@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.
Files changed (47) hide show
  1. package/README.md +483 -0
  2. package/TelnyxVoiceCommons.podspec +31 -31
  3. package/ios/CallKitBridge.m +43 -43
  4. package/ios/CallKitBridge.swift +879 -879
  5. package/ios/VoicePnBridge.m +30 -30
  6. package/ios/VoicePnBridge.swift +86 -86
  7. package/lib/callkit/callkit-coordinator.d.ts +117 -113
  8. package/lib/callkit/callkit-coordinator.js +727 -681
  9. package/lib/callkit/callkit.d.ts +41 -41
  10. package/lib/callkit/callkit.js +242 -252
  11. package/lib/callkit/index.js +47 -15
  12. package/lib/callkit/use-callkit.d.ts +19 -19
  13. package/lib/callkit/use-callkit.js +310 -270
  14. package/lib/context/TelnyxVoiceContext.d.ts +9 -9
  15. package/lib/context/TelnyxVoiceContext.js +13 -10
  16. package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
  17. package/lib/hooks/use-callkit-coordinator.js +50 -45
  18. package/lib/hooks/useAppReadyNotifier.js +15 -13
  19. package/lib/hooks/useAppStateHandler.d.ts +11 -6
  20. package/lib/hooks/useAppStateHandler.js +110 -95
  21. package/lib/index.d.ts +21 -3
  22. package/lib/index.js +201 -50
  23. package/lib/internal/CallKitHandler.d.ts +6 -6
  24. package/lib/internal/CallKitHandler.js +104 -96
  25. package/lib/internal/callkit-manager.d.ts +57 -57
  26. package/lib/internal/callkit-manager.js +316 -299
  27. package/lib/internal/calls/call-state-controller.d.ts +86 -81
  28. package/lib/internal/calls/call-state-controller.js +307 -269
  29. package/lib/internal/session/session-manager.d.ts +75 -75
  30. package/lib/internal/session/session-manager.js +424 -350
  31. package/lib/internal/user-defaults-helpers.js +39 -49
  32. package/lib/internal/voice-pn-bridge.d.ts +11 -11
  33. package/lib/internal/voice-pn-bridge.js +3 -3
  34. package/lib/models/call-state.d.ts +44 -44
  35. package/lib/models/call-state.js +68 -66
  36. package/lib/models/call.d.ts +133 -133
  37. package/lib/models/call.js +382 -354
  38. package/lib/models/config.d.ts +18 -11
  39. package/lib/models/config.js +35 -37
  40. package/lib/models/connection-state.d.ts +10 -10
  41. package/lib/models/connection-state.js +16 -16
  42. package/lib/telnyx-voice-app.d.ts +28 -28
  43. package/lib/telnyx-voice-app.js +482 -424
  44. package/lib/telnyx-voip-client.d.ts +167 -155
  45. package/lib/telnyx-voip-client.js +392 -331
  46. package/package.json +1 -1
  47. package/src/telnyx-voip-client.ts +64 -0
@@ -1,69 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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("./voice-pn-bridge");
9
- const react_native_1 = require("react-native");
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
- if (react_native_1.Platform.OS !== 'ios')
17
- return null;
18
- try {
19
- return await voice_pn_bridge_1.VoicePnBridge.getVoipToken();
20
- }
21
- catch (error) {
22
- console.warn('[UserDefaults] getVoipToken error:', error);
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
- if (react_native_1.Platform.OS !== 'ios')
28
- return null;
29
- try {
30
- return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipPush();
31
- }
32
- catch (error) {
33
- console.warn('[UserDefaults] getPendingVoipPush error:', error);
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
- if (react_native_1.Platform.OS !== 'ios')
39
- return true;
40
- try {
41
- return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipPush();
42
- }
43
- catch (error) {
44
- console.warn('[UserDefaults] clearPendingVoipPush error:', error);
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
- if (react_native_1.Platform.OS !== 'ios')
50
- return null;
51
- try {
52
- return await voice_pn_bridge_1.VoicePnBridge.getPendingVoipAction();
53
- }
54
- catch (error) {
55
- console.warn('[UserDefaults] getPendingVoipAction error:', error);
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
- if (react_native_1.Platform.OS !== 'ios')
61
- return true;
62
- try {
63
- return await voice_pn_bridge_1.VoicePnBridge.clearPendingVoipAction();
64
- }
65
- catch (error) {
66
- console.warn('[UserDefaults] clearPendingVoipAction error:', error);
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
- 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>;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
3
  exports.VoicePnBridge = void 0;
4
- const react_native_1 = require("react-native");
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
- /** 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"
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
- * 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;
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
  };
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- /** 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";
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
- return Object.values(TelnyxCallState).includes(value);
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
- * 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 (state === TelnyxCallState.RINGING ||
47
- state === TelnyxCallState.CONNECTING ||
48
- state === TelnyxCallState.ACTIVE ||
49
- state === TelnyxCallState.HELD);
50
- },
51
- /**
52
- * Can the call be put on hold in this state?
53
- */
54
- canHold(state) {
55
- return state === TelnyxCallState.ACTIVE;
56
- },
57
- /**
58
- * Can the call be resumed from hold in this state?
59
- */
60
- canResume(state) {
61
- return state === TelnyxCallState.HELD;
62
- },
63
- /**
64
- * Can the call be muted/unmuted in this state?
65
- */
66
- canToggleMute(state) {
67
- return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
68
- },
69
- /**
70
- * Is the call in a terminated state?
71
- */
72
- isTerminated(state) {
73
- return state === TelnyxCallState.ENDED || state === TelnyxCallState.FAILED;
74
- },
75
- /**
76
- * Is the call in an active state (can have media)?
77
- */
78
- isActive(state) {
79
- return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
80
- },
81
- /**
82
- * Is the call in a connecting state (answered but not yet active)?
83
- */
84
- isConnecting(state) {
85
- return state === TelnyxCallState.CONNECTING;
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
  };