@codingame/monaco-vscode-api 1.67.19 → 1.67.20
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/dist/api.js +3 -3
- package/dist/{async-c36a786b.js → async-088c7d8b.js} +1 -1
- package/dist/configuration.js +14 -928
- package/dist/messages.js +8 -7
- package/dist/missing-services-9c48c894.js +3177 -0
- package/dist/modelEditor.js +6 -5
- package/dist/{services-9299c4ca.js → services-a8445f52.js} +20 -1
- package/dist/services.js +1 -1
- package/package.json +1 -1
- package/dist/missing-services-c84f89c2.js +0 -1299
|
@@ -0,0 +1,3177 @@
|
|
|
1
|
+
import { VSBuffer as VSBuffer$1 } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
2
|
+
import { toDisposable, DisposableStore, Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
4
|
+
import { Themable as Themable$1 } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
5
|
+
import { ProgressBar as ProgressBar$1 } from 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
|
|
6
|
+
import { mixin, equals, deepClone, deepFreeze } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
7
|
+
import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
8
|
+
import { show, hide, trackFocus } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
9
|
+
import { isNumber, isObject, isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
10
|
+
import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
|
|
11
|
+
import { LanguageService as LanguageService$1 } from 'monaco-editor/esm/vs/editor/common/services/languageService.js';
|
|
12
|
+
import { LanguagesRegistry } from 'monaco-editor/esm/vs/editor/common/services/languagesRegistry.js';
|
|
13
|
+
import { firstOrDefault, distinct, flatten, equals as equals$1 } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
14
|
+
import { PLAINTEXT_LANGUAGE_ID } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
15
|
+
import { TokenizationRegistry } from 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
16
|
+
import { NoOpNotification } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
17
|
+
import { v as shuffle, N as NoOpNotification$1, k as IEditorService, n as IPaneCompositePartService, g as IUriIdentityService, b as ITextFileService, e as IFileService, l as IEditorGroupsService, f as IWorkbenchEnvironmentService, h as IWorkingCopyFileService, i as IPathService, I as IProgressService, s as Services, o as IProductService, p as ILanguageStatusService, q as IHostService } from './services-a8445f52.js';
|
|
18
|
+
import { ResourceMap, TernarySearchTree as TernarySearchTree$1 } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
19
|
+
import { compareSubstring, compareSubstringIgnoreCase, compareIgnoreCase, compare as compare$1 } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
20
|
+
import { Configuration as Configuration$1 } from 'monaco-editor/esm/vs/platform/configuration/common/configurationModels.js';
|
|
21
|
+
import { overrideIdentifiersFromKey, OVERRIDE_PROPERTY_REGEX, Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
22
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
23
|
+
import { getConfigurationValue, addToValueTree, removeFromValueTree, toValuesTree } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
24
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
25
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
26
|
+
import { StandaloneConfigurationService } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
27
|
+
import { QuickInputController } from 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInput.js';
|
|
28
|
+
import { getSingletonServiceDescriptors, registerSingleton } from 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
|
|
29
|
+
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
30
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
31
|
+
import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
32
|
+
import { ExtUri } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
33
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
34
|
+
import { LanguageFeatureRegistry } from 'monaco-editor/esm/vs/editor/common/languageFeatureRegistry.js';
|
|
35
|
+
import { DomEmitter } from 'monaco-editor/esm/vs/base/browser/event.js';
|
|
36
|
+
function isReadableStream(obj) {
|
|
37
|
+
const candidate = obj;
|
|
38
|
+
if (!candidate) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return [candidate.on, candidate.pause, candidate.resume, candidate.destroy].every(fn => typeof fn === 'function');
|
|
42
|
+
}
|
|
43
|
+
function isReadableBufferedStream(obj) {
|
|
44
|
+
const candidate = obj;
|
|
45
|
+
if (!candidate) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return isReadableStream(candidate.stream) && Array.isArray(candidate.buffer) && typeof candidate.ended === 'boolean';
|
|
49
|
+
}
|
|
50
|
+
function newWriteableStream(reducer, options) {
|
|
51
|
+
return (
|
|
52
|
+
new WriteableStreamImpl(reducer, options)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
class WriteableStreamImpl {
|
|
56
|
+
constructor(reducer, options) {
|
|
57
|
+
this.reducer = reducer;
|
|
58
|
+
this.options = options;
|
|
59
|
+
this.state = {
|
|
60
|
+
flowing: false,
|
|
61
|
+
ended: false,
|
|
62
|
+
destroyed: false
|
|
63
|
+
};
|
|
64
|
+
this.buffer = {
|
|
65
|
+
data: [],
|
|
66
|
+
error: []
|
|
67
|
+
};
|
|
68
|
+
this.listeners = {
|
|
69
|
+
data: [],
|
|
70
|
+
error: [],
|
|
71
|
+
end: []
|
|
72
|
+
};
|
|
73
|
+
this.pendingWritePromises = [];
|
|
74
|
+
}
|
|
75
|
+
pause() {
|
|
76
|
+
if (this.state.destroyed) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.state.flowing = false;
|
|
80
|
+
}
|
|
81
|
+
resume() {
|
|
82
|
+
if (this.state.destroyed) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!this.state.flowing) {
|
|
86
|
+
this.state.flowing = true;
|
|
87
|
+
this.flowData();
|
|
88
|
+
this.flowErrors();
|
|
89
|
+
this.flowEnd();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
write(data) {
|
|
93
|
+
if (this.state.destroyed) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (this.state.flowing) {
|
|
97
|
+
this.emitData(data);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.buffer.data.push(data);
|
|
101
|
+
if (typeof this.options?.highWaterMark === 'number' && this.buffer.data.length > this.options.highWaterMark) {
|
|
102
|
+
return (
|
|
103
|
+
new Promise(resolve => this.pendingWritePromises.push(resolve))
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
error(error) {
|
|
109
|
+
if (this.state.destroyed) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.state.flowing) {
|
|
113
|
+
this.emitError(error);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.buffer.error.push(error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
end(result) {
|
|
120
|
+
if (this.state.destroyed) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (typeof result !== 'undefined') {
|
|
124
|
+
this.write(result);
|
|
125
|
+
}
|
|
126
|
+
if (this.state.flowing) {
|
|
127
|
+
this.emitEnd();
|
|
128
|
+
this.destroy();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.state.ended = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
emitData(data) {
|
|
135
|
+
this.listeners.data.slice(0).forEach(listener => listener(data));
|
|
136
|
+
}
|
|
137
|
+
emitError(error) {
|
|
138
|
+
if (this.listeners.error.length === 0) {
|
|
139
|
+
onUnexpectedError(error);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.listeners.error.slice(0).forEach(listener => listener(error));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
emitEnd() {
|
|
146
|
+
this.listeners.end.slice(0).forEach(listener => listener());
|
|
147
|
+
}
|
|
148
|
+
on(event, callback) {
|
|
149
|
+
if (this.state.destroyed) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
switch (event) {
|
|
153
|
+
case 'data':
|
|
154
|
+
this.listeners.data.push(callback);
|
|
155
|
+
this.resume();
|
|
156
|
+
break;
|
|
157
|
+
case 'end':
|
|
158
|
+
this.listeners.end.push(callback);
|
|
159
|
+
if (this.state.flowing && this.flowEnd()) {
|
|
160
|
+
this.destroy();
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 'error':
|
|
164
|
+
this.listeners.error.push(callback);
|
|
165
|
+
if (this.state.flowing) {
|
|
166
|
+
this.flowErrors();
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
removeListener(event, callback) {
|
|
172
|
+
if (this.state.destroyed) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
let listeners = undefined;
|
|
176
|
+
switch (event) {
|
|
177
|
+
case 'data':
|
|
178
|
+
listeners = this.listeners.data;
|
|
179
|
+
break;
|
|
180
|
+
case 'end':
|
|
181
|
+
listeners = this.listeners.end;
|
|
182
|
+
break;
|
|
183
|
+
case 'error':
|
|
184
|
+
listeners = this.listeners.error;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
if (listeners) {
|
|
188
|
+
const index = listeners.indexOf(callback);
|
|
189
|
+
if (index >= 0) {
|
|
190
|
+
listeners.splice(index, 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
flowData() {
|
|
195
|
+
if (this.buffer.data.length > 0) {
|
|
196
|
+
const fullDataBuffer = this.reducer(this.buffer.data);
|
|
197
|
+
this.emitData(fullDataBuffer);
|
|
198
|
+
this.buffer.data.length = 0;
|
|
199
|
+
const pendingWritePromises = [...this.pendingWritePromises];
|
|
200
|
+
this.pendingWritePromises.length = 0;
|
|
201
|
+
pendingWritePromises.forEach(pendingWritePromise => pendingWritePromise());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
flowErrors() {
|
|
205
|
+
if (this.listeners.error.length > 0) {
|
|
206
|
+
for (const error of this.buffer.error) {
|
|
207
|
+
this.emitError(error);
|
|
208
|
+
}
|
|
209
|
+
this.buffer.error.length = 0;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
flowEnd() {
|
|
213
|
+
if (this.state.ended) {
|
|
214
|
+
this.emitEnd();
|
|
215
|
+
return this.listeners.end.length > 0;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
destroy() {
|
|
220
|
+
if (!this.state.destroyed) {
|
|
221
|
+
this.state.destroyed = true;
|
|
222
|
+
this.state.ended = true;
|
|
223
|
+
this.buffer.data.length = 0;
|
|
224
|
+
this.buffer.error.length = 0;
|
|
225
|
+
this.listeners.data.length = 0;
|
|
226
|
+
this.listeners.error.length = 0;
|
|
227
|
+
this.listeners.end.length = 0;
|
|
228
|
+
this.pendingWritePromises.length = 0;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function consumeReadable(readable, reducer) {
|
|
233
|
+
const chunks = [];
|
|
234
|
+
let chunk;
|
|
235
|
+
while ((chunk = readable.read()) !== null) {
|
|
236
|
+
chunks.push(chunk);
|
|
237
|
+
}
|
|
238
|
+
return reducer(chunks);
|
|
239
|
+
}
|
|
240
|
+
function peekReadable(readable, reducer, maxChunks) {
|
|
241
|
+
const chunks = [];
|
|
242
|
+
let chunk = undefined;
|
|
243
|
+
while ((chunk = readable.read()) !== null && chunks.length < maxChunks) {
|
|
244
|
+
chunks.push(chunk);
|
|
245
|
+
}
|
|
246
|
+
if (chunk === null && chunks.length > 0) {
|
|
247
|
+
return reducer(chunks);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
read: () => {
|
|
251
|
+
if (chunks.length > 0) {
|
|
252
|
+
return chunks.shift();
|
|
253
|
+
}
|
|
254
|
+
if (typeof chunk !== 'undefined') {
|
|
255
|
+
const lastReadChunk = chunk;
|
|
256
|
+
chunk = undefined;
|
|
257
|
+
return lastReadChunk;
|
|
258
|
+
}
|
|
259
|
+
return readable.read();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function consumeStream(stream, reducer) {
|
|
264
|
+
return (
|
|
265
|
+
new Promise((resolve, reject) => {
|
|
266
|
+
const chunks = [];
|
|
267
|
+
listenStream(stream, {
|
|
268
|
+
onData: chunk => {
|
|
269
|
+
if (reducer) {
|
|
270
|
+
chunks.push(chunk);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
onError: error => {
|
|
274
|
+
if (reducer) {
|
|
275
|
+
reject(error);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
resolve(undefined);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
onEnd: () => {
|
|
282
|
+
if (reducer) {
|
|
283
|
+
resolve(reducer(chunks));
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
resolve(undefined);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
})
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
function listenStream(stream, listener) {
|
|
294
|
+
let destroyed = false;
|
|
295
|
+
stream.on('error', error => {
|
|
296
|
+
if (!destroyed) {
|
|
297
|
+
listener.onError(error);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
stream.on('end', () => {
|
|
301
|
+
if (!destroyed) {
|
|
302
|
+
listener.onEnd();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
stream.on('data', data => {
|
|
306
|
+
if (!destroyed) {
|
|
307
|
+
listener.onData(data);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
return toDisposable(() => destroyed = true);
|
|
311
|
+
}
|
|
312
|
+
function peekStream(stream, maxChunks) {
|
|
313
|
+
return (
|
|
314
|
+
new Promise((resolve, reject) => {
|
|
315
|
+
const streamListeners = new DisposableStore();
|
|
316
|
+
const buffer = [];
|
|
317
|
+
const dataListener = (chunk) => {
|
|
318
|
+
buffer.push(chunk);
|
|
319
|
+
if (buffer.length > maxChunks) {
|
|
320
|
+
streamListeners.dispose();
|
|
321
|
+
stream.pause();
|
|
322
|
+
return resolve({ stream, buffer, ended: false });
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const errorListener = (error) => {
|
|
326
|
+
return reject(error);
|
|
327
|
+
};
|
|
328
|
+
const endListener = () => {
|
|
329
|
+
return resolve({ stream, buffer, ended: true });
|
|
330
|
+
};
|
|
331
|
+
streamListeners.add(toDisposable(() => stream.removeListener('error', errorListener)));
|
|
332
|
+
stream.on('error', errorListener);
|
|
333
|
+
streamListeners.add(toDisposable(() => stream.removeListener('end', endListener)));
|
|
334
|
+
stream.on('end', endListener);
|
|
335
|
+
streamListeners.add(toDisposable(() => stream.removeListener('data', dataListener)));
|
|
336
|
+
stream.on('data', dataListener);
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
function toReadable(t) {
|
|
341
|
+
let consumed = false;
|
|
342
|
+
return {
|
|
343
|
+
read: () => {
|
|
344
|
+
if (consumed) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
consumed = true;
|
|
348
|
+
return t;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function transform(stream, transformer, reducer) {
|
|
353
|
+
const target = newWriteableStream(reducer);
|
|
354
|
+
listenStream(stream, {
|
|
355
|
+
onData: data => target.write(transformer.data(data)),
|
|
356
|
+
onError: error => target.error(transformer.error ? transformer.error(error) : error),
|
|
357
|
+
onEnd: () => target.end()
|
|
358
|
+
});
|
|
359
|
+
return target;
|
|
360
|
+
}
|
|
361
|
+
const hasBuffer = (typeof Buffer !== 'undefined');
|
|
362
|
+
let textEncoder;
|
|
363
|
+
let textDecoder;
|
|
364
|
+
class VSBuffer {
|
|
365
|
+
constructor(buffer) {
|
|
366
|
+
this.buffer = buffer;
|
|
367
|
+
this.byteLength = this.buffer.byteLength;
|
|
368
|
+
}
|
|
369
|
+
static alloc(byteLength) {
|
|
370
|
+
if (hasBuffer) {
|
|
371
|
+
return (
|
|
372
|
+
new VSBuffer(Buffer.allocUnsafe(byteLength))
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return (
|
|
377
|
+
new VSBuffer( new Uint8Array(byteLength))
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
static wrap(actual) {
|
|
382
|
+
if (hasBuffer && !(Buffer.isBuffer(actual))) {
|
|
383
|
+
actual = Buffer.from(actual.buffer, actual.byteOffset, actual.byteLength);
|
|
384
|
+
}
|
|
385
|
+
return (
|
|
386
|
+
new VSBuffer(actual)
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
static fromString(source, options) {
|
|
390
|
+
const dontUseNodeBuffer = options?.dontUseNodeBuffer || false;
|
|
391
|
+
if (!dontUseNodeBuffer && hasBuffer) {
|
|
392
|
+
return (
|
|
393
|
+
new VSBuffer(Buffer.from(source))
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
if (!textEncoder) {
|
|
398
|
+
textEncoder = new TextEncoder();
|
|
399
|
+
}
|
|
400
|
+
return (
|
|
401
|
+
new VSBuffer(textEncoder.encode(source))
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
static fromByteArray(source) {
|
|
406
|
+
const result = VSBuffer.alloc(source.length);
|
|
407
|
+
for (let i = 0, len = source.length; i < len; i++) {
|
|
408
|
+
result.buffer[i] = source[i];
|
|
409
|
+
}
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
412
|
+
static concat(buffers, totalLength) {
|
|
413
|
+
if (typeof totalLength === 'undefined') {
|
|
414
|
+
totalLength = 0;
|
|
415
|
+
for (let i = 0, len = buffers.length; i < len; i++) {
|
|
416
|
+
totalLength += buffers[i].byteLength;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const ret = VSBuffer.alloc(totalLength);
|
|
420
|
+
let offset = 0;
|
|
421
|
+
for (let i = 0, len = buffers.length; i < len; i++) {
|
|
422
|
+
const element = buffers[i];
|
|
423
|
+
ret.set(element, offset);
|
|
424
|
+
offset += element.byteLength;
|
|
425
|
+
}
|
|
426
|
+
return ret;
|
|
427
|
+
}
|
|
428
|
+
clone() {
|
|
429
|
+
const result = VSBuffer.alloc(this.byteLength);
|
|
430
|
+
result.set(this);
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
toString() {
|
|
434
|
+
if (hasBuffer) {
|
|
435
|
+
return this.buffer.toString();
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
if (!textDecoder) {
|
|
439
|
+
textDecoder = new TextDecoder();
|
|
440
|
+
}
|
|
441
|
+
return textDecoder.decode(this.buffer);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
slice(start, end) {
|
|
445
|
+
return (
|
|
446
|
+
new VSBuffer(this.buffer.subarray(start, end))
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
set(array, offset) {
|
|
450
|
+
if (array instanceof VSBuffer) {
|
|
451
|
+
this.buffer.set(array.buffer, offset);
|
|
452
|
+
}
|
|
453
|
+
else if (array instanceof Uint8Array) {
|
|
454
|
+
this.buffer.set(array, offset);
|
|
455
|
+
}
|
|
456
|
+
else if (array instanceof ArrayBuffer) {
|
|
457
|
+
this.buffer.set( new Uint8Array(array), offset);
|
|
458
|
+
}
|
|
459
|
+
else if (ArrayBuffer.isView(array)) {
|
|
460
|
+
this.buffer.set( new Uint8Array(array.buffer, array.byteOffset, array.byteLength), offset);
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
throw new Error(`Unknown argument 'array'`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
readUInt32BE(offset) {
|
|
467
|
+
return readUInt32BE(this.buffer, offset);
|
|
468
|
+
}
|
|
469
|
+
writeUInt32BE(value, offset) {
|
|
470
|
+
writeUInt32BE(this.buffer, value, offset);
|
|
471
|
+
}
|
|
472
|
+
readUInt32LE(offset) {
|
|
473
|
+
return readUInt32LE(this.buffer, offset);
|
|
474
|
+
}
|
|
475
|
+
writeUInt32LE(value, offset) {
|
|
476
|
+
writeUInt32LE(this.buffer, value, offset);
|
|
477
|
+
}
|
|
478
|
+
readUInt8(offset) {
|
|
479
|
+
return readUInt8(this.buffer, offset);
|
|
480
|
+
}
|
|
481
|
+
writeUInt8(value, offset) {
|
|
482
|
+
writeUInt8(this.buffer, value, offset);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function readUInt32BE(source, offset) {
|
|
486
|
+
return (source[offset] * 2 ** 24
|
|
487
|
+
+ source[offset + 1] * 2 ** 16
|
|
488
|
+
+ source[offset + 2] * 2 ** 8
|
|
489
|
+
+ source[offset + 3]);
|
|
490
|
+
}
|
|
491
|
+
function writeUInt32BE(destination, value, offset) {
|
|
492
|
+
destination[offset + 3] = value;
|
|
493
|
+
value = value >>> 8;
|
|
494
|
+
destination[offset + 2] = value;
|
|
495
|
+
value = value >>> 8;
|
|
496
|
+
destination[offset + 1] = value;
|
|
497
|
+
value = value >>> 8;
|
|
498
|
+
destination[offset] = value;
|
|
499
|
+
}
|
|
500
|
+
function readUInt32LE(source, offset) {
|
|
501
|
+
return (((source[offset + 0] << 0) >>> 0) |
|
|
502
|
+
((source[offset + 1] << 8) >>> 0) |
|
|
503
|
+
((source[offset + 2] << 16) >>> 0) |
|
|
504
|
+
((source[offset + 3] << 24) >>> 0));
|
|
505
|
+
}
|
|
506
|
+
function writeUInt32LE(destination, value, offset) {
|
|
507
|
+
destination[offset + 0] = (value & 0b11111111);
|
|
508
|
+
value = value >>> 8;
|
|
509
|
+
destination[offset + 1] = (value & 0b11111111);
|
|
510
|
+
value = value >>> 8;
|
|
511
|
+
destination[offset + 2] = (value & 0b11111111);
|
|
512
|
+
value = value >>> 8;
|
|
513
|
+
destination[offset + 3] = (value & 0b11111111);
|
|
514
|
+
}
|
|
515
|
+
function readUInt8(source, offset) {
|
|
516
|
+
return source[offset];
|
|
517
|
+
}
|
|
518
|
+
function writeUInt8(destination, value, offset) {
|
|
519
|
+
destination[offset] = value;
|
|
520
|
+
}
|
|
521
|
+
function readableToBuffer(readable) {
|
|
522
|
+
return consumeReadable(readable, chunks => VSBuffer.concat(chunks));
|
|
523
|
+
}
|
|
524
|
+
function bufferToReadable(buffer) {
|
|
525
|
+
return toReadable(buffer);
|
|
526
|
+
}
|
|
527
|
+
function streamToBuffer(stream) {
|
|
528
|
+
return consumeStream(stream, chunks => VSBuffer.concat(chunks));
|
|
529
|
+
}
|
|
530
|
+
async function bufferedStreamToBuffer(bufferedStream) {
|
|
531
|
+
if (bufferedStream.ended) {
|
|
532
|
+
return VSBuffer.concat(bufferedStream.buffer);
|
|
533
|
+
}
|
|
534
|
+
return VSBuffer.concat([
|
|
535
|
+
...bufferedStream.buffer,
|
|
536
|
+
await streamToBuffer(bufferedStream.stream)
|
|
537
|
+
]);
|
|
538
|
+
}
|
|
539
|
+
function newWriteableBufferStream(options) {
|
|
540
|
+
return newWriteableStream(chunks => VSBuffer.concat(chunks), options);
|
|
541
|
+
}
|
|
542
|
+
const Emitter = monaco.Emitter;
|
|
543
|
+
class Themable extends Disposable {
|
|
544
|
+
constructor(themeService) {
|
|
545
|
+
super();
|
|
546
|
+
this.themeService = themeService;
|
|
547
|
+
this.theme = themeService.getColorTheme();
|
|
548
|
+
this._register(this.themeService.onDidColorThemeChange(theme => this.onThemeChange(theme)));
|
|
549
|
+
}
|
|
550
|
+
onThemeChange(theme) {
|
|
551
|
+
this.theme = theme;
|
|
552
|
+
this.updateStyles();
|
|
553
|
+
}
|
|
554
|
+
updateStyles() {
|
|
555
|
+
}
|
|
556
|
+
getColor(id, modify) {
|
|
557
|
+
let color = this.theme.getColor(id);
|
|
558
|
+
if (color && modify) {
|
|
559
|
+
color = modify(color, this.theme);
|
|
560
|
+
}
|
|
561
|
+
return color ? color.toString() : null;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const CSS_DONE = 'done';
|
|
565
|
+
const CSS_ACTIVE = 'active';
|
|
566
|
+
const CSS_INFINITE = 'infinite';
|
|
567
|
+
const CSS_INFINITE_LONG_RUNNING = 'infinite-long-running';
|
|
568
|
+
const CSS_DISCRETE = 'discrete';
|
|
569
|
+
const defaultOpts = {
|
|
570
|
+
progressBarBackground: Color.fromHex('#0E70C0')
|
|
571
|
+
};
|
|
572
|
+
class ProgressBar extends Disposable {
|
|
573
|
+
constructor(container, options) {
|
|
574
|
+
super();
|
|
575
|
+
this.options = options || Object.create(null);
|
|
576
|
+
mixin(this.options, defaultOpts, false);
|
|
577
|
+
this.workedVal = 0;
|
|
578
|
+
this.progressBarBackground = this.options.progressBarBackground;
|
|
579
|
+
this.showDelayedScheduler = this._register( new RunOnceScheduler(() => show(this.element), 0));
|
|
580
|
+
this.longRunningScheduler = this._register( new RunOnceScheduler(
|
|
581
|
+
() => this.infiniteLongRunning(),
|
|
582
|
+
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD
|
|
583
|
+
));
|
|
584
|
+
this.create(container);
|
|
585
|
+
}
|
|
586
|
+
create(container) {
|
|
587
|
+
this.element = document.createElement('div');
|
|
588
|
+
this.element.classList.add('monaco-progress-container');
|
|
589
|
+
this.element.setAttribute('role', 'progressbar');
|
|
590
|
+
this.element.setAttribute('aria-valuemin', '0');
|
|
591
|
+
container.appendChild(this.element);
|
|
592
|
+
this.bit = document.createElement('div');
|
|
593
|
+
this.bit.classList.add('progress-bit');
|
|
594
|
+
this.element.appendChild(this.bit);
|
|
595
|
+
this.applyStyles();
|
|
596
|
+
}
|
|
597
|
+
off() {
|
|
598
|
+
this.bit.style.width = 'inherit';
|
|
599
|
+
this.bit.style.opacity = '1';
|
|
600
|
+
this.element.classList.remove(CSS_ACTIVE, CSS_INFINITE, CSS_INFINITE_LONG_RUNNING, CSS_DISCRETE);
|
|
601
|
+
this.workedVal = 0;
|
|
602
|
+
this.totalWork = undefined;
|
|
603
|
+
this.longRunningScheduler.cancel();
|
|
604
|
+
}
|
|
605
|
+
done() {
|
|
606
|
+
return this.doDone(true);
|
|
607
|
+
}
|
|
608
|
+
stop() {
|
|
609
|
+
return this.doDone(false);
|
|
610
|
+
}
|
|
611
|
+
doDone(delayed) {
|
|
612
|
+
this.element.classList.add(CSS_DONE);
|
|
613
|
+
if (!this.element.classList.contains(CSS_INFINITE)) {
|
|
614
|
+
this.bit.style.width = 'inherit';
|
|
615
|
+
if (delayed) {
|
|
616
|
+
setTimeout(() => this.off(), 200);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
this.off();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
this.bit.style.opacity = '0';
|
|
624
|
+
if (delayed) {
|
|
625
|
+
setTimeout(() => this.off(), 200);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
this.off();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
infinite() {
|
|
634
|
+
this.bit.style.width = '2%';
|
|
635
|
+
this.bit.style.opacity = '1';
|
|
636
|
+
this.element.classList.remove(CSS_DISCRETE, CSS_DONE, CSS_INFINITE_LONG_RUNNING);
|
|
637
|
+
this.element.classList.add(CSS_ACTIVE, CSS_INFINITE);
|
|
638
|
+
this.longRunningScheduler.schedule();
|
|
639
|
+
return this;
|
|
640
|
+
}
|
|
641
|
+
infiniteLongRunning() {
|
|
642
|
+
this.element.classList.add(CSS_INFINITE_LONG_RUNNING);
|
|
643
|
+
}
|
|
644
|
+
total(value) {
|
|
645
|
+
this.workedVal = 0;
|
|
646
|
+
this.totalWork = value;
|
|
647
|
+
this.element.setAttribute('aria-valuemax', value.toString());
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
hasTotal() {
|
|
651
|
+
return isNumber(this.totalWork);
|
|
652
|
+
}
|
|
653
|
+
worked(value) {
|
|
654
|
+
value = Math.max(1, Number(value));
|
|
655
|
+
return this.doSetWorked(this.workedVal + value);
|
|
656
|
+
}
|
|
657
|
+
setWorked(value) {
|
|
658
|
+
value = Math.max(1, Number(value));
|
|
659
|
+
return this.doSetWorked(value);
|
|
660
|
+
}
|
|
661
|
+
doSetWorked(value) {
|
|
662
|
+
const totalWork = this.totalWork || 100;
|
|
663
|
+
this.workedVal = value;
|
|
664
|
+
this.workedVal = Math.min(totalWork, this.workedVal);
|
|
665
|
+
this.element.classList.remove(CSS_INFINITE, CSS_INFINITE_LONG_RUNNING, CSS_DONE);
|
|
666
|
+
this.element.classList.add(CSS_ACTIVE, CSS_DISCRETE);
|
|
667
|
+
this.element.setAttribute('aria-valuenow', value.toString());
|
|
668
|
+
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
|
|
669
|
+
return this;
|
|
670
|
+
}
|
|
671
|
+
getContainer() {
|
|
672
|
+
return this.element;
|
|
673
|
+
}
|
|
674
|
+
show(delay) {
|
|
675
|
+
this.showDelayedScheduler.cancel();
|
|
676
|
+
if (typeof delay === 'number') {
|
|
677
|
+
this.showDelayedScheduler.schedule(delay);
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
show(this.element);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
hide() {
|
|
684
|
+
hide(this.element);
|
|
685
|
+
this.showDelayedScheduler.cancel();
|
|
686
|
+
}
|
|
687
|
+
style(styles) {
|
|
688
|
+
this.progressBarBackground = styles.progressBarBackground;
|
|
689
|
+
this.applyStyles();
|
|
690
|
+
}
|
|
691
|
+
applyStyles() {
|
|
692
|
+
if (this.bit) {
|
|
693
|
+
const background = this.progressBarBackground ? this.progressBarBackground.toString() : '';
|
|
694
|
+
this.bit.style.backgroundColor = background;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD = 10000;
|
|
699
|
+
class LanguageService extends Disposable {
|
|
700
|
+
constructor(warnOnOverwrite = false) {
|
|
701
|
+
super();
|
|
702
|
+
this._onDidEncounterLanguage = this._register( new Emitter());
|
|
703
|
+
this.onDidEncounterLanguage = this._onDidEncounterLanguage.event;
|
|
704
|
+
this._onDidChange = this._register( new Emitter(
|
|
705
|
+
{ leakWarningThreshold: 200 }
|
|
706
|
+
));
|
|
707
|
+
this.onDidChange = this._onDidChange.event;
|
|
708
|
+
LanguageService.instanceCount++;
|
|
709
|
+
this._encounteredLanguages = new Set();
|
|
710
|
+
this._registry = this._register( new LanguagesRegistry(true, warnOnOverwrite));
|
|
711
|
+
this.languageIdCodec = this._registry.languageIdCodec;
|
|
712
|
+
this._register(this._registry.onDidChange(() => this._onDidChange.fire()));
|
|
713
|
+
}
|
|
714
|
+
dispose() {
|
|
715
|
+
LanguageService.instanceCount--;
|
|
716
|
+
super.dispose();
|
|
717
|
+
}
|
|
718
|
+
isRegisteredLanguageId(languageId) {
|
|
719
|
+
return this._registry.isRegisteredLanguageId(languageId);
|
|
720
|
+
}
|
|
721
|
+
getRegisteredLanguageIds() {
|
|
722
|
+
return this._registry.getRegisteredLanguageIds();
|
|
723
|
+
}
|
|
724
|
+
getSortedRegisteredLanguageNames() {
|
|
725
|
+
return this._registry.getSortedRegisteredLanguageNames();
|
|
726
|
+
}
|
|
727
|
+
getLanguageName(languageId) {
|
|
728
|
+
return this._registry.getLanguageName(languageId);
|
|
729
|
+
}
|
|
730
|
+
getMimeType(languageId) {
|
|
731
|
+
return this._registry.getMimeType(languageId);
|
|
732
|
+
}
|
|
733
|
+
getIcon(languageId) {
|
|
734
|
+
return this._registry.getIcon(languageId);
|
|
735
|
+
}
|
|
736
|
+
getExtensions(languageId) {
|
|
737
|
+
return this._registry.getExtensions(languageId);
|
|
738
|
+
}
|
|
739
|
+
getFilenames(languageId) {
|
|
740
|
+
return this._registry.getFilenames(languageId);
|
|
741
|
+
}
|
|
742
|
+
getConfigurationFiles(languageId) {
|
|
743
|
+
return this._registry.getConfigurationFiles(languageId);
|
|
744
|
+
}
|
|
745
|
+
getLanguageIdByLanguageName(languageName) {
|
|
746
|
+
return this._registry.getLanguageIdByLanguageName(languageName);
|
|
747
|
+
}
|
|
748
|
+
getLanguageIdByMimeType(mimeType) {
|
|
749
|
+
return this._registry.getLanguageIdByMimeType(mimeType);
|
|
750
|
+
}
|
|
751
|
+
guessLanguageIdByFilepathOrFirstLine(resource, firstLine) {
|
|
752
|
+
const languageIds = this._registry.guessLanguageIdByFilepathOrFirstLine(resource, firstLine);
|
|
753
|
+
return firstOrDefault(languageIds, null);
|
|
754
|
+
}
|
|
755
|
+
createById(languageId) {
|
|
756
|
+
return (
|
|
757
|
+
new LanguageSelection(this.onDidChange, () => {
|
|
758
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
759
|
+
})
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
createByMimeType(mimeType) {
|
|
763
|
+
return (
|
|
764
|
+
new LanguageSelection(this.onDidChange, () => {
|
|
765
|
+
const languageId = this.getLanguageIdByMimeType(mimeType);
|
|
766
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
767
|
+
})
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
createByFilepathOrFirstLine(resource, firstLine) {
|
|
771
|
+
return (
|
|
772
|
+
new LanguageSelection(this.onDidChange, () => {
|
|
773
|
+
const languageId = this.guessLanguageIdByFilepathOrFirstLine(resource, firstLine);
|
|
774
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
775
|
+
})
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
_createAndGetLanguageIdentifier(languageId) {
|
|
779
|
+
if (!languageId || !this.isRegisteredLanguageId(languageId)) {
|
|
780
|
+
languageId = PLAINTEXT_LANGUAGE_ID;
|
|
781
|
+
}
|
|
782
|
+
if (!this._encounteredLanguages.has(languageId)) {
|
|
783
|
+
this._encounteredLanguages.add(languageId);
|
|
784
|
+
TokenizationRegistry.getOrCreate(languageId);
|
|
785
|
+
this._onDidEncounterLanguage.fire(languageId);
|
|
786
|
+
}
|
|
787
|
+
return languageId;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
LanguageService.instanceCount = 0;
|
|
791
|
+
class LanguageSelection {
|
|
792
|
+
constructor(_onDidChangeLanguages, _selector) {
|
|
793
|
+
this._onDidChangeLanguages = _onDidChangeLanguages;
|
|
794
|
+
this._selector = _selector;
|
|
795
|
+
this._listener = null;
|
|
796
|
+
this._emitter = null;
|
|
797
|
+
this.languageId = this._selector();
|
|
798
|
+
}
|
|
799
|
+
_dispose() {
|
|
800
|
+
if (this._listener) {
|
|
801
|
+
this._listener.dispose();
|
|
802
|
+
this._listener = null;
|
|
803
|
+
}
|
|
804
|
+
if (this._emitter) {
|
|
805
|
+
this._emitter.dispose();
|
|
806
|
+
this._emitter = null;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
get onDidChange() {
|
|
810
|
+
if (!this._listener) {
|
|
811
|
+
this._listener = this._onDidChangeLanguages(() => this._evaluate());
|
|
812
|
+
}
|
|
813
|
+
if (!this._emitter) {
|
|
814
|
+
this._emitter = new Emitter({
|
|
815
|
+
onLastListenerRemove: () => {
|
|
816
|
+
this._dispose();
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
return this._emitter.event;
|
|
821
|
+
}
|
|
822
|
+
_evaluate() {
|
|
823
|
+
const languageId = this._selector();
|
|
824
|
+
if (languageId === this.languageId) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
this.languageId = languageId;
|
|
828
|
+
if (this._emitter) {
|
|
829
|
+
this._emitter.fire(this.languageId);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
class StringIterator {
|
|
834
|
+
constructor() {
|
|
835
|
+
this._value = '';
|
|
836
|
+
this._pos = 0;
|
|
837
|
+
}
|
|
838
|
+
reset(key) {
|
|
839
|
+
this._value = key;
|
|
840
|
+
this._pos = 0;
|
|
841
|
+
return this;
|
|
842
|
+
}
|
|
843
|
+
next() {
|
|
844
|
+
this._pos += 1;
|
|
845
|
+
return this;
|
|
846
|
+
}
|
|
847
|
+
hasNext() {
|
|
848
|
+
return this._pos < this._value.length - 1;
|
|
849
|
+
}
|
|
850
|
+
cmp(a) {
|
|
851
|
+
const aCode = a.charCodeAt(0);
|
|
852
|
+
const thisCode = this._value.charCodeAt(this._pos);
|
|
853
|
+
return aCode - thisCode;
|
|
854
|
+
}
|
|
855
|
+
value() {
|
|
856
|
+
return this._value[this._pos];
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
class ConfigKeysIterator {
|
|
860
|
+
constructor(_caseSensitive = true) {
|
|
861
|
+
this._caseSensitive = _caseSensitive;
|
|
862
|
+
}
|
|
863
|
+
reset(key) {
|
|
864
|
+
this._value = key;
|
|
865
|
+
this._from = 0;
|
|
866
|
+
this._to = 0;
|
|
867
|
+
return this.next();
|
|
868
|
+
}
|
|
869
|
+
hasNext() {
|
|
870
|
+
return this._to < this._value.length;
|
|
871
|
+
}
|
|
872
|
+
next() {
|
|
873
|
+
this._from = this._to;
|
|
874
|
+
let justSeps = true;
|
|
875
|
+
for (; this._to < this._value.length; this._to++) {
|
|
876
|
+
const ch = this._value.charCodeAt(this._to);
|
|
877
|
+
if (ch === 46 ) {
|
|
878
|
+
if (justSeps) {
|
|
879
|
+
this._from++;
|
|
880
|
+
}
|
|
881
|
+
else {
|
|
882
|
+
break;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
justSeps = false;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return this;
|
|
890
|
+
}
|
|
891
|
+
cmp(a) {
|
|
892
|
+
return this._caseSensitive
|
|
893
|
+
? compareSubstring(a, this._value, 0, a.length, this._from, this._to)
|
|
894
|
+
: compareSubstringIgnoreCase(a, this._value, 0, a.length, this._from, this._to);
|
|
895
|
+
}
|
|
896
|
+
value() {
|
|
897
|
+
return this._value.substring(this._from, this._to);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
class PathIterator {
|
|
901
|
+
constructor(_splitOnBackslash = true, _caseSensitive = true) {
|
|
902
|
+
this._splitOnBackslash = _splitOnBackslash;
|
|
903
|
+
this._caseSensitive = _caseSensitive;
|
|
904
|
+
}
|
|
905
|
+
reset(key) {
|
|
906
|
+
this._from = 0;
|
|
907
|
+
this._to = 0;
|
|
908
|
+
this._value = key;
|
|
909
|
+
this._valueLen = key.length;
|
|
910
|
+
for (let pos = key.length - 1; pos >= 0; pos--, this._valueLen--) {
|
|
911
|
+
const ch = this._value.charCodeAt(pos);
|
|
912
|
+
if (!((ch === 47 || this._splitOnBackslash && ch === 92) )) {
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return this.next();
|
|
917
|
+
}
|
|
918
|
+
hasNext() {
|
|
919
|
+
return this._to < this._valueLen;
|
|
920
|
+
}
|
|
921
|
+
next() {
|
|
922
|
+
this._from = this._to;
|
|
923
|
+
let justSeps = true;
|
|
924
|
+
for (; this._to < this._valueLen; this._to++) {
|
|
925
|
+
const ch = this._value.charCodeAt(this._to);
|
|
926
|
+
if (ch === 47 || this._splitOnBackslash && ch === 92 ) {
|
|
927
|
+
if (justSeps) {
|
|
928
|
+
this._from++;
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
justSeps = false;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return this;
|
|
939
|
+
}
|
|
940
|
+
cmp(a) {
|
|
941
|
+
return this._caseSensitive
|
|
942
|
+
? compareSubstring(a, this._value, 0, a.length, this._from, this._to)
|
|
943
|
+
: compareSubstringIgnoreCase(a, this._value, 0, a.length, this._from, this._to);
|
|
944
|
+
}
|
|
945
|
+
value() {
|
|
946
|
+
return this._value.substring(this._from, this._to);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
class UriIterator {
|
|
950
|
+
constructor(_ignorePathCasing) {
|
|
951
|
+
this._ignorePathCasing = _ignorePathCasing;
|
|
952
|
+
this._states = [];
|
|
953
|
+
this._stateIdx = 0;
|
|
954
|
+
}
|
|
955
|
+
reset(key) {
|
|
956
|
+
this._value = key;
|
|
957
|
+
this._states = [];
|
|
958
|
+
if (this._value.scheme) {
|
|
959
|
+
this._states.push(1 );
|
|
960
|
+
}
|
|
961
|
+
if (this._value.authority) {
|
|
962
|
+
this._states.push(2 );
|
|
963
|
+
}
|
|
964
|
+
if (this._value.path) {
|
|
965
|
+
this._pathIterator = new PathIterator(false, !this._ignorePathCasing(key));
|
|
966
|
+
this._pathIterator.reset(key.path);
|
|
967
|
+
if (this._pathIterator.value()) {
|
|
968
|
+
this._states.push(3 );
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (this._value.query) {
|
|
972
|
+
this._states.push(4 );
|
|
973
|
+
}
|
|
974
|
+
if (this._value.fragment) {
|
|
975
|
+
this._states.push(5 );
|
|
976
|
+
}
|
|
977
|
+
this._stateIdx = 0;
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
next() {
|
|
981
|
+
if (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext()) {
|
|
982
|
+
this._pathIterator.next();
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
this._stateIdx += 1;
|
|
986
|
+
}
|
|
987
|
+
return this;
|
|
988
|
+
}
|
|
989
|
+
hasNext() {
|
|
990
|
+
return (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext())
|
|
991
|
+
|| this._stateIdx < this._states.length - 1;
|
|
992
|
+
}
|
|
993
|
+
cmp(a) {
|
|
994
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
995
|
+
return compareIgnoreCase(a, this._value.scheme);
|
|
996
|
+
}
|
|
997
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
998
|
+
return compareIgnoreCase(a, this._value.authority);
|
|
999
|
+
}
|
|
1000
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
1001
|
+
return this._pathIterator.cmp(a);
|
|
1002
|
+
}
|
|
1003
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
1004
|
+
return compare$1(a, this._value.query);
|
|
1005
|
+
}
|
|
1006
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
1007
|
+
return compare$1(a, this._value.fragment);
|
|
1008
|
+
}
|
|
1009
|
+
throw new Error();
|
|
1010
|
+
}
|
|
1011
|
+
value() {
|
|
1012
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
1013
|
+
return this._value.scheme;
|
|
1014
|
+
}
|
|
1015
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
1016
|
+
return this._value.authority;
|
|
1017
|
+
}
|
|
1018
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
1019
|
+
return this._pathIterator.value();
|
|
1020
|
+
}
|
|
1021
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
1022
|
+
return this._value.query;
|
|
1023
|
+
}
|
|
1024
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
1025
|
+
return this._value.fragment;
|
|
1026
|
+
}
|
|
1027
|
+
throw new Error();
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
class TernarySearchTreeNode {
|
|
1031
|
+
constructor() {
|
|
1032
|
+
this.height = 1;
|
|
1033
|
+
}
|
|
1034
|
+
isEmpty() {
|
|
1035
|
+
return !this.left && !this.mid && !this.right && !this.value;
|
|
1036
|
+
}
|
|
1037
|
+
rotateLeft() {
|
|
1038
|
+
const tmp = this.right;
|
|
1039
|
+
this.right = tmp.left;
|
|
1040
|
+
tmp.left = this;
|
|
1041
|
+
this.updateHeight();
|
|
1042
|
+
tmp.updateHeight();
|
|
1043
|
+
return tmp;
|
|
1044
|
+
}
|
|
1045
|
+
rotateRight() {
|
|
1046
|
+
const tmp = this.left;
|
|
1047
|
+
this.left = tmp.right;
|
|
1048
|
+
tmp.right = this;
|
|
1049
|
+
this.updateHeight();
|
|
1050
|
+
tmp.updateHeight();
|
|
1051
|
+
return tmp;
|
|
1052
|
+
}
|
|
1053
|
+
updateHeight() {
|
|
1054
|
+
this.height = 1 + Math.max(this.heightLeft, this.heightRight);
|
|
1055
|
+
}
|
|
1056
|
+
balanceFactor() {
|
|
1057
|
+
return this.heightRight - this.heightLeft;
|
|
1058
|
+
}
|
|
1059
|
+
get heightLeft() {
|
|
1060
|
+
return this.left?.height ?? 0;
|
|
1061
|
+
}
|
|
1062
|
+
get heightRight() {
|
|
1063
|
+
return this.right?.height ?? 0;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
class TernarySearchTree {
|
|
1067
|
+
constructor(segments) {
|
|
1068
|
+
this._iter = segments;
|
|
1069
|
+
}
|
|
1070
|
+
static forUris(ignorePathCasing = () => false) {
|
|
1071
|
+
return (
|
|
1072
|
+
new TernarySearchTree( new UriIterator(ignorePathCasing))
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
static forPaths(ignorePathCasing = false) {
|
|
1076
|
+
return (
|
|
1077
|
+
new TernarySearchTree( new PathIterator(undefined, !ignorePathCasing))
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
static forStrings() {
|
|
1081
|
+
return (
|
|
1082
|
+
new TernarySearchTree( new StringIterator())
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
static forConfigKeys() {
|
|
1086
|
+
return (
|
|
1087
|
+
new TernarySearchTree( new ConfigKeysIterator())
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
clear() {
|
|
1091
|
+
this._root = undefined;
|
|
1092
|
+
}
|
|
1093
|
+
fill(values, keys) {
|
|
1094
|
+
if (keys) {
|
|
1095
|
+
const arr = keys.slice(0);
|
|
1096
|
+
shuffle(arr);
|
|
1097
|
+
for (let k of arr) {
|
|
1098
|
+
this.set(k, values);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
const arr = values.slice(0);
|
|
1103
|
+
shuffle(arr);
|
|
1104
|
+
for (let entry of arr) {
|
|
1105
|
+
this.set(entry[0], entry[1]);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
set(key, element) {
|
|
1110
|
+
const iter = this._iter.reset(key);
|
|
1111
|
+
let node;
|
|
1112
|
+
if (!this._root) {
|
|
1113
|
+
this._root = new TernarySearchTreeNode();
|
|
1114
|
+
this._root.segment = iter.value();
|
|
1115
|
+
}
|
|
1116
|
+
const stack = [];
|
|
1117
|
+
node = this._root;
|
|
1118
|
+
while (true) {
|
|
1119
|
+
const val = iter.cmp(node.segment);
|
|
1120
|
+
if (val > 0) {
|
|
1121
|
+
if (!node.left) {
|
|
1122
|
+
node.left = new TernarySearchTreeNode();
|
|
1123
|
+
node.left.segment = iter.value();
|
|
1124
|
+
}
|
|
1125
|
+
stack.push([-1 , node]);
|
|
1126
|
+
node = node.left;
|
|
1127
|
+
}
|
|
1128
|
+
else if (val < 0) {
|
|
1129
|
+
if (!node.right) {
|
|
1130
|
+
node.right = new TernarySearchTreeNode();
|
|
1131
|
+
node.right.segment = iter.value();
|
|
1132
|
+
}
|
|
1133
|
+
stack.push([1 , node]);
|
|
1134
|
+
node = node.right;
|
|
1135
|
+
}
|
|
1136
|
+
else if (iter.hasNext()) {
|
|
1137
|
+
iter.next();
|
|
1138
|
+
if (!node.mid) {
|
|
1139
|
+
node.mid = new TernarySearchTreeNode();
|
|
1140
|
+
node.mid.segment = iter.value();
|
|
1141
|
+
}
|
|
1142
|
+
stack.push([0 , node]);
|
|
1143
|
+
node = node.mid;
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
const oldElement = node.value;
|
|
1150
|
+
node.value = element;
|
|
1151
|
+
node.key = key;
|
|
1152
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
1153
|
+
const node = stack[i][1];
|
|
1154
|
+
node.updateHeight();
|
|
1155
|
+
const bf = node.balanceFactor();
|
|
1156
|
+
if (bf < -1 || bf > 1) {
|
|
1157
|
+
const d1 = stack[i][0];
|
|
1158
|
+
const d2 = stack[i + 1][0];
|
|
1159
|
+
if (d1 === 1 && d2 === 1 ) {
|
|
1160
|
+
stack[i][1] = node.rotateLeft();
|
|
1161
|
+
}
|
|
1162
|
+
else if (d1 === -1 && d2 === -1 ) {
|
|
1163
|
+
stack[i][1] = node.rotateRight();
|
|
1164
|
+
}
|
|
1165
|
+
else if (d1 === 1 && d2 === -1 ) {
|
|
1166
|
+
node.right = stack[i + 1][1] = stack[i + 1][1].rotateRight();
|
|
1167
|
+
stack[i][1] = node.rotateLeft();
|
|
1168
|
+
}
|
|
1169
|
+
else if (d1 === -1 && d2 === 1 ) {
|
|
1170
|
+
node.left = stack[i + 1][1] = stack[i + 1][1].rotateLeft();
|
|
1171
|
+
stack[i][1] = node.rotateRight();
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
throw new Error();
|
|
1175
|
+
}
|
|
1176
|
+
if (i > 0) {
|
|
1177
|
+
switch (stack[i - 1][0]) {
|
|
1178
|
+
case -1 :
|
|
1179
|
+
stack[i - 1][1].left = stack[i][1];
|
|
1180
|
+
break;
|
|
1181
|
+
case 1 :
|
|
1182
|
+
stack[i - 1][1].right = stack[i][1];
|
|
1183
|
+
break;
|
|
1184
|
+
case 0 :
|
|
1185
|
+
stack[i - 1][1].mid = stack[i][1];
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
this._root = stack[0][1];
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
return oldElement;
|
|
1195
|
+
}
|
|
1196
|
+
get(key) {
|
|
1197
|
+
return this._getNode(key)?.value;
|
|
1198
|
+
}
|
|
1199
|
+
_getNode(key) {
|
|
1200
|
+
const iter = this._iter.reset(key);
|
|
1201
|
+
let node = this._root;
|
|
1202
|
+
while (node) {
|
|
1203
|
+
const val = iter.cmp(node.segment);
|
|
1204
|
+
if (val > 0) {
|
|
1205
|
+
node = node.left;
|
|
1206
|
+
}
|
|
1207
|
+
else if (val < 0) {
|
|
1208
|
+
node = node.right;
|
|
1209
|
+
}
|
|
1210
|
+
else if (iter.hasNext()) {
|
|
1211
|
+
iter.next();
|
|
1212
|
+
node = node.mid;
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
break;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return node;
|
|
1219
|
+
}
|
|
1220
|
+
has(key) {
|
|
1221
|
+
const node = this._getNode(key);
|
|
1222
|
+
return !(node?.value === undefined && node?.mid === undefined);
|
|
1223
|
+
}
|
|
1224
|
+
delete(key) {
|
|
1225
|
+
return this._delete(key, false);
|
|
1226
|
+
}
|
|
1227
|
+
deleteSuperstr(key) {
|
|
1228
|
+
return this._delete(key, true);
|
|
1229
|
+
}
|
|
1230
|
+
_delete(key, superStr) {
|
|
1231
|
+
const iter = this._iter.reset(key);
|
|
1232
|
+
const stack = [];
|
|
1233
|
+
let node = this._root;
|
|
1234
|
+
while (node) {
|
|
1235
|
+
const val = iter.cmp(node.segment);
|
|
1236
|
+
if (val > 0) {
|
|
1237
|
+
stack.push([-1 , node]);
|
|
1238
|
+
node = node.left;
|
|
1239
|
+
}
|
|
1240
|
+
else if (val < 0) {
|
|
1241
|
+
stack.push([1 , node]);
|
|
1242
|
+
node = node.right;
|
|
1243
|
+
}
|
|
1244
|
+
else if (iter.hasNext()) {
|
|
1245
|
+
iter.next();
|
|
1246
|
+
stack.push([0 , node]);
|
|
1247
|
+
node = node.mid;
|
|
1248
|
+
}
|
|
1249
|
+
else {
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (!node) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
if (superStr) {
|
|
1257
|
+
node.left = undefined;
|
|
1258
|
+
node.mid = undefined;
|
|
1259
|
+
node.right = undefined;
|
|
1260
|
+
node.height = 1;
|
|
1261
|
+
}
|
|
1262
|
+
else {
|
|
1263
|
+
node.key = undefined;
|
|
1264
|
+
node.value = undefined;
|
|
1265
|
+
}
|
|
1266
|
+
if (!node.mid && !node.value) {
|
|
1267
|
+
if (node.left && node.right) {
|
|
1268
|
+
const min = this._min(node.right);
|
|
1269
|
+
const { key, value, segment } = min;
|
|
1270
|
+
this._delete(min.key, false);
|
|
1271
|
+
node.key = key;
|
|
1272
|
+
node.value = value;
|
|
1273
|
+
node.segment = segment;
|
|
1274
|
+
}
|
|
1275
|
+
else {
|
|
1276
|
+
const newChild = node.left ?? node.right;
|
|
1277
|
+
if (stack.length > 0) {
|
|
1278
|
+
const [dir, parent] = stack[stack.length - 1];
|
|
1279
|
+
switch (dir) {
|
|
1280
|
+
case -1 :
|
|
1281
|
+
parent.left = newChild;
|
|
1282
|
+
break;
|
|
1283
|
+
case 0 :
|
|
1284
|
+
parent.mid = newChild;
|
|
1285
|
+
break;
|
|
1286
|
+
case 1 :
|
|
1287
|
+
parent.right = newChild;
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
this._root = newChild;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
1297
|
+
const node = stack[i][1];
|
|
1298
|
+
node.updateHeight();
|
|
1299
|
+
const bf = node.balanceFactor();
|
|
1300
|
+
if (bf > 1) {
|
|
1301
|
+
if (node.right.balanceFactor() >= 0) {
|
|
1302
|
+
stack[i][1] = node.rotateLeft();
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
node.right = node.right.rotateRight();
|
|
1306
|
+
stack[i][1] = node.rotateLeft();
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
else if (bf < -1) {
|
|
1310
|
+
if (node.left.balanceFactor() <= 0) {
|
|
1311
|
+
stack[i][1] = node.rotateRight();
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
node.left = node.left.rotateLeft();
|
|
1315
|
+
stack[i][1] = node.rotateRight();
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
if (i > 0) {
|
|
1319
|
+
switch (stack[i - 1][0]) {
|
|
1320
|
+
case -1 :
|
|
1321
|
+
stack[i - 1][1].left = stack[i][1];
|
|
1322
|
+
break;
|
|
1323
|
+
case 1 :
|
|
1324
|
+
stack[i - 1][1].right = stack[i][1];
|
|
1325
|
+
break;
|
|
1326
|
+
case 0 :
|
|
1327
|
+
stack[i - 1][1].mid = stack[i][1];
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
this._root = stack[0][1];
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
_min(node) {
|
|
1337
|
+
while (node.left) {
|
|
1338
|
+
node = node.left;
|
|
1339
|
+
}
|
|
1340
|
+
return node;
|
|
1341
|
+
}
|
|
1342
|
+
findSubstr(key) {
|
|
1343
|
+
const iter = this._iter.reset(key);
|
|
1344
|
+
let node = this._root;
|
|
1345
|
+
let candidate = undefined;
|
|
1346
|
+
while (node) {
|
|
1347
|
+
const val = iter.cmp(node.segment);
|
|
1348
|
+
if (val > 0) {
|
|
1349
|
+
node = node.left;
|
|
1350
|
+
}
|
|
1351
|
+
else if (val < 0) {
|
|
1352
|
+
node = node.right;
|
|
1353
|
+
}
|
|
1354
|
+
else if (iter.hasNext()) {
|
|
1355
|
+
iter.next();
|
|
1356
|
+
candidate = node.value || candidate;
|
|
1357
|
+
node = node.mid;
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
break;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return node && node.value || candidate;
|
|
1364
|
+
}
|
|
1365
|
+
findSuperstr(key) {
|
|
1366
|
+
const iter = this._iter.reset(key);
|
|
1367
|
+
let node = this._root;
|
|
1368
|
+
while (node) {
|
|
1369
|
+
const val = iter.cmp(node.segment);
|
|
1370
|
+
if (val > 0) {
|
|
1371
|
+
node = node.left;
|
|
1372
|
+
}
|
|
1373
|
+
else if (val < 0) {
|
|
1374
|
+
node = node.right;
|
|
1375
|
+
}
|
|
1376
|
+
else if (iter.hasNext()) {
|
|
1377
|
+
iter.next();
|
|
1378
|
+
node = node.mid;
|
|
1379
|
+
}
|
|
1380
|
+
else {
|
|
1381
|
+
if (!node.mid) {
|
|
1382
|
+
return undefined;
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
return this._entries(node.mid);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return undefined;
|
|
1390
|
+
}
|
|
1391
|
+
forEach(callback) {
|
|
1392
|
+
for (const [key, value] of this) {
|
|
1393
|
+
callback(value, key);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
*[Symbol.iterator]() {
|
|
1397
|
+
yield* this._entries(this._root);
|
|
1398
|
+
}
|
|
1399
|
+
*_entries(node) {
|
|
1400
|
+
if (!node) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (node.left) {
|
|
1404
|
+
yield* this._entries(node.left);
|
|
1405
|
+
}
|
|
1406
|
+
if (node.value) {
|
|
1407
|
+
yield [node.key, node.value];
|
|
1408
|
+
}
|
|
1409
|
+
if (node.mid) {
|
|
1410
|
+
yield* this._entries(node.mid);
|
|
1411
|
+
}
|
|
1412
|
+
if (node.right) {
|
|
1413
|
+
yield* this._entries(node.right);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
_isBalanced() {
|
|
1417
|
+
const nodeIsBalanced = (node) => {
|
|
1418
|
+
if (!node) {
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1421
|
+
const bf = node.balanceFactor();
|
|
1422
|
+
if (bf < -1 || bf > 1) {
|
|
1423
|
+
return false;
|
|
1424
|
+
}
|
|
1425
|
+
return nodeIsBalanced(node.left) && nodeIsBalanced(node.right);
|
|
1426
|
+
};
|
|
1427
|
+
return nodeIsBalanced(this._root);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
var ParseOptions;
|
|
1431
|
+
(function(ParseOptions) {
|
|
1432
|
+
ParseOptions.DEFAULT = {
|
|
1433
|
+
allowTrailingComma: true
|
|
1434
|
+
};
|
|
1435
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
1436
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
1437
|
+
let pos = 0, len = text.length, value = '', tokenOffset = 0, token = 16 , scanError = 0 ;
|
|
1438
|
+
function scanHexDigits(count) {
|
|
1439
|
+
let digits = 0;
|
|
1440
|
+
let hexValue = 0;
|
|
1441
|
+
while (digits < count) {
|
|
1442
|
+
const ch = text.charCodeAt(pos);
|
|
1443
|
+
if (ch >= 48 && ch <= 57 ) {
|
|
1444
|
+
hexValue = hexValue * 16 + ch - 48 ;
|
|
1445
|
+
}
|
|
1446
|
+
else if (ch >= 65 && ch <= 70 ) {
|
|
1447
|
+
hexValue = hexValue * 16 + ch - 65 + 10;
|
|
1448
|
+
}
|
|
1449
|
+
else if (ch >= 97 && ch <= 102 ) {
|
|
1450
|
+
hexValue = hexValue * 16 + ch - 97 + 10;
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
break;
|
|
1454
|
+
}
|
|
1455
|
+
pos++;
|
|
1456
|
+
digits++;
|
|
1457
|
+
}
|
|
1458
|
+
if (digits < count) {
|
|
1459
|
+
hexValue = -1;
|
|
1460
|
+
}
|
|
1461
|
+
return hexValue;
|
|
1462
|
+
}
|
|
1463
|
+
function setPosition(newPosition) {
|
|
1464
|
+
pos = newPosition;
|
|
1465
|
+
value = '';
|
|
1466
|
+
tokenOffset = 0;
|
|
1467
|
+
token = 16 ;
|
|
1468
|
+
scanError = 0 ;
|
|
1469
|
+
}
|
|
1470
|
+
function scanNumber() {
|
|
1471
|
+
const start = pos;
|
|
1472
|
+
if (text.charCodeAt(pos) === 48 ) {
|
|
1473
|
+
pos++;
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
pos++;
|
|
1477
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1478
|
+
pos++;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
if (pos < text.length && text.charCodeAt(pos) === 46 ) {
|
|
1482
|
+
pos++;
|
|
1483
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1484
|
+
pos++;
|
|
1485
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1486
|
+
pos++;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
else {
|
|
1490
|
+
scanError = 3 ;
|
|
1491
|
+
return text.substring(start, pos);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
let end = pos;
|
|
1495
|
+
if (pos < text.length && ((text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) )) {
|
|
1496
|
+
pos++;
|
|
1497
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45 ) {
|
|
1498
|
+
pos++;
|
|
1499
|
+
}
|
|
1500
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1501
|
+
pos++;
|
|
1502
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1503
|
+
pos++;
|
|
1504
|
+
}
|
|
1505
|
+
end = pos;
|
|
1506
|
+
}
|
|
1507
|
+
else {
|
|
1508
|
+
scanError = 3 ;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
return text.substring(start, end);
|
|
1512
|
+
}
|
|
1513
|
+
function scanString() {
|
|
1514
|
+
let result = '', start = pos;
|
|
1515
|
+
while (true) {
|
|
1516
|
+
if (pos >= len) {
|
|
1517
|
+
result += text.substring(start, pos);
|
|
1518
|
+
scanError = 2 ;
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
const ch = text.charCodeAt(pos);
|
|
1522
|
+
if (ch === 34 ) {
|
|
1523
|
+
result += text.substring(start, pos);
|
|
1524
|
+
pos++;
|
|
1525
|
+
break;
|
|
1526
|
+
}
|
|
1527
|
+
if (ch === 92 ) {
|
|
1528
|
+
result += text.substring(start, pos);
|
|
1529
|
+
pos++;
|
|
1530
|
+
if (pos >= len) {
|
|
1531
|
+
scanError = 2 ;
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
const ch2 = text.charCodeAt(pos++);
|
|
1535
|
+
switch (ch2) {
|
|
1536
|
+
case 34 :
|
|
1537
|
+
result += '\"';
|
|
1538
|
+
break;
|
|
1539
|
+
case 92 :
|
|
1540
|
+
result += '\\';
|
|
1541
|
+
break;
|
|
1542
|
+
case 47 :
|
|
1543
|
+
result += '/';
|
|
1544
|
+
break;
|
|
1545
|
+
case 98 :
|
|
1546
|
+
result += '\b';
|
|
1547
|
+
break;
|
|
1548
|
+
case 102 :
|
|
1549
|
+
result += '\f';
|
|
1550
|
+
break;
|
|
1551
|
+
case 110 :
|
|
1552
|
+
result += '\n';
|
|
1553
|
+
break;
|
|
1554
|
+
case 114 :
|
|
1555
|
+
result += '\r';
|
|
1556
|
+
break;
|
|
1557
|
+
case 116 :
|
|
1558
|
+
result += '\t';
|
|
1559
|
+
break;
|
|
1560
|
+
case 117 : {
|
|
1561
|
+
const ch3 = scanHexDigits(4);
|
|
1562
|
+
if (ch3 >= 0) {
|
|
1563
|
+
result += String.fromCharCode(ch3);
|
|
1564
|
+
}
|
|
1565
|
+
else {
|
|
1566
|
+
scanError = 4 ;
|
|
1567
|
+
}
|
|
1568
|
+
break;
|
|
1569
|
+
}
|
|
1570
|
+
default:
|
|
1571
|
+
scanError = 5 ;
|
|
1572
|
+
}
|
|
1573
|
+
start = pos;
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
if (ch >= 0 && ch <= 0x1F) {
|
|
1577
|
+
if (isLineBreak(ch)) {
|
|
1578
|
+
result += text.substring(start, pos);
|
|
1579
|
+
scanError = 2 ;
|
|
1580
|
+
break;
|
|
1581
|
+
}
|
|
1582
|
+
else {
|
|
1583
|
+
scanError = 6 ;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
pos++;
|
|
1587
|
+
}
|
|
1588
|
+
return result;
|
|
1589
|
+
}
|
|
1590
|
+
function scanNext() {
|
|
1591
|
+
value = '';
|
|
1592
|
+
scanError = 0 ;
|
|
1593
|
+
tokenOffset = pos;
|
|
1594
|
+
if (pos >= len) {
|
|
1595
|
+
tokenOffset = len;
|
|
1596
|
+
return token = 17 ;
|
|
1597
|
+
}
|
|
1598
|
+
let code = text.charCodeAt(pos);
|
|
1599
|
+
if (isWhitespace(code)) {
|
|
1600
|
+
do {
|
|
1601
|
+
pos++;
|
|
1602
|
+
value += String.fromCharCode(code);
|
|
1603
|
+
code = text.charCodeAt(pos);
|
|
1604
|
+
} while (isWhitespace(code));
|
|
1605
|
+
return token = 15 ;
|
|
1606
|
+
}
|
|
1607
|
+
if (isLineBreak(code)) {
|
|
1608
|
+
pos++;
|
|
1609
|
+
value += String.fromCharCode(code);
|
|
1610
|
+
if (code === 13 && text.charCodeAt(pos) === 10 ) {
|
|
1611
|
+
pos++;
|
|
1612
|
+
value += '\n';
|
|
1613
|
+
}
|
|
1614
|
+
return token = 14 ;
|
|
1615
|
+
}
|
|
1616
|
+
switch (code) {
|
|
1617
|
+
case 123 :
|
|
1618
|
+
pos++;
|
|
1619
|
+
return token = 1 ;
|
|
1620
|
+
case 125 :
|
|
1621
|
+
pos++;
|
|
1622
|
+
return token = 2 ;
|
|
1623
|
+
case 91 :
|
|
1624
|
+
pos++;
|
|
1625
|
+
return token = 3 ;
|
|
1626
|
+
case 93 :
|
|
1627
|
+
pos++;
|
|
1628
|
+
return token = 4 ;
|
|
1629
|
+
case 58 :
|
|
1630
|
+
pos++;
|
|
1631
|
+
return token = 6 ;
|
|
1632
|
+
case 44 :
|
|
1633
|
+
pos++;
|
|
1634
|
+
return token = 5 ;
|
|
1635
|
+
case 34 :
|
|
1636
|
+
pos++;
|
|
1637
|
+
value = scanString();
|
|
1638
|
+
return token = 10 ;
|
|
1639
|
+
case 47 : {
|
|
1640
|
+
const start = pos - 1;
|
|
1641
|
+
if (text.charCodeAt(pos + 1) === 47 ) {
|
|
1642
|
+
pos += 2;
|
|
1643
|
+
while (pos < len) {
|
|
1644
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
1645
|
+
break;
|
|
1646
|
+
}
|
|
1647
|
+
pos++;
|
|
1648
|
+
}
|
|
1649
|
+
value = text.substring(start, pos);
|
|
1650
|
+
return token = 12 ;
|
|
1651
|
+
}
|
|
1652
|
+
if (text.charCodeAt(pos + 1) === 42 ) {
|
|
1653
|
+
pos += 2;
|
|
1654
|
+
const safeLength = len - 1;
|
|
1655
|
+
let commentClosed = false;
|
|
1656
|
+
while (pos < safeLength) {
|
|
1657
|
+
const ch = text.charCodeAt(pos);
|
|
1658
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47 ) {
|
|
1659
|
+
pos += 2;
|
|
1660
|
+
commentClosed = true;
|
|
1661
|
+
break;
|
|
1662
|
+
}
|
|
1663
|
+
pos++;
|
|
1664
|
+
}
|
|
1665
|
+
if (!commentClosed) {
|
|
1666
|
+
pos++;
|
|
1667
|
+
scanError = 1 ;
|
|
1668
|
+
}
|
|
1669
|
+
value = text.substring(start, pos);
|
|
1670
|
+
return token = 13 ;
|
|
1671
|
+
}
|
|
1672
|
+
value += String.fromCharCode(code);
|
|
1673
|
+
pos++;
|
|
1674
|
+
return token = 16 ;
|
|
1675
|
+
}
|
|
1676
|
+
case 45 :
|
|
1677
|
+
value += String.fromCharCode(code);
|
|
1678
|
+
pos++;
|
|
1679
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
1680
|
+
return token = 16 ;
|
|
1681
|
+
}
|
|
1682
|
+
case 48 :
|
|
1683
|
+
case 49 :
|
|
1684
|
+
case 50 :
|
|
1685
|
+
case 51 :
|
|
1686
|
+
case 52 :
|
|
1687
|
+
case 53 :
|
|
1688
|
+
case 54 :
|
|
1689
|
+
case 55 :
|
|
1690
|
+
case 56 :
|
|
1691
|
+
case 57 :
|
|
1692
|
+
value += scanNumber();
|
|
1693
|
+
return token = 11 ;
|
|
1694
|
+
default:
|
|
1695
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
1696
|
+
pos++;
|
|
1697
|
+
code = text.charCodeAt(pos);
|
|
1698
|
+
}
|
|
1699
|
+
if (tokenOffset !== pos) {
|
|
1700
|
+
value = text.substring(tokenOffset, pos);
|
|
1701
|
+
switch (value) {
|
|
1702
|
+
case 'true': return token = 8 ;
|
|
1703
|
+
case 'false': return token = 9 ;
|
|
1704
|
+
case 'null': return token = 7 ;
|
|
1705
|
+
}
|
|
1706
|
+
return token = 16 ;
|
|
1707
|
+
}
|
|
1708
|
+
value += String.fromCharCode(code);
|
|
1709
|
+
pos++;
|
|
1710
|
+
return token = 16 ;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
function isUnknownContentCharacter(code) {
|
|
1714
|
+
if (isWhitespace(code) || isLineBreak(code)) {
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1717
|
+
switch (code) {
|
|
1718
|
+
case 125 :
|
|
1719
|
+
case 93 :
|
|
1720
|
+
case 123 :
|
|
1721
|
+
case 91 :
|
|
1722
|
+
case 34 :
|
|
1723
|
+
case 58 :
|
|
1724
|
+
case 44 :
|
|
1725
|
+
case 47 :
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
return true;
|
|
1729
|
+
}
|
|
1730
|
+
function scanNextNonTrivia() {
|
|
1731
|
+
let result;
|
|
1732
|
+
do {
|
|
1733
|
+
result = scanNext();
|
|
1734
|
+
} while (result >= 12 && result <= 15 );
|
|
1735
|
+
return result;
|
|
1736
|
+
}
|
|
1737
|
+
return {
|
|
1738
|
+
setPosition: setPosition,
|
|
1739
|
+
getPosition: () => pos,
|
|
1740
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
1741
|
+
getToken: () => token,
|
|
1742
|
+
getTokenValue: () => value,
|
|
1743
|
+
getTokenOffset: () => tokenOffset,
|
|
1744
|
+
getTokenLength: () => pos - tokenOffset,
|
|
1745
|
+
getTokenError: () => scanError
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function isWhitespace(ch) {
|
|
1749
|
+
return ch === 32 || ch === 9 || ch === 11 || ch === 12 ||
|
|
1750
|
+
ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 ||
|
|
1751
|
+
ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279 ;
|
|
1752
|
+
}
|
|
1753
|
+
function isLineBreak(ch) {
|
|
1754
|
+
return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 ;
|
|
1755
|
+
}
|
|
1756
|
+
function isDigit(ch) {
|
|
1757
|
+
return ch >= 48 && ch <= 57 ;
|
|
1758
|
+
}
|
|
1759
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
1760
|
+
const _scanner = createScanner(text, false);
|
|
1761
|
+
function toNoArgVisit(visitFunction) {
|
|
1762
|
+
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
1763
|
+
}
|
|
1764
|
+
function toOneArgVisit(visitFunction) {
|
|
1765
|
+
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
1766
|
+
}
|
|
1767
|
+
const onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
1768
|
+
const disallowComments = options && options.disallowComments;
|
|
1769
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
1770
|
+
function scanNext() {
|
|
1771
|
+
while (true) {
|
|
1772
|
+
const token = _scanner.scan();
|
|
1773
|
+
switch (_scanner.getTokenError()) {
|
|
1774
|
+
case 4 :
|
|
1775
|
+
handleError(14 );
|
|
1776
|
+
break;
|
|
1777
|
+
case 5 :
|
|
1778
|
+
handleError(15 );
|
|
1779
|
+
break;
|
|
1780
|
+
case 3 :
|
|
1781
|
+
handleError(13 );
|
|
1782
|
+
break;
|
|
1783
|
+
case 1 :
|
|
1784
|
+
if (!disallowComments) {
|
|
1785
|
+
handleError(11 );
|
|
1786
|
+
}
|
|
1787
|
+
break;
|
|
1788
|
+
case 2 :
|
|
1789
|
+
handleError(12 );
|
|
1790
|
+
break;
|
|
1791
|
+
case 6 :
|
|
1792
|
+
handleError(16 );
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
switch (token) {
|
|
1796
|
+
case 12 :
|
|
1797
|
+
case 13 :
|
|
1798
|
+
if (disallowComments) {
|
|
1799
|
+
handleError(10 );
|
|
1800
|
+
}
|
|
1801
|
+
else {
|
|
1802
|
+
onComment();
|
|
1803
|
+
}
|
|
1804
|
+
break;
|
|
1805
|
+
case 16 :
|
|
1806
|
+
handleError(1 );
|
|
1807
|
+
break;
|
|
1808
|
+
case 15 :
|
|
1809
|
+
case 14 :
|
|
1810
|
+
break;
|
|
1811
|
+
default:
|
|
1812
|
+
return token;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
1817
|
+
onError(error);
|
|
1818
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
1819
|
+
let token = _scanner.getToken();
|
|
1820
|
+
while (token !== 17 ) {
|
|
1821
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
1822
|
+
scanNext();
|
|
1823
|
+
break;
|
|
1824
|
+
}
|
|
1825
|
+
else if (skipUntil.indexOf(token) !== -1) {
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
token = scanNext();
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
function parseString(isValue) {
|
|
1833
|
+
const value = _scanner.getTokenValue();
|
|
1834
|
+
if (isValue) {
|
|
1835
|
+
onLiteralValue(value);
|
|
1836
|
+
}
|
|
1837
|
+
else {
|
|
1838
|
+
onObjectProperty(value);
|
|
1839
|
+
}
|
|
1840
|
+
scanNext();
|
|
1841
|
+
return true;
|
|
1842
|
+
}
|
|
1843
|
+
function parseLiteral() {
|
|
1844
|
+
switch (_scanner.getToken()) {
|
|
1845
|
+
case 11 : {
|
|
1846
|
+
let value = 0;
|
|
1847
|
+
try {
|
|
1848
|
+
value = JSON.parse(_scanner.getTokenValue());
|
|
1849
|
+
if (typeof value !== 'number') {
|
|
1850
|
+
handleError(2 );
|
|
1851
|
+
value = 0;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
catch (e) {
|
|
1855
|
+
handleError(2 );
|
|
1856
|
+
}
|
|
1857
|
+
onLiteralValue(value);
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
case 7 :
|
|
1861
|
+
onLiteralValue(null);
|
|
1862
|
+
break;
|
|
1863
|
+
case 8 :
|
|
1864
|
+
onLiteralValue(true);
|
|
1865
|
+
break;
|
|
1866
|
+
case 9 :
|
|
1867
|
+
onLiteralValue(false);
|
|
1868
|
+
break;
|
|
1869
|
+
default:
|
|
1870
|
+
return false;
|
|
1871
|
+
}
|
|
1872
|
+
scanNext();
|
|
1873
|
+
return true;
|
|
1874
|
+
}
|
|
1875
|
+
function parseProperty() {
|
|
1876
|
+
if (_scanner.getToken() !== 10 ) {
|
|
1877
|
+
handleError(3 , [], [2 , 5 ]);
|
|
1878
|
+
return false;
|
|
1879
|
+
}
|
|
1880
|
+
parseString(false);
|
|
1881
|
+
if (_scanner.getToken() === 6 ) {
|
|
1882
|
+
onSeparator(':');
|
|
1883
|
+
scanNext();
|
|
1884
|
+
if (!parseValue()) {
|
|
1885
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
handleError(5 , [], [2 , 5 ]);
|
|
1890
|
+
}
|
|
1891
|
+
return true;
|
|
1892
|
+
}
|
|
1893
|
+
function parseObject() {
|
|
1894
|
+
onObjectBegin();
|
|
1895
|
+
scanNext();
|
|
1896
|
+
let needsComma = false;
|
|
1897
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17 ) {
|
|
1898
|
+
if (_scanner.getToken() === 5 ) {
|
|
1899
|
+
if (!needsComma) {
|
|
1900
|
+
handleError(4 , [], []);
|
|
1901
|
+
}
|
|
1902
|
+
onSeparator(',');
|
|
1903
|
+
scanNext();
|
|
1904
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
1905
|
+
break;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
else if (needsComma) {
|
|
1909
|
+
handleError(6 , [], []);
|
|
1910
|
+
}
|
|
1911
|
+
if (!parseProperty()) {
|
|
1912
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1913
|
+
}
|
|
1914
|
+
needsComma = true;
|
|
1915
|
+
}
|
|
1916
|
+
onObjectEnd();
|
|
1917
|
+
if (_scanner.getToken() !== 2 ) {
|
|
1918
|
+
handleError(7 , [2 ], []);
|
|
1919
|
+
}
|
|
1920
|
+
else {
|
|
1921
|
+
scanNext();
|
|
1922
|
+
}
|
|
1923
|
+
return true;
|
|
1924
|
+
}
|
|
1925
|
+
function parseArray() {
|
|
1926
|
+
onArrayBegin();
|
|
1927
|
+
scanNext();
|
|
1928
|
+
let needsComma = false;
|
|
1929
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17 ) {
|
|
1930
|
+
if (_scanner.getToken() === 5 ) {
|
|
1931
|
+
if (!needsComma) {
|
|
1932
|
+
handleError(4 , [], []);
|
|
1933
|
+
}
|
|
1934
|
+
onSeparator(',');
|
|
1935
|
+
scanNext();
|
|
1936
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
1937
|
+
break;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
else if (needsComma) {
|
|
1941
|
+
handleError(6 , [], []);
|
|
1942
|
+
}
|
|
1943
|
+
if (!parseValue()) {
|
|
1944
|
+
handleError(4 , [], [4 , 5 ]);
|
|
1945
|
+
}
|
|
1946
|
+
needsComma = true;
|
|
1947
|
+
}
|
|
1948
|
+
onArrayEnd();
|
|
1949
|
+
if (_scanner.getToken() !== 4 ) {
|
|
1950
|
+
handleError(8 , [4 ], []);
|
|
1951
|
+
}
|
|
1952
|
+
else {
|
|
1953
|
+
scanNext();
|
|
1954
|
+
}
|
|
1955
|
+
return true;
|
|
1956
|
+
}
|
|
1957
|
+
function parseValue() {
|
|
1958
|
+
switch (_scanner.getToken()) {
|
|
1959
|
+
case 3 :
|
|
1960
|
+
return parseArray();
|
|
1961
|
+
case 1 :
|
|
1962
|
+
return parseObject();
|
|
1963
|
+
case 10 :
|
|
1964
|
+
return parseString(true);
|
|
1965
|
+
default:
|
|
1966
|
+
return parseLiteral();
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
scanNext();
|
|
1970
|
+
if (_scanner.getToken() === 17 ) {
|
|
1971
|
+
if (options.allowEmptyContent) {
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
handleError(4 , [], []);
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
if (!parseValue()) {
|
|
1978
|
+
handleError(4 , [], []);
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
if (_scanner.getToken() !== 17 ) {
|
|
1982
|
+
handleError(9 , [], []);
|
|
1983
|
+
}
|
|
1984
|
+
return true;
|
|
1985
|
+
}
|
|
1986
|
+
class ConfigurationModel {
|
|
1987
|
+
constructor(_contents = {}, _keys = [], _overrides = []) {
|
|
1988
|
+
this._contents = _contents;
|
|
1989
|
+
this._keys = _keys;
|
|
1990
|
+
this._overrides = _overrides;
|
|
1991
|
+
this.isFrozen = false;
|
|
1992
|
+
this.overrideConfigurations = new Map();
|
|
1993
|
+
}
|
|
1994
|
+
get contents() {
|
|
1995
|
+
return this.checkAndFreeze(this._contents);
|
|
1996
|
+
}
|
|
1997
|
+
get overrides() {
|
|
1998
|
+
return this.checkAndFreeze(this._overrides);
|
|
1999
|
+
}
|
|
2000
|
+
get keys() {
|
|
2001
|
+
return this.checkAndFreeze(this._keys);
|
|
2002
|
+
}
|
|
2003
|
+
isEmpty() {
|
|
2004
|
+
return this._keys.length === 0 && Object.keys(this._contents).length === 0 && this._overrides.length === 0;
|
|
2005
|
+
}
|
|
2006
|
+
getValue(section) {
|
|
2007
|
+
return section ? getConfigurationValue(this.contents, section) : this.contents;
|
|
2008
|
+
}
|
|
2009
|
+
getOverrideValue(section, overrideIdentifier) {
|
|
2010
|
+
const overrideContents = this.getContentsForOverrideIdentifer(overrideIdentifier);
|
|
2011
|
+
return overrideContents
|
|
2012
|
+
? section ? getConfigurationValue(overrideContents, section) : overrideContents
|
|
2013
|
+
: undefined;
|
|
2014
|
+
}
|
|
2015
|
+
getKeysForOverrideIdentifier(identifier) {
|
|
2016
|
+
const keys = [];
|
|
2017
|
+
for (const override of this.overrides) {
|
|
2018
|
+
if (override.identifiers.includes(identifier)) {
|
|
2019
|
+
keys.push(...override.keys);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
return distinct(keys);
|
|
2023
|
+
}
|
|
2024
|
+
getAllOverrideIdentifiers() {
|
|
2025
|
+
const result = [];
|
|
2026
|
+
for (const override of this.overrides) {
|
|
2027
|
+
result.push(...override.identifiers);
|
|
2028
|
+
}
|
|
2029
|
+
return distinct(result);
|
|
2030
|
+
}
|
|
2031
|
+
override(identifier) {
|
|
2032
|
+
let overrideConfigurationModel = this.overrideConfigurations.get(identifier);
|
|
2033
|
+
if (!overrideConfigurationModel) {
|
|
2034
|
+
overrideConfigurationModel = this.createOverrideConfigurationModel(identifier);
|
|
2035
|
+
this.overrideConfigurations.set(identifier, overrideConfigurationModel);
|
|
2036
|
+
}
|
|
2037
|
+
return overrideConfigurationModel;
|
|
2038
|
+
}
|
|
2039
|
+
merge(...others) {
|
|
2040
|
+
const contents = deepClone(this.contents);
|
|
2041
|
+
const overrides = deepClone(this.overrides);
|
|
2042
|
+
const keys = [...this.keys];
|
|
2043
|
+
for (const other of others) {
|
|
2044
|
+
this.mergeContents(contents, other.contents);
|
|
2045
|
+
for (const otherOverride of other.overrides) {
|
|
2046
|
+
const [override] = overrides.filter(o => equals$1(o.identifiers, otherOverride.identifiers));
|
|
2047
|
+
if (override) {
|
|
2048
|
+
this.mergeContents(override.contents, otherOverride.contents);
|
|
2049
|
+
override.keys.push(...otherOverride.keys);
|
|
2050
|
+
override.keys = distinct(override.keys);
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
overrides.push(deepClone(otherOverride));
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
for (const key of other.keys) {
|
|
2057
|
+
if (keys.indexOf(key) === -1) {
|
|
2058
|
+
keys.push(key);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return (
|
|
2063
|
+
new ConfigurationModel(contents, keys, overrides)
|
|
2064
|
+
);
|
|
2065
|
+
}
|
|
2066
|
+
freeze() {
|
|
2067
|
+
this.isFrozen = true;
|
|
2068
|
+
return this;
|
|
2069
|
+
}
|
|
2070
|
+
createOverrideConfigurationModel(identifier) {
|
|
2071
|
+
const overrideContents = this.getContentsForOverrideIdentifer(identifier);
|
|
2072
|
+
if (!overrideContents || typeof overrideContents !== 'object' || !Object.keys(overrideContents).length) {
|
|
2073
|
+
return this;
|
|
2074
|
+
}
|
|
2075
|
+
let contents = {};
|
|
2076
|
+
for (const key of distinct([...Object.keys(this.contents), ...Object.keys(overrideContents)])) {
|
|
2077
|
+
let contentsForKey = this.contents[key];
|
|
2078
|
+
let overrideContentsForKey = overrideContents[key];
|
|
2079
|
+
if (overrideContentsForKey) {
|
|
2080
|
+
if (typeof contentsForKey === 'object' && typeof overrideContentsForKey === 'object') {
|
|
2081
|
+
contentsForKey = deepClone(contentsForKey);
|
|
2082
|
+
this.mergeContents(contentsForKey, overrideContentsForKey);
|
|
2083
|
+
}
|
|
2084
|
+
else {
|
|
2085
|
+
contentsForKey = overrideContentsForKey;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
contents[key] = contentsForKey;
|
|
2089
|
+
}
|
|
2090
|
+
return (
|
|
2091
|
+
new ConfigurationModel(contents, this.keys, this.overrides)
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
mergeContents(source, target) {
|
|
2095
|
+
for (const key of Object.keys(target)) {
|
|
2096
|
+
if (key in source) {
|
|
2097
|
+
if (isObject(source[key]) && isObject(target[key])) {
|
|
2098
|
+
this.mergeContents(source[key], target[key]);
|
|
2099
|
+
continue;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
source[key] = deepClone(target[key]);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
checkAndFreeze(data) {
|
|
2106
|
+
if (this.isFrozen && !Object.isFrozen(data)) {
|
|
2107
|
+
return deepFreeze(data);
|
|
2108
|
+
}
|
|
2109
|
+
return data;
|
|
2110
|
+
}
|
|
2111
|
+
getContentsForOverrideIdentifer(identifier) {
|
|
2112
|
+
let contentsForIdentifierOnly = null;
|
|
2113
|
+
let contents = null;
|
|
2114
|
+
const mergeContents = (contentsToMerge) => {
|
|
2115
|
+
if (contentsToMerge) {
|
|
2116
|
+
if (contents) {
|
|
2117
|
+
this.mergeContents(contents, contentsToMerge);
|
|
2118
|
+
}
|
|
2119
|
+
else {
|
|
2120
|
+
contents = deepClone(contentsToMerge);
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
};
|
|
2124
|
+
for (const override of this.overrides) {
|
|
2125
|
+
if (equals$1(override.identifiers, [identifier])) {
|
|
2126
|
+
contentsForIdentifierOnly = override.contents;
|
|
2127
|
+
}
|
|
2128
|
+
else if (override.identifiers.includes(identifier)) {
|
|
2129
|
+
mergeContents(override.contents);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
mergeContents(contentsForIdentifierOnly);
|
|
2133
|
+
return contents;
|
|
2134
|
+
}
|
|
2135
|
+
toJSON() {
|
|
2136
|
+
return {
|
|
2137
|
+
contents: this.contents,
|
|
2138
|
+
overrides: this.overrides,
|
|
2139
|
+
keys: this.keys
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
setValue(key, value) {
|
|
2143
|
+
this.addKey(key);
|
|
2144
|
+
addToValueTree(this.contents, key, value, e => { throw new Error(e); });
|
|
2145
|
+
}
|
|
2146
|
+
removeValue(key) {
|
|
2147
|
+
if (this.removeKey(key)) {
|
|
2148
|
+
removeFromValueTree(this.contents, key);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
addKey(key) {
|
|
2152
|
+
let index = this.keys.length;
|
|
2153
|
+
for (let i = 0; i < index; i++) {
|
|
2154
|
+
if (key.indexOf(this.keys[i]) === 0) {
|
|
2155
|
+
index = i;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
this.keys.splice(index, 1, key);
|
|
2159
|
+
}
|
|
2160
|
+
removeKey(key) {
|
|
2161
|
+
let index = this.keys.indexOf(key);
|
|
2162
|
+
if (index !== -1) {
|
|
2163
|
+
this.keys.splice(index, 1);
|
|
2164
|
+
return true;
|
|
2165
|
+
}
|
|
2166
|
+
return false;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
class ConfigurationModelParser {
|
|
2170
|
+
constructor(_name) {
|
|
2171
|
+
this._name = _name;
|
|
2172
|
+
this._raw = null;
|
|
2173
|
+
this._configurationModel = null;
|
|
2174
|
+
this._restrictedConfigurations = [];
|
|
2175
|
+
this._parseErrors = [];
|
|
2176
|
+
}
|
|
2177
|
+
get configurationModel() {
|
|
2178
|
+
return this._configurationModel || new ConfigurationModel();
|
|
2179
|
+
}
|
|
2180
|
+
get restrictedConfigurations() {
|
|
2181
|
+
return this._restrictedConfigurations;
|
|
2182
|
+
}
|
|
2183
|
+
get errors() {
|
|
2184
|
+
return this._parseErrors;
|
|
2185
|
+
}
|
|
2186
|
+
parse(content, options) {
|
|
2187
|
+
if (!isUndefinedOrNull(content)) {
|
|
2188
|
+
const raw = this.doParseContent(content);
|
|
2189
|
+
this.parseRaw(raw, options);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
reparse(options) {
|
|
2193
|
+
if (this._raw) {
|
|
2194
|
+
this.parseRaw(this._raw, options);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
parseRaw(raw, options) {
|
|
2198
|
+
this._raw = raw;
|
|
2199
|
+
const { contents, keys, overrides, restricted } = this.doParseRaw(raw, options);
|
|
2200
|
+
this._configurationModel = new ConfigurationModel(contents, keys, overrides);
|
|
2201
|
+
this._restrictedConfigurations = restricted || [];
|
|
2202
|
+
}
|
|
2203
|
+
doParseContent(content) {
|
|
2204
|
+
let raw = {};
|
|
2205
|
+
let currentProperty = null;
|
|
2206
|
+
let currentParent = [];
|
|
2207
|
+
let previousParents = [];
|
|
2208
|
+
function onValue(value) {
|
|
2209
|
+
if (Array.isArray(currentParent)) {
|
|
2210
|
+
currentParent.push(value);
|
|
2211
|
+
}
|
|
2212
|
+
else if (currentProperty !== null) {
|
|
2213
|
+
currentParent[currentProperty] = value;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
let visitor = {
|
|
2217
|
+
onObjectBegin: () => {
|
|
2218
|
+
let object = {};
|
|
2219
|
+
onValue(object);
|
|
2220
|
+
previousParents.push(currentParent);
|
|
2221
|
+
currentParent = object;
|
|
2222
|
+
currentProperty = null;
|
|
2223
|
+
},
|
|
2224
|
+
onObjectProperty: (name) => {
|
|
2225
|
+
currentProperty = name;
|
|
2226
|
+
},
|
|
2227
|
+
onObjectEnd: () => {
|
|
2228
|
+
currentParent = previousParents.pop();
|
|
2229
|
+
},
|
|
2230
|
+
onArrayBegin: () => {
|
|
2231
|
+
let array = [];
|
|
2232
|
+
onValue(array);
|
|
2233
|
+
previousParents.push(currentParent);
|
|
2234
|
+
currentParent = array;
|
|
2235
|
+
currentProperty = null;
|
|
2236
|
+
},
|
|
2237
|
+
onArrayEnd: () => {
|
|
2238
|
+
currentParent = previousParents.pop();
|
|
2239
|
+
},
|
|
2240
|
+
onLiteralValue: onValue,
|
|
2241
|
+
onError: (error, offset, length) => {
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2244
|
+
if (content) {
|
|
2245
|
+
try {
|
|
2246
|
+
visit(content, visitor);
|
|
2247
|
+
raw = currentParent[0] || {};
|
|
2248
|
+
}
|
|
2249
|
+
catch (e) {
|
|
2250
|
+
console.error(`Error while parsing settings file ${this._name}: ${e}`);
|
|
2251
|
+
this._parseErrors = [e];
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
return raw;
|
|
2255
|
+
}
|
|
2256
|
+
doParseRaw(raw, options) {
|
|
2257
|
+
const configurationProperties = Registry.as(Extensions.Configuration).getConfigurationProperties();
|
|
2258
|
+
const filtered = this.filter(raw, configurationProperties, true, options);
|
|
2259
|
+
raw = filtered.raw;
|
|
2260
|
+
const contents = toValuesTree(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2261
|
+
const keys = Object.keys(raw);
|
|
2262
|
+
const overrides = this.toOverrides(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2263
|
+
return { contents, keys, overrides, restricted: filtered.restricted };
|
|
2264
|
+
}
|
|
2265
|
+
filter(properties, configurationProperties, filterOverriddenProperties, options) {
|
|
2266
|
+
if (!options?.scopes && !options?.skipRestricted) {
|
|
2267
|
+
return { raw: properties, restricted: [] };
|
|
2268
|
+
}
|
|
2269
|
+
const raw = {};
|
|
2270
|
+
const restricted = [];
|
|
2271
|
+
for (let key in properties) {
|
|
2272
|
+
if (OVERRIDE_PROPERTY_REGEX.test(key) && filterOverriddenProperties) {
|
|
2273
|
+
const result = this.filter(properties[key], configurationProperties, false, options);
|
|
2274
|
+
raw[key] = result.raw;
|
|
2275
|
+
restricted.push(...result.restricted);
|
|
2276
|
+
}
|
|
2277
|
+
else {
|
|
2278
|
+
const propertySchema = configurationProperties[key];
|
|
2279
|
+
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3 : undefined;
|
|
2280
|
+
if (propertySchema?.restricted) {
|
|
2281
|
+
restricted.push(key);
|
|
2282
|
+
}
|
|
2283
|
+
if (scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) {
|
|
2284
|
+
if (!(options.skipRestricted && propertySchema?.restricted)) {
|
|
2285
|
+
raw[key] = properties[key];
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
return { raw, restricted };
|
|
2291
|
+
}
|
|
2292
|
+
toOverrides(raw, conflictReporter) {
|
|
2293
|
+
const overrides = [];
|
|
2294
|
+
for (const key of Object.keys(raw)) {
|
|
2295
|
+
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
2296
|
+
const overrideRaw = {};
|
|
2297
|
+
for (const keyInOverrideRaw in raw[key]) {
|
|
2298
|
+
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
|
|
2299
|
+
}
|
|
2300
|
+
overrides.push({
|
|
2301
|
+
identifiers: overrideIdentifiersFromKey(key),
|
|
2302
|
+
keys: Object.keys(overrideRaw),
|
|
2303
|
+
contents: toValuesTree(overrideRaw, conflictReporter)
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
return overrides;
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
class UserSettings extends Disposable {
|
|
2311
|
+
constructor(userSettingsResource, scopes, extUri, fileService) {
|
|
2312
|
+
super();
|
|
2313
|
+
this.userSettingsResource = userSettingsResource;
|
|
2314
|
+
this.scopes = scopes;
|
|
2315
|
+
this.fileService = fileService;
|
|
2316
|
+
this._onDidChange = this._register( new Emitter());
|
|
2317
|
+
this.onDidChange = this._onDidChange.event;
|
|
2318
|
+
this.parser = new ConfigurationModelParser(this.userSettingsResource.toString());
|
|
2319
|
+
this.parseOptions = { scopes: this.scopes };
|
|
2320
|
+
this._register(this.fileService.watch(extUri.dirname(this.userSettingsResource)));
|
|
2321
|
+
this._register(this.fileService.watch(this.userSettingsResource));
|
|
2322
|
+
this._register(Event.any(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.userSettingsResource)), Event.filter(this.fileService.onDidRunOperation, e => (e.isOperation(0 ) || e.isOperation(1 ) || e.isOperation(4 )) && extUri.isEqual(e.resource, userSettingsResource)))(() => this._onDidChange.fire()));
|
|
2323
|
+
}
|
|
2324
|
+
async loadConfiguration() {
|
|
2325
|
+
try {
|
|
2326
|
+
const content = await this.fileService.readFile(this.userSettingsResource);
|
|
2327
|
+
this.parser.parse(content.value.toString() || '{}', this.parseOptions);
|
|
2328
|
+
return this.parser.configurationModel;
|
|
2329
|
+
}
|
|
2330
|
+
catch (e) {
|
|
2331
|
+
return (
|
|
2332
|
+
new ConfigurationModel()
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
reparse() {
|
|
2337
|
+
this.parser.reparse(this.parseOptions);
|
|
2338
|
+
return this.parser.configurationModel;
|
|
2339
|
+
}
|
|
2340
|
+
getRestrictedSettings() {
|
|
2341
|
+
return this.parser.restrictedConfigurations;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
class Configuration {
|
|
2345
|
+
constructor(_defaultConfiguration, _localUserConfiguration, _remoteUserConfiguration = new ConfigurationModel(), _workspaceConfiguration = new ConfigurationModel(), _folderConfigurations = new ResourceMap(), _memoryConfiguration = new ConfigurationModel(), _memoryConfigurationByResource = new ResourceMap(), _freeze = true) {
|
|
2346
|
+
this._defaultConfiguration = _defaultConfiguration;
|
|
2347
|
+
this._localUserConfiguration = _localUserConfiguration;
|
|
2348
|
+
this._remoteUserConfiguration = _remoteUserConfiguration;
|
|
2349
|
+
this._workspaceConfiguration = _workspaceConfiguration;
|
|
2350
|
+
this._folderConfigurations = _folderConfigurations;
|
|
2351
|
+
this._memoryConfiguration = _memoryConfiguration;
|
|
2352
|
+
this._memoryConfigurationByResource = _memoryConfigurationByResource;
|
|
2353
|
+
this._freeze = _freeze;
|
|
2354
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2355
|
+
this._foldersConsolidatedConfigurations = new ResourceMap();
|
|
2356
|
+
this._userConfiguration = null;
|
|
2357
|
+
}
|
|
2358
|
+
getValue(section, overrides, workspace) {
|
|
2359
|
+
const consolidateConfigurationModel = this.getConsolidateConfigurationModel(overrides, workspace);
|
|
2360
|
+
return consolidateConfigurationModel.getValue(section);
|
|
2361
|
+
}
|
|
2362
|
+
updateValue(key, value, overrides = {}) {
|
|
2363
|
+
let memoryConfiguration;
|
|
2364
|
+
if (overrides.resource) {
|
|
2365
|
+
memoryConfiguration = this._memoryConfigurationByResource.get(overrides.resource);
|
|
2366
|
+
if (!memoryConfiguration) {
|
|
2367
|
+
memoryConfiguration = new ConfigurationModel();
|
|
2368
|
+
this._memoryConfigurationByResource.set(overrides.resource, memoryConfiguration);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
else {
|
|
2372
|
+
memoryConfiguration = this._memoryConfiguration;
|
|
2373
|
+
}
|
|
2374
|
+
if (value === undefined) {
|
|
2375
|
+
memoryConfiguration.removeValue(key);
|
|
2376
|
+
}
|
|
2377
|
+
else {
|
|
2378
|
+
memoryConfiguration.setValue(key, value);
|
|
2379
|
+
}
|
|
2380
|
+
if (!overrides.resource) {
|
|
2381
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
inspect(key, overrides, workspace) {
|
|
2385
|
+
const consolidateConfigurationModel = this.getConsolidateConfigurationModel(overrides, workspace);
|
|
2386
|
+
const folderConfigurationModel = this.getFolderConfigurationModelForResource(overrides.resource, workspace);
|
|
2387
|
+
const memoryConfigurationModel = overrides.resource ? this._memoryConfigurationByResource.get(overrides.resource) || this._memoryConfiguration : this._memoryConfiguration;
|
|
2388
|
+
const defaultValue = overrides.overrideIdentifier ? this._defaultConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._defaultConfiguration.freeze().getValue(key);
|
|
2389
|
+
const userValue = overrides.overrideIdentifier ? this.userConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.userConfiguration.freeze().getValue(key);
|
|
2390
|
+
const userLocalValue = overrides.overrideIdentifier ? this.localUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.localUserConfiguration.freeze().getValue(key);
|
|
2391
|
+
const userRemoteValue = overrides.overrideIdentifier ? this.remoteUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.remoteUserConfiguration.freeze().getValue(key);
|
|
2392
|
+
const workspaceValue = workspace ? overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._workspaceConfiguration.freeze().getValue(key) : undefined;
|
|
2393
|
+
const workspaceFolderValue = folderConfigurationModel ? overrides.overrideIdentifier ? folderConfigurationModel.freeze().override(overrides.overrideIdentifier).getValue(key) : folderConfigurationModel.freeze().getValue(key) : undefined;
|
|
2394
|
+
const memoryValue = overrides.overrideIdentifier ? memoryConfigurationModel.override(overrides.overrideIdentifier).getValue(key) : memoryConfigurationModel.getValue(key);
|
|
2395
|
+
const value = consolidateConfigurationModel.getValue(key);
|
|
2396
|
+
const overrideIdentifiers = distinct(flatten(consolidateConfigurationModel.overrides.map(override => override.identifiers))).filter(overrideIdentifier => consolidateConfigurationModel.getOverrideValue(key, overrideIdentifier) !== undefined);
|
|
2397
|
+
return {
|
|
2398
|
+
defaultValue: defaultValue,
|
|
2399
|
+
userValue: userValue,
|
|
2400
|
+
userLocalValue: userLocalValue,
|
|
2401
|
+
userRemoteValue: userRemoteValue,
|
|
2402
|
+
workspaceValue: workspaceValue,
|
|
2403
|
+
workspaceFolderValue: workspaceFolderValue,
|
|
2404
|
+
memoryValue: memoryValue,
|
|
2405
|
+
value,
|
|
2406
|
+
default: defaultValue !== undefined ? { value: this._defaultConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this._defaultConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2407
|
+
user: userValue !== undefined ? { value: this.userConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.userConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2408
|
+
userLocal: userLocalValue !== undefined ? { value: this.localUserConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.localUserConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2409
|
+
userRemote: userRemoteValue !== undefined ? { value: this.remoteUserConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.remoteUserConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2410
|
+
workspace: workspaceValue !== undefined ? { value: this._workspaceConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2411
|
+
workspaceFolder: workspaceFolderValue !== undefined ? { value: folderConfigurationModel?.freeze().getValue(key), override: overrides.overrideIdentifier ? folderConfigurationModel?.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2412
|
+
memory: memoryValue !== undefined ? { value: memoryConfigurationModel.getValue(key), override: overrides.overrideIdentifier ? memoryConfigurationModel.getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
|
|
2413
|
+
overrideIdentifiers: overrideIdentifiers.length ? overrideIdentifiers : undefined
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
keys(workspace) {
|
|
2417
|
+
const folderConfigurationModel = this.getFolderConfigurationModelForResource(undefined, workspace);
|
|
2418
|
+
return {
|
|
2419
|
+
default: this._defaultConfiguration.freeze().keys,
|
|
2420
|
+
user: this.userConfiguration.freeze().keys,
|
|
2421
|
+
workspace: this._workspaceConfiguration.freeze().keys,
|
|
2422
|
+
workspaceFolder: folderConfigurationModel ? folderConfigurationModel.freeze().keys : []
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2425
|
+
updateDefaultConfiguration(defaultConfiguration) {
|
|
2426
|
+
this._defaultConfiguration = defaultConfiguration;
|
|
2427
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2428
|
+
this._foldersConsolidatedConfigurations.clear();
|
|
2429
|
+
}
|
|
2430
|
+
updateLocalUserConfiguration(localUserConfiguration) {
|
|
2431
|
+
this._localUserConfiguration = localUserConfiguration;
|
|
2432
|
+
this._userConfiguration = null;
|
|
2433
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2434
|
+
this._foldersConsolidatedConfigurations.clear();
|
|
2435
|
+
}
|
|
2436
|
+
updateRemoteUserConfiguration(remoteUserConfiguration) {
|
|
2437
|
+
this._remoteUserConfiguration = remoteUserConfiguration;
|
|
2438
|
+
this._userConfiguration = null;
|
|
2439
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2440
|
+
this._foldersConsolidatedConfigurations.clear();
|
|
2441
|
+
}
|
|
2442
|
+
updateWorkspaceConfiguration(workspaceConfiguration) {
|
|
2443
|
+
this._workspaceConfiguration = workspaceConfiguration;
|
|
2444
|
+
this._workspaceConsolidatedConfiguration = null;
|
|
2445
|
+
this._foldersConsolidatedConfigurations.clear();
|
|
2446
|
+
}
|
|
2447
|
+
updateFolderConfiguration(resource, configuration) {
|
|
2448
|
+
this._folderConfigurations.set(resource, configuration);
|
|
2449
|
+
this._foldersConsolidatedConfigurations.delete(resource);
|
|
2450
|
+
}
|
|
2451
|
+
deleteFolderConfiguration(resource) {
|
|
2452
|
+
this.folderConfigurations.delete(resource);
|
|
2453
|
+
this._foldersConsolidatedConfigurations.delete(resource);
|
|
2454
|
+
}
|
|
2455
|
+
compareAndUpdateDefaultConfiguration(defaults, keys) {
|
|
2456
|
+
const overrides = [];
|
|
2457
|
+
if (!keys) {
|
|
2458
|
+
const { added, updated, removed } = compare(this._defaultConfiguration, defaults);
|
|
2459
|
+
keys = [...added, ...updated, ...removed];
|
|
2460
|
+
}
|
|
2461
|
+
for (const key of keys) {
|
|
2462
|
+
for (const overrideIdentifier of overrideIdentifiersFromKey(key)) {
|
|
2463
|
+
const fromKeys = this._defaultConfiguration.getKeysForOverrideIdentifier(overrideIdentifier);
|
|
2464
|
+
const toKeys = defaults.getKeysForOverrideIdentifier(overrideIdentifier);
|
|
2465
|
+
const keys = [
|
|
2466
|
+
...toKeys.filter(key => fromKeys.indexOf(key) === -1),
|
|
2467
|
+
...fromKeys.filter(key => toKeys.indexOf(key) === -1),
|
|
2468
|
+
...fromKeys.filter(key => !equals(this._defaultConfiguration.override(overrideIdentifier).getValue(key), defaults.override(overrideIdentifier).getValue(key)))
|
|
2469
|
+
];
|
|
2470
|
+
overrides.push([overrideIdentifier, keys]);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
this.updateDefaultConfiguration(defaults);
|
|
2474
|
+
return { keys, overrides };
|
|
2475
|
+
}
|
|
2476
|
+
compareAndUpdateLocalUserConfiguration(user) {
|
|
2477
|
+
const { added, updated, removed, overrides } = compare(this.localUserConfiguration, user);
|
|
2478
|
+
const keys = [...added, ...updated, ...removed];
|
|
2479
|
+
if (keys.length) {
|
|
2480
|
+
this.updateLocalUserConfiguration(user);
|
|
2481
|
+
}
|
|
2482
|
+
return { keys, overrides };
|
|
2483
|
+
}
|
|
2484
|
+
compareAndUpdateRemoteUserConfiguration(user) {
|
|
2485
|
+
const { added, updated, removed, overrides } = compare(this.remoteUserConfiguration, user);
|
|
2486
|
+
let keys = [...added, ...updated, ...removed];
|
|
2487
|
+
if (keys.length) {
|
|
2488
|
+
this.updateRemoteUserConfiguration(user);
|
|
2489
|
+
}
|
|
2490
|
+
return { keys, overrides };
|
|
2491
|
+
}
|
|
2492
|
+
compareAndUpdateWorkspaceConfiguration(workspaceConfiguration) {
|
|
2493
|
+
const { added, updated, removed, overrides } = compare(this.workspaceConfiguration, workspaceConfiguration);
|
|
2494
|
+
let keys = [...added, ...updated, ...removed];
|
|
2495
|
+
if (keys.length) {
|
|
2496
|
+
this.updateWorkspaceConfiguration(workspaceConfiguration);
|
|
2497
|
+
}
|
|
2498
|
+
return { keys, overrides };
|
|
2499
|
+
}
|
|
2500
|
+
compareAndUpdateFolderConfiguration(resource, folderConfiguration) {
|
|
2501
|
+
const currentFolderConfiguration = this.folderConfigurations.get(resource);
|
|
2502
|
+
const { added, updated, removed, overrides } = compare(currentFolderConfiguration, folderConfiguration);
|
|
2503
|
+
let keys = [...added, ...updated, ...removed];
|
|
2504
|
+
if (keys.length || !currentFolderConfiguration) {
|
|
2505
|
+
this.updateFolderConfiguration(resource, folderConfiguration);
|
|
2506
|
+
}
|
|
2507
|
+
return { keys, overrides };
|
|
2508
|
+
}
|
|
2509
|
+
compareAndDeleteFolderConfiguration(folder) {
|
|
2510
|
+
const folderConfig = this.folderConfigurations.get(folder);
|
|
2511
|
+
if (!folderConfig) {
|
|
2512
|
+
throw new Error('Unknown folder');
|
|
2513
|
+
}
|
|
2514
|
+
this.deleteFolderConfiguration(folder);
|
|
2515
|
+
const { added, updated, removed, overrides } = compare(folderConfig, undefined);
|
|
2516
|
+
return { keys: [...added, ...updated, ...removed], overrides };
|
|
2517
|
+
}
|
|
2518
|
+
get defaults() {
|
|
2519
|
+
return this._defaultConfiguration;
|
|
2520
|
+
}
|
|
2521
|
+
get userConfiguration() {
|
|
2522
|
+
if (!this._userConfiguration) {
|
|
2523
|
+
this._userConfiguration = this._remoteUserConfiguration.isEmpty() ? this._localUserConfiguration : this._localUserConfiguration.merge(this._remoteUserConfiguration);
|
|
2524
|
+
if (this._freeze) {
|
|
2525
|
+
this._userConfiguration.freeze();
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
return this._userConfiguration;
|
|
2529
|
+
}
|
|
2530
|
+
get localUserConfiguration() {
|
|
2531
|
+
return this._localUserConfiguration;
|
|
2532
|
+
}
|
|
2533
|
+
get remoteUserConfiguration() {
|
|
2534
|
+
return this._remoteUserConfiguration;
|
|
2535
|
+
}
|
|
2536
|
+
get workspaceConfiguration() {
|
|
2537
|
+
return this._workspaceConfiguration;
|
|
2538
|
+
}
|
|
2539
|
+
get folderConfigurations() {
|
|
2540
|
+
return this._folderConfigurations;
|
|
2541
|
+
}
|
|
2542
|
+
getConsolidateConfigurationModel(overrides, workspace) {
|
|
2543
|
+
let configurationModel = this.getConsolidatedConfigurationModelForResource(overrides, workspace);
|
|
2544
|
+
return overrides.overrideIdentifier ? configurationModel.override(overrides.overrideIdentifier) : configurationModel;
|
|
2545
|
+
}
|
|
2546
|
+
getConsolidatedConfigurationModelForResource({ resource }, workspace) {
|
|
2547
|
+
let consolidateConfiguration = this.getWorkspaceConsolidatedConfiguration();
|
|
2548
|
+
if (workspace && resource) {
|
|
2549
|
+
const root = workspace.getFolder(resource);
|
|
2550
|
+
if (root) {
|
|
2551
|
+
consolidateConfiguration = this.getFolderConsolidatedConfiguration(root.uri) || consolidateConfiguration;
|
|
2552
|
+
}
|
|
2553
|
+
const memoryConfigurationForResource = this._memoryConfigurationByResource.get(resource);
|
|
2554
|
+
if (memoryConfigurationForResource) {
|
|
2555
|
+
consolidateConfiguration = consolidateConfiguration.merge(memoryConfigurationForResource);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return consolidateConfiguration;
|
|
2559
|
+
}
|
|
2560
|
+
getWorkspaceConsolidatedConfiguration() {
|
|
2561
|
+
if (!this._workspaceConsolidatedConfiguration) {
|
|
2562
|
+
this._workspaceConsolidatedConfiguration = this._defaultConfiguration.merge(this.userConfiguration, this._workspaceConfiguration, this._memoryConfiguration);
|
|
2563
|
+
if (this._freeze) {
|
|
2564
|
+
this._workspaceConfiguration = this._workspaceConfiguration.freeze();
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
return this._workspaceConsolidatedConfiguration;
|
|
2568
|
+
}
|
|
2569
|
+
getFolderConsolidatedConfiguration(folder) {
|
|
2570
|
+
let folderConsolidatedConfiguration = this._foldersConsolidatedConfigurations.get(folder);
|
|
2571
|
+
if (!folderConsolidatedConfiguration) {
|
|
2572
|
+
const workspaceConsolidateConfiguration = this.getWorkspaceConsolidatedConfiguration();
|
|
2573
|
+
const folderConfiguration = this._folderConfigurations.get(folder);
|
|
2574
|
+
if (folderConfiguration) {
|
|
2575
|
+
folderConsolidatedConfiguration = workspaceConsolidateConfiguration.merge(folderConfiguration);
|
|
2576
|
+
if (this._freeze) {
|
|
2577
|
+
folderConsolidatedConfiguration = folderConsolidatedConfiguration.freeze();
|
|
2578
|
+
}
|
|
2579
|
+
this._foldersConsolidatedConfigurations.set(folder, folderConsolidatedConfiguration);
|
|
2580
|
+
}
|
|
2581
|
+
else {
|
|
2582
|
+
folderConsolidatedConfiguration = workspaceConsolidateConfiguration;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
return folderConsolidatedConfiguration;
|
|
2586
|
+
}
|
|
2587
|
+
getFolderConfigurationModelForResource(resource, workspace) {
|
|
2588
|
+
if (workspace && resource) {
|
|
2589
|
+
const root = workspace.getFolder(resource);
|
|
2590
|
+
if (root) {
|
|
2591
|
+
return this._folderConfigurations.get(root.uri);
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
return undefined;
|
|
2595
|
+
}
|
|
2596
|
+
toData() {
|
|
2597
|
+
return {
|
|
2598
|
+
defaults: {
|
|
2599
|
+
contents: this._defaultConfiguration.contents,
|
|
2600
|
+
overrides: this._defaultConfiguration.overrides,
|
|
2601
|
+
keys: this._defaultConfiguration.keys
|
|
2602
|
+
},
|
|
2603
|
+
user: {
|
|
2604
|
+
contents: this.userConfiguration.contents,
|
|
2605
|
+
overrides: this.userConfiguration.overrides,
|
|
2606
|
+
keys: this.userConfiguration.keys
|
|
2607
|
+
},
|
|
2608
|
+
workspace: {
|
|
2609
|
+
contents: this._workspaceConfiguration.contents,
|
|
2610
|
+
overrides: this._workspaceConfiguration.overrides,
|
|
2611
|
+
keys: this._workspaceConfiguration.keys
|
|
2612
|
+
},
|
|
2613
|
+
folders: [...this._folderConfigurations.keys()].reduce((result, folder) => {
|
|
2614
|
+
const { contents, overrides, keys } = this._folderConfigurations.get(folder);
|
|
2615
|
+
result.push([folder, { contents, overrides, keys }]);
|
|
2616
|
+
return result;
|
|
2617
|
+
}, [])
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
allKeys() {
|
|
2621
|
+
const keys = new Set();
|
|
2622
|
+
this._defaultConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
2623
|
+
this.userConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
2624
|
+
this._workspaceConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
2625
|
+
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().keys.forEach(key => keys.add(key)));
|
|
2626
|
+
return [...keys.values()];
|
|
2627
|
+
}
|
|
2628
|
+
allOverrideIdentifiers() {
|
|
2629
|
+
const keys = new Set();
|
|
2630
|
+
this._defaultConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
2631
|
+
this.userConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
2632
|
+
this._workspaceConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
2633
|
+
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key)));
|
|
2634
|
+
return [...keys.values()];
|
|
2635
|
+
}
|
|
2636
|
+
getAllKeysForOverrideIdentifier(overrideIdentifier) {
|
|
2637
|
+
const keys = new Set();
|
|
2638
|
+
this._defaultConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
2639
|
+
this.userConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
2640
|
+
this._workspaceConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
2641
|
+
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key)));
|
|
2642
|
+
return [...keys.values()];
|
|
2643
|
+
}
|
|
2644
|
+
static parse(data) {
|
|
2645
|
+
const defaultConfiguration = this.parseConfigurationModel(data.defaults);
|
|
2646
|
+
const userConfiguration = this.parseConfigurationModel(data.user);
|
|
2647
|
+
const workspaceConfiguration = this.parseConfigurationModel(data.workspace);
|
|
2648
|
+
const folders = data.folders.reduce((result, value) => {
|
|
2649
|
+
result.set(URI.revive(value[0]), this.parseConfigurationModel(value[1]));
|
|
2650
|
+
return result;
|
|
2651
|
+
}, new ResourceMap());
|
|
2652
|
+
return (
|
|
2653
|
+
new Configuration(defaultConfiguration, userConfiguration, new ConfigurationModel(), workspaceConfiguration, folders, new ConfigurationModel(), new ResourceMap(), false)
|
|
2654
|
+
);
|
|
2655
|
+
}
|
|
2656
|
+
static parseConfigurationModel(model) {
|
|
2657
|
+
return (
|
|
2658
|
+
new ConfigurationModel(model.contents, model.keys, model.overrides).freeze()
|
|
2659
|
+
);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
function compare(from, to) {
|
|
2663
|
+
const { added, removed, updated } = compareConfigurationContents(to, from);
|
|
2664
|
+
const overrides = [];
|
|
2665
|
+
const fromOverrideIdentifiers = from?.getAllOverrideIdentifiers() || [];
|
|
2666
|
+
const toOverrideIdentifiers = to?.getAllOverrideIdentifiers() || [];
|
|
2667
|
+
if (to) {
|
|
2668
|
+
const addedOverrideIdentifiers = toOverrideIdentifiers.filter(key => !fromOverrideIdentifiers.includes(key));
|
|
2669
|
+
for (const identifier of addedOverrideIdentifiers) {
|
|
2670
|
+
overrides.push([identifier, to.getKeysForOverrideIdentifier(identifier)]);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
if (from) {
|
|
2674
|
+
const removedOverrideIdentifiers = fromOverrideIdentifiers.filter(key => !toOverrideIdentifiers.includes(key));
|
|
2675
|
+
for (const identifier of removedOverrideIdentifiers) {
|
|
2676
|
+
overrides.push([identifier, from.getKeysForOverrideIdentifier(identifier)]);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
if (to && from) {
|
|
2680
|
+
for (const identifier of fromOverrideIdentifiers) {
|
|
2681
|
+
if (toOverrideIdentifiers.includes(identifier)) {
|
|
2682
|
+
const result = compareConfigurationContents({ contents: from.getOverrideValue(undefined, identifier) || {}, keys: from.getKeysForOverrideIdentifier(identifier) }, { contents: to.getOverrideValue(undefined, identifier) || {}, keys: to.getKeysForOverrideIdentifier(identifier) });
|
|
2683
|
+
overrides.push([identifier, [...result.added, ...result.removed, ...result.updated]]);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
return { added, removed, updated, overrides };
|
|
2688
|
+
}
|
|
2689
|
+
function compareConfigurationContents(to, from) {
|
|
2690
|
+
const added = to
|
|
2691
|
+
? from ? to.keys.filter(key => from.keys.indexOf(key) === -1) : [...to.keys]
|
|
2692
|
+
: [];
|
|
2693
|
+
const removed = from
|
|
2694
|
+
? to ? from.keys.filter(key => to.keys.indexOf(key) === -1) : [...from.keys]
|
|
2695
|
+
: [];
|
|
2696
|
+
const updated = [];
|
|
2697
|
+
if (to && from) {
|
|
2698
|
+
for (const key of from.keys) {
|
|
2699
|
+
if (to.keys.indexOf(key) !== -1) {
|
|
2700
|
+
const value1 = getConfigurationValue(from.contents, key);
|
|
2701
|
+
const value2 = getConfigurationValue(to.contents, key);
|
|
2702
|
+
if (!equals(value1, value2)) {
|
|
2703
|
+
updated.push(key);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
return { added, removed, updated };
|
|
2709
|
+
}
|
|
2710
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2711
|
+
Object.defineProperties(Configuration$1.prototype, Object.getOwnPropertyDescriptors(Configuration.prototype));
|
|
2712
|
+
Object.defineProperties(TernarySearchTree$1.prototype, Object.getOwnPropertyDescriptors(TernarySearchTree.prototype));
|
|
2713
|
+
(_a = StandaloneConfigurationService.prototype).getConfigurationData ?? (_a.getConfigurationData = () => {
|
|
2714
|
+
const emptyModel = {
|
|
2715
|
+
contents: {},
|
|
2716
|
+
keys: [],
|
|
2717
|
+
overrides: []
|
|
2718
|
+
};
|
|
2719
|
+
return {
|
|
2720
|
+
defaults: emptyModel,
|
|
2721
|
+
user: emptyModel,
|
|
2722
|
+
workspace: emptyModel,
|
|
2723
|
+
folders: []
|
|
2724
|
+
};
|
|
2725
|
+
});
|
|
2726
|
+
const configurationRegistry = Registry.as(Extensions.Configuration);
|
|
2727
|
+
configurationRegistry.onDidUpdateConfiguration ?? (configurationRegistry.onDidUpdateConfiguration = configurationRegistry._onDidUpdateConfiguration.event);
|
|
2728
|
+
(_b = NoOpNotification.prototype).onDidClose ?? (_b.onDidClose = Event.None);
|
|
2729
|
+
Object.defineProperties(NoOpNotification.prototype, Object.getOwnPropertyDescriptors(NoOpNotification$1.prototype));
|
|
2730
|
+
(_c = LanguageService$1.prototype).getRegisteredLanguageIds ?? (_c.getRegisteredLanguageIds = LanguageService.prototype.getRegisteredLanguageIds);
|
|
2731
|
+
(_d = ProgressBar$1.prototype).hide ?? (_d.hide = ProgressBar.prototype.hide);
|
|
2732
|
+
(_e = Themable$1.prototype)['getColor'] ?? (_e['getColor'] = Themable.prototype['getColor']);
|
|
2733
|
+
function polyfillQuickInput(fn) {
|
|
2734
|
+
return function () {
|
|
2735
|
+
const quickInput = fn.call(this);
|
|
2736
|
+
quickInput.onDidTriggerButton ?? (quickInput.onDidTriggerButton = quickInput.onDidTriggerButtonEmitter.event);
|
|
2737
|
+
return quickInput;
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
QuickInputController.prototype.createQuickPick = polyfillQuickInput(QuickInputController.prototype.createQuickPick);
|
|
2741
|
+
QuickInputController.prototype.createInputBox = polyfillQuickInput(QuickInputController.prototype.createInputBox);
|
|
2742
|
+
const StandaloneUriLabelService = getSingletonServiceDescriptors().find(([id]) => id === ILabelService)[1].ctor;
|
|
2743
|
+
(_f = StandaloneUriLabelService.prototype).onDidChangeFormatters ?? (_f.onDidChangeFormatters = Event.None);
|
|
2744
|
+
function toVSCodeVSBuffer(value) {
|
|
2745
|
+
if (value instanceof VSBuffer$1) {
|
|
2746
|
+
return VSBuffer.wrap(value.buffer);
|
|
2747
|
+
}
|
|
2748
|
+
return value;
|
|
2749
|
+
}
|
|
2750
|
+
function toMonacoVSBuffer(value) {
|
|
2751
|
+
if (value instanceof VSBuffer) {
|
|
2752
|
+
return VSBuffer$1.wrap(value.buffer);
|
|
2753
|
+
}
|
|
2754
|
+
return value;
|
|
2755
|
+
}
|
|
2756
|
+
for (const key of Object.getOwnPropertyNames(VSBuffer)) {
|
|
2757
|
+
if (!Object.hasOwnProperty.call(VSBuffer$1, key)) {
|
|
2758
|
+
const method = VSBuffer[key];
|
|
2759
|
+
VSBuffer[key] = VSBuffer$1[key] = function (...args) {
|
|
2760
|
+
return toMonacoVSBuffer(method.call(VSBuffer$1, ...args.map(toVSCodeVSBuffer)));
|
|
2761
|
+
};
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
for (const key of Object.getOwnPropertyNames(VSBuffer.prototype)) {
|
|
2765
|
+
if (!Object.hasOwnProperty.call(VSBuffer$1.prototype, key)) {
|
|
2766
|
+
VSBuffer$1.prototype[key] = function (...args) {
|
|
2767
|
+
return toMonacoVSBuffer(VSBuffer.prototype[key].call(this, ...args.map(toVSCodeVSBuffer)));
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
const ILifecycleService = createDecorator('lifecycleService');
|
|
2772
|
+
const ILanguageDetectionService = createDecorator('ILanguageDetectionService');
|
|
2773
|
+
function unsupported() {
|
|
2774
|
+
throw new Error('unsupported');
|
|
2775
|
+
}
|
|
2776
|
+
registerSingleton(IEditorService, class EditorService {
|
|
2777
|
+
constructor() {
|
|
2778
|
+
this._serviceBrand = undefined;
|
|
2779
|
+
this.onDidActiveEditorChange = Event.None;
|
|
2780
|
+
this.onDidVisibleEditorsChange = Event.None;
|
|
2781
|
+
this.onDidEditorsChange = Event.None;
|
|
2782
|
+
this.onDidCloseEditor = Event.None;
|
|
2783
|
+
this.activeEditorPane = undefined;
|
|
2784
|
+
this.activeEditor = undefined;
|
|
2785
|
+
this.activeTextEditorControl = undefined;
|
|
2786
|
+
this.activeTextEditorLanguageId = undefined;
|
|
2787
|
+
this.visibleEditorPanes = [];
|
|
2788
|
+
this.visibleEditors = [];
|
|
2789
|
+
this.visibleTextEditorControls = [];
|
|
2790
|
+
this.editors = [];
|
|
2791
|
+
this.count = 0;
|
|
2792
|
+
this.getEditors = () => [];
|
|
2793
|
+
this.openEditor = unsupported;
|
|
2794
|
+
this.openEditors = unsupported;
|
|
2795
|
+
this.replaceEditors = async () => { };
|
|
2796
|
+
this.isOpened = () => false;
|
|
2797
|
+
this.isVisible = () => false;
|
|
2798
|
+
this.closeEditor = async () => { };
|
|
2799
|
+
this.closeEditors = async () => { };
|
|
2800
|
+
this.findEditors = () => [];
|
|
2801
|
+
this.save = async () => false;
|
|
2802
|
+
this.saveAll = async () => false;
|
|
2803
|
+
this.revert = async () => false;
|
|
2804
|
+
this.revertAll = async () => false;
|
|
2805
|
+
}
|
|
2806
|
+
});
|
|
2807
|
+
registerSingleton(IPaneCompositePartService, class PaneCompositePartService {
|
|
2808
|
+
constructor() {
|
|
2809
|
+
this._serviceBrand = undefined;
|
|
2810
|
+
this.onDidPaneCompositeOpen = Event.None;
|
|
2811
|
+
this.onDidPaneCompositeClose = Event.None;
|
|
2812
|
+
this.openPaneComposite = unsupported;
|
|
2813
|
+
this.getActivePaneComposite = () => undefined;
|
|
2814
|
+
this.getPaneComposite = () => undefined;
|
|
2815
|
+
this.getPaneComposites = () => [];
|
|
2816
|
+
this.getPinnedPaneCompositeIds = () => [];
|
|
2817
|
+
this.getVisiblePaneCompositeIds = () => [];
|
|
2818
|
+
this.getProgressIndicator = () => undefined;
|
|
2819
|
+
this.hideActivePaneComposite = () => { };
|
|
2820
|
+
this.getLastActivePaneCompositeId = unsupported;
|
|
2821
|
+
this.showActivity = unsupported;
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
registerSingleton(IUriIdentityService, class UriIdentityService {
|
|
2825
|
+
constructor() {
|
|
2826
|
+
this._serviceBrand = undefined;
|
|
2827
|
+
this.extUri = new ExtUri(() => false);
|
|
2828
|
+
}
|
|
2829
|
+
asCanonicalUri(uri) {
|
|
2830
|
+
return uri;
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2833
|
+
const onDidSave = new Emitter();
|
|
2834
|
+
class TextFileEditorModelManager {
|
|
2835
|
+
constructor() {
|
|
2836
|
+
this.onDidCreate = Event.None;
|
|
2837
|
+
this.onDidResolve = Event.None;
|
|
2838
|
+
this.onDidChangeDirty = Event.None;
|
|
2839
|
+
this.onDidChangeReadonly = Event.None;
|
|
2840
|
+
this.onDidRemove = Event.None;
|
|
2841
|
+
this.onDidChangeOrphaned = Event.None;
|
|
2842
|
+
this.onDidChangeEncoding = Event.None;
|
|
2843
|
+
this.onDidSaveError = Event.None;
|
|
2844
|
+
this.onDidSave = onDidSave.event;
|
|
2845
|
+
this.onDidRevert = Event.None;
|
|
2846
|
+
this.models = [];
|
|
2847
|
+
this.saveErrorHandler = {
|
|
2848
|
+
onSaveError: unsupported
|
|
2849
|
+
};
|
|
2850
|
+
this.get = () => undefined;
|
|
2851
|
+
this.resolve = unsupported;
|
|
2852
|
+
this.addSaveParticipant = unsupported;
|
|
2853
|
+
this.runSaveParticipants = unsupported;
|
|
2854
|
+
}
|
|
2855
|
+
canDispose() {
|
|
2856
|
+
return true;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
registerSingleton(ITextFileService, class TextFileService {
|
|
2860
|
+
constructor() {
|
|
2861
|
+
this._serviceBrand = undefined;
|
|
2862
|
+
this.files = new TextFileEditorModelManager();
|
|
2863
|
+
this.isDirty = () => false;
|
|
2864
|
+
this.save = unsupported;
|
|
2865
|
+
this.saveAs = unsupported;
|
|
2866
|
+
this.revert = unsupported;
|
|
2867
|
+
this.read = unsupported;
|
|
2868
|
+
this.readStream = unsupported;
|
|
2869
|
+
this.write = unsupported;
|
|
2870
|
+
this.create = unsupported;
|
|
2871
|
+
this.getEncodedReadable = unsupported;
|
|
2872
|
+
this.getDecodedStream = unsupported;
|
|
2873
|
+
}
|
|
2874
|
+
get untitled() { return unsupported(); }
|
|
2875
|
+
get encoding() { return unsupported(); }
|
|
2876
|
+
dispose() {
|
|
2877
|
+
}
|
|
2878
|
+
});
|
|
2879
|
+
registerSingleton(IFileService, class FileService {
|
|
2880
|
+
constructor() {
|
|
2881
|
+
this._serviceBrand = undefined;
|
|
2882
|
+
this.onDidChangeFileSystemProviderRegistrations = Event.None;
|
|
2883
|
+
this.onDidChangeFileSystemProviderCapabilities = Event.None;
|
|
2884
|
+
this.onWillActivateFileSystemProvider = Event.None;
|
|
2885
|
+
this.registerProvider = unsupported;
|
|
2886
|
+
this.getProvider = function () {
|
|
2887
|
+
return undefined;
|
|
2888
|
+
};
|
|
2889
|
+
this.activateProvider = async () => { };
|
|
2890
|
+
this.canHandleResource = async () => false;
|
|
2891
|
+
this.hasProvider = () => false;
|
|
2892
|
+
this.hasCapability = () => false;
|
|
2893
|
+
this.listCapabilities = () => [];
|
|
2894
|
+
this.onDidFilesChange = Event.None;
|
|
2895
|
+
this.onDidRunOperation = Event.None;
|
|
2896
|
+
this.resolve = unsupported;
|
|
2897
|
+
this.resolveAll = unsupported;
|
|
2898
|
+
this.stat = unsupported;
|
|
2899
|
+
this.exists = async () => false;
|
|
2900
|
+
this.readFile = unsupported;
|
|
2901
|
+
this.readFileStream = unsupported;
|
|
2902
|
+
this.writeFile = unsupported;
|
|
2903
|
+
this.move = unsupported;
|
|
2904
|
+
this.canMove = unsupported;
|
|
2905
|
+
this.copy = unsupported;
|
|
2906
|
+
this.canCopy = unsupported;
|
|
2907
|
+
this.cloneFile = unsupported;
|
|
2908
|
+
this.createFile = unsupported;
|
|
2909
|
+
this.canCreateFile = unsupported;
|
|
2910
|
+
this.createFolder = unsupported;
|
|
2911
|
+
this.del = unsupported;
|
|
2912
|
+
this.canDelete = unsupported;
|
|
2913
|
+
this.onDidWatchError = Event.None;
|
|
2914
|
+
this.watch = unsupported;
|
|
2915
|
+
}
|
|
2916
|
+
dispose() {
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
class EmptyEditorGroup {
|
|
2920
|
+
constructor() {
|
|
2921
|
+
this.onDidModelChange = Event.None;
|
|
2922
|
+
this.onWillDispose = Event.None;
|
|
2923
|
+
this.onDidActiveEditorChange = Event.None;
|
|
2924
|
+
this.onWillCloseEditor = Event.None;
|
|
2925
|
+
this.onDidCloseEditor = Event.None;
|
|
2926
|
+
this.onWillMoveEditor = Event.None;
|
|
2927
|
+
this.onWillOpenEditor = Event.None;
|
|
2928
|
+
this.id = 0;
|
|
2929
|
+
this.index = 0;
|
|
2930
|
+
this.label = 'main';
|
|
2931
|
+
this.ariaLabel = 'main';
|
|
2932
|
+
this.activeEditorPane = undefined;
|
|
2933
|
+
this.activeEditor = null;
|
|
2934
|
+
this.previewEditor = null;
|
|
2935
|
+
this.count = 0;
|
|
2936
|
+
this.isEmpty = false;
|
|
2937
|
+
this.isLocked = false;
|
|
2938
|
+
this.stickyCount = 0;
|
|
2939
|
+
this.editors = [];
|
|
2940
|
+
this.getEditors = unsupported;
|
|
2941
|
+
this.findEditors = unsupported;
|
|
2942
|
+
this.getEditorByIndex = unsupported;
|
|
2943
|
+
this.getIndexOfEditor = unsupported;
|
|
2944
|
+
this.openEditor = unsupported;
|
|
2945
|
+
this.openEditors = unsupported;
|
|
2946
|
+
this.isPinned = unsupported;
|
|
2947
|
+
this.isSticky = unsupported;
|
|
2948
|
+
this.isActive = unsupported;
|
|
2949
|
+
this.contains = unsupported;
|
|
2950
|
+
this.moveEditor = unsupported;
|
|
2951
|
+
this.moveEditors = unsupported;
|
|
2952
|
+
this.copyEditor = unsupported;
|
|
2953
|
+
this.copyEditors = unsupported;
|
|
2954
|
+
this.closeEditor = unsupported;
|
|
2955
|
+
this.closeEditors = unsupported;
|
|
2956
|
+
this.closeAllEditors = unsupported;
|
|
2957
|
+
this.replaceEditors = unsupported;
|
|
2958
|
+
this.pinEditor = unsupported;
|
|
2959
|
+
this.stickEditor = unsupported;
|
|
2960
|
+
this.unstickEditor = unsupported;
|
|
2961
|
+
this.lock = unsupported;
|
|
2962
|
+
}
|
|
2963
|
+
get scopedContextKeyService() { return unsupported(); }
|
|
2964
|
+
focus() {
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
registerSingleton(IEditorGroupsService, class EditorGroupsService {
|
|
2968
|
+
constructor() {
|
|
2969
|
+
this._serviceBrand = undefined;
|
|
2970
|
+
this.onDidChangeActiveGroup = Event.None;
|
|
2971
|
+
this.onDidAddGroup = Event.None;
|
|
2972
|
+
this.onDidRemoveGroup = Event.None;
|
|
2973
|
+
this.onDidMoveGroup = Event.None;
|
|
2974
|
+
this.onDidActivateGroup = Event.None;
|
|
2975
|
+
this.onDidLayout = Event.None;
|
|
2976
|
+
this.onDidScroll = Event.None;
|
|
2977
|
+
this.onDidChangeGroupIndex = Event.None;
|
|
2978
|
+
this.onDidChangeGroupLocked = Event.None;
|
|
2979
|
+
this.activeGroup = new EmptyEditorGroup();
|
|
2980
|
+
this.groups = [];
|
|
2981
|
+
this.count = 0;
|
|
2982
|
+
this.orientation = 0 ;
|
|
2983
|
+
this.isReady = false;
|
|
2984
|
+
this.whenReady = Promise.resolve();
|
|
2985
|
+
this.whenRestored = Promise.resolve();
|
|
2986
|
+
this.hasRestorableState = false;
|
|
2987
|
+
this.getGroups = () => [];
|
|
2988
|
+
this.getGroup = () => undefined;
|
|
2989
|
+
this.activateGroup = unsupported;
|
|
2990
|
+
this.getSize = unsupported;
|
|
2991
|
+
this.setSize = unsupported;
|
|
2992
|
+
this.arrangeGroups = unsupported;
|
|
2993
|
+
this.applyLayout = unsupported;
|
|
2994
|
+
this.centerLayout = unsupported;
|
|
2995
|
+
this.isLayoutCentered = () => false;
|
|
2996
|
+
this.setGroupOrientation = unsupported;
|
|
2997
|
+
this.findGroup = () => undefined;
|
|
2998
|
+
this.addGroup = unsupported;
|
|
2999
|
+
this.removeGroup = unsupported;
|
|
3000
|
+
this.moveGroup = unsupported;
|
|
3001
|
+
this.mergeGroup = unsupported;
|
|
3002
|
+
this.mergeAllGroups = unsupported;
|
|
3003
|
+
this.copyGroup = unsupported;
|
|
3004
|
+
this.onDidChangeEditorPartOptions = Event.None;
|
|
3005
|
+
this.enforcePartOptions = unsupported;
|
|
3006
|
+
}
|
|
3007
|
+
get contentDimension() { return unsupported(); }
|
|
3008
|
+
get sideGroup() { return unsupported(); }
|
|
3009
|
+
get partOptions() { return unsupported(); }
|
|
3010
|
+
});
|
|
3011
|
+
registerSingleton(IWorkbenchEnvironmentService, class WorkbenchEnvironmentService {
|
|
3012
|
+
constructor() {
|
|
3013
|
+
this._serviceBrand = undefined;
|
|
3014
|
+
this.skipReleaseNotes = true;
|
|
3015
|
+
this.skipWelcome = true;
|
|
3016
|
+
this.disableWorkspaceTrust = true;
|
|
3017
|
+
this.debugRenderer = false;
|
|
3018
|
+
this.sync = undefined;
|
|
3019
|
+
this.isExtensionDevelopment = false;
|
|
3020
|
+
this.disableExtensions = false;
|
|
3021
|
+
this.logsPath = '';
|
|
3022
|
+
this.verbose = false;
|
|
3023
|
+
this.isBuilt = false;
|
|
3024
|
+
this.disableTelemetry = false;
|
|
3025
|
+
}
|
|
3026
|
+
get logFile() { return unsupported(); }
|
|
3027
|
+
get extHostLogsPath() { return unsupported(); }
|
|
3028
|
+
get webviewExternalEndpoint() { return unsupported(); }
|
|
3029
|
+
get userRoamingDataHome() { return unsupported(); }
|
|
3030
|
+
get settingsResource() { return unsupported(); }
|
|
3031
|
+
get keybindingsResource() { return unsupported(); }
|
|
3032
|
+
get keyboardLayoutResource() { return unsupported(); }
|
|
3033
|
+
get argvResource() { return unsupported(); }
|
|
3034
|
+
get snippetsHome() { return unsupported(); }
|
|
3035
|
+
get untitledWorkspacesHome() { return unsupported(); }
|
|
3036
|
+
get globalStorageHome() { return unsupported(); }
|
|
3037
|
+
get workspaceStorageHome() { return unsupported(); }
|
|
3038
|
+
get localHistoryHome() { return unsupported(); }
|
|
3039
|
+
get cacheHome() { return unsupported(); }
|
|
3040
|
+
get userDataSyncHome() { return unsupported(); }
|
|
3041
|
+
get userDataSyncLogResource() { return unsupported(); }
|
|
3042
|
+
get debugExtensionHost() { return unsupported(); }
|
|
3043
|
+
get telemetryLogResource() { return unsupported(); }
|
|
3044
|
+
get serviceMachineIdResource() { return unsupported(); }
|
|
3045
|
+
});
|
|
3046
|
+
registerSingleton(IWorkingCopyFileService, class WorkingCopyFileService {
|
|
3047
|
+
constructor() {
|
|
3048
|
+
this._serviceBrand = undefined;
|
|
3049
|
+
this.onWillRunWorkingCopyFileOperation = Event.None;
|
|
3050
|
+
this.onDidFailWorkingCopyFileOperation = Event.None;
|
|
3051
|
+
this.onDidRunWorkingCopyFileOperation = Event.None;
|
|
3052
|
+
this.addFileOperationParticipant = unsupported;
|
|
3053
|
+
this.hasSaveParticipants = false;
|
|
3054
|
+
this.addSaveParticipant = unsupported;
|
|
3055
|
+
this.runSaveParticipants = unsupported;
|
|
3056
|
+
this.create = unsupported;
|
|
3057
|
+
this.createFolder = unsupported;
|
|
3058
|
+
this.move = unsupported;
|
|
3059
|
+
this.copy = unsupported;
|
|
3060
|
+
this.delete = unsupported;
|
|
3061
|
+
this.registerWorkingCopyProvider = unsupported;
|
|
3062
|
+
this.getDirty = unsupported;
|
|
3063
|
+
}
|
|
3064
|
+
});
|
|
3065
|
+
registerSingleton(IPathService, class PathService {
|
|
3066
|
+
constructor() {
|
|
3067
|
+
this._serviceBrand = undefined;
|
|
3068
|
+
this.defaultUriScheme = Schemas.file;
|
|
3069
|
+
this.userHome = unsupported;
|
|
3070
|
+
this.hasValidBasename = unsupported;
|
|
3071
|
+
this.resolvedUserHome = undefined;
|
|
3072
|
+
}
|
|
3073
|
+
get path() { return unsupported(); }
|
|
3074
|
+
async fileURI(path) {
|
|
3075
|
+
return URI.file(path);
|
|
3076
|
+
}
|
|
3077
|
+
});
|
|
3078
|
+
registerSingleton(IProgressService, class ProgressService {
|
|
3079
|
+
constructor() {
|
|
3080
|
+
this._serviceBrand = undefined;
|
|
3081
|
+
}
|
|
3082
|
+
withProgress(options, task, onDidCancel) {
|
|
3083
|
+
const { window } = Services.get();
|
|
3084
|
+
if (window?.withProgress != null) {
|
|
3085
|
+
return window.withProgress(options, task, onDidCancel);
|
|
3086
|
+
}
|
|
3087
|
+
return task({ report: () => { } });
|
|
3088
|
+
}
|
|
3089
|
+
});
|
|
3090
|
+
registerSingleton(IProductService, class ProductService {
|
|
3091
|
+
constructor() {
|
|
3092
|
+
this._serviceBrand = undefined;
|
|
3093
|
+
this.version = "1.67.0";
|
|
3094
|
+
this.nameShort = 'Code - OSS Dev';
|
|
3095
|
+
this.nameLong = 'Code - OSS Dev';
|
|
3096
|
+
this.applicationName = 'code-oss';
|
|
3097
|
+
this.dataFolderName = '.vscode-oss';
|
|
3098
|
+
this.urlProtocol = 'code-oss';
|
|
3099
|
+
this.reportIssueUrl = 'https://github.com/microsoft/vscode/issues/new';
|
|
3100
|
+
this.licenseName = 'MIT';
|
|
3101
|
+
this.licenseUrl = 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt';
|
|
3102
|
+
this.serverApplicationName = 'code-server-oss';
|
|
3103
|
+
}
|
|
3104
|
+
});
|
|
3105
|
+
registerSingleton(ILanguageStatusService, class LanguageStatusServiceImpl {
|
|
3106
|
+
constructor() {
|
|
3107
|
+
this._provider = new LanguageFeatureRegistry();
|
|
3108
|
+
this.onDidChange = this._provider.onDidChange;
|
|
3109
|
+
}
|
|
3110
|
+
addStatus(status) {
|
|
3111
|
+
return this._provider.register(status.selector, status);
|
|
3112
|
+
}
|
|
3113
|
+
getLanguageStatus(model) {
|
|
3114
|
+
return this._provider.ordered(model).sort((a, b) => {
|
|
3115
|
+
let res = b.severity - a.severity;
|
|
3116
|
+
if (res === 0) {
|
|
3117
|
+
res = compare$1(a.source, b.source);
|
|
3118
|
+
}
|
|
3119
|
+
if (res === 0) {
|
|
3120
|
+
res = compare$1(a.id, b.id);
|
|
3121
|
+
}
|
|
3122
|
+
return res;
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
});
|
|
3126
|
+
const focusTracker = trackFocus(window);
|
|
3127
|
+
const onVisibilityChange = new DomEmitter(window.document, 'visibilitychange');
|
|
3128
|
+
const onDidChangeFocus = Event.latch(Event.any(Event.map(focusTracker.onDidFocus, () => document.hasFocus()), Event.map(focusTracker.onDidBlur, () => document.hasFocus()), Event.map(onVisibilityChange.event, () => document.hasFocus())));
|
|
3129
|
+
registerSingleton(IHostService, class HostService {
|
|
3130
|
+
constructor() {
|
|
3131
|
+
this.onDidChangeFocus = onDidChangeFocus;
|
|
3132
|
+
this.openWindow = unsupported;
|
|
3133
|
+
this.restart = unsupported;
|
|
3134
|
+
this.reload = unsupported;
|
|
3135
|
+
this.close = unsupported;
|
|
3136
|
+
}
|
|
3137
|
+
get hasFocus() {
|
|
3138
|
+
return document.hasFocus();
|
|
3139
|
+
}
|
|
3140
|
+
async hadLastFocus() {
|
|
3141
|
+
return true;
|
|
3142
|
+
}
|
|
3143
|
+
async focus() {
|
|
3144
|
+
window.focus();
|
|
3145
|
+
}
|
|
3146
|
+
async toggleFullScreen() {
|
|
3147
|
+
if (document.fullscreenEnabled) {
|
|
3148
|
+
await document.body.requestFullscreen();
|
|
3149
|
+
}
|
|
3150
|
+
else {
|
|
3151
|
+
await document.exitFullscreen();
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
});
|
|
3155
|
+
registerSingleton(ILifecycleService, class LifecycleService {
|
|
3156
|
+
constructor() {
|
|
3157
|
+
this.startupKind = 1 ;
|
|
3158
|
+
this.phase = 2 ;
|
|
3159
|
+
this.onBeforeShutdown = Event.None;
|
|
3160
|
+
this.onShutdownVeto = Event.None;
|
|
3161
|
+
this.onBeforeShutdownError = Event.None;
|
|
3162
|
+
this.onWillShutdown = Event.None;
|
|
3163
|
+
this.onDidShutdown = Event.None;
|
|
3164
|
+
this.shutdown = unsupported;
|
|
3165
|
+
}
|
|
3166
|
+
async when() {
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
registerSingleton(ILanguageDetectionService, class LanguageDetectionService {
|
|
3170
|
+
isEnabledForLanguage() {
|
|
3171
|
+
return false;
|
|
3172
|
+
}
|
|
3173
|
+
async detectLanguage() {
|
|
3174
|
+
return undefined;
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
export { Emitter as E, ILifecycleService as I, UserSettings as U, ILanguageDetectionService as a, peekReadable as b, bufferToReadable as c, consumeStream as d, isReadableBufferedStream as e, bufferedStreamToBuffer as f, newWriteableStream as g, isReadableStream as i, listenStream as l, newWriteableBufferStream as n, peekStream as p, readableToBuffer as r, streamToBuffer as s, transform as t, unsupported as u };
|