@theia/core 1.77.0-next.6 → 1.77.0-next.63

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 (455) hide show
  1. package/README.md +5 -5
  2. package/lib/browser/breadcrumbs/breadcrumbs-renderer.js +1 -1
  3. package/lib/browser/breadcrumbs/breadcrumbs-renderer.js.map +1 -1
  4. package/lib/browser/catalog.json +294 -22
  5. package/lib/browser/color-application-contribution.d.ts +7 -1
  6. package/lib/browser/color-application-contribution.d.ts.map +1 -1
  7. package/lib/browser/color-application-contribution.js +15 -4
  8. package/lib/browser/color-application-contribution.js.map +1 -1
  9. package/lib/browser/color-application-contribution.spec.d.ts +2 -0
  10. package/lib/browser/color-application-contribution.spec.d.ts.map +1 -0
  11. package/lib/browser/color-application-contribution.spec.js +96 -0
  12. package/lib/browser/color-application-contribution.spec.js.map +1 -0
  13. package/lib/browser/color-registry.d.ts +7 -1
  14. package/lib/browser/color-registry.d.ts.map +1 -1
  15. package/lib/browser/color-registry.js +12 -0
  16. package/lib/browser/color-registry.js.map +1 -1
  17. package/lib/browser/common-frontend-contribution.d.ts +6 -1
  18. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  19. package/lib/browser/common-frontend-contribution.js +20 -3
  20. package/lib/browser/common-frontend-contribution.js.map +1 -1
  21. package/lib/browser/common-frontend-contribution.spec.js +2 -1
  22. package/lib/browser/common-frontend-contribution.spec.js.map +1 -1
  23. package/lib/browser/components/card.d.ts +1 -1
  24. package/lib/browser/components/card.d.ts.map +1 -1
  25. package/lib/browser/components/card.js +3 -2
  26. package/lib/browser/components/card.js.map +1 -1
  27. package/lib/browser/connection-status-service.spec.js +2 -1
  28. package/lib/browser/connection-status-service.spec.js.map +1 -1
  29. package/lib/browser/context-key-service.d.ts +11 -0
  30. package/lib/browser/context-key-service.d.ts.map +1 -1
  31. package/lib/browser/context-key-service.js +7 -0
  32. package/lib/browser/context-key-service.js.map +1 -1
  33. package/lib/browser/decorations-service.spec.js +2 -1
  34. package/lib/browser/decorations-service.spec.js.map +1 -1
  35. package/lib/browser/dialogs/react-dialog.spec.js +2 -1
  36. package/lib/browser/dialogs/react-dialog.spec.js.map +1 -1
  37. package/lib/browser/diff-uris.js +1 -1
  38. package/lib/browser/diff-uris.js.map +1 -1
  39. package/lib/browser/endpoint.js +2 -1
  40. package/lib/browser/endpoint.js.map +1 -1
  41. package/lib/browser/endpoint.spec.js +2 -1
  42. package/lib/browser/endpoint.spec.js.map +1 -1
  43. package/lib/browser/keybinding.d.ts +95 -17
  44. package/lib/browser/keybinding.d.ts.map +1 -1
  45. package/lib/browser/keybinding.js +406 -76
  46. package/lib/browser/keybinding.js.map +1 -1
  47. package/lib/browser/keybinding.spec.js +804 -33
  48. package/lib/browser/keybinding.spec.js.map +1 -1
  49. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js +1 -1
  50. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js.map +1 -1
  51. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts +3 -4
  52. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts.map +1 -1
  53. package/lib/browser/keyboard/browser-keyboard-layout-provider.js +3 -3
  54. package/lib/browser/keyboard/browser-keyboard-layout-provider.js.map +1 -1
  55. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js +42 -3
  56. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js.map +1 -1
  57. package/lib/browser/keyboard/keyboard-layout-service.d.ts +67 -15
  58. package/lib/browser/keyboard/keyboard-layout-service.d.ts.map +1 -1
  59. package/lib/browser/keyboard/keyboard-layout-service.js +313 -98
  60. package/lib/browser/keyboard/keyboard-layout-service.js.map +1 -1
  61. package/lib/browser/keyboard/keyboard-layout-service.spec.js +570 -15
  62. package/lib/browser/keyboard/keyboard-layout-service.spec.js.map +1 -1
  63. package/lib/browser/keyboard/keys.spec.js +187 -3
  64. package/lib/browser/keyboard/keys.spec.js.map +1 -1
  65. package/lib/browser/label-provider.d.ts.map +1 -1
  66. package/lib/browser/label-provider.js +5 -3
  67. package/lib/browser/label-provider.js.map +1 -1
  68. package/lib/browser/label-provider.spec.js +2 -1
  69. package/lib/browser/label-provider.spec.js.map +1 -1
  70. package/lib/browser/markdown-rendering/markdown-link-handler.js +2 -1
  71. package/lib/browser/markdown-rendering/markdown-link-handler.js.map +1 -1
  72. package/lib/browser/markdown-rendering/markdown-renderer.d.ts +1 -1
  73. package/lib/browser/markdown-rendering/markdown-renderer.d.ts.map +1 -1
  74. package/lib/browser/markdown-rendering/markdown-renderer.js +4 -4
  75. package/lib/browser/markdown-rendering/markdown-renderer.js.map +1 -1
  76. package/lib/browser/markdown-rendering/markdown.js +2 -1
  77. package/lib/browser/markdown-rendering/markdown.js.map +1 -1
  78. package/lib/browser/markdown-rendering/markdown.spec.js +2 -1
  79. package/lib/browser/markdown-rendering/markdown.spec.js.map +1 -1
  80. package/lib/browser/menu/action-menu-node.d.ts +5 -3
  81. package/lib/browser/menu/action-menu-node.d.ts.map +1 -1
  82. package/lib/browser/menu/action-menu-node.js +2 -11
  83. package/lib/browser/menu/action-menu-node.js.map +1 -1
  84. package/lib/browser/menu/action-menu-node.spec.d.ts +2 -0
  85. package/lib/browser/menu/action-menu-node.spec.d.ts.map +1 -0
  86. package/lib/browser/menu/action-menu-node.spec.js +54 -0
  87. package/lib/browser/menu/action-menu-node.spec.js.map +1 -0
  88. package/lib/browser/menu/browser-menu-plugin.js +1 -1
  89. package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
  90. package/lib/browser/menu/menu.spec.js +2 -1
  91. package/lib/browser/menu/menu.spec.js.map +1 -1
  92. package/lib/browser/opener-service.spec.js +3 -2
  93. package/lib/browser/opener-service.spec.js.map +1 -1
  94. package/lib/browser/perspective-service.spec.js +2 -1
  95. package/lib/browser/perspective-service.spec.js.map +1 -1
  96. package/lib/browser/preferences/preference-proxy.spec.js +2 -1
  97. package/lib/browser/preferences/preference-proxy.spec.js.map +1 -1
  98. package/lib/browser/preferences/preference-schema-provider.spec.js +2 -1
  99. package/lib/browser/preferences/preference-schema-provider.spec.js.map +1 -1
  100. package/lib/browser/preferences/preference-service.spec.js +2 -1
  101. package/lib/browser/preferences/preference-service.spec.js.map +1 -1
  102. package/lib/browser/preferences/preference-validation-service.spec.js +78 -77
  103. package/lib/browser/preferences/preference-validation-service.spec.js.map +1 -1
  104. package/lib/browser/quick-input/quick-command-service.d.ts +10 -1
  105. package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
  106. package/lib/browser/quick-input/quick-command-service.js +31 -6
  107. package/lib/browser/quick-input/quick-command-service.js.map +1 -1
  108. package/lib/browser/quick-input/quick-command-service.spec.d.ts +2 -0
  109. package/lib/browser/quick-input/quick-command-service.spec.d.ts.map +1 -0
  110. package/lib/browser/quick-input/quick-command-service.spec.js +130 -0
  111. package/lib/browser/quick-input/quick-command-service.spec.js.map +1 -0
  112. package/lib/browser/quick-input/quick-help-service.js +1 -1
  113. package/lib/browser/quick-input/quick-help-service.js.map +1 -1
  114. package/lib/browser/quick-input/quick-input-service.spec.js +2 -1
  115. package/lib/browser/quick-input/quick-input-service.spec.js.map +1 -1
  116. package/lib/browser/quick-input/quick-pick-service-impl.d.ts +6 -6
  117. package/lib/browser/quick-input/quick-pick-service-impl.d.ts.map +1 -1
  118. package/lib/browser/quick-input/quick-view-service.spec.js +2 -1
  119. package/lib/browser/quick-input/quick-view-service.spec.js.map +1 -1
  120. package/lib/browser/secondary-window-handler.d.ts +4 -4
  121. package/lib/browser/secondary-window-handler.d.ts.map +1 -1
  122. package/lib/browser/shell/application-shell.js +1 -1
  123. package/lib/browser/shell/application-shell.js.map +1 -1
  124. package/lib/browser/shell/application-shell.spec.js +2 -1
  125. package/lib/browser/shell/application-shell.spec.js.map +1 -1
  126. package/lib/browser/shell/shell-layout-restorer.spec.js +2 -1
  127. package/lib/browser/shell/shell-layout-restorer.spec.js.map +1 -1
  128. package/lib/browser/shell/side-panel-toolbar.d.ts +1 -1
  129. package/lib/browser/shell/side-panel-toolbar.d.ts.map +1 -1
  130. package/lib/browser/shell/sidebar-menu-widget.js +1 -1
  131. package/lib/browser/shell/sidebar-menu-widget.js.map +1 -1
  132. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +1 -1
  133. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
  134. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js +2 -1
  135. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js.map +1 -1
  136. package/lib/browser/shell/tab-bars.js +2 -1
  137. package/lib/browser/shell/tab-bars.js.map +1 -1
  138. package/lib/browser/status-bar/status-bar.js +1 -1
  139. package/lib/browser/status-bar/status-bar.js.map +1 -1
  140. package/lib/browser/storage-service.spec.js +2 -1
  141. package/lib/browser/storage-service.spec.js.map +1 -1
  142. package/lib/browser/test/jsdom.d.ts.map +1 -1
  143. package/lib/browser/test/jsdom.js +11 -0
  144. package/lib/browser/test/jsdom.js.map +1 -1
  145. package/lib/browser/tooltip-service.js +1 -1
  146. package/lib/browser/tooltip-service.js.map +1 -1
  147. package/lib/browser/tree/tree-compression/compressed-tree-model.d.ts +2 -0
  148. package/lib/browser/tree/tree-compression/compressed-tree-model.d.ts.map +1 -1
  149. package/lib/browser/tree/tree-compression/compressed-tree-model.js +6 -2
  150. package/lib/browser/tree/tree-compression/compressed-tree-model.js.map +1 -1
  151. package/lib/browser/tree/tree-compression/compressed-tree-model.spec.d.ts +2 -0
  152. package/lib/browser/tree/tree-compression/compressed-tree-model.spec.d.ts.map +1 -0
  153. package/lib/browser/tree/tree-compression/compressed-tree-model.spec.js +52 -0
  154. package/lib/browser/tree/tree-compression/compressed-tree-model.spec.js.map +1 -0
  155. package/lib/browser/tree/tree-consistency.spec.js +1 -1
  156. package/lib/browser/tree/tree-consistency.spec.js.map +1 -1
  157. package/lib/browser/tree/tree-container.spec.js +6 -5
  158. package/lib/browser/tree/tree-container.spec.js.map +1 -1
  159. package/lib/browser/tree/tree-iterator.js +1 -1
  160. package/lib/browser/tree/tree-iterator.js.map +1 -1
  161. package/lib/browser/tree/tree-model.js +2 -2
  162. package/lib/browser/tree/tree-model.js.map +1 -1
  163. package/lib/browser/tree/tree-selection-state.d.ts +23 -1
  164. package/lib/browser/tree/tree-selection-state.d.ts.map +1 -1
  165. package/lib/browser/tree/tree-selection-state.js +23 -1
  166. package/lib/browser/tree/tree-selection-state.js.map +1 -1
  167. package/lib/browser/tree/tree-view-welcome-widget.js +1 -1
  168. package/lib/browser/tree/tree-view-welcome-widget.js.map +1 -1
  169. package/lib/browser/tree/tree-widget.d.ts +30 -2
  170. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  171. package/lib/browser/tree/tree-widget.js +62 -7
  172. package/lib/browser/tree/tree-widget.js.map +1 -1
  173. package/lib/browser/tree/tree-widget.spec.js +71 -3
  174. package/lib/browser/tree/tree-widget.spec.js.map +1 -1
  175. package/lib/browser/tree/tree.spec.js +2 -1
  176. package/lib/browser/tree/tree.spec.js.map +1 -1
  177. package/lib/browser/user-working-directory-provider.js +1 -1
  178. package/lib/browser/user-working-directory-provider.js.map +1 -1
  179. package/lib/browser/view-container.d.ts.map +1 -1
  180. package/lib/browser/view-container.js +2 -1
  181. package/lib/browser/view-container.js.map +1 -1
  182. package/lib/browser/widgets/react-renderer.js +1 -1
  183. package/lib/browser/widgets/react-renderer.js.map +1 -1
  184. package/lib/browser/widgets/react-widget.js +1 -1
  185. package/lib/browser/widgets/react-widget.js.map +1 -1
  186. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  187. package/lib/browser/widgets/select-component.js +10 -14
  188. package/lib/browser/widgets/select-component.js.map +1 -1
  189. package/lib/browser/widgets/select-component.spec.d.ts +2 -0
  190. package/lib/browser/widgets/select-component.spec.d.ts.map +1 -0
  191. package/lib/browser/widgets/select-component.spec.js +67 -0
  192. package/lib/browser/widgets/select-component.spec.js.map +1 -0
  193. package/lib/browser/widgets/widget.js +1 -1
  194. package/lib/browser/widgets/widget.js.map +1 -1
  195. package/lib/common/buffer.js +3 -2
  196. package/lib/common/buffer.js.map +1 -1
  197. package/lib/common/cancellation.js.map +1 -1
  198. package/lib/common/command.spec.js +2 -1
  199. package/lib/common/command.spec.js.map +1 -1
  200. package/lib/common/core-preferences.js +5 -5
  201. package/lib/common/core-preferences.js.map +1 -1
  202. package/lib/common/disposable.spec.js +3 -2
  203. package/lib/common/disposable.spec.js.map +1 -1
  204. package/lib/common/encoding-service.js +2 -2
  205. package/lib/common/encoding-service.js.map +1 -1
  206. package/lib/common/event.d.ts +1 -1
  207. package/lib/common/event.d.ts.map +1 -1
  208. package/lib/common/event.js +0 -1
  209. package/lib/common/event.js.map +1 -1
  210. package/lib/common/file-uri.js +2 -1
  211. package/lib/common/file-uri.js.map +1 -1
  212. package/lib/common/fuzzy-search.js +1 -1
  213. package/lib/common/fuzzy-search.js.map +1 -1
  214. package/lib/common/glob.d.ts.map +1 -1
  215. package/lib/common/glob.js +9 -15
  216. package/lib/common/glob.js.map +1 -1
  217. package/lib/common/index.js +1 -1
  218. package/lib/common/index.js.map +1 -1
  219. package/lib/common/keyboard/keyboard-layout-provider.d.ts +7 -0
  220. package/lib/common/keyboard/keyboard-layout-provider.d.ts.map +1 -1
  221. package/lib/common/keyboard/keyboard-layout-provider.js.map +1 -1
  222. package/lib/common/keys.d.ts +86 -3
  223. package/lib/common/keys.d.ts.map +1 -1
  224. package/lib/common/keys.js +263 -24
  225. package/lib/common/keys.js.map +1 -1
  226. package/lib/common/message-rpc/channel.spec.js +3 -2
  227. package/lib/common/message-rpc/channel.spec.js.map +1 -1
  228. package/lib/common/messaging/proxy-factory.js +2 -2
  229. package/lib/common/messaging/proxy-factory.js.map +1 -1
  230. package/lib/common/messaging/proxy-factory.spec.js +2 -1
  231. package/lib/common/messaging/proxy-factory.spec.js.map +1 -1
  232. package/lib/common/messaging/web-socket-channel.d.ts +1 -1
  233. package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
  234. package/lib/common/path.spec.js +2 -1
  235. package/lib/common/path.spec.js.map +1 -1
  236. package/lib/common/performance/stopwatch.spec.js +2 -1
  237. package/lib/common/performance/stopwatch.spec.js.map +1 -1
  238. package/lib/common/preferences/preference-schema-service.d.ts +2 -2
  239. package/lib/common/preferences/preference-schema-service.d.ts.map +1 -1
  240. package/lib/common/preferences/preference-service.js +1 -1
  241. package/lib/common/preferences/preference-service.js.map +1 -1
  242. package/lib/common/promise-util.d.ts.map +1 -1
  243. package/lib/common/promise-util.js +5 -2
  244. package/lib/common/promise-util.js.map +1 -1
  245. package/lib/common/promise-util.spec.js +17 -1
  246. package/lib/common/promise-util.spec.js.map +1 -1
  247. package/lib/common/quick-pick-service.d.ts +5 -0
  248. package/lib/common/quick-pick-service.d.ts.map +1 -1
  249. package/lib/common/quick-pick-service.js +2 -1
  250. package/lib/common/quick-pick-service.js.map +1 -1
  251. package/lib/common/reference.spec.js +2 -1
  252. package/lib/common/reference.spec.js.map +1 -1
  253. package/lib/common/resource.js +1 -1
  254. package/lib/common/resource.js.map +1 -1
  255. package/lib/common/selection-service.spec.js +2 -1
  256. package/lib/common/selection-service.spec.js.map +1 -1
  257. package/lib/common/selection.js +2 -1
  258. package/lib/common/selection.js.map +1 -1
  259. package/lib/common/stream.d.ts.map +1 -1
  260. package/lib/common/stream.js +2 -1
  261. package/lib/common/stream.js.map +1 -1
  262. package/lib/common/strings.d.ts.map +1 -1
  263. package/lib/common/strings.js +1 -2
  264. package/lib/common/strings.js.map +1 -1
  265. package/lib/common/ternary-search-tree.js +2 -2
  266. package/lib/common/ternary-search-tree.js.map +1 -1
  267. package/lib/common/ternary-search-tree.spec.js +12 -0
  268. package/lib/common/ternary-search-tree.spec.js.map +1 -1
  269. package/lib/common/test/mock-resource-provider.js +1 -1
  270. package/lib/common/test/mock-resource-provider.js.map +1 -1
  271. package/lib/common/types.spec.js +2 -1
  272. package/lib/common/types.spec.js.map +1 -1
  273. package/lib/common/uri-command-handler.js +4 -3
  274. package/lib/common/uri-command-handler.js.map +1 -1
  275. package/lib/common/uri-command-handler.spec.js +3 -2
  276. package/lib/common/uri-command-handler.spec.js.map +1 -1
  277. package/lib/common/uri.spec.js +3 -2
  278. package/lib/common/uri.spec.js.map +1 -1
  279. package/lib/electron-browser/electron-clipboard-service.d.ts +1 -1
  280. package/lib/electron-browser/electron-clipboard-service.d.ts.map +1 -1
  281. package/lib/electron-browser/keyboard/electron-keyboard-module.d.ts +2 -0
  282. package/lib/electron-browser/keyboard/electron-keyboard-module.d.ts.map +1 -1
  283. package/lib/electron-browser/keyboard/electron-keyboard-module.js +8 -1
  284. package/lib/electron-browser/keyboard/electron-keyboard-module.js.map +1 -1
  285. package/lib/electron-browser/keyboard/electron-keyboard-module.spec.d.ts +2 -0
  286. package/lib/electron-browser/keyboard/electron-keyboard-module.spec.d.ts.map +1 -0
  287. package/lib/electron-browser/keyboard/electron-keyboard-module.spec.js +28 -0
  288. package/lib/electron-browser/keyboard/electron-keyboard-module.spec.js.map +1 -0
  289. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  290. package/lib/electron-browser/menu/electron-main-menu-factory.js +3 -2
  291. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  292. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  293. package/lib/electron-browser/menu/electron-menu-contribution.js +3 -0
  294. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  295. package/lib/electron-browser/preload.js +1 -1
  296. package/lib/electron-browser/preload.js.map +1 -1
  297. package/lib/electron-browser/window/window-zoom-action-bar.js +2 -1
  298. package/lib/electron-browser/window/window-zoom-action-bar.js.map +1 -1
  299. package/lib/electron-common/electron-api.d.ts +6 -1
  300. package/lib/electron-common/electron-api.d.ts.map +1 -1
  301. package/lib/electron-common/electron-api.js +21 -0
  302. package/lib/electron-common/electron-api.js.map +1 -1
  303. package/lib/electron-common/electron-api.spec.d.ts +2 -0
  304. package/lib/electron-common/electron-api.spec.d.ts.map +1 -0
  305. package/lib/electron-common/electron-api.spec.js +40 -0
  306. package/lib/electron-common/electron-api.spec.js.map +1 -0
  307. package/lib/electron-main/electron-api-main.d.ts +0 -1
  308. package/lib/electron-main/electron-api-main.d.ts.map +1 -1
  309. package/lib/electron-main/electron-api-main.js +8 -18
  310. package/lib/electron-main/electron-api-main.js.map +1 -1
  311. package/lib/electron-main/electron-main-application.js +2 -2
  312. package/lib/electron-main/electron-main-application.js.map +1 -1
  313. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js +2 -1
  314. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js.map +1 -1
  315. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js +1 -1
  316. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js.map +1 -1
  317. package/lib/electron-node/token/electron-token-validator.js +2 -2
  318. package/lib/electron-node/token/electron-token-validator.js.map +1 -1
  319. package/lib/node/backend-application.d.ts +11 -5
  320. package/lib/node/backend-application.d.ts.map +1 -1
  321. package/lib/node/backend-application.js +34 -12
  322. package/lib/node/backend-application.js.map +1 -1
  323. package/lib/node/backend-application.spec.js +52 -3
  324. package/lib/node/backend-application.spec.js.map +1 -1
  325. package/lib/node/bundled-resource-provider.js +4 -4
  326. package/lib/node/bundled-resource-provider.js.map +1 -1
  327. package/lib/node/bundled-resource-provider.spec.js +5 -4
  328. package/lib/node/bundled-resource-provider.spec.js.map +1 -1
  329. package/lib/node/cli.d.ts +1 -1
  330. package/lib/node/cli.d.ts.map +1 -1
  331. package/lib/node/cli.js +2 -2
  332. package/lib/node/cli.js.map +1 -1
  333. package/lib/node/cli.spec.js +3 -2
  334. package/lib/node/cli.spec.js.map +1 -1
  335. package/lib/node/console-logger-server.js +1 -1
  336. package/lib/node/console-logger-server.js.map +1 -1
  337. package/lib/node/env-variables/env-variables-server.js +1 -1
  338. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  339. package/lib/node/environment-utils.spec.js +2 -1
  340. package/lib/node/environment-utils.spec.js.map +1 -1
  341. package/lib/node/file-uri.spec.js +4 -3
  342. package/lib/node/file-uri.spec.js.map +1 -1
  343. package/lib/node/filesystem-locking.js +1 -1
  344. package/lib/node/filesystem-locking.js.map +1 -1
  345. package/lib/node/hosting/browser-connection-token.js +2 -2
  346. package/lib/node/hosting/browser-connection-token.js.map +1 -1
  347. package/lib/node/i18n/localization-contribution.js +1 -1
  348. package/lib/node/i18n/localization-contribution.js.map +1 -1
  349. package/lib/node/key-store-server.js +1 -1
  350. package/lib/node/key-store-server.js.map +1 -1
  351. package/lib/node/logger-cli-contribution.js +2 -2
  352. package/lib/node/logger-cli-contribution.js.map +1 -1
  353. package/lib/node/logger-cli-contribution.spec.js +17 -16
  354. package/lib/node/logger-cli-contribution.spec.js.map +1 -1
  355. package/lib/node/messaging/binary-message-pipe.d.ts.map +1 -1
  356. package/lib/node/messaging/binary-message-pipe.js +5 -3
  357. package/lib/node/messaging/binary-message-pipe.js.map +1 -1
  358. package/lib/node/messaging/binary-message-pipe.spec.d.ts +2 -0
  359. package/lib/node/messaging/binary-message-pipe.spec.d.ts.map +1 -0
  360. package/lib/node/messaging/binary-message-pipe.spec.js +71 -0
  361. package/lib/node/messaging/binary-message-pipe.spec.js.map +1 -0
  362. package/lib/node/messaging/ipc-connection-provider.js +2 -2
  363. package/lib/node/messaging/ipc-connection-provider.js.map +1 -1
  364. package/lib/node/process-utils.d.ts +61 -0
  365. package/lib/node/process-utils.d.ts.map +1 -1
  366. package/lib/node/process-utils.js +157 -4
  367. package/lib/node/process-utils.js.map +1 -1
  368. package/lib/node/process-utils.slow-spec.d.ts +2 -0
  369. package/lib/node/process-utils.slow-spec.d.ts.map +1 -0
  370. package/lib/node/process-utils.slow-spec.js +106 -0
  371. package/lib/node/process-utils.slow-spec.js.map +1 -0
  372. package/lib/node/process-utils.spec.js +139 -1
  373. package/lib/node/process-utils.spec.js.map +1 -1
  374. package/lib/node/request/backend-request-facade.spec.js +2 -1
  375. package/lib/node/request/backend-request-facade.spec.js.map +1 -1
  376. package/lib/node/setting-service.spec.js +2 -1
  377. package/lib/node/setting-service.spec.js.map +1 -1
  378. package/lib/node/test/exiting-backend.d.ts +18 -0
  379. package/lib/node/test/exiting-backend.d.ts.map +1 -0
  380. package/lib/node/test/exiting-backend.js +71 -0
  381. package/lib/node/test/exiting-backend.js.map +1 -0
  382. package/package.json +16 -16
  383. package/src/browser/color-application-contribution.spec.ts +108 -0
  384. package/src/browser/color-application-contribution.ts +16 -4
  385. package/src/browser/color-registry.ts +13 -0
  386. package/src/browser/common-frontend-contribution.ts +17 -1
  387. package/src/browser/components/card.tsx +1 -1
  388. package/src/browser/context-key-service.ts +15 -0
  389. package/src/browser/keybinding.spec.ts +895 -34
  390. package/src/browser/keybinding.ts +470 -85
  391. package/src/browser/keyboard/browser-keyboard-frontend-contribution.ts +1 -1
  392. package/src/browser/keyboard/browser-keyboard-layout-provider.spec.ts +52 -1
  393. package/src/browser/keyboard/browser-keyboard-layout-provider.ts +5 -5
  394. package/src/browser/keyboard/keyboard-layout-service.spec.ts +673 -15
  395. package/src/browser/keyboard/keyboard-layout-service.ts +362 -106
  396. package/src/browser/keyboard/keys.spec.ts +206 -1
  397. package/src/browser/label-provider.ts +3 -1
  398. package/src/browser/markdown-rendering/markdown-renderer.ts +1 -1
  399. package/src/browser/menu/action-menu-node.spec.ts +60 -0
  400. package/src/browser/menu/action-menu-node.ts +8 -14
  401. package/src/browser/menu/browser-menu-plugin.ts +1 -1
  402. package/src/browser/preferences/preference-validation-service.spec.ts +1 -1
  403. package/src/browser/quick-input/quick-command-service.spec.ts +159 -0
  404. package/src/browser/quick-input/quick-command-service.ts +36 -9
  405. package/src/browser/quick-input/quick-help-service.ts +1 -1
  406. package/src/browser/style/hover-service.css +0 -2
  407. package/src/browser/test/jsdom.ts +11 -0
  408. package/src/browser/tree/tree-compression/compressed-tree-model.spec.ts +57 -0
  409. package/src/browser/tree/tree-compression/compressed-tree-model.ts +11 -2
  410. package/src/browser/tree/tree-container.spec.ts +1 -1
  411. package/src/browser/tree/tree-iterator.ts +1 -1
  412. package/src/browser/tree/tree-model.ts +2 -2
  413. package/src/browser/tree/tree-selection-state.ts +40 -1
  414. package/src/browser/tree/tree-widget.spec.tsx +79 -3
  415. package/src/browser/tree/tree-widget.tsx +68 -7
  416. package/src/browser/view-container.ts +2 -1
  417. package/src/browser/widgets/select-component.spec.ts +77 -0
  418. package/src/browser/widgets/select-component.tsx +6 -10
  419. package/src/common/cancellation.ts +1 -1
  420. package/src/common/core-preferences.ts +5 -5
  421. package/src/common/disposable.spec.ts +1 -1
  422. package/src/common/event.ts +1 -2
  423. package/src/common/glob.ts +13 -30
  424. package/src/common/json-schema.ts +1 -1
  425. package/src/common/keyboard/keyboard-layout-provider.ts +8 -0
  426. package/src/common/keys.ts +312 -27
  427. package/src/common/message-rpc/channel.spec.ts +1 -1
  428. package/src/common/messaging/proxy-factory.ts +2 -2
  429. package/src/common/promise-util.spec.ts +18 -2
  430. package/src/common/promise-util.ts +5 -2
  431. package/src/common/quick-pick-service.ts +5 -0
  432. package/src/common/stream.ts +4 -3
  433. package/src/common/strings.ts +2 -5
  434. package/src/common/ternary-search-tree.spec.ts +14 -0
  435. package/src/common/ternary-search-tree.ts +3 -3
  436. package/src/common/uri-command-handler.ts +2 -2
  437. package/src/electron-browser/electron-clipboard-service.ts +1 -1
  438. package/src/electron-browser/keyboard/electron-keyboard-module.spec.ts +29 -0
  439. package/src/electron-browser/keyboard/electron-keyboard-module.ts +9 -2
  440. package/src/electron-browser/menu/electron-main-menu-factory.ts +3 -3
  441. package/src/electron-browser/menu/electron-menu-contribution.ts +4 -0
  442. package/src/electron-browser/preload.ts +2 -2
  443. package/src/electron-common/electron-api.spec.ts +42 -0
  444. package/src/electron-common/electron-api.ts +24 -1
  445. package/src/electron-main/electron-api-main.ts +7 -17
  446. package/src/node/backend-application.spec.ts +68 -2
  447. package/src/node/backend-application.ts +28 -6
  448. package/src/node/cli.ts +1 -1
  449. package/src/node/logger-cli-contribution.spec.ts +1 -1
  450. package/src/node/messaging/binary-message-pipe.spec.ts +81 -0
  451. package/src/node/messaging/binary-message-pipe.ts +5 -4
  452. package/src/node/process-utils.slow-spec.ts +122 -0
  453. package/src/node/process-utils.spec.ts +162 -0
  454. package/src/node/process-utils.ts +166 -3
  455. package/src/node/test/exiting-backend.ts +75 -0
@@ -57,6 +57,10 @@ export class BinaryMessagePipe implements Disposable {
57
57
  }
58
58
 
59
59
  protected handleNewMessage(chunk: Uint8Array): void {
60
+ if (this.cachedMessageData.partialMessageStart) {
61
+ chunk = Buffer.concat([this.cachedMessageData.partialMessageStart, chunk]);
62
+ this.cachedMessageData.partialMessageStart = undefined;
63
+ }
60
64
  if (chunk.byteLength < this.messageStartByteLength) {
61
65
  // The chunk only contains a part of the encoded message start
62
66
  this.cachedMessageData.partialMessageStart = chunk;
@@ -137,10 +141,7 @@ export class BinaryMessagePipe implements Disposable {
137
141
  * @throws An error if the message start can not be read successfully.
138
142
  */
139
143
  protected readMessageStart(chunk: Uint8Array): number {
140
- const messageData = this.cachedMessageData.partialMessageStart ? Buffer.concat([this.cachedMessageData.partialMessageStart, chunk]) : chunk;
141
- this.cachedMessageData.partialMessageStart = undefined;
142
-
143
- const reader = new Uint8ArrayReadBuffer(messageData);
144
+ const reader = new Uint8ArrayReadBuffer(chunk);
144
145
  const identifier = reader.readString();
145
146
 
146
147
  if (identifier !== BinaryMessagePipe.MESSAGE_START_IDENTIFIER) {
@@ -0,0 +1,122 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 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 { expect } from 'chai';
18
+ import * as cp from 'child_process';
19
+ import { Container } from 'inversify';
20
+ import { ILogger } from '../common/logger';
21
+ import { MockLogger } from '../common/test/mock-logger';
22
+ import { ProcessUtils } from './process-utils';
23
+ import { EXITING_BACKEND_EXIT_CODE, EXITING_BACKEND_GRACEFUL, EXITING_BACKEND_NO_POWERSHELL } from './test/exiting-backend';
24
+
25
+ interface ExitingProcessResult {
26
+ exitCode: number | null;
27
+ childPid: number;
28
+ }
29
+
30
+ function runExitingProcess(options: { env?: NodeJS.ProcessEnv, detached?: boolean } = {}): Promise<ExitingProcessResult> {
31
+ return new Promise((resolve, reject) => {
32
+ const exitingProcess = cp.spawn(process.execPath, [require.resolve('./test/exiting-backend')], {
33
+ env: { ...process.env, ...options.env },
34
+ detached: options.detached,
35
+ stdio: ['ignore', 'pipe', 'inherit'],
36
+ windowsHide: true
37
+ });
38
+ let stdout = '';
39
+ exitingProcess.stdout.on('data', data => stdout += data);
40
+ exitingProcess.on('error', reject);
41
+ exitingProcess.on('close', exitCode => resolve({ exitCode, childPid: Number.parseInt(stdout, 10) }));
42
+ });
43
+ }
44
+
45
+ function isAlive(pid: number): boolean {
46
+ try {
47
+ process.kill(pid, 0);
48
+ return true;
49
+ } catch (error) {
50
+ return (error as NodeJS.ErrnoException).code !== 'ESRCH';
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Waits a little for the process to disappear, as killing it may not take effect immediately.
56
+ */
57
+ async function isAliveAfterKill(pid: number): Promise<boolean> {
58
+ for (let attempt = 0; attempt < 20 && isAlive(pid); attempt++) {
59
+ await new Promise(resolve => setTimeout(resolve, 100));
60
+ }
61
+ return isAlive(pid);
62
+ }
63
+
64
+ describe('ProcessUtils (real processes)', function (): void {
65
+
66
+ this.timeout(30_000);
67
+
68
+ const childPids: number[] = [];
69
+
70
+ afterEach(() => {
71
+ // Do not leak processes if a test fails.
72
+ for (const pid of childPids.splice(0)) {
73
+ if (isAlive(pid)) {
74
+ process.kill(pid);
75
+ }
76
+ }
77
+ });
78
+
79
+ async function expectTerminatedTree(options: Parameters<typeof runExitingProcess>[0], expectedExitCode: number): Promise<void> {
80
+ const { exitCode, childPid } = await runExitingProcess(options);
81
+ expect(childPid, 'the exiting process should report the PID of its child').to.be.greaterThan(0);
82
+ childPids.push(childPid);
83
+ expect(exitCode).to.equal(expectedExitCode);
84
+ expect(await isAliveAfterKill(childPid), 'the child of the exiting process should be killed').to.be.false;
85
+ }
86
+
87
+ it('keeps the exit code of the backend and kills its children', async () => {
88
+ await expectTerminatedTree({}, EXITING_BACKEND_EXIT_CODE);
89
+ });
90
+
91
+ (process.platform === 'win32' ? it.skip : it)('keeps the exit code of the backend when it leads its process group', async () => {
92
+ await expectTerminatedTree({ detached: true }, EXITING_BACKEND_EXIT_CODE);
93
+ });
94
+
95
+ it('kills the children of the backend on graceful shutdown', async () => {
96
+ // `BackendApplication.gracefulShutdown` exits with code 1 on purpose.
97
+ await expectTerminatedTree({ env: { [EXITING_BACKEND_GRACEFUL]: 'true' } }, 1);
98
+ });
99
+
100
+ (process.platform === 'win32' ? it : it.skip)('kills the whole tree of the backend when PowerShell cannot be run', async () => {
101
+ // Only PowerShell is made unrunnable: breaking the environment, e.g. `SystemRoot`, would
102
+ // break `taskkill.exe` as well. The fallback kills the backend too, with exit code 1.
103
+ await expectTerminatedTree({ env: { [EXITING_BACKEND_NO_POWERSHELL]: 'true' } }, 1);
104
+ });
105
+
106
+ (process.platform === 'win32' ? it : it.skip)('lists the children of a process with PowerShell', async () => {
107
+ const container = new Container();
108
+ container.bind(ProcessUtils).toSelf().inSingletonScope();
109
+ container.bind(ILogger).to(MockLogger).inSingletonScope();
110
+ const processUtils = container.get(ProcessUtils);
111
+
112
+ const children = [1, 2].map(() => cp.spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { stdio: 'ignore' }));
113
+ await Promise.all(children.map(child => new Promise(resolve => child.on('spawn', resolve))));
114
+ childPids.push(...children.map(child => child.pid!));
115
+
116
+ for (const listedPids of [processUtils['winGetChildPids'](process.pid), await processUtils['winGetChildPidsAsync'](process.pid)]) {
117
+ expect(listedPids).to.include.members(childPids);
118
+ // The PowerShell process that lists the children has exited by now, so it must not be listed.
119
+ expect(listedPids.filter(pid => !isAlive(pid)), 'only live processes should be listed').to.be.empty;
120
+ }
121
+ });
122
+ });
@@ -51,6 +51,33 @@ describe('ProcessUtils', () => {
51
51
  expect(Array.from(pids)).members([40, 5, 6, 7]);
52
52
  });
53
53
 
54
+ describe('#unixTerminateChildProcessTrees', () => {
55
+ let killStub: sinon.SinonStub;
56
+
57
+ beforeEach(() => {
58
+ coreProcessManager['execFile'] = async () => ({ stdout: mockPsOutput, stderr: '' });
59
+ killStub = sinon.stub();
60
+ coreProcessManager['unixKill'] = killStub;
61
+ });
62
+
63
+ afterEach(() => {
64
+ sinon.restore();
65
+ });
66
+
67
+ it('kills all descendants but not the process itself', async () => {
68
+ await coreProcessManager['unixTerminateChildProcessTrees'](2);
69
+ expect(killStub.args.map(([pid]) => pid)).members([40, 5, 6, 7]);
70
+ });
71
+
72
+ it('rejects when the processes cannot be listed', async () => {
73
+ coreProcessManager['execFile'] = async () => { throw new Error('ps not found'); };
74
+ let error: unknown;
75
+ await coreProcessManager['unixTerminateChildProcessTrees'](2).catch(e => error = e);
76
+ expect(error).to.be.instanceOf(Error);
77
+ expect(killStub.called).to.be.false;
78
+ });
79
+ });
80
+
54
81
  describe('#unixTerminateProcessTree', () => {
55
82
  let originalKill: typeof process.kill;
56
83
  let errorStub: sinon.SinonStub;
@@ -96,4 +123,139 @@ describe('ProcessUtils', () => {
96
123
  expect(errorStub.called).to.be.true;
97
124
  });
98
125
  });
126
+
127
+ describe('#winTerminateProcessTree', () => {
128
+ let taskkillStub: sinon.SinonStub;
129
+ let warnStub: sinon.SinonStub;
130
+
131
+ beforeEach(() => {
132
+ const mockLogger = (coreProcessManager as unknown as { logger: ILogger }).logger;
133
+ warnStub = sinon.stub(mockLogger, 'warn');
134
+ taskkillStub = sinon.stub();
135
+ coreProcessManager['winTaskkillTrees'] = taskkillStub;
136
+ });
137
+
138
+ afterEach(() => {
139
+ sinon.restore();
140
+ });
141
+
142
+ it('kills the tree of another process including its root', () => {
143
+ coreProcessManager['winGetChildPids'] = () => expect.fail('children should not be listed');
144
+ coreProcessManager['winTerminateProcessTree'](424243);
145
+ expect(taskkillStub.calledOnceWithExactly([424243])).to.be.true;
146
+ });
147
+
148
+ it('kills only the trees of the children of the current process', () => {
149
+ coreProcessManager['winGetChildPids'] = () => [424244, 424245];
150
+ coreProcessManager['winTerminateProcessTree'](process.pid);
151
+ expect(taskkillStub.calledOnceWithExactly([424244, 424245])).to.be.true;
152
+ });
153
+
154
+ it('does not run taskkill when the current process has no children', () => {
155
+ coreProcessManager['winGetChildPids'] = () => [];
156
+ coreProcessManager['winTerminateProcessTree'](process.pid);
157
+ expect(taskkillStub.called).to.be.false;
158
+ });
159
+
160
+ it('falls back to killing the whole tree when the children of the current process cannot be listed', () => {
161
+ coreProcessManager['winGetChildPids'] = () => { throw new Error('powershell.exe not found'); };
162
+ expect(() => coreProcessManager['winTerminateProcessTree'](process.pid)).to.not.throw();
163
+ expect(taskkillStub.calledOnceWithExactly([process.pid])).to.be.true;
164
+ expect(warnStub.called).to.be.true;
165
+ });
166
+ });
167
+
168
+ describe('#winTerminateChildProcessTrees', () => {
169
+ let taskkillStub: sinon.SinonStub;
170
+
171
+ beforeEach(() => {
172
+ taskkillStub = sinon.stub();
173
+ coreProcessManager['winTaskkillTrees'] = taskkillStub;
174
+ });
175
+
176
+ afterEach(() => {
177
+ sinon.restore();
178
+ });
179
+
180
+ it('kills the trees of the children of the process', async () => {
181
+ coreProcessManager['winGetChildPidsAsync'] = async () => [424244, 424245];
182
+ await coreProcessManager['winTerminateChildProcessTrees'](process.pid);
183
+ expect(taskkillStub.calledOnceWithExactly([424244, 424245])).to.be.true;
184
+ });
185
+
186
+ it('does not run taskkill when the process has no children', async () => {
187
+ coreProcessManager['winGetChildPidsAsync'] = async () => [];
188
+ await coreProcessManager['winTerminateChildProcessTrees'](process.pid);
189
+ expect(taskkillStub.called).to.be.false;
190
+ });
191
+
192
+ it('rejects when the children cannot be listed', async () => {
193
+ coreProcessManager['winGetChildPidsAsync'] = async () => { throw new Error('powershell.exe not found'); };
194
+ let error: unknown;
195
+ await coreProcessManager['winTerminateChildProcessTrees'](process.pid).catch(e => error = e);
196
+ expect(error).to.be.instanceOf(Error);
197
+ expect(taskkillStub.called).to.be.false;
198
+ });
199
+ });
200
+
201
+ describe('#winGetChildPids', () => {
202
+ let originalSystemRoot: string | undefined;
203
+ let spawnSyncStub: sinon.SinonStub;
204
+ let execFileStub: sinon.SinonStub;
205
+
206
+ beforeEach(() => {
207
+ originalSystemRoot = process.env.SystemRoot;
208
+ spawnSyncStub = sinon.stub().returns({ stdout: '1234\r\n5678\r\n\r\n' });
209
+ coreProcessManager['spawnSync'] = spawnSyncStub;
210
+ execFileStub = sinon.stub().resolves({ stdout: '1234\r\n5678\r\n\r\n', stderr: '' });
211
+ coreProcessManager['execFile'] = execFileStub;
212
+ });
213
+
214
+ afterEach(() => {
215
+ if (originalSystemRoot === undefined) {
216
+ delete process.env.SystemRoot;
217
+ } else {
218
+ process.env.SystemRoot = originalSystemRoot;
219
+ }
220
+ });
221
+
222
+ it('parses the PowerShell output', () => {
223
+ expect(coreProcessManager['winGetChildPids'](42)).to.deep.equal([1234, 5678]);
224
+ });
225
+
226
+ it('parses the PowerShell output asynchronously', async () => {
227
+ expect(await coreProcessManager['winGetChildPidsAsync'](42)).to.deep.equal([1234, 5678]);
228
+ expect(spawnSyncStub.called).to.be.false;
229
+ });
230
+
231
+ it('runs PowerShell from the Windows directory with a timeout', async () => {
232
+ process.env.SystemRoot = 'C:\\Windows';
233
+ coreProcessManager['winGetChildPids'](42);
234
+ await coreProcessManager['winGetChildPidsAsync'](42);
235
+ for (const stub of [spawnSyncStub, execFileStub]) {
236
+ const [file, , options] = stub.firstCall.args;
237
+ expect(file).to.equal('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe');
238
+ expect(options.timeout).to.be.greaterThan(0);
239
+ }
240
+ });
241
+
242
+ it('excludes the PowerShell process itself, the console host and the children of a previous process with the same PID', async () => {
243
+ coreProcessManager['winGetChildPids'](42);
244
+ await coreProcessManager['winGetChildPidsAsync'](42);
245
+ for (const stub of [spawnSyncStub, execFileStub]) {
246
+ const command: string = stub.firstCall.args[1].at(-1);
247
+ expect(command).to.contain("Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId=42'");
248
+ expect(command).to.contain('ParentProcessId=42');
249
+ expect(command).to.contain('$_.ProcessId -ne $PID');
250
+ expect(command).to.contain("$_.Name -ne 'conhost.exe'");
251
+ expect(command).to.contain('$_.CreationDate -ge $parent.CreationDate');
252
+ }
253
+ });
254
+
255
+ it('runs PowerShell from the PATH when the Windows directory is unknown', () => {
256
+ delete process.env.SystemRoot;
257
+ coreProcessManager['winGetChildPids'](42);
258
+ expect(spawnSyncStub.firstCall.args[0]).to.equal('powershell.exe');
259
+ });
260
+ });
99
261
  });
@@ -15,9 +15,20 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as cp from 'child_process';
18
+ import * as path from 'path';
18
19
  import { injectable, inject, named } from 'inversify';
19
20
  import { ILogger } from '../common/logger';
20
21
 
22
+ /**
23
+ * How long to wait for PowerShell to list child processes before giving up, in milliseconds.
24
+ */
25
+ const WIN_LIST_CHILDREN_TIMEOUT_MS = 5000;
26
+
27
+ /**
28
+ * Options for running PowerShell to list child processes.
29
+ */
30
+ const WIN_LIST_CHILDREN_OPTIONS = { windowsHide: true, timeout: WIN_LIST_CHILDREN_TIMEOUT_MS };
31
+
21
32
  /**
22
33
  * `@theia/core` service with some process-related utilities.
23
34
  */
@@ -27,6 +38,13 @@ export class ProcessUtils {
27
38
  @inject(ILogger) @named('core:ProcessUtils')
28
39
  protected readonly logger: ILogger;
29
40
 
41
+ /**
42
+ * Kills the given process together with all of its descendants.
43
+ *
44
+ * This blocks the event loop, so that it can run in an `exit` handler, where the loop is no longer
45
+ * available. Prefer {@link terminateChildProcessTrees} while the event loop is running, as listing
46
+ * the descendants of a process can be slow, in particular on Windows.
47
+ */
30
48
  terminateProcessTree(ppid: number): void {
31
49
  if (process.platform === 'win32') {
32
50
  this.winTerminateProcessTree(ppid);
@@ -35,18 +53,128 @@ export class ProcessUtils {
35
53
  }
36
54
  }
37
55
 
56
+ /**
57
+ * Kills all of the descendants of the given process, but not the process itself, without blocking
58
+ * the event loop.
59
+ *
60
+ * @throws if the descendants of the process cannot be listed
61
+ */
62
+ async terminateChildProcessTrees(ppid: number): Promise<void> {
63
+ if (process.platform === 'win32') {
64
+ await this.winTerminateChildProcessTrees(ppid);
65
+ } else {
66
+ await this.unixTerminateChildProcessTrees(ppid);
67
+ }
68
+ }
69
+
38
70
  protected winTerminateProcessTree(ppid: number): void {
39
- const result = cp.spawnSync('taskkill.exe', ['/f', '/t', '/pid', ppid.toString(10)], { encoding: 'utf8' });
71
+ if (ppid !== process.pid) {
72
+ this.winTaskkillTrees([ppid]);
73
+ return;
74
+ }
75
+ // `taskkill /t` always kills the root of the tree as well. Killing the current process
76
+ // with `/f` terminates it with exit code 1, overriding the exit code that it may be
77
+ // exiting with, so only kill the trees of its children, as on Unix.
78
+ let childPids: number[];
79
+ try {
80
+ childPids = this.winGetChildPids(ppid);
81
+ } catch (error) {
82
+ // Without the list of children, killing the whole tree is the only way to avoid leaking
83
+ // child processes, at the cost of the current process exiting with code 1.
84
+ this.logger.warn(`Failed to list the child processes of PID ${ppid}, killing its whole tree`, error);
85
+ this.winTaskkillTrees([ppid]);
86
+ return;
87
+ }
88
+ if (childPids.length > 0) {
89
+ this.winTaskkillTrees(childPids);
90
+ }
91
+ }
92
+
93
+ protected async winTerminateChildProcessTrees(ppid: number): Promise<void> {
94
+ const childPids = await this.winGetChildPidsAsync(ppid);
95
+ if (childPids.length > 0) {
96
+ // `taskkill` is quick, unlike PowerShell, so running it synchronously is fine here too.
97
+ this.winTaskkillTrees(childPids);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Forcefully kills the given processes together with all of their descendants.
103
+ */
104
+ protected winTaskkillTrees(pids: number[]): void {
105
+ const pidArgs = pids.flatMap(pid => ['/pid', pid.toString(10)]);
106
+ // Not `this.spawnSync`, which throws on a non-zero exit code that is expected here.
107
+ const result = cp.spawnSync('taskkill.exe', ['/f', '/t', ...pidArgs], { encoding: 'utf8' });
40
108
  if (result.error) {
41
109
  throw result.error;
42
110
  }
43
111
  // taskkill may exit with a non-zero code when some child processes have already exited.
44
112
  // This is expected during shutdown — log but don't throw.
45
113
  if (result.status !== 0) {
46
- this.logger.warn(`taskkill.exe exited with ${result.status} for PID ${ppid}. Output:\n${JSON.stringify(result.output)}`);
114
+ this.logger.warn(`taskkill.exe exited with ${result.status} for PIDs ${pids.join(', ')}. Output:\n${JSON.stringify(result.output)}`);
47
115
  }
48
116
  }
49
117
 
118
+ /**
119
+ * @returns the PIDs of the direct children of the given process, see {@link winGetChildPidsArgs}
120
+ */
121
+ protected winGetChildPids(ppid: number): number[] {
122
+ const { stdout } = this.spawnSync(this.winGetPowerShellPath(), this.winGetChildPidsArgs(ppid), WIN_LIST_CHILDREN_OPTIONS);
123
+ return this.winParsePids(stdout);
124
+ }
125
+
126
+ /**
127
+ * @returns the PIDs of the direct children of the given process, see {@link winGetChildPidsArgs}
128
+ */
129
+ protected async winGetChildPidsAsync(ppid: number): Promise<number[]> {
130
+ const { stdout } = await this.execFile(this.winGetPowerShellPath(), this.winGetChildPidsArgs(ppid), WIN_LIST_CHILDREN_OPTIONS);
131
+ return this.winParsePids(stdout);
132
+ }
133
+
134
+ /**
135
+ * @returns the arguments of a PowerShell command that prints the PIDs of the direct children of the
136
+ * given process, one per line, except for:
137
+ * - the PowerShell process that lists them, which is a child of the current process and exits right after
138
+ * - the console host (`conhost.exe`) that Windows attaches to a process launched without a console,
139
+ * which `taskkill` may fail to kill
140
+ * - processes created before the given process: Windows does not update the parent of a process
141
+ * when the parent exits and reuses PIDs, so these are the orphans of a previous process with the same PID
142
+ */
143
+ protected winGetChildPidsArgs(ppid: number): string[] {
144
+ const pid = ppid.toString(10);
145
+ return [
146
+ '-NoLogo', '-NoProfile', '-NonInteractive', '-Command',
147
+ `$parent = Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId=${pid}';`
148
+ + ` Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=${pid}'`
149
+ + " | Where-Object { $_.ProcessId -ne $PID -and $_.Name -ne 'conhost.exe' -and $_.CreationDate -ge $parent.CreationDate }"
150
+ + ' | ForEach-Object { $_.ProcessId }'
151
+ ];
152
+ }
153
+
154
+ /**
155
+ * @param output the output of the command of {@link winGetChildPidsArgs}
156
+ */
157
+ protected winParsePids(output: string): number[] {
158
+ return output
159
+ .split(/\s+/)
160
+ .filter(token => /^\d+$/.test(token))
161
+ .map(token => Number.parseInt(token, 10));
162
+ }
163
+
164
+ /**
165
+ * @returns the absolute path of Windows PowerShell, so that it does not depend on the `PATH`,
166
+ * or just its name if the Windows directory is unknown.
167
+ */
168
+ protected winGetPowerShellPath(): string {
169
+ const systemRoot = process.env.SystemRoot;
170
+ if (!systemRoot) {
171
+ return 'powershell.exe';
172
+ }
173
+ // `v1.0` is not the version: all versions of Windows PowerShell, up to the final 5.1, are installed
174
+ // in this directory. PowerShell 7 and later are a separate, optional installation (`pwsh.exe`).
175
+ return path.win32.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
176
+ }
177
+
50
178
  protected unixTerminateProcessTree(ppid: number): void {
51
179
  for (const pid of this.unixGetChildrenRecursive(ppid)) {
52
180
  // Prevent killing the current process:
@@ -63,6 +191,16 @@ export class ProcessUtils {
63
191
  this.unixKill(ppid);
64
192
  }
65
193
 
194
+ protected async unixTerminateChildProcessTrees(ppid: number): Promise<void> {
195
+ const { stdout } = await this.execFile('ps', ['ax', '-o', 'ppid=,pid=']);
196
+ for (const pid of this.unixParseChildrenRecursive(stdout, ppid)) {
197
+ // Prevent killing the current process:
198
+ if (pid !== process.pid) {
199
+ this.unixKill(pid);
200
+ }
201
+ }
202
+ }
203
+
66
204
  protected unixKill(pid: number): void {
67
205
  try {
68
206
  process.kill(pid);
@@ -82,9 +220,17 @@ export class ProcessUtils {
82
220
 
83
221
  protected unixGetChildrenRecursive(ppid: number): Set<number> {
84
222
  const { stdout } = this.spawnSync('ps', ['ax', '-o', 'ppid=,pid=']);
223
+ return this.unixParseChildrenRecursive(stdout, ppid);
224
+ }
225
+
226
+ /**
227
+ * @param psOutput the output of `ps ax -o ppid=,pid=`
228
+ * @returns the PIDs of all of the descendants of the given process
229
+ */
230
+ protected unixParseChildrenRecursive(psOutput: string, ppid: number): Set<number> {
85
231
  const pids = new Set<number>([ppid]);
86
232
  const matcher = /(\d+)\s+(\d+)/;
87
- const psList = stdout
233
+ const psList = psOutput
88
234
  .trim()
89
235
  .split('\n')
90
236
  .map(line => {
@@ -108,6 +254,23 @@ export class ProcessUtils {
108
254
  return pids;
109
255
  }
110
256
 
257
+ /**
258
+ * Runs the given executable without blocking the event loop.
259
+ *
260
+ * @throws if the executable cannot be run or exits with a non-zero code, or on timeout
261
+ */
262
+ protected execFile(file: string, argv: string[], options?: cp.ExecFileOptions): Promise<{ stdout: string, stderr: string }> {
263
+ return new Promise((resolve, reject) => {
264
+ cp.execFile(file, argv, { ...options, encoding: 'utf8' }, (error, stdout, stderr) => {
265
+ if (error) {
266
+ reject(error);
267
+ } else {
268
+ resolve({ stdout, stderr });
269
+ }
270
+ });
271
+ });
272
+ }
273
+
111
274
  protected spawnSync(file: string, argv: string[], options?: cp.SpawnSyncOptions): cp.SpawnSyncReturns<string> {
112
275
  const result = cp.spawnSync(file, argv, { ...options, encoding: 'utf8' });
113
276
  if (result.error) {
@@ -0,0 +1,75 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 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
+ /**
18
+ * Script for tests: creates a `BackendApplication`, which installs its process handlers, starts a
19
+ * child process, prints the PID of the child and exits with code {@link EXITING_BACKEND_EXIT_CODE}.
20
+ * The `exit` handler of the `BackendApplication` then terminates the process tree.
21
+ * Set {@link EXITING_BACKEND_NO_POWERSHELL} to make the listing of the children of the process fail.
22
+ * Set {@link EXITING_BACKEND_GRACEFUL} to shut down as on `SIGTERM` instead, which exits with code 1.
23
+ */
24
+
25
+ import 'reflect-metadata';
26
+ import * as cp from 'child_process';
27
+ import { Container } from 'inversify';
28
+ import { bindContributionProvider, ILogger, Stopwatch } from '../../common';
29
+ import { MockLogger } from '../../common/test/mock-logger';
30
+ import {
31
+ BackendApplication, BackendApplicationCliContribution, BackendApplicationContribution, EarlyExpressMiddleware, RootContainer
32
+ } from '../backend-application';
33
+ import { NodeStopwatch } from '../performance/node-stopwatch';
34
+ import { ProcessUtils } from '../process-utils';
35
+
36
+ export const EXITING_BACKEND_EXIT_CODE = 3;
37
+
38
+ /**
39
+ * Environment variable that makes PowerShell unrunnable for the {@link ProcessUtils} of the script.
40
+ */
41
+ export const EXITING_BACKEND_NO_POWERSHELL = 'THEIA_TEST_EXITING_BACKEND_NO_POWERSHELL';
42
+
43
+ /**
44
+ * Environment variable that makes the script shut down gracefully, as on `SIGTERM`, rather than exit abruptly.
45
+ */
46
+ export const EXITING_BACKEND_GRACEFUL = 'THEIA_TEST_EXITING_BACKEND_GRACEFUL';
47
+
48
+ class NoPowerShellProcessUtils extends ProcessUtils {
49
+ protected override winGetPowerShellPath(): string {
50
+ return 'C:\\does-not-exist\\powershell.exe';
51
+ }
52
+ }
53
+
54
+ if (require.main === module) {
55
+ const container = new Container();
56
+ container.bind(RootContainer).toConstantValue(container);
57
+ container.bind(ILogger).to(MockLogger).inSingletonScope();
58
+ container.bind(Stopwatch).to(NodeStopwatch).inSingletonScope();
59
+ container.bind(ProcessUtils).to(process.env[EXITING_BACKEND_NO_POWERSHELL] ? NoPowerShellProcessUtils : ProcessUtils).inSingletonScope();
60
+ container.bind(BackendApplicationCliContribution).toSelf().inSingletonScope();
61
+ container.bind(EarlyExpressMiddleware).toSelf().inSingletonScope();
62
+ bindContributionProvider(container, BackendApplicationContribution);
63
+ container.bind(BackendApplication).toSelf().inSingletonScope();
64
+ container.get(BackendApplication);
65
+
66
+ const child = cp.spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { stdio: 'ignore' });
67
+ child.on('spawn', () => process.stdout.write(`${child.pid}\n`, () => {
68
+ if (process.env[EXITING_BACKEND_GRACEFUL]) {
69
+ // Signals cannot be sent to a process on Windows, so invoke the handler of the `BackendApplication` directly.
70
+ process.emit('SIGTERM', 'SIGTERM');
71
+ } else {
72
+ process.exit(EXITING_BACKEND_EXIT_CODE);
73
+ }
74
+ }));
75
+ }