@telnyx/react-voice-commons-sdk 0.1.4 → 0.1.5

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 (56) hide show
  1. package/CHANGELOG.md +19 -16
  2. package/README.md +469 -469
  3. package/TelnyxVoiceCommons.podspec +31 -31
  4. package/ios/CallKitBridge.m +43 -43
  5. package/ios/CallKitBridge.swift +874 -874
  6. package/ios/VoicePnBridge.m +30 -30
  7. package/ios/VoicePnBridge.swift +86 -86
  8. package/lib/callkit/callkit-coordinator.d.ts +114 -110
  9. package/lib/callkit/callkit-coordinator.js +706 -664
  10. package/lib/callkit/callkit.d.ts +41 -41
  11. package/lib/callkit/callkit.js +242 -252
  12. package/lib/callkit/index.js +47 -15
  13. package/lib/callkit/use-callkit.d.ts +19 -19
  14. package/lib/callkit/use-callkit.js +310 -270
  15. package/lib/context/TelnyxVoiceContext.d.ts +9 -9
  16. package/lib/context/TelnyxVoiceContext.js +13 -10
  17. package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
  18. package/lib/hooks/use-callkit-coordinator.js +50 -45
  19. package/lib/hooks/useAppReadyNotifier.js +15 -13
  20. package/lib/hooks/useAppStateHandler.d.ts +11 -6
  21. package/lib/hooks/useAppStateHandler.js +110 -95
  22. package/lib/index.d.ts +21 -3
  23. package/lib/index.js +201 -50
  24. package/lib/internal/CallKitHandler.d.ts +6 -6
  25. package/lib/internal/CallKitHandler.js +104 -96
  26. package/lib/internal/callkit-manager.d.ts +57 -57
  27. package/lib/internal/callkit-manager.js +316 -299
  28. package/lib/internal/calls/call-state-controller.d.ts +78 -73
  29. package/lib/internal/calls/call-state-controller.js +326 -265
  30. package/lib/internal/session/session-manager.d.ts +71 -71
  31. package/lib/internal/session/session-manager.js +437 -360
  32. package/lib/internal/user-defaults-helpers.js +39 -49
  33. package/lib/internal/voice-pn-bridge.d.ts +112 -104
  34. package/lib/internal/voice-pn-bridge.js +193 -203
  35. package/lib/models/call-state.d.ts +46 -46
  36. package/lib/models/call-state.js +74 -70
  37. package/lib/models/call.d.ts +173 -157
  38. package/lib/models/call.js +492 -448
  39. package/lib/models/config.d.ts +18 -11
  40. package/lib/models/config.js +35 -37
  41. package/lib/models/connection-state.d.ts +10 -10
  42. package/lib/models/connection-state.js +16 -16
  43. package/lib/telnyx-voice-app.d.ts +28 -28
  44. package/lib/telnyx-voice-app.js +561 -509
  45. package/lib/telnyx-voip-client.d.ts +174 -167
  46. package/lib/telnyx-voip-client.js +397 -385
  47. package/package.json +115 -115
  48. package/src/callkit/callkit-coordinator.ts +830 -830
  49. package/src/internal/calls/call-state-controller.ts +407 -407
  50. package/src/internal/session/session-manager.ts +483 -483
  51. package/src/internal/voice-pn-bridge.ts +266 -266
  52. package/src/models/call-state.ts +105 -105
  53. package/src/models/call.ts +502 -502
  54. package/src/telnyx-voice-app.tsx +787 -788
  55. package/src/telnyx-voip-client.ts +551 -551
  56. package/src/types/telnyx-sdk.d.ts +93 -93
@@ -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,82 +10,86 @@ 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";
25
- /** Call was dropped due to network issues */
26
- TelnyxCallState["DROPPED"] = "DROPPED";
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
+ /** Call was dropped due to network issues */
26
+ TelnyxCallState['DROPPED'] = 'DROPPED';
27
27
  })(TelnyxCallState || (exports.TelnyxCallState = TelnyxCallState = {}));
28
28
  /**
29
29
  * Type guard to check if a value is a valid TelnyxCallState
30
30
  */
31
31
  function isTelnyxCallState(value) {
32
- return Object.values(TelnyxCallState).includes(value);
32
+ return Object.values(TelnyxCallState).includes(value);
33
33
  }
34
34
  /**
35
35
  * Helper functions to determine what actions are available in each state
36
36
  */
37
37
  exports.CallStateHelpers = {
38
- /**
39
- * Can the call be answered in this state?
40
- */
41
- canAnswer(state) {
42
- return state === TelnyxCallState.RINGING;
43
- },
44
- /**
45
- * Can the call be hung up in this state?
46
- */
47
- canHangup(state) {
48
- return (state === TelnyxCallState.RINGING ||
49
- state === TelnyxCallState.CONNECTING ||
50
- state === TelnyxCallState.ACTIVE ||
51
- state === TelnyxCallState.HELD);
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 ||
76
- state === TelnyxCallState.FAILED ||
77
- state === TelnyxCallState.DROPPED);
78
- },
79
- /**
80
- * Is the call in an active state (can have media)?
81
- */
82
- isActive(state) {
83
- return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
84
- },
85
- /**
86
- * Is the call in a connecting state (answered but not yet active)?
87
- */
88
- isConnecting(state) {
89
- return state === TelnyxCallState.CONNECTING;
90
- },
38
+ /**
39
+ * Can the call be answered in this state?
40
+ */
41
+ canAnswer(state) {
42
+ return state === TelnyxCallState.RINGING;
43
+ },
44
+ /**
45
+ * Can the call be hung up in this state?
46
+ */
47
+ canHangup(state) {
48
+ return (
49
+ state === TelnyxCallState.RINGING ||
50
+ state === TelnyxCallState.CONNECTING ||
51
+ state === TelnyxCallState.ACTIVE ||
52
+ state === TelnyxCallState.HELD
53
+ );
54
+ },
55
+ /**
56
+ * Can the call be put on hold in this state?
57
+ */
58
+ canHold(state) {
59
+ return state === TelnyxCallState.ACTIVE;
60
+ },
61
+ /**
62
+ * Can the call be resumed from hold in this state?
63
+ */
64
+ canResume(state) {
65
+ return state === TelnyxCallState.HELD;
66
+ },
67
+ /**
68
+ * Can the call be muted/unmuted in this state?
69
+ */
70
+ canToggleMute(state) {
71
+ return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
72
+ },
73
+ /**
74
+ * Is the call in a terminated state?
75
+ */
76
+ isTerminated(state) {
77
+ return (
78
+ state === TelnyxCallState.ENDED ||
79
+ state === TelnyxCallState.FAILED ||
80
+ state === TelnyxCallState.DROPPED
81
+ );
82
+ },
83
+ /**
84
+ * Is the call in an active state (can have media)?
85
+ */
86
+ isActive(state) {
87
+ return state === TelnyxCallState.ACTIVE || state === TelnyxCallState.HELD;
88
+ },
89
+ /**
90
+ * Is the call in a connecting state (answered but not yet active)?
91
+ */
92
+ isConnecting(state) {
93
+ return state === TelnyxCallState.CONNECTING;
94
+ },
91
95
  };
@@ -9,165 +9,181 @@ import { Call as TelnyxCall } from '@telnyx/react-native-voice-sdk';
9
9
  * integrate with any state management solution.
10
10
  */
11
11
  export declare class Call {
12
- private readonly _telnyxCall;
13
- private readonly _callId;
14
- private readonly _destination;
15
- private readonly _isIncoming;
16
- private readonly _originalCallerName?;
17
- private readonly _originalCallerNumber?;
18
- private readonly _callState;
19
- private readonly _isMuted;
20
- private readonly _isHeld;
21
- private readonly _duration;
22
- private _durationTimer?;
23
- private _startTime?;
24
- constructor(_telnyxCall: TelnyxCall, _callId: string, _destination: string, _isIncoming: boolean, isReattached?: boolean, _originalCallerName?: string, _originalCallerNumber?: string);
25
- /**
26
- * Unique identifier for this call
27
- */
28
- get callId(): string;
29
- /**
30
- * The destination number or SIP URI
31
- */
32
- get destination(): string;
33
- /**
34
- * Whether this is an incoming call
35
- */
36
- get isIncoming(): boolean;
37
- /**
38
- * Whether this is an outgoing call
39
- */
40
- get isOutgoing(): boolean;
41
- /**
42
- * Current call state (synchronous access)
43
- */
44
- get currentState(): TelnyxCallState;
45
- /**
46
- * Current mute state (synchronous access)
47
- */
48
- get currentIsMuted(): boolean;
49
- /**
50
- * Current hold state (synchronous access)
51
- */
52
- get currentIsHeld(): boolean;
53
- /**
54
- * Current call duration in seconds (synchronous access)
55
- */
56
- get currentDuration(): number;
57
- /**
58
- * Custom headers received from the WebRTC INVITE message.
59
- * These headers are passed during call initiation and can contain application-specific information.
60
- * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
61
- */
62
- get inviteCustomHeaders(): {
12
+ private readonly _telnyxCall;
13
+ private readonly _callId;
14
+ private readonly _destination;
15
+ private readonly _isIncoming;
16
+ private readonly _originalCallerName?;
17
+ private readonly _originalCallerNumber?;
18
+ private readonly _callState;
19
+ private readonly _isMuted;
20
+ private readonly _isHeld;
21
+ private readonly _duration;
22
+ private _durationTimer?;
23
+ private _startTime?;
24
+ constructor(
25
+ _telnyxCall: TelnyxCall,
26
+ _callId: string,
27
+ _destination: string,
28
+ _isIncoming: boolean,
29
+ isReattached?: boolean,
30
+ _originalCallerName?: string,
31
+ _originalCallerNumber?: string
32
+ );
33
+ /**
34
+ * Unique identifier for this call
35
+ */
36
+ get callId(): string;
37
+ /**
38
+ * The destination number or SIP URI
39
+ */
40
+ get destination(): string;
41
+ /**
42
+ * Whether this is an incoming call
43
+ */
44
+ get isIncoming(): boolean;
45
+ /**
46
+ * Whether this is an outgoing call
47
+ */
48
+ get isOutgoing(): boolean;
49
+ /**
50
+ * Current call state (synchronous access)
51
+ */
52
+ get currentState(): TelnyxCallState;
53
+ /**
54
+ * Current mute state (synchronous access)
55
+ */
56
+ get currentIsMuted(): boolean;
57
+ /**
58
+ * Current hold state (synchronous access)
59
+ */
60
+ get currentIsHeld(): boolean;
61
+ /**
62
+ * Current call duration in seconds (synchronous access)
63
+ */
64
+ get currentDuration(): number;
65
+ /**
66
+ * Custom headers received from the WebRTC INVITE message.
67
+ * These headers are passed during call initiation and can contain application-specific information.
68
+ * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
69
+ */
70
+ get inviteCustomHeaders():
71
+ | {
63
72
  name: string;
64
73
  value: string;
65
- }[] | null;
66
- /**
67
- * Custom headers received from the WebRTC ANSWER message.
68
- * These headers are passed during call acceptance and can contain application-specific information.
69
- * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
70
- */
71
- get answerCustomHeaders(): {
74
+ }[]
75
+ | null;
76
+ /**
77
+ * Custom headers received from the WebRTC ANSWER message.
78
+ * These headers are passed during call acceptance and can contain application-specific information.
79
+ * Format should be [{"name": "X-Header-Name", "value": "Value"}] where header names must start with "X-".
80
+ */
81
+ get answerCustomHeaders():
82
+ | {
72
83
  name: string;
73
84
  value: string;
74
- }[] | null;
75
- /**
76
- * Get the underlying Telnyx Call object (for internal use)
77
- * @internal
78
- */
79
- get telnyxCall(): TelnyxCall;
80
- /**
81
- * Observable stream of call state changes
82
- */
83
- get callState$(): Observable<TelnyxCallState>;
84
- /**
85
- * Observable stream of mute state changes
86
- */
87
- get isMuted$(): Observable<boolean>;
88
- /**
89
- * Observable stream of hold state changes
90
- */
91
- get isHeld$(): Observable<boolean>;
92
- /**
93
- * Observable stream of call duration changes (in seconds)
94
- */
95
- get duration$(): Observable<number>;
96
- /**
97
- * Observable that emits true when the call can be answered
98
- */
99
- get canAnswer$(): Observable<boolean>;
100
- /**
101
- * Observable that emits true when the call can be hung up
102
- */
103
- get canHangup$(): Observable<boolean>;
104
- /**
105
- * Observable that emits true when the call can be put on hold
106
- */
107
- get canHold$(): Observable<boolean>;
108
- /**
109
- * Observable that emits true when the call can be resumed from hold
110
- */
111
- get canResume$(): Observable<boolean>;
112
- /**
113
- * Answer the incoming call
114
- * @param customHeaders Optional custom headers to include with the answer
115
- */
116
- answer(customHeaders?: {
117
- name: string;
118
- value: string;
119
- }[]): Promise<void>;
120
- /**
121
- * Hang up the call
122
- * @param customHeaders Optional custom headers to include with the hangup request
123
- */
124
- hangup(customHeaders?: {
125
- name: string;
126
- value: string;
127
- }[]): Promise<void>;
128
- /**
129
- * Put the call on hold
130
- */
131
- hold(): Promise<void>;
132
- /**
133
- * Resume the call from hold
134
- */
135
- resume(): Promise<void>;
136
- /**
137
- * Mute the call
138
- */
139
- mute(): Promise<void>;
140
- /**
141
- * Unmute the call
142
- */
143
- unmute(): Promise<void>;
144
- /**
145
- * Toggle mute state
146
- */
147
- toggleMute(): Promise<void>;
148
- /**
149
- * Set the call to connecting state (used for push notification calls when answered via CallKit)
150
- * @internal
151
- */
152
- setConnecting(): void;
153
- /**
154
- * Clean up resources when the call is disposed
155
- */
156
- dispose(): void;
157
- /**
158
- * Set up listeners for the underlying Telnyx call
159
- */
160
- private _setupCallListeners;
161
- /**
162
- * Map Telnyx SDK call states to our simplified call states
163
- */
164
- private _mapToTelnyxCallState;
165
- /**
166
- * Start the duration timer
167
- */
168
- private _startDurationTimer;
169
- /**
170
- * Stop the duration timer
171
- */
172
- private _stopDurationTimer;
85
+ }[]
86
+ | null;
87
+ /**
88
+ * Get the underlying Telnyx Call object (for internal use)
89
+ * @internal
90
+ */
91
+ get telnyxCall(): TelnyxCall;
92
+ /**
93
+ * Observable stream of call state changes
94
+ */
95
+ get callState$(): Observable<TelnyxCallState>;
96
+ /**
97
+ * Observable stream of mute state changes
98
+ */
99
+ get isMuted$(): Observable<boolean>;
100
+ /**
101
+ * Observable stream of hold state changes
102
+ */
103
+ get isHeld$(): Observable<boolean>;
104
+ /**
105
+ * Observable stream of call duration changes (in seconds)
106
+ */
107
+ get duration$(): Observable<number>;
108
+ /**
109
+ * Observable that emits true when the call can be answered
110
+ */
111
+ get canAnswer$(): Observable<boolean>;
112
+ /**
113
+ * Observable that emits true when the call can be hung up
114
+ */
115
+ get canHangup$(): Observable<boolean>;
116
+ /**
117
+ * Observable that emits true when the call can be put on hold
118
+ */
119
+ get canHold$(): Observable<boolean>;
120
+ /**
121
+ * Observable that emits true when the call can be resumed from hold
122
+ */
123
+ get canResume$(): Observable<boolean>;
124
+ /**
125
+ * Answer the incoming call
126
+ * @param customHeaders Optional custom headers to include with the answer
127
+ */
128
+ answer(
129
+ customHeaders?: {
130
+ name: string;
131
+ value: string;
132
+ }[]
133
+ ): Promise<void>;
134
+ /**
135
+ * Hang up the call
136
+ * @param customHeaders Optional custom headers to include with the hangup request
137
+ */
138
+ hangup(
139
+ customHeaders?: {
140
+ name: string;
141
+ value: string;
142
+ }[]
143
+ ): Promise<void>;
144
+ /**
145
+ * Put the call on hold
146
+ */
147
+ hold(): Promise<void>;
148
+ /**
149
+ * Resume the call from hold
150
+ */
151
+ resume(): Promise<void>;
152
+ /**
153
+ * Mute the call
154
+ */
155
+ mute(): Promise<void>;
156
+ /**
157
+ * Unmute the call
158
+ */
159
+ unmute(): Promise<void>;
160
+ /**
161
+ * Toggle mute state
162
+ */
163
+ toggleMute(): Promise<void>;
164
+ /**
165
+ * Set the call to connecting state (used for push notification calls when answered via CallKit)
166
+ * @internal
167
+ */
168
+ setConnecting(): void;
169
+ /**
170
+ * Clean up resources when the call is disposed
171
+ */
172
+ dispose(): void;
173
+ /**
174
+ * Set up listeners for the underlying Telnyx call
175
+ */
176
+ private _setupCallListeners;
177
+ /**
178
+ * Map Telnyx SDK call states to our simplified call states
179
+ */
180
+ private _mapToTelnyxCallState;
181
+ /**
182
+ * Start the duration timer
183
+ */
184
+ private _startDurationTimer;
185
+ /**
186
+ * Stop the duration timer
187
+ */
188
+ private _stopDurationTimer;
173
189
  }