@theia/filesystem 1.45.0 → 1.46.0-next.72
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/README.md +30 -30
- package/lib/browser/breadcrumbs/filepath-breadcrumb.d.ts +15 -15
- package/lib/browser/breadcrumbs/filepath-breadcrumb.js +41 -41
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.d.ts +13 -13
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.js +81 -81
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-contribution.d.ts +27 -27
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-contribution.js +126 -126
- package/lib/browser/download/file-download-command-contribution.d.ts +18 -18
- package/lib/browser/download/file-download-command-contribution.js +83 -83
- package/lib/browser/download/file-download-frontend-module.d.ts +3 -3
- package/lib/browser/download/file-download-frontend-module.js +25 -25
- package/lib/browser/download/file-download-service.d.ts +28 -28
- package/lib/browser/download/file-download-service.js +175 -175
- package/lib/browser/file-dialog/file-dialog-container.d.ts +5 -5
- package/lib/browser/file-dialog/file-dialog-container.js +60 -60
- package/lib/browser/file-dialog/file-dialog-hidden-files-renderer.d.ts +15 -15
- package/lib/browser/file-dialog/file-dialog-hidden-files-renderer.js +67 -67
- package/lib/browser/file-dialog/file-dialog-model.d.ts +25 -25
- package/lib/browser/file-dialog/file-dialog-model.js +108 -108
- package/lib/browser/file-dialog/file-dialog-module.d.ts +3 -3
- package/lib/browser/file-dialog/file-dialog-module.js +45 -45
- package/lib/browser/file-dialog/file-dialog-service.d.ts +32 -32
- package/lib/browser/file-dialog/file-dialog-service.js +109 -109
- package/lib/browser/file-dialog/file-dialog-tree-filters-renderer.d.ts +39 -39
- package/lib/browser/file-dialog/file-dialog-tree-filters-renderer.js +92 -92
- package/lib/browser/file-dialog/file-dialog-tree.d.ts +26 -26
- package/lib/browser/file-dialog/file-dialog-tree.js +88 -88
- package/lib/browser/file-dialog/file-dialog-widget.d.ts +15 -15
- package/lib/browser/file-dialog/file-dialog-widget.js +86 -86
- package/lib/browser/file-dialog/file-dialog.d.ts +129 -129
- package/lib/browser/file-dialog/file-dialog.js +362 -362
- package/lib/browser/file-dialog/index.d.ts +4 -4
- package/lib/browser/file-dialog/index.js +31 -31
- package/lib/browser/file-resource.d.ts +66 -63
- package/lib/browser/file-resource.d.ts.map +1 -1
- package/lib/browser/file-resource.js +362 -352
- package/lib/browser/file-resource.js.map +1 -1
- package/lib/browser/file-selection.d.ts +14 -14
- package/lib/browser/file-selection.js +36 -36
- package/lib/browser/file-service.d.ts +413 -412
- package/lib/browser/file-service.d.ts.map +1 -1
- package/lib/browser/file-service.js +1362 -1360
- package/lib/browser/file-service.js.map +1 -1
- package/lib/browser/file-tree/file-tree-container.d.ts +3 -3
- package/lib/browser/file-tree/file-tree-container.js +35 -35
- package/lib/browser/file-tree/file-tree-decorator-adapter.d.ts +30 -30
- package/lib/browser/file-tree/file-tree-decorator-adapter.js +177 -177
- package/lib/browser/file-tree/file-tree-label-provider.d.ts +12 -12
- package/lib/browser/file-tree/file-tree-label-provider.js +62 -62
- package/lib/browser/file-tree/file-tree-model.d.ts +37 -37
- package/lib/browser/file-tree/file-tree-model.js +225 -225
- package/lib/browser/file-tree/file-tree-widget.d.ts +44 -44
- package/lib/browser/file-tree/file-tree-widget.js +328 -328
- package/lib/browser/file-tree/file-tree.d.ts +46 -46
- package/lib/browser/file-tree/file-tree.js +184 -184
- package/lib/browser/file-tree/index.d.ts +6 -6
- package/lib/browser/file-tree/index.js +33 -33
- package/lib/browser/file-upload-service.d.ts +109 -111
- package/lib/browser/file-upload-service.d.ts.map +1 -1
- package/lib/browser/file-upload-service.js +442 -442
- package/lib/browser/file-upload-service.js.map +1 -1
- package/lib/browser/filesystem-frontend-contribution.d.ts +63 -63
- package/lib/browser/filesystem-frontend-contribution.js +327 -327
- package/lib/browser/filesystem-frontend-module.d.ts +5 -5
- package/lib/browser/filesystem-frontend-module.js +64 -64
- package/lib/browser/filesystem-preferences.d.ts +29 -29
- package/lib/browser/filesystem-preferences.js +110 -110
- package/lib/browser/filesystem-save-resource-service.d.ts +29 -29
- package/lib/browser/filesystem-save-resource-service.d.ts.map +1 -1
- package/lib/browser/filesystem-save-resource-service.js +143 -142
- package/lib/browser/filesystem-save-resource-service.js.map +1 -1
- package/lib/browser/filesystem-watcher-error-handler.d.ts +10 -10
- package/lib/browser/filesystem-watcher-error-handler.js +69 -69
- package/lib/browser/index.d.ts +5 -5
- package/lib/browser/index.js +32 -32
- package/lib/browser/location/index.d.ts +2 -2
- package/lib/browser/location/index.js +29 -29
- package/lib/browser/location/location-renderer.d.ts +100 -100
- package/lib/browser/location/location-renderer.js +354 -354
- package/lib/browser/location/location-service.d.ts +5 -5
- package/lib/browser/location/location-service.js +17 -17
- package/lib/browser/remote-file-service-contribution.d.ts +6 -6
- package/lib/browser/remote-file-service-contribution.js +47 -47
- package/lib/browser-only/browser-only-filesystem-frontend-module.d.ts +4 -0
- package/lib/browser-only/browser-only-filesystem-frontend-module.d.ts.map +1 -0
- package/lib/browser-only/browser-only-filesystem-frontend-module.js +41 -0
- package/lib/browser-only/browser-only-filesystem-frontend-module.js.map +1 -0
- package/lib/browser-only/browser-only-filesystem-provider-server.d.ts +12 -0
- package/lib/browser-only/browser-only-filesystem-provider-server.d.ts.map +1 -0
- package/lib/browser-only/browser-only-filesystem-provider-server.js +45 -0
- package/lib/browser-only/browser-only-filesystem-provider-server.js.map +1 -0
- package/lib/browser-only/browserfs-filesystem-initialization.d.ts +13 -0
- package/lib/browser-only/browserfs-filesystem-initialization.d.ts.map +1 -0
- package/lib/browser-only/browserfs-filesystem-initialization.js +60 -0
- package/lib/browser-only/browserfs-filesystem-initialization.js.map +1 -0
- package/lib/browser-only/browserfs-filesystem-provider.d.ts +46 -0
- package/lib/browser-only/browserfs-filesystem-provider.d.ts.map +1 -0
- package/lib/browser-only/browserfs-filesystem-provider.js +451 -0
- package/lib/browser-only/browserfs-filesystem-provider.js.map +1 -0
- package/lib/common/delegating-file-system-provider.d.ts +76 -76
- package/lib/common/delegating-file-system-provider.js +168 -168
- package/lib/common/download/file-download-data.d.ts +6 -6
- package/lib/common/download/file-download-data.js +26 -26
- package/lib/common/file-upload.d.ts +1 -1
- package/lib/common/file-upload.js +19 -19
- package/lib/common/files.d.ts +651 -651
- package/lib/common/files.js +347 -347
- package/lib/common/files.spec.d.ts +1 -1
- package/lib/common/files.spec.js +51 -51
- package/lib/common/filesystem-utils.d.ts +14 -14
- package/lib/common/filesystem-utils.js +63 -63
- package/lib/common/filesystem-utils.spec.d.ts +1 -1
- package/lib/common/filesystem-utils.spec.js +378 -378
- package/lib/common/filesystem-watcher-protocol.d.ts +71 -71
- package/lib/common/filesystem-watcher-protocol.js +20 -20
- package/lib/common/filesystem.d.ts +22 -22
- package/lib/common/filesystem.js +42 -42
- package/lib/common/index.d.ts +2 -2
- package/lib/common/index.js +29 -29
- package/lib/common/io.d.ts +19 -19
- package/lib/common/io.js +110 -110
- package/lib/common/remote-file-system-provider.d.ts +164 -164
- package/lib/common/remote-file-system-provider.js +413 -413
- package/lib/electron-browser/file-dialog/electron-file-dialog-module.d.ts +3 -3
- package/lib/electron-browser/file-dialog/electron-file-dialog-module.js +24 -24
- package/lib/electron-browser/file-dialog/electron-file-dialog-service.d.ts +19 -19
- package/lib/electron-browser/file-dialog/electron-file-dialog-service.js +156 -156
- package/lib/electron-browser/file-dialog/electron-file-dialog-service.js.map +1 -1
- package/lib/electron-browser/preload.d.ts +1 -1
- package/lib/electron-browser/preload.js +30 -30
- package/lib/electron-common/electron-api.d.ts +34 -34
- package/lib/electron-common/electron-api.js +20 -20
- package/lib/electron-main/electron-api-main.d.ts +5 -5
- package/lib/electron-main/electron-api-main.js +78 -78
- package/lib/electron-main/electron-main-module.d.ts +3 -3
- package/lib/electron-main/electron-main-module.js +24 -24
- package/lib/node/disk-file-system-provider.d.ts +72 -72
- package/lib/node/disk-file-system-provider.d.ts.map +1 -1
- package/lib/node/disk-file-system-provider.js +795 -789
- package/lib/node/disk-file-system-provider.js.map +1 -1
- package/lib/node/disk-file-system-provider.spec.d.ts +1 -1
- package/lib/node/disk-file-system-provider.spec.js +122 -91
- package/lib/node/disk-file-system-provider.spec.js.map +1 -1
- package/lib/node/download/directory-archiver.d.ts +9 -9
- package/lib/node/download/directory-archiver.js +132 -132
- package/lib/node/download/directory-archiver.js.map +1 -1
- package/lib/node/download/directory-archiver.spec.d.ts +1 -1
- package/lib/node/download/directory-archiver.spec.js +97 -97
- package/lib/node/download/directory-archiver.spec.js.map +1 -1
- package/lib/node/download/file-download-backend-module.d.ts +3 -3
- package/lib/node/download/file-download-backend-module.js +32 -32
- package/lib/node/download/file-download-cache.d.ts +21 -21
- package/lib/node/download/file-download-cache.js +90 -90
- package/lib/node/download/file-download-endpoint.d.ts +11 -11
- package/lib/node/download/file-download-endpoint.js +75 -75
- package/lib/node/download/file-download-endpoint.js.map +1 -1
- package/lib/node/download/file-download-handler.d.ts +50 -50
- package/lib/node/download/file-download-handler.d.ts.map +1 -1
- package/lib/node/download/file-download-handler.js +315 -315
- package/lib/node/download/file-download-handler.js.map +1 -1
- package/lib/node/download/test/mock-directory-archiver.d.ts +7 -7
- package/lib/node/download/test/mock-directory-archiver.js +29 -29
- package/lib/node/file-change-collection.d.ts +22 -22
- package/lib/node/file-change-collection.js +77 -77
- package/lib/node/file-change-collection.spec.d.ts +1 -1
- package/lib/node/file-change-collection.spec.js +90 -90
- package/lib/node/file-change-collection.spec.js.map +1 -1
- package/lib/node/filesystem-backend-module.d.ts +26 -26
- package/lib/node/filesystem-backend-module.js +120 -120
- package/lib/node/filesystem-watcher-client.d.ts +23 -23
- package/lib/node/filesystem-watcher-client.js +83 -83
- package/lib/node/filesystem-watcher-dispatcher.d.ts +23 -23
- package/lib/node/filesystem-watcher-dispatcher.js +85 -85
- package/lib/node/node-file-upload-service.d.ts +16 -16
- package/lib/node/node-file-upload-service.js +84 -84
- package/lib/node/nsfw-watcher/index.d.ts +3 -3
- package/lib/node/nsfw-watcher/index.js +39 -39
- package/lib/node/nsfw-watcher/nsfw-filesystem-service.d.ts +191 -191
- package/lib/node/nsfw-watcher/nsfw-filesystem-service.js +405 -405
- package/lib/node/nsfw-watcher/nsfw-filesystem-service.js.map +1 -1
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.spec.d.ts +1 -1
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.spec.js +151 -151
- package/lib/node/nsfw-watcher/nsfw-options.d.ts +6 -6
- package/lib/node/nsfw-watcher/nsfw-options.js +22 -22
- package/package.json +8 -6
- package/src/browser/breadcrumbs/filepath-breadcrumb.ts +43 -43
- package/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts +65 -65
- package/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts +129 -129
- package/src/browser/download/file-download-command-contribution.ts +83 -83
- package/src/browser/download/file-download-frontend-module.ts +25 -25
- package/src/browser/download/file-download-service.ts +179 -179
- package/src/browser/file-dialog/file-dialog-container.ts +67 -67
- package/src/browser/file-dialog/file-dialog-hidden-files-renderer.tsx +59 -59
- package/src/browser/file-dialog/file-dialog-model.ts +96 -96
- package/src/browser/file-dialog/file-dialog-module.ts +44 -44
- package/src/browser/file-dialog/file-dialog-service.ts +99 -99
- package/src/browser/file-dialog/file-dialog-tree-filters-renderer.tsx +100 -100
- package/src/browser/file-dialog/file-dialog-tree.ts +89 -89
- package/src/browser/file-dialog/file-dialog-widget.ts +75 -75
- package/src/browser/file-dialog/file-dialog.ts +434 -434
- package/src/browser/file-dialog/index.ts +20 -20
- package/src/browser/file-resource.ts +373 -361
- package/src/browser/file-selection.ts +44 -44
- package/src/browser/file-service.ts +1817 -1814
- package/src/browser/file-tree/file-tree-container.ts +36 -36
- package/src/browser/file-tree/file-tree-decorator-adapter.ts +159 -159
- package/src/browser/file-tree/file-tree-label-provider.ts +53 -53
- package/src/browser/file-tree/file-tree-model.ts +212 -212
- package/src/browser/file-tree/file-tree-widget.tsx +327 -327
- package/src/browser/file-tree/file-tree.ts +183 -183
- package/src/browser/file-tree/index.ts +22 -22
- package/src/browser/file-upload-service.ts +539 -541
- package/src/browser/filesystem-frontend-contribution.ts +338 -338
- package/src/browser/filesystem-frontend-module.ts +77 -77
- package/src/browser/filesystem-preferences.ts +139 -139
- package/src/browser/filesystem-save-resource-service.ts +125 -124
- package/src/browser/filesystem-watcher-error-handler.ts +60 -60
- package/src/browser/index.ts +21 -21
- package/src/browser/location/index.ts +18 -18
- package/src/browser/location/location-renderer.tsx +404 -404
- package/src/browser/location/location-service.ts +22 -22
- package/src/browser/remote-file-service-contribution.ts +38 -38
- package/src/browser/style/file-dialog.css +208 -208
- package/src/browser/style/file-icons.css +64 -64
- package/src/browser/style/filepath-breadcrumbs.css +20 -20
- package/src/browser/style/index.css +36 -36
- package/src/browser-only/browser-only-filesystem-frontend-module.ts +38 -0
- package/src/browser-only/browser-only-filesystem-provider-server.ts +32 -0
- package/src/browser-only/browserfs-filesystem-initialization.ts +61 -0
- package/src/browser-only/browserfs-filesystem-provider.ts +462 -0
- package/src/common/delegating-file-system-provider.ts +226 -226
- package/src/common/download/README.md +30 -30
- package/src/common/download/file-download-data.ts +27 -27
- package/src/common/file-upload.ts +17 -17
- package/src/common/files.spec.ts +51 -51
- package/src/common/files.ts +983 -983
- package/src/common/filesystem-utils.spec.ts +411 -411
- package/src/common/filesystem-utils.ts +64 -64
- package/src/common/filesystem-watcher-protocol.ts +96 -96
- package/src/common/filesystem.ts +43 -43
- package/src/common/index.ts +18 -18
- package/src/common/io.ts +150 -150
- package/src/common/remote-file-system-provider.ts +511 -511
- package/src/electron-browser/file-dialog/electron-file-dialog-module.ts +24 -24
- package/src/electron-browser/file-dialog/electron-file-dialog-service.ts +165 -165
- package/src/electron-browser/preload.ts +31 -31
- package/src/electron-common/electron-api.ts +55 -55
- package/src/electron-main/electron-api-main.ts +78 -78
- package/src/electron-main/electron-main-module.ts +23 -23
- package/src/node/disk-file-system-provider.spec.ts +142 -109
- package/src/node/disk-file-system-provider.ts +915 -910
- package/src/node/download/directory-archiver.spec.ts +104 -104
- package/src/node/download/directory-archiver.ts +126 -126
- package/src/node/download/file-download-backend-module.ts +32 -32
- package/src/node/download/file-download-cache.ts +88 -88
- package/src/node/download/file-download-endpoint.ts +63 -63
- package/src/node/download/file-download-handler.ts +304 -304
- package/src/node/download/test/mock-directory-archiver.ts +30 -30
- package/src/node/file-change-collection.spec.ts +110 -110
- package/src/node/file-change-collection.ts +78 -78
- package/src/node/filesystem-backend-module.ts +140 -140
- package/src/node/filesystem-watcher-client.ts +72 -72
- package/src/node/filesystem-watcher-dispatcher.ts +82 -82
- package/src/node/node-file-upload-service.ts +80 -80
- package/src/node/nsfw-watcher/index.ts +45 -45
- package/src/node/nsfw-watcher/nsfw-filesystem-service.ts +481 -481
- package/src/node/nsfw-watcher/nsfw-filesystem-watcher.spec.ts +182 -182
- package/src/node/nsfw-watcher/nsfw-options.ts +23 -23
- package/src/typings/dom.webkit.d.ts +77 -77
- package/src/typings/mv/index.d.ts +21 -21
- package/src/typings/nsfw/index.d.ts +18 -18
- package/src/typings/trash/index.d.ts +20 -20
|
@@ -1,414 +1,414 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.FileSystemProviderServer = exports.RemoteFileSystemProvider = exports.RemoteFileSystemProxyFactory = exports.RemoteFileSystemProviderError = exports.RemoteFileSystemServer = exports.remoteFileSystemPath = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
30
|
-
const event_1 = require("@theia/core/lib/common/event");
|
|
31
|
-
const disposable_1 = require("@theia/core/lib/common/disposable");
|
|
32
|
-
const buffer_1 = require("@theia/core/lib/common/buffer");
|
|
33
|
-
const files_1 = require("./files");
|
|
34
|
-
const proxy_factory_1 = require("@theia/core/lib/common/messaging/proxy-factory");
|
|
35
|
-
const application_error_1 = require("@theia/core/lib/common/application-error");
|
|
36
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
37
|
-
const stream_1 = require("@theia/core/lib/common/stream");
|
|
38
|
-
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
39
|
-
exports.remoteFileSystemPath = '/services/remote-filesystem';
|
|
40
|
-
exports.RemoteFileSystemServer = Symbol('RemoteFileSystemServer');
|
|
41
|
-
exports.RemoteFileSystemProviderError = application_error_1.ApplicationError.declare(-33005, (message, data, stack) => ({ message, data, stack }));
|
|
42
|
-
class RemoteFileSystemProxyFactory extends proxy_factory_1.RpcProxyFactory {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
serializeError(e) {
|
|
45
|
-
if (e instanceof files_1.FileSystemProviderError) {
|
|
46
|
-
const { code, name } = e;
|
|
47
|
-
return super.serializeError((0, exports.RemoteFileSystemProviderError)(e.message, { code, name }, e.stack));
|
|
48
|
-
}
|
|
49
|
-
return super.serializeError(e);
|
|
50
|
-
}
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
deserializeError(capturedError, e) {
|
|
53
|
-
const error = super.deserializeError(capturedError, e);
|
|
54
|
-
if (exports.RemoteFileSystemProviderError.is(error)) {
|
|
55
|
-
const fileOperationError = new files_1.FileSystemProviderError(error.message, error.data.code);
|
|
56
|
-
fileOperationError.name = error.data.name;
|
|
57
|
-
fileOperationError.stack = error.stack;
|
|
58
|
-
return fileOperationError;
|
|
59
|
-
}
|
|
60
|
-
return e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.RemoteFileSystemProxyFactory = RemoteFileSystemProxyFactory;
|
|
64
|
-
/**
|
|
65
|
-
* Frontend component.
|
|
66
|
-
*
|
|
67
|
-
* Wraps the remote filesystem provider living on the backend.
|
|
68
|
-
*/
|
|
69
|
-
let RemoteFileSystemProvider = class RemoteFileSystemProvider {
|
|
70
|
-
constructor() {
|
|
71
|
-
this.onDidChangeFileEmitter = new event_1.Emitter();
|
|
72
|
-
this.onDidChangeFile = this.onDidChangeFileEmitter.event;
|
|
73
|
-
this.onFileWatchErrorEmitter = new event_1.Emitter();
|
|
74
|
-
this.onFileWatchError = this.onFileWatchErrorEmitter.event;
|
|
75
|
-
this.onDidChangeCapabilitiesEmitter = new event_1.Emitter();
|
|
76
|
-
this.onDidChangeCapabilities = this.onDidChangeCapabilitiesEmitter.event;
|
|
77
|
-
this.onFileStreamDataEmitter = new event_1.Emitter();
|
|
78
|
-
this.onFileStreamData = this.onFileStreamDataEmitter.event;
|
|
79
|
-
this.onFileStreamEndEmitter = new event_1.Emitter();
|
|
80
|
-
this.onFileStreamEnd = this.onFileStreamEndEmitter.event;
|
|
81
|
-
this.toDispose = new disposable_1.DisposableCollection(this.onDidChangeFileEmitter, this.onDidChangeCapabilitiesEmitter, this.onFileStreamDataEmitter, this.onFileStreamEndEmitter);
|
|
82
|
-
this.watcherSequence = 0;
|
|
83
|
-
/**
|
|
84
|
-
* We'll track the currently allocated watchers, in order to re-allocate them
|
|
85
|
-
* with the same options once we reconnect to the backend after a disconnection.
|
|
86
|
-
*/
|
|
87
|
-
this.watchOptions = new Map();
|
|
88
|
-
this._capabilities = 0;
|
|
89
|
-
this.readyDeferred = new promise_util_1.Deferred();
|
|
90
|
-
this.ready = this.readyDeferred.promise;
|
|
91
|
-
}
|
|
92
|
-
get capabilities() { return this._capabilities; }
|
|
93
|
-
init() {
|
|
94
|
-
this.server.getCapabilities().then(capabilities => {
|
|
95
|
-
this._capabilities = capabilities;
|
|
96
|
-
this.readyDeferred.resolve();
|
|
97
|
-
}, this.readyDeferred.reject);
|
|
98
|
-
this.server.setClient({
|
|
99
|
-
notifyDidChangeFile: ({ changes }) => {
|
|
100
|
-
this.onDidChangeFileEmitter.fire(changes.map(event => ({ resource: new uri_1.default(event.resource), type: event.type })));
|
|
101
|
-
},
|
|
102
|
-
notifyFileWatchError: () => {
|
|
103
|
-
this.onFileWatchErrorEmitter.fire();
|
|
104
|
-
},
|
|
105
|
-
notifyDidChangeCapabilities: capabilities => this.setCapabilities(capabilities),
|
|
106
|
-
onFileStreamData: (handle, data) => this.onFileStreamDataEmitter.fire([handle, data]),
|
|
107
|
-
onFileStreamEnd: (handle, error) => this.onFileStreamEndEmitter.fire([handle, error])
|
|
108
|
-
});
|
|
109
|
-
const onInitialized = this.server.onDidOpenConnection(() => {
|
|
110
|
-
// skip reconnection on the first connection
|
|
111
|
-
onInitialized.dispose();
|
|
112
|
-
this.toDispose.push(this.server.onDidOpenConnection(() => this.reconnect()));
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
dispose() {
|
|
116
|
-
this.toDispose.dispose();
|
|
117
|
-
}
|
|
118
|
-
setCapabilities(capabilities) {
|
|
119
|
-
this._capabilities = capabilities;
|
|
120
|
-
this.onDidChangeCapabilitiesEmitter.fire(undefined);
|
|
121
|
-
}
|
|
122
|
-
// --- forwarding calls
|
|
123
|
-
stat(resource) {
|
|
124
|
-
return this.server.stat(resource.toString());
|
|
125
|
-
}
|
|
126
|
-
access(resource, mode) {
|
|
127
|
-
return this.server.access(resource.toString(), mode);
|
|
128
|
-
}
|
|
129
|
-
fsPath(resource) {
|
|
130
|
-
return this.server.fsPath(resource.toString());
|
|
131
|
-
}
|
|
132
|
-
open(resource, opts) {
|
|
133
|
-
return this.server.open(resource.toString(), opts);
|
|
134
|
-
}
|
|
135
|
-
close(fd) {
|
|
136
|
-
return this.server.close(fd);
|
|
137
|
-
}
|
|
138
|
-
async read(fd, pos, data, offset, length) {
|
|
139
|
-
const { bytes, bytesRead } = await this.server.read(fd, pos, length);
|
|
140
|
-
// copy back the data that was written into the buffer on the remote
|
|
141
|
-
// side. we need to do this because buffers are not referenced by
|
|
142
|
-
// pointer, but only by value and as such cannot be directly written
|
|
143
|
-
// to from the other process.
|
|
144
|
-
data.set(bytes.slice(0, bytesRead), offset);
|
|
145
|
-
return bytesRead;
|
|
146
|
-
}
|
|
147
|
-
async readFile(resource) {
|
|
148
|
-
const bytes = await this.server.readFile(resource.toString());
|
|
149
|
-
return bytes;
|
|
150
|
-
}
|
|
151
|
-
readFileStream(resource, opts, token) {
|
|
152
|
-
const capturedError = new Error();
|
|
153
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
154
|
-
const stream = (0, stream_1.newWriteableStream)(data => buffer_1.BinaryBuffer.concat(data.map(data => buffer_1.BinaryBuffer.wrap(data))).buffer);
|
|
155
|
-
this.server.readFileStream(resource.toString(), opts, token).then(streamHandle => {
|
|
156
|
-
if (token.isCancellationRequested) {
|
|
157
|
-
stream.end((0, cancellation_1.cancelled)());
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const toDispose = new disposable_1.DisposableCollection(token.onCancellationRequested(() => stream.end((0, cancellation_1.cancelled)())), this.onFileStreamData(([handle, data]) => {
|
|
161
|
-
if (streamHandle === handle) {
|
|
162
|
-
stream.write(data);
|
|
163
|
-
}
|
|
164
|
-
}), this.onFileStreamEnd(([handle, error]) => {
|
|
165
|
-
if (streamHandle === handle) {
|
|
166
|
-
if (error) {
|
|
167
|
-
const code = ('code' in error && error.code) || files_1.FileSystemProviderErrorCode.Unknown;
|
|
168
|
-
const fileOperationError = new files_1.FileSystemProviderError(error.message, code);
|
|
169
|
-
fileOperationError.name = error.name;
|
|
170
|
-
const capturedStack = capturedError.stack || '';
|
|
171
|
-
fileOperationError.stack = `${capturedStack}\nCaused by: ${error.stack}`;
|
|
172
|
-
stream.end(fileOperationError);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
stream.end();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}));
|
|
179
|
-
stream.on('end', () => toDispose.dispose());
|
|
180
|
-
}, error => stream.end(error));
|
|
181
|
-
return stream;
|
|
182
|
-
}
|
|
183
|
-
write(fd, pos, data, offset, length) {
|
|
184
|
-
return this.server.write(fd, pos, data, offset, length);
|
|
185
|
-
}
|
|
186
|
-
writeFile(resource, content, opts) {
|
|
187
|
-
return this.server.writeFile(resource.toString(), content, opts);
|
|
188
|
-
}
|
|
189
|
-
delete(resource, opts) {
|
|
190
|
-
return this.server.delete(resource.toString(), opts);
|
|
191
|
-
}
|
|
192
|
-
mkdir(resource) {
|
|
193
|
-
return this.server.mkdir(resource.toString());
|
|
194
|
-
}
|
|
195
|
-
readdir(resource) {
|
|
196
|
-
return this.server.readdir(resource.toString());
|
|
197
|
-
}
|
|
198
|
-
rename(resource, target, opts) {
|
|
199
|
-
return this.server.rename(resource.toString(), target.toString(), opts);
|
|
200
|
-
}
|
|
201
|
-
copy(resource, target, opts) {
|
|
202
|
-
return this.server.copy(resource.toString(), target.toString(), opts);
|
|
203
|
-
}
|
|
204
|
-
updateFile(resource, changes, opts) {
|
|
205
|
-
return this.server.updateFile(resource.toString(), changes, opts);
|
|
206
|
-
}
|
|
207
|
-
watch(resource, options) {
|
|
208
|
-
const watcherId = this.watcherSequence++;
|
|
209
|
-
const uri = resource.toString();
|
|
210
|
-
this.watchOptions.set(watcherId, { uri, options });
|
|
211
|
-
this.server.watch(watcherId, uri, options);
|
|
212
|
-
const toUnwatch = disposable_1.Disposable.create(() => {
|
|
213
|
-
this.watchOptions.delete(watcherId);
|
|
214
|
-
this.server.unwatch(watcherId);
|
|
215
|
-
});
|
|
216
|
-
this.toDispose.push(toUnwatch);
|
|
217
|
-
return toUnwatch;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* When a frontend disconnects (e.g. bad connection) the backend resources will be cleared.
|
|
221
|
-
*
|
|
222
|
-
* This means that we need to re-allocate the watchers when a frontend reconnects.
|
|
223
|
-
*/
|
|
224
|
-
reconnect() {
|
|
225
|
-
for (const [watcher, { uri, options }] of this.watchOptions.entries()) {
|
|
226
|
-
this.server.watch(watcher, uri, options);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
__decorate([
|
|
231
|
-
(0, inversify_1.inject)(exports.RemoteFileSystemServer),
|
|
232
|
-
__metadata("design:type", Object)
|
|
233
|
-
], RemoteFileSystemProvider.prototype, "server", void 0);
|
|
234
|
-
__decorate([
|
|
235
|
-
(0, inversify_1.postConstruct)(),
|
|
236
|
-
__metadata("design:type", Function),
|
|
237
|
-
__metadata("design:paramtypes", []),
|
|
238
|
-
__metadata("design:returntype", void 0)
|
|
239
|
-
], RemoteFileSystemProvider.prototype, "init", null);
|
|
240
|
-
RemoteFileSystemProvider = __decorate([
|
|
241
|
-
(0, inversify_1.injectable)()
|
|
242
|
-
], RemoteFileSystemProvider);
|
|
243
|
-
exports.RemoteFileSystemProvider = RemoteFileSystemProvider;
|
|
244
|
-
/**
|
|
245
|
-
* Backend component.
|
|
246
|
-
*
|
|
247
|
-
* JSON-RPC server exposing a wrapped file system provider remotely.
|
|
248
|
-
*/
|
|
249
|
-
let FileSystemProviderServer = class FileSystemProviderServer {
|
|
250
|
-
constructor() {
|
|
251
|
-
this.BUFFER_SIZE = 64 * 1024;
|
|
252
|
-
/**
|
|
253
|
-
* Mapping of `watcherId` to a disposable watcher handle.
|
|
254
|
-
*/
|
|
255
|
-
this.watchers = new Map();
|
|
256
|
-
this.toDispose = new disposable_1.DisposableCollection();
|
|
257
|
-
this.readFileStreamSeq = 0;
|
|
258
|
-
}
|
|
259
|
-
dispose() {
|
|
260
|
-
this.toDispose.dispose();
|
|
261
|
-
}
|
|
262
|
-
setClient(client) {
|
|
263
|
-
this.client = client;
|
|
264
|
-
}
|
|
265
|
-
init() {
|
|
266
|
-
if (this.provider.dispose) {
|
|
267
|
-
this.toDispose.push(disposable_1.Disposable.create(() => this.provider.dispose()));
|
|
268
|
-
}
|
|
269
|
-
this.toDispose.push(this.provider.onDidChangeCapabilities(() => {
|
|
270
|
-
if (this.client) {
|
|
271
|
-
this.client.notifyDidChangeCapabilities(this.provider.capabilities);
|
|
272
|
-
}
|
|
273
|
-
}));
|
|
274
|
-
this.toDispose.push(this.provider.onDidChangeFile(changes => {
|
|
275
|
-
if (this.client) {
|
|
276
|
-
this.client.notifyDidChangeFile({
|
|
277
|
-
changes: changes.map(({ resource, type }) => ({ resource: resource.toString(), type }))
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}));
|
|
281
|
-
this.toDispose.push(this.provider.onFileWatchError(() => {
|
|
282
|
-
if (this.client) {
|
|
283
|
-
this.client.notifyFileWatchError();
|
|
284
|
-
}
|
|
285
|
-
}));
|
|
286
|
-
}
|
|
287
|
-
async getCapabilities() {
|
|
288
|
-
return this.provider.capabilities;
|
|
289
|
-
}
|
|
290
|
-
stat(resource) {
|
|
291
|
-
return this.provider.stat(new uri_1.default(resource));
|
|
292
|
-
}
|
|
293
|
-
access(resource, mode) {
|
|
294
|
-
if ((0, files_1.hasAccessCapability)(this.provider)) {
|
|
295
|
-
return this.provider.access(new uri_1.default(resource), mode);
|
|
296
|
-
}
|
|
297
|
-
throw new Error('not supported');
|
|
298
|
-
}
|
|
299
|
-
async fsPath(resource) {
|
|
300
|
-
if ((0, files_1.hasAccessCapability)(this.provider)) {
|
|
301
|
-
return this.provider.fsPath(new uri_1.default(resource));
|
|
302
|
-
}
|
|
303
|
-
throw new Error('not supported');
|
|
304
|
-
}
|
|
305
|
-
open(resource, opts) {
|
|
306
|
-
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
307
|
-
return this.provider.open(new uri_1.default(resource), opts);
|
|
308
|
-
}
|
|
309
|
-
throw new Error('not supported');
|
|
310
|
-
}
|
|
311
|
-
close(fd) {
|
|
312
|
-
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
313
|
-
return this.provider.close(fd);
|
|
314
|
-
}
|
|
315
|
-
throw new Error('not supported');
|
|
316
|
-
}
|
|
317
|
-
async read(fd, pos, length) {
|
|
318
|
-
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
319
|
-
const buffer = buffer_1.BinaryBuffer.alloc(this.BUFFER_SIZE);
|
|
320
|
-
const bytes = buffer.buffer;
|
|
321
|
-
const bytesRead = await this.provider.read(fd, pos, bytes, 0, length);
|
|
322
|
-
return { bytes, bytesRead };
|
|
323
|
-
}
|
|
324
|
-
throw new Error('not supported');
|
|
325
|
-
}
|
|
326
|
-
write(fd, pos, data, offset, length) {
|
|
327
|
-
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
328
|
-
return this.provider.write(fd, pos, data, offset, length);
|
|
329
|
-
}
|
|
330
|
-
throw new Error('not supported');
|
|
331
|
-
}
|
|
332
|
-
async readFile(resource) {
|
|
333
|
-
if ((0, files_1.hasReadWriteCapability)(this.provider)) {
|
|
334
|
-
return this.provider.readFile(new uri_1.default(resource));
|
|
335
|
-
}
|
|
336
|
-
throw new Error('not supported');
|
|
337
|
-
}
|
|
338
|
-
writeFile(resource, content, opts) {
|
|
339
|
-
if ((0, files_1.hasReadWriteCapability)(this.provider)) {
|
|
340
|
-
return this.provider.writeFile(new uri_1.default(resource), content, opts);
|
|
341
|
-
}
|
|
342
|
-
throw new Error('not supported');
|
|
343
|
-
}
|
|
344
|
-
delete(resource, opts) {
|
|
345
|
-
return this.provider.delete(new uri_1.default(resource), opts);
|
|
346
|
-
}
|
|
347
|
-
mkdir(resource) {
|
|
348
|
-
return this.provider.mkdir(new uri_1.default(resource));
|
|
349
|
-
}
|
|
350
|
-
readdir(resource) {
|
|
351
|
-
return this.provider.readdir(new uri_1.default(resource));
|
|
352
|
-
}
|
|
353
|
-
rename(source, target, opts) {
|
|
354
|
-
return this.provider.rename(new uri_1.default(source), new uri_1.default(target), opts);
|
|
355
|
-
}
|
|
356
|
-
copy(source, target, opts) {
|
|
357
|
-
if ((0, files_1.hasFileFolderCopyCapability)(this.provider)) {
|
|
358
|
-
return this.provider.copy(new uri_1.default(source), new uri_1.default(target), opts);
|
|
359
|
-
}
|
|
360
|
-
throw new Error('not supported');
|
|
361
|
-
}
|
|
362
|
-
updateFile(resource, changes, opts) {
|
|
363
|
-
if ((0, files_1.hasUpdateCapability)(this.provider)) {
|
|
364
|
-
return this.provider.updateFile(new uri_1.default(resource), changes, opts);
|
|
365
|
-
}
|
|
366
|
-
throw new Error('not supported');
|
|
367
|
-
}
|
|
368
|
-
async watch(requestedWatcherId, resource, opts) {
|
|
369
|
-
if (this.watchers.has(requestedWatcherId)) {
|
|
370
|
-
throw new Error('watcher id is already allocated!');
|
|
371
|
-
}
|
|
372
|
-
const watcher = this.provider.watch(new uri_1.default(resource), opts);
|
|
373
|
-
this.watchers.set(requestedWatcherId, watcher);
|
|
374
|
-
this.toDispose.push(disposable_1.Disposable.create(() => this.unwatch(requestedWatcherId)));
|
|
375
|
-
}
|
|
376
|
-
async unwatch(watcherId) {
|
|
377
|
-
const watcher = this.watchers.get(watcherId);
|
|
378
|
-
if (watcher) {
|
|
379
|
-
this.watchers.delete(watcherId);
|
|
380
|
-
watcher.dispose();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
async readFileStream(resource, opts, token) {
|
|
384
|
-
if ((0, files_1.hasFileReadStreamCapability)(this.provider)) {
|
|
385
|
-
const handle = this.readFileStreamSeq++;
|
|
386
|
-
const stream = this.provider.readFileStream(new uri_1.default(resource), opts, token);
|
|
387
|
-
stream.on('data', data => { var _a; return (_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamData(handle, data); });
|
|
388
|
-
stream.on('error', error => {
|
|
389
|
-
var _a;
|
|
390
|
-
const code = error instanceof files_1.FileSystemProviderError ? error.code : undefined;
|
|
391
|
-
const { name, message, stack } = error;
|
|
392
|
-
(_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamEnd(handle, { code, name, message, stack });
|
|
393
|
-
});
|
|
394
|
-
stream.on('end', () => { var _a; return (_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamEnd(handle, undefined); });
|
|
395
|
-
return handle;
|
|
396
|
-
}
|
|
397
|
-
throw new Error('not supported');
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
__decorate([
|
|
401
|
-
(0, inversify_1.inject)(files_1.FileSystemProvider),
|
|
402
|
-
__metadata("design:type", Object)
|
|
403
|
-
], FileSystemProviderServer.prototype, "provider", void 0);
|
|
404
|
-
__decorate([
|
|
405
|
-
(0, inversify_1.postConstruct)(),
|
|
406
|
-
__metadata("design:type", Function),
|
|
407
|
-
__metadata("design:paramtypes", []),
|
|
408
|
-
__metadata("design:returntype", void 0)
|
|
409
|
-
], FileSystemProviderServer.prototype, "init", null);
|
|
410
|
-
FileSystemProviderServer = __decorate([
|
|
411
|
-
(0, inversify_1.injectable)()
|
|
412
|
-
], FileSystemProviderServer);
|
|
413
|
-
exports.FileSystemProviderServer = FileSystemProviderServer;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.FileSystemProviderServer = exports.RemoteFileSystemProvider = exports.RemoteFileSystemProxyFactory = exports.RemoteFileSystemProviderError = exports.RemoteFileSystemServer = exports.remoteFileSystemPath = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
30
|
+
const event_1 = require("@theia/core/lib/common/event");
|
|
31
|
+
const disposable_1 = require("@theia/core/lib/common/disposable");
|
|
32
|
+
const buffer_1 = require("@theia/core/lib/common/buffer");
|
|
33
|
+
const files_1 = require("./files");
|
|
34
|
+
const proxy_factory_1 = require("@theia/core/lib/common/messaging/proxy-factory");
|
|
35
|
+
const application_error_1 = require("@theia/core/lib/common/application-error");
|
|
36
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
37
|
+
const stream_1 = require("@theia/core/lib/common/stream");
|
|
38
|
+
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
39
|
+
exports.remoteFileSystemPath = '/services/remote-filesystem';
|
|
40
|
+
exports.RemoteFileSystemServer = Symbol('RemoteFileSystemServer');
|
|
41
|
+
exports.RemoteFileSystemProviderError = application_error_1.ApplicationError.declare(-33005, (message, data, stack) => ({ message, data, stack }));
|
|
42
|
+
class RemoteFileSystemProxyFactory extends proxy_factory_1.RpcProxyFactory {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
serializeError(e) {
|
|
45
|
+
if (e instanceof files_1.FileSystemProviderError) {
|
|
46
|
+
const { code, name } = e;
|
|
47
|
+
return super.serializeError((0, exports.RemoteFileSystemProviderError)(e.message, { code, name }, e.stack));
|
|
48
|
+
}
|
|
49
|
+
return super.serializeError(e);
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
deserializeError(capturedError, e) {
|
|
53
|
+
const error = super.deserializeError(capturedError, e);
|
|
54
|
+
if (exports.RemoteFileSystemProviderError.is(error)) {
|
|
55
|
+
const fileOperationError = new files_1.FileSystemProviderError(error.message, error.data.code);
|
|
56
|
+
fileOperationError.name = error.data.name;
|
|
57
|
+
fileOperationError.stack = error.stack;
|
|
58
|
+
return fileOperationError;
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RemoteFileSystemProxyFactory = RemoteFileSystemProxyFactory;
|
|
64
|
+
/**
|
|
65
|
+
* Frontend component.
|
|
66
|
+
*
|
|
67
|
+
* Wraps the remote filesystem provider living on the backend.
|
|
68
|
+
*/
|
|
69
|
+
let RemoteFileSystemProvider = class RemoteFileSystemProvider {
|
|
70
|
+
constructor() {
|
|
71
|
+
this.onDidChangeFileEmitter = new event_1.Emitter();
|
|
72
|
+
this.onDidChangeFile = this.onDidChangeFileEmitter.event;
|
|
73
|
+
this.onFileWatchErrorEmitter = new event_1.Emitter();
|
|
74
|
+
this.onFileWatchError = this.onFileWatchErrorEmitter.event;
|
|
75
|
+
this.onDidChangeCapabilitiesEmitter = new event_1.Emitter();
|
|
76
|
+
this.onDidChangeCapabilities = this.onDidChangeCapabilitiesEmitter.event;
|
|
77
|
+
this.onFileStreamDataEmitter = new event_1.Emitter();
|
|
78
|
+
this.onFileStreamData = this.onFileStreamDataEmitter.event;
|
|
79
|
+
this.onFileStreamEndEmitter = new event_1.Emitter();
|
|
80
|
+
this.onFileStreamEnd = this.onFileStreamEndEmitter.event;
|
|
81
|
+
this.toDispose = new disposable_1.DisposableCollection(this.onDidChangeFileEmitter, this.onDidChangeCapabilitiesEmitter, this.onFileStreamDataEmitter, this.onFileStreamEndEmitter);
|
|
82
|
+
this.watcherSequence = 0;
|
|
83
|
+
/**
|
|
84
|
+
* We'll track the currently allocated watchers, in order to re-allocate them
|
|
85
|
+
* with the same options once we reconnect to the backend after a disconnection.
|
|
86
|
+
*/
|
|
87
|
+
this.watchOptions = new Map();
|
|
88
|
+
this._capabilities = 0;
|
|
89
|
+
this.readyDeferred = new promise_util_1.Deferred();
|
|
90
|
+
this.ready = this.readyDeferred.promise;
|
|
91
|
+
}
|
|
92
|
+
get capabilities() { return this._capabilities; }
|
|
93
|
+
init() {
|
|
94
|
+
this.server.getCapabilities().then(capabilities => {
|
|
95
|
+
this._capabilities = capabilities;
|
|
96
|
+
this.readyDeferred.resolve();
|
|
97
|
+
}, this.readyDeferred.reject);
|
|
98
|
+
this.server.setClient({
|
|
99
|
+
notifyDidChangeFile: ({ changes }) => {
|
|
100
|
+
this.onDidChangeFileEmitter.fire(changes.map(event => ({ resource: new uri_1.default(event.resource), type: event.type })));
|
|
101
|
+
},
|
|
102
|
+
notifyFileWatchError: () => {
|
|
103
|
+
this.onFileWatchErrorEmitter.fire();
|
|
104
|
+
},
|
|
105
|
+
notifyDidChangeCapabilities: capabilities => this.setCapabilities(capabilities),
|
|
106
|
+
onFileStreamData: (handle, data) => this.onFileStreamDataEmitter.fire([handle, data]),
|
|
107
|
+
onFileStreamEnd: (handle, error) => this.onFileStreamEndEmitter.fire([handle, error])
|
|
108
|
+
});
|
|
109
|
+
const onInitialized = this.server.onDidOpenConnection(() => {
|
|
110
|
+
// skip reconnection on the first connection
|
|
111
|
+
onInitialized.dispose();
|
|
112
|
+
this.toDispose.push(this.server.onDidOpenConnection(() => this.reconnect()));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
dispose() {
|
|
116
|
+
this.toDispose.dispose();
|
|
117
|
+
}
|
|
118
|
+
setCapabilities(capabilities) {
|
|
119
|
+
this._capabilities = capabilities;
|
|
120
|
+
this.onDidChangeCapabilitiesEmitter.fire(undefined);
|
|
121
|
+
}
|
|
122
|
+
// --- forwarding calls
|
|
123
|
+
stat(resource) {
|
|
124
|
+
return this.server.stat(resource.toString());
|
|
125
|
+
}
|
|
126
|
+
access(resource, mode) {
|
|
127
|
+
return this.server.access(resource.toString(), mode);
|
|
128
|
+
}
|
|
129
|
+
fsPath(resource) {
|
|
130
|
+
return this.server.fsPath(resource.toString());
|
|
131
|
+
}
|
|
132
|
+
open(resource, opts) {
|
|
133
|
+
return this.server.open(resource.toString(), opts);
|
|
134
|
+
}
|
|
135
|
+
close(fd) {
|
|
136
|
+
return this.server.close(fd);
|
|
137
|
+
}
|
|
138
|
+
async read(fd, pos, data, offset, length) {
|
|
139
|
+
const { bytes, bytesRead } = await this.server.read(fd, pos, length);
|
|
140
|
+
// copy back the data that was written into the buffer on the remote
|
|
141
|
+
// side. we need to do this because buffers are not referenced by
|
|
142
|
+
// pointer, but only by value and as such cannot be directly written
|
|
143
|
+
// to from the other process.
|
|
144
|
+
data.set(bytes.slice(0, bytesRead), offset);
|
|
145
|
+
return bytesRead;
|
|
146
|
+
}
|
|
147
|
+
async readFile(resource) {
|
|
148
|
+
const bytes = await this.server.readFile(resource.toString());
|
|
149
|
+
return bytes;
|
|
150
|
+
}
|
|
151
|
+
readFileStream(resource, opts, token) {
|
|
152
|
+
const capturedError = new Error();
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
154
|
+
const stream = (0, stream_1.newWriteableStream)(data => buffer_1.BinaryBuffer.concat(data.map(data => buffer_1.BinaryBuffer.wrap(data))).buffer);
|
|
155
|
+
this.server.readFileStream(resource.toString(), opts, token).then(streamHandle => {
|
|
156
|
+
if (token.isCancellationRequested) {
|
|
157
|
+
stream.end((0, cancellation_1.cancelled)());
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const toDispose = new disposable_1.DisposableCollection(token.onCancellationRequested(() => stream.end((0, cancellation_1.cancelled)())), this.onFileStreamData(([handle, data]) => {
|
|
161
|
+
if (streamHandle === handle) {
|
|
162
|
+
stream.write(data);
|
|
163
|
+
}
|
|
164
|
+
}), this.onFileStreamEnd(([handle, error]) => {
|
|
165
|
+
if (streamHandle === handle) {
|
|
166
|
+
if (error) {
|
|
167
|
+
const code = ('code' in error && error.code) || files_1.FileSystemProviderErrorCode.Unknown;
|
|
168
|
+
const fileOperationError = new files_1.FileSystemProviderError(error.message, code);
|
|
169
|
+
fileOperationError.name = error.name;
|
|
170
|
+
const capturedStack = capturedError.stack || '';
|
|
171
|
+
fileOperationError.stack = `${capturedStack}\nCaused by: ${error.stack}`;
|
|
172
|
+
stream.end(fileOperationError);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
stream.end();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
stream.on('end', () => toDispose.dispose());
|
|
180
|
+
}, error => stream.end(error));
|
|
181
|
+
return stream;
|
|
182
|
+
}
|
|
183
|
+
write(fd, pos, data, offset, length) {
|
|
184
|
+
return this.server.write(fd, pos, data, offset, length);
|
|
185
|
+
}
|
|
186
|
+
writeFile(resource, content, opts) {
|
|
187
|
+
return this.server.writeFile(resource.toString(), content, opts);
|
|
188
|
+
}
|
|
189
|
+
delete(resource, opts) {
|
|
190
|
+
return this.server.delete(resource.toString(), opts);
|
|
191
|
+
}
|
|
192
|
+
mkdir(resource) {
|
|
193
|
+
return this.server.mkdir(resource.toString());
|
|
194
|
+
}
|
|
195
|
+
readdir(resource) {
|
|
196
|
+
return this.server.readdir(resource.toString());
|
|
197
|
+
}
|
|
198
|
+
rename(resource, target, opts) {
|
|
199
|
+
return this.server.rename(resource.toString(), target.toString(), opts);
|
|
200
|
+
}
|
|
201
|
+
copy(resource, target, opts) {
|
|
202
|
+
return this.server.copy(resource.toString(), target.toString(), opts);
|
|
203
|
+
}
|
|
204
|
+
updateFile(resource, changes, opts) {
|
|
205
|
+
return this.server.updateFile(resource.toString(), changes, opts);
|
|
206
|
+
}
|
|
207
|
+
watch(resource, options) {
|
|
208
|
+
const watcherId = this.watcherSequence++;
|
|
209
|
+
const uri = resource.toString();
|
|
210
|
+
this.watchOptions.set(watcherId, { uri, options });
|
|
211
|
+
this.server.watch(watcherId, uri, options);
|
|
212
|
+
const toUnwatch = disposable_1.Disposable.create(() => {
|
|
213
|
+
this.watchOptions.delete(watcherId);
|
|
214
|
+
this.server.unwatch(watcherId);
|
|
215
|
+
});
|
|
216
|
+
this.toDispose.push(toUnwatch);
|
|
217
|
+
return toUnwatch;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* When a frontend disconnects (e.g. bad connection) the backend resources will be cleared.
|
|
221
|
+
*
|
|
222
|
+
* This means that we need to re-allocate the watchers when a frontend reconnects.
|
|
223
|
+
*/
|
|
224
|
+
reconnect() {
|
|
225
|
+
for (const [watcher, { uri, options }] of this.watchOptions.entries()) {
|
|
226
|
+
this.server.watch(watcher, uri, options);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, inversify_1.inject)(exports.RemoteFileSystemServer),
|
|
232
|
+
__metadata("design:type", Object)
|
|
233
|
+
], RemoteFileSystemProvider.prototype, "server", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
(0, inversify_1.postConstruct)(),
|
|
236
|
+
__metadata("design:type", Function),
|
|
237
|
+
__metadata("design:paramtypes", []),
|
|
238
|
+
__metadata("design:returntype", void 0)
|
|
239
|
+
], RemoteFileSystemProvider.prototype, "init", null);
|
|
240
|
+
RemoteFileSystemProvider = __decorate([
|
|
241
|
+
(0, inversify_1.injectable)()
|
|
242
|
+
], RemoteFileSystemProvider);
|
|
243
|
+
exports.RemoteFileSystemProvider = RemoteFileSystemProvider;
|
|
244
|
+
/**
|
|
245
|
+
* Backend component.
|
|
246
|
+
*
|
|
247
|
+
* JSON-RPC server exposing a wrapped file system provider remotely.
|
|
248
|
+
*/
|
|
249
|
+
let FileSystemProviderServer = class FileSystemProviderServer {
|
|
250
|
+
constructor() {
|
|
251
|
+
this.BUFFER_SIZE = 64 * 1024;
|
|
252
|
+
/**
|
|
253
|
+
* Mapping of `watcherId` to a disposable watcher handle.
|
|
254
|
+
*/
|
|
255
|
+
this.watchers = new Map();
|
|
256
|
+
this.toDispose = new disposable_1.DisposableCollection();
|
|
257
|
+
this.readFileStreamSeq = 0;
|
|
258
|
+
}
|
|
259
|
+
dispose() {
|
|
260
|
+
this.toDispose.dispose();
|
|
261
|
+
}
|
|
262
|
+
setClient(client) {
|
|
263
|
+
this.client = client;
|
|
264
|
+
}
|
|
265
|
+
init() {
|
|
266
|
+
if (this.provider.dispose) {
|
|
267
|
+
this.toDispose.push(disposable_1.Disposable.create(() => this.provider.dispose()));
|
|
268
|
+
}
|
|
269
|
+
this.toDispose.push(this.provider.onDidChangeCapabilities(() => {
|
|
270
|
+
if (this.client) {
|
|
271
|
+
this.client.notifyDidChangeCapabilities(this.provider.capabilities);
|
|
272
|
+
}
|
|
273
|
+
}));
|
|
274
|
+
this.toDispose.push(this.provider.onDidChangeFile(changes => {
|
|
275
|
+
if (this.client) {
|
|
276
|
+
this.client.notifyDidChangeFile({
|
|
277
|
+
changes: changes.map(({ resource, type }) => ({ resource: resource.toString(), type }))
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}));
|
|
281
|
+
this.toDispose.push(this.provider.onFileWatchError(() => {
|
|
282
|
+
if (this.client) {
|
|
283
|
+
this.client.notifyFileWatchError();
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
async getCapabilities() {
|
|
288
|
+
return this.provider.capabilities;
|
|
289
|
+
}
|
|
290
|
+
stat(resource) {
|
|
291
|
+
return this.provider.stat(new uri_1.default(resource));
|
|
292
|
+
}
|
|
293
|
+
access(resource, mode) {
|
|
294
|
+
if ((0, files_1.hasAccessCapability)(this.provider)) {
|
|
295
|
+
return this.provider.access(new uri_1.default(resource), mode);
|
|
296
|
+
}
|
|
297
|
+
throw new Error('not supported');
|
|
298
|
+
}
|
|
299
|
+
async fsPath(resource) {
|
|
300
|
+
if ((0, files_1.hasAccessCapability)(this.provider)) {
|
|
301
|
+
return this.provider.fsPath(new uri_1.default(resource));
|
|
302
|
+
}
|
|
303
|
+
throw new Error('not supported');
|
|
304
|
+
}
|
|
305
|
+
open(resource, opts) {
|
|
306
|
+
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
307
|
+
return this.provider.open(new uri_1.default(resource), opts);
|
|
308
|
+
}
|
|
309
|
+
throw new Error('not supported');
|
|
310
|
+
}
|
|
311
|
+
close(fd) {
|
|
312
|
+
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
313
|
+
return this.provider.close(fd);
|
|
314
|
+
}
|
|
315
|
+
throw new Error('not supported');
|
|
316
|
+
}
|
|
317
|
+
async read(fd, pos, length) {
|
|
318
|
+
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
319
|
+
const buffer = buffer_1.BinaryBuffer.alloc(this.BUFFER_SIZE);
|
|
320
|
+
const bytes = buffer.buffer;
|
|
321
|
+
const bytesRead = await this.provider.read(fd, pos, bytes, 0, length);
|
|
322
|
+
return { bytes, bytesRead };
|
|
323
|
+
}
|
|
324
|
+
throw new Error('not supported');
|
|
325
|
+
}
|
|
326
|
+
write(fd, pos, data, offset, length) {
|
|
327
|
+
if ((0, files_1.hasOpenReadWriteCloseCapability)(this.provider)) {
|
|
328
|
+
return this.provider.write(fd, pos, data, offset, length);
|
|
329
|
+
}
|
|
330
|
+
throw new Error('not supported');
|
|
331
|
+
}
|
|
332
|
+
async readFile(resource) {
|
|
333
|
+
if ((0, files_1.hasReadWriteCapability)(this.provider)) {
|
|
334
|
+
return this.provider.readFile(new uri_1.default(resource));
|
|
335
|
+
}
|
|
336
|
+
throw new Error('not supported');
|
|
337
|
+
}
|
|
338
|
+
writeFile(resource, content, opts) {
|
|
339
|
+
if ((0, files_1.hasReadWriteCapability)(this.provider)) {
|
|
340
|
+
return this.provider.writeFile(new uri_1.default(resource), content, opts);
|
|
341
|
+
}
|
|
342
|
+
throw new Error('not supported');
|
|
343
|
+
}
|
|
344
|
+
delete(resource, opts) {
|
|
345
|
+
return this.provider.delete(new uri_1.default(resource), opts);
|
|
346
|
+
}
|
|
347
|
+
mkdir(resource) {
|
|
348
|
+
return this.provider.mkdir(new uri_1.default(resource));
|
|
349
|
+
}
|
|
350
|
+
readdir(resource) {
|
|
351
|
+
return this.provider.readdir(new uri_1.default(resource));
|
|
352
|
+
}
|
|
353
|
+
rename(source, target, opts) {
|
|
354
|
+
return this.provider.rename(new uri_1.default(source), new uri_1.default(target), opts);
|
|
355
|
+
}
|
|
356
|
+
copy(source, target, opts) {
|
|
357
|
+
if ((0, files_1.hasFileFolderCopyCapability)(this.provider)) {
|
|
358
|
+
return this.provider.copy(new uri_1.default(source), new uri_1.default(target), opts);
|
|
359
|
+
}
|
|
360
|
+
throw new Error('not supported');
|
|
361
|
+
}
|
|
362
|
+
updateFile(resource, changes, opts) {
|
|
363
|
+
if ((0, files_1.hasUpdateCapability)(this.provider)) {
|
|
364
|
+
return this.provider.updateFile(new uri_1.default(resource), changes, opts);
|
|
365
|
+
}
|
|
366
|
+
throw new Error('not supported');
|
|
367
|
+
}
|
|
368
|
+
async watch(requestedWatcherId, resource, opts) {
|
|
369
|
+
if (this.watchers.has(requestedWatcherId)) {
|
|
370
|
+
throw new Error('watcher id is already allocated!');
|
|
371
|
+
}
|
|
372
|
+
const watcher = this.provider.watch(new uri_1.default(resource), opts);
|
|
373
|
+
this.watchers.set(requestedWatcherId, watcher);
|
|
374
|
+
this.toDispose.push(disposable_1.Disposable.create(() => this.unwatch(requestedWatcherId)));
|
|
375
|
+
}
|
|
376
|
+
async unwatch(watcherId) {
|
|
377
|
+
const watcher = this.watchers.get(watcherId);
|
|
378
|
+
if (watcher) {
|
|
379
|
+
this.watchers.delete(watcherId);
|
|
380
|
+
watcher.dispose();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async readFileStream(resource, opts, token) {
|
|
384
|
+
if ((0, files_1.hasFileReadStreamCapability)(this.provider)) {
|
|
385
|
+
const handle = this.readFileStreamSeq++;
|
|
386
|
+
const stream = this.provider.readFileStream(new uri_1.default(resource), opts, token);
|
|
387
|
+
stream.on('data', data => { var _a; return (_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamData(handle, data); });
|
|
388
|
+
stream.on('error', error => {
|
|
389
|
+
var _a;
|
|
390
|
+
const code = error instanceof files_1.FileSystemProviderError ? error.code : undefined;
|
|
391
|
+
const { name, message, stack } = error;
|
|
392
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamEnd(handle, { code, name, message, stack });
|
|
393
|
+
});
|
|
394
|
+
stream.on('end', () => { var _a; return (_a = this.client) === null || _a === void 0 ? void 0 : _a.onFileStreamEnd(handle, undefined); });
|
|
395
|
+
return handle;
|
|
396
|
+
}
|
|
397
|
+
throw new Error('not supported');
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
__decorate([
|
|
401
|
+
(0, inversify_1.inject)(files_1.FileSystemProvider),
|
|
402
|
+
__metadata("design:type", Object)
|
|
403
|
+
], FileSystemProviderServer.prototype, "provider", void 0);
|
|
404
|
+
__decorate([
|
|
405
|
+
(0, inversify_1.postConstruct)(),
|
|
406
|
+
__metadata("design:type", Function),
|
|
407
|
+
__metadata("design:paramtypes", []),
|
|
408
|
+
__metadata("design:returntype", void 0)
|
|
409
|
+
], FileSystemProviderServer.prototype, "init", null);
|
|
410
|
+
FileSystemProviderServer = __decorate([
|
|
411
|
+
(0, inversify_1.injectable)()
|
|
412
|
+
], FileSystemProviderServer);
|
|
413
|
+
exports.FileSystemProviderServer = FileSystemProviderServer;
|
|
414
414
|
//# sourceMappingURL=remote-file-system-provider.js.map
|