@danielx/civet 0.6.6 → 0.6.8

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.
@@ -0,0 +1,25 @@
1
+ import { compile } from "./main.mjs"
2
+
3
+ export default function (api, civetOptions) {
4
+ return {
5
+ parserOverride(code, opts, parse) {
6
+ let src
7
+ if (opts.sourceFileName.endsWith(".civet")) {
8
+ const config = Object.assign({}, civetOptions, {
9
+ filename: opts.sourceFileName,
10
+ sourceMap: opts.sourceMaps ?? true,
11
+ })
12
+
13
+ if (config.sourceMap) {
14
+ ({ code: src } = compile(code, config))
15
+ } else {
16
+ src = compile(code, config)
17
+ }
18
+ } else {
19
+ src = code
20
+ }
21
+ const ast = parse(src, opts)
22
+ return ast
23
+ }
24
+ }
25
+ }
package/dist/browser.js CHANGED
@@ -798,13 +798,14 @@ var Civet = (() => {
798
798
  }
799
799
  function hoistRefDecs(statements) {
800
800
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
801
- const { hoistDec } = node;
801
+ let { hoistDec, parent } = node;
802
802
  node.hoistDec = null;
803
- while (node.parent?.type !== "BlockStatement") {
804
- node = node.parent;
803
+ while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
804
+ node = parent;
805
+ parent = node.parent;
805
806
  }
806
- if (node.parent) {
807
- insertHoistDec(node.parent, node, hoistDec);
807
+ if (parent) {
808
+ insertHoistDec(parent, node, hoistDec);
808
809
  } else {
809
810
  throw new Error("Couldn't find block to hoist declaration into.");
810
811
  }
@@ -1106,6 +1107,16 @@ var Civet = (() => {
1106
1107
  }
1107
1108
  return node;
1108
1109
  }
1110
+ function makeEmptyBlock() {
1111
+ const expressions = [];
1112
+ return {
1113
+ type: "BlockStatement",
1114
+ expressions,
1115
+ children: ["{", expressions, "}"],
1116
+ bare: false,
1117
+ empty: true
1118
+ };
1119
+ }
1109
1120
  function makeLeftHandSideExpression(expression) {
1110
1121
  switch (expression.type) {
1111
1122
  case "Ref":
@@ -1321,8 +1332,27 @@ var Civet = (() => {
1321
1332
  thisAssignments
1322
1333
  };
1323
1334
  }
1335
+ function implicitFunctionBlock(f) {
1336
+ if (f.abstract || f.block)
1337
+ return;
1338
+ const { name, parent } = f;
1339
+ const expressions = parent?.expressions ?? parent?.elements;
1340
+ const currentIndex = expressions?.findIndex(([, def]) => def === f);
1341
+ const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
1342
+ if (f.type === following?.type && name && name === following.name) {
1343
+ f.ts = true;
1344
+ } else {
1345
+ const block = makeEmptyBlock();
1346
+ block.parent = f;
1347
+ f.block = block;
1348
+ f.children.push(block);
1349
+ f.ts = false;
1350
+ }
1351
+ }
1324
1352
  function processFunctions(statements, config) {
1325
1353
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1354
+ if (f.type === "FunctionExpression")
1355
+ implicitFunctionBlock(f);
1326
1356
  processParams(f);
1327
1357
  if (!processReturnValue(f) && config.implicitReturns) {
1328
1358
  const { block, returnType } = f;
@@ -1334,6 +1364,7 @@ var Civet = (() => {
1334
1364
  }
1335
1365
  });
1336
1366
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1367
+ implicitFunctionBlock(f);
1337
1368
  processParams(f);
1338
1369
  if (!processReturnValue(f) && config.implicitReturns) {
1339
1370
  const { signature, block } = f;
@@ -2462,6 +2493,7 @@ var Civet = (() => {
2462
2493
  lastAccessInCallExpression,
2463
2494
  literalValue,
2464
2495
  makeAsConst,
2496
+ makeEmptyBlock,
2465
2497
  makeLeftHandSideExpression,
2466
2498
  maybeRef,
2467
2499
  modifyString,
@@ -3435,6 +3467,7 @@ ${input.slice(result.pos)}
3435
3467
  NestedEnumProperties,
3436
3468
  NestedEnumProperty,
3437
3469
  EnumProperty,
3470
+ TypeProperty,
3438
3471
  TypeIndexSignature,
3439
3472
  TypeIndex,
3440
3473
  TypeSuffix,
@@ -4234,10 +4267,9 @@ ${input.slice(result.pos)}
4234
4267
  }
4235
4268
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4236
4269
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4237
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4238
- var ForbiddenImplicitCalls$3 = AtAt;
4239
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4240
- var ForbiddenImplicitCalls$5 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4270
+ var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, $C(Class, AtAt));
4271
+ var ForbiddenImplicitCalls$3 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4272
+ var ForbiddenImplicitCalls$4 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4241
4273
  if (module.operators.has($1.name))
4242
4274
  return $1;
4243
4275
  return $skip;
@@ -4253,12 +4285,12 @@ ${input.slice(result.pos)}
4253
4285
  }
4254
4286
  }
4255
4287
  if (state.tokenize) {
4256
- const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state));
4288
+ const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state));
4257
4289
  if (state.events)
4258
4290
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4259
4291
  return result;
4260
4292
  } else {
4261
- const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state);
4293
+ const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state);
4262
4294
  if (state.events)
4263
4295
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4264
4296
  return result;
@@ -5692,8 +5724,22 @@ ${input.slice(result.pos)}
5692
5724
  return result;
5693
5725
  }
5694
5726
  }
5695
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5696
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5727
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5728
+ var elements = $3;
5729
+ return {
5730
+ type: "ClassBody",
5731
+ children: $0,
5732
+ elements
5733
+ };
5734
+ });
5735
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5736
+ var elements = $2;
5737
+ return {
5738
+ type: "ClassBody",
5739
+ children: $0,
5740
+ elements
5741
+ };
5742
+ });
5697
5743
  function ClassBody(state) {
5698
5744
  let eventData;
5699
5745
  if (state.events) {
@@ -5767,8 +5813,19 @@ ${input.slice(result.pos)}
5767
5813
  return result;
5768
5814
  }
5769
5815
  }
5770
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5771
- var ClassElement$1 = $S(Static, BracedBlock);
5816
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5817
+ var definition = $4;
5818
+ return {
5819
+ ...definition,
5820
+ children: [$1, $2, $3, ...definition.children]
5821
+ };
5822
+ });
5823
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5824
+ return {
5825
+ type: "ClassStaticBlock",
5826
+ children: $0
5827
+ };
5828
+ });
5772
5829
  function ClassElement(state) {
5773
5830
  let eventData;
5774
5831
  if (state.events) {
@@ -5937,7 +5994,7 @@ ${input.slice(result.pos)}
5937
5994
  return result;
5938
5995
  }
5939
5996
  }
5940
- var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), __)), $E($S(Readonly, __))), function($skip, $loc, $0, $1, $2) {
5997
+ var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), NotDedented)), $E($S(Readonly, NotDedented))), function($skip, $loc, $0, $1, $2) {
5941
5998
  if (!($1 || $2))
5942
5999
  return $skip;
5943
6000
  return {
@@ -5984,7 +6041,10 @@ ${input.slice(result.pos)}
5984
6041
  children
5985
6042
  };
5986
6043
  default:
5987
- return [id, " = ", exp];
6044
+ return {
6045
+ type: "FieldDefinition",
6046
+ children: [id, " = ", exp]
6047
+ };
5988
6048
  }
5989
6049
  });
5990
6050
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5994,12 +6054,18 @@ ${input.slice(result.pos)}
5994
6054
  pos: ca.$loc.pos - 1,
5995
6055
  length: ca.$loc.length + 1
5996
6056
  };
5997
- return $0;
6057
+ return {
6058
+ type: "FieldDefinition",
6059
+ children: $0
6060
+ };
5998
6061
  });
5999
6062
  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) {
6000
6063
  if ($1)
6001
6064
  return { children: $0, ts: true };
6002
- return $0;
6065
+ return {
6066
+ type: "FieldDefinition",
6067
+ children: $0
6068
+ };
6003
6069
  });
6004
6070
  function FieldDefinition(state) {
6005
6071
  let eventData;
@@ -7684,9 +7750,11 @@ ${input.slice(result.pos)}
7684
7750
  async = [];
7685
7751
  if (!generator)
7686
7752
  generator = [];
7753
+ const id = wid?.[1];
7687
7754
  return {
7688
7755
  type: "FunctionSignature",
7689
- id: wid?.[1],
7756
+ id,
7757
+ name: id?.name,
7690
7758
  parameters,
7691
7759
  returnType: suffix,
7692
7760
  ts: false,
@@ -7722,8 +7790,11 @@ ${input.slice(result.pos)}
7722
7790
  var signature = $1;
7723
7791
  var block = $2;
7724
7792
  if (!block) {
7725
- signature.ts = true;
7726
- return signature;
7793
+ return {
7794
+ ...signature,
7795
+ type: "FunctionExpression",
7796
+ ts: true
7797
+ };
7727
7798
  }
7728
7799
  if (hasAwait(block) && !signature.async.length) {
7729
7800
  signature.async.push("async ");
@@ -9713,7 +9784,7 @@ ${input.slice(result.pos)}
9713
9784
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9714
9785
  var ws = $1;
9715
9786
  var def = $2;
9716
- if (def.block.empty)
9787
+ if (!def.block || def.block.empty)
9717
9788
  return $skip;
9718
9789
  return {
9719
9790
  ...def,
@@ -10036,12 +10107,13 @@ ${input.slice(result.pos)}
10036
10107
  type: "MethodDefinition",
10037
10108
  children: $0,
10038
10109
  name: signature.name,
10110
+ abstract: true,
10039
10111
  signature,
10040
10112
  parameters: signature.parameters,
10041
10113
  ts: true
10042
10114
  };
10043
10115
  });
10044
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10116
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10045
10117
  var signature = $1;
10046
10118
  var block = $3;
10047
10119
  let children = $0;
@@ -10171,7 +10243,7 @@ ${input.slice(result.pos)}
10171
10243
  var modifier = $1;
10172
10244
  var name = $2;
10173
10245
  var parameters = $4;
10174
- var suffix = $5;
10246
+ var returnType = $5;
10175
10247
  if (name.name) {
10176
10248
  name = name.name;
10177
10249
  } else if (name.token) {
@@ -10182,7 +10254,7 @@ ${input.slice(result.pos)}
10182
10254
  children: $0,
10183
10255
  name,
10184
10256
  modifier,
10185
- returnType: suffix,
10257
+ returnType,
10186
10258
  parameters
10187
10259
  };
10188
10260
  });
@@ -12684,14 +12756,7 @@ ${input.slice(result.pos)}
12684
12756
  var c = $4;
12685
12757
  var f = $5;
12686
12758
  if (!c && !f) {
12687
- const e = [];
12688
- const emptyCatchBlock = {
12689
- type: "BlockStatement",
12690
- expressions: e,
12691
- children: ["{", e, "}"],
12692
- bare: false,
12693
- empty: true
12694
- };
12759
+ const emptyCatchBlock = makeEmptyBlock();
12695
12760
  c = {
12696
12761
  type: "CatchClause",
12697
12762
  children: [" catch(e) ", emptyCatchBlock],
@@ -12997,7 +13062,7 @@ ${input.slice(result.pos)}
12997
13062
  }
12998
13063
  }
12999
13064
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13000
- module.forbidIndentedApplication.push(true);
13065
+ module.forbidClassImplicitCall.push(true);
13001
13066
  });
13002
13067
  function ForbidClassImplicitCall(state) {
13003
13068
  let eventData;
@@ -13022,7 +13087,7 @@ ${input.slice(result.pos)}
13022
13087
  }
13023
13088
  }
13024
13089
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13025
- module.forbidIndentedApplication.push(false);
13090
+ module.forbidClassImplicitCall.push(false);
13026
13091
  });
13027
13092
  function AllowClassImplicitCall(state) {
13028
13093
  let eventData;
@@ -13047,7 +13112,7 @@ ${input.slice(result.pos)}
13047
13112
  }
13048
13113
  }
13049
13114
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13050
- module.forbidIndentedApplication.pop();
13115
+ module.forbidClassImplicitCall.pop();
13051
13116
  });
13052
13117
  function RestoreClassImplicitCall(state) {
13053
13118
  let eventData;
@@ -13072,7 +13137,7 @@ ${input.slice(result.pos)}
13072
13137
  }
13073
13138
  }
13074
13139
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13075
- if (module.classImplicitCallForbidden)
13140
+ if (!module.classImplicitCallForbidden)
13076
13141
  return $skip;
13077
13142
  return;
13078
13143
  });
@@ -20281,7 +20346,7 @@ ${input.slice(result.pos)}
20281
20346
  return result;
20282
20347
  }
20283
20348
  }
20284
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20349
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20285
20350
  function BasicInterfaceProperty(state) {
20286
20351
  let eventData;
20287
20352
  if (state.events) {
@@ -20722,7 +20787,30 @@ ${input.slice(result.pos)}
20722
20787
  return result;
20723
20788
  }
20724
20789
  }
20725
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L141, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
20790
+ var TypeProperty$0 = $S($E($S(Readonly, NotDedented)), PropertyName);
20791
+ function TypeProperty(state) {
20792
+ let eventData;
20793
+ if (state.events) {
20794
+ const result = state.events.enter?.("TypeProperty", state);
20795
+ if (result) {
20796
+ if (result.cache)
20797
+ return result.cache;
20798
+ eventData = result.data;
20799
+ }
20800
+ }
20801
+ if (state.tokenize) {
20802
+ const result = $TOKEN("TypeProperty", state, TypeProperty$0(state));
20803
+ if (state.events)
20804
+ state.events.exit?.("TypeProperty", state, result, eventData);
20805
+ return result;
20806
+ } else {
20807
+ const result = TypeProperty$0(state);
20808
+ if (state.events)
20809
+ state.events.exit?.("TypeProperty", state, result, eventData);
20810
+ return result;
20811
+ }
20812
+ }
20813
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
20726
20814
  function TypeIndexSignature(state) {
20727
20815
  let eventData;
20728
20816
  if (state.events) {
@@ -21406,7 +21494,7 @@ ${input.slice(result.pos)}
21406
21494
  return result;
21407
21495
  }
21408
21496
  }
21409
- var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21497
+ var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21410
21498
  function InlineBasicInterfaceProperty(state) {
21411
21499
  let eventData;
21412
21500
  if (state.events) {
@@ -23405,6 +23493,7 @@ ${input.slice(result.pos)}
23405
23493
  isWhitespaceOrEmpty,
23406
23494
  lastAccessInCallExpression,
23407
23495
  literalValue,
23496
+ makeEmptyBlock,
23408
23497
  makeLeftHandSideExpression,
23409
23498
  maybeRef,
23410
23499
  modifyString,
package/dist/main.js CHANGED
@@ -797,13 +797,14 @@ var require_lib = __commonJS({
797
797
  }
798
798
  function hoistRefDecs(statements) {
799
799
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
800
- const { hoistDec } = node;
800
+ let { hoistDec, parent } = node;
801
801
  node.hoistDec = null;
802
- while (node.parent?.type !== "BlockStatement") {
803
- node = node.parent;
802
+ while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
803
+ node = parent;
804
+ parent = node.parent;
804
805
  }
805
- if (node.parent) {
806
- insertHoistDec(node.parent, node, hoistDec);
806
+ if (parent) {
807
+ insertHoistDec(parent, node, hoistDec);
807
808
  } else {
808
809
  throw new Error("Couldn't find block to hoist declaration into.");
809
810
  }
@@ -1105,6 +1106,16 @@ var require_lib = __commonJS({
1105
1106
  }
1106
1107
  return node;
1107
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
+ }
1108
1119
  function makeLeftHandSideExpression(expression) {
1109
1120
  switch (expression.type) {
1110
1121
  case "Ref":
@@ -1320,8 +1331,27 @@ var require_lib = __commonJS({
1320
1331
  thisAssignments
1321
1332
  };
1322
1333
  }
1334
+ function implicitFunctionBlock(f) {
1335
+ if (f.abstract || f.block)
1336
+ return;
1337
+ const { name, parent } = f;
1338
+ const expressions = parent?.expressions ?? parent?.elements;
1339
+ const currentIndex = expressions?.findIndex(([, def]) => def === f);
1340
+ const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
1341
+ if (f.type === following?.type && name && name === following.name) {
1342
+ f.ts = true;
1343
+ } else {
1344
+ const block = makeEmptyBlock();
1345
+ block.parent = f;
1346
+ f.block = block;
1347
+ f.children.push(block);
1348
+ f.ts = false;
1349
+ }
1350
+ }
1323
1351
  function processFunctions(statements, config) {
1324
1352
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1353
+ if (f.type === "FunctionExpression")
1354
+ implicitFunctionBlock(f);
1325
1355
  processParams(f);
1326
1356
  if (!processReturnValue(f) && config.implicitReturns) {
1327
1357
  const { block, returnType } = f;
@@ -1333,6 +1363,7 @@ var require_lib = __commonJS({
1333
1363
  }
1334
1364
  });
1335
1365
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1366
+ implicitFunctionBlock(f);
1336
1367
  processParams(f);
1337
1368
  if (!processReturnValue(f) && config.implicitReturns) {
1338
1369
  const { signature, block } = f;
@@ -2461,6 +2492,7 @@ var require_lib = __commonJS({
2461
2492
  lastAccessInCallExpression,
2462
2493
  literalValue,
2463
2494
  makeAsConst,
2495
+ makeEmptyBlock,
2464
2496
  makeLeftHandSideExpression,
2465
2497
  maybeRef,
2466
2498
  modifyString,
@@ -3434,6 +3466,7 @@ ${input.slice(result.pos)}
3434
3466
  NestedEnumProperties,
3435
3467
  NestedEnumProperty,
3436
3468
  EnumProperty,
3469
+ TypeProperty,
3437
3470
  TypeIndexSignature,
3438
3471
  TypeIndex,
3439
3472
  TypeSuffix,
@@ -4233,10 +4266,9 @@ ${input.slice(result.pos)}
4233
4266
  }
4234
4267
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4235
4268
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4236
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4237
- var ForbiddenImplicitCalls$3 = AtAt;
4238
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4239
- var ForbiddenImplicitCalls$5 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4269
+ var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, $C(Class, AtAt));
4270
+ var ForbiddenImplicitCalls$3 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4271
+ var ForbiddenImplicitCalls$4 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4240
4272
  if (module2.operators.has($1.name))
4241
4273
  return $1;
4242
4274
  return $skip;
@@ -4252,12 +4284,12 @@ ${input.slice(result.pos)}
4252
4284
  }
4253
4285
  }
4254
4286
  if (state.tokenize) {
4255
- const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state));
4287
+ const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state));
4256
4288
  if (state.events)
4257
4289
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4258
4290
  return result;
4259
4291
  } else {
4260
- const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state);
4292
+ const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state);
4261
4293
  if (state.events)
4262
4294
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4263
4295
  return result;
@@ -5691,8 +5723,22 @@ ${input.slice(result.pos)}
5691
5723
  return result;
5692
5724
  }
5693
5725
  }
5694
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5695
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5726
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5727
+ var elements = $3;
5728
+ return {
5729
+ type: "ClassBody",
5730
+ children: $0,
5731
+ elements
5732
+ };
5733
+ });
5734
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5735
+ var elements = $2;
5736
+ return {
5737
+ type: "ClassBody",
5738
+ children: $0,
5739
+ elements
5740
+ };
5741
+ });
5696
5742
  function ClassBody(state) {
5697
5743
  let eventData;
5698
5744
  if (state.events) {
@@ -5766,8 +5812,19 @@ ${input.slice(result.pos)}
5766
5812
  return result;
5767
5813
  }
5768
5814
  }
5769
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5770
- var ClassElement$1 = $S(Static, BracedBlock);
5815
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5816
+ var definition = $4;
5817
+ return {
5818
+ ...definition,
5819
+ children: [$1, $2, $3, ...definition.children]
5820
+ };
5821
+ });
5822
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5823
+ return {
5824
+ type: "ClassStaticBlock",
5825
+ children: $0
5826
+ };
5827
+ });
5771
5828
  function ClassElement(state) {
5772
5829
  let eventData;
5773
5830
  if (state.events) {
@@ -5936,7 +5993,7 @@ ${input.slice(result.pos)}
5936
5993
  return result;
5937
5994
  }
5938
5995
  }
5939
- var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), __)), $E($S(Readonly, __))), function($skip, $loc, $0, $1, $2) {
5996
+ var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), NotDedented)), $E($S(Readonly, NotDedented))), function($skip, $loc, $0, $1, $2) {
5940
5997
  if (!($1 || $2))
5941
5998
  return $skip;
5942
5999
  return {
@@ -5983,7 +6040,10 @@ ${input.slice(result.pos)}
5983
6040
  children
5984
6041
  };
5985
6042
  default:
5986
- return [id, " = ", exp];
6043
+ return {
6044
+ type: "FieldDefinition",
6045
+ children: [id, " = ", exp]
6046
+ };
5987
6047
  }
5988
6048
  });
5989
6049
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5993,12 +6053,18 @@ ${input.slice(result.pos)}
5993
6053
  pos: ca.$loc.pos - 1,
5994
6054
  length: ca.$loc.length + 1
5995
6055
  };
5996
- return $0;
6056
+ return {
6057
+ type: "FieldDefinition",
6058
+ children: $0
6059
+ };
5997
6060
  });
5998
6061
  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
6062
  if ($1)
6000
6063
  return { children: $0, ts: true };
6001
- return $0;
6064
+ return {
6065
+ type: "FieldDefinition",
6066
+ children: $0
6067
+ };
6002
6068
  });
6003
6069
  function FieldDefinition(state) {
6004
6070
  let eventData;
@@ -7683,9 +7749,11 @@ ${input.slice(result.pos)}
7683
7749
  async = [];
7684
7750
  if (!generator)
7685
7751
  generator = [];
7752
+ const id = wid?.[1];
7686
7753
  return {
7687
7754
  type: "FunctionSignature",
7688
- id: wid?.[1],
7755
+ id,
7756
+ name: id?.name,
7689
7757
  parameters,
7690
7758
  returnType: suffix,
7691
7759
  ts: false,
@@ -7721,8 +7789,11 @@ ${input.slice(result.pos)}
7721
7789
  var signature = $1;
7722
7790
  var block = $2;
7723
7791
  if (!block) {
7724
- signature.ts = true;
7725
- return signature;
7792
+ return {
7793
+ ...signature,
7794
+ type: "FunctionExpression",
7795
+ ts: true
7796
+ };
7726
7797
  }
7727
7798
  if (hasAwait(block) && !signature.async.length) {
7728
7799
  signature.async.push("async ");
@@ -9712,7 +9783,7 @@ ${input.slice(result.pos)}
9712
9783
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9713
9784
  var ws = $1;
9714
9785
  var def = $2;
9715
- if (def.block.empty)
9786
+ if (!def.block || def.block.empty)
9716
9787
  return $skip;
9717
9788
  return {
9718
9789
  ...def,
@@ -10035,12 +10106,13 @@ ${input.slice(result.pos)}
10035
10106
  type: "MethodDefinition",
10036
10107
  children: $0,
10037
10108
  name: signature.name,
10109
+ abstract: true,
10038
10110
  signature,
10039
10111
  parameters: signature.parameters,
10040
10112
  ts: true
10041
10113
  };
10042
10114
  });
10043
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10115
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10044
10116
  var signature = $1;
10045
10117
  var block = $3;
10046
10118
  let children = $0;
@@ -10170,7 +10242,7 @@ ${input.slice(result.pos)}
10170
10242
  var modifier = $1;
10171
10243
  var name = $2;
10172
10244
  var parameters = $4;
10173
- var suffix = $5;
10245
+ var returnType = $5;
10174
10246
  if (name.name) {
10175
10247
  name = name.name;
10176
10248
  } else if (name.token) {
@@ -10181,7 +10253,7 @@ ${input.slice(result.pos)}
10181
10253
  children: $0,
10182
10254
  name,
10183
10255
  modifier,
10184
- returnType: suffix,
10256
+ returnType,
10185
10257
  parameters
10186
10258
  };
10187
10259
  });
@@ -12683,14 +12755,7 @@ ${input.slice(result.pos)}
12683
12755
  var c = $4;
12684
12756
  var f = $5;
12685
12757
  if (!c && !f) {
12686
- const e = [];
12687
- const emptyCatchBlock = {
12688
- type: "BlockStatement",
12689
- expressions: e,
12690
- children: ["{", e, "}"],
12691
- bare: false,
12692
- empty: true
12693
- };
12758
+ const emptyCatchBlock = makeEmptyBlock();
12694
12759
  c = {
12695
12760
  type: "CatchClause",
12696
12761
  children: [" catch(e) ", emptyCatchBlock],
@@ -12996,7 +13061,7 @@ ${input.slice(result.pos)}
12996
13061
  }
12997
13062
  }
12998
13063
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
12999
- module2.forbidIndentedApplication.push(true);
13064
+ module2.forbidClassImplicitCall.push(true);
13000
13065
  });
13001
13066
  function ForbidClassImplicitCall(state) {
13002
13067
  let eventData;
@@ -13021,7 +13086,7 @@ ${input.slice(result.pos)}
13021
13086
  }
13022
13087
  }
13023
13088
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13024
- module2.forbidIndentedApplication.push(false);
13089
+ module2.forbidClassImplicitCall.push(false);
13025
13090
  });
13026
13091
  function AllowClassImplicitCall(state) {
13027
13092
  let eventData;
@@ -13046,7 +13111,7 @@ ${input.slice(result.pos)}
13046
13111
  }
13047
13112
  }
13048
13113
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13049
- module2.forbidIndentedApplication.pop();
13114
+ module2.forbidClassImplicitCall.pop();
13050
13115
  });
13051
13116
  function RestoreClassImplicitCall(state) {
13052
13117
  let eventData;
@@ -13071,7 +13136,7 @@ ${input.slice(result.pos)}
13071
13136
  }
13072
13137
  }
13073
13138
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13074
- if (module2.classImplicitCallForbidden)
13139
+ if (!module2.classImplicitCallForbidden)
13075
13140
  return $skip;
13076
13141
  return;
13077
13142
  });
@@ -20280,7 +20345,7 @@ ${input.slice(result.pos)}
20280
20345
  return result;
20281
20346
  }
20282
20347
  }
20283
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20348
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20284
20349
  function BasicInterfaceProperty(state) {
20285
20350
  let eventData;
20286
20351
  if (state.events) {
@@ -20721,7 +20786,30 @@ ${input.slice(result.pos)}
20721
20786
  return result;
20722
20787
  }
20723
20788
  }
20724
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L141, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
20789
+ var TypeProperty$0 = $S($E($S(Readonly, NotDedented)), PropertyName);
20790
+ function TypeProperty(state) {
20791
+ let eventData;
20792
+ if (state.events) {
20793
+ const result = state.events.enter?.("TypeProperty", state);
20794
+ if (result) {
20795
+ if (result.cache)
20796
+ return result.cache;
20797
+ eventData = result.data;
20798
+ }
20799
+ }
20800
+ if (state.tokenize) {
20801
+ const result = $TOKEN("TypeProperty", state, TypeProperty$0(state));
20802
+ if (state.events)
20803
+ state.events.exit?.("TypeProperty", state, result, eventData);
20804
+ return result;
20805
+ } else {
20806
+ const result = TypeProperty$0(state);
20807
+ if (state.events)
20808
+ state.events.exit?.("TypeProperty", state, result, eventData);
20809
+ return result;
20810
+ }
20811
+ }
20812
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
20725
20813
  function TypeIndexSignature(state) {
20726
20814
  let eventData;
20727
20815
  if (state.events) {
@@ -21405,7 +21493,7 @@ ${input.slice(result.pos)}
21405
21493
  return result;
21406
21494
  }
21407
21495
  }
21408
- var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21496
+ var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21409
21497
  function InlineBasicInterfaceProperty(state) {
21410
21498
  let eventData;
21411
21499
  if (state.events) {
@@ -23404,6 +23492,7 @@ ${input.slice(result.pos)}
23404
23492
  isWhitespaceOrEmpty,
23405
23493
  lastAccessInCallExpression,
23406
23494
  literalValue,
23495
+ makeEmptyBlock,
23407
23496
  makeLeftHandSideExpression,
23408
23497
  maybeRef,
23409
23498
  modifyString,
package/dist/main.mjs CHANGED
@@ -795,13 +795,14 @@ var require_lib = __commonJS({
795
795
  }
796
796
  function hoistRefDecs(statements) {
797
797
  gatherRecursiveAll(statements, (s) => s.hoistDec).forEach((node) => {
798
- const { hoistDec } = node;
798
+ let { hoistDec, parent } = node;
799
799
  node.hoistDec = null;
800
- while (node.parent?.type !== "BlockStatement") {
801
- node = node.parent;
800
+ while (parent?.type !== "BlockStatement" || parent.bare && !parent.root) {
801
+ node = parent;
802
+ parent = node.parent;
802
803
  }
803
- if (node.parent) {
804
- insertHoistDec(node.parent, node, hoistDec);
804
+ if (parent) {
805
+ insertHoistDec(parent, node, hoistDec);
805
806
  } else {
806
807
  throw new Error("Couldn't find block to hoist declaration into.");
807
808
  }
@@ -1103,6 +1104,16 @@ var require_lib = __commonJS({
1103
1104
  }
1104
1105
  return node;
1105
1106
  }
1107
+ function makeEmptyBlock() {
1108
+ const expressions = [];
1109
+ return {
1110
+ type: "BlockStatement",
1111
+ expressions,
1112
+ children: ["{", expressions, "}"],
1113
+ bare: false,
1114
+ empty: true
1115
+ };
1116
+ }
1106
1117
  function makeLeftHandSideExpression(expression) {
1107
1118
  switch (expression.type) {
1108
1119
  case "Ref":
@@ -1318,8 +1329,27 @@ var require_lib = __commonJS({
1318
1329
  thisAssignments
1319
1330
  };
1320
1331
  }
1332
+ function implicitFunctionBlock(f) {
1333
+ if (f.abstract || f.block)
1334
+ return;
1335
+ const { name, parent } = f;
1336
+ const expressions = parent?.expressions ?? parent?.elements;
1337
+ const currentIndex = expressions?.findIndex(([, def]) => def === f);
1338
+ const following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
1339
+ if (f.type === following?.type && name && name === following.name) {
1340
+ f.ts = true;
1341
+ } else {
1342
+ const block = makeEmptyBlock();
1343
+ block.parent = f;
1344
+ f.block = block;
1345
+ f.children.push(block);
1346
+ f.ts = false;
1347
+ }
1348
+ }
1321
1349
  function processFunctions(statements, config) {
1322
1350
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1351
+ if (f.type === "FunctionExpression")
1352
+ implicitFunctionBlock(f);
1323
1353
  processParams(f);
1324
1354
  if (!processReturnValue(f) && config.implicitReturns) {
1325
1355
  const { block, returnType } = f;
@@ -1331,6 +1361,7 @@ var require_lib = __commonJS({
1331
1361
  }
1332
1362
  });
1333
1363
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
1364
+ implicitFunctionBlock(f);
1334
1365
  processParams(f);
1335
1366
  if (!processReturnValue(f) && config.implicitReturns) {
1336
1367
  const { signature, block } = f;
@@ -2459,6 +2490,7 @@ var require_lib = __commonJS({
2459
2490
  lastAccessInCallExpression,
2460
2491
  literalValue,
2461
2492
  makeAsConst,
2493
+ makeEmptyBlock,
2462
2494
  makeLeftHandSideExpression,
2463
2495
  maybeRef,
2464
2496
  modifyString,
@@ -3432,6 +3464,7 @@ ${input.slice(result.pos)}
3432
3464
  NestedEnumProperties,
3433
3465
  NestedEnumProperty,
3434
3466
  EnumProperty,
3467
+ TypeProperty,
3435
3468
  TypeIndexSignature,
3436
3469
  TypeIndex,
3437
3470
  TypeSuffix,
@@ -4231,10 +4264,9 @@ ${input.slice(result.pos)}
4231
4264
  }
4232
4265
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4233
4266
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4234
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4235
- var ForbiddenImplicitCalls$3 = AtAt;
4236
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4237
- var ForbiddenImplicitCalls$5 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4267
+ var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, $C(Class, AtAt));
4268
+ var ForbiddenImplicitCalls$3 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4269
+ var ForbiddenImplicitCalls$4 = $TS($S(Identifier, $N($EXPECT($L3, fail, 'ForbiddenImplicitCalls "("'))), function($skip, $loc, $0, $1, $2) {
4238
4270
  if (module.operators.has($1.name))
4239
4271
  return $1;
4240
4272
  return $skip;
@@ -4250,12 +4282,12 @@ ${input.slice(result.pos)}
4250
4282
  }
4251
4283
  }
4252
4284
  if (state.tokenize) {
4253
- const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state));
4285
+ const result = $TOKEN("ForbiddenImplicitCalls", state, ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state));
4254
4286
  if (state.events)
4255
4287
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4256
4288
  return result;
4257
4289
  } else {
4258
- const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state) || ForbiddenImplicitCalls$5(state);
4290
+ const result = ForbiddenImplicitCalls$0(state) || ForbiddenImplicitCalls$1(state) || ForbiddenImplicitCalls$2(state) || ForbiddenImplicitCalls$3(state) || ForbiddenImplicitCalls$4(state);
4259
4291
  if (state.events)
4260
4292
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4261
4293
  return result;
@@ -5689,8 +5721,22 @@ ${input.slice(result.pos)}
5689
5721
  return result;
5690
5722
  }
5691
5723
  }
5692
- var ClassBody$0 = $S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace);
5693
- var ClassBody$1 = $S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace);
5724
+ var ClassBody$0 = $TS($S(__, OpenBrace, $E(NestedClassElements), __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5725
+ var elements = $3;
5726
+ return {
5727
+ type: "ClassBody",
5728
+ children: $0,
5729
+ elements
5730
+ };
5731
+ });
5732
+ var ClassBody$1 = $TS($S(InsertOpenBrace, $E(NestedClassElements), InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5733
+ var elements = $2;
5734
+ return {
5735
+ type: "ClassBody",
5736
+ children: $0,
5737
+ elements
5738
+ };
5739
+ });
5694
5740
  function ClassBody(state) {
5695
5741
  let eventData;
5696
5742
  if (state.events) {
@@ -5764,8 +5810,19 @@ ${input.slice(result.pos)}
5764
5810
  return result;
5765
5811
  }
5766
5812
  }
5767
- var ClassElement$0 = $S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition);
5768
- var ClassElement$1 = $S(Static, BracedBlock);
5813
+ var ClassElement$0 = $TS($S($E(Decorators), $E(AccessModifier), $E($S(Static, $E(_))), ClassElementDefinition), function($skip, $loc, $0, $1, $2, $3, $4) {
5814
+ var definition = $4;
5815
+ return {
5816
+ ...definition,
5817
+ children: [$1, $2, $3, ...definition.children]
5818
+ };
5819
+ });
5820
+ var ClassElement$1 = $TS($S(Static, BracedBlock), function($skip, $loc, $0, $1, $2) {
5821
+ return {
5822
+ type: "ClassStaticBlock",
5823
+ children: $0
5824
+ };
5825
+ });
5769
5826
  function ClassElement(state) {
5770
5827
  let eventData;
5771
5828
  if (state.events) {
@@ -5934,7 +5991,7 @@ ${input.slice(result.pos)}
5934
5991
  return result;
5935
5992
  }
5936
5993
  }
5937
- var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), __)), $E($S(Readonly, __))), function($skip, $loc, $0, $1, $2) {
5994
+ var AccessModifier$0 = $TS($S($E($S($C(Public, Private, Protected), NotDedented)), $E($S(Readonly, NotDedented))), function($skip, $loc, $0, $1, $2) {
5938
5995
  if (!($1 || $2))
5939
5996
  return $skip;
5940
5997
  return {
@@ -5981,7 +6038,10 @@ ${input.slice(result.pos)}
5981
6038
  children
5982
6039
  };
5983
6040
  default:
5984
- return [id, " = ", exp];
6041
+ return {
6042
+ type: "FieldDefinition",
6043
+ children: [id, " = ", exp]
6044
+ };
5985
6045
  }
5986
6046
  });
5987
6047
  var FieldDefinition$1 = $TS($S(InsertReadonly, ClassElementName, $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -5991,12 +6051,18 @@ ${input.slice(result.pos)}
5991
6051
  pos: ca.$loc.pos - 1,
5992
6052
  length: ca.$loc.length + 1
5993
6053
  };
5994
- return $0;
6054
+ return {
6055
+ type: "FieldDefinition",
6056
+ children: $0
6057
+ };
5995
6058
  });
5996
6059
  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) {
5997
6060
  if ($1)
5998
6061
  return { children: $0, ts: true };
5999
- return $0;
6062
+ return {
6063
+ type: "FieldDefinition",
6064
+ children: $0
6065
+ };
6000
6066
  });
6001
6067
  function FieldDefinition(state) {
6002
6068
  let eventData;
@@ -7681,9 +7747,11 @@ ${input.slice(result.pos)}
7681
7747
  async = [];
7682
7748
  if (!generator)
7683
7749
  generator = [];
7750
+ const id = wid?.[1];
7684
7751
  return {
7685
7752
  type: "FunctionSignature",
7686
- id: wid?.[1],
7753
+ id,
7754
+ name: id?.name,
7687
7755
  parameters,
7688
7756
  returnType: suffix,
7689
7757
  ts: false,
@@ -7719,8 +7787,11 @@ ${input.slice(result.pos)}
7719
7787
  var signature = $1;
7720
7788
  var block = $2;
7721
7789
  if (!block) {
7722
- signature.ts = true;
7723
- return signature;
7790
+ return {
7791
+ ...signature,
7792
+ type: "FunctionExpression",
7793
+ ts: true
7794
+ };
7724
7795
  }
7725
7796
  if (hasAwait(block) && !signature.async.length) {
7726
7797
  signature.async.push("async ");
@@ -9710,7 +9781,7 @@ ${input.slice(result.pos)}
9710
9781
  var PropertyDefinition$3 = $TS($S(__, MethodDefinition), function($skip, $loc, $0, $1, $2) {
9711
9782
  var ws = $1;
9712
9783
  var def = $2;
9713
- if (def.block.empty)
9784
+ if (!def.block || def.block.empty)
9714
9785
  return $skip;
9715
9786
  return {
9716
9787
  ...def,
@@ -10033,12 +10104,13 @@ ${input.slice(result.pos)}
10033
10104
  type: "MethodDefinition",
10034
10105
  children: $0,
10035
10106
  name: signature.name,
10107
+ abstract: true,
10036
10108
  signature,
10037
10109
  parameters: signature.parameters,
10038
10110
  ts: true
10039
10111
  };
10040
10112
  });
10041
- var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3) {
10113
+ var MethodDefinition$1 = $TS($S(MethodSignature, $N(PropertyAccess), $E(BracedBlock)), function($skip, $loc, $0, $1, $2, $3) {
10042
10114
  var signature = $1;
10043
10115
  var block = $3;
10044
10116
  let children = $0;
@@ -10168,7 +10240,7 @@ ${input.slice(result.pos)}
10168
10240
  var modifier = $1;
10169
10241
  var name = $2;
10170
10242
  var parameters = $4;
10171
- var suffix = $5;
10243
+ var returnType = $5;
10172
10244
  if (name.name) {
10173
10245
  name = name.name;
10174
10246
  } else if (name.token) {
@@ -10179,7 +10251,7 @@ ${input.slice(result.pos)}
10179
10251
  children: $0,
10180
10252
  name,
10181
10253
  modifier,
10182
- returnType: suffix,
10254
+ returnType,
10183
10255
  parameters
10184
10256
  };
10185
10257
  });
@@ -12681,14 +12753,7 @@ ${input.slice(result.pos)}
12681
12753
  var c = $4;
12682
12754
  var f = $5;
12683
12755
  if (!c && !f) {
12684
- const e = [];
12685
- const emptyCatchBlock = {
12686
- type: "BlockStatement",
12687
- expressions: e,
12688
- children: ["{", e, "}"],
12689
- bare: false,
12690
- empty: true
12691
- };
12756
+ const emptyCatchBlock = makeEmptyBlock();
12692
12757
  c = {
12693
12758
  type: "CatchClause",
12694
12759
  children: [" catch(e) ", emptyCatchBlock],
@@ -12994,7 +13059,7 @@ ${input.slice(result.pos)}
12994
13059
  }
12995
13060
  }
12996
13061
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
12997
- module.forbidIndentedApplication.push(true);
13062
+ module.forbidClassImplicitCall.push(true);
12998
13063
  });
12999
13064
  function ForbidClassImplicitCall(state) {
13000
13065
  let eventData;
@@ -13019,7 +13084,7 @@ ${input.slice(result.pos)}
13019
13084
  }
13020
13085
  }
13021
13086
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13022
- module.forbidIndentedApplication.push(false);
13087
+ module.forbidClassImplicitCall.push(false);
13023
13088
  });
13024
13089
  function AllowClassImplicitCall(state) {
13025
13090
  let eventData;
@@ -13044,7 +13109,7 @@ ${input.slice(result.pos)}
13044
13109
  }
13045
13110
  }
13046
13111
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13047
- module.forbidIndentedApplication.pop();
13112
+ module.forbidClassImplicitCall.pop();
13048
13113
  });
13049
13114
  function RestoreClassImplicitCall(state) {
13050
13115
  let eventData;
@@ -13069,7 +13134,7 @@ ${input.slice(result.pos)}
13069
13134
  }
13070
13135
  }
13071
13136
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13072
- if (module.classImplicitCallForbidden)
13137
+ if (!module.classImplicitCallForbidden)
13073
13138
  return $skip;
13074
13139
  return;
13075
13140
  });
@@ -20278,7 +20343,7 @@ ${input.slice(result.pos)}
20278
20343
  return result;
20279
20344
  }
20280
20345
  }
20281
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20346
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20282
20347
  function BasicInterfaceProperty(state) {
20283
20348
  let eventData;
20284
20349
  if (state.events) {
@@ -20719,7 +20784,30 @@ ${input.slice(result.pos)}
20719
20784
  return result;
20720
20785
  }
20721
20786
  }
20722
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), $EXPECT($L141, fail, 'TypeIndexSignature "readonly"'), __)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), QuestionMark)));
20787
+ var TypeProperty$0 = $S($E($S(Readonly, NotDedented)), PropertyName);
20788
+ function TypeProperty(state) {
20789
+ let eventData;
20790
+ if (state.events) {
20791
+ const result = state.events.enter?.("TypeProperty", state);
20792
+ if (result) {
20793
+ if (result.cache)
20794
+ return result.cache;
20795
+ eventData = result.data;
20796
+ }
20797
+ }
20798
+ if (state.tokenize) {
20799
+ const result = $TOKEN("TypeProperty", state, TypeProperty$0(state));
20800
+ if (state.events)
20801
+ state.events.exit?.("TypeProperty", state, result, eventData);
20802
+ return result;
20803
+ } else {
20804
+ const result = TypeProperty$0(state);
20805
+ if (state.events)
20806
+ state.events.exit?.("TypeProperty", state, result, eventData);
20807
+ return result;
20808
+ }
20809
+ }
20810
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R58, fail, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R59, fail, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
20723
20811
  function TypeIndexSignature(state) {
20724
20812
  let eventData;
20725
20813
  if (state.events) {
@@ -21403,7 +21491,7 @@ ${input.slice(result.pos)}
21403
21491
  return result;
21404
21492
  }
21405
21493
  }
21406
- var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21494
+ var InlineBasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(QuestionMark), Colon, Type, InlineInterfacePropertyDelimiter);
21407
21495
  function InlineBasicInterfaceProperty(state) {
21408
21496
  let eventData;
21409
21497
  if (state.events) {
@@ -23402,6 +23490,7 @@ ${input.slice(result.pos)}
23402
23490
  isWhitespaceOrEmpty,
23403
23491
  lastAccessInCallExpression,
23404
23492
  literalValue,
23493
+ makeEmptyBlock,
23405
23494
  makeLeftHandSideExpression,
23406
23495
  maybeRef,
23407
23496
  modifyString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",