@axonkit/client-sdk-js 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +87 -66
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,18 @@
1
- # @axonkit/client-sdk-js
2
-
3
- AxonKit JavaScript/TypeScript Client SDK for real-time communication, built on top of [mediasoup-client](https://github.com/versatica/mediasoup-client).
4
-
5
- > **License**: This SDK is proprietary software licensed exclusively for use
6
- > with the AxonKit Service. See [LICENSE](./LICENSE) for the full terms.
7
- > For commercial inquiries, contact <jiyeyuran@gmail.com>.
1
+ <p align="center">
2
+ <img src="assets/banner.svg" alt="AxonKit" width="480">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>AxonKit JavaScript/TypeScript client SDK</strong> for real-time communication,<br/>
7
+ built on <a href="https://github.com/versatica/mediasoup-client">mediasoup-client</a> with a
8
+ <a href="https://livekit.io">LiveKit</a>-compatible API surface.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/axonkit/client-sdk-js/actions/workflows/publish.yml"><img alt="CI" src="https://github.com/axonkit/client-sdk-js/actions/workflows/publish.yml/badge.svg"></a>
13
+ <a href="https://www.npmjs.com/package/@axonkit/client-sdk-js"><img alt="npm version" src="https://img.shields.io/npm/v/@axonkit/client-sdk-js"></a>
14
+ <a href="https://www.npmjs.com/package/@axonkit/client-sdk-js"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@axonkit/client-sdk-js"></a>
15
+ </p>
8
16
 
9
17
  ## Installation
10
18
 
@@ -15,94 +23,105 @@ pnpm add @axonkit/client-sdk-js
15
23
  ## Quick Start
16
24
 
17
25
  ```typescript
18
- import { Room, RoomState, setLogLevel, LogLevel } from '@axonkit/client-sdk-js';
26
+ import {
27
+ Room,
28
+ RoomEvent,
29
+ ConnectionState,
30
+ setLogLevel,
31
+ LogLevel,
32
+ } from '@axonkit/client-sdk-js';
19
33
 
20
34
  setLogLevel(LogLevel.INFO);
21
35
 
22
36
  const room = new Room({
23
- autoSubscribe: true,
24
- dynacast: true,
25
- adaptiveStream: true,
37
+ dynacast: true, // pause simulcast layers with no subscribers
38
+ adaptiveStream: true, // adapt subscription quality to element size/visibility
26
39
  });
27
40
 
28
- // Connect
41
+ // Subscribe to events before connecting
42
+ room
43
+ .on(RoomEvent.ParticipantConnected, (participant) => {
44
+ console.log(`${participant.identity} joined`);
45
+ })
46
+ .on(RoomEvent.ParticipantDisconnected, (participant) => {
47
+ console.log(`${participant.identity} left`);
48
+ })
49
+ .on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
50
+ const element = track.attach();
51
+ if (track.kind === 'video') {
52
+ document.getElementById('remote-videos')?.appendChild(element);
53
+ } else {
54
+ element.play();
55
+ }
56
+ });
57
+
58
+ // Connect (token is optional when the server allows anonymous joins —
59
+ // pass roomName in RoomOptions instead)
29
60
  await room.connect('https://your-server.com', 'your-jwt-token');
30
61
 
31
62
  // Publish camera and microphone
32
63
  await room.localParticipant.setCameraEnabled(true);
33
64
  await room.localParticipant.setMicrophoneEnabled(true);
34
65
 
35
- // Listen for remote tracks
36
- room.on('trackSubscribed', (track, publication, participant) => {
37
- if (track.kind === 'video') {
38
- const element = track.attach();
39
- document.getElementById('remote-videos')?.appendChild(element);
40
- } else {
41
- const element = track.attach();
42
- element.play();
43
- }
44
- });
45
-
46
- // Listen for participants
47
- room.on('participantJoined', (participant) => {
48
- console.log(`${participant.identity} joined`);
49
- });
50
-
51
- room.on('participantLeft', (participant) => {
52
- console.log(`${participant.identity} left`);
53
- });
54
-
55
- // Disconnect
66
+ // Later
56
67
  await room.disconnect();
57
68
  ```
58
69
 
59
70
  ## Features
60
71
 
61
- - **WebRTC Transport** — Powered by mediasoup-client for reliable media transport
62
- - **DataChannel RPC** — Axon Protocol for signaling over DataChannel (after initial HTTP join)
63
- - **Auto Subscribe** — Automatically subscribe to new tracks
64
- - **Dynacast** — Dynamic simulcast layer control based on subscriber needs
65
- - **Adaptive Stream** — Visibility and size-based subscription management
66
- - **Reconnection** — Automatic reconnect with exponential backoff and state sync
67
- - **Heartbeat** — Ping/pong keep-alive with RTT measurement
72
+ - **LiveKit-compatible API** — familiar `Room` / `Participant` / `Track` model, events, and options
73
+ - **mediasoup-client transport** — WebRTC media over mediasoup send/receive transports
74
+ - **DataChannel RPC** — Axon Protocol for signaling over DataChannel after the initial HTTP join
75
+ - **Auto Subscribe** — server-side subscription management with no media loss
76
+ - **Simulcast / SVC** — simulcast layers, scalability modes, backup codec policies
77
+ - **Dynacast** — dynamically pause video encodings with no subscribers
78
+ - **Adaptive Stream** — visibility and size-based subscription management
79
+ - **Reconnection** — automatic reconnect with pluggable reconnect policy and state sync
80
+ - **Data streams & RPC** — sendText/streamText/sendFile/streamBytes and typed RPC between participants
81
+ - **Groups** — breakout-room style participant grouping with pin/move
82
+ - **Room shared state** — server-backed key/value state with offline catch-up
68
83
 
69
84
  ## API Reference
70
85
 
71
86
  ### Room
72
87
 
73
- | Method | Description |
74
- | --------------------- | ------------------------------------------ |
75
- | `connect(url, token)` | Connect to a room |
76
- | `disconnect()` | Disconnect from the room |
77
- | `startAudio()` | Start audio playback (for autoplay policy) |
88
+ | Method | Description |
89
+ | --- | --- |
90
+ | `connect(url, token?, options?)` | Connect to a room (token optional for anonymous servers) |
91
+ | `disconnect(stopTracks?)` | Disconnect and optionally stop local tracks |
92
+ | `switchActiveDevice(kind, deviceId)` | Switch camera / microphone / output device |
93
+ | `startAudio()` | Resume audio playback (autoplay policy) |
78
94
 
79
95
  ### LocalParticipant
80
96
 
81
- | Method | Description |
82
- | -------------------------------- | --------------------------- |
83
- | `setCameraEnabled(enabled)` | Toggle camera |
84
- | `setMicrophoneEnabled(enabled)` | Toggle microphone |
85
- | `setScreenShareEnabled(enabled)` | Toggle screen share |
86
- | `publishTrack(track, options?)` | Publish a local track |
87
- | `unpublishTrack(track)` | Unpublish a track |
88
- | `publishData(data, options?)` | Send data via DataChannel |
89
- | `updateMetadata(metadata)` | Update participant metadata |
90
- | `updateName(name)` | Update participant name |
97
+ | Method | Description |
98
+ | --- | --- |
99
+ | `setCameraEnabled(enabled)` | Toggle camera |
100
+ | `setMicrophoneEnabled(enabled)` | Toggle microphone |
101
+ | `setScreenShareEnabled(enabled)` | Toggle screen share |
102
+ | `publishTrack(track, options?)` | Publish a local track |
103
+ | `unpublishTrack(track, stopOnUnpublish?)` | Unpublish a track |
104
+ | `publishData(data, options?)` | Send data via DataChannel |
105
+ | `setMetadata(metadata)` | Update participant metadata |
106
+ | `setName(name)` | Update participant display name |
91
107
 
92
108
  ### Events
93
109
 
110
+ Subscribe with the `RoomEvent` enum (values are camelCase, matching LiveKit):
111
+
94
112
  ```typescript
95
- room.on('connected', () => {});
96
- room.on('disconnected', (reason) => {});
97
- room.on('reconnecting', () => {});
98
- room.on('reconnected', () => {});
99
- room.on('participantJoined', (participant) => {});
100
- room.on('participantLeft', (participant) => {});
101
- room.on('trackSubscribed', (track, publication, participant) => {});
102
- room.on('trackUnsubscribed', (track, publication, participant) => {});
103
- room.on('activeSpeakersChanged', (speakers) => {});
113
+ room.on(RoomEvent.Connected, () => {});
114
+ room.on(RoomEvent.Disconnected, (reason) => {});
115
+ room.on(RoomEvent.Reconnecting, () => {});
116
+ room.on(RoomEvent.ParticipantConnected, (participant) => {});
117
+ room.on(RoomEvent.ParticipantDisconnected, (participant, reason) => {});
118
+ room.on(RoomEvent.TrackSubscribed, (track, publication, participant) => {});
119
+ room.on(RoomEvent.TrackUnsubscribed, (track, publication, participant) => {});
120
+ room.on(RoomEvent.ActiveSpeakersChanged, (speakers) => {});
104
121
  ```
105
122
 
123
+ Full API documentation is generated with TypeDoc: `pnpm run docs`.
124
+
106
125
  ## Building
107
126
 
108
127
  ```bash
@@ -118,8 +137,10 @@ Outputs:
118
137
 
119
138
  ## Demo
120
139
 
121
- Open `examples/demo/index.html` in a browser after building. Requires a running AxonKit server.
140
+ Open `examples/demo/index.html` in a browser after building. Requires a running [AxonKit server](https://github.com/axonkit/axonkit).
122
141
 
123
142
  ## License
124
143
 
125
- MIT
144
+ This SDK is proprietary software licensed exclusively for use with the AxonKit
145
+ Service. See [LICENSE](./LICENSE) for the full terms. For commercial inquiries,
146
+ contact <jiyeyuran@gmail.com>.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axonkit/client-sdk-js",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "AxonKit JS/TS Client SDK based on mediasoup-client",
5
5
  "main": "dist/axonkit-client.umd.js",
6
6
  "module": "dist/axonkit-client.esm.js",