@codingame/monaco-vscode-api 1.67.8-dev.0 → 1.67.10

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,46 @@
1
+ import { CancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
2
+ function isThenable(obj) {
3
+ return !!obj && typeof obj.then === 'function';
4
+ }
5
+ function raceCancellationError(promise, token) {
6
+ return (
7
+ new Promise((resolve, reject) => {
8
+ const ref = token.onCancellationRequested(() => {
9
+ ref.dispose();
10
+ reject( new CancellationError());
11
+ });
12
+ promise.then(resolve, reject).finally(() => ref.dispose());
13
+ })
14
+ );
15
+ }
16
+ function asPromise(callback) {
17
+ return (
18
+ new Promise((resolve, reject) => {
19
+ const item = callback();
20
+ if (isThenable(item)) {
21
+ item.then(resolve, reject);
22
+ }
23
+ else {
24
+ resolve(item);
25
+ }
26
+ })
27
+ );
28
+ }
29
+ class IntervalCounter {
30
+ constructor(interval, nowFn = () => Date.now()) {
31
+ this.interval = interval;
32
+ this.nowFn = nowFn;
33
+ this.lastIncrementTime = 0;
34
+ this.value = 0;
35
+ }
36
+ increment() {
37
+ const now = this.nowFn();
38
+ if (now - this.lastIncrementTime > this.interval) {
39
+ this.lastIncrementTime = now;
40
+ this.value = 0;
41
+ }
42
+ this.value++;
43
+ return this.value;
44
+ }
45
+ }
46
+ export { IntervalCounter as I, asPromise as a, raceCancellationError as r };
@@ -0,0 +1,7 @@
1
+ interface IEditorOverrideServices {
2
+ [index: string]: any;
3
+ }
4
+
5
+ declare function getServiceOverride(container: HTMLElement): IEditorOverrideServices;
6
+
7
+ export { getServiceOverride as default };