react-jssip-kit 0.7.9 → 1.0.1
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/CHANGELOG.md +17 -0
- package/README.md +105 -17
- package/dist/index.cjs +1178 -1052
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -162
- package/dist/index.d.ts +158 -162
- package/dist/index.js +1175 -1052
- package/dist/index.js.map +1 -1
- package/package.json +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
- Breaking: API surface is now explicitly fixed at package root exports (`src/index.ts`). Internal `core/*` modules are not part of the public contract.
|
|
5
|
+
- Breaking: `SipContext` is no longer exported from package root; use `SipProvider` + hooks (`useSipKernel`, etc.).
|
|
6
|
+
- Breaking: `createSipKernel()` no longer accepts injected `client`/`eventManager`; kernel composition is internal-only.
|
|
7
|
+
- Breaking: video-related API and state were removed (`switchCamera`, `enableVideo`, `disableVideo`, `remoteVideoEnabled`, video track surface).
|
|
8
|
+
- Breaking: platform/jssip-lib transitional structure was removed; architecture is consolidated into `core`.
|
|
9
|
+
- Added: `docs/MODULES.md` with module-level architecture map and ownership notes.
|
|
10
|
+
- Docs: README updated with explicit public API contract and internal boundary.
|
|
11
|
+
|
|
12
|
+
## 0.8.0
|
|
13
|
+
- Breaking: `SipProvider` is now kernel-only and requires `kernel` prop.
|
|
14
|
+
- Added `createSipKernel()` and `SipKernel` as the primary composition API.
|
|
15
|
+
- Added `useSipKernel()` hook for explicit direct kernel access.
|
|
16
|
+
- Hooks migrated internally to kernel interfaces (`store`, `commands`, `events`).
|
|
17
|
+
- Added new core module skeleton (`core/contracts`, `core/modules`, `core/kernel`) for modular architecture.
|
|
18
|
+
- Restored missing `src/jssip-lib/core/sipErrorHandler.ts` to align source with published typings/build output.
|
|
19
|
+
|
|
3
20
|
## 0.4.0
|
|
4
21
|
- Breaking: public client control methods now require an explicit `sessionId` as the first argument (`answer`, `hangup`, mute/hold toggles, DTMF/transfer helpers).
|
|
5
22
|
- Added exports for client-facing types (events, options, RTCSession/UA maps) from the package entrypoint for easier consumption.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# react-jssip-kit
|
|
2
2
|
|
|
3
|
-
React provider and hooks
|
|
3
|
+
React provider and hooks around [JsSIP](https://jssip.net/) for SIP/WebRTC calls with idiomatic React state.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -16,50 +16,138 @@ Peer deps: `react >=18 <20` and `react-dom >=18 <20`.
|
|
|
16
16
|
import React from "react";
|
|
17
17
|
import {
|
|
18
18
|
SipProvider,
|
|
19
|
+
useSipKernel,
|
|
20
|
+
useActiveSipSession,
|
|
19
21
|
useSipState,
|
|
20
22
|
useSipActions,
|
|
21
|
-
|
|
23
|
+
createSipKernel,
|
|
22
24
|
WebSocketInterface,
|
|
23
25
|
} from "react-jssip-kit";
|
|
24
26
|
|
|
25
|
-
const
|
|
27
|
+
const kernel = createSipKernel();
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
function SipBoot() {
|
|
30
|
+
const { commands } = useSipKernel();
|
|
31
|
+
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
commands.connect("sip:alice@example.com", "supersecret", {
|
|
34
|
+
sockets: [new WebSocketInterface("wss://example.com/ws")],
|
|
35
|
+
uri: "sip:example.com",
|
|
36
|
+
display_name: "Alice",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return () => commands.disconnect();
|
|
40
|
+
}, [commands]);
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
32
44
|
|
|
33
45
|
function CallControls() {
|
|
34
|
-
const {
|
|
46
|
+
const { sipStatus } = useSipState();
|
|
47
|
+
const activeSession = useActiveSipSession();
|
|
35
48
|
const { call, hangup, toggleMute } = useSipActions();
|
|
36
|
-
const active = sessions[0];
|
|
37
49
|
|
|
38
50
|
return (
|
|
39
51
|
<div>
|
|
40
52
|
<div>Status: {sipStatus}</div>
|
|
41
53
|
<button onClick={() => call("sip:bob@example.com")}>Call Bob</button>
|
|
42
|
-
<button onClick={() => hangup(
|
|
43
|
-
<button onClick={() => toggleMute(
|
|
54
|
+
<button onClick={() => hangup(activeSession?.id)}>Hang up</button>
|
|
55
|
+
<button onClick={() => toggleMute(activeSession?.id)}>Toggle mute</button>
|
|
44
56
|
</div>
|
|
45
57
|
);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
export function App() {
|
|
49
61
|
return (
|
|
50
|
-
<SipProvider
|
|
62
|
+
<SipProvider kernel={kernel}>
|
|
63
|
+
<SipBoot />
|
|
51
64
|
<CallControls />
|
|
52
65
|
</SipProvider>
|
|
53
66
|
);
|
|
54
67
|
}
|
|
55
68
|
```
|
|
56
69
|
|
|
70
|
+
## Migration
|
|
71
|
+
|
|
72
|
+
`SipProvider` is kernel-only.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
// before
|
|
76
|
+
<SipProvider client={client} />
|
|
77
|
+
|
|
78
|
+
// after
|
|
79
|
+
const kernel = createSipKernel();
|
|
80
|
+
<SipProvider kernel={kernel} />
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Selector-first usage
|
|
84
|
+
|
|
85
|
+
Use selector hooks for minimal re-renders.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { useSipSelector } from "react-jssip-kit";
|
|
89
|
+
|
|
90
|
+
const sipStatus = useSipSelector((state) => state.sipStatus);
|
|
91
|
+
const hasError = useSipSelector((state) => Boolean(state.error));
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { useSipSession, useActiveSipSession } from "react-jssip-kit";
|
|
96
|
+
|
|
97
|
+
const active = useActiveSipSession();
|
|
98
|
+
const current = useSipSession(active?.id);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { useSessionMedia } from "react-jssip-kit";
|
|
103
|
+
|
|
104
|
+
const { remoteStream, audioTracks } = useSessionMedia(sessionId);
|
|
105
|
+
```
|
|
106
|
+
|
|
57
107
|
## API surface
|
|
58
108
|
|
|
59
|
-
- `SipProvider`
|
|
60
|
-
- Hooks: `
|
|
61
|
-
- Components: `CallPlayer` (basic audio
|
|
62
|
-
-
|
|
109
|
+
- `SipProvider` provides `SipKernel` to children.
|
|
110
|
+
- Hooks: `useSipKernel`, `useSipState`, `useSipSelector`, `useSipActions`, `useSipEvent`, `useSipSessionEvent`, `useSipSessions`, `useSipSession`, `useActiveSipSession`, `useSessionMedia`.
|
|
111
|
+
- Components: `CallPlayer` (basic remote audio element).
|
|
112
|
+
- Kernel utilities: `createSipKernel`, `createSipClientInstance`, `createSipEventManager`.
|
|
113
|
+
- Kernel commands include:
|
|
114
|
+
- Call/session: `call`, `answer`, `hangup`, `hangupAll`, `toggleMute`, `toggleHold`, `sendDTMF`, `transfer`, `sendInfo`, `update`, `reinvite`.
|
|
115
|
+
- UA-level: `sendMessage`, `sendOptions`.
|
|
116
|
+
- JsSIP utility: `WebSocketInterface`.
|
|
117
|
+
|
|
118
|
+
## Public API Contract (1.0.0)
|
|
119
|
+
|
|
120
|
+
The package has a single supported entrypoint: `react-jssip-kit`.
|
|
121
|
+
|
|
122
|
+
Public and supported:
|
|
123
|
+
- `SipProvider` and `SipProviderProps`
|
|
124
|
+
- Hooks listed above
|
|
125
|
+
- `CallPlayer`
|
|
126
|
+
- `createSipKernel()`
|
|
127
|
+
- `createSipClientInstance()`
|
|
128
|
+
- `createSipEventManager()`
|
|
129
|
+
- `SipStatus`, `CallStatus`, `CallDirection`
|
|
130
|
+
- Public types exported from root (`SipKernel`, `SipState`, event/call option types)
|
|
131
|
+
- Public state shape: `SipState = { sipStatus, error, sessions }`
|
|
132
|
+
|
|
133
|
+
Internal (not part of public contract):
|
|
134
|
+
- Direct imports from `src/core/*`
|
|
135
|
+
- `SipContext` object
|
|
136
|
+
- Internal normalized fields (`sessionsById`, `sessionIds`)
|
|
137
|
+
- Any file not re-exported from package root
|
|
138
|
+
|
|
139
|
+
## Architecture and Lifecycle
|
|
140
|
+
|
|
141
|
+
Runtime flow (short):
|
|
142
|
+
1. App creates kernel with `createSipKernel()`.
|
|
143
|
+
2. `SipProvider` injects kernel into React tree.
|
|
144
|
+
3. `commands.connect(...)` starts UA and state transitions.
|
|
145
|
+
4. Session events are projected into public `SipState.sessions`.
|
|
146
|
+
5. Media hooks (`useSessionMedia`) observe peer connection/remote tracks.
|
|
147
|
+
6. `commands.disconnect()` stops UA and performs full cleanup.
|
|
148
|
+
|
|
149
|
+
Detailed module map and full lifecycle:
|
|
150
|
+
- `docs/MODULES.md`
|
|
63
151
|
|
|
64
152
|
## Build
|
|
65
153
|
|