@danielx/civet 0.6.29 → 0.6.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ The modern way to write TypeScript.
23
23
  [Vite](https://github.com/lorefnon/vite-plugin-civet),
24
24
  -->
25
25
  [Babel](source/babel-plugin.mjs),
26
- [Gulp](integrations/gulp),
26
+ [Gulp](integration/gulp),
27
27
  [ESM module resolution](source/esm.civet),
28
28
  [CJS](register.js),
29
29
  [Bun](source/bun-civet.coffee)
package/dist/browser.js CHANGED
@@ -629,7 +629,8 @@ ${input.slice(result.pos)}
629
629
  aliasBinding(p.value, ref);
630
630
  } else {
631
631
  p.value = ref;
632
- p.children.push(": ", ref);
632
+ const index = p.children.indexOf(p.name);
633
+ p.children.splice(index + 1, 0, ": ", ref);
633
634
  }
634
635
  }
635
636
  function arrayElementHasTrailingComma(elementNode) {
@@ -1912,7 +1913,7 @@ ${input.slice(result.pos)}
1912
1913
  } else if (modifier.async) {
1913
1914
  modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
1914
1915
  } else {
1915
- modifier = ["function ", ...modifier.children];
1916
+ modifier = ["function ", ...modifier.children || []];
1916
1917
  }
1917
1918
  } else {
1918
1919
  modifier = "function ";
@@ -1920,6 +1921,7 @@ ${input.slice(result.pos)}
1920
1921
  return {
1921
1922
  ...signature,
1922
1923
  id: signature.name,
1924
+ signature,
1923
1925
  type: "FunctionExpression",
1924
1926
  children: [
1925
1927
  [modifier, ...signature.children.slice(1)],
@@ -2061,40 +2063,31 @@ ${input.slice(result.pos)}
2061
2063
  f.ts = false;
2062
2064
  }
2063
2065
  }
2066
+ function processReturn(f, implicitReturns) {
2067
+ if (!processReturnValue(f) && implicitReturns) {
2068
+ const { signature, block } = f;
2069
+ const { modifier, name, returnType } = signature;
2070
+ const { async, set } = modifier;
2071
+ const isMethod = f.type === "MethodDefinition";
2072
+ const isConstructor = isMethod && name === "constructor";
2073
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2074
+ const isBlock = block?.type === "BlockStatement";
2075
+ if (!isVoid && !set && !isConstructor && isBlock) {
2076
+ insertReturn(block);
2077
+ }
2078
+ }
2079
+ }
2064
2080
  function processFunctions(statements, config) {
2065
2081
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
2066
2082
  if (f.type === "FunctionExpression")
2067
2083
  implicitFunctionBlock(f);
2068
2084
  processParams(f);
2069
- if (!processReturnValue(f) && config.implicitReturns) {
2070
- const { async, block, returnType } = f;
2071
- const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2072
- const isBlock = block?.type === "BlockStatement";
2073
- if (!isVoid && isBlock) {
2074
- return insertReturn(block);
2075
- }
2076
- ;
2077
- return;
2078
- }
2079
- ;
2080
- return;
2085
+ return processReturn(f, config.implicitReturns);
2081
2086
  });
2082
2087
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
2083
2088
  implicitFunctionBlock(f);
2084
2089
  processParams(f);
2085
- if (!processReturnValue(f) && config.implicitReturns) {
2086
- const { signature, block } = f;
2087
- const isConstructor = signature.name === "constructor";
2088
- const isVoid = isVoidType(signature.returnType?.t);
2089
- const isSet = signature.modifier?.set;
2090
- if (!isConstructor && !isSet && !isVoid) {
2091
- return insertReturn(block);
2092
- }
2093
- ;
2094
- return;
2095
- }
2096
- ;
2097
- return;
2090
+ return processReturn(f, config.implicitReturns);
2098
2091
  });
2099
2092
  }
2100
2093
  function processSwitchExpressions(statements) {
@@ -3419,6 +3412,8 @@ ${input.slice(result.pos)}
3419
3412
  ReturnValue,
3420
3413
  AfterReturnShorthand,
3421
3414
  Parameters,
3415
+ ShortArrowParameters,
3416
+ ArrowParameters,
3422
3417
  NonEmptyParameters,
3423
3418
  FunctionRestParameter,
3424
3419
  ParameterElement,
@@ -4734,7 +4729,7 @@ ${input.slice(result.pos)}
4734
4729
  return $EVENT_C(ctx, state, "YieldTail", YieldTail$$);
4735
4730
  }
4736
4731
  var ArrowFunction$0 = ThinArrowFunction;
4737
- var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4732
+ var ArrowFunction$1 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4738
4733
  var async = $1;
4739
4734
  var parameters = $2;
4740
4735
  var suffix = $3;
@@ -4751,6 +4746,12 @@ ${input.slice(result.pos)}
4751
4746
  }
4752
4747
  return {
4753
4748
  type: "ArrowFunction",
4749
+ signature: {
4750
+ modifier: {
4751
+ async: !!async
4752
+ },
4753
+ returnType: suffix
4754
+ },
4754
4755
  parameters,
4755
4756
  returnType: suffix,
4756
4757
  ts: false,
@@ -4826,6 +4827,11 @@ ${input.slice(result.pos)}
4826
4827
  };
4827
4828
  return {
4828
4829
  type: "ArrowFunction",
4830
+ signature: {
4831
+ modifier: {
4832
+ children: []
4833
+ }
4834
+ },
4829
4835
  children: [ref, " => ", arrowBody],
4830
4836
  ref,
4831
4837
  body: [arrowBody],
@@ -5525,6 +5531,24 @@ ${input.slice(result.pos)}
5525
5531
  function Parameters(ctx, state) {
5526
5532
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5527
5533
  }
5534
+ var ShortArrowParameters$0 = ObjectBindingPattern;
5535
+ var ShortArrowParameters$1 = ArrayBindingPattern;
5536
+ var ShortArrowParameters$$ = [ShortArrowParameters$0, ShortArrowParameters$1];
5537
+ function ShortArrowParameters(ctx, state) {
5538
+ return $EVENT_C(ctx, state, "ShortArrowParameters", ShortArrowParameters$$);
5539
+ }
5540
+ var ArrowParameters$0 = $TS($S(ShortArrowParameters), function($skip, $loc, $0, $1) {
5541
+ return {
5542
+ type: "Parameters",
5543
+ children: ["(", $0, ")"],
5544
+ names: $0.names
5545
+ };
5546
+ });
5547
+ var ArrowParameters$1 = Parameters;
5548
+ var ArrowParameters$$ = [ArrowParameters$0, ArrowParameters$1];
5549
+ function ArrowParameters(ctx, state) {
5550
+ return $EVENT_C(ctx, state, "ArrowParameters", ArrowParameters$$);
5551
+ }
5528
5552
  var NonEmptyParameters$0 = $TS($S($E(TypeParameters), OpenParen, $E(ThisType), $Q(ParameterElement), $E(FunctionRestParameter), $Q(ParameterElement), $S(__, CloseParen)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
5529
5553
  var tp = $1;
5530
5554
  var open = $2;
@@ -5969,6 +5993,10 @@ ${input.slice(result.pos)}
5969
5993
  ts: false,
5970
5994
  async,
5971
5995
  generator,
5996
+ modifier: {
5997
+ async: !async.length,
5998
+ generator: !generator.length
5999
+ },
5972
6000
  block: null,
5973
6001
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5974
6002
  };
@@ -5983,6 +6011,7 @@ ${input.slice(result.pos)}
5983
6011
  return {
5984
6012
  ...signature,
5985
6013
  type: "FunctionExpression",
6014
+ signature,
5986
6015
  ts: true
5987
6016
  };
5988
6017
  }
@@ -5995,6 +6024,7 @@ ${input.slice(result.pos)}
5995
6024
  return {
5996
6025
  ...signature,
5997
6026
  type: "FunctionExpression",
6027
+ signature,
5998
6028
  children: [...signature.children, block],
5999
6029
  block
6000
6030
  };
@@ -6003,6 +6033,9 @@ ${input.slice(result.pos)}
6003
6033
  const ref = makeRef("$"), body = [ref];
6004
6034
  return {
6005
6035
  type: "ArrowFunction",
6036
+ signature: {
6037
+ modifier: {}
6038
+ },
6006
6039
  children: [ref, " => ", body],
6007
6040
  ref,
6008
6041
  body,
@@ -6014,7 +6047,6 @@ ${input.slice(result.pos)}
6014
6047
  var id = $1;
6015
6048
  var ws = $4;
6016
6049
  var fn = $5;
6017
- debugger;
6018
6050
  return {
6019
6051
  ...fn,
6020
6052
  id,
@@ -6051,11 +6083,17 @@ ${input.slice(result.pos)}
6051
6083
  };
6052
6084
  }
6053
6085
  const children = [ref, " => ", body];
6054
- if (hasAwait(body)) {
6086
+ const async = hasAwait(body);
6087
+ if (async) {
6055
6088
  children.unshift("async ");
6056
6089
  }
6057
6090
  return {
6058
6091
  type: "ArrowFunction",
6092
+ signature: {
6093
+ modifier: {
6094
+ async
6095
+ }
6096
+ },
6059
6097
  children,
6060
6098
  ref,
6061
6099
  body,
@@ -6079,6 +6117,7 @@ ${input.slice(result.pos)}
6079
6117
  return {
6080
6118
  ...signature,
6081
6119
  type: "FunctionExpression",
6120
+ signature,
6082
6121
  children: [...signature.children, block],
6083
6122
  block,
6084
6123
  operator: true
@@ -6113,6 +6152,7 @@ ${input.slice(result.pos)}
6113
6152
  return {
6114
6153
  type: "FunctionSignature",
6115
6154
  id,
6155
+ modifier: {},
6116
6156
  parameters,
6117
6157
  returnType: suffix,
6118
6158
  ts: false,
@@ -6165,7 +6205,7 @@ ${input.slice(result.pos)}
6165
6205
  function AmpersandUnaryPrefix(ctx, state) {
6166
6206
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6167
6207
  }
6168
- var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6208
+ var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6169
6209
  var async = $1;
6170
6210
  var parameters = $2;
6171
6211
  var suffix = $3;
@@ -6187,6 +6227,14 @@ ${input.slice(result.pos)}
6187
6227
  async,
6188
6228
  generator,
6189
6229
  block,
6230
+ signature: {
6231
+ name: void 0,
6232
+ modifier: {
6233
+ async: !!async,
6234
+ generator: !!generator
6235
+ },
6236
+ returnType: suffix
6237
+ },
6190
6238
  children: [
6191
6239
  async,
6192
6240
  { $loc: arrow.$loc, token: "function" },
@@ -7250,6 +7298,7 @@ ${input.slice(result.pos)}
7250
7298
  type: "MethodSignature",
7251
7299
  children: $0,
7252
7300
  name: $1.token,
7301
+ modifier: {},
7253
7302
  returnType: void 0,
7254
7303
  parameters
7255
7304
  };
@@ -7267,6 +7316,7 @@ ${input.slice(result.pos)}
7267
7316
  }
7268
7317
  if (optional)
7269
7318
  $0[3] = optional = { ...optional, ts: true };
7319
+ modifier = modifier || {};
7270
7320
  return {
7271
7321
  type: "MethodSignature",
7272
7322
  children: $0,
@@ -12371,6 +12421,8 @@ ${input.slice(result.pos)}
12371
12421
  exports.ReturnValue = ReturnValue;
12372
12422
  exports.AfterReturnShorthand = AfterReturnShorthand;
12373
12423
  exports.Parameters = Parameters;
12424
+ exports.ShortArrowParameters = ShortArrowParameters;
12425
+ exports.ArrowParameters = ArrowParameters;
12374
12426
  exports.NonEmptyParameters = NonEmptyParameters;
12375
12427
  exports.FunctionRestParameter = FunctionRestParameter;
12376
12428
  exports.ParameterElement = ParameterElement;
package/dist/main.js CHANGED
@@ -628,7 +628,8 @@ var require_lib = __commonJS({
628
628
  aliasBinding(p.value, ref);
629
629
  } else {
630
630
  p.value = ref;
631
- p.children.push(": ", ref);
631
+ const index = p.children.indexOf(p.name);
632
+ p.children.splice(index + 1, 0, ": ", ref);
632
633
  }
633
634
  }
634
635
  function arrayElementHasTrailingComma(elementNode) {
@@ -1911,7 +1912,7 @@ var require_lib = __commonJS({
1911
1912
  } else if (modifier.async) {
1912
1913
  modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
1913
1914
  } else {
1914
- modifier = ["function ", ...modifier.children];
1915
+ modifier = ["function ", ...modifier.children || []];
1915
1916
  }
1916
1917
  } else {
1917
1918
  modifier = "function ";
@@ -1919,6 +1920,7 @@ var require_lib = __commonJS({
1919
1920
  return {
1920
1921
  ...signature,
1921
1922
  id: signature.name,
1923
+ signature,
1922
1924
  type: "FunctionExpression",
1923
1925
  children: [
1924
1926
  [modifier, ...signature.children.slice(1)],
@@ -2060,40 +2062,31 @@ var require_lib = __commonJS({
2060
2062
  f.ts = false;
2061
2063
  }
2062
2064
  }
2065
+ function processReturn(f, implicitReturns) {
2066
+ if (!processReturnValue(f) && implicitReturns) {
2067
+ const { signature, block } = f;
2068
+ const { modifier, name, returnType } = signature;
2069
+ const { async, set } = modifier;
2070
+ const isMethod = f.type === "MethodDefinition";
2071
+ const isConstructor = isMethod && name === "constructor";
2072
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2073
+ const isBlock = block?.type === "BlockStatement";
2074
+ if (!isVoid && !set && !isConstructor && isBlock) {
2075
+ insertReturn(block);
2076
+ }
2077
+ }
2078
+ }
2063
2079
  function processFunctions(statements, config) {
2064
2080
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
2065
2081
  if (f.type === "FunctionExpression")
2066
2082
  implicitFunctionBlock(f);
2067
2083
  processParams(f);
2068
- if (!processReturnValue(f) && config.implicitReturns) {
2069
- const { async, block, returnType } = f;
2070
- const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2071
- const isBlock = block?.type === "BlockStatement";
2072
- if (!isVoid && isBlock) {
2073
- return insertReturn(block);
2074
- }
2075
- ;
2076
- return;
2077
- }
2078
- ;
2079
- return;
2084
+ return processReturn(f, config.implicitReturns);
2080
2085
  });
2081
2086
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
2082
2087
  implicitFunctionBlock(f);
2083
2088
  processParams(f);
2084
- if (!processReturnValue(f) && config.implicitReturns) {
2085
- const { signature, block } = f;
2086
- const isConstructor = signature.name === "constructor";
2087
- const isVoid = isVoidType(signature.returnType?.t);
2088
- const isSet = signature.modifier?.set;
2089
- if (!isConstructor && !isSet && !isVoid) {
2090
- return insertReturn(block);
2091
- }
2092
- ;
2093
- return;
2094
- }
2095
- ;
2096
- return;
2089
+ return processReturn(f, config.implicitReturns);
2097
2090
  });
2098
2091
  }
2099
2092
  function processSwitchExpressions(statements) {
@@ -3418,6 +3411,8 @@ var require_parser = __commonJS({
3418
3411
  ReturnValue,
3419
3412
  AfterReturnShorthand,
3420
3413
  Parameters,
3414
+ ShortArrowParameters,
3415
+ ArrowParameters,
3421
3416
  NonEmptyParameters,
3422
3417
  FunctionRestParameter,
3423
3418
  ParameterElement,
@@ -4733,7 +4728,7 @@ var require_parser = __commonJS({
4733
4728
  return $EVENT_C(ctx, state, "YieldTail", YieldTail$$);
4734
4729
  }
4735
4730
  var ArrowFunction$0 = ThinArrowFunction;
4736
- var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4731
+ var ArrowFunction$1 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4737
4732
  var async = $1;
4738
4733
  var parameters = $2;
4739
4734
  var suffix = $3;
@@ -4750,6 +4745,12 @@ var require_parser = __commonJS({
4750
4745
  }
4751
4746
  return {
4752
4747
  type: "ArrowFunction",
4748
+ signature: {
4749
+ modifier: {
4750
+ async: !!async
4751
+ },
4752
+ returnType: suffix
4753
+ },
4753
4754
  parameters,
4754
4755
  returnType: suffix,
4755
4756
  ts: false,
@@ -4825,6 +4826,11 @@ var require_parser = __commonJS({
4825
4826
  };
4826
4827
  return {
4827
4828
  type: "ArrowFunction",
4829
+ signature: {
4830
+ modifier: {
4831
+ children: []
4832
+ }
4833
+ },
4828
4834
  children: [ref, " => ", arrowBody],
4829
4835
  ref,
4830
4836
  body: [arrowBody],
@@ -5524,6 +5530,24 @@ var require_parser = __commonJS({
5524
5530
  function Parameters(ctx, state) {
5525
5531
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5526
5532
  }
5533
+ var ShortArrowParameters$0 = ObjectBindingPattern;
5534
+ var ShortArrowParameters$1 = ArrayBindingPattern;
5535
+ var ShortArrowParameters$$ = [ShortArrowParameters$0, ShortArrowParameters$1];
5536
+ function ShortArrowParameters(ctx, state) {
5537
+ return $EVENT_C(ctx, state, "ShortArrowParameters", ShortArrowParameters$$);
5538
+ }
5539
+ var ArrowParameters$0 = $TS($S(ShortArrowParameters), function($skip, $loc, $0, $1) {
5540
+ return {
5541
+ type: "Parameters",
5542
+ children: ["(", $0, ")"],
5543
+ names: $0.names
5544
+ };
5545
+ });
5546
+ var ArrowParameters$1 = Parameters;
5547
+ var ArrowParameters$$ = [ArrowParameters$0, ArrowParameters$1];
5548
+ function ArrowParameters(ctx, state) {
5549
+ return $EVENT_C(ctx, state, "ArrowParameters", ArrowParameters$$);
5550
+ }
5527
5551
  var NonEmptyParameters$0 = $TS($S($E(TypeParameters), OpenParen, $E(ThisType), $Q(ParameterElement), $E(FunctionRestParameter), $Q(ParameterElement), $S(__, CloseParen)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
5528
5552
  var tp = $1;
5529
5553
  var open = $2;
@@ -5968,6 +5992,10 @@ var require_parser = __commonJS({
5968
5992
  ts: false,
5969
5993
  async,
5970
5994
  generator,
5995
+ modifier: {
5996
+ async: !async.length,
5997
+ generator: !generator.length
5998
+ },
5971
5999
  block: null,
5972
6000
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5973
6001
  };
@@ -5982,6 +6010,7 @@ var require_parser = __commonJS({
5982
6010
  return {
5983
6011
  ...signature,
5984
6012
  type: "FunctionExpression",
6013
+ signature,
5985
6014
  ts: true
5986
6015
  };
5987
6016
  }
@@ -5994,6 +6023,7 @@ var require_parser = __commonJS({
5994
6023
  return {
5995
6024
  ...signature,
5996
6025
  type: "FunctionExpression",
6026
+ signature,
5997
6027
  children: [...signature.children, block],
5998
6028
  block
5999
6029
  };
@@ -6002,6 +6032,9 @@ var require_parser = __commonJS({
6002
6032
  const ref = makeRef("$"), body = [ref];
6003
6033
  return {
6004
6034
  type: "ArrowFunction",
6035
+ signature: {
6036
+ modifier: {}
6037
+ },
6005
6038
  children: [ref, " => ", body],
6006
6039
  ref,
6007
6040
  body,
@@ -6013,7 +6046,6 @@ var require_parser = __commonJS({
6013
6046
  var id = $1;
6014
6047
  var ws = $4;
6015
6048
  var fn = $5;
6016
- debugger;
6017
6049
  return {
6018
6050
  ...fn,
6019
6051
  id,
@@ -6050,11 +6082,17 @@ var require_parser = __commonJS({
6050
6082
  };
6051
6083
  }
6052
6084
  const children = [ref, " => ", body];
6053
- if (hasAwait(body)) {
6085
+ const async = hasAwait(body);
6086
+ if (async) {
6054
6087
  children.unshift("async ");
6055
6088
  }
6056
6089
  return {
6057
6090
  type: "ArrowFunction",
6091
+ signature: {
6092
+ modifier: {
6093
+ async
6094
+ }
6095
+ },
6058
6096
  children,
6059
6097
  ref,
6060
6098
  body,
@@ -6078,6 +6116,7 @@ var require_parser = __commonJS({
6078
6116
  return {
6079
6117
  ...signature,
6080
6118
  type: "FunctionExpression",
6119
+ signature,
6081
6120
  children: [...signature.children, block],
6082
6121
  block,
6083
6122
  operator: true
@@ -6112,6 +6151,7 @@ var require_parser = __commonJS({
6112
6151
  return {
6113
6152
  type: "FunctionSignature",
6114
6153
  id,
6154
+ modifier: {},
6115
6155
  parameters,
6116
6156
  returnType: suffix,
6117
6157
  ts: false,
@@ -6164,7 +6204,7 @@ var require_parser = __commonJS({
6164
6204
  function AmpersandUnaryPrefix(ctx, state) {
6165
6205
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6166
6206
  }
6167
- var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6207
+ var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6168
6208
  var async = $1;
6169
6209
  var parameters = $2;
6170
6210
  var suffix = $3;
@@ -6186,6 +6226,14 @@ var require_parser = __commonJS({
6186
6226
  async,
6187
6227
  generator,
6188
6228
  block,
6229
+ signature: {
6230
+ name: void 0,
6231
+ modifier: {
6232
+ async: !!async,
6233
+ generator: !!generator
6234
+ },
6235
+ returnType: suffix
6236
+ },
6189
6237
  children: [
6190
6238
  async,
6191
6239
  { $loc: arrow.$loc, token: "function" },
@@ -7249,6 +7297,7 @@ var require_parser = __commonJS({
7249
7297
  type: "MethodSignature",
7250
7298
  children: $0,
7251
7299
  name: $1.token,
7300
+ modifier: {},
7252
7301
  returnType: void 0,
7253
7302
  parameters
7254
7303
  };
@@ -7266,6 +7315,7 @@ var require_parser = __commonJS({
7266
7315
  }
7267
7316
  if (optional)
7268
7317
  $0[3] = optional = { ...optional, ts: true };
7318
+ modifier = modifier || {};
7269
7319
  return {
7270
7320
  type: "MethodSignature",
7271
7321
  children: $0,
@@ -12370,6 +12420,8 @@ var require_parser = __commonJS({
12370
12420
  exports.ReturnValue = ReturnValue;
12371
12421
  exports.AfterReturnShorthand = AfterReturnShorthand;
12372
12422
  exports.Parameters = Parameters;
12423
+ exports.ShortArrowParameters = ShortArrowParameters;
12424
+ exports.ArrowParameters = ArrowParameters;
12373
12425
  exports.NonEmptyParameters = NonEmptyParameters;
12374
12426
  exports.FunctionRestParameter = FunctionRestParameter;
12375
12427
  exports.ParameterElement = ParameterElement;
package/dist/main.mjs CHANGED
@@ -626,7 +626,8 @@ var require_lib = __commonJS({
626
626
  aliasBinding(p.value, ref);
627
627
  } else {
628
628
  p.value = ref;
629
- p.children.push(": ", ref);
629
+ const index = p.children.indexOf(p.name);
630
+ p.children.splice(index + 1, 0, ": ", ref);
630
631
  }
631
632
  }
632
633
  function arrayElementHasTrailingComma(elementNode) {
@@ -1909,7 +1910,7 @@ var require_lib = __commonJS({
1909
1910
  } else if (modifier.async) {
1910
1911
  modifier = [modifier.children[0][0], " function ", ...modifier.children.slice(1)];
1911
1912
  } else {
1912
- modifier = ["function ", ...modifier.children];
1913
+ modifier = ["function ", ...modifier.children || []];
1913
1914
  }
1914
1915
  } else {
1915
1916
  modifier = "function ";
@@ -1917,6 +1918,7 @@ var require_lib = __commonJS({
1917
1918
  return {
1918
1919
  ...signature,
1919
1920
  id: signature.name,
1921
+ signature,
1920
1922
  type: "FunctionExpression",
1921
1923
  children: [
1922
1924
  [modifier, ...signature.children.slice(1)],
@@ -2058,40 +2060,31 @@ var require_lib = __commonJS({
2058
2060
  f.ts = false;
2059
2061
  }
2060
2062
  }
2063
+ function processReturn(f, implicitReturns) {
2064
+ if (!processReturnValue(f) && implicitReturns) {
2065
+ const { signature, block } = f;
2066
+ const { modifier, name, returnType } = signature;
2067
+ const { async, set } = modifier;
2068
+ const isMethod = f.type === "MethodDefinition";
2069
+ const isConstructor = isMethod && name === "constructor";
2070
+ const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2071
+ const isBlock = block?.type === "BlockStatement";
2072
+ if (!isVoid && !set && !isConstructor && isBlock) {
2073
+ insertReturn(block);
2074
+ }
2075
+ }
2076
+ }
2061
2077
  function processFunctions(statements, config) {
2062
2078
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
2063
2079
  if (f.type === "FunctionExpression")
2064
2080
  implicitFunctionBlock(f);
2065
2081
  processParams(f);
2066
- if (!processReturnValue(f) && config.implicitReturns) {
2067
- const { async, block, returnType } = f;
2068
- const isVoid = isVoidType(returnType?.t) || async && isPromiseVoidType(returnType?.t);
2069
- const isBlock = block?.type === "BlockStatement";
2070
- if (!isVoid && isBlock) {
2071
- return insertReturn(block);
2072
- }
2073
- ;
2074
- return;
2075
- }
2076
- ;
2077
- return;
2082
+ return processReturn(f, config.implicitReturns);
2078
2083
  });
2079
2084
  gatherRecursiveAll(statements, ({ type }) => type === "MethodDefinition").forEach((f) => {
2080
2085
  implicitFunctionBlock(f);
2081
2086
  processParams(f);
2082
- if (!processReturnValue(f) && config.implicitReturns) {
2083
- const { signature, block } = f;
2084
- const isConstructor = signature.name === "constructor";
2085
- const isVoid = isVoidType(signature.returnType?.t);
2086
- const isSet = signature.modifier?.set;
2087
- if (!isConstructor && !isSet && !isVoid) {
2088
- return insertReturn(block);
2089
- }
2090
- ;
2091
- return;
2092
- }
2093
- ;
2094
- return;
2087
+ return processReturn(f, config.implicitReturns);
2095
2088
  });
2096
2089
  }
2097
2090
  function processSwitchExpressions(statements) {
@@ -3416,6 +3409,8 @@ var require_parser = __commonJS({
3416
3409
  ReturnValue,
3417
3410
  AfterReturnShorthand,
3418
3411
  Parameters,
3412
+ ShortArrowParameters,
3413
+ ArrowParameters,
3419
3414
  NonEmptyParameters,
3420
3415
  FunctionRestParameter,
3421
3416
  ParameterElement,
@@ -4731,7 +4726,7 @@ var require_parser = __commonJS({
4731
4726
  return $EVENT_C(ctx, state, "YieldTail", YieldTail$$);
4732
4727
  }
4733
4728
  var ArrowFunction$0 = ThinArrowFunction;
4734
- var ArrowFunction$1 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4729
+ var ArrowFunction$1 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), FatArrow, FatArrowBody), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4735
4730
  var async = $1;
4736
4731
  var parameters = $2;
4737
4732
  var suffix = $3;
@@ -4748,6 +4743,12 @@ var require_parser = __commonJS({
4748
4743
  }
4749
4744
  return {
4750
4745
  type: "ArrowFunction",
4746
+ signature: {
4747
+ modifier: {
4748
+ async: !!async
4749
+ },
4750
+ returnType: suffix
4751
+ },
4751
4752
  parameters,
4752
4753
  returnType: suffix,
4753
4754
  ts: false,
@@ -4823,6 +4824,11 @@ var require_parser = __commonJS({
4823
4824
  };
4824
4825
  return {
4825
4826
  type: "ArrowFunction",
4827
+ signature: {
4828
+ modifier: {
4829
+ children: []
4830
+ }
4831
+ },
4826
4832
  children: [ref, " => ", arrowBody],
4827
4833
  ref,
4828
4834
  body: [arrowBody],
@@ -5522,6 +5528,24 @@ var require_parser = __commonJS({
5522
5528
  function Parameters(ctx, state) {
5523
5529
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5524
5530
  }
5531
+ var ShortArrowParameters$0 = ObjectBindingPattern;
5532
+ var ShortArrowParameters$1 = ArrayBindingPattern;
5533
+ var ShortArrowParameters$$ = [ShortArrowParameters$0, ShortArrowParameters$1];
5534
+ function ShortArrowParameters(ctx, state) {
5535
+ return $EVENT_C(ctx, state, "ShortArrowParameters", ShortArrowParameters$$);
5536
+ }
5537
+ var ArrowParameters$0 = $TS($S(ShortArrowParameters), function($skip, $loc, $0, $1) {
5538
+ return {
5539
+ type: "Parameters",
5540
+ children: ["(", $0, ")"],
5541
+ names: $0.names
5542
+ };
5543
+ });
5544
+ var ArrowParameters$1 = Parameters;
5545
+ var ArrowParameters$$ = [ArrowParameters$0, ArrowParameters$1];
5546
+ function ArrowParameters(ctx, state) {
5547
+ return $EVENT_C(ctx, state, "ArrowParameters", ArrowParameters$$);
5548
+ }
5525
5549
  var NonEmptyParameters$0 = $TS($S($E(TypeParameters), OpenParen, $E(ThisType), $Q(ParameterElement), $E(FunctionRestParameter), $Q(ParameterElement), $S(__, CloseParen)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
5526
5550
  var tp = $1;
5527
5551
  var open = $2;
@@ -5966,6 +5990,10 @@ var require_parser = __commonJS({
5966
5990
  ts: false,
5967
5991
  async,
5968
5992
  generator,
5993
+ modifier: {
5994
+ async: !async.length,
5995
+ generator: !generator.length
5996
+ },
5969
5997
  block: null,
5970
5998
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5971
5999
  };
@@ -5980,6 +6008,7 @@ var require_parser = __commonJS({
5980
6008
  return {
5981
6009
  ...signature,
5982
6010
  type: "FunctionExpression",
6011
+ signature,
5983
6012
  ts: true
5984
6013
  };
5985
6014
  }
@@ -5992,6 +6021,7 @@ var require_parser = __commonJS({
5992
6021
  return {
5993
6022
  ...signature,
5994
6023
  type: "FunctionExpression",
6024
+ signature,
5995
6025
  children: [...signature.children, block],
5996
6026
  block
5997
6027
  };
@@ -6000,6 +6030,9 @@ var require_parser = __commonJS({
6000
6030
  const ref = makeRef("$"), body = [ref];
6001
6031
  return {
6002
6032
  type: "ArrowFunction",
6033
+ signature: {
6034
+ modifier: {}
6035
+ },
6003
6036
  children: [ref, " => ", body],
6004
6037
  ref,
6005
6038
  body,
@@ -6011,7 +6044,6 @@ var require_parser = __commonJS({
6011
6044
  var id = $1;
6012
6045
  var ws = $4;
6013
6046
  var fn = $5;
6014
- debugger;
6015
6047
  return {
6016
6048
  ...fn,
6017
6049
  id,
@@ -6048,11 +6080,17 @@ var require_parser = __commonJS({
6048
6080
  };
6049
6081
  }
6050
6082
  const children = [ref, " => ", body];
6051
- if (hasAwait(body)) {
6083
+ const async = hasAwait(body);
6084
+ if (async) {
6052
6085
  children.unshift("async ");
6053
6086
  }
6054
6087
  return {
6055
6088
  type: "ArrowFunction",
6089
+ signature: {
6090
+ modifier: {
6091
+ async
6092
+ }
6093
+ },
6056
6094
  children,
6057
6095
  ref,
6058
6096
  body,
@@ -6076,6 +6114,7 @@ var require_parser = __commonJS({
6076
6114
  return {
6077
6115
  ...signature,
6078
6116
  type: "FunctionExpression",
6117
+ signature,
6079
6118
  children: [...signature.children, block],
6080
6119
  block,
6081
6120
  operator: true
@@ -6110,6 +6149,7 @@ var require_parser = __commonJS({
6110
6149
  return {
6111
6150
  type: "FunctionSignature",
6112
6151
  id,
6152
+ modifier: {},
6113
6153
  parameters,
6114
6154
  returnType: suffix,
6115
6155
  ts: false,
@@ -6162,7 +6202,7 @@ var require_parser = __commonJS({
6162
6202
  function AmpersandUnaryPrefix(ctx, state) {
6163
6203
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6164
6204
  }
6165
- var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), Parameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6205
+ var ThinArrowFunction$0 = $TS($S($E($S(Async, _)), ArrowParameters, $E(ReturnTypeSuffix), $E(_), Arrow, BracedOrEmptyBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
6166
6206
  var async = $1;
6167
6207
  var parameters = $2;
6168
6208
  var suffix = $3;
@@ -6184,6 +6224,14 @@ var require_parser = __commonJS({
6184
6224
  async,
6185
6225
  generator,
6186
6226
  block,
6227
+ signature: {
6228
+ name: void 0,
6229
+ modifier: {
6230
+ async: !!async,
6231
+ generator: !!generator
6232
+ },
6233
+ returnType: suffix
6234
+ },
6187
6235
  children: [
6188
6236
  async,
6189
6237
  { $loc: arrow.$loc, token: "function" },
@@ -7247,6 +7295,7 @@ var require_parser = __commonJS({
7247
7295
  type: "MethodSignature",
7248
7296
  children: $0,
7249
7297
  name: $1.token,
7298
+ modifier: {},
7250
7299
  returnType: void 0,
7251
7300
  parameters
7252
7301
  };
@@ -7264,6 +7313,7 @@ var require_parser = __commonJS({
7264
7313
  }
7265
7314
  if (optional)
7266
7315
  $0[3] = optional = { ...optional, ts: true };
7316
+ modifier = modifier || {};
7267
7317
  return {
7268
7318
  type: "MethodSignature",
7269
7319
  children: $0,
@@ -12368,6 +12418,8 @@ var require_parser = __commonJS({
12368
12418
  exports.ReturnValue = ReturnValue;
12369
12419
  exports.AfterReturnShorthand = AfterReturnShorthand;
12370
12420
  exports.Parameters = Parameters;
12421
+ exports.ShortArrowParameters = ShortArrowParameters;
12422
+ exports.ArrowParameters = ArrowParameters;
12371
12423
  exports.NonEmptyParameters = NonEmptyParameters;
12372
12424
  exports.FunctionRestParameter = FunctionRestParameter;
12373
12425
  exports.ParameterElement = ParameterElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.29",
3
+ "version": "0.6.31",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",