@telnyx/react-voice-commons-sdk 0.1.1 → 0.1.2
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 +483 -0
- package/ios/README.md +211 -211
- package/lib/callkit/callkit-coordinator.d.ts +117 -113
- package/lib/callkit/callkit-coordinator.js +727 -681
- package/lib/callkit/callkit.d.ts +41 -41
- package/lib/callkit/callkit.js +242 -252
- package/lib/callkit/index.js +47 -15
- package/lib/callkit/use-callkit-coordinator.d.ts +21 -21
- package/lib/callkit/use-callkit-coordinator.js +53 -53
- package/lib/callkit/use-callkit.d.ts +19 -19
- package/lib/callkit/use-callkit.js +310 -270
- package/lib/context/TelnyxVoiceContext.d.ts +9 -9
- package/lib/context/TelnyxVoiceContext.js +13 -10
- package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
- package/lib/hooks/use-callkit-coordinator.js +50 -45
- package/lib/hooks/useAppReadyNotifier.js +15 -13
- package/lib/hooks/useAppStateHandler.d.ts +11 -6
- package/lib/hooks/useAppStateHandler.js +110 -95
- package/lib/index.d.ts +21 -3
- package/lib/index.js +201 -50
- package/lib/internal/CallKitHandler.d.ts +6 -6
- package/lib/internal/CallKitHandler.js +104 -96
- package/lib/internal/callkit-manager.d.ts +57 -57
- package/lib/internal/callkit-manager.js +316 -299
- package/lib/internal/calls/call-state-controller.d.ts +86 -81
- package/lib/internal/calls/call-state-controller.js +307 -269
- package/lib/internal/session/session-manager.d.ts +75 -75
- package/lib/internal/session/session-manager.js +424 -350
- package/lib/internal/user-defaults-helpers.js +39 -49
- package/lib/internal/voice-pn-bridge.d.ts +11 -11
- package/lib/internal/voice-pn-bridge.js +3 -3
- package/lib/models/call-state.d.ts +44 -44
- package/lib/models/call-state.js +68 -66
- package/lib/models/call.d.ts +133 -133
- package/lib/models/call.js +382 -354
- package/lib/models/config.d.ts +18 -11
- package/lib/models/config.js +35 -37
- package/lib/models/connection-state.d.ts +10 -10
- package/lib/models/connection-state.js +16 -16
- package/lib/telnyx-voice-app.d.ts +28 -28
- package/lib/telnyx-voice-app.js +482 -424
- package/lib/telnyx-voip-client.d.ts +167 -165
- package/lib/telnyx-voip-client.js +390 -383
- package/package.json +104 -104
- package/src/callkit/callkit-coordinator.ts +846 -846
- package/src/callkit/callkit.ts +322 -322
- package/src/callkit/index.ts +4 -4
- package/src/callkit/use-callkit.ts +345 -345
- package/src/context/TelnyxVoiceContext.tsx +33 -33
- package/src/hooks/use-callkit-coordinator.ts +60 -60
- package/src/hooks/useAppReadyNotifier.ts +25 -25
- package/src/hooks/useAppStateHandler.ts +134 -134
- package/src/index.ts +56 -56
- package/src/internal/CallKitHandler.tsx +149 -149
- package/src/internal/callkit-manager.ts +335 -335
- package/src/internal/calls/call-state-controller.ts +384 -384
- package/src/internal/session/session-manager.ts +467 -467
- package/src/internal/user-defaults-helpers.ts +58 -58
- package/src/internal/voice-pn-bridge.ts +18 -18
- package/src/models/call-state.ts +98 -98
- package/src/models/call.ts +388 -388
- package/src/models/config.ts +125 -125
- package/src/models/connection-state.ts +50 -50
- package/src/telnyx-voice-app.tsx +690 -690
- package/src/telnyx-voip-client.ts +539 -539
- package/src/types/telnyx-sdk.d.ts +79 -79
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { VoicePnBridge } from './voice-pn-bridge';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Helper functions that use VoicePnBridge for UserDefaults functionality on iOS
|
|
6
|
-
* These functions provide the same interface as the UserDefaultsModule from main branch
|
|
7
|
-
* but route through the VoicePnBridge instead
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export async function getVoipToken(): Promise<string | null> {
|
|
11
|
-
if (Platform.OS !== 'ios') return null;
|
|
12
|
-
try {
|
|
13
|
-
return await VoicePnBridge.getVoipToken();
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.warn('[UserDefaults] getVoipToken error:', error);
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function getPendingVoipPush(): Promise<string | null> {
|
|
21
|
-
if (Platform.OS !== 'ios') return null;
|
|
22
|
-
try {
|
|
23
|
-
return await VoicePnBridge.getPendingVoipPush();
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.warn('[UserDefaults] getPendingVoipPush error:', error);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function clearPendingVoipPush(): Promise<boolean> {
|
|
31
|
-
if (Platform.OS !== 'ios') return true;
|
|
32
|
-
try {
|
|
33
|
-
return await VoicePnBridge.clearPendingVoipPush();
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.warn('[UserDefaults] clearPendingVoipPush error:', error);
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function getPendingVoipAction(): Promise<string | null> {
|
|
41
|
-
if (Platform.OS !== 'ios') return null;
|
|
42
|
-
try {
|
|
43
|
-
return await VoicePnBridge.getPendingVoipAction();
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.warn('[UserDefaults] getPendingVoipAction error:', error);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export async function clearPendingVoipAction(): Promise<boolean> {
|
|
51
|
-
if (Platform.OS !== 'ios') return true;
|
|
52
|
-
try {
|
|
53
|
-
return await VoicePnBridge.clearPendingVoipAction();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.warn('[UserDefaults] clearPendingVoipAction error:', error);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
import { VoicePnBridge } from './voice-pn-bridge';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Helper functions that use VoicePnBridge for UserDefaults functionality on iOS
|
|
6
|
+
* These functions provide the same interface as the UserDefaultsModule from main branch
|
|
7
|
+
* but route through the VoicePnBridge instead
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export async function getVoipToken(): Promise<string | null> {
|
|
11
|
+
if (Platform.OS !== 'ios') return null;
|
|
12
|
+
try {
|
|
13
|
+
return await VoicePnBridge.getVoipToken();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.warn('[UserDefaults] getVoipToken error:', error);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function getPendingVoipPush(): Promise<string | null> {
|
|
21
|
+
if (Platform.OS !== 'ios') return null;
|
|
22
|
+
try {
|
|
23
|
+
return await VoicePnBridge.getPendingVoipPush();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.warn('[UserDefaults] getPendingVoipPush error:', error);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function clearPendingVoipPush(): Promise<boolean> {
|
|
31
|
+
if (Platform.OS !== 'ios') return true;
|
|
32
|
+
try {
|
|
33
|
+
return await VoicePnBridge.clearPendingVoipPush();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.warn('[UserDefaults] clearPendingVoipPush error:', error);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function getPendingVoipAction(): Promise<string | null> {
|
|
41
|
+
if (Platform.OS !== 'ios') return null;
|
|
42
|
+
try {
|
|
43
|
+
return await VoicePnBridge.getPendingVoipAction();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.warn('[UserDefaults] getPendingVoipAction error:', error);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function clearPendingVoipAction(): Promise<boolean> {
|
|
51
|
+
if (Platform.OS !== 'ios') return true;
|
|
52
|
+
try {
|
|
53
|
+
return await VoicePnBridge.clearPendingVoipAction();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.warn('[UserDefaults] clearPendingVoipAction error:', error);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
|
-
|
|
3
|
-
export interface VoicePnBridgeInterface {
|
|
4
|
-
getPendingPushAction(): Promise<{
|
|
5
|
-
action: string | null;
|
|
6
|
-
metadata: string | null;
|
|
7
|
-
}>;
|
|
8
|
-
setPendingPushAction(action: string, metadata: string): Promise<boolean>;
|
|
9
|
-
clearPendingPushAction(): Promise<boolean>;
|
|
10
|
-
// Additional UserDefaults methods
|
|
11
|
-
getVoipToken(): Promise<string | null>;
|
|
12
|
-
getPendingVoipPush(): Promise<string | null>;
|
|
13
|
-
clearPendingVoipPush(): Promise<boolean>;
|
|
14
|
-
getPendingVoipAction(): Promise<string | null>;
|
|
15
|
-
clearPendingVoipAction(): Promise<boolean>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const VoicePnBridge: VoicePnBridgeInterface = NativeModules.VoicePnBridge;
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export interface VoicePnBridgeInterface {
|
|
4
|
+
getPendingPushAction(): Promise<{
|
|
5
|
+
action: string | null;
|
|
6
|
+
metadata: string | null;
|
|
7
|
+
}>;
|
|
8
|
+
setPendingPushAction(action: string, metadata: string): Promise<boolean>;
|
|
9
|
+
clearPendingPushAction(): Promise<boolean>;
|
|
10
|
+
// Additional UserDefaults methods
|
|
11
|
+
getVoipToken(): Promise<string | null>;
|
|
12
|
+
getPendingVoipPush(): Promise<string | null>;
|
|
13
|
+
clearPendingVoipPush(): Promise<boolean>;
|
|
14
|
+
getPendingVoipAction(): Promise<string | null>;
|
|
15
|
+
clearPendingVoipAction(): Promise<boolean>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const VoicePnBridge: VoicePnBridgeInterface = NativeModules.VoicePnBridge;
|
package/src/models/call-state.ts
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the state of a call in the Telnyx system.
|
|
3
|
-
*
|
|
4
|
-
* This enum provides a simplified view of call states, abstracting away
|
|
5
|
-
* the complexity of the underlying SIP call states.
|
|
6
|
-
*/
|
|
7
|
-
export enum TelnyxCallState {
|
|
8
|
-
/** Call is being initiated (outgoing) or received (incoming) */
|
|
9
|
-
RINGING = 'RINGING',
|
|
10
|
-
|
|
11
|
-
/** Call is connecting after being answered (usually from push notification) */
|
|
12
|
-
CONNECTING = 'CONNECTING',
|
|
13
|
-
|
|
14
|
-
/** Call has been answered and media is flowing */
|
|
15
|
-
ACTIVE = 'ACTIVE',
|
|
16
|
-
|
|
17
|
-
/** Call is on hold */
|
|
18
|
-
HELD = 'HELD',
|
|
19
|
-
|
|
20
|
-
/** Call has ended normally */
|
|
21
|
-
ENDED = 'ENDED',
|
|
22
|
-
|
|
23
|
-
/** Call failed to connect or was rejected */
|
|
24
|
-
FAILED = 'FAILED',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Type guard to check if a value is a valid TelnyxCallState
|
|
29
|
-
*/
|
|
30
|
-
export function isTelnyxCallState(value: any): value is TelnyxCallState {
|
|
31
|
-
return Object.values(TelnyxCallState).includes(value);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Helper functions to determine what actions are available in each state
|
|
36
|
-
*/
|
|
37
|
-
export const CallStateHelpers = {
|
|
38
|
-
/**
|
|
39
|
-
* Can the call be answered in this state?
|
|
40
|
-
*/
|
|
41
|
-
canAnswer(state: TelnyxCallState): boolean {
|
|
42
|
-
return state === TelnyxCallState.RINGING;
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Can the call be hung up in this state?
|
|
47
|
-
*/
|
|
48
|
-
canHangup(state: TelnyxCallState): boolean {
|
|
49
|
-
return (
|
|
50
|
-
state === TelnyxCallState.RINGING ||
|
|
51
|
-
state === TelnyxCallState.CONNECTING ||
|
|
52
|
-
state === TelnyxCallState.ACTIVE ||
|
|
53
|
-
state === TelnyxCallState.HELD
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Can the call be put on hold in this state?
|
|
59
|
-
*/
|
|
60
|
-
canHold(state: TelnyxCallState): boolean {
|
|
61
|
-
return state === TelnyxCallState.ACTIVE;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Can the call be resumed from hold in this state?
|
|
66
|
-
*/
|
|
67
|
-
canResume(state: TelnyxCallState): boolean {
|
|
68
|
-
return state === TelnyxCallState.HELD;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Can the call be muted/unmuted in this state?
|
|
73
|
-
*/
|
|
74
|
-
canToggleMute(state: TelnyxCallState): boolean {
|
|
75
|
-
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Is the call in a terminated state?
|
|
80
|
-
*/
|
|
81
|
-
isTerminated(state: TelnyxCallState): boolean {
|
|
82
|
-
return state === TelnyxCallState.ENDED || state === TelnyxCallState.FAILED;
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Is the call in an active state (can have media)?
|
|
87
|
-
*/
|
|
88
|
-
isActive(state: TelnyxCallState): boolean {
|
|
89
|
-
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Is the call in a connecting state (answered but not yet active)?
|
|
94
|
-
*/
|
|
95
|
-
isConnecting(state: TelnyxCallState): boolean {
|
|
96
|
-
return state === TelnyxCallState.CONNECTING;
|
|
97
|
-
},
|
|
98
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Represents the state of a call in the Telnyx system.
|
|
3
|
+
*
|
|
4
|
+
* This enum provides a simplified view of call states, abstracting away
|
|
5
|
+
* the complexity of the underlying SIP call states.
|
|
6
|
+
*/
|
|
7
|
+
export enum TelnyxCallState {
|
|
8
|
+
/** Call is being initiated (outgoing) or received (incoming) */
|
|
9
|
+
RINGING = 'RINGING',
|
|
10
|
+
|
|
11
|
+
/** Call is connecting after being answered (usually from push notification) */
|
|
12
|
+
CONNECTING = 'CONNECTING',
|
|
13
|
+
|
|
14
|
+
/** Call has been answered and media is flowing */
|
|
15
|
+
ACTIVE = 'ACTIVE',
|
|
16
|
+
|
|
17
|
+
/** Call is on hold */
|
|
18
|
+
HELD = 'HELD',
|
|
19
|
+
|
|
20
|
+
/** Call has ended normally */
|
|
21
|
+
ENDED = 'ENDED',
|
|
22
|
+
|
|
23
|
+
/** Call failed to connect or was rejected */
|
|
24
|
+
FAILED = 'FAILED',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Type guard to check if a value is a valid TelnyxCallState
|
|
29
|
+
*/
|
|
30
|
+
export function isTelnyxCallState(value: any): value is TelnyxCallState {
|
|
31
|
+
return Object.values(TelnyxCallState).includes(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Helper functions to determine what actions are available in each state
|
|
36
|
+
*/
|
|
37
|
+
export const CallStateHelpers = {
|
|
38
|
+
/**
|
|
39
|
+
* Can the call be answered in this state?
|
|
40
|
+
*/
|
|
41
|
+
canAnswer(state: TelnyxCallState): boolean {
|
|
42
|
+
return state === TelnyxCallState.RINGING;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Can the call be hung up in this state?
|
|
47
|
+
*/
|
|
48
|
+
canHangup(state: TelnyxCallState): boolean {
|
|
49
|
+
return (
|
|
50
|
+
state === TelnyxCallState.RINGING ||
|
|
51
|
+
state === TelnyxCallState.CONNECTING ||
|
|
52
|
+
state === TelnyxCallState.ACTIVE ||
|
|
53
|
+
state === TelnyxCallState.HELD
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Can the call be put on hold in this state?
|
|
59
|
+
*/
|
|
60
|
+
canHold(state: TelnyxCallState): boolean {
|
|
61
|
+
return state === TelnyxCallState.ACTIVE;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Can the call be resumed from hold in this state?
|
|
66
|
+
*/
|
|
67
|
+
canResume(state: TelnyxCallState): boolean {
|
|
68
|
+
return state === TelnyxCallState.HELD;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Can the call be muted/unmuted in this state?
|
|
73
|
+
*/
|
|
74
|
+
canToggleMute(state: TelnyxCallState): boolean {
|
|
75
|
+
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Is the call in a terminated state?
|
|
80
|
+
*/
|
|
81
|
+
isTerminated(state: TelnyxCallState): boolean {
|
|
82
|
+
return state === TelnyxCallState.ENDED || state === TelnyxCallState.FAILED;
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Is the call in an active state (can have media)?
|
|
87
|
+
*/
|
|
88
|
+
isActive(state: TelnyxCallState): boolean {
|
|
89
|
+
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Is the call in a connecting state (answered but not yet active)?
|
|
94
|
+
*/
|
|
95
|
+
isConnecting(state: TelnyxCallState): boolean {
|
|
96
|
+
return state === TelnyxCallState.CONNECTING;
|
|
97
|
+
},
|
|
98
|
+
};
|