@codingame/monaco-vscode-files-service-override 4.5.1 → 5.0.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/files.js +8 -44
- package/package.json +2 -2
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js +40 -57
- package/vscode/src/vs/platform/files/common/fileService.js +292 -141
- package/vscode/src/vs/platform/files/common/io.js +2 -1
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +1 -1
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +51 -82
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +38 -35
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +7 -11
package/files.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
3
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
-
import { FileService } from './vscode/src/vs/platform/files/common/fileService.js';
|
|
4
|
+
import { mkdirp, FileService } from './vscode/src/vs/platform/files/common/fileService.js';
|
|
5
5
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
6
6
|
import { InMemoryFileSystemProvider } from 'vscode/vscode/vs/platform/files/common/inMemoryFilesystemProvider';
|
|
7
7
|
export { InMemoryFileSystemProvider } from 'vscode/vscode/vs/platform/files/common/inMemoryFilesystemProvider';
|
|
8
8
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
9
9
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
10
|
-
import { FileType, FilePermission, createFileSystemProviderError, FileSystemProviderErrorCode, FileSystemProviderError
|
|
10
|
+
import { FileType, FilePermission, createFileSystemProviderError, FileSystemProviderErrorCode, FileSystemProviderError } from 'vscode/vscode/vs/platform/files/common/files';
|
|
11
11
|
export { FileChangeType, FilePermission, FileSystemProviderCapabilities, FileSystemProviderError, FileSystemProviderErrorCode, FileType } from 'vscode/vscode/vs/platform/files/common/files';
|
|
12
12
|
import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
13
13
|
import { extUri, joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
@@ -20,7 +20,6 @@ import { IndexedDB } from 'vscode/vscode/vs/base/browser/indexedDB';
|
|
|
20
20
|
export { IndexedDB } from 'vscode/vscode/vs/base/browser/indexedDB';
|
|
21
21
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
22
22
|
import { BufferLogger } from 'vscode/vscode/vs/platform/log/common/bufferLog';
|
|
23
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
24
23
|
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
25
24
|
import { BrowserTextFileService } from './vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js';
|
|
26
25
|
import { FilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
|
@@ -29,7 +28,7 @@ import { BrowserElevatedFileService } from './vscode/src/vs/workbench/services/f
|
|
|
29
28
|
import { IElevatedFileService } from 'vscode/vscode/vs/workbench/services/files/common/elevatedFileService.service';
|
|
30
29
|
import { registerServiceInitializePreParticipant, checkServicesNotInitialized } from 'vscode/lifecycle';
|
|
31
30
|
import { logsPath } from 'vscode/workbench';
|
|
32
|
-
import 'vscode/vscode/vs/workbench/contrib/files/browser/files.
|
|
31
|
+
import 'vscode/vscode/vs/workbench/contrib/files/browser/files.contribution._configuration';
|
|
33
32
|
|
|
34
33
|
class RegisteredFile {
|
|
35
34
|
constructor(uri, readonly) {
|
|
@@ -171,9 +170,10 @@ class RegisteredFileSystemProvider extends Disposable {
|
|
|
171
170
|
throw createFileSystemProviderError('file not found', FileSystemProviderErrorCode.FileNotFound);
|
|
172
171
|
}
|
|
173
172
|
async readdir(resource) {
|
|
174
|
-
const includedPaths = ( Array.from(( this.files.keys()))
|
|
175
|
-
.map(uri =>
|
|
176
|
-
.filter(
|
|
173
|
+
const includedPaths = ( ( Array.from(( this.files.keys()))
|
|
174
|
+
.map(uri => ( URI.parse(uri))))
|
|
175
|
+
.filter(uri => uri.path.startsWith(resource.path + '/'))
|
|
176
|
+
.map(uri => extUri.relativePath(resource, uri)));
|
|
177
177
|
const files = includedPaths.filter(path => !path.includes('/'));
|
|
178
178
|
const directories = ( includedPaths.filter(path => path.includes('/')).map(path => path.slice(0, path.indexOf('/'))));
|
|
179
179
|
return [
|
|
@@ -365,45 +365,9 @@ class OverlayFileSystemProvider {
|
|
|
365
365
|
await this.writeToDelegates(delegate => delegate.rename(from, to, opts));
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
function resourceForError(resource) {
|
|
369
|
-
if (resource.scheme === Schemas.file) {
|
|
370
|
-
return resource.fsPath;
|
|
371
|
-
}
|
|
372
|
-
return ( resource.toString(true));
|
|
373
|
-
}
|
|
374
|
-
async function mkdirp(provider, directory) {
|
|
375
|
-
const directoriesToCreate = [];
|
|
376
|
-
while (!extUri.isEqual(directory, extUri.dirname(directory))) {
|
|
377
|
-
try {
|
|
378
|
-
const stat = await provider.stat(directory);
|
|
379
|
-
if ((stat.type & FileType.Directory) === 0) {
|
|
380
|
-
throw new Error(localizeWithPath('mkdirExistsError', "Unable to create folder '{0}' that already exists but is not a directory", resourceForError(directory)));
|
|
381
|
-
}
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
catch (error) {
|
|
385
|
-
if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileNotFound) {
|
|
386
|
-
throw error;
|
|
387
|
-
}
|
|
388
|
-
directoriesToCreate.push(extUri.basename(directory));
|
|
389
|
-
directory = extUri.dirname(directory);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
for (let i = directoriesToCreate.length - 1; i >= 0; i--) {
|
|
393
|
-
directory = extUri.joinPath(directory, directoriesToCreate[i]);
|
|
394
|
-
try {
|
|
395
|
-
await provider.mkdir(directory);
|
|
396
|
-
}
|
|
397
|
-
catch (error) {
|
|
398
|
-
if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileExists) {
|
|
399
|
-
throw error;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
368
|
class MkdirpOnWriteInMemoryFileSystemProvider extends InMemoryFileSystemProvider {
|
|
405
369
|
async writeFile(resource, content, opts) {
|
|
406
|
-
await mkdirp(this, extUri.dirname(resource));
|
|
370
|
+
await mkdirp(extUri, this, extUri.dirname(resource));
|
|
407
371
|
return super.writeFile(resource, content, opts);
|
|
408
372
|
}
|
|
409
373
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-files-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@5.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -10,34 +10,15 @@ import { createFileSystemProviderError, FileSystemProviderErrorCode, FileType, F
|
|
|
10
10
|
import { DBClosedError } from 'vscode/vscode/vs/base/browser/indexedDB';
|
|
11
11
|
import { BroadcastDataChannel } from 'vscode/vscode/vs/base/browser/broadcast';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)), FileSystemProviderErrorCode.
|
|
18
|
-
const
|
|
19
|
-
'vs/platform/files/browser/indexedDBFileSystemProvider',
|
|
20
|
-
'fileIsDirectory',
|
|
21
|
-
"File is Directory"
|
|
22
|
-
)), FileSystemProviderErrorCode.FileIsADirectory);
|
|
23
|
-
const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localizeWithPath(
|
|
24
|
-
'vs/platform/files/browser/indexedDBFileSystemProvider',
|
|
25
|
-
'fileNotDirectory',
|
|
26
|
-
"File is not a directory"
|
|
27
|
-
)), FileSystemProviderErrorCode.FileNotADirectory);
|
|
28
|
-
const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localizeWithPath(
|
|
29
|
-
'vs/platform/files/browser/indexedDBFileSystemProvider',
|
|
30
|
-
'dirIsNotEmpty',
|
|
31
|
-
"Directory is not empty"
|
|
32
|
-
)), FileSystemProviderErrorCode.Unknown);
|
|
33
|
-
const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localizeWithPath(
|
|
34
|
-
'vs/platform/files/browser/indexedDBFileSystemProvider',
|
|
35
|
-
'fileExceedsStorageQuota',
|
|
36
|
-
"File exceeds available storage quota"
|
|
37
|
-
)), FileSystemProviderErrorCode.FileExceedsStorageQuota);
|
|
13
|
+
const _moduleId = "vs/platform/files/browser/indexedDBFileSystemProvider";
|
|
14
|
+
const ERR_FILE_NOT_FOUND = createFileSystemProviderError(( localizeWithPath(_moduleId, 0, "File does not exist")), FileSystemProviderErrorCode.FileNotFound);
|
|
15
|
+
const ERR_FILE_IS_DIR = createFileSystemProviderError(( localizeWithPath(_moduleId, 1, "File is Directory")), FileSystemProviderErrorCode.FileIsADirectory);
|
|
16
|
+
const ERR_FILE_NOT_DIR = createFileSystemProviderError(( localizeWithPath(_moduleId, 2, "File is not a directory")), FileSystemProviderErrorCode.FileNotADirectory);
|
|
17
|
+
const ERR_DIR_NOT_EMPTY = createFileSystemProviderError(( localizeWithPath(_moduleId, 3, "Directory is not empty")), FileSystemProviderErrorCode.Unknown);
|
|
18
|
+
const ERR_FILE_EXCEEDS_STORAGE_QUOTA = createFileSystemProviderError(( localizeWithPath(_moduleId, 4, "File exceeds available storage quota")), FileSystemProviderErrorCode.FileExceedsStorageQuota);
|
|
38
19
|
const ERR_UNKNOWN_INTERNAL = (message) => createFileSystemProviderError(( localizeWithPath(
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
_moduleId,
|
|
21
|
+
5,
|
|
41
22
|
"Internal error occurred in IndexedDB File System Provider. ({0})",
|
|
42
23
|
message
|
|
43
24
|
)), FileSystemProviderErrorCode.Unknown);
|
|
@@ -109,32 +90,32 @@ class IndexedDBFileSystemNode {
|
|
|
109
90
|
if (existing?.entry.type === FileType.File) {
|
|
110
91
|
throw ERR_UNKNOWN_INTERNAL(`Internal error creating IndexedDBFSNode -- overwriting file with directory: ${this.entry.path}/${next} (encountered while adding ${originalPath})`);
|
|
111
92
|
}
|
|
112
|
-
this.entry.children.set(next, existing ?? ( new IndexedDBFileSystemNode({
|
|
93
|
+
this.entry.children.set(next, existing ?? ( (new IndexedDBFileSystemNode({
|
|
113
94
|
type: FileType.Directory,
|
|
114
95
|
path: this.entry.path + '/' + next,
|
|
115
|
-
children: ( new Map()),
|
|
116
|
-
})));
|
|
96
|
+
children: ( (new Map())),
|
|
97
|
+
}))));
|
|
117
98
|
}
|
|
118
99
|
else {
|
|
119
100
|
if (existing?.entry.type === FileType.Directory) {
|
|
120
101
|
throw ERR_UNKNOWN_INTERNAL(`Internal error creating IndexedDBFSNode -- overwriting directory with file: ${this.entry.path}/${next} (encountered while adding ${originalPath})`);
|
|
121
102
|
}
|
|
122
|
-
this.entry.children.set(next, ( new IndexedDBFileSystemNode({
|
|
103
|
+
this.entry.children.set(next, ( (new IndexedDBFileSystemNode({
|
|
123
104
|
type: FileType.File,
|
|
124
105
|
path: this.entry.path + '/' + next,
|
|
125
106
|
size: entry.size,
|
|
126
|
-
})));
|
|
107
|
+
}))));
|
|
127
108
|
}
|
|
128
109
|
}
|
|
129
110
|
else if (pathParts.length > 1) {
|
|
130
111
|
const next = pathParts[0];
|
|
131
112
|
let childNode = this.entry.children.get(next);
|
|
132
113
|
if (!childNode) {
|
|
133
|
-
childNode = ( new IndexedDBFileSystemNode({
|
|
134
|
-
children: ( new Map()),
|
|
114
|
+
childNode = ( (new IndexedDBFileSystemNode({
|
|
115
|
+
children: ( (new Map())),
|
|
135
116
|
path: this.entry.path + '/' + next,
|
|
136
117
|
type: FileType.Directory
|
|
137
|
-
}));
|
|
118
|
+
})));
|
|
138
119
|
this.entry.children.set(next, childNode);
|
|
139
120
|
}
|
|
140
121
|
else if (childNode.type === FileType.File) {
|
|
@@ -159,18 +140,18 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
159
140
|
this.capabilities = 2
|
|
160
141
|
| 1024 ;
|
|
161
142
|
this.onDidChangeCapabilities = Event.None;
|
|
162
|
-
this.extUri = ( new ExtUri(() => false)) ;
|
|
163
|
-
this._onDidChangeFile = this._register(( new Emitter()));
|
|
143
|
+
this.extUri = ( (new ExtUri(() => false))) ;
|
|
144
|
+
this._onDidChangeFile = this._register(( (new Emitter())));
|
|
164
145
|
this.onDidChangeFile = this._onDidChangeFile.event;
|
|
165
|
-
this._onReportError = this._register(( new Emitter()));
|
|
146
|
+
this._onReportError = this._register(( (new Emitter())));
|
|
166
147
|
this.onReportError = this._onReportError.event;
|
|
167
|
-
this.mtimes = ( new Map());
|
|
148
|
+
this.mtimes = ( (new Map()));
|
|
168
149
|
this.fileWriteBatch = [];
|
|
169
|
-
this.writeManyThrottler = ( new Throttler());
|
|
150
|
+
this.writeManyThrottler = ( (new Throttler()));
|
|
170
151
|
if (watchCrossWindowChanges) {
|
|
171
|
-
this.changesBroadcastChannel = this._register(( new BroadcastDataChannel(`vscode.indexedDB.${scheme}.changes`)));
|
|
152
|
+
this.changesBroadcastChannel = this._register(( (new BroadcastDataChannel(`vscode.indexedDB.${scheme}.changes`))));
|
|
172
153
|
this._register(this.changesBroadcastChannel.onDidReceiveData(changes => {
|
|
173
|
-
this._onDidChangeFile.fire(( changes.map(c => ({ type: c.type, resource: URI.revive(c.resource) }))));
|
|
154
|
+
this._onDidChangeFile.fire(( (changes.map(c => ({ type: c.type, resource: URI.revive(c.resource) })))));
|
|
174
155
|
}));
|
|
175
156
|
}
|
|
176
157
|
}
|
|
@@ -193,7 +174,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
193
174
|
return {
|
|
194
175
|
type: FileType.File,
|
|
195
176
|
ctime: 0,
|
|
196
|
-
mtime: this.mtimes.get(( resource.toString())) || 0,
|
|
177
|
+
mtime: this.mtimes.get(( (resource.toString()))) || 0,
|
|
197
178
|
size: entry.size ?? (await this.readFile(resource)).byteLength
|
|
198
179
|
};
|
|
199
180
|
}
|
|
@@ -217,7 +198,9 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
217
198
|
throw ERR_FILE_NOT_DIR;
|
|
218
199
|
}
|
|
219
200
|
else {
|
|
220
|
-
return (
|
|
201
|
+
return (
|
|
202
|
+
([...entry.children.entries()].map(([name, node]) => [name, node.type]))
|
|
203
|
+
);
|
|
221
204
|
}
|
|
222
205
|
}
|
|
223
206
|
catch (error) {
|
|
@@ -286,7 +269,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
286
269
|
}
|
|
287
270
|
if (sourceFiles.length) {
|
|
288
271
|
const targetFiles = [];
|
|
289
|
-
const sourceFilesContents = await this.indexedDB.runInTransaction(this.store, 'readonly', objectStore => ( sourceFiles.map(([path]) => objectStore.get(path))));
|
|
272
|
+
const sourceFilesContents = await this.indexedDB.runInTransaction(this.store, 'readonly', objectStore => ( (sourceFiles.map(([path]) => objectStore.get(path)))));
|
|
290
273
|
for (let index = 0; index < sourceFiles.length; index++) {
|
|
291
274
|
const content = sourceFilesContents[index] instanceof Uint8Array ? sourceFilesContents[index] : isString(sourceFilesContents[index]) ? VSBuffer.fromString(sourceFilesContents[index]).buffer : undefined;
|
|
292
275
|
if (content) {
|
|
@@ -311,7 +294,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
311
294
|
let toDelete;
|
|
312
295
|
if (opts.recursive) {
|
|
313
296
|
const tree = await this.tree(resource);
|
|
314
|
-
toDelete = ( tree.map(([path]) => path));
|
|
297
|
+
toDelete = ( (tree.map(([path]) => path)));
|
|
315
298
|
}
|
|
316
299
|
else {
|
|
317
300
|
if (stat.type === FileType.Directory && (await this.readdir(resource)).length) {
|
|
@@ -322,9 +305,9 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
322
305
|
await this.deleteKeys(toDelete);
|
|
323
306
|
(await this.getFiletree()).delete(resource.path);
|
|
324
307
|
toDelete.forEach(key => this.mtimes.delete(key));
|
|
325
|
-
this.triggerChanges(( toDelete.map(
|
|
308
|
+
this.triggerChanges(( (toDelete.map(
|
|
326
309
|
path => ({ resource: resource.with({ path }), type: 2 })
|
|
327
|
-
)));
|
|
310
|
+
))));
|
|
328
311
|
}
|
|
329
312
|
async tree(resource) {
|
|
330
313
|
const stat = await this.stat(resource);
|
|
@@ -351,13 +334,13 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
351
334
|
getFiletree() {
|
|
352
335
|
if (!this.cachedFiletree) {
|
|
353
336
|
this.cachedFiletree = (async () => {
|
|
354
|
-
const rootNode = ( new IndexedDBFileSystemNode({
|
|
355
|
-
children: ( new Map()),
|
|
337
|
+
const rootNode = ( (new IndexedDBFileSystemNode({
|
|
338
|
+
children: ( (new Map())),
|
|
356
339
|
path: '',
|
|
357
340
|
type: FileType.Directory
|
|
358
|
-
}));
|
|
341
|
+
})));
|
|
359
342
|
const result = await this.indexedDB.runInTransaction(this.store, 'readonly', objectStore => objectStore.getAllKeys());
|
|
360
|
-
const keys = ( result.map(key => ( key.toString())));
|
|
343
|
+
const keys = ( (result.map(key => ( (key.toString())))));
|
|
361
344
|
keys.forEach(key => rootNode.add(key, { type: 'file' }));
|
|
362
345
|
return rootNode;
|
|
363
346
|
})();
|
|
@@ -370,17 +353,17 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
370
353
|
const fileTree = await this.getFiletree();
|
|
371
354
|
for (const [resource, content] of files) {
|
|
372
355
|
fileTree.add(resource.path, { type: 'file', size: content.byteLength });
|
|
373
|
-
this.mtimes.set(( resource.toString()), Date.now());
|
|
356
|
+
this.mtimes.set(( (resource.toString())), Date.now());
|
|
374
357
|
}
|
|
375
|
-
this.triggerChanges(( files.map(([resource]) => ({ resource, type: 0 }))));
|
|
358
|
+
this.triggerChanges(( (files.map(([resource]) => ({ resource, type: 0 })))));
|
|
376
359
|
}
|
|
377
360
|
async writeMany() {
|
|
378
361
|
if (this.fileWriteBatch.length) {
|
|
379
362
|
const fileBatch = this.fileWriteBatch.splice(0, this.fileWriteBatch.length);
|
|
380
363
|
try {
|
|
381
|
-
await this.indexedDB.runInTransaction(this.store, 'readwrite', objectStore => ( fileBatch.map(entry => {
|
|
364
|
+
await this.indexedDB.runInTransaction(this.store, 'readwrite', objectStore => ( (fileBatch.map(entry => {
|
|
382
365
|
return objectStore.put(entry.content, entry.resource.path);
|
|
383
|
-
})));
|
|
366
|
+
}))));
|
|
384
367
|
}
|
|
385
368
|
catch (ex) {
|
|
386
369
|
if (ex instanceof DOMException && ex.name === 'QuotaExceededError') {
|
|
@@ -392,7 +375,7 @@ class IndexedDBFileSystemProvider extends Disposable {
|
|
|
392
375
|
}
|
|
393
376
|
async deleteKeys(keys) {
|
|
394
377
|
if (keys.length) {
|
|
395
|
-
await this.indexedDB.runInTransaction(this.store, 'readwrite', objectStore => ( keys.map(key => objectStore.delete(key))));
|
|
378
|
+
await this.indexedDB.runInTransaction(this.store, 'readwrite', objectStore => ( (keys.map(key => objectStore.delete(key)))));
|
|
396
379
|
}
|
|
397
380
|
}
|
|
398
381
|
async reset() {
|