@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.
Files changed (48) hide show
  1. package/README.md +266 -108
  2. package/dist/components/phone.d.ts +3 -0
  3. package/dist/components/phone.d.ts.map +1 -0
  4. package/dist/context/PhoneContext.d.ts +23 -0
  5. package/dist/context/PhoneContext.d.ts.map +1 -0
  6. package/dist/core/PhoneManager.d.ts +94 -0
  7. package/dist/core/PhoneManager.d.ts.map +1 -0
  8. package/dist/core/index.cjs +1 -0
  9. package/dist/core/index.d.ts +7 -0
  10. package/dist/core/index.d.ts.map +1 -0
  11. package/dist/core/index.js +7 -0
  12. package/dist/hooks/index.d.ts +2 -0
  13. package/dist/hooks/index.d.ts.map +1 -0
  14. package/dist/hooks/usePhoneManager.d.ts +69 -0
  15. package/dist/hooks/usePhoneManager.d.ts.map +1 -0
  16. package/dist/index-Br8w8pI3.cjs +68 -0
  17. package/dist/index-TymkBND5.js +8237 -0
  18. package/dist/index.cjs +1 -68
  19. package/dist/index.d.ts +9 -1
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +11 -8616
  22. package/dist/react/Phone.d.ts +3 -0
  23. package/dist/react/Phone.d.ts.map +1 -0
  24. package/dist/react/PhoneContext.d.ts +23 -0
  25. package/dist/react/PhoneContext.d.ts.map +1 -0
  26. package/dist/react/index.cjs +1 -0
  27. package/dist/react/index.d.ts +7 -0
  28. package/dist/react/index.d.ts.map +1 -0
  29. package/dist/react/index.js +9 -0
  30. package/dist/react/usePhoneManager.d.ts +67 -0
  31. package/dist/react/usePhoneManager.d.ts.map +1 -0
  32. package/dist/types/index.d.ts +56 -0
  33. package/dist/types/index.d.ts.map +1 -0
  34. package/dist/usePhoneManager-OZM1GaNS.js +536 -0
  35. package/dist/usePhoneManager-uj2opBKT.cjs +1 -0
  36. package/dist/utils/cn.d.ts +5 -0
  37. package/dist/utils/cn.d.ts.map +1 -0
  38. package/dist/utils/formatDuration.d.ts +5 -0
  39. package/dist/utils/formatDuration.d.ts.map +1 -0
  40. package/dist/vue/index.cjs +1 -0
  41. package/dist/vue/index.d.ts +8 -0
  42. package/dist/vue/index.d.ts.map +1 -0
  43. package/dist/vue/index.js +706 -0
  44. package/dist/vue/usePhone.d.ts +59 -0
  45. package/dist/vue/usePhone.d.ts.map +1 -0
  46. package/dist/vue/usePhoneManager.d.ts +72 -0
  47. package/dist/vue/usePhoneManager.d.ts.map +1 -0
  48. package/package.json +34 -4
@@ -0,0 +1,3 @@
1
+ import type { PhoneProps } from '../types';
2
+ export default function Phone({ config, className, onCallStart, onCallEnd, onStatusChange, labels }: PhoneProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=Phone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Phone.d.ts","sourceRoot":"","sources":["../../src/react/Phone.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,UAAU,CAAC;AAwV7D,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,UAAU,2CAW9G"}
@@ -0,0 +1,23 @@
1
+ import type { PhoneConfig, PhoneStatus, CallHistoryEntry } from '../types';
2
+ interface PhoneContextValue {
3
+ status: PhoneStatus;
4
+ callNumber: string;
5
+ setCallNumber: (number: string) => void;
6
+ callHistory: CallHistoryEntry[];
7
+ currentCallDuration: number;
8
+ startCall: (number: string) => void;
9
+ endCall: () => void;
10
+ isReady: boolean;
11
+ connectionStatus: 'connecting' | 'connected' | 'disconnected' | 'failed';
12
+ }
13
+ interface PhoneProviderProps {
14
+ config: PhoneConfig;
15
+ children: React.ReactNode;
16
+ onCallStart?: (number: string) => void;
17
+ onCallEnd?: (number: string, duration: number, status: 'completed' | 'failed') => void;
18
+ onStatusChange?: (status: PhoneStatus) => void;
19
+ }
20
+ export declare function PhoneProvider({ config, children, onCallStart, onCallEnd, onStatusChange }: PhoneProviderProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function usePhone(): PhoneContextValue;
22
+ export {};
23
+ //# sourceMappingURL=PhoneContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhoneContext.d.ts","sourceRoot":"","sources":["../../src/react/PhoneContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AA0J3E,UAAU,iBAAiB;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,QAAQ,CAAC;CAC5E;AAID,UAAU,kBAAkB;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,QAAQ,KAAK,IAAI,CAAC;IACvF,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,aAAa,CAAC,EAC1B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACjB,EAAE,kBAAkB,2CAoNpB;AAED,wBAAgB,QAAQ,sBAMvB"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../usePhoneManager-uj2opBKT.cjs");exports.Phone=e.Phone;exports.PhoneProvider=e.PhoneProvider;exports.default=e.Phone;exports.usePhone=e.usePhone;exports.usePhoneManager=e.usePhoneManager;
@@ -0,0 +1,7 @@
1
+ import Phone from './Phone';
2
+ export { Phone };
3
+ export { PhoneProvider, usePhone } from './PhoneContext';
4
+ export { usePhoneManager } from './usePhoneManager';
5
+ export type { UsePhoneManagerOptions, UsePhoneManagerReturn, ConnectionStatus } from './usePhoneManager';
6
+ export default Phone;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEzG,eAAe,KAAK,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { P as o } from "../usePhoneManager-OZM1GaNS.js";
2
+ import { a as s, u as P, b as n } from "../usePhoneManager-OZM1GaNS.js";
3
+ export {
4
+ o as Phone,
5
+ s as PhoneProvider,
6
+ o as default,
7
+ P as usePhone,
8
+ n as usePhoneManager
9
+ };
@@ -0,0 +1,67 @@
1
+ import type { PhoneConfig, PhoneStatus, CallHistoryEntry, ConnectionStatus } from '../types';
2
+ export type { ConnectionStatus };
3
+ export interface UsePhoneManagerOptions {
4
+ /** Callback when a call starts */
5
+ onCallStart?: (number: string) => void;
6
+ /** Callback when a call ends */
7
+ onCallEnd?: (number: string, duration: number, status: 'completed' | 'failed') => void;
8
+ /** Callback when call status changes */
9
+ onStatusChange?: (status: PhoneStatus) => void;
10
+ /** Callback when connection status changes */
11
+ onConnectionChange?: (status: ConnectionStatus) => void;
12
+ /** Enable call history persistence in localStorage */
13
+ persistHistory?: boolean;
14
+ /** localStorage key for call history */
15
+ historyKey?: string;
16
+ }
17
+ export interface UsePhoneManagerReturn {
18
+ /** Current call status */
19
+ status: PhoneStatus;
20
+ /** Current phone number being called or in the input */
21
+ callNumber: string;
22
+ /** Set the phone number */
23
+ setCallNumber: (number: string) => void;
24
+ /** Call history */
25
+ callHistory: CallHistoryEntry[];
26
+ /** Clear call history */
27
+ clearCallHistory: () => void;
28
+ /** Current call duration in seconds */
29
+ currentCallDuration: number;
30
+ /** Start a call to the given number */
31
+ startCall: (number: string) => void;
32
+ /** End the current call */
33
+ endCall: () => void;
34
+ /** Whether the phone is registered and ready to make calls */
35
+ isReady: boolean;
36
+ /** Current connection status */
37
+ connectionStatus: ConnectionStatus;
38
+ /** The raw JsSIP UA instance (for advanced usage) */
39
+ ua: any | null;
40
+ }
41
+ /**
42
+ * React hook to manage a SIP phone connection.
43
+ * This hook wraps the framework-agnostic PhoneManager class.
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * const {
48
+ * status,
49
+ * callNumber,
50
+ * setCallNumber,
51
+ * startCall,
52
+ * endCall,
53
+ * isReady,
54
+ * connectionStatus,
55
+ * } = usePhoneManager({
56
+ * websocketUrl: 'wss://sip-server.com:8989',
57
+ * sipUri: 'sip:user@domain.com',
58
+ * password: 'password',
59
+ * registrarServer: 'sip:domain.com',
60
+ * displayName: 'User',
61
+ * authorizationUser: 'user',
62
+ * });
63
+ * ```
64
+ */
65
+ export declare function usePhoneManager(config: PhoneConfig, options?: UsePhoneManagerOptions): UsePhoneManagerReturn;
66
+ export default usePhoneManager;
67
+ //# sourceMappingURL=usePhoneManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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E,OAAO,CAAC;IACjB,gCAAgC;IAChC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qDAAqD;IACrD,EAAE,EAAE,GAAG,GAAG,IAAI,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,sBAA2B,GACrC,qBAAqB,CA0HvB;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,56 @@
1
+ export interface CallHistoryEntry {
2
+ id: string;
3
+ number: string;
4
+ timestamp: number;
5
+ duration: number;
6
+ status: 'completed' | 'failed' | 'missed';
7
+ }
8
+ export type PhoneStatus = 'disconnected' | 'progress' | 'confirmed' | 'failed' | 'ended';
9
+ export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'failed';
10
+ export interface PhoneConfig {
11
+ /** WebSocket URL for the SIP connection */
12
+ websocketUrl: string;
13
+ /** SIP URI (e.g., 'sip:user@domain.com') */
14
+ sipUri: string;
15
+ /** SIP password */
16
+ password: string;
17
+ /** Registrar server (e.g., 'sip:domain.com') */
18
+ registrarServer: string;
19
+ /** Display name for the caller */
20
+ displayName: string;
21
+ /** Authorization user */
22
+ authorizationUser: string;
23
+ }
24
+ export interface PhoneProps {
25
+ /** Configuration for the SIP connection */
26
+ config: PhoneConfig;
27
+ /** Custom class name for the phone container */
28
+ className?: string;
29
+ /** Callback when a call starts */
30
+ onCallStart?: (number: string) => void;
31
+ /** Callback when a call ends */
32
+ onCallEnd?: (number: string, duration: number, status: 'completed' | 'failed') => void;
33
+ /** Callback when status changes */
34
+ onStatusChange?: (status: PhoneStatus) => void;
35
+ /** Custom labels for internationalization */
36
+ labels?: Partial<PhoneLabels>;
37
+ }
38
+ export interface PhoneLabels {
39
+ calling: string;
40
+ waitingResponse: string;
41
+ cancel: string;
42
+ hangUp: string;
43
+ callEnded: string;
44
+ duration: string;
45
+ inactive: string;
46
+ inCall: string;
47
+ placeholder: string;
48
+ callHistory: string;
49
+ noCallsRegistered: string;
50
+ callsRegistered: string;
51
+ noCalls: string;
52
+ startingCall: string;
53
+ callInProgress: string;
54
+ }
55
+ export declare const defaultLabels: PhoneLabels;
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC7C;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEtF,MAAM,WAAW,WAAW;IACxB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACvB,2CAA2C;IAC3C,MAAM,EAAE,WAAW,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,gCAAgC;IAChC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAA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