react-native-audio-browser 0.2.0-next.1 → 0.2.0-next.10

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 (284) hide show
  1. package/README.md +22 -18
  2. package/android/build.gradle +7 -5
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/AndroidManifest.xml +3 -1
  5. package/android/src/main/java/com/audiobrowser/AudioBrowser.kt +76 -21
  6. package/android/src/main/java/com/audiobrowser/AudioBrowserLifecycleModule.kt +38 -0
  7. package/android/src/main/java/com/audiobrowser/AudioBrowserPackage.kt +18 -2
  8. package/android/src/main/java/com/audiobrowser/ServiceBinding.kt +48 -0
  9. package/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +1 -2
  10. package/android/src/main/java/com/audiobrowser/browser/BrowserUrlResolution.kt +1 -2
  11. package/android/src/main/java/com/audiobrowser/browser/SectionScope.kt +6 -7
  12. package/android/src/main/java/com/audiobrowser/http/HttpClient.kt +20 -3
  13. package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +11 -11
  14. package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +111 -58
  15. package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +9 -5
  16. package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +218 -252
  17. package/android/src/main/java/com/audiobrowser/player/NowPlayingUpdater.kt +0 -1
  18. package/android/src/main/java/com/audiobrowser/player/PlaybackStateStore.kt +2 -4
  19. package/android/src/main/java/com/audiobrowser/player/Player.kt +30 -8
  20. package/android/src/main/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicy.kt +2 -1
  21. package/android/src/main/java/com/audiobrowser/player/TransformingDataSource.kt +2 -1
  22. package/android/src/main/java/com/audiobrowser/tls/AiaCertChaser.kt +21 -6
  23. package/android/src/main/java/com/audiobrowser/tls/AiaChasingExtendedTrustManager.kt +109 -0
  24. package/android/src/main/java/com/audiobrowser/tls/AiaTls.kt +16 -2
  25. package/android/src/main/java/com/audiobrowser/tls/CachingCertificateFetcher.kt +59 -3
  26. package/android/src/main/java/com/audiobrowser/util/ArtworkVariant.kt +7 -9
  27. package/android/src/main/java/com/audiobrowser/util/TrackFactory.kt +8 -7
  28. package/android/src/test/java/com/audiobrowser/ServiceBindingTest.kt +87 -0
  29. package/android/src/test/java/com/audiobrowser/TestFixtures.kt +0 -1
  30. package/android/src/test/java/com/audiobrowser/browser/JsonArtworkTest.kt +2 -1
  31. package/android/src/test/java/com/audiobrowser/browser/SectionScopeTest.kt +2 -4
  32. package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +100 -56
  33. package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +45 -0
  34. package/android/src/test/java/com/audiobrowser/player/PlaybackErrorClassifierTest.kt +3 -4
  35. package/android/src/test/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicyTest.kt +3 -3
  36. package/android/src/test/java/com/audiobrowser/tls/AiaCertChaserTest.kt +46 -0
  37. package/android/src/test/java/com/audiobrowser/tls/AiaChasingTrustManagerTest.kt +113 -0
  38. package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherTest.kt +83 -0
  39. package/ios/Browser/BrowserManager.swift +2 -27
  40. package/ios/Browser/SearchDrillIn.swift +1 -1
  41. package/ios/CarPlay/RNABMediaAddHandler.swift +6 -6
  42. package/ios/CarPlay/RNABMediaAffinityHandler.swift +2 -2
  43. package/ios/CarPlay/RNABMediaIntentHandler.swift +16 -16
  44. package/ios/HybridAudioBrowser.swift +87 -56
  45. package/ios/Model/RemoteCommand.swift +18 -0
  46. package/ios/Model/TrackPlayerError.swift +2 -2
  47. package/ios/Option/SessionCategories.swift +3 -2
  48. package/ios/Player/MediaIntentCriteria.swift +4 -4
  49. package/ios/Player/MediaLoader.swift +3 -1
  50. package/ios/Player/PlaybackCoordinator.swift +4 -1
  51. package/ios/Player/PlaybackErrorHandler.swift +4 -4
  52. package/ios/Player/QueueManager.swift +10 -3
  53. package/ios/Player/RetryManager.swift +79 -18
  54. package/ios/Player/ShuffleOrder.swift +10 -0
  55. package/ios/Player/SleepTimerManager.swift +43 -15
  56. package/ios/RemoteCommand/RemoteCommandCallbacks.swift +47 -0
  57. package/ios/RemoteCommand/RemoteCommandController.swift +9 -6
  58. package/ios/Tests/LRUCacheTests.swift +111 -0
  59. package/ios/Tests/LoadSeekCoordinatorTests.swift +3 -1
  60. package/ios/Tests/MediaIntentCriteriaTests.swift +2 -2
  61. package/ios/Tests/MediaLoaderTests.swift +10 -13
  62. package/ios/Tests/PlaybackCoordinatorTests.swift +10 -7
  63. package/ios/Tests/PlaybackErrorHandlerTests.swift +3 -1
  64. package/ios/Tests/PlayerTimeObserverTests.swift +37 -0
  65. package/ios/Tests/QueueManagerTests.swift +46 -0
  66. package/ios/Tests/RemoteCommandControllerTests.swift +156 -0
  67. package/ios/Tests/RemoteCommandTests.swift +67 -0
  68. package/ios/Tests/RetryManagerTests.swift +89 -0
  69. package/ios/Tests/SectionScopeTests.swift +2 -2
  70. package/ios/Tests/SleepTimerManagerTests.swift +22 -19
  71. package/ios/Tests/Support/ManualSleepTimerScheduler.swift +47 -0
  72. package/ios/Tests/Support/TestTypes.swift +1 -1
  73. package/ios/Tests/TabBarEntriesTests.swift +7 -7
  74. package/ios/TrackPlayer.swift +6 -1
  75. package/ios/TrackPlayerCallbacks.swift +5 -38
  76. package/ios/Util/LRUCache.swift +4 -1
  77. package/lib/commonjs/AudioBrowser.js +0 -11
  78. package/lib/commonjs/AudioBrowser.js.map +1 -1
  79. package/lib/commonjs/CLAUDE.md +52 -0
  80. package/lib/commonjs/features/browser.js +1 -1
  81. package/lib/commonjs/features/browser.js.map +1 -1
  82. package/lib/commonjs/features/carConnection.js +1 -1
  83. package/lib/commonjs/features/equalizer.js +1 -1
  84. package/lib/commonjs/features/errors.js +3 -3
  85. package/lib/commonjs/features/favorites.js +1 -1
  86. package/lib/commonjs/features/gate.js +16 -1
  87. package/lib/commonjs/features/gate.js.map +1 -1
  88. package/lib/commonjs/features/metadata.js +20 -3
  89. package/lib/commonjs/features/metadata.js.map +1 -1
  90. package/lib/commonjs/features/network.js +1 -1
  91. package/lib/commonjs/features/nowPlaying.js +1 -1
  92. package/lib/commonjs/features/output.js +1 -1
  93. package/lib/commonjs/features/playback/playWhenReady.js +1 -1
  94. package/lib/commonjs/features/playback/playing.js +1 -1
  95. package/lib/commonjs/features/playback/progress.js +1 -1
  96. package/lib/commonjs/features/playback/state.js +1 -1
  97. package/lib/commonjs/features/playback/trackPlaybackTime.js +0 -6
  98. package/lib/commonjs/features/playback/trackPlaybackTime.js.map +1 -1
  99. package/lib/commonjs/features/playback/volume.js +1 -1
  100. package/lib/commonjs/features/player/options.js +48 -34
  101. package/lib/commonjs/features/player/options.js.map +1 -1
  102. package/lib/commonjs/features/player/setup.js +15 -8
  103. package/lib/commonjs/features/player/setup.js.map +1 -1
  104. package/lib/commonjs/features/player/validateOptions.js +21 -0
  105. package/lib/commonjs/features/player/validateOptions.js.map +1 -0
  106. package/lib/commonjs/features/queue/activeTrack.js +1 -1
  107. package/lib/commonjs/features/queue/queue.js +2 -2
  108. package/lib/commonjs/features/queue/repeatMode.js +1 -1
  109. package/lib/commonjs/features/queue/shuffle.js +1 -1
  110. package/lib/commonjs/features/remoteControls.js +13 -92
  111. package/lib/commonjs/features/remoteControls.js.map +1 -1
  112. package/lib/commonjs/features/sleepTimer.js +13 -1
  113. package/lib/commonjs/features/sleepTimer.js.map +1 -1
  114. package/lib/commonjs/test-utils/reactNativeStub.js +65 -0
  115. package/lib/commonjs/test-utils/reactNativeStub.js.map +1 -0
  116. package/lib/commonjs/utils/LazyNativeEmitter.js +8 -5
  117. package/lib/commonjs/utils/LazyNativeEmitter.js.map +1 -1
  118. package/lib/commonjs/web/NativeAudioBrowser.js +1 -1
  119. package/lib/commonjs/web/NativeAudioBrowser.js.map +1 -1
  120. package/lib/commonjs/web/browser/BrowserManager.js +1 -1
  121. package/lib/module/AudioBrowser.js +1 -1
  122. package/lib/module/AudioBrowser.js.map +1 -1
  123. package/lib/module/CLAUDE.md +52 -0
  124. package/lib/module/features/browser.js +1 -1
  125. package/lib/module/features/browser.js.map +1 -1
  126. package/lib/module/features/carConnection.js +1 -1
  127. package/lib/module/features/equalizer.js +1 -1
  128. package/lib/module/features/errors.js +3 -3
  129. package/lib/module/features/favorites.js +1 -1
  130. package/lib/module/features/gate.js +16 -1
  131. package/lib/module/features/gate.js.map +1 -1
  132. package/lib/module/features/metadata.js +20 -3
  133. package/lib/module/features/metadata.js.map +1 -1
  134. package/lib/module/features/network.js +1 -1
  135. package/lib/module/features/nowPlaying.js +1 -1
  136. package/lib/module/features/output.js +1 -1
  137. package/lib/module/features/playback/playWhenReady.js +1 -1
  138. package/lib/module/features/playback/playing.js +1 -1
  139. package/lib/module/features/playback/progress.js +1 -1
  140. package/lib/module/features/playback/state.js +1 -1
  141. package/lib/module/features/playback/trackPlaybackTime.js +0 -5
  142. package/lib/module/features/playback/trackPlaybackTime.js.map +1 -1
  143. package/lib/module/features/playback/volume.js +1 -1
  144. package/lib/module/features/player/options.js +47 -32
  145. package/lib/module/features/player/options.js.map +1 -1
  146. package/lib/module/features/player/setup.js +14 -7
  147. package/lib/module/features/player/setup.js.map +1 -1
  148. package/lib/module/features/player/validateOptions.js +17 -0
  149. package/lib/module/features/player/validateOptions.js.map +1 -0
  150. package/lib/module/features/queue/activeTrack.js +1 -1
  151. package/lib/module/features/queue/queue.js +2 -2
  152. package/lib/module/features/queue/repeatMode.js +1 -1
  153. package/lib/module/features/queue/shuffle.js +1 -1
  154. package/lib/module/features/remoteControls.js +13 -92
  155. package/lib/module/features/remoteControls.js.map +1 -1
  156. package/lib/module/features/sleepTimer.js +13 -1
  157. package/lib/module/features/sleepTimer.js.map +1 -1
  158. package/lib/module/test-utils/reactNativeStub.js +58 -0
  159. package/lib/module/test-utils/reactNativeStub.js.map +1 -0
  160. package/lib/module/utils/LazyNativeEmitter.js +8 -5
  161. package/lib/module/utils/LazyNativeEmitter.js.map +1 -1
  162. package/lib/module/web/NativeAudioBrowser.js +1 -1
  163. package/lib/module/web/NativeAudioBrowser.js.map +1 -1
  164. package/lib/module/web/browser/BrowserManager.js +1 -1
  165. package/lib/typescript/src/AudioBrowser.d.ts +0 -1
  166. package/lib/typescript/src/AudioBrowser.d.ts.map +1 -1
  167. package/lib/typescript/src/features/carConnection.d.ts +1 -1
  168. package/lib/typescript/src/features/equalizer.d.ts +1 -1
  169. package/lib/typescript/src/features/errors.d.ts +3 -3
  170. package/lib/typescript/src/features/favorites.d.ts +1 -1
  171. package/lib/typescript/src/features/gate.d.ts +18 -2
  172. package/lib/typescript/src/features/gate.d.ts.map +1 -1
  173. package/lib/typescript/src/features/metadata.d.ts +20 -3
  174. package/lib/typescript/src/features/metadata.d.ts.map +1 -1
  175. package/lib/typescript/src/features/network.d.ts +1 -1
  176. package/lib/typescript/src/features/nowPlaying.d.ts +1 -1
  177. package/lib/typescript/src/features/output.d.ts +1 -1
  178. package/lib/typescript/src/features/playback/playWhenReady.d.ts +1 -1
  179. package/lib/typescript/src/features/playback/playing.d.ts +1 -1
  180. package/lib/typescript/src/features/playback/progress.d.ts +1 -1
  181. package/lib/typescript/src/features/playback/state.d.ts +1 -1
  182. package/lib/typescript/src/features/playback/volume.d.ts +1 -1
  183. package/lib/typescript/src/features/player/options.d.ts +87 -37
  184. package/lib/typescript/src/features/player/options.d.ts.map +1 -1
  185. package/lib/typescript/src/features/player/setup.d.ts +14 -4
  186. package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
  187. package/lib/typescript/src/features/player/validateOptions.d.ts +9 -0
  188. package/lib/typescript/src/features/player/validateOptions.d.ts.map +1 -0
  189. package/lib/typescript/src/features/queue/activeTrack.d.ts +1 -1
  190. package/lib/typescript/src/features/queue/queue.d.ts +2 -2
  191. package/lib/typescript/src/features/queue/repeatMode.d.ts +1 -1
  192. package/lib/typescript/src/features/queue/shuffle.d.ts +1 -1
  193. package/lib/typescript/src/features/remoteControls.d.ts +23 -22
  194. package/lib/typescript/src/features/remoteControls.d.ts.map +1 -1
  195. package/lib/typescript/src/features/sleepTimer.d.ts +1 -1
  196. package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
  197. package/lib/typescript/src/test-utils/reactNativeStub.d.ts +36 -0
  198. package/lib/typescript/src/test-utils/reactNativeStub.d.ts.map +1 -0
  199. package/lib/typescript/src/utils/LazyNativeEmitter.d.ts +8 -4
  200. package/lib/typescript/src/utils/LazyNativeEmitter.d.ts.map +1 -1
  201. package/nitrogen/generated/android/AudioBrowser+autolinking.cmake +1 -1
  202. package/nitrogen/generated/android/c++/JAndroidOptions.hpp +10 -10
  203. package/nitrogen/generated/android/c++/JFunc_void_Options.hpp +5 -5
  204. package/nitrogen/generated/android/c++/JHybridAudioBrowserSpec.cpp +11 -11
  205. package/nitrogen/generated/android/c++/JHybridAudioBrowserSpec.hpp +1 -1
  206. package/nitrogen/generated/android/c++/JNativeSetupPlayerOptions.hpp +5 -5
  207. package/nitrogen/generated/android/c++/JNativeUpdateOptions.hpp +5 -5
  208. package/nitrogen/generated/android/c++/JNitroAndroidUpdateOptions.hpp +10 -10
  209. package/nitrogen/generated/android/c++/JOptions.hpp +5 -5
  210. package/nitrogen/generated/android/c++/{JNotificationButton.hpp → JRemoteButton.hpp} +19 -19
  211. package/nitrogen/generated/android/c++/JRemoteButtonLayout.hpp +86 -0
  212. package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.cpp +26 -0
  213. package/nitrogen/generated/android/c++/JVariant_NullType_RemoteButtonLayout.hpp +75 -0
  214. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/AndroidOptions.kt +3 -3
  215. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/HybridAudioBrowserSpec.kt +1 -1
  216. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NitroAndroidUpdateOptions.kt +3 -3
  217. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{NotificationButton.kt → RemoteButton.kt} +3 -3
  218. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/RemoteButtonLayout.kt +44 -0
  219. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/{Variant_NullType_NotificationButtonLayout.kt → Variant_NullType_RemoteButtonLayout.kt} +9 -9
  220. package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Bridge.hpp +36 -51
  221. package/nitrogen/generated/ios/AudioBrowser-Swift-Cxx-Umbrella.hpp +6 -6
  222. package/nitrogen/generated/ios/c++/HybridAudioBrowserSpecSwift.hpp +8 -8
  223. package/nitrogen/generated/ios/swift/AndroidOptions.swift +12 -12
  224. package/nitrogen/generated/ios/swift/HybridAudioBrowserSpec.swift +1 -1
  225. package/nitrogen/generated/ios/swift/HybridAudioBrowserSpec_cxx.swift +2 -2
  226. package/nitrogen/generated/ios/swift/NitroAndroidUpdateOptions.swift +12 -12
  227. package/nitrogen/generated/ios/swift/{NotificationButton.swift → RemoteButton.swift} +6 -6
  228. package/nitrogen/generated/ios/swift/RemoteButtonLayout.swift +57 -0
  229. package/nitrogen/generated/ios/swift/{Variant_NullType_NotificationButtonLayout.swift → Variant_NullType_RemoteButtonLayout.swift} +3 -3
  230. package/nitrogen/generated/shared/c++/AndroidOptions.hpp +8 -8
  231. package/nitrogen/generated/shared/c++/HybridAudioBrowserSpec.cpp +1 -1
  232. package/nitrogen/generated/shared/c++/HybridAudioBrowserSpec.hpp +1 -1
  233. package/nitrogen/generated/shared/c++/NitroAndroidUpdateOptions.hpp +8 -8
  234. package/nitrogen/generated/shared/c++/{NotificationButton.hpp → RemoteButton.hpp} +19 -19
  235. package/nitrogen/generated/shared/c++/RemoteButtonLayout.hpp +94 -0
  236. package/package.json +10 -3
  237. package/src/AudioBrowser.ts +1 -1
  238. package/src/CLAUDE.md +52 -0
  239. package/src/features/battery.test.ts +79 -0
  240. package/src/features/browser.ts +1 -1
  241. package/src/features/carConnection.ts +1 -1
  242. package/src/features/equalizer.ts +1 -1
  243. package/src/features/errors.ts +3 -3
  244. package/src/features/favorites.ts +1 -1
  245. package/src/features/gate.ts +16 -1
  246. package/src/features/hook-wiring.test.ts +254 -0
  247. package/src/features/metadata.ts +20 -3
  248. package/src/features/network.ts +1 -1
  249. package/src/features/nowPlaying.ts +1 -1
  250. package/src/features/output.ts +1 -1
  251. package/src/features/playback/playWhenReady.ts +1 -1
  252. package/src/features/playback/playing.ts +1 -1
  253. package/src/features/playback/progress.test.ts +169 -0
  254. package/src/features/playback/progress.ts +1 -1
  255. package/src/features/playback/state.ts +1 -1
  256. package/src/features/playback/trackPlaybackTime.test.ts +16 -6
  257. package/src/features/playback/trackPlaybackTime.ts +0 -5
  258. package/src/features/playback/volume.ts +1 -1
  259. package/src/features/player/options.ts +99 -57
  260. package/src/features/player/setup.test.ts +12 -4
  261. package/src/features/player/setup.ts +19 -9
  262. package/src/features/player/validateOptions.ts +19 -0
  263. package/src/features/queue/activeTrack.ts +1 -1
  264. package/src/features/queue/queue.ts +2 -2
  265. package/src/features/queue/repeatMode.ts +1 -1
  266. package/src/features/queue/shuffle.ts +1 -1
  267. package/src/features/remoteControls.ts +13 -92
  268. package/src/features/sleepTimer.test.ts +172 -0
  269. package/src/features/sleepTimer.ts +9 -1
  270. package/src/public-surface.test.ts +107 -0
  271. package/src/specs/audio-browser.nitro.ts +1 -1
  272. package/src/test-utils/reactNativeStub.ts +60 -0
  273. package/src/utils/LazyNativeEmitter.ts +9 -6
  274. package/src/utils/useDebug.test.ts +182 -0
  275. package/src/utils/useNativeUpdatedValue.test.ts +103 -0
  276. package/src/web/NativeAudioBrowser.ts +1 -1
  277. package/src/web/browser/BrowserManager.ts +1 -1
  278. package/ios/Model/MediaURL.swift +0 -67
  279. package/nitrogen/generated/android/c++/JNotificationButtonLayout.hpp +0 -94
  280. package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.cpp +0 -26
  281. package/nitrogen/generated/android/c++/JVariant_NullType_NotificationButtonLayout.hpp +0 -75
  282. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audiobrowser/NotificationButtonLayout.kt +0 -50
  283. package/nitrogen/generated/ios/swift/NotificationButtonLayout.swift +0 -92
  284. package/nitrogen/generated/shared/c++/NotificationButtonLayout.hpp +0 -102
@@ -0,0 +1,103 @@
1
+ /** @vitest-environment happy-dom */
2
+
3
+ import { renderHook, act, cleanup } from '@testing-library/react'
4
+ import { describe, it, expect, afterEach, vi } from 'vitest'
5
+ import { NativeUpdatedValue } from './NativeUpdatedValue'
6
+ import { useNativeUpdatedValue } from './useNativeUpdatedValue'
7
+
8
+ afterEach(cleanup)
9
+
10
+ /**
11
+ * Builds an emitter plus the native-side callback that feeds it, so a test can
12
+ * push a value the way native would. `NativeUpdatedValue` hands its internal
13
+ * handler to the setter it is constructed with; capturing that handler _is_ the
14
+ * native bridge.
15
+ */
16
+ function makeEmitter<T>() {
17
+ let emit: (value: T) => void = () => {}
18
+ const emitter = NativeUpdatedValue.emitterize<T>((cb) => (emit = cb))
19
+ return {
20
+ emitter,
21
+ /** Emit from outside React, as a native event would arrive. */
22
+ fire: (value: T) => act(() => emit(value)),
23
+ /** Emit from inside a render pass, where wrapping in `act` would nest. */
24
+ fireDuringRender: (value: T) => emit(value)
25
+ }
26
+ }
27
+
28
+ describe('useNativeUpdatedValue', () => {
29
+ it('falls back to the getter when nothing has fired yet', () => {
30
+ const { emitter } = makeEmitter<string>()
31
+ const { result } = renderHook(() =>
32
+ useNativeUpdatedValue(() => 'a', emitter)
33
+ )
34
+ expect(result.current).toBe('a')
35
+ })
36
+
37
+ it('prefers lastValue over the getter', () => {
38
+ const { emitter, fire } = makeEmitter<string>()
39
+ fire('fromNative')
40
+ const getter = vi.fn(() => 'fromGetter')
41
+ const { result } = renderHook(() => useNativeUpdatedValue(getter, emitter))
42
+ expect(result.current).toBe('fromNative')
43
+ expect(getter).not.toHaveBeenCalled()
44
+ })
45
+
46
+ it('updates when the emitter fires', () => {
47
+ const { emitter, fire } = makeEmitter<string>()
48
+ const { result } = renderHook(() =>
49
+ useNativeUpdatedValue(() => 'a', emitter)
50
+ )
51
+ fire('b')
52
+ expect(result.current).toBe('b')
53
+ })
54
+
55
+ it('extracts eventKey from both lastValue and later events', () => {
56
+ const { emitter, fire } = makeEmitter<{ volume: number }>()
57
+ fire({ volume: 0.5 })
58
+ const { result } = renderHook(() =>
59
+ useNativeUpdatedValue(() => 0, emitter, 'volume')
60
+ )
61
+ expect(result.current).toBe(0.5)
62
+ fire({ volume: 0.9 })
63
+ expect(result.current).toBe(0.9)
64
+ })
65
+
66
+ // The reason the effect re-reads `lastValue` instead of going straight to
67
+ // `addListener`. Nothing reads the value again until the next native event, so
68
+ // a value landing in this window would otherwise be missed permanently.
69
+ it('re-syncs a value that lands between the render read and the effect', () => {
70
+ const { emitter, fireDuringRender } = makeEmitter<string>()
71
+ // Firing from inside the getter puts the emit exactly where the race is:
72
+ // after the useState initializer has read, before the effect subscribes.
73
+ const getter = () => {
74
+ fireDuringRender('landedMidRender')
75
+ return 'staleAtRender'
76
+ }
77
+ const { result } = renderHook(() => useNativeUpdatedValue(getter, emitter))
78
+ expect(result.current).toBe('landedMidRender')
79
+ })
80
+
81
+ it('stops updating after unmount', () => {
82
+ const { emitter, fire } = makeEmitter<string>()
83
+ const { result, unmount } = renderHook(() =>
84
+ useNativeUpdatedValue(() => 'a', emitter)
85
+ )
86
+ unmount()
87
+ fire('b')
88
+ expect(result.current).toBe('a')
89
+ })
90
+
91
+ it('leaves no listener behind on unmount', () => {
92
+ const { emitter, fire } = makeEmitter<string>()
93
+ const { unmount } = renderHook(() =>
94
+ useNativeUpdatedValue(() => 'a', emitter)
95
+ )
96
+ unmount()
97
+ const seen: string[] = []
98
+ emitter.addListener((v) => seen.push(v))
99
+ fire('b')
100
+ // Only the listener added above — the hook's is gone, not merely inert.
101
+ expect(seen).toEqual(['b'])
102
+ })
103
+ })
@@ -520,7 +520,7 @@ export class NativeAudioBrowser
520
520
  })
521
521
  }
522
522
 
523
- async onSearch(query: string): Promise<Track[]> {
523
+ async search(query: string): Promise<Track[]> {
524
524
  // Wrap query string in SearchParams (matches Android's search(query: String) overload)
525
525
  return this.searchManager.search({ query, reference: 'unknown' })
526
526
  }
@@ -573,7 +573,7 @@ export class BrowserManager {
573
573
  * `request → search` chain (search is its own kind — no browse layer). The
574
574
  * query params are seeded on the base so they survive both the static merge
575
575
  * and a search `transform`. Shared by `resolveSearchContent` (navigating to a
576
- * search path) and `SearchManager` (the voice/`onSearch` API), so the ladder
576
+ * search path) and `SearchManager` (the voice/`search` API), so the ladder
577
577
  * isn't duplicated. Errors propagate to the caller.
578
578
  */
579
579
  async fetchSearchResults(
@@ -1,67 +0,0 @@
1
- import Foundation
2
-
3
- struct MediaURL {
4
- let value: URL
5
- let isLocal: Bool
6
- private let originalObject: Any
7
-
8
- init?(object: Any?) {
9
- guard let object else { return nil }
10
- originalObject = object
11
-
12
- // This is based on logic found in RCTConvert NSURLRequest
13
- if let localObject = object as? [String: Any] {
14
- var urlString = localObject["uri"] as? String ?? localObject["url"] as! String
15
-
16
- if let bundleName = localObject["bundle"] as? String {
17
- urlString = String(format: "%@.bundle/%@", bundleName, urlString)
18
- }
19
-
20
- isLocal = !urlString.lowercased().hasPrefix("http")
21
- guard let converted = Self.convertToURL(urlString) else { return nil }
22
- value = converted
23
- } else {
24
- let urlString = object as! String
25
- isLocal = urlString.lowercased().hasPrefix("file://")
26
- guard let converted = Self.convertToURL(urlString) else { return nil }
27
- value = converted
28
- }
29
- }
30
-
31
- /// Convert a string to URL, matching RCTConvert NSURL behavior
32
- private static func convertToURL(_ string: String) -> URL? {
33
- // Try as absolute URL first
34
- if let url = URL(string: string), url.scheme != nil {
35
- return url
36
- }
37
-
38
- // If it has a scheme but failed, try percent-encoding
39
- if string.contains("://") {
40
- var allowed = CharacterSet()
41
- allowed.formUnion(.urlUserAllowed)
42
- allowed.formUnion(.urlPasswordAllowed)
43
- allowed.formUnion(.urlHostAllowed)
44
- allowed.formUnion(.urlPathAllowed)
45
- allowed.formUnion(.urlQueryAllowed)
46
- allowed.formUnion(.urlFragmentAllowed)
47
- if let encoded = string.addingPercentEncoding(withAllowedCharacters: allowed),
48
- let url = URL(string: encoded)
49
- {
50
- return url
51
- }
52
- }
53
-
54
- // Assume it's a local path
55
- var path = string.removingPercentEncoding ?? string
56
-
57
- if path.hasPrefix("~") {
58
- // Expand tilde for user directory
59
- path = NSString(string: path).expandingTildeInPath
60
- } else if !path.hasPrefix("/") {
61
- // Not absolute - assume it's a bundle resource path
62
- path = (Bundle.main.resourcePath ?? "") + "/" + path
63
- }
64
-
65
- return URL(fileURLWithPath: path)
66
- }
67
- }
@@ -1,94 +0,0 @@
1
- ///
2
- /// JNotificationButtonLayout.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include "NotificationButtonLayout.hpp"
12
-
13
- #include "JNotificationButton.hpp"
14
- #include "NotificationButton.hpp"
15
- #include <optional>
16
- #include <vector>
17
-
18
- namespace margelo::nitro::audiobrowser {
19
-
20
- using namespace facebook;
21
-
22
- /**
23
- * The C++ JNI bridge between the C++ struct "NotificationButtonLayout" and the the Kotlin data class "NotificationButtonLayout".
24
- */
25
- struct JNotificationButtonLayout final: public jni::JavaClass<JNotificationButtonLayout> {
26
- public:
27
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/NotificationButtonLayout;";
28
-
29
- public:
30
- /**
31
- * Convert this Java/Kotlin-based struct to the C++ struct NotificationButtonLayout by copying all values to C++.
32
- */
33
- [[maybe_unused]]
34
- [[nodiscard]]
35
- NotificationButtonLayout toCpp() const {
36
- static const auto clazz = javaClassStatic();
37
- static const auto fieldBack = clazz->getField<JNotificationButton>("back");
38
- jni::local_ref<JNotificationButton> back = this->getFieldValue(fieldBack);
39
- static const auto fieldForward = clazz->getField<JNotificationButton>("forward");
40
- jni::local_ref<JNotificationButton> forward = this->getFieldValue(fieldForward);
41
- static const auto fieldBackSecondary = clazz->getField<JNotificationButton>("backSecondary");
42
- jni::local_ref<JNotificationButton> backSecondary = this->getFieldValue(fieldBackSecondary);
43
- static const auto fieldForwardSecondary = clazz->getField<JNotificationButton>("forwardSecondary");
44
- jni::local_ref<JNotificationButton> forwardSecondary = this->getFieldValue(fieldForwardSecondary);
45
- static const auto fieldOverflow = clazz->getField<jni::JArrayClass<JNotificationButton>>("overflow");
46
- jni::local_ref<jni::JArrayClass<JNotificationButton>> overflow = this->getFieldValue(fieldOverflow);
47
- return NotificationButtonLayout(
48
- back != nullptr ? std::make_optional(back->toCpp()) : std::nullopt,
49
- forward != nullptr ? std::make_optional(forward->toCpp()) : std::nullopt,
50
- backSecondary != nullptr ? std::make_optional(backSecondary->toCpp()) : std::nullopt,
51
- forwardSecondary != nullptr ? std::make_optional(forwardSecondary->toCpp()) : std::nullopt,
52
- overflow != nullptr ? std::make_optional([&]() {
53
- size_t __size = overflow->size();
54
- std::vector<NotificationButton> __vector;
55
- __vector.reserve(__size);
56
- for (size_t __i = 0; __i < __size; __i++) {
57
- auto __element = overflow->getElement(__i);
58
- __vector.push_back(__element->toCpp());
59
- }
60
- return __vector;
61
- }()) : std::nullopt
62
- );
63
- }
64
-
65
- public:
66
- /**
67
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
68
- */
69
- [[maybe_unused]]
70
- static jni::local_ref<JNotificationButtonLayout::javaobject> fromCpp(const NotificationButtonLayout& value) {
71
- using JSignature = JNotificationButtonLayout(jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<JNotificationButton>, jni::alias_ref<jni::JArrayClass<JNotificationButton>>);
72
- static const auto clazz = javaClassStatic();
73
- static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
74
- return create(
75
- clazz,
76
- value.back.has_value() ? JNotificationButton::fromCpp(value.back.value()) : nullptr,
77
- value.forward.has_value() ? JNotificationButton::fromCpp(value.forward.value()) : nullptr,
78
- value.backSecondary.has_value() ? JNotificationButton::fromCpp(value.backSecondary.value()) : nullptr,
79
- value.forwardSecondary.has_value() ? JNotificationButton::fromCpp(value.forwardSecondary.value()) : nullptr,
80
- value.overflow.has_value() ? [&]() {
81
- size_t __size = value.overflow.value().size();
82
- jni::local_ref<jni::JArrayClass<JNotificationButton>> __array = jni::JArrayClass<JNotificationButton>::newArray(__size);
83
- for (size_t __i = 0; __i < __size; __i++) {
84
- const auto& __element = value.overflow.value()[__i];
85
- auto __elementJni = JNotificationButton::fromCpp(__element);
86
- __array->setElement(__i, *__elementJni);
87
- }
88
- return __array;
89
- }() : nullptr
90
- );
91
- }
92
- };
93
-
94
- } // namespace margelo::nitro::audiobrowser
@@ -1,26 +0,0 @@
1
- ///
2
- /// JVariant_NullType_NotificationButtonLayout.cpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #include "JVariant_NullType_NotificationButtonLayout.hpp"
9
-
10
- namespace margelo::nitro::audiobrowser {
11
- /**
12
- * Converts JVariant_NullType_NotificationButtonLayout to std::variant<nitro::NullType, NotificationButtonLayout>
13
- */
14
- std::variant<nitro::NullType, NotificationButtonLayout> JVariant_NullType_NotificationButtonLayout::toCpp() const {
15
- if (isInstanceOf(JVariant_NullType_NotificationButtonLayout_impl::First::javaClassStatic())) {
16
- // It's a `nitro::NullType`
17
- auto jniValue = static_cast<const JVariant_NullType_NotificationButtonLayout_impl::First*>(this)->getValue();
18
- return nitro::null;
19
- } else if (isInstanceOf(JVariant_NullType_NotificationButtonLayout_impl::Second::javaClassStatic())) {
20
- // It's a `NotificationButtonLayout`
21
- auto jniValue = static_cast<const JVariant_NullType_NotificationButtonLayout_impl::Second*>(this)->getValue();
22
- return jniValue->toCpp();
23
- }
24
- throw std::invalid_argument("Variant is unknown Kotlin instance!");
25
- }
26
- } // namespace margelo::nitro::audiobrowser
@@ -1,75 +0,0 @@
1
- ///
2
- /// JVariant_NullType_NotificationButtonLayout.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include <variant>
12
-
13
- #include <NitroModules/Null.hpp>
14
- #include "NotificationButtonLayout.hpp"
15
- #include <variant>
16
- #include <NitroModules/JNull.hpp>
17
- #include "JNotificationButtonLayout.hpp"
18
- #include "NotificationButton.hpp"
19
- #include <optional>
20
- #include "JNotificationButton.hpp"
21
- #include <vector>
22
-
23
- namespace margelo::nitro::audiobrowser {
24
-
25
- using namespace facebook;
26
-
27
- /**
28
- * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_NotificationButtonLayout".
29
- */
30
- class JVariant_NullType_NotificationButtonLayout: public jni::JavaClass<JVariant_NullType_NotificationButtonLayout> {
31
- public:
32
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout;";
33
-
34
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> create_0(jni::alias_ref<JNull> value) {
35
- static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_NotificationButtonLayout(jni::alias_ref<JNull>)>("create");
36
- return method(javaClassStatic(), value);
37
- }
38
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> create_1(jni::alias_ref<JNotificationButtonLayout> value) {
39
- static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_NotificationButtonLayout(jni::alias_ref<JNotificationButtonLayout>)>("create");
40
- return method(javaClassStatic(), value);
41
- }
42
-
43
- static jni::local_ref<JVariant_NullType_NotificationButtonLayout> fromCpp(const std::variant<nitro::NullType, NotificationButtonLayout>& variant) {
44
- switch (variant.index()) {
45
- case 0: return create_0(JNull::null());
46
- case 1: return create_1(JNotificationButtonLayout::fromCpp(std::get<1>(variant)));
47
- default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
48
- }
49
- }
50
-
51
- [[nodiscard]] std::variant<nitro::NullType, NotificationButtonLayout> toCpp() const;
52
- };
53
-
54
- namespace JVariant_NullType_NotificationButtonLayout_impl {
55
- class First final: public jni::JavaClass<First, JVariant_NullType_NotificationButtonLayout> {
56
- public:
57
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout$First;";
58
-
59
- [[nodiscard]] jni::local_ref<JNull> getValue() const {
60
- static const auto field = javaClassStatic()->getField<JNull>("value");
61
- return getFieldValue(field);
62
- }
63
- };
64
-
65
- class Second final: public jni::JavaClass<Second, JVariant_NullType_NotificationButtonLayout> {
66
- public:
67
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audiobrowser/Variant_NullType_NotificationButtonLayout$Second;";
68
-
69
- [[nodiscard]] jni::local_ref<JNotificationButtonLayout> getValue() const {
70
- static const auto field = javaClassStatic()->getField<JNotificationButtonLayout>("value");
71
- return getFieldValue(field);
72
- }
73
- };
74
- } // namespace JVariant_NullType_NotificationButtonLayout_impl
75
- } // namespace margelo::nitro::audiobrowser
@@ -1,50 +0,0 @@
1
- ///
2
- /// NotificationButtonLayout.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audiobrowser
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.proguard.annotations.DoNotStrip
12
-
13
-
14
- /**
15
- * Represents the JavaScript object/struct "NotificationButtonLayout".
16
- */
17
- @DoNotStrip
18
- @Keep
19
- data class NotificationButtonLayout(
20
- @DoNotStrip
21
- @Keep
22
- val back: NotificationButton?,
23
- @DoNotStrip
24
- @Keep
25
- val forward: NotificationButton?,
26
- @DoNotStrip
27
- @Keep
28
- val backSecondary: NotificationButton?,
29
- @DoNotStrip
30
- @Keep
31
- val forwardSecondary: NotificationButton?,
32
- @DoNotStrip
33
- @Keep
34
- val overflow: Array<NotificationButton>?
35
- ) {
36
- /* primary constructor */
37
-
38
- companion object {
39
- /**
40
- * Constructor called from C++
41
- */
42
- @DoNotStrip
43
- @Keep
44
- @Suppress("unused")
45
- @JvmStatic
46
- private fun fromCpp(back: NotificationButton?, forward: NotificationButton?, backSecondary: NotificationButton?, forwardSecondary: NotificationButton?, overflow: Array<NotificationButton>?): NotificationButtonLayout {
47
- return NotificationButtonLayout(back, forward, backSecondary, forwardSecondary, overflow)
48
- }
49
- }
50
- }
@@ -1,92 +0,0 @@
1
- ///
2
- /// NotificationButtonLayout.swift
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- import NitroModules
9
-
10
- /**
11
- * Represents an instance of `NotificationButtonLayout`, backed by a C++ struct.
12
- */
13
- public typealias NotificationButtonLayout = margelo.nitro.audiobrowser.NotificationButtonLayout
14
-
15
- public extension NotificationButtonLayout {
16
- private typealias bridge = margelo.nitro.audiobrowser.bridge.swift
17
-
18
- /**
19
- * Create a new instance of `NotificationButtonLayout`.
20
- */
21
- init(back: NotificationButton?, forward: NotificationButton?, backSecondary: NotificationButton?, forwardSecondary: NotificationButton?, overflow: [NotificationButton]?) {
22
- self.init({ () -> bridge.std__optional_NotificationButton_ in
23
- if let __unwrappedValue = back {
24
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
25
- } else {
26
- return .init()
27
- }
28
- }(), { () -> bridge.std__optional_NotificationButton_ in
29
- if let __unwrappedValue = forward {
30
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
31
- } else {
32
- return .init()
33
- }
34
- }(), { () -> bridge.std__optional_NotificationButton_ in
35
- if let __unwrappedValue = backSecondary {
36
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
37
- } else {
38
- return .init()
39
- }
40
- }(), { () -> bridge.std__optional_NotificationButton_ in
41
- if let __unwrappedValue = forwardSecondary {
42
- return bridge.create_std__optional_NotificationButton_(__unwrappedValue)
43
- } else {
44
- return .init()
45
- }
46
- }(), { () -> bridge.std__optional_std__vector_NotificationButton__ in
47
- if let __unwrappedValue = overflow {
48
- return bridge.create_std__optional_std__vector_NotificationButton__({ () -> bridge.std__vector_NotificationButton_ in
49
- var __vector = bridge.create_std__vector_NotificationButton_(__unwrappedValue.count)
50
- for __item in __unwrappedValue {
51
- __vector.push_back(__item)
52
- }
53
- return __vector
54
- }())
55
- } else {
56
- return .init()
57
- }
58
- }())
59
- }
60
-
61
- @inline(__always)
62
- var back: NotificationButton? {
63
- return self.__back.value
64
- }
65
-
66
- @inline(__always)
67
- var forward: NotificationButton? {
68
- return self.__forward.value
69
- }
70
-
71
- @inline(__always)
72
- var backSecondary: NotificationButton? {
73
- return self.__backSecondary.value
74
- }
75
-
76
- @inline(__always)
77
- var forwardSecondary: NotificationButton? {
78
- return self.__forwardSecondary.value
79
- }
80
-
81
- @inline(__always)
82
- var overflow: [NotificationButton]? {
83
- return { () -> [NotificationButton]? in
84
- if bridge.has_value_std__optional_std__vector_NotificationButton__(self.__overflow) {
85
- let __unwrapped = bridge.get_std__optional_std__vector_NotificationButton__(self.__overflow)
86
- return __unwrapped.map({ __item in __item })
87
- } else {
88
- return nil
89
- }
90
- }()
91
- }
92
- }
@@ -1,102 +0,0 @@
1
- ///
2
- /// NotificationButtonLayout.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/JSIConverter.hpp>)
11
- #include <NitroModules/JSIConverter.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
- #if __has_include(<NitroModules/NitroDefines.hpp>)
16
- #include <NitroModules/NitroDefines.hpp>
17
- #else
18
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
- #endif
20
- #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
- #include <NitroModules/JSIHelpers.hpp>
22
- #else
23
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
- #endif
25
- #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
- #include <NitroModules/PropNameIDCache.hpp>
27
- #else
28
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
- #endif
30
-
31
- // Forward declaration of `NotificationButton` to properly resolve imports.
32
- namespace margelo::nitro::audiobrowser { enum class NotificationButton; }
33
-
34
- #include "NotificationButton.hpp"
35
- #include <optional>
36
- #include <vector>
37
-
38
- namespace margelo::nitro::audiobrowser {
39
-
40
- /**
41
- * A struct which can be represented as a JavaScript object (NotificationButtonLayout).
42
- */
43
- struct NotificationButtonLayout final {
44
- public:
45
- std::optional<NotificationButton> back SWIFT_PRIVATE;
46
- std::optional<NotificationButton> forward SWIFT_PRIVATE;
47
- std::optional<NotificationButton> backSecondary SWIFT_PRIVATE;
48
- std::optional<NotificationButton> forwardSecondary SWIFT_PRIVATE;
49
- std::optional<std::vector<NotificationButton>> overflow SWIFT_PRIVATE;
50
-
51
- public:
52
- NotificationButtonLayout() = default;
53
- explicit NotificationButtonLayout(std::optional<NotificationButton> back, std::optional<NotificationButton> forward, std::optional<NotificationButton> backSecondary, std::optional<NotificationButton> forwardSecondary, std::optional<std::vector<NotificationButton>> overflow): back(back), forward(forward), backSecondary(backSecondary), forwardSecondary(forwardSecondary), overflow(overflow) {}
54
-
55
- public:
56
- friend bool operator==(const NotificationButtonLayout& lhs, const NotificationButtonLayout& rhs) = default;
57
- };
58
-
59
- } // namespace margelo::nitro::audiobrowser
60
-
61
- namespace margelo::nitro {
62
-
63
- // C++ NotificationButtonLayout <> JS NotificationButtonLayout (object)
64
- template <>
65
- struct JSIConverter<margelo::nitro::audiobrowser::NotificationButtonLayout> final {
66
- static inline margelo::nitro::audiobrowser::NotificationButtonLayout fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
67
- jsi::Object obj = arg.asObject(runtime);
68
- return margelo::nitro::audiobrowser::NotificationButtonLayout(
69
- JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "back"))),
70
- JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forward"))),
71
- JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backSecondary"))),
72
- JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forwardSecondary"))),
73
- JSIConverter<std::optional<std::vector<margelo::nitro::audiobrowser::NotificationButton>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "overflow")))
74
- );
75
- }
76
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::audiobrowser::NotificationButtonLayout& arg) {
77
- jsi::Object obj(runtime);
78
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "back"), JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::toJSI(runtime, arg.back));
79
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "forward"), JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::toJSI(runtime, arg.forward));
80
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "backSecondary"), JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::toJSI(runtime, arg.backSecondary));
81
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "forwardSecondary"), JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::toJSI(runtime, arg.forwardSecondary));
82
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "overflow"), JSIConverter<std::optional<std::vector<margelo::nitro::audiobrowser::NotificationButton>>>::toJSI(runtime, arg.overflow));
83
- return obj;
84
- }
85
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
86
- if (!value.isObject()) {
87
- return false;
88
- }
89
- jsi::Object obj = value.getObject(runtime);
90
- if (!nitro::isPlainObject(runtime, obj)) {
91
- return false;
92
- }
93
- if (!JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "back")))) return false;
94
- if (!JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forward")))) return false;
95
- if (!JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "backSecondary")))) return false;
96
- if (!JSIConverter<std::optional<margelo::nitro::audiobrowser::NotificationButton>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forwardSecondary")))) return false;
97
- if (!JSIConverter<std::optional<std::vector<margelo::nitro::audiobrowser::NotificationButton>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "overflow")))) return false;
98
- return true;
99
- }
100
- };
101
-
102
- } // namespace margelo::nitro