vim-web 0.3.41 → 0.3.42-dev.0

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,5 +5,5 @@ export * from './viewer/vim';
5
5
  export * from './utils/math3d';
6
6
  export * from './viewer/color';
7
7
  export type { ILoadRequest, VimRequestErrorType } from './viewer/loadRequest';
8
- export type { ClientState } from './viewer/socketClient';
8
+ export type { ClientState, ConnectionSettings } from './viewer/socketClient';
9
9
  export type { VimSource } from './viewer/rpcSafeClient';
@@ -1,6 +1,11 @@
1
1
  import * as Protocol from './protocol';
2
2
  import { Marshal } from './marshal';
3
3
  import { ILogger } from './logger';
4
+ export declare const DEFAULT_LOCAL_ULTRA_SERVER_URL = "ws://localhost:8123";
5
+ export type ConnectionSettings = {
6
+ url?: string;
7
+ attempts?: number;
8
+ };
4
9
  export type ClientState = ClientStateConnecting | ClientStateConnected | ClientStateDisconnected | ClientStateValidating | ClientError;
5
10
  export type ClientError = ClientStateCompatibilityError | ClientStateConnectionError | ClientStreamError;
6
11
  export type ClientStateConnecting = {
@@ -53,6 +58,7 @@ export declare class SocketClient {
53
58
  private _rpcCallId;
54
59
  private _reconnectTimeout;
55
60
  private _connectionTimeout;
61
+ private _attempts;
56
62
  private _validateConnection;
57
63
  /**
58
64
  * Callback function to handle incoming video frames.
@@ -94,7 +100,7 @@ export declare class SocketClient {
94
100
  * @param url - The WebSocket URL to connect to.
95
101
  * @returns A promise that resolves when the connection is established.
96
102
  */
97
- connect(url: string): Promise<void>;
103
+ connect(settings: ConnectionSettings): Promise<void>;
98
104
  /**
99
105
  * Disconnects from the current WebSocket server.
100
106
  */
@@ -1,5 +1,5 @@
1
1
  import { IInputs } from './inputs/inputs';
2
- import { ClientState } from './socketClient';
2
+ import { ClientState, ConnectionSettings } from './socketClient';
3
3
  import { IDecoder } from './decoder';
4
4
  import { Vim } from './vim';
5
5
  import { ILoadRequest } from './loadRequest';
@@ -11,7 +11,6 @@ import { RpcSafeClient, VimSource } from './rpcSafeClient';
11
11
  import { ISimpleEvent } from 'ste-simple-events';
12
12
  import { IReadonlyVimCollection } from './vimCollection';
13
13
  import { IRenderer } from './renderer';
14
- export declare const DEFAULT_LOCAL_ULTRA_SERVER_URL = "ws://localhost:8123";
15
14
  export declare const INVALID_HANDLE = 4294967295;
16
15
  /**
17
16
  * The main Viewer class responsible for managing VIM files,
@@ -97,7 +96,7 @@ export declare class Viewer {
97
96
  * @param url - The server URL to connect to. Defaults to 'ws://localhost:8123'.
98
97
  * @returns A promise that resolves when the connection is established.
99
98
  */
100
- connect(url?: string): Promise<void>;
99
+ connect(settings?: ConnectionSettings): Promise<void>;
101
100
  /**
102
101
  * Disconnects from the current VIM Ultra server.
103
102
  */
@@ -59720,6 +59720,7 @@ Averrage Date/Second ${avgDataRatePS} kb
59720
59720
  ControllablePromise,
59721
59721
  ResolvedPromise
59722
59722
  }, Symbol.toStringTag, { value: "Module" }));
59723
+ const DEFAULT_LOCAL_ULTRA_SERVER_URL = "ws://localhost:8123";
59723
59724
  class SocketClient {
59724
59725
  /**
59725
59726
  * Constructs a new Messenger instance.
@@ -59734,6 +59735,7 @@ Averrage Date/Second ${avgDataRatePS} kb
59734
59735
  __publicField(this, "_rpcCallId", 0);
59735
59736
  __publicField(this, "_reconnectTimeout");
59736
59737
  __publicField(this, "_connectionTimeout");
59738
+ __publicField(this, "_attempts", -1);
59737
59739
  __publicField(this, "_validateConnection");
59738
59740
  /**
59739
59741
  * Callback function to handle incoming video frames.
@@ -59784,7 +59786,12 @@ Averrage Date/Second ${avgDataRatePS} kb
59784
59786
  * @param url - The WebSocket URL to connect to.
59785
59787
  * @returns A promise that resolves when the connection is established.
59786
59788
  */
59787
- connect(url) {
59789
+ connect(settings2) {
59790
+ settings2 = {
59791
+ url: (settings2 == null ? void 0 : settings2.url) ?? DEFAULT_LOCAL_ULTRA_SERVER_URL,
59792
+ attempts: (settings2 == null ? void 0 : settings2.attempts) ?? 0
59793
+ };
59794
+ const url = settings2.url;
59788
59795
  if (!isWebSocketUrl(url)) {
59789
59796
  this._disconnect({ status: "error", error: "connection", serverUrl: url });
59790
59797
  return Promise.reject(new Error(`Invalid WebSocket URL: ${url}`));
@@ -59926,11 +59933,16 @@ Averrage Date/Second ${avgDataRatePS} kb
59926
59933
  clearTimeout(this._connectionTimeout);
59927
59934
  this._disconnect({ status: "error", error: "connection", serverUrl: this._connectingUrl });
59928
59935
  this._logger.log("WebSocket closed.");
59929
- this._logger.log("Attempting to reconnect in 5 seconds");
59930
- this._reconnectTimeout = setTimeout(() => {
59931
- this.updateState({ status: "connecting" });
59932
- this.connect(this._connectingUrl);
59933
- }, 5e3);
59936
+ if (this._attempts != 0) {
59937
+ this._logger.log("Attempting to reconnect in 5 seconds");
59938
+ this._reconnectTimeout = setTimeout(() => {
59939
+ this.updateState({ status: "connecting" });
59940
+ this.connect({
59941
+ url: this._connectingUrl,
59942
+ attempts: this._attempts - 1
59943
+ });
59944
+ }, 5e3);
59945
+ }
59934
59946
  }
59935
59947
  /**
59936
59948
  * Sends binary data over the WebSocket connection.
@@ -61583,7 +61595,6 @@ Averrage Date/Second ${avgDataRatePS} kb
61583
61595
  }
61584
61596
  }
61585
61597
  }
61586
- const DEFAULT_LOCAL_ULTRA_SERVER_URL = "ws://localhost:8123";
61587
61598
  const INVALID_HANDLE = 4294967295;
61588
61599
  class Viewer {
61589
61600
  /**
@@ -61756,8 +61767,8 @@ Averrage Date/Second ${avgDataRatePS} kb
61756
61767
  * @param url - The server URL to connect to. Defaults to 'ws://localhost:8123'.
61757
61768
  * @returns A promise that resolves when the connection is established.
61758
61769
  */
61759
- async connect(url = DEFAULT_LOCAL_ULTRA_SERVER_URL) {
61760
- await this._socketClient.connect(url);
61770
+ async connect(settings2) {
61771
+ await this._socketClient.connect(settings2);
61761
61772
  }
61762
61773
  /**
61763
61774
  * Disconnects from the current VIM Ultra server.
@@ -61820,7 +61831,6 @@ Averrage Date/Second ${avgDataRatePS} kb
61820
61831
  __proto__: null,
61821
61832
  Box3,
61822
61833
  ColorHandle,
61823
- DEFAULT_LOCAL_ULTRA_SERVER_URL,
61824
61834
  INVALID_HANDLE,
61825
61835
  Matrix44: Matrix4,
61826
61836
  RGB,
@@ -75728,7 +75738,7 @@ Averrage Date/Second ${avgDataRatePS} kb
75728
75738
  dotList([
75729
75739
  server ? bullet("VIM ULTRA Server:", server) : null,
75730
75740
  bullet("File URL:", url),
75731
- authToken ? bullet("Auth Token:", authToken) : null``
75741
+ authToken ? bullet("Auth Token:", authToken) : null
75732
75742
  ]),
75733
75743
  subTitle("Troubleshooting tips:"),
75734
75744
  numList([