@simba-dev/react-native-media-player 2.0.1 → 3.0.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.
Files changed (38) hide show
  1. package/README.md +317 -560
  2. package/android/src/main/cpp/main.cpp +117 -17
  3. package/android/src/main/java/com/simba/player/PipManager.kt +13 -0
  4. package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +177 -6
  5. package/android/src/main/java/com/simba/player/mpv/PipAutoEnterPolicy.kt +54 -0
  6. package/package.json +11 -2
  7. package/src/components/PlayerProvider.tsx +5 -5
  8. package/src/index.ts +25 -12
  9. package/android/src/test/java/com/simba/player/PipActionReceiverTest.kt +0 -123
  10. package/android/src/test/java/com/simba/player/PipManagerTest.kt +0 -281
  11. package/android/src/test/java/com/simba/player/TestApplication.kt +0 -26
  12. package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleNullInstanceTest.kt +0 -117
  13. package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleTest.kt +0 -212
  14. package/android/src/test/java/com/simba/player/mpv/MpvRenderViewRegistryTest.kt +0 -120
  15. package/android/src/test/java/com/simba/player/mpv/MpvRenderViewTest.kt +0 -249
  16. package/scripts/override_react_methods.js +0 -184
  17. package/scripts/override_react_methods.py +0 -150
  18. package/src/bridge/__tests__/MpvPlayerModule.test.ts +0 -163
  19. package/src/bridge/__tests__/debugMode.test.ts +0 -138
  20. package/src/bridge/__tests__/errorContract.test.ts +0 -175
  21. package/src/bridge/__tests__/loadAndPlay.startPosition.test.tsx +0 -142
  22. package/src/components/PlayerRoot.tsx +0 -124
  23. package/src/components/PlayerSurface.tsx +0 -62
  24. package/src/components/__tests__/PlayerProvider.performance.test.tsx +0 -242
  25. package/src/components/__tests__/PlayerProvider.progressContext.test.tsx +0 -194
  26. package/src/components/__tests__/PlayerProvider.test.tsx +0 -558
  27. package/src/components/__tests__/PlayerRoot.test.tsx +0 -71
  28. package/src/components/__tests__/SimbaVideo.test.tsx +0 -164
  29. package/src/hooks/__tests__/resolveStreamType.test.ts +0 -159
  30. package/src/hooks/__tests__/useLaunchPlayback.test.tsx +0 -278
  31. package/src/hooks/__tests__/useResumeThumbnail.test.ts +0 -154
  32. package/src/stores/__tests__/playerQueueSelectionStore.test.ts +0 -73
  33. package/src/stores/__tests__/playerQueueStore.test.ts +0 -171
  34. package/src/types/__tests__/config.test.ts +0 -188
  35. package/src/types/__tests__/player.pipAnswer.test.tsx +0 -87
  36. package/src/types/__tests__/player.pipArity.test.tsx +0 -74
  37. package/src/types/__tests__/player.test.tsx +0 -1365
  38. package/src/types/__tests__/playerLoading.test.ts +0 -170
@@ -1,74 +0,0 @@
1
- /**
2
- * The PiP command must call the native bridge with TWO arguments.
3
- *
4
- * The native TurboModule method has arity 2, and TurboModule checks the
5
- * argument count on EVERY call, so a zero-argument call is rejected
6
- * before it ever reaches the native body:
7
- *
8
- * Exception in HostFunction: TurboModule method "enterPip"
9
- * called with 0 arguments (expected argument count: 2)
10
- *
11
- * That is what the PiP button did: it threw instead of entering PiP.
12
- * The native side had already been made nullable (v1.9.3) and the
13
- * codegen spec had already been given two parameters — but the CALL
14
- * SITE still passed none, and nothing tested the call site's arity.
15
- *
16
- * So this file asserts the arity, not the behaviour: a test that only
17
- * checked "enterPip was called" would pass with a zero-argument call
18
- * and the bug would survive.
19
- */
20
-
21
- import {NativeModules} from 'react-native';
22
- import {renderHook} from '@testing-library/react-native';
23
- import {usePlayer} from '../player';
24
-
25
- function enterPipMock(): jest.Mock {
26
- return (NativeModules.MpvPlayerModule as unknown as Record<string, jest.Mock>)
27
- .enterPip;
28
- }
29
-
30
- describe('commands.enterPip — the native call arity', () => {
31
- beforeEach(() => {
32
- for (const key of Object.keys(NativeModules.MpvPlayerModule)) {
33
- const fn = (NativeModules.MpvPlayerModule as unknown as Record<
34
- string,
35
- jest.Mock
36
- >)[key];
37
- if (typeof fn?.mockClear === 'function') {
38
- fn.mockClear();
39
- }
40
- }
41
- });
42
-
43
- it('calls the bridge with TWO arguments even when no values are given', async () => {
44
- const {result} = await renderHook(() => usePlayer());
45
- result.current.commands.enterPip();
46
-
47
- const enterPip = enterPipMock();
48
- expect(enterPip).toHaveBeenCalledTimes(1);
49
- // The arity is the whole point: TurboModule rejects anything else.
50
- expect(enterPip.mock.calls[0]).toHaveLength(2);
51
- // And the "not supplied" value is null, which the native accepts
52
- // (its own fallbacks are "Simba Player" and "0 %").
53
- expect(enterPip.mock.calls[0][0]).toBeNull();
54
- expect(enterPip.mock.calls[0][1]).toBeNull();
55
- });
56
-
57
- it('forwards the chapter title and the progress percentage', async () => {
58
- const {result} = await renderHook(() => usePlayer());
59
- result.current.commands.enterPip('Chapter 3', '45 %');
60
-
61
- const enterPip = enterPipMock();
62
- expect(enterPip.mock.calls[0]).toHaveLength(2);
63
- expect(enterPip).toHaveBeenCalledWith('Chapter 3', '45 %');
64
- });
65
-
66
- it('passes null for a value that was not supplied, not undefined', async () => {
67
- const {result} = await renderHook(() => usePlayer());
68
- result.current.commands.enterPip('Chapter 3', null);
69
-
70
- const enterPip = enterPipMock();
71
- expect(enterPip.mock.calls[0]).toHaveLength(2);
72
- expect(enterPip).toHaveBeenCalledWith('Chapter 3', null);
73
- });
74
- });