@theia/plugin-ext 1.22.0-next.9 → 1.22.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 (70) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +4 -3
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js.map +1 -1
  4. package/lib/common/plugin-protocol.d.ts +5 -0
  5. package/lib/common/plugin-protocol.d.ts.map +1 -1
  6. package/lib/common/plugin-protocol.js.map +1 -1
  7. package/lib/main/browser/custom-editors/custom-editor-opener.d.ts +3 -3
  8. package/lib/main/browser/custom-editors/custom-editor-opener.d.ts.map +1 -1
  9. package/lib/main/browser/custom-editors/custom-editor-opener.js +1 -1
  10. package/lib/main/browser/custom-editors/custom-editor-opener.js.map +1 -1
  11. package/lib/main/browser/custom-editors/custom-editors-main.d.ts +3 -3
  12. package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
  13. package/lib/main/browser/custom-editors/custom-editors-main.js +34 -6
  14. package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
  15. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts +3 -3
  16. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts.map +1 -1
  17. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js +3 -3
  18. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js.map +1 -1
  19. package/lib/main/browser/debug/debug-main.d.ts +1 -0
  20. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  21. package/lib/main/browser/debug/debug-main.js +12 -2
  22. package/lib/main/browser/debug/debug-main.js.map +1 -1
  23. package/lib/main/browser/view/tree-view-widget.js +1 -1
  24. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  25. package/lib/main/electron-browser/webview/electron-webview-widget-factory.js +3 -3
  26. package/lib/main/electron-browser/webview/electron-webview-widget-factory.js.map +1 -1
  27. package/lib/main/node/plugin-deployer-impl.d.ts +6 -9
  28. package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
  29. package/lib/main/node/plugin-deployer-impl.js +32 -24
  30. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  31. package/lib/main/node/plugin-server-handler.d.ts +2 -2
  32. package/lib/main/node/plugin-server-handler.d.ts.map +1 -1
  33. package/lib/main/node/plugin-server-handler.js +6 -3
  34. package/lib/main/node/plugin-server-handler.js.map +1 -1
  35. package/lib/plugin/custom-editors.d.ts +2 -1
  36. package/lib/plugin/custom-editors.d.ts.map +1 -1
  37. package/lib/plugin/custom-editors.js +2 -4
  38. package/lib/plugin/custom-editors.js.map +1 -1
  39. package/lib/plugin/node/debug/debug.d.ts +1 -0
  40. package/lib/plugin/node/debug/debug.d.ts.map +1 -1
  41. package/lib/plugin/node/debug/debug.js +3 -0
  42. package/lib/plugin/node/debug/debug.js.map +1 -1
  43. package/lib/plugin/plugin-context.d.ts +50 -2
  44. package/lib/plugin/plugin-context.d.ts.map +1 -1
  45. package/lib/plugin/plugin-context.js +37 -6
  46. package/lib/plugin/plugin-context.js.map +1 -1
  47. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  48. package/lib/plugin/plugin-manager.js +4 -1
  49. package/lib/plugin/plugin-manager.js.map +1 -1
  50. package/lib/plugin/types-impl.js +1 -1
  51. package/lib/plugin/types-impl.js.map +1 -1
  52. package/lib/plugin/types-impl.spec.js +33 -0
  53. package/lib/plugin/types-impl.spec.js.map +1 -1
  54. package/package.json +24 -26
  55. package/src/common/plugin-api-rpc.ts +4 -3
  56. package/src/common/plugin-protocol.ts +7 -1
  57. package/src/main/browser/custom-editors/custom-editor-opener.tsx +4 -4
  58. package/src/main/browser/custom-editors/custom-editors-main.ts +41 -8
  59. package/src/main/browser/custom-editors/plugin-custom-editor-registry.ts +6 -6
  60. package/src/main/browser/debug/debug-main.ts +13 -3
  61. package/src/main/browser/view/tree-view-widget.tsx +1 -1
  62. package/src/main/electron-browser/webview/electron-webview-widget-factory.ts +3 -3
  63. package/src/main/node/plugin-deployer-impl.ts +38 -27
  64. package/src/main/node/plugin-server-handler.ts +8 -4
  65. package/src/plugin/custom-editors.ts +3 -4
  66. package/src/plugin/node/debug/debug.ts +4 -0
  67. package/src/plugin/plugin-context.ts +73 -8
  68. package/src/plugin/plugin-manager.ts +4 -1
  69. package/src/plugin/types-impl.spec.ts +37 -1
  70. package/src/plugin/types-impl.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. and others.
2
+ * Copyright (C) 2018-2022 Red Hat, Inc. and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -724,13 +724,13 @@ export function createAPIFactory(
724
724
  const plugins: typeof theia.plugins = {
725
725
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
726
726
  get all(): theia.Plugin<any>[] {
727
- return pluginManager.getAllPlugins().map(plg => new Plugin(pluginManager, plg));
727
+ return pluginManager.getAllPlugins().map(plg => new PluginExt(pluginManager, plg));
728
728
  },
729
729
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
730
730
  getPlugin(pluginId: string): theia.Plugin<any> | undefined {
731
731
  const plg = pluginManager.getPluginById(pluginId.toLowerCase());
732
732
  if (plg) {
733
- return new Plugin(pluginManager, plg);
733
+ return new PluginExt(pluginManager, plg);
734
734
  }
735
735
  return undefined;
736
736
  },
@@ -780,9 +780,18 @@ export function createAPIFactory(
780
780
  registerDebugAdapterTrackerFactory(debugType: string, factory: theia.DebugAdapterTrackerFactory): Disposable {
781
781
  return debugExt.registerDebugAdapterTrackerFactory(debugType, factory);
782
782
  },
783
- startDebugging(folder: theia.WorkspaceFolder | undefined, nameOrConfiguration: string | theia.DebugConfiguration, options: theia.DebugSessionOptions):
784
- Thenable<boolean> {
785
- return debugExt.startDebugging(folder, nameOrConfiguration, options);
783
+ startDebugging(
784
+ folder: theia.WorkspaceFolder | undefined,
785
+ nameOrConfiguration: string | theia.DebugConfiguration,
786
+ parentSessionOrOptions?: theia.DebugSession | theia.DebugSessionOptions
787
+ ): Thenable<boolean> {
788
+ if (!parentSessionOrOptions || (typeof parentSessionOrOptions === 'object' && 'configuration' in parentSessionOrOptions)) {
789
+ return debugExt.startDebugging(folder, nameOrConfiguration, { parentSession: parentSessionOrOptions });
790
+ }
791
+ return debugExt.startDebugging(folder, nameOrConfiguration, parentSessionOrOptions || {});
792
+ },
793
+ stopDebugging(session?: theia.DebugSession): Thenable<void> {
794
+ return debugExt.stopDebugging(session);
786
795
  },
787
796
  addBreakpoints(breakpoints: theia.Breakpoint[]): void {
788
797
  debugExt.addBreakpoints(breakpoints);
@@ -969,14 +978,44 @@ export function createAPIFactory(
969
978
  };
970
979
  }
971
980
 
972
- class Plugin<T> implements theia.Plugin<T> {
981
+ export enum ExtensionKind {
982
+ UI = 1,
983
+ Workspace = 2
984
+ }
985
+
986
+ /**
987
+ * Represents a Theia plugin as well as a VSCode extension.
988
+ */
989
+ export interface ExtensionPlugin<T> extends theia.Plugin<T> {
990
+ /**
991
+ * The uri of the directory containing the extension. Same as {@linkcode theia.Plugin.pluginUri}.
992
+ */
993
+ readonly extensionUri: theia.Uri;
994
+
995
+ /**
996
+ * The absolute file path of the directory containing this extension.
997
+ * Same as {@linkcode theia.Plugin.pluginPath}.
998
+ */
999
+ readonly extensionPath: string;
1000
+
1001
+ /**
1002
+ * The extension kind describes if an extension runs where the UI runs
1003
+ * or if an extension runs where the remote extension host runs. The extension kind
1004
+ * is defined in the `package.json`-file of extensions. When no remote extension host exists,
1005
+ * the value is {@linkcode ExtensionKind.UI}.
1006
+ */
1007
+ extensionKind: ExtensionKind;
1008
+ }
1009
+
1010
+ export class Plugin<T> implements theia.Plugin<T> {
973
1011
  id: string;
974
1012
  pluginPath: string;
975
1013
  pluginUri: theia.Uri;
976
1014
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
977
1015
  packageJSON: any;
978
1016
  pluginType: theia.PluginType;
979
- constructor(private readonly pluginManager: PluginManager, plugin: InternalPlugin) {
1017
+
1018
+ constructor(protected readonly pluginManager: PluginManager, plugin: InternalPlugin) {
980
1019
  this.id = plugin.model.id;
981
1020
  this.pluginPath = plugin.pluginFolder;
982
1021
  this.pluginUri = URI.parse(plugin.pluginUri);
@@ -996,3 +1035,29 @@ class Plugin<T> implements theia.Plugin<T> {
996
1035
  return this.pluginManager.activatePlugin(this.id).then(() => this.exports);
997
1036
  }
998
1037
  }
1038
+
1039
+ export class PluginExt<T> extends Plugin<T> implements ExtensionPlugin<T> {
1040
+ extensionPath: string;
1041
+ extensionUri: theia.Uri;
1042
+ extensionKind: ExtensionKind;
1043
+
1044
+ constructor(protected readonly pluginManager: PluginManager, plugin: InternalPlugin) {
1045
+ super(pluginManager, plugin);
1046
+
1047
+ this.extensionPath = this.pluginPath;
1048
+ this.extensionUri = this.pluginUri;
1049
+ this.extensionKind = ExtensionKind.UI; // stub as a local extension (not running on a remote workspace)
1050
+ }
1051
+
1052
+ get isActive(): boolean {
1053
+ return this.pluginManager.isActive(this.id);
1054
+ }
1055
+
1056
+ get exports(): T {
1057
+ return <T>this.pluginManager.getPluginExport(this.id);
1058
+ }
1059
+
1060
+ activate(): PromiseLike<T> {
1061
+ return this.pluginManager.activatePlugin(this.id).then(() => this.exports);
1062
+ }
1063
+ }
@@ -40,6 +40,7 @@ import { Emitter } from '@theia/core/lib/common/event';
40
40
  import { WebviewsExtImpl } from './webviews';
41
41
  import { URI as Uri } from './types-impl';
42
42
  import { SecretsExtImpl, SecretStorageExt } from '../plugin/secrets-ext';
43
+ import { PluginExt } from './plugin-context';
43
44
 
44
45
  export interface PluginHost {
45
46
 
@@ -383,7 +384,9 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
383
384
  globalStoragePath: globalStoragePath,
384
385
  globalStorageUri: Uri.file(globalStoragePath),
385
386
  environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id),
386
- extensionMode: 1 // @todo: implement proper `extensionMode`.
387
+ extensionMode: 1, // @todo: implement proper `extensionMode`.
388
+ extension: new PluginExt(this, plugin),
389
+ logUri: Uri.file(logPath)
387
390
  };
388
391
  this.pluginContextsMap.set(plugin.model.id, pluginContext);
389
392
 
@@ -14,13 +14,14 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
+ import { isWindows } from '@theia/core';
17
18
  import * as assert from 'assert';
18
19
  import * as types from './types-impl';
19
20
 
20
21
  describe('API Type Implementations:', () => {
21
22
 
22
23
  describe('URI:', () => {
23
- it('should convert to string', () => {
24
+ it('should convert to string', () => {
24
25
  const uriString = 'scheme://authority.com/foo/bar/zoz?query#fragment';
25
26
  const uri = types.URI.parse(uriString);
26
27
  // when
@@ -29,5 +30,40 @@ describe('API Type Implementations:', () => {
29
30
  // then
30
31
  assert.strictEqual(result, uriString);
31
32
  });
33
+
34
+ // Issue: #10370
35
+ it('should returns correct path while using joinPath()', () => {
36
+ if (isWindows) {
37
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\foo\\bar'), '/file.js').toString(), 'file:///c%3A/foo/bar/file.js');
38
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\foo\\bar\\'), 'file.js').toString(), 'file:///c%3A/foo/bar/file.js');
39
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\foo\\bar\\'), '/file.js').toString(), 'file:///c%3A/foo/bar/file.js');
40
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\'), '/file.js').toString(), 'file:///c%3A/file.js');
41
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\'), 'bar/file.js').toString(), 'file:///c%3A/bar/file.js');
42
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\foo'), './file.js').toString(), 'file:///c%3A/foo/file.js');
43
+ assert.strictEqual(types.URI.joinPath(types.URI.file('c:\\foo'), '/./file.js').toString(), 'file:///c%3A/foo/file.js');
44
+ assert.strictEqual(types.URI.joinPath(types.URI.file('C:\\foo'), '../file.js').toString(), 'file:///c%3A/file.js');
45
+ assert.strictEqual(types.URI.joinPath(types.URI.file('C:\\foo\\.'), '../file.js').toString(), 'file:///c%3A/file.js');
46
+ } else {
47
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar'), '/file.js').toString(), 'file:///foo/bar/file.js');
48
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar'), 'file.js').toString(), 'file:///foo/bar/file.js');
49
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar/'), '/file.js').toString(), 'file:///foo/bar/file.js');
50
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/'), '/file.js').toString(), 'file:///file.js');
51
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar'), './file.js').toString(), 'file:///foo/bar/file.js');
52
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar'), '/./file.js').toString(), 'file:///foo/bar/file.js');
53
+ assert.strictEqual(types.URI.joinPath(types.URI.file('/foo/bar'), '../file.js').toString(), 'file:///foo/file.js');
54
+ }
55
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar')).toString(), 'foo://a/foo/bar');
56
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar'), '/file.js').toString(), 'foo://a/foo/bar/file.js');
57
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar'), 'file.js').toString(), 'foo://a/foo/bar/file.js');
58
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar/'), '/file.js').toString(), 'foo://a/foo/bar/file.js');
59
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/'), '/file.js').toString(), 'foo://a/file.js');
60
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar/'), './file.js').toString(), 'foo://a/foo/bar/file.js');
61
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar/'), '/./file.js').toString(), 'foo://a/foo/bar/file.js');
62
+ assert.strictEqual(types.URI.joinPath(types.URI.parse('foo://a/foo/bar/'), '../file.js').toString(), 'foo://a/foo/file.js');
63
+
64
+ assert.strictEqual(
65
+ types.URI.joinPath(types.URI.from({ scheme: 'myScheme', authority: 'authority', path: '/path', query: 'query', fragment: 'fragment' }), '/file.js').toString(),
66
+ 'myScheme://authority/path/file.js?query#fragment');
67
+ });
32
68
  });
33
69
  });
@@ -82,7 +82,7 @@ export class URI extends CodeURI implements theia.Uri {
82
82
  if (!uri.path) {
83
83
  throw new Error('\'joinPath\' called on URI without path');
84
84
  }
85
- const newPath = paths.resolve(uri.path, ...pathSegments);
85
+ const newPath = paths.posix.join(uri.path, ...pathSegments);
86
86
  return new URI(uri.scheme, uri.authority, newPath, uri.query, uri.fragment);
87
87
  }
88
88