@theia/plugin-ext-vscode 1.73.0-next.3 → 1.73.0-next.31
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/node/plugin-vscode-init.d.ts +8 -1
- package/lib/node/plugin-vscode-init.d.ts.map +1 -1
- package/lib/node/plugin-vscode-init.js +11 -3
- package/lib/node/plugin-vscode-init.js.map +1 -1
- package/lib/node/plugin-vscode-init.spec.d.ts +2 -0
- package/lib/node/plugin-vscode-init.spec.d.ts.map +1 -0
- package/lib/node/plugin-vscode-init.spec.js +47 -0
- package/lib/node/plugin-vscode-init.spec.js.map +1 -0
- package/package.json +16 -16
- package/src/node/plugin-vscode-init.spec.ts +55 -0
- package/src/node/plugin-vscode-init.ts +10 -3
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { BackendInitializationFn } from '@theia/plugin-ext';
|
|
1
|
+
import { BackendInitializationFn, Plugin } from '@theia/plugin-ext';
|
|
2
2
|
export declare const doInitialization: BackendInitializationFn;
|
|
3
|
+
/**
|
|
4
|
+
* Locate the plugin whose folder contains the given file.
|
|
5
|
+
*
|
|
6
|
+
* Matches on folder boundaries, so sibling plugins whose folder names share
|
|
7
|
+
* a prefix (e.g. `acme.foo` vs. `acme.foo-extras`) are not mismatched.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findPlugin(pluginList: ReadonlyArray<Plugin>, filePath: string): Plugin | undefined;
|
|
3
10
|
//# sourceMappingURL=plugin-vscode-init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-vscode-init.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-vscode-init.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,uBAAuB,EAAoB,MAAM,EAAe,MAAM,mBAAmB,CAAC;AAWnG,eAAO,MAAM,gBAAgB,EAAE,uBAS9B,CAAC;AAwCF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElG"}
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.doInitialization = void 0;
|
|
19
|
+
exports.findPlugin = findPlugin;
|
|
19
20
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
21
|
const node_module_1 = require("node:module");
|
|
22
|
+
const paths_1 = require("@theia/core/lib/common/paths");
|
|
21
23
|
const plugin_ext_1 = require("@theia/plugin-ext");
|
|
22
24
|
const plugin_vscode_types_1 = require("../common/plugin-vscode-types");
|
|
23
25
|
process.env['VSCODE_PID'] = process.env['THEIA_PARENT_PID'];
|
|
@@ -53,7 +55,7 @@ function overrideInternalLoad() {
|
|
|
53
55
|
if (request !== vscodeModuleName) {
|
|
54
56
|
return internalLoad.apply(this, arguments);
|
|
55
57
|
}
|
|
56
|
-
const plugin = findPlugin(parent.filename);
|
|
58
|
+
const plugin = findPlugin(plugins, parent.filename);
|
|
57
59
|
if (plugin) {
|
|
58
60
|
const apiImpl = pluginsApiImpl.get(plugin.model.id);
|
|
59
61
|
return apiImpl;
|
|
@@ -66,8 +68,14 @@ function overrideInternalLoad() {
|
|
|
66
68
|
};
|
|
67
69
|
registerESMLoaderHook();
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Locate the plugin whose folder contains the given file.
|
|
73
|
+
*
|
|
74
|
+
* Matches on folder boundaries, so sibling plugins whose folder names share
|
|
75
|
+
* a prefix (e.g. `acme.foo` vs. `acme.foo-extras`) are not mismatched.
|
|
76
|
+
*/
|
|
77
|
+
function findPlugin(pluginList, filePath) {
|
|
78
|
+
return pluginList.find(plugin => (0, paths_1.isEqualOrParent)(filePath, plugin.pluginFolder));
|
|
71
79
|
}
|
|
72
80
|
/**
|
|
73
81
|
* Register an ESM loader hook so that `import 'vscode'` from an ESM plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-vscode-init.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,wCAAwC;AACxC,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;;;
|
|
1
|
+
{"version":3,"file":"plugin-vscode-init.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,wCAAwC;AACxC,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;;;AAyEhF,gCAEC;AAzED,uDAAuD;AAEvD,6CAAuC;AAEvC,wDAA+D;AAC/D,kDAAmG;AACnG,uEAA2E;AAE3E,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAE5D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;AACvD,MAAM,OAAO,GAAG,IAAI,KAAK,EAAU,CAAC;AACpC,IAAI,UAAwB,CAAC;AAC7B,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,gBAAkC,CAAC;AAEhC,MAAM,gBAAgB,GAA4B,CAAC,UAA4B,EAAE,MAAc,EAAE,EAAE;IACtG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,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file":"plugin-vscode-init.spec.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
19
|
+
const chai_1 = require("chai");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const plugin_vscode_init_1 = require("./plugin-vscode-init");
|
|
22
|
+
const PLUGIN_A_FOLDER = path.join(path.sep, 'p', 'sample-namespace.plugin-esm');
|
|
23
|
+
const PLUGIN_B_FOLDER = path.join(path.sep, 'p', 'sample-namespace.plugin-esm-mjs');
|
|
24
|
+
const pluginA = { pluginFolder: PLUGIN_A_FOLDER };
|
|
25
|
+
const pluginB = { pluginFolder: PLUGIN_B_FOLDER };
|
|
26
|
+
const plugins = [pluginA, pluginB];
|
|
27
|
+
describe('findPlugin', () => {
|
|
28
|
+
it('matches the plugin whose folder directly contains the file', () => {
|
|
29
|
+
const file = path.join(PLUGIN_A_FOLDER, 'extension.js');
|
|
30
|
+
(0, chai_1.expect)((0, plugin_vscode_init_1.findPlugin)(plugins, file)).to.equal(pluginA);
|
|
31
|
+
});
|
|
32
|
+
it('matches a nested file inside the plugin folder', () => {
|
|
33
|
+
const file = path.join(PLUGIN_B_FOLDER, 'node_modules', 'dep', 'index.js');
|
|
34
|
+
(0, chai_1.expect)((0, plugin_vscode_init_1.findPlugin)(plugins, file)).to.equal(pluginB);
|
|
35
|
+
});
|
|
36
|
+
it('does not mismatch when one plugin folder name is a prefix of another', () => {
|
|
37
|
+
const file = path.join(PLUGIN_B_FOLDER, 'extension.mjs');
|
|
38
|
+
(0, chai_1.expect)((0, plugin_vscode_init_1.findPlugin)(plugins, file)).to.equal(pluginB);
|
|
39
|
+
});
|
|
40
|
+
it('returns undefined for a path outside any plugin folder', () => {
|
|
41
|
+
(0, chai_1.expect)((0, plugin_vscode_init_1.findPlugin)(plugins, path.join(path.sep, 'p', 'some-other', 'file.js'))).to.be.undefined;
|
|
42
|
+
});
|
|
43
|
+
it('returns undefined for an empty plugin list', () => {
|
|
44
|
+
(0, chai_1.expect)((0, plugin_vscode_init_1.findPlugin)([], path.join(PLUGIN_A_FOLDER, 'extension.js'))).to.be.undefined;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=plugin-vscode-init.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-vscode-init.spec.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,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,uDAAuD;AAEvD,+BAA8B;AAC9B,6BAA6B;AAE7B,6DAAkD;AAElD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,C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EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAC9D,IAAA,aAAM,EAAC,IAAA,+BAAU,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IACnG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,IAAA,aAAM,EAAC,IAAA,+BAAU,EAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/plugin-ext-vscode",
|
|
3
|
-
"version": "1.73.0-next.
|
|
3
|
+
"version": "1.73.0-next.31+f888a90fa",
|
|
4
4
|
"description": "Theia - Plugin Extension for VsCode",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/callhierarchy": "1.73.0-next.
|
|
7
|
-
"@theia/core": "1.73.0-next.
|
|
8
|
-
"@theia/editor": "1.73.0-next.
|
|
9
|
-
"@theia/filesystem": "1.73.0-next.
|
|
10
|
-
"@theia/monaco": "1.73.0-next.
|
|
6
|
+
"@theia/callhierarchy": "1.73.0-next.31+f888a90fa",
|
|
7
|
+
"@theia/core": "1.73.0-next.31+f888a90fa",
|
|
8
|
+
"@theia/editor": "1.73.0-next.31+f888a90fa",
|
|
9
|
+
"@theia/filesystem": "1.73.0-next.31+f888a90fa",
|
|
10
|
+
"@theia/monaco": "1.73.0-next.31+f888a90fa",
|
|
11
11
|
"@theia/monaco-editor-core": "1.108.201",
|
|
12
|
-
"@theia/navigator": "1.73.0-next.
|
|
13
|
-
"@theia/outline-view": "1.73.0-next.
|
|
14
|
-
"@theia/plugin": "1.73.0-next.
|
|
15
|
-
"@theia/plugin-ext": "1.73.0-next.
|
|
16
|
-
"@theia/scm": "1.73.0-next.
|
|
17
|
-
"@theia/terminal": "1.73.0-next.
|
|
18
|
-
"@theia/typehierarchy": "1.73.0-next.
|
|
19
|
-
"@theia/userstorage": "1.73.0-next.
|
|
20
|
-
"@theia/workspace": "1.73.0-next.
|
|
12
|
+
"@theia/navigator": "1.73.0-next.31+f888a90fa",
|
|
13
|
+
"@theia/outline-view": "1.73.0-next.31+f888a90fa",
|
|
14
|
+
"@theia/plugin": "1.73.0-next.31+f888a90fa",
|
|
15
|
+
"@theia/plugin-ext": "1.73.0-next.31+f888a90fa",
|
|
16
|
+
"@theia/scm": "1.73.0-next.31+f888a90fa",
|
|
17
|
+
"@theia/terminal": "1.73.0-next.31+f888a90fa",
|
|
18
|
+
"@theia/typehierarchy": "1.73.0-next.31+f888a90fa",
|
|
19
|
+
"@theia/userstorage": "1.73.0-next.31+f888a90fa",
|
|
20
|
+
"@theia/workspace": "1.73.0-next.31+f888a90fa",
|
|
21
21
|
"decompress": "^4.2.1",
|
|
22
22
|
"filenamify": "^4.3.0",
|
|
23
23
|
"tslib": "^2.8.1"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"nyc": {
|
|
62
62
|
"extends": "../../configs/nyc.json"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f888a90fa9ccf8c0468fcb567369625c51ede3ee"
|
|
65
65
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
+
|
|
19
|
+
import { expect } from 'chai';
|
|
20
|
+
import * as path from 'path';
|
|
21
|
+
import { Plugin } from '@theia/plugin-ext';
|
|
22
|
+
import { findPlugin } from './plugin-vscode-init';
|
|
23
|
+
|
|
24
|
+
const PLUGIN_A_FOLDER = path.join(path.sep, 'p', 'sample-namespace.plugin-esm');
|
|
25
|
+
const PLUGIN_B_FOLDER = path.join(path.sep, 'p', 'sample-namespace.plugin-esm-mjs');
|
|
26
|
+
|
|
27
|
+
const pluginA = { pluginFolder: PLUGIN_A_FOLDER } as Plugin;
|
|
28
|
+
const pluginB = { pluginFolder: PLUGIN_B_FOLDER } as Plugin;
|
|
29
|
+
const plugins = [pluginA, pluginB];
|
|
30
|
+
|
|
31
|
+
describe('findPlugin', () => {
|
|
32
|
+
|
|
33
|
+
it('matches the plugin whose folder directly contains the file', () => {
|
|
34
|
+
const file = path.join(PLUGIN_A_FOLDER, 'extension.js');
|
|
35
|
+
expect(findPlugin(plugins, file)).to.equal(pluginA);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('matches a nested file inside the plugin folder', () => {
|
|
39
|
+
const file = path.join(PLUGIN_B_FOLDER, 'node_modules', 'dep', 'index.js');
|
|
40
|
+
expect(findPlugin(plugins, file)).to.equal(pluginB);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not mismatch when one plugin folder name is a prefix of another', () => {
|
|
44
|
+
const file = path.join(PLUGIN_B_FOLDER, 'extension.mjs');
|
|
45
|
+
expect(findPlugin(plugins, file)).to.equal(pluginB);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns undefined for a path outside any plugin folder', () => {
|
|
49
|
+
expect(findPlugin(plugins, path.join(path.sep, 'p', 'some-other', 'file.js'))).to.be.undefined;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('returns undefined for an empty plugin list', () => {
|
|
53
|
+
expect(findPlugin([], path.join(PLUGIN_A_FOLDER, 'extension.js'))).to.be.undefined;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { register } from 'node:module';
|
|
20
20
|
import * as theia from '@theia/plugin';
|
|
21
|
+
import { isEqualOrParent } from '@theia/core/lib/common/paths';
|
|
21
22
|
import { BackendInitializationFn, PluginAPIFactory, Plugin, emptyPlugin } from '@theia/plugin-ext';
|
|
22
23
|
import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
|
|
23
24
|
|
|
@@ -61,7 +62,7 @@ function overrideInternalLoad(): void {
|
|
|
61
62
|
return internalLoad.apply(this, arguments);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
const plugin = findPlugin(parent.filename);
|
|
65
|
+
const plugin = findPlugin(plugins, parent.filename);
|
|
65
66
|
if (plugin) {
|
|
66
67
|
const apiImpl = pluginsApiImpl.get(plugin.model.id);
|
|
67
68
|
return apiImpl;
|
|
@@ -78,8 +79,14 @@ function overrideInternalLoad(): void {
|
|
|
78
79
|
registerESMLoaderHook();
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Locate the plugin whose folder contains the given file.
|
|
84
|
+
*
|
|
85
|
+
* Matches on folder boundaries, so sibling plugins whose folder names share
|
|
86
|
+
* a prefix (e.g. `acme.foo` vs. `acme.foo-extras`) are not mismatched.
|
|
87
|
+
*/
|
|
88
|
+
export function findPlugin(pluginList: ReadonlyArray<Plugin>, filePath: string): Plugin | undefined {
|
|
89
|
+
return pluginList.find(plugin => isEqualOrParent(filePath, plugin.pluginFolder));
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
/**
|