@viamrobotics/sdk 0.24.0 → 0.25.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.
@@ -0,0 +1,20 @@
1
+ import type { ProtobufMessage } from '@improbable-eng/grpc-web/dist/typings/message';
2
+ export declare class BaseChannel {
3
+ readonly ready: Promise<unknown>;
4
+ private readonly peerConn;
5
+ private readonly dataChannel;
6
+ private pResolve;
7
+ private pReject;
8
+ private closed;
9
+ private closedReason;
10
+ protected maxDataChannelSize: number;
11
+ constructor(peerConn: RTCPeerConnection, dataChannel: RTCDataChannel);
12
+ close(): void;
13
+ isClosed(): boolean;
14
+ isClosedReason(): Error | undefined;
15
+ protected closeWithReason(err?: Error): void;
16
+ private onChannelOpen;
17
+ private onChannelClose;
18
+ private onChannelError;
19
+ protected write(msg: ProtobufMessage): void;
20
+ }
@@ -0,0 +1,14 @@
1
+ import type { grpc } from '@improbable-eng/grpc-web';
2
+ import type { PacketMessage, Stream } from '../gen/proto/rpc/webrtc/v1/grpc_pb';
3
+ export declare class BaseStream {
4
+ protected readonly stream: Stream;
5
+ private readonly onDone;
6
+ protected readonly opts: grpc.TransportOptions;
7
+ protected closed: boolean;
8
+ private readonly packetBuf;
9
+ private packetBufSize;
10
+ private err;
11
+ constructor(stream: Stream, onDone: (id: number) => void, opts: grpc.TransportOptions);
12
+ closeWithRecvError(err?: Error): void;
13
+ protected processPacketMessage(msg: PacketMessage): Uint8Array | undefined;
14
+ }
@@ -0,0 +1,17 @@
1
+ import type { grpc } from '@improbable-eng/grpc-web';
2
+ import { RequestHeaders, RequestMessage, Stream } from '../gen/proto/rpc/webrtc/v1/grpc_pb';
3
+ import { BaseChannel } from './base-channel';
4
+ export declare class ClientChannel extends BaseChannel {
5
+ private streamIDCounter;
6
+ private readonly streams;
7
+ constructor(pc: RTCPeerConnection, dc: RTCDataChannel);
8
+ transportFactory(): grpc.TransportFactory;
9
+ private onConnectionTerminated;
10
+ private onChannelMessage;
11
+ private nextStreamID;
12
+ private newStream;
13
+ private removeStreamByID;
14
+ writeHeaders(stream: Stream, headers: RequestHeaders): void;
15
+ writeMessage(stream: Stream, msg: RequestMessage): void;
16
+ writeReset(stream: Stream): void;
17
+ }
@@ -0,0 +1,21 @@
1
+ import { grpc } from '@improbable-eng/grpc-web';
2
+ import { Response, Stream } from '../gen/proto/rpc/webrtc/v1/grpc_pb';
3
+ import { BaseStream } from './base-stream';
4
+ import type { ClientChannel } from './client-channel';
5
+ export declare class ClientStream extends BaseStream implements grpc.Transport {
6
+ private readonly channel;
7
+ private headersReceived;
8
+ private trailersReceived;
9
+ constructor(channel: ClientChannel, stream: Stream, onDone: (id: number) => void, opts: grpc.TransportOptions);
10
+ start(metadata: grpc.Metadata): void;
11
+ sendMessage(msgBytes?: Uint8Array): void;
12
+ resetStream(): void;
13
+ finishSend(): void;
14
+ cancel(): void;
15
+ private writeMessage;
16
+ onResponse(resp: Response): void;
17
+ private processHeaders;
18
+ private processMessage;
19
+ private processTrailers;
20
+ }
21
+ export declare const encodeASCII: (input: string) => Uint8Array;
@@ -0,0 +1,5 @@
1
+ export declare class ConnectionClosedError extends Error {
2
+ readonly name = "ConnectionClosedError";
3
+ constructor(msg: string);
4
+ static isError(error: unknown): boolean;
5
+ }
@@ -0,0 +1,31 @@
1
+ import { grpc } from '@improbable-eng/grpc-web';
2
+ export interface DialOptions {
3
+ authEntity?: string | undefined;
4
+ credentials?: Credentials | undefined;
5
+ webrtcOptions?: DialWebRTCOptions;
6
+ externalAuthAddress?: string | undefined;
7
+ externalAuthToEntity?: string | undefined;
8
+ accessToken?: string | undefined;
9
+ dialTimeout?: number | undefined;
10
+ }
11
+ export interface DialWebRTCOptions {
12
+ disableTrickleICE: boolean;
13
+ rtcConfig?: RTCConfiguration;
14
+ signalingAuthEntity?: string;
15
+ signalingExternalAuthAddress?: string;
16
+ signalingExternalAuthToEntity?: string;
17
+ signalingCredentials?: Credentials;
18
+ signalingAccessToken?: string;
19
+ additionalSdpFields?: Record<string, string | number>;
20
+ }
21
+ export interface Credentials {
22
+ type: string;
23
+ payload: string;
24
+ }
25
+ export declare const dialDirect: (address: string, opts?: DialOptions) => Promise<grpc.TransportFactory>;
26
+ export interface WebRTCConnection {
27
+ transportFactory: grpc.TransportFactory;
28
+ peerConnection: RTCPeerConnection;
29
+ dataChannel: RTCDataChannel;
30
+ }
31
+ export declare const dialWebRTC: (signalingAddress: string, host: string, opts?: DialOptions) => Promise<WebRTCConnection>;
@@ -0,0 +1,6 @@
1
+ export declare class GRPCError extends Error {
2
+ readonly name = "GRPCError";
3
+ readonly code: number;
4
+ readonly grpcMessage: string;
5
+ constructor(code: number, message: string);
6
+ }
@@ -0,0 +1,10 @@
1
+ import type { TransportFactory } from '@improbable-eng/grpc-web/dist/typings/transports/Transport';
2
+ import type { CrossBrowserHttpTransportInit } from '@improbable-eng/grpc-web/dist/typings/transports/http/http';
3
+ declare global {
4
+ var VIAM: {
5
+ GRPC_TRANSPORT_FACTORY?: (opts: CrossBrowserHttpTransportInit) => TransportFactory;
6
+ } | undefined;
7
+ }
8
+ export { dialDirect, dialWebRTC, type Credentials, type DialOptions, type DialWebRTCOptions, type WebRTCConnection, } from './dial';
9
+ export { ConnectionClosedError } from './connection-closed-error';
10
+ export { GRPCError } from './grpc-error';
@@ -0,0 +1,10 @@
1
+ interface ReadyPeer {
2
+ pc: RTCPeerConnection;
3
+ dc: RTCDataChannel;
4
+ }
5
+ export declare const addSdpFields: (localDescription?: RTCSessionDescription | null, sdpFields?: Record<string, string | number>) => {
6
+ sdp: string | undefined;
7
+ type: RTCSdpType | undefined;
8
+ };
9
+ export declare const newPeerConnectionForClient: (disableTrickle: boolean, rtcConfig?: RTCConfiguration, additionalSdpFields?: Record<string, string | number>) => Promise<ReadyPeer>;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const btoa: (input?: string) => string;
2
+ export declare const atob: (input?: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "",
5
5
  "main": "./dist/main.umd.js",
6
6
  "module": "./dist/main.es.js",
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "homepage": "https://github.com/viamrobotics/viam-typescript-sdk#readme",
48
48
  "dependencies": {
49
- "@viamrobotics/rpc": "^0.2.6",
50
49
  "exponential-backoff": "^3.1.1"
51
50
  },
52
51
  "devDependencies": {