@danielx/civet 0.11.12 → 0.11.13

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
@@ -3407,10 +3407,10 @@ function insertReturn(node) {
3407
3407
  }
3408
3408
  insertReturn(node.block);
3409
3409
  if (!isExit(node.block)) {
3410
- const comment = hasTrailingComment(node.block.expressions);
3410
+ const comment = node.block.trailing?.length || hasTrailingComment(node.block.expressions);
3411
3411
  let ref12;
3412
3412
  node.block.expressions.push([
3413
- comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
3413
+ comment ? (ref12 = node.block.expressions)[ref12.length - 1]?.[0] || "\n" : "",
3414
3414
  wrapWithReturn(void 0, node, !comment)
3415
3415
  ]);
3416
3416
  }
@@ -4050,6 +4050,53 @@ function processParams(f) {
4050
4050
  } else {
4051
4051
  indent = expressions[0][0];
4052
4052
  }
4053
+ const { ancestor: enclosingClass } = findAncestor(f, ($10) => $10.type === "ClassExpression");
4054
+ if (enclosingClass != null) {
4055
+ const fieldTypes = /* @__PURE__ */ new Map();
4056
+ for (let ref20 = gatherRecursiveWithinFunction(enclosingClass.body, ($11) => $11.type === "FieldDefinition"), i9 = 0, len8 = ref20.length; i9 < len8; i9++) {
4057
+ const { id, typeSuffix } = ref20[i9];
4058
+ if (typeSuffix != null && id?.type === "Identifier") {
4059
+ fieldTypes.set(id.name, typeSuffix);
4060
+ }
4061
+ }
4062
+ if (fieldTypes.size) {
4063
+ for (let ref21 = gatherRecursive(parameters, ($12) => $12.type === "Parameter"), i10 = 0, len9 = ref21.length; i10 < len9; i10++) {
4064
+ const parameter = ref21[i10];
4065
+ if (parameter.typeSuffix != null) {
4066
+ continue;
4067
+ }
4068
+ let inferredInPattern = false;
4069
+ for (let ref22 = gatherRecursive(parameter, ($13) => $13.type === "AtBinding"), i11 = 0, len10 = ref22.length; i11 < len10; i11++) {
4070
+ const binding = ref22[i11];
4071
+ const owner = binding.parent;
4072
+ assert(owner, "@-binding has no parent");
4073
+ const fieldType = fieldTypes.get(binding.ref.id);
4074
+ if (!(fieldType != null)) {
4075
+ continue;
4076
+ }
4077
+ owner.typeSuffix = deepCopy(fieldType);
4078
+ updateParentPointers(owner);
4079
+ if (owner === parameter) {
4080
+ const i = owner.children.indexOf(binding);
4081
+ assert.notEqual(i, -1, "@-binding missing from parameter children");
4082
+ owner.children[i + 1] = owner.typeSuffix;
4083
+ } else {
4084
+ inferredInPattern = true;
4085
+ }
4086
+ }
4087
+ if (inferredInPattern) {
4088
+ const pattern = parameter.binding;
4089
+ pattern.typeSuffix = void 0;
4090
+ gatherBindingPatternTypeSuffix(pattern);
4091
+ assert(pattern.typeSuffix, "expected aggregated binding pattern type");
4092
+ parameter.typeSuffix = pattern.typeSuffix;
4093
+ const i = parameter.children.indexOf(pattern);
4094
+ assert.notEqual(i, -1, "binding pattern missing from parameter children");
4095
+ parameter.children[i + 1] = parameter.typeSuffix;
4096
+ }
4097
+ }
4098
+ }
4099
+ }
4053
4100
  const [splices, thisAssignments] = gatherBindingCode(parameters, {
4054
4101
  injectParamProps: isConstructor,
4055
4102
  assignPins: true
@@ -4058,22 +4105,21 @@ function processParams(f) {
4058
4105
  simplifyBindingProperties(parameters.parameters);
4059
4106
  simplifyBindingProperties(subbindings);
4060
4107
  if (isConstructor) {
4061
- const { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
4062
- if (ancestor != null) {
4063
- const fields = new Set(gatherRecursiveWithinFunction(ancestor, ($11) => $11.type === "FieldDefinition").map(($12) => $12.id).filter(((a3) => typeof a3 === "object" && a3 != null && "type" in a3 && a3.type === "Identifier")).map(($13) => $13.name));
4064
- const classExpressions = ancestor.body.expressions;
4108
+ if (enclosingClass != null) {
4109
+ const fields = new Set(gatherRecursiveWithinFunction(enclosingClass, ($14) => $14.type === "FieldDefinition").map(($15) => $15.id).filter(((a3) => typeof a3 === "object" && a3 != null && "type" in a3 && a3.type === "Identifier")).map(($16) => $16.name));
4110
+ const classExpressions = enclosingClass.body.expressions;
4065
4111
  let index2 = findChildIndex(classExpressions, f);
4066
4112
  assert.notEqual(index2, -1, "Could not find constructor in class");
4067
4113
  index2 -= precedingOverloads(f).length;
4068
4114
  const fStatement = classExpressions[index2];
4069
- for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i9 = 0, len8 = ref20.length; i9 < len8; i9++) {
4070
- const parameter = ref20[i9];
4115
+ for (let ref23 = gatherRecursive(parameters, ($17) => $17.type === "Parameter"), i12 = 0, len11 = ref23.length; i12 < len11; i12++) {
4116
+ const parameter = ref23[i12];
4071
4117
  const { accessModifier } = parameter;
4072
4118
  if (!(accessModifier || parameter.typeSuffix)) {
4073
4119
  continue;
4074
4120
  }
4075
- for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i10 = 0, len9 = ref21.length; i10 < len9; i10++) {
4076
- const binding = ref21[i10];
4121
+ for (let ref24 = gatherRecursive(parameter, ($18) => $18.type === "AtBinding"), i13 = 0, len12 = ref24.length; i13 < len12; i13++) {
4122
+ const binding = ref24[i13];
4077
4123
  const typeSuffix = binding.parent?.typeSuffix;
4078
4124
  if (!(accessModifier || typeSuffix)) {
4079
4125
  continue;
@@ -4111,8 +4157,8 @@ function processParams(f) {
4111
4157
  decl: "const"
4112
4158
  }));
4113
4159
  }
4114
- for (let ref22 = splices, i11 = 0, len10 = ref22.length; i11 < len10; i11++) {
4115
- const binding = ref22[i11];
4160
+ for (let ref25 = splices, i14 = 0, len13 = ref25.length; i14 < len13; i14++) {
4161
+ const binding = ref25[i14];
4116
4162
  assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
4117
4163
  prefix.push(makeNode({
4118
4164
  type: "Declaration",
@@ -4155,6 +4201,43 @@ function findSuperCall(block) {
4155
4201
  return -1;
4156
4202
  }
4157
4203
  }
4204
+ function transformArrowFunctionWithYield(f) {
4205
+ const { block, parameters, returnType, async, signature } = f;
4206
+ if (block?.type === "BlockStatement" && block.implicitlyReturned) {
4207
+ insertReturn(block);
4208
+ block.implicitlyReturned = false;
4209
+ }
4210
+ if (block?.type === "BlockStatement" && block.bare && !block.root) {
4211
+ block.children.unshift(" {");
4212
+ block.children.push("}");
4213
+ block.bare = false;
4214
+ }
4215
+ const generator = ["*"];
4216
+ signature.modifier ??= {};
4217
+ signature.modifier.generator = true;
4218
+ signature.generator = generator;
4219
+ signature.children = [async, "function", generator, parameters, returnType];
4220
+ f.type = "FunctionExpression";
4221
+ f.generator = generator;
4222
+ f.children = [async, "function", generator, parameters, returnType, block];
4223
+ const originalParent = f.parent;
4224
+ const lhs = makeLeftHandSideExpression(f);
4225
+ let ref26;
4226
+ if (gatherRecursiveWithinFunction(block, ((a6) => typeof a6 === "object" && a6 != null && "token" in a6 && a6.token === "this")).length) {
4227
+ ref26 = makeNode({
4228
+ type: "CallExpression",
4229
+ children: [lhs, ".bind(this)"]
4230
+ });
4231
+ } else {
4232
+ ref26 = lhs;
4233
+ }
4234
+ ;
4235
+ const newNode = ref26;
4236
+ if (newNode !== f && originalParent != null) {
4237
+ replaceNode(f, newNode, originalParent);
4238
+ updateParentPointers(newNode, originalParent);
4239
+ }
4240
+ }
4158
4241
  function processSignature(f) {
4159
4242
  const { block, signature } = f;
4160
4243
  let addAsync = false;
@@ -4163,8 +4246,8 @@ function processSignature(f) {
4163
4246
  if (f.async != null) {
4164
4247
  addAsync = true;
4165
4248
  } else {
4166
- for (let ref23 = gatherRecursiveWithinFunction(block, ($16) => $16.type === "Await"), i12 = 0, len11 = ref23.length; i12 < len11; i12++) {
4167
- const a = ref23[i12];
4249
+ for (let ref27 = gatherRecursiveWithinFunction(block, ($19) => $19.type === "Await"), i15 = 0, len14 = ref27.length; i15 < len14; i15++) {
4250
+ const a = ref27[i15];
4168
4251
  const i = findChildIndex(a.parent, a);
4169
4252
  a.parent.children.splice(i + 1, 0, {
4170
4253
  type: "Error",
@@ -4176,19 +4259,21 @@ function processSignature(f) {
4176
4259
  if (!f.generator?.length && hasYield(block)) {
4177
4260
  if (f.generator != null) {
4178
4261
  addGenerator = true;
4262
+ } else if (f.type === "ArrowFunction") {
4263
+ transformArrowFunctionWithYield(f);
4179
4264
  } else {
4180
- for (let ref24 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "YieldExpression"), i13 = 0, len12 = ref24.length; i13 < len12; i13++) {
4181
- const y = ref24[i13];
4182
- const i = y.children.findIndex(($18) => $18.type === "Yield");
4265
+ for (let ref28 = gatherRecursiveWithinFunction(block, ($20) => $20.type === "YieldExpression"), i16 = 0, len15 = ref28.length; i16 < len15; i16++) {
4266
+ const y = ref28[i16];
4267
+ const i = y.children.findIndex(($21) => $21.type === "Yield");
4183
4268
  y.children.splice(i + 1, 0, {
4184
4269
  type: "Error",
4185
- message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
4270
+ message: `yield invalid in ${signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
4186
4271
  });
4187
4272
  }
4188
4273
  }
4189
4274
  }
4190
- for (let ref25 = [f, ...precedingOverloads(f)], i14 = 0, len13 = ref25.length; i14 < len13; i14++) {
4191
- const overload = ref25[i14];
4275
+ for (let ref29 = [f, ...precedingOverloads(f)], i17 = 0, len16 = ref29.length; i17 < len16; i17++) {
4276
+ const overload = ref29[i17];
4192
4277
  if (addAsync && overload.async != null && !overload.async.length) {
4193
4278
  overload.async.push("async ");
4194
4279
  overload.signature.modifier.async = true;
@@ -4207,8 +4292,8 @@ function processSignature(f) {
4207
4292
  }
4208
4293
  }
4209
4294
  function processFunctions(statements, config2) {
4210
- for (let ref26 = gatherRecursiveAll(statements, ($19) => $19.type === "FunctionExpression" || $19.type === "ArrowFunction" || $19.type === "MethodDefinition"), i15 = 0, len14 = ref26.length; i15 < len14; i15++) {
4211
- const f = ref26[i15];
4295
+ for (let ref30 = gatherRecursiveAll(statements, ($22) => $22.type === "FunctionExpression" || $22.type === "ArrowFunction" || $22.type === "MethodDefinition"), i18 = 0, len17 = ref30.length; i18 < len17; i18++) {
4296
+ const f = ref30[i18];
4212
4297
  if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
4213
4298
  implicitFunctionBlock(f);
4214
4299
  }
@@ -4281,14 +4366,14 @@ function expressionizeIteration(exp, consumeRoot) {
4281
4366
  ];
4282
4367
  } else {
4283
4368
  const reduction = statement.type === "ForStatement" && statement.reduction;
4284
- let ref27;
4369
+ let ref31;
4285
4370
  if (!async && !reduction && !statement.block.empty) {
4286
- ref27 = blockContainingStatement(exp);
4371
+ ref31 = blockContainingStatement(exp);
4287
4372
  } else {
4288
- ref27 = void 0;
4373
+ ref31 = void 0;
4289
4374
  }
4290
4375
  ;
4291
- const parentInfo = ref27;
4376
+ const parentInfo = ref31;
4292
4377
  if (parentInfo && iterationValueDiscarded(parentInfo.block, parentInfo.index, consumeRoot)) {
4293
4378
  const origSemi = parentInfo.block.expressions[parentInfo.index][2];
4294
4379
  statements = [["", statement, origSemi]];
@@ -4304,9 +4389,9 @@ function expressionizeIteration(exp, consumeRoot) {
4304
4389
  }
4305
4390
  let done;
4306
4391
  if (!async) {
4307
- let ref28;
4308
- if ((ref28 = blockContainingStatement(exp)) && typeof ref28 === "object" && "block" in ref28 && "index" in ref28) {
4309
- const { block: parentBlock, index } = ref28;
4392
+ let ref32;
4393
+ if ((ref32 = blockContainingStatement(exp)) && typeof ref32 === "object" && "block" in ref32 && "index" in ref32) {
4394
+ const { block: parentBlock, index } = ref32;
4310
4395
  statements[0][0] = parentBlock.expressions[index][0];
4311
4396
  parentBlock.expressions.splice(index, index + 1 - index, ...statements);
4312
4397
  updateParentPointers(parentBlock);
@@ -4323,8 +4408,8 @@ function expressionizeIteration(exp, consumeRoot) {
4323
4408
  }
4324
4409
  }
4325
4410
  function processIterationExpressions(statements, consumeRoot = false) {
4326
- for (let ref29 = gatherRecursiveAll(statements, ($20) => $20.type === "IterationExpression"), i16 = 0, len15 = ref29.length; i16 < len15; i16++) {
4327
- const s = ref29[i16];
4411
+ for (let ref33 = gatherRecursiveAll(statements, ($23) => $23.type === "IterationExpression"), i19 = 0, len18 = ref33.length; i19 < len18; i19++) {
4412
+ const s = ref33[i19];
4328
4413
  expressionizeIteration(s, consumeRoot);
4329
4414
  }
4330
4415
  }
@@ -4337,7 +4422,12 @@ function skipImplicitArguments(args) {
4337
4422
  if (arg0.type === "StatementExpression") {
4338
4423
  arg0 = arg0.statement;
4339
4424
  }
4340
- return arg0.type === "IterationExpression" && arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block);
4425
+ if (arg0.type === "IterationExpression") {
4426
+ return arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block);
4427
+ }
4428
+ if (arg0.type === "IfStatement") {
4429
+ return !arg0.else && isEmptyBareBlock(arg0.then);
4430
+ }
4341
4431
  }
4342
4432
  return false;
4343
4433
  }
@@ -4348,21 +4438,21 @@ function processCoffeeDo(ws, expression) {
4348
4438
  let { parameters } = expression;
4349
4439
  const parameterList = parameters.parameters;
4350
4440
  const results3 = [];
4351
- for (let i17 = 0, len16 = parameterList.length; i17 < len16; i17++) {
4352
- let parameter = parameterList[i17];
4441
+ for (let i20 = 0, len19 = parameterList.length; i20 < len19; i20++) {
4442
+ let parameter = parameterList[i20];
4353
4443
  if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
4354
- let ref30;
4355
- if (ref30 = parameter.initializer) {
4356
- const initializer = ref30;
4444
+ let ref34;
4445
+ if (ref34 = parameter.initializer) {
4446
+ const initializer = ref34;
4357
4447
  args.push(initializer.expression, parameter.delim);
4358
4448
  parameter = {
4359
4449
  ...parameter,
4360
4450
  initializer: void 0,
4361
- children: parameter.children.filter(((a6) => a6 !== initializer))
4451
+ children: parameter.children.filter(((a7) => a7 !== initializer))
4362
4452
  };
4363
4453
  } else {
4364
4454
  args.push(parameter.children.filter(
4365
- ((a7) => a7 !== parameter.typeSuffix)
4455
+ ((a8) => a8 !== parameter.typeSuffix)
4366
4456
  ));
4367
4457
  }
4368
4458
  }
@@ -4373,12 +4463,12 @@ function processCoffeeDo(ws, expression) {
4373
4463
  const newParameters = {
4374
4464
  ...parameters,
4375
4465
  parameters: newParameterList,
4376
- children: parameters.children.map(($21) => $21 === parameterList ? newParameterList : $21)
4466
+ children: parameters.children.map(($24) => $24 === parameterList ? newParameterList : $24)
4377
4467
  };
4378
4468
  expression = {
4379
4469
  ...expression,
4380
4470
  parameters: newParameters,
4381
- children: expression.children.map(($22) => $22 === parameters ? newParameters : $22)
4471
+ children: expression.children.map(($25) => $25 === parameters ? newParameters : $25)
4382
4472
  };
4383
4473
  }
4384
4474
  return {
@@ -4400,7 +4490,7 @@ function makeAmpersandFunction(rhs) {
4400
4490
  ref = makeRef("$");
4401
4491
  inplacePrepend(ref, body);
4402
4492
  }
4403
- if (startsWithPredicate(body, ($23) => $23.type === "ObjectExpression")) {
4493
+ if (startsWithPredicate(body, ($26) => $26.type === "ObjectExpression")) {
4404
4494
  body = makeLeftHandSideExpression(body);
4405
4495
  }
4406
4496
  const parameterList = [
@@ -4443,7 +4533,7 @@ function makeAmpersandFunction(rhs) {
4443
4533
  }
4444
4534
  if (gatherRecursiveWithinFunction(
4445
4535
  block,
4446
- ((a8) => a8 === ref)
4536
+ ((a9) => a9 === ref)
4447
4537
  ).length > 1) {
4448
4538
  fn.ampersandBlock = false;
4449
4539
  }
@@ -4468,6 +4558,9 @@ function blockWithPrefix(prefixStatements, block) {
4468
4558
  function braceBlock(block) {
4469
4559
  if (block.bare && !block.root) {
4470
4560
  block.children.unshift(" {");
4561
+ if (hasTrailingComment(block.children)) {
4562
+ block.children.push("\n");
4563
+ }
4471
4564
  block.children.push("}");
4472
4565
  const { implicitlyReturned } = block;
4473
4566
  block.bare = block.implicitlyReturned = false;
@@ -6030,15 +6123,42 @@ function dynamizeFromClause(from) {
6030
6123
  }
6031
6124
  return ["(", ...from, ")"];
6032
6125
  }
6126
+ function markAllTypeImports(decl) {
6127
+ if (decl.ts) {
6128
+ return decl;
6129
+ }
6130
+ const { imports } = decl;
6131
+ if (!imports) {
6132
+ return decl;
6133
+ }
6134
+ const i = imports;
6135
+ if (!i.binding && !i.star) {
6136
+ const specs = i.specifiers;
6137
+ if (specs?.length && specs.every(($5) => $5.ts)) {
6138
+ return { ...decl, ts: true };
6139
+ }
6140
+ return decl;
6141
+ }
6142
+ const children = imports.children;
6143
+ const namedSpecs = children.at(-1).specifiers;
6144
+ if (!(namedSpecs?.length && namedSpecs.every(($6) => $6.ts))) {
6145
+ return decl;
6146
+ }
6147
+ const [binding, ...rest] = children;
6148
+ const newImportsChildren = [binding, { ts: true, children: rest }];
6149
+ const newImports = { ...imports, children: newImportsChildren };
6150
+ const newDeclChildren = decl.children.map((c) => c === imports ? newImports : c);
6151
+ return { ...decl, imports: newImports, children: newDeclChildren };
6152
+ }
6033
6153
  function processStaticImport(decl) {
6034
6154
  const { imports, from, children } = decl;
6035
6155
  if (!(imports && "rest" in imports)) {
6036
- return decl;
6156
+ return markAllTypeImports(decl);
6037
6157
  }
6038
6158
  const namedImports = imports.binding ? imports.children.at(-1) : imports;
6039
6159
  const allSpecs = namedImports.specifiers;
6040
6160
  if (!(namedImports.rest || allSpecs.some((s) => s.pattern))) {
6041
- return decl;
6161
+ return markAllTypeImports(decl);
6042
6162
  }
6043
6163
  const ref = makeRef("imports");
6044
6164
  const star = { type: "Star", token: "*" };
@@ -7727,6 +7847,12 @@ function expressionizeIfStatement(statement) {
7727
7847
  children.push(":void 0");
7728
7848
  }
7729
7849
  children.push(closeParen);
7850
+ if (b.trailing?.length) {
7851
+ children.push(b.trailing);
7852
+ }
7853
+ if (e?.block.trailing?.length) {
7854
+ children.push(e.block.trailing);
7855
+ }
7730
7856
  return makeNode({
7731
7857
  type: "IfExpression",
7732
7858
  children
@@ -10008,6 +10134,9 @@ var grammar = {
10008
10134
  PostfixedSingleLineNoCommaStatements,
10009
10135
  NestedBlockStatements,
10010
10136
  NestedBlockStatement,
10137
+ TrailingNestedComments,
10138
+ TrailingInlineComment,
10139
+ TrailingNestedCommentLine,
10011
10140
  BlockStatementPart,
10012
10141
  Literal,
10013
10142
  LiteralContent,
@@ -10625,6 +10754,7 @@ var grammar = {
10625
10754
  CoffeeOfEnabled,
10626
10755
  CoffeePrototypeEnabled,
10627
10756
  ESArrowFunctionEnabled,
10757
+ ESBraceBlockEnabled,
10628
10758
  JSXCodeNestedEnabled,
10629
10759
  JSXCodeSameLineEnabled,
10630
10760
  ObjectIsEnabled,
@@ -13064,7 +13194,7 @@ function TrailingPostfix($$ctx, $$state) {
13064
13194
  $$ctx.exit?.("TrailingPostfix", $$state, $$final, $$eventData);
13065
13195
  return $$final;
13066
13196
  }
13067
- var FatArrowBody$0$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$E)(_), ExpressionizedStatement)), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$E)(_), Declaration)), NonPipelineExpression, (0, import_lib2.$N)(TrailingDeclaration), (0, import_lib2.$N)(TrailingPipe), (0, import_lib2.$N)(TrailingPostfix), (0, import_lib2.$N)(SemicolonDelimiter));
13197
+ var FatArrowBody$0$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$E)(_), ExpressionizedStatement)), (0, import_lib2.$N)((0, import_lib2.$S)((0, import_lib2.$E)(_), Declaration)), NonPipelineExpression, (0, import_lib2.$N)(TrailingDeclaration), (0, import_lib2.$N)(TrailingPipe), (0, import_lib2.$N)(TrailingPostfix), (0, import_lib2.$C)(ESArrowFunctionEnabled, (0, import_lib2.$N)(SemicolonDelimiter)));
13068
13198
  function FatArrowBody$0($$ctx, $$state) {
13069
13199
  const $$r = FatArrowBody$0$parser($$ctx, $$state);
13070
13200
  if (!$$r) {
@@ -14180,7 +14310,7 @@ function ClassBracedContent($$ctx, $$state) {
14180
14310
  $$ctx.exit?.("ClassBracedContent", $$state, $$final, $$eventData);
14181
14311
  return $$final;
14182
14312
  }
14183
- var NestedClassElements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedClassElement), PopIndent);
14313
+ var NestedClassElements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedClassElement), (0, import_lib2.$Q)(TrailingNestedCommentLine), PopIndent);
14184
14314
  function NestedClassElements($$ctx, $$state) {
14185
14315
  const $$entered = $$ctx.enter?.("NestedClassElements", $$state);
14186
14316
  if ($$entered && "cache" in $$entered) return $$entered.cache;
@@ -14190,12 +14320,13 @@ function NestedClassElements($$ctx, $$state) {
14190
14320
  $$ctx.exit?.("NestedClassElements", $$state, void 0, $$eventData);
14191
14321
  return void 0;
14192
14322
  }
14193
- const $$m = (function(elements) {
14194
- if (!elements.length) {
14323
+ const $$value = $$r.value;
14324
+ const $$m = (function(elements, trailing) {
14325
+ if (!(elements.length || trailing.length)) {
14195
14326
  return $skip;
14196
14327
  }
14197
- return elements;
14198
- })($$r.value[1]);
14328
+ return trailing.length ? [...elements, ...trailing] : elements;
14329
+ })($$value[1], $$value[2]);
14199
14330
  const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
14200
14331
  $$ctx.exit?.("NestedClassElements", $$state, $$final, $$eventData);
14201
14332
  return $$final;
@@ -17767,8 +17898,9 @@ function ThenClause($$ctx, $$state) {
17767
17898
  }
17768
17899
  var ThenBlock$0$parser = (0, import_lib2.$S)(NoBlock, EmptyBlock);
17769
17900
  var ThenBlock$1$parser = ImplicitNestedBlock;
17770
- var ThenBlock$2$parser = ObjectSingleLineStatements;
17771
- var ThenBlock$3$parser = SingleLineStatements;
17901
+ var ThenBlock$2$parser = (0, import_lib2.$S)(ESBraceBlockEnabled, ExplicitBlock);
17902
+ var ThenBlock$3$parser = (0, import_lib2.$S)((0, import_lib2.$N)(ESBraceBlockEnabled), ObjectSingleLineStatements);
17903
+ var ThenBlock$4$parser = SingleLineStatements;
17772
17904
  function ThenBlock$0($$ctx, $$state) {
17773
17905
  const $$r = ThenBlock$0$parser($$ctx, $$state);
17774
17906
  if (!$$r) {
@@ -17784,16 +17916,35 @@ function ThenBlock$1($$ctx, $$state) {
17784
17916
  return ThenBlock$1$parser($$ctx, $$state);
17785
17917
  }
17786
17918
  function ThenBlock$2($$ctx, $$state) {
17787
- return ThenBlock$2$parser($$ctx, $$state);
17919
+ const $$r = ThenBlock$2$parser($$ctx, $$state);
17920
+ if (!$$r) {
17921
+ return void 0;
17922
+ }
17923
+ const $$m = /* @__PURE__ */ (function($2) {
17924
+ return $2;
17925
+ })($$r.value[1]);
17926
+ $$r.value = $$m;
17927
+ return $$r;
17788
17928
  }
17789
17929
  function ThenBlock$3($$ctx, $$state) {
17790
- return ThenBlock$3$parser($$ctx, $$state);
17930
+ const $$r = ThenBlock$3$parser($$ctx, $$state);
17931
+ if (!$$r) {
17932
+ return void 0;
17933
+ }
17934
+ const $$m = /* @__PURE__ */ (function($2) {
17935
+ return $2;
17936
+ })($$r.value[1]);
17937
+ $$r.value = $$m;
17938
+ return $$r;
17939
+ }
17940
+ function ThenBlock$4($$ctx, $$state) {
17941
+ return ThenBlock$4$parser($$ctx, $$state);
17791
17942
  }
17792
17943
  function ThenBlock($$ctx, $$state) {
17793
17944
  const $$entered = $$ctx.enter?.("ThenBlock", $$state);
17794
17945
  if ($$entered && "cache" in $$entered) return $$entered.cache;
17795
17946
  const $$eventData = $$entered?.data;
17796
- const $$final = ThenBlock$0($$ctx, $$state) || ThenBlock$1($$ctx, $$state) || ThenBlock$2($$ctx, $$state) || ThenBlock$3($$ctx, $$state);
17947
+ const $$final = ThenBlock$0($$ctx, $$state) || ThenBlock$1($$ctx, $$state) || ThenBlock$2($$ctx, $$state) || ThenBlock$3($$ctx, $$state) || ThenBlock$4($$ctx, $$state);
17797
17948
  $$ctx.exit?.("ThenBlock", $$state, $$final, $$eventData);
17798
17949
  return $$final;
17799
17950
  }
@@ -17918,11 +18069,19 @@ function BlockOrEmptyStatement($$ctx, $$state) {
17918
18069
  $$ctx.exit?.("BlockOrEmptyStatement", $$state, $$final, $$eventData);
17919
18070
  return $$final;
17920
18071
  }
17921
- var BlockOrEmpty$0$parser = ObjectSingleLineStatements;
18072
+ var BlockOrEmpty$0$parser = (0, import_lib2.$S)((0, import_lib2.$N)(ESBraceBlockEnabled), ObjectSingleLineStatements);
17922
18073
  var BlockOrEmpty$1$parser = Block;
17923
18074
  var BlockOrEmpty$2$parser = (0, import_lib2.$S)(NoBlock, EmptyBlock);
17924
18075
  function BlockOrEmpty$0($$ctx, $$state) {
17925
- return BlockOrEmpty$0$parser($$ctx, $$state);
18076
+ const $$r = BlockOrEmpty$0$parser($$ctx, $$state);
18077
+ if (!$$r) {
18078
+ return void 0;
18079
+ }
18080
+ const $$m = /* @__PURE__ */ (function($2) {
18081
+ return $2;
18082
+ })($$r.value[1]);
18083
+ $$r.value = $$m;
18084
+ return $$r;
17926
18085
  }
17927
18086
  function BlockOrEmpty$1($$ctx, $$state) {
17928
18087
  return BlockOrEmpty$1$parser($$ctx, $$state);
@@ -18292,7 +18451,7 @@ function PostfixedSingleLineNoCommaStatements($$ctx, $$state) {
18292
18451
  $$ctx.exit?.("PostfixedSingleLineNoCommaStatements", $$state, $$r, $$eventData);
18293
18452
  return $$r;
18294
18453
  }
18295
- var NestedBlockStatements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedBlockStatement), PopIndent);
18454
+ var NestedBlockStatements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedBlockStatement), TrailingNestedComments, PopIndent);
18296
18455
  function NestedBlockStatements($$ctx, $$state) {
18297
18456
  const $$entered = $$ctx.enter?.("NestedBlockStatements", $$state);
18298
18457
  if ($$entered && "cache" in $$entered) return $$entered.cache;
@@ -18302,18 +18461,24 @@ function NestedBlockStatements($$ctx, $$state) {
18302
18461
  $$ctx.exit?.("NestedBlockStatements", $$state, void 0, $$eventData);
18303
18462
  return void 0;
18304
18463
  }
18305
- const $$m = (function(statements) {
18306
- if (!statements.length) {
18464
+ const $$value = $$r.value;
18465
+ const $$m = (function(statements, trailing) {
18466
+ if (!(statements.length || trailing.length)) {
18307
18467
  return $skip;
18308
18468
  }
18309
- statements = statements.flat();
18469
+ const expressions = statements.flat();
18470
+ const children = [expressions];
18471
+ if (trailing.length) {
18472
+ children.push(trailing);
18473
+ }
18310
18474
  return {
18311
18475
  type: "BlockStatement",
18312
- expressions: statements,
18313
- children: [statements],
18314
- bare: true
18476
+ expressions,
18477
+ children,
18478
+ bare: true,
18479
+ trailing: trailing.length ? trailing : void 0
18315
18480
  };
18316
- })($$r.value[1]);
18481
+ })($$value[1], $$value[2]);
18317
18482
  const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
18318
18483
  $$ctx.exit?.("NestedBlockStatements", $$state, $$final, $$eventData);
18319
18484
  return $$final;
@@ -18339,6 +18504,70 @@ function NestedBlockStatement($$ctx, $$state) {
18339
18504
  $$ctx.exit?.("NestedBlockStatement", $$state, $$r, $$eventData);
18340
18505
  return $$r;
18341
18506
  }
18507
+ var TrailingNestedComments$parser = (0, import_lib2.$S)((0, import_lib2.$E)(TrailingInlineComment), (0, import_lib2.$Q)(TrailingNestedCommentLine));
18508
+ function TrailingNestedComments($$ctx, $$state) {
18509
+ const $$entered = $$ctx.enter?.("TrailingNestedComments", $$state);
18510
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18511
+ const $$eventData = $$entered?.data;
18512
+ const $$r = TrailingNestedComments$parser($$ctx, $$state);
18513
+ if (!$$r) {
18514
+ $$ctx.exit?.("TrailingNestedComments", $$state, void 0, $$eventData);
18515
+ return void 0;
18516
+ }
18517
+ const $$value = $$r.value;
18518
+ const $$m = (function(inline, lines) {
18519
+ const out = [];
18520
+ if (inline) {
18521
+ out.push(inline);
18522
+ }
18523
+ if (lines.length) {
18524
+ out.push(...lines);
18525
+ }
18526
+ return out;
18527
+ })($$value[0], $$value[1]);
18528
+ $$r.value = $$m;
18529
+ $$ctx.exit?.("TrailingNestedComments", $$state, $$r, $$eventData);
18530
+ return $$r;
18531
+ }
18532
+ var TrailingInlineComment$parser = (0, import_lib2.$S)((0, import_lib2.$E)(_), SingleLineComment);
18533
+ function TrailingInlineComment($$ctx, $$state) {
18534
+ const $$entered = $$ctx.enter?.("TrailingInlineComment", $$state);
18535
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18536
+ const $$eventData = $$entered?.data;
18537
+ const $$r = TrailingInlineComment$parser($$ctx, $$state);
18538
+ if (!$$r) {
18539
+ $$ctx.exit?.("TrailingInlineComment", $$state, void 0, $$eventData);
18540
+ return void 0;
18541
+ }
18542
+ const $$value = $$r.value;
18543
+ const $$m = /* @__PURE__ */ (function(ws, c) {
18544
+ return [ws, c];
18545
+ })($$value[0], $$value[1]);
18546
+ $$r.value = $$m;
18547
+ $$ctx.exit?.("TrailingInlineComment", $$state, $$r, $$eventData);
18548
+ return $$r;
18549
+ }
18550
+ var TrailingNestedCommentLine$parser = (0, import_lib2.$S)(EOL, Indent, SingleLineComment);
18551
+ function TrailingNestedCommentLine($$ctx, $$state) {
18552
+ const $$entered = $$ctx.enter?.("TrailingNestedCommentLine", $$state);
18553
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18554
+ const $$eventData = $$entered?.data;
18555
+ const $$r = TrailingNestedCommentLine$parser($$ctx, $$state);
18556
+ if (!$$r) {
18557
+ $$ctx.exit?.("TrailingNestedCommentLine", $$state, void 0, $$eventData);
18558
+ return void 0;
18559
+ }
18560
+ const $$value = $$r.value;
18561
+ const $$m = (function(eol, indent, c) {
18562
+ if (!(indent.level >= state.currentIndent.level)) {
18563
+ return $skip;
18564
+ }
18565
+ return [eol, indent, c];
18566
+ })($$value[0], $$value[1], $$value[2]);
18567
+ const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
18568
+ $$ctx.exit?.("TrailingNestedCommentLine", $$state, $$final, $$eventData);
18569
+ return $$final;
18570
+ }
18342
18571
  var BlockStatementPart$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), (0, import_lib2.$E)(_), StatementListItem, StatementDelimiter);
18343
18572
  function BlockStatementPart($$ctx, $$state) {
18344
18573
  const $$entered = $$ctx.enter?.("BlockStatementPart", $$state);
@@ -23617,10 +23846,16 @@ function CaseClause$2($$ctx, $$state) {
23617
23846
  return void 0;
23618
23847
  }
23619
23848
  const $$value = $$r.value;
23620
- const $$m = /* @__PURE__ */ (function($0, cases, block, b) {
23849
+ const $$m = (function($0, cases, block, b) {
23850
+ let children = $0;
23851
+ if (hasTrailingComment(block)) {
23852
+ const bIdx = children.indexOf(b);
23853
+ b = { ...b, token: "\n" + b.token };
23854
+ children = [...children.slice(0, bIdx), b, ...children.slice(bIdx + 1)];
23855
+ }
23621
23856
  return {
23622
23857
  type: "WhenClause",
23623
- children: $0,
23858
+ children,
23624
23859
  cases,
23625
23860
  block,
23626
23861
  break: b
@@ -25312,7 +25547,7 @@ function MaybeNestedExpression($$ctx, $$state) {
25312
25547
  $$ctx.exit?.("MaybeNestedExpression", $$state, $$final, $$eventData);
25313
25548
  return $$final;
25314
25549
  }
25315
- var MaybeParenNestedExpression$0$parser = (0, import_lib2.$Y)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement, NoBlock));
25550
+ var MaybeParenNestedExpression$0$parser = (0, import_lib2.$Y)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement, (0, import_lib2.$C)(NoBlock, (0, import_lib2.$S)((0, import_lib2.$E)(_), Semicolon))));
25316
25551
  var MaybeParenNestedExpression$1$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), Expression);
25317
25552
  var MaybeParenNestedExpression$2$parser = (0, import_lib2.$S)((0, import_lib2.$Y)(EOS), (0, import_lib2.$C)(ArrayLiteral, ObjectLiteral));
25318
25553
  var MaybeParenNestedExpression$3$parser = (0, import_lib2.$S)((0, import_lib2.$Y)(EOS), InsertSpace, InsertOpenParen, PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, Expression)), PopIndent, (0, import_lib2.$E)(AllowedTrailingCallExpressions), InsertNewline, InsertIndent, InsertCloseParen);
@@ -35128,6 +35363,24 @@ function ESArrowFunctionEnabled($$ctx, $$state) {
35128
35363
  $$ctx.exit?.("ESArrowFunctionEnabled", $$state, $$final, $$eventData);
35129
35364
  return $$final;
35130
35365
  }
35366
+ var ESBraceBlockEnabled$parser = (0, import_lib2.$EXPECT)($L0, 'ESBraceBlockEnabled ""');
35367
+ function ESBraceBlockEnabled($$ctx, $$state) {
35368
+ const $$entered = $$ctx.enter?.("ESBraceBlockEnabled", $$state);
35369
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
35370
+ const $$eventData = $$entered?.data;
35371
+ const $$r = ESBraceBlockEnabled$parser($$ctx, $$state);
35372
+ if (!$$r) {
35373
+ $$ctx.exit?.("ESBraceBlockEnabled", $$state, void 0, $$eventData);
35374
+ return void 0;
35375
+ }
35376
+ const $$m = (function() {
35377
+ if (config.esBraceBlock) return;
35378
+ return $skip;
35379
+ })();
35380
+ const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
35381
+ $$ctx.exit?.("ESBraceBlockEnabled", $$state, $$final, $$eventData);
35382
+ return $$final;
35383
+ }
35131
35384
  var JSXCodeNestedEnabled$parser = (0, import_lib2.$EXPECT)($L0, 'JSXCodeNestedEnabled ""');
35132
35385
  function JSXCodeNestedEnabled($$ctx, $$state) {
35133
35386
  const $$entered = $$ctx.enter?.("JSXCodeNestedEnabled", $$state);
@@ -35465,12 +35718,19 @@ function TrackIndented($$ctx, $$state) {
35465
35718
  $$ctx.exit?.("TrackIndented", $$state, $$final, $$eventData);
35466
35719
  return $$final;
35467
35720
  }
35468
- var PushIndent$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOS, TrackIndented));
35721
+ var PushIndent$0$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOS, TrackIndented));
35722
+ var PushIndent$1$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOL, TrackIndented));
35723
+ function PushIndent$0($$ctx, $$state) {
35724
+ return PushIndent$0$parser($$ctx, $$state);
35725
+ }
35726
+ function PushIndent$1($$ctx, $$state) {
35727
+ return PushIndent$1$parser($$ctx, $$state);
35728
+ }
35469
35729
  function PushIndent($$ctx, $$state) {
35470
35730
  const $$entered = $$ctx.enter?.("PushIndent", $$state);
35471
35731
  if ($$entered && "cache" in $$entered) return $$entered.cache;
35472
35732
  const $$eventData = $$entered?.data;
35473
- const $$final = PushIndent$parser($$ctx, $$state);
35733
+ const $$final = PushIndent$0($$ctx, $$state) || PushIndent$1($$ctx, $$state);
35474
35734
  $$ctx.exit?.("PushIndent", $$state, $$final, $$eventData);
35475
35735
  return $$final;
35476
35736
  }