@danielx/civet 0.6.7 → 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
  }
@@ -1331,8 +1332,27 @@ var Civet = (() => {
1331
1332
  thisAssignments
1332
1333
  };
1333
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
+ }
1334
1352
  function processFunctions(statements, config) {
1335
1353
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1354
+ if (f.type === "FunctionExpression")
1355
+ implicitFunctionBlock(f);
1336
1356
  processParams(f);
1337
1357
  if (!processReturnValue(f) && config.implicitReturns) {
1338
1358
  const { block, returnType } = f;
@@ -1344,25 +1364,15 @@ var Civet = (() => {
1344
1364
  }
1345
1365
  });
1346
1366
  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
- }
1367
+ implicitFunctionBlock(f);
1358
1368
  processParams(f);
1359
1369
  if (!processReturnValue(f) && config.implicitReturns) {
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;
1370
+ const { signature, block } = f;
1371
+ const isConstructor = signature.name === "constructor";
1372
+ const isVoid = isVoidType(signature.returnType?.t);
1373
+ const isSet = signature.modifier?.set;
1364
1374
  if (!isConstructor && !isSet && !isVoid) {
1365
- insertReturn(block2);
1375
+ insertReturn(block);
1366
1376
  }
1367
1377
  }
1368
1378
  });
@@ -3457,6 +3467,7 @@ ${input.slice(result.pos)}
3457
3467
  NestedEnumProperties,
3458
3468
  NestedEnumProperty,
3459
3469
  EnumProperty,
3470
+ TypeProperty,
3460
3471
  TypeIndexSignature,
3461
3472
  TypeIndex,
3462
3473
  TypeSuffix,
@@ -4256,10 +4267,9 @@ ${input.slice(result.pos)}
4256
4267
  }
4257
4268
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4258
4269
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4259
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4260
- var ForbiddenImplicitCalls$3 = AtAt;
4261
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4262
- 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) {
4263
4273
  if (module.operators.has($1.name))
4264
4274
  return $1;
4265
4275
  return $skip;
@@ -4275,12 +4285,12 @@ ${input.slice(result.pos)}
4275
4285
  }
4276
4286
  }
4277
4287
  if (state.tokenize) {
4278
- 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));
4279
4289
  if (state.events)
4280
4290
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4281
4291
  return result;
4282
4292
  } else {
4283
- 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);
4284
4294
  if (state.events)
4285
4295
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4286
4296
  return result;
@@ -5984,7 +5994,7 @@ ${input.slice(result.pos)}
5984
5994
  return result;
5985
5995
  }
5986
5996
  }
5987
- 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) {
5988
5998
  if (!($1 || $2))
5989
5999
  return $skip;
5990
6000
  return {
@@ -7740,9 +7750,11 @@ ${input.slice(result.pos)}
7740
7750
  async = [];
7741
7751
  if (!generator)
7742
7752
  generator = [];
7753
+ const id = wid?.[1];
7743
7754
  return {
7744
7755
  type: "FunctionSignature",
7745
- id: wid?.[1],
7756
+ id,
7757
+ name: id?.name,
7746
7758
  parameters,
7747
7759
  returnType: suffix,
7748
7760
  ts: false,
@@ -7778,8 +7790,11 @@ ${input.slice(result.pos)}
7778
7790
  var signature = $1;
7779
7791
  var block = $2;
7780
7792
  if (!block) {
7781
- signature.ts = true;
7782
- return signature;
7793
+ return {
7794
+ ...signature,
7795
+ type: "FunctionExpression",
7796
+ ts: true
7797
+ };
7783
7798
  }
7784
7799
  if (hasAwait(block) && !signature.async.length) {
7785
7800
  signature.async.push("async ");
@@ -13047,7 +13062,7 @@ ${input.slice(result.pos)}
13047
13062
  }
13048
13063
  }
13049
13064
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13050
- module.forbidIndentedApplication.push(true);
13065
+ module.forbidClassImplicitCall.push(true);
13051
13066
  });
13052
13067
  function ForbidClassImplicitCall(state) {
13053
13068
  let eventData;
@@ -13072,7 +13087,7 @@ ${input.slice(result.pos)}
13072
13087
  }
13073
13088
  }
13074
13089
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13075
- module.forbidIndentedApplication.push(false);
13090
+ module.forbidClassImplicitCall.push(false);
13076
13091
  });
13077
13092
  function AllowClassImplicitCall(state) {
13078
13093
  let eventData;
@@ -13097,7 +13112,7 @@ ${input.slice(result.pos)}
13097
13112
  }
13098
13113
  }
13099
13114
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13100
- module.forbidIndentedApplication.pop();
13115
+ module.forbidClassImplicitCall.pop();
13101
13116
  });
13102
13117
  function RestoreClassImplicitCall(state) {
13103
13118
  let eventData;
@@ -13122,7 +13137,7 @@ ${input.slice(result.pos)}
13122
13137
  }
13123
13138
  }
13124
13139
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13125
- if (module.classImplicitCallForbidden)
13140
+ if (!module.classImplicitCallForbidden)
13126
13141
  return $skip;
13127
13142
  return;
13128
13143
  });
@@ -20331,7 +20346,7 @@ ${input.slice(result.pos)}
20331
20346
  return result;
20332
20347
  }
20333
20348
  }
20334
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20349
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20335
20350
  function BasicInterfaceProperty(state) {
20336
20351
  let eventData;
20337
20352
  if (state.events) {
@@ -20772,7 +20787,30 @@ ${input.slice(result.pos)}
20772
20787
  return result;
20773
20788
  }
20774
20789
  }
20775
- 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)))));
20776
20814
  function TypeIndexSignature(state) {
20777
20815
  let eventData;
20778
20816
  if (state.events) {
@@ -21456,7 +21494,7 @@ ${input.slice(result.pos)}
21456
21494
  return result;
21457
21495
  }
21458
21496
  }
21459
- 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);
21460
21498
  function InlineBasicInterfaceProperty(state) {
21461
21499
  let eventData;
21462
21500
  if (state.events) {
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
  }
@@ -1330,8 +1331,27 @@ var require_lib = __commonJS({
1330
1331
  thisAssignments
1331
1332
  };
1332
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
+ }
1333
1351
  function processFunctions(statements, config) {
1334
1352
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1353
+ if (f.type === "FunctionExpression")
1354
+ implicitFunctionBlock(f);
1335
1355
  processParams(f);
1336
1356
  if (!processReturnValue(f) && config.implicitReturns) {
1337
1357
  const { block, returnType } = f;
@@ -1343,25 +1363,15 @@ var require_lib = __commonJS({
1343
1363
  }
1344
1364
  });
1345
1365
  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
- }
1366
+ implicitFunctionBlock(f);
1357
1367
  processParams(f);
1358
1368
  if (!processReturnValue(f) && config.implicitReturns) {
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;
1369
+ const { signature, block } = f;
1370
+ const isConstructor = signature.name === "constructor";
1371
+ const isVoid = isVoidType(signature.returnType?.t);
1372
+ const isSet = signature.modifier?.set;
1363
1373
  if (!isConstructor && !isSet && !isVoid) {
1364
- insertReturn(block2);
1374
+ insertReturn(block);
1365
1375
  }
1366
1376
  }
1367
1377
  });
@@ -3456,6 +3466,7 @@ ${input.slice(result.pos)}
3456
3466
  NestedEnumProperties,
3457
3467
  NestedEnumProperty,
3458
3468
  EnumProperty,
3469
+ TypeProperty,
3459
3470
  TypeIndexSignature,
3460
3471
  TypeIndex,
3461
3472
  TypeSuffix,
@@ -4255,10 +4266,9 @@ ${input.slice(result.pos)}
4255
4266
  }
4256
4267
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4257
4268
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4258
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4259
- var ForbiddenImplicitCalls$3 = AtAt;
4260
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4261
- 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) {
4262
4272
  if (module2.operators.has($1.name))
4263
4273
  return $1;
4264
4274
  return $skip;
@@ -4274,12 +4284,12 @@ ${input.slice(result.pos)}
4274
4284
  }
4275
4285
  }
4276
4286
  if (state.tokenize) {
4277
- 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));
4278
4288
  if (state.events)
4279
4289
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4280
4290
  return result;
4281
4291
  } else {
4282
- 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);
4283
4293
  if (state.events)
4284
4294
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4285
4295
  return result;
@@ -5983,7 +5993,7 @@ ${input.slice(result.pos)}
5983
5993
  return result;
5984
5994
  }
5985
5995
  }
5986
- 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) {
5987
5997
  if (!($1 || $2))
5988
5998
  return $skip;
5989
5999
  return {
@@ -7739,9 +7749,11 @@ ${input.slice(result.pos)}
7739
7749
  async = [];
7740
7750
  if (!generator)
7741
7751
  generator = [];
7752
+ const id = wid?.[1];
7742
7753
  return {
7743
7754
  type: "FunctionSignature",
7744
- id: wid?.[1],
7755
+ id,
7756
+ name: id?.name,
7745
7757
  parameters,
7746
7758
  returnType: suffix,
7747
7759
  ts: false,
@@ -7777,8 +7789,11 @@ ${input.slice(result.pos)}
7777
7789
  var signature = $1;
7778
7790
  var block = $2;
7779
7791
  if (!block) {
7780
- signature.ts = true;
7781
- return signature;
7792
+ return {
7793
+ ...signature,
7794
+ type: "FunctionExpression",
7795
+ ts: true
7796
+ };
7782
7797
  }
7783
7798
  if (hasAwait(block) && !signature.async.length) {
7784
7799
  signature.async.push("async ");
@@ -13046,7 +13061,7 @@ ${input.slice(result.pos)}
13046
13061
  }
13047
13062
  }
13048
13063
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13049
- module2.forbidIndentedApplication.push(true);
13064
+ module2.forbidClassImplicitCall.push(true);
13050
13065
  });
13051
13066
  function ForbidClassImplicitCall(state) {
13052
13067
  let eventData;
@@ -13071,7 +13086,7 @@ ${input.slice(result.pos)}
13071
13086
  }
13072
13087
  }
13073
13088
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13074
- module2.forbidIndentedApplication.push(false);
13089
+ module2.forbidClassImplicitCall.push(false);
13075
13090
  });
13076
13091
  function AllowClassImplicitCall(state) {
13077
13092
  let eventData;
@@ -13096,7 +13111,7 @@ ${input.slice(result.pos)}
13096
13111
  }
13097
13112
  }
13098
13113
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13099
- module2.forbidIndentedApplication.pop();
13114
+ module2.forbidClassImplicitCall.pop();
13100
13115
  });
13101
13116
  function RestoreClassImplicitCall(state) {
13102
13117
  let eventData;
@@ -13121,7 +13136,7 @@ ${input.slice(result.pos)}
13121
13136
  }
13122
13137
  }
13123
13138
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13124
- if (module2.classImplicitCallForbidden)
13139
+ if (!module2.classImplicitCallForbidden)
13125
13140
  return $skip;
13126
13141
  return;
13127
13142
  });
@@ -20330,7 +20345,7 @@ ${input.slice(result.pos)}
20330
20345
  return result;
20331
20346
  }
20332
20347
  }
20333
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20348
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20334
20349
  function BasicInterfaceProperty(state) {
20335
20350
  let eventData;
20336
20351
  if (state.events) {
@@ -20771,7 +20786,30 @@ ${input.slice(result.pos)}
20771
20786
  return result;
20772
20787
  }
20773
20788
  }
20774
- 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)))));
20775
20813
  function TypeIndexSignature(state) {
20776
20814
  let eventData;
20777
20815
  if (state.events) {
@@ -21455,7 +21493,7 @@ ${input.slice(result.pos)}
21455
21493
  return result;
21456
21494
  }
21457
21495
  }
21458
- 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);
21459
21497
  function InlineBasicInterfaceProperty(state) {
21460
21498
  let eventData;
21461
21499
  if (state.events) {
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
  }
@@ -1328,8 +1329,27 @@ var require_lib = __commonJS({
1328
1329
  thisAssignments
1329
1330
  };
1330
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
+ }
1331
1349
  function processFunctions(statements, config) {
1332
1350
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1351
+ if (f.type === "FunctionExpression")
1352
+ implicitFunctionBlock(f);
1333
1353
  processParams(f);
1334
1354
  if (!processReturnValue(f) && config.implicitReturns) {
1335
1355
  const { block, returnType } = f;
@@ -1341,25 +1361,15 @@ var require_lib = __commonJS({
1341
1361
  }
1342
1362
  });
1343
1363
  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
- }
1364
+ implicitFunctionBlock(f);
1355
1365
  processParams(f);
1356
1366
  if (!processReturnValue(f) && config.implicitReturns) {
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;
1367
+ const { signature, block } = f;
1368
+ const isConstructor = signature.name === "constructor";
1369
+ const isVoid = isVoidType(signature.returnType?.t);
1370
+ const isSet = signature.modifier?.set;
1361
1371
  if (!isConstructor && !isSet && !isVoid) {
1362
- insertReturn(block2);
1372
+ insertReturn(block);
1363
1373
  }
1364
1374
  }
1365
1375
  });
@@ -3454,6 +3464,7 @@ ${input.slice(result.pos)}
3454
3464
  NestedEnumProperties,
3455
3465
  NestedEnumProperty,
3456
3466
  EnumProperty,
3467
+ TypeProperty,
3457
3468
  TypeIndexSignature,
3458
3469
  TypeIndex,
3459
3470
  TypeSuffix,
@@ -4253,10 +4264,9 @@ ${input.slice(result.pos)}
4253
4264
  }
4254
4265
  var ForbiddenImplicitCalls$0 = $R$0($EXPECT($R0, fail, "ForbiddenImplicitCalls /(as|of|satisfies|then|when|implements|xor|xnor)(?!\\p{ID_Continue}|[\\u200C\\u200D$])/"));
4255
4266
  var ForbiddenImplicitCalls$1 = $EXPECT($L1, fail, 'ForbiddenImplicitCalls "/ "');
4256
- var ForbiddenImplicitCalls$2 = $S(ClassImplicitCallForbidden, Class);
4257
- var ForbiddenImplicitCalls$3 = AtAt;
4258
- var ForbiddenImplicitCalls$4 = $S(Identifier, $EXPECT($L2, fail, 'ForbiddenImplicitCalls "="'), Whitespace);
4259
- 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) {
4260
4270
  if (module.operators.has($1.name))
4261
4271
  return $1;
4262
4272
  return $skip;
@@ -4272,12 +4282,12 @@ ${input.slice(result.pos)}
4272
4282
  }
4273
4283
  }
4274
4284
  if (state.tokenize) {
4275
- 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));
4276
4286
  if (state.events)
4277
4287
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4278
4288
  return result;
4279
4289
  } else {
4280
- 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);
4281
4291
  if (state.events)
4282
4292
  state.events.exit?.("ForbiddenImplicitCalls", state, result, eventData);
4283
4293
  return result;
@@ -5981,7 +5991,7 @@ ${input.slice(result.pos)}
5981
5991
  return result;
5982
5992
  }
5983
5993
  }
5984
- 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) {
5985
5995
  if (!($1 || $2))
5986
5996
  return $skip;
5987
5997
  return {
@@ -7737,9 +7747,11 @@ ${input.slice(result.pos)}
7737
7747
  async = [];
7738
7748
  if (!generator)
7739
7749
  generator = [];
7750
+ const id = wid?.[1];
7740
7751
  return {
7741
7752
  type: "FunctionSignature",
7742
- id: wid?.[1],
7753
+ id,
7754
+ name: id?.name,
7743
7755
  parameters,
7744
7756
  returnType: suffix,
7745
7757
  ts: false,
@@ -7775,8 +7787,11 @@ ${input.slice(result.pos)}
7775
7787
  var signature = $1;
7776
7788
  var block = $2;
7777
7789
  if (!block) {
7778
- signature.ts = true;
7779
- return signature;
7790
+ return {
7791
+ ...signature,
7792
+ type: "FunctionExpression",
7793
+ ts: true
7794
+ };
7780
7795
  }
7781
7796
  if (hasAwait(block) && !signature.async.length) {
7782
7797
  signature.async.push("async ");
@@ -13044,7 +13059,7 @@ ${input.slice(result.pos)}
13044
13059
  }
13045
13060
  }
13046
13061
  var ForbidClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'ForbidClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13047
- module.forbidIndentedApplication.push(true);
13062
+ module.forbidClassImplicitCall.push(true);
13048
13063
  });
13049
13064
  function ForbidClassImplicitCall(state) {
13050
13065
  let eventData;
@@ -13069,7 +13084,7 @@ ${input.slice(result.pos)}
13069
13084
  }
13070
13085
  }
13071
13086
  var AllowClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'AllowClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13072
- module.forbidIndentedApplication.push(false);
13087
+ module.forbidClassImplicitCall.push(false);
13073
13088
  });
13074
13089
  function AllowClassImplicitCall(state) {
13075
13090
  let eventData;
@@ -13094,7 +13109,7 @@ ${input.slice(result.pos)}
13094
13109
  }
13095
13110
  }
13096
13111
  var RestoreClassImplicitCall$0 = $TV($EXPECT($L0, fail, 'RestoreClassImplicitCall ""'), function($skip, $loc, $0, $1) {
13097
- module.forbidIndentedApplication.pop();
13112
+ module.forbidClassImplicitCall.pop();
13098
13113
  });
13099
13114
  function RestoreClassImplicitCall(state) {
13100
13115
  let eventData;
@@ -13119,7 +13134,7 @@ ${input.slice(result.pos)}
13119
13134
  }
13120
13135
  }
13121
13136
  var ClassImplicitCallForbidden$0 = $TV($EXPECT($L0, fail, 'ClassImplicitCallForbidden ""'), function($skip, $loc, $0, $1) {
13122
- if (module.classImplicitCallForbidden)
13137
+ if (!module.classImplicitCallForbidden)
13123
13138
  return $skip;
13124
13139
  return;
13125
13140
  });
@@ -20328,7 +20343,7 @@ ${input.slice(result.pos)}
20328
20343
  return result;
20329
20344
  }
20330
20345
  }
20331
- var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, PropertyName), TypeSuffix, InterfacePropertyDelimiter);
20346
+ var BasicInterfaceProperty$0 = $S($C(TypeIndexSignature, TypeProperty), $E(_), TypeSuffix, InterfacePropertyDelimiter);
20332
20347
  function BasicInterfaceProperty(state) {
20333
20348
  let eventData;
20334
20349
  if (state.events) {
@@ -20769,7 +20784,30 @@ ${input.slice(result.pos)}
20769
20784
  return result;
20770
20785
  }
20771
20786
  }
20772
- 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)))));
20773
20811
  function TypeIndexSignature(state) {
20774
20812
  let eventData;
20775
20813
  if (state.events) {
@@ -21453,7 +21491,7 @@ ${input.slice(result.pos)}
21453
21491
  return result;
21454
21492
  }
21455
21493
  }
21456
- 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);
21457
21495
  function InlineBasicInterfaceProperty(state) {
21458
21496
  let eventData;
21459
21497
  if (state.events) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.7",
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",