@codingame/monaco-vscode-api 1.67.13 → 1.67.16

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