@theia/filesystem 1.26.0-next.4 → 1.26.0-next.44

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.
Files changed (70) hide show
  1. package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.d.ts +1 -2
  2. package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.d.ts.map +1 -1
  3. package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.js +3 -4
  4. package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.js.map +1 -1
  5. package/lib/browser/file-service.d.ts +5 -0
  6. package/lib/browser/file-service.d.ts.map +1 -1
  7. package/lib/browser/file-service.js +5 -0
  8. package/lib/browser/file-service.js.map +1 -1
  9. package/lib/browser/file-tree/file-tree-decorator-adapter.d.ts +1 -1
  10. package/lib/browser/file-tree/file-tree-decorator-adapter.js +1 -1
  11. package/lib/browser/file-tree/file-tree-widget.js +1 -1
  12. package/lib/browser/file-tree/file-tree-widget.js.map +1 -1
  13. package/lib/browser/file-tree/file-tree.d.ts +1 -2
  14. package/lib/browser/file-tree/file-tree.d.ts.map +1 -1
  15. package/lib/browser/file-tree/file-tree.js.map +1 -1
  16. package/lib/browser/filesystem-frontend-module.d.ts.map +1 -1
  17. package/lib/browser/filesystem-frontend-module.js +0 -165
  18. package/lib/browser/filesystem-frontend-module.js.map +1 -1
  19. package/lib/browser/index.d.ts +0 -1
  20. package/lib/browser/index.d.ts.map +1 -1
  21. package/lib/browser/index.js +0 -1
  22. package/lib/browser/index.js.map +1 -1
  23. package/lib/browser/location/location-renderer.js +2 -2
  24. package/lib/browser/location/location-renderer.js.map +1 -1
  25. package/lib/common/files.d.ts +13 -4
  26. package/lib/common/files.d.ts.map +1 -1
  27. package/lib/common/files.js.map +1 -1
  28. package/lib/common/filesystem-utils.spec.js +49 -49
  29. package/lib/common/filesystem-utils.spec.js.map +1 -1
  30. package/lib/common/filesystem-watcher-protocol.d.ts +1 -22
  31. package/lib/common/filesystem-watcher-protocol.d.ts.map +1 -1
  32. package/lib/common/filesystem-watcher-protocol.js +1 -68
  33. package/lib/common/filesystem-watcher-protocol.js.map +1 -1
  34. package/lib/common/filesystem.d.ts +0 -229
  35. package/lib/common/filesystem.d.ts.map +1 -1
  36. package/lib/common/filesystem.js +1 -51
  37. package/lib/common/filesystem.js.map +1 -1
  38. package/lib/common/remote-file-system-provider.d.ts +9 -9
  39. package/lib/common/remote-file-system-provider.d.ts.map +1 -1
  40. package/lib/common/remote-file-system-provider.js +9 -10
  41. package/lib/common/remote-file-system-provider.js.map +1 -1
  42. package/package.json +3 -3
  43. package/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts +1 -2
  44. package/src/browser/file-service.ts +5 -0
  45. package/src/browser/file-tree/file-tree-decorator-adapter.ts +1 -1
  46. package/src/browser/file-tree/file-tree-widget.tsx +1 -1
  47. package/src/browser/file-tree/file-tree.ts +1 -2
  48. package/src/browser/filesystem-frontend-module.ts +0 -162
  49. package/src/browser/index.ts +0 -1
  50. package/src/browser/location/location-renderer.tsx +2 -2
  51. package/src/common/files.ts +13 -4
  52. package/src/common/filesystem-utils.spec.ts +1 -1
  53. package/src/common/filesystem-watcher-protocol.ts +1 -67
  54. package/src/common/filesystem.ts +0 -262
  55. package/src/common/remote-file-system-provider.ts +18 -19
  56. package/lib/browser/filesystem-watcher.d.ts +0 -134
  57. package/lib/browser/filesystem-watcher.d.ts.map +0 -1
  58. package/lib/browser/filesystem-watcher.js +0 -240
  59. package/lib/browser/filesystem-watcher.js.map +0 -1
  60. package/lib/node/node-file-upload.d.ts +0 -19
  61. package/lib/node/node-file-upload.d.ts.map +0 -1
  62. package/lib/node/node-file-upload.js +0 -55
  63. package/lib/node/node-file-upload.js.map +0 -1
  64. package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.d.ts +0 -53
  65. package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.d.ts.map +0 -1
  66. package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.js +0 -197
  67. package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.js.map +0 -1
  68. package/src/browser/filesystem-watcher.ts +0 -249
  69. package/src/node/node-file-upload.ts +0 -64
  70. package/src/node/nsfw-watcher/nsfw-filesystem-watcher.ts +0 -255
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/filesystem",
3
- "version": "1.26.0-next.4+eb0930a267c",
3
+ "version": "1.26.0-next.44+4099a4ec58f",
4
4
  "description": "Theia - FileSystem Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.26.0-next.4+eb0930a267c",
6
+ "@theia/core": "1.26.0-next.44+4099a4ec58f",
7
7
  "@types/body-parser": "^1.17.0",
8
8
  "@types/multer": "^1.4.7",
9
9
  "@types/rimraf": "^2.0.2",
@@ -68,5 +68,5 @@
68
68
  "nyc": {
69
69
  "extends": "../../configs/nyc.json"
70
70
  },
71
- "gitHead": "eb0930a267cda577b31532474a404e45b5ae350b"
71
+ "gitHead": "4099a4ec58f8573a36b32514d37b7d8541db7030"
72
72
  }
@@ -16,8 +16,7 @@
16
16
 
17
17
  import { Container, interfaces, injectable, inject } from '@theia/core/shared/inversify';
18
18
  import { TreeProps, ContextMenuRenderer, TreeNode, OpenerService, open, NodeProps, defaultTreeProps } from '@theia/core/lib/browser';
19
- import { createFileTreeContainer, FileTreeWidget } from '../';
20
- import { FileTreeModel, FileStatNode } from '../file-tree';
19
+ import { FileTreeModel, FileStatNode, createFileTreeContainer, FileTreeWidget } from '../file-tree';
21
20
 
22
21
  const BREADCRUMBS_FILETREE_CLASS = 'theia-FilepathBreadcrumbFileTree';
23
22
 
@@ -602,6 +602,11 @@ export class FileService {
602
602
 
603
603
  /**
604
604
  * Tests a user's permissions for the given resource.
605
+ * @param resource `URI` of the resource which should be tested.
606
+ * @param mode An optional integer that specifies the accessibility checks to be performed.
607
+ * Check `FileAccess.Constants` for possible values of mode.
608
+ * It is possible to create a mask consisting of the bitwise `OR` of two or more values (e.g. FileAccess.Constants.W_OK | FileAccess.Constants.R_OK).
609
+ * If `mode` is not defined, `FileAccess.Constants.F_OK` will be used instead.
605
610
  */
606
611
  async access(resource: URI, mode?: number): Promise<boolean> {
607
612
  const provider = await this.withProvider(resource);
@@ -143,7 +143,7 @@ export class FileTreeDecoratorAdapter implements TreeDecorator {
143
143
  }
144
144
 
145
145
  /**
146
- * Sort higher priorities earier. I.e. positive number means right higher than left.
146
+ * Sort higher priorities earlier. I.e. positive number means right higher than left.
147
147
  */
148
148
  protected compareWeight(left: Decoration, right: Decoration): number {
149
149
  return (right.weight ?? 0) - (left.weight ?? 0);
@@ -280,7 +280,7 @@ export class FileTreeWidget extends CompressedTreeWidget {
280
280
  if (node.fileStat) {
281
281
  stat = {
282
282
  type: node.fileStat.isDirectory ? FileType.Directory : FileType.File,
283
- mtime: node.fileStat.lastModification,
283
+ mtime: node.fileStat.mtime,
284
284
  size: node.fileStat.size
285
285
  };
286
286
  delete node['fileStat'];
@@ -19,7 +19,6 @@ import URI from '@theia/core/lib/common/uri';
19
19
  import { TreeNode, CompositeTreeNode, SelectableTreeNode, ExpandableTreeNode, TreeImpl } from '@theia/core/lib/browser';
20
20
  import { Mutable } from '@theia/core/lib/common/types';
21
21
  import { FileStat, Stat, FileType, FileOperationError, FileOperationResult } from '../../common/files';
22
- import { FileStat as DeprecatedFileStat } from '../../common/filesystem';
23
22
  import { UriSelection } from '@theia/core/lib/common/selection';
24
23
  import { MessageService } from '@theia/core/lib/common/message-service';
25
24
  import { FileSelection } from '../file-selection';
@@ -117,7 +116,7 @@ export namespace FileStatNode {
117
116
  export type FileStatNodeData = Omit<FileStatNode, 'uri' | 'fileStat'> & {
118
117
  uri: string
119
118
  stat?: Stat | { type: FileType } & Partial<Stat>
120
- fileStat?: DeprecatedFileStat
119
+ fileStat?: FileStat
121
120
  };
122
121
  export namespace FileStatNodeData {
123
122
  export function is(node: object | undefined): node is FileStatNodeData {
@@ -21,21 +21,14 @@ import { ResourceResolver, CommandContribution } from '@theia/core/lib/common';
21
21
  import { WebSocketConnectionProvider, FrontendApplicationContribution, LabelProviderContribution, BreadcrumbsContribution } from '@theia/core/lib/browser';
22
22
  import { FileResourceResolver } from './file-resource';
23
23
  import { bindFileSystemPreferences } from './filesystem-preferences';
24
- import { FileSystemWatcher } from './filesystem-watcher';
25
24
  import { FileSystemFrontendContribution } from './filesystem-frontend-contribution';
26
25
  import { FileUploadService } from './file-upload-service';
27
26
  import { FileTreeDecoratorAdapter, FileTreeLabelProvider } from './file-tree';
28
27
  import { FileService, FileServiceContribution } from './file-service';
29
28
  import { RemoteFileSystemProvider, RemoteFileSystemServer, remoteFileSystemPath, RemoteFileSystemProxyFactory } from '../common/remote-file-system-provider';
30
- import { FileSystem, FileStat, FileMoveOptions, FileDeleteOptions, FileSystemError } from '../common/filesystem';
31
- import URI from '@theia/core/lib/common/uri';
32
- import { FileOperationError, FileOperationResult, BaseStatWithMetadata, FileStatWithMetadata, etag } from '../common/files';
33
- import { TextDocumentContentChangeEvent } from '@theia/core/shared/vscode-languageserver-protocol';
34
- import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
35
29
  import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
36
30
  import { RemoteFileServiceContribution } from './remote-file-service-contribution';
37
31
  import { FileSystemWatcherErrorHandler } from './filesystem-watcher-error-handler';
38
- import { UTF8 } from '@theia/core/lib/common/encodings';
39
32
  import { FilepathBreadcrumbsContribution } from './breadcrumbs/filepath-breadcrumbs-contribution';
40
33
  import { BreadcrumbsFileTreeWidget, createFileTreeBreadcrumbsWidget } from './breadcrumbs/filepath-breadcrumbs-container';
41
34
  import { FilesystemSaveResourceService } from './filesystem-save-resource-service';
@@ -54,163 +47,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
54
47
  bind(RemoteFileServiceContribution).toSelf().inSingletonScope();
55
48
  bind(FileServiceContribution).toService(RemoteFileServiceContribution);
56
49
 
57
- bind(FileSystemWatcher).toSelf().inSingletonScope();
58
50
  bind(FileSystemWatcherErrorHandler).toSelf().inSingletonScope();
59
51
 
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- bind(FileSystem).toDynamicValue(({ container }) => {
62
- const fileService = container.get(FileService);
63
- const environments = container.get<EnvVariablesServer>(EnvVariablesServer);
64
- const convertStat: (stat: BaseStatWithMetadata | FileStatWithMetadata) => FileStat = stat => ({
65
- uri: stat.resource.toString(),
66
- lastModification: stat.mtime,
67
- size: stat.size,
68
- isDirectory: 'isDirectory' in stat && stat.isDirectory,
69
- children: 'children' in stat ? stat.children?.map(convertStat) : undefined
70
- });
71
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- const rethrowError: (uri: string, error: any) => never = (uri, error) => {
73
- if (error instanceof FileOperationError) {
74
- if (error.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
75
- throw FileSystemError.FileNotFound(uri);
76
- }
77
- if (error.fileOperationResult === FileOperationResult.FILE_IS_DIRECTORY) {
78
- throw FileSystemError.FileIsDirectory(uri);
79
- }
80
- if (error.fileOperationResult === FileOperationResult.FILE_NOT_DIRECTORY) {
81
- throw FileSystemError.FileNotDirectory(uri);
82
- }
83
- if (error.fileOperationResult === FileOperationResult.FILE_MODIFIED_SINCE) {
84
- throw FileSystemError.FileIsOutOfSync(uri);
85
- }
86
- }
87
- throw error;
88
- };
89
- return new class implements FileSystem {
90
- async getFileStat(uri: string): Promise<FileStat | undefined> {
91
- try {
92
- const stat = await fileService.resolve(new URI(uri), { resolveMetadata: true });
93
- return convertStat(stat);
94
- } catch (e) {
95
- if (e instanceof FileOperationError && e.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
96
- return undefined;
97
- }
98
- rethrowError(uri, e);
99
- }
100
- }
101
- exists(uri: string): Promise<boolean> {
102
- return fileService.exists(new URI(uri));
103
- }
104
- async resolveContent(uri: string, options?: { encoding?: string | undefined; } | undefined): Promise<{ stat: FileStat; content: string; }> {
105
- try {
106
- const content = await fileService.read(new URI(uri), options);
107
- return {
108
- stat: convertStat(content),
109
- content: content.value
110
- };
111
- } catch (e) {
112
- rethrowError(uri, e);
113
- }
114
- }
115
- async setContent(file: FileStat, content: string, options?: { encoding?: string | undefined; } | undefined): Promise<FileStat> {
116
- try {
117
- const result = await fileService.write(new URI(file.uri), content, {
118
- ...options,
119
- mtime: file.lastModification
120
- });
121
- return convertStat(result);
122
- } catch (e) {
123
- rethrowError(file.uri, e);
124
- }
125
- }
126
- async updateContent(file: FileStat, contentChanges: TextDocumentContentChangeEvent[], options?: {
127
- encoding?: string | undefined;
128
- overwriteEncoding?: string | undefined;
129
- } | undefined): Promise<FileStat> {
130
- try {
131
- const result = await fileService.update(new URI(file.uri), contentChanges, {
132
- mtime: file.lastModification,
133
- etag: etag({ size: file.size, mtime: file.lastModification }),
134
- readEncoding: options?.encoding || UTF8,
135
- encoding: options?.overwriteEncoding,
136
- overwriteEncoding: !!options?.overwriteEncoding
137
- });
138
- return convertStat(result);
139
- } catch (e) {
140
- rethrowError(file.uri, e);
141
- }
142
- }
143
- async move(sourceUri: string, targetUri: string, options?: FileMoveOptions | undefined): Promise<FileStat> {
144
- try {
145
- const result = await fileService.move(new URI(sourceUri), new URI(targetUri), options);
146
- return convertStat(result);
147
- } catch (e) {
148
- rethrowError(sourceUri, e);
149
- }
150
- }
151
- async copy(sourceUri: string, targetUri: string, options?: { overwrite?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<FileStat> {
152
- try {
153
- const result = await fileService.copy(new URI(sourceUri), new URI(targetUri), options);
154
- return convertStat(result);
155
- } catch (e) {
156
- rethrowError(sourceUri, e);
157
- }
158
- }
159
- async createFile(uri: string, options?: { content?: string | undefined; encoding?: string | undefined; } | undefined): Promise<FileStat> {
160
- try {
161
- const result = await fileService.create(new URI(uri), options?.content, { encoding: options?.encoding });
162
- return convertStat(result);
163
- } catch (e) {
164
- rethrowError(uri, e);
165
- }
166
- }
167
- async createFolder(uri: string): Promise<FileStat> {
168
- try {
169
- const result = await fileService.createFolder(new URI(uri));
170
- return convertStat(result);
171
- } catch (e) {
172
- rethrowError(uri, e);
173
- }
174
- }
175
- touchFile(uri: string): Promise<FileStat> {
176
- throw new Error('Method not implemented.');
177
- }
178
- async delete(uri: string, options?: FileDeleteOptions | undefined): Promise<void> {
179
- try {
180
- return await fileService.delete(new URI(uri), { useTrash: options?.moveToTrash, recursive: true });
181
- } catch (e) {
182
- rethrowError(uri, e);
183
- }
184
- }
185
- async getEncoding(uri: string): Promise<string> {
186
- const { encoding } = await fileService.read(new URI(uri));
187
- return encoding;
188
- }
189
- async guessEncoding(uri: string): Promise<string | undefined> {
190
- const { encoding } = await fileService.read(new URI(uri), { autoGuessEncoding: true });
191
- return encoding;
192
- }
193
- async getRoots(): Promise<FileStat[]> {
194
- const drives = await environments.getDrives();
195
- const roots = await Promise.all(drives.map(uri => this.getFileStat(uri)));
196
- return roots.filter(root => !!root) as FileStat[];
197
- }
198
- async getCurrentUserHome(): Promise<FileStat | undefined> {
199
- return this.getFileStat(await environments.getHomeDirUri());
200
- }
201
- getDrives(): Promise<string[]> {
202
- return environments.getDrives();
203
- }
204
- access(uri: string, mode?: number | undefined): Promise<boolean> {
205
- return fileService.access(new URI(uri), mode);
206
- }
207
- getFsPath(uri: string): Promise<string | undefined> {
208
- return fileService.fsPath(new URI(uri));
209
- }
210
-
211
- };
212
- }).inSingletonScope();
213
-
214
52
  bindFileResource(bind);
215
53
 
216
54
  bind(FileUploadService).toSelf().inSingletonScope();
@@ -18,5 +18,4 @@ export * from './location';
18
18
  export * from './file-tree';
19
19
  export * from './file-dialog';
20
20
  export * from './filesystem-preferences';
21
- export * from './filesystem-watcher';
22
21
  export * from './file-resource';
@@ -187,7 +187,7 @@ export class LocationListRenderer extends ReactRenderer {
187
187
  protected renderTextInput(): React.ReactNode {
188
188
  return (
189
189
  <input className={'theia-select ' + LocationListRenderer.Styles.LOCATION_TEXT_INPUT_CLASS}
190
- defaultValue={this.service.location?.path.toString()}
190
+ defaultValue={this.service.location?.path.fsPath()}
191
191
  onBlur={this.handleTextInputOnBlur}
192
192
  onChange={this.handleTextInputOnChange}
193
193
  onKeyDown={this.handleTextInputKeyDown}
@@ -278,7 +278,7 @@ export class LocationListRenderer extends ReactRenderer {
278
278
  protected renderLocation(location: LocationListRenderer.Location): React.ReactNode {
279
279
  const { uri, isDrive } = location;
280
280
  const value = uri.toString();
281
- return <option value={value} key={uri.toString()}>{isDrive ? uri.path.toString() : uri.displayName}</option>;
281
+ return <option value={value} key={uri.toString()}>{isDrive ? uri.path.fsPath() : uri.displayName}</option>;
282
282
  }
283
283
 
284
284
  protected onLocationChanged(e: React.ChangeEvent<HTMLSelectElement>): void {
@@ -698,16 +698,25 @@ export interface FileSystemProvider {
698
698
  */
699
699
  export interface FileSystemProviderWithAccessCapability extends FileSystemProvider {
700
700
  /**
701
- * Test if the user has the permission to access the given file in the specified mode.
701
+ * Tests a user's permissions for the file or directory specified by URI.
702
702
  * @param resource The `URI` of the file that should be tested.
703
- * @param mode The access mode that should be tested.
703
+ * @param mode An optional integer that specifies the accessibility checks to be performed.
704
+ * Check `FileAccess.Constants` for possible values of mode.
705
+ * It is possible to create a mask consisting of the bitwise `OR` of two or more values (e.g. FileAccess.Constants.W_OK | FileAccess.Constants.R_OK).
706
+ * If `mode` is not defined, `FileAccess.Constants.F_OK` will be used instead.
704
707
  *
705
708
  * @returns A promise that resolves if the user has the required permissions, should be rejected otherwise.
706
709
  */
707
710
  access(resource: URI, mode?: number): Promise<void>;
708
711
 
709
712
  /**
710
- * Derive the platform specific file system path that is represented by the resource.
713
+ * Returns the path of the given file URI, specific to the backend's operating system.
714
+ * If the URI is not a file URI, undefined is returned.
715
+ *
716
+ * USE WITH CAUTION: You should always prefer URIs to paths if possible, as they are
717
+ * portable and platform independent. Paths should only be used in cases you directly
718
+ * interact with the OS, e.g. when running a command on the shell.
719
+ *
711
720
  * @param resource `URI` of the resource to derive the path from.
712
721
  *
713
722
  * @returns A promise of the corresponding file system path.
@@ -837,7 +846,7 @@ export function hasOpenReadWriteCloseCapability(provider: FileSystemProvider): p
837
846
  */
838
847
  export interface FileSystemProviderWithFileReadStreamCapability extends FileSystemProvider {
839
848
  /**
840
- * Read the contents of the given file as stream.
849
+ * Read the contents of the given file as stream.
841
850
  * @param resource The `URI` of the file.
842
851
  *
843
852
  * @return The `ReadableStreamEvents` for the readable stream of the given file.
@@ -14,9 +14,9 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { FileSystemUtils } from '.';
18
17
  import { FileStat } from './files';
19
18
  import { expect } from 'chai';
19
+ import { FileSystemUtils } from './filesystem-utils';
20
20
 
21
21
  describe('generateUniqueResourceURI', () => {
22
22
  describe('Target is file', () => {
@@ -14,8 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import { JsonRpcServer, JsonRpcProxy } from '@theia/core';
17
+ import { JsonRpcServer } from '@theia/core';
19
18
  import { FileChangeType } from './files';
20
19
  export { FileChangeType };
21
20
 
@@ -95,68 +94,3 @@ export interface FileChange {
95
94
  uri: string;
96
95
  type: FileChangeType;
97
96
  }
98
-
99
- export const FileSystemWatcherServerProxy = Symbol('FileSystemWatcherServerProxy');
100
- export type FileSystemWatcherServerProxy = JsonRpcProxy<FileSystemWatcherServer>;
101
-
102
- /**
103
- * @deprecated not used internally anymore.
104
- */
105
- @injectable()
106
- export class ReconnectingFileSystemWatcherServer implements FileSystemWatcherServer {
107
-
108
- protected watcherSequence = 1;
109
- protected readonly watchParams = new Map<number, {
110
- uri: string;
111
- options?: WatchOptions
112
- }>();
113
- protected readonly localToRemoteWatcher = new Map<number, number>();
114
-
115
- constructor(
116
- @inject(FileSystemWatcherServerProxy) protected readonly proxy: FileSystemWatcherServerProxy
117
- ) {
118
- const onInitialized = this.proxy.onDidOpenConnection(() => {
119
- // skip reconnection on the first connection
120
- onInitialized.dispose();
121
- this.proxy.onDidOpenConnection(() => this.reconnect());
122
- });
123
- }
124
-
125
- protected reconnect(): void {
126
- for (const [watcher, { uri, options }] of this.watchParams.entries()) {
127
- this.doWatchFileChanges(watcher, uri, options);
128
- }
129
- }
130
-
131
- dispose(): void {
132
- this.proxy.dispose();
133
- }
134
-
135
- watchFileChanges(uri: string, options?: WatchOptions): Promise<number> {
136
- const watcher = this.watcherSequence++;
137
- this.watchParams.set(watcher, { uri, options });
138
- return this.doWatchFileChanges(watcher, uri, options);
139
- }
140
-
141
- protected doWatchFileChanges(watcher: number, uri: string, options?: WatchOptions): Promise<number> {
142
- return this.proxy.watchFileChanges(uri, options).then(remote => {
143
- this.localToRemoteWatcher.set(watcher, remote);
144
- return watcher;
145
- });
146
- }
147
-
148
- unwatchFileChanges(watcher: number): Promise<void> {
149
- this.watchParams.delete(watcher);
150
- const remote = this.localToRemoteWatcher.get(watcher);
151
- if (remote) {
152
- this.localToRemoteWatcher.delete(watcher);
153
- return this.proxy.unwatchFileChanges(remote);
154
- }
155
- return Promise.resolve();
156
- }
157
-
158
- setClient(client: FileSystemWatcherClient | undefined): void {
159
- this.proxy.setClient(client);
160
- }
161
-
162
- }