@danielx/civet 0.6.38 → 0.6.40

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
@@ -727,57 +727,107 @@ var require_lib = __commonJS({
727
727
  }
728
728
  return [constructInvocation(fn, arg), null];
729
729
  }
730
- var initialSpacingRe = /^(?:\r?\n|\n)*((?:\r?\n|\n)\s+)/;
731
- function dedentBlockString({ $loc, token: str }, spacing, trim = true) {
732
- if (spacing == null)
733
- spacing = str.match(initialSpacingRe);
734
- if (spacing) {
735
- str = str.replaceAll(spacing[1], "\n");
736
- const l = spacing.length;
737
- $loc.pos += l;
738
- $loc.length -= l;
739
- }
740
- if (trim) {
741
- str = str.replace(/^(\r?\n|\n)/, "").replace(/(\r?\n|\n)[ \t]*$/, "");
730
+ function getIndentLevel(str, tab) {
731
+ if (tab != null && tab != 1) {
732
+ const tabs = str.match(/\t/g);
733
+ const numTabs = tabs ? tabs.length : 0;
734
+ return numTabs * tab + /*spaces*/
735
+ (str.length - numTabs);
736
+ } else {
737
+ return str.length;
738
+ }
739
+ }
740
+ function reduceIndentLevel(str, dedent, tab) {
741
+ if (tab != null && tab != 1) {
742
+ for (let i1 = 0, len1 = str.length; i1 < len1; i1++) {
743
+ const i = i1;
744
+ const char = str[i1];
745
+ if (!dedent) {
746
+ return str.slice(i);
747
+ }
748
+ if (char == " ") {
749
+ dedent -= tab;
750
+ if (dedent < 0) {
751
+ return "".padStart(-dedent, " ") + str.slice(i + 1);
752
+ }
753
+ } else {
754
+ dedent--;
755
+ }
756
+ }
757
+ return "";
758
+ } else {
759
+ return str.slice(dedent);
760
+ }
761
+ }
762
+ var indentRe = /\n([ \t]*)(?![ \t]|\r?\n|$)/g;
763
+ function getIndentOfBlockString(str, tab) {
764
+ let minLevel = Infinity;
765
+ let ref1;
766
+ while (ref1 = indentRe.exec(str)) {
767
+ const match = ref1;
768
+ const level = getIndentLevel(match[1], tab);
769
+ if (level < minLevel) {
770
+ minLevel = level;
771
+ }
772
+ }
773
+ if (minLevel == Infinity) {
774
+ minLevel = 0;
775
+ }
776
+ return minLevel;
777
+ }
778
+ function dedentBlockString({ $loc, token: str }, tab, dedent, trimStart = true, trimEnd = true) {
779
+ if (dedent == null && /^[ \t]*\r?\n/.test(str)) {
780
+ dedent = getIndentOfBlockString(str, tab);
781
+ }
782
+ if (dedent) {
783
+ str = str.replace(/(\n)([ \t]*)/g, (_, newline, indent) => {
784
+ return newline + reduceIndentLevel(indent, dedent, tab);
785
+ });
786
+ }
787
+ if (trimStart) {
788
+ str = str.replace(/^[ \t]*\r?\n/, "");
789
+ }
790
+ if (trimEnd) {
791
+ str = str.replace(/(\r?\n|\n)[ \t]*$/, "");
742
792
  }
743
793
  str = str.replace(/(\\.|`|\$\{)/g, (s) => {
744
794
  if (s[0] === "\\") {
745
795
  return s;
796
+ } else {
797
+ return `\\${s}`;
746
798
  }
747
- return `\\${s}`;
748
799
  });
749
- return {
750
- $loc,
751
- token: str
752
- };
800
+ return { $loc, token: str };
753
801
  }
754
- function dedentBlockSubstitutions($0) {
802
+ function dedentBlockSubstitutions($0, tab) {
755
803
  const [s, strWithSubstitutions, e] = $0;
756
- if (strWithSubstitutions.length === 0) {
804
+ if (!strWithSubstitutions.length) {
757
805
  return $0;
758
806
  }
759
- let initialSpacing, i = 0, l = strWithSubstitutions.length, results = [s];
760
- const { token } = strWithSubstitutions[0];
761
- if (token) {
762
- initialSpacing = token.match(initialSpacingRe);
763
- } else {
764
- initialSpacing = false;
765
- }
766
- while (i < l) {
767
- let segment = strWithSubstitutions[i];
768
- if (segment.token) {
769
- segment = dedentBlockString(segment, initialSpacing, false);
770
- if (i === 0) {
771
- segment.token = segment.token.replace(/^(\r?\n|\n)/, "");
772
- }
773
- if (i === l - 1) {
774
- segment.token = segment.token.replace(/(\r?\n|\n)[ \t]*$/, "");
775
- }
776
- results.push(segment);
777
- } else {
778
- results.push(segment);
807
+ const stringPart = (() => {
808
+ const results1 = [];
809
+ for (let i2 = 0, len2 = strWithSubstitutions.length; i2 < len2; i2++) {
810
+ const part = strWithSubstitutions[i2];
811
+ results1.push(part.token ?? "s");
779
812
  }
780
- i++;
813
+ ;
814
+ return results1;
815
+ })().join("");
816
+ const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
817
+ let results = [s];
818
+ for (let i3 = 0, len3 = strWithSubstitutions.length; i3 < len3; i3++) {
819
+ const i = i3;
820
+ let part = strWithSubstitutions[i3];
821
+ if (part.token != null) {
822
+ part = dedentBlockString(
823
+ part,
824
+ tab,
825
+ dedent,
826
+ i === 0,
827
+ i === strWithSubstitutions.length - 1
828
+ );
829
+ }
830
+ results.push(part);
781
831
  }
782
832
  results.push(e);
783
833
  return {
@@ -1306,17 +1356,17 @@ var require_lib = __commonJS({
1306
1356
  }
1307
1357
  function arrayRecurse(array) {
1308
1358
  const len2 = array.length;
1309
- const results1 = [];
1359
+ const results2 = [];
1310
1360
  for (let i = 0; i < len2; i++) {
1311
1361
  const c = array[i];
1312
1362
  if (c === child || Array.isArray(c) && arrayRecurse(c)) {
1313
1363
  return true;
1314
1364
  } else {
1315
- results1.push(void 0);
1365
+ results2.push(void 0);
1316
1366
  }
1317
1367
  }
1318
1368
  ;
1319
- return results1;
1369
+ return results2;
1320
1370
  }
1321
1371
  return -1;
1322
1372
  }
@@ -2310,9 +2360,11 @@ var require_lib = __commonJS({
2310
2360
  }
2311
2361
  if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
2312
2362
  if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
2313
- post.push([", ", lhs]);
2363
+ pre.push("(");
2364
+ post.push([", ", lhs, ")"]);
2314
2365
  } else {
2315
- pre.push([lhs, ", "]);
2366
+ pre.push(["(", lhs, ", "]);
2367
+ post.push(")");
2316
2368
  }
2317
2369
  return expr.assigned;
2318
2370
  }
@@ -3458,7 +3510,7 @@ var require_lib = __commonJS({
3458
3510
  gatherRecursive,
3459
3511
  gatherRecursiveAll,
3460
3512
  gatherRecursiveWithinFunction,
3461
- getIndent,
3513
+ getIndentLevel,
3462
3514
  getTrimmingSpace,
3463
3515
  hasAwait,
3464
3516
  hasYield,
@@ -4467,7 +4519,7 @@ var require_parser = __commonJS({
4467
4519
  var $R43 = $R(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
4468
4520
  var $R44 = $R(new RegExp("[^]*?###", "suy"));
4469
4521
  var $R45 = $R(new RegExp("###(?!#)", "suy"));
4470
- var $R46 = $R(new RegExp("[^\\r\\n]", "suy"));
4522
+ var $R46 = $R(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
4471
4523
  var $R47 = $R(new RegExp("[ \\t]+", "suy"));
4472
4524
  var $R48 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
4473
4525
  var $R49 = $R(new RegExp("['\u2019]s", "suy"));
@@ -5515,7 +5567,7 @@ var require_parser = __commonJS({
5515
5567
  function CallExpressionRest(ctx, state) {
5516
5568
  return $EVENT_C(ctx, state, "CallExpressionRest", CallExpressionRest$$);
5517
5569
  }
5518
- var OptionalShorthand$0 = $TS($S($Q(MultiLineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5570
+ var OptionalShorthand$0 = $TS($S($Q(InlineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5519
5571
  return {
5520
5572
  type: "Optional",
5521
5573
  children: $0
@@ -5524,8 +5576,8 @@ var require_parser = __commonJS({
5524
5576
  function OptionalShorthand(ctx, state) {
5525
5577
  return $EVENT(ctx, state, "OptionalShorthand", OptionalShorthand$0);
5526
5578
  }
5527
- var OptionalDot$0 = $S($Q(MultiLineComment), Dot);
5528
- var OptionalDot$1 = $S(InsertDot, $Q(MultiLineComment));
5579
+ var OptionalDot$0 = $S($Q(InlineComment), Dot);
5580
+ var OptionalDot$1 = $S(InsertDot, $Q(InlineComment));
5529
5581
  var OptionalDot$$ = [OptionalDot$0, OptionalDot$1];
5530
5582
  function OptionalDot(ctx, state) {
5531
5583
  return $EVENT_C(ctx, state, "OptionalDot", OptionalDot$$);
@@ -5556,7 +5608,7 @@ var require_parser = __commonJS({
5556
5608
  function MemberBase(ctx, state) {
5557
5609
  return $EVENT_C(ctx, state, "MemberBase", MemberBase$$);
5558
5610
  }
5559
- var MemberExpressionRest$0 = $TS($S($Q(MultiLineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5611
+ var MemberExpressionRest$0 = $TS($S($Q(InlineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5560
5612
  var comments = $1;
5561
5613
  var body = $2;
5562
5614
  if (Array.isArray(body))
@@ -5569,7 +5621,7 @@ var require_parser = __commonJS({
5569
5621
  function MemberExpressionRest(ctx, state) {
5570
5622
  return $EVENT(ctx, state, "MemberExpressionRest", MemberExpressionRest$0);
5571
5623
  }
5572
- var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(MultiLineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5624
+ var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(InlineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5573
5625
  var dot = $1;
5574
5626
  var comments = $2;
5575
5627
  var content = $3;
@@ -5727,7 +5779,7 @@ var require_parser = __commonJS({
5727
5779
  function AccessStart(ctx, state) {
5728
5780
  return $EVENT(ctx, state, "AccessStart", AccessStart$0);
5729
5781
  }
5730
- var PropertyAccess$0 = $TS($S(AccessStart, $Q(MultiLineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5782
+ var PropertyAccess$0 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5731
5783
  var access = $1;
5732
5784
  var comments = $2;
5733
5785
  var id = $3;
@@ -5759,7 +5811,7 @@ var require_parser = __commonJS({
5759
5811
  function PropertyAccess(ctx, state) {
5760
5812
  return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
5761
5813
  }
5762
- var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(MultiLineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5814
+ var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(InlineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5763
5815
  var dot = $1;
5764
5816
  var object = $3;
5765
5817
  return {
@@ -7116,7 +7168,7 @@ var require_parser = __commonJS({
7116
7168
  names: exp.names
7117
7169
  };
7118
7170
  });
7119
- var ArrayElementExpression$2 = $TS($S($E($S($E($S(__, DotDotDot, __)), ExtendedExpression)), $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2) {
7171
+ var ArrayElementExpression$2 = $TS($S($E($S($E($S(__, DotDotDot, __)), PostfixedExpression)), $Y(ArrayElementDelimiter)), function($skip, $loc, $0, $1, $2) {
7120
7172
  var expMaybeSpread = $1;
7121
7173
  if (expMaybeSpread) {
7122
7174
  const [spread, exp] = expMaybeSpread;
@@ -8670,7 +8722,7 @@ var require_parser = __commonJS({
8670
8722
  children: $0
8671
8723
  };
8672
8724
  });
8673
- var ForStatementParameters$1 = $TS($S(InsertOpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E($S($N(EOS), Expression)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8725
+ var ForStatementParameters$1 = $TS($S(InsertOpenParen, __, $C(LexicalDeclaration, VariableStatement, $E(Expression)), __, Semicolon, $E(Expression), Semicolon, $E($S($N(EOS), ExpressionWithIndentedApplicationForbidden)), InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
8674
8726
  var declaration = $3;
8675
8727
  return {
8676
8728
  declaration,
@@ -9965,7 +10017,7 @@ var require_parser = __commonJS({
9965
10017
  return $EVENT(ctx, state, "RegularExpressionFlags", RegularExpressionFlags$0);
9966
10018
  }
9967
10019
  var TemplateLiteral$0 = $TS($S(TripleTick, $Q($C(TemplateBlockCharacters, TemplateSubstitution)), TripleTick), function($skip, $loc, $0, $1, $2, $3) {
9968
- return dedentBlockSubstitutions($0);
10020
+ return dedentBlockSubstitutions($0, module.config.tab);
9969
10021
  });
9970
10022
  var TemplateLiteral$1 = $TS($S(Backtick, $Q($C(TemplateCharacters, TemplateSubstitution)), Backtick), function($skip, $loc, $0, $1, $2, $3) {
9971
10023
  return {
@@ -9974,7 +10026,7 @@ var require_parser = __commonJS({
9974
10026
  };
9975
10027
  });
9976
10028
  var TemplateLiteral$2 = $TS($S(TripleDoubleQuote, $Q($C(TripleDoubleStringCharacters, CoffeeStringSubstitution)), TripleDoubleQuote), function($skip, $loc, $0, $1, $2, $3) {
9977
- return dedentBlockSubstitutions($0);
10029
+ return dedentBlockSubstitutions($0, module.config.tab);
9978
10030
  });
9979
10031
  var TemplateLiteral$3 = $TS($S(TripleSingleQuote, TripleSingleStringCharacters, TripleSingleQuote), function($skip, $loc, $0, $1, $2, $3) {
9980
10032
  var s = $1;
@@ -9982,7 +10034,7 @@ var require_parser = __commonJS({
9982
10034
  var e = $3;
9983
10035
  return {
9984
10036
  type: "TemplateLiteral",
9985
- children: [s, dedentBlockString(str), e]
10037
+ children: [s, dedentBlockString(str, module.config.tab), e]
9986
10038
  };
9987
10039
  });
9988
10040
  var TemplateLiteral$4 = CoffeeInterpolatedDoubleQuotedString;
@@ -10062,13 +10114,13 @@ var require_parser = __commonJS({
10062
10114
  function CoffeeHereCommentStart(ctx, state) {
10063
10115
  return $EVENT(ctx, state, "CoffeeHereCommentStart", CoffeeHereCommentStart$0);
10064
10116
  }
10065
- var InlineComment$0 = $TV($TEXT($S($EXPECT($L109, 'InlineComment "/*"'), $TEXT($Q($S($N($EXPECT($L110, 'InlineComment "*/"')), $EXPECT($R46, "InlineComment /[^\\r\\n]/")))), $EXPECT($L110, 'InlineComment "*/"'))), function($skip, $loc, $0, $1) {
10066
- return { $loc, token: $1 };
10117
+ var InlineComment$0 = $TR($EXPECT($R46, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10118
+ return { $loc, token: $0 };
10067
10119
  });
10068
10120
  function InlineComment(ctx, state) {
10069
10121
  return $EVENT(ctx, state, "InlineComment", InlineComment$0);
10070
10122
  }
10071
- var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, SingleLineComment, MultiLineComment)), EOL);
10123
+ var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, Comment)), EOL);
10072
10124
  function RestOfLine(ctx, state) {
10073
10125
  return $EVENT(ctx, state, "RestOfLine", RestOfLine$0);
10074
10126
  }
@@ -12478,7 +12530,7 @@ var require_parser = __commonJS({
12478
12530
  indexOf(indexOfRef) {
12479
12531
  const typeSuffix = {
12480
12532
  ts: true,
12481
- children: [": <T>(this: T[], searchElement: T) => boolean"]
12533
+ children: [": <T>(this: T[], searchElement: T) => number"]
12482
12534
  };
12483
12535
  module.prelude.push(["", [preludeVar, indexOfRef, typeSuffix, " = [].indexOf", asAny, ";\n"]]);
12484
12536
  },
@@ -12616,8 +12668,8 @@ var require_parser = __commonJS({
12616
12668
  function Reset(ctx, state) {
12617
12669
  return $EVENT(ctx, state, "Reset", Reset$0);
12618
12670
  }
12619
- var Init$0 = $TS($S($E(Shebang), $Q(TripleSlashDirective), $Q(DirectivePrologue)), function($skip, $loc, $0, $1, $2, $3) {
12620
- var directives = $3;
12671
+ var Init$0 = $TS($S($E(Shebang), $Q($C(TripleSlashDirective, $S($C(JSSingleLineComment, JSMultiLineComment), EOS), DirectivePrologue))), function($skip, $loc, $0, $1, $2) {
12672
+ var directives = $2;
12621
12673
  directives.forEach((directive) => {
12622
12674
  if (directive.type === "CivetPrologue") {
12623
12675
  Object.assign(module.config, directive.config);
@@ -12629,15 +12681,7 @@ var require_parser = __commonJS({
12629
12681
  return $EVENT(ctx, state, "Init", Init$0);
12630
12682
  }
12631
12683
  var Indent$0 = $TR($EXPECT($R67, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12632
- let level;
12633
- if (module.config.tab) {
12634
- const tabs = $0.match(/\t/g);
12635
- const numTabs = tabs ? tabs.length : 0;
12636
- level = numTabs * module.config.tab + /*spaces*/
12637
- ($0.length - numTabs);
12638
- } else {
12639
- level = $0.length;
12640
- }
12684
+ const level = getIndentLevel($0, module.config.tab);
12641
12685
  return {
12642
12686
  $loc,
12643
12687
  token: $0,
@@ -13435,6 +13479,7 @@ var require_parser = __commonJS({
13435
13479
  expressionizeIfClause,
13436
13480
  forRange,
13437
13481
  gatherBindingCode,
13482
+ getIndentLevel,
13438
13483
  getTrimmingSpace,
13439
13484
  hasAwait,
13440
13485
  hasYield,
@@ -13978,15 +14023,55 @@ function compile(src, options) {
13978
14023
  if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
13979
14024
  options.parseOptions.coffeeCompat = true;
13980
14025
  }
14026
+ ;
14027
+ const { hits, trace, noCache } = options;
13981
14028
  let events;
13982
- if (!options.noCache) {
13983
- events = makeCache();
14029
+ if (!noCache) {
14030
+ events = makeCache({
14031
+ hits: !!hits,
14032
+ trace: !!trace
14033
+ });
14034
+ }
14035
+ let ast;
14036
+ try {
14037
+ parse.config = options.parseOptions || {};
14038
+ ast = prune(parse(src, {
14039
+ filename,
14040
+ events
14041
+ }));
14042
+ } finally {
14043
+ if (hits || trace) {
14044
+ import("fs").then(function({ writeFileSync }) {
14045
+ let ref;
14046
+ if ((ref = events?.meta) && "logs" in ref) {
14047
+ const { logs } = ref;
14048
+ if (trace) {
14049
+ writeFileSync(trace, logs.join("\n"));
14050
+ }
14051
+ }
14052
+ if (hits) {
14053
+ let ref1;
14054
+ if (ref1 = events?.meta.hits) {
14055
+ const hitData = ref1;
14056
+ let total = 0;
14057
+ const data = [...hitData.entries()];
14058
+ const counts = data.sort(([, a], [, b]) => b - a).map(([k, v]) => {
14059
+ total += v;
14060
+ return `${k}: ${v}`;
14061
+ }).join("\n");
14062
+ const hitSummary = `Total: ${total}
14063
+
14064
+ ${counts}`;
14065
+ return writeFileSync(hits, hitSummary);
14066
+ }
14067
+ ;
14068
+ return;
14069
+ }
14070
+ ;
14071
+ return;
14072
+ });
14073
+ }
13984
14074
  }
13985
- parse.config = options.parseOptions || {};
13986
- const ast = prune(parse(src, {
13987
- filename,
13988
- events
13989
- }));
13990
14075
  if (options.ast) {
13991
14076
  return ast;
13992
14077
  }
@@ -14009,22 +14094,45 @@ function compile(src, options) {
14009
14094
  }
14010
14095
  return result;
14011
14096
  }
14012
- function makeCache() {
14097
+ function makeCache({ hits, trace } = {}) {
14098
+ const meta = {};
14099
+ let hitCount;
14100
+ if (hits) {
14101
+ hitCount = /* @__PURE__ */ new Map();
14102
+ meta.hits = hitCount;
14103
+ }
14104
+ let logs;
14105
+ if (trace) {
14106
+ logs = [];
14107
+ meta.logs = logs;
14108
+ }
14013
14109
  const stateCache = new StateCache();
14014
14110
  let getStateKey = null;
14111
+ const stack = [];
14015
14112
  const events = {
14113
+ meta,
14016
14114
  enter: function(ruleName, state) {
14115
+ if (hits) {
14116
+ hitCount.set(ruleName, (hitCount.get(ruleName) || 0) + 1);
14117
+ }
14017
14118
  if (uncacheable.has(ruleName)) {
14018
14119
  return;
14019
14120
  }
14020
14121
  ;
14021
14122
  const key = [ruleName, state.pos, ...getStateKey()];
14022
14123
  if (stateCache.has(key)) {
14124
+ if (trace) {
14125
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state.pos + "\u{1F4B0}");
14126
+ }
14023
14127
  const result = stateCache.get(key);
14024
14128
  return {
14025
14129
  cache: result ? { ...result } : void 0
14026
14130
  };
14027
14131
  }
14132
+ if (trace) {
14133
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state.pos + "\u2192");
14134
+ stack.push(ruleName);
14135
+ }
14028
14136
  return;
14029
14137
  },
14030
14138
  exit: function(ruleName, state, result) {
@@ -14042,6 +14150,10 @@ function makeCache() {
14042
14150
  if (parse.config.verbose && result) {
14043
14151
  console.log(`Parsed ${JSON.stringify(state.input.slice(state.pos, result.pos))} [pos ${state.pos}-${result.pos}] as ${ruleName}`);
14044
14152
  }
14153
+ if (trace) {
14154
+ stack.pop();
14155
+ logs.push("".padStart(stack.length * 2, " ") + ruleName + ":" + state.pos + " " + (result ? "\u2705" : "\u274C"));
14156
+ }
14045
14157
  return;
14046
14158
  }
14047
14159
  };
@@ -35,10 +35,13 @@ __export(ts_diagnostic_exports, {
35
35
  remapRange: () => remapRange
36
36
  });
37
37
  module.exports = __toCommonJS(ts_diagnostic_exports);
38
- var import_typescript = __toESM(require("typescript"));
39
38
  var import_vscode_languageserver = __toESM(require("vscode-languageserver"));
40
39
  var import_vscode_languageserver_textdocument = require("vscode-languageserver-textdocument");
41
- const { DiagnosticCategory } = import_typescript.default;
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";
42
45
  function remapPosition(position, sourcemapLines) {
43
46
  if (!sourcemapLines)
44
47
  return position;
@@ -1,7 +1,10 @@
1
- import ts from "typescript";
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";
2
6
  import vs, { DiagnosticSeverity, Position, Range } from "vscode-languageserver";
3
7
  import { TextDocument } from "vscode-languageserver-textdocument";
4
- const { DiagnosticCategory } = ts;
5
8
  function remapPosition(position, sourcemapLines) {
6
9
  if (!sourcemapLines)
7
10
  return position;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.38",
4
+ "version": "0.6.40",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -70,7 +70,7 @@
70
70
  "unplugin": "^1.4.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@danielx/civet": "0.6.34",
73
+ "@danielx/civet": "0.6.38",
74
74
  "@danielx/hera": "^0.8.10",
75
75
  "@types/assert": "^1.5.6",
76
76
  "@types/mocha": "^9.1.1",