@atlaspack/fs 2.15.16-typescript-e99c742e9.0 → 2.15.16-typescript-5b4d3ad41.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.
@@ -0,0 +1,165 @@
1
+ import type { FilePath, FileSystem, FileOptions, ReaddirOptions, Encoding } from '@atlaspack/types-internal';
2
+ import type { Event, Options as WatcherOptions, AsyncSubscription } from '@parcel/watcher';
3
+ import { Readable, Writable } from 'stream';
4
+ import WorkerFarm, { Handle } from '@atlaspack/workers';
5
+ import EventEmitter from 'events';
6
+ type HandleFunction = (...args: Array<any>) => any;
7
+ type SerializedMemoryFS = {
8
+ id: number;
9
+ handle: any;
10
+ dirs: Map<FilePath, Directory>;
11
+ files: Map<FilePath, File>;
12
+ symlinks: Map<FilePath, FilePath>;
13
+ };
14
+ type WorkerEvent = {
15
+ type: 'writeFile' | 'unlink' | 'mkdir' | 'symlink';
16
+ path: FilePath;
17
+ entry?: Entry;
18
+ target?: FilePath;
19
+ };
20
+ type ResolveFunction = () => unknown;
21
+ export declare class MemoryFS implements FileSystem {
22
+ dirs: Map<FilePath, Directory>;
23
+ files: Map<FilePath, File>;
24
+ symlinks: Map<FilePath, FilePath>;
25
+ watchers: Map<FilePath, Set<Watcher>>;
26
+ events: Array<Event>;
27
+ id: number;
28
+ handle: Handle;
29
+ farm: WorkerFarm;
30
+ _cwd: FilePath;
31
+ _eventQueue: Array<Event>;
32
+ _watcherTimer: number;
33
+ _numWorkerInstances: number;
34
+ _workerHandles: Array<Handle>;
35
+ _workerRegisterResolves: Array<ResolveFunction>;
36
+ _emitter: EventEmitter;
37
+ constructor(workerFarm: WorkerFarm);
38
+ static deserialize(opts: SerializedMemoryFS): MemoryFS | WorkerFS;
39
+ serialize(): SerializedMemoryFS;
40
+ decrementWorkerInstance(): void;
41
+ cwd(): FilePath;
42
+ chdir(dir: FilePath): void;
43
+ _normalizePath(filePath: FilePath, realpath?: boolean): FilePath;
44
+ writeFile(filePath: FilePath, contents: Buffer | string, options?: FileOptions | null): Promise<void>;
45
+ readFile(filePath: FilePath, encoding?: Encoding): Promise<any>;
46
+ readFileSync(filePath: FilePath, encoding?: Encoding): any;
47
+ copyFile(source: FilePath, destination: FilePath): Promise<void>;
48
+ statSync(filePath: FilePath): Stat;
49
+ stat(filePath: FilePath): Promise<Stat>;
50
+ readdirSync(dir: FilePath, opts?: ReaddirOptions): any;
51
+ readdir(dir: FilePath, opts?: ReaddirOptions): Promise<any>;
52
+ unlink(filePath: FilePath): Promise<void>;
53
+ mkdirp(dir: FilePath): Promise<void>;
54
+ rimraf(filePath: FilePath): Promise<void>;
55
+ ncp(source: FilePath, destination: FilePath): Promise<void>;
56
+ createReadStream(filePath: FilePath): ReadStream;
57
+ createWriteStream(filePath: FilePath, options?: FileOptions | null): WriteStream;
58
+ realpathSync(filePath: FilePath): FilePath;
59
+ realpath(filePath: FilePath): Promise<FilePath>;
60
+ symlink(target: FilePath, path: FilePath): Promise<void>;
61
+ existsSync(filePath: FilePath): boolean;
62
+ exists(filePath: FilePath): Promise<boolean>;
63
+ _triggerEvent(event: Event): void;
64
+ _registerWorker(handle: Handle): void;
65
+ _sendWorkerEvent(event: WorkerEvent): Promise<void>;
66
+ watch(dir: FilePath, fn: (err: Error | null | undefined, events: Array<Event>) => unknown, opts: WatcherOptions): Promise<AsyncSubscription>;
67
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<Array<Event>>;
68
+ writeSnapshot(dir: FilePath, snapshot: FilePath): Promise<void>;
69
+ findAncestorFile(fileNames: Array<string>, fromDir: FilePath, root: FilePath): FilePath | null | undefined;
70
+ findNodeModule(moduleName: string, fromDir: FilePath): FilePath | null | undefined;
71
+ findFirstFile(filePaths: Array<FilePath>): FilePath | null | undefined;
72
+ }
73
+ declare class Watcher {
74
+ fn: (err: Error | null | undefined, events: Array<Event>) => unknown;
75
+ options: WatcherOptions;
76
+ constructor(fn: (err: Error | null | undefined, events: Array<Event>) => unknown, options: WatcherOptions);
77
+ trigger(events: Array<Event>): void;
78
+ }
79
+ export declare class FSError extends Error {
80
+ code: string;
81
+ path: FilePath;
82
+ constructor(code: string, path: FilePath, message: string);
83
+ }
84
+ declare class ReadStream extends Readable {
85
+ fs: FileSystem;
86
+ filePath: FilePath;
87
+ reading: boolean;
88
+ bytesRead: number;
89
+ constructor(fs: FileSystem, filePath: FilePath);
90
+ _read(): void;
91
+ }
92
+ declare class WriteStream extends Writable {
93
+ fs: FileSystem;
94
+ filePath: FilePath;
95
+ options: FileOptions | null | undefined;
96
+ buffer: Buffer;
97
+ constructor(fs: FileSystem, filePath: FilePath, options?: FileOptions | null);
98
+ _write(chunk: Buffer | string, encoding: any, callback: (error?: Error) => void): void;
99
+ _final(callback: (error?: Error) => void): void;
100
+ }
101
+ declare class Entry {
102
+ mode: number;
103
+ atime: number;
104
+ mtime: number;
105
+ ctime: number;
106
+ birthtime: number;
107
+ constructor(mode: number);
108
+ access(): void;
109
+ modify(mode: number): void;
110
+ getSize(): number;
111
+ stat(): Stat;
112
+ }
113
+ declare class Stat {
114
+ dev: number;
115
+ ino: number;
116
+ mode: number;
117
+ nlink: number;
118
+ uid: number;
119
+ gid: number;
120
+ rdev: number;
121
+ size: number;
122
+ blksize: number;
123
+ blocks: number;
124
+ atimeMs: number;
125
+ mtimeMs: number;
126
+ ctimeMs: number;
127
+ birthtimeMs: number;
128
+ atime: Date;
129
+ mtime: Date;
130
+ ctime: Date;
131
+ birthtime: Date;
132
+ constructor(entry: Entry);
133
+ isFile(): boolean;
134
+ isDirectory(): boolean;
135
+ isBlockDevice(): boolean;
136
+ isCharacterDevice(): boolean;
137
+ isSymbolicLink(): boolean;
138
+ isFIFO(): boolean;
139
+ isSocket(): boolean;
140
+ }
141
+ export declare class File extends Entry {
142
+ buffer: Buffer;
143
+ constructor(buffer: Buffer, mode: number);
144
+ read(): Buffer;
145
+ write(buffer: Buffer, mode: number): void;
146
+ getSize(): number;
147
+ }
148
+ declare class Directory extends Entry {
149
+ constructor();
150
+ }
151
+ export declare function makeShared(contents: Buffer | string): Buffer;
152
+ declare class WorkerFS extends MemoryFS {
153
+ id: number;
154
+ handleFn: HandleFunction;
155
+ constructor(id: number, handle: Handle);
156
+ static deserialize(opts: SerializedMemoryFS): MemoryFS;
157
+ serialize(): SerializedMemoryFS;
158
+ writeFile(filePath: FilePath, contents: Buffer | string, options?: FileOptions | null): Promise<void>;
159
+ unlink(filePath: FilePath): Promise<void>;
160
+ mkdirp(dir: FilePath): Promise<void>;
161
+ rimraf(filePath: FilePath): Promise<void>;
162
+ ncp(source: FilePath, destination: FilePath): Promise<void>;
163
+ symlink(target: FilePath, path: FilePath): Promise<void>;
164
+ }
165
+ export {};