@mrclrchtr/supi-lsp 11.0.0 → 11.1.0

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.
@@ -26,6 +26,8 @@ var ESCAPE = '\\';
26
26
  var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
27
27
  var BOM = "\uFEFF";
28
28
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
29
+ // A run of two or more asterisks is a globstar (#175)
30
+ var REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
29
31
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
30
32
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
31
33
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
@@ -60,12 +62,6 @@ var RETURN_FALSE = function RETURN_FALSE() {
60
62
  return false;
61
63
  };
62
64
 
63
- // See fixtures #59
64
- var cleanRangeBackSlash = function cleanRangeBackSlash(slashes) {
65
- var length = slashes.length;
66
- return slashes.slice(0, length - length % 2);
67
- };
68
-
69
65
  // > The range notation, e.g. [a-zA-Z],
70
66
  // > can be used to match one of the characters in a range.
71
67
  //
@@ -187,13 +183,13 @@ var scanBracket = function scanBracket(pattern, start) {
187
183
  return null;
188
184
  }
189
185
  if (end > nameStart && pattern[end - 1] === ':') {
190
- var expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
186
+ var name = pattern.slice(nameStart, end - 1);
191
187
 
192
188
  // An unknown class name makes the whole pattern match nothing
193
- if (expanded === UNDEFINED) {
189
+ if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) {
194
190
  return null;
195
191
  }
196
- body += expanded;
192
+ body += POSIX_CLASSES[name];
197
193
  prev = EMPTY;
198
194
  index = end;
199
195
  } else {
@@ -233,9 +229,10 @@ var REGEX_RESTORE_PLACEHOLDER = new RegExp("".concat(PLACEHOLDER, "(\\d+)").conc
233
229
  // That is what keeps it apart from a user-escaped literal `\*`: the unescape
234
230
  // steps collapse the escaped one to the exact `\*` a wildcard would leave
235
231
  // behind, so by the time `_make` runs the two are otherwise the same string
236
- // and a literal star gets wrongly rewritten into a wildcard. This marker is a
237
- // private-use character no compiled pattern carries, and it never survives
238
- // into a `RegExp` -- `_make` always turns it back into a real wildcard first.
232
+ // and a literal star gets wrongly rewritten into a wildcard. The marker is a
233
+ // private-use character, and `extractBrackets` keeps one that came out of the
234
+ // pattern apart from it, so the only marker `_make` ever turns back into a
235
+ // real wildcard is the one this chain put there itself.
239
236
  var TRAILING_WILDCARD = "\uE000";
240
237
 
241
238
  // A trailing "/**" is deferred the same way, because `checkRegex` has to tell
@@ -243,6 +240,27 @@ var TRAILING_WILDCARD = "\uE000";
243
240
  // still never matches the folder itself (#21).
244
241
  var TRAILING_DOUBLESTAR = "\uE001";
245
242
 
243
+ // The three characters above mean something to the chain that builds the
244
+ // source rather than to the path, so one that came out of the pattern is
245
+ // held aside like a bracket expression instead of going straight out. Being
246
+ // held is what makes it safe: the restore runs after the step that anchors
247
+ // the source, so the character comes back in the middle of the source and
248
+ // not at its end, which is the one place `_make` and `checkSourceOf` look
249
+ // for a marker. Without it a pattern's own character lands where a pending
250
+ // marker sits, and `_make` turns it into a real trailing wildcard.
251
+ //
252
+ // It is held as a one-member class rather than bare, in both of the branches
253
+ // a reserved character can reach, so that the property can be
254
+ // read off this function alone -- a reserved character never goes out on
255
+ // its own -- rather than depending on where in the chain the restore
256
+ // happens to run. In the expression built here `[x]` matches exactly what
257
+ // `x` matches, none of the three being special to a regular expression or
258
+ // inside a class, so no test can tell the two apart: the class is insurance,
259
+ // and the paragraph above is the reason it is not needed.
260
+ var isReserved = function isReserved(_char3) {
261
+ return _char3 === PLACEHOLDER || _char3 === TRAILING_WILDCARD || _char3 === TRAILING_DOUBLESTAR;
262
+ };
263
+
246
264
  // Replace every bracket expression with a placeholder the replacers below
247
265
  // leave alone, and translate it separately.
248
266
  var extractBrackets = function extractBrackets(pattern) {
@@ -254,8 +272,8 @@ var extractBrackets = function extractBrackets(pattern) {
254
272
  var out = EMPTY;
255
273
  var index = 0;
256
274
  while (index < length) {
257
- var _char3 = pattern[index];
258
- if (_char3 === ESCAPE) {
275
+ var _char4 = pattern[index];
276
+ if (_char4 === ESCAPE) {
259
277
  // > Put a backslash ("\") in front of ... a character to make it literal.
260
278
  // (gitignore(5) -> fnmatch(3))
261
279
  // A backslash quotes the next character, whatever it is, so `\d` is a
@@ -265,29 +283,34 @@ var extractBrackets = function extractBrackets(pattern) {
265
283
  // `\1`, `\/` keep their regular-expression meaning, and would turn a
266
284
  // `\?` into `[^\/]`.
267
285
  //
268
- // Four escapes are left for the chain, each with dedicated handling it
269
- // would be wrong to bypass: `\*` (a literal star, told apart from a
270
- // wildcard by `TRAILING_WILDCARD` and the wildcard replacers), `\[`
271
- // (a literal bracket, the one `[` the bracket replacer still expects),
272
- // `\ ` (a quoted trailing space), and `\\` (a literal backslash). A
273
- // lone trailing backslash can reach here after line-ending cleanup.
286
+ // Three escapes are still left for the chain: `\*` (a literal star,
287
+ // told apart from a wildcard by `TRAILING_WILDCARD` and the wildcard
288
+ // replacers), `\[` (a literal bracket, the one `[` the bracket
289
+ // replacer still expects), and `\ ` (a quoted space, which one pass
290
+ // below rewrites in bulk -- holding each one aside instead costs more
291
+ // on a pattern built out of them). A lone trailing backslash can reach
292
+ // here after line-ending cleanup.
293
+ //
294
+ // A quoted backslash is not among them. The chain doubles every
295
+ // backslash, then takes the doubling back out again, and a quoted one
296
+ // standing next to a character the chain also escapes left the two
297
+ // counts sharing a run, so one of the escapes was lost. Held here as
298
+ // the literal it means, it never joins that run.
274
299
  var escaped = pattern[index + 1];
275
300
  if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
276
301
  // Git removes a final directory slash before matching. An escape
277
302
  // without a character after that removal makes the pattern invalid.
278
303
  out += hold(NEVER_MATCH);
279
- } else if (escaped === '*' || escaped === '[' || escaped === SPACE || escaped === ESCAPE) {
304
+ } else if (escaped === '*' || escaped === '[' || escaped === SPACE) {
280
305
  out += pattern.slice(index, index + 2);
281
306
  } else {
282
- out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped);
307
+ out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : isReserved(escaped) ? "[".concat(escaped, "]") : escaped);
283
308
  }
284
309
  index += 2;
285
- } else if (_char3 === PLACEHOLDER) {
286
- // Hold a literal placeholder character aside as well, so that pattern
287
- // text can never be mistaken for a placeholder we emitted.
288
- out += hold("[".concat(PLACEHOLDER, "]"));
310
+ } else if (isReserved(_char4)) {
311
+ out += hold("[".concat(_char4, "]"));
289
312
  index++;
290
- } else if (_char3 === '[') {
313
+ } else if (_char4 === '[') {
291
314
  var scanned = scanBracket(pattern, index);
292
315
  if (scanned === null) {
293
316
  // git gives up on the whole pattern (`WM_ABORT_ALL`), so whatever
@@ -299,7 +322,7 @@ var extractBrackets = function extractBrackets(pattern) {
299
322
  index = scanned.end + 1;
300
323
  }
301
324
  } else {
302
- out += _char3;
325
+ out += _char4;
303
326
  index++;
304
327
  }
305
328
  }
@@ -365,6 +388,18 @@ var REPLACERS = [
365
388
  /(\\+)( ?)/g, function (_, run, space) {
366
389
  return space ? run.slice(0, run.length - run.length % 2) + SPACE : run;
367
390
  }, ESCAPE + SPACE],
391
+ // git's wildmatch() reads a run of two or more asterisks as one globstar
392
+ // whenever the run fills a path segment: it starts the pattern or follows
393
+ // a `/`, and it ends the pattern or comes before a `/`. A run of two is
394
+ // already `**`; a longer one is folded into `**` here, so the steps
395
+ // below only ever have to know `**`.
396
+ // `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
397
+ // git also takes a run beside a literal prefix (`a***/b`) or beside an
398
+ // escaped slash (`***\/b`) as a globstar, and this does not; the README
399
+ // lists both, under "A run of asterisks".
400
+ [/(^|\/)\*{3,}(?=\/|$)/g, function (_, start) {
401
+ return "".concat(start, "**");
402
+ }, '*'],
368
403
  // Escape metacharacters
369
404
  // which is written down by users but means special for regular expressions.
370
405
 
@@ -499,25 +534,23 @@ function (_, p1, p2) {
499
534
  // trailing wildcard, held apart from a literal star
500
535
  [
501
536
  // The step above leaves a trailing `*` alone, so a single `\*` is all that
502
- // can be left at the end here. Whether it is a wildcard or a literal
503
- // turns on the backslashes the user put in front of it: the escaper has
504
- // since doubled every one, so what stands here is those `2N` doubled
505
- // backslashes and then the star's own escape. An even number of the
506
- // original `N` leaves the star unescaped -- a wildcard -- and an odd
507
- // number escapes it -- a literal. This runs while the two are still
508
- // distinct, before the unescape steps below collapse the literal onto
509
- // the very `\*` a wildcard leaves behind.
537
+ // can be left at the end here, and what stands in front of it says which
538
+ // kind it is. A wildcard arrives as the escaper wrote it, `\*` with
539
+ // nothing before it; a literal arrives as the user's own escape, which
540
+ // the escaper doubled, and then the star's own -- `\\` and then `\*`.
541
+ // There is no third case: every backslash still reaching the chain is
542
+ // one `\*`, `\[` or `\ ` carries itself, and each is followed by its
543
+ // own character, so a longer run can never form. This runs while the
544
+ // two are still distinct, before the unescape steps below collapse the
545
+ // literal onto the very `\*` a wildcard leaves behind.
510
546
  /(^|[^\\])((?:\\\\)*)\\\*$/, function (match, p1, p2) {
511
- return (
512
- // `p2` holds the doubled user backslashes; half of them is `N`.
513
- p2.length / 2 % 2 === 0
514
- // A real wildcard: carry it to `_make` as the marker, so the unescape
515
- // steps and the trailing-wildcard rewrite can never mistake it for a
516
- // literal `\*` (nor the reverse).
517
- ? p1 + p2 + TRAILING_WILDCARD
518
- // A literal star: leave it exactly as it stands for the unescape steps.
519
- : match
520
- );
547
+ return p2 === EMPTY
548
+ // A real wildcard: carry it to `_make` as the marker, so the unescape
549
+ // steps and the trailing-wildcard rewrite can never mistake it for a
550
+ // literal `\*` (nor the reverse).
551
+ ? p1 + TRAILING_WILDCARD
552
+ // A literal star: leave it exactly as it stands for the unescape steps.
553
+ : match;
521
554
  }, '*'], [
522
555
  // unescape, revert step 3 except for back slash
523
556
  // For example, if a user escape a '\\*',
@@ -533,11 +566,12 @@ function (_, p1, p2) {
533
566
  // been held aside by `extractBrackets`, so the only `[` left in the
534
567
  // pattern is an escaped, literal one.
535
568
 
536
- // `\` is escaped by step 3
537
- /\\\[([^\]/]*?)(\\*)($|\])/g,
538
- // '\\[bar]' -> '\\\\[bar\\]'
539
- function (match, range, endEscape, close) {
540
- return "\\[".concat(range).concat(cleanRangeBackSlash(endEscape)).concat(close);
569
+ // A backslash could only stand at the end of the range if it quoted the
570
+ // `]`, and `\]` is held aside long before this.
571
+ /\\\[([^\]/]*?)($|\])/g,
572
+ // '\\[bar]' -> '\\\\[bar]'
573
+ function (match, range, close) {
574
+ return "\\[".concat(range).concat(close);
541
575
  }, '['],
542
576
  // ending
543
577
  [
@@ -596,30 +630,41 @@ var replaceTrailingDoublestar = function replaceTrailingDoublestar() {
596
630
  };
597
631
  var WILDCARD = '[^\\/]*';
598
632
 
599
- // Where a run of non-slash wildcards is split by single fixed characters --
600
- // `[^/]*x[^/]*y...` -- the engine has many equivalent ways to lay the
633
+ // The fixed piece between the wildcard at `at` and the next wildcard of the
634
+ // run: the tokens that separate them, joined as they appear in the source.
635
+ // A run never holds two wildcards in a row, so there is always at least one
636
+ // token.
637
+ var separatorAfter = function separatorAfter(run, at) {
638
+ var separator = EMPTY;
639
+ for (var index = at + 1; index < run.length && !run[index].wildcard; index++) {
640
+ separator += run[index].single;
641
+ }
642
+ return separator;
643
+ };
644
+
645
+ // Where a run of non-slash wildcards is split by fixed pieces --
646
+ // `[^/]*ab[^/]*cd...` -- the engine has many equivalent ways to lay the
601
647
  // input across the wildcards, and on input that does not match it works
602
648
  // through all of them, so the time grows with the number of wildcards
603
649
  // rather than the length of the path. Every wildcard but the last in such a
604
- // run can be pinned to stop at the character that follows it, which leaves
650
+ // run can be pinned to stop where the piece after it begins, which leaves
605
651
  // one way to lay out the input and no rewinding, without changing which
606
- // paths match: the fixed characters still bound the count, and the last
652
+ // paths match: the fixed pieces still bound the count, and the last
607
653
  // wildcard still absorbs the rest.
608
654
  //
655
+ // A wildcard is pinned to the whole piece, never to the piece's first
656
+ // character. The pin leaves no way back, so a wildcard that stopped at that
657
+ // first character would hand over wherever the character happens to turn
658
+ // up, including the places the rest of the piece cannot follow -- which is
659
+ // how `f*o/*/*` came to miss `foo/b/c`, the first `o` of `foo` not being
660
+ // the one the `o/` after it needs. Every token of a piece matches exactly
661
+ // one character, so the first place the whole piece fits is the leftmost
662
+ // place it can sit, and whatever is left over goes to the wildcards that
663
+ // follow.
664
+ //
609
665
  // The source is read one token at a time -- a wildcard, a single-character
610
666
  // piece (a literal, an escape, a class), or a parenthesised group or anchor
611
667
  // that ends the run -- so only a genuine wildcard is touched.
612
-
613
- // The fixed pieces between the wildcard at `at` and the next wildcard of the
614
- // run, joined as they appear in the source. A run never holds two wildcards
615
- // in a row, so there is always at least one piece.
616
- var separatorAfter = function separatorAfter(run, at) {
617
- var separator = EMPTY;
618
- for (var index = at + 1; index < run.length && !run[index].wildcard; index++) {
619
- separator += run[index].single;
620
- }
621
- return separator;
622
- };
623
668
  var pinWildcards = function pinWildcards(source) {
624
669
  if (source.indexOf(WILDCARD) < 0) {
625
670
  return source;
@@ -628,13 +673,13 @@ var pinWildcards = function pinWildcards(source) {
628
673
  var length = source.length;
629
674
  var index = 0;
630
675
  while (index < length) {
631
- var _char4 = source[index];
676
+ var _char5 = source[index];
632
677
  if (source.startsWith(WILDCARD, index)) {
633
678
  tokens.push({
634
679
  wildcard: true
635
680
  });
636
681
  index += WILDCARD.length;
637
- } else if (_char4 === '[') {
682
+ } else if (_char5 === '[') {
638
683
  var end = index + 1;
639
684
  if (source[end] === '^') {
640
685
  end++;
@@ -650,12 +695,12 @@ var pinWildcards = function pinWildcards(source) {
650
695
  single: source.slice(index, end)
651
696
  });
652
697
  index = end;
653
- } else if (_char4 === ESCAPE) {
698
+ } else if (_char5 === ESCAPE) {
654
699
  tokens.push({
655
700
  single: source.slice(index, index + 2)
656
701
  });
657
702
  index += 2;
658
- } else if (_char4 === '(') {
703
+ } else if (_char5 === '(') {
659
704
  var depth = 0;
660
705
  var _end = index;
661
706
  do {
@@ -675,14 +720,14 @@ var pinWildcards = function pinWildcards(source) {
675
720
  boundary: source.slice(index, _end)
676
721
  });
677
722
  index = _end;
678
- } else if (_char4 === '^' || _char4 === '$') {
723
+ } else if (_char5 === '^' || _char5 === '$') {
679
724
  tokens.push({
680
- boundary: _char4
725
+ boundary: _char5
681
726
  });
682
727
  index++;
683
728
  } else {
684
729
  tokens.push({
685
- single: _char4
730
+ single: _char5
686
731
  });
687
732
  index++;
688
733
  }
@@ -702,16 +747,9 @@ var pinWildcards = function pinWildcards(source) {
702
747
  return;
703
748
  }
704
749
 
705
- // A wildcard that is not the last in the run is pinned to the whole
706
- // fixed piece that separates it from the next wildcard, not just to
707
- // that piece's first character: stopping at the first character alone
708
- // would let the wildcard hand over at a place where the rest of the
709
- // separator cannot follow, and the pin leaves no way back, so
710
- // `f*o/*/*` would miss `foo/b/c` -- the first `o` of `foo` is not the
711
- // one the `o/` after it needs. Every piece matches exactly one
712
- // character, so pinning to the first place the whole separator fits
713
- // is the leftmost place it can sit, and the wildcards that follow
714
- // take up whatever is left.
750
+ // Every wildcard but the last is pinned to the whole piece that
751
+ // follows it, for the reason set out above this function. The last
752
+ // one stays as it is and takes up the rest.
715
753
  out += at === lastWildcard ? WILDCARD : "(?:(?!".concat(separatorAfter(run, at), ")[^\\/])*");
716
754
  });
717
755
  run = [];
@@ -730,6 +768,14 @@ var pinWildcards = function pinWildcards(source) {
730
768
 
731
769
  // @param {pattern}
732
770
  var makeRegexPrefix = function makeRegexPrefix(pattern) {
771
+ // `/**` matches every path, as `**` does. The translation below only finds
772
+ // a globstar beside a slash it keeps, and the leading one is turned into
773
+ // an anchor, so `/**` would come out as `/*` and match one level only.
774
+ // Here rather than in `createRule`, so that `checkSourceOf`, which
775
+ // compiles `/**/` again without its trailing slash, gets it too.
776
+ if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
777
+ pattern = '**';
778
+ }
733
779
  var _extractBrackets = extractBrackets(pattern),
734
780
  source = _extractBrackets.source,
735
781
  sources = _extractBrackets.sources;
@@ -890,8 +936,8 @@ var IgnoreRule = /*#__PURE__*/function () {
890
936
  }]);
891
937
  return IgnoreRule;
892
938
  }();
893
- var isLineEnd = function isLineEnd(_char5) {
894
- return _char5 === '\r' || _char5 === '\n';
939
+ var isLineEnd = function isLineEnd(_char6) {
940
+ return _char6 === '\r' || _char6 === '\n';
895
941
  };
896
942
 
897
943
  // Drop a line terminator, which can remain when patterns are passed as an
@@ -1057,19 +1103,12 @@ var RuleManager = /*#__PURE__*/function () {
1057
1103
 
1058
1104
  // Test one single path without recursively checking parent directories
1059
1105
  //
1060
- // - checkUnignored `boolean` whether should check if the path is unignored,
1061
- // setting `checkUnignored` to `false` could reduce additional
1062
- // path matching.
1063
- // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1106
+ // - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1064
1107
 
1065
- // @returns {TestResult} true if a file is ignored
1108
+ // @returns {TestResult}
1066
1109
  }, {
1067
1110
  key: "test",
1068
- value: function test(path, checkUnignored, mode) {
1069
- var ignored = false;
1070
- var unignored = false;
1071
- var matchedRule;
1072
-
1111
+ value: function test(path, mode) {
1073
1112
  // Most of a .gitignore is patterns with no slash in them, and running
1074
1113
  // those against the whole path makes the regular expression engine walk
1075
1114
  // every directory name on the way to the only segment that could match.
@@ -1080,40 +1119,31 @@ var RuleManager = /*#__PURE__*/function () {
1080
1119
  var shortcut = this._basenameCount * 2 >= length;
1081
1120
  var basename = shortcut ? basenameOf(path) : path;
1082
1121
 
1122
+ // The last rule to match decides, as in git, and it is the rule
1123
+ // `git check-ignore -v` reports, so the scan runs from the end and stops
1124
+ // at the first match.
1083
1125
  // A plain loop rather than `forEach`, so that `path`, `basename` and
1084
1126
  // `shortcut` are locals. As a callback they became closure variables,
1085
1127
  // and reaching for one of those once per rule cost 10% of a scan over a
1086
1128
  // large rule set -- more than the shortcut they were there to serve.
1087
- for (var index = 0; index < length; index++) {
1129
+ for (var index = length - 1; index >= 0; index--) {
1088
1130
  var rule = rules[index];
1089
- var negative = rule.negative;
1090
-
1091
- // | ignored : unignored
1092
- // -------- | ---------------------------------------
1093
- // negative | 0:0 | 0:1 | 1:0 | 1:1
1094
- // -------- | ------- | ------- | ------- | --------
1095
- // 0 | TEST | TEST | SKIP | X
1096
- // 1 | TESTIF | SKIP | TEST | X
1097
-
1098
- // - SKIP: always skip
1099
- // - TEST: always test
1100
- // - TESTIF: only test if checkUnignored
1101
- // - X: that never happen
1102
- var skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
1103
- if (!skip && rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
1104
- ignored = !negative;
1105
- unignored = negative;
1106
- matchedRule = negative ? UNDEFINED : rule;
1131
+ if (rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
1132
+ var negative = rule.negative;
1133
+ var ret = {
1134
+ ignored: !negative,
1135
+ unignored: negative
1136
+ };
1137
+ if (!negative) {
1138
+ ret.rule = rule;
1139
+ }
1140
+ return ret;
1107
1141
  }
1108
1142
  }
1109
- var ret = {
1110
- ignored: ignored,
1111
- unignored: unignored
1143
+ return {
1144
+ ignored: false,
1145
+ unignored: false
1112
1146
  };
1113
- if (matchedRule) {
1114
- ret.rule = matchedRule;
1115
- }
1116
- return ret;
1117
1147
  }
1118
1148
  }]);
1119
1149
  return RuleManager;
@@ -1225,12 +1255,12 @@ var Ignore = /*#__PURE__*/function () {
1225
1255
  // @returns {TestResult}
1226
1256
  }, {
1227
1257
  key: "_test",
1228
- value: function _test(originalPath, cache, checkUnignored) {
1258
+ value: function _test(originalPath, cache) {
1229
1259
  var path = originalPath
1230
1260
  // Supports nullable path
1231
1261
  && checkPath.convert(originalPath);
1232
1262
  checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
1233
- return this._t(path, cache, checkUnignored);
1263
+ return this._t(path, cache);
1234
1264
  }
1235
1265
  }, {
1236
1266
  key: "checkIgnore",
@@ -1244,7 +1274,7 @@ var Ignore = /*#__PURE__*/function () {
1244
1274
  // Like `git check-ignore`: a directory excluded by itself or by an
1245
1275
  // ancestor settles it, and only then is the literal 'abc/' matched
1246
1276
  // against the rules (see `checkSourceOf`).
1247
- var dir = this._t(path, this._testCache, true);
1277
+ var dir = this._t(path, this._testCache);
1248
1278
  if (dir.ignored) {
1249
1279
  return dir;
1250
1280
  }
@@ -1257,25 +1287,23 @@ var Ignore = /*#__PURE__*/function () {
1257
1287
  // The path to be tested
1258
1288
  path,
1259
1289
  // The cache for the result of a certain checking
1260
- cache,
1261
- // Whether should check if the path is unignored
1262
- checkUnignored) {
1290
+ cache) {
1263
1291
  if (path in cache) {
1264
1292
  return cache[path];
1265
1293
  }
1266
1294
  var parentPath = parentOf(path);
1267
1295
 
1268
1296
  // If the path contains a parent directory, check the parent first
1269
- var parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
1297
+ var parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
1270
1298
  return cache[path] = parent && parent.ignored
1271
1299
  // > It is not possible to re-include a file if a parent directory of
1272
1300
  // > that file is excluded.
1273
- ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
1301
+ ? parent : this._rules.test(path, MODE_IGNORE);
1274
1302
  }
1275
1303
  }, {
1276
1304
  key: "ignores",
1277
1305
  value: function ignores(path) {
1278
- return this._test(path, this._ignoreCache, false).ignored;
1306
+ return this._test(path, this._ignoreCache).ignored;
1279
1307
  }
1280
1308
  }, {
1281
1309
  key: "createFilter",
@@ -1295,7 +1323,7 @@ var Ignore = /*#__PURE__*/function () {
1295
1323
  }, {
1296
1324
  key: "test",
1297
1325
  value: function test(path) {
1298
- return this._test(path, this._testCache, true);
1326
+ return this._test(path, this._testCache);
1299
1327
  }
1300
1328
  }]);
1301
1329
  return Ignore;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ignore",
3
- "version": "7.0.12",
3
+ "version": "7.0.14",
4
4
  "description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -6,6 +6,11 @@
6
6
 
7
7
  This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.
8
8
 
9
+ The Node.js entry point requires Node.js 14.17.0 or newer. The runtime abstraction layer exposes
10
+ `RAL().crypto.randomUUID()` for cryptographically generated v4 UUIDs. The browser implementation
11
+ uses native `crypto.randomUUID()` when available and falls back to `crypto.getRandomValues()`,
12
+ including in non-secure contexts. Custom RAL implementations must provide this capability.
13
+
9
14
  The npm module can also be used standalone to establish a [JSON-RPC](http://www.jsonrpc.org/) channel between
10
15
  a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.
11
16
 
@@ -145,6 +145,14 @@ class PromiseImpl {
145
145
  exports.PromiseImpl = PromiseImpl;
146
146
  const _textEncoder = new TextEncoder();
147
147
  const _ril = Object.freeze({
148
+ crypto: Object.freeze({
149
+ randomUUID() {
150
+ if (typeof globalThis.crypto.randomUUID === 'function') {
151
+ return globalThis.crypto.randomUUID();
152
+ }
153
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c => (+c ^ (globalThis.crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16));
154
+ }
155
+ }),
148
156
  messageBuffer: Object.freeze({
149
157
  create: (encoding) => new MessageBuffer(encoding)
150
158
  }),
@@ -418,11 +418,16 @@ function createMessageConnection(messageReader, messageWriter, _logger, options)
418
418
  }
419
419
  finally {
420
420
  if (result instanceof Promise) {
421
+ // Both settlements must release the parallelism slot. Written as
422
+ // .then(...).catch(...) the rejection path skipped the decrement, so
423
+ // one failed dispatch left `inFlight` permanently elevated and
424
+ // triggerMessageQueue() bailed out forever after.
421
425
  result.then(() => {
422
- inFlight--;
423
- triggerMessageQueue();
424
426
  }).catch((error) => {
425
427
  logger.error(`Processing message queue failed: ${error.toString()}`);
428
+ }).finally(() => {
429
+ inFlight--;
430
+ triggerMessageQueue();
426
431
  });
427
432
  }
428
433
  else {
@@ -42,7 +42,15 @@ interface _WritableStream {
42
42
  }
43
43
  interface _DuplexStream extends _ReadableStream, _WritableStream {
44
44
  }
45
+ /**
46
+ * Runtime abstraction implemented by this npm module.
47
+ * External implementations are not supported. Changes to this interface do not
48
+ * require a major version bump.
49
+ */
45
50
  interface RAL {
51
+ readonly crypto: {
52
+ randomUUID(): string;
53
+ };
46
54
  readonly applicationJson: {
47
55
  readonly encoder: ContentTypeEncoder;
48
56
  readonly decoder: ContentTypeDecoder;
@@ -46,12 +46,26 @@ export declare class StreamMessageWriter extends WriteableStreamMessageWriter {
46
46
  export declare function generateRandomPipeName(): string;
47
47
  export interface PipeTransport {
48
48
  onConnected(): Promise<[MessageReader, MessageWriter]>;
49
+ /**
50
+ * Closes the underlying server if a client hasn't connected yet. Callers
51
+ * should invoke this if they abandon the transport before `onConnected`
52
+ * resolves (for example because the server process failed to start) to
53
+ * avoid leaking the listening pipe.
54
+ */
55
+ close(): void;
49
56
  }
50
57
  export declare function createClientPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): Promise<PipeTransport>;
51
58
  export declare function createServerPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): [MessageReader, MessageWriter];
52
59
  export interface SocketTransport {
53
60
  port(): number;
54
61
  onConnected(): Promise<[MessageReader, MessageWriter]>;
62
+ /**
63
+ * Closes the underlying server if a client hasn't connected yet. Callers
64
+ * should invoke this if they abandon the transport before `onConnected`
65
+ * resolves (for example because the server process failed to start) to
66
+ * avoid leaking the listening socket.
67
+ */
68
+ close(): void;
55
69
  }
56
70
  export declare function createClientSocketTransport(port: number, encoding?: RAL.MessageBufferEncoding): Promise<SocketTransport>;
57
71
  export declare function createServerSocketTransport(port: number, encoding?: RAL.MessageBufferEncoding): [MessageReader, MessageWriter];