@eclipse-glsp/protocol 2.7.0-next.2 → 2.7.0-next.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/lib/action-protocol/base-protocol.d.ts +7 -1
- package/lib/action-protocol/base-protocol.d.ts.map +1 -1
- package/lib/action-protocol/base-protocol.js +1 -1
- package/lib/action-protocol/base-protocol.js.map +1 -1
- package/lib/action-protocol/contexts.d.ts +44 -1
- package/lib/action-protocol/contexts.d.ts.map +1 -1
- package/lib/action-protocol/contexts.js +35 -2
- package/lib/action-protocol/contexts.js.map +1 -1
- package/lib/action-protocol/types.d.ts +9 -1
- package/lib/action-protocol/types.d.ts.map +1 -1
- package/lib/action-protocol/types.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/sprotty-geometry-point.d.ts +29 -1
- package/lib/sprotty-geometry-point.d.ts.map +1 -1
- package/lib/sprotty-geometry-point.js +4 -1
- package/lib/sprotty-geometry-point.js.map +1 -1
- package/lib/utils/array-util.d.ts +1 -0
- package/lib/utils/array-util.d.ts.map +1 -1
- package/lib/utils/array-util.js +18 -0
- package/lib/utils/array-util.js.map +1 -1
- package/lib/utils/function-util.d.ts +34 -0
- package/lib/utils/function-util.d.ts.map +1 -0
- package/lib/utils/function-util.js +61 -0
- package/lib/utils/function-util.js.map +1 -0
- package/lib/utils/math-util.d.ts +6 -1
- package/lib/utils/math-util.d.ts.map +1 -1
- package/lib/utils/math-util.js +7 -1
- package/lib/utils/math-util.js.map +1 -1
- package/package.json +3 -3
- package/src/action-protocol/base-protocol.ts +7 -1
- package/src/action-protocol/contexts.ts +65 -1
- package/src/action-protocol/types.ts +11 -1
- package/src/index.ts +1 -0
- package/src/sprotty-geometry-point.spec.ts +48 -1
- package/src/sprotty-geometry-point.ts +38 -2
- package/src/utils/array-util.spec.ts +205 -0
- package/src/utils/array-util.ts +17 -0
- package/src/utils/function-util.spec.ts +109 -0
- package/src/utils/function-util.ts +81 -0
- package/src/utils/math-util.ts +7 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Minimal lodash-compatible debounce subset.
|
|
19
|
+
* Compared to `lodash.DebouncedFunc<T>`:
|
|
20
|
+
* - The debounced call returns `void` instead of `ReturnType<T> | undefined`.
|
|
21
|
+
* - `flush()`, `pending()`, and `maxWait` are not supported.
|
|
22
|
+
*/
|
|
23
|
+
export interface DebouncedFunc<T extends (...args: any[]) => any> {
|
|
24
|
+
(...args: Parameters<T>): void;
|
|
25
|
+
cancel(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DebounceSettings {
|
|
29
|
+
leading?: boolean;
|
|
30
|
+
trailing?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Minimal lodash-compatible debounce. See {@link DebouncedFunc} for intentional differences from `lodash.debounce`.
|
|
35
|
+
*/
|
|
36
|
+
export function debounce<T extends (...args: any[]) => any>(func: T, wait: number, options: DebounceSettings = {}): DebouncedFunc<T> {
|
|
37
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
38
|
+
let lastArgs: Parameters<T> | undefined;
|
|
39
|
+
let lastThis: ThisParameterType<T> | undefined;
|
|
40
|
+
let hasPendingCall = false;
|
|
41
|
+
|
|
42
|
+
const leading = options.leading ?? false;
|
|
43
|
+
const trailing = options.trailing ?? true;
|
|
44
|
+
|
|
45
|
+
const debounced = function (this: ThisParameterType<T>, ...args: Parameters<T>): void {
|
|
46
|
+
const shouldCallLeading = leading && timeout === undefined;
|
|
47
|
+
|
|
48
|
+
lastArgs = args;
|
|
49
|
+
lastThis = this;
|
|
50
|
+
hasPendingCall = true;
|
|
51
|
+
|
|
52
|
+
if (shouldCallLeading) {
|
|
53
|
+
func.apply(lastThis, lastArgs);
|
|
54
|
+
hasPendingCall = false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (timeout !== undefined) {
|
|
58
|
+
clearTimeout(timeout);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
timeout = setTimeout(() => {
|
|
62
|
+
timeout = undefined;
|
|
63
|
+
if (trailing && hasPendingCall && lastArgs !== undefined) {
|
|
64
|
+
func.apply(lastThis, lastArgs);
|
|
65
|
+
hasPendingCall = false;
|
|
66
|
+
}
|
|
67
|
+
}, wait);
|
|
68
|
+
} as DebouncedFunc<T>;
|
|
69
|
+
|
|
70
|
+
debounced.cancel = () => {
|
|
71
|
+
if (timeout !== undefined) {
|
|
72
|
+
clearTimeout(timeout);
|
|
73
|
+
timeout = undefined;
|
|
74
|
+
}
|
|
75
|
+
lastArgs = undefined;
|
|
76
|
+
lastThis = undefined;
|
|
77
|
+
hasPendingCall = false;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return debounced;
|
|
81
|
+
}
|
package/src/utils/math-util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2024 Axon Ivy AG and others.
|
|
2
|
+
* Copyright (c) 2024-2026 Axon Ivy AG and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Default epsilon for loose numeric equality checks, matching the tolerance
|
|
19
|
+
* used by sprotty's `almostEquals` convention.
|
|
20
|
+
*/
|
|
21
|
+
export const ALMOST_EQUAL_EPSILON = 1e-3;
|
|
22
|
+
|
|
17
23
|
export function equalUpTo(one: number, other: number, epsilon: number = Number.EPSILON): boolean {
|
|
18
24
|
return Math.abs(one - other) <= epsilon;
|
|
19
25
|
}
|