@danielx/civet 0.6.41 → 0.6.42

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
@@ -849,14 +849,36 @@ var require_lib = __commonJS({
849
849
  })
850
850
  );
851
851
  }
852
+ function negateCondition(condition) {
853
+ let { expression } = condition;
854
+ const children = condition.children.slice();
855
+ const i = children.indexOf(expression);
856
+ if (i < 0) {
857
+ throw new Error(`Could not find expression in condition`);
858
+ }
859
+ children[i] = expression = {
860
+ type: "UnaryExpression",
861
+ children: [
862
+ "!",
863
+ makeLeftHandSideExpression(expression)
864
+ ]
865
+ };
866
+ return { ...condition, expression, children };
867
+ }
852
868
  function expressionizeIfClause(clause, b, e) {
853
- const children = clause.children.slice(1);
854
- children.push("?", b);
869
+ const { condition } = clause;
870
+ const [...condRest] = condition.children, [closeParen] = condRest.splice(-1);
871
+ const children = [
872
+ ...condRest,
873
+ "?",
874
+ b
875
+ ];
855
876
  if (e) {
856
877
  children.push(e[0], ":", ...e.slice(2));
857
878
  } else {
858
879
  children.push(":void 0");
859
880
  }
881
+ children.push(closeParen);
860
882
  return {
861
883
  type: "IfExpression",
862
884
  children
@@ -1540,7 +1562,6 @@ var require_lib = __commonJS({
1540
1562
  const [, exp, semi] = node;
1541
1563
  if (semi?.type === "SemicolonDelimiter")
1542
1564
  return;
1543
- let indent = getIndent(node);
1544
1565
  if (!exp)
1545
1566
  return;
1546
1567
  switch (exp.type) {
@@ -1965,6 +1986,7 @@ var require_lib = __commonJS({
1965
1986
  case "CallExpression":
1966
1987
  case "MemberExpression":
1967
1988
  case "ParenthesizedExpression":
1989
+ case "IfExpression":
1968
1990
  case "DebuggerExpression":
1969
1991
  case "SwitchExpression":
1970
1992
  case "ThrowExpression":
@@ -2204,7 +2226,7 @@ var require_lib = __commonJS({
2204
2226
  children
2205
2227
  };
2206
2228
  }
2207
- function processDeclarationCondition(condition) {
2229
+ function processDeclarationCondition(condition, rootCondition) {
2208
2230
  if (!(condition.type === "DeclarationCondition")) {
2209
2231
  return;
2210
2232
  }
@@ -2212,7 +2234,7 @@ var require_lib = __commonJS({
2212
2234
  const { decl, bindings } = condition.declaration;
2213
2235
  const binding = bindings[0];
2214
2236
  const { pattern, suffix, initializer, splices, thisAssignments } = binding;
2215
- const initCondition = {
2237
+ Object.assign(condition, {
2216
2238
  type: "AssignmentExpression",
2217
2239
  children: [ref, initializer],
2218
2240
  hoistDec: {
@@ -2220,14 +2242,15 @@ var require_lib = __commonJS({
2220
2242
  children: ["let ", ref, suffix],
2221
2243
  names: []
2222
2244
  },
2245
+ pattern,
2246
+ ref
2247
+ });
2248
+ Object.assign(rootCondition, {
2223
2249
  blockPrefix: [
2224
2250
  ["", [decl, pattern, suffix, " = ", ref, ...splices], ";"],
2225
2251
  ...thisAssignments
2226
- ],
2227
- pattern,
2228
- ref
2229
- };
2230
- Object.assign(condition, initCondition);
2252
+ ]
2253
+ });
2231
2254
  }
2232
2255
  function processDeclarationConditions(node) {
2233
2256
  gatherRecursiveAll(node, (n) => {
@@ -2239,8 +2262,15 @@ var require_lib = __commonJS({
2239
2262
  if (!condition?.expression) {
2240
2263
  return;
2241
2264
  }
2242
- processDeclarationCondition(condition.expression);
2243
- const { ref, pattern } = condition.expression;
2265
+ ;
2266
+ let { expression } = condition;
2267
+ if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && expression.children.length === 2 && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
2268
+ const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
2269
+ const type = [type1, type2];
2270
+ expression = expression2;
2271
+ }
2272
+ processDeclarationCondition(expression, condition.expression);
2273
+ const { ref, pattern } = expression;
2244
2274
  if (pattern) {
2245
2275
  let conditions = [];
2246
2276
  getPatternConditions(pattern, ref, conditions);
@@ -3532,6 +3562,7 @@ var require_lib = __commonJS({
3532
3562
  maybeRef,
3533
3563
  modifyString,
3534
3564
  needsRef,
3565
+ negateCondition,
3535
3566
  processAssignmentDeclaration,
3536
3567
  processBinaryOpExpression,
3537
3568
  processCallMemberExpression,
@@ -3974,6 +4005,7 @@ var require_parser = __commonJS({
3974
4005
  TemplateBlockCharacters,
3975
4006
  ReservedWord,
3976
4007
  Comment,
4008
+ _Comment,
3977
4009
  SingleLineComment,
3978
4010
  JSSingleLineComment,
3979
4011
  MultiLineComment,
@@ -4514,33 +4546,36 @@ var require_parser = __commonJS({
4514
4546
  var $R38 = $R(new RegExp("(?:by)(?!\\p{ID_Continue})", "suy"));
4515
4547
  var $R39 = $R(new RegExp("(?:of)(?!\\p{ID_Continue})", "suy"));
4516
4548
  var $R40 = $R(new RegExp("(?:and|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|import|in|instanceof|interface|is|let|loop|new|not|null|or|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|unless|until|var|void|while|with|yield)(?!\\p{ID_Continue})", "suy"));
4517
- var $R41 = $R(new RegExp("\\/\\/(?!\\/)[^\\r\\n]*", "suy"));
4518
- var $R42 = $R(new RegExp(".", "suy"));
4519
- var $R43 = $R(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
4520
- var $R44 = $R(new RegExp("[^]*?###", "suy"));
4521
- var $R45 = $R(new RegExp("###(?!#)", "suy"));
4522
- var $R46 = $R(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
4523
- var $R47 = $R(new RegExp("[ \\t]+", "suy"));
4524
- var $R48 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
4525
- var $R49 = $R(new RegExp("['\u2019]s", "suy"));
4526
- var $R50 = $R(new RegExp("\\s", "suy"));
4527
- var $R51 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
4528
- var $R52 = $R(new RegExp("[\\s>]|\\/>", "suy"));
4529
- var $R53 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
4530
- var $R54 = $R(new RegExp(`"[^"]*"|'[^']*'`, "suy"));
4531
- var $R55 = $R(new RegExp("[<>]", "suy"));
4532
- var $R56 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
4533
- var $R57 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
4534
- var $R58 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
4535
- var $R59 = $R(new RegExp("[+-]?", "suy"));
4536
- var $R60 = $R(new RegExp("[+-]", "suy"));
4537
- var $R61 = $R(new RegExp("#![^\\r\\n]*", "suy"));
4538
- var $R62 = $R(new RegExp("[\\t ]*", "suy"));
4539
- var $R63 = $R(new RegExp("[\\s]*", "suy"));
4540
- var $R64 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4541
- var $R65 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4542
- var $R66 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4543
- var $R67 = $R(new RegExp("[ \\t]*", "suy"));
4549
+ var $R41 = $R(new RegExp("(?=\\/|#)", "suy"));
4550
+ var $R42 = $R(new RegExp("\\/\\/(?!\\/)[^\\r\\n]*", "suy"));
4551
+ var $R43 = $R(new RegExp(".", "suy"));
4552
+ var $R44 = $R(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
4553
+ var $R45 = $R(new RegExp("[^]*?###", "suy"));
4554
+ var $R46 = $R(new RegExp("###(?!#)", "suy"));
4555
+ var $R47 = $R(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
4556
+ var $R48 = $R(new RegExp("(?=[ \\t\\/])", "suy"));
4557
+ var $R49 = $R(new RegExp("[ \\t]+", "suy"));
4558
+ var $R50 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
4559
+ var $R51 = $R(new RegExp("['\u2019]s", "suy"));
4560
+ var $R52 = $R(new RegExp("\\s", "suy"));
4561
+ var $R53 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
4562
+ var $R54 = $R(new RegExp("[\\s>]|\\/>", "suy"));
4563
+ var $R55 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
4564
+ var $R56 = $R(new RegExp(`"[^"]*"|'[^']*'`, "suy"));
4565
+ var $R57 = $R(new RegExp("[<>]", "suy"));
4566
+ var $R58 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
4567
+ var $R59 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
4568
+ var $R60 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
4569
+ var $R61 = $R(new RegExp("[+-]?", "suy"));
4570
+ var $R62 = $R(new RegExp("[+-]", "suy"));
4571
+ var $R63 = $R(new RegExp("#![^\\r\\n]*", "suy"));
4572
+ var $R64 = $R(new RegExp("[\\t ]*", "suy"));
4573
+ var $R65 = $R(new RegExp("[\\s]*", "suy"));
4574
+ var $R66 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
4575
+ var $R67 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
4576
+ var $R68 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
4577
+ var $R69 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
4578
+ var $R70 = $R(new RegExp("[ \\t]*", "suy"));
4544
4579
  var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
4545
4580
  var statements = $4;
4546
4581
  processProgram({
@@ -5947,8 +5982,8 @@ var require_parser = __commonJS({
5947
5982
  function NonEmptyParameters(ctx, state) {
5948
5983
  return $EVENT(ctx, state, "NonEmptyParameters", NonEmptyParameters$0);
5949
5984
  }
5950
- var FunctionRestParameter$0 = $TS($S(BindingRestElement, $E(TypeSuffix), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3) {
5951
- var id = $1;
5985
+ var FunctionRestParameter$0 = $TS($S(__, BindingRestElement, $E(TypeSuffix), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
5986
+ var id = $2;
5952
5987
  return {
5953
5988
  type: "FunctionRestParameter",
5954
5989
  children: $0,
@@ -8311,10 +8346,10 @@ var require_parser = __commonJS({
8311
8346
  kind = { ...kind, token: "if" };
8312
8347
  kind.token += getTrimmingSpace(condition);
8313
8348
  condition = insertTrimmingSpace(condition, "");
8349
+ condition = negateCondition(condition);
8314
8350
  return {
8315
8351
  type: "IfStatement",
8316
- // TODO: Don't add unnecessary parens
8317
- children: [kind, ["(!", condition, ")"]],
8352
+ children: [kind, condition],
8318
8353
  condition
8319
8354
  };
8320
8355
  });
@@ -8517,16 +8552,12 @@ var require_parser = __commonJS({
8517
8552
  var ws = $2;
8518
8553
  var condition = $3;
8519
8554
  if (kind.token === "until") {
8520
- kind.token = "while";
8521
- return {
8522
- type: "IterationStatement",
8523
- children: [kind, ...ws, ["(!", ...condition.children, ")"]],
8524
- condition
8525
- };
8555
+ kind = { ...kind, token: "while" };
8556
+ condition = negateCondition(condition);
8526
8557
  }
8527
8558
  return {
8528
8559
  type: "IterationStatement",
8529
- children: [kind, ...ws, ...condition.children],
8560
+ children: [kind, ws, condition],
8530
8561
  condition
8531
8562
  };
8532
8563
  });
@@ -10067,11 +10098,17 @@ var require_parser = __commonJS({
10067
10098
  function ReservedWord(ctx, state) {
10068
10099
  return $EVENT_C(ctx, state, "ReservedWord", ReservedWord$$);
10069
10100
  }
10070
- var Comment$0 = MultiLineComment;
10071
- var Comment$1 = SingleLineComment;
10072
- var Comment$$ = [Comment$0, Comment$1];
10101
+ var Comment$0 = $T($S($EXPECT($R41, "Comment /(?=\\/|#)/"), _Comment), function(value) {
10102
+ return value[1];
10103
+ });
10073
10104
  function Comment(ctx, state) {
10074
- return $EVENT_C(ctx, state, "Comment", Comment$$);
10105
+ return $EVENT(ctx, state, "Comment", Comment$0);
10106
+ }
10107
+ var _Comment$0 = MultiLineComment;
10108
+ var _Comment$1 = SingleLineComment;
10109
+ var _Comment$$ = [_Comment$0, _Comment$1];
10110
+ function _Comment(ctx, state) {
10111
+ return $EVENT_C(ctx, state, "_Comment", _Comment$$);
10075
10112
  }
10076
10113
  var SingleLineComment$0 = JSSingleLineComment;
10077
10114
  var SingleLineComment$1 = $S(CoffeeCommentEnabled, CoffeeSingleLineComment);
@@ -10079,7 +10116,7 @@ var require_parser = __commonJS({
10079
10116
  function SingleLineComment(ctx, state) {
10080
10117
  return $EVENT_C(ctx, state, "SingleLineComment", SingleLineComment$$);
10081
10118
  }
10082
- var JSSingleLineComment$0 = $TR($EXPECT($R41, "JSSingleLineComment /\\/\\/(?!\\/)[^\\r\\n]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10119
+ var JSSingleLineComment$0 = $TR($EXPECT($R42, "JSSingleLineComment /\\/\\/(?!\\/)[^\\r\\n]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10083
10120
  return { type: "Comment", $loc, token: $0 };
10084
10121
  });
10085
10122
  function JSSingleLineComment(ctx, state) {
@@ -10091,30 +10128,30 @@ var require_parser = __commonJS({
10091
10128
  function MultiLineComment(ctx, state) {
10092
10129
  return $EVENT_C(ctx, state, "MultiLineComment", MultiLineComment$$);
10093
10130
  }
10094
- var JSMultiLineComment$0 = $TV($TEXT($S($EXPECT($L109, 'JSMultiLineComment "/*"'), $Q($S($N($EXPECT($L110, 'JSMultiLineComment "*/"')), $EXPECT($R42, "JSMultiLineComment /./"))), $EXPECT($L110, 'JSMultiLineComment "*/"'))), function($skip, $loc, $0, $1) {
10131
+ var JSMultiLineComment$0 = $TV($TEXT($S($EXPECT($L109, 'JSMultiLineComment "/*"'), $Q($S($N($EXPECT($L110, 'JSMultiLineComment "*/"')), $EXPECT($R43, "JSMultiLineComment /./"))), $EXPECT($L110, 'JSMultiLineComment "*/"'))), function($skip, $loc, $0, $1) {
10095
10132
  return { type: "Comment", $loc, token: $1 };
10096
10133
  });
10097
10134
  function JSMultiLineComment(ctx, state) {
10098
10135
  return $EVENT(ctx, state, "JSMultiLineComment", JSMultiLineComment$0);
10099
10136
  }
10100
- var CoffeeSingleLineComment$0 = $TR($EXPECT($R43, "CoffeeSingleLineComment /#(?!##(?!#))([^\\r\\n]*)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10137
+ var CoffeeSingleLineComment$0 = $TR($EXPECT($R44, "CoffeeSingleLineComment /#(?!##(?!#))([^\\r\\n]*)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10101
10138
  return { type: "Comment", $loc, token: `//${$1}` };
10102
10139
  });
10103
10140
  function CoffeeSingleLineComment(ctx, state) {
10104
10141
  return $EVENT(ctx, state, "CoffeeSingleLineComment", CoffeeSingleLineComment$0);
10105
10142
  }
10106
- var CoffeeMultiLineComment$0 = $TS($S(CoffeeHereCommentStart, $TEXT($EXPECT($R44, "CoffeeMultiLineComment /[^]*?###/"))), function($skip, $loc, $0, $1, $2) {
10143
+ var CoffeeMultiLineComment$0 = $TS($S(CoffeeHereCommentStart, $TEXT($EXPECT($R45, "CoffeeMultiLineComment /[^]*?###/"))), function($skip, $loc, $0, $1, $2) {
10107
10144
  $2 = $2.slice(0, $2.length - 3).replace(/\*\//g, "* /");
10108
10145
  return { type: "Comment", $loc, token: `/*${$2}*/` };
10109
10146
  });
10110
10147
  function CoffeeMultiLineComment(ctx, state) {
10111
10148
  return $EVENT(ctx, state, "CoffeeMultiLineComment", CoffeeMultiLineComment$0);
10112
10149
  }
10113
- var CoffeeHereCommentStart$0 = $R$0($EXPECT($R45, "CoffeeHereCommentStart /###(?!#)/"));
10150
+ var CoffeeHereCommentStart$0 = $R$0($EXPECT($R46, "CoffeeHereCommentStart /###(?!#)/"));
10114
10151
  function CoffeeHereCommentStart(ctx, state) {
10115
10152
  return $EVENT(ctx, state, "CoffeeHereCommentStart", CoffeeHereCommentStart$0);
10116
10153
  }
10117
- var InlineComment$0 = $TR($EXPECT($R46, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10154
+ var InlineComment$0 = $TR($EXPECT($R47, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10118
10155
  return { $loc, token: $0 };
10119
10156
  });
10120
10157
  function InlineComment(ctx, state) {
@@ -10128,11 +10165,13 @@ var require_parser = __commonJS({
10128
10165
  function TrailingComment(ctx, state) {
10129
10166
  return $EVENT(ctx, state, "TrailingComment", TrailingComment$0);
10130
10167
  }
10131
- var _$0 = $P($C(NonNewlineWhitespace, InlineComment));
10168
+ var _$0 = $T($S($EXPECT($R48, "_ /(?=[ \\t\\/])/"), $P($C(NonNewlineWhitespace, InlineComment))), function(value) {
10169
+ return value[1];
10170
+ });
10132
10171
  function _(ctx, state) {
10133
10172
  return $EVENT(ctx, state, "_", _$0);
10134
10173
  }
10135
- var NonNewlineWhitespace$0 = $TR($EXPECT($R47, "NonNewlineWhitespace /[ \\t]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10174
+ var NonNewlineWhitespace$0 = $TR($EXPECT($R49, "NonNewlineWhitespace /[ \\t]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10136
10175
  return { $loc, token: $0 };
10137
10176
  });
10138
10177
  var NonNewlineWhitespace$1 = $T($S(CoffeeLineContinuationEnabled, $EXPECT($L111, 'NonNewlineWhitespace "\\\\\\\\"'), EOL), function(value) {
@@ -10192,7 +10231,7 @@ var require_parser = __commonJS({
10192
10231
  function SemicolonDelimiter(ctx, state) {
10193
10232
  return $EVENT(ctx, state, "SemicolonDelimiter", SemicolonDelimiter$0);
10194
10233
  }
10195
- var NonIdContinue$0 = $R$0($EXPECT($R48, "NonIdContinue /(?!\\p{ID_Continue})/"));
10234
+ var NonIdContinue$0 = $R$0($EXPECT($R50, "NonIdContinue /(?!\\p{ID_Continue})/"));
10196
10235
  function NonIdContinue(ctx, state) {
10197
10236
  return $EVENT(ctx, state, "NonIdContinue", NonIdContinue$0);
10198
10237
  }
@@ -10343,7 +10382,7 @@ var require_parser = __commonJS({
10343
10382
  var Dot$0 = $TV($EXPECT($L6, 'Dot "."'), function($skip, $loc, $0, $1) {
10344
10383
  return { $loc, token: $1 };
10345
10384
  });
10346
- var Dot$1 = $TS($S($EXPECT($R49, "Dot /['\u2019]s/"), _), function($skip, $loc, $0, $1, $2) {
10385
+ var Dot$1 = $TS($S($EXPECT($R51, "Dot /['\u2019]s/"), _), function($skip, $loc, $0, $1, $2) {
10347
10386
  var ws = $2;
10348
10387
  return [
10349
10388
  { $loc, token: "." },
@@ -10458,7 +10497,7 @@ var require_parser = __commonJS({
10458
10497
  function If(ctx, state) {
10459
10498
  return $EVENT(ctx, state, "If", If$0);
10460
10499
  }
10461
- var Import$0 = $TS($S($EXPECT($L15, 'Import "import"'), $Y($EXPECT($R50, "Import /\\s/"))), function($skip, $loc, $0, $1, $2) {
10500
+ var Import$0 = $TS($S($EXPECT($L15, 'Import "import"'), $Y($EXPECT($R52, "Import /\\s/"))), function($skip, $loc, $0, $1, $2) {
10462
10501
  return { $loc, token: $1 };
10463
10502
  });
10464
10503
  function Import(ctx, state) {
@@ -10927,7 +10966,7 @@ var require_parser = __commonJS({
10927
10966
  function JSXElementName(ctx, state) {
10928
10967
  return $EVENT_C(ctx, state, "JSXElementName", JSXElementName$$);
10929
10968
  }
10930
- var JSXIdentifierName$0 = $R$0($EXPECT($R51, "JSXIdentifierName /(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*/"));
10969
+ var JSXIdentifierName$0 = $R$0($EXPECT($R53, "JSXIdentifierName /(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*/"));
10931
10970
  function JSXIdentifierName(ctx, state) {
10932
10971
  return $EVENT(ctx, state, "JSXIdentifierName", JSXIdentifierName$0);
10933
10972
  }
@@ -11110,11 +11149,11 @@ var require_parser = __commonJS({
11110
11149
  function JSXAttribute(ctx, state) {
11111
11150
  return $EVENT_C(ctx, state, "JSXAttribute", JSXAttribute$$);
11112
11151
  }
11113
- var JSXAttributeSpace$0 = $R$0($EXPECT($R52, "JSXAttributeSpace /[\\s>]|\\/>/"));
11152
+ var JSXAttributeSpace$0 = $R$0($EXPECT($R54, "JSXAttributeSpace /[\\s>]|\\/>/"));
11114
11153
  function JSXAttributeSpace(ctx, state) {
11115
11154
  return $EVENT(ctx, state, "JSXAttributeSpace", JSXAttributeSpace$0);
11116
11155
  }
11117
- var JSXShorthandString$0 = $TR($EXPECT($R53, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11156
+ var JSXShorthandString$0 = $TR($EXPECT($R55, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11118
11157
  return quoteString($0);
11119
11158
  });
11120
11159
  var JSXShorthandString$1 = $TS($S(TemplateLiteral), function($skip, $loc, $0, $1) {
@@ -11148,7 +11187,7 @@ var require_parser = __commonJS({
11148
11187
  }
11149
11188
  return [open, value, close];
11150
11189
  });
11151
- var JSXAttributeValue$4 = $R$0($EXPECT($R54, `JSXAttributeValue /"[^"]*"|'[^']*'/`));
11190
+ var JSXAttributeValue$4 = $R$0($EXPECT($R56, `JSXAttributeValue /"[^"]*"|'[^']*'/`));
11152
11191
  var JSXAttributeValue$$ = [JSXAttributeValue$0, JSXAttributeValue$1, JSXAttributeValue$2, JSXAttributeValue$3, JSXAttributeValue$4];
11153
11192
  function JSXAttributeValue(ctx, state) {
11154
11193
  return $EVENT_C(ctx, state, "JSXAttributeValue", JSXAttributeValue$$);
@@ -11161,7 +11200,7 @@ var require_parser = __commonJS({
11161
11200
  function InlineJSXAttributeValue(ctx, state) {
11162
11201
  return $EVENT(ctx, state, "InlineJSXAttributeValue", InlineJSXAttributeValue$0);
11163
11202
  }
11164
- var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R55, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
11203
+ var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R57, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
11165
11204
  var op = $2;
11166
11205
  var rhs = $3;
11167
11206
  return [[], op, [], rhs];
@@ -11178,7 +11217,7 @@ var require_parser = __commonJS({
11178
11217
  function InlineJSXUnaryExpression(ctx, state) {
11179
11218
  return $EVENT(ctx, state, "InlineJSXUnaryExpression", InlineJSXUnaryExpression$0);
11180
11219
  }
11181
- var InlineJSXUnaryOp$0 = $TR($EXPECT($R56, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11220
+ var InlineJSXUnaryOp$0 = $TR($EXPECT($R58, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11182
11221
  return { $loc, token: $0 };
11183
11222
  });
11184
11223
  function InlineJSXUnaryOp(ctx, state) {
@@ -11390,13 +11429,13 @@ var require_parser = __commonJS({
11390
11429
  function JSXComment(ctx, state) {
11391
11430
  return $EVENT(ctx, state, "JSXComment", JSXComment$0);
11392
11431
  }
11393
- var JSXCommentContent$0 = $TR($EXPECT($R57, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11432
+ var JSXCommentContent$0 = $TR($EXPECT($R59, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11394
11433
  return { $loc, token: $0.replace(/\*\//g, "* /") };
11395
11434
  });
11396
11435
  function JSXCommentContent(ctx, state) {
11397
11436
  return $EVENT(ctx, state, "JSXCommentContent", JSXCommentContent$0);
11398
11437
  }
11399
- var JSXText$0 = $TR($EXPECT($R58, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11438
+ var JSXText$0 = $TR($EXPECT($R60, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
11400
11439
  return {
11401
11440
  type: "JSXText",
11402
11441
  token: $0,
@@ -11761,7 +11800,7 @@ var require_parser = __commonJS({
11761
11800
  function TypeProperty(ctx, state) {
11762
11801
  return $EVENT(ctx, state, "TypeProperty", TypeProperty$0);
11763
11802
  }
11764
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R59, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R60, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
11803
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R61, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R62, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
11765
11804
  function TypeIndexSignature(ctx, state) {
11766
11805
  return $EVENT(ctx, state, "TypeIndexSignature", TypeIndexSignature$0);
11767
11806
  }
@@ -12120,15 +12159,15 @@ var require_parser = __commonJS({
12120
12159
  function ThisType(ctx, state) {
12121
12160
  return $EVENT(ctx, state, "ThisType", ThisType$0);
12122
12161
  }
12123
- var Shebang$0 = $S($R$0($EXPECT($R61, "Shebang /#![^\\r\\n]*/")), EOL);
12162
+ var Shebang$0 = $S($R$0($EXPECT($R63, "Shebang /#![^\\r\\n]*/")), EOL);
12124
12163
  function Shebang(ctx, state) {
12125
12164
  return $EVENT(ctx, state, "Shebang", Shebang$0);
12126
12165
  }
12127
- var CivetPrologue$0 = $T($S($EXPECT($R62, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $E(EOS)), function(value) {
12166
+ var CivetPrologue$0 = $T($S($EXPECT($R64, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $E(EOS)), function(value) {
12128
12167
  var content = value[2];
12129
12168
  return content;
12130
12169
  });
12131
- var CivetPrologue$1 = $T($S($EXPECT($R62, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $E(EOS)), function(value) {
12170
+ var CivetPrologue$1 = $T($S($EXPECT($R64, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $E(EOS)), function(value) {
12132
12171
  var content = value[2];
12133
12172
  return content;
12134
12173
  });
@@ -12136,7 +12175,7 @@ var require_parser = __commonJS({
12136
12175
  function CivetPrologue(ctx, state) {
12137
12176
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
12138
12177
  }
12139
- var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R63, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12178
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R65, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
12140
12179
  var options = $3;
12141
12180
  return {
12142
12181
  type: "CivetPrologue",
@@ -12147,7 +12186,7 @@ var require_parser = __commonJS({
12147
12186
  function CivetPrologueContent(ctx, state) {
12148
12187
  return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
12149
12188
  }
12150
- var CivetOption$0 = $TR($EXPECT($R64, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12189
+ var CivetOption$0 = $TR($EXPECT($R66, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12151
12190
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
12152
12191
  if (l)
12153
12192
  return l.toUpperCase();
@@ -12164,11 +12203,11 @@ var require_parser = __commonJS({
12164
12203
  function CivetOption(ctx, state) {
12165
12204
  return $EVENT(ctx, state, "CivetOption", CivetOption$0);
12166
12205
  }
12167
- var UnknownPrologue$0 = $S($R$0($EXPECT($R62, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
12206
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R64, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
12168
12207
  function UnknownPrologue(ctx, state) {
12169
12208
  return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
12170
12209
  }
12171
- var TripleSlashDirective$0 = $S($R$0($EXPECT($R65, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12210
+ var TripleSlashDirective$0 = $S($R$0($EXPECT($R67, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
12172
12211
  function TripleSlashDirective(ctx, state) {
12173
12212
  return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
12174
12213
  }
@@ -12182,11 +12221,13 @@ var require_parser = __commonJS({
12182
12221
  function PrologueString(ctx, state) {
12183
12222
  return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
12184
12223
  }
12185
- var EOS$0 = $P(RestOfLine);
12224
+ var EOS$0 = $T($S($EXPECT($R68, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
12225
+ return value[1];
12226
+ });
12186
12227
  function EOS(ctx, state) {
12187
12228
  return $EVENT(ctx, state, "EOS", EOS$0);
12188
12229
  }
12189
- var EOL$0 = $TR($EXPECT($R66, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12230
+ var EOL$0 = $TR($EXPECT($R69, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12190
12231
  return { $loc, token: $0 };
12191
12232
  });
12192
12233
  function EOL(ctx, state) {
@@ -12680,7 +12721,7 @@ var require_parser = __commonJS({
12680
12721
  function Init(ctx, state) {
12681
12722
  return $EVENT(ctx, state, "Init", Init$0);
12682
12723
  }
12683
- var Indent$0 = $TR($EXPECT($R67, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12724
+ var Indent$0 = $TR($EXPECT($R70, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12684
12725
  const level = getIndentLevel($0, module.config.tab);
12685
12726
  return {
12686
12727
  $loc,
@@ -13180,6 +13221,7 @@ var require_parser = __commonJS({
13180
13221
  exports.TemplateBlockCharacters = TemplateBlockCharacters;
13181
13222
  exports.ReservedWord = ReservedWord;
13182
13223
  exports.Comment = Comment;
13224
+ exports._Comment = _Comment;
13183
13225
  exports.SingleLineComment = SingleLineComment;
13184
13226
  exports.JSSingleLineComment = JSSingleLineComment;
13185
13227
  exports.MultiLineComment = MultiLineComment;
@@ -13494,6 +13536,7 @@ var require_parser = __commonJS({
13494
13536
  makeRef,
13495
13537
  maybeRef,
13496
13538
  modifyString,
13539
+ negateCondition,
13497
13540
  processAssignmentDeclaration,
13498
13541
  processBinaryOpExpression,
13499
13542
  processCallMemberExpression,
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,31 +15,14 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var ts_diagnostic_exports = {};
30
20
  __export(ts_diagnostic_exports, {
31
- convertDiagnostic: () => convertDiagnostic,
32
21
  flattenDiagnosticMessageText: () => flattenDiagnosticMessageText,
33
- rangeFromTextSpan: () => rangeFromTextSpan,
34
22
  remapPosition: () => remapPosition,
35
23
  remapRange: () => remapRange
36
24
  });
37
25
  module.exports = __toCommonJS(ts_diagnostic_exports);
38
- var import_vscode_languageserver = __toESM(require("vscode-languageserver"));
39
- var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
40
- let DiagnosticCategory = {};
41
- DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
42
- DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
43
- DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
44
- DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
45
26
  function remapPosition(position, sourcemapLines) {
46
27
  if (!sourcemapLines)
47
28
  return position;
@@ -102,51 +83,9 @@ function flattenDiagnosticMessageText(diag, indent = 0) {
102
83
  }
103
84
  return result;
104
85
  }
105
- function rangeFromTextSpan(span, document) {
106
- return {
107
- start: document.positionAt(span.start),
108
- end: document.positionAt(span.start + span.length)
109
- };
110
- }
111
- function convertDiagnostic(diagnostic, document, sourcemapLines) {
112
- return {
113
- message: flattenDiagnosticMessageText(diagnostic.messageText),
114
- range: remapRange(
115
- rangeFromTextSpan(
116
- {
117
- start: diagnostic.start || 0,
118
- length: diagnostic.length ?? 1
119
- },
120
- document
121
- ),
122
- sourcemapLines
123
- ),
124
- severity: diagnosticCategoryToSeverity(diagnostic.category),
125
- code: diagnostic.code,
126
- source: diagnostic.source || "typescript"
127
- };
128
- }
129
- function diagnosticCategoryToSeverity(category) {
130
- switch (category) {
131
- case DiagnosticCategory.Warning: {
132
- return import_vscode_languageserver.DiagnosticSeverity.Warning;
133
- }
134
- case DiagnosticCategory.Error: {
135
- return import_vscode_languageserver.DiagnosticSeverity.Error;
136
- }
137
- case DiagnosticCategory.Suggestion: {
138
- return import_vscode_languageserver.DiagnosticSeverity.Hint;
139
- }
140
- case DiagnosticCategory.Message: {
141
- return import_vscode_languageserver.DiagnosticSeverity.Information;
142
- }
143
- }
144
- }
145
86
  // Annotate the CommonJS export names for ESM import in node:
146
87
  0 && (module.exports = {
147
- convertDiagnostic,
148
88
  flattenDiagnosticMessageText,
149
- rangeFromTextSpan,
150
89
  remapPosition,
151
90
  remapRange
152
91
  });
@@ -1,10 +1,3 @@
1
- let DiagnosticCategory = {};
2
- DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
3
- DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
4
- DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
5
- DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
6
- import vs, { DiagnosticSeverity, Position, Range } from "vscode-languageserver";
7
- import { TextDocument } from "vscode-languageserver-textdocument";
8
1
  function remapPosition(position, sourcemapLines) {
9
2
  if (!sourcemapLines)
10
3
  return position;
@@ -65,50 +58,8 @@ function flattenDiagnosticMessageText(diag, indent = 0) {
65
58
  }
66
59
  return result;
67
60
  }
68
- function rangeFromTextSpan(span, document) {
69
- return {
70
- start: document.positionAt(span.start),
71
- end: document.positionAt(span.start + span.length)
72
- };
73
- }
74
- function convertDiagnostic(diagnostic, document, sourcemapLines) {
75
- return {
76
- message: flattenDiagnosticMessageText(diagnostic.messageText),
77
- range: remapRange(
78
- rangeFromTextSpan(
79
- {
80
- start: diagnostic.start || 0,
81
- length: diagnostic.length ?? 1
82
- },
83
- document
84
- ),
85
- sourcemapLines
86
- ),
87
- severity: diagnosticCategoryToSeverity(diagnostic.category),
88
- code: diagnostic.code,
89
- source: diagnostic.source || "typescript"
90
- };
91
- }
92
- function diagnosticCategoryToSeverity(category) {
93
- switch (category) {
94
- case DiagnosticCategory.Warning: {
95
- return DiagnosticSeverity.Warning;
96
- }
97
- case DiagnosticCategory.Error: {
98
- return DiagnosticSeverity.Error;
99
- }
100
- case DiagnosticCategory.Suggestion: {
101
- return DiagnosticSeverity.Hint;
102
- }
103
- case DiagnosticCategory.Message: {
104
- return DiagnosticSeverity.Information;
105
- }
106
- }
107
- }
108
61
  export {
109
- convertDiagnostic,
110
62
  flattenDiagnosticMessageText,
111
- rangeFromTextSpan,
112
63
  remapPosition,
113
64
  remapRange
114
65
  };