@axonkit/client-sdk-js 0.1.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.
Files changed (43) hide show
  1. package/LICENSE +85 -0
  2. package/README.md +125 -0
  3. package/dist/Room.d.ts +273 -0
  4. package/dist/axonkit-client.esm.js +1 -0
  5. package/dist/axonkit-client.umd.js +1 -0
  6. package/dist/connectionHelper/ConnectionCheck.d.ts +33 -0
  7. package/dist/data-stream/DataStreamManager.d.ts +65 -0
  8. package/dist/events.d.ts +432 -0
  9. package/dist/index.d.ts +41 -0
  10. package/dist/participant/LocalParticipant.d.ts +186 -0
  11. package/dist/participant/LocalTrackPublication.d.ts +28 -0
  12. package/dist/participant/Participant.d.ts +133 -0
  13. package/dist/participant/RemoteParticipant.d.ts +30 -0
  14. package/dist/participant/RemoteTrackPublication.d.ts +63 -0
  15. package/dist/protocol/errors.d.ts +22 -0
  16. package/dist/protocol/message.d.ts +30 -0
  17. package/dist/protocol/types.d.ts +522 -0
  18. package/dist/room/DefaultReconnectPolicy.d.ts +28 -0
  19. package/dist/room/options.d.ts +74 -0
  20. package/dist/rpc.d.ts +28 -0
  21. package/dist/signal/RPCClient.d.ts +28 -0
  22. package/dist/signal/SignalClient.d.ts +14 -0
  23. package/dist/stats/StatsCollector.d.ts +15 -0
  24. package/dist/track/LocalAudioTrack.d.ts +20 -0
  25. package/dist/track/LocalTrack.d.ts +108 -0
  26. package/dist/track/LocalVideoTrack.d.ts +35 -0
  27. package/dist/track/RemoteAudioTrack.d.ts +7 -0
  28. package/dist/track/RemoteTrack.d.ts +33 -0
  29. package/dist/track/RemoteVideoTrack.d.ts +31 -0
  30. package/dist/track/Track.d.ts +62 -0
  31. package/dist/track/create.d.ts +30 -0
  32. package/dist/track/options.d.ts +525 -0
  33. package/dist/track/processor/types.d.ts +49 -0
  34. package/dist/track/publishUtils.d.ts +14 -0
  35. package/dist/transport/TransportManager.d.ts +62 -0
  36. package/dist/types.d.ts +146 -0
  37. package/dist/utils/browser.d.ts +113 -0
  38. package/dist/utils/deviceFailure.d.ts +30 -0
  39. package/dist/utils/id.d.ts +1 -0
  40. package/dist/utils/logger.d.ts +39 -0
  41. package/dist/utils/typedEmitter.d.ts +24 -0
  42. package/dist/version.d.ts +2 -0
  43. package/package.json +80 -0
@@ -0,0 +1,20 @@
1
+ import { LocalTrack } from './LocalTrack';
2
+ export declare class LocalAudioTrack extends LocalTrack {
3
+ /**
4
+ * When `true`, the underlying `MediaStreamTrack` is stopped when the track
5
+ * is muted and restarted when unmuted. Useful for disabling the microphone
6
+ * recording indicator on some platforms.
7
+ */
8
+ stopOnMute: boolean;
9
+ /**
10
+ * Pending constraints to apply on the next unmute. Used when the user
11
+ * switches devices while the track is muted — the actual restart is
12
+ * deferred until unmute.
13
+ */
14
+ private pendingRestartConstraints?;
15
+ private muteLock;
16
+ constructor(mediaStreamTrack: MediaStreamTrack, constraints?: MediaTrackConstraints);
17
+ mute(): Promise<void>;
18
+ unmute(): Promise<void>;
19
+ setDeviceId(deviceId: string): Promise<void>;
20
+ }
@@ -0,0 +1,108 @@
1
+ import { Mutex } from 'async-mutex';
2
+ import { Track, type TrackDimensions, type TrackEvents } from './Track';
3
+ import { TrackKind, TrackSource } from '../protocol/types';
4
+ import { TrackEvent } from '../events';
5
+ import type { TrackProcessor } from './processor/types';
6
+ export type LocalTrackEvents = TrackEvents & {
7
+ [TrackEvent.Restarted]: (track: LocalTrack) => void;
8
+ };
9
+ export declare class LocalTrack extends Track {
10
+ private _constraints?;
11
+ private _producer?;
12
+ protected _processor?: TrackProcessor;
13
+ protected processorElement?: HTMLMediaElement;
14
+ private _isUpstreamPaused;
15
+ private _providedByUser;
16
+ private _prevBytesSent;
17
+ private _prevStatsTime;
18
+ private _mediaTrackMuteDebounce;
19
+ private _handleVisibilityChange;
20
+ protected trackChangeLock: Mutex;
21
+ protected pauseUpstreamLock: Mutex;
22
+ constructor(kind: TrackKind, mediaStreamTrack: MediaStreamTrack, source?: TrackSource, constraints?: MediaTrackConstraints, userProvided?: boolean);
23
+ /**
24
+ * Returns the processed track if a processor is active, otherwise the
25
+ * raw source track. Consumers should use this for playback and
26
+ * publishing.
27
+ */
28
+ get mediaStreamTrack(): MediaStreamTrack;
29
+ get isLocal(): boolean;
30
+ /** The MediaStreamTrack id. */
31
+ get id(): string;
32
+ /** Current capture constraints. */
33
+ get constraints(): MediaTrackConstraints | undefined;
34
+ /**
35
+ * Video dimensions from the current track settings.
36
+ * Returns `undefined` for audio tracks.
37
+ */
38
+ get dimensions(): TrackDimensions | undefined;
39
+ /** Whether upstream publishing has been paused via {@link pauseUpstream}. */
40
+ get isUpstreamPaused(): boolean;
41
+ /** Whether the track was provided by the user (not managed by the SDK). */
42
+ get isUserProvided(): boolean;
43
+ /** Returns the currently active processor, or `undefined`. */
44
+ getProcessor(): TrackProcessor | undefined;
45
+ /**
46
+ * Returns the settings of the *original* source track, ignoring any
47
+ * active processor. Useful when you need the real capture resolution
48
+ * or device info regardless of post-processing.
49
+ */
50
+ getSourceTrackSettings(): MediaTrackSettings;
51
+ /**
52
+ * Set a {@link TrackProcessor} on this track. Pass `undefined` to remove
53
+ * the current processor.
54
+ */
55
+ setProcessor(processor: TrackProcessor | undefined, showProcessedStreamLocally?: boolean): Promise<void>;
56
+ /** Stop and remove the current processor. */
57
+ stopProcessor(): Promise<void>;
58
+ /** Mute the track (disables the MediaStreamTrack). */
59
+ mute(): void;
60
+ /** Unmute the track (enables the MediaStreamTrack). */
61
+ unmute(): void;
62
+ /**
63
+ * Pause publishing to the server without disabling the local
64
+ * MediaStreamTrack. Useful for showing a local preview while
65
+ * not sending to remote participants.
66
+ */
67
+ pauseUpstream(): Promise<void>;
68
+ /** Resume publishing after a call to {@link pauseUpstream}. */
69
+ resumeUpstream(): Promise<void>;
70
+ /**
71
+ * Gets the RTCStatsReport for the underlying RTP sender.
72
+ */
73
+ getRTCStatsReport(): Promise<RTCStatsReport | undefined>;
74
+ /**
75
+ * Get the device ID currently used by this track.
76
+ */
77
+ getDeviceId(): Promise<string | undefined>;
78
+ /**
79
+ * Wait until the video track reports valid dimensions.
80
+ * @throws Error if the track is audio or dimensions don't become
81
+ * available within the timeout.
82
+ */
83
+ waitForDimensions(timeout?: number): Promise<TrackDimensions>;
84
+ restart(constraints?: MediaTrackConstraints): Promise<void>;
85
+ replaceTrack(newTrack: MediaStreamTrack): Promise<void>;
86
+ /** Internal replace without acquiring trackChangeLock (caller must hold it). */
87
+ private replaceTrackInternal;
88
+ stop(): void;
89
+ protected setTrackMuted(muted: boolean): void;
90
+ private monitorSender;
91
+ private attachMediaTrackListeners;
92
+ private detachMediaTrackListeners;
93
+ private onMediaTrackMute;
94
+ private onMediaTrackUnmute;
95
+ /** Start listening for visibility changes (should be called after publishing). */
96
+ addVisibilityListener(): void;
97
+ private removeVisibilityListener;
98
+ private onVisibilityChange;
99
+ /**
100
+ * Ensures a hidden HTMLMediaElement exists for the processor to read
101
+ * frames from the source track. Reuses the existing element if present.
102
+ */
103
+ private ensureProcessorElement;
104
+ private attachTrackToProcessorElement;
105
+ private destroyProcessorElement;
106
+ /** Re-attach all user-facing elements to the given track. */
107
+ private reattachElementsToTrack;
108
+ }
@@ -0,0 +1,35 @@
1
+ import { LocalTrack } from './LocalTrack';
2
+ import { TrackSource, VideoQuality } from '../protocol/types';
3
+ import type { VideoEncoding, VideoResolution } from './options';
4
+ export declare class LocalVideoTrack extends LocalTrack {
5
+ private simulcast;
6
+ private encoding?;
7
+ private senderLock;
8
+ /** The codec used for the primary producer (e.g. 'vp9', 'av1'). */
9
+ publishedCodec?: string;
10
+ /** The backup codec name (e.g. 'vp8'). */
11
+ backupCodec?: string;
12
+ constructor(mediaStreamTrack: MediaStreamTrack, source?: TrackSource, constraints?: MediaTrackConstraints);
13
+ get dimensions(): VideoResolution | undefined;
14
+ setSimulcast(enabled: boolean): void;
15
+ setEncoding(encoding: VideoEncoding): void;
16
+ getSimulcastEncodings(): RTCRtpEncodingParameters[];
17
+ /**
18
+ * Applies dynacast quality updates from the server.
19
+ *
20
+ * - Simulcast: toggles each encoding's `active` by rid.
21
+ * - SVC (single encoding): sets `active = false` only when ALL qualities
22
+ * are disabled; otherwise keeps it `true`.
23
+ */
24
+ setDynacastQuality(qualities: {
25
+ quality: VideoQuality;
26
+ enabled: boolean;
27
+ }[]): Promise<void>;
28
+ /**
29
+ * Set the degradation preference hint for the browser encoder.
30
+ * Takes effect on the next `setParameters` call (or immediately if
31
+ * an RTP sender is available).
32
+ */
33
+ setDegradationPreference(preference: RTCDegradationPreference): Promise<void>;
34
+ setDeviceId(deviceId: string): Promise<void>;
35
+ }
@@ -0,0 +1,7 @@
1
+ import { RemoteTrack } from './RemoteTrack';
2
+ export declare class RemoteAudioTrack extends RemoteTrack {
3
+ private _volume;
4
+ constructor(mediaStreamTrack: MediaStreamTrack);
5
+ get volume(): number;
6
+ setVolume(volume: number): void;
7
+ }
@@ -0,0 +1,33 @@
1
+ import { Track } from './Track';
2
+ import { TrackKind, TrackSource } from '../protocol/types';
3
+ export declare class RemoteTrack extends Track {
4
+ private _prevBytesReceived;
5
+ private _prevStatsTime;
6
+ private _rtpTimestamp?;
7
+ private _timeSyncHandle?;
8
+ constructor(kind: TrackKind, source: TrackSource | undefined, mediaStreamTrack: MediaStreamTrack);
9
+ get isLocal(): boolean;
10
+ /**
11
+ * Stop the remote track.
12
+ */
13
+ stop(): void;
14
+ /**
15
+ * Gets the RTCStatsReport for the underlying RTP receiver.
16
+ */
17
+ getRTCStatsReport(): Promise<RTCStatsReport | undefined>;
18
+ /**
19
+ * Set a playout delay (in seconds) for this track. Higher values allow
20
+ * more buffering in the browser and add latency.
21
+ */
22
+ setPlayoutDelay(delayInSeconds: number): void;
23
+ /** Returns the current playout delay (in seconds). */
24
+ getPlayoutDelay(): number;
25
+ /**
26
+ * Registers a loop that emits {@link TrackEvent.TimeSyncUpdate} events
27
+ * with the current RTP timestamp and browser timestamp, useful for
28
+ * lip-sync and cross-track synchronization.
29
+ */
30
+ private registerTimeSyncUpdate;
31
+ private supportsSynchronizationSources;
32
+ private monitorReceiver;
33
+ }
@@ -0,0 +1,31 @@
1
+ import { RemoteTrack } from './RemoteTrack';
2
+ import { TrackSource } from '../protocol/types';
3
+ import type { AdaptiveStreamSettings } from '../room/options';
4
+ export declare class RemoteVideoTrack extends RemoteTrack {
5
+ adaptiveStreamSettings?: AdaptiveStreamSettings;
6
+ private rpc?;
7
+ private elementInfos;
8
+ private intersectionObserver?;
9
+ private resizeObserver?;
10
+ private visibilityBound?;
11
+ private debounceTimer?;
12
+ private pipElement?;
13
+ constructor(source: TrackSource | undefined, mediaStreamTrack: MediaStreamTrack);
14
+ get isAdaptiveStream(): boolean;
15
+ attach(element?: HTMLMediaElement): HTMLMediaElement;
16
+ detach(element?: HTMLMediaElement): HTMLMediaElement[];
17
+ /** Enter Picture-in-Picture on the first attached video element. */
18
+ requestPictureInPicture(): Promise<PictureInPictureWindow | undefined>;
19
+ stop(): void;
20
+ private setupAdaptiveObservers;
21
+ private observeElement;
22
+ private unobserveElement;
23
+ private handleVisibilityUpdate;
24
+ private handlePageVisibilityChange;
25
+ private debouncedUpdateLayers;
26
+ private updatePreferredLayers;
27
+ private getPixelDensity;
28
+ private calculateSpatialLayer;
29
+ private cleanupAdaptive;
30
+ private getFirstVideoElement;
31
+ }
@@ -0,0 +1,62 @@
1
+ import { TypedEmitter } from '../utils/typedEmitter';
2
+ import { TrackKind, TrackSource, StreamState } from '../protocol/types';
3
+ import { TrackEvent } from '../events';
4
+ export type TrackEvents = {
5
+ [TrackEvent.Muted]: (track: Track) => void;
6
+ [TrackEvent.Unmuted]: (track: Track) => void;
7
+ [TrackEvent.Ended]: (track: Track) => void;
8
+ [TrackEvent.ElementAttached]: (element: HTMLMediaElement) => void;
9
+ [TrackEvent.ElementDetached]: (element: HTMLMediaElement) => void;
10
+ [TrackEvent.AudioPlaybackStarted]: () => void;
11
+ [TrackEvent.AudioPlaybackFailed]: (error?: Error) => void;
12
+ [TrackEvent.VideoPlaybackStarted]: () => void;
13
+ [TrackEvent.VideoPlaybackFailed]: (error?: Error) => void;
14
+ [TrackEvent.UpstreamPaused]: (track: Track) => void;
15
+ [TrackEvent.UpstreamResumed]: (track: Track) => void;
16
+ [TrackEvent.VisibilityChanged]: (visible: boolean, track: Track) => void;
17
+ [TrackEvent.VideoDimensionsChanged]: (dimensions: TrackDimensions, track: Track) => void;
18
+ [TrackEvent.AudioSilenceDetected]: () => void;
19
+ [TrackEvent.StreamStateChanged]: (track: Track, streamState: StreamState) => void;
20
+ [TrackEvent.TimeSyncUpdate]: (update: {
21
+ timestamp: number;
22
+ rtpTimestamp: number;
23
+ }) => void;
24
+ };
25
+ export declare abstract class Track extends TypedEmitter<TrackEvents> {
26
+ kind: TrackKind;
27
+ source: TrackSource;
28
+ sid?: string;
29
+ protected _mediaStreamTrack: MediaStreamTrack;
30
+ get mediaStreamTrack(): MediaStreamTrack;
31
+ protected _isMuted: boolean;
32
+ private _streamState;
33
+ attachedElements: HTMLMediaElement[];
34
+ protected _currentBitrate: number;
35
+ protected monitorInterval?: ReturnType<typeof setInterval>;
36
+ constructor(kind: TrackKind, source: TrackSource | undefined, mediaStreamTrack: MediaStreamTrack);
37
+ /** Current bitrate in bits per second, updated by the monitor. */
38
+ get currentBitrate(): number;
39
+ abstract get isLocal(): boolean;
40
+ /**
41
+ * Whether the track is currently muted.
42
+ * This reflects the publisher's intent and is independent of consumer
43
+ * pause state or {@link streamState}.
44
+ */
45
+ get isMuted(): boolean;
46
+ /**
47
+ * The current stream state of the track.
48
+ * {@link StreamState.Active} means the server is actively forwarding media;
49
+ * {@link StreamState.Paused} means the server has temporarily stopped forwarding (e.g. bandwidth limits).
50
+ * This is separate from `isMuted`, which reflects the publisher's intent.
51
+ */
52
+ get streamState(): StreamState;
53
+ attach(element?: HTMLMediaElement): HTMLMediaElement;
54
+ detach(element?: HTMLMediaElement): HTMLMediaElement[];
55
+ private detachElement;
56
+ private recycleElement;
57
+ stop(): void;
58
+ }
59
+ export interface TrackDimensions {
60
+ width: number;
61
+ height: number;
62
+ }
@@ -0,0 +1,30 @@
1
+ import { LocalTrack } from './LocalTrack';
2
+ import { LocalAudioTrack } from './LocalAudioTrack';
3
+ import { LocalVideoTrack } from './LocalVideoTrack';
4
+ import { type AudioCaptureOptions, type VideoCaptureOptions, type ScreenShareCaptureOptions, type CreateLocalTracksOptions } from './options';
5
+ /**
6
+ * Create local audio and video tracks with the given options.
7
+ *
8
+ * @param options - Capture options for audio and video. Defaults to
9
+ * `{ audio: true, video: true }`.
10
+ * @returns An array of created local tracks.
11
+ */
12
+ export declare function createLocalTracks(options?: CreateLocalTracksOptions): Promise<LocalTrack[]>;
13
+ /**
14
+ * Create a local audio track from the microphone.
15
+ *
16
+ * @param options - Audio capture options. Uses defaults when omitted.
17
+ */
18
+ export declare function createLocalAudioTrack(options?: AudioCaptureOptions): Promise<LocalAudioTrack>;
19
+ /**
20
+ * Create a local video track from the camera.
21
+ *
22
+ * @param options - Video capture options. Uses defaults when omitted.
23
+ */
24
+ export declare function createLocalVideoTrack(options?: VideoCaptureOptions): Promise<LocalVideoTrack>;
25
+ /**
26
+ * Create local screen share tracks (video and optionally audio).
27
+ *
28
+ * @param options - Screen share capture options.
29
+ */
30
+ export declare function createLocalScreenTracks(options?: ScreenShareCaptureOptions): Promise<LocalTrack[]>;