custom-electron-titlebar 4.2.0-alpha.2 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +83 -65
  3. package/package.json +69 -58
  4. package/dist/enums/menu-state.d.ts +0 -6
  5. package/dist/index.d.ts +0 -3
  6. package/dist/index.js +0 -1
  7. package/dist/titlebar.d.ts +0 -143
  8. package/dist/types/menubar-options.d.ts +0 -41
  9. package/dist/types/scss.d.ts +0 -6
  10. package/dist/types/titlebar-options.d.ts +0 -66
  11. package/dist/utils/color.d.ts +0 -2
  12. package/dist/vs/base/browser/browser.d.ts +0 -40
  13. package/dist/vs/base/browser/canIUse.d.ts +0 -17
  14. package/dist/vs/base/browser/dom.d.ts +0 -325
  15. package/dist/vs/base/browser/event.d.ts +0 -27
  16. package/dist/vs/base/browser/fastDomNode.d.ts +0 -59
  17. package/dist/vs/base/browser/globalMouseMoveMonitor.d.ts +0 -29
  18. package/dist/vs/base/browser/iframe.d.ts +0 -33
  19. package/dist/vs/base/browser/keyboardEvent.d.ts +0 -42
  20. package/dist/vs/base/browser/mouseEvent.d.ts +0 -69
  21. package/dist/vs/base/browser/touch.d.ts +0 -39
  22. package/dist/vs/base/browser/ui/actionbar/actionViewItems.d.ts +0 -58
  23. package/dist/vs/base/browser/ui/actionbar/actionbar.d.ts +0 -95
  24. package/dist/vs/base/browser/ui/contextview/contextview.d.ts +0 -94
  25. package/dist/vs/base/browser/ui/menu/menu.d.ts +0 -58
  26. package/dist/vs/base/browser/ui/menu/menubar.d.ts +0 -78
  27. package/dist/vs/base/browser/ui/scrollbar/abstractScrollbar.d.ts +0 -67
  28. package/dist/vs/base/browser/ui/scrollbar/horizontalScrollbar.d.ts +0 -15
  29. package/dist/vs/base/browser/ui/scrollbar/scrollableElement.d.ts +0 -107
  30. package/dist/vs/base/browser/ui/scrollbar/scrollableElementOptions.d.ts +0 -157
  31. package/dist/vs/base/browser/ui/scrollbar/scrollbarArrow.d.ts +0 -25
  32. package/dist/vs/base/browser/ui/scrollbar/scrollbarState.d.ts +0 -75
  33. package/dist/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.d.ts +0 -24
  34. package/dist/vs/base/browser/ui/scrollbar/verticalScrollbar.d.ts +0 -15
  35. package/dist/vs/base/browser/ui/widget.d.ts +0 -16
  36. package/dist/vs/base/common/actions.d.ts +0 -115
  37. package/dist/vs/base/common/arrays.d.ts +0 -168
  38. package/dist/vs/base/common/async.d.ts +0 -510
  39. package/dist/vs/base/common/cache.d.ts +0 -23
  40. package/dist/vs/base/common/cancellation.d.ts +0 -29
  41. package/dist/vs/base/common/charCode.d.ts +0 -405
  42. package/dist/vs/base/common/color.d.ts +0 -159
  43. package/dist/vs/base/common/decorators.d.ts +0 -7
  44. package/dist/vs/base/common/errors.d.ts +0 -77
  45. package/dist/vs/base/common/event.d.ts +0 -274
  46. package/dist/vs/base/common/functional.d.ts +0 -1
  47. package/dist/vs/base/common/iterator.d.ts +0 -31
  48. package/dist/vs/base/common/keyCodes.d.ts +0 -429
  49. package/dist/vs/base/common/keybindings.d.ts +0 -99
  50. package/dist/vs/base/common/lazy.d.ts +0 -19
  51. package/dist/vs/base/common/lifecycle.d.ts +0 -129
  52. package/dist/vs/base/common/linkedList.d.ts +0 -15
  53. package/dist/vs/base/common/platform.d.ts +0 -85
  54. package/dist/vs/base/common/range.d.ts +0 -18
  55. package/dist/vs/base/common/scrollable.d.ts +0 -141
  56. package/dist/vs/base/common/strings.d.ts +0 -215
  57. package/dist/vs/base/common/types.d.ts +0 -89
  58. package/dist/vs/base/common/uint.d.ts +0 -31
  59. package/dist/vs/nls.d.ts +0 -18
  60. package/main/attach-titlebar-to-window.d.ts +0 -3
  61. package/main/index.d.ts +0 -5
  62. package/main/main.js +0 -1
  63. package/main/setup-main.d.ts +0 -2
@@ -1,168 +0,0 @@
1
- /**
2
- * Returns the last element of an array.
3
- * @param array The array.
4
- * @param n Which element from the end (default is zero).
5
- */
6
- export declare function tail<T>(array: ArrayLike<T>, n?: number): T;
7
- export declare function tail2<T>(arr: T[]): [T[], T];
8
- export declare function equals<T>(one: ReadonlyArray<T> | undefined, other: ReadonlyArray<T> | undefined, itemEquals?: (a: T, b: T) => boolean): boolean;
9
- export declare function binarySearch<T>(array: ReadonlyArray<T>, key: T, comparator: (op1: T, op2: T) => number): number;
10
- /**
11
- * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false
12
- * are located before all elements where p(x) is true.
13
- * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
14
- */
15
- export declare function findFirstInSorted<T>(array: ReadonlyArray<T>, p: (x: T) => boolean): number;
16
- declare type Compare<T> = (a: T, b: T) => number;
17
- export declare function quickSelect<T>(nth: number, data: T[], compare: Compare<T>): T;
18
- export declare function groupBy<T>(data: ReadonlyArray<T>, compare: (a: T, b: T) => number): T[][];
19
- /**
20
- * Returns the top N elements from the array.
21
- *
22
- * Faster than sorting the entire array when the array is a lot larger than N.
23
- *
24
- * @param array The unsorted array.
25
- * @param compare A sort function for the elements.
26
- * @param n The number of elements to return.
27
- * @return The first n elements from array when sorted with compare.
28
- */
29
- export declare function top<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, n: number): T[];
30
- /**
31
- * @returns New array with all falsy values removed. The original array IS NOT modified.
32
- */
33
- export declare function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[];
34
- /**
35
- * Remove all falsy values from `array`. The original array IS modified.
36
- */
37
- export declare function coalesceInPlace<T>(array: Array<T | undefined | null>): void;
38
- /**
39
- * @deprecated Use `Array.copyWithin` instead
40
- */
41
- export declare function move(array: any[], from: number, to: number): void;
42
- /**
43
- * @returns false if the provided object is an array and not empty.
44
- */
45
- export declare function isFalsyOrEmpty(obj: any): boolean;
46
- /**
47
- * @returns True if the provided object is an array and has at least one element.
48
- */
49
- export declare function isNonEmptyArray<T>(obj: T[] | undefined | null): obj is T[];
50
- export declare function isNonEmptyArray<T>(obj: readonly T[] | undefined | null): obj is readonly T[];
51
- /**
52
- * Removes duplicates from the given array. The optional keyFn allows to specify
53
- * how elements are checked for equality by returning an alternate value for each.
54
- */
55
- export declare function distinct<T>(array: ReadonlyArray<T>, keyFn?: (value: T) => any): T[];
56
- export declare function uniqueFilter<T, R>(keyFn: (t: T) => R): (t: T) => boolean;
57
- export declare function findLast<T>(arr: readonly T[], predicate: (item: T) => boolean): T | undefined;
58
- export declare function lastIndex<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): number;
59
- export declare function firstOrDefault<T, NotFound = T>(array: ReadonlyArray<T>, notFoundValue: NotFound): T | NotFound;
60
- export declare function firstOrDefault<T>(array: ReadonlyArray<T>): T | undefined;
61
- export declare function commonPrefixLength<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): number;
62
- export declare function flatten<T>(arr: T[][]): T[];
63
- export declare function range(to: number): number[];
64
- export declare function range(from: number, to: number): number[];
65
- export declare function index<T>(array: ReadonlyArray<T>, indexer: (t: T) => string): {
66
- [key: string]: T;
67
- };
68
- export declare function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper: (t: T) => R): {
69
- [key: string]: R;
70
- };
71
- /**
72
- * Inserts an element into an array. Returns a function which, when
73
- * called, will remove that element from the array.
74
- */
75
- export declare function insert<T>(array: T[], element: T): () => void;
76
- /**
77
- * Removes an element from an array if it can be found.
78
- */
79
- export declare function remove<T>(array: T[], element: T): T | undefined;
80
- /**
81
- * Insert `insertArr` inside `target` at `insertIndex`.
82
- * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
83
- */
84
- export declare function arrayInsert<T>(target: T[], insertIndex: number, insertArr: T[]): T[];
85
- /**
86
- * Uses Fisher-Yates shuffle to shuffle the given array
87
- */
88
- export declare function shuffle<T>(array: T[], _seed?: number): void;
89
- /**
90
- * Pushes an element to the start of the array, if found.
91
- */
92
- export declare function pushToStart<T>(arr: T[], value: T): void;
93
- /**
94
- * Pushes an element to the end of the array, if found.
95
- */
96
- export declare function pushToEnd<T>(arr: T[], value: T): void;
97
- export declare function mapArrayOrNot<T, U>(items: T | T[], fn: (_: T) => U): U | U[];
98
- export declare function asArray<T>(x: T | T[]): T[];
99
- export declare function asArray<T>(x: T | readonly T[]): readonly T[];
100
- export declare function getRandomElement<T>(arr: T[]): T | undefined;
101
- /**
102
- * Returns the first mapped value of the array which is not undefined.
103
- */
104
- export declare function mapFind<T, R>(array: Iterable<T>, mapFn: (value: T) => R | undefined): R | undefined;
105
- /**
106
- * Insert the new items in the array.
107
- * @param array The original array.
108
- * @param start The zero-based location in the array from which to start inserting elements.
109
- * @param newItems The items to be inserted
110
- */
111
- export declare function insertInto<T>(array: T[], start: number, newItems: T[]): void;
112
- /**
113
- * Removes elements from an array and inserts new elements in their place, returning the deleted elements. Alternative to the native Array.splice method, it
114
- * can only support limited number of items due to the maximum call stack size limit.
115
- * @param array The original array.
116
- * @param start The zero-based location in the array from which to start removing elements.
117
- * @param deleteCount The number of elements to remove.
118
- * @returns An array containing the elements that were deleted.
119
- */
120
- export declare function splice<T>(array: T[], start: number, deleteCount: number, newItems: T[]): T[];
121
- /**
122
- * A comparator `c` defines a total order `<=` on `T` as following:
123
- * `c(a, b) <= 0` iff `a` <= `b`.
124
- * We also have `c(a, b) == 0` iff `c(b, a) == 0`.
125
- */
126
- export declare type Comparator<T> = (a: T, b: T) => number;
127
- export declare function compareBy<TItem, TCompareBy>(selector: (item: TItem) => TCompareBy, comparator: Comparator<TCompareBy>): Comparator<TItem>;
128
- /**
129
- * The natural order on numbers.
130
- */
131
- export declare const numberComparator: Comparator<number>;
132
- /**
133
- * Returns the first item that is equal to or greater than every other item.
134
- */
135
- export declare function findMaxBy<T>(items: readonly T[], comparator: Comparator<T>): T | undefined;
136
- /**
137
- * Returns the last item that is equal to or greater than every other item.
138
- */
139
- export declare function findLastMaxBy<T>(items: readonly T[], comparator: Comparator<T>): T | undefined;
140
- /**
141
- * Returns the first item that is equal to or less than every other item.
142
- */
143
- export declare function findMinBy<T>(items: readonly T[], comparator: Comparator<T>): T | undefined;
144
- export declare class ArrayQueue<T> {
145
- private readonly items;
146
- private firstIdx;
147
- private lastIdx;
148
- /**
149
- * Constructs a queue that is backed by the given array. Runtime is O(1).
150
- */
151
- constructor(items: T[]);
152
- get length(): number;
153
- /**
154
- * Consumes elements from the beginning of the queue as long as the predicate returns true.
155
- * If no elements were consumed, `null` is returned. Has a runtime of O(result.length).
156
- */
157
- takeWhile(predicate: (value: T) => boolean): T[] | null;
158
- /**
159
- * Consumes elements from the end of the queue as long as the predicate returns true.
160
- * If no elements were consumed, `null` is returned.
161
- * The result has the same order as the underlying array!
162
- */
163
- takeFromEndWhile(predicate: (value: T) => boolean): T[] | null;
164
- peek(): T | undefined;
165
- dequeue(): T | undefined;
166
- takeCount(count: number): T[];
167
- }
168
- export {};
@@ -1,510 +0,0 @@
1
- import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
2
- import { Event } from 'vs/base/common/event';
3
- import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
4
- export declare function isThenable<T>(obj: unknown): obj is Promise<T>;
5
- export interface CancelablePromise<T> extends Promise<T> {
6
- cancel(): void;
7
- }
8
- export declare function createCancelablePromise<T>(callback: (token: CancellationToken) => Promise<T>): CancelablePromise<T>;
9
- /**
10
- * Returns a promise that resolves with `undefined` as soon as the passed token is cancelled.
11
- * @see {@link raceCancellationError}
12
- */
13
- export declare function raceCancellation<T>(promise: Promise<T>, token: CancellationToken): Promise<T | undefined>;
14
- /**
15
- * Returns a promise that resolves with `defaultValue` as soon as the passed token is cancelled.
16
- * @see {@link raceCancellationError}
17
- */
18
- export declare function raceCancellation<T>(promise: Promise<T>, token: CancellationToken, defaultValue: T): Promise<T>;
19
- /**
20
- * Returns a promise that rejects with an {@CancellationError} as soon as the passed token is cancelled.
21
- * @see {@link raceCancellation}
22
- */
23
- export declare function raceCancellationError<T>(promise: Promise<T>, token: CancellationToken): Promise<T>;
24
- /**
25
- * Returns as soon as one of the promises is resolved and cancels remaining promises
26
- */
27
- export declare function raceCancellablePromises<T>(cancellablePromises: CancelablePromise<T>[]): Promise<T>;
28
- export declare function raceTimeout<T>(promise: Promise<T>, timeout: number, onTimeout?: () => void): Promise<T | undefined>;
29
- export interface ITask<T> {
30
- (): T;
31
- }
32
- /**
33
- * A helper to prevent accumulation of sequential async tasks.
34
- *
35
- * Imagine a mail man with the sole task of delivering letters. As soon as
36
- * a letter submitted for delivery, he drives to the destination, delivers it
37
- * and returns to his base. Imagine that during the trip, N more letters were submitted.
38
- * When the mail man returns, he picks those N letters and delivers them all in a
39
- * single trip. Even though N+1 submissions occurred, only 2 deliveries were made.
40
- *
41
- * The throttler implements this via the queue() method, by providing it a task
42
- * factory. Following the example:
43
- *
44
- * const throttler = new Throttler();
45
- * const letters = [];
46
- *
47
- * function deliver() {
48
- * const lettersToDeliver = letters;
49
- * letters = [];
50
- * return makeTheTrip(lettersToDeliver);
51
- * }
52
- *
53
- * function onLetterReceived(l) {
54
- * letters.push(l);
55
- * throttler.queue(deliver);
56
- * }
57
- */
58
- export declare class Throttler {
59
- private activePromise;
60
- private queuedPromise;
61
- private queuedPromiseFactory;
62
- constructor();
63
- queue<T>(promiseFactory: ITask<Promise<T>>): Promise<T>;
64
- }
65
- export declare class Sequencer {
66
- private current;
67
- queue<T>(promiseTask: ITask<Promise<T>>): Promise<T>;
68
- }
69
- export declare class SequencerByKey<TKey> {
70
- private promiseMap;
71
- queue<T>(key: TKey, promiseTask: ITask<Promise<T>>): Promise<T>;
72
- }
73
- /** Can be passed into the Delayed to defer using a microtask */
74
- export declare const MicrotaskDelay: unique symbol;
75
- /**
76
- * A helper to delay (debounce) execution of a task that is being requested often.
77
- *
78
- * Following the throttler, now imagine the mail man wants to optimize the number of
79
- * trips proactively. The trip itself can be long, so he decides not to make the trip
80
- * as soon as a letter is submitted. Instead he waits a while, in case more
81
- * letters are submitted. After said waiting period, if no letters were submitted, he
82
- * decides to make the trip. Imagine that N more letters were submitted after the first
83
- * one, all within a short period of time between each other. Even though N+1
84
- * submissions occurred, only 1 delivery was made.
85
- *
86
- * The delayer offers this behavior via the trigger() method, into which both the task
87
- * to be executed and the waiting period (delay) must be passed in as arguments. Following
88
- * the example:
89
- *
90
- * const delayer = new Delayer(WAITING_PERIOD);
91
- * const letters = [];
92
- *
93
- * function letterReceived(l) {
94
- * letters.push(l);
95
- * delayer.trigger(() => { return makeTheTrip(); });
96
- * }
97
- */
98
- export declare class Delayer<T> implements IDisposable {
99
- defaultDelay: number | typeof MicrotaskDelay;
100
- private deferred;
101
- private completionPromise;
102
- private doResolve;
103
- private doReject;
104
- private task;
105
- constructor(defaultDelay: number | typeof MicrotaskDelay);
106
- trigger(task: ITask<T | Promise<T>>, delay?: number | typeof MicrotaskDelay): Promise<T>;
107
- isTriggered(): boolean;
108
- cancel(): void;
109
- private cancelTimeout;
110
- dispose(): void;
111
- }
112
- /**
113
- * A helper to delay execution of a task that is being requested often, while
114
- * preventing accumulation of consecutive executions, while the task runs.
115
- *
116
- * The mail man is clever and waits for a certain amount of time, before going
117
- * out to deliver letters. While the mail man is going out, more letters arrive
118
- * and can only be delivered once he is back. Once he is back the mail man will
119
- * do one more trip to deliver the letters that have accumulated while he was out.
120
- */
121
- export declare class ThrottledDelayer<T> {
122
- private delayer;
123
- private throttler;
124
- constructor(defaultDelay: number);
125
- trigger(promiseFactory: ITask<Promise<T>>, delay?: number): Promise<T>;
126
- isTriggered(): boolean;
127
- cancel(): void;
128
- dispose(): void;
129
- }
130
- /**
131
- * A barrier that is initially closed and then becomes opened permanently.
132
- */
133
- export declare class Barrier {
134
- private _isOpen;
135
- private _promise;
136
- private _completePromise;
137
- constructor();
138
- isOpen(): boolean;
139
- open(): void;
140
- wait(): Promise<boolean>;
141
- }
142
- /**
143
- * A barrier that is initially closed and then becomes opened permanently after a certain period of
144
- * time or when open is called explicitly
145
- */
146
- export declare class AutoOpenBarrier extends Barrier {
147
- private readonly _timeout;
148
- constructor(autoOpenTimeMs: number);
149
- open(): void;
150
- }
151
- export declare function timeout(millis: number): CancelablePromise<void>;
152
- export declare function timeout(millis: number, token: CancellationToken): Promise<void>;
153
- export declare function disposableTimeout(handler: () => void, timeout?: number): IDisposable;
154
- /**
155
- * Runs the provided list of promise factories in sequential order. The returned
156
- * promise will complete to an array of results from each promise.
157
- */
158
- export declare function sequence<T>(promiseFactories: ITask<Promise<T>>[]): Promise<T[]>;
159
- export declare function first<T>(promiseFactories: ITask<Promise<T>>[], shouldStop?: (t: T) => boolean, defaultValue?: T | null): Promise<T | null>;
160
- /**
161
- * Returns the result of the first promise that matches the "shouldStop",
162
- * running all promises in parallel. Supports cancelable promises.
163
- */
164
- export declare function firstParallel<T>(promiseList: Promise<T>[], shouldStop?: (t: T) => boolean, defaultValue?: T | null): Promise<T | null>;
165
- export declare function firstParallel<T, R extends T>(promiseList: Promise<T>[], shouldStop: (t: T) => t is R, defaultValue?: R | null): Promise<R | null>;
166
- export interface ILimiter<T> {
167
- readonly size: number;
168
- queue(factory: ITask<Promise<T>>): Promise<T>;
169
- }
170
- /**
171
- * A helper to queue N promises and run them all with a max degree of parallelism. The helper
172
- * ensures that at any time no more than M promises are running at the same time.
173
- */
174
- export declare class Limiter<T> implements ILimiter<T> {
175
- private _size;
176
- private runningPromises;
177
- private maxDegreeOfParalellism;
178
- private outstandingPromises;
179
- private readonly _onFinished;
180
- constructor(maxDegreeOfParalellism: number);
181
- get onFinished(): Event<void>;
182
- get size(): number;
183
- queue(factory: ITask<Promise<T>>): Promise<T>;
184
- private consume;
185
- private consumed;
186
- dispose(): void;
187
- }
188
- /**
189
- * A queue is handles one promise at a time and guarantees that at any time only one promise is executing.
190
- */
191
- export declare class Queue<T> extends Limiter<T> {
192
- constructor();
193
- }
194
- /**
195
- * A helper to organize queues per resource. The ResourceQueue makes sure to manage queues per resource
196
- * by disposing them once the queue is empty.
197
- */
198
- export declare class ResourceQueue implements IDisposable {
199
- private readonly queues;
200
- private readonly drainers;
201
- whenDrained(): Promise<void>;
202
- private isDrained;
203
- private releaseDrainers;
204
- dispose(): void;
205
- }
206
- export declare class TimeoutTimer implements IDisposable {
207
- private _token;
208
- constructor();
209
- constructor(runner: () => void, timeout: number);
210
- dispose(): void;
211
- cancel(): void;
212
- cancelAndSet(runner: () => void, timeout: number): void;
213
- setIfNotSet(runner: () => void, timeout: number): void;
214
- }
215
- export declare class IntervalTimer implements IDisposable {
216
- private _token;
217
- constructor();
218
- dispose(): void;
219
- cancel(): void;
220
- cancelAndSet(runner: () => void, interval: number): void;
221
- }
222
- export declare class RunOnceScheduler {
223
- protected runner: ((...args: unknown[]) => void) | null;
224
- private timeoutToken;
225
- private timeout;
226
- private timeoutHandler;
227
- constructor(runner: (...args: any[]) => void, delay: number);
228
- /**
229
- * Dispose RunOnceScheduler
230
- */
231
- dispose(): void;
232
- /**
233
- * Cancel current scheduled runner (if any).
234
- */
235
- cancel(): void;
236
- /**
237
- * Cancel previous runner (if any) & schedule a new runner.
238
- */
239
- schedule(delay?: number): void;
240
- get delay(): number;
241
- set delay(value: number);
242
- /**
243
- * Returns true if scheduled.
244
- */
245
- isScheduled(): boolean;
246
- private onTimeout;
247
- protected doRun(): void;
248
- }
249
- /**
250
- * Same as `RunOnceScheduler`, but doesn't count the time spent in sleep mode.
251
- * > **NOTE**: Only offers 1s resolution.
252
- *
253
- * When calling `setTimeout` with 3hrs, and putting the computer immediately to sleep
254
- * for 8hrs, `setTimeout` will fire **as soon as the computer wakes from sleep**. But
255
- * this scheduler will execute 3hrs **after waking the computer from sleep**.
256
- */
257
- export declare class ProcessTimeRunOnceScheduler {
258
- private runner;
259
- private timeout;
260
- private counter;
261
- private intervalToken;
262
- private intervalHandler;
263
- constructor(runner: () => void, delay: number);
264
- dispose(): void;
265
- cancel(): void;
266
- /**
267
- * Cancel previous runner (if any) & schedule a new runner.
268
- */
269
- schedule(delay?: number): void;
270
- /**
271
- * Returns true if scheduled.
272
- */
273
- isScheduled(): boolean;
274
- private onInterval;
275
- }
276
- export declare class RunOnceWorker<T> extends RunOnceScheduler {
277
- private units;
278
- constructor(runner: (units: T[]) => void, timeout: number);
279
- work(unit: T): void;
280
- protected doRun(): void;
281
- dispose(): void;
282
- }
283
- export interface IThrottledWorkerOptions {
284
- /**
285
- * maximum of units the worker will pass onto handler at once
286
- */
287
- maxWorkChunkSize: number;
288
- /**
289
- * maximum of units the worker will keep in memory for processing
290
- */
291
- maxBufferedWork: number | undefined;
292
- /**
293
- * delay before processing the next round of chunks when chunk size exceeds limits
294
- */
295
- throttleDelay: number;
296
- }
297
- /**
298
- * The `ThrottledWorker` will accept units of work `T`
299
- * to handle. The contract is:
300
- * * there is a maximum of units the worker can handle at once (via `maxWorkChunkSize`)
301
- * * there is a maximum of units the worker will keep in memory for processing (via `maxBufferedWork`)
302
- * * after having handled `maxWorkChunkSize` units, the worker needs to rest (via `throttleDelay`)
303
- */
304
- export declare class ThrottledWorker<T> extends Disposable {
305
- private options;
306
- private readonly handler;
307
- private readonly pendingWork;
308
- private readonly throttler;
309
- private disposed;
310
- constructor(options: IThrottledWorkerOptions, handler: (units: T[]) => void);
311
- /**
312
- * The number of work units that are pending to be processed.
313
- */
314
- get pending(): number;
315
- /**
316
- * Add units to be worked on. Use `pending` to figure out
317
- * how many units are not yet processed after this method
318
- * was called.
319
- *
320
- * @returns whether the work was accepted or not. If the
321
- * worker is disposed, it will not accept any more work.
322
- * If the number of pending units would become larger
323
- * than `maxPendingWork`, more work will also not be accepted.
324
- */
325
- work(units: readonly T[]): boolean;
326
- private doWork;
327
- dispose(): void;
328
- }
329
- export interface IdleDeadline {
330
- readonly didTimeout: boolean;
331
- timeRemaining(): number;
332
- }
333
- /**
334
- * Execute the callback the next time the browser is idle
335
- */
336
- export declare let runWhenIdle: (callback: (idle: IdleDeadline) => void, timeout?: number) => IDisposable;
337
- /**
338
- * An implementation of the "idle-until-urgent"-strategy as introduced
339
- * here: https://philipwalton.com/articles/idle-until-urgent/
340
- */
341
- export declare class IdleValue<T> {
342
- private readonly _executor;
343
- private readonly _handle;
344
- private _didRun;
345
- private _value?;
346
- private _error;
347
- constructor(executor: () => T);
348
- dispose(): void;
349
- get value(): T;
350
- get isInitialized(): boolean;
351
- }
352
- export declare function retry<T>(task: ITask<Promise<T>>, delay: number, retries: number): Promise<T>;
353
- export interface ITaskSequentializerWithPendingTask {
354
- readonly pending: Promise<void>;
355
- }
356
- export declare class TaskSequentializer {
357
- private _pending?;
358
- private _next?;
359
- hasPending(taskId?: number): this is ITaskSequentializerWithPendingTask;
360
- get pending(): Promise<void> | undefined;
361
- cancelPending(): void;
362
- setPending(taskId: number, promise: Promise<void>, onCancel?: () => void): Promise<void>;
363
- private donePending;
364
- private triggerNext;
365
- setNext(run: () => Promise<void>): Promise<void>;
366
- }
367
- /**
368
- * The `IntervalCounter` allows to count the number
369
- * of calls to `increment()` over a duration of
370
- * `interval`. This utility can be used to conditionally
371
- * throttle a frequent task when a certain threshold
372
- * is reached.
373
- */
374
- export declare class IntervalCounter {
375
- private readonly interval;
376
- private readonly nowFn;
377
- private lastIncrementTime;
378
- private value;
379
- constructor(interval: number, nowFn?: () => number);
380
- increment(): number;
381
- }
382
- export declare type ValueCallback<T = unknown> = (value: T | Promise<T>) => void;
383
- /**
384
- * Creates a promise whose resolution or rejection can be controlled imperatively.
385
- */
386
- export declare class DeferredPromise<T> {
387
- private completeCallback;
388
- private errorCallback;
389
- private rejected;
390
- private resolved;
391
- get isRejected(): boolean;
392
- get isResolved(): boolean;
393
- get isSettled(): boolean;
394
- p: Promise<T>;
395
- constructor();
396
- complete(value: T): Promise<void>;
397
- error(err: unknown): Promise<void>;
398
- cancel(): void;
399
- }
400
- export declare namespace Promises {
401
- /**
402
- * A drop-in replacement for `Promise.all` with the only difference
403
- * that the method awaits every promise to either fulfill or reject.
404
- *
405
- * Similar to `Promise.all`, only the first error will be returned
406
- * if any.
407
- */
408
- function settled<T>(promises: Promise<T>[]): Promise<T[]>;
409
- /**
410
- * A helper to create a new `Promise<T>` with a body that is a promise
411
- * itself. By default, an error that raises from the async body will
412
- * end up as a unhandled rejection, so this utility properly awaits the
413
- * body and rejects the promise as a normal promise does without async
414
- * body.
415
- *
416
- * This method should only be used in rare cases where otherwise `async`
417
- * cannot be used (e.g. when callbacks are involved that require this).
418
- */
419
- function withAsyncBody<T, E = Error>(bodyFn: (resolve: (value: T) => unknown, reject: (error: E) => unknown) => Promise<unknown>): Promise<T>;
420
- }
421
- /**
422
- * An object that allows to emit async values asynchronously or bring the iterable to an error state using `reject()`.
423
- * This emitter is valid only for the duration of the executor (until the promise returned by the executor settles).
424
- */
425
- export interface AsyncIterableEmitter<T> {
426
- /**
427
- * The value will be appended at the end.
428
- *
429
- * **NOTE** If `reject()` has already been called, this method has no effect.
430
- */
431
- emitOne(value: T): void;
432
- /**
433
- * The values will be appended at the end.
434
- *
435
- * **NOTE** If `reject()` has already been called, this method has no effect.
436
- */
437
- emitMany(values: T[]): void;
438
- /**
439
- * Writing an error will permanently invalidate this iterable.
440
- * The current users will receive an error thrown, as will all future users.
441
- *
442
- * **NOTE** If `reject()` have already been called, this method has no effect.
443
- */
444
- reject(error: Error): void;
445
- }
446
- /**
447
- * An executor for the `AsyncIterableObject` that has access to an emitter.
448
- */
449
- export interface AyncIterableExecutor<T> {
450
- /**
451
- * @param emitter An object that allows to emit async values valid only for the duration of the executor.
452
- */
453
- (emitter: AsyncIterableEmitter<T>): void | Promise<void>;
454
- }
455
- /**
456
- * A rich implementation for an `AsyncIterable<T>`.
457
- */
458
- export declare class AsyncIterableObject<T> implements AsyncIterable<T> {
459
- static fromArray<T>(items: T[]): AsyncIterableObject<T>;
460
- static fromPromise<T>(promise: Promise<T[]>): AsyncIterableObject<T>;
461
- static fromPromises<T>(promises: Promise<T>[]): AsyncIterableObject<T>;
462
- static merge<T>(iterables: AsyncIterable<T>[]): AsyncIterableObject<T>;
463
- static EMPTY: AsyncIterableObject<any>;
464
- private _state;
465
- private _results;
466
- private _error;
467
- private readonly _onStateChanged;
468
- constructor(executor: AyncIterableExecutor<T>);
469
- [Symbol.asyncIterator](): AsyncIterator<T, undefined, undefined>;
470
- static map<T, R>(iterable: AsyncIterable<T>, mapFn: (item: T) => R): AsyncIterableObject<R>;
471
- map<R>(mapFn: (item: T) => R): AsyncIterableObject<R>;
472
- static filter<T>(iterable: AsyncIterable<T>, filterFn: (item: T) => boolean): AsyncIterableObject<T>;
473
- filter(filterFn: (item: T) => boolean): AsyncIterableObject<T>;
474
- static coalesce<T>(iterable: AsyncIterable<T | undefined | null>): AsyncIterableObject<T>;
475
- coalesce(): AsyncIterableObject<NonNullable<T>>;
476
- static toPromise<T>(iterable: AsyncIterable<T>): Promise<T[]>;
477
- toPromise(): Promise<T[]>;
478
- /**
479
- * The value will be appended at the end.
480
- *
481
- * **NOTE** If `resolve()` or `reject()` have already been called, this method has no effect.
482
- */
483
- private emitOne;
484
- /**
485
- * The values will be appended at the end.
486
- *
487
- * **NOTE** If `resolve()` or `reject()` have already been called, this method has no effect.
488
- */
489
- private emitMany;
490
- /**
491
- * Calling `resolve()` will mark the result array as complete.
492
- *
493
- * **NOTE** `resolve()` must be called, otherwise all consumers of this iterable will hang indefinitely, similar to a non-resolved promise.
494
- * **NOTE** If `resolve()` or `reject()` have already been called, this method has no effect.
495
- */
496
- private resolve;
497
- /**
498
- * Writing an error will permanently invalidate this iterable.
499
- * The current users will receive an error thrown, as will all future users.
500
- *
501
- * **NOTE** If `resolve()` or `reject()` have already been called, this method has no effect.
502
- */
503
- private reject;
504
- }
505
- export declare class CancelableAsyncIterableObject<T> extends AsyncIterableObject<T> {
506
- private readonly _source;
507
- constructor(_source: CancellationTokenSource, executor: AyncIterableExecutor<T>);
508
- cancel(): void;
509
- }
510
- export declare function createCancelableAsyncIterable<T>(callback: (token: CancellationToken) => AsyncIterable<T>): CancelableAsyncIterableObject<T>;