kasunk99-livestream-core 0.3.17 → 0.3.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"LiveStreamViewerItem.d.ts","sourceRoot":"","sources":["../../src/components/LiveStreamViewerItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAkBvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ/C,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwBF,eAAO,MAAM,oBAAoB,uDAme/B,CAAC"}
1
+ {"version":3,"file":"LiveStreamViewerItem.d.ts","sourceRoot":"","sources":["../../src/components/LiveStreamViewerItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAkBvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ/C,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwBF,eAAO,MAAM,oBAAoB,uDAqe/B,CAAC"}
@@ -42,9 +42,11 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
42
42
  const seededRoomRef = useRef(null);
43
43
  const chatListRef = useRef(null);
44
44
  const textInputRef = useRef(null);
45
- // Cell layout tracking — used to compensate for adjustResize shrinking the cell
46
- const baseCellH = useRef(0); // largest height seen = keyboard-free baseline
47
- const currCellH = useRef(0); // current cell height (may shrink with adjustResize)
45
+ // Cell layout tracking — used to compensate for adjustResize shrinking the cell.
46
+ // Initialise baseCellH with the same estimate LiveStreamFeed uses for viewportHeight
47
+ // so the gap formula works correctly even before onCellLayout fires.
48
+ const baseCellH = useRef(SCREEN_HEIGHT - 120);
49
+ const currCellH = useRef(SCREEN_HEIGHT - 120);
48
50
  const onCellLayout = useCallback((e) => {
49
51
  const h = Math.round(e.nativeEvent.layout.height);
50
52
  currCellH.current = h;
@@ -57,25 +59,27 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
57
59
  // Remember last offset so re-open positions instantly instead of jumping
58
60
  const lastOffsetRef = useRef(0);
59
61
  // Compute the correct bottom offset for the floating input.
60
- // If adjustResize has shrunk the cell (shrink > 0), subtract that from keyboard height
61
- // so we don't double-offset. If cell hasn't shrunk, use full keyboard height.
62
+ //
63
+ // The cell sits inside a tab navigator whose height is less than the full window.
64
+ // `kbH` from the keyboard event is measured from the bottom of the WINDOW, not the
65
+ // bottom of the CELL. We subtract `cellBottomGap` (window bottom → cell bottom) to
66
+ // get the offset relative to the cell.
67
+ //
68
+ // If adjustResize has also shrunk the cell, we subtract that too (avoids double-offset).
62
69
  const computeOffset = useCallback((kbH) => {
63
- const base = baseCellH.current || SCREEN_HEIGHT;
64
- const cur = currCellH.current || base;
65
- const shrink = Math.max(0, base - cur);
66
- return Math.max(BOTTOM_SAFE, kbH - shrink);
70
+ const base = baseCellH.current;
71
+ const cur = currCellH.current;
72
+ const cellBottomGap = Math.max(0, SCREEN_HEIGHT - base); // tab-nav area below cell
73
+ const shrink = Math.max(0, base - cur); // adjustResize shrink (if any)
74
+ return Math.max(BOTTOM_SAFE, kbH - cellBottomGap - shrink);
67
75
  }, []);
68
- // Pre-position the input immediately when typing starts (uses last known offset)
76
+ // Pre-position the input immediately when typing starts (uses last known offset).
77
+ // Keyboard listeners own the reset when isTyping becomes false.
69
78
  useEffect(() => {
70
79
  if (isTyping && lastOffsetRef.current > 0) {
71
80
  inputBottom.setValue(lastOffsetRef.current);
72
81
  chatAnim.setValue(lastOffsetRef.current + 60);
73
82
  }
74
- else if (!isTyping) {
75
- // Only reset if keyboard is not currently shown (let keyboard events handle active state)
76
- inputBottom.setValue(0);
77
- chatAnim.setValue(CHAT_BOTTOM_DEFAULT);
78
- }
79
83
  }, [isTyping, inputBottom, chatAnim]);
80
84
  // Keyboard event listeners — platform-specific
81
85
  useEffect(() => {
@@ -264,15 +268,11 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
264
268
  const text = chatInput.trim();
265
269
  if (!text || !socket || !joined)
266
270
  return;
267
- // Clear input, close panel, dismiss keyboard all before the emit
268
- // so the button press completes synchronously before any state teardown.
271
+ // Emit FIRST so the message reaches the server before any cleanup.
272
+ // keyboardDidHide will set isTyping=false and reset animations.
273
+ socket.emit('chat-message', { text });
269
274
  setChatInput('');
270
- setIsTyping(false);
271
275
  Keyboard.dismiss();
272
- socket.emit('chat-message', { text }, (res) => {
273
- if (res?.error)
274
- console.log('[viewer] chat send error', res.error);
275
- });
276
276
  };
277
277
  const hostLabel = stream.hostDisplayName || stream.title || 'Live';
278
278
  const avatarLetter = hostLabel[0]?.toUpperCase() ?? 'L';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kasunk99-livestream-core",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "Reusable livestream viewer/host module for React Native (Expo) — mediasoup + Socket.IO",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",