@theia/core 1.43.1 → 1.45.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 (320) hide show
  1. package/README.md +6 -6
  2. package/i18n/nls.cs.json +10 -3
  3. package/i18n/nls.de.json +10 -3
  4. package/i18n/nls.es.json +10 -3
  5. package/i18n/nls.fr.json +10 -3
  6. package/i18n/nls.hu.json +10 -3
  7. package/i18n/nls.it.json +10 -3
  8. package/i18n/nls.ja.json +10 -3
  9. package/i18n/nls.json +10 -3
  10. package/i18n/nls.pl.json +10 -3
  11. package/i18n/nls.pt-br.json +10 -3
  12. package/i18n/nls.pt-pt.json +10 -3
  13. package/i18n/nls.ru.json +10 -3
  14. package/i18n/nls.zh-cn.json +10 -3
  15. package/lib/browser/common-frontend-contribution.d.ts +10 -0
  16. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  17. package/lib/browser/common-frontend-contribution.js +68 -10
  18. package/lib/browser/common-frontend-contribution.js.map +1 -1
  19. package/lib/browser/connection-status-service.d.ts +2 -2
  20. package/lib/browser/connection-status-service.d.ts.map +1 -1
  21. package/lib/browser/connection-status-service.js +3 -3
  22. package/lib/browser/connection-status-service.js.map +1 -1
  23. package/lib/browser/connection-status-service.spec.js +6 -6
  24. package/lib/browser/connection-status-service.spec.js.map +1 -1
  25. package/lib/browser/core-preferences.d.ts.map +1 -1
  26. package/lib/browser/core-preferences.js +16 -0
  27. package/lib/browser/core-preferences.js.map +1 -1
  28. package/lib/browser/dialogs.d.ts +0 -1
  29. package/lib/browser/dialogs.d.ts.map +1 -1
  30. package/lib/browser/dialogs.js +1 -34
  31. package/lib/browser/dialogs.js.map +1 -1
  32. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  33. package/lib/browser/frontend-application-module.js +4 -0
  34. package/lib/browser/frontend-application-module.js.map +1 -1
  35. package/lib/browser/icon-theme-contribution.d.ts +1 -0
  36. package/lib/browser/icon-theme-contribution.d.ts.map +1 -1
  37. package/lib/browser/icon-theme-contribution.js +1 -0
  38. package/lib/browser/icon-theme-contribution.js.map +1 -1
  39. package/lib/browser/icon-theme-service.d.ts +1 -0
  40. package/lib/browser/icon-theme-service.d.ts.map +1 -1
  41. package/lib/browser/icon-theme-service.js.map +1 -1
  42. package/lib/browser/language-icon-provider.d.ts +15 -0
  43. package/lib/browser/language-icon-provider.d.ts.map +1 -0
  44. package/lib/browser/language-icon-provider.js +74 -0
  45. package/lib/browser/language-icon-provider.js.map +1 -0
  46. package/lib/browser/language-service.d.ts +22 -0
  47. package/lib/browser/language-service.d.ts.map +1 -1
  48. package/lib/browser/language-service.js +28 -0
  49. package/lib/browser/language-service.js.map +1 -1
  50. package/lib/browser/messaging/connection-source.d.ts +9 -0
  51. package/lib/browser/messaging/connection-source.d.ts.map +1 -0
  52. package/lib/browser/messaging/connection-source.js +20 -0
  53. package/lib/browser/messaging/connection-source.js.map +1 -0
  54. package/lib/browser/messaging/frontend-id-provider.d.ts +13 -0
  55. package/lib/browser/messaging/frontend-id-provider.d.ts.map +1 -0
  56. package/lib/browser/messaging/frontend-id-provider.js +40 -0
  57. package/lib/browser/messaging/frontend-id-provider.js.map +1 -0
  58. package/lib/browser/messaging/messaging-frontend-module.d.ts.map +1 -1
  59. package/lib/browser/messaging/messaging-frontend-module.js +18 -1
  60. package/lib/browser/messaging/messaging-frontend-module.js.map +1 -1
  61. package/lib/browser/messaging/service-connection-provider.d.ts +48 -0
  62. package/lib/browser/messaging/service-connection-provider.d.ts.map +1 -0
  63. package/lib/browser/messaging/service-connection-provider.js +115 -0
  64. package/lib/browser/messaging/service-connection-provider.js.map +1 -0
  65. package/lib/browser/messaging/ws-connection-provider.d.ts +7 -38
  66. package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
  67. package/lib/browser/messaging/ws-connection-provider.js +17 -121
  68. package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
  69. package/lib/browser/messaging/ws-connection-source.d.ts +41 -0
  70. package/lib/browser/messaging/ws-connection-source.d.ts.map +1 -0
  71. package/lib/browser/messaging/ws-connection-source.js +210 -0
  72. package/lib/browser/messaging/ws-connection-source.js.map +1 -0
  73. package/lib/browser/preload/i18n-preload-contribution.js +1 -1
  74. package/lib/browser/preload/i18n-preload-contribution.js.map +1 -1
  75. package/lib/browser/shell/application-shell.js +1 -1
  76. package/lib/browser/shell/application-shell.js.map +1 -1
  77. package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts +1 -0
  78. package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts.map +1 -1
  79. package/lib/browser/tree/tree-compression/compressed-tree-widget.js +5 -0
  80. package/lib/browser/tree/tree-compression/compressed-tree-widget.js.map +1 -1
  81. package/lib/browser/tree/tree-widget.d.ts +6 -0
  82. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  83. package/lib/browser/tree/tree-widget.js +21 -11
  84. package/lib/browser/tree/tree-widget.js.map +1 -1
  85. package/lib/browser/user-working-directory-provider.d.ts +8 -1
  86. package/lib/browser/user-working-directory-provider.d.ts.map +1 -1
  87. package/lib/browser/user-working-directory-provider.js +22 -1
  88. package/lib/browser/user-working-directory-provider.js.map +1 -1
  89. package/lib/browser/window/default-secondary-window-service.d.ts +3 -0
  90. package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
  91. package/lib/browser/window/default-secondary-window-service.js +55 -1
  92. package/lib/browser/window/default-secondary-window-service.js.map +1 -1
  93. package/lib/common/contribution-filter/contribution-filter.d.ts +9 -0
  94. package/lib/common/contribution-filter/contribution-filter.d.ts.map +1 -1
  95. package/lib/common/event.js +1 -1
  96. package/lib/common/event.js.map +1 -1
  97. package/lib/common/message-rpc/channel.d.ts.map +1 -1
  98. package/lib/common/message-rpc/channel.js +7 -1
  99. package/lib/common/message-rpc/channel.js.map +1 -1
  100. package/lib/common/message-rpc/message-buffer.d.ts +2 -0
  101. package/lib/common/message-rpc/message-buffer.d.ts.map +1 -1
  102. package/lib/common/message-rpc/message-buffer.js +4 -0
  103. package/lib/common/message-rpc/message-buffer.js.map +1 -1
  104. package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +1 -0
  105. package/lib/common/message-rpc/uint8-array-message-buffer.d.ts.map +1 -1
  106. package/lib/common/message-rpc/uint8-array-message-buffer.js +6 -0
  107. package/lib/common/message-rpc/uint8-array-message-buffer.js.map +1 -1
  108. package/lib/common/messaging/connection-management.d.ts +25 -0
  109. package/lib/common/messaging/connection-management.d.ts.map +1 -0
  110. package/lib/common/messaging/connection-management.js +38 -0
  111. package/lib/common/messaging/connection-management.js.map +1 -0
  112. package/lib/common/messaging/handler.d.ts +1 -0
  113. package/lib/common/messaging/handler.d.ts.map +1 -1
  114. package/lib/common/messaging/handler.js +2 -1
  115. package/lib/common/messaging/handler.js.map +1 -1
  116. package/lib/common/messaging/socket-write-buffer.d.ts +11 -0
  117. package/lib/common/messaging/socket-write-buffer.d.ts.map +1 -0
  118. package/lib/common/messaging/socket-write-buffer.js +50 -0
  119. package/lib/common/messaging/socket-write-buffer.js.map +1 -0
  120. package/lib/common/messaging/web-socket-channel.d.ts +7 -35
  121. package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
  122. package/lib/common/messaging/web-socket-channel.js +20 -9
  123. package/lib/common/messaging/web-socket-channel.js.map +1 -1
  124. package/lib/common/nls.js +12 -1
  125. package/lib/common/nls.js.map +1 -1
  126. package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts +5 -0
  127. package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts.map +1 -0
  128. package/lib/{electron-node/token/electron-token-messaging-contribution.js → electron-browser/messaging/electron-frontend-id-provider.js} +9 -28
  129. package/lib/electron-browser/messaging/electron-frontend-id-provider.js.map +1 -0
  130. package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts +24 -0
  131. package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts.map +1 -0
  132. package/lib/electron-browser/messaging/{electron-ipc-connection-provider.js → electron-ipc-connection-source.js} +19 -19
  133. package/lib/electron-browser/messaging/electron-ipc-connection-source.js.map +1 -0
  134. package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +7 -0
  135. package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts.map +1 -0
  136. package/lib/electron-browser/messaging/{electron-local-ws-connection-provider.js → electron-local-ws-connection-source.js} +7 -7
  137. package/lib/electron-browser/messaging/electron-local-ws-connection-source.js.map +1 -0
  138. package/lib/electron-browser/messaging/electron-messaging-frontend-module.d.ts.map +1 -1
  139. package/lib/electron-browser/messaging/electron-messaging-frontend-module.js +45 -13
  140. package/lib/electron-browser/messaging/electron-messaging-frontend-module.js.map +1 -1
  141. package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts +12 -0
  142. package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts.map +1 -0
  143. package/lib/electron-browser/messaging/{electron-ws-connection-provider.js → electron-ws-connection-source.js} +14 -21
  144. package/lib/electron-browser/messaging/electron-ws-connection-source.js.map +1 -0
  145. package/lib/electron-browser/preload.d.ts.map +1 -1
  146. package/lib/electron-browser/preload.js +11 -0
  147. package/lib/electron-browser/preload.js.map +1 -1
  148. package/lib/electron-browser/window/electron-secondary-window-service.d.ts +1 -1
  149. package/lib/electron-browser/window/electron-secondary-window-service.d.ts.map +1 -1
  150. package/lib/electron-browser/window/electron-window-module.js +2 -2
  151. package/lib/electron-browser/window/electron-window-module.js.map +1 -1
  152. package/lib/electron-browser/window/electron-window-preferences.js +1 -1
  153. package/lib/electron-browser/window/electron-window-preferences.js.map +1 -1
  154. package/lib/electron-browser/window/electron-window-service.d.ts +4 -0
  155. package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
  156. package/lib/electron-browser/window/electron-window-service.js +13 -0
  157. package/lib/electron-browser/window/electron-window-service.js.map +1 -1
  158. package/lib/electron-common/electron-api.d.ts +7 -0
  159. package/lib/electron-common/electron-api.d.ts.map +1 -1
  160. package/lib/electron-common/electron-api.js +3 -1
  161. package/lib/electron-common/electron-api.js.map +1 -1
  162. package/lib/electron-main/electron-api-main.d.ts +1 -0
  163. package/lib/electron-main/electron-api-main.d.ts.map +1 -1
  164. package/lib/electron-main/electron-api-main.js +15 -0
  165. package/lib/electron-main/electron-api-main.js.map +1 -1
  166. package/lib/electron-main/electron-main-application-module.js +5 -5
  167. package/lib/electron-main/electron-main-application-module.js.map +1 -1
  168. package/lib/electron-main/electron-main-application.d.ts +9 -13
  169. package/lib/electron-main/electron-main-application.d.ts.map +1 -1
  170. package/lib/electron-main/electron-main-application.js +60 -28
  171. package/lib/electron-main/electron-main-application.js.map +1 -1
  172. package/lib/electron-main/messaging/electron-connection-handler.d.ts.map +1 -0
  173. package/lib/electron-main/messaging/electron-connection-handler.js.map +1 -0
  174. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +13 -22
  175. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
  176. package/lib/electron-main/messaging/electron-messaging-contribution.js +39 -39
  177. package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
  178. package/lib/electron-main/messaging/electron-messaging-service.d.ts.map +1 -1
  179. package/lib/electron-main/messaging/electron-messaging-service.js.map +1 -1
  180. package/lib/electron-main/theia-electron-window.d.ts +2 -2
  181. package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
  182. package/lib/electron-main/theia-electron-window.js +3 -2
  183. package/lib/electron-main/theia-electron-window.js.map +1 -1
  184. package/lib/node/backend-application.d.ts +2 -0
  185. package/lib/node/backend-application.d.ts.map +1 -1
  186. package/lib/node/backend-application.js +11 -9
  187. package/lib/node/backend-application.js.map +1 -1
  188. package/lib/node/cli.d.ts +1 -1
  189. package/lib/node/cli.d.ts.map +1 -1
  190. package/lib/node/cli.js +9 -5
  191. package/lib/node/cli.js.map +1 -1
  192. package/lib/node/cli.spec.js +3 -3
  193. package/lib/node/cli.spec.js.map +1 -1
  194. package/lib/node/env-variables/env-variables-server.d.ts +3 -0
  195. package/lib/node/env-variables/env-variables-server.d.ts.map +1 -1
  196. package/lib/node/env-variables/env-variables-server.js +25 -1
  197. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  198. package/lib/node/i18n/localization-server.d.ts +1 -1
  199. package/lib/node/i18n/localization-server.d.ts.map +1 -1
  200. package/lib/node/messaging/default-messaging-service.d.ts +29 -0
  201. package/lib/node/messaging/default-messaging-service.d.ts.map +1 -0
  202. package/lib/node/messaging/default-messaging-service.js +140 -0
  203. package/lib/node/messaging/default-messaging-service.js.map +1 -0
  204. package/lib/node/messaging/frontend-connection-service.d.ts +7 -0
  205. package/lib/node/messaging/frontend-connection-service.d.ts.map +1 -0
  206. package/lib/node/messaging/frontend-connection-service.js +19 -0
  207. package/lib/node/messaging/frontend-connection-service.js.map +1 -0
  208. package/lib/node/messaging/ipc-protocol.js +1 -1
  209. package/lib/node/messaging/ipc-protocol.js.map +1 -1
  210. package/lib/node/messaging/messaging-backend-module.d.ts.map +1 -1
  211. package/lib/node/messaging/messaging-backend-module.js +23 -9
  212. package/lib/node/messaging/messaging-backend-module.js.map +1 -1
  213. package/lib/node/messaging/messaging-service.d.ts +2 -3
  214. package/lib/node/messaging/messaging-service.d.ts.map +1 -1
  215. package/lib/node/messaging/test/test-web-socket-channel.d.ts +3 -3
  216. package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
  217. package/lib/node/messaging/test/test-web-socket-channel.js +38 -24
  218. package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
  219. package/lib/node/messaging/websocket-endpoint.d.ts +21 -0
  220. package/lib/node/messaging/websocket-endpoint.d.ts.map +1 -0
  221. package/lib/node/messaging/websocket-endpoint.js +89 -0
  222. package/lib/node/messaging/websocket-endpoint.js.map +1 -0
  223. package/lib/node/messaging/websocket-frontend-connection-service.d.ts +30 -0
  224. package/lib/node/messaging/websocket-frontend-connection-service.d.ts.map +1 -0
  225. package/lib/node/messaging/websocket-frontend-connection-service.js +173 -0
  226. package/lib/node/messaging/websocket-frontend-connection-service.js.map +1 -0
  227. package/package.json +6 -6
  228. package/src/browser/common-frontend-contribution.ts +70 -9
  229. package/src/browser/connection-status-service.spec.ts +6 -6
  230. package/src/browser/connection-status-service.ts +2 -2
  231. package/src/browser/core-preferences.ts +16 -0
  232. package/src/browser/dialogs.ts +0 -34
  233. package/src/browser/frontend-application-module.ts +4 -0
  234. package/src/browser/icon-theme-contribution.ts +1 -0
  235. package/src/browser/icon-theme-service.ts +1 -0
  236. package/src/browser/language-icon-provider.ts +55 -0
  237. package/src/browser/language-service.ts +34 -0
  238. package/src/browser/messaging/connection-source.ts +26 -0
  239. package/src/browser/messaging/frontend-id-provider.ts +37 -0
  240. package/src/browser/messaging/messaging-frontend-module.ts +20 -2
  241. package/src/browser/messaging/service-connection-provider.ts +126 -0
  242. package/src/browser/messaging/ws-connection-provider.ts +16 -141
  243. package/src/browser/messaging/ws-connection-source.ts +210 -0
  244. package/src/browser/preload/i18n-preload-contribution.ts +1 -1
  245. package/src/browser/shell/application-shell.ts +1 -1
  246. package/src/browser/style/index.css +1 -0
  247. package/src/browser/style/os.css +87 -0
  248. package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +27 -7
  249. package/src/browser/tree/tree-widget.tsx +21 -10
  250. package/src/browser/user-working-directory-provider.ts +32 -3
  251. package/src/browser/window/default-secondary-window-service.ts +54 -1
  252. package/src/common/contribution-filter/contribution-filter.ts +9 -0
  253. package/src/common/event.ts +1 -1
  254. package/src/common/i18n/nls.metadata.json +7695 -7220
  255. package/src/common/message-rpc/channel.ts +5 -1
  256. package/src/common/message-rpc/message-buffer.ts +6 -0
  257. package/src/common/message-rpc/uint8-array-message-buffer.ts +7 -0
  258. package/src/common/messaging/connection-management.ts +43 -0
  259. package/src/common/messaging/handler.ts +2 -0
  260. package/src/common/messaging/socket-write-buffer.ts +52 -0
  261. package/src/common/messaging/web-socket-channel.ts +28 -45
  262. package/src/common/nls.ts +12 -1
  263. package/src/electron-browser/messaging/electron-frontend-id-provider.ts +25 -0
  264. package/src/electron-browser/messaging/{electron-ipc-connection-provider.ts → electron-ipc-connection-source.ts} +17 -13
  265. package/src/electron-browser/messaging/{electron-local-ws-connection-provider.ts → electron-local-ws-connection-source.ts} +2 -2
  266. package/src/electron-browser/messaging/electron-messaging-frontend-module.ts +49 -12
  267. package/src/electron-browser/messaging/{electron-ws-connection-provider.ts → electron-ws-connection-source.ts} +6 -17
  268. package/src/electron-browser/preload.ts +16 -1
  269. package/src/electron-browser/window/electron-secondary-window-service.ts +1 -1
  270. package/src/electron-browser/window/electron-window-module.ts +1 -1
  271. package/src/electron-browser/window/electron-window-preferences.ts +1 -1
  272. package/src/electron-browser/window/electron-window-service.ts +11 -0
  273. package/src/electron-common/electron-api.ts +8 -0
  274. package/src/electron-main/electron-api-main.ts +20 -1
  275. package/src/electron-main/electron-main-application-module.ts +5 -5
  276. package/src/electron-main/electron-main-application.ts +72 -44
  277. package/src/electron-main/messaging/electron-messaging-contribution.ts +45 -43
  278. package/src/electron-main/messaging/electron-messaging-service.ts +1 -0
  279. package/src/electron-main/theia-electron-window.ts +4 -3
  280. package/src/node/backend-application.ts +14 -11
  281. package/src/node/cli.spec.ts +3 -3
  282. package/src/node/cli.ts +9 -5
  283. package/src/node/env-variables/env-variables-server.ts +21 -1
  284. package/src/node/i18n/localization-server.ts +1 -1
  285. package/src/node/messaging/default-messaging-service.ts +129 -0
  286. package/src/node/messaging/frontend-connection-service.ts +24 -0
  287. package/src/node/messaging/ipc-protocol.ts +1 -1
  288. package/src/node/messaging/messaging-backend-module.ts +25 -10
  289. package/src/node/messaging/messaging-service.ts +3 -3
  290. package/src/node/messaging/test/test-web-socket-channel.ts +32 -27
  291. package/src/node/messaging/websocket-endpoint.ts +79 -0
  292. package/src/node/messaging/websocket-frontend-connection-service.ts +171 -0
  293. package/lib/common/messaging/abstract-connection-provider.d.ts +0 -45
  294. package/lib/common/messaging/abstract-connection-provider.d.ts.map +0 -1
  295. package/lib/common/messaging/abstract-connection-provider.js +0 -93
  296. package/lib/common/messaging/abstract-connection-provider.js.map +0 -1
  297. package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts +0 -19
  298. package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +0 -1
  299. package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +0 -1
  300. package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts +0 -7
  301. package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts.map +0 -1
  302. package/lib/electron-browser/messaging/electron-local-ws-connection-provider.js.map +0 -1
  303. package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +0 -17
  304. package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +0 -1
  305. package/lib/electron-browser/messaging/electron-ws-connection-provider.js.map +0 -1
  306. package/lib/electron-common/messaging/electron-connection-handler.d.ts.map +0 -1
  307. package/lib/electron-common/messaging/electron-connection-handler.js.map +0 -1
  308. package/lib/electron-node/token/electron-token-messaging-contribution.d.ts +0 -16
  309. package/lib/electron-node/token/electron-token-messaging-contribution.d.ts.map +0 -1
  310. package/lib/electron-node/token/electron-token-messaging-contribution.js.map +0 -1
  311. package/lib/node/messaging/messaging-contribution.d.ts +0 -44
  312. package/lib/node/messaging/messaging-contribution.d.ts.map +0 -1
  313. package/lib/node/messaging/messaging-contribution.js +0 -210
  314. package/lib/node/messaging/messaging-contribution.js.map +0 -1
  315. package/src/common/messaging/abstract-connection-provider.ts +0 -115
  316. package/src/electron-node/token/electron-token-messaging-contribution.ts +0 -41
  317. package/src/node/messaging/messaging-contribution.ts +0 -197
  318. /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.d.ts +0 -0
  319. /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.js +0 -0
  320. /package/src/{electron-common → electron-main}/messaging/electron-connection-handler.ts +0 -0
@@ -1,115 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson 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 { injectable, interfaces } from 'inversify';
18
- import { Emitter, Event } from '../event';
19
- import { ConnectionHandler } from './handler';
20
- import { RpcProxy, RpcProxyFactory } from './proxy-factory';
21
- import { Channel, ChannelMultiplexer } from '../message-rpc/channel';
22
-
23
- /**
24
- * Factor common logic according to `ElectronIpcConnectionProvider` and
25
- * `WebSocketConnectionProvider`. This class handles channels in a somewhat
26
- * generic way.
27
- */
28
- @injectable()
29
- export abstract class AbstractConnectionProvider<AbstractOptions extends object> {
30
-
31
- /**
32
- * Create a proxy object to remote interface of T type
33
- * over an electron ipc connection for the given path and proxy factory.
34
- */
35
- static createProxy<T extends object>(container: interfaces.Container, path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
36
- /**
37
- * Create a proxy object to remote interface of T type
38
- * over an electron ipc connection for the given path.
39
- *
40
- * An optional target can be provided to handle
41
- * notifications and requests from a remote side.
42
- */
43
- static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): RpcProxy<T> {
44
- throw new Error('abstract');
45
- }
46
-
47
- protected readonly onIncomingMessageActivityEmitter: Emitter<void> = new Emitter();
48
- get onIncomingMessageActivity(): Event<void> {
49
- return this.onIncomingMessageActivityEmitter.event;
50
- }
51
-
52
- /**
53
- * Create a proxy object to remote interface of T type
54
- * over a web socket connection for the given path and proxy factory.
55
- */
56
- createProxy<T extends object>(path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
57
- /**
58
- * Create a proxy object to remote interface of T type
59
- * over a web socket connection for the given path.
60
- *
61
- * An optional target can be provided to handle
62
- * notifications and requests from a remote side.
63
- */
64
- createProxy<T extends object>(path: string, target?: object): RpcProxy<T>;
65
- createProxy<T extends object>(path: string, arg?: object): RpcProxy<T> {
66
- const factory = arg instanceof RpcProxyFactory ? arg : new RpcProxyFactory<T>(arg);
67
- this.listen({
68
- path,
69
- onConnection: c => factory.listen(c)
70
- });
71
- return factory.createProxy();
72
- }
73
-
74
- protected channelMultiplexer?: ChannelMultiplexer;
75
-
76
- // A set of channel opening functions that are executed if the backend reconnects to restore the
77
- // the channels that were open before the disconnect occurred.
78
- protected reconnectChannelOpeners: Array<() => Promise<void>> = [];
79
-
80
- protected initializeMultiplexer(): void {
81
- const mainChannel = this.createMainChannel();
82
- mainChannel.onMessage(() => this.onIncomingMessageActivityEmitter.fire());
83
- this.channelMultiplexer = new ChannelMultiplexer(mainChannel);
84
- }
85
-
86
- /**
87
- * Install a connection handler for the given path.
88
- */
89
- listen(handler: ConnectionHandler, options?: AbstractOptions): void {
90
- this.openChannel(handler.path, channel => {
91
- handler.onConnection(channel);
92
- }, options);
93
- }
94
-
95
- async openChannel(path: string, handler: (channel: Channel) => void, options?: AbstractOptions): Promise<void> {
96
- if (!this.channelMultiplexer) {
97
- throw new Error('The channel multiplexer has not been initialized yet!');
98
- }
99
- const newChannel = await this.channelMultiplexer.open(path);
100
- newChannel.onClose(() => {
101
- const { reconnecting } = { reconnecting: true, ...options };
102
- if (reconnecting) {
103
- this.reconnectChannelOpeners.push(() => this.openChannel(path, handler, options));
104
- }
105
- });
106
-
107
- handler(newChannel);
108
- }
109
-
110
- /**
111
- * Create the main connection that is used for multiplexing all service channels.
112
- */
113
- protected abstract createMainChannel(): Channel;
114
-
115
- }
@@ -1,41 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson 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 * as http from 'http';
18
- import { injectable, inject } from 'inversify';
19
- import { MessagingContribution } from '../../node/messaging/messaging-contribution';
20
- import { ElectronTokenValidator } from './electron-token-validator';
21
-
22
- /**
23
- * Override the browser MessagingContribution class to refuse connections that do not include a specific token.
24
- * @deprecated since 1.8.0
25
- */
26
- @injectable()
27
- export class ElectronMessagingContribution extends MessagingContribution {
28
-
29
- @inject(ElectronTokenValidator)
30
- protected readonly tokenValidator: ElectronTokenValidator;
31
-
32
- /**
33
- * Only allow token-bearers.
34
- */
35
- protected override async allowConnect(request: http.IncomingMessage): Promise<boolean> {
36
- if (this.tokenValidator.allowRequest(request)) {
37
- return super.allowConnect(request);
38
- }
39
- return false;
40
- }
41
- }
@@ -1,197 +0,0 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * as http from 'http';
18
- import * as https from 'https';
19
- import { Server, Socket } from 'socket.io';
20
- import { injectable, inject, named, postConstruct, interfaces, Container } from 'inversify';
21
- import { ContributionProvider, ConnectionHandler, bindContributionProvider } from '../../common';
22
- import { IWebSocket, WebSocketChannel } from '../../common/messaging/web-socket-channel';
23
- import { BackendApplicationContribution } from '../backend-application';
24
- import { MessagingService } from './messaging-service';
25
- import { ConnectionContainerModule } from './connection-container-module';
26
- import Route = require('route-parser');
27
- import { WsRequestValidator } from '../ws-request-validators';
28
- import { MessagingListener } from './messaging-listeners';
29
- import { Channel, ChannelMultiplexer } from '../../common/message-rpc/channel';
30
-
31
- export const MessagingContainer = Symbol('MessagingContainer');
32
-
33
- @injectable()
34
- export class MessagingContribution implements BackendApplicationContribution, MessagingService {
35
-
36
- @inject(MessagingContainer)
37
- protected readonly container: interfaces.Container;
38
-
39
- @inject(ContributionProvider) @named(ConnectionContainerModule)
40
- protected readonly connectionModules: ContributionProvider<interfaces.ContainerModule>;
41
-
42
- @inject(ContributionProvider) @named(MessagingService.Contribution)
43
- protected readonly contributions: ContributionProvider<MessagingService.Contribution>;
44
-
45
- @inject(WsRequestValidator)
46
- protected readonly wsRequestValidator: WsRequestValidator;
47
-
48
- @inject(MessagingListener)
49
- protected readonly messagingListener: MessagingListener;
50
-
51
- protected readonly wsHandlers = new MessagingContribution.ConnectionHandlers<Socket>();
52
- protected readonly channelHandlers = new MessagingContribution.ConnectionHandlers<Channel>();
53
-
54
- @postConstruct()
55
- protected init(): void {
56
- this.ws(WebSocketChannel.wsPath, (_, socket) => this.handleChannels(socket));
57
- for (const contribution of this.contributions.getContributions()) {
58
- contribution.configure(this);
59
- }
60
- }
61
-
62
- wsChannel(spec: string, callback: (params: MessagingService.PathParams, channel: Channel) => void): void {
63
- this.channelHandlers.push(spec, (params, channel) => callback(params, channel));
64
- }
65
-
66
- ws(spec: string, callback: (params: MessagingService.PathParams, socket: Socket) => void): void {
67
- this.wsHandlers.push(spec, callback);
68
- }
69
-
70
- protected checkAliveTimeout = 30000; // 30 seconds
71
- protected maxHttpBufferSize = 1e8; // 100 MB
72
-
73
- onStart(server: http.Server | https.Server): void {
74
- const socketServer = new Server(server, {
75
- pingInterval: this.checkAliveTimeout,
76
- pingTimeout: this.checkAliveTimeout * 2,
77
- maxHttpBufferSize: this.maxHttpBufferSize
78
- });
79
- // Accept every namespace by using /.*/
80
- socketServer.of(/.*/).on('connection', async socket => {
81
- const request = socket.request;
82
- // Socket.io strips the `origin` header of the incoming request
83
- // We provide a `fix-origin` header in the `WebSocketConnectionProvider`
84
- request.headers.origin = request.headers['fix-origin'] as string;
85
- if (await this.allowConnect(socket.request)) {
86
- await this.handleConnection(socket);
87
- this.messagingListener.onDidWebSocketUpgrade(socket.request, socket);
88
- } else {
89
- socket.disconnect(true);
90
- }
91
- });
92
- }
93
-
94
- protected async handleConnection(socket: Socket): Promise<void> {
95
- const pathname = socket.nsp.name;
96
- if (pathname && !this.wsHandlers.route(pathname, socket)) {
97
- console.error('Cannot find a ws handler for the path: ' + pathname);
98
- }
99
- }
100
-
101
- protected async allowConnect(request: http.IncomingMessage): Promise<boolean> {
102
- try {
103
- return this.wsRequestValidator.allowWsUpgrade(request);
104
- } catch (e) {
105
- return false;
106
- }
107
- }
108
-
109
- protected handleChannels(socket: Socket): void {
110
- const socketChannel = new WebSocketChannel(this.toIWebSocket(socket));
111
- const multiplexer = new ChannelMultiplexer(socketChannel);
112
- const channelHandlers = this.getConnectionChannelHandlers(socket);
113
- multiplexer.onDidOpenChannel(event => {
114
- if (channelHandlers.route(event.id, event.channel)) {
115
- console.debug(`Opening channel for service path '${event.id}'.`);
116
- event.channel.onClose(() => console.debug(`Closing channel on service path '${event.id}'.`));
117
- }
118
- });
119
- }
120
-
121
- protected toIWebSocket(socket: Socket): IWebSocket {
122
- return {
123
- close: () => {
124
- socket.removeAllListeners('disconnect');
125
- socket.removeAllListeners('error');
126
- socket.removeAllListeners('message');
127
- socket.disconnect();
128
- },
129
- isConnected: () => socket.connected,
130
- onClose: cb => socket.on('disconnect', reason => cb(reason)),
131
- onError: cb => socket.on('error', error => cb(error)),
132
- onMessage: cb => socket.on('message', data => cb(data)),
133
- send: message => socket.emit('message', message)
134
- };
135
- }
136
-
137
- protected createSocketContainer(socket: Socket): Container {
138
- const connectionContainer: Container = this.container.createChild() as Container;
139
- connectionContainer.bind(Socket).toConstantValue(socket);
140
- return connectionContainer;
141
- }
142
-
143
- protected getConnectionChannelHandlers(socket: Socket): MessagingContribution.ConnectionHandlers<Channel> {
144
- const connectionContainer = this.createSocketContainer(socket);
145
- bindContributionProvider(connectionContainer, ConnectionHandler);
146
- connectionContainer.load(...this.connectionModules.getContributions());
147
- const connectionChannelHandlers = new MessagingContribution.ConnectionHandlers(this.channelHandlers);
148
- const connectionHandlers = connectionContainer.getNamed<ContributionProvider<ConnectionHandler>>(ContributionProvider, ConnectionHandler);
149
- for (const connectionHandler of connectionHandlers.getContributions(true)) {
150
- connectionChannelHandlers.push(connectionHandler.path, (_, channel) => {
151
- connectionHandler.onConnection(channel);
152
- });
153
- }
154
- return connectionChannelHandlers;
155
- }
156
-
157
- }
158
-
159
- export namespace MessagingContribution {
160
- export class ConnectionHandlers<T> {
161
- protected readonly handlers: ((path: string, connection: T) => string | false)[] = [];
162
-
163
- constructor(
164
- protected readonly parent?: ConnectionHandlers<T>
165
- ) { }
166
-
167
- push(spec: string, callback: (params: MessagingService.PathParams, connection: T) => void): void {
168
- const route = new Route(spec);
169
- const handler = (path: string, channel: T): string | false => {
170
- const params = route.match(path);
171
- if (!params) {
172
- return false;
173
- }
174
- callback(params, channel);
175
- return route.reverse(params);
176
- };
177
- this.handlers.push(handler);
178
- }
179
-
180
- route(path: string, connection: T): string | false {
181
- for (const handler of this.handlers) {
182
- try {
183
- const result = handler(path, connection);
184
- if (result) {
185
- return result;
186
- }
187
- } catch (e) {
188
- console.error(e);
189
- }
190
- }
191
- if (this.parent) {
192
- return this.parent.route(path, connection);
193
- }
194
- return false;
195
- }
196
- }
197
- }