@theia/plugin-ext 1.45.1 → 1.46.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 (291) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +9 -4
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js +3 -1
  4. package/lib/common/plugin-api-rpc.js.map +1 -1
  5. package/lib/common/plugin-ext-api-contribution.d.ts +35 -5
  6. package/lib/common/plugin-ext-api-contribution.d.ts.map +1 -1
  7. package/lib/common/plugin-ext-api-contribution.js.map +1 -1
  8. package/lib/common/plugin-protocol.d.ts +5 -2
  9. package/lib/common/plugin-protocol.d.ts.map +1 -1
  10. package/lib/common/plugin-protocol.js +1 -0
  11. package/lib/common/plugin-protocol.js.map +1 -1
  12. package/lib/common/proxy-handler.d.ts +7 -0
  13. package/lib/common/proxy-handler.d.ts.map +1 -1
  14. package/lib/common/proxy-handler.js +5 -1
  15. package/lib/common/proxy-handler.js.map +1 -1
  16. package/lib/common/rpc-protocol.d.ts +10 -0
  17. package/lib/common/rpc-protocol.d.ts.map +1 -1
  18. package/lib/common/rpc-protocol.js +32 -3
  19. package/lib/common/rpc-protocol.js.map +1 -1
  20. package/lib/hosted/browser/hosted-plugin.d.ts +16 -74
  21. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  22. package/lib/hosted/browser/hosted-plugin.js +41 -314
  23. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  24. package/lib/hosted/browser/worker/debug-stub.d.ts +2 -2
  25. package/lib/hosted/browser/worker/debug-stub.d.ts.map +1 -1
  26. package/lib/hosted/browser/worker/debug-stub.js +3 -3
  27. package/lib/hosted/browser/worker/debug-stub.js.map +1 -1
  28. package/lib/hosted/browser/worker/worker-env-ext.d.ts +1 -2
  29. package/lib/hosted/browser/worker/worker-env-ext.d.ts.map +1 -1
  30. package/lib/hosted/browser/worker/worker-env-ext.js +18 -4
  31. package/lib/hosted/browser/worker/worker-env-ext.js.map +1 -1
  32. package/lib/hosted/browser/worker/worker-main.js +20 -32
  33. package/lib/hosted/browser/worker/worker-main.js.map +1 -1
  34. package/lib/hosted/browser/worker/worker-plugin-module.d.ts +5 -0
  35. package/lib/hosted/browser/worker/worker-plugin-module.d.ts.map +1 -0
  36. package/lib/hosted/browser/worker/worker-plugin-module.js +71 -0
  37. package/lib/hosted/browser/worker/worker-plugin-module.js.map +1 -0
  38. package/lib/hosted/common/hosted-plugin.d.ts +97 -0
  39. package/lib/hosted/common/hosted-plugin.d.ts.map +1 -0
  40. package/lib/hosted/common/hosted-plugin.js +408 -0
  41. package/lib/hosted/common/hosted-plugin.js.map +1 -0
  42. package/lib/hosted/node/hosted-plugin-process.d.ts +1 -1
  43. package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
  44. package/lib/hosted/node/hosted-plugin-process.js +2 -2
  45. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  46. package/lib/hosted/node/plugin-ext-hosted-backend-module.d.ts.map +1 -1
  47. package/lib/hosted/node/plugin-ext-hosted-backend-module.js +2 -0
  48. package/lib/hosted/node/plugin-ext-hosted-backend-module.js.map +1 -1
  49. package/lib/hosted/node/plugin-host-module.d.ts +5 -0
  50. package/lib/hosted/node/plugin-host-module.d.ts.map +1 -0
  51. package/lib/hosted/node/plugin-host-module.js +68 -0
  52. package/lib/hosted/node/plugin-host-module.js.map +1 -0
  53. package/lib/hosted/node/plugin-host-rpc.d.ts +93 -7
  54. package/lib/hosted/node/plugin-host-rpc.d.ts.map +1 -1
  55. package/lib/hosted/node/plugin-host-rpc.js +202 -53
  56. package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
  57. package/lib/hosted/node/plugin-host.js +6 -5
  58. package/lib/hosted/node/plugin-host.js.map +1 -1
  59. package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
  60. package/lib/hosted/node/plugin-reader.js +3 -0
  61. package/lib/hosted/node/plugin-reader.js.map +1 -1
  62. package/lib/hosted/node/plugin-service.d.ts +8 -0
  63. package/lib/hosted/node/plugin-service.d.ts.map +1 -1
  64. package/lib/hosted/node/plugin-service.js +14 -4
  65. package/lib/hosted/node/plugin-service.js.map +1 -1
  66. package/lib/hosted/node/scanners/file-plugin-uri-factory.js +1 -1
  67. package/lib/hosted/node/scanners/file-plugin-uri-factory.js.map +1 -1
  68. package/lib/hosted/node/scanners/scanner-theia.d.ts +17 -3
  69. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  70. package/lib/hosted/node/scanners/scanner-theia.js +48 -19
  71. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  72. package/lib/main/browser/authentication-main.d.ts.map +1 -1
  73. package/lib/main/browser/authentication-main.js +3 -1
  74. package/lib/main/browser/authentication-main.js.map +1 -1
  75. package/lib/main/browser/env-main.d.ts +1 -10
  76. package/lib/main/browser/env-main.d.ts.map +1 -1
  77. package/lib/main/browser/env-main.js +2 -21
  78. package/lib/main/browser/env-main.js.map +1 -1
  79. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  80. package/lib/main/browser/menus/menus-contribution-handler.js +6 -3
  81. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  82. package/lib/main/browser/menus/plugin-menu-command-adapter.js +1 -1
  83. package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -1
  84. package/lib/main/browser/message-registry-main.d.ts +6 -4
  85. package/lib/main/browser/message-registry-main.d.ts.map +1 -1
  86. package/lib/main/browser/message-registry-main.js +7 -19
  87. package/lib/main/browser/message-registry-main.js.map +1 -1
  88. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts +1 -0
  89. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -1
  90. package/lib/main/browser/notebooks/renderers/cell-output-webview.js +23 -22
  91. package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -1
  92. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -1
  93. package/lib/main/browser/notebooks/renderers/output-webview-internal.js +22 -14
  94. package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -1
  95. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts +2 -1
  96. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts.map +1 -1
  97. package/lib/main/browser/notification-main.d.ts +2 -14
  98. package/lib/main/browser/notification-main.d.ts.map +1 -1
  99. package/lib/main/browser/notification-main.js +3 -52
  100. package/lib/main/browser/notification-main.js.map +1 -1
  101. package/lib/main/browser/terminal-main.d.ts +1 -1
  102. package/lib/main/browser/terminal-main.d.ts.map +1 -1
  103. package/lib/main/browser/terminal-main.js +2 -2
  104. package/lib/main/browser/terminal-main.js.map +1 -1
  105. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  106. package/lib/main/browser/view/plugin-view-registry.js +5 -2
  107. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  108. package/lib/main/browser/webview/webview-context-keys.d.ts +5 -1
  109. package/lib/main/browser/webview/webview-context-keys.d.ts.map +1 -1
  110. package/lib/main/browser/webview/webview-context-keys.js +13 -4
  111. package/lib/main/browser/webview/webview-context-keys.js.map +1 -1
  112. package/lib/main/browser/webview/webview-widget-factory.d.ts.map +1 -1
  113. package/lib/main/browser/webview/webview-widget-factory.js +2 -1
  114. package/lib/main/browser/webview/webview-widget-factory.js.map +1 -1
  115. package/lib/main/browser/webview/webview.d.ts +1 -0
  116. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  117. package/lib/main/browser/webview/webview.js +1 -0
  118. package/lib/main/browser/webview/webview.js.map +1 -1
  119. package/lib/main/browser/webviews-main.d.ts.map +1 -1
  120. package/lib/main/browser/webviews-main.js +7 -2
  121. package/lib/main/browser/webviews-main.js.map +1 -1
  122. package/lib/main/common/basic-message-registry-main.d.ts +14 -0
  123. package/lib/main/common/basic-message-registry-main.d.ts.map +1 -0
  124. package/lib/main/common/basic-message-registry-main.js +50 -0
  125. package/lib/main/common/basic-message-registry-main.js.map +1 -0
  126. package/lib/main/common/basic-notification-main.d.ts +19 -0
  127. package/lib/main/common/basic-notification-main.d.ts.map +1 -0
  128. package/lib/main/common/basic-notification-main.js +75 -0
  129. package/lib/main/common/basic-notification-main.js.map +1 -0
  130. package/lib/main/common/env-main.d.ts +11 -0
  131. package/lib/main/common/env-main.d.ts.map +1 -0
  132. package/lib/main/common/env-main.js +40 -0
  133. package/lib/main/common/env-main.js.map +1 -0
  134. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +8 -3
  135. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
  136. package/lib/main/node/handlers/plugin-theia-directory-handler.js +38 -20
  137. package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
  138. package/lib/main/node/handlers/plugin-theia-file-handler.js +1 -1
  139. package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
  140. package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
  141. package/lib/main/node/plugin-deployer-impl.js +5 -1
  142. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  143. package/lib/main/node/plugins-key-value-storage.js +1 -1
  144. package/lib/main/node/plugins-key-value-storage.js.map +1 -1
  145. package/lib/plugin/clipboard-ext.d.ts +3 -2
  146. package/lib/plugin/clipboard-ext.d.ts.map +1 -1
  147. package/lib/plugin/clipboard-ext.js +28 -4
  148. package/lib/plugin/clipboard-ext.js.map +1 -1
  149. package/lib/plugin/debug/debug-ext.d.ts +3 -1
  150. package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
  151. package/lib/plugin/debug/debug-ext.js +31 -4
  152. package/lib/plugin/debug/debug-ext.js.map +1 -1
  153. package/lib/plugin/documents.js +2 -2
  154. package/lib/plugin/documents.js.map +1 -1
  155. package/lib/plugin/editors-and-documents.d.ts +1 -2
  156. package/lib/plugin/editors-and-documents.d.ts.map +1 -1
  157. package/lib/plugin/editors-and-documents.js +21 -4
  158. package/lib/plugin/editors-and-documents.js.map +1 -1
  159. package/lib/plugin/env.d.ts +6 -2
  160. package/lib/plugin/env.d.ts.map +1 -1
  161. package/lib/plugin/env.js +37 -4
  162. package/lib/plugin/env.js.map +1 -1
  163. package/lib/plugin/localization-ext.d.ts +3 -2
  164. package/lib/plugin/localization-ext.d.ts.map +1 -1
  165. package/lib/plugin/localization-ext.js +30 -4
  166. package/lib/plugin/localization-ext.js.map +1 -1
  167. package/lib/plugin/message-registry.d.ts +2 -1
  168. package/lib/plugin/message-registry.d.ts.map +1 -1
  169. package/lib/plugin/message-registry.js +28 -4
  170. package/lib/plugin/message-registry.js.map +1 -1
  171. package/lib/plugin/node/debug/debug.spec.js +21 -1
  172. package/lib/plugin/node/debug/debug.spec.js.map +1 -1
  173. package/lib/plugin/node/env-node-ext.d.ts +1 -6
  174. package/lib/plugin/node/env-node-ext.d.ts.map +1 -1
  175. package/lib/plugin/node/env-node-ext.js +18 -10
  176. package/lib/plugin/node/env-node-ext.js.map +1 -1
  177. package/lib/plugin/node/plugin-container-module.d.ts +75 -0
  178. package/lib/plugin/node/plugin-container-module.d.ts.map +1 -0
  179. package/lib/plugin/node/plugin-container-module.js +115 -0
  180. package/lib/plugin/node/plugin-container-module.js.map +1 -0
  181. package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -1
  182. package/lib/plugin/notebook/notebook-kernels.js +0 -1
  183. package/lib/plugin/notebook/notebook-kernels.js.map +1 -1
  184. package/lib/plugin/plugin-context.d.ts.map +1 -1
  185. package/lib/plugin/plugin-context.js +9 -1
  186. package/lib/plugin/plugin-context.js.map +1 -1
  187. package/lib/plugin/plugin-manager.d.ts +26 -17
  188. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  189. package/lib/plugin/plugin-manager.js +107 -37
  190. package/lib/plugin/plugin-manager.js.map +1 -1
  191. package/lib/plugin/plugin-storage.d.ts +11 -3
  192. package/lib/plugin/plugin-storage.d.ts.map +1 -1
  193. package/lib/plugin/plugin-storage.js +25 -5
  194. package/lib/plugin/plugin-storage.js.map +1 -1
  195. package/lib/plugin/preference-registry.d.ts +3 -2
  196. package/lib/plugin/preference-registry.d.ts.map +1 -1
  197. package/lib/plugin/preference-registry.js +35 -5
  198. package/lib/plugin/preference-registry.js.map +1 -1
  199. package/lib/plugin/preference-registry.spec.js +8 -1
  200. package/lib/plugin/preference-registry.spec.js.map +1 -1
  201. package/lib/plugin/quick-open.js +3 -3
  202. package/lib/plugin/quick-open.js.map +1 -1
  203. package/lib/plugin/secrets-ext.d.ts +16 -7
  204. package/lib/plugin/secrets-ext.d.ts.map +1 -1
  205. package/lib/plugin/secrets-ext.js +23 -3
  206. package/lib/plugin/secrets-ext.js.map +1 -1
  207. package/lib/plugin/terminal-ext.d.ts +1 -1
  208. package/lib/plugin/terminal-ext.d.ts.map +1 -1
  209. package/lib/plugin/terminal-ext.js +26 -6
  210. package/lib/plugin/terminal-ext.js.map +1 -1
  211. package/lib/plugin/types-impl.d.ts +22 -2
  212. package/lib/plugin/types-impl.d.ts.map +1 -1
  213. package/lib/plugin/types-impl.js +22 -6
  214. package/lib/plugin/types-impl.js.map +1 -1
  215. package/lib/plugin/webview-views.d.ts.map +1 -1
  216. package/lib/plugin/webview-views.js +2 -1
  217. package/lib/plugin/webview-views.js.map +1 -1
  218. package/lib/plugin/webviews.d.ts +7 -5
  219. package/lib/plugin/webviews.d.ts.map +1 -1
  220. package/lib/plugin/webviews.js +46 -12
  221. package/lib/plugin/webviews.js.map +1 -1
  222. package/lib/plugin/workspace.d.ts +4 -3
  223. package/lib/plugin/workspace.d.ts.map +1 -1
  224. package/lib/plugin/workspace.js +40 -6
  225. package/lib/plugin/workspace.js.map +1 -1
  226. package/package.json +29 -29
  227. package/src/common/plugin-api-rpc.ts +10 -6
  228. package/src/common/plugin-ext-api-contribution.ts +38 -5
  229. package/src/common/plugin-protocol.ts +7 -2
  230. package/src/common/proxy-handler.ts +14 -1
  231. package/src/common/rpc-protocol.ts +41 -3
  232. package/src/hosted/browser/hosted-plugin.ts +47 -337
  233. package/src/hosted/browser/worker/debug-stub.ts +4 -3
  234. package/src/hosted/browser/worker/worker-env-ext.ts +5 -4
  235. package/src/hosted/browser/worker/worker-main.ts +103 -115
  236. package/src/hosted/browser/worker/worker-plugin-module.ts +73 -0
  237. package/src/hosted/common/hosted-plugin.ts +456 -0
  238. package/src/hosted/node/hosted-plugin-process.ts +4 -4
  239. package/src/hosted/node/plugin-ext-hosted-backend-module.ts +3 -1
  240. package/src/hosted/node/plugin-host-module.ts +69 -0
  241. package/src/hosted/node/plugin-host-rpc.ts +232 -73
  242. package/src/hosted/node/plugin-host.ts +9 -7
  243. package/src/hosted/node/plugin-reader.ts +3 -0
  244. package/src/hosted/node/plugin-service.ts +21 -4
  245. package/src/hosted/node/scanners/file-plugin-uri-factory.ts +1 -1
  246. package/src/hosted/node/scanners/scanner-theia.ts +46 -12
  247. package/src/main/browser/authentication-main.ts +3 -1
  248. package/src/main/browser/env-main.ts +1 -28
  249. package/src/main/browser/menus/menus-contribution-handler.ts +8 -3
  250. package/src/main/browser/menus/plugin-menu-command-adapter.ts +1 -1
  251. package/src/main/browser/message-registry-main.ts +10 -23
  252. package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +26 -24
  253. package/src/main/browser/notebooks/renderers/output-webview-internal.ts +22 -13
  254. package/src/main/browser/notebooks/renderers/webview-communication.ts +2 -1
  255. package/src/main/browser/notification-main.ts +4 -64
  256. package/src/main/browser/terminal-main.ts +2 -2
  257. package/src/main/browser/view/plugin-view-registry.ts +6 -3
  258. package/src/main/browser/webview/webview-context-keys.ts +17 -4
  259. package/src/main/browser/webview/webview-widget-factory.ts +2 -1
  260. package/src/main/browser/webview/webview.ts +2 -0
  261. package/src/main/browser/webviews-main.ts +7 -2
  262. package/src/main/common/basic-message-registry-main.ts +53 -0
  263. package/src/main/common/basic-notification-main.ts +86 -0
  264. package/src/main/common/env-main.ts +44 -0
  265. package/src/main/node/handlers/plugin-theia-directory-handler.ts +38 -16
  266. package/src/main/node/handlers/plugin-theia-file-handler.ts +1 -1
  267. package/src/main/node/plugin-deployer-impl.ts +5 -1
  268. package/src/main/node/plugins-key-value-storage.ts +1 -1
  269. package/src/plugin/clipboard-ext.ts +9 -3
  270. package/src/plugin/debug/debug-ext.ts +11 -2
  271. package/src/plugin/documents.ts +2 -2
  272. package/src/plugin/editors-and-documents.ts +5 -3
  273. package/src/plugin/env.ts +19 -3
  274. package/src/plugin/localization-ext.ts +8 -3
  275. package/src/plugin/message-registry.ts +7 -2
  276. package/src/plugin/node/debug/debug.spec.ts +5 -1
  277. package/src/plugin/node/env-node-ext.ts +5 -10
  278. package/src/plugin/node/plugin-container-module.ts +165 -0
  279. package/src/plugin/notebook/notebook-kernels.ts +0 -1
  280. package/src/plugin/plugin-context.ts +11 -2
  281. package/src/plugin/plugin-manager.ts +99 -45
  282. package/src/plugin/plugin-storage.ts +22 -4
  283. package/src/plugin/preference-registry.spec.ts +6 -1
  284. package/src/plugin/preference-registry.ts +11 -5
  285. package/src/plugin/quick-open.ts +3 -3
  286. package/src/plugin/secrets-ext.ts +25 -5
  287. package/src/plugin/terminal-ext.ts +5 -3
  288. package/src/plugin/types-impl.ts +30 -2
  289. package/src/plugin/webview-views.ts +2 -1
  290. package/src/plugin/webviews.ts +22 -13
  291. package/src/plugin/workspace.ts +14 -4
@@ -0,0 +1,165 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { interfaces, ContainerModule } from '@theia/core/shared/inversify';
18
+ import { Plugin, PluginManager, emptyPlugin } from '../../common';
19
+
20
+ export type ApiFactory<T extends object> = (plugin: Plugin) => T;
21
+
22
+ /**
23
+ * Bind a service identifier for the factory function creating API objects of
24
+ * type `T` for a client plugin to a class providing a `call()` method that
25
+ * implements that factory function.
26
+ *
27
+ * @template T the API object type that the factory creates
28
+ * @param serviceIdentifier the injection key identifying the API factory function
29
+ * @param factoryClass the class implementing the API factory function via its `call()` method
30
+ */
31
+ export type BindApiFactory = <T extends object>(
32
+ apiModuleName: string,
33
+ serviceIdentifier: interfaces.ServiceIdentifier<ApiFactory<T>>,
34
+ factoryClass: new () => { createApi: ApiFactory<T>}) => void;
35
+
36
+ /**
37
+ * An analogue of the callback function in the constructor of the Inversify
38
+ * `ContainerModule` providing a registry that, in addition to the standard
39
+ * binding-related functions, includes a custom function for binding an
40
+ * API factory.
41
+ */
42
+ export type PluginContainerModuleCallBack = (registry: {
43
+ bind: interfaces.Bind;
44
+ unbind: interfaces.Unbind;
45
+ isBound: interfaces.IsBound;
46
+ rebind: interfaces.Rebind;
47
+ bindApiFactory: BindApiFactory;
48
+ }) => void;
49
+
50
+ /**
51
+ * Factory for an Inversify `ContainerModule` that supports registration of the plugin's
52
+ * API factory. Use the `PluginContainerModule`'s `create()` method to create the container
53
+ * module; its `callback` function provides a `registry` of Inversify binding functions that
54
+ * includes a `bindApiFactory` function for binding the API factory.
55
+ */
56
+ export const PluginContainerModule: symbol & { create(callback: PluginContainerModuleCallBack): ContainerModule } = Object.assign(Symbol('PluginContainerModule'), {
57
+ create(callback: PluginContainerModuleCallBack): ContainerModule {
58
+ const result: InternalPluginContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
59
+ const bindApiFactory: BindApiFactory = (apiModuleName, serviceIdentifier, factoryClass) => {
60
+ result.initializeApi = container => {
61
+ const apiCache = new PluginApiCache(apiModuleName, serviceIdentifier);
62
+ apiCache.initializeApi(container);
63
+ return apiCache;
64
+ };
65
+ bind(factoryClass).toSelf().inSingletonScope();
66
+ bind(serviceIdentifier).toDynamicValue(({ container }) => {
67
+ const factory = container.get(factoryClass);
68
+ return factory.createApi.bind(factory);
69
+ }).inSingletonScope();
70
+ };
71
+ callback({ bind, unbind, isBound, rebind, bindApiFactory });
72
+ });
73
+ return result;
74
+ }
75
+ });
76
+
77
+ /**
78
+ * Definition of additional API provided by the `ContainerModule` created by the
79
+ * {@link PluginContainerModule} factory function that is for internal use by Theia.
80
+ */
81
+ export type InternalPluginContainerModule = ContainerModule & {
82
+ /** Use my API factory binding to initialize the plugin API in some `container`. */
83
+ initializeApi?: (container: interfaces.Container) => PluginApiCache<object>;
84
+ };
85
+
86
+ /**
87
+ * An object that creates and caches the instance of the plugin API created by the
88
+ * factory binding in a {@link PluginContainerModule} in some plugin host.
89
+ *
90
+ * @template T the custom API object's type
91
+ */
92
+ export class PluginApiCache<T extends object> {
93
+
94
+ private apiFactory: ApiFactory<T>;
95
+ private pluginManager: PluginManager;
96
+ private defaultApi: T;
97
+ private pluginsApiImpl = new Map<string, T>();
98
+ private hookedModuleLoader = false;
99
+
100
+ /**
101
+ * Initializes me with the module name by which plugins import the API
102
+ * and the service identifier to look up in the Inversify `Container` to
103
+ * obtain the {@link ApiFactory} that will instantiate it.
104
+ */
105
+ constructor(private readonly apiModuleName: string,
106
+ private readonly serviceIdentifier: interfaces.ServiceIdentifier<ApiFactory<T>>) {}
107
+
108
+ // Called by Theia to do any prep work needed for dishing out the API object
109
+ // when it's requested. The key part of that is hooking into the node module
110
+ // loader. This is called every time a plugin-host process is forked.
111
+ initializeApi(container: interfaces.Container): void {
112
+ this.apiFactory = container.get(this.serviceIdentifier);
113
+ this.pluginManager = container.get(PluginManager);
114
+
115
+ if (!this.hookedModuleLoader) {
116
+ this.hookedModuleLoader = true;
117
+ this.overrideInternalLoad();
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Hook into the override chain of JavaScript's `module` loading function
123
+ * to implement ourselves, using the API provider's registered factory,
124
+ * the construction of its default exports object.
125
+ */
126
+ private overrideInternalLoad(): void {
127
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
128
+ const module = require('module');
129
+
130
+ const internalLoad = module._load;
131
+ const self = this;
132
+
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ module._load = function (request: string, parent: any, isMain: any): any {
135
+ if (request !== self.apiModuleName) {
136
+ // Pass the request to the next implementation down the chain
137
+ return internalLoad.call(this, request, parent, isMain);
138
+ }
139
+
140
+ const plugin = self.findPlugin(parent.filename);
141
+ if (plugin) {
142
+ let apiImpl = self.pluginsApiImpl.get(plugin.model.id);
143
+ if (!apiImpl) {
144
+ apiImpl = self.apiFactory(plugin);
145
+ self.pluginsApiImpl.set(plugin.model.id, apiImpl);
146
+ }
147
+ return apiImpl;
148
+ }
149
+
150
+ console.warn(
151
+ `Extension module ${parent.filename} did an import of '${self.apiModuleName}' but our cache ` +
152
+ ' has no knowledge of that extension. Returning a generic API object; some functionality might not work correctly.'
153
+ );
154
+ if (!self.defaultApi) {
155
+ self.defaultApi = self.apiFactory(emptyPlugin);
156
+ }
157
+ return self.defaultApi;
158
+ };
159
+ }
160
+
161
+ // Search all loaded plugins to see which one has the given file (absolute path)
162
+ protected findPlugin(filePath: string): Plugin | undefined {
163
+ return this.pluginManager.getAllPlugins().find(plugin => filePath.startsWith(plugin.pluginFolder));
164
+ }
165
+ }
@@ -334,7 +334,6 @@ export class NotebookKernelsExtImpl implements NotebookKernelsExt {
334
334
  await obj.controller.executeHandler.call(obj.controller, cells, document.apiNotebook, obj.controller);
335
335
  } catch (err) {
336
336
  console.error(`NotebookController[${handle}] execute cells FAILED`, err);
337
- console.error(err);
338
337
  }
339
338
 
340
339
  }
@@ -87,6 +87,7 @@ import {
87
87
  InlineValueContext,
88
88
  DocumentHighlightKind,
89
89
  DocumentHighlight,
90
+ MultiDocumentHighlight,
90
91
  DocumentLink,
91
92
  DocumentDropEdit,
92
93
  CodeLens,
@@ -200,7 +201,7 @@ import {
200
201
  ExternalUriOpenerPriority,
201
202
  EditSessionIdentityMatch,
202
203
  TerminalOutputAnchor,
203
- TerminalQuickFixExecuteTerminalCommand,
204
+ TerminalQuickFixTerminalCommand,
204
205
  TerminalQuickFixOpener,
205
206
  TestResultState
206
207
  } from './types-impl';
@@ -916,6 +917,13 @@ export function createAPIFactory(
916
917
  registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable {
917
918
  return languagesExt.registerDocumentHighlightProvider(selector, provider, pluginToPluginInfo(plugin));
918
919
  },
920
+ /**
921
+ * @stubbed
922
+ * @monaco-uplift: wait until API is available in Monaco (1.85.0+)
923
+ */
924
+ registerMultiDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.MultiDocumentHighlightProvider): theia.Disposable {
925
+ return Disposable.NULL;
926
+ },
919
927
  registerWorkspaceSymbolProvider(provider: theia.WorkspaceSymbolProvider): theia.Disposable {
920
928
  return languagesExt.registerWorkspaceSymbolProvider(provider, pluginToPluginInfo(plugin));
921
929
  },
@@ -1261,6 +1269,7 @@ export function createAPIFactory(
1261
1269
  InlineValueContext,
1262
1270
  DocumentHighlightKind,
1263
1271
  DocumentHighlight,
1272
+ MultiDocumentHighlight,
1264
1273
  DocumentLink,
1265
1274
  DocumentDropEdit,
1266
1275
  CodeLens,
@@ -1375,7 +1384,7 @@ export function createAPIFactory(
1375
1384
  TerminalExitReason,
1376
1385
  DocumentPasteEdit,
1377
1386
  ExternalUriOpenerPriority,
1378
- TerminalQuickFixExecuteTerminalCommand,
1387
+ TerminalQuickFixTerminalCommand,
1379
1388
  TerminalQuickFixOpener,
1380
1389
  EditSessionIdentityMatch,
1381
1390
  TestResultState
@@ -14,8 +14,10 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
17
18
  import {
18
19
  PLUGIN_RPC_CONTEXT,
20
+ AbstractPluginManagerExt,
19
21
  NotificationMain,
20
22
  MainMessageType,
21
23
  MessageRegistryMain,
@@ -35,13 +37,13 @@ import * as types from './types-impl';
35
37
  import { join } from './path';
36
38
  import { EnvExtImpl } from './env';
37
39
  import { PreferenceRegistryExtImpl } from './preference-registry';
38
- import { Memento, KeyValueStorageProxy, GlobalState } from './plugin-storage';
40
+ import { InternalStorageExt, Memento, GlobalState } from './plugin-storage';
39
41
  import { ExtPluginApi } from '../common/plugin-ext-api-contribution';
40
42
  import { RPCProtocol } from '../common/rpc-protocol';
41
43
  import { Emitter } from '@theia/core/lib/common/event';
42
44
  import { WebviewsExtImpl } from './webviews';
43
45
  import { URI as Uri } from './types-impl';
44
- import { SecretsExtImpl, SecretStorageExt } from '../plugin/secrets-ext';
46
+ import { InternalSecretsExt, SecretStorageExt } from '../plugin/secrets-ext';
45
47
  import { PluginExt } from './plugin-context';
46
48
  import { Deferred } from '@theia/core/lib/common/promise-util';
47
49
 
@@ -77,7 +79,34 @@ class ActivatedPlugin {
77
79
  }
78
80
  }
79
81
 
80
- export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
82
+ export const MinimalTerminalServiceExt = Symbol('MinimalTerminalServiceExt');
83
+ export type MinimalTerminalServiceExt = Pick<TerminalServiceExt,
84
+ 'getEnvironmentVariableCollection'|'$initEnvironmentVariableCollections'|'$setShell'>;
85
+
86
+ @injectable()
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
+ export abstract class AbstractPluginManagerExtImpl<P extends Record<string, any>> implements AbstractPluginManagerExt<P>, PluginManager {
89
+
90
+ @inject(EnvExtImpl)
91
+ protected readonly envExt: EnvExtImpl;
92
+
93
+ @inject(MinimalTerminalServiceExt)
94
+ protected readonly terminalService: MinimalTerminalServiceExt;
95
+
96
+ @inject(InternalStorageExt)
97
+ protected readonly storage: InternalStorageExt;
98
+
99
+ @inject(InternalSecretsExt)
100
+ protected readonly secrets: InternalSecretsExt;
101
+
102
+ @inject(LocalizationExt)
103
+ protected readonly localization: LocalizationExt;
104
+
105
+ @inject(RPCProtocol)
106
+ protected readonly rpc: RPCProtocol;
107
+
108
+ // Cannot be Inversify-injected because it induces a dependency cycle
109
+ protected host: PluginHost;
81
110
 
82
111
  private configStorage: ConfigStorage | undefined;
83
112
  private readonly registry = new Map<string, Plugin>();
@@ -90,29 +119,22 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
90
119
  private onDidChangeEmitter = new Emitter<void>();
91
120
  private messageRegistryProxy: MessageRegistryMain;
92
121
  private notificationMain: NotificationMain;
93
- private supportedActivationEvents: Set<string>;
94
- protected fireOnDidChange(): void {
95
- this.onDidChangeEmitter.fire(undefined);
96
- }
97
122
 
98
123
  protected jsonValidation: PluginJsonValidationContribution[] = [];
99
124
  protected ready = new Deferred();
100
125
 
101
- constructor(
102
- private readonly host: PluginHost,
103
- private readonly envExt: EnvExtImpl,
104
- private readonly terminalService: TerminalServiceExt,
105
- private readonly storageProxy: KeyValueStorageProxy,
106
- private readonly secrets: SecretsExtImpl,
107
- private readonly preferencesManager: PreferenceRegistryExtImpl,
108
- private readonly webview: WebviewsExtImpl,
109
- private readonly localization: LocalizationExt,
110
- private readonly rpc: RPCProtocol
111
- ) {
126
+ @postConstruct()
127
+ initialize(): void {
112
128
  this.messageRegistryProxy = this.rpc.getProxy(PLUGIN_RPC_CONTEXT.MESSAGE_REGISTRY_MAIN);
113
129
  this.notificationMain = this.rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTIFICATION_MAIN);
114
130
  }
115
131
 
132
+ setPluginHost(pluginHost: PluginHost): void {
133
+ this.host = pluginHost;
134
+ }
135
+
136
+ abstract $init(params: P): Promise<void>;
137
+
116
138
  async $stop(pluginId?: string): Promise<void> {
117
139
  if (!pluginId) {
118
140
  return this.stopAll();
@@ -179,28 +201,6 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
179
201
  }
180
202
  }
181
203
 
182
- async $init(params: PluginManagerInitializeParams): Promise<void> {
183
- this.storageProxy.init(params.globalState, params.workspaceState);
184
-
185
- this.envExt.setQueryParameters(params.env.queryParams);
186
- this.envExt.setLanguage(params.env.language);
187
- this.terminalService.$setShell(params.env.shell);
188
- this.envExt.setUIKind(params.env.uiKind);
189
- this.envExt.setApplicationName(params.env.appName);
190
- this.envExt.setAppHost(params.env.appHost);
191
-
192
- this.preferencesManager.init(params.preferences);
193
-
194
- if (params.extApi) {
195
- this.host.initExtApi(params.extApi);
196
- }
197
-
198
- this.webview.init(params.webview);
199
- this.jsonValidation = params.jsonValidation;
200
-
201
- this.supportedActivationEvents = new Set(params.supportedActivationEvents ?? []);
202
- }
203
-
204
204
  async $start(params: PluginManagerStartParams): Promise<void> {
205
205
  this.configStorage = params.configStorage;
206
206
 
@@ -239,15 +239,16 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
239
239
  contributes.jsonValidation = (contributes.jsonValidation || []).concat(this.jsonValidation);
240
240
  }
241
241
  this.registry.set(plugin.model.id, plugin);
242
- if (plugin.pluginPath && Array.isArray(plugin.rawModel.activationEvents)) {
242
+ const activationEvents = this.getActivationEvents(plugin);
243
+ if (plugin.pluginPath && activationEvents) {
243
244
  const activation = () => this.$activatePlugin(plugin.model.id);
244
245
  // an internal activation event is a subject to change
245
246
  this.setActivation(`onPlugin:${plugin.model.id}`, activation);
246
- const unsupportedActivationEvents = plugin.rawModel.activationEvents.filter(e => !this.supportedActivationEvents.has(e.split(':')[0]));
247
+ const unsupportedActivationEvents = activationEvents.filter(e => !this.isSupportedActivationEvent(e));
247
248
  if (unsupportedActivationEvents.length) {
248
249
  console.warn(`Unsupported activation events: ${unsupportedActivationEvents.join(', ')}, please open an issue: https://github.com/eclipse-theia/theia/issues/new`);
249
250
  }
250
- for (let activationEvent of plugin.rawModel.activationEvents) {
251
+ for (let activationEvent of activationEvents) {
251
252
  if (activationEvent === 'onUri') {
252
253
  activationEvent = `onUri:theia://${plugin.model.id}`;
253
254
  }
@@ -255,6 +256,14 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
255
256
  }
256
257
  }
257
258
  }
259
+
260
+ protected getActivationEvents(plugin: Plugin): string[] | undefined {
261
+ const result = plugin.rawModel.activationEvents;
262
+ return Array.isArray(result) ? result : undefined;
263
+ }
264
+
265
+ protected abstract isSupportedActivationEvent(activationEvent: string): boolean;
266
+
258
267
  protected setActivation(activationEvent: string, activation: () => Promise<void>): void {
259
268
  const activations = this.activations.get(activationEvent) || [];
260
269
  activations.push(activation);
@@ -363,11 +372,12 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
363
372
  const globalStoragePath = join(configStorage.hostGlobalStoragePath, plugin.model.id);
364
373
  const extension = new PluginExt(this, plugin);
365
374
  const extensionModeValue = plugin.isUnderDevelopment ? types.ExtensionMode.Development : types.ExtensionMode.Production;
375
+
366
376
  const pluginContext: theia.PluginContext = {
367
377
  extensionPath: extension.extensionPath,
368
378
  extensionUri: extension.extensionUri,
369
- globalState: new GlobalState(plugin.model.id, true, this.storageProxy),
370
- workspaceState: new Memento(plugin.model.id, false, this.storageProxy),
379
+ globalState: new GlobalState(plugin.model.id, true, this.storage),
380
+ workspaceState: new Memento(plugin.model.id, false, this.storage),
371
381
  subscriptions: subscriptions,
372
382
  asAbsolutePath: asAbsolutePath,
373
383
  logPath: logPath,
@@ -431,6 +441,50 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
431
441
  return this.onDidChangeEmitter.event;
432
442
  }
433
443
 
444
+ protected fireOnDidChange(): void {
445
+ this.onDidChangeEmitter.fire(undefined);
446
+ }
447
+
448
+ }
449
+
450
+ @injectable()
451
+ export class PluginManagerExtImpl extends AbstractPluginManagerExtImpl<PluginManagerInitializeParams> implements PluginManagerExt {
452
+
453
+ @inject(PreferenceRegistryExtImpl)
454
+ protected readonly preferencesManager: PreferenceRegistryExtImpl;
455
+
456
+ @inject(WebviewsExtImpl)
457
+ protected readonly webview: WebviewsExtImpl;
458
+
459
+ private supportedActivationEvents: Set<string>;
460
+
461
+ async $init(params: PluginManagerInitializeParams): Promise<void> {
462
+ this.storage.init(params.globalState, params.workspaceState);
463
+
464
+ this.envExt.setQueryParameters(params.env.queryParams);
465
+ this.envExt.setUIKind(params.env.uiKind);
466
+ this.envExt.setLanguage(params.env.language);
467
+ this.terminalService.$setShell(params.env.shell);
468
+ this.envExt.setApplicationName(params.env.appName);
469
+ this.envExt.setAppHost(params.env.appHost);
470
+ this.envExt.setAppRoot(params.env.appRoot);
471
+
472
+ this.preferencesManager.init(params.preferences);
473
+
474
+ if (params.extApi) {
475
+ this.host.initExtApi(params.extApi);
476
+ }
477
+
478
+ this.webview.init(params.webview);
479
+ this.jsonValidation = params.jsonValidation;
480
+
481
+ this.supportedActivationEvents = new Set(params.supportedActivationEvents ?? []);
482
+ }
483
+
484
+ protected isSupportedActivationEvent(activationEvent: string): boolean {
485
+ return this.supportedActivationEvents.has(activationEvent.split(':')[0]);
486
+ }
487
+
434
488
  }
435
489
 
436
490
  // for electron
@@ -15,7 +15,8 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as theia from '@theia/plugin';
18
- import { Event, Emitter } from '@theia/core/lib/common/event';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { Disposable, DisposableGroup, Event, Emitter } from '@theia/core';
19
20
  import { PLUGIN_RPC_CONTEXT, StorageMain, StorageExt } from '../common/plugin-api-rpc';
20
21
  import { KeysToAnyValues, KeysToKeysToAnyValue } from '../common/types';
21
22
  import { RPCProtocol } from '../common/rpc-protocol';
@@ -27,7 +28,7 @@ export class Memento implements theia.Memento {
27
28
  constructor(
28
29
  private readonly pluginId: string,
29
30
  private readonly isPluginGlobalData: boolean,
30
- private readonly storage: KeyValueStorageProxy
31
+ private readonly storage: InternalStorageExt
31
32
  ) {
32
33
  this.cache = storage.getPerPluginData(pluginId, isPluginGlobalData);
33
34
 
@@ -69,11 +70,28 @@ export class GlobalState extends Memento {
69
70
  setKeysForSync(keys: readonly string[]): void { }
70
71
  }
71
72
 
73
+ export const InternalStorageExt = Symbol('InternalStorageExt');
74
+ export interface InternalStorageExt extends StorageExt {
75
+
76
+ init(initGlobalData: KeysToKeysToAnyValue, initWorkspaceData: KeysToKeysToAnyValue): void;
77
+
78
+ getPerPluginData(key: string, isGlobal: boolean): KeysToAnyValues;
79
+
80
+ setPerPluginData(key: string, value: KeysToAnyValues, isGlobal: boolean): Promise<boolean>;
81
+
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ storageDataChangedEvent(listener: (e: KeysToKeysToAnyValue) => any, thisArgs?: any, disposables?: DisposableGroup): Disposable;
84
+
85
+ $updatePluginsWorkspaceData(workspaceData: KeysToKeysToAnyValue): void;
86
+
87
+ }
88
+
72
89
  /**
73
90
  * Singleton.
74
91
  * Is used to proxy storage requests to main side.
75
92
  */
76
- export class KeyValueStorageProxy implements StorageExt {
93
+ @injectable()
94
+ export class KeyValueStorageProxy implements InternalStorageExt {
77
95
 
78
96
  private storageDataChangedEmitter = new Emitter<KeysToKeysToAnyValue>();
79
97
  public readonly storageDataChangedEvent: Event<KeysToKeysToAnyValue> = this.storageDataChangedEmitter.event;
@@ -83,7 +101,7 @@ export class KeyValueStorageProxy implements StorageExt {
83
101
  private globalDataCache: KeysToKeysToAnyValue;
84
102
  private workspaceDataCache: KeysToKeysToAnyValue;
85
103
 
86
- constructor(rpc: RPCProtocol) {
104
+ constructor(@inject(RPCProtocol) rpc: RPCProtocol) {
87
105
  this.proxy = rpc.getProxy<StorageMain>(PLUGIN_RPC_CONTEXT.STORAGE_MAIN);
88
106
  }
89
107
 
@@ -14,6 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+ import { Container } from '@theia/core/shared/inversify';
17
18
  import { PreferenceRegistryExtImpl, PreferenceScope } from './preference-registry';
18
19
  import * as chai from 'chai';
19
20
  import { WorkspaceExtImpl } from '../plugin/workspace';
@@ -38,7 +39,11 @@ describe('PreferenceRegistryExtImpl:', () => {
38
39
  const mockWorkspace: WorkspaceExtImpl = { workspaceFolders: [{ uri: workspaceRoot, name: 'workspace-root', index: 0 }] } as WorkspaceExtImpl;
39
40
 
40
41
  beforeEach(() => {
41
- preferenceRegistryExtImpl = new PreferenceRegistryExtImpl(mockRPC, mockWorkspace);
42
+ const container = new Container();
43
+ container.bind(RPCProtocol).toConstantValue(mockRPC);
44
+ container.bind(WorkspaceExtImpl).toConstantValue(mockWorkspace);
45
+ container.bind(PreferenceRegistryExtImpl).toSelf().inSingletonScope();
46
+ preferenceRegistryExtImpl = container.get(PreferenceRegistryExtImpl);
42
47
  });
43
48
 
44
49
  describe('Prototype pollution', () => {
@@ -16,6 +16,7 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
20
  import { Emitter, Event } from '@theia/core/lib/common/event';
20
21
  import { isOSX, isWindows } from '@theia/core/lib/common/os';
21
22
  import { URI } from '@theia/core/shared/vscode-uri';
@@ -78,18 +79,23 @@ export class TheiaWorkspace extends Workspace {
78
79
  }
79
80
  }
80
81
 
82
+ @injectable()
81
83
  export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
84
+ @inject(RPCProtocol)
85
+ protected rpc: RPCProtocol;
86
+
87
+ @inject(WorkspaceExtImpl)
88
+ protected readonly workspace: WorkspaceExtImpl;
89
+
82
90
  private proxy: PreferenceRegistryMain;
83
91
  private _preferences: Configuration;
84
92
  private readonly _onDidChangeConfiguration = new Emitter<theia.ConfigurationChangeEvent>();
85
93
 
86
94
  readonly onDidChangeConfiguration: Event<theia.ConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
87
95
 
88
- constructor(
89
- rpc: RPCProtocol,
90
- private readonly workspace: WorkspaceExtImpl
91
- ) {
92
- this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.PREFERENCE_REGISTRY_MAIN);
96
+ @postConstruct()
97
+ initialize(): void {
98
+ this.proxy = this.rpc.getProxy(PLUGIN_RPC_CONTEXT.PREFERENCE_REGISTRY_MAIN);
93
99
  }
94
100
 
95
101
  init(data: PreferenceData): void {
@@ -246,11 +246,11 @@ export class QuickOpenExtImpl implements QuickOpenExt {
246
246
  async $acceptOnDidTriggerButton(sessionId: number, btn: QuickInputButtonHandle): Promise<void> {
247
247
  const session = this._sessions.get(sessionId);
248
248
  if (session) {
249
- if (btn.index === -1) {
249
+ if (btn.handle === -1) {
250
250
  session._fireButtonTrigger(QuickInputButtons.Back);
251
251
  } else if (session && (session instanceof InputBoxExt || session instanceof QuickPickExt)) {
252
- const btnFromIndex = session.buttons[btn.index];
253
- session._fireButtonTrigger(btnFromIndex as theia.QuickInputButton);
252
+ const btnFromHandle = session.buttons[btn.handle];
253
+ session._fireButtonTrigger(btnFromHandle as theia.QuickInputButton);
254
254
  }
255
255
  }
256
256
  }
@@ -20,17 +20,37 @@
20
20
  *--------------------------------------------------------------------------------------------*/
21
21
  // code copied and modified from https://github.com/microsoft/vscode/blob/1.55.2/src/vs/workbench/api/common/extHostSecrets.ts
22
22
 
23
+ import { inject, injectable } from '@theia/core/shared/inversify';
23
24
  import { Plugin, PLUGIN_RPC_CONTEXT, SecretsExt, SecretsMain } from '../common/plugin-api-rpc';
24
25
  import { RPCProtocol } from '../common/rpc-protocol';
25
26
  import { Event, Emitter } from '@theia/core/lib/common/event';
27
+ import { Disposable, DisposableGroup } from '@theia/core';
26
28
  import * as theia from '@theia/plugin';
27
29
 
28
- export class SecretsExtImpl implements SecretsExt {
30
+ export interface PasswordChange {
31
+ extensionId: string;
32
+ key: string;
33
+ }
34
+
35
+ export const InternalSecretsExt = Symbol('InternalSecretsExt');
36
+ export interface InternalSecretsExt extends SecretsExt {
37
+ get(extensionId: string, key: string): Promise<string | undefined>;
38
+
39
+ store(extensionId: string, key: string, value: string): Promise<void>;
40
+
41
+ delete(extensionId: string, key: string): Promise<void>;
42
+
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ onDidChangePassword(listener: (e: PasswordChange) => any, thisArgs?: any, disposables?: DisposableGroup): Disposable;
45
+ }
46
+
47
+ @injectable()
48
+ export class SecretsExtImpl implements InternalSecretsExt {
29
49
  private proxy: SecretsMain;
30
- private onDidChangePasswordEmitter = new Emitter<{ extensionId: string, key: string }>();
50
+ private onDidChangePasswordEmitter = new Emitter<PasswordChange>();
31
51
  readonly onDidChangePassword = this.onDidChangePasswordEmitter.event;
32
52
 
33
- constructor(rpc: RPCProtocol) {
53
+ constructor(@inject(RPCProtocol) rpc: RPCProtocol) {
34
54
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.SECRETS_MAIN);
35
55
  }
36
56
 
@@ -54,12 +74,12 @@ export class SecretsExtImpl implements SecretsExt {
54
74
  export class SecretStorageExt implements theia.SecretStorage {
55
75
 
56
76
  protected readonly id: string;
57
- readonly secretState: SecretsExtImpl;
77
+ readonly secretState: InternalSecretsExt;
58
78
 
59
79
  private onDidChangeEmitter = new Emitter<theia.SecretStorageChangeEvent>();
60
80
  readonly onDidChange: Event<theia.SecretStorageChangeEvent> = this.onDidChangeEmitter.event;
61
81
 
62
- constructor(pluginDescription: Plugin, secretState: SecretsExtImpl) {
82
+ constructor(pluginDescription: Plugin, secretState: InternalSecretsExt) {
63
83
  this.id = pluginDescription.model.id.toLowerCase();
64
84
  this.secretState = secretState;
65
85
 
@@ -14,6 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
  import { UUID } from '@theia/core/shared/@phosphor/coreutils';
17
+ import { inject, injectable } from '@theia/core/shared/inversify';
17
18
  import { Terminal, TerminalOptions, PseudoTerminalOptions, ExtensionTerminalOptions, TerminalState } from '@theia/plugin';
18
19
  import { TerminalServiceExt, TerminalServiceMain, PLUGIN_RPC_CONTEXT } from '../common/plugin-api-rpc';
19
20
  import { RPCProtocol } from '../common/rpc-protocol';
@@ -46,6 +47,7 @@ export function getIconClass(options: theia.TerminalOptions | theia.ExtensionTer
46
47
  * Provides high level terminal plugin api to use in the Theia plugins.
47
48
  * This service allow(with help proxy) create and use terminal emulator.
48
49
  */
50
+ @injectable()
49
51
  export class TerminalServiceExtImpl implements TerminalServiceExt {
50
52
 
51
53
  private readonly proxy: TerminalServiceMain;
@@ -75,7 +77,7 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
75
77
  private readonly onDidChangeShellEmitter = new Emitter<string>();
76
78
  readonly onDidChangeShell: theia.Event<string> = this.onDidChangeShellEmitter.event;
77
79
 
78
- constructor(rpc: RPCProtocol) {
80
+ constructor(@inject(RPCProtocol) rpc: RPCProtocol) {
79
81
  this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.TERMINAL_MAIN);
80
82
  }
81
83
 
@@ -463,8 +465,8 @@ export class TerminalExtImpl implements Terminal {
463
465
  this.creationOptions = this.options;
464
466
  }
465
467
 
466
- sendText(text: string, addNewLine: boolean = true): void {
467
- this.id.promise.then(id => this.proxy.$sendText(id, text, addNewLine));
468
+ sendText(text: string, shouldExecute: boolean = true): void {
469
+ this.id.promise.then(id => this.proxy.$sendText(id, text, shouldExecute));
468
470
  }
469
471
 
470
472
  show(preserveFocus?: boolean): void {