@theia/plugin-ext 1.76.0-next.6 → 1.76.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/lib/common/paths-util.d.ts.map +1 -1
- package/lib/common/paths-util.js +9 -2
- package/lib/common/paths-util.js.map +1 -1
- package/lib/common/paths-util.spec.d.ts +2 -0
- package/lib/common/paths-util.spec.d.ts.map +1 -0
- package/lib/common/paths-util.spec.js +42 -0
- package/lib/common/paths-util.spec.js.map +1 -0
- package/lib/common/plugin-api-rpc.d.ts +14 -0
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +2 -2
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js +2 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts +2 -0
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +9 -3
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/browser/worker/worker-main.js +22 -12
- package/lib/hosted/browser/worker/worker-main.js.map +1 -1
- package/lib/hosted/browser/worker/worker-plugin-module.d.ts.map +1 -1
- package/lib/hosted/browser/worker/worker-plugin-module.js +2 -0
- package/lib/hosted/browser/worker/worker-plugin-module.js.map +1 -1
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.d.ts +37 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.js +107 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.spec.d.ts +2 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.spec.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.spec.js +106 -0
- package/lib/hosted/browser-only/browser-only-hosted-plugin-server.spec.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.d.ts +38 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.js +124 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.spec.d.ts +2 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.spec.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.spec.js +137 -0
- package/lib/hosted/browser-only/browser-only-plugin-file-system-provider.spec.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.d.ts +43 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.js +145 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.spec.d.ts +2 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.spec.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.spec.js +165 -0
- package/lib/hosted/browser-only/browser-only-plugin-paths-service.spec.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.d.ts +54 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.js +155 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.js.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.spec.d.ts +2 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.spec.d.ts.map +1 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.spec.js +190 -0
- package/lib/hosted/browser-only/browser-only-plugin-server.spec.js.map +1 -0
- package/lib/hosted/browser-only/test/navigator-locks-test-util.d.ts +24 -0
- package/lib/hosted/browser-only/test/navigator-locks-test-util.d.ts.map +1 -0
- package/lib/hosted/browser-only/test/navigator-locks-test-util.js +46 -0
- package/lib/hosted/browser-only/test/navigator-locks-test-util.js.map +1 -0
- package/lib/hosted/common/hosted-plugin.d.ts +2 -2
- package/lib/hosted/common/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/common/hosted-plugin.js +2 -2
- package/lib/hosted/common/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/plugin-host-module.d.ts.map +1 -1
- package/lib/hosted/node/plugin-host-module.js +2 -0
- package/lib/hosted/node/plugin-host-module.js.map +1 -1
- package/lib/hosted/node/plugin-host-rpc.d.ts +3 -0
- package/lib/hosted/node/plugin-host-rpc.d.ts.map +1 -1
- package/lib/hosted/node/plugin-host-rpc.js +9 -3
- package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
- package/lib/main/browser/editors-and-documents-main.d.ts +7 -0
- package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
- package/lib/main/browser/editors-and-documents-main.js +19 -9
- package/lib/main/browser/editors-and-documents-main.js.map +1 -1
- package/lib/main/browser/editors-and-documents-main.spec.d.ts +2 -0
- package/lib/main/browser/editors-and-documents-main.spec.d.ts.map +1 -0
- package/lib/main/browser/editors-and-documents-main.spec.js +117 -0
- package/lib/main/browser/editors-and-documents-main.spec.js.map +1 -0
- package/lib/main/browser/languages-main.d.ts +7 -0
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +31 -9
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/languages-main.spec.d.ts +2 -0
- package/lib/main/browser/languages-main.spec.d.ts.map +1 -0
- package/lib/main/browser/languages-main.spec.js +82 -0
- package/lib/main/browser/languages-main.spec.js.map +1 -0
- package/lib/main/browser/main-context.d.ts.map +1 -1
- package/lib/main/browser/main-context.js +3 -0
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +5 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js +5 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.js +1 -0
- package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
- package/lib/main/browser/plugin-icon-service.d.ts +6 -0
- package/lib/main/browser/plugin-icon-service.d.ts.map +1 -1
- package/lib/main/browser/plugin-icon-service.js +14 -2
- package/lib/main/browser/plugin-icon-service.js.map +1 -1
- package/lib/main/browser/plugin-icon-service.spec.d.ts +2 -0
- package/lib/main/browser/plugin-icon-service.spec.d.ts.map +1 -0
- package/lib/main/browser/plugin-icon-service.spec.js +83 -0
- package/lib/main/browser/plugin-icon-service.spec.js.map +1 -0
- package/lib/main/browser/plugin-icon-theme-service.d.ts.map +1 -1
- package/lib/main/browser/plugin-icon-theme-service.js +2 -1
- package/lib/main/browser/plugin-icon-theme-service.js.map +1 -1
- package/lib/main/browser/plugin-icon-theme-service.spec.d.ts +2 -0
- package/lib/main/browser/plugin-icon-theme-service.spec.d.ts.map +1 -0
- package/lib/main/browser/plugin-icon-theme-service.spec.js +91 -0
- package/lib/main/browser/plugin-icon-theme-service.spec.js.map +1 -0
- package/lib/main/browser/telemetry-main.d.ts +20 -0
- package/lib/main/browser/telemetry-main.d.ts.map +1 -0
- package/lib/main/browser/telemetry-main.js +43 -0
- package/lib/main/browser/telemetry-main.js.map +1 -0
- package/lib/main/browser/telemetry-main.spec.d.ts +2 -0
- package/lib/main/browser/telemetry-main.spec.d.ts.map +1 -0
- package/lib/main/browser/telemetry-main.spec.js +66 -0
- package/lib/main/browser/telemetry-main.spec.js.map +1 -0
- package/lib/main/browser/webview/webview-context-keys.d.ts +3 -2
- package/lib/main/browser/webview/webview-context-keys.d.ts.map +1 -1
- package/lib/main/browser/webview/webview-context-keys.js +16 -2
- package/lib/main/browser/webview/webview-context-keys.js.map +1 -1
- package/lib/main/browser/webview/webview-environment.d.ts.map +1 -1
- package/lib/main/browser/webview/webview-environment.js +2 -1
- package/lib/main/browser/webview/webview-environment.js.map +1 -1
- package/lib/main/common/paths/const.d.ts +13 -0
- package/lib/main/common/paths/const.d.ts.map +1 -0
- package/lib/main/common/paths/const.js +32 -0
- package/lib/main/common/paths/const.js.map +1 -0
- package/lib/main/node/paths/const.d.ts +5 -5
- package/lib/main/node/paths/const.d.ts.map +1 -1
- package/lib/main/node/paths/const.js +6 -6
- package/lib/main/node/paths/const.js.map +1 -1
- package/lib/main/node/paths/plugin-paths-service.js +1 -1
- package/lib/main/node/paths/plugin-paths-service.js.map +1 -1
- package/lib/main/node/plugin-cli-contribution.d.ts +2 -2
- package/lib/main/node/plugin-cli-contribution.d.ts.map +1 -1
- package/lib/main/node/plugin-cli-contribution.js +4 -3
- package/lib/main/node/plugin-cli-contribution.js.map +1 -1
- package/lib/main/node/plugins-key-value-storage.js +1 -1
- package/lib/main/node/plugins-key-value-storage.js.map +1 -1
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.d.ts +5 -0
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.d.ts.map +1 -1
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.js +12 -1
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.js.map +1 -1
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.spec.d.ts +2 -0
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.spec.d.ts.map +1 -0
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.spec.js +54 -0
- package/lib/main/node/resolvers/local-directory-plugin-deployer-resolver.spec.js.map +1 -0
- package/lib/plugin/plugin-context.d.ts +2 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +2 -3
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-manager.d.ts +2 -0
- package/lib/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/plugin/plugin-manager.js +12 -1
- package/lib/plugin/plugin-manager.js.map +1 -1
- package/lib/plugin/relative-pattern.spec.d.ts +2 -0
- package/lib/plugin/relative-pattern.spec.d.ts.map +1 -0
- package/lib/plugin/relative-pattern.spec.js +51 -0
- package/lib/plugin/relative-pattern.spec.js.map +1 -0
- package/lib/plugin/telemetry-ext.d.ts +23 -7
- package/lib/plugin/telemetry-ext.d.ts.map +1 -1
- package/lib/plugin/telemetry-ext.js +60 -33
- package/lib/plugin/telemetry-ext.js.map +1 -1
- package/lib/plugin/telemetry-ext.spec.js +121 -16
- package/lib/plugin/telemetry-ext.spec.js.map +1 -1
- package/lib/plugin-ext-frontend-only-module.d.ts +4 -0
- package/lib/plugin-ext-frontend-only-module.d.ts.map +1 -0
- package/lib/plugin-ext-frontend-only-module.js +34 -0
- package/lib/plugin-ext-frontend-only-module.js.map +1 -0
- package/package.json +36 -32
- package/src/common/paths-util.spec.ts +47 -0
- package/src/common/paths-util.ts +11 -2
- package/src/common/plugin-api-rpc.ts +15 -1
- package/src/common/plugin-protocol.ts +2 -0
- package/src/hosted/browser/hosted-plugin.ts +9 -4
- package/src/hosted/browser/worker/worker-main.ts +23 -12
- package/src/hosted/browser/worker/worker-plugin-module.ts +2 -0
- package/src/hosted/browser-only/browser-only-hosted-plugin-server.spec.ts +133 -0
- package/src/hosted/browser-only/browser-only-hosted-plugin-server.ts +122 -0
- package/src/hosted/browser-only/browser-only-plugin-file-system-provider.spec.ts +178 -0
- package/src/hosted/browser-only/browser-only-plugin-file-system-provider.ts +129 -0
- package/src/hosted/browser-only/browser-only-plugin-paths-service.spec.ts +199 -0
- package/src/hosted/browser-only/browser-only-plugin-paths-service.ts +145 -0
- package/src/hosted/browser-only/browser-only-plugin-server.spec.ts +228 -0
- package/src/hosted/browser-only/browser-only-plugin-server.ts +165 -0
- package/src/hosted/browser-only/test/navigator-locks-test-util.ts +54 -0
- package/src/hosted/common/hosted-plugin.ts +4 -4
- package/src/hosted/node/plugin-host-module.ts +2 -0
- package/src/hosted/node/plugin-host-rpc.ts +10 -4
- package/src/main/browser/editors-and-documents-main.spec.ts +140 -0
- package/src/main/browser/editors-and-documents-main.ts +19 -7
- package/src/main/browser/languages-main.spec.ts +101 -0
- package/src/main/browser/languages-main.ts +31 -9
- package/src/main/browser/main-context.ts +4 -0
- package/src/main/browser/menus/vscode-theia-menu-mappings.ts +5 -0
- package/src/main/browser/plugin-ext-frontend-module.ts +2 -1
- package/src/main/browser/plugin-icon-service.spec.ts +101 -0
- package/src/main/browser/plugin-icon-service.ts +16 -3
- package/src/main/browser/plugin-icon-theme-service.spec.ts +103 -0
- package/src/main/browser/plugin-icon-theme-service.ts +2 -1
- package/src/main/browser/telemetry-main.spec.ts +77 -0
- package/src/main/browser/telemetry-main.ts +46 -0
- package/src/main/browser/webview/webview-context-keys.ts +20 -4
- package/src/main/browser/webview/webview-environment.ts +2 -1
- package/src/main/common/paths/const.ts +28 -0
- package/src/main/node/paths/const.ts +5 -5
- package/src/main/node/paths/plugin-paths-service.ts +1 -1
- package/src/main/node/plugin-cli-contribution.ts +4 -3
- package/src/main/node/plugins-key-value-storage.ts +1 -1
- package/src/main/node/resolvers/local-directory-plugin-deployer-resolver.spec.ts +61 -0
- package/src/main/node/resolvers/local-directory-plugin-deployer-resolver.ts +14 -1
- package/src/plugin/plugin-context.ts +3 -2
- package/src/plugin/plugin-manager.ts +11 -1
- package/src/plugin/relative-pattern.spec.ts +55 -0
- package/src/plugin/telemetry-ext.spec.ts +158 -17
- package/src/plugin/telemetry-ext.ts +63 -33
- package/src/plugin-ext-frontend-only-module.ts +34 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BrowserOnlyHostedPluginServer = exports.BrowserOnlyPluginOptions = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const constants_1 = require("@theia/plugin-utils/lib/common/constants");
|
|
22
|
+
const common_1 = require("../../common");
|
|
23
|
+
const core_1 = require("@theia/core");
|
|
24
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
25
|
+
exports.BrowserOnlyPluginOptions = Symbol('BrowserOnlyPluginOptions');
|
|
26
|
+
/**
|
|
27
|
+
* Serves the plugins statically deployed into the frontend bundle. There's no backend in a
|
|
28
|
+
* browser-only application, so nothing can be deployed or undeployed at runtime.
|
|
29
|
+
*/
|
|
30
|
+
let BrowserOnlyHostedPluginServer = class BrowserOnlyHostedPluginServer {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.onDidOpenConnection = core_1.Event.None;
|
|
33
|
+
this.onDidCloseConnection = core_1.Event.None;
|
|
34
|
+
}
|
|
35
|
+
/** The statically deployed plugins, from {@link BrowserOnlyPluginOptions} if bound, otherwise from the list the build wrote. */
|
|
36
|
+
getPlugins() {
|
|
37
|
+
if (!this.plugins) {
|
|
38
|
+
this.plugins = this.options ? Promise.resolve(this.options.pluginMetadata) : this.fetchDeployedPlugins();
|
|
39
|
+
// don't keep a failed fetch around, otherwise the tab has no plugins until it's reloaded
|
|
40
|
+
this.plugins.catch(() => this.plugins = undefined);
|
|
41
|
+
}
|
|
42
|
+
return this.plugins;
|
|
43
|
+
}
|
|
44
|
+
async fetchDeployedPlugins() {
|
|
45
|
+
// Built through `Endpoint`, like `PluginIconService#toPluginUrl`, so this keeps working
|
|
46
|
+
// when the application is deployed under a sub-path.
|
|
47
|
+
const url = new browser_1.Endpoint({ path: `${constants_1.PLUGINS_BASE_PATH}/${constants_1.LIST_JSON}` }).getRestUrl().toString();
|
|
48
|
+
try {
|
|
49
|
+
const response = await fetch(url);
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
const plugins = await response.json();
|
|
54
|
+
if (!Array.isArray(plugins)) {
|
|
55
|
+
throw new Error(`expected an array but got ${typeof plugins}`);
|
|
56
|
+
}
|
|
57
|
+
return plugins;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new Error(`Failed to load the deployed plugins from '${url}': ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async getDeployedPluginIds() {
|
|
64
|
+
const plugins = await this.getPlugins();
|
|
65
|
+
return plugins.map(p => common_1.PluginIdentifiers.componentsToVersionedId(p.metadata.model));
|
|
66
|
+
}
|
|
67
|
+
getInstalledPluginIds() {
|
|
68
|
+
// the statically deployed plugins are the only ones that could ever be "installed"
|
|
69
|
+
return this.getDeployedPluginIds();
|
|
70
|
+
}
|
|
71
|
+
async getUninstalledPluginIds() {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
async getDisabledPluginIds() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
async getDeployedPlugins(ids) {
|
|
78
|
+
const plugins = await this.getPlugins();
|
|
79
|
+
const requested = new Set(ids);
|
|
80
|
+
return plugins.filter(p => requested.has(common_1.PluginIdentifiers.componentsToVersionedId(p.metadata.model)));
|
|
81
|
+
}
|
|
82
|
+
async getExtPluginAPI() {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
async onMessage(targetHost, message) {
|
|
86
|
+
// the frontend delivers messages to the plugin host directly, not through here
|
|
87
|
+
}
|
|
88
|
+
setClient(client) {
|
|
89
|
+
this.client = client;
|
|
90
|
+
}
|
|
91
|
+
getClient() {
|
|
92
|
+
return this.client;
|
|
93
|
+
}
|
|
94
|
+
dispose() {
|
|
95
|
+
this.client = undefined;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.BrowserOnlyHostedPluginServer = BrowserOnlyHostedPluginServer;
|
|
99
|
+
tslib_1.__decorate([
|
|
100
|
+
(0, inversify_1.inject)(exports.BrowserOnlyPluginOptions),
|
|
101
|
+
(0, inversify_1.optional)(),
|
|
102
|
+
tslib_1.__metadata("design:type", Object)
|
|
103
|
+
], BrowserOnlyHostedPluginServer.prototype, "options", void 0);
|
|
104
|
+
exports.BrowserOnlyHostedPluginServer = BrowserOnlyHostedPluginServer = tslib_1.__decorate([
|
|
105
|
+
(0, inversify_1.injectable)()
|
|
106
|
+
], BrowserOnlyHostedPluginServer);
|
|
107
|
+
//# sourceMappingURL=browser-only-hosted-plugin-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-hosted-plugin-server.js","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-hosted-plugin-server.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAA4E;AAC5E,wEAAwF;AACxF,yCAAuH;AACvH,sCAA+D;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AM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;CACJ,CAAA;AAnFY,sEAA6B;AAKnB;IADlB,IAAA,kBAAM,EAAC,gCAAwB,CAAC;IAAE,IAAA,oBAAQ,GAAE;;8DACS;wCAL7C,6BAA6B;IADzC,IAAA,sBAAU,GAAE;GACA,6BAA6B,CAmFzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-hosted-plugin-server.spec.d.ts","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-hosted-plugin-server.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
// `BrowserOnlyHostedPluginServer` transitively imports `Endpoint` via `@theia/core/lib/browser`,
|
|
20
|
+
// which touches `document` at load time, so JSDOM is enabled before it for that import.
|
|
21
|
+
let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
22
|
+
const chai_1 = require("chai");
|
|
23
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
24
|
+
const common_1 = require("../../common");
|
|
25
|
+
const browser_only_hosted_plugin_server_1 = require("./browser-only-hosted-plugin-server");
|
|
26
|
+
disableJSDOM();
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
+
function plugin(name, version = '1.0.0') {
|
|
29
|
+
return {
|
|
30
|
+
type: common_1.PluginType.System,
|
|
31
|
+
metadata: {
|
|
32
|
+
host: 'main',
|
|
33
|
+
model: { publisher: 'theia', name, version },
|
|
34
|
+
lifecycle: {}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
describe('BrowserOnlyHostedPluginServer', () => {
|
|
39
|
+
// `fetchDeployedPlugins` builds the list URL through `Endpoint`, which reads `self.location`.
|
|
40
|
+
before(() => { disableJSDOM = (0, jsdom_1.enableJSDOM)(); });
|
|
41
|
+
after(() => disableJSDOM());
|
|
42
|
+
const originalFetch = globalThis.fetch;
|
|
43
|
+
let requestedUrls;
|
|
44
|
+
function stubFetch(respond) {
|
|
45
|
+
requestedUrls = [];
|
|
46
|
+
globalThis.fetch = (async (url) => {
|
|
47
|
+
requestedUrls.push(String(url));
|
|
48
|
+
return respond();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function createServer(options) {
|
|
52
|
+
const container = new inversify_1.Container();
|
|
53
|
+
container.bind(browser_only_hosted_plugin_server_1.BrowserOnlyHostedPluginServer).toSelf().inSingletonScope();
|
|
54
|
+
if (options) {
|
|
55
|
+
container.bind(browser_only_hosted_plugin_server_1.BrowserOnlyPluginOptions).toConstantValue(options);
|
|
56
|
+
}
|
|
57
|
+
return container.get(browser_only_hosted_plugin_server_1.BrowserOnlyHostedPluginServer);
|
|
58
|
+
}
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
globalThis.fetch = originalFetch;
|
|
61
|
+
});
|
|
62
|
+
it('serves the plugins listed by the build', async () => {
|
|
63
|
+
stubFetch(() => Response.json([plugin('a'), plugin('b')]));
|
|
64
|
+
const server = createServer();
|
|
65
|
+
(0, chai_1.expect)(await server.getDeployedPluginIds()).to.deep.equal(['theia.a@1.0.0', 'theia.b@1.0.0']);
|
|
66
|
+
(0, chai_1.expect)(requestedUrls).to.deep.equal(['http://localhost/hostedPlugin/list.json']);
|
|
67
|
+
});
|
|
68
|
+
it('fetches the list only once', async () => {
|
|
69
|
+
stubFetch(() => Response.json([plugin('a')]));
|
|
70
|
+
const server = createServer();
|
|
71
|
+
await server.getDeployedPluginIds();
|
|
72
|
+
await server.getDeployedPluginIds();
|
|
73
|
+
(0, chai_1.expect)(requestedUrls).to.have.lengthOf(1);
|
|
74
|
+
});
|
|
75
|
+
it('prefers the metadata supplied by an adopter over the list', async () => {
|
|
76
|
+
stubFetch(() => Response.json([plugin('from-list')]));
|
|
77
|
+
const server = createServer({ pluginMetadata: [plugin('from-options')] });
|
|
78
|
+
(0, chai_1.expect)(await server.getDeployedPluginIds()).to.deep.equal(['theia.from-options@1.0.0']);
|
|
79
|
+
(0, chai_1.expect)(requestedUrls).to.be.empty;
|
|
80
|
+
});
|
|
81
|
+
it('returns only the requested plugins', async () => {
|
|
82
|
+
stubFetch(() => Response.json([plugin('a'), plugin('b'), plugin('c')]));
|
|
83
|
+
const server = createServer();
|
|
84
|
+
const deployed = await server.getDeployedPlugins(['theia.a@1.0.0', 'theia.c@1.0.0']);
|
|
85
|
+
(0, chai_1.expect)(deployed.map(p => p.metadata.model.name)).to.deep.equal(['a', 'c']);
|
|
86
|
+
});
|
|
87
|
+
it('reports where the list could not be loaded from', async () => {
|
|
88
|
+
stubFetch(() => new Response('', { status: 404, statusText: 'Not Found' }));
|
|
89
|
+
const server = createServer();
|
|
90
|
+
await server.getDeployedPluginIds().then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.message).to.contain('http://localhost/hostedPlugin/list.json').and.to.contain('404'));
|
|
91
|
+
});
|
|
92
|
+
it('fetches the list again after a failed attempt', async () => {
|
|
93
|
+
let attempt = 0;
|
|
94
|
+
stubFetch(() => ++attempt === 1 ? new Response('', { status: 503 }) : Response.json([plugin('a')]));
|
|
95
|
+
const server = createServer();
|
|
96
|
+
await server.getDeployedPluginIds().catch(() => undefined);
|
|
97
|
+
(0, chai_1.expect)(await server.getDeployedPluginIds()).to.deep.equal(['theia.a@1.0.0']);
|
|
98
|
+
(0, chai_1.expect)(requestedUrls).to.have.lengthOf(2);
|
|
99
|
+
});
|
|
100
|
+
it('rejects a list that is not an array', async () => {
|
|
101
|
+
stubFetch(() => Response.json({ plugins: [] }));
|
|
102
|
+
const server = createServer();
|
|
103
|
+
await server.getDeployedPluginIds().then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.message).to.contain('expected an array'));
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=browser-only-hosted-plugin-server.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-hosted-plugin-server.spec.js","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-hosted-plugin-server.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,8DAAiE;AACjE,iGAAiG;AACjG,wFAAwF;AACxF,IAAI,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AAEjC,+BAA8B;AAC9B,4DAAyD;AACzD,yCAA0D;AAC1D,2FAA8G;AAE9G,YAAY,EAAE,CAAC;AAEf,uDAAuD;AAEvD,SAAS,MAAM,CAAC,IAAY,EAAE,O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C,EAAE,CAAC,IAAA,aAAM,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Disposable, Event, Emitter, URI } from '@theia/core';
|
|
2
|
+
import { FileChange, FileDeleteOptions, FileOverwriteOptions, FileSystemProvider, FileType, FileWriteOptions, Stat, WatchOptions } from '@theia/filesystem/lib/common/files';
|
|
3
|
+
import { FileService, FileServiceContribution } from '@theia/filesystem/lib/browser/file-service';
|
|
4
|
+
/**
|
|
5
|
+
* Reads the plugin assets the build dropped under `PLUGINS_BASE_PATH`. With a backend those come
|
|
6
|
+
* off its disk via `file:`; browser-only has to fetch them over HTTP.
|
|
7
|
+
*
|
|
8
|
+
* Read-only, and only for what goes through the `FileService`: color themes, icon themes, icon
|
|
9
|
+
* fonts.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BrowserOnlyPluginFileSystemProvider implements FileSystemProvider {
|
|
12
|
+
readonly capabilities: number;
|
|
13
|
+
readonly onDidChangeCapabilities: Event<any>;
|
|
14
|
+
readonly onFileWatchError: Event<any>;
|
|
15
|
+
protected readonly onDidChangeFileEmitter: Emitter<readonly FileChange[]>;
|
|
16
|
+
readonly onDidChangeFile: Event<readonly FileChange[]>;
|
|
17
|
+
watch(resource: URI, opts: WatchOptions): Disposable;
|
|
18
|
+
stat(resource: URI): Promise<Stat>;
|
|
19
|
+
readFile(resource: URI): Promise<Uint8Array>;
|
|
20
|
+
/**
|
|
21
|
+
* Maps the URI back to the path the build actually wrote, built through `Endpoint` so this
|
|
22
|
+
* still works when the application is deployed under a sub-path. `URI.path` is decoded, so it
|
|
23
|
+
* has to be re-encoded - otherwise a `#` or `?` in an asset name would be read as a fragment or
|
|
24
|
+
* query.
|
|
25
|
+
*/
|
|
26
|
+
protected toUrl(resource: URI): string;
|
|
27
|
+
protected fetch(resource: URI, method: 'GET' | 'HEAD'): Promise<Response>;
|
|
28
|
+
readdir(resource: URI): Promise<[string, FileType][]>;
|
|
29
|
+
mkdir(resource: URI): Promise<void>;
|
|
30
|
+
delete(resource: URI, opts: FileDeleteOptions): Promise<void>;
|
|
31
|
+
rename(from: URI, to: URI, opts: FileOverwriteOptions): Promise<void>;
|
|
32
|
+
writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare class BrowserOnlyPluginFileServiceContribution implements FileServiceContribution {
|
|
35
|
+
protected readonly provider: BrowserOnlyPluginFileSystemProvider;
|
|
36
|
+
registerFileSystemProviders(service: FileService): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=browser-only-plugin-file-system-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-plugin-file-system-provider.d.ts","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-plugin-file-system-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAC4B,UAAU,EAAE,iBAAiB,EAAE,oBAAoB,EAAkB,kBAAkB,EACzF,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAC9E,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAIlG;;;;;;GAMG;AACH,qBACa,mCAAoC,YAAW,kBAAkB;IAE1E,QAAQ,CAAC,YAAY,SAA6I;IAClK,QAAQ,CAAC,uBAAuB,aAAc;IAC9C,QAAQ,CAAC,gBAAgB,aAAc;IAEvC,SAAS,CAAC,QAAQ,CAAC,sBAAsB,iCAAwC;IACjF,QAAQ,CAAC,eAAe,+BAAqC;IAE7D,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,GAAG,UAAU;IAK9C,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBlC,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAKlD;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM;cAItB,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAkB/E,OAAO,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;IAIrD,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvF;AAED,qBACa,wCAAyC,YAAW,uBAAuB;IAGpF,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,mCAAmC,CAAC;IAEjE,2BAA2B,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;CAG1D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BrowserOnlyPluginFileServiceContribution = exports.BrowserOnlyPluginFileSystemProvider = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
23
|
+
const files_1 = require("@theia/filesystem/lib/common/files");
|
|
24
|
+
const constants_1 = require("@theia/plugin-utils/lib/common/constants");
|
|
25
|
+
const plugin_model_1 = require("@theia/plugin-utils/lib/common/plugin-model");
|
|
26
|
+
/**
|
|
27
|
+
* Reads the plugin assets the build dropped under `PLUGINS_BASE_PATH`. With a backend those come
|
|
28
|
+
* off its disk via `file:`; browser-only has to fetch them over HTTP.
|
|
29
|
+
*
|
|
30
|
+
* Read-only, and only for what goes through the `FileService`: color themes, icon themes, icon
|
|
31
|
+
* fonts.
|
|
32
|
+
*/
|
|
33
|
+
let BrowserOnlyPluginFileSystemProvider = class BrowserOnlyPluginFileSystemProvider {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.capabilities = 2048 /* FileSystemProviderCapabilities.Readonly */ | 2 /* FileSystemProviderCapabilities.FileReadWrite */ | 1024 /* FileSystemProviderCapabilities.PathCaseSensitive */;
|
|
36
|
+
this.onDidChangeCapabilities = core_1.Event.None;
|
|
37
|
+
this.onFileWatchError = core_1.Event.None;
|
|
38
|
+
this.onDidChangeFileEmitter = new core_1.Emitter();
|
|
39
|
+
this.onDidChangeFile = this.onDidChangeFileEmitter.event;
|
|
40
|
+
}
|
|
41
|
+
watch(resource, opts) {
|
|
42
|
+
// baked into the build, nothing to watch
|
|
43
|
+
return core_1.Disposable.NULL;
|
|
44
|
+
}
|
|
45
|
+
async stat(resource) {
|
|
46
|
+
const response = await this.fetch(resource, 'HEAD');
|
|
47
|
+
const length = Number(response.headers.get('content-length'));
|
|
48
|
+
const modified = Date.parse(response.headers.get('last-modified') ?? '');
|
|
49
|
+
// Build output, so created and modified are the same. Falling back to 0 rather than
|
|
50
|
+
// `Date.now()` keeps it stable - callers cache on `mtime`.
|
|
51
|
+
const mtime = Number.isNaN(modified) ? 0 : modified;
|
|
52
|
+
return {
|
|
53
|
+
type: files_1.FileType.File,
|
|
54
|
+
permissions: files_1.FilePermission.Readonly,
|
|
55
|
+
mtime,
|
|
56
|
+
ctime: mtime,
|
|
57
|
+
size: Number.isNaN(length) ? 0 : length
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async readFile(resource) {
|
|
61
|
+
const response = await this.fetch(resource, 'GET');
|
|
62
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Maps the URI back to the path the build actually wrote, built through `Endpoint` so this
|
|
66
|
+
* still works when the application is deployed under a sub-path. `URI.path` is decoded, so it
|
|
67
|
+
* has to be re-encoded - otherwise a `#` or `?` in an asset name would be read as a fragment or
|
|
68
|
+
* query.
|
|
69
|
+
*/
|
|
70
|
+
toUrl(resource) {
|
|
71
|
+
return new browser_1.Endpoint({ path: `${constants_1.PLUGINS_BASE_PATH}${(0, plugin_model_1.encodePluginAssetPath)(resource.path.toString())}` }).getRestUrl().toString();
|
|
72
|
+
}
|
|
73
|
+
async fetch(resource, method) {
|
|
74
|
+
if (resource.scheme !== constants_1.PLUGINS_SCHEME) {
|
|
75
|
+
throw (0, files_1.createFileSystemProviderError)(`Not a plugin asset: '${resource.toString()}'`, files_1.FileSystemProviderErrorCode.FileNotFound);
|
|
76
|
+
}
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await fetch(this.toUrl(resource), { method });
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw (0, files_1.createFileSystemProviderError)(`Could not read '${resource.toString()}': ${error.message}`, files_1.FileSystemProviderErrorCode.Unavailable);
|
|
83
|
+
}
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
// A static server 404s for directories too, but nothing asks us for one.
|
|
86
|
+
const code = response.status === 404 ? files_1.FileSystemProviderErrorCode.FileNotFound : files_1.FileSystemProviderErrorCode.Unknown;
|
|
87
|
+
throw (0, files_1.createFileSystemProviderError)(`Could not read '${resource.toString()}': ${response.status} ${response.statusText}`, code);
|
|
88
|
+
}
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
readdir(resource) {
|
|
92
|
+
throw (0, files_1.createFileSystemProviderError)('Plugin assets cannot be listed.', files_1.FileSystemProviderErrorCode.FileNotADirectory);
|
|
93
|
+
}
|
|
94
|
+
mkdir(resource) {
|
|
95
|
+
throw (0, files_1.createFileSystemProviderError)('Plugin assets are read-only.', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
96
|
+
}
|
|
97
|
+
delete(resource, opts) {
|
|
98
|
+
throw (0, files_1.createFileSystemProviderError)('Plugin assets are read-only.', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
99
|
+
}
|
|
100
|
+
rename(from, to, opts) {
|
|
101
|
+
throw (0, files_1.createFileSystemProviderError)('Plugin assets are read-only.', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
102
|
+
}
|
|
103
|
+
writeFile(resource, content, opts) {
|
|
104
|
+
throw (0, files_1.createFileSystemProviderError)('Plugin assets are read-only.', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.BrowserOnlyPluginFileSystemProvider = BrowserOnlyPluginFileSystemProvider;
|
|
108
|
+
exports.BrowserOnlyPluginFileSystemProvider = BrowserOnlyPluginFileSystemProvider = tslib_1.__decorate([
|
|
109
|
+
(0, inversify_1.injectable)()
|
|
110
|
+
], BrowserOnlyPluginFileSystemProvider);
|
|
111
|
+
let BrowserOnlyPluginFileServiceContribution = class BrowserOnlyPluginFileServiceContribution {
|
|
112
|
+
registerFileSystemProviders(service) {
|
|
113
|
+
service.registerProvider(constants_1.PLUGINS_SCHEME, this.provider);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
exports.BrowserOnlyPluginFileServiceContribution = BrowserOnlyPluginFileServiceContribution;
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, inversify_1.inject)(BrowserOnlyPluginFileSystemProvider),
|
|
119
|
+
tslib_1.__metadata("design:type", BrowserOnlyPluginFileSystemProvider)
|
|
120
|
+
], BrowserOnlyPluginFileServiceContribution.prototype, "provider", void 0);
|
|
121
|
+
exports.BrowserOnlyPluginFileServiceContribution = BrowserOnlyPluginFileServiceContribution = tslib_1.__decorate([
|
|
122
|
+
(0, inversify_1.injectable)()
|
|
123
|
+
], BrowserOnlyPluginFileServiceContribution);
|
|
124
|
+
//# sourceMappingURL=browser-only-plugin-file-system-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-plugin-file-system-provider.js","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-plugin-file-system-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAClE,sCAA8D;AAC9D,qDAAmD;AACnD,8DAG4C;AAE5C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
|
+
{"version":3,"file":"browser-only-plugin-file-system-provider.spec.d.ts","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-plugin-file-system-provider.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 Robert Jandow
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
// `BrowserOnlyPluginFileSystemProvider` transitively imports `Endpoint` via `@theia/core/lib/browser`,
|
|
20
|
+
// which touches `document` at load time, so JSDOM is enabled before it for that import.
|
|
21
|
+
let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
22
|
+
const chai_1 = require("chai");
|
|
23
|
+
const core_1 = require("@theia/core");
|
|
24
|
+
const files_1 = require("@theia/filesystem/lib/common/files");
|
|
25
|
+
const constants_1 = require("@theia/plugin-utils/lib/common/constants");
|
|
26
|
+
const browser_only_plugin_file_system_provider_1 = require("./browser-only-plugin-file-system-provider");
|
|
27
|
+
disableJSDOM();
|
|
28
|
+
describe('BrowserOnlyPluginFileSystemProvider', () => {
|
|
29
|
+
// The provider builds asset URLs through `Endpoint`, which reads `self.location`.
|
|
30
|
+
before(() => { disableJSDOM = (0, jsdom_1.enableJSDOM)(); });
|
|
31
|
+
after(() => disableJSDOM());
|
|
32
|
+
const originalFetch = globalThis.fetch;
|
|
33
|
+
let requests;
|
|
34
|
+
function stubFetch(respond) {
|
|
35
|
+
requests = [];
|
|
36
|
+
globalThis.fetch = (async (url, init) => {
|
|
37
|
+
requests.push({ url: String(url), method: init?.method });
|
|
38
|
+
return respond();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function stubFetchFailure(error) {
|
|
42
|
+
requests = [];
|
|
43
|
+
globalThis.fetch = (async (url, init) => {
|
|
44
|
+
requests.push({ url: String(url), method: init?.method });
|
|
45
|
+
throw error;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
globalThis.fetch = originalFetch;
|
|
50
|
+
});
|
|
51
|
+
function assetUri(path) {
|
|
52
|
+
return new core_1.URI(`${constants_1.PLUGINS_SCHEME}:/`).resolve(path);
|
|
53
|
+
}
|
|
54
|
+
function createProvider() {
|
|
55
|
+
return new browser_only_plugin_file_system_provider_1.BrowserOnlyPluginFileSystemProvider();
|
|
56
|
+
}
|
|
57
|
+
it('rejects a resource whose scheme is not the plugin asset scheme', async () => {
|
|
58
|
+
const provider = createProvider();
|
|
59
|
+
await provider.stat(new core_1.URI('file:///theia.foo/1.0.0/package.json')).then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.code).to.equal(files_1.FileSystemProviderErrorCode.FileNotFound));
|
|
60
|
+
});
|
|
61
|
+
it('maps content-length and last-modified into size and mtime', async () => {
|
|
62
|
+
const modified = new Date('2020-01-01T00:00:00.000Z');
|
|
63
|
+
stubFetch(() => new Response(undefined, {
|
|
64
|
+
status: 200,
|
|
65
|
+
headers: { 'content-length': '42', 'last-modified': modified.toUTCString() }
|
|
66
|
+
}));
|
|
67
|
+
const provider = createProvider();
|
|
68
|
+
const stat = await provider.stat(assetUri('theia.foo/1.0.0/icon.svg'));
|
|
69
|
+
(0, chai_1.expect)(stat.size).to.equal(42);
|
|
70
|
+
(0, chai_1.expect)(stat.mtime).to.equal(modified.getTime());
|
|
71
|
+
(0, chai_1.expect)(stat.ctime).to.equal(modified.getTime());
|
|
72
|
+
(0, chai_1.expect)(requests).to.deep.equal([{ url: 'http://localhost/hostedPlugin/theia.foo/1.0.0/icon.svg', method: 'HEAD' }]);
|
|
73
|
+
});
|
|
74
|
+
it('falls back to 0 when content-length/last-modified are absent', async () => {
|
|
75
|
+
stubFetch(() => new Response(undefined, { status: 200 }));
|
|
76
|
+
const provider = createProvider();
|
|
77
|
+
const stat = await provider.stat(assetUri('theia.foo/1.0.0/icon.svg'));
|
|
78
|
+
(0, chai_1.expect)(stat.size).to.equal(0);
|
|
79
|
+
(0, chai_1.expect)(stat.mtime).to.equal(0);
|
|
80
|
+
(0, chai_1.expect)(stat.ctime).to.equal(0);
|
|
81
|
+
});
|
|
82
|
+
it('falls back to 0 when content-length/last-modified cannot be parsed', async () => {
|
|
83
|
+
stubFetch(() => new Response(undefined, {
|
|
84
|
+
status: 200,
|
|
85
|
+
headers: { 'content-length': 'not-a-number', 'last-modified': 'not-a-date' }
|
|
86
|
+
}));
|
|
87
|
+
const provider = createProvider();
|
|
88
|
+
const stat = await provider.stat(assetUri('theia.foo/1.0.0/icon.svg'));
|
|
89
|
+
(0, chai_1.expect)(stat.size).to.equal(0);
|
|
90
|
+
(0, chai_1.expect)(stat.mtime).to.equal(0);
|
|
91
|
+
(0, chai_1.expect)(stat.ctime).to.equal(0);
|
|
92
|
+
});
|
|
93
|
+
it('returns the response body as bytes', async () => {
|
|
94
|
+
const bytes = new Uint8Array([1, 2, 3, 4]);
|
|
95
|
+
stubFetch(() => new Response(bytes, { status: 200 }));
|
|
96
|
+
const provider = createProvider();
|
|
97
|
+
const result = await provider.readFile(assetUri('theia.foo/1.0.0/icon.svg'));
|
|
98
|
+
(0, chai_1.expect)(Array.from(result)).to.deep.equal(Array.from(bytes));
|
|
99
|
+
(0, chai_1.expect)(requests).to.deep.equal([{ url: 'http://localhost/hostedPlugin/theia.foo/1.0.0/icon.svg', method: 'GET' }]);
|
|
100
|
+
});
|
|
101
|
+
it('maps a 404 response to FileNotFound', async () => {
|
|
102
|
+
stubFetch(() => new Response('', { status: 404, statusText: 'Not Found' }));
|
|
103
|
+
const provider = createProvider();
|
|
104
|
+
await provider.readFile(assetUri('theia.foo/1.0.0/missing.svg')).then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.code).to.equal(files_1.FileSystemProviderErrorCode.FileNotFound));
|
|
105
|
+
});
|
|
106
|
+
it('maps other non-ok responses to Unknown', async () => {
|
|
107
|
+
stubFetch(() => new Response('', { status: 500, statusText: 'Internal Server Error' }));
|
|
108
|
+
const provider = createProvider();
|
|
109
|
+
await provider.readFile(assetUri('theia.foo/1.0.0/icon.svg')).then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.code).to.equal(files_1.FileSystemProviderErrorCode.Unknown));
|
|
110
|
+
});
|
|
111
|
+
it('maps a network failure to Unavailable', async () => {
|
|
112
|
+
stubFetchFailure(new Error('network down'));
|
|
113
|
+
const provider = createProvider();
|
|
114
|
+
await provider.readFile(assetUri('theia.foo/1.0.0/icon.svg')).then(() => chai_1.expect.fail('should have rejected'), error => (0, chai_1.expect)(error.code).to.equal(files_1.FileSystemProviderErrorCode.Unavailable));
|
|
115
|
+
});
|
|
116
|
+
it('rejects mutating operations as read-only', () => {
|
|
117
|
+
const provider = createProvider();
|
|
118
|
+
const uri = assetUri('theia.foo/1.0.0/icon.svg');
|
|
119
|
+
(0, chai_1.expect)(() => provider.mkdir(uri)).to.throw().that.has.property('code', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
120
|
+
(0, chai_1.expect)(() => provider.delete(uri, { recursive: false, useTrash: false })).to.throw()
|
|
121
|
+
.that.has.property('code', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
122
|
+
(0, chai_1.expect)(() => provider.rename(uri, uri, { overwrite: false })).to.throw()
|
|
123
|
+
.that.has.property('code', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
124
|
+
(0, chai_1.expect)(() => provider.writeFile(uri, new Uint8Array(), { create: true, overwrite: true })).to.throw()
|
|
125
|
+
.that.has.property('code', files_1.FileSystemProviderErrorCode.NoPermissions);
|
|
126
|
+
});
|
|
127
|
+
it('resolves the request URL through Endpoint, re-encoding # ? % and spaces while keeping / literal', async () => {
|
|
128
|
+
stubFetch(() => new Response(undefined, { status: 200 }));
|
|
129
|
+
const provider = createProvider();
|
|
130
|
+
await provider.stat(assetUri('theia.foo/1.0.0/a b#c?d%e.svg'));
|
|
131
|
+
(0, chai_1.expect)(requests).to.deep.equal([{
|
|
132
|
+
url: 'http://localhost/hostedPlugin/theia.foo/1.0.0/a%20b%23c%3Fd%25e.svg',
|
|
133
|
+
method: 'HEAD'
|
|
134
|
+
}]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=browser-only-plugin-file-system-provider.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-plugin-file-system-provider.spec.js","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-plugin-file-system-provider.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,8DAAiE;AACjE,uGAAuG;AACvG,wFAAwF;AACxF,IAAI,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AAEjC,+BAA8B;AAC9B,sCAAkC;AAClC,8DAAiF;AACjF,wEAA0E;AAC1E,yGAAiG;AAEjG,YAAY,EAAE,CAAC;AAEf,QAAQ,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AM,EAAE,mCAA2B,CAAC,aAAa,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iGAAiG,EAAE,KAAK,IAAI,EAAE;QAC7G,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;QAElC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAE/D,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC5B,GAAG,EAAE,qEAAqE;gBAC1E,MAAM,EAAE,MAAM;aACjB,CAAC,CAAC,CAAC;IACR,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ILogger } from '@theia/core';
|
|
2
|
+
import URI from '@theia/core/lib/common/uri';
|
|
3
|
+
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
4
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
5
|
+
import { UntitledWorkspaceService } from '@theia/workspace/lib/common';
|
|
6
|
+
import { PluginPathsService } from '../../main/common/plugin-paths-protocol';
|
|
7
|
+
/**
|
|
8
|
+
* Resolves plugin log and storage locations for a browser-only application, under the config
|
|
9
|
+
* directory, which lives on the same (browser-local) file system as the workspace.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BrowserOnlyPluginPathsService implements PluginPathsService {
|
|
12
|
+
protected readonly logger: ILogger;
|
|
13
|
+
protected readonly envServer: EnvVariablesServer;
|
|
14
|
+
protected readonly fileService: FileService;
|
|
15
|
+
protected readonly untitledWorkspaceService: UntitledWorkspaceService;
|
|
16
|
+
protected hostLogPath: Promise<string> | undefined;
|
|
17
|
+
getHostLogPath(): Promise<string>;
|
|
18
|
+
protected resolveHostLogPath(): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolving re-hashes the workspace id and hits {@link FileService.createFolder}, and the plugin
|
|
21
|
+
* server asks for this on every workspace storage read/write. The roots are part of the key
|
|
22
|
+
* because an untitled workspace's id is derived from them.
|
|
23
|
+
*/
|
|
24
|
+
protected readonly hostStoragePaths: Map<string, Promise<string>>;
|
|
25
|
+
getHostStoragePath(workspaceUri: string | undefined, rootUris: string[]): Promise<string | undefined>;
|
|
26
|
+
protected resolveHostStoragePath(workspaceUri: string, rootUris: string[]): Promise<string>;
|
|
27
|
+
protected buildWorkspaceId(configDirUri: URI, workspaceUri: string, rootUris: string[]): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Generate time folder name in format: YYYYMMDDTHHMMSS, for example: 20181205T093828
|
|
30
|
+
*/
|
|
31
|
+
protected generateTimeFolderName(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Keeps only the most recent {@link PluginPaths.DEFAULT_PLUGIN_MAX_SESSION_LOGS_FOLDERS}
|
|
34
|
+
* session folders under `logsDirUri`, so reloading doesn't fill up browser storage.
|
|
35
|
+
*/
|
|
36
|
+
protected cleanUpOldLogs(logsDirUri: URI): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates `uri` as a directory (fine if it already exists) and returns its path. Plugins get
|
|
39
|
+
* the path rather than the URI, e.g. as `ExtensionContext.storagePath`.
|
|
40
|
+
*/
|
|
41
|
+
protected ensureDirectory(uri: URI): Promise<string>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=browser-only-plugin-paths-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-only-plugin-paths-service.d.ts","sourceRoot":"","sources":["../../../src/hosted/browser-only/browser-only-plugin-paths-service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,GAAG,MAAM,4BAA4B,CAAC;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