@theia/plugin-ext 1.34.0 → 1.35.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 (123) 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 +11 -6
  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 +30 -0
  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 +10 -17
  12. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  13. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  14. package/lib/hosted/node/plugin-activation-events.d.ts +7 -0
  15. package/lib/hosted/node/plugin-activation-events.d.ts.map +1 -0
  16. package/lib/hosted/node/plugin-activation-events.js +96 -0
  17. package/lib/hosted/node/plugin-activation-events.js.map +1 -0
  18. package/lib/hosted/node/plugin-manifest-loader.d.ts +2 -1
  19. package/lib/hosted/node/plugin-manifest-loader.d.ts.map +1 -1
  20. package/lib/hosted/node/plugin-manifest-loader.js +2 -1
  21. package/lib/hosted/node/plugin-manifest-loader.js.map +1 -1
  22. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  23. package/lib/hosted/node/scanners/scanner-theia.js +27 -36
  24. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  25. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts +9 -0
  26. package/lib/main/browser/data-transfer/data-transfer-type-converters.d.ts.map +1 -0
  27. package/lib/main/browser/data-transfer/data-transfer-type-converters.js +65 -0
  28. package/lib/main/browser/data-transfer/data-transfer-type-converters.js.map +1 -0
  29. package/lib/main/browser/dialogs/modal-notification.d.ts.map +1 -1
  30. package/lib/main/browser/dialogs/modal-notification.js +4 -2
  31. package/lib/main/browser/dialogs/modal-notification.js.map +1 -1
  32. package/lib/main/browser/languages-main.d.ts +8 -1
  33. package/lib/main/browser/languages-main.d.ts.map +1 -1
  34. package/lib/main/browser/languages-main.js +26 -2
  35. package/lib/main/browser/languages-main.js.map +1 -1
  36. package/lib/main/browser/main-context.d.ts.map +1 -1
  37. package/lib/main/browser/main-context.js +3 -0
  38. package/lib/main/browser/main-context.js.map +1 -1
  39. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  40. package/lib/main/browser/plugin-ext-frontend-module.js +3 -0
  41. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  42. package/lib/main/browser/tabs/tabs-main.d.ts +33 -2
  43. package/lib/main/browser/tabs/tabs-main.d.ts.map +1 -1
  44. package/lib/main/browser/tabs/tabs-main.js +256 -6
  45. package/lib/main/browser/tabs/tabs-main.js.map +1 -1
  46. package/lib/main/browser/text-editors-main.d.ts +2 -2
  47. package/lib/main/browser/text-editors-main.d.ts.map +1 -1
  48. package/lib/main/browser/text-editors-main.js +2 -2
  49. package/lib/main/browser/text-editors-main.js.map +1 -1
  50. package/lib/main/browser/webview/webview-context-keys.d.ts +13 -0
  51. package/lib/main/browser/webview/webview-context-keys.d.ts.map +1 -0
  52. package/lib/main/browser/webview/webview-context-keys.js +64 -0
  53. package/lib/main/browser/webview/webview-context-keys.js.map +1 -0
  54. package/lib/plugin/dialogs.js +2 -2
  55. package/lib/plugin/dialogs.js.map +1 -1
  56. package/lib/plugin/file-system-ext-impl.d.ts +11 -5
  57. package/lib/plugin/file-system-ext-impl.d.ts.map +1 -1
  58. package/lib/plugin/file-system-ext-impl.js +8 -16
  59. package/lib/plugin/file-system-ext-impl.js.map +1 -1
  60. package/lib/plugin/known-commands.d.ts.map +1 -1
  61. package/lib/plugin/known-commands.js +13 -0
  62. package/lib/plugin/known-commands.js.map +1 -1
  63. package/lib/plugin/languages/document-drop-edit.d.ts +16 -0
  64. package/lib/plugin/languages/document-drop-edit.d.ts.map +1 -0
  65. package/lib/plugin/languages/document-drop-edit.js +23 -0
  66. package/lib/plugin/languages/document-drop-edit.js.map +1 -0
  67. package/lib/plugin/languages.d.ts +9 -2
  68. package/lib/plugin/languages.d.ts.map +1 -1
  69. package/lib/plugin/languages.js +27 -1
  70. package/lib/plugin/languages.js.map +1 -1
  71. package/lib/plugin/plugin-context.d.ts.map +1 -1
  72. package/lib/plugin/plugin-context.js +8 -4
  73. package/lib/plugin/plugin-context.js.map +1 -1
  74. package/lib/plugin/preference-registry.d.ts +5 -3
  75. package/lib/plugin/preference-registry.d.ts.map +1 -1
  76. package/lib/plugin/preference-registry.js +31 -42
  77. package/lib/plugin/preference-registry.js.map +1 -1
  78. package/lib/plugin/preference-registry.spec.js +29 -41
  79. package/lib/plugin/preference-registry.spec.js.map +1 -1
  80. package/lib/plugin/tabs.d.ts.map +1 -1
  81. package/lib/plugin/tabs.js +10 -13
  82. package/lib/plugin/tabs.js.map +1 -1
  83. package/lib/plugin/text-editors.d.ts +1 -1
  84. package/lib/plugin/text-editors.d.ts.map +1 -1
  85. package/lib/plugin/text-editors.js +2 -2
  86. package/lib/plugin/text-editors.js.map +1 -1
  87. package/lib/plugin/type-converters.d.ts +6 -0
  88. package/lib/plugin/type-converters.d.ts.map +1 -1
  89. package/lib/plugin/type-converters.js +37 -1
  90. package/lib/plugin/type-converters.js.map +1 -1
  91. package/lib/plugin/types-impl.d.ts +5 -0
  92. package/lib/plugin/types-impl.d.ts.map +1 -1
  93. package/lib/plugin/types-impl.js +13 -3
  94. package/lib/plugin/types-impl.js.map +1 -1
  95. package/package.json +27 -26
  96. package/src/common/plugin-api-rpc-model.ts +22 -1
  97. package/src/common/plugin-api-rpc.ts +19 -6
  98. package/src/common/plugin-protocol.ts +32 -4
  99. package/src/hosted/browser/hosted-plugin.ts +9 -16
  100. package/src/hosted/node/hosted-plugin-process.ts +2 -2
  101. package/src/hosted/node/plugin-activation-events.ts +111 -0
  102. package/src/hosted/node/plugin-manifest-loader.ts +4 -3
  103. package/src/hosted/node/scanners/scanner-theia.ts +59 -75
  104. package/src/main/browser/data-transfer/data-transfer-type-converters.ts +70 -0
  105. package/src/main/browser/dialogs/modal-notification.ts +4 -2
  106. package/src/main/browser/languages-main.ts +34 -4
  107. package/src/main/browser/main-context.ts +4 -0
  108. package/src/main/browser/plugin-ext-frontend-module.ts +3 -0
  109. package/src/main/browser/tabs/tabs-main.ts +287 -6
  110. package/src/main/browser/text-editors-main.ts +3 -2
  111. package/src/main/browser/webview/webview-context-keys.ts +49 -0
  112. package/src/plugin/dialogs.ts +2 -2
  113. package/src/plugin/file-system-ext-impl.ts +8 -18
  114. package/src/plugin/known-commands.ts +16 -1
  115. package/src/plugin/languages/document-drop-edit.ts +44 -0
  116. package/src/plugin/languages.ts +41 -3
  117. package/src/plugin/plugin-context.ts +9 -4
  118. package/src/plugin/preference-registry.spec.ts +29 -45
  119. package/src/plugin/preference-registry.ts +33 -45
  120. package/src/plugin/tabs.ts +10 -14
  121. package/src/plugin/text-editors.ts +2 -2
  122. package/src/plugin/type-converters.ts +37 -0
  123. package/src/plugin/types-impl.ts +11 -0
package/package.json CHANGED
@@ -1,34 +1,35 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
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.34.0",
9
- "@theia/callhierarchy": "1.34.0",
10
- "@theia/console": "1.34.0",
11
- "@theia/core": "1.34.0",
12
- "@theia/debug": "1.34.0",
13
- "@theia/editor": "1.34.0",
14
- "@theia/file-search": "1.34.0",
15
- "@theia/filesystem": "1.34.0",
16
- "@theia/markers": "1.34.0",
17
- "@theia/messages": "1.34.0",
18
- "@theia/monaco": "1.34.0",
8
+ "@theia/bulk-edit": "1.35.0",
9
+ "@theia/callhierarchy": "1.35.0",
10
+ "@theia/console": "1.35.0",
11
+ "@theia/core": "1.35.0",
12
+ "@theia/debug": "1.35.0",
13
+ "@theia/editor": "1.35.0",
14
+ "@theia/editor-preview": "1.35.0",
15
+ "@theia/file-search": "1.35.0",
16
+ "@theia/filesystem": "1.35.0",
17
+ "@theia/markers": "1.35.0",
18
+ "@theia/messages": "1.35.0",
19
+ "@theia/monaco": "1.35.0",
19
20
  "@theia/monaco-editor-core": "1.72.3",
20
- "@theia/navigator": "1.34.0",
21
- "@theia/output": "1.34.0",
22
- "@theia/plugin": "1.34.0",
23
- "@theia/preferences": "1.34.0",
24
- "@theia/scm": "1.34.0",
25
- "@theia/search-in-workspace": "1.34.0",
26
- "@theia/task": "1.34.0",
27
- "@theia/terminal": "1.34.0",
28
- "@theia/timeline": "1.34.0",
29
- "@theia/typehierarchy": "1.34.0",
30
- "@theia/variable-resolver": "1.34.0",
31
- "@theia/workspace": "1.34.0",
21
+ "@theia/navigator": "1.35.0",
22
+ "@theia/output": "1.35.0",
23
+ "@theia/plugin": "1.35.0",
24
+ "@theia/preferences": "1.35.0",
25
+ "@theia/scm": "1.35.0",
26
+ "@theia/search-in-workspace": "1.35.0",
27
+ "@theia/task": "1.35.0",
28
+ "@theia/terminal": "1.35.0",
29
+ "@theia/timeline": "1.35.0",
30
+ "@theia/typehierarchy": "1.35.0",
31
+ "@theia/variable-resolver": "1.35.0",
32
+ "@theia/workspace": "1.35.0",
32
33
  "@types/mime": "^2.0.1",
33
34
  "@vscode/debugprotocol": "^1.51.0",
34
35
  "decompress": "^4.2.1",
@@ -85,7 +86,7 @@
85
86
  "watch": "theiaext watch"
86
87
  },
87
88
  "devDependencies": {
88
- "@theia/ext-scripts": "1.34.0",
89
+ "@theia/ext-scripts": "1.35.0",
89
90
  "@types/decompress": "^4.2.2",
90
91
  "@types/escape-html": "^0.0.20",
91
92
  "@types/lodash.clonedeep": "^4.5.3",
@@ -95,5 +96,5 @@
95
96
  "nyc": {
96
97
  "extends": "../../configs/nyc.json"
97
98
  },
98
- "gitHead": "a8c403b103829a1b8b092ce741ef3826804f773b"
99
+ "gitHead": "5b1e4f9b913cf1b0d27acd4bc435cb2570f164d8"
99
100
  }
@@ -18,7 +18,7 @@ import * as theia from '@theia/plugin';
18
18
  import type * as monaco from '@theia/monaco-editor-core';
19
19
  import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/markdown-rendering';
20
20
  import { UriComponents } from './uri-components';
21
- import { CompletionItemTag } from '../plugin/types-impl';
21
+ import { CompletionItemTag, SnippetString } from '../plugin/types-impl';
22
22
  import { Event as TheiaEvent } from '@theia/core/lib/common/event';
23
23
  import { URI } from '@theia/core/shared/vscode-uri';
24
24
  import { SerializedRegExp } from './plugin-api-rpc';
@@ -324,6 +324,27 @@ export interface TextEdit {
324
324
  eol?: monaco.editor.EndOfLineSequence;
325
325
  }
326
326
 
327
+ export interface DocumentDropEdit {
328
+ insertText: string | SnippetString;
329
+ additionalEdit?: WorkspaceEdit;
330
+ }
331
+
332
+ export interface DataTransferFileDTO {
333
+ readonly name: string;
334
+ readonly uri?: UriComponents;
335
+ }
336
+
337
+ export interface DataTransferItemDTO {
338
+ readonly id: string;
339
+ readonly asString: string;
340
+ readonly fileData: DataTransferFileDTO | undefined;
341
+ readonly uriListData?: ReadonlyArray<string | UriComponents>;
342
+ }
343
+
344
+ export interface DataTransferDTO {
345
+ readonly items: Array<[/* type */string, DataTransferItemDTO]>;
346
+ }
347
+
327
348
  export interface Location {
328
349
  uri: UriComponents;
329
350
  range: Range;
@@ -84,7 +84,9 @@ import {
84
84
  TypeHierarchyItem,
85
85
  InlineCompletion,
86
86
  InlineCompletions,
87
- InlineCompletionContext
87
+ InlineCompletionContext,
88
+ DocumentDropEdit,
89
+ DataTransferDTO
88
90
  } from './plugin-api-rpc-model';
89
91
  import { ExtPluginApi } from './plugin-ext-api-contribution';
90
92
  import { KeysToAnyValues, KeysToKeysToAnyValue } from './types';
@@ -1244,7 +1246,7 @@ export interface TextEditorsMain {
1244
1246
  $tryRevealRange(id: string, range: Range, revealType: TextEditorRevealType): Promise<void>;
1245
1247
  $trySetSelections(id: string, selections: Selection[]): Promise<void>;
1246
1248
  $tryApplyEdits(id: string, modelVersionId: number, edits: SingleEditOperation[], opts: ApplyEditsOptions): Promise<boolean>;
1247
- $tryApplyWorkspaceEdit(workspaceEditDto: WorkspaceEditDto): Promise<boolean>;
1249
+ $tryApplyWorkspaceEdit(workspaceEditDto: WorkspaceEditDto, metadata?: WorkspaceEditMetadataDto): Promise<boolean>;
1248
1250
  $tryInsertSnippet(id: string, template: string, selections: Range[], opts: UndoStopOptions): Promise<boolean>;
1249
1251
  $saveAll(includeUntitled?: boolean): Promise<boolean>;
1250
1252
  // $getDiffInformation(id: string): Promise<editorCommon.ILineChange[]>;
@@ -1416,7 +1418,7 @@ export interface CodeActionDto {
1416
1418
  disabled?: string;
1417
1419
  }
1418
1420
 
1419
- export interface WorkspaceEditMetadataDto {
1421
+ export interface WorkspaceEditEntryMetadataDto {
1420
1422
  needsConfirmation: boolean;
1421
1423
  label: string;
1422
1424
  description?: string;
@@ -1432,14 +1434,14 @@ export interface WorkspaceFileEditDto {
1432
1434
  oldResource?: UriComponents;
1433
1435
  newResource?: UriComponents;
1434
1436
  options?: FileOperationOptions;
1435
- metadata?: WorkspaceEditMetadataDto;
1437
+ metadata?: WorkspaceEditEntryMetadataDto;
1436
1438
  }
1437
1439
 
1438
1440
  export interface WorkspaceTextEditDto {
1439
1441
  resource: UriComponents;
1440
1442
  modelVersionId?: number;
1441
1443
  textEdit: TextEdit & { insertAsSnippet?: boolean };
1442
- metadata?: WorkspaceEditMetadataDto;
1444
+ metadata?: WorkspaceEditEntryMetadataDto;
1443
1445
  }
1444
1446
  export namespace WorkspaceTextEditDto {
1445
1447
  export function is(arg: WorkspaceTextEditDto | WorkspaceFileEditDto): arg is WorkspaceTextEditDto {
@@ -1450,6 +1452,9 @@ export namespace WorkspaceTextEditDto {
1450
1452
  && typeof arg.textEdit === 'object';
1451
1453
  }
1452
1454
  }
1455
+ export interface WorkspaceEditMetadataDto {
1456
+ isRefactoring?: boolean;
1457
+ }
1453
1458
 
1454
1459
  export interface WorkspaceEditDto {
1455
1460
  edits: Array<WorkspaceTextEditDto | WorkspaceFileEditDto>;
@@ -1557,6 +1562,13 @@ export interface LanguagesExt {
1557
1562
  options: FormattingOptions,
1558
1563
  token: CancellationToken
1559
1564
  ): Promise<TextEdit[] | undefined>;
1565
+ $provideDocumentDropEdits(
1566
+ handle: number,
1567
+ resource: UriComponents,
1568
+ position: Position,
1569
+ dataTransfer: DataTransferDTO,
1570
+ token: CancellationToken
1571
+ ): Promise<DocumentDropEdit | undefined>;
1560
1572
  $provideDocumentLinks(handle: number, resource: UriComponents, token: CancellationToken): Promise<DocumentLink[] | undefined>;
1561
1573
  $resolveDocumentLink(handle: number, link: DocumentLink, token: CancellationToken): Promise<DocumentLink | undefined>;
1562
1574
  $releaseDocumentLinks(handle: number, ids: number[]): void;
@@ -1637,6 +1649,7 @@ export interface LanguagesMain {
1637
1649
  $clearDiagnostics(id: string): void;
1638
1650
  $changeDiagnostics(id: string, delta: [string, MarkerData[]][]): void;
1639
1651
  $registerDocumentFormattingSupport(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
1652
+ $registerDocumentDropEditProvider(handle: number, selector: SerializedDocumentFilter[]): void
1640
1653
  $registerRangeFormattingSupport(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
1641
1654
  $registerOnTypeFormattingProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void;
1642
1655
  $registerDocumentLinkProvider(handle: number, pluginInfo: PluginInfo, selector: SerializedDocumentFilter[]): void;
@@ -2037,7 +2050,7 @@ export interface TabOperation {
2037
2050
  export interface TabDto {
2038
2051
  id: string;
2039
2052
  label: string;
2040
- input: any;
2053
+ input: AnyInputDto;
2041
2054
  editorId?: string;
2042
2055
  isActive: boolean;
2043
2056
  isPinned: boolean;
@@ -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 {
@@ -778,22 +778,15 @@ export class HostedPluginSupport {
778
778
  protected async restoreWebview(webview: WebviewWidget): Promise<void> {
779
779
  await this.activateByEvent(`onWebviewPanel:${webview.viewType}`);
780
780
  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);
781
+ if (restore) {
782
+ try {
783
+ await restore(webview);
784
+ } catch (e) {
785
+ webview.setHTML(this.getDeserializationFailedContents(`
786
+ An error occurred while restoring '${webview.viewType}' view. Please check logs.
787
+ `));
788
+ console.error('Failed to restore the webview', e);
789
+ }
797
790
  }
798
791
  }
799
792
 
@@ -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
+ }
@@ -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
  }