@robono/calling-react-native 0.2.1 → 0.2.2

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 CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.2
2
+
3
+ Authenticated event listening, no idle state polling, foreground reconciliation and silent idle-session expiry. Bounded event reconnects preserve existing call controls and optional UI.
4
+
1
5
  # Changes
2
6
 
3
7
  ## 0.2.1
package/README.md CHANGED
@@ -152,3 +152,18 @@ The included CallingHost accepts these optional session fields. Use the same val
152
152
  Incoming, outgoing and connecting cues repeat. Other selected cues play once; defaults keep decline and unanswered calls silent. Local audio interruptions always silence cues. The host app's notification configuration and OS govern background notification sounds; changing an in-app sound does not override that configuration. Supplied WAV assets are available from `/assets/*` for your notification integration.
153
153
 
154
154
  The controller reports platform, package versions, configuration revision and optional components through the authenticated calling session. These client-declared inventory records contain no contact or message data and do not set charges. Service usage counts a same-app call once, separates cross-app directions, and records held and connected time independently.
155
+
156
+ ## Event-based listening
157
+
158
+ Use `@robono/calling@0.1.3` with `@robono/calling-react-native@0.2.2` when using the optional mobile interface. Existing custom interfaces remain supported. See https://robono.com/docs#calling-events for the lifecycle and recovery contract.
159
+
160
+ - Foreground, idle: an authenticated WebSocket listens for incoming calls. No periodic state polling. A ping/pong every 20 seconds maintains presence.
161
+ - Active calls: events trigger state reconciliation immediately; a state health check runs every 3 seconds. The native background fallback also checks every 3 seconds; overlapping checks are coalesced.
162
+ - Idle in background: call `setForeground(false)`. The event socket and state checks stop. Your backend delivers Robono's signed incoming-call events through your app's APNs/FCM notifications. A WebSocket does not replace push delivery.
163
+ - Return to foreground: call `setForeground(true)`. The socket reconnects and current state is checked. Do not create a new call to recover a listening session. The optional controller forwards this lifecycle method to the engine.
164
+ - Event reconnection: delays start at 1 second, double to 30 seconds (plus up to 20% jitter), honor Retry-After, and stop after eight retries. Foreground re-entry can restart recovery. State recovery stops after six consecutive failed idle checks.
165
+ - Expired idle sessions: `onSessionExpired` requests new admission without presenting a failed-call screen. Dispose the expired client and create a new one with a new session from your backend. Use bounded backoff for admission failures. Authorization revocation is not a retryable session expiration. An active call cannot be transferred to a new session.
166
+
167
+ `createHttpTransport` supplies the event subscription automatically. If wrapping it, preserve `request.subscribe = transport.subscribe`. A custom request without `subscribe`, or `{events:false}`, retains the compatibility polling interval (`pollMs`, default 1000 ms).
168
+
169
+ The 0.1.2 engine had polling and retry backoff but did not include this event transport. No native permissions or rebuild are added by this JavaScript patch to an app already using the native calling package.
package/SBOM.spdx.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "@robono/calling-react-native@0.2.1",
6
- "documentNamespace": "https://robono.com/sbom/calling-react-native/0.2.1/fdee611c62a281e0e3c4b7a44c8a3d7392c90c00",
5
+ "name": "@robono/calling-react-native@0.2.2",
6
+ "documentNamespace": "https://robono.com/sbom/calling-react-native/0.2.2/fdee611c62a281e0e3c4b7a44c8a3d7392c90c00",
7
7
  "creationInfo": {
8
8
  "created": "2026-10-25T10:28:57.652Z",
9
9
  "creators": [
@@ -14,7 +14,7 @@
14
14
  {
15
15
  "name": "@robono/calling-react-native",
16
16
  "SPDXID": "SPDXRef-Package",
17
- "versionInfo": "0.2.1",
17
+ "versionInfo": "0.2.2",
18
18
  "downloadLocation": "NOASSERTION",
19
19
  "filesAnalyzed": true,
20
20
  "packageVerificationCode": {
@@ -162,7 +162,7 @@ export function createController({ createClient, request, media, audio, resolveC
162
162
  publish({ speaker: value });
163
163
  sound(state.phase);
164
164
  },
165
- setForeground(value) { foreground = value; sound(state.phase); },
165
+ setForeground(value) { foreground = value; client.setForeground?.(value); sound(state.phase); },
166
166
  async refresh() { return client.refresh(); },
167
167
  async openIncoming(callId) {
168
168
  if (disposed || typeof callId !== 'string' || !callId || callId.length > 128)
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export function createCallingController(options) {
12
12
  return;
13
13
  sent = key;
14
14
  // Inventory is explicitly client-declared; it cannot set charges or access.
15
- void Promise.resolve().then(() => options.request('client-info', { platform: Platform.OS, engineVersion: '0.1.1', mobileVersion: '0.2.0', components: [...components].sort(), appearanceRevision: options.appearanceRevision })).catch(() => { sent = ''; });
15
+ void Promise.resolve().then(() => options.request('client-info', { platform: Platform.OS, engineVersion: '0.1.3', mobileVersion: '0.2.2', components: [...components].sort(), appearanceRevision: options.appearanceRevision })).catch(() => { sent = ''; });
16
16
  };
17
17
  const listen = controller.listen;
18
18
  controller.listen = async () => { await listen(); controller.reportComponents?.([]); };
package/dist/runtime.js CHANGED
@@ -99,7 +99,7 @@ export function createNativeCallRuntime(options) {
99
99
  if (refreshing || now < nextRefresh)
100
100
  return;
101
101
  refreshing = true;
102
- nextRefresh = now + 1000;
102
+ nextRefresh = now + 3000;
103
103
  const currentToken = token;
104
104
  void controller.refresh().then(ok => {
105
105
  if (ok && token === currentToken)
@@ -43,6 +43,7 @@ function AccountCallingHost(props: CallingHostProps & {cleanup: React.MutableRef
43
43
  const [consumed, setConsumed] = useState<string | undefined>();
44
44
  const handled = useRef(new Set<string>());
45
45
  const availabilityNotBefore = useRef(0);
46
+ const idleRenewals = useRef(0);
46
47
  const state = useSyncExternalStore(controller?.subscribe || emptySubscribe, controller?.getSnapshot || idleSnapshot, idleSnapshot);
47
48
  const pendingNotification = props.notificationCallId && consumed !== props.notificationCallId;
48
49
  useEffect(() => { props.onController?.(controller); return () => props.onController?.(null); }, [controller, props.onController]);
@@ -62,8 +63,11 @@ function AccountCallingHost(props: CallingHostProps & {cleanup: React.MutableRef
62
63
  if (!cancelled && !renewing && instance?.client.closed) {
63
64
  renewing = true; clearTimeout(expiryTimer); clearTimeout(renewalTimer); unsubscribe?.();
64
65
  setController(null); setAvailable(false);
65
- setError('Calling access ended. Reconnect to check your access.');
66
66
  props.cleanup.current = dispose();
67
+ if(instance.client.state.listeningStatus==='session_expired' && instance.getSnapshot().phase==='idle' && idleRenewals.current<6){
68
+ const delay=Math.min(30000,1000*2**idleRenewals.current++);
69
+ renewalTimer=setTimeout(()=>{if(!cancelled)setAttempt(value=>value+1);},delay);
70
+ } else setError('Calling access ended. Reconnect to check your access.');
67
71
  return;
68
72
  }
69
73
  if (!cancelled && renewDue && !renewing && instance?.getSnapshot().phase === 'idle') {
@@ -126,7 +130,7 @@ function AccountCallingHost(props: CallingHostProps & {cleanup: React.MutableRef
126
130
  };
127
131
  }, [attempt, props.getSession, props.resolveContact, props.serviceOrigin, props.cleanup, props.createRuntime]);
128
132
  useEffect(() => {
129
- let cancelled = false, timer: ReturnType<typeof setTimeout> | undefined, checking = false;
133
+ let cancelled = false, timer: ReturnType<typeof setTimeout> | undefined, checking = false, failures = 0;
130
134
  setAvailable(false);
131
135
  const check = async () => {
132
136
  clearTimeout(timer);
@@ -136,22 +140,23 @@ function AccountCallingHost(props: CallingHostProps & {cleanup: React.MutableRef
136
140
  timer = setTimeout(check, availabilityNotBefore.current - Date.now()); return;
137
141
  }
138
142
  checking = true;
139
- let nextCheck = 10000;
143
+ let nextCheck = 0;
140
144
  try {
141
145
  const result = await controller.client.availability(props.connectionId);
142
- availabilityNotBefore.current = 0;
146
+ availabilityNotBefore.current = 0; failures = 0;
143
147
  if (!cancelled) setAvailable(result.voiceAvailable);
144
148
  } catch (error) {
145
149
  if (!cancelled) setAvailable(false);
150
+ nextCheck = Math.min(30000, 1000 * 2 ** failures++);
146
151
  const retryAfter = (error as {retryAfterMs?: number}).retryAfterMs;
147
152
  if (Number.isFinite(retryAfter)) nextCheck = Math.min(2147483647, Math.max(nextCheck, retryAfter!));
148
153
  availabilityNotBefore.current = Date.now() + nextCheck;
149
154
  }
150
- finally { checking = false; if (!cancelled) timer = setTimeout(check, nextCheck); }
155
+ finally { checking = false; if (!cancelled && nextCheck > 0 && failures < 6) timer = setTimeout(check, nextCheck); }
151
156
  };
152
157
  const sub = AppState.addEventListener('change', value => {
153
158
  controller?.setForeground(value === 'active');
154
- if (value === 'active') { void controller?.refresh(); void check(); }
159
+ if (value === 'active') { failures = 0; void check(); }
155
160
  else clearTimeout(timer);
156
161
  });
157
162
  void check();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robono/calling-react-native",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Optional branded calling screens, sounds and native audio adapters for Robono calling.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -60,7 +60,7 @@
60
60
  "@types/react": "~19.2.2"
61
61
  },
62
62
  "peerDependencies": {
63
- "@robono/calling": "^0.1.1",
63
+ "@robono/calling": "^0.1.3",
64
64
  "react": ">=18.2 <20",
65
65
  "react-native": ">=0.76 <1",
66
66
  "react-native-svg": ">=15 <16",
@@ -88,11 +88,6 @@
88
88
  "optional": true
89
89
  }
90
90
  },
91
- "scripts": {
92
- "build": "node build.mjs",
93
- "test": "npm run build && node --test test/*.test.mjs",
94
- "prepack": "npm run build"
95
- },
96
91
  "license": "SEE LICENSE IN LICENSE",
97
92
  "homepage": "https://robono.com/docs#calling",
98
93
  "repository": {