vim-web 0.3.42-dev.3 → 0.3.42-dev.5
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/types/core-viewers/ultra/viewer/socketClient.d.ts +5 -4
- package/dist/types/core-viewers/ultra/viewer/viewer.d.ts +1 -1
- package/dist/vim-web.iife.js +35 -55
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +41 -61
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -100,7 +101,7 @@ export declare class SocketClient {
|
|
|
100
101
|
* @param url - The WebSocket URL to connect to.
|
|
101
102
|
* @returns A promise that resolves when the connection is established.
|
|
102
103
|
*/
|
|
103
|
-
connect(settings: ConnectionSettings): Promise<
|
|
104
|
+
connect(settings: ConnectionSettings): Promise<boolean>;
|
|
104
105
|
/**
|
|
105
106
|
* Disconnects from the current WebSocket server.
|
|
106
107
|
*/
|
|
@@ -96,7 +96,7 @@ export declare class Viewer {
|
|
|
96
96
|
* @param url - The server URL to connect to. Defaults to 'ws://localhost:8123'.
|
|
97
97
|
* @returns A promise that resolves when the connection is established.
|
|
98
98
|
*/
|
|
99
|
-
connect(settings?: ConnectionSettings): Promise<
|
|
99
|
+
connect(settings?: ConnectionSettings): Promise<boolean>;
|
|
100
100
|
/**
|
|
101
101
|
* Disconnects from the current VIM Ultra server.
|
|
102
102
|
*/
|
package/dist/vim-web.iife.js
CHANGED
|
@@ -49963,7 +49963,7 @@ void main() {
|
|
|
49963
49963
|
}
|
|
49964
49964
|
return vim;
|
|
49965
49965
|
}
|
|
49966
|
-
let DeferredPromise$
|
|
49966
|
+
let DeferredPromise$1 = class DeferredPromise extends Promise {
|
|
49967
49967
|
constructor(executor = () => {
|
|
49968
49968
|
}) {
|
|
49969
49969
|
var _a2;
|
|
@@ -50026,8 +50026,8 @@ void main() {
|
|
|
50026
50026
|
__publicField(this, "_error");
|
|
50027
50027
|
// Promises to await progress updates and completion
|
|
50028
50028
|
__publicField(this, "_progress", { loaded: 0, total: 0, all: /* @__PURE__ */ new Map() });
|
|
50029
|
-
__publicField(this, "_progressPromise", new DeferredPromise$
|
|
50030
|
-
__publicField(this, "_completionPromise", new DeferredPromise$
|
|
50029
|
+
__publicField(this, "_progressPromise", new DeferredPromise$1());
|
|
50030
|
+
__publicField(this, "_completionPromise", new DeferredPromise$1());
|
|
50031
50031
|
this._source = source;
|
|
50032
50032
|
this._settings = settings2;
|
|
50033
50033
|
this.startRequest();
|
|
@@ -50041,7 +50041,7 @@ void main() {
|
|
|
50041
50041
|
const vim = await open(this._bfast, this._settings, (progress) => {
|
|
50042
50042
|
this._progress = progress;
|
|
50043
50043
|
this._progressPromise.resolve(progress);
|
|
50044
|
-
this._progressPromise = new DeferredPromise$
|
|
50044
|
+
this._progressPromise = new DeferredPromise$1();
|
|
50045
50045
|
});
|
|
50046
50046
|
this._vimResult = vim;
|
|
50047
50047
|
} catch (err) {
|
|
@@ -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) ??
|
|
59792
|
+
retries: (settings2 == null ? void 0 : settings2.retries) ?? -1,
|
|
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)) {
|
|
@@ -59801,16 +59803,18 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59801
59803
|
return this._connectPromise.promise;
|
|
59802
59804
|
} else {
|
|
59803
59805
|
this._clearSocket();
|
|
59806
|
+
this._connectionSettings = void 0;
|
|
59804
59807
|
this._connectPromise.reject("Connection to a different server");
|
|
59805
59808
|
}
|
|
59806
59809
|
}
|
|
59807
|
-
this.
|
|
59808
|
-
|
|
59809
|
-
|
|
59810
|
+
if (this.url !== url) {
|
|
59811
|
+
this._connectPromise = new ControllablePromise();
|
|
59812
|
+
this._connectionSettings = settings2;
|
|
59813
|
+
}
|
|
59810
59814
|
this.updateState({ status: "connecting" });
|
|
59811
59815
|
try {
|
|
59812
59816
|
this._socket = new WebSocket(url);
|
|
59813
|
-
this._connectionTimeout = setTimeout(() => this._onClose(),
|
|
59817
|
+
this._connectionTimeout = setTimeout(() => this._onClose(), settings2.timeout);
|
|
59814
59818
|
this._socket.onopen = (e) => {
|
|
59815
59819
|
this._onOpen(e);
|
|
59816
59820
|
};
|
|
@@ -59833,15 +59837,15 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59833
59837
|
* Disconnects from the current WebSocket server.
|
|
59834
59838
|
*/
|
|
59835
59839
|
disconnect(error) {
|
|
59836
|
-
this._logger.log("Disconnecting from: ", this.
|
|
59837
|
-
this.
|
|
59840
|
+
this._logger.log("Disconnecting from: ", this.url);
|
|
59841
|
+
this._connectionSettings = void 0;
|
|
59838
59842
|
this._disconnect(error);
|
|
59839
59843
|
}
|
|
59840
59844
|
/**
|
|
59841
59845
|
* Handles the disconnection logic, stopping logging and clearing the socket.
|
|
59842
59846
|
*/
|
|
59843
59847
|
_disconnect(error) {
|
|
59844
|
-
|
|
59848
|
+
this._logger.log("disconnect", error);
|
|
59845
59849
|
clearTimeout(this._reconnectTimeout);
|
|
59846
59850
|
clearTimeout(this._connectionTimeout);
|
|
59847
59851
|
this._streamLogger.stopLogging();
|
|
@@ -59922,29 +59926,30 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
59922
59926
|
this._logger.log("Connected to: ", (_a2 = this._socket) == null ? void 0 : _a2.url);
|
|
59923
59927
|
this.updateState({ status: "connected" });
|
|
59924
59928
|
this._streamLogger.startLoggging();
|
|
59925
|
-
this._connectPromise.resolve();
|
|
59929
|
+
this._connectPromise.resolve(true);
|
|
59926
59930
|
}
|
|
59927
59931
|
/**
|
|
59928
59932
|
* Handler for WebSocket 'close' event.
|
|
59929
59933
|
* @param _event - The event object.
|
|
59930
59934
|
*/
|
|
59931
59935
|
_onClose(_event) {
|
|
59936
|
+
const connecting = this.state.status === "connecting" || this.state.status === "validating";
|
|
59932
59937
|
this._logger.log("WebSocket closed.");
|
|
59933
59938
|
clearTimeout(this._connectionTimeout);
|
|
59934
|
-
this._disconnect({ status: "error", error: "connection", serverUrl: this.
|
|
59935
|
-
if (this.
|
|
59939
|
+
this._disconnect({ status: "error", error: "connection", serverUrl: this.url });
|
|
59940
|
+
if (connecting && this._connectionSettings.retries === 0) {
|
|
59936
59941
|
this._logger.log("No more retries left");
|
|
59937
|
-
this._connectPromise.resolve();
|
|
59942
|
+
this._connectPromise.resolve(false);
|
|
59938
59943
|
return;
|
|
59939
59944
|
}
|
|
59940
59945
|
this._logger.log("Attempting to reconnect in 5 seconds");
|
|
59941
59946
|
this._reconnectTimeout = setTimeout(() => {
|
|
59942
59947
|
this.updateState({ status: "connecting" });
|
|
59943
|
-
|
|
59944
|
-
|
|
59945
|
-
|
|
59946
|
-
|
|
59947
|
-
},
|
|
59948
|
+
if (connecting) {
|
|
59949
|
+
this._connectionSettings.retries--;
|
|
59950
|
+
}
|
|
59951
|
+
this.connect(this._connectionSettings);
|
|
59952
|
+
}, this._connectionSettings.retryDelay);
|
|
59948
59953
|
}
|
|
59949
59954
|
/**
|
|
59950
59955
|
* Sends binary data over the WebSocket connection.
|
|
@@ -60317,31 +60322,6 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
60317
60322
|
this._pendingFrame = frame;
|
|
60318
60323
|
}
|
|
60319
60324
|
}
|
|
60320
|
-
let DeferredPromise$1 = class DeferredPromise extends Promise {
|
|
60321
|
-
constructor(executor = () => {
|
|
60322
|
-
}) {
|
|
60323
|
-
var _a2;
|
|
60324
|
-
let resolver;
|
|
60325
|
-
let rejector;
|
|
60326
|
-
super((resolve, reject) => {
|
|
60327
|
-
resolver = resolve;
|
|
60328
|
-
rejector = reject;
|
|
60329
|
-
return executor(resolve, reject);
|
|
60330
|
-
});
|
|
60331
|
-
__publicField(this, "resolve");
|
|
60332
|
-
__publicField(this, "reject");
|
|
60333
|
-
__publicField(this, "initialCallStack");
|
|
60334
|
-
this.resolve = resolver;
|
|
60335
|
-
this.reject = rejector;
|
|
60336
|
-
this.initialCallStack = (_a2 = Error().stack) == null ? void 0 : _a2.split("\n").slice(2).join("\n");
|
|
60337
|
-
}
|
|
60338
|
-
/** @throws error with amended call stack */
|
|
60339
|
-
rejectWithError(error) {
|
|
60340
|
-
var _a2;
|
|
60341
|
-
error.stack = [(_a2 = error.stack) == null ? void 0 : _a2.split("\n")[0], this.initialCallStack].join("\n");
|
|
60342
|
-
this.reject(error);
|
|
60343
|
-
}
|
|
60344
|
-
};
|
|
60345
60325
|
class LoadSuccess {
|
|
60346
60326
|
constructor(vim) {
|
|
60347
60327
|
__publicField(this, "isError", false);
|
|
@@ -60364,8 +60344,8 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
60364
60344
|
let LoadRequest$1 = class LoadRequest {
|
|
60365
60345
|
constructor() {
|
|
60366
60346
|
__publicField(this, "_progress", 0);
|
|
60367
|
-
__publicField(this, "_progressPromise", new
|
|
60368
|
-
__publicField(this, "_completionPromise", new
|
|
60347
|
+
__publicField(this, "_progressPromise", new ControllablePromise());
|
|
60348
|
+
__publicField(this, "_completionPromise", new ControllablePromise());
|
|
60369
60349
|
__publicField(this, "_result");
|
|
60370
60350
|
}
|
|
60371
60351
|
get isCompleted() {
|
|
@@ -60378,18 +60358,18 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
60378
60358
|
return;
|
|
60379
60359
|
}
|
|
60380
60360
|
while (this._result === void 0) {
|
|
60381
|
-
await this._progressPromise;
|
|
60361
|
+
await this._progressPromise.promise;
|
|
60382
60362
|
yield this._progress;
|
|
60383
60363
|
}
|
|
60384
60364
|
}
|
|
60385
60365
|
async getResult() {
|
|
60386
|
-
await this._completionPromise;
|
|
60366
|
+
await this._completionPromise.promise;
|
|
60387
60367
|
return this._result;
|
|
60388
60368
|
}
|
|
60389
60369
|
onProgress(progress) {
|
|
60390
60370
|
this._progress = progress;
|
|
60391
60371
|
this._progressPromise.resolve();
|
|
60392
|
-
this._progressPromise = new
|
|
60372
|
+
this._progressPromise = new ControllablePromise();
|
|
60393
60373
|
}
|
|
60394
60374
|
success(vim) {
|
|
60395
60375
|
this._result = new LoadSuccess(vim);
|
|
@@ -61770,7 +61750,7 @@ Averrage Date/Second ${avgDataRatePS} kb
|
|
|
61770
61750
|
* @returns A promise that resolves when the connection is established.
|
|
61771
61751
|
*/
|
|
61772
61752
|
async connect(settings2) {
|
|
61773
|
-
|
|
61753
|
+
return this._socketClient.connect(settings2);
|
|
61774
61754
|
}
|
|
61775
61755
|
/**
|
|
61776
61756
|
* Disconnects from the current VIM Ultra server.
|