@danielx/civet 0.6.39 → 0.6.41

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/browser.js CHANGED
@@ -737,57 +737,107 @@ ${input.slice(result.pos)}
737
737
  }
738
738
  return [constructInvocation(fn, arg), null];
739
739
  }
740
- var initialSpacingRe = /^(?:\r?\n|\n)*((?:\r?\n|\n)\s+)/;
741
- function dedentBlockString({ $loc, token: str }, spacing, trim = true) {
742
- if (spacing == null)
743
- spacing = str.match(initialSpacingRe);
744
- if (spacing) {
745
- str = str.replaceAll(spacing[1], "\n");
746
- const l = spacing.length;
747
- $loc.pos += l;
748
- $loc.length -= l;
749
- }
750
- if (trim) {
751
- str = str.replace(/^(\r?\n|\n)/, "").replace(/(\r?\n|\n)[ \t]*$/, "");
740
+ function getIndentLevel(str, tab) {
741
+ if (tab != null && tab != 1) {
742
+ const tabs = str.match(/\t/g);
743
+ const numTabs = tabs ? tabs.length : 0;
744
+ return numTabs * tab + /*spaces*/
745
+ (str.length - numTabs);
746
+ } else {
747
+ return str.length;
748
+ }
749
+ }
750
+ function reduceIndentLevel(str, dedent, tab) {
751
+ if (tab != null && tab != 1) {
752
+ for (let i1 = 0, len1 = str.length; i1 < len1; i1++) {
753
+ const i = i1;
754
+ const char = str[i1];
755
+ if (!dedent) {
756
+ return str.slice(i);
757
+ }
758
+ if (char == " ") {
759
+ dedent -= tab;
760
+ if (dedent < 0) {
761
+ return "".padStart(-dedent, " ") + str.slice(i + 1);
762
+ }
763
+ } else {
764
+ dedent--;
765
+ }
766
+ }
767
+ return "";
768
+ } else {
769
+ return str.slice(dedent);
770
+ }
771
+ }
772
+ var indentRe = /\n([ \t]*)(?![ \t]|\r?\n|$)/g;
773
+ function getIndentOfBlockString(str, tab) {
774
+ let minLevel = Infinity;
775
+ let ref1;
776
+ while (ref1 = indentRe.exec(str)) {
777
+ const match = ref1;
778
+ const level = getIndentLevel(match[1], tab);
779
+ if (level < minLevel) {
780
+ minLevel = level;
781
+ }
782
+ }
783
+ if (minLevel == Infinity) {
784
+ minLevel = 0;
785
+ }
786
+ return minLevel;
787
+ }
788
+ function dedentBlockString({ $loc, token: str }, tab, dedent, trimStart = true, trimEnd = true) {
789
+ if (dedent == null && /^[ \t]*\r?\n/.test(str)) {
790
+ dedent = getIndentOfBlockString(str, tab);
791
+ }
792
+ if (dedent) {
793
+ str = str.replace(/(\n)([ \t]*)/g, (_, newline, indent) => {
794
+ return newline + reduceIndentLevel(indent, dedent, tab);
795
+ });
796
+ }
797
+ if (trimStart) {
798
+ str = str.replace(/^[ \t]*\r?\n/, "");
799
+ }
800
+ if (trimEnd) {
801
+ str = str.replace(/(\r?\n|\n)[ \t]*$/, "");
752
802
  }
753
803
  str = str.replace(/(\\.|`|\$\{)/g, (s) => {
754
804
  if (s[0] === "\\") {
755
805
  return s;
806
+ } else {
807
+ return `\\${s}`;
756
808
  }
757
- return `\\${s}`;
758
809
  });
759
- return {
760
- $loc,
761
- token: str
762
- };
810
+ return { $loc, token: str };
763
811
  }
764
- function dedentBlockSubstitutions($0) {
812
+ function dedentBlockSubstitutions($0, tab) {
765
813
  const [s, strWithSubstitutions, e] = $0;
766
- if (strWithSubstitutions.length === 0) {
814
+ if (!strWithSubstitutions.length) {
767
815
  return $0;
768
816
  }
769
- let initialSpacing, i = 0, l = strWithSubstitutions.length, results = [s];
770
- const { token } = strWithSubstitutions[0];
771
- if (token) {
772
- initialSpacing = token.match(initialSpacingRe);
773
- } else {
774
- initialSpacing = false;
775
- }
776
- while (i < l) {
777
- let segment = strWithSubstitutions[i];
778
- if (segment.token) {
779
- segment = dedentBlockString(segment, initialSpacing, false);
780
- if (i === 0) {
781
- segment.token = segment.token.replace(/^(\r?\n|\n)/, "");
782
- }
783
- if (i === l - 1) {
784
- segment.token = segment.token.replace(/(\r?\n|\n)[ \t]*$/, "");
785
- }
786
- results.push(segment);
787
- } else {
788
- results.push(segment);
817
+ const stringPart = (() => {
818
+ const results1 = [];
819
+ for (let i2 = 0, len2 = strWithSubstitutions.length; i2 < len2; i2++) {
820
+ const part = strWithSubstitutions[i2];
821
+ results1.push(part.token ?? "s");
789
822
  }
790
- i++;
823
+ ;
824
+ return results1;
825
+ })().join("");
826
+ const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
827
+ let results = [s];
828
+ for (let i3 = 0, len3 = strWithSubstitutions.length; i3 < len3; i3++) {
829
+ const i = i3;
830
+ let part = strWithSubstitutions[i3];
831
+ if (part.token != null) {
832
+ part = dedentBlockString(
833
+ part,
834
+ tab,
835
+ dedent,
836
+ i === 0,
837
+ i === strWithSubstitutions.length - 1
838
+ );
839
+ }
840
+ results.push(part);
791
841
  }
792
842
  results.push(e);
793
843
  return {
@@ -1316,17 +1366,17 @@ ${input.slice(result.pos)}
1316
1366
  }
1317
1367
  function arrayRecurse(array) {
1318
1368
  const len2 = array.length;
1319
- const results1 = [];
1369
+ const results2 = [];
1320
1370
  for (let i = 0; i < len2; i++) {
1321
1371
  const c = array[i];
1322
1372
  if (c === child || Array.isArray(c) && arrayRecurse(c)) {
1323
1373
  return true;
1324
1374
  } else {
1325
- results1.push(void 0);
1375
+ results2.push(void 0);
1326
1376
  }
1327
1377
  }
1328
1378
  ;
1329
- return results1;
1379
+ return results2;
1330
1380
  }
1331
1381
  return -1;
1332
1382
  }
@@ -2320,9 +2370,11 @@ ${input.slice(result.pos)}
2320
2370
  }
2321
2371
  if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
2322
2372
  if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
2323
- post.push([", ", lhs]);
2373
+ pre.push("(");
2374
+ post.push([", ", lhs, ")"]);
2324
2375
  } else {
2325
- pre.push([lhs, ", "]);
2376
+ pre.push(["(", lhs, ", "]);
2377
+ post.push(")");
2326
2378
  }
2327
2379
  return expr.assigned;
2328
2380
  }
@@ -3468,7 +3520,7 @@ ${input.slice(result.pos)}
3468
3520
  gatherRecursive,
3469
3521
  gatherRecursiveAll,
3470
3522
  gatherRecursiveWithinFunction,
3471
- getIndent,
3523
+ getIndentLevel,
3472
3524
  getTrimmingSpace,
3473
3525
  hasAwait,
3474
3526
  hasYield,
@@ -4477,7 +4529,7 @@ ${input.slice(result.pos)}
4477
4529
  var $R43 = $R(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
4478
4530
  var $R44 = $R(new RegExp("[^]*?###", "suy"));
4479
4531
  var $R45 = $R(new RegExp("###(?!#)", "suy"));
4480
- var $R46 = $R(new RegExp("[^\\r\\n]", "suy"));
4532
+ var $R46 = $R(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
4481
4533
  var $R47 = $R(new RegExp("[ \\t]+", "suy"));
4482
4534
  var $R48 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
4483
4535
  var $R49 = $R(new RegExp("['\u2019]s", "suy"));
@@ -5525,7 +5577,7 @@ ${input.slice(result.pos)}
5525
5577
  function CallExpressionRest(ctx, state) {
5526
5578
  return $EVENT_C(ctx, state, "CallExpressionRest", CallExpressionRest$$);
5527
5579
  }
5528
- var OptionalShorthand$0 = $TS($S($Q(MultiLineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5580
+ var OptionalShorthand$0 = $TS($S($Q(InlineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5529
5581
  return {
5530
5582
  type: "Optional",
5531
5583
  children: $0
@@ -5534,8 +5586,8 @@ ${input.slice(result.pos)}
5534
5586
  function OptionalShorthand(ctx, state) {
5535
5587
  return $EVENT(ctx, state, "OptionalShorthand", OptionalShorthand$0);
5536
5588
  }
5537
- var OptionalDot$0 = $S($Q(MultiLineComment), Dot);
5538
- var OptionalDot$1 = $S(InsertDot, $Q(MultiLineComment));
5589
+ var OptionalDot$0 = $S($Q(InlineComment), Dot);
5590
+ var OptionalDot$1 = $S(InsertDot, $Q(InlineComment));
5539
5591
  var OptionalDot$$ = [OptionalDot$0, OptionalDot$1];
5540
5592
  function OptionalDot(ctx, state) {
5541
5593
  return $EVENT_C(ctx, state, "OptionalDot", OptionalDot$$);
@@ -5566,7 +5618,7 @@ ${input.slice(result.pos)}
5566
5618
  function MemberBase(ctx, state) {
5567
5619
  return $EVENT_C(ctx, state, "MemberBase", MemberBase$$);
5568
5620
  }
5569
- var MemberExpressionRest$0 = $TS($S($Q(MultiLineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5621
+ var MemberExpressionRest$0 = $TS($S($Q(InlineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5570
5622
  var comments = $1;
5571
5623
  var body = $2;
5572
5624
  if (Array.isArray(body))
@@ -5579,7 +5631,7 @@ ${input.slice(result.pos)}
5579
5631
  function MemberExpressionRest(ctx, state) {
5580
5632
  return $EVENT(ctx, state, "MemberExpressionRest", MemberExpressionRest$0);
5581
5633
  }
5582
- var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(MultiLineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5634
+ var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(InlineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5583
5635
  var dot = $1;
5584
5636
  var comments = $2;
5585
5637
  var content = $3;
@@ -5737,7 +5789,7 @@ ${input.slice(result.pos)}
5737
5789
  function AccessStart(ctx, state) {
5738
5790
  return $EVENT(ctx, state, "AccessStart", AccessStart$0);
5739
5791
  }
5740
- var PropertyAccess$0 = $TS($S(AccessStart, $Q(MultiLineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5792
+ var PropertyAccess$0 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5741
5793
  var access = $1;
5742
5794
  var comments = $2;
5743
5795
  var id = $3;
@@ -5769,7 +5821,7 @@ ${input.slice(result.pos)}
5769
5821
  function PropertyAccess(ctx, state) {
5770
5822
  return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
5771
5823
  }
5772
- var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(MultiLineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5824
+ var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(InlineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5773
5825
  var dot = $1;
5774
5826
  var object = $3;
5775
5827
  return {
@@ -9975,7 +10027,7 @@ ${input.slice(result.pos)}
9975
10027
  return $EVENT(ctx, state, "RegularExpressionFlags", RegularExpressionFlags$0);
9976
10028
  }
9977
10029
  var TemplateLiteral$0 = $TS($S(TripleTick, $Q($C(TemplateBlockCharacters, TemplateSubstitution)), TripleTick), function($skip, $loc, $0, $1, $2, $3) {
9978
- return dedentBlockSubstitutions($0);
10030
+ return dedentBlockSubstitutions($0, module.config.tab);
9979
10031
  });
9980
10032
  var TemplateLiteral$1 = $TS($S(Backtick, $Q($C(TemplateCharacters, TemplateSubstitution)), Backtick), function($skip, $loc, $0, $1, $2, $3) {
9981
10033
  return {
@@ -9984,7 +10036,7 @@ ${input.slice(result.pos)}
9984
10036
  };
9985
10037
  });
9986
10038
  var TemplateLiteral$2 = $TS($S(TripleDoubleQuote, $Q($C(TripleDoubleStringCharacters, CoffeeStringSubstitution)), TripleDoubleQuote), function($skip, $loc, $0, $1, $2, $3) {
9987
- return dedentBlockSubstitutions($0);
10039
+ return dedentBlockSubstitutions($0, module.config.tab);
9988
10040
  });
9989
10041
  var TemplateLiteral$3 = $TS($S(TripleSingleQuote, TripleSingleStringCharacters, TripleSingleQuote), function($skip, $loc, $0, $1, $2, $3) {
9990
10042
  var s = $1;
@@ -9992,7 +10044,7 @@ ${input.slice(result.pos)}
9992
10044
  var e = $3;
9993
10045
  return {
9994
10046
  type: "TemplateLiteral",
9995
- children: [s, dedentBlockString(str), e]
10047
+ children: [s, dedentBlockString(str, module.config.tab), e]
9996
10048
  };
9997
10049
  });
9998
10050
  var TemplateLiteral$4 = CoffeeInterpolatedDoubleQuotedString;
@@ -10072,13 +10124,13 @@ ${input.slice(result.pos)}
10072
10124
  function CoffeeHereCommentStart(ctx, state) {
10073
10125
  return $EVENT(ctx, state, "CoffeeHereCommentStart", CoffeeHereCommentStart$0);
10074
10126
  }
10075
- 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) {
10076
- return { $loc, token: $1 };
10127
+ var InlineComment$0 = $TR($EXPECT($R46, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10128
+ return { $loc, token: $0 };
10077
10129
  });
10078
10130
  function InlineComment(ctx, state) {
10079
10131
  return $EVENT(ctx, state, "InlineComment", InlineComment$0);
10080
10132
  }
10081
- var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, SingleLineComment, MultiLineComment)), EOL);
10133
+ var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, Comment)), EOL);
10082
10134
  function RestOfLine(ctx, state) {
10083
10135
  return $EVENT(ctx, state, "RestOfLine", RestOfLine$0);
10084
10136
  }
@@ -12488,7 +12540,7 @@ ${input.slice(result.pos)}
12488
12540
  indexOf(indexOfRef) {
12489
12541
  const typeSuffix = {
12490
12542
  ts: true,
12491
- children: [": <T>(this: T[], searchElement: T) => boolean"]
12543
+ children: [": <T>(this: T[], searchElement: T) => number"]
12492
12544
  };
12493
12545
  module.prelude.push(["", [preludeVar, indexOfRef, typeSuffix, " = [].indexOf", asAny, ";\n"]]);
12494
12546
  },
@@ -12626,8 +12678,8 @@ ${input.slice(result.pos)}
12626
12678
  function Reset(ctx, state) {
12627
12679
  return $EVENT(ctx, state, "Reset", Reset$0);
12628
12680
  }
12629
- var Init$0 = $TS($S($E(Shebang), $Q(TripleSlashDirective), $Q(DirectivePrologue)), function($skip, $loc, $0, $1, $2, $3) {
12630
- var directives = $3;
12681
+ var Init$0 = $TS($S($E(Shebang), $Q($C(TripleSlashDirective, $S($C(JSSingleLineComment, JSMultiLineComment), EOS), DirectivePrologue))), function($skip, $loc, $0, $1, $2) {
12682
+ var directives = $2;
12631
12683
  directives.forEach((directive) => {
12632
12684
  if (directive.type === "CivetPrologue") {
12633
12685
  Object.assign(module.config, directive.config);
@@ -12639,15 +12691,7 @@ ${input.slice(result.pos)}
12639
12691
  return $EVENT(ctx, state, "Init", Init$0);
12640
12692
  }
12641
12693
  var Indent$0 = $TR($EXPECT($R67, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12642
- let level;
12643
- if (module.config.tab) {
12644
- const tabs = $0.match(/\t/g);
12645
- const numTabs = tabs ? tabs.length : 0;
12646
- level = numTabs * module.config.tab + /*spaces*/
12647
- ($0.length - numTabs);
12648
- } else {
12649
- level = $0.length;
12650
- }
12694
+ const level = getIndentLevel($0, module.config.tab);
12651
12695
  return {
12652
12696
  $loc,
12653
12697
  token: $0,
@@ -13445,6 +13489,7 @@ ${input.slice(result.pos)}
13445
13489
  expressionizeIfClause,
13446
13490
  forRange,
13447
13491
  gatherBindingCode,
13492
+ getIndentLevel,
13448
13493
  getTrimmingSpace,
13449
13494
  hasAwait,
13450
13495
  hasYield,
package/dist/civet CHANGED
@@ -42,39 +42,39 @@ if (process.argv.includes("--version")) {
42
42
  process.exit(0);
43
43
  }
44
44
  if (process.argv.includes("--help")) {
45
- process.stderr.write(`\u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
46
- \u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
47
- \u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
48
- \u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
49
- \xB7\u2580\u2580\u2580 \u2580\u2580\u2580. \u2580 \u2580\u2580\u2580 \u2580\u2580\u2580 \`- \\\`_\`"'-
45
+ process.stderr.write(` \u2584\u2584\xB7 \u25AA \u258C \u2590\xB7\u2584\u2584\u2584 .\u2584\u2584\u2584\u2584\u2584
46
+ \u2590\u2588 \u258C\u25AA\u2588\u2588 \u25AA\u2588\xB7\u2588\u258C\u2580\u2584.\u2580\xB7\u2022\u2588\u2588 _._ _,-'""\`-._
47
+ \u2588\u2588 \u2584\u2584\u2590\u2588\xB7\u2590\u2588\u2590\u2588\u2022\u2590\u2580\u2580\u25AA\u2584 \u2590\u2588.\u25AA (,-.\`._,'( |\\\`-/|
48
+ \u2590\u2588\u2588\u2588\u258C\u2590\u2588\u258C \u2588\u2588\u2588 \u2590\u2588\u2584\u2584\u258C \u2590\u2588\u258C\xB7 \`-.-' \\ )-\`( , o o)
49
+ \xB7\u2580\u2580\u2580 \u2580\u2580\u2580. \u2580 \u2580\u2580\u2580 \u2580\u2580\u2580 \`- \\\`_\`"'-
50
50
 
51
51
 
52
- Usage:
52
+ Usage:
53
53
 
54
- civet # REPL for executing code
55
- civet -c # REPL for transpiling code
56
- civet --ast # REPL for parsing code
57
- civet [options] input.civet # run input.civet
58
- civet [options] -c input.civet # -> input.civet.tsx
59
- civet [options] -c input.civet -o .ts # -> input.ts
60
- civet [options] -c input.civet -o dir # -> dir/input.civet.tsx
61
- civet [options] -c input.civet -o dir/.ts # -> dir/input.ts
62
- civet [options] -c input.civet -o output.ts # -> output.ts
63
- civet [options] < input.civet > output.ts # pipe form
54
+ civet # REPL for executing code
55
+ civet -c # REPL for transpiling code
56
+ civet --ast # REPL for parsing code
57
+ civet [options] input.civet # run input.civet
58
+ civet [options] -c input.civet # -> input.civet.tsx
59
+ civet [options] -c input.civet -o .ts # -> input.ts
60
+ civet [options] -c input.civet -o dir # -> dir/input.civet.tsx
61
+ civet [options] -c input.civet -o dir/.ts # -> dir/input.ts
62
+ civet [options] -c input.civet -o output.ts # -> output.ts
63
+ civet [options] < input.civet > output.ts # pipe form
64
64
 
65
- Options:
66
- --help Show this help message
67
- --version Show the version number
68
- -o / --output XX Specify output directory and/or extension, or filename
69
- -c / --compile Compile input files to TypeScript (or JavaScript)
70
- --config XX Specify a config file (default scans for a config.civet, civet.json, civetconfig.civet or civetconfig.json file, optionally in a .config directory, or starting with a .)
71
- --no-config Don't scan for a config file
72
- --js Strip out all type annotations; default to .jsx extension
73
- --ast Print the AST instead of the compiled code
74
- --inline-map Generate a sourcemap
75
- --no-cache Disable compiler caching (slow, for debugging)
65
+ Options:
66
+ --help Show this help message
67
+ --version Show the version number
68
+ -o / --output XX Specify output directory and/or extension, or filename
69
+ -c / --compile Compile input files to TypeScript (or JavaScript)
70
+ --config XX Specify a config file (default scans for a config.civet, civet.json, civetconfig.civet or civetconfig.json file, optionally in a .config directory, or starting with a .)
71
+ --no-config Don't scan for a config file
72
+ --js Strip out all type annotations; default to .jsx extension
73
+ --ast Print the AST instead of the compiled code
74
+ --inline-map Generate a sourcemap
75
+ --no-cache Disable compiler caching (slow, for debugging)
76
76
 
77
- You can use - to read from stdin or (prefixed by -o) write to stdout.
77
+ You can use - to read from stdin or (prefixed by -o) write to stdout.
78
78
 
79
79
  `);
80
80
  process.exit(0);
package/dist/main.js CHANGED
@@ -729,57 +729,107 @@ var require_lib = __commonJS({
729
729
  }
730
730
  return [constructInvocation(fn, arg), null];
731
731
  }
732
- var initialSpacingRe = /^(?:\r?\n|\n)*((?:\r?\n|\n)\s+)/;
733
- function dedentBlockString({ $loc, token: str }, spacing, trim = true) {
734
- if (spacing == null)
735
- spacing = str.match(initialSpacingRe);
736
- if (spacing) {
737
- str = str.replaceAll(spacing[1], "\n");
738
- const l = spacing.length;
739
- $loc.pos += l;
740
- $loc.length -= l;
741
- }
742
- if (trim) {
743
- str = str.replace(/^(\r?\n|\n)/, "").replace(/(\r?\n|\n)[ \t]*$/, "");
732
+ function getIndentLevel(str, tab) {
733
+ if (tab != null && tab != 1) {
734
+ const tabs = str.match(/\t/g);
735
+ const numTabs = tabs ? tabs.length : 0;
736
+ return numTabs * tab + /*spaces*/
737
+ (str.length - numTabs);
738
+ } else {
739
+ return str.length;
740
+ }
741
+ }
742
+ function reduceIndentLevel(str, dedent, tab) {
743
+ if (tab != null && tab != 1) {
744
+ for (let i1 = 0, len1 = str.length; i1 < len1; i1++) {
745
+ const i = i1;
746
+ const char = str[i1];
747
+ if (!dedent) {
748
+ return str.slice(i);
749
+ }
750
+ if (char == " ") {
751
+ dedent -= tab;
752
+ if (dedent < 0) {
753
+ return "".padStart(-dedent, " ") + str.slice(i + 1);
754
+ }
755
+ } else {
756
+ dedent--;
757
+ }
758
+ }
759
+ return "";
760
+ } else {
761
+ return str.slice(dedent);
762
+ }
763
+ }
764
+ var indentRe = /\n([ \t]*)(?![ \t]|\r?\n|$)/g;
765
+ function getIndentOfBlockString(str, tab) {
766
+ let minLevel = Infinity;
767
+ let ref1;
768
+ while (ref1 = indentRe.exec(str)) {
769
+ const match = ref1;
770
+ const level = getIndentLevel(match[1], tab);
771
+ if (level < minLevel) {
772
+ minLevel = level;
773
+ }
774
+ }
775
+ if (minLevel == Infinity) {
776
+ minLevel = 0;
777
+ }
778
+ return minLevel;
779
+ }
780
+ function dedentBlockString({ $loc, token: str }, tab, dedent, trimStart = true, trimEnd = true) {
781
+ if (dedent == null && /^[ \t]*\r?\n/.test(str)) {
782
+ dedent = getIndentOfBlockString(str, tab);
783
+ }
784
+ if (dedent) {
785
+ str = str.replace(/(\n)([ \t]*)/g, (_, newline, indent) => {
786
+ return newline + reduceIndentLevel(indent, dedent, tab);
787
+ });
788
+ }
789
+ if (trimStart) {
790
+ str = str.replace(/^[ \t]*\r?\n/, "");
791
+ }
792
+ if (trimEnd) {
793
+ str = str.replace(/(\r?\n|\n)[ \t]*$/, "");
744
794
  }
745
795
  str = str.replace(/(\\.|`|\$\{)/g, (s) => {
746
796
  if (s[0] === "\\") {
747
797
  return s;
798
+ } else {
799
+ return `\\${s}`;
748
800
  }
749
- return `\\${s}`;
750
801
  });
751
- return {
752
- $loc,
753
- token: str
754
- };
802
+ return { $loc, token: str };
755
803
  }
756
- function dedentBlockSubstitutions($0) {
804
+ function dedentBlockSubstitutions($0, tab) {
757
805
  const [s, strWithSubstitutions, e] = $0;
758
- if (strWithSubstitutions.length === 0) {
806
+ if (!strWithSubstitutions.length) {
759
807
  return $0;
760
808
  }
761
- let initialSpacing, i = 0, l = strWithSubstitutions.length, results = [s];
762
- const { token } = strWithSubstitutions[0];
763
- if (token) {
764
- initialSpacing = token.match(initialSpacingRe);
765
- } else {
766
- initialSpacing = false;
767
- }
768
- while (i < l) {
769
- let segment = strWithSubstitutions[i];
770
- if (segment.token) {
771
- segment = dedentBlockString(segment, initialSpacing, false);
772
- if (i === 0) {
773
- segment.token = segment.token.replace(/^(\r?\n|\n)/, "");
774
- }
775
- if (i === l - 1) {
776
- segment.token = segment.token.replace(/(\r?\n|\n)[ \t]*$/, "");
777
- }
778
- results.push(segment);
779
- } else {
780
- results.push(segment);
809
+ const stringPart = (() => {
810
+ const results1 = [];
811
+ for (let i2 = 0, len2 = strWithSubstitutions.length; i2 < len2; i2++) {
812
+ const part = strWithSubstitutions[i2];
813
+ results1.push(part.token ?? "s");
781
814
  }
782
- i++;
815
+ ;
816
+ return results1;
817
+ })().join("");
818
+ const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
819
+ let results = [s];
820
+ for (let i3 = 0, len3 = strWithSubstitutions.length; i3 < len3; i3++) {
821
+ const i = i3;
822
+ let part = strWithSubstitutions[i3];
823
+ if (part.token != null) {
824
+ part = dedentBlockString(
825
+ part,
826
+ tab,
827
+ dedent,
828
+ i === 0,
829
+ i === strWithSubstitutions.length - 1
830
+ );
831
+ }
832
+ results.push(part);
783
833
  }
784
834
  results.push(e);
785
835
  return {
@@ -1308,17 +1358,17 @@ var require_lib = __commonJS({
1308
1358
  }
1309
1359
  function arrayRecurse(array) {
1310
1360
  const len2 = array.length;
1311
- const results1 = [];
1361
+ const results2 = [];
1312
1362
  for (let i = 0; i < len2; i++) {
1313
1363
  const c = array[i];
1314
1364
  if (c === child || Array.isArray(c) && arrayRecurse(c)) {
1315
1365
  return true;
1316
1366
  } else {
1317
- results1.push(void 0);
1367
+ results2.push(void 0);
1318
1368
  }
1319
1369
  }
1320
1370
  ;
1321
- return results1;
1371
+ return results2;
1322
1372
  }
1323
1373
  return -1;
1324
1374
  }
@@ -2312,9 +2362,11 @@ var require_lib = __commonJS({
2312
2362
  }
2313
2363
  if (expr.type === "AssignmentExpression" || expr.type === "UpdateExpression") {
2314
2364
  if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
2315
- post.push([", ", lhs]);
2365
+ pre.push("(");
2366
+ post.push([", ", lhs, ")"]);
2316
2367
  } else {
2317
- pre.push([lhs, ", "]);
2368
+ pre.push(["(", lhs, ", "]);
2369
+ post.push(")");
2318
2370
  }
2319
2371
  return expr.assigned;
2320
2372
  }
@@ -3460,7 +3512,7 @@ var require_lib = __commonJS({
3460
3512
  gatherRecursive,
3461
3513
  gatherRecursiveAll,
3462
3514
  gatherRecursiveWithinFunction,
3463
- getIndent,
3515
+ getIndentLevel,
3464
3516
  getTrimmingSpace,
3465
3517
  hasAwait,
3466
3518
  hasYield,
@@ -4469,7 +4521,7 @@ var require_parser = __commonJS({
4469
4521
  var $R43 = $R(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
4470
4522
  var $R44 = $R(new RegExp("[^]*?###", "suy"));
4471
4523
  var $R45 = $R(new RegExp("###(?!#)", "suy"));
4472
- var $R46 = $R(new RegExp("[^\\r\\n]", "suy"));
4524
+ var $R46 = $R(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
4473
4525
  var $R47 = $R(new RegExp("[ \\t]+", "suy"));
4474
4526
  var $R48 = $R(new RegExp("(?!\\p{ID_Continue})", "suy"));
4475
4527
  var $R49 = $R(new RegExp("['\u2019]s", "suy"));
@@ -5517,7 +5569,7 @@ var require_parser = __commonJS({
5517
5569
  function CallExpressionRest(ctx, state) {
5518
5570
  return $EVENT_C(ctx, state, "CallExpressionRest", CallExpressionRest$$);
5519
5571
  }
5520
- var OptionalShorthand$0 = $TS($S($Q(MultiLineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5572
+ var OptionalShorthand$0 = $TS($S($Q(InlineComment), QuestionMark, OptionalDot), function($skip, $loc, $0, $1, $2, $3) {
5521
5573
  return {
5522
5574
  type: "Optional",
5523
5575
  children: $0
@@ -5526,8 +5578,8 @@ var require_parser = __commonJS({
5526
5578
  function OptionalShorthand(ctx, state) {
5527
5579
  return $EVENT(ctx, state, "OptionalShorthand", OptionalShorthand$0);
5528
5580
  }
5529
- var OptionalDot$0 = $S($Q(MultiLineComment), Dot);
5530
- var OptionalDot$1 = $S(InsertDot, $Q(MultiLineComment));
5581
+ var OptionalDot$0 = $S($Q(InlineComment), Dot);
5582
+ var OptionalDot$1 = $S(InsertDot, $Q(InlineComment));
5531
5583
  var OptionalDot$$ = [OptionalDot$0, OptionalDot$1];
5532
5584
  function OptionalDot(ctx, state) {
5533
5585
  return $EVENT_C(ctx, state, "OptionalDot", OptionalDot$$);
@@ -5558,7 +5610,7 @@ var require_parser = __commonJS({
5558
5610
  function MemberBase(ctx, state) {
5559
5611
  return $EVENT_C(ctx, state, "MemberBase", MemberBase$$);
5560
5612
  }
5561
- var MemberExpressionRest$0 = $TS($S($Q(MultiLineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5613
+ var MemberExpressionRest$0 = $TS($S($Q(InlineComment), MemberExpressionRestBody), function($skip, $loc, $0, $1, $2) {
5562
5614
  var comments = $1;
5563
5615
  var body = $2;
5564
5616
  if (Array.isArray(body))
@@ -5571,7 +5623,7 @@ var require_parser = __commonJS({
5571
5623
  function MemberExpressionRest(ctx, state) {
5572
5624
  return $EVENT(ctx, state, "MemberExpressionRest", MemberExpressionRest$0);
5573
5625
  }
5574
- var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(MultiLineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5626
+ var MemberExpressionRestBody$0 = $TS($S($E($C(OptionalShorthand, NonNullAssertion)), $Q(InlineComment), MemberBracketContent), function($skip, $loc, $0, $1, $2, $3) {
5575
5627
  var dot = $1;
5576
5628
  var comments = $2;
5577
5629
  var content = $3;
@@ -5729,7 +5781,7 @@ var require_parser = __commonJS({
5729
5781
  function AccessStart(ctx, state) {
5730
5782
  return $EVENT(ctx, state, "AccessStart", AccessStart$0);
5731
5783
  }
5732
- var PropertyAccess$0 = $TS($S(AccessStart, $Q(MultiLineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5784
+ var PropertyAccess$0 = $TS($S(AccessStart, $Q(InlineComment), $C(IdentifierName, PrivateIdentifier)), function($skip, $loc, $0, $1, $2, $3) {
5733
5785
  var access = $1;
5734
5786
  var comments = $2;
5735
5787
  var id = $3;
@@ -5761,7 +5813,7 @@ var require_parser = __commonJS({
5761
5813
  function PropertyAccess(ctx, state) {
5762
5814
  return $EVENT_C(ctx, state, "PropertyAccess", PropertyAccess$$);
5763
5815
  }
5764
- var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(MultiLineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5816
+ var PropertyGlob$0 = $TS($S($S($E($C(QuestionMark, NonNullAssertion)), OptionalDot), $Q(InlineComment), BracedObjectLiteral), function($skip, $loc, $0, $1, $2, $3) {
5765
5817
  var dot = $1;
5766
5818
  var object = $3;
5767
5819
  return {
@@ -9967,7 +10019,7 @@ var require_parser = __commonJS({
9967
10019
  return $EVENT(ctx, state, "RegularExpressionFlags", RegularExpressionFlags$0);
9968
10020
  }
9969
10021
  var TemplateLiteral$0 = $TS($S(TripleTick, $Q($C(TemplateBlockCharacters, TemplateSubstitution)), TripleTick), function($skip, $loc, $0, $1, $2, $3) {
9970
- return dedentBlockSubstitutions($0);
10022
+ return dedentBlockSubstitutions($0, module2.config.tab);
9971
10023
  });
9972
10024
  var TemplateLiteral$1 = $TS($S(Backtick, $Q($C(TemplateCharacters, TemplateSubstitution)), Backtick), function($skip, $loc, $0, $1, $2, $3) {
9973
10025
  return {
@@ -9976,7 +10028,7 @@ var require_parser = __commonJS({
9976
10028
  };
9977
10029
  });
9978
10030
  var TemplateLiteral$2 = $TS($S(TripleDoubleQuote, $Q($C(TripleDoubleStringCharacters, CoffeeStringSubstitution)), TripleDoubleQuote), function($skip, $loc, $0, $1, $2, $3) {
9979
- return dedentBlockSubstitutions($0);
10031
+ return dedentBlockSubstitutions($0, module2.config.tab);
9980
10032
  });
9981
10033
  var TemplateLiteral$3 = $TS($S(TripleSingleQuote, TripleSingleStringCharacters, TripleSingleQuote), function($skip, $loc, $0, $1, $2, $3) {
9982
10034
  var s = $1;
@@ -9984,7 +10036,7 @@ var require_parser = __commonJS({
9984
10036
  var e = $3;
9985
10037
  return {
9986
10038
  type: "TemplateLiteral",
9987
- children: [s, dedentBlockString(str), e]
10039
+ children: [s, dedentBlockString(str, module2.config.tab), e]
9988
10040
  };
9989
10041
  });
9990
10042
  var TemplateLiteral$4 = CoffeeInterpolatedDoubleQuotedString;
@@ -10064,13 +10116,13 @@ var require_parser = __commonJS({
10064
10116
  function CoffeeHereCommentStart(ctx, state) {
10065
10117
  return $EVENT(ctx, state, "CoffeeHereCommentStart", CoffeeHereCommentStart$0);
10066
10118
  }
10067
- 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) {
10068
- return { $loc, token: $1 };
10119
+ var InlineComment$0 = $TR($EXPECT($R46, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
10120
+ return { $loc, token: $0 };
10069
10121
  });
10070
10122
  function InlineComment(ctx, state) {
10071
10123
  return $EVENT(ctx, state, "InlineComment", InlineComment$0);
10072
10124
  }
10073
- var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, SingleLineComment, MultiLineComment)), EOL);
10125
+ var RestOfLine$0 = $S($Q($C(NonNewlineWhitespace, Comment)), EOL);
10074
10126
  function RestOfLine(ctx, state) {
10075
10127
  return $EVENT(ctx, state, "RestOfLine", RestOfLine$0);
10076
10128
  }
@@ -12480,7 +12532,7 @@ var require_parser = __commonJS({
12480
12532
  indexOf(indexOfRef) {
12481
12533
  const typeSuffix = {
12482
12534
  ts: true,
12483
- children: [": <T>(this: T[], searchElement: T) => boolean"]
12535
+ children: [": <T>(this: T[], searchElement: T) => number"]
12484
12536
  };
12485
12537
  module2.prelude.push(["", [preludeVar, indexOfRef, typeSuffix, " = [].indexOf", asAny, ";\n"]]);
12486
12538
  },
@@ -12618,8 +12670,8 @@ var require_parser = __commonJS({
12618
12670
  function Reset(ctx, state) {
12619
12671
  return $EVENT(ctx, state, "Reset", Reset$0);
12620
12672
  }
12621
- var Init$0 = $TS($S($E(Shebang), $Q(TripleSlashDirective), $Q(DirectivePrologue)), function($skip, $loc, $0, $1, $2, $3) {
12622
- var directives = $3;
12673
+ var Init$0 = $TS($S($E(Shebang), $Q($C(TripleSlashDirective, $S($C(JSSingleLineComment, JSMultiLineComment), EOS), DirectivePrologue))), function($skip, $loc, $0, $1, $2) {
12674
+ var directives = $2;
12623
12675
  directives.forEach((directive) => {
12624
12676
  if (directive.type === "CivetPrologue") {
12625
12677
  Object.assign(module2.config, directive.config);
@@ -12631,15 +12683,7 @@ var require_parser = __commonJS({
12631
12683
  return $EVENT(ctx, state, "Init", Init$0);
12632
12684
  }
12633
12685
  var Indent$0 = $TR($EXPECT($R67, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
12634
- let level;
12635
- if (module2.config.tab) {
12636
- const tabs = $0.match(/\t/g);
12637
- const numTabs = tabs ? tabs.length : 0;
12638
- level = numTabs * module2.config.tab + /*spaces*/
12639
- ($0.length - numTabs);
12640
- } else {
12641
- level = $0.length;
12642
- }
12686
+ const level = getIndentLevel($0, module2.config.tab);
12643
12687
  return {
12644
12688
  $loc,
12645
12689
  token: $0,
@@ -13437,6 +13481,7 @@ var require_parser = __commonJS({
13437
13481
  expressionizeIfClause,
13438
13482
  forRange,
13439
13483
  gatherBindingCode,
13484
+ getIndentLevel,
13440
13485
  getTrimmingSpace,
13441
13486
  hasAwait,
13442
13487
  hasYield,
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 {
@@ -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,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.39",
4
+ "version": "0.6.41",
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.38",
73
+ "@danielx/civet": "0.6.40",
74
74
  "@danielx/hera": "^0.8.10",
75
75
  "@types/assert": "^1.5.6",
76
76
  "@types/mocha": "^9.1.1",