pathprobe 0.8.12 → 0.9.14

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/index.mjs CHANGED
@@ -75,8 +75,7 @@ function add(result, seen, value, start, end, kind) {
75
75
  }
76
76
  function addMatches(result, seen, text, pattern, kind) {
77
77
  for (const match of text.matchAll(pattern)) {
78
- const value = match[0];
79
- const start = match.index ?? 0;
78
+ const value = match[0], start = match.index ?? 0;
80
79
  add(result, seen, value, start, start + value.length, kind);
81
80
  }
82
81
  }
@@ -90,22 +89,17 @@ function addQuotedMatches(result, seen, text) {
90
89
  }
91
90
  function addSpanMatches(result, seen, text, maximumWords) {
92
91
  for (const clause of text.matchAll(clausePattern)) {
93
- const clauseStart = clause.index ?? 0;
94
- const tokens = [...clause[0].matchAll(tokenPattern)].map((token) => ({
92
+ const clauseStart = clause.index ?? 0, tokens = [...clause[0].matchAll(tokenPattern)].map((token) => ({
95
93
  end: clauseStart + (token.index ?? 0) + token[0].length,
96
94
  hint: Number(pathHintPattern.test(token[0]) || variableHintPattern.test(token[0])),
97
95
  start: clauseStart + (token.index ?? 0),
98
96
  value: token[0]
99
- }));
100
- const hintCounts = [0];
97
+ })), hintCounts = [0];
101
98
  for (const token of tokens) hintCounts.push((hintCounts.at(-1) ?? 0) + token.hint);
102
99
  for (let start = 0; start < tokens.length; start += 1) {
103
100
  const last = Math.min(tokens.length, start + maximumWords);
104
101
  for (let end = start + 1; end <= last; end += 1) {
105
- const firstToken = tokens[start];
106
- const lastToken = tokens[end - 1];
107
- const hintsBefore = hintCounts[start];
108
- const hintsAfter = hintCounts[end];
102
+ const firstToken = tokens[start], lastToken = tokens[end - 1], hintsBefore = hintCounts[start], hintsAfter = hintCounts[end];
109
103
  if (firstToken === void 0 || lastToken === void 0 || hintsBefore === void 0 || hintsAfter === void 0 || hintsBefore === hintsAfter) continue;
110
104
  const value = text.slice(firstToken.start, lastToken.end);
111
105
  if (pathHintPattern.test(value)) add(result, seen, value, firstToken.start, lastToken.end, "span");
@@ -114,8 +108,7 @@ function addSpanMatches(result, seen, text, maximumWords) {
114
108
  }
115
109
  }
116
110
  function extractCandidates(text, level) {
117
- const result = [];
118
- const seen = /* @__PURE__ */ new Set();
111
+ const result = [], seen = /* @__PURE__ */ new Set();
119
112
  addQuotedMatches(result, seen, text);
120
113
  addMatches(result, seen, text, explicitPattern, "explicit");
121
114
  if (level >= 2) {
@@ -149,14 +142,11 @@ function addLocalServerName(names, value) {
149
142
  if (value !== void 0 && uncServerSegmentPattern.test(value)) names.add(normalizeServerName(value));
150
143
  }
151
144
  function addIpv6LiteralName(names, value) {
152
- const zoneIndex = value.indexOf("%");
153
- const address = zoneIndex === -1 ? value : value.slice(0, zoneIndex);
154
- const zone = zoneIndex === -1 ? "" : `s${value.slice(zoneIndex + 1)}`;
145
+ const zoneIndex = value.indexOf("%"), address = zoneIndex === -1 ? value : value.slice(0, zoneIndex), zone = zoneIndex === -1 ? "" : `s${value.slice(zoneIndex + 1)}`;
155
146
  addLocalServerName(names, `${address.replaceAll(":", "-")}${zone}.ipv6-literal.net`);
156
147
  }
157
148
  function collectLocalServerNames() {
158
- const names = /* @__PURE__ */ new Set(["localhost"]);
159
- const computerName = process.env.COMPUTERNAME;
149
+ const names = /* @__PURE__ */ new Set(["localhost"]), computerName = process.env.COMPUTERNAME;
160
150
  addLocalServerName(names, hostname());
161
151
  addLocalServerName(names, computerName);
162
152
  if (computerName !== void 0 && process.env.USERDNSDOMAIN !== void 0) addLocalServerName(names, `${computerName}.${process.env.USERDNSDOMAIN}`);
@@ -168,24 +158,18 @@ function collectLocalServerNames() {
168
158
  const localServerNames = process.platform === "win32" ? collectLocalServerNames() : /* @__PURE__ */ new Set();
169
159
  let driveMappings;
170
160
  function containsControlCharacter(value) {
171
- return [...value].some((character) => character.charCodeAt(0) < 32);
161
+ for (const character of value) if (character.charCodeAt(0) < 32) return true;
162
+ return false;
172
163
  }
173
164
  function normalizeUncRoot(value) {
174
165
  return value.replaceAll("/", "\\").replace(/\\+$/u, "").toLowerCase();
175
166
  }
176
167
  function parseUncPath(value) {
177
- const normalized = value.replaceAll("/", "\\");
178
- const extended = normalized.slice(0, 8).toLowerCase() === "\\\\?\\unc\\";
168
+ const normalized = value.replaceAll("/", "\\"), extended = normalized.slice(0, 8).toLowerCase() === "\\\\?\\unc\\";
179
169
  if (normalized.startsWith("\\\\.\\") || normalized.startsWith("\\\\?\\") && !extended) return;
180
- const serverStart = extended ? 8 : 2;
181
- const serverSeparator = normalized.slice(serverStart).indexOf("\\");
170
+ const serverStart = extended ? 8 : 2, serverSeparator = normalized.slice(serverStart).indexOf("\\");
182
171
  if (serverSeparator <= 0) return;
183
- const serverEnd = serverStart + serverSeparator;
184
- const shareStart = serverEnd + 1;
185
- const shareSeparator = normalized.slice(shareStart).indexOf("\\");
186
- const shareEnd = shareSeparator === -1 ? normalized.length : shareStart + shareSeparator;
187
- const server = normalized.slice(serverStart, serverEnd);
188
- const share = normalized.slice(shareStart, shareEnd);
172
+ const serverEnd = serverStart + serverSeparator, shareStart = serverEnd + 1, shareSeparator = normalized.slice(shareStart).indexOf("\\"), shareEnd = shareSeparator === -1 ? normalized.length : shareStart + shareSeparator, server = normalized.slice(serverStart, serverEnd), share = normalized.slice(shareStart, shareEnd);
189
173
  if (share.length === 0 || !uncServerSegmentPattern.test(server) || !uncServerSegmentPattern.test(share)) return;
190
174
  const suffix = normalized.slice(shareEnd);
191
175
  return {
@@ -201,15 +185,14 @@ function queryDriveMapping(drive) {
201
185
  if (status === errorMoreData) throw new Error(`WNetGetConnectionW returned an oversized mapping for ${drive}`);
202
186
  if (unmappedDriveErrors.has(status)) return;
203
187
  if (status !== 0) throw new Error(`WNetGetConnectionW failed for ${drive} with error ${status}`);
204
- if (typeof remote !== "string" || !remote.startsWith("\\\\")) throw new TypeError(`WNetGetConnectionW returned an invalid mapping for ${drive}`);
188
+ if (typeof remote !== "string" || !remote.startsWith(String.raw`\\`)) throw new TypeError(`WNetGetConnectionW returned an invalid mapping for ${drive}`);
205
189
  return normalizeUncRoot(remote);
206
190
  }
207
191
  function queryDriveMappings() {
208
192
  if (driveMappings !== void 0) return driveMappings;
209
193
  const result = [];
210
194
  for (let code = "A".charCodeAt(0); code <= "Z".charCodeAt(0); code += 1) {
211
- const drive = `${String.fromCharCode(code)}:`;
212
- const remote = queryDriveMapping(drive);
195
+ const drive = `${String.fromCharCode(code)}:`, remote = queryDriveMapping(drive);
213
196
  if (remote !== void 0) result.push({
214
197
  drive,
215
198
  remote
@@ -219,8 +202,7 @@ function queryDriveMappings() {
219
202
  return driveMappings;
220
203
  }
221
204
  function resolveMappedUncPath(path) {
222
- const canonical = normalizeUncRoot(path.canonical);
223
- const mapping = queryDriveMappings().find(({ remote }) => canonical === remote || canonical.startsWith(`${remote}\\`));
205
+ const canonical = normalizeUncRoot(path.canonical), mapping = queryDriveMappings().find(({ remote }) => canonical === remote || canonical.startsWith(`${remote}\\`));
224
206
  if (mapping === void 0) return;
225
207
  const relative = path.canonical.slice(mapping.remote.length);
226
208
  return nodePath.win32.normalize(`${mapping.drive}${relative}`);
@@ -235,7 +217,7 @@ function resolveLocalAdministrativeShare(path) {
235
217
  return nodePath.win32.normalize(`${match[1]}:${path.suffix || "\\"}`);
236
218
  }
237
219
  function resolveUncPath(value) {
238
- if (process.platform !== "win32" || !value.startsWith("\\\\") && !value.startsWith("//")) return value;
220
+ if (process.platform !== "win32" || !value.startsWith(String.raw`\\`) && !value.startsWith("//")) return value;
239
221
  if (containsControlCharacter(value)) return;
240
222
  const path = parseUncPath(value);
241
223
  if (path === void 0) return;
@@ -313,14 +295,12 @@ function completeDirectoryRead(error, entries, callback) {
313
295
  }
314
296
  function indexScope(root, scope) {
315
297
  if (scope === void 0) return;
316
- const resolvedRoot = nodePath.resolve(root);
317
- const childrenByDirectory = /* @__PURE__ */ new Map();
298
+ const resolvedRoot = nodePath.resolve(root), childrenByDirectory = /* @__PURE__ */ new Map();
318
299
  for (const relativePath of scope.paths) {
319
300
  if (nodePath.isAbsolute(relativePath) || relativePath === ".." || relativePath.startsWith(`..${nodePath.sep}`)) throw new RangeError(`${relativePath} is outside the traversal root ${root}`);
320
301
  let directory = resolvedRoot;
321
302
  for (const name of relativePath.split(nodePath.sep)) {
322
- const directoryKey = pathKey$4(directory);
323
- const children = childrenByDirectory.get(directoryKey) ?? /* @__PURE__ */ new Set();
303
+ const directoryKey = pathKey$4(directory), children = childrenByDirectory.get(directoryKey) ?? /* @__PURE__ */ new Set();
324
304
  children.add(pathKey$4(name));
325
305
  childrenByDirectory.set(directoryKey, children);
326
306
  directory = nodePath.join(directory, name);
@@ -340,27 +320,34 @@ function filterToScope(filePath, entries, scope) {
340
320
  return children.has(key) || scope.passthroughNames.has(key);
341
321
  });
342
322
  }
323
+ function completeTraversalRead(root, filePath, searchHidden, hiddenDetector, scope, error, entries, callback) {
324
+ const scopedEntries = error === null ? filterToScope(filePath, entries, scope) : entries;
325
+ if (error !== null || searchHidden) {
326
+ completeDirectoryRead(error, scopedEntries, callback);
327
+ return;
328
+ }
329
+ try {
330
+ callback(null, scopedEntries.filter((entry) => {
331
+ if (typeof entry !== "string" && !entry.isDirectory()) return true;
332
+ const name = typeof entry === "string" ? entry : entry.name;
333
+ return !hiddenDetector.isHidden(nodePath.join(filePath, name), root);
334
+ }));
335
+ } catch (caughtError) {
336
+ callback(caughtError instanceof Error ? caughtError : new Error(String(caughtError)), []);
337
+ }
338
+ }
343
339
  function createReadDirectory(root, searchHidden, readDirectory, scope) {
344
340
  const hiddenDetector = createHiddenPathDetector();
345
341
  function traverseReadDirectory(filePath, optionsOrCallback, entryCallback) {
346
342
  if (typeof optionsOrCallback === "function") {
347
343
  readDirectory(filePath, (error, entries) => {
348
- completeDirectoryRead(error, error === null ? filterToScope(filePath, entries, scope) : entries, optionsOrCallback);
344
+ completeTraversalRead(root, filePath, searchHidden, hiddenDetector, scope, error, entries, optionsOrCallback);
349
345
  });
350
346
  return;
351
347
  }
352
348
  if (entryCallback === void 0) throw new TypeError("A directory entry callback is required");
353
349
  readDirectory(filePath, optionsOrCallback, (error, entries) => {
354
- const scopedEntries = error === null ? filterToScope(filePath, entries, scope) : entries;
355
- if (error !== null || searchHidden) {
356
- completeDirectoryRead(error, scopedEntries, entryCallback);
357
- return;
358
- }
359
- try {
360
- entryCallback(null, scopedEntries.filter((entry) => !entry.isDirectory() || !hiddenDetector.isHidden(nodePath.join(filePath, entry.name), root)));
361
- } catch (caught) {
362
- entryCallback(caught instanceof Error ? caught : new Error(String(caught)), []);
363
- }
350
+ completeTraversalRead(root, filePath, searchHidden, hiddenDetector, scope, error, entries, entryCallback);
364
351
  });
365
352
  }
366
353
  return traverseReadDirectory;
@@ -426,17 +413,14 @@ async function listSearchEntries(root, respectIgnore, searchHidden) {
426
413
  const entries = await globby("**/*", {
427
414
  ...globbyOptions(root, respectIgnore, searchHidden),
428
415
  objectMode: true
429
- });
430
- const hiddenDetector = createHiddenPathDetector();
416
+ }), hiddenDetector = createHiddenPathDetector();
431
417
  return entries.filter((entry) => searchHidden || !hiddenDetector.isHidden(nodePath.resolve(root, entry.path), root)).map((entry) => ({
432
418
  directory: entry.dirent.isDirectory(),
433
419
  path: entry.path
434
420
  }));
435
421
  }
436
422
  async function filterSearchablePaths(paths, roots, respectIgnore, searchHidden) {
437
- const allowed = /* @__PURE__ */ new Set();
438
- const pathsByRoot = /* @__PURE__ */ new Map();
439
- const hiddenDetector = createHiddenPathDetector();
423
+ const allowed = /* @__PURE__ */ new Set(), pathsByRoot = /* @__PURE__ */ new Map(), hiddenDetector = createHiddenPathDetector();
440
424
  for (const filePath of paths) {
441
425
  let hasSearchRoot = false;
442
426
  for (const root of roots) {
@@ -452,13 +436,11 @@ async function filterSearchablePaths(paths, roots, respectIgnore, searchHidden)
452
436
  }
453
437
  }
454
438
  if (hasSearchRoot) continue;
455
- const filesystemRoot = nodePath.parse(filePath).root;
456
- const hiddenBoundary = process.platform === "win32" ? nodePath.dirname(filePath) : filesystemRoot;
439
+ const filesystemRoot = nodePath.parse(filePath).root, hiddenBoundary = process.platform === "win32" ? nodePath.dirname(filePath) : filesystemRoot;
457
440
  if (searchHidden || !hiddenDetector.isHidden(filePath, hiddenBoundary)) allowed.add(filePath);
458
441
  }
459
442
  await Promise.all([...pathsByRoot].map(async ([root, relativePaths]) => {
460
- const patterns = relativePaths.map(convertPathToPattern);
461
- const matches = await globby(patterns, {
443
+ const patterns = relativePaths.map(convertPathToPattern), matches = await globby(patterns, {
462
444
  ...globbyOptions(root, true, true, relativePaths),
463
445
  absolute: true
464
446
  });
@@ -473,8 +455,7 @@ function pathKey$2(value) {
473
455
  }
474
456
  async function applySearchPolicies(existingPaths, roots, respectIgnore, searchHidden) {
475
457
  if (!respectIgnore && searchHidden) return new Map(existingPaths);
476
- const searchablePaths = await filterSearchablePaths([...existingPaths.keys()], roots, respectIgnore, searchHidden);
477
- const searchableKeys = new Set([...searchablePaths].map(pathKey$2));
458
+ const searchablePaths = await filterSearchablePaths([...existingPaths.keys()], roots, respectIgnore, searchHidden), searchableKeys = new Set([...searchablePaths].map(pathKey$2));
478
459
  return new Map([...existingPaths].filter(([filePath]) => searchableKeys.has(pathKey$2(filePath))));
479
460
  }
480
461
  //#endregion
@@ -494,7 +475,7 @@ function pathKey$1(value) {
494
475
  }
495
476
  function isUnavailablePathError(error, filePath) {
496
477
  const code = error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
497
- return code !== void 0 && (unavailablePathErrors.has(code) || filePath?.startsWith("\\\\") === true && unverifiableUncErrors.has(code));
478
+ return code !== void 0 && (unavailablePathErrors.has(code) || filePath?.startsWith(String.raw`\\`) === true && unverifiableUncErrors.has(code));
498
479
  }
499
480
  async function classifyPath(filePath) {
500
481
  try {
@@ -511,30 +492,25 @@ async function classifyAndAdd(found, filePath) {
511
492
  if (kind !== void 0) found.set(filePath, kind);
512
493
  }
513
494
  async function classifyExistingPaths(paths, roots) {
514
- const found = /* @__PURE__ */ new Map();
515
- const limit = pLimit(settings.validationConcurrency);
495
+ const found = /* @__PURE__ */ new Map(), limit = pLimit(settings.validationConcurrency);
516
496
  if (paths.length < settings.batchValidationThreshold) {
517
497
  await limit.map(paths, (filePath) => classifyAndAdd(found, filePath));
518
498
  return found;
519
499
  }
520
- const rootKeys = new Set(roots.map(pathKey$1));
521
- const pathsByParent = /* @__PURE__ */ new Map();
500
+ const rootKeys = new Set(roots.map(pathKey$1)), pathsByParent = /* @__PURE__ */ new Map();
522
501
  for (const filePath of paths) {
523
502
  if (rootKeys.has(pathKey$1(filePath))) {
524
503
  found.set(filePath, "directory");
525
504
  continue;
526
505
  }
527
- const parent = nodePath.dirname(filePath);
528
- const key = pathKey$1(parent);
529
- const group = pathsByParent.get(key) ?? {
506
+ const parent = nodePath.dirname(filePath), key = pathKey$1(parent), group = pathsByParent.get(key) ?? {
530
507
  parent,
531
508
  paths: []
532
509
  };
533
510
  group.paths.push(filePath);
534
511
  pathsByParent.set(key, group);
535
512
  }
536
- const directPaths = [];
537
- const scannedGroups = [];
513
+ const directPaths = [], scannedGroups = [];
538
514
  for (const group of pathsByParent.values()) if (group.paths.length < settings.directoryScanThreshold) directPaths.push(...group.paths);
539
515
  else scannedGroups.push(group);
540
516
  await Promise.all([limit.map(directPaths, (filePath) => classifyAndAdd(found, filePath)), limit.map(scannedGroups, async ({ parent, paths: groupPaths }) => {
@@ -547,8 +523,7 @@ async function classifyExistingPaths(paths, roots) {
547
523
  }
548
524
  const entriesByName = new Map(entries.map((entry) => [pathKey$1(entry.name), entry]));
549
525
  await Promise.all(groupPaths.map(async (filePath) => {
550
- const name = nodePath.basename(filePath);
551
- const entry = entriesByName.get(pathKey$1(name));
526
+ const name = nodePath.basename(filePath), entry = entriesByName.get(pathKey$1(name));
552
527
  if (entry?.isFile()) found.set(filePath, "file");
553
528
  else if (entry?.isDirectory()) found.set(filePath, "directory");
554
529
  else if (entry !== void 0 || process.platform === "win32" && name.includes(":")) await classifyAndAdd(found, filePath);
@@ -562,11 +537,8 @@ function removeContainedMatches(matches) {
562
537
  const ordered = matches.map((match, index) => ({
563
538
  index,
564
539
  match
565
- })).toSorted(({ match: left }, { match: right }) => left.position.start - right.position.start || right.position.end - left.position.end);
566
- const kept = /* @__PURE__ */ new Set();
567
- let maxEndBeforeStart = -1;
568
- let groupStart = -1;
569
- let maxEndInGroup = -1;
540
+ })).toSorted(({ match: left }, { match: right }) => left.position.start - right.position.start || right.position.end - left.position.end), kept = /* @__PURE__ */ new Set();
541
+ let maxEndBeforeStart = -1, groupStart = -1, maxEndInGroup = -1;
570
542
  for (const { index, match } of ordered) {
571
543
  const { start, end } = match.position;
572
544
  if (start !== groupStart) {
@@ -587,9 +559,7 @@ function parseLocationPart(value, name) {
587
559
  return result;
588
560
  }
589
561
  function prepareCandidate(candidate) {
590
- let end = candidate.end;
591
- let start = candidate.start;
592
- let value = candidate.value;
562
+ let { end } = candidate, { start } = candidate, { value } = candidate;
593
563
  if (candidate.kind !== "inventory" && candidate.kind !== "quoted") {
594
564
  const startTrimmed = value.trimStart();
595
565
  start += value.length - startTrimmed.length;
@@ -597,7 +567,7 @@ function prepareCandidate(candidate) {
597
567
  const endTrimmed = value.trimEnd();
598
568
  end -= value.length - endTrimmed.length;
599
569
  value = endTrimmed;
600
- if (value.length >= 2 && (value[0] === "\"" && value.at(-1) === "\"" || value[0] === "'" && value.at(-1) === "'" || value[0] === "`" && value.at(-1) === "`")) {
570
+ if (value.length >= 2 && (value.startsWith("\"") && value.at(-1) === "\"" || value.startsWith("'") && value.at(-1) === "'" || value.startsWith("`") && value.at(-1) === "`")) {
601
571
  start += 1;
602
572
  end -= 1;
603
573
  value = value.slice(1, -1);
@@ -622,7 +592,7 @@ function prepareCandidate(candidate) {
622
592
  value = value.slice(0, match.index);
623
593
  }
624
594
  }
625
- if (value === "/") return;
595
+ if (value === "/" || value === ".") return;
626
596
  return {
627
597
  ...location === void 0 ? {} : { location },
628
598
  position: {
@@ -643,11 +613,12 @@ function uniquePaths(values) {
643
613
  return [...paths.values()];
644
614
  }
645
615
  function unescape(value) {
646
- if (value.startsWith("\\\\") && !value.startsWith("\\\\\\\\")) return value;
616
+ if (value.startsWith(String.raw`\\`) && !value.startsWith(String.raw`\\\\`)) return value;
647
617
  return value.replace(/\\(["'`\\])/gu, "$1").replace(/\\\\/gu, "\\");
648
618
  }
649
619
  function toPaths(value, roots, variables) {
650
620
  let expanded = expandVariables(value, variables);
621
+ if (expanded.includes("\0")) return [];
651
622
  if (expanded.startsWith("file://")) try {
652
623
  expanded = fileURLToPath(expanded);
653
624
  } catch (error) {
@@ -673,8 +644,7 @@ function mergeLocation(match, location) {
673
644
  if (match.location.line !== location.line || match.location.column !== location.column) throw new Error("Candidates for the same path and position have conflicting locations");
674
645
  }
675
646
  async function validateCandidates(candidates, roots, variables, respectIgnore, searchHidden) {
676
- const resolvedCandidates = [];
677
- const validationPaths = /* @__PURE__ */ new Map();
647
+ const resolvedCandidates = [], validationPaths = /* @__PURE__ */ new Map();
678
648
  for (const candidate of candidates) {
679
649
  const prepared = prepareCandidate(candidate);
680
650
  if (prepared === void 0) continue;
@@ -689,14 +659,11 @@ async function validateCandidates(candidates, roots, variables, respectIgnore, s
689
659
  validationPaths.set(pathKey(filePath), filePath);
690
660
  }
691
661
  }
692
- const classifiedPaths = await applySearchPolicies(await classifyExistingPaths([...validationPaths.values()], roots), roots, respectIgnore, searchHidden);
693
- const kindsByPath = new Map([...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind]));
694
- const matches = /* @__PURE__ */ new Map();
662
+ const classifiedPaths = await applySearchPolicies(await classifyExistingPaths([...validationPaths.values()], roots), roots, respectIgnore, searchHidden), kindsByPath = new Map([...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind])), matches = /* @__PURE__ */ new Map();
695
663
  for (const { expectedKind, location, path, position } of resolvedCandidates) {
696
664
  const kind = kindsByPath.get(pathKey(path));
697
665
  if (kind === void 0 || expectedKind !== void 0 && kind !== expectedKind) continue;
698
- const key = `${pathKey(path)}\0${position.start}\0${position.end}`;
699
- const existing = matches.get(key);
666
+ const key = `${pathKey(path)}\0${position.start}\0${position.end}`, existing = matches.get(key);
700
667
  if (existing !== void 0) {
701
668
  mergeLocation(existing, location);
702
669
  continue;
@@ -753,9 +720,7 @@ function addEntryVariants(patterns, entry) {
753
720
  function createRootPrefixes(roots) {
754
721
  const prefixes = /* @__PURE__ */ new Map();
755
722
  for (const root of roots) {
756
- const native = root.endsWith(nodePath.sep) ? root : `${root}${nodePath.sep}`;
757
- const slashRoot = root.replaceAll(nodePath.sep, "/");
758
- const slash = slashRoot.endsWith("/") ? slashRoot : `${slashRoot}/`;
723
+ const native = root.endsWith(nodePath.sep) ? root : `${root}${nodePath.sep}`, slashRoot = root.replaceAll(nodePath.sep, "/"), slash = slashRoot.endsWith("/") ? slashRoot : `${slashRoot}/`;
759
724
  for (const value of [native, slash]) {
760
725
  const key = process.platform === "win32" ? value.toLowerCase() : value;
761
726
  prefixes.set(key, {
@@ -779,26 +744,21 @@ function addAbsoluteMatch(result, seen, source, text, pattern, prefixes, end, re
779
744
  function hasSameEntries(cached, entries) {
780
745
  if (cached.entries.length !== entries.length) return false;
781
746
  for (let index = 0; index < entries.length; index += 1) {
782
- const cachedEntries = cached.entries[index];
783
- const currentEntries = entries[index];
747
+ const cachedEntries = cached.entries[index], currentEntries = entries[index];
784
748
  if (cachedEntries === void 0 || currentEntries === void 0) return false;
785
749
  if (cachedEntries.length !== currentEntries.length) return false;
786
750
  for (let entryIndex = 0; entryIndex < currentEntries.length; entryIndex += 1) {
787
- const cachedEntry = cachedEntries[entryIndex];
788
- const currentEntry = currentEntries[entryIndex];
751
+ const cachedEntry = cachedEntries[entryIndex], currentEntry = currentEntries[entryIndex];
789
752
  if (cachedEntry === void 0 || currentEntry === void 0 || cachedEntry.directory !== currentEntry.directory || cachedEntry.path !== currentEntry.path) return false;
790
753
  }
791
754
  }
792
755
  return true;
793
756
  }
794
757
  function canReuseMatcher(cached, entries, roots, respectIgnore, searchHidden) {
795
- return cached !== void 0 && cached.respectIgnore === respectIgnore && cached.searchHidden === searchHidden && cached.roots.length === roots.length && cached.roots.every((root, index) => root === roots[index]) && hasSameEntries(cached, entries);
758
+ return cached?.respectIgnore === respectIgnore && cached.searchHidden === searchHidden && cached.roots.length === roots.length && cached.roots.every((root, index) => root === roots[index]) && hasSameEntries(cached, entries);
796
759
  }
797
760
  async function inventoryCandidates(text, roots, respectIgnore, searchHidden) {
798
- const entries = await Promise.all(roots.map((root) => listSearchEntries(root, respectIgnore, searchHidden)));
799
- const result = [];
800
- const seen = /* @__PURE__ */ new Set();
801
- const source = process.platform === "win32" ? text.toLowerCase() : text;
761
+ const entries = await Promise.all(roots.map((root) => listSearchEntries(root, respectIgnore, searchHidden))), result = [], seen = /* @__PURE__ */ new Set(), source = process.platform === "win32" ? text.toLowerCase() : text;
802
762
  let inventoryMatcher = inventoryMatcherCache;
803
763
  if (!canReuseMatcher(inventoryMatcher, entries, roots, respectIgnore, searchHidden)) {
804
764
  const patterns = /* @__PURE__ */ new Map();
@@ -838,8 +798,7 @@ async function findExistingPaths(options) {
838
798
  validateVariables(variables);
839
799
  if (typeof respectIgnore !== "boolean") throw new TypeError("respectIgnore must be a boolean");
840
800
  if (typeof searchHidden !== "boolean") throw new TypeError("searchHidden must be a boolean");
841
- const roots = await resolveSearchDirectories(directories);
842
- const candidates = extractCandidates(text, level);
801
+ const roots = await resolveSearchDirectories(directories), candidates = extractCandidates(text, level);
843
802
  if (level === MAX_LEVEL) candidates.push(...await inventoryCandidates(text, roots, respectIgnore, searchHidden));
844
803
  return validateCandidates(candidates, roots, variables, respectIgnore, searchHidden);
845
804
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["pathKey","pathKey","pathKey","pathKey","pathKey"],"sources":["../config/settings.ts","../src/variables.ts","../src/candidates.ts","../src/native/unc.ts","../src/native/attributes.ts","../src/search/hidden.ts","../src/search/traversal.ts","../src/search/policy.ts","../src/validation/eligibility.ts","../src/validation/existence.ts","../src/validation/containment.ts","../src/validation/preparation.ts","../src/validation/resolution.ts","../src/search/inventory.ts","../src/index.ts"],"sourcesContent":["import type { SearchSettings } from \"../src/types.js\";\n\nexport const settings: SearchSettings = {\n batchValidationThreshold: 48,\n directoryScanThreshold: 2,\n ignoreFileNames: [\".ignore\", \".rgignore\"],\n locationSuffixPattern: /:(?<line>\\d+)(?::(?<column>\\d+))?$/u,\n respectIgnoreByDefault: true,\n searchHiddenByDefault: false,\n spanWordLimits: [3, 24],\n trailingPunctuation: \".,;:!?,。;:!?、\",\n validationConcurrency: 32,\n};\n","import type { Variables } from \"./types.js\";\n\nconst nameSource = String.raw`[A-Za-z_][A-Za-z0-9_.-]*`;\nexport const variableReferenceSource = String.raw`(?:\\$\\{\\{\\s*(?:(?:env|vars|variables)[.:])?${nameSource}\\s*\\}\\}|\\{\\{\\s*${nameSource}\\s*\\}\\}|\\$\\{(?:env[.:])?${nameSource}\\}|\\$env:${nameSource}|\\$[A-Za-z_][A-Za-z0-9_]*|%${nameSource}%|!${nameSource}!|\\$\\(\\s*${nameSource}\\s*\\)|@${nameSource}@)`;\nconst expressionPatterns = [\n new RegExp(String.raw`\\$\\{\\{\\s*(?:(?:env|vars|variables)[.:])?(${nameSource})\\s*\\}\\}`, \"giu\"),\n new RegExp(String.raw`\\{\\{\\s*(${nameSource})\\s*\\}\\}`, \"gu\"),\n new RegExp(String.raw`\\$\\{(?:env[.:])?(${nameSource})\\}`, \"giu\"),\n new RegExp(String.raw`\\$env:(${nameSource})`, \"giu\"),\n new RegExp(String.raw`\\$(?!env:)([A-Za-z_][A-Za-z0-9_]*)`, \"giu\"),\n new RegExp(String.raw`%(${nameSource})%`, \"gu\"),\n new RegExp(String.raw`!(${nameSource})!`, \"gu\"),\n new RegExp(String.raw`\\$\\(\\s*(${nameSource})\\s*\\)`, \"gu\"),\n new RegExp(String.raw`@(${nameSource})@`, \"gu\"),\n];\nfunction resolveVariable(name: string, variables: Variables): string | undefined {\n const direct = variables[name] ?? process.env[name];\n if (direct !== undefined) {\n return direct;\n }\n const unscoped = /^(?:env|vars|variables)[.:](.+)$/iu.exec(name)?.[1];\n return unscoped === undefined ? undefined : (variables[unscoped] ?? process.env[unscoped]);\n}\nexport function expandVariables(value: string, variables: Variables): string {\n let result = value;\n for (const pattern of expressionPatterns) {\n result = result.replace(pattern, (match, name: string) => {\n const replacement = resolveVariable(name, variables);\n return replacement === undefined ? match : replacement;\n });\n }\n return result;\n}\n","import type { Candidate, SearchLevel } from \"./types.js\";\nimport { settings } from \"../config/settings.js\";\nimport { variableReferenceSource } from \"./variables.js\";\n\nconst explicitPattern =\n /(?:file:\\/\\/\\/?|[A-Za-z]:[\\\\/]|\\\\\\\\|\\/|(?:\\.{1,2}|~)[\\\\/])[^\"'`<>()[\\]{}\\s]+/gu;\nconst quotedPattern = /([\"'`])(?<value>[^\"'`\\r\\n]+)\\1/gu;\nconst tokenPattern = /[^\\s]+/gu;\nconst pathTokenPattern =\n /(?:(?:[\\p{L}\\p{N}_@%$+~.#[\\],-]+[\\\\/])+(?:[\\p{L}\\p{N}_@%$+~.#[\\],-]+)|[\\p{L}\\p{N}_@%$+~.#[\\],-]+\\.[\\p{L}\\p{N}_@%$-]{1,16})(?::\\d+){0,2}/gu;\nconst unquotedPathCharacterSource = \"[^\\\"'`<>()[\\\\]{}\\\\s]\";\nconst variablePathPattern = new RegExp(\n `${variableReferenceSource}(?:[\\\\\\\\/]${unquotedPathCharacterSource}+)+`,\n \"giu\",\n);\nconst clausePattern = /[^\\r\\n!?!?;;。]+/gu;\nconst pathHintPattern =\n /[\\\\/]|(?:^|[\\s\"'`])(?:\\.{1,2}|~|%[A-Za-z_][A-Za-z0-9_]*%|\\$\\{?[A-Za-z_][A-Za-z0-9_]*\\}?)(?:[\\\\/]|$)|\\.[\\p{L}\\p{N}]{1,16}(?::\\d+){0,2}(?:$|[\\s,.;:!?,。;:!?、])/u;\nconst variableHintPattern = new RegExp(String.raw`${variableReferenceSource}(?:[\\\\/]|$)`, \"iu\");\nfunction add(\n result: Candidate[],\n seen: Set<string>,\n value: string,\n start: number,\n end: number,\n kind: Candidate[\"kind\"],\n): void {\n if (value.length === 0 || value === \"/\") {\n return;\n }\n const key = `${start}:${end}:${value}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push({ end, kind, start, value });\n }\n}\nfunction addMatches(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n pattern: RegExp,\n kind: Candidate[\"kind\"],\n): void {\n for (const match of text.matchAll(pattern)) {\n const value = match[0];\n const start = match.index ?? 0;\n add(result, seen, value, start, start + value.length, kind);\n }\n}\nfunction addQuotedMatches(result: Candidate[], seen: Set<string>, text: string): void {\n for (const match of text.matchAll(quotedPattern)) {\n const value = match.groups?.value;\n if (value === undefined) {\n continue;\n }\n const start = (match.index ?? 0) + match[0].indexOf(value);\n add(result, seen, value, start, start + value.length, \"quoted\");\n }\n}\nfunction addSpanMatches(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n maximumWords: number,\n): void {\n for (const clause of text.matchAll(clausePattern)) {\n const clauseStart = clause.index ?? 0;\n const clauseText = clause[0];\n const tokens = [...clauseText.matchAll(tokenPattern)].map((token) => ({\n end: clauseStart + (token.index ?? 0) + token[0].length,\n hint: Number(pathHintPattern.test(token[0]) || variableHintPattern.test(token[0])),\n start: clauseStart + (token.index ?? 0),\n value: token[0],\n }));\n const hintCounts = [0];\n for (const token of tokens) {\n hintCounts.push((hintCounts.at(-1) ?? 0) + token.hint);\n }\n for (let start = 0; start < tokens.length; start += 1) {\n const last = Math.min(tokens.length, start + maximumWords);\n for (let end = start + 1; end <= last; end += 1) {\n const firstToken = tokens[start];\n const lastToken = tokens[end - 1];\n const hintsBefore = hintCounts[start];\n const hintsAfter = hintCounts[end];\n if (\n firstToken === undefined ||\n lastToken === undefined ||\n hintsBefore === undefined ||\n hintsAfter === undefined ||\n hintsBefore === hintsAfter\n ) {\n continue;\n }\n const value = text.slice(firstToken.start, lastToken.end);\n if (pathHintPattern.test(value)) {\n add(result, seen, value, firstToken.start, lastToken.end, \"span\");\n }\n }\n }\n }\n}\nexport function extractCandidates(text: string, level: SearchLevel): Candidate[] {\n const result: Candidate[] = [];\n const seen = new Set<string>();\n addQuotedMatches(result, seen, text);\n addMatches(result, seen, text, explicitPattern, \"explicit\");\n if (level >= 2) {\n addMatches(result, seen, text, variablePathPattern, \"heuristic\");\n addMatches(result, seen, text, pathTokenPattern, \"heuristic\");\n }\n if (level >= 3) {\n const maximumWords =\n settings.spanWordLimits[Math.min(level - 3, settings.spanWordLimits.length - 1)];\n if (maximumWords === undefined) {\n throw new RangeError(\"No text-span level is configured\");\n }\n addSpanMatches(result, seen, text, maximumWords);\n }\n return result;\n}\n","import { isIP } from \"node:net\";\nimport { hostname, networkInterfaces } from \"node:os\";\nimport nodePath from \"node:path\";\nimport nativeBridge from \"./windows-bridge.cjs\";\n\nconst native = process.platform === \"win32\" ? nativeBridge : undefined;\nconst uncServerSegmentPattern = /^[^\\\\/:*?\"<>|]+$/u;\nconst unmappedDriveErrors = new Set([1200, 1201, 1203, 1222, 2250]);\nconst errorMoreData = 234;\nconst mappingBufferChars = 32_768;\ninterface UncPath {\n canonical: string;\n server: string;\n share: string;\n suffix: string;\n}\ninterface DriveMapping {\n drive: string;\n remote: string;\n}\nfunction normalizeServerName(value: string): string {\n return value.replace(/\\.+$/u, \"\").toLowerCase();\n}\nfunction addLocalServerName(names: Set<string>, value: string | undefined): void {\n if (value !== undefined && uncServerSegmentPattern.test(value)) {\n names.add(normalizeServerName(value));\n }\n}\nfunction addIpv6LiteralName(names: Set<string>, value: string): void {\n const zoneIndex = value.indexOf(\"%\");\n const address = zoneIndex === -1 ? value : value.slice(0, zoneIndex);\n const zone = zoneIndex === -1 ? \"\" : `s${value.slice(zoneIndex + 1)}`;\n addLocalServerName(names, `${address.replaceAll(\":\", \"-\")}${zone}.ipv6-literal.net`);\n}\nfunction collectLocalServerNames(): Set<string> {\n const names = new Set<string>([\"localhost\"]);\n const computerName = process.env.COMPUTERNAME;\n addLocalServerName(names, hostname());\n addLocalServerName(names, computerName);\n if (computerName !== undefined && process.env.USERDNSDOMAIN !== undefined) {\n addLocalServerName(names, `${computerName}.${process.env.USERDNSDOMAIN}`);\n }\n for (const addresses of Object.values(networkInterfaces())) {\n for (const address of addresses ?? []) {\n if (isIP(address.address) === 4) {\n addLocalServerName(names, address.address);\n } else if (isIP(address.address) === 6) {\n addIpv6LiteralName(names, address.address);\n }\n }\n }\n addLocalServerName(names, \"--1.ipv6-literal.net\");\n return names;\n}\nconst localServerNames =\n process.platform === \"win32\" ? collectLocalServerNames() : new Set<string>();\nlet driveMappings: DriveMapping[] | undefined;\nfunction containsControlCharacter(value: string): boolean {\n return [...value].some((character) => character.charCodeAt(0) < 32);\n}\nfunction normalizeUncRoot(value: string): string {\n return value.replaceAll(\"/\", \"\\\\\").replace(/\\\\+$/u, \"\").toLowerCase();\n}\nfunction parseUncPath(value: string): UncPath | undefined {\n const normalized = value.replaceAll(\"/\", \"\\\\\");\n const extended = normalized.slice(0, 8).toLowerCase() === \"\\\\\\\\?\\\\unc\\\\\";\n if (normalized.startsWith(\"\\\\\\\\.\\\\\") || (normalized.startsWith(\"\\\\\\\\?\\\\\") && !extended)) {\n return undefined;\n }\n const serverStart = extended ? 8 : 2;\n const serverSeparator = normalized.slice(serverStart).indexOf(\"\\\\\");\n if (serverSeparator <= 0) {\n return undefined;\n }\n const serverEnd = serverStart + serverSeparator;\n const shareStart = serverEnd + 1;\n const shareSeparator = normalized.slice(shareStart).indexOf(\"\\\\\");\n const shareEnd = shareSeparator === -1 ? normalized.length : shareStart + shareSeparator;\n const server = normalized.slice(serverStart, serverEnd);\n const share = normalized.slice(shareStart, shareEnd);\n if (\n share.length === 0 ||\n !uncServerSegmentPattern.test(server) ||\n !uncServerSegmentPattern.test(share)\n ) {\n return undefined;\n }\n const suffix = normalized.slice(shareEnd);\n return {\n canonical: `\\\\\\\\${server}\\\\${share}${suffix}`,\n server,\n share,\n suffix,\n };\n}\nfunction queryDriveMapping(drive: string): string | undefined {\n if (native === undefined) {\n return undefined;\n }\n const { remote, status } = native.getDriveConnection(drive, mappingBufferChars);\n if (status === errorMoreData) {\n throw new Error(`WNetGetConnectionW returned an oversized mapping for ${drive}`);\n }\n if (unmappedDriveErrors.has(status)) {\n return undefined;\n }\n if (status !== 0) {\n throw new Error(`WNetGetConnectionW failed for ${drive} with error ${status}`);\n }\n if (typeof remote !== \"string\" || !remote.startsWith(\"\\\\\\\\\")) {\n throw new TypeError(`WNetGetConnectionW returned an invalid mapping for ${drive}`);\n }\n return normalizeUncRoot(remote);\n}\nfunction queryDriveMappings(): DriveMapping[] {\n if (driveMappings !== undefined) {\n return driveMappings;\n }\n const result: DriveMapping[] = [];\n for (let code = \"A\".charCodeAt(0); code <= \"Z\".charCodeAt(0); code += 1) {\n const drive = `${String.fromCharCode(code)}:`;\n const remote = queryDriveMapping(drive);\n if (remote !== undefined) {\n result.push({ drive, remote });\n }\n }\n driveMappings = result.toSorted((left, right) => right.remote.length - left.remote.length);\n return driveMappings;\n}\nfunction resolveMappedUncPath(path: UncPath): string | undefined {\n const canonical = normalizeUncRoot(path.canonical);\n const mapping = queryDriveMappings().find(\n ({ remote }) => canonical === remote || canonical.startsWith(`${remote}\\\\`),\n );\n if (mapping === undefined) {\n return undefined;\n }\n const relative = path.canonical.slice(mapping.remote.length);\n return nodePath.win32.normalize(`${mapping.drive}${relative}`);\n}\nfunction isLocalServer(value: string): boolean {\n const normalized = normalizeServerName(value);\n return (\n localServerNames.has(normalized) ||\n (isIP(value) === 4 && value.split(\".\")[0] === \"127\") ||\n normalized === \"--1.ipv6-literal.net\"\n );\n}\nfunction resolveLocalAdministrativeShare(path: UncPath): string | undefined {\n const match = /^([A-Za-z])\\$$/u.exec(path.share);\n if (match === null || !isLocalServer(path.server)) {\n return undefined;\n }\n return nodePath.win32.normalize(`${match[1]}:${path.suffix || \"\\\\\"}`);\n}\nexport function resolveUncPath(value: string): string | undefined {\n if (process.platform !== \"win32\" || (!value.startsWith(\"\\\\\\\\\") && !value.startsWith(\"//\"))) {\n return value;\n }\n if (containsControlCharacter(value)) {\n return undefined;\n }\n const path = parseUncPath(value);\n if (path === undefined) {\n return undefined;\n }\n return resolveMappedUncPath(path) ?? resolveLocalAdministrativeShare(path);\n}\n","import nodePath from \"node:path\";\nimport nativeBridge from \"./windows-bridge.cjs\";\n\nconst fileAttributeHidden = 0x2;\nconst invalidFileAttributes = 0xffffffff;\nconst missingPathErrors = new Set([2, 3]);\nexport function hasWindowsHiddenAttribute(filePath: string): boolean {\n if (process.platform !== \"win32\") {\n throw new Error(\"Windows file attributes are unavailable on this platform\");\n }\n const { attributes, error } = nativeBridge.getFileAttributes(nodePath.toNamespacedPath(filePath));\n if (!Number.isInteger(attributes) || !Number.isInteger(error)) {\n throw new TypeError(\"Windows file attribute lookup returned an invalid result\");\n }\n if (attributes !== invalidFileAttributes) {\n if (error !== 0) {\n throw new Error(`Windows file attribute lookup returned attributes with error ${error}`);\n }\n return (attributes & fileAttributeHidden) !== 0;\n }\n if (missingPathErrors.has(error)) {\n return false;\n }\n throw new Error(`Windows file attribute lookup failed for ${filePath} with error ${error}`);\n}\n","import nodePath from \"node:path\";\nimport { hasWindowsHiddenAttribute } from \"../native/attributes.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction relativePath(filePath: string, boundary: string): string {\n const relative = nodePath.relative(boundary, filePath);\n if (\n nodePath.isAbsolute(relative) ||\n relative === \"..\" ||\n relative.startsWith(`..${nodePath.sep}`)\n ) {\n throw new RangeError(`${filePath} is outside the hidden-path boundary ${boundary}`);\n }\n return relative;\n}\nfunction hasHiddenDotSegment(filePath: string, boundary: string): boolean {\n return relativePath(filePath, boundary)\n .split(/[\\\\/]/u)\n .some((part) => part.length > 1 && part.startsWith(\".\"));\n}\nexport function createHiddenPathDetector() {\n const attributeCache = new Map<string, boolean>();\n return {\n isHidden(filePath: string, boundary: string): boolean {\n if (process.platform !== \"win32\") {\n return hasHiddenDotSegment(filePath, boundary);\n }\n relativePath(filePath, boundary);\n const boundaryKey = pathKey(nodePath.resolve(boundary));\n let current = nodePath.resolve(filePath);\n while (pathKey(current) !== boundaryKey) {\n const key = pathKey(current);\n let hidden = attributeCache.get(key);\n if (hidden === undefined) {\n hidden = hasWindowsHiddenAttribute(current);\n attributeCache.set(key, hidden);\n }\n if (hidden) {\n return true;\n }\n const parent = nodePath.dirname(current);\n if (parent === current) {\n throw new Error(`Unable to reach hidden-path boundary ${boundary} from ${filePath}`);\n }\n current = parent;\n }\n return false;\n },\n };\n}\n","import nodeFileSystem from \"node:fs\";\nimport nodePath from \"node:path\";\nimport type { Options as GlobbyOptions } from \"globby\";\nimport { createHiddenPathDetector } from \"./hidden.js\";\n\ntype ReadDirectory = NonNullable<NonNullable<GlobbyOptions[\"fs\"]>[\"readdir\"]>;\nconst unreadableDirectoryErrors = new Set([\"EACCES\", \"ENOTDIR\", \"ENOENT\", \"EPERM\"]);\ninterface DirectoryEntry {\n isBlockDevice(): boolean;\n isCharacterDevice(): boolean;\n isDirectory(): boolean;\n isFIFO(): boolean;\n isFile(): boolean;\n isSocket(): boolean;\n isSymbolicLink(): boolean;\n name: string;\n}\ntype DirectoryEntryCallback = (\n error: NodeJS.ErrnoException | null,\n entries: DirectoryEntry[],\n) => void;\ntype DirectoryNameCallback = (error: NodeJS.ErrnoException | null, entries: string[]) => void;\ninterface TraversalScope {\n paths: readonly string[];\n passthroughNames: readonly string[];\n}\ninterface TraversalFileSystemOptions {\n readDirectory?: ReadDirectory;\n scope?: TraversalScope;\n}\ninterface IndexedScope {\n childrenByDirectory: ReadonlyMap<string, ReadonlySet<string>>;\n passthroughNames: ReadonlySet<string>;\n}\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isUnreadableDirectoryError(error: NodeJS.ErrnoException): boolean {\n return error.code !== undefined && unreadableDirectoryErrors.has(error.code);\n}\nfunction completeDirectoryRead<T>(\n error: NodeJS.ErrnoException | null,\n entries: T[],\n callback: (error: NodeJS.ErrnoException | null, entries: T[]) => void,\n): void {\n if (error === null) {\n callback(null, entries);\n } else if (isUnreadableDirectoryError(error)) {\n callback(null, []);\n } else {\n callback(error, []);\n }\n}\nfunction indexScope(root: string, scope: TraversalScope | undefined): IndexedScope | undefined {\n if (scope === undefined) {\n return undefined;\n }\n const resolvedRoot = nodePath.resolve(root);\n const childrenByDirectory = new Map<string, Set<string>>();\n for (const relativePath of scope.paths) {\n if (\n nodePath.isAbsolute(relativePath) ||\n relativePath === \"..\" ||\n relativePath.startsWith(`..${nodePath.sep}`)\n ) {\n throw new RangeError(`${relativePath} is outside the traversal root ${root}`);\n }\n let directory = resolvedRoot;\n for (const name of relativePath.split(nodePath.sep)) {\n const directoryKey = pathKey(directory);\n const children = childrenByDirectory.get(directoryKey) ?? new Set<string>();\n children.add(pathKey(name));\n childrenByDirectory.set(directoryKey, children);\n directory = nodePath.join(directory, name);\n }\n }\n return {\n childrenByDirectory,\n passthroughNames: new Set(scope.passthroughNames.map(pathKey)),\n };\n}\nfunction filterToScope<T extends DirectoryEntry | string>(\n filePath: string,\n entries: T[],\n scope: IndexedScope | undefined,\n): T[] {\n if (scope === undefined) {\n return entries;\n }\n const children = scope.childrenByDirectory.get(pathKey(nodePath.resolve(filePath)));\n if (children === undefined) {\n return [];\n }\n return entries.filter((entry) => {\n const name = typeof entry === \"string\" ? entry : entry.name;\n const key = pathKey(name);\n return children.has(key) || scope.passthroughNames.has(key);\n });\n}\nfunction createReadDirectory(\n root: string,\n searchHidden: boolean,\n readDirectory: ReadDirectory,\n scope: IndexedScope | undefined,\n): ReadDirectory {\n const hiddenDetector = createHiddenPathDetector();\n function traverseReadDirectory(\n filePath: string,\n options: { withFileTypes: true },\n callback: DirectoryEntryCallback,\n ): void;\n function traverseReadDirectory(filePath: string, callback: DirectoryNameCallback): void;\n function traverseReadDirectory(\n filePath: string,\n optionsOrCallback: { withFileTypes: true } | DirectoryNameCallback,\n entryCallback?: DirectoryEntryCallback,\n ): void {\n if (typeof optionsOrCallback === \"function\") {\n readDirectory(filePath, (error, entries) => {\n const scopedEntries = error === null ? filterToScope(filePath, entries, scope) : entries;\n completeDirectoryRead(error, scopedEntries, optionsOrCallback);\n });\n return;\n }\n if (entryCallback === undefined) {\n throw new TypeError(\"A directory entry callback is required\");\n }\n readDirectory(filePath, optionsOrCallback, (error, entries) => {\n const scopedEntries = error === null ? filterToScope(filePath, entries, scope) : entries;\n if (error !== null || searchHidden) {\n completeDirectoryRead(error, scopedEntries, entryCallback);\n return;\n }\n try {\n const visibleEntries = scopedEntries.filter(\n (entry) =>\n !entry.isDirectory() ||\n !hiddenDetector.isHidden(nodePath.join(filePath, entry.name), root),\n );\n entryCallback(null, visibleEntries);\n } catch (caught) {\n entryCallback(caught instanceof Error ? caught : new Error(String(caught)), []);\n }\n });\n }\n return traverseReadDirectory;\n}\nexport function createTraversalFileSystem(\n root: string,\n searchHidden: boolean,\n options: TraversalFileSystemOptions = {},\n) {\n const { readDirectory = nodeFileSystem.readdir, scope } = options;\n return {\n ...nodeFileSystem,\n readdir: createReadDirectory(root, searchHidden, readDirectory, indexScope(root, scope)),\n };\n}\n","import { stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport { convertPathToPattern, globby } from \"globby\";\nimport isPathInside from \"is-path-inside\";\nimport { settings } from \"../../config/settings.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport type { SearchEntry } from \"../types.js\";\nimport { createHiddenPathDetector } from \"./hidden.js\";\nimport { createTraversalFileSystem } from \"./traversal.js\";\n\nconst ignoreFilePatterns = settings.ignoreFileNames.map(\n (name) => `**/${convertPathToPattern(name)}`,\n);\nconst ignoreFileNames = [\".gitignore\", ...settings.ignoreFileNames];\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isWithinRoot(filePath: string, root: string): boolean {\n return filePath === root || isPathInside(filePath, root);\n}\nfunction traversalOptions(\n root: string,\n searchHidden: boolean,\n scopedPaths: readonly string[] | undefined,\n) {\n const fileSystem =\n scopedPaths === undefined\n ? createTraversalFileSystem(root, searchHidden)\n : createTraversalFileSystem(root, searchHidden, {\n scope: {\n passthroughNames: ignoreFileNames,\n paths: scopedPaths,\n },\n });\n return {\n caseSensitiveMatch: process.platform !== \"win32\",\n cwd: root,\n dot: process.platform === \"win32\" || searchHidden,\n followSymbolicLinks: false,\n fs: fileSystem,\n onlyFiles: false,\n unique: true,\n } as const;\n}\nfunction globbyOptions(\n root: string,\n respectIgnore: boolean,\n searchHidden: boolean,\n scopedPaths?: readonly string[],\n) {\n return {\n ...traversalOptions(root, searchHidden, scopedPaths),\n expandDirectories: false,\n gitignore: respectIgnore,\n globalGitignore: respectIgnore,\n ...(respectIgnore ? { ignoreFiles: ignoreFilePatterns } : {}),\n } as const;\n}\nexport async function resolveSearchDirectories(directories: readonly string[]): Promise<string[]> {\n if (!Array.isArray(directories)) {\n throw new TypeError(\"directories must be an array\");\n }\n if (directories.length === 0) {\n throw new RangeError(\"directories must not be empty\");\n }\n const unique = new Map<string, string>();\n for (const directory of directories) {\n if (typeof directory !== \"string\" || directory.length === 0) {\n throw new TypeError(\"every directory must be a non-empty string\");\n }\n const resolvedUnc = resolveUncPath(directory);\n if (resolvedUnc === undefined || resolvedUnc.length === 0) {\n throw new TypeError(`${directory} cannot be represented as a drive-based path`);\n }\n const resolved = nodePath.resolve(resolvedUnc);\n unique.set(pathKey(resolved), resolved);\n }\n await Promise.all(\n [...unique.values()].map(async (directory) => {\n if (!(await stat(directory)).isDirectory()) {\n throw new TypeError(`${directory} is not a directory`);\n }\n }),\n );\n return [...unique.values()];\n}\nexport async function listSearchEntries(\n root: string,\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<SearchEntry[]> {\n const entries = await globby(\"**/*\", {\n ...globbyOptions(root, respectIgnore, searchHidden),\n objectMode: true,\n });\n const hiddenDetector = createHiddenPathDetector();\n return entries\n .filter(\n (entry) => searchHidden || !hiddenDetector.isHidden(nodePath.resolve(root, entry.path), root),\n )\n .map((entry) => ({\n directory: entry.dirent.isDirectory(),\n path: entry.path,\n }));\n}\nexport async function filterSearchablePaths(\n paths: readonly string[],\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Set<string>> {\n const allowed = new Set<string>();\n const pathsByRoot = new Map<string, string[]>();\n const hiddenDetector = createHiddenPathDetector();\n for (const filePath of paths) {\n let hasSearchRoot = false;\n for (const root of roots) {\n if (!isWithinRoot(filePath, root)) {\n continue;\n }\n hasSearchRoot = true;\n const relative = nodePath.relative(root, filePath);\n if (!searchHidden && hiddenDetector.isHidden(filePath, root)) {\n continue;\n }\n if (relative === \"\" || !respectIgnore) {\n allowed.add(filePath);\n } else {\n const grouped = pathsByRoot.get(root) ?? [];\n grouped.push(relative);\n pathsByRoot.set(root, grouped);\n }\n }\n if (hasSearchRoot) {\n continue;\n }\n const filesystemRoot = nodePath.parse(filePath).root;\n const hiddenBoundary =\n process.platform === \"win32\" ? nodePath.dirname(filePath) : filesystemRoot;\n if (searchHidden || !hiddenDetector.isHidden(filePath, hiddenBoundary)) {\n allowed.add(filePath);\n }\n }\n await Promise.all(\n [...pathsByRoot].map(async ([root, relativePaths]) => {\n const patterns = relativePaths.map(convertPathToPattern);\n const matches = await globby(patterns, {\n ...globbyOptions(root, true, true, relativePaths),\n absolute: true,\n });\n for (const match of matches) {\n allowed.add(nodePath.normalize(match));\n }\n }),\n );\n return allowed;\n}\n","import { filterSearchablePaths } from \"../search/policy.js\";\nimport type { PathKind } from \"../types.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nexport async function applySearchPolicies(\n existingPaths: ReadonlyMap<string, PathKind>,\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Map<string, PathKind>> {\n if (!respectIgnore && searchHidden) {\n return new Map(existingPaths);\n }\n const searchablePaths = await filterSearchablePaths(\n [...existingPaths.keys()],\n roots,\n respectIgnore,\n searchHidden,\n );\n const searchableKeys = new Set([...searchablePaths].map(pathKey));\n return new Map([...existingPaths].filter(([filePath]) => searchableKeys.has(pathKey(filePath))));\n}\n","import { readdir, stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport pLimit from \"p-limit\";\nimport { settings } from \"../../config/settings.js\";\nimport type { PathKind } from \"../types.js\";\n\nconst unavailablePathErrors = new Set([\n \"EACCES\",\n \"ELOOP\",\n \"ENAMETOOLONG\",\n \"ENOTDIR\",\n \"ENOENT\",\n \"EPERM\",\n \"EINVAL\",\n]);\nconst unverifiableUncErrors = new Set([\"UNKNOWN\", \"EUNKNOWN\"]);\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isUnavailablePathError(error: unknown, filePath?: string): boolean {\n const code =\n error instanceof Error && \"code\" in error && typeof error.code === \"string\"\n ? error.code\n : undefined;\n return (\n code !== undefined &&\n (unavailablePathErrors.has(code) ||\n (filePath?.startsWith(\"\\\\\\\\\") === true && unverifiableUncErrors.has(code)))\n );\n}\nasync function classifyPath(filePath: string): Promise<PathKind | undefined> {\n try {\n const pathStats = await stat(filePath);\n if (pathStats.isFile()) {\n return \"file\";\n }\n return pathStats.isDirectory() ? \"directory\" : undefined;\n } catch (error) {\n if (isUnavailablePathError(error, filePath)) {\n return undefined;\n }\n throw error;\n }\n}\nasync function classifyAndAdd(found: Map<string, PathKind>, filePath: string): Promise<void> {\n const kind = await classifyPath(filePath);\n if (kind !== undefined) {\n found.set(filePath, kind);\n }\n}\nexport async function classifyExistingPaths(\n paths: readonly string[],\n roots: readonly string[],\n): Promise<Map<string, PathKind>> {\n const found = new Map<string, PathKind>();\n const limit = pLimit(settings.validationConcurrency);\n if (paths.length < settings.batchValidationThreshold) {\n await limit.map(paths, (filePath) => classifyAndAdd(found, filePath));\n return found;\n }\n const rootKeys = new Set(roots.map(pathKey));\n const pathsByParent = new Map<string, { parent: string; paths: string[] }>();\n for (const filePath of paths) {\n if (rootKeys.has(pathKey(filePath))) {\n found.set(filePath, \"directory\");\n continue;\n }\n const parent = nodePath.dirname(filePath);\n const key = pathKey(parent);\n const group = pathsByParent.get(key) ?? { parent, paths: [] };\n group.paths.push(filePath);\n pathsByParent.set(key, group);\n }\n const directPaths: string[] = [];\n const scannedGroups: { parent: string; paths: string[] }[] = [];\n for (const group of pathsByParent.values()) {\n if (group.paths.length < settings.directoryScanThreshold) {\n directPaths.push(...group.paths);\n } else {\n scannedGroups.push(group);\n }\n }\n await Promise.all([\n limit.map(directPaths, (filePath) => classifyAndAdd(found, filePath)),\n limit.map(scannedGroups, async ({ parent, paths: groupPaths }) => {\n let entries;\n try {\n entries = await readdir(parent, { withFileTypes: true });\n } catch (error) {\n if (isUnavailablePathError(error, parent)) {\n return;\n }\n throw error;\n }\n const entriesByName = new Map(entries.map((entry) => [pathKey(entry.name), entry]));\n await Promise.all(\n groupPaths.map(async (filePath) => {\n const name = nodePath.basename(filePath);\n const entry = entriesByName.get(pathKey(name));\n if (entry?.isFile()) {\n found.set(filePath, \"file\");\n } else if (entry?.isDirectory()) {\n found.set(filePath, \"directory\");\n } else if (entry !== undefined || (process.platform === \"win32\" && name.includes(\":\"))) {\n await classifyAndAdd(found, filePath);\n }\n }),\n );\n }),\n ]);\n return found;\n}\n","import type { PathMatch } from \"../types.js\";\n\nexport function removeContainedMatches(matches: readonly PathMatch[]): PathMatch[] {\n const ordered = matches\n .map((match, index) => ({ index, match }))\n .toSorted(\n ({ match: left }, { match: right }) =>\n left.position.start - right.position.start || right.position.end - left.position.end,\n );\n const kept = new Set<number>();\n let maxEndBeforeStart = -1;\n let groupStart = -1;\n let maxEndInGroup = -1;\n for (const { index, match } of ordered) {\n const { start, end } = match.position;\n if (start !== groupStart) {\n maxEndBeforeStart = Math.max(maxEndBeforeStart, maxEndInGroup);\n groupStart = start;\n maxEndInGroup = -1;\n }\n if (maxEndBeforeStart < end && maxEndInGroup <= end) {\n kept.add(index);\n }\n maxEndInGroup = Math.max(maxEndInGroup, end);\n }\n return matches.filter((_, index) => kept.has(index));\n}\n","import { settings } from \"../../config/settings.js\";\nimport type { Candidate, PathLocation, PathPosition } from \"../types.js\";\n\nexport interface PreparedCandidate {\n location?: PathLocation;\n position: PathPosition;\n value: string;\n}\nfunction parseLocationPart(value: string, name: string): number {\n const result = Number(value);\n if (!Number.isSafeInteger(result)) {\n throw new RangeError(`${name} must be a safe integer`);\n }\n return result;\n}\nexport function prepareCandidate(candidate: Candidate): PreparedCandidate | undefined {\n let end = candidate.end;\n let start = candidate.start;\n let value = candidate.value;\n if (candidate.kind !== \"inventory\" && candidate.kind !== \"quoted\") {\n const startTrimmed = value.trimStart();\n start += value.length - startTrimmed.length;\n value = startTrimmed;\n const endTrimmed = value.trimEnd();\n end -= value.length - endTrimmed.length;\n value = endTrimmed;\n if (\n value.length >= 2 &&\n ((value[0] === '\"' && value.at(-1) === '\"') ||\n (value[0] === \"'\" && value.at(-1) === \"'\") ||\n (value[0] === \"`\" && value.at(-1) === \"`\"))\n ) {\n start += 1;\n end -= 1;\n value = value.slice(1, -1);\n }\n while (value.length > 0 && settings.trailingPunctuation.includes(value.at(-1) ?? \"\")) {\n end -= 1;\n value = value.slice(0, -1);\n }\n }\n let location: PathLocation | undefined;\n if (candidate.kind !== \"inventory\") {\n const match = settings.locationSuffixPattern.exec(value);\n if (match !== null) {\n const lineValue = match.groups?.line;\n if (lineValue === undefined) {\n throw new TypeError(\"locationSuffixPattern must capture a line\");\n }\n const columnValue = match.groups?.column;\n location =\n columnValue === undefined\n ? { line: parseLocationPart(lineValue, \"line\") }\n : {\n column: parseLocationPart(columnValue, \"column\"),\n line: parseLocationPart(lineValue, \"line\"),\n };\n end -= match[0].length;\n value = value.slice(0, match.index);\n }\n }\n if (value === \"/\") {\n return undefined;\n }\n return {\n ...(location === undefined ? {} : { location }),\n position: { end, start },\n value,\n };\n}\n","import { fileURLToPath } from \"node:url\";\nimport nodePath from \"node:path\";\nimport { applySearchPolicies } from \"./eligibility.js\";\nimport { classifyExistingPaths } from \"./existence.js\";\nimport { removeContainedMatches } from \"./containment.js\";\nimport { prepareCandidate } from \"./preparation.js\";\nimport { expandVariables } from \"../variables.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport type {\n Candidate,\n PathKind,\n PathLocation,\n PathMatch,\n PathPosition,\n Variables,\n} from \"../types.js\";\n\ninterface ResolvedCandidate {\n expectedKind?: PathKind;\n location?: PathLocation;\n path: string;\n position: PathPosition;\n}\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction uniquePaths(values: Iterable<string>): string[] {\n const paths = new Map<string, string>();\n for (const value of values) {\n paths.set(pathKey(value), value);\n }\n return [...paths.values()];\n}\nfunction unescape(value: string): string {\n if (value.startsWith(\"\\\\\\\\\") && !value.startsWith(\"\\\\\\\\\\\\\\\\\")) {\n return value;\n }\n return value.replace(/\\\\([\"'`\\\\])/gu, \"$1\").replace(/\\\\\\\\/gu, \"\\\\\");\n}\nfunction toPaths(value: string, roots: readonly string[], variables: Variables): string[] {\n let expanded = expandVariables(value, variables);\n if (expanded.startsWith(\"file://\")) {\n try {\n expanded = fileURLToPath(expanded);\n } catch (error) {\n if (error instanceof TypeError) {\n return [];\n }\n throw error;\n }\n } else {\n expanded = unescape(expanded);\n if (expanded === \"~\" || /^~[\\\\/]/u.test(expanded)) {\n expanded = nodePath.join(\n variables.HOME ??\n variables.USERPROFILE ??\n process.env.HOME ??\n process.env.USERPROFILE ??\n \"\",\n expanded.slice(2),\n );\n }\n }\n const resolvedPath = resolveUncPath(expanded);\n if (resolvedPath === undefined || resolvedPath.length === 0) {\n return [];\n }\n expanded = resolvedPath;\n if (nodePath.isAbsolute(expanded)) {\n return [nodePath.normalize(expanded)];\n }\n return uniquePaths(roots.map((root) => nodePath.resolve(root, expanded)));\n}\nfunction mergeLocation(match: PathMatch, location: PathLocation | undefined): void {\n if (location === undefined) {\n return;\n }\n if (match.location === undefined) {\n match.location = location;\n return;\n }\n if (match.location.line !== location.line || match.location.column !== location.column) {\n throw new Error(\"Candidates for the same path and position have conflicting locations\");\n }\n}\nexport async function validateCandidates(\n candidates: Candidate[],\n roots: readonly string[],\n variables: Variables,\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<PathMatch[]> {\n const resolvedCandidates: ResolvedCandidate[] = [];\n const validationPaths = new Map<string, string>();\n for (const candidate of candidates) {\n const prepared = prepareCandidate(candidate);\n if (prepared === undefined) {\n continue;\n }\n const paths = toPaths(prepared.value, roots, variables);\n for (const filePath of paths) {\n resolvedCandidates.push({\n ...(candidate.expectedKind === undefined ? {} : { expectedKind: candidate.expectedKind }),\n ...(prepared.location === undefined ? {} : { location: prepared.location }),\n path: filePath,\n position: prepared.position,\n });\n validationPaths.set(pathKey(filePath), filePath);\n }\n }\n const classifiedPaths = await applySearchPolicies(\n await classifyExistingPaths([...validationPaths.values()], roots),\n roots,\n respectIgnore,\n searchHidden,\n );\n const kindsByPath = new Map(\n [...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind]),\n );\n const matches = new Map<string, PathMatch>();\n for (const { expectedKind, location, path, position } of resolvedCandidates) {\n const kind = kindsByPath.get(pathKey(path));\n if (kind === undefined || (expectedKind !== undefined && kind !== expectedKind)) {\n continue;\n }\n const key = `${pathKey(path)}\\0${position.start}\\0${position.end}`;\n const existing = matches.get(key);\n if (existing !== undefined) {\n mergeLocation(existing, location);\n continue;\n }\n matches.set(key, {\n kind,\n ...(location === undefined ? {} : { location }),\n path,\n position,\n });\n }\n return removeContainedMatches([...matches.values()]);\n}\n","import nodePath from \"node:path\";\nimport { AhoCorasick } from \"@monyone/aho-corasick\";\nimport { listSearchEntries } from \"./policy.js\";\nimport type {\n Candidate,\n InventoryMatcher,\n InventoryPattern,\n RootPrefix,\n SearchEntry,\n} from \"../types.js\";\n\nlet inventoryMatcherCache: InventoryMatcher | undefined;\nfunction isBoundary(\n value: string | undefined,\n following: string | undefined,\n directoryEnd = false,\n): boolean {\n if (directoryEnd && value !== \".\") {\n return value === undefined || /[\\s\"'`<>)\\]},;:!?,。;:!?、]/u.test(value);\n }\n if (value === \".\") {\n return following === undefined || !/[\\p{L}\\p{N}_-]/u.test(following);\n }\n return value === undefined || !/[\\p{L}\\p{N}_/\\\\-]/u.test(value);\n}\nfunction addMatch(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n value: string,\n start: number,\n end: number,\n expectedKind: InventoryPattern[\"expectedKind\"],\n): void {\n if (\n !isBoundary(text[start - 1], text[start]) ||\n !isBoundary(text[end], text[end + 1], expectedKind === \"directory\")\n ) {\n return;\n }\n const key = `${start}:${end}:${text.slice(start, end)}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push({ end, expectedKind, kind: \"inventory\", start, value });\n }\n}\nfunction addVariant(\n patterns: Map<string, InventoryPattern>,\n entry: SearchEntry,\n value: string,\n): void {\n const key = process.platform === \"win32\" ? value.toLowerCase() : value;\n if (!patterns.has(key)) {\n patterns.set(key, {\n expectedKind: entry.directory ? \"directory\" : \"file\",\n relative: entry.path,\n value,\n });\n }\n}\nfunction addEntryVariants(patterns: Map<string, InventoryPattern>, entry: SearchEntry): void {\n const native = entry.path.replaceAll(\"/\", nodePath.sep);\n if (entry.directory) {\n addVariant(patterns, entry, `${entry.path}/`);\n addVariant(patterns, entry, `${native}${nodePath.sep}`);\n return;\n }\n addVariant(patterns, entry, entry.path);\n addVariant(patterns, entry, native);\n}\nfunction createRootPrefixes(roots: readonly string[]): RootPrefix[] {\n const prefixes = new Map<string, RootPrefix>();\n for (const root of roots) {\n const native = root.endsWith(nodePath.sep) ? root : `${root}${nodePath.sep}`;\n const slashRoot = root.replaceAll(nodePath.sep, \"/\");\n const slash = slashRoot.endsWith(\"/\") ? slashRoot : `${slashRoot}/`;\n for (const value of [native, slash]) {\n const key = process.platform === \"win32\" ? value.toLowerCase() : value;\n prefixes.set(key, { root, value: key });\n }\n }\n return [...prefixes.values()];\n}\nfunction addAbsoluteMatch(\n result: Candidate[],\n seen: Set<string>,\n source: string,\n text: string,\n pattern: InventoryPattern,\n prefixes: readonly RootPrefix[],\n end: number,\n relativeStart: number,\n): boolean {\n for (const prefix of prefixes) {\n const start = relativeStart - prefix.value.length;\n if (start >= 0 && source.startsWith(prefix.value, start)) {\n addMatch(\n result,\n seen,\n text,\n nodePath.resolve(prefix.root, pattern.relative),\n start,\n end,\n pattern.expectedKind,\n );\n return true;\n }\n }\n return false;\n}\nfunction hasSameEntries(\n cached: InventoryMatcher,\n entries: readonly (readonly SearchEntry[])[],\n): boolean {\n if (cached.entries.length !== entries.length) {\n return false;\n }\n for (let index = 0; index < entries.length; index += 1) {\n const cachedEntries = cached.entries[index];\n const currentEntries = entries[index];\n if (cachedEntries === undefined || currentEntries === undefined) {\n return false;\n }\n if (cachedEntries.length !== currentEntries.length) {\n return false;\n }\n for (let entryIndex = 0; entryIndex < currentEntries.length; entryIndex += 1) {\n const cachedEntry = cachedEntries[entryIndex];\n const currentEntry = currentEntries[entryIndex];\n if (\n cachedEntry === undefined ||\n currentEntry === undefined ||\n cachedEntry.directory !== currentEntry.directory ||\n cachedEntry.path !== currentEntry.path\n ) {\n return false;\n }\n }\n }\n return true;\n}\nfunction canReuseMatcher(\n cached: InventoryMatcher | undefined,\n entries: readonly (readonly SearchEntry[])[],\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): cached is InventoryMatcher {\n return (\n cached !== undefined &&\n cached.respectIgnore === respectIgnore &&\n cached.searchHidden === searchHidden &&\n cached.roots.length === roots.length &&\n cached.roots.every((root, index) => root === roots[index]) &&\n hasSameEntries(cached, entries)\n );\n}\nexport async function inventoryCandidates(\n text: string,\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Candidate[]> {\n const entries = await Promise.all(\n roots.map((root) => listSearchEntries(root, respectIgnore, searchHidden)),\n );\n const result: Candidate[] = [];\n const seen = new Set<string>();\n const source = process.platform === \"win32\" ? text.toLowerCase() : text;\n let inventoryMatcher = inventoryMatcherCache;\n if (!canReuseMatcher(inventoryMatcher, entries, roots, respectIgnore, searchHidden)) {\n const patterns = new Map<string, InventoryPattern>();\n for (const relativeEntries of entries) {\n for (const entry of relativeEntries) {\n addEntryVariants(patterns, entry);\n }\n }\n inventoryMatcher = {\n entries,\n matcher: new AhoCorasick([...patterns.keys()]),\n patterns,\n prefixes: createRootPrefixes(roots),\n respectIgnore,\n roots: [...roots],\n searchHidden,\n };\n inventoryMatcherCache = inventoryMatcher;\n }\n for (const { begin, end, keyword } of inventoryMatcher.matcher.matchInText(source)) {\n const pattern = inventoryMatcher.patterns.get(keyword);\n if (pattern === undefined) {\n throw new Error(\"Inventory matcher returned an unknown path\");\n }\n if (\n !addAbsoluteMatch(result, seen, source, text, pattern, inventoryMatcher.prefixes, end, begin)\n ) {\n addMatch(result, seen, text, pattern.value, begin, end, pattern.expectedKind);\n }\n }\n return result;\n}\n","import { extractCandidates } from \"./candidates.js\";\nimport { validateCandidates } from \"./validation/resolution.js\";\nimport { inventoryCandidates } from \"./search/inventory.js\";\nimport { resolveSearchDirectories } from \"./search/policy.js\";\nimport { settings } from \"../config/settings.js\";\nimport type { FindExistingPathsOptions, PathMatch, Variables } from \"./types.js\";\n\nexport const MAX_LEVEL = settings.spanWordLimits.length + 3;\nfunction validateOptions(value: unknown): asserts value is FindExistingPathsOptions {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"options must be an object\");\n }\n}\nfunction validateVariables(value: unknown): asserts value is Variables {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n Object.values(value).some((item) => typeof item !== \"string\")\n ) {\n throw new TypeError(\"variables must be an object of string values\");\n }\n}\nexport async function findExistingPaths(options: FindExistingPathsOptions): Promise<PathMatch[]> {\n validateOptions(options);\n const {\n directories,\n level,\n respectIgnore = settings.respectIgnoreByDefault,\n searchHidden = settings.searchHiddenByDefault,\n text,\n variables = {},\n } = options;\n if (typeof text !== \"string\") {\n throw new TypeError(\"text must be a string\");\n }\n if (!Number.isInteger(level) || level < 1 || level > MAX_LEVEL) {\n throw new RangeError(`level must be an integer from 1 to ${MAX_LEVEL}`);\n }\n validateVariables(variables);\n if (typeof respectIgnore !== \"boolean\") {\n throw new TypeError(\"respectIgnore must be a boolean\");\n }\n if (typeof searchHidden !== \"boolean\") {\n throw new TypeError(\"searchHidden must be a boolean\");\n }\n const roots = await resolveSearchDirectories(directories);\n const candidates = extractCandidates(text, level);\n if (level === MAX_LEVEL) {\n candidates.push(...(await inventoryCandidates(text, roots, respectIgnore, searchHidden)));\n }\n return validateCandidates(candidates, roots, variables, respectIgnore, searchHidden);\n}\nexport type {\n FindExistingPathsOptions,\n PathKind,\n PathLocation,\n PathMatch,\n PathPosition,\n SearchLevel,\n Variables,\n} from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;AAEA,MAAa,WAA2B;CACtC,0BAA0B;CAC1B,wBAAwB;CACxB,iBAAiB,CAAC,WAAW,WAAW;CACxC,uBAAuB;CACvB,wBAAwB;CACxB,uBAAuB;CACvB,gBAAgB,CAAC,GAAG,EAAE;CACtB,qBAAqB;CACrB,uBAAuB;AACzB;;;ACVA,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAa,0BAA0B,OAAO,GAAG,8CAA8C,WAAW,iBAAiB,WAAW,0BAA0B,WAAW,WAAW,WAAW,6BAA6B,WAAW,KAAK,WAAW,WAAW,WAAW,SAAS,WAAW;AACnS,MAAM,qBAAqB;CACzB,IAAI,OAAO,OAAO,GAAG,4CAA4C,WAAW,WAAW,KAAK;CAC5F,IAAI,OAAO,OAAO,GAAG,WAAW,WAAW,WAAW,IAAI;CAC1D,IAAI,OAAO,OAAO,GAAG,oBAAoB,WAAW,MAAM,KAAK;CAC/D,IAAI,OAAO,OAAO,GAAG,UAAU,WAAW,IAAI,KAAK;CACnD,IAAI,OAAO,OAAO,GAAG,sCAAsC,KAAK;CAChE,IAAI,OAAO,OAAO,GAAG,KAAK,WAA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/candidates.ts","../src/native/unc.ts","../src/native/attributes.ts","../src/search/hidden.ts","../src/search/traversal.ts","../src/search/policy.ts","../src/validation/eligibility.ts","../src/validation/existence.ts","../src/validation/containment.ts","../src/validation/preparation.ts","../src/validation/resolution.ts","../src/search/inventory.ts","../src/index.ts"],"sourcesContent":["import type { SearchSettings } from \"../src/types.js\";\n\nexport const settings: SearchSettings = {\n batchValidationThreshold: 48,\n directoryScanThreshold: 2,\n ignoreFileNames: [\".ignore\", \".rgignore\"],\n locationSuffixPattern: /:(?<line>\\d+)(?::(?<column>\\d+))?$/u,\n respectIgnoreByDefault: true,\n searchHiddenByDefault: false,\n spanWordLimits: [3, 24],\n trailingPunctuation: \".,;:!?,。;:!?、\",\n validationConcurrency: 32,\n};\n","import type { Variables } from \"./types.js\";\n\nconst nameSource = String.raw`[A-Za-z_][A-Za-z0-9_.-]*`;\nexport const variableReferenceSource = String.raw`(?:\\$\\{\\{\\s*(?:(?:env|vars|variables)[.:])?${nameSource}\\s*\\}\\}|\\{\\{\\s*${nameSource}\\s*\\}\\}|\\$\\{(?:env[.:])?${nameSource}\\}|\\$env:${nameSource}|\\$[A-Za-z_][A-Za-z0-9_]*|%${nameSource}%|!${nameSource}!|\\$\\(\\s*${nameSource}\\s*\\)|@${nameSource}@)`;\nconst expressionPatterns = [\n new RegExp(String.raw`\\$\\{\\{\\s*(?:(?:env|vars|variables)[.:])?(${nameSource})\\s*\\}\\}`, \"giu\"),\n new RegExp(String.raw`\\{\\{\\s*(${nameSource})\\s*\\}\\}`, \"gu\"),\n new RegExp(String.raw`\\$\\{(?:env[.:])?(${nameSource})\\}`, \"giu\"),\n new RegExp(String.raw`\\$env:(${nameSource})`, \"giu\"),\n new RegExp(String.raw`\\$(?!env:)([A-Za-z_][A-Za-z0-9_]*)`, \"giu\"),\n new RegExp(String.raw`%(${nameSource})%`, \"gu\"),\n new RegExp(String.raw`!(${nameSource})!`, \"gu\"),\n new RegExp(String.raw`\\$\\(\\s*(${nameSource})\\s*\\)`, \"gu\"),\n new RegExp(String.raw`@(${nameSource})@`, \"gu\"),\n];\nfunction resolveVariable(name: string, variables: Variables): string | undefined {\n const direct = variables[name] ?? process.env[name];\n if (direct !== undefined) {\n return direct;\n }\n const unscoped = /^(?:env|vars|variables)[.:](.+)$/iu.exec(name)?.[1];\n return unscoped === undefined ? undefined : (variables[unscoped] ?? process.env[unscoped]);\n}\nexport function expandVariables(value: string, variables: Variables): string {\n let result = value;\n for (const pattern of expressionPatterns) {\n result = result.replace(pattern, (match, name: string) => {\n const replacement = resolveVariable(name, variables);\n return replacement === undefined ? match : replacement;\n });\n }\n return result;\n}\n","import type { Candidate, SearchLevel } from \"./types.js\";\nimport { settings } from \"../config/settings.js\";\nimport { variableReferenceSource } from \"./variables.js\";\n\nconst explicitPattern =\n /(?:file:\\/\\/\\/?|[A-Za-z]:[\\\\/]|\\\\\\\\|\\/|(?:\\.{1,2}|~)[\\\\/])[^\"'`<>()[\\]{}\\s]+/gu,\n quotedPattern = /([\"'`])(?<value>[^\"'`\\r\\n]+)\\1/gu,\n tokenPattern = /[^\\s]+/gu,\n pathTokenPattern =\n /(?:(?:[\\p{L}\\p{N}_@%$+~.#[\\],-]+[\\\\/])+(?:[\\p{L}\\p{N}_@%$+~.#[\\],-]+)|[\\p{L}\\p{N}_@%$+~.#[\\],-]+\\.[\\p{L}\\p{N}_@%$-]{1,16})(?::\\d+){0,2}/gu,\n unquotedPathCharacterSource = \"[^\\\"'`<>()[\\\\]{}\\\\s]\",\n variablePathPattern = new RegExp(\n `${variableReferenceSource}(?:[\\\\\\\\/]${unquotedPathCharacterSource}+)+`,\n \"giu\",\n ),\n clausePattern = /[^\\r\\n!?!?;;。]+/gu,\n pathHintPattern =\n /[\\\\/]|(?:^|[\\s\"'`])(?:\\.{1,2}|~|%[A-Za-z_][A-Za-z0-9_]*%|\\$\\{?[A-Za-z_][A-Za-z0-9_]*\\}?)(?:[\\\\/]|$)|\\.[\\p{L}\\p{N}]{1,16}(?::\\d+){0,2}(?:$|[\\s,.;:!?,。;:!?、])/u,\n variableHintPattern = new RegExp(String.raw`${variableReferenceSource}(?:[\\\\/]|$)`, \"iu\");\nfunction add(\n result: Candidate[],\n seen: Set<string>,\n value: string,\n start: number,\n end: number,\n kind: Candidate[\"kind\"],\n): void {\n if (value.length === 0 || value === \"/\") {\n return;\n }\n const key = `${start}:${end}:${value}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push({ end, kind, start, value });\n }\n}\nfunction addMatches(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n pattern: RegExp,\n kind: Candidate[\"kind\"],\n): void {\n for (const match of text.matchAll(pattern)) {\n const value = match[0],\n start = match.index ?? 0;\n add(result, seen, value, start, start + value.length, kind);\n }\n}\nfunction addQuotedMatches(result: Candidate[], seen: Set<string>, text: string): void {\n for (const match of text.matchAll(quotedPattern)) {\n const value = match.groups?.value;\n if (value === undefined) {\n continue;\n }\n const start = (match.index ?? 0) + match[0].indexOf(value);\n add(result, seen, value, start, start + value.length, \"quoted\");\n }\n}\nfunction addSpanMatches(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n maximumWords: number,\n): void {\n for (const clause of text.matchAll(clausePattern)) {\n const clauseStart = clause.index ?? 0,\n clauseText = clause[0],\n tokens = [...clauseText.matchAll(tokenPattern)].map((token) => ({\n end: clauseStart + (token.index ?? 0) + token[0].length,\n hint: Number(pathHintPattern.test(token[0]) || variableHintPattern.test(token[0])),\n start: clauseStart + (token.index ?? 0),\n value: token[0],\n })),\n hintCounts = [0];\n for (const token of tokens) {\n hintCounts.push((hintCounts.at(-1) ?? 0) + token.hint);\n }\n for (let start = 0; start < tokens.length; start += 1) {\n const last = Math.min(tokens.length, start + maximumWords);\n for (let end = start + 1; end <= last; end += 1) {\n const firstToken = tokens[start],\n lastToken = tokens[end - 1],\n hintsBefore = hintCounts[start],\n hintsAfter = hintCounts[end];\n if (\n firstToken === undefined ||\n lastToken === undefined ||\n hintsBefore === undefined ||\n hintsAfter === undefined ||\n hintsBefore === hintsAfter\n ) {\n continue;\n }\n const value = text.slice(firstToken.start, lastToken.end);\n if (pathHintPattern.test(value)) {\n add(result, seen, value, firstToken.start, lastToken.end, \"span\");\n }\n }\n }\n }\n}\nexport function extractCandidates(text: string, level: SearchLevel): Candidate[] {\n const result: Candidate[] = [],\n seen = new Set<string>();\n addQuotedMatches(result, seen, text);\n addMatches(result, seen, text, explicitPattern, \"explicit\");\n if (level >= 2) {\n addMatches(result, seen, text, variablePathPattern, \"heuristic\");\n addMatches(result, seen, text, pathTokenPattern, \"heuristic\");\n }\n if (level >= 3) {\n const maximumWords =\n settings.spanWordLimits[Math.min(level - 3, settings.spanWordLimits.length - 1)];\n if (maximumWords === undefined) {\n throw new RangeError(\"No text-span level is configured\");\n }\n addSpanMatches(result, seen, text, maximumWords);\n }\n return result;\n}\n","import { isIP } from \"node:net\";\nimport { hostname, networkInterfaces } from \"node:os\";\nimport nodePath from \"node:path\";\nimport nativeBridge from \"./windows-bridge.cjs\";\n\nconst native = process.platform === \"win32\" ? nativeBridge : undefined,\n uncServerSegmentPattern = /^[^\\\\/:*?\"<>|]+$/u,\n unmappedDriveErrors = new Set([1200, 1201, 1203, 1222, 2250]),\n errorMoreData = 234,\n mappingBufferChars = 32_768;\ninterface UncPath {\n canonical: string;\n server: string;\n share: string;\n suffix: string;\n}\ninterface DriveMapping {\n drive: string;\n remote: string;\n}\nfunction normalizeServerName(value: string): string {\n return value.replace(/\\.+$/u, \"\").toLowerCase();\n}\nfunction addLocalServerName(names: Set<string>, value: string | undefined): void {\n if (value !== undefined && uncServerSegmentPattern.test(value)) {\n names.add(normalizeServerName(value));\n }\n}\nfunction addIpv6LiteralName(names: Set<string>, value: string): void {\n const zoneIndex = value.indexOf(\"%\"),\n address = zoneIndex === -1 ? value : value.slice(0, zoneIndex),\n zone = zoneIndex === -1 ? \"\" : `s${value.slice(zoneIndex + 1)}`;\n addLocalServerName(names, `${address.replaceAll(\":\", \"-\")}${zone}.ipv6-literal.net`);\n}\nfunction collectLocalServerNames(): Set<string> {\n const names = new Set<string>([\"localhost\"]),\n computerName = process.env.COMPUTERNAME;\n addLocalServerName(names, hostname());\n addLocalServerName(names, computerName);\n if (computerName !== undefined && process.env.USERDNSDOMAIN !== undefined) {\n addLocalServerName(names, `${computerName}.${process.env.USERDNSDOMAIN}`);\n }\n for (const addresses of Object.values(networkInterfaces())) {\n for (const address of addresses ?? []) {\n if (isIP(address.address) === 4) {\n addLocalServerName(names, address.address);\n } else if (isIP(address.address) === 6) {\n addIpv6LiteralName(names, address.address);\n }\n }\n }\n addLocalServerName(names, \"--1.ipv6-literal.net\");\n return names;\n}\nconst localServerNames =\n process.platform === \"win32\" ? collectLocalServerNames() : new Set<string>();\nlet driveMappings: DriveMapping[] | undefined;\nfunction containsControlCharacter(value: string): boolean {\n for (const character of value) {\n if (character.charCodeAt(0) < 32) {\n return true;\n }\n }\n return false;\n}\nfunction normalizeUncRoot(value: string): string {\n return value.replaceAll(\"/\", \"\\\\\").replace(/\\\\+$/u, \"\").toLowerCase();\n}\nfunction parseUncPath(value: string): UncPath | undefined {\n const normalized = value.replaceAll(\"/\", \"\\\\\"),\n extended = normalized.slice(0, 8).toLowerCase() === \"\\\\\\\\?\\\\unc\\\\\";\n if (normalized.startsWith(\"\\\\\\\\.\\\\\") || (normalized.startsWith(\"\\\\\\\\?\\\\\") && !extended)) {\n return undefined;\n }\n const serverStart = extended ? 8 : 2,\n serverSeparator = normalized.slice(serverStart).indexOf(\"\\\\\");\n if (serverSeparator <= 0) {\n return undefined;\n }\n const serverEnd = serverStart + serverSeparator,\n shareStart = serverEnd + 1,\n shareSeparator = normalized.slice(shareStart).indexOf(\"\\\\\"),\n shareEnd = shareSeparator === -1 ? normalized.length : shareStart + shareSeparator,\n server = normalized.slice(serverStart, serverEnd),\n share = normalized.slice(shareStart, shareEnd);\n if (\n share.length === 0 ||\n !uncServerSegmentPattern.test(server) ||\n !uncServerSegmentPattern.test(share)\n ) {\n return undefined;\n }\n const suffix = normalized.slice(shareEnd);\n return {\n canonical: `\\\\\\\\${server}\\\\${share}${suffix}`,\n server,\n share,\n suffix,\n };\n}\nfunction queryDriveMapping(drive: string): string | undefined {\n if (native === undefined) {\n return undefined;\n }\n const { remote, status } = native.getDriveConnection(drive, mappingBufferChars);\n if (status === errorMoreData) {\n throw new Error(`WNetGetConnectionW returned an oversized mapping for ${drive}`);\n }\n if (unmappedDriveErrors.has(status)) {\n return undefined;\n }\n if (status !== 0) {\n throw new Error(`WNetGetConnectionW failed for ${drive} with error ${status}`);\n }\n if (typeof remote !== \"string\" || !remote.startsWith(String.raw`\\\\`)) {\n throw new TypeError(`WNetGetConnectionW returned an invalid mapping for ${drive}`);\n }\n return normalizeUncRoot(remote);\n}\nfunction queryDriveMappings(): DriveMapping[] {\n if (driveMappings !== undefined) {\n return driveMappings;\n }\n const result: DriveMapping[] = [];\n for (let code = \"A\".charCodeAt(0); code <= \"Z\".charCodeAt(0); code += 1) {\n const drive = `${String.fromCharCode(code)}:`,\n remote = queryDriveMapping(drive);\n if (remote !== undefined) {\n result.push({ drive, remote });\n }\n }\n driveMappings = result.toSorted((left, right) => right.remote.length - left.remote.length);\n return driveMappings;\n}\nfunction resolveMappedUncPath(path: UncPath): string | undefined {\n const canonical = normalizeUncRoot(path.canonical),\n mapping = queryDriveMappings().find(\n ({ remote }) => canonical === remote || canonical.startsWith(`${remote}\\\\`),\n );\n if (mapping === undefined) {\n return undefined;\n }\n const relative = path.canonical.slice(mapping.remote.length);\n return nodePath.win32.normalize(`${mapping.drive}${relative}`);\n}\nfunction isLocalServer(value: string): boolean {\n const normalized = normalizeServerName(value);\n return (\n localServerNames.has(normalized) ||\n (isIP(value) === 4 && value.split(\".\")[0] === \"127\") ||\n normalized === \"--1.ipv6-literal.net\"\n );\n}\nfunction resolveLocalAdministrativeShare(path: UncPath): string | undefined {\n const match = /^([A-Za-z])\\$$/u.exec(path.share);\n if (match === null || !isLocalServer(path.server)) {\n return undefined;\n }\n return nodePath.win32.normalize(`${match[1]}:${path.suffix || \"\\\\\"}`);\n}\nexport function resolveUncPath(value: string): string | undefined {\n if (\n process.platform !== \"win32\" ||\n (!value.startsWith(String.raw`\\\\`) && !value.startsWith(\"//\"))\n ) {\n return value;\n }\n if (containsControlCharacter(value)) {\n return undefined;\n }\n const path = parseUncPath(value);\n if (path === undefined) {\n return undefined;\n }\n return resolveMappedUncPath(path) ?? resolveLocalAdministrativeShare(path);\n}\n","import nodePath from \"node:path\";\nimport nativeBridge from \"./windows-bridge.cjs\";\n\nconst fileAttributeHidden = 0x2,\n invalidFileAttributes = 0xff_ff_ff_ff;\nconst missingPathErrors = new Set([2, 3]);\nexport function hasWindowsHiddenAttribute(filePath: string): boolean {\n if (process.platform !== \"win32\") {\n throw new Error(\"Windows file attributes are unavailable on this platform\");\n }\n const { attributes, error } = nativeBridge.getFileAttributes(nodePath.toNamespacedPath(filePath));\n if (!Number.isInteger(attributes) || !Number.isInteger(error)) {\n throw new TypeError(\"Windows file attribute lookup returned an invalid result\");\n }\n if (attributes !== invalidFileAttributes) {\n if (error !== 0) {\n throw new Error(`Windows file attribute lookup returned attributes with error ${error}`);\n }\n return (attributes & fileAttributeHidden) !== 0;\n }\n if (missingPathErrors.has(error)) {\n return false;\n }\n throw new Error(`Windows file attribute lookup failed for ${filePath} with error ${error}`);\n}\n","import nodePath from \"node:path\";\nimport { hasWindowsHiddenAttribute } from \"../native/attributes.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction relativePath(filePath: string, boundary: string): string {\n const relative = nodePath.relative(boundary, filePath);\n if (\n nodePath.isAbsolute(relative) ||\n relative === \"..\" ||\n relative.startsWith(`..${nodePath.sep}`)\n ) {\n throw new RangeError(`${filePath} is outside the hidden-path boundary ${boundary}`);\n }\n return relative;\n}\nfunction hasHiddenDotSegment(filePath: string, boundary: string): boolean {\n return relativePath(filePath, boundary)\n .split(/[\\\\/]/u)\n .some((part) => part.length > 1 && part.startsWith(\".\"));\n}\nexport function createHiddenPathDetector() {\n const attributeCache = new Map<string, boolean>();\n return {\n isHidden(filePath: string, boundary: string): boolean {\n if (process.platform !== \"win32\") {\n return hasHiddenDotSegment(filePath, boundary);\n }\n relativePath(filePath, boundary);\n const boundaryKey = pathKey(nodePath.resolve(boundary));\n let current = nodePath.resolve(filePath);\n while (pathKey(current) !== boundaryKey) {\n const key = pathKey(current);\n let hidden = attributeCache.get(key);\n if (hidden === undefined) {\n hidden = hasWindowsHiddenAttribute(current);\n attributeCache.set(key, hidden);\n }\n if (hidden) {\n return true;\n }\n const parent = nodePath.dirname(current);\n if (parent === current) {\n throw new Error(`Unable to reach hidden-path boundary ${boundary} from ${filePath}`);\n }\n current = parent;\n }\n return false;\n },\n };\n}\n","import nodeFileSystem from \"node:fs\";\nimport nodePath from \"node:path\";\nimport type { Options as GlobbyOptions } from \"globby\";\nimport { createHiddenPathDetector } from \"./hidden.js\";\n\ntype ReadDirectory = NonNullable<NonNullable<GlobbyOptions[\"fs\"]>[\"readdir\"]>;\nconst unreadableDirectoryErrors = new Set([\"EACCES\", \"ENOTDIR\", \"ENOENT\", \"EPERM\"]);\ninterface DirectoryEntry {\n isBlockDevice(): boolean;\n isCharacterDevice(): boolean;\n isDirectory(): boolean;\n isFIFO(): boolean;\n isFile(): boolean;\n isSocket(): boolean;\n isSymbolicLink(): boolean;\n name: string;\n}\ntype DirectoryEntryCallback = (\n error: NodeJS.ErrnoException | null,\n entries: DirectoryEntry[],\n) => void;\ntype DirectoryNameCallback = (error: NodeJS.ErrnoException | null, entries: string[]) => void;\ninterface TraversalScope {\n paths: readonly string[];\n passthroughNames: readonly string[];\n}\ninterface TraversalFileSystemOptions {\n readDirectory?: ReadDirectory;\n scope?: TraversalScope;\n}\ninterface IndexedScope {\n childrenByDirectory: ReadonlyMap<string, ReadonlySet<string>>;\n passthroughNames: ReadonlySet<string>;\n}\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isUnreadableDirectoryError(error: NodeJS.ErrnoException): boolean {\n return error.code !== undefined && unreadableDirectoryErrors.has(error.code);\n}\nfunction completeDirectoryRead<T>(\n error: NodeJS.ErrnoException | null,\n entries: T[],\n callback: (error: NodeJS.ErrnoException | null, entries: T[]) => void,\n): void {\n if (error === null) {\n callback(null, entries);\n } else if (isUnreadableDirectoryError(error)) {\n callback(null, []);\n } else {\n callback(error, []);\n }\n}\nfunction indexScope(root: string, scope: TraversalScope | undefined): IndexedScope | undefined {\n if (scope === undefined) {\n return undefined;\n }\n const resolvedRoot = nodePath.resolve(root),\n childrenByDirectory = new Map<string, Set<string>>();\n for (const relativePath of scope.paths) {\n if (\n nodePath.isAbsolute(relativePath) ||\n relativePath === \"..\" ||\n relativePath.startsWith(`..${nodePath.sep}`)\n ) {\n throw new RangeError(`${relativePath} is outside the traversal root ${root}`);\n }\n let directory = resolvedRoot;\n for (const name of relativePath.split(nodePath.sep)) {\n const directoryKey = pathKey(directory),\n children = childrenByDirectory.get(directoryKey) ?? new Set<string>();\n children.add(pathKey(name));\n childrenByDirectory.set(directoryKey, children);\n directory = nodePath.join(directory, name);\n }\n }\n return {\n childrenByDirectory,\n passthroughNames: new Set(scope.passthroughNames.map(pathKey)),\n };\n}\nfunction filterToScope<T extends DirectoryEntry | string>(\n filePath: string,\n entries: T[],\n scope: IndexedScope | undefined,\n): T[] {\n if (scope === undefined) {\n return entries;\n }\n const children = scope.childrenByDirectory.get(pathKey(nodePath.resolve(filePath)));\n if (children === undefined) {\n return [];\n }\n return entries.filter((entry) => {\n const name = typeof entry === \"string\" ? entry : entry.name,\n key = pathKey(name);\n return children.has(key) || scope.passthroughNames.has(key);\n });\n}\nfunction completeTraversalRead<T extends DirectoryEntry | string>(\n root: string,\n filePath: string,\n searchHidden: boolean,\n hiddenDetector: ReturnType<typeof createHiddenPathDetector>,\n scope: IndexedScope | undefined,\n error: NodeJS.ErrnoException | null,\n entries: T[],\n callback: (error: NodeJS.ErrnoException | null, entries: T[]) => void,\n): void {\n const scopedEntries = error === null ? filterToScope(filePath, entries, scope) : entries;\n if (error !== null || searchHidden) {\n completeDirectoryRead(error, scopedEntries, callback);\n return;\n }\n try {\n const visibleEntries = scopedEntries.filter((entry) => {\n if (typeof entry !== \"string\" && !entry.isDirectory()) {\n return true;\n }\n const name = typeof entry === \"string\" ? entry : entry.name;\n return !hiddenDetector.isHidden(nodePath.join(filePath, name), root);\n });\n callback(null, visibleEntries);\n } catch (caughtError) {\n callback(caughtError instanceof Error ? caughtError : new Error(String(caughtError)), []);\n }\n}\nfunction createReadDirectory(\n root: string,\n searchHidden: boolean,\n readDirectory: ReadDirectory,\n scope: IndexedScope | undefined,\n): ReadDirectory {\n const hiddenDetector = createHiddenPathDetector();\n function traverseReadDirectory(\n filePath: string,\n options: { withFileTypes: true },\n callback: DirectoryEntryCallback,\n ): void;\n function traverseReadDirectory(filePath: string, callback: DirectoryNameCallback): void;\n function traverseReadDirectory(\n filePath: string,\n optionsOrCallback: { withFileTypes: true } | DirectoryNameCallback,\n entryCallback?: DirectoryEntryCallback,\n ): void {\n if (typeof optionsOrCallback === \"function\") {\n readDirectory(filePath, (error, entries) => {\n completeTraversalRead(\n root,\n filePath,\n searchHidden,\n hiddenDetector,\n scope,\n error,\n entries,\n optionsOrCallback,\n );\n });\n return;\n }\n if (entryCallback === undefined) {\n throw new TypeError(\"A directory entry callback is required\");\n }\n readDirectory(filePath, optionsOrCallback, (error, entries) => {\n completeTraversalRead(\n root,\n filePath,\n searchHidden,\n hiddenDetector,\n scope,\n error,\n entries,\n entryCallback,\n );\n });\n }\n return traverseReadDirectory;\n}\nexport function createTraversalFileSystem(\n root: string,\n searchHidden: boolean,\n options: TraversalFileSystemOptions = {},\n) {\n const { readDirectory = nodeFileSystem.readdir, scope } = options;\n return {\n ...nodeFileSystem,\n readdir: createReadDirectory(root, searchHidden, readDirectory, indexScope(root, scope)),\n };\n}\n","import { stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport { convertPathToPattern, globby } from \"globby\";\nimport isPathInside from \"is-path-inside\";\nimport { settings } from \"../../config/settings.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport type { SearchEntry } from \"../types.js\";\nimport { createHiddenPathDetector } from \"./hidden.js\";\nimport { createTraversalFileSystem } from \"./traversal.js\";\n\nconst ignoreFilePatterns = settings.ignoreFileNames.map(\n (name) => `**/${convertPathToPattern(name)}`,\n ),\n ignoreFileNames = [\".gitignore\", ...settings.ignoreFileNames];\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isWithinRoot(filePath: string, root: string): boolean {\n return filePath === root || isPathInside(filePath, root);\n}\nfunction traversalOptions(\n root: string,\n searchHidden: boolean,\n scopedPaths: readonly string[] | undefined,\n) {\n const fileSystem =\n scopedPaths === undefined\n ? createTraversalFileSystem(root, searchHidden)\n : createTraversalFileSystem(root, searchHidden, {\n scope: {\n passthroughNames: ignoreFileNames,\n paths: scopedPaths,\n },\n });\n return {\n caseSensitiveMatch: process.platform !== \"win32\",\n cwd: root,\n dot: process.platform === \"win32\" || searchHidden,\n followSymbolicLinks: false,\n fs: fileSystem,\n onlyFiles: false,\n unique: true,\n } as const;\n}\nfunction globbyOptions(\n root: string,\n respectIgnore: boolean,\n searchHidden: boolean,\n scopedPaths?: readonly string[],\n) {\n return {\n ...traversalOptions(root, searchHidden, scopedPaths),\n expandDirectories: false,\n gitignore: respectIgnore,\n globalGitignore: respectIgnore,\n ...(respectIgnore ? { ignoreFiles: ignoreFilePatterns } : {}),\n } as const;\n}\nexport async function resolveSearchDirectories(directories: readonly string[]): Promise<string[]> {\n if (!Array.isArray(directories)) {\n throw new TypeError(\"directories must be an array\");\n }\n if (directories.length === 0) {\n throw new RangeError(\"directories must not be empty\");\n }\n const unique = new Map<string, string>();\n for (const directory of directories) {\n if (typeof directory !== \"string\" || directory.length === 0) {\n throw new TypeError(\"every directory must be a non-empty string\");\n }\n const resolvedUnc = resolveUncPath(directory);\n if (resolvedUnc === undefined || resolvedUnc.length === 0) {\n throw new TypeError(`${directory} cannot be represented as a drive-based path`);\n }\n const resolved = nodePath.resolve(resolvedUnc);\n unique.set(pathKey(resolved), resolved);\n }\n await Promise.all(\n [...unique.values()].map(async (directory) => {\n if (!(await stat(directory)).isDirectory()) {\n throw new TypeError(`${directory} is not a directory`);\n }\n }),\n );\n return [...unique.values()];\n}\nexport async function listSearchEntries(\n root: string,\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<SearchEntry[]> {\n const entries = await globby(\"**/*\", {\n ...globbyOptions(root, respectIgnore, searchHidden),\n objectMode: true,\n }),\n hiddenDetector = createHiddenPathDetector();\n return entries\n .filter(\n (entry) => searchHidden || !hiddenDetector.isHidden(nodePath.resolve(root, entry.path), root),\n )\n .map((entry) => ({\n directory: entry.dirent.isDirectory(),\n path: entry.path,\n }));\n}\nexport async function filterSearchablePaths(\n paths: readonly string[],\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Set<string>> {\n const allowed = new Set<string>(),\n pathsByRoot = new Map<string, string[]>(),\n hiddenDetector = createHiddenPathDetector();\n for (const filePath of paths) {\n let hasSearchRoot = false;\n for (const root of roots) {\n if (!isWithinRoot(filePath, root)) {\n continue;\n }\n hasSearchRoot = true;\n const relative = nodePath.relative(root, filePath);\n if (!searchHidden && hiddenDetector.isHidden(filePath, root)) {\n continue;\n }\n if (relative === \"\" || !respectIgnore) {\n allowed.add(filePath);\n } else {\n const grouped = pathsByRoot.get(root) ?? [];\n grouped.push(relative);\n pathsByRoot.set(root, grouped);\n }\n }\n if (hasSearchRoot) {\n continue;\n }\n const filesystemRoot = nodePath.parse(filePath).root,\n hiddenBoundary = process.platform === \"win32\" ? nodePath.dirname(filePath) : filesystemRoot;\n if (searchHidden || !hiddenDetector.isHidden(filePath, hiddenBoundary)) {\n allowed.add(filePath);\n }\n }\n await Promise.all(\n [...pathsByRoot].map(async ([root, relativePaths]) => {\n const patterns = relativePaths.map(convertPathToPattern),\n matches = await globby(patterns, {\n ...globbyOptions(root, true, true, relativePaths),\n absolute: true,\n });\n for (const match of matches) {\n allowed.add(nodePath.normalize(match));\n }\n }),\n );\n return allowed;\n}\n","import { filterSearchablePaths } from \"../search/policy.js\";\nimport type { PathKind } from \"../types.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nexport async function applySearchPolicies(\n existingPaths: ReadonlyMap<string, PathKind>,\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Map<string, PathKind>> {\n if (!respectIgnore && searchHidden) {\n return new Map(existingPaths);\n }\n const searchablePaths = await filterSearchablePaths(\n [...existingPaths.keys()],\n roots,\n respectIgnore,\n searchHidden,\n ),\n searchableKeys = new Set([...searchablePaths].map(pathKey));\n return new Map([...existingPaths].filter(([filePath]) => searchableKeys.has(pathKey(filePath))));\n}\n","import { readdir, stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport pLimit from \"p-limit\";\nimport { settings } from \"../../config/settings.js\";\nimport type { PathKind } from \"../types.js\";\n\nconst unavailablePathErrors = new Set([\n \"EACCES\",\n \"ELOOP\",\n \"ENAMETOOLONG\",\n \"ENOTDIR\",\n \"ENOENT\",\n \"EPERM\",\n \"EINVAL\",\n ]),\n unverifiableUncErrors = new Set([\"UNKNOWN\", \"EUNKNOWN\"]);\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isUnavailablePathError(error: unknown, filePath?: string): boolean {\n const code =\n error instanceof Error && \"code\" in error && typeof error.code === \"string\"\n ? error.code\n : undefined;\n return (\n code !== undefined &&\n (unavailablePathErrors.has(code) ||\n (filePath?.startsWith(String.raw`\\\\`) === true && unverifiableUncErrors.has(code)))\n );\n}\nasync function classifyPath(filePath: string): Promise<PathKind | undefined> {\n try {\n const pathStats = await stat(filePath);\n if (pathStats.isFile()) {\n return \"file\";\n }\n return pathStats.isDirectory() ? \"directory\" : undefined;\n } catch (error) {\n if (isUnavailablePathError(error, filePath)) {\n return undefined;\n }\n throw error;\n }\n}\nasync function classifyAndAdd(found: Map<string, PathKind>, filePath: string): Promise<void> {\n const kind = await classifyPath(filePath);\n if (kind !== undefined) {\n found.set(filePath, kind);\n }\n}\nexport async function classifyExistingPaths(\n paths: readonly string[],\n roots: readonly string[],\n): Promise<Map<string, PathKind>> {\n const found = new Map<string, PathKind>(),\n limit = pLimit(settings.validationConcurrency);\n if (paths.length < settings.batchValidationThreshold) {\n await limit.map(paths, (filePath) => classifyAndAdd(found, filePath));\n return found;\n }\n const rootKeys = new Set(roots.map(pathKey)),\n pathsByParent = new Map<string, { parent: string; paths: string[] }>();\n for (const filePath of paths) {\n if (rootKeys.has(pathKey(filePath))) {\n found.set(filePath, \"directory\");\n continue;\n }\n const parent = nodePath.dirname(filePath),\n key = pathKey(parent),\n group = pathsByParent.get(key) ?? { parent, paths: [] };\n group.paths.push(filePath);\n pathsByParent.set(key, group);\n }\n const directPaths: string[] = [],\n scannedGroups: { parent: string; paths: string[] }[] = [];\n for (const group of pathsByParent.values()) {\n if (group.paths.length < settings.directoryScanThreshold) {\n directPaths.push(...group.paths);\n } else {\n scannedGroups.push(group);\n }\n }\n await Promise.all([\n limit.map(directPaths, (filePath) => classifyAndAdd(found, filePath)),\n limit.map(scannedGroups, async ({ parent, paths: groupPaths }) => {\n let entries;\n try {\n entries = await readdir(parent, { withFileTypes: true });\n } catch (error) {\n if (isUnavailablePathError(error, parent)) {\n return;\n }\n throw error;\n }\n const entriesByName = new Map(entries.map((entry) => [pathKey(entry.name), entry]));\n await Promise.all(\n groupPaths.map(async (filePath) => {\n const name = nodePath.basename(filePath),\n entry = entriesByName.get(pathKey(name));\n if (entry?.isFile()) {\n found.set(filePath, \"file\");\n } else if (entry?.isDirectory()) {\n found.set(filePath, \"directory\");\n } else if (entry !== undefined || (process.platform === \"win32\" && name.includes(\":\"))) {\n await classifyAndAdd(found, filePath);\n }\n }),\n );\n }),\n ]);\n return found;\n}\n","import type { PathMatch } from \"../types.js\";\n\nexport function removeContainedMatches(matches: readonly PathMatch[]): PathMatch[] {\n const ordered = matches\n .map((match, index) => ({ index, match }))\n .toSorted(\n ({ match: left }, { match: right }) =>\n left.position.start - right.position.start || right.position.end - left.position.end,\n ),\n kept = new Set<number>();\n let maxEndBeforeStart = -1,\n groupStart = -1,\n maxEndInGroup = -1;\n for (const { index, match } of ordered) {\n const { start, end } = match.position;\n if (start !== groupStart) {\n maxEndBeforeStart = Math.max(maxEndBeforeStart, maxEndInGroup);\n groupStart = start;\n maxEndInGroup = -1;\n }\n if (maxEndBeforeStart < end && maxEndInGroup <= end) {\n kept.add(index);\n }\n maxEndInGroup = Math.max(maxEndInGroup, end);\n }\n return matches.filter((_, index) => kept.has(index));\n}\n","import { settings } from \"../../config/settings.js\";\nimport type { Candidate, PathLocation, PathPosition } from \"../types.js\";\n\nexport interface PreparedCandidate {\n location?: PathLocation;\n position: PathPosition;\n value: string;\n}\nfunction parseLocationPart(value: string, name: string): number {\n const result = Number(value);\n if (!Number.isSafeInteger(result)) {\n throw new RangeError(`${name} must be a safe integer`);\n }\n return result;\n}\nexport function prepareCandidate(candidate: Candidate): PreparedCandidate | undefined {\n let { end } = candidate,\n { start } = candidate,\n { value } = candidate;\n if (candidate.kind !== \"inventory\" && candidate.kind !== \"quoted\") {\n const startTrimmed = value.trimStart();\n start += value.length - startTrimmed.length;\n value = startTrimmed;\n const endTrimmed = value.trimEnd();\n end -= value.length - endTrimmed.length;\n value = endTrimmed;\n if (\n value.length >= 2 &&\n ((value.startsWith('\"') && value.at(-1) === '\"') ||\n (value.startsWith(\"'\") && value.at(-1) === \"'\") ||\n (value.startsWith(\"`\") && value.at(-1) === \"`\"))\n ) {\n start += 1;\n end -= 1;\n value = value.slice(1, -1);\n }\n while (value.length > 0 && settings.trailingPunctuation.includes(value.at(-1) ?? \"\")) {\n end -= 1;\n value = value.slice(0, -1);\n }\n }\n let location: PathLocation | undefined;\n if (candidate.kind !== \"inventory\") {\n const match = settings.locationSuffixPattern.exec(value);\n if (match !== null) {\n const lineValue = match.groups?.line;\n if (lineValue === undefined) {\n throw new TypeError(\"locationSuffixPattern must capture a line\");\n }\n const columnValue = match.groups?.column;\n location =\n columnValue === undefined\n ? { line: parseLocationPart(lineValue, \"line\") }\n : {\n column: parseLocationPart(columnValue, \"column\"),\n line: parseLocationPart(lineValue, \"line\"),\n };\n end -= match[0].length;\n value = value.slice(0, match.index);\n }\n }\n if (value === \"/\" || value === \".\") {\n return undefined;\n }\n return {\n ...(location === undefined ? {} : { location }),\n position: { end, start },\n value,\n };\n}\n","import { fileURLToPath } from \"node:url\";\nimport nodePath from \"node:path\";\nimport { applySearchPolicies } from \"./eligibility.js\";\nimport { classifyExistingPaths } from \"./existence.js\";\nimport { removeContainedMatches } from \"./containment.js\";\nimport { prepareCandidate } from \"./preparation.js\";\nimport { expandVariables } from \"../variables.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport type {\n Candidate,\n PathKind,\n PathLocation,\n PathMatch,\n PathPosition,\n Variables,\n} from \"../types.js\";\n\ninterface ResolvedCandidate {\n expectedKind?: PathKind;\n location?: PathLocation;\n path: string;\n position: PathPosition;\n}\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction uniquePaths(values: Iterable<string>): string[] {\n const paths = new Map<string, string>();\n for (const value of values) {\n paths.set(pathKey(value), value);\n }\n return [...paths.values()];\n}\nfunction unescape(value: string): string {\n if (value.startsWith(String.raw`\\\\`) && !value.startsWith(String.raw`\\\\\\\\`)) {\n return value;\n }\n return value.replace(/\\\\([\"'`\\\\])/gu, \"$1\").replace(/\\\\\\\\/gu, \"\\\\\");\n}\nfunction toPaths(value: string, roots: readonly string[], variables: Variables): string[] {\n let expanded = expandVariables(value, variables);\n if (expanded.includes(\"\\0\")) {\n return [];\n }\n if (expanded.startsWith(\"file://\")) {\n try {\n expanded = fileURLToPath(expanded);\n } catch (error) {\n if (error instanceof TypeError) {\n return [];\n }\n throw error;\n }\n } else {\n expanded = unescape(expanded);\n if (expanded === \"~\" || /^~[\\\\/]/u.test(expanded)) {\n expanded = nodePath.join(\n variables.HOME ??\n variables.USERPROFILE ??\n process.env.HOME ??\n process.env.USERPROFILE ??\n \"\",\n expanded.slice(2),\n );\n }\n }\n const resolvedPath = resolveUncPath(expanded);\n if (resolvedPath === undefined || resolvedPath.length === 0) {\n return [];\n }\n expanded = resolvedPath;\n if (nodePath.isAbsolute(expanded)) {\n return [nodePath.normalize(expanded)];\n }\n return uniquePaths(roots.map((root) => nodePath.resolve(root, expanded)));\n}\nfunction mergeLocation(match: PathMatch, location: PathLocation | undefined): void {\n if (location === undefined) {\n return;\n }\n if (match.location === undefined) {\n match.location = location;\n return;\n }\n if (match.location.line !== location.line || match.location.column !== location.column) {\n throw new Error(\"Candidates for the same path and position have conflicting locations\");\n }\n}\nexport async function validateCandidates(\n candidates: Candidate[],\n roots: readonly string[],\n variables: Variables,\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<PathMatch[]> {\n const resolvedCandidates: ResolvedCandidate[] = [],\n validationPaths = new Map<string, string>();\n for (const candidate of candidates) {\n const prepared = prepareCandidate(candidate);\n if (prepared === undefined) {\n continue;\n }\n const paths = toPaths(prepared.value, roots, variables);\n for (const filePath of paths) {\n resolvedCandidates.push({\n ...(candidate.expectedKind === undefined ? {} : { expectedKind: candidate.expectedKind }),\n ...(prepared.location === undefined ? {} : { location: prepared.location }),\n path: filePath,\n position: prepared.position,\n });\n validationPaths.set(pathKey(filePath), filePath);\n }\n }\n const classifiedPaths = await applySearchPolicies(\n await classifyExistingPaths([...validationPaths.values()], roots),\n roots,\n respectIgnore,\n searchHidden,\n ),\n kindsByPath = new Map(\n [...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind]),\n ),\n matches = new Map<string, PathMatch>();\n for (const { expectedKind, location, path, position } of resolvedCandidates) {\n const kind = kindsByPath.get(pathKey(path));\n if (kind === undefined || (expectedKind !== undefined && kind !== expectedKind)) {\n continue;\n }\n const key = `${pathKey(path)}\\0${position.start}\\0${position.end}`,\n existing = matches.get(key);\n if (existing !== undefined) {\n mergeLocation(existing, location);\n continue;\n }\n matches.set(key, {\n kind,\n ...(location === undefined ? {} : { location }),\n path,\n position,\n });\n }\n return removeContainedMatches([...matches.values()]);\n}\n","import nodePath from \"node:path\";\nimport { AhoCorasick } from \"@monyone/aho-corasick\";\nimport { listSearchEntries } from \"./policy.js\";\nimport type {\n Candidate,\n InventoryMatcher,\n InventoryPattern,\n RootPrefix,\n SearchEntry,\n} from \"../types.js\";\n\nlet inventoryMatcherCache: InventoryMatcher | undefined;\nfunction isBoundary(\n value: string | undefined,\n following: string | undefined,\n directoryEnd = false,\n): boolean {\n if (directoryEnd && value !== \".\") {\n return value === undefined || /[\\s\"'`<>)\\]},;:!?,。;:!?、]/u.test(value);\n }\n if (value === \".\") {\n return following === undefined || !/[\\p{L}\\p{N}_-]/u.test(following);\n }\n return value === undefined || !/[\\p{L}\\p{N}_/\\\\-]/u.test(value);\n}\nfunction addMatch(\n result: Candidate[],\n seen: Set<string>,\n text: string,\n value: string,\n start: number,\n end: number,\n expectedKind: InventoryPattern[\"expectedKind\"],\n): void {\n if (\n !isBoundary(text[start - 1], text[start]) ||\n !isBoundary(text[end], text[end + 1], expectedKind === \"directory\")\n ) {\n return;\n }\n const key = `${start}:${end}:${text.slice(start, end)}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push({ end, expectedKind, kind: \"inventory\", start, value });\n }\n}\nfunction addVariant(\n patterns: Map<string, InventoryPattern>,\n entry: SearchEntry,\n value: string,\n): void {\n const key = process.platform === \"win32\" ? value.toLowerCase() : value;\n if (!patterns.has(key)) {\n patterns.set(key, {\n expectedKind: entry.directory ? \"directory\" : \"file\",\n relative: entry.path,\n value,\n });\n }\n}\nfunction addEntryVariants(patterns: Map<string, InventoryPattern>, entry: SearchEntry): void {\n const native = entry.path.replaceAll(\"/\", nodePath.sep);\n if (entry.directory) {\n addVariant(patterns, entry, `${entry.path}/`);\n addVariant(patterns, entry, `${native}${nodePath.sep}`);\n return;\n }\n addVariant(patterns, entry, entry.path);\n addVariant(patterns, entry, native);\n}\nfunction createRootPrefixes(roots: readonly string[]): RootPrefix[] {\n const prefixes = new Map<string, RootPrefix>();\n for (const root of roots) {\n const native = root.endsWith(nodePath.sep) ? root : `${root}${nodePath.sep}`,\n slashRoot = root.replaceAll(nodePath.sep, \"/\"),\n slash = slashRoot.endsWith(\"/\") ? slashRoot : `${slashRoot}/`;\n for (const value of [native, slash]) {\n const key = process.platform === \"win32\" ? value.toLowerCase() : value;\n prefixes.set(key, { root, value: key });\n }\n }\n return [...prefixes.values()];\n}\nfunction addAbsoluteMatch(\n result: Candidate[],\n seen: Set<string>,\n source: string,\n text: string,\n pattern: InventoryPattern,\n prefixes: readonly RootPrefix[],\n end: number,\n relativeStart: number,\n): boolean {\n for (const prefix of prefixes) {\n const start = relativeStart - prefix.value.length;\n if (start >= 0 && source.startsWith(prefix.value, start)) {\n addMatch(\n result,\n seen,\n text,\n nodePath.resolve(prefix.root, pattern.relative),\n start,\n end,\n pattern.expectedKind,\n );\n return true;\n }\n }\n return false;\n}\nfunction hasSameEntries(\n cached: InventoryMatcher,\n entries: readonly (readonly SearchEntry[])[],\n): boolean {\n if (cached.entries.length !== entries.length) {\n return false;\n }\n for (let index = 0; index < entries.length; index += 1) {\n const cachedEntries = cached.entries[index],\n currentEntries = entries[index];\n if (cachedEntries === undefined || currentEntries === undefined) {\n return false;\n }\n if (cachedEntries.length !== currentEntries.length) {\n return false;\n }\n for (let entryIndex = 0; entryIndex < currentEntries.length; entryIndex += 1) {\n const cachedEntry = cachedEntries[entryIndex],\n currentEntry = currentEntries[entryIndex];\n if (\n cachedEntry === undefined ||\n currentEntry === undefined ||\n cachedEntry.directory !== currentEntry.directory ||\n cachedEntry.path !== currentEntry.path\n ) {\n return false;\n }\n }\n }\n return true;\n}\nfunction canReuseMatcher(\n cached: InventoryMatcher | undefined,\n entries: readonly (readonly SearchEntry[])[],\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): cached is InventoryMatcher {\n return (\n cached?.respectIgnore === respectIgnore &&\n cached.searchHidden === searchHidden &&\n cached.roots.length === roots.length &&\n cached.roots.every((root, index) => root === roots[index]) &&\n hasSameEntries(cached, entries)\n );\n}\nexport async function inventoryCandidates(\n text: string,\n roots: readonly string[],\n respectIgnore: boolean,\n searchHidden: boolean,\n): Promise<Candidate[]> {\n const entries = await Promise.all(\n roots.map((root) => listSearchEntries(root, respectIgnore, searchHidden)),\n ),\n result: Candidate[] = [],\n seen = new Set<string>(),\n source = process.platform === \"win32\" ? text.toLowerCase() : text;\n let inventoryMatcher = inventoryMatcherCache;\n if (!canReuseMatcher(inventoryMatcher, entries, roots, respectIgnore, searchHidden)) {\n const patterns = new Map<string, InventoryPattern>();\n for (const relativeEntries of entries) {\n for (const entry of relativeEntries) {\n addEntryVariants(patterns, entry);\n }\n }\n inventoryMatcher = {\n entries,\n matcher: new AhoCorasick([...patterns.keys()]),\n patterns,\n prefixes: createRootPrefixes(roots),\n respectIgnore,\n roots: [...roots],\n searchHidden,\n };\n inventoryMatcherCache = inventoryMatcher;\n }\n for (const { begin, end, keyword } of inventoryMatcher.matcher.matchInText(source)) {\n const pattern = inventoryMatcher.patterns.get(keyword);\n if (pattern === undefined) {\n throw new Error(\"Inventory matcher returned an unknown path\");\n }\n if (\n !addAbsoluteMatch(result, seen, source, text, pattern, inventoryMatcher.prefixes, end, begin)\n ) {\n addMatch(result, seen, text, pattern.value, begin, end, pattern.expectedKind);\n }\n }\n return result;\n}\n","import { extractCandidates } from \"./candidates.js\";\nimport { validateCandidates } from \"./validation/resolution.js\";\nimport { inventoryCandidates } from \"./search/inventory.js\";\nimport { resolveSearchDirectories } from \"./search/policy.js\";\nimport { settings } from \"../config/settings.js\";\nimport type { FindExistingPathsOptions, PathMatch, Variables } from \"./types.js\";\n\nexport const MAX_LEVEL = settings.spanWordLimits.length + 3;\nfunction validateOptions(value: unknown): asserts value is FindExistingPathsOptions {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"options must be an object\");\n }\n}\nfunction validateVariables(value: unknown): asserts value is Variables {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n Object.values(value).some((item) => typeof item !== \"string\")\n ) {\n throw new TypeError(\"variables must be an object of string values\");\n }\n}\nexport async function findExistingPaths(options: FindExistingPathsOptions): Promise<PathMatch[]> {\n validateOptions(options);\n const {\n directories,\n level,\n respectIgnore = settings.respectIgnoreByDefault,\n searchHidden = settings.searchHiddenByDefault,\n text,\n variables = {},\n } = options;\n if (typeof text !== \"string\") {\n throw new TypeError(\"text must be a string\");\n }\n if (!Number.isInteger(level) || level < 1 || level > MAX_LEVEL) {\n throw new RangeError(`level must be an integer from 1 to ${MAX_LEVEL}`);\n }\n validateVariables(variables);\n if (typeof respectIgnore !== \"boolean\") {\n throw new TypeError(\"respectIgnore must be a boolean\");\n }\n if (typeof searchHidden !== \"boolean\") {\n throw new TypeError(\"searchHidden must be a boolean\");\n }\n const roots = await resolveSearchDirectories(directories),\n candidates = extractCandidates(text, level);\n if (level === MAX_LEVEL) {\n candidates.push(...(await inventoryCandidates(text, roots, respectIgnore, searchHidden)));\n }\n return validateCandidates(candidates, roots, variables, respectIgnore, searchHidden);\n}\nexport type {\n FindExistingPathsOptions,\n PathKind,\n PathLocation,\n PathMatch,\n PathPosition,\n SearchLevel,\n Variables,\n} from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;AAEA,MAAa,WAA2B;CACtC,0BAA0B;CAC1B,wBAAwB;CACxB,iBAAiB,CAAC,WAAW,WAAW;CACxC,uBAAuB;CACvB,wBAAwB;CACxB,uBAAuB;CACvB,gBAAgB,CAAC,GAAG,EAAE;CACtB,qBAAqB;CACrB,uBAAuB;AACzB;;;ACVA,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAa,0BAA0B,OAAO,GAAG,8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BAAkB,SAAS;CAC3B,IAAI,OAAO,kBAAkB,WAC3B,MAAM,IAAI,UAAU,iCAAiC;CAEvD,IAAI,OAAO,iBAAiB,WAC1B,MAAM,IAAI,UAAU,gCAAgC;CAEtD,MAAM,QAAQ,MAAM,yBAAyB,WAAW,GACtD,aAAa,kBAAkB,MAAM,KAAK;CAC5C,IAAI,UAAU,WACZ,WAAW,KAAK,GAAI,MAAM,oBAAoB,MAAM,OAAO,eAAe,YAAY,CAAE;CAE1F,OAAO,mBAAmB,YAAY,OAAO,WAAW,eAAe,YAAY;AACrF"}
@@ -1,63 +1,62 @@
1
1
  const { Buffer } = require("node:buffer");
2
- let connectionApi;
3
- let fileApi;
2
+
3
+ let connectionApi, fileApi;
4
4
  function getDriveConnection(drive, bufferChars) {
5
5
  if (connectionApi === undefined) {
6
- const koffi = require("koffi");
7
- const getConnectionW = koffi
8
- .load("mpr.dll")
9
- .func(
10
- "uint32_t WNetGetConnectionW(const char16_t *lpLocalName, _Out_ char16_t *lpRemoteName, _Inout_ uint32_t *lpnLength)",
11
- );
6
+ const koffi = require("koffi"),
7
+ getConnectionW = koffi
8
+ .load("mpr.dll")
9
+ .func(
10
+ "uint32_t WNetGetConnectionW(const char16_t *lpLocalName, _Out_ char16_t *lpRemoteName, _Inout_ uint32_t *lpnLength)",
11
+ );
12
12
  connectionApi = { getConnectionW, koffi };
13
13
  }
14
- const buffer = Buffer.alloc(bufferChars * 2);
15
- const length = [bufferChars];
16
- const status = connectionApi.getConnectionW(drive, buffer, length);
17
- const remote =
18
- status === 0 ? connectionApi.koffi.decode(buffer, "char16_t", bufferChars) : undefined;
14
+ const buffer = Buffer.alloc(bufferChars * 2),
15
+ length = [bufferChars],
16
+ status = connectionApi.getConnectionW(drive, buffer, length),
17
+ remote = status === 0 ? connectionApi.koffi.decode(buffer, "char16_t", bufferChars) : undefined;
19
18
  return { remote, status };
20
19
  }
21
20
  function getFileAttributes(filePath) {
22
21
  if (fileApi === undefined) {
23
- const koffi = require("koffi");
24
- const kernel32 = koffi.load("kernel32.dll");
25
- const fileTime = koffi.struct({
26
- lowDateTime: "uint32_t",
27
- highDateTime: "uint32_t",
28
- });
29
- const findData = koffi.struct({
30
- fileAttributes: "uint32_t",
31
- creationTime: fileTime,
32
- lastAccessTime: fileTime,
33
- lastWriteTime: fileTime,
34
- fileSizeHigh: "uint32_t",
35
- fileSizeLow: "uint32_t",
36
- reserved0: "uint32_t",
37
- reserved1: "uint32_t",
38
- fileName: koffi.array("char16_t", 260, "String"),
39
- alternateFileName: koffi.array("char16_t", 14, "String"),
40
- });
22
+ const koffi = require("koffi"),
23
+ kernel32 = koffi.load("kernel32.dll"),
24
+ fileTime = koffi.struct({
25
+ highDateTime: "uint32_t",
26
+ lowDateTime: "uint32_t",
27
+ }),
28
+ findData = koffi.struct({
29
+ fileAttributes: "uint32_t",
30
+ creationTime: fileTime,
31
+ lastAccessTime: fileTime,
32
+ lastWriteTime: fileTime,
33
+ fileSizeHigh: "uint32_t",
34
+ fileSizeLow: "uint32_t",
35
+ reserved0: "uint32_t",
36
+ reserved1: "uint32_t",
37
+ fileName: koffi.array("char16_t", 260, "String"),
38
+ alternateFileName: koffi.array("char16_t", 14, "String"),
39
+ });
41
40
  fileApi = {
41
+ findClose: kernel32.func("FindClose", "bool", ["void *"]),
42
42
  findFirstFileW: kernel32.func("FindFirstFileW", "void *", [
43
43
  "const char16_t *",
44
44
  koffi.out(koffi.pointer(findData)),
45
45
  ]),
46
- findClose: kernel32.func("FindClose", "bool", ["void *"]),
47
46
  getLastError: kernel32.func("uint32_t GetLastError(void)"),
48
47
  };
49
48
  }
50
- const data = {};
51
- const handle = fileApi.findFirstFileW(filePath, data);
49
+ const data = {},
50
+ handle = fileApi.findFirstFileW(filePath, data);
52
51
  if (
53
52
  handle === null ||
54
53
  handle === undefined ||
55
54
  handle === -1 ||
56
55
  handle === -1n ||
57
- handle === 0xffffffffn ||
58
- handle === 0xffffffffffffffffn
56
+ handle === 0xff_ff_ff_ffn ||
57
+ handle === 0xff_ff_ff_ff_ff_ff_ff_ffn
59
58
  ) {
60
- return { attributes: 0xffffffff, error: fileApi.getLastError() };
59
+ return { attributes: 0xff_ff_ff_ff, error: fileApi.getLastError() };
61
60
  }
62
61
  const closed = fileApi.findClose(handle);
63
62
  if (!closed) {
@@ -166,17 +166,10 @@ export declare function createTraversalFileSystem(root: string, searchHidden: bo
166
166
  readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: nodeFileSystem.ReadPosition | null): number;
167
167
  readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: nodeFileSystem.ReadOptions): number;
168
168
  readFile: typeof nodeFileSystem.readFile;
169
- readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options?: {
170
- encoding?: null | undefined;
171
- flag?: string | undefined;
172
- } | null): NonSharedBuffer;
173
- readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options: {
174
- encoding: BufferEncoding;
175
- flag?: string | undefined;
176
- } | BufferEncoding): string;
177
- readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options?: (nodeFileSystem.ObjectEncodingOptions & {
178
- flag?: string | undefined;
179
- }) | BufferEncoding | null): string | NonSharedBuffer;
169
+ readFileSync<T extends NodeJS.ArrayBufferView>(path: nodeFileSystem.PathOrFileDescriptor, options: nodeFileSystem.ReadFileSyncOptionsWithBuffer<T>): import("node:buffer").BufferView<T>;
170
+ readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options?: nodeFileSystem.ReadFileSyncOptionsWithBufferEncoding | null): NonSharedBuffer;
171
+ readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options: nodeFileSystem.ReadFileSyncOptionsWithStringEncoding | BufferEncoding): string;
172
+ readFileSync(path: nodeFileSystem.PathOrFileDescriptor, options: nodeFileSystem.ReadFileSyncOptions): string | NonSharedBuffer;
180
173
  writeFile: typeof nodeFileSystem.writeFile;
181
174
  writeFileSync(file: nodeFileSystem.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: nodeFileSystem.WriteFileOptions): void;
182
175
  appendFile: typeof nodeFileSystem.appendFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pathprobe",
3
- "version": "0.8.12",
3
+ "version": "0.9.14",
4
4
  "description": "Extract, resolve, and validate file and directory paths mentioned in text, with variable expansion, ignore rules, hidden-file control, and configurable search roots.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "build": "tsdown --config config/tsdown.config.ts && tsc --project config/tsconfig.build.json",
22
- "format": "oxfmt --config config/oxfmt.json .",
23
- "lint": "oxlint --config config/oxlint.json --tsconfig tsconfig.json .",
22
+ "format": "oxfmt",
23
+ "lint": "oxlint",
24
24
  "prepack": "bun run build",
25
25
  "test": "node --test \"quality/test/*.test.mjs\" && bun test quality/test",
26
26
  "test:benchmark": "node quality/benchmark/run.mjs",
@@ -34,9 +34,11 @@
34
34
  "p-limit": "latest"
35
35
  },
36
36
  "devDependencies": {
37
+ "@types/bun": "latest",
37
38
  "@types/node": "latest",
38
39
  "oxfmt": "latest",
39
40
  "oxlint": "latest",
41
+ "oxlint-tsgolint": "latest",
40
42
  "tinybench": "latest",
41
43
  "tsdown": "beta",
42
44
  "typescript": "next"