@sanseng/livekit-ws-sdk 0.1.17 → 0.1.20
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/index.cjs.js +3 -3
- package/dist/index.d.ts +63 -37
- package/dist/index.esm.js +3 -3
- package/dist/index.full.umd.js +7 -7
- package/dist/index.umd.js +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ interface AudioEvents {
|
|
|
130
130
|
*/
|
|
131
131
|
frameSize: number;
|
|
132
132
|
};
|
|
133
|
+
'inner:audio:speaking:changed': { participantId: string; isSpeaking: boolean };
|
|
133
134
|
'inner:audio:track:added': { trackId: string; participantId: string };
|
|
134
135
|
'inner:audio:track:removed': { trackId: string };
|
|
135
136
|
'inner:audio:volume:changed': { volume: number };
|
|
@@ -762,6 +763,14 @@ interface ClientOptions extends BaseOptions {
|
|
|
762
763
|
*/
|
|
763
764
|
headers?: Record<string, string>;
|
|
764
765
|
};
|
|
766
|
+
/**
|
|
767
|
+
* Indicates if sandbox is enabled
|
|
768
|
+
*
|
|
769
|
+
* @type {boolean}
|
|
770
|
+
* @default undefined
|
|
771
|
+
* @author sansen
|
|
772
|
+
*/
|
|
773
|
+
sandbox?: boolean;
|
|
765
774
|
}
|
|
766
775
|
|
|
767
776
|
/**
|
|
@@ -807,6 +816,43 @@ declare class SDKError extends Error {
|
|
|
807
816
|
static fromError(error: unknown, code?: string): SDKError;
|
|
808
817
|
}
|
|
809
818
|
|
|
819
|
+
/**
|
|
820
|
+
* SDK connection state (lifecycle FSM state).
|
|
821
|
+
* Single source of truth for SDK lifecycle; used in connection snapshot overall state.
|
|
822
|
+
*
|
|
823
|
+
* @author sansen
|
|
824
|
+
*/
|
|
825
|
+
type SDKConnectionState = 'idle' | 'connecting' | 'connected' | 'partial' | 'reconnecting:auto' | 'reconnecting:manual' | 'disconnecting' | 'disconnected' | 'disposed' | 'error';
|
|
826
|
+
/**
|
|
827
|
+
* Read-only connection snapshot.
|
|
828
|
+
* Derived from aggregated internal facts (rtc:* / ws:* events), not from LiveKit Room or Track objects.
|
|
829
|
+
* Used for user-driven reconnect UX: available synchronously when user triggers manual reconnect.
|
|
830
|
+
*
|
|
831
|
+
* @remarks
|
|
832
|
+
* - ws.connected: whether WebSocket (conversation) is currently connected.
|
|
833
|
+
* - rtc.connected: whether RTC (LiveKit) is currently connected.
|
|
834
|
+
* - rtc.hasVideoTrack: whether at least one video track is available (from rtc:video:available / rtc:video:unavailable).
|
|
835
|
+
* - overall.state: current SDK lifecycle state from SDKConnectionFSM.
|
|
836
|
+
*
|
|
837
|
+
* @author sansen
|
|
838
|
+
*/
|
|
839
|
+
interface ConnectionSnapshot {
|
|
840
|
+
readonly ws: {
|
|
841
|
+
/** True when WebSocket connection is open. */
|
|
842
|
+
readonly connected: boolean;
|
|
843
|
+
};
|
|
844
|
+
readonly rtc: {
|
|
845
|
+
/** True when LiveKit room is connected. */
|
|
846
|
+
readonly connected: boolean;
|
|
847
|
+
/** True when at least one video track is available (subscribed and usable). */
|
|
848
|
+
readonly hasVideoTrack: boolean;
|
|
849
|
+
};
|
|
850
|
+
readonly overall: {
|
|
851
|
+
/** Current lifecycle state from SDKConnectionFSM. */
|
|
852
|
+
readonly state: SDKConnectionState;
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
|
|
810
856
|
/**
|
|
811
857
|
* SDK Context
|
|
812
858
|
* Contains all shared states and event bus
|
|
@@ -841,6 +887,8 @@ declare class SDKContext {
|
|
|
841
887
|
private _roomId;
|
|
842
888
|
private _wsUrl;
|
|
843
889
|
private _httpToken;
|
|
890
|
+
/** The function to return the current SDK connection FSM state by the coordinator */
|
|
891
|
+
private _connectionStateGetter;
|
|
844
892
|
/**
|
|
845
893
|
* Creates an SDK context instance
|
|
846
894
|
*
|
|
@@ -919,6 +967,21 @@ declare class SDKContext {
|
|
|
919
967
|
livekitUrl: string;
|
|
920
968
|
token: string;
|
|
921
969
|
};
|
|
970
|
+
/**
|
|
971
|
+
* Bind connection state getter to get the current SDK connection FSM state by the coordinator
|
|
972
|
+
* @param getter - The function to return the current SDK connection FSM state
|
|
973
|
+
* @author sansen
|
|
974
|
+
*/
|
|
975
|
+
bindConnectionState(getter: () => SDKConnectionState): void;
|
|
976
|
+
/**
|
|
977
|
+
* The current SDK connection FSM state; undefined if not connected or not bound to the coordinator
|
|
978
|
+
*/
|
|
979
|
+
get connectionState(): SDKConnectionState | undefined;
|
|
980
|
+
/**
|
|
981
|
+
* Clear connection state binding when dispose
|
|
982
|
+
* @author sansen
|
|
983
|
+
*/
|
|
984
|
+
clearConnectionStateBinding(): void;
|
|
922
985
|
/**
|
|
923
986
|
* Disposes all resources and cleans up states
|
|
924
987
|
*
|
|
@@ -927,43 +990,6 @@ declare class SDKContext {
|
|
|
927
990
|
dispose(): void;
|
|
928
991
|
}
|
|
929
992
|
|
|
930
|
-
/**
|
|
931
|
-
* SDK connection state (lifecycle FSM state).
|
|
932
|
-
* Single source of truth for SDK lifecycle; used in connection snapshot overall state.
|
|
933
|
-
*
|
|
934
|
-
* @author sansen
|
|
935
|
-
*/
|
|
936
|
-
type SDKConnectionState = 'idle' | 'connecting' | 'connected' | 'partial' | 'reconnecting:auto' | 'reconnecting:manual' | 'disconnecting' | 'disconnected' | 'disposed' | 'error';
|
|
937
|
-
/**
|
|
938
|
-
* Read-only connection snapshot.
|
|
939
|
-
* Derived from aggregated internal facts (rtc:* / ws:* events), not from LiveKit Room or Track objects.
|
|
940
|
-
* Used for user-driven reconnect UX: available synchronously when user triggers manual reconnect.
|
|
941
|
-
*
|
|
942
|
-
* @remarks
|
|
943
|
-
* - ws.connected: whether WebSocket (conversation) is currently connected.
|
|
944
|
-
* - rtc.connected: whether RTC (LiveKit) is currently connected.
|
|
945
|
-
* - rtc.hasVideoTrack: whether at least one video track is available (from rtc:video:available / rtc:video:unavailable).
|
|
946
|
-
* - overall.state: current SDK lifecycle state from SDKConnectionFSM.
|
|
947
|
-
*
|
|
948
|
-
* @author sansen
|
|
949
|
-
*/
|
|
950
|
-
interface ConnectionSnapshot {
|
|
951
|
-
readonly ws: {
|
|
952
|
-
/** True when WebSocket connection is open. */
|
|
953
|
-
readonly connected: boolean;
|
|
954
|
-
};
|
|
955
|
-
readonly rtc: {
|
|
956
|
-
/** True when LiveKit room is connected. */
|
|
957
|
-
readonly connected: boolean;
|
|
958
|
-
/** True when at least one video track is available (subscribed and usable). */
|
|
959
|
-
readonly hasVideoTrack: boolean;
|
|
960
|
-
};
|
|
961
|
-
readonly overall: {
|
|
962
|
-
/** Current lifecycle state from SDKConnectionFSM. */
|
|
963
|
-
readonly state: SDKConnectionState;
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
|
|
967
993
|
interface PublicEmitterAPI {
|
|
968
994
|
on<K extends keyof PublicSDKEvents>(event: K, listener: (data: PublicSDKEvents[K]) => void): () => void;
|
|
969
995
|
off<K extends keyof PublicSDKEvents>(event: K, listener: (data: PublicSDKEvents[K]) => void): void;
|