@memberjunction/livekit-room-core 0.0.1 → 5.42.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.
- package/README.md +75 -28
- package/dist/audio-meter.d.ts +48 -0
- package/dist/audio-meter.d.ts.map +1 -0
- package/dist/audio-meter.js +60 -0
- package/dist/audio-meter.js.map +1 -0
- package/dist/events.d.ts +162 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +93 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/livekit-effects.d.ts +29 -0
- package/dist/livekit-effects.d.ts.map +1 -0
- package/dist/livekit-effects.js +57 -0
- package/dist/livekit-effects.js.map +1 -0
- package/dist/livekit-preview.d.ts +45 -0
- package/dist/livekit-preview.d.ts.map +1 -0
- package/dist/livekit-preview.js +92 -0
- package/dist/livekit-preview.js.map +1 -0
- package/dist/livekit-room-controller.d.ts +202 -0
- package/dist/livekit-room-controller.d.ts.map +1 -0
- package/dist/livekit-room-controller.js +601 -0
- package/dist/livekit-room-controller.js.map +1 -0
- package/dist/types.d.ts +163 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -7
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Framework-agnostic types for the LiveKit room core. These are the vocabulary the
|
|
3
|
+
* MJ-native realtime room UX binds to — deliberately free of any UI-framework or LiveKit SDK type in
|
|
4
|
+
* their *public* shape, so consumers (Angular, React, plain TS) program against a stable surface.
|
|
5
|
+
*
|
|
6
|
+
* The one intentional exception is {@link LiveKitParticipantView.Raw}, which carries the underlying
|
|
7
|
+
* livekit-client `Participant` so a UI layer can call `track.attach(element)` to render media — the SDK
|
|
8
|
+
* owns the DOM-attach mechanics and there is no value in re-implementing them.
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/livekit-room-core
|
|
11
|
+
*/
|
|
12
|
+
import type { Participant, RoomOptions, Track } from 'livekit-client';
|
|
13
|
+
/**
|
|
14
|
+
* The connection lifecycle of a LiveKit room as the core normalizes it. Maps the livekit-client
|
|
15
|
+
* `ConnectionState` plus the pre-connect / post-disconnect edges into one stable union.
|
|
16
|
+
*/
|
|
17
|
+
export type LiveKitConnectionStatus = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'error';
|
|
18
|
+
/** Why a room disconnected — normalized from the livekit-client `DisconnectReason`. */
|
|
19
|
+
export type LiveKitDisconnectReason = 'client-initiated' | 'server-shutdown' | 'participant-removed' | 'room-deleted' | 'connection-lost' | 'duplicate-identity' | 'unknown';
|
|
20
|
+
/** The role a participant holds in the room, derived from LiveKit participant metadata. */
|
|
21
|
+
export type LiveKitParticipantRole = 'host' | 'agent' | 'participant';
|
|
22
|
+
/** The kind of a media track, normalized from `Track.Kind`. */
|
|
23
|
+
export type LiveKitTrackKind = 'audio' | 'video' | 'screen' | 'screen-audio' | 'unknown';
|
|
24
|
+
/** A camera background effect (requires `@livekit/track-processors`). */
|
|
25
|
+
export type LiveKitBackgroundEffect = {
|
|
26
|
+
Kind: 'none';
|
|
27
|
+
} | {
|
|
28
|
+
Kind: 'blur';
|
|
29
|
+
Radius?: number;
|
|
30
|
+
} | {
|
|
31
|
+
Kind: 'image';
|
|
32
|
+
ImageUrl: string;
|
|
33
|
+
};
|
|
34
|
+
/** End-to-end-encryption options. The host supplies the worker (bundler-specific) + a shared passphrase. */
|
|
35
|
+
export interface LiveKitE2EEOptions {
|
|
36
|
+
/** The shared passphrase all participants derive the room key from. */
|
|
37
|
+
Passphrase: string;
|
|
38
|
+
/** The E2EE web worker (e.g. `new Worker(new URL('livekit-client/e2ee-worker', import.meta.url))`). */
|
|
39
|
+
Worker: Worker;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A normalized view of one room participant. This is what a UI grid renders — one tile per view.
|
|
43
|
+
* {@link Raw} is included so the UI can attach the participant's video/audio tracks to DOM elements.
|
|
44
|
+
*/
|
|
45
|
+
export interface LiveKitParticipantView {
|
|
46
|
+
/** Stable, application-assigned participant identity (the diarization / addressing key). */
|
|
47
|
+
Identity: string;
|
|
48
|
+
/** The participant's display name (`name`), when set; falls back to {@link Identity}. */
|
|
49
|
+
DisplayName: string;
|
|
50
|
+
/** Whether this is the local participant (the human running this client). */
|
|
51
|
+
IsLocal: boolean;
|
|
52
|
+
/** The participant's room role, derived from metadata (the agent bot reports as `'agent'`). */
|
|
53
|
+
Role: LiveKitParticipantRole;
|
|
54
|
+
/** Whether the participant is currently speaking (LiveKit voice-activity detection). */
|
|
55
|
+
IsSpeaking: boolean;
|
|
56
|
+
/** Smoothed audio level in 0..1 for meters, sourced from LiveKit's per-participant audio level. */
|
|
57
|
+
AudioLevel: number;
|
|
58
|
+
/** Whether the participant currently has a published, unmuted microphone track. */
|
|
59
|
+
HasAudio: boolean;
|
|
60
|
+
/** Whether the participant currently has a published, unmuted camera track. */
|
|
61
|
+
HasVideo: boolean;
|
|
62
|
+
/** Whether the participant is currently sharing their screen. */
|
|
63
|
+
IsScreenSharing: boolean;
|
|
64
|
+
/** Connection quality bucket as LiveKit reports it. */
|
|
65
|
+
ConnectionQuality: 'excellent' | 'good' | 'poor' | 'lost' | 'unknown';
|
|
66
|
+
/**
|
|
67
|
+
* The underlying livekit-client participant, exposed ONLY so a UI layer can attach media tracks
|
|
68
|
+
* (`view.Raw.getTrackPublication(...)?.track?.attach(el)`). Do not mutate it directly — drive the
|
|
69
|
+
* room through {@link import('./livekit-room-controller.js').LiveKitRoomController} instead.
|
|
70
|
+
*/
|
|
71
|
+
Raw: Participant;
|
|
72
|
+
}
|
|
73
|
+
/** A message received on the LiveKit data channel (the room-native "chat" / app payload). */
|
|
74
|
+
export interface LiveKitDataMessage {
|
|
75
|
+
/** The decoded text payload (UTF-8). For binary payloads use {@link Bytes}. */
|
|
76
|
+
Text: string;
|
|
77
|
+
/** The raw bytes as received (for non-text payloads). */
|
|
78
|
+
Bytes: Uint8Array;
|
|
79
|
+
/** The optional topic the message was published under. */
|
|
80
|
+
Topic?: string;
|
|
81
|
+
/** The sender's participant identity, when the message came from a remote participant. */
|
|
82
|
+
FromIdentity?: string;
|
|
83
|
+
/** The sender's display name, when known. */
|
|
84
|
+
FromDisplayName?: string;
|
|
85
|
+
/** Epoch-ms receive timestamp. */
|
|
86
|
+
ReceivedAt: number;
|
|
87
|
+
}
|
|
88
|
+
/** A normalized error surfaced by the room (connection failure, device error, publish failure). */
|
|
89
|
+
export interface LiveKitRoomError {
|
|
90
|
+
/** A stable category for programmatic handling. */
|
|
91
|
+
Kind: 'connect' | 'device' | 'publish' | 'data' | 'disconnect' | 'unknown';
|
|
92
|
+
/** A human-readable message. */
|
|
93
|
+
Message: string;
|
|
94
|
+
/** The original error, when available. */
|
|
95
|
+
Cause?: unknown;
|
|
96
|
+
}
|
|
97
|
+
/** The current local-media toggle state (what the human is publishing). */
|
|
98
|
+
export interface LiveKitLocalMediaState {
|
|
99
|
+
/** Whether the local microphone is enabled (publishing audio). */
|
|
100
|
+
MicrophoneEnabled: boolean;
|
|
101
|
+
/** Whether the local camera is enabled (publishing video). */
|
|
102
|
+
CameraEnabled: boolean;
|
|
103
|
+
/** Whether the local participant is sharing their screen. */
|
|
104
|
+
ScreenShareEnabled: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** A media input/output device the user can pick (microphone, camera, speaker). */
|
|
107
|
+
export interface LiveKitDevice {
|
|
108
|
+
/** The `deviceId` to pass to {@link import('./livekit-room-controller.js').LiveKitRoomController.SwitchDevice}. */
|
|
109
|
+
DeviceId: string;
|
|
110
|
+
/** The human-readable device label. */
|
|
111
|
+
Label: string;
|
|
112
|
+
/** The device kind. */
|
|
113
|
+
Kind: 'audioinput' | 'videoinput' | 'audiooutput';
|
|
114
|
+
}
|
|
115
|
+
/** Options for opening a room connection. */
|
|
116
|
+
export interface LiveKitRoomConnectOptions {
|
|
117
|
+
/** Start with the microphone enabled (default: true). */
|
|
118
|
+
EnableMicrophone?: boolean;
|
|
119
|
+
/** Start with the camera enabled (default: false — voice-first). */
|
|
120
|
+
EnableCamera?: boolean;
|
|
121
|
+
/** The display name to publish as the local participant's `name`. */
|
|
122
|
+
DisplayName?: string;
|
|
123
|
+
/** Start with the Krisp noise filter enabled (LiveKit Cloud; requires `@livekit/krisp-noise-filter`). */
|
|
124
|
+
NoiseFilterEnabled?: boolean;
|
|
125
|
+
/** Start with a camera background effect (requires `@livekit/track-processors`). */
|
|
126
|
+
BackgroundEffect?: LiveKitBackgroundEffect;
|
|
127
|
+
/** Enable end-to-end encryption for this connection. */
|
|
128
|
+
E2EE?: LiveKitE2EEOptions;
|
|
129
|
+
/** Preferred microphone device id. */
|
|
130
|
+
MicrophoneDeviceId?: string;
|
|
131
|
+
/** Preferred camera device id. */
|
|
132
|
+
CameraDeviceId?: string;
|
|
133
|
+
/** Advanced livekit-client room options merged into the constructed `Room`. */
|
|
134
|
+
RoomOptions?: RoomOptions;
|
|
135
|
+
}
|
|
136
|
+
/** A snapshot of the whole room state, emitted whenever anything material changes. */
|
|
137
|
+
export interface LiveKitRoomState {
|
|
138
|
+
/** The connection lifecycle status. */
|
|
139
|
+
Status: LiveKitConnectionStatus;
|
|
140
|
+
/** The room name once connected. */
|
|
141
|
+
RoomName?: string;
|
|
142
|
+
/** The local participant's view, once connected. */
|
|
143
|
+
Local?: LiveKitParticipantView;
|
|
144
|
+
/** All remote participants. */
|
|
145
|
+
Remote: LiveKitParticipantView[];
|
|
146
|
+
/** Identities currently flagged as active speakers, most-recent first. */
|
|
147
|
+
ActiveSpeakerIdentities: string[];
|
|
148
|
+
/** The local-media toggle state. */
|
|
149
|
+
LocalMedia: LiveKitLocalMediaState;
|
|
150
|
+
/** Whether browser autoplay policy is blocking remote audio (the UI should prompt to enable sound). */
|
|
151
|
+
AudioPlaybackBlocked: boolean;
|
|
152
|
+
/** Whether the Krisp noise filter is currently applied to the local microphone. */
|
|
153
|
+
NoiseFilterEnabled: boolean;
|
|
154
|
+
/** The active camera background effect. */
|
|
155
|
+
BackgroundEffect: LiveKitBackgroundEffect;
|
|
156
|
+
/** Whether end-to-end encryption is enabled for this connection. */
|
|
157
|
+
E2EEEnabled: boolean;
|
|
158
|
+
/** The reason for disconnect, once disconnected. */
|
|
159
|
+
DisconnectReason?: LiveKitDisconnectReason;
|
|
160
|
+
}
|
|
161
|
+
/** Maps a livekit-client `Track.Source` to a normalized {@link LiveKitTrackKind}. */
|
|
162
|
+
export type LiveKitTrackSourceMapper = (source: Track.Source) => LiveKitTrackKind;
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC;AAEtH,uFAAuF;AACvF,MAAM,MAAM,uBAAuB,GAC/B,kBAAkB,GAClB,iBAAiB,GACjB,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,oBAAoB,GACpB,SAAS,CAAC;AAEd,2FAA2F;AAC3F,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;AAEtE,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;AAEzF,yEAAyE;AACzE,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,C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;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,+BAA+B;IAC/B,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC,0EAA0E;IAC1E,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,oCAAoC;IACpC,UAAU,EAAE,sBAAsB,CAAC;IACnC,uGAAuG;IACvG,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mFAAmF;IACnF,kBAAkB,EAAE,OAAO,CAAC;IAC5B,2CAA2C;IAC3C,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;CAC5C;AAED,qFAAqF;AACrF,MAAM,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,gBAAgB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Framework-agnostic types for the LiveKit room core. These are the vocabulary the
|
|
3
|
+
* MJ-native realtime room UX binds to — deliberately free of any UI-framework or LiveKit SDK type in
|
|
4
|
+
* their *public* shape, so consumers (Angular, React, plain TS) program against a stable surface.
|
|
5
|
+
*
|
|
6
|
+
* The one intentional exception is {@link LiveKitParticipantView.Raw}, which carries the underlying
|
|
7
|
+
* livekit-client `Participant` so a UI layer can call `track.attach(element)` to render media — the SDK
|
|
8
|
+
* owns the DOM-attach mechanics and there is no value in re-implementing them.
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/livekit-room-core
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/livekit-room-core",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.42.0",
|
|
5
|
+
"description": "MemberJunction: Framework-agnostic LiveKit room client core. Pure TypeScript wrapper around livekit-client that manages a single room connection — participants, tracks, active speakers, audio levels, device control, and data-channel messages — and surfaces it as observable state. Zero UI dependencies; consumable from any framework (Angular, React, Vue) or plain TS. The MJ-native realtime room UX foundation.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc && tsc-alias -f",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest"
|
|
15
|
+
},
|
|
16
|
+
"author": "MemberJunction.com",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@livekit/krisp-noise-filter": "^0.4.3",
|
|
20
|
+
"@livekit/track-processors": "^0.7.2",
|
|
21
|
+
"@memberjunction/global": "5.42.0",
|
|
22
|
+
"livekit-client": "^2.7.4",
|
|
23
|
+
"rxjs": "^7.8.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "24.10.11",
|
|
27
|
+
"typescript": "^5.9.3"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
32
|
+
}
|
|
10
33
|
}
|