@theia/plugin-ext-vscode 1.43.1 → 1.45.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.
Files changed (31) hide show
  1. package/lib/common/plugin-vscode-environment.d.ts +6 -2
  2. package/lib/common/plugin-vscode-environment.d.ts.map +1 -1
  3. package/lib/common/plugin-vscode-environment.js +21 -4
  4. package/lib/common/plugin-vscode-environment.js.map +1 -1
  5. package/lib/common/plugin-vscode-types.d.ts +1 -1
  6. package/lib/node/local-vsix-file-plugin-deployer-resolver.d.ts +1 -4
  7. package/lib/node/local-vsix-file-plugin-deployer-resolver.d.ts.map +1 -1
  8. package/lib/node/local-vsix-file-plugin-deployer-resolver.js +8 -24
  9. package/lib/node/local-vsix-file-plugin-deployer-resolver.js.map +1 -1
  10. package/lib/node/plugin-vscode-deployer-participant.d.ts.map +1 -1
  11. package/lib/node/plugin-vscode-deployer-participant.js +17 -2
  12. package/lib/node/plugin-vscode-deployer-participant.js.map +1 -1
  13. package/lib/node/plugin-vscode-directory-handler.d.ts +0 -3
  14. package/lib/node/plugin-vscode-directory-handler.d.ts.map +1 -1
  15. package/lib/node/plugin-vscode-directory-handler.js +6 -43
  16. package/lib/node/plugin-vscode-directory-handler.js.map +1 -1
  17. package/lib/node/plugin-vscode-file-handler.d.ts +1 -4
  18. package/lib/node/plugin-vscode-file-handler.d.ts.map +1 -1
  19. package/lib/node/plugin-vscode-file-handler.js +21 -36
  20. package/lib/node/plugin-vscode-file-handler.js.map +1 -1
  21. package/lib/node/plugin-vscode-utils.d.ts +8 -0
  22. package/lib/node/plugin-vscode-utils.d.ts.map +1 -0
  23. package/lib/node/plugin-vscode-utils.js +105 -0
  24. package/lib/node/plugin-vscode-utils.js.map +1 -0
  25. package/package.json +16 -15
  26. package/src/common/plugin-vscode-environment.ts +28 -5
  27. package/src/node/local-vsix-file-plugin-deployer-resolver.ts +9 -23
  28. package/src/node/plugin-vscode-deployer-participant.ts +19 -3
  29. package/src/node/plugin-vscode-directory-handler.ts +6 -43
  30. package/src/node/plugin-vscode-file-handler.ts +20 -41
  31. package/src/node/plugin-vscode-utils.ts +101 -0
@@ -2,7 +2,11 @@ import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
2
2
  import URI from '@theia/core/lib/common/uri';
3
3
  export declare class PluginVSCodeEnvironment {
4
4
  protected readonly environments: EnvVariablesServer;
5
- protected _extensionsDirUri: URI | undefined;
6
- getExtensionsDirUri(): Promise<URI>;
5
+ protected _userExtensionsDirUri: URI | undefined;
6
+ protected _deployedPluginsUri: URI | undefined;
7
+ protected _tmpDirUri: URI | undefined;
8
+ getUserExtensionsDirUri(): Promise<URI>;
9
+ getDeploymentDirUri(): Promise<URI>;
10
+ getTempDirUri(prefix?: string): Promise<URI>;
7
11
  }
8
12
  //# sourceMappingURL=plugin-vscode-environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-environment.d.ts","sourceRoot":"","sources":["../../src/common/plugin-vscode-environment.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,qBACa,uBAAuB;IAGhC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAEpD,SAAS,CAAC,iBAAiB,EAAE,GAAG,GAAG,SAAS,CAAC;IACvC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;CAQ5C"}
1
+ {"version":3,"file":"plugin-vscode-environment.d.ts","sourceRoot":"","sources":["../../src/common/plugin-vscode-environment.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,qBACa,uBAAuB;IAGhC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAEpD,SAAS,CAAC,qBAAqB,EAAE,GAAG,GAAG,SAAS,CAAC;IACjD,SAAS,CAAC,mBAAmB,EAAE,GAAG,GAAG,SAAS,CAAC;IAC/C,SAAS,CAAC,UAAU,EAAE,GAAG,GAAG,SAAS,CAAC;IAEhC,uBAAuB,IAAI,OAAO,CAAC,GAAG,CAAC;IAQvC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;IAQnC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAYrD"}
@@ -29,12 +29,29 @@ const inversify_1 = require("@theia/core/shared/inversify");
29
29
  const env_variables_1 = require("@theia/core/lib/common/env-variables");
30
30
  const uri_1 = require("@theia/core/lib/common/uri");
31
31
  let PluginVSCodeEnvironment = class PluginVSCodeEnvironment {
32
- async getExtensionsDirUri() {
33
- if (!this._extensionsDirUri) {
32
+ async getUserExtensionsDirUri() {
33
+ if (!this._userExtensionsDirUri) {
34
34
  const configDir = new uri_1.default(await this.environments.getConfigDirUri());
35
- this._extensionsDirUri = configDir.resolve('extensions');
35
+ this._userExtensionsDirUri = configDir.resolve('extensions');
36
36
  }
37
- return this._extensionsDirUri;
37
+ return this._userExtensionsDirUri;
38
+ }
39
+ async getDeploymentDirUri() {
40
+ if (!this._deployedPluginsUri) {
41
+ const configDir = new uri_1.default(await this.environments.getConfigDirUri());
42
+ this._deployedPluginsUri = configDir.resolve('deployedPlugins');
43
+ }
44
+ return this._deployedPluginsUri;
45
+ }
46
+ async getTempDirUri(prefix) {
47
+ if (!this._tmpDirUri) {
48
+ const configDir = new uri_1.default(await this.environments.getConfigDirUri());
49
+ this._tmpDirUri = configDir.resolve('tmp');
50
+ }
51
+ if (prefix) {
52
+ return this._tmpDirUri.resolve(prefix);
53
+ }
54
+ return this._tmpDirUri;
38
55
  }
39
56
  };
40
57
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-environment.js","sourceRoot":"","sources":["../../src/common/plugin-vscode-environment.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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,wEAA0E;AAC1E,oDAA6C;AAG7C,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAMhC,KAAK,CAAC,mBAAmB;QACrB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,MAAM,SAAS,GAAG,IAAI,aAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;SAC5D;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CAEJ,CAAA;AAXG;IADC,IAAA,kBAAM,EAAC,kCAAkB,CAAC;;6DACyB;AAH3C,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAcnC;AAdY,0DAAuB"}
1
+ {"version":3,"file":"plugin-vscode-environment.js","sourceRoot":"","sources":["../../src/common/plugin-vscode-environment.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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,wEAA0E;AAC1E,oDAA6C;AAG7C,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAShC,KAAK,CAAC,uBAAuB;QACzB,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE;YAC7B,MAAM,SAAS,GAAG,IAAI,aAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;SAChE;QACD,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,mBAAmB;QACrB,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC3B,MAAM,SAAS,GAAG,IAAI,aAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SACnE;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAe;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,MAAM,SAAS,GAAQ,IAAI,aAAG,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;YAC1E,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC9C;QAED,IAAI,MAAM,EAAE;YACR,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC1C;QAED,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ,CAAA;AAlCG;IADC,IAAA,kBAAM,EAAC,kCAAkB,CAAC;;6DACyB;AAH3C,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAqCnC;AArCY,0DAAuB"}
@@ -1,3 +1,3 @@
1
- export declare const VSCODE_DEFAULT_API_VERSION = "1.82.0";
1
+ export declare const VSCODE_DEFAULT_API_VERSION = "1.84.2";
2
2
  export declare const VSX_REGISTRY_URL_DEFAULT = "https://open-vsx.org";
3
3
  //# sourceMappingURL=plugin-vscode-types.d.ts.map
@@ -3,13 +3,10 @@ import { LocalPluginDeployerResolver } from '@theia/plugin-ext/lib/main/node/res
3
3
  import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
4
4
  export declare class LocalVSIXFilePluginDeployerResolver extends LocalPluginDeployerResolver {
5
5
  static LOCAL_FILE: string;
6
+ static FILE_EXTENSION: string;
6
7
  protected readonly environment: PluginVSCodeEnvironment;
7
8
  protected get supportedScheme(): string;
8
9
  accept(pluginId: string): boolean;
9
10
  resolveFromLocalPath(pluginResolverContext: PluginDeployerResolverContext, localPath: string): Promise<void>;
10
- /**
11
- * Ensures that a user-installed plugin file is transferred to the user extension folder.
12
- */
13
- protected ensureDiscoverability(localPath: string): Promise<string>;
14
11
  }
15
12
  //# sourceMappingURL=local-vsix-file-plugin-deployer-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-vsix-file-plugin-deployer-resolver.d.ts","sourceRoot":"","sources":["../../src/node/local-vsix-file-plugin-deployer-resolver.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0EAA0E,CAAC;AACvH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,qBACa,mCAAoC,SAAQ,2BAA2B;IAChF,MAAM,CAAC,UAAU,SAAgB;IAEA,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAEzF,SAAS,KAAK,eAAe,IAAI,MAAM,CAEtC;IAEQ,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpC,oBAAoB,CAAC,qBAAqB,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlH;;OAEG;cACa,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAgB5E"}
1
+ {"version":3,"file":"local-vsix-file-plugin-deployer-resolver.d.ts","sourceRoot":"","sources":["../../src/node/local-vsix-file-plugin-deployer-resolver.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0EAA0E,CAAC;AACvH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAI9E,qBACa,mCAAoC,SAAQ,2BAA2B;IAChF,MAAM,CAAC,UAAU,SAAgB;IACjC,MAAM,CAAC,cAAc,SAAW;IAEC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAEzF,SAAS,KAAK,eAAe,IAAI,MAAM,CAEtC;IAEQ,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpC,oBAAoB,CAAC,qBAAqB,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWrH"}
@@ -26,13 +26,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
26
26
  var LocalVSIXFilePluginDeployerResolver_1;
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  exports.LocalVSIXFilePluginDeployerResolver = void 0;
29
- const fs = require("@theia/core/shared/fs-extra");
30
29
  const path = require("path");
31
30
  const inversify_1 = require("@theia/core/shared/inversify");
32
- const node_1 = require("@theia/core/lib/node");
33
31
  const local_plugin_deployer_resolver_1 = require("@theia/plugin-ext/lib/main/node/resolvers/local-plugin-deployer-resolver");
34
32
  const plugin_vscode_environment_1 = require("../common/plugin-vscode-environment");
35
33
  const plugin_vscode_file_handler_1 = require("./plugin-vscode-file-handler");
34
+ const plugin_vscode_utils_1 = require("./plugin-vscode-utils");
36
35
  let LocalVSIXFilePluginDeployerResolver = LocalVSIXFilePluginDeployerResolver_1 = class LocalVSIXFilePluginDeployerResolver extends local_plugin_deployer_resolver_1.LocalPluginDeployerResolver {
37
36
  get supportedScheme() {
38
37
  return LocalVSIXFilePluginDeployerResolver_1.LOCAL_FILE;
@@ -41,32 +40,17 @@ let LocalVSIXFilePluginDeployerResolver = LocalVSIXFilePluginDeployerResolver_1
41
40
  return super.accept(pluginId) && (0, plugin_vscode_file_handler_1.isVSCodePluginFile)(pluginId);
42
41
  }
43
42
  async resolveFromLocalPath(pluginResolverContext, localPath) {
44
- const fileName = path.basename(localPath);
45
- const pathInUserExtensionsDirectory = await this.ensureDiscoverability(localPath);
46
- pluginResolverContext.addPlugin(fileName, pathInUserExtensionsDirectory);
47
- }
48
- /**
49
- * Ensures that a user-installed plugin file is transferred to the user extension folder.
50
- */
51
- async ensureDiscoverability(localPath) {
52
- const userExtensionsDir = await this.environment.getExtensionsDirUri();
53
- if (!userExtensionsDir.isEqualOrParent(node_1.FileUri.create(localPath))) {
54
- try {
55
- const newPath = node_1.FileUri.fsPath(userExtensionsDir.resolve(path.basename(localPath)));
56
- await fs.mkdirp(node_1.FileUri.fsPath(userExtensionsDir));
57
- await new Promise((resolve, reject) => {
58
- fs.copyFile(localPath, newPath, error => error ? reject(error) : resolve());
59
- });
60
- return newPath;
61
- }
62
- catch (e) {
63
- console.warn(`Problem copying plugin at ${localPath}:`, e);
64
- }
43
+ const extensionId = path.basename(localPath, LocalVSIXFilePluginDeployerResolver_1.FILE_EXTENSION);
44
+ if (await (0, plugin_vscode_utils_1.existsInDeploymentDir)(this.environment, extensionId)) {
45
+ console.log(`[${pluginResolverContext.getOriginId()}]: Target dir already exists in plugin deployment dir`);
46
+ return;
65
47
  }
66
- return localPath;
48
+ const extensionDeploymentDir = await (0, plugin_vscode_utils_1.unpackToDeploymentDir)(this.environment, localPath, extensionId);
49
+ pluginResolverContext.addPlugin(extensionId, extensionDeploymentDir);
67
50
  }
68
51
  };
69
52
  LocalVSIXFilePluginDeployerResolver.LOCAL_FILE = 'local-file';
53
+ LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION = '.vsix';
70
54
  __decorate([
71
55
  (0, inversify_1.inject)(plugin_vscode_environment_1.PluginVSCodeEnvironment),
72
56
  __metadata("design:type", plugin_vscode_environment_1.PluginVSCodeEnvironment)
@@ -1 +1 @@
1
- {"version":3,"file":"local-vsix-file-plugin-deployer-resolver.js","sourceRoot":"","sources":["../../src/node/local-vsix-file-plugin-deployer-resolver.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,kDAAkD;AAClD,6BAA6B;AAC7B,4DAAkE;AAClE,+CAA+C;AAE/C,6HAAuH;AACvH,mFAA8E;AAC9E,6EAAkE;AAGlE,IAAa,mCAAmC,2CAAhD,MAAa,mCAAoC,SAAQ,4DAA2B;IAKhF,IAAc,eAAe;QACzB,OAAO,qCAAmC,CAAC,UAAU,CAAC;IAC1D,CAAC;IAEQ,MAAM,CAAC,QAAgB;QAC5B,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAA,+CAAkB,EAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,qBAAoD,EAAE,SAAiB;QAC9F,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,6BAA6B,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAClF,qBAAqB,CAAC,SAAS,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,qBAAqB,CAAC,SAAiB;QACnD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACvE,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,cAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;YAC/D,IAAI;gBACA,MAAM,OAAO,GAAG,cAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACpF,MAAM,EAAE,CAAC,MAAM,CAAC,cAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBACnD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBACxC,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBAChF,CAAC,CAAC,CAAC;gBACH,OAAO,OAAO,CAAC;aAClB;YAAC,OAAO,CAAC,EAAE;gBACR,OAAO,CAAC,IAAI,CAAC,6BAA6B,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC;aAC9D;SACJ;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AArCU,8CAAU,GAAG,YAAY,CAAC;AAEA;IAAhC,IAAA,kBAAM,EAAC,mDAAuB,CAAC;8BAAiC,mDAAuB;wEAAC;AAHhF,mCAAmC;IAD/C,IAAA,sBAAU,GAAE;GACA,mCAAmC,CAsC/C;AAtCY,kFAAmC"}
1
+ {"version":3,"file":"local-vsix-file-plugin-deployer-resolver.js","sourceRoot":"","sources":["../../src/node/local-vsix-file-plugin-deployer-resolver.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;AAC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participant.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAErH,qBACa,+BAAgC,YAAW,yBAAyB;IAG7E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAEnD,WAAW,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAKxE"}
1
+ {"version":3,"file":"plugin-vscode-deployer-participant.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-deployer-participant.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAGrH,qBACa,+BAAgC,YAAW,yBAAyB;IAG7E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAEnD,WAAW,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBxE"}
@@ -26,11 +26,26 @@ var __metadata = (this && this.__metadata) || function (k, v) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.PluginVSCodeDeployerParticipant = void 0;
28
28
  const inversify_1 = require("@theia/core/shared/inversify");
29
+ const fs = require("@theia/core/shared/fs-extra");
30
+ const node_1 = require("@theia/core/lib/node");
29
31
  const plugin_vscode_environment_1 = require("../common/plugin-vscode-environment");
32
+ const local_vsix_file_plugin_deployer_resolver_1 = require("./local-vsix-file-plugin-deployer-resolver");
30
33
  let PluginVSCodeDeployerParticipant = class PluginVSCodeDeployerParticipant {
31
34
  async onWillStart(context) {
32
- const extensionsDirUri = await this.environments.getExtensionsDirUri();
33
- context.userEntries.push(extensionsDirUri.withScheme('local-dir').toString());
35
+ const extensionDeploymentDirUri = await this.environments.getDeploymentDirUri();
36
+ context.userEntries.push(extensionDeploymentDirUri.withScheme('local-dir').toString());
37
+ const userExtensionDirUri = await this.environments.getUserExtensionsDirUri();
38
+ const userExtensionDirPath = node_1.FileUri.fsPath(userExtensionDirUri);
39
+ if (await fs.pathExists(userExtensionDirPath)) {
40
+ const files = await fs.readdir(userExtensionDirPath);
41
+ for (const file of files) {
42
+ if (file.endsWith(local_vsix_file_plugin_deployer_resolver_1.LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION)) {
43
+ const extensionUri = userExtensionDirUri.resolve(file).withScheme('local-file').toString();
44
+ console.log(`found drop-in extension "${extensionUri}"`);
45
+ context.userEntries.push(extensionUri);
46
+ }
47
+ }
48
+ }
34
49
  }
35
50
  };
36
51
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-deployer-participant.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-deployer-participant.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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,mFAA8E;AAI9E,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAKxC,KAAK,CAAC,WAAW,CAAC,OAAmC;QACjD,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;QACvE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClF,CAAC;CAEJ,CAAA;AAPG;IADC,IAAA,kBAAM,EAAC,mDAAuB,CAAC;8BACC,mDAAuB;qEAAC;AAHhD,+BAA+B;IAD3C,IAAA,sBAAU,GAAE;GACA,+BAA+B,CAU3C;AAVY,0EAA+B"}
1
+ {"version":3,"file":"plugin-vscode-deployer-participant.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-deployer-participant.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,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,kDAAkD;AAClD,+CAA+C;AAC/C,mFAA8E;AAE9E,yGAAiG;AAGjG,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAKxC,KAAK,CAAC,WAAW,CAAC,OAAmC;QACjD,MAAM,yBAAyB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;QAChF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEvF,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC9E,MAAM,oBAAoB,GAAG,cAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAEjE,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YAC3C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;YACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACtB,IAAI,IAAI,CAAC,QAAQ,CAAC,8EAAmC,CAAC,cAAc,CAAC,EAAE;oBACnE,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;oBAC3F,OAAO,CAAC,GAAG,CAAC,4BAA4B,YAAY,GAAG,CAAC,CAAC;oBACzD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC1C;aACJ;SACJ;IACL,CAAC;CACJ,CAAA;AApBG;IADC,IAAA,kBAAM,EAAC,mDAAuB,CAAC;8BACC,mDAAuB;qEAAC;AAHhD,+BAA+B;IAD3C,IAAA,sBAAU,GAAE;GACA,+BAA+B,CAuB3C;AAvBY,0EAA+B"}
@@ -5,12 +5,10 @@ import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cl
5
5
  export declare class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
6
6
  protected readonly deploymentDirectory: Deferred<URI>;
7
7
  protected readonly pluginCli: PluginCliContribution;
8
- constructor();
9
8
  accept(plugin: PluginDeployerEntry): Promise<boolean>;
10
9
  protected attemptResolution(plugin: PluginDeployerEntry): Promise<boolean>;
11
10
  protected deriveMetadata(plugin: PluginDeployerEntry): Promise<boolean>;
12
11
  handle(context: PluginDeployerDirectoryHandlerContext): Promise<void>;
13
- protected copyDirectory(context: PluginDeployerDirectoryHandlerContext): Promise<void>;
14
12
  protected resolveFromSources(plugin: PluginDeployerEntry): Promise<boolean>;
15
13
  protected resolveFromVSIX(plugin: PluginDeployerEntry): Promise<boolean>;
16
14
  protected resolveFromNpmTarball(plugin: PluginDeployerEntry): Promise<boolean>;
@@ -19,6 +17,5 @@ export declare class PluginVsCodeDirectoryHandler implements PluginDeployerDirec
19
17
  pck?: RecursivePartial<PluginPackage>;
20
18
  }): boolean;
21
19
  protected requirePackage(pluginPath: string): Promise<PluginPackage | undefined>;
22
- protected getExtensionDir(context: PluginDeployerDirectoryHandlerContext): Promise<string>;
23
20
  }
24
21
  //# sourceMappingURL=plugin-vscode-directory-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-directory-handler.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-directory-handler.ts"],"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AAC,EAAE;QAC5D,UAAU,EAAE,MAAM,CAAA;QAClB,GAAG,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAA;KACxC,GAAG,OAAO;cAkBK,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CASzF"}
@@ -26,22 +26,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.PluginVsCodeDirectoryHandler = void 0;
28
28
  const path = require("path");
29
- const filenamify = require("filenamify");
30
29
  const fs = require("@theia/core/shared/fs-extra");
31
30
  const inversify_1 = require("@theia/core/shared/inversify");
32
31
  const promise_util_1 = require("@theia/core/lib/common/promise-util");
33
- const temp_dir_util_1 = require("@theia/plugin-ext/lib/main/node/temp-dir-util");
34
32
  const plugin_ext_1 = require("@theia/plugin-ext");
35
- const node_1 = require("@theia/core/lib/node");
36
33
  const plugin_cli_contribution_1 = require("@theia/plugin-ext/lib/main/node/plugin-cli-contribution");
34
+ const plugin_vscode_utils_1 = require("./plugin-vscode-utils");
37
35
  let PluginVsCodeDirectoryHandler = class PluginVsCodeDirectoryHandler {
38
- constructor() {
39
- this.deploymentDirectory = new promise_util_1.Deferred();
40
- (0, temp_dir_util_1.getTempDirPathAsync)('vscode-copied')
41
- .then(deploymentDirectoryPath => this.deploymentDirectory.resolve(node_1.FileUri.create(deploymentDirectoryPath)));
42
- }
43
36
  async accept(plugin) {
44
37
  console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
38
+ if (plugin.path().startsWith(plugin_vscode_utils_1.TMP_DIR_PREFIX)) {
39
+ // avoid adding corrupted plugins from temporary directories
40
+ return false;
41
+ }
45
42
  return this.attemptResolution(plugin);
46
43
  }
47
44
  async attemptResolution(plugin) {
@@ -54,7 +51,6 @@ let PluginVsCodeDirectoryHandler = class PluginVsCodeDirectoryHandler {
54
51
  return (0, promise_util_1.firstTrue)(this.resolveFromSources(plugin), this.resolveFromVSIX(plugin), this.resolveFromNpmTarball(plugin));
55
52
  }
56
53
  async handle(context) {
57
- await this.copyDirectory(context);
58
54
  const types = [];
59
55
  const packageJson = context.pluginEntry().getValue('package.json');
60
56
  if (packageJson.browser) {
@@ -65,34 +61,6 @@ let PluginVsCodeDirectoryHandler = class PluginVsCodeDirectoryHandler {
65
61
  }
66
62
  context.pluginEntry().accept(...types);
67
63
  }
68
- async copyDirectory(context) {
69
- if (this.pluginCli.copyUncompressedPlugins() && context.pluginEntry().type === plugin_ext_1.PluginType.User) {
70
- const entry = context.pluginEntry();
71
- const id = entry.id();
72
- const pathToRestore = entry.path();
73
- const origin = entry.originalPath();
74
- const targetDir = await this.getExtensionDir(context);
75
- try {
76
- if (await fs.pathExists(targetDir) || !entry.path().startsWith(origin)) {
77
- console.log(`[${id}]: already copied.`);
78
- }
79
- else {
80
- console.log(`[${id}]: copying to "${targetDir}"`);
81
- const deploymentDirectory = await this.deploymentDirectory.promise;
82
- await fs.mkdirp(node_1.FileUri.fsPath(deploymentDirectory));
83
- await context.copy(origin, targetDir);
84
- entry.updatePath(targetDir);
85
- if (!this.deriveMetadata(entry)) {
86
- throw new Error('Unable to resolve plugin metadata after copying');
87
- }
88
- }
89
- }
90
- catch (e) {
91
- console.warn(`[${id}]: Error when copying.`, e);
92
- entry.updatePath(pathToRestore);
93
- }
94
- }
95
- }
96
64
  async resolveFromSources(plugin) {
97
65
  const pluginPath = plugin.path();
98
66
  const pck = await this.requirePackage(pluginPath);
@@ -140,18 +108,13 @@ let PluginVsCodeDirectoryHandler = class PluginVsCodeDirectoryHandler {
140
108
  return undefined;
141
109
  }
142
110
  }
143
- async getExtensionDir(context) {
144
- const deploymentDirectory = await this.deploymentDirectory.promise;
145
- return node_1.FileUri.fsPath(deploymentDirectory.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
146
- }
147
111
  };
148
112
  __decorate([
149
113
  (0, inversify_1.inject)(plugin_cli_contribution_1.PluginCliContribution),
150
114
  __metadata("design:type", plugin_cli_contribution_1.PluginCliContribution)
151
115
  ], PluginVsCodeDirectoryHandler.prototype, "pluginCli", void 0);
152
116
  PluginVsCodeDirectoryHandler = __decorate([
153
- (0, inversify_1.injectable)(),
154
- __metadata("design:paramtypes", [])
117
+ (0, inversify_1.injectable)()
155
118
  ], PluginVsCodeDirectoryHandler);
156
119
  exports.PluginVsCodeDirectoryHandler = PluginVsCodeDirectoryHandler;
157
120
  //# sourceMappingURL=plugin-vscode-directory-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-directory-handler.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-directory-handler.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,6BAA6B;AAC7B,yCAAyC;AACzC,kDAAkD;AAClD,4DAAkE;AAElE,sEAA0E;AAC1E,iFAAoF;AACpF,kDAG2B;AAC3B,+CAA+C;AAC/C,qGAAgG;AAGhG,IAAa,4BAA4B,GAAzC,MAAa,4BAA4B;IAMrC;QACI,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAQ,EAAE,CAAC;QAC1C,IAAA,mCAAmB,EAAC,eAAe,CAAC;aAC/B,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,cAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACpH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAA2B;QACpC,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,EAAE,EAAE,6BAA6B,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC,iBAAiB,CAA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AqB,CAAC;8BAA+B,+CAAqB;+DAAC;AAJ1E,4BAA4B;IADxC,IAAA,sBAAU,GAAE;;GACA,4BAA4B,CAgIxC;AAhIY,oEAA4B"}
1
+ {"version":3,"file":"plugin-vscode-directory-handler.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-directory-handler.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,6BAA6B;AAC7B,kDAAkD;AAClD,4DAAkE;AAElE,sEAA0E;AAC1E,kDAG2B;AAC3B,qGAAgG;AAChG,+DAAuD;AAGvD,IAAa,4BAA4B,GAAzC,MAAa,4BAA4B;IAMrC,KAAK,CAAC,MAAM,CAAC,MAA2B;QACpC,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,EAAE,EAAE,6BAA6B,CAAC,CAAC;QACtE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,oCAAc,CAAC,EAAE;YAC1C,4DAA4D;YAC5D,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,MAA2B;QACzD,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAA2B;QACtD,OAAO,IAAA,wBAAS,EACZ,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAC/B,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,E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O,IAAI,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,UAAkB;;QAC7C,IAAI;YACA,MAAM,MAAM,GAAkB,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;YACvF,MAAA,MAAM,CAAC,SAAS,oCAAhB,MAAM,CAAC,SAAS,GAAK,8BAAiB,CAAC,WAAW,EAAC;YACnD,OAAO,MAAM,CAAC;SACjB;QAAC,MAAM;YACJ,OAAO,SAAS,CAAC;SACpB;IACL,CAAC;CACJ,CAAA;AAzFkC;IAA9B,IAAA,kBAAM,EAAC,+CAAqB,CAAC;8BAA+B,+CAAqB;+DAAC;AAJ1E,4BAA4B;IADxC,IAAA,sBAAU,GAAE;GACA,4BAA4B,CA6FxC;AA7FY,oEAA4B"}
@@ -3,11 +3,8 @@ import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
3
3
  export declare const isVSCodePluginFile: (pluginPath?: string | undefined) => boolean;
4
4
  export declare class PluginVsCodeFileHandler implements PluginDeployerFileHandler {
5
5
  protected readonly environment: PluginVSCodeEnvironment;
6
- private readonly systemExtensionsDirUri;
7
- constructor();
8
6
  accept(resolvedPlugin: PluginDeployerEntry): Promise<boolean>;
9
7
  handle(context: PluginDeployerFileHandlerContext): Promise<void>;
10
- protected getExtensionDir(context: PluginDeployerFileHandlerContext): Promise<string>;
11
- protected decompress(extensionDir: string, context: PluginDeployerFileHandlerContext): Promise<void>;
8
+ protected getNormalizedExtensionId(pluginId: string): string;
12
9
  }
13
10
  //# sourceMappingURL=plugin-vscode-file-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-file-handler.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-file-handler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,gCAAgC,EAAc,MAAM,mBAAmB,CAAC;AAQjI,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,eAAO,MAAM,kBAAkB,8CAAgH,CAAC;AAEhJ,qBACa,uBAAwB,YAAW,yBAAyB;IAGrE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAExD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAgB;;IAQjD,MAAM,CAAC,cAAc,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7D,MAAM,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;cActD,eAAe,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,MAAM,CAAC;cAK3E,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;CAW7G"}
1
+ {"version":3,"file":"plugin-vscode-file-handler.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-file-handler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAKrH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,eAAO,MAAM,kBAAkB,8CAAgH,CAAC;AAEhJ,qBACa,uBAAwB,YAAW,yBAAyB;IAErE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAElD,MAAM,CAAC,cAAc,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7D,MAAM,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBtE,SAAS,CAAC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAG/D"}
@@ -25,23 +25,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.PluginVsCodeFileHandler = exports.isVSCodePluginFile = void 0;
28
- const plugin_ext_1 = require("@theia/plugin-ext");
29
- const fs = require("@theia/core/shared/fs-extra");
30
- const path = require("path");
31
28
  const filenamify = require("filenamify");
32
29
  const inversify_1 = require("@theia/core/shared/inversify");
33
- const promise_util_1 = require("@theia/core/lib/common/promise-util");
34
- const temp_dir_util_1 = require("@theia/plugin-ext/lib/main/node/temp-dir-util");
30
+ const fs = require("@theia/core/shared/fs-extra");
31
+ const node_1 = require("@theia/core/lib/node");
35
32
  const plugin_vscode_environment_1 = require("../common/plugin-vscode-environment");
36
- const file_uri_1 = require("@theia/core/lib/node/file-uri");
33
+ const plugin_vscode_utils_1 = require("./plugin-vscode-utils");
37
34
  const isVSCodePluginFile = (pluginPath) => Boolean(pluginPath && (pluginPath.endsWith('.vsix') || pluginPath.endsWith('.tgz')));
38
35
  exports.isVSCodePluginFile = isVSCodePluginFile;
39
36
  let PluginVsCodeFileHandler = class PluginVsCodeFileHandler {
40
- constructor() {
41
- this.systemExtensionsDirUri = new promise_util_1.Deferred();
42
- (0, temp_dir_util_1.getTempDirPathAsync)('vscode-unpacked')
43
- .then(systemExtensionsDirPath => this.systemExtensionsDirUri.resolve(file_uri_1.FileUri.create(systemExtensionsDirPath)));
44
- }
45
37
  async accept(resolvedPlugin) {
46
38
  return resolvedPlugin.isFile().then(file => {
47
39
  if (!file) {
@@ -51,40 +43,33 @@ let PluginVsCodeFileHandler = class PluginVsCodeFileHandler {
51
43
  });
52
44
  }
53
45
  async handle(context) {
54
- const id = context.pluginEntry().id();
55
- const extensionDir = await this.getExtensionDir(context);
56
- console.log(`[${id}]: trying to decompress into "${extensionDir}"...`);
57
- if (context.pluginEntry().type === plugin_ext_1.PluginType.User && await fs.pathExists(extensionDir)) {
58
- console.log(`[${id}]: already found`);
59
- context.pluginEntry().updatePath(extensionDir);
60
- return;
61
- }
62
- await this.decompress(extensionDir, context);
63
- console.log(`[${id}]: decompressed`);
64
- context.pluginEntry().updatePath(extensionDir);
65
- }
66
- async getExtensionDir(context) {
67
- const systemExtensionsDirUri = await this.systemExtensionsDirUri.promise;
68
- return file_uri_1.FileUri.fsPath(systemExtensionsDirUri.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
69
- }
70
- async decompress(extensionDir, context) {
71
- await context.unzip(context.pluginEntry().path(), extensionDir);
72
- if (context.pluginEntry().path().endsWith('.tgz')) {
73
- const extensionPath = path.join(extensionDir, 'package');
74
- const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
75
- if (await fs.pathExists(vscodeNodeModulesPath)) {
76
- await context.unzip(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
46
+ const id = this.getNormalizedExtensionId(context.pluginEntry().id());
47
+ const extensionDeploymentDir = await (0, plugin_vscode_utils_1.unpackToDeploymentDir)(this.environment, context.pluginEntry().path(), id);
48
+ context.pluginEntry().updatePath(extensionDeploymentDir);
49
+ console.log(`root path: ${context.pluginEntry().rootPath}`);
50
+ const originalPath = context.pluginEntry().originalPath();
51
+ if (originalPath && originalPath !== extensionDeploymentDir) {
52
+ const tempDirUri = await this.environment.getTempDirUri();
53
+ if (originalPath.startsWith(node_1.FileUri.fsPath(tempDirUri))) {
54
+ try {
55
+ await fs.remove(node_1.FileUri.fsPath(originalPath));
56
+ }
57
+ catch (e) {
58
+ console.error(`[${id}]: failed to remove temporary files: "${originalPath}"`, e);
59
+ }
77
60
  }
78
61
  }
79
62
  }
63
+ getNormalizedExtensionId(pluginId) {
64
+ return filenamify(pluginId, { replacement: '_' }).replace(/\.vsix$/, '');
65
+ }
80
66
  };
81
67
  __decorate([
82
68
  (0, inversify_1.inject)(plugin_vscode_environment_1.PluginVSCodeEnvironment),
83
69
  __metadata("design:type", plugin_vscode_environment_1.PluginVSCodeEnvironment)
84
70
  ], PluginVsCodeFileHandler.prototype, "environment", void 0);
85
71
  PluginVsCodeFileHandler = __decorate([
86
- (0, inversify_1.injectable)(),
87
- __metadata("design:paramtypes", [])
72
+ (0, inversify_1.injectable)()
88
73
  ], PluginVsCodeFileHandler);
89
74
  exports.PluginVsCodeFileHandler = PluginVsCodeFileHandler;
90
75
  //# sourceMappingURL=plugin-vscode-file-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-file-handler.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-file-handler.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,kDAAiI;AACjI,kDAAkD;AAClD,6BAA6B;AAC7B,yCAAyC;AAEzC,4DAAkE;AAClE,sEAA+D;AAC/D,iFAAoF;AACpF,mFAA8E;AAC9E,4DAAwD;AAEjD,MAAM,kBAAkB,GAAG,CAAC,UAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAAnI,QAAA,kBAAkB,sBAAiH;AAGhJ,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAOhC;QACI,IAAI,CAAC,sBAAsB,GAAG,IAAI,uBAAQ,EAAE,CAAC;QAC7C,IAAA,mCAAmB,EAAC,iBAAiB,CAAC;aACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,kBAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACvH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,cAAmC;QAC5C,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACvC,IAAI,CAA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AAC,CAAC,CAAC;iBACjD;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,yCAAyC,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC;iBACpF;aACJ;SACJ;IACL,CAAC;IAES,wBAAwB,CAAC,QAAgB;QAC/C,OAAO,UAAU,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;CACJ,CAAA;AAhCG;IADC,IAAA,kBAAM,EAAC,mDAAuB,CAAC;8BACA,mDAAuB;4DAAC;AAF/C,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAkCnC;AAlCY,0DAAuB"}
@@ -0,0 +1,8 @@
1
+ import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
2
+ export declare function decompressExtension(sourcePath: string, destPath: string): Promise<boolean>;
3
+ export declare function existsInDeploymentDir(env: PluginVSCodeEnvironment, extensionId: string): Promise<boolean>;
4
+ export declare const TMP_DIR_PREFIX = "tmp-vscode-unpacked-";
5
+ export declare function unpackToDeploymentDir(env: PluginVSCodeEnvironment, sourcePath: string, extensionId: string): Promise<string>;
6
+ export declare function getExtensionDeploymentDir(env: PluginVSCodeEnvironment, extensionId: string): Promise<string>;
7
+ export declare function getTempDir(env: PluginVSCodeEnvironment, prefix: string): Promise<string>;
8
+ //# sourceMappingURL=plugin-vscode-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-vscode-utils.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-utils.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBhG;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE/G;AAED,eAAO,MAAM,cAAc,yBAAyB,CAAC;AACrD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiClI;AAED,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKlH;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9F"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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
+ exports.getTempDir = exports.getExtensionDeploymentDir = exports.unpackToDeploymentDir = exports.TMP_DIR_PREFIX = exports.existsInDeploymentDir = exports.decompressExtension = void 0;
19
+ const decompress = require("decompress");
20
+ const path = require("path");
21
+ const filenamify = require("filenamify");
22
+ const node_1 = require("@theia/core/lib/node");
23
+ const fs = require("@theia/core/shared/fs-extra");
24
+ async function decompressExtension(sourcePath, destPath) {
25
+ try {
26
+ await decompress(sourcePath, destPath);
27
+ if (sourcePath.endsWith('.tgz')) {
28
+ // unzip node_modules from built-in extensions, see https://github.com/eclipse-theia/theia/issues/5756
29
+ const extensionPath = path.join(destPath, 'package');
30
+ const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
31
+ if (await fs.pathExists(vscodeNodeModulesPath)) {
32
+ await decompress(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+ catch (error) {
38
+ console.error(`Failed to decompress ${sourcePath} to ${destPath}: ${error}`);
39
+ throw error;
40
+ }
41
+ }
42
+ exports.decompressExtension = decompressExtension;
43
+ async function existsInDeploymentDir(env, extensionId) {
44
+ return fs.pathExists(await getExtensionDeploymentDir(env, extensionId));
45
+ }
46
+ exports.existsInDeploymentDir = existsInDeploymentDir;
47
+ exports.TMP_DIR_PREFIX = 'tmp-vscode-unpacked-';
48
+ async function unpackToDeploymentDir(env, sourcePath, extensionId) {
49
+ const extensionDeploymentDir = await getExtensionDeploymentDir(env, extensionId);
50
+ if (await fs.pathExists(extensionDeploymentDir)) {
51
+ console.log(`[${extensionId}]: deployment dir "${extensionDeploymentDir}" already exists`);
52
+ return extensionDeploymentDir;
53
+ }
54
+ const tempDir = await getTempDir(env, exports.TMP_DIR_PREFIX);
55
+ try {
56
+ console.log(`[${extensionId}]: trying to decompress "${sourcePath}" into "${tempDir}"...`);
57
+ if (!await decompressExtension(sourcePath, tempDir)) {
58
+ await fs.remove(tempDir);
59
+ const msg = `[${extensionId}]: decompressing "${sourcePath}" to "${tempDir}" failed`;
60
+ console.error(msg);
61
+ throw new Error(msg);
62
+ }
63
+ }
64
+ catch (e) {
65
+ await fs.remove(tempDir);
66
+ const msg = `[${extensionId}]: error while decompressing "${sourcePath}" to "${tempDir}"`;
67
+ console.error(msg, e);
68
+ throw e;
69
+ }
70
+ console.log(`[${extensionId}]: decompressed to temp dir "${tempDir}"`);
71
+ try {
72
+ console.log(`[${extensionId}]: renaming to extension dir "${extensionDeploymentDir}"...`);
73
+ await fs.rename(tempDir, extensionDeploymentDir);
74
+ return extensionDeploymentDir;
75
+ }
76
+ catch (e) {
77
+ await fs.remove(tempDir);
78
+ console.error(`[${extensionId}]: error while renaming "${tempDir}" to "${extensionDeploymentDir}"`, e);
79
+ throw e;
80
+ }
81
+ }
82
+ exports.unpackToDeploymentDir = unpackToDeploymentDir;
83
+ async function getExtensionDeploymentDir(env, extensionId) {
84
+ const deployedPluginsDirUri = await env.getDeploymentDirUri();
85
+ const normalizedExtensionId = filenamify(extensionId, { replacement: '_' });
86
+ const extensionDeploymentDirPath = node_1.FileUri.fsPath(deployedPluginsDirUri.resolve(normalizedExtensionId));
87
+ return extensionDeploymentDirPath;
88
+ }
89
+ exports.getExtensionDeploymentDir = getExtensionDeploymentDir;
90
+ async function getTempDir(env, prefix) {
91
+ const deploymentDirPath = node_1.FileUri.fsPath(await env.getDeploymentDirUri());
92
+ try {
93
+ if (!await fs.pathExists(deploymentDirPath)) {
94
+ console.log(`Creating deployment dir ${deploymentDirPath}`);
95
+ await fs.mkdirs(deploymentDirPath);
96
+ }
97
+ return await fs.mkdtemp(path.join(deploymentDirPath, prefix));
98
+ }
99
+ catch (error) {
100
+ console.error(`Failed to create deployment dir ${deploymentDirPath}: ${error}`);
101
+ throw error;
102
+ }
103
+ }
104
+ exports.getTempDir = getTempDir;
105
+ //# sourceMappingURL=plugin-vscode-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-vscode-utils.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-utils.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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,yCAAyC;AACzC,6BAA6B;AAC7B,yCA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AM,CAAC,CAAC;KACX;AACL,CAAC;AAjCD,sDAiCC;AAEM,KAAK,UAAU,yBAAyB,CAAC,GAA4B,EAAE,WAAmB;IAC7F,MAAM,qBAAqB,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;IAC9D,MAAM,qBAAqB,GAAG,UAAU,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5E,MAAM,0BAA0B,GAAG,cAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACxG,OAAO,0BAA0B,CAAC;AACtC,CAAC;AALD,8DAKC;AAEM,KAAK,UAAU,UAAU,CAAC,GAA4B,EAAE,MAAc;IACzE,MAAM,iBAAiB,GAAG,cAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1E,IAAI;QACA,IAAI,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;YACzC,OAAO,CAAC,GAAG,CAAC,2BAA2B,iBAAiB,EAAE,CAAC,CAAC;YAC5D,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;SACtC;QACD,OAAO,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;KACjE;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,mCAAmC,iBAAiB,KAAK,KAAK,EAAE,CAAC,CAAC;QAChF,MAAM,KAAK,CAAC;KACf;AACL,CAAC;AAZD,gCAYC"}
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext-vscode",
3
- "version": "1.43.1",
3
+ "version": "1.45.0",
4
4
  "description": "Theia - Plugin Extension for VsCode",
5
5
  "dependencies": {
6
- "@theia/callhierarchy": "1.43.1",
7
- "@theia/core": "1.43.1",
8
- "@theia/editor": "1.43.1",
9
- "@theia/filesystem": "1.43.1",
10
- "@theia/monaco": "1.43.1",
6
+ "@theia/callhierarchy": "1.45.0",
7
+ "@theia/core": "1.45.0",
8
+ "@theia/editor": "1.45.0",
9
+ "@theia/filesystem": "1.45.0",
10
+ "@theia/monaco": "1.45.0",
11
11
  "@theia/monaco-editor-core": "1.72.3",
12
- "@theia/navigator": "1.43.1",
13
- "@theia/plugin": "1.43.1",
14
- "@theia/plugin-ext": "1.43.1",
15
- "@theia/terminal": "1.43.1",
16
- "@theia/typehierarchy": "1.43.1",
17
- "@theia/userstorage": "1.43.1",
18
- "@theia/workspace": "1.43.1",
12
+ "@theia/navigator": "1.45.0",
13
+ "@theia/plugin": "1.45.0",
14
+ "@theia/plugin-ext": "1.45.0",
15
+ "@theia/terminal": "1.45.0",
16
+ "@theia/typehierarchy": "1.45.0",
17
+ "@theia/userstorage": "1.45.0",
18
+ "@theia/workspace": "1.45.0",
19
+ "decompress": "^4.2.1",
19
20
  "filenamify": "^4.1.0"
20
21
  },
21
22
  "publishConfig": {
@@ -52,10 +53,10 @@
52
53
  "watch": "theiaext watch"
53
54
  },
54
55
  "devDependencies": {
55
- "@theia/ext-scripts": "1.43.1"
56
+ "@theia/ext-scripts": "1.45.0"
56
57
  },
57
58
  "nyc": {
58
59
  "extends": "../../configs/nyc.json"
59
60
  },
60
- "gitHead": "df48285b7d3340e0109e89ffdb0f437ba6710378"
61
+ "gitHead": "2b20a60a0f9b54b19838a0f71760989a19622495"
61
62
  }
@@ -24,13 +24,36 @@ export class PluginVSCodeEnvironment {
24
24
  @inject(EnvVariablesServer)
25
25
  protected readonly environments: EnvVariablesServer;
26
26
 
27
- protected _extensionsDirUri: URI | undefined;
28
- async getExtensionsDirUri(): Promise<URI> {
29
- if (!this._extensionsDirUri) {
27
+ protected _userExtensionsDirUri: URI | undefined;
28
+ protected _deployedPluginsUri: URI | undefined;
29
+ protected _tmpDirUri: URI | undefined;
30
+
31
+ async getUserExtensionsDirUri(): Promise<URI> {
32
+ if (!this._userExtensionsDirUri) {
33
+ const configDir = new URI(await this.environments.getConfigDirUri());
34
+ this._userExtensionsDirUri = configDir.resolve('extensions');
35
+ }
36
+ return this._userExtensionsDirUri;
37
+ }
38
+
39
+ async getDeploymentDirUri(): Promise<URI> {
40
+ if (!this._deployedPluginsUri) {
30
41
  const configDir = new URI(await this.environments.getConfigDirUri());
31
- this._extensionsDirUri = configDir.resolve('extensions');
42
+ this._deployedPluginsUri = configDir.resolve('deployedPlugins');
32
43
  }
33
- return this._extensionsDirUri;
44
+ return this._deployedPluginsUri;
34
45
  }
35
46
 
47
+ async getTempDirUri(prefix?: string): Promise<URI> {
48
+ if (!this._tmpDirUri) {
49
+ const configDir: URI = new URI(await this.environments.getConfigDirUri());
50
+ this._tmpDirUri = configDir.resolve('tmp');
51
+ }
52
+
53
+ if (prefix) {
54
+ return this._tmpDirUri.resolve(prefix);
55
+ }
56
+
57
+ return this._tmpDirUri;
58
+ }
36
59
  }
@@ -14,18 +14,18 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import * as fs from '@theia/core/shared/fs-extra';
18
17
  import * as path from 'path';
19
18
  import { inject, injectable } from '@theia/core/shared/inversify';
20
- import { FileUri } from '@theia/core/lib/node';
21
19
  import { PluginDeployerResolverContext } from '@theia/plugin-ext';
22
20
  import { LocalPluginDeployerResolver } from '@theia/plugin-ext/lib/main/node/resolvers/local-plugin-deployer-resolver';
23
21
  import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
24
22
  import { isVSCodePluginFile } from './plugin-vscode-file-handler';
23
+ import { existsInDeploymentDir, unpackToDeploymentDir } from './plugin-vscode-utils';
25
24
 
26
25
  @injectable()
27
26
  export class LocalVSIXFilePluginDeployerResolver extends LocalPluginDeployerResolver {
28
27
  static LOCAL_FILE = 'local-file';
28
+ static FILE_EXTENSION = '.vsix';
29
29
 
30
30
  @inject(PluginVSCodeEnvironment) protected readonly environment: PluginVSCodeEnvironment;
31
31
 
@@ -38,28 +38,14 @@ export class LocalVSIXFilePluginDeployerResolver extends LocalPluginDeployerReso
38
38
  }
39
39
 
40
40
  async resolveFromLocalPath(pluginResolverContext: PluginDeployerResolverContext, localPath: string): Promise<void> {
41
- const fileName = path.basename(localPath);
42
- const pathInUserExtensionsDirectory = await this.ensureDiscoverability(localPath);
43
- pluginResolverContext.addPlugin(fileName, pathInUserExtensionsDirectory);
44
- }
41
+ const extensionId = path.basename(localPath, LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION);
45
42
 
46
- /**
47
- * Ensures that a user-installed plugin file is transferred to the user extension folder.
48
- */
49
- protected async ensureDiscoverability(localPath: string): Promise<string> {
50
- const userExtensionsDir = await this.environment.getExtensionsDirUri();
51
- if (!userExtensionsDir.isEqualOrParent(FileUri.create(localPath))) {
52
- try {
53
- const newPath = FileUri.fsPath(userExtensionsDir.resolve(path.basename(localPath)));
54
- await fs.mkdirp(FileUri.fsPath(userExtensionsDir));
55
- await new Promise<void>((resolve, reject) => {
56
- fs.copyFile(localPath, newPath, error => error ? reject(error) : resolve());
57
- });
58
- return newPath;
59
- } catch (e) {
60
- console.warn(`Problem copying plugin at ${localPath}:`, e);
61
- }
43
+ if (await existsInDeploymentDir(this.environment, extensionId)) {
44
+ console.log(`[${pluginResolverContext.getOriginId()}]: Target dir already exists in plugin deployment dir`);
45
+ return;
62
46
  }
63
- return localPath;
47
+
48
+ const extensionDeploymentDir = await unpackToDeploymentDir(this.environment, localPath, extensionId);
49
+ pluginResolverContext.addPlugin(extensionId, extensionDeploymentDir);
64
50
  }
65
51
  }
@@ -15,8 +15,11 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import * as fs from '@theia/core/shared/fs-extra';
19
+ import { FileUri } from '@theia/core/lib/node';
18
20
  import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
19
21
  import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/plugin-ext/lib/common/plugin-protocol';
22
+ import { LocalVSIXFilePluginDeployerResolver } from './local-vsix-file-plugin-deployer-resolver';
20
23
 
21
24
  @injectable()
22
25
  export class PluginVSCodeDeployerParticipant implements PluginDeployerParticipant {
@@ -25,8 +28,21 @@ export class PluginVSCodeDeployerParticipant implements PluginDeployerParticipan
25
28
  protected readonly environments: PluginVSCodeEnvironment;
26
29
 
27
30
  async onWillStart(context: PluginDeployerStartContext): Promise<void> {
28
- const extensionsDirUri = await this.environments.getExtensionsDirUri();
29
- context.userEntries.push(extensionsDirUri.withScheme('local-dir').toString());
30
- }
31
+ const extensionDeploymentDirUri = await this.environments.getDeploymentDirUri();
32
+ context.userEntries.push(extensionDeploymentDirUri.withScheme('local-dir').toString());
33
+
34
+ const userExtensionDirUri = await this.environments.getUserExtensionsDirUri();
35
+ const userExtensionDirPath = FileUri.fsPath(userExtensionDirUri);
31
36
 
37
+ if (await fs.pathExists(userExtensionDirPath)) {
38
+ const files = await fs.readdir(userExtensionDirPath);
39
+ for (const file of files) {
40
+ if (file.endsWith(LocalVSIXFilePluginDeployerResolver.FILE_EXTENSION)) {
41
+ const extensionUri = userExtensionDirUri.resolve(file).withScheme('local-file').toString();
42
+ console.log(`found drop-in extension "${extensionUri}"`);
43
+ context.userEntries.push(extensionUri);
44
+ }
45
+ }
46
+ }
47
+ }
32
48
  }
@@ -15,18 +15,16 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as path from 'path';
18
- import * as filenamify from 'filenamify';
19
18
  import * as fs from '@theia/core/shared/fs-extra';
20
19
  import { inject, injectable } from '@theia/core/shared/inversify';
21
20
  import type { RecursivePartial, URI } from '@theia/core';
22
21
  import { Deferred, firstTrue } from '@theia/core/lib/common/promise-util';
23
- import { getTempDirPathAsync } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
24
22
  import {
25
23
  PluginDeployerDirectoryHandler, PluginDeployerEntry, PluginDeployerDirectoryHandlerContext,
26
- PluginDeployerEntryType, PluginPackage, PluginType, PluginIdentifiers
24
+ PluginDeployerEntryType, PluginPackage, PluginIdentifiers
27
25
  } from '@theia/plugin-ext';
28
- import { FileUri } from '@theia/core/lib/node';
29
26
  import { PluginCliContribution } from '@theia/plugin-ext/lib/main/node/plugin-cli-contribution';
27
+ import { TMP_DIR_PREFIX } from './plugin-vscode-utils';
30
28
 
31
29
  @injectable()
32
30
  export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {
@@ -35,14 +33,12 @@ export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHand
35
33
 
36
34
  @inject(PluginCliContribution) protected readonly pluginCli: PluginCliContribution;
37
35
 
38
- constructor() {
39
- this.deploymentDirectory = new Deferred();
40
- getTempDirPathAsync('vscode-copied')
41
- .then(deploymentDirectoryPath => this.deploymentDirectory.resolve(FileUri.create(deploymentDirectoryPath)));
42
- }
43
-
44
36
  async accept(plugin: PluginDeployerEntry): Promise<boolean> {
45
37
  console.debug(`Resolving "${plugin.id()}" as a VS Code extension...`);
38
+ if (plugin.path().startsWith(TMP_DIR_PREFIX)) {
39
+ // avoid adding corrupted plugins from temporary directories
40
+ return false;
41
+ }
46
42
  return this.attemptResolution(plugin);
47
43
  }
48
44
 
@@ -62,7 +58,6 @@ export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHand
62
58
  }
63
59
 
64
60
  async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
65
- await this.copyDirectory(context);
66
61
  const types: PluginDeployerEntryType[] = [];
67
62
  const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
68
63
  if (packageJson.browser) {
@@ -74,33 +69,6 @@ export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHand
74
69
  context.pluginEntry().accept(...types);
75
70
  }
76
71
 
77
- protected async copyDirectory(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
78
- if (this.pluginCli.copyUncompressedPlugins() && context.pluginEntry().type === PluginType.User) {
79
- const entry = context.pluginEntry();
80
- const id = entry.id();
81
- const pathToRestore = entry.path();
82
- const origin = entry.originalPath();
83
- const targetDir = await this.getExtensionDir(context);
84
- try {
85
- if (await fs.pathExists(targetDir) || !entry.path().startsWith(origin)) {
86
- console.log(`[${id}]: already copied.`);
87
- } else {
88
- console.log(`[${id}]: copying to "${targetDir}"`);
89
- const deploymentDirectory = await this.deploymentDirectory.promise;
90
- await fs.mkdirp(FileUri.fsPath(deploymentDirectory));
91
- await context.copy(origin, targetDir);
92
- entry.updatePath(targetDir);
93
- if (!this.deriveMetadata(entry)) {
94
- throw new Error('Unable to resolve plugin metadata after copying');
95
- }
96
- }
97
- } catch (e) {
98
- console.warn(`[${id}]: Error when copying.`, e);
99
- entry.updatePath(pathToRestore);
100
- }
101
- }
102
- }
103
-
104
72
  protected async resolveFromSources(plugin: PluginDeployerEntry): Promise<boolean> {
105
73
  const pluginPath = plugin.path();
106
74
  const pck = await this.requirePackage(pluginPath);
@@ -152,9 +120,4 @@ export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHand
152
120
  return undefined;
153
121
  }
154
122
  }
155
-
156
- protected async getExtensionDir(context: PluginDeployerDirectoryHandlerContext): Promise<string> {
157
- const deploymentDirectory = await this.deploymentDirectory.promise;
158
- return FileUri.fsPath(deploymentDirectory.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
159
- }
160
123
  }
@@ -14,33 +14,21 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
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';
17
+ import { PluginDeployerFileHandler, PluginDeployerEntry, PluginDeployerFileHandlerContext } from '@theia/plugin-ext';
20
18
  import * as filenamify from 'filenamify';
21
- import type { URI } from '@theia/core';
22
19
  import { inject, injectable } from '@theia/core/shared/inversify';
23
- import { Deferred } from '@theia/core/lib/common/promise-util';
24
- import { getTempDirPathAsync } from '@theia/plugin-ext/lib/main/node/temp-dir-util';
20
+ import * as fs from '@theia/core/shared/fs-extra';
21
+ import { FileUri } from '@theia/core/lib/node';
25
22
  import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
26
- import { FileUri } from '@theia/core/lib/node/file-uri';
23
+ import { unpackToDeploymentDir } from './plugin-vscode-utils';
27
24
 
28
25
  export const isVSCodePluginFile = (pluginPath?: string) => Boolean(pluginPath && (pluginPath.endsWith('.vsix') || pluginPath.endsWith('.tgz')));
29
26
 
30
27
  @injectable()
31
28
  export class PluginVsCodeFileHandler implements PluginDeployerFileHandler {
32
-
33
29
  @inject(PluginVSCodeEnvironment)
34
30
  protected readonly environment: PluginVSCodeEnvironment;
35
31
 
36
- private readonly systemExtensionsDirUri: Deferred<URI>;
37
-
38
- constructor() {
39
- this.systemExtensionsDirUri = new Deferred();
40
- getTempDirPathAsync('vscode-unpacked')
41
- .then(systemExtensionsDirPath => this.systemExtensionsDirUri.resolve(FileUri.create(systemExtensionsDirPath)));
42
- }
43
-
44
32
  async accept(resolvedPlugin: PluginDeployerEntry): Promise<boolean> {
45
33
  return resolvedPlugin.isFile().then(file => {
46
34
  if (!file) {
@@ -51,33 +39,24 @@ export class PluginVsCodeFileHandler implements PluginDeployerFileHandler {
51
39
  }
52
40
 
53
41
  async handle(context: PluginDeployerFileHandlerContext): Promise<void> {
54
- const id = context.pluginEntry().id();
55
- const extensionDir = await this.getExtensionDir(context);
56
- console.log(`[${id}]: trying to decompress into "${extensionDir}"...`);
57
- if (context.pluginEntry().type === PluginType.User && await fs.pathExists(extensionDir)) {
58
- console.log(`[${id}]: already found`);
59
- context.pluginEntry().updatePath(extensionDir);
60
- return;
61
- }
62
- await this.decompress(extensionDir, context);
63
- console.log(`[${id}]: decompressed`);
64
- context.pluginEntry().updatePath(extensionDir);
65
- }
66
-
67
- protected async getExtensionDir(context: PluginDeployerFileHandlerContext): Promise<string> {
68
- const systemExtensionsDirUri = await this.systemExtensionsDirUri.promise;
69
- return FileUri.fsPath(systemExtensionsDirUri.resolve(filenamify(context.pluginEntry().id(), { replacement: '_' })));
70
- }
71
-
72
- protected async decompress(extensionDir: string, context: PluginDeployerFileHandlerContext): Promise<void> {
73
- await context.unzip(context.pluginEntry().path(), extensionDir);
74
- if (context.pluginEntry().path().endsWith('.tgz')) {
75
- const extensionPath = path.join(extensionDir, 'package');
76
- const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
77
- if (await fs.pathExists(vscodeNodeModulesPath)) {
78
- await context.unzip(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
42
+ const id = this.getNormalizedExtensionId(context.pluginEntry().id());
43
+ const extensionDeploymentDir = await unpackToDeploymentDir(this.environment, context.pluginEntry().path(), id);
44
+ context.pluginEntry().updatePath(extensionDeploymentDir);
45
+ console.log(`root path: ${context.pluginEntry().rootPath}`);
46
+ const originalPath = context.pluginEntry().originalPath();
47
+ if (originalPath && originalPath !== extensionDeploymentDir) {
48
+ const tempDirUri = await this.environment.getTempDirUri();
49
+ if (originalPath.startsWith(FileUri.fsPath(tempDirUri))) {
50
+ try {
51
+ await fs.remove(FileUri.fsPath(originalPath));
52
+ } catch (e) {
53
+ console.error(`[${id}]: failed to remove temporary files: "${originalPath}"`, e);
54
+ }
79
55
  }
80
56
  }
81
57
  }
82
58
 
59
+ protected getNormalizedExtensionId(pluginId: string): string {
60
+ return filenamify(pluginId, { replacement: '_' }).replace(/\.vsix$/, '');
61
+ }
83
62
  }
@@ -0,0 +1,101 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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
+ import * as decompress from 'decompress';
18
+ import * as path from 'path';
19
+ import * as filenamify from 'filenamify';
20
+ import { FileUri } from '@theia/core/lib/node';
21
+ import * as fs from '@theia/core/shared/fs-extra';
22
+ import { PluginVSCodeEnvironment } from '../common/plugin-vscode-environment';
23
+
24
+ export async function decompressExtension(sourcePath: string, destPath: string): Promise<boolean> {
25
+ try {
26
+ await decompress(sourcePath, destPath);
27
+ if (sourcePath.endsWith('.tgz')) {
28
+ // unzip node_modules from built-in extensions, see https://github.com/eclipse-theia/theia/issues/5756
29
+ const extensionPath = path.join(destPath, 'package');
30
+ const vscodeNodeModulesPath = path.join(extensionPath, 'vscode_node_modules.zip');
31
+ if (await fs.pathExists(vscodeNodeModulesPath)) {
32
+ await decompress(vscodeNodeModulesPath, path.join(extensionPath, 'node_modules'));
33
+ }
34
+ }
35
+ return true;
36
+ } catch (error) {
37
+ console.error(`Failed to decompress ${sourcePath} to ${destPath}: ${error}`);
38
+ throw error;
39
+ }
40
+ }
41
+
42
+ export async function existsInDeploymentDir(env: PluginVSCodeEnvironment, extensionId: string): Promise<boolean> {
43
+ return fs.pathExists(await getExtensionDeploymentDir(env, extensionId));
44
+ }
45
+
46
+ export const TMP_DIR_PREFIX = 'tmp-vscode-unpacked-';
47
+ export async function unpackToDeploymentDir(env: PluginVSCodeEnvironment, sourcePath: string, extensionId: string): Promise<string> {
48
+ const extensionDeploymentDir = await getExtensionDeploymentDir(env, extensionId);
49
+ if (await fs.pathExists(extensionDeploymentDir)) {
50
+ console.log(`[${extensionId}]: deployment dir "${extensionDeploymentDir}" already exists`);
51
+ return extensionDeploymentDir;
52
+ }
53
+
54
+ const tempDir = await getTempDir(env, TMP_DIR_PREFIX);
55
+ try {
56
+ console.log(`[${extensionId}]: trying to decompress "${sourcePath}" into "${tempDir}"...`);
57
+ if (!await decompressExtension(sourcePath, tempDir)) {
58
+ await fs.remove(tempDir);
59
+ const msg = `[${extensionId}]: decompressing "${sourcePath}" to "${tempDir}" failed`;
60
+ console.error(msg);
61
+ throw new Error(msg);
62
+ }
63
+ } catch (e) {
64
+ await fs.remove(tempDir);
65
+ const msg = `[${extensionId}]: error while decompressing "${sourcePath}" to "${tempDir}"`;
66
+ console.error(msg, e);
67
+ throw e;
68
+ }
69
+ console.log(`[${extensionId}]: decompressed to temp dir "${tempDir}"`);
70
+
71
+ try {
72
+ console.log(`[${extensionId}]: renaming to extension dir "${extensionDeploymentDir}"...`);
73
+ await fs.rename(tempDir, extensionDeploymentDir);
74
+ return extensionDeploymentDir;
75
+ } catch (e) {
76
+ await fs.remove(tempDir);
77
+ console.error(`[${extensionId}]: error while renaming "${tempDir}" to "${extensionDeploymentDir}"`, e);
78
+ throw e;
79
+ }
80
+ }
81
+
82
+ export async function getExtensionDeploymentDir(env: PluginVSCodeEnvironment, extensionId: string): Promise<string> {
83
+ const deployedPluginsDirUri = await env.getDeploymentDirUri();
84
+ const normalizedExtensionId = filenamify(extensionId, { replacement: '_' });
85
+ const extensionDeploymentDirPath = FileUri.fsPath(deployedPluginsDirUri.resolve(normalizedExtensionId));
86
+ return extensionDeploymentDirPath;
87
+ }
88
+
89
+ export async function getTempDir(env: PluginVSCodeEnvironment, prefix: string): Promise<string> {
90
+ const deploymentDirPath = FileUri.fsPath(await env.getDeploymentDirUri());
91
+ try {
92
+ if (!await fs.pathExists(deploymentDirPath)) {
93
+ console.log(`Creating deployment dir ${deploymentDirPath}`);
94
+ await fs.mkdirs(deploymentDirPath);
95
+ }
96
+ return await fs.mkdtemp(path.join(deploymentDirPath, prefix));
97
+ } catch (error) {
98
+ console.error(`Failed to create deployment dir ${deploymentDirPath}: ${error}`);
99
+ throw error;
100
+ }
101
+ }