@codingame/monaco-vscode-files-service-override 1.83.16 → 1.85.0-next.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-files-service-override",
3
- "version": "1.83.16",
3
+ "version": "1.85.0-next.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,7 +18,7 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@1.83.16",
22
- "monaco-editor": "0.44.0"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@1.85.0-next.0",
22
+ "monaco-editor": "0.45.0"
23
23
  }
24
24
  }
@@ -18,7 +18,9 @@ import { readFileIntoStream } from './io.js';
18
18
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
19
19
  import { ErrorNoTelemetry } from 'monaco-editor/esm/vs/base/common/errors.js';
20
20
 
21
+ var FileService_1;
21
22
  let FileService = class FileService extends Disposable {
23
+ static { FileService_1 = this; }
22
24
  constructor(logService) {
23
25
  super();
24
26
  this.logService = logService;
@@ -32,8 +34,9 @@ let FileService = class FileService extends Disposable {
32
34
  this.provider = ( new Map());
33
35
  this._onDidRunOperation = this._register(( new Emitter()));
34
36
  this.onDidRunOperation = this._onDidRunOperation.event;
35
- this._onDidFilesChange = this._register(( new Emitter()));
36
- this.onDidFilesChange = this._onDidFilesChange.event;
37
+ this.internalOnDidFilesChange = this._register(( new Emitter()));
38
+ this._onDidUncorrelatedFilesChange = this._register(( new Emitter()));
39
+ this.onDidFilesChange = this._onDidUncorrelatedFilesChange.event;
37
40
  this._onDidWatchError = this._register(( new Emitter()));
38
41
  this.onDidWatchError = this._onDidWatchError.event;
39
42
  this.activeWatchers = ( new Map());
@@ -47,7 +50,13 @@ let FileService = class FileService extends Disposable {
47
50
  const providerDisposables = ( new DisposableStore());
48
51
  this.provider.set(scheme, provider);
49
52
  this._onDidChangeFileSystemProviderRegistrations.fire({ added: true, scheme, provider });
50
- providerDisposables.add(provider.onDidChangeFile(changes => this._onDidFilesChange.fire(( new FileChangesEvent(changes, !this.isPathCaseSensitive(provider))))));
53
+ providerDisposables.add(provider.onDidChangeFile(changes => {
54
+ const event = ( new FileChangesEvent(changes, !this.isPathCaseSensitive(provider)));
55
+ this.internalOnDidFilesChange.fire(event);
56
+ if (!event.hasCorrelation()) {
57
+ this._onDidUncorrelatedFilesChange.fire(event);
58
+ }
59
+ }));
51
60
  if (typeof provider.onDidWatchError === 'function') {
52
61
  providerDisposables.add(provider.onDidWatchError(error => this._onDidWatchError.fire(( new Error(error)))));
53
62
  }
@@ -737,6 +746,13 @@ let FileService = class FileService extends Disposable {
737
746
  }
738
747
  return sourceWriteQueue.queue(() => this.doCopyFile(sourceProvider, source, targetProvider, target));
739
748
  }
749
+ static { this.WATCHER_CORRELATION_IDS = 0; }
750
+ createWatcher(resource, options) {
751
+ return this.watch(resource, {
752
+ ...options,
753
+ correlationId: FileService_1.WATCHER_CORRELATION_IDS++
754
+ });
755
+ }
740
756
  watch(resource, options = { recursive: false, excludes: [] }) {
741
757
  const disposables = ( new DisposableStore());
742
758
  let watchDisposed = false;
@@ -756,6 +772,20 @@ let FileService = class FileService extends Disposable {
756
772
  this.logService.error(error);
757
773
  }
758
774
  })();
775
+ const correlationId = options.correlationId;
776
+ if (typeof correlationId === 'number') {
777
+ const fileChangeEmitter = disposables.add(( new Emitter()));
778
+ disposables.add(this.internalOnDidFilesChange.event(e => {
779
+ if (e.correlates(correlationId)) {
780
+ fileChangeEmitter.fire(e);
781
+ }
782
+ }));
783
+ const watcher = {
784
+ onDidChange: fileChangeEmitter.event,
785
+ dispose: () => disposables.dispose()
786
+ };
787
+ return watcher;
788
+ }
759
789
  return disposables;
760
790
  }
761
791
  async doWatch(resource, options) {
@@ -952,7 +982,7 @@ let FileService = class FileService extends Disposable {
952
982
  return ( resource.toString(true));
953
983
  }
954
984
  };
955
- FileService = ( __decorate([
985
+ FileService = FileService_1 = ( __decorate([
956
986
  ( __param(0, ILogService))
957
987
  ], FileService));
958
988
 
@@ -1,5 +1,7 @@
1
+ import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/ternarySearchTree.js';
1
2
  import { isNumber } from 'monaco-editor/esm/vs/base/common/types.js';
2
3
  import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
4
+ import { Lazy } from 'monaco-editor/esm/vs/base/common/lazy.js';
3
5
 
4
6
  var FileType;
5
7
  ( (function(FileType) {
@@ -86,6 +88,111 @@ var FileChangeType;
86
88
  FileChangeType[FileChangeType["ADDED"] = 1] = "ADDED";
87
89
  FileChangeType[FileChangeType["DELETED"] = 2] = "DELETED";
88
90
  })(FileChangeType || (FileChangeType = {})));
91
+ class FileChangesEvent {
92
+ static { this.MIXED_CORRELATION = null; }
93
+ constructor(changes, ignorePathCasing) {
94
+ this.ignorePathCasing = ignorePathCasing;
95
+ this.correlationId = undefined;
96
+ this.added = ( new Lazy(() => {
97
+ const added = TernarySearchTree.forUris(() => this.ignorePathCasing);
98
+ added.fill(( this.rawAdded.map(resource => [resource, true])));
99
+ return added;
100
+ }));
101
+ this.updated = ( new Lazy(() => {
102
+ const updated = TernarySearchTree.forUris(() => this.ignorePathCasing);
103
+ updated.fill(( this.rawUpdated.map(resource => [resource, true])));
104
+ return updated;
105
+ }));
106
+ this.deleted = ( new Lazy(() => {
107
+ const deleted = TernarySearchTree.forUris(() => this.ignorePathCasing);
108
+ deleted.fill(( this.rawDeleted.map(resource => [resource, true])));
109
+ return deleted;
110
+ }));
111
+ this.rawAdded = [];
112
+ this.rawUpdated = [];
113
+ this.rawDeleted = [];
114
+ for (const change of changes) {
115
+ switch (change.type) {
116
+ case 1 :
117
+ this.rawAdded.push(change.resource);
118
+ break;
119
+ case 0 :
120
+ this.rawUpdated.push(change.resource);
121
+ break;
122
+ case 2 :
123
+ this.rawDeleted.push(change.resource);
124
+ break;
125
+ }
126
+ if (this.correlationId !== FileChangesEvent.MIXED_CORRELATION) {
127
+ if (typeof change.cId === 'number') {
128
+ if (this.correlationId === undefined) {
129
+ this.correlationId = change.cId;
130
+ }
131
+ else if (this.correlationId !== change.cId) {
132
+ this.correlationId = FileChangesEvent.MIXED_CORRELATION;
133
+ }
134
+ }
135
+ else {
136
+ if (this.correlationId !== undefined) {
137
+ this.correlationId = FileChangesEvent.MIXED_CORRELATION;
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ contains(resource, ...types) {
144
+ return this.doContains(resource, { includeChildren: false }, ...types);
145
+ }
146
+ affects(resource, ...types) {
147
+ return this.doContains(resource, { includeChildren: true }, ...types);
148
+ }
149
+ doContains(resource, options, ...types) {
150
+ if (!resource) {
151
+ return false;
152
+ }
153
+ const hasTypesFilter = types.length > 0;
154
+ if (!hasTypesFilter || types.includes(1 )) {
155
+ if (this.added.value.get(resource)) {
156
+ return true;
157
+ }
158
+ if (options.includeChildren && this.added.value.findSuperstr(resource)) {
159
+ return true;
160
+ }
161
+ }
162
+ if (!hasTypesFilter || types.includes(0 )) {
163
+ if (this.updated.value.get(resource)) {
164
+ return true;
165
+ }
166
+ if (options.includeChildren && this.updated.value.findSuperstr(resource)) {
167
+ return true;
168
+ }
169
+ }
170
+ if (!hasTypesFilter || types.includes(2 )) {
171
+ if (this.deleted.value.findSubstr(resource) ) {
172
+ return true;
173
+ }
174
+ if (options.includeChildren && this.deleted.value.findSuperstr(resource)) {
175
+ return true;
176
+ }
177
+ }
178
+ return false;
179
+ }
180
+ gotAdded() {
181
+ return this.rawAdded.length > 0;
182
+ }
183
+ gotDeleted() {
184
+ return this.rawDeleted.length > 0;
185
+ }
186
+ gotUpdated() {
187
+ return this.rawUpdated.length > 0;
188
+ }
189
+ correlates(correlationId) {
190
+ return this.correlationId === correlationId;
191
+ }
192
+ hasCorrelation() {
193
+ return typeof this.correlationId === 'number';
194
+ }
195
+ }
89
196
  class ByteSize {
90
197
  static { this.KB = 1024; }
91
198
  static { this.MB = ByteSize.KB * ByteSize.KB; }
@@ -131,4 +238,4 @@ class ByteSize {
131
238
  }
132
239
  }
133
240
 
134
- export { ByteSize, FileChangeType, FilePermission, FileSystemProviderCapabilities, FileSystemProviderError, FileSystemProviderErrorCode, FileType, markAsFileSystemProviderError, toFileSystemProviderErrorCode };
241
+ export { ByteSize, FileChangeType, FileChangesEvent, FilePermission, FileSystemProviderCapabilities, FileSystemProviderError, FileSystemProviderErrorCode, FileType, markAsFileSystemProviderError, toFileSystemProviderErrorCode };