@theia/plugin-ext 1.34.2 → 1.36.0-next.21

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 (131) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +18 -1
  2. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  4. package/lib/common/plugin-api-rpc.d.ts +10 -5
  5. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/common/plugin-protocol.d.ts +44 -10
  8. package/lib/common/plugin-protocol.d.ts.map +1 -1
  9. package/lib/common/plugin-protocol.js.map +1 -1
  10. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  11. package/lib/hosted/browser/hosted-plugin.js +16 -21
  12. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  13. package/lib/hosted/node/hosted-plugin-deployer-handler.js +1 -1
  14. package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
  15. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  16. package/lib/hosted/node/plugin-activation-events.d.ts +7 -0
  17. package/lib/hosted/node/plugin-activation-events.d.ts.map +1 -0
  18. package/lib/hosted/node/plugin-activation-events.js +96 -0
  19. package/lib/hosted/node/plugin-activation-events.js.map +1 -0
  20. package/lib/hosted/node/plugin-host-rpc.js +2 -2
  21. package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
  22. package/lib/hosted/node/plugin-manifest-loader.d.ts +2 -1
  23. package/lib/hosted/node/plugin-manifest-loader.d.ts.map +1 -1
  24. package/lib/hosted/node/plugin-manifest-loader.js +2 -1
  25. package/lib/hosted/node/plugin-manifest-loader.js.map +1 -1
  26. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  27. package/lib/hosted/node/scanners/scanner-theia.js +27 -36
  28. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  29. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts +9 -0
  30. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts.map +1 -0
  31. package/lib/main/browser/data-transfer/data-transfer-type-converters.js +65 -0
  32. package/lib/main/browser/data-transfer/data-transfer-type-converters.js.map +1 -0
  33. package/lib/main/browser/dialogs/modal-notification.d.ts.map +1 -1
  34. package/lib/main/browser/dialogs/modal-notification.js +4 -2
  35. package/lib/main/browser/dialogs/modal-notification.js.map +1 -1
  36. package/lib/main/browser/languages-main.d.ts +8 -1
  37. package/lib/main/browser/languages-main.d.ts.map +1 -1
  38. package/lib/main/browser/languages-main.js +26 -2
  39. package/lib/main/browser/languages-main.js.map +1 -1
  40. package/lib/main/browser/main-file-system-event-service.d.ts.map +1 -1
  41. package/lib/main/browser/main-file-system-event-service.js +6 -9
  42. package/lib/main/browser/main-file-system-event-service.js.map +1 -1
  43. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  44. package/lib/main/browser/plugin-contribution-handler.js +4 -1
  45. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  46. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  47. package/lib/main/browser/plugin-ext-frontend-module.js +3 -0
  48. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  49. package/lib/main/browser/text-editors-main.d.ts +2 -2
  50. package/lib/main/browser/text-editors-main.d.ts.map +1 -1
  51. package/lib/main/browser/text-editors-main.js +2 -2
  52. package/lib/main/browser/text-editors-main.js.map +1 -1
  53. package/lib/main/browser/webview/webview-context-keys.d.ts +13 -0
  54. package/lib/main/browser/webview/webview-context-keys.d.ts.map +1 -0
  55. package/lib/main/browser/webview/webview-context-keys.js +64 -0
  56. package/lib/main/browser/webview/webview-context-keys.js.map +1 -0
  57. package/lib/main/node/handlers/plugin-theia-directory-handler.js +1 -1
  58. package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
  59. package/lib/plugin/dialogs.js +2 -2
  60. package/lib/plugin/dialogs.js.map +1 -1
  61. package/lib/plugin/file-system-ext-impl.d.ts +11 -5
  62. package/lib/plugin/file-system-ext-impl.d.ts.map +1 -1
  63. package/lib/plugin/file-system-ext-impl.js +8 -16
  64. package/lib/plugin/file-system-ext-impl.js.map +1 -1
  65. package/lib/plugin/known-commands.d.ts.map +1 -1
  66. package/lib/plugin/known-commands.js +13 -0
  67. package/lib/plugin/known-commands.js.map +1 -1
  68. package/lib/plugin/languages/document-drop-edit.d.ts +16 -0
  69. package/lib/plugin/languages/document-drop-edit.d.ts.map +1 -0
  70. package/lib/plugin/languages/document-drop-edit.js +23 -0
  71. package/lib/plugin/languages/document-drop-edit.js.map +1 -0
  72. package/lib/plugin/languages.d.ts +9 -2
  73. package/lib/plugin/languages.d.ts.map +1 -1
  74. package/lib/plugin/languages.js +27 -1
  75. package/lib/plugin/languages.js.map +1 -1
  76. package/lib/plugin/plugin-context.d.ts +2 -1
  77. package/lib/plugin/plugin-context.d.ts.map +1 -1
  78. package/lib/plugin/plugin-context.js +16 -6
  79. package/lib/plugin/plugin-context.js.map +1 -1
  80. package/lib/plugin/preference-registry.d.ts +5 -3
  81. package/lib/plugin/preference-registry.d.ts.map +1 -1
  82. package/lib/plugin/preference-registry.js +31 -42
  83. package/lib/plugin/preference-registry.js.map +1 -1
  84. package/lib/plugin/preference-registry.spec.js +29 -41
  85. package/lib/plugin/preference-registry.spec.js.map +1 -1
  86. package/lib/plugin/text-editors.d.ts +1 -1
  87. package/lib/plugin/text-editors.d.ts.map +1 -1
  88. package/lib/plugin/text-editors.js +2 -2
  89. package/lib/plugin/text-editors.js.map +1 -1
  90. package/lib/plugin/type-converters.d.ts +6 -0
  91. package/lib/plugin/type-converters.d.ts.map +1 -1
  92. package/lib/plugin/type-converters.js +37 -1
  93. package/lib/plugin/type-converters.js.map +1 -1
  94. package/lib/plugin/types-impl.d.ts +6 -1
  95. package/lib/plugin/types-impl.d.ts.map +1 -1
  96. package/lib/plugin/types-impl.js +16 -3
  97. package/lib/plugin/types-impl.js.map +1 -1
  98. package/lib/plugin/webview-views.js +2 -2
  99. package/lib/plugin/webview-views.js.map +1 -1
  100. package/package.json +27 -27
  101. package/src/common/plugin-api-rpc-model.ts +22 -1
  102. package/src/common/plugin-api-rpc.ts +18 -5
  103. package/src/common/plugin-protocol.ts +47 -14
  104. package/src/hosted/browser/hosted-plugin.ts +15 -20
  105. package/src/hosted/node/hosted-plugin-deployer-handler.ts +1 -1
  106. package/src/hosted/node/hosted-plugin-process.ts +2 -2
  107. package/src/hosted/node/plugin-activation-events.ts +111 -0
  108. package/src/hosted/node/plugin-host-rpc.ts +2 -2
  109. package/src/hosted/node/plugin-manifest-loader.ts +4 -3
  110. package/src/hosted/node/scanners/scanner-theia.ts +59 -75
  111. package/src/main/browser/data-transfer/data-transfer-type-converters.ts +70 -0
  112. package/src/main/browser/dialogs/modal-notification.ts +4 -2
  113. package/src/main/browser/languages-main.ts +34 -4
  114. package/src/main/browser/main-file-system-event-service.ts +6 -9
  115. package/src/main/browser/plugin-contribution-handler.ts +6 -3
  116. package/src/main/browser/plugin-ext-frontend-module.ts +3 -0
  117. package/src/main/browser/text-editors-main.ts +3 -2
  118. package/src/main/browser/webview/webview-context-keys.ts +49 -0
  119. package/src/main/node/handlers/plugin-theia-directory-handler.ts +1 -1
  120. package/src/plugin/dialogs.ts +2 -2
  121. package/src/plugin/file-system-ext-impl.ts +8 -18
  122. package/src/plugin/known-commands.ts +16 -1
  123. package/src/plugin/languages/document-drop-edit.ts +44 -0
  124. package/src/plugin/languages.ts +41 -3
  125. package/src/plugin/plugin-context.ts +18 -6
  126. package/src/plugin/preference-registry.spec.ts +29 -45
  127. package/src/plugin/preference-registry.ts +33 -45
  128. package/src/plugin/text-editors.ts +2 -2
  129. package/src/plugin/type-converters.ts +37 -0
  130. package/src/plugin/types-impl.ts +15 -1
  131. package/src/plugin/webview-views.ts +2 -2
@@ -72,6 +72,7 @@ export namespace PluginPackage {
72
72
  * This interface describes a package.json contribution section object.
73
73
  */
74
74
  export interface PluginPackageContribution {
75
+ authentication?: PluginPackageAuthenticationProvider[];
75
76
  configuration?: RecursivePartial<PreferenceSchema> | RecursivePartial<PreferenceSchema>[];
76
77
  configurationDefaults?: RecursivePartial<PreferenceSchemaProperties>;
77
78
  languages?: PluginPackageLanguageContribution[];
@@ -96,16 +97,29 @@ export interface PluginPackageContribution {
96
97
  resourceLabelFormatters?: ResourceLabelFormatter[];
97
98
  localizations?: PluginPackageLocalization[];
98
99
  terminal?: PluginPackageTerminal;
100
+ notebooks?: PluginPackageNotebook[];
101
+ }
102
+
103
+ export interface PluginPackageNotebook {
104
+ type: string;
105
+ displayName: string;
106
+ selector?: readonly { filenamePattern?: string; excludeFileNamePattern?: string }[];
107
+ priority?: string;
108
+ }
109
+
110
+ export interface PluginPackageAuthenticationProvider {
111
+ id: string;
112
+ label: string;
99
113
  }
100
114
 
101
115
  export interface PluginPackageTerminalProfile {
102
- title: string,
103
- id: string,
104
- icon?: string
116
+ title: string;
117
+ id: string;
118
+ icon?: string;
105
119
  }
106
120
 
107
121
  export interface PluginPackageTerminal {
108
- profiles: PluginPackageTerminalProfile[]
122
+ profiles: PluginPackageTerminalProfile[];
109
123
  }
110
124
 
111
125
  export interface PluginPackageLocalization {
@@ -544,6 +558,7 @@ export interface PluginEntryPoint {
544
558
  */
545
559
  export interface PluginContribution {
546
560
  activationEvents?: string[];
561
+ authentication?: AuthenticationProviderInformation[];
547
562
  configuration?: PreferenceSchema[];
548
563
  configurationDefaults?: PreferenceSchemaProperties;
549
564
  languages?: LanguageContribution[];
@@ -567,6 +582,19 @@ export interface PluginContribution {
567
582
  resourceLabelFormatters?: ResourceLabelFormatter[];
568
583
  localizations?: Localization[];
569
584
  terminalProfiles?: TerminalProfile[];
585
+ notebooks?: NotebookContribution[];
586
+ }
587
+
588
+ export interface NotebookContribution {
589
+ type: string;
590
+ displayName: string;
591
+ selector?: readonly { filenamePattern?: string; excludeFileNamePattern?: string }[];
592
+ priority?: string;
593
+ }
594
+
595
+ export interface AuthenticationProviderInformation {
596
+ id: string;
597
+ label: string;
570
598
  }
571
599
 
572
600
  export interface TerminalProfile {
@@ -641,6 +669,11 @@ export interface LanguageContribution {
641
669
  configuration?: LanguageConfiguration;
642
670
  }
643
671
 
672
+ export interface RegExpOptions {
673
+ pattern: string;
674
+ flags?: string;
675
+ }
676
+
644
677
  export interface LanguageConfiguration {
645
678
  brackets?: CharacterPair[];
646
679
  indentationRules?: IndentationRules;
@@ -648,7 +681,7 @@ export interface LanguageConfiguration {
648
681
  autoClosingPairs?: AutoClosingPairConditional[];
649
682
  comments?: CommentRule;
650
683
  folding?: FoldingRules;
651
- wordPattern?: string;
684
+ wordPattern?: string | RegExpOptions;
652
685
  onEnterRules?: OnEnterRule[];
653
686
  }
654
687
 
@@ -674,10 +707,10 @@ export interface DebuggerContribution extends PlatformSpecificAdapterContributio
674
707
  }
675
708
 
676
709
  export interface IndentationRules {
677
- increaseIndentPattern: string;
678
- decreaseIndentPattern: string;
679
- unIndentedLinePattern?: string;
680
- indentNextLinePattern?: string;
710
+ increaseIndentPattern: string | RegExpOptions;
711
+ decreaseIndentPattern: string | RegExpOptions;
712
+ unIndentedLinePattern?: string | RegExpOptions;
713
+ indentNextLinePattern?: string | RegExpOptions;
681
714
  }
682
715
  export interface AutoClosingPair {
683
716
  close: string;
@@ -689,8 +722,8 @@ export interface AutoClosingPairConditional extends AutoClosingPair {
689
722
  }
690
723
 
691
724
  export interface FoldingMarkers {
692
- start: string;
693
- end: string;
725
+ start: string | RegExpOptions;
726
+ end: string | RegExpOptions;
694
727
  }
695
728
 
696
729
  export interface FoldingRules {
@@ -699,9 +732,9 @@ export interface FoldingRules {
699
732
  }
700
733
 
701
734
  export interface OnEnterRule {
702
- beforeText: string;
703
- afterText?: string;
704
- previousLineText?: string;
735
+ beforeText: string | RegExpOptions;
736
+ afterText?: string | RegExpOptions;
737
+ previousLineText?: string | RegExpOptions;
705
738
  action: EnterAction;
706
739
  }
707
740
 
@@ -375,6 +375,7 @@ export class HostedPluginSupport {
375
375
  const loadPluginsMeasurement = this.measure('loadPlugins');
376
376
 
377
377
  const hostContributions = new Map<PluginHost, PluginContributions[]>();
378
+ console.log(`[${this.clientId}] Loading plugin contributions`);
378
379
  for (const contributions of this.contributions.values()) {
379
380
  const plugin = contributions.plugin.metadata;
380
381
  const pluginId = plugin.model.id;
@@ -384,7 +385,7 @@ export class HostedPluginSupport {
384
385
  contributions.push(Disposable.create(() => console.log(`[${pluginId}]: Unloaded plugin.`)));
385
386
  contributions.push(this.contributionHandler.handleContributions(this.clientId, contributions.plugin));
386
387
  contributions.state = PluginContributions.State.LOADED;
387
- console.log(`[${this.clientId}][${pluginId}]: Loaded contributions.`);
388
+ console.debug(`[${this.clientId}][${pluginId}]: Loaded contributions.`);
388
389
  loaded++;
389
390
  }
390
391
 
@@ -396,7 +397,7 @@ export class HostedPluginSupport {
396
397
  hostContributions.set(host, dynamicContributions);
397
398
  toDisconnect.push(Disposable.create(() => {
398
399
  contributions!.state = PluginContributions.State.LOADED;
399
- console.log(`[${this.clientId}][${pluginId}]: Disconnected.`);
400
+ console.debug(`[${this.clientId}][${pluginId}]: Disconnected.`);
400
401
  }));
401
402
  }
402
403
  }
@@ -446,14 +447,15 @@ export class HostedPluginSupport {
446
447
  if (toDisconnect.disposed) {
447
448
  return;
448
449
  }
450
+ console.log(`[${this.clientId}] Starting plugins.`);
449
451
  for (const contributions of hostContributions) {
450
452
  started++;
451
453
  const plugin = contributions.plugin;
452
454
  const id = plugin.metadata.model.id;
453
455
  contributions.state = PluginContributions.State.STARTED;
454
- console.log(`[${this.clientId}][${id}]: Started plugin.`);
456
+ console.debug(`[${this.clientId}][${id}]: Started plugin.`);
455
457
  toDisconnect.push(contributions.push(Disposable.create(() => {
456
- console.log(`[${this.clientId}][${id}]: Stopped plugin.`);
458
+ console.debug(`[${this.clientId}][${id}]: Stopped plugin.`);
457
459
  manager.$stop(id);
458
460
  })));
459
461
 
@@ -778,22 +780,15 @@ export class HostedPluginSupport {
778
780
  protected async restoreWebview(webview: WebviewWidget): Promise<void> {
779
781
  await this.activateByEvent(`onWebviewPanel:${webview.viewType}`);
780
782
  const restore = this.webviewRevivers.get(webview.viewType);
781
- if (!restore) {
782
- /* eslint-disable max-len */
783
- webview.setHTML(this.getDeserializationFailedContents(`
784
- <p>The extension providing '${webview.viewType}' view is not capable of restoring it.</p>
785
- <p>Want to help fix this? Please inform the extension developer to register a <a href="https://code.visualstudio.com/api/extension-guides/webview#serialization">reviver</a>.</p>
786
- `));
787
- /* eslint-enable max-len */
788
- return;
789
- }
790
- try {
791
- await restore(webview);
792
- } catch (e) {
793
- webview.setHTML(this.getDeserializationFailedContents(`
794
- An error occurred while restoring '${webview.viewType}' view. Please check logs.
795
- `));
796
- console.error('Failed to restore the webview', e);
783
+ if (restore) {
784
+ try {
785
+ await restore(webview);
786
+ } catch (e) {
787
+ webview.setHTML(this.getDeserializationFailedContents(`
788
+ An error occurred while restoring '${webview.viewType}' view. Please check logs.
789
+ `));
790
+ console.error('Failed to restore the webview', e);
791
+ }
797
792
  }
798
793
  }
799
794
 
@@ -176,7 +176,7 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
176
176
  deployed.contributes = this.reader.readContribution(manifest);
177
177
  this.localizationService.deployLocalizations(deployed);
178
178
  deployedPlugins.set(id, deployed);
179
- deployPlugin.log(`Deployed ${entryPoint} plugin "${id}" from "${metadata.model.entryPoint[entryPoint] || pluginPath}"`);
179
+ deployPlugin.debug(`Deployed ${entryPoint} plugin "${id}" from "${metadata.model.entryPoint[entryPoint] || pluginPath}"`);
180
180
  } catch (e) {
181
181
  deployPlugin.error(`Failed to deploy ${entryPoint} plugin from '${pluginPath}' path`, e);
182
182
  return success = false;
@@ -126,7 +126,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
126
126
  await waitForTerminated.promise;
127
127
  }
128
128
 
129
- this.killProcessTree(cp.pid);
129
+ this.killProcessTree(cp.pid!);
130
130
  }
131
131
 
132
132
  killProcessTree(parentPid: number): void {
@@ -206,7 +206,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
206
206
  childProcess.stderr!.on('data', data => this.logger.error(`[${options.serverName}: ${childProcess.pid}] ${data.toString().trim()}`));
207
207
 
208
208
  this.logger.debug(`[${options.serverName}: ${childProcess.pid}] IPC started`);
209
- childProcess.once('exit', (code: number, signal: string) => this.onChildProcessExit(options.serverName, childProcess.pid, code, signal));
209
+ childProcess.once('exit', (code: number, signal: string) => this.onChildProcessExit(options.serverName, childProcess.pid!, code, signal));
210
210
  childProcess.on('error', err => this.onChildProcessError(err));
211
211
  return childProcess;
212
212
  }
@@ -0,0 +1,111 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { flatten } from '../../common/arrays';
18
+ import { isStringArray, isObject } from '@theia/core/lib/common/types';
19
+ import {
20
+ PluginPackage,
21
+ PluginPackageAuthenticationProvider,
22
+ PluginPackageCommand,
23
+ PluginPackageCustomEditor,
24
+ PluginPackageLanguageContribution,
25
+ PluginPackageNotebook,
26
+ PluginPackageView
27
+ } from '../../common/plugin-protocol';
28
+
29
+ /**
30
+ * Most activation events can be automatically deduced from the package manifest.
31
+ * This function will update the manifest based on the plugin contributions.
32
+ */
33
+ export function updateActivationEvents(manifest: PluginPackage): void {
34
+ if (!isObject(manifest) || !isObject(manifest.contributes) || !manifest.contributes) {
35
+ return;
36
+ }
37
+
38
+ const activationEvents = new Set(isStringArray(manifest.activationEvents) ? manifest.activationEvents : []);
39
+
40
+ if (manifest.contributes.commands) {
41
+ const value = manifest.contributes.commands;
42
+ const commands = Array.isArray(value) ? value : [value];
43
+ updateCommandsContributions(commands, activationEvents);
44
+ }
45
+ if (Array.isArray(manifest.contributes.views)) {
46
+ const views = flatten(Object.values(manifest.contributes.views)) as PluginPackageView[];
47
+ updateViewsContribution(views, activationEvents);
48
+ }
49
+ if (Array.isArray(manifest.contributes.customEditors)) {
50
+ updateCustomEditorsContribution(manifest.contributes.customEditors, activationEvents);
51
+ }
52
+ if (Array.isArray(manifest.contributes.authentication)) {
53
+ updateAuthenticationProviderContributions(manifest.contributes.authentication, activationEvents);
54
+ }
55
+ if (Array.isArray(manifest.contributes.languages)) {
56
+ updateLanguageContributions(manifest.contributes.languages, activationEvents);
57
+ }
58
+ if (Array.isArray(manifest.contributes.notebooks)) {
59
+ updateNotebookContributions(manifest.contributes.notebooks, activationEvents);
60
+ }
61
+
62
+ manifest.activationEvents = Array.from(activationEvents);
63
+ }
64
+
65
+ function updateViewsContribution(views: PluginPackageView[], activationEvents: Set<string>): void {
66
+ for (const view of views) {
67
+ if (isObject(view) && typeof view.id === 'string') {
68
+ activationEvents.add(`onView:${view.id}`);
69
+ }
70
+ }
71
+ }
72
+
73
+ function updateCustomEditorsContribution(customEditors: PluginPackageCustomEditor[], activationEvents: Set<string>): void {
74
+ for (const customEditor of customEditors) {
75
+ if (isObject(customEditor) && typeof customEditor.viewType === 'string') {
76
+ activationEvents.add(`onCustomEditor:${customEditor.viewType}`);
77
+ }
78
+ }
79
+ }
80
+
81
+ function updateCommandsContributions(commands: PluginPackageCommand[], activationEvents: Set<string>): void {
82
+ for (const command of commands) {
83
+ if (isObject(command) && typeof command.command === 'string') {
84
+ activationEvents.add(`onCommand:${command.command}`);
85
+ }
86
+ }
87
+ }
88
+
89
+ function updateAuthenticationProviderContributions(authProviders: PluginPackageAuthenticationProvider[], activationEvents: Set<string>): void {
90
+ for (const authProvider of authProviders) {
91
+ if (isObject(authProvider) && typeof authProvider.id === 'string') {
92
+ activationEvents.add(`onAuthenticationRequest:${authProvider.id}`);
93
+ }
94
+ }
95
+ }
96
+
97
+ function updateLanguageContributions(languages: PluginPackageLanguageContribution[], activationEvents: Set<string>): void {
98
+ for (const language of languages) {
99
+ if (isObject(language) && typeof language.id === 'string') {
100
+ activationEvents.add(`onLanguage:${language.id}`);
101
+ }
102
+ }
103
+ }
104
+
105
+ function updateNotebookContributions(notebooks: PluginPackageNotebook[], activationEvents: Set<string>): void {
106
+ for (const notebook of notebooks) {
107
+ if (isObject(notebook) && typeof notebook.type === 'string') {
108
+ activationEvents.add(`onNotebookSerializer:${notebook.type}`);
109
+ }
110
+ }
111
+ }
@@ -91,7 +91,7 @@ export class PluginHostRPC {
91
91
 
92
92
  initContext(contextPath: string, plugin: Plugin): void {
93
93
  const { name, version } = plugin.rawModel;
94
- console.log('PLUGIN_HOST(' + process.pid + '): initializing(' + name + '@' + version + ' with ' + contextPath + ')');
94
+ console.debug('PLUGIN_HOST(' + process.pid + '): initializing(' + name + '@' + version + ' with ' + contextPath + ')');
95
95
  try {
96
96
  const backendInit = dynamicRequire<{ doInitialization: BackendInitializationFn }>(contextPath);
97
97
  backendInit.doInitialization(this.apiFactory, plugin);
@@ -111,7 +111,7 @@ export class PluginHostRPC {
111
111
  const pluginManager = new PluginManagerExtImpl({
112
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
113
  loadPlugin(plugin: Plugin): any {
114
- console.log('PLUGIN_HOST(' + process.pid + '): PluginManagerExtImpl/loadPlugin(' + plugin.pluginPath + ')');
114
+ console.debug('PLUGIN_HOST(' + process.pid + '): PluginManagerExtImpl/loadPlugin(' + plugin.pluginPath + ')');
115
115
  // cleaning the cache for all files of that plug-in.
116
116
  Object.keys(require.cache).forEach(function (key): void {
117
117
  const mod: NodeJS.Module = require.cache[key]!;
@@ -16,10 +16,10 @@
16
16
 
17
17
  import * as path from 'path';
18
18
  import * as fs from '@theia/core/shared/fs-extra';
19
- import { PluginIdentifiers } from '../../common';
19
+ import { PluginIdentifiers, PluginPackage } from '../../common';
20
+ import { updateActivationEvents } from './plugin-activation-events';
20
21
 
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- export async function loadManifest(pluginPath: string): Promise<any> {
22
+ export async function loadManifest(pluginPath: string): Promise<PluginPackage> {
23
23
  const manifest = await fs.readJson(path.join(pluginPath, 'package.json'));
24
24
  // translate vscode builtins, as they are published with a prefix. See https://github.com/theia-ide/vscode-builtin-extensions/blob/master/src/republish.js#L50
25
25
  const built_prefix = '@theia/vscode-builtin-';
@@ -27,5 +27,6 @@ export async function loadManifest(pluginPath: string): Promise<any> {
27
27
  manifest.name = manifest.name.substr(built_prefix.length);
28
28
  }
29
29
  manifest.publisher ??= PluginIdentifiers.UNPUBLISHED;
30
+ updateActivationEvents(manifest);
30
31
  return manifest;
31
32
  }
@@ -64,21 +64,15 @@ import {
64
64
  } from '../../../common/plugin-protocol';
65
65
  import * as fs from 'fs';
66
66
  import * as path from 'path';
67
- import { isObject } from 'util';
67
+ import { isObject, isStringArray, RecursivePartial } from '@theia/core/lib/common/types';
68
68
  import { GrammarsReader } from './grammars-reader';
69
69
  import { CharacterPair } from '../../../common/plugin-api-rpc';
70
70
  import * as jsoncparser from 'jsonc-parser';
71
71
  import { IJSONSchema } from '@theia/core/lib/common/json-schema';
72
72
  import { deepClone } from '@theia/core/lib/common/objects';
73
73
  import { PreferenceSchema, PreferenceSchemaProperties } from '@theia/core/lib/common/preferences/preference-schema';
74
- import { RecursivePartial } from '@theia/core/lib/common/types';
75
- import {
76
- ProblemMatcherContribution,
77
- ProblemPatternContribution,
78
- TaskDefinition
79
- } from '@theia/task/lib/common/task-protocol';
74
+ import { TaskDefinition } from '@theia/task/lib/common/task-protocol';
80
75
  import { ColorDefinition } from '@theia/core/lib/common/color';
81
- import { ResourceLabelFormatter } from '@theia/core/lib/common/label-protocol';
82
76
  import { PluginUriFactory } from './plugin-uri-factory';
83
77
 
84
78
  namespace nls {
@@ -181,42 +175,42 @@ export class TheiaPluginScanner implements PluginScanner {
181
175
  contributions.configurationDefaults = PreferenceSchemaProperties.is(configurationDefaults) ? configurationDefaults : undefined;
182
176
 
183
177
  try {
184
- if (rawPlugin.contributes!.languages) {
185
- const languages = this.readLanguages(rawPlugin.contributes.languages!, rawPlugin.packagePath);
178
+ if (rawPlugin.contributes.languages) {
179
+ const languages = this.readLanguages(rawPlugin.contributes.languages, rawPlugin.packagePath);
186
180
  contributions.languages = languages;
187
181
  }
188
182
  } catch (err) {
189
- console.error(`Could not read '${rawPlugin.name}' contribution 'languages'.`, rawPlugin.contributes!.languages, err);
183
+ console.error(`Could not read '${rawPlugin.name}' contribution 'languages'.`, rawPlugin.contributes.languages, err);
190
184
  }
191
185
 
192
186
  try {
193
- if (rawPlugin.contributes!.submenus) {
194
- contributions.submenus = this.readSubmenus(rawPlugin.contributes.submenus!, rawPlugin);
187
+ if (rawPlugin.contributes.submenus) {
188
+ contributions.submenus = this.readSubmenus(rawPlugin.contributes.submenus, rawPlugin);
195
189
  }
196
190
  } catch (err) {
197
- console.error(`Could not read '${rawPlugin.name}' contribution 'submenus'.`, rawPlugin.contributes!.submenus, err);
191
+ console.error(`Could not read '${rawPlugin.name}' contribution 'submenus'.`, rawPlugin.contributes.submenus, err);
198
192
  }
199
193
 
200
194
  try {
201
- if (rawPlugin.contributes!.grammars) {
202
- const grammars = this.grammarsReader.readGrammars(rawPlugin.contributes.grammars!, rawPlugin.packagePath);
195
+ if (rawPlugin.contributes.grammars) {
196
+ const grammars = this.grammarsReader.readGrammars(rawPlugin.contributes.grammars, rawPlugin.packagePath);
203
197
  contributions.grammars = grammars;
204
198
  }
205
199
  } catch (err) {
206
- console.error(`Could not read '${rawPlugin.name}' contribution 'grammars'.`, rawPlugin.contributes!.grammars, err);
200
+ console.error(`Could not read '${rawPlugin.name}' contribution 'grammars'.`, rawPlugin.contributes.grammars, err);
207
201
  }
208
202
 
209
203
  try {
210
- if (rawPlugin.contributes?.customEditors) {
211
- const customEditors = this.readCustomEditors(rawPlugin.contributes.customEditors!);
204
+ if (rawPlugin.contributes.customEditors) {
205
+ const customEditors = this.readCustomEditors(rawPlugin.contributes.customEditors);
212
206
  contributions.customEditors = customEditors;
213
207
  }
214
208
  } catch (err) {
215
- console.error(`Could not read '${rawPlugin.name}' contribution 'customEditors'.`, rawPlugin.contributes!.customEditors, err);
209
+ console.error(`Could not read '${rawPlugin.name}' contribution 'customEditors'.`, rawPlugin.contributes.customEditors, err);
216
210
  }
217
211
 
218
212
  try {
219
- if (rawPlugin.contributes && rawPlugin.contributes.viewsContainers) {
213
+ if (rawPlugin.contributes.viewsContainers) {
220
214
  const viewsContainers = rawPlugin.contributes.viewsContainers;
221
215
  contributions.viewsContainers = {};
222
216
 
@@ -231,28 +225,28 @@ export class TheiaPluginScanner implements PluginScanner {
231
225
  }
232
226
  }
233
227
  } catch (err) {
234
- console.error(`Could not read '${rawPlugin.name}' contribution 'viewsContainers'.`, rawPlugin.contributes!.viewsContainers, err);
228
+ console.error(`Could not read '${rawPlugin.name}' contribution 'viewsContainers'.`, rawPlugin.contributes.viewsContainers, err);
235
229
  }
236
230
 
237
231
  try {
238
- if (rawPlugin.contributes!.views) {
232
+ if (rawPlugin.contributes.views) {
239
233
  contributions.views = {};
240
234
 
241
- Object.keys(rawPlugin.contributes.views!).forEach(location => {
242
- const views = this.readViews(rawPlugin.contributes!.views![location]);
243
- contributions.views![location] = views;
244
- });
235
+ for (const location of Object.keys(rawPlugin.contributes.views)) {
236
+ const views = this.readViews(rawPlugin.contributes.views[location]);
237
+ contributions.views[location] = views;
238
+ }
245
239
  }
246
240
  } catch (err) {
247
- console.error(`Could not read '${rawPlugin.name}' contribution 'views'.`, rawPlugin.contributes!.views, err);
241
+ console.error(`Could not read '${rawPlugin.name}' contribution 'views'.`, rawPlugin.contributes.views, err);
248
242
  }
249
243
 
250
244
  try {
251
- if (rawPlugin.contributes!.viewsWelcome) {
252
- contributions.viewsWelcome = this.readViewsWelcome(rawPlugin.contributes!.viewsWelcome, rawPlugin.contributes!.views);
245
+ if (rawPlugin.contributes.viewsWelcome) {
246
+ contributions.viewsWelcome = this.readViewsWelcome(rawPlugin.contributes!.viewsWelcome, rawPlugin.contributes.views);
253
247
  }
254
248
  } catch (err) {
255
- console.error(`Could not read '${rawPlugin.name}' contribution 'viewsWelcome'.`, rawPlugin.contributes!.viewsWelcome, err);
249
+ console.error(`Could not read '${rawPlugin.name}' contribution 'viewsWelcome'.`, rawPlugin.contributes.viewsWelcome, err);
256
250
  }
257
251
 
258
252
  try {
@@ -266,67 +260,73 @@ export class TheiaPluginScanner implements PluginScanner {
266
260
  }
267
261
 
268
262
  try {
269
- if (rawPlugin.contributes!.menus) {
263
+ if (rawPlugin.contributes.menus) {
270
264
  contributions.menus = {};
271
265
 
272
- Object.keys(rawPlugin.contributes.menus!).forEach(location => {
273
- const menus = this.readMenus(rawPlugin.contributes!.menus![location]);
274
- contributions.menus![location] = menus;
275
- });
266
+ for (const location of Object.keys(rawPlugin.contributes.menus)) {
267
+ const menus = this.readMenus(rawPlugin.contributes.menus[location]);
268
+ contributions.menus[location] = menus;
269
+ }
276
270
  }
277
271
  } catch (err) {
278
- console.error(`Could not read '${rawPlugin.name}' contribution 'menus'.`, rawPlugin.contributes!.menus, err);
272
+ console.error(`Could not read '${rawPlugin.name}' contribution 'menus'.`, rawPlugin.contributes.menus, err);
279
273
  }
280
274
 
281
275
  try {
282
- if (rawPlugin.contributes! && rawPlugin.contributes.keybindings) {
276
+ if (rawPlugin.contributes.keybindings) {
283
277
  const rawKeybindings = Array.isArray(rawPlugin.contributes.keybindings) ? rawPlugin.contributes.keybindings : [rawPlugin.contributes.keybindings];
284
278
  contributions.keybindings = rawKeybindings.map(rawKeybinding => this.readKeybinding(rawKeybinding));
285
279
  }
286
280
  } catch (err) {
287
- console.error(`Could not read '${rawPlugin.name}' contribution 'keybindings'.`, rawPlugin.contributes!.keybindings, err);
281
+ console.error(`Could not read '${rawPlugin.name}' contribution 'keybindings'.`, rawPlugin.contributes.keybindings, err);
288
282
  }
289
283
 
290
284
  try {
291
- if (rawPlugin.contributes!.debuggers) {
292
- const debuggers = this.readDebuggers(rawPlugin.contributes.debuggers!);
285
+ if (rawPlugin.contributes.debuggers) {
286
+ const debuggers = this.readDebuggers(rawPlugin.contributes.debuggers);
293
287
  contributions.debuggers = debuggers;
294
288
  }
295
289
  } catch (err) {
296
- console.error(`Could not read '${rawPlugin.name}' contribution 'debuggers'.`, rawPlugin.contributes!.debuggers, err);
290
+ console.error(`Could not read '${rawPlugin.name}' contribution 'debuggers'.`, rawPlugin.contributes.debuggers, err);
297
291
  }
298
292
 
299
293
  try {
300
- if (rawPlugin.contributes!.taskDefinitions) {
301
- const definitions = rawPlugin.contributes!.taskDefinitions!;
294
+ if (rawPlugin.contributes.taskDefinitions) {
295
+ const definitions = rawPlugin.contributes.taskDefinitions!;
302
296
  contributions.taskDefinitions = definitions.map(definitionContribution => this.readTaskDefinition(rawPlugin.name, definitionContribution));
303
297
  }
304
298
  } catch (err) {
305
- console.error(`Could not read '${rawPlugin.name}' contribution 'taskDefinitions'.`, rawPlugin.contributes!.taskDefinitions, err);
299
+ console.error(`Could not read '${rawPlugin.name}' contribution 'taskDefinitions'.`, rawPlugin.contributes.taskDefinitions, err);
306
300
  }
307
301
 
308
302
  try {
309
- if (rawPlugin.contributes!.problemMatchers) {
310
- contributions.problemMatchers = rawPlugin.contributes!.problemMatchers as ProblemMatcherContribution[];
311
- }
303
+ contributions.problemMatchers = rawPlugin.contributes.problemMatchers;
312
304
  } catch (err) {
313
- console.error(`Could not read '${rawPlugin.name}' contribution 'problemMatchers'.`, rawPlugin.contributes!.problemMatchers, err);
305
+ console.error(`Could not read '${rawPlugin.name}' contribution 'problemMatchers'.`, rawPlugin.contributes.problemMatchers, err);
314
306
  }
315
307
 
316
308
  try {
317
- if (rawPlugin.contributes!.problemPatterns) {
318
- contributions.problemPatterns = rawPlugin.contributes!.problemPatterns as ProblemPatternContribution[];
319
- }
309
+ contributions.problemPatterns = rawPlugin.contributes.problemPatterns;
320
310
  } catch (err) {
321
- console.error(`Could not read '${rawPlugin.name}' contribution 'problemPatterns'.`, rawPlugin.contributes!.problemPatterns, err);
311
+ console.error(`Could not read '${rawPlugin.name}' contribution 'problemPatterns'.`, rawPlugin.contributes.problemPatterns, err);
322
312
  }
323
313
 
324
314
  try {
325
- if (rawPlugin.contributes!.resourceLabelFormatters) {
326
- contributions.resourceLabelFormatters = rawPlugin.contributes!.resourceLabelFormatters as ResourceLabelFormatter[];
327
- }
315
+ contributions.resourceLabelFormatters = rawPlugin.contributes.resourceLabelFormatters;
316
+ } catch (err) {
317
+ console.error(`Could not read '${rawPlugin.name}' contribution 'resourceLabelFormatters'.`, rawPlugin.contributes.resourceLabelFormatters, err);
318
+ }
319
+
320
+ try {
321
+ contributions.authentication = rawPlugin.contributes.authentication;
322
+ } catch (err) {
323
+ console.error(`Could not read '${rawPlugin.name}' contribution 'authentication'.`, rawPlugin.contributes.authentication, err);
324
+ }
325
+
326
+ try {
327
+ contributions.notebooks = rawPlugin.contributes.notebooks;
328
328
  } catch (err) {
329
- console.error(`Could not read '${rawPlugin.name}' contribution 'resourceLabelFormatters'.`, rawPlugin.contributes!.resourceLabelFormatters, err);
329
+ console.error(`Could not read '${rawPlugin.name}' contribution 'notebooks'.`, rawPlugin.contributes.authentication, err);
330
330
  }
331
331
 
332
332
  try {
@@ -837,7 +837,6 @@ export class TheiaPluginScanner implements PluginScanner {
837
837
  }
838
838
 
839
839
  let result: AutoClosingPairConditional[] | undefined = undefined;
840
- // tslint:disable-next-line:one-variable-per-declaration
841
840
  for (let i = 0, len = source.length; i < len; i++) {
842
841
  const pair = source[i];
843
842
  if (Array.isArray(pair)) {
@@ -861,7 +860,7 @@ export class TheiaPluginScanner implements PluginScanner {
861
860
  continue;
862
861
  }
863
862
  if (typeof pair.notIn !== 'undefined') {
864
- if (!isStringArr(pair.notIn)) {
863
+ if (!isStringArray(pair.notIn)) {
865
864
  console.warn(`[${langId}]: language configuration: expected \`autoClosingPairs[${i}].notIn\` to be a string array.`);
866
865
  continue;
867
866
  }
@@ -884,7 +883,6 @@ export class TheiaPluginScanner implements PluginScanner {
884
883
  }
885
884
 
886
885
  let result: AutoClosingPair[] | undefined = undefined;
887
- // tslint:disable-next-line:one-variable-per-declaration
888
886
  for (let i = 0, len = source.length; i < len; i++) {
889
887
  const pair = source[i];
890
888
  if (Array.isArray(pair)) {
@@ -918,21 +916,7 @@ export class TheiaPluginScanner implements PluginScanner {
918
916
 
919
917
  function isCharacterPair(something: CharacterPair): boolean {
920
918
  return (
921
- isStringArr(something)
919
+ isStringArray(something)
922
920
  && something.length === 2
923
921
  );
924
922
  }
925
-
926
- function isStringArr(something: string[]): boolean {
927
- if (!Array.isArray(something)) {
928
- return false;
929
- }
930
- // tslint:disable-next-line:one-variable-per-declaration
931
- for (let i = 0, len = something.length; i < len; i++) {
932
- if (typeof something[i] !== 'string') {
933
- return false;
934
- }
935
- }
936
- return true;
937
-
938
- }