pathprobe 0.5.5 → 0.7.7
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/README.md +14 -9
- package/dist/index.mjs +209 -62
- package/dist/index.mjs.map +1 -1
- package/dist/native/windows-bridge.cjs +15 -1
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/native/attributes.d.ts +1 -0
- package/dist/types/src/search/hidden.d.ts +3 -0
- package/dist/types/src/{inventory.d.ts → search/inventory.d.ts} +1 -1
- package/dist/types/src/{policy.d.ts → search/policy.d.ts} +2 -1
- package/dist/types/src/types.d.ts +32 -0
- package/dist/types/src/validation/containment.d.ts +2 -0
- package/dist/types/src/{existence.d.ts → validation/existence.d.ts} +1 -1
- package/dist/types/src/{filesystem.d.ts → validation/filesystem.d.ts} +1 -1
- package/dist/types/src/{variables/index.d.ts → variables.d.ts} +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -13,14 +13,14 @@ npm install pathprobe
|
|
|
13
13
|
```ts
|
|
14
14
|
import { findExistingPaths } from "pathprobe";
|
|
15
15
|
|
|
16
|
-
const matches = await findExistingPaths(
|
|
17
|
-
`
|
|
16
|
+
const matches = await findExistingPaths({
|
|
17
|
+
text: `
|
|
18
18
|
请检查 src/index.ts:12
|
|
19
19
|
以及 "./config/settings.json"
|
|
20
20
|
`,
|
|
21
|
-
2,
|
|
22
|
-
[process.cwd()],
|
|
23
|
-
);
|
|
21
|
+
level: 2,
|
|
22
|
+
directories: [process.cwd()],
|
|
23
|
+
});
|
|
24
24
|
|
|
25
25
|
console.log(matches);
|
|
26
26
|
```
|
|
@@ -46,14 +46,14 @@ console.log(matches);
|
|
|
46
46
|
## API
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
findExistingPaths(
|
|
49
|
+
findExistingPaths({
|
|
50
50
|
text,
|
|
51
51
|
level,
|
|
52
52
|
directories,
|
|
53
53
|
variables?,
|
|
54
54
|
respectIgnore?,
|
|
55
55
|
searchHidden?,
|
|
56
|
-
): Promise<PathMatch[]>
|
|
56
|
+
}): Promise<PathMatch[]>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
参数说明:
|
|
@@ -117,8 +117,13 @@ ${{ env.HOME }}/project/file.txt
|
|
|
117
117
|
也可以自行提供变量:
|
|
118
118
|
|
|
119
119
|
```ts
|
|
120
|
-
await findExistingPaths(
|
|
121
|
-
|
|
120
|
+
await findExistingPaths({
|
|
121
|
+
text: "$PROJECT_ROOT/src/index.ts",
|
|
122
|
+
level: 2,
|
|
123
|
+
directories: [process.cwd()],
|
|
124
|
+
variables: {
|
|
125
|
+
PROJECT_ROOT: "/projects/demo",
|
|
126
|
+
},
|
|
122
127
|
});
|
|
123
128
|
```
|
|
124
129
|
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { convertPathToPattern, globby } from "globby";
|
|
|
7
7
|
import { isIP } from "node:net";
|
|
8
8
|
import { hostname, networkInterfaces } from "node:os";
|
|
9
9
|
import nativeBridge from "./native/windows-bridge.cjs";
|
|
10
|
+
import { AhoCorasick } from "@monyone/aho-corasick";
|
|
10
11
|
//#region config/settings.ts
|
|
11
12
|
const settings = {
|
|
12
13
|
batchValidationThreshold: 48,
|
|
@@ -20,7 +21,7 @@ const settings = {
|
|
|
20
21
|
validationConcurrency: 32
|
|
21
22
|
};
|
|
22
23
|
//#endregion
|
|
23
|
-
//#region src/variables
|
|
24
|
+
//#region src/variables.ts
|
|
24
25
|
const nameSource = String.raw`[A-Za-z_][A-Za-z0-9_.-]*`;
|
|
25
26
|
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}@)`;
|
|
26
27
|
const expressionPatterns = [
|
|
@@ -128,7 +129,7 @@ function extractCandidates(text, level) {
|
|
|
128
129
|
return result;
|
|
129
130
|
}
|
|
130
131
|
//#endregion
|
|
131
|
-
//#region src/existence.ts
|
|
132
|
+
//#region src/validation/existence.ts
|
|
132
133
|
const knownFileErrors = /* @__PURE__ */ new Set([
|
|
133
134
|
"EACCES",
|
|
134
135
|
"ELOOP",
|
|
@@ -139,7 +140,7 @@ const knownFileErrors = /* @__PURE__ */ new Set([
|
|
|
139
140
|
"EINVAL"
|
|
140
141
|
]);
|
|
141
142
|
const unverifiableUncErrors = /* @__PURE__ */ new Set(["UNKNOWN", "EUNKNOWN"]);
|
|
142
|
-
function pathKey$
|
|
143
|
+
function pathKey$3(value) {
|
|
143
144
|
return process.platform === "win32" ? value.toLowerCase() : value;
|
|
144
145
|
}
|
|
145
146
|
function fileErrorCode(error) {
|
|
@@ -170,15 +171,15 @@ async function classifyExistingPaths(paths, roots) {
|
|
|
170
171
|
await Promise.all(paths.map((filePath) => limit(() => classifyAndAdd(found, filePath))));
|
|
171
172
|
return found;
|
|
172
173
|
}
|
|
173
|
-
const rootKeys = new Set(roots.map(pathKey$
|
|
174
|
+
const rootKeys = new Set(roots.map(pathKey$3));
|
|
174
175
|
const pathsByParent = /* @__PURE__ */ new Map();
|
|
175
176
|
for (const filePath of paths) {
|
|
176
|
-
if (rootKeys.has(pathKey$
|
|
177
|
+
if (rootKeys.has(pathKey$3(filePath))) {
|
|
177
178
|
found.set(filePath, "directory");
|
|
178
179
|
continue;
|
|
179
180
|
}
|
|
180
181
|
const parent = nodePath.dirname(filePath);
|
|
181
|
-
const key = pathKey$
|
|
182
|
+
const key = pathKey$3(parent);
|
|
182
183
|
const group = pathsByParent.get(key) ?? {
|
|
183
184
|
parent,
|
|
184
185
|
paths: []
|
|
@@ -198,10 +199,10 @@ async function classifyExistingPaths(paths, roots) {
|
|
|
198
199
|
if (isKnownFileError(error, parent)) return;
|
|
199
200
|
throw error;
|
|
200
201
|
}
|
|
201
|
-
const entriesByName = new Map(entries.map((entry) => [pathKey$
|
|
202
|
+
const entriesByName = new Map(entries.map((entry) => [pathKey$3(entry.name), entry]));
|
|
202
203
|
await Promise.all(groupPaths.map(async (filePath) => {
|
|
203
204
|
const name = nodePath.basename(filePath);
|
|
204
|
-
const entry = entriesByName.get(pathKey$
|
|
205
|
+
const entry = entriesByName.get(pathKey$3(name));
|
|
205
206
|
if (entry?.isFile()) found.set(filePath, "file");
|
|
206
207
|
else if (entry?.isDirectory()) found.set(filePath, "directory");
|
|
207
208
|
else if (entry !== void 0 || process.platform === "win32" && name.includes(":")) await classifyAndAdd(found, filePath);
|
|
@@ -210,6 +211,29 @@ async function classifyExistingPaths(paths, roots) {
|
|
|
210
211
|
return found;
|
|
211
212
|
}
|
|
212
213
|
//#endregion
|
|
214
|
+
//#region src/validation/containment.ts
|
|
215
|
+
function removeContainedMatches(matches) {
|
|
216
|
+
const ordered = matches.map((match, index) => ({
|
|
217
|
+
index,
|
|
218
|
+
match
|
|
219
|
+
})).toSorted(({ match: left }, { match: right }) => left.position.start - right.position.start || right.position.end - left.position.end);
|
|
220
|
+
const kept = /* @__PURE__ */ new Set();
|
|
221
|
+
let maxEndBeforeStart = -1;
|
|
222
|
+
let groupStart = -1;
|
|
223
|
+
let maxEndInGroup = -1;
|
|
224
|
+
for (const { index, match } of ordered) {
|
|
225
|
+
const { start, end } = match.position;
|
|
226
|
+
if (start !== groupStart) {
|
|
227
|
+
maxEndBeforeStart = Math.max(maxEndBeforeStart, maxEndInGroup);
|
|
228
|
+
groupStart = start;
|
|
229
|
+
maxEndInGroup = -1;
|
|
230
|
+
}
|
|
231
|
+
if (maxEndBeforeStart < end && maxEndInGroup <= end) kept.add(index);
|
|
232
|
+
maxEndInGroup = Math.max(maxEndInGroup, end);
|
|
233
|
+
}
|
|
234
|
+
return matches.filter((_, index) => kept.has(index));
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
213
237
|
//#region src/native/unc.ts
|
|
214
238
|
const native = process.platform === "win32" ? nativeBridge : void 0;
|
|
215
239
|
const uncServerSegmentPattern = /^[^\\/:*?"<>|]+$/u;
|
|
@@ -322,7 +346,58 @@ function resolveUncPath(value) {
|
|
|
322
346
|
return resolveMappedUncPath(path) ?? resolveLocalAdministrativeShare(path);
|
|
323
347
|
}
|
|
324
348
|
//#endregion
|
|
325
|
-
//#region src/
|
|
349
|
+
//#region src/native/attributes.ts
|
|
350
|
+
const fileAttributeHidden = 2;
|
|
351
|
+
const invalidFileAttributes = 4294967295;
|
|
352
|
+
const missingPathErrors = /* @__PURE__ */ new Set([2, 3]);
|
|
353
|
+
function hasWindowsHiddenAttribute(filePath) {
|
|
354
|
+
if (process.platform !== "win32") throw new Error("Windows file attributes are unavailable on this platform");
|
|
355
|
+
const { attributes, error } = nativeBridge.getFileAttributes(nodePath.toNamespacedPath(filePath));
|
|
356
|
+
if (!Number.isInteger(attributes) || !Number.isInteger(error)) throw new TypeError("GetFileAttributesW returned an invalid result");
|
|
357
|
+
if (attributes !== invalidFileAttributes) {
|
|
358
|
+
if (error !== 0) throw new Error(`GetFileAttributesW returned attributes with error ${error}`);
|
|
359
|
+
return (attributes & fileAttributeHidden) !== 0;
|
|
360
|
+
}
|
|
361
|
+
if (missingPathErrors.has(error)) return false;
|
|
362
|
+
throw new Error(`GetFileAttributesW failed for ${filePath} with error ${error}`);
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/search/hidden.ts
|
|
366
|
+
function pathKey$2(value) {
|
|
367
|
+
return process.platform === "win32" ? value.toLowerCase() : value;
|
|
368
|
+
}
|
|
369
|
+
function relativePath(filePath, boundary) {
|
|
370
|
+
const relative = nodePath.relative(boundary, filePath);
|
|
371
|
+
if (nodePath.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${nodePath.sep}`)) throw new RangeError(`${filePath} is outside the hidden-path boundary ${boundary}`);
|
|
372
|
+
return relative;
|
|
373
|
+
}
|
|
374
|
+
function hasHiddenDotSegment(filePath, boundary) {
|
|
375
|
+
return relativePath(filePath, boundary).split(/[\\/]/u).some((part) => part.length > 1 && part.startsWith("."));
|
|
376
|
+
}
|
|
377
|
+
function createHiddenPathDetector() {
|
|
378
|
+
const attributeCache = /* @__PURE__ */ new Map();
|
|
379
|
+
return { isHidden(filePath, boundary) {
|
|
380
|
+
if (process.platform !== "win32") return hasHiddenDotSegment(filePath, boundary);
|
|
381
|
+
relativePath(filePath, boundary);
|
|
382
|
+
const boundaryKey = pathKey$2(nodePath.resolve(boundary));
|
|
383
|
+
let current = nodePath.resolve(filePath);
|
|
384
|
+
while (pathKey$2(current) !== boundaryKey) {
|
|
385
|
+
const key = pathKey$2(current);
|
|
386
|
+
let hidden = attributeCache.get(key);
|
|
387
|
+
if (hidden === void 0) {
|
|
388
|
+
hidden = hasWindowsHiddenAttribute(current);
|
|
389
|
+
attributeCache.set(key, hidden);
|
|
390
|
+
}
|
|
391
|
+
if (hidden) return true;
|
|
392
|
+
const parent = nodePath.dirname(current);
|
|
393
|
+
if (parent === current) throw new Error(`Unable to reach hidden-path boundary ${boundary} from ${filePath}`);
|
|
394
|
+
current = parent;
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
397
|
+
} };
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/search/policy.ts
|
|
326
401
|
function pathKey$1(value) {
|
|
327
402
|
return process.platform === "win32" ? value.toLowerCase() : value;
|
|
328
403
|
}
|
|
@@ -330,14 +405,11 @@ function isWithinRoot(filePath, root) {
|
|
|
330
405
|
const relative = nodePath.relative(root, filePath);
|
|
331
406
|
return relative === "" || relative !== ".." && !relative.startsWith(`..${nodePath.sep}`) && !nodePath.isAbsolute(relative);
|
|
332
407
|
}
|
|
333
|
-
function isHidden(relativePath) {
|
|
334
|
-
return relativePath.split(/[\\/]/u).some((part) => part.length > 1 && part.startsWith("."));
|
|
335
|
-
}
|
|
336
408
|
function traversalOptions(root, searchHidden) {
|
|
337
409
|
return {
|
|
338
410
|
caseSensitiveMatch: process.platform !== "win32",
|
|
339
411
|
cwd: root,
|
|
340
|
-
dot: searchHidden,
|
|
412
|
+
dot: process.platform === "win32" || searchHidden,
|
|
341
413
|
followSymbolicLinks: false,
|
|
342
414
|
onlyFiles: false,
|
|
343
415
|
unique: true
|
|
@@ -369,19 +441,30 @@ async function resolveSearchDirectories(directories) {
|
|
|
369
441
|
return [...unique.values()];
|
|
370
442
|
}
|
|
371
443
|
async function listSearchEntries(root, respectIgnore, searchHidden) {
|
|
372
|
-
|
|
373
|
-
|
|
444
|
+
const entries = !respectIgnore ? await fastGlob("**/*", {
|
|
445
|
+
...traversalOptions(root, searchHidden),
|
|
446
|
+
objectMode: true
|
|
447
|
+
}) : await globby("**/*", {
|
|
448
|
+
...globbyOptions(root, respectIgnore, searchHidden),
|
|
449
|
+
objectMode: true
|
|
450
|
+
});
|
|
451
|
+
const hiddenDetector = createHiddenPathDetector();
|
|
452
|
+
return entries.filter((entry) => searchHidden || !hiddenDetector.isHidden(nodePath.resolve(root, entry.path), root)).map((entry) => ({
|
|
453
|
+
directory: entry.dirent.isDirectory(),
|
|
454
|
+
path: entry.path
|
|
455
|
+
}));
|
|
374
456
|
}
|
|
375
457
|
async function filterSearchablePaths(paths, roots, respectIgnore, searchHidden) {
|
|
376
458
|
const allowed = /* @__PURE__ */ new Set();
|
|
377
459
|
const pathsByRoot = /* @__PURE__ */ new Map();
|
|
460
|
+
const hiddenDetector = createHiddenPathDetector();
|
|
378
461
|
for (const filePath of paths) {
|
|
379
462
|
let hasSearchRoot = false;
|
|
380
463
|
for (const root of roots) {
|
|
381
464
|
if (!isWithinRoot(filePath, root)) continue;
|
|
382
465
|
hasSearchRoot = true;
|
|
383
466
|
const relative = nodePath.relative(root, filePath);
|
|
384
|
-
if (!searchHidden && isHidden(
|
|
467
|
+
if (!searchHidden && hiddenDetector.isHidden(filePath, root)) continue;
|
|
385
468
|
if (relative === "" || !respectIgnore) allowed.add(filePath);
|
|
386
469
|
else {
|
|
387
470
|
const grouped = pathsByRoot.get(root) ?? [];
|
|
@@ -390,8 +473,9 @@ async function filterSearchablePaths(paths, roots, respectIgnore, searchHidden)
|
|
|
390
473
|
}
|
|
391
474
|
}
|
|
392
475
|
if (hasSearchRoot) continue;
|
|
393
|
-
const
|
|
394
|
-
|
|
476
|
+
const filesystemRoot = nodePath.parse(filePath).root;
|
|
477
|
+
const hiddenBoundary = process.platform === "win32" ? nodePath.dirname(filePath) : filesystemRoot;
|
|
478
|
+
if (searchHidden || !hiddenDetector.isHidden(filePath, hiddenBoundary)) allowed.add(filePath);
|
|
395
479
|
}
|
|
396
480
|
await Promise.all([...pathsByRoot].map(async ([root, relativePaths]) => {
|
|
397
481
|
const patterns = relativePaths.map(convertPathToPattern);
|
|
@@ -404,7 +488,7 @@ async function filterSearchablePaths(paths, roots, respectIgnore, searchHidden)
|
|
|
404
488
|
return allowed;
|
|
405
489
|
}
|
|
406
490
|
//#endregion
|
|
407
|
-
//#region src/filesystem.ts
|
|
491
|
+
//#region src/validation/filesystem.ts
|
|
408
492
|
function pathKey(value) {
|
|
409
493
|
return process.platform === "win32" ? value.toLowerCase() : value;
|
|
410
494
|
}
|
|
@@ -509,6 +593,7 @@ async function validateCandidates(candidates, roots, variables, respectIgnore, s
|
|
|
509
593
|
const paths = toPaths(prepared.value, roots, variables);
|
|
510
594
|
for (const filePath of paths) {
|
|
511
595
|
resolvedCandidates.push({
|
|
596
|
+
...candidate.expectedKind === void 0 ? {} : { expectedKind: candidate.expectedKind },
|
|
512
597
|
...prepared.location === void 0 ? {} : { location: prepared.location },
|
|
513
598
|
path: filePath,
|
|
514
599
|
position: prepared.position
|
|
@@ -521,9 +606,9 @@ async function validateCandidates(candidates, roots, variables, respectIgnore, s
|
|
|
521
606
|
const classifiedPaths = await classifyExistingPaths(searchablePaths, roots);
|
|
522
607
|
const kindsByPath = new Map([...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind]));
|
|
523
608
|
const matches = /* @__PURE__ */ new Map();
|
|
524
|
-
for (const { location, path, position } of resolvedCandidates) {
|
|
609
|
+
for (const { expectedKind, location, path, position } of resolvedCandidates) {
|
|
525
610
|
const kind = kindsByPath.get(pathKey(path));
|
|
526
|
-
if (kind === void 0) continue;
|
|
611
|
+
if (kind === void 0 || expectedKind !== void 0 && kind !== expectedKind) continue;
|
|
527
612
|
const key = `${pathKey(path)}\0${position.start}\0${position.end}`;
|
|
528
613
|
const existing = matches.get(key);
|
|
529
614
|
if (existing !== void 0) {
|
|
@@ -537,69 +622,131 @@ async function validateCandidates(candidates, roots, variables, respectIgnore, s
|
|
|
537
622
|
position
|
|
538
623
|
});
|
|
539
624
|
}
|
|
540
|
-
return [...matches.values()];
|
|
625
|
+
return removeContainedMatches([...matches.values()]);
|
|
541
626
|
}
|
|
542
627
|
//#endregion
|
|
543
|
-
//#region src/inventory.ts
|
|
544
|
-
|
|
628
|
+
//#region src/search/inventory.ts
|
|
629
|
+
let inventoryMatcherCache;
|
|
630
|
+
function isBoundary(value, following, directoryEnd = false) {
|
|
631
|
+
if (directoryEnd && value !== ".") return value === void 0 || /[\s"'`<>)\]},;:!?,。;:!?、]/u.test(value);
|
|
545
632
|
if (value === ".") return following === void 0 || !/[\p{L}\p{N}_-]/u.test(following);
|
|
546
633
|
return value === void 0 || !/[\p{L}\p{N}_/\\-]/u.test(value);
|
|
547
634
|
}
|
|
548
|
-
function
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
635
|
+
function addMatch(result, seen, text, value, start, end, expectedKind) {
|
|
636
|
+
if (!isBoundary(text[start - 1], text[start]) || !isBoundary(text[end], text[end + 1], expectedKind === "directory")) return;
|
|
637
|
+
const key = `${start}:${end}:${text.slice(start, end)}`;
|
|
638
|
+
if (!seen.has(key)) {
|
|
639
|
+
seen.add(key);
|
|
640
|
+
result.push({
|
|
641
|
+
end,
|
|
642
|
+
expectedKind,
|
|
643
|
+
kind: "inventory",
|
|
644
|
+
start,
|
|
645
|
+
value
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function addVariant(patterns, entry, value) {
|
|
650
|
+
const key = process.platform === "win32" ? value.toLowerCase() : value;
|
|
651
|
+
if (!patterns.has(key)) patterns.set(key, {
|
|
652
|
+
expectedKind: entry.directory ? "directory" : "file",
|
|
653
|
+
relative: entry.path,
|
|
654
|
+
value
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function addEntryVariants(patterns, entry) {
|
|
658
|
+
const native = entry.path.replaceAll("/", nodePath.sep);
|
|
659
|
+
if (entry.directory) {
|
|
660
|
+
addVariant(patterns, entry, `${entry.path}/`);
|
|
661
|
+
addVariant(patterns, entry, `${native}${nodePath.sep}`);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
addVariant(patterns, entry, entry.path);
|
|
665
|
+
addVariant(patterns, entry, native);
|
|
666
|
+
}
|
|
667
|
+
function createRootPrefixes(roots) {
|
|
668
|
+
const prefixes = /* @__PURE__ */ new Map();
|
|
669
|
+
for (const root of roots) {
|
|
670
|
+
const native = root.endsWith(nodePath.sep) ? root : `${root}${nodePath.sep}`;
|
|
671
|
+
const slashRoot = root.replaceAll(nodePath.sep, "/");
|
|
672
|
+
const slash = slashRoot.endsWith("/") ? slashRoot : `${slashRoot}/`;
|
|
673
|
+
for (const value of [native, slash]) {
|
|
674
|
+
const key = process.platform === "win32" ? value.toLowerCase() : value;
|
|
675
|
+
prefixes.set(key, {
|
|
676
|
+
root,
|
|
677
|
+
value: key
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return [...prefixes.values()];
|
|
682
|
+
}
|
|
683
|
+
function addAbsoluteMatch(result, seen, source, text, pattern, prefixes, end, relativeStart) {
|
|
684
|
+
for (const prefix of prefixes) {
|
|
685
|
+
const start = relativeStart - prefix.value.length;
|
|
686
|
+
if (start >= 0 && source.startsWith(prefix.value, start)) {
|
|
687
|
+
addMatch(result, seen, text, nodePath.resolve(prefix.root, pattern.relative), start, end, pattern.expectedKind);
|
|
688
|
+
return true;
|
|
564
689
|
}
|
|
565
|
-
offset = source.indexOf(target, offset + 1);
|
|
566
690
|
}
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
function hasSameEntries(cached, entries) {
|
|
694
|
+
if (cached.entries.length !== entries.length) return false;
|
|
695
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
696
|
+
const cachedEntries = cached.entries[index];
|
|
697
|
+
const currentEntries = entries[index];
|
|
698
|
+
if (cachedEntries === void 0 || currentEntries === void 0) return false;
|
|
699
|
+
if (cachedEntries.length !== currentEntries.length) return false;
|
|
700
|
+
for (let entryIndex = 0; entryIndex < currentEntries.length; entryIndex += 1) {
|
|
701
|
+
const cachedEntry = cachedEntries[entryIndex];
|
|
702
|
+
const currentEntry = currentEntries[entryIndex];
|
|
703
|
+
if (cachedEntry === void 0 || currentEntry === void 0 || cachedEntry.directory !== currentEntry.directory || cachedEntry.path !== currentEntry.path) return false;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
function canReuseMatcher(cached, entries, roots, respectIgnore, searchHidden) {
|
|
709
|
+
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);
|
|
567
710
|
}
|
|
568
711
|
async function inventoryCandidates(text, roots, respectIgnore, searchHidden) {
|
|
569
712
|
const entries = await Promise.all(roots.map((root) => listSearchEntries(root, respectIgnore, searchHidden)));
|
|
570
713
|
const result = [];
|
|
571
714
|
const seen = /* @__PURE__ */ new Set();
|
|
572
|
-
const scanned = /* @__PURE__ */ new Set();
|
|
573
715
|
const source = process.platform === "win32" ? text.toLowerCase() : text;
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
for (const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
]
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
716
|
+
let inventoryMatcher = inventoryMatcherCache;
|
|
717
|
+
if (!canReuseMatcher(inventoryMatcher, entries, roots, respectIgnore, searchHidden)) {
|
|
718
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
719
|
+
for (const relativeEntries of entries) for (const entry of relativeEntries) addEntryVariants(patterns, entry);
|
|
720
|
+
inventoryMatcher = {
|
|
721
|
+
entries,
|
|
722
|
+
matcher: new AhoCorasick([...patterns.keys()]),
|
|
723
|
+
patterns,
|
|
724
|
+
prefixes: createRootPrefixes(roots),
|
|
725
|
+
respectIgnore,
|
|
726
|
+
roots: [...roots],
|
|
727
|
+
searchHidden
|
|
728
|
+
};
|
|
729
|
+
inventoryMatcherCache = inventoryMatcher;
|
|
730
|
+
}
|
|
731
|
+
for (const { begin, end, keyword } of inventoryMatcher.matcher.matchInText(source)) {
|
|
732
|
+
const pattern = inventoryMatcher.patterns.get(keyword);
|
|
733
|
+
if (pattern === void 0) throw new Error("Inventory matcher returned an unknown path");
|
|
734
|
+
if (!addAbsoluteMatch(result, seen, source, text, pattern, inventoryMatcher.prefixes, end, begin)) addMatch(result, seen, text, pattern.value, begin, end, pattern.expectedKind);
|
|
593
735
|
}
|
|
594
736
|
return result;
|
|
595
737
|
}
|
|
596
738
|
//#endregion
|
|
597
739
|
//#region src/index.ts
|
|
598
740
|
const MAX_LEVEL = settings.spanWordLimits.length + 3;
|
|
741
|
+
function validateOptions(value) {
|
|
742
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError("options must be an object");
|
|
743
|
+
}
|
|
599
744
|
function validateVariables(value) {
|
|
600
745
|
if (typeof value !== "object" || value === null || Array.isArray(value) || Object.values(value).some((item) => typeof item !== "string")) throw new TypeError("variables must be an object of string values");
|
|
601
746
|
}
|
|
602
|
-
async function findExistingPaths(
|
|
747
|
+
async function findExistingPaths(options) {
|
|
748
|
+
validateOptions(options);
|
|
749
|
+
const { directories, level, respectIgnore = settings.respectIgnoreByDefault, searchHidden = settings.searchHiddenByDefault, text, variables = {} } = options;
|
|
603
750
|
if (typeof text !== "string") throw new TypeError("text must be a string");
|
|
604
751
|
if (!Number.isInteger(level) || level < 1 || level > MAX_LEVEL) throw new RangeError(`level must be an integer from 1 to ${MAX_LEVEL}`);
|
|
605
752
|
validateVariables(variables);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["pathKey","pathKey"],"sources":["../config/settings.ts","../src/variables/index.ts","../src/candidates.ts","../src/existence.ts","../src/native/unc.ts","../src/policy.ts","../src/filesystem.ts","../src/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 ignoreFilePatterns: [\"**/.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/index.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) {\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 { 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 knownFileErrors = 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 fileErrorCode(error: unknown): string | undefined {\n if (error instanceof Error && \"code\" in error && typeof error.code === \"string\") {\n return error.code;\n }\n return undefined;\n}\nfunction isKnownFileError(error: unknown, filePath?: string): boolean {\n const code = fileErrorCode(error);\n return (\n code !== undefined &&\n (knownFileErrors.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 (isKnownFileError(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 Promise.all(paths.map((filePath) => limit(() => 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 ...directPaths.map((filePath) => limit(() => classifyAndAdd(found, filePath))),\n ...scannedGroups.map(({ parent, paths: groupPaths }) =>\n limit(async () => {\n let entries;\n try {\n entries = await readdir(parent, { withFileTypes: true });\n } catch (error) {\n if (isKnownFileError(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 (\n entry !== undefined ||\n (process.platform === \"win32\" && name.includes(\":\"))\n ) {\n await classifyAndAdd(found, filePath);\n }\n }),\n );\n }),\n ),\n ]);\n return found;\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 { stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport fastGlob from \"fast-glob\";\nimport { convertPathToPattern, globby } from \"globby\";\nimport { settings } from \"../config/settings.js\";\nimport { resolveUncPath } from \"./native/unc.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isWithinRoot(filePath: string, root: string): boolean {\n const relative = nodePath.relative(root, filePath);\n return (\n relative === \"\" ||\n (relative !== \"..\" &&\n !relative.startsWith(`..${nodePath.sep}`) &&\n !nodePath.isAbsolute(relative))\n );\n}\nfunction isHidden(relativePath: string): boolean {\n return relativePath.split(/[\\\\/]/u).some((part) => part.length > 1 && part.startsWith(\".\"));\n}\nfunction traversalOptions(root: string, searchHidden: boolean) {\n return {\n caseSensitiveMatch: process.platform !== \"win32\",\n cwd: root,\n dot: searchHidden,\n followSymbolicLinks: false,\n onlyFiles: false,\n unique: true,\n } as const;\n}\nfunction globbyOptions(root: string, respectIgnore: boolean, searchHidden: boolean) {\n return {\n ...traversalOptions(root, searchHidden),\n expandDirectories: false,\n gitignore: respectIgnore,\n globalGitignore: respectIgnore,\n ...(respectIgnore ? { ignoreFiles: settings.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<string[]> {\n if (!respectIgnore) {\n return fastGlob(\"**/*\", traversalOptions(root, searchHidden));\n }\n return globby(\"**/*\", globbyOptions(root, respectIgnore, searchHidden));\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 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 && isHidden(relative)) {\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 filesystemRelative = nodePath.relative(nodePath.parse(filePath).root, filePath);\n if (searchHidden || !isHidden(filesystemRelative)) {\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),\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 { fileURLToPath } from \"node:url\";\nimport nodePath from \"node:path\";\nimport { classifyExistingPaths } from \"./existence.js\";\nimport { filterSearchablePaths } from \"./policy.js\";\nimport { expandVariables } from \"./variables/index.js\";\nimport { resolveUncPath } from \"./native/unc.js\";\nimport { settings } from \"../config/settings.js\";\nimport type { Candidate, PathLocation, PathMatch, PathPosition, Variables } from \"./types.js\";\n\ninterface ResolvedCandidate {\n location?: PathLocation;\n path: string;\n position: PathPosition;\n}\ninterface PreparedCandidate {\n location?: PathLocation;\n position: PathPosition;\n value: string;\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 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}\nfunction prepareCandidate(candidate: Candidate): PreparedCandidate {\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 if (candidate.kind === \"inventory\") {\n return { position: { end, start }, value };\n }\n const match = settings.locationSuffixPattern.exec(value);\n if (match === null) {\n return { position: { end, start }, value };\n }\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 const location: PathLocation =\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 return {\n location,\n position: { end, start },\n value: value.slice(0, match.index),\n };\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 const paths = toPaths(prepared.value, roots, variables);\n for (const filePath of paths) {\n resolvedCandidates.push({\n ...(prepared.location === undefined ? {} : { location: prepared.location }),\n path: filePath,\n position: prepared.position,\n });\n validationPaths.set(pathKey(filePath), filePath);\n }\n }\n let searchablePaths = [...validationPaths.values()];\n if (respectIgnore || !searchHidden) {\n searchablePaths = [\n ...(await filterSearchablePaths(searchablePaths, roots, respectIgnore, searchHidden)),\n ];\n }\n const classifiedPaths = await classifyExistingPaths(searchablePaths, roots);\n const kindsByPath = new Map(\n [...classifiedPaths].map(([filePath, kind]) => [pathKey(filePath), kind]),\n );\n const matches = new Map<string, PathMatch>();\n for (const { location, path, position } of resolvedCandidates) {\n const kind = kindsByPath.get(pathKey(path));\n if (kind === undefined) {\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 [...matches.values()];\n}\n","import nodePath from \"node:path\";\nimport { listSearchEntries } from \"./policy.js\";\nimport type { Candidate } from \"./types.js\";\n\nfunction isBoundary(value: string | undefined, following: string | undefined): boolean {\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 addOccurrences(\n result: Candidate[],\n seen: Set<string>,\n source: string,\n text: string,\n value: string,\n): void {\n const target = process.platform === \"win32\" ? value.toLowerCase() : value;\n let offset = source.indexOf(target);\n while (offset !== -1) {\n const end = offset + target.length;\n if (isBoundary(text[offset - 1], text[offset]) && isBoundary(text[end], text[end + 1])) {\n const key = `${offset}:${end}:${text.slice(offset, end)}`;\n if (!seen.has(key)) {\n seen.add(key);\n result.push({\n end,\n kind: \"inventory\",\n start: offset,\n value,\n });\n }\n }\n offset = source.indexOf(target, offset + 1);\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 scanned = new Set<string>();\n const source = process.platform === \"win32\" ? text.toLowerCase() : text;\n for (const [rootIndex, relativeEntries] of entries.entries()) {\n const root = roots[rootIndex];\n if (root === undefined) {\n continue;\n }\n for (const relativeEntry of relativeEntries) {\n const absoluteEntry = nodePath.resolve(root, relativeEntry);\n const variants = [\n relativeEntry,\n relativeEntry.replaceAll(\"/\", nodePath.sep),\n absoluteEntry,\n absoluteEntry.replaceAll(nodePath.sep, \"/\"),\n ];\n for (const value of variants) {\n const key = process.platform === \"win32\" ? value.toLowerCase() : value;\n if (!scanned.has(key)) {\n scanned.add(key);\n addOccurrences(result, seen, source, text, value);\n }\n }\n }\n }\n return result;\n}\n","import { extractCandidates } from \"./candidates.js\";\nimport { validateCandidates } from \"./filesystem.js\";\nimport { inventoryCandidates } from \"./inventory.js\";\nimport { resolveSearchDirectories } from \"./policy.js\";\nimport { settings } from \"../config/settings.js\";\nimport type { PathMatch, SearchLevel, Variables } from \"./types.js\";\n\nexport const MAX_LEVEL = settings.spanWordLimits.length + 3;\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(\n text: string,\n level: SearchLevel,\n directories: readonly string[],\n variables: Variables = {},\n respectIgnore: boolean = settings.respectIgnoreByDefault,\n searchHidden: boolean = settings.searchHiddenByDefault,\n): Promise<PathMatch[]> {\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 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,oBAAoB,CAAC,cAAc,cAAc;CACjD,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,WAAW,KAAK,IAAI;CAC9C,IAAI,OAAO,OAAO,GAAG,KAAK,WAAW,KAAK,IAAI;CAC9C,IAAI,OAAO,OAAO,GAAG,WAAW,WAAW,SAAS,IA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;CAE7C,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,QAAQ,WACnD,MAAM,IAAI,WAAW,sCAAsC,WAAW;CAExE,kBAAkB,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;CACxD,MAAM,aAAa,kBAAkB,MAAM,KAAK;CAChD,IAAI,UAAU,WACZ,WAAW,KAAK,GAAI,MAAM,oBAAoB,MAAM,OAAO,eAAe,YAAY,CAAE;CAE1F,OAAO,mBAAmB,YAAY,OAAO,WAAW,eAAe,YAAY;AACrF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["pathKey","pathKey","pathKey"],"sources":["../config/settings.ts","../src/variables.ts","../src/candidates.ts","../src/validation/existence.ts","../src/validation/containment.ts","../src/native/unc.ts","../src/native/attributes.ts","../src/search/hidden.ts","../src/search/policy.ts","../src/validation/filesystem.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 ignoreFilePatterns: [\"**/.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) {\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 { 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 knownFileErrors = 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 fileErrorCode(error: unknown): string | undefined {\n if (error instanceof Error && \"code\" in error && typeof error.code === \"string\") {\n return error.code;\n }\n return undefined;\n}\nfunction isKnownFileError(error: unknown, filePath?: string): boolean {\n const code = fileErrorCode(error);\n return (\n code !== undefined &&\n (knownFileErrors.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 (isKnownFileError(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 Promise.all(paths.map((filePath) => limit(() => 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 ...directPaths.map((filePath) => limit(() => classifyAndAdd(found, filePath))),\n ...scannedGroups.map(({ parent, paths: groupPaths }) =>\n limit(async () => {\n let entries;\n try {\n entries = await readdir(parent, { withFileTypes: true });\n } catch (error) {\n if (isKnownFileError(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 (\n entry !== undefined ||\n (process.platform === \"win32\" && name.includes(\":\"))\n ) {\n await classifyAndAdd(found, filePath);\n }\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 { 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(\"GetFileAttributesW returned an invalid result\");\n }\n if (attributes !== invalidFileAttributes) {\n if (error !== 0) {\n throw new Error(`GetFileAttributesW 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(`GetFileAttributesW 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 { stat } from \"node:fs/promises\";\nimport nodePath from \"node:path\";\nimport fastGlob from \"fast-glob\";\nimport { convertPathToPattern, globby } from \"globby\";\nimport { settings } from \"../../config/settings.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport type { SearchEntry } from \"../types.js\";\nimport { createHiddenPathDetector } from \"./hidden.js\";\n\nfunction pathKey(value: string): string {\n return process.platform === \"win32\" ? value.toLowerCase() : value;\n}\nfunction isWithinRoot(filePath: string, root: string): boolean {\n const relative = nodePath.relative(root, filePath);\n return (\n relative === \"\" ||\n (relative !== \"..\" &&\n !relative.startsWith(`..${nodePath.sep}`) &&\n !nodePath.isAbsolute(relative))\n );\n}\nfunction traversalOptions(root: string, searchHidden: boolean) {\n return {\n caseSensitiveMatch: process.platform !== \"win32\",\n cwd: root,\n dot: process.platform === \"win32\" || searchHidden,\n followSymbolicLinks: false,\n onlyFiles: false,\n unique: true,\n } as const;\n}\nfunction globbyOptions(root: string, respectIgnore: boolean, searchHidden: boolean) {\n return {\n ...traversalOptions(root, searchHidden),\n expandDirectories: false,\n gitignore: respectIgnore,\n globalGitignore: respectIgnore,\n ...(respectIgnore ? { ignoreFiles: settings.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 = !respectIgnore\n ? await fastGlob(\"**/*\", { ...traversalOptions(root, searchHidden), objectMode: true })\n : 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),\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 { fileURLToPath } from \"node:url\";\nimport nodePath from \"node:path\";\nimport { classifyExistingPaths } from \"./existence.js\";\nimport { removeContainedMatches } from \"./containment.js\";\nimport { filterSearchablePaths } from \"../search/policy.js\";\nimport { expandVariables } from \"../variables.js\";\nimport { resolveUncPath } from \"../native/unc.js\";\nimport { settings } from \"../../config/settings.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}\ntype PreparedCandidate = Pick<ResolvedCandidate, \"location\" | \"position\"> & { value: string };\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 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}\nfunction prepareCandidate(candidate: Candidate): PreparedCandidate {\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 if (candidate.kind === \"inventory\") {\n return { position: { end, start }, value };\n }\n const match = settings.locationSuffixPattern.exec(value);\n if (match === null) {\n return { position: { end, start }, value };\n }\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 const location: PathLocation =\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 return {\n location,\n position: { end, start },\n value: value.slice(0, match.index),\n };\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 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 let searchablePaths = [...validationPaths.values()];\n if (respectIgnore || !searchHidden) {\n searchablePaths = [\n ...(await filterSearchablePaths(searchablePaths, roots, respectIgnore, searchHidden)),\n ];\n }\n const classifiedPaths = await classifyExistingPaths(searchablePaths, roots);\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/filesystem.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,oBAAoB,CAAC,cAAc,cAAc;CACjD,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,WAAW,KAAK,IAAI;CAC9C,IAAI,OAAO,OAAO,GAAG,KAAK,WAAW,KAAK,IAAI;CAC9C,IAAI,OAAO,OAAO,GAAG,WAAW,WAAW,SAAS,IAAI;CACxD,IAAI,OAAO,OAAO,GAAG,KAAK,WAAW,KAAK,IAAI;AAChD;AACA,SAAS,gBAAgB,MAAc,WAA0C;CAC/E,MAAM,SAAS,UAAU,SAAS,QAAQ,IAAI;CAC9C,IAAI,WAAW,KAAA,GACb,OAAO;CAET,MAAM,WAAW,qCAAqC,KAAK,IAAI,CAAC,GAAG;CACnE,OAAO,aAAa,KAAA,IAAY,KAA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WAAW,sCAAsC,WAAW;CAExE,kBAAkB,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;CACxD,MAAM,aAAa,kBAAkB,MAAM,KAAK;CAChD,IAAI,UAAU,WACZ,WAAW,KAAK,GAAI,MAAM,oBAAoB,MAAM,OAAO,eAAe,YAAY,CAAE;CAE1F,OAAO,mBAAmB,YAAY,OAAO,WAAW,eAAe,YAAY;AACrF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { Buffer } = require("node:buffer");
|
|
2
2
|
let connectionApi;
|
|
3
|
+
let fileApi;
|
|
3
4
|
function getDriveConnection(drive, bufferChars) {
|
|
4
5
|
if (connectionApi === undefined) {
|
|
5
6
|
const koffi = require("koffi");
|
|
@@ -17,4 +18,17 @@ function getDriveConnection(drive, bufferChars) {
|
|
|
17
18
|
status === 0 ? connectionApi.koffi.decode(buffer, "char16_t", bufferChars) : undefined;
|
|
18
19
|
return { remote, status };
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
function getFileAttributes(filePath) {
|
|
22
|
+
if (fileApi === undefined) {
|
|
23
|
+
const koffi = require("koffi");
|
|
24
|
+
const kernel32 = koffi.load("kernel32.dll");
|
|
25
|
+
fileApi = {
|
|
26
|
+
getFileAttributesW: kernel32.func("uint32_t GetFileAttributesW(const char16_t *lpFileName)"),
|
|
27
|
+
getLastError: kernel32.func("uint32_t GetLastError(void)"),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const attributes = fileApi.getFileAttributesW(filePath);
|
|
31
|
+
const error = attributes === 0xffffffff ? fileApi.getLastError() : 0;
|
|
32
|
+
return { attributes, error };
|
|
33
|
+
}
|
|
34
|
+
module.exports = { getDriveConnection, getFileAttributes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FindExistingPathsOptions, PathMatch } from "./types.js";
|
|
2
2
|
export declare const MAX_LEVEL: number;
|
|
3
|
-
export declare function findExistingPaths(
|
|
4
|
-
export type { PathKind, PathLocation, PathMatch, PathPosition, SearchLevel, Variables, } from "./types.js";
|
|
3
|
+
export declare function findExistingPaths(options: FindExistingPathsOptions): Promise<PathMatch[]>;
|
|
4
|
+
export type { FindExistingPathsOptions, PathKind, PathLocation, PathMatch, PathPosition, SearchLevel, Variables, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasWindowsHiddenAttribute(filePath: string): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Candidate } from "
|
|
1
|
+
import type { Candidate } from "../types.js";
|
|
2
2
|
export declare function inventoryCandidates(text: string, roots: readonly string[], respectIgnore: boolean, searchHidden: boolean): Promise<Candidate[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SearchEntry } from "../types.js";
|
|
1
2
|
export declare function resolveSearchDirectories(directories: readonly string[]): Promise<string[]>;
|
|
2
|
-
export declare function listSearchEntries(root: string, respectIgnore: boolean, searchHidden: boolean): Promise<
|
|
3
|
+
export declare function listSearchEntries(root: string, respectIgnore: boolean, searchHidden: boolean): Promise<SearchEntry[]>;
|
|
3
4
|
export declare function filterSearchablePaths(paths: readonly string[], roots: readonly string[], respectIgnore: boolean, searchHidden: boolean): Promise<Set<string>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AhoCorasick } from "@monyone/aho-corasick";
|
|
1
2
|
export type SearchLevel = number;
|
|
2
3
|
export type PathKind = "directory" | "file";
|
|
3
4
|
export interface PathPosition {
|
|
@@ -14,9 +15,40 @@ export interface PathMatch {
|
|
|
14
15
|
path: string;
|
|
15
16
|
position: PathPosition;
|
|
16
17
|
}
|
|
18
|
+
export interface FindExistingPathsOptions {
|
|
19
|
+
directories: readonly string[];
|
|
20
|
+
level: SearchLevel;
|
|
21
|
+
respectIgnore?: boolean;
|
|
22
|
+
searchHidden?: boolean;
|
|
23
|
+
text: string;
|
|
24
|
+
variables?: Variables;
|
|
25
|
+
}
|
|
26
|
+
export interface InventoryPattern {
|
|
27
|
+
expectedKind: PathKind;
|
|
28
|
+
relative: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}
|
|
31
|
+
export interface InventoryMatcher {
|
|
32
|
+
entries: readonly (readonly SearchEntry[])[];
|
|
33
|
+
matcher: AhoCorasick;
|
|
34
|
+
patterns: Map<string, InventoryPattern>;
|
|
35
|
+
prefixes: readonly RootPrefix[];
|
|
36
|
+
respectIgnore: boolean;
|
|
37
|
+
roots: readonly string[];
|
|
38
|
+
searchHidden: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface RootPrefix {
|
|
41
|
+
root: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SearchEntry {
|
|
45
|
+
directory: boolean;
|
|
46
|
+
path: string;
|
|
47
|
+
}
|
|
17
48
|
export type CandidateKind = "explicit" | "heuristic" | "inventory" | "quoted" | "span";
|
|
18
49
|
export interface Candidate {
|
|
19
50
|
end: number;
|
|
51
|
+
expectedKind?: PathKind;
|
|
20
52
|
kind: CandidateKind;
|
|
21
53
|
start: number;
|
|
22
54
|
value: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PathKind } from "
|
|
1
|
+
import type { PathKind } from "../types.js";
|
|
2
2
|
export declare function classifyExistingPaths(paths: readonly string[], roots: readonly string[]): Promise<Map<string, PathKind>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Candidate, PathMatch, Variables } from "
|
|
1
|
+
import type { Candidate, PathMatch, Variables } from "../types.js";
|
|
2
2
|
export declare function validateCandidates(candidates: Candidate[], roots: readonly string[], variables: Variables, respectIgnore: boolean, searchHidden: boolean): Promise<PathMatch[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pathprobe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.7",
|
|
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": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"test:benchmark:bun": "bun quality/benchmark/run.mjs"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@monyone/aho-corasick": "latest",
|
|
30
31
|
"fast-glob": "latest",
|
|
31
32
|
"globby": "latest",
|
|
32
33
|
"koffi": "latest",
|