From 23af981dae2d60dead0143b6713179c79beb84b6 Mon Sep 17 00:00:00 2001 From: SPGoding Date: Sat, 12 Oct 2024 00:58:43 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Moved=20FsWatcher=20to=20separat?= =?UTF-8?q?e=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/common/externals/BrowserExternals.ts | 8 +----- packages/core/src/common/externals/index.ts | 26 ------------------- packages/core/src/service/FsWatcher.ts | 25 ++++++++++++++++++ packages/core/src/service/Project.ts | 3 ++- packages/core/src/service/index.ts | 1 + 5 files changed, 29 insertions(+), 34 deletions(-) create mode 100644 packages/core/src/service/FsWatcher.ts diff --git a/packages/core/src/common/externals/BrowserExternals.ts b/packages/core/src/common/externals/BrowserExternals.ts index f14d0e3ad..bea1dc54e 100644 --- a/packages/core/src/common/externals/BrowserExternals.ts +++ b/packages/core/src/common/externals/BrowserExternals.ts @@ -6,13 +6,7 @@ import type { ExternalDownloaderOptions, RemoteUriString, } from './downloader.js' -import type { - ExternalEventEmitter, - ExternalFileSystem, - Externals, - FsLocation, - FsWatcher, -} from './index.js' +import type { ExternalEventEmitter, ExternalFileSystem, Externals, FsLocation } from './index.js' type Listener = (...args: unknown[]) => unknown class BrowserEventEmitter implements ExternalEventEmitter { diff --git a/packages/core/src/common/externals/index.ts b/packages/core/src/common/externals/index.ts index 789999b3b..5bdaabb54 100644 --- a/packages/core/src/common/externals/index.ts +++ b/packages/core/src/common/externals/index.ts @@ -86,29 +86,3 @@ export interface ExternalFileSystem { * A file URI string or a URI object. */ export type FsLocation = string | Uri - -/** - * A file system watcher that reports additions, changes, and deletions of files. - * Changes to directories should not be reported. - */ -export interface FsWatcher { - get isReady(): boolean - get watchedFiles(): Set - - on(eventName: 'ready', listener: () => unknown): this - once(eventName: 'ready', listener: () => unknown): this - - on(eventName: 'add', listener: (uri: string) => unknown): this - once(eventName: 'add', listener: (uri: string) => unknown): this - - on(eventName: 'change', listener: (uri: string) => unknown): this - once(eventName: 'change', listener: (uri: string) => unknown): this - - on(eventName: 'unlink', listener: (uri: string) => unknown): this - once(eventName: 'unlink', listener: (uri: string) => unknown): this - - on(eventName: 'error', listener: (error: Error) => unknown): this - once(eventName: 'error', listener: (error: Error) => unknown): this - - close(): Promise -} diff --git a/packages/core/src/service/FsWatcher.ts b/packages/core/src/service/FsWatcher.ts new file mode 100644 index 000000000..6b88d8bb2 --- /dev/null +++ b/packages/core/src/service/FsWatcher.ts @@ -0,0 +1,25 @@ +/** + * A file system watcher that reports additions, changes, and deletions of files. + * Changes to directories should not be reported. + */ +export interface FsWatcher { + get isReady(): boolean + get watchedFiles(): Set + + on(eventName: 'ready', listener: () => unknown): this + once(eventName: 'ready', listener: () => unknown): this + + on(eventName: 'add', listener: (uri: string) => unknown): this + once(eventName: 'add', listener: (uri: string) => unknown): this + + on(eventName: 'change', listener: (uri: string) => unknown): this + once(eventName: 'change', listener: (uri: string) => unknown): this + + on(eventName: 'unlink', listener: (uri: string) => unknown): this + once(eventName: 'unlink', listener: (uri: string) => unknown): this + + on(eventName: 'error', listener: (error: Error) => unknown): this + once(eventName: 'error', listener: (error: Error) => unknown): this + + close(): Promise +} diff --git a/packages/core/src/service/Project.ts b/packages/core/src/service/Project.ts index d766db2dd..458e6f019 100644 --- a/packages/core/src/service/Project.ts +++ b/packages/core/src/service/Project.ts @@ -2,7 +2,7 @@ import type { Ignore } from 'ignore' import ignore from 'ignore' import type { TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument' import { TextDocument } from 'vscode-languageserver-textdocument' -import type { ExternalEventEmitter, Externals, FsWatcher, IntervalId } from '../common/index.js' +import type { ExternalEventEmitter, Externals, IntervalId } from '../common/index.js' import { bufferToString, Logger, @@ -34,6 +34,7 @@ import { LinterErrorReporter } from './ErrorReporter.js' import { ArchiveUriSupporter, FileService, FileUriSupporter } from './FileService.js' import type { RootUriString } from './fileUtil.js' import { fileUtil } from './fileUtil.js' +import type { FsWatcher } from './FsWatcher.js' import { MetaRegistry } from './MetaRegistry.js' import { ProfilerFactory } from './Profiler.js' diff --git a/packages/core/src/service/index.ts b/packages/core/src/service/index.ts index 05abf06ae..a2e431b06 100644 --- a/packages/core/src/service/index.ts +++ b/packages/core/src/service/index.ts @@ -8,6 +8,7 @@ export * from './Downloader.js' export * from './ErrorReporter.js' export { FileService, UriProtocolSupporter } from './FileService.js' export * from './fileUtil.js' +export * from './FsWatcher.js' export * from './Hover.js' export * from './MetaRegistry.js' export * from './Profiler.js'