@hpcc-js/util 3.4.1 → 3.4.2
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/dist/index.js +1 -2223
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/dispatch.ts +9 -3
- package/types/dispatch.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/util",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "hpcc-js - Utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@xmldom/xmldom": "0.9.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@hpcc-js/esbuild-plugins": "^1.
|
|
44
|
+
"@hpcc-js/esbuild-plugins": "^1.7.0"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"bugs": {
|
|
54
54
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
55
55
|
},
|
|
56
|
-
"homepage": "https://github.com/hpcc-systems/Visualization/tree/
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"homepage": "https://github.com/hpcc-systems/Visualization/tree/main/packages/util",
|
|
57
|
+
"gitHead": "5e5fc8d746e6a42c58da2ec4f55f2f7cbaeff611"
|
|
58
58
|
}
|
package/src/dispatch.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { IObserverHandle } from "./observer.ts";
|
|
2
2
|
import { root } from "./platform.ts";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type RequestAnimationFrame = (callback: FrameRequestCallback) => number | undefined;
|
|
5
5
|
export type CancelAnimationFrame = (handle: number) => void | undefined;
|
|
6
6
|
|
|
7
|
-
let requestAnimationFrame:
|
|
7
|
+
let requestAnimationFrame: RequestAnimationFrame;
|
|
8
8
|
// let cancelAnimationFrame: CancelAnimationFrame;
|
|
9
9
|
|
|
10
10
|
(function () {
|
|
@@ -53,6 +53,7 @@ export class Dispatch<T extends Message = Message> {
|
|
|
53
53
|
private _observerID: number = 0;
|
|
54
54
|
private _observers: ObserverAdapter<T>[] = [];
|
|
55
55
|
private _messageBuffer: T[] = [];
|
|
56
|
+
private _rafHandle: number | undefined = undefined;
|
|
56
57
|
|
|
57
58
|
constructor() {
|
|
58
59
|
}
|
|
@@ -72,6 +73,7 @@ export class Dispatch<T extends Message = Message> {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
private dispatchAll() {
|
|
76
|
+
this._rafHandle = undefined;
|
|
75
77
|
this.dispatch(this.messages());
|
|
76
78
|
this.flush();
|
|
77
79
|
}
|
|
@@ -95,12 +97,16 @@ export class Dispatch<T extends Message = Message> {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
send(msg: T) {
|
|
100
|
+
if (!this.hasObserver()) return;
|
|
98
101
|
this.dispatch([msg]);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
post(msg: T) {
|
|
105
|
+
if (!this.hasObserver()) return;
|
|
102
106
|
this._messageBuffer.push(msg);
|
|
103
|
-
|
|
107
|
+
if (this._rafHandle === undefined) {
|
|
108
|
+
this._rafHandle = requestAnimationFrame(() => this.dispatchAll());
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
attach(callback: Callback<T>, type?: MessageConstructor<T>): IObserverHandle {
|
package/types/dispatch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IObserverHandle } from "./observer.ts";
|
|
2
|
-
export type
|
|
2
|
+
export type RequestAnimationFrame = (callback: FrameRequestCallback) => number | undefined;
|
|
3
3
|
export type CancelAnimationFrame = (handle: number) => void | undefined;
|
|
4
4
|
export declare class Message {
|
|
5
5
|
get canConflate(): boolean;
|
|
@@ -13,6 +13,7 @@ export declare class Dispatch<T extends Message = Message> {
|
|
|
13
13
|
private _observerID;
|
|
14
14
|
private _observers;
|
|
15
15
|
private _messageBuffer;
|
|
16
|
+
private _rafHandle;
|
|
16
17
|
constructor();
|
|
17
18
|
private observers;
|
|
18
19
|
private messages;
|