@theia/core 1.74.0-next.9 → 1.74.1

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 (252) hide show
  1. package/README.md +10 -10
  2. package/i18n/nls.cs.json +143 -16
  3. package/i18n/nls.de.json +143 -16
  4. package/i18n/nls.es.json +143 -16
  5. package/i18n/nls.fr.json +143 -16
  6. package/i18n/nls.hu.json +143 -16
  7. package/i18n/nls.it.json +143 -16
  8. package/i18n/nls.ja.json +143 -16
  9. package/i18n/nls.json +143 -16
  10. package/i18n/nls.ko.json +143 -16
  11. package/i18n/nls.pl.json +143 -16
  12. package/i18n/nls.pt-br.json +143 -16
  13. package/i18n/nls.ru.json +143 -16
  14. package/i18n/nls.tr.json +143 -16
  15. package/i18n/nls.zh-cn.json +143 -16
  16. package/i18n/nls.zh-tw.json +143 -16
  17. package/lib/browser/browser-clipboard-service.d.ts +3 -0
  18. package/lib/browser/browser-clipboard-service.d.ts.map +1 -1
  19. package/lib/browser/browser-clipboard-service.js +8 -1
  20. package/lib/browser/browser-clipboard-service.js.map +1 -1
  21. package/lib/browser/catalog.json +505 -46
  22. package/lib/browser/clipboard-service.d.ts +11 -0
  23. package/lib/browser/clipboard-service.d.ts.map +1 -1
  24. package/lib/browser/clipboard-service.js.map +1 -1
  25. package/lib/browser/common-frontend-contribution.d.ts +3 -0
  26. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  27. package/lib/browser/common-frontend-contribution.js +22 -10
  28. package/lib/browser/common-frontend-contribution.js.map +1 -1
  29. package/lib/browser/common-frontend-contribution.spec.d.ts +2 -0
  30. package/lib/browser/common-frontend-contribution.spec.d.ts.map +1 -0
  31. package/lib/browser/common-frontend-contribution.spec.js +71 -0
  32. package/lib/browser/common-frontend-contribution.spec.js.map +1 -0
  33. package/lib/browser/frontend-application-contribution.d.ts +1 -1
  34. package/lib/browser/frontend-application-module.d.ts +2 -2
  35. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  36. package/lib/browser/frontend-application-module.js +13 -2
  37. package/lib/browser/frontend-application-module.js.map +1 -1
  38. package/lib/browser/frontend-application.d.ts.map +1 -1
  39. package/lib/browser/frontend-application.js +12 -2
  40. package/lib/browser/frontend-application.js.map +1 -1
  41. package/lib/browser/index.d.ts +1 -0
  42. package/lib/browser/index.d.ts.map +1 -1
  43. package/lib/browser/index.js +1 -0
  44. package/lib/browser/index.js.map +1 -1
  45. package/lib/browser/keybinding.d.ts.map +1 -1
  46. package/lib/browser/keybinding.js +12 -7
  47. package/lib/browser/keybinding.js.map +1 -1
  48. package/lib/browser/perspective-service.d.ts +173 -0
  49. package/lib/browser/perspective-service.d.ts.map +1 -0
  50. package/lib/browser/perspective-service.js +484 -0
  51. package/lib/browser/perspective-service.js.map +1 -0
  52. package/lib/browser/perspective-service.spec.d.ts +2 -0
  53. package/lib/browser/perspective-service.spec.d.ts.map +1 -0
  54. package/lib/browser/perspective-service.spec.js +1806 -0
  55. package/lib/browser/perspective-service.spec.js.map +1 -0
  56. package/lib/browser/preferences/preference-contribution.d.ts.map +1 -1
  57. package/lib/browser/preferences/preference-contribution.js +9 -1
  58. package/lib/browser/preferences/preference-contribution.js.map +1 -1
  59. package/lib/browser/preferences/preference-service.spec.js +63 -0
  60. package/lib/browser/preferences/preference-service.spec.js.map +1 -1
  61. package/lib/browser/shell/application-shell.d.ts +7 -0
  62. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  63. package/lib/browser/shell/application-shell.js +38 -28
  64. package/lib/browser/shell/application-shell.js.map +1 -1
  65. package/lib/browser/shell/shell-layout-restorer.d.ts +9 -0
  66. package/lib/browser/shell/shell-layout-restorer.d.ts.map +1 -1
  67. package/lib/browser/shell/shell-layout-restorer.js +124 -14
  68. package/lib/browser/shell/shell-layout-restorer.js.map +1 -1
  69. package/lib/browser/shell/shell-layout-restorer.spec.d.ts +2 -0
  70. package/lib/browser/shell/shell-layout-restorer.spec.d.ts.map +1 -0
  71. package/lib/browser/shell/shell-layout-restorer.spec.js +539 -0
  72. package/lib/browser/shell/shell-layout-restorer.spec.js.map +1 -0
  73. package/lib/browser/shell/view-contribution.d.ts +2 -0
  74. package/lib/browser/shell/view-contribution.d.ts.map +1 -1
  75. package/lib/browser/shell/view-contribution.js +5 -1
  76. package/lib/browser/shell/view-contribution.js.map +1 -1
  77. package/lib/browser/status-bar/status-bar.d.ts +2 -0
  78. package/lib/browser/status-bar/status-bar.d.ts.map +1 -1
  79. package/lib/browser/status-bar/status-bar.js +11 -3
  80. package/lib/browser/status-bar/status-bar.js.map +1 -1
  81. package/lib/browser/tree/tree-consistency.spec.js +103 -0
  82. package/lib/browser/tree/tree-consistency.spec.js.map +1 -1
  83. package/lib/browser/tree/tree-widget.d.ts +7 -33
  84. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  85. package/lib/browser/tree/tree-widget.js +7 -54
  86. package/lib/browser/tree/tree-widget.js.map +1 -1
  87. package/lib/browser/tree/tree.d.ts.map +1 -1
  88. package/lib/browser/tree/tree.js +6 -0
  89. package/lib/browser/tree/tree.js.map +1 -1
  90. package/lib/browser/widgets/index.d.ts +1 -0
  91. package/lib/browser/widgets/index.d.ts.map +1 -1
  92. package/lib/browser/widgets/index.js +1 -0
  93. package/lib/browser/widgets/index.js.map +1 -1
  94. package/lib/browser/widgets/select-component.d.ts +15 -2
  95. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  96. package/lib/browser/widgets/select-component.js +86 -24
  97. package/lib/browser/widgets/select-component.js.map +1 -1
  98. package/lib/browser/widgets/tab-bar-tracker.d.ts +23 -0
  99. package/lib/browser/widgets/tab-bar-tracker.d.ts.map +1 -0
  100. package/lib/browser/widgets/tab-bar-tracker.js +65 -0
  101. package/lib/browser/widgets/tab-bar-tracker.js.map +1 -0
  102. package/lib/browser/widgets/tab-bar-tracker.spec.d.ts +2 -0
  103. package/lib/browser/widgets/tab-bar-tracker.spec.d.ts.map +1 -0
  104. package/lib/browser/widgets/tab-bar-tracker.spec.js +109 -0
  105. package/lib/browser/widgets/tab-bar-tracker.spec.js.map +1 -0
  106. package/lib/browser/window/default-secondary-window-service.d.ts +2 -0
  107. package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
  108. package/lib/browser/window/default-secondary-window-service.js +8 -2
  109. package/lib/browser/window/default-secondary-window-service.js.map +1 -1
  110. package/lib/browser/window/default-window-service.d.ts +19 -0
  111. package/lib/browser/window/default-window-service.d.ts.map +1 -1
  112. package/lib/browser/window/default-window-service.js +34 -5
  113. package/lib/browser/window/default-window-service.js.map +1 -1
  114. package/lib/browser/window/default-window-service.spec.js +22 -0
  115. package/lib/browser/window/default-window-service.spec.js.map +1 -1
  116. package/lib/browser/window/secondary-window-service.d.ts +7 -0
  117. package/lib/browser/window/secondary-window-service.d.ts.map +1 -1
  118. package/lib/browser/window/window-service.d.ts +1 -1
  119. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts +13 -2
  120. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts.map +1 -1
  121. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js +31 -3
  122. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js.map +1 -1
  123. package/lib/common/preferences/index.d.ts +1 -0
  124. package/lib/common/preferences/index.d.ts.map +1 -1
  125. package/lib/common/preferences/index.js +1 -0
  126. package/lib/common/preferences/index.js.map +1 -1
  127. package/lib/common/preferences/preference-provider.d.ts +15 -0
  128. package/lib/common/preferences/preference-provider.d.ts.map +1 -1
  129. package/lib/common/preferences/preference-provider.js +21 -1
  130. package/lib/common/preferences/preference-provider.js.map +1 -1
  131. package/lib/common/preferences/preference-provider.spec.js +17 -0
  132. package/lib/common/preferences/preference-provider.spec.js.map +1 -1
  133. package/lib/common/preferences/preference-scope.d.ts +6 -1
  134. package/lib/common/preferences/preference-scope.d.ts.map +1 -1
  135. package/lib/common/preferences/preference-scope.js +5 -0
  136. package/lib/common/preferences/preference-scope.js.map +1 -1
  137. package/lib/common/preferences/preference-scope.spec.js +5 -3
  138. package/lib/common/preferences/preference-scope.spec.js.map +1 -1
  139. package/lib/common/preferences/preference-service.d.ts +19 -0
  140. package/lib/common/preferences/preference-service.d.ts.map +1 -1
  141. package/lib/common/preferences/preference-service.js +34 -5
  142. package/lib/common/preferences/preference-service.js.map +1 -1
  143. package/lib/common/preferences/session-preference-provider.d.ts +17 -0
  144. package/lib/common/preferences/session-preference-provider.d.ts.map +1 -0
  145. package/lib/common/preferences/session-preference-provider.js +77 -0
  146. package/lib/common/preferences/session-preference-provider.js.map +1 -0
  147. package/lib/common/preferences/session-preference-provider.spec.d.ts +2 -0
  148. package/lib/common/preferences/session-preference-provider.spec.d.ts.map +1 -0
  149. package/lib/common/preferences/session-preference-provider.spec.js +71 -0
  150. package/lib/common/preferences/session-preference-provider.spec.js.map +1 -0
  151. package/lib/electron-browser/electron-clipboard-service.d.ts +3 -0
  152. package/lib/electron-browser/electron-clipboard-service.d.ts.map +1 -1
  153. package/lib/electron-browser/electron-clipboard-service.js +6 -0
  154. package/lib/electron-browser/electron-clipboard-service.js.map +1 -1
  155. package/lib/electron-browser/menu/electron-menu-contribution.js +1 -1
  156. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  157. package/lib/electron-browser/preload.d.ts.map +1 -1
  158. package/lib/electron-browser/preload.js +2 -1
  159. package/lib/electron-browser/preload.js.map +1 -1
  160. package/lib/electron-browser/window/electron-secondary-window-service.js +1 -1
  161. package/lib/electron-browser/window/electron-secondary-window-service.js.map +1 -1
  162. package/lib/electron-browser/window/electron-window-service.js +3 -3
  163. package/lib/electron-browser/window/electron-window-service.js.map +1 -1
  164. package/lib/electron-common/electron-api.d.ts +2 -0
  165. package/lib/electron-common/electron-api.d.ts.map +1 -1
  166. package/lib/electron-common/electron-api.js +2 -1
  167. package/lib/electron-common/electron-api.js.map +1 -1
  168. package/lib/electron-main/electron-api-main.d.ts.map +1 -1
  169. package/lib/electron-main/electron-api-main.js +43 -0
  170. package/lib/electron-main/electron-api-main.js.map +1 -1
  171. package/lib/electron-main/electron-main-application.d.ts.map +1 -1
  172. package/lib/electron-main/electron-main-application.js +3 -0
  173. package/lib/electron-main/electron-main-application.js.map +1 -1
  174. package/lib/electron-node/hosting/electron-backend-hosting-module.d.ts.map +1 -1
  175. package/lib/electron-node/hosting/electron-backend-hosting-module.js +7 -0
  176. package/lib/electron-node/hosting/electron-backend-hosting-module.js.map +1 -1
  177. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.d.ts +2 -0
  178. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.d.ts.map +1 -0
  179. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js +39 -0
  180. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js.map +1 -0
  181. package/lib/node/hosting/backend-hosting-module.d.ts.map +1 -1
  182. package/lib/node/hosting/backend-hosting-module.js +4 -1
  183. package/lib/node/hosting/backend-hosting-module.js.map +1 -1
  184. package/lib/node/hosting/browser-connection-token.d.ts +29 -1
  185. package/lib/node/hosting/browser-connection-token.d.ts.map +1 -1
  186. package/lib/node/hosting/browser-connection-token.js +25 -1
  187. package/lib/node/hosting/browser-connection-token.js.map +1 -1
  188. package/lib/node/hosting/browser-connection-token.spec.js +70 -0
  189. package/lib/node/hosting/browser-connection-token.spec.js.map +1 -1
  190. package/lib/node/index.d.ts +1 -0
  191. package/lib/node/index.d.ts.map +1 -1
  192. package/lib/node/index.js +3 -1
  193. package/lib/node/index.js.map +1 -1
  194. package/package.json +11 -11
  195. package/src/browser/browser-clipboard-service.ts +7 -1
  196. package/src/browser/clipboard-service.ts +11 -0
  197. package/src/browser/common-frontend-contribution.spec.ts +84 -0
  198. package/src/browser/common-frontend-contribution.ts +22 -10
  199. package/src/browser/frontend-application-contribution.ts +1 -1
  200. package/src/browser/frontend-application-module.ts +15 -3
  201. package/src/browser/frontend-application.ts +12 -4
  202. package/src/browser/index.ts +1 -0
  203. package/src/browser/keybinding.ts +12 -7
  204. package/src/browser/perspective-service.spec.ts +2270 -0
  205. package/src/browser/perspective-service.ts +625 -0
  206. package/src/browser/preferences/preference-contribution.ts +9 -1
  207. package/src/browser/preferences/preference-service.spec.ts +72 -0
  208. package/src/browser/shell/application-shell.ts +41 -26
  209. package/src/browser/shell/shell-layout-restorer.spec.ts +746 -0
  210. package/src/browser/shell/shell-layout-restorer.ts +134 -13
  211. package/src/browser/shell/view-contribution.ts +6 -1
  212. package/src/browser/status-bar/status-bar.tsx +13 -3
  213. package/src/browser/style/select-component.css +16 -0
  214. package/src/browser/style/sidepanel.css +5 -0
  215. package/src/browser/style/status-bar.css +1 -1
  216. package/src/browser/tree/tree-consistency.spec.ts +119 -0
  217. package/src/browser/tree/tree-widget.tsx +12 -78
  218. package/src/browser/tree/tree.ts +6 -0
  219. package/src/browser/widgets/index.ts +1 -0
  220. package/src/browser/widgets/select-component.tsx +90 -24
  221. package/src/browser/widgets/tab-bar-tracker.spec.ts +121 -0
  222. package/src/browser/widgets/tab-bar-tracker.ts +68 -0
  223. package/src/browser/window/default-secondary-window-service.ts +8 -2
  224. package/src/browser/window/default-window-service.spec.ts +22 -0
  225. package/src/browser/window/default-window-service.ts +37 -5
  226. package/src/browser/window/secondary-window-service.ts +7 -0
  227. package/src/browser/window/window-service.ts +1 -1
  228. package/src/browser-only/messaging/frontend-only-service-connection-provider.ts +32 -3
  229. package/src/common/i18n/nls.metadata.json +4149 -888
  230. package/src/common/preferences/index.ts +1 -0
  231. package/src/common/preferences/preference-provider.spec.ts +17 -0
  232. package/src/common/preferences/preference-provider.ts +22 -1
  233. package/src/common/preferences/preference-scope.spec.ts +5 -3
  234. package/src/common/preferences/preference-scope.ts +6 -1
  235. package/src/common/preferences/preference-service.ts +39 -5
  236. package/src/common/preferences/session-preference-provider.spec.ts +78 -0
  237. package/src/common/preferences/session-preference-provider.ts +69 -0
  238. package/src/electron-browser/electron-clipboard-service.ts +5 -0
  239. package/src/electron-browser/menu/electron-menu-contribution.ts +1 -1
  240. package/src/electron-browser/menu/electron-menu-style.css +3 -1
  241. package/src/electron-browser/preload.ts +5 -2
  242. package/src/electron-browser/window/electron-secondary-window-service.ts +1 -1
  243. package/src/electron-browser/window/electron-window-service.ts +3 -3
  244. package/src/electron-common/electron-api.ts +4 -0
  245. package/src/electron-main/electron-api-main.ts +56 -3
  246. package/src/electron-main/electron-main-application.ts +3 -0
  247. package/src/electron-node/hosting/electron-backend-hosting-module.spec.ts +42 -0
  248. package/src/electron-node/hosting/electron-backend-hosting-module.ts +8 -0
  249. package/src/node/hosting/backend-hosting-module.ts +5 -2
  250. package/src/node/hosting/browser-connection-token.spec.ts +92 -0
  251. package/src/node/hosting/browser-connection-token.ts +45 -1
  252. package/src/node/index.ts +1 -0
@@ -0,0 +1,173 @@
1
+ import { DockLayout } from '@lumino/widgets';
2
+ import { ApplicationShell, WidgetAreaResolver } from './shell/application-shell';
3
+ import { SidePanel } from './shell/side-panel-handler';
4
+ import { FrontendApplicationContribution } from './frontend-application-contribution';
5
+ import { WidgetManager } from './widget-manager';
6
+ import { ContributionProvider } from '../common/contribution-provider';
7
+ import { Command, CommandContribution, CommandRegistry } from '../common/command';
8
+ import { Emitter, Event } from '../common/event';
9
+ import { ILogger } from '../common/logger';
10
+ import { QuickInputService } from '../common/quick-pick-service';
11
+ import { ContextKeyService } from './context-key-service';
12
+ export declare const ACTIVE_PERSPECTIVE_CONTEXT_KEY = "activePerspectiveId";
13
+ export interface PerspectiveChromeOptions {
14
+ /** Areas to collapse on first activation. User can re-expand freely. */
15
+ collapseAreas?: ('left' | 'right' | 'bottom')[];
16
+ }
17
+ export interface PerspectiveDescriptor {
18
+ id: string;
19
+ label: string;
20
+ /** Widget/view-container ID → target shell area */
21
+ viewPlacements: Map<string, ApplicationShell.Area>;
22
+ /** Chrome control options for this perspective */
23
+ chromeOptions?: PerspectiveChromeOptions;
24
+ /** Per-area primary view: the widget to activate last in each shell area, so it gets focus. */
25
+ primaryViews?: Partial<Record<ApplicationShell.Area, string>>;
26
+ /** Called when perspective is activated */
27
+ onActivate?(shell: ApplicationShell): void;
28
+ /** Called when switching away */
29
+ onDeactivate?(shell: ApplicationShell): void;
30
+ }
31
+ export declare const PerspectiveService: unique symbol;
32
+ export interface PerspectiveService {
33
+ /** Event fired whenever the active perspective changes. The payload is the new perspective ID. */
34
+ readonly onDidChangePerspective: Event<string>;
35
+ /**
36
+ * Registers a new perspective descriptor.
37
+ * Contributions should call this from their `PerspectiveContribution.registerPerspectives` callback.
38
+ */
39
+ registerPerspective(descriptor: PerspectiveDescriptor): void;
40
+ /**
41
+ * Switches the workbench to the given perspective.
42
+ * Saves the current perspective's layout, then restores the target perspective's layout
43
+ * (or applies its `viewPlacements` on first activation). Concurrent calls are serialized.
44
+ */
45
+ switchPerspective(id: string): Promise<void>;
46
+ /** Returns the descriptor of the currently active perspective, or `undefined` if none. */
47
+ getActivePerspective(): PerspectiveDescriptor | undefined;
48
+ /** Returns the target shell area for a widget in the active perspective, or `undefined` if unmapped. */
49
+ getAreaForView(viewId: string): ApplicationShell.Area | undefined;
50
+ /** Returns all registered perspective descriptors. */
51
+ getRegisteredPerspectives(): PerspectiveDescriptor[];
52
+ /** Returns the ID of the currently active perspective. A convenient alternative to `getActivePerspective()?.id` that always returns a string. */
53
+ getActivePerspectiveId(): string;
54
+ /**
55
+ * Resets the active perspective to its programmatic state (viewPlacements from its descriptor),
56
+ * discarding the saved layout. Does not affect other perspectives.
57
+ */
58
+ resetCurrentPerspective(): Promise<void>;
59
+ }
60
+ export declare const PerspectiveServiceInternal: unique symbol;
61
+ /**
62
+ * Internal plumbing API for layout persistence infrastructure.
63
+ * General consumers should use {@link PerspectiveService} instead.
64
+ */
65
+ export interface PerspectiveServiceInternal {
66
+ /**
67
+ * Returns the ID of the currently active perspective.
68
+ * @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
69
+ */
70
+ getActivePerspectiveId(): string;
71
+ /**
72
+ * Returns the IDs of all perspectives that have a saved (in-memory) layout snapshot.
73
+ * @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
74
+ */
75
+ getSavedPerspectiveIds(): string[];
76
+ /**
77
+ * Returns the saved in-memory layout for a perspective, or `undefined` if none exists.
78
+ * @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
79
+ */
80
+ getSavedLayout(perspectiveId: string): ApplicationShell.LayoutData | undefined;
81
+ /**
82
+ * Stores an in-memory layout snapshot for a perspective.
83
+ * @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
84
+ */
85
+ setSavedLayout(perspectiveId: string, layout: ApplicationShell.LayoutData): void;
86
+ /**
87
+ * Sets the active perspective ID (without triggering a switch).
88
+ * Returns `true` if the ID corresponds to a registered perspective, `false` otherwise.
89
+ * @internal Plumbing API, used by `ShellLayoutRestorer` during layout restore.
90
+ */
91
+ setActivePerspectiveId(id: string): boolean;
92
+ /**
93
+ * The ID of the built-in default perspective.
94
+ * @internal Plumbing API, used by `ShellLayoutRestorer` for legacy migration.
95
+ */
96
+ readonly defaultPerspectiveId: string;
97
+ /**
98
+ * Clears all saved in-memory layout snapshots.
99
+ * @internal Plumbing API, used by `ShellLayoutRestorer` during layout reset.
100
+ */
101
+ clearSavedLayouts(): void;
102
+ /**
103
+ * Called by `ShellLayoutRestorer` after restoring a persisted layout to apply chrome options
104
+ * (e.g., status bar visibility) for the given perspective.
105
+ * @internal Plumbing API, used by `ShellLayoutRestorer` after layout restore.
106
+ */
107
+ onLayoutRestored(activePerspectiveId: string): void;
108
+ }
109
+ export declare const PerspectiveContribution: unique symbol;
110
+ export interface PerspectiveContribution {
111
+ registerPerspectives(service: PerspectiveService): void;
112
+ }
113
+ export declare class WidgetAreaResolverImpl implements WidgetAreaResolver {
114
+ protected activePlacementMap: Map<string, ApplicationShell.Area>;
115
+ setActivePlacementMap(map: Map<string, ApplicationShell.Area>): void;
116
+ resolveArea(widgetId: string, requestedArea: ApplicationShell.Area): ApplicationShell.Area | undefined;
117
+ }
118
+ export declare class PerspectiveServiceImpl implements FrontendApplicationContribution, CommandContribution, PerspectiveService, PerspectiveServiceInternal {
119
+ static readonly SWITCH_PERSPECTIVE_COMMAND: Command;
120
+ static readonly RESET_PERSPECTIVE_COMMAND: Command;
121
+ protected readonly shell: ApplicationShell;
122
+ protected readonly widgetManager: WidgetManager;
123
+ protected readonly contributions: ContributionProvider<PerspectiveContribution> | undefined;
124
+ protected readonly appContributions: ContributionProvider<FrontendApplicationContribution>;
125
+ protected readonly quickInputService: QuickInputService | undefined;
126
+ protected readonly logger: ILogger;
127
+ protected readonly widgetAreaResolver: WidgetAreaResolver;
128
+ protected readonly contextKeyService: ContextKeyService | undefined;
129
+ static readonly DEFAULT_PERSPECTIVE_ID = "default";
130
+ readonly defaultPerspectiveId = "default";
131
+ protected readonly perspectives: Map<string, PerspectiveDescriptor>;
132
+ protected activePerspectiveId: string | undefined;
133
+ protected readonly savedLayouts: Map<string, ApplicationShell.LayoutData>;
134
+ protected readonly onDidChangePerspectiveEmitter: Emitter<string>;
135
+ readonly onDidChangePerspective: Event<string>;
136
+ protected switchInProgress: Promise<void> | undefined;
137
+ onLayoutRestored(activePerspectiveId: string): void;
138
+ initialize(): void;
139
+ onStop(): void;
140
+ protected updateActivePerspectiveContextKey(id: string): void;
141
+ registerPerspective(descriptor: PerspectiveDescriptor): void;
142
+ switchPerspective(id: string): Promise<void>;
143
+ protected doSwitchPerspective(id: string): Promise<void>;
144
+ protected applyViewPlacements(descriptor: PerspectiveDescriptor): Promise<void>;
145
+ resetCurrentPerspective(): Promise<void>;
146
+ protected doResetCurrentPerspective(): Promise<void>;
147
+ protected resetDefaultPerspective(): Promise<void>;
148
+ /**
149
+ * Views may be shared between multiple perspective. If a view exists in two or more perspectives
150
+ * and is closed in one of them, the shared widget is disposed. When switching back to the other
151
+ * perspective, we need to restore this widget (i.e. reopen the view).
152
+ * @param layout
153
+ */
154
+ protected healLayoutData(layout: ApplicationShell.LayoutData): Promise<void>;
155
+ protected healSidePanelLayout(layout: SidePanel.LayoutData): Promise<void>;
156
+ protected healDockAreaConfig(config: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig): Promise<void>;
157
+ protected collectWidgetIds(layout: ApplicationShell.LayoutData): Set<string>;
158
+ protected collectSidePanelWidgetIds(layout: SidePanel.LayoutData, ids: Set<string>): void;
159
+ protected collectDockWidgetIds(config: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig, ids: Set<string>): void;
160
+ protected detachStrayWidgets(layoutWidgetIds: Set<string>): void;
161
+ getActivePerspective(): PerspectiveDescriptor | undefined;
162
+ getAreaForView(viewId: string): ApplicationShell.Area | undefined;
163
+ getRegisteredPerspectives(): PerspectiveDescriptor[];
164
+ getActivePerspectiveId(): string;
165
+ getSavedPerspectiveIds(): string[];
166
+ getSavedLayout(perspectiveId: string): ApplicationShell.LayoutData | undefined;
167
+ setSavedLayout(perspectiveId: string, layout: ApplicationShell.LayoutData): void;
168
+ setActivePerspectiveId(id: string): boolean;
169
+ clearSavedLayouts(): void;
170
+ registerCommands(commands: CommandRegistry): void;
171
+ protected showPerspectivePicker(): Promise<void>;
172
+ }
173
+ //# sourceMappingURL=perspective-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perspective-service.d.ts","sourceRoot":"","sources":["../../src/browser/perspective-service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CA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AC,kBAAkB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI;IAchE,oBAAoB,IAAI,qBAAqB,GAAG,SAAS;IAOzD,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC,IAAI,GAAG,SAAS;IAQjE,yBAAyB,IAAI,qBAAqB,EAAE;IAIpD,sBAAsB,IAAI,MAAM;IAIhC,sBAAsB,IAAI,MAAM,EAAE;IAIlC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,CAAC,UAAU,GAAG,SAAS;IAI9E,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,GAAG,IAAI;IAIhF,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAQ3C,iBAAiB,IAAI,IAAI;IAIzB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;cAWjC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBzD"}
@@ -0,0 +1,484 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 EclipseSource GmbH.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var PerspectiveServiceImpl_1;
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.PerspectiveServiceImpl = exports.WidgetAreaResolverImpl = exports.PerspectiveContribution = exports.PerspectiveServiceInternal = exports.PerspectiveService = exports.ACTIVE_PERSPECTIVE_CONTEXT_KEY = void 0;
20
+ const tslib_1 = require("tslib");
21
+ const inversify_1 = require("inversify");
22
+ const application_shell_1 = require("./shell/application-shell");
23
+ const frontend_application_contribution_1 = require("./frontend-application-contribution");
24
+ const view_contribution_1 = require("./shell/view-contribution");
25
+ const widget_manager_1 = require("./widget-manager");
26
+ const contribution_provider_1 = require("../common/contribution-provider");
27
+ const command_1 = require("../common/command");
28
+ const event_1 = require("../common/event");
29
+ const logger_1 = require("../common/logger");
30
+ const quick_pick_service_1 = require("../common/quick-pick-service");
31
+ const nls_1 = require("../common/nls");
32
+ const common_commands_1 = require("./common-commands");
33
+ const context_key_service_1 = require("./context-key-service");
34
+ exports.ACTIVE_PERSPECTIVE_CONTEXT_KEY = 'activePerspectiveId';
35
+ exports.PerspectiveService = Symbol('PerspectiveService');
36
+ exports.PerspectiveServiceInternal = Symbol('PerspectiveServiceInternal');
37
+ exports.PerspectiveContribution = Symbol('PerspectiveContribution');
38
+ let WidgetAreaResolverImpl = class WidgetAreaResolverImpl {
39
+ constructor() {
40
+ this.activePlacementMap = new Map();
41
+ }
42
+ setActivePlacementMap(map) {
43
+ this.activePlacementMap = map;
44
+ }
45
+ resolveArea(widgetId, requestedArea) {
46
+ return this.activePlacementMap.get(widgetId);
47
+ }
48
+ };
49
+ exports.WidgetAreaResolverImpl = WidgetAreaResolverImpl;
50
+ exports.WidgetAreaResolverImpl = WidgetAreaResolverImpl = tslib_1.__decorate([
51
+ (0, inversify_1.injectable)()
52
+ ], WidgetAreaResolverImpl);
53
+ let PerspectiveServiceImpl = class PerspectiveServiceImpl {
54
+ constructor() {
55
+ this.defaultPerspectiveId = PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID;
56
+ this.perspectives = new Map();
57
+ this.savedLayouts = new Map();
58
+ this.onDidChangePerspectiveEmitter = new event_1.Emitter();
59
+ this.onDidChangePerspective = this.onDidChangePerspectiveEmitter.event;
60
+ }
61
+ static { PerspectiveServiceImpl_1 = this; }
62
+ static { this.SWITCH_PERSPECTIVE_COMMAND = command_1.Command.toLocalizedCommand({
63
+ id: 'perspective.switch',
64
+ category: common_commands_1.CommonCommands.VIEW_CATEGORY,
65
+ label: 'Switch Perspective (Experimental)'
66
+ }, 'theia/core/perspective/switchPerspective', common_commands_1.CommonCommands.VIEW_CATEGORY_KEY); }
67
+ static { this.RESET_PERSPECTIVE_COMMAND = command_1.Command.toLocalizedCommand({
68
+ id: 'perspective.reset',
69
+ category: common_commands_1.CommonCommands.VIEW_CATEGORY,
70
+ label: 'Reset Perspective (Experimental)'
71
+ }, 'theia/core/perspective/resetPerspective', common_commands_1.CommonCommands.VIEW_CATEGORY_KEY); }
72
+ static { this.DEFAULT_PERSPECTIVE_ID = 'default'; }
73
+ onLayoutRestored(activePerspectiveId) {
74
+ this.updateActivePerspectiveContextKey(activePerspectiveId);
75
+ }
76
+ initialize() {
77
+ this.registerPerspective({
78
+ id: PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID,
79
+ label: nls_1.nls.localizeByDefault('Default'),
80
+ viewPlacements: new Map()
81
+ });
82
+ this.activePerspectiveId = PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID;
83
+ this.updateActivePerspectiveContextKey(PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID);
84
+ if (this.contributions) {
85
+ for (const contribution of this.contributions.getContributions()) {
86
+ contribution.registerPerspectives(this);
87
+ }
88
+ }
89
+ }
90
+ onStop() {
91
+ this.onDidChangePerspectiveEmitter.dispose();
92
+ }
93
+ updateActivePerspectiveContextKey(id) {
94
+ this.contextKeyService?.createKey(exports.ACTIVE_PERSPECTIVE_CONTEXT_KEY, id).set(id);
95
+ }
96
+ registerPerspective(descriptor) {
97
+ this.perspectives.set(descriptor.id, descriptor);
98
+ }
99
+ async switchPerspective(id) {
100
+ const pending = (this.switchInProgress ?? Promise.resolve())
101
+ .catch(() => { })
102
+ .then(() => this.doSwitchPerspective(id));
103
+ this.switchInProgress = pending;
104
+ try {
105
+ await pending;
106
+ }
107
+ finally {
108
+ if (this.switchInProgress === pending) {
109
+ this.switchInProgress = undefined;
110
+ }
111
+ }
112
+ }
113
+ async doSwitchPerspective(id) {
114
+ if (id === this.activePerspectiveId) {
115
+ return;
116
+ }
117
+ const descriptor = this.perspectives.get(id);
118
+ if (!descriptor) {
119
+ return;
120
+ }
121
+ const oldPerspective = this.getActivePerspective();
122
+ if (oldPerspective?.onDeactivate) {
123
+ oldPerspective.onDeactivate(this.shell);
124
+ }
125
+ if (this.activePerspectiveId) {
126
+ this.savedLayouts.set(this.activePerspectiveId, this.shell.getLayoutData());
127
+ }
128
+ this.activePerspectiveId = id;
129
+ this.widgetAreaResolver.setActivePlacementMap(descriptor.viewPlacements);
130
+ try {
131
+ const savedLayout = this.savedLayouts.get(id);
132
+ if (savedLayout) {
133
+ const layoutWidgetIds = this.collectWidgetIds(savedLayout);
134
+ await this.healLayoutData(savedLayout);
135
+ await this.shell.setLayoutData(savedLayout);
136
+ this.detachStrayWidgets(layoutWidgetIds);
137
+ }
138
+ else {
139
+ await this.applyViewPlacements(descriptor);
140
+ }
141
+ }
142
+ catch (error) {
143
+ this.logger.warn('Failed to apply layout for perspective', error);
144
+ }
145
+ if (descriptor.onActivate) {
146
+ descriptor.onActivate(this.shell);
147
+ }
148
+ this.updateActivePerspectiveContextKey(id);
149
+ this.onDidChangePerspectiveEmitter.fire(id);
150
+ }
151
+ async applyViewPlacements(descriptor) {
152
+ for (const [viewId, area] of descriptor.viewPlacements) {
153
+ try {
154
+ const widget = await this.widgetManager.getOrCreateWidget(viewId);
155
+ const currentTabBar = this.shell.getTabBarFor(widget);
156
+ if (currentTabBar) {
157
+ const currentArea = this.shell.getAreaFor(widget);
158
+ if (currentArea === area) {
159
+ continue;
160
+ }
161
+ }
162
+ await this.shell.addWidget(widget, { area });
163
+ }
164
+ catch (error) {
165
+ this.logger.warn('Failed to create or place widget for perspective', error);
166
+ }
167
+ }
168
+ for (const [viewId] of descriptor.viewPlacements) {
169
+ try {
170
+ await this.shell.activateWidget(viewId);
171
+ }
172
+ catch (error) {
173
+ this.logger.warn('Failed to activate widget for perspective', error);
174
+ }
175
+ }
176
+ if (descriptor.primaryViews) {
177
+ for (const viewId of Object.values(descriptor.primaryViews)) {
178
+ if (viewId) {
179
+ try {
180
+ await this.shell.activateWidget(viewId);
181
+ }
182
+ catch (error) {
183
+ this.logger.warn('Failed to activate primary view for perspective', error);
184
+ }
185
+ }
186
+ }
187
+ }
188
+ if (descriptor.chromeOptions?.collapseAreas) {
189
+ for (const area of descriptor.chromeOptions.collapseAreas) {
190
+ await this.shell.collapsePanel(area);
191
+ }
192
+ }
193
+ }
194
+ async resetCurrentPerspective() {
195
+ const pending = (this.switchInProgress ?? Promise.resolve())
196
+ .catch(() => { })
197
+ .then(() => this.doResetCurrentPerspective());
198
+ this.switchInProgress = pending;
199
+ try {
200
+ await pending;
201
+ }
202
+ finally {
203
+ if (this.switchInProgress === pending) {
204
+ this.switchInProgress = undefined;
205
+ }
206
+ }
207
+ }
208
+ async doResetCurrentPerspective() {
209
+ const descriptor = this.getActivePerspective();
210
+ if (!descriptor) {
211
+ return;
212
+ }
213
+ this.savedLayouts.delete(descriptor.id);
214
+ try {
215
+ if (descriptor.id === PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID) {
216
+ await this.resetDefaultPerspective();
217
+ }
218
+ else {
219
+ await this.applyViewPlacements(descriptor);
220
+ }
221
+ }
222
+ catch (error) {
223
+ this.logger.warn('Failed to apply layout for perspective', error);
224
+ }
225
+ if (descriptor.onActivate) {
226
+ descriptor.onActivate(this.shell);
227
+ }
228
+ this.onDidChangePerspectiveEmitter.fire(descriptor.id);
229
+ }
230
+ async resetDefaultPerspective() {
231
+ // Phase 1: Relocate open views to their default areas
232
+ for (const contribution of this.appContributions.getContributions()) {
233
+ if (contribution instanceof view_contribution_1.AbstractViewContribution) {
234
+ const widgetId = contribution.effectiveWidgetId;
235
+ const targetArea = contribution.defaultViewOptions?.area;
236
+ if (!widgetId || !targetArea) {
237
+ continue;
238
+ }
239
+ const widget = this.widgetManager.tryGetWidget(widgetId);
240
+ if (widget && !widget.isDisposed && widget.isAttached) {
241
+ const currentArea = this.shell.getAreaFor(widget);
242
+ if (currentArea && currentArea !== targetArea) {
243
+ try {
244
+ await this.shell.addWidget(widget, { area: targetArea });
245
+ }
246
+ catch (error) {
247
+ this.logger.warn('Failed to relocate widget during default perspective reset', widgetId, error);
248
+ }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ // Phase 2: Re-open closed views via openView({ activate: false }).
254
+ // Non-view contributions (e.g., Terminal) are skipped to avoid side effects
255
+ // like creating new terminal instances.
256
+ for (const contribution of this.appContributions.getContributions()) {
257
+ if (contribution instanceof view_contribution_1.AbstractViewContribution) {
258
+ try {
259
+ await contribution.openView({ activate: false });
260
+ }
261
+ catch (error) {
262
+ this.logger.warn('Failed to open view during default perspective reset', error);
263
+ }
264
+ }
265
+ }
266
+ }
267
+ /**
268
+ * Views may be shared between multiple perspective. If a view exists in two or more perspectives
269
+ * and is closed in one of them, the shared widget is disposed. When switching back to the other
270
+ * perspective, we need to restore this widget (i.e. reopen the view).
271
+ * @param layout
272
+ */
273
+ async healLayoutData(layout) {
274
+ if (layout.leftPanel) {
275
+ await this.healSidePanelLayout(layout.leftPanel);
276
+ }
277
+ if (layout.rightPanel) {
278
+ await this.healSidePanelLayout(layout.rightPanel);
279
+ }
280
+ if (layout.mainPanel?.main) {
281
+ await this.healDockAreaConfig(layout.mainPanel.main);
282
+ }
283
+ if (layout.bottomPanel?.config?.main) {
284
+ await this.healDockAreaConfig(layout.bottomPanel.config.main);
285
+ }
286
+ }
287
+ async healSidePanelLayout(layout) {
288
+ if (!layout.items) {
289
+ return;
290
+ }
291
+ for (const item of layout.items) {
292
+ if (item.widget?.isDisposed) {
293
+ try {
294
+ item.widget = await this.widgetManager.getOrCreateWidget(item.widget.id);
295
+ }
296
+ catch (error) {
297
+ this.logger.warn('Failed to recreate disposed widget for perspective layout', item.widget.id, error);
298
+ item.widget = undefined;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ async healDockAreaConfig(config) {
304
+ if (config.type === 'tab-area') {
305
+ for (let i = 0; i < config.widgets.length; i++) {
306
+ const widget = config.widgets[i];
307
+ if (widget.isDisposed) {
308
+ try {
309
+ config.widgets[i] = await this.widgetManager.getOrCreateWidget(widget.id);
310
+ }
311
+ catch (error) {
312
+ this.logger.warn('Failed to recreate disposed widget for perspective layout', widget.id, error);
313
+ config.widgets.splice(i, 1);
314
+ i--;
315
+ }
316
+ }
317
+ }
318
+ }
319
+ else if (config.type === 'split-area') {
320
+ for (const child of config.children) {
321
+ await this.healDockAreaConfig(child);
322
+ }
323
+ }
324
+ }
325
+ collectWidgetIds(layout) {
326
+ const ids = new Set();
327
+ if (layout.leftPanel) {
328
+ this.collectSidePanelWidgetIds(layout.leftPanel, ids);
329
+ }
330
+ if (layout.rightPanel) {
331
+ this.collectSidePanelWidgetIds(layout.rightPanel, ids);
332
+ }
333
+ if (layout.mainPanel?.main) {
334
+ this.collectDockWidgetIds(layout.mainPanel.main, ids);
335
+ }
336
+ if (layout.bottomPanel?.config?.main) {
337
+ this.collectDockWidgetIds(layout.bottomPanel.config.main, ids);
338
+ }
339
+ return ids;
340
+ }
341
+ collectSidePanelWidgetIds(layout, ids) {
342
+ if (layout.items) {
343
+ for (const item of layout.items) {
344
+ if (item.widget) {
345
+ ids.add(item.widget.id);
346
+ }
347
+ }
348
+ }
349
+ }
350
+ collectDockWidgetIds(config, ids) {
351
+ if (config.type === 'tab-area') {
352
+ for (const widget of config.widgets) {
353
+ if (widget) {
354
+ ids.add(widget.id);
355
+ }
356
+ }
357
+ }
358
+ else if (config.type === 'split-area') {
359
+ for (const child of config.children) {
360
+ this.collectDockWidgetIds(child, ids);
361
+ }
362
+ }
363
+ }
364
+ detachStrayWidgets(layoutWidgetIds) {
365
+ const sidePanelAreas = ['left', 'right'];
366
+ for (const area of sidePanelAreas) {
367
+ for (const widget of this.shell.getWidgets(area)) {
368
+ if (!layoutWidgetIds.has(widget.id)) {
369
+ // Detach via parent = null rather than widget.close() to avoid
370
+ // disposing the widget — it may be needed by another perspective.
371
+ // eslint-disable-next-line no-null/no-null
372
+ widget.parent = null;
373
+ }
374
+ }
375
+ }
376
+ }
377
+ getActivePerspective() {
378
+ if (this.activePerspectiveId) {
379
+ return this.perspectives.get(this.activePerspectiveId);
380
+ }
381
+ return undefined;
382
+ }
383
+ getAreaForView(viewId) {
384
+ const active = this.getActivePerspective();
385
+ if (active) {
386
+ return active.viewPlacements.get(viewId);
387
+ }
388
+ return undefined;
389
+ }
390
+ getRegisteredPerspectives() {
391
+ return Array.from(this.perspectives.values());
392
+ }
393
+ getActivePerspectiveId() {
394
+ return this.activePerspectiveId ?? PerspectiveServiceImpl_1.DEFAULT_PERSPECTIVE_ID;
395
+ }
396
+ getSavedPerspectiveIds() {
397
+ return Array.from(this.savedLayouts.keys());
398
+ }
399
+ getSavedLayout(perspectiveId) {
400
+ return this.savedLayouts.get(perspectiveId);
401
+ }
402
+ setSavedLayout(perspectiveId, layout) {
403
+ this.savedLayouts.set(perspectiveId, layout);
404
+ }
405
+ setActivePerspectiveId(id) {
406
+ if (this.perspectives.has(id)) {
407
+ this.activePerspectiveId = id;
408
+ return true;
409
+ }
410
+ return false;
411
+ }
412
+ clearSavedLayouts() {
413
+ this.savedLayouts.clear();
414
+ }
415
+ registerCommands(commands) {
416
+ commands.registerCommand(PerspectiveServiceImpl_1.SWITCH_PERSPECTIVE_COMMAND, {
417
+ execute: () => this.showPerspectivePicker(),
418
+ isVisible: () => this.perspectives.size > 1
419
+ });
420
+ commands.registerCommand(PerspectiveServiceImpl_1.RESET_PERSPECTIVE_COMMAND, {
421
+ execute: () => this.resetCurrentPerspective(),
422
+ isEnabled: () => this.activePerspectiveId !== undefined
423
+ });
424
+ }
425
+ async showPerspectivePicker() {
426
+ if (!this.quickInputService) {
427
+ return;
428
+ }
429
+ const items = this.getRegisteredPerspectives().map(p => ({
430
+ label: p.label,
431
+ id: p.id,
432
+ description: this.activePerspectiveId === p.id ? nls_1.nls.localizeByDefault('Active') : undefined
433
+ }));
434
+ const selected = await this.quickInputService.showQuickPick(items, {
435
+ placeholder: nls_1.nls.localize('theia/core/perspective/selectPerspective', 'Select a perspective')
436
+ });
437
+ if (selected?.id) {
438
+ await this.switchPerspective(selected.id);
439
+ }
440
+ }
441
+ };
442
+ exports.PerspectiveServiceImpl = PerspectiveServiceImpl;
443
+ tslib_1.__decorate([
444
+ (0, inversify_1.inject)(application_shell_1.ApplicationShell),
445
+ tslib_1.__metadata("design:type", application_shell_1.ApplicationShell)
446
+ ], PerspectiveServiceImpl.prototype, "shell", void 0);
447
+ tslib_1.__decorate([
448
+ (0, inversify_1.inject)(widget_manager_1.WidgetManager),
449
+ tslib_1.__metadata("design:type", widget_manager_1.WidgetManager)
450
+ ], PerspectiveServiceImpl.prototype, "widgetManager", void 0);
451
+ tslib_1.__decorate([
452
+ (0, inversify_1.inject)(contribution_provider_1.ContributionProvider),
453
+ (0, inversify_1.named)(exports.PerspectiveContribution),
454
+ (0, inversify_1.optional)(),
455
+ tslib_1.__metadata("design:type", Object)
456
+ ], PerspectiveServiceImpl.prototype, "contributions", void 0);
457
+ tslib_1.__decorate([
458
+ (0, inversify_1.inject)(contribution_provider_1.ContributionProvider),
459
+ (0, inversify_1.named)(frontend_application_contribution_1.FrontendApplicationContribution),
460
+ tslib_1.__metadata("design:type", Object)
461
+ ], PerspectiveServiceImpl.prototype, "appContributions", void 0);
462
+ tslib_1.__decorate([
463
+ (0, inversify_1.inject)(quick_pick_service_1.QuickInputService),
464
+ (0, inversify_1.optional)(),
465
+ tslib_1.__metadata("design:type", Object)
466
+ ], PerspectiveServiceImpl.prototype, "quickInputService", void 0);
467
+ tslib_1.__decorate([
468
+ (0, inversify_1.inject)(logger_1.ILogger),
469
+ (0, inversify_1.named)('core:PerspectiveService'),
470
+ tslib_1.__metadata("design:type", Object)
471
+ ], PerspectiveServiceImpl.prototype, "logger", void 0);
472
+ tslib_1.__decorate([
473
+ (0, inversify_1.inject)(application_shell_1.WidgetAreaResolver),
474
+ tslib_1.__metadata("design:type", Object)
475
+ ], PerspectiveServiceImpl.prototype, "widgetAreaResolver", void 0);
476
+ tslib_1.__decorate([
477
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
478
+ (0, inversify_1.optional)(),
479
+ tslib_1.__metadata("design:type", Object)
480
+ ], PerspectiveServiceImpl.prototype, "contextKeyService", void 0);
481
+ exports.PerspectiveServiceImpl = PerspectiveServiceImpl = PerspectiveServiceImpl_1 = tslib_1.__decorate([
482
+ (0, inversify_1.injectable)()
483
+ ], PerspectiveServiceImpl);
484
+ //# sourceMappingURL=perspective-service.js.map