@tellescope/video-chat 1.2.3 → 1.3.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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@tellescope/video-chat",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
7
+ "react-native": "./lib/esm/index.js",
7
8
  "types": "./lib/esm/index.d.ts",
8
9
  "scripts": {
9
10
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -33,13 +34,13 @@
33
34
  "@fontsource/roboto": "^4.5.1",
34
35
  "@mui/icons-material": "^5.0.1",
35
36
  "@mui/material": "^5.0.2",
36
- "@tellescope/constants": "^1.2.3",
37
- "@tellescope/react-components": "^1.2.3",
38
- "@tellescope/sdk": "^1.2.3",
39
- "@tellescope/types-client": "^1.2.3",
40
- "@tellescope/types-models": "^1.2.3",
37
+ "@tellescope/constants": "^1.3.0",
38
+ "@tellescope/react-components": "^1.3.0",
39
+ "@tellescope/sdk": "^1.3.0",
40
+ "@tellescope/types-client": "^1.3.0",
41
+ "@tellescope/types-models": "^1.3.0",
41
42
  "@tellescope/types-utilities": "^1.2.2",
42
- "@tellescope/utilities": "^1.2.3",
43
+ "@tellescope/utilities": "^1.3.0",
43
44
  "@typescript-eslint/eslint-plugin": "^4.33.0",
44
45
  "@typescript-eslint/parser": "^4.33.0",
45
46
  "amazon-chime-sdk-component-library-react": "^2.15.0",
@@ -54,7 +55,7 @@
54
55
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
55
56
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
56
57
  },
57
- "gitHead": "257986a3c2ef1450413175d3b30d3932bddb8aee",
58
+ "gitHead": "8635df935a3bb2562c8308341626488cb84dd8c4",
58
59
  "publishConfig": {
59
60
  "access": "public"
60
61
  }
package/src/hooks.ts ADDED
@@ -0,0 +1,83 @@
1
+ import { useCallback, useContext } from "react"
2
+ import { useCalendarEvents, useResolvedSession, useSession } from "@tellescope/react-components"
3
+ import { useMeetingManager } from "amazon-chime-sdk-component-library-react"
4
+ import { CurrentCallContext, useCurrentCallContext } from "./index"
5
+ import { CalendarEvent, Meeting } from "@tellescope/types-client"
6
+
7
+ export const useStartAndJoinMeetingForCalendarEvent = (calendarEventId: string) => {
8
+ const session = useSession()
9
+ const [, { updateLocalElement: updateLocalEvent }] = useCalendarEvents()
10
+
11
+ const meetingManager = useMeetingManager();
12
+
13
+ const { setMeeting, setIsHost } = useContext(CurrentCallContext)
14
+ if (!(!!setMeeting && setIsHost)) {
15
+ throw new Error("Missing CurrentCallContext")
16
+ }
17
+
18
+ const startAndJoinMeeting = useCallback(async () => {
19
+ const { meeting, host, id } = await session.api.meetings.start_meeting_for_event({ calendarEventId })
20
+
21
+ updateLocalEvent(calendarEventId, { meetingId: id } )
22
+
23
+ setMeeting(meeting as any)
24
+
25
+ await meetingManager.join({ meetingInfo: meeting, attendeeInfo: host.info }); // Use the join API to create a meeting session
26
+ await meetingManager.start(); // At this point you can let users setup their devices, or start the session immediately
27
+
28
+ setMeeting(meeting.Meeting)
29
+ setIsHost(true)
30
+ }, [session, calendarEventId, updateLocalEvent, meetingManager, setMeeting, setIsHost])
31
+
32
+ return {
33
+ startAndJoinMeeting,
34
+ }
35
+ }
36
+
37
+ export const useJoinMeeting = () => {
38
+ const session = useResolvedSession()
39
+ const meetingManager = useMeetingManager();
40
+
41
+ const { setMeeting, setIsHost } = useContext(CurrentCallContext)
42
+ if (!(!!setMeeting && setIsHost)) {
43
+ throw new Error("Missing CurrentCallContext")
44
+ }
45
+
46
+ const joinMeeting = useCallback(async (meeting: Meeting) => {
47
+ setMeeting(meeting.meetingInfo.Meeting)
48
+ setIsHost(meeting.creator === session.userInfo.id)
49
+
50
+ await meetingManager.join({
51
+ meetingInfo: meeting.meetingInfo,
52
+ attendeeInfo: meeting.attendees.find(a => a.id === session.userInfo.id)!.info
53
+ }); // Use the join API to create a meeting session
54
+ await meetingManager.start(); // At this point you can let users setup their devices, or start the session immediately
55
+
56
+ }, [setMeeting, meetingManager, setMeeting, setIsHost])
57
+
58
+ return {
59
+ joinMeeting,
60
+ }
61
+ }
62
+
63
+ export const useMeetingForCalendarEvent = (event: CalendarEvent) => {
64
+ const { meeting } = useCurrentCallContext()
65
+ const { startAndJoinMeeting } = useStartAndJoinMeetingForCalendarEvent(event.id)
66
+ const { joinMeeting } = useJoinMeeting()
67
+
68
+ return {
69
+ startAndJoinMeeting,
70
+ joinMeeting,
71
+ meeting,
72
+ meetingStatus: (
73
+ !event.enableVideoCall
74
+ ? 'disabled'
75
+ : !(event.meetingId)
76
+ ? 'waiting-room'
77
+ : !!meeting
78
+ ? 'joined'
79
+ : 'loading'
80
+
81
+ )
82
+ }
83
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./video"
2
+ export * from "./hooks"
2
3
  export * from "./controls"
3
4
  export {
4
5
  CurrentCallContext,
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./video"
2
2
  export * from "./controls"
3
+ export * from "./hooks"
3
4
  export {
4
5
  CurrentCallContext,
5
6
  useCurrentCallContext,