@robono/calling-react-native 0.6.0 → 0.8.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.
@@ -12,3 +12,7 @@
12
12
  public void onNewToken(java.lang.String);
13
13
  public void onDeletedMessages();
14
14
  }
15
+
16
+ # Optional WebRTC renderer uses its normal public manager, including its thread and release handling.
17
+ -keep class com.oney.WebRTCModule.WebRTCView { public <init>(android.content.Context); public void setObjectFit(java.lang.String); }
18
+ -keep class com.oney.WebRTCModule.RTCVideoViewManager { public <init>(); public void setStreamURL(com.oney.WebRTCModule.WebRTCView,java.lang.String); }
@@ -9,7 +9,7 @@ import java.util.List;
9
9
 
10
10
  public final class CallingPackage implements ReactPackage {
11
11
  public List<NativeModule> createNativeModules(ReactApplicationContext context) {
12
- return java.util.Arrays.asList(new CallingRuntime(context),new SystemCalling(context));
12
+ return java.util.Arrays.asList(new CallingRuntime(context),new SystemCalling(context),new CallingPictureInPicture(context));
13
13
  }
14
14
  public List<ViewManager> createViewManagers(ReactApplicationContext context) { return Collections.emptyList(); }
15
15
  }
@@ -0,0 +1,102 @@
1
+ package com.robono.calling;
2
+
3
+ import android.app.Activity;
4
+ import android.app.Application;
5
+ import android.app.PictureInPictureParams;
6
+ import android.os.Build;
7
+ import android.os.Bundle;
8
+ import android.os.Handler;
9
+ import android.os.Looper;
10
+ import android.graphics.Color;
11
+ import android.view.View;
12
+ import android.view.ViewGroup;
13
+ import android.widget.FrameLayout;
14
+ import com.facebook.react.bridge.*;
15
+ import java.lang.ref.WeakReference;
16
+ import java.util.IdentityHashMap;
17
+
18
+ /** Uses the existing activity: Android forbids starting a new activity after Home. */
19
+ public final class CallingPictureInPicture extends ReactContextBaseJavaModule implements Application.ActivityLifecycleCallbacks {
20
+ private static WeakReference<CallingPictureInPicture> instance = new WeakReference<>(null);
21
+ private final Handler handler = new Handler(Looper.getMainLooper());
22
+ private final IdentityHashMap<View,Integer> hidden = new IdentityHashMap<>();
23
+ private WeakReference<Activity> owner = new WeakReference<>(null);
24
+ private String streamURL, renderedURL;
25
+ private int width=9,height=16,sourceTag;
26
+ private FrameLayout mainCover;
27
+ private FrameLayout overlay;
28
+ private View renderer;
29
+ private Object manager;
30
+ private Class<?> videoView;
31
+ private boolean launching;
32
+ private final Runnable observe = new Runnable(){public void run(){
33
+ Activity activity=owner.get();
34
+ if(activity==null||activity.isDestroyed()||!activity.isInPictureInPictureMode())release();
35
+ else handler.postDelayed(this,250);
36
+ }};
37
+ public CallingPictureInPicture(ReactApplicationContext context){super(context);instance=new WeakReference<>(this);((Application)context.getApplicationContext()).registerActivityLifecycleCallbacks(this);}
38
+ @Override public String getName(){return "RobonoCallingPictureInPicture";}
39
+ @ReactMethod public void setSource(String url,int sourceWidth,int sourceHeight,boolean enabled,int reactTag,Promise promise){
40
+ UiThreadUtil.runOnUiThread(()->{
41
+ sourceTag=reactTag;
42
+ streamURL=enabled&&url!=null&&!url.isEmpty()?url:null;
43
+ if(sourceWidth>0&&sourceHeight>0){width=sourceWidth;height=sourceHeight;}
44
+ Activity activity=owner.get();
45
+ if(streamURL==null){
46
+ // Keep the opaque cover until Android has removed the pinned window.
47
+ detachVideo();
48
+ if(activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode())activity.moveTaskToBack(true);
49
+ else release();
50
+ }else if(renderer!=null){try{refreshSource();if(activity!=null)activity.setPictureInPictureParams(params());}catch(Exception e){stop();}}
51
+ promise.resolve(Build.VERSION.SDK_INT>=26);
52
+ });
53
+ }
54
+ @ReactMethod public void status(Promise promise){UiThreadUtil.runOnUiThread(()->{Activity activity=owner.get();WritableMap state=Arguments.createMap();state.putBoolean("available",Build.VERSION.SDK_INT>=26&&getReactApplicationContext().getPackageManager().hasSystemFeature("android.software.picture_in_picture"));state.putBoolean("ready",streamURL!=null);state.putBoolean("active",activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode());state.putBoolean("launching",launching);promise.resolve(state);});}
55
+ @ReactMethod public void enter(Promise promise){UiThreadUtil.runOnUiThread(()->promise.resolve(launch(getCurrentActivity())));}
56
+ public static void onUserLeaveHint(Activity activity){CallingPictureInPicture module=instance.get();if(module!=null)module.launch(activity);}
57
+ private PictureInPictureParams params(){double value=(double)width/height;android.util.Rational ratio=value<0.418?new android.util.Rational(9,21):value>2.39?new android.util.Rational(21,9):new android.util.Rational(width,height);return new PictureInPictureParams.Builder().setAspectRatio(ratio).build();}
58
+ private boolean launch(Activity activity){
59
+ if(Build.VERSION.SDK_INT<26||streamURL==null||launching||overlay!=null||activity==null||activity.isFinishing()||activity.isInPictureInPictureMode())return false;
60
+ if(!activity.getPackageManager().hasSystemFeature("android.software.picture_in_picture"))return false;
61
+ try{
62
+ launching=true;owner=new WeakReference<>(activity);
63
+ videoView=Class.forName("com.oney.WebRTCModule.WebRTCView");
64
+ renderer=(View)videoView.getConstructor(android.content.Context.class).newInstance(getReactApplicationContext());
65
+ manager=Class.forName("com.oney.WebRTCModule.RTCVideoViewManager").getConstructor().newInstance();
66
+ videoView.getMethod("setObjectFit",String.class).invoke(renderer,"contain");
67
+ ViewGroup decor=(ViewGroup)activity.getWindow().getDecorView();
68
+ ViewGroup sourceRoot=decor;
69
+ if(sourceTag>0){
70
+ com.facebook.react.bridge.UIManager ui=com.facebook.react.uimanager.UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(),sourceTag);
71
+ View original=ui==null?null:ui.resolveView(sourceTag);
72
+ if(original!=null&&original.getRootView() instanceof ViewGroup)sourceRoot=(ViewGroup)original.getRootView();
73
+ }
74
+ if(sourceRoot!=decor){
75
+ coverChildren(decor);
76
+ mainCover=new FrameLayout(activity);mainCover.setBackgroundColor(Color.BLACK);decor.addView(mainCover,new ViewGroup.LayoutParams(-1,-1));
77
+ }
78
+ decor=sourceRoot;
79
+ overlay=new FrameLayout(activity);overlay.setBackgroundColor(Color.BLACK);
80
+ overlay.addView(renderer,new FrameLayout.LayoutParams(-1,-1));
81
+ // Hide every original child, including native host navigation. Restore exact visibility afterward.
82
+ coverChildren(decor);
83
+ decor.addView(overlay,new ViewGroup.LayoutParams(-1,-1));refreshSource();
84
+ boolean entered=activity.enterPictureInPictureMode(params());launching=false;
85
+ if(!entered){release();return false;}
86
+ handler.postDelayed(observe,250);return true;
87
+ }catch(Exception error){android.util.Log.w("RobonoCallingPiP","Unable to enter picture-in-picture",error);release();return false;}
88
+ }
89
+ private void coverChildren(ViewGroup decor){for(int i=0;i<decor.getChildCount();i++){View child=decor.getChildAt(i);hidden.put(child,child.getVisibility());child.setVisibility(View.INVISIBLE);}}
90
+ private void refreshSource()throws Exception{if(renderer!=null&&streamURL!=null&&!streamURL.equals(renderedURL)){manager.getClass().getMethod("setStreamURL",videoView,String.class).invoke(manager,renderer,streamURL);renderedURL=streamURL;}}
91
+ private void detachVideo(){if(renderer!=null){try{manager.getClass().getMethod("setStreamURL",videoView,String.class).invoke(manager,renderer,null);}catch(Exception ignored){}if(renderer.getParent() instanceof ViewGroup)((ViewGroup)renderer.getParent()).removeView(renderer);}renderer=null;manager=null;renderedURL=null;}
92
+ private void stop(){Activity activity=owner.get();detachVideo();if(activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode()){activity.moveTaskToBack(true);handler.removeCallbacks(observe);handler.postDelayed(observe,250);}else release();}
93
+ private void release(){handler.removeCallbacks(observe);detachVideo();if(overlay!=null&&overlay.getParent() instanceof ViewGroup)((ViewGroup)overlay.getParent()).removeView(overlay);overlay=null;if(mainCover!=null&&mainCover.getParent() instanceof ViewGroup)((ViewGroup)mainCover.getParent()).removeView(mainCover);mainCover=null;for(java.util.Map.Entry<View,Integer> entry:hidden.entrySet())entry.getKey().setVisibility(entry.getValue());hidden.clear();owner.clear();launching=false;}
94
+ @Override public void onActivityResumed(Activity activity){if(activity==owner.get()&&Build.VERSION.SDK_INT>=26&&!activity.isInPictureInPictureMode()&&!launching)release();}
95
+ @Override public void onActivityDestroyed(Activity activity){if(activity==owner.get())release();}
96
+ @Override public void onActivityCreated(Activity activity,Bundle state){}
97
+ @Override public void onActivityStarted(Activity activity){}
98
+ @Override public void onActivityPaused(Activity activity){}
99
+ @Override public void onActivityStopped(Activity activity){}
100
+ @Override public void onActivitySaveInstanceState(Activity activity,Bundle state){}
101
+ @Override public void invalidate(){((Application)getReactApplicationContext().getApplicationContext()).unregisterActivityLifecycleCallbacks(this);UiThreadUtil.runOnUiThread(()->{streamURL=null;stop();if(instance.get()==this)instance=new WeakReference<>(null);});super.invalidate();}
102
+ }
package/app.plugin.cjs CHANGED
@@ -1,8 +1,10 @@
1
1
  const {withInfoPlist, withAndroidManifest, createRunOncePlugin} = require('expo/config-plugins');
2
2
  function withCallingRuntime(config, options = {}) {
3
+ if(options.video&&options.pictureInPicture!==false)config=require('./plugin/picture-in-picture.cjs').withCallPictureInPicture(config);
3
4
  if(options.incomingCalls!==false)config=require('./plugin/incoming-calls.cjs').withIncomingCalls(config);
4
5
  if(options.screenSharing)config=require('./plugin/screensharing.cjs').withScreenSharing(config,typeof options.screenSharing==='object'?options.screenSharing:{});
5
6
  config = withInfoPlist(config, value => {
7
+ value.modResults.RobonoPictureInPictureEnabled=options.video===true&&options.pictureInPicture!==false;
6
8
  if (options.video) value.modResults.NSCameraUsageDescription ||= options.cameraPermission || 'Allow camera access to make video calls.';
7
9
  value.modResults.UIBackgroundModes = [...new Set([...(value.modResults.UIBackgroundModes || []), 'audio'])];
8
10
  if(options.incomingCalls!==false){value.modResults.RobonoSystemCallingEnabled=true;value.modResults.UIBackgroundModes=[...new Set([...value.modResults.UIBackgroundModes,'voip','remote-notification'])];}
@@ -14,6 +16,12 @@ function withCallingRuntime(config, options = {}) {
14
16
  const manifest = value.modResults.manifest;
15
17
  const app=manifest.application?.[0];
16
18
  if(app){
19
+ if(options.video&&options.pictureInPicture!==false){
20
+ const main=app.activity?.find(activity=>activity['intent-filter']?.some(filter=>filter.action?.some(action=>action.$['android:name']==='android.intent.action.MAIN')));
21
+ if(!main)throw Error('Calling picture-in-picture requires a main Android activity.');
22
+ main.$['android:supportsPictureInPicture']='true';main.$['android:resizeableActivity']='true';
23
+ main.$['android:configChanges']=[...new Set([...(main.$['android:configChanges']||'').split('|').filter(Boolean),'screenSize','smallestScreenSize','screenLayout','orientation'])].join('|');
24
+ }
17
25
  const meta=app['meta-data']||=[];const key='com.robono.calling.SYSTEM_CALLING';
18
26
  const row=meta.find(v=>v.$['android:name']===key);const data={'android:name':key,'android:value':options.incomingCalls===false?'false':'true'};if(row)row.$=data;else meta.push({$:data});
19
27
  app.service=(app.service||[]).filter(v=>v.$['android:name']!=='com.robono.calling.SystemCallMessagingService');
@@ -1,7 +1,7 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import type { CallHistoryEntry } from '@robono/calling';
3
3
  /** A call record, aligned with its caller. Separate from the text-bubble component. */
4
- export declare function CallRecord({ entry, incomingColor, outgoingColor, textColor, secondaryColor, onCallBack, label, children, showTime }: {
4
+ export interface CallRecordProps {
5
5
  entry: CallHistoryEntry;
6
6
  incomingColor: string;
7
7
  outgoingColor: string;
@@ -16,4 +16,5 @@ export declare function CallRecord({ entry, incomingColor, outgoingColor, textCo
16
16
  };
17
17
  children?: ReactNode;
18
18
  showTime?: boolean;
19
- }): React.JSX.Element;
19
+ }
20
+ export declare function CallRecord({ entry, incomingColor, outgoingColor, textColor, secondaryColor, onCallBack, label, children, showTime }: CallRecordProps): React.JSX.Element;
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import React from 'react';
3
3
  import { Pressable, StyleSheet, Text, View } from 'react-native';
4
4
  import { RobonoIcon } from './visual/RobonoIcon.js';
5
- /** A call record, aligned with its caller. Separate from the text-bubble component. */
6
5
  export function CallRecord({ entry, incomingColor, outgoingColor, textColor = '#ffffff', secondaryColor, onCallBack, label, children, showTime = false }) {
7
6
  const description = label(entry);
8
7
  const incoming = entry.role === 'callee';
@@ -1,5 +1,6 @@
1
1
  import React, { type ComponentType, type ReactNode } from 'react';
2
2
  import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
3
+ import type { CallDiagnostics } from '@robono/calling';
3
4
  import { callingText, callingIcons, resolveCallingDesign, type CallingAppearance } from './appearance.js';
4
5
  import type { CallingState } from './types.js';
5
6
  export interface CallingTheme {
@@ -66,6 +67,13 @@ export interface CallingScreenComponents {
66
67
  ActionButton?: ComponentType<CallingActionButtonProps>;
67
68
  }
68
69
  export interface CallingScreenProps {
70
+ /** Supplied automatically by connected overlays; read only while details are open. */
71
+ getDiagnostics?(): Promise<CallDiagnostics>;
72
+ diagnostics?: false | {
73
+ labels?: Partial<typeof callDiagnosticsText>;
74
+ };
75
+ /** Allow the connected remote video to use the operating system floating window. */
76
+ pictureInPicture?: boolean;
69
77
  state: CallingState;
70
78
  appearance?: CallingAppearance;
71
79
  onScreenShare?(): void;
@@ -76,6 +84,7 @@ export interface CallingScreenProps {
76
84
  stream: MediaStream;
77
85
  local: boolean;
78
86
  screen?: boolean;
87
+ pictureInPicture?: boolean;
79
88
  style: StyleProp<ViewStyle>;
80
89
  }): ReactNode;
81
90
  onResume?(): void;
@@ -94,6 +103,9 @@ export interface CallingScreenProps {
94
103
  components?: CallingScreenComponents;
95
104
  }
96
105
  export interface CallingUIValue {
106
+ getDiagnostics?: CallingScreenProps['getDiagnostics'];
107
+ diagnostics?: CallingScreenProps['diagnostics'];
108
+ pictureInPicture: boolean;
97
109
  renderVideo?: CallingScreenProps['renderVideo'];
98
110
  state: Readonly<CallingState>;
99
111
  appearance?: CallingAppearance;
@@ -130,6 +142,21 @@ export declare function CallingActionButton({ action, style, iconStyle, labelSty
130
142
  export declare function CallingAudioControls({ style }?: CallingSectionProps): React.JSX.Element | null;
131
143
  export declare function CallingIncomingControls({ style }?: CallingSectionProps): React.JSX.Element | null;
132
144
  export declare function CallingControls({ style }?: CallingSectionProps): React.JSX.Element;
145
+ export declare const callDiagnosticsText: {
146
+ details: string;
147
+ checking: string;
148
+ unavailable: string;
149
+ good: string;
150
+ fair: string;
151
+ poor: string;
152
+ delay: string;
153
+ loss: string;
154
+ video: string;
155
+ participant: string;
156
+ explanation: string;
157
+ };
158
+ /** Small on-demand panel. Never records audio, submits logs or changes call controls. */
159
+ export declare function CallingConnectionDetails(): React.JSX.Element | null;
133
160
  /** Video uses the same SDK layout, labels and controls on native and web. */
134
161
  export declare function CallingVideo({ style }?: CallingSectionProps): React.JSX.Element | null;
135
162
  export {};
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { createContext, useContext, useEffect, useState } from 'react';
3
- import { Image, Platform, Pressable, ScrollView, StyleSheet, Text, View, useColorScheme } from 'react-native';
2
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
3
+ import { AppState, Image, Platform, Pressable, ScrollView, StyleSheet, Text, View, useColorScheme } from 'react-native';
4
4
  import { RobonoIcon } from './visual/RobonoIcon.js';
5
5
  import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
6
6
  import { callingText, callingInk, resolveCallingDesign } from './appearance.js';
@@ -52,7 +52,8 @@ export function CallingUIProvider({ children, ...props }) {
52
52
  };
53
53
  const fontFamily = Platform.OS === 'ios' ? design.fontFamily.ios : Platform.OS === 'android' ? design.fontFamily.android : design.fontFamily.web;
54
54
  const value = {
55
- state: s, renderVideo: props.renderVideo, appearance: props.appearance, theme: c, labels: t, design,
55
+ getDiagnostics: props.getDiagnostics, diagnostics: props.diagnostics,
56
+ state: s, pictureInPicture: props.pictureInPicture !== false, renderVideo: props.renderVideo, appearance: props.appearance, theme: c, labels: t, design,
56
57
  insets: props.insets || safeArea, components: props.components || {},
57
58
  title: s.contact?.name || t.contact,
58
59
  status: s.phase === 'connected' ? duration : s.phase === 'error' || s.phase === 'idle' ? '' : s.phase === 'incoming' && s.kind === 'video' ? t.incomingVideo : t[s.phase],
@@ -130,7 +131,7 @@ export function CallingIncomingControls({ style } = {}) {
130
131
  }
131
132
  /** Essential controls stay visible; secondary tools open above the dock. */
132
133
  function CallingConferenceControls({ style }) {
133
- const { actions, components, state, theme, labels, typography, design } = useCallingUI();
134
+ const { actions, components, state, theme, labels, typography, design, getDiagnostics, diagnostics } = useCallingUI();
134
135
  const Button = components.ActionButton || CallingActionButton;
135
136
  const [expanded, setExpanded] = useState(false);
136
137
  const secondary = (state.kind === 'video' ? ['speaker', 'flip', 'share'] : []).filter(action => actions[action].visible);
@@ -138,7 +139,7 @@ function CallingConferenceControls({ style }) {
138
139
  const icon = { width: 48, height: 48 };
139
140
  const label = typography(12);
140
141
  useEffect(() => { setExpanded(false); }, [state.phase]);
141
- return _jsxs(View, { style: [{ position: 'relative', zIndex: 2, paddingVertical: 8 }, style], children: [expanded && _jsx(View, { testID: "calling-more-tools", style: { marginBottom: 12, width: '100%', maxWidth: 420, alignSelf: 'center', borderRadius: 18, padding: 16, backgroundColor: theme.control }, children: _jsx(View, { style: { flexDirection: 'row', justifyContent: 'space-evenly', gap: 12 }, children: secondary.map(action => _jsx(Button, { action: action, style: compact, iconStyle: icon, labelStyle: label }, action)) }) }), _jsxs(View, { testID: "calling-main-controls", style: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'center', gap: 12, maxWidth: 420, width: '100%', alignSelf: 'center' }, children: [_jsx(Button, { action: "mute", style: compact, iconStyle: icon, labelStyle: label }), actions.camera.visible && _jsx(Button, { action: "camera", style: compact, iconStyle: icon, labelStyle: label }), state.kind !== 'video' && _jsx(Button, { action: "speaker", style: compact, iconStyle: icon, labelStyle: label }), secondary.length > 0 && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: labels.more, accessibilityState: { expanded }, onPress: () => setExpanded(value => !value), style: [styles.button, compact], children: [_jsx(View, { style: [styles.circle, icon, { borderRadius: design.controlRadius, backgroundColor: expanded ? theme.foreground : theme.control }], children: _jsx(RobonoIcon, { name: "more", size: 24, color: expanded ? theme.background : theme.foreground }) }), _jsx(Text, { style: [label, { color: theme.foreground, textAlign: 'center' }], children: labels.more })] }), _jsx(Button, { action: "end", style: [compact, { marginLeft: 8 }], iconStyle: icon, labelStyle: label })] })] });
142
+ return _jsxs(View, { style: [{ position: 'relative', zIndex: 2, paddingVertical: 8 }, style], children: [expanded && _jsxs(View, { testID: "calling-more-tools", style: { marginBottom: 12, width: '100%', maxWidth: 420, alignSelf: 'center', borderRadius: 18, padding: 16, backgroundColor: theme.control }, children: [_jsx(View, { style: { flexDirection: 'row', justifyContent: 'space-evenly', gap: 12 }, children: secondary.map(action => _jsx(Button, { action: action, style: compact, iconStyle: icon, labelStyle: label }, action)) }), _jsx(CallingConnectionDetails, {})] }), _jsxs(View, { testID: "calling-main-controls", style: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'center', gap: 12, maxWidth: 420, width: '100%', alignSelf: 'center' }, children: [_jsx(Button, { action: "mute", style: compact, iconStyle: icon, labelStyle: label }), actions.camera.visible && _jsx(Button, { action: "camera", style: compact, iconStyle: icon, labelStyle: label }), state.kind !== 'video' && _jsx(Button, { action: "speaker", style: compact, iconStyle: icon, labelStyle: label }), (secondary.length > 0 || getDiagnostics && diagnostics !== false && state.phase === 'connected') && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: labels.more, accessibilityState: { expanded }, onPress: () => setExpanded(value => !value), style: [styles.button, compact], children: [_jsx(View, { style: [styles.circle, icon, { borderRadius: design.controlRadius, backgroundColor: expanded ? theme.foreground : theme.control }], children: _jsx(RobonoIcon, { name: "more", size: 24, color: expanded ? theme.background : theme.foreground }) }), _jsx(Text, { style: [label, { color: theme.foreground, textAlign: 'center' }], children: labels.more })] }), _jsx(Button, { action: "end", style: [compact, { marginLeft: 8 }], iconStyle: icon, labelStyle: label })] })] });
142
143
  }
143
144
  export function CallingControls({ style } = {}) {
144
145
  const { actions, components, state } = useCallingUI();
@@ -149,7 +150,60 @@ export function CallingControls({ style } = {}) {
149
150
  return _jsxs(View, { style: [{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', gap: 24, paddingVertical: 8 }, style], children: [actions.resume.visible && _jsx(Button, { action: "resume" }), _jsx(Button, { action: "end", iconStyle: { width: 48, height: 48 }, labelStyle: { fontSize: 12 } })] });
150
151
  if ((state.kind === 'video' || state.group) && ['outgoing', 'connecting', 'connected'].includes(state.phase))
151
152
  return _jsx(CallingConferenceControls, { style: style });
152
- return _jsxs(View, { style: [styles.controls, style], children: [actions.resume.visible && _jsx(Button, { action: "resume" }), actions.mute.visible && _jsx(Audio, {}), actions.close.visible ? _jsx(Button, { action: "close" }) : state.phase === 'incoming' ? _jsx(Incoming, {}) : _jsx(View, { style: styles.row, children: _jsx(Button, { action: "end" }) })] });
153
+ return _jsxs(View, { style: [styles.controls, style], children: [actions.resume.visible && _jsx(Button, { action: "resume" }), actions.mute.visible && _jsx(Audio, {}), _jsx(CallingConnectionDetails, {}), actions.close.visible ? _jsx(Button, { action: "close" }) : state.phase === 'incoming' ? _jsx(Incoming, {}) : _jsx(View, { style: styles.row, children: _jsx(Button, { action: "end" }) })] });
154
+ }
155
+ export const callDiagnosticsText = {
156
+ details: 'Connection details', checking: 'Checking connection…', unavailable: 'Measurements unavailable',
157
+ good: 'Connection looks good', fair: 'Connection may affect the call', poor: 'Connection is struggling',
158
+ delay: 'Round-trip delay', loss: 'Lost incoming data', video: 'Incoming video', participant: 'Participant',
159
+ explanation: 'Estimates from this device. Missing measurements are not treated as zero.',
160
+ };
161
+ /** Small on-demand panel. Never records audio, submits logs or changes call controls. */
162
+ export function CallingConnectionDetails() {
163
+ const { getDiagnostics, diagnostics, state, theme, typography } = useCallingUI();
164
+ const labels = { ...callDiagnosticsText, ...(diagnostics === false ? {} : diagnostics?.labels) };
165
+ const [expanded, setExpanded] = useState(false), [sample, setSample] = useState(null), [unavailable, setUnavailable] = useState(false);
166
+ const [foreground, setForeground] = useState(AppState.currentState !== 'background' && AppState.currentState !== 'inactive');
167
+ const read = useRef(getDiagnostics);
168
+ read.current = getDiagnostics;
169
+ useEffect(() => { const sub = AppState.addEventListener('change', value => setForeground(value === 'active')); return () => sub.remove(); }, []);
170
+ useEffect(() => { setExpanded(false); setSample(null); }, [state.call?.id, state.connectedAt, state.phase]);
171
+ const enabled = !!getDiagnostics && diagnostics !== false && state.phase === 'connected';
172
+ useEffect(() => {
173
+ if (!enabled || !expanded || !foreground) {
174
+ setSample(null);
175
+ return;
176
+ }
177
+ let current = true, timer;
178
+ setUnavailable(false);
179
+ const refresh = async () => { try {
180
+ const result = await read.current();
181
+ if (current) {
182
+ setSample(result);
183
+ setUnavailable(!result.peers.length);
184
+ }
185
+ }
186
+ catch {
187
+ if (current) {
188
+ setSample(null);
189
+ setUnavailable(true);
190
+ }
191
+ }
192
+ finally {
193
+ if (current)
194
+ timer = setTimeout(refresh, 2000);
195
+ } };
196
+ void refresh();
197
+ return () => { current = false; clearTimeout(timer); };
198
+ }, [enabled, expanded, foreground, state.call?.id, state.connectedAt]);
199
+ if (!enabled)
200
+ return null;
201
+ const textStyle = [typography(14), { color: theme.foreground }];
202
+ return _jsxs(View, { style: { width: '100%', maxWidth: 420, alignSelf: 'center' }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityState: { expanded }, accessibilityLabel: labels.details, onPress: () => setExpanded(v => !v), style: { minHeight: 44, alignItems: 'center', justifyContent: 'center', flexDirection: 'row', gap: 8 }, children: [_jsx(RobonoIcon, { name: "activity", size: 18, color: theme.accent }), _jsx(Text, { style: [...textStyle, { color: theme.accent }], children: labels.details })] }), expanded && _jsxs(ScrollView, { testID: "calling-connection-details", style: { maxHeight: 220, backgroundColor: theme.control, borderRadius: 12 }, contentContainerStyle: { padding: 12, gap: 12 }, children: [(!sample?.peers.length) && _jsx(Text, { style: textStyle, children: unavailable ? labels.unavailable : labels.checking }), sample?.peers.map((peer, index) => {
203
+ const losses = peer.media.map(m => m.receiveLossPercent).filter((n) => n !== null), video = peer.media.find(m => m.kind === 'video' && m.width && m.height);
204
+ const title = peer.participant === null ? null : state.groupMembers?.find(m => m.id === peer.participant)?.name ?? `${labels.participant} ${index + 1}`;
205
+ return _jsxs(View, { style: { gap: 5 }, children: [title && _jsx(Text, { style: [...textStyle, { fontWeight: '600' }], children: title }), _jsx(Text, { style: textStyle, children: peer.quality === 'unknown' ? labels.unavailable : labels[peer.quality] }), _jsxs(Text, { style: [typography(13), { color: theme.secondary }], children: [labels.delay, ": ", peer.roundTripMs === null ? '—' : `${Math.round(peer.roundTripMs)} ms`, " \u00B7 ", labels.loss, ": ", losses.length ? `${Math.max(...losses).toFixed(1)}%` : '—'] }), video && _jsxs(Text, { style: [typography(13), { color: theme.secondary }], children: [labels.video, ": ", video.width, " \u00D7 ", video.height, video.framesPerSecond === null ? '' : ` · ${Math.round(video.framesPerSecond)} fps`] })] }, peer.participant ?? index);
206
+ }), _jsx(Text, { style: [typography(12), { color: theme.secondary }], children: labels.explanation })] })] });
153
207
  }
154
208
  const styles = StyleSheet.create({
155
209
  screen: { flexGrow: 1, paddingHorizontal: 24, justifyContent: 'space-between', gap: 40 },
@@ -164,12 +218,13 @@ const styles = StyleSheet.create({
164
218
  });
165
219
  /** Video uses the same SDK layout, labels and controls on native and web. */
166
220
  export function CallingVideo({ style } = {}) {
167
- const { state, renderVideo, theme, typography, labels, design } = useCallingUI();
221
+ const { state, renderVideo, pictureInPicture, theme, typography, labels, design } = useCallingUI();
168
222
  const [area, setArea] = useState({ width: 0, height: 0 });
169
223
  if (state.group && ['outgoing', 'connecting', 'connected', 'held'].includes(state.phase)) {
170
224
  const members = state.groupMembers?.filter(m => !['left', 'declined'].includes(m.state)) ?? [], sharing = members.find(m => m.sharing);
225
+ const pipMember = members.find(m => !m.local && !m.held && m.sharing && m.stream) ?? members.find(m => !m.local && !m.held && m.stream);
171
226
  const tile = (member, tileStyle, compact = false) => _jsxs(View, { style: [{ flex: 1, minHeight: 60, overflow: 'hidden', borderRadius: 12, backgroundColor: theme.control, alignItems: 'center', justifyContent: 'center' }, tileStyle], children: [state.kind === 'video' && member.stream && renderVideo && !member.held && state.phase !== 'held' && (member.sharing || !member.local || state.cameraEnabled !== false)
172
- ? renderVideo({ stream: member.stream, local: !!member.local, screen: member.sharing, style: { position: 'absolute', width: '100%', height: '100%' } })
227
+ ? renderVideo({ stream: member.stream, local: !!member.local, screen: member.sharing, pictureInPicture: pictureInPicture && state.phase === 'connected' && member === pipMember, style: { position: 'absolute', width: '100%', height: '100%' } })
173
228
  : design.presentation.showAvatar && _jsx(View, { style: { width: compact ? 36 : avatarSize, height: compact ? 36 : avatarSize, borderRadius: 40, backgroundColor: theme.background, alignItems: 'center', justifyContent: 'center' }, children: member.avatarUri ? _jsx(Image, { source: { uri: member.avatarUri }, style: { width: compact ? 36 : avatarSize, height: compact ? 36 : avatarSize, borderRadius: 40 } }) : _jsx(Text, { style: [typography(28), { color: theme.accent }], children: member.name.slice(0, 1) }) }), _jsx(View, { style: { position: 'absolute', bottom: 8, left: 8, maxWidth: '90%', borderRadius: 6, paddingHorizontal: 8, paddingVertical: 4, backgroundColor: '#000000b0' }, children: _jsxs(Text, { numberOfLines: 1, style: [typography(12), { color: '#ffffff', textAlign: 'left' }], children: [member.name, member.sharing ? ' · ' + labels.sharingScreen : '', member.held ? ' · ' + labels.held : member.state === 'invited' ? ' · ' + labels.outgoing : ''] }) })] }, member.id);
174
229
  const landscape = area.width > area.height;
175
230
  const columns = Math.max(1, Math.min(members.length, landscape && area.width > 700 && members.length > 4 ? 4 : landscape || members.length > 2 ? 2 : 1));
@@ -180,6 +235,6 @@ export function CallingVideo({ style } = {}) {
180
235
  if (state.kind !== 'video' || !['outgoing', 'connecting', 'connected', 'held'].includes(state.phase) || !renderVideo)
181
236
  return null;
182
237
  const visible = !['held', 'idle', 'error'].includes(state.phase);
183
- return _jsxs(View, { style: [{ flex: 1, minHeight: 100, borderRadius: 16, overflow: 'hidden', backgroundColor: theme.control }, style], children: [visible && state.remoteStream ? renderVideo({ stream: state.remoteStream, local: false, screen: state.remoteScreenSharing, style: { width: '100%', height: '100%' } }) :
238
+ return _jsxs(View, { style: [{ flex: 1, minHeight: 100, borderRadius: 16, overflow: 'hidden', backgroundColor: theme.control }, style], children: [visible && state.remoteStream ? renderVideo({ stream: state.remoteStream, local: false, screen: state.remoteScreenSharing, pictureInPicture: pictureInPicture && state.phase === 'connected', style: { width: '100%', height: '100%' } }) :
184
239
  _jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [_jsx(CallingAvatar, { size: 80 }), _jsx(Text, { style: [typography(16), { color: theme.secondary }], children: state.phase === 'held' ? labels.held : labels.connecting })] }), visible && (state.screenSharing || state.remoteScreenSharing) && _jsx(Text, { style: [typography(13), { position: 'absolute', top: 8, left: 8, padding: 6, borderRadius: 5, color: '#ffffff', backgroundColor: '#000000b0' }], children: labels.sharingScreen }), visible && state.localStream && (state.screenSharing || state.cameraEnabled !== false) && _jsx(View, { style: { position: 'absolute', right: 10, bottom: 10, width: 86, height: 114, borderRadius: 10, overflow: 'hidden' }, children: renderVideo({ stream: state.displayStream || state.localStream, local: true, screen: state.screenSharing, style: { width: '100%', height: '100%' } }) })] });
185
240
  }
@@ -107,6 +107,7 @@ export function createController({ createClient, request, media, audio, resolveC
107
107
  };
108
108
  return {
109
109
  client,
110
+ getDiagnostics: () => client.getDiagnostics(),
110
111
  getSnapshot: () => state,
111
112
  subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); },
112
113
  async listen() { if (disposed)
package/dist/groups.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface GroupCallingOptions extends Omit<CallingOptions, 'resolveContac
8
8
  }
9
9
  export declare function createGroupCallingController(options: GroupCallingOptions): {
10
10
  client: RobonoGroupCallingClient;
11
+ getDiagnostics: () => Promise<import("@robono/calling").CallDiagnostics>;
11
12
  getSnapshot: () => CallingState;
12
13
  subscribe: (fn: () => void) => () => void;
13
14
  listen(): Promise<void>;
package/dist/groups.js CHANGED
@@ -27,7 +27,7 @@ export function createGroupCallingController(options) {
27
27
  const components = new Set(['controller', ...(options.media.robonoAdapter ? ['native-media'] : []), ...(options.audio.robonoAdapter ? ['native-audio'] : [])]);
28
28
  const inventory = () => void options.request('client-info', { platform: Platform.OS, engineVersion, mobileVersion, components: [...components], appearanceRevision: options.appearanceRevision }).catch(report);
29
29
  const client = new RobonoGroupCallingClient({ ...options.media, request: options.request, forceRelay: options.forceRelay, onChange: apply });
30
- return { client, getSnapshot: () => state, subscribe: (fn) => { listeners.add(fn); return () => { listeners.delete(fn); }; },
30
+ return { client, getDiagnostics: () => client.getDiagnostics(), getSnapshot: () => state, subscribe: (fn) => { listeners.add(fn); return () => { listeners.delete(fn); }; },
31
31
  async listen() { await client.listen(); inventory(); },
32
32
  reportComponents(values) { values.forEach(v => components.add(v)); inventory(); },
33
33
  async call(connectionId, input = {}) { pendingKind = input.kind ?? 'voice'; pending = true; state = { ...state, contact: options.resolveGroup?.(connectionId) ?? { name: 'Group call' }, kind: pendingKind, phase: 'outgoing' }; sound(); emit(); try {
@@ -87,5 +87,5 @@ export function createGroupCallingController(options) {
87
87
  export function GroupCallingOverlay({ controller, ...props }) {
88
88
  const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
89
89
  useEffect(() => { controller.reportComponents(['screens']); controller.setForeground(AppState.currentState === 'active'); const s = AppState.addEventListener('change', v => controller.setForeground(v === 'active')); return () => s.remove(); }, [controller]);
90
- return _jsx(Modal, { visible: state.phase !== 'idle', animationType: "none", presentationStyle: "fullScreen", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: _jsx(SafeAreaProvider, { children: _jsx(CallingScreen, { ...props, state: state, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: controller.mute, onSpeaker: controller.setSpeaker, onScreenShare: () => { void (state.screenSharing ? controller.stopScreenSharing() : controller.startScreenSharing()).catch(() => { }); }, onCamera: controller.setCamera, onSwitchCamera: () => { void controller.switchCamera().catch(() => { }); }, onResume: () => { void controller.resume().catch(() => { }); }, onClose: controller.dismissError }) }) });
90
+ return _jsx(Modal, { visible: state.phase !== 'idle', animationType: "none", presentationStyle: "fullScreen", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: _jsx(SafeAreaProvider, { children: _jsx(CallingScreen, { ...props, getDiagnostics: controller.getDiagnostics, state: state, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: controller.mute, onSpeaker: controller.setSpeaker, onScreenShare: () => { void (state.screenSharing ? controller.stopScreenSharing() : controller.startScreenSharing()).catch(() => { }); }, onCamera: controller.setCamera, onSwitchCamera: () => { void controller.switchCamera().catch(() => { }); }, onResume: () => { void controller.resume().catch(() => { }); }, onClose: controller.dismissError }) }) });
91
91
  }
package/dist/history.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { CallRecord } from './CallRecord.js';
3
- type Props = Omit<React.ComponentProps<typeof CallRecord>, 'label'> & {
4
- label?: React.ComponentProps<typeof CallRecord>['label'];
2
+ import { type CallRecordProps } from './CallRecord.js';
3
+ export type CallHistoryItemProps = Omit<CallRecordProps, 'label'> & {
4
+ label?: CallRecordProps['label'];
5
5
  };
6
- export declare function CallHistoryItem({ label, ...props }: Props): React.JSX.Element;
7
- export {};
6
+ export declare function CallHistoryItem({ label, ...props }: CallHistoryItemProps): React.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { CallingController, CallingOptions } from './types.js';
2
2
  export declare function createCallingController(options: CallingOptions): CallingController;
3
3
  export { CallingScreen, CallingOverlay, useCalling } from './screens.js';
4
- export { CallHistoryItem } from './history.js';
4
+ export { CallHistoryItem, type CallHistoryItemProps } from './history.js';
5
+ export type { CallRecordProps } from './CallRecord.js';
5
6
  export type { CallingScreenProps, CallingOverlayProps, CallingLabels, CallingTheme } from './screens.js';
6
7
  export type { CallAudio, CallingState, CallingController, CallingOptions, Contact, MediaAdapter, Phase } from './types.js';
7
8
  export { callingInk, resolveCallingDesign, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
8
9
  export type { CallingAppearance, CallingPresentation, SoundChoice, SoundEvent } from './appearance.js';
9
- export { CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
10
+ export { CallingConnectionDetails, callDiagnosticsText, CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
10
11
  export type { CallingUIProviderProps, CallingUIValue, CallingScreenComponents, CallingAction, CallingActionModel, CallingSectionProps, CallingLayoutProps, CallingAvatarProps, CallingContactProps, CallingStatusProps, CallingActionButtonProps, } from './components.js';
package/dist/index.js CHANGED
@@ -22,4 +22,4 @@ export function createCallingController(options) {
22
22
  export { CallingScreen, CallingOverlay, useCalling } from './screens.js';
23
23
  export { CallHistoryItem } from './history.js';
24
24
  export { callingInk, resolveCallingDesign, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
25
- export { CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
25
+ export { CallingConnectionDetails, callDiagnosticsText, CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
@@ -1,7 +1,24 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState, useRef } from 'react';
3
+ import { NativeModules, Platform, findNodeHandle } from 'react-native';
2
4
  import { RTCView } from 'react-native-webrtc';
3
5
  import { CallingOverlay } from './screens.js';
4
- export const renderNativeCallVideo = ({ stream, local, screen, style }) => _jsx(RTCView, { streamURL: stream.toURL(), mirror: local && !screen, objectFit: screen ? "contain" : "cover", zOrder: local ? 1 : 0, style: style });
6
+ function NativeCallVideo({ stream, local, screen, style, pictureInPicture }) {
7
+ const view = useRef(null);
8
+ const url = stream.toURL();
9
+ const [size, setSize] = useState(screen ? { width: 16, height: 9 } : { width: 9, height: 16 });
10
+ useEffect(() => {
11
+ if (Platform.OS === 'android' && pictureInPicture && !local)
12
+ void NativeModules.RobonoCallingPictureInPicture?.setSource(url, size.width, size.height, true, findNodeHandle(view.current) ?? 0).catch(() => { });
13
+ }, [url, pictureInPicture, local, size.width, size.height]);
14
+ useEffect(() => () => {
15
+ if (Platform.OS === 'android' && pictureInPicture && !local)
16
+ void NativeModules.RobonoCallingPictureInPicture?.setSource('', 9, 16, false, 0).catch(() => { });
17
+ }, [url, pictureInPicture, local]);
18
+ return _jsx(RTCView, { ref: view, streamURL: url, onDimensionsChange: event => { const { width, height } = event.nativeEvent; if (width > 0 && height > 0)
19
+ setSize(previous => previous.width === width && previous.height === height ? previous : { width, height }); }, mirror: local && !screen, objectFit: screen ? "contain" : "cover", zOrder: local ? 1 : 0, style: style, iosPIP: Platform.OS === 'ios' && !local && pictureInPicture && NativeModules.RobonoCallingRuntime?.pictureInPictureEnabled !== false ? { enabled: true, startAutomatically: true, stopAutomatically: true, preferredSize: screen ? { width: 640, height: 360 } : { width: 360, height: 640 } } : { enabled: false } });
20
+ }
21
+ export const renderNativeCallVideo = props => _jsx(NativeCallVideo, { ...props });
5
22
  /** Optional complete native screen; the calling engine can also use your UI. */
6
23
  export function NativeCallingOverlay(props) {
7
24
  return _jsx(CallingOverlay, { ...props, renderVideo: props.renderVideo || renderNativeCallVideo });
package/dist/screens.js CHANGED
@@ -30,5 +30,5 @@ export function CallingOverlay({ controller, ...props }) {
30
30
  return () => sub.remove();
31
31
  }, [controller]);
32
32
  const active = state.phase !== 'idle';
33
- return _jsx(Modal, { visible: active, presentationStyle: "fullScreen", animationType: "none", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: active && _jsxs(SafeAreaProvider, { children: [_jsx(StatusBar, { barStyle: callingInk(props.theme?.background || design.colors.background) === '#000000' ? 'dark-content' : 'light-content' }), _jsx(CallingScreen, { ...props, state: state, onResume: () => { void controller.resume().catch(() => { }); }, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: value => controller.mute(value), onScreenShare: controller.startScreenSharing ? () => { void (state.screenSharing ? controller.stopScreenSharing?.() : controller.startScreenSharing?.())?.catch(() => { }); } : undefined, onCamera: controller.setCamera ? value => controller.setCamera?.(value) : undefined, onSwitchCamera: controller.switchCamera ? () => { void controller.switchCamera?.(); } : undefined, onSpeaker: value => controller.setSpeaker(value), onClose: () => controller.dismissError() })] }) });
33
+ return _jsx(Modal, { visible: active, presentationStyle: "fullScreen", animationType: "none", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: active && _jsxs(SafeAreaProvider, { children: [_jsx(StatusBar, { barStyle: callingInk(props.theme?.background || design.colors.background) === '#000000' ? 'dark-content' : 'light-content' }), _jsx(CallingScreen, { ...props, getDiagnostics: controller.getDiagnostics, state: state, onResume: () => { void controller.resume().catch(() => { }); }, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: value => controller.mute(value), onScreenShare: controller.startScreenSharing ? () => { void (state.screenSharing ? controller.stopScreenSharing?.() : controller.startScreenSharing?.())?.catch(() => { }); } : undefined, onCamera: controller.setCamera ? value => controller.setCamera?.(value) : undefined, onSwitchCamera: controller.switchCamera ? () => { void controller.switchCamera?.(); } : undefined, onSpeaker: value => controller.setSpeaker(value), onClose: () => controller.dismissError() })] }) });
34
34
  }
package/dist/types.d.ts CHANGED
@@ -82,6 +82,7 @@ export interface CallingOptions {
82
82
  }) => void;
83
83
  }
84
84
  export interface CallingController {
85
+ getDiagnostics?(): Promise<import('@robono/calling').CallDiagnostics>;
85
86
  reportComponents?(components: string[]): void;
86
87
  readonly client: RobonoCallingClient;
87
88
  getSnapshot(): CallingState;
@@ -1,2 +1,2 @@
1
- export declare const mobileVersion = "0.6.0";
2
- export declare const engineVersion = "0.4.0";
1
+ export declare const mobileVersion = "0.8.0";
2
+ export declare const engineVersion = "0.5.0";
package/dist/versions.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Generated from the package manifests by build.mjs.
2
- export const mobileVersion = "0.6.0";
3
- export const engineVersion = "0.4.0";
2
+ export const mobileVersion = "0.8.0";
3
+ export const engineVersion = "0.5.0";
@@ -15,6 +15,7 @@
15
15
 
16
16
  @implementation RobonoCallingRuntime
17
17
  RCT_EXPORT_MODULE();
18
+ - (NSDictionary *)constantsToExport { return @{@"pictureInPictureEnabled": @(![[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RobonoPictureInPictureEnabled"] isEqual:@NO])}; }
18
19
  + (BOOL)requiresMainQueueSetup { return YES; }
19
20
  - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }
20
21
  - (NSArray<NSString *> *)supportedEvents { return @[@"RobonoCallingRuntimeEvent"]; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robono/calling-react-native",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Optional branded calling screens, sounds and native audio adapters for Robono calling.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -81,7 +81,7 @@
81
81
  "@types/react": "~19.2.2"
82
82
  },
83
83
  "peerDependencies": {
84
- "@robono/calling": "^0.4.0",
84
+ "@robono/calling": "^0.5.0",
85
85
  "react": ">=18.2 <20",
86
86
  "react-native": ">=0.76 <1",
87
87
  "react-native-svg": ">=15 <16",
@@ -0,0 +1,26 @@
1
+ const {withMainActivity}=require('expo/config-plugins');
2
+ const marker='// @robono/call-picture-in-picture';
3
+ // Preserve offsets while ignoring braces in strings and comments. Only change
4
+ // the actual ReactActivity class, never a helper class later in the file.
5
+ function activityBody(source){
6
+ const code=source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g,match=>match.replace(/[^\n]/g,' '));
7
+ const declaration=/\bclass\s+\w+\b[^{}]*\bReactActivity\b[^{}]*\{/.exec(code);
8
+ if(!declaration)throw Error('Could not identify the ReactActivity class. Forward onUserLeaveHint as described in the calling guide.');
9
+ const start=declaration.index+declaration[0].length;let depth=1;
10
+ for(let i=start;i<code.length;i++){if(code[i]==='{')depth++;if(code[i]==='}'&&!--depth)return {start,end:i,code:code.slice(start,i)};}
11
+ throw Error('Could not locate the end of the ReactActivity class.');
12
+ }
13
+ function installPictureInPictureHook(source,language){
14
+ if(!['kt','java'].includes(language))throw Error('Forward Android onUserLeaveHint to RobonoCallingPictureInPicture; see the calling guide.');
15
+ const body=activityBody(source),content=source.slice(body.start,body.end);
16
+ if(content.includes(marker))return source;
17
+ const existing=language==='kt'?/override\s+(?:(?:public|protected)\s+)?fun\s+onUserLeaveHint\s*\(\s*\)\s*\{/:/(?:public|protected)\s+void\s+onUserLeaveHint\s*\(\s*\)\s*\{/;
18
+ const hook=`\n ${marker}\n com.robono.calling.CallingPictureInPicture.onUserLeaveHint(this)${language==='java'?';':''}\n`;
19
+ const found=existing.exec(body.code);
20
+ if(found){const at=body.start+found.index+found[0].length;return source.slice(0,at)+hook+source.slice(at);}
21
+ if(/\bonUserLeaveHint\b/.test(body.code))throw Error('A custom onUserLeaveHint needs the forwarding call described in the calling guide.');
22
+ const method=language==='kt'?`\n override fun onUserLeaveHint() {\n super.onUserLeaveHint()${hook} }\n`:`\n @Override protected void onUserLeaveHint() {\n super.onUserLeaveHint();${hook} }\n`;
23
+ return source.slice(0,body.end)+method+source.slice(body.end);
24
+ }
25
+ function withCallPictureInPicture(config){return withMainActivity(config,c=>{c.modResults.contents=installPictureInPictureHook(c.modResults.contents,c.modResults.language);return c;});}
26
+ module.exports={withCallPictureInPicture,installPictureInPictureHook};