@theia/plugin-ext 1.18.0 → 1.21.0-next.12

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 (264) hide show
  1. package/README.md +5 -0
  2. package/lib/common/connection.d.ts +47 -34
  3. package/lib/common/connection.d.ts.map +1 -1
  4. package/lib/common/connection.js +90 -28
  5. package/lib/common/connection.js.map +1 -1
  6. package/lib/common/plugin-api-rpc-model.d.ts +2 -0
  7. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  8. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  9. package/lib/common/plugin-api-rpc.d.ts +10 -11
  10. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  11. package/lib/common/plugin-api-rpc.js.map +1 -1
  12. package/lib/common/plugin-protocol.d.ts +3 -1
  13. package/lib/common/plugin-protocol.d.ts.map +1 -1
  14. package/lib/common/plugin-protocol.js.map +1 -1
  15. package/lib/hosted/browser/hosted-plugin.d.ts +4 -5
  16. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  17. package/lib/hosted/browser/hosted-plugin.js +18 -14
  18. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  19. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts +1 -1
  20. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts.map +1 -1
  21. package/lib/hosted/node/hosted-plugin-deployer-handler.js +14 -38
  22. package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
  23. package/lib/hosted/node/hosted-plugin-localization-service.d.ts +37 -0
  24. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -0
  25. package/lib/hosted/node/hosted-plugin-localization-service.js +197 -0
  26. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -0
  27. package/lib/hosted/node/hosted-plugin-process.d.ts +2 -2
  28. package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
  29. package/lib/hosted/node/hosted-plugin-process.js +5 -7
  30. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  31. package/lib/hosted/node/plugin-ext-hosted-backend-module.d.ts.map +1 -1
  32. package/lib/hosted/node/plugin-ext-hosted-backend-module.js +2 -0
  33. package/lib/hosted/node/plugin-ext-hosted-backend-module.js.map +1 -1
  34. package/lib/hosted/node/plugin-manifest-loader.d.ts +1 -1
  35. package/lib/hosted/node/plugin-manifest-loader.d.ts.map +1 -1
  36. package/lib/hosted/node/plugin-manifest-loader.js +4 -52
  37. package/lib/hosted/node/plugin-manifest-loader.js.map +1 -1
  38. package/lib/hosted/node/plugin-service.d.ts +3 -6
  39. package/lib/hosted/node/plugin-service.d.ts.map +1 -1
  40. package/lib/hosted/node/plugin-service.js +7 -40
  41. package/lib/hosted/node/plugin-service.js.map +1 -1
  42. package/lib/hosted/node/scanners/scanner-theia.d.ts +1 -1
  43. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  44. package/lib/hosted/node/scanners/scanner-theia.js +5 -1
  45. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  46. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.d.ts.map +1 -1
  47. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.js +5 -2
  48. package/lib/main/browser/callhierarchy/callhierarchy-type-converters.js.map +1 -1
  49. package/lib/main/browser/custom-editors/custom-editor-opener.d.ts +1 -2
  50. package/lib/main/browser/custom-editors/custom-editor-opener.d.ts.map +1 -1
  51. package/lib/main/browser/custom-editors/custom-editor-opener.js.map +1 -1
  52. package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
  53. package/lib/main/browser/custom-editors/custom-editors-main.js +1 -2
  54. package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
  55. package/lib/main/browser/debug/debug-main.d.ts +3 -3
  56. package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
  57. package/lib/main/browser/debug/debug-main.js +2 -3
  58. package/lib/main/browser/debug/debug-main.js.map +1 -1
  59. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +6 -6
  60. package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
  61. package/lib/main/browser/debug/plugin-debug-session-factory.js +1 -1
  62. package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
  63. package/lib/main/browser/dialogs/modal-notification.d.ts +3 -3
  64. package/lib/main/browser/dialogs/modal-notification.d.ts.map +1 -1
  65. package/lib/main/browser/dialogs/modal-notification.js +17 -6
  66. package/lib/main/browser/dialogs/modal-notification.js.map +1 -1
  67. package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
  68. package/lib/main/browser/editors-and-documents-main.js +3 -4
  69. package/lib/main/browser/editors-and-documents-main.js.map +1 -1
  70. package/lib/main/browser/file-system-main-impl.js +1 -1
  71. package/lib/main/browser/file-system-main-impl.js.map +1 -1
  72. package/lib/main/browser/languages-main.js +1 -1
  73. package/lib/main/browser/languages-main.js.map +1 -1
  74. package/lib/main/browser/main-context.js +2 -2
  75. package/lib/main/browser/main-context.js.map +1 -1
  76. package/lib/main/browser/message-registry-main.js +1 -1
  77. package/lib/main/browser/message-registry-main.js.map +1 -1
  78. package/lib/main/browser/quick-open-main.d.ts +1 -1
  79. package/lib/main/browser/quick-open-main.d.ts.map +1 -1
  80. package/lib/main/browser/quick-open-main.js.map +1 -1
  81. package/lib/main/browser/tasks-main.d.ts.map +1 -1
  82. package/lib/main/browser/tasks-main.js +6 -0
  83. package/lib/main/browser/tasks-main.js.map +1 -1
  84. package/lib/main/browser/timeline-main.d.ts.map +1 -1
  85. package/lib/main/browser/timeline-main.js +1 -1
  86. package/lib/main/browser/timeline-main.js.map +1 -1
  87. package/lib/main/browser/view/plugin-view-registry.d.ts +3 -2
  88. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  89. package/lib/main/browser/view/plugin-view-registry.js +77 -26
  90. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  91. package/lib/main/browser/view/plugin-view-widget.d.ts +2 -0
  92. package/lib/main/browser/view/plugin-view-widget.d.ts.map +1 -1
  93. package/lib/main/browser/view/plugin-view-widget.js +3 -1
  94. package/lib/main/browser/view/plugin-view-widget.js.map +1 -1
  95. package/lib/main/browser/view/tree-view-widget.d.ts +3 -7
  96. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  97. package/lib/main/browser/view/tree-view-widget.js +26 -39
  98. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  99. package/lib/main/browser/webview/webview-frontend-security-warnings.d.ts.map +1 -1
  100. package/lib/main/browser/webview/webview-frontend-security-warnings.js +8 -5
  101. package/lib/main/browser/webview/webview-frontend-security-warnings.js.map +1 -1
  102. package/lib/main/browser/webview/webview-preferences.d.ts.map +1 -1
  103. package/lib/main/browser/webview/webview-preferences.js +3 -2
  104. package/lib/main/browser/webview/webview-preferences.js.map +1 -1
  105. package/lib/main/browser/webview/webview.d.ts +1 -1
  106. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  107. package/lib/main/browser/webview/webview.js +1 -1
  108. package/lib/main/browser/webview/webview.js.map +1 -1
  109. package/lib/plugin/comments.d.ts.map +1 -1
  110. package/lib/plugin/comments.js +2 -3
  111. package/lib/plugin/comments.js.map +1 -1
  112. package/lib/plugin/custom-editors.d.ts +1 -2
  113. package/lib/plugin/custom-editors.d.ts.map +1 -1
  114. package/lib/plugin/custom-editors.js +2 -3
  115. package/lib/plugin/custom-editors.js.map +1 -1
  116. package/lib/plugin/decorations.d.ts.map +1 -1
  117. package/lib/plugin/decorations.js +2 -3
  118. package/lib/plugin/decorations.js.map +1 -1
  119. package/lib/plugin/document-data.d.ts.map +1 -1
  120. package/lib/plugin/document-data.js +1 -1
  121. package/lib/plugin/document-data.js.map +1 -1
  122. package/lib/plugin/documents.d.ts.map +1 -1
  123. package/lib/plugin/documents.js +1 -2
  124. package/lib/plugin/documents.js.map +1 -1
  125. package/lib/plugin/file-system-event-service-ext-impl.d.ts.map +1 -1
  126. package/lib/plugin/file-system-event-service-ext-impl.js +2 -3
  127. package/lib/plugin/file-system-event-service-ext-impl.js.map +1 -1
  128. package/lib/plugin/file-system-ext-impl.d.ts.map +1 -1
  129. package/lib/plugin/file-system-ext-impl.js +12 -13
  130. package/lib/plugin/file-system-ext-impl.js.map +1 -1
  131. package/lib/plugin/known-commands.spec.js +1 -2
  132. package/lib/plugin/known-commands.spec.js.map +1 -1
  133. package/lib/plugin/languages/call-hierarchy.d.ts +1 -1
  134. package/lib/plugin/languages/call-hierarchy.d.ts.map +1 -1
  135. package/lib/plugin/languages/call-hierarchy.js +7 -3
  136. package/lib/plugin/languages/call-hierarchy.js.map +1 -1
  137. package/lib/plugin/languages/rename.d.ts +1 -2
  138. package/lib/plugin/languages/rename.d.ts.map +1 -1
  139. package/lib/plugin/languages/rename.js.map +1 -1
  140. package/lib/plugin/languages.d.ts +1 -1
  141. package/lib/plugin/languages.d.ts.map +1 -1
  142. package/lib/plugin/languages.js.map +1 -1
  143. package/lib/plugin/message-registry.d.ts.map +1 -1
  144. package/lib/plugin/message-registry.js +3 -0
  145. package/lib/plugin/message-registry.js.map +1 -1
  146. package/lib/plugin/node/debug/debug.d.ts +4 -4
  147. package/lib/plugin/node/debug/debug.d.ts.map +1 -1
  148. package/lib/plugin/node/debug/debug.js +13 -8
  149. package/lib/plugin/node/debug/debug.js.map +1 -1
  150. package/lib/plugin/node/debug/plugin-debug-adapter-session.d.ts +7 -7
  151. package/lib/plugin/node/debug/plugin-debug-adapter-session.d.ts.map +1 -1
  152. package/lib/plugin/node/debug/plugin-debug-adapter-session.js +6 -6
  153. package/lib/plugin/node/debug/plugin-debug-adapter-session.js.map +1 -1
  154. package/lib/plugin/node/debug/plugin-debug-adapter-starter.d.ts +8 -4
  155. package/lib/plugin/node/debug/plugin-debug-adapter-starter.d.ts.map +1 -1
  156. package/lib/plugin/node/debug/plugin-debug-adapter-starter.js +16 -13
  157. package/lib/plugin/node/debug/plugin-debug-adapter-starter.js.map +1 -1
  158. package/lib/plugin/plugin-context.d.ts.map +1 -1
  159. package/lib/plugin/plugin-context.js +5 -4
  160. package/lib/plugin/plugin-context.js.map +1 -1
  161. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  162. package/lib/plugin/plugin-storage.js.map +1 -1
  163. package/lib/plugin/preference-registry.spec.js.map +1 -1
  164. package/lib/plugin/quick-open.d.ts +1 -1
  165. package/lib/plugin/quick-open.d.ts.map +1 -1
  166. package/lib/plugin/quick-open.js +11 -6
  167. package/lib/plugin/quick-open.js.map +1 -1
  168. package/lib/plugin/tasks/tasks.d.ts +1 -3
  169. package/lib/plugin/tasks/tasks.d.ts.map +1 -1
  170. package/lib/plugin/tasks/tasks.js +3 -17
  171. package/lib/plugin/tasks/tasks.js.map +1 -1
  172. package/lib/plugin/timeline.d.ts.map +1 -1
  173. package/lib/plugin/timeline.js +1 -2
  174. package/lib/plugin/timeline.js.map +1 -1
  175. package/lib/plugin/type-converters.d.ts.map +1 -1
  176. package/lib/plugin/type-converters.js +10 -7
  177. package/lib/plugin/type-converters.js.map +1 -1
  178. package/lib/plugin/types-impl.d.ts +34 -0
  179. package/lib/plugin/types-impl.d.ts.map +1 -1
  180. package/lib/plugin/types-impl.js +61 -1
  181. package/lib/plugin/types-impl.js.map +1 -1
  182. package/lib/plugin/webviews.d.ts +1 -2
  183. package/lib/plugin/webviews.d.ts.map +1 -1
  184. package/lib/plugin/webviews.js.map +1 -1
  185. package/package.json +26 -24
  186. package/src/common/connection.ts +98 -42
  187. package/src/common/plugin-api-rpc-model.ts +2 -0
  188. package/src/common/plugin-api-rpc.ts +10 -11
  189. package/src/common/plugin-protocol.ts +3 -2
  190. package/src/hosted/browser/hosted-plugin.ts +17 -12
  191. package/src/hosted/node/hosted-plugin-deployer-handler.ts +13 -40
  192. package/src/hosted/node/hosted-plugin-localization-service.ts +201 -0
  193. package/src/hosted/node/hosted-plugin-process.ts +4 -6
  194. package/src/hosted/node/plugin-ext-hosted-backend-module.ts +2 -0
  195. package/src/hosted/node/plugin-manifest-loader.ts +4 -56
  196. package/src/hosted/node/plugin-service.ts +7 -40
  197. package/src/hosted/node/scanners/scanner-theia.ts +6 -3
  198. package/src/main/browser/callhierarchy/callhierarchy-type-converters.ts +5 -2
  199. package/src/main/browser/custom-editors/custom-editor-opener.tsx +1 -2
  200. package/src/main/browser/custom-editors/custom-editors-main.ts +1 -2
  201. package/src/main/browser/debug/debug-main.ts +4 -5
  202. package/src/main/browser/debug/plugin-debug-session-factory.ts +6 -6
  203. package/src/main/browser/dialogs/modal-notification.ts +18 -7
  204. package/src/main/browser/dialogs/style/modal-notification.css +17 -2
  205. package/src/main/browser/editors-and-documents-main.ts +1 -2
  206. package/src/main/browser/file-system-main-impl.ts +1 -1
  207. package/src/main/browser/languages-main.ts +1 -1
  208. package/src/main/browser/main-context.ts +3 -3
  209. package/src/main/browser/message-registry-main.ts +1 -1
  210. package/src/main/browser/quick-open-main.ts +1 -1
  211. package/src/main/browser/style/tree.css +4 -0
  212. package/src/main/browser/tasks-main.ts +7 -0
  213. package/src/main/browser/timeline-main.ts +1 -2
  214. package/src/main/browser/view/plugin-view-registry.ts +83 -28
  215. package/src/main/browser/view/plugin-view-widget.ts +7 -2
  216. package/src/main/browser/view/tree-view-widget.tsx +43 -65
  217. package/src/main/browser/webview/pre/host.js +3 -4
  218. package/src/main/browser/webview/webview-frontend-security-warnings.ts +8 -7
  219. package/src/main/browser/webview/webview-preferences.ts +3 -2
  220. package/src/main/browser/webview/webview.ts +1 -1
  221. package/src/plugin/comments.ts +1 -2
  222. package/src/plugin/custom-editors.ts +2 -4
  223. package/src/plugin/decorations.ts +1 -2
  224. package/src/plugin/document-data.ts +1 -2
  225. package/src/plugin/documents.ts +1 -2
  226. package/src/plugin/file-system-event-service-ext-impl.ts +1 -2
  227. package/src/plugin/file-system-ext-impl.ts +1 -2
  228. package/src/plugin/known-commands.spec.ts +1 -2
  229. package/src/plugin/languages/call-hierarchy.ts +13 -5
  230. package/src/plugin/languages/rename.ts +1 -2
  231. package/src/plugin/languages.ts +3 -1
  232. package/src/plugin/message-registry.ts +3 -1
  233. package/src/plugin/node/debug/debug.ts +20 -14
  234. package/src/plugin/node/debug/plugin-debug-adapter-session.ts +9 -9
  235. package/src/plugin/node/debug/plugin-debug-adapter-starter.ts +17 -14
  236. package/src/plugin/plugin-context.ts +10 -7
  237. package/src/plugin/plugin-storage.ts +1 -2
  238. package/src/plugin/preference-registry.spec.ts +1 -2
  239. package/src/plugin/quick-open.ts +14 -10
  240. package/src/plugin/tasks/tasks.ts +4 -18
  241. package/src/plugin/timeline.ts +1 -2
  242. package/src/plugin/type-converters.ts +12 -8
  243. package/src/plugin/types-impl.ts +53 -0
  244. package/src/plugin/webviews.ts +1 -2
  245. package/lib/common/plugin-message-reader.d.ts +0 -46
  246. package/lib/common/plugin-message-reader.d.ts.map +0 -1
  247. package/lib/common/plugin-message-reader.js +0 -116
  248. package/lib/common/plugin-message-reader.js.map +0 -1
  249. package/lib/common/plugin-message-writer.d.ts +0 -38
  250. package/lib/common/plugin-message-writer.d.ts.map +0 -1
  251. package/lib/common/plugin-message-writer.js +0 -67
  252. package/lib/common/plugin-message-writer.js.map +0 -1
  253. package/lib/main/browser/connection-main.d.ts +0 -59
  254. package/lib/main/browser/connection-main.d.ts.map +0 -1
  255. package/lib/main/browser/connection-main.js +0 -98
  256. package/lib/main/browser/connection-main.js.map +0 -1
  257. package/lib/plugin/connection-ext.d.ts +0 -56
  258. package/lib/plugin/connection-ext.d.ts.map +0 -1
  259. package/lib/plugin/connection-ext.js +0 -88
  260. package/lib/plugin/connection-ext.js.map +0 -1
  261. package/src/common/plugin-message-reader.ts +0 -111
  262. package/src/common/plugin-message-writer.ts +0 -65
  263. package/src/main/browser/connection-main.ts +0 -107
  264. package/src/plugin/connection-ext.ts +0 -95
@@ -1,111 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. 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 { DataCallback, Emitter, Event, PartialMessageInfo } from '@theia/core/shared/vscode-ws-jsonrpc';
18
-
19
- export abstract class AbstractMessageReader {
20
- protected errorEmitter = new Emitter<Error>();
21
- protected closeEmitter = new Emitter<void>();
22
- protected partialMessageEmitter = new Emitter<PartialMessageInfo>();
23
- dispose(): void {
24
- this.errorEmitter.dispose();
25
- this.closeEmitter.dispose();
26
- }
27
- get onError(): Event<Error> {
28
- return this.errorEmitter.event;
29
- }
30
- fireError(error: Error): void {
31
- this.errorEmitter.fire(this.asError(error));
32
- }
33
- get onClose(): Event<void> {
34
- return this.closeEmitter.event;
35
- }
36
- fireClose(): void {
37
- this.closeEmitter.fire(undefined);
38
- }
39
- get onPartialMessage(): Event<PartialMessageInfo> {
40
- return this.partialMessageEmitter.event;
41
- }
42
- firePartialMessage(info: PartialMessageInfo): void {
43
- this.partialMessageEmitter.fire(info);
44
- }
45
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
- asError(error: any): Error {
47
- if (error instanceof Error) {
48
- return error;
49
- } else {
50
- return new Error(`Reader received error. Reason: ${typeof error.message === 'string' ? error.message : 'unknown'}`);
51
- }
52
- }
53
- }
54
-
55
- /**
56
- * Support for reading string message through RPC protocol.
57
- */
58
- export class PluginMessageReader extends AbstractMessageReader {
59
- protected state: 'initial' | 'listening' | 'closed' = 'initial';
60
- protected callback: DataCallback | undefined;
61
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
- protected readonly events: { message?: any, error?: any }[] = [];
63
-
64
- constructor() {
65
- super();
66
- }
67
-
68
- listen(callback: DataCallback): void {
69
- if (this.state === 'initial') {
70
- this.state = 'listening';
71
- this.callback = callback;
72
- while (this.events.length !== 0) {
73
- const event = this.events.pop()!;
74
- if (event.message) {
75
- this.readMessage(event.message);
76
- } else if (event.error) {
77
- this.fireError(event.error);
78
- } else {
79
- this.fireClose();
80
- }
81
- }
82
- }
83
- }
84
-
85
- readMessage(message: string): void {
86
- if (this.state === 'initial') {
87
- this.events.splice(0, 0, { message });
88
- } else if (this.state === 'listening') {
89
- const data = JSON.parse(message);
90
- this.callback!(data);
91
- }
92
- }
93
-
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
- fireError(error: any): void {
96
- if (this.state === 'initial') {
97
- this.events.splice(0, 0, { error });
98
- } else if (this.state === 'listening') {
99
- super.fireError(error);
100
- }
101
- }
102
-
103
- fireClose(): void {
104
- if (this.state === 'initial') {
105
- this.events.splice(0, 0, {});
106
- } else if (this.state === 'listening') {
107
- super.fireClose();
108
- }
109
- this.state = 'closed';
110
- }
111
- }
@@ -1,65 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. 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 { Message, MessageWriter, Emitter, Event } from '@theia/core/shared/vscode-ws-jsonrpc';
18
- import { ConnectionMain, ConnectionExt } from './plugin-api-rpc';
19
-
20
- export abstract class AbstractMessageWriter {
21
- protected errorEmitter = new Emitter<[Error, Message | undefined, number | undefined]>();
22
- protected closeEmitter = new Emitter<void>();
23
- dispose(): void {
24
- this.errorEmitter.dispose();
25
- this.closeEmitter.dispose();
26
- }
27
- get onError(): Event<[Error, Message | undefined, number | undefined]> {
28
- return this.errorEmitter.event;
29
- }
30
- fireError(error: Error, message: Message | undefined, count: number | undefined): void {
31
- this.errorEmitter.fire([this.asError(error), message, count]);
32
- }
33
- get onClose(): Event<void> {
34
- return this.closeEmitter.event;
35
- }
36
- fireClose(): void {
37
- this.closeEmitter.fire(undefined);
38
- }
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- asError(error: any): Error {
41
- if (error instanceof Error) {
42
- return error;
43
- } else {
44
- return new Error(`Writer received error. Reason: ${typeof error.message === 'string' ? error.message : 'unknown'}`);
45
- }
46
- }
47
- }
48
-
49
- /**
50
- * Support for writing string message through RPC protocol.
51
- */
52
- export class PluginMessageWriter extends AbstractMessageWriter implements MessageWriter {
53
- constructor(
54
- protected readonly id: string,
55
- protected readonly proxy: ConnectionMain | ConnectionExt) {
56
- super();
57
- }
58
-
59
- write(message: string): void;
60
- write(message: Message): void;
61
- write(arg: string | Message): void {
62
- const content = JSON.stringify(arg);
63
- this.proxy.$sendMessage(this.id, content);
64
- }
65
- }
@@ -1,107 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. 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 { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
18
- import { MAIN_RPC_CONTEXT, ConnectionMain, ConnectionExt } from '../../common/plugin-api-rpc';
19
- import { RPCProtocol } from '../../common/rpc-protocol';
20
- import { PluginConnection } from '../../common/connection';
21
- import { PluginMessageReader } from '../../common/plugin-message-reader';
22
- import { PluginMessageWriter } from '../../common/plugin-message-writer';
23
-
24
- /**
25
- * Implementation of connection system of the plugin API.
26
- * Creates holds the connections to the plugins. Allows to send a message to the plugin by getting already created connection via id.
27
- */
28
- export class ConnectionMainImpl implements ConnectionMain, Disposable {
29
-
30
- private readonly proxy: ConnectionExt;
31
- private readonly connections = new Map<string, PluginConnection>();
32
- private readonly toDispose = new DisposableCollection();
33
- constructor(rpc: RPCProtocol) {
34
- this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.CONNECTION_EXT);
35
- }
36
-
37
- dispose(): void {
38
- this.toDispose.dispose();
39
- }
40
-
41
- /**
42
- * Gets the connection between plugin by id and sends string message to it.
43
- *
44
- * @param id connection's id
45
- * @param message incoming message
46
- */
47
- async $sendMessage(id: string, message: string): Promise<void> {
48
- if (this.connections.has(id)) {
49
- this.connections.get(id)!.reader.readMessage(message);
50
- } else {
51
- console.warn('It is not possible to read message. Connection missed.');
52
- }
53
- }
54
-
55
- /**
56
- * Instantiates a new connection by the given id.
57
- * @param id the connection id
58
- */
59
- async $createConnection(id: string): Promise<void> {
60
- await this.doEnsureConnection(id);
61
- }
62
-
63
- /**
64
- * Deletes a connection.
65
- * @param id the connection id
66
- */
67
- async $deleteConnection(id: string): Promise<void> {
68
- this.connections.delete(id);
69
- }
70
-
71
- /**
72
- * Returns existed connection or creates a new one.
73
- * @param id the connection id
74
- */
75
- async ensureConnection(id: string): Promise<PluginConnection> {
76
- const connection = await this.doEnsureConnection(id);
77
- await this.proxy.$createConnection(id);
78
- return connection;
79
- }
80
-
81
- /**
82
- * Returns existed connection or creates a new one.
83
- * @param id the connection id
84
- */
85
- async doEnsureConnection(id: string): Promise<PluginConnection> {
86
- const connection = this.connections.get(id) || await this.doCreateConnection(id);
87
- this.connections.set(id, connection);
88
- return connection;
89
- }
90
-
91
- protected async doCreateConnection(id: string): Promise<PluginConnection> {
92
- const reader = new PluginMessageReader();
93
- const writer = new PluginMessageWriter(id, this.proxy);
94
- const connection = new PluginConnection(
95
- reader,
96
- writer,
97
- () => {
98
- this.connections.delete(id);
99
- if (!toClose.disposed) {
100
- this.proxy.$deleteConnection(id);
101
- }
102
- });
103
- const toClose = new DisposableCollection(Disposable.create(() => reader.fireClose()));
104
- this.toDispose.push(toClose);
105
- return connection;
106
- }
107
- }
@@ -1,95 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. 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 { ConnectionExt, PLUGIN_RPC_CONTEXT, ConnectionMain } from '../common/plugin-api-rpc';
18
- import { RPCProtocol } from '../common/rpc-protocol';
19
- import { PluginConnection } from '../common/connection';
20
- import { PluginMessageReader } from '../common/plugin-message-reader';
21
- import { PluginMessageWriter } from '../common/plugin-message-writer';
22
-
23
- /**
24
- * Implementation of connection system of the plugin API.
25
- * It allows to communicate with main side to send and read messages.
26
- */
27
- export class ConnectionExtImpl implements ConnectionExt {
28
- private proxy: ConnectionMain;
29
- private connections = new Map<string, PluginConnection>();
30
- constructor(rpc: RPCProtocol) {
31
- this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.CONNECTION_MAIN);
32
- }
33
-
34
- /**
35
- * Gets the connection between plugin by id and sends string message to it.
36
- *
37
- * @param id connection's id
38
- * @param message incoming message
39
- */
40
- async $sendMessage(id: string, message: string): Promise<void> {
41
- if (this.connections.has(id)) {
42
- this.connections.get(id)!.reader.readMessage(message);
43
- } else {
44
- console.warn('It is not possible to read message. Connection missed.');
45
- }
46
- }
47
-
48
- /**
49
- * Instantiates a new connection by the given id.
50
- * @param id the connection id
51
- */
52
- async $createConnection(id: string): Promise<void> {
53
- await this.doEnsureConnection(id);
54
- }
55
-
56
- /**
57
- * Deletes a connection.
58
- * @param id the connection id
59
- */
60
- async $deleteConnection(id: string): Promise<void> {
61
- this.connections.delete(id);
62
- }
63
-
64
- /**
65
- * Returns existed connection or creates a new one.
66
- * @param id the connection id
67
- */
68
- async ensureConnection(id: string): Promise<PluginConnection> {
69
- const connection = await this.doEnsureConnection(id);
70
- this.proxy.$createConnection(id);
71
- return connection;
72
- }
73
-
74
- /**
75
- * Returns existed connection or creates a new one.
76
- * @param id the connection id
77
- */
78
- async doEnsureConnection(id: string): Promise<PluginConnection> {
79
- const connection = this.connections.get(id) || await this.doCreateConnection(id);
80
- this.connections.set(id, connection);
81
- return connection;
82
- }
83
-
84
- protected async doCreateConnection(id: string): Promise<PluginConnection> {
85
- const reader = new PluginMessageReader();
86
- const writer = new PluginMessageWriter(id, this.proxy);
87
- return new PluginConnection(
88
- reader,
89
- writer,
90
- () => {
91
- this.connections.delete(id);
92
- this.proxy.$deleteConnection(id);
93
- });
94
- }
95
- }