@theia/plugin-ext 1.29.0-next.23 → 1.29.0-next.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext",
3
- "version": "1.29.0-next.23+7cb705b64a3",
3
+ "version": "1.29.0-next.30+a0e7922bd76",
4
4
  "description": "Theia - Plugin Extension",
5
5
  "main": "lib/common/index.js",
6
6
  "typings": "lib/common/index.d.ts",
7
7
  "dependencies": {
8
- "@theia/bulk-edit": "1.29.0-next.23+7cb705b64a3",
9
- "@theia/callhierarchy": "1.29.0-next.23+7cb705b64a3",
10
- "@theia/console": "1.29.0-next.23+7cb705b64a3",
11
- "@theia/core": "1.29.0-next.23+7cb705b64a3",
12
- "@theia/debug": "1.29.0-next.23+7cb705b64a3",
13
- "@theia/editor": "1.29.0-next.23+7cb705b64a3",
14
- "@theia/file-search": "1.29.0-next.23+7cb705b64a3",
15
- "@theia/filesystem": "1.29.0-next.23+7cb705b64a3",
16
- "@theia/markers": "1.29.0-next.23+7cb705b64a3",
17
- "@theia/messages": "1.29.0-next.23+7cb705b64a3",
18
- "@theia/monaco": "1.29.0-next.23+7cb705b64a3",
8
+ "@theia/bulk-edit": "1.29.0-next.30+a0e7922bd76",
9
+ "@theia/callhierarchy": "1.29.0-next.30+a0e7922bd76",
10
+ "@theia/console": "1.29.0-next.30+a0e7922bd76",
11
+ "@theia/core": "1.29.0-next.30+a0e7922bd76",
12
+ "@theia/debug": "1.29.0-next.30+a0e7922bd76",
13
+ "@theia/editor": "1.29.0-next.30+a0e7922bd76",
14
+ "@theia/file-search": "1.29.0-next.30+a0e7922bd76",
15
+ "@theia/filesystem": "1.29.0-next.30+a0e7922bd76",
16
+ "@theia/markers": "1.29.0-next.30+a0e7922bd76",
17
+ "@theia/messages": "1.29.0-next.30+a0e7922bd76",
18
+ "@theia/monaco": "1.29.0-next.30+a0e7922bd76",
19
19
  "@theia/monaco-editor-core": "1.67.2",
20
- "@theia/navigator": "1.29.0-next.23+7cb705b64a3",
21
- "@theia/output": "1.29.0-next.23+7cb705b64a3",
22
- "@theia/plugin": "1.29.0-next.23+7cb705b64a3",
23
- "@theia/preferences": "1.29.0-next.23+7cb705b64a3",
24
- "@theia/scm": "1.29.0-next.23+7cb705b64a3",
25
- "@theia/search-in-workspace": "1.29.0-next.23+7cb705b64a3",
26
- "@theia/task": "1.29.0-next.23+7cb705b64a3",
27
- "@theia/terminal": "1.29.0-next.23+7cb705b64a3",
28
- "@theia/timeline": "1.29.0-next.23+7cb705b64a3",
29
- "@theia/variable-resolver": "1.29.0-next.23+7cb705b64a3",
30
- "@theia/workspace": "1.29.0-next.23+7cb705b64a3",
20
+ "@theia/navigator": "1.29.0-next.30+a0e7922bd76",
21
+ "@theia/output": "1.29.0-next.30+a0e7922bd76",
22
+ "@theia/plugin": "1.29.0-next.30+a0e7922bd76",
23
+ "@theia/preferences": "1.29.0-next.30+a0e7922bd76",
24
+ "@theia/scm": "1.29.0-next.30+a0e7922bd76",
25
+ "@theia/search-in-workspace": "1.29.0-next.30+a0e7922bd76",
26
+ "@theia/task": "1.29.0-next.30+a0e7922bd76",
27
+ "@theia/terminal": "1.29.0-next.30+a0e7922bd76",
28
+ "@theia/timeline": "1.29.0-next.30+a0e7922bd76",
29
+ "@theia/variable-resolver": "1.29.0-next.30+a0e7922bd76",
30
+ "@theia/workspace": "1.29.0-next.30+a0e7922bd76",
31
31
  "@types/mime": "^2.0.1",
32
32
  "decompress": "^4.2.1",
33
33
  "escape-html": "^1.0.3",
@@ -94,5 +94,5 @@
94
94
  "nyc": {
95
95
  "extends": "../../configs/nyc.json"
96
96
  },
97
- "gitHead": "7cb705b64a387bbf582c455365a1fa453ea301bf"
97
+ "gitHead": "a0e7922bd76160d0d29564ec1316f82dc021af3f"
98
98
  }
@@ -1943,20 +1943,15 @@ export interface AuthenticationExt {
1943
1943
  $getSessions(id: string, scopes?: string[]): Promise<ReadonlyArray<theia.AuthenticationSession>>;
1944
1944
  $createSession(id: string, scopes: string[]): Promise<theia.AuthenticationSession>;
1945
1945
  $removeSession(id: string, sessionId: string): Promise<void>;
1946
- $onDidChangeAuthenticationSessions(id: string, label: string): Promise<void>;
1947
- $onDidChangeAuthenticationProviders(added: theia.AuthenticationProviderInformation[], removed: theia.AuthenticationProviderInformation[]): Promise<void>;
1948
- $setProviders(providers: theia.AuthenticationProviderInformation[]): Promise<void>;
1946
+ $onDidChangeAuthenticationSessions(provider: theia.AuthenticationProviderInformation): Promise<void>;
1949
1947
  }
1950
1948
 
1951
1949
  export interface AuthenticationMain {
1952
1950
  $registerAuthenticationProvider(id: string, label: string, supportsMultipleAccounts: boolean): void;
1953
1951
  $unregisterAuthenticationProvider(id: string): void;
1954
- $getProviderIds(): Promise<string[]>;
1955
- $ensureProvider(id: string): Promise<void>;
1956
- $sendDidChangeSessions(providerId: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): void;
1952
+ $onDidChangeSessions(providerId: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): void;
1957
1953
  $getSession(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string,
1958
1954
  options: theia.AuthenticationGetSessionOptions): Promise<theia.AuthenticationSession | undefined>;
1959
- $removeSession(providerId: string, sessionId: string): Promise<void>;
1960
1955
  }
1961
1956
 
1962
1957
  export interface RawColorInfo {
@@ -21,7 +21,7 @@
21
21
  // code copied and modified from https://github.com/microsoft/vscode/blob/1.47.3/src/vs/workbench/api/browser/mainThreadAuthentication.ts
22
22
 
23
23
  import { interfaces } from '@theia/core/shared/inversify';
24
- import { AuthenticationExt, AuthenticationMain, PluginManagerExt, MAIN_RPC_CONTEXT } from '../../common/plugin-api-rpc';
24
+ import { AuthenticationExt, AuthenticationMain, MAIN_RPC_CONTEXT } from '../../common/plugin-api-rpc';
25
25
  import { RPCProtocol } from '../../common/rpc-protocol';
26
26
  import { MessageService } from '@theia/core/lib/common/message-service';
27
27
  import { Dialog, StorageService } from '@theia/core/lib/browser';
@@ -43,28 +43,17 @@ export class AuthenticationMainImpl implements AuthenticationMain {
43
43
  private readonly storageService: StorageService;
44
44
  private readonly authenticationService: AuthenticationService;
45
45
  private readonly quickPickService: QuickPickService;
46
- private readonly extensionService: PluginManagerExt;
47
46
  constructor(rpc: RPCProtocol, container: interfaces.Container) {
48
47
  this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.AUTHENTICATION_EXT);
49
48
  this.messageService = container.get(MessageService);
50
49
  this.storageService = container.get(StorageService);
51
50
  this.authenticationService = container.get(AuthenticationService);
52
51
  this.quickPickService = container.get(QuickPickService);
53
- this.extensionService = rpc.getProxy(MAIN_RPC_CONTEXT.HOSTED_PLUGIN_MANAGER_EXT);
54
52
 
55
53
  this.authenticationService.onDidChangeSessions(e => {
56
- this.proxy.$onDidChangeAuthenticationSessions(e.providerId, e.label);
57
- });
58
- this.authenticationService.onDidRegisterAuthenticationProvider(info => {
59
- this.proxy.$onDidChangeAuthenticationProviders([info], []);
60
- });
61
- this.authenticationService.onDidUnregisterAuthenticationProvider(providerId => {
62
- this.proxy.$onDidChangeAuthenticationProviders([], [providerId]);
54
+ this.proxy.$onDidChangeAuthenticationSessions({ id: e.providerId, label: e.label });
63
55
  });
64
56
  }
65
- $getProviderIds(): Promise<string[]> {
66
- return Promise.resolve(this.authenticationService.getProviderIds());
67
- }
68
57
 
69
58
  async $registerAuthenticationProvider(id: string, label: string, supportsMultipleAccounts: boolean): Promise<void> {
70
59
  const provider = new AuthenticationProviderImpl(this.proxy, id, label, supportsMultipleAccounts, this.storageService, this.messageService);
@@ -230,15 +219,7 @@ export class AuthenticationMainImpl implements AuthenticationMain {
230
219
  this.storageService.setData(`authentication-session-${extensionName}-${providerId}`, sessionId);
231
220
  }
232
221
 
233
- $ensureProvider(id: string): Promise<void> {
234
- return this.extensionService.$activateByEvent(getAuthenticationProviderActivationEvent(id));
235
- }
236
-
237
- $removeSession(providerId: string, sessionId: string): Promise<void> {
238
- return this.authenticationService.logout(providerId, sessionId);
239
- }
240
-
241
- $sendDidChangeSessions(providerId: string, event: theia.AuthenticationProviderAuthenticationSessionsChangeEvent): void {
222
+ $onDidChangeSessions(providerId: string, event: theia.AuthenticationProviderAuthenticationSessionsChangeEvent): void {
242
223
  this.authenticationService.updateSessions(providerId, event);
243
224
  }
244
225
  }
@@ -272,8 +253,10 @@ interface AccountUsage {
272
253
  }
273
254
 
274
255
  export class AuthenticationProviderImpl implements AuthenticationProvider {
275
- private accounts = new Map<string, string[]>(); // Map account name to session ids
276
- private sessions = new Map<string, string>(); // Map account id to name
256
+ /** map from account name to session ids */
257
+ private accounts = new Map<string, string[]>();
258
+ /** map from session id to account name */
259
+ private sessions = new Map<string, string>();
277
260
 
278
261
  readonly onDidChangeSessions: theia.Event<theia.AuthenticationProviderAuthenticationSessionsChangeEvent>;
279
262
 
@@ -313,7 +296,7 @@ export class AuthenticationProviderImpl implements AuthenticationProvider {
313
296
  Dialog.CANCEL);
314
297
 
315
298
  if (result && result === nls.localizeByDefault('Sign Out') && sessionsForAccount) {
316
- sessionsForAccount.forEach(sessionId => this.logout(sessionId));
299
+ sessionsForAccount.forEach(sessionId => this.removeSession(sessionId));
317
300
  removeAccountUsage(this.storageService, this.id, accountName);
318
301
  }
319
302
  }
@@ -325,10 +308,10 @@ export class AuthenticationProviderImpl implements AuthenticationProvider {
325
308
  async updateSessionItems(event: theia.AuthenticationProviderAuthenticationSessionsChangeEvent): Promise<void> {
326
309
  const { added, removed } = event;
327
310
  const session = await this.proxy.$getSessions(this.id);
328
- const addedSessions = session.filter(s => added.some(addedSession => this.getSessionId(addedSession) === s.id));
311
+ const addedSessions = added ? session.filter(s => added.some(addedSession => addedSession.id === s.id)) : [];
329
312
 
330
- removed.forEach(removedSession => {
331
- const sessionId = this.getSessionId(removedSession);
313
+ removed?.forEach(removedSession => {
314
+ const sessionId = removedSession.id;
332
315
  if (sessionId) {
333
316
  const accountName = this.sessions.get(sessionId);
334
317
  if (accountName) {
@@ -347,29 +330,21 @@ export class AuthenticationProviderImpl implements AuthenticationProvider {
347
330
  addedSessions.forEach(s => this.registerSession(s));
348
331
  }
349
332
 
350
- login(scopes: string[]): Promise<theia.AuthenticationSession> {
351
- return this.proxy.$createSession(this.id, scopes);
333
+ async login(scopes: string[]): Promise<theia.AuthenticationSession> {
334
+ return this.createSession(scopes);
352
335
  }
353
336
 
354
337
  async logout(sessionId: string): Promise<void> {
355
- await this.proxy.$removeSession(this.id, sessionId);
356
- this.messageService.info('Successfully signed out.');
338
+ return this.removeSession(sessionId);
357
339
  }
358
340
 
359
341
  createSession(scopes: string[]): Thenable<theia.AuthenticationSession> {
360
- return this.login(scopes);
342
+ return this.proxy.$createSession(this.id, scopes);
361
343
  }
362
344
 
363
345
  removeSession(sessionId: string): Thenable<void> {
364
- return this.logout(sessionId);
365
- }
366
-
367
- // utility method to be backwards compatible with the old AuthenticationProviderAuthenticationSessionsChangeEvent containing only the session id string
368
- private getSessionId(obj: string | theia.AuthenticationSession | undefined): string | undefined {
369
- if (!obj || typeof obj === 'string') {
370
- return obj;
371
- }
372
- return obj.id;
346
+ return this.proxy.$removeSession(this.id, sessionId)
347
+ .then(() => { this.messageService.info('Successfully signed out.'); });
373
348
  }
374
349
  }
375
350
 
@@ -490,7 +490,6 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
490
490
  const currentDataWidget = widget.widgets[0];
491
491
  const viewDataWidget = await this.createViewDataWidget(view.id, webviewId);
492
492
  if (widget.isDisposed) {
493
- // eslint-disable-next-line no-unused-expressions
494
493
  viewDataWidget?.dispose();
495
494
  return;
496
495
  }
@@ -34,13 +34,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
34
34
  private proxy: AuthenticationMain;
35
35
  private authenticationProviders: Map<string, theia.AuthenticationProvider> = new Map<string, theia.AuthenticationProvider>();
36
36
 
37
- private _providerIds: string[] = [];
38
-
39
- private _providers: theia.AuthenticationProviderInformation[] = [];
40
-
41
- private onDidChangeAuthenticationProvidersEmitter = new Emitter<theia.AuthenticationProvidersChangeEvent>();
42
- readonly onDidChangeAuthenticationProviders: Event<theia.AuthenticationProvidersChangeEvent> = this.onDidChangeAuthenticationProvidersEmitter.event;
43
-
44
37
  private onDidChangeSessionsEmitter = new Emitter<theia.AuthenticationSessionsChangeEvent>();
45
38
  readonly onDidChangeSessions: Event<theia.AuthenticationSessionsChangeEvent> = this.onDidChangeSessionsEmitter.event;
46
39
 
@@ -48,18 +41,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
48
41
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.AUTHENTICATION_MAIN);
49
42
  }
50
43
 
51
- getProviderIds(): Promise<ReadonlyArray<string>> {
52
- return this.proxy.$getProviderIds();
53
- }
54
-
55
- get providerIds(): string[] {
56
- return this._providerIds;
57
- }
58
-
59
- get providers(): ReadonlyArray<theia.AuthenticationProviderInformation> {
60
- return Object.freeze(this._providers.slice());
61
- }
62
-
63
44
  async getSession(requestingExtension: InternalPlugin, providerId: string, scopes: readonly string[],
64
45
  options: theia.AuthenticationGetSessionOptions & ({ createIfNone: true } | { forceNewSession: true } | { forceNewSession: { detail: string } })):
65
46
  Promise<theia.AuthenticationSession>;
@@ -76,29 +57,14 @@ export class AuthenticationExtImpl implements AuthenticationExt {
76
57
  return this.proxy.$getSession(providerId, scopes, extensionId, extensionName, options);
77
58
  }
78
59
 
79
- async logout(providerId: string, sessionId: string): Promise<void> {
80
- return this.proxy.$removeSession(providerId, sessionId);
81
- }
82
-
83
60
  registerAuthenticationProvider(id: string, label: string, provider: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions): theia.Disposable {
84
61
  if (this.authenticationProviders.get(id)) {
85
62
  throw new Error(`An authentication provider with id '${id}' is already registered.`);
86
63
  }
87
64
 
88
65
  this.authenticationProviders.set(id, provider);
89
- if (this._providerIds.indexOf(id) === -1) {
90
- this._providerIds.push(id);
91
- }
92
-
93
- if (!this._providers.find(p => p.id === id)) {
94
- this._providers.push({
95
- id,
96
- label
97
- });
98
- }
99
-
100
66
  const listener = provider.onDidChangeSessions(e => {
101
- this.proxy.$sendDidChangeSessions(id, e);
67
+ this.proxy.$onDidChangeSessions(id, e);
102
68
  });
103
69
 
104
70
  this.proxy.$registerAuthenticationProvider(id, label, !!options?.supportsMultipleAccounts);
@@ -106,16 +72,6 @@ export class AuthenticationExtImpl implements AuthenticationExt {
106
72
  return new Disposable(() => {
107
73
  listener.dispose();
108
74
  this.authenticationProviders.delete(id);
109
- const index = this._providerIds.findIndex(pid => id === pid);
110
- if (index > -1) {
111
- this._providerIds.splice(index);
112
- }
113
-
114
- const i = this._providers.findIndex(p => p.id === id);
115
- if (i > -1) {
116
- this._providers.splice(i);
117
- }
118
-
119
75
  this.proxy.$unregisterAuthenticationProvider(id);
120
76
  });
121
77
  }
@@ -163,30 +119,7 @@ export class AuthenticationExtImpl implements AuthenticationExt {
163
119
  throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
164
120
  }
165
121
 
166
- $onDidChangeAuthenticationSessions(id: string, label: string): Promise<void> {
167
- this.onDidChangeSessionsEmitter.fire({ provider: { id, label } });
168
- return Promise.resolve();
169
- }
170
-
171
- async $onDidChangeAuthenticationProviders(added: theia.AuthenticationProviderInformation[], removed: theia.AuthenticationProviderInformation[]): Promise<void> {
172
- added.forEach(id => {
173
- if (this._providers.indexOf(id) === -1) {
174
- this._providers.push(id);
175
- }
176
- });
177
-
178
- removed.forEach(p => {
179
- const index = this._providers.findIndex(provider => provider.id === p.id);
180
- if (index > -1) {
181
- this._providers.splice(index);
182
- }
183
- });
184
-
185
- this.onDidChangeAuthenticationProvidersEmitter.fire({ added, removed });
186
- }
187
-
188
- $setProviders(providers: theia.AuthenticationProviderInformation[]): Promise<void> {
189
- this._providers.push(...providers);
190
- return Promise.resolve(undefined);
122
+ async $onDidChangeAuthenticationSessions(provider: theia.AuthenticationProviderInformation): Promise<void> {
123
+ this.onDidChangeSessionsEmitter.fire({ provider });
191
124
  }
192
125
  }
@@ -224,50 +224,14 @@ export function createAPIFactory(
224
224
 
225
225
  return function (plugin: InternalPlugin): typeof theia {
226
226
  const authentication: typeof theia.authentication = {
227
- // support older (< 1.53.0) and newer version of authentication provider registration
228
- registerAuthenticationProvider(
229
- id: string | theia.AuthenticationProvider, label?: string, provider?: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions):
230
- theia.Disposable {
231
- // collect registration data based on registration type: new (all parameters given) vs old (data stored in provider)
232
- const isNewRegistration = typeof id === 'string';
233
- const regProvider = isNewRegistration ? provider! : id;
234
- const regId = isNewRegistration ? id : regProvider.id;
235
- const regLabel = isNewRegistration ? label! : regProvider.label;
236
- const regOptions = isNewRegistration ? options : { supportsMultipleAccounts: regProvider.supportsMultipleAccounts };
237
-
238
- // ensure that all methods of the new AuthenticationProvider are available or delegate otherwise
239
- if (!regProvider['createSession']) {
240
- regProvider['createSession'] = (scopes: string[]) => regProvider.login(scopes);
241
- }
242
- if (!regProvider['removeSession']) {
243
- regProvider['removeSession'] = (sessionId: string) => regProvider.logout(sessionId);
244
- }
245
- return authenticationExt.registerAuthenticationProvider(regId, regLabel, regProvider, regOptions);
246
- },
247
- get onDidChangeAuthenticationProviders(): theia.Event<theia.AuthenticationProvidersChangeEvent> {
248
- return authenticationExt.onDidChangeAuthenticationProviders;
249
- },
250
- getProviderIds(): Thenable<ReadonlyArray<string>> {
251
- return Promise.resolve(authenticationExt.providerIds);
252
- },
253
- get providerIds(): string[] {
254
- return authenticationExt.providerIds;
255
- },
256
- get providers(): ReadonlyArray<theia.AuthenticationProviderInformation> {
257
- return authenticationExt.providers;
227
+ registerAuthenticationProvider(id: string, label: string, provider: theia.AuthenticationProvider, options?: theia.AuthenticationProviderOptions): theia.Disposable {
228
+ return authenticationExt.registerAuthenticationProvider(id, label, provider, options);
258
229
  },
259
230
  getSession(providerId: string, scopes: string[], options: theia.AuthenticationGetSessionOptions) {
260
231
  return authenticationExt.getSession(plugin, providerId, scopes, options as any);
261
232
  },
262
- logout(providerId: string, sessionId: string): Thenable<void> {
263
- return authenticationExt.logout(providerId, sessionId);
264
- },
265
233
  get onDidChangeSessions(): theia.Event<theia.AuthenticationSessionsChangeEvent> {
266
234
  return authenticationExt.onDidChangeSessions;
267
- },
268
- async hasSession(providerId: string, scopes: readonly string[]): Promise<boolean> {
269
- const session = await authenticationExt.getSession(plugin, providerId, scopes, { silent: true });
270
- return !!session;
271
235
  }
272
236
  };
273
237
  const commands: typeof theia.commands = {
@@ -112,7 +112,6 @@ describe('PreferenceRegistryExtImpl:', () => {
112
112
  });
113
113
  });
114
114
 
115
- /* eslint-disable no-unused-expressions */
116
115
  describe('toConfigurationChangeEvent', () => {
117
116
  // E.g. deletion of a `tasks.json`.
118
117
  it('Handles deletion of a section', () => {