vim-web 0.3.40 → 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,4 +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
+ export type { VimSource } from './viewer/rpcSafeClient';
@@ -1,5 +1,5 @@
1
1
  export interface ILogger {
2
- log(message: string): void;
2
+ log(message: string, obj?: any): void;
3
3
  error: (message: string, e: unknown) => void;
4
4
  }
5
5
  export declare const defaultLogger: ILogger;
@@ -1,4 +1,5 @@
1
1
  import { RGBA } from "../utils/math3d";
2
+ import { ILogger } from "./logger";
2
3
  import { RpcSafeClient, SceneSettings } from "./rpcSafeClient";
3
4
  import { ClientStreamError } from "./socketClient";
4
5
  /**
@@ -32,6 +33,7 @@ export interface IRenderer {
32
33
  */
33
34
  export declare class Renderer implements IRenderer {
34
35
  private _rpc;
36
+ private _logger;
35
37
  private _settings;
36
38
  private _animationFrame;
37
39
  private _updateLighting;
@@ -42,7 +44,7 @@ export declare class Renderer implements IRenderer {
42
44
  * @param rpc - RPC client for communication with the rendering backend
43
45
  * @param settings - Optional partial render settings to override defaults
44
46
  */
45
- constructor(rpc: RpcSafeClient, settings?: Partial<RenderSettings>);
47
+ constructor(rpc: RpcSafeClient, logger: ILogger, settings?: Partial<RenderSettings>);
46
48
  /**
47
49
  * Validates the connection to the server by attempting to start a scene.
48
50
  * @returns A promise that resolves to a ClientStreamError if the connection fails, or undefined if successful.
@@ -18,6 +18,7 @@ export declare const materialHandles: MaterialHandle[];
18
18
  export declare class RpcClient {
19
19
  private readonly _messenger;
20
20
  get url(): string;
21
+ get connected(): boolean;
21
22
  constructor(_messenger: SocketClient);
22
23
  readonly API_VERSION = "5.0.0";
23
24
  RPCAddNodeFlags(componentHandle: number, nodes: number[], flags: number): void;
@@ -1,6 +1,10 @@
1
1
  import { Box3, RGBA, RGBA32, Segment, Vector2, Vector3 } from "../utils/math3d";
2
2
  import { HitCheckResult } from "./marshal";
3
3
  import { MaterialHandle, RpcClient } from "./rpcClient";
4
+ export type VimSource = {
5
+ url: string;
6
+ authToken?: string;
7
+ };
4
8
  export type VimLoadingState = {
5
9
  status: VimLoadingStatus;
6
10
  progress: number;
@@ -34,6 +38,7 @@ export declare class RpcSafeClient {
34
38
  private readonly rpc;
35
39
  private readonly batchSize;
36
40
  get url(): string;
41
+ get connected(): boolean;
37
42
  constructor(rpc: RpcClient, batchSize?: number);
38
43
  /*******************************************************************************
39
44
  * SCENE MANAGEMENT METHODS
@@ -213,18 +218,18 @@ export declare class RpcSafeClient {
213
218
  ******************************************************************************/
214
219
  /**
215
220
  * Loads a VIM file from the local filesystem.
216
- * @param fileName - The path to the VIM file (supports file:// protocol)
221
+ * @param source - The path to the VIM file (supports file:// protocol)
217
222
  * @returns Promise resolving to the handle of the loaded VIM component
218
223
  * @throws {Error} If the filename is invalid or empty
219
224
  */
220
- RPCLoadVim(fileName: string): Promise<number>;
225
+ RPCLoadVim(source: VimSource): Promise<number>;
221
226
  /**
222
227
  * Loads a VIM file from a remote URL.
223
228
  * @param url - The URL of the VIM file to load
224
229
  * @returns Promise resolving to the handle of the loaded VIM component
225
230
  * @throws {Error} If the URL is invalid
226
231
  */
227
- RPCLoadVimURL(url: string): Promise<number>;
232
+ RPCLoadVimURL(source: VimSource): Promise<number>;
228
233
  /**
229
234
  * Retrieves the current loading state and progress of a VIM component.
230
235
  * @param componentHandle - The handle of the VIM component
@@ -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';
@@ -7,11 +7,10 @@ import { ILogger } from './logger';
7
7
  import { IViewport } from './viewport';
8
8
  import { ColorManager } from './colorManager';
9
9
  import { ICamera } from './camera';
10
- import { RpcSafeClient } from './rpcSafeClient';
10
+ 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,17 +96,17 @@ 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
  */
104
103
  disconnect(): void;
105
104
  /**
106
105
  * Requests the server to load the given URL or file path.
107
- * @param path - The path or URL to the VIM file.
106
+ * @param source - The path or URL to the VIM file.
108
107
  * @returns A load request object that can be used to wait for the load to complete.
109
108
  */
110
- loadVim(path: string): ILoadRequest;
109
+ loadVim(source: VimSource): ILoadRequest;
111
110
  /**
112
111
  * Unloads the given VIM from the viewer.
113
112
  * @param vim - The VIM instance to unload.
@@ -1,3 +1,4 @@
1
+ import { ILogger } from "./logger";
1
2
  import { RpcSafeClient } from "./rpcSafeClient";
2
3
  /**
3
4
  * Interface defining viewport functionality
@@ -15,6 +16,7 @@ export declare class Viewport {
15
16
  /** The HTML canvas element used for rendering */
16
17
  canvas: HTMLCanvasElement;
17
18
  private _rpc;
19
+ private _logger;
18
20
  private _observer;
19
21
  private _clearTimeout;
20
22
  /**
@@ -22,7 +24,7 @@ export declare class Viewport {
22
24
  * @param canvas - The HTML canvas element to observe and manage
23
25
  * @param rpc - RPC client for viewport communication
24
26
  */
25
- constructor(canvas: HTMLCanvasElement, rpc: RpcSafeClient);
27
+ constructor(canvas: HTMLCanvasElement, rpc: RpcSafeClient, logger: ILogger);
26
28
  /**
27
29
  * Handles resize events for the canvas
28
30
  * @private
@@ -1,12 +1,12 @@
1
1
  import { ColorHandle } from './color';
2
2
  import { ColorManager } from './colorManager';
3
3
  import { LoadRequest } from './loadRequest';
4
- import { RpcSafeClient } from './rpcSafeClient';
4
+ import { RpcSafeClient, VimSource } from './rpcSafeClient';
5
5
  import { ILogger } from './logger';
6
6
  import { Box3 } from '../utils/math3d';
7
7
  type NodeState = 'visible' | 'hidden' | 'ghosted' | 'highlighted';
8
8
  export declare class Vim {
9
- readonly source: string;
9
+ readonly source: VimSource;
10
10
  private _handle;
11
11
  private _request;
12
12
  private readonly _rpc;
@@ -24,7 +24,7 @@ export declare class Vim {
24
24
  * @param source - The source URL or file path of the Vim.
25
25
  * @param logger - The logger for logging messages.
26
26
  */
27
- constructor(rpc: RpcSafeClient, color: ColorManager, source: string, logger: ILogger);
27
+ constructor(rpc: RpcSafeClient, color: ColorManager, source: VimSource, logger: ILogger);
28
28
  get handle(): number;
29
29
  /**
30
30
  * Indicates whether the Vim is connected.
@@ -44,7 +44,7 @@ export declare class Vim {
44
44
  disconnect(): void;
45
45
  /**
46
46
  * Requests for the server to load the given URL or file path.
47
- * @param url - The URL or file path to load.
47
+ * @param source - The URL or file path to load.
48
48
  * @param result - The load request object to update.
49
49
  * @returns The updated load request.
50
50
  */
@@ -26,6 +26,7 @@ export declare class BoxInputs {
26
26
  constructor(viewer: Viewer, cube: THREE.Object3D, box: THREE.Box3);
27
27
  private reg;
28
28
  register(): void;
29
+ onPointerLeave(event: PointerEvent): void;
29
30
  capturePointer(pointerId: number): void;
30
31
  releasePointer(): void;
31
32
  unregister(): void;
@@ -1,2 +1,2 @@
1
1
  import { MessageBoxProps } from '../../panels/messageBox';
2
- export declare function serverFileDownloadingError(url: string, server?: string): MessageBoxProps;
2
+ export declare function serverFileDownloadingError(url: string, authToken?: string, server?: string): MessageBoxProps;
@@ -1,3 +1,3 @@
1
1
  import * as Ultra from '../../../core-viewers/ultra';
2
2
  export declare function getErrorMessage(state: Ultra.ClientState): import("../..").MessageBoxProps;
3
- export declare function getRequestErrorMessage(url: string, error: Ultra.VimRequestErrorType): import("../..").MessageBoxProps;
3
+ export declare function getRequestErrorMessage(source: Ultra.VimSource, error: Ultra.VimRequestErrorType): import("../..").MessageBoxProps;
@@ -5,7 +5,7 @@ export type UltraComponentRef = {
5
5
  viewer: Ultra.Viewer;
6
6
  modal: ModalRef;
7
7
  dispose: () => void;
8
- load(url: string): Ultra.ILoadRequest;
8
+ load(url: Ultra.VimSource): Ultra.ILoadRequest;
9
9
  };
10
10
  /**
11
11
  * Creates a UI container along with a VIM.Viewer and its associated React component.