@poolse/react-native 2.23.0 → 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
 
@@ -5763,7 +5763,10 @@ function CallVideoGrid({
5763
5763
  const others = useMemo(() => participants.filter((p) => !p.isSelf), [participants]);
5764
5764
  const columns = others.length + 1 <= 6 ? 2 : 3;
5765
5765
  const rows = Math.ceil((others.length + 1) / columns);
5766
- const tileHeight = size.height > 0 ? (size.height - GAP * (rows - 1)) / rows : 0;
5766
+ const padTop = safeArea?.top ?? 0;
5767
+ const padBottom = safeArea?.bottom ?? 0;
5768
+ const availableHeight = size.height > 0 ? size.height - padTop - padBottom : 0;
5769
+ const tileHeight = availableHeight > 0 ? (availableHeight - GAP * (rows - 1)) / rows : 0;
5767
5770
  const scrolls = tileHeight > 0 && tileHeight < MIN_TILE_HEIGHT;
5768
5771
  if (participants.length === 0) return /* @__PURE__ */ jsx(View, { style: styles30.stage, onLayout });
5769
5772
  if (others.length <= 1) {
@@ -5811,17 +5814,24 @@ function CallVideoGrid({
5811
5814
  },
5812
5815
  participant.userId
5813
5816
  )) });
5814
- return /* @__PURE__ */ jsx(View, { style: styles30.stage, onLayout, children: scrolls ? /* @__PURE__ */ jsx(
5815
- ScrollView,
5817
+ return /* @__PURE__ */ jsx(
5818
+ View,
5816
5819
  {
5817
- contentContainerStyle: [
5818
- styles30.scroll,
5819
- { paddingBottom: (chromeInsets?.bottom ?? 0) + GAP }
5820
- ],
5821
- showsVerticalScrollIndicator: false,
5822
- children: grid
5820
+ style: [styles30.stage, { paddingTop: padTop, paddingBottom: padBottom }],
5821
+ onLayout,
5822
+ children: scrolls ? /* @__PURE__ */ jsx(
5823
+ ScrollView,
5824
+ {
5825
+ contentContainerStyle: [
5826
+ styles30.scroll,
5827
+ { paddingBottom: (chromeInsets?.bottom ?? 0) + GAP }
5828
+ ],
5829
+ showsVerticalScrollIndicator: false,
5830
+ children: grid
5831
+ }
5832
+ ) : grid
5823
5833
  }
5824
- ) : grid });
5834
+ );
5825
5835
  }
5826
5836
  var styles30 = StyleSheet.create({
5827
5837
  stage: { flex: 1, overflow: "hidden" },
@@ -6021,7 +6031,7 @@ function CallScreen({
6021
6031
  inCallManager,
6022
6032
  nativeIncomingUi
6023
6033
  }) {
6024
- const insets = useSafeAreaInsets();
6034
+ const [insets, setInsets] = useState({ top: 0, bottom: 0, left: 0, right: 0 });
6025
6035
  const ownCalls = useCalls(callsProp ? null : userId);
6026
6036
  const calls = callsProp ?? ownCalls;
6027
6037
  const meshAvailable = isNativeWebRtcAvailable(webrtc);
@@ -6114,14 +6124,16 @@ function CallScreen({
6114
6124
  [wakeChrome]
6115
6125
  );
6116
6126
  const hangUp = useCallback(() => {
6117
- const othersOnCall = (usingSfu ? sfu.participants : mesh.participants).filter(
6118
- (p) => !p.isSelf
6119
- ).length;
6120
6127
  sfu.leave();
6121
6128
  mesh.leave();
6122
- if (calls.phase === "active" && othersOnCall >= 2) calls.reset();
6123
- else void calls.hangUp();
6124
- }, [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]);
6125
6137
  const alone = usingSfu ? sfu.alone : mesh.alone;
6126
6138
  const endedOnEmpty = useRef(false);
6127
6139
  if (calls.phase !== "active") endedOnEmpty.current = false;
@@ -6178,165 +6190,177 @@ function CallScreen({
6178
6190
  onRequestClose: hangUp,
6179
6191
  children: [
6180
6192
  /* @__PURE__ */ jsx(StatusBar, { barStyle: "light-content" }),
6181
- /* @__PURE__ */ jsxs(Pressable, { style: styles31.screen, onPress: toggleChrome, accessible: false, children: [
6182
- /* @__PURE__ */ jsx(CallBackdrop, {}),
6183
- showStage ? /* @__PURE__ */ jsx(
6184
- CallVideoGrid,
6185
- {
6186
- participants,
6187
- livekitReactNative,
6188
- labelFor: label,
6189
- onLocalPress: () => void sfu.switchCamera(),
6190
- chromeInsets,
6191
- safeArea: { top: insets.top, bottom: insets.bottom }
6192
- }
6193
- ) : (
6194
- // Audio (and pre-media) calls carry their identity in the
6195
- // middle of the scene — name under the avatar, status in a
6196
- // pill — rather than a bar pinned to the top of a void.
6197
- /* @__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(
6198
6245
  View,
6199
6246
  {
6200
- style: [styles31.identity, { paddingBottom: insets.bottom + 160 }],
6201
- pointerEvents: "none",
6247
+ style: [styles31.controls, { paddingBottom: insets.bottom + 22 }],
6248
+ pointerEvents: "box-none",
6202
6249
  children: [
6203
- /* @__PURE__ */ jsxs(View, { style: styles31.avatarStage, children: [
6204
- (ringingIn || ringingOut) && /* @__PURE__ */ jsx(PulseRings, { size: 132, color: callColors.glow }),
6205
- /* @__PURE__ */ jsx(
6206
- CallAvatar,
6207
- {
6208
- name: peerIds.length === 1 ? label(peerIds[0]) : title,
6209
- seed: titleConversationId ?? peerIds[0] ?? "call",
6210
- size: 132
6211
- }
6212
- )
6213
- ] }),
6214
- /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: styles31.identityTitle, children: title }),
6215
- /* @__PURE__ */ jsxs(View, { style: styles31.statusPill, children: [
6216
- connected && /* @__PURE__ */ jsx(View, { style: styles31.statusDot }),
6217
- /* @__PURE__ */ jsx(Text, { style: styles31.statusText, children: subtitle })
6218
- ] })
6219
- ]
6220
- }
6221
- )
6222
- ),
6223
- chromeVisible && showStage && /* @__PURE__ */ jsxs(View, { style: [styles31.header, { paddingTop: insets.top + 14 }], pointerEvents: "box-none", children: [
6224
- /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles31.title, children: title }),
6225
- /* @__PURE__ */ jsxs(View, { style: styles31.subtitleRow, children: [
6226
- isGroup && /* @__PURE__ */ jsx(PoolseIcon, { name: "users", size: 14, color: callColors.textDim, label: null }),
6227
- /* @__PURE__ */ jsx(Text, { style: styles31.subtitle, children: isGroup ? `${participants.length} \xB7 ${subtitle}` : subtitle })
6228
- ] })
6229
- ] }),
6230
- chromeVisible && /* @__PURE__ */ jsxs(
6231
- View,
6232
- {
6233
- style: [styles31.controls, { paddingBottom: insets.bottom + 22 }],
6234
- pointerEvents: "box-none",
6235
- children: [
6236
- error && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: error.message }),
6237
- !meshAvailable && !livekit && /* @__PURE__ */ jsx(Text, { style: styles31.error, children: "No WebRTC module supplied \u2014 this call has no audio." }),
6238
- ringingIn ? /* @__PURE__ */ jsxs(View, { style: styles31.answerRow, children: [
6239
- /* @__PURE__ */ jsx(
6240
- CallControlButton,
6241
- {
6242
- icon: "phone-off",
6243
- tone: "danger",
6244
- large: true,
6245
- label: "Decline",
6246
- onPress: () => void calls.decline(),
6247
- accessibilityLabel: "Decline call"
6248
- }
6249
- ),
6250
- /* @__PURE__ */ jsx(
6251
- CallControlButton,
6252
- {
6253
- icon: isVideoCall ? "video" : "phone",
6254
- tone: "accept",
6255
- large: true,
6256
- label: "Accept",
6257
- onPress: () => void calls.accept(),
6258
- accessibilityLabel: "Accept call"
6259
- }
6260
- )
6261
- ] }) : ended ? /* @__PURE__ */ jsx(View, { style: styles31.row, children: /* @__PURE__ */ jsx(
6262
- CallControlButton,
6263
- {
6264
- icon: "close",
6265
- onPress: calls.reset,
6266
- label: "Close",
6267
- accessibilityLabel: "Close"
6268
- }
6269
- ) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6270
- /* @__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: [
6271
6253
  /* @__PURE__ */ jsx(
6272
6254
  CallControlButton,
6273
6255
  {
6274
- icon: micOn ? "mic" : "mic-off",
6275
- label: micOn ? "Mute" : "Unmute",
6276
- active: !micOn,
6277
- onPress: withWake(toggleMic),
6278
- 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"
6279
6262
  }
6280
6263
  ),
6281
6264
  /* @__PURE__ */ jsx(
6282
6265
  CallControlButton,
6283
6266
  {
6284
- icon: speakerIcon(audio),
6285
- label: speakerLabel(audio),
6286
- active: audio.speakerOn,
6287
- onPress: withWake(onSpeakerPress),
6288
- accessibilityLabel: "Audio output"
6289
- }
6290
- ),
6291
- usingSfu && /* @__PURE__ */ jsx(
6292
- CallControlButton,
6293
- {
6294
- icon: videoOn ? "video" : "video-off",
6295
- label: "Camera",
6296
- active: !videoOn,
6297
- onPress: withWake(() => void sfu.toggleCamera()),
6298
- accessibilityLabel: videoOn ? "Turn camera off" : "Turn camera on"
6299
- }
6300
- ),
6301
- usingSfu && videoOn && /* @__PURE__ */ jsx(
6302
- CallControlButton,
6303
- {
6304
- icon: "camera-flip",
6305
- label: "Flip",
6306
- onPress: withWake(() => void sfu.switchCamera()),
6307
- 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"
6308
6273
  }
6309
6274
  )
6310
- ] }),
6311
- /* @__PURE__ */ jsx(View, { style: styles31.hangUpRow, children: /* @__PURE__ */ jsx(
6275
+ ] }) : ended ? /* @__PURE__ */ jsx(View, { style: styles31.row, children: /* @__PURE__ */ jsx(
6312
6276
  CallControlButton,
6313
6277
  {
6314
- icon: "phone-off",
6315
- tone: "danger",
6316
- large: true,
6317
- onPress: ringingOut ? () => void calls.cancel() : hangUp,
6318
- accessibilityLabel: ringingOut ? "Cancel call" : "Hang up"
6278
+ icon: "close",
6279
+ onPress: calls.reset,
6280
+ label: "Close",
6281
+ accessibilityLabel: "Close"
6319
6282
  }
6320
- ) })
6321
- ] })
6322
- ]
6323
- }
6324
- ),
6325
- /* @__PURE__ */ jsx(
6326
- AudioRouteSheet,
6327
- {
6328
- visible: routesOpen,
6329
- routes: audio.routes,
6330
- selectedRouteId: audio.selectedRouteId,
6331
- onSelect: audio.selectRoute,
6332
- onClose: () => setRoutesOpen(false)
6333
- }
6334
- )
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
+ ] })
6335
6350
  ] })
6336
6351
  ]
6337
6352
  }
6338
6353
  );
6339
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
+ }
6340
6364
  function speakerIcon(audio) {
6341
6365
  if (audio.externalDevice) return "headphones";
6342
6366
  return audio.speakerOn ? "speaker" : "speaker-off";