@danielx/civet 0.8.5 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.mjs CHANGED
@@ -518,6 +518,7 @@ __export(lib_exports, {
518
518
  hasImportDeclaration: () => hasImportDeclaration,
519
519
  hasYield: () => hasYield,
520
520
  insertTrimmingSpace: () => insertTrimmingSpace,
521
+ isComma: () => isComma,
521
522
  isEmptyBareBlock: () => isEmptyBareBlock,
522
523
  isFunction: () => isFunction,
523
524
  isWhitespaceOrEmpty: () => isWhitespaceOrEmpty,
@@ -2300,11 +2301,21 @@ function serialize(value, context) {
2300
2301
  }
2301
2302
 
2302
2303
  // source/parser/function.civet
2304
+ function getTypeArguments(args) {
2305
+ while (typeof args === "object" && args != null && "args" in args) {
2306
+ args = args.args;
2307
+ }
2308
+ if (!Array.isArray(args)) {
2309
+ throw new Error("getTypeArguments could not find relevant array");
2310
+ }
2311
+ return args.filter((a) => typeof a === "object" && a != null && "type" in a && a.type === "TypeArgument");
2312
+ }
2303
2313
  function isVoidType(t) {
2304
- return t?.type === "TypeLiteral" && t.t.type === "VoidType";
2314
+ return typeof t === "object" && t != null && "type" in t && t.type === "TypeLiteral" && "t" in t && typeof t.t === "object" && t.t != null && "type" in t.t && t.t.type === "VoidType";
2305
2315
  }
2306
2316
  function isPromiseVoidType(t) {
2307
- return t?.type === "TypeIdentifier" && t.raw === "Promise" && t.args?.types?.length === 1 && isVoidType(t.args.types[0]);
2317
+ let args;
2318
+ return typeof t === "object" && t != null && "type" in t && t.type === "TypeIdentifier" && "raw" in t && t.raw === "Promise" && (args = getTypeArguments(t.args?.args)).length === 1 && isVoidType(args[0].t);
2308
2319
  }
2309
2320
  function implicitFunctionBlock(f) {
2310
2321
  if (f.abstract || f.block || f.signature?.optional)
@@ -2890,7 +2901,7 @@ function processParams(f) {
2890
2901
  if (isConstructor) {
2891
2902
  const { ancestor } = findAncestor(f, ($5) => $5.type === "ClassExpression");
2892
2903
  if (ancestor != null) {
2893
- const fields = new Set(gatherRecursiveWithinFunction(ancestor, ($6) => $6.type === "FieldDefinition").map(($7) => $7.id).filter((a) => typeof a === "object" && a != null && "type" in a && a.type === "Identifier").map(($8) => $8.name));
2904
+ const fields = new Set(gatherRecursiveWithinFunction(ancestor, ($6) => $6.type === "FieldDefinition").map(($7) => $7.id).filter((a1) => typeof a1 === "object" && a1 != null && "type" in a1 && a1.type === "Identifier").map(($8) => $8.name));
2894
2905
  const classExpressions = ancestor.body.expressions;
2895
2906
  let index = findChildIndex(classExpressions, f);
2896
2907
  assert.notEqual(index, -1, "Could not find constructor in class");
@@ -2942,10 +2953,10 @@ function processParams(f) {
2942
2953
  if (isConstructor) {
2943
2954
  const superCalls = gatherNodes(
2944
2955
  expressions,
2945
- (a1) => typeof a1 === "object" && a1 != null && "type" in a1 && a1.type === "CallExpression" && "children" in a1 && Array.isArray(a1.children) && a1.children.length >= 1 && typeof a1.children[0] === "object" && a1.children[0] != null && "token" in a1.children[0] && a1.children[0].token === "super"
2956
+ (a2) => typeof a2 === "object" && a2 != null && "type" in a2 && a2.type === "CallExpression" && "children" in a2 && Array.isArray(a2.children) && a2.children.length >= 1 && typeof a2.children[0] === "object" && a2.children[0] != null && "token" in a2.children[0] && a2.children[0].token === "super"
2946
2957
  );
2947
2958
  if (superCalls.length) {
2948
- const { child } = findAncestor(superCalls[0], (a2) => a2 === block);
2959
+ const { child } = findAncestor(superCalls[0], (a3) => a3 === block);
2949
2960
  const index = findChildIndex(expressions, child);
2950
2961
  if (index < 0) {
2951
2962
  throw new Error("Could not find super call within top-level expressions");
@@ -2955,6 +2966,7 @@ function processParams(f) {
2955
2966
  }
2956
2967
  }
2957
2968
  expressions.unshift(...prefix);
2969
+ braceBlock(block);
2958
2970
  }
2959
2971
  function processSignature(f) {
2960
2972
  const { block, signature } = f;
@@ -3077,11 +3089,11 @@ function processCoffeeDo(ws, expression) {
3077
3089
  parameter = {
3078
3090
  ...parameter,
3079
3091
  initializer: void 0,
3080
- children: parameter.children.filter((a3) => a3 !== initializer)
3092
+ children: parameter.children.filter((a4) => a4 !== initializer)
3081
3093
  };
3082
3094
  } else {
3083
3095
  args.push(parameter.children.filter(
3084
- (a4) => a4 !== parameter.typeSuffix
3096
+ (a5) => a5 !== parameter.typeSuffix
3085
3097
  ));
3086
3098
  }
3087
3099
  }
@@ -3154,7 +3166,7 @@ function makeAmpersandFunction(rhs) {
3154
3166
  }
3155
3167
  if (gatherRecursiveWithinFunction(
3156
3168
  block,
3157
- (a5) => a5 === ref
3169
+ (a6) => a6 === ref
3158
3170
  ).length > 1) {
3159
3171
  fn.ampersandBlock = false;
3160
3172
  }
@@ -7713,6 +7725,8 @@ var grammar = {
7713
7725
  NamedImports,
7714
7726
  OperatorNamedImports,
7715
7727
  FromClause,
7728
+ ImpliedFromClause,
7729
+ ImpliedFrom,
7716
7730
  ImportAssertion,
7717
7731
  TypeAndImportSpecifier,
7718
7732
  ImportSpecifier,
@@ -8049,6 +8063,7 @@ var grammar = {
8049
8063
  NestedTypeArgumentList,
8050
8064
  NestedTypeArgument,
8051
8065
  SingleLineTypeArgumentList,
8066
+ WTypeArgument,
8052
8067
  TypeArgumentDelimited,
8053
8068
  TypeArgument,
8054
8069
  TypeArgumentDelimiter,
@@ -8397,7 +8412,7 @@ var $R28 = (0, import_lib4.$R)(new RegExp("(?!\\+\\+|--)[!~+-](?!\\s)", "suy"));
8397
8412
  var $R29 = (0, import_lib4.$R)(new RegExp("[:.]", "suy"));
8398
8413
  var $R30 = (0, import_lib4.$R)(new RegExp("(?=for|if|loop|unless|until|while)", "suy"));
8399
8414
  var $R31 = (0, import_lib4.$R)(new RegExp("(?=loop|comptime|do|for|until|while)", "suy"));
8400
- var $R32 = (0, import_lib4.$R)(new RegExp('[^;"\\s]+', "suy"));
8415
+ var $R32 = (0, import_lib4.$R)(new RegExp('[^;"\\s=>]+', "suy"));
8401
8416
  var $R33 = (0, import_lib4.$R)(new RegExp("(?=[0-9.])", "suy"));
8402
8417
  var $R34 = (0, import_lib4.$R)(new RegExp("(?:0|[1-9](?:_[0-9]|[0-9])*)n", "suy"));
8403
8418
  var $R35 = (0, import_lib4.$R)(new RegExp("(?:0|[1-9](?:_[0-9]|[0-9])*)(?=\\.(?:\\p{ID_Start}|[_$]))", "suy"));
@@ -8910,10 +8925,10 @@ var RHS$$ = [RHS$0, RHS$1];
8910
8925
  function RHS(ctx, state2) {
8911
8926
  return (0, import_lib4.$EVENT_C)(ctx, state2, "RHS", RHS$$);
8912
8927
  }
8913
- var UnaryExpression$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(IndentedApplicationAllowed, (0, import_lib4.$P)(UnaryOp), (0, import_lib4.$C)(ArrayLiteral, NestedArgumentList), (0, import_lib4.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3, $4) {
8928
+ var UnaryExpression$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(IndentedApplicationAllowed, (0, import_lib4.$P)(UnaryOp), (0, import_lib4.$C)(ArrayLiteral, NestedArgumentList), (0, import_lib4.$N)(CallExpressionRest), (0, import_lib4.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
8914
8929
  var pre = $2;
8915
8930
  var args = $3;
8916
- var post = $4;
8931
+ var post = $5;
8917
8932
  return processUnaryNestedExpression(pre, args, post) ?? $skip;
8918
8933
  });
8919
8934
  var UnaryExpression$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$Q)(UnaryOp), UnaryBody, (0, import_lib4.$E)(UnaryPostfix)), function($skip, $loc, $0, $1, $2, $3) {
@@ -9906,14 +9921,22 @@ var CallExpression$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Super, Arguments
9906
9921
  var CallExpression$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(Import, _, NamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
9907
9922
  return dynamizeImportDeclarationExpression($0);
9908
9923
  });
9909
- var CallExpression$2 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$EXPECT)($L15, 'CallExpression "import"'), ArgumentsWithTrailingMemberExpressions, (0, import_lib4.$Q)(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
9924
+ var CallExpression$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(FromClause, __, Import, _, NamedImports), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
9925
+ var from = $1;
9926
+ var fws = $2;
9927
+ var i = $3;
9928
+ var iws = $4;
9929
+ var imports = $5;
9930
+ return dynamizeImportDeclarationExpression([i, iws, imports, fws, from]);
9931
+ });
9932
+ var CallExpression$3 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$EXPECT)($L15, 'CallExpression "import"'), ArgumentsWithTrailingMemberExpressions, (0, import_lib4.$Q)(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
9910
9933
  var rest = $3;
9911
9934
  return processCallMemberExpression({
9912
9935
  type: "CallExpression",
9913
9936
  children: [$1, ...$2, ...rest.flat()]
9914
9937
  });
9915
9938
  });
9916
- var CallExpression$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(MemberExpression, AllowedTrailingMemberExpressions, (0, import_lib4.$Q)(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
9939
+ var CallExpression$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(MemberExpression, AllowedTrailingMemberExpressions, (0, import_lib4.$Q)(CallExpressionRest)), function($skip, $loc, $0, $1, $2, $3) {
9917
9940
  var member = $1;
9918
9941
  var trailing = $2;
9919
9942
  var rest = $3;
@@ -9926,7 +9949,7 @@ var CallExpression$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(MemberExpression
9926
9949
  }
9927
9950
  return member;
9928
9951
  });
9929
- var CallExpression$$ = [CallExpression$0, CallExpression$1, CallExpression$2, CallExpression$3];
9952
+ var CallExpression$$ = [CallExpression$0, CallExpression$1, CallExpression$2, CallExpression$3, CallExpression$4];
9930
9953
  function CallExpression(ctx, state2) {
9931
9954
  return (0, import_lib4.$EVENT_C)(ctx, state2, "CallExpression", CallExpression$$);
9932
9955
  }
@@ -13956,9 +13979,12 @@ var ForBinding$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(
13956
13979
  function ForBinding(ctx, state2) {
13957
13980
  return (0, import_lib4.$EVENT)(ctx, state2, "ForBinding", ForBinding$0);
13958
13981
  }
13959
- var SwitchStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Switch, (0, import_lib4.$C)(EmptyCondition, Condition), CaseBlock), function($skip, $loc, $0, $1, $2, $3) {
13960
- var condition = $2;
13961
- var caseBlock = $3;
13982
+ var SwitchStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Switch, ForbidNewlineBinaryOp, (0, import_lib4.$E)((0, import_lib4.$C)(EmptyCondition, Condition)), RestoreNewlineBinaryOp, CaseBlock), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
13983
+ var s = $1;
13984
+ var condition = $3;
13985
+ var caseBlock = $5;
13986
+ if (!condition)
13987
+ return $skip;
13962
13988
  if (condition.type === "EmptyCondition") {
13963
13989
  caseBlock.clauses.forEach(({ cases }) => {
13964
13990
  if (cases) {
@@ -13978,7 +14004,8 @@ var SwitchStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Switch, (0, imp
13978
14004
  }
13979
14005
  return {
13980
14006
  type: "SwitchStatement",
13981
- children: $0,
14007
+ children: [s, condition, caseBlock],
14008
+ // omit NewlineBinaryOp control
13982
14009
  condition,
13983
14010
  caseBlock
13984
14011
  };
@@ -14346,8 +14373,8 @@ var SingleLineExpressionWithIndentedApplicationForbidden$0 = (0, import_lib4.$TS
14346
14373
  function SingleLineExpressionWithIndentedApplicationForbidden(ctx, state2) {
14347
14374
  return (0, import_lib4.$EVENT)(ctx, state2, "SingleLineExpressionWithIndentedApplicationForbidden", SingleLineExpressionWithIndentedApplicationForbidden$0);
14348
14375
  }
14349
- var ExpressionWithObjectApplicationForbidden$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForbidBracedApplication, ForbidIndentedApplication, ForbidNewlineBinaryOp, (0, import_lib4.$E)(Expression), RestoreNewlineBinaryOp, RestoreBracedApplication, RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14350
- var exp = $4;
14376
+ var ExpressionWithObjectApplicationForbidden$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(ForbidBracedApplication, ForbidIndentedApplication, (0, import_lib4.$E)(Expression), RestoreBracedApplication, RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14377
+ var exp = $3;
14351
14378
  if (exp)
14352
14379
  return exp;
14353
14380
  return $skip;
@@ -14736,36 +14763,41 @@ var ImportDeclaration$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Import, _, Id
14736
14763
  children: [imp, $0.slice(1)]
14737
14764
  };
14738
14765
  });
14739
- var ImportDeclaration$1 = (0, import_lib4.$T)((0, import_lib4.$S)(Import, __, TypeKeyword, __, ImportClause, __, FromClause), function(value) {
14740
- var imports = value[4];
14741
- var from = value[6];
14742
- return { "type": "ImportDeclaration", "ts": true, "children": value, "imports": imports, "from": from };
14743
- });
14744
- var ImportDeclaration$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(Import, __, Operator, (0, import_lib4.$E)(OperatorBehavior), __, OperatorNamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
14745
- var behavior = $4;
14746
- var imports = $6;
14747
- var from = $8;
14766
+ var ImportDeclaration$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)((0, import_lib4.$S)(Import, __), ImpliedImport), Operator, (0, import_lib4.$E)(OperatorBehavior), __, OperatorNamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14767
+ var i = $1;
14768
+ var behavior = $3;
14769
+ var ws1 = $4;
14770
+ var imports = $5;
14771
+ var ws2 = $6;
14772
+ var from = $7;
14748
14773
  imports.specifiers.forEach((spec) => {
14749
14774
  state.operators.set(spec.binding.name, spec.behavior ?? behavior);
14750
14775
  });
14751
14776
  return {
14752
14777
  type: "ImportDeclaration",
14753
- children: [$1, $2, trimFirstSpace($5), imports, $7, from],
14754
- // omit $3 = Operator and $4 = OperatorBehavior
14778
+ children: [i, trimFirstSpace(ws1), imports, ws2, from],
14779
+ // omit $2 = Operator and $3 = OperatorBehavior
14755
14780
  imports,
14756
14781
  from
14757
14782
  };
14758
14783
  });
14759
- var ImportDeclaration$3 = (0, import_lib4.$T)((0, import_lib4.$S)(Import, __, ImportClause, __, FromClause), function(value) {
14760
- var imports = value[2];
14761
- var from = value[4];
14762
- return { "type": "ImportDeclaration", "children": value, "imports": imports, "from": from };
14784
+ var ImportDeclaration$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(Import, __, (0, import_lib4.$E)((0, import_lib4.$S)(TypeKeyword, __)), ImportClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14785
+ var t = $3;
14786
+ var imports = $4;
14787
+ var from = $6;
14788
+ return {
14789
+ type: "ImportDeclaration",
14790
+ children: $0,
14791
+ imports,
14792
+ from,
14793
+ ts: !!t
14794
+ };
14763
14795
  });
14764
- var ImportDeclaration$4 = (0, import_lib4.$T)((0, import_lib4.$S)(Import, __, ModuleSpecifier), function(value) {
14796
+ var ImportDeclaration$3 = (0, import_lib4.$T)((0, import_lib4.$S)(Import, __, ModuleSpecifier), function(value) {
14765
14797
  var module = value[2];
14766
14798
  return { "type": "ImportDeclaration", "children": value, "module": module };
14767
14799
  });
14768
- var ImportDeclaration$5 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedImport, (0, import_lib4.$E)((0, import_lib4.$S)(TypeKeyword, __)), ImportClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14800
+ var ImportDeclaration$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedImport, (0, import_lib4.$E)((0, import_lib4.$S)(TypeKeyword, __)), ImportClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14769
14801
  var i = $1;
14770
14802
  var t = $2;
14771
14803
  var imports = $3;
@@ -14778,22 +14810,40 @@ var ImportDeclaration$5 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedImport
14778
14810
  const children = [i, t, imports, w, from];
14779
14811
  return { type: "ImportDeclaration", ts: !!t, children, imports, from };
14780
14812
  });
14781
- var ImportDeclaration$6 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedImport, Operator, (0, import_lib4.$E)(OperatorBehavior), __, OperatorNamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14782
- var i = $1;
14783
- var behavior = $3;
14784
- var imports = $5;
14785
- var from = $7;
14813
+ var ImportDeclaration$5 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedFromClause, __, Import, __, Operator, (0, import_lib4.$E)(OperatorBehavior), __, OperatorNamedImports), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
14814
+ var from = $1;
14815
+ var fws = $2;
14816
+ var i = $3;
14817
+ var iws = $4;
14818
+ var behavior = $6;
14819
+ var ows = $7;
14820
+ var imports = $8;
14786
14821
  imports.specifiers.forEach((spec) => {
14787
14822
  state.operators.set(spec.binding.name, spec.behavior ?? behavior);
14788
14823
  });
14789
14824
  return {
14790
14825
  type: "ImportDeclaration",
14791
- children: [$1, trimFirstSpace($4), imports, $6, from],
14792
- // omit $2 = Operator and $3 = OperatorBehavior
14826
+ children: [i, iws, trimFirstSpace(ows), imports, fws, from],
14827
+ // omit Operator and OperatorBehavior
14793
14828
  imports,
14794
14829
  from
14795
14830
  };
14796
14831
  });
14832
+ var ImportDeclaration$6 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedFromClause, __, Import, __, (0, import_lib4.$E)((0, import_lib4.$S)(TypeKeyword, __)), ImportClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14833
+ var from = $1;
14834
+ var fws = $2;
14835
+ var i = $3;
14836
+ var iws = $4;
14837
+ var t = $5;
14838
+ var imports = $6;
14839
+ return {
14840
+ type: "ImportDeclaration",
14841
+ children: [i, iws, t, imports, fws, from],
14842
+ imports,
14843
+ from,
14844
+ ts: !!t
14845
+ };
14846
+ });
14797
14847
  var ImportDeclaration$$ = [ImportDeclaration$0, ImportDeclaration$1, ImportDeclaration$2, ImportDeclaration$3, ImportDeclaration$4, ImportDeclaration$5, ImportDeclaration$6];
14798
14848
  function ImportDeclaration(ctx, state2) {
14799
14849
  return (0, import_lib4.$EVENT_C)(ctx, state2, "ImportDeclaration", ImportDeclaration$$);
@@ -14878,6 +14928,21 @@ var FromClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(From, __, ModuleSpec
14878
14928
  function FromClause(ctx, state2) {
14879
14929
  return (0, import_lib4.$EVENT)(ctx, state2, "FromClause", FromClause$0);
14880
14930
  }
14931
+ var ImpliedFromClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)((0, import_lib4.$S)(From, __), ImpliedFrom), ModuleSpecifier), function($skip, $loc, $0, $1, $2) {
14932
+ var module = $2;
14933
+ if (!Array.isArray(module))
14934
+ return $0;
14935
+ return [$1, ...module];
14936
+ });
14937
+ function ImpliedFromClause(ctx, state2) {
14938
+ return (0, import_lib4.$EVENT)(ctx, state2, "ImpliedFromClause", ImpliedFromClause$0);
14939
+ }
14940
+ var ImpliedFrom$0 = (0, import_lib4.$TV)((0, import_lib4.$EXPECT)($L0, 'ImpliedFrom ""'), function($skip, $loc, $0, $1) {
14941
+ return { $loc, token: "from " };
14942
+ });
14943
+ function ImpliedFrom(ctx, state2) {
14944
+ return (0, import_lib4.$EVENT)(ctx, state2, "ImpliedFrom", ImpliedFrom$0);
14945
+ }
14881
14946
  var ImportAssertion$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), (0, import_lib4.$C)((0, import_lib4.$EXPECT)($L124, 'ImportAssertion "with"'), (0, import_lib4.$EXPECT)($L125, 'ImportAssertion "assert"')), NonIdContinue, (0, import_lib4.$E)(_), ObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
14882
14947
  var keyword = $2;
14883
14948
  var object = $5;
@@ -15010,7 +15075,7 @@ var UnprocessedModuleSpecifier$$ = [UnprocessedModuleSpecifier$0, UnprocessedMod
15010
15075
  function UnprocessedModuleSpecifier(ctx, state2) {
15011
15076
  return (0, import_lib4.$EVENT_C)(ctx, state2, "UnprocessedModuleSpecifier", UnprocessedModuleSpecifier$$);
15012
15077
  }
15013
- var UnquotedSpecifier$0 = (0, import_lib4.$TV)((0, import_lib4.$EXPECT)($R32, 'UnquotedSpecifier /[^;"\\s]+/'), function($skip, $loc, $0, $1) {
15078
+ var UnquotedSpecifier$0 = (0, import_lib4.$TV)((0, import_lib4.$EXPECT)($R32, 'UnquotedSpecifier /[^;"\\s=>]+/'), function($skip, $loc, $0, $1) {
15014
15079
  var spec = $0;
15015
15080
  return { $loc, token: `"${spec}"` };
15016
15081
  });
@@ -15063,13 +15128,26 @@ var ExportDeclaration$2 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_li
15063
15128
  return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
15064
15129
  });
15065
15130
  var ExportDeclaration$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(Export, __, ExportFromClause, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
15066
- return { type: "ExportDeclaration", ts: $3.ts, children: $0 };
15131
+ var exports = $3;
15132
+ return { type: "ExportDeclaration", ts: exports.ts, children: $0 };
15133
+ });
15134
+ var ExportDeclaration$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(ImpliedFromClause, __, Export, __, ExportFromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
15135
+ var from = $1;
15136
+ var fws = $2;
15137
+ var e = $3;
15138
+ var ews = $4;
15139
+ var exports = $5;
15140
+ return {
15141
+ type: "ExportDeclaration",
15142
+ ts: exports.ts,
15143
+ children: [e, ews, exports, " ", from, trimFirstSpace(fws)]
15144
+ };
15067
15145
  });
15068
- var ExportDeclaration$4 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(Decorators), Export, __, (0, import_lib4.$C)(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
15146
+ var ExportDeclaration$5 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(Decorators), Export, __, (0, import_lib4.$C)(Declaration, VariableStatement, TypeAndNamedExports, ExportVarDec)), function($skip, $loc, $0, $1, $2, $3, $4) {
15069
15147
  var declaration = $4;
15070
15148
  return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
15071
15149
  });
15072
- var ExportDeclaration$$ = [ExportDeclaration$0, ExportDeclaration$1, ExportDeclaration$2, ExportDeclaration$3, ExportDeclaration$4];
15150
+ var ExportDeclaration$$ = [ExportDeclaration$0, ExportDeclaration$1, ExportDeclaration$2, ExportDeclaration$3, ExportDeclaration$4, ExportDeclaration$5];
15073
15151
  function ExportDeclaration(ctx, state2) {
15074
15152
  return (0, import_lib4.$EVENT_C)(ctx, state2, "ExportDeclaration", ExportDeclaration$$);
15075
15153
  }
@@ -18253,11 +18331,12 @@ function TypeArrowFunction(ctx, state2) {
18253
18331
  }
18254
18332
  var TypeArguments$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(OpenAngleBracket, (0, import_lib4.$P)((0, import_lib4.$S)(__, TypeArgumentDelimited)), __, CloseAngleBracket), function($skip, $loc, $0, $1, $2, $3, $4) {
18255
18333
  var args = $2;
18256
- args = args.map(([ws, arg]) => [ws, ...arg]);
18334
+ args = args.flatMap(([ws, [arg, delim]]) => [prepend(ws, arg), delim]);
18335
+ args.pop();
18257
18336
  return {
18258
18337
  type: "TypeArguments",
18259
18338
  ts: true,
18260
- types: args.map(([, t]) => t),
18339
+ args,
18261
18340
  children: $0
18262
18341
  };
18263
18342
  });
@@ -18269,10 +18348,15 @@ var ImplicitTypeArguments$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(TypeAppli
18269
18348
  var ws = $3;
18270
18349
  var args = $4;
18271
18350
  var close = $5;
18272
- let last = args[args.length - 1];
18273
- if (last?.token === ",")
18351
+ const last = args[args.length - 1];
18352
+ if (isComma(last))
18274
18353
  args = args.slice(0, -1);
18275
- return [open, ws, args, close];
18354
+ return {
18355
+ type: "TypeArguments",
18356
+ ts: true,
18357
+ args,
18358
+ children: [open, ws, args, close]
18359
+ };
18276
18360
  });
18277
18361
  function ImplicitTypeArguments(ctx, state2) {
18278
18362
  return (0, import_lib4.$EVENT)(ctx, state2, "ImplicitTypeArguments", ImplicitTypeArguments$0);
@@ -18290,10 +18374,10 @@ var ForbiddenImplicitTypeCalls$$ = [ForbiddenImplicitTypeCalls$0, ForbiddenImpli
18290
18374
  function ForbiddenImplicitTypeCalls(ctx, state2) {
18291
18375
  return (0, import_lib4.$EVENT_C)(ctx, state2, "ForbiddenImplicitTypeCalls", ForbiddenImplicitTypeCalls$$);
18292
18376
  }
18293
- var TypeArgumentList$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$N)(EOS), TypeArgument, (0, import_lib4.$Q)((0, import_lib4.$S)(CommaDelimiter, (0, import_lib4.$N)(EOS), (0, import_lib4.$E)(_), TypeArgument)), (0, import_lib4.$P)((0, import_lib4.$S)(CommaDelimiter, (0, import_lib4.$C)(NestedTypeBulletedTuple, NestedInterfaceBlock, NestedTypeArgumentList)))), function($skip, $loc, $0, $1, $2, $3, $4) {
18377
+ var TypeArgumentList$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$N)(EOS), TypeArgument, (0, import_lib4.$Q)((0, import_lib4.$S)(CommaDelimiter, (0, import_lib4.$N)(EOS), WTypeArgument)), (0, import_lib4.$P)((0, import_lib4.$S)(CommaDelimiter, (0, import_lib4.$C)(NestedTypeBulletedTuple, NestedInterfaceBlock, NestedTypeArgumentList)))), function($skip, $loc, $0, $1, $2, $3, $4) {
18294
18378
  return [
18295
18379
  $2,
18296
- ...$3.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
18380
+ ...$3.flatMap(([comma, eos, arg]) => [comma, arg]),
18297
18381
  ...$4.flatMap(
18298
18382
  ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
18299
18383
  )
@@ -18308,10 +18392,10 @@ var TypeArgumentList$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib
18308
18392
  ];
18309
18393
  });
18310
18394
  var TypeArgumentList$2 = NestedTypeArgumentList;
18311
- var TypeArgumentList$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(TypeArgument, (0, import_lib4.$Q)((0, import_lib4.$S)(CommaDelimiter, (0, import_lib4.$E)(_), TypeArgument))), function($skip, $loc, $0, $1, $2) {
18395
+ var TypeArgumentList$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(TypeArgument, (0, import_lib4.$Q)((0, import_lib4.$S)(CommaDelimiter, WTypeArgument))), function($skip, $loc, $0, $1, $2) {
18312
18396
  return [
18313
18397
  $1,
18314
- ...$2.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
18398
+ ...$2.flatMap(([comma, arg]) => [comma, arg])
18315
18399
  ];
18316
18400
  });
18317
18401
  var TypeArgumentList$$ = [TypeArgumentList$0, TypeArgumentList$1, TypeArgumentList$2, TypeArgumentList$3];
@@ -18338,17 +18422,25 @@ var NestedTypeArgument$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Nested, Sing
18338
18422
  function NestedTypeArgument(ctx, state2) {
18339
18423
  return (0, import_lib4.$EVENT)(ctx, state2, "NestedTypeArgument", NestedTypeArgument$0);
18340
18424
  }
18341
- var SingleLineTypeArgumentList$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$S)((0, import_lib4.$E)(_), TypeArgument), (0, import_lib4.$Q)((0, import_lib4.$S)((0, import_lib4.$S)((0, import_lib4.$E)(_), Comma), (0, import_lib4.$S)((0, import_lib4.$E)(_), TypeArgument)))), function($skip, $loc, $0, $1, $2) {
18342
- return [$1, ...$2.flat()];
18425
+ var SingleLineTypeArgumentList$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(WTypeArgument, (0, import_lib4.$Q)((0, import_lib4.$S)((0, import_lib4.$S)((0, import_lib4.$E)(_), Comma), WTypeArgument))), function($skip, $loc, $0, $1, $2) {
18426
+ return [$1, ...$2];
18343
18427
  });
18344
18428
  function SingleLineTypeArgumentList(ctx, state2) {
18345
18429
  return (0, import_lib4.$EVENT)(ctx, state2, "SingleLineTypeArgumentList", SingleLineTypeArgumentList$0);
18346
18430
  }
18431
+ var WTypeArgument$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), TypeArgument), function($skip, $loc, $0, $1, $2) {
18432
+ return prepend($1, $2);
18433
+ });
18434
+ function WTypeArgument(ctx, state2) {
18435
+ return (0, import_lib4.$EVENT)(ctx, state2, "WTypeArgument", WTypeArgument$0);
18436
+ }
18347
18437
  var TypeArgumentDelimited$0 = (0, import_lib4.$S)(TypeArgument, TypeArgumentDelimiter);
18348
18438
  function TypeArgumentDelimited(ctx, state2) {
18349
18439
  return (0, import_lib4.$EVENT)(ctx, state2, "TypeArgumentDelimited", TypeArgumentDelimited$0);
18350
18440
  }
18351
- var TypeArgument$0 = Type;
18441
+ var TypeArgument$0 = (0, import_lib4.$T)(Type, function(value) {
18442
+ return { "type": "TypeArgument", "ts": true, "t": value, "children": [value] };
18443
+ });
18352
18444
  function TypeArgument(ctx, state2) {
18353
18445
  return (0, import_lib4.$EVENT)(ctx, state2, "TypeArgument", TypeArgument$0);
18354
18446
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.8.5",
4
+ "version": "0.8.7",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -95,7 +95,7 @@
95
95
  "unplugin": "^1.12.2"
96
96
  },
97
97
  "devDependencies": {
98
- "@danielx/civet": "0.8.4",
98
+ "@danielx/civet": "0.8.5",
99
99
  "@danielx/hera": "^0.8.16",
100
100
  "@prettier/sync": "^0.5.2",
101
101
  "@types/assert": "^1.5.6",