@danielx/civet 0.6.16 → 0.6.17

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
@@ -946,6 +946,9 @@ var Civet = (() => {
946
946
  function isVoidType(t) {
947
947
  return t?.type === "LiteralType" && t.t.type === "VoidType";
948
948
  }
949
+ function isPromiseVoidType(t) {
950
+ return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
951
+ }
949
952
  function isWhitespaceOrEmpty(node) {
950
953
  if (!node)
951
954
  return true;
@@ -1391,8 +1394,8 @@ var Civet = (() => {
1391
1394
  implicitFunctionBlock(f);
1392
1395
  processParams(f);
1393
1396
  if (!processReturnValue(f) && config.implicitReturns) {
1394
- const { block, returnType } = f;
1395
- const isVoid = isVoidType(returnType?.t);
1397
+ const { async, block, returnType } = f;
1398
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
1396
1399
  const isBlock = block?.type === "BlockStatement";
1397
1400
  if (!isVoid && isBlock) {
1398
1401
  insertReturn(block);
@@ -2114,7 +2117,7 @@ var Civet = (() => {
2114
2117
  if (!hasDec(x))
2115
2118
  return a.indexOf(x) === i;
2116
2119
  }).forEach(pushVar);
2117
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2120
+ const fnNodes = gatherNodes(statements, isFunction);
2118
2121
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2119
2122
  const blockNodes = new Set(gatherNodes(statements, (s) => s.type === "BlockStatement"));
2120
2123
  fnNodes.forEach(({ block }) => blockNodes.delete(block));
@@ -2166,7 +2169,7 @@ var Civet = (() => {
2166
2169
  }
2167
2170
  let currentScope = /* @__PURE__ */ new Set();
2168
2171
  scopes.push(currentScope);
2169
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2172
+ const fnNodes = gatherNodes(statements, isFunction);
2170
2173
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2171
2174
  let targetStatements = [];
2172
2175
  for (const statement of statements) {
@@ -2999,6 +3002,7 @@ ${input.slice(result.pos)}
2999
3002
  NonPipelineArgumentPart,
3000
3003
  BinaryOpExpression,
3001
3004
  BinaryOpRHS,
3005
+ WRHS,
3002
3006
  SingleLineBinaryOpRHS,
3003
3007
  RHS,
3004
3008
  ParenthesizedAssignment,
@@ -3108,6 +3112,8 @@ ${input.slice(result.pos)}
3108
3112
  ExplicitBlock,
3109
3113
  ImplicitNestedBlock,
3110
3114
  Block,
3115
+ BareNestedBlock,
3116
+ BareBlock,
3111
3117
  ThenClause,
3112
3118
  BracedOrEmptyBlock,
3113
3119
  NoPostfixBracedOrEmptyBlock,
@@ -3232,7 +3238,9 @@ ${input.slice(result.pos)}
3232
3238
  PatternExpressionList,
3233
3239
  ConditionFragment,
3234
3240
  CaseExpressionList,
3241
+ CaseExpression,
3235
3242
  ImpliedColon,
3243
+ IgnoreColon,
3236
3244
  TryStatement,
3237
3245
  TryExpression,
3238
3246
  CatchClause,
@@ -3575,6 +3583,7 @@ ${input.slice(result.pos)}
3575
3583
  EOS,
3576
3584
  EOL,
3577
3585
  DebugHere,
3586
+ InsertColon,
3578
3587
  InsertSemicolon,
3579
3588
  InsertOpenParen,
3580
3589
  InsertCloseParen,
@@ -4806,9 +4815,10 @@ ${input.slice(result.pos)}
4806
4815
  var rhs = $2;
4807
4816
  return [[], op, [], rhs];
4808
4817
  });
4809
- var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, $S(NotDedentedBinaryOp, $C(_, $S(EOS, __)), RHS)), function($skip, $loc, $0, $1, $2) {
4810
- var rhs = $2;
4811
- return [...rhs[0], ...rhs.slice(1)];
4818
+ var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
4819
+ var op = $2;
4820
+ var rhs = $3;
4821
+ return [...op, ...rhs];
4812
4822
  });
4813
4823
  var BinaryOpRHS$2 = $T($S($N(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
4814
4824
  return value[1];
@@ -4835,6 +4845,35 @@ ${input.slice(result.pos)}
4835
4845
  return result;
4836
4846
  }
4837
4847
  }
4848
+ var WRHS$0 = $TS($S(PushIndent, $E($S(Nested, RHS)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
4849
+ var wrhs = $2;
4850
+ if (!wrhs)
4851
+ return $skip;
4852
+ return wrhs;
4853
+ });
4854
+ var WRHS$1 = $S($C(_, $S(EOS, __)), RHS);
4855
+ function WRHS(state) {
4856
+ let eventData;
4857
+ if (state.events) {
4858
+ const result = state.events.enter?.("WRHS", state);
4859
+ if (result) {
4860
+ if (result.cache)
4861
+ return result.cache;
4862
+ eventData = result.data;
4863
+ }
4864
+ }
4865
+ if (state.tokenize) {
4866
+ const result = $TOKEN("WRHS", state, WRHS$0(state) || WRHS$1(state));
4867
+ if (state.events)
4868
+ state.events.exit?.("WRHS", state, result, eventData);
4869
+ return result;
4870
+ } else {
4871
+ const result = WRHS$0(state) || WRHS$1(state);
4872
+ if (state.events)
4873
+ state.events.exit?.("WRHS", state, result, eventData);
4874
+ return result;
4875
+ }
4876
+ }
4838
4877
  var SingleLineBinaryOpRHS$0 = $TS($S($E(_), BinaryOp, $C(_, $S(EOS, __)), RHS), function($skip, $loc, $0, $1, $2, $3, $4) {
4839
4878
  var ws1 = $1;
4840
4879
  var op = $2;
@@ -5541,8 +5580,8 @@ ${input.slice(result.pos)}
5541
5580
  var PrimaryExpression$2 = TemplateLiteral;
5542
5581
  var PrimaryExpression$3 = Literal;
5543
5582
  var PrimaryExpression$4 = ArrayLiteral;
5544
- var PrimaryExpression$5 = IdentifierReference;
5545
- var PrimaryExpression$6 = FunctionExpression;
5583
+ var PrimaryExpression$5 = FunctionExpression;
5584
+ var PrimaryExpression$6 = IdentifierReference;
5546
5585
  var PrimaryExpression$7 = ClassExpression;
5547
5586
  var PrimaryExpression$8 = RegularExpressionLiteral;
5548
5587
  var PrimaryExpression$9 = ParenthesizedExpression;
@@ -8468,6 +8507,70 @@ ${input.slice(result.pos)}
8468
8507
  return result;
8469
8508
  }
8470
8509
  }
8510
+ var BareNestedBlock$0 = $TS($S($Y(EOS), AllowAll, $E(NestedBlockStatements), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
8511
+ if (!$3)
8512
+ return $skip;
8513
+ return $3;
8514
+ });
8515
+ function BareNestedBlock(state) {
8516
+ let eventData;
8517
+ if (state.events) {
8518
+ const result = state.events.enter?.("BareNestedBlock", state);
8519
+ if (result) {
8520
+ if (result.cache)
8521
+ return result.cache;
8522
+ eventData = result.data;
8523
+ }
8524
+ }
8525
+ if (state.tokenize) {
8526
+ const result = $TOKEN("BareNestedBlock", state, BareNestedBlock$0(state));
8527
+ if (state.events)
8528
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8529
+ return result;
8530
+ } else {
8531
+ const result = BareNestedBlock$0(state);
8532
+ if (state.events)
8533
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8534
+ return result;
8535
+ }
8536
+ }
8537
+ var BareBlock$0 = BareNestedBlock;
8538
+ var BareBlock$1 = ExplicitBlock;
8539
+ var BareBlock$2 = ThenClause;
8540
+ var BareBlock$3 = $TS($S($E(_), $N(EOS), Statement), function($skip, $loc, $0, $1, $2, $3) {
8541
+ var ws = $1;
8542
+ var s = $3;
8543
+ const expressions = [[ws, s]];
8544
+ return {
8545
+ type: "BlockStatement",
8546
+ expressions,
8547
+ children: [expressions],
8548
+ bare: true
8549
+ };
8550
+ });
8551
+ var BareBlock$4 = EmptyBareBlock;
8552
+ function BareBlock(state) {
8553
+ let eventData;
8554
+ if (state.events) {
8555
+ const result = state.events.enter?.("BareBlock", state);
8556
+ if (result) {
8557
+ if (result.cache)
8558
+ return result.cache;
8559
+ eventData = result.data;
8560
+ }
8561
+ }
8562
+ if (state.tokenize) {
8563
+ const result = $TOKEN("BareBlock", state, BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state));
8564
+ if (state.events)
8565
+ state.events.exit?.("BareBlock", state, result, eventData);
8566
+ return result;
8567
+ } else {
8568
+ const result = BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state);
8569
+ if (state.events)
8570
+ state.events.exit?.("BareBlock", state, result, eventData);
8571
+ return result;
8572
+ }
8573
+ }
8471
8574
  var ThenClause$0 = $T($S(Then, SingleLineStatements), function(value) {
8472
8575
  return value[1];
8473
8576
  });
@@ -10218,13 +10321,17 @@ ${input.slice(result.pos)}
10218
10321
  return {
10219
10322
  type: "ComputedPropertyName",
10220
10323
  children: $0,
10221
- expression
10324
+ expression,
10325
+ implicit: true
10222
10326
  };
10223
10327
  });
10224
10328
  var ComputedPropertyName$2 = $TS($S(InsertOpenBracket, $EXPECT($L20, fail, 'ComputedPropertyName "-"'), NumericLiteral, InsertCloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
10329
+ const expression = [$2, $3];
10225
10330
  return {
10226
10331
  type: "ComputedPropertyName",
10227
- children: $0
10332
+ expression,
10333
+ children: [$1, expression, $4],
10334
+ implicit: true
10228
10335
  };
10229
10336
  });
10230
10337
  function ComputedPropertyName(state) {
@@ -12852,7 +12959,7 @@ ${input.slice(result.pos)}
12852
12959
  return result;
12853
12960
  }
12854
12961
  }
12855
- var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
12962
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2) {
12856
12963
  var patterns = $1;
12857
12964
  var block = $2;
12858
12965
  return {
@@ -12862,13 +12969,13 @@ ${input.slice(result.pos)}
12862
12969
  patterns
12863
12970
  };
12864
12971
  });
12865
- var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
12972
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, IgnoreColon, $C(ThenClause, BareBlock)), function(value) {
12866
12973
  return { "type": "CaseClause", "children": value };
12867
12974
  });
12868
- 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) {
12975
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, IgnoreColon, InsertOpenBrace, $C(ThenClause, BareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12869
12976
  var cases = $2;
12870
- var block = $4;
12871
- var b = $5;
12977
+ var block = $5;
12978
+ var b = $6;
12872
12979
  return {
12873
12980
  type: "WhenClause",
12874
12981
  cases,
@@ -12877,7 +12984,7 @@ ${input.slice(result.pos)}
12877
12984
  children: $0
12878
12985
  };
12879
12986
  });
12880
- var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12987
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12881
12988
  var block = $3;
12882
12989
  return {
12883
12990
  type: "DefaultClause",
@@ -12973,7 +13080,7 @@ ${input.slice(result.pos)}
12973
13080
  return result;
12974
13081
  }
12975
13082
  }
12976
- var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithObjectApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithObjectApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
13083
+ var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($E(_), CaseExpression, InsertColon)), $Q($S(__, Comma, CaseExpression, InsertColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
12977
13084
  var first = $2;
12978
13085
  var rest = $3;
12979
13086
  if (!first)
@@ -13009,10 +13116,40 @@ ${input.slice(result.pos)}
13009
13116
  return result;
13010
13117
  }
13011
13118
  }
13012
- var ImpliedColon$0 = $S($E(_), Colon);
13013
- var ImpliedColon$1 = $TV($EXPECT($L0, fail, 'ImpliedColon ""'), function($skip, $loc, $0, $1) {
13014
- return { $loc, token: ":" };
13119
+ var CaseExpression$0 = $TS($S(PropertyName, $Y($S($E(_), Colon))), function($skip, $loc, $0, $1, $2) {
13120
+ var value = $1;
13121
+ if (value.type === "ComputedPropertyName") {
13122
+ if (value.implicit)
13123
+ return value.expression;
13124
+ return { ...value, type: "ArrayExpression" };
13125
+ }
13126
+ return value;
13015
13127
  });
13128
+ var CaseExpression$1 = ExpressionWithObjectApplicationForbidden;
13129
+ function CaseExpression(state) {
13130
+ let eventData;
13131
+ if (state.events) {
13132
+ const result = state.events.enter?.("CaseExpression", state);
13133
+ if (result) {
13134
+ if (result.cache)
13135
+ return result.cache;
13136
+ eventData = result.data;
13137
+ }
13138
+ }
13139
+ if (state.tokenize) {
13140
+ const result = $TOKEN("CaseExpression", state, CaseExpression$0(state) || CaseExpression$1(state));
13141
+ if (state.events)
13142
+ state.events.exit?.("CaseExpression", state, result, eventData);
13143
+ return result;
13144
+ } else {
13145
+ const result = CaseExpression$0(state) || CaseExpression$1(state);
13146
+ if (state.events)
13147
+ state.events.exit?.("CaseExpression", state, result, eventData);
13148
+ return result;
13149
+ }
13150
+ }
13151
+ var ImpliedColon$0 = $S($E(_), Colon);
13152
+ var ImpliedColon$1 = InsertColon;
13016
13153
  function ImpliedColon(state) {
13017
13154
  let eventData;
13018
13155
  if (state.events) {
@@ -13035,6 +13172,32 @@ ${input.slice(result.pos)}
13035
13172
  return result;
13036
13173
  }
13037
13174
  }
13175
+ var IgnoreColon$0 = $TV($E($S($E(_), Colon)), function($skip, $loc, $0, $1) {
13176
+ if ($1)
13177
+ return $1[0];
13178
+ });
13179
+ function IgnoreColon(state) {
13180
+ let eventData;
13181
+ if (state.events) {
13182
+ const result = state.events.enter?.("IgnoreColon", state);
13183
+ if (result) {
13184
+ if (result.cache)
13185
+ return result.cache;
13186
+ eventData = result.data;
13187
+ }
13188
+ }
13189
+ if (state.tokenize) {
13190
+ const result = $TOKEN("IgnoreColon", state, IgnoreColon$0(state));
13191
+ if (state.events)
13192
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13193
+ return result;
13194
+ } else {
13195
+ const result = IgnoreColon$0(state);
13196
+ if (state.events)
13197
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13198
+ return result;
13199
+ }
13200
+ }
13038
13201
  var TryStatement$0 = $TS($S(Try, $N($EXPECT($L12, fail, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, $E(CatchClause), $E(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13039
13202
  var t = $1;
13040
13203
  var b = $3;
@@ -22112,7 +22275,8 @@ ${input.slice(result.pos)}
22112
22275
  }
22113
22276
  }
22114
22277
  var TypeArguments$0 = $TS($S($EXPECT($L155, fail, 'TypeArguments "<"'), $P(TypeArgument), __, $EXPECT($L34, fail, 'TypeArguments ">"')), function($skip, $loc, $0, $1, $2, $3, $4) {
22115
- return { ts: true, children: $0 };
22278
+ var args = $2;
22279
+ return { ts: true, types: args.map(([, t]) => t), children: $0 };
22116
22280
  });
22117
22281
  function TypeArguments(state) {
22118
22282
  let eventData;
@@ -22573,6 +22737,31 @@ ${input.slice(result.pos)}
22573
22737
  return result;
22574
22738
  }
22575
22739
  }
22740
+ var InsertColon$0 = $TV($EXPECT($L0, fail, 'InsertColon ""'), function($skip, $loc, $0, $1) {
22741
+ return { $loc, token: ":" };
22742
+ });
22743
+ function InsertColon(state) {
22744
+ let eventData;
22745
+ if (state.events) {
22746
+ const result = state.events.enter?.("InsertColon", state);
22747
+ if (result) {
22748
+ if (result.cache)
22749
+ return result.cache;
22750
+ eventData = result.data;
22751
+ }
22752
+ }
22753
+ if (state.tokenize) {
22754
+ const result = $TOKEN("InsertColon", state, InsertColon$0(state));
22755
+ if (state.events)
22756
+ state.events.exit?.("InsertColon", state, result, eventData);
22757
+ return result;
22758
+ } else {
22759
+ const result = InsertColon$0(state);
22760
+ if (state.events)
22761
+ state.events.exit?.("InsertColon", state, result, eventData);
22762
+ return result;
22763
+ }
22764
+ }
22576
22765
  var InsertSemicolon$0 = $TV($EXPECT($L0, fail, 'InsertSemicolon ""'), function($skip, $loc, $0, $1) {
22577
22766
  return { $loc, token: ";" };
22578
22767
  });
package/dist/main.js CHANGED
@@ -945,6 +945,9 @@ var require_lib = __commonJS({
945
945
  function isVoidType(t) {
946
946
  return t?.type === "LiteralType" && t.t.type === "VoidType";
947
947
  }
948
+ function isPromiseVoidType(t) {
949
+ return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
950
+ }
948
951
  function isWhitespaceOrEmpty(node) {
949
952
  if (!node)
950
953
  return true;
@@ -1390,8 +1393,8 @@ var require_lib = __commonJS({
1390
1393
  implicitFunctionBlock(f);
1391
1394
  processParams(f);
1392
1395
  if (!processReturnValue(f) && config.implicitReturns) {
1393
- const { block, returnType } = f;
1394
- const isVoid = isVoidType(returnType?.t);
1396
+ const { async, block, returnType } = f;
1397
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
1395
1398
  const isBlock = block?.type === "BlockStatement";
1396
1399
  if (!isVoid && isBlock) {
1397
1400
  insertReturn(block);
@@ -2113,7 +2116,7 @@ var require_lib = __commonJS({
2113
2116
  if (!hasDec(x))
2114
2117
  return a.indexOf(x) === i;
2115
2118
  }).forEach(pushVar);
2116
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2119
+ const fnNodes = gatherNodes(statements, isFunction);
2117
2120
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2118
2121
  const blockNodes = new Set(gatherNodes(statements, (s) => s.type === "BlockStatement"));
2119
2122
  fnNodes.forEach(({ block }) => blockNodes.delete(block));
@@ -2165,7 +2168,7 @@ var require_lib = __commonJS({
2165
2168
  }
2166
2169
  let currentScope = /* @__PURE__ */ new Set();
2167
2170
  scopes.push(currentScope);
2168
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2171
+ const fnNodes = gatherNodes(statements, isFunction);
2169
2172
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2170
2173
  let targetStatements = [];
2171
2174
  for (const statement of statements) {
@@ -2998,6 +3001,7 @@ ${input.slice(result.pos)}
2998
3001
  NonPipelineArgumentPart,
2999
3002
  BinaryOpExpression,
3000
3003
  BinaryOpRHS,
3004
+ WRHS,
3001
3005
  SingleLineBinaryOpRHS,
3002
3006
  RHS,
3003
3007
  ParenthesizedAssignment,
@@ -3107,6 +3111,8 @@ ${input.slice(result.pos)}
3107
3111
  ExplicitBlock,
3108
3112
  ImplicitNestedBlock,
3109
3113
  Block,
3114
+ BareNestedBlock,
3115
+ BareBlock,
3110
3116
  ThenClause,
3111
3117
  BracedOrEmptyBlock,
3112
3118
  NoPostfixBracedOrEmptyBlock,
@@ -3231,7 +3237,9 @@ ${input.slice(result.pos)}
3231
3237
  PatternExpressionList,
3232
3238
  ConditionFragment,
3233
3239
  CaseExpressionList,
3240
+ CaseExpression,
3234
3241
  ImpliedColon,
3242
+ IgnoreColon,
3235
3243
  TryStatement,
3236
3244
  TryExpression,
3237
3245
  CatchClause,
@@ -3574,6 +3582,7 @@ ${input.slice(result.pos)}
3574
3582
  EOS,
3575
3583
  EOL,
3576
3584
  DebugHere,
3585
+ InsertColon,
3577
3586
  InsertSemicolon,
3578
3587
  InsertOpenParen,
3579
3588
  InsertCloseParen,
@@ -4805,9 +4814,10 @@ ${input.slice(result.pos)}
4805
4814
  var rhs = $2;
4806
4815
  return [[], op, [], rhs];
4807
4816
  });
4808
- var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, $S(NotDedentedBinaryOp, $C(_, $S(EOS, __)), RHS)), function($skip, $loc, $0, $1, $2) {
4809
- var rhs = $2;
4810
- return [...rhs[0], ...rhs.slice(1)];
4817
+ var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
4818
+ var op = $2;
4819
+ var rhs = $3;
4820
+ return [...op, ...rhs];
4811
4821
  });
4812
4822
  var BinaryOpRHS$2 = $T($S($N(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
4813
4823
  return value[1];
@@ -4834,6 +4844,35 @@ ${input.slice(result.pos)}
4834
4844
  return result;
4835
4845
  }
4836
4846
  }
4847
+ var WRHS$0 = $TS($S(PushIndent, $E($S(Nested, RHS)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
4848
+ var wrhs = $2;
4849
+ if (!wrhs)
4850
+ return $skip;
4851
+ return wrhs;
4852
+ });
4853
+ var WRHS$1 = $S($C(_, $S(EOS, __)), RHS);
4854
+ function WRHS(state) {
4855
+ let eventData;
4856
+ if (state.events) {
4857
+ const result = state.events.enter?.("WRHS", state);
4858
+ if (result) {
4859
+ if (result.cache)
4860
+ return result.cache;
4861
+ eventData = result.data;
4862
+ }
4863
+ }
4864
+ if (state.tokenize) {
4865
+ const result = $TOKEN("WRHS", state, WRHS$0(state) || WRHS$1(state));
4866
+ if (state.events)
4867
+ state.events.exit?.("WRHS", state, result, eventData);
4868
+ return result;
4869
+ } else {
4870
+ const result = WRHS$0(state) || WRHS$1(state);
4871
+ if (state.events)
4872
+ state.events.exit?.("WRHS", state, result, eventData);
4873
+ return result;
4874
+ }
4875
+ }
4837
4876
  var SingleLineBinaryOpRHS$0 = $TS($S($E(_), BinaryOp, $C(_, $S(EOS, __)), RHS), function($skip, $loc, $0, $1, $2, $3, $4) {
4838
4877
  var ws1 = $1;
4839
4878
  var op = $2;
@@ -5540,8 +5579,8 @@ ${input.slice(result.pos)}
5540
5579
  var PrimaryExpression$2 = TemplateLiteral;
5541
5580
  var PrimaryExpression$3 = Literal;
5542
5581
  var PrimaryExpression$4 = ArrayLiteral;
5543
- var PrimaryExpression$5 = IdentifierReference;
5544
- var PrimaryExpression$6 = FunctionExpression;
5582
+ var PrimaryExpression$5 = FunctionExpression;
5583
+ var PrimaryExpression$6 = IdentifierReference;
5545
5584
  var PrimaryExpression$7 = ClassExpression;
5546
5585
  var PrimaryExpression$8 = RegularExpressionLiteral;
5547
5586
  var PrimaryExpression$9 = ParenthesizedExpression;
@@ -8467,6 +8506,70 @@ ${input.slice(result.pos)}
8467
8506
  return result;
8468
8507
  }
8469
8508
  }
8509
+ var BareNestedBlock$0 = $TS($S($Y(EOS), AllowAll, $E(NestedBlockStatements), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
8510
+ if (!$3)
8511
+ return $skip;
8512
+ return $3;
8513
+ });
8514
+ function BareNestedBlock(state) {
8515
+ let eventData;
8516
+ if (state.events) {
8517
+ const result = state.events.enter?.("BareNestedBlock", state);
8518
+ if (result) {
8519
+ if (result.cache)
8520
+ return result.cache;
8521
+ eventData = result.data;
8522
+ }
8523
+ }
8524
+ if (state.tokenize) {
8525
+ const result = $TOKEN("BareNestedBlock", state, BareNestedBlock$0(state));
8526
+ if (state.events)
8527
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8528
+ return result;
8529
+ } else {
8530
+ const result = BareNestedBlock$0(state);
8531
+ if (state.events)
8532
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8533
+ return result;
8534
+ }
8535
+ }
8536
+ var BareBlock$0 = BareNestedBlock;
8537
+ var BareBlock$1 = ExplicitBlock;
8538
+ var BareBlock$2 = ThenClause;
8539
+ var BareBlock$3 = $TS($S($E(_), $N(EOS), Statement), function($skip, $loc, $0, $1, $2, $3) {
8540
+ var ws = $1;
8541
+ var s = $3;
8542
+ const expressions = [[ws, s]];
8543
+ return {
8544
+ type: "BlockStatement",
8545
+ expressions,
8546
+ children: [expressions],
8547
+ bare: true
8548
+ };
8549
+ });
8550
+ var BareBlock$4 = EmptyBareBlock;
8551
+ function BareBlock(state) {
8552
+ let eventData;
8553
+ if (state.events) {
8554
+ const result = state.events.enter?.("BareBlock", state);
8555
+ if (result) {
8556
+ if (result.cache)
8557
+ return result.cache;
8558
+ eventData = result.data;
8559
+ }
8560
+ }
8561
+ if (state.tokenize) {
8562
+ const result = $TOKEN("BareBlock", state, BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state));
8563
+ if (state.events)
8564
+ state.events.exit?.("BareBlock", state, result, eventData);
8565
+ return result;
8566
+ } else {
8567
+ const result = BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state);
8568
+ if (state.events)
8569
+ state.events.exit?.("BareBlock", state, result, eventData);
8570
+ return result;
8571
+ }
8572
+ }
8470
8573
  var ThenClause$0 = $T($S(Then, SingleLineStatements), function(value) {
8471
8574
  return value[1];
8472
8575
  });
@@ -10217,13 +10320,17 @@ ${input.slice(result.pos)}
10217
10320
  return {
10218
10321
  type: "ComputedPropertyName",
10219
10322
  children: $0,
10220
- expression
10323
+ expression,
10324
+ implicit: true
10221
10325
  };
10222
10326
  });
10223
10327
  var ComputedPropertyName$2 = $TS($S(InsertOpenBracket, $EXPECT($L20, fail, 'ComputedPropertyName "-"'), NumericLiteral, InsertCloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
10328
+ const expression = [$2, $3];
10224
10329
  return {
10225
10330
  type: "ComputedPropertyName",
10226
- children: $0
10331
+ expression,
10332
+ children: [$1, expression, $4],
10333
+ implicit: true
10227
10334
  };
10228
10335
  });
10229
10336
  function ComputedPropertyName(state) {
@@ -12851,7 +12958,7 @@ ${input.slice(result.pos)}
12851
12958
  return result;
12852
12959
  }
12853
12960
  }
12854
- var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
12961
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2) {
12855
12962
  var patterns = $1;
12856
12963
  var block = $2;
12857
12964
  return {
@@ -12861,13 +12968,13 @@ ${input.slice(result.pos)}
12861
12968
  patterns
12862
12969
  };
12863
12970
  });
12864
- var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
12971
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, IgnoreColon, $C(ThenClause, BareBlock)), function(value) {
12865
12972
  return { "type": "CaseClause", "children": value };
12866
12973
  });
12867
- 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) {
12974
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, IgnoreColon, InsertOpenBrace, $C(ThenClause, BareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12868
12975
  var cases = $2;
12869
- var block = $4;
12870
- var b = $5;
12976
+ var block = $5;
12977
+ var b = $6;
12871
12978
  return {
12872
12979
  type: "WhenClause",
12873
12980
  cases,
@@ -12876,7 +12983,7 @@ ${input.slice(result.pos)}
12876
12983
  children: $0
12877
12984
  };
12878
12985
  });
12879
- var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12986
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12880
12987
  var block = $3;
12881
12988
  return {
12882
12989
  type: "DefaultClause",
@@ -12972,7 +13079,7 @@ ${input.slice(result.pos)}
12972
13079
  return result;
12973
13080
  }
12974
13081
  }
12975
- var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithObjectApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithObjectApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
13082
+ var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($E(_), CaseExpression, InsertColon)), $Q($S(__, Comma, CaseExpression, InsertColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
12976
13083
  var first = $2;
12977
13084
  var rest = $3;
12978
13085
  if (!first)
@@ -13008,10 +13115,40 @@ ${input.slice(result.pos)}
13008
13115
  return result;
13009
13116
  }
13010
13117
  }
13011
- var ImpliedColon$0 = $S($E(_), Colon);
13012
- var ImpliedColon$1 = $TV($EXPECT($L0, fail, 'ImpliedColon ""'), function($skip, $loc, $0, $1) {
13013
- return { $loc, token: ":" };
13118
+ var CaseExpression$0 = $TS($S(PropertyName, $Y($S($E(_), Colon))), function($skip, $loc, $0, $1, $2) {
13119
+ var value = $1;
13120
+ if (value.type === "ComputedPropertyName") {
13121
+ if (value.implicit)
13122
+ return value.expression;
13123
+ return { ...value, type: "ArrayExpression" };
13124
+ }
13125
+ return value;
13014
13126
  });
13127
+ var CaseExpression$1 = ExpressionWithObjectApplicationForbidden;
13128
+ function CaseExpression(state) {
13129
+ let eventData;
13130
+ if (state.events) {
13131
+ const result = state.events.enter?.("CaseExpression", state);
13132
+ if (result) {
13133
+ if (result.cache)
13134
+ return result.cache;
13135
+ eventData = result.data;
13136
+ }
13137
+ }
13138
+ if (state.tokenize) {
13139
+ const result = $TOKEN("CaseExpression", state, CaseExpression$0(state) || CaseExpression$1(state));
13140
+ if (state.events)
13141
+ state.events.exit?.("CaseExpression", state, result, eventData);
13142
+ return result;
13143
+ } else {
13144
+ const result = CaseExpression$0(state) || CaseExpression$1(state);
13145
+ if (state.events)
13146
+ state.events.exit?.("CaseExpression", state, result, eventData);
13147
+ return result;
13148
+ }
13149
+ }
13150
+ var ImpliedColon$0 = $S($E(_), Colon);
13151
+ var ImpliedColon$1 = InsertColon;
13015
13152
  function ImpliedColon(state) {
13016
13153
  let eventData;
13017
13154
  if (state.events) {
@@ -13034,6 +13171,32 @@ ${input.slice(result.pos)}
13034
13171
  return result;
13035
13172
  }
13036
13173
  }
13174
+ var IgnoreColon$0 = $TV($E($S($E(_), Colon)), function($skip, $loc, $0, $1) {
13175
+ if ($1)
13176
+ return $1[0];
13177
+ });
13178
+ function IgnoreColon(state) {
13179
+ let eventData;
13180
+ if (state.events) {
13181
+ const result = state.events.enter?.("IgnoreColon", state);
13182
+ if (result) {
13183
+ if (result.cache)
13184
+ return result.cache;
13185
+ eventData = result.data;
13186
+ }
13187
+ }
13188
+ if (state.tokenize) {
13189
+ const result = $TOKEN("IgnoreColon", state, IgnoreColon$0(state));
13190
+ if (state.events)
13191
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13192
+ return result;
13193
+ } else {
13194
+ const result = IgnoreColon$0(state);
13195
+ if (state.events)
13196
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13197
+ return result;
13198
+ }
13199
+ }
13037
13200
  var TryStatement$0 = $TS($S(Try, $N($EXPECT($L12, fail, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, $E(CatchClause), $E(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13038
13201
  var t = $1;
13039
13202
  var b = $3;
@@ -22111,7 +22274,8 @@ ${input.slice(result.pos)}
22111
22274
  }
22112
22275
  }
22113
22276
  var TypeArguments$0 = $TS($S($EXPECT($L155, fail, 'TypeArguments "<"'), $P(TypeArgument), __, $EXPECT($L34, fail, 'TypeArguments ">"')), function($skip, $loc, $0, $1, $2, $3, $4) {
22114
- return { ts: true, children: $0 };
22277
+ var args = $2;
22278
+ return { ts: true, types: args.map(([, t]) => t), children: $0 };
22115
22279
  });
22116
22280
  function TypeArguments(state) {
22117
22281
  let eventData;
@@ -22572,6 +22736,31 @@ ${input.slice(result.pos)}
22572
22736
  return result;
22573
22737
  }
22574
22738
  }
22739
+ var InsertColon$0 = $TV($EXPECT($L0, fail, 'InsertColon ""'), function($skip, $loc, $0, $1) {
22740
+ return { $loc, token: ":" };
22741
+ });
22742
+ function InsertColon(state) {
22743
+ let eventData;
22744
+ if (state.events) {
22745
+ const result = state.events.enter?.("InsertColon", state);
22746
+ if (result) {
22747
+ if (result.cache)
22748
+ return result.cache;
22749
+ eventData = result.data;
22750
+ }
22751
+ }
22752
+ if (state.tokenize) {
22753
+ const result = $TOKEN("InsertColon", state, InsertColon$0(state));
22754
+ if (state.events)
22755
+ state.events.exit?.("InsertColon", state, result, eventData);
22756
+ return result;
22757
+ } else {
22758
+ const result = InsertColon$0(state);
22759
+ if (state.events)
22760
+ state.events.exit?.("InsertColon", state, result, eventData);
22761
+ return result;
22762
+ }
22763
+ }
22575
22764
  var InsertSemicolon$0 = $TV($EXPECT($L0, fail, 'InsertSemicolon ""'), function($skip, $loc, $0, $1) {
22576
22765
  return { $loc, token: ";" };
22577
22766
  });
package/dist/main.mjs CHANGED
@@ -943,6 +943,9 @@ var require_lib = __commonJS({
943
943
  function isVoidType(t) {
944
944
  return t?.type === "LiteralType" && t.t.type === "VoidType";
945
945
  }
946
+ function isPromiseVoidType(t) {
947
+ return t?.type === "IdentifierType" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
948
+ }
946
949
  function isWhitespaceOrEmpty(node) {
947
950
  if (!node)
948
951
  return true;
@@ -1388,8 +1391,8 @@ var require_lib = __commonJS({
1388
1391
  implicitFunctionBlock(f);
1389
1392
  processParams(f);
1390
1393
  if (!processReturnValue(f) && config.implicitReturns) {
1391
- const { block, returnType } = f;
1392
- const isVoid = isVoidType(returnType?.t);
1394
+ const { async, block, returnType } = f;
1395
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
1393
1396
  const isBlock = block?.type === "BlockStatement";
1394
1397
  if (!isVoid && isBlock) {
1395
1398
  insertReturn(block);
@@ -2111,7 +2114,7 @@ var require_lib = __commonJS({
2111
2114
  if (!hasDec(x))
2112
2115
  return a.indexOf(x) === i;
2113
2116
  }).forEach(pushVar);
2114
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2117
+ const fnNodes = gatherNodes(statements, isFunction);
2115
2118
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2116
2119
  const blockNodes = new Set(gatherNodes(statements, (s) => s.type === "BlockStatement"));
2117
2120
  fnNodes.forEach(({ block }) => blockNodes.delete(block));
@@ -2163,7 +2166,7 @@ var require_lib = __commonJS({
2163
2166
  }
2164
2167
  let currentScope = /* @__PURE__ */ new Set();
2165
2168
  scopes.push(currentScope);
2166
- const fnNodes = gatherNodes(statements, (s) => s.type === "FunctionExpression");
2169
+ const fnNodes = gatherNodes(statements, isFunction);
2167
2170
  const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
2168
2171
  let targetStatements = [];
2169
2172
  for (const statement of statements) {
@@ -2996,6 +2999,7 @@ ${input.slice(result.pos)}
2996
2999
  NonPipelineArgumentPart,
2997
3000
  BinaryOpExpression,
2998
3001
  BinaryOpRHS,
3002
+ WRHS,
2999
3003
  SingleLineBinaryOpRHS,
3000
3004
  RHS,
3001
3005
  ParenthesizedAssignment,
@@ -3105,6 +3109,8 @@ ${input.slice(result.pos)}
3105
3109
  ExplicitBlock,
3106
3110
  ImplicitNestedBlock,
3107
3111
  Block,
3112
+ BareNestedBlock,
3113
+ BareBlock,
3108
3114
  ThenClause,
3109
3115
  BracedOrEmptyBlock,
3110
3116
  NoPostfixBracedOrEmptyBlock,
@@ -3229,7 +3235,9 @@ ${input.slice(result.pos)}
3229
3235
  PatternExpressionList,
3230
3236
  ConditionFragment,
3231
3237
  CaseExpressionList,
3238
+ CaseExpression,
3232
3239
  ImpliedColon,
3240
+ IgnoreColon,
3233
3241
  TryStatement,
3234
3242
  TryExpression,
3235
3243
  CatchClause,
@@ -3572,6 +3580,7 @@ ${input.slice(result.pos)}
3572
3580
  EOS,
3573
3581
  EOL,
3574
3582
  DebugHere,
3583
+ InsertColon,
3575
3584
  InsertSemicolon,
3576
3585
  InsertOpenParen,
3577
3586
  InsertCloseParen,
@@ -4803,9 +4812,10 @@ ${input.slice(result.pos)}
4803
4812
  var rhs = $2;
4804
4813
  return [[], op, [], rhs];
4805
4814
  });
4806
- var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, $S(NotDedentedBinaryOp, $C(_, $S(EOS, __)), RHS)), function($skip, $loc, $0, $1, $2) {
4807
- var rhs = $2;
4808
- return [...rhs[0], ...rhs.slice(1)];
4815
+ var BinaryOpRHS$1 = $TS($S(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
4816
+ var op = $2;
4817
+ var rhs = $3;
4818
+ return [...op, ...rhs];
4809
4819
  });
4810
4820
  var BinaryOpRHS$2 = $T($S($N(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
4811
4821
  return value[1];
@@ -4832,6 +4842,35 @@ ${input.slice(result.pos)}
4832
4842
  return result;
4833
4843
  }
4834
4844
  }
4845
+ var WRHS$0 = $TS($S(PushIndent, $E($S(Nested, RHS)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
4846
+ var wrhs = $2;
4847
+ if (!wrhs)
4848
+ return $skip;
4849
+ return wrhs;
4850
+ });
4851
+ var WRHS$1 = $S($C(_, $S(EOS, __)), RHS);
4852
+ function WRHS(state) {
4853
+ let eventData;
4854
+ if (state.events) {
4855
+ const result = state.events.enter?.("WRHS", state);
4856
+ if (result) {
4857
+ if (result.cache)
4858
+ return result.cache;
4859
+ eventData = result.data;
4860
+ }
4861
+ }
4862
+ if (state.tokenize) {
4863
+ const result = $TOKEN("WRHS", state, WRHS$0(state) || WRHS$1(state));
4864
+ if (state.events)
4865
+ state.events.exit?.("WRHS", state, result, eventData);
4866
+ return result;
4867
+ } else {
4868
+ const result = WRHS$0(state) || WRHS$1(state);
4869
+ if (state.events)
4870
+ state.events.exit?.("WRHS", state, result, eventData);
4871
+ return result;
4872
+ }
4873
+ }
4835
4874
  var SingleLineBinaryOpRHS$0 = $TS($S($E(_), BinaryOp, $C(_, $S(EOS, __)), RHS), function($skip, $loc, $0, $1, $2, $3, $4) {
4836
4875
  var ws1 = $1;
4837
4876
  var op = $2;
@@ -5538,8 +5577,8 @@ ${input.slice(result.pos)}
5538
5577
  var PrimaryExpression$2 = TemplateLiteral;
5539
5578
  var PrimaryExpression$3 = Literal;
5540
5579
  var PrimaryExpression$4 = ArrayLiteral;
5541
- var PrimaryExpression$5 = IdentifierReference;
5542
- var PrimaryExpression$6 = FunctionExpression;
5580
+ var PrimaryExpression$5 = FunctionExpression;
5581
+ var PrimaryExpression$6 = IdentifierReference;
5543
5582
  var PrimaryExpression$7 = ClassExpression;
5544
5583
  var PrimaryExpression$8 = RegularExpressionLiteral;
5545
5584
  var PrimaryExpression$9 = ParenthesizedExpression;
@@ -8465,6 +8504,70 @@ ${input.slice(result.pos)}
8465
8504
  return result;
8466
8505
  }
8467
8506
  }
8507
+ var BareNestedBlock$0 = $TS($S($Y(EOS), AllowAll, $E(NestedBlockStatements), RestoreAll), function($skip, $loc, $0, $1, $2, $3, $4) {
8508
+ if (!$3)
8509
+ return $skip;
8510
+ return $3;
8511
+ });
8512
+ function BareNestedBlock(state) {
8513
+ let eventData;
8514
+ if (state.events) {
8515
+ const result = state.events.enter?.("BareNestedBlock", state);
8516
+ if (result) {
8517
+ if (result.cache)
8518
+ return result.cache;
8519
+ eventData = result.data;
8520
+ }
8521
+ }
8522
+ if (state.tokenize) {
8523
+ const result = $TOKEN("BareNestedBlock", state, BareNestedBlock$0(state));
8524
+ if (state.events)
8525
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8526
+ return result;
8527
+ } else {
8528
+ const result = BareNestedBlock$0(state);
8529
+ if (state.events)
8530
+ state.events.exit?.("BareNestedBlock", state, result, eventData);
8531
+ return result;
8532
+ }
8533
+ }
8534
+ var BareBlock$0 = BareNestedBlock;
8535
+ var BareBlock$1 = ExplicitBlock;
8536
+ var BareBlock$2 = ThenClause;
8537
+ var BareBlock$3 = $TS($S($E(_), $N(EOS), Statement), function($skip, $loc, $0, $1, $2, $3) {
8538
+ var ws = $1;
8539
+ var s = $3;
8540
+ const expressions = [[ws, s]];
8541
+ return {
8542
+ type: "BlockStatement",
8543
+ expressions,
8544
+ children: [expressions],
8545
+ bare: true
8546
+ };
8547
+ });
8548
+ var BareBlock$4 = EmptyBareBlock;
8549
+ function BareBlock(state) {
8550
+ let eventData;
8551
+ if (state.events) {
8552
+ const result = state.events.enter?.("BareBlock", state);
8553
+ if (result) {
8554
+ if (result.cache)
8555
+ return result.cache;
8556
+ eventData = result.data;
8557
+ }
8558
+ }
8559
+ if (state.tokenize) {
8560
+ const result = $TOKEN("BareBlock", state, BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state));
8561
+ if (state.events)
8562
+ state.events.exit?.("BareBlock", state, result, eventData);
8563
+ return result;
8564
+ } else {
8565
+ const result = BareBlock$0(state) || BareBlock$1(state) || BareBlock$2(state) || BareBlock$3(state) || BareBlock$4(state);
8566
+ if (state.events)
8567
+ state.events.exit?.("BareBlock", state, result, eventData);
8568
+ return result;
8569
+ }
8570
+ }
8468
8571
  var ThenClause$0 = $T($S(Then, SingleLineStatements), function(value) {
8469
8572
  return value[1];
8470
8573
  });
@@ -10215,13 +10318,17 @@ ${input.slice(result.pos)}
10215
10318
  return {
10216
10319
  type: "ComputedPropertyName",
10217
10320
  children: $0,
10218
- expression
10321
+ expression,
10322
+ implicit: true
10219
10323
  };
10220
10324
  });
10221
10325
  var ComputedPropertyName$2 = $TS($S(InsertOpenBracket, $EXPECT($L20, fail, 'ComputedPropertyName "-"'), NumericLiteral, InsertCloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
10326
+ const expression = [$2, $3];
10222
10327
  return {
10223
10328
  type: "ComputedPropertyName",
10224
- children: $0
10329
+ expression,
10330
+ children: [$1, expression, $4],
10331
+ implicit: true
10225
10332
  };
10226
10333
  });
10227
10334
  function ComputedPropertyName(state) {
@@ -12849,7 +12956,7 @@ ${input.slice(result.pos)}
12849
12956
  return result;
12850
12957
  }
12851
12958
  }
12852
- var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
12959
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2) {
12853
12960
  var patterns = $1;
12854
12961
  var block = $2;
12855
12962
  return {
@@ -12859,13 +12966,13 @@ ${input.slice(result.pos)}
12859
12966
  patterns
12860
12967
  };
12861
12968
  });
12862
- var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
12969
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, IgnoreColon, $C(ThenClause, BareBlock)), function(value) {
12863
12970
  return { "type": "CaseClause", "children": value };
12864
12971
  });
12865
- 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) {
12972
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, IgnoreColon, InsertOpenBrace, $C(ThenClause, BareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12866
12973
  var cases = $2;
12867
- var block = $4;
12868
- var b = $5;
12974
+ var block = $5;
12975
+ var b = $6;
12869
12976
  return {
12870
12977
  type: "WhenClause",
12871
12978
  cases,
@@ -12874,7 +12981,7 @@ ${input.slice(result.pos)}
12874
12981
  children: $0
12875
12982
  };
12876
12983
  });
12877
- var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12984
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(ThenClause, BareBlock)), function($skip, $loc, $0, $1, $2, $3) {
12878
12985
  var block = $3;
12879
12986
  return {
12880
12987
  type: "DefaultClause",
@@ -12970,7 +13077,7 @@ ${input.slice(result.pos)}
12970
13077
  return result;
12971
13078
  }
12972
13079
  }
12973
- var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithObjectApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithObjectApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
13080
+ var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($E(_), CaseExpression, InsertColon)), $Q($S(__, Comma, CaseExpression, InsertColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
12974
13081
  var first = $2;
12975
13082
  var rest = $3;
12976
13083
  if (!first)
@@ -13006,10 +13113,40 @@ ${input.slice(result.pos)}
13006
13113
  return result;
13007
13114
  }
13008
13115
  }
13009
- var ImpliedColon$0 = $S($E(_), Colon);
13010
- var ImpliedColon$1 = $TV($EXPECT($L0, fail, 'ImpliedColon ""'), function($skip, $loc, $0, $1) {
13011
- return { $loc, token: ":" };
13116
+ var CaseExpression$0 = $TS($S(PropertyName, $Y($S($E(_), Colon))), function($skip, $loc, $0, $1, $2) {
13117
+ var value = $1;
13118
+ if (value.type === "ComputedPropertyName") {
13119
+ if (value.implicit)
13120
+ return value.expression;
13121
+ return { ...value, type: "ArrayExpression" };
13122
+ }
13123
+ return value;
13012
13124
  });
13125
+ var CaseExpression$1 = ExpressionWithObjectApplicationForbidden;
13126
+ function CaseExpression(state) {
13127
+ let eventData;
13128
+ if (state.events) {
13129
+ const result = state.events.enter?.("CaseExpression", state);
13130
+ if (result) {
13131
+ if (result.cache)
13132
+ return result.cache;
13133
+ eventData = result.data;
13134
+ }
13135
+ }
13136
+ if (state.tokenize) {
13137
+ const result = $TOKEN("CaseExpression", state, CaseExpression$0(state) || CaseExpression$1(state));
13138
+ if (state.events)
13139
+ state.events.exit?.("CaseExpression", state, result, eventData);
13140
+ return result;
13141
+ } else {
13142
+ const result = CaseExpression$0(state) || CaseExpression$1(state);
13143
+ if (state.events)
13144
+ state.events.exit?.("CaseExpression", state, result, eventData);
13145
+ return result;
13146
+ }
13147
+ }
13148
+ var ImpliedColon$0 = $S($E(_), Colon);
13149
+ var ImpliedColon$1 = InsertColon;
13013
13150
  function ImpliedColon(state) {
13014
13151
  let eventData;
13015
13152
  if (state.events) {
@@ -13032,6 +13169,32 @@ ${input.slice(result.pos)}
13032
13169
  return result;
13033
13170
  }
13034
13171
  }
13172
+ var IgnoreColon$0 = $TV($E($S($E(_), Colon)), function($skip, $loc, $0, $1) {
13173
+ if ($1)
13174
+ return $1[0];
13175
+ });
13176
+ function IgnoreColon(state) {
13177
+ let eventData;
13178
+ if (state.events) {
13179
+ const result = state.events.enter?.("IgnoreColon", state);
13180
+ if (result) {
13181
+ if (result.cache)
13182
+ return result.cache;
13183
+ eventData = result.data;
13184
+ }
13185
+ }
13186
+ if (state.tokenize) {
13187
+ const result = $TOKEN("IgnoreColon", state, IgnoreColon$0(state));
13188
+ if (state.events)
13189
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13190
+ return result;
13191
+ } else {
13192
+ const result = IgnoreColon$0(state);
13193
+ if (state.events)
13194
+ state.events.exit?.("IgnoreColon", state, result, eventData);
13195
+ return result;
13196
+ }
13197
+ }
13035
13198
  var TryStatement$0 = $TS($S(Try, $N($EXPECT($L12, fail, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, $E(CatchClause), $E(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13036
13199
  var t = $1;
13037
13200
  var b = $3;
@@ -22109,7 +22272,8 @@ ${input.slice(result.pos)}
22109
22272
  }
22110
22273
  }
22111
22274
  var TypeArguments$0 = $TS($S($EXPECT($L155, fail, 'TypeArguments "<"'), $P(TypeArgument), __, $EXPECT($L34, fail, 'TypeArguments ">"')), function($skip, $loc, $0, $1, $2, $3, $4) {
22112
- return { ts: true, children: $0 };
22275
+ var args = $2;
22276
+ return { ts: true, types: args.map(([, t]) => t), children: $0 };
22113
22277
  });
22114
22278
  function TypeArguments(state) {
22115
22279
  let eventData;
@@ -22570,6 +22734,31 @@ ${input.slice(result.pos)}
22570
22734
  return result;
22571
22735
  }
22572
22736
  }
22737
+ var InsertColon$0 = $TV($EXPECT($L0, fail, 'InsertColon ""'), function($skip, $loc, $0, $1) {
22738
+ return { $loc, token: ":" };
22739
+ });
22740
+ function InsertColon(state) {
22741
+ let eventData;
22742
+ if (state.events) {
22743
+ const result = state.events.enter?.("InsertColon", state);
22744
+ if (result) {
22745
+ if (result.cache)
22746
+ return result.cache;
22747
+ eventData = result.data;
22748
+ }
22749
+ }
22750
+ if (state.tokenize) {
22751
+ const result = $TOKEN("InsertColon", state, InsertColon$0(state));
22752
+ if (state.events)
22753
+ state.events.exit?.("InsertColon", state, result, eventData);
22754
+ return result;
22755
+ } else {
22756
+ const result = InsertColon$0(state);
22757
+ if (state.events)
22758
+ state.events.exit?.("InsertColon", state, result, eventData);
22759
+ return result;
22760
+ }
22761
+ }
22573
22762
  var InsertSemicolon$0 = $TV($EXPECT($L0, fail, 'InsertSemicolon ""'), function($skip, $loc, $0, $1) {
22574
22763
  return { $loc, token: ";" };
22575
22764
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.16",
3
+ "version": "0.6.17",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",