@onlive.ai/common-121 0.2.70 → 0.2.179
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 +0 -1
- package/chunk-CHMR2I4G.js +2 -0
- package/components/asset/asset-modal-portal.cjs +550 -0
- package/components/asset/asset-modal-portal.d.cts +22 -0
- package/components/asset/asset-modal-portal.d.ts +22 -0
- package/components/asset/asset-modal-portal.js +550 -0
- package/components/asset/asset.cjs +3536 -0
- package/components/asset/asset.d.cts +37 -0
- package/components/asset/asset.d.ts +37 -0
- package/components/asset/asset.js +3536 -0
- package/components/asset/asset.loaders.cjs +2 -0
- package/components/asset/asset.loaders.d.cts +17 -0
- package/components/asset/asset.loaders.d.ts +17 -0
- package/components/asset/asset.loaders.js +2 -0
- package/components/asset/asset.renderer.cjs +2292 -0
- package/components/asset/asset.renderer.d.cts +29 -0
- package/components/asset/asset.renderer.d.ts +29 -0
- package/components/asset/asset.renderer.js +2292 -0
- package/components/asset/asset.styles.cjs +683 -0
- package/components/asset/asset.styles.d.cts +6 -0
- package/components/asset/asset.styles.d.ts +6 -0
- package/components/asset/asset.styles.js +683 -0
- package/components/asset/asset.types.cjs +2 -0
- package/components/asset/asset.types.d.cts +103 -0
- package/components/asset/asset.types.d.ts +103 -0
- package/components/asset/asset.types.js +1 -0
- package/components/asset/index.cjs +3536 -0
- package/components/asset/index.d.cts +8 -0
- package/components/asset/index.d.ts +8 -0
- package/components/asset/index.js +3536 -0
- package/components/player/player.cjs +2044 -0
- package/components/player/player.d.cts +25 -0
- package/components/player/player.d.ts +25 -0
- package/components/player/player.js +2044 -0
- package/components/player/player.styles.cjs +16 -0
- package/components/player/player.styles.d.cts +6 -0
- package/components/player/player.styles.d.ts +6 -0
- package/components/player/player.styles.js +16 -0
- package/components/side-bar/index.cjs +3185 -0
- package/components/side-bar/index.d.cts +11 -0
- package/components/side-bar/index.d.ts +11 -0
- package/components/side-bar/index.js +3185 -0
- package/components/side-bar/side-bar.cjs +3185 -0
- package/components/side-bar/side-bar.d.cts +83 -0
- package/components/side-bar/side-bar.d.ts +83 -0
- package/components/side-bar/side-bar.js +3185 -0
- package/components/side-bar/side-bar.styles.cjs +801 -0
- package/components/side-bar/side-bar.styles.d.cts +6 -0
- package/components/side-bar/side-bar.styles.d.ts +6 -0
- package/components/side-bar/side-bar.styles.js +801 -0
- package/components/side-bar/side-bar.types.cjs +2 -0
- package/components/side-bar/side-bar.types.d.cts +105 -0
- package/components/side-bar/side-bar.types.d.ts +105 -0
- package/components/side-bar/side-bar.types.js +2 -0
- package/components/upload/index.cjs +83 -0
- package/components/upload/index.d.cts +4 -0
- package/components/upload/index.d.ts +4 -0
- package/components/upload/index.js +83 -0
- package/components/upload/upload.cjs +83 -0
- package/components/upload/upload.d.cts +28 -0
- package/components/upload/upload.d.ts +28 -0
- package/components/upload/upload.js +83 -0
- package/components/upload/upload.styles.cjs +65 -0
- package/components/upload/upload.styles.d.cts +6 -0
- package/components/upload/upload.styles.d.ts +6 -0
- package/components/upload/upload.styles.js +65 -0
- package/components/upload/upload.types.cjs +2 -0
- package/components/upload/upload.types.d.cts +16 -0
- package/components/upload/upload.types.d.ts +16 -0
- package/components/upload/upload.types.js +1 -0
- package/index.cjs +4677 -0
- package/index.d.cts +4397 -0
- package/index.d.ts +4397 -0
- package/index.js +4677 -0
- package/media-TFGJGBU2.js +2 -0
- package/package.json +35 -11
- package/react/components/asset/Asset.cjs +2 -0
- package/react/components/asset/Asset.jsx +2 -0
- package/react/components/side-bar/SideBar.cjs +2 -0
- package/react/components/side-bar/SideBar.jsx +2 -0
- package/react/components/upload/Upload.cjs +2 -0
- package/react/components/upload/Upload.jsx +2 -0
- package/services/audio.service.cjs +2 -2
- package/services/audio.service.d.cts +1 -0
- package/services/audio.service.d.ts +1 -0
- package/services/audio.service.js +2 -2
- package/services/conversation/conversation.service.cjs +2 -0
- package/services/conversation/conversation.service.d.cts +543 -0
- package/services/conversation/conversation.service.d.ts +543 -0
- package/services/conversation/conversation.service.js +2 -0
- package/services/conversation/conversation.types.cjs +2 -0
- package/services/conversation/conversation.types.d.cts +525 -0
- package/services/conversation/conversation.types.d.ts +525 -0
- package/services/conversation/conversation.types.js +2 -0
- package/services/conversation/index.cjs +2 -0
- package/services/conversation/index.d.cts +24 -0
- package/services/conversation/index.d.ts +24 -0
- package/services/conversation/index.js +2 -0
- package/services/conversation/mock/actor/agent.cjs +2 -0
- package/services/conversation/mock/actor/agent.d.cts +202 -0
- package/services/conversation/mock/actor/agent.d.ts +202 -0
- package/services/conversation/mock/actor/agent.js +2 -0
- package/services/conversation/mock/actor/index.cjs +2 -0
- package/services/conversation/mock/actor/index.d.cts +4 -0
- package/services/conversation/mock/actor/index.d.ts +4 -0
- package/services/conversation/mock/actor/index.js +2 -0
- package/services/conversation/mock/actor/strategies.cjs +2 -0
- package/services/conversation/mock/actor/strategies.d.cts +31 -0
- package/services/conversation/mock/actor/strategies.d.ts +31 -0
- package/services/conversation/mock/actor/strategies.js +2 -0
- package/services/conversation/mock/errors.cjs +2 -0
- package/services/conversation/mock/errors.d.cts +125 -0
- package/services/conversation/mock/errors.d.ts +125 -0
- package/services/conversation/mock/errors.js +2 -0
- package/services/conversation/mock/events.cjs +2 -0
- package/services/conversation/mock/events.d.cts +253 -0
- package/services/conversation/mock/events.d.ts +253 -0
- package/services/conversation/mock/events.js +2 -0
- package/services/conversation/mock/factory.cjs +2 -0
- package/services/conversation/mock/factory.d.cts +134 -0
- package/services/conversation/mock/factory.d.ts +134 -0
- package/services/conversation/mock/factory.js +2 -0
- package/services/conversation/mock/fixtures.cjs +2 -0
- package/services/conversation/mock/fixtures.d.cts +191 -0
- package/services/conversation/mock/fixtures.d.ts +191 -0
- package/services/conversation/mock/fixtures.js +2 -0
- package/services/conversation/mock/generators.cjs +2 -0
- package/services/conversation/mock/generators.d.cts +123 -0
- package/services/conversation/mock/generators.d.ts +123 -0
- package/services/conversation/mock/generators.js +2 -0
- package/services/conversation/mock/index.cjs +2 -0
- package/services/conversation/mock/index.d.cts +24 -0
- package/services/conversation/mock/index.d.ts +24 -0
- package/services/conversation/mock/index.js +2 -0
- package/services/conversation/mock/livekit/index.cjs +2 -0
- package/services/conversation/mock/livekit/index.d.cts +7 -0
- package/services/conversation/mock/livekit/index.d.ts +7 -0
- package/services/conversation/mock/livekit/index.js +2 -0
- package/services/conversation/mock/livekit/local-participant.cjs +2 -0
- package/services/conversation/mock/livekit/local-participant.d.cts +204 -0
- package/services/conversation/mock/livekit/local-participant.d.ts +204 -0
- package/services/conversation/mock/livekit/local-participant.js +2 -0
- package/services/conversation/mock/livekit/participant.cjs +2 -0
- package/services/conversation/mock/livekit/participant.d.cts +171 -0
- package/services/conversation/mock/livekit/participant.d.ts +171 -0
- package/services/conversation/mock/livekit/participant.js +2 -0
- package/services/conversation/mock/livekit/room.cjs +2 -0
- package/services/conversation/mock/livekit/room.d.cts +292 -0
- package/services/conversation/mock/livekit/room.d.ts +292 -0
- package/services/conversation/mock/livekit/room.js +2 -0
- package/services/conversation/mock/livekit/streams.cjs +2 -0
- package/services/conversation/mock/livekit/streams.d.cts +190 -0
- package/services/conversation/mock/livekit/streams.d.ts +190 -0
- package/services/conversation/mock/livekit/streams.js +2 -0
- package/services/conversation/mock/livekit/tracks.cjs +2 -0
- package/services/conversation/mock/livekit/tracks.d.cts +149 -0
- package/services/conversation/mock/livekit/tracks.d.ts +149 -0
- package/services/conversation/mock/livekit/tracks.js +2 -0
- package/services/conversation/mock/media.cjs +2 -0
- package/services/conversation/mock/media.d.cts +174 -0
- package/services/conversation/mock/media.d.ts +174 -0
- package/services/conversation/mock/media.js +2 -0
- package/services/conversation/mock/service.cjs +2 -0
- package/services/conversation/mock/service.d.cts +300 -0
- package/services/conversation/mock/service.d.ts +300 -0
- package/services/conversation/mock/service.js +2 -0
- package/services/conversation/mock/service.test.cjs +2 -0
- package/services/conversation/mock/service.test.d.cts +1 -0
- package/services/conversation/mock/service.test.d.ts +1 -0
- package/services/conversation/mock/service.test.js +2 -0
- package/services/conversation/mock/state.cjs +2 -0
- package/services/conversation/mock/state.d.cts +296 -0
- package/services/conversation/mock/state.d.ts +296 -0
- package/services/conversation/mock/state.js +2 -0
- package/services/conversation/mock/storybook.cjs +2 -0
- package/services/conversation/mock/storybook.d.cts +197 -0
- package/services/conversation/mock/storybook.d.ts +197 -0
- package/services/conversation/mock/storybook.js +2 -0
- package/services/conversation/mock/types.cjs +2 -0
- package/services/conversation/mock/types.d.cts +442 -0
- package/services/conversation/mock/types.d.ts +442 -0
- package/services/conversation/mock/types.js +1 -0
- package/services/faqs/faqs.service.cjs +2 -0
- package/services/faqs/faqs.service.d.cts +16 -0
- package/services/faqs/faqs.service.d.ts +16 -0
- package/services/faqs/faqs.service.js +2 -0
- package/services/faqs/faqs.types.cjs +2 -0
- package/services/faqs/faqs.types.d.cts +60 -0
- package/services/faqs/faqs.types.d.ts +60 -0
- package/services/faqs/faqs.types.js +1 -0
- package/services/faqs/index.cjs +2 -0
- package/services/faqs/index.d.cts +3 -0
- package/services/faqs/index.d.ts +3 -0
- package/services/faqs/index.js +2 -0
- package/services/file/file.service.cjs +2 -0
- package/services/file/file.service.d.cts +66 -0
- package/services/file/file.service.d.ts +66 -0
- package/services/file/file.service.js +2 -0
- package/services/file/file.types.cjs +2 -0
- package/services/file/file.types.d.cts +72 -0
- package/services/file/file.types.d.ts +72 -0
- package/services/file/file.types.js +1 -0
- package/services/file/index.cjs +2 -0
- package/services/file/index.d.cts +3 -0
- package/services/file/index.d.ts +3 -0
- package/services/file/index.js +2 -0
- package/services/firebase/firebase-api.cjs +2 -2
- package/services/firebase/firebase-api.d.cts +25 -9
- package/services/firebase/firebase-api.d.ts +25 -9
- package/services/firebase/firebase-api.js +2 -2
- package/services/multimedia/config.example.cjs +2 -0
- package/services/multimedia/config.example.d.cts +13 -0
- package/services/multimedia/config.example.d.ts +13 -0
- package/services/multimedia/config.example.js +2 -0
- package/services/multimedia/index.cjs +2 -0
- package/services/multimedia/index.d.cts +3 -0
- package/services/multimedia/index.d.ts +3 -0
- package/services/multimedia/index.js +2 -0
- package/services/multimedia/multimedia.service.cjs +2 -0
- package/services/multimedia/multimedia.service.d.cts +28 -0
- package/services/multimedia/multimedia.service.d.ts +28 -0
- package/services/multimedia/multimedia.service.js +2 -0
- package/services/multimedia/multimedia.types.cjs +2 -0
- package/services/multimedia/multimedia.types.d.cts +65 -0
- package/services/multimedia/multimedia.types.d.ts +65 -0
- package/services/multimedia/multimedia.types.js +1 -0
- package/services/product/index.cjs +2 -0
- package/services/product/index.d.cts +3 -0
- package/services/product/index.d.ts +3 -0
- package/services/product/index.js +2 -0
- package/services/product/product.service.cjs +2 -0
- package/services/product/product.service.d.cts +19 -0
- package/services/product/product.service.d.ts +19 -0
- package/services/product/product.service.js +2 -0
- package/services/product/product.types.cjs +2 -0
- package/services/product/product.types.d.cts +78 -0
- package/services/product/product.types.d.ts +78 -0
- package/services/product/product.types.js +1 -0
- package/services/request.provider.cjs +1 -1
- package/services/request.provider.d.cts +1 -0
- package/services/request.provider.d.ts +1 -0
- package/services/request.provider.js +1 -1
- package/services/session.service.cjs +2 -0
- package/services/session.service.d.cts +70 -0
- package/services/session.service.d.ts +70 -0
- package/services/session.service.js +2 -0
- package/services/upload/index.cjs +2 -0
- package/services/upload/index.d.cts +2 -0
- package/services/upload/index.d.ts +2 -0
- package/services/upload/index.js +2 -0
- package/services/upload/upload.service.cjs +2 -0
- package/services/upload/upload.service.d.cts +81 -0
- package/services/upload/upload.service.d.ts +81 -0
- package/services/upload/upload.service.js +2 -0
- package/themes/dark.cjs +16 -2
- package/themes/dark.d.cts +1 -0
- package/themes/dark.d.ts +1 -0
- package/themes/dark.js +15 -1
- package/themes/light.cjs +13 -2
- package/themes/light.d.cts +1 -0
- package/themes/light.d.ts +1 -0
- package/themes/light.js +12 -1
- package/types/globals.cjs +2 -0
- package/types/globals.d.cts +39 -0
- package/types/globals.d.ts +39 -0
- package/types/globals.js +1 -0
- package/types/tracking-options.cjs +2 -2
- package/types/tracking-options.d.cts +8 -6
- package/types/tracking-options.d.ts +8 -6
- package/types/tracking-options.js +1 -1
- package/utils/adopt-styles.cjs +2 -2
- package/utils/adopt-styles.d.cts +1 -0
- package/utils/adopt-styles.d.ts +1 -0
- package/utils/adopt-styles.js +2 -2
- package/utils/browser-preferences.cjs +2 -2
- package/utils/browser-preferences.d.cts +1 -0
- package/utils/browser-preferences.d.ts +1 -0
- package/utils/browser-preferences.js +2 -2
- package/utils/classify-media.cjs +1 -1
- package/utils/classify-media.d.cts +1 -0
- package/utils/classify-media.d.ts +1 -0
- package/utils/classify-media.js +1 -1
- package/utils/decorators.cjs +1 -1
- package/utils/decorators.d.cts +1 -0
- package/utils/decorators.d.ts +1 -0
- package/utils/decorators.js +1 -1
- package/utils/detected-lang.cjs +2 -2
- package/utils/detected-lang.d.cts +1 -0
- package/utils/detected-lang.d.ts +1 -0
- package/utils/detected-lang.js +2 -2
- package/utils/fullscreen.cjs +2 -2
- package/utils/fullscreen.d.cts +6 -5
- package/utils/fullscreen.d.ts +6 -5
- package/utils/fullscreen.js +2 -2
- package/utils/insert-script.cjs +1 -1
- package/utils/insert-script.d.cts +1 -0
- package/utils/insert-script.d.ts +1 -0
- package/utils/insert-script.js +1 -1
- package/utils/is-map-compatible.cjs +1 -1
- package/utils/is-map-compatible.d.cts +1 -0
- package/utils/is-map-compatible.d.ts +1 -0
- package/utils/is-map-compatible.js +1 -1
- package/utils/markdown.cjs +2 -2
- package/utils/markdown.d.cts +1 -0
- package/utils/markdown.d.ts +1 -0
- package/utils/markdown.js +2 -2
- package/utils/merge.cjs +2 -2
- package/utils/merge.d.cts +2 -1
- package/utils/merge.d.ts +2 -1
- package/utils/merge.js +2 -2
- package/utils/multiband-track-volume.cjs +2 -2
- package/utils/multiband-track-volume.d.cts +1 -0
- package/utils/multiband-track-volume.d.ts +1 -0
- package/utils/multiband-track-volume.js +2 -2
- package/utils/onlive-url-params.cjs +1 -1
- package/utils/onlive-url-params.d.cts +1 -0
- package/utils/onlive-url-params.d.ts +1 -0
- package/utils/onlive-url-params.js +1 -1
- package/utils/pretty-distance.cjs +2 -2
- package/utils/pretty-distance.d.cts +2 -1
- package/utils/pretty-distance.d.ts +2 -1
- package/utils/pretty-distance.js +2 -2
- package/utils/pretty-time.cjs +2 -0
- package/utils/pretty-time.d.cts +16 -0
- package/utils/pretty-time.d.ts +16 -0
- package/utils/pretty-time.js +2 -0
- package/utils/random-string.cjs +1 -1
- package/utils/random-string.d.cts +1 -0
- package/utils/random-string.d.ts +1 -0
- package/utils/random-string.js +1 -1
- package/utils/resource-type.cjs +1 -1
- package/utils/resource-type.d.cts +1 -0
- package/utils/resource-type.d.ts +1 -0
- package/utils/resource-type.js +1 -1
- package/utils/round-number.cjs +2 -0
- package/utils/round-number.d.cts +30 -0
- package/utils/round-number.d.ts +30 -0
- package/utils/round-number.js +2 -0
- package/utils/safe-html.cjs +2 -2
- package/utils/safe-html.d.cts +12 -4
- package/utils/safe-html.d.ts +12 -4
- package/utils/safe-html.js +2 -2
- package/utils/sanitize.cjs +2 -2
- package/utils/sanitize.d.cts +1 -0
- package/utils/sanitize.d.ts +1 -0
- package/utils/sanitize.js +2 -2
- package/utils/spread.cjs +2 -2
- package/utils/spread.d.cts +1 -0
- package/utils/spread.d.ts +1 -0
- package/utils/spread.js +2 -2
- package/utils/watch.cjs +1 -1
- package/utils/watch.d.cts +1 -0
- package/utils/watch.d.ts +1 -0
- package/utils/watch.js +1 -1
- package/services/firebase/firebase.service.cjs +0 -2
- package/services/firebase/firebase.service.d.cts +0 -40
- package/services/firebase/firebase.service.d.ts +0 -40
- package/services/firebase/firebase.service.js +0 -2
- package/services/livekit.service.cjs +0 -2
- package/services/livekit.service.d.cts +0 -219
- package/services/livekit.service.d.ts +0 -219
- package/services/livekit.service.js +0 -2
- package/types/window-context.cjs +0 -2
- package/types/window-context.d.cts +0 -8
- package/types/window-context.d.ts +0 -8
- package/types/window-context.js +0 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
import { MockLocalParticipant } from './local-participant.js';
|
|
3
|
+
import { MockParticipant, MockParticipantKind } from './participant.js';
|
|
4
|
+
import { MockTextStreamReader } from './streams.js';
|
|
5
|
+
import { MockTrack } from './tracks.js';
|
|
6
|
+
import '../types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @file Mock LiveKit Room implementation.
|
|
10
|
+
*
|
|
11
|
+
* @description Provides a mock implementation of LiveKit's Room class that simulates
|
|
12
|
+
* room connections, events, and participant management without real infrastructure.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Room connection state.
|
|
17
|
+
*/
|
|
18
|
+
type MockConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
|
|
19
|
+
/**
|
|
20
|
+
* RPC method handler type.
|
|
21
|
+
*/
|
|
22
|
+
type MockRpcHandler = (data: {
|
|
23
|
+
callerIdentity: string;
|
|
24
|
+
payload: string;
|
|
25
|
+
responseTimeout: number;
|
|
26
|
+
}) => Promise<string> | string;
|
|
27
|
+
/**
|
|
28
|
+
* Text stream handler type.
|
|
29
|
+
*/
|
|
30
|
+
type MockTextStreamHandler = (reader: MockTextStreamReader, participant: {
|
|
31
|
+
identity: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Event handler type.
|
|
35
|
+
*/
|
|
36
|
+
type MockEventHandler = (...args: unknown[]) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Options for simulating participant join.
|
|
39
|
+
*/
|
|
40
|
+
interface SimulateParticipantOptions {
|
|
41
|
+
/** Participant display name */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** Participant kind */
|
|
44
|
+
kind?: MockParticipantKind;
|
|
45
|
+
/** Custom attributes */
|
|
46
|
+
attributes?: Record<string, string>;
|
|
47
|
+
/** Whether to add camera track */
|
|
48
|
+
withCamera?: boolean;
|
|
49
|
+
/** Whether to add microphone track */
|
|
50
|
+
withMicrophone?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mock Room class that mimics LiveKit's Room behavior.
|
|
54
|
+
*
|
|
55
|
+
* @description Simulates a LiveKit room with connection management, participant tracking,
|
|
56
|
+
* event emission, and RPC/stream handling. Core component for testing real-time features.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const room = new MockRoom(mockService);
|
|
61
|
+
* await room.connect("wss://mock.local", "token");
|
|
62
|
+
*
|
|
63
|
+
* room.on("ParticipantConnected", (participant) => {
|
|
64
|
+
* console.log(`${participant.name} joined`);
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* await room.simulateAgentJoin("agent_1", "AI Assistant");
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare class MockRoom {
|
|
71
|
+
/** Room ID */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Server-assigned SID */
|
|
74
|
+
sid: string;
|
|
75
|
+
/** Room group ID */
|
|
76
|
+
groupId: string;
|
|
77
|
+
/** Room name */
|
|
78
|
+
name: string;
|
|
79
|
+
/** Creation timestamp */
|
|
80
|
+
createdAt: string;
|
|
81
|
+
/** Connection timestamp */
|
|
82
|
+
connectedAt: string;
|
|
83
|
+
/** Room metadata */
|
|
84
|
+
metadata?: string;
|
|
85
|
+
/** Local participant reference */
|
|
86
|
+
localParticipant: MockLocalParticipant;
|
|
87
|
+
/** Remote participants by identity */
|
|
88
|
+
remoteParticipants: Map<string, MockParticipant>;
|
|
89
|
+
/** Connection state */
|
|
90
|
+
private _state;
|
|
91
|
+
/** Event handlers by event name */
|
|
92
|
+
private eventHandlers;
|
|
93
|
+
/** Text stream handlers by topic */
|
|
94
|
+
private textStreamHandlers;
|
|
95
|
+
/** RPC method handlers */
|
|
96
|
+
private rpcHandlers;
|
|
97
|
+
/** Reference to parent service for simulation */
|
|
98
|
+
private mockService;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new MockRoom.
|
|
101
|
+
*
|
|
102
|
+
* @param mockService - Parent mock service for coordination.
|
|
103
|
+
*/
|
|
104
|
+
constructor(mockService: {
|
|
105
|
+
simulateLatency(): Promise<void>;
|
|
106
|
+
getState(): any;
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Gets the current connection state.
|
|
110
|
+
*/
|
|
111
|
+
get state(): MockConnectionState;
|
|
112
|
+
/**
|
|
113
|
+
* Sets the connection state.
|
|
114
|
+
*/
|
|
115
|
+
set state(value: MockConnectionState);
|
|
116
|
+
/**
|
|
117
|
+
* Gets the number of participants (including local).
|
|
118
|
+
*/
|
|
119
|
+
get numParticipants(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Gets whether the room is connected.
|
|
122
|
+
*/
|
|
123
|
+
get isConnected(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Connects to the room.
|
|
126
|
+
*
|
|
127
|
+
* @param wsURL - WebSocket URL.
|
|
128
|
+
* @param token - Authentication token.
|
|
129
|
+
*/
|
|
130
|
+
connect(_wsURL: string, _token: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Disconnects from the room.
|
|
133
|
+
*/
|
|
134
|
+
disconnect(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Simulates reconnection.
|
|
137
|
+
*/
|
|
138
|
+
reconnect(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Registers an event handler.
|
|
141
|
+
*
|
|
142
|
+
* @param event - Event name.
|
|
143
|
+
* @param handler - Event handler function.
|
|
144
|
+
*/
|
|
145
|
+
on(event: string, handler: MockEventHandler): this;
|
|
146
|
+
/**
|
|
147
|
+
* Registers a one-time event handler.
|
|
148
|
+
*
|
|
149
|
+
* @param event - Event name.
|
|
150
|
+
* @param handler - Event handler function.
|
|
151
|
+
*/
|
|
152
|
+
once(event: string, handler: MockEventHandler): this;
|
|
153
|
+
/**
|
|
154
|
+
* Removes an event handler.
|
|
155
|
+
*
|
|
156
|
+
* @param event - Event name.
|
|
157
|
+
* @param handler - Handler to remove.
|
|
158
|
+
*/
|
|
159
|
+
off(event: string, handler: MockEventHandler): this;
|
|
160
|
+
/**
|
|
161
|
+
* Removes all event handlers.
|
|
162
|
+
*/
|
|
163
|
+
removeAllListeners(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Emits an event to all registered handlers.
|
|
166
|
+
*
|
|
167
|
+
* @param event - Event name.
|
|
168
|
+
* @param args - Event arguments.
|
|
169
|
+
*/
|
|
170
|
+
emit(event: string, ...args: unknown[]): void;
|
|
171
|
+
/**
|
|
172
|
+
* Registers an RPC method handler.
|
|
173
|
+
*
|
|
174
|
+
* @param method - Method name.
|
|
175
|
+
* @param handler - Method handler.
|
|
176
|
+
*/
|
|
177
|
+
registerRpcMethod(method: string, handler: MockRpcHandler): void;
|
|
178
|
+
/**
|
|
179
|
+
* Unregisters an RPC method handler.
|
|
180
|
+
*
|
|
181
|
+
* @param method - Method name.
|
|
182
|
+
*/
|
|
183
|
+
unregisterRpcMethod(method: string): void;
|
|
184
|
+
/**
|
|
185
|
+
* Calls an RPC method (simulates receiving a call).
|
|
186
|
+
*
|
|
187
|
+
* @param method - Method name.
|
|
188
|
+
* @param callerIdentity - Caller identity.
|
|
189
|
+
* @param payload - Method payload.
|
|
190
|
+
* @param responseTimeout - Timeout in ms.
|
|
191
|
+
*/
|
|
192
|
+
callRpc(method: string, callerIdentity: string, payload: string, responseTimeout?: number): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Registers a text stream handler.
|
|
195
|
+
*
|
|
196
|
+
* @param topic - Stream topic.
|
|
197
|
+
* @param handler - Stream handler.
|
|
198
|
+
*/
|
|
199
|
+
registerTextStreamHandler(topic: string, handler: MockTextStreamHandler): void;
|
|
200
|
+
/**
|
|
201
|
+
* Unregisters a text stream handler.
|
|
202
|
+
*
|
|
203
|
+
* @param topic - Stream topic.
|
|
204
|
+
*/
|
|
205
|
+
unregisterTextStreamHandler(topic: string): void;
|
|
206
|
+
/**
|
|
207
|
+
* Simulates receiving a text stream.
|
|
208
|
+
*
|
|
209
|
+
* @param topic - Stream topic.
|
|
210
|
+
* @param reader - Text stream reader.
|
|
211
|
+
*/
|
|
212
|
+
simulateTextStream(topic: string, reader: MockTextStreamReader): void;
|
|
213
|
+
/**
|
|
214
|
+
* Gets a participant by identity.
|
|
215
|
+
*
|
|
216
|
+
* @param identity - Participant identity.
|
|
217
|
+
*/
|
|
218
|
+
getParticipantByIdentity(identity: string): MockParticipant | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Gets a participant by SID.
|
|
221
|
+
*
|
|
222
|
+
* @param sid - Participant SID.
|
|
223
|
+
*/
|
|
224
|
+
getParticipantBySid(sid: string): MockParticipant | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Simulates a remote participant joining.
|
|
227
|
+
*
|
|
228
|
+
* @param identity - Participant identity.
|
|
229
|
+
* @param options - Join options.
|
|
230
|
+
*/
|
|
231
|
+
simulateParticipantJoin(identity: string, options?: SimulateParticipantOptions): Promise<MockParticipant>;
|
|
232
|
+
/**
|
|
233
|
+
* Simulates a remote participant leaving.
|
|
234
|
+
*
|
|
235
|
+
* @param identity - Participant identity.
|
|
236
|
+
*/
|
|
237
|
+
simulateParticipantLeave(identity: string): void;
|
|
238
|
+
/**
|
|
239
|
+
* Simulates a remote track being published.
|
|
240
|
+
*
|
|
241
|
+
* @param participantIdentity - Participant identity.
|
|
242
|
+
* @param kind - Track kind.
|
|
243
|
+
* @param source - Track source.
|
|
244
|
+
*/
|
|
245
|
+
simulateRemoteTrack(participantIdentity: string, kind: "audio" | "video", source: string): Promise<MockTrack | undefined>;
|
|
246
|
+
/**
|
|
247
|
+
* Simulates a track being unpublished.
|
|
248
|
+
*
|
|
249
|
+
* @param participantIdentity - Participant identity.
|
|
250
|
+
* @param source - Track source.
|
|
251
|
+
*/
|
|
252
|
+
simulateTrackUnpublished(participantIdentity: string, source: string): void;
|
|
253
|
+
/**
|
|
254
|
+
* Simulates an agent joining with camera and microphone.
|
|
255
|
+
*
|
|
256
|
+
* @param identity - Agent identity.
|
|
257
|
+
* @param name - Agent display name.
|
|
258
|
+
*/
|
|
259
|
+
simulateAgentJoin(identity: string, name?: string): Promise<MockParticipant>;
|
|
260
|
+
/**
|
|
261
|
+
* Simulates a participant's attribute change.
|
|
262
|
+
*
|
|
263
|
+
* @param identity - Participant identity.
|
|
264
|
+
* @param attributes - New attributes.
|
|
265
|
+
*/
|
|
266
|
+
simulateAttributeChange(identity: string, attributes: Record<string, string>): void;
|
|
267
|
+
/**
|
|
268
|
+
* Simulates a track mute/unmute.
|
|
269
|
+
*
|
|
270
|
+
* @param participantIdentity - Participant identity.
|
|
271
|
+
* @param source - Track source.
|
|
272
|
+
* @param muted - Whether muted.
|
|
273
|
+
*/
|
|
274
|
+
simulateTrackMuted(participantIdentity: string, source: string, muted: boolean): void;
|
|
275
|
+
/**
|
|
276
|
+
* Simulates an active speaker change.
|
|
277
|
+
*
|
|
278
|
+
* @param speakerIdentities - Identities of active speakers.
|
|
279
|
+
*/
|
|
280
|
+
simulateActiveSpeakersChanged(speakerIdentities: string[]): void;
|
|
281
|
+
/**
|
|
282
|
+
* Simulates data received event.
|
|
283
|
+
*
|
|
284
|
+
* @param data - Binary data.
|
|
285
|
+
* @param participantIdentity - Sender identity.
|
|
286
|
+
* @param kind - Data kind.
|
|
287
|
+
* @param topic - Data topic.
|
|
288
|
+
*/
|
|
289
|
+
simulateDataReceived(data: Uint8Array, participantIdentity: string, kind?: string, topic?: string): void;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export { type MockConnectionState, type MockEventHandler, MockRoom, type MockRpcHandler, type MockTextStreamHandler, type SimulateParticipantOptions };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
var N=Object.defineProperty;var O=(s,t)=>()=>(s&&(t=s(s=0)),t);var U=(s,t)=>{for(var e in t)N(s,e,{get:t[e],enumerable:!0})};var M={};U(M,{SYNTHETIC_MEDIA_PRESETS:()=>$,createSyntheticAudioTrack:()=>H,createSyntheticMedia:()=>I,createSyntheticMediaFromPreset:()=>j,createSyntheticVideoTrack:()=>R});function R(s={}){let{width:t=640,height:e=480,fps:i=30,backgroundColor:n="#1a1a2e",foregroundColor:o="#4361ee",label:c="Mock Video",animation:d="wave"}=s,r=document.createElement("canvas");r.width=t,r.height=e;let a=r.getContext("2d"),u,f=Date.now(),y={wave:m=>{a.fillStyle=n,a.fillRect(0,0,t,e),a.strokeStyle=o,a.lineWidth=3,a.beginPath();for(let l=0;l<t;l++){let h=e/2+Math.sin(l/t*4*Math.PI+m*.002)*(e/4);l===0?a.moveTo(l,h):a.lineTo(l,h)}a.stroke()},pulse:m=>{a.fillStyle=n,a.fillRect(0,0,t,e);let l=Math.sin(m*.003)*.3+.7,h=Math.min(t,e)*.3*l;a.beginPath(),a.arc(t/2,e/2,h,0,Math.PI*2),a.fillStyle=o,a.fill()},bars:m=>{a.fillStyle=n,a.fillRect(0,0,t,e);let l=20,h=t/l,b=e*.7;a.fillStyle=o;for(let v=0;v<l;v++){let C=Math.abs(Math.sin(v/l*Math.PI*2+m*.004))*b,L=v*h,V=e-C;a.fillRect(L+2,V,h-4,C)}},avatar:m=>{a.fillStyle=n,a.fillRect(0,0,t,e);let l=t/2,h=e/2-20,b=Math.min(t,e)*.15;a.beginPath(),a.arc(l,h,b,0,Math.PI*2),a.fillStyle=o,a.fill(),a.beginPath(),a.ellipse(l,h+b*2.2,b*1.5,b,0,Math.PI,0),a.fill(),Math.sin(m*.01)>0&&(a.beginPath(),a.arc(l,h+b*3,5+Math.sin(m*.02)*3,0,Math.PI*2),a.fillStyle="#22c55e",a.fill())},none:()=>{a.fillStyle=n,a.fillRect(0,0,t,e)}},_=()=>{a.fillStyle="rgba(255, 255, 255, 0.8)",a.font=`${Math.floor(e*.04)}px system-ui, sans-serif`,a.textAlign="center",a.fillText(c,t/2,e-20)},P=()=>{let m=Date.now()-f;y[d](m),_(),u=requestAnimationFrame(P)};P();let E=r.captureStream(i),x=E.getVideoTracks()[0];return{track:x,stream:E,cleanup:()=>{cancelAnimationFrame(u),x.stop()}}}function H(s={}){let{frequency:t=440,volume:e=.1,waveType:i="sine",addVariation:n=!0,enabled:o=!1}=s,c=new AudioContext,d=c.createMediaStreamDestination(),r=c.createOscillator();r.type=i,r.frequency.value=t;let a=c.createGain();a.gain.value=o?e:0;let u=null,f=null;n&&(u=c.createOscillator(),u.frequency.value=.5,f=c.createGain(),f.gain.value=10,u.connect(f),f.connect(r.frequency),u.start()),r.connect(a),a.connect(d),r.start();let y=d.stream,_=y.getAudioTracks()[0];return{track:_,stream:y,setVolume:P=>{a.gain.value=Math.max(0,Math.min(1,P))},setEnabled:P=>{a.gain.value=P?e:0},cleanup:()=>{r.stop(),u?.stop(),c.close(),_.stop()}}}function I(s,t){let e=R(s),i=H(t),n=new MediaStream([e.track,i.track]);return{videoTrack:e.track,audioTrack:i.track,combinedStream:n,setAudioVolume:i.setVolume,setAudioEnabled:i.setEnabled,cleanup:()=>{e.cleanup(),i.cleanup()}}}function j(s){let t=$[s];return I(t.video,t.audio)}var $,S=O(()=>{"use strict";$={localCamera:{video:{width:640,height:480,animation:"avatar",label:"You",foregroundColor:"#4361ee"},audio:{enabled:!1}},agentCamera:{video:{width:640,height:480,animation:"avatar",label:"AI Agent",foregroundColor:"#22c55e",backgroundColor:"#0f172a"},audio:{enabled:!1,frequency:300}},screenShare:{video:{width:1920,height:1080,animation:"bars",label:"Screen Share",backgroundColor:"#0a0a0a",foregroundColor:"#f59e0b"},audio:{enabled:!1}},voiceOnly:{video:{width:320,height:240,animation:"wave",label:"Voice Call"},audio:{enabled:!1,volume:.05}}}});var A=0;function k(s){return A++,`mock_${s}_${A}_${Date.now().toString(36)}`}var g=class{constructor(t,e,i,n){this.muted=!1;this.enabled=!0;this.attachedElements=new Set;this.kind=t,this.source=e,this.sid=k("TR"),this.mediaStreamTrack=i,this.mediaCleanup=n}get mediaTrack(){return this.mediaStreamTrack}attach(t){let e=t||document.createElement(this.kind==="video"?"video":"audio");if(this.mediaStreamTrack){let i=new MediaStream([this.mediaStreamTrack]);e.srcObject=i,e.autoplay=!0,this.kind==="video"&&(e.playsInline=!0,e.muted=!0)}return this.attachedElements.add(e),e}detach(t){if(t)return t.srcObject=null,this.attachedElements.delete(t),[t];let e=Array.from(this.attachedElements);for(let i of e)i.srcObject=null;return this.attachedElements.clear(),e}stop(){this.detach(),this.mediaCleanup&&this.mediaCleanup(),this.mediaStreamTrack&&this.mediaStreamTrack.stop(),this.enabled=!1}setMuted(t){this.muted=t,this.mediaStreamTrack&&(this.mediaStreamTrack.enabled=!t)}setEnabled(t){this.enabled=t,this.mediaStreamTrack&&(this.mediaStreamTrack.enabled=t)}},p=class{constructor(t,e){this.subscribed=!0;this.isEnabled=!0;this.track=t,this.trackSid=t.sid,this.trackName=e||`${t.kind}_${t.source}`,this.source=t.source,this.kind=t.kind}get isMuted(){return this.track?.muted??!1}get isSubscribed(){return this.subscribed&&this.track!==null}setSubscribed(t){this.subscribed=t}setEnabled(t){this.isEnabled=t,this.track&&(this.track.enabled=t)}setMuted(t){this.track&&this.track.setMuted(t)}};var w=class{constructor(t){this.identity="";this.sid="";this.name="";this.attributes={};this.kind="standard";this.trackPublications=new Map;this.audioTrackPublications=new Map;this.videoTrackPublications=new Map;this._cameraEnabled=!1;this._microphoneEnabled=!1;this._screenShareEnabled=!1;this.room=t,this.sid=k("PA"),this.joinedAt=new Date}get isCameraEnabled(){return this._cameraEnabled}get isMicrophoneEnabled(){return this._microphoneEnabled}get isScreenShareEnabled(){return this._screenShareEnabled}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(t){let i={camera:"camera",Camera:"camera",microphone:"microphone",Microphone:"microphone",screen_share:"screen_share",ScreenShare:"screen_share",screen_share_audio:"screen_share_audio",ScreenShareAudio:"screen_share_audio"}[t]||t;return this.trackPublications.get(i)}getTrackPublicationBySid(t){for(let e of this.trackPublications.values())if(e.trackSid===t)return e}setAttributes(t){this.attributes={...this.attributes,...t}}async setCameraEnabled(t,e){if(this._cameraEnabled=t,t){let{createSyntheticVideoTrack:n}=await Promise.resolve().then(()=>(S(),M)),{track:o,cleanup:c}=n({animation:"avatar",label:this.name||"Local Camera"}),d=new g("video","camera",o,c),r=new p(d,e?.name);return this.trackPublications.set("camera",r),this.videoTrackPublications.set(d.sid,r),this.room.emit("localTrackPublished",r,this),r}let i=this.trackPublications.get("camera");i&&(i.track?.stop(),this.trackPublications.delete("camera"),this.videoTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async setMicrophoneEnabled(t,e){if(this._microphoneEnabled=t,t){let{createSyntheticAudioTrack:n}=await Promise.resolve().then(()=>(S(),M)),{track:o,cleanup:c}=n({enabled:!1}),d=new g("audio","microphone",o,c),r=new p(d,e?.name);return this.trackPublications.set("microphone",r),this.audioTrackPublications.set(d.sid,r),this.room.emit("localTrackPublished",r,this),r}let i=this.trackPublications.get("microphone");i&&(i.track?.stop(),this.trackPublications.delete("microphone"),this.audioTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async setScreenShareEnabled(t,e){if(this._screenShareEnabled=t,t){let{createSyntheticVideoTrack:n}=await Promise.resolve().then(()=>(S(),M)),{track:o,cleanup:c}=n({animation:"bars",label:"Screen Share",width:1920,height:1080}),d=new g("video","screen_share",o,c),r=new p(d,e?.name||"screen");return this.trackPublications.set("screen_share",r),this.videoTrackPublications.set(d.sid,r),this.room.emit("localTrackPublished",r,this),r}let i=this.trackPublications.get("screen_share");i&&(i.track?.stop(),this.trackPublications.delete("screen_share"),this.videoTrackPublications.delete(i.trackSid),this.room.emit("localTrackUnpublished",i,this))}async publishTrack(t,e){let i=new p(t,e?.name),n=e?.source||t.source;return this.trackPublications.set(n,i),t.kind==="audio"?this.audioTrackPublications.set(t.sid,i):t.kind==="video"&&this.videoTrackPublications.set(t.sid,i),this.room.emit("localTrackPublished",i,this),i}async unpublishTrack(t){t.stop();for(let[e,i]of this.trackPublications)if(i.track===t){this.trackPublications.delete(e),t.kind==="audio"?this.audioTrackPublications.delete(t.sid):t.kind==="video"&&this.videoTrackPublications.delete(t.sid),this.room.emit("localTrackUnpublished",i,this);break}}async sendText(t,e){return{id:k("msg")}}async publishData(t,e){}async setMetadata(t){this.attributes.metadata=t}async setName(t){this.name=t}cleanup(){for(let t of this.trackPublications.values())t.track?.stop();this.trackPublications.clear(),this.audioTrackPublications.clear(),this.videoTrackPublications.clear(),this._cameraEnabled=!1,this._microphoneEnabled=!1,this._screenShareEnabled=!1}};function G(s){switch(s){case"standard":return 0;case"ingress":return 1;case"egress":return 2;case"sip":return 3;case"agent":return 4;default:return 0}}var T=class{constructor(t,e,i={},n="standard"){this.connectionQuality="excellent";this.isSpeaking=!1;this.audioLevel=0;this.trackPublications=new Map;this.identity=t,this.sid=k("PA"),this.name=e,this.attributes=i,this._kindString=n,this.kind=G(n),this.joinedAt=new Date}get isAgent(){return this.kind===4||this.attributes["lk.agent.name"]!==void 0}get kindString(){return this._kindString}get isCameraEnabled(){let t=this.getTrackPublication("camera");return!!(t?.track&&!t.isMuted)}get isMicrophoneEnabled(){let t=this.getTrackPublication("microphone");return!!(t?.track&&!t.isMuted)}getTrackPublication(t){for(let e of this.trackPublications.values())if(e.source===t)return e}getTrackPublicationBySid(t){return this.trackPublications.get(t)}getTrackPublications(){return Array.from(this.trackPublications.values())}getAudioTracks(){return this.getTrackPublications().filter(t=>t.kind==="audio")}getVideoTracks(){return this.getTrackPublications().filter(t=>t.kind==="video")}addTrackPublication(t){this.trackPublications.set(t.trackSid,t)}removeTrackPublication(t){let e=this.trackPublications.get(t);return e&&(this.trackPublications.delete(t),e.track?.stop()),e}setAttributes(t){this.attributes={...this.attributes,...t}}getAttribute(t){return this.attributes[t]}startSpeaking(t=.5){this.isSpeaking=!0,this.audioLevel=t}stopSpeaking(){this.isSpeaking=!1,this.audioLevel=0}setConnectionQuality(t){this.connectionQuality=t}cleanup(){for(let t of this.trackPublications.values())t.track?.stop();this.trackPublications.clear()}};var D=class{constructor(t){this.remoteParticipants=new Map;this._state="disconnected";this.eventHandlers=new Map;this.textStreamHandlers=new Map;this.rpcHandlers=new Map;this.mockService=t,this.localParticipant=new w(this),this.sid=k("RM")}get state(){return this._state}set state(t){let e=this._state;this._state=t,e!==t&&this.emit("connectionStateChanged",t,e)}get numParticipants(){return this.remoteParticipants.size+1}get isConnected(){return this._state==="connected"}async connect(t,e){this._state="connecting",this.emit("connectionStateChanged","connecting","disconnected"),await this.mockService.simulateLatency(),this._state="connected",this.connectedAt=new Date().toISOString(),this.emit("connectionStateChanged","connected","connecting"),this.emit("connected")}async disconnect(){for(let e of this.remoteParticipants.values())e.cleanup();this.remoteParticipants.clear(),this.localParticipant.cleanup();let t=this._state;this._state="disconnected",this.emit("connectionStateChanged","disconnected",t),this.emit("disconnected"),this.eventHandlers.clear()}async reconnect(){this._state="reconnecting",this.emit("connectionStateChanged","reconnecting","connected"),await this.mockService.simulateLatency(),this._state="connected",this.emit("connectionStateChanged","connected","reconnecting"),this.emit("reconnected")}on(t,e){return this.eventHandlers.has(t)||this.eventHandlers.set(t,new Set),this.eventHandlers.get(t).add(e),this}once(t,e){let i=(...n)=>{this.off(t,i),e(...n)};return this.on(t,i)}off(t,e){return this.eventHandlers.get(t)?.delete(e),this}removeAllListeners(){this.eventHandlers.clear()}emit(t,...e){let i=this.eventHandlers.get(t);if(i)for(let n of i)try{n(...e)}catch(o){console.error(`Error in mock room event handler for ${t}:`,o)}}registerRpcMethod(t,e){this.rpcHandlers.set(t,e)}unregisterRpcMethod(t){this.rpcHandlers.delete(t)}async callRpc(t,e,i,n=1e4){let o=this.rpcHandlers.get(t);if(!o)throw new Error(`RPC method not found: ${t}`);return o({callerIdentity:e,payload:i,responseTimeout:n})}registerTextStreamHandler(t,e){this.textStreamHandlers.set(t,e)}unregisterTextStreamHandler(t){this.textStreamHandlers.delete(t)}simulateTextStream(t,e){let i=this.textStreamHandlers.get(t);i&&i(e,{identity:e.participantIdentity})}getParticipantByIdentity(t){return t===this.localParticipant.identity?new T(this.localParticipant.identity,this.localParticipant.name,this.localParticipant.attributes):this.remoteParticipants.get(t)}getParticipantBySid(t){if(t===this.localParticipant.sid)return new T(this.localParticipant.identity,this.localParticipant.name,this.localParticipant.attributes);for(let e of this.remoteParticipants.values())if(e.sid===t)return e}async simulateParticipantJoin(t,e){let i=new T(t,e?.name,e?.attributes||{},e?.kind||"standard");return this.remoteParticipants.set(t,i),this.emit("participantConnected",i),e?.withCamera&&await this.simulateRemoteTrack(t,"video","camera"),e?.withMicrophone&&await this.simulateRemoteTrack(t,"audio","microphone"),i}simulateParticipantLeave(t){let e=this.remoteParticipants.get(t);if(e){for(let i of e.getTrackPublications())i.track?.stop(),this.emit("trackUnsubscribed",i.track,i,e);this.remoteParticipants.delete(t),this.emit("participantDisconnected",e)}}async simulateRemoteTrack(t,e,i){let n=this.remoteParticipants.get(t);if(!n)return;let o,c;if(e==="video"){let{createSyntheticVideoTrack:a}=await Promise.resolve().then(()=>(S(),M)),u=a({animation:n.isAgent?"avatar":"pulse",label:n.name||t,foregroundColor:n.isAgent?"#22c55e":"#4361ee"});o=u.track,c=u.cleanup}else if(e==="audio"){let{createSyntheticAudioTrack:a}=await Promise.resolve().then(()=>(S(),M)),u=a({enabled:!1});o=u.track,c=u.cleanup}let d=new g(e,i,o,c),r=new p(d);return n.addTrackPublication(r),this.emit("trackSubscribed",d,r,n),this.emit("trackPublished",r,n),d}simulateTrackUnpublished(t,e){let i=this.remoteParticipants.get(t);if(!i)return;let n=i.getTrackPublication(e);n&&(i.removeTrackPublication(n.trackSid),this.emit("trackUnpublished",n,i),this.emit("trackUnsubscribed",n.track,n,i))}async simulateAgentJoin(t,e="AI Agent"){return this.simulateParticipantJoin(t,{name:e,kind:"agent",withCamera:!0,withMicrophone:!0,attributes:{"lk.agent.name":e,"lk.agent.state":"active"}})}simulateAttributeChange(t,e){let i=this.remoteParticipants.get(t);if(i){let n={...i.attributes};i.setAttributes(e),this.emit("participantAttributesChanged",e,n,i)}}simulateTrackMuted(t,e,i){let n=this.remoteParticipants.get(t);if(!n)return;let o=n.getTrackPublication(e);o?.track&&(o.track.setMuted(i),this.emit(i?"trackMuted":"trackUnmuted",o,n))}simulateActiveSpeakersChanged(t){let e=[];for(let i of t){let n=this.remoteParticipants.get(i);n&&(n.startSpeaking(),e.push(n))}this.emit("activeSpeakersChanged",e)}simulateDataReceived(t,e,i,n){let o=this.remoteParticipants.get(e);this.emit("dataReceived",t,o,i,n)}};export{D as MockRoom};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
"use strict";var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of m(t))!k.call(e,i)&&i!==n&&c(e,i,{get:()=>t[i],enumerable:!(r=p(t,i))||r.enumerable});return e};var y=e=>f(c({},"__esModule",{value:!0}),e);var I={};_(I,{MockByteStreamReader:()=>u,MockTextStreamReader:()=>o,MockTextStreamWriter:()=>g,createTextStream:()=>x});module.exports=y(I);var l=0;function a(e){return l++,`mock_${e}_${l}_${Date.now().toString(36)}`}var o=class{constructor(t,n,r,i,s){this.index=0;this._complete=!1;this.info={id:t,attributes:i,topic:s,timestamp:Date.now()},this.participantIdentity=n,this.topic=s,this.chunks=Array.isArray(r)?r:[r],this.info.totalSize=this.chunks.reduce((d,h)=>d+h.length,0)}get isComplete(){return this._complete}async*[Symbol.asyncIterator](){for(let t of this.chunks)yield t;this._complete=!0}async read(){return this.index>=this.chunks.length?(this._complete=!0,null):this.chunks[this.index++]}async readAll(){let t=this.chunks.slice(this.index).join("");return this.index=this.chunks.length,this._complete=!0,t}cancel(){this._complete=!0}},g=class{constructor(t,n){this.chunks=[];this._closed=!1;this.id=a("stream"),this._topic=t,this._destinationIdentities=n}get isClosed(){return this._closed}get topic(){return this._topic}get destinationIdentities(){return this._destinationIdentities}get content(){return this.chunks.join("")}onWrite(t){this.onWriteCallback=t}async write(t){if(this._closed)throw new Error("Stream is closed");this.chunks.push(t),this.onWriteCallback?.(t)}async close(){this._closed=!0}},u=class{constructor(t,n,r){this._index=0;this.info={id:t,timestamp:Date.now()},this.participantIdentity=n,this.chunks=Array.isArray(r)?r:[r]}get index(){return this._index}async*[Symbol.asyncIterator](){for(let t of this.chunks)yield t}async readAll(){let t=this.chunks.reduce((i,s)=>i+s.length,0),n=new Uint8Array(t),r=0;for(let i of this.chunks)n.set(i,r),r+=i.length;return n}};function x(e,t,n){return new o(n?.id||a("stream"),e,t,n?.attributes,n?.topic)}0&&(module.exports={MockByteStreamReader,MockTextStreamReader,MockTextStreamWriter,createTextStream});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*! @onlive.ai/common-121 v0.2.179 | © 2026 Onlive.ai */
|
|
2
|
+
/**
|
|
3
|
+
* @file Mock LiveKit data streams.
|
|
4
|
+
*
|
|
5
|
+
* @description Provides mock implementations for LiveKit's text and data streaming
|
|
6
|
+
* capabilities used for real-time message delivery.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Text stream info.
|
|
10
|
+
*/
|
|
11
|
+
interface MockTextStreamInfo {
|
|
12
|
+
/** Stream ID */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Stream topic */
|
|
15
|
+
topic?: string;
|
|
16
|
+
/** Stream attributes */
|
|
17
|
+
attributes?: Record<string, string>;
|
|
18
|
+
/** Timestamp */
|
|
19
|
+
timestamp?: number;
|
|
20
|
+
/** Total size if known */
|
|
21
|
+
totalSize?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mock text stream reader for simulating message streams.
|
|
25
|
+
*
|
|
26
|
+
* @description Simulates LiveKit's TextStreamReader for receiving streamed text content.
|
|
27
|
+
* Supports async iteration for consuming stream chunks.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const reader = new MockTextStreamReader("msg_1", "agent", "Hello, world!");
|
|
32
|
+
* for await (const chunk of reader) {
|
|
33
|
+
* console.log(chunk); // "Hello, world!"
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare class MockTextStreamReader {
|
|
38
|
+
/** Stream info */
|
|
39
|
+
info: MockTextStreamInfo;
|
|
40
|
+
/** Sender participant identity */
|
|
41
|
+
participantIdentity: string;
|
|
42
|
+
/** Stream topic */
|
|
43
|
+
topic?: string;
|
|
44
|
+
/** Content chunks */
|
|
45
|
+
private chunks;
|
|
46
|
+
/** Current read index */
|
|
47
|
+
private index;
|
|
48
|
+
/** Whether stream is complete */
|
|
49
|
+
private _complete;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new MockTextStreamReader.
|
|
52
|
+
*
|
|
53
|
+
* @param id - Stream ID.
|
|
54
|
+
* @param participantIdentity - Sender identity.
|
|
55
|
+
* @param content - Full content or array of chunks.
|
|
56
|
+
* @param attributes - Optional stream attributes.
|
|
57
|
+
* @param topic - Optional stream topic.
|
|
58
|
+
*/
|
|
59
|
+
constructor(id: string, participantIdentity: string, content: string | string[], attributes?: Record<string, string>, topic?: string);
|
|
60
|
+
/**
|
|
61
|
+
* Gets whether the stream is complete.
|
|
62
|
+
*/
|
|
63
|
+
get isComplete(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Async iterator for stream chunks.
|
|
66
|
+
*/
|
|
67
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Reads the next chunk.
|
|
70
|
+
*
|
|
71
|
+
* @returns The next chunk or null if complete.
|
|
72
|
+
*/
|
|
73
|
+
read(): Promise<string | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Reads all remaining content.
|
|
76
|
+
*
|
|
77
|
+
* @returns The complete remaining content.
|
|
78
|
+
*/
|
|
79
|
+
readAll(): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Cancels the stream.
|
|
82
|
+
*/
|
|
83
|
+
cancel(): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mock text stream writer for sending streamed text.
|
|
87
|
+
*
|
|
88
|
+
* @description Simulates LiveKit's capability to send streamed text content.
|
|
89
|
+
*/
|
|
90
|
+
declare class MockTextStreamWriter {
|
|
91
|
+
/** Stream ID */
|
|
92
|
+
readonly id: string;
|
|
93
|
+
/** Destination identities */
|
|
94
|
+
private _destinationIdentities?;
|
|
95
|
+
/** Topic */
|
|
96
|
+
private _topic?;
|
|
97
|
+
/** Written chunks */
|
|
98
|
+
private chunks;
|
|
99
|
+
/** Whether stream is closed */
|
|
100
|
+
private _closed;
|
|
101
|
+
/** Callback when data is written */
|
|
102
|
+
private onWriteCallback?;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a new MockTextStreamWriter.
|
|
105
|
+
*
|
|
106
|
+
* @param topic - Stream topic.
|
|
107
|
+
* @param destinationIdentities - Optional specific recipients.
|
|
108
|
+
*/
|
|
109
|
+
constructor(topic?: string, destinationIdentities?: string[]);
|
|
110
|
+
/**
|
|
111
|
+
* Gets whether the stream is closed.
|
|
112
|
+
*/
|
|
113
|
+
get isClosed(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Gets the stream topic.
|
|
116
|
+
*/
|
|
117
|
+
get topic(): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Gets the destination identities.
|
|
120
|
+
*/
|
|
121
|
+
get destinationIdentities(): string[] | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Gets all written content.
|
|
124
|
+
*/
|
|
125
|
+
get content(): string;
|
|
126
|
+
/**
|
|
127
|
+
* Sets a callback for when data is written.
|
|
128
|
+
*
|
|
129
|
+
* @param callback - Callback function.
|
|
130
|
+
*/
|
|
131
|
+
onWrite(callback: (chunk: string) => void): void;
|
|
132
|
+
/**
|
|
133
|
+
* Writes a chunk to the stream.
|
|
134
|
+
*
|
|
135
|
+
* @param chunk - Text chunk to write.
|
|
136
|
+
*/
|
|
137
|
+
write(chunk: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Closes the stream.
|
|
140
|
+
*/
|
|
141
|
+
close(): Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Mock byte stream reader for binary data.
|
|
145
|
+
*/
|
|
146
|
+
declare class MockByteStreamReader {
|
|
147
|
+
/** Stream info */
|
|
148
|
+
info: MockTextStreamInfo;
|
|
149
|
+
/** Sender identity */
|
|
150
|
+
participantIdentity: string;
|
|
151
|
+
/** Data chunks */
|
|
152
|
+
private chunks;
|
|
153
|
+
/** Current index */
|
|
154
|
+
private _index;
|
|
155
|
+
/**
|
|
156
|
+
* Gets the current index.
|
|
157
|
+
*/
|
|
158
|
+
get index(): number;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a new MockByteStreamReader.
|
|
161
|
+
*
|
|
162
|
+
* @param id - Stream ID.
|
|
163
|
+
* @param participantIdentity - Sender identity.
|
|
164
|
+
* @param data - Binary data.
|
|
165
|
+
*/
|
|
166
|
+
constructor(id: string, participantIdentity: string, data: Uint8Array | Uint8Array[]);
|
|
167
|
+
/**
|
|
168
|
+
* Async iterator for data chunks.
|
|
169
|
+
*/
|
|
170
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<Uint8Array>;
|
|
171
|
+
/**
|
|
172
|
+
* Reads all remaining data.
|
|
173
|
+
*/
|
|
174
|
+
readAll(): Promise<Uint8Array>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates a text stream reader from content.
|
|
178
|
+
*
|
|
179
|
+
* @param participantIdentity - Sender identity.
|
|
180
|
+
* @param content - Content to stream.
|
|
181
|
+
* @param options - Optional configuration.
|
|
182
|
+
* @returns A MockTextStreamReader.
|
|
183
|
+
*/
|
|
184
|
+
declare function createTextStream(participantIdentity: string, content: string | string[], options?: {
|
|
185
|
+
id?: string;
|
|
186
|
+
attributes?: Record<string, string>;
|
|
187
|
+
topic?: string;
|
|
188
|
+
}): MockTextStreamReader;
|
|
189
|
+
|
|
190
|
+
export { MockByteStreamReader, type MockTextStreamInfo, MockTextStreamReader, MockTextStreamWriter, createTextStream };
|