@theia/core 1.45.0 → 1.46.0-next.72

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 (1591) hide show
  1. package/README.md +6 -6
  2. package/i18n/nls.cs.json +524 -520
  3. package/i18n/nls.de.json +524 -520
  4. package/i18n/nls.es.json +524 -520
  5. package/i18n/nls.fr.json +524 -520
  6. package/i18n/nls.hu.json +524 -520
  7. package/i18n/nls.it.json +524 -520
  8. package/i18n/nls.ja.json +524 -520
  9. package/i18n/nls.json +524 -520
  10. package/i18n/nls.pl.json +524 -520
  11. package/i18n/nls.pt-br.json +524 -520
  12. package/i18n/nls.pt-pt.json +524 -520
  13. package/i18n/nls.ru.json +524 -520
  14. package/i18n/nls.zh-cn.json +524 -520
  15. package/lib/browser/about-dialog.d.ts +33 -33
  16. package/lib/browser/about-dialog.js +136 -136
  17. package/lib/browser/authentication-service.d.ts +144 -144
  18. package/lib/browser/authentication-service.js +332 -332
  19. package/lib/browser/breadcrumbs/breadcrumb-popup-container.d.ts +34 -34
  20. package/lib/browser/breadcrumbs/breadcrumb-popup-container.js +114 -114
  21. package/lib/browser/breadcrumbs/breadcrumb-renderer.d.ts +12 -12
  22. package/lib/browser/breadcrumbs/breadcrumb-renderer.js +42 -42
  23. package/lib/browser/breadcrumbs/breadcrumbs-constants.d.ts +49 -49
  24. package/lib/browser/breadcrumbs/breadcrumbs-constants.js +27 -27
  25. package/lib/browser/breadcrumbs/breadcrumbs-renderer.d.ts +43 -43
  26. package/lib/browser/breadcrumbs/breadcrumbs-renderer.js +187 -187
  27. package/lib/browser/breadcrumbs/breadcrumbs-service.d.ts +32 -32
  28. package/lib/browser/breadcrumbs/breadcrumbs-service.js +119 -119
  29. package/lib/browser/breadcrumbs/index.d.ts +5 -5
  30. package/lib/browser/breadcrumbs/index.js +32 -32
  31. package/lib/browser/browser-clipboard-service.d.ts +23 -23
  32. package/lib/browser/browser-clipboard-service.js +115 -115
  33. package/lib/browser/browser.d.ts +37 -34
  34. package/lib/browser/browser.d.ts.map +1 -1
  35. package/lib/browser/browser.js +196 -192
  36. package/lib/browser/browser.js.map +1 -1
  37. package/lib/browser/clipboard-service.d.ts +6 -6
  38. package/lib/browser/clipboard-service.js +19 -19
  39. package/lib/browser/color-application-contribution.d.ts +24 -24
  40. package/lib/browser/color-application-contribution.js +108 -108
  41. package/lib/browser/color-registry.d.ts +14 -14
  42. package/lib/browser/color-registry.js +63 -63
  43. package/lib/browser/command-open-handler.d.ts +9 -9
  44. package/lib/browser/command-open-handler.js +66 -66
  45. package/lib/browser/common-frontend-contribution.d.ts +206 -206
  46. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  47. package/lib/browser/common-frontend-contribution.js +2307 -2307
  48. package/lib/browser/common-frontend-contribution.js.map +1 -1
  49. package/lib/browser/common-styling-participants.d.ts +27 -27
  50. package/lib/browser/common-styling-participants.js +370 -370
  51. package/lib/browser/connection-status-service.d.ts +77 -77
  52. package/lib/browser/connection-status-service.js +209 -209
  53. package/lib/browser/connection-status-service.spec.d.ts +1 -1
  54. package/lib/browser/connection-status-service.spec.js +161 -161
  55. package/lib/browser/context-key-service.d.ts +82 -83
  56. package/lib/browser/context-key-service.d.ts.map +1 -1
  57. package/lib/browser/context-key-service.js +88 -88
  58. package/lib/browser/context-key-service.js.map +1 -1
  59. package/lib/browser/context-menu-renderer.d.ts +54 -55
  60. package/lib/browser/context-menu-renderer.d.ts.map +1 -1
  61. package/lib/browser/context-menu-renderer.js +92 -96
  62. package/lib/browser/context-menu-renderer.js.map +1 -1
  63. package/lib/browser/core-preferences.d.ts +37 -36
  64. package/lib/browser/core-preferences.d.ts.map +1 -1
  65. package/lib/browser/core-preferences.js +300 -295
  66. package/lib/browser/core-preferences.js.map +1 -1
  67. package/lib/browser/credentials-service.d.ts +35 -35
  68. package/lib/browser/credentials-service.js +91 -91
  69. package/lib/browser/decoration-style.d.ts +6 -6
  70. package/lib/browser/decoration-style.js +64 -64
  71. package/lib/browser/decorations-service.d.ts +30 -30
  72. package/lib/browser/decorations-service.js +163 -163
  73. package/lib/browser/dialogs/react-dialog.d.ts +17 -17
  74. package/lib/browser/dialogs/react-dialog.js +60 -60
  75. package/lib/browser/dialogs.d.ts +135 -135
  76. package/lib/browser/dialogs.js +457 -457
  77. package/lib/browser/diff-uris.d.ts +17 -17
  78. package/lib/browser/diff-uris.js +126 -126
  79. package/lib/browser/encoding-registry.d.ts +18 -18
  80. package/lib/browser/encoding-registry.js +96 -96
  81. package/lib/browser/endpoint.d.ts +42 -42
  82. package/lib/browser/endpoint.js +120 -120
  83. package/lib/browser/endpoint.spec.d.ts +1 -1
  84. package/lib/browser/endpoint.spec.js +122 -122
  85. package/lib/browser/external-uri-service.d.ts +24 -24
  86. package/lib/browser/external-uri-service.js +77 -77
  87. package/lib/browser/frontend-application-bindings.d.ts +5 -5
  88. package/lib/browser/frontend-application-bindings.js +56 -56
  89. package/lib/browser/frontend-application-config-provider.d.ts +8 -8
  90. package/lib/browser/frontend-application-config-provider.js +46 -46
  91. package/lib/browser/frontend-application-config-provider.spec.d.ts +1 -1
  92. package/lib/browser/frontend-application-config-provider.spec.js +40 -40
  93. package/lib/browser/frontend-application-contribution.d.ts +75 -75
  94. package/lib/browser/frontend-application-contribution.js +50 -50
  95. package/lib/browser/frontend-application-module.d.ts +8 -8
  96. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  97. package/lib/browser/frontend-application-module.js +354 -353
  98. package/lib/browser/frontend-application-module.js.map +1 -1
  99. package/lib/browser/frontend-application-state.d.ts +19 -19
  100. package/lib/browser/frontend-application-state.js +79 -79
  101. package/lib/browser/frontend-application.d.ts +86 -86
  102. package/lib/browser/frontend-application.js +319 -319
  103. package/lib/browser/hover-service.d.ts +50 -50
  104. package/lib/browser/hover-service.js +207 -207
  105. package/lib/browser/http-open-handler.d.ts +14 -14
  106. package/lib/browser/http-open-handler.js +54 -54
  107. package/lib/browser/i18n/i18n-frontend-module.d.ts +3 -3
  108. package/lib/browser/i18n/i18n-frontend-module.js +25 -25
  109. package/lib/browser/i18n/language-quick-pick-service.d.ts +15 -15
  110. package/lib/browser/i18n/language-quick-pick-service.js +144 -144
  111. package/lib/browser/icon-registry.d.ts +56 -62
  112. package/lib/browser/icon-registry.d.ts.map +1 -1
  113. package/lib/browser/icon-registry.js +24 -24
  114. package/lib/browser/icon-registry.js.map +1 -1
  115. package/lib/browser/icon-theme-contribution.d.ts +23 -23
  116. package/lib/browser/icon-theme-contribution.js +72 -72
  117. package/lib/browser/icon-theme-service.d.ts +63 -63
  118. package/lib/browser/icon-theme-service.js +206 -206
  119. package/lib/browser/index.d.ts +31 -31
  120. package/lib/browser/index.js +58 -58
  121. package/lib/browser/json-schema-store.d.ts +37 -37
  122. package/lib/browser/json-schema-store.js +119 -119
  123. package/lib/browser/keybinding.d.ts +288 -288
  124. package/lib/browser/keybinding.js +682 -682
  125. package/lib/browser/keybinding.spec.d.ts +1 -1
  126. package/lib/browser/keybinding.spec.js +456 -456
  127. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.d.ts +13 -13
  128. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js +118 -118
  129. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts +91 -91
  130. package/lib/browser/keyboard/browser-keyboard-layout-provider.js +426 -426
  131. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.d.ts +1 -1
  132. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js +157 -157
  133. package/lib/browser/keyboard/browser-keyboard-module.d.ts +3 -3
  134. package/lib/browser/keyboard/browser-keyboard-module.js +30 -30
  135. package/lib/browser/keyboard/index.d.ts +4 -4
  136. package/lib/browser/keyboard/index.js +31 -31
  137. package/lib/browser/keyboard/keyboard-layout-service.d.ts +49 -49
  138. package/lib/browser/keyboard/keyboard-layout-service.js +435 -435
  139. package/lib/browser/keyboard/keyboard-layout-service.spec.d.ts +1 -1
  140. package/lib/browser/keyboard/keyboard-layout-service.spec.js +115 -115
  141. package/lib/browser/keyboard/keys.d.ts +4 -4
  142. package/lib/browser/keyboard/keys.js +31 -31
  143. package/lib/browser/keyboard/keys.spec.d.ts +1 -1
  144. package/lib/browser/keyboard/keys.spec.js +205 -205
  145. package/lib/browser/keys.d.ts +2 -2
  146. package/lib/browser/keys.js +28 -28
  147. package/lib/browser/label-parser.d.ts +34 -34
  148. package/lib/browser/label-parser.js +112 -112
  149. package/lib/browser/label-parser.spec.d.ts +1 -1
  150. package/lib/browser/label-parser.spec.js +146 -146
  151. package/lib/browser/label-provider.d.ts +140 -140
  152. package/lib/browser/label-provider.js +318 -318
  153. package/lib/browser/label-provider.spec.d.ts +1 -1
  154. package/lib/browser/label-provider.spec.js +53 -53
  155. package/lib/browser/language-icon-provider.d.ts +14 -14
  156. package/lib/browser/language-icon-provider.js +73 -73
  157. package/lib/browser/language-service.d.ts +38 -38
  158. package/lib/browser/language-service.js +71 -71
  159. package/lib/browser/logger-frontend-module.d.ts +2 -2
  160. package/lib/browser/logger-frontend-module.js +63 -63
  161. package/lib/browser/markdown-rendering/markdown-renderer.d.ts +39 -39
  162. package/lib/browser/markdown-rendering/markdown-renderer.d.ts.map +1 -1
  163. package/lib/browser/markdown-rendering/markdown-renderer.js +80 -80
  164. package/lib/browser/menu/browser-context-menu-renderer.d.ts +12 -12
  165. package/lib/browser/menu/browser-context-menu-renderer.js +61 -61
  166. package/lib/browser/menu/browser-menu-module.d.ts +3 -3
  167. package/lib/browser/menu/browser-menu-module.js +28 -28
  168. package/lib/browser/menu/browser-menu-plugin.d.ts +103 -103
  169. package/lib/browser/menu/browser-menu-plugin.js +450 -450
  170. package/lib/browser/menu/context-menu-context.d.ts +7 -7
  171. package/lib/browser/menu/context-menu-context.js +50 -50
  172. package/lib/browser/messaging/connection-source.d.ts +8 -8
  173. package/lib/browser/messaging/connection-source.js +19 -19
  174. package/lib/browser/messaging/frontend-id-provider.d.ts +12 -12
  175. package/lib/browser/messaging/frontend-id-provider.js +39 -39
  176. package/lib/browser/messaging/index.d.ts +1 -1
  177. package/lib/browser/messaging/index.js +28 -28
  178. package/lib/browser/messaging/messaging-frontend-module.d.ts +2 -2
  179. package/lib/browser/messaging/messaging-frontend-module.js +41 -41
  180. package/lib/browser/messaging/service-connection-provider.d.ts +47 -47
  181. package/lib/browser/messaging/service-connection-provider.js +114 -114
  182. package/lib/browser/messaging/ws-connection-provider.d.ts +12 -12
  183. package/lib/browser/messaging/ws-connection-provider.js +57 -57
  184. package/lib/browser/messaging/ws-connection-source.d.ts +42 -40
  185. package/lib/browser/messaging/ws-connection-source.d.ts.map +1 -1
  186. package/lib/browser/messaging/ws-connection-source.js +225 -209
  187. package/lib/browser/messaging/ws-connection-source.js.map +1 -1
  188. package/lib/browser/mime-service.d.ts +7 -7
  189. package/lib/browser/mime-service.js +35 -35
  190. package/lib/browser/navigatable-types.d.ts +33 -33
  191. package/lib/browser/navigatable-types.js +63 -63
  192. package/lib/browser/navigatable.d.ts +8 -8
  193. package/lib/browser/navigatable.js +47 -47
  194. package/lib/browser/opener-service.d.ts +79 -79
  195. package/lib/browser/opener-service.js +90 -90
  196. package/lib/browser/opener-service.spec.d.ts +1 -1
  197. package/lib/browser/opener-service.spec.js +46 -46
  198. package/lib/browser/performance/frontend-stopwatch.d.ts +20 -20
  199. package/lib/browser/performance/frontend-stopwatch.js +74 -74
  200. package/lib/browser/performance/index.d.ts +2 -2
  201. package/lib/browser/performance/index.js +29 -29
  202. package/lib/browser/performance/measurement-frontend-bindings.d.ts +19 -19
  203. package/lib/browser/performance/measurement-frontend-bindings.js +32 -32
  204. package/lib/browser/preferences/index.d.ts +7 -7
  205. package/lib/browser/preferences/index.js +34 -34
  206. package/lib/browser/preferences/injectable-preference-proxy.d.ts +51 -51
  207. package/lib/browser/preferences/injectable-preference-proxy.js +284 -284
  208. package/lib/browser/preferences/preference-configurations.d.ts +22 -22
  209. package/lib/browser/preferences/preference-configurations.js +80 -80
  210. package/lib/browser/preferences/preference-contribution.d.ts +111 -111
  211. package/lib/browser/preferences/preference-contribution.js +394 -394
  212. package/lib/browser/preferences/preference-language-override-service.d.ts +39 -39
  213. package/lib/browser/preferences/preference-language-override-service.js +112 -112
  214. package/lib/browser/preferences/preference-provider.d.ts +132 -132
  215. package/lib/browser/preferences/preference-provider.js +227 -227
  216. package/lib/browser/preferences/preference-provider.spec.d.ts +1 -1
  217. package/lib/browser/preferences/preference-provider.spec.js +33 -33
  218. package/lib/browser/preferences/preference-proxy.d.ts +150 -150
  219. package/lib/browser/preferences/preference-proxy.js +229 -229
  220. package/lib/browser/preferences/preference-proxy.spec.d.ts +1 -1
  221. package/lib/browser/preferences/preference-proxy.spec.js +337 -337
  222. package/lib/browser/preferences/preference-schema-provider.spec.d.ts +1 -1
  223. package/lib/browser/preferences/preference-schema-provider.spec.js +115 -115
  224. package/lib/browser/preferences/preference-scope.d.ts +2 -2
  225. package/lib/browser/preferences/preference-scope.js +20 -20
  226. package/lib/browser/preferences/preference-service.d.ts +278 -278
  227. package/lib/browser/preferences/preference-service.js +358 -358
  228. package/lib/browser/preferences/preference-service.spec.d.ts +1 -1
  229. package/lib/browser/preferences/preference-service.spec.js +505 -505
  230. package/lib/browser/preferences/preference-validation-service.d.ts +57 -57
  231. package/lib/browser/preferences/preference-validation-service.js +354 -354
  232. package/lib/browser/preferences/preference-validation-service.spec.d.ts +1 -1
  233. package/lib/browser/preferences/preference-validation-service.spec.js +330 -330
  234. package/lib/browser/preferences/test/index.d.ts +3 -3
  235. package/lib/browser/preferences/test/index.js +30 -30
  236. package/lib/browser/preferences/test/mock-preference-provider.d.ts +16 -16
  237. package/lib/browser/preferences/test/mock-preference-provider.js +46 -46
  238. package/lib/browser/preferences/test/mock-preference-proxy.d.ts +3 -3
  239. package/lib/browser/preferences/test/mock-preference-proxy.js +49 -49
  240. package/lib/browser/preferences/test/mock-preference-service.d.ts +28 -28
  241. package/lib/browser/preferences/test/mock-preference-service.js +67 -67
  242. package/lib/browser/preload/i18n-preload-contribution.d.ts +6 -6
  243. package/lib/browser/preload/i18n-preload-contribution.js +62 -62
  244. package/lib/browser/preload/os-preload-contribution.d.ts +6 -6
  245. package/lib/browser/preload/os-preload-contribution.js +48 -48
  246. package/lib/browser/preload/preload-module.d.ts +3 -3
  247. package/lib/browser/preload/preload-module.js +38 -38
  248. package/lib/browser/preload/preloader.d.ts +11 -11
  249. package/lib/browser/preload/preloader.js +44 -44
  250. package/lib/browser/preload/theme-preload-contribution.d.ts +4 -4
  251. package/lib/browser/preload/theme-preload-contribution.js +39 -39
  252. package/lib/browser/progress-bar-factory.d.ts +11 -11
  253. package/lib/browser/progress-bar-factory.js +20 -20
  254. package/lib/browser/progress-bar.d.ts +15 -15
  255. package/lib/browser/progress-bar.js +89 -89
  256. package/lib/browser/progress-client.d.ts +12 -12
  257. package/lib/browser/progress-client.js +61 -61
  258. package/lib/browser/progress-location-service.d.ts +21 -21
  259. package/lib/browser/progress-location-service.js +96 -96
  260. package/lib/browser/progress-location-service.spec.d.ts +1 -1
  261. package/lib/browser/progress-location-service.spec.js +44 -44
  262. package/lib/browser/progress-status-bar-item.d.ts +16 -16
  263. package/lib/browser/progress-status-bar-item.js +89 -89
  264. package/lib/browser/quick-input/index.d.ts +8 -8
  265. package/lib/browser/quick-input/index.js +35 -35
  266. package/lib/browser/quick-input/quick-access.d.ts +53 -53
  267. package/lib/browser/quick-input/quick-access.js +20 -20
  268. package/lib/browser/quick-input/quick-command-frontend-contribution.d.ts +11 -11
  269. package/lib/browser/quick-input/quick-command-frontend-contribution.js +104 -104
  270. package/lib/browser/quick-input/quick-command-service.d.ts +59 -59
  271. package/lib/browser/quick-input/quick-command-service.js +233 -233
  272. package/lib/browser/quick-input/quick-help-service.d.ts +11 -11
  273. package/lib/browser/quick-input/quick-help-service.js +91 -91
  274. package/lib/browser/quick-input/quick-input-frontend-contribution.d.ts +7 -7
  275. package/lib/browser/quick-input/quick-input-frontend-contribution.js +46 -46
  276. package/lib/browser/quick-input/quick-input-service.d.ts +1 -1
  277. package/lib/browser/quick-input/quick-input-service.js +28 -28
  278. package/lib/browser/quick-input/quick-input-service.spec.d.ts +1 -1
  279. package/lib/browser/quick-input/quick-input-service.spec.js +159 -159
  280. package/lib/browser/quick-input/quick-pick-service-impl.d.ts +30 -30
  281. package/lib/browser/quick-input/quick-pick-service-impl.js +77 -77
  282. package/lib/browser/quick-input/quick-view-service.d.ts +23 -23
  283. package/lib/browser/quick-input/quick-view-service.js +86 -86
  284. package/lib/browser/request/browser-request-module.d.ts +18 -18
  285. package/lib/browser/request/browser-request-module.js +23 -23
  286. package/lib/browser/request/browser-request-service.d.ts +41 -41
  287. package/lib/browser/request/browser-request-service.js +180 -180
  288. package/lib/browser/resource-context-key.d.ts +19 -19
  289. package/lib/browser/resource-context-key.js +83 -83
  290. package/lib/browser/save-resource-service.d.ts +35 -35
  291. package/lib/browser/save-resource-service.d.ts.map +1 -1
  292. package/lib/browser/save-resource-service.js +72 -71
  293. package/lib/browser/save-resource-service.js.map +1 -1
  294. package/lib/browser/saveable.d.ts +124 -124
  295. package/lib/browser/saveable.js +274 -274
  296. package/lib/browser/secondary-window-handler.d.ts +64 -64
  297. package/lib/browser/secondary-window-handler.js +208 -208
  298. package/lib/browser/shell/additional-views-menu-widget.d.ts +19 -19
  299. package/lib/browser/shell/additional-views-menu-widget.js +81 -81
  300. package/lib/browser/shell/application-shell-mouse-tracker.d.ts +30 -30
  301. package/lib/browser/shell/application-shell-mouse-tracker.js +107 -107
  302. package/lib/browser/shell/application-shell.d.ts +572 -572
  303. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  304. package/lib/browser/shell/application-shell.js +1995 -1990
  305. package/lib/browser/shell/application-shell.js.map +1 -1
  306. package/lib/browser/shell/current-widget-command-adapter.d.ts +23 -23
  307. package/lib/browser/shell/current-widget-command-adapter.js +41 -41
  308. package/lib/browser/shell/index.d.ts +7 -7
  309. package/lib/browser/shell/index.js +34 -34
  310. package/lib/browser/shell/shell-layout-restorer.d.ts +123 -123
  311. package/lib/browser/shell/shell-layout-restorer.js +347 -347
  312. package/lib/browser/shell/side-panel-handler.d.ts +286 -286
  313. package/lib/browser/shell/side-panel-handler.js +667 -667
  314. package/lib/browser/shell/side-panel-toolbar.d.ts +25 -25
  315. package/lib/browser/shell/side-panel-toolbar.js +96 -96
  316. package/lib/browser/shell/sidebar-bottom-menu-widget.d.ts +9 -9
  317. package/lib/browser/shell/sidebar-bottom-menu-widget.js +46 -46
  318. package/lib/browser/shell/sidebar-menu-widget.d.ts +38 -38
  319. package/lib/browser/shell/sidebar-menu-widget.js +121 -121
  320. package/lib/browser/shell/sidebar-top-menu-widget.d.ts +6 -6
  321. package/lib/browser/shell/sidebar-top-menu-widget.js +35 -35
  322. package/lib/browser/shell/split-panels.d.ts +42 -42
  323. package/lib/browser/shell/split-panels.js +177 -177
  324. package/lib/browser/shell/tab-bar-decorator.d.ts +40 -35
  325. package/lib/browser/shell/tab-bar-decorator.d.ts.map +1 -1
  326. package/lib/browser/shell/tab-bar-decorator.js +95 -64
  327. package/lib/browser/shell/tab-bar-decorator.js.map +1 -1
  328. package/lib/browser/shell/tab-bar-toolbar/index.d.ts +3 -3
  329. package/lib/browser/shell/tab-bar-toolbar/index.js +30 -30
  330. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.d.ts +15 -15
  331. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.js +35 -35
  332. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts +95 -95
  333. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js +253 -253
  334. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts +136 -136
  335. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js +88 -88
  336. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +88 -88
  337. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +417 -417
  338. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.d.ts +1 -1
  339. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js +51 -51
  340. package/lib/browser/shell/tab-bars.d.ts +339 -338
  341. package/lib/browser/shell/tab-bars.d.ts.map +1 -1
  342. package/lib/browser/shell/tab-bars.js +1309 -1277
  343. package/lib/browser/shell/tab-bars.js.map +1 -1
  344. package/lib/browser/shell/tab-bars.spec.d.ts +1 -1
  345. package/lib/browser/shell/tab-bars.spec.js +56 -56
  346. package/lib/browser/shell/theia-dock-panel.d.ts +59 -59
  347. package/lib/browser/shell/theia-dock-panel.js +226 -226
  348. package/lib/browser/shell/view-contribution.d.ts +43 -43
  349. package/lib/browser/shell/view-contribution.js +167 -167
  350. package/lib/browser/source-tree/index.d.ts +3 -3
  351. package/lib/browser/source-tree/index.js +30 -30
  352. package/lib/browser/source-tree/source-tree-widget.d.ts +21 -21
  353. package/lib/browser/source-tree/source-tree-widget.js +118 -118
  354. package/lib/browser/source-tree/source-tree.d.ts +36 -36
  355. package/lib/browser/source-tree/source-tree.js +134 -134
  356. package/lib/browser/source-tree/tree-source.d.ts +35 -35
  357. package/lib/browser/source-tree/tree-source.js +64 -64
  358. package/lib/browser/status-bar/index.d.ts +5 -5
  359. package/lib/browser/status-bar/index.js +40 -40
  360. package/lib/browser/status-bar/status-bar-types.d.ts +72 -72
  361. package/lib/browser/status-bar/status-bar-types.js +25 -25
  362. package/lib/browser/status-bar/status-bar-view-model.d.ts +35 -35
  363. package/lib/browser/status-bar/status-bar-view-model.js +212 -212
  364. package/lib/browser/status-bar/status-bar.d.ts +34 -34
  365. package/lib/browser/status-bar/status-bar.js +192 -192
  366. package/lib/browser/storage-service.d.ts +35 -35
  367. package/lib/browser/storage-service.js +130 -130
  368. package/lib/browser/storage-service.spec.d.ts +1 -1
  369. package/lib/browser/storage-service.spec.js +68 -68
  370. package/lib/browser/styling-service.d.ts +28 -28
  371. package/lib/browser/styling-service.js +85 -85
  372. package/lib/browser/supported-encodings.d.ts +9 -9
  373. package/lib/browser/supported-encodings.js +263 -263
  374. package/lib/browser/test/jsdom.d.ts +8 -8
  375. package/lib/browser/test/jsdom.js +69 -69
  376. package/lib/browser/test/mock-connection-status-service.d.ts +5 -5
  377. package/lib/browser/test/mock-connection-status-service.js +32 -32
  378. package/lib/browser/test/mock-env-variables-server.d.ts +12 -12
  379. package/lib/browser/test/mock-env-variables-server.js +42 -42
  380. package/lib/browser/test/mock-opener-service.d.ts +8 -8
  381. package/lib/browser/test/mock-opener-service.js +40 -40
  382. package/lib/browser/test/mock-storage-service.d.ts +11 -11
  383. package/lib/browser/test/mock-storage-service.js +54 -54
  384. package/lib/browser/theming.d.ts +50 -50
  385. package/lib/browser/theming.js +211 -211
  386. package/lib/browser/tooltip-service.d.ts +34 -34
  387. package/lib/browser/tooltip-service.js +87 -87
  388. package/lib/browser/tooltip-service.js.map +1 -1
  389. package/lib/browser/tree/fuzzy-search.d.ts +60 -60
  390. package/lib/browser/tree/fuzzy-search.js +80 -80
  391. package/lib/browser/tree/fuzzy-search.spec.d.ts +1 -1
  392. package/lib/browser/tree/fuzzy-search.spec.js +89 -89
  393. package/lib/browser/tree/index.d.ts +13 -12
  394. package/lib/browser/tree/index.d.ts.map +1 -1
  395. package/lib/browser/tree/index.js +40 -39
  396. package/lib/browser/tree/index.js.map +1 -1
  397. package/lib/browser/tree/search-box-debounce.d.ts +33 -33
  398. package/lib/browser/tree/search-box-debounce.js +75 -75
  399. package/lib/browser/tree/search-box.d.ts +105 -105
  400. package/lib/browser/tree/search-box.js +265 -265
  401. package/lib/browser/tree/test/mock-selectable-tree-model.d.ts +15 -0
  402. package/lib/browser/tree/test/mock-selectable-tree-model.d.ts.map +1 -0
  403. package/lib/browser/tree/test/mock-selectable-tree-model.js +103 -0
  404. package/lib/browser/tree/test/mock-selectable-tree-model.js.map +1 -0
  405. package/lib/browser/tree/test/mock-tree-model.d.ts +12 -12
  406. package/lib/browser/tree/test/mock-tree-model.js +129 -129
  407. package/lib/browser/tree/test/tree-test-container.d.ts +2 -2
  408. package/lib/browser/tree/test/tree-test-container.js +52 -52
  409. package/lib/browser/tree/tree-compression/compressed-tree-expansion-service.d.ts +8 -8
  410. package/lib/browser/tree/tree-compression/compressed-tree-expansion-service.js +67 -67
  411. package/lib/browser/tree/tree-compression/compressed-tree-model.d.ts +23 -23
  412. package/lib/browser/tree/tree-compression/compressed-tree-model.js +97 -97
  413. package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts +38 -38
  414. package/lib/browser/tree/tree-compression/compressed-tree-widget.js +198 -198
  415. package/lib/browser/tree/tree-compression/index.d.ts +4 -4
  416. package/lib/browser/tree/tree-compression/index.js +31 -31
  417. package/lib/browser/tree/tree-compression/tree-compression-service.d.ts +58 -58
  418. package/lib/browser/tree/tree-compression/tree-compression-service.js +103 -103
  419. package/lib/browser/tree/tree-consistency.spec.d.ts +1 -1
  420. package/lib/browser/tree/tree-consistency.spec.js +104 -104
  421. package/lib/browser/tree/tree-container.d.ts +51 -51
  422. package/lib/browser/tree/tree-container.js +115 -115
  423. package/lib/browser/tree/tree-container.spec.d.ts +1 -1
  424. package/lib/browser/tree/tree-container.spec.js +45 -45
  425. package/lib/browser/tree/tree-decorator.d.ts +143 -143
  426. package/lib/browser/tree/tree-decorator.js +123 -123
  427. package/lib/browser/tree/tree-decorator.spec.d.ts +1 -1
  428. package/lib/browser/tree/tree-decorator.spec.js +145 -145
  429. package/lib/browser/tree/tree-expansion.d.ts +65 -65
  430. package/lib/browser/tree/tree-expansion.js +132 -132
  431. package/lib/browser/tree/tree-expansion.spec.d.ts +1 -1
  432. package/lib/browser/tree/tree-expansion.spec.js +155 -155
  433. package/lib/browser/tree/tree-focus-service.d.ts +19 -19
  434. package/lib/browser/tree/tree-focus-service.js +61 -61
  435. package/lib/browser/tree/tree-iterator.d.ts +94 -94
  436. package/lib/browser/tree/tree-iterator.js +223 -223
  437. package/lib/browser/tree/tree-iterator.spec.d.ts +1 -1
  438. package/lib/browser/tree/tree-iterator.spec.js +150 -150
  439. package/lib/browser/tree/tree-label-provider.d.ts +8 -8
  440. package/lib/browser/tree/tree-label-provider.js +44 -44
  441. package/lib/browser/tree/tree-model.d.ts +202 -178
  442. package/lib/browser/tree/tree-model.d.ts.map +1 -1
  443. package/lib/browser/tree/tree-model.js +403 -357
  444. package/lib/browser/tree/tree-model.js.map +1 -1
  445. package/lib/browser/tree/tree-navigation.d.ts +10 -10
  446. package/lib/browser/tree/tree-navigation.js +62 -62
  447. package/lib/browser/tree/tree-preference.d.ts +11 -0
  448. package/lib/browser/tree/tree-preference.d.ts.map +1 -0
  449. package/lib/browser/tree/tree-preference.js +47 -0
  450. package/lib/browser/tree/tree-preference.js.map +1 -0
  451. package/lib/browser/tree/tree-search.d.ts +36 -36
  452. package/lib/browser/tree/tree-search.js +138 -138
  453. package/lib/browser/tree/tree-selectable.spec.d.ts +2 -0
  454. package/lib/browser/tree/tree-selectable.spec.d.ts.map +1 -0
  455. package/lib/browser/tree/tree-selectable.spec.js +147 -0
  456. package/lib/browser/tree/tree-selectable.spec.js.map +1 -0
  457. package/lib/browser/tree/tree-selection-impl.d.ts +44 -44
  458. package/lib/browser/tree/tree-selection-impl.js +166 -166
  459. package/lib/browser/tree/tree-selection-state.d.ts +48 -48
  460. package/lib/browser/tree/tree-selection-state.js +227 -227
  461. package/lib/browser/tree/tree-selection-state.spec.d.ts +1 -1
  462. package/lib/browser/tree/tree-selection-state.spec.js +420 -420
  463. package/lib/browser/tree/tree-selection.d.ts +86 -86
  464. package/lib/browser/tree/tree-selection.js +86 -86
  465. package/lib/browser/tree/tree-view-welcome-widget.d.ts +45 -45
  466. package/lib/browser/tree/tree-view-welcome-widget.js +200 -200
  467. package/lib/browser/tree/tree-widget-selection.d.ts +11 -11
  468. package/lib/browser/tree/tree-widget-selection.js +46 -46
  469. package/lib/browser/tree/tree-widget.d.ts +559 -556
  470. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  471. package/lib/browser/tree/tree-widget.js +1363 -1342
  472. package/lib/browser/tree/tree-widget.js.map +1 -1
  473. package/lib/browser/tree/tree.d.ts +180 -180
  474. package/lib/browser/tree/tree.d.ts.map +1 -1
  475. package/lib/browser/tree/tree.js +296 -293
  476. package/lib/browser/tree/tree.js.map +1 -1
  477. package/lib/browser/tree/tree.spec.d.ts +1 -1
  478. package/lib/browser/tree/tree.spec.js +226 -226
  479. package/lib/browser/user-working-directory-provider.d.ts +23 -23
  480. package/lib/browser/user-working-directory-provider.js +84 -84
  481. package/lib/browser/view-container.d.ts +312 -312
  482. package/lib/browser/view-container.js +1466 -1466
  483. package/lib/browser/widget-decoration.d.ts +299 -299
  484. package/lib/browser/widget-decoration.js +140 -140
  485. package/lib/browser/widget-manager.d.ts +172 -163
  486. package/lib/browser/widget-manager.d.ts.map +1 -1
  487. package/lib/browser/widget-manager.js +230 -207
  488. package/lib/browser/widget-manager.js.map +1 -1
  489. package/lib/browser/widget-manager.spec.d.ts +1 -1
  490. package/lib/browser/widget-manager.spec.js +91 -91
  491. package/lib/browser/widget-open-handler.d.ts +88 -88
  492. package/lib/browser/widget-open-handler.js +145 -145
  493. package/lib/browser/widgets/alert-message.d.ts +23 -23
  494. package/lib/browser/widgets/alert-message.js +38 -38
  495. package/lib/browser/widgets/enhanced-preview-widget.d.ts +6 -6
  496. package/lib/browser/widgets/enhanced-preview-widget.js +26 -26
  497. package/lib/browser/widgets/extractable-widget.d.ts +13 -13
  498. package/lib/browser/widgets/extractable-widget.js +26 -26
  499. package/lib/browser/widgets/index.d.ts +4 -4
  500. package/lib/browser/widgets/index.js +31 -31
  501. package/lib/browser/widgets/previewable-widget.d.ts +8 -8
  502. package/lib/browser/widgets/previewable-widget.js +30 -30
  503. package/lib/browser/widgets/react-renderer.d.ts +14 -14
  504. package/lib/browser/widgets/react-renderer.js +59 -59
  505. package/lib/browser/widgets/react-widget.d.ts +16 -16
  506. package/lib/browser/widgets/react-widget.js +57 -57
  507. package/lib/browser/widgets/select-component.d.ts +53 -53
  508. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  509. package/lib/browser/widgets/select-component.js +307 -306
  510. package/lib/browser/widgets/select-component.js.map +1 -1
  511. package/lib/browser/widgets/widget.d.ts +108 -106
  512. package/lib/browser/widgets/widget.d.ts.map +1 -1
  513. package/lib/browser/widgets/widget.js +385 -377
  514. package/lib/browser/widgets/widget.js.map +1 -1
  515. package/lib/browser/window/browser-window-module.d.ts +3 -3
  516. package/lib/browser/window/browser-window-module.js +32 -32
  517. package/lib/browser/window/default-secondary-window-service.d.ts +25 -25
  518. package/lib/browser/window/default-secondary-window-service.js +198 -198
  519. package/lib/browser/window/default-window-service.d.ts +49 -49
  520. package/lib/browser/window/default-window-service.js +172 -172
  521. package/lib/browser/window/default-window-service.spec.d.ts +1 -1
  522. package/lib/browser/window/default-window-service.spec.js +80 -80
  523. package/lib/browser/window/secondary-window-service.d.ts +20 -20
  524. package/lib/browser/window/secondary-window-service.js +19 -19
  525. package/lib/browser/window/test/mock-window-service.d.ts +10 -10
  526. package/lib/browser/window/test/mock-window-service.js +38 -38
  527. package/lib/browser/window/window-service.d.ts +45 -45
  528. package/lib/browser/window/window-service.js +22 -22
  529. package/lib/browser/window/window-title-service.d.ts +31 -31
  530. package/lib/browser/window/window-title-service.js +120 -120
  531. package/lib/browser/window/window-title-updater.d.ts +19 -19
  532. package/lib/browser/window/window-title-updater.js +107 -107
  533. package/lib/browser/window-contribution.d.ts +14 -14
  534. package/lib/browser/window-contribution.js +70 -70
  535. package/lib/browser-only/frontend-only-application-module.d.ts +5 -0
  536. package/lib/browser-only/frontend-only-application-module.d.ts.map +1 -0
  537. package/lib/browser-only/frontend-only-application-module.js +115 -0
  538. package/lib/browser-only/frontend-only-application-module.js.map +1 -0
  539. package/lib/browser-only/i18n/i18n-frontend-only-module.d.ts +4 -0
  540. package/lib/browser-only/i18n/i18n-frontend-only-module.d.ts.map +1 -0
  541. package/lib/browser-only/i18n/i18n-frontend-only-module.js +35 -0
  542. package/lib/browser-only/i18n/i18n-frontend-only-module.js.map +1 -0
  543. package/lib/browser-only/logger-frontend-only-module.d.ts +3 -0
  544. package/lib/browser-only/logger-frontend-only-module.d.ts.map +1 -0
  545. package/lib/browser-only/logger-frontend-only-module.js +61 -0
  546. package/lib/browser-only/logger-frontend-only-module.js.map +1 -0
  547. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts +14 -0
  548. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts.map +1 -0
  549. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js +57 -0
  550. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js.map +1 -0
  551. package/lib/browser-only/messaging/messaging-frontend-only-module.d.ts +3 -0
  552. package/lib/browser-only/messaging/messaging-frontend-only-module.d.ts.map +1 -0
  553. package/lib/browser-only/messaging/messaging-frontend-only-module.js +48 -0
  554. package/lib/browser-only/messaging/messaging-frontend-only-module.js.map +1 -0
  555. package/lib/browser-only/preload/frontend-only-preload-module.d.ts +4 -0
  556. package/lib/browser-only/preload/frontend-only-preload-module.d.ts.map +1 -0
  557. package/lib/browser-only/preload/frontend-only-preload-module.js +52 -0
  558. package/lib/browser-only/preload/frontend-only-preload-module.js.map +1 -0
  559. package/lib/common/accessibility.d.ts +16 -16
  560. package/lib/common/accessibility.js +17 -17
  561. package/lib/common/application-error.d.ts +20 -20
  562. package/lib/common/application-error.js +62 -62
  563. package/lib/common/application-error.spec.d.ts +1 -1
  564. package/lib/common/application-error.spec.js +26 -26
  565. package/lib/common/application-protocol.d.ts +20 -19
  566. package/lib/common/application-protocol.d.ts.map +1 -1
  567. package/lib/common/application-protocol.js +20 -20
  568. package/lib/common/array-utils.d.ts +55 -55
  569. package/lib/common/array-utils.js +118 -118
  570. package/lib/common/buffer.d.ts +43 -43
  571. package/lib/common/buffer.js +205 -205
  572. package/lib/common/cancellation.d.ts +24 -24
  573. package/lib/common/cancellation.js +142 -142
  574. package/lib/common/char-code.d.ts +401 -401
  575. package/lib/common/char-code.js +22 -22
  576. package/lib/common/collections.d.ts +29 -29
  577. package/lib/common/collections.js +121 -121
  578. package/lib/common/color.d.ts +71 -71
  579. package/lib/common/color.js +43 -43
  580. package/lib/common/command.d.ts +232 -232
  581. package/lib/common/command.js +364 -364
  582. package/lib/common/command.spec.d.ts +1 -1
  583. package/lib/common/command.spec.js +173 -173
  584. package/lib/common/contribution-filter/contribution-filter-registry.d.ts +17 -17
  585. package/lib/common/contribution-filter/contribution-filter-registry.js +88 -88
  586. package/lib/common/contribution-filter/contribution-filter.d.ts +41 -41
  587. package/lib/common/contribution-filter/contribution-filter.js +20 -20
  588. package/lib/common/contribution-filter/filter.d.ts +6 -6
  589. package/lib/common/contribution-filter/filter.js +19 -19
  590. package/lib/common/contribution-filter/index.d.ts +3 -3
  591. package/lib/common/contribution-filter/index.js +30 -30
  592. package/lib/common/contribution-provider.d.ts +20 -20
  593. package/lib/common/contribution-provider.js +82 -82
  594. package/lib/common/disposable.d.ts +80 -43
  595. package/lib/common/disposable.d.ts.map +1 -1
  596. package/lib/common/disposable.js +173 -120
  597. package/lib/common/disposable.js.map +1 -1
  598. package/lib/common/disposable.spec.d.ts +1 -1
  599. package/lib/common/disposable.spec.js +80 -29
  600. package/lib/common/disposable.spec.js.map +1 -1
  601. package/lib/common/encoding-service.d.ts +38 -38
  602. package/lib/common/encoding-service.js +307 -307
  603. package/lib/common/encodings.d.ts +7 -7
  604. package/lib/common/encodings.js +25 -25
  605. package/lib/common/env-variables/env-variables-protocol.d.ts +20 -20
  606. package/lib/common/env-variables/env-variables-protocol.js +20 -20
  607. package/lib/common/env-variables/index.d.ts +1 -1
  608. package/lib/common/env-variables/index.js +28 -28
  609. package/lib/common/event.d.ts +115 -115
  610. package/lib/common/event.js +385 -385
  611. package/lib/common/event.spec.d.ts +1 -1
  612. package/lib/common/event.spec.js +29 -29
  613. package/lib/{node → common}/file-uri.d.ts +14 -14
  614. package/lib/common/file-uri.d.ts.map +1 -0
  615. package/lib/{node → common}/file-uri.js +62 -62
  616. package/lib/common/file-uri.js.map +1 -0
  617. package/lib/common/frontend-application-state.d.ts +15 -15
  618. package/lib/common/frontend-application-state.js +33 -33
  619. package/lib/common/glob.d.ts +50 -50
  620. package/lib/common/glob.js +591 -591
  621. package/lib/common/hash.d.ts +7 -7
  622. package/lib/common/hash.js +84 -84
  623. package/lib/common/i18n/localization-server.d.ts +6 -6
  624. package/lib/common/i18n/localization-server.js +20 -20
  625. package/lib/common/i18n/localization.d.ts +34 -34
  626. package/lib/common/i18n/localization.js +59 -59
  627. package/lib/common/index.d.ts +35 -34
  628. package/lib/common/index.d.ts.map +1 -1
  629. package/lib/common/index.js +65 -64
  630. package/lib/common/index.js.map +1 -1
  631. package/lib/common/json-schema.d.ts +72 -72
  632. package/lib/common/json-schema.js +17 -17
  633. package/lib/common/key-store.d.ts +12 -12
  634. package/lib/common/key-store.js +20 -20
  635. package/lib/common/keybinding.d.ts +75 -75
  636. package/lib/common/keybinding.js +113 -113
  637. package/lib/common/keyboard/keyboard-layout-provider.d.ts +26 -26
  638. package/lib/common/keyboard/keyboard-layout-provider.js +22 -22
  639. package/lib/common/keys.d.ts +253 -253
  640. package/lib/common/keys.js +634 -634
  641. package/lib/common/label-protocol.d.ts +13 -13
  642. package/lib/common/label-protocol.js +17 -17
  643. package/lib/common/logger-protocol.d.ts +41 -41
  644. package/lib/common/logger-protocol.js +105 -105
  645. package/lib/common/logger-watcher.d.ts +9 -9
  646. package/lib/common/logger-watcher.js +54 -54
  647. package/lib/common/logger.d.ts +207 -207
  648. package/lib/common/logger.js +212 -212
  649. package/lib/common/logger.spec.d.ts +1 -1
  650. package/lib/common/logger.spec.js +41 -41
  651. package/lib/common/lsp-types.d.ts +9 -9
  652. package/lib/common/lsp-types.js +30 -30
  653. package/lib/common/markdown-rendering/icon-utilities.d.ts +7 -7
  654. package/lib/common/markdown-rendering/icon-utilities.js +32 -32
  655. package/lib/common/markdown-rendering/index.d.ts +2 -2
  656. package/lib/common/markdown-rendering/index.js +29 -29
  657. package/lib/common/markdown-rendering/markdown-string.d.ts +46 -43
  658. package/lib/common/markdown-rendering/markdown-string.d.ts.map +1 -1
  659. package/lib/common/markdown-rendering/markdown-string.js +126 -126
  660. package/lib/common/markdown-rendering/markdown-string.js.map +1 -1
  661. package/lib/common/menu/action-menu-node.d.ts +19 -19
  662. package/lib/common/menu/action-menu-node.js +56 -56
  663. package/lib/common/menu/composite-menu-node.d.ts +46 -46
  664. package/lib/common/menu/composite-menu-node.js +93 -93
  665. package/lib/common/menu/index.d.ts +5 -5
  666. package/lib/common/menu/index.js +32 -32
  667. package/lib/common/menu/menu-adapter.d.ts +35 -35
  668. package/lib/common/menu/menu-adapter.js +100 -100
  669. package/lib/common/menu/menu-model-registry.d.ts +145 -145
  670. package/lib/common/menu/menu-model-registry.d.ts.map +1 -1
  671. package/lib/common/menu/menu-model-registry.js +286 -272
  672. package/lib/common/menu/menu-model-registry.js.map +1 -1
  673. package/lib/common/menu/menu-types.d.ts +148 -148
  674. package/lib/common/menu/menu-types.js +93 -93
  675. package/lib/common/menu/menu.spec.d.ts +1 -1
  676. package/lib/common/menu/menu.spec.js +96 -69
  677. package/lib/common/menu/menu.spec.js.map +1 -1
  678. package/lib/common/message-rpc/channel.d.ts +123 -123
  679. package/lib/common/message-rpc/channel.js +230 -230
  680. package/lib/common/message-rpc/channel.spec.d.ts +8 -8
  681. package/lib/common/message-rpc/channel.spec.js +79 -79
  682. package/lib/common/message-rpc/index.d.ts +3 -3
  683. package/lib/common/message-rpc/index.js +24 -24
  684. package/lib/common/message-rpc/message-buffer.d.ts +51 -51
  685. package/lib/common/message-rpc/message-buffer.js +59 -59
  686. package/lib/common/message-rpc/msg-pack-extension-manager.d.ts +22 -22
  687. package/lib/common/message-rpc/msg-pack-extension-manager.js +57 -57
  688. package/lib/common/message-rpc/rpc-message-encoder.d.ts +103 -103
  689. package/lib/common/message-rpc/rpc-message-encoder.js +113 -113
  690. package/lib/common/message-rpc/rpc-message-encoder.spec.d.ts +1 -1
  691. package/lib/common/message-rpc/rpc-message-encoder.spec.js +58 -58
  692. package/lib/common/message-rpc/rpc-protocol.d.ts +67 -65
  693. package/lib/common/message-rpc/rpc-protocol.d.ts.map +1 -1
  694. package/lib/common/message-rpc/rpc-protocol.js +209 -191
  695. package/lib/common/message-rpc/rpc-protocol.js.map +1 -1
  696. package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +52 -52
  697. package/lib/common/message-rpc/uint8-array-message-buffer.js +174 -174
  698. package/lib/common/message-rpc/uint8-array-message-buffer.spec.d.ts +1 -1
  699. package/lib/common/message-rpc/uint8-array-message-buffer.spec.js +38 -38
  700. package/lib/common/message-service-protocol.d.ts +110 -110
  701. package/lib/common/message-service-protocol.js +78 -78
  702. package/lib/common/message-service.d.ts +134 -134
  703. package/lib/common/message-service.js +162 -162
  704. package/lib/common/messaging/connection-error-handler.d.ts +28 -28
  705. package/lib/common/messaging/connection-error-handler.js +47 -47
  706. package/lib/common/messaging/connection-management.d.ts +24 -24
  707. package/lib/common/messaging/connection-management.js +37 -37
  708. package/lib/common/messaging/handler.d.ts +7 -7
  709. package/lib/common/messaging/handler.js +20 -20
  710. package/lib/common/messaging/index.d.ts +3 -3
  711. package/lib/common/messaging/index.js +30 -30
  712. package/lib/common/messaging/proxy-factory.d.ts +180 -180
  713. package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
  714. package/lib/common/messaging/proxy-factory.js +280 -287
  715. package/lib/common/messaging/proxy-factory.js.map +1 -1
  716. package/lib/common/messaging/proxy-factory.spec.d.ts +1 -1
  717. package/lib/common/messaging/proxy-factory.spec.js +99 -99
  718. package/lib/common/messaging/socket-write-buffer.d.ts +10 -10
  719. package/lib/common/messaging/socket-write-buffer.js +49 -49
  720. package/lib/common/messaging/web-socket-channel.d.ts +19 -19
  721. package/lib/common/messaging/web-socket-channel.js +64 -64
  722. package/lib/common/nls.d.ts +15 -15
  723. package/lib/common/nls.js +133 -133
  724. package/lib/common/numbers.d.ts +5 -5
  725. package/lib/common/numbers.js +23 -23
  726. package/lib/common/objects.d.ts +8 -8
  727. package/lib/common/objects.js +118 -118
  728. package/lib/common/objects.spec.d.ts +1 -1
  729. package/lib/common/objects.spec.js +101 -101
  730. package/lib/common/os.d.ts +31 -31
  731. package/lib/common/os.js +73 -73
  732. package/lib/common/path.d.ts +93 -93
  733. package/lib/common/path.js +307 -307
  734. package/lib/common/path.spec.d.ts +1 -1
  735. package/lib/common/path.spec.js +350 -350
  736. package/lib/common/paths.d.ts +24 -24
  737. package/lib/common/paths.js +226 -226
  738. package/lib/common/performance/index.d.ts +3 -3
  739. package/lib/common/performance/index.js +30 -30
  740. package/lib/common/performance/measurement-protocol.d.ts +64 -64
  741. package/lib/common/performance/measurement-protocol.js +78 -78
  742. package/lib/common/performance/measurement.d.ts +111 -111
  743. package/lib/common/performance/measurement.js +17 -17
  744. package/lib/common/performance/stopwatch.d.ts +75 -75
  745. package/lib/common/performance/stopwatch.js +156 -156
  746. package/lib/common/preferences/preference-schema.d.ts +52 -52
  747. package/lib/common/preferences/preference-schema.js +58 -58
  748. package/lib/common/preferences/preference-scope.d.ts +19 -19
  749. package/lib/common/preferences/preference-scope.js +71 -71
  750. package/lib/common/preferences/preference-scope.spec.d.ts +1 -1
  751. package/lib/common/preferences/preference-scope.spec.js +44 -44
  752. package/lib/common/prioritizeable.d.ts +16 -16
  753. package/lib/common/prioritizeable.js +55 -55
  754. package/lib/common/progress-service-protocol.d.ts +13 -13
  755. package/lib/common/progress-service-protocol.js +19 -19
  756. package/lib/common/progress-service.d.ts +13 -13
  757. package/lib/common/progress-service.js +96 -96
  758. package/lib/common/promise-util.d.ts +51 -51
  759. package/lib/common/promise-util.js +132 -132
  760. package/lib/common/promise-util.spec.d.ts +1 -1
  761. package/lib/common/promise-util.spec.js +55 -55
  762. package/lib/common/quick-pick-service.d.ts +269 -280
  763. package/lib/common/quick-pick-service.d.ts.map +1 -1
  764. package/lib/common/quick-pick-service.js +133 -158
  765. package/lib/common/quick-pick-service.js.map +1 -1
  766. package/lib/common/reference.d.ts +95 -40
  767. package/lib/common/reference.d.ts.map +1 -1
  768. package/lib/common/reference.js +207 -152
  769. package/lib/common/reference.js.map +1 -1
  770. package/lib/common/reference.spec.d.ts +1 -1
  771. package/lib/common/reference.spec.js +125 -125
  772. package/lib/common/resource.d.ts +207 -205
  773. package/lib/common/resource.d.ts.map +1 -1
  774. package/lib/common/resource.js +333 -333
  775. package/lib/common/resource.js.map +1 -1
  776. package/lib/common/selection-command-handler.d.ts +24 -24
  777. package/lib/common/selection-command-handler.js +83 -83
  778. package/lib/common/selection-service.d.ts +18 -18
  779. package/lib/common/selection-service.js +48 -48
  780. package/lib/common/selection-service.spec.d.ts +1 -1
  781. package/lib/common/selection-service.spec.js +38 -38
  782. package/lib/common/selection.d.ts +9 -9
  783. package/lib/common/selection.js +47 -47
  784. package/lib/common/severity.d.ts +15 -15
  785. package/lib/common/severity.js +113 -113
  786. package/lib/common/stream.d.ts +176 -176
  787. package/lib/common/stream.js +474 -474
  788. package/lib/common/strings.d.ts +24 -24
  789. package/lib/common/strings.js +215 -215
  790. package/lib/common/telemetry.d.ts +19 -19
  791. package/lib/common/telemetry.js +24 -24
  792. package/lib/common/ternary-search-tree.d.ts +50 -50
  793. package/lib/common/ternary-search-tree.js +381 -381
  794. package/lib/common/test/expect.d.ts +2 -2
  795. package/lib/common/test/expect.js +34 -34
  796. package/lib/common/test/mock-logger.d.ts +27 -27
  797. package/lib/common/test/mock-logger.js +104 -104
  798. package/lib/common/test/mock-menu.d.ts +7 -7
  799. package/lib/common/test/mock-menu.js +34 -34
  800. package/lib/common/test/mock-resource-provider.d.ts +6 -6
  801. package/lib/common/test/mock-resource-provider.js +44 -44
  802. package/lib/common/theme.d.ts +40 -15
  803. package/lib/common/theme.d.ts.map +1 -1
  804. package/lib/common/theme.js +22 -22
  805. package/lib/common/theme.js.map +1 -1
  806. package/lib/common/types.d.ts +58 -58
  807. package/lib/common/types.js +126 -126
  808. package/lib/common/types.spec.d.ts +1 -1
  809. package/lib/common/types.spec.js +73 -73
  810. package/lib/common/uri-command-handler.d.ts +53 -53
  811. package/lib/common/uri-command-handler.js +99 -99
  812. package/lib/common/uri-command-handler.spec.d.ts +1 -1
  813. package/lib/common/uri-command-handler.spec.js +80 -80
  814. package/lib/common/uri.d.ts +87 -86
  815. package/lib/common/uri.d.ts.map +1 -1
  816. package/lib/common/uri.js +236 -236
  817. package/lib/common/uri.js.map +1 -1
  818. package/lib/common/uri.spec.d.ts +1 -1
  819. package/lib/common/uri.spec.js +230 -230
  820. package/lib/common/uuid.d.ts +8 -2
  821. package/lib/common/uuid.d.ts.map +1 -1
  822. package/lib/common/uuid.js +44 -85
  823. package/lib/common/uuid.js.map +1 -1
  824. package/lib/common/version.d.ts +1 -1
  825. package/lib/common/version.js +19 -19
  826. package/lib/common/view-column.d.ts +17 -17
  827. package/lib/common/view-column.js +36 -36
  828. package/lib/common/window.d.ts +16 -16
  829. package/lib/common/window.js +22 -22
  830. package/lib/electron-browser/electron-clipboard-service.d.ts +5 -5
  831. package/lib/electron-browser/electron-clipboard-service.js +38 -38
  832. package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.d.ts +11 -11
  833. package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.js +54 -54
  834. package/lib/electron-browser/keyboard/electron-keyboard-module.d.ts +3 -3
  835. package/lib/electron-browser/keyboard/electron-keyboard-module.js +26 -26
  836. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +30 -30
  837. package/lib/electron-browser/menu/electron-context-menu-renderer.js +137 -137
  838. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +59 -59
  839. package/lib/electron-browser/menu/electron-main-menu-factory.js +282 -282
  840. package/lib/electron-browser/menu/electron-menu-contribution.d.ts +78 -77
  841. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  842. package/lib/electron-browser/menu/electron-menu-contribution.js +482 -473
  843. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  844. package/lib/electron-browser/menu/electron-menu-module.d.ts +3 -3
  845. package/lib/electron-browser/menu/electron-menu-module.js +39 -39
  846. package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts +4 -4
  847. package/lib/electron-browser/messaging/electron-frontend-id-provider.js +34 -34
  848. package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts +23 -23
  849. package/lib/electron-browser/messaging/electron-ipc-connection-source.js +64 -64
  850. package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +6 -6
  851. package/lib/electron-browser/messaging/electron-local-ws-connection-source.js +54 -54
  852. package/lib/electron-browser/messaging/electron-messaging-frontend-module.d.ts +2 -2
  853. package/lib/electron-browser/messaging/electron-messaging-frontend-module.js +75 -75
  854. package/lib/electron-browser/messaging/electron-messaging-frontend-module.js.map +1 -1
  855. package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts +11 -11
  856. package/lib/electron-browser/messaging/electron-ws-connection-source.js +50 -50
  857. package/lib/electron-browser/preload.d.ts +1 -1
  858. package/lib/electron-browser/preload.js +201 -201
  859. package/lib/electron-browser/request/electron-browser-request-module.d.ts +18 -18
  860. package/lib/electron-browser/request/electron-browser-request-module.js +26 -26
  861. package/lib/electron-browser/token/electron-token-frontend-module.d.ts +3 -3
  862. package/lib/electron-browser/token/electron-token-frontend-module.js +22 -22
  863. package/lib/electron-browser/window/electron-frontend-application-state.d.ts +4 -4
  864. package/lib/electron-browser/window/electron-frontend-application-state.js +36 -36
  865. package/lib/electron-browser/window/electron-secondary-window-service.d.ts +7 -7
  866. package/lib/electron-browser/window/electron-secondary-window-service.js +47 -47
  867. package/lib/electron-browser/window/electron-window-module.d.ts +3 -3
  868. package/lib/electron-browser/window/electron-window-module.js +39 -39
  869. package/lib/electron-browser/window/electron-window-preferences.d.ts +18 -18
  870. package/lib/electron-browser/window/electron-window-preferences.js +72 -72
  871. package/lib/electron-browser/window/electron-window-service.d.ts +29 -29
  872. package/lib/electron-browser/window/electron-window-service.js +114 -114
  873. package/lib/electron-common/electron-api.d.ts +104 -104
  874. package/lib/electron-common/electron-api.js +56 -56
  875. package/lib/electron-common/electron-main-window-service.d.ts +7 -7
  876. package/lib/electron-common/electron-main-window-service.js +20 -20
  877. package/lib/electron-common/electron-token.d.ts +10 -10
  878. package/lib/electron-common/electron-token.js +27 -27
  879. package/lib/electron-main/electron-api-main.d.ts +22 -22
  880. package/lib/electron-main/electron-api-main.js +294 -294
  881. package/lib/electron-main/electron-main-application-module.d.ts +3 -3
  882. package/lib/electron-main/electron-main-application-module.js +56 -56
  883. package/lib/electron-main/electron-main-application-module.js.map +1 -1
  884. package/lib/electron-main/electron-main-application.d.ts +159 -159
  885. package/lib/electron-main/electron-main-application.js +611 -611
  886. package/lib/electron-main/electron-main-application.js.map +1 -1
  887. package/lib/electron-main/electron-main-constants.d.ts +6 -6
  888. package/lib/electron-main/electron-main-constants.js +19 -19
  889. package/lib/electron-main/electron-main-window-service-impl.d.ts +8 -8
  890. package/lib/electron-main/electron-main-window-service-impl.js +54 -54
  891. package/lib/electron-main/electron-security-token-service.d.ts +5 -5
  892. package/lib/electron-main/electron-security-token-service.js +49 -49
  893. package/lib/electron-main/event-utils.d.ts +8 -8
  894. package/lib/electron-main/event-utils.js +33 -33
  895. package/lib/electron-main/messaging/electron-connection-handler.d.ts +5 -5
  896. package/lib/electron-main/messaging/electron-connection-handler.js +23 -23
  897. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +41 -41
  898. package/lib/electron-main/messaging/electron-messaging-contribution.js +150 -150
  899. package/lib/electron-main/messaging/electron-messaging-service.d.ts +17 -17
  900. package/lib/electron-main/messaging/electron-messaging-service.js +22 -22
  901. package/lib/electron-main/theia-electron-window.d.ts +53 -53
  902. package/lib/electron-main/theia-electron-window.js +194 -194
  903. package/lib/electron-main/theia-electron-window.js.map +1 -1
  904. package/lib/electron-node/hosting/electron-backend-hosting-module.d.ts +3 -3
  905. package/lib/electron-node/hosting/electron-backend-hosting-module.js +24 -24
  906. package/lib/electron-node/hosting/electron-ws-origin-validator.d.ts +8 -8
  907. package/lib/electron-node/hosting/electron-ws-origin-validator.js +48 -48
  908. package/lib/electron-node/keyboard/electron-backend-keyboard-module.d.ts +3 -3
  909. package/lib/electron-node/keyboard/electron-backend-keyboard-module.js +26 -26
  910. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.d.ts +5 -5
  911. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js +41 -41
  912. package/lib/electron-node/request/electron-backend-request-module.d.ts +18 -18
  913. package/lib/electron-node/request/electron-backend-request-module.js +23 -23
  914. package/lib/electron-node/request/electron-backend-request-service.d.ts +22 -22
  915. package/lib/electron-node/request/electron-backend-request-service.js +86 -86
  916. package/lib/electron-node/token/electron-token-backend-contribution.d.ts +15 -15
  917. package/lib/electron-node/token/electron-token-backend-contribution.js +58 -58
  918. package/lib/electron-node/token/electron-token-backend-module.d.ts +3 -3
  919. package/lib/electron-node/token/electron-token-backend-module.js +28 -28
  920. package/lib/electron-node/token/electron-token-validator.d.ts +29 -29
  921. package/lib/electron-node/token/electron-token-validator.js +103 -103
  922. package/lib/node/application-server.d.ts +10 -9
  923. package/lib/node/application-server.d.ts.map +1 -1
  924. package/lib/node/application-server.js +63 -57
  925. package/lib/node/application-server.js.map +1 -1
  926. package/lib/node/backend-application-config-provider.d.ts +7 -7
  927. package/lib/node/backend-application-config-provider.js +45 -45
  928. package/lib/node/backend-application-config-provider.spec.d.ts +1 -1
  929. package/lib/node/backend-application-config-provider.spec.js +28 -28
  930. package/lib/node/backend-application-module.d.ts +2 -2
  931. package/lib/node/backend-application-module.js +108 -108
  932. package/lib/node/backend-application.d.ts +108 -108
  933. package/lib/node/backend-application.js +301 -301
  934. package/lib/node/backend-remote-service.d.ts +3 -3
  935. package/lib/node/backend-remote-service.js +34 -34
  936. package/lib/node/cli.d.ts +17 -17
  937. package/lib/node/cli.js +70 -70
  938. package/lib/node/cli.spec.d.ts +1 -1
  939. package/lib/node/cli.spec.js +89 -89
  940. package/lib/node/console-logger-server.d.ts +15 -15
  941. package/lib/node/console-logger-server.js +90 -90
  942. package/lib/node/console-logger-server.spec.d.ts +1 -1
  943. package/lib/node/console-logger-server.spec.js +69 -69
  944. package/lib/node/debug.d.ts +1 -1
  945. package/lib/node/debug.js +28 -28
  946. package/lib/node/dynamic-require.d.ts +7 -7
  947. package/lib/node/dynamic-require.js +56 -56
  948. package/lib/node/env-variables/env-variables-server.d.ts +23 -23
  949. package/lib/node/env-variables/env-variables-server.js +125 -125
  950. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  951. package/lib/node/env-variables/index.d.ts +1 -1
  952. package/lib/node/env-variables/index.js +28 -28
  953. package/lib/node/environment-utils.d.ts +21 -21
  954. package/lib/node/environment-utils.js +77 -77
  955. package/lib/node/environment-utils.spec.d.ts +1 -1
  956. package/lib/node/environment-utils.spec.js +77 -77
  957. package/lib/node/file-uri.spec.d.ts +1 -1
  958. package/lib/node/file-uri.spec.js +66 -66
  959. package/lib/node/file-uri.spec.js.map +1 -1
  960. package/lib/node/filesystem-locking.d.ts +23 -23
  961. package/lib/node/filesystem-locking.js +70 -70
  962. package/lib/node/hosting/backend-application-hosts.d.ts +23 -23
  963. package/lib/node/hosting/backend-application-hosts.js +77 -77
  964. package/lib/node/hosting/backend-hosting-module.d.ts +3 -3
  965. package/lib/node/hosting/backend-hosting-module.js +26 -26
  966. package/lib/node/hosting/ws-origin-validator.d.ts +8 -8
  967. package/lib/node/hosting/ws-origin-validator.js +47 -47
  968. package/lib/node/i18n/i18n-backend-module.d.ts +3 -3
  969. package/lib/node/i18n/i18n-backend-module.js +38 -38
  970. package/lib/node/i18n/localization-contribution.d.ts +18 -18
  971. package/lib/node/i18n/localization-contribution.js +116 -116
  972. package/lib/node/i18n/localization-provider.d.ts +23 -23
  973. package/lib/node/i18n/localization-provider.js +114 -114
  974. package/lib/node/i18n/localization-server.d.ts +14 -14
  975. package/lib/node/i18n/localization-server.js +62 -62
  976. package/lib/node/i18n/theia-localization-contribution.d.ts +4 -4
  977. package/lib/node/i18n/theia-localization-contribution.js +45 -45
  978. package/lib/node/index.d.ts +6 -6
  979. package/lib/node/index.d.ts.map +1 -1
  980. package/lib/node/index.js +35 -35
  981. package/lib/node/index.js.map +1 -1
  982. package/lib/node/key-store-server.d.ts +27 -27
  983. package/lib/node/key-store-server.js +150 -150
  984. package/lib/node/logger-backend-module.d.ts +9 -9
  985. package/lib/node/logger-backend-module.js +78 -78
  986. package/lib/node/logger-cli-contribution.d.ts +33 -33
  987. package/lib/node/logger-cli-contribution.js +152 -152
  988. package/lib/node/logger-cli-contribution.spec.d.ts +1 -1
  989. package/lib/node/logger-cli-contribution.spec.js +207 -207
  990. package/lib/node/main.d.ts +7 -7
  991. package/lib/node/main.js +29 -29
  992. package/lib/node/messaging/binary-message-pipe.d.ts +44 -44
  993. package/lib/node/messaging/binary-message-pipe.js +151 -151
  994. package/lib/node/messaging/connection-container-module.d.ts +53 -53
  995. package/lib/node/messaging/connection-container-module.js +81 -81
  996. package/lib/node/messaging/default-messaging-service.d.ts +28 -28
  997. package/lib/node/messaging/default-messaging-service.js +139 -139
  998. package/lib/node/messaging/frontend-connection-service.d.ts +6 -6
  999. package/lib/node/messaging/frontend-connection-service.js +18 -18
  1000. package/lib/node/messaging/index.d.ts +3 -3
  1001. package/lib/node/messaging/index.js +30 -30
  1002. package/lib/node/messaging/ipc-bootstrap.d.ts +1 -1
  1003. package/lib/node/messaging/ipc-bootstrap.js +24 -24
  1004. package/lib/node/messaging/ipc-channel.d.ts +17 -17
  1005. package/lib/node/messaging/ipc-channel.js +69 -69
  1006. package/lib/node/messaging/ipc-connection-provider.d.ts +21 -21
  1007. package/lib/node/messaging/ipc-connection-provider.js +100 -100
  1008. package/lib/node/messaging/ipc-protocol.d.ts +19 -19
  1009. package/lib/node/messaging/ipc-protocol.js +68 -68
  1010. package/lib/node/messaging/messaging-backend-module.d.ts +2 -2
  1011. package/lib/node/messaging/messaging-backend-module.js +52 -52
  1012. package/lib/node/messaging/messaging-listeners.d.ts +27 -27
  1013. package/lib/node/messaging/messaging-listeners.js +53 -53
  1014. package/lib/node/messaging/messaging-service.d.ts +28 -28
  1015. package/lib/node/messaging/messaging-service.js +24 -24
  1016. package/lib/node/messaging/test/test-web-socket-channel.d.ts +12 -12
  1017. package/lib/node/messaging/test/test-web-socket-channel.js +62 -62
  1018. package/lib/node/messaging/websocket-endpoint.d.ts +20 -20
  1019. package/lib/node/messaging/websocket-endpoint.js +88 -88
  1020. package/lib/node/messaging/websocket-frontend-connection-service.d.ts +30 -29
  1021. package/lib/node/messaging/websocket-frontend-connection-service.d.ts.map +1 -1
  1022. package/lib/node/messaging/websocket-frontend-connection-service.js +177 -172
  1023. package/lib/node/messaging/websocket-frontend-connection-service.js.map +1 -1
  1024. package/lib/node/os-backend-provider.d.ts +4 -4
  1025. package/lib/node/os-backend-provider.js +35 -35
  1026. package/lib/node/performance/index.d.ts +2 -2
  1027. package/lib/node/performance/index.js +29 -29
  1028. package/lib/node/performance/measurement-backend-bindings.d.ts +19 -19
  1029. package/lib/node/performance/measurement-backend-bindings.js +30 -30
  1030. package/lib/node/performance/node-stopwatch.d.ts +20 -20
  1031. package/lib/node/performance/node-stopwatch.js +51 -51
  1032. package/lib/node/process-utils.d.ts +13 -13
  1033. package/lib/node/process-utils.js +110 -110
  1034. package/lib/node/process-utils.spec.d.ts +1 -1
  1035. package/lib/node/process-utils.spec.js +44 -44
  1036. package/lib/node/request/backend-request-facade.d.ts +22 -22
  1037. package/lib/node/request/backend-request-facade.js +49 -49
  1038. package/lib/node/request/backend-request-module.d.ts +18 -18
  1039. package/lib/node/request/backend-request-module.js +24 -24
  1040. package/lib/node/request/proxy-cli-contribution.d.ts +27 -27
  1041. package/lib/node/request/proxy-cli-contribution.js +72 -72
  1042. package/lib/node/ws-request-validators.d.ts +25 -25
  1043. package/lib/node/ws-request-validators.js +60 -60
  1044. package/package.json +13 -8
  1045. package/shared/ajv/index.d.ts +2 -2
  1046. package/shared/markdown-it.d.ts +2 -2
  1047. package/shared/markdown-it.js +1 -1
  1048. package/shared/reflect-metadata/index.d.ts +1 -1
  1049. package/shared/reflect-metadata/index.js +1 -1
  1050. package/shared/vscode-languageserver-types/index.d.ts +1 -1
  1051. package/src/browser/about-dialog.tsx +137 -137
  1052. package/src/browser/authentication-service.ts +456 -456
  1053. package/src/browser/breadcrumbs/breadcrumb-popup-container.ts +101 -101
  1054. package/src/browser/breadcrumbs/breadcrumb-renderer.tsx +41 -41
  1055. package/src/browser/breadcrumbs/breadcrumbs-constants.ts +79 -79
  1056. package/src/browser/breadcrumbs/breadcrumbs-renderer.tsx +185 -185
  1057. package/src/browser/breadcrumbs/breadcrumbs-service.ts +108 -108
  1058. package/src/browser/breadcrumbs/index.ts +21 -21
  1059. package/src/browser/browser-clipboard-service.ts +122 -122
  1060. package/src/browser/browser.ts +225 -220
  1061. package/src/browser/clipboard-service.ts +23 -23
  1062. package/src/browser/color-application-contribution.ts +101 -101
  1063. package/src/browser/color-registry.ts +60 -60
  1064. package/src/browser/command-open-handler.ts +54 -54
  1065. package/src/browser/common-frontend-contribution.ts +2526 -2526
  1066. package/src/browser/common-styling-participants.ts +361 -361
  1067. package/src/browser/connection-status-service.spec.ts +200 -200
  1068. package/src/browser/connection-status-service.ts +216 -216
  1069. package/src/browser/context-key-service.ts +142 -143
  1070. package/src/browser/context-menu-renderer.ts +124 -128
  1071. package/src/browser/core-preferences.ts +334 -328
  1072. package/src/browser/credentials-service.ts +106 -106
  1073. package/src/browser/decoration-style.ts +65 -65
  1074. package/src/browser/decorations-service.ts +209 -209
  1075. package/src/browser/dialogs/react-dialog.tsx +56 -56
  1076. package/src/browser/dialogs.ts +534 -534
  1077. package/src/browser/diff-uris.ts +117 -117
  1078. package/src/browser/encoding-registry.ts +97 -97
  1079. package/src/browser/endpoint.spec.ts +148 -148
  1080. package/src/browser/endpoint.ts +136 -136
  1081. package/src/browser/external-uri-service.ts +79 -79
  1082. package/src/browser/file-icons-js.d.ts +20 -20
  1083. package/src/browser/frontend-application-bindings.ts +62 -62
  1084. package/src/browser/frontend-application-config-provider.spec.ts +45 -45
  1085. package/src/browser/frontend-application-config-provider.ts +50 -50
  1086. package/src/browser/frontend-application-contribution.ts +110 -110
  1087. package/src/browser/frontend-application-module.ts +458 -457
  1088. package/src/browser/frontend-application-state.ts +74 -74
  1089. package/src/browser/frontend-application.ts +326 -326
  1090. package/src/browser/hover-service.ts +218 -218
  1091. package/src/browser/http-open-handler.ts +47 -47
  1092. package/src/browser/i18n/i18n-frontend-module.ts +27 -27
  1093. package/src/browser/i18n/language-quick-pick-service.ts +130 -130
  1094. package/src/browser/icon-registry.ts +87 -96
  1095. package/src/browser/icon-theme-contribution.ts +64 -64
  1096. package/src/browser/icon-theme-service.ts +217 -217
  1097. package/src/browser/icons/CollapseAll.svg +7 -7
  1098. package/src/browser/icons/CollapseAll_inverse.svg +7 -7
  1099. package/src/browser/icons/Refresh.svg +7 -7
  1100. package/src/browser/icons/Refresh_inverse.svg +7 -7
  1101. package/src/browser/icons/add-inverse.svg +4 -4
  1102. package/src/browser/icons/add.svg +4 -4
  1103. package/src/browser/icons/arrow-down-bright.svg +6 -6
  1104. package/src/browser/icons/arrow-down-dark.svg +6 -6
  1105. package/src/browser/icons/arrow-up-bright.svg +6 -6
  1106. package/src/browser/icons/arrow-up-dark.svg +6 -6
  1107. package/src/browser/icons/case-sensitive-dark.svg +16 -16
  1108. package/src/browser/icons/case-sensitive.svg +16 -16
  1109. package/src/browser/icons/chevron-right-dark.svg +5 -5
  1110. package/src/browser/icons/chevron-right-light.svg +6 -6
  1111. package/src/browser/icons/circle-bright.svg +7 -7
  1112. package/src/browser/icons/circle-dark.svg +7 -7
  1113. package/src/browser/icons/clear-search-results-dark.svg +7 -7
  1114. package/src/browser/icons/clear-search-results.svg +7 -7
  1115. package/src/browser/icons/close-all-bright.svg +7 -7
  1116. package/src/browser/icons/close-all-dark.svg +7 -7
  1117. package/src/browser/icons/close-bright.svg +7 -7
  1118. package/src/browser/icons/close-dark.svg +7 -7
  1119. package/src/browser/icons/collapse.svg +4 -4
  1120. package/src/browser/icons/edit-json-dark.svg +6 -6
  1121. package/src/browser/icons/edit-json.svg +6 -6
  1122. package/src/browser/icons/expand.svg +4 -4
  1123. package/src/browser/icons/loading-dark.svg +6 -6
  1124. package/src/browser/icons/loading-light.svg +6 -6
  1125. package/src/browser/icons/open-change-bright.svg +3 -3
  1126. package/src/browser/icons/open-change-dark.svg +4 -4
  1127. package/src/browser/icons/open-file-bright.svg +4 -4
  1128. package/src/browser/icons/open-file-dark.svg +4 -4
  1129. package/src/browser/icons/preview-bright.svg +3 -3
  1130. package/src/browser/icons/preview-dark.svg +3 -3
  1131. package/src/browser/icons/regex-dark.svg +10 -10
  1132. package/src/browser/icons/regex.svg +10 -10
  1133. package/src/browser/icons/remove-all-inverse.svg +4 -4
  1134. package/src/browser/icons/remove-all.svg +4 -4
  1135. package/src/browser/icons/replace-all-inverse.svg +13 -13
  1136. package/src/browser/icons/replace-all.svg +13 -13
  1137. package/src/browser/icons/replace-inverse.svg +15 -15
  1138. package/src/browser/icons/replace.svg +15 -15
  1139. package/src/browser/icons/whole-word-dark.svg +19 -19
  1140. package/src/browser/icons/whole-word.svg +19 -19
  1141. package/src/browser/index.ts +47 -47
  1142. package/src/browser/json-schema-store.ts +127 -127
  1143. package/src/browser/keybinding.spec.ts +553 -553
  1144. package/src/browser/keybinding.ts +756 -756
  1145. package/src/browser/keyboard/browser-keyboard-frontend-contribution.ts +108 -108
  1146. package/src/browser/keyboard/browser-keyboard-layout-provider.spec.ts +171 -171
  1147. package/src/browser/keyboard/browser-keyboard-layout-provider.ts +469 -469
  1148. package/src/browser/keyboard/browser-keyboard-module.ts +30 -30
  1149. package/src/browser/keyboard/index.ts +20 -20
  1150. package/src/browser/keyboard/keyboard-layout-service.spec.ts +121 -121
  1151. package/src/browser/keyboard/keyboard-layout-service.ts +455 -455
  1152. package/src/browser/keyboard/keys.spec.ts +258 -258
  1153. package/src/browser/keyboard/keys.ts +20 -20
  1154. package/src/browser/keys.ts +21 -21
  1155. package/src/browser/label-parser.spec.ts +165 -165
  1156. package/src/browser/label-parser.ts +108 -108
  1157. package/src/browser/label-provider.spec.ts +62 -62
  1158. package/src/browser/label-provider.ts +385 -385
  1159. package/src/browser/language-icon-provider.ts +55 -55
  1160. package/src/browser/language-service.ts +77 -77
  1161. package/src/browser/logger-frontend-module.ts +65 -65
  1162. package/src/browser/markdown-rendering/markdown-renderer.ts +98 -98
  1163. package/src/browser/menu/browser-context-menu-renderer.ts +47 -47
  1164. package/src/browser/menu/browser-menu-module.ts +28 -28
  1165. package/src/browser/menu/browser-menu-plugin.ts +484 -484
  1166. package/src/browser/menu/context-menu-context.ts +41 -41
  1167. package/src/browser/messaging/connection-source.ts +26 -26
  1168. package/src/browser/messaging/frontend-id-provider.ts +37 -37
  1169. package/src/browser/messaging/index.ts +17 -17
  1170. package/src/browser/messaging/messaging-frontend-module.ts +41 -41
  1171. package/src/browser/messaging/service-connection-provider.ts +126 -126
  1172. package/src/browser/messaging/ws-connection-provider.ts +48 -48
  1173. package/src/browser/messaging/ws-connection-source.ts +230 -210
  1174. package/src/browser/mime-service.ts +30 -30
  1175. package/src/browser/navigatable-types.ts +81 -81
  1176. package/src/browser/navigatable.ts +39 -39
  1177. package/src/browser/opener-service.spec.ts +49 -49
  1178. package/src/browser/opener-service.ts +146 -146
  1179. package/src/browser/performance/frontend-stopwatch.ts +65 -65
  1180. package/src/browser/performance/index.ts +18 -18
  1181. package/src/browser/performance/measurement-frontend-bindings.ts +31 -31
  1182. package/src/browser/preferences/index.ts +23 -23
  1183. package/src/browser/preferences/injectable-preference-proxy.ts +283 -283
  1184. package/src/browser/preferences/preference-configurations.ts +82 -82
  1185. package/src/browser/preferences/preference-contribution.ts +436 -436
  1186. package/src/browser/preferences/preference-language-override-service.ts +111 -111
  1187. package/src/browser/preferences/preference-provider.spec.ts +36 -36
  1188. package/src/browser/preferences/preference-provider.ts +277 -277
  1189. package/src/browser/preferences/preference-proxy.spec.ts +367 -367
  1190. package/src/browser/preferences/preference-proxy.ts +367 -367
  1191. package/src/browser/preferences/preference-schema-provider.spec.ts +130 -130
  1192. package/src/browser/preferences/preference-scope.ts +18 -18
  1193. package/src/browser/preferences/preference-service.spec.ts +613 -613
  1194. package/src/browser/preferences/preference-service.ts +594 -594
  1195. package/src/browser/preferences/preference-validation-service.spec.ts +334 -334
  1196. package/src/browser/preferences/preference-validation-service.ts +358 -358
  1197. package/src/browser/preferences/test/index.ts +19 -19
  1198. package/src/browser/preferences/test/mock-preference-provider.ts +50 -50
  1199. package/src/browser/preferences/test/mock-preference-proxy.ts +48 -48
  1200. package/src/browser/preferences/test/mock-preference-service.ts +63 -63
  1201. package/src/browser/preload/i18n-preload-contribution.ts +50 -50
  1202. package/src/browser/preload/os-preload-contribution.ts +37 -37
  1203. package/src/browser/preload/preload-module.ts +45 -45
  1204. package/src/browser/preload/preloader.ts +37 -37
  1205. package/src/browser/preload/theme-preload-contribution.ts +31 -31
  1206. package/src/browser/progress-bar-factory.ts +29 -29
  1207. package/src/browser/progress-bar.ts +76 -76
  1208. package/src/browser/progress-client.ts +53 -53
  1209. package/src/browser/progress-location-service.spec.ts +50 -50
  1210. package/src/browser/progress-location-service.ts +96 -96
  1211. package/src/browser/progress-status-bar-item.ts +83 -83
  1212. package/src/browser/quick-input/index.ts +23 -23
  1213. package/src/browser/quick-input/quick-access.ts +75 -75
  1214. package/src/browser/quick-input/quick-command-frontend-contribution.ts +89 -89
  1215. package/src/browser/quick-input/quick-command-service.ts +246 -246
  1216. package/src/browser/quick-input/quick-help-service.ts +87 -87
  1217. package/src/browser/quick-input/quick-input-frontend-contribution.ts +33 -33
  1218. package/src/browser/quick-input/quick-input-service.spec.ts +176 -176
  1219. package/src/browser/quick-input/quick-input-service.ts +17 -17
  1220. package/src/browser/quick-input/quick-pick-service-impl.ts +69 -69
  1221. package/src/browser/quick-input/quick-view-service.ts +83 -83
  1222. package/src/browser/request/browser-request-module.ts +23 -23
  1223. package/src/browser/request/browser-request-service.ts +172 -172
  1224. package/src/browser/resource-context-key.ts +77 -77
  1225. package/src/browser/save-resource-service.ts +60 -59
  1226. package/src/browser/saveable.ts +365 -365
  1227. package/src/browser/secondary-window-handler.ts +212 -212
  1228. package/src/browser/shell/additional-views-menu-widget.tsx +71 -71
  1229. package/src/browser/shell/application-shell-mouse-tracker.ts +103 -103
  1230. package/src/browser/shell/application-shell.ts +2254 -2249
  1231. package/src/browser/shell/current-widget-command-adapter.ts +57 -57
  1232. package/src/browser/shell/index.ts +23 -23
  1233. package/src/browser/shell/shell-layout-restorer.ts +399 -399
  1234. package/src/browser/shell/side-panel-handler.ts +793 -793
  1235. package/src/browser/shell/side-panel-toolbar.ts +111 -111
  1236. package/src/browser/shell/sidebar-bottom-menu-widget.tsx +39 -39
  1237. package/src/browser/shell/sidebar-menu-widget.tsx +140 -140
  1238. package/src/browser/shell/sidebar-top-menu-widget.tsx +26 -26
  1239. package/src/browser/shell/split-panels.ts +190 -190
  1240. package/src/browser/shell/tab-bar-decorator.ts +106 -76
  1241. package/src/browser/shell/tab-bar-toolbar/index.ts +19 -19
  1242. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.ts +31 -31
  1243. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +256 -256
  1244. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.ts +207 -207
  1245. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.ts +62 -62
  1246. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +423 -423
  1247. package/src/browser/shell/tab-bars.spec.ts +63 -63
  1248. package/src/browser/shell/tab-bars.ts +1481 -1449
  1249. package/src/browser/shell/theia-dock-panel.ts +255 -255
  1250. package/src/browser/shell/view-contribution.ts +177 -177
  1251. package/src/browser/source-tree/index.ts +19 -19
  1252. package/src/browser/source-tree/source-tree-widget.tsx +107 -107
  1253. package/src/browser/source-tree/source-tree.ts +146 -146
  1254. package/src/browser/source-tree/tree-source.ts +73 -73
  1255. package/src/browser/status-bar/index.ts +29 -29
  1256. package/src/browser/status-bar/status-bar-types.ts +97 -97
  1257. package/src/browser/status-bar/status-bar-view-model.ts +209 -209
  1258. package/src/browser/status-bar/status-bar.tsx +189 -189
  1259. package/src/browser/storage-service.spec.ts +76 -76
  1260. package/src/browser/storage-service.ts +129 -129
  1261. package/src/browser/style/about.css +36 -36
  1262. package/src/browser/style/alert-messages.css +62 -62
  1263. package/src/browser/style/ansi.css +88 -88
  1264. package/src/browser/style/breadcrumbs.css +130 -130
  1265. package/src/browser/style/dialog.css +126 -126
  1266. package/src/browser/style/dockpanel.css +76 -76
  1267. package/src/browser/style/hover-service.css +101 -101
  1268. package/src/browser/style/icons.css +61 -61
  1269. package/src/browser/style/index.css +351 -346
  1270. package/src/browser/style/materialcolors.css +278 -278
  1271. package/src/browser/style/menus.css +230 -230
  1272. package/src/browser/style/notification.css +39 -39
  1273. package/src/browser/style/os.css +87 -87
  1274. package/src/browser/style/progress-bar.css +43 -43
  1275. package/src/browser/style/quick-title-bar.css +45 -45
  1276. package/src/browser/style/scrollbars.css +172 -172
  1277. package/src/browser/style/search-box.css +123 -123
  1278. package/src/browser/style/select-component.css +107 -108
  1279. package/src/browser/style/sidepanel.css +364 -364
  1280. package/src/browser/style/status-bar.css +127 -127
  1281. package/src/browser/style/tabs.css +647 -641
  1282. package/src/browser/style/tooltip.css +28 -28
  1283. package/src/browser/style/tree-decorators.css +81 -81
  1284. package/src/browser/style/tree.css +232 -232
  1285. package/src/browser/style/view-container.css +194 -194
  1286. package/src/browser/style/widget.css +19 -19
  1287. package/src/browser/styling-service.ts +87 -87
  1288. package/src/browser/supported-encodings.ts +262 -262
  1289. package/src/browser/test/jsdom.ts +69 -69
  1290. package/src/browser/test/mock-connection-status-service.ts +33 -33
  1291. package/src/browser/test/mock-env-variables-server.ts +47 -47
  1292. package/src/browser/test/mock-opener-service.ts +34 -34
  1293. package/src/browser/test/mock-storage-service.ts +49 -49
  1294. package/src/browser/theming.ts +206 -206
  1295. package/src/browser/tooltip-service.tsx +96 -96
  1296. package/src/browser/tree/fuzzy-search.spec.ts +99 -99
  1297. package/src/browser/tree/fuzzy-search.ts +136 -136
  1298. package/src/browser/tree/index.ts +29 -28
  1299. package/src/browser/tree/search-box-debounce.ts +96 -96
  1300. package/src/browser/tree/search-box.ts +355 -355
  1301. package/src/browser/tree/test/mock-selectable-tree-model.ts +109 -0
  1302. package/src/browser/tree/test/mock-tree-model.ts +136 -136
  1303. package/src/browser/tree/test/tree-test-container.ts +50 -50
  1304. package/src/browser/tree/tree-compression/compressed-tree-expansion-service.ts +46 -46
  1305. package/src/browser/tree/tree-compression/compressed-tree-model.ts +88 -88
  1306. package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +203 -203
  1307. package/src/browser/tree/tree-compression/index.ts +20 -20
  1308. package/src/browser/tree/tree-compression/tree-compression-service.ts +125 -125
  1309. package/src/browser/tree/tree-compression/tree-compression.css +28 -28
  1310. package/src/browser/tree/tree-consistency.spec.ts +105 -105
  1311. package/src/browser/tree/tree-container.spec.ts +45 -45
  1312. package/src/browser/tree/tree-container.ts +155 -155
  1313. package/src/browser/tree/tree-decorator.spec.ts +162 -162
  1314. package/src/browser/tree/tree-decorator.ts +238 -238
  1315. package/src/browser/tree/tree-expansion.spec.ts +173 -173
  1316. package/src/browser/tree/tree-expansion.ts +165 -165
  1317. package/src/browser/tree/tree-focus-service.ts +55 -55
  1318. package/src/browser/tree/tree-iterator.spec.ts +170 -170
  1319. package/src/browser/tree/tree-iterator.ts +256 -256
  1320. package/src/browser/tree/tree-label-provider.ts +40 -40
  1321. package/src/browser/tree/tree-model.ts +562 -488
  1322. package/src/browser/tree/tree-navigation.ts +58 -58
  1323. package/src/browser/tree/tree-preference.ts +50 -0
  1324. package/src/browser/tree/tree-search.ts +128 -128
  1325. package/src/browser/tree/tree-selectable.spec.ts +152 -0
  1326. package/src/browser/tree/tree-selection-impl.ts +176 -176
  1327. package/src/browser/tree/tree-selection-state.spec.ts +462 -462
  1328. package/src/browser/tree/tree-selection-state.ts +245 -245
  1329. package/src/browser/tree/tree-selection.ts +159 -159
  1330. package/src/browser/tree/tree-view-welcome-widget.tsx +263 -263
  1331. package/src/browser/tree/tree-widget-selection.ts +45 -45
  1332. package/src/browser/tree/tree-widget.tsx +1585 -1566
  1333. package/src/browser/tree/tree.spec.ts +241 -241
  1334. package/src/browser/tree/tree.ts +425 -424
  1335. package/src/browser/user-working-directory-provider.ts +77 -77
  1336. package/src/browser/view-container.ts +1640 -1640
  1337. package/src/browser/widget-decoration.ts +358 -358
  1338. package/src/browser/widget-manager.spec.ts +102 -102
  1339. package/src/browser/widget-manager.ts +310 -285
  1340. package/src/browser/widget-open-handler.ts +165 -165
  1341. package/src/browser/widgets/alert-message.tsx +56 -56
  1342. package/src/browser/widgets/enhanced-preview-widget.ts +27 -27
  1343. package/src/browser/widgets/extractable-widget.ts +33 -33
  1344. package/src/browser/widgets/index.ts +20 -20
  1345. package/src/browser/widgets/previewable-widget.ts +31 -31
  1346. package/src/browser/widgets/react-renderer.tsx +50 -50
  1347. package/src/browser/widgets/react-widget.tsx +51 -51
  1348. package/src/browser/widgets/select-component.tsx +367 -366
  1349. package/src/browser/widgets/widget.ts +406 -398
  1350. package/src/browser/window/browser-window-module.ts +32 -32
  1351. package/src/browser/window/default-secondary-window-service.ts +187 -187
  1352. package/src/browser/window/default-window-service.spec.ts +78 -78
  1353. package/src/browser/window/default-window-service.ts +167 -167
  1354. package/src/browser/window/secondary-window-service.ts +39 -39
  1355. package/src/browser/window/test/mock-window-service.ts +28 -28
  1356. package/src/browser/window/window-service.ts +68 -68
  1357. package/src/browser/window/window-title-service.ts +107 -107
  1358. package/src/browser/window/window-title-updater.ts +95 -95
  1359. package/src/browser/window-contribution.ts +64 -64
  1360. package/src/browser-only/frontend-only-application-module.ts +115 -0
  1361. package/src/browser-only/i18n/i18n-frontend-only-module.ts +37 -0
  1362. package/src/browser-only/logger-frontend-only-module.ts +63 -0
  1363. package/src/browser-only/messaging/frontend-only-service-connection-provider.ts +39 -0
  1364. package/src/browser-only/messaging/messaging-frontend-only-module.ts +42 -0
  1365. package/src/browser-only/preload/frontend-only-preload-module.ts +49 -0
  1366. package/src/common/accessibility.ts +33 -33
  1367. package/src/common/application-error.spec.ts +27 -27
  1368. package/src/common/application-error.ts +76 -76
  1369. package/src/common/application-protocol.ts +41 -40
  1370. package/src/common/array-utils.ts +129 -129
  1371. package/src/common/buffer.ts +228 -228
  1372. package/src/common/cancellation.ts +163 -163
  1373. package/src/common/char-code.ts +438 -438
  1374. package/src/common/collections.ts +125 -125
  1375. package/src/common/color.ts +103 -103
  1376. package/src/common/command.spec.ts +208 -208
  1377. package/src/common/command.ts +485 -485
  1378. package/src/common/contribution-filter/contribution-filter-registry.ts +79 -79
  1379. package/src/common/contribution-filter/contribution-filter.ts +64 -64
  1380. package/src/common/contribution-filter/filter.ts +23 -23
  1381. package/src/common/contribution-filter/index.ts +19 -19
  1382. package/src/common/contribution-provider.ts +96 -96
  1383. package/src/common/disposable.spec.ts +94 -29
  1384. package/src/common/disposable.ts +188 -135
  1385. package/src/common/encoding-service.ts +380 -380
  1386. package/src/common/encodings.ts +24 -24
  1387. package/src/common/env-variables/env-variables-protocol.ts +38 -38
  1388. package/src/common/env-variables/index.ts +17 -17
  1389. package/src/common/event.spec.ts +32 -32
  1390. package/src/common/event.ts +469 -469
  1391. package/src/{node → common}/file-uri.ts +61 -61
  1392. package/src/common/frontend-application-state.ts +38 -38
  1393. package/src/common/glob.ts +741 -741
  1394. package/src/common/hash.ts +85 -85
  1395. package/src/common/i18n/localization-server.ts +25 -25
  1396. package/src/common/i18n/localization.ts +80 -80
  1397. package/src/common/i18n/nls.metadata.json +31314 -31314
  1398. package/src/common/index.ts +51 -50
  1399. package/src/common/json-schema.ts +106 -106
  1400. package/src/common/key-store.ts +26 -26
  1401. package/src/common/keybinding.ts +152 -152
  1402. package/src/common/keyboard/keyboard-layout-provider.ts +51 -51
  1403. package/src/common/keys.ts +694 -694
  1404. package/src/common/label-protocol.ts +35 -35
  1405. package/src/common/logger-protocol.ts +119 -119
  1406. package/src/common/logger-watcher.ts +48 -48
  1407. package/src/common/logger.spec.ts +46 -46
  1408. package/src/common/logger.ts +389 -389
  1409. package/src/common/lsp-types.ts +34 -34
  1410. package/src/common/markdown-rendering/icon-utilities.ts +30 -30
  1411. package/src/common/markdown-rendering/index.ts +18 -18
  1412. package/src/common/markdown-rendering/markdown-string.ts +152 -149
  1413. package/src/common/menu/action-menu-node.ts +65 -65
  1414. package/src/common/menu/composite-menu-node.ts +114 -114
  1415. package/src/common/menu/index.ts +21 -21
  1416. package/src/common/menu/menu-adapter.ts +103 -103
  1417. package/src/common/menu/menu-model-registry.ts +343 -326
  1418. package/src/common/menu/menu-types.ts +219 -219
  1419. package/src/common/menu/menu.spec.ts +101 -73
  1420. package/src/common/message-rpc/channel.spec.ts +88 -88
  1421. package/src/common/message-rpc/channel.ts +300 -300
  1422. package/src/common/message-rpc/index.ts +22 -22
  1423. package/src/common/message-rpc/message-buffer.ts +105 -105
  1424. package/src/common/message-rpc/msg-pack-extension-manager.ts +70 -70
  1425. package/src/common/message-rpc/rpc-message-encoder.spec.ts +65 -65
  1426. package/src/common/message-rpc/rpc-message-encoder.ts +190 -190
  1427. package/src/common/message-rpc/rpc-protocol.ts +255 -235
  1428. package/src/common/message-rpc/uint8-array-message-buffer.spec.ts +41 -41
  1429. package/src/common/message-rpc/uint8-array-message-buffer.ts +213 -213
  1430. package/src/common/message-service-protocol.ts +148 -148
  1431. package/src/common/message-service.ts +226 -226
  1432. package/src/common/messaging/connection-error-handler.ts +73 -73
  1433. package/src/common/messaging/connection-management.ts +43 -43
  1434. package/src/common/messaging/handler.ts +26 -26
  1435. package/src/common/messaging/index.ts +19 -19
  1436. package/src/common/messaging/proxy-factory.spec.ts +108 -108
  1437. package/src/common/messaging/proxy-factory.ts +336 -343
  1438. package/src/common/messaging/socket-write-buffer.ts +52 -52
  1439. package/src/common/messaging/web-socket-channel.ts +76 -76
  1440. package/src/common/nls.ts +149 -149
  1441. package/src/common/numbers.ts +21 -21
  1442. package/src/common/objects.spec.ts +112 -112
  1443. package/src/common/objects.ts +123 -123
  1444. package/src/common/os.ts +82 -82
  1445. package/src/common/path.spec.ts +415 -415
  1446. package/src/common/path.ts +334 -334
  1447. package/src/common/paths.ts +250 -250
  1448. package/src/common/performance/index.ts +19 -19
  1449. package/src/common/performance/measurement-protocol.ts +104 -104
  1450. package/src/common/performance/measurement.ts +130 -130
  1451. package/src/common/performance/stopwatch.ts +183 -183
  1452. package/src/common/preferences/preference-schema.ts +95 -95
  1453. package/src/common/preferences/preference-scope.spec.ts +48 -48
  1454. package/src/common/preferences/preference-scope.ts +68 -68
  1455. package/src/common/prioritizeable.ts +58 -58
  1456. package/src/common/progress-service-protocol.ts +35 -35
  1457. package/src/common/progress-service.ts +82 -82
  1458. package/src/common/promise-util.spec.ts +72 -72
  1459. package/src/common/promise-util.ts +143 -143
  1460. package/src/common/quick-pick-service.ts +355 -377
  1461. package/src/common/reference.spec.ts +145 -145
  1462. package/src/common/reference.ts +230 -175
  1463. package/src/common/resource.ts +430 -426
  1464. package/src/common/selection-command-handler.ts +101 -101
  1465. package/src/common/selection-service.spec.ts +43 -43
  1466. package/src/common/selection-service.ts +49 -49
  1467. package/src/common/selection.ts +50 -50
  1468. package/src/common/severity.ts +111 -111
  1469. package/src/common/stream.ts +718 -718
  1470. package/src/common/strings.ts +231 -231
  1471. package/src/common/telemetry.ts +45 -45
  1472. package/src/common/ternary-search-tree.ts +417 -417
  1473. package/src/common/test/expect.ts +34 -34
  1474. package/src/common/test/mock-logger.ts +118 -118
  1475. package/src/common/test/mock-menu.ts +35 -35
  1476. package/src/common/test/mock-resource-provider.ts +33 -33
  1477. package/src/common/theme.ts +68 -36
  1478. package/src/common/types.spec.ts +86 -86
  1479. package/src/common/types.ts +140 -140
  1480. package/src/common/uri-command-handler.spec.ts +90 -90
  1481. package/src/common/uri-command-handler.ts +148 -148
  1482. package/src/common/uri.spec.ts +278 -278
  1483. package/src/common/uri.ts +279 -277
  1484. package/src/common/uuid.ts +45 -99
  1485. package/src/common/version.ts +17 -17
  1486. package/src/common/view-column.ts +33 -33
  1487. package/src/common/window.ts +34 -34
  1488. package/src/electron-browser/electron-clipboard-service.ts +32 -32
  1489. package/src/electron-browser/keyboard/electron-keyboard-layout-change-notifier.ts +39 -39
  1490. package/src/electron-browser/keyboard/electron-keyboard-module.ts +28 -28
  1491. package/src/electron-browser/menu/electron-context-menu-renderer.ts +120 -120
  1492. package/src/electron-browser/menu/electron-main-menu-factory.ts +335 -335
  1493. package/src/electron-browser/menu/electron-menu-contribution.ts +506 -498
  1494. package/src/electron-browser/menu/electron-menu-module.ts +40 -40
  1495. package/src/electron-browser/menu/electron-menu-style.css +110 -110
  1496. package/src/electron-browser/messaging/electron-frontend-id-provider.ts +25 -25
  1497. package/src/electron-browser/messaging/electron-ipc-connection-source.ts +65 -65
  1498. package/src/electron-browser/messaging/electron-local-ws-connection-source.ts +45 -45
  1499. package/src/electron-browser/messaging/electron-messaging-frontend-module.ts +78 -78
  1500. package/src/electron-browser/messaging/electron-ws-connection-source.ts +38 -38
  1501. package/src/electron-browser/preload.ts +246 -246
  1502. package/src/electron-browser/request/electron-browser-request-module.ts +26 -26
  1503. package/src/electron-browser/token/electron-token-frontend-module.ts +22 -22
  1504. package/src/electron-browser/window/electron-frontend-application-state.ts +26 -26
  1505. package/src/electron-browser/window/electron-secondary-window-service.ts +39 -39
  1506. package/src/electron-browser/window/electron-window-module.ts +41 -41
  1507. package/src/electron-browser/window/electron-window-preferences.ts +76 -76
  1508. package/src/electron-browser/window/electron-window-service.ts +97 -97
  1509. package/src/electron-common/electron-api.ts +148 -148
  1510. package/src/electron-common/electron-main-window-service.ts +24 -24
  1511. package/src/electron-common/electron-token.ts +27 -27
  1512. package/src/electron-main/electron-api-main.ts +333 -333
  1513. package/src/electron-main/electron-main-application-module.ts +65 -65
  1514. package/src/electron-main/electron-main-application.ts +685 -685
  1515. package/src/electron-main/electron-main-constants.ts +22 -22
  1516. package/src/electron-main/electron-main-window-service-impl.ts +44 -44
  1517. package/src/electron-main/electron-security-token-service.ts +36 -36
  1518. package/src/electron-main/event-utils.ts +36 -36
  1519. package/src/electron-main/messaging/electron-connection-handler.ts +21 -21
  1520. package/src/electron-main/messaging/electron-messaging-contribution.ts +143 -143
  1521. package/src/electron-main/messaging/electron-messaging-service.ts +35 -35
  1522. package/src/electron-main/theia-electron-window.ts +202 -202
  1523. package/src/electron-node/hosting/electron-backend-hosting-module.ts +24 -24
  1524. package/src/electron-node/hosting/electron-ws-origin-validator.ts +37 -37
  1525. package/src/electron-node/keyboard/electron-backend-keyboard-module.ts +30 -30
  1526. package/src/electron-node/keyboard/electron-keyboard-layout-provider.ts +35 -35
  1527. package/src/electron-node/request/electron-backend-request-module.ts +23 -23
  1528. package/src/electron-node/request/electron-backend-request-service.ts +78 -78
  1529. package/src/electron-node/token/electron-token-backend-contribution.ts +48 -48
  1530. package/src/electron-node/token/electron-token-backend-module.ts +28 -28
  1531. package/src/electron-node/token/electron-token-validator.ts +93 -93
  1532. package/src/node/application-server.ts +55 -48
  1533. package/src/node/backend-application-config-provider.spec.ts +29 -29
  1534. package/src/node/backend-application-config-provider.ts +48 -48
  1535. package/src/node/backend-application-module.ts +140 -140
  1536. package/src/node/backend-application.ts +382 -382
  1537. package/src/node/backend-remote-service.ts +25 -25
  1538. package/src/node/cli.spec.ts +94 -94
  1539. package/src/node/cli.ts +63 -63
  1540. package/src/node/console-logger-server.spec.ts +59 -59
  1541. package/src/node/console-logger-server.ts +76 -76
  1542. package/src/node/debug.ts +30 -30
  1543. package/src/node/dynamic-require.ts +56 -56
  1544. package/src/node/env-variables/env-variables-server.ts +120 -120
  1545. package/src/node/env-variables/index.ts +17 -17
  1546. package/src/node/environment-utils.spec.ts +92 -92
  1547. package/src/node/environment-utils.ts +66 -66
  1548. package/src/node/file-uri.spec.ts +76 -76
  1549. package/src/node/filesystem-locking.ts +77 -77
  1550. package/src/node/hosting/backend-application-hosts.ts +60 -60
  1551. package/src/node/hosting/backend-hosting-module.ts +26 -26
  1552. package/src/node/hosting/ws-origin-validator.ts +36 -36
  1553. package/src/node/i18n/i18n-backend-module.ts +42 -42
  1554. package/src/node/i18n/localization-contribution.ts +112 -112
  1555. package/src/node/i18n/localization-provider.ts +125 -125
  1556. package/src/node/i18n/localization-server.ts +52 -52
  1557. package/src/node/i18n/theia-localization-contribution.ts +36 -36
  1558. package/src/node/index.ts +22 -22
  1559. package/src/node/key-store-server.ts +162 -162
  1560. package/src/node/logger-backend-module.ts +88 -88
  1561. package/src/node/logger-cli-contribution.spec.ts +245 -245
  1562. package/src/node/logger-cli-contribution.ts +168 -168
  1563. package/src/node/main.ts +33 -33
  1564. package/src/node/messaging/binary-message-pipe.ts +168 -168
  1565. package/src/node/messaging/connection-container-module.ts +96 -96
  1566. package/src/node/messaging/default-messaging-service.ts +129 -129
  1567. package/src/node/messaging/frontend-connection-service.ts +24 -24
  1568. package/src/node/messaging/index.ts +19 -19
  1569. package/src/node/messaging/ipc-bootstrap.ts +27 -27
  1570. package/src/node/messaging/ipc-channel.ts +77 -77
  1571. package/src/node/messaging/ipc-connection-provider.ts +107 -107
  1572. package/src/node/messaging/ipc-protocol.ts +76 -76
  1573. package/src/node/messaging/messaging-backend-module.ts +52 -52
  1574. package/src/node/messaging/messaging-listeners.ts +52 -52
  1575. package/src/node/messaging/messaging-service.ts +46 -46
  1576. package/src/node/messaging/test/test-web-socket-channel.ts +61 -61
  1577. package/src/node/messaging/websocket-endpoint.ts +79 -79
  1578. package/src/node/messaging/websocket-frontend-connection-service.ts +176 -171
  1579. package/src/node/os-backend-provider.ts +25 -25
  1580. package/src/node/performance/index.ts +18 -18
  1581. package/src/node/performance/measurement-backend-bindings.ts +35 -35
  1582. package/src/node/performance/node-stopwatch.ts +40 -40
  1583. package/src/node/process-utils.spec.ts +48 -48
  1584. package/src/node/process-utils.ts +102 -102
  1585. package/src/node/request/backend-request-facade.ts +39 -39
  1586. package/src/node/request/backend-request-module.ts +25 -25
  1587. package/src/node/request/proxy-cli-contribution.ts +65 -65
  1588. package/src/node/ws-request-validators.ts +56 -56
  1589. package/src/typings/native-keymap.d.ts +108 -108
  1590. package/lib/node/file-uri.d.ts.map +0 -1
  1591. package/lib/node/file-uri.js.map +0 -1
@@ -1,2249 +1,2254 @@
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 { injectable, inject, optional, postConstruct } from 'inversify';
18
- import { ArrayExt, find, toArray, each } from '@phosphor/algorithm';
19
- import {
20
- BoxLayout, BoxPanel, DockLayout, DockPanel, FocusTracker, Layout, Panel, SplitLayout,
21
- SplitPanel, TabBar, Widget, Title
22
- } from '@phosphor/widgets';
23
- import { Message } from '@phosphor/messaging';
24
- import { IDragEvent } from '@phosphor/dragdrop';
25
- import { RecursivePartial, Event as CommonEvent, DisposableCollection, Disposable, environment, isObject } from '../../common';
26
- import { animationFrame } from '../browser';
27
- import { Saveable, SaveableWidget, SaveOptions, SaveableSource } from '../saveable';
28
- import { StatusBarImpl, StatusBarEntry, StatusBarAlignment } from '../status-bar/status-bar';
29
- import { TheiaDockPanel, BOTTOM_AREA_ID, MAIN_AREA_ID } from './theia-dock-panel';
30
- import { SidePanelHandler, SidePanel, SidePanelHandlerFactory } from './side-panel-handler';
31
- import { TabBarRendererFactory, SHELL_TABBAR_CONTEXT_MENU, ScrollableTabBar, ToolbarAwareTabBar } from './tab-bars';
32
- import { SplitPositionHandler, SplitPositionOptions } from './split-panels';
33
- import { FrontendApplicationStateService } from '../frontend-application-state';
34
- import { TabBarToolbarRegistry, TabBarToolbarFactory } from './tab-bar-toolbar';
35
- import { ContextKeyService } from '../context-key-service';
36
- import { Emitter } from '../../common/event';
37
- import { waitForRevealed, waitForClosed, PINNED_CLASS } from '../widgets';
38
- import { CorePreferences } from '../core-preferences';
39
- import { BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer';
40
- import { Deferred } from '../../common/promise-util';
41
- import { SaveResourceService } from '../save-resource-service';
42
- import { nls } from '../../common/nls';
43
- import { SecondaryWindowHandler } from '../secondary-window-handler';
44
- import URI from '../../common/uri';
45
- import { OpenerService } from '../opener-service';
46
- import { PreviewableWidget } from '../widgets/previewable-widget';
47
-
48
- /** The class name added to ApplicationShell instances. */
49
- const APPLICATION_SHELL_CLASS = 'theia-ApplicationShell';
50
- /** The class name added to the main and bottom area panels. */
51
- const MAIN_BOTTOM_AREA_CLASS = 'theia-app-centers';
52
- /** Status bar entry identifier for the bottom panel toggle button. */
53
- const BOTTOM_PANEL_TOGGLE_ID = 'bottom-panel-toggle';
54
- /** The class name added to the main area panel. */
55
- const MAIN_AREA_CLASS = 'theia-app-main';
56
- /** The class name added to the bottom area panel. */
57
- const BOTTOM_AREA_CLASS = 'theia-app-bottom';
58
-
59
- export type ApplicationShellLayoutVersion =
60
- /** layout versioning is introduced, unversioned layout are not compatible */
61
- 2.0 |
62
- /** view containers are introduced, backward compatible to 2.0 */
63
- 3.0 |
64
- /** git history view is replaced by a more generic scm history view, backward compatible to 3.0 */
65
- 4.0 |
66
- /** Replace custom/font-awesome icons with codicons */
67
- 5.0 |
68
- /** added the ability to drag and drop view parts between view containers */
69
- 6.0;
70
-
71
- /**
72
- * When a version is increased, make sure to introduce a migration (ApplicationShellLayoutMigration) to this version.
73
- */
74
- export const applicationShellLayoutVersion: ApplicationShellLayoutVersion = 5.0;
75
-
76
- export const ApplicationShellOptions = Symbol('ApplicationShellOptions');
77
- export const DockPanelRendererFactory = Symbol('DockPanelRendererFactory');
78
- export interface DockPanelRendererFactory {
79
- (): DockPanelRenderer
80
- }
81
-
82
- /**
83
- * A renderer for dock panels that supports context menus on tabs.
84
- */
85
- @injectable()
86
- export class DockPanelRenderer implements DockLayout.IRenderer {
87
-
88
- @inject(TheiaDockPanel.Factory)
89
- protected readonly dockPanelFactory: TheiaDockPanel.Factory;
90
-
91
- readonly tabBarClasses: string[] = [];
92
-
93
- private readonly onDidCreateTabBarEmitter = new Emitter<TabBar<Widget>>();
94
-
95
- constructor(
96
- @inject(TabBarRendererFactory) protected readonly tabBarRendererFactory: TabBarRendererFactory,
97
- @inject(TabBarToolbarRegistry) protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry,
98
- @inject(TabBarToolbarFactory) protected readonly tabBarToolbarFactory: TabBarToolbarFactory,
99
- @inject(BreadcrumbsRendererFactory) protected readonly breadcrumbsRendererFactory: BreadcrumbsRendererFactory,
100
- @inject(CorePreferences) protected readonly corePreferences: CorePreferences
101
- ) { }
102
-
103
- get onDidCreateTabBar(): CommonEvent<TabBar<Widget>> {
104
- return this.onDidCreateTabBarEmitter.event;
105
- }
106
-
107
- createTabBar(): TabBar<Widget> {
108
- const getDynamicTabOptions: () => ScrollableTabBar.Options | undefined = () => {
109
- if (this.corePreferences.get('workbench.tab.shrinkToFit.enabled')) {
110
- return {
111
- minimumTabSize: this.corePreferences.get('workbench.tab.shrinkToFit.minimumSize'),
112
- defaultTabSize: this.corePreferences.get('workbench.tab.shrinkToFit.defaultSize')
113
- };
114
- } else {
115
- return undefined;
116
- }
117
- };
118
-
119
- const renderer = this.tabBarRendererFactory();
120
- const tabBar = new ToolbarAwareTabBar(
121
- this.tabBarToolbarRegistry,
122
- this.tabBarToolbarFactory,
123
- this.breadcrumbsRendererFactory,
124
- {
125
- renderer,
126
- // Scroll bar options
127
- handlers: ['drag-thumb', 'keyboard', 'wheel', 'touch'],
128
- useBothWheelAxes: true,
129
- scrollXMarginOffset: 4,
130
- suppressScrollY: true
131
- },
132
- getDynamicTabOptions());
133
- this.tabBarClasses.forEach(c => tabBar.addClass(c));
134
- renderer.tabBar = tabBar;
135
- tabBar.disposed.connect(() => renderer.dispose());
136
- renderer.contextMenuPath = SHELL_TABBAR_CONTEXT_MENU;
137
- tabBar.currentChanged.connect(this.onCurrentTabChanged, this);
138
- this.corePreferences.onPreferenceChanged(change => {
139
- if (change.preferenceName === 'workbench.tab.shrinkToFit.enabled' ||
140
- change.preferenceName === 'workbench.tab.shrinkToFit.minimumSize' ||
141
- change.preferenceName === 'workbench.tab.shrinkToFit.defaultSize') {
142
- tabBar.dynamicTabOptions = getDynamicTabOptions();
143
- }
144
- });
145
- this.onDidCreateTabBarEmitter.fire(tabBar);
146
- return tabBar;
147
- }
148
-
149
- createHandle(): HTMLDivElement {
150
- return DockPanel.defaultRenderer.createHandle();
151
- }
152
-
153
- protected onCurrentTabChanged(sender: ToolbarAwareTabBar, { currentIndex }: TabBar.ICurrentChangedArgs<Widget>): void {
154
- if (currentIndex >= 0) {
155
- sender.revealTab(currentIndex);
156
- }
157
- }
158
- }
159
-
160
- /**
161
- * Data stored while dragging widgets in the shell.
162
- */
163
- interface WidgetDragState {
164
- startTime: number;
165
- leftExpanded: boolean;
166
- rightExpanded: boolean;
167
- bottomExpanded: boolean;
168
- lastDragOver?: IDragEvent;
169
- leaveTimeout?: number;
170
- }
171
-
172
- /**
173
- * The application shell manages the top-level widgets of the application. Use this class to
174
- * add, remove, or activate a widget.
175
- */
176
- @injectable()
177
- export class ApplicationShell extends Widget {
178
-
179
- /**
180
- * The dock panel in the main shell area. This is where editors usually go to.
181
- */
182
- mainPanel: TheiaDockPanel;
183
-
184
- /**
185
- * The dock panel in the bottom shell area. In contrast to the main panel, the bottom panel
186
- * can be collapsed and expanded.
187
- */
188
- bottomPanel: TheiaDockPanel;
189
-
190
- /**
191
- * Handler for the left side panel. The primary application views go here, such as the
192
- * file explorer and the git view.
193
- */
194
- leftPanelHandler: SidePanelHandler;
195
-
196
- /**
197
- * Handler for the right side panel. The secondary application views go here, such as the
198
- * outline view.
199
- */
200
- rightPanelHandler: SidePanelHandler;
201
-
202
- /**
203
- * General options for the application shell.
204
- */
205
- protected options: ApplicationShell.Options;
206
-
207
- /**
208
- * The fixed-size panel shown on top. This one usually holds the main menu.
209
- */
210
- topPanel: Panel;
211
-
212
- /**
213
- * The current state of the bottom panel.
214
- */
215
- protected readonly bottomPanelState: SidePanel.State = {
216
- empty: true,
217
- expansion: SidePanel.ExpansionState.collapsed,
218
- pendingUpdate: Promise.resolve()
219
- };
220
-
221
- private readonly tracker = new FocusTracker<Widget>();
222
- private dragState?: WidgetDragState;
223
- additionalDraggedUris: URI[] | undefined;
224
-
225
- @inject(ContextKeyService)
226
- protected readonly contextKeyService: ContextKeyService;
227
-
228
- @inject(OpenerService)
229
- protected readonly openerService: OpenerService;
230
-
231
- protected readonly onDidAddWidgetEmitter = new Emitter<Widget>();
232
- readonly onDidAddWidget = this.onDidAddWidgetEmitter.event;
233
- protected fireDidAddWidget(widget: Widget): void {
234
- this.onDidAddWidgetEmitter.fire(widget);
235
- }
236
-
237
- protected readonly onDidRemoveWidgetEmitter = new Emitter<Widget>();
238
- readonly onDidRemoveWidget = this.onDidRemoveWidgetEmitter.event;
239
- protected fireDidRemoveWidget(widget: Widget): void {
240
- this.onDidRemoveWidgetEmitter.fire(widget);
241
- }
242
-
243
- protected readonly onDidChangeActiveWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
244
- readonly onDidChangeActiveWidget = this.onDidChangeActiveWidgetEmitter.event;
245
-
246
- protected readonly onDidChangeCurrentWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
247
- readonly onDidChangeCurrentWidget = this.onDidChangeCurrentWidgetEmitter.event;
248
-
249
- protected readonly onDidDoubleClickMainAreaEmitter = new Emitter<void>();
250
- readonly onDidDoubleClickMainArea = this.onDidDoubleClickMainAreaEmitter.event;
251
-
252
- @inject(TheiaDockPanel.Factory)
253
- protected readonly dockPanelFactory: TheiaDockPanel.Factory;
254
-
255
- private _mainPanelRenderer: DockPanelRenderer;
256
- get mainPanelRenderer(): DockPanelRenderer {
257
- return this._mainPanelRenderer;
258
- }
259
-
260
- /**
261
- * Construct a new application shell.
262
- */
263
- constructor(
264
- @inject(DockPanelRendererFactory) protected dockPanelRendererFactory: () => DockPanelRenderer,
265
- @inject(StatusBarImpl) protected readonly statusBar: StatusBarImpl,
266
- @inject(SidePanelHandlerFactory) protected readonly sidePanelHandlerFactory: () => SidePanelHandler,
267
- @inject(SplitPositionHandler) protected splitPositionHandler: SplitPositionHandler,
268
- @inject(FrontendApplicationStateService) protected readonly applicationStateService: FrontendApplicationStateService,
269
- @inject(ApplicationShellOptions) @optional() options: RecursivePartial<ApplicationShell.Options> = {},
270
- @inject(CorePreferences) protected readonly corePreferences: CorePreferences,
271
- @inject(SaveResourceService) protected readonly saveResourceService: SaveResourceService,
272
- @inject(SecondaryWindowHandler) protected readonly secondaryWindowHandler: SecondaryWindowHandler,
273
- ) {
274
- super(options as Widget.IOptions);
275
-
276
- // Merge the user-defined application options with the default options
277
- this.options = {
278
- bottomPanel: {
279
- ...ApplicationShell.DEFAULT_OPTIONS.bottomPanel,
280
- ...options?.bottomPanel || {}
281
- },
282
- leftPanel: {
283
- ...ApplicationShell.DEFAULT_OPTIONS.leftPanel,
284
- ...options?.leftPanel || {}
285
- },
286
- rightPanel: {
287
- ...ApplicationShell.DEFAULT_OPTIONS.rightPanel,
288
- ...options?.rightPanel || {}
289
- }
290
- };
291
- }
292
-
293
- @postConstruct()
294
- protected init(): void {
295
- this.initializeShell();
296
- this.initSidebarVisibleKeyContext();
297
- this.initFocusKeyContexts();
298
-
299
- if (!environment.electron.is()) {
300
- this.corePreferences.ready.then(() => {
301
- this.setTopPanelVisibility(this.corePreferences['window.menuBarVisibility']);
302
- });
303
- this.corePreferences.onPreferenceChanged(preference => {
304
- if (preference.preferenceName === 'window.menuBarVisibility') {
305
- this.setTopPanelVisibility(preference.newValue);
306
- }
307
- });
308
- }
309
-
310
- this.corePreferences.onPreferenceChanged(preference => {
311
- if (preference.preferenceName === 'window.tabbar.enhancedPreview') {
312
- this.allTabBars.forEach(tabBar => {
313
- tabBar.update();
314
- });
315
- }
316
- });
317
- }
318
-
319
- protected initializeShell(): void {
320
- this.addClass(APPLICATION_SHELL_CLASS);
321
- this.id = 'theia-app-shell';
322
-
323
- this.mainPanel = this.createMainPanel();
324
- this.topPanel = this.createTopPanel();
325
- this.bottomPanel = this.createBottomPanel();
326
-
327
- this.leftPanelHandler = this.sidePanelHandlerFactory();
328
- this.leftPanelHandler.create('left', this.options.leftPanel);
329
- this.leftPanelHandler.dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
330
- this.leftPanelHandler.dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
331
-
332
- this.rightPanelHandler = this.sidePanelHandlerFactory();
333
- this.rightPanelHandler.create('right', this.options.rightPanel);
334
- this.rightPanelHandler.dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
335
- this.rightPanelHandler.dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
336
-
337
- this.secondaryWindowHandler.init(this);
338
- this.secondaryWindowHandler.onDidAddWidget(widget => this.fireDidAddWidget(widget));
339
- this.secondaryWindowHandler.onDidRemoveWidget(widget => this.fireDidRemoveWidget(widget));
340
-
341
- this.layout = this.createLayout();
342
-
343
- this.tracker.currentChanged.connect(this.onCurrentChanged, this);
344
- this.tracker.activeChanged.connect(this.onActiveChanged, this);
345
- }
346
-
347
- protected initSidebarVisibleKeyContext(): void {
348
- const leftSideBarPanel = this.leftPanelHandler.dockPanel;
349
- const sidebarVisibleKey = this.contextKeyService.createKey('sidebarVisible', leftSideBarPanel.isVisible);
350
- const onAfterShow = leftSideBarPanel['onAfterShow'].bind(leftSideBarPanel);
351
- leftSideBarPanel['onAfterShow'] = (msg: Message) => {
352
- onAfterShow(msg);
353
- sidebarVisibleKey.set(true);
354
- };
355
- const onAfterHide = leftSideBarPanel['onAfterHide'].bind(leftSideBarPanel);
356
- leftSideBarPanel['onAfterHide'] = (msg: Message) => {
357
- onAfterHide(msg);
358
- sidebarVisibleKey.set(false);
359
- };
360
- }
361
-
362
- protected initFocusKeyContexts(): void {
363
- const sideBarFocus = this.contextKeyService.createKey<boolean>('sideBarFocus', false);
364
- const panelFocus = this.contextKeyService.createKey<boolean>('panelFocus', false);
365
- const updateFocusContextKeys = () => {
366
- const area = this.activeWidget && this.getAreaFor(this.activeWidget);
367
- sideBarFocus.set(area === 'left');
368
- panelFocus.set(area === 'main');
369
- };
370
- updateFocusContextKeys();
371
- this.onDidChangeActiveWidget(updateFocusContextKeys);
372
- }
373
-
374
- protected setTopPanelVisibility(preference: string): void {
375
- const hiddenPreferences = ['compact', 'hidden'];
376
- this.topPanel.setHidden(hiddenPreferences.includes(preference));
377
- }
378
-
379
- protected override onBeforeAttach(msg: Message): void {
380
- document.addEventListener('p-dragenter', this, true);
381
- document.addEventListener('p-dragover', this, true);
382
- document.addEventListener('p-dragleave', this, true);
383
- document.addEventListener('p-drop', this, true);
384
- }
385
-
386
- protected override onAfterDetach(msg: Message): void {
387
- document.removeEventListener('p-dragenter', this, true);
388
- document.removeEventListener('p-dragover', this, true);
389
- document.removeEventListener('p-dragleave', this, true);
390
- document.removeEventListener('p-drop', this, true);
391
- }
392
-
393
- handleEvent(event: Event): void {
394
- switch (event.type) {
395
- case 'p-dragenter':
396
- this.onDragEnter(event as IDragEvent);
397
- break;
398
- case 'p-dragover':
399
- this.onDragOver(event as IDragEvent);
400
- break;
401
- case 'p-drop':
402
- this.onDrop(event as IDragEvent);
403
- break;
404
- case 'p-dragleave':
405
- this.onDragLeave(event as IDragEvent);
406
- break;
407
- }
408
- }
409
-
410
- protected onDragEnter({ mimeData }: IDragEvent): void {
411
- if (!this.dragState) {
412
- if (mimeData && mimeData.hasData('application/vnd.phosphor.widget-factory')) {
413
- // The drag contains a widget, so we'll track it and expand side panels as needed
414
- this.dragState = {
415
- startTime: performance.now(),
416
- leftExpanded: false,
417
- rightExpanded: false,
418
- bottomExpanded: false
419
- };
420
- }
421
- }
422
- }
423
-
424
- protected onDragOver(event: IDragEvent): void {
425
- const state = this.dragState;
426
- if (state) {
427
- state.lastDragOver = event;
428
- if (state.leaveTimeout) {
429
- window.clearTimeout(state.leaveTimeout);
430
- state.leaveTimeout = undefined;
431
- }
432
- const { clientX, clientY } = event;
433
- const { offsetLeft, offsetTop, clientWidth, clientHeight } = this.node;
434
-
435
- // Don't expand any side panels right after the drag has started
436
- const allowExpansion = performance.now() - state.startTime >= 500;
437
- const expLeft = allowExpansion && clientX >= offsetLeft
438
- && clientX <= offsetLeft + this.options.leftPanel.expandThreshold;
439
- const expRight = allowExpansion && clientX <= offsetLeft + clientWidth
440
- && clientX >= offsetLeft + clientWidth - this.options.rightPanel.expandThreshold;
441
- const expBottom = allowExpansion && !expLeft && !expRight && clientY <= offsetTop + clientHeight
442
- && clientY >= offsetTop + clientHeight - this.options.bottomPanel.expandThreshold;
443
- // eslint-disable-next-line no-null/no-null
444
- if (expLeft && !state.leftExpanded && this.leftPanelHandler.tabBar.currentTitle === null) {
445
- // The mouse cursor is moved close to the left border
446
- this.leftPanelHandler.expand();
447
- this.leftPanelHandler.state.pendingUpdate.then(() => this.dispatchMouseMove());
448
- state.leftExpanded = true;
449
- } else if (!expLeft && state.leftExpanded) {
450
- // The mouse cursor is moved away from the left border
451
- this.leftPanelHandler.collapse();
452
- state.leftExpanded = false;
453
- }
454
- // eslint-disable-next-line no-null/no-null
455
- if (expRight && !state.rightExpanded && this.rightPanelHandler.tabBar.currentTitle === null) {
456
- // The mouse cursor is moved close to the right border
457
- this.rightPanelHandler.expand();
458
- this.rightPanelHandler.state.pendingUpdate.then(() => this.dispatchMouseMove());
459
- state.rightExpanded = true;
460
- } else if (!expRight && state.rightExpanded) {
461
- // The mouse cursor is moved away from the right border
462
- this.rightPanelHandler.collapse();
463
- state.rightExpanded = false;
464
- }
465
- if (expBottom && !state.bottomExpanded && this.bottomPanel.isHidden) {
466
- // The mouse cursor is moved close to the bottom border
467
- this.expandBottomPanel();
468
- this.bottomPanelState.pendingUpdate.then(() => this.dispatchMouseMove());
469
- state.bottomExpanded = true;
470
- } else if (!expBottom && state.bottomExpanded) {
471
- // The mouse cursor is moved away from the bottom border
472
- this.collapseBottomPanel();
473
- state.bottomExpanded = false;
474
- }
475
- }
476
- }
477
-
478
- /**
479
- * This method is called after a side panel has been expanded while dragging a widget. It fires
480
- * a `mousemove` event so that the drag overlay markers are updated correctly in all dock panels.
481
- */
482
- private dispatchMouseMove(): void {
483
- if (this.dragState && this.dragState.lastDragOver) {
484
- const { clientX, clientY } = this.dragState.lastDragOver;
485
- const event = document.createEvent('MouseEvent');
486
- event.initMouseEvent('mousemove', true, true, window, 0, 0, 0,
487
- // eslint-disable-next-line no-null/no-null
488
- clientX, clientY, false, false, false, false, 0, null);
489
- document.dispatchEvent(event);
490
- }
491
- }
492
-
493
- protected onDrop(event: IDragEvent): void {
494
- const state = this.dragState;
495
- if (state) {
496
- if (state.leaveTimeout) {
497
- window.clearTimeout(state.leaveTimeout);
498
- }
499
- this.dragState = undefined;
500
- window.requestAnimationFrame(() => {
501
- // Clean up the side panel state in the next frame
502
- if (this.leftPanelHandler.dockPanel.isEmpty) {
503
- this.leftPanelHandler.collapse();
504
- }
505
- if (this.rightPanelHandler.dockPanel.isEmpty) {
506
- this.rightPanelHandler.collapse();
507
- }
508
- if (this.bottomPanel.isEmpty) {
509
- this.collapseBottomPanel();
510
- }
511
- });
512
- }
513
- }
514
-
515
- protected onDragLeave(event: IDragEvent): void {
516
- const state = this.dragState;
517
- if (state) {
518
- state.lastDragOver = undefined;
519
- if (state.leaveTimeout) {
520
- window.clearTimeout(state.leaveTimeout);
521
- }
522
- state.leaveTimeout = window.setTimeout(() => {
523
- this.dragState = undefined;
524
- if (state.leftExpanded || this.leftPanelHandler.dockPanel.isEmpty) {
525
- this.leftPanelHandler.collapse();
526
- }
527
- if (state.rightExpanded || this.rightPanelHandler.dockPanel.isEmpty) {
528
- this.rightPanelHandler.collapse();
529
- }
530
- if (state.bottomExpanded || this.bottomPanel.isEmpty) {
531
- this.collapseBottomPanel();
532
- }
533
- }, 100);
534
- }
535
- }
536
-
537
- /**
538
- * Create the dock panel in the main shell area.
539
- */
540
- protected createMainPanel(): TheiaDockPanel {
541
- const renderer = this.dockPanelRendererFactory();
542
- renderer.tabBarClasses.push(MAIN_BOTTOM_AREA_CLASS);
543
- renderer.tabBarClasses.push(MAIN_AREA_CLASS);
544
- this._mainPanelRenderer = renderer;
545
- const dockPanel = this.dockPanelFactory({
546
- mode: 'multiple-document',
547
- renderer,
548
- spacing: 0
549
- });
550
- dockPanel.id = MAIN_AREA_ID;
551
- dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
552
- dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
553
-
554
- const openUri = async (fileUri: URI) => {
555
- try {
556
- const opener = await this.openerService.getOpener(fileUri);
557
- opener.open(fileUri);
558
- } catch (e) {
559
- console.info(`no opener found for '${fileUri}'`);
560
- }
561
- };
562
-
563
- dockPanel.node.addEventListener('drop', event => {
564
- if (event.dataTransfer) {
565
- const uris = this.additionalDraggedUris || ApplicationShell.getDraggedEditorUris(event.dataTransfer);
566
- if (uris.length > 0) {
567
- uris.forEach(openUri);
568
- } else if (event.dataTransfer.files?.length > 0) {
569
- // the files were dragged from the outside the workspace
570
- Array.from(event.dataTransfer.files).forEach(file => {
571
- if (file.path) {
572
- const fileUri = URI.fromComponents({
573
- scheme: 'file',
574
- path: file.path,
575
- authority: '',
576
- query: '',
577
- fragment: ''
578
- });
579
- openUri(fileUri);
580
- }
581
- });
582
- }
583
- }
584
- });
585
-
586
- dockPanel.node.addEventListener('dblclick', event => {
587
- const el = event.target as Element;
588
- if (el.id === MAIN_AREA_ID || el.classList.contains('p-TabBar-content')) {
589
- this.onDidDoubleClickMainAreaEmitter.fire();
590
- }
591
- });
592
-
593
- const handler = (e: DragEvent) => {
594
- if (e.dataTransfer) {
595
- e.dataTransfer.dropEffect = 'link';
596
- e.preventDefault();
597
- e.stopPropagation();
598
- }
599
- };
600
- dockPanel.node.addEventListener('dragover', handler);
601
- dockPanel.node.addEventListener('dragenter', handler);
602
-
603
- return dockPanel;
604
- }
605
-
606
- addAdditionalDraggedEditorUris(uris: URI[]): void {
607
- this.additionalDraggedUris = uris;
608
- }
609
-
610
- clearAdditionalDraggedEditorUris(): void {
611
- this.additionalDraggedUris = undefined;
612
- }
613
-
614
- protected static getDraggedEditorUris(dataTransfer: DataTransfer): URI[] {
615
- const data = dataTransfer.getData('theia-editor-dnd');
616
- return data ? data.split('\n').map(entry => new URI(entry)) : [];
617
- }
618
-
619
- static setDraggedEditorUris(dataTransfer: DataTransfer, uris: URI[]): void {
620
- dataTransfer.setData('theia-editor-dnd', uris.map(uri => uri.toString()).join('\n'));
621
- }
622
-
623
- /**
624
- * Create the dock panel in the bottom shell area.
625
- */
626
- protected createBottomPanel(): TheiaDockPanel {
627
- const renderer = this.dockPanelRendererFactory();
628
- renderer.tabBarClasses.push(MAIN_BOTTOM_AREA_CLASS);
629
- renderer.tabBarClasses.push(BOTTOM_AREA_CLASS);
630
- const dockPanel = this.dockPanelFactory({
631
- mode: 'multiple-document',
632
- renderer,
633
- spacing: 0
634
- });
635
- dockPanel.id = BOTTOM_AREA_ID;
636
- dockPanel.widgetAdded.connect((sender, widget) => {
637
- this.refreshBottomPanelToggleButton();
638
- });
639
- dockPanel.widgetRemoved.connect((sender, widget) => {
640
- if (sender.isEmpty) {
641
- this.collapseBottomPanel();
642
- }
643
- this.refreshBottomPanelToggleButton();
644
- }, this);
645
- dockPanel.node.addEventListener('p-dragenter', event => {
646
- // Make sure that the main panel hides its overlay when the bottom panel is expanded
647
- this.mainPanel.overlay.hide(0);
648
- });
649
- dockPanel.hide();
650
- dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
651
- dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
652
- return dockPanel;
653
- }
654
-
655
- /**
656
- * Create the top panel, which is used to hold the main menu.
657
- */
658
- protected createTopPanel(): Panel {
659
- const topPanel = new Panel();
660
- topPanel.id = 'theia-top-panel';
661
- topPanel.hide();
662
- return topPanel;
663
- }
664
-
665
- /**
666
- * Create a box layout to assemble the application shell layout.
667
- */
668
- protected createBoxLayout(widgets: Widget[], stretch?: number[], options?: BoxPanel.IOptions): BoxLayout {
669
- const boxLayout = new BoxLayout(options);
670
- for (let i = 0; i < widgets.length; i++) {
671
- if (stretch !== undefined && i < stretch.length) {
672
- BoxPanel.setStretch(widgets[i], stretch[i]);
673
- }
674
- boxLayout.addWidget(widgets[i]);
675
- }
676
- return boxLayout;
677
- }
678
-
679
- /**
680
- * Create a split layout to assemble the application shell layout.
681
- */
682
- protected createSplitLayout(widgets: Widget[], stretch?: number[], options?: Partial<SplitLayout.IOptions>): SplitLayout {
683
- let optParam: SplitLayout.IOptions = { renderer: SplitPanel.defaultRenderer, };
684
- if (options) {
685
- optParam = { ...optParam, ...options };
686
- }
687
- const splitLayout = new SplitLayout(optParam);
688
- for (let i = 0; i < widgets.length; i++) {
689
- if (stretch !== undefined && i < stretch.length) {
690
- SplitPanel.setStretch(widgets[i], stretch[i]);
691
- }
692
- splitLayout.addWidget(widgets[i]);
693
- }
694
- return splitLayout;
695
- }
696
-
697
- /**
698
- * Assemble the application shell layout. Override this method in order to change the arrangement
699
- * of the main area and the side panels.
700
- */
701
- protected createLayout(): Layout {
702
- const bottomSplitLayout = this.createSplitLayout(
703
- [this.mainPanel, this.bottomPanel],
704
- [1, 0],
705
- { orientation: 'vertical', spacing: 0 }
706
- );
707
- const panelForBottomArea = new SplitPanel({ layout: bottomSplitLayout });
708
- panelForBottomArea.id = 'theia-bottom-split-panel';
709
-
710
- const leftRightSplitLayout = this.createSplitLayout(
711
- [this.leftPanelHandler.container, panelForBottomArea, this.rightPanelHandler.container],
712
- [0, 1, 0],
713
- { orientation: 'horizontal', spacing: 0 }
714
- );
715
- const panelForSideAreas = new SplitPanel({ layout: leftRightSplitLayout });
716
- panelForSideAreas.id = 'theia-left-right-split-panel';
717
-
718
- return this.createBoxLayout(
719
- [this.topPanel, panelForSideAreas, this.statusBar],
720
- [0, 1, 0],
721
- { direction: 'top-to-bottom', spacing: 0 }
722
- );
723
- }
724
-
725
- /**
726
- * Create an object that describes the current shell layout. This object may contain references
727
- * to widgets; these need to be transformed before the layout can be serialized.
728
- */
729
- getLayoutData(): ApplicationShell.LayoutData {
730
- return {
731
- version: applicationShellLayoutVersion,
732
- mainPanel: this.mainPanel.saveLayout(),
733
- mainPanelPinned: this.getPinnedMainWidgets(),
734
- bottomPanel: {
735
- config: this.bottomPanel.saveLayout(),
736
- pinned: this.getPinnedBottomWidgets(),
737
- size: this.bottomPanel.isVisible ? this.getBottomPanelSize() : this.bottomPanelState.lastPanelSize,
738
- expanded: this.isExpanded('bottom')
739
- },
740
- leftPanel: this.leftPanelHandler.getLayoutData(),
741
- rightPanel: this.rightPanelHandler.getLayoutData(),
742
- activeWidgetId: this.activeWidget ? this.activeWidget.id : undefined
743
- };
744
- }
745
-
746
- // Get an array corresponding to main panel widgets' pinned state.
747
- getPinnedMainWidgets(): boolean[] {
748
- const pinned: boolean[] = [];
749
-
750
- toArray(this.mainPanel.widgets()).forEach((a, i) => {
751
- pinned[i] = a.title.className.includes(PINNED_CLASS);
752
- });
753
-
754
- return pinned;
755
- }
756
-
757
- // Get an array corresponding to bottom panel widgets' pinned state.
758
- getPinnedBottomWidgets(): boolean[] {
759
- const pinned: boolean[] = [];
760
-
761
- toArray(this.bottomPanel.widgets()).forEach((a, i) => {
762
- pinned[i] = a.title.className.includes(PINNED_CLASS);
763
- });
764
-
765
- return pinned;
766
- }
767
-
768
- /**
769
- * Compute the current height of the bottom panel. This implementation assumes that the container
770
- * of the bottom panel is a `SplitPanel`.
771
- */
772
- protected getBottomPanelSize(): number | undefined {
773
- const parent = this.bottomPanel.parent;
774
- if (parent instanceof SplitPanel && parent.isVisible) {
775
- const index = parent.widgets.indexOf(this.bottomPanel) - 1;
776
- if (index >= 0) {
777
- const handle = parent.handles[index];
778
- if (!handle.classList.contains('p-mod-hidden')) {
779
- const parentHeight = parent.node.clientHeight;
780
- return parentHeight - handle.offsetTop;
781
- }
782
- }
783
- }
784
- }
785
-
786
- /**
787
- * Determine the default size to apply when the bottom panel is expanded for the first time.
788
- */
789
- protected getDefaultBottomPanelSize(): number | undefined {
790
- const parent = this.bottomPanel.parent;
791
- if (parent && parent.isVisible) {
792
- return parent.node.clientHeight * this.options.bottomPanel.initialSizeRatio;
793
- }
794
- }
795
-
796
- /**
797
- * Apply a shell layout that has been previously created with `getLayoutData`.
798
- */
799
- async setLayoutData(layoutData: ApplicationShell.LayoutData): Promise<void> {
800
- const { mainPanel, mainPanelPinned, bottomPanel, leftPanel, rightPanel, activeWidgetId } = layoutData;
801
- if (leftPanel) {
802
- this.leftPanelHandler.setLayoutData(leftPanel);
803
- this.registerWithFocusTracker(leftPanel);
804
- }
805
- if (rightPanel) {
806
- this.rightPanelHandler.setLayoutData(rightPanel);
807
- this.registerWithFocusTracker(rightPanel);
808
- }
809
- // Proceed with the bottom panel once the side panels are set up
810
- await Promise.all([this.leftPanelHandler.state.pendingUpdate, this.rightPanelHandler.state.pendingUpdate]);
811
- if (bottomPanel) {
812
- if (bottomPanel.config) {
813
- this.bottomPanel.restoreLayout(bottomPanel.config);
814
- this.registerWithFocusTracker(bottomPanel.config.main);
815
- }
816
- if (bottomPanel.size) {
817
- this.bottomPanelState.lastPanelSize = bottomPanel.size;
818
- }
819
- if (bottomPanel.expanded) {
820
- this.expandBottomPanel();
821
- } else {
822
- this.collapseBottomPanel();
823
- }
824
- const widgets = toArray(this.bottomPanel.widgets());
825
- this.bottomPanel.markActiveTabBar(widgets[0]?.title);
826
- if (bottomPanel.pinned && bottomPanel.pinned.length === widgets.length) {
827
- widgets.forEach((a, i) => {
828
- if (bottomPanel.pinned![i]) {
829
- a.title.className += ` ${PINNED_CLASS}`;
830
- a.title.closable = false;
831
- }
832
- });
833
- }
834
- this.refreshBottomPanelToggleButton();
835
- }
836
- // Proceed with the main panel once all others are set up
837
- await this.bottomPanelState.pendingUpdate;
838
- if (mainPanel) {
839
- this.mainPanel.restoreLayout(mainPanel);
840
- this.registerWithFocusTracker(mainPanel.main);
841
- const widgets = toArray(this.mainPanel.widgets());
842
- // We don't store information about the last active tabbar
843
- // So we simply mark the first as being active
844
- this.mainPanel.markActiveTabBar(widgets[0]?.title);
845
- if (mainPanelPinned && mainPanelPinned.length === widgets.length) {
846
- widgets.forEach((a, i) => {
847
- if (mainPanelPinned[i]) {
848
- a.title.className += ` ${PINNED_CLASS}`;
849
- a.title.closable = false;
850
- }
851
- });
852
- }
853
- }
854
- if (activeWidgetId) {
855
- this.activateWidget(activeWidgetId);
856
- }
857
- }
858
-
859
- /**
860
- * Modify the height of the bottom panel. This implementation assumes that the container of the
861
- * bottom panel is a `SplitPanel`.
862
- */
863
- protected setBottomPanelSize(size: number): Promise<void> {
864
- const enableAnimation = this.applicationStateService.state === 'ready';
865
- const options: SplitPositionOptions = {
866
- side: 'bottom',
867
- duration: enableAnimation ? this.options.bottomPanel.expandDuration : 0,
868
- referenceWidget: this.bottomPanel
869
- };
870
- const promise = this.splitPositionHandler.setSidePanelSize(this.bottomPanel, size, options);
871
- const result = new Promise<void>(resolve => {
872
- // Resolve the resulting promise in any case, regardless of whether resizing was successful
873
- promise.then(() => resolve(), () => resolve());
874
- });
875
- this.bottomPanelState.pendingUpdate = this.bottomPanelState.pendingUpdate.then(() => result);
876
- return result;
877
- }
878
-
879
- /**
880
- * A promise that is resolved when all currently pending updates are done.
881
- */
882
- get pendingUpdates(): Promise<void> {
883
- return Promise.all([
884
- this.bottomPanelState.pendingUpdate,
885
- this.leftPanelHandler.state.pendingUpdate,
886
- this.rightPanelHandler.state.pendingUpdate
887
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
888
- ]) as Promise<any>;
889
- }
890
-
891
- /**
892
- * Track all widgets that are referenced by the given layout data.
893
- */
894
- protected registerWithFocusTracker(data: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig | SidePanel.LayoutData | null): void {
895
- if (data) {
896
- if (data.type === 'tab-area') {
897
- for (const widget of data.widgets) {
898
- if (widget) {
899
- this.track(widget);
900
- }
901
- }
902
- } else if (data.type === 'split-area') {
903
- for (const child of data.children) {
904
- this.registerWithFocusTracker(child);
905
- }
906
- } else if (data.type === 'sidepanel' && data.items) {
907
- for (const item of data.items) {
908
- if (item.widget) {
909
- this.track(item.widget);
910
- }
911
- }
912
- }
913
- }
914
- }
915
-
916
- /**
917
- * Add a widget to the application shell. The given widget must have a unique `id` property,
918
- * which will be used as the DOM id.
919
- *
920
- * Widgets are removed from the shell by calling their `close` or `dispose` methods.
921
- *
922
- * Widgets added to the top area are not tracked regarding the _current_ and _active_ states.
923
- */
924
- async addWidget(widget: Widget, options?: Readonly<ApplicationShell.WidgetOptions>): Promise<void> {
925
- if (!widget.id) {
926
- console.error('Widgets added to the application shell must have a unique id property.');
927
- return;
928
- }
929
- const { area, addOptions } = this.getInsertionOptions(options);
930
- const sidePanelOptions: SidePanel.WidgetOptions = { rank: options?.rank };
931
- switch (area) {
932
- case 'main':
933
- this.mainPanel.addWidget(widget, addOptions);
934
- break;
935
- case 'top':
936
- this.topPanel.addWidget(widget);
937
- break;
938
- case 'bottom':
939
- this.bottomPanel.addWidget(widget, addOptions);
940
- break;
941
- case 'left':
942
- this.leftPanelHandler.addWidget(widget, sidePanelOptions);
943
- break;
944
- case 'right':
945
- this.rightPanelHandler.addWidget(widget, sidePanelOptions);
946
- break;
947
- case 'secondaryWindow':
948
- /** At the moment, widgets are only moved to this area (i.e. a secondary window) by moving them from one of the other areas. */
949
- throw new Error('Widgets cannot be added directly to a secondary window');
950
- default:
951
- throw new Error('Unexpected area: ' + options?.area);
952
- }
953
- if (area !== 'top') {
954
- this.track(widget);
955
- }
956
- }
957
-
958
- getInsertionOptions(options?: Readonly<ApplicationShell.WidgetOptions>): { area: string; addOptions: DockLayout.IAddOptions; } {
959
- let ref: Widget | undefined = options?.ref;
960
- let area: ApplicationShell.Area = options?.area || 'main';
961
- if (!ref && (area === 'main' || area === 'bottom')) {
962
- const tabBar = this.getTabBarFor(area);
963
- ref = tabBar && tabBar.currentTitle && tabBar.currentTitle.owner || undefined;
964
- }
965
- // make sure that ref belongs to area
966
- area = ref && this.getAreaFor(ref) || area;
967
- const addOptions: DockPanel.IAddOptions = {};
968
- if (ApplicationShell.isOpenToSideMode(options?.mode)) {
969
- const areaPanel = area === 'main' ? this.mainPanel : area === 'bottom' ? this.bottomPanel : undefined;
970
- const sideRef = areaPanel && ref && (options?.mode === 'open-to-left' ?
971
- areaPanel.previousTabBarWidget(ref) :
972
- areaPanel.nextTabBarWidget(ref));
973
- if (sideRef) {
974
- addOptions.ref = sideRef;
975
- } else {
976
- addOptions.ref = ref;
977
- addOptions.mode = options?.mode === 'open-to-left' ? 'split-left' : 'split-right';
978
- }
979
- } else {
980
- addOptions.ref = ref;
981
- addOptions.mode = options?.mode;
982
- }
983
- return { area, addOptions };
984
- }
985
-
986
- /**
987
- * The widgets contained in the given shell area.
988
- */
989
- getWidgets(area: ApplicationShell.Area): Widget[] {
990
- switch (area) {
991
- case 'main':
992
- return toArray(this.mainPanel.widgets());
993
- case 'top':
994
- return toArray(this.topPanel.widgets);
995
- case 'bottom':
996
- return toArray(this.bottomPanel.widgets());
997
- case 'left':
998
- return toArray(this.leftPanelHandler.dockPanel.widgets());
999
- case 'right':
1000
- return toArray(this.rightPanelHandler.dockPanel.widgets());
1001
- case 'secondaryWindow':
1002
- return toArray(this.secondaryWindowHandler.widgets);
1003
- default:
1004
- throw new Error('Illegal argument: ' + area);
1005
- }
1006
- }
1007
-
1008
- /**
1009
- * Find the widget that contains the given HTML element. The returned widget may be one
1010
- * that is managed by the application shell, or one that is embedded in another widget and
1011
- * not directly managed by the shell, or a tab bar.
1012
- */
1013
- findWidgetForElement(element: HTMLElement): Widget | undefined {
1014
- let widgetNode: HTMLElement | null = element;
1015
- while (widgetNode && !widgetNode.classList.contains('p-Widget')) {
1016
- widgetNode = widgetNode.parentElement;
1017
- }
1018
- if (widgetNode) {
1019
- return this.findWidgetForNode(widgetNode, this);
1020
- }
1021
- return undefined;
1022
- }
1023
-
1024
- private findWidgetForNode(widgetNode: HTMLElement, widget: Widget): Widget | undefined {
1025
- if (widget.node === widgetNode) {
1026
- return widget;
1027
- }
1028
- let result: Widget | undefined;
1029
- each(widget.children(), child => {
1030
- result = this.findWidgetForNode(widgetNode, child);
1031
- return !result;
1032
- });
1033
- return result;
1034
- }
1035
-
1036
- /**
1037
- * Finds the title widget from the tab-bar.
1038
- * @param tabBar used for providing an array of titles.
1039
- * @returns the selected title widget, else returns the currentTitle or undefined.
1040
- */
1041
- findTitle(tabBar: TabBar<Widget>, event?: Event): Title<Widget> | undefined {
1042
- if (event?.target instanceof HTMLElement) {
1043
- const tabNode = event.target;
1044
-
1045
- const titleIndex = Array.from(tabBar.contentNode.getElementsByClassName('p-TabBar-tab'))
1046
- .findIndex(node => node.contains(tabNode));
1047
-
1048
- if (titleIndex !== -1) {
1049
- return tabBar.titles[titleIndex];
1050
- }
1051
-
1052
- }
1053
- return tabBar.currentTitle || undefined;
1054
- }
1055
-
1056
- /**
1057
- * Finds the tab-bar widget.
1058
- * @returns the selected tab-bar, else returns the currentTabBar.
1059
- */
1060
- findTabBar(event?: Event): TabBar<Widget> | undefined {
1061
- if (event?.target instanceof HTMLElement) {
1062
- const tabBar = this.findWidgetForElement(event.target);
1063
- if (tabBar instanceof TabBar) {
1064
- return tabBar;
1065
- }
1066
- }
1067
- return this.currentTabBar;
1068
- }
1069
-
1070
- /**
1071
- * @returns the widget whose title has been targeted by a DOM event on a tabbar, or undefined if none can be found.
1072
- */
1073
- findTargetedWidget(event?: Event): Widget | undefined {
1074
- if (event) {
1075
- const tab = this.findTabBar(event);
1076
- const title = tab && this.findTitle(tab, event);
1077
- return title && title.owner;
1078
- }
1079
- }
1080
-
1081
- /**
1082
- * The current widget in the application shell. The current widget is the last widget that
1083
- * was active and not yet closed. See the remarks to `activeWidget` on what _active_ means.
1084
- */
1085
- get currentWidget(): Widget | undefined {
1086
- return this.tracker.currentWidget || undefined;
1087
- }
1088
-
1089
- /**
1090
- * The active widget in the application shell. The active widget is the one that has focus
1091
- * (either the widget itself or any of its contents).
1092
- *
1093
- * _Note:_ Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1094
- * widget implementation which DOM element will get the focus. The default implementation
1095
- * does not take any focus; in that case the widget is never returned by this property.
1096
- */
1097
- get activeWidget(): Widget | undefined {
1098
- return this.tracker.activeWidget || undefined;
1099
- }
1100
-
1101
- /**
1102
- * Returns the last active widget in the given shell area.
1103
- */
1104
- getCurrentWidget(area: ApplicationShell.Area): Widget | undefined {
1105
- let title: Title<Widget> | null | undefined;
1106
- switch (area) {
1107
- case 'main':
1108
- title = this.mainPanel.currentTitle;
1109
- break;
1110
- case 'bottom':
1111
- title = this.bottomPanel.currentTitle;
1112
- break;
1113
- case 'left':
1114
- title = this.leftPanelHandler.tabBar.currentTitle;
1115
- break;
1116
- case 'right':
1117
- title = this.rightPanelHandler.tabBar.currentTitle;
1118
- break;
1119
- case 'secondaryWindow':
1120
- // The current widget in a secondary window is not tracked.
1121
- return undefined;
1122
- default:
1123
- throw new Error('Illegal argument: ' + area);
1124
- }
1125
- return title ? title.owner : undefined;
1126
- }
1127
-
1128
- /**
1129
- * Handle a change to the current widget.
1130
- */
1131
- private onCurrentChanged(sender: FocusTracker<Widget>, args: FocusTracker.IChangedArgs<Widget>): void {
1132
- this.onDidChangeCurrentWidgetEmitter.fire(args);
1133
- }
1134
-
1135
- protected readonly toDisposeOnActiveChanged = new DisposableCollection();
1136
-
1137
- /**
1138
- * Handle a change to the active widget.
1139
- */
1140
- private onActiveChanged(sender: FocusTracker<Widget>, args: FocusTracker.IChangedArgs<Widget>): void {
1141
- this.toDisposeOnActiveChanged.dispose();
1142
- const { newValue, oldValue } = args;
1143
- if (oldValue) {
1144
- let w: Widget | null = oldValue;
1145
- while (w) {
1146
- // Remove the mark of the previously active widget
1147
- w.title.className = w.title.className.replace(' theia-mod-active', '');
1148
- w = w.parent;
1149
- }
1150
- // Reset the z-index to the default
1151
- // eslint-disable-next-line no-null/no-null
1152
- this.setZIndex(oldValue.node, null);
1153
- }
1154
- if (newValue) {
1155
- let w: Widget | null = newValue;
1156
- while (w) {
1157
- // Mark the tab of the active widget
1158
- w.title.className += ' theia-mod-active';
1159
- w = w.parent;
1160
- }
1161
- // Reveal the title of the active widget in its tab bar
1162
- const tabBar = this.getTabBarFor(newValue);
1163
- if (tabBar instanceof ScrollableTabBar) {
1164
- const index = tabBar.titles.indexOf(newValue.title);
1165
- if (index >= 0) {
1166
- tabBar.revealTab(index);
1167
- }
1168
- }
1169
- const widget = this.toTrackedStack(newValue.id).pop();
1170
- const panel = this.findPanel(widget);
1171
- if (panel) {
1172
- // if widget was undefined, we wouldn't have gotten a panel back before
1173
- panel.markAsCurrent(widget!.title);
1174
- }
1175
- // Add checks to ensure that the 'sash' for left panel is displayed correctly
1176
- if (newValue.node.className === 'p-Widget theia-view-container p-DockPanel-widget') {
1177
- // Set the z-index so elements with `position: fixed` contained in the active widget are displayed correctly
1178
- this.setZIndex(newValue.node, '1');
1179
- }
1180
-
1181
- // activate another widget if an active widget will be closed
1182
- const onCloseRequest = newValue['onCloseRequest'];
1183
- newValue['onCloseRequest'] = msg => {
1184
- const currentTabBar = this.currentTabBar;
1185
- if (currentTabBar) {
1186
- const recentlyUsedInTabBar = currentTabBar['_previousTitle'] as TabBar<Widget>['currentTitle'];
1187
- if (recentlyUsedInTabBar && recentlyUsedInTabBar.owner !== newValue) {
1188
- currentTabBar.currentIndex = ArrayExt.firstIndexOf(currentTabBar.titles, recentlyUsedInTabBar);
1189
- if (currentTabBar.currentTitle) {
1190
- this.activateWidget(currentTabBar.currentTitle.owner.id);
1191
- }
1192
- } else if (!this.activateNextTabInTabBar(currentTabBar)) {
1193
- if (!this.activatePreviousTabBar(currentTabBar)) {
1194
- this.activateNextTabBar(currentTabBar);
1195
- }
1196
- }
1197
- }
1198
- newValue['onCloseRequest'] = onCloseRequest;
1199
- newValue['onCloseRequest'](msg);
1200
- };
1201
- this.toDisposeOnActiveChanged.push(Disposable.create(() => newValue['onCloseRequest'] = onCloseRequest));
1202
- if (PreviewableWidget.is(newValue)) {
1203
- newValue.loaded = true;
1204
- }
1205
- }
1206
- this.onDidChangeActiveWidgetEmitter.fire(args);
1207
- }
1208
-
1209
- /**
1210
- * Set the z-index of the given element and its ancestors to the value `z`.
1211
- */
1212
- private setZIndex(element: HTMLElement, z: string | null): void {
1213
- element.style.zIndex = z || '';
1214
- const parent = element.parentElement;
1215
- if (parent && parent !== this.node) {
1216
- this.setZIndex(parent, z);
1217
- }
1218
- }
1219
-
1220
- /**
1221
- * Track the given widget so it is considered in the `current` and `active` state of the shell.
1222
- */
1223
- protected track(widget: Widget): void {
1224
- if (this.tracker.widgets.indexOf(widget) !== -1) {
1225
- return;
1226
- }
1227
- this.tracker.add(widget);
1228
- this.checkActivation(widget);
1229
- Saveable.apply(
1230
- widget,
1231
- () => this.widgets.filter((maybeSaveable): maybeSaveable is Widget & SaveableSource => !!Saveable.get(maybeSaveable)),
1232
- (toSave, options) => this.saveResourceService.save(toSave, options),
1233
- );
1234
- if (ApplicationShell.TrackableWidgetProvider.is(widget)) {
1235
- for (const toTrack of widget.getTrackableWidgets()) {
1236
- this.track(toTrack);
1237
- }
1238
- if (widget.onDidChangeTrackableWidgets) {
1239
- widget.onDidChangeTrackableWidgets(widgets => widgets.forEach(w => this.track(w)));
1240
- }
1241
- }
1242
- }
1243
-
1244
- /**
1245
- * @returns an array of Widgets, all of which are tracked by the focus tracker
1246
- * The first member of the array is the widget whose id is passed in, and the other widgets
1247
- * are its tracked parents in ascending order
1248
- */
1249
- protected toTrackedStack(id: string): Widget[] {
1250
- const tracked = new Map<string, Widget>(this.tracker.widgets.map(w => [w.id, w] as [string, Widget]));
1251
- let current = tracked.get(id);
1252
- const stack: Widget[] = [];
1253
- while (current) {
1254
- if (tracked.has(current.id)) {
1255
- stack.push(current);
1256
- }
1257
- current = current.parent || undefined;
1258
- }
1259
- return stack;
1260
- }
1261
-
1262
- /**
1263
- * Activate a widget in the application shell. This makes the widget visible and usually
1264
- * also assigns focus to it.
1265
- *
1266
- * _Note:_ Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1267
- * widget implementation which DOM element will get the focus. The default implementation
1268
- * does not take any focus.
1269
- *
1270
- * @returns the activated widget if it was found
1271
- */
1272
- async activateWidget(id: string): Promise<Widget | undefined> {
1273
- const stack = this.toTrackedStack(id);
1274
- let current = stack.pop();
1275
- if (current && !this.doActivateWidget(current.id)) {
1276
- return undefined;
1277
- }
1278
- while (current && stack.length) {
1279
- const child = stack.pop()!;
1280
- if (ApplicationShell.TrackableWidgetProvider.is(current) && current.activateWidget) {
1281
- current = current.activateWidget(child.id);
1282
- } else {
1283
- child.activate();
1284
- current = child;
1285
- }
1286
- }
1287
- if (!current) {
1288
- return undefined;
1289
- }
1290
- return Promise.all([
1291
- this.waitForActivation(current.id),
1292
- waitForRevealed(current),
1293
- this.pendingUpdates
1294
- ]).then(() => current, () => undefined);
1295
- }
1296
-
1297
- waitForActivation(id: string): Promise<void> {
1298
- if (this.activeWidget && this.activeWidget.id === id) {
1299
- return Promise.resolve();
1300
- }
1301
- const activation = new Deferred();
1302
- const success = this.onDidChangeActiveWidget(() => {
1303
- if (this.activeWidget && this.activeWidget.id === id) {
1304
- activation.resolve();
1305
- }
1306
- });
1307
- const failure = setTimeout(() => activation.reject(new Error(`Widget with id '${id}' failed to activate.`)), this.activationTimeout + 250);
1308
- return activation.promise.finally(() => {
1309
- success.dispose();
1310
- clearTimeout(failure);
1311
- });
1312
- }
1313
-
1314
- /**
1315
- * Activate top-level area widget.
1316
- */
1317
- protected doActivateWidget(id: string): Widget | undefined {
1318
- let widget = find(this.mainPanel.widgets(), w => w.id === id);
1319
- if (widget) {
1320
- this.mainPanel.activateWidget(widget);
1321
- return widget;
1322
- }
1323
- widget = find(this.bottomPanel.widgets(), w => w.id === id);
1324
- if (widget) {
1325
- this.expandBottomPanel();
1326
- this.bottomPanel.activateWidget(widget);
1327
- return widget;
1328
- }
1329
- widget = this.leftPanelHandler.activate(id);
1330
- if (widget) {
1331
- return widget;
1332
- }
1333
- widget = this.rightPanelHandler.activate(id);
1334
- if (widget) {
1335
- return widget;
1336
- }
1337
- return this.secondaryWindowHandler.activateWidget(id);
1338
- }
1339
-
1340
- /**
1341
- * Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1342
- * widget implementation which DOM element will get the focus. The default implementation
1343
- * of Widget does not take any focus. This method can help finding such problems by logging
1344
- * a warning in case a widget was explicitly activated, but did not trigger a change of the
1345
- * `activeWidget` property.
1346
- */
1347
- private checkActivation(widget: Widget): Widget {
1348
- const onActivateRequest = widget['onActivateRequest'].bind(widget);
1349
- widget['onActivateRequest'] = (msg: Message) => {
1350
- onActivateRequest(msg);
1351
- this.assertActivated(widget);
1352
- };
1353
- return widget;
1354
- }
1355
-
1356
- private readonly activationTimeout = 2000;
1357
- private readonly toDisposeOnActivationCheck = new DisposableCollection();
1358
- private assertActivated(widget: Widget): void {
1359
- this.toDisposeOnActivationCheck.dispose();
1360
-
1361
- const onDispose = () => this.toDisposeOnActivationCheck.dispose();
1362
- widget.disposed.connect(onDispose);
1363
- this.toDisposeOnActivationCheck.push(Disposable.create(() => widget.disposed.disconnect(onDispose)));
1364
-
1365
- let start = 0;
1366
- const step: FrameRequestCallback = timestamp => {
1367
- const activeElement = widget.node.ownerDocument.activeElement;
1368
- if (activeElement && widget.node.contains(activeElement)) {
1369
- return;
1370
- }
1371
- if (!start) {
1372
- start = timestamp;
1373
- }
1374
- const delta = timestamp - start;
1375
- if (delta < this.activationTimeout) {
1376
- request = window.requestAnimationFrame(step);
1377
- } else {
1378
- console.warn(`Widget was activated, but did not accept focus after ${this.activationTimeout}ms: ${widget.id}`);
1379
- }
1380
- };
1381
- let request = window.requestAnimationFrame(step);
1382
- this.toDisposeOnActivationCheck.push(Disposable.create(() => window.cancelAnimationFrame(request)));
1383
- }
1384
-
1385
- /**
1386
- * Reveal a widget in the application shell. This makes the widget visible,
1387
- * but does not activate it.
1388
- *
1389
- * @returns the revealed widget if it was found
1390
- */
1391
- async revealWidget(id: string): Promise<Widget | undefined> {
1392
- const stack = this.toTrackedStack(id);
1393
- let current = stack.pop();
1394
- if (current && !this.doRevealWidget(current.id)) {
1395
- return undefined;
1396
- }
1397
- while (current && stack.length) {
1398
- const child = stack.pop()!;
1399
- if (ApplicationShell.TrackableWidgetProvider.is(current) && current.revealWidget) {
1400
- current = current.revealWidget(child.id);
1401
- } else {
1402
- current = child;
1403
- }
1404
- }
1405
- if (!current) {
1406
- return undefined;
1407
- }
1408
- await Promise.all([
1409
- waitForRevealed(current),
1410
- this.pendingUpdates
1411
- ]);
1412
- return current;
1413
- }
1414
-
1415
- /**
1416
- * Reveal top-level area widget.
1417
- */
1418
- protected doRevealWidget(id: string): Widget | undefined {
1419
- let widget = find(this.mainPanel.widgets(), w => w.id === id);
1420
- if (!widget) {
1421
- widget = find(this.bottomPanel.widgets(), w => w.id === id);
1422
- if (widget) {
1423
- this.expandBottomPanel();
1424
- }
1425
- }
1426
- if (widget) {
1427
- const tabBar = this.getTabBarFor(widget);
1428
- if (tabBar) {
1429
- tabBar.currentTitle = widget.title;
1430
- }
1431
- return widget;
1432
- }
1433
- widget = this.leftPanelHandler.expand(id);
1434
- if (widget) {
1435
- return widget;
1436
- }
1437
- widget = this.rightPanelHandler.expand(id);
1438
- if (widget) {
1439
- return widget;
1440
- }
1441
- return this.secondaryWindowHandler.revealWidget(id);
1442
- }
1443
-
1444
- /**
1445
- * Expand the named side panel area. This makes sure that the panel is visible, even if there
1446
- * are no widgets in it. If the panel is already visible, nothing happens. If the panel is currently
1447
- * collapsed (see `collapsePanel`) and it contains widgets, the widgets are revealed that were
1448
- * visible before it was collapsed.
1449
- */
1450
- expandPanel(area: ApplicationShell.Area): void {
1451
- switch (area) {
1452
- case 'bottom':
1453
- this.expandBottomPanel();
1454
- break;
1455
- case 'left':
1456
- this.leftPanelHandler.expand();
1457
- break;
1458
- case 'right':
1459
- this.rightPanelHandler.expand();
1460
- break;
1461
- default:
1462
- throw new Error('Area cannot be expanded: ' + area);
1463
- }
1464
- }
1465
-
1466
- /**
1467
- * Adjusts the size of the given area in the application shell.
1468
- *
1469
- * @param size the desired size of the panel in pixels.
1470
- * @param area the area to resize.
1471
- */
1472
- resize(size: number, area: ApplicationShell.Area): void {
1473
- switch (area) {
1474
- case 'bottom':
1475
- if (this.bottomPanel.isHidden) {
1476
- this.bottomPanelState.lastPanelSize = size;
1477
- } else {
1478
- this.setBottomPanelSize(size);
1479
- }
1480
- break;
1481
- case 'left':
1482
- this.leftPanelHandler.resize(size);
1483
- break;
1484
- case 'right':
1485
- this.rightPanelHandler.resize(size);
1486
- break;
1487
- default:
1488
- throw new Error('Area cannot be resized: ' + area);
1489
- }
1490
- }
1491
-
1492
- /**
1493
- * Expand the bottom panel. See `expandPanel` regarding the exact behavior.
1494
- */
1495
- protected expandBottomPanel(): void {
1496
- const bottomPanel = this.bottomPanel;
1497
- if (bottomPanel.isHidden) {
1498
- let relativeSizes: number[] | undefined;
1499
- const parent = bottomPanel.parent;
1500
- if (parent instanceof SplitPanel) {
1501
- relativeSizes = parent.relativeSizes();
1502
- }
1503
- bottomPanel.show();
1504
- if (relativeSizes && parent instanceof SplitPanel) {
1505
- // Make sure that the expansion animation starts at the smallest possible size
1506
- parent.setRelativeSizes(relativeSizes);
1507
- }
1508
-
1509
- let size: number | undefined;
1510
- if (bottomPanel.isEmpty) {
1511
- bottomPanel.node.style.minHeight = '0';
1512
- size = this.options.bottomPanel.emptySize;
1513
- } else if (this.bottomPanelState.lastPanelSize) {
1514
- size = this.bottomPanelState.lastPanelSize;
1515
- } else {
1516
- size = this.getDefaultBottomPanelSize();
1517
- }
1518
- if (size) {
1519
- this.bottomPanelState.expansion = SidePanel.ExpansionState.expanding;
1520
- this.setBottomPanelSize(size).then(() => {
1521
- if (this.bottomPanelState.expansion === SidePanel.ExpansionState.expanding) {
1522
- this.bottomPanelState.expansion = SidePanel.ExpansionState.expanded;
1523
- }
1524
- });
1525
- } else {
1526
- this.bottomPanelState.expansion = SidePanel.ExpansionState.expanded;
1527
- }
1528
- }
1529
- }
1530
-
1531
- /**
1532
- * Collapse the named side panel area. This makes sure that the panel is hidden,
1533
- * increasing the space that is available for other shell areas.
1534
- */
1535
- collapsePanel(area: ApplicationShell.Area): Promise<void> {
1536
- switch (area) {
1537
- case 'bottom':
1538
- return this.collapseBottomPanel();
1539
- case 'left':
1540
- return this.leftPanelHandler.collapse();
1541
- case 'right':
1542
- return this.rightPanelHandler.collapse();
1543
- default:
1544
- throw new Error('Area cannot be collapsed: ' + area);
1545
- }
1546
- }
1547
-
1548
- /**
1549
- * Collapse the bottom panel. All contained widgets are hidden, but not closed.
1550
- * They can be restored by calling `expandBottomPanel`.
1551
- */
1552
- protected collapseBottomPanel(): Promise<void> {
1553
- const bottomPanel = this.bottomPanel;
1554
- if (bottomPanel.isHidden) {
1555
- return Promise.resolve();
1556
- }
1557
- if (this.bottomPanelState.expansion === SidePanel.ExpansionState.expanded) {
1558
- const size = this.getBottomPanelSize();
1559
- if (size) {
1560
- this.bottomPanelState.lastPanelSize = size;
1561
- }
1562
- }
1563
- this.bottomPanelState.expansion = SidePanel.ExpansionState.collapsed;
1564
- bottomPanel.hide();
1565
- return animationFrame();
1566
- }
1567
-
1568
- /**
1569
- * Refresh the toggle button for the bottom panel. This implementation creates a status bar entry
1570
- * and refers to the command `core.toggle.bottom.panel`.
1571
- */
1572
- protected refreshBottomPanelToggleButton(): void {
1573
- if (this.bottomPanel.isEmpty) {
1574
- this.statusBar.removeElement(BOTTOM_PANEL_TOGGLE_ID);
1575
- } else {
1576
- const label = nls.localize('theia/core/common/collapseBottomPanel', 'Toggle Bottom Panel');
1577
- const element: StatusBarEntry = {
1578
- name: label,
1579
- text: '$(codicon-window)',
1580
- alignment: StatusBarAlignment.RIGHT,
1581
- tooltip: label,
1582
- command: 'core.toggle.bottom.panel',
1583
- accessibilityInformation: {
1584
- label: label,
1585
- role: 'button'
1586
- },
1587
- priority: -1000
1588
- };
1589
- this.statusBar.setElement(BOTTOM_PANEL_TOGGLE_ID, element);
1590
- }
1591
- }
1592
-
1593
- /**
1594
- * Check whether the named side panel area is expanded (returns `true`) or collapsed (returns `false`).
1595
- */
1596
- isExpanded(area: ApplicationShell.Area): boolean {
1597
- switch (area) {
1598
- case 'bottom':
1599
- return this.bottomPanelState.expansion === SidePanel.ExpansionState.expanded;
1600
- case 'left':
1601
- return this.leftPanelHandler.state.expansion === SidePanel.ExpansionState.expanded;
1602
- case 'right':
1603
- return this.rightPanelHandler.state.expansion === SidePanel.ExpansionState.expanded;
1604
- default:
1605
- return true;
1606
- }
1607
- }
1608
-
1609
- /**
1610
- * Close all tabs or a selection of tabs in a specific part of the application shell.
1611
- *
1612
- * @param tabBarOrArea
1613
- * Either the name of a shell area or a `TabBar` that is contained in such an area.
1614
- * @param filter
1615
- * If undefined, all tabs are closed; otherwise only those tabs that match the filter are closed.
1616
- */
1617
- async closeTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1618
- filter?: (title: Title<Widget>, index: number) => boolean): Promise<void> {
1619
- const titles: Array<Title<Widget>> = this.getWidgetTitles(tabBarOrArea, filter);
1620
- if (titles.length) {
1621
- await this.closeMany(titles.map(title => title.owner));
1622
- }
1623
- }
1624
-
1625
- saveTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1626
- filter?: (title: Title<Widget>, index: number) => boolean): void {
1627
-
1628
- const titles = this.getWidgetTitles(tabBarOrArea, filter);
1629
- for (let i = 0; i < titles.length; i++) {
1630
- const widget = titles[i].owner;
1631
- const saveable = Saveable.get(widget);
1632
- saveable?.save();
1633
- }
1634
- }
1635
-
1636
- /**
1637
- * Collects all widget titles for the given tab bar or area and optionally filters them.
1638
- *
1639
- * @param tabBarOrArea The tab bar or area to retrieve the widget titles for
1640
- * @param filter The filter to apply to the result
1641
- * @returns The filtered array of widget titles or an empty array
1642
- */
1643
- protected getWidgetTitles(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1644
- filter?: (title: Title<Widget>, index: number) => boolean): Title<Widget>[] {
1645
-
1646
- const titles: Title<Widget>[] = [];
1647
- if (tabBarOrArea === 'main') {
1648
- this.mainAreaTabBars.forEach(tabbar => titles.push(...toArray(tabbar.titles)));
1649
- } else if (tabBarOrArea === 'bottom') {
1650
- this.bottomAreaTabBars.forEach(tabbar => titles.push(...toArray(tabbar.titles)));
1651
- } else if (tabBarOrArea === 'secondaryWindow') {
1652
- titles.push(...this.secondaryWindowHandler.widgets.map(w => w.title));
1653
- } else if (typeof tabBarOrArea === 'string') {
1654
- const tabbar = this.getTabBarFor(tabBarOrArea);
1655
- if (tabbar) {
1656
- titles.push(...toArray(tabbar.titles));
1657
- }
1658
- } else if (tabBarOrArea) {
1659
- titles.push(...toArray(tabBarOrArea.titles));
1660
- }
1661
-
1662
- return filter ? titles.filter(filter) : titles;
1663
- }
1664
-
1665
- /**
1666
- * @param targets the widgets to be closed
1667
- * @return an array of all the widgets that were actually closed.
1668
- */
1669
- async closeMany(targets: Widget[], options?: ApplicationShell.CloseOptions): Promise<Widget[]> {
1670
- if (options?.save === false || await Saveable.confirmSaveBeforeClose(targets, this.widgets.filter(widget => !targets.includes(widget)))) {
1671
- return (await Promise.all(targets.map(target => this.closeWidget(target.id, options)))).filter((widget): widget is Widget => widget !== undefined);
1672
- }
1673
- return [];
1674
- }
1675
-
1676
- /**
1677
- * @returns the widget that was closed, if any, `undefined` otherwise.
1678
- *
1679
- * If your use case requires closing multiple widgets, use {@link ApplicationShell#closeMany} instead. That method handles closing saveable widgets more reliably.
1680
- */
1681
- async closeWidget(id: string, options?: ApplicationShell.CloseOptions): Promise<Widget | undefined> {
1682
- // TODO handle save for composite widgets, i.e. the preference widget has 2 editors
1683
- const stack = this.toTrackedStack(id);
1684
- const current = stack.pop();
1685
- if (!current) {
1686
- return undefined;
1687
- }
1688
- const saveableOptions = options && { shouldSave: () => options.save };
1689
- const pendingClose = SaveableWidget.is(current)
1690
- ? current.closeWithSaving(saveableOptions)
1691
- : (current.close(), waitForClosed(current));
1692
- await Promise.all([
1693
- pendingClose,
1694
- this.pendingUpdates
1695
- ]);
1696
- return stack[0] || current;
1697
- }
1698
-
1699
- /**
1700
- * The shell area name of the currently active tab, or undefined.
1701
- */
1702
- get currentTabArea(): ApplicationShell.Area | undefined {
1703
- const currentWidget = this.currentWidget;
1704
- if (currentWidget) {
1705
- return this.getAreaFor(currentWidget);
1706
- }
1707
- }
1708
-
1709
- /**
1710
- * Determine the name of the shell area where the given widget resides. The result is
1711
- * undefined if the widget does not reside directly in the shell.
1712
- */
1713
- getAreaFor(input: TabBar<Widget> | Widget): ApplicationShell.Area | undefined {
1714
- if (input instanceof TabBar) {
1715
- if (find(this.mainPanel.tabBars(), tb => tb === input)) {
1716
- return 'main';
1717
- }
1718
- if (find(this.bottomPanel.tabBars(), tb => tb === input)) {
1719
- return 'bottom';
1720
- }
1721
- if (this.leftPanelHandler.tabBar === input) {
1722
- return 'left';
1723
- }
1724
- if (this.rightPanelHandler.tabBar === input) {
1725
- return 'right';
1726
- }
1727
- }
1728
- const widget = this.toTrackedStack(input.id).pop();
1729
- if (!widget) {
1730
- return undefined;
1731
- }
1732
- const title = widget.title;
1733
- const mainPanelTabBar = this.mainPanel.findTabBar(title);
1734
- if (mainPanelTabBar) {
1735
- return 'main';
1736
- }
1737
- const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
1738
- if (bottomPanelTabBar) {
1739
- return 'bottom';
1740
- }
1741
- if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
1742
- return 'left';
1743
- }
1744
- if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
1745
- return 'right';
1746
- }
1747
- if (this.secondaryWindowHandler.widgets.includes(widget)) {
1748
- return 'secondaryWindow';
1749
- }
1750
- return undefined;
1751
- }
1752
-
1753
- protected getAreaPanelFor(input: Widget): DockPanel | undefined {
1754
- const widget = this.toTrackedStack(input.id).pop();
1755
- if (!widget) {
1756
- return undefined;
1757
- }
1758
- return this.findPanel(widget);
1759
- }
1760
-
1761
- /**
1762
- * Find the shell panel this top-level widget is part of
1763
- */
1764
- protected findPanel(widget: Widget | undefined): TheiaDockPanel | undefined {
1765
- if (!widget) {
1766
- return undefined;
1767
- }
1768
- const title = widget.title;
1769
- const mainPanelTabBar = this.mainPanel.findTabBar(title);
1770
- if (mainPanelTabBar) {
1771
- return this.mainPanel;
1772
- }
1773
- const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
1774
- if (bottomPanelTabBar) {
1775
- return this.bottomPanel;
1776
- }
1777
- if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
1778
- return this.leftPanelHandler.dockPanel;
1779
- }
1780
- if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
1781
- return this.rightPanelHandler.dockPanel;
1782
- }
1783
- return undefined;
1784
- }
1785
-
1786
- /**
1787
- * Return the tab bar that has the currently active widget, or undefined.
1788
- */
1789
- get currentTabBar(): TabBar<Widget> | undefined {
1790
- const currentWidget = this.currentWidget;
1791
- if (currentWidget) {
1792
- return this.getTabBarFor(currentWidget);
1793
- }
1794
- }
1795
-
1796
- /**
1797
- * Return the tab bar in the given shell area, or the tab bar that has the given widget, or undefined.
1798
- */
1799
- getTabBarFor(widgetOrArea: Widget | ApplicationShell.Area): TabBar<Widget> | undefined {
1800
- if (typeof widgetOrArea === 'string') {
1801
- switch (widgetOrArea) {
1802
- case 'main':
1803
- return this.mainPanel.currentTabBar;
1804
- case 'bottom':
1805
- return this.bottomPanel.currentTabBar;
1806
- case 'left':
1807
- return this.leftPanelHandler.tabBar;
1808
- case 'right':
1809
- return this.rightPanelHandler.tabBar;
1810
- case 'secondaryWindow':
1811
- // Secondary windows don't have a tab bar
1812
- return undefined;
1813
- default:
1814
- throw new Error('Illegal argument: ' + widgetOrArea);
1815
- }
1816
- }
1817
- const widget = this.toTrackedStack(widgetOrArea.id).pop();
1818
- if (!widget) {
1819
- return undefined;
1820
- }
1821
- const widgetTitle = widget.title;
1822
- const mainPanelTabBar = this.mainPanel.findTabBar(widgetTitle);
1823
- if (mainPanelTabBar) {
1824
- return mainPanelTabBar;
1825
- }
1826
- const bottomPanelTabBar = this.bottomPanel.findTabBar(widgetTitle);
1827
- if (bottomPanelTabBar) {
1828
- return bottomPanelTabBar;
1829
- }
1830
- const leftPanelTabBar = this.leftPanelHandler.tabBar;
1831
- if (ArrayExt.firstIndexOf(leftPanelTabBar.titles, widgetTitle) > -1) {
1832
- return leftPanelTabBar;
1833
- }
1834
- const rightPanelTabBar = this.rightPanelHandler.tabBar;
1835
- if (ArrayExt.firstIndexOf(rightPanelTabBar.titles, widgetTitle) > -1) {
1836
- return rightPanelTabBar;
1837
- }
1838
- return undefined;
1839
- }
1840
-
1841
- /**
1842
- * The tab bars contained in the main shell area. If there is no widget in the main area, the
1843
- * returned array is empty.
1844
- */
1845
- get mainAreaTabBars(): TabBar<Widget>[] {
1846
- return toArray(this.mainPanel.tabBars());
1847
- }
1848
-
1849
- /**
1850
- * The tab bars contained in the bottom shell area. If there is no widget in the bottom area,
1851
- * the returned array is empty.
1852
- */
1853
- get bottomAreaTabBars(): TabBar<Widget>[] {
1854
- return toArray(this.bottomPanel.tabBars());
1855
- }
1856
-
1857
- /**
1858
- * The tab bars contained in all shell areas.
1859
- */
1860
- get allTabBars(): TabBar<Widget>[] {
1861
- return [...this.mainAreaTabBars, ...this.bottomAreaTabBars, this.leftPanelHandler.tabBar, this.rightPanelHandler.tabBar];
1862
- }
1863
-
1864
- /*
1865
- * Activate the next tab in the current tab bar.
1866
- */
1867
- activateNextTabInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1868
- const index = this.nextTabIndexInTabBar(current);
1869
- if (!current || index === -1) {
1870
- return false;
1871
- }
1872
- current.currentIndex = index;
1873
- if (current.currentTitle) {
1874
- this.activateWidget(current.currentTitle.owner.id);
1875
- }
1876
- return true;
1877
- }
1878
-
1879
- nextTabIndexInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): number {
1880
- if (!current || current.titles.length <= 1) {
1881
- return -1;
1882
- }
1883
- const index = current.currentIndex;
1884
- if (index === -1) {
1885
- return -1;
1886
- }
1887
- if (index < current.titles.length - 1) {
1888
- return index + 1;
1889
- }
1890
- return 0;
1891
- }
1892
-
1893
- activateNextTab(): boolean {
1894
- const current = this.currentTabBar;
1895
- if (current) {
1896
- const ci = current.currentIndex;
1897
- if (ci !== -1) {
1898
- if (ci < current.titles.length - 1) {
1899
- current.currentIndex += 1;
1900
- if (current.currentTitle) {
1901
- this.activateWidget(current.currentTitle.owner.id);
1902
- }
1903
- return true;
1904
- } else if (ci === current.titles.length - 1) {
1905
- return this.activateNextTabBar(current);
1906
- }
1907
- }
1908
- }
1909
- return false;
1910
- }
1911
-
1912
- activateNextTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1913
- const nextBar = this.nextTabBar(current);
1914
- if (nextBar) {
1915
- nextBar.currentIndex = 0;
1916
- if (nextBar.currentTitle) {
1917
- this.activateWidget(nextBar.currentTitle.owner.id);
1918
- }
1919
- return true;
1920
- }
1921
- return false;
1922
- }
1923
-
1924
- /**
1925
- * Return the tab bar next to the given tab bar; return the given tab bar if there is no adjacent one.
1926
- */
1927
- nextTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): TabBar<Widget> | undefined {
1928
- let bars = toArray(this.bottomPanel.tabBars());
1929
- let len = bars.length;
1930
- let ci = ArrayExt.firstIndexOf(bars, current);
1931
- if (ci < 0) {
1932
- bars = toArray(this.mainPanel.tabBars());
1933
- len = bars.length;
1934
- ci = ArrayExt.firstIndexOf(bars, current);
1935
- }
1936
- if (ci >= 0 && ci < len - 1) {
1937
- return bars[ci + 1];
1938
- } else if (ci >= 0 && ci === len - 1) {
1939
- return bars[0];
1940
- } else {
1941
- return current;
1942
- }
1943
- }
1944
-
1945
- /*
1946
- * Activate the previous tab in the current tab bar.
1947
- */
1948
- activatePreviousTabInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1949
- const index = this.previousTabIndexInTabBar(current);
1950
- if (!current || index === -1) {
1951
- return false;
1952
- }
1953
- current.currentIndex = index;
1954
- if (current.currentTitle) {
1955
- this.activateWidget(current.currentTitle.owner.id);
1956
- }
1957
- return true;
1958
- }
1959
-
1960
- previousTabIndexInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): number {
1961
- if (!current || current.titles.length <= 1) {
1962
- return -1;
1963
- }
1964
- const index = current.currentIndex;
1965
- if (index === -1) {
1966
- return -1;
1967
- }
1968
- if (index > 0) {
1969
- return index - 1;
1970
- }
1971
- return current.titles.length - 1;
1972
- }
1973
-
1974
- activatePreviousTab(): boolean {
1975
- const current = this.currentTabBar;
1976
- if (current) {
1977
- const ci = current.currentIndex;
1978
- if (ci !== -1) {
1979
- if (ci > 0) {
1980
- current.currentIndex -= 1;
1981
- if (current.currentTitle) {
1982
- this.activateWidget(current.currentTitle.owner.id);
1983
- }
1984
- return true;
1985
- } else if (ci === 0) {
1986
- if (current && current.titles.length > 0) {
1987
- current.currentIndex = current.titles.length - 1;
1988
- if (current.currentTitle) {
1989
- this.activateWidget(current.currentTitle.owner.id);
1990
- }
1991
- return true;
1992
- }
1993
- return this.activatePreviousTabBar(current);
1994
- }
1995
- }
1996
- }
1997
- return false;
1998
- }
1999
-
2000
- activatePreviousTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
2001
- const prevBar = this.previousTabBar(current);
2002
- if (!prevBar) {
2003
- return false;
2004
- }
2005
- if (!prevBar.currentTitle) {
2006
- prevBar.currentIndex = prevBar.titles.length - 1;
2007
- }
2008
- if (prevBar.currentTitle) {
2009
- this.activateWidget(prevBar.currentTitle.owner.id);
2010
- }
2011
- return true;
2012
- }
2013
-
2014
- /**
2015
- * Return the tab bar previous to the given tab bar; return the given tab bar if there is no adjacent one.
2016
- */
2017
- previousTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): TabBar<Widget> | undefined {
2018
- const bars = toArray(this.mainPanel.tabBars());
2019
- const len = bars.length;
2020
- const ci = ArrayExt.firstIndexOf(bars, current);
2021
- if (ci > 0) {
2022
- return bars[ci - 1];
2023
- } else if (ci === 0) {
2024
- return bars[len - 1];
2025
- } else {
2026
- return current;
2027
- }
2028
- }
2029
-
2030
- /**
2031
- * Test whether the current widget is dirty.
2032
- */
2033
- canSave(): boolean {
2034
- return this.saveResourceService.canSave(this.currentWidget);
2035
- }
2036
-
2037
- /**
2038
- * Save the current widget if it is dirty.
2039
- */
2040
- async save(options?: SaveOptions): Promise<void> {
2041
- await this.saveResourceService.save(this.currentWidget, options);
2042
- }
2043
-
2044
- /**
2045
- * Test whether there is a dirty widget.
2046
- */
2047
- canSaveAll(): boolean {
2048
- return this.tracker.widgets.some(widget => this.saveResourceService.canSave(widget));
2049
- }
2050
-
2051
- /**
2052
- * Save all dirty widgets.
2053
- */
2054
- async saveAll(options?: SaveOptions): Promise<void> {
2055
- for (const widget of this.widgets) {
2056
- if (this.saveResourceService.canSaveNotSaveAs(widget)) {
2057
- await this.saveResourceService.save(widget, options);
2058
- }
2059
- }
2060
- }
2061
-
2062
- /**
2063
- * Returns a snapshot of all tracked widgets to allow async modifications.
2064
- */
2065
- get widgets(): ReadonlyArray<Widget> {
2066
- return [...this.tracker.widgets];
2067
- }
2068
-
2069
- getWidgetById(id: string): Widget | undefined {
2070
- for (const widget of this.tracker.widgets) {
2071
- if (widget.id === id) {
2072
- return widget;
2073
- }
2074
- }
2075
- return undefined;
2076
- }
2077
-
2078
- canToggleMaximized(widget: Widget | undefined = this.currentWidget): boolean {
2079
- const area = widget && this.getAreaFor(widget);
2080
- return area === 'main' || area === 'bottom';
2081
- }
2082
-
2083
- toggleMaximized(widget: Widget | undefined = this.currentWidget): void {
2084
- const area = widget && this.getAreaPanelFor(widget);
2085
- if (area instanceof TheiaDockPanel && (area === this.mainPanel || area === this.bottomPanel)) {
2086
- area.toggleMaximized();
2087
- this.revealWidget(widget!.id);
2088
- }
2089
- }
2090
-
2091
- }
2092
-
2093
- /**
2094
- * The namespace for `ApplicationShell` class statics.
2095
- */
2096
- export namespace ApplicationShell {
2097
- /**
2098
- * The areas of the application shell where widgets can reside.
2099
- */
2100
- export type Area = 'main' | 'top' | 'left' | 'right' | 'bottom' | 'secondaryWindow';
2101
-
2102
- export const areaLabels: Record<Area, string> = {
2103
- main: nls.localizeByDefault('Main'),
2104
- top: nls.localizeByDefault('Top'),
2105
- left: nls.localizeByDefault('Left'),
2106
- right: nls.localizeByDefault('Right'),
2107
- bottom: nls.localizeByDefault('Bottom'),
2108
- secondaryWindow: nls.localize('theia/shell-area/secondary', 'Secondary Window'),
2109
- };
2110
-
2111
- /**
2112
- * The _side areas_ are those shell areas that can be collapsed and expanded,
2113
- * i.e. `left`, `right`, and `bottom`.
2114
- */
2115
- export function isSideArea(area?: string): area is 'left' | 'right' | 'bottom' {
2116
- return area === 'left' || area === 'right' || area === 'bottom';
2117
- }
2118
-
2119
- export function isValidArea(area?: unknown): area is ApplicationShell.Area {
2120
- const areas = ['main', 'top', 'left', 'right', 'bottom', 'secondaryWindow'];
2121
- return typeof area === 'string' && areas.includes(area);
2122
- }
2123
-
2124
- /**
2125
- * General options for the application shell. These are passed on construction and can be modified
2126
- * through dependency injection (`ApplicationShellOptions` symbol).
2127
- */
2128
- export interface Options extends Widget.IOptions {
2129
- bottomPanel: BottomPanelOptions;
2130
- leftPanel: SidePanel.Options;
2131
- rightPanel: SidePanel.Options;
2132
- }
2133
-
2134
- export interface BottomPanelOptions extends SidePanel.Options {
2135
- }
2136
-
2137
- /**
2138
- * The default values for application shell options.
2139
- */
2140
- export const DEFAULT_OPTIONS = Object.freeze(<Options>{
2141
- bottomPanel: Object.freeze(<BottomPanelOptions>{
2142
- emptySize: 140,
2143
- expandThreshold: 160,
2144
- expandDuration: 0,
2145
- initialSizeRatio: 0.382
2146
- }),
2147
- leftPanel: Object.freeze(<SidePanel.Options>{
2148
- emptySize: 140,
2149
- expandThreshold: 140,
2150
- expandDuration: 0,
2151
- initialSizeRatio: 0.191
2152
- }),
2153
- rightPanel: Object.freeze(<SidePanel.Options>{
2154
- emptySize: 140,
2155
- expandThreshold: 140,
2156
- expandDuration: 0,
2157
- initialSizeRatio: 0.191
2158
- })
2159
- });
2160
-
2161
- /**
2162
- * Whether a widget should be opened to the side tab bar relatively to the reference widget.
2163
- */
2164
- export type OpenToSideMode = 'open-to-left' | 'open-to-right';
2165
-
2166
- export function isOpenToSideMode(mode: unknown): mode is OpenToSideMode {
2167
- return mode === 'open-to-left' || mode === 'open-to-right';
2168
- }
2169
-
2170
- /**
2171
- * Options for adding a widget to the application shell.
2172
- */
2173
- export interface WidgetOptions extends SidePanel.WidgetOptions {
2174
- /**
2175
- * The area of the application shell where the widget will reside.
2176
- */
2177
- area?: Area;
2178
- /**
2179
- * The insertion mode for adding the widget.
2180
- *
2181
- * The default is `'tab-after'`.
2182
- */
2183
- mode?: DockLayout.InsertMode | OpenToSideMode
2184
- /**
2185
- * The reference widget for the insert location.
2186
- *
2187
- * The default is `undefined`.
2188
- */
2189
- ref?: Widget;
2190
- }
2191
-
2192
- export interface CloseOptions {
2193
- /**
2194
- * if optional then a user will be prompted
2195
- * if undefined then close will be canceled
2196
- * if true then will be saved on close
2197
- * if false then won't be saved on close
2198
- */
2199
- save?: boolean | undefined
2200
- }
2201
-
2202
- /**
2203
- * Data to save and load the application shell layout.
2204
- */
2205
- export interface LayoutData {
2206
- version?: string | ApplicationShellLayoutVersion,
2207
- mainPanel?: DockPanel.ILayoutConfig;
2208
- mainPanelPinned?: boolean[];
2209
- bottomPanel?: BottomPanelLayoutData;
2210
- leftPanel?: SidePanel.LayoutData;
2211
- rightPanel?: SidePanel.LayoutData;
2212
- activeWidgetId?: string;
2213
- }
2214
-
2215
- /**
2216
- * Data to save and load the bottom panel layout.
2217
- */
2218
- export interface BottomPanelLayoutData {
2219
- config?: DockPanel.ILayoutConfig;
2220
- size?: number;
2221
- expanded?: boolean;
2222
- pinned?: boolean[];
2223
- }
2224
-
2225
- /**
2226
- * Exposes widgets which activation state should be tracked by shell.
2227
- */
2228
- export interface TrackableWidgetProvider {
2229
- getTrackableWidgets(): Widget[]
2230
- readonly onDidChangeTrackableWidgets?: CommonEvent<Widget[]>
2231
- /**
2232
- * Make visible and focus a trackable widget for the given id.
2233
- * If not implemented then `activate` request will be sent to a child widget directly.
2234
- */
2235
- activateWidget?(id: string): Widget | undefined;
2236
- /**
2237
- * Make visible a trackable widget for the given id.
2238
- * If not implemented then a widget should be always visible when an owner is visible.
2239
- */
2240
- revealWidget?(id: string): Widget | undefined;
2241
- }
2242
-
2243
- export namespace TrackableWidgetProvider {
2244
- export function is(widget: unknown): widget is TrackableWidgetProvider {
2245
- return isObject(widget) && 'getTrackableWidgets' in widget;
2246
- }
2247
- }
2248
-
2249
- }
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 { injectable, inject, optional, postConstruct } from 'inversify';
18
+ import { ArrayExt, find, toArray, each } from '@phosphor/algorithm';
19
+ import {
20
+ BoxLayout, BoxPanel, DockLayout, DockPanel, FocusTracker, Layout, Panel, SplitLayout,
21
+ SplitPanel, TabBar, Widget, Title
22
+ } from '@phosphor/widgets';
23
+ import { Message } from '@phosphor/messaging';
24
+ import { IDragEvent } from '@phosphor/dragdrop';
25
+ import { RecursivePartial, Event as CommonEvent, DisposableCollection, Disposable, environment, isObject } from '../../common';
26
+ import { animationFrame } from '../browser';
27
+ import { Saveable, SaveableWidget, SaveOptions, SaveableSource } from '../saveable';
28
+ import { StatusBarImpl, StatusBarEntry, StatusBarAlignment } from '../status-bar/status-bar';
29
+ import { TheiaDockPanel, BOTTOM_AREA_ID, MAIN_AREA_ID } from './theia-dock-panel';
30
+ import { SidePanelHandler, SidePanel, SidePanelHandlerFactory } from './side-panel-handler';
31
+ import { TabBarRendererFactory, SHELL_TABBAR_CONTEXT_MENU, ScrollableTabBar, ToolbarAwareTabBar } from './tab-bars';
32
+ import { SplitPositionHandler, SplitPositionOptions } from './split-panels';
33
+ import { FrontendApplicationStateService } from '../frontend-application-state';
34
+ import { TabBarToolbarRegistry, TabBarToolbarFactory } from './tab-bar-toolbar';
35
+ import { ContextKeyService } from '../context-key-service';
36
+ import { Emitter } from '../../common/event';
37
+ import { waitForRevealed, waitForClosed, PINNED_CLASS } from '../widgets';
38
+ import { CorePreferences } from '../core-preferences';
39
+ import { BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer';
40
+ import { Deferred } from '../../common/promise-util';
41
+ import { SaveResourceService } from '../save-resource-service';
42
+ import { nls } from '../../common/nls';
43
+ import { SecondaryWindowHandler } from '../secondary-window-handler';
44
+ import URI from '../../common/uri';
45
+ import { OpenerService } from '../opener-service';
46
+ import { PreviewableWidget } from '../widgets/previewable-widget';
47
+
48
+ /** The class name added to ApplicationShell instances. */
49
+ const APPLICATION_SHELL_CLASS = 'theia-ApplicationShell';
50
+ /** The class name added to the main and bottom area panels. */
51
+ const MAIN_BOTTOM_AREA_CLASS = 'theia-app-centers';
52
+ /** Status bar entry identifier for the bottom panel toggle button. */
53
+ const BOTTOM_PANEL_TOGGLE_ID = 'bottom-panel-toggle';
54
+ /** The class name added to the main area panel. */
55
+ const MAIN_AREA_CLASS = 'theia-app-main';
56
+ /** The class name added to the bottom area panel. */
57
+ const BOTTOM_AREA_CLASS = 'theia-app-bottom';
58
+
59
+ export type ApplicationShellLayoutVersion =
60
+ /** layout versioning is introduced, unversioned layout are not compatible */
61
+ 2.0 |
62
+ /** view containers are introduced, backward compatible to 2.0 */
63
+ 3.0 |
64
+ /** git history view is replaced by a more generic scm history view, backward compatible to 3.0 */
65
+ 4.0 |
66
+ /** Replace custom/font-awesome icons with codicons */
67
+ 5.0 |
68
+ /** added the ability to drag and drop view parts between view containers */
69
+ 6.0;
70
+
71
+ /**
72
+ * When a version is increased, make sure to introduce a migration (ApplicationShellLayoutMigration) to this version.
73
+ */
74
+ export const applicationShellLayoutVersion: ApplicationShellLayoutVersion = 5.0;
75
+
76
+ export const ApplicationShellOptions = Symbol('ApplicationShellOptions');
77
+ export const DockPanelRendererFactory = Symbol('DockPanelRendererFactory');
78
+ export interface DockPanelRendererFactory {
79
+ (): DockPanelRenderer
80
+ }
81
+
82
+ /**
83
+ * A renderer for dock panels that supports context menus on tabs.
84
+ */
85
+ @injectable()
86
+ export class DockPanelRenderer implements DockLayout.IRenderer {
87
+
88
+ @inject(TheiaDockPanel.Factory)
89
+ protected readonly dockPanelFactory: TheiaDockPanel.Factory;
90
+
91
+ readonly tabBarClasses: string[] = [];
92
+
93
+ private readonly onDidCreateTabBarEmitter = new Emitter<TabBar<Widget>>();
94
+
95
+ constructor(
96
+ @inject(TabBarRendererFactory) protected readonly tabBarRendererFactory: TabBarRendererFactory,
97
+ @inject(TabBarToolbarRegistry) protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry,
98
+ @inject(TabBarToolbarFactory) protected readonly tabBarToolbarFactory: TabBarToolbarFactory,
99
+ @inject(BreadcrumbsRendererFactory) protected readonly breadcrumbsRendererFactory: BreadcrumbsRendererFactory,
100
+ @inject(CorePreferences) protected readonly corePreferences: CorePreferences
101
+ ) { }
102
+
103
+ get onDidCreateTabBar(): CommonEvent<TabBar<Widget>> {
104
+ return this.onDidCreateTabBarEmitter.event;
105
+ }
106
+
107
+ createTabBar(): TabBar<Widget> {
108
+ const getDynamicTabOptions: () => ScrollableTabBar.Options | undefined = () => {
109
+ if (this.corePreferences.get('workbench.tab.shrinkToFit.enabled')) {
110
+ return {
111
+ minimumTabSize: this.corePreferences.get('workbench.tab.shrinkToFit.minimumSize'),
112
+ defaultTabSize: this.corePreferences.get('workbench.tab.shrinkToFit.defaultSize')
113
+ };
114
+ } else {
115
+ return undefined;
116
+ }
117
+ };
118
+
119
+ const renderer = this.tabBarRendererFactory();
120
+ const tabBar = new ToolbarAwareTabBar(
121
+ this.tabBarToolbarRegistry,
122
+ this.tabBarToolbarFactory,
123
+ this.breadcrumbsRendererFactory,
124
+ {
125
+ renderer,
126
+ // Scroll bar options
127
+ handlers: ['drag-thumb', 'keyboard', 'wheel', 'touch'],
128
+ useBothWheelAxes: true,
129
+ scrollXMarginOffset: 4,
130
+ suppressScrollY: true
131
+ },
132
+ getDynamicTabOptions());
133
+ this.tabBarClasses.forEach(c => tabBar.addClass(c));
134
+ renderer.tabBar = tabBar;
135
+ renderer.contextMenuPath = SHELL_TABBAR_CONTEXT_MENU;
136
+ tabBar.currentChanged.connect(this.onCurrentTabChanged, this);
137
+ const prefChangeDisposable = this.corePreferences.onPreferenceChanged(change => {
138
+ if (change.preferenceName === 'workbench.tab.shrinkToFit.enabled' ||
139
+ change.preferenceName === 'workbench.tab.shrinkToFit.minimumSize' ||
140
+ change.preferenceName === 'workbench.tab.shrinkToFit.defaultSize') {
141
+ tabBar.dynamicTabOptions = getDynamicTabOptions();
142
+ }
143
+ });
144
+ tabBar.disposed.connect(() => {
145
+ prefChangeDisposable.dispose();
146
+ renderer.dispose();
147
+ });
148
+ this.onDidCreateTabBarEmitter.fire(tabBar);
149
+ return tabBar;
150
+ }
151
+
152
+ createHandle(): HTMLDivElement {
153
+ return DockPanel.defaultRenderer.createHandle();
154
+ }
155
+
156
+ protected onCurrentTabChanged(sender: ToolbarAwareTabBar, { currentIndex }: TabBar.ICurrentChangedArgs<Widget>): void {
157
+ if (currentIndex >= 0) {
158
+ sender.revealTab(currentIndex);
159
+ }
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Data stored while dragging widgets in the shell.
165
+ */
166
+ interface WidgetDragState {
167
+ startTime: number;
168
+ leftExpanded: boolean;
169
+ rightExpanded: boolean;
170
+ bottomExpanded: boolean;
171
+ lastDragOver?: IDragEvent;
172
+ leaveTimeout?: number;
173
+ }
174
+
175
+ /**
176
+ * The application shell manages the top-level widgets of the application. Use this class to
177
+ * add, remove, or activate a widget.
178
+ */
179
+ @injectable()
180
+ export class ApplicationShell extends Widget {
181
+
182
+ /**
183
+ * The dock panel in the main shell area. This is where editors usually go to.
184
+ */
185
+ mainPanel: TheiaDockPanel;
186
+
187
+ /**
188
+ * The dock panel in the bottom shell area. In contrast to the main panel, the bottom panel
189
+ * can be collapsed and expanded.
190
+ */
191
+ bottomPanel: TheiaDockPanel;
192
+
193
+ /**
194
+ * Handler for the left side panel. The primary application views go here, such as the
195
+ * file explorer and the git view.
196
+ */
197
+ leftPanelHandler: SidePanelHandler;
198
+
199
+ /**
200
+ * Handler for the right side panel. The secondary application views go here, such as the
201
+ * outline view.
202
+ */
203
+ rightPanelHandler: SidePanelHandler;
204
+
205
+ /**
206
+ * General options for the application shell.
207
+ */
208
+ protected options: ApplicationShell.Options;
209
+
210
+ /**
211
+ * The fixed-size panel shown on top. This one usually holds the main menu.
212
+ */
213
+ topPanel: Panel;
214
+
215
+ /**
216
+ * The current state of the bottom panel.
217
+ */
218
+ protected readonly bottomPanelState: SidePanel.State = {
219
+ empty: true,
220
+ expansion: SidePanel.ExpansionState.collapsed,
221
+ pendingUpdate: Promise.resolve()
222
+ };
223
+
224
+ private readonly tracker = new FocusTracker<Widget>();
225
+ private dragState?: WidgetDragState;
226
+ additionalDraggedUris: URI[] | undefined;
227
+
228
+ @inject(ContextKeyService)
229
+ protected readonly contextKeyService: ContextKeyService;
230
+
231
+ @inject(OpenerService)
232
+ protected readonly openerService: OpenerService;
233
+
234
+ protected readonly onDidAddWidgetEmitter = new Emitter<Widget>();
235
+ readonly onDidAddWidget = this.onDidAddWidgetEmitter.event;
236
+ protected fireDidAddWidget(widget: Widget): void {
237
+ this.onDidAddWidgetEmitter.fire(widget);
238
+ }
239
+
240
+ protected readonly onDidRemoveWidgetEmitter = new Emitter<Widget>();
241
+ readonly onDidRemoveWidget = this.onDidRemoveWidgetEmitter.event;
242
+ protected fireDidRemoveWidget(widget: Widget): void {
243
+ this.onDidRemoveWidgetEmitter.fire(widget);
244
+ }
245
+
246
+ protected readonly onDidChangeActiveWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
247
+ readonly onDidChangeActiveWidget = this.onDidChangeActiveWidgetEmitter.event;
248
+
249
+ protected readonly onDidChangeCurrentWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
250
+ readonly onDidChangeCurrentWidget = this.onDidChangeCurrentWidgetEmitter.event;
251
+
252
+ protected readonly onDidDoubleClickMainAreaEmitter = new Emitter<void>();
253
+ readonly onDidDoubleClickMainArea = this.onDidDoubleClickMainAreaEmitter.event;
254
+
255
+ @inject(TheiaDockPanel.Factory)
256
+ protected readonly dockPanelFactory: TheiaDockPanel.Factory;
257
+
258
+ private _mainPanelRenderer: DockPanelRenderer;
259
+ get mainPanelRenderer(): DockPanelRenderer {
260
+ return this._mainPanelRenderer;
261
+ }
262
+
263
+ /**
264
+ * Construct a new application shell.
265
+ */
266
+ constructor(
267
+ @inject(DockPanelRendererFactory) protected dockPanelRendererFactory: () => DockPanelRenderer,
268
+ @inject(StatusBarImpl) protected readonly statusBar: StatusBarImpl,
269
+ @inject(SidePanelHandlerFactory) protected readonly sidePanelHandlerFactory: () => SidePanelHandler,
270
+ @inject(SplitPositionHandler) protected splitPositionHandler: SplitPositionHandler,
271
+ @inject(FrontendApplicationStateService) protected readonly applicationStateService: FrontendApplicationStateService,
272
+ @inject(ApplicationShellOptions) @optional() options: RecursivePartial<ApplicationShell.Options> = {},
273
+ @inject(CorePreferences) protected readonly corePreferences: CorePreferences,
274
+ @inject(SaveResourceService) protected readonly saveResourceService: SaveResourceService,
275
+ @inject(SecondaryWindowHandler) protected readonly secondaryWindowHandler: SecondaryWindowHandler,
276
+ ) {
277
+ super(options as Widget.IOptions);
278
+
279
+ // Merge the user-defined application options with the default options
280
+ this.options = {
281
+ bottomPanel: {
282
+ ...ApplicationShell.DEFAULT_OPTIONS.bottomPanel,
283
+ ...options?.bottomPanel || {}
284
+ },
285
+ leftPanel: {
286
+ ...ApplicationShell.DEFAULT_OPTIONS.leftPanel,
287
+ ...options?.leftPanel || {}
288
+ },
289
+ rightPanel: {
290
+ ...ApplicationShell.DEFAULT_OPTIONS.rightPanel,
291
+ ...options?.rightPanel || {}
292
+ }
293
+ };
294
+ }
295
+
296
+ @postConstruct()
297
+ protected init(): void {
298
+ this.initializeShell();
299
+ this.initSidebarVisibleKeyContext();
300
+ this.initFocusKeyContexts();
301
+
302
+ if (!environment.electron.is()) {
303
+ this.corePreferences.ready.then(() => {
304
+ this.setTopPanelVisibility(this.corePreferences['window.menuBarVisibility']);
305
+ });
306
+ this.corePreferences.onPreferenceChanged(preference => {
307
+ if (preference.preferenceName === 'window.menuBarVisibility') {
308
+ this.setTopPanelVisibility(preference.newValue);
309
+ }
310
+ });
311
+ }
312
+
313
+ this.corePreferences.onPreferenceChanged(preference => {
314
+ if (preference.preferenceName === 'window.tabbar.enhancedPreview') {
315
+ this.allTabBars.forEach(tabBar => {
316
+ tabBar.update();
317
+ });
318
+ }
319
+ });
320
+ }
321
+
322
+ protected initializeShell(): void {
323
+ this.addClass(APPLICATION_SHELL_CLASS);
324
+ this.id = 'theia-app-shell';
325
+
326
+ this.mainPanel = this.createMainPanel();
327
+ this.topPanel = this.createTopPanel();
328
+ this.bottomPanel = this.createBottomPanel();
329
+
330
+ this.leftPanelHandler = this.sidePanelHandlerFactory();
331
+ this.leftPanelHandler.create('left', this.options.leftPanel);
332
+ this.leftPanelHandler.dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
333
+ this.leftPanelHandler.dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
334
+
335
+ this.rightPanelHandler = this.sidePanelHandlerFactory();
336
+ this.rightPanelHandler.create('right', this.options.rightPanel);
337
+ this.rightPanelHandler.dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
338
+ this.rightPanelHandler.dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
339
+
340
+ this.secondaryWindowHandler.init(this);
341
+ this.secondaryWindowHandler.onDidAddWidget(widget => this.fireDidAddWidget(widget));
342
+ this.secondaryWindowHandler.onDidRemoveWidget(widget => this.fireDidRemoveWidget(widget));
343
+
344
+ this.layout = this.createLayout();
345
+
346
+ this.tracker.currentChanged.connect(this.onCurrentChanged, this);
347
+ this.tracker.activeChanged.connect(this.onActiveChanged, this);
348
+ }
349
+
350
+ protected initSidebarVisibleKeyContext(): void {
351
+ const leftSideBarPanel = this.leftPanelHandler.dockPanel;
352
+ const sidebarVisibleKey = this.contextKeyService.createKey('sidebarVisible', leftSideBarPanel.isVisible);
353
+ const onAfterShow = leftSideBarPanel['onAfterShow'].bind(leftSideBarPanel);
354
+ leftSideBarPanel['onAfterShow'] = (msg: Message) => {
355
+ onAfterShow(msg);
356
+ sidebarVisibleKey.set(true);
357
+ };
358
+ const onAfterHide = leftSideBarPanel['onAfterHide'].bind(leftSideBarPanel);
359
+ leftSideBarPanel['onAfterHide'] = (msg: Message) => {
360
+ onAfterHide(msg);
361
+ sidebarVisibleKey.set(false);
362
+ };
363
+ }
364
+
365
+ protected initFocusKeyContexts(): void {
366
+ const sideBarFocus = this.contextKeyService.createKey<boolean>('sideBarFocus', false);
367
+ const panelFocus = this.contextKeyService.createKey<boolean>('panelFocus', false);
368
+ const updateFocusContextKeys = () => {
369
+ const area = this.activeWidget && this.getAreaFor(this.activeWidget);
370
+ sideBarFocus.set(area === 'left');
371
+ panelFocus.set(area === 'main');
372
+ };
373
+ updateFocusContextKeys();
374
+ this.onDidChangeActiveWidget(updateFocusContextKeys);
375
+ }
376
+
377
+ protected setTopPanelVisibility(preference: string): void {
378
+ const hiddenPreferences = ['compact', 'hidden'];
379
+ this.topPanel.setHidden(hiddenPreferences.includes(preference));
380
+ }
381
+
382
+ protected override onBeforeAttach(msg: Message): void {
383
+ document.addEventListener('p-dragenter', this, true);
384
+ document.addEventListener('p-dragover', this, true);
385
+ document.addEventListener('p-dragleave', this, true);
386
+ document.addEventListener('p-drop', this, true);
387
+ }
388
+
389
+ protected override onAfterDetach(msg: Message): void {
390
+ document.removeEventListener('p-dragenter', this, true);
391
+ document.removeEventListener('p-dragover', this, true);
392
+ document.removeEventListener('p-dragleave', this, true);
393
+ document.removeEventListener('p-drop', this, true);
394
+ }
395
+
396
+ handleEvent(event: Event): void {
397
+ switch (event.type) {
398
+ case 'p-dragenter':
399
+ this.onDragEnter(event as IDragEvent);
400
+ break;
401
+ case 'p-dragover':
402
+ this.onDragOver(event as IDragEvent);
403
+ break;
404
+ case 'p-drop':
405
+ this.onDrop(event as IDragEvent);
406
+ break;
407
+ case 'p-dragleave':
408
+ this.onDragLeave(event as IDragEvent);
409
+ break;
410
+ }
411
+ }
412
+
413
+ protected onDragEnter({ mimeData }: IDragEvent): void {
414
+ if (!this.dragState) {
415
+ if (mimeData && mimeData.hasData('application/vnd.phosphor.widget-factory')) {
416
+ // The drag contains a widget, so we'll track it and expand side panels as needed
417
+ this.dragState = {
418
+ startTime: performance.now(),
419
+ leftExpanded: false,
420
+ rightExpanded: false,
421
+ bottomExpanded: false
422
+ };
423
+ }
424
+ }
425
+ }
426
+
427
+ protected onDragOver(event: IDragEvent): void {
428
+ const state = this.dragState;
429
+ if (state) {
430
+ state.lastDragOver = event;
431
+ if (state.leaveTimeout) {
432
+ window.clearTimeout(state.leaveTimeout);
433
+ state.leaveTimeout = undefined;
434
+ }
435
+ const { clientX, clientY } = event;
436
+ const { offsetLeft, offsetTop, clientWidth, clientHeight } = this.node;
437
+
438
+ // Don't expand any side panels right after the drag has started
439
+ const allowExpansion = performance.now() - state.startTime >= 500;
440
+ const expLeft = allowExpansion && clientX >= offsetLeft
441
+ && clientX <= offsetLeft + this.options.leftPanel.expandThreshold;
442
+ const expRight = allowExpansion && clientX <= offsetLeft + clientWidth
443
+ && clientX >= offsetLeft + clientWidth - this.options.rightPanel.expandThreshold;
444
+ const expBottom = allowExpansion && !expLeft && !expRight && clientY <= offsetTop + clientHeight
445
+ && clientY >= offsetTop + clientHeight - this.options.bottomPanel.expandThreshold;
446
+ // eslint-disable-next-line no-null/no-null
447
+ if (expLeft && !state.leftExpanded && this.leftPanelHandler.tabBar.currentTitle === null) {
448
+ // The mouse cursor is moved close to the left border
449
+ this.leftPanelHandler.expand();
450
+ this.leftPanelHandler.state.pendingUpdate.then(() => this.dispatchMouseMove());
451
+ state.leftExpanded = true;
452
+ } else if (!expLeft && state.leftExpanded) {
453
+ // The mouse cursor is moved away from the left border
454
+ this.leftPanelHandler.collapse();
455
+ state.leftExpanded = false;
456
+ }
457
+ // eslint-disable-next-line no-null/no-null
458
+ if (expRight && !state.rightExpanded && this.rightPanelHandler.tabBar.currentTitle === null) {
459
+ // The mouse cursor is moved close to the right border
460
+ this.rightPanelHandler.expand();
461
+ this.rightPanelHandler.state.pendingUpdate.then(() => this.dispatchMouseMove());
462
+ state.rightExpanded = true;
463
+ } else if (!expRight && state.rightExpanded) {
464
+ // The mouse cursor is moved away from the right border
465
+ this.rightPanelHandler.collapse();
466
+ state.rightExpanded = false;
467
+ }
468
+ if (expBottom && !state.bottomExpanded && this.bottomPanel.isHidden) {
469
+ // The mouse cursor is moved close to the bottom border
470
+ this.expandBottomPanel();
471
+ this.bottomPanelState.pendingUpdate.then(() => this.dispatchMouseMove());
472
+ state.bottomExpanded = true;
473
+ } else if (!expBottom && state.bottomExpanded) {
474
+ // The mouse cursor is moved away from the bottom border
475
+ this.collapseBottomPanel();
476
+ state.bottomExpanded = false;
477
+ }
478
+ }
479
+ }
480
+
481
+ /**
482
+ * This method is called after a side panel has been expanded while dragging a widget. It fires
483
+ * a `mousemove` event so that the drag overlay markers are updated correctly in all dock panels.
484
+ */
485
+ private dispatchMouseMove(): void {
486
+ if (this.dragState && this.dragState.lastDragOver) {
487
+ const { clientX, clientY } = this.dragState.lastDragOver;
488
+ const event = document.createEvent('MouseEvent');
489
+ event.initMouseEvent('mousemove', true, true, window, 0, 0, 0,
490
+ // eslint-disable-next-line no-null/no-null
491
+ clientX, clientY, false, false, false, false, 0, null);
492
+ document.dispatchEvent(event);
493
+ }
494
+ }
495
+
496
+ protected onDrop(event: IDragEvent): void {
497
+ const state = this.dragState;
498
+ if (state) {
499
+ if (state.leaveTimeout) {
500
+ window.clearTimeout(state.leaveTimeout);
501
+ }
502
+ this.dragState = undefined;
503
+ window.requestAnimationFrame(() => {
504
+ // Clean up the side panel state in the next frame
505
+ if (this.leftPanelHandler.dockPanel.isEmpty) {
506
+ this.leftPanelHandler.collapse();
507
+ }
508
+ if (this.rightPanelHandler.dockPanel.isEmpty) {
509
+ this.rightPanelHandler.collapse();
510
+ }
511
+ if (this.bottomPanel.isEmpty) {
512
+ this.collapseBottomPanel();
513
+ }
514
+ });
515
+ }
516
+ }
517
+
518
+ protected onDragLeave(event: IDragEvent): void {
519
+ const state = this.dragState;
520
+ if (state) {
521
+ state.lastDragOver = undefined;
522
+ if (state.leaveTimeout) {
523
+ window.clearTimeout(state.leaveTimeout);
524
+ }
525
+ state.leaveTimeout = window.setTimeout(() => {
526
+ this.dragState = undefined;
527
+ if (state.leftExpanded || this.leftPanelHandler.dockPanel.isEmpty) {
528
+ this.leftPanelHandler.collapse();
529
+ }
530
+ if (state.rightExpanded || this.rightPanelHandler.dockPanel.isEmpty) {
531
+ this.rightPanelHandler.collapse();
532
+ }
533
+ if (state.bottomExpanded || this.bottomPanel.isEmpty) {
534
+ this.collapseBottomPanel();
535
+ }
536
+ }, 100);
537
+ }
538
+ }
539
+
540
+ /**
541
+ * Create the dock panel in the main shell area.
542
+ */
543
+ protected createMainPanel(): TheiaDockPanel {
544
+ const renderer = this.dockPanelRendererFactory();
545
+ renderer.tabBarClasses.push(MAIN_BOTTOM_AREA_CLASS);
546
+ renderer.tabBarClasses.push(MAIN_AREA_CLASS);
547
+ this._mainPanelRenderer = renderer;
548
+ const dockPanel = this.dockPanelFactory({
549
+ mode: 'multiple-document',
550
+ renderer,
551
+ spacing: 0
552
+ });
553
+ dockPanel.id = MAIN_AREA_ID;
554
+ dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
555
+ dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
556
+
557
+ const openUri = async (fileUri: URI) => {
558
+ try {
559
+ const opener = await this.openerService.getOpener(fileUri);
560
+ opener.open(fileUri);
561
+ } catch (e) {
562
+ console.info(`no opener found for '${fileUri}'`);
563
+ }
564
+ };
565
+
566
+ dockPanel.node.addEventListener('drop', event => {
567
+ if (event.dataTransfer) {
568
+ const uris = this.additionalDraggedUris || ApplicationShell.getDraggedEditorUris(event.dataTransfer);
569
+ if (uris.length > 0) {
570
+ uris.forEach(openUri);
571
+ } else if (event.dataTransfer.files?.length > 0) {
572
+ // the files were dragged from the outside the workspace
573
+ Array.from(event.dataTransfer.files).forEach(file => {
574
+ if (file.path) {
575
+ const fileUri = URI.fromComponents({
576
+ scheme: 'file',
577
+ path: file.path,
578
+ authority: '',
579
+ query: '',
580
+ fragment: ''
581
+ });
582
+ openUri(fileUri);
583
+ }
584
+ });
585
+ }
586
+ }
587
+ });
588
+
589
+ dockPanel.node.addEventListener('dblclick', event => {
590
+ const el = event.target as Element;
591
+ if (el.id === MAIN_AREA_ID || el.classList.contains('p-TabBar-content')) {
592
+ this.onDidDoubleClickMainAreaEmitter.fire();
593
+ }
594
+ });
595
+
596
+ const handler = (e: DragEvent) => {
597
+ if (e.dataTransfer) {
598
+ e.dataTransfer.dropEffect = 'link';
599
+ e.preventDefault();
600
+ e.stopPropagation();
601
+ }
602
+ };
603
+ dockPanel.node.addEventListener('dragover', handler);
604
+ dockPanel.node.addEventListener('dragenter', handler);
605
+
606
+ return dockPanel;
607
+ }
608
+
609
+ addAdditionalDraggedEditorUris(uris: URI[]): void {
610
+ this.additionalDraggedUris = uris;
611
+ }
612
+
613
+ clearAdditionalDraggedEditorUris(): void {
614
+ this.additionalDraggedUris = undefined;
615
+ }
616
+
617
+ protected static getDraggedEditorUris(dataTransfer: DataTransfer): URI[] {
618
+ const data = dataTransfer.getData('theia-editor-dnd');
619
+ return data ? data.split('\n').map(entry => new URI(entry)) : [];
620
+ }
621
+
622
+ static setDraggedEditorUris(dataTransfer: DataTransfer, uris: URI[]): void {
623
+ dataTransfer.setData('theia-editor-dnd', uris.map(uri => uri.toString()).join('\n'));
624
+ }
625
+
626
+ /**
627
+ * Create the dock panel in the bottom shell area.
628
+ */
629
+ protected createBottomPanel(): TheiaDockPanel {
630
+ const renderer = this.dockPanelRendererFactory();
631
+ renderer.tabBarClasses.push(MAIN_BOTTOM_AREA_CLASS);
632
+ renderer.tabBarClasses.push(BOTTOM_AREA_CLASS);
633
+ const dockPanel = this.dockPanelFactory({
634
+ mode: 'multiple-document',
635
+ renderer,
636
+ spacing: 0
637
+ });
638
+ dockPanel.id = BOTTOM_AREA_ID;
639
+ dockPanel.widgetAdded.connect((sender, widget) => {
640
+ this.refreshBottomPanelToggleButton();
641
+ });
642
+ dockPanel.widgetRemoved.connect((sender, widget) => {
643
+ if (sender.isEmpty) {
644
+ this.collapseBottomPanel();
645
+ }
646
+ this.refreshBottomPanelToggleButton();
647
+ }, this);
648
+ dockPanel.node.addEventListener('p-dragenter', event => {
649
+ // Make sure that the main panel hides its overlay when the bottom panel is expanded
650
+ this.mainPanel.overlay.hide(0);
651
+ });
652
+ dockPanel.hide();
653
+ dockPanel.widgetAdded.connect((_, widget) => this.fireDidAddWidget(widget));
654
+ dockPanel.widgetRemoved.connect((_, widget) => this.fireDidRemoveWidget(widget));
655
+ return dockPanel;
656
+ }
657
+
658
+ /**
659
+ * Create the top panel, which is used to hold the main menu.
660
+ */
661
+ protected createTopPanel(): Panel {
662
+ const topPanel = new Panel();
663
+ topPanel.id = 'theia-top-panel';
664
+ topPanel.hide();
665
+ return topPanel;
666
+ }
667
+
668
+ /**
669
+ * Create a box layout to assemble the application shell layout.
670
+ */
671
+ protected createBoxLayout(widgets: Widget[], stretch?: number[], options?: BoxPanel.IOptions): BoxLayout {
672
+ const boxLayout = new BoxLayout(options);
673
+ for (let i = 0; i < widgets.length; i++) {
674
+ if (stretch !== undefined && i < stretch.length) {
675
+ BoxPanel.setStretch(widgets[i], stretch[i]);
676
+ }
677
+ boxLayout.addWidget(widgets[i]);
678
+ }
679
+ return boxLayout;
680
+ }
681
+
682
+ /**
683
+ * Create a split layout to assemble the application shell layout.
684
+ */
685
+ protected createSplitLayout(widgets: Widget[], stretch?: number[], options?: Partial<SplitLayout.IOptions>): SplitLayout {
686
+ let optParam: SplitLayout.IOptions = { renderer: SplitPanel.defaultRenderer, };
687
+ if (options) {
688
+ optParam = { ...optParam, ...options };
689
+ }
690
+ const splitLayout = new SplitLayout(optParam);
691
+ for (let i = 0; i < widgets.length; i++) {
692
+ if (stretch !== undefined && i < stretch.length) {
693
+ SplitPanel.setStretch(widgets[i], stretch[i]);
694
+ }
695
+ splitLayout.addWidget(widgets[i]);
696
+ }
697
+ return splitLayout;
698
+ }
699
+
700
+ /**
701
+ * Assemble the application shell layout. Override this method in order to change the arrangement
702
+ * of the main area and the side panels.
703
+ */
704
+ protected createLayout(): Layout {
705
+ const bottomSplitLayout = this.createSplitLayout(
706
+ [this.mainPanel, this.bottomPanel],
707
+ [1, 0],
708
+ { orientation: 'vertical', spacing: 0 }
709
+ );
710
+ const panelForBottomArea = new SplitPanel({ layout: bottomSplitLayout });
711
+ panelForBottomArea.id = 'theia-bottom-split-panel';
712
+
713
+ const leftRightSplitLayout = this.createSplitLayout(
714
+ [this.leftPanelHandler.container, panelForBottomArea, this.rightPanelHandler.container],
715
+ [0, 1, 0],
716
+ { orientation: 'horizontal', spacing: 0 }
717
+ );
718
+ const panelForSideAreas = new SplitPanel({ layout: leftRightSplitLayout });
719
+ panelForSideAreas.id = 'theia-left-right-split-panel';
720
+
721
+ return this.createBoxLayout(
722
+ [this.topPanel, panelForSideAreas, this.statusBar],
723
+ [0, 1, 0],
724
+ { direction: 'top-to-bottom', spacing: 0 }
725
+ );
726
+ }
727
+
728
+ /**
729
+ * Create an object that describes the current shell layout. This object may contain references
730
+ * to widgets; these need to be transformed before the layout can be serialized.
731
+ */
732
+ getLayoutData(): ApplicationShell.LayoutData {
733
+ return {
734
+ version: applicationShellLayoutVersion,
735
+ mainPanel: this.mainPanel.saveLayout(),
736
+ mainPanelPinned: this.getPinnedMainWidgets(),
737
+ bottomPanel: {
738
+ config: this.bottomPanel.saveLayout(),
739
+ pinned: this.getPinnedBottomWidgets(),
740
+ size: this.bottomPanel.isVisible ? this.getBottomPanelSize() : this.bottomPanelState.lastPanelSize,
741
+ expanded: this.isExpanded('bottom')
742
+ },
743
+ leftPanel: this.leftPanelHandler.getLayoutData(),
744
+ rightPanel: this.rightPanelHandler.getLayoutData(),
745
+ activeWidgetId: this.activeWidget ? this.activeWidget.id : undefined
746
+ };
747
+ }
748
+
749
+ // Get an array corresponding to main panel widgets' pinned state.
750
+ getPinnedMainWidgets(): boolean[] {
751
+ const pinned: boolean[] = [];
752
+
753
+ toArray(this.mainPanel.widgets()).forEach((a, i) => {
754
+ pinned[i] = a.title.className.includes(PINNED_CLASS);
755
+ });
756
+
757
+ return pinned;
758
+ }
759
+
760
+ // Get an array corresponding to bottom panel widgets' pinned state.
761
+ getPinnedBottomWidgets(): boolean[] {
762
+ const pinned: boolean[] = [];
763
+
764
+ toArray(this.bottomPanel.widgets()).forEach((a, i) => {
765
+ pinned[i] = a.title.className.includes(PINNED_CLASS);
766
+ });
767
+
768
+ return pinned;
769
+ }
770
+
771
+ /**
772
+ * Compute the current height of the bottom panel. This implementation assumes that the container
773
+ * of the bottom panel is a `SplitPanel`.
774
+ */
775
+ protected getBottomPanelSize(): number | undefined {
776
+ const parent = this.bottomPanel.parent;
777
+ if (parent instanceof SplitPanel && parent.isVisible) {
778
+ const index = parent.widgets.indexOf(this.bottomPanel) - 1;
779
+ if (index >= 0) {
780
+ const handle = parent.handles[index];
781
+ if (!handle.classList.contains('p-mod-hidden')) {
782
+ const parentHeight = parent.node.clientHeight;
783
+ return parentHeight - handle.offsetTop;
784
+ }
785
+ }
786
+ }
787
+ }
788
+
789
+ /**
790
+ * Determine the default size to apply when the bottom panel is expanded for the first time.
791
+ */
792
+ protected getDefaultBottomPanelSize(): number | undefined {
793
+ const parent = this.bottomPanel.parent;
794
+ if (parent && parent.isVisible) {
795
+ return parent.node.clientHeight * this.options.bottomPanel.initialSizeRatio;
796
+ }
797
+ }
798
+
799
+ /**
800
+ * Apply a shell layout that has been previously created with `getLayoutData`.
801
+ */
802
+ async setLayoutData(layoutData: ApplicationShell.LayoutData): Promise<void> {
803
+ const { mainPanel, mainPanelPinned, bottomPanel, leftPanel, rightPanel, activeWidgetId } = layoutData;
804
+ if (leftPanel) {
805
+ this.leftPanelHandler.setLayoutData(leftPanel);
806
+ this.registerWithFocusTracker(leftPanel);
807
+ }
808
+ if (rightPanel) {
809
+ this.rightPanelHandler.setLayoutData(rightPanel);
810
+ this.registerWithFocusTracker(rightPanel);
811
+ }
812
+ // Proceed with the bottom panel once the side panels are set up
813
+ await Promise.all([this.leftPanelHandler.state.pendingUpdate, this.rightPanelHandler.state.pendingUpdate]);
814
+ if (bottomPanel) {
815
+ if (bottomPanel.config) {
816
+ this.bottomPanel.restoreLayout(bottomPanel.config);
817
+ this.registerWithFocusTracker(bottomPanel.config.main);
818
+ }
819
+ if (bottomPanel.size) {
820
+ this.bottomPanelState.lastPanelSize = bottomPanel.size;
821
+ }
822
+ if (bottomPanel.expanded) {
823
+ this.expandBottomPanel();
824
+ } else {
825
+ this.collapseBottomPanel();
826
+ }
827
+ const widgets = toArray(this.bottomPanel.widgets());
828
+ this.bottomPanel.markActiveTabBar(widgets[0]?.title);
829
+ if (bottomPanel.pinned && bottomPanel.pinned.length === widgets.length) {
830
+ widgets.forEach((a, i) => {
831
+ if (bottomPanel.pinned![i]) {
832
+ a.title.className += ` ${PINNED_CLASS}`;
833
+ a.title.closable = false;
834
+ }
835
+ });
836
+ }
837
+ this.refreshBottomPanelToggleButton();
838
+ }
839
+ // Proceed with the main panel once all others are set up
840
+ await this.bottomPanelState.pendingUpdate;
841
+ if (mainPanel) {
842
+ this.mainPanel.restoreLayout(mainPanel);
843
+ this.registerWithFocusTracker(mainPanel.main);
844
+ const widgets = toArray(this.mainPanel.widgets());
845
+ // We don't store information about the last active tabbar
846
+ // So we simply mark the first as being active
847
+ this.mainPanel.markActiveTabBar(widgets[0]?.title);
848
+ if (mainPanelPinned && mainPanelPinned.length === widgets.length) {
849
+ widgets.forEach((a, i) => {
850
+ if (mainPanelPinned[i]) {
851
+ a.title.className += ` ${PINNED_CLASS}`;
852
+ a.title.closable = false;
853
+ }
854
+ });
855
+ }
856
+ }
857
+ if (activeWidgetId) {
858
+ this.activateWidget(activeWidgetId);
859
+ }
860
+ }
861
+
862
+ /**
863
+ * Modify the height of the bottom panel. This implementation assumes that the container of the
864
+ * bottom panel is a `SplitPanel`.
865
+ */
866
+ protected setBottomPanelSize(size: number): Promise<void> {
867
+ const enableAnimation = this.applicationStateService.state === 'ready';
868
+ const options: SplitPositionOptions = {
869
+ side: 'bottom',
870
+ duration: enableAnimation ? this.options.bottomPanel.expandDuration : 0,
871
+ referenceWidget: this.bottomPanel
872
+ };
873
+ const promise = this.splitPositionHandler.setSidePanelSize(this.bottomPanel, size, options);
874
+ const result = new Promise<void>(resolve => {
875
+ // Resolve the resulting promise in any case, regardless of whether resizing was successful
876
+ promise.then(() => resolve(), () => resolve());
877
+ });
878
+ this.bottomPanelState.pendingUpdate = this.bottomPanelState.pendingUpdate.then(() => result);
879
+ return result;
880
+ }
881
+
882
+ /**
883
+ * A promise that is resolved when all currently pending updates are done.
884
+ */
885
+ get pendingUpdates(): Promise<void> {
886
+ return Promise.all([
887
+ this.bottomPanelState.pendingUpdate,
888
+ this.leftPanelHandler.state.pendingUpdate,
889
+ this.rightPanelHandler.state.pendingUpdate
890
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
891
+ ]) as Promise<any>;
892
+ }
893
+
894
+ /**
895
+ * Track all widgets that are referenced by the given layout data.
896
+ */
897
+ protected registerWithFocusTracker(data: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig | SidePanel.LayoutData | null): void {
898
+ if (data) {
899
+ if (data.type === 'tab-area') {
900
+ for (const widget of data.widgets) {
901
+ if (widget) {
902
+ this.track(widget);
903
+ }
904
+ }
905
+ } else if (data.type === 'split-area') {
906
+ for (const child of data.children) {
907
+ this.registerWithFocusTracker(child);
908
+ }
909
+ } else if (data.type === 'sidepanel' && data.items) {
910
+ for (const item of data.items) {
911
+ if (item.widget) {
912
+ this.track(item.widget);
913
+ }
914
+ }
915
+ }
916
+ }
917
+ }
918
+
919
+ /**
920
+ * Add a widget to the application shell. The given widget must have a unique `id` property,
921
+ * which will be used as the DOM id.
922
+ *
923
+ * Widgets are removed from the shell by calling their `close` or `dispose` methods.
924
+ *
925
+ * Widgets added to the top area are not tracked regarding the _current_ and _active_ states.
926
+ */
927
+ async addWidget(widget: Widget, options?: Readonly<ApplicationShell.WidgetOptions>): Promise<void> {
928
+ if (!widget.id) {
929
+ console.error('Widgets added to the application shell must have a unique id property.');
930
+ return;
931
+ }
932
+ const { area, addOptions } = this.getInsertionOptions(options);
933
+ const sidePanelOptions: SidePanel.WidgetOptions = { rank: options?.rank };
934
+ switch (area) {
935
+ case 'main':
936
+ this.mainPanel.addWidget(widget, addOptions);
937
+ break;
938
+ case 'top':
939
+ this.topPanel.addWidget(widget);
940
+ break;
941
+ case 'bottom':
942
+ this.bottomPanel.addWidget(widget, addOptions);
943
+ break;
944
+ case 'left':
945
+ this.leftPanelHandler.addWidget(widget, sidePanelOptions);
946
+ break;
947
+ case 'right':
948
+ this.rightPanelHandler.addWidget(widget, sidePanelOptions);
949
+ break;
950
+ case 'secondaryWindow':
951
+ /** At the moment, widgets are only moved to this area (i.e. a secondary window) by moving them from one of the other areas. */
952
+ throw new Error('Widgets cannot be added directly to a secondary window');
953
+ default:
954
+ throw new Error('Unexpected area: ' + options?.area);
955
+ }
956
+ if (area !== 'top') {
957
+ this.track(widget);
958
+ }
959
+ }
960
+
961
+ getInsertionOptions(options?: Readonly<ApplicationShell.WidgetOptions>): { area: string; addOptions: DockLayout.IAddOptions; } {
962
+ let ref: Widget | undefined = options?.ref;
963
+ let area: ApplicationShell.Area = options?.area || 'main';
964
+ if (!ref && (area === 'main' || area === 'bottom')) {
965
+ const tabBar = this.getTabBarFor(area);
966
+ ref = tabBar && tabBar.currentTitle && tabBar.currentTitle.owner || undefined;
967
+ }
968
+ // make sure that ref belongs to area
969
+ area = ref && this.getAreaFor(ref) || area;
970
+ const addOptions: DockPanel.IAddOptions = {};
971
+ if (ApplicationShell.isOpenToSideMode(options?.mode)) {
972
+ const areaPanel = area === 'main' ? this.mainPanel : area === 'bottom' ? this.bottomPanel : undefined;
973
+ const sideRef = areaPanel && ref && (options?.mode === 'open-to-left' ?
974
+ areaPanel.previousTabBarWidget(ref) :
975
+ areaPanel.nextTabBarWidget(ref));
976
+ if (sideRef) {
977
+ addOptions.ref = sideRef;
978
+ } else {
979
+ addOptions.ref = ref;
980
+ addOptions.mode = options?.mode === 'open-to-left' ? 'split-left' : 'split-right';
981
+ }
982
+ } else {
983
+ addOptions.ref = ref;
984
+ addOptions.mode = options?.mode;
985
+ }
986
+ return { area, addOptions };
987
+ }
988
+
989
+ /**
990
+ * The widgets contained in the given shell area.
991
+ */
992
+ getWidgets(area: ApplicationShell.Area): Widget[] {
993
+ switch (area) {
994
+ case 'main':
995
+ return toArray(this.mainPanel.widgets());
996
+ case 'top':
997
+ return toArray(this.topPanel.widgets);
998
+ case 'bottom':
999
+ return toArray(this.bottomPanel.widgets());
1000
+ case 'left':
1001
+ return toArray(this.leftPanelHandler.dockPanel.widgets());
1002
+ case 'right':
1003
+ return toArray(this.rightPanelHandler.dockPanel.widgets());
1004
+ case 'secondaryWindow':
1005
+ return toArray(this.secondaryWindowHandler.widgets);
1006
+ default:
1007
+ throw new Error('Illegal argument: ' + area);
1008
+ }
1009
+ }
1010
+
1011
+ /**
1012
+ * Find the widget that contains the given HTML element. The returned widget may be one
1013
+ * that is managed by the application shell, or one that is embedded in another widget and
1014
+ * not directly managed by the shell, or a tab bar.
1015
+ */
1016
+ findWidgetForElement(element: HTMLElement): Widget | undefined {
1017
+ let widgetNode: HTMLElement | null = element;
1018
+ while (widgetNode && !widgetNode.classList.contains('p-Widget')) {
1019
+ widgetNode = widgetNode.parentElement;
1020
+ }
1021
+ if (widgetNode) {
1022
+ return this.findWidgetForNode(widgetNode, this);
1023
+ }
1024
+ return undefined;
1025
+ }
1026
+
1027
+ private findWidgetForNode(widgetNode: HTMLElement, widget: Widget): Widget | undefined {
1028
+ if (widget.node === widgetNode) {
1029
+ return widget;
1030
+ }
1031
+ let result: Widget | undefined;
1032
+ each(widget.children(), child => {
1033
+ result = this.findWidgetForNode(widgetNode, child);
1034
+ return !result;
1035
+ });
1036
+ return result;
1037
+ }
1038
+
1039
+ /**
1040
+ * Finds the title widget from the tab-bar.
1041
+ * @param tabBar used for providing an array of titles.
1042
+ * @returns the selected title widget, else returns the currentTitle or undefined.
1043
+ */
1044
+ findTitle(tabBar: TabBar<Widget>, event?: Event): Title<Widget> | undefined {
1045
+ if (event?.target instanceof HTMLElement) {
1046
+ const tabNode = event.target;
1047
+
1048
+ const titleIndex = Array.from(tabBar.contentNode.getElementsByClassName('p-TabBar-tab'))
1049
+ .findIndex(node => node.contains(tabNode));
1050
+
1051
+ if (titleIndex !== -1) {
1052
+ return tabBar.titles[titleIndex];
1053
+ }
1054
+
1055
+ }
1056
+ return tabBar.currentTitle || undefined;
1057
+ }
1058
+
1059
+ /**
1060
+ * Finds the tab-bar widget.
1061
+ * @returns the selected tab-bar, else returns the currentTabBar.
1062
+ */
1063
+ findTabBar(event?: Event): TabBar<Widget> | undefined {
1064
+ if (event?.target instanceof HTMLElement) {
1065
+ const tabBar = this.findWidgetForElement(event.target);
1066
+ if (tabBar instanceof TabBar) {
1067
+ return tabBar;
1068
+ }
1069
+ }
1070
+ return this.currentTabBar;
1071
+ }
1072
+
1073
+ /**
1074
+ * @returns the widget whose title has been targeted by a DOM event on a tabbar, or undefined if none can be found.
1075
+ */
1076
+ findTargetedWidget(event?: Event): Widget | undefined {
1077
+ if (event) {
1078
+ const tab = this.findTabBar(event);
1079
+ const title = tab && this.findTitle(tab, event);
1080
+ return title && title.owner;
1081
+ }
1082
+ }
1083
+
1084
+ /**
1085
+ * The current widget in the application shell. The current widget is the last widget that
1086
+ * was active and not yet closed. See the remarks to `activeWidget` on what _active_ means.
1087
+ */
1088
+ get currentWidget(): Widget | undefined {
1089
+ return this.tracker.currentWidget || undefined;
1090
+ }
1091
+
1092
+ /**
1093
+ * The active widget in the application shell. The active widget is the one that has focus
1094
+ * (either the widget itself or any of its contents).
1095
+ *
1096
+ * _Note:_ Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1097
+ * widget implementation which DOM element will get the focus. The default implementation
1098
+ * does not take any focus; in that case the widget is never returned by this property.
1099
+ */
1100
+ get activeWidget(): Widget | undefined {
1101
+ return this.tracker.activeWidget || undefined;
1102
+ }
1103
+
1104
+ /**
1105
+ * Returns the last active widget in the given shell area.
1106
+ */
1107
+ getCurrentWidget(area: ApplicationShell.Area): Widget | undefined {
1108
+ let title: Title<Widget> | null | undefined;
1109
+ switch (area) {
1110
+ case 'main':
1111
+ title = this.mainPanel.currentTitle;
1112
+ break;
1113
+ case 'bottom':
1114
+ title = this.bottomPanel.currentTitle;
1115
+ break;
1116
+ case 'left':
1117
+ title = this.leftPanelHandler.tabBar.currentTitle;
1118
+ break;
1119
+ case 'right':
1120
+ title = this.rightPanelHandler.tabBar.currentTitle;
1121
+ break;
1122
+ case 'secondaryWindow':
1123
+ // The current widget in a secondary window is not tracked.
1124
+ return undefined;
1125
+ default:
1126
+ throw new Error('Illegal argument: ' + area);
1127
+ }
1128
+ return title ? title.owner : undefined;
1129
+ }
1130
+
1131
+ /**
1132
+ * Handle a change to the current widget.
1133
+ */
1134
+ private onCurrentChanged(sender: FocusTracker<Widget>, args: FocusTracker.IChangedArgs<Widget>): void {
1135
+ this.onDidChangeCurrentWidgetEmitter.fire(args);
1136
+ }
1137
+
1138
+ protected readonly toDisposeOnActiveChanged = new DisposableCollection();
1139
+
1140
+ /**
1141
+ * Handle a change to the active widget.
1142
+ */
1143
+ private onActiveChanged(sender: FocusTracker<Widget>, args: FocusTracker.IChangedArgs<Widget>): void {
1144
+ this.toDisposeOnActiveChanged.dispose();
1145
+ const { newValue, oldValue } = args;
1146
+ if (oldValue) {
1147
+ let w: Widget | null = oldValue;
1148
+ while (w) {
1149
+ // Remove the mark of the previously active widget
1150
+ w.title.className = w.title.className.replace(' theia-mod-active', '');
1151
+ w = w.parent;
1152
+ }
1153
+ // Reset the z-index to the default
1154
+ // eslint-disable-next-line no-null/no-null
1155
+ this.setZIndex(oldValue.node, null);
1156
+ }
1157
+ if (newValue) {
1158
+ let w: Widget | null = newValue;
1159
+ while (w) {
1160
+ // Mark the tab of the active widget
1161
+ w.title.className += ' theia-mod-active';
1162
+ w = w.parent;
1163
+ }
1164
+ // Reveal the title of the active widget in its tab bar
1165
+ const tabBar = this.getTabBarFor(newValue);
1166
+ if (tabBar instanceof ScrollableTabBar) {
1167
+ const index = tabBar.titles.indexOf(newValue.title);
1168
+ if (index >= 0) {
1169
+ tabBar.revealTab(index);
1170
+ }
1171
+ }
1172
+ const widget = this.toTrackedStack(newValue.id).pop();
1173
+ const panel = this.findPanel(widget);
1174
+ if (panel) {
1175
+ // if widget was undefined, we wouldn't have gotten a panel back before
1176
+ panel.markAsCurrent(widget!.title);
1177
+ }
1178
+ // Add checks to ensure that the 'sash' for left panel is displayed correctly
1179
+ if (newValue.node.className === 'p-Widget theia-view-container p-DockPanel-widget') {
1180
+ // Set the z-index so elements with `position: fixed` contained in the active widget are displayed correctly
1181
+ this.setZIndex(newValue.node, '1');
1182
+ }
1183
+
1184
+ // activate another widget if an active widget will be closed
1185
+ const onCloseRequest = newValue['onCloseRequest'];
1186
+ newValue['onCloseRequest'] = msg => {
1187
+ const currentTabBar = this.currentTabBar;
1188
+ if (currentTabBar) {
1189
+ const recentlyUsedInTabBar = currentTabBar['_previousTitle'] as TabBar<Widget>['currentTitle'];
1190
+ if (recentlyUsedInTabBar && recentlyUsedInTabBar.owner !== newValue) {
1191
+ currentTabBar.currentIndex = ArrayExt.firstIndexOf(currentTabBar.titles, recentlyUsedInTabBar);
1192
+ if (currentTabBar.currentTitle) {
1193
+ this.activateWidget(currentTabBar.currentTitle.owner.id);
1194
+ }
1195
+ } else if (!this.activateNextTabInTabBar(currentTabBar)) {
1196
+ if (!this.activatePreviousTabBar(currentTabBar)) {
1197
+ this.activateNextTabBar(currentTabBar);
1198
+ }
1199
+ }
1200
+ }
1201
+ newValue['onCloseRequest'] = onCloseRequest;
1202
+ newValue['onCloseRequest'](msg);
1203
+ };
1204
+ this.toDisposeOnActiveChanged.push(Disposable.create(() => newValue['onCloseRequest'] = onCloseRequest));
1205
+ if (PreviewableWidget.is(newValue)) {
1206
+ newValue.loaded = true;
1207
+ }
1208
+ }
1209
+ this.onDidChangeActiveWidgetEmitter.fire(args);
1210
+ }
1211
+
1212
+ /**
1213
+ * Set the z-index of the given element and its ancestors to the value `z`.
1214
+ */
1215
+ private setZIndex(element: HTMLElement, z: string | null): void {
1216
+ element.style.zIndex = z || '';
1217
+ const parent = element.parentElement;
1218
+ if (parent && parent !== this.node) {
1219
+ this.setZIndex(parent, z);
1220
+ }
1221
+ }
1222
+
1223
+ /**
1224
+ * Track the given widget so it is considered in the `current` and `active` state of the shell.
1225
+ */
1226
+ protected track(widget: Widget): void {
1227
+ if (this.tracker.widgets.indexOf(widget) !== -1) {
1228
+ return;
1229
+ }
1230
+ this.tracker.add(widget);
1231
+ this.checkActivation(widget);
1232
+ Saveable.apply(
1233
+ widget,
1234
+ () => this.widgets.filter((maybeSaveable): maybeSaveable is Widget & SaveableSource => !!Saveable.get(maybeSaveable)),
1235
+ async (toSave, options) => {
1236
+ await this.saveResourceService.save(toSave, options);
1237
+ },
1238
+ );
1239
+ if (ApplicationShell.TrackableWidgetProvider.is(widget)) {
1240
+ for (const toTrack of widget.getTrackableWidgets()) {
1241
+ this.track(toTrack);
1242
+ }
1243
+ if (widget.onDidChangeTrackableWidgets) {
1244
+ widget.onDidChangeTrackableWidgets(widgets => widgets.forEach(w => this.track(w)));
1245
+ }
1246
+ }
1247
+ }
1248
+
1249
+ /**
1250
+ * @returns an array of Widgets, all of which are tracked by the focus tracker
1251
+ * The first member of the array is the widget whose id is passed in, and the other widgets
1252
+ * are its tracked parents in ascending order
1253
+ */
1254
+ protected toTrackedStack(id: string): Widget[] {
1255
+ const tracked = new Map<string, Widget>(this.tracker.widgets.map(w => [w.id, w] as [string, Widget]));
1256
+ let current = tracked.get(id);
1257
+ const stack: Widget[] = [];
1258
+ while (current) {
1259
+ if (tracked.has(current.id)) {
1260
+ stack.push(current);
1261
+ }
1262
+ current = current.parent || undefined;
1263
+ }
1264
+ return stack;
1265
+ }
1266
+
1267
+ /**
1268
+ * Activate a widget in the application shell. This makes the widget visible and usually
1269
+ * also assigns focus to it.
1270
+ *
1271
+ * _Note:_ Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1272
+ * widget implementation which DOM element will get the focus. The default implementation
1273
+ * does not take any focus.
1274
+ *
1275
+ * @returns the activated widget if it was found
1276
+ */
1277
+ async activateWidget(id: string): Promise<Widget | undefined> {
1278
+ const stack = this.toTrackedStack(id);
1279
+ let current = stack.pop();
1280
+ if (current && !this.doActivateWidget(current.id)) {
1281
+ return undefined;
1282
+ }
1283
+ while (current && stack.length) {
1284
+ const child = stack.pop()!;
1285
+ if (ApplicationShell.TrackableWidgetProvider.is(current) && current.activateWidget) {
1286
+ current = current.activateWidget(child.id);
1287
+ } else {
1288
+ child.activate();
1289
+ current = child;
1290
+ }
1291
+ }
1292
+ if (!current) {
1293
+ return undefined;
1294
+ }
1295
+ return Promise.all([
1296
+ this.waitForActivation(current.id),
1297
+ waitForRevealed(current),
1298
+ this.pendingUpdates
1299
+ ]).then(() => current, () => undefined);
1300
+ }
1301
+
1302
+ waitForActivation(id: string): Promise<void> {
1303
+ if (this.activeWidget && this.activeWidget.id === id) {
1304
+ return Promise.resolve();
1305
+ }
1306
+ const activation = new Deferred();
1307
+ const success = this.onDidChangeActiveWidget(() => {
1308
+ if (this.activeWidget && this.activeWidget.id === id) {
1309
+ activation.resolve();
1310
+ }
1311
+ });
1312
+ const failure = setTimeout(() => activation.reject(new Error(`Widget with id '${id}' failed to activate.`)), this.activationTimeout + 250);
1313
+ return activation.promise.finally(() => {
1314
+ success.dispose();
1315
+ clearTimeout(failure);
1316
+ });
1317
+ }
1318
+
1319
+ /**
1320
+ * Activate top-level area widget.
1321
+ */
1322
+ protected doActivateWidget(id: string): Widget | undefined {
1323
+ let widget = find(this.mainPanel.widgets(), w => w.id === id);
1324
+ if (widget) {
1325
+ this.mainPanel.activateWidget(widget);
1326
+ return widget;
1327
+ }
1328
+ widget = find(this.bottomPanel.widgets(), w => w.id === id);
1329
+ if (widget) {
1330
+ this.expandBottomPanel();
1331
+ this.bottomPanel.activateWidget(widget);
1332
+ return widget;
1333
+ }
1334
+ widget = this.leftPanelHandler.activate(id);
1335
+ if (widget) {
1336
+ return widget;
1337
+ }
1338
+ widget = this.rightPanelHandler.activate(id);
1339
+ if (widget) {
1340
+ return widget;
1341
+ }
1342
+ return this.secondaryWindowHandler.activateWidget(id);
1343
+ }
1344
+
1345
+ /**
1346
+ * Focus is taken by a widget through the `onActivateRequest` method. It is up to the
1347
+ * widget implementation which DOM element will get the focus. The default implementation
1348
+ * of Widget does not take any focus. This method can help finding such problems by logging
1349
+ * a warning in case a widget was explicitly activated, but did not trigger a change of the
1350
+ * `activeWidget` property.
1351
+ */
1352
+ private checkActivation(widget: Widget): Widget {
1353
+ const onActivateRequest = widget['onActivateRequest'].bind(widget);
1354
+ widget['onActivateRequest'] = (msg: Message) => {
1355
+ onActivateRequest(msg);
1356
+ this.assertActivated(widget);
1357
+ };
1358
+ return widget;
1359
+ }
1360
+
1361
+ private readonly activationTimeout = 2000;
1362
+ private readonly toDisposeOnActivationCheck = new DisposableCollection();
1363
+ private assertActivated(widget: Widget): void {
1364
+ this.toDisposeOnActivationCheck.dispose();
1365
+
1366
+ const onDispose = () => this.toDisposeOnActivationCheck.dispose();
1367
+ widget.disposed.connect(onDispose);
1368
+ this.toDisposeOnActivationCheck.push(Disposable.create(() => widget.disposed.disconnect(onDispose)));
1369
+
1370
+ let start = 0;
1371
+ const step: FrameRequestCallback = timestamp => {
1372
+ const activeElement = widget.node.ownerDocument.activeElement;
1373
+ if (activeElement && widget.node.contains(activeElement)) {
1374
+ return;
1375
+ }
1376
+ if (!start) {
1377
+ start = timestamp;
1378
+ }
1379
+ const delta = timestamp - start;
1380
+ if (delta < this.activationTimeout) {
1381
+ request = window.requestAnimationFrame(step);
1382
+ } else {
1383
+ console.warn(`Widget was activated, but did not accept focus after ${this.activationTimeout}ms: ${widget.id}`);
1384
+ }
1385
+ };
1386
+ let request = window.requestAnimationFrame(step);
1387
+ this.toDisposeOnActivationCheck.push(Disposable.create(() => window.cancelAnimationFrame(request)));
1388
+ }
1389
+
1390
+ /**
1391
+ * Reveal a widget in the application shell. This makes the widget visible,
1392
+ * but does not activate it.
1393
+ *
1394
+ * @returns the revealed widget if it was found
1395
+ */
1396
+ async revealWidget(id: string): Promise<Widget | undefined> {
1397
+ const stack = this.toTrackedStack(id);
1398
+ let current = stack.pop();
1399
+ if (current && !this.doRevealWidget(current.id)) {
1400
+ return undefined;
1401
+ }
1402
+ while (current && stack.length) {
1403
+ const child = stack.pop()!;
1404
+ if (ApplicationShell.TrackableWidgetProvider.is(current) && current.revealWidget) {
1405
+ current = current.revealWidget(child.id);
1406
+ } else {
1407
+ current = child;
1408
+ }
1409
+ }
1410
+ if (!current) {
1411
+ return undefined;
1412
+ }
1413
+ await Promise.all([
1414
+ waitForRevealed(current),
1415
+ this.pendingUpdates
1416
+ ]);
1417
+ return current;
1418
+ }
1419
+
1420
+ /**
1421
+ * Reveal top-level area widget.
1422
+ */
1423
+ protected doRevealWidget(id: string): Widget | undefined {
1424
+ let widget = find(this.mainPanel.widgets(), w => w.id === id);
1425
+ if (!widget) {
1426
+ widget = find(this.bottomPanel.widgets(), w => w.id === id);
1427
+ if (widget) {
1428
+ this.expandBottomPanel();
1429
+ }
1430
+ }
1431
+ if (widget) {
1432
+ const tabBar = this.getTabBarFor(widget);
1433
+ if (tabBar) {
1434
+ tabBar.currentTitle = widget.title;
1435
+ }
1436
+ return widget;
1437
+ }
1438
+ widget = this.leftPanelHandler.expand(id);
1439
+ if (widget) {
1440
+ return widget;
1441
+ }
1442
+ widget = this.rightPanelHandler.expand(id);
1443
+ if (widget) {
1444
+ return widget;
1445
+ }
1446
+ return this.secondaryWindowHandler.revealWidget(id);
1447
+ }
1448
+
1449
+ /**
1450
+ * Expand the named side panel area. This makes sure that the panel is visible, even if there
1451
+ * are no widgets in it. If the panel is already visible, nothing happens. If the panel is currently
1452
+ * collapsed (see `collapsePanel`) and it contains widgets, the widgets are revealed that were
1453
+ * visible before it was collapsed.
1454
+ */
1455
+ expandPanel(area: ApplicationShell.Area): void {
1456
+ switch (area) {
1457
+ case 'bottom':
1458
+ this.expandBottomPanel();
1459
+ break;
1460
+ case 'left':
1461
+ this.leftPanelHandler.expand();
1462
+ break;
1463
+ case 'right':
1464
+ this.rightPanelHandler.expand();
1465
+ break;
1466
+ default:
1467
+ throw new Error('Area cannot be expanded: ' + area);
1468
+ }
1469
+ }
1470
+
1471
+ /**
1472
+ * Adjusts the size of the given area in the application shell.
1473
+ *
1474
+ * @param size the desired size of the panel in pixels.
1475
+ * @param area the area to resize.
1476
+ */
1477
+ resize(size: number, area: ApplicationShell.Area): void {
1478
+ switch (area) {
1479
+ case 'bottom':
1480
+ if (this.bottomPanel.isHidden) {
1481
+ this.bottomPanelState.lastPanelSize = size;
1482
+ } else {
1483
+ this.setBottomPanelSize(size);
1484
+ }
1485
+ break;
1486
+ case 'left':
1487
+ this.leftPanelHandler.resize(size);
1488
+ break;
1489
+ case 'right':
1490
+ this.rightPanelHandler.resize(size);
1491
+ break;
1492
+ default:
1493
+ throw new Error('Area cannot be resized: ' + area);
1494
+ }
1495
+ }
1496
+
1497
+ /**
1498
+ * Expand the bottom panel. See `expandPanel` regarding the exact behavior.
1499
+ */
1500
+ protected expandBottomPanel(): void {
1501
+ const bottomPanel = this.bottomPanel;
1502
+ if (bottomPanel.isHidden) {
1503
+ let relativeSizes: number[] | undefined;
1504
+ const parent = bottomPanel.parent;
1505
+ if (parent instanceof SplitPanel) {
1506
+ relativeSizes = parent.relativeSizes();
1507
+ }
1508
+ bottomPanel.show();
1509
+ if (relativeSizes && parent instanceof SplitPanel) {
1510
+ // Make sure that the expansion animation starts at the smallest possible size
1511
+ parent.setRelativeSizes(relativeSizes);
1512
+ }
1513
+
1514
+ let size: number | undefined;
1515
+ if (bottomPanel.isEmpty) {
1516
+ bottomPanel.node.style.minHeight = '0';
1517
+ size = this.options.bottomPanel.emptySize;
1518
+ } else if (this.bottomPanelState.lastPanelSize) {
1519
+ size = this.bottomPanelState.lastPanelSize;
1520
+ } else {
1521
+ size = this.getDefaultBottomPanelSize();
1522
+ }
1523
+ if (size) {
1524
+ this.bottomPanelState.expansion = SidePanel.ExpansionState.expanding;
1525
+ this.setBottomPanelSize(size).then(() => {
1526
+ if (this.bottomPanelState.expansion === SidePanel.ExpansionState.expanding) {
1527
+ this.bottomPanelState.expansion = SidePanel.ExpansionState.expanded;
1528
+ }
1529
+ });
1530
+ } else {
1531
+ this.bottomPanelState.expansion = SidePanel.ExpansionState.expanded;
1532
+ }
1533
+ }
1534
+ }
1535
+
1536
+ /**
1537
+ * Collapse the named side panel area. This makes sure that the panel is hidden,
1538
+ * increasing the space that is available for other shell areas.
1539
+ */
1540
+ collapsePanel(area: ApplicationShell.Area): Promise<void> {
1541
+ switch (area) {
1542
+ case 'bottom':
1543
+ return this.collapseBottomPanel();
1544
+ case 'left':
1545
+ return this.leftPanelHandler.collapse();
1546
+ case 'right':
1547
+ return this.rightPanelHandler.collapse();
1548
+ default:
1549
+ throw new Error('Area cannot be collapsed: ' + area);
1550
+ }
1551
+ }
1552
+
1553
+ /**
1554
+ * Collapse the bottom panel. All contained widgets are hidden, but not closed.
1555
+ * They can be restored by calling `expandBottomPanel`.
1556
+ */
1557
+ protected collapseBottomPanel(): Promise<void> {
1558
+ const bottomPanel = this.bottomPanel;
1559
+ if (bottomPanel.isHidden) {
1560
+ return Promise.resolve();
1561
+ }
1562
+ if (this.bottomPanelState.expansion === SidePanel.ExpansionState.expanded) {
1563
+ const size = this.getBottomPanelSize();
1564
+ if (size) {
1565
+ this.bottomPanelState.lastPanelSize = size;
1566
+ }
1567
+ }
1568
+ this.bottomPanelState.expansion = SidePanel.ExpansionState.collapsed;
1569
+ bottomPanel.hide();
1570
+ return animationFrame();
1571
+ }
1572
+
1573
+ /**
1574
+ * Refresh the toggle button for the bottom panel. This implementation creates a status bar entry
1575
+ * and refers to the command `core.toggle.bottom.panel`.
1576
+ */
1577
+ protected refreshBottomPanelToggleButton(): void {
1578
+ if (this.bottomPanel.isEmpty) {
1579
+ this.statusBar.removeElement(BOTTOM_PANEL_TOGGLE_ID);
1580
+ } else {
1581
+ const label = nls.localize('theia/core/common/collapseBottomPanel', 'Toggle Bottom Panel');
1582
+ const element: StatusBarEntry = {
1583
+ name: label,
1584
+ text: '$(codicon-window)',
1585
+ alignment: StatusBarAlignment.RIGHT,
1586
+ tooltip: label,
1587
+ command: 'core.toggle.bottom.panel',
1588
+ accessibilityInformation: {
1589
+ label: label,
1590
+ role: 'button'
1591
+ },
1592
+ priority: -1000
1593
+ };
1594
+ this.statusBar.setElement(BOTTOM_PANEL_TOGGLE_ID, element);
1595
+ }
1596
+ }
1597
+
1598
+ /**
1599
+ * Check whether the named side panel area is expanded (returns `true`) or collapsed (returns `false`).
1600
+ */
1601
+ isExpanded(area: ApplicationShell.Area): boolean {
1602
+ switch (area) {
1603
+ case 'bottom':
1604
+ return this.bottomPanelState.expansion === SidePanel.ExpansionState.expanded;
1605
+ case 'left':
1606
+ return this.leftPanelHandler.state.expansion === SidePanel.ExpansionState.expanded;
1607
+ case 'right':
1608
+ return this.rightPanelHandler.state.expansion === SidePanel.ExpansionState.expanded;
1609
+ default:
1610
+ return true;
1611
+ }
1612
+ }
1613
+
1614
+ /**
1615
+ * Close all tabs or a selection of tabs in a specific part of the application shell.
1616
+ *
1617
+ * @param tabBarOrArea
1618
+ * Either the name of a shell area or a `TabBar` that is contained in such an area.
1619
+ * @param filter
1620
+ * If undefined, all tabs are closed; otherwise only those tabs that match the filter are closed.
1621
+ */
1622
+ async closeTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1623
+ filter?: (title: Title<Widget>, index: number) => boolean): Promise<void> {
1624
+ const titles: Array<Title<Widget>> = this.getWidgetTitles(tabBarOrArea, filter);
1625
+ if (titles.length) {
1626
+ await this.closeMany(titles.map(title => title.owner));
1627
+ }
1628
+ }
1629
+
1630
+ saveTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1631
+ filter?: (title: Title<Widget>, index: number) => boolean): void {
1632
+
1633
+ const titles = this.getWidgetTitles(tabBarOrArea, filter);
1634
+ for (let i = 0; i < titles.length; i++) {
1635
+ const widget = titles[i].owner;
1636
+ const saveable = Saveable.get(widget);
1637
+ saveable?.save();
1638
+ }
1639
+ }
1640
+
1641
+ /**
1642
+ * Collects all widget titles for the given tab bar or area and optionally filters them.
1643
+ *
1644
+ * @param tabBarOrArea The tab bar or area to retrieve the widget titles for
1645
+ * @param filter The filter to apply to the result
1646
+ * @returns The filtered array of widget titles or an empty array
1647
+ */
1648
+ protected getWidgetTitles(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
1649
+ filter?: (title: Title<Widget>, index: number) => boolean): Title<Widget>[] {
1650
+
1651
+ const titles: Title<Widget>[] = [];
1652
+ if (tabBarOrArea === 'main') {
1653
+ this.mainAreaTabBars.forEach(tabbar => titles.push(...toArray(tabbar.titles)));
1654
+ } else if (tabBarOrArea === 'bottom') {
1655
+ this.bottomAreaTabBars.forEach(tabbar => titles.push(...toArray(tabbar.titles)));
1656
+ } else if (tabBarOrArea === 'secondaryWindow') {
1657
+ titles.push(...this.secondaryWindowHandler.widgets.map(w => w.title));
1658
+ } else if (typeof tabBarOrArea === 'string') {
1659
+ const tabbar = this.getTabBarFor(tabBarOrArea);
1660
+ if (tabbar) {
1661
+ titles.push(...toArray(tabbar.titles));
1662
+ }
1663
+ } else if (tabBarOrArea) {
1664
+ titles.push(...toArray(tabBarOrArea.titles));
1665
+ }
1666
+
1667
+ return filter ? titles.filter(filter) : titles;
1668
+ }
1669
+
1670
+ /**
1671
+ * @param targets the widgets to be closed
1672
+ * @return an array of all the widgets that were actually closed.
1673
+ */
1674
+ async closeMany(targets: Widget[], options?: ApplicationShell.CloseOptions): Promise<Widget[]> {
1675
+ if (options?.save === false || await Saveable.confirmSaveBeforeClose(targets, this.widgets.filter(widget => !targets.includes(widget)))) {
1676
+ return (await Promise.all(targets.map(target => this.closeWidget(target.id, options)))).filter((widget): widget is Widget => widget !== undefined);
1677
+ }
1678
+ return [];
1679
+ }
1680
+
1681
+ /**
1682
+ * @returns the widget that was closed, if any, `undefined` otherwise.
1683
+ *
1684
+ * If your use case requires closing multiple widgets, use {@link ApplicationShell#closeMany} instead. That method handles closing saveable widgets more reliably.
1685
+ */
1686
+ async closeWidget(id: string, options?: ApplicationShell.CloseOptions): Promise<Widget | undefined> {
1687
+ // TODO handle save for composite widgets, i.e. the preference widget has 2 editors
1688
+ const stack = this.toTrackedStack(id);
1689
+ const current = stack.pop();
1690
+ if (!current) {
1691
+ return undefined;
1692
+ }
1693
+ const saveableOptions = options && { shouldSave: () => options.save };
1694
+ const pendingClose = SaveableWidget.is(current)
1695
+ ? current.closeWithSaving(saveableOptions)
1696
+ : (current.close(), waitForClosed(current));
1697
+ await Promise.all([
1698
+ pendingClose,
1699
+ this.pendingUpdates
1700
+ ]);
1701
+ return stack[0] || current;
1702
+ }
1703
+
1704
+ /**
1705
+ * The shell area name of the currently active tab, or undefined.
1706
+ */
1707
+ get currentTabArea(): ApplicationShell.Area | undefined {
1708
+ const currentWidget = this.currentWidget;
1709
+ if (currentWidget) {
1710
+ return this.getAreaFor(currentWidget);
1711
+ }
1712
+ }
1713
+
1714
+ /**
1715
+ * Determine the name of the shell area where the given widget resides. The result is
1716
+ * undefined if the widget does not reside directly in the shell.
1717
+ */
1718
+ getAreaFor(input: TabBar<Widget> | Widget): ApplicationShell.Area | undefined {
1719
+ if (input instanceof TabBar) {
1720
+ if (find(this.mainPanel.tabBars(), tb => tb === input)) {
1721
+ return 'main';
1722
+ }
1723
+ if (find(this.bottomPanel.tabBars(), tb => tb === input)) {
1724
+ return 'bottom';
1725
+ }
1726
+ if (this.leftPanelHandler.tabBar === input) {
1727
+ return 'left';
1728
+ }
1729
+ if (this.rightPanelHandler.tabBar === input) {
1730
+ return 'right';
1731
+ }
1732
+ }
1733
+ const widget = this.toTrackedStack(input.id).pop();
1734
+ if (!widget) {
1735
+ return undefined;
1736
+ }
1737
+ const title = widget.title;
1738
+ const mainPanelTabBar = this.mainPanel.findTabBar(title);
1739
+ if (mainPanelTabBar) {
1740
+ return 'main';
1741
+ }
1742
+ const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
1743
+ if (bottomPanelTabBar) {
1744
+ return 'bottom';
1745
+ }
1746
+ if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
1747
+ return 'left';
1748
+ }
1749
+ if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
1750
+ return 'right';
1751
+ }
1752
+ if (this.secondaryWindowHandler.widgets.includes(widget)) {
1753
+ return 'secondaryWindow';
1754
+ }
1755
+ return undefined;
1756
+ }
1757
+
1758
+ protected getAreaPanelFor(input: Widget): DockPanel | undefined {
1759
+ const widget = this.toTrackedStack(input.id).pop();
1760
+ if (!widget) {
1761
+ return undefined;
1762
+ }
1763
+ return this.findPanel(widget);
1764
+ }
1765
+
1766
+ /**
1767
+ * Find the shell panel this top-level widget is part of
1768
+ */
1769
+ protected findPanel(widget: Widget | undefined): TheiaDockPanel | undefined {
1770
+ if (!widget) {
1771
+ return undefined;
1772
+ }
1773
+ const title = widget.title;
1774
+ const mainPanelTabBar = this.mainPanel.findTabBar(title);
1775
+ if (mainPanelTabBar) {
1776
+ return this.mainPanel;
1777
+ }
1778
+ const bottomPanelTabBar = this.bottomPanel.findTabBar(title);
1779
+ if (bottomPanelTabBar) {
1780
+ return this.bottomPanel;
1781
+ }
1782
+ if (ArrayExt.firstIndexOf(this.leftPanelHandler.tabBar.titles, title) > -1) {
1783
+ return this.leftPanelHandler.dockPanel;
1784
+ }
1785
+ if (ArrayExt.firstIndexOf(this.rightPanelHandler.tabBar.titles, title) > -1) {
1786
+ return this.rightPanelHandler.dockPanel;
1787
+ }
1788
+ return undefined;
1789
+ }
1790
+
1791
+ /**
1792
+ * Return the tab bar that has the currently active widget, or undefined.
1793
+ */
1794
+ get currentTabBar(): TabBar<Widget> | undefined {
1795
+ const currentWidget = this.currentWidget;
1796
+ if (currentWidget) {
1797
+ return this.getTabBarFor(currentWidget);
1798
+ }
1799
+ }
1800
+
1801
+ /**
1802
+ * Return the tab bar in the given shell area, or the tab bar that has the given widget, or undefined.
1803
+ */
1804
+ getTabBarFor(widgetOrArea: Widget | ApplicationShell.Area): TabBar<Widget> | undefined {
1805
+ if (typeof widgetOrArea === 'string') {
1806
+ switch (widgetOrArea) {
1807
+ case 'main':
1808
+ return this.mainPanel.currentTabBar;
1809
+ case 'bottom':
1810
+ return this.bottomPanel.currentTabBar;
1811
+ case 'left':
1812
+ return this.leftPanelHandler.tabBar;
1813
+ case 'right':
1814
+ return this.rightPanelHandler.tabBar;
1815
+ case 'secondaryWindow':
1816
+ // Secondary windows don't have a tab bar
1817
+ return undefined;
1818
+ default:
1819
+ throw new Error('Illegal argument: ' + widgetOrArea);
1820
+ }
1821
+ }
1822
+ const widget = this.toTrackedStack(widgetOrArea.id).pop();
1823
+ if (!widget) {
1824
+ return undefined;
1825
+ }
1826
+ const widgetTitle = widget.title;
1827
+ const mainPanelTabBar = this.mainPanel.findTabBar(widgetTitle);
1828
+ if (mainPanelTabBar) {
1829
+ return mainPanelTabBar;
1830
+ }
1831
+ const bottomPanelTabBar = this.bottomPanel.findTabBar(widgetTitle);
1832
+ if (bottomPanelTabBar) {
1833
+ return bottomPanelTabBar;
1834
+ }
1835
+ const leftPanelTabBar = this.leftPanelHandler.tabBar;
1836
+ if (ArrayExt.firstIndexOf(leftPanelTabBar.titles, widgetTitle) > -1) {
1837
+ return leftPanelTabBar;
1838
+ }
1839
+ const rightPanelTabBar = this.rightPanelHandler.tabBar;
1840
+ if (ArrayExt.firstIndexOf(rightPanelTabBar.titles, widgetTitle) > -1) {
1841
+ return rightPanelTabBar;
1842
+ }
1843
+ return undefined;
1844
+ }
1845
+
1846
+ /**
1847
+ * The tab bars contained in the main shell area. If there is no widget in the main area, the
1848
+ * returned array is empty.
1849
+ */
1850
+ get mainAreaTabBars(): TabBar<Widget>[] {
1851
+ return toArray(this.mainPanel.tabBars());
1852
+ }
1853
+
1854
+ /**
1855
+ * The tab bars contained in the bottom shell area. If there is no widget in the bottom area,
1856
+ * the returned array is empty.
1857
+ */
1858
+ get bottomAreaTabBars(): TabBar<Widget>[] {
1859
+ return toArray(this.bottomPanel.tabBars());
1860
+ }
1861
+
1862
+ /**
1863
+ * The tab bars contained in all shell areas.
1864
+ */
1865
+ get allTabBars(): TabBar<Widget>[] {
1866
+ return [...this.mainAreaTabBars, ...this.bottomAreaTabBars, this.leftPanelHandler.tabBar, this.rightPanelHandler.tabBar];
1867
+ }
1868
+
1869
+ /*
1870
+ * Activate the next tab in the current tab bar.
1871
+ */
1872
+ activateNextTabInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1873
+ const index = this.nextTabIndexInTabBar(current);
1874
+ if (!current || index === -1) {
1875
+ return false;
1876
+ }
1877
+ current.currentIndex = index;
1878
+ if (current.currentTitle) {
1879
+ this.activateWidget(current.currentTitle.owner.id);
1880
+ }
1881
+ return true;
1882
+ }
1883
+
1884
+ nextTabIndexInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): number {
1885
+ if (!current || current.titles.length <= 1) {
1886
+ return -1;
1887
+ }
1888
+ const index = current.currentIndex;
1889
+ if (index === -1) {
1890
+ return -1;
1891
+ }
1892
+ if (index < current.titles.length - 1) {
1893
+ return index + 1;
1894
+ }
1895
+ return 0;
1896
+ }
1897
+
1898
+ activateNextTab(): boolean {
1899
+ const current = this.currentTabBar;
1900
+ if (current) {
1901
+ const ci = current.currentIndex;
1902
+ if (ci !== -1) {
1903
+ if (ci < current.titles.length - 1) {
1904
+ current.currentIndex += 1;
1905
+ if (current.currentTitle) {
1906
+ this.activateWidget(current.currentTitle.owner.id);
1907
+ }
1908
+ return true;
1909
+ } else if (ci === current.titles.length - 1) {
1910
+ return this.activateNextTabBar(current);
1911
+ }
1912
+ }
1913
+ }
1914
+ return false;
1915
+ }
1916
+
1917
+ activateNextTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1918
+ const nextBar = this.nextTabBar(current);
1919
+ if (nextBar) {
1920
+ nextBar.currentIndex = 0;
1921
+ if (nextBar.currentTitle) {
1922
+ this.activateWidget(nextBar.currentTitle.owner.id);
1923
+ }
1924
+ return true;
1925
+ }
1926
+ return false;
1927
+ }
1928
+
1929
+ /**
1930
+ * Return the tab bar next to the given tab bar; return the given tab bar if there is no adjacent one.
1931
+ */
1932
+ nextTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): TabBar<Widget> | undefined {
1933
+ let bars = toArray(this.bottomPanel.tabBars());
1934
+ let len = bars.length;
1935
+ let ci = ArrayExt.firstIndexOf(bars, current);
1936
+ if (ci < 0) {
1937
+ bars = toArray(this.mainPanel.tabBars());
1938
+ len = bars.length;
1939
+ ci = ArrayExt.firstIndexOf(bars, current);
1940
+ }
1941
+ if (ci >= 0 && ci < len - 1) {
1942
+ return bars[ci + 1];
1943
+ } else if (ci >= 0 && ci === len - 1) {
1944
+ return bars[0];
1945
+ } else {
1946
+ return current;
1947
+ }
1948
+ }
1949
+
1950
+ /*
1951
+ * Activate the previous tab in the current tab bar.
1952
+ */
1953
+ activatePreviousTabInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
1954
+ const index = this.previousTabIndexInTabBar(current);
1955
+ if (!current || index === -1) {
1956
+ return false;
1957
+ }
1958
+ current.currentIndex = index;
1959
+ if (current.currentTitle) {
1960
+ this.activateWidget(current.currentTitle.owner.id);
1961
+ }
1962
+ return true;
1963
+ }
1964
+
1965
+ previousTabIndexInTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): number {
1966
+ if (!current || current.titles.length <= 1) {
1967
+ return -1;
1968
+ }
1969
+ const index = current.currentIndex;
1970
+ if (index === -1) {
1971
+ return -1;
1972
+ }
1973
+ if (index > 0) {
1974
+ return index - 1;
1975
+ }
1976
+ return current.titles.length - 1;
1977
+ }
1978
+
1979
+ activatePreviousTab(): boolean {
1980
+ const current = this.currentTabBar;
1981
+ if (current) {
1982
+ const ci = current.currentIndex;
1983
+ if (ci !== -1) {
1984
+ if (ci > 0) {
1985
+ current.currentIndex -= 1;
1986
+ if (current.currentTitle) {
1987
+ this.activateWidget(current.currentTitle.owner.id);
1988
+ }
1989
+ return true;
1990
+ } else if (ci === 0) {
1991
+ if (current && current.titles.length > 0) {
1992
+ current.currentIndex = current.titles.length - 1;
1993
+ if (current.currentTitle) {
1994
+ this.activateWidget(current.currentTitle.owner.id);
1995
+ }
1996
+ return true;
1997
+ }
1998
+ return this.activatePreviousTabBar(current);
1999
+ }
2000
+ }
2001
+ }
2002
+ return false;
2003
+ }
2004
+
2005
+ activatePreviousTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): boolean {
2006
+ const prevBar = this.previousTabBar(current);
2007
+ if (!prevBar) {
2008
+ return false;
2009
+ }
2010
+ if (!prevBar.currentTitle) {
2011
+ prevBar.currentIndex = prevBar.titles.length - 1;
2012
+ }
2013
+ if (prevBar.currentTitle) {
2014
+ this.activateWidget(prevBar.currentTitle.owner.id);
2015
+ }
2016
+ return true;
2017
+ }
2018
+
2019
+ /**
2020
+ * Return the tab bar previous to the given tab bar; return the given tab bar if there is no adjacent one.
2021
+ */
2022
+ previousTabBar(current: TabBar<Widget> | undefined = this.currentTabBar): TabBar<Widget> | undefined {
2023
+ const bars = toArray(this.mainPanel.tabBars());
2024
+ const len = bars.length;
2025
+ const ci = ArrayExt.firstIndexOf(bars, current);
2026
+ if (ci > 0) {
2027
+ return bars[ci - 1];
2028
+ } else if (ci === 0) {
2029
+ return bars[len - 1];
2030
+ } else {
2031
+ return current;
2032
+ }
2033
+ }
2034
+
2035
+ /**
2036
+ * Test whether the current widget is dirty.
2037
+ */
2038
+ canSave(): boolean {
2039
+ return this.saveResourceService.canSave(this.currentWidget);
2040
+ }
2041
+
2042
+ /**
2043
+ * Save the current widget if it is dirty.
2044
+ */
2045
+ async save(options?: SaveOptions): Promise<void> {
2046
+ await this.saveResourceService.save(this.currentWidget, options);
2047
+ }
2048
+
2049
+ /**
2050
+ * Test whether there is a dirty widget.
2051
+ */
2052
+ canSaveAll(): boolean {
2053
+ return this.tracker.widgets.some(widget => this.saveResourceService.canSave(widget));
2054
+ }
2055
+
2056
+ /**
2057
+ * Save all dirty widgets.
2058
+ */
2059
+ async saveAll(options?: SaveOptions): Promise<void> {
2060
+ for (const widget of this.widgets) {
2061
+ if (this.saveResourceService.canSaveNotSaveAs(widget)) {
2062
+ await this.saveResourceService.save(widget, options);
2063
+ }
2064
+ }
2065
+ }
2066
+
2067
+ /**
2068
+ * Returns a snapshot of all tracked widgets to allow async modifications.
2069
+ */
2070
+ get widgets(): ReadonlyArray<Widget> {
2071
+ return [...this.tracker.widgets];
2072
+ }
2073
+
2074
+ getWidgetById(id: string): Widget | undefined {
2075
+ for (const widget of this.tracker.widgets) {
2076
+ if (widget.id === id) {
2077
+ return widget;
2078
+ }
2079
+ }
2080
+ return undefined;
2081
+ }
2082
+
2083
+ canToggleMaximized(widget: Widget | undefined = this.currentWidget): boolean {
2084
+ const area = widget && this.getAreaFor(widget);
2085
+ return area === 'main' || area === 'bottom';
2086
+ }
2087
+
2088
+ toggleMaximized(widget: Widget | undefined = this.currentWidget): void {
2089
+ const area = widget && this.getAreaPanelFor(widget);
2090
+ if (area instanceof TheiaDockPanel && (area === this.mainPanel || area === this.bottomPanel)) {
2091
+ area.toggleMaximized();
2092
+ this.revealWidget(widget!.id);
2093
+ }
2094
+ }
2095
+
2096
+ }
2097
+
2098
+ /**
2099
+ * The namespace for `ApplicationShell` class statics.
2100
+ */
2101
+ export namespace ApplicationShell {
2102
+ /**
2103
+ * The areas of the application shell where widgets can reside.
2104
+ */
2105
+ export type Area = 'main' | 'top' | 'left' | 'right' | 'bottom' | 'secondaryWindow';
2106
+
2107
+ export const areaLabels: Record<Area, string> = {
2108
+ main: nls.localizeByDefault('Main'),
2109
+ top: nls.localizeByDefault('Top'),
2110
+ left: nls.localizeByDefault('Left'),
2111
+ right: nls.localizeByDefault('Right'),
2112
+ bottom: nls.localizeByDefault('Bottom'),
2113
+ secondaryWindow: nls.localize('theia/shell-area/secondary', 'Secondary Window'),
2114
+ };
2115
+
2116
+ /**
2117
+ * The _side areas_ are those shell areas that can be collapsed and expanded,
2118
+ * i.e. `left`, `right`, and `bottom`.
2119
+ */
2120
+ export function isSideArea(area?: string): area is 'left' | 'right' | 'bottom' {
2121
+ return area === 'left' || area === 'right' || area === 'bottom';
2122
+ }
2123
+
2124
+ export function isValidArea(area?: unknown): area is ApplicationShell.Area {
2125
+ const areas = ['main', 'top', 'left', 'right', 'bottom', 'secondaryWindow'];
2126
+ return typeof area === 'string' && areas.includes(area);
2127
+ }
2128
+
2129
+ /**
2130
+ * General options for the application shell. These are passed on construction and can be modified
2131
+ * through dependency injection (`ApplicationShellOptions` symbol).
2132
+ */
2133
+ export interface Options extends Widget.IOptions {
2134
+ bottomPanel: BottomPanelOptions;
2135
+ leftPanel: SidePanel.Options;
2136
+ rightPanel: SidePanel.Options;
2137
+ }
2138
+
2139
+ export interface BottomPanelOptions extends SidePanel.Options {
2140
+ }
2141
+
2142
+ /**
2143
+ * The default values for application shell options.
2144
+ */
2145
+ export const DEFAULT_OPTIONS = Object.freeze(<Options>{
2146
+ bottomPanel: Object.freeze(<BottomPanelOptions>{
2147
+ emptySize: 140,
2148
+ expandThreshold: 160,
2149
+ expandDuration: 0,
2150
+ initialSizeRatio: 0.382
2151
+ }),
2152
+ leftPanel: Object.freeze(<SidePanel.Options>{
2153
+ emptySize: 140,
2154
+ expandThreshold: 140,
2155
+ expandDuration: 0,
2156
+ initialSizeRatio: 0.191
2157
+ }),
2158
+ rightPanel: Object.freeze(<SidePanel.Options>{
2159
+ emptySize: 140,
2160
+ expandThreshold: 140,
2161
+ expandDuration: 0,
2162
+ initialSizeRatio: 0.191
2163
+ })
2164
+ });
2165
+
2166
+ /**
2167
+ * Whether a widget should be opened to the side tab bar relatively to the reference widget.
2168
+ */
2169
+ export type OpenToSideMode = 'open-to-left' | 'open-to-right';
2170
+
2171
+ export function isOpenToSideMode(mode: unknown): mode is OpenToSideMode {
2172
+ return mode === 'open-to-left' || mode === 'open-to-right';
2173
+ }
2174
+
2175
+ /**
2176
+ * Options for adding a widget to the application shell.
2177
+ */
2178
+ export interface WidgetOptions extends SidePanel.WidgetOptions {
2179
+ /**
2180
+ * The area of the application shell where the widget will reside.
2181
+ */
2182
+ area?: Area;
2183
+ /**
2184
+ * The insertion mode for adding the widget.
2185
+ *
2186
+ * The default is `'tab-after'`.
2187
+ */
2188
+ mode?: DockLayout.InsertMode | OpenToSideMode
2189
+ /**
2190
+ * The reference widget for the insert location.
2191
+ *
2192
+ * The default is `undefined`.
2193
+ */
2194
+ ref?: Widget;
2195
+ }
2196
+
2197
+ export interface CloseOptions {
2198
+ /**
2199
+ * if optional then a user will be prompted
2200
+ * if undefined then close will be canceled
2201
+ * if true then will be saved on close
2202
+ * if false then won't be saved on close
2203
+ */
2204
+ save?: boolean | undefined
2205
+ }
2206
+
2207
+ /**
2208
+ * Data to save and load the application shell layout.
2209
+ */
2210
+ export interface LayoutData {
2211
+ version?: string | ApplicationShellLayoutVersion,
2212
+ mainPanel?: DockPanel.ILayoutConfig;
2213
+ mainPanelPinned?: boolean[];
2214
+ bottomPanel?: BottomPanelLayoutData;
2215
+ leftPanel?: SidePanel.LayoutData;
2216
+ rightPanel?: SidePanel.LayoutData;
2217
+ activeWidgetId?: string;
2218
+ }
2219
+
2220
+ /**
2221
+ * Data to save and load the bottom panel layout.
2222
+ */
2223
+ export interface BottomPanelLayoutData {
2224
+ config?: DockPanel.ILayoutConfig;
2225
+ size?: number;
2226
+ expanded?: boolean;
2227
+ pinned?: boolean[];
2228
+ }
2229
+
2230
+ /**
2231
+ * Exposes widgets which activation state should be tracked by shell.
2232
+ */
2233
+ export interface TrackableWidgetProvider {
2234
+ getTrackableWidgets(): Widget[]
2235
+ readonly onDidChangeTrackableWidgets?: CommonEvent<Widget[]>
2236
+ /**
2237
+ * Make visible and focus a trackable widget for the given id.
2238
+ * If not implemented then `activate` request will be sent to a child widget directly.
2239
+ */
2240
+ activateWidget?(id: string): Widget | undefined;
2241
+ /**
2242
+ * Make visible a trackable widget for the given id.
2243
+ * If not implemented then a widget should be always visible when an owner is visible.
2244
+ */
2245
+ revealWidget?(id: string): Widget | undefined;
2246
+ }
2247
+
2248
+ export namespace TrackableWidgetProvider {
2249
+ export function is(widget: unknown): widget is TrackableWidgetProvider {
2250
+ return isObject(widget) && 'getTrackableWidgets' in widget;
2251
+ }
2252
+ }
2253
+
2254
+ }