@codingame/monaco-vscode-base-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-base-service-override",
3
- "version": "7.1.0",
3
+ "version": "8.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,6 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@7.1.0"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@8.0.0"
30
30
  }
31
31
  }
@@ -2,60 +2,92 @@ import { bufferToStream, VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
2
2
  import { canceled } from 'vscode/vscode/vs/base/common/errors';
3
3
  import { OfflineError } from 'vscode/vscode/vs/base/parts/request/common/request';
4
4
 
5
- function request(options, token) {
6
- if (options.proxyAuthorization) {
7
- options.headers = {
8
- ...(options.headers || {}),
9
- 'Proxy-Authorization': options.proxyAuthorization
10
- };
5
+ async function request(options, token) {
6
+ if (token.isCancellationRequested) {
7
+ throw canceled();
11
8
  }
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());
9
+ const cancellation = ( new AbortController());
10
+ const disposable = token.onCancellationRequested(() => cancellation.abort());
11
+ const signal = options.timeout ? AbortSignal.any([
12
+ cancellation.signal,
13
+ AbortSignal.timeout(options.timeout),
14
+ ]) : cancellation.signal;
15
+ try {
16
+ const res = await fetch(options.url || '', {
17
+ method: options.type || 'GET',
18
+ headers: getRequestHeaders(options),
19
+ body: options.data,
20
+ signal,
35
21
  });
36
- }));
22
+ return {
23
+ res: {
24
+ statusCode: res.status,
25
+ headers: getResponseHeaders(res),
26
+ },
27
+ stream: bufferToStream(VSBuffer.wrap(( new Uint8Array(await res.arrayBuffer())))),
28
+ };
29
+ }
30
+ catch (err) {
31
+ if (!navigator.onLine) {
32
+ throw ( new OfflineError());
33
+ }
34
+ if (err?.name === 'AbortError') {
35
+ throw canceled();
36
+ }
37
+ if (err?.name === 'TimeoutError') {
38
+ throw ( new Error(`Fetch timeout: ${options.timeout}ms`));
39
+ }
40
+ throw err;
41
+ }
42
+ finally {
43
+ disposable.dispose();
44
+ }
37
45
  }
38
- function setRequestHeaders(xhr, options) {
39
- if (options.headers) {
46
+ function getRequestHeaders(options) {
47
+ if (options.headers || options.user || options.password || options.proxyAuthorization) {
48
+ const headers = ( new Headers());
40
49
  outer: for (const k in options.headers) {
41
- switch (k) {
42
- case 'User-Agent':
43
- case 'Accept-Encoding':
44
- case 'Content-Length':
50
+ switch (k.toLowerCase()) {
51
+ case 'user-agent':
52
+ case 'accept-encoding':
53
+ case 'content-length':
45
54
  continue outer;
46
55
  }
47
- xhr.setRequestHeader(k, options.headers[k]);
56
+ const header = options.headers[k];
57
+ if (typeof header === 'string') {
58
+ headers.set(k, header);
59
+ }
60
+ else if (Array.isArray(header)) {
61
+ for (const h of header) {
62
+ headers.append(k, h);
63
+ }
64
+ }
65
+ }
66
+ if (options.user || options.password) {
67
+ headers.set('Authorization', 'Basic ' + btoa(`${options.user || ''}:${options.password || ''}`));
68
+ }
69
+ if (options.proxyAuthorization) {
70
+ headers.set('Proxy-Authorization', options.proxyAuthorization);
48
71
  }
72
+ return headers;
49
73
  }
74
+ return undefined;
50
75
  }
51
- function getResponseHeaders(xhr) {
76
+ function getResponseHeaders(res) {
52
77
  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();
78
+ res.headers.forEach((value, key) => {
79
+ if (headers[key]) {
80
+ if (Array.isArray(headers[key])) {
81
+ headers[key].push(value);
82
+ }
83
+ else {
84
+ headers[key] = [headers[key], value];
85
+ }
57
86
  }
58
- }
87
+ else {
88
+ headers[key] = value;
89
+ }
90
+ });
59
91
  return headers;
60
92
  }
61
93
 
@@ -18,6 +18,12 @@ let RequestService = class RequestService extends AbstractRequestService {
18
18
  async resolveProxy(url) {
19
19
  return undefined;
20
20
  }
21
+ async lookupAuthorization(authInfo) {
22
+ return undefined;
23
+ }
24
+ async lookupKerberosAuthorization(url) {
25
+ return undefined;
26
+ }
21
27
  async loadCertificates() {
22
28
  return [];
23
29
  }
@@ -12,6 +12,12 @@ class RequestChannelClient {
12
12
  async resolveProxy(url) {
13
13
  return this.channel.call('resolveProxy', [url]);
14
14
  }
15
+ async lookupAuthorization(authInfo) {
16
+ return this.channel.call('lookupAuthorization', [authInfo]);
17
+ }
18
+ async lookupKerberosAuthorization(url) {
19
+ return this.channel.call('lookupKerberosAuthorization', [url]);
20
+ }
15
21
  async loadCertificates() {
16
22
  return this.channel.call('loadCertificates');
17
23
  }
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
+ import { localize } from 'vscode/vscode/vs/nls';
3
3
  import { parse } from 'vscode/vscode/vs/base/common/json';
4
4
  import { setProperty } from 'vscode/vscode/vs/base/common/jsonEdit';
5
5
  import { Queue } from 'vscode/vscode/vs/base/common/async';
@@ -13,7 +13,6 @@ import { JSONEditingErrorCode, JSONEditingError } from './jsonEditing.js';
13
13
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
14
14
  import 'vscode/vscode/vs/platform/instantiation/common/extensions';
15
15
 
16
- const _moduleId = "vs/workbench/services/configuration/common/jsonEditingService";
17
16
  let JSONEditingService = class JSONEditingService {
18
17
  constructor(fileService, textModelResolverService, textFileService) {
19
18
  this.fileService = fileService;
@@ -107,9 +106,8 @@ let JSONEditingService = class JSONEditingService {
107
106
  toErrorMessage(error) {
108
107
  switch (error) {
109
108
  case JSONEditingErrorCode.ERROR_INVALID_FILE: {
110
- return ( localizeWithPath(
111
- _moduleId,
112
- 0,
109
+ return ( localize(
110
+ 847,
113
111
  "Unable to write into the file. Please open the file to correct errors/warnings in the file and try again."
114
112
  ));
115
113
  }
@@ -9,7 +9,7 @@ import { createCSSRule, asCSSPropertyValue, removeCSSRulesContainingSelector, cr
9
9
  import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
10
10
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
11
11
  import { isFalsyOrWhitespace } from 'vscode/vscode/vs/base/common/strings';
12
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
12
+ import { localize } from 'vscode/vscode/vs/nls';
13
13
  import { isCancellationError } from 'vscode/vscode/vs/base/common/errors';
14
14
  import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
15
15
  import 'vscode/vscode/vs/platform/instantiation/common/extensions';
@@ -29,7 +29,6 @@ import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
29
29
  import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
30
30
  import { getIconRegistry } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
31
31
 
32
- const _moduleId = "vs/workbench/services/decorations/browser/decorationsService";
33
32
  class DecorationRule {
34
33
  static keyOf(data) {
35
34
  if (Array.isArray(data)) {
@@ -160,7 +159,7 @@ class DecorationStyles {
160
159
  const strikethrough = ( (data.some(d => d.strikethrough)));
161
160
  if (onlyChildren) {
162
161
  badgeClassName = rule.bubbleBadgeClassName;
163
- tooltip = ( localizeWithPath(_moduleId, 0, "Contains emphasized items"));
162
+ tooltip = ( localize(848, "Contains emphasized items"));
164
163
  }
165
164
  return {
166
165
  labelClassName,
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
+ import { localize } from 'vscode/vscode/vs/nls';
3
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
4
4
  import { dispose, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
5
  import { sep, posix, win32 } from 'vscode/vscode/vs/base/common/path';
@@ -28,11 +28,10 @@ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storag
28
28
  import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
29
29
  import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
30
30
 
31
- const _moduleId = "vs/workbench/services/label/common/labelService";
32
31
  const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoint({
33
32
  extensionPoint: 'resourceLabelFormatters',
34
33
  jsonSchema: {
35
- description: ( localizeWithPath(_moduleId, 0, 'Contributes resource label formatting rules.')),
34
+ description: ( localize(849, 'Contributes resource label formatting rules.')),
36
35
  type: 'array',
37
36
  items: {
38
37
  type: 'object',
@@ -40,59 +39,53 @@ const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoin
40
39
  properties: {
41
40
  scheme: {
42
41
  type: 'string',
43
- description: ( localizeWithPath(
44
- _moduleId,
45
- 1,
42
+ description: ( localize(
43
+ 850,
46
44
  'URI scheme on which to match the formatter on. For example "file". Simple glob patterns are supported.'
47
45
  )),
48
46
  },
49
47
  authority: {
50
48
  type: 'string',
51
- description: ( localizeWithPath(
52
- _moduleId,
53
- 2,
49
+ description: ( localize(
50
+ 851,
54
51
  'URI authority on which to match the formatter on. Simple glob patterns are supported.'
55
52
  )),
56
53
  },
57
54
  formatting: {
58
- description: ( localizeWithPath(_moduleId, 3, "Rules for formatting uri resource labels.")),
55
+ description: ( localize(852, "Rules for formatting uri resource labels.")),
59
56
  type: 'object',
60
57
  properties: {
61
58
  label: {
62
59
  type: 'string',
63
- description: ( localizeWithPath(
64
- _moduleId,
65
- 4,
60
+ description: ( localize(
61
+ 853,
66
62
  "Label rules to display. For example: myLabel:/${path}. ${path}, ${scheme}, ${authority} and ${authoritySuffix} are supported as variables."
67
63
  ))
68
64
  },
69
65
  separator: {
70
66
  type: 'string',
71
- description: ( localizeWithPath(
72
- _moduleId,
73
- 5,
67
+ description: ( localize(
68
+ 854,
74
69
  "Separator to be used in the uri label display. '/' or '\' as an example."
75
70
  ))
76
71
  },
77
72
  stripPathStartingSeparator: {
78
73
  type: 'boolean',
79
- description: ( localizeWithPath(
80
- _moduleId,
81
- 6,
74
+ description: ( localize(
75
+ 855,
82
76
  "Controls whether `${path}` substitutions should have starting separator characters stripped."
83
77
  ))
84
78
  },
85
79
  tildify: {
86
80
  type: 'boolean',
87
- description: ( localizeWithPath(
88
- _moduleId,
89
- 7,
81
+ description: ( localize(
82
+ 856,
90
83
  "Controls if the start of the uri label should be tildified when possible."
91
84
  ))
92
85
  },
93
86
  workspaceSuffix: {
94
87
  type: 'string',
95
- description: ( localizeWithPath(_moduleId, 8, "Suffix appended to the workspace label."))
88
+ description: ( localize(857, "Suffix appended to the workspace label."))
96
89
  }
97
90
  }
98
91
  }
@@ -271,10 +264,10 @@ let LabelService = class LabelService extends Disposable {
271
264
  }
272
265
  doGetWorkspaceLabel(workspaceUri, options) {
273
266
  if (isUntitledWorkspace(workspaceUri, this.environmentService)) {
274
- return ( localizeWithPath(_moduleId, 9, "Untitled (Workspace)"));
267
+ return ( localize(858, "Untitled (Workspace)"));
275
268
  }
276
269
  if (isTemporaryWorkspace(workspaceUri)) {
277
- return ( localizeWithPath(_moduleId, 10, "Workspace"));
270
+ return ( localize(859, "Workspace"));
278
271
  }
279
272
  let filename = basename(workspaceUri);
280
273
  if (filename.endsWith(WORKSPACE_EXTENSION)) {
@@ -286,16 +279,15 @@ let LabelService = class LabelService extends Disposable {
286
279
  label = filename;
287
280
  break;
288
281
  case Verbosity.LONG:
289
- label = ( localizeWithPath(
290
- _moduleId,
291
- 11,
282
+ label = ( localize(
283
+ 860,
292
284
  "{0} (Workspace)",
293
285
  this.getUriLabel(joinPath(dirname(workspaceUri), filename))
294
286
  ));
295
287
  break;
296
288
  case Verbosity.MEDIUM:
297
289
  default:
298
- label = ( localizeWithPath(_moduleId, 12, "{0} (Workspace)", filename));
290
+ label = ( localize(861, "{0} (Workspace)", filename));
299
291
  break;
300
292
  }
301
293
  if (options?.verbose === Verbosity.SHORT) {