@tbisoftware/phone 1.0.13 → 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/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/index-Br8w8pI3.cjs +68 -0
- package/dist/index-TymkBND5.js +8237 -0
- package/dist/index.cjs +1 -68
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- 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/usePhoneManager-OZM1GaNS.js +536 -0
- package/dist/usePhoneManager-uj2opBKT.cjs +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 +33 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import type { PhoneConfig, PhoneStatus, CallHistoryEntry, ConnectionStatus } from '../types';
|
|
3
|
+
export interface PhoneContextValue {
|
|
4
|
+
status: Ref<PhoneStatus>;
|
|
5
|
+
callNumber: Ref<string>;
|
|
6
|
+
setCallNumber: (number: string) => void;
|
|
7
|
+
callHistory: Ref<CallHistoryEntry[]>;
|
|
8
|
+
currentCallDuration: Ref<number>;
|
|
9
|
+
startCall: (number: string) => void;
|
|
10
|
+
endCall: () => void;
|
|
11
|
+
isReady: Ref<boolean>;
|
|
12
|
+
connectionStatus: Ref<ConnectionStatus>;
|
|
13
|
+
}
|
|
14
|
+
export declare const PhoneKey: InjectionKey<PhoneContextValue>;
|
|
15
|
+
export interface UsePhoneProviderOptions {
|
|
16
|
+
config: PhoneConfig;
|
|
17
|
+
onCallStart?: (number: string) => void;
|
|
18
|
+
onCallEnd?: (number: string, duration: number, status: 'completed' | 'failed') => void;
|
|
19
|
+
onStatusChange?: (status: PhoneStatus) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Composable that provides phone functionality to child components.
|
|
23
|
+
* Similar to React's PhoneProvider context.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```vue
|
|
27
|
+
* <script setup>
|
|
28
|
+
* import { usePhoneProvider } from '@tbisoftware/phone/vue';
|
|
29
|
+
*
|
|
30
|
+
* usePhoneProvider({
|
|
31
|
+
* config: {
|
|
32
|
+
* websocketUrl: 'wss://sip-server.com:8989',
|
|
33
|
+
* sipUri: 'sip:user@domain.com',
|
|
34
|
+
* password: 'password',
|
|
35
|
+
* registrarServer: 'sip:domain.com',
|
|
36
|
+
* displayName: 'User',
|
|
37
|
+
* authorizationUser: 'user',
|
|
38
|
+
* },
|
|
39
|
+
* onCallStart: (number) => console.log('Calling', number),
|
|
40
|
+
* });
|
|
41
|
+
* </script>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function usePhoneProvider(options: UsePhoneProviderOptions): PhoneContextValue;
|
|
45
|
+
/**
|
|
46
|
+
* Composable to access phone functionality from child components.
|
|
47
|
+
* Must be used within a component that has called usePhoneProvider.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```vue
|
|
51
|
+
* <script setup>
|
|
52
|
+
* import { usePhone } from '@tbisoftware/phone/vue';
|
|
53
|
+
*
|
|
54
|
+
* const { status, callNumber, startCall, endCall } = usePhone();
|
|
55
|
+
* </script>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function usePhone(): PhoneContextValue;
|
|
59
|
+
//# sourceMappingURL=usePhone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhone.d.ts","sourceRoot":"","sources":["../../src/vue/usePhone.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM7F,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC3C;AAGD,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,iBAAiB,CAAmB,CAAC;AA8HzE,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,WAAW,CAAC;IACpB,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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CAoNpF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ref, readonly } from 'vue';
|
|
2
|
+
import type { PhoneConfig, PhoneStatus, CallHistoryEntry, ConnectionStatus } from '../types';
|
|
3
|
+
export type { ConnectionStatus };
|
|
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: ReturnType<typeof readonly<ReturnType<typeof ref<PhoneStatus>>>>;
|
|
21
|
+
/** Current phone number being called or in the input */
|
|
22
|
+
callNumber: ReturnType<typeof ref<string>>;
|
|
23
|
+
/** Set the phone number */
|
|
24
|
+
setCallNumber: (number: string) => void;
|
|
25
|
+
/** Call history */
|
|
26
|
+
callHistory: ReturnType<typeof readonly<ReturnType<typeof ref<CallHistoryEntry[]>>>>;
|
|
27
|
+
/** Clear call history */
|
|
28
|
+
clearCallHistory: () => void;
|
|
29
|
+
/** Current call duration in seconds */
|
|
30
|
+
currentCallDuration: ReturnType<typeof readonly<ReturnType<typeof ref<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: ReturnType<typeof readonly<ReturnType<typeof ref<boolean>>>>;
|
|
37
|
+
/** Current connection status */
|
|
38
|
+
connectionStatus: ReturnType<typeof readonly<ReturnType<typeof ref<ConnectionStatus>>>>;
|
|
39
|
+
/** The raw JsSIP UA instance (for advanced usage) */
|
|
40
|
+
ua: ReturnType<typeof ref<any>>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Vue composable to manage a SIP phone connection.
|
|
44
|
+
* This composable wraps the framework-agnostic PhoneManager class.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```vue
|
|
48
|
+
* <script setup>
|
|
49
|
+
* import { usePhoneManager } from '@tbisoftware/phone/vue';
|
|
50
|
+
*
|
|
51
|
+
* const {
|
|
52
|
+
* status,
|
|
53
|
+
* callNumber,
|
|
54
|
+
* setCallNumber,
|
|
55
|
+
* startCall,
|
|
56
|
+
* endCall,
|
|
57
|
+
* isReady,
|
|
58
|
+
* connectionStatus,
|
|
59
|
+
* } = usePhoneManager({
|
|
60
|
+
* websocketUrl: 'wss://sip-server.com:8989',
|
|
61
|
+
* sipUri: 'sip:user@domain.com',
|
|
62
|
+
* password: 'password',
|
|
63
|
+
* registrarServer: 'sip:domain.com',
|
|
64
|
+
* displayName: 'User',
|
|
65
|
+
* authorizationUser: 'user',
|
|
66
|
+
* });
|
|
67
|
+
* </script>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function usePhoneManager(config: PhoneConfig, options?: UsePhoneManagerOptions): UsePhoneManagerReturn;
|
|
71
|
+
export default usePhoneManager;
|
|
72
|
+
//# sourceMappingURL=usePhoneManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneManager.d.ts","sourceRoot":"","sources":["../../src/vue/usePhoneManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA0B,QAAQ,EAAS,MAAM,KAAK,CAAC;AAEnE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7F,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACnC,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,EAAE,WAAW,GAAG,QAAQ,KAAK,IAAI,CAAC;IACvF,wCAAwC;IACxC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACxD,sDAAsD;IACtD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IAClC,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,wDAAwD;IACxD,UAAU,EAAE,UAAU,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,2BAA2B;IAC3B,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,mBAAmB;IACnB,WAAW,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,uCAAuC;IACvC,mBAAmB,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,uCAAuC;IACvC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,2BAA2B;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8DAA8D;IAC9D,OAAO,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,gCAAgC;IAChC,gBAAgB,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,qDAAqD;IACrD,EAAE,EAAE,UAAU,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,sBAA2B,GACrC,qBAAqB,CAyGvB;AAED,eAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbisoftware/phone",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "A reusable SIP phone component for React applications",
|
|
5
|
+
"description": "A reusable SIP phone component for React and Vue applications",
|
|
6
6
|
"author": "TBI",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "./dist/index.cjs",
|
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
16
|
},
|
|
17
|
+
"./react": {
|
|
18
|
+
"types": "./dist/react/index.d.ts",
|
|
19
|
+
"import": "./dist/react/index.js",
|
|
20
|
+
"require": "./dist/react/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./vue": {
|
|
23
|
+
"types": "./dist/vue/index.d.ts",
|
|
24
|
+
"import": "./dist/vue/index.js",
|
|
25
|
+
"require": "./dist/vue/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"./core": {
|
|
28
|
+
"types": "./dist/core/index.d.ts",
|
|
29
|
+
"import": "./dist/core/index.js",
|
|
30
|
+
"require": "./dist/core/index.cjs"
|
|
31
|
+
},
|
|
17
32
|
"./styles.css": "./dist/styles.css"
|
|
18
33
|
},
|
|
19
34
|
"files": [
|
|
@@ -30,7 +45,19 @@
|
|
|
30
45
|
},
|
|
31
46
|
"peerDependencies": {
|
|
32
47
|
"react": ">=18.0.0",
|
|
33
|
-
"react-dom": ">=18.0.0"
|
|
48
|
+
"react-dom": ">=18.0.0",
|
|
49
|
+
"vue": ">=3.3.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"react": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"react-dom": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"vue": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
34
61
|
},
|
|
35
62
|
"dependencies": {
|
|
36
63
|
"jssip": "^3.11.1"
|
|
@@ -42,12 +69,14 @@
|
|
|
42
69
|
"@types/react": "^19.2.5",
|
|
43
70
|
"@types/react-dom": "^19.2.3",
|
|
44
71
|
"@vitejs/plugin-react": "^5.1.1",
|
|
72
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
45
73
|
"eslint": "^9.39.1",
|
|
46
74
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
47
75
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
48
76
|
"globals": "^16.5.0",
|
|
49
77
|
"react": "^19.2.0",
|
|
50
78
|
"react-dom": "^19.2.0",
|
|
79
|
+
"vue": "^3.5.13",
|
|
51
80
|
"tailwindcss": "^4.1.18",
|
|
52
81
|
"typescript": "~5.9.3",
|
|
53
82
|
"typescript-eslint": "^8.46.4",
|
|
@@ -56,6 +85,7 @@
|
|
|
56
85
|
},
|
|
57
86
|
"keywords": [
|
|
58
87
|
"react",
|
|
88
|
+
"vue",
|
|
59
89
|
"phone",
|
|
60
90
|
"sip",
|
|
61
91
|
"voip",
|