@tbisoftware/phone 1.0.12 → 2.0.4
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 +266 -108
- package/dist/components/phone.d.ts +3 -0
- package/dist/components/phone.d.ts.map +1 -0
- package/dist/context/PhoneContext.d.ts +23 -0
- package/dist/context/PhoneContext.d.ts.map +1 -0
- package/dist/core/PhoneManager.d.ts +94 -0
- package/dist/core/PhoneManager.d.ts.map +1 -0
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/usePhoneManager.d.ts +69 -0
- package/dist/hooks/usePhoneManager.d.ts.map +1 -0
- package/dist/index-Br8w8pI3.cjs +68 -0
- package/dist/index-TymkBND5.js +8237 -0
- package/dist/index.cjs +1 -68
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -8616
- package/dist/react/Phone.d.ts +3 -0
- package/dist/react/Phone.d.ts.map +1 -0
- package/dist/react/PhoneContext.d.ts +23 -0
- package/dist/react/PhoneContext.d.ts.map +1 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +9 -0
- package/dist/react/usePhoneManager.d.ts +67 -0
- package/dist/react/usePhoneManager.d.ts.map +1 -0
- package/dist/types/index.d.ts +56 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/usePhoneManager-OZM1GaNS.js +536 -0
- package/dist/usePhoneManager-uj2opBKT.cjs +1 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/formatDuration.d.ts +5 -0
- package/dist/utils/formatDuration.d.ts.map +1 -0
- package/dist/vue/index.cjs +1 -0
- package/dist/vue/index.d.ts +8 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +706 -0
- package/dist/vue/usePhone.d.ts +59 -0
- package/dist/vue/usePhone.d.ts.map +1 -0
- package/dist/vue/usePhoneManager.d.ts +72 -0
- package/dist/vue/usePhoneManager.d.ts.map +1 -0
- package/package.json +34 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import JsSIP from 'jssip';
|
|
2
|
+
import type { PhoneConfig, PhoneStatus, CallHistoryEntry } from '../types';
|
|
3
|
+
export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'failed';
|
|
4
|
+
export interface UsePhoneManagerOptions {
|
|
5
|
+
/** Callback when a call starts */
|
|
6
|
+
onCallStart?: (number: string) => void;
|
|
7
|
+
/** Callback when a call ends */
|
|
8
|
+
onCallEnd?: (number: string, duration: number, status: 'completed' | 'failed') => void;
|
|
9
|
+
/** Callback when call status changes */
|
|
10
|
+
onStatusChange?: (status: PhoneStatus) => void;
|
|
11
|
+
/** Callback when connection status changes */
|
|
12
|
+
onConnectionChange?: (status: ConnectionStatus) => void;
|
|
13
|
+
/** Enable call history persistence in localStorage */
|
|
14
|
+
persistHistory?: boolean;
|
|
15
|
+
/** localStorage key for call history */
|
|
16
|
+
historyKey?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UsePhoneManagerReturn {
|
|
19
|
+
/** Current call status */
|
|
20
|
+
status: PhoneStatus;
|
|
21
|
+
/** Current phone number being called or in the input */
|
|
22
|
+
callNumber: string;
|
|
23
|
+
/** Set the phone number */
|
|
24
|
+
setCallNumber: (number: string) => void;
|
|
25
|
+
/** Call history */
|
|
26
|
+
callHistory: CallHistoryEntry[];
|
|
27
|
+
/** Clear call history */
|
|
28
|
+
clearCallHistory: () => void;
|
|
29
|
+
/** Current call duration in seconds */
|
|
30
|
+
currentCallDuration: number;
|
|
31
|
+
/** Start a call to the given number */
|
|
32
|
+
startCall: (number: string) => void;
|
|
33
|
+
/** End the current call */
|
|
34
|
+
endCall: () => void;
|
|
35
|
+
/** Whether the phone is registered and ready to make calls */
|
|
36
|
+
isReady: boolean;
|
|
37
|
+
/** Current connection status */
|
|
38
|
+
connectionStatus: ConnectionStatus;
|
|
39
|
+
/** The raw JsSIP UA instance (for advanced usage) */
|
|
40
|
+
ua: JsSIP.UA | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hook to manage a SIP phone connection.
|
|
44
|
+
* This hook manages the JsSIP User Agent and provides all the necessary
|
|
45
|
+
* state and functions to build your own phone UI.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const {
|
|
50
|
+
* status,
|
|
51
|
+
* callNumber,
|
|
52
|
+
* setCallNumber,
|
|
53
|
+
* startCall,
|
|
54
|
+
* endCall,
|
|
55
|
+
* isReady,
|
|
56
|
+
* connectionStatus,
|
|
57
|
+
* } = usePhoneManager({
|
|
58
|
+
* websocketUrl: 'wss://sip-server.com:8989',
|
|
59
|
+
* sipUri: 'sip:user@domain.com',
|
|
60
|
+
* password: 'password',
|
|
61
|
+
* registrarServer: 'sip:domain.com',
|
|
62
|
+
* displayName: 'User',
|
|
63
|
+
* authorizationUser: 'user',
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function usePhoneManager(config: PhoneConfig, options?: UsePhoneManagerOptions): UsePhoneManagerReturn;
|
|
68
|
+
export default usePhoneManager;
|
|
69
|
+
//# sourceMappingURL=usePhoneManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneManager.d.ts","sourceRoot":"","sources":["../../src/hooks/usePhoneManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoI3E,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAA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