@theia/messages 1.34.1 → 1.34.3

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 (38) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/messages-frontend-module.d.ts +4 -4
  4. package/lib/browser/messages-frontend-module.js +43 -43
  5. package/lib/browser/notification-center-component.d.ts +18 -18
  6. package/lib/browser/notification-center-component.js +67 -67
  7. package/lib/browser/notification-component.d.ts +15 -15
  8. package/lib/browser/notification-component.js +88 -88
  9. package/lib/browser/notification-content-renderer.d.ts +5 -5
  10. package/lib/browser/notification-content-renderer.js +40 -40
  11. package/lib/browser/notification-content-renderer.spec.d.ts +1 -1
  12. package/lib/browser/notification-content-renderer.spec.js +41 -41
  13. package/lib/browser/notification-preferences.d.ts +11 -11
  14. package/lib/browser/notification-preferences.js +46 -46
  15. package/lib/browser/notification-toasts-component.d.ts +18 -18
  16. package/lib/browser/notification-toasts-component.js +48 -48
  17. package/lib/browser/notifications-commands.d.ts +7 -7
  18. package/lib/browser/notifications-commands.js +47 -47
  19. package/lib/browser/notifications-contribution.d.ts +30 -30
  20. package/lib/browser/notifications-contribution.js +232 -232
  21. package/lib/browser/notifications-manager.d.ts +69 -69
  22. package/lib/browser/notifications-manager.js +277 -277
  23. package/lib/browser/notifications-renderer.d.ts +13 -13
  24. package/lib/browser/notifications-renderer.js +75 -75
  25. package/package.json +4 -4
  26. package/src/browser/messages-frontend-module.ts +44 -44
  27. package/src/browser/notification-center-component.tsx +95 -95
  28. package/src/browser/notification-component.tsx +128 -128
  29. package/src/browser/notification-content-renderer.spec.ts +73 -73
  30. package/src/browser/notification-content-renderer.ts +31 -31
  31. package/src/browser/notification-preferences.ts +58 -58
  32. package/src/browser/notification-toasts-component.tsx +67 -67
  33. package/src/browser/notifications-commands.ts +50 -50
  34. package/src/browser/notifications-contribution.ts +235 -235
  35. package/src/browser/notifications-manager.ts +297 -297
  36. package/src/browser/notifications-renderer.tsx +61 -61
  37. package/src/browser/style/index.css +17 -17
  38. package/src/browser/style/notifications.css +270 -270
@@ -1,235 +1,235 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import {
19
- FrontendApplicationContribution, StatusBar, FrontendApplication, StatusBarAlignment,
20
- KeybindingContribution, KeybindingRegistry, KeybindingContext, StylingParticipant, ColorTheme, CssStyleCollector
21
- } from '@theia/core/lib/browser';
22
- import { Keybinding } from '@theia/core/lib/common/keybinding';
23
- import { NotificationsCommands } from './notifications-commands';
24
- import { CommandContribution, CommandRegistry } from '@theia/core';
25
- import { NotificationManager } from './notifications-manager';
26
- import { NotificationsRenderer } from './notifications-renderer';
27
- import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
28
- import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
29
- import { Color } from '@theia/core/lib/common/color';
30
- import { nls } from '@theia/core/lib/common/nls';
31
- import { isHighContrast } from '@theia/core/lib/common/theme';
32
-
33
- @injectable()
34
- export class NotificationsContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, ColorContribution, StylingParticipant {
35
-
36
- protected readonly id = 'theia-notification-center';
37
-
38
- @inject(NotificationManager)
39
- protected readonly manager: NotificationManager;
40
-
41
- @inject(NotificationsRenderer)
42
- protected readonly notificationsRenderer: NotificationsRenderer; // required for initialization
43
-
44
- @inject(StatusBar)
45
- protected readonly statusBar: StatusBar;
46
-
47
- onStart(_app: FrontendApplication): void {
48
- this.createStatusBarItem();
49
- }
50
-
51
- protected createStatusBarItem(): void {
52
- this.updateStatusBarItem();
53
- this.manager.onUpdated(e => this.updateStatusBarItem(e.notifications.length));
54
- }
55
- protected updateStatusBarItem(count: number = 0): void {
56
- this.statusBar.setElement(this.id, {
57
- text: this.getStatusBarItemText(count),
58
- alignment: StatusBarAlignment.RIGHT,
59
- priority: -900,
60
- command: NotificationsCommands.TOGGLE.id,
61
- tooltip: this.getStatusBarItemTooltip(count),
62
- accessibilityInformation: {
63
- label: this.getStatusBarItemTooltip(count)
64
- }
65
- });
66
- }
67
- protected getStatusBarItemText(count: number): string {
68
- return `$(${count ? 'codicon-bell-dot' : 'codicon-bell'}) ${count ? ` ${count}` : ''}`;
69
- }
70
- protected getStatusBarItemTooltip(count: number): string {
71
- if (this.manager.centerVisible) {
72
- return nls.localizeByDefault('Hide Notifications');
73
- }
74
- return count === 0
75
- ? nls.localizeByDefault('No Notifications')
76
- : count === 1
77
- ? nls.localizeByDefault('1 New Notification')
78
- : nls.localizeByDefault('{0} New Notifications', count.toString());
79
- }
80
-
81
- registerCommands(commands: CommandRegistry): void {
82
- commands.registerCommand(NotificationsCommands.TOGGLE, {
83
- isEnabled: () => true,
84
- execute: () => this.manager.toggleCenter()
85
- });
86
- commands.registerCommand(NotificationsCommands.SHOW, {
87
- isEnabled: () => true,
88
- execute: () => this.manager.showCenter()
89
- });
90
- commands.registerCommand(NotificationsCommands.HIDE, {
91
- execute: () => this.manager.hide()
92
- });
93
- commands.registerCommand(NotificationsCommands.CLEAR_ALL, {
94
- execute: () => this.manager.clearAll()
95
- });
96
- }
97
-
98
- registerKeybindings(keybindings: KeybindingRegistry): void {
99
- keybindings.registerKeybinding({
100
- command: NotificationsCommands.HIDE.id,
101
- context: NotificationsKeybindingContext.notificationsVisible,
102
- keybinding: 'esc'
103
- });
104
- }
105
-
106
- registerColors(colors: ColorRegistry): void {
107
- colors.register(
108
- {
109
- id: 'notificationCenter.border', defaults: {
110
- hcDark: 'contrastBorder',
111
- hcLight: 'contrastBorder'
112
- }, description: 'Notifications center border color. Notifications slide in from the bottom right of the window.'
113
- },
114
- {
115
- id: 'notificationToast.border', defaults: {
116
- hcDark: 'contrastBorder',
117
- hcLight: 'contrastBorder'
118
- }, description: 'Notification toast border color. Notifications slide in from the bottom right of the window.'
119
- },
120
- {
121
- id: 'notifications.foreground', defaults: {
122
- dark: 'editorWidget.foreground',
123
- light: 'editorWidget.foreground',
124
- hcDark: 'editorWidget.foreground',
125
- hcLight: 'editorWidget.foreground'
126
- }, description: 'Notifications foreground color. Notifications slide in from the bottom right of the window.'
127
- },
128
- {
129
- id: 'notifications.background', defaults: {
130
- dark: 'editorWidget.background',
131
- light: 'editorWidget.background',
132
- hcDark: 'editorWidget.background',
133
- hcLight: 'editorWidget.background'
134
- }, description: 'Notifications background color. Notifications slide in from the bottom right of the window.'
135
- },
136
- {
137
- id: 'notificationLink.foreground', defaults: {
138
- dark: 'textLink.foreground',
139
- light: 'textLink.foreground',
140
- hcDark: 'textLink.foreground',
141
- hcLight: 'textLink.foreground'
142
- }, description: 'Notification links foreground color. Notifications slide in from the bottom right of the window.'
143
- },
144
- {
145
- id: 'notificationCenterHeader.foreground',
146
- description: 'Notifications center header foreground color. Notifications slide in from the bottom right of the window.'
147
- },
148
- {
149
- id: 'notificationCenterHeader.background', defaults: {
150
- dark: Color.lighten('notifications.background', 0.3),
151
- light: Color.darken('notifications.background', 0.05),
152
- hcDark: 'notifications.background',
153
- hcLight: 'notifications.background'
154
- }, description: 'Notifications center header background color. Notifications slide in from the bottom right of the window.'
155
- },
156
- {
157
- id: 'notifications.border', defaults: {
158
- dark: 'notificationCenterHeader.background',
159
- light: 'notificationCenterHeader.background',
160
- hcDark: 'notificationCenterHeader.background',
161
- hcLight: 'notificationCenterHeader.background'
162
- // eslint-disable-next-line max-len
163
- }, description: 'Notifications border color separating from other notifications in the notifications center. Notifications slide in from the bottom right of the window.'
164
- },
165
- {
166
- id: 'notificationsErrorIcon.foreground', defaults: {
167
- dark: 'editorError.foreground',
168
- light: 'editorError.foreground',
169
- hcDark: 'editorError.foreground',
170
- hcLight: 'editorError.foreground'
171
- }, description: 'The color used for the icon of error notifications. Notifications slide in from the bottom right of the window.'
172
- },
173
- {
174
- id: 'notificationsWarningIcon.foreground', defaults: {
175
- dark: 'editorWarning.foreground',
176
- light: 'editorWarning.foreground',
177
- hcDark: 'editorWarning.foreground',
178
- hcLight: 'editorWarning.foreground'
179
- }, description: 'The color used for the icon of warning notifications. Notifications slide in from the bottom right of the window.'
180
- },
181
- {
182
- id: 'notificationsInfoIcon.foreground', defaults: {
183
- dark: 'editorInfo.foreground',
184
- light: 'editorInfo.foreground',
185
- hcDark: 'editorInfo.foreground',
186
- hcLight: 'editorInfo.foreground'
187
- }, description: 'The color used for the icon of info notifications. Notifications slide in from the bottom right of the window.'
188
- }
189
- );
190
- }
191
-
192
- registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
193
- const notificationsBackground = theme.getColor('notifications.background');
194
- if (notificationsBackground) {
195
- collector.addRule(`
196
- .theia-notification-list-item-container {
197
- background-color: ${notificationsBackground};
198
- }
199
- `);
200
- }
201
- const notificationHover = theme.getColor('list.hoverBackground');
202
- if (notificationHover) {
203
- collector.addRule(`
204
- .theia-notification-list-item:hover:not(:focus) {
205
- background-color: ${notificationHover};
206
- }
207
- `);
208
- }
209
- const focusBorder = theme.getColor('focusBorder');
210
- if (focusBorder && isHighContrast(theme.type)) {
211
- collector.addRule(`
212
- .theia-notification-list-item:hover:not(:focus) {
213
- outline: 1px dashed ${focusBorder};
214
- outline-offset: -2px;
215
- }
216
- `);
217
- }
218
- }
219
- }
220
-
221
- @injectable()
222
- export class NotificationsKeybindingContext implements KeybindingContext {
223
-
224
- @inject(NotificationManager)
225
- protected readonly manager: NotificationManager;
226
-
227
- readonly id = NotificationsKeybindingContext.notificationsVisible;
228
- isEnabled(_arg: Keybinding): boolean {
229
- return this.manager.centerVisible || this.manager.toastsVisible;
230
- }
231
-
232
- }
233
- export namespace NotificationsKeybindingContext {
234
- export const notificationsVisible = 'notificationsVisible';
235
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import {
19
+ FrontendApplicationContribution, StatusBar, FrontendApplication, StatusBarAlignment,
20
+ KeybindingContribution, KeybindingRegistry, KeybindingContext, StylingParticipant, ColorTheme, CssStyleCollector
21
+ } from '@theia/core/lib/browser';
22
+ import { Keybinding } from '@theia/core/lib/common/keybinding';
23
+ import { NotificationsCommands } from './notifications-commands';
24
+ import { CommandContribution, CommandRegistry } from '@theia/core';
25
+ import { NotificationManager } from './notifications-manager';
26
+ import { NotificationsRenderer } from './notifications-renderer';
27
+ import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
28
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
29
+ import { Color } from '@theia/core/lib/common/color';
30
+ import { nls } from '@theia/core/lib/common/nls';
31
+ import { isHighContrast } from '@theia/core/lib/common/theme';
32
+
33
+ @injectable()
34
+ export class NotificationsContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, ColorContribution, StylingParticipant {
35
+
36
+ protected readonly id = 'theia-notification-center';
37
+
38
+ @inject(NotificationManager)
39
+ protected readonly manager: NotificationManager;
40
+
41
+ @inject(NotificationsRenderer)
42
+ protected readonly notificationsRenderer: NotificationsRenderer; // required for initialization
43
+
44
+ @inject(StatusBar)
45
+ protected readonly statusBar: StatusBar;
46
+
47
+ onStart(_app: FrontendApplication): void {
48
+ this.createStatusBarItem();
49
+ }
50
+
51
+ protected createStatusBarItem(): void {
52
+ this.updateStatusBarItem();
53
+ this.manager.onUpdated(e => this.updateStatusBarItem(e.notifications.length));
54
+ }
55
+ protected updateStatusBarItem(count: number = 0): void {
56
+ this.statusBar.setElement(this.id, {
57
+ text: this.getStatusBarItemText(count),
58
+ alignment: StatusBarAlignment.RIGHT,
59
+ priority: -900,
60
+ command: NotificationsCommands.TOGGLE.id,
61
+ tooltip: this.getStatusBarItemTooltip(count),
62
+ accessibilityInformation: {
63
+ label: this.getStatusBarItemTooltip(count)
64
+ }
65
+ });
66
+ }
67
+ protected getStatusBarItemText(count: number): string {
68
+ return `$(${count ? 'codicon-bell-dot' : 'codicon-bell'}) ${count ? ` ${count}` : ''}`;
69
+ }
70
+ protected getStatusBarItemTooltip(count: number): string {
71
+ if (this.manager.centerVisible) {
72
+ return nls.localizeByDefault('Hide Notifications');
73
+ }
74
+ return count === 0
75
+ ? nls.localizeByDefault('No Notifications')
76
+ : count === 1
77
+ ? nls.localizeByDefault('1 New Notification')
78
+ : nls.localizeByDefault('{0} New Notifications', count.toString());
79
+ }
80
+
81
+ registerCommands(commands: CommandRegistry): void {
82
+ commands.registerCommand(NotificationsCommands.TOGGLE, {
83
+ isEnabled: () => true,
84
+ execute: () => this.manager.toggleCenter()
85
+ });
86
+ commands.registerCommand(NotificationsCommands.SHOW, {
87
+ isEnabled: () => true,
88
+ execute: () => this.manager.showCenter()
89
+ });
90
+ commands.registerCommand(NotificationsCommands.HIDE, {
91
+ execute: () => this.manager.hide()
92
+ });
93
+ commands.registerCommand(NotificationsCommands.CLEAR_ALL, {
94
+ execute: () => this.manager.clearAll()
95
+ });
96
+ }
97
+
98
+ registerKeybindings(keybindings: KeybindingRegistry): void {
99
+ keybindings.registerKeybinding({
100
+ command: NotificationsCommands.HIDE.id,
101
+ context: NotificationsKeybindingContext.notificationsVisible,
102
+ keybinding: 'esc'
103
+ });
104
+ }
105
+
106
+ registerColors(colors: ColorRegistry): void {
107
+ colors.register(
108
+ {
109
+ id: 'notificationCenter.border', defaults: {
110
+ hcDark: 'contrastBorder',
111
+ hcLight: 'contrastBorder'
112
+ }, description: 'Notifications center border color. Notifications slide in from the bottom right of the window.'
113
+ },
114
+ {
115
+ id: 'notificationToast.border', defaults: {
116
+ hcDark: 'contrastBorder',
117
+ hcLight: 'contrastBorder'
118
+ }, description: 'Notification toast border color. Notifications slide in from the bottom right of the window.'
119
+ },
120
+ {
121
+ id: 'notifications.foreground', defaults: {
122
+ dark: 'editorWidget.foreground',
123
+ light: 'editorWidget.foreground',
124
+ hcDark: 'editorWidget.foreground',
125
+ hcLight: 'editorWidget.foreground'
126
+ }, description: 'Notifications foreground color. Notifications slide in from the bottom right of the window.'
127
+ },
128
+ {
129
+ id: 'notifications.background', defaults: {
130
+ dark: 'editorWidget.background',
131
+ light: 'editorWidget.background',
132
+ hcDark: 'editorWidget.background',
133
+ hcLight: 'editorWidget.background'
134
+ }, description: 'Notifications background color. Notifications slide in from the bottom right of the window.'
135
+ },
136
+ {
137
+ id: 'notificationLink.foreground', defaults: {
138
+ dark: 'textLink.foreground',
139
+ light: 'textLink.foreground',
140
+ hcDark: 'textLink.foreground',
141
+ hcLight: 'textLink.foreground'
142
+ }, description: 'Notification links foreground color. Notifications slide in from the bottom right of the window.'
143
+ },
144
+ {
145
+ id: 'notificationCenterHeader.foreground',
146
+ description: 'Notifications center header foreground color. Notifications slide in from the bottom right of the window.'
147
+ },
148
+ {
149
+ id: 'notificationCenterHeader.background', defaults: {
150
+ dark: Color.lighten('notifications.background', 0.3),
151
+ light: Color.darken('notifications.background', 0.05),
152
+ hcDark: 'notifications.background',
153
+ hcLight: 'notifications.background'
154
+ }, description: 'Notifications center header background color. Notifications slide in from the bottom right of the window.'
155
+ },
156
+ {
157
+ id: 'notifications.border', defaults: {
158
+ dark: 'notificationCenterHeader.background',
159
+ light: 'notificationCenterHeader.background',
160
+ hcDark: 'notificationCenterHeader.background',
161
+ hcLight: 'notificationCenterHeader.background'
162
+ // eslint-disable-next-line max-len
163
+ }, description: 'Notifications border color separating from other notifications in the notifications center. Notifications slide in from the bottom right of the window.'
164
+ },
165
+ {
166
+ id: 'notificationsErrorIcon.foreground', defaults: {
167
+ dark: 'editorError.foreground',
168
+ light: 'editorError.foreground',
169
+ hcDark: 'editorError.foreground',
170
+ hcLight: 'editorError.foreground'
171
+ }, description: 'The color used for the icon of error notifications. Notifications slide in from the bottom right of the window.'
172
+ },
173
+ {
174
+ id: 'notificationsWarningIcon.foreground', defaults: {
175
+ dark: 'editorWarning.foreground',
176
+ light: 'editorWarning.foreground',
177
+ hcDark: 'editorWarning.foreground',
178
+ hcLight: 'editorWarning.foreground'
179
+ }, description: 'The color used for the icon of warning notifications. Notifications slide in from the bottom right of the window.'
180
+ },
181
+ {
182
+ id: 'notificationsInfoIcon.foreground', defaults: {
183
+ dark: 'editorInfo.foreground',
184
+ light: 'editorInfo.foreground',
185
+ hcDark: 'editorInfo.foreground',
186
+ hcLight: 'editorInfo.foreground'
187
+ }, description: 'The color used for the icon of info notifications. Notifications slide in from the bottom right of the window.'
188
+ }
189
+ );
190
+ }
191
+
192
+ registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void {
193
+ const notificationsBackground = theme.getColor('notifications.background');
194
+ if (notificationsBackground) {
195
+ collector.addRule(`
196
+ .theia-notification-list-item-container {
197
+ background-color: ${notificationsBackground};
198
+ }
199
+ `);
200
+ }
201
+ const notificationHover = theme.getColor('list.hoverBackground');
202
+ if (notificationHover) {
203
+ collector.addRule(`
204
+ .theia-notification-list-item:hover:not(:focus) {
205
+ background-color: ${notificationHover};
206
+ }
207
+ `);
208
+ }
209
+ const focusBorder = theme.getColor('focusBorder');
210
+ if (focusBorder && isHighContrast(theme.type)) {
211
+ collector.addRule(`
212
+ .theia-notification-list-item:hover:not(:focus) {
213
+ outline: 1px dashed ${focusBorder};
214
+ outline-offset: -2px;
215
+ }
216
+ `);
217
+ }
218
+ }
219
+ }
220
+
221
+ @injectable()
222
+ export class NotificationsKeybindingContext implements KeybindingContext {
223
+
224
+ @inject(NotificationManager)
225
+ protected readonly manager: NotificationManager;
226
+
227
+ readonly id = NotificationsKeybindingContext.notificationsVisible;
228
+ isEnabled(_arg: Keybinding): boolean {
229
+ return this.manager.centerVisible || this.manager.toastsVisible;
230
+ }
231
+
232
+ }
233
+ export namespace NotificationsKeybindingContext {
234
+ export const notificationsVisible = 'notificationsVisible';
235
+ }