vg-x07df 0.1.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/.azure-pipelines/publish-public.yml +37 -0
- package/.azure-pipelines/publish.yml +39 -0
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/AUTO_JOIN_GUIDE.md +411 -0
- package/README.md +215 -0
- package/Screenshot 2025-09-24 at 14.34.48.png +0 -0
- package/Screenshot 2025-10-04 at 12.58.54.png +0 -0
- package/biome.json +48 -0
- package/examples/demo/.env.example +19 -0
- package/examples/demo/CHANGELOG.md +22 -0
- package/examples/demo/README.md +72 -0
- package/examples/demo/eslint.config.js +23 -0
- package/examples/demo/index.html +13 -0
- package/examples/demo/package.json +34 -0
- package/examples/demo/pnpm-lock.yaml +2098 -0
- package/examples/demo/pnpm-workspace.yaml +1 -0
- package/examples/demo/public/vite.svg +1 -0
- package/examples/demo/src/App.css +52 -0
- package/examples/demo/src/App.tsx +176 -0
- package/examples/demo/src/assets/react.svg +1 -0
- package/examples/demo/src/components/auth/LoginForm.css +144 -0
- package/examples/demo/src/components/auth/LoginForm.tsx +80 -0
- package/examples/demo/src/components/calling/AutoJoinSettings.tsx +213 -0
- package/examples/demo/src/components/calling/AutoJoinStatus.tsx +72 -0
- package/examples/demo/src/components/calling/CallInitiator.css +258 -0
- package/examples/demo/src/components/calling/CallInitiator.tsx +142 -0
- package/examples/demo/src/components/calling/CallNotifications.css +119 -0
- package/examples/demo/src/components/calling/CallNotifications.tsx +108 -0
- package/examples/demo/src/components/calling/IncomingCallModal.css +192 -0
- package/examples/demo/src/components/calling/IncomingCallModal.tsx +78 -0
- package/examples/demo/src/components/calling/MinimizedCall.css +156 -0
- package/examples/demo/src/components/calling/MinimizedCall.tsx +78 -0
- package/examples/demo/src/components/conference/ConferenceHeader.css +265 -0
- package/examples/demo/src/components/conference/ConferenceHeader.tsx +78 -0
- package/examples/demo/src/components/conference/EnhancedControlBar.css +356 -0
- package/examples/demo/src/components/conference/EnhancedControlBar.tsx +262 -0
- package/examples/demo/src/components/conference/PaginationControls.css +67 -0
- package/examples/demo/src/components/conference/PaginationControls.tsx +64 -0
- package/examples/demo/src/components/conference/ParticipantGrid.css +153 -0
- package/examples/demo/src/components/conference/ParticipantGrid.tsx +87 -0
- package/examples/demo/src/components/conference/ParticipantTile.css +210 -0
- package/examples/demo/src/components/conference/ParticipantTile.tsx +114 -0
- package/examples/demo/src/components/conference/VideoConference.css +214 -0
- package/examples/demo/src/components/conference/VideoConference.tsx +93 -0
- package/examples/demo/src/contexts/AuthContext.tsx +105 -0
- package/examples/demo/src/hooks/useAuth.ts +5 -0
- package/examples/demo/src/hooks/useCallTimer.ts +42 -0
- package/examples/demo/src/index.css +68 -0
- package/examples/demo/src/main.tsx +10 -0
- package/examples/demo/src/services/auth.service.ts +153 -0
- package/examples/demo/src/types/auth.types.ts +31 -0
- package/examples/demo/tsconfig.app.json +28 -0
- package/examples/demo/tsconfig.json +7 -0
- package/examples/demo/tsconfig.node.json +26 -0
- package/examples/demo/vite.config.ts +15 -0
- package/images/callpad-without-ai.png +0 -0
- package/package.json +28 -0
- package/packages/sdk/CHANGELOG.md +33 -0
- package/packages/sdk/LICENSE +21 -0
- package/packages/sdk/README.md +97 -0
- package/packages/sdk/documentation.md +1132 -0
- package/packages/sdk/openapi-ts.config.ts +7 -0
- package/packages/sdk/package.json +88 -0
- package/packages/sdk/src/core/auth.manager.ts +52 -0
- package/packages/sdk/src/core/events/event-bus.ts +301 -0
- package/packages/sdk/src/core/events/index.ts +8 -0
- package/packages/sdk/src/core/events/types.ts +165 -0
- package/packages/sdk/src/core/index.ts +3 -0
- package/packages/sdk/src/core/signal/api.config.ts +49 -0
- package/packages/sdk/src/core/signal/index.ts +16 -0
- package/packages/sdk/src/core/signal/signal.client.ts +101 -0
- package/packages/sdk/src/core/signal/types.ts +110 -0
- package/packages/sdk/src/core/socketio/handlers/base.handler.ts +212 -0
- package/packages/sdk/src/core/socketio/handlers/call-accepted.handler.ts +34 -0
- package/packages/sdk/src/core/socketio/handlers/call-canceled.handler.ts +34 -0
- package/packages/sdk/src/core/socketio/handlers/call-declined.handler.ts +29 -0
- package/packages/sdk/src/core/socketio/handlers/call-ended.handler.ts +40 -0
- package/packages/sdk/src/core/socketio/handlers/call-incoming.handler.ts +72 -0
- package/packages/sdk/src/core/socketio/handlers/call-join-info.handler.ts +181 -0
- package/packages/sdk/src/core/socketio/handlers/call-participant-joined.handler.ts +42 -0
- package/packages/sdk/src/core/socketio/handlers/call-participant-joining.handler.ts +42 -0
- package/packages/sdk/src/core/socketio/handlers/call-timeout.handler.ts +31 -0
- package/packages/sdk/src/core/socketio/handlers/handler.registry.ts +62 -0
- package/packages/sdk/src/core/socketio/handlers/index.ts +21 -0
- package/packages/sdk/src/core/socketio/handlers/participant-left.handler.ts +37 -0
- package/packages/sdk/src/core/socketio/handlers/schema.ts +130 -0
- package/packages/sdk/src/core/socketio/index.ts +5 -0
- package/packages/sdk/src/core/socketio/socket.manager.ts +187 -0
- package/packages/sdk/src/core/socketio/types.ts +14 -0
- package/packages/sdk/src/core/types.ts +23 -0
- package/packages/sdk/src/generated/api/core/ApiError.ts +21 -0
- package/packages/sdk/src/generated/api/core/ApiRequestOptions.ts +13 -0
- package/packages/sdk/src/generated/api/core/ApiResult.ts +7 -0
- package/packages/sdk/src/generated/api/core/CancelablePromise.ts +126 -0
- package/packages/sdk/src/generated/api/core/OpenAPI.ts +55 -0
- package/packages/sdk/src/generated/api/core/request.ts +339 -0
- package/packages/sdk/src/generated/api/index.ts +5 -0
- package/packages/sdk/src/generated/api/models.ts +219 -0
- package/packages/sdk/src/generated/api/services.ts +225 -0
- package/packages/sdk/src/hooks/index.ts +21 -0
- package/packages/sdk/src/hooks/useAutoJoin.ts +66 -0
- package/packages/sdk/src/hooks/useCallActions.ts +28 -0
- package/packages/sdk/src/hooks/useCallQuality.ts +416 -0
- package/packages/sdk/src/hooks/useCallState.ts +23 -0
- package/packages/sdk/src/hooks/useConnection.ts +15 -0
- package/packages/sdk/src/hooks/useDevices.ts +296 -0
- package/packages/sdk/src/hooks/useErrorRecovery.ts +299 -0
- package/packages/sdk/src/hooks/useErrors.ts +84 -0
- package/packages/sdk/src/hooks/useEvent.ts +188 -0
- package/packages/sdk/src/hooks/useMediaControls.ts +215 -0
- package/packages/sdk/src/hooks/useParticipantStatus.ts +318 -0
- package/packages/sdk/src/hooks/useParticipants.ts +111 -0
- package/packages/sdk/src/index.ts +66 -0
- package/packages/sdk/src/livekit/constants.ts +76 -0
- package/packages/sdk/src/livekit/device.manager.ts +172 -0
- package/packages/sdk/src/livekit/error-classifier.ts +155 -0
- package/packages/sdk/src/livekit/events/eventBridge.ts +371 -0
- package/packages/sdk/src/livekit/events/trackRegistry.ts +114 -0
- package/packages/sdk/src/livekit/index.ts +49 -0
- package/packages/sdk/src/livekit/livekit.service.ts +110 -0
- package/packages/sdk/src/livekit/media.controls.ts +315 -0
- package/packages/sdk/src/livekit/room.manager.ts +79 -0
- package/packages/sdk/src/livekit/track.utils.ts +230 -0
- package/packages/sdk/src/livekit/types.ts +135 -0
- package/packages/sdk/src/provider/RtcProvider.tsx +78 -0
- package/packages/sdk/src/services/call-actions.ts +260 -0
- package/packages/sdk/src/services/error-recovery.ts +461 -0
- package/packages/sdk/src/services/index.ts +2 -0
- package/packages/sdk/src/services/sdk-builder.ts +104 -0
- package/packages/sdk/src/state/errors.ts +163 -0
- package/packages/sdk/src/state/selectors.ts +28 -0
- package/packages/sdk/src/state/store.ts +36 -0
- package/packages/sdk/src/state/types.ts +151 -0
- package/packages/sdk/src/utils/logger.ts +183 -0
- package/packages/sdk/tsconfig.json +49 -0
- package/packages/sdk/tsup.config.ts +51 -0
- package/pnpm-workspace.yaml +4 -0
- package/tsconfig.base.json +19 -0
- package/turbo.json +34 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useAutoJoin, useAutoJoinForCurrentUser } from 'vg-x07df'
|
|
2
|
+
import { useSdk } from 'vg-x07df'
|
|
3
|
+
|
|
4
|
+
export function AutoJoinStatus() {
|
|
5
|
+
const sdk = useSdk()
|
|
6
|
+
const autoJoinState = sdk.store((state) => state.autoJoin)
|
|
7
|
+
const autoJoin = useAutoJoin()
|
|
8
|
+
const userAutoJoin = useAutoJoinForCurrentUser()
|
|
9
|
+
|
|
10
|
+
// Don't show component when auto-join is idle or completed
|
|
11
|
+
if (autoJoinState.status === 'idle' || autoJoinState.status === 'succeeded') {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const getStatusDisplay = () => {
|
|
16
|
+
switch (autoJoinState.status) {
|
|
17
|
+
case 'pending':
|
|
18
|
+
return {
|
|
19
|
+
icon: '⏳',
|
|
20
|
+
message: 'Joining call automatically...',
|
|
21
|
+
color: 'text-blue-600',
|
|
22
|
+
bgColor: 'bg-blue-50 border-blue-200'
|
|
23
|
+
}
|
|
24
|
+
case 'retrying':
|
|
25
|
+
return {
|
|
26
|
+
icon: '🔄',
|
|
27
|
+
message: `Retrying connection... (${autoJoinState.attempt}/${autoJoinState.maxAttempts})`,
|
|
28
|
+
color: 'text-orange-600',
|
|
29
|
+
bgColor: 'bg-orange-50 border-orange-200'
|
|
30
|
+
}
|
|
31
|
+
case 'failed':
|
|
32
|
+
return {
|
|
33
|
+
icon: '⚠️',
|
|
34
|
+
message: 'Auto-join failed. You can join manually.',
|
|
35
|
+
color: 'text-red-600',
|
|
36
|
+
bgColor: 'bg-red-50 border-red-200'
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const statusInfo = getStatusDisplay()
|
|
44
|
+
if (!statusInfo) return null
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className={`fixed top-4 right-4 z-50 p-3 rounded-lg border ${statusInfo.bgColor} ${statusInfo.color} max-w-sm`}>
|
|
48
|
+
<div className="flex items-center gap-2">
|
|
49
|
+
<span className="text-lg">{statusInfo.icon}</span>
|
|
50
|
+
<div className="flex-1">
|
|
51
|
+
<p className="font-medium text-sm">{statusInfo.message}</p>
|
|
52
|
+
{autoJoinState.lastError && (
|
|
53
|
+
<p className="text-xs opacity-75 mt-1">Error: {autoJoinState.lastError}</p>
|
|
54
|
+
)}
|
|
55
|
+
{userAutoJoin.shouldAutoJoin && (
|
|
56
|
+
<p className="text-xs opacity-75 mt-1">
|
|
57
|
+
Mode: {userAutoJoin.trigger === 'immediate' ? 'Immediate' : 'After first accept'}
|
|
58
|
+
</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
{autoJoinState.status === 'failed' && (
|
|
62
|
+
<button
|
|
63
|
+
onClick={() => sdk.join()}
|
|
64
|
+
className="ml-2 px-3 py-1 bg-red-600 text-white text-xs rounded hover:bg-red-700 transition-colors"
|
|
65
|
+
>
|
|
66
|
+
Join Manually
|
|
67
|
+
</button>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
.call-initiator {
|
|
2
|
+
max-width: 1200px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 24px;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 24px;
|
|
8
|
+
min-height: 100vh;
|
|
9
|
+
background: #f9fafb;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.call-initiator-header {
|
|
13
|
+
text-align: center;
|
|
14
|
+
padding: 24px 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.call-initiator-header h1 {
|
|
18
|
+
margin: 0 0 8px 0;
|
|
19
|
+
font-size: 32px;
|
|
20
|
+
font-weight: 700;
|
|
21
|
+
color: #111827;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.call-initiator-header p {
|
|
25
|
+
margin: 0;
|
|
26
|
+
font-size: 16px;
|
|
27
|
+
color: #6b7280;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.call-setup-form {
|
|
31
|
+
background: white;
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
padding: 24px;
|
|
34
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: 24px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.form-section {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
gap: 8px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.form-section label {
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
color: #374151;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.user-ids-input {
|
|
53
|
+
width: 100%;
|
|
54
|
+
padding: 12px 16px;
|
|
55
|
+
border: 2px solid #e5e7eb;
|
|
56
|
+
border-radius: 8px;
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
resize: vertical;
|
|
60
|
+
min-height: 80px;
|
|
61
|
+
transition: border-color 0.2s;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.user-ids-input:focus {
|
|
65
|
+
outline: none;
|
|
66
|
+
border-color: #667eea;
|
|
67
|
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.user-ids-input:disabled {
|
|
71
|
+
background-color: #f9fafb;
|
|
72
|
+
color: #9ca3af;
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.input-helper {
|
|
77
|
+
min-height: 20px;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.parsed-count {
|
|
83
|
+
font-size: 13px;
|
|
84
|
+
color: #059669;
|
|
85
|
+
font-weight: 500;
|
|
86
|
+
background: rgba(16, 185, 129, 0.1);
|
|
87
|
+
padding: 4px 8px;
|
|
88
|
+
border-radius: 4px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.call-type-selector label {
|
|
92
|
+
display: block;
|
|
93
|
+
font-weight: 600;
|
|
94
|
+
color: #374151;
|
|
95
|
+
margin-bottom: 12px;
|
|
96
|
+
font-size: 14px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.call-type-buttons {
|
|
100
|
+
display: flex;
|
|
101
|
+
gap: 12px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.call-type-button {
|
|
105
|
+
flex: 1;
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
gap: 8px;
|
|
110
|
+
padding: 12px 16px;
|
|
111
|
+
border: 2px solid #e5e7eb;
|
|
112
|
+
border-radius: 8px;
|
|
113
|
+
background: white;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
transition: all 0.2s;
|
|
116
|
+
font-weight: 500;
|
|
117
|
+
color: #374151;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.call-type-button:hover:not(:disabled) {
|
|
121
|
+
border-color: #667eea;
|
|
122
|
+
background-color: #f8faff;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.call-type-button.active {
|
|
126
|
+
border-color: #667eea;
|
|
127
|
+
background-color: #eef2ff;
|
|
128
|
+
color: #4338ca;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.call-type-button:disabled {
|
|
132
|
+
opacity: 0.5;
|
|
133
|
+
cursor: not-allowed;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.call-type-button .icon {
|
|
137
|
+
font-size: 18px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.error-message {
|
|
141
|
+
background-color: #fef2f2;
|
|
142
|
+
border: 1px solid #fecaca;
|
|
143
|
+
border-radius: 8px;
|
|
144
|
+
padding: 12px 16px;
|
|
145
|
+
display: flex;
|
|
146
|
+
justify-content: space-between;
|
|
147
|
+
align-items: center;
|
|
148
|
+
color: #dc2626;
|
|
149
|
+
font-size: 14px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.error-close {
|
|
153
|
+
background: none;
|
|
154
|
+
border: none;
|
|
155
|
+
color: #dc2626;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
font-size: 18px;
|
|
158
|
+
padding: 0;
|
|
159
|
+
width: 24px;
|
|
160
|
+
height: 24px;
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.call-actions {
|
|
167
|
+
display: flex;
|
|
168
|
+
gap: 12px;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
padding: 20px 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.clear-button {
|
|
174
|
+
padding: 12px 24px;
|
|
175
|
+
border: 1px solid #d1d5db;
|
|
176
|
+
border-radius: 8px;
|
|
177
|
+
background: white;
|
|
178
|
+
color: #374151;
|
|
179
|
+
font-weight: 500;
|
|
180
|
+
cursor: pointer;
|
|
181
|
+
transition: all 0.2s;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.clear-button:hover:not(:disabled) {
|
|
185
|
+
border-color: #9ca3af;
|
|
186
|
+
background-color: #f9fafb;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.clear-button:disabled {
|
|
190
|
+
opacity: 0.5;
|
|
191
|
+
cursor: not-allowed;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.initiate-button {
|
|
195
|
+
padding: 12px 32px;
|
|
196
|
+
border: none;
|
|
197
|
+
border-radius: 8px;
|
|
198
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
199
|
+
color: white;
|
|
200
|
+
font-weight: 600;
|
|
201
|
+
font-size: 16px;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
transition: all 0.2s;
|
|
204
|
+
display: flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
gap: 8px;
|
|
207
|
+
min-width: 200px;
|
|
208
|
+
justify-content: center;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.initiate-button:hover:not(:disabled) {
|
|
212
|
+
transform: translateY(-1px);
|
|
213
|
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.initiate-button:disabled {
|
|
217
|
+
opacity: 0.6;
|
|
218
|
+
cursor: not-allowed;
|
|
219
|
+
transform: none;
|
|
220
|
+
box-shadow: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.loading-spinner {
|
|
224
|
+
width: 16px;
|
|
225
|
+
height: 16px;
|
|
226
|
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
227
|
+
border-top: 2px solid white;
|
|
228
|
+
border-radius: 50%;
|
|
229
|
+
animation: spin 1s linear infinite;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@keyframes spin {
|
|
233
|
+
0% { transform: rotate(0deg); }
|
|
234
|
+
100% { transform: rotate(360deg); }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@media (max-width: 640px) {
|
|
238
|
+
.call-initiator {
|
|
239
|
+
padding: 16px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.call-initiator-header h1 {
|
|
243
|
+
font-size: 24px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.call-type-buttons {
|
|
247
|
+
flex-direction: column;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.call-actions {
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
align-items: stretch;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.initiate-button {
|
|
256
|
+
min-width: auto;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useCallActions } from 'vg-x07df';
|
|
3
|
+
import './CallInitiator.css';
|
|
4
|
+
|
|
5
|
+
interface CallInitiatorProps {
|
|
6
|
+
onCallInitiated?: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function CallInitiator({ onCallInitiated }: CallInitiatorProps) {
|
|
10
|
+
const [userIds, setUserIds] = useState('');
|
|
11
|
+
const [callType, setCallType] = useState<'AUDIO' | 'VIDEO'>('AUDIO');
|
|
12
|
+
const [isInitiating, setIsInitiating] = useState(false);
|
|
13
|
+
const [error, setError] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
const { initiate } = useCallActions();
|
|
16
|
+
|
|
17
|
+
const parseUserIds = (input: string): string[] => {
|
|
18
|
+
return input
|
|
19
|
+
.split(',')
|
|
20
|
+
.map(id => id.trim())
|
|
21
|
+
.filter(id => id.length > 0);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleInitiateCall = async () => {
|
|
25
|
+
const invitees = parseUserIds(userIds);
|
|
26
|
+
|
|
27
|
+
if (invitees.length === 0) {
|
|
28
|
+
setError('Please enter at least one user ID');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setIsInitiating(true);
|
|
33
|
+
setError(null);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
await initiate(invitees, callType);
|
|
37
|
+
|
|
38
|
+
onCallInitiated?.();
|
|
39
|
+
} catch (err) {
|
|
40
|
+
const errorMessage = err instanceof Error ? err.message : 'Failed to initiate call';
|
|
41
|
+
setError(errorMessage);
|
|
42
|
+
} finally {
|
|
43
|
+
setIsInitiating(false);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const clearInput = () => {
|
|
48
|
+
setUserIds('');
|
|
49
|
+
setError(null);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const parsedUserIds = parseUserIds(userIds);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="call-initiator">
|
|
56
|
+
<div className="call-initiator-header">
|
|
57
|
+
<h1>Start a Call</h1>
|
|
58
|
+
<p>Enter user IDs to start a video or audio call</p>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<div className="call-setup-form">
|
|
62
|
+
<div className="form-section">
|
|
63
|
+
<label htmlFor="userIds">User IDs to Call</label>
|
|
64
|
+
<textarea
|
|
65
|
+
id="userIds"
|
|
66
|
+
value={userIds}
|
|
67
|
+
onChange={(e) => setUserIds(e.target.value)}
|
|
68
|
+
placeholder="Enter user IDs separated by commas Example: 123, 456, 789"
|
|
69
|
+
className="user-ids-input"
|
|
70
|
+
rows={3}
|
|
71
|
+
disabled={isInitiating}
|
|
72
|
+
/>
|
|
73
|
+
<div className="input-helper">
|
|
74
|
+
{parsedUserIds.length > 0 && (
|
|
75
|
+
<span className="parsed-count">
|
|
76
|
+
{parsedUserIds.length} user{parsedUserIds.length !== 1 ? 's' : ''} will be invited
|
|
77
|
+
</span>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div className="call-type-selector">
|
|
83
|
+
<label>Call Type:</label>
|
|
84
|
+
<div className="call-type-buttons">
|
|
85
|
+
<button
|
|
86
|
+
className={`call-type-button ${callType === 'AUDIO' ? 'active' : ''}`}
|
|
87
|
+
onClick={() => setCallType('AUDIO')}
|
|
88
|
+
disabled={isInitiating}
|
|
89
|
+
>
|
|
90
|
+
<span className="icon">🎤</span>
|
|
91
|
+
Audio Call
|
|
92
|
+
</button>
|
|
93
|
+
<button
|
|
94
|
+
className={`call-type-button ${callType === 'VIDEO' ? 'active' : ''}`}
|
|
95
|
+
onClick={() => setCallType('VIDEO')}
|
|
96
|
+
disabled={isInitiating}
|
|
97
|
+
>
|
|
98
|
+
<span className="icon">🎥</span>
|
|
99
|
+
Video Call
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{error && (
|
|
106
|
+
<div className="error-message">
|
|
107
|
+
<span>{error}</span>
|
|
108
|
+
<button onClick={() => setError(null)} className="error-close">×</button>
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
|
|
112
|
+
<div className="call-actions">
|
|
113
|
+
{userIds.trim() && (
|
|
114
|
+
<button
|
|
115
|
+
onClick={clearInput}
|
|
116
|
+
className="clear-button"
|
|
117
|
+
disabled={isInitiating}
|
|
118
|
+
>
|
|
119
|
+
Clear Input
|
|
120
|
+
</button>
|
|
121
|
+
)}
|
|
122
|
+
|
|
123
|
+
<button
|
|
124
|
+
onClick={handleInitiateCall}
|
|
125
|
+
className="initiate-button"
|
|
126
|
+
disabled={parsedUserIds.length === 0 || isInitiating}
|
|
127
|
+
>
|
|
128
|
+
{isInitiating ? (
|
|
129
|
+
<>
|
|
130
|
+
<div className="loading-spinner"></div>
|
|
131
|
+
Initiating {callType.toLowerCase()} call...
|
|
132
|
+
</>
|
|
133
|
+
) : (
|
|
134
|
+
<>
|
|
135
|
+
Start {callType.toLowerCase()} call with {parsedUserIds.length} user{parsedUserIds.length !== 1 ? 's' : ''}
|
|
136
|
+
</>
|
|
137
|
+
)}
|
|
138
|
+
</button>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.call-notifications {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 20px;
|
|
4
|
+
right: 20px;
|
|
5
|
+
z-index: 1001;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: 0.5rem;
|
|
9
|
+
max-width: 350px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.notification {
|
|
13
|
+
background: white;
|
|
14
|
+
border-radius: 8px;
|
|
15
|
+
padding: 1rem;
|
|
16
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
transition: all 0.3s ease;
|
|
22
|
+
animation: slideInRight 0.3s ease-out;
|
|
23
|
+
border-left: 4px solid;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.notification:hover {
|
|
27
|
+
transform: translateX(-5px);
|
|
28
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.notification-success {
|
|
32
|
+
border-left-color: #28a745;
|
|
33
|
+
background: linear-gradient(to right, rgba(40, 167, 69, 0.1), white);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.notification-warning {
|
|
37
|
+
border-left-color: #ffc107;
|
|
38
|
+
background: linear-gradient(to right, rgba(255, 193, 7, 0.1), white);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.notification-error {
|
|
42
|
+
border-left-color: #dc3545;
|
|
43
|
+
background: linear-gradient(to right, rgba(220, 53, 69, 0.1), white);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.notification-info {
|
|
47
|
+
border-left-color: #007bff;
|
|
48
|
+
background: linear-gradient(to right, rgba(0, 123, 255, 0.1), white);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.notification-content {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 0.75rem;
|
|
55
|
+
flex: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.notification-icon {
|
|
59
|
+
font-size: 1.2rem;
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.notification-message {
|
|
64
|
+
font-size: 0.9rem;
|
|
65
|
+
color: #333;
|
|
66
|
+
line-height: 1.4;
|
|
67
|
+
flex: 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.notification-close {
|
|
71
|
+
background: none;
|
|
72
|
+
border: none;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
color: #999;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
padding: 0;
|
|
77
|
+
width: 20px;
|
|
78
|
+
height: 20px;
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
border-radius: 50%;
|
|
83
|
+
transition: all 0.2s ease;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.notification-close:hover {
|
|
88
|
+
background: rgba(0, 0, 0, 0.1);
|
|
89
|
+
color: #666;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@keyframes slideInRight {
|
|
93
|
+
from {
|
|
94
|
+
transform: translateX(100%);
|
|
95
|
+
opacity: 0;
|
|
96
|
+
}
|
|
97
|
+
to {
|
|
98
|
+
transform: translateX(0);
|
|
99
|
+
opacity: 1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Responsive design */
|
|
104
|
+
@media (max-width: 480px) {
|
|
105
|
+
.call-notifications {
|
|
106
|
+
top: 10px;
|
|
107
|
+
right: 10px;
|
|
108
|
+
left: 10px;
|
|
109
|
+
max-width: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.notification {
|
|
113
|
+
padding: 0.75rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.notification-message {
|
|
117
|
+
font-size: 0.85rem;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useEvent } from 'vg-x07df';
|
|
3
|
+
import './CallNotifications.css';
|
|
4
|
+
|
|
5
|
+
interface Notification {
|
|
6
|
+
id: string;
|
|
7
|
+
message: string;
|
|
8
|
+
type: 'info' | 'warning' | 'error' | 'success';
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function CallNotifications() {
|
|
13
|
+
const [notifications, setNotifications] = useState<Notification[]>([]);
|
|
14
|
+
|
|
15
|
+
// Listen for call-declined events
|
|
16
|
+
useEvent('call:declined', (event) => {
|
|
17
|
+
const notification: Notification = {
|
|
18
|
+
id: `declined-${Date.now()}`,
|
|
19
|
+
message: `Call declined${event.payload.reason ? `: ${event.payload.reason}` : ''}`,
|
|
20
|
+
type: 'warning',
|
|
21
|
+
timestamp: Date.now(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
addNotification(notification);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Listen for call ended events
|
|
28
|
+
useEvent('call:ended', (event) => {
|
|
29
|
+
const notification: Notification = {
|
|
30
|
+
id: `ended-${Date.now()}`,
|
|
31
|
+
message: `Call ended${event.payload.reason ? `: ${event.payload.reason}` : ''}`,
|
|
32
|
+
type: 'info',
|
|
33
|
+
timestamp: Date.now(),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
addNotification(notification);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Listen for participant left events
|
|
40
|
+
useEvent('call:participant-left', (event) => {
|
|
41
|
+
const notification: Notification = {
|
|
42
|
+
id: `left-${Date.now()}`,
|
|
43
|
+
message: `${event.payload.participant.id} left the call`,
|
|
44
|
+
type: 'info',
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
addNotification(notification);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Listen for call accepted events
|
|
52
|
+
useEvent('call:accepted', (event) => {
|
|
53
|
+
const notification: Notification = {
|
|
54
|
+
id: `accepted-${Date.now()}`,
|
|
55
|
+
message: `Participant ${event.payload.participantId} joined the call`,
|
|
56
|
+
type: 'success',
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
addNotification(notification);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const addNotification = (notification: Notification) => {
|
|
64
|
+
setNotifications(prev => [notification, ...prev.slice(0, 4)]); // Keep max 5 notifications
|
|
65
|
+
|
|
66
|
+
// Auto-remove after 5 seconds
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
removeNotification(notification.id);
|
|
69
|
+
}, 5000);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const removeNotification = (id: string) => {
|
|
73
|
+
setNotifications(prev => prev.filter(n => n.id !== id));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
if (notifications.length === 0) return null;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="call-notifications">
|
|
80
|
+
{notifications.map((notification) => (
|
|
81
|
+
<div
|
|
82
|
+
key={notification.id}
|
|
83
|
+
className={`notification notification-${notification.type}`}
|
|
84
|
+
onClick={() => removeNotification(notification.id)}
|
|
85
|
+
>
|
|
86
|
+
<div className="notification-content">
|
|
87
|
+
<span className="notification-icon">
|
|
88
|
+
{notification.type === 'success' && '✅'}
|
|
89
|
+
{notification.type === 'warning' && '⚠️'}
|
|
90
|
+
{notification.type === 'error' && '❌'}
|
|
91
|
+
{notification.type === 'info' && 'ℹ️'}
|
|
92
|
+
</span>
|
|
93
|
+
<span className="notification-message">{notification.message}</span>
|
|
94
|
+
</div>
|
|
95
|
+
<button
|
|
96
|
+
className="notification-close"
|
|
97
|
+
onClick={(e) => {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
removeNotification(notification.id);
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
×
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
))}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|