@zenfs/core 0.12.5 → 0.12.6

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.
@@ -7,6 +7,7 @@ export declare class Dirent implements _Dirent {
7
7
  protected stats: Stats;
8
8
  get name(): string;
9
9
  constructor(path: string, stats: Stats);
10
+ get parentPath(): string;
10
11
  isFile(): boolean;
11
12
  isDirectory(): boolean;
12
13
  isBlockDevice(): boolean;
@@ -10,6 +10,9 @@ export class Dirent {
10
10
  this.path = path;
11
11
  this.stats = stats;
12
12
  }
13
+ get parentPath() {
14
+ return this.path;
15
+ }
13
16
  isFile() {
14
17
  return this.stats.isFile();
15
18
  }
@@ -0,0 +1,27 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import { EventEmitter } from 'eventemitter3';
5
+ import type { EventEmitter as NodeEventEmitter } from 'node:events';
6
+ import type * as fs from 'node:fs';
7
+ declare class Watcher<TEvents extends Record<string, unknown[]> = Record<string, unknown[]>> extends EventEmitter<TEvents> implements NodeEventEmitter {
8
+ off<T extends EventEmitter.EventNames<TEvents>>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined): this;
9
+ removeListener<T extends EventEmitter.EventNames<TEvents>>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined): this;
10
+ setMaxListeners(): never;
11
+ getMaxListeners(): never;
12
+ prependListener(): never;
13
+ prependOnceListener(): never;
14
+ rawListeners(): never;
15
+ ref(): this;
16
+ unref(): this;
17
+ }
18
+ export declare class FSWatcher extends Watcher<{
19
+ change: [eventType: string, filename: string | Buffer];
20
+ close: [];
21
+ error: [error: Error];
22
+ }> implements fs.FSWatcher {
23
+ close(): void;
24
+ }
25
+ export declare class StatWatcher extends Watcher implements fs.StatWatcher {
26
+ }
27
+ export {};
@@ -0,0 +1,38 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { ErrnoError } from '../error.js';
3
+ class Watcher extends EventEmitter {
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ off(event, fn, context, once) {
6
+ return super.off(event, fn, context, once);
7
+ }
8
+ removeListener(event, fn, context, once) {
9
+ return super.removeListener(event, fn, context, once);
10
+ }
11
+ /* eslint-enable @typescript-eslint/no-explicit-any */
12
+ setMaxListeners() {
13
+ throw ErrnoError.With('ENOTSUP');
14
+ }
15
+ getMaxListeners() {
16
+ throw ErrnoError.With('ENOTSUP');
17
+ }
18
+ prependListener() {
19
+ throw ErrnoError.With('ENOTSUP');
20
+ }
21
+ prependOnceListener() {
22
+ throw ErrnoError.With('ENOTSUP');
23
+ }
24
+ rawListeners() {
25
+ throw ErrnoError.With('ENOTSUP');
26
+ }
27
+ ref() {
28
+ return this;
29
+ }
30
+ unref() {
31
+ return this;
32
+ }
33
+ }
34
+ export class FSWatcher extends Watcher {
35
+ close() { }
36
+ }
37
+ export class StatWatcher extends Watcher {
38
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "description": "A filesystem in your browser",
5
5
  "main": "dist/index.js",
6
- "types": "src/index.ts",
6
+ "types": "dist/index.d.ts",
7
7
  "keywords": [
8
8
  "filesystem",
9
9
  "node",
@@ -46,9 +46,10 @@
46
46
  "prepublishOnly": "npm run build"
47
47
  },
48
48
  "dependencies": {
49
- "@types/node": "^20.12.5",
49
+ "@types/node": "^20.12.12",
50
50
  "@types/readable-stream": "^4.0.10",
51
51
  "buffer": "^6.0.3",
52
+ "eventemitter3": "^5.0.1",
52
53
  "minimatch": "^9.0.3",
53
54
  "readable-stream": "^4.5.2",
54
55
  "utilium": "^0.4.0"
@@ -16,6 +16,10 @@ export class Dirent implements _Dirent {
16
16
  protected stats: Stats
17
17
  ) {}
18
18
 
19
+ get parentPath(): string {
20
+ return this.path;
21
+ }
22
+
19
23
  isFile(): boolean {
20
24
  return this.stats.isFile();
21
25
  }
@@ -0,0 +1,57 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import type { EventEmitter as NodeEventEmitter } from 'node:events';
3
+ import type * as fs from 'node:fs';
4
+ import { ErrnoError } from '../error.js';
5
+
6
+ class Watcher<TEvents extends Record<string, unknown[]> = Record<string, unknown[]>> extends EventEmitter<TEvents> implements NodeEventEmitter {
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ public off<T extends EventEmitter.EventNames<TEvents>>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined): this {
9
+ return super.off<T>(event, fn as EventEmitter.EventListener<TEvents, T>, context, once);
10
+ }
11
+
12
+ public removeListener<T extends EventEmitter.EventNames<TEvents>>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined): this {
13
+ return super.removeListener<T>(event, fn as EventEmitter.EventListener<TEvents, T>, context, once);
14
+ }
15
+ /* eslint-enable @typescript-eslint/no-explicit-any */
16
+
17
+ public setMaxListeners(): never {
18
+ throw ErrnoError.With('ENOTSUP');
19
+ }
20
+
21
+ public getMaxListeners(): never {
22
+ throw ErrnoError.With('ENOTSUP');
23
+ }
24
+
25
+ public prependListener(): never {
26
+ throw ErrnoError.With('ENOTSUP');
27
+ }
28
+
29
+ public prependOnceListener(): never {
30
+ throw ErrnoError.With('ENOTSUP');
31
+ }
32
+
33
+ public rawListeners(): never {
34
+ throw ErrnoError.With('ENOTSUP');
35
+ }
36
+
37
+ public ref(): this {
38
+ return this;
39
+ }
40
+
41
+ public unref(): this {
42
+ return this;
43
+ }
44
+ }
45
+
46
+ export class FSWatcher
47
+ extends Watcher<{
48
+ change: [eventType: string, filename: string | Buffer];
49
+ close: [];
50
+ error: [error: Error];
51
+ }>
52
+ implements fs.FSWatcher
53
+ {
54
+ public close(): void {}
55
+ }
56
+
57
+ export class StatWatcher extends Watcher implements fs.StatWatcher {}