@ikonai/sdk 1.0.21 → 1.0.23

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.
@@ -9,6 +9,15 @@ import { IkonClientConfig } from './ikon-client-config';
9
9
  * Protocol message handler callback type for subscribers.
10
10
  */
11
11
  export type ProtocolMessageHandler = (message: ProtocolMessage) => void;
12
+ export interface WebRTCTrackMapInfo {
13
+ kind: string;
14
+ trackIndex: number;
15
+ senderId: number;
16
+ senderTrackId: number;
17
+ streamId: string;
18
+ sourceType: string;
19
+ active: boolean;
20
+ }
12
21
  /**
13
22
  * A MessagePort that receives raw protocol messages as transferred ArrayBuffers.
14
23
  *
@@ -99,6 +108,7 @@ export declare class IkonClient {
99
108
  private boundBeforeUnload;
100
109
  private boundPageHide;
101
110
  private boundVisibilityChange;
111
+ private boundPopstate;
102
112
  private _globalState;
103
113
  private _globalStateReceived;
104
114
  private _channelsConnected;
@@ -112,9 +122,9 @@ export declare class IkonClient {
112
122
  private readonly _media;
113
123
  private _mediaCapture;
114
124
  private _webRtcSignaling;
115
- private _webRtcAudioStream;
116
- private _webRtcVideoStream;
117
- private _webRtcScreenStream;
125
+ private _webRtcAudioElements;
126
+ private _webRtcVideoStreams;
127
+ private _webRtcTrackMap;
118
128
  private _waitForExternalConnectUrl;
119
129
  private _externalConnectUrlCleanup;
120
130
  /**
@@ -135,20 +145,22 @@ export declare class IkonClient {
135
145
  */
136
146
  get isWebRtcEnabled(): boolean;
137
147
  /**
138
- * WebRTC audio MediaStream (when WebRTC enabled and connected).
139
- * Attach to an `<audio>` element via `element.srcObject = stream`.
148
+ * All WebRTC video streams keyed by track index.
149
+ */
150
+ get webRtcVideoStreams(): Map<number, MediaStream>;
151
+ /**
152
+ * Track mapping info. Keys are "kind:trackIndex" (e.g. "audio:3", "video:0").
140
153
  */
141
- get webRtcAudioStream(): MediaStream | null;
154
+ get webRtcTrackMap(): Map<string, WebRTCTrackMapInfo>;
142
155
  /**
143
- * WebRTC video MediaStream for camera (when WebRTC enabled and connected).
144
- * Attach to a `<video>` element via `element.srcObject = stream`.
156
+ * Callback fired when a WebRTC track map update is received from the server.
145
157
  */
146
- get webRtcVideoStream(): MediaStream | null;
158
+ onWebRtcTrackMapChanged?: (info: WebRTCTrackMapInfo) => void;
147
159
  /**
148
- * WebRTC video MediaStream for screen share (when WebRTC enabled and connected).
149
- * Attach to a `<video>` element via `element.srcObject = stream`.
160
+ * Look up the WebRTC video MediaStream for a given app-level stream ID.
161
+ * Returns null if no track is mapped to this stream ID or if the stream is inactive.
150
162
  */
151
- get webRtcScreenStream(): MediaStream | null;
163
+ getWebRtcVideoStreamByStreamId(streamId: string): MediaStream | null;
152
164
  /**
153
165
  * Get the WebRTC signaling instance (when WebRTC enabled and connected).
154
166
  * Used internally by capture functions.
@@ -275,10 +287,9 @@ export declare class IkonClient {
275
287
  private setErrorState;
276
288
  private connectProtocol;
277
289
  private setupWebRtcSignaling;
278
- private _webRtcAudioElement;
279
290
  private _webRtcAudioUnlockHandler;
280
291
  private readonly _webRtcMediaSession;
281
- private autoPlayWebRtcAudio;
292
+ private playWebRtcAudioTrack;
282
293
  private setupWebRtcMediaSession;
283
294
  private removeWebRtcAudioUnlockHandler;
284
295
  private connectProtocolOnMainThread;
@@ -312,6 +323,11 @@ export declare class IkonClient {
312
323
  * Check connection health when tab becomes visible again.
313
324
  */
314
325
  private handleVisibilityChange;
326
+ /**
327
+ * Handle browser popstate event (back/forward navigation).
328
+ * Sends the new URL path to the server.
329
+ */
330
+ private handlePopstate;
315
331
  /**
316
332
  * Check if the connection is still healthy after page was backgrounded.
317
333
  * If connection died while backgrounded, trigger reconnection.
@@ -83,6 +83,11 @@ export declare function parseUrlParams(): UrlParams;
83
83
  * - SSR (typeof window === 'undefined')
84
84
  */
85
85
  export declare function isCloudEnvironment(): boolean;
86
+ /**
87
+ * Get the initial path from the browser URL, stripping /c/[channelKey] or /s/[sessionId] prefix.
88
+ * Returns just the app-specific path portion (e.g. "/buttons"), or "/" if no path remains.
89
+ */
90
+ export declare function getInitialPath(): string;
86
91
  /**
87
92
  * Remove sessionId and channelKey path patterns from the URL.
88
93
  * Replaces /s/[sessionId] or /c/[channelKey] paths with root.
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { IkonClient, type ProtocolMessageHandler, type StateHandler, type ProtocolMessageSubscriptionOptions, type ProtocolMessagePort, type ProtocolSendPort } from './client/ikon-client';
1
+ export { IkonClient, type ProtocolMessageHandler, type StateHandler, type ProtocolMessageSubscriptionOptions, type ProtocolMessagePort, type ProtocolSendPort, type WebRTCTrackMapInfo } from './client/ikon-client';
2
2
  export type { IkonClientConfig, LocalConfig, ApiKeyConfig, SessionTokenConfig, CloudConnectionConfig, CommonConnectionConfig, TimeoutConfig, BackendType, AudioConfig, VideoConfig, MediaSessionConfig, WebRtcConfig } from './client/ikon-client-config';
3
3
  export type { ConnectionState } from './client/connection-state';
4
4
  export { isConnecting, isConnected, isOffline, isError } from './client/connection-state';
@@ -23,5 +23,5 @@ export { IKON_AUTH_BASE_URL, IKON_AUTH_URL_PROD, IKON_AUTH_URL_DEV, IKON_BACKEND
23
23
  export { getOrCreateDeviceId, clearDeviceId, extractUserIdFromToken } from './storage';
24
24
  export { IkonMedia, IkonAudioPlayback, IkonVideoPlayback, isSharedArrayBufferSupported, isAudioWorkletSupported, IkonMediaCapture, IkonVideoCapture, IkonAudioCapture, IkonImageCapture } from './media';
25
25
  export type { IkonMediaConfig, IkonAudioPlaybackConfig, IkonVideoPlaybackConfig, IkonVideoCaptureHandle, IkonVideoCaptureRequest, IkonVideoCaptureOptions, VideoCaptureSource, IkonAudioCaptureHandle, IkonAudioCaptureRequest, IkonAudioCaptureOptions, IkonImageCaptureRequest, IkonImageCaptureResult } from './media';
26
- export { WebRTCConnection, WebRTCSignaling, WEBRTC_AUDIO_CODEC, WEBRTC_AUDIO_SAMPLE_RATE, WEBRTC_AUDIO_CHANNELS, WEBRTC_AUDIO_BITRATE, WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, WEBRTC_VIDEO_CODEC, WEBRTC_VIDEO_MAX_BITRATE, WEBRTC_VIDEO_MAX_FRAMERATE, WEBRTC_BUNDLE_POLICY, WEBRTC_RTCP_MUX_POLICY, WEBRTC_ICE_SERVERS, WEBRTC_DATA_CHANNEL_LABEL, WEBRTC_DATA_CHANNEL_ORDERED, WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS } from './webrtc';
26
+ export { WebRTCConnection, WebRTCSignaling, WEBRTC_AUDIO_CODEC, WEBRTC_AUDIO_SAMPLE_RATE, WEBRTC_AUDIO_CHANNELS, WEBRTC_AUDIO_BITRATE, WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, WEBRTC_VIDEO_CODEC, WEBRTC_VIDEO_MAX_BITRATE, WEBRTC_VIDEO_MAX_FRAMERATE, WEBRTC_BUNDLE_POLICY, WEBRTC_RTCP_MUX_POLICY, WEBRTC_ICE_SERVERS, WEBRTC_DATA_CHANNEL_LABEL, WEBRTC_DATA_CHANNEL_ORDERED, WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, WEBRTC_MAX_AUDIO_TRACKS, WEBRTC_MAX_VIDEO_TRACKS } from './webrtc';
27
27
  export type { WebRTCConnectionConfig, WebRTCConnectionState, WebRTCSignalingConfig } from './webrtc';