@codingame/monaco-vscode-scm-service-override 7.1.0 → 8.0.0

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.
@@ -1,16 +1,34 @@
1
+ import { localize } from 'vscode/vscode/vs/nls';
1
2
  import { lastOrDefault } from 'vscode/vscode/vs/base/common/arrays';
2
3
  import { deepClone } from 'vscode/vscode/vs/base/common/objects';
3
4
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
5
+ import { registerColor, asCssVariable } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
6
+ import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
7
+ import { chartsBlue, chartsPurple, chartsOrange, chartsGreen, chartsRed, chartsYellow } from 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
8
+ import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
9
+ import { buttonForeground } from 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
10
+ import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
11
+ import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
12
+ import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
13
+ import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
14
+ import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
15
+ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
16
+ import { rot } from 'vscode/vscode/vs/base/common/numbers';
4
17
 
5
18
  const SWIMLANE_HEIGHT = 22;
6
19
  const SWIMLANE_WIDTH = 11;
7
20
  const CIRCLE_RADIUS = 4;
8
21
  const SWIMLANE_CURVE_RADIUS = 5;
9
- const graphColors = ['#007ACC', '#BC3FBC', '#BF8803', '#CC6633', '#F14C4C', '#16825D'];
10
- function getNextColorIndex(colorIndex) {
11
- return colorIndex < graphColors.length - 1 ? colorIndex + 1 : 1;
12
- }
13
- function getLabelColorIndex(historyItem, colorMap) {
22
+ const historyItemGroupLocal = registerColor('scm.historyGraph.historyItemGroupLocal', chartsBlue, ( localize(10413, "Local history item group color.")));
23
+ const historyItemGroupRemote = registerColor('scm.historyGraph.historyItemGroupRemote', chartsPurple, ( localize(10414, "Remote history item group color.")));
24
+ const historyItemGroupBase = registerColor('scm.historyGraph.historyItemGroupBase', chartsOrange, ( localize(10415, "Base history item group color.")));
25
+ const historyItemGroupHoverLabelForeground = registerColor('scm.historyGraph.historyItemGroupHoverLabelForeground', buttonForeground, ( localize(10416, "History item group hover label foreground color.")));
26
+ const colorRegistry = [
27
+ registerColor('scm.historyGraph.green', chartsGreen, ( localize(10417, "The green color used in history graph."))),
28
+ registerColor('scm.historyGraph.red', chartsRed, ( localize(10418, "The red color used in history graph."))),
29
+ registerColor('scm.historyGraph.yellow', chartsYellow, ( localize(10419, "The yellow color used in history graph."))),
30
+ ];
31
+ function getLabelColorIdentifier(historyItem, colorMap) {
14
32
  for (const label of historyItem.labels ?? []) {
15
33
  const colorIndex = colorMap.get(label.title);
16
34
  if (colorIndex !== undefined) {
@@ -19,20 +37,20 @@ function getLabelColorIndex(historyItem, colorMap) {
19
37
  }
20
38
  return undefined;
21
39
  }
22
- function createPath(stroke) {
40
+ function createPath(colorIdentifier) {
23
41
  const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
24
42
  path.setAttribute('fill', 'none');
25
- path.setAttribute('stroke', stroke);
26
43
  path.setAttribute('stroke-width', '1px');
27
44
  path.setAttribute('stroke-linecap', 'round');
45
+ path.style.stroke = asCssVariable(colorIdentifier);
28
46
  return path;
29
47
  }
30
- function drawCircle(index, radius, fill) {
48
+ function drawCircle(index, radius, colorIdentifier) {
31
49
  const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
32
50
  circle.setAttribute('cx', `${SWIMLANE_WIDTH * (index + 1)}`);
33
51
  circle.setAttribute('cy', `${SWIMLANE_WIDTH}`);
34
52
  circle.setAttribute('r', `${radius}`);
35
- circle.setAttribute('fill', fill);
53
+ circle.style.fill = asCssVariable(colorIdentifier);
36
54
  return circle;
37
55
  }
38
56
  function drawVerticalLine(x1, y1, y2, color) {
@@ -56,10 +74,10 @@ function renderSCMHistoryItemGraph(historyItemViewModel) {
56
74
  const outputSwimlanes = historyItemViewModel.outputSwimlanes;
57
75
  const inputIndex = inputSwimlanes.findIndex(node => node.id === historyItem.id);
58
76
  const circleIndex = inputIndex !== -1 ? inputIndex : inputSwimlanes.length;
59
- const circleColorIndex = circleIndex < outputSwimlanes.length ? outputSwimlanes[circleIndex].color : inputSwimlanes[circleIndex].color;
77
+ const circleColor = circleIndex < outputSwimlanes.length ? outputSwimlanes[circleIndex].color : inputSwimlanes[circleIndex].color;
60
78
  let outputSwimlaneIndex = 0;
61
79
  for (let index = 0; index < inputSwimlanes.length; index++) {
62
- const color = graphColors[inputSwimlanes[index].color];
80
+ const color = inputSwimlanes[index].color;
63
81
  if (inputSwimlanes[index].id === historyItem.id) {
64
82
  if (index !== circleIndex) {
65
83
  const d = [];
@@ -103,7 +121,7 @@ function renderSCMHistoryItemGraph(historyItemViewModel) {
103
121
  continue;
104
122
  }
105
123
  const d = [];
106
- const path = createPath(graphColors[outputSwimlanes[parentOutputIndex].color]);
124
+ const path = createPath(outputSwimlanes[parentOutputIndex].color);
107
125
  d.push(`M ${SWIMLANE_WIDTH * parentOutputIndex} ${SWIMLANE_HEIGHT / 2}`);
108
126
  d.push(`A ${SWIMLANE_WIDTH} ${SWIMLANE_WIDTH} 0 0 1 ${SWIMLANE_WIDTH * (parentOutputIndex + 1)} ${SWIMLANE_HEIGHT}`);
109
127
  d.push(`M ${SWIMLANE_WIDTH * parentOutputIndex} ${SWIMLANE_HEIGHT / 2}`);
@@ -112,38 +130,38 @@ function renderSCMHistoryItemGraph(historyItemViewModel) {
112
130
  svg.append(path);
113
131
  }
114
132
  if (inputIndex !== -1) {
115
- const path = drawVerticalLine(SWIMLANE_WIDTH * (circleIndex + 1), 0, SWIMLANE_HEIGHT / 2, graphColors[inputSwimlanes[inputIndex].color]);
133
+ const path = drawVerticalLine(SWIMLANE_WIDTH * (circleIndex + 1), 0, SWIMLANE_HEIGHT / 2, inputSwimlanes[inputIndex].color);
116
134
  svg.append(path);
117
135
  }
118
136
  if (historyItem.parentIds.length > 0) {
119
- const path = drawVerticalLine(SWIMLANE_WIDTH * (circleIndex + 1), SWIMLANE_HEIGHT / 2, SWIMLANE_HEIGHT, graphColors[circleColorIndex]);
137
+ const path = drawVerticalLine(SWIMLANE_WIDTH * (circleIndex + 1), SWIMLANE_HEIGHT / 2, SWIMLANE_HEIGHT, circleColor);
120
138
  svg.append(path);
121
139
  }
122
140
  if (historyItem.parentIds.length > 1) {
123
- const circleOuter = drawCircle(circleIndex, CIRCLE_RADIUS + 1, graphColors[circleColorIndex]);
141
+ const circleOuter = drawCircle(circleIndex, CIRCLE_RADIUS + 1, circleColor);
124
142
  svg.append(circleOuter);
125
- const circleInner = drawCircle(circleIndex, CIRCLE_RADIUS - 1, graphColors[circleColorIndex]);
143
+ const circleInner = drawCircle(circleIndex, CIRCLE_RADIUS - 1, circleColor);
126
144
  svg.append(circleInner);
127
145
  }
128
146
  else {
129
147
  if (historyItem.labels?.some(l => ThemeIcon.isThemeIcon(l.icon) && l.icon.id === 'target')) {
130
- const outerCircle = drawCircle(circleIndex, CIRCLE_RADIUS + 2, graphColors[circleColorIndex]);
148
+ const outerCircle = drawCircle(circleIndex, CIRCLE_RADIUS + 2, circleColor);
131
149
  svg.append(outerCircle);
132
150
  }
133
- const circle = drawCircle(circleIndex, CIRCLE_RADIUS, graphColors[circleColorIndex]);
151
+ const circle = drawCircle(circleIndex, CIRCLE_RADIUS, circleColor);
134
152
  svg.append(circle);
135
153
  }
136
154
  svg.style.height = `${SWIMLANE_HEIGHT}px`;
137
155
  svg.style.width = `${SWIMLANE_WIDTH * (Math.max(inputSwimlanes.length, outputSwimlanes.length, 1) + 1)}px`;
138
156
  return svg;
139
157
  }
140
- function toISCMHistoryItemViewModelArray(historyItems, colorMap = ( new Map())) {
158
+ function toISCMHistoryItemViewModelArray(historyItems, colorMap = ( (new Map()))) {
141
159
  let colorIndex = -1;
142
160
  const viewModels = [];
143
161
  for (let index = 0; index < historyItems.length; index++) {
144
162
  const historyItem = historyItems[index];
145
163
  const outputSwimlanesFromPreviousItem = lastOrDefault(viewModels)?.outputSwimlanes ?? [];
146
- const inputSwimlanes = ( outputSwimlanesFromPreviousItem.map(i => deepClone(i)));
164
+ const inputSwimlanes = ( (outputSwimlanesFromPreviousItem.map(i => deepClone(i))));
147
165
  const outputSwimlanes = [];
148
166
  if (historyItem.parentIds.length > 0) {
149
167
  let firstParentAdded = false;
@@ -152,7 +170,7 @@ function toISCMHistoryItemViewModelArray(historyItems, colorMap = ( new Map()))
152
170
  if (!firstParentAdded) {
153
171
  outputSwimlanes.push({
154
172
  id: historyItem.parentIds[0],
155
- color: getLabelColorIndex(historyItem, colorMap) ?? node.color
173
+ color: getLabelColorIdentifier(historyItem, colorMap) ?? node.color
156
174
  });
157
175
  firstParentAdded = true;
158
176
  }
@@ -161,10 +179,22 @@ function toISCMHistoryItemViewModelArray(historyItems, colorMap = ( new Map()))
161
179
  outputSwimlanes.push(deepClone(node));
162
180
  }
163
181
  for (let i = firstParentAdded ? 1 : 0; i < historyItem.parentIds.length; i++) {
164
- colorIndex = getLabelColorIndex(historyItem, colorMap) ?? getNextColorIndex(colorIndex);
182
+ let colorIdentifier;
183
+ if (!firstParentAdded) {
184
+ colorIdentifier = getLabelColorIdentifier(historyItem, colorMap);
185
+ }
186
+ else {
187
+ const historyItemParent = historyItems
188
+ .find(h => h.id === historyItem.parentIds[i]);
189
+ colorIdentifier = historyItemParent ? getLabelColorIdentifier(historyItemParent, colorMap) : undefined;
190
+ }
191
+ if (!colorIdentifier) {
192
+ colorIndex = rot(colorIndex + 1, colorRegistry.length);
193
+ colorIdentifier = colorRegistry[colorIndex];
194
+ }
165
195
  outputSwimlanes.push({
166
196
  id: historyItem.parentIds[i],
167
- color: colorIndex
197
+ color: colorIdentifier
168
198
  });
169
199
  }
170
200
  }
@@ -177,4 +207,4 @@ function toISCMHistoryItemViewModelArray(historyItems, colorMap = ( new Map()))
177
207
  return viewModels;
178
208
  }
179
209
 
180
- export { renderSCMHistoryItemGraph, toISCMHistoryItemViewModelArray };
210
+ export { colorRegistry, historyItemGroupBase, historyItemGroupHoverLabelForeground, historyItemGroupLocal, historyItemGroupRemote, renderSCMHistoryItemGraph, toISCMHistoryItemViewModelArray };
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import './media/scm.css.js';
3
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { localize } from 'vscode/vscode/vs/nls';
4
4
  import { Event } from 'vscode/vscode/vs/base/common/event';
5
5
  import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
6
6
  import { append, $ } from 'vscode/vscode/vs/base/browser/dom';
@@ -13,7 +13,6 @@ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeServi
13
13
  import { WorkbenchList } from 'vscode/vscode/vs/platform/list/browser/listService';
14
14
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
15
15
  import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
16
- import { SIDE_BAR_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
17
16
  import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
18
17
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
19
18
  import { RepositoryRenderer, RepositoryActionRunner } from './scmRepositoryRenderer.js';
@@ -24,7 +23,6 @@ import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
24
23
  import { MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
25
24
  import { IHoverService } from 'vscode/vscode/vs/platform/hover/browser/hover.service';
26
25
 
27
- const _moduleId = "vs/workbench/contrib/scm/browser/scmRepositoriesViewPane";
28
26
  class ListDelegate {
29
27
  getHeight() {
30
28
  return 22;
@@ -55,15 +53,13 @@ let SCMRepositoriesViewPane = class SCMRepositoriesViewPane extends ViewPane {
55
53
  this.list = this.instantiationService.createInstance(WorkbenchList, `SCM Main`, listContainer, delegate, [renderer], {
56
54
  identityProvider,
57
55
  horizontalScrolling: false,
58
- overrideStyles: {
59
- listBackground: SIDE_BAR_BACKGROUND
60
- },
56
+ overrideStyles: this.getLocationBasedColors().listOverrideStyles,
61
57
  accessibilityProvider: {
62
58
  getAriaLabel(r) {
63
59
  return r.provider.label;
64
60
  },
65
61
  getWidgetAriaLabel() {
66
- return ( localizeWithPath(_moduleId, 0, "Source Control Repositories"));
62
+ return ( localize(6366, "Source Control Repositories"));
67
63
  }
68
64
  }
69
65
  });