react-sip-kit 0.2.3 → 0.3.62

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.
@@ -1,3 +1,2 @@
1
- import { CallbackFunction } from '../../types';
2
- export declare function detectDevices(callback: CallbackFunction<MediaDeviceInfo[]>): void;
1
+ export declare function detectDevices(): Promise<MediaDeviceInfo[]>;
3
2
  export declare function getMediaPermissions(media?: 'audio' | 'video'): Promise<MediaStream>;
@@ -1,3 +1,3 @@
1
- import { SipUserAgent } from '../../types';
2
- export declare function Register(userAgent?: SipUserAgent): void;
3
- export declare function Unregister(skipUnsubscribe?: boolean, userAgent?: SipUserAgent): void;
1
+ export declare function register(userAgent?: import("../..").SipUserAgent | undefined): void;
2
+ export declare function unregister(skipUnsubscribe?: boolean, userAgent?: import("../..").SipUserAgent | undefined): void;
3
+ export declare function refreshRegistration(): void;
@@ -1,2 +1,11 @@
1
1
  import { LineType } from '../../store/types';
2
+ import { SendMessageSessionValueType, SendMessageSessionEnum } from './type';
2
3
  export declare function teardownSession(lineObj: LineType): void;
4
+ export declare function sendMessageSession<T extends SendMessageSessionEnum>(session: LineType['sipSession'], type: T, value: SendMessageSessionValueType[T]): Promise<void>;
5
+ /**
6
+ * Sends VIDEO_TOGGLE and retries until VIDEO_TOGGLE_ACK is received.
7
+ */
8
+ export declare function sendVideoActivationWithAckRetry(session: LineType['sipSession'], options?: {
9
+ maxRetries?: number;
10
+ delayMs?: number;
11
+ }): Promise<void>;
@@ -0,0 +1,16 @@
1
+ export declare enum SendMessageSessionEnum {
2
+ 'SOUND_TOGGLE' = "SOUND_TOGGLE",
3
+ 'VIDEO_TOGGLE' = "VIDEO_TOGGLE",
4
+ 'SCREEN_SHARE_TOGGLE' = "SCREEN_SHARE_TOGGLE",
5
+ 'VIDEO_TOGGLE_ACK' = "VIDEO_TOGGLE_ACK"
6
+ }
7
+ export type SendMessageSessionValueType = {
8
+ [SendMessageSessionEnum.SOUND_TOGGLE]: boolean;
9
+ [SendMessageSessionEnum.VIDEO_TOGGLE]: boolean;
10
+ [SendMessageSessionEnum.SCREEN_SHARE_TOGGLE]: boolean;
11
+ [SendMessageSessionEnum.VIDEO_TOGGLE_ACK]: null | undefined | '';
12
+ };
13
+ export type SendMessageRequestBody<T extends SendMessageSessionEnum = SendMessageSessionEnum.SOUND_TOGGLE> = {
14
+ type: T;
15
+ value: SendMessageSessionValueType[T];
16
+ };
@@ -1,5 +1,4 @@
1
1
  import { SipContextType, SipProviderProps } from './types';
2
- import React from 'react';
3
- export declare const SipContext: React.Context<SipContextType | undefined>;
4
- export declare const SipProvider: React.FC<SipProviderProps>;
2
+ export declare const SipContext: import("react").Context<SipContextType | undefined>;
3
+ export declare const SipProvider: ({ children, configs }: SipProviderProps) => import("react/jsx-runtime").JSX.Element;
5
4
  export declare const useSipProvider: () => SipContextType;
@@ -1,7 +1,6 @@
1
1
  import { SipConfigs } from '../configs/types';
2
2
  import { AudioBlobs } from '../constructors';
3
- import { SipUserAgent } from '../types';
4
- import { Dayjs } from 'dayjs';
3
+ import { CallbackFunction, CallType, SipUserAgent } from '../types';
5
4
  import { Invitation, Inviter, Session, SessionDescriptionHandler, SessionDescriptionHandlerOptions } from 'sip.js';
6
5
  import { IncomingInviteRequest } from 'sip.js/lib/core';
7
6
  export interface SipStoreStateType {
@@ -13,7 +12,7 @@ export interface SipStoreStateType {
13
12
  setSipStore: (state: Partial<SipStoreStateType>) => void;
14
13
  setUserAgent: (userAgent: SipStoreStateType['userAgent']) => void;
15
14
  addLine: (line: LineType) => void;
16
- updateLine: (line: LineType) => void;
15
+ updateLine: (line: LineType, callback?: CallbackFunction) => void;
17
16
  removeLine: (lineNum: LineType['lineNumber']) => void;
18
17
  findLineByNumber: (lineNum: LineType['lineNumber']) => LineType | null;
19
18
  getSessions: () => SipUserAgent['sessions'] | null;
@@ -26,6 +25,9 @@ export interface SipInvitationType extends Omit<Invitation, 'incomingInviteReque
26
25
  sessionDescriptionHandler: SipSessionDescriptionHandler;
27
26
  sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
28
27
  isOnHold: boolean;
28
+ callType: CallType;
29
+ initiateLocalMediaStreams: (videoEnabled?: boolean, pc?: RTCPeerConnection) => void;
30
+ initiateRemoteMediaStreams: (videoEnabled?: boolean, pc?: RTCPeerConnection) => void;
29
31
  }
30
32
  export interface SipSessionDescriptionHandlerOptions extends SessionDescriptionHandlerOptions {
31
33
  hold: boolean;
@@ -35,15 +37,17 @@ export interface SipInviterType extends Inviter {
35
37
  sessionDescriptionHandler: SipSessionDescriptionHandler;
36
38
  sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
37
39
  isOnHold: boolean;
40
+ callType: CallType;
41
+ initiateLocalMediaStreams: (videoEnabled?: boolean, pc?: RTCPeerConnection) => void;
42
+ initiateRemoteMediaStreams: (videoEnabled?: boolean, pc?: RTCPeerConnection) => void;
38
43
  }
39
44
  export interface SipSessionDescriptionHandler extends SessionDescriptionHandler {
40
45
  peerConnection: RTCPeerConnection;
41
46
  peerConnectionDelegate: any;
42
47
  }
43
- export interface LineType<T extends object = object> {
48
+ export interface LineType {
44
49
  lineNumber: number;
45
50
  displayNumber: string;
46
- metaData: Partial<T>;
47
51
  sipSession: SipInvitationType | SipInviterType | null;
48
52
  localSoundMeter: any;
49
53
  remoteSoundMeter: any;
@@ -56,30 +60,26 @@ export interface SipSessionDataType {
56
60
  callDirection: 'inbound' | 'outbound';
57
61
  terminateBy: string;
58
62
  src: string;
59
- metaData: LineType['metaData'];
60
- callstart: string;
61
63
  earlyReject: boolean;
62
- withVideo: boolean;
63
64
  reasonCode: number;
64
65
  reasonText: string;
65
66
  teardownComplete: boolean;
66
67
  childsession: SipSessionType | null;
67
- startTime: Dayjs;
68
+ startTime: string;
68
69
  started: boolean;
69
70
  hold: Array<{
70
71
  event: 'hold' | 'unhold';
71
72
  eventTime: string;
72
73
  }>;
73
74
  isHold: boolean;
74
- mute: Array<{
75
- event: 'mute' | 'unmute';
76
- eventTime: string;
77
- }>;
78
- isMute: boolean;
79
75
  videoChannelNames: Array<Record<'mid' | 'channel', string>>;
76
+ localMediaStreamStatus: MediaStremStatus;
77
+ remoteMediaStreamStatus: MediaStremStatus;
78
+ videoAckReceived: boolean;
80
79
  dialledNumber: string;
81
80
  transfer: Array<SipSessionTransferType>;
82
- audioSourceTrack: any;
81
+ audioSourceTrack: MediaStreamTrack | null;
82
+ videoSourceTrack: MediaStreamTrack | null;
83
83
  earlyMedia: any;
84
84
  ringerObj: {
85
85
  [key: string]: any;
@@ -89,6 +89,11 @@ export interface SipSessionDataType {
89
89
  videoSourceDevice: string | null;
90
90
  audioSourceDevice: string | null;
91
91
  audioOutputDevice: string | null;
92
+ recordMedia: {
93
+ recording: boolean;
94
+ startTime: string | null;
95
+ recorder: MediaRecorder | null;
96
+ };
92
97
  }
93
98
  export interface SipSessionTransferType {
94
99
  type: 'Attended' | 'Blind';
@@ -111,4 +116,9 @@ interface DevicesInfoType {
111
116
  videoInputDevices: any[];
112
117
  speakerDevices: any[];
113
118
  }
119
+ interface MediaStremStatus {
120
+ soundEnabled: boolean;
121
+ videoEnabled: boolean;
122
+ screenShareEnabled: boolean;
123
+ }
114
124
  export {};
package/dist/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { SipConfigs } from './configs/types';
2
2
  import { reconnectTransport } from './events/transport';
3
- import { useSessionMethods, useSessionEvents } from './hooks';
4
- import { SipSessionType, SipStoreStateType } from './store/types';
5
- import { UserAgent, Registerer, Subscriber } from 'sip.js';
3
+ import { useSessionEvents, useSessionMethods } from './hooks';
4
+ import { LineType, SipSessionType } from './store/types';
5
+ import { Registerer, Subscriber, UserAgent } from 'sip.js';
6
6
  export interface SipUserAgent extends UserAgent {
7
7
  isReRegister: boolean;
8
8
  isRegistered: () => boolean;
@@ -16,7 +16,7 @@ export interface SipUserAgent extends UserAgent {
16
16
  registrationCompleted: boolean;
17
17
  registering: boolean;
18
18
  transport: UserAgent['transport'] & {
19
- ReconnectionAttempts: number;
19
+ reconnectionAttempts: number;
20
20
  attemptingReconnection: boolean;
21
21
  };
22
22
  BlfSubs: any[];
@@ -34,8 +34,8 @@ export interface SipProviderProps<T extends SipConfigs = SipConfigs> {
34
34
  configs: SipProviderConfigs<T>;
35
35
  }
36
36
  export interface SipContextType {
37
- lines: SipStoreStateType['lines'];
38
- session: SipContextSessionType;
37
+ status: 'connected' | 'disconnected';
38
+ lines: LineType[];
39
39
  transport: SipContextTransportType;
40
40
  }
41
41
  export interface SipContextSessionType {
@@ -45,5 +45,6 @@ export interface SipContextSessionType {
45
45
  export interface SipContextTransportType {
46
46
  reconnectTransport: typeof reconnectTransport;
47
47
  }
48
- export type CallbackFunction<T> = (value?: T) => void;
48
+ export type CallbackFunction<T = any> = (value?: T) => void;
49
+ export type CallType = 'audio' | 'video' | 'conferenceAudio' | 'conferenceVideo' | 'transferAudio' | 'transferVideo';
49
50
  export {};
package/package.json CHANGED
@@ -1,98 +1,98 @@
1
- {
2
- "name": "react-sip-kit",
3
- "private": false,
4
- "version": "0.2.3",
5
- "type": "module",
6
- "author": {
7
- "name": "Shervin Ghajar",
8
- "email": "ssghajar.work@gmail.com"
9
- },
10
- "homepage": "https://github.com/shervin-ghajar/react-sip-kit#readme",
11
- "keywords": [
12
- "react",
13
- "sip",
14
- "sipjs",
15
- "jssip",
16
- "voip",
17
- "communication",
18
- "webRTC",
19
- "telephony",
20
- "react-hooks",
21
- "sip.js",
22
- "react-sip",
23
- "react-sip-provider",
24
- "real-time",
25
- "session-initiation-protocol",
26
- "frontend",
27
- "javascript",
28
- "typescript",
29
- "npm",
30
- "library",
31
- "utility",
32
- "responsive",
33
- "design",
34
- "state-management",
35
- "zustand"
36
- ],
37
- "repository": {
38
- "type": "git",
39
- "url": "https://github.com/shervin-ghajar/react-sip-kit.git"
40
- },
41
- "license": "MIT",
42
- "main": "dist/index.cjs",
43
- "module": "dist/index.mjs",
44
- "types": "dist/index.d.ts",
45
- "exports": {
46
- ".": {
47
- "import": "./dist/index.mjs",
48
- "require": "./dist/index.cjs",
49
- "types": "./dist/index.d.ts"
50
- }
51
- },
52
- "scripts": {
53
- "build": "rollup -c",
54
- "lint": "eslint .",
55
- "format": "prettier --write --cache . --plugin=prettier-plugin-organize-imports"
56
- },
57
- "dependencies": {
58
- "clone": "^2.1.2",
59
- "dayjs": "^1.11.13",
60
- "sip.js": "0.21.2",
61
- "zustand": "^5.0.1"
62
- },
63
- "devDependencies": {
64
- "@eslint/js": "9.13.0",
65
- "@rollup/plugin-commonjs": "^28.0.3",
66
- "@rollup/plugin-node-resolve": "^16.0.1",
67
- "@rollup/plugin-terser": "^0.4.4",
68
- "@rollup/plugin-typescript": "^12.1.2",
69
- "@trivago/prettier-plugin-sort-imports": "^4.3.0",
70
- "@types/clone": "^2.1.4",
71
- "@types/react": "18.3.12",
72
- "@types/react-dom": "18.3.1",
73
- "@typescript-eslint/eslint-plugin": "^8.15.0",
74
- "@typescript-eslint/parser": "^8.15.0",
75
- "eslint": "^9.15.0",
76
- "eslint-config-prettier": "^9.1.0",
77
- "eslint-plugin-prettier": "^5.2.1",
78
- "eslint-plugin-react-hooks": "5.0.0",
79
- "eslint-plugin-react-refresh": "0.4.14",
80
- "globals": "15.11.0",
81
- "prettier": "^3.3.3",
82
- "prettier-plugin-organize-imports": "^4.1.0",
83
- "react-dom": "18.3.1",
84
- "rollup": "^4.41.1",
85
- "rollup-plugin-delete": "^3.0.1",
86
- "rollup-plugin-dts": "^6.2.1",
87
- "typescript": "~5.6.2",
88
- "typescript-eslint": "8.11.0"
89
- },
90
- "peerDependencies": {
91
- "react": ">=17.0.0"
92
- },
93
- "files": [
94
- "dist",
95
- "README.md",
96
- "LICENSE"
97
- ]
98
- }
1
+ {
2
+ "name": "react-sip-kit",
3
+ "private": false,
4
+ "version": "0.3.62",
5
+ "type": "module",
6
+ "author": {
7
+ "name": "Shervin Ghajar",
8
+ "email": "ssghajar.work@gmail.com"
9
+ },
10
+ "homepage": "https://github.com/shervin-ghajar/react-sip-kit#readme",
11
+ "keywords": [
12
+ "react",
13
+ "sip",
14
+ "sipjs",
15
+ "jssip",
16
+ "voip",
17
+ "communication",
18
+ "webRTC",
19
+ "telephony",
20
+ "react-hooks",
21
+ "sip.js",
22
+ "react-sip",
23
+ "react-sip-provider",
24
+ "real-time",
25
+ "session-initiation-protocol",
26
+ "frontend",
27
+ "javascript",
28
+ "typescript",
29
+ "npm",
30
+ "library",
31
+ "utility",
32
+ "responsive",
33
+ "design",
34
+ "state-management",
35
+ "zustand"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/shervin-ghajar/react-sip-kit.git"
40
+ },
41
+ "license": "MIT",
42
+ "main": "dist/index.cjs",
43
+ "module": "dist/index.mjs",
44
+ "types": "dist/index.d.ts",
45
+ "exports": {
46
+ ".": {
47
+ "import": "./dist/index.mjs",
48
+ "require": "./dist/index.cjs",
49
+ "types": "./dist/index.d.ts"
50
+ }
51
+ },
52
+ "scripts": {
53
+ "build": "rollup -c",
54
+ "lint": "eslint .",
55
+ "format": "prettier --write --cache . --plugin=prettier-plugin-organize-imports"
56
+ },
57
+ "dependencies": {
58
+ "dayjs": "^1.11.13",
59
+ "sip.js": "0.21.2",
60
+ "zustand": "^5.0.1"
61
+ },
62
+ "devDependencies": {
63
+ "@eslint/js": "9.13.0",
64
+ "@rollup/plugin-commonjs": "^28.0.3",
65
+ "@rollup/plugin-node-resolve": "^16.0.1",
66
+ "@rollup/plugin-terser": "^0.4.4",
67
+ "@rollup/plugin-typescript": "^12.1.2",
68
+ "@trivago/prettier-plugin-sort-imports": "^4.3.0",
69
+ "@types/clone": "^2.1.4",
70
+ "@types/react": "18.3.12",
71
+ "@types/react-dom": "18.3.1",
72
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
73
+ "@typescript-eslint/parser": "^8.15.0",
74
+ "eslint": "^9.15.0",
75
+ "eslint-config-prettier": "^9.1.0",
76
+ "eslint-plugin-prettier": "^5.2.1",
77
+ "eslint-plugin-react-hooks": "5.0.0",
78
+ "eslint-plugin-react-refresh": "0.4.14",
79
+ "globals": "15.11.0",
80
+ "prettier": "^3.3.3",
81
+ "prettier-plugin-organize-imports": "^4.1.0",
82
+ "rollup": "^4.41.1",
83
+ "rollup-plugin-delete": "^3.0.1",
84
+ "rollup-plugin-strip": "^1.2.2",
85
+ "tslib": "^2.8.1",
86
+ "typescript": "~5.6.2",
87
+ "typescript-eslint": "8.11.0"
88
+ },
89
+ "peerDependencies": {
90
+ "react": ">=17.0.0",
91
+ "react-dom": ">=17.0.0"
92
+ },
93
+ "files": [
94
+ "dist",
95
+ "README.md",
96
+ "LICENSE"
97
+ ]
98
+ }
@@ -1 +0,0 @@
1
- export declare const useDetectDevices: () => void;