@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.js CHANGED
@@ -3428,10 +3428,10 @@ function insertReturn(node) {
3428
3428
  }
3429
3429
  insertReturn(node.block);
3430
3430
  if (!isExit(node.block)) {
3431
- const comment = hasTrailingComment(node.block.expressions);
3431
+ const comment = node.block.trailing?.length || hasTrailingComment(node.block.expressions);
3432
3432
  let ref12;
3433
3433
  node.block.expressions.push([
3434
- comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
3434
+ comment ? (ref12 = node.block.expressions)[ref12.length - 1]?.[0] || "\n" : "",
3435
3435
  wrapWithReturn(void 0, node, !comment)
3436
3436
  ]);
3437
3437
  }
@@ -4071,6 +4071,53 @@ function processParams(f) {
4071
4071
  } else {
4072
4072
  indent = expressions[0][0];
4073
4073
  }
4074
+ const { ancestor: enclosingClass } = findAncestor(f, ($10) => $10.type === "ClassExpression");
4075
+ if (enclosingClass != null) {
4076
+ const fieldTypes = /* @__PURE__ */ new Map();
4077
+ for (let ref20 = gatherRecursiveWithinFunction(enclosingClass.body, ($11) => $11.type === "FieldDefinition"), i9 = 0, len8 = ref20.length; i9 < len8; i9++) {
4078
+ const { id, typeSuffix } = ref20[i9];
4079
+ if (typeSuffix != null && id?.type === "Identifier") {
4080
+ fieldTypes.set(id.name, typeSuffix);
4081
+ }
4082
+ }
4083
+ if (fieldTypes.size) {
4084
+ for (let ref21 = gatherRecursive(parameters, ($12) => $12.type === "Parameter"), i10 = 0, len9 = ref21.length; i10 < len9; i10++) {
4085
+ const parameter = ref21[i10];
4086
+ if (parameter.typeSuffix != null) {
4087
+ continue;
4088
+ }
4089
+ let inferredInPattern = false;
4090
+ for (let ref22 = gatherRecursive(parameter, ($13) => $13.type === "AtBinding"), i11 = 0, len10 = ref22.length; i11 < len10; i11++) {
4091
+ const binding = ref22[i11];
4092
+ const owner = binding.parent;
4093
+ assert(owner, "@-binding has no parent");
4094
+ const fieldType = fieldTypes.get(binding.ref.id);
4095
+ if (!(fieldType != null)) {
4096
+ continue;
4097
+ }
4098
+ owner.typeSuffix = deepCopy(fieldType);
4099
+ updateParentPointers(owner);
4100
+ if (owner === parameter) {
4101
+ const i = owner.children.indexOf(binding);
4102
+ assert.notEqual(i, -1, "@-binding missing from parameter children");
4103
+ owner.children[i + 1] = owner.typeSuffix;
4104
+ } else {
4105
+ inferredInPattern = true;
4106
+ }
4107
+ }
4108
+ if (inferredInPattern) {
4109
+ const pattern = parameter.binding;
4110
+ pattern.typeSuffix = void 0;
4111
+ gatherBindingPatternTypeSuffix(pattern);
4112
+ assert(pattern.typeSuffix, "expected aggregated binding pattern type");
4113
+ parameter.typeSuffix = pattern.typeSuffix;
4114
+ const i = parameter.children.indexOf(pattern);
4115
+ assert.notEqual(i, -1, "binding pattern missing from parameter children");
4116
+ parameter.children[i + 1] = parameter.typeSuffix;
4117
+ }
4118
+ }
4119
+ }
4120
+ }
4074
4121
  const [splices, thisAssignments] = gatherBindingCode(parameters, {
4075
4122
  injectParamProps: isConstructor,
4076
4123
  assignPins: true
@@ -4079,22 +4126,21 @@ function processParams(f) {
4079
4126
  simplifyBindingProperties(parameters.parameters);
4080
4127
  simplifyBindingProperties(subbindings);
4081
4128
  if (isConstructor) {
4082
- const { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
4083
- if (ancestor != null) {
4084
- 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));
4085
- const classExpressions = ancestor.body.expressions;
4129
+ if (enclosingClass != null) {
4130
+ 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));
4131
+ const classExpressions = enclosingClass.body.expressions;
4086
4132
  let index2 = findChildIndex(classExpressions, f);
4087
4133
  assert.notEqual(index2, -1, "Could not find constructor in class");
4088
4134
  index2 -= precedingOverloads(f).length;
4089
4135
  const fStatement = classExpressions[index2];
4090
- for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i9 = 0, len8 = ref20.length; i9 < len8; i9++) {
4091
- const parameter = ref20[i9];
4136
+ for (let ref23 = gatherRecursive(parameters, ($17) => $17.type === "Parameter"), i12 = 0, len11 = ref23.length; i12 < len11; i12++) {
4137
+ const parameter = ref23[i12];
4092
4138
  const { accessModifier } = parameter;
4093
4139
  if (!(accessModifier || parameter.typeSuffix)) {
4094
4140
  continue;
4095
4141
  }
4096
- for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i10 = 0, len9 = ref21.length; i10 < len9; i10++) {
4097
- const binding = ref21[i10];
4142
+ for (let ref24 = gatherRecursive(parameter, ($18) => $18.type === "AtBinding"), i13 = 0, len12 = ref24.length; i13 < len12; i13++) {
4143
+ const binding = ref24[i13];
4098
4144
  const typeSuffix = binding.parent?.typeSuffix;
4099
4145
  if (!(accessModifier || typeSuffix)) {
4100
4146
  continue;
@@ -4132,8 +4178,8 @@ function processParams(f) {
4132
4178
  decl: "const"
4133
4179
  }));
4134
4180
  }
4135
- for (let ref22 = splices, i11 = 0, len10 = ref22.length; i11 < len10; i11++) {
4136
- const binding = ref22[i11];
4181
+ for (let ref25 = splices, i14 = 0, len13 = ref25.length; i14 < len13; i14++) {
4182
+ const binding = ref25[i14];
4137
4183
  assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
4138
4184
  prefix.push(makeNode({
4139
4185
  type: "Declaration",
@@ -4176,6 +4222,43 @@ function findSuperCall(block) {
4176
4222
  return -1;
4177
4223
  }
4178
4224
  }
4225
+ function transformArrowFunctionWithYield(f) {
4226
+ const { block, parameters, returnType, async, signature } = f;
4227
+ if (block?.type === "BlockStatement" && block.implicitlyReturned) {
4228
+ insertReturn(block);
4229
+ block.implicitlyReturned = false;
4230
+ }
4231
+ if (block?.type === "BlockStatement" && block.bare && !block.root) {
4232
+ block.children.unshift(" {");
4233
+ block.children.push("}");
4234
+ block.bare = false;
4235
+ }
4236
+ const generator = ["*"];
4237
+ signature.modifier ??= {};
4238
+ signature.modifier.generator = true;
4239
+ signature.generator = generator;
4240
+ signature.children = [async, "function", generator, parameters, returnType];
4241
+ f.type = "FunctionExpression";
4242
+ f.generator = generator;
4243
+ f.children = [async, "function", generator, parameters, returnType, block];
4244
+ const originalParent = f.parent;
4245
+ const lhs = makeLeftHandSideExpression(f);
4246
+ let ref26;
4247
+ if (gatherRecursiveWithinFunction(block, ((a6) => typeof a6 === "object" && a6 != null && "token" in a6 && a6.token === "this")).length) {
4248
+ ref26 = makeNode({
4249
+ type: "CallExpression",
4250
+ children: [lhs, ".bind(this)"]
4251
+ });
4252
+ } else {
4253
+ ref26 = lhs;
4254
+ }
4255
+ ;
4256
+ const newNode = ref26;
4257
+ if (newNode !== f && originalParent != null) {
4258
+ replaceNode(f, newNode, originalParent);
4259
+ updateParentPointers(newNode, originalParent);
4260
+ }
4261
+ }
4179
4262
  function processSignature(f) {
4180
4263
  const { block, signature } = f;
4181
4264
  let addAsync = false;
@@ -4184,8 +4267,8 @@ function processSignature(f) {
4184
4267
  if (f.async != null) {
4185
4268
  addAsync = true;
4186
4269
  } else {
4187
- for (let ref23 = gatherRecursiveWithinFunction(block, ($16) => $16.type === "Await"), i12 = 0, len11 = ref23.length; i12 < len11; i12++) {
4188
- const a = ref23[i12];
4270
+ for (let ref27 = gatherRecursiveWithinFunction(block, ($19) => $19.type === "Await"), i15 = 0, len14 = ref27.length; i15 < len14; i15++) {
4271
+ const a = ref27[i15];
4189
4272
  const i = findChildIndex(a.parent, a);
4190
4273
  a.parent.children.splice(i + 1, 0, {
4191
4274
  type: "Error",
@@ -4197,19 +4280,21 @@ function processSignature(f) {
4197
4280
  if (!f.generator?.length && hasYield(block)) {
4198
4281
  if (f.generator != null) {
4199
4282
  addGenerator = true;
4283
+ } else if (f.type === "ArrowFunction") {
4284
+ transformArrowFunctionWithYield(f);
4200
4285
  } else {
4201
- for (let ref24 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "YieldExpression"), i13 = 0, len12 = ref24.length; i13 < len12; i13++) {
4202
- const y = ref24[i13];
4203
- const i = y.children.findIndex(($18) => $18.type === "Yield");
4286
+ for (let ref28 = gatherRecursiveWithinFunction(block, ($20) => $20.type === "YieldExpression"), i16 = 0, len15 = ref28.length; i16 < len15; i16++) {
4287
+ const y = ref28[i16];
4288
+ const i = y.children.findIndex(($21) => $21.type === "Yield");
4204
4289
  y.children.splice(i + 1, 0, {
4205
4290
  type: "Error",
4206
- message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
4291
+ message: `yield invalid in ${signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
4207
4292
  });
4208
4293
  }
4209
4294
  }
4210
4295
  }
4211
- for (let ref25 = [f, ...precedingOverloads(f)], i14 = 0, len13 = ref25.length; i14 < len13; i14++) {
4212
- const overload = ref25[i14];
4296
+ for (let ref29 = [f, ...precedingOverloads(f)], i17 = 0, len16 = ref29.length; i17 < len16; i17++) {
4297
+ const overload = ref29[i17];
4213
4298
  if (addAsync && overload.async != null && !overload.async.length) {
4214
4299
  overload.async.push("async ");
4215
4300
  overload.signature.modifier.async = true;
@@ -4228,8 +4313,8 @@ function processSignature(f) {
4228
4313
  }
4229
4314
  }
4230
4315
  function processFunctions(statements, config2) {
4231
- for (let ref26 = gatherRecursiveAll(statements, ($19) => $19.type === "FunctionExpression" || $19.type === "ArrowFunction" || $19.type === "MethodDefinition"), i15 = 0, len14 = ref26.length; i15 < len14; i15++) {
4232
- const f = ref26[i15];
4316
+ for (let ref30 = gatherRecursiveAll(statements, ($22) => $22.type === "FunctionExpression" || $22.type === "ArrowFunction" || $22.type === "MethodDefinition"), i18 = 0, len17 = ref30.length; i18 < len17; i18++) {
4317
+ const f = ref30[i18];
4233
4318
  if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
4234
4319
  implicitFunctionBlock(f);
4235
4320
  }
@@ -4302,14 +4387,14 @@ function expressionizeIteration(exp, consumeRoot) {
4302
4387
  ];
4303
4388
  } else {
4304
4389
  const reduction = statement.type === "ForStatement" && statement.reduction;
4305
- let ref27;
4390
+ let ref31;
4306
4391
  if (!async && !reduction && !statement.block.empty) {
4307
- ref27 = blockContainingStatement(exp);
4392
+ ref31 = blockContainingStatement(exp);
4308
4393
  } else {
4309
- ref27 = void 0;
4394
+ ref31 = void 0;
4310
4395
  }
4311
4396
  ;
4312
- const parentInfo = ref27;
4397
+ const parentInfo = ref31;
4313
4398
  if (parentInfo && iterationValueDiscarded(parentInfo.block, parentInfo.index, consumeRoot)) {
4314
4399
  const origSemi = parentInfo.block.expressions[parentInfo.index][2];
4315
4400
  statements = [["", statement, origSemi]];
@@ -4325,9 +4410,9 @@ function expressionizeIteration(exp, consumeRoot) {
4325
4410
  }
4326
4411
  let done;
4327
4412
  if (!async) {
4328
- let ref28;
4329
- if ((ref28 = blockContainingStatement(exp)) && typeof ref28 === "object" && "block" in ref28 && "index" in ref28) {
4330
- const { block: parentBlock, index } = ref28;
4413
+ let ref32;
4414
+ if ((ref32 = blockContainingStatement(exp)) && typeof ref32 === "object" && "block" in ref32 && "index" in ref32) {
4415
+ const { block: parentBlock, index } = ref32;
4331
4416
  statements[0][0] = parentBlock.expressions[index][0];
4332
4417
  parentBlock.expressions.splice(index, index + 1 - index, ...statements);
4333
4418
  updateParentPointers(parentBlock);
@@ -4344,8 +4429,8 @@ function expressionizeIteration(exp, consumeRoot) {
4344
4429
  }
4345
4430
  }
4346
4431
  function processIterationExpressions(statements, consumeRoot = false) {
4347
- for (let ref29 = gatherRecursiveAll(statements, ($20) => $20.type === "IterationExpression"), i16 = 0, len15 = ref29.length; i16 < len15; i16++) {
4348
- const s = ref29[i16];
4432
+ for (let ref33 = gatherRecursiveAll(statements, ($23) => $23.type === "IterationExpression"), i19 = 0, len18 = ref33.length; i19 < len18; i19++) {
4433
+ const s = ref33[i19];
4349
4434
  expressionizeIteration(s, consumeRoot);
4350
4435
  }
4351
4436
  }
@@ -4358,7 +4443,12 @@ function skipImplicitArguments(args) {
4358
4443
  if (arg0.type === "StatementExpression") {
4359
4444
  arg0 = arg0.statement;
4360
4445
  }
4361
- return arg0.type === "IterationExpression" && arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block);
4446
+ if (arg0.type === "IterationExpression") {
4447
+ return arg0.subtype !== "DoStatement" && !arg0.async && isEmptyBareBlock(arg0.block);
4448
+ }
4449
+ if (arg0.type === "IfStatement") {
4450
+ return !arg0.else && isEmptyBareBlock(arg0.then);
4451
+ }
4362
4452
  }
4363
4453
  return false;
4364
4454
  }
@@ -4369,21 +4459,21 @@ function processCoffeeDo(ws, expression) {
4369
4459
  let { parameters } = expression;
4370
4460
  const parameterList = parameters.parameters;
4371
4461
  const results3 = [];
4372
- for (let i17 = 0, len16 = parameterList.length; i17 < len16; i17++) {
4373
- let parameter = parameterList[i17];
4462
+ for (let i20 = 0, len19 = parameterList.length; i20 < len19; i20++) {
4463
+ let parameter = parameterList[i20];
4374
4464
  if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
4375
- let ref30;
4376
- if (ref30 = parameter.initializer) {
4377
- const initializer = ref30;
4465
+ let ref34;
4466
+ if (ref34 = parameter.initializer) {
4467
+ const initializer = ref34;
4378
4468
  args.push(initializer.expression, parameter.delim);
4379
4469
  parameter = {
4380
4470
  ...parameter,
4381
4471
  initializer: void 0,
4382
- children: parameter.children.filter(((a6) => a6 !== initializer))
4472
+ children: parameter.children.filter(((a7) => a7 !== initializer))
4383
4473
  };
4384
4474
  } else {
4385
4475
  args.push(parameter.children.filter(
4386
- ((a7) => a7 !== parameter.typeSuffix)
4476
+ ((a8) => a8 !== parameter.typeSuffix)
4387
4477
  ));
4388
4478
  }
4389
4479
  }
@@ -4394,12 +4484,12 @@ function processCoffeeDo(ws, expression) {
4394
4484
  const newParameters = {
4395
4485
  ...parameters,
4396
4486
  parameters: newParameterList,
4397
- children: parameters.children.map(($21) => $21 === parameterList ? newParameterList : $21)
4487
+ children: parameters.children.map(($24) => $24 === parameterList ? newParameterList : $24)
4398
4488
  };
4399
4489
  expression = {
4400
4490
  ...expression,
4401
4491
  parameters: newParameters,
4402
- children: expression.children.map(($22) => $22 === parameters ? newParameters : $22)
4492
+ children: expression.children.map(($25) => $25 === parameters ? newParameters : $25)
4403
4493
  };
4404
4494
  }
4405
4495
  return {
@@ -4421,7 +4511,7 @@ function makeAmpersandFunction(rhs) {
4421
4511
  ref = makeRef("$");
4422
4512
  inplacePrepend(ref, body);
4423
4513
  }
4424
- if (startsWithPredicate(body, ($23) => $23.type === "ObjectExpression")) {
4514
+ if (startsWithPredicate(body, ($26) => $26.type === "ObjectExpression")) {
4425
4515
  body = makeLeftHandSideExpression(body);
4426
4516
  }
4427
4517
  const parameterList = [
@@ -4464,7 +4554,7 @@ function makeAmpersandFunction(rhs) {
4464
4554
  }
4465
4555
  if (gatherRecursiveWithinFunction(
4466
4556
  block,
4467
- ((a8) => a8 === ref)
4557
+ ((a9) => a9 === ref)
4468
4558
  ).length > 1) {
4469
4559
  fn.ampersandBlock = false;
4470
4560
  }
@@ -4489,6 +4579,9 @@ function blockWithPrefix(prefixStatements, block) {
4489
4579
  function braceBlock(block) {
4490
4580
  if (block.bare && !block.root) {
4491
4581
  block.children.unshift(" {");
4582
+ if (hasTrailingComment(block.children)) {
4583
+ block.children.push("\n");
4584
+ }
4492
4585
  block.children.push("}");
4493
4586
  const { implicitlyReturned } = block;
4494
4587
  block.bare = block.implicitlyReturned = false;
@@ -6051,15 +6144,42 @@ function dynamizeFromClause(from) {
6051
6144
  }
6052
6145
  return ["(", ...from, ")"];
6053
6146
  }
6147
+ function markAllTypeImports(decl) {
6148
+ if (decl.ts) {
6149
+ return decl;
6150
+ }
6151
+ const { imports } = decl;
6152
+ if (!imports) {
6153
+ return decl;
6154
+ }
6155
+ const i = imports;
6156
+ if (!i.binding && !i.star) {
6157
+ const specs = i.specifiers;
6158
+ if (specs?.length && specs.every(($5) => $5.ts)) {
6159
+ return { ...decl, ts: true };
6160
+ }
6161
+ return decl;
6162
+ }
6163
+ const children = imports.children;
6164
+ const namedSpecs = children.at(-1).specifiers;
6165
+ if (!(namedSpecs?.length && namedSpecs.every(($6) => $6.ts))) {
6166
+ return decl;
6167
+ }
6168
+ const [binding, ...rest] = children;
6169
+ const newImportsChildren = [binding, { ts: true, children: rest }];
6170
+ const newImports = { ...imports, children: newImportsChildren };
6171
+ const newDeclChildren = decl.children.map((c) => c === imports ? newImports : c);
6172
+ return { ...decl, imports: newImports, children: newDeclChildren };
6173
+ }
6054
6174
  function processStaticImport(decl) {
6055
6175
  const { imports, from, children } = decl;
6056
6176
  if (!(imports && "rest" in imports)) {
6057
- return decl;
6177
+ return markAllTypeImports(decl);
6058
6178
  }
6059
6179
  const namedImports = imports.binding ? imports.children.at(-1) : imports;
6060
6180
  const allSpecs = namedImports.specifiers;
6061
6181
  if (!(namedImports.rest || allSpecs.some((s) => s.pattern))) {
6062
- return decl;
6182
+ return markAllTypeImports(decl);
6063
6183
  }
6064
6184
  const ref = makeRef("imports");
6065
6185
  const star = { type: "Star", token: "*" };
@@ -7748,6 +7868,12 @@ function expressionizeIfStatement(statement) {
7748
7868
  children.push(":void 0");
7749
7869
  }
7750
7870
  children.push(closeParen);
7871
+ if (b.trailing?.length) {
7872
+ children.push(b.trailing);
7873
+ }
7874
+ if (e?.block.trailing?.length) {
7875
+ children.push(e.block.trailing);
7876
+ }
7751
7877
  return makeNode({
7752
7878
  type: "IfExpression",
7753
7879
  children
@@ -10029,6 +10155,9 @@ var grammar = {
10029
10155
  PostfixedSingleLineNoCommaStatements,
10030
10156
  NestedBlockStatements,
10031
10157
  NestedBlockStatement,
10158
+ TrailingNestedComments,
10159
+ TrailingInlineComment,
10160
+ TrailingNestedCommentLine,
10032
10161
  BlockStatementPart,
10033
10162
  Literal,
10034
10163
  LiteralContent,
@@ -10646,6 +10775,7 @@ var grammar = {
10646
10775
  CoffeeOfEnabled,
10647
10776
  CoffeePrototypeEnabled,
10648
10777
  ESArrowFunctionEnabled,
10778
+ ESBraceBlockEnabled,
10649
10779
  JSXCodeNestedEnabled,
10650
10780
  JSXCodeSameLineEnabled,
10651
10781
  ObjectIsEnabled,
@@ -13085,7 +13215,7 @@ function TrailingPostfix($$ctx, $$state) {
13085
13215
  $$ctx.exit?.("TrailingPostfix", $$state, $$final, $$eventData);
13086
13216
  return $$final;
13087
13217
  }
13088
- 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));
13218
+ 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)));
13089
13219
  function FatArrowBody$0($$ctx, $$state) {
13090
13220
  const $$r = FatArrowBody$0$parser($$ctx, $$state);
13091
13221
  if (!$$r) {
@@ -14201,7 +14331,7 @@ function ClassBracedContent($$ctx, $$state) {
14201
14331
  $$ctx.exit?.("ClassBracedContent", $$state, $$final, $$eventData);
14202
14332
  return $$final;
14203
14333
  }
14204
- var NestedClassElements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedClassElement), PopIndent);
14334
+ var NestedClassElements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedClassElement), (0, import_lib2.$Q)(TrailingNestedCommentLine), PopIndent);
14205
14335
  function NestedClassElements($$ctx, $$state) {
14206
14336
  const $$entered = $$ctx.enter?.("NestedClassElements", $$state);
14207
14337
  if ($$entered && "cache" in $$entered) return $$entered.cache;
@@ -14211,12 +14341,13 @@ function NestedClassElements($$ctx, $$state) {
14211
14341
  $$ctx.exit?.("NestedClassElements", $$state, void 0, $$eventData);
14212
14342
  return void 0;
14213
14343
  }
14214
- const $$m = (function(elements) {
14215
- if (!elements.length) {
14344
+ const $$value = $$r.value;
14345
+ const $$m = (function(elements, trailing) {
14346
+ if (!(elements.length || trailing.length)) {
14216
14347
  return $skip;
14217
14348
  }
14218
- return elements;
14219
- })($$r.value[1]);
14349
+ return trailing.length ? [...elements, ...trailing] : elements;
14350
+ })($$value[1], $$value[2]);
14220
14351
  const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
14221
14352
  $$ctx.exit?.("NestedClassElements", $$state, $$final, $$eventData);
14222
14353
  return $$final;
@@ -17788,8 +17919,9 @@ function ThenClause($$ctx, $$state) {
17788
17919
  }
17789
17920
  var ThenBlock$0$parser = (0, import_lib2.$S)(NoBlock, EmptyBlock);
17790
17921
  var ThenBlock$1$parser = ImplicitNestedBlock;
17791
- var ThenBlock$2$parser = ObjectSingleLineStatements;
17792
- var ThenBlock$3$parser = SingleLineStatements;
17922
+ var ThenBlock$2$parser = (0, import_lib2.$S)(ESBraceBlockEnabled, ExplicitBlock);
17923
+ var ThenBlock$3$parser = (0, import_lib2.$S)((0, import_lib2.$N)(ESBraceBlockEnabled), ObjectSingleLineStatements);
17924
+ var ThenBlock$4$parser = SingleLineStatements;
17793
17925
  function ThenBlock$0($$ctx, $$state) {
17794
17926
  const $$r = ThenBlock$0$parser($$ctx, $$state);
17795
17927
  if (!$$r) {
@@ -17805,16 +17937,35 @@ function ThenBlock$1($$ctx, $$state) {
17805
17937
  return ThenBlock$1$parser($$ctx, $$state);
17806
17938
  }
17807
17939
  function ThenBlock$2($$ctx, $$state) {
17808
- return ThenBlock$2$parser($$ctx, $$state);
17940
+ const $$r = ThenBlock$2$parser($$ctx, $$state);
17941
+ if (!$$r) {
17942
+ return void 0;
17943
+ }
17944
+ const $$m = /* @__PURE__ */ (function($2) {
17945
+ return $2;
17946
+ })($$r.value[1]);
17947
+ $$r.value = $$m;
17948
+ return $$r;
17809
17949
  }
17810
17950
  function ThenBlock$3($$ctx, $$state) {
17811
- return ThenBlock$3$parser($$ctx, $$state);
17951
+ const $$r = ThenBlock$3$parser($$ctx, $$state);
17952
+ if (!$$r) {
17953
+ return void 0;
17954
+ }
17955
+ const $$m = /* @__PURE__ */ (function($2) {
17956
+ return $2;
17957
+ })($$r.value[1]);
17958
+ $$r.value = $$m;
17959
+ return $$r;
17960
+ }
17961
+ function ThenBlock$4($$ctx, $$state) {
17962
+ return ThenBlock$4$parser($$ctx, $$state);
17812
17963
  }
17813
17964
  function ThenBlock($$ctx, $$state) {
17814
17965
  const $$entered = $$ctx.enter?.("ThenBlock", $$state);
17815
17966
  if ($$entered && "cache" in $$entered) return $$entered.cache;
17816
17967
  const $$eventData = $$entered?.data;
17817
- const $$final = ThenBlock$0($$ctx, $$state) || ThenBlock$1($$ctx, $$state) || ThenBlock$2($$ctx, $$state) || ThenBlock$3($$ctx, $$state);
17968
+ const $$final = ThenBlock$0($$ctx, $$state) || ThenBlock$1($$ctx, $$state) || ThenBlock$2($$ctx, $$state) || ThenBlock$3($$ctx, $$state) || ThenBlock$4($$ctx, $$state);
17818
17969
  $$ctx.exit?.("ThenBlock", $$state, $$final, $$eventData);
17819
17970
  return $$final;
17820
17971
  }
@@ -17939,11 +18090,19 @@ function BlockOrEmptyStatement($$ctx, $$state) {
17939
18090
  $$ctx.exit?.("BlockOrEmptyStatement", $$state, $$final, $$eventData);
17940
18091
  return $$final;
17941
18092
  }
17942
- var BlockOrEmpty$0$parser = ObjectSingleLineStatements;
18093
+ var BlockOrEmpty$0$parser = (0, import_lib2.$S)((0, import_lib2.$N)(ESBraceBlockEnabled), ObjectSingleLineStatements);
17943
18094
  var BlockOrEmpty$1$parser = Block;
17944
18095
  var BlockOrEmpty$2$parser = (0, import_lib2.$S)(NoBlock, EmptyBlock);
17945
18096
  function BlockOrEmpty$0($$ctx, $$state) {
17946
- return BlockOrEmpty$0$parser($$ctx, $$state);
18097
+ const $$r = BlockOrEmpty$0$parser($$ctx, $$state);
18098
+ if (!$$r) {
18099
+ return void 0;
18100
+ }
18101
+ const $$m = /* @__PURE__ */ (function($2) {
18102
+ return $2;
18103
+ })($$r.value[1]);
18104
+ $$r.value = $$m;
18105
+ return $$r;
17947
18106
  }
17948
18107
  function BlockOrEmpty$1($$ctx, $$state) {
17949
18108
  return BlockOrEmpty$1$parser($$ctx, $$state);
@@ -18313,7 +18472,7 @@ function PostfixedSingleLineNoCommaStatements($$ctx, $$state) {
18313
18472
  $$ctx.exit?.("PostfixedSingleLineNoCommaStatements", $$state, $$r, $$eventData);
18314
18473
  return $$r;
18315
18474
  }
18316
- var NestedBlockStatements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedBlockStatement), PopIndent);
18475
+ var NestedBlockStatements$parser = (0, import_lib2.$S)(PushIndent, (0, import_lib2.$Q)(NestedBlockStatement), TrailingNestedComments, PopIndent);
18317
18476
  function NestedBlockStatements($$ctx, $$state) {
18318
18477
  const $$entered = $$ctx.enter?.("NestedBlockStatements", $$state);
18319
18478
  if ($$entered && "cache" in $$entered) return $$entered.cache;
@@ -18323,18 +18482,24 @@ function NestedBlockStatements($$ctx, $$state) {
18323
18482
  $$ctx.exit?.("NestedBlockStatements", $$state, void 0, $$eventData);
18324
18483
  return void 0;
18325
18484
  }
18326
- const $$m = (function(statements) {
18327
- if (!statements.length) {
18485
+ const $$value = $$r.value;
18486
+ const $$m = (function(statements, trailing) {
18487
+ if (!(statements.length || trailing.length)) {
18328
18488
  return $skip;
18329
18489
  }
18330
- statements = statements.flat();
18490
+ const expressions = statements.flat();
18491
+ const children = [expressions];
18492
+ if (trailing.length) {
18493
+ children.push(trailing);
18494
+ }
18331
18495
  return {
18332
18496
  type: "BlockStatement",
18333
- expressions: statements,
18334
- children: [statements],
18335
- bare: true
18497
+ expressions,
18498
+ children,
18499
+ bare: true,
18500
+ trailing: trailing.length ? trailing : void 0
18336
18501
  };
18337
- })($$r.value[1]);
18502
+ })($$value[1], $$value[2]);
18338
18503
  const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
18339
18504
  $$ctx.exit?.("NestedBlockStatements", $$state, $$final, $$eventData);
18340
18505
  return $$final;
@@ -18360,6 +18525,70 @@ function NestedBlockStatement($$ctx, $$state) {
18360
18525
  $$ctx.exit?.("NestedBlockStatement", $$state, $$r, $$eventData);
18361
18526
  return $$r;
18362
18527
  }
18528
+ var TrailingNestedComments$parser = (0, import_lib2.$S)((0, import_lib2.$E)(TrailingInlineComment), (0, import_lib2.$Q)(TrailingNestedCommentLine));
18529
+ function TrailingNestedComments($$ctx, $$state) {
18530
+ const $$entered = $$ctx.enter?.("TrailingNestedComments", $$state);
18531
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18532
+ const $$eventData = $$entered?.data;
18533
+ const $$r = TrailingNestedComments$parser($$ctx, $$state);
18534
+ if (!$$r) {
18535
+ $$ctx.exit?.("TrailingNestedComments", $$state, void 0, $$eventData);
18536
+ return void 0;
18537
+ }
18538
+ const $$value = $$r.value;
18539
+ const $$m = (function(inline, lines) {
18540
+ const out = [];
18541
+ if (inline) {
18542
+ out.push(inline);
18543
+ }
18544
+ if (lines.length) {
18545
+ out.push(...lines);
18546
+ }
18547
+ return out;
18548
+ })($$value[0], $$value[1]);
18549
+ $$r.value = $$m;
18550
+ $$ctx.exit?.("TrailingNestedComments", $$state, $$r, $$eventData);
18551
+ return $$r;
18552
+ }
18553
+ var TrailingInlineComment$parser = (0, import_lib2.$S)((0, import_lib2.$E)(_), SingleLineComment);
18554
+ function TrailingInlineComment($$ctx, $$state) {
18555
+ const $$entered = $$ctx.enter?.("TrailingInlineComment", $$state);
18556
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18557
+ const $$eventData = $$entered?.data;
18558
+ const $$r = TrailingInlineComment$parser($$ctx, $$state);
18559
+ if (!$$r) {
18560
+ $$ctx.exit?.("TrailingInlineComment", $$state, void 0, $$eventData);
18561
+ return void 0;
18562
+ }
18563
+ const $$value = $$r.value;
18564
+ const $$m = /* @__PURE__ */ (function(ws, c) {
18565
+ return [ws, c];
18566
+ })($$value[0], $$value[1]);
18567
+ $$r.value = $$m;
18568
+ $$ctx.exit?.("TrailingInlineComment", $$state, $$r, $$eventData);
18569
+ return $$r;
18570
+ }
18571
+ var TrailingNestedCommentLine$parser = (0, import_lib2.$S)(EOL, Indent, SingleLineComment);
18572
+ function TrailingNestedCommentLine($$ctx, $$state) {
18573
+ const $$entered = $$ctx.enter?.("TrailingNestedCommentLine", $$state);
18574
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
18575
+ const $$eventData = $$entered?.data;
18576
+ const $$r = TrailingNestedCommentLine$parser($$ctx, $$state);
18577
+ if (!$$r) {
18578
+ $$ctx.exit?.("TrailingNestedCommentLine", $$state, void 0, $$eventData);
18579
+ return void 0;
18580
+ }
18581
+ const $$value = $$r.value;
18582
+ const $$m = (function(eol, indent, c) {
18583
+ if (!(indent.level >= state.currentIndent.level)) {
18584
+ return $skip;
18585
+ }
18586
+ return [eol, indent, c];
18587
+ })($$value[0], $$value[1], $$value[2]);
18588
+ const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
18589
+ $$ctx.exit?.("TrailingNestedCommentLine", $$state, $$final, $$eventData);
18590
+ return $$final;
18591
+ }
18363
18592
  var BlockStatementPart$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), (0, import_lib2.$E)(_), StatementListItem, StatementDelimiter);
18364
18593
  function BlockStatementPart($$ctx, $$state) {
18365
18594
  const $$entered = $$ctx.enter?.("BlockStatementPart", $$state);
@@ -23638,10 +23867,16 @@ function CaseClause$2($$ctx, $$state) {
23638
23867
  return void 0;
23639
23868
  }
23640
23869
  const $$value = $$r.value;
23641
- const $$m = /* @__PURE__ */ (function($0, cases, block, b) {
23870
+ const $$m = (function($0, cases, block, b) {
23871
+ let children = $0;
23872
+ if (hasTrailingComment(block)) {
23873
+ const bIdx = children.indexOf(b);
23874
+ b = { ...b, token: "\n" + b.token };
23875
+ children = [...children.slice(0, bIdx), b, ...children.slice(bIdx + 1)];
23876
+ }
23642
23877
  return {
23643
23878
  type: "WhenClause",
23644
- children: $0,
23879
+ children,
23645
23880
  cases,
23646
23881
  block,
23647
23882
  break: b
@@ -25333,7 +25568,7 @@ function MaybeNestedExpression($$ctx, $$state) {
25333
25568
  $$ctx.exit?.("MaybeNestedExpression", $$state, $$final, $$eventData);
25334
25569
  return $$final;
25335
25570
  }
25336
- var MaybeParenNestedExpression$0$parser = (0, import_lib2.$Y)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement, NoBlock));
25571
+ 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))));
25337
25572
  var MaybeParenNestedExpression$1$parser = (0, import_lib2.$S)((0, import_lib2.$N)(EOS), Expression);
25338
25573
  var MaybeParenNestedExpression$2$parser = (0, import_lib2.$S)((0, import_lib2.$Y)(EOS), (0, import_lib2.$C)(ArrayLiteral, ObjectLiteral));
25339
25574
  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);
@@ -35149,6 +35384,24 @@ function ESArrowFunctionEnabled($$ctx, $$state) {
35149
35384
  $$ctx.exit?.("ESArrowFunctionEnabled", $$state, $$final, $$eventData);
35150
35385
  return $$final;
35151
35386
  }
35387
+ var ESBraceBlockEnabled$parser = (0, import_lib2.$EXPECT)($L0, 'ESBraceBlockEnabled ""');
35388
+ function ESBraceBlockEnabled($$ctx, $$state) {
35389
+ const $$entered = $$ctx.enter?.("ESBraceBlockEnabled", $$state);
35390
+ if ($$entered && "cache" in $$entered) return $$entered.cache;
35391
+ const $$eventData = $$entered?.data;
35392
+ const $$r = ESBraceBlockEnabled$parser($$ctx, $$state);
35393
+ if (!$$r) {
35394
+ $$ctx.exit?.("ESBraceBlockEnabled", $$state, void 0, $$eventData);
35395
+ return void 0;
35396
+ }
35397
+ const $$m = (function() {
35398
+ if (config.esBraceBlock) return;
35399
+ return $skip;
35400
+ })();
35401
+ const $$final = $$m !== import_lib2.SKIP ? ($$r.value = $$m, $$r) : void 0;
35402
+ $$ctx.exit?.("ESBraceBlockEnabled", $$state, $$final, $$eventData);
35403
+ return $$final;
35404
+ }
35152
35405
  var JSXCodeNestedEnabled$parser = (0, import_lib2.$EXPECT)($L0, 'JSXCodeNestedEnabled ""');
35153
35406
  function JSXCodeNestedEnabled($$ctx, $$state) {
35154
35407
  const $$entered = $$ctx.enter?.("JSXCodeNestedEnabled", $$state);
@@ -35486,12 +35739,19 @@ function TrackIndented($$ctx, $$state) {
35486
35739
  $$ctx.exit?.("TrackIndented", $$state, $$final, $$eventData);
35487
35740
  return $$final;
35488
35741
  }
35489
- var PushIndent$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOS, TrackIndented));
35742
+ var PushIndent$0$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOS, TrackIndented));
35743
+ var PushIndent$1$parser = (0, import_lib2.$Y)((0, import_lib2.$S)(EOL, TrackIndented));
35744
+ function PushIndent$0($$ctx, $$state) {
35745
+ return PushIndent$0$parser($$ctx, $$state);
35746
+ }
35747
+ function PushIndent$1($$ctx, $$state) {
35748
+ return PushIndent$1$parser($$ctx, $$state);
35749
+ }
35490
35750
  function PushIndent($$ctx, $$state) {
35491
35751
  const $$entered = $$ctx.enter?.("PushIndent", $$state);
35492
35752
  if ($$entered && "cache" in $$entered) return $$entered.cache;
35493
35753
  const $$eventData = $$entered?.data;
35494
- const $$final = PushIndent$parser($$ctx, $$state);
35754
+ const $$final = PushIndent$0($$ctx, $$state) || PushIndent$1($$ctx, $$state);
35495
35755
  $$ctx.exit?.("PushIndent", $$state, $$final, $$eventData);
35496
35756
  return $$final;
35497
35757
  }