@codingame/monaco-vscode-base-service-override 4.1.0 → 4.1.2

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.
package/base.js CHANGED
@@ -7,16 +7,16 @@ import { ITreeViewsDnDService } from 'vscode/vscode/vs/editor/common/services/tr
7
7
  import { ITreeViewsService } from 'vscode/vscode/vs/workbench/services/views/browser/treeViewsService';
8
8
  import { TreeViewsDnDService } from 'vscode/vscode/vs/editor/common/services/treeViewsDnd';
9
9
  import { IURLService } from 'vscode/vscode/vs/platform/url/common/url';
10
- import { JSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditingService';
11
- import { DecorationsService } from 'vscode/vscode/vs/workbench/services/decorations/browser/decorationsService';
12
- import { BrowserRequestService } from 'vscode/vscode/vs/workbench/services/request/browser/requestService';
13
- import { BrowserURLService } from 'vscode/vscode/vs/workbench/services/url/browser/urlService';
10
+ import { JSONEditingService } from './vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js';
11
+ import { DecorationsService } from './vscode/src/vs/workbench/services/decorations/browser/decorationsService.js';
12
+ import { BrowserRequestService } from './vscode/src/vs/workbench/services/request/browser/requestService.js';
13
+ import { BrowserURLService } from './vscode/src/vs/workbench/services/url/browser/urlService.js';
14
14
  import { TreeviewsService } from './vscode/src/vs/workbench/services/views/common/treeViewsService.js';
15
15
  import { CanonicalUriService } from './vscode/src/vs/workbench/services/workspaces/common/canonicalUriService.js';
16
16
  import { ICanonicalUriService } from 'vscode/vscode/vs/platform/workspace/common/canonicalUri';
17
17
  import { IUserActivityService, UserActivityService } from 'vscode/vscode/vs/workbench/services/userActivity/common/userActivityService';
18
18
  import { IDownloadService } from 'vscode/vscode/vs/platform/download/common/download';
19
- import { DownloadService } from 'vscode/vscode/vs/platform/download/common/downloadService';
19
+ import { DownloadService } from './vscode/src/vs/platform/download/common/downloadService.js';
20
20
  import { IPathService, AbstractPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
21
21
  import { IWorkingCopyFileService, WorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService';
22
22
  import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-base-service-override",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@4.1.0"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.2"
22
22
  }
23
23
  }
@@ -0,0 +1,62 @@
1
+ import { bufferToStream, VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
2
+ import { canceled } from 'vscode/vscode/vs/base/common/errors';
3
+ import { OfflineError } from 'vscode/vscode/vs/base/parts/request/common/request';
4
+
5
+ function request(options, token) {
6
+ if (options.proxyAuthorization) {
7
+ options.headers = {
8
+ ...(options.headers || {}),
9
+ 'Proxy-Authorization': options.proxyAuthorization
10
+ };
11
+ }
12
+ const xhr = ( new XMLHttpRequest());
13
+ return ( new Promise((resolve, reject) => {
14
+ xhr.open(options.type || 'GET', options.url || '', true, options.user, options.password);
15
+ setRequestHeaders(xhr, options);
16
+ xhr.responseType = 'arraybuffer';
17
+ xhr.onerror = e => reject(navigator.onLine ? ( new Error(xhr.statusText && ('XHR failed: ' + xhr.statusText) || 'XHR failed')) : ( new OfflineError()));
18
+ xhr.onload = (e) => {
19
+ resolve({
20
+ res: {
21
+ statusCode: xhr.status,
22
+ headers: getResponseHeaders(xhr)
23
+ },
24
+ stream: bufferToStream(VSBuffer.wrap(( new Uint8Array(xhr.response))))
25
+ });
26
+ };
27
+ xhr.ontimeout = e => reject(( new Error(`XHR timeout: ${options.timeout}ms`)));
28
+ if (options.timeout) {
29
+ xhr.timeout = options.timeout;
30
+ }
31
+ xhr.send(options.data);
32
+ token.onCancellationRequested(() => {
33
+ xhr.abort();
34
+ reject(canceled());
35
+ });
36
+ }));
37
+ }
38
+ function setRequestHeaders(xhr, options) {
39
+ if (options.headers) {
40
+ outer: for (const k in options.headers) {
41
+ switch (k) {
42
+ case 'User-Agent':
43
+ case 'Accept-Encoding':
44
+ case 'Content-Length':
45
+ continue outer;
46
+ }
47
+ xhr.setRequestHeader(k, options.headers[k]);
48
+ }
49
+ }
50
+ }
51
+ function getResponseHeaders(xhr) {
52
+ const headers = Object.create(null);
53
+ for (const line of xhr.getAllResponseHeaders().split(/\r\n|\n|\r/g)) {
54
+ if (line) {
55
+ const idx = line.indexOf(':');
56
+ headers[line.substr(0, idx).trim().toLowerCase()] = line.substr(idx + 1).trim();
57
+ }
58
+ }
59
+ return headers;
60
+ }
61
+
62
+ export { request };
@@ -0,0 +1,33 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
3
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
4
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
5
+ import { asTextOrError, IRequestService } from 'vscode/vscode/vs/platform/request/common/request';
6
+
7
+ let DownloadService = class DownloadService {
8
+ constructor(requestService, fileService) {
9
+ this.requestService = requestService;
10
+ this.fileService = fileService;
11
+ }
12
+ async download(resource, target, cancellationToken = CancellationToken.None) {
13
+ if (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote) {
14
+ await this.fileService.copy(resource, target);
15
+ return;
16
+ }
17
+ const options = { type: 'GET', url: ( resource.toString(true)) };
18
+ const context = await this.requestService.request(options, cancellationToken);
19
+ if (context.res.statusCode === 200) {
20
+ await this.fileService.writeFile(target, context.stream);
21
+ }
22
+ else {
23
+ const message = await asTextOrError(context);
24
+ throw new Error(`Expected 200, got back ${context.res.statusCode} instead.\n\n${message}`);
25
+ }
26
+ }
27
+ };
28
+ DownloadService = ( __decorate([
29
+ ( __param(0, IRequestService)),
30
+ ( __param(1, IFileService))
31
+ ], DownloadService));
32
+
33
+ export { DownloadService };
@@ -0,0 +1,30 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { request } from '../../../base/parts/request/browser/request.js';
3
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
4
+ import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
5
+ import { AbstractRequestService } from 'vscode/vscode/vs/platform/request/common/request';
6
+
7
+ let RequestService = class RequestService extends AbstractRequestService {
8
+ constructor(configurationService, loggerService) {
9
+ super(loggerService);
10
+ this.configurationService = configurationService;
11
+ }
12
+ async request(options, token) {
13
+ if (!options.proxyAuthorization) {
14
+ options.proxyAuthorization = this.configurationService.getValue('http.proxyAuthorization');
15
+ }
16
+ return this.logAndRequest('browser', options, () => request(options, token));
17
+ }
18
+ async resolveProxy(url) {
19
+ return undefined;
20
+ }
21
+ async loadCertificates() {
22
+ return [];
23
+ }
24
+ };
25
+ RequestService = ( __decorate([
26
+ ( __param(0, IConfigurationService)),
27
+ ( __param(1, ILoggerService))
28
+ ], RequestService));
29
+
30
+ export { RequestService };
@@ -0,0 +1,20 @@
1
+ import { bufferToStream } from 'vscode/vscode/vs/base/common/buffer';
2
+ import 'vscode/vscode/vs/base/common/cancellation';
3
+
4
+ class RequestChannelClient {
5
+ constructor(channel) {
6
+ this.channel = channel;
7
+ }
8
+ async request(options, token) {
9
+ const [res, buffer] = await this.channel.call('request', [options], token);
10
+ return { res, stream: bufferToStream(buffer) };
11
+ }
12
+ async resolveProxy(url) {
13
+ return this.channel.call('resolveProxy', [url]);
14
+ }
15
+ async loadCertificates() {
16
+ return this.channel.call('loadCertificates');
17
+ }
18
+ }
19
+
20
+ export { RequestChannelClient };
@@ -0,0 +1,22 @@
1
+ import { first } from 'vscode/vscode/vs/base/common/async';
2
+ import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import 'vscode/vscode/vs/base/common/path';
4
+ import 'vscode/vscode/vs/base/common/platform';
5
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
6
+
7
+ class AbstractURLService extends Disposable {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.handlers = ( new Set());
11
+ }
12
+ open(uri, options) {
13
+ const handlers = [...( this.handlers.values())];
14
+ return first(( handlers.map(h => () => h.handleURL(uri, options))), undefined, false).then(val => val || false);
15
+ }
16
+ registerHandler(handler) {
17
+ this.handlers.add(handler);
18
+ return toDisposable(() => this.handlers.delete(handler));
19
+ }
20
+ }
21
+
22
+ export { AbstractURLService };
@@ -0,0 +1,122 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { parse } from 'vscode/vscode/vs/base/common/json';
4
+ import { setProperty } from 'vscode/vscode/vs/base/common/jsonEdit';
5
+ import { Queue } from 'vscode/vscode/vs/base/common/async';
6
+ import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
7
+ import { Range } from 'vscode/vscode/vs/editor/common/core/range';
8
+ import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
9
+ import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
10
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
11
+ import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
12
+ import { JSONEditingError } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing';
13
+
14
+ let JSONEditingService = class JSONEditingService {
15
+ constructor(fileService, textModelResolverService, textFileService) {
16
+ this.fileService = fileService;
17
+ this.textModelResolverService = textModelResolverService;
18
+ this.textFileService = textFileService;
19
+ this.queue = ( new Queue());
20
+ }
21
+ write(resource, values) {
22
+ return Promise.resolve(this.queue.queue(() => this.doWriteConfiguration(resource, values)));
23
+ }
24
+ async doWriteConfiguration(resource, values) {
25
+ const reference = await this.resolveAndValidate(resource, true);
26
+ try {
27
+ await this.writeToBuffer(reference.object.textEditorModel, values);
28
+ }
29
+ finally {
30
+ reference.dispose();
31
+ }
32
+ }
33
+ async writeToBuffer(model, values) {
34
+ let hasEdits = false;
35
+ for (const value of values) {
36
+ const edit = this.getEdits(model, value)[0];
37
+ hasEdits = !!edit && this.applyEditsToBuffer(edit, model);
38
+ }
39
+ if (hasEdits) {
40
+ return this.textFileService.save(model.uri);
41
+ }
42
+ }
43
+ applyEditsToBuffer(edit, model) {
44
+ const startPosition = model.getPositionAt(edit.offset);
45
+ const endPosition = model.getPositionAt(edit.offset + edit.length);
46
+ const range = ( new Range(
47
+ startPosition.lineNumber,
48
+ startPosition.column,
49
+ endPosition.lineNumber,
50
+ endPosition.column
51
+ ));
52
+ const currentText = model.getValueInRange(range);
53
+ if (edit.content !== currentText) {
54
+ const editOperation = currentText ? EditOperation.replace(range, edit.content) : EditOperation.insert(startPosition, edit.content);
55
+ model.pushEditOperations([( new Selection(
56
+ startPosition.lineNumber,
57
+ startPosition.column,
58
+ startPosition.lineNumber,
59
+ startPosition.column
60
+ ))], [editOperation], () => []);
61
+ return true;
62
+ }
63
+ return false;
64
+ }
65
+ getEdits(model, configurationValue) {
66
+ const { tabSize, insertSpaces } = model.getOptions();
67
+ const eol = model.getEOL();
68
+ const { path, value } = configurationValue;
69
+ if (!path.length) {
70
+ const content = JSON.stringify(value, null, insertSpaces ? ' '.repeat(tabSize) : '\t');
71
+ return [{
72
+ content,
73
+ length: content.length,
74
+ offset: 0
75
+ }];
76
+ }
77
+ return setProperty(model.getValue(), path, value, { tabSize, insertSpaces, eol });
78
+ }
79
+ async resolveModelReference(resource) {
80
+ const exists = await this.fileService.exists(resource);
81
+ if (!exists) {
82
+ await this.textFileService.write(resource, '{}', { encoding: 'utf8' });
83
+ }
84
+ return this.textModelResolverService.createModelReference(resource);
85
+ }
86
+ hasParseErrors(model) {
87
+ const parseErrors = [];
88
+ parse(model.getValue(), parseErrors, { allowTrailingComma: true, allowEmptyContent: true });
89
+ return parseErrors.length > 0;
90
+ }
91
+ async resolveAndValidate(resource, checkDirty) {
92
+ const reference = await this.resolveModelReference(resource);
93
+ const model = reference.object.textEditorModel;
94
+ if (this.hasParseErrors(model)) {
95
+ reference.dispose();
96
+ return this.reject(0 );
97
+ }
98
+ return reference;
99
+ }
100
+ reject(code) {
101
+ const message = this.toErrorMessage(code);
102
+ return Promise.reject(( new JSONEditingError(message, code)));
103
+ }
104
+ toErrorMessage(error) {
105
+ switch (error) {
106
+ case 0 : {
107
+ return ( localizeWithPath(
108
+ 'vs/workbench/services/configuration/common/jsonEditingService',
109
+ 'errorInvalidFile',
110
+ "Unable to write into the file. Please open the file to correct errors/warnings in the file and try again."
111
+ ));
112
+ }
113
+ }
114
+ }
115
+ };
116
+ JSONEditingService = ( __decorate([
117
+ ( __param(0, IFileService)),
118
+ ( __param(1, ITextModelService)),
119
+ ( __param(2, ITextFileService))
120
+ ], JSONEditingService));
121
+
122
+ export { JSONEditingService };
@@ -0,0 +1,332 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { DebounceEmitter, Emitter } from 'vscode/vscode/vs/base/common/event';
3
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
+ import { TernarySearchTree } from 'vscode/vscode/vs/base/common/ternarySearchTree';
5
+ import { toDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
6
+ import { isThenable } from 'vscode/vscode/vs/base/common/async';
7
+ import { LinkedList } from 'vscode/vscode/vs/base/common/linkedList';
8
+ import { createCSSRule, asCSSPropertyValue, removeCSSRulesContainingSelector, createStyleSheet } from 'vscode/vscode/vs/base/browser/dom';
9
+ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
10
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
11
+ import { isFalsyOrWhitespace } from 'vscode/vscode/vs/base/common/strings';
12
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
13
+ import { isCancellationError } from 'vscode/vscode/vs/base/common/errors';
14
+ import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
15
+ import { hash } from 'vscode/vscode/vs/base/common/hash';
16
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
17
+ import { distinct, asArray } from 'vscode/vscode/vs/base/common/arrays';
18
+ import { asCssVariable } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
19
+ import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
20
+ import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
21
+ import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
22
+ import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
23
+ import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
24
+ import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
25
+ import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
26
+ import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
27
+ import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
28
+ import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
29
+ import { getIconRegistry } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
30
+
31
+ class DecorationRule {
32
+ static keyOf(data) {
33
+ if (Array.isArray(data)) {
34
+ return ( data.map(DecorationRule.keyOf)).join(',');
35
+ }
36
+ else {
37
+ const { color, letter } = data;
38
+ if (ThemeIcon.isThemeIcon(letter)) {
39
+ return `${color}+${letter.id}`;
40
+ }
41
+ else {
42
+ return `${color}/${letter}`;
43
+ }
44
+ }
45
+ }
46
+ static { this._classNamesPrefix = 'monaco-decoration'; }
47
+ constructor(themeService, data, key) {
48
+ this.themeService = themeService;
49
+ this._refCounter = 0;
50
+ this.data = data;
51
+ const suffix = ( hash(key).toString(36));
52
+ this.itemColorClassName = `${DecorationRule._classNamesPrefix}-itemColor-${suffix}`;
53
+ this.itemBadgeClassName = `${DecorationRule._classNamesPrefix}-itemBadge-${suffix}`;
54
+ this.bubbleBadgeClassName = `${DecorationRule._classNamesPrefix}-bubbleBadge-${suffix}`;
55
+ this.iconBadgeClassName = `${DecorationRule._classNamesPrefix}-iconBadge-${suffix}`;
56
+ }
57
+ acquire() {
58
+ this._refCounter += 1;
59
+ }
60
+ release() {
61
+ return --this._refCounter === 0;
62
+ }
63
+ appendCSSRules(element) {
64
+ if (!Array.isArray(this.data)) {
65
+ this._appendForOne(this.data, element);
66
+ }
67
+ else {
68
+ this._appendForMany(this.data, element);
69
+ }
70
+ }
71
+ _appendForOne(data, element) {
72
+ const { color, letter } = data;
73
+ createCSSRule(`.${this.itemColorClassName}`, `color: ${getColor(color)};`, element);
74
+ if (ThemeIcon.isThemeIcon(letter)) {
75
+ this._createIconCSSRule(letter, color, element);
76
+ }
77
+ else if (letter) {
78
+ createCSSRule(`.${this.itemBadgeClassName}::after`, `content: "${letter}"; color: ${getColor(color)};`, element);
79
+ }
80
+ }
81
+ _appendForMany(data, element) {
82
+ const { color } = data.find(d => !!d.color) ?? data[0];
83
+ createCSSRule(`.${this.itemColorClassName}`, `color: ${getColor(color)};`, element);
84
+ const letters = [];
85
+ let icon;
86
+ for (const d of data) {
87
+ if (ThemeIcon.isThemeIcon(d.letter)) {
88
+ icon = d.letter;
89
+ break;
90
+ }
91
+ else if (d.letter) {
92
+ letters.push(d.letter);
93
+ }
94
+ }
95
+ if (icon) {
96
+ this._createIconCSSRule(icon, color, element);
97
+ }
98
+ else {
99
+ if (letters.length) {
100
+ createCSSRule(`.${this.itemBadgeClassName}::after`, `content: "${letters.join(', ')}"; color: ${getColor(color)};`, element);
101
+ }
102
+ createCSSRule(`.${this.bubbleBadgeClassName}::after`, `content: "\uea71"; color: ${getColor(color)}; font-family: codicon; font-size: 14px; margin-right: 14px; opacity: 0.4;`, element);
103
+ }
104
+ }
105
+ _createIconCSSRule(icon, color, element) {
106
+ const modifier = ThemeIcon.getModifier(icon);
107
+ if (modifier) {
108
+ icon = ThemeIcon.modify(icon, undefined);
109
+ }
110
+ const iconContribution = getIconRegistry().getIcon(icon.id);
111
+ if (!iconContribution) {
112
+ return;
113
+ }
114
+ const definition = this.themeService.getProductIconTheme().getIcon(iconContribution);
115
+ if (!definition) {
116
+ return;
117
+ }
118
+ createCSSRule(`.${this.iconBadgeClassName}::after`, `content: '${definition.fontCharacter}';
119
+ color: ${icon.color ? getColor(icon.color.id) : getColor(color)};
120
+ font-family: ${asCSSPropertyValue(definition.font?.id ?? 'codicon')};
121
+ font-size: 16px;
122
+ margin-right: 14px;
123
+ font-weight: normal;
124
+ ${modifier === 'spin' ? 'animation: codicon-spin 1.5s steps(30) infinite' : ''};
125
+ `, element);
126
+ }
127
+ removeCSSRules(element) {
128
+ removeCSSRulesContainingSelector(this.itemColorClassName, element);
129
+ removeCSSRulesContainingSelector(this.itemBadgeClassName, element);
130
+ removeCSSRulesContainingSelector(this.bubbleBadgeClassName, element);
131
+ removeCSSRulesContainingSelector(this.iconBadgeClassName, element);
132
+ }
133
+ }
134
+ class DecorationStyles {
135
+ constructor(_themeService) {
136
+ this._themeService = _themeService;
137
+ this._dispoables = ( new DisposableStore());
138
+ this._styleElement = createStyleSheet(undefined, undefined, this._dispoables);
139
+ this._decorationRules = ( new Map());
140
+ }
141
+ dispose() {
142
+ this._dispoables.dispose();
143
+ }
144
+ asDecoration(data, onlyChildren) {
145
+ data.sort((a, b) => (b.weight || 0) - (a.weight || 0));
146
+ const key = DecorationRule.keyOf(data);
147
+ let rule = this._decorationRules.get(key);
148
+ if (!rule) {
149
+ rule = ( new DecorationRule(this._themeService, data, key));
150
+ this._decorationRules.set(key, rule);
151
+ rule.appendCSSRules(this._styleElement);
152
+ }
153
+ rule.acquire();
154
+ const labelClassName = rule.itemColorClassName;
155
+ let badgeClassName = rule.itemBadgeClassName;
156
+ const iconClassName = rule.iconBadgeClassName;
157
+ let tooltip = distinct(( data.filter(d => !isFalsyOrWhitespace(d.tooltip)).map(d => d.tooltip))).join(' • ');
158
+ const strikethrough = ( data.some(d => d.strikethrough));
159
+ if (onlyChildren) {
160
+ badgeClassName = rule.bubbleBadgeClassName;
161
+ tooltip = ( localizeWithPath(
162
+ 'vs/workbench/services/decorations/browser/decorationsService',
163
+ 'bubbleTitle',
164
+ "Contains emphasized items"
165
+ ));
166
+ }
167
+ return {
168
+ labelClassName,
169
+ badgeClassName,
170
+ iconClassName,
171
+ strikethrough,
172
+ tooltip,
173
+ dispose: () => {
174
+ if (rule?.release()) {
175
+ this._decorationRules.delete(key);
176
+ rule.removeCSSRules(this._styleElement);
177
+ rule = undefined;
178
+ }
179
+ }
180
+ };
181
+ }
182
+ }
183
+ class FileDecorationChangeEvent {
184
+ constructor(all) {
185
+ this._data = TernarySearchTree.forUris(_uri => true);
186
+ this._data.fill(true, asArray(all));
187
+ }
188
+ affectsResource(uri) {
189
+ return this._data.hasElementOrSubtree(uri);
190
+ }
191
+ }
192
+ class DecorationDataRequest {
193
+ constructor(source, thenable) {
194
+ this.source = source;
195
+ this.thenable = thenable;
196
+ }
197
+ }
198
+ function getColor(color) {
199
+ return color ? asCssVariable(color) : 'inherit';
200
+ }
201
+ let DecorationsService = class DecorationsService {
202
+ constructor(uriIdentityService, themeService) {
203
+ this._onDidChangeDecorationsDelayed = ( new DebounceEmitter({ merge: all => all.flat() }));
204
+ this._onDidChangeDecorations = ( new Emitter());
205
+ this.onDidChangeDecorations = this._onDidChangeDecorations.event;
206
+ this._provider = ( new LinkedList());
207
+ this._decorationStyles = ( new DecorationStyles(themeService));
208
+ this._data = TernarySearchTree.forUris(key => uriIdentityService.extUri.ignorePathCasing(key));
209
+ this._onDidChangeDecorationsDelayed.event(event => { this._onDidChangeDecorations.fire(( new FileDecorationChangeEvent(event))); });
210
+ }
211
+ dispose() {
212
+ this._onDidChangeDecorations.dispose();
213
+ this._onDidChangeDecorationsDelayed.dispose();
214
+ this._data.clear();
215
+ }
216
+ registerDecorationsProvider(provider) {
217
+ const rm = this._provider.unshift(provider);
218
+ this._onDidChangeDecorations.fire({
219
+ affectsResource() { return true; }
220
+ });
221
+ const removeAll = () => {
222
+ const uris = [];
223
+ for (const [uri, map] of this._data) {
224
+ if (map.delete(provider)) {
225
+ uris.push(uri);
226
+ }
227
+ }
228
+ if (uris.length > 0) {
229
+ this._onDidChangeDecorationsDelayed.fire(uris);
230
+ }
231
+ };
232
+ const listener = provider.onDidChange(uris => {
233
+ if (!uris) {
234
+ removeAll();
235
+ }
236
+ else {
237
+ for (const uri of uris) {
238
+ const map = this._ensureEntry(uri);
239
+ this._fetchData(map, uri, provider);
240
+ }
241
+ }
242
+ });
243
+ return toDisposable(() => {
244
+ rm();
245
+ listener.dispose();
246
+ removeAll();
247
+ });
248
+ }
249
+ _ensureEntry(uri) {
250
+ let map = this._data.get(uri);
251
+ if (!map) {
252
+ map = ( new Map());
253
+ this._data.set(uri, map);
254
+ }
255
+ return map;
256
+ }
257
+ getDecoration(uri, includeChildren) {
258
+ const all = [];
259
+ let containsChildren = false;
260
+ const map = this._ensureEntry(uri);
261
+ for (const provider of this._provider) {
262
+ let data = map.get(provider);
263
+ if (data === undefined) {
264
+ data = this._fetchData(map, uri, provider);
265
+ }
266
+ if (data && !(data instanceof DecorationDataRequest)) {
267
+ all.push(data);
268
+ }
269
+ }
270
+ if (includeChildren) {
271
+ const iter = this._data.findSuperstr(uri);
272
+ if (iter) {
273
+ for (const tuple of iter) {
274
+ for (const data of ( tuple[1].values())) {
275
+ if (data && !(data instanceof DecorationDataRequest)) {
276
+ if (data.bubble) {
277
+ all.push(data);
278
+ containsChildren = true;
279
+ }
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ return all.length === 0
286
+ ? undefined
287
+ : this._decorationStyles.asDecoration(all, containsChildren);
288
+ }
289
+ _fetchData(map, uri, provider) {
290
+ const pendingRequest = map.get(provider);
291
+ if (pendingRequest instanceof DecorationDataRequest) {
292
+ pendingRequest.source.cancel();
293
+ map.delete(provider);
294
+ }
295
+ const cts = ( new CancellationTokenSource());
296
+ const dataOrThenable = provider.provideDecorations(uri, cts.token);
297
+ if (!isThenable(dataOrThenable)) {
298
+ cts.dispose();
299
+ return this._keepItem(map, provider, uri, dataOrThenable);
300
+ }
301
+ else {
302
+ const request = ( new DecorationDataRequest(cts, Promise.resolve(dataOrThenable).then(data => {
303
+ if (map.get(provider) === request) {
304
+ this._keepItem(map, provider, uri, data);
305
+ }
306
+ }).catch(err => {
307
+ if (!isCancellationError(err) && map.get(provider) === request) {
308
+ map.delete(provider);
309
+ }
310
+ }).finally(() => {
311
+ cts.dispose();
312
+ })));
313
+ map.set(provider, request);
314
+ return null;
315
+ }
316
+ }
317
+ _keepItem(map, provider, uri, data) {
318
+ const deco = data ? data : null;
319
+ const old = map.get(provider);
320
+ map.set(provider, deco);
321
+ if (deco || old) {
322
+ this._onDidChangeDecorationsDelayed.fire(uri);
323
+ }
324
+ return deco;
325
+ }
326
+ };
327
+ DecorationsService = ( __decorate([
328
+ ( __param(0, IUriIdentityService)),
329
+ ( __param(1, IThemeService))
330
+ ], DecorationsService));
331
+
332
+ export { DecorationsService };
@@ -0,0 +1,50 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
3
+ import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
4
+ import { RequestChannelClient } from '../../../../platform/request/common/requestIpc.js';
5
+ import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
6
+ import { RequestService } from '../../../../platform/request/browser/requestService.js';
7
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
8
+
9
+ let BrowserRequestService = class BrowserRequestService extends RequestService {
10
+ constructor(remoteAgentService, configurationService, loggerService) {
11
+ super(configurationService, loggerService);
12
+ this.remoteAgentService = remoteAgentService;
13
+ }
14
+ async request(options, token) {
15
+ try {
16
+ const context = await super.request(options, token);
17
+ const connection = this.remoteAgentService.getConnection();
18
+ if (connection && context.res.statusCode === 405) {
19
+ return this._makeRemoteRequest(connection, options, token);
20
+ }
21
+ return context;
22
+ }
23
+ catch (error) {
24
+ const connection = this.remoteAgentService.getConnection();
25
+ if (connection) {
26
+ return this._makeRemoteRequest(connection, options, token);
27
+ }
28
+ throw error;
29
+ }
30
+ }
31
+ _makeRemoteRequest(connection, options, token) {
32
+ return connection.withChannel('request', channel => ( new RequestChannelClient(channel)).request(options, token));
33
+ }
34
+ };
35
+ BrowserRequestService = ( __decorate([
36
+ ( __param(0, IRemoteAgentService)),
37
+ ( __param(1, IConfigurationService)),
38
+ ( __param(2, ILoggerService))
39
+ ], BrowserRequestService));
40
+ CommandsRegistry.registerCommand('_workbench.fetchJSON', async function (accessor, url, method) {
41
+ const result = await fetch(url, { method, headers: { Accept: 'application/json' } });
42
+ if (result.ok) {
43
+ return result.json();
44
+ }
45
+ else {
46
+ throw new Error(result.statusText);
47
+ }
48
+ });
49
+
50
+ export { BrowserRequestService };
@@ -0,0 +1,50 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
3
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
4
+ import { AbstractURLService } from '../../../../platform/url/common/urlService.js';
5
+ import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
6
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
7
+ import { matchesScheme } from 'vscode/vscode/vs/base/common/network';
8
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
9
+
10
+ class BrowserURLOpener {
11
+ constructor(urlService, productService) {
12
+ this.urlService = urlService;
13
+ this.productService = productService;
14
+ }
15
+ async open(resource, options) {
16
+ if (options?.openExternal) {
17
+ return false;
18
+ }
19
+ if (!matchesScheme(resource, this.productService.urlProtocol)) {
20
+ return false;
21
+ }
22
+ if (typeof resource === 'string') {
23
+ resource = ( URI.parse(resource));
24
+ }
25
+ return this.urlService.open(resource, { trusted: true });
26
+ }
27
+ }
28
+ let BrowserURLService = class BrowserURLService extends AbstractURLService {
29
+ constructor(environmentService, openerService, productService) {
30
+ super();
31
+ this.provider = environmentService.options?.urlCallbackProvider;
32
+ if (this.provider) {
33
+ this._register(this.provider.onCallback(uri => this.open(uri, { trusted: true })));
34
+ }
35
+ this._register(openerService.registerOpener(( new BrowserURLOpener(this, productService))));
36
+ }
37
+ create(options) {
38
+ if (this.provider) {
39
+ return this.provider.create(options);
40
+ }
41
+ return ( URI.parse('unsupported://'));
42
+ }
43
+ };
44
+ BrowserURLService = ( __decorate([
45
+ ( __param(0, IBrowserWorkbenchEnvironmentService)),
46
+ ( __param(1, IOpenerService)),
47
+ ( __param(2, IProductService))
48
+ ], BrowserURLService));
49
+
50
+ export { BrowserURLService };