@xh/hoist 73.0.0-SNAPSHOT.1744666869301 → 73.0.0-SNAPSHOT.1744727919048
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/CHANGELOG.md
CHANGED
|
@@ -83,6 +83,7 @@ export declare class WebSocketService extends HoistService {
|
|
|
83
83
|
private buildWebSocketUrl;
|
|
84
84
|
private maybeLogMessage;
|
|
85
85
|
private noteTelemetryEvent;
|
|
86
|
+
private ensureEnabled;
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
89
|
* Wrapper class to encapsulate and manage a subscription to messages for a given topic + handler.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "73.0.0-SNAPSHOT.
|
|
3
|
+
"version": "73.0.0-SNAPSHOT.1744727919048",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|
package/svc/WebSocketService.ts
CHANGED
|
@@ -108,6 +108,7 @@ export class WebSocketService extends HoistService {
|
|
|
108
108
|
* dispose of their subs on destroy.
|
|
109
109
|
*/
|
|
110
110
|
subscribe(topic: string, fn: (msg: WebSocketMessage) => any): WebSocketSubscription {
|
|
111
|
+
this.ensureEnabled();
|
|
111
112
|
const subs = this.getSubsForTopic(topic),
|
|
112
113
|
existingSub = find(subs, {fn});
|
|
113
114
|
|
|
@@ -125,6 +126,7 @@ export class WebSocketService extends HoistService {
|
|
|
125
126
|
* @param subscription - WebSocketSubscription returned when the subscription was established.
|
|
126
127
|
*/
|
|
127
128
|
unsubscribe(subscription: WebSocketSubscription) {
|
|
129
|
+
this.ensureEnabled();
|
|
128
130
|
const subs = this.getSubsForTopic(subscription.topic);
|
|
129
131
|
pull(subs, subscription);
|
|
130
132
|
this.telemetry.subscriptionCount--;
|
|
@@ -134,6 +136,7 @@ export class WebSocketService extends HoistService {
|
|
|
134
136
|
* Send a message back to the server via the connected websocket.
|
|
135
137
|
*/
|
|
136
138
|
sendMessage(message: WebSocketMessage) {
|
|
139
|
+
this.ensureEnabled();
|
|
137
140
|
this.updateConnectedStatus();
|
|
138
141
|
throwIf(!this.connected, 'Unable to send message via websocket - not connected.');
|
|
139
142
|
|
|
@@ -319,6 +322,10 @@ export class WebSocketService extends HoistService {
|
|
|
319
322
|
evtTel.count++;
|
|
320
323
|
evtTel.lastTime = Date.now();
|
|
321
324
|
}
|
|
325
|
+
|
|
326
|
+
private ensureEnabled() {
|
|
327
|
+
throwIf(!this.enabled, 'Operation not available. WebSocketService is disabled.');
|
|
328
|
+
}
|
|
322
329
|
}
|
|
323
330
|
|
|
324
331
|
/**
|