vim-web 0.3.42-dev.2 → 0.3.42-dev.4
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.
|
@@ -5,6 +5,8 @@ export declare const DEFAULT_LOCAL_ULTRA_SERVER_URL = "ws://localhost:8123";
|
|
|
5
5
|
export type ConnectionSettings = {
|
|
6
6
|
url?: string;
|
|
7
7
|
retries?: number;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
retryDelay?: number;
|
|
8
10
|
};
|
|
9
11
|
export type ClientState = ClientStateConnecting | ClientStateConnected | ClientStateDisconnected | ClientStateValidating | ClientError;
|
|
10
12
|
export type ClientError = ClientStateCompatibilityError | ClientStateConnectionError | ClientStreamError;
|
|
@@ -58,7 +60,6 @@ export declare class SocketClient {
|
|
|
58
60
|
private _rpcCallId;
|
|
59
61
|
private _reconnectTimeout;
|
|
60
62
|
private _connectionTimeout;
|
|
61
|
-
private _retries;
|
|
62
63
|
private _validateConnection;
|
|
63
64
|
/**
|
|
64
65
|
* Callback function to handle incoming video frames.
|
|
@@ -67,6 +68,8 @@ export declare class SocketClient {
|
|
|
67
68
|
onVideoFrame: (msg: Protocol.VideoFrameMessage) => void;
|
|
68
69
|
private _state;
|
|
69
70
|
private _onStatusUpdate;
|
|
71
|
+
private _connectPromise;
|
|
72
|
+
private _connectionSettings;
|
|
70
73
|
/**
|
|
71
74
|
* Event that is triggered when the connection status updates.
|
|
72
75
|
* @returns An event dispatcher for connection status updates.
|
|
@@ -82,8 +85,6 @@ export declare class SocketClient {
|
|
|
82
85
|
* @param state - The new connection state.
|
|
83
86
|
*/
|
|
84
87
|
private updateState;
|
|
85
|
-
private _connectPromise;
|
|
86
|
-
private _connectingUrl;
|
|
87
88
|
/**
|
|
88
89
|
* Gets the URL to which the messenger is currently connecting or connected.
|
|
89
90
|
* @returns The WebSocket URL as a string, or undefined if not set.
|
package/dist/vim-web.iife.js
CHANGED
|
@@ -59735,7 +59735,6 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59735
59735
|
__publicField(this, "_rpcCallId", 0);
|
|
59736
59736
|
__publicField(this, "_reconnectTimeout");
|
|
59737
59737
|
__publicField(this, "_connectionTimeout");
|
|
59738
|
-
__publicField(this, "_retries", -1);
|
|
59739
59738
|
__publicField(this, "_validateConnection");
|
|
59740
59739
|
/**
|
|
59741
59740
|
* Callback function to handle incoming video frames.
|
|
@@ -59746,7 +59745,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59746
59745
|
__publicField(this, "_state", { status: "disconnected" });
|
|
59747
59746
|
__publicField(this, "_onStatusUpdate", new distExports.SimpleEventDispatcher());
|
|
59748
59747
|
__publicField(this, "_connectPromise", new ResolvedPromise(void 0));
|
|
59749
|
-
__publicField(this, "
|
|
59748
|
+
__publicField(this, "_connectionSettings");
|
|
59750
59749
|
this._logger = logger;
|
|
59751
59750
|
this._rpcCallId = 0;
|
|
59752
59751
|
this._streamLogger = new StreamLogger(logger);
|
|
@@ -59779,7 +59778,8 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59779
59778
|
* @returns The WebSocket URL as a string, or undefined if not set.
|
|
59780
59779
|
*/
|
|
59781
59780
|
get url() {
|
|
59782
|
-
|
|
59781
|
+
var _a2;
|
|
59782
|
+
return (_a2 = this._connectionSettings) == null ? void 0 : _a2.url;
|
|
59783
59783
|
}
|
|
59784
59784
|
/**
|
|
59785
59785
|
* Connects to a WebSocket server at the specified URL.
|
|
@@ -59789,7 +59789,9 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59789
59789
|
connect(settings2) {
|
|
59790
59790
|
settings2 = {
|
|
59791
59791
|
url: (settings2 == null ? void 0 : settings2.url) ?? DEFAULT_LOCAL_ULTRA_SERVER_URL,
|
|
59792
|
-
retries: (settings2 == null ? void 0 : settings2.retries) ?? 0
|
|
59792
|
+
retries: (settings2 == null ? void 0 : settings2.retries) ?? 0,
|
|
59793
|
+
timeout: (settings2 == null ? void 0 : settings2.timeout) ?? 5e3,
|
|
59794
|
+
retryDelay: (settings2 == null ? void 0 : settings2.retryDelay) ?? 5e3
|
|
59793
59795
|
};
|
|
59794
59796
|
const url = settings2.url;
|
|
59795
59797
|
if (!isWebSocketUrl(url)) {
|
|
@@ -59805,12 +59807,11 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59805
59807
|
}
|
|
59806
59808
|
}
|
|
59807
59809
|
this._connectPromise = new ControllablePromise();
|
|
59808
|
-
this.
|
|
59809
|
-
this._retries = settings2.retries;
|
|
59810
|
+
this._connectionSettings = settings2;
|
|
59810
59811
|
this.updateState({ status: "connecting" });
|
|
59811
59812
|
try {
|
|
59812
59813
|
this._socket = new WebSocket(url);
|
|
59813
|
-
this._connectionTimeout = setTimeout(() => this._onClose(),
|
|
59814
|
+
this._connectionTimeout = setTimeout(() => this._onClose(), settings2.timeout);
|
|
59814
59815
|
this._socket.onopen = (e) => {
|
|
59815
59816
|
this._onOpen(e);
|
|
59816
59817
|
};
|
|
@@ -59833,8 +59834,8 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59833
59834
|
* Disconnects from the current WebSocket server.
|
|
59834
59835
|
*/
|
|
59835
59836
|
disconnect(error) {
|
|
59836
|
-
this._logger.log("Disconnecting from: ", this.
|
|
59837
|
-
this.
|
|
59837
|
+
this._logger.log("Disconnecting from: ", this.url);
|
|
59838
|
+
this._connectionSettings = void 0;
|
|
59838
59839
|
this._disconnect(error);
|
|
59839
59840
|
}
|
|
59840
59841
|
/**
|
|
@@ -59929,19 +59930,20 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59929
59930
|
* @param _event - The event object.
|
|
59930
59931
|
*/
|
|
59931
59932
|
_onClose(_event) {
|
|
59932
|
-
clearTimeout(this._connectionTimeout);
|
|
59933
|
-
this._disconnect({ status: "error", error: "connection", serverUrl: this._connectingUrl });
|
|
59934
59933
|
this._logger.log("WebSocket closed.");
|
|
59935
|
-
|
|
59936
|
-
|
|
59937
|
-
|
|
59938
|
-
|
|
59939
|
-
|
|
59940
|
-
|
|
59941
|
-
retries: this._retries - 1
|
|
59942
|
-
});
|
|
59943
|
-
}, 5e3);
|
|
59934
|
+
clearTimeout(this._connectionTimeout);
|
|
59935
|
+
this._disconnect({ status: "error", error: "connection", serverUrl: this.url });
|
|
59936
|
+
if (this._connectionSettings.retries === 0) {
|
|
59937
|
+
this._logger.log("No more retries left");
|
|
59938
|
+
this._connectPromise.resolve();
|
|
59939
|
+
return;
|
|
59944
59940
|
}
|
|
59941
|
+
this._logger.log("Attempting to reconnect in 5 seconds");
|
|
59942
|
+
this._reconnectTimeout = setTimeout(() => {
|
|
59943
|
+
this.updateState({ status: "connecting" });
|
|
59944
|
+
this._connectionSettings.retries--;
|
|
59945
|
+
this.connect(this._connectionSettings);
|
|
59946
|
+
}, this._connectionSettings.retryDelay);
|
|
59945
59947
|
}
|
|
59946
59948
|
/**
|
|
59947
59949
|
* Sends binary data over the WebSocket connection.
|