@theia/scm 1.34.3 → 1.34.4

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 (95) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +31 -31
  3. package/lib/browser/decorations/scm-decorations-service.d.ts +14 -14
  4. package/lib/browser/decorations/scm-decorations-service.js +101 -101
  5. package/lib/browser/decorations/scm-navigator-decorator.d.ts +25 -25
  6. package/lib/browser/decorations/scm-navigator-decorator.js +132 -132
  7. package/lib/browser/decorations/scm-tab-bar-decorator.d.ts +17 -17
  8. package/lib/browser/decorations/scm-tab-bar-decorator.js +93 -93
  9. package/lib/browser/dirty-diff/content-lines.d.ts +12 -12
  10. package/lib/browser/dirty-diff/content-lines.js +106 -106
  11. package/lib/browser/dirty-diff/content-lines.spec.d.ts +1 -1
  12. package/lib/browser/dirty-diff/content-lines.spec.js +39 -39
  13. package/lib/browser/dirty-diff/diff-computer.d.ts +29 -29
  14. package/lib/browser/dirty-diff/diff-computer.js +102 -102
  15. package/lib/browser/dirty-diff/diff-computer.spec.d.ts +1 -1
  16. package/lib/browser/dirty-diff/diff-computer.spec.js +315 -315
  17. package/lib/browser/dirty-diff/dirty-diff-decorator.d.ts +14 -14
  18. package/lib/browser/dirty-diff/dirty-diff-decorator.js +98 -98
  19. package/lib/browser/dirty-diff/dirty-diff-module.d.ts +3 -3
  20. package/lib/browser/dirty-diff/dirty-diff-module.js +24 -24
  21. package/lib/browser/scm-amend-component.d.ts +123 -123
  22. package/lib/browser/scm-amend-component.js +423 -423
  23. package/lib/browser/scm-amend-widget.d.ts +20 -20
  24. package/lib/browser/scm-amend-widget.js +101 -101
  25. package/lib/browser/scm-avatar-service.d.ts +3 -3
  26. package/lib/browser/scm-avatar-service.js +36 -36
  27. package/lib/browser/scm-commit-widget.d.ts +52 -52
  28. package/lib/browser/scm-commit-widget.js +199 -199
  29. package/lib/browser/scm-context-key-service.d.ts +10 -10
  30. package/lib/browser/scm-context-key-service.js +58 -58
  31. package/lib/browser/scm-contribution.d.ts +83 -83
  32. package/lib/browser/scm-contribution.js +353 -353
  33. package/lib/browser/scm-frontend-module.d.ts +6 -6
  34. package/lib/browser/scm-frontend-module.js +130 -130
  35. package/lib/browser/scm-groups-tree-model.d.ts +14 -14
  36. package/lib/browser/scm-groups-tree-model.js +97 -97
  37. package/lib/browser/scm-input.d.ts +53 -53
  38. package/lib/browser/scm-input.js +127 -127
  39. package/lib/browser/scm-layout-migrations.d.ts +9 -9
  40. package/lib/browser/scm-layout-migrations.js +79 -79
  41. package/lib/browser/scm-no-repository-widget.d.ts +8 -8
  42. package/lib/browser/scm-no-repository-widget.js +49 -49
  43. package/lib/browser/scm-preferences.d.ts +11 -11
  44. package/lib/browser/scm-preferences.js +51 -51
  45. package/lib/browser/scm-provider.d.ts +56 -56
  46. package/lib/browser/scm-provider.js +19 -19
  47. package/lib/browser/scm-quick-open-service.d.ts +11 -11
  48. package/lib/browser/scm-quick-open-service.js +73 -73
  49. package/lib/browser/scm-repository.d.ts +17 -17
  50. package/lib/browser/scm-repository.js +41 -41
  51. package/lib/browser/scm-service.d.ts +26 -26
  52. package/lib/browser/scm-service.js +108 -108
  53. package/lib/browser/scm-tree-label-provider.d.ts +7 -7
  54. package/lib/browser/scm-tree-label-provider.js +57 -57
  55. package/lib/browser/scm-tree-model.d.ts +74 -74
  56. package/lib/browser/scm-tree-model.js +348 -348
  57. package/lib/browser/scm-tree-widget.d.ts +201 -201
  58. package/lib/browser/scm-tree-widget.js +664 -664
  59. package/lib/browser/scm-widget.d.ts +40 -40
  60. package/lib/browser/scm-widget.js +218 -218
  61. package/package.json +6 -6
  62. package/src/browser/decorations/scm-decorations-service.ts +78 -78
  63. package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
  64. package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
  65. package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
  66. package/src/browser/dirty-diff/content-lines.ts +112 -112
  67. package/src/browser/dirty-diff/diff-computer.spec.ts +387 -387
  68. package/src/browser/dirty-diff/diff-computer.ts +129 -129
  69. package/src/browser/dirty-diff/dirty-diff-decorator.ts +107 -107
  70. package/src/browser/dirty-diff/dirty-diff-module.ts +24 -24
  71. package/src/browser/scm-amend-component.tsx +600 -600
  72. package/src/browser/scm-amend-widget.tsx +77 -77
  73. package/src/browser/scm-avatar-service.ts +27 -27
  74. package/src/browser/scm-commit-widget.tsx +215 -215
  75. package/src/browser/scm-context-key-service.ts +46 -46
  76. package/src/browser/scm-contribution.ts +361 -361
  77. package/src/browser/scm-frontend-module.ts +149 -149
  78. package/src/browser/scm-groups-tree-model.ts +78 -78
  79. package/src/browser/scm-input.ts +164 -164
  80. package/src/browser/scm-layout-migrations.ts +64 -64
  81. package/src/browser/scm-no-repository-widget.tsx +41 -41
  82. package/src/browser/scm-preferences.ts +63 -63
  83. package/src/browser/scm-provider.ts +89 -89
  84. package/src/browser/scm-quick-open-service.ts +48 -48
  85. package/src/browser/scm-repository.ts +52 -52
  86. package/src/browser/scm-service.ts +108 -108
  87. package/src/browser/scm-tree-label-provider.ts +44 -44
  88. package/src/browser/scm-tree-model.ts +405 -405
  89. package/src/browser/scm-tree-widget.tsx +809 -809
  90. package/src/browser/scm-widget.tsx +204 -204
  91. package/src/browser/style/dirty-diff-decorator.css +52 -52
  92. package/src/browser/style/dirty-diff.css +50 -50
  93. package/src/browser/style/index.css +267 -267
  94. package/src/browser/style/scm-amend-component.css +94 -94
  95. package/src/browser/style/scm.svg +4 -4
@@ -1,354 +1,354 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ScmContribution = exports.ScmColors = exports.SCM_COMMANDS = exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS = exports.SCM_VIEW_CONTAINER_ID = exports.SCM_WIDGET_FACTORY_ID = void 0;
13
- // *****************************************************************************
14
- // Copyright (C) 2019 Red Hat, Inc. and others.
15
- //
16
- // This program and the accompanying materials are made available under the
17
- // terms of the Eclipse Public License v. 2.0 which is available at
18
- // http://www.eclipse.org/legal/epl-2.0.
19
- //
20
- // This Source Code may also be made available under the following Secondary
21
- // Licenses when the conditions for such availability set forth in the Eclipse
22
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
- // with the GNU Classpath Exception which is available at
24
- // https://www.gnu.org/software/classpath/license.html.
25
- //
26
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
- // *****************************************************************************
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const event_1 = require("@theia/core/lib/common/event");
30
- const browser_1 = require("@theia/core/lib/browser");
31
- const common_1 = require("@theia/core/lib/common");
32
- const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
33
- const scm_service_1 = require("./scm-service");
34
- const scm_widget_1 = require("../browser/scm-widget");
35
- const uri_1 = require("@theia/core/lib/common/uri");
36
- const scm_quick_open_service_1 = require("./scm-quick-open-service");
37
- const color_1 = require("@theia/core/lib/common/color");
38
- const scm_decorations_service_1 = require("../browser/decorations/scm-decorations-service");
39
- const nls_1 = require("@theia/core/lib/common/nls");
40
- const theme_1 = require("@theia/core/lib/common/theme");
41
- exports.SCM_WIDGET_FACTORY_ID = scm_widget_1.ScmWidget.ID;
42
- exports.SCM_VIEW_CONTAINER_ID = 'scm-view-container';
43
- exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS = {
44
- label: nls_1.nls.localizeByDefault('Source Control'),
45
- iconClass: (0, browser_1.codicon)('source-control'),
46
- closeable: true
47
- };
48
- var SCM_COMMANDS;
49
- (function (SCM_COMMANDS) {
50
- SCM_COMMANDS.CHANGE_REPOSITORY = {
51
- id: 'scm.change.repository',
52
- category: nls_1.nls.localizeByDefault('Source Control'),
53
- originalCategory: 'Source Control',
54
- label: nls_1.nls.localize('theia/scm/changeRepository', 'Change Repository...'),
55
- originalLabel: 'Change Repository...'
56
- };
57
- SCM_COMMANDS.ACCEPT_INPUT = {
58
- id: 'scm.acceptInput'
59
- };
60
- SCM_COMMANDS.TREE_VIEW_MODE = {
61
- id: 'scm.viewmode.tree',
62
- tooltip: nls_1.nls.localizeByDefault('View as Tree'),
63
- iconClass: (0, browser_1.codicon)('list-tree'),
64
- originalLabel: 'View as Tree',
65
- label: nls_1.nls.localizeByDefault('View as Tree')
66
- };
67
- SCM_COMMANDS.LIST_VIEW_MODE = {
68
- id: 'scm.viewmode.list',
69
- tooltip: nls_1.nls.localizeByDefault('View as List'),
70
- iconClass: (0, browser_1.codicon)('list-flat'),
71
- originalLabel: 'View as List',
72
- label: nls_1.nls.localizeByDefault('View as List')
73
- };
74
- SCM_COMMANDS.COLLAPSE_ALL = {
75
- id: 'scm.collapseAll',
76
- category: nls_1.nls.localizeByDefault('Source Control'),
77
- originalCategory: 'Source Control',
78
- tooltip: nls_1.nls.localizeByDefault('Collapse All'),
79
- iconClass: (0, browser_1.codicon)('collapse-all'),
80
- label: nls_1.nls.localizeByDefault('Collapse All'),
81
- originalLabel: 'Collapse All'
82
- };
83
- })(SCM_COMMANDS = exports.SCM_COMMANDS || (exports.SCM_COMMANDS = {}));
84
- var ScmColors;
85
- (function (ScmColors) {
86
- ScmColors.editorGutterModifiedBackground = 'editorGutter.modifiedBackground';
87
- ScmColors.editorGutterAddedBackground = 'editorGutter.addedBackground';
88
- ScmColors.editorGutterDeletedBackground = 'editorGutter.deletedBackground';
89
- })(ScmColors = exports.ScmColors || (exports.ScmColors = {}));
90
- let ScmContribution = class ScmContribution extends browser_1.AbstractViewContribution {
91
- constructor() {
92
- super({
93
- viewContainerId: exports.SCM_VIEW_CONTAINER_ID,
94
- widgetId: exports.SCM_WIDGET_FACTORY_ID,
95
- widgetName: exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS.label,
96
- defaultWidgetOptions: {
97
- area: 'left',
98
- rank: 300
99
- },
100
- toggleCommandId: 'scmView:toggle',
101
- toggleKeybinding: 'ctrlcmd+shift+g'
102
- });
103
- this.statusBarDisposable = new common_1.DisposableCollection();
104
- }
105
- init() {
106
- this.scmFocus = this.contextKeys.createKey('scmFocus', false);
107
- }
108
- async initializeLayout() {
109
- await this.openView();
110
- }
111
- onStart() {
112
- this.updateStatusBar();
113
- this.scmService.onDidAddRepository(() => this.updateStatusBar());
114
- this.scmService.onDidRemoveRepository(() => this.updateStatusBar());
115
- this.scmService.onDidChangeSelectedRepository(() => this.updateStatusBar());
116
- this.scmService.onDidChangeStatusBarCommands(() => this.updateStatusBar());
117
- this.labelProvider.onDidChange(() => this.updateStatusBar());
118
- this.updateContextKeys();
119
- this.shell.onDidChangeCurrentWidget(() => this.updateContextKeys());
120
- }
121
- updateContextKeys() {
122
- this.scmFocus.set(this.shell.currentWidget instanceof scm_widget_1.ScmWidget);
123
- }
124
- registerCommands(commandRegistry) {
125
- super.registerCommands(commandRegistry);
126
- commandRegistry.registerCommand(SCM_COMMANDS.CHANGE_REPOSITORY, {
127
- execute: () => this.scmQuickOpenService.changeRepository(),
128
- isEnabled: () => this.scmService.repositories.length > 1
129
- });
130
- commandRegistry.registerCommand(SCM_COMMANDS.ACCEPT_INPUT, {
131
- execute: () => this.acceptInput(),
132
- isEnabled: () => !!this.scmFocus.get() && !!this.acceptInputCommand()
133
- });
134
- }
135
- registerToolbarItems(registry) {
136
- const viewModeEmitter = new event_1.Emitter();
137
- const registerToggleViewItem = (command, mode) => {
138
- const id = command.id;
139
- const item = {
140
- id,
141
- command: id,
142
- tooltip: command.label,
143
- onDidChange: viewModeEmitter.event
144
- };
145
- this.commandRegistry.registerCommand({ id, iconClass: command && command.iconClass }, {
146
- execute: widget => {
147
- if (widget instanceof scm_widget_1.ScmWidget) {
148
- widget.viewMode = mode;
149
- viewModeEmitter.fire();
150
- }
151
- },
152
- isVisible: widget => {
153
- if (widget instanceof scm_widget_1.ScmWidget) {
154
- return !!this.scmService.selectedRepository
155
- && widget.viewMode !== mode;
156
- }
157
- return false;
158
- },
159
- });
160
- registry.registerItem(item);
161
- };
162
- registerToggleViewItem(SCM_COMMANDS.TREE_VIEW_MODE, 'tree');
163
- registerToggleViewItem(SCM_COMMANDS.LIST_VIEW_MODE, 'list');
164
- this.commandRegistry.registerCommand(SCM_COMMANDS.COLLAPSE_ALL, {
165
- execute: widget => {
166
- if (widget instanceof scm_widget_1.ScmWidget && widget.viewMode === 'tree') {
167
- widget.collapseScmTree();
168
- }
169
- },
170
- isVisible: widget => {
171
- if (widget instanceof scm_widget_1.ScmWidget) {
172
- return !!this.scmService.selectedRepository && widget.viewMode === 'tree';
173
- }
174
- return false;
175
- }
176
- });
177
- registry.registerItem(Object.assign(Object.assign({}, SCM_COMMANDS.COLLAPSE_ALL), { command: SCM_COMMANDS.COLLAPSE_ALL.id }));
178
- }
179
- registerKeybindings(keybindings) {
180
- super.registerKeybindings(keybindings);
181
- keybindings.registerKeybinding({
182
- command: SCM_COMMANDS.ACCEPT_INPUT.id,
183
- keybinding: 'ctrlcmd+enter',
184
- when: 'scmFocus'
185
- });
186
- }
187
- async acceptInput() {
188
- const command = this.acceptInputCommand();
189
- if (command && command.command) {
190
- await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
191
- }
192
- }
193
- acceptInputCommand() {
194
- const repository = this.scmService.selectedRepository;
195
- if (!repository) {
196
- return undefined;
197
- }
198
- return repository.provider.acceptInputCommand;
199
- }
200
- updateStatusBar() {
201
- this.statusBarDisposable.dispose();
202
- const repository = this.scmService.selectedRepository;
203
- if (!repository) {
204
- return;
205
- }
206
- const name = this.labelProvider.getName(new uri_1.default(repository.provider.rootUri));
207
- if (this.scmService.repositories.length > 1) {
208
- this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
209
- text: `$(database) ${name}`,
210
- tooltip: name.toString(),
211
- command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
212
- alignment: browser_1.StatusBarAlignment.LEFT,
213
- priority: 100
214
- });
215
- }
216
- const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
217
- this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
218
- text: value.title,
219
- tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
220
- command: value.command,
221
- arguments: value.arguments,
222
- alignment: browser_1.StatusBarAlignment.LEFT,
223
- priority: 100
224
- }));
225
- }
226
- setStatusBarEntry(id, entry) {
227
- this.statusBar.setElement(id, entry);
228
- this.statusBarDisposable.push(common_1.Disposable.create(() => this.statusBar.removeElement(id)));
229
- }
230
- /**
231
- * It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
232
- */
233
- registerColors(colors) {
234
- colors.register({
235
- id: ScmColors.editorGutterModifiedBackground, defaults: {
236
- dark: '#1B81A8',
237
- light: '#2090D3',
238
- hcDark: '#1B81A8',
239
- hcLight: '#2090D3'
240
- }, description: 'Editor gutter background color for lines that are modified.'
241
- }, {
242
- id: ScmColors.editorGutterAddedBackground, defaults: {
243
- dark: '#487E02',
244
- light: '#48985D',
245
- hcDark: '#487E02',
246
- hcLight: '#48985D'
247
- }, description: 'Editor gutter background color for lines that are added.'
248
- }, {
249
- id: ScmColors.editorGutterDeletedBackground, defaults: {
250
- dark: 'editorError.foreground',
251
- light: 'editorError.foreground',
252
- hcDark: 'editorError.foreground',
253
- hcLight: 'editorError.foreground'
254
- }, description: 'Editor gutter background color for lines that are deleted.'
255
- }, {
256
- id: 'minimapGutter.modifiedBackground', defaults: {
257
- dark: 'editorGutter.modifiedBackground',
258
- light: 'editorGutter.modifiedBackground',
259
- hcDark: 'editorGutter.modifiedBackground',
260
- hcLight: 'editorGutter.modifiedBackground'
261
- }, description: 'Minimap gutter background color for lines that are modified.'
262
- }, {
263
- id: 'minimapGutter.addedBackground', defaults: {
264
- dark: 'editorGutter.addedBackground',
265
- light: 'editorGutter.addedBackground',
266
- hcDark: 'editorGutter.modifiedBackground',
267
- hcLight: 'editorGutter.modifiedBackground'
268
- }, description: 'Minimap gutter background color for lines that are added.'
269
- }, {
270
- id: 'minimapGutter.deletedBackground', defaults: {
271
- dark: 'editorGutter.deletedBackground',
272
- light: 'editorGutter.deletedBackground',
273
- hcDark: 'editorGutter.deletedBackground',
274
- hcLight: 'editorGutter.deletedBackground'
275
- }, description: 'Minimap gutter background color for lines that are deleted.'
276
- }, {
277
- id: 'editorOverviewRuler.modifiedForeground', defaults: {
278
- dark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
279
- light: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
280
- hcDark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
281
- hcLight: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
282
- }, description: 'Overview ruler marker color for modified content.'
283
- }, {
284
- id: 'editorOverviewRuler.addedForeground', defaults: {
285
- dark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
286
- light: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
287
- hcDark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
288
- hcLight: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
289
- }, description: 'Overview ruler marker color for added content.'
290
- }, {
291
- id: 'editorOverviewRuler.deletedForeground', defaults: {
292
- dark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
293
- light: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
294
- hcDark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
295
- hcLight: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
296
- }, description: 'Overview ruler marker color for deleted content.'
297
- });
298
- }
299
- registerThemeStyle(theme, collector) {
300
- const contrastBorder = theme.getColor('contrastBorder');
301
- if (contrastBorder && (0, theme_1.isHighContrast)(theme.type)) {
302
- collector.addRule(`
303
- .theia-scm-input-message-container textarea {
304
- outline: var(--theia-border-width) solid ${contrastBorder};
305
- outline-offset: -1px;
306
- }
307
- `);
308
- }
309
- }
310
- };
311
- __decorate([
312
- (0, inversify_1.inject)(browser_1.StatusBar),
313
- __metadata("design:type", Object)
314
- ], ScmContribution.prototype, "statusBar", void 0);
315
- __decorate([
316
- (0, inversify_1.inject)(scm_service_1.ScmService),
317
- __metadata("design:type", scm_service_1.ScmService)
318
- ], ScmContribution.prototype, "scmService", void 0);
319
- __decorate([
320
- (0, inversify_1.inject)(scm_quick_open_service_1.ScmQuickOpenService),
321
- __metadata("design:type", scm_quick_open_service_1.ScmQuickOpenService)
322
- ], ScmContribution.prototype, "scmQuickOpenService", void 0);
323
- __decorate([
324
- (0, inversify_1.inject)(browser_1.LabelProvider),
325
- __metadata("design:type", browser_1.LabelProvider)
326
- ], ScmContribution.prototype, "labelProvider", void 0);
327
- __decorate([
328
- (0, inversify_1.inject)(common_1.CommandService),
329
- __metadata("design:type", Object)
330
- ], ScmContribution.prototype, "commands", void 0);
331
- __decorate([
332
- (0, inversify_1.inject)(common_1.CommandRegistry),
333
- __metadata("design:type", common_1.CommandRegistry)
334
- ], ScmContribution.prototype, "commandRegistry", void 0);
335
- __decorate([
336
- (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
337
- __metadata("design:type", Object)
338
- ], ScmContribution.prototype, "contextKeys", void 0);
339
- __decorate([
340
- (0, inversify_1.inject)(scm_decorations_service_1.ScmDecorationsService),
341
- __metadata("design:type", scm_decorations_service_1.ScmDecorationsService)
342
- ], ScmContribution.prototype, "scmDecorationsService", void 0);
343
- __decorate([
344
- (0, inversify_1.postConstruct)(),
345
- __metadata("design:type", Function),
346
- __metadata("design:paramtypes", []),
347
- __metadata("design:returntype", void 0)
348
- ], ScmContribution.prototype, "init", null);
349
- ScmContribution = __decorate([
350
- (0, inversify_1.injectable)(),
351
- __metadata("design:paramtypes", [])
352
- ], ScmContribution);
353
- exports.ScmContribution = ScmContribution;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ScmContribution = exports.ScmColors = exports.SCM_COMMANDS = exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS = exports.SCM_VIEW_CONTAINER_ID = exports.SCM_WIDGET_FACTORY_ID = void 0;
13
+ // *****************************************************************************
14
+ // Copyright (C) 2019 Red Hat, Inc. and others.
15
+ //
16
+ // This program and the accompanying materials are made available under the
17
+ // terms of the Eclipse Public License v. 2.0 which is available at
18
+ // http://www.eclipse.org/legal/epl-2.0.
19
+ //
20
+ // This Source Code may also be made available under the following Secondary
21
+ // Licenses when the conditions for such availability set forth in the Eclipse
22
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ // with the GNU Classpath Exception which is available at
24
+ // https://www.gnu.org/software/classpath/license.html.
25
+ //
26
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
+ // *****************************************************************************
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const event_1 = require("@theia/core/lib/common/event");
30
+ const browser_1 = require("@theia/core/lib/browser");
31
+ const common_1 = require("@theia/core/lib/common");
32
+ const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
33
+ const scm_service_1 = require("./scm-service");
34
+ const scm_widget_1 = require("../browser/scm-widget");
35
+ const uri_1 = require("@theia/core/lib/common/uri");
36
+ const scm_quick_open_service_1 = require("./scm-quick-open-service");
37
+ const color_1 = require("@theia/core/lib/common/color");
38
+ const scm_decorations_service_1 = require("../browser/decorations/scm-decorations-service");
39
+ const nls_1 = require("@theia/core/lib/common/nls");
40
+ const theme_1 = require("@theia/core/lib/common/theme");
41
+ exports.SCM_WIDGET_FACTORY_ID = scm_widget_1.ScmWidget.ID;
42
+ exports.SCM_VIEW_CONTAINER_ID = 'scm-view-container';
43
+ exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS = {
44
+ label: nls_1.nls.localizeByDefault('Source Control'),
45
+ iconClass: (0, browser_1.codicon)('source-control'),
46
+ closeable: true
47
+ };
48
+ var SCM_COMMANDS;
49
+ (function (SCM_COMMANDS) {
50
+ SCM_COMMANDS.CHANGE_REPOSITORY = {
51
+ id: 'scm.change.repository',
52
+ category: nls_1.nls.localizeByDefault('Source Control'),
53
+ originalCategory: 'Source Control',
54
+ label: nls_1.nls.localize('theia/scm/changeRepository', 'Change Repository...'),
55
+ originalLabel: 'Change Repository...'
56
+ };
57
+ SCM_COMMANDS.ACCEPT_INPUT = {
58
+ id: 'scm.acceptInput'
59
+ };
60
+ SCM_COMMANDS.TREE_VIEW_MODE = {
61
+ id: 'scm.viewmode.tree',
62
+ tooltip: nls_1.nls.localizeByDefault('View as Tree'),
63
+ iconClass: (0, browser_1.codicon)('list-tree'),
64
+ originalLabel: 'View as Tree',
65
+ label: nls_1.nls.localizeByDefault('View as Tree')
66
+ };
67
+ SCM_COMMANDS.LIST_VIEW_MODE = {
68
+ id: 'scm.viewmode.list',
69
+ tooltip: nls_1.nls.localizeByDefault('View as List'),
70
+ iconClass: (0, browser_1.codicon)('list-flat'),
71
+ originalLabel: 'View as List',
72
+ label: nls_1.nls.localizeByDefault('View as List')
73
+ };
74
+ SCM_COMMANDS.COLLAPSE_ALL = {
75
+ id: 'scm.collapseAll',
76
+ category: nls_1.nls.localizeByDefault('Source Control'),
77
+ originalCategory: 'Source Control',
78
+ tooltip: nls_1.nls.localizeByDefault('Collapse All'),
79
+ iconClass: (0, browser_1.codicon)('collapse-all'),
80
+ label: nls_1.nls.localizeByDefault('Collapse All'),
81
+ originalLabel: 'Collapse All'
82
+ };
83
+ })(SCM_COMMANDS = exports.SCM_COMMANDS || (exports.SCM_COMMANDS = {}));
84
+ var ScmColors;
85
+ (function (ScmColors) {
86
+ ScmColors.editorGutterModifiedBackground = 'editorGutter.modifiedBackground';
87
+ ScmColors.editorGutterAddedBackground = 'editorGutter.addedBackground';
88
+ ScmColors.editorGutterDeletedBackground = 'editorGutter.deletedBackground';
89
+ })(ScmColors = exports.ScmColors || (exports.ScmColors = {}));
90
+ let ScmContribution = class ScmContribution extends browser_1.AbstractViewContribution {
91
+ constructor() {
92
+ super({
93
+ viewContainerId: exports.SCM_VIEW_CONTAINER_ID,
94
+ widgetId: exports.SCM_WIDGET_FACTORY_ID,
95
+ widgetName: exports.SCM_VIEW_CONTAINER_TITLE_OPTIONS.label,
96
+ defaultWidgetOptions: {
97
+ area: 'left',
98
+ rank: 300
99
+ },
100
+ toggleCommandId: 'scmView:toggle',
101
+ toggleKeybinding: 'ctrlcmd+shift+g'
102
+ });
103
+ this.statusBarDisposable = new common_1.DisposableCollection();
104
+ }
105
+ init() {
106
+ this.scmFocus = this.contextKeys.createKey('scmFocus', false);
107
+ }
108
+ async initializeLayout() {
109
+ await this.openView();
110
+ }
111
+ onStart() {
112
+ this.updateStatusBar();
113
+ this.scmService.onDidAddRepository(() => this.updateStatusBar());
114
+ this.scmService.onDidRemoveRepository(() => this.updateStatusBar());
115
+ this.scmService.onDidChangeSelectedRepository(() => this.updateStatusBar());
116
+ this.scmService.onDidChangeStatusBarCommands(() => this.updateStatusBar());
117
+ this.labelProvider.onDidChange(() => this.updateStatusBar());
118
+ this.updateContextKeys();
119
+ this.shell.onDidChangeCurrentWidget(() => this.updateContextKeys());
120
+ }
121
+ updateContextKeys() {
122
+ this.scmFocus.set(this.shell.currentWidget instanceof scm_widget_1.ScmWidget);
123
+ }
124
+ registerCommands(commandRegistry) {
125
+ super.registerCommands(commandRegistry);
126
+ commandRegistry.registerCommand(SCM_COMMANDS.CHANGE_REPOSITORY, {
127
+ execute: () => this.scmQuickOpenService.changeRepository(),
128
+ isEnabled: () => this.scmService.repositories.length > 1
129
+ });
130
+ commandRegistry.registerCommand(SCM_COMMANDS.ACCEPT_INPUT, {
131
+ execute: () => this.acceptInput(),
132
+ isEnabled: () => !!this.scmFocus.get() && !!this.acceptInputCommand()
133
+ });
134
+ }
135
+ registerToolbarItems(registry) {
136
+ const viewModeEmitter = new event_1.Emitter();
137
+ const registerToggleViewItem = (command, mode) => {
138
+ const id = command.id;
139
+ const item = {
140
+ id,
141
+ command: id,
142
+ tooltip: command.label,
143
+ onDidChange: viewModeEmitter.event
144
+ };
145
+ this.commandRegistry.registerCommand({ id, iconClass: command && command.iconClass }, {
146
+ execute: widget => {
147
+ if (widget instanceof scm_widget_1.ScmWidget) {
148
+ widget.viewMode = mode;
149
+ viewModeEmitter.fire();
150
+ }
151
+ },
152
+ isVisible: widget => {
153
+ if (widget instanceof scm_widget_1.ScmWidget) {
154
+ return !!this.scmService.selectedRepository
155
+ && widget.viewMode !== mode;
156
+ }
157
+ return false;
158
+ },
159
+ });
160
+ registry.registerItem(item);
161
+ };
162
+ registerToggleViewItem(SCM_COMMANDS.TREE_VIEW_MODE, 'tree');
163
+ registerToggleViewItem(SCM_COMMANDS.LIST_VIEW_MODE, 'list');
164
+ this.commandRegistry.registerCommand(SCM_COMMANDS.COLLAPSE_ALL, {
165
+ execute: widget => {
166
+ if (widget instanceof scm_widget_1.ScmWidget && widget.viewMode === 'tree') {
167
+ widget.collapseScmTree();
168
+ }
169
+ },
170
+ isVisible: widget => {
171
+ if (widget instanceof scm_widget_1.ScmWidget) {
172
+ return !!this.scmService.selectedRepository && widget.viewMode === 'tree';
173
+ }
174
+ return false;
175
+ }
176
+ });
177
+ registry.registerItem(Object.assign(Object.assign({}, SCM_COMMANDS.COLLAPSE_ALL), { command: SCM_COMMANDS.COLLAPSE_ALL.id }));
178
+ }
179
+ registerKeybindings(keybindings) {
180
+ super.registerKeybindings(keybindings);
181
+ keybindings.registerKeybinding({
182
+ command: SCM_COMMANDS.ACCEPT_INPUT.id,
183
+ keybinding: 'ctrlcmd+enter',
184
+ when: 'scmFocus'
185
+ });
186
+ }
187
+ async acceptInput() {
188
+ const command = this.acceptInputCommand();
189
+ if (command && command.command) {
190
+ await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
191
+ }
192
+ }
193
+ acceptInputCommand() {
194
+ const repository = this.scmService.selectedRepository;
195
+ if (!repository) {
196
+ return undefined;
197
+ }
198
+ return repository.provider.acceptInputCommand;
199
+ }
200
+ updateStatusBar() {
201
+ this.statusBarDisposable.dispose();
202
+ const repository = this.scmService.selectedRepository;
203
+ if (!repository) {
204
+ return;
205
+ }
206
+ const name = this.labelProvider.getName(new uri_1.default(repository.provider.rootUri));
207
+ if (this.scmService.repositories.length > 1) {
208
+ this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
209
+ text: `$(database) ${name}`,
210
+ tooltip: name.toString(),
211
+ command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
212
+ alignment: browser_1.StatusBarAlignment.LEFT,
213
+ priority: 100
214
+ });
215
+ }
216
+ const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
217
+ this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
218
+ text: value.title,
219
+ tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
220
+ command: value.command,
221
+ arguments: value.arguments,
222
+ alignment: browser_1.StatusBarAlignment.LEFT,
223
+ priority: 100
224
+ }));
225
+ }
226
+ setStatusBarEntry(id, entry) {
227
+ this.statusBar.setElement(id, entry);
228
+ this.statusBarDisposable.push(common_1.Disposable.create(() => this.statusBar.removeElement(id)));
229
+ }
230
+ /**
231
+ * It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
232
+ */
233
+ registerColors(colors) {
234
+ colors.register({
235
+ id: ScmColors.editorGutterModifiedBackground, defaults: {
236
+ dark: '#1B81A8',
237
+ light: '#2090D3',
238
+ hcDark: '#1B81A8',
239
+ hcLight: '#2090D3'
240
+ }, description: 'Editor gutter background color for lines that are modified.'
241
+ }, {
242
+ id: ScmColors.editorGutterAddedBackground, defaults: {
243
+ dark: '#487E02',
244
+ light: '#48985D',
245
+ hcDark: '#487E02',
246
+ hcLight: '#48985D'
247
+ }, description: 'Editor gutter background color for lines that are added.'
248
+ }, {
249
+ id: ScmColors.editorGutterDeletedBackground, defaults: {
250
+ dark: 'editorError.foreground',
251
+ light: 'editorError.foreground',
252
+ hcDark: 'editorError.foreground',
253
+ hcLight: 'editorError.foreground'
254
+ }, description: 'Editor gutter background color for lines that are deleted.'
255
+ }, {
256
+ id: 'minimapGutter.modifiedBackground', defaults: {
257
+ dark: 'editorGutter.modifiedBackground',
258
+ light: 'editorGutter.modifiedBackground',
259
+ hcDark: 'editorGutter.modifiedBackground',
260
+ hcLight: 'editorGutter.modifiedBackground'
261
+ }, description: 'Minimap gutter background color for lines that are modified.'
262
+ }, {
263
+ id: 'minimapGutter.addedBackground', defaults: {
264
+ dark: 'editorGutter.addedBackground',
265
+ light: 'editorGutter.addedBackground',
266
+ hcDark: 'editorGutter.modifiedBackground',
267
+ hcLight: 'editorGutter.modifiedBackground'
268
+ }, description: 'Minimap gutter background color for lines that are added.'
269
+ }, {
270
+ id: 'minimapGutter.deletedBackground', defaults: {
271
+ dark: 'editorGutter.deletedBackground',
272
+ light: 'editorGutter.deletedBackground',
273
+ hcDark: 'editorGutter.deletedBackground',
274
+ hcLight: 'editorGutter.deletedBackground'
275
+ }, description: 'Minimap gutter background color for lines that are deleted.'
276
+ }, {
277
+ id: 'editorOverviewRuler.modifiedForeground', defaults: {
278
+ dark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
279
+ light: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
280
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
281
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
282
+ }, description: 'Overview ruler marker color for modified content.'
283
+ }, {
284
+ id: 'editorOverviewRuler.addedForeground', defaults: {
285
+ dark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
286
+ light: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
287
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
288
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
289
+ }, description: 'Overview ruler marker color for added content.'
290
+ }, {
291
+ id: 'editorOverviewRuler.deletedForeground', defaults: {
292
+ dark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
293
+ light: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
294
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
295
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
296
+ }, description: 'Overview ruler marker color for deleted content.'
297
+ });
298
+ }
299
+ registerThemeStyle(theme, collector) {
300
+ const contrastBorder = theme.getColor('contrastBorder');
301
+ if (contrastBorder && (0, theme_1.isHighContrast)(theme.type)) {
302
+ collector.addRule(`
303
+ .theia-scm-input-message-container textarea {
304
+ outline: var(--theia-border-width) solid ${contrastBorder};
305
+ outline-offset: -1px;
306
+ }
307
+ `);
308
+ }
309
+ }
310
+ };
311
+ __decorate([
312
+ (0, inversify_1.inject)(browser_1.StatusBar),
313
+ __metadata("design:type", Object)
314
+ ], ScmContribution.prototype, "statusBar", void 0);
315
+ __decorate([
316
+ (0, inversify_1.inject)(scm_service_1.ScmService),
317
+ __metadata("design:type", scm_service_1.ScmService)
318
+ ], ScmContribution.prototype, "scmService", void 0);
319
+ __decorate([
320
+ (0, inversify_1.inject)(scm_quick_open_service_1.ScmQuickOpenService),
321
+ __metadata("design:type", scm_quick_open_service_1.ScmQuickOpenService)
322
+ ], ScmContribution.prototype, "scmQuickOpenService", void 0);
323
+ __decorate([
324
+ (0, inversify_1.inject)(browser_1.LabelProvider),
325
+ __metadata("design:type", browser_1.LabelProvider)
326
+ ], ScmContribution.prototype, "labelProvider", void 0);
327
+ __decorate([
328
+ (0, inversify_1.inject)(common_1.CommandService),
329
+ __metadata("design:type", Object)
330
+ ], ScmContribution.prototype, "commands", void 0);
331
+ __decorate([
332
+ (0, inversify_1.inject)(common_1.CommandRegistry),
333
+ __metadata("design:type", common_1.CommandRegistry)
334
+ ], ScmContribution.prototype, "commandRegistry", void 0);
335
+ __decorate([
336
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
337
+ __metadata("design:type", Object)
338
+ ], ScmContribution.prototype, "contextKeys", void 0);
339
+ __decorate([
340
+ (0, inversify_1.inject)(scm_decorations_service_1.ScmDecorationsService),
341
+ __metadata("design:type", scm_decorations_service_1.ScmDecorationsService)
342
+ ], ScmContribution.prototype, "scmDecorationsService", void 0);
343
+ __decorate([
344
+ (0, inversify_1.postConstruct)(),
345
+ __metadata("design:type", Function),
346
+ __metadata("design:paramtypes", []),
347
+ __metadata("design:returntype", void 0)
348
+ ], ScmContribution.prototype, "init", null);
349
+ ScmContribution = __decorate([
350
+ (0, inversify_1.injectable)(),
351
+ __metadata("design:paramtypes", [])
352
+ ], ScmContribution);
353
+ exports.ScmContribution = ScmContribution;
354
354
  //# sourceMappingURL=scm-contribution.js.map