@danielx/civet 0.4.28 → 0.4.30

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/README.md CHANGED
@@ -55,10 +55,8 @@ Things Kept from CoffeeScript
55
55
  ---
56
56
 
57
57
  - `is` -> `===`
58
- - `or` -> `||`
59
- - `and` -> `&&`
60
- - `or=` -> `||=`
61
- - `and=` -> `&&=`
58
+ - `or`, `or=` -> `||`, `||=`
59
+ - `and`, `and=` -> `&&`, `&&=`
62
60
  - `loop` -> `while(true)`
63
61
  - `unless exp` -> `if(!exp)`
64
62
  - `until condition` -> `while(!condition)`
@@ -123,9 +121,7 @@ Civet.
123
121
  - `a of b` (use `a in b` matching JS, or `"civet coffeeCompat"`, or `"civet coffeeOf"`)
124
122
  - Backtick embedded JS (replaced by template literals)
125
123
  - Will likely add later
126
- - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
127
124
  - Conditional assignment `a?[x] = 3` -> `a ? a[x] = 3 : undefined`
128
- - Might add later
129
125
  - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
130
126
 
131
127
  Things Changed from CoffeeScript
@@ -156,7 +152,8 @@ Things Changed from CoffeeScript
156
152
  x + 3
157
153
  ```
158
154
  remains as is.
159
- - Heregex
155
+ - Heregex / re.X
156
+ - Stay closer to the [Python spec](https://docs.python.org/3/library/re.html#re.X)
160
157
  - Allows both kinds of substitutions `#{..}`, `${..}`.
161
158
  - Also allows both kinds of single line comments `//`, `#`.
162
159
  - Keeps non-newline whitespace inside of character classes.
package/dist/browser.js CHANGED
@@ -939,19 +939,19 @@ ${input.slice(result.pos)}
939
939
  var $L13 = $L("import.meta");
940
940
  var $L14 = $L(")");
941
941
  var $L15 = $L("->");
942
- var $L16 = $L("null");
943
- var $L17 = $L("true");
944
- var $L18 = $L("false");
945
- var $L19 = $L("yes");
946
- var $L20 = $L("on");
947
- var $L21 = $L("no");
948
- var $L22 = $L("off");
949
- var $L23 = $L(",");
950
- var $L24 = $L("=");
951
- var $L25 = $L(">");
952
- var $L26 = $L("]");
953
- var $L27 = $L(":");
954
- var $L28 = $L("}");
942
+ var $L16 = $L("}");
943
+ var $L17 = $L("null");
944
+ var $L18 = $L("true");
945
+ var $L19 = $L("false");
946
+ var $L20 = $L("yes");
947
+ var $L21 = $L("on");
948
+ var $L22 = $L("no");
949
+ var $L23 = $L("off");
950
+ var $L24 = $L(",");
951
+ var $L25 = $L("=");
952
+ var $L26 = $L(">");
953
+ var $L27 = $L("]");
954
+ var $L28 = $L(":");
955
955
  var $L29 = $L("**=");
956
956
  var $L30 = $L("*=");
957
957
  var $L31 = $L("/=");
@@ -3808,8 +3808,15 @@ ${input.slice(result.pos)}
3808
3808
  return {
3809
3809
  type: "BlockStatement",
3810
3810
  expressions,
3811
- children: [$1, expressions],
3812
- bare: true
3811
+ children: [$1, expressions]
3812
+ };
3813
+ });
3814
+ var BracedContent$2 = $TV($Y($S(__, $EXPECT($L16, fail, 'BracedContent "}"'))), function($skip, $loc, $0, $1) {
3815
+ const expressions = [];
3816
+ return {
3817
+ type: "BlockStatement",
3818
+ expressions,
3819
+ children: [expressions]
3813
3820
  };
3814
3821
  });
3815
3822
  function BracedContent(state) {
@@ -3819,12 +3826,12 @@ ${input.slice(result.pos)}
3819
3826
  return result.cache;
3820
3827
  }
3821
3828
  if (state.tokenize) {
3822
- const result = $TOKEN("BracedContent", state, BracedContent$0(state) || BracedContent$1(state));
3829
+ const result = $TOKEN("BracedContent", state, BracedContent$0(state) || BracedContent$1(state) || BracedContent$2(state));
3823
3830
  if (state.events)
3824
3831
  state.events.exit?.("BracedContent", state, result);
3825
3832
  return result;
3826
3833
  } else {
3827
- const result = BracedContent$0(state) || BracedContent$1(state);
3834
+ const result = BracedContent$0(state) || BracedContent$1(state) || BracedContent$2(state);
3828
3835
  if (state.events)
3829
3836
  state.events.exit?.("BracedContent", state, result);
3830
3837
  return result;
@@ -3929,7 +3936,7 @@ ${input.slice(result.pos)}
3929
3936
  return result;
3930
3937
  }
3931
3938
  }
3932
- var NullLiteral$0 = $TV($EXPECT($L16, fail, 'NullLiteral "null"'), function($skip, $loc, $0, $1) {
3939
+ var NullLiteral$0 = $TV($EXPECT($L17, fail, 'NullLiteral "null"'), function($skip, $loc, $0, $1) {
3933
3940
  return { $loc, token: $1 };
3934
3941
  });
3935
3942
  function NullLiteral(state) {
@@ -3953,7 +3960,7 @@ ${input.slice(result.pos)}
3953
3960
  var BooleanLiteral$0 = $T($S(CoffeeBooleansEnabled, CoffeeScriptBooleanLiteral), function(value) {
3954
3961
  return value[1];
3955
3962
  });
3956
- var BooleanLiteral$1 = $TS($S($C($EXPECT($L17, fail, 'BooleanLiteral "true"'), $EXPECT($L18, fail, 'BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3963
+ var BooleanLiteral$1 = $TS($S($C($EXPECT($L18, fail, 'BooleanLiteral "true"'), $EXPECT($L19, fail, 'BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3957
3964
  return { $loc, token: $1 };
3958
3965
  });
3959
3966
  function BooleanLiteral(state) {
@@ -3974,10 +3981,10 @@ ${input.slice(result.pos)}
3974
3981
  return result;
3975
3982
  }
3976
3983
  }
3977
- var CoffeeScriptBooleanLiteral$0 = $TS($S($C($EXPECT($L19, fail, 'CoffeeScriptBooleanLiteral "yes"'), $EXPECT($L20, fail, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3984
+ var CoffeeScriptBooleanLiteral$0 = $TS($S($C($EXPECT($L20, fail, 'CoffeeScriptBooleanLiteral "yes"'), $EXPECT($L21, fail, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3978
3985
  return { $loc, token: "true" };
3979
3986
  });
3980
- var CoffeeScriptBooleanLiteral$1 = $TS($S($C($EXPECT($L21, fail, 'CoffeeScriptBooleanLiteral "no"'), $EXPECT($L22, fail, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3987
+ var CoffeeScriptBooleanLiteral$1 = $TS($S($C($EXPECT($L22, fail, 'CoffeeScriptBooleanLiteral "no"'), $EXPECT($L23, fail, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3981
3988
  return { $loc, token: "false" };
3982
3989
  });
3983
3990
  function CoffeeScriptBooleanLiteral(state) {
@@ -3998,7 +4005,7 @@ ${input.slice(result.pos)}
3998
4005
  return result;
3999
4006
  }
4000
4007
  }
4001
- var Comma$0 = $TV($EXPECT($L23, fail, 'Comma ","'), function($skip, $loc, $0, $1) {
4008
+ var Comma$0 = $TV($EXPECT($L24, fail, 'Comma ","'), function($skip, $loc, $0, $1) {
4002
4009
  return { $loc, token: $1 };
4003
4010
  });
4004
4011
  function Comma(state) {
@@ -4088,7 +4095,7 @@ ${input.slice(result.pos)}
4088
4095
  return result;
4089
4096
  }
4090
4097
  }
4091
- var UpcomingAssignment$0 = $Y($S(__, $EXPECT($L24, fail, 'UpcomingAssignment "="'), $N($C($EXPECT($L24, fail, 'UpcomingAssignment "="'), $EXPECT($L25, fail, 'UpcomingAssignment ">"')))));
4098
+ var UpcomingAssignment$0 = $Y($S(__, $EXPECT($L25, fail, 'UpcomingAssignment "="'), $N($C($EXPECT($L25, fail, 'UpcomingAssignment "="'), $EXPECT($L26, fail, 'UpcomingAssignment ">"')))));
4092
4099
  function UpcomingAssignment(state) {
4093
4100
  if (state.events) {
4094
4101
  const result = state.events.enter?.("UpcomingAssignment", state);
@@ -4327,7 +4334,7 @@ ${input.slice(result.pos)}
4327
4334
  }
4328
4335
  }
4329
4336
  var ArrayElementDelimiter$0 = $S(__, Comma);
4330
- var ArrayElementDelimiter$1 = $Y($S(__, $EXPECT($L26, fail, 'ArrayElementDelimiter "]"')));
4337
+ var ArrayElementDelimiter$1 = $Y($S(__, $EXPECT($L27, fail, 'ArrayElementDelimiter "]"')));
4331
4338
  var ArrayElementDelimiter$2 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
4332
4339
  return { $loc, token: "," };
4333
4340
  });
@@ -4692,11 +4699,11 @@ ${input.slice(result.pos)}
4692
4699
  return result;
4693
4700
  }
4694
4701
  }
4695
- var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), $EXPECT($L23, fail, 'ImplicitInlineObjectPropertyDelimiter ","'));
4702
+ var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), $EXPECT($L24, fail, 'ImplicitInlineObjectPropertyDelimiter ","'));
4696
4703
  var ImplicitInlineObjectPropertyDelimiter$1 = $T($Y($S(EOS, NamedProperty)), function(value) {
4697
4704
  return ",";
4698
4705
  });
4699
- var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L27, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L14, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L26, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
4706
+ var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L14, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L27, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L16, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
4700
4707
  return "";
4701
4708
  });
4702
4709
  var ImplicitInlineObjectPropertyDelimiter$3 = $T($Y(EOS), function(value) {
@@ -4721,7 +4728,7 @@ ${input.slice(result.pos)}
4721
4728
  }
4722
4729
  }
4723
4730
  var ObjectPropertyDelimiter$0 = $S($Q(_), Comma);
4724
- var ObjectPropertyDelimiter$1 = $Y($S(__, $EXPECT($L28, fail, 'ObjectPropertyDelimiter "}"')));
4731
+ var ObjectPropertyDelimiter$1 = $Y($S(__, $EXPECT($L16, fail, 'ObjectPropertyDelimiter "}"')));
4725
4732
  var ObjectPropertyDelimiter$2 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
4726
4733
  return { $loc, token: "," };
4727
4734
  });
@@ -4773,14 +4780,24 @@ ${input.slice(result.pos)}
4773
4780
  var ws = $1;
4774
4781
  var at = $2;
4775
4782
  var id = $3;
4783
+ const value = [{ ...at, token: "this." }, id];
4776
4784
  return {
4777
4785
  type: "Property",
4778
- children: [...ws, id, ": ", { ...at, token: "this." }, id],
4779
- names: id.names
4786
+ children: [...ws, id, ": ", ...value],
4787
+ name: id,
4788
+ names: id.names,
4789
+ value
4780
4790
  };
4781
4791
  });
4782
4792
  var PropertyDefinition$1 = NamedProperty;
4783
- var PropertyDefinition$2 = MethodDefinition;
4793
+ var PropertyDefinition$2 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
4794
+ var ws = $1;
4795
+ var def = $2;
4796
+ return {
4797
+ ...def,
4798
+ children: [...ws, ...def.children]
4799
+ };
4800
+ });
4784
4801
  var PropertyDefinition$3 = $TS($S(__, DotDotDot, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3) {
4785
4802
  var ws = $1;
4786
4803
  var dots = $2;
@@ -4788,7 +4805,8 @@ ${input.slice(result.pos)}
4788
4805
  return {
4789
4806
  type: "SpreadProperty",
4790
4807
  children: [...ws, dots, exp],
4791
- names: exp.names
4808
+ names: exp.names,
4809
+ value: [dots, exp]
4792
4810
  };
4793
4811
  });
4794
4812
  var PropertyDefinition$4 = $TS($S(__, IdentifierReference), function($skip, $loc, $0, $1, $2) {
@@ -4815,11 +4833,14 @@ ${input.slice(result.pos)}
4815
4833
  }
4816
4834
  }
4817
4835
  var NamedProperty$0 = $TS($S(__, PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4836
+ var name = $2;
4818
4837
  var exp = $5;
4819
4838
  return {
4820
4839
  type: "Property",
4821
4840
  children: $0,
4822
- names: exp.names || []
4841
+ name,
4842
+ names: exp.names || [],
4843
+ value: exp
4823
4844
  };
4824
4845
  });
4825
4846
  function NamedProperty(state) {
@@ -4869,7 +4890,12 @@ ${input.slice(result.pos)}
4869
4890
  var PropertyName$0 = NumericLiteral;
4870
4891
  var PropertyName$1 = StringLiteral;
4871
4892
  var PropertyName$2 = IdentifierName;
4872
- var PropertyName$3 = $S(OpenBracket, ExtendedExpression, __, CloseBracket);
4893
+ var PropertyName$3 = $TS($S(OpenBracket, ExtendedExpression, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
4894
+ return {
4895
+ type: "ComputedPropertyName",
4896
+ children: $0
4897
+ };
4898
+ });
4873
4899
  function PropertyName(state) {
4874
4900
  if (state.events) {
4875
4901
  const result = state.events.enter?.("PropertyName", state);
@@ -4927,11 +4953,14 @@ ${input.slice(result.pos)}
4927
4953
  }
4928
4954
  }
4929
4955
  var MethodDefinition$0 = $TS($S($E(Decorators), MethodSignature, BracedBlock), function($skip, $loc, $0, $1, $2, $3) {
4956
+ var decorators = $1;
4930
4957
  var signature = $2;
4931
4958
  var block = $3;
4932
4959
  return {
4933
4960
  type: "MethodDefinition",
4934
4961
  children: $0,
4962
+ name: signature.name,
4963
+ decorators,
4935
4964
  signature,
4936
4965
  block,
4937
4966
  parameters: signature.parameters
@@ -4958,7 +4987,6 @@ ${input.slice(result.pos)}
4958
4987
  var MethodModifier$0 = $S(GetOrSet, $Q(TrailingComment));
4959
4988
  var MethodModifier$1 = $S($S(Async, __), $E($S(Star, __)));
4960
4989
  var MethodModifier$2 = $S(Star, __);
4961
- var MethodModifier$3 = $S(Async, __);
4962
4990
  function MethodModifier(state) {
4963
4991
  if (state.events) {
4964
4992
  const result = state.events.enter?.("MethodModifier", state);
@@ -4966,12 +4994,12 @@ ${input.slice(result.pos)}
4966
4994
  return result.cache;
4967
4995
  }
4968
4996
  if (state.tokenize) {
4969
- const result = $TOKEN("MethodModifier", state, MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state));
4997
+ const result = $TOKEN("MethodModifier", state, MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state));
4970
4998
  if (state.events)
4971
4999
  state.events.exit?.("MethodModifier", state, result);
4972
5000
  return result;
4973
5001
  } else {
4974
- const result = MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state);
5002
+ const result = MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state);
4975
5003
  if (state.events)
4976
5004
  state.events.exit?.("MethodModifier", state, result);
4977
5005
  return result;
@@ -5117,7 +5145,7 @@ ${input.slice(result.pos)}
5117
5145
  var AssignmentOpSymbol$15 = $T($EXPECT($L44, fail, 'AssignmentOpSymbol "?="'), function(value) {
5118
5146
  return "??=";
5119
5147
  });
5120
- var AssignmentOpSymbol$16 = $EXPECT($L24, fail, 'AssignmentOpSymbol "="');
5148
+ var AssignmentOpSymbol$16 = $EXPECT($L25, fail, 'AssignmentOpSymbol "="');
5121
5149
  var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
5122
5150
  return value[0];
5123
5151
  });
@@ -5200,7 +5228,7 @@ ${input.slice(result.pos)}
5200
5228
  });
5201
5229
  var BinaryOpSymbol$10 = $EXPECT($L56, fail, 'BinaryOpSymbol ">>>"');
5202
5230
  var BinaryOpSymbol$11 = $EXPECT($L57, fail, 'BinaryOpSymbol ">>"');
5203
- var BinaryOpSymbol$12 = $EXPECT($L25, fail, 'BinaryOpSymbol ">"');
5231
+ var BinaryOpSymbol$12 = $EXPECT($L26, fail, 'BinaryOpSymbol ">"');
5204
5232
  var BinaryOpSymbol$13 = $EXPECT($L58, fail, 'BinaryOpSymbol "!=="');
5205
5233
  var BinaryOpSymbol$14 = $TV($EXPECT($L59, fail, 'BinaryOpSymbol "!="'), function($skip, $loc, $0, $1) {
5206
5234
  if (module.config.coffeeEq)
@@ -5432,7 +5460,7 @@ ${input.slice(result.pos)}
5432
5460
  return result;
5433
5461
  }
5434
5462
  }
5435
- var BlockStatement$0 = $T($S(ExplicitBlock, $N($S(__, $EXPECT($L24, fail, 'BlockStatement "="')))), function(value) {
5463
+ var BlockStatement$0 = $T($S(ExplicitBlock, $N($S(__, $EXPECT($L25, fail, 'BlockStatement "="')))), function(value) {
5436
5464
  return value[0];
5437
5465
  });
5438
5466
  function BlockStatement(state) {
@@ -8980,7 +9008,7 @@ ${input.slice(result.pos)}
8980
9008
  }
8981
9009
  }
8982
9010
  var Async$0 = $TV($EXPECT($L92, fail, 'Async "async"'), function($skip, $loc, $0, $1) {
8983
- return { $loc, token: $1 };
9011
+ return { $loc, token: $1, type: "Async" };
8984
9012
  });
8985
9013
  function Async(state) {
8986
9014
  if (state.events) {
@@ -9126,7 +9154,7 @@ ${input.slice(result.pos)}
9126
9154
  return result;
9127
9155
  }
9128
9156
  }
9129
- var CloseBrace$0 = $TV($EXPECT($L28, fail, 'CloseBrace "}"'), function($skip, $loc, $0, $1) {
9157
+ var CloseBrace$0 = $TV($EXPECT($L16, fail, 'CloseBrace "}"'), function($skip, $loc, $0, $1) {
9130
9158
  return { $loc, token: $1 };
9131
9159
  });
9132
9160
  function CloseBrace(state) {
@@ -9147,7 +9175,7 @@ ${input.slice(result.pos)}
9147
9175
  return result;
9148
9176
  }
9149
9177
  }
9150
- var CloseBracket$0 = $TV($EXPECT($L26, fail, 'CloseBracket "]"'), function($skip, $loc, $0, $1) {
9178
+ var CloseBracket$0 = $TV($EXPECT($L27, fail, 'CloseBracket "]"'), function($skip, $loc, $0, $1) {
9151
9179
  return { $loc, token: $1 };
9152
9180
  });
9153
9181
  function CloseBracket(state) {
@@ -9210,7 +9238,7 @@ ${input.slice(result.pos)}
9210
9238
  return result;
9211
9239
  }
9212
9240
  }
9213
- var Colon$0 = $TV($EXPECT($L27, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
9241
+ var Colon$0 = $TV($EXPECT($L28, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
9214
9242
  return { $loc, token: $1 };
9215
9243
  });
9216
9244
  function Colon(state) {
@@ -9441,7 +9469,7 @@ ${input.slice(result.pos)}
9441
9469
  return result;
9442
9470
  }
9443
9471
  }
9444
- var Equals$0 = $TV($EXPECT($L24, fail, 'Equals "="'), function($skip, $loc, $0, $1) {
9472
+ var Equals$0 = $TV($EXPECT($L25, fail, 'Equals "="'), function($skip, $loc, $0, $1) {
9445
9473
  return { $loc, token: $1 };
9446
9474
  });
9447
9475
  function Equals(state) {
@@ -9547,7 +9575,7 @@ ${input.slice(result.pos)}
9547
9575
  }
9548
9576
  }
9549
9577
  var GetOrSet$0 = $TS($S($C($EXPECT($L111, fail, 'GetOrSet "get"'), $EXPECT($L112, fail, 'GetOrSet "set"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
9550
- return { $loc, token: $1 };
9578
+ return { $loc, token: $1, type: "GetOrSet" };
9551
9579
  });
9552
9580
  function GetOrSet(state) {
9553
9581
  if (state.events) {
@@ -10382,7 +10410,7 @@ ${input.slice(result.pos)}
10382
10410
  return result;
10383
10411
  }
10384
10412
  }
10385
- var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L25, fail, 'JSXOpeningElement ">"'));
10413
+ var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L26, fail, 'JSXOpeningElement ">"'));
10386
10414
  function JSXOpeningElement(state) {
10387
10415
  if (state.events) {
10388
10416
  const result = state.events.enter?.("JSXOpeningElement", state);
@@ -10401,7 +10429,7 @@ ${input.slice(result.pos)}
10401
10429
  return result;
10402
10430
  }
10403
10431
  }
10404
- var JSXClosingElement$0 = $S($EXPECT($L144, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L25, fail, 'JSXClosingElement ">"'));
10432
+ var JSXClosingElement$0 = $S($EXPECT($L144, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L26, fail, 'JSXClosingElement ">"'));
10405
10433
  function JSXClosingElement(state) {
10406
10434
  if (state.events) {
10407
10435
  const result = state.events.enter?.("JSXClosingElement", state);
@@ -10499,7 +10527,44 @@ ${input.slice(result.pos)}
10499
10527
  return result;
10500
10528
  }
10501
10529
  }
10502
- var JSXAttribute$0 = $S(OpenBrace, __, DotDotDot, ExtendedExpression, __, CloseBrace);
10530
+ var JSXAttribute$0 = $TS($S(BracedObjectLiteral), function($skip, $loc, $0, $1) {
10531
+ const { children } = $1;
10532
+ const parts = [];
10533
+ const rest = [];
10534
+ for (let i = 1; i < children.length - 1; i++) {
10535
+ if (i > 1)
10536
+ parts.push(" ");
10537
+ const part = children[i];
10538
+ switch (part.type) {
10539
+ case "Identifier":
10540
+ parts.push([part.name, "={", part.name, "}"]);
10541
+ break;
10542
+ case "Property":
10543
+ if (part.name.type === "ComputedPropertyName") {
10544
+ rest.push(part);
10545
+ } else {
10546
+ parts.push([part.name, "={", module.insertTrimmingSpace(part.value, ""), "}"]);
10547
+ }
10548
+ break;
10549
+ case "SpreadProperty":
10550
+ parts.push(["{", part.value, "}"]);
10551
+ break;
10552
+ case "MethodDefinition":
10553
+ try {
10554
+ parts.push([part.name, "={", module.convertMethodToFunction(part), "}"]);
10555
+ } catch {
10556
+ rest.push(part);
10557
+ }
10558
+ break;
10559
+ default:
10560
+ throw new Error(`invalid object literal type in JSX attribute: ${part.type}`);
10561
+ }
10562
+ }
10563
+ if (rest.length) {
10564
+ parts.push(["{...{", ...rest, "}}"]);
10565
+ }
10566
+ return parts;
10567
+ });
10503
10568
  var JSXAttribute$1 = $S(JSXAttributeName, $E(JSXAttributeInitializer));
10504
10569
  function JSXAttribute(state) {
10505
10570
  if (state.events) {
@@ -11409,7 +11474,7 @@ ${input.slice(result.pos)}
11409
11474
  return result;
11410
11475
  }
11411
11476
  }
11412
- var TypeArguments$0 = $S(__, $EXPECT($L5, fail, 'TypeArguments "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L25, fail, 'TypeArguments ">"'));
11477
+ var TypeArguments$0 = $S(__, $EXPECT($L5, fail, 'TypeArguments "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L26, fail, 'TypeArguments ">"'));
11413
11478
  function TypeArguments(state) {
11414
11479
  if (state.events) {
11415
11480
  const result = state.events.enter?.("TypeArguments", state);
@@ -11428,7 +11493,7 @@ ${input.slice(result.pos)}
11428
11493
  return result;
11429
11494
  }
11430
11495
  }
11431
- var TypeParameters$0 = $TS($S(__, $EXPECT($L5, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L25, fail, 'TypeParameters ">"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
11496
+ var TypeParameters$0 = $TS($S(__, $EXPECT($L5, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L26, fail, 'TypeParameters ">"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
11432
11497
  return { ts: true, children: $0 };
11433
11498
  });
11434
11499
  function TypeParameters(state) {
@@ -11488,8 +11553,8 @@ ${input.slice(result.pos)}
11488
11553
  }
11489
11554
  }
11490
11555
  var TypeParameterDelimiter$0 = $S($Q(_), Comma);
11491
- var TypeParameterDelimiter$1 = $Y($S($Q(_), $EXPECT($L25, fail, 'TypeParameterDelimiter ">"')));
11492
- var TypeParameterDelimiter$2 = $TV($Y($S(__, $EXPECT($L25, fail, 'TypeParameterDelimiter ">"'))), function($skip, $loc, $0, $1) {
11556
+ var TypeParameterDelimiter$1 = $Y($S($Q(_), $EXPECT($L26, fail, 'TypeParameterDelimiter ">"')));
11557
+ var TypeParameterDelimiter$2 = $TV($Y($S(__, $EXPECT($L26, fail, 'TypeParameterDelimiter ">"'))), function($skip, $loc, $0, $1) {
11493
11558
  return { $loc, token: "," };
11494
11559
  });
11495
11560
  var TypeParameterDelimiter$3 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
@@ -12607,6 +12672,8 @@ ${input.slice(result.pos)}
12607
12672
  module.isWhitespaceOrEmpty = function(node) {
12608
12673
  if (!node)
12609
12674
  return true;
12675
+ if (node.token)
12676
+ return node.token.match(/^\s*$/);
12610
12677
  if (!node.length)
12611
12678
  return true;
12612
12679
  if (typeof node === "string")
@@ -13003,6 +13070,32 @@ ${input.slice(result.pos)}
13003
13070
  throw new Error("Unknown postfix statement");
13004
13071
  }
13005
13072
  };
13073
+ module.convertMethodToFunction = function(method) {
13074
+ const { decorators, signature, block } = method;
13075
+ let opening = signature.children[0];
13076
+ if (opening) {
13077
+ if (opening[0].type === "GetOrSet") {
13078
+ throw new Error("cannot convert get/set method to function");
13079
+ } else if (opening[0][0]?.type === "Async") {
13080
+ opening = [opening[0][0], " function ", ...opening.slice(1)];
13081
+ } else {
13082
+ opening = ["function ", ...opening];
13083
+ }
13084
+ } else {
13085
+ opening = "function ";
13086
+ }
13087
+ return {
13088
+ ...signature,
13089
+ id: signature.name,
13090
+ type: "FunctionExpression",
13091
+ children: [
13092
+ decorators,
13093
+ [opening, ...signature.children.slice(1)],
13094
+ block
13095
+ ],
13096
+ block
13097
+ };
13098
+ };
13006
13099
  module.processProgram = function(statements) {
13007
13100
  processAssignments(statements);
13008
13101
  processFunctions(statements);
package/dist/main.js CHANGED
@@ -938,19 +938,19 @@ ${input.slice(result.pos)}
938
938
  var $L13 = $L("import.meta");
939
939
  var $L14 = $L(")");
940
940
  var $L15 = $L("->");
941
- var $L16 = $L("null");
942
- var $L17 = $L("true");
943
- var $L18 = $L("false");
944
- var $L19 = $L("yes");
945
- var $L20 = $L("on");
946
- var $L21 = $L("no");
947
- var $L22 = $L("off");
948
- var $L23 = $L(",");
949
- var $L24 = $L("=");
950
- var $L25 = $L(">");
951
- var $L26 = $L("]");
952
- var $L27 = $L(":");
953
- var $L28 = $L("}");
941
+ var $L16 = $L("}");
942
+ var $L17 = $L("null");
943
+ var $L18 = $L("true");
944
+ var $L19 = $L("false");
945
+ var $L20 = $L("yes");
946
+ var $L21 = $L("on");
947
+ var $L22 = $L("no");
948
+ var $L23 = $L("off");
949
+ var $L24 = $L(",");
950
+ var $L25 = $L("=");
951
+ var $L26 = $L(">");
952
+ var $L27 = $L("]");
953
+ var $L28 = $L(":");
954
954
  var $L29 = $L("**=");
955
955
  var $L30 = $L("*=");
956
956
  var $L31 = $L("/=");
@@ -3807,8 +3807,15 @@ ${input.slice(result.pos)}
3807
3807
  return {
3808
3808
  type: "BlockStatement",
3809
3809
  expressions,
3810
- children: [$1, expressions],
3811
- bare: true
3810
+ children: [$1, expressions]
3811
+ };
3812
+ });
3813
+ var BracedContent$2 = $TV($Y($S(__, $EXPECT($L16, fail, 'BracedContent "}"'))), function($skip, $loc, $0, $1) {
3814
+ const expressions = [];
3815
+ return {
3816
+ type: "BlockStatement",
3817
+ expressions,
3818
+ children: [expressions]
3812
3819
  };
3813
3820
  });
3814
3821
  function BracedContent(state) {
@@ -3818,12 +3825,12 @@ ${input.slice(result.pos)}
3818
3825
  return result.cache;
3819
3826
  }
3820
3827
  if (state.tokenize) {
3821
- const result = $TOKEN("BracedContent", state, BracedContent$0(state) || BracedContent$1(state));
3828
+ const result = $TOKEN("BracedContent", state, BracedContent$0(state) || BracedContent$1(state) || BracedContent$2(state));
3822
3829
  if (state.events)
3823
3830
  state.events.exit?.("BracedContent", state, result);
3824
3831
  return result;
3825
3832
  } else {
3826
- const result = BracedContent$0(state) || BracedContent$1(state);
3833
+ const result = BracedContent$0(state) || BracedContent$1(state) || BracedContent$2(state);
3827
3834
  if (state.events)
3828
3835
  state.events.exit?.("BracedContent", state, result);
3829
3836
  return result;
@@ -3928,7 +3935,7 @@ ${input.slice(result.pos)}
3928
3935
  return result;
3929
3936
  }
3930
3937
  }
3931
- var NullLiteral$0 = $TV($EXPECT($L16, fail, 'NullLiteral "null"'), function($skip, $loc, $0, $1) {
3938
+ var NullLiteral$0 = $TV($EXPECT($L17, fail, 'NullLiteral "null"'), function($skip, $loc, $0, $1) {
3932
3939
  return { $loc, token: $1 };
3933
3940
  });
3934
3941
  function NullLiteral(state) {
@@ -3952,7 +3959,7 @@ ${input.slice(result.pos)}
3952
3959
  var BooleanLiteral$0 = $T($S(CoffeeBooleansEnabled, CoffeeScriptBooleanLiteral), function(value) {
3953
3960
  return value[1];
3954
3961
  });
3955
- var BooleanLiteral$1 = $TS($S($C($EXPECT($L17, fail, 'BooleanLiteral "true"'), $EXPECT($L18, fail, 'BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3962
+ var BooleanLiteral$1 = $TS($S($C($EXPECT($L18, fail, 'BooleanLiteral "true"'), $EXPECT($L19, fail, 'BooleanLiteral "false"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3956
3963
  return { $loc, token: $1 };
3957
3964
  });
3958
3965
  function BooleanLiteral(state) {
@@ -3973,10 +3980,10 @@ ${input.slice(result.pos)}
3973
3980
  return result;
3974
3981
  }
3975
3982
  }
3976
- var CoffeeScriptBooleanLiteral$0 = $TS($S($C($EXPECT($L19, fail, 'CoffeeScriptBooleanLiteral "yes"'), $EXPECT($L20, fail, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3983
+ var CoffeeScriptBooleanLiteral$0 = $TS($S($C($EXPECT($L20, fail, 'CoffeeScriptBooleanLiteral "yes"'), $EXPECT($L21, fail, 'CoffeeScriptBooleanLiteral "on"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3977
3984
  return { $loc, token: "true" };
3978
3985
  });
3979
- var CoffeeScriptBooleanLiteral$1 = $TS($S($C($EXPECT($L21, fail, 'CoffeeScriptBooleanLiteral "no"'), $EXPECT($L22, fail, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3986
+ var CoffeeScriptBooleanLiteral$1 = $TS($S($C($EXPECT($L22, fail, 'CoffeeScriptBooleanLiteral "no"'), $EXPECT($L23, fail, 'CoffeeScriptBooleanLiteral "off"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
3980
3987
  return { $loc, token: "false" };
3981
3988
  });
3982
3989
  function CoffeeScriptBooleanLiteral(state) {
@@ -3997,7 +4004,7 @@ ${input.slice(result.pos)}
3997
4004
  return result;
3998
4005
  }
3999
4006
  }
4000
- var Comma$0 = $TV($EXPECT($L23, fail, 'Comma ","'), function($skip, $loc, $0, $1) {
4007
+ var Comma$0 = $TV($EXPECT($L24, fail, 'Comma ","'), function($skip, $loc, $0, $1) {
4001
4008
  return { $loc, token: $1 };
4002
4009
  });
4003
4010
  function Comma(state) {
@@ -4087,7 +4094,7 @@ ${input.slice(result.pos)}
4087
4094
  return result;
4088
4095
  }
4089
4096
  }
4090
- var UpcomingAssignment$0 = $Y($S(__, $EXPECT($L24, fail, 'UpcomingAssignment "="'), $N($C($EXPECT($L24, fail, 'UpcomingAssignment "="'), $EXPECT($L25, fail, 'UpcomingAssignment ">"')))));
4097
+ var UpcomingAssignment$0 = $Y($S(__, $EXPECT($L25, fail, 'UpcomingAssignment "="'), $N($C($EXPECT($L25, fail, 'UpcomingAssignment "="'), $EXPECT($L26, fail, 'UpcomingAssignment ">"')))));
4091
4098
  function UpcomingAssignment(state) {
4092
4099
  if (state.events) {
4093
4100
  const result = state.events.enter?.("UpcomingAssignment", state);
@@ -4326,7 +4333,7 @@ ${input.slice(result.pos)}
4326
4333
  }
4327
4334
  }
4328
4335
  var ArrayElementDelimiter$0 = $S(__, Comma);
4329
- var ArrayElementDelimiter$1 = $Y($S(__, $EXPECT($L26, fail, 'ArrayElementDelimiter "]"')));
4336
+ var ArrayElementDelimiter$1 = $Y($S(__, $EXPECT($L27, fail, 'ArrayElementDelimiter "]"')));
4330
4337
  var ArrayElementDelimiter$2 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
4331
4338
  return { $loc, token: "," };
4332
4339
  });
@@ -4691,11 +4698,11 @@ ${input.slice(result.pos)}
4691
4698
  return result;
4692
4699
  }
4693
4700
  }
4694
- var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), $EXPECT($L23, fail, 'ImplicitInlineObjectPropertyDelimiter ","'));
4701
+ var ImplicitInlineObjectPropertyDelimiter$0 = $S($Q(TrailingComment), $EXPECT($L24, fail, 'ImplicitInlineObjectPropertyDelimiter ","'));
4695
4702
  var ImplicitInlineObjectPropertyDelimiter$1 = $T($Y($S(EOS, NamedProperty)), function(value) {
4696
4703
  return ",";
4697
4704
  });
4698
- var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L27, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L14, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L26, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
4705
+ var ImplicitInlineObjectPropertyDelimiter$2 = $T($Y($S(__, $C($EXPECT($L28, fail, 'ImplicitInlineObjectPropertyDelimiter ":"'), $EXPECT($L14, fail, 'ImplicitInlineObjectPropertyDelimiter ")"'), $EXPECT($L27, fail, 'ImplicitInlineObjectPropertyDelimiter "]"'), $EXPECT($L16, fail, 'ImplicitInlineObjectPropertyDelimiter "}"'), ReservedWord))), function(value) {
4699
4706
  return "";
4700
4707
  });
4701
4708
  var ImplicitInlineObjectPropertyDelimiter$3 = $T($Y(EOS), function(value) {
@@ -4720,7 +4727,7 @@ ${input.slice(result.pos)}
4720
4727
  }
4721
4728
  }
4722
4729
  var ObjectPropertyDelimiter$0 = $S($Q(_), Comma);
4723
- var ObjectPropertyDelimiter$1 = $Y($S(__, $EXPECT($L28, fail, 'ObjectPropertyDelimiter "}"')));
4730
+ var ObjectPropertyDelimiter$1 = $Y($S(__, $EXPECT($L16, fail, 'ObjectPropertyDelimiter "}"')));
4724
4731
  var ObjectPropertyDelimiter$2 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
4725
4732
  return { $loc, token: "," };
4726
4733
  });
@@ -4772,14 +4779,24 @@ ${input.slice(result.pos)}
4772
4779
  var ws = $1;
4773
4780
  var at = $2;
4774
4781
  var id = $3;
4782
+ const value = [{ ...at, token: "this." }, id];
4775
4783
  return {
4776
4784
  type: "Property",
4777
- children: [...ws, id, ": ", { ...at, token: "this." }, id],
4778
- names: id.names
4785
+ children: [...ws, id, ": ", ...value],
4786
+ name: id,
4787
+ names: id.names,
4788
+ value
4779
4789
  };
4780
4790
  });
4781
4791
  var PropertyDefinition$1 = NamedProperty;
4782
- var PropertyDefinition$2 = MethodDefinition;
4792
+ var PropertyDefinition$2 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
4793
+ var ws = $1;
4794
+ var def = $2;
4795
+ return {
4796
+ ...def,
4797
+ children: [...ws, ...def.children]
4798
+ };
4799
+ });
4783
4800
  var PropertyDefinition$3 = $TS($S(__, DotDotDot, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3) {
4784
4801
  var ws = $1;
4785
4802
  var dots = $2;
@@ -4787,7 +4804,8 @@ ${input.slice(result.pos)}
4787
4804
  return {
4788
4805
  type: "SpreadProperty",
4789
4806
  children: [...ws, dots, exp],
4790
- names: exp.names
4807
+ names: exp.names,
4808
+ value: [dots, exp]
4791
4809
  };
4792
4810
  });
4793
4811
  var PropertyDefinition$4 = $TS($S(__, IdentifierReference), function($skip, $loc, $0, $1, $2) {
@@ -4814,11 +4832,14 @@ ${input.slice(result.pos)}
4814
4832
  }
4815
4833
  }
4816
4834
  var NamedProperty$0 = $TS($S(__, PropertyName, __, Colon, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4835
+ var name = $2;
4817
4836
  var exp = $5;
4818
4837
  return {
4819
4838
  type: "Property",
4820
4839
  children: $0,
4821
- names: exp.names || []
4840
+ name,
4841
+ names: exp.names || [],
4842
+ value: exp
4822
4843
  };
4823
4844
  });
4824
4845
  function NamedProperty(state) {
@@ -4868,7 +4889,12 @@ ${input.slice(result.pos)}
4868
4889
  var PropertyName$0 = NumericLiteral;
4869
4890
  var PropertyName$1 = StringLiteral;
4870
4891
  var PropertyName$2 = IdentifierName;
4871
- var PropertyName$3 = $S(OpenBracket, ExtendedExpression, __, CloseBracket);
4892
+ var PropertyName$3 = $TS($S(OpenBracket, ExtendedExpression, __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
4893
+ return {
4894
+ type: "ComputedPropertyName",
4895
+ children: $0
4896
+ };
4897
+ });
4872
4898
  function PropertyName(state) {
4873
4899
  if (state.events) {
4874
4900
  const result = state.events.enter?.("PropertyName", state);
@@ -4926,11 +4952,14 @@ ${input.slice(result.pos)}
4926
4952
  }
4927
4953
  }
4928
4954
  var MethodDefinition$0 = $TS($S($E(Decorators), MethodSignature, BracedBlock), function($skip, $loc, $0, $1, $2, $3) {
4955
+ var decorators = $1;
4929
4956
  var signature = $2;
4930
4957
  var block = $3;
4931
4958
  return {
4932
4959
  type: "MethodDefinition",
4933
4960
  children: $0,
4961
+ name: signature.name,
4962
+ decorators,
4934
4963
  signature,
4935
4964
  block,
4936
4965
  parameters: signature.parameters
@@ -4957,7 +4986,6 @@ ${input.slice(result.pos)}
4957
4986
  var MethodModifier$0 = $S(GetOrSet, $Q(TrailingComment));
4958
4987
  var MethodModifier$1 = $S($S(Async, __), $E($S(Star, __)));
4959
4988
  var MethodModifier$2 = $S(Star, __);
4960
- var MethodModifier$3 = $S(Async, __);
4961
4989
  function MethodModifier(state) {
4962
4990
  if (state.events) {
4963
4991
  const result = state.events.enter?.("MethodModifier", state);
@@ -4965,12 +4993,12 @@ ${input.slice(result.pos)}
4965
4993
  return result.cache;
4966
4994
  }
4967
4995
  if (state.tokenize) {
4968
- const result = $TOKEN("MethodModifier", state, MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state));
4996
+ const result = $TOKEN("MethodModifier", state, MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state));
4969
4997
  if (state.events)
4970
4998
  state.events.exit?.("MethodModifier", state, result);
4971
4999
  return result;
4972
5000
  } else {
4973
- const result = MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state) || MethodModifier$3(state);
5001
+ const result = MethodModifier$0(state) || MethodModifier$1(state) || MethodModifier$2(state);
4974
5002
  if (state.events)
4975
5003
  state.events.exit?.("MethodModifier", state, result);
4976
5004
  return result;
@@ -5116,7 +5144,7 @@ ${input.slice(result.pos)}
5116
5144
  var AssignmentOpSymbol$15 = $T($EXPECT($L44, fail, 'AssignmentOpSymbol "?="'), function(value) {
5117
5145
  return "??=";
5118
5146
  });
5119
- var AssignmentOpSymbol$16 = $EXPECT($L24, fail, 'AssignmentOpSymbol "="');
5147
+ var AssignmentOpSymbol$16 = $EXPECT($L25, fail, 'AssignmentOpSymbol "="');
5120
5148
  var AssignmentOpSymbol$17 = $T($S(CoffeeWordAssignmentOp), function(value) {
5121
5149
  return value[0];
5122
5150
  });
@@ -5199,7 +5227,7 @@ ${input.slice(result.pos)}
5199
5227
  });
5200
5228
  var BinaryOpSymbol$10 = $EXPECT($L56, fail, 'BinaryOpSymbol ">>>"');
5201
5229
  var BinaryOpSymbol$11 = $EXPECT($L57, fail, 'BinaryOpSymbol ">>"');
5202
- var BinaryOpSymbol$12 = $EXPECT($L25, fail, 'BinaryOpSymbol ">"');
5230
+ var BinaryOpSymbol$12 = $EXPECT($L26, fail, 'BinaryOpSymbol ">"');
5203
5231
  var BinaryOpSymbol$13 = $EXPECT($L58, fail, 'BinaryOpSymbol "!=="');
5204
5232
  var BinaryOpSymbol$14 = $TV($EXPECT($L59, fail, 'BinaryOpSymbol "!="'), function($skip, $loc, $0, $1) {
5205
5233
  if (module2.config.coffeeEq)
@@ -5431,7 +5459,7 @@ ${input.slice(result.pos)}
5431
5459
  return result;
5432
5460
  }
5433
5461
  }
5434
- var BlockStatement$0 = $T($S(ExplicitBlock, $N($S(__, $EXPECT($L24, fail, 'BlockStatement "="')))), function(value) {
5462
+ var BlockStatement$0 = $T($S(ExplicitBlock, $N($S(__, $EXPECT($L25, fail, 'BlockStatement "="')))), function(value) {
5435
5463
  return value[0];
5436
5464
  });
5437
5465
  function BlockStatement(state) {
@@ -8979,7 +9007,7 @@ ${input.slice(result.pos)}
8979
9007
  }
8980
9008
  }
8981
9009
  var Async$0 = $TV($EXPECT($L92, fail, 'Async "async"'), function($skip, $loc, $0, $1) {
8982
- return { $loc, token: $1 };
9010
+ return { $loc, token: $1, type: "Async" };
8983
9011
  });
8984
9012
  function Async(state) {
8985
9013
  if (state.events) {
@@ -9125,7 +9153,7 @@ ${input.slice(result.pos)}
9125
9153
  return result;
9126
9154
  }
9127
9155
  }
9128
- var CloseBrace$0 = $TV($EXPECT($L28, fail, 'CloseBrace "}"'), function($skip, $loc, $0, $1) {
9156
+ var CloseBrace$0 = $TV($EXPECT($L16, fail, 'CloseBrace "}"'), function($skip, $loc, $0, $1) {
9129
9157
  return { $loc, token: $1 };
9130
9158
  });
9131
9159
  function CloseBrace(state) {
@@ -9146,7 +9174,7 @@ ${input.slice(result.pos)}
9146
9174
  return result;
9147
9175
  }
9148
9176
  }
9149
- var CloseBracket$0 = $TV($EXPECT($L26, fail, 'CloseBracket "]"'), function($skip, $loc, $0, $1) {
9177
+ var CloseBracket$0 = $TV($EXPECT($L27, fail, 'CloseBracket "]"'), function($skip, $loc, $0, $1) {
9150
9178
  return { $loc, token: $1 };
9151
9179
  });
9152
9180
  function CloseBracket(state) {
@@ -9209,7 +9237,7 @@ ${input.slice(result.pos)}
9209
9237
  return result;
9210
9238
  }
9211
9239
  }
9212
- var Colon$0 = $TV($EXPECT($L27, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
9240
+ var Colon$0 = $TV($EXPECT($L28, fail, 'Colon ":"'), function($skip, $loc, $0, $1) {
9213
9241
  return { $loc, token: $1 };
9214
9242
  });
9215
9243
  function Colon(state) {
@@ -9440,7 +9468,7 @@ ${input.slice(result.pos)}
9440
9468
  return result;
9441
9469
  }
9442
9470
  }
9443
- var Equals$0 = $TV($EXPECT($L24, fail, 'Equals "="'), function($skip, $loc, $0, $1) {
9471
+ var Equals$0 = $TV($EXPECT($L25, fail, 'Equals "="'), function($skip, $loc, $0, $1) {
9444
9472
  return { $loc, token: $1 };
9445
9473
  });
9446
9474
  function Equals(state) {
@@ -9546,7 +9574,7 @@ ${input.slice(result.pos)}
9546
9574
  }
9547
9575
  }
9548
9576
  var GetOrSet$0 = $TS($S($C($EXPECT($L111, fail, 'GetOrSet "get"'), $EXPECT($L112, fail, 'GetOrSet "set"')), NonIdContinue), function($skip, $loc, $0, $1, $2) {
9549
- return { $loc, token: $1 };
9577
+ return { $loc, token: $1, type: "GetOrSet" };
9550
9578
  });
9551
9579
  function GetOrSet(state) {
9552
9580
  if (state.events) {
@@ -10381,7 +10409,7 @@ ${input.slice(result.pos)}
10381
10409
  return result;
10382
10410
  }
10383
10411
  }
10384
- var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L25, fail, 'JSXOpeningElement ">"'));
10412
+ var JSXOpeningElement$0 = $S($EXPECT($L5, fail, 'JSXOpeningElement "<"'), $TEXT(JSXElementName), $E(JSXAttributes), __, $EXPECT($L26, fail, 'JSXOpeningElement ">"'));
10385
10413
  function JSXOpeningElement(state) {
10386
10414
  if (state.events) {
10387
10415
  const result = state.events.enter?.("JSXOpeningElement", state);
@@ -10400,7 +10428,7 @@ ${input.slice(result.pos)}
10400
10428
  return result;
10401
10429
  }
10402
10430
  }
10403
- var JSXClosingElement$0 = $S($EXPECT($L144, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L25, fail, 'JSXClosingElement ">"'));
10431
+ var JSXClosingElement$0 = $S($EXPECT($L144, fail, 'JSXClosingElement "</"'), __, $TEXT(JSXElementName), __, $EXPECT($L26, fail, 'JSXClosingElement ">"'));
10404
10432
  function JSXClosingElement(state) {
10405
10433
  if (state.events) {
10406
10434
  const result = state.events.enter?.("JSXClosingElement", state);
@@ -10498,7 +10526,44 @@ ${input.slice(result.pos)}
10498
10526
  return result;
10499
10527
  }
10500
10528
  }
10501
- var JSXAttribute$0 = $S(OpenBrace, __, DotDotDot, ExtendedExpression, __, CloseBrace);
10529
+ var JSXAttribute$0 = $TS($S(BracedObjectLiteral), function($skip, $loc, $0, $1) {
10530
+ const { children } = $1;
10531
+ const parts = [];
10532
+ const rest = [];
10533
+ for (let i = 1; i < children.length - 1; i++) {
10534
+ if (i > 1)
10535
+ parts.push(" ");
10536
+ const part = children[i];
10537
+ switch (part.type) {
10538
+ case "Identifier":
10539
+ parts.push([part.name, "={", part.name, "}"]);
10540
+ break;
10541
+ case "Property":
10542
+ if (part.name.type === "ComputedPropertyName") {
10543
+ rest.push(part);
10544
+ } else {
10545
+ parts.push([part.name, "={", module2.insertTrimmingSpace(part.value, ""), "}"]);
10546
+ }
10547
+ break;
10548
+ case "SpreadProperty":
10549
+ parts.push(["{", part.value, "}"]);
10550
+ break;
10551
+ case "MethodDefinition":
10552
+ try {
10553
+ parts.push([part.name, "={", module2.convertMethodToFunction(part), "}"]);
10554
+ } catch {
10555
+ rest.push(part);
10556
+ }
10557
+ break;
10558
+ default:
10559
+ throw new Error(`invalid object literal type in JSX attribute: ${part.type}`);
10560
+ }
10561
+ }
10562
+ if (rest.length) {
10563
+ parts.push(["{...{", ...rest, "}}"]);
10564
+ }
10565
+ return parts;
10566
+ });
10502
10567
  var JSXAttribute$1 = $S(JSXAttributeName, $E(JSXAttributeInitializer));
10503
10568
  function JSXAttribute(state) {
10504
10569
  if (state.events) {
@@ -11408,7 +11473,7 @@ ${input.slice(result.pos)}
11408
11473
  return result;
11409
11474
  }
11410
11475
  }
11411
- var TypeArguments$0 = $S(__, $EXPECT($L5, fail, 'TypeArguments "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L25, fail, 'TypeArguments ">"'));
11476
+ var TypeArguments$0 = $S(__, $EXPECT($L5, fail, 'TypeArguments "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L26, fail, 'TypeArguments ">"'));
11412
11477
  function TypeArguments(state) {
11413
11478
  if (state.events) {
11414
11479
  const result = state.events.enter?.("TypeArguments", state);
@@ -11427,7 +11492,7 @@ ${input.slice(result.pos)}
11427
11492
  return result;
11428
11493
  }
11429
11494
  }
11430
- var TypeParameters$0 = $TS($S(__, $EXPECT($L5, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L25, fail, 'TypeParameters ">"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
11495
+ var TypeParameters$0 = $TS($S(__, $EXPECT($L5, fail, 'TypeParameters "<"'), __, Type, $Q($S(__, Comma, __, Type)), $E($S(__, Comma)), __, $EXPECT($L26, fail, 'TypeParameters ">"')), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
11431
11496
  return { ts: true, children: $0 };
11432
11497
  });
11433
11498
  function TypeParameters(state) {
@@ -11487,8 +11552,8 @@ ${input.slice(result.pos)}
11487
11552
  }
11488
11553
  }
11489
11554
  var TypeParameterDelimiter$0 = $S($Q(_), Comma);
11490
- var TypeParameterDelimiter$1 = $Y($S($Q(_), $EXPECT($L25, fail, 'TypeParameterDelimiter ">"')));
11491
- var TypeParameterDelimiter$2 = $TV($Y($S(__, $EXPECT($L25, fail, 'TypeParameterDelimiter ">"'))), function($skip, $loc, $0, $1) {
11555
+ var TypeParameterDelimiter$1 = $Y($S($Q(_), $EXPECT($L26, fail, 'TypeParameterDelimiter ">"')));
11556
+ var TypeParameterDelimiter$2 = $TV($Y($S(__, $EXPECT($L26, fail, 'TypeParameterDelimiter ">"'))), function($skip, $loc, $0, $1) {
11492
11557
  return { $loc, token: "," };
11493
11558
  });
11494
11559
  var TypeParameterDelimiter$3 = $TV($Y(EOS), function($skip, $loc, $0, $1) {
@@ -12606,6 +12671,8 @@ ${input.slice(result.pos)}
12606
12671
  module2.isWhitespaceOrEmpty = function(node) {
12607
12672
  if (!node)
12608
12673
  return true;
12674
+ if (node.token)
12675
+ return node.token.match(/^\s*$/);
12609
12676
  if (!node.length)
12610
12677
  return true;
12611
12678
  if (typeof node === "string")
@@ -13002,6 +13069,32 @@ ${input.slice(result.pos)}
13002
13069
  throw new Error("Unknown postfix statement");
13003
13070
  }
13004
13071
  };
13072
+ module2.convertMethodToFunction = function(method) {
13073
+ const { decorators, signature, block } = method;
13074
+ let opening = signature.children[0];
13075
+ if (opening) {
13076
+ if (opening[0].type === "GetOrSet") {
13077
+ throw new Error("cannot convert get/set method to function");
13078
+ } else if (opening[0][0]?.type === "Async") {
13079
+ opening = [opening[0][0], " function ", ...opening.slice(1)];
13080
+ } else {
13081
+ opening = ["function ", ...opening];
13082
+ }
13083
+ } else {
13084
+ opening = "function ";
13085
+ }
13086
+ return {
13087
+ ...signature,
13088
+ id: signature.name,
13089
+ type: "FunctionExpression",
13090
+ children: [
13091
+ decorators,
13092
+ [opening, ...signature.children.slice(1)],
13093
+ block
13094
+ ],
13095
+ block
13096
+ };
13097
+ };
13005
13098
  module2.processProgram = function(statements) {
13006
13099
  processAssignments(statements);
13007
13100
  processFunctions(statements);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.4.28",
3
+ "version": "0.4.30",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {