@poolse/react-native 2.23.1 → 2.24.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import Svg2, { SvgXml, Svg, Path, Circle, G, Defs, RadialGradient, Stop, Rect }
6
6
  import * as ImagePicker from 'expo-image-picker';
7
7
  import * as DocumentPicker from 'expo-document-picker';
8
8
  import { manipulateAsync, SaveFormat } from 'expo-image-manipulator';
9
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
9
+ import { useSafeAreaInsets, SafeAreaProvider } from 'react-native-safe-area-context';
10
10
  import * as Clipboard from 'expo-clipboard';
11
11
  import Markdown, { MarkdownIt } from 'react-native-markdown-display';
12
12
 
@@ -6031,7 +6031,7 @@ function CallScreen({
6031
6031
  inCallManager,
6032
6032
  nativeIncomingUi
6033
6033
  }) {
6034
- const insets = useSafeAreaInsets();
6034
+ const [insets, setInsets] = useState({ top: 0, bottom: 0, left: 0, right: 0 });
6035
6035
  const ownCalls = useCalls(callsProp ? null : userId);
6036
6036
  const calls = callsProp ?? ownCalls;
6037
6037
  const meshAvailable = isNativeWebRtcAvailable(webrtc);
@@ -6124,14 +6124,16 @@ function CallScreen({
6124
6124
  [wakeChrome]
6125
6125
  );
6126
6126
  const hangUp = useCallback(() => {
6127
- const othersOnCall = (usingSfu ? sfu.participants : mesh.participants).filter(
6128
- (p) => !p.isSelf
6129
- ).length;
6130
6127
  sfu.leave();
6131
6128
  mesh.leave();
6132
- if (calls.phase === "active" && othersOnCall >= 2) calls.reset();
6133
- else void calls.hangUp();
6134
- }, [sfu, mesh, calls, usingSfu]);
6129
+ void calls.hangUp();
6130
+ }, [sfu, mesh, calls]);
6131
+ const othersNow = (usingSfu ? sfu.participants : mesh.participants).filter(
6132
+ (p) => !p.isSelf
6133
+ ).length;
6134
+ useEffect(() => {
6135
+ calls.reportOthersOnCall?.(othersNow);
6136
+ }, [calls, othersNow]);
6135
6137
  const alone = usingSfu ? sfu.alone : mesh.alone;
6136
6138
  const endedOnEmpty = useRef(false);
6137
6139
  if (calls.phase !== "active") endedOnEmpty.current = false;
@@ -6188,165 +6190,177 @@ function CallScreen({
6188
6190
  onRequestClose: hangUp,
6189
6191
  children: [
6190
6192
  /* @__PURE__ */ jsx(StatusBar, { barStyle: "light-content" }),
6191
- /* @__PURE__ */ jsxs(Pressable, { style: styles31.screen, onPress: toggleChrome, accessible: false, children: [
6192
- /* @__PURE__ */ jsx(CallBackdrop, {}),
6193
- showStage ? /* @__PURE__ */ jsx(
6194
- CallVideoGrid,
6195
- {
6196
- participants,
6197
- livekitReactNative,
6198
- labelFor: label,
6199
- onLocalPress: () => void sfu.switchCamera(),
6200
- chromeInsets,
6201
- safeArea: { top: insets.top, bottom: insets.bottom }
6202
- }
6203
- ) : (
6204
- // Audio (and pre-media) calls carry their identity in the
6205
- // middle of the scene — name under the avatar, status in a
6206
- // pill — rather than a bar pinned to the top of a void.
6207
- /* @__PURE__ */ jsxs(
6193
+ /* @__PURE__ */ jsxs(SafeAreaProvider, { children: [
6194
+ /* @__PURE__ */ jsx(InsetsProbe, { onChange: setInsets }),
6195
+ /* @__PURE__ */ jsxs(Pressable, { style: styles31.screen, onPress: toggleChrome, accessible: false, children: [
6196
+ /* @__PURE__ */ jsx(CallBackdrop, {}),
6197
+ showStage ? /* @__PURE__ */ jsx(
6198
+ CallVideoGrid,
6199
+ {
6200
+ participants,
6201
+ livekitReactNative,
6202
+ labelFor: label,
6203
+ onLocalPress: () => void sfu.switchCamera(),
6204
+ chromeInsets,
6205
+ safeArea: { top: insets.top, bottom: insets.bottom }
6206
+ }
6207
+ ) : (
6208
+ // Audio (and pre-media) calls carry their identity in the
6209
+ // middle of the scene — name under the avatar, status in a
6210
+ // pill — rather than a bar pinned to the top of a void.
6211
+ /* @__PURE__ */ jsxs(
6212
+ View,
6213
+ {
6214
+ style: [styles31.identity, { paddingBottom: insets.bottom + 160 }],
6215
+ pointerEvents: "none",
6216
+ children: [
6217
+ /* @__PURE__ */ jsxs(View, { style: styles31.avatarStage, children: [
6218
+ (ringingIn || ringingOut) && /* @__PURE__ */ jsx(PulseRings, { size: 132, color: callColors.glow }),
6219
+ /* @__PURE__ */ jsx(
6220
+ CallAvatar,
6221
+ {
6222
+ name: peerIds.length === 1 ? label(peerIds[0]) : title,
6223
+ seed: titleConversationId ?? peerIds[0] ?? "call",
6224
+ size: 132
6225
+ }
6226
+ )
6227
+ ] }),
6228
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: styles31.identityTitle, children: title }),
6229
+ /* @__PURE__ */ jsxs(View, { style: styles31.statusPill, children: [
6230
+ connected && /* @__PURE__ */ jsx(View, { style: styles31.statusDot }),
6231
+ /* @__PURE__ */ jsx(Text, { style: styles31.statusText, children: subtitle })
6232
+ ] })
6233
+ ]
6234
+ }
6235
+ )
6236
+ ),
6237
+ chromeVisible && showStage && /* @__PURE__ */ jsxs(View, { style: [styles31.header, { paddingTop: insets.top + 14 }], pointerEvents: "box-none", children: [
6238
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles31.title, children: title }),
6239
+ /* @__PURE__ */ jsxs(View, { style: styles31.subtitleRow, children: [
6240
+ isGroup && /* @__PURE__ */ jsx(PoolseIcon, { name: "users", size: 14, color: callColors.textDim, label: null }),
6241
+ /* @__PURE__ */ jsx(Text, { style: styles31.subtitle, children: isGroup ? `${participants.length} \xB7 ${subtitle}` : subtitle })
6242
+ ] })
6243
+ ] }),
6244
+ chromeVisible && /* @__PURE__ */ jsxs(
6208
6245
  View,
6209
6246
  {
6210
- style: [styles31.identity, { paddingBottom: insets.bottom + 160 }],
6211
- pointerEvents: "none",
6247
+ style: [styles31.controls, { paddingBottom: insets.bottom + 22 }],
6248
+ pointerEvents: "box-none",
6212
6249
  children: [
6213
- /* @__PURE__ */ jsxs(View, { style: styles31.avatarStage, children: [
6214
- (ringingIn || ringingOut) && /* @__PURE__ */ jsx(PulseRings, { size: 132, color: callColors.glow }),
6215
- /* @__PURE__ */ jsx(
6216
- CallAvatar,
6217
- {
6218
- name: peerIds.length === 1 ? label(peerIds[0]) : title,
6219
- seed: titleConversationId ?? peerIds[0] ?? "call",
6220
- size: 132
6221
- }
6222
- )
6223
- ] }),
6224
- /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: styles31.identityTitle, children: title }),
6225
- /* @__PURE__ */ jsxs(View, { style: styles31.statusPill, children: [
6226
- connected && /* @__PURE__ */ jsx(View, { style: styles31.statusDot }),
6227
- /* @__PURE__ */ jsx(Text, { style: styles31.statusText, children: subtitle })
6228
- ] })
6229
- ]
6230
- }
6231
- )
6232
- ),
6233
- chromeVisible && showStage && /* @__PURE__ */ jsxs(View, { style: [styles31.header, { paddingTop: insets.top + 14 }], pointerEvents: "box-none", children: [
6234
- /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles31.title, children: title }),
6235
- /* @__PURE__ */ jsxs(View, { style: styles31.subtitleRow, children: [
6236
- isGroup && /* @__PURE__ */ jsx(PoolseIcon, { name: "users", size: 14, color: callColors.textDim, label: null }),
6237
- /* @__PURE__ */ jsx(Text, { style: styles31.subtitle, children: isGroup ? `${participants.length} \xB7 ${subtitle}` : subtitle })
6238
- ] })
6239
- ] }),
6240
- chromeVisible && /* @__PURE__ */ jsxs(
6241
- View,
6242
- {
6243
- style: [styles31.controls, { paddingBottom: insets.bottom + 22 }],
6244
- pointerEvents: "box-none",
6245
- children: [
6246
- error && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: error.message }),
6247
- !meshAvailable && !livekit && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: "No WebRTC module supplied \u2014 this call has no audio." }),
6248
- ringingIn ? /* @__PURE__ */ jsxs(View, { style: styles31.answerRow, children: [
6249
- /* @__PURE__ */ jsx(
6250
- CallControlButton,
6251
- {
6252
- icon: "phone-off",
6253
- tone: "danger",
6254
- large: true,
6255
- label: "Decline",
6256
- onPress: () => void calls.decline(),
6257
- accessibilityLabel: "Decline call"
6258
- }
6259
- ),
6260
- /* @__PURE__ */ jsx(
6261
- CallControlButton,
6262
- {
6263
- icon: isVideoCall ? "video" : "phone",
6264
- tone: "accept",
6265
- large: true,
6266
- label: "Accept",
6267
- onPress: () => void calls.accept(),
6268
- accessibilityLabel: "Accept call"
6269
- }
6270
- )
6271
- ] }) : ended ? /* @__PURE__ */ jsx(View, { style: styles31.row, children: /* @__PURE__ */ jsx(
6272
- CallControlButton,
6273
- {
6274
- icon: "close",
6275
- onPress: calls.reset,
6276
- label: "Close",
6277
- accessibilityLabel: "Close"
6278
- }
6279
- ) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6280
- /* @__PURE__ */ jsxs(View, { style: styles31.dock, children: [
6250
+ error && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: error.message }),
6251
+ !meshAvailable && !livekit && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: "No WebRTC module supplied \u2014 this call has no audio." }),
6252
+ ringingIn ? /* @__PURE__ */ jsxs(View, { style: styles31.answerRow, children: [
6281
6253
  /* @__PURE__ */ jsx(
6282
6254
  CallControlButton,
6283
6255
  {
6284
- icon: micOn ? "mic" : "mic-off",
6285
- label: micOn ? "Mute" : "Unmute",
6286
- active: !micOn,
6287
- onPress: withWake(toggleMic),
6288
- accessibilityLabel: micOn ? "Mute microphone" : "Unmute microphone"
6256
+ icon: "phone-off",
6257
+ tone: "danger",
6258
+ large: true,
6259
+ label: "Decline",
6260
+ onPress: () => void calls.decline(),
6261
+ accessibilityLabel: "Decline call"
6289
6262
  }
6290
6263
  ),
6291
6264
  /* @__PURE__ */ jsx(
6292
6265
  CallControlButton,
6293
6266
  {
6294
- icon: speakerIcon(audio),
6295
- label: speakerLabel(audio),
6296
- active: audio.speakerOn,
6297
- onPress: withWake(onSpeakerPress),
6298
- accessibilityLabel: "Audio output"
6299
- }
6300
- ),
6301
- usingSfu && /* @__PURE__ */ jsx(
6302
- CallControlButton,
6303
- {
6304
- icon: videoOn ? "video" : "video-off",
6305
- label: "Camera",
6306
- active: !videoOn,
6307
- onPress: withWake(() => void sfu.toggleCamera()),
6308
- accessibilityLabel: videoOn ? "Turn camera off" : "Turn camera on"
6309
- }
6310
- ),
6311
- usingSfu && videoOn && /* @__PURE__ */ jsx(
6312
- CallControlButton,
6313
- {
6314
- icon: "camera-flip",
6315
- label: "Flip",
6316
- onPress: withWake(() => void sfu.switchCamera()),
6317
- accessibilityLabel: "Switch camera"
6267
+ icon: isVideoCall ? "video" : "phone",
6268
+ tone: "accept",
6269
+ large: true,
6270
+ label: "Accept",
6271
+ onPress: () => void calls.accept(),
6272
+ accessibilityLabel: "Accept call"
6318
6273
  }
6319
6274
  )
6320
- ] }),
6321
- /* @__PURE__ */ jsx(View, { style: styles31.hangUpRow, children: /* @__PURE__ */ jsx(
6275
+ ] }) : ended ? /* @__PURE__ */ jsx(View, { style: styles31.row, children: /* @__PURE__ */ jsx(
6322
6276
  CallControlButton,
6323
6277
  {
6324
- icon: "phone-off",
6325
- tone: "danger",
6326
- large: true,
6327
- onPress: ringingOut ? () => void calls.cancel() : hangUp,
6328
- accessibilityLabel: ringingOut ? "Cancel call" : "Hang up"
6278
+ icon: "close",
6279
+ onPress: calls.reset,
6280
+ label: "Close",
6281
+ accessibilityLabel: "Close"
6329
6282
  }
6330
- ) })
6331
- ] })
6332
- ]
6333
- }
6334
- ),
6335
- /* @__PURE__ */ jsx(
6336
- AudioRouteSheet,
6337
- {
6338
- visible: routesOpen,
6339
- routes: audio.routes,
6340
- selectedRouteId: audio.selectedRouteId,
6341
- onSelect: audio.selectRoute,
6342
- onClose: () => setRoutesOpen(false)
6343
- }
6344
- )
6283
+ ) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6284
+ /* @__PURE__ */ jsxs(View, { style: styles31.dock, children: [
6285
+ /* @__PURE__ */ jsx(
6286
+ CallControlButton,
6287
+ {
6288
+ icon: micOn ? "mic" : "mic-off",
6289
+ label: micOn ? "Mute" : "Unmute",
6290
+ active: !micOn,
6291
+ onPress: withWake(toggleMic),
6292
+ accessibilityLabel: micOn ? "Mute microphone" : "Unmute microphone"
6293
+ }
6294
+ ),
6295
+ /* @__PURE__ */ jsx(
6296
+ CallControlButton,
6297
+ {
6298
+ icon: speakerIcon(audio),
6299
+ label: speakerLabel(audio),
6300
+ active: audio.speakerOn,
6301
+ onPress: withWake(onSpeakerPress),
6302
+ accessibilityLabel: "Audio output"
6303
+ }
6304
+ ),
6305
+ usingSfu && /* @__PURE__ */ jsx(
6306
+ CallControlButton,
6307
+ {
6308
+ icon: videoOn ? "video" : "video-off",
6309
+ label: "Camera",
6310
+ active: !videoOn,
6311
+ onPress: withWake(() => void sfu.toggleCamera()),
6312
+ accessibilityLabel: videoOn ? "Turn camera off" : "Turn camera on"
6313
+ }
6314
+ ),
6315
+ usingSfu && videoOn && /* @__PURE__ */ jsx(
6316
+ CallControlButton,
6317
+ {
6318
+ icon: "camera-flip",
6319
+ label: "Flip",
6320
+ onPress: withWake(() => void sfu.switchCamera()),
6321
+ accessibilityLabel: "Switch camera"
6322
+ }
6323
+ )
6324
+ ] }),
6325
+ /* @__PURE__ */ jsx(View, { style: styles31.hangUpRow, children: /* @__PURE__ */ jsx(
6326
+ CallControlButton,
6327
+ {
6328
+ icon: "phone-off",
6329
+ tone: "danger",
6330
+ large: true,
6331
+ onPress: ringingOut ? () => void calls.cancel() : hangUp,
6332
+ accessibilityLabel: ringingOut ? "Cancel call" : "Hang up"
6333
+ }
6334
+ ) })
6335
+ ] })
6336
+ ]
6337
+ }
6338
+ ),
6339
+ /* @__PURE__ */ jsx(
6340
+ AudioRouteSheet,
6341
+ {
6342
+ visible: routesOpen,
6343
+ routes: audio.routes,
6344
+ selectedRouteId: audio.selectedRouteId,
6345
+ onSelect: audio.selectRoute,
6346
+ onClose: () => setRoutesOpen(false)
6347
+ }
6348
+ )
6349
+ ] })
6345
6350
  ] })
6346
6351
  ]
6347
6352
  }
6348
6353
  );
6349
6354
  }
6355
+ function InsetsProbe({
6356
+ onChange
6357
+ }) {
6358
+ const insets = useSafeAreaInsets();
6359
+ useEffect(() => {
6360
+ onChange({ top: insets.top, bottom: insets.bottom, left: insets.left, right: insets.right });
6361
+ }, [insets.top, insets.bottom, insets.left, insets.right, onChange]);
6362
+ return null;
6363
+ }
6350
6364
  function speakerIcon(audio) {
6351
6365
  if (audio.externalDevice) return "headphones";
6352
6366
  return audio.speakerOn ? "speaker" : "speaker-off";