@danielx/civet 0.11.2 → 0.11.3

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
@@ -2912,20 +2912,7 @@ function wrapTypeInApplication(t, id, raw) {
2912
2912
  }
2913
2913
  function implicitFunctionBlock(f) {
2914
2914
  if (f.abstract || f.block || f.signature?.optional) return;
2915
- const { name, parent } = f;
2916
- let ancestor = parent;
2917
- let child = f;
2918
- if (ancestor?.type === "ExportDeclaration") {
2919
- child = ancestor;
2920
- ancestor = ancestor.parent;
2921
- }
2922
- const expressions = ancestor?.expressions ?? ancestor?.elements;
2923
- const currentIndex = expressions?.findIndex(([, def]) => def === child);
2924
- let following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
2925
- if (following?.type === "ExportDeclaration") {
2926
- following = following.declaration;
2927
- }
2928
- if (f.type === following?.type && name != null && name === following.name) {
2915
+ if (followingOverloads(f).length) {
2929
2916
  f.ts = true;
2930
2917
  } else {
2931
2918
  const block = makeEmptyBlock();
@@ -2935,6 +2922,66 @@ function implicitFunctionBlock(f) {
2935
2922
  f.ts = false;
2936
2923
  }
2937
2924
  }
2925
+ function overloadsInDirection(f, direction) {
2926
+ if (!(f.name != null)) {
2927
+ return [];
2928
+ }
2929
+ let ancestor = f.parent;
2930
+ let child = f;
2931
+ if (ancestor?.type === "ExportDeclaration") {
2932
+ child = ancestor;
2933
+ ancestor = ancestor.parent;
2934
+ }
2935
+ if (!(ancestor?.type === "BlockStatement")) {
2936
+ return [];
2937
+ }
2938
+ const { expressions } = ancestor;
2939
+ let index = findChildIndex(expressions, child);
2940
+ if (!(index >= 0)) {
2941
+ return [];
2942
+ }
2943
+ if (direction < 0) {
2944
+ const results1 = [];
2945
+ while (--index >= 0) {
2946
+ let candidate = expressions[index][1];
2947
+ if (!candidate) {
2948
+ break;
2949
+ }
2950
+ if (candidate.type === "ExportDeclaration") {
2951
+ candidate = candidate.declaration;
2952
+ }
2953
+ if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
2954
+ break;
2955
+ }
2956
+ results1.push(candidate);
2957
+ }
2958
+ ;
2959
+ return results1;
2960
+ } else {
2961
+ const results2 = [];
2962
+ while (++index < expressions.length) {
2963
+ let candidate = expressions[index][1];
2964
+ if (!candidate) {
2965
+ break;
2966
+ }
2967
+ if (candidate.type === "ExportDeclaration") {
2968
+ candidate = candidate.declaration;
2969
+ }
2970
+ if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
2971
+ break;
2972
+ }
2973
+ results2.push(candidate);
2974
+ }
2975
+ ;
2976
+ return results2;
2977
+ }
2978
+ }
2979
+ function precedingOverloads(f) {
2980
+ return overloadsInDirection(f, -1);
2981
+ }
2982
+ function followingOverloads(f) {
2983
+ return overloadsInDirection(f, 1);
2984
+ }
2938
2985
  function processReturn(f, implicitReturns) {
2939
2986
  let { returnType } = f.signature;
2940
2987
  if (returnType && returnType.optional) {
@@ -3968,10 +4015,7 @@ function processParams(f) {
3968
4015
  const classExpressions = ancestor.body.expressions;
3969
4016
  let index2 = findChildIndex(classExpressions, f);
3970
4017
  assert.notEqual(index2, -1, "Could not find constructor in class");
3971
- let m7;
3972
- while (m7 = classExpressions[index2 - 1]?.[1], typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "MethodDefinition" && "name" in m7 && m7.name === "constructor") {
3973
- index2--;
3974
- }
4018
+ index2 -= precedingOverloads(f).length;
3975
4019
  const fStatement = classExpressions[index2];
3976
4020
  for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i10 = 0, len9 = ref20.length; i10 < len9; i10++) {
3977
4021
  const parameter = ref20[i10];
@@ -4066,10 +4110,11 @@ function findSuperCall(block) {
4066
4110
  }
4067
4111
  function processSignature(f) {
4068
4112
  const { block, signature } = f;
4113
+ let addAsync = false;
4114
+ let addGenerator = false;
4069
4115
  if (!f.async?.length && hasAwait(block)) {
4070
4116
  if (f.async != null) {
4071
- f.async.push("async ");
4072
- signature.modifier.async = true;
4117
+ addAsync = true;
4073
4118
  } else {
4074
4119
  for (let ref23 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i13 = 0, len12 = ref23.length; i13 < len12; i13++) {
4075
4120
  const a = ref23[i13];
@@ -4083,8 +4128,7 @@ function processSignature(f) {
4083
4128
  }
4084
4129
  if (!f.generator?.length && hasYield(block)) {
4085
4130
  if (f.generator != null) {
4086
- f.generator.push("*");
4087
- signature.modifier.generator = true;
4131
+ addGenerator = true;
4088
4132
  } else {
4089
4133
  for (let ref24 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i14 = 0, len13 = ref24.length; i14 < len13; i14++) {
4090
4134
  const y = ref24[i14];
@@ -4096,17 +4140,28 @@ function processSignature(f) {
4096
4140
  }
4097
4141
  }
4098
4142
  }
4099
- if (signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t)) {
4100
- replaceNode(
4101
- signature.returnType.t,
4102
- wrapTypeInPromise(signature.returnType.t),
4103
- signature.returnType
4104
- );
4143
+ for (let ref25 = [f, ...precedingOverloads(f)], i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
4144
+ const overload = ref25[i15];
4145
+ if (addAsync && overload.async != null && !overload.async.length) {
4146
+ overload.async.push("async ");
4147
+ overload.signature.modifier.async = true;
4148
+ }
4149
+ if (addGenerator && overload.generator != null && !overload.generator.length) {
4150
+ overload.generator.push("*");
4151
+ overload.signature.modifier.generator = true;
4152
+ }
4153
+ if (overload.signature.modifier.async && !overload.signature.modifier.generator && overload.signature.returnType && !isPromiseType(overload.signature.returnType.t)) {
4154
+ replaceNode(
4155
+ overload.signature.returnType.t,
4156
+ wrapTypeInPromise(overload.signature.returnType.t),
4157
+ overload.signature.returnType
4158
+ );
4159
+ }
4105
4160
  }
4106
4161
  }
4107
4162
  function processFunctions(statements, config2) {
4108
- for (let ref25 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
4109
- const f = ref25[i15];
4163
+ for (let ref26 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i16 = 0, len15 = ref26.length; i16 < len15; i16++) {
4164
+ const f = ref26[i16];
4110
4165
  if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
4111
4166
  implicitFunctionBlock(f);
4112
4167
  }
@@ -4165,9 +4220,9 @@ function expressionizeIteration(exp) {
4165
4220
  }
4166
4221
  let done;
4167
4222
  if (!async) {
4168
- let ref26;
4169
- if ((ref26 = blockContainingStatement(exp)) && typeof ref26 === "object" && "block" in ref26 && "index" in ref26) {
4170
- const { block: parentBlock, index } = ref26;
4223
+ let ref27;
4224
+ if ((ref27 = blockContainingStatement(exp)) && typeof ref27 === "object" && "block" in ref27 && "index" in ref27) {
4225
+ const { block: parentBlock, index } = ref27;
4171
4226
  statements[0][0] = parentBlock.expressions[index][0];
4172
4227
  parentBlock.expressions.splice(index, index + 1 - index, ...statements);
4173
4228
  updateParentPointers(parentBlock);
@@ -4184,8 +4239,8 @@ function expressionizeIteration(exp) {
4184
4239
  }
4185
4240
  }
4186
4241
  function processIterationExpressions(statements) {
4187
- for (let ref27 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i16 = 0, len15 = ref27.length; i16 < len15; i16++) {
4188
- const s = ref27[i16];
4242
+ for (let ref28 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i17 = 0, len16 = ref28.length; i17 < len16; i17++) {
4243
+ const s = ref28[i17];
4189
4244
  expressionizeIteration(s);
4190
4245
  }
4191
4246
  }
@@ -4208,13 +4263,13 @@ function processCoffeeDo(ws, expression) {
4208
4263
  if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
4209
4264
  let { parameters } = expression;
4210
4265
  const parameterList = parameters.parameters;
4211
- const results1 = [];
4212
- for (let i17 = 0, len16 = parameterList.length; i17 < len16; i17++) {
4213
- let parameter = parameterList[i17];
4266
+ const results3 = [];
4267
+ for (let i18 = 0, len17 = parameterList.length; i18 < len17; i18++) {
4268
+ let parameter = parameterList[i18];
4214
4269
  if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
4215
- let ref28;
4216
- if (ref28 = parameter.initializer) {
4217
- const initializer = ref28;
4270
+ let ref29;
4271
+ if (ref29 = parameter.initializer) {
4272
+ const initializer = ref29;
4218
4273
  args.push(initializer.expression, parameter.delim);
4219
4274
  parameter = {
4220
4275
  ...parameter,
@@ -4227,10 +4282,10 @@ function processCoffeeDo(ws, expression) {
4227
4282
  ));
4228
4283
  }
4229
4284
  }
4230
- results1.push(parameter);
4285
+ results3.push(parameter);
4231
4286
  }
4232
4287
  ;
4233
- const newParameterList = results1;
4288
+ const newParameterList = results3;
4234
4289
  const newParameters = {
4235
4290
  ...parameters,
4236
4291
  parameters: newParameterList,
@@ -9166,12 +9221,16 @@ var grammar = {
9166
9221
  CommaDelimiter,
9167
9222
  OptionalCommaDelimiter,
9168
9223
  ArgumentList,
9224
+ PostfixedArgumentList,
9169
9225
  NestedArguments,
9170
9226
  NestedArgumentList,
9171
9227
  NestedArgument,
9172
9228
  SingleLineArgumentExpressions,
9173
9229
  WArgumentPart,
9230
+ SingleLinePostfixedArgumentExpressions,
9231
+ WPostfixedArgumentPart,
9174
9232
  ArgumentPart,
9233
+ PostfixedArgumentPart,
9175
9234
  BinaryOpExpression,
9176
9235
  BinaryOpNotDedented,
9177
9236
  BinaryOpRHS,
@@ -9554,6 +9613,7 @@ var grammar = {
9554
9613
  Debugger,
9555
9614
  MaybeNestedNonPipelineExpression,
9556
9615
  MaybeNestedPostfixedExpression,
9616
+ MaybeNestedPostfixedCommaExpression,
9557
9617
  NestedPostfixedExpressionNoTrailing,
9558
9618
  MaybeNestedExpression,
9559
9619
  MaybeParenNestedExpression,
@@ -10569,7 +10629,7 @@ var ImplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(ApplicationSt
10569
10629
  function ImplicitArguments(ctx, state2) {
10570
10630
  return (0, import_lib2.$EVENT)(ctx, state2, "ImplicitArguments", ImplicitArguments$0);
10571
10631
  }
10572
- var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(ArgumentList, (0, import_lib2.$E)((0, import_lib2.$S)(__, Comma)))), __, RestoreAll, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10632
+ var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(PostfixedArgumentList, (0, import_lib2.$E)((0, import_lib2.$S)(__, Comma)))), __, RestoreAll, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10573
10633
  var open = $1;
10574
10634
  var args = $3;
10575
10635
  var ws = $4;
@@ -10707,6 +10767,35 @@ var ArgumentList$$ = [ArgumentList$0, ArgumentList$1, ArgumentList$2];
10707
10767
  function ArgumentList(ctx, state2) {
10708
10768
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentList", ArgumentList$$);
10709
10769
  }
10770
+ var PostfixedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$N)(EOS), (0, import_lib2.$E)(_), PostfixedArgumentPart)), (0, import_lib2.$S)(CommaDelimiter, NestedArguments), (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10771
+ return [
10772
+ $2,
10773
+ ...$3.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
10774
+ ...Array.isArray($4[1]) ? [$4[0], ...$4[1]] : $4,
10775
+ ...$5.flatMap(
10776
+ ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
10777
+ )
10778
+ ];
10779
+ });
10780
+ var PostfixedArgumentList$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(NestedArguments, (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2) {
10781
+ if (!Array.isArray($1)) $1 = [$1];
10782
+ return [
10783
+ ...trimFirstSpace($1),
10784
+ ...$2.flatMap(
10785
+ ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
10786
+ )
10787
+ ];
10788
+ });
10789
+ var PostfixedArgumentList$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$E)(_), PostfixedArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
10790
+ return [
10791
+ prepend($1, $2),
10792
+ ...$3.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
10793
+ ];
10794
+ });
10795
+ var PostfixedArgumentList$$ = [PostfixedArgumentList$0, PostfixedArgumentList$1, PostfixedArgumentList$2];
10796
+ function PostfixedArgumentList(ctx, state2) {
10797
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentList", PostfixedArgumentList$$);
10798
+ }
10710
10799
  var NestedArguments$0 = NestedBulletedArray;
10711
10800
  var NestedArguments$1 = NestedImplicitObjectLiteral;
10712
10801
  var NestedArguments$2 = NestedArgumentList;
@@ -10722,7 +10811,7 @@ var NestedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent,
10722
10811
  function NestedArgumentList(ctx, state2) {
10723
10812
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedArgumentList", NestedArgumentList$0);
10724
10813
  }
10725
- var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet), SingleLineArgumentExpressions, ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10814
+ var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet), SingleLinePostfixedArgumentExpressions, ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10726
10815
  var indent = $2;
10727
10816
  var args = $4;
10728
10817
  var comma = $5;
@@ -10745,6 +10834,18 @@ var WArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$
10745
10834
  function WArgumentPart(ctx, state2) {
10746
10835
  return (0, import_lib2.$EVENT)(ctx, state2, "WArgumentPart", WArgumentPart$0);
10747
10836
  }
10837
+ var SingleLinePostfixedArgumentExpressions$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(WPostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)((0, import_lib2.$S)((0, import_lib2.$E)(_), Comma), WPostfixedArgumentPart))), function($skip, $loc, $0, $1, $2) {
10838
+ return [$1, ...$2.flat()];
10839
+ });
10840
+ function SingleLinePostfixedArgumentExpressions(ctx, state2) {
10841
+ return (0, import_lib2.$EVENT)(ctx, state2, "SingleLinePostfixedArgumentExpressions", SingleLinePostfixedArgumentExpressions$0);
10842
+ }
10843
+ var WPostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart), function($skip, $loc, $0, $1, $2) {
10844
+ return prepend($1, $2);
10845
+ });
10846
+ function WPostfixedArgumentPart(ctx, state2) {
10847
+ return (0, import_lib2.$EVENT)(ctx, state2, "WPostfixedArgumentPart", WPostfixedArgumentPart$0);
10848
+ }
10748
10849
  var ArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, Expression), function($skip, $loc, $0, $1, $2) {
10749
10850
  var spread = $1;
10750
10851
  var expression = $2;
@@ -10769,6 +10870,30 @@ var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
10769
10870
  function ArgumentPart(ctx, state2) {
10770
10871
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentPart", ArgumentPart$$);
10771
10872
  }
10873
+ var PostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, PostfixedExpression), function($skip, $loc, $0, $1, $2) {
10874
+ var spread = $1;
10875
+ var expression = $2;
10876
+ return {
10877
+ type: "Argument",
10878
+ children: $0,
10879
+ expression,
10880
+ spread
10881
+ };
10882
+ });
10883
+ var PostfixedArgumentPart$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PostfixedExpression, (0, import_lib2.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
10884
+ var expression = $1;
10885
+ var spread = $2;
10886
+ return {
10887
+ type: "Argument",
10888
+ children: spread ? [spread, expression] : [expression],
10889
+ expression,
10890
+ spread
10891
+ };
10892
+ });
10893
+ var PostfixedArgumentPart$$ = [PostfixedArgumentPart$0, PostfixedArgumentPart$1];
10894
+ function PostfixedArgumentPart(ctx, state2) {
10895
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentPart", PostfixedArgumentPart$$);
10896
+ }
10772
10897
  var BinaryOpExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(UnaryExpression, (0, import_lib2.$Q)(BinaryOpRHS)), function($skip, $loc, $0, $1, $2) {
10773
10898
  if (!$2.length) return $1;
10774
10899
  return processBinaryOpExpression($0);
@@ -10801,10 +10926,13 @@ var BinaryOpRHS$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(BinaryOp, RHS), fun
10801
10926
  var BinaryOpRHS$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
10802
10927
  var op = $2;
10803
10928
  var rhs = $3;
10929
+ if (op[1].token === ">" && op[0].length === 0) return $skip;
10804
10930
  return [...op, ...rhs];
10805
10931
  });
10806
- var BinaryOpRHS$3 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
10807
- return value[1];
10932
+ var BinaryOpRHS$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function($skip, $loc, $0, $1, $2) {
10933
+ const [ws1, op] = $2;
10934
+ if (op.token === ">" && !ws1.length) return $skip;
10935
+ return $2;
10808
10936
  });
10809
10937
  var BinaryOpRHS$$ = [BinaryOpRHS$0, BinaryOpRHS$1, BinaryOpRHS$2, BinaryOpRHS$3];
10810
10938
  function BinaryOpRHS(ctx, state2) {
@@ -11759,7 +11887,7 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
11759
11887
  };
11760
11888
  }
11761
11889
  });
11762
- var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11890
+ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11763
11891
  var readonly = $1;
11764
11892
  var id = $2;
11765
11893
  var typeSuffix = $3;
@@ -15527,26 +15655,37 @@ var PostfixedNoCommaStatement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(NoCom
15527
15655
  function PostfixedNoCommaStatement(ctx, state2) {
15528
15656
  return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedNoCommaStatement", PostfixedNoCommaStatement$0);
15529
15657
  }
15530
- var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
15658
+ var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(AssignmentExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
15659
+ var expression = $1;
15660
+ var ws = $2;
15661
+ var post = $4;
15662
+ return attachPostfixStatementAsExpression(expression, [ws, post]);
15663
+ });
15664
+ var PostfixedExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
15531
15665
  var expression = $1;
15532
15666
  var post = $2;
15533
- if (post) return attachPostfixStatementAsExpression(expression, post);
15534
- return expression;
15667
+ return attachPostfixStatementAsExpression(expression, post);
15535
15668
  });
15669
+ var PostfixedExpression$2 = Expression;
15670
+ var PostfixedExpression$$ = [PostfixedExpression$0, PostfixedExpression$1, PostfixedExpression$2];
15536
15671
  function PostfixedExpression(ctx, state2) {
15537
- return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedExpression", PostfixedExpression$0);
15672
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedExpression", PostfixedExpression$$);
15538
15673
  }
15539
- var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(PostfixedExpression, (0, import_lib2.$C)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement), (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, AssignmentExpression)))), function($skip, $loc, $0, $1, $2) {
15674
+ var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CommaExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
15675
+ var expression = $1;
15676
+ var ws = $2;
15677
+ var post = $4;
15678
+ return attachPostfixStatementAsExpression(expression, [ws, post]);
15679
+ });
15680
+ var PostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
15540
15681
  var expression = $1;
15541
15682
  var post = $2;
15542
- if (!post.length) return $1;
15543
- if (post.length === 2 && !Array.isArray(post[1])) {
15544
- return attachPostfixStatementAsExpression(expression, post);
15545
- }
15546
- return $0;
15683
+ return attachPostfixStatementAsExpression(expression, post);
15547
15684
  });
15685
+ var PostfixedCommaExpression$2 = CommaExpression;
15686
+ var PostfixedCommaExpression$$ = [PostfixedCommaExpression$0, PostfixedCommaExpression$1, PostfixedCommaExpression$2];
15548
15687
  function PostfixedCommaExpression(ctx, state2) {
15549
- return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$0);
15688
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$$);
15550
15689
  }
15551
15690
  var PostfixStatement$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R31, "PostfixStatement /(?=for|if|loop|unless|until|while)/"), _PostfixStatement), function(value) {
15552
15691
  return value[1];
@@ -16998,6 +17137,22 @@ var MaybeNestedPostfixedExpression$$ = [MaybeNestedPostfixedExpression$0, MaybeN
16998
17137
  function MaybeNestedPostfixedExpression(ctx, state2) {
16999
17138
  return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedExpression", MaybeNestedPostfixedExpression$$);
17000
17139
  }
17140
+ var MaybeNestedPostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedBulletedArray), (0, import_lib2.$N)(NestedImplicitObjectLiteral), PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedCommaExpression)), PopIndent, (0, import_lib2.$E)(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17141
+ var expression = $4;
17142
+ var trailing = $6;
17143
+ if (!expression) return $skip;
17144
+ if (!trailing) return expression;
17145
+ return [expression, trailing];
17146
+ });
17147
+ var MaybeNestedPostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidImplicitFragment, (0, import_lib2.$E)(PostfixedCommaExpression), RestoreImplicitFragment), function($skip, $loc, $0, $1, $2, $3) {
17148
+ var expression = $2;
17149
+ if (!expression) return $skip;
17150
+ return expression;
17151
+ });
17152
+ var MaybeNestedPostfixedCommaExpression$$ = [MaybeNestedPostfixedCommaExpression$0, MaybeNestedPostfixedCommaExpression$1];
17153
+ function MaybeNestedPostfixedCommaExpression(ctx, state2) {
17154
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedCommaExpression", MaybeNestedPostfixedCommaExpression$$);
17155
+ }
17001
17156
  var NestedPostfixedExpressionNoTrailing$0 = NestedBulletedArray;
17002
17157
  var NestedPostfixedExpressionNoTrailing$1 = NestedImplicitObjectLiteral;
17003
17158
  var NestedPostfixedExpressionNoTrailing$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedExpression)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
@@ -17448,7 +17603,7 @@ var ExportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
17448
17603
  }
17449
17604
  ];
17450
17605
  });
17451
- var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration, MaybeNestedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17606
+ var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration, MaybeNestedPostfixedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17452
17607
  var declaration = $6;
17453
17608
  return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
17454
17609
  });
@@ -17571,7 +17726,7 @@ var LexicalDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConst,
17571
17726
  thisAssignments: bindings.flatMap((b) => b.thisAssignments)
17572
17727
  };
17573
17728
  });
17574
- var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment), MaybeNestedPostfixedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17729
+ var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment), MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17575
17730
  var loc = $1;
17576
17731
  var assign = $5;
17577
17732
  return processAssignmentDeclaration(
@@ -17637,7 +17792,7 @@ var LexicalBinding$$ = [LexicalBinding$0, LexicalBinding$1];
17637
17792
  function LexicalBinding(ctx, state2) {
17638
17793
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LexicalBinding", LexicalBinding$$);
17639
17794
  }
17640
- var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals, MaybeNestedExpression), function(value) {
17795
+ var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals, MaybeNestedPostfixedExpression), function(value) {
17641
17796
  var expression = value[2];
17642
17797
  return { "type": "Initializer", "expression": expression, "children": value };
17643
17798
  });
@@ -40,7 +40,180 @@ var import_config = require("@danielx/civet/config");
40
40
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
41
  var fs = __toESM(require("fs"));
42
42
  var import_path = __toESM(require("path"));
43
- var tsvfs = __toESM(require("@typescript/vfs"));
43
+
44
+ // node_modules/@typescript/vfs/dist/vfs.esm.js
45
+ function _extends() {
46
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
47
+ for (var i = 1; i < arguments.length; i++) {
48
+ var source = arguments[i];
49
+ for (var key in source) {
50
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
51
+ target[key] = source[key];
52
+ }
53
+ }
54
+ }
55
+ return target;
56
+ };
57
+ return _extends.apply(this, arguments);
58
+ }
59
+ var hasLocalStorage = false;
60
+ try {
61
+ hasLocalStorage = typeof localStorage !== "undefined";
62
+ } catch (error) {
63
+ }
64
+ var hasProcess = typeof process !== "undefined";
65
+ var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
66
+ var debugLog = shouldDebug ? console.log : function(_message) {
67
+ return "";
68
+ };
69
+ function notImplemented(methodName) {
70
+ throw new Error("Method '" + methodName + "' is not implemented.");
71
+ }
72
+ function audit(name, fn) {
73
+ return function() {
74
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
75
+ args[_key] = arguments[_key];
76
+ }
77
+ var res = fn.apply(void 0, args);
78
+ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;
79
+ debugLog.apply(void 0, ["> " + name].concat(args));
80
+ debugLog("< " + smallres);
81
+ return res;
82
+ };
83
+ }
84
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
85
+ return _extends({}, ts.getDefaultCompilerOptions(), {
86
+ jsx: ts.JsxEmit.React,
87
+ strict: true,
88
+ esModuleInterop: true,
89
+ module: ts.ModuleKind.ESNext,
90
+ suppressOutputPathCheck: true,
91
+ skipLibCheck: true,
92
+ skipDefaultLibCheck: true,
93
+ moduleResolution: ts.ModuleResolutionKind.NodeJs
94
+ });
95
+ };
96
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
97
+ var root = _projectRoot + "/vfs";
98
+ var path2 = requirePath();
99
+ var nodeSys = ts.sys;
100
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path2.dirname(require.resolve("typescript"));
101
+ return {
102
+ // @ts-ignore
103
+ name: "fs-vfs",
104
+ root,
105
+ args: [],
106
+ createDirectory: function createDirectory() {
107
+ return notImplemented("createDirectory");
108
+ },
109
+ // TODO: could make a real file tree
110
+ directoryExists: audit("directoryExists", function(directory) {
111
+ return Array.from(files.keys()).some(function(path3) {
112
+ return path3.startsWith(directory);
113
+ }) || nodeSys.directoryExists(directory);
114
+ }),
115
+ exit: nodeSys.exit,
116
+ fileExists: audit("fileExists", function(fileName) {
117
+ if (files.has(fileName)) return true;
118
+ if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
119
+ if (fileName.startsWith("/lib")) {
120
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
121
+ return nodeSys.fileExists(tsLibName);
122
+ }
123
+ return nodeSys.fileExists(fileName);
124
+ }),
125
+ getCurrentDirectory: function getCurrentDirectory() {
126
+ return root;
127
+ },
128
+ getDirectories: nodeSys.getDirectories,
129
+ getExecutingFilePath: function getExecutingFilePath() {
130
+ return notImplemented("getExecutingFilePath");
131
+ },
132
+ readDirectory: audit("readDirectory", function() {
133
+ if ((arguments.length <= 0 ? void 0 : arguments[0]) === "/") {
134
+ return Array.from(files.keys());
135
+ } else {
136
+ return nodeSys.readDirectory.apply(nodeSys, arguments);
137
+ }
138
+ }),
139
+ readFile: audit("readFile", function(fileName) {
140
+ if (files.has(fileName)) return files.get(fileName);
141
+ if (fileName.startsWith("/lib")) {
142
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
143
+ var result = nodeSys.readFile(tsLibName);
144
+ if (!result) {
145
+ var libs = nodeSys.readDirectory(tsLib);
146
+ throw new Error("TSVFS: A request was made for " + tsLibName + " but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: " + libs + ".");
147
+ }
148
+ return result;
149
+ }
150
+ return nodeSys.readFile(fileName);
151
+ }),
152
+ resolvePath: function resolvePath(path3) {
153
+ if (files.has(path3)) return path3;
154
+ return nodeSys.resolvePath(path3);
155
+ },
156
+ newLine: "\n",
157
+ useCaseSensitiveFileNames: true,
158
+ write: function write() {
159
+ return notImplemented("write");
160
+ },
161
+ writeFile: function writeFile(fileName, contents) {
162
+ files.set(fileName, contents);
163
+ },
164
+ deleteFile: function deleteFile(fileName) {
165
+ files["delete"](fileName);
166
+ },
167
+ realpath: nodeSys.realpath
168
+ };
169
+ }
170
+ function createVirtualCompilerHost(sys, compilerOptions, ts) {
171
+ var sourceFiles = /* @__PURE__ */ new Map();
172
+ var save = function save2(sourceFile) {
173
+ sourceFiles.set(sourceFile.fileName, sourceFile);
174
+ return sourceFile;
175
+ };
176
+ var vHost = {
177
+ compilerHost: _extends({}, sys, {
178
+ getCanonicalFileName: function getCanonicalFileName(fileName) {
179
+ return fileName;
180
+ },
181
+ getDefaultLibFileName: function getDefaultLibFileName() {
182
+ return "/" + ts.getDefaultLibFileName(compilerOptions);
183
+ },
184
+ // '/lib.d.ts',
185
+ // getDefaultLibLocation: () => '/',
186
+ getNewLine: function getNewLine() {
187
+ return sys.newLine;
188
+ },
189
+ getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
190
+ var _ref;
191
+ return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
192
+ },
193
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
194
+ return sys.useCaseSensitiveFileNames;
195
+ }
196
+ }),
197
+ updateFile: function updateFile(sourceFile) {
198
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
199
+ sys.writeFile(sourceFile.fileName, sourceFile.text);
200
+ sourceFiles.set(sourceFile.fileName, sourceFile);
201
+ return alreadyExists;
202
+ },
203
+ deleteFile: function deleteFile(sourceFile) {
204
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
205
+ sourceFiles["delete"](sourceFile.fileName);
206
+ sys.deleteFile(sourceFile.fileName);
207
+ return alreadyExists;
208
+ }
209
+ };
210
+ return vHost;
211
+ }
212
+ var requirePath = function requirePath2() {
213
+ return require(String.fromCharCode(112, 97, 116, 104));
214
+ };
215
+
216
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
44
217
  var import_os = __toESM(require("os"));
45
218
 
46
219
  // source/unplugin/constants.mjs
@@ -219,7 +392,7 @@ var rawPlugin = (options = {}, meta) => {
219
392
  async buildEnd(useConfigFileNames = false) {
220
393
  if (transformTS) {
221
394
  const ts2 = await tsPromise;
222
- const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts2);
395
+ const system = createFSBackedSystem(fsMap, process.cwd(), ts2);
223
396
  const {
224
397
  fileExists: systemFileExists,
225
398
  readFile: systemReadFile,
@@ -280,7 +453,7 @@ var rawPlugin = (options = {}, meta) => {
280
453
  sourceMaps.set(filename, sourceMap);
281
454
  return compiledTS;
282
455
  };
283
- const host = tsvfs.createVirtualCompilerHost(
456
+ const host = createVirtualCompilerHost(
284
457
  system,
285
458
  compilerOptions,
286
459
  ts2