view-ignored 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +98 -41
  2. package/out/browser.d.ts +3 -0
  3. package/out/browser.js +2 -0
  4. package/out/browser_scan.d.ts +20 -0
  5. package/out/browser_scan.js +59 -0
  6. package/out/browser_stream.d.ts +12 -0
  7. package/out/browser_stream.js +51 -0
  8. package/out/getDepth.d.ts +4 -0
  9. package/out/getDepth.js +21 -0
  10. package/out/index.d.ts +3 -1
  11. package/out/index.js +2 -1
  12. package/out/normalizeCwd.d.ts +1 -0
  13. package/out/normalizeCwd.js +4 -0
  14. package/out/opendir.d.ts +3 -0
  15. package/out/opendir.js +18 -0
  16. package/out/patterns/extractor.d.ts +80 -0
  17. package/out/patterns/extractor.js +1 -0
  18. package/out/patterns/gitignore.d.ts +9 -3
  19. package/out/patterns/gitignore.js +13 -20
  20. package/out/patterns/ignores.d.ts +19 -0
  21. package/out/patterns/ignores.js +1 -0
  22. package/out/patterns/index.d.ts +13 -4
  23. package/out/patterns/index.js +13 -4
  24. package/out/patterns/jsrjson.d.ts +16 -4
  25. package/out/patterns/jsrjson.js +30 -13
  26. package/out/patterns/matcherContext.d.ts +71 -0
  27. package/out/patterns/matcherContext.js +1 -0
  28. package/out/patterns/matcherContextPatch.d.ts +16 -0
  29. package/out/patterns/matcherContextPatch.js +156 -0
  30. package/out/patterns/matcherStream.d.ts +64 -0
  31. package/out/patterns/matcherStream.js +9 -0
  32. package/out/patterns/packagejson.d.ts +9 -3
  33. package/out/patterns/packagejson.js +18 -7
  34. package/out/patterns/pattern.d.ts +44 -0
  35. package/out/patterns/pattern.js +21 -0
  36. package/out/patterns/patternMatcher.d.ts +23 -0
  37. package/out/patterns/patternMatcher.js +1 -0
  38. package/out/patterns/resolveSources.d.ts +34 -0
  39. package/out/patterns/resolveSources.js +135 -0
  40. package/out/patterns/signedPattern.d.ts +126 -0
  41. package/out/patterns/signedPattern.js +145 -0
  42. package/out/patterns/source.d.ts +57 -0
  43. package/out/patterns/source.js +20 -0
  44. package/out/patterns/stringCompile.d.ts +9 -0
  45. package/out/patterns/stringCompile.js +28 -0
  46. package/out/scan.d.ts +5 -37
  47. package/out/scan.js +8 -101
  48. package/out/stream.d.ts +9 -0
  49. package/out/stream.js +12 -0
  50. package/out/targets/git.d.ts +4 -1
  51. package/out/targets/git.js +26 -17
  52. package/out/targets/index.d.ts +6 -6
  53. package/out/targets/index.js +6 -6
  54. package/out/targets/jsr.d.ts +4 -1
  55. package/out/targets/jsr.js +34 -20
  56. package/out/targets/npm.d.ts +4 -1
  57. package/out/targets/npm.js +47 -40
  58. package/out/targets/target.d.ts +17 -3
  59. package/out/targets/vsce.d.ts +4 -1
  60. package/out/targets/vsce.js +30 -19
  61. package/out/targets/yarn.d.ts +4 -1
  62. package/out/targets/yarn.js +53 -43
  63. package/out/types.d.ts +116 -0
  64. package/out/types.js +1 -0
  65. package/out/walk.d.ts +12 -2
  66. package/out/walk.js +98 -13
  67. package/package.json +113 -78
  68. package/out/patterns/matcher.d.ts +0 -114
  69. package/out/patterns/matcher.js +0 -137
package/README.md CHANGED
@@ -10,19 +10,19 @@ by Git, NPM, Yarn, JSR, VSCE or other tools.
10
10
 
11
11
  ## Requirements
12
12
 
13
- - Node.js 18 or later for production
14
- - Node.js 20 or later for production type definitions
15
- - Node.js 22 or later for development type definitions
13
+ Node.js 18 or later
16
14
 
17
15
  ## Highlights
18
16
 
19
- - **Native.** Get a list of included files using configuration file
17
+ - **Reader.** Get a list of included files using configuration file
20
18
  readers, not command-line wrappers.
21
19
  - **Plugins.** Built-in [targets](#targets) for popular tools. Use custom
22
- targets by implementing the `Target` interface.
20
+ targets by implementing/extending the `Target` interface.
23
21
  - **TypeScript.** Written in TypeScript with type definitions included.
24
22
  - **Lightweight.** Minimal dependencies for fast performance and small bundle size.
25
23
  - **Easy-to-modify.** Well-written and MIT-licensed.
24
+ - **Browser.** Can be bundled for browser use. See `ScanOptions.fs` and `import ... "view-ignored/browser"`.
25
+ - **Windows.** Windows paths are converted to Unix paths for compatibility with `memfs` based tests and browsers.
26
26
 
27
27
  > [!NOTE]
28
28
  > Despite the name of the package being "view-ignored",
@@ -36,51 +36,99 @@ by Git, NPM, Yarn, JSR, VSCE or other tools.
36
36
  ### Basic example
37
37
 
38
38
  ```ts
39
- import * as vign from "view-ignored";
40
- import { Git } from "view-ignored/targets";
39
+ import * as vign from "view-ignored"
40
+ import { Git as target } from "view-ignored/targets"
41
41
 
42
- const results = await vign.scan({ target: Git });
43
- results.paths.has(".git/HEAD");
42
+ const ctx = await vign.scan({ target })
43
+ ctx.paths.has(".git/HEAD") // false
44
+ ctx.paths.has("src") // true
45
+
46
+ ctx.paths.get("src") // { ignored, match, kind, ... }
44
47
  ```
45
48
 
46
49
  ### Using custom target
47
50
 
48
51
  ```ts
49
- import * as vign from "view-ignored";
50
52
  import {
51
- type SourceExtractor,
52
- type SignedPattern,
53
- extractGitignore
54
- findAndExtract,
55
- signedPatternIgnores,
56
- } from "view-ignored/patterns";
57
- import type { Target } from "view-ignored/targets";
58
-
59
- const gitSources = ['.gitignore'];
60
- const gitSourceMap = new Map<string, SourceExtractor>([
61
- ['.gitignore', extractGitignore]
62
- ]);
63
- const gitPattern: SignedPattern = {
64
- exclude: [
65
- '.git',
66
- '.DS_Store',
67
- ],
68
- include: []
69
- };
53
+ type Extractor,
54
+ extractGitignore,
55
+ signedPatternIgnores,
56
+ signedPatternCompile,
57
+ type SignedPattern,
58
+ } from "view-ignored/patterns"
59
+
60
+ import type { Target } from "view-ignored/targets"
61
+
62
+ const extractors: Extractor[] = [
63
+ {
64
+ extract: extractGitignore,
65
+ path: ".gitignore",
66
+ },
67
+ {
68
+ extract: extractGitignore,
69
+ path: ".git/info/exclude",
70
+ },
71
+ ]
72
+
73
+ const internal: SignedPattern = {
74
+ exclude: [".git", ".DS_Store"],
75
+ include: [],
76
+ compiled: null,
77
+ }
78
+
79
+ signedPatternCompile(internal)
70
80
 
71
81
  export const Git: Target = {
72
- async matcher(entry, isDir, ctx) {
73
- if (isDir) {
74
- await findAndExtract(entry, gitSources, gitSourceMap, ctx);
75
- return true;
76
- }
77
- return await signedPatternIgnores(gitPattern, entry, gitSources, gitSourceMap, ctx);
78
- }
79
- };
82
+ extractors,
83
+ ignores(o) {
84
+ return signedPatternIgnores({
85
+ ...o,
86
+ internal,
87
+ root: "/",
88
+ target: Git,
89
+ })
90
+ },
91
+ }
92
+
93
+ const ctx = await vign.scan({ target })
94
+ ```
95
+
96
+ ### Streaming results
97
+
98
+ ```ts
99
+ import * as vign from "view-ignored"
100
+ import { NPM as target } from "view-ignored/targets"
101
+
102
+ const stream = await vign.scanStream({ target })
103
+
104
+ stream.on("dirent", console.log)
105
+ stream.on("end", (ctx) => {
106
+ ctx.paths.has(".git/HEAD") // false
107
+ ctx.paths.has("node_modules/") // false
108
+ ctx.paths.has("package.json") // true
109
+ })
80
110
  ```
81
111
 
112
+ ### Browser and custom FS
113
+
114
+ To avoid imports from `node:fs` and `node:process` modules,
115
+ use the browser submodule, which requires some additional options.
116
+
82
117
  ```ts
83
- vign.scan({ target: Git });
118
+ import * as vign from "view-ignored/browser"
119
+ // or view-ignored/browser/scan
120
+ import { Git as target } from "view-ignored/targets"
121
+
122
+ export const cwd = process.cwd()
123
+
124
+ const customFs = {
125
+ promises: {
126
+ opendir,
127
+ readFile,
128
+ },
129
+ }
130
+
131
+ vign.scan({ target, cwd, fs })
84
132
  ```
85
133
 
86
134
  ## Targets
@@ -92,25 +140,34 @@ vign.scan({ target: Git });
92
140
  The following built-in scanners are available:
93
141
 
94
142
  - Git
95
- - Reads `.gitignore` files but does not consider global settings.
96
- - Check this scanner by running `git ls-tree -r HEAD --name-only`.
143
+ - Reads `.gitignore` and `.git/info/exclude` but does not consider global settings.
144
+ - Starts searching from `/`.
145
+ - Check this scanner by running `git ls-files --others --exclude-standard --cached`.
97
146
  - See the implementation of [Git target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/git.ts) for details.
98
147
  - NPM (compatible with Bun, PNPM, and others)
99
148
  - Reads `.npmignore` and `package.json` `files` field.
149
+ - Starts searching from `.` (current working directory).
100
150
  - No additional checks for `name`, `version` or `publishConfig`.
101
151
  - Check this scanner by running `npm pack --dry-run`.
102
152
  - See the implementation of [NPM target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/npm.ts) for details.
103
153
  - Yarn
104
154
  - Same behavior as `npm`, but also reads `.yarnignore`.
155
+ - Starts searching from `.` (current working directory).
105
156
  - See the implementation of [Yarn target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarn.ts) for details.
106
157
  - VSCE
107
- - Reads `.vscodeignore` and `package.json` `files` field.
158
+ - Reads `package.json` `files` field, `.vscodeignore` and `.gitignore`.
159
+ - Starts searching from `.` (current working directory).
108
160
  - Check this scanner by running `vsce ls`.
109
161
  - See the implementation of [VSCE target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/vsce.ts) for details.
110
162
  - JSR (compatible with Deno)
111
163
  - Reads `jsr.json(c)` and `deno.json(c)` `include` and `exclude` fields.
164
+ - Starts searching from `.` (current working directory).
112
165
  - See the implementation of [JSR target](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/jsr.ts) for details.
113
166
 
167
+ ## See also
168
+
169
+ - https://jsr.io/@m234/path - Utility to sort, convert and format paths.
170
+
114
171
  ## License
115
172
 
116
173
  MIT License. See [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,3 @@
1
+ export { scan } from "./browser_scan.js";
2
+ export { scanStream as stream } from "./browser_stream.js";
3
+ export type * from "./types.js";
package/out/browser.js ADDED
@@ -0,0 +1,2 @@
1
+ export { scan } from "./browser_scan.js";
2
+ export { scanStream as stream } from "./browser_stream.js";
@@ -0,0 +1,20 @@
1
+ import type { MatcherContext } from "./patterns/matcherContext.js";
2
+ import type { ScanOptions, FsAdapter } from "./types.js";
3
+ export type * from "./types.js";
4
+ /**
5
+ * Scan the directory for included files based on the provided targets.
6
+ *
7
+ * Note that this function uses `fs/promises.readFile` and `fs/promises.opendir` without options within
8
+ * custom recursion, instead of `fs.promises.readdir` with `{ withFileTypes: true }.
9
+ * It also normalizes paths to use forward slashes.
10
+ * Please report any issues if you encounter problems related to this behavior.
11
+ *
12
+ * @param options Scan options.
13
+ * @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
14
+ *
15
+ * @since 0.6.0
16
+ */
17
+ export declare function scan(options: ScanOptions & {
18
+ fs: FsAdapter;
19
+ cwd: string;
20
+ }): Promise<MatcherContext>;
@@ -0,0 +1,59 @@
1
+ import { resolve } from "node:path";
2
+ import { relative } from "node:path/posix";
3
+ import { normalizeCwd } from "./normalizeCwd.js";
4
+ import { opendir } from "./opendir.js";
5
+ import { walkIncludes } from "./walk.js";
6
+ /**
7
+ * Scan the directory for included files based on the provided targets.
8
+ *
9
+ * Note that this function uses `fs/promises.readFile` and `fs/promises.opendir` without options within
10
+ * custom recursion, instead of `fs.promises.readdir` with `{ withFileTypes: true }.
11
+ * It also normalizes paths to use forward slashes.
12
+ * Please report any issues if you encounter problems related to this behavior.
13
+ *
14
+ * @param options Scan options.
15
+ * @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
16
+ *
17
+ * @since 0.6.0
18
+ */
19
+ export function scan(options) {
20
+ const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = options;
21
+ if (maxDepth < 0) {
22
+ throw new TypeError("Depth must be a non-negative integer");
23
+ }
24
+ const ctx = {
25
+ paths: new Map(),
26
+ external: new Map(),
27
+ failed: [],
28
+ depthPaths: new Map(),
29
+ totalFiles: 0,
30
+ totalMatchedFiles: 0,
31
+ totalDirs: 0,
32
+ };
33
+ const normalCwd = normalizeCwd(cwd);
34
+ const scanOptions = {
35
+ cwd: normalCwd,
36
+ within,
37
+ depth: maxDepth,
38
+ fastDepth,
39
+ fastInternal,
40
+ fs,
41
+ invert,
42
+ signal,
43
+ target,
44
+ };
45
+ const result = opendir(fs, normalizeCwd(resolve(normalCwd, within)), (entry) => {
46
+ const path = relative(normalCwd, normalizeCwd(entry.parentPath) + "/" + entry.name);
47
+ return walkIncludes({
48
+ path,
49
+ entry,
50
+ ctx,
51
+ stream: undefined,
52
+ scanOptions,
53
+ });
54
+ });
55
+ return (async () => {
56
+ await result;
57
+ return ctx;
58
+ })();
59
+ }
@@ -0,0 +1,12 @@
1
+ import { MatcherStream } from "./patterns/matcherStream.js";
2
+ import type { ScanOptions, FsAdapter } from "./types.js";
3
+ export type * from "./types.js";
4
+ /**
5
+ * @see {@link browserScan}
6
+ *
7
+ * @since 0.6.0
8
+ */
9
+ export declare function scanStream(options: ScanOptions & {
10
+ fs: FsAdapter;
11
+ cwd: string;
12
+ }): MatcherStream;
@@ -0,0 +1,51 @@
1
+ import { resolve } from "node:path";
2
+ import { relative } from "node:path/posix";
3
+ import { normalizeCwd } from "./normalizeCwd.js";
4
+ import { opendir } from "./opendir.js";
5
+ import { MatcherStream } from "./patterns/matcherStream.js";
6
+ import { walkIncludes } from "./walk.js";
7
+ /**
8
+ * @see {@link browserScan}
9
+ *
10
+ * @since 0.6.0
11
+ */
12
+ export function scanStream(options) {
13
+ const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = options;
14
+ const ctx = {
15
+ paths: new Map(),
16
+ external: new Map(),
17
+ failed: [],
18
+ depthPaths: new Map(),
19
+ totalFiles: 0,
20
+ totalMatchedFiles: 0,
21
+ totalDirs: 0,
22
+ };
23
+ const stream = new MatcherStream({ captureRejections: false });
24
+ const normalCwd = normalizeCwd(cwd);
25
+ const scanOptions = {
26
+ cwd: normalCwd,
27
+ within,
28
+ depth: maxDepth,
29
+ fastDepth,
30
+ fastInternal,
31
+ fs,
32
+ invert,
33
+ signal,
34
+ target,
35
+ };
36
+ const result = opendir(fs, normalizeCwd(resolve(normalCwd, within)), (entry) => {
37
+ const path = relative(normalCwd, normalizeCwd(entry.parentPath) + "/" + entry.name);
38
+ return walkIncludes({
39
+ path,
40
+ entry,
41
+ ctx,
42
+ stream,
43
+ scanOptions,
44
+ });
45
+ });
46
+ void (async () => {
47
+ await result;
48
+ stream.emit("end", ctx);
49
+ })();
50
+ return stream;
51
+ }
@@ -0,0 +1,4 @@
1
+ export declare function getDepth(path: string, maxDepth: number): {
2
+ depth: number;
3
+ depthSlash: number;
4
+ };
@@ -0,0 +1,21 @@
1
+ export function getDepth(path, maxDepth) {
2
+ if (path.endsWith("/")) {
3
+ path = path.substring(0, path.length - 1);
4
+ }
5
+ const result = {
6
+ depth: 0,
7
+ depthSlash: -1,
8
+ };
9
+ let i = -1;
10
+ for (const c of path) {
11
+ i++;
12
+ if (c !== "/") {
13
+ continue;
14
+ }
15
+ if (result.depth === maxDepth) {
16
+ result.depthSlash = i;
17
+ }
18
+ result.depth++;
19
+ }
20
+ return result;
21
+ }
package/out/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export * from './scan.js';
1
+ export { scan } from "./scan.js";
2
+ export { scanStream } from "./stream.js";
3
+ export type * from "./types.js";
package/out/index.js CHANGED
@@ -1 +1,2 @@
1
- export * from './scan.js';
1
+ export { scan } from "./scan.js";
2
+ export { scanStream } from "./stream.js";
@@ -0,0 +1 @@
1
+ export declare function normalizeCwd(cwd: string): string;
@@ -0,0 +1,4 @@
1
+ import { resolve } from "node:path";
2
+ export function normalizeCwd(cwd) {
3
+ return resolve(cwd).replaceAll("\\", "/").replace(/\w:/, "");
4
+ }
@@ -0,0 +1,3 @@
1
+ import type { Dirent, PathLike } from "node:fs";
2
+ import type { FsAdapter } from "./types.js";
3
+ export declare function opendir(fs: FsAdapter, path: PathLike, cb: (entry: Dirent) => Promise<0 | 1 | 2>): Promise<void | 2>;
package/out/opendir.js ADDED
@@ -0,0 +1,18 @@
1
+ export async function opendir(fs, path, cb) {
2
+ const dir = await fs.promises.opendir(path);
3
+ for await (const entry of dir) {
4
+ const r = await cb(entry);
5
+ if (r === 2) {
6
+ return 2;
7
+ }
8
+ if (r === 1) {
9
+ continue;
10
+ }
11
+ if (entry.isDirectory()) {
12
+ const r = await opendir(fs, path + "/" + entry.name, cb);
13
+ if (r === 2) {
14
+ return 2;
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,80 @@
1
+ import type { Target } from "../targets/target.js";
2
+ import type { FsAdapter } from "../types.js";
3
+ import type { MatcherContext } from "./matcherContext.js";
4
+ import type { Source } from "./source.js";
5
+ /**
6
+ * Populates the source object from the content of a source file.
7
+ * Results are available in `ctx.external`.
8
+ * If `"none"` returned or throwed, will skip the extractor.
9
+ *
10
+ * @see {@link Source.pattern} for more details.
11
+ * @throws Error if extraction fails. Processing stops.
12
+ *
13
+ * @since 0.6.0
14
+ */
15
+ export type ExtractorFn = (source: Source, content: Buffer, ctx: MatcherContext) => void | "none";
16
+ /**
17
+ * Defines a method for extracting patterns from a specific source file.
18
+ *
19
+ * @since 0.6.0
20
+ */
21
+ export interface Extractor {
22
+ /**
23
+ * Relative path.
24
+ *
25
+ * @example
26
+ * ".gitignore"
27
+ *
28
+ * @since 0.6.0
29
+ */
30
+ path: string;
31
+ /**
32
+ * Populates the source object from the content of a source file.
33
+ *
34
+ * @see {@link ExtractorFn}
35
+ *
36
+ * @since 0.6.0
37
+ */
38
+ extract: ExtractorFn;
39
+ }
40
+ /**
41
+ * Options for finding and extracting patterns from source files.
42
+ *
43
+ * @see {@link resolveSources}
44
+ * @see {@link signedPatternIgnores}
45
+ *
46
+ * @since 0.6.0
47
+ */
48
+ export interface PatternFinderOptions {
49
+ /**
50
+ * The file system adapter for directory walking and reading files.
51
+ *
52
+ * @since 0.6.0
53
+ */
54
+ fs: FsAdapter;
55
+ /**
56
+ * The context to modify.
57
+ *
58
+ * @since 0.6.0
59
+ */
60
+ ctx: MatcherContext;
61
+ /**
62
+ * The current working directory.
63
+ *
64
+ * @since 0.6.0
65
+ */
66
+ cwd: string;
67
+ /**
68
+ * The target implementation.
69
+ *
70
+ * @since 0.6.0
71
+ */
72
+ target: Target;
73
+ /**
74
+ * Initial search directory.
75
+ * Relative to the `cwd` path or absolute path.
76
+ *
77
+ * @since 0.6.0
78
+ */
79
+ root: string;
80
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,9 @@
1
- import { type Source } from './matcher.js';
2
- export declare function extractGitignore(source: Source, content: Buffer<ArrayBuffer>): void;
3
- export declare function gitignoreMatch(pattern: string, path: string): boolean;
1
+ import { type Source } from "./source.js";
2
+ /**
3
+ * Extracts and compiles patterns from the file.
4
+ *
5
+ * @see {@link signedPatternCompile}
6
+ *
7
+ * @since 0.6.0
8
+ */
9
+ export declare function extractGitignore(source: Source, content: Buffer): void;
@@ -1,31 +1,24 @@
1
- import { sourcePushNegatable } from './matcher.js';
2
- import { minimatch } from 'minimatch';
1
+ import { signedPatternCompile } from "./resolveSources.js";
2
+ import { sourcePushNegatable } from "./source.js";
3
+ /**
4
+ * Extracts and compiles patterns from the file.
5
+ *
6
+ * @see {@link signedPatternCompile}
7
+ *
8
+ * @since 0.6.0
9
+ */
3
10
  export function extractGitignore(source, content) {
4
- for (let line of content.toString().split('\n')) {
11
+ for (let line of content.toString().split("\n")) {
5
12
  line = line.trim();
6
- if (line === '' || line.startsWith('#')) {
13
+ if (line === "" || line.startsWith("#")) {
7
14
  continue;
8
15
  }
9
- const cdx = line.indexOf('#');
16
+ const cdx = line.indexOf("#");
10
17
  if (cdx >= 0) {
11
18
  line = line.substring(-cdx);
12
19
  }
13
20
  sourcePushNegatable(source, line);
14
21
  }
15
- // TODO: validate gitignore
22
+ signedPatternCompile(source.pattern);
16
23
  }
17
24
  extractGitignore;
18
- export function gitignoreMatch(pattern, path) {
19
- const o = { dot: true };
20
- if (pattern.startsWith('/')) {
21
- pattern = pattern.substring(1);
22
- }
23
- else if (!pattern.startsWith('**/')) {
24
- if (minimatch(path, '**/' + pattern, o))
25
- return true;
26
- }
27
- if (pattern.endsWith('/')) {
28
- pattern = pattern.substring(-1);
29
- }
30
- return minimatch(path, pattern, o) || minimatch(path, pattern + '/**', o);
31
- }
@@ -0,0 +1,19 @@
1
+ import type { MatcherContext } from "../patterns/matcherContext.js";
2
+ import type { SignedPatternMatch } from "../patterns/signedPattern.js";
3
+ import type { FsAdapter } from "../types.js";
4
+ export interface IgnoresOptions {
5
+ fs: FsAdapter;
6
+ cwd: string;
7
+ entry: string;
8
+ ctx: MatcherContext;
9
+ }
10
+ /**
11
+ * Checks whether a given entry path should be ignored based on its patterns.
12
+ *
13
+ * @see {@link resolveSources}
14
+ * @see {@link signedPatternIgnores}
15
+ * @see {@link https://github.com/Mopsgamer/view-ignored/tree/main/src/targets} for usage examples.
16
+ *
17
+ * @since 0.6.0
18
+ */
19
+ export type Ignores = (options: IgnoresOptions) => Promise<SignedPatternMatch>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,13 @@
1
- export * from './matcher.js';
2
- export * from './gitignore.js';
3
- export * from './jsrjson.js';
4
- export * from './packagejson.js';
1
+ export * from "./extractor.js";
2
+ export * from "./gitignore.js";
3
+ export * from "./ignores.js";
4
+ export * from "./jsrjson.js";
5
+ export * from "./matcherContext.js";
6
+ export * from "./matcherContextPatch.js";
7
+ export * from "./matcherStream.js";
8
+ export * from "./packagejson.js";
9
+ export * from "./pattern.js";
10
+ export * from "./patternMatcher.js";
11
+ export * from "./resolveSources.js";
12
+ export * from "./signedPattern.js";
13
+ export * from "./source.js";
@@ -1,4 +1,13 @@
1
- export * from './matcher.js';
2
- export * from './gitignore.js';
3
- export * from './jsrjson.js';
4
- export * from './packagejson.js';
1
+ export * from "./extractor.js";
2
+ export * from "./gitignore.js";
3
+ export * from "./ignores.js";
4
+ export * from "./jsrjson.js";
5
+ export * from "./matcherContext.js";
6
+ export * from "./matcherContextPatch.js";
7
+ export * from "./matcherStream.js";
8
+ export * from "./packagejson.js";
9
+ export * from "./pattern.js";
10
+ export * from "./patternMatcher.js";
11
+ export * from "./resolveSources.js";
12
+ export * from "./signedPattern.js";
13
+ export * from "./source.js";
@@ -1,4 +1,16 @@
1
- import { type } from 'arktype';
2
- import type { Source } from './matcher.js';
3
- export declare function extractJsrJson(source: Source, content: Buffer<ArrayBuffer>): type.errors | undefined;
4
- export declare function extractJsrJsonc(source: Source, content: Buffer<ArrayBuffer>): type.errors | undefined;
1
+ import type { MatcherContext } from "./matcherContext.js";
2
+ import type { Source } from "./source.js";
3
+ /**
4
+ * Extracts and compiles patterns from the file.
5
+ *
6
+ * @since 0.6.0
7
+ */
8
+ export declare function extractJsrJson(source: Source, content: Buffer, ctx: MatcherContext): void;
9
+ /**
10
+ * Extracts and compiles patterns from the file.
11
+ *
12
+ * @see {@link signedPatternCompile}
13
+ *
14
+ * @since 0.6.0
15
+ */
16
+ export declare function extractJsrJsonc(source: Source, content: Buffer, ctx: MatcherContext): void;