@danielx/civet 0.6.5 → 0.6.7

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
@@ -1106,6 +1106,16 @@ var Civet = (() => {
1106
1106
  }
1107
1107
  return node;
1108
1108
  }
1109
+ function makeEmptyBlock() {
1110
+ const expressions = [];
1111
+ return {
1112
+ type: "BlockStatement",
1113
+ expressions,
1114
+ children: ["{", expressions, "}"],
1115
+ bare: false,
1116
+ empty: true
1117
+ };
1118
+ }
1109
1119
  function makeLeftHandSideExpression(expression) {
1110
1120
  switch (expression.type) {
1111
1121
  case "Ref":
@@ -1334,14 +1344,25 @@ var Civet = (() => {
1334
1344
  }
1335
1345
  });
1336
1346
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1347
+ const { abstract, block, signature } = f;
1348
+ if (!abstract && !block) {
1349
+ const { name } = signature, { parent } = f, { elements } = parent, currentIndex = elements.findIndex(([, def]) => def === f);
1350
+ const following = elements[currentIndex + 1]?.[1];
1351
+ if (following?.signature?.name !== name) {
1352
+ const block2 = makeEmptyBlock();
1353
+ block2.parent = f;
1354
+ f.block = block2;
1355
+ f.children.push(block2);
1356
+ }
1357
+ }
1337
1358
  processParams(f);
1338
1359
  if (!processReturnValue(f) && config.implicitReturns) {
1339
- const { signature, block } = f;
1340
- const isConstructor = signature.name === "constructor";
1341
- const isVoid = isVoidType(signature.returnType?.t);
1342
- const isSet = signature.modifier?.set;
1360
+ const { signature: signature2, block: block2 } = f;
1361
+ const isConstructor = signature2.name === "constructor";
1362
+ const isVoid = isVoidType(signature2.returnType?.t);
1363
+ const isSet = signature2.modifier?.set;
1343
1364
  if (!isConstructor && !isSet && !isVoid) {
1344
- insertReturn(block);
1365
+ insertReturn(block2);
1345
1366
  }
1346
1367
  }
1347
1368
  });
@@ -2462,7 +2483,9 @@ var Civet = (() => {
2462
2483
  lastAccessInCallExpression,
2463
2484
  literalValue,
2464
2485
  makeAsConst,
2486
+ makeEmptyBlock,
2465
2487
  makeLeftHandSideExpression,
2488
+ maybeRef,
2466
2489
  modifyString,
2467
2490
  needsRef,
2468
2491
  processBinaryOpExpression,
@@ -5691,8 +5714,22 @@ ${input.slice(result.pos)}
5691
5714
  return result;
5692
5715
  }
5693
5716
  }
5694
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5695
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5717
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5718
+ var elements = $3;
5719
+ return {
5720
+ type: "ClassBody",
5721
+ children: $0,
5722
+ elements
5723
+ };
5724
+ });
5725
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5726
+ var elements = $2;
5727
+ return {
5728
+ type: "ClassBody",
5729
+ children: $0,
5730
+ elements
5731
+ };
5732
+ });
5696
5733
  function ClassBody(state) {
5697
5734
  let eventData;
5698
5735
  if (state.events) {
@@ -5766,8 +5803,19 @@ ${input.slice(result.pos)}
5766
5803
  return result;
5767
5804
  }
5768
5805
  }
5769
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5770
- var ClassElement$1 = $S(Static, BracedBlock);
5806
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5807
+ var definition = $4;
5808
+ return {
5809
+ ...definition,
5810
+ children: [$1, $2, $3, ...definition.children]
5811
+ };
5812
+ });
5813
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5814
+ return {
5815
+ type: "ClassStaticBlock",
5816
+ children: $0
5817
+ };
5818
+ });
5771
5819
  function ClassElement(state) {
5772
5820
  let eventData;
5773
5821
  if (state.events) {
@@ -5983,7 +6031,10 @@ ${input.slice(result.pos)}
5983
6031
  children
5984
6032
  };
5985
6033
  default:
5986
- return [id, " = ", exp];
6034
+ return {
6035
+ type: "FieldDefinition",
6036
+ children: [id, " = ", exp]
6037
+ };
5987
6038
  }
5988
6039
  });
5989
6040
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5993,12 +6044,18 @@ ${input.slice(result.pos)}
5993
6044
  pos: ca.$loc.pos - 1,
5994
6045
  length: ca.$loc.length + 1
5995
6046
  };
5996
- return $0;
6047
+ return {
6048
+ type: "FieldDefinition",
6049
+ children: $0
6050
+ };
5997
6051
  });
5998
6052
  var FieldDefinition$2 = $TS($S($E($S(Abstract, $E(_))), $E($S(Readonly, $E(_))), ClassElementName, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5999
6053
  if ($1)
6000
6054
  return { children: $0, ts: true };
6001
- return $0;
6055
+ return {
6056
+ type: "FieldDefinition",
6057
+ children: $0
6058
+ };
6002
6059
  });
6003
6060
  function FieldDefinition(state) {
6004
6061
  let eventData;
@@ -6330,11 +6387,11 @@ ${input.slice(result.pos)}
6330
6387
  }
6331
6388
  var MemberBracketContent$0 = $TS($S(OpenBracket, $C(SliceParameters, PostfixedExpression), __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
6332
6389
  var open = $1;
6333
- var exp = $2;
6390
+ var expression = $2;
6334
6391
  var ws = $3;
6335
6392
  var close = $4;
6336
- if (exp.type === "SliceParameters") {
6337
- const { start, end, children } = exp;
6393
+ if (expression.type === "SliceParameters") {
6394
+ const { start, end, children } = expression;
6338
6395
  return {
6339
6396
  type: "SliceExpression",
6340
6397
  start,
@@ -6348,7 +6405,8 @@ ${input.slice(result.pos)}
6348
6405
  }
6349
6406
  return {
6350
6407
  type: "Index",
6351
- children: $0
6408
+ children: $0,
6409
+ expression
6352
6410
  };
6353
6411
  });
6354
6412
  var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral)), function($skip, $loc, $0, $1, $2) {
@@ -9711,7 +9769,7 @@ ${input.slice(result.pos)}
9711
9769
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9712
9770
  var ws = $1;
9713
9771
  var def = $2;
9714
- if (def.block.empty)
9772
+ if (!def.block || def.block.empty)
9715
9773
  return $skip;
9716
9774
  return {
9717
9775
  ...def,
@@ -9739,12 +9797,40 @@ ${input.slice(result.pos)}
9739
9797
  const last = lastAccessInCallExpression(value);
9740
9798
  if (!last)
9741
9799
  return $skip;
9742
- let name;
9743
- if (last.type === "Index") {
9744
- name = {
9745
- type: "ComputedPropertyName",
9746
- children: last.children
9747
- };
9800
+ let name, hoistDec, ref, refAssignment;
9801
+ const { expression, type } = last;
9802
+ if (type === "Index") {
9803
+ ref = maybeRef(expression);
9804
+ if (ref !== expression) {
9805
+ hoistDec = {
9806
+ type: "Declaration",
9807
+ children: ["let ", ref]
9808
+ };
9809
+ refAssignment = {
9810
+ type: "Assignment",
9811
+ children: [ref, " = ", expression]
9812
+ };
9813
+ name = {
9814
+ type: "ComputedPropertyName",
9815
+ children: [last.children[0], "(", refAssignment, ",", ref, ")", ...last.children.slice(-2)]
9816
+ };
9817
+ value = {
9818
+ ...value,
9819
+ children: value.children.map((c) => {
9820
+ if (c === last)
9821
+ return {
9822
+ type: "Index",
9823
+ children: ["[", ref, "]"]
9824
+ };
9825
+ return c;
9826
+ })
9827
+ };
9828
+ } else {
9829
+ name = {
9830
+ type: "ComputedPropertyName",
9831
+ children: last.children
9832
+ };
9833
+ }
9748
9834
  } else {
9749
9835
  ({ name } = last);
9750
9836
  if (!name)
@@ -9755,7 +9841,8 @@ ${input.slice(result.pos)}
9755
9841
  children: [ws, name, ": ", value],
9756
9842
  name,
9757
9843
  value,
9758
- names: []
9844
+ names: [],
9845
+ hoistDec
9759
9846
  };
9760
9847
  });
9761
9848
  function PropertyDefinition(state) {
@@ -10005,12 +10092,13 @@ ${input.slice(result.pos)}
10005
10092
  type: "MethodDefinition",
10006
10093
  children: $0,
10007
10094
  name: signature.name,
10095
+ abstract: true,
10008
10096
  signature,
10009
10097
  parameters: signature.parameters,
10010
10098
  ts: true
10011
10099
  };
10012
10100
  });
10013
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10101
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10014
10102
  var signature = $1;
10015
10103
  var block = $3;
10016
10104
  let children = $0;
@@ -10140,7 +10228,7 @@ ${input.slice(result.pos)}
10140
10228
  var modifier = $1;
10141
10229
  var name = $2;
10142
10230
  var parameters = $4;
10143
- var suffix = $5;
10231
+ var returnType = $5;
10144
10232
  if (name.name) {
10145
10233
  name = name.name;
10146
10234
  } else if (name.token) {
@@ -10151,7 +10239,7 @@ ${input.slice(result.pos)}
10151
10239
  children: $0,
10152
10240
  name,
10153
10241
  modifier,
10154
- returnType: suffix,
10242
+ returnType,
10155
10243
  parameters
10156
10244
  };
10157
10245
  });
@@ -12653,14 +12741,7 @@ ${input.slice(result.pos)}
12653
12741
  var c = $4;
12654
12742
  var f = $5;
12655
12743
  if (!c && !f) {
12656
- const e = [];
12657
- const emptyCatchBlock = {
12658
- type: "BlockStatement",
12659
- expressions: e,
12660
- children: ["{", e, "}"],
12661
- bare: false,
12662
- empty: true
12663
- };
12744
+ const emptyCatchBlock = makeEmptyBlock();
12664
12745
  c = {
12665
12746
  type: "CatchClause",
12666
12747
  children: [" catch(e) ", emptyCatchBlock],
@@ -23374,7 +23455,9 @@ ${input.slice(result.pos)}
23374
23455
  isWhitespaceOrEmpty,
23375
23456
  lastAccessInCallExpression,
23376
23457
  literalValue,
23458
+ makeEmptyBlock,
23377
23459
  makeLeftHandSideExpression,
23460
+ maybeRef,
23378
23461
  modifyString,
23379
23462
  processBinaryOpExpression,
23380
23463
  processCallMemberExpression,
package/dist/main.js CHANGED
@@ -1105,6 +1105,16 @@ var require_lib = __commonJS({
1105
1105
  }
1106
1106
  return node;
1107
1107
  }
1108
+ function makeEmptyBlock() {
1109
+ const expressions = [];
1110
+ return {
1111
+ type: "BlockStatement",
1112
+ expressions,
1113
+ children: ["{", expressions, "}"],
1114
+ bare: false,
1115
+ empty: true
1116
+ };
1117
+ }
1108
1118
  function makeLeftHandSideExpression(expression) {
1109
1119
  switch (expression.type) {
1110
1120
  case "Ref":
@@ -1333,14 +1343,25 @@ var require_lib = __commonJS({
1333
1343
  }
1334
1344
  });
1335
1345
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1346
+ const { abstract, block, signature } = f;
1347
+ if (!abstract && !block) {
1348
+ const { name } = signature, { parent } = f, { elements } = parent, currentIndex = elements.findIndex(([, def]) => def === f);
1349
+ const following = elements[currentIndex + 1]?.[1];
1350
+ if (following?.signature?.name !== name) {
1351
+ const block2 = makeEmptyBlock();
1352
+ block2.parent = f;
1353
+ f.block = block2;
1354
+ f.children.push(block2);
1355
+ }
1356
+ }
1336
1357
  processParams(f);
1337
1358
  if (!processReturnValue(f) && config.implicitReturns) {
1338
- const { signature, block } = f;
1339
- const isConstructor = signature.name === "constructor";
1340
- const isVoid = isVoidType(signature.returnType?.t);
1341
- const isSet = signature.modifier?.set;
1359
+ const { signature: signature2, block: block2 } = f;
1360
+ const isConstructor = signature2.name === "constructor";
1361
+ const isVoid = isVoidType(signature2.returnType?.t);
1362
+ const isSet = signature2.modifier?.set;
1342
1363
  if (!isConstructor && !isSet && !isVoid) {
1343
- insertReturn(block);
1364
+ insertReturn(block2);
1344
1365
  }
1345
1366
  }
1346
1367
  });
@@ -2461,7 +2482,9 @@ var require_lib = __commonJS({
2461
2482
  lastAccessInCallExpression,
2462
2483
  literalValue,
2463
2484
  makeAsConst,
2485
+ makeEmptyBlock,
2464
2486
  makeLeftHandSideExpression,
2487
+ maybeRef,
2465
2488
  modifyString,
2466
2489
  needsRef,
2467
2490
  processBinaryOpExpression,
@@ -5690,8 +5713,22 @@ ${input.slice(result.pos)}
5690
5713
  return result;
5691
5714
  }
5692
5715
  }
5693
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5694
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5716
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5717
+ var elements = $3;
5718
+ return {
5719
+ type: "ClassBody",
5720
+ children: $0,
5721
+ elements
5722
+ };
5723
+ });
5724
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5725
+ var elements = $2;
5726
+ return {
5727
+ type: "ClassBody",
5728
+ children: $0,
5729
+ elements
5730
+ };
5731
+ });
5695
5732
  function ClassBody(state) {
5696
5733
  let eventData;
5697
5734
  if (state.events) {
@@ -5765,8 +5802,19 @@ ${input.slice(result.pos)}
5765
5802
  return result;
5766
5803
  }
5767
5804
  }
5768
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5769
- var ClassElement$1 = $S(Static, BracedBlock);
5805
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5806
+ var definition = $4;
5807
+ return {
5808
+ ...definition,
5809
+ children: [$1, $2, $3, ...definition.children]
5810
+ };
5811
+ });
5812
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5813
+ return {
5814
+ type: "ClassStaticBlock",
5815
+ children: $0
5816
+ };
5817
+ });
5770
5818
  function ClassElement(state) {
5771
5819
  let eventData;
5772
5820
  if (state.events) {
@@ -5982,7 +6030,10 @@ ${input.slice(result.pos)}
5982
6030
  children
5983
6031
  };
5984
6032
  default:
5985
- return [id, " = ", exp];
6033
+ return {
6034
+ type: "FieldDefinition",
6035
+ children: [id, " = ", exp]
6036
+ };
5986
6037
  }
5987
6038
  });
5988
6039
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5992,12 +6043,18 @@ ${input.slice(result.pos)}
5992
6043
  pos: ca.$loc.pos - 1,
5993
6044
  length: ca.$loc.length + 1
5994
6045
  };
5995
- return $0;
6046
+ return {
6047
+ type: "FieldDefinition",
6048
+ children: $0
6049
+ };
5996
6050
  });
5997
6051
  var FieldDefinition$2 = $TS($S($E($S(Abstract, $E(_))), $E($S(Readonly, $E(_))), ClassElementName, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5998
6052
  if ($1)
5999
6053
  return { children: $0, ts: true };
6000
- return $0;
6054
+ return {
6055
+ type: "FieldDefinition",
6056
+ children: $0
6057
+ };
6001
6058
  });
6002
6059
  function FieldDefinition(state) {
6003
6060
  let eventData;
@@ -6329,11 +6386,11 @@ ${input.slice(result.pos)}
6329
6386
  }
6330
6387
  var MemberBracketContent$0 = $TS($S(OpenBracket, $C(SliceParameters, PostfixedExpression), __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
6331
6388
  var open = $1;
6332
- var exp = $2;
6389
+ var expression = $2;
6333
6390
  var ws = $3;
6334
6391
  var close = $4;
6335
- if (exp.type === "SliceParameters") {
6336
- const { start, end, children } = exp;
6392
+ if (expression.type === "SliceParameters") {
6393
+ const { start, end, children } = expression;
6337
6394
  return {
6338
6395
  type: "SliceExpression",
6339
6396
  start,
@@ -6347,7 +6404,8 @@ ${input.slice(result.pos)}
6347
6404
  }
6348
6405
  return {
6349
6406
  type: "Index",
6350
- children: $0
6407
+ children: $0,
6408
+ expression
6351
6409
  };
6352
6410
  });
6353
6411
  var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral)), function($skip, $loc, $0, $1, $2) {
@@ -9710,7 +9768,7 @@ ${input.slice(result.pos)}
9710
9768
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9711
9769
  var ws = $1;
9712
9770
  var def = $2;
9713
- if (def.block.empty)
9771
+ if (!def.block || def.block.empty)
9714
9772
  return $skip;
9715
9773
  return {
9716
9774
  ...def,
@@ -9738,12 +9796,40 @@ ${input.slice(result.pos)}
9738
9796
  const last = lastAccessInCallExpression(value);
9739
9797
  if (!last)
9740
9798
  return $skip;
9741
- let name;
9742
- if (last.type === "Index") {
9743
- name = {
9744
- type: "ComputedPropertyName",
9745
- children: last.children
9746
- };
9799
+ let name, hoistDec, ref, refAssignment;
9800
+ const { expression, type } = last;
9801
+ if (type === "Index") {
9802
+ ref = maybeRef(expression);
9803
+ if (ref !== expression) {
9804
+ hoistDec = {
9805
+ type: "Declaration",
9806
+ children: ["let ", ref]
9807
+ };
9808
+ refAssignment = {
9809
+ type: "Assignment",
9810
+ children: [ref, " = ", expression]
9811
+ };
9812
+ name = {
9813
+ type: "ComputedPropertyName",
9814
+ children: [last.children[0], "(", refAssignment, ",", ref, ")", ...last.children.slice(-2)]
9815
+ };
9816
+ value = {
9817
+ ...value,
9818
+ children: value.children.map((c) => {
9819
+ if (c === last)
9820
+ return {
9821
+ type: "Index",
9822
+ children: ["[", ref, "]"]
9823
+ };
9824
+ return c;
9825
+ })
9826
+ };
9827
+ } else {
9828
+ name = {
9829
+ type: "ComputedPropertyName",
9830
+ children: last.children
9831
+ };
9832
+ }
9747
9833
  } else {
9748
9834
  ({ name } = last);
9749
9835
  if (!name)
@@ -9754,7 +9840,8 @@ ${input.slice(result.pos)}
9754
9840
  children: [ws, name, ": ", value],
9755
9841
  name,
9756
9842
  value,
9757
- names: []
9843
+ names: [],
9844
+ hoistDec
9758
9845
  };
9759
9846
  });
9760
9847
  function PropertyDefinition(state) {
@@ -10004,12 +10091,13 @@ ${input.slice(result.pos)}
10004
10091
  type: "MethodDefinition",
10005
10092
  children: $0,
10006
10093
  name: signature.name,
10094
+ abstract: true,
10007
10095
  signature,
10008
10096
  parameters: signature.parameters,
10009
10097
  ts: true
10010
10098
  };
10011
10099
  });
10012
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10100
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10013
10101
  var signature = $1;
10014
10102
  var block = $3;
10015
10103
  let children = $0;
@@ -10139,7 +10227,7 @@ ${input.slice(result.pos)}
10139
10227
  var modifier = $1;
10140
10228
  var name = $2;
10141
10229
  var parameters = $4;
10142
- var suffix = $5;
10230
+ var returnType = $5;
10143
10231
  if (name.name) {
10144
10232
  name = name.name;
10145
10233
  } else if (name.token) {
@@ -10150,7 +10238,7 @@ ${input.slice(result.pos)}
10150
10238
  children: $0,
10151
10239
  name,
10152
10240
  modifier,
10153
- returnType: suffix,
10241
+ returnType,
10154
10242
  parameters
10155
10243
  };
10156
10244
  });
@@ -12652,14 +12740,7 @@ ${input.slice(result.pos)}
12652
12740
  var c = $4;
12653
12741
  var f = $5;
12654
12742
  if (!c && !f) {
12655
- const e = [];
12656
- const emptyCatchBlock = {
12657
- type: "BlockStatement",
12658
- expressions: e,
12659
- children: ["{", e, "}"],
12660
- bare: false,
12661
- empty: true
12662
- };
12743
+ const emptyCatchBlock = makeEmptyBlock();
12663
12744
  c = {
12664
12745
  type: "CatchClause",
12665
12746
  children: [" catch(e) ", emptyCatchBlock],
@@ -23373,7 +23454,9 @@ ${input.slice(result.pos)}
23373
23454
  isWhitespaceOrEmpty,
23374
23455
  lastAccessInCallExpression,
23375
23456
  literalValue,
23457
+ makeEmptyBlock,
23376
23458
  makeLeftHandSideExpression,
23459
+ maybeRef,
23377
23460
  modifyString,
23378
23461
  processBinaryOpExpression,
23379
23462
  processCallMemberExpression,
package/dist/main.mjs CHANGED
@@ -1103,6 +1103,16 @@ var require_lib = __commonJS({
1103
1103
  }
1104
1104
  return node;
1105
1105
  }
1106
+ function makeEmptyBlock() {
1107
+ const expressions = [];
1108
+ return {
1109
+ type: "BlockStatement",
1110
+ expressions,
1111
+ children: ["{", expressions, "}"],
1112
+ bare: false,
1113
+ empty: true
1114
+ };
1115
+ }
1106
1116
  function makeLeftHandSideExpression(expression) {
1107
1117
  switch (expression.type) {
1108
1118
  case "Ref":
@@ -1331,14 +1341,25 @@ var require_lib = __commonJS({
1331
1341
  }
1332
1342
  });
1333
1343
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1344
+ const { abstract, block, signature } = f;
1345
+ if (!abstract && !block) {
1346
+ const { name } = signature, { parent } = f, { elements } = parent, currentIndex = elements.findIndex(([, def]) => def === f);
1347
+ const following = elements[currentIndex + 1]?.[1];
1348
+ if (following?.signature?.name !== name) {
1349
+ const block2 = makeEmptyBlock();
1350
+ block2.parent = f;
1351
+ f.block = block2;
1352
+ f.children.push(block2);
1353
+ }
1354
+ }
1334
1355
  processParams(f);
1335
1356
  if (!processReturnValue(f) && config.implicitReturns) {
1336
- const { signature, block } = f;
1337
- const isConstructor = signature.name === "constructor";
1338
- const isVoid = isVoidType(signature.returnType?.t);
1339
- const isSet = signature.modifier?.set;
1357
+ const { signature: signature2, block: block2 } = f;
1358
+ const isConstructor = signature2.name === "constructor";
1359
+ const isVoid = isVoidType(signature2.returnType?.t);
1360
+ const isSet = signature2.modifier?.set;
1340
1361
  if (!isConstructor && !isSet && !isVoid) {
1341
- insertReturn(block);
1362
+ insertReturn(block2);
1342
1363
  }
1343
1364
  }
1344
1365
  });
@@ -2459,7 +2480,9 @@ var require_lib = __commonJS({
2459
2480
  lastAccessInCallExpression,
2460
2481
  literalValue,
2461
2482
  makeAsConst,
2483
+ makeEmptyBlock,
2462
2484
  makeLeftHandSideExpression,
2485
+ maybeRef,
2463
2486
  modifyString,
2464
2487
  needsRef,
2465
2488
  processBinaryOpExpression,
@@ -5688,8 +5711,22 @@ ${input.slice(result.pos)}
5688
5711
  return result;
5689
5712
  }
5690
5713
  }
5691
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5692
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5714
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5715
+ var elements = $3;
5716
+ return {
5717
+ type: "ClassBody",
5718
+ children: $0,
5719
+ elements
5720
+ };
5721
+ });
5722
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5723
+ var elements = $2;
5724
+ return {
5725
+ type: "ClassBody",
5726
+ children: $0,
5727
+ elements
5728
+ };
5729
+ });
5693
5730
  function ClassBody(state) {
5694
5731
  let eventData;
5695
5732
  if (state.events) {
@@ -5763,8 +5800,19 @@ ${input.slice(result.pos)}
5763
5800
  return result;
5764
5801
  }
5765
5802
  }
5766
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5767
- var ClassElement$1 = $S(Static, BracedBlock);
5803
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5804
+ var definition = $4;
5805
+ return {
5806
+ ...definition,
5807
+ children: [$1, $2, $3, ...definition.children]
5808
+ };
5809
+ });
5810
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5811
+ return {
5812
+ type: "ClassStaticBlock",
5813
+ children: $0
5814
+ };
5815
+ });
5768
5816
  function ClassElement(state) {
5769
5817
  let eventData;
5770
5818
  if (state.events) {
@@ -5980,7 +6028,10 @@ ${input.slice(result.pos)}
5980
6028
  children
5981
6029
  };
5982
6030
  default:
5983
- return [id, " = ", exp];
6031
+ return {
6032
+ type: "FieldDefinition",
6033
+ children: [id, " = ", exp]
6034
+ };
5984
6035
  }
5985
6036
  });
5986
6037
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5990,12 +6041,18 @@ ${input.slice(result.pos)}
5990
6041
  pos: ca.$loc.pos - 1,
5991
6042
  length: ca.$loc.length + 1
5992
6043
  };
5993
- return $0;
6044
+ return {
6045
+ type: "FieldDefinition",
6046
+ children: $0
6047
+ };
5994
6048
  });
5995
6049
  var FieldDefinition$2 = $TS($S($E($S(Abstract, $E(_))), $E($S(Readonly, $E(_))), ClassElementName, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5996
6050
  if ($1)
5997
6051
  return { children: $0, ts: true };
5998
- return $0;
6052
+ return {
6053
+ type: "FieldDefinition",
6054
+ children: $0
6055
+ };
5999
6056
  });
6000
6057
  function FieldDefinition(state) {
6001
6058
  let eventData;
@@ -6327,11 +6384,11 @@ ${input.slice(result.pos)}
6327
6384
  }
6328
6385
  var MemberBracketContent$0 = $TS($S(OpenBracket, $C(SliceParameters, PostfixedExpression), __, CloseBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
6329
6386
  var open = $1;
6330
- var exp = $2;
6387
+ var expression = $2;
6331
6388
  var ws = $3;
6332
6389
  var close = $4;
6333
- if (exp.type === "SliceParameters") {
6334
- const { start, end, children } = exp;
6390
+ if (expression.type === "SliceParameters") {
6391
+ const { start, end, children } = expression;
6335
6392
  return {
6336
6393
  type: "SliceExpression",
6337
6394
  start,
@@ -6345,7 +6402,8 @@ ${input.slice(result.pos)}
6345
6402
  }
6346
6403
  return {
6347
6404
  type: "Index",
6348
- children: $0
6405
+ children: $0,
6406
+ expression
6349
6407
  };
6350
6408
  });
6351
6409
  var MemberBracketContent$1 = $TS($S(Dot, $C(TemplateLiteral, StringLiteral)), function($skip, $loc, $0, $1, $2) {
@@ -9708,7 +9766,7 @@ ${input.slice(result.pos)}
9708
9766
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9709
9767
  var ws = $1;
9710
9768
  var def = $2;
9711
- if (def.block.empty)
9769
+ if (!def.block || def.block.empty)
9712
9770
  return $skip;
9713
9771
  return {
9714
9772
  ...def,
@@ -9736,12 +9794,40 @@ ${input.slice(result.pos)}
9736
9794
  const last = lastAccessInCallExpression(value);
9737
9795
  if (!last)
9738
9796
  return $skip;
9739
- let name;
9740
- if (last.type === "Index") {
9741
- name = {
9742
- type: "ComputedPropertyName",
9743
- children: last.children
9744
- };
9797
+ let name, hoistDec, ref, refAssignment;
9798
+ const { expression, type } = last;
9799
+ if (type === "Index") {
9800
+ ref = maybeRef(expression);
9801
+ if (ref !== expression) {
9802
+ hoistDec = {
9803
+ type: "Declaration",
9804
+ children: ["let ", ref]
9805
+ };
9806
+ refAssignment = {
9807
+ type: "Assignment",
9808
+ children: [ref, " = ", expression]
9809
+ };
9810
+ name = {
9811
+ type: "ComputedPropertyName",
9812
+ children: [last.children[0], "(", refAssignment, ",", ref, ")", ...last.children.slice(-2)]
9813
+ };
9814
+ value = {
9815
+ ...value,
9816
+ children: value.children.map((c) => {
9817
+ if (c === last)
9818
+ return {
9819
+ type: "Index",
9820
+ children: ["[", ref, "]"]
9821
+ };
9822
+ return c;
9823
+ })
9824
+ };
9825
+ } else {
9826
+ name = {
9827
+ type: "ComputedPropertyName",
9828
+ children: last.children
9829
+ };
9830
+ }
9745
9831
  } else {
9746
9832
  ({ name } = last);
9747
9833
  if (!name)
@@ -9752,7 +9838,8 @@ ${input.slice(result.pos)}
9752
9838
  children: [ws, name, ": ", value],
9753
9839
  name,
9754
9840
  value,
9755
- names: []
9841
+ names: [],
9842
+ hoistDec
9756
9843
  };
9757
9844
  });
9758
9845
  function PropertyDefinition(state) {
@@ -10002,12 +10089,13 @@ ${input.slice(result.pos)}
10002
10089
  type: "MethodDefinition",
10003
10090
  children: $0,
10004
10091
  name: signature.name,
10092
+ abstract: true,
10005
10093
  signature,
10006
10094
  parameters: signature.parameters,
10007
10095
  ts: true
10008
10096
  };
10009
10097
  });
10010
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10098
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10011
10099
  var signature = $1;
10012
10100
  var block = $3;
10013
10101
  let children = $0;
@@ -10137,7 +10225,7 @@ ${input.slice(result.pos)}
10137
10225
  var modifier = $1;
10138
10226
  var name = $2;
10139
10227
  var parameters = $4;
10140
- var suffix = $5;
10228
+ var returnType = $5;
10141
10229
  if (name.name) {
10142
10230
  name = name.name;
10143
10231
  } else if (name.token) {
@@ -10148,7 +10236,7 @@ ${input.slice(result.pos)}
10148
10236
  children: $0,
10149
10237
  name,
10150
10238
  modifier,
10151
- returnType: suffix,
10239
+ returnType,
10152
10240
  parameters
10153
10241
  };
10154
10242
  });
@@ -12650,14 +12738,7 @@ ${input.slice(result.pos)}
12650
12738
  var c = $4;
12651
12739
  var f = $5;
12652
12740
  if (!c && !f) {
12653
- const e = [];
12654
- const emptyCatchBlock = {
12655
- type: "BlockStatement",
12656
- expressions: e,
12657
- children: ["{", e, "}"],
12658
- bare: false,
12659
- empty: true
12660
- };
12741
+ const emptyCatchBlock = makeEmptyBlock();
12661
12742
  c = {
12662
12743
  type: "CatchClause",
12663
12744
  children: [" catch(e) ", emptyCatchBlock],
@@ -23371,7 +23452,9 @@ ${input.slice(result.pos)}
23371
23452
  isWhitespaceOrEmpty,
23372
23453
  lastAccessInCallExpression,
23373
23454
  literalValue,
23455
+ makeEmptyBlock,
23374
23456
  makeLeftHandSideExpression,
23457
+ maybeRef,
23375
23458
  modifyString,
23376
23459
  processBinaryOpExpression,
23377
23460
  processCallMemberExpression,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",