@theia/scm 1.45.0 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +31 -31
  2. package/lib/browser/decorations/scm-decorations-service.d.ts +14 -14
  3. package/lib/browser/decorations/scm-decorations-service.js +101 -101
  4. package/lib/browser/decorations/scm-navigator-decorator.d.ts +25 -25
  5. package/lib/browser/decorations/scm-navigator-decorator.js +132 -132
  6. package/lib/browser/decorations/scm-tab-bar-decorator.d.ts +17 -17
  7. package/lib/browser/decorations/scm-tab-bar-decorator.js +93 -93
  8. package/lib/browser/dirty-diff/content-lines.d.ts +12 -12
  9. package/lib/browser/dirty-diff/content-lines.js +106 -106
  10. package/lib/browser/dirty-diff/content-lines.spec.d.ts +1 -1
  11. package/lib/browser/dirty-diff/content-lines.spec.js +39 -39
  12. package/lib/browser/dirty-diff/diff-computer.d.ts +29 -29
  13. package/lib/browser/dirty-diff/diff-computer.js +102 -102
  14. package/lib/browser/dirty-diff/diff-computer.spec.d.ts +1 -1
  15. package/lib/browser/dirty-diff/diff-computer.spec.js +315 -315
  16. package/lib/browser/dirty-diff/dirty-diff-decorator.d.ts +14 -14
  17. package/lib/browser/dirty-diff/dirty-diff-decorator.js +98 -98
  18. package/lib/browser/dirty-diff/dirty-diff-module.d.ts +3 -3
  19. package/lib/browser/dirty-diff/dirty-diff-module.js +24 -24
  20. package/lib/browser/scm-amend-component.d.ts +123 -123
  21. package/lib/browser/scm-amend-component.js +463 -463
  22. package/lib/browser/scm-amend-widget.d.ts +20 -20
  23. package/lib/browser/scm-amend-widget.js +101 -101
  24. package/lib/browser/scm-avatar-service.d.ts +3 -3
  25. package/lib/browser/scm-avatar-service.js +36 -36
  26. package/lib/browser/scm-commit-widget.d.ts +52 -52
  27. package/lib/browser/scm-commit-widget.js +199 -199
  28. package/lib/browser/scm-context-key-service.d.ts +10 -10
  29. package/lib/browser/scm-context-key-service.js +58 -58
  30. package/lib/browser/scm-contribution.d.ts +83 -83
  31. package/lib/browser/scm-contribution.js +356 -356
  32. package/lib/browser/scm-frontend-module.d.ts +6 -6
  33. package/lib/browser/scm-frontend-module.js +130 -130
  34. package/lib/browser/scm-groups-tree-model.d.ts +14 -14
  35. package/lib/browser/scm-groups-tree-model.js +97 -97
  36. package/lib/browser/scm-input.d.ts +53 -53
  37. package/lib/browser/scm-input.js +127 -127
  38. package/lib/browser/scm-layout-migrations.d.ts +9 -9
  39. package/lib/browser/scm-layout-migrations.js +79 -79
  40. package/lib/browser/scm-no-repository-widget.d.ts +8 -8
  41. package/lib/browser/scm-no-repository-widget.js +49 -49
  42. package/lib/browser/scm-preferences.d.ts +11 -11
  43. package/lib/browser/scm-preferences.js +51 -51
  44. package/lib/browser/scm-provider.d.ts +58 -58
  45. package/lib/browser/scm-provider.js +19 -19
  46. package/lib/browser/scm-quick-open-service.d.ts +11 -11
  47. package/lib/browser/scm-quick-open-service.js +73 -73
  48. package/lib/browser/scm-repository.d.ts +17 -17
  49. package/lib/browser/scm-repository.js +41 -41
  50. package/lib/browser/scm-service.d.ts +26 -26
  51. package/lib/browser/scm-service.js +108 -108
  52. package/lib/browser/scm-tree-label-provider.d.ts +7 -7
  53. package/lib/browser/scm-tree-label-provider.js +57 -57
  54. package/lib/browser/scm-tree-model.d.ts +74 -74
  55. package/lib/browser/scm-tree-model.js +351 -351
  56. package/lib/browser/scm-tree-widget.d.ts +208 -208
  57. package/lib/browser/scm-tree-widget.js +703 -703
  58. package/lib/browser/scm-widget.d.ts +40 -40
  59. package/lib/browser/scm-widget.js +218 -218
  60. package/package.json +6 -6
  61. package/src/browser/decorations/scm-decorations-service.ts +78 -78
  62. package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
  63. package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
  64. package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
  65. package/src/browser/dirty-diff/content-lines.ts +112 -112
  66. package/src/browser/dirty-diff/diff-computer.spec.ts +387 -387
  67. package/src/browser/dirty-diff/diff-computer.ts +129 -129
  68. package/src/browser/dirty-diff/dirty-diff-decorator.ts +107 -107
  69. package/src/browser/dirty-diff/dirty-diff-module.ts +24 -24
  70. package/src/browser/scm-amend-component.tsx +600 -600
  71. package/src/browser/scm-amend-widget.tsx +77 -77
  72. package/src/browser/scm-avatar-service.ts +27 -27
  73. package/src/browser/scm-commit-widget.tsx +215 -215
  74. package/src/browser/scm-context-key-service.ts +46 -46
  75. package/src/browser/scm-contribution.ts +361 -361
  76. package/src/browser/scm-frontend-module.ts +149 -149
  77. package/src/browser/scm-groups-tree-model.ts +78 -78
  78. package/src/browser/scm-input.ts +164 -164
  79. package/src/browser/scm-layout-migrations.ts +64 -64
  80. package/src/browser/scm-no-repository-widget.tsx +41 -41
  81. package/src/browser/scm-preferences.ts +63 -63
  82. package/src/browser/scm-provider.ts +91 -91
  83. package/src/browser/scm-quick-open-service.ts +48 -48
  84. package/src/browser/scm-repository.ts +52 -52
  85. package/src/browser/scm-service.ts +108 -108
  86. package/src/browser/scm-tree-label-provider.ts +44 -44
  87. package/src/browser/scm-tree-model.ts +405 -405
  88. package/src/browser/scm-tree-widget.tsx +838 -838
  89. package/src/browser/scm-widget.tsx +204 -204
  90. package/src/browser/style/dirty-diff-decorator.css +52 -52
  91. package/src/browser/style/dirty-diff.css +50 -50
  92. package/src/browser/style/index.css +271 -271
  93. package/src/browser/style/scm-amend-component.css +94 -94
  94. package/src/browser/style/scm.svg +4 -4
@@ -1,357 +1,357 @@
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-only 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({
178
- ...SCM_COMMANDS.COLLAPSE_ALL,
179
- command: SCM_COMMANDS.COLLAPSE_ALL.id
180
- });
181
- }
182
- registerKeybindings(keybindings) {
183
- super.registerKeybindings(keybindings);
184
- keybindings.registerKeybinding({
185
- command: SCM_COMMANDS.ACCEPT_INPUT.id,
186
- keybinding: 'ctrlcmd+enter',
187
- when: 'scmFocus'
188
- });
189
- }
190
- async acceptInput() {
191
- const command = this.acceptInputCommand();
192
- if (command && command.command) {
193
- await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
194
- }
195
- }
196
- acceptInputCommand() {
197
- const repository = this.scmService.selectedRepository;
198
- if (!repository) {
199
- return undefined;
200
- }
201
- return repository.provider.acceptInputCommand;
202
- }
203
- updateStatusBar() {
204
- this.statusBarDisposable.dispose();
205
- const repository = this.scmService.selectedRepository;
206
- if (!repository) {
207
- return;
208
- }
209
- const name = this.labelProvider.getName(new uri_1.default(repository.provider.rootUri));
210
- if (this.scmService.repositories.length > 1) {
211
- this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
212
- text: `$(database) ${name}`,
213
- tooltip: name.toString(),
214
- command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
215
- alignment: browser_1.StatusBarAlignment.LEFT,
216
- priority: 100
217
- });
218
- }
219
- const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
220
- this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
221
- text: value.title,
222
- tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
223
- command: value.command,
224
- arguments: value.arguments,
225
- alignment: browser_1.StatusBarAlignment.LEFT,
226
- priority: 100
227
- }));
228
- }
229
- setStatusBarEntry(id, entry) {
230
- this.statusBar.setElement(id, entry);
231
- this.statusBarDisposable.push(common_1.Disposable.create(() => this.statusBar.removeElement(id)));
232
- }
233
- /**
234
- * It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
235
- */
236
- registerColors(colors) {
237
- colors.register({
238
- id: ScmColors.editorGutterModifiedBackground, defaults: {
239
- dark: '#1B81A8',
240
- light: '#2090D3',
241
- hcDark: '#1B81A8',
242
- hcLight: '#2090D3'
243
- }, description: 'Editor gutter background color for lines that are modified.'
244
- }, {
245
- id: ScmColors.editorGutterAddedBackground, defaults: {
246
- dark: '#487E02',
247
- light: '#48985D',
248
- hcDark: '#487E02',
249
- hcLight: '#48985D'
250
- }, description: 'Editor gutter background color for lines that are added.'
251
- }, {
252
- id: ScmColors.editorGutterDeletedBackground, defaults: {
253
- dark: 'editorError.foreground',
254
- light: 'editorError.foreground',
255
- hcDark: 'editorError.foreground',
256
- hcLight: 'editorError.foreground'
257
- }, description: 'Editor gutter background color for lines that are deleted.'
258
- }, {
259
- id: 'minimapGutter.modifiedBackground', defaults: {
260
- dark: 'editorGutter.modifiedBackground',
261
- light: 'editorGutter.modifiedBackground',
262
- hcDark: 'editorGutter.modifiedBackground',
263
- hcLight: 'editorGutter.modifiedBackground'
264
- }, description: 'Minimap gutter background color for lines that are modified.'
265
- }, {
266
- id: 'minimapGutter.addedBackground', defaults: {
267
- dark: 'editorGutter.addedBackground',
268
- light: 'editorGutter.addedBackground',
269
- hcDark: 'editorGutter.modifiedBackground',
270
- hcLight: 'editorGutter.modifiedBackground'
271
- }, description: 'Minimap gutter background color for lines that are added.'
272
- }, {
273
- id: 'minimapGutter.deletedBackground', defaults: {
274
- dark: 'editorGutter.deletedBackground',
275
- light: 'editorGutter.deletedBackground',
276
- hcDark: 'editorGutter.deletedBackground',
277
- hcLight: 'editorGutter.deletedBackground'
278
- }, description: 'Minimap gutter background color for lines that are deleted.'
279
- }, {
280
- id: 'editorOverviewRuler.modifiedForeground', defaults: {
281
- dark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
282
- light: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
283
- hcDark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
284
- hcLight: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
285
- }, description: 'Overview ruler marker color for modified content.'
286
- }, {
287
- id: 'editorOverviewRuler.addedForeground', defaults: {
288
- dark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
289
- light: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
290
- hcDark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
291
- hcLight: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
292
- }, description: 'Overview ruler marker color for added content.'
293
- }, {
294
- id: 'editorOverviewRuler.deletedForeground', defaults: {
295
- dark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
296
- light: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
297
- hcDark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
298
- hcLight: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
299
- }, description: 'Overview ruler marker color for deleted content.'
300
- });
301
- }
302
- registerThemeStyle(theme, collector) {
303
- const contrastBorder = theme.getColor('contrastBorder');
304
- if (contrastBorder && (0, theme_1.isHighContrast)(theme.type)) {
305
- collector.addRule(`
306
- .theia-scm-input-message-container textarea {
307
- outline: var(--theia-border-width) solid ${contrastBorder};
308
- outline-offset: -1px;
309
- }
310
- `);
311
- }
312
- }
313
- };
314
- __decorate([
315
- (0, inversify_1.inject)(browser_1.StatusBar),
316
- __metadata("design:type", Object)
317
- ], ScmContribution.prototype, "statusBar", void 0);
318
- __decorate([
319
- (0, inversify_1.inject)(scm_service_1.ScmService),
320
- __metadata("design:type", scm_service_1.ScmService)
321
- ], ScmContribution.prototype, "scmService", void 0);
322
- __decorate([
323
- (0, inversify_1.inject)(scm_quick_open_service_1.ScmQuickOpenService),
324
- __metadata("design:type", scm_quick_open_service_1.ScmQuickOpenService)
325
- ], ScmContribution.prototype, "scmQuickOpenService", void 0);
326
- __decorate([
327
- (0, inversify_1.inject)(browser_1.LabelProvider),
328
- __metadata("design:type", browser_1.LabelProvider)
329
- ], ScmContribution.prototype, "labelProvider", void 0);
330
- __decorate([
331
- (0, inversify_1.inject)(common_1.CommandService),
332
- __metadata("design:type", Object)
333
- ], ScmContribution.prototype, "commands", void 0);
334
- __decorate([
335
- (0, inversify_1.inject)(common_1.CommandRegistry),
336
- __metadata("design:type", common_1.CommandRegistry)
337
- ], ScmContribution.prototype, "commandRegistry", void 0);
338
- __decorate([
339
- (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
340
- __metadata("design:type", Object)
341
- ], ScmContribution.prototype, "contextKeys", void 0);
342
- __decorate([
343
- (0, inversify_1.inject)(scm_decorations_service_1.ScmDecorationsService),
344
- __metadata("design:type", scm_decorations_service_1.ScmDecorationsService)
345
- ], ScmContribution.prototype, "scmDecorationsService", void 0);
346
- __decorate([
347
- (0, inversify_1.postConstruct)(),
348
- __metadata("design:type", Function),
349
- __metadata("design:paramtypes", []),
350
- __metadata("design:returntype", void 0)
351
- ], ScmContribution.prototype, "init", null);
352
- ScmContribution = __decorate([
353
- (0, inversify_1.injectable)(),
354
- __metadata("design:paramtypes", [])
355
- ], ScmContribution);
356
- 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-only 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({
178
+ ...SCM_COMMANDS.COLLAPSE_ALL,
179
+ command: SCM_COMMANDS.COLLAPSE_ALL.id
180
+ });
181
+ }
182
+ registerKeybindings(keybindings) {
183
+ super.registerKeybindings(keybindings);
184
+ keybindings.registerKeybinding({
185
+ command: SCM_COMMANDS.ACCEPT_INPUT.id,
186
+ keybinding: 'ctrlcmd+enter',
187
+ when: 'scmFocus'
188
+ });
189
+ }
190
+ async acceptInput() {
191
+ const command = this.acceptInputCommand();
192
+ if (command && command.command) {
193
+ await this.commands.executeCommand(command.command, ...command.arguments ? command.arguments : []);
194
+ }
195
+ }
196
+ acceptInputCommand() {
197
+ const repository = this.scmService.selectedRepository;
198
+ if (!repository) {
199
+ return undefined;
200
+ }
201
+ return repository.provider.acceptInputCommand;
202
+ }
203
+ updateStatusBar() {
204
+ this.statusBarDisposable.dispose();
205
+ const repository = this.scmService.selectedRepository;
206
+ if (!repository) {
207
+ return;
208
+ }
209
+ const name = this.labelProvider.getName(new uri_1.default(repository.provider.rootUri));
210
+ if (this.scmService.repositories.length > 1) {
211
+ this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
212
+ text: `$(database) ${name}`,
213
+ tooltip: name.toString(),
214
+ command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
215
+ alignment: browser_1.StatusBarAlignment.LEFT,
216
+ priority: 100
217
+ });
218
+ }
219
+ const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
220
+ this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
221
+ text: value.title,
222
+ tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
223
+ command: value.command,
224
+ arguments: value.arguments,
225
+ alignment: browser_1.StatusBarAlignment.LEFT,
226
+ priority: 100
227
+ }));
228
+ }
229
+ setStatusBarEntry(id, entry) {
230
+ this.statusBar.setElement(id, entry);
231
+ this.statusBarDisposable.push(common_1.Disposable.create(() => this.statusBar.removeElement(id)));
232
+ }
233
+ /**
234
+ * It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
235
+ */
236
+ registerColors(colors) {
237
+ colors.register({
238
+ id: ScmColors.editorGutterModifiedBackground, defaults: {
239
+ dark: '#1B81A8',
240
+ light: '#2090D3',
241
+ hcDark: '#1B81A8',
242
+ hcLight: '#2090D3'
243
+ }, description: 'Editor gutter background color for lines that are modified.'
244
+ }, {
245
+ id: ScmColors.editorGutterAddedBackground, defaults: {
246
+ dark: '#487E02',
247
+ light: '#48985D',
248
+ hcDark: '#487E02',
249
+ hcLight: '#48985D'
250
+ }, description: 'Editor gutter background color for lines that are added.'
251
+ }, {
252
+ id: ScmColors.editorGutterDeletedBackground, defaults: {
253
+ dark: 'editorError.foreground',
254
+ light: 'editorError.foreground',
255
+ hcDark: 'editorError.foreground',
256
+ hcLight: 'editorError.foreground'
257
+ }, description: 'Editor gutter background color for lines that are deleted.'
258
+ }, {
259
+ id: 'minimapGutter.modifiedBackground', defaults: {
260
+ dark: 'editorGutter.modifiedBackground',
261
+ light: 'editorGutter.modifiedBackground',
262
+ hcDark: 'editorGutter.modifiedBackground',
263
+ hcLight: 'editorGutter.modifiedBackground'
264
+ }, description: 'Minimap gutter background color for lines that are modified.'
265
+ }, {
266
+ id: 'minimapGutter.addedBackground', defaults: {
267
+ dark: 'editorGutter.addedBackground',
268
+ light: 'editorGutter.addedBackground',
269
+ hcDark: 'editorGutter.modifiedBackground',
270
+ hcLight: 'editorGutter.modifiedBackground'
271
+ }, description: 'Minimap gutter background color for lines that are added.'
272
+ }, {
273
+ id: 'minimapGutter.deletedBackground', defaults: {
274
+ dark: 'editorGutter.deletedBackground',
275
+ light: 'editorGutter.deletedBackground',
276
+ hcDark: 'editorGutter.deletedBackground',
277
+ hcLight: 'editorGutter.deletedBackground'
278
+ }, description: 'Minimap gutter background color for lines that are deleted.'
279
+ }, {
280
+ id: 'editorOverviewRuler.modifiedForeground', defaults: {
281
+ dark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
282
+ light: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
283
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
284
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
285
+ }, description: 'Overview ruler marker color for modified content.'
286
+ }, {
287
+ id: 'editorOverviewRuler.addedForeground', defaults: {
288
+ dark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
289
+ light: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
290
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
291
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
292
+ }, description: 'Overview ruler marker color for added content.'
293
+ }, {
294
+ id: 'editorOverviewRuler.deletedForeground', defaults: {
295
+ dark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
296
+ light: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
297
+ hcDark: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
298
+ hcLight: color_1.Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
299
+ }, description: 'Overview ruler marker color for deleted content.'
300
+ });
301
+ }
302
+ registerThemeStyle(theme, collector) {
303
+ const contrastBorder = theme.getColor('contrastBorder');
304
+ if (contrastBorder && (0, theme_1.isHighContrast)(theme.type)) {
305
+ collector.addRule(`
306
+ .theia-scm-input-message-container textarea {
307
+ outline: var(--theia-border-width) solid ${contrastBorder};
308
+ outline-offset: -1px;
309
+ }
310
+ `);
311
+ }
312
+ }
313
+ };
314
+ __decorate([
315
+ (0, inversify_1.inject)(browser_1.StatusBar),
316
+ __metadata("design:type", Object)
317
+ ], ScmContribution.prototype, "statusBar", void 0);
318
+ __decorate([
319
+ (0, inversify_1.inject)(scm_service_1.ScmService),
320
+ __metadata("design:type", scm_service_1.ScmService)
321
+ ], ScmContribution.prototype, "scmService", void 0);
322
+ __decorate([
323
+ (0, inversify_1.inject)(scm_quick_open_service_1.ScmQuickOpenService),
324
+ __metadata("design:type", scm_quick_open_service_1.ScmQuickOpenService)
325
+ ], ScmContribution.prototype, "scmQuickOpenService", void 0);
326
+ __decorate([
327
+ (0, inversify_1.inject)(browser_1.LabelProvider),
328
+ __metadata("design:type", browser_1.LabelProvider)
329
+ ], ScmContribution.prototype, "labelProvider", void 0);
330
+ __decorate([
331
+ (0, inversify_1.inject)(common_1.CommandService),
332
+ __metadata("design:type", Object)
333
+ ], ScmContribution.prototype, "commands", void 0);
334
+ __decorate([
335
+ (0, inversify_1.inject)(common_1.CommandRegistry),
336
+ __metadata("design:type", common_1.CommandRegistry)
337
+ ], ScmContribution.prototype, "commandRegistry", void 0);
338
+ __decorate([
339
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
340
+ __metadata("design:type", Object)
341
+ ], ScmContribution.prototype, "contextKeys", void 0);
342
+ __decorate([
343
+ (0, inversify_1.inject)(scm_decorations_service_1.ScmDecorationsService),
344
+ __metadata("design:type", scm_decorations_service_1.ScmDecorationsService)
345
+ ], ScmContribution.prototype, "scmDecorationsService", void 0);
346
+ __decorate([
347
+ (0, inversify_1.postConstruct)(),
348
+ __metadata("design:type", Function),
349
+ __metadata("design:paramtypes", []),
350
+ __metadata("design:returntype", void 0)
351
+ ], ScmContribution.prototype, "init", null);
352
+ ScmContribution = __decorate([
353
+ (0, inversify_1.injectable)(),
354
+ __metadata("design:paramtypes", [])
355
+ ], ScmContribution);
356
+ exports.ScmContribution = ScmContribution;
357
357
  //# sourceMappingURL=scm-contribution.js.map