@codingame/monaco-vscode-api 1.67.12 → 1.67.15

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.
@@ -0,0 +1,212 @@
1
+ import { E as Emitter } from './missing-services-8687ea11.js';
2
+ import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { extUri } from 'monaco-editor/esm/vs/base/common/resources.js';
4
+ import { CancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
5
+ function isThenable(obj) {
6
+ return !!obj && typeof obj.then === 'function';
7
+ }
8
+ function raceCancellationError(promise, token) {
9
+ return (
10
+ new Promise((resolve, reject) => {
11
+ const ref = token.onCancellationRequested(() => {
12
+ ref.dispose();
13
+ reject( new CancellationError());
14
+ });
15
+ promise.then(resolve, reject).finally(() => ref.dispose());
16
+ })
17
+ );
18
+ }
19
+ function asPromise(callback) {
20
+ return (
21
+ new Promise((resolve, reject) => {
22
+ const item = callback();
23
+ if (isThenable(item)) {
24
+ item.then(resolve, reject);
25
+ }
26
+ else {
27
+ resolve(item);
28
+ }
29
+ })
30
+ );
31
+ }
32
+ class Barrier {
33
+ constructor() {
34
+ this._isOpen = false;
35
+ this._promise = new Promise((c, e) => {
36
+ this._completePromise = c;
37
+ });
38
+ }
39
+ isOpen() {
40
+ return this._isOpen;
41
+ }
42
+ open() {
43
+ this._isOpen = true;
44
+ this._completePromise(true);
45
+ }
46
+ wait() {
47
+ return this._promise;
48
+ }
49
+ }
50
+ class Limiter {
51
+ constructor(maxDegreeOfParalellism) {
52
+ this._size = 0;
53
+ this.maxDegreeOfParalellism = maxDegreeOfParalellism;
54
+ this.outstandingPromises = [];
55
+ this.runningPromises = 0;
56
+ this._onFinished = new Emitter();
57
+ }
58
+ get onFinished() {
59
+ return this._onFinished.event;
60
+ }
61
+ get size() {
62
+ return this._size;
63
+ }
64
+ queue(factory) {
65
+ this._size++;
66
+ return (
67
+ new Promise((c, e) => {
68
+ this.outstandingPromises.push({ factory, c, e });
69
+ this.consume();
70
+ })
71
+ );
72
+ }
73
+ consume() {
74
+ while (this.outstandingPromises.length && this.runningPromises < this.maxDegreeOfParalellism) {
75
+ const iLimitedTask = this.outstandingPromises.shift();
76
+ this.runningPromises++;
77
+ const promise = iLimitedTask.factory();
78
+ promise.then(iLimitedTask.c, iLimitedTask.e);
79
+ promise.then(() => this.consumed(), () => this.consumed());
80
+ }
81
+ }
82
+ consumed() {
83
+ this._size--;
84
+ this.runningPromises--;
85
+ if (this.outstandingPromises.length > 0) {
86
+ this.consume();
87
+ }
88
+ else {
89
+ this._onFinished.fire();
90
+ }
91
+ }
92
+ dispose() {
93
+ this._onFinished.dispose();
94
+ }
95
+ }
96
+ class Queue extends Limiter {
97
+ constructor() {
98
+ super(1);
99
+ }
100
+ }
101
+ class ResourceQueue {
102
+ constructor() {
103
+ this.queues = new Map();
104
+ this.drainers = new Set();
105
+ }
106
+ async whenDrained() {
107
+ if (this.isDrained()) {
108
+ return;
109
+ }
110
+ const promise = new DeferredPromise();
111
+ this.drainers.add(promise);
112
+ return promise.p;
113
+ }
114
+ isDrained() {
115
+ for (const [, queue] of this.queues) {
116
+ if (queue.size > 0) {
117
+ return false;
118
+ }
119
+ }
120
+ return true;
121
+ }
122
+ queueFor(resource, extUri$1 = extUri) {
123
+ const key = extUri$1.getComparisonKey(resource);
124
+ let queue = this.queues.get(key);
125
+ if (!queue) {
126
+ queue = new Queue();
127
+ Event.once(queue.onFinished)(() => {
128
+ queue?.dispose();
129
+ this.queues.delete(key);
130
+ this.onDidQueueFinish();
131
+ });
132
+ this.queues.set(key, queue);
133
+ }
134
+ return queue;
135
+ }
136
+ onDidQueueFinish() {
137
+ if (!this.isDrained()) {
138
+ return;
139
+ }
140
+ this.releaseDrainers();
141
+ }
142
+ releaseDrainers() {
143
+ for (const drainer of this.drainers) {
144
+ drainer.complete();
145
+ }
146
+ this.drainers.clear();
147
+ }
148
+ dispose() {
149
+ for (const [, queue] of this.queues) {
150
+ queue.dispose();
151
+ }
152
+ this.queues.clear();
153
+ this.releaseDrainers();
154
+ }
155
+ }
156
+ class IntervalCounter {
157
+ constructor(interval, nowFn = () => Date.now()) {
158
+ this.interval = interval;
159
+ this.nowFn = nowFn;
160
+ this.lastIncrementTime = 0;
161
+ this.value = 0;
162
+ }
163
+ increment() {
164
+ const now = this.nowFn();
165
+ if (now - this.lastIncrementTime > this.interval) {
166
+ this.lastIncrementTime = now;
167
+ this.value = 0;
168
+ }
169
+ this.value++;
170
+ return this.value;
171
+ }
172
+ }
173
+ class DeferredPromise {
174
+ constructor() {
175
+ this.rejected = false;
176
+ this.resolved = false;
177
+ this.p = new Promise((c, e) => {
178
+ this.completeCallback = c;
179
+ this.errorCallback = e;
180
+ });
181
+ }
182
+ get isRejected() {
183
+ return this.rejected;
184
+ }
185
+ get isResolved() {
186
+ return this.resolved;
187
+ }
188
+ get isSettled() {
189
+ return this.rejected || this.resolved;
190
+ }
191
+ complete(value) {
192
+ return (
193
+ new Promise(resolve => {
194
+ this.completeCallback(value);
195
+ this.resolved = true;
196
+ resolve();
197
+ })
198
+ );
199
+ }
200
+ error(err) {
201
+ return (
202
+ new Promise(resolve => {
203
+ this.errorCallback(err);
204
+ this.rejected = true;
205
+ resolve();
206
+ })
207
+ );
208
+ }
209
+ cancel() {
210
+ }
211
+ }
212
+ export { Barrier as B, IntervalCounter as I, ResourceQueue as R, asPromise as a, raceCancellationError as r };
@@ -0,0 +1,293 @@
1
+ import * as vscode from 'vscode';
2
+
3
+ interface IDisposable {
4
+ dispose(): void;
5
+ }
6
+ declare class DisposableStore implements IDisposable {
7
+ static DISABLE_DISPOSED_WARNING: boolean;
8
+ private _toDispose;
9
+ private _isDisposed;
10
+ constructor();
11
+ /**
12
+ * Dispose of all registered disposables and mark this object as disposed.
13
+ *
14
+ * Any future disposables added to this object will be disposed of on `add`.
15
+ */
16
+ dispose(): void;
17
+ /**
18
+ * Returns `true` if this object has been disposed
19
+ */
20
+ get isDisposed(): boolean;
21
+ /**
22
+ * Dispose of all registered disposables but do not mark this object as disposed.
23
+ */
24
+ clear(): void;
25
+ add<T extends IDisposable>(o: T): T;
26
+ }
27
+
28
+ /**
29
+ * To an event a function with one or zero parameters
30
+ * can be subscribed. The event is the subscriber function itself.
31
+ */
32
+ type Event<T> = vscode.Event<T>
33
+ declare namespace Event {
34
+ const None: Event<any>;
35
+ /**
36
+ * Given an event, returns another event which only fires once.
37
+ */
38
+ function once<T>(event: Event<T>): Event<T>;
39
+ /**
40
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
41
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
42
+ * returned event causes this utility to leak a listener on the original event.
43
+ */
44
+ function map<I, O>(event: Event<I>, map: (i: I) => O, disposable?: DisposableStore): Event<O>;
45
+ /**
46
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
47
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
48
+ * returned event causes this utility to leak a listener on the original event.
49
+ */
50
+ function forEach<I>(event: Event<I>, each: (i: I) => void, disposable?: DisposableStore): Event<I>;
51
+ /**
52
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
53
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
54
+ * returned event causes this utility to leak a listener on the original event.
55
+ */
56
+ function filter<T, U>(event: Event<T | U>, filter: (e: T | U) => e is T, disposable?: DisposableStore): Event<T>;
57
+ function filter<T>(event: Event<T>, filter: (e: T) => boolean, disposable?: DisposableStore): Event<T>;
58
+ function filter<T, R>(event: Event<T | R>, filter: (e: T | R) => e is R, disposable?: DisposableStore): Event<R>;
59
+ /**
60
+ * Given an event, returns the same event but typed as `Event<void>`.
61
+ */
62
+ function signal<T>(event: Event<T>): Event<void>;
63
+ /**
64
+ * Given a collection of events, returns a single event which emits
65
+ * whenever any of the provided events emit.
66
+ */
67
+ function any<T>(...events: Event<T>[]): Event<T>;
68
+ function any(...events: Event<any>[]): Event<void>;
69
+ /**
70
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
71
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
72
+ * returned event causes this utility to leak a listener on the original event.
73
+ */
74
+ function reduce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, initial?: O, disposable?: DisposableStore): Event<O>;
75
+ /**
76
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
77
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
78
+ * returned event causes this utility to leak a listener on the original event.
79
+ */
80
+ function debounce<T>(event: Event<T>, merge: (last: T | undefined, event: T) => T, delay?: number, leading?: boolean, leakWarningThreshold?: number, disposable?: DisposableStore): Event<T>;
81
+ /**
82
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
83
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
84
+ * returned event causes this utility to leak a listener on the original event.
85
+ */
86
+ function debounce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, delay?: number, leading?: boolean, leakWarningThreshold?: number, disposable?: DisposableStore): Event<O>;
87
+ /**
88
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
89
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
90
+ * returned event causes this utility to leak a listener on the original event.
91
+ */
92
+ function latch<T>(event: Event<T>, equals?: (a: T, b: T) => boolean, disposable?: DisposableStore): Event<T>;
93
+ /**
94
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
95
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
96
+ * returned event causes this utility to leak a listener on the original event.
97
+ */
98
+ function split<T, U>(event: Event<T | U>, isT: (e: T | U) => e is T, disposable?: DisposableStore): [Event<T>, Event<U>];
99
+ /**
100
+ * *NOTE* that this function returns an `Event` and it MUST be called with a `DisposableStore` whenever the returned
101
+ * event is accessible to "third parties", e.g the event is a public property. Otherwise a leaked listener on the
102
+ * returned event causes this utility to leak a listener on the original event.
103
+ */
104
+ function buffer<T>(event: Event<T>, flushAfterTimeout?: boolean, _buffer?: T[]): Event<T>;
105
+ interface IChainableEvent<T> {
106
+ event: Event<T>;
107
+ map<O>(fn: (i: T) => O): IChainableEvent<O>;
108
+ forEach(fn: (i: T) => void): IChainableEvent<T>;
109
+ filter(fn: (e: T) => boolean): IChainableEvent<T>;
110
+ filter<R>(fn: (e: T | R) => e is R): IChainableEvent<R>;
111
+ reduce<R>(merge: (last: R | undefined, event: T) => R, initial?: R): IChainableEvent<R>;
112
+ latch(): IChainableEvent<T>;
113
+ debounce(merge: (last: T | undefined, event: T) => T, delay?: number, leading?: boolean, leakWarningThreshold?: number): IChainableEvent<T>;
114
+ debounce<R>(merge: (last: R | undefined, event: T) => R, delay?: number, leading?: boolean, leakWarningThreshold?: number): IChainableEvent<R>;
115
+ on(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore): IDisposable;
116
+ once(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
117
+ }
118
+ /**
119
+ * @deprecated DO NOT use, this leaks memory
120
+ */
121
+ function chain<T>(event: Event<T>): IChainableEvent<T>;
122
+ interface NodeEventEmitter {
123
+ on(event: string | symbol, listener: Function): unknown;
124
+ removeListener(event: string | symbol, listener: Function): unknown;
125
+ }
126
+ function fromNodeEventEmitter<T>(emitter: NodeEventEmitter, eventName: string, map?: (...args: any[]) => T): Event<T>;
127
+ interface DOMEventEmitter {
128
+ addEventListener(event: string | symbol, listener: Function): void;
129
+ removeEventListener(event: string | symbol, listener: Function): void;
130
+ }
131
+ function fromDOMEventEmitter<T>(emitter: DOMEventEmitter, eventName: string, map?: (...args: any[]) => T): Event<T>;
132
+ function toPromise<T>(event: Event<T>): Promise<T>;
133
+ function runAndSubscribe<T>(event: Event<T>, handler: (e: T | undefined) => any): IDisposable;
134
+ function runAndSubscribeWithStore<T>(event: Event<T>, handler: (e: T | undefined, disposableStore: DisposableStore) => any): IDisposable;
135
+ }
136
+
137
+ /**
138
+ * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
139
+ * This class is a simple parser which creates the basic component parts
140
+ * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
141
+ * and encoding.
142
+ *
143
+ * ```txt
144
+ * foo://example.com:8042/over/there?name=ferret#nose
145
+ * \_/ \______________/\_________/ \_________/ \__/
146
+ * | | | | |
147
+ * scheme authority path query fragment
148
+ * | _____________________|__
149
+ * / \ / \
150
+ * urn:example:animal:ferret:nose
151
+ * ```
152
+ */
153
+ declare class URI implements UriComponents {
154
+ static isUri(thing: any): thing is URI;
155
+ /**
156
+ * scheme is the 'http' part of 'http://www.example.com/some/path?query#fragment'.
157
+ * The part before the first colon.
158
+ */
159
+ readonly scheme: string;
160
+ /**
161
+ * authority is the 'www.example.com' part of 'http://www.example.com/some/path?query#fragment'.
162
+ * The part between the first double slashes and the next slash.
163
+ */
164
+ readonly authority: string;
165
+ /**
166
+ * path is the '/some/path' part of 'http://www.example.com/some/path?query#fragment'.
167
+ */
168
+ readonly path: string;
169
+ /**
170
+ * query is the 'query' part of 'http://www.example.com/some/path?query#fragment'.
171
+ */
172
+ readonly query: string;
173
+ /**
174
+ * fragment is the 'fragment' part of 'http://www.example.com/some/path?query#fragment'.
175
+ */
176
+ readonly fragment: string;
177
+ /**
178
+ * @internal
179
+ */
180
+ protected constructor(scheme: string, authority?: string, path?: string, query?: string, fragment?: string, _strict?: boolean);
181
+ /**
182
+ * @internal
183
+ */
184
+ protected constructor(components: UriComponents);
185
+ /**
186
+ * Returns a string representing the corresponding file system path of this URI.
187
+ * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
188
+ * platform specific path separator.
189
+ *
190
+ * * Will *not* validate the path for invalid characters and semantics.
191
+ * * Will *not* look at the scheme of this URI.
192
+ * * The result shall *not* be used for display purposes but for accessing a file on disk.
193
+ *
194
+ *
195
+ * The *difference* to `URI#path` is the use of the platform specific separator and the handling
196
+ * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
197
+ *
198
+ * ```ts
199
+ const u = URI.parse('file://server/c$/folder/file.txt')
200
+ u.authority === 'server'
201
+ u.path === '/shares/c$/file.txt'
202
+ u.fsPath === '\\server\c$\folder\file.txt'
203
+ ```
204
+ *
205
+ * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
206
+ * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
207
+ * with URIs that represent files on disk (`file` scheme).
208
+ */
209
+ get fsPath(): string;
210
+ with(change: {
211
+ scheme?: string;
212
+ authority?: string | null;
213
+ path?: string | null;
214
+ query?: string | null;
215
+ fragment?: string | null;
216
+ }): URI;
217
+ /**
218
+ * Creates a new URI from a string, e.g. `http://www.example.com/some/path`,
219
+ * `file:///usr/home`, or `scheme:with/path`.
220
+ *
221
+ * @param value A string which represents an URI (see `URI#toString`).
222
+ */
223
+ static parse(value: string, _strict?: boolean): URI;
224
+ /**
225
+ * Creates a new URI from a file system path, e.g. `c:\my\files`,
226
+ * `/usr/home`, or `\\server\share\some\path`.
227
+ *
228
+ * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
229
+ * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
230
+ * `URI.parse('file://' + path)` because the path might contain characters that are
231
+ * interpreted (# and ?). See the following sample:
232
+ * ```ts
233
+ const good = URI.file('/coding/c#/project1');
234
+ good.scheme === 'file';
235
+ good.path === '/coding/c#/project1';
236
+ good.fragment === '';
237
+ const bad = URI.parse('file://' + '/coding/c#/project1');
238
+ bad.scheme === 'file';
239
+ bad.path === '/coding/c'; // path is now broken
240
+ bad.fragment === '/project1';
241
+ ```
242
+ *
243
+ * @param path A file system path (see `URI#fsPath`)
244
+ */
245
+ static file(path: string): URI;
246
+ static from(components: {
247
+ scheme: string;
248
+ authority?: string;
249
+ path?: string;
250
+ query?: string;
251
+ fragment?: string;
252
+ }): URI;
253
+ /**
254
+ * Join a URI path with path fragments and normalizes the resulting path.
255
+ *
256
+ * @param uri The input URI.
257
+ * @param pathFragment The path fragment to add to the URI path.
258
+ * @returns The resulting URI.
259
+ */
260
+ static joinPath(uri: URI, ...pathFragment: string[]): URI;
261
+ /**
262
+ * Creates a string representation for this URI. It's guaranteed that calling
263
+ * `URI.parse` with the result of this function creates an URI which is equal
264
+ * to this URI.
265
+ *
266
+ * * The result shall *not* be used for display purposes but for externalization or transport.
267
+ * * The result will be encoded using the percentage encoding and encoding happens mostly
268
+ * ignore the scheme-specific encoding rules.
269
+ *
270
+ * @param skipEncoding Do not encode the result, default is `false`
271
+ */
272
+ toString(skipEncoding?: boolean): string;
273
+ toJSON(): UriComponents;
274
+ static revive(data: UriComponents | URI): URI;
275
+ static revive(data: UriComponents | URI | undefined): URI | undefined;
276
+ static revive(data: UriComponents | URI | null): URI | null;
277
+ static revive(data: UriComponents | URI | undefined | null): URI | undefined | null;
278
+ }
279
+ interface UriComponents {
280
+ scheme: string;
281
+ authority: string;
282
+ path: string;
283
+ query: string;
284
+ fragment: string;
285
+ }
286
+
287
+ interface IEditorOverrideServices {
288
+ [index: string]: any;
289
+ }
290
+
291
+ declare function getServiceOverride(readConfiguration: () => string, onChange: Event<void>, settingsResource?: URI): IEditorOverrideServices;
292
+
293
+ export { getServiceOverride as default };