@dialstack/sdk-native 0.1.0
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/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/index.d.ts +2367 -0
- package/dist/index.js +5668 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DialStack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @dialstack/sdk-native
|
|
2
|
+
|
|
3
|
+
The React Native softphone components for the DialStack SDK — a headless
|
|
4
|
+
`SoftphoneProvider`, a batteries-included `<Softphone>`, and the composable
|
|
5
|
+
pieces (`<DialPad>` / `<IncomingCall>` / `<OngoingCall>`).
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Softphone, SoftphoneProvider } from '@dialstack/sdk-native';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Why a separate package (not `@dialstack/sdk/native`)
|
|
12
|
+
|
|
13
|
+
This is a distinct package from `@dialstack/sdk` **on purpose**: it declares the
|
|
14
|
+
React Native peer dependencies. Keeping them here means the web SDK's dependency
|
|
15
|
+
graph is _structurally_ free of anything React Native — a web app that installs
|
|
16
|
+
`@dialstack/sdk` can never pull `react-native-webrtc`/`-svg`/`-incall-manager`.
|
|
17
|
+
|
|
18
|
+
`@dialstack/sdk-native` is self-contained: it inlines its own compiled copy of
|
|
19
|
+
the shared headless calling core and call-state hooks at build time, so it has
|
|
20
|
+
**no runtime dependency on `@dialstack/sdk`** (the core is authored once in that
|
|
21
|
+
package and shared at build time only). The core is written to the standard
|
|
22
|
+
browser WebRTC surface (`RTCPeerConnection`, `MediaStream`, `navigator.mediaDevices`);
|
|
23
|
+
call `registerGlobals()` from your WebRTC package at your app's entry point so
|
|
24
|
+
that surface exists on React Native before the SDK runs. The two RN-only gaps —
|
|
25
|
+
outbound ringback audio and E911 persistence — are supplied by the softphone
|
|
26
|
+
provider (an InCallManager-backed ringback and your `storage` adapter).
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// index.js — before anything imports the SDK
|
|
30
|
+
import { registerGlobals } from 'react-native-webrtc';
|
|
31
|
+
registerGlobals();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm install @dialstack/sdk-native \
|
|
38
|
+
'github:dialstack/react-native-webrtc#7e9a0eb55e068b2ba452f22e02e4b789aff9e4ed' \
|
|
39
|
+
react-native-incall-manager react-native-svg libphonenumber-js
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
These are **peer dependencies** — install the versions that match your app.
|
|
43
|
+
|
|
44
|
+
**Install exactly one WebRTC package.** Two of them autolink two copies of the
|
|
45
|
+
native library and the Android build fails with `Duplicate class org.webrtc.*`.
|
|
46
|
+
|
|
47
|
+
We recommend DialStack's fork at the pinned commit above: it is the only build
|
|
48
|
+
that bridges DTMF (see below). If your app already ships a different WebRTC
|
|
49
|
+
package — LiveKit's, Stream's, or stock `react-native-webrtc` — keep that one
|
|
50
|
+
instead and skip ours. The SDK never imports a WebRTC package; it reads the
|
|
51
|
+
globals `registerGlobals()` installs, so any spec-compliant build works. The
|
|
52
|
+
`react-native-webrtc` peer is **optional** precisely so a differently-named
|
|
53
|
+
package can satisfy it without npm installing a second copy alongside.
|
|
54
|
+
|
|
55
|
+
See the example apps under `../mobile/` for a runnable Expo app and a bare React
|
|
56
|
+
Native app.
|
|
57
|
+
|
|
58
|
+
## DTMF
|
|
59
|
+
|
|
60
|
+
DTMF (RFC 4733 telephone-event over the media path) requires **DialStack's fork
|
|
61
|
+
of `react-native-webrtc`**, which adds the `RTCRtpSender.dtmf` bridge that no
|
|
62
|
+
published build ships:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
npm install 'github:dialstack/react-native-webrtc#7e9a0eb55e068b2ba452f22e02e4b789aff9e4ed'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
With any other WebRTC package — including LiveKit's and Stream's forks, neither
|
|
69
|
+
of which exposes `RTCRtpSender.dtmf` — `Call.canSendDtmf` is `false`, the in-call
|
|
70
|
+
keypad stays hidden, `Call.sendDtmf()` throws `call_failed`, and the SDK logs
|
|
71
|
+
`[dialstack] DTMF is unavailable …` on the first call. Calls are otherwise
|
|
72
|
+
unaffected, but there is no way to navigate an IVR or phone tree. That is the
|
|
73
|
+
tradeoff to weigh if another library forces a particular WebRTC package on you.
|
|
74
|
+
|
|
75
|
+
## Storage (required)
|
|
76
|
+
|
|
77
|
+
`<SoftphoneProvider>` requires a `storage` prop — a small `PlatformStorage`
|
|
78
|
+
adapter used to persist the selected E911 address id across launches. The SDK
|
|
79
|
+
takes **no** persistence dependency of its own (react-native-mmkv and
|
|
80
|
+
AsyncStorage vary across versions/architectures and can't be defaulted safely),
|
|
81
|
+
so you supply one:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import type { PlatformStorage } from '@dialstack/sdk-native';
|
|
85
|
+
import { createMMKV } from 'react-native-mmkv';
|
|
86
|
+
|
|
87
|
+
const mmkv = createMMKV();
|
|
88
|
+
const storage: PlatformStorage = {
|
|
89
|
+
getItem: (k) => mmkv.getString(k) ?? null,
|
|
90
|
+
setItem: (k, v) => mmkv.set(k, v),
|
|
91
|
+
removeItem: (k) => mmkv.remove(k),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
<SoftphoneProvider token={token} storage={storage}>
|
|
95
|
+
<Softphone />
|
|
96
|
+
</SoftphoneProvider>;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The Expo `../examples/mobile/expo` app ships this MMKV adapter; the bare
|
|
100
|
+
`../examples/mobile/bare` app ships an AsyncStorage one. Either works —
|
|
101
|
+
`storage` just needs `getItem`/`setItem`/`removeItem`.
|
|
102
|
+
|
|
103
|
+
## Scope
|
|
104
|
+
|
|
105
|
+
This package provides the in-app calling surface: the provider, the call state,
|
|
106
|
+
and the React Native UI. The operating system's own call experience — the
|
|
107
|
+
full-screen incoming call, ringing on a locked screen, and waking the app from a
|
|
108
|
+
push — is the integrator's to wire, using the platform frameworks directly (iOS
|
|
109
|
+
PushKit + CallKit, Android FCM + Telecom/ConnectionService).
|
|
110
|
+
|
|
111
|
+
The seams for that are public. `useSoftphone()` exposes `calls`,
|
|
112
|
+
`incomingCalls`, `activeCall` and `actions.callActionsFor(call)`, and every
|
|
113
|
+
`Call` carries a stable `id` and `state`, so a native call session can be
|
|
114
|
+
created, kept in step, and torn down alongside the SDK's own. DialStack stores
|
|
115
|
+
no device tokens — delivering the push that wakes your app is yours to arrange.
|