@danielx/civet 0.6.29 → 0.6.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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,11 @@ ${input.slice(result.pos)}
4751
4746
  }
4752
4747
  return {
4753
4748
  type: "ArrowFunction",
4749
+ signature: {
4750
+ modifier: {
4751
+ async: !!async
4752
+ }
4753
+ },
4754
4754
  parameters,
4755
4755
  returnType: suffix,
4756
4756
  ts: false,
@@ -4826,6 +4826,11 @@ ${input.slice(result.pos)}
4826
4826
  };
4827
4827
  return {
4828
4828
  type: "ArrowFunction",
4829
+ signature: {
4830
+ modifier: {
4831
+ children: []
4832
+ }
4833
+ },
4829
4834
  children: [ref, " => ", arrowBody],
4830
4835
  ref,
4831
4836
  body: [arrowBody],
@@ -5525,6 +5530,24 @@ ${input.slice(result.pos)}
5525
5530
  function Parameters(ctx, state) {
5526
5531
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5527
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
+ }
5528
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) {
5529
5552
  var tp = $1;
5530
5553
  var open = $2;
@@ -5969,6 +5992,10 @@ ${input.slice(result.pos)}
5969
5992
  ts: false,
5970
5993
  async,
5971
5994
  generator,
5995
+ modifier: {
5996
+ async: !async.length,
5997
+ generator: !generator.length
5998
+ },
5972
5999
  block: null,
5973
6000
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5974
6001
  };
@@ -5983,6 +6010,7 @@ ${input.slice(result.pos)}
5983
6010
  return {
5984
6011
  ...signature,
5985
6012
  type: "FunctionExpression",
6013
+ signature,
5986
6014
  ts: true
5987
6015
  };
5988
6016
  }
@@ -5995,6 +6023,7 @@ ${input.slice(result.pos)}
5995
6023
  return {
5996
6024
  ...signature,
5997
6025
  type: "FunctionExpression",
6026
+ signature,
5998
6027
  children: [...signature.children, block],
5999
6028
  block
6000
6029
  };
@@ -6003,6 +6032,9 @@ ${input.slice(result.pos)}
6003
6032
  const ref = makeRef("$"), body = [ref];
6004
6033
  return {
6005
6034
  type: "ArrowFunction",
6035
+ signature: {
6036
+ modifier: {}
6037
+ },
6006
6038
  children: [ref, " => ", body],
6007
6039
  ref,
6008
6040
  body,
@@ -6014,7 +6046,6 @@ ${input.slice(result.pos)}
6014
6046
  var id = $1;
6015
6047
  var ws = $4;
6016
6048
  var fn = $5;
6017
- debugger;
6018
6049
  return {
6019
6050
  ...fn,
6020
6051
  id,
@@ -6051,11 +6082,17 @@ ${input.slice(result.pos)}
6051
6082
  };
6052
6083
  }
6053
6084
  const children = [ref, " => ", body];
6054
- if (hasAwait(body)) {
6085
+ const async = hasAwait(body);
6086
+ if (async) {
6055
6087
  children.unshift("async ");
6056
6088
  }
6057
6089
  return {
6058
6090
  type: "ArrowFunction",
6091
+ signature: {
6092
+ modifier: {
6093
+ async
6094
+ }
6095
+ },
6059
6096
  children,
6060
6097
  ref,
6061
6098
  body,
@@ -6079,6 +6116,7 @@ ${input.slice(result.pos)}
6079
6116
  return {
6080
6117
  ...signature,
6081
6118
  type: "FunctionExpression",
6119
+ signature,
6082
6120
  children: [...signature.children, block],
6083
6121
  block,
6084
6122
  operator: true
@@ -6113,6 +6151,7 @@ ${input.slice(result.pos)}
6113
6151
  return {
6114
6152
  type: "FunctionSignature",
6115
6153
  id,
6154
+ modifier: {},
6116
6155
  parameters,
6117
6156
  returnType: suffix,
6118
6157
  ts: false,
@@ -6165,7 +6204,7 @@ ${input.slice(result.pos)}
6165
6204
  function AmpersandUnaryPrefix(ctx, state) {
6166
6205
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6167
6206
  }
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) {
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) {
6169
6208
  var async = $1;
6170
6209
  var parameters = $2;
6171
6210
  var suffix = $3;
@@ -6187,6 +6226,14 @@ ${input.slice(result.pos)}
6187
6226
  async,
6188
6227
  generator,
6189
6228
  block,
6229
+ signature: {
6230
+ name: void 0,
6231
+ modifier: {
6232
+ async: !!async,
6233
+ generator: !!generator
6234
+ },
6235
+ returnType: suffix
6236
+ },
6190
6237
  children: [
6191
6238
  async,
6192
6239
  { $loc: arrow.$loc, token: "function" },
@@ -7250,6 +7297,7 @@ ${input.slice(result.pos)}
7250
7297
  type: "MethodSignature",
7251
7298
  children: $0,
7252
7299
  name: $1.token,
7300
+ modifier: {},
7253
7301
  returnType: void 0,
7254
7302
  parameters
7255
7303
  };
@@ -7267,6 +7315,7 @@ ${input.slice(result.pos)}
7267
7315
  }
7268
7316
  if (optional)
7269
7317
  $0[3] = optional = { ...optional, ts: true };
7318
+ modifier = modifier || {};
7270
7319
  return {
7271
7320
  type: "MethodSignature",
7272
7321
  children: $0,
@@ -12371,6 +12420,8 @@ ${input.slice(result.pos)}
12371
12420
  exports.ReturnValue = ReturnValue;
12372
12421
  exports.AfterReturnShorthand = AfterReturnShorthand;
12373
12422
  exports.Parameters = Parameters;
12423
+ exports.ShortArrowParameters = ShortArrowParameters;
12424
+ exports.ArrowParameters = ArrowParameters;
12374
12425
  exports.NonEmptyParameters = NonEmptyParameters;
12375
12426
  exports.FunctionRestParameter = FunctionRestParameter;
12376
12427
  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,11 @@ var require_parser = __commonJS({
4750
4745
  }
4751
4746
  return {
4752
4747
  type: "ArrowFunction",
4748
+ signature: {
4749
+ modifier: {
4750
+ async: !!async
4751
+ }
4752
+ },
4753
4753
  parameters,
4754
4754
  returnType: suffix,
4755
4755
  ts: false,
@@ -4825,6 +4825,11 @@ var require_parser = __commonJS({
4825
4825
  };
4826
4826
  return {
4827
4827
  type: "ArrowFunction",
4828
+ signature: {
4829
+ modifier: {
4830
+ children: []
4831
+ }
4832
+ },
4828
4833
  children: [ref, " => ", arrowBody],
4829
4834
  ref,
4830
4835
  body: [arrowBody],
@@ -5524,6 +5529,24 @@ var require_parser = __commonJS({
5524
5529
  function Parameters(ctx, state) {
5525
5530
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5526
5531
  }
5532
+ var ShortArrowParameters$0 = ObjectBindingPattern;
5533
+ var ShortArrowParameters$1 = ArrayBindingPattern;
5534
+ var ShortArrowParameters$$ = [ShortArrowParameters$0, ShortArrowParameters$1];
5535
+ function ShortArrowParameters(ctx, state) {
5536
+ return $EVENT_C(ctx, state, "ShortArrowParameters", ShortArrowParameters$$);
5537
+ }
5538
+ var ArrowParameters$0 = $TS($S(ShortArrowParameters), function($skip, $loc, $0, $1) {
5539
+ return {
5540
+ type: "Parameters",
5541
+ children: ["(", $0, ")"],
5542
+ names: $0.names
5543
+ };
5544
+ });
5545
+ var ArrowParameters$1 = Parameters;
5546
+ var ArrowParameters$$ = [ArrowParameters$0, ArrowParameters$1];
5547
+ function ArrowParameters(ctx, state) {
5548
+ return $EVENT_C(ctx, state, "ArrowParameters", ArrowParameters$$);
5549
+ }
5527
5550
  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
5551
  var tp = $1;
5529
5552
  var open = $2;
@@ -5968,6 +5991,10 @@ var require_parser = __commonJS({
5968
5991
  ts: false,
5969
5992
  async,
5970
5993
  generator,
5994
+ modifier: {
5995
+ async: !async.length,
5996
+ generator: !generator.length
5997
+ },
5971
5998
  block: null,
5972
5999
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5973
6000
  };
@@ -5982,6 +6009,7 @@ var require_parser = __commonJS({
5982
6009
  return {
5983
6010
  ...signature,
5984
6011
  type: "FunctionExpression",
6012
+ signature,
5985
6013
  ts: true
5986
6014
  };
5987
6015
  }
@@ -5994,6 +6022,7 @@ var require_parser = __commonJS({
5994
6022
  return {
5995
6023
  ...signature,
5996
6024
  type: "FunctionExpression",
6025
+ signature,
5997
6026
  children: [...signature.children, block],
5998
6027
  block
5999
6028
  };
@@ -6002,6 +6031,9 @@ var require_parser = __commonJS({
6002
6031
  const ref = makeRef("$"), body = [ref];
6003
6032
  return {
6004
6033
  type: "ArrowFunction",
6034
+ signature: {
6035
+ modifier: {}
6036
+ },
6005
6037
  children: [ref, " => ", body],
6006
6038
  ref,
6007
6039
  body,
@@ -6013,7 +6045,6 @@ var require_parser = __commonJS({
6013
6045
  var id = $1;
6014
6046
  var ws = $4;
6015
6047
  var fn = $5;
6016
- debugger;
6017
6048
  return {
6018
6049
  ...fn,
6019
6050
  id,
@@ -6050,11 +6081,17 @@ var require_parser = __commonJS({
6050
6081
  };
6051
6082
  }
6052
6083
  const children = [ref, " => ", body];
6053
- if (hasAwait(body)) {
6084
+ const async = hasAwait(body);
6085
+ if (async) {
6054
6086
  children.unshift("async ");
6055
6087
  }
6056
6088
  return {
6057
6089
  type: "ArrowFunction",
6090
+ signature: {
6091
+ modifier: {
6092
+ async
6093
+ }
6094
+ },
6058
6095
  children,
6059
6096
  ref,
6060
6097
  body,
@@ -6078,6 +6115,7 @@ var require_parser = __commonJS({
6078
6115
  return {
6079
6116
  ...signature,
6080
6117
  type: "FunctionExpression",
6118
+ signature,
6081
6119
  children: [...signature.children, block],
6082
6120
  block,
6083
6121
  operator: true
@@ -6112,6 +6150,7 @@ var require_parser = __commonJS({
6112
6150
  return {
6113
6151
  type: "FunctionSignature",
6114
6152
  id,
6153
+ modifier: {},
6115
6154
  parameters,
6116
6155
  returnType: suffix,
6117
6156
  ts: false,
@@ -6164,7 +6203,7 @@ var require_parser = __commonJS({
6164
6203
  function AmpersandUnaryPrefix(ctx, state) {
6165
6204
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6166
6205
  }
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) {
6206
+ 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
6207
  var async = $1;
6169
6208
  var parameters = $2;
6170
6209
  var suffix = $3;
@@ -6186,6 +6225,14 @@ var require_parser = __commonJS({
6186
6225
  async,
6187
6226
  generator,
6188
6227
  block,
6228
+ signature: {
6229
+ name: void 0,
6230
+ modifier: {
6231
+ async: !!async,
6232
+ generator: !!generator
6233
+ },
6234
+ returnType: suffix
6235
+ },
6189
6236
  children: [
6190
6237
  async,
6191
6238
  { $loc: arrow.$loc, token: "function" },
@@ -7249,6 +7296,7 @@ var require_parser = __commonJS({
7249
7296
  type: "MethodSignature",
7250
7297
  children: $0,
7251
7298
  name: $1.token,
7299
+ modifier: {},
7252
7300
  returnType: void 0,
7253
7301
  parameters
7254
7302
  };
@@ -7266,6 +7314,7 @@ var require_parser = __commonJS({
7266
7314
  }
7267
7315
  if (optional)
7268
7316
  $0[3] = optional = { ...optional, ts: true };
7317
+ modifier = modifier || {};
7269
7318
  return {
7270
7319
  type: "MethodSignature",
7271
7320
  children: $0,
@@ -12370,6 +12419,8 @@ var require_parser = __commonJS({
12370
12419
  exports.ReturnValue = ReturnValue;
12371
12420
  exports.AfterReturnShorthand = AfterReturnShorthand;
12372
12421
  exports.Parameters = Parameters;
12422
+ exports.ShortArrowParameters = ShortArrowParameters;
12423
+ exports.ArrowParameters = ArrowParameters;
12373
12424
  exports.NonEmptyParameters = NonEmptyParameters;
12374
12425
  exports.FunctionRestParameter = FunctionRestParameter;
12375
12426
  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,11 @@ var require_parser = __commonJS({
4748
4743
  }
4749
4744
  return {
4750
4745
  type: "ArrowFunction",
4746
+ signature: {
4747
+ modifier: {
4748
+ async: !!async
4749
+ }
4750
+ },
4751
4751
  parameters,
4752
4752
  returnType: suffix,
4753
4753
  ts: false,
@@ -4823,6 +4823,11 @@ var require_parser = __commonJS({
4823
4823
  };
4824
4824
  return {
4825
4825
  type: "ArrowFunction",
4826
+ signature: {
4827
+ modifier: {
4828
+ children: []
4829
+ }
4830
+ },
4826
4831
  children: [ref, " => ", arrowBody],
4827
4832
  ref,
4828
4833
  body: [arrowBody],
@@ -5522,6 +5527,24 @@ var require_parser = __commonJS({
5522
5527
  function Parameters(ctx, state) {
5523
5528
  return $EVENT_C(ctx, state, "Parameters", Parameters$$);
5524
5529
  }
5530
+ var ShortArrowParameters$0 = ObjectBindingPattern;
5531
+ var ShortArrowParameters$1 = ArrayBindingPattern;
5532
+ var ShortArrowParameters$$ = [ShortArrowParameters$0, ShortArrowParameters$1];
5533
+ function ShortArrowParameters(ctx, state) {
5534
+ return $EVENT_C(ctx, state, "ShortArrowParameters", ShortArrowParameters$$);
5535
+ }
5536
+ var ArrowParameters$0 = $TS($S(ShortArrowParameters), function($skip, $loc, $0, $1) {
5537
+ return {
5538
+ type: "Parameters",
5539
+ children: ["(", $0, ")"],
5540
+ names: $0.names
5541
+ };
5542
+ });
5543
+ var ArrowParameters$1 = Parameters;
5544
+ var ArrowParameters$$ = [ArrowParameters$0, ArrowParameters$1];
5545
+ function ArrowParameters(ctx, state) {
5546
+ return $EVENT_C(ctx, state, "ArrowParameters", ArrowParameters$$);
5547
+ }
5525
5548
  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
5549
  var tp = $1;
5527
5550
  var open = $2;
@@ -5966,6 +5989,10 @@ var require_parser = __commonJS({
5966
5989
  ts: false,
5967
5990
  async,
5968
5991
  generator,
5992
+ modifier: {
5993
+ async: !async.length,
5994
+ generator: !generator.length
5995
+ },
5969
5996
  block: null,
5970
5997
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
5971
5998
  };
@@ -5980,6 +6007,7 @@ var require_parser = __commonJS({
5980
6007
  return {
5981
6008
  ...signature,
5982
6009
  type: "FunctionExpression",
6010
+ signature,
5983
6011
  ts: true
5984
6012
  };
5985
6013
  }
@@ -5992,6 +6020,7 @@ var require_parser = __commonJS({
5992
6020
  return {
5993
6021
  ...signature,
5994
6022
  type: "FunctionExpression",
6023
+ signature,
5995
6024
  children: [...signature.children, block],
5996
6025
  block
5997
6026
  };
@@ -6000,6 +6029,9 @@ var require_parser = __commonJS({
6000
6029
  const ref = makeRef("$"), body = [ref];
6001
6030
  return {
6002
6031
  type: "ArrowFunction",
6032
+ signature: {
6033
+ modifier: {}
6034
+ },
6003
6035
  children: [ref, " => ", body],
6004
6036
  ref,
6005
6037
  body,
@@ -6011,7 +6043,6 @@ var require_parser = __commonJS({
6011
6043
  var id = $1;
6012
6044
  var ws = $4;
6013
6045
  var fn = $5;
6014
- debugger;
6015
6046
  return {
6016
6047
  ...fn,
6017
6048
  id,
@@ -6048,11 +6079,17 @@ var require_parser = __commonJS({
6048
6079
  };
6049
6080
  }
6050
6081
  const children = [ref, " => ", body];
6051
- if (hasAwait(body)) {
6082
+ const async = hasAwait(body);
6083
+ if (async) {
6052
6084
  children.unshift("async ");
6053
6085
  }
6054
6086
  return {
6055
6087
  type: "ArrowFunction",
6088
+ signature: {
6089
+ modifier: {
6090
+ async
6091
+ }
6092
+ },
6056
6093
  children,
6057
6094
  ref,
6058
6095
  body,
@@ -6076,6 +6113,7 @@ var require_parser = __commonJS({
6076
6113
  return {
6077
6114
  ...signature,
6078
6115
  type: "FunctionExpression",
6116
+ signature,
6079
6117
  children: [...signature.children, block],
6080
6118
  block,
6081
6119
  operator: true
@@ -6110,6 +6148,7 @@ var require_parser = __commonJS({
6110
6148
  return {
6111
6149
  type: "FunctionSignature",
6112
6150
  id,
6151
+ modifier: {},
6113
6152
  parameters,
6114
6153
  returnType: suffix,
6115
6154
  ts: false,
@@ -6162,7 +6201,7 @@ var require_parser = __commonJS({
6162
6201
  function AmpersandUnaryPrefix(ctx, state) {
6163
6202
  return $EVENT(ctx, state, "AmpersandUnaryPrefix", AmpersandUnaryPrefix$0);
6164
6203
  }
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) {
6204
+ 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
6205
  var async = $1;
6167
6206
  var parameters = $2;
6168
6207
  var suffix = $3;
@@ -6184,6 +6223,14 @@ var require_parser = __commonJS({
6184
6223
  async,
6185
6224
  generator,
6186
6225
  block,
6226
+ signature: {
6227
+ name: void 0,
6228
+ modifier: {
6229
+ async: !!async,
6230
+ generator: !!generator
6231
+ },
6232
+ returnType: suffix
6233
+ },
6187
6234
  children: [
6188
6235
  async,
6189
6236
  { $loc: arrow.$loc, token: "function" },
@@ -7247,6 +7294,7 @@ var require_parser = __commonJS({
7247
7294
  type: "MethodSignature",
7248
7295
  children: $0,
7249
7296
  name: $1.token,
7297
+ modifier: {},
7250
7298
  returnType: void 0,
7251
7299
  parameters
7252
7300
  };
@@ -7264,6 +7312,7 @@ var require_parser = __commonJS({
7264
7312
  }
7265
7313
  if (optional)
7266
7314
  $0[3] = optional = { ...optional, ts: true };
7315
+ modifier = modifier || {};
7267
7316
  return {
7268
7317
  type: "MethodSignature",
7269
7318
  children: $0,
@@ -12368,6 +12417,8 @@ var require_parser = __commonJS({
12368
12417
  exports.ReturnValue = ReturnValue;
12369
12418
  exports.AfterReturnShorthand = AfterReturnShorthand;
12370
12419
  exports.Parameters = Parameters;
12420
+ exports.ShortArrowParameters = ShortArrowParameters;
12421
+ exports.ArrowParameters = ArrowParameters;
12371
12422
  exports.NonEmptyParameters = NonEmptyParameters;
12372
12423
  exports.FunctionRestParameter = FunctionRestParameter;
12373
12424
  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.30",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",