feat(native): provide FSWatcher

This commit is contained in:
LongYinan
2023-05-10 17:16:48 +08:00
parent ee1e50f391
commit e54a5b6128
23 changed files with 1215 additions and 788 deletions

View File

@@ -3,18 +3,42 @@
/* auto-generated by NAPI-RS */
export class Storage {
constructor(path: string);
error(): string | null;
getBlob(workspaceId: string | undefined | null, id: string): Promise<Buffer>;
connect(workspaceId: string, remote: string): Workspace | null;
sync(workspaceId: string, remote: string): Workspace;
export interface WatchOptions {
recursive?: boolean;
}
export class Workspace {
constructor(id: string);
id(): string;
clientId(): number;
search(query: string): string;
getSearchIndex(): Array<string>;
setSearchIndex(fields: Array<string>): boolean;
/** Watcher kind enumeration */
export const enum WatcherKind {
/** inotify backend (linux) */
Inotify = 'Inotify',
/** FS-Event backend (mac) */
Fsevent = 'Fsevent',
/** KQueue backend (bsd,optionally mac) */
Kqueue = 'Kqueue',
/** Polling based backend (fallback) */
PollWatcher = 'PollWatcher',
/** Windows backend */
ReadDirectoryChangesWatcher = 'ReadDirectoryChangesWatcher',
/** Fake watcher for testing */
NullWatcher = 'NullWatcher',
Unknown = 'Unknown',
}
export function watch(
p: string,
options?: WatchOptions | undefined | null
): FSWatcher;
export class Subscription {
unsubscribe(): void;
}
export type FSWatcher = FsWatcher;
export class FsWatcher {
get kind(): WatcherKind;
toString(): string;
subscribe(
callback: (value: any) => any,
errorCallback?: (
err: Error | null,
value: undefined
) => any | undefined | null
): Subscription;
close(): void;
}