@theia/plugin-ext-vscode 1.34.2 → 1.34.3

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.
Files changed (53) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +32 -32
  3. package/lib/browser/plugin-vscode-commands-contribution.d.ts +79 -79
  4. package/lib/browser/plugin-vscode-commands-contribution.js +768 -768
  5. package/lib/browser/plugin-vscode-contribution.d.ts +5 -5
  6. package/lib/browser/plugin-vscode-contribution.js +53 -53
  7. package/lib/browser/plugin-vscode-frontend-module.d.ts +3 -3
  8. package/lib/browser/plugin-vscode-frontend-module.js +30 -30
  9. package/lib/common/plugin-vscode-environment.d.ts +7 -7
  10. package/lib/common/plugin-vscode-environment.js +47 -47
  11. package/lib/common/plugin-vscode-types.d.ts +2 -2
  12. package/lib/common/plugin-vscode-types.js +21 -21
  13. package/lib/common/plugin-vscode-uri.d.ts +16 -16
  14. package/lib/common/plugin-vscode-uri.js +51 -51
  15. package/lib/node/context/plugin-vscode-init-fe.d.ts +2 -2
  16. package/lib/node/context/plugin-vscode-init-fe.js +37 -37
  17. package/lib/node/local-vsix-file-plugin-deployer-resolver.d.ts +14 -14
  18. package/lib/node/local-vsix-file-plugin-deployer-resolver.js +77 -77
  19. package/lib/node/package.spec.js +25 -25
  20. package/lib/node/plugin-reader.d.ts +6 -6
  21. package/lib/node/plugin-reader.js +36 -36
  22. package/lib/node/plugin-vscode-backend-module.d.ts +3 -3
  23. package/lib/node/plugin-vscode-backend-module.js +43 -43
  24. package/lib/node/plugin-vscode-cli-contribution.d.ts +21 -21
  25. package/lib/node/plugin-vscode-cli-contribution.js +67 -67
  26. package/lib/node/plugin-vscode-deployer-participant.d.ts +6 -6
  27. package/lib/node/plugin-vscode-deployer-participant.js +43 -43
  28. package/lib/node/plugin-vscode-directory-handler.d.ts +21 -21
  29. package/lib/node/plugin-vscode-directory-handler.js +144 -144
  30. package/lib/node/plugin-vscode-file-handler.d.ts +11 -11
  31. package/lib/node/plugin-vscode-file-handler.js +82 -82
  32. package/lib/node/plugin-vscode-init.d.ts +2 -2
  33. package/lib/node/plugin-vscode-init.js +68 -68
  34. package/lib/node/scanner-vscode.d.ts +12 -12
  35. package/lib/node/scanner-vscode.js +111 -111
  36. package/package.json +15 -15
  37. package/src/browser/plugin-vscode-commands-contribution.ts +924 -924
  38. package/src/browser/plugin-vscode-contribution.ts +47 -47
  39. package/src/browser/plugin-vscode-frontend-module.ts +30 -30
  40. package/src/common/plugin-vscode-environment.ts +36 -36
  41. package/src/common/plugin-vscode-types.ts +20 -20
  42. package/src/common/plugin-vscode-uri.ts +47 -47
  43. package/src/node/context/plugin-vscode-init-fe.ts +43 -43
  44. package/src/node/local-vsix-file-plugin-deployer-resolver.ts +65 -65
  45. package/src/node/package.spec.ts +28 -28
  46. package/src/node/plugin-reader.ts +28 -28
  47. package/src/node/plugin-vscode-backend-module.ts +50 -50
  48. package/src/node/plugin-vscode-cli-contribution.ts +64 -64
  49. package/src/node/plugin-vscode-deployer-participant.ts +32 -32
  50. package/src/node/plugin-vscode-directory-handler.ts +141 -141
  51. package/src/node/plugin-vscode-file-handler.ts +72 -72
  52. package/src/node/plugin-vscode-init.ts +80 -80
  53. package/src/node/scanner-vscode.ts +108 -108
@@ -1,141 +1,141 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Red Hat, Inc. 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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * as path from 'path';
18
- import * as filenamify from 'filenamify';
19
- import * as fs from '@theia/core/shared/fs-extra';
20
- import { inject, injectable } from '@theia/core/shared/inversify';
21
- import { RecursivePartial } from '@theia/core';
22
- import {
23
- PluginDeployerDirectoryHandler, PluginDeployerEntry, PluginDeployerDirectoryHandlerContext,
24
- PluginDeployerEntryType, PluginPackage, PluginType, PluginIdentifiers
25
- } from '@theia/plugin-ext';
26
- import { FileUri } from '@theia/core/lib/node';
27
- import { getTempDir } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
28
- import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cli-contribution';
29
-
30
- @injectable()
31
- export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
32
-
33
- protected readonly deploymentDirectory = FileUri.create(getTempDir('vscode-copied'));
34
-
35
- @inject(PluginCliContribution) protected readonly pluginCli: PluginCliContribution;
36
-
37
- accept(plugin: PluginDeployerEntry): boolean {
38
- console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
39
- return this.attemptResolution(plugin);
40
- }
41
-
42
- protected attemptResolution(plugin: PluginDeployerEntry): boolean {
43
- return this.resolvePackage(plugin) || this.deriveMetadata(plugin);
44
- }
45
-
46
- protected deriveMetadata(plugin: PluginDeployerEntry): boolean {
47
- return this.resolveFromSources(plugin) || this.resolveFromVSIX(plugin) || this.resolveFromNpmTarball(plugin);
48
- }
49
-
50
- async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
51
- await this.copyDirectory(context);
52
- const types: PluginDeployerEntryType[] = [];
53
- const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
54
- if (packageJson.browser) {
55
- types.push(PluginDeployerEntryType.FRONTEND);
56
- }
57
- if (packageJson.main || !packageJson.browser) {
58
- types.push(PluginDeployerEntryType.BACKEND);
59
- }
60
- context.pluginEntry().accept(...types);
61
- }
62
-
63
- protected async copyDirectory(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
64
- if (this.pluginCli.copyUncompressedPlugins() && context.pluginEntry().type === PluginType.User) {
65
- const entry = context.pluginEntry();
66
- const id = entry.id();
67
- const pathToRestore = entry.path();
68
- const origin = entry.originalPath();
69
- const targetDir = await this.getExtensionDir(context);
70
- try {
71
- if (fs.existsSync(targetDir) || !entry.path().startsWith(origin)) {
72
- console.log(`[${id}]: already copied.`);
73
- } else {
74
- console.log(`[${id}]: copying to "${targetDir}"`);
75
- await fs.mkdirp(FileUri.fsPath(this.deploymentDirectory));
76
- await context.copy(origin, targetDir);
77
- entry.updatePath(targetDir);
78
- if (!this.deriveMetadata(entry)) {
79
- throw new Error('Unable to resolve plugin metadata after copying');
80
- }
81
- }
82
- } catch (e) {
83
- console.warn(`[${id}]: Error when copying.`, e);
84
- entry.updatePath(pathToRestore);
85
- }
86
- }
87
- }
88
-
89
- protected resolveFromSources(plugin: PluginDeployerEntry): boolean {
90
- const pluginPath = plugin.path();
91
- return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
92
- }
93
-
94
- protected resolveFromVSIX(plugin: PluginDeployerEntry): boolean {
95
- if (!fs.existsSync(path.join(plugin.path(), 'extension.vsixmanifest'))) {
96
- return false;
97
- }
98
- const pluginPath = path.join(plugin.path(), 'extension');
99
- return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
100
- }
101
-
102
- protected resolveFromNpmTarball(plugin: PluginDeployerEntry): boolean {
103
- const pluginPath = path.join(plugin.path(), 'package');
104
- return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
105
- }
106
-
107
- protected resolvePackage(plugin: PluginDeployerEntry, options?: {
108
- pluginPath: string
109
- pck?: RecursivePartial<PluginPackage>
110
- }): boolean {
111
- const { pluginPath, pck } = options || {
112
- pluginPath: plugin.path(),
113
- pck: plugin.getValue('package.json')
114
- };
115
- if (!pck || !pck.name || !pck.version || !pck.engines || !pck.engines.vscode) {
116
- return false;
117
- }
118
- pck.publisher ??= PluginIdentifiers.UNPUBLISHED;
119
- if (options) {
120
- plugin.storeValue('package.json', pck);
121
- plugin.rootPath = plugin.path();
122
- plugin.updatePath(pluginPath);
123
- }
124
- console.log(`Resolved "${plugin.id()}" to a VS Code extension "${pck.name}@${pck.version}" with engines:`, pck.engines);
125
- return true;
126
- }
127
-
128
- protected requirePackage(pluginPath: string): PluginPackage | undefined {
129
- try {
130
- const plugin = fs.readJSONSync(path.join(pluginPath, 'package.json')) as PluginPackage;
131
- plugin.publisher ??= PluginIdentifiers.UNPUBLISHED;
132
- return plugin;
133
- } catch {
134
- return undefined;
135
- }
136
- }
137
-
138
- protected async getExtensionDir(context: PluginDeployerDirectoryHandlerContext): Promise<string> {
139
- return FileUri.fsPath(this.deploymentDirectory.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
140
- }
141
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Red Hat, Inc. 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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import * as path from 'path';
18
+ import * as filenamify from 'filenamify';
19
+ import * as fs from '@theia/core/shared/fs-extra';
20
+ import { inject, injectable } from '@theia/core/shared/inversify';
21
+ import { RecursivePartial } from '@theia/core';
22
+ import {
23
+ PluginDeployerDirectoryHandler, PluginDeployerEntry, PluginDeployerDirectoryHandlerContext,
24
+ PluginDeployerEntryType, PluginPackage, PluginType, PluginIdentifiers
25
+ } from '@theia/plugin-ext';
26
+ import { FileUri } from '@theia/core/lib/node';
27
+ import { getTempDir } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
28
+ import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cli-contribution';
29
+
30
+ @injectable()
31
+ export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
32
+
33
+ protected readonly deploymentDirectory = FileUri.create(getTempDir('vscode-copied'));
34
+
35
+ @inject(PluginCliContribution) protected readonly pluginCli: PluginCliContribution;
36
+
37
+ accept(plugin: PluginDeployerEntry): boolean {
38
+ console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
39
+ return this.attemptResolution(plugin);
40
+ }
41
+
42
+ protected attemptResolution(plugin: PluginDeployerEntry): boolean {
43
+ return this.resolvePackage(plugin) || this.deriveMetadata(plugin);
44
+ }
45
+
46
+ protected deriveMetadata(plugin: PluginDeployerEntry): boolean {
47
+ return this.resolveFromSources(plugin) || this.resolveFromVSIX(plugin) || this.resolveFromNpmTarball(plugin);
48
+ }
49
+
50
+ async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
51
+ await this.copyDirectory(context);
52
+ const types: PluginDeployerEntryType[] = [];
53
+ const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
54
+ if (packageJson.browser) {
55
+ types.push(PluginDeployerEntryType.FRONTEND);
56
+ }
57
+ if (packageJson.main || !packageJson.browser) {
58
+ types.push(PluginDeployerEntryType.BACKEND);
59
+ }
60
+ context.pluginEntry().accept(...types);
61
+ }
62
+
63
+ protected async copyDirectory(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
64
+ if (this.pluginCli.copyUncompressedPlugins() && context.pluginEntry().type === PluginType.User) {
65
+ const entry = context.pluginEntry();
66
+ const id = entry.id();
67
+ const pathToRestore = entry.path();
68
+ const origin = entry.originalPath();
69
+ const targetDir = await this.getExtensionDir(context);
70
+ try {
71
+ if (fs.existsSync(targetDir) || !entry.path().startsWith(origin)) {
72
+ console.log(`[${id}]: already copied.`);
73
+ } else {
74
+ console.log(`[${id}]: copying to "${targetDir}"`);
75
+ await fs.mkdirp(FileUri.fsPath(this.deploymentDirectory));
76
+ await context.copy(origin, targetDir);
77
+ entry.updatePath(targetDir);
78
+ if (!this.deriveMetadata(entry)) {
79
+ throw new Error('Unable to resolve plugin metadata after copying');
80
+ }
81
+ }
82
+ } catch (e) {
83
+ console.warn(`[${id}]: Error when copying.`, e);
84
+ entry.updatePath(pathToRestore);
85
+ }
86
+ }
87
+ }
88
+
89
+ protected resolveFromSources(plugin: PluginDeployerEntry): boolean {
90
+ const pluginPath = plugin.path();
91
+ return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
92
+ }
93
+
94
+ protected resolveFromVSIX(plugin: PluginDeployerEntry): boolean {
95
+ if (!fs.existsSync(path.join(plugin.path(), 'extension.vsixmanifest'))) {
96
+ return false;
97
+ }
98
+ const pluginPath = path.join(plugin.path(), 'extension');
99
+ return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
100
+ }
101
+
102
+ protected resolveFromNpmTarball(plugin: PluginDeployerEntry): boolean {
103
+ const pluginPath = path.join(plugin.path(), 'package');
104
+ return this.resolvePackage(plugin, { pluginPath, pck: this.requirePackage(pluginPath) });
105
+ }
106
+
107
+ protected resolvePackage(plugin: PluginDeployerEntry, options?: {
108
+ pluginPath: string
109
+ pck?: RecursivePartial<PluginPackage>
110
+ }): boolean {
111
+ const { pluginPath, pck } = options || {
112
+ pluginPath: plugin.path(),
113
+ pck: plugin.getValue('package.json')
114
+ };
115
+ if (!pck || !pck.name || !pck.version || !pck.engines || !pck.engines.vscode) {
116
+ return false;
117
+ }
118
+ pck.publisher ??= PluginIdentifiers.UNPUBLISHED;
119
+ if (options) {
120
+ plugin.storeValue('package.json', pck);
121
+ plugin.rootPath = plugin.path();
122
+ plugin.updatePath(pluginPath);
123
+ }
124
+ console.log(`Resolved "${plugin.id()}" to a VS Code extension "${pck.name}@${pck.version}" with engines:`, pck.engines);
125
+ return true;
126
+ }
127
+
128
+ protected requirePackage(pluginPath: string): PluginPackage | undefined {
129
+ try {
130
+ const plugin = fs.readJSONSync(path.join(pluginPath, 'package.json')) as PluginPackage;
131
+ plugin.publisher ??= PluginIdentifiers.UNPUBLISHED;
132
+ return plugin;
133
+ } catch {
134
+ return undefined;
135
+ }
136
+ }
137
+
138
+ protected async getExtensionDir(context: PluginDeployerDirectoryHandlerContext): Promise<string> {
139
+ return FileUri.fsPath(this.deploymentDirectory.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
140
+ }
141
+ }
@@ -1,72 +1,72 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Red Hat, Inc. 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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { PluginDeployerFileHandler, PluginDeployerEntry, PluginDeployerFileHandlerContext, PluginType } from '@theia/plugin-ext';
18
- import * as fs from '@theia/core/shared/fs-extra';
19
- import * as path from 'path';
20
- import * as filenamify from 'filenamify';
21
- import { injectable, inject } from '@theia/core/shared/inversify';
22
- import { getTempDir } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
23
- import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
24
- import { FileUri } from '@theia/core/lib/node/file-uri';
25
-
26
- export const isVSCodePluginFile = (pluginPath?: string) => Boolean(pluginPath && (pluginPath.endsWith('.vsix') || pluginPath.endsWith('.tgz')));
27
-
28
- @injectable()
29
- export class PluginVsCodeFileHandler implements PluginDeployerFileHandler {
30
-
31
- @inject(PluginVSCodeEnvironment)
32
- protected readonly environment: PluginVSCodeEnvironment;
33
-
34
- private readonly systemExtensionsDirUri = FileUri.create(getTempDir('vscode-unpacked'));
35
-
36
- accept(resolvedPlugin: PluginDeployerEntry): boolean {
37
- if (!resolvedPlugin.isFile()) {
38
- return false;
39
- }
40
- return isVSCodePluginFile(resolvedPlugin.path());
41
- }
42
-
43
- async handle(context: PluginDeployerFileHandlerContext): Promise<void> {
44
- const id = context.pluginEntry().id();
45
- const extensionDir = await this.getExtensionDir(context);
46
- console.log(`[${id}]: trying to decompress into "${extensionDir}"...`);
47
- if (context.pluginEntry().type === PluginType.User && await fs.pathExists(extensionDir)) {
48
- console.log(`[${id}]: already found`);
49
- context.pluginEntry().updatePath(extensionDir);
50
- return;
51
- }
52
- await this.decompress(extensionDir, context);
53
- console.log(`[${id}]: decompressed`);
54
- context.pluginEntry().updatePath(extensionDir);
55
- }
56
-
57
- protected async getExtensionDir(context: PluginDeployerFileHandlerContext): Promise<string> {
58
- return FileUri.fsPath(this.systemExtensionsDirUri.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
59
- }
60
-
61
- protected async decompress(extensionDir: string, context: PluginDeployerFileHandlerContext): Promise<void> {
62
- await context.unzip(context.pluginEntry().path(), extensionDir);
63
- if (context.pluginEntry().path().endsWith('.tgz')) {
64
- const extensionPath = path.join(extensionDir, 'package');
65
- const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
66
- if (await fs.pathExists(vscodeNodeModulesPath)) {
67
- await context.unzip(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
68
- }
69
- }
70
- }
71
-
72
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Red Hat, Inc. 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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { PluginDeployerFileHandler, PluginDeployerEntry, PluginDeployerFileHandlerContext, PluginType } from '@theia/plugin-ext';
18
+ import * as fs from '@theia/core/shared/fs-extra';
19
+ import * as path from 'path';
20
+ import * as filenamify from 'filenamify';
21
+ import { injectable, inject } from '@theia/core/shared/inversify';
22
+ import { getTempDir } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
23
+ import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
24
+ import { FileUri } from '@theia/core/lib/node/file-uri';
25
+
26
+ export const isVSCodePluginFile = (pluginPath?: string) => Boolean(pluginPath && (pluginPath.endsWith('.vsix') || pluginPath.endsWith('.tgz')));
27
+
28
+ @injectable()
29
+ export class PluginVsCodeFileHandler implements PluginDeployerFileHandler {
30
+
31
+ @inject(PluginVSCodeEnvironment)
32
+ protected readonly environment: PluginVSCodeEnvironment;
33
+
34
+ private readonly systemExtensionsDirUri = FileUri.create(getTempDir('vscode-unpacked'));
35
+
36
+ accept(resolvedPlugin: PluginDeployerEntry): boolean {
37
+ if (!resolvedPlugin.isFile()) {
38
+ return false;
39
+ }
40
+ return isVSCodePluginFile(resolvedPlugin.path());
41
+ }
42
+
43
+ async handle(context: PluginDeployerFileHandlerContext): Promise<void> {
44
+ const id = context.pluginEntry().id();
45
+ const extensionDir = await this.getExtensionDir(context);
46
+ console.log(`[${id}]: trying to decompress into "${extensionDir}"...`);
47
+ if (context.pluginEntry().type === PluginType.User && await fs.pathExists(extensionDir)) {
48
+ console.log(`[${id}]: already found`);
49
+ context.pluginEntry().updatePath(extensionDir);
50
+ return;
51
+ }
52
+ await this.decompress(extensionDir, context);
53
+ console.log(`[${id}]: decompressed`);
54
+ context.pluginEntry().updatePath(extensionDir);
55
+ }
56
+
57
+ protected async getExtensionDir(context: PluginDeployerFileHandlerContext): Promise<string> {
58
+ return FileUri.fsPath(this.systemExtensionsDirUri.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
59
+ }
60
+
61
+ protected async decompress(extensionDir: string, context: PluginDeployerFileHandlerContext): Promise<void> {
62
+ await context.unzip(context.pluginEntry().path(), extensionDir);
63
+ if (context.pluginEntry().path().endsWith('.tgz')) {
64
+ const extensionPath = path.join(extensionDir, 'package');
65
+ const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
66
+ if (await fs.pathExists(vscodeNodeModulesPath)) {
67
+ await context.unzip(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
68
+ }
69
+ }
70
+ }
71
+
72
+ }
@@ -1,80 +1,80 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018-2019 Red Hat, Inc.
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
-
19
- import * as theia from '@theia/plugin';
20
- import { BackendInitializationFn, PluginAPIFactory, Plugin, emptyPlugin } from '@theia/plugin-ext';
21
- import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
22
-
23
- process.env['VSCODE_PID'] = process.env['THEIA_PARENT_PID'];
24
-
25
- const pluginsApiImpl = new Map<string, typeof theia>();
26
- const plugins = new Array<Plugin>();
27
- let defaultApi: typeof theia;
28
- let isLoadOverride = false;
29
- let pluginApiFactory: PluginAPIFactory;
30
-
31
- export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIFactory, plugin: Plugin) => {
32
- pluginsApiImpl.set(plugin.model.id, createVSCodeAPI(apiFactory, plugin));
33
- plugins.push(plugin);
34
- pluginApiFactory = apiFactory;
35
-
36
- if (!isLoadOverride) {
37
- overrideInternalLoad();
38
- isLoadOverride = true;
39
- }
40
- };
41
-
42
- function createVSCodeAPI(apiFactory: PluginAPIFactory, plugin: Plugin): typeof theia {
43
- const vscode = apiFactory(plugin);
44
-
45
- // override the version for vscode to be a VSCode version
46
- (<any>vscode).version = process.env['VSCODE_API_VERSION'] || VSCODE_DEFAULT_API_VERSION;
47
- return vscode;
48
- }
49
-
50
- function overrideInternalLoad(): void {
51
- const module = require('module');
52
- const vscodeModuleName = 'vscode';
53
- // save original load method
54
- const internalLoad = module._load;
55
-
56
- // if we try to resolve theia module, return the filename entry to use cache.
57
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- module._load = function (request: string, parent: any, isMain: {}): any {
59
- if (request !== vscodeModuleName) {
60
- return internalLoad.apply(this, arguments);
61
- }
62
-
63
- const plugin = findPlugin(parent.filename);
64
- if (plugin) {
65
- const apiImpl = pluginsApiImpl.get(plugin.model.id);
66
- return apiImpl;
67
- }
68
-
69
- if (!defaultApi) {
70
- console.warn(`Could not identify plugin for 'Theia' require call from ${parent.filename}`);
71
- defaultApi = createVSCodeAPI(pluginApiFactory, emptyPlugin);
72
- }
73
-
74
- return defaultApi;
75
- };
76
- }
77
-
78
- function findPlugin(filePath: string): Plugin | undefined {
79
- return plugins.find(plugin => filePath.startsWith(plugin.pluginFolder));
80
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018-2019 Red Hat, Inc.
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
+
19
+ import * as theia from '@theia/plugin';
20
+ import { BackendInitializationFn, PluginAPIFactory, Plugin, emptyPlugin } from '@theia/plugin-ext';
21
+ import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
22
+
23
+ process.env['VSCODE_PID'] = process.env['THEIA_PARENT_PID'];
24
+
25
+ const pluginsApiImpl = new Map<string, typeof theia>();
26
+ const plugins = new Array<Plugin>();
27
+ let defaultApi: typeof theia;
28
+ let isLoadOverride = false;
29
+ let pluginApiFactory: PluginAPIFactory;
30
+
31
+ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIFactory, plugin: Plugin) => {
32
+ pluginsApiImpl.set(plugin.model.id, createVSCodeAPI(apiFactory, plugin));
33
+ plugins.push(plugin);
34
+ pluginApiFactory = apiFactory;
35
+
36
+ if (!isLoadOverride) {
37
+ overrideInternalLoad();
38
+ isLoadOverride = true;
39
+ }
40
+ };
41
+
42
+ function createVSCodeAPI(apiFactory: PluginAPIFactory, plugin: Plugin): typeof theia {
43
+ const vscode = apiFactory(plugin);
44
+
45
+ // override the version for vscode to be a VSCode version
46
+ (<any>vscode).version = process.env['VSCODE_API_VERSION'] || VSCODE_DEFAULT_API_VERSION;
47
+ return vscode;
48
+ }
49
+
50
+ function overrideInternalLoad(): void {
51
+ const module = require('module');
52
+ const vscodeModuleName = 'vscode';
53
+ // save original load method
54
+ const internalLoad = module._load;
55
+
56
+ // if we try to resolve theia module, return the filename entry to use cache.
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ module._load = function (request: string, parent: any, isMain: {}): any {
59
+ if (request !== vscodeModuleName) {
60
+ return internalLoad.apply(this, arguments);
61
+ }
62
+
63
+ const plugin = findPlugin(parent.filename);
64
+ if (plugin) {
65
+ const apiImpl = pluginsApiImpl.get(plugin.model.id);
66
+ return apiImpl;
67
+ }
68
+
69
+ if (!defaultApi) {
70
+ console.warn(`Could not identify plugin for 'Theia' require call from ${parent.filename}`);
71
+ defaultApi = createVSCodeAPI(pluginApiFactory, emptyPlugin);
72
+ }
73
+
74
+ return defaultApi;
75
+ };
76
+ }
77
+
78
+ function findPlugin(filePath: string): Plugin | undefined {
79
+ return plugins.find(plugin => filePath.startsWith(plugin.pluginFolder));
80
+ }