@danielx/civet 0.6.88 → 0.6.90

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
@@ -225,6 +225,9 @@ function hasAwait(exp) {
225
225
  function hasYield(exp) {
226
226
  return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
227
227
  }
228
+ function hasImportDeclaration(exp) {
229
+ return gatherRecursiveWithinFunction(exp, ({ type }) => type === "ImportDeclaration").length > 0;
230
+ }
228
231
  function deepCopy(node) {
229
232
  if (node == null)
230
233
  return node;
@@ -386,9 +389,10 @@ function parenthesizeType(type) {
386
389
  }
387
390
  return ["(", type, ")"];
388
391
  }
389
- function wrapIIFE(expressions, async) {
392
+ function wrapIIFE(expressions, asyncFlag) {
390
393
  let prefix;
391
- if (async) {
394
+ let async;
395
+ if (asyncFlag) {
392
396
  async = "async ";
393
397
  } else if (hasAwait(expressions)) {
394
398
  async = "async ";
@@ -576,16 +580,16 @@ function blockWithPrefix(prefixStatements, block) {
576
580
  expressions,
577
581
  children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
578
582
  };
579
- if (block.bare) {
580
- block.children = [[" {"], ...block.children, "}"];
581
- block.bare = false;
582
- }
583
+ braceBlock(block);
583
584
  updateParentPointers(block);
584
585
  }
585
586
  return block;
586
587
  }
587
588
  function braceBlock(block) {
588
589
  if (block.bare) {
590
+ if (block.children === block.expressions) {
591
+ block.children = [block.expressions];
592
+ }
589
593
  block.children.unshift(" {");
590
594
  block.children.push("}");
591
595
  return block.bare = false;
@@ -595,8 +599,13 @@ function braceBlock(block) {
595
599
  }
596
600
  function duplicateBlock(block) {
597
601
  const expressions = [...block.expressions];
598
- const children = [...block.children];
599
- children.splice(children.indexOf(block.expressions), 1, expressions);
602
+ let children;
603
+ if (block.children === block.expressions) {
604
+ children = expressions;
605
+ } else {
606
+ children = [...block.children];
607
+ children.splice(children.indexOf(block.expressions), 1, expressions);
608
+ }
600
609
  return {
601
610
  ...block,
602
611
  expressions,
@@ -1881,7 +1890,7 @@ function insertReturn(node, outerNode = node) {
1881
1890
  return;
1882
1891
  case "IfStatement":
1883
1892
  insertReturn(exp.then);
1884
- if (exp.else)
1893
+ if (exp.else && exp.else.length !== 0)
1885
1894
  insertReturn(exp.else[2]);
1886
1895
  else
1887
1896
  exp.children.push(["", {
@@ -2013,8 +2022,7 @@ function expressionizeIteration(exp) {
2013
2022
  throw new Error("Could not find iteration statement in iteration expression");
2014
2023
  }
2015
2024
  if (subtype === "DoStatement") {
2016
- insertReturn(block);
2017
- children.splice(i, 1, ...wrapIIFE(["", statement, void 0], async));
2025
+ children.splice(i, 1, ...wrapIIFE([["", statement, void 0]], async));
2018
2026
  updateParentPointers(exp);
2019
2027
  return;
2020
2028
  }
@@ -2175,7 +2183,8 @@ function processDeclarationCondition(condition, rootCondition, parent) {
2175
2183
  }
2176
2184
  const { decl, bindings } = condition.declaration;
2177
2185
  const binding = bindings[0];
2178
- const { pattern, suffix, initializer, splices, thisAssignments } = binding;
2186
+ let { pattern, suffix, initializer, splices, thisAssignments } = binding;
2187
+ const nullCheck = suffix?.optional && !suffix.t && !suffix.nonnull;
2179
2188
  let ref = prependStatementExpressionBlock(initializer, parent);
2180
2189
  if (ref) {
2181
2190
  Object.assign(condition, {
@@ -2189,11 +2198,16 @@ function processDeclarationCondition(condition, rootCondition, parent) {
2189
2198
  ref = makeRef();
2190
2199
  const grandparent = condition.parent?.parent;
2191
2200
  const children = (
2192
- // Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
2201
+ // Wrap declaration that is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
2202
+ // to satisfy eslint's no-cond-assign rule
2193
2203
  // More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
2194
- // @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
2195
- pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
2204
+ pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "IterationStatement") && !nullCheck ? ["(", ref, initializer, ")"] : [ref, initializer]
2196
2205
  );
2206
+ if (nullCheck) {
2207
+ children.unshift("(");
2208
+ children.push(") != null");
2209
+ suffix = void 0;
2210
+ }
2197
2211
  Object.assign(condition, {
2198
2212
  type: "AssignmentExpression",
2199
2213
  children,
@@ -3256,13 +3270,17 @@ __export(lib_exports, {
3256
3270
  forRange: () => forRange,
3257
3271
  gatherBindingCode: () => gatherBindingCode,
3258
3272
  gatherRecursive: () => gatherRecursive,
3273
+ gatherRecursiveAll: () => gatherRecursiveAll,
3274
+ gatherRecursiveWithinFunction: () => gatherRecursiveWithinFunction,
3259
3275
  getIndentLevel: () => getIndentLevel,
3260
3276
  getPrecedence: () => getPrecedence,
3261
3277
  getTrimmingSpace: () => getTrimmingSpace,
3262
3278
  hasAwait: () => hasAwait,
3279
+ hasImportDeclaration: () => hasImportDeclaration,
3263
3280
  hasYield: () => hasYield,
3264
3281
  insertTrimmingSpace: () => insertTrimmingSpace,
3265
3282
  isEmptyBareBlock: () => isEmptyBareBlock,
3283
+ isFunction: () => isFunction,
3266
3284
  isWhitespaceOrEmpty: () => isWhitespaceOrEmpty,
3267
3285
  lastAccessInCallExpression: () => lastAccessInCallExpression,
3268
3286
  literalValue: () => literalValue,
@@ -5059,6 +5077,7 @@ var require_parser = __commonJS({
5059
5077
  MemberBracketContent,
5060
5078
  SliceParameters,
5061
5079
  AccessStart,
5080
+ ImplicitAccessStart,
5062
5081
  PropertyAccessModifier,
5063
5082
  PropertyAccess,
5064
5083
  PropertyGlob,
@@ -5193,6 +5212,7 @@ var require_parser = __commonJS({
5193
5212
  BinaryOp,
5194
5213
  _BinaryOp,
5195
5214
  BinaryOpSymbol,
5215
+ ActualIn,
5196
5216
  CoffeeOfOp,
5197
5217
  NotOp,
5198
5218
  Xor,
@@ -5905,7 +5925,7 @@ var require_parser = __commonJS({
5905
5925
  var $R4 = $R(new RegExp("[ \\t]", "suy"));
5906
5926
  var $R5 = $R(new RegExp("(?=['\"`])", "suy"));
5907
5927
  var $R6 = $R(new RegExp("(?=[\\/?])", "suy"));
5908
- var $R7 = $R(new RegExp("(?=[\\/\\[{?.!@'\u2019:])", "suy"));
5928
+ var $R7 = $R(new RegExp("(?=[\\/\\[{?.!@#'\u2019:])", "suy"));
5909
5929
  var $R8 = $R(new RegExp("[)}]", "suy"));
5910
5930
  var $R9 = $R(new RegExp("\\+\\+|--|[\\+-]\\S", "suy"));
5911
5931
  var $R10 = $R(new RegExp("[&]", "suy"));
@@ -5967,29 +5987,30 @@ var require_parser = __commonJS({
5967
5987
  var $R66 = $R(new RegExp("[ \\t]+", "suy"));
5968
5988
  var $R67 = $R(new RegExp("(?=\\s|\\/|#)", "suy"));
5969
5989
  var $R68 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
5970
- var $R69 = $R(new RegExp("['\u2019]s", "suy"));
5971
- var $R70 = $R(new RegExp("\\s", "suy"));
5972
- var $R71 = $R(new RegExp("(?=[<])", "suy"));
5973
- var $R72 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
5974
- var $R73 = $R(new RegExp("[!+-]", "suy"));
5975
- var $R74 = $R(new RegExp("[\\s>]|\\/>", "suy"));
5976
- var $R75 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
5977
- var $R76 = $R(new RegExp(`"[^"]*"|'[^']*'`, "suy"));
5978
- var $R77 = $R(new RegExp("[<>]", "suy"));
5979
- var $R78 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
5980
- var $R79 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
5981
- var $R80 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
5982
- var $R81 = $R(new RegExp("[+-]?", "suy"));
5983
- var $R82 = $R(new RegExp("(?=if|unless)", "suy"));
5984
- var $R83 = $R(new RegExp("#![^\\r\\n]*", "suy"));
5985
- var $R84 = $R(new RegExp("[\\t ]*", "suy"));
5986
- var $R85 = $R(new RegExp("[ \\t]*", "suy"));
5987
- var $R86 = $R(new RegExp("[\\s]*", "suy"));
5988
- var $R87 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
5989
- var $R88 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
5990
- var $R89 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
5991
- var $R90 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
5992
- var $R91 = $R(new RegExp("[^]*", "suy"));
5990
+ var $R69 = $R(new RegExp("[=:]", "suy"));
5991
+ var $R70 = $R(new RegExp("['\u2019]s", "suy"));
5992
+ var $R71 = $R(new RegExp("\\s", "suy"));
5993
+ var $R72 = $R(new RegExp("(?=[<])", "suy"));
5994
+ var $R73 = $R(new RegExp("(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*", "suy"));
5995
+ var $R74 = $R(new RegExp("[!+-]", "suy"));
5996
+ var $R75 = $R(new RegExp("[\\s>]|\\/>", "suy"));
5997
+ var $R76 = $R(new RegExp("(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+", "suy"));
5998
+ var $R77 = $R(new RegExp(`"[^"]*"|'[^']*'`, "suy"));
5999
+ var $R78 = $R(new RegExp("[<>]", "suy"));
6000
+ var $R79 = $R(new RegExp("[!~+-](?!\\s|[!~+-]*&)", "suy"));
6001
+ var $R80 = $R(new RegExp("(?:-[^-]|[^-]*)*", "suy"));
6002
+ var $R81 = $R(new RegExp("[^{}<>\\r\\n]+", "suy"));
6003
+ var $R82 = $R(new RegExp("[+-]?", "suy"));
6004
+ var $R83 = $R(new RegExp("(?=if|unless)", "suy"));
6005
+ var $R84 = $R(new RegExp("#![^\\r\\n]*", "suy"));
6006
+ var $R85 = $R(new RegExp("[\\t ]*", "suy"));
6007
+ var $R86 = $R(new RegExp("[ \\t]*", "suy"));
6008
+ var $R87 = $R(new RegExp("[\\s]*", "suy"));
6009
+ var $R88 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
6010
+ var $R89 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
6011
+ var $R90 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
6012
+ var $R91 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
6013
+ var $R92 = $R(new RegExp("[^]*", "suy"));
5993
6014
  var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
5994
6015
  var statements = $4;
5995
6016
  processProgram({
@@ -7105,7 +7126,8 @@ var require_parser = __commonJS({
7105
7126
  return $EVENT_C(ctx, state, "FieldDefinition", FieldDefinition$$);
7106
7127
  }
7107
7128
  var ThisLiteral$0 = This;
7108
- var ThisLiteral$1 = $TS($S(AtThis, $TEXT($S($E(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
7129
+ var ThisLiteral$1 = HashThis;
7130
+ var ThisLiteral$2 = $TS($S(AtThis, $TEXT($S($E(Hash), IdentifierName))), function($skip, $loc, $0, $1, $2) {
7109
7131
  var at = $1;
7110
7132
  var id = $2;
7111
7133
  return {
@@ -7118,20 +7140,20 @@ var require_parser = __commonJS({
7118
7140
  thisShorthand: true
7119
7141
  };
7120
7142
  });
7121
- var ThisLiteral$2 = AtThis;
7122
- var ThisLiteral$3 = HashThis;
7143
+ var ThisLiteral$3 = AtThis;
7123
7144
  var ThisLiteral$$ = [ThisLiteral$0, ThisLiteral$1, ThisLiteral$2, ThisLiteral$3];
7124
7145
  function ThisLiteral(ctx, state) {
7125
7146
  return $EVENT_C(ctx, state, "ThisLiteral", ThisLiteral$$);
7126
7147
  }
7127
- var HashThis$0 = $TS($S(LengthShorthand, $E($S($Y($S($P(_), $C($S(Not, __, In), In))), $EXPECT($L0, 'HashThis ""')))), function($skip, $loc, $0, $1, $2) {
7128
- var id = $1;
7129
- var beforeIn = $2;
7130
- if (beforeIn != null)
7148
+ var HashThis$0 = $TS($S($E(AtThis), LengthShorthand, $E($S($Y($S(_, $E($S(Not, __)), ActualIn)), $EXPECT($L0, 'HashThis ""')))), function($skip, $loc, $0, $1, $2, $3) {
7149
+ var at = $1;
7150
+ var id = $2;
7151
+ var beforeIn = $3;
7152
+ if (beforeIn != null && at == null)
7131
7153
  return ['"', id.name, '"'];
7132
7154
  return {
7133
7155
  type: "MemberExpression",
7134
- children: ["this", {
7156
+ children: [at ?? "this", {
7135
7157
  type: "PropertyAccess",
7136
7158
  name: id.name,
7137
7159
  children: [".", id]
@@ -7139,7 +7161,7 @@ var require_parser = __commonJS({
7139
7161
  thisShorthand: true
7140
7162
  };
7141
7163
  });
7142
- var HashThis$1 = $TS($S(PrivateIdentifier, $Y($S($P(_), $C($S(Not, __, In), In)))), function($skip, $loc, $0, $1, $2) {
7164
+ var HashThis$1 = $TS($S(PrivateIdentifier, $Y($S(_, $E($S(Not, __)), ActualIn))), function($skip, $loc, $0, $1, $2) {
7143
7165
  var id = $1;
7144
7166
  return id;
7145
7167
  });
@@ -7310,7 +7332,7 @@ var require_parser = __commonJS({
7310
7332
  function MemberBase(ctx, state) {
7311
7333
  return $EVENT_C(ctx, state, "MemberBase", MemberBase$$);
7312
7334
  }
7313
- var MemberExpressionRest$0 = $TS($S($EXPECT($R7, "MemberExpressionRest /(?=[\\/\\[{?.!@'\u2019:])/"), $Q(InlineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2, $3) {
7335
+ var MemberExpressionRest$0 = $TS($S($EXPECT($R7, "MemberExpressionRest /(?=[\\/\\[{?.!@#'\u2019:])/"), $Q(InlineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2, $3) {
7314
7336
  var comments = $2;
7315
7337
  var body = $3;
7316
7338
  if (Array.isArray(body))
@@ -7443,16 +7465,27 @@ var require_parser = __commonJS({
7443
7465
  var AccessStart$0 = $TS($S($E(PropertyAccessModifier), Dot, $N(Dot)), function($skip, $loc, $0, $1, $2, $3) {
7444
7466
  var modifier = $1;
7445
7467
  var dot = $2;
7446
- let children = modifier ? [modifier, dot] : [dot];
7447
7468
  return {
7448
7469
  type: "AccessStart",
7449
- children,
7470
+ children: modifier ? [modifier, dot] : [dot],
7450
7471
  optional: modifier?.token === "?"
7451
7472
  };
7452
7473
  });
7453
7474
  function AccessStart(ctx, state) {
7454
7475
  return $EVENT(ctx, state, "AccessStart", AccessStart$0);
7455
7476
  }
7477
+ var ImplicitAccessStart$0 = $TS($S($E(PropertyAccessModifier), InsertDot, $N(Dot)), function($skip, $loc, $0, $1, $2, $3) {
7478
+ var modifier = $1;
7479
+ var dot = $2;
7480
+ return {
7481
+ type: "AccessStart",
7482
+ children: modifier ? [modifier, dot] : [dot],
7483
+ optional: modifier?.token === "?"
7484
+ };
7485
+ });
7486
+ function ImplicitAccessStart(ctx, state) {
7487
+ return $EVENT(ctx, state, "ImplicitAccessStart", ImplicitAccessStart$0);
7488
+ }
7456
7489
  var PropertyAccessModifier$0 = QuestionMark;
7457
7490
  var PropertyAccessModifier$1 = NonNullAssertion;
7458
7491
  var PropertyAccessModifier$$ = [PropertyAccessModifier$0, PropertyAccessModifier$1];
@@ -7494,15 +7527,24 @@ var require_parser = __commonJS({
7494
7527
  var dot = $1;
7495
7528
  var comments = $2;
7496
7529
  var id = $3;
7497
- const children = [dot, ...comments, ...id.children];
7498
7530
  return {
7499
7531
  type: "PropertyAccess",
7500
7532
  name: id.name,
7501
7533
  dot,
7502
- children
7534
+ children: [dot, ...comments, ...id.children]
7503
7535
  };
7504
7536
  });
7505
- var PropertyAccess$3 = $TS($S(CoffeePrototypeEnabled, DoubleColon, $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
7537
+ var PropertyAccess$3 = $TS($S(ImplicitAccessStart, $C(PrivateIdentifier, LengthShorthand)), function($skip, $loc, $0, $1, $2) {
7538
+ var dot = $1;
7539
+ var id = $2;
7540
+ return {
7541
+ type: "PropertyAccess",
7542
+ name: id.name,
7543
+ dot,
7544
+ children: [dot, ...id.children]
7545
+ };
7546
+ });
7547
+ var PropertyAccess$4 = $TS($S(CoffeePrototypeEnabled, DoubleColon, $E(IdentifierName)), function($skip, $loc, $0, $1, $2, $3) {
7506
7548
  var p = $2;
7507
7549
  var id = $3;
7508
7550
  if (id) {
@@ -7523,7 +7565,7 @@ var require_parser = __commonJS({
7523
7565
  };
7524
7566
  }
7525
7567
  });
7526
- var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1, PropertyAccess$2, PropertyAccess$3];
7568
+ var PropertyAccess$$ = [PropertyAccess$0, PropertyAccess$1, PropertyAccess$2, PropertyAccess$3, PropertyAccess$4];
7527
7569
  function PropertyAccess(ctx, state) {
7528
7570
  return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
7529
7571
  }
@@ -8807,11 +8849,14 @@ var require_parser = __commonJS({
8807
8849
  });
8808
8850
  var NonSingleBracedBlock$1 = ImplicitNestedBlock;
8809
8851
  var NonSingleBracedBlock$2 = $TS($S(InsertOpenBrace, NestedImplicitObjectLiteral, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3) {
8852
+ var o = $1;
8810
8853
  var s = $2;
8854
+ var c = $3;
8855
+ const expressions = [s];
8811
8856
  return {
8812
8857
  type: "BlockStatement",
8813
- expressions: [s],
8814
- children: $0
8858
+ expressions,
8859
+ children: [o, expressions, c]
8815
8860
  };
8816
8861
  });
8817
8862
  var NonSingleBracedBlock$$ = [NonSingleBracedBlock$0, NonSingleBracedBlock$1, NonSingleBracedBlock$2];
@@ -9212,7 +9257,7 @@ var require_parser = __commonJS({
9212
9257
  var ArrayElementExpression$1 = $T($S(ImplicitObjectLiteral, $Y(ArrayElementDelimiter)), function(value) {
9213
9258
  return value[0];
9214
9259
  });
9215
- var ArrayElementExpression$2 = $TS($S($E(ExtendedExpression), __, DotDotDot, $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
9260
+ var ArrayElementExpression$2 = $TS($S(ExtendedExpression, $E(_), DotDotDot, $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2, $3, $4) {
9216
9261
  var exp = $1;
9217
9262
  var ws = $2;
9218
9263
  var dots = $3;
@@ -9221,7 +9266,7 @@ var require_parser = __commonJS({
9221
9266
  }
9222
9267
  return {
9223
9268
  type: "SpreadElement",
9224
- children: [...ws, dots, exp],
9269
+ children: [ws, dots, exp],
9225
9270
  names: exp.names
9226
9271
  };
9227
9272
  });
@@ -10231,6 +10276,16 @@ var require_parser = __commonJS({
10231
10276
  function BinaryOpSymbol(ctx, state) {
10232
10277
  return $EVENT_C(ctx, state, "BinaryOpSymbol", BinaryOpSymbol$$);
10233
10278
  }
10279
+ var ActualIn$0 = $T($S(CoffeeOfEnabled, Of), function(value) {
10280
+ return value[1];
10281
+ });
10282
+ var ActualIn$1 = $T($S($N(CoffeeOfEnabled), In), function(value) {
10283
+ return value[1];
10284
+ });
10285
+ var ActualIn$$ = [ActualIn$0, ActualIn$1];
10286
+ function ActualIn(ctx, state) {
10287
+ return $EVENT_C(ctx, state, "ActualIn", ActualIn$$);
10288
+ }
10234
10289
  var CoffeeOfOp$0 = $T($S(Of), function(value) {
10235
10290
  return "in";
10236
10291
  });
@@ -12544,7 +12599,7 @@ var require_parser = __commonJS({
12544
12599
  function CoffeeSubstitutionStart(ctx, state) {
12545
12600
  return $EVENT(ctx, state, "CoffeeSubstitutionStart", CoffeeSubstitutionStart$0);
12546
12601
  }
12547
- var Colon$0 = $TS($S($EXPECT($L15, 'Colon ":"'), $N($EXPECT($L3, 'Colon "="'))), function($skip, $loc, $0, $1, $2) {
12602
+ var Colon$0 = $TS($S($EXPECT($L15, 'Colon ":"'), $N($EXPECT($R69, "Colon /[=:]/"))), function($skip, $loc, $0, $1, $2) {
12548
12603
  return { $loc, token: $1 };
12549
12604
  });
12550
12605
  function Colon(ctx, state) {
@@ -12589,7 +12644,7 @@ var require_parser = __commonJS({
12589
12644
  var Dot$0 = $TV($EXPECT($L7, 'Dot "."'), function($skip, $loc, $0, $1) {
12590
12645
  return { $loc, token: $1 };
12591
12646
  });
12592
- var Dot$1 = $TS($S($EXPECT($R69, "Dot /['\u2019]s/"), _), function($skip, $loc, $0, $1, $2) {
12647
+ var Dot$1 = $TS($S($EXPECT($R70, "Dot /['\u2019]s/"), _), function($skip, $loc, $0, $1, $2) {
12593
12648
  var ws = $2;
12594
12649
  return [
12595
12650
  { $loc, token: "." },
@@ -12710,7 +12765,7 @@ var require_parser = __commonJS({
12710
12765
  function If(ctx, state) {
12711
12766
  return $EVENT(ctx, state, "If", If$0);
12712
12767
  }
12713
- var Import$0 = $TS($S($EXPECT($L20, 'Import "import"'), $Y($EXPECT($R70, "Import /\\s/"))), function($skip, $loc, $0, $1, $2) {
12768
+ var Import$0 = $TS($S($EXPECT($L20, 'Import "import"'), $Y($EXPECT($R71, "Import /\\s/"))), function($skip, $loc, $0, $1, $2) {
12714
12769
  return { $loc, token: $1 };
12715
12770
  });
12716
12771
  function Import(ctx, state) {
@@ -13050,7 +13105,7 @@ var require_parser = __commonJS({
13050
13105
  function JSXImplicitFragment(ctx, state) {
13051
13106
  return $EVENT(ctx, state, "JSXImplicitFragment", JSXImplicitFragment$0);
13052
13107
  }
13053
- var JSXTag$0 = $T($S($EXPECT($R71, "JSXTag /(?=[<])/"), _JSXTag), function(value) {
13108
+ var JSXTag$0 = $T($S($EXPECT($R72, "JSXTag /(?=[<])/"), _JSXTag), function(value) {
13054
13109
  return value[1];
13055
13110
  });
13056
13111
  function JSXTag(ctx, state) {
@@ -13197,7 +13252,7 @@ var require_parser = __commonJS({
13197
13252
  function JSXElementName(ctx, state) {
13198
13253
  return $EVENT_C(ctx, state, "JSXElementName", JSXElementName$$);
13199
13254
  }
13200
- var JSXIdentifierName$0 = $R$0($EXPECT($R72, "JSXIdentifierName /(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*/"));
13255
+ var JSXIdentifierName$0 = $R$0($EXPECT($R73, "JSXIdentifierName /(?:\\p{ID_Start}|[_$])(?:\\p{ID_Continue}|[\\u200C\\u200D$-])*/"));
13201
13256
  function JSXIdentifierName(ctx, state) {
13202
13257
  return $EVENT(ctx, state, "JSXIdentifierName", JSXIdentifierName$0);
13203
13258
  }
@@ -13376,7 +13431,7 @@ var require_parser = __commonJS({
13376
13431
  class: $2
13377
13432
  };
13378
13433
  });
13379
- var JSXAttribute$7 = $TS($S($TEXT($EXPECT($R73, "JSXAttribute /[!+-]/")), JSXAttributeName, $Y(JSXAttributeSpace)), function($skip, $loc, $0, $1, $2, $3) {
13434
+ var JSXAttribute$7 = $TS($S($TEXT($EXPECT($R74, "JSXAttribute /[!+-]/")), JSXAttributeName, $Y(JSXAttributeSpace)), function($skip, $loc, $0, $1, $2, $3) {
13380
13435
  var toggle = $1;
13381
13436
  var id = $2;
13382
13437
  const value = toggle === "+" ? "true" : "false";
@@ -13386,11 +13441,11 @@ var require_parser = __commonJS({
13386
13441
  function JSXAttribute(ctx, state) {
13387
13442
  return $EVENT_C(ctx, state, "JSXAttribute", JSXAttribute$$);
13388
13443
  }
13389
- var JSXAttributeSpace$0 = $R$0($EXPECT($R74, "JSXAttributeSpace /[\\s>]|\\/>/"));
13444
+ var JSXAttributeSpace$0 = $R$0($EXPECT($R75, "JSXAttributeSpace /[\\s>]|\\/>/"));
13390
13445
  function JSXAttributeSpace(ctx, state) {
13391
13446
  return $EVENT(ctx, state, "JSXAttributeSpace", JSXAttributeSpace$0);
13392
13447
  }
13393
- var JSXShorthandString$0 = $TR($EXPECT($R75, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13448
+ var JSXShorthandString$0 = $TR($EXPECT($R76, "JSXShorthandString /(?:[\\w\\-:]+|\\([^()]*\\)|\\[[^\\[\\]]*\\])+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13394
13449
  return quoteString($0);
13395
13450
  });
13396
13451
  var JSXShorthandString$1 = $TS($S(TemplateLiteral), function($skip, $loc, $0, $1) {
@@ -13424,7 +13479,7 @@ var require_parser = __commonJS({
13424
13479
  }
13425
13480
  return [open, value, close];
13426
13481
  });
13427
- var JSXAttributeValue$4 = $R$0($EXPECT($R76, `JSXAttributeValue /"[^"]*"|'[^']*'/`));
13482
+ var JSXAttributeValue$4 = $R$0($EXPECT($R77, `JSXAttributeValue /"[^"]*"|'[^']*'/`));
13428
13483
  var JSXAttributeValue$$ = [JSXAttributeValue$0, JSXAttributeValue$1, JSXAttributeValue$2, JSXAttributeValue$3, JSXAttributeValue$4];
13429
13484
  function JSXAttributeValue(ctx, state) {
13430
13485
  return $EVENT_C(ctx, state, "JSXAttributeValue", JSXAttributeValue$$);
@@ -13437,7 +13492,7 @@ var require_parser = __commonJS({
13437
13492
  function InlineJSXAttributeValue(ctx, state) {
13438
13493
  return $EVENT(ctx, state, "InlineJSXAttributeValue", InlineJSXAttributeValue$0);
13439
13494
  }
13440
- var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R77, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
13495
+ var InlineJSXBinaryOpRHS$0 = $TS($S($N($EXPECT($R78, "InlineJSXBinaryOpRHS /[<>]/")), BinaryOp, InlineJSXUnaryExpression), function($skip, $loc, $0, $1, $2, $3) {
13441
13496
  var op = $2;
13442
13497
  var rhs = $3;
13443
13498
  return [[], op, [], rhs];
@@ -13454,7 +13509,7 @@ var require_parser = __commonJS({
13454
13509
  function InlineJSXUnaryExpression(ctx, state) {
13455
13510
  return $EVENT(ctx, state, "InlineJSXUnaryExpression", InlineJSXUnaryExpression$0);
13456
13511
  }
13457
- var InlineJSXUnaryOp$0 = $TR($EXPECT($R78, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13512
+ var InlineJSXUnaryOp$0 = $TR($EXPECT($R79, "InlineJSXUnaryOp /[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13458
13513
  return { $loc, token: $0 };
13459
13514
  });
13460
13515
  function InlineJSXUnaryOp(ctx, state) {
@@ -13670,13 +13725,13 @@ var require_parser = __commonJS({
13670
13725
  function JSXComment(ctx, state) {
13671
13726
  return $EVENT(ctx, state, "JSXComment", JSXComment$0);
13672
13727
  }
13673
- var JSXCommentContent$0 = $TR($EXPECT($R79, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13728
+ var JSXCommentContent$0 = $TR($EXPECT($R80, "JSXCommentContent /(?:-[^-]|[^-]*)*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13674
13729
  return { $loc, token: $0.replace(/\*\//g, "* /") };
13675
13730
  });
13676
13731
  function JSXCommentContent(ctx, state) {
13677
13732
  return $EVENT(ctx, state, "JSXCommentContent", JSXCommentContent$0);
13678
13733
  }
13679
- var JSXText$0 = $TR($EXPECT($R80, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13734
+ var JSXText$0 = $TR($EXPECT($R81, "JSXText /[^{}<>\\r\\n]+/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13680
13735
  return {
13681
13736
  type: "JSXText",
13682
13737
  token: $0,
@@ -14097,7 +14152,7 @@ var require_parser = __commonJS({
14097
14152
  function TypeProperty(ctx, state) {
14098
14153
  return $EVENT(ctx, state, "TypeProperty", TypeProperty$0);
14099
14154
  }
14100
- var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R81, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R17, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
14155
+ var TypeIndexSignature$0 = $S($E($S($R$0($EXPECT($R82, "TypeIndexSignature /[+-]?/")), Readonly, NotDedented)), OpenBracket, TypeIndex, CloseBracket, $E($S(__, $R$0($EXPECT($R17, "TypeIndexSignature /[+-]/")), $Y($S($E(_), QuestionMark)))));
14101
14156
  function TypeIndexSignature(ctx, state) {
14102
14157
  return $EVENT(ctx, state, "TypeIndexSignature", TypeIndexSignature$0);
14103
14158
  }
@@ -14117,11 +14172,13 @@ var require_parser = __commonJS({
14117
14172
  return { "type": "TypeSuffix", "ts": true, "optional": optional, "children": value };
14118
14173
  });
14119
14174
  var TypeSuffix$2 = $TS($S(NonNullAssertion, $E(_), $E($S(Colon, MaybeIndentedType))), function($skip, $loc, $0, $1, $2, $3) {
14175
+ var nonnull = $1;
14120
14176
  var ct = $3;
14121
14177
  const [colon, t] = ct ?? [];
14122
14178
  return {
14123
14179
  type: "TypeSuffix",
14124
14180
  ts: true,
14181
+ nonnull,
14125
14182
  t,
14126
14183
  children: [$1, $2, colon, t]
14127
14184
  };
@@ -14391,7 +14448,7 @@ var require_parser = __commonJS({
14391
14448
  function NestedType(ctx, state) {
14392
14449
  return $EVENT(ctx, state, "NestedType", NestedType$0);
14393
14450
  }
14394
- var TypeConditional$0 = $TS($S($E(_), $EXPECT($R82, "TypeConditional /(?=if|unless)/"), TypeIfThenElse), function($skip, $loc, $0, $1, $2, $3) {
14451
+ var TypeConditional$0 = $TS($S($E(_), $EXPECT($R83, "TypeConditional /(?=if|unless)/"), TypeIfThenElse), function($skip, $loc, $0, $1, $2, $3) {
14395
14452
  return [$1, expressionizeTypeIf($3)];
14396
14453
  });
14397
14454
  var TypeConditional$1 = $TS($S(TypeCondition, NotDedented, QuestionMark, Type, __, Colon, Type), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
@@ -14591,15 +14648,15 @@ var require_parser = __commonJS({
14591
14648
  function ThisType(ctx, state) {
14592
14649
  return $EVENT(ctx, state, "ThisType", ThisType$0);
14593
14650
  }
14594
- var Shebang$0 = $S($R$0($EXPECT($R83, "Shebang /#![^\\r\\n]*/")), EOL);
14651
+ var Shebang$0 = $S($R$0($EXPECT($R84, "Shebang /#![^\\r\\n]*/")), EOL);
14595
14652
  function Shebang(ctx, state) {
14596
14653
  return $EVENT(ctx, state, "Shebang", Shebang$0);
14597
14654
  }
14598
- var CivetPrologue$0 = $T($S($EXPECT($R84, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R85, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
14655
+ var CivetPrologue$0 = $T($S($EXPECT($R85, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R86, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
14599
14656
  var content = value[2];
14600
14657
  return content;
14601
14658
  });
14602
- var CivetPrologue$1 = $T($S($EXPECT($R84, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R85, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
14659
+ var CivetPrologue$1 = $T($S($EXPECT($R85, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R86, "CivetPrologue /[ \\t]*/"), $C(EOL, $Y(RestOfLine))), function(value) {
14603
14660
  var content = value[2];
14604
14661
  return content;
14605
14662
  });
@@ -14607,7 +14664,7 @@ var require_parser = __commonJS({
14607
14664
  function CivetPrologue(ctx, state) {
14608
14665
  return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
14609
14666
  }
14610
- var CivetPrologueContent$0 = $TS($S($EXPECT($L226, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R86, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
14667
+ var CivetPrologueContent$0 = $TS($S($EXPECT($L226, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R87, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
14611
14668
  var options = $3;
14612
14669
  return {
14613
14670
  type: "CivetPrologue",
@@ -14618,7 +14675,7 @@ var require_parser = __commonJS({
14618
14675
  function CivetPrologueContent(ctx, state) {
14619
14676
  return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
14620
14677
  }
14621
- var CivetOption$0 = $TR($EXPECT($R87, "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) {
14678
+ var CivetOption$0 = $TR($EXPECT($R88, "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) {
14622
14679
  const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
14623
14680
  if (l)
14624
14681
  return l.toUpperCase();
@@ -14635,11 +14692,11 @@ var require_parser = __commonJS({
14635
14692
  function CivetOption(ctx, state) {
14636
14693
  return $EVENT(ctx, state, "CivetOption", CivetOption$0);
14637
14694
  }
14638
- var UnknownPrologue$0 = $S($R$0($EXPECT($R84, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
14695
+ var UnknownPrologue$0 = $S($R$0($EXPECT($R85, "UnknownPrologue /[\\t ]*/")), StringLiteral, $TEXT(SimpleStatementDelimiter), EOS);
14639
14696
  function UnknownPrologue(ctx, state) {
14640
14697
  return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
14641
14698
  }
14642
- var TripleSlashDirective$0 = $S($R$0($EXPECT($R88, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
14699
+ var TripleSlashDirective$0 = $S($R$0($EXPECT($R89, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
14643
14700
  function TripleSlashDirective(ctx, state) {
14644
14701
  return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
14645
14702
  }
@@ -14655,13 +14712,13 @@ var require_parser = __commonJS({
14655
14712
  function PrologueString(ctx, state) {
14656
14713
  return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
14657
14714
  }
14658
- var EOS$0 = $T($S($EXPECT($R89, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
14715
+ var EOS$0 = $T($S($EXPECT($R90, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
14659
14716
  return value[1];
14660
14717
  });
14661
14718
  function EOS(ctx, state) {
14662
14719
  return $EVENT(ctx, state, "EOS", EOS$0);
14663
14720
  }
14664
- var EOL$0 = $TR($EXPECT($R90, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14721
+ var EOL$0 = $TR($EXPECT($R91, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
14665
14722
  return { $loc, token: $0 };
14666
14723
  });
14667
14724
  function EOL(ctx, state) {
@@ -15233,11 +15290,11 @@ var require_parser = __commonJS({
15233
15290
  function Prologue(ctx, state) {
15234
15291
  return $EVENT(ctx, state, "Prologue", Prologue$0);
15235
15292
  }
15236
- var ProloguePrefix$0 = $S(Prologue, $R$0($EXPECT($R91, "ProloguePrefix /[^]*/")));
15293
+ var ProloguePrefix$0 = $S(Prologue, $R$0($EXPECT($R92, "ProloguePrefix /[^]*/")));
15237
15294
  function ProloguePrefix(ctx, state) {
15238
15295
  return $EVENT(ctx, state, "ProloguePrefix", ProloguePrefix$0);
15239
15296
  }
15240
- var Indent$0 = $TR($EXPECT($R85, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
15297
+ var Indent$0 = $TR($EXPECT($R86, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
15241
15298
  const level = getIndentLevel($0, module.config.tab);
15242
15299
  return {
15243
15300
  $loc,
@@ -15461,6 +15518,7 @@ var require_parser = __commonJS({
15461
15518
  exports.MemberBracketContent = MemberBracketContent;
15462
15519
  exports.SliceParameters = SliceParameters;
15463
15520
  exports.AccessStart = AccessStart;
15521
+ exports.ImplicitAccessStart = ImplicitAccessStart;
15464
15522
  exports.PropertyAccessModifier = PropertyAccessModifier;
15465
15523
  exports.PropertyAccess = PropertyAccess;
15466
15524
  exports.PropertyGlob = PropertyGlob;
@@ -15595,6 +15653,7 @@ var require_parser = __commonJS({
15595
15653
  exports.BinaryOp = BinaryOp;
15596
15654
  exports._BinaryOp = _BinaryOp;
15597
15655
  exports.BinaryOpSymbol = BinaryOpSymbol;
15656
+ exports.ActualIn = ActualIn;
15598
15657
  exports.CoffeeOfOp = CoffeeOfOp;
15599
15658
  exports.NotOp = NotOp;
15600
15659
  exports.Xor = Xor;
@@ -16599,10 +16658,13 @@ function compile(src, options) {
16599
16658
  let ast;
16600
16659
  try {
16601
16660
  import_parser.parse.config = options.parseOptions || {};
16602
- ast = prune((0, import_parser.parse)(src, {
16661
+ ast = (0, import_parser.parse)(src, {
16603
16662
  filename,
16604
16663
  events
16605
- }));
16664
+ });
16665
+ if (!(options.ast === "raw")) {
16666
+ ast = prune(ast);
16667
+ }
16606
16668
  } finally {
16607
16669
  if (hits || trace) {
16608
16670
  import("fs").then(function({ writeFileSync }) {
package/dist/types.d.ts CHANGED
@@ -32,8 +32,13 @@ declare module "@danielx/civet" {
32
32
  }>
33
33
  export type CompileOptions = {
34
34
  filename?: string
35
- js?: boolean
36
35
  sourceMap?: boolean
36
+ inlineMap?: boolean
37
+ ast?: boolean | "raw"
38
+ js?: boolean
39
+ noCache?: boolean
40
+ hits?: string
41
+ trace?: string
37
42
  parseOptions?: ParseOptions
38
43
  }
39
44
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.88",
4
+ "version": "0.6.90",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",