view-ignored 0.11.0 → 0.11.1

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 CHANGED
@@ -1,21 +1,15 @@
1
1
  <div align="center">
2
2
  <h1>view-ignored</h1>
3
3
 
4
- [![npm version](https://img.shields.io/npm/v/view-ignored.svg)](https://www.npmjs.com/package/view-ignored)
5
- [![npm downloads](https://img.shields.io/npm/dm/view-ignored.svg)](https://www.npmjs.com/package/view-ignored)
6
- ![node-v-18-or-later](https://img.shields.io/badge/node->=18-salad?repo=Mopsgamer/view-ignored)
7
- [![speed-fast](https://img.shields.io/badge/speed-fast-salad?repo=Mopsgamer/view-ignored)](https://github.com/Mopsgamer/view-ignored/tree/main/benchmarks)
8
-
9
- [![github issues](https://img.shields.io/github/issues/Mopsgamer/view-ignored.svg)](https://github.com/Mopsgamer/view-ignored/issues)
10
- [![github](https://img.shields.io/github/stars/Mopsgamer/view-ignored.svg)](https://github.com/Mopsgamer/view-ignored)
4
+ [![npm-version](https://img.shields.io/npm/v/view-ignored.svg)](https://www.npmjs.com/package/view-ignored)
5
+ [![npm-downloads](https://img.shields.io/npm/dm/view-ignored.svg)](https://www.npmjs.com/package/view-ignored)
6
+ ![node-v20-or-later](https://img.shields.io/badge/node->=22-salad?repo=Mopsgamer/view-ignored.svg)
7
+ ![ts-v5-or-later](https://img.shields.io/badge/ts->=5.7-salad?repo=Mopsgamer/view-ignored)
8
+ [![speed-fast](https://img.shields.io/badge/speed-fast-salad?repo=Mopsgamer/view-ignored.svg)](https://github.com/Mopsgamer/view-ignored/tree/main/benchmarks)
11
9
 
12
10
  Retrieve list of files ignored/included
13
11
  by Git, NPM, Yarn, JSR, Deno, Bun, VSCode extension CLI and other tools.
14
12
 
15
- ---
16
-
17
- ### `view-ignored` scans for
18
-
19
13
  <img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/git/git-original.svg" width="32" height="32" alt="git" />
20
14
  <img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/npm/npm-original-wordmark.svg" width="32" height="32" alt="npm" />
21
15
  <img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/yarn/yarn-original.svg" width="32" height="32" alt="yarn" />
@@ -24,11 +18,11 @@ by Git, NPM, Yarn, JSR, Deno, Bun, VSCode extension CLI and other tools.
24
18
  <img src="https://jsr.io/logo.svg" width="32" height="32" alt="jsr" />
25
19
  <img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/vscode/vscode-original.svg" width="32" height="32" alt="vsce" />
26
20
 
27
- and more!
28
-
29
- [![issues](https://img.shields.io/github/issues-search?query=repo%3AMopsgamer%2Fview-ignored%20label%3Atargets%20type%3Aissue&label=issues)](https://github.com/search?q=repo%3AMopsgamer%2Fview-ignored+label%3Atargets+type%3Aissue&type=issues&query=repo%3AMopsgamer%2Fview-ignored+label%3Atargets)
21
+ [![github-issues](https://img.shields.io/github/issues/Mopsgamer/view-ignored.svg)](https://github.com/Mopsgamer/view-ignored/issues)
22
+ [![github](https://img.shields.io/github/stars/Mopsgamer/view-ignored)](https://github.com/Mopsgamer/view-ignored)
23
+ [![issues-for-targets](https://img.shields.io/badge/issues-targets-blue)](https://github.com/search?q=repo%3AMopsgamer%2Fview-ignored+label%3Atargets+type%3Aissue&type=issues&query=repo%3AMopsgamer%2Fview-ignored+label%3Atargets)
30
24
  [![suggest](https://img.shields.io/badge/suggest-salad?repo=Mopsgamer/view-ignored)](https://github.com/Mopsgamer/view-ignored/issues/new)
31
- [![details](https://img.shields.io/badge/details-gray?repo=Mopsgamer/view-ignored)](#targets)
25
+ [![details](https://img.shields.io/badge/details-gray)](#targets)
32
26
 
33
27
  </div>
34
28
 
@@ -83,13 +77,14 @@ import * as vign from "view-ignored"
83
77
  // "/scan", "/stream"
84
78
  // "/browser", "/browser/scan", "/browser/stream"
85
79
  import { Git as target } from "view-ignored/targets"
80
+ import { RuleMatchKind } from "view-ignored/patterns"
86
81
 
87
82
  const ctx = await vign.scan({ target })
88
83
  ctx.paths.has(".git/HEAD") // false
89
84
  ctx.paths.has("src") // true
90
85
 
91
- const match = ctx.paths.get("src")
92
- if (match.kind === "external") {
86
+ const match = ctx.paths.get("src")!
87
+ if (match.kind === RuleMatchKind.external) {
93
88
  console.log(match.source.path) // ".gitignore"
94
89
  console.log(match.pattern) // "src/**"
95
90
  }
@@ -150,7 +145,7 @@ const stream = vign.scanStream({ target })
150
145
  stream.addEventListener("dirent", console.log)
151
146
  stream.addEventListener(
152
147
  "end",
153
- (ctx) => {
148
+ ({ detail: ctx }) => {
154
149
  ctx.paths.has(".git/HEAD")
155
150
  // false
156
151
  ctx.paths.has("node_modules/")
@@ -170,12 +165,13 @@ use the browser submodule, which requires some additional options.
170
165
 
171
166
  ```ts
172
167
  import * as vign from "view-ignored/browser"
173
- // or view-ignored/browser/scan
168
+ // or "/browser/scan"
174
169
  import { Git as target } from "view-ignored/targets"
170
+ import { readFile, readdir } from "original-fs"
175
171
 
176
172
  export const cwd = process.cwd()
177
- const customFs = { readdir, readFile }
178
- vign.scan({ target, cwd, fs })
173
+ const customFs = { readFile, readdir }
174
+ await vign.scan({ cwd, fs: customFs, target })
179
175
  ```
180
176
 
181
177
  ## Targets
@@ -1,68 +1,12 @@
1
- import type { Dirent } from "node:fs";
2
1
  import type { MatcherContext } from "../patterns/matcherContext.js";
3
2
  import type { ScanOptions, FsAdapter } from "../types.js";
4
- import type { RuleMatch } from "./rule.js";
5
- /**
6
- * Post-scan entry information.
7
- *
8
- * @since 0.6.0
9
- */
10
- export type EntryInfo = {
11
- /**
12
- * The relative path of the entry.
13
- *
14
- * @since 0.6.0
15
- */
16
- path: string;
17
- /**
18
- * The directory entry.
19
- *
20
- * @since 0.6.0
21
- */
22
- dirent: Dirent;
23
- /**
24
- * Whether the entry was ignored.
25
- *
26
- * @since 0.6.0
27
- */
28
- match: RuleMatch;
29
- };
30
- /**
31
- * @see {@link MatcherStream} uses it for the "dirent" event.
32
- *
33
- * @since 0.6.0
34
- */
35
- export type EntryListener = (info: EntryInfo) => void;
36
- /**
37
- * @see {@link MatcherStream} uses it for the "end" event.
38
- *
39
- * @since 0.6.0
40
- */
41
- export type EndListener = (ctx: MatcherContext) => void;
42
- /**
43
- * @see {@link MatcherStream} uses it for its event map.
44
- *
45
- * @since 0.6.0
46
- */
47
- export type EventMap = {
48
- dirent: CustomEvent<EntryInfo>;
49
- end: CustomEvent<MatcherContext>;
50
- };
51
- /**
52
- * @see {@link MatcherStream} uses it for its event map.
53
- *
54
- * @since 0.11.0
55
- */
56
- interface EventListener<K extends keyof EventMap> {
57
- (evt: EventMap[K]): void;
58
- }
59
- /**
60
- * @see {@link MatcherStream} uses it for its event map.
61
- *
62
- * @since 0.11.0
63
- */
64
- interface EventListenerObject<K extends keyof EventMap> {
65
- handleEvent(object: EventMap[K]): void;
3
+ import type { EventMap, EventListener, EventListenerObject } from "./matcherStreamTypes.js";
4
+ export type { EntryInfo, EntryListener, EndListener, EventMap } from "./matcherStreamTypes.js";
5
+ export interface AddEventListenerOptions {
6
+ capture?: boolean;
7
+ once?: boolean;
8
+ passive?: boolean;
9
+ signal?: AbortSignal;
66
10
  }
67
11
  /**
68
12
  * Event emitter.
@@ -76,11 +20,9 @@ export declare class MatcherStream extends EventTarget {
76
20
  fs: FsAdapter;
77
21
  cwd: string;
78
22
  noTimeout?: boolean;
79
- } & {
80
- captureRejections?: boolean;
81
23
  });
82
- addEventListener<K extends keyof EventMap>(type: K, callback: EventListenerObject<K> | EventListener<K>, options?: boolean | AddEventListenerOptions): void;
83
- removeEventListener<K extends keyof EventMap>(type: K, callback: EventListenerObject<K> | EventListener<K>, options?: boolean | EventListenerOptions): void;
24
+ addEventListener<K extends keyof EventMap>(type: K, callback: EventListenerObject<K> | EventListener<K> | null, options?: boolean | AddEventListenerOptions): void;
25
+ removeEventListener<K extends keyof EventMap>(type: K, callback: EventListenerObject<K> | EventListener<K> | null, options?: boolean | EventListenerOptions): void;
84
26
  dispatchEvent(event: EventMap[keyof EventMap]): boolean;
85
27
  /**
86
28
  * Resolves when everything is scanned.
@@ -95,4 +37,3 @@ export declare class MatcherStream extends EventTarget {
95
37
  */
96
38
  startCb(cb: (err: Error | null, ctx: MatcherContext) => void): void;
97
39
  }
98
- export {};
@@ -34,7 +34,12 @@ export class MatcherStream extends EventTarget {
34
34
  * @since 0.8.0
35
35
  */
36
36
  start() {
37
- const { promise, resolve, reject } = Promise.withResolvers();
37
+ let resolve;
38
+ let reject;
39
+ const promise = new Promise((res, rej) => {
40
+ resolve = res;
41
+ reject = rej;
42
+ });
38
43
  this.startCb((err) => {
39
44
  if (err) {
40
45
  reject(err);
@@ -0,0 +1,65 @@
1
+ import type { Dirent } from "node:fs";
2
+ import type { MatcherContext } from "./matcherContext.js";
3
+ import type { RuleMatch } from "./rule.js";
4
+ /**
5
+ * Post-scan entry information.
6
+ *
7
+ * @since 0.6.0
8
+ */
9
+ export type EntryInfo = {
10
+ /**
11
+ * The relative path of the entry.
12
+ *
13
+ * @since 0.6.0
14
+ */
15
+ path: string;
16
+ /**
17
+ * The directory entry.
18
+ *
19
+ * @since 0.6.0
20
+ */
21
+ dirent: Dirent;
22
+ /**
23
+ * Whether the entry was ignored.
24
+ *
25
+ * @since 0.6.0
26
+ */
27
+ match: RuleMatch;
28
+ };
29
+ /**
30
+ * @see {@link MatcherStream} uses it for the "dirent" event.
31
+ *
32
+ * @since 0.6.0
33
+ */
34
+ export type EntryListener = (info: EntryInfo) => void;
35
+ /**
36
+ * @see {@link MatcherStream} uses it for the "end" event.
37
+ *
38
+ * @since 0.6.0
39
+ */
40
+ export type EndListener = (ctx: MatcherContext) => void;
41
+ /**
42
+ * @see {@link MatcherStream} uses it for its event map.
43
+ *
44
+ * @since 0.6.0
45
+ */
46
+ export type EventMap = {
47
+ dirent: CustomEvent<EntryInfo>;
48
+ end: CustomEvent<MatcherContext>;
49
+ };
50
+ /**
51
+ * @see {@link MatcherStream} uses it for its event map.
52
+ *
53
+ * @since 0.11.0
54
+ */
55
+ export interface EventListener<K extends keyof EventMap> {
56
+ (evt: EventMap[K]): void;
57
+ }
58
+ /**
59
+ * @see {@link MatcherStream} uses it for its event map.
60
+ *
61
+ * @since 0.11.0
62
+ */
63
+ export interface EventListenerObject<K extends keyof EventMap> {
64
+ handleEvent(object: EventMap[K]): void;
65
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "view-ignored",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Retrieve list of files ignored/included by Git, NPM, Yarn, JSR, Deno, Bun, VSCode extension CLI and other tools.",
5
5
  "keywords": [
6
6
  ".gitignore",
@@ -76,7 +76,7 @@
76
76
  "access": "public"
77
77
  },
78
78
  "scripts": {
79
- "prerelease": "bun run test && bun run prod && bun run lint && bun run fmt --check && bun publint --pack bun --strict",
79
+ "prerelease": "bun run test && bun run prod && bun run lint && bun run fmt --check && bun run ts-compat && bun publint --pack bun --strict",
80
80
  "heap": "bun scripts/scanHeap.js --snapshot",
81
81
  "heap:node": "node scripts/scanHeap.js --snapshot",
82
82
  "cpu": "bun run --expose-gc --cpu-prof --cpu-prof-md --cpu-prof-name CPU.me scripts/scan.js --fastInternal",
@@ -95,6 +95,12 @@
95
95
  "check": "bun tsgo -p src --noEmit",
96
96
  "dev": "bun tsgo -p src",
97
97
  "prod": "rm -rf out && bun tsgo -p src/tsconfig.prod.json",
98
+ "node-compat": "bun node-compat-22 && bun node-compat-24",
99
+ "ts-compat": "bun run ts-compat-6 && bun run ts-compat-5",
100
+ "node-compat-24": "bun node_modules/typescript6/bin/tsc -p src/tsconfig.prod24.json --noEmit",
101
+ "node-compat-22": "bun node_modules/typescript6/bin/tsc -p src/tsconfig.prod22.json --noEmit",
102
+ "ts-compat-5": "bun node_modules/typescript5/bin/tsc -p src/tsconfig.prod.json --noEmit",
103
+ "ts-compat-6": "bun node_modules/typescript6/bin/tsc -p src/tsconfig.prod.json --noEmit",
98
104
  "release:major": "bun run --bun release-it --increment=major",
99
105
  "release:minor": "bun run --bun release-it --increment=minor",
100
106
  "release:patch": "bun run --bun release-it --increment=patch"
@@ -105,10 +111,13 @@
105
111
  },
106
112
  "devDependencies": {
107
113
  "@release-it/keep-a-changelog": "latest",
114
+ "@types/braces": "*",
108
115
  "@types/bun": "latest",
109
- "@types/ignore-walk": "^4.0.3",
110
- "@types/micromatch": "^4.0.10",
111
- "@types/node": "^18.19.130",
116
+ "@types/ignore-walk": "npm:@types/ignore-walk@^4.0.3",
117
+ "@types/micromatch": "npm:@types/micromatch@^4.0.10",
118
+ "@types/node": "npm:@types/node@latest",
119
+ "@types/node-22": "npm:@types/node@22.x",
120
+ "@types/node-24": "npm:@types/node@24.x",
112
121
  "@typescript/native-preview": "latest",
113
122
  "ignore-walk": "latest",
114
123
  "memfs": "latest",
@@ -117,9 +126,12 @@
117
126
  "oxlint": "latest",
118
127
  "oxlint-tsgolint": "latest",
119
128
  "publint": "latest",
120
- "release-it": "latest"
129
+ "release-it": "latest",
130
+ "typescript5": "npm:typescript@5.7.x",
131
+ "typescript6": "npm:typescript@6.x",
132
+ "undici-types": "*"
121
133
  },
122
134
  "engines": {
123
- "node": ">=18"
135
+ "node": ">=22"
124
136
  }
125
137
  }