@telnyx/react-voice-commons-sdk 0.1.0 → 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/TelnyxVoiceCommons.podspec +31 -31
- package/ios/CallKitBridge.m +43 -43
- package/ios/CallKitBridge.swift +879 -879
- package/ios/VoicePnBridge.m +30 -30
- package/ios/VoicePnBridge.swift +86 -86
- 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.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 -155
- package/lib/telnyx-voip-client.js +392 -331
- package/package.json +1 -1
- package/src/telnyx-voip-client.ts +64 -0
|
@@ -1,69 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.getVoipToken = getVoipToken;
|
|
4
4
|
exports.getPendingVoipPush = getPendingVoipPush;
|
|
5
5
|
exports.clearPendingVoipPush = clearPendingVoipPush;
|
|
6
6
|
exports.getPendingVoipAction = getPendingVoipAction;
|
|
7
7
|
exports.clearPendingVoipAction = clearPendingVoipAction;
|
|
8
|
-
const voice_pn_bridge_1 = require(
|
|
9
|
-
const react_native_1 = require(
|
|
8
|
+
const voice_pn_bridge_1 = require('./voice-pn-bridge');
|
|
9
|
+
const react_native_1 = require('react-native');
|
|
10
10
|
/**
|
|
11
11
|
* Helper functions that use VoicePnBridge for UserDefaults functionality on iOS
|
|
12
12
|
* These functions provide the same interface as the UserDefaultsModule from main branch
|
|
13
13
|
* but route through the VoicePnBridge instead
|
|
14
14
|
*/
|
|
15
15
|
async function getVoipToken() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
16
|
+
if (react_native_1.Platform.OS !== 'ios') return null;
|
|
17
|
+
try {
|
|
18
|
+
return await voice_pn_bridge_1.VoicePnBridge.getVoipToken();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.warn('[UserDefaults] getVoipToken error:', error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
25
23
|
}
|
|
26
24
|
async function getPendingVoipPush() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
25
|
+
if (react_native_1.Platform.OS !== 'ios') return null;
|
|
26
|
+
try {
|
|
27
|
+
return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipPush();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn('[UserDefaults] getPendingVoipPush error:', error);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
36
32
|
}
|
|
37
33
|
async function clearPendingVoipPush() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
34
|
+
if (react_native_1.Platform.OS !== 'ios') return true;
|
|
35
|
+
try {
|
|
36
|
+
return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipPush();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.warn('[UserDefaults] clearPendingVoipPush error:', error);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
47
41
|
}
|
|
48
42
|
async function getPendingVoipAction() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
43
|
+
if (react_native_1.Platform.OS !== 'ios') return null;
|
|
44
|
+
try {
|
|
45
|
+
return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipAction();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.warn('[UserDefaults] getPendingVoipAction error:', error);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
58
50
|
}
|
|
59
51
|
async function clearPendingVoipAction() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
52
|
+
if (react_native_1.Platform.OS !== 'ios') return true;
|
|
53
|
+
try {
|
|
54
|
+
return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipAction();
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.warn('[UserDefaults] clearPendingVoipAction error:', error);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
69
59
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export interface VoicePnBridgeInterface {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
getPendingPushAction(): Promise<{
|
|
3
|
+
action: string | null;
|
|
4
|
+
metadata: string | null;
|
|
5
|
+
}>;
|
|
6
|
+
setPendingPushAction(action: string, metadata: string): Promise<boolean>;
|
|
7
|
+
clearPendingPushAction(): Promise<boolean>;
|
|
8
|
+
getVoipToken(): Promise<string | null>;
|
|
9
|
+
getPendingVoipPush(): Promise<string | null>;
|
|
10
|
+
clearPendingVoipPush(): Promise<boolean>;
|
|
11
|
+
getPendingVoipAction(): Promise<string | null>;
|
|
12
|
+
clearPendingVoipAction(): Promise<boolean>;
|
|
13
13
|
}
|
|
14
14
|
export declare const VoicePnBridge: VoicePnBridgeInterface;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.VoicePnBridge = void 0;
|
|
4
|
-
const react_native_1 = require(
|
|
4
|
+
const react_native_1 = require('react-native');
|
|
5
5
|
exports.VoicePnBridge = react_native_1.NativeModules.VoicePnBridge;
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
* the complexity of the underlying SIP call states.
|
|
6
6
|
*/
|
|
7
7
|
export declare enum TelnyxCallState {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
/** Call is being initiated (outgoing) or received (incoming) */
|
|
9
|
+
RINGING = 'RINGING',
|
|
10
|
+
/** Call is connecting after being answered (usually from push notification) */
|
|
11
|
+
CONNECTING = 'CONNECTING',
|
|
12
|
+
/** Call has been answered and media is flowing */
|
|
13
|
+
ACTIVE = 'ACTIVE',
|
|
14
|
+
/** Call is on hold */
|
|
15
|
+
HELD = 'HELD',
|
|
16
|
+
/** Call has ended normally */
|
|
17
|
+
ENDED = 'ENDED',
|
|
18
|
+
/** Call failed to connect or was rejected */
|
|
19
|
+
FAILED = 'FAILED',
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Type guard to check if a value is a valid TelnyxCallState
|
|
@@ -26,36 +26,36 @@ export declare function isTelnyxCallState(value: any): value is TelnyxCallState;
|
|
|
26
26
|
* Helper functions to determine what actions are available in each state
|
|
27
27
|
*/
|
|
28
28
|
export declare const CallStateHelpers: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Can the call be answered in this state?
|
|
31
|
+
*/
|
|
32
|
+
canAnswer(state: TelnyxCallState): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Can the call be hung up in this state?
|
|
35
|
+
*/
|
|
36
|
+
canHangup(state: TelnyxCallState): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Can the call be put on hold in this state?
|
|
39
|
+
*/
|
|
40
|
+
canHold(state: TelnyxCallState): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Can the call be resumed from hold in this state?
|
|
43
|
+
*/
|
|
44
|
+
canResume(state: TelnyxCallState): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Can the call be muted/unmuted in this state?
|
|
47
|
+
*/
|
|
48
|
+
canToggleMute(state: TelnyxCallState): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Is the call in a terminated state?
|
|
51
|
+
*/
|
|
52
|
+
isTerminated(state: TelnyxCallState): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Is the call in an active state (can have media)?
|
|
55
|
+
*/
|
|
56
|
+
isActive(state: TelnyxCallState): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Is the call in a connecting state (answered but not yet active)?
|
|
59
|
+
*/
|
|
60
|
+
isConnecting(state: TelnyxCallState): boolean;
|
|
61
61
|
};
|
package/lib/models/call-state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.CallStateHelpers = exports.TelnyxCallState = void 0;
|
|
4
4
|
exports.isTelnyxCallState = isTelnyxCallState;
|
|
5
5
|
/**
|
|
@@ -10,78 +10,80 @@ exports.isTelnyxCallState = isTelnyxCallState;
|
|
|
10
10
|
*/
|
|
11
11
|
var TelnyxCallState;
|
|
12
12
|
(function (TelnyxCallState) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
/** Call is being initiated (outgoing) or received (incoming) */
|
|
14
|
+
TelnyxCallState['RINGING'] = 'RINGING';
|
|
15
|
+
/** Call is connecting after being answered (usually from push notification) */
|
|
16
|
+
TelnyxCallState['CONNECTING'] = 'CONNECTING';
|
|
17
|
+
/** Call has been answered and media is flowing */
|
|
18
|
+
TelnyxCallState['ACTIVE'] = 'ACTIVE';
|
|
19
|
+
/** Call is on hold */
|
|
20
|
+
TelnyxCallState['HELD'] = 'HELD';
|
|
21
|
+
/** Call has ended normally */
|
|
22
|
+
TelnyxCallState['ENDED'] = 'ENDED';
|
|
23
|
+
/** Call failed to connect or was rejected */
|
|
24
|
+
TelnyxCallState['FAILED'] = 'FAILED';
|
|
25
25
|
})(TelnyxCallState || (exports.TelnyxCallState = TelnyxCallState = {}));
|
|
26
26
|
/**
|
|
27
27
|
* Type guard to check if a value is a valid TelnyxCallState
|
|
28
28
|
*/
|
|
29
29
|
function isTelnyxCallState(value) {
|
|
30
|
-
|
|
30
|
+
return Object.values(TelnyxCallState).includes(value);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Helper functions to determine what actions are available in each state
|
|
34
34
|
*/
|
|
35
35
|
exports.CallStateHelpers = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Can the call be answered in this state?
|
|
38
|
+
*/
|
|
39
|
+
canAnswer(state) {
|
|
40
|
+
return state === TelnyxCallState.RINGING;
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Can the call be hung up in this state?
|
|
44
|
+
*/
|
|
45
|
+
canHangup(state) {
|
|
46
|
+
return (
|
|
47
|
+
state === TelnyxCallState.RINGING ||
|
|
48
|
+
state === TelnyxCallState.CONNECTING ||
|
|
49
|
+
state === TelnyxCallState.ACTIVE ||
|
|
50
|
+
state === TelnyxCallState.HELD
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Can the call be put on hold in this state?
|
|
55
|
+
*/
|
|
56
|
+
canHold(state) {
|
|
57
|
+
return state === TelnyxCallState.ACTIVE;
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Can the call be resumed from hold in this state?
|
|
61
|
+
*/
|
|
62
|
+
canResume(state) {
|
|
63
|
+
return state === TelnyxCallState.HELD;
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Can the call be muted/unmuted in this state?
|
|
67
|
+
*/
|
|
68
|
+
canToggleMute(state) {
|
|
69
|
+
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Is the call in a terminated state?
|
|
73
|
+
*/
|
|
74
|
+
isTerminated(state) {
|
|
75
|
+
return state === TelnyxCallState.ENDED || state === TelnyxCallState.FAILED;
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Is the call in an active state (can have media)?
|
|
79
|
+
*/
|
|
80
|
+
isActive(state) {
|
|
81
|
+
return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Is the call in a connecting state (answered but not yet active)?
|
|
85
|
+
*/
|
|
86
|
+
isConnecting(state) {
|
|
87
|
+
return state === TelnyxCallState.CONNECTING;
|
|
88
|
+
},
|
|
87
89
|
};
|