@vuu-ui/vuu-data-remote 4.0.0-alpha.26 → 4.0.0-alpha.28
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/package.json +8 -8
- package/src/ConnectionManager.js +17 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0-alpha.
|
|
2
|
+
"version": "4.0.0-alpha.28",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@vuu-ui/vuu-data-types": "4.0.0-alpha.
|
|
16
|
-
"@vuu-ui/vuu-table-types": "4.0.0-alpha.
|
|
17
|
-
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.
|
|
18
|
-
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.
|
|
15
|
+
"@vuu-ui/vuu-data-types": "4.0.0-alpha.28",
|
|
16
|
+
"@vuu-ui/vuu-table-types": "4.0.0-alpha.28",
|
|
17
|
+
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.28",
|
|
18
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.28"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vuu-ui/vuu-data-editing": "4.0.0-alpha.
|
|
22
|
-
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.
|
|
23
|
-
"@vuu-ui/vuu-utils": "4.0.0-alpha.
|
|
21
|
+
"@vuu-ui/vuu-data-editing": "4.0.0-alpha.28",
|
|
22
|
+
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.28",
|
|
23
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.28"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"README.md",
|
package/src/ConnectionManager.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isWebSocketConnectionStatus } from "./WebSocketConnection.js";
|
|
|
3
3
|
import { DedicatedWorker } from "./DedicatedWorker.js";
|
|
4
4
|
import { shouldMessageBeRoutedToDataSource } from "./data-source.js";
|
|
5
5
|
const DEFAULT_CONNECTION_ID = "portal";
|
|
6
|
+
const MAX_CLOSED_VIEWPORTS = 500;
|
|
6
7
|
class ConnectionChannel {
|
|
7
8
|
onConnectionStatus;
|
|
8
9
|
onConnectionMetrics;
|
|
@@ -10,6 +11,7 @@ class ConnectionChannel {
|
|
|
10
11
|
#deferredServerAPI = new DeferredPromise();
|
|
11
12
|
#pendingRequests = new Map();
|
|
12
13
|
#viewports = new Map();
|
|
14
|
+
#closedViewports = new Set();
|
|
13
15
|
#worker;
|
|
14
16
|
#serverAPI;
|
|
15
17
|
constructor(onConnectionStatus, onConnectionMetrics){
|
|
@@ -19,6 +21,7 @@ class ConnectionChannel {
|
|
|
19
21
|
this.#serverAPI = {
|
|
20
22
|
subscribe: (message, callback)=>{
|
|
21
23
|
if (this.#viewports.get(message.viewport)) throw Error("ConnectionManager attempting to subscribe with an existing viewport id");
|
|
24
|
+
this.#closedViewports.delete(message.viewport);
|
|
22
25
|
this.#viewports.set(message.viewport, {
|
|
23
26
|
status: "subscribing",
|
|
24
27
|
request: message,
|
|
@@ -30,6 +33,7 @@ class ConnectionChannel {
|
|
|
30
33
|
});
|
|
31
34
|
},
|
|
32
35
|
unsubscribe: (viewport)=>{
|
|
36
|
+
this.#markClosed(viewport);
|
|
33
37
|
this.#worker.send({
|
|
34
38
|
type: "unsubscribe",
|
|
35
39
|
viewport
|
|
@@ -39,7 +43,10 @@ class ConnectionChannel {
|
|
|
39
43
|
this.#worker.send(message);
|
|
40
44
|
},
|
|
41
45
|
destroy: (viewportId)=>{
|
|
42
|
-
if (viewportId && this.#viewports.has(viewportId))
|
|
46
|
+
if (viewportId && this.#viewports.has(viewportId)) {
|
|
47
|
+
this.#viewports.delete(viewportId);
|
|
48
|
+
this.#markClosed(viewportId);
|
|
49
|
+
}
|
|
43
50
|
},
|
|
44
51
|
rpcCall: async (message)=>this.asyncRequest(message),
|
|
45
52
|
select: async (selectRequest)=>this.asyncRequest(selectRequest),
|
|
@@ -97,11 +104,19 @@ class ConnectionChannel {
|
|
|
97
104
|
destroy() {
|
|
98
105
|
this.#worker.terminate();
|
|
99
106
|
}
|
|
107
|
+
#markClosed(viewportId) {
|
|
108
|
+
this.#closedViewports.delete(viewportId);
|
|
109
|
+
this.#closedViewports.add(viewportId);
|
|
110
|
+
if (this.#closedViewports.size > MAX_CLOSED_VIEWPORTS) {
|
|
111
|
+
const [oldest] = this.#closedViewports;
|
|
112
|
+
this.#closedViewports.delete(oldest);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
100
115
|
handleMessageFromWorker = (message)=>{
|
|
101
116
|
if (shouldMessageBeRoutedToDataSource(message)) {
|
|
102
117
|
const viewport = this.#viewports.get(message.clientViewportId);
|
|
103
118
|
if (viewport) viewport.postMessageToClientDataSource(message);
|
|
104
|
-
else console.error(
|
|
119
|
+
else this.#closedViewports.has(message.clientViewportId) || console.error("[ConnectionManager] %s message received, viewport not found", message.type);
|
|
105
120
|
} else if (isWebSocketConnectionStatus(message)) {
|
|
106
121
|
this.#connectionStatus = message;
|
|
107
122
|
this.onConnectionStatus(message);
|