@mrksbnc/livekit-vue 0.0.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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/components.cjs +2 -0
  4. package/dist/components.cjs.map +1 -0
  5. package/dist/components.d.ts +1 -0
  6. package/dist/components.mjs +213 -0
  7. package/dist/components.mjs.map +1 -0
  8. package/dist/composables.cjs +2 -0
  9. package/dist/composables.cjs.map +1 -0
  10. package/dist/composables.d.ts +1 -0
  11. package/dist/composables.mjs +913 -0
  12. package/dist/composables.mjs.map +1 -0
  13. package/dist/contexts-BGR-EyiF.mjs +227 -0
  14. package/dist/contexts-BGR-EyiF.mjs.map +1 -0
  15. package/dist/favicon.ico +0 -0
  16. package/dist/index.cjs +2 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.css +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.mjs +74 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/shared-B72lPzrj.cjs +2 -0
  23. package/dist/shared-B72lPzrj.cjs.map +1 -0
  24. package/dist/shared-Bt-fJtlk.cjs +2 -0
  25. package/dist/shared-Bt-fJtlk.cjs.map +1 -0
  26. package/dist/shared-UqxyWhFA.cjs +2 -0
  27. package/dist/shared-UqxyWhFA.cjs.map +1 -0
  28. package/package.json +78 -0
  29. package/src/App.vue +16 -0
  30. package/src/assets/icons/chevron-down.svg +4 -0
  31. package/src/assets/icons/chevron-up.svg +4 -0
  32. package/src/assets/icons/frown.svg +7 -0
  33. package/src/assets/icons/heart.svg +6 -0
  34. package/src/assets/icons/mic-off.svg +8 -0
  35. package/src/assets/icons/mic.svg +7 -0
  36. package/src/assets/icons/phone-hang-up.svg +9 -0
  37. package/src/assets/icons/share-screen-off.svg +6 -0
  38. package/src/assets/icons/share-screen.svg +7 -0
  39. package/src/assets/icons/smile.svg +7 -0
  40. package/src/assets/icons/thumbs-down.svg +6 -0
  41. package/src/assets/icons/thumbs-up.svg +6 -0
  42. package/src/assets/icons/video-off.svg +5 -0
  43. package/src/assets/icons/video.svg +5 -0
  44. package/src/assets/index.ts +1 -0
  45. package/src/assets/placeholders/participant.svg +8 -0
  46. package/src/components/controls/TrackToggle.vue +27 -0
  47. package/src/components/controls/buttons.ts +5 -0
  48. package/src/components/controls/index.ts +3 -0
  49. package/src/components/controls/track_toggle.ts +13 -0
  50. package/src/components/icons/ParticipantPlaceholderIcon.vue +7 -0
  51. package/src/components/icons/TrackIcon.vue +55 -0
  52. package/src/components/index.ts +3 -0
  53. package/src/components/participant/AudioTrack.vue +17 -0
  54. package/src/components/participant/audio_track.ts +8 -0
  55. package/src/composables/index.ts +89 -0
  56. package/src/composables/private/useObservableState.ts +44 -0
  57. package/src/composables/useAudioPlayback.ts +42 -0
  58. package/src/composables/useClearPinButton.ts +41 -0
  59. package/src/composables/useConnectionQualityIndicator.ts +39 -0
  60. package/src/composables/useConnectionState.ts +21 -0
  61. package/src/composables/useDataChannel.ts +56 -0
  62. package/src/composables/useDisconnectButton.ts +28 -0
  63. package/src/composables/useFacingMode.ts +28 -0
  64. package/src/composables/useFocusToggle.ts +38 -0
  65. package/src/composables/useGridLayout.ts +44 -0
  66. package/src/composables/useIsEncrypted.ts +34 -0
  67. package/src/composables/useIsMuted.ts +56 -0
  68. package/src/composables/useIsRecording.ts +30 -0
  69. package/src/composables/useIsSpeaking.ts +23 -0
  70. package/src/composables/useLiveKitRoom.ts +219 -0
  71. package/src/composables/useLocalParticipant.ts +64 -0
  72. package/src/composables/useParticipantTile.ts +68 -0
  73. package/src/composables/useParticipantTracks.ts +36 -0
  74. package/src/composables/useParticipants.ts +25 -0
  75. package/src/composables/usePersistentUserChoices.ts +64 -0
  76. package/src/composables/usePinnedTracks.ts +16 -0
  77. package/src/composables/useRemoteParticipant.ts +42 -0
  78. package/src/composables/useRemoteParticipants.ts +27 -0
  79. package/src/composables/useRoomInfo.ts +42 -0
  80. package/src/composables/useSortedParticipants.ts +21 -0
  81. package/src/composables/useSpeakingParticipants.ts +22 -0
  82. package/src/composables/useStartAudio.ts +53 -0
  83. package/src/composables/useStartVideo.ts +53 -0
  84. package/src/composables/useToken.ts +40 -0
  85. package/src/composables/useTrack.ts +11 -0
  86. package/src/composables/useTrackByName.ts +11 -0
  87. package/src/composables/useTrackMutedIndicator.ts +34 -0
  88. package/src/composables/useTrackRefBySourceOrName.ts +39 -0
  89. package/src/composables/useTrackSyncTime.ts +32 -0
  90. package/src/composables/useTrackToggle.ts +113 -0
  91. package/src/composables/useTrackVolume.ts +268 -0
  92. package/src/composables/useTracks.ts +122 -0
  93. package/src/composables/useVisualStableUpdate.ts +57 -0
  94. package/src/context/index.ts +6 -0
  95. package/src/context/layout.context.ts +46 -0
  96. package/src/context/participant.context.ts +33 -0
  97. package/src/context/pin.context.ts +50 -0
  98. package/src/context/room.context.ts +31 -0
  99. package/src/context/track_reference.context.ts +29 -0
  100. package/src/context/widget.context.ts +17 -0
  101. package/src/index.css +1 -0
  102. package/src/index.ts +5 -0
  103. package/src/main.ts +6 -0
  104. package/src/types/livekit_room.types.ts +78 -0
  105. package/src/utils/room.utils.ts +9 -0
@@ -0,0 +1,33 @@
1
+ import { createInjectionState } from '@vueuse/core';
2
+ import type { Participant } from 'livekit-client';
3
+ import { shallowRef, type ShallowRef } from 'vue';
4
+
5
+ export type ParticipantContext = {
6
+ participant: Participant;
7
+ };
8
+
9
+ const [useProvideParticipantContext, useParticipantContext] = createInjectionState(
10
+ (initialValue: Participant): ShallowRef<Participant> => {
11
+ const participant = shallowRef(initialValue);
12
+
13
+ return participant;
14
+ },
15
+ );
16
+
17
+ export function useMaybeParticipantContext(): ShallowRef<Participant> | undefined {
18
+ return useParticipantContext();
19
+ }
20
+
21
+ export function useEnsureParticipant(participant?: Participant): ShallowRef<Participant> {
22
+ const r = participant ? shallowRef(participant) : useParticipantContext();
23
+
24
+ if (!r || !r.value) {
25
+ throw new Error(
26
+ 'Please call `useProvideParticipantContext` on the appropriate parent component',
27
+ );
28
+ }
29
+
30
+ return r;
31
+ }
32
+
33
+ export { useParticipantContext, useProvideParticipantContext };
@@ -0,0 +1,50 @@
1
+ import type { PinState, TrackReferenceOrPlaceholder } from '@livekit/components-core';
2
+ import { createInjectionState } from '@vueuse/core';
3
+ import { shallowRef } from 'vue';
4
+
5
+ export type PinAction =
6
+ | {
7
+ msg: 'set_pin';
8
+ trackReference: TrackReferenceOrPlaceholder;
9
+ }
10
+ | { msg: 'clear_pin' }
11
+ | { msg: 'toggle_settings' };
12
+
13
+ export type PinContext = {
14
+ state: PinState;
15
+ dispatch?: (action: PinAction) => void;
16
+ };
17
+
18
+ export function pinReducer(state: PinState, action: PinAction): PinState {
19
+ if (action.msg === 'set_pin') {
20
+ return [action.trackReference];
21
+ } else if (action.msg === 'clear_pin') {
22
+ return [];
23
+ } else {
24
+ return { ...state };
25
+ }
26
+ }
27
+
28
+ const [useProvidePinContext, usePinContext] = createInjectionState((initialValue: PinState) => {
29
+ const state = shallowRef(initialValue);
30
+
31
+ function dispatch(action: PinAction) {
32
+ state.value = pinReducer(state.value, action);
33
+ }
34
+
35
+ return {
36
+ state,
37
+ dispatch,
38
+ };
39
+ });
40
+
41
+ export { usePinContext, useProvidePinContext };
42
+
43
+ export const useEnsurePinContext = (pinContext?: PinState) => {
44
+ const pc = pinContext ? shallowRef(pinContext) : usePinContext();
45
+
46
+ if (!pc) {
47
+ throw Error('Tried to access PinContext context outside a PinContextProvider provider.');
48
+ }
49
+ return pc;
50
+ };
@@ -0,0 +1,31 @@
1
+ import { createInjectionState } from '@vueuse/core';
2
+ import type { Room } from 'livekit-client';
3
+ import { shallowRef, type ShallowRef } from 'vue';
4
+
5
+ export type RoomContext = {
6
+ room: Room;
7
+ };
8
+
9
+ const [useProvideRoomContext, useRoomContext] = createInjectionState(
10
+ (initialValue: Room): ShallowRef<Room> => {
11
+ const room = shallowRef(initialValue);
12
+
13
+ return room;
14
+ },
15
+ );
16
+
17
+ export function useMaybeRoomContext(): ShallowRef<Room> | undefined {
18
+ return useRoomContext();
19
+ }
20
+
21
+ export function useEnsureRoomContext(room?: Room): ShallowRef<Room> {
22
+ const r = room ? shallowRef(room) : useRoomContext();
23
+
24
+ if (!r || !r.value) {
25
+ throw new Error('Please call `useProvideRoomContext` on the appropriate parent component');
26
+ }
27
+
28
+ return r;
29
+ }
30
+
31
+ export { useProvideRoomContext, useRoomContext };
@@ -0,0 +1,29 @@
1
+ import type { TrackReference, TrackReferenceOrPlaceholder } from '@livekit/components-core';
2
+ import { createInjectionState } from '@vueuse/core';
3
+ import { shallowRef, type ShallowRef } from 'vue';
4
+
5
+ const [useTrackRefContextProvider, useTrackRefContext] = createInjectionState(
6
+ (ref: TrackReference | TrackReferenceOrPlaceholder): ShallowRef<TrackReferenceOrPlaceholder> => {
7
+ const trackRef = shallowRef(ref);
8
+
9
+ return trackRef;
10
+ },
11
+ );
12
+
13
+ export function useMaybeTrackRefContext(): ShallowRef<TrackReferenceOrPlaceholder> | undefined {
14
+ return useTrackRefContext();
15
+ }
16
+
17
+ export function useEnsureTrackRef(
18
+ trackRef?: TrackReferenceOrPlaceholder,
19
+ ): ShallowRef<TrackReferenceOrPlaceholder> {
20
+ const t = trackRef ? shallowRef(trackRef) : useTrackRefContext();
21
+
22
+ if (!t || !t.value) {
23
+ throw new Error('Please call `useTrackRefContextProvider` on the appropriate parent component');
24
+ }
25
+
26
+ return t;
27
+ }
28
+
29
+ export { useTrackRefContext, useTrackRefContextProvider };
@@ -0,0 +1,17 @@
1
+ import type { WidgetState } from '@livekit/components-core';
2
+ import { createInjectionState } from '@vueuse/core';
3
+ import { shallowRef, type ShallowRef } from 'vue';
4
+
5
+ export type WidgetContextType = {
6
+ state?: WidgetState;
7
+ };
8
+
9
+ const [useProvideWidgetContext, useWidgetContext] = createInjectionState(
10
+ (initialValue: WidgetState): ShallowRef<WidgetState> => {
11
+ const state = shallowRef(initialValue);
12
+
13
+ return state;
14
+ },
15
+ );
16
+
17
+ export { useProvideWidgetContext, useWidgetContext };
package/src/index.css ADDED
@@ -0,0 +1 @@
1
+ @import 'tailwindcss';
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './components';
2
+ export * from './composables';
3
+ export * from './context';
4
+
5
+ import './index.css';
package/src/main.ts ADDED
@@ -0,0 +1,6 @@
1
+ import '@/assets/index.css';
2
+
3
+ import { createApp } from 'vue';
4
+ import App from './App.vue';
5
+
6
+ createApp(App).mount('#app');
@@ -0,0 +1,78 @@
1
+ import type {
2
+ AudioCaptureOptions,
3
+ DisconnectReason,
4
+ MediaDeviceFailure,
5
+ Room,
6
+ RoomConnectOptions,
7
+ RoomOptions,
8
+ ScreenShareCaptureOptions,
9
+ VideoCaptureOptions,
10
+ } from 'livekit-client';
11
+ import type { HTMLAttributes } from 'vue';
12
+
13
+ export type LiveKitRoomProps = {
14
+ /**
15
+ * URL to the LiveKit server.
16
+ * For example: `wss://<domain>.livekit.cloud`
17
+ * To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string url can the connection be established.
18
+ */
19
+ serverUrl: string | undefined;
20
+ /**
21
+ * A user specific access token for a client to authenticate to the room.
22
+ * This token is necessary to establish a connection to the room.
23
+ * To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string token can the connection be established.
24
+ *
25
+ * @see https://docs.livekit.io/cloud/project-management/keys-and-tokens/#generating-access-tokens
26
+ */
27
+ token: string | undefined;
28
+ /**
29
+ * Publish audio immediately after connecting to your LiveKit room.
30
+ * @defaultValue `false`
31
+ * @see https://docs.livekit.io/client-sdk-js/interfaces/AudioCaptureOptions.html
32
+ */
33
+ audio?: AudioCaptureOptions | boolean;
34
+ /**
35
+ * Publish video immediately after connecting to your LiveKit room.
36
+ * @defaultValue `false`
37
+ * @see https://docs.livekit.io/client-sdk-js/interfaces/VideoCaptureOptions.html
38
+ */
39
+ video?: VideoCaptureOptions | boolean;
40
+ /**
41
+ * Publish screen share immediately after connecting to your LiveKit room.
42
+ * @defaultValue `false`
43
+ * @see https://docs.livekit.io/client-sdk-js/interfaces/ScreenShareCaptureOptions.html
44
+ */
45
+ screen?: ScreenShareCaptureOptions | boolean;
46
+ /**
47
+ * If set to true a connection to LiveKit room is initiated.
48
+ * @defaultValue `true`
49
+ */
50
+ connect?: boolean;
51
+ /**
52
+ * Options for when creating a new room.
53
+ * When you pass your own room instance to this component, these options have no effect.
54
+ * Instead, set the options directly in the room instance.
55
+ *
56
+ * @see https://docs.livekit.io/client-sdk-js/interfaces/RoomOptions.html
57
+ */
58
+ options?: RoomOptions;
59
+ /**
60
+ * Define options how to connect to the LiveKit server.
61
+ *
62
+ * @see https://docs.livekit.io/client-sdk-js/interfaces/RoomConnectOptions.html
63
+ */
64
+ connectOptions?: RoomConnectOptions;
65
+ /**
66
+ * Optional room instance.
67
+ * By passing your own room instance you overwrite the `options` parameter,
68
+ * make sure to set the options directly on the room instance itself.
69
+ */
70
+ room?: Room;
71
+ simulateParticipants?: number | undefined;
72
+ htmlProps?: HTMLAttributes;
73
+ onConnected?: () => void;
74
+ onDisconnected?: (reason?: DisconnectReason) => void;
75
+ onError?: (error: Error) => void;
76
+ onMediaDeviceFailure?: (failure?: MediaDeviceFailure) => void;
77
+ onEncryptionError?: (error: Error) => void;
78
+ };
@@ -0,0 +1,9 @@
1
+ export function roomOptionsStringifyReplacer(key: string, val: unknown): unknown {
2
+ if (key === 'processor' && val && typeof val === 'object' && 'name' in val) {
3
+ return val.name;
4
+ }
5
+ if (key === 'e2ee' && val) {
6
+ return 'e2ee-enabled';
7
+ }
8
+ return val;
9
+ }