react-native-audio-browser 0.2.0-next.62 → 0.2.0-next.63
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/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +16 -6
- package/android/src/main/java/com/audiobrowser/player/PlaybackStateMachine.kt +9 -6
- package/android/src/main/java/com/audiobrowser/player/PlayerListener.kt +0 -5
- package/android/src/test/java/com/audiobrowser/browser/BrowserManagerInvalidationTest.kt +14 -0
- package/android/src/test/java/com/audiobrowser/player/PlaybackStateMachineTest.kt +7 -6
- package/android/src/test/java/com/audiobrowser/player/PlayerRetryTest.kt +35 -0
- package/ios/Browser/BrowserManager.swift +22 -7
- package/ios/HybridAudioBrowser+Options.swift +14 -0
- package/ios/HybridAudioBrowser.swift +4 -1
- package/lib/commonjs/CLAUDE.md +2 -2
- package/lib/commonjs/features/sleepTimer.js +8 -12
- package/lib/commonjs/features/sleepTimer.js.map +1 -1
- package/lib/commonjs/utils/LazyNativeEmitter.js +3 -3
- package/lib/commonjs/utils/NativeUpdatedValue.js +10 -13
- package/lib/commonjs/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/commonjs/utils/useNativeUpdatedValue.js +12 -20
- package/lib/commonjs/utils/useNativeUpdatedValue.js.map +1 -1
- package/lib/commonjs/utils/useNativeValueRefreshedBy.js +10 -5
- package/lib/commonjs/utils/useNativeValueRefreshedBy.js.map +1 -1
- package/lib/module/CLAUDE.md +2 -2
- package/lib/module/features/sleepTimer.js +9 -13
- package/lib/module/features/sleepTimer.js.map +1 -1
- package/lib/module/utils/LazyNativeEmitter.js +3 -3
- package/lib/module/utils/NativeUpdatedValue.js +10 -13
- package/lib/module/utils/NativeUpdatedValue.js.map +1 -1
- package/lib/module/utils/useNativeUpdatedValue.js +13 -21
- package/lib/module/utils/useNativeUpdatedValue.js.map +1 -1
- package/lib/module/utils/useNativeValueRefreshedBy.js +11 -6
- package/lib/module/utils/useNativeValueRefreshedBy.js.map +1 -1
- package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
- package/lib/typescript/src/utils/LazyNativeEmitter.d.ts +3 -3
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts +4 -13
- package/lib/typescript/src/utils/NativeUpdatedValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/useNativeUpdatedValue.d.ts +4 -4
- package/lib/typescript/src/utils/useNativeUpdatedValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/useNativeValueRefreshedBy.d.ts +3 -4
- package/lib/typescript/src/utils/useNativeValueRefreshedBy.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CLAUDE.md +2 -2
- package/src/features/sleepTimer.test.ts +25 -26
- package/src/features/sleepTimer.ts +9 -9
- package/src/utils/LazyNativeEmitter.ts +3 -3
- package/src/utils/NativeUpdatedValue.ts +10 -13
- package/src/utils/useNativeUpdatedValue.test.ts +30 -22
- package/src/utils/useNativeUpdatedValue.ts +13 -17
- package/src/utils/useNativeValueRefreshedBy.test.ts +68 -0
- package/src/utils/useNativeValueRefreshedBy.ts +13 -6
|
@@ -81,10 +81,12 @@ class BrowserManager {
|
|
|
81
81
|
|
|
82
82
|
private val contentCache = LruCache<String, ResolvedTrack>(20)
|
|
83
83
|
|
|
84
|
-
// Moves on clearContentCache, so a fetch that outlives one caches nothing
|
|
85
|
-
//
|
|
86
|
-
//
|
|
84
|
+
// Moves on clearContentCache, so a fetch that outlives one caches nothing; [pageGenerations]
|
|
85
|
+
// does the same for one path, and is cleared only together with a move of this. Separate from
|
|
86
|
+
// layerGeneration, which also moves on every path change. Car browses run on IO threads and
|
|
87
|
+
// the clear on the JS thread: each check and its write hold [cacheLock].
|
|
87
88
|
@Volatile private var contentGeneration = 0
|
|
89
|
+
private val pageGenerations = HashMap<String, Int>()
|
|
88
90
|
private var tabsGeneration = -1
|
|
89
91
|
private val cacheLock = Any()
|
|
90
92
|
|
|
@@ -453,11 +455,13 @@ class BrowserManager {
|
|
|
453
455
|
Timber.d("Content cache MISS for path='$normalizedPath'")
|
|
454
456
|
}
|
|
455
457
|
|
|
456
|
-
val generation =
|
|
458
|
+
val generation = synchronized(cacheLock) { pageGeneration(normalizedPath) }
|
|
457
459
|
val resolvedTrack = resolveUncached(normalizedPath)
|
|
458
460
|
|
|
459
461
|
synchronized(cacheLock) {
|
|
460
|
-
if (generation ==
|
|
462
|
+
if (generation == pageGeneration(normalizedPath)) {
|
|
463
|
+
contentCache.put(normalizedPath, resolvedTrack)
|
|
464
|
+
}
|
|
461
465
|
}
|
|
462
466
|
|
|
463
467
|
cacheChildren(resolvedTrack)
|
|
@@ -470,10 +474,15 @@ class BrowserManager {
|
|
|
470
474
|
require(!BrowserPathHelper.isContextual(path)) {
|
|
471
475
|
"invalidateContentCache() expects a container path, not a contextual path: $path"
|
|
472
476
|
}
|
|
473
|
-
|
|
477
|
+
synchronized(cacheLock) {
|
|
478
|
+
pageGenerations[path] = (pageGenerations[path] ?: 0) + 1
|
|
479
|
+
contentCache.remove(path)
|
|
480
|
+
}
|
|
474
481
|
Timber.d("Invalidated content cache for path='$path'")
|
|
475
482
|
}
|
|
476
483
|
|
|
484
|
+
private fun pageGeneration(path: String) = contentGeneration to pageGenerations[path]
|
|
485
|
+
|
|
477
486
|
/**
|
|
478
487
|
* Clears every cached page and the last search, which nothing else evicts, and re-resolves the
|
|
479
488
|
* tabs, resolver layers and "view more" title on the next request. A fetch in flight caches
|
|
@@ -482,6 +491,7 @@ class BrowserManager {
|
|
|
482
491
|
fun clearContentCache() {
|
|
483
492
|
synchronized(cacheLock) {
|
|
484
493
|
contentGeneration += 1
|
|
494
|
+
pageGenerations.clear()
|
|
485
495
|
contentCache.evictAll()
|
|
486
496
|
lastSearch = null
|
|
487
497
|
}
|
|
@@ -64,7 +64,10 @@ object PlaybackStateMachine {
|
|
|
64
64
|
}
|
|
65
65
|
is PlaybackEvent.MediaItemTransition ->
|
|
66
66
|
when {
|
|
67
|
-
|
|
67
|
+
// An emptied queue. STOPPED holds: the service clears the queue just before stop(), and
|
|
68
|
+
// the events arrive after it.
|
|
69
|
+
!event.hasTrack ->
|
|
70
|
+
if (current == PlaybackState.STOPPED) emptyList() else listOf(PlaybackState.NONE)
|
|
68
71
|
// Already playing (gapless auto-advance): no IsPlayingChanged follows, so run the whole
|
|
69
72
|
// sequence here or the state sticks on LOADING.
|
|
70
73
|
event.isPlaying ->
|
|
@@ -74,11 +77,11 @@ object PlaybackStateMachine {
|
|
|
74
77
|
is PlaybackEvent.ShouldPlayWhenReadyChanged ->
|
|
75
78
|
when {
|
|
76
79
|
// stop() and a natural end both clear the intent themselves; STOPPED and ENDED must not
|
|
77
|
-
// turn into PAUSED.
|
|
78
|
-
!event.shouldPlayWhenReady
|
|
79
|
-
current
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
// turn into PAUSED. A pause holds ERROR, as on iOS.
|
|
81
|
+
!event.shouldPlayWhenReady ->
|
|
82
|
+
if (current in setOf(PlaybackState.STOPPED, PlaybackState.ENDED, PlaybackState.ERROR))
|
|
83
|
+
emptyList()
|
|
84
|
+
else listOf(PlaybackState.PAUSED)
|
|
82
85
|
// Resuming while ExoPlayer still buffers: no state change of its own follows, and the
|
|
83
86
|
// READY after it is dropped while playing, so report the load now.
|
|
84
87
|
current == PlaybackState.PAUSED && event.exoState == MediaPlayer.STATE_BUFFERING ->
|
|
@@ -150,11 +150,6 @@ class PlayerListener(private val player: Player) : MediaPlayer.Listener {
|
|
|
150
150
|
override fun onEvents(media3Player: MediaPlayer, events: MediaPlayer.Events) {
|
|
151
151
|
// In event order: each setPlaybackState emits.
|
|
152
152
|
for (i in 0 until events.size()) {
|
|
153
|
-
// A new item clears the prior error even when no state transition follows (queue emptied).
|
|
154
|
-
if (events[i] == MediaPlayer.EVENT_MEDIA_ITEM_TRANSITION) {
|
|
155
|
-
player.playbackError = null
|
|
156
|
-
}
|
|
157
|
-
|
|
158
153
|
val event =
|
|
159
154
|
when (events[i]) {
|
|
160
155
|
MediaPlayer.EVENT_PLAYBACK_STATE_CHANGED ->
|
|
@@ -139,6 +139,20 @@ class BrowserManagerInvalidationTest {
|
|
|
139
139
|
assertNull(browserManager.getTabs())
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
@Test
|
|
143
|
+
fun `a page in flight across invalidateContentCache of its path is not cached`() {
|
|
144
|
+
across({ browserManager.invalidateContentCache("/page") }) { browserManager.resolve("/page") }
|
|
145
|
+
|
|
146
|
+
assertEquals("nl", runBlocking { browserManager.resolve("/page") }.title)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@Test
|
|
150
|
+
fun `a page in flight across invalidateContentCache of another path is cached`() {
|
|
151
|
+
across({ browserManager.invalidateContentCache("/other") }) { browserManager.resolve("/page") }
|
|
152
|
+
|
|
153
|
+
assertEquals("en", runBlocking { browserManager.resolve("/page") }.title)
|
|
154
|
+
}
|
|
155
|
+
|
|
142
156
|
@Test
|
|
143
157
|
fun `a page in flight across a config change is cached`() {
|
|
144
158
|
across({ browserManager.config = config() }) { browserManager.resolve("/page") }
|
|
@@ -146,17 +146,17 @@ class PlaybackStateMachineTest {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
@Test
|
|
149
|
-
fun `a transition without a track is
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)
|
|
149
|
+
fun `a transition without a track is none, except from stopped`() {
|
|
150
|
+
val emptied = PlaybackEvent.MediaItemTransition(hasTrack = false, isPlaying = false)
|
|
151
|
+
assertEquals(listOf(PlaybackState.NONE), on(emptied, from = PlaybackState.ERROR))
|
|
152
|
+
assertEquals(listOf(PlaybackState.NONE), on(emptied, from = PlaybackState.ENDED))
|
|
153
|
+
assertEquals(emptyList<PlaybackState>(), on(emptied, from = PlaybackState.STOPPED))
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// MARK: shouldPlayWhenReady / isPlaying
|
|
157
157
|
|
|
158
158
|
@Test
|
|
159
|
-
fun `losing shouldPlayWhenReady pauses except from stopped or
|
|
159
|
+
fun `losing shouldPlayWhenReady pauses except from stopped, ended or error`() {
|
|
160
160
|
val paused =
|
|
161
161
|
PlaybackEvent.ShouldPlayWhenReadyChanged(
|
|
162
162
|
shouldPlayWhenReady = false,
|
|
@@ -165,6 +165,7 @@ class PlaybackStateMachineTest {
|
|
|
165
165
|
assertEquals(listOf(PlaybackState.PAUSED), on(paused, from = PlaybackState.PLAYING))
|
|
166
166
|
assertEquals(emptyList<PlaybackState>(), on(paused, from = PlaybackState.STOPPED))
|
|
167
167
|
assertEquals(emptyList<PlaybackState>(), on(paused, from = PlaybackState.ENDED))
|
|
168
|
+
assertEquals(emptyList<PlaybackState>(), on(paused, from = PlaybackState.ERROR))
|
|
168
169
|
assertEquals(
|
|
169
170
|
emptyList<PlaybackState>(),
|
|
170
171
|
on(
|
|
@@ -33,6 +33,8 @@ import org.junit.rules.TemporaryFolder
|
|
|
33
33
|
import org.junit.runner.RunWith
|
|
34
34
|
import org.mockito.Mockito.mock
|
|
35
35
|
import org.mockito.Mockito.mockingDetails
|
|
36
|
+
import org.mockito.Mockito.never
|
|
37
|
+
import org.mockito.Mockito.verify
|
|
36
38
|
import org.robolectric.RobolectricTestRunner
|
|
37
39
|
import org.robolectric.RuntimeEnvironment
|
|
38
40
|
import org.robolectric.Shadows.shadowOf
|
|
@@ -89,6 +91,30 @@ class PlayerRetryTest {
|
|
|
89
91
|
assertFalse(player.hasPlayedCache)
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
@Test
|
|
95
|
+
fun `a pause keeps a terminal error`() {
|
|
96
|
+
failTerminally()
|
|
97
|
+
val failed = player.getPlayback()
|
|
98
|
+
|
|
99
|
+
player.pause()
|
|
100
|
+
shadowOf(Looper.getMainLooper()).idle()
|
|
101
|
+
|
|
102
|
+
assertEquals(failed, player.getPlayback())
|
|
103
|
+
verify(callbacks, never()).onPlaybackError(null)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@Test
|
|
107
|
+
fun `emptying the queue clears a terminal error`() {
|
|
108
|
+
failTerminally()
|
|
109
|
+
|
|
110
|
+
player.clear()
|
|
111
|
+
shadowOf(Looper.getMainLooper()).idle()
|
|
112
|
+
|
|
113
|
+
assertEquals(Playback(PlaybackState.NONE, null), player.getPlayback())
|
|
114
|
+
verify(callbacks).onPlaybackError(null)
|
|
115
|
+
verify(callbacks).onPlaybackChanged(Playback(PlaybackState.NONE, null))
|
|
116
|
+
}
|
|
117
|
+
|
|
92
118
|
@Test
|
|
93
119
|
fun `a player that gave up stays stopped when the network returns`() {
|
|
94
120
|
connectivity.setNetworkCapabilities(wifi, capabilities(validated = false))
|
|
@@ -120,6 +146,15 @@ class PlayerRetryTest {
|
|
|
120
146
|
assertEquals(PlaybackState.ERROR, player.playbackState)
|
|
121
147
|
}
|
|
122
148
|
|
|
149
|
+
/** A closed port: the load fails at once, and with no retries the failure is terminal. */
|
|
150
|
+
private fun failTerminally() {
|
|
151
|
+
play("https://127.0.0.1:9/stream", RetryPolicy.Limited(maxRetries = 0))
|
|
152
|
+
idleUntil("a terminal error") {
|
|
153
|
+
ShadowSystemClock.advanceBy(Duration.ofSeconds(1))
|
|
154
|
+
player.playbackState == PlaybackState.ERROR
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
123
158
|
private fun play(src: String, retryPolicy: RetryPolicy = RetryPolicy.Default) {
|
|
124
159
|
player.setup(PlayerSetupOptions(retryPolicy = retryPolicy))
|
|
125
160
|
player.setCallbacks(callbacks)
|
|
@@ -18,8 +18,10 @@ final class BrowserManager {
|
|
|
18
18
|
|
|
19
19
|
// Entries are unhydrated; `resolve` hydrates favorites on the way out.
|
|
20
20
|
private let contentCache = LRUCache<String, ResolvedTrack>(maxSize: 20)
|
|
21
|
-
// Moves on `
|
|
21
|
+
// Moves on `clearContent`, so a fetch that outlives one caches nothing; `pageGenerations` does
|
|
22
|
+
// the same for one path, and is cleared only together with a move of this.
|
|
22
23
|
private var contentGeneration = 0
|
|
24
|
+
private var pageGenerations: [String: Int] = [:]
|
|
23
25
|
|
|
24
26
|
// Raw results, never hydrated ones: `FavoriteSet.hydrate` skips a track whose `favorited` is
|
|
25
27
|
// already set, so a hydrated slot would keep the favorites of the first search.
|
|
@@ -145,10 +147,12 @@ final class BrowserManager {
|
|
|
145
147
|
return favorites.hydrate(cached)
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
let generation =
|
|
150
|
+
let generation = pageGeneration(normalizedPath)
|
|
149
151
|
let resolvedTrack = try await pages.resolve(normalizedPath)
|
|
150
152
|
|
|
151
|
-
if generation ==
|
|
153
|
+
if generation == pageGeneration(normalizedPath) {
|
|
154
|
+
contentCache.set(normalizedPath, value: resolvedTrack)
|
|
155
|
+
}
|
|
152
156
|
|
|
153
157
|
return favorites.hydrate(resolvedTrack)
|
|
154
158
|
}
|
|
@@ -160,18 +164,20 @@ final class BrowserManager {
|
|
|
160
164
|
"invalidateContentCache() expects a container path, not a contextual path: \(path)",
|
|
161
165
|
)
|
|
162
166
|
}
|
|
167
|
+
pageGenerations[path, default: 0] += 1
|
|
163
168
|
contentCache.remove(path)
|
|
164
169
|
}
|
|
165
170
|
|
|
171
|
+
private func pageGeneration(_ path: String) -> (Int, Int?) {
|
|
172
|
+
(contentGeneration, pageGenerations[path])
|
|
173
|
+
}
|
|
174
|
+
|
|
166
175
|
/// Clears every cache and the resolved request layers, then re-queries the tabs and reloads
|
|
167
176
|
/// the current path, independently: a failed reload goes to `reloadFailed` with its path, and
|
|
168
177
|
/// a failed tabs query keeps the current tabs.
|
|
169
178
|
func invalidateAll(reloadFailed: @escaping @MainActor (Error, String) async -> Void) {
|
|
170
|
-
|
|
171
|
-
contentGeneration &+= 1
|
|
179
|
+
clearContent()
|
|
172
180
|
requests.invalidateLayers()
|
|
173
|
-
lastSearchKey = nil
|
|
174
|
-
lastSearchResults = nil
|
|
175
181
|
Task { _ = try? await queryTabs() }
|
|
176
182
|
Task {
|
|
177
183
|
do {
|
|
@@ -182,6 +188,15 @@ final class BrowserManager {
|
|
|
182
188
|
}
|
|
183
189
|
}
|
|
184
190
|
|
|
191
|
+
/// Clears the cached pages and the last search; a fetch in flight caches nothing.
|
|
192
|
+
func clearContent() {
|
|
193
|
+
contentCache.clear()
|
|
194
|
+
contentGeneration &+= 1
|
|
195
|
+
pageGenerations.removeAll()
|
|
196
|
+
lastSearchKey = nil
|
|
197
|
+
lastSearchResults = nil
|
|
198
|
+
}
|
|
199
|
+
|
|
185
200
|
/// The app's `formatNavigationError` result, or the default when it has none or it fails.
|
|
186
201
|
func formatted(_ error: NavigationError, path: String) async -> FormattedNavigationError {
|
|
187
202
|
let fallback = error.defaultFormatted()
|
|
@@ -16,6 +16,8 @@ public extension HybridAudioBrowser {
|
|
|
16
16
|
self.audioSession.configure(options.ios)
|
|
17
17
|
|
|
18
18
|
// A re-setup replaces the player, so the outgoing one is torn down first. No-op on first setup.
|
|
19
|
+
let oldPlayer = player
|
|
20
|
+
oldPlayer?.sleepTimerManager.clear()
|
|
19
21
|
destroyPlayer()
|
|
20
22
|
|
|
21
23
|
let newEngine = AVPlayerEngine(
|
|
@@ -43,6 +45,18 @@ public extension HybridAudioBrowser {
|
|
|
43
45
|
if let mode = options.repeatMode { pendingRepeatMode = mode }
|
|
44
46
|
if let intent = options.playWhenReady { pendingPlayWhenReady = intent }
|
|
45
47
|
applyPendingPlayerState()
|
|
48
|
+
// The new player starts at its defaults without emitting them; listeners still hold the old values.
|
|
49
|
+
if let oldPlayer {
|
|
50
|
+
if oldPlayer.repeatMode != newPlayer.repeatMode {
|
|
51
|
+
playerDidChangeRepeatMode(RepeatModeChangedEvent(repeatMode: newPlayer.repeatMode))
|
|
52
|
+
}
|
|
53
|
+
if oldPlayer.shuffleEnabled != newPlayer.shuffleEnabled {
|
|
54
|
+
playerDidChangeShuffleEnabled(newPlayer.shuffleEnabled)
|
|
55
|
+
}
|
|
56
|
+
if oldPlayer.playWhenReady != newPlayer.playWhenReady {
|
|
57
|
+
playerDidChangePlayWhenReady(newPlayer.playWhenReady)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
46
60
|
// The stored options outlive the player, so a re-setup applies them to the new one.
|
|
47
61
|
applyOptions()
|
|
48
62
|
playerAndConfiguredBrowser.check()
|
|
@@ -121,7 +121,10 @@ public class HybridAudioBrowser: HybridAudioBrowserSpec, @unchecked Sendable {
|
|
|
121
121
|
// Copied on the setter's thread: the Task below outlives this call, and Nitro can reassign
|
|
122
122
|
// `configuration` (a C++ struct holding std::string/std::function) from the JS thread.
|
|
123
123
|
let configuredPath = configuration.path
|
|
124
|
-
onMainActor {
|
|
124
|
+
onMainActor {
|
|
125
|
+
browserManager.config = BrowserConfig(from: configuration)
|
|
126
|
+
browserManager.clearContent()
|
|
127
|
+
}
|
|
125
128
|
|
|
126
129
|
Task { @MainActor in
|
|
127
130
|
playerAndConfiguredBrowser.check()
|
package/lib/commonjs/CLAUDE.md
CHANGED
|
@@ -39,8 +39,8 @@ error until it was unified.
|
|
|
39
39
|
Two emitter classes, picked by what the event _is_:
|
|
40
40
|
|
|
41
41
|
- `NativeUpdatedValue` — state with a current value (playback, options,
|
|
42
|
-
progress). Subscribes to native at module load so no update is missed
|
|
43
|
-
|
|
42
|
+
progress). Subscribes to native at module load so no update is missed; hooks
|
|
43
|
+
read the matching getter, never a cached payload.
|
|
44
44
|
- `LazyNativeEmitter` — discrete events with no current value (remote controls,
|
|
45
45
|
gate hits). Assigns the native callback on the first `addListener`, so an
|
|
46
46
|
event nobody listens to costs nothing.
|
|
@@ -94,15 +94,12 @@ const onSleepTimerChanged = exports.onSleepTimerChanged = _NativeUpdatedValue.Na
|
|
|
94
94
|
* @returns true if any sleep timer is active, false otherwise
|
|
95
95
|
*/
|
|
96
96
|
function useSleepTimerActive() {
|
|
97
|
+
const eventCountAtRender = (0, _react.useRef)(onSleepTimerChanged.eventCount);
|
|
97
98
|
const [isActive, setIsActive] = (0, _react.useState)(() => getSleepTimer() !== null);
|
|
98
99
|
(0, _react.useEffect)(() => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const {
|
|
103
|
-
lastValue
|
|
104
|
-
} = onSleepTimerChanged;
|
|
105
|
-
if (lastValue !== undefined) setIsActive(lastValue !== null);
|
|
100
|
+
if (onSleepTimerChanged.eventCount !== eventCountAtRender.current) {
|
|
101
|
+
setIsActive(getSleepTimer() !== null);
|
|
102
|
+
}
|
|
106
103
|
return onSleepTimerChanged.addListener(timer => {
|
|
107
104
|
setIsActive(timer !== null);
|
|
108
105
|
});
|
|
@@ -123,17 +120,16 @@ function useSleepTimerActive() {
|
|
|
123
120
|
function useSleepTimer(params) {
|
|
124
121
|
const updateInterval = params?.updateInterval ?? 1000;
|
|
125
122
|
const inactive = params?.inactive ?? false;
|
|
123
|
+
const eventCountAtRender = (0, _react.useRef)(onSleepTimerChanged.eventCount);
|
|
126
124
|
const [state, setState] = (0, _react.useState)(() => {
|
|
127
125
|
const timerState = getSleepTimer();
|
|
128
126
|
return addSecondsLeft(timerState);
|
|
129
127
|
});
|
|
130
128
|
const time = state && 'time' in state ? state.time : undefined;
|
|
131
129
|
(0, _react.useEffect)(() => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} = onSleepTimerChanged;
|
|
136
|
-
if (lastValue !== undefined) setState(addSecondsLeft(lastValue));
|
|
130
|
+
if (onSleepTimerChanged.eventCount !== eventCountAtRender.current) {
|
|
131
|
+
setState(addSecondsLeft(getSleepTimer()));
|
|
132
|
+
}
|
|
137
133
|
return onSleepTimerChanged.addListener(event => {
|
|
138
134
|
setState(addSecondsLeft(event));
|
|
139
135
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_native","_NativeUpdatedValue","getSleepTimer","nativeBrowser","setSleepTimer","seconds","options","fadeDuration","setSleepTimerToEndOfTrack","clearSleepTimer","onSleepTimerChanged","exports","NativeUpdatedValue","emitterize","cb","useSleepTimerActive","isActive","setIsActive","useState","useEffect","
|
|
1
|
+
{"version":3,"names":["_react","require","_native","_NativeUpdatedValue","getSleepTimer","nativeBrowser","setSleepTimer","seconds","options","fadeDuration","setSleepTimerToEndOfTrack","clearSleepTimer","onSleepTimerChanged","exports","NativeUpdatedValue","emitterize","cb","useSleepTimerActive","eventCountAtRender","useRef","eventCount","isActive","setIsActive","useState","useEffect","current","addListener","timer","useSleepTimer","params","updateInterval","inactive","state","setState","timerState","addSecondsLeft","time","undefined","event","update","sleepTimer","result","secondsLeft","clear","initialTimeoutId","setTimeout","intervalId","setInterval","clearTimeout","clearInterval","Math","max","round","Date","now"],"sourceRoot":"../../../src","sources":["features/sleepTimer.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -9,9 +9,9 @@ exports.LazyNativeEmitter = void 0;
|
|
|
9
9
|
* `onRemoteSeek`, …) and `onGate`. Subscribe with {@link addListener}; the
|
|
10
10
|
* returned function unsubscribes. The emitter is not callable itself.
|
|
11
11
|
*
|
|
12
|
-
* Native starts delivering the event only once the first listener is added
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Native starts delivering the event only once the first listener is added.
|
|
13
|
+
* The other `on*` exports use `NativeUpdatedValue`, which listens from module
|
|
14
|
+
* load.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
@@ -9,14 +9,10 @@ exports.NativeUpdatedValue = void 0;
|
|
|
9
9
|
* `onQueueChanged`, `onTrackMetadata`, …). Subscribe with {@link addListener};
|
|
10
10
|
* the returned function unsubscribes. The emitter is not callable itself.
|
|
11
11
|
*
|
|
12
|
-
* It listens to native from module load
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `lastValue` is the last payload native sent, not a fresh reading: it is
|
|
17
|
-
* `undefined` before the first event, and for the queue and active track it
|
|
18
|
-
* can be stale after an in-place change (a favorite toggle). Use the getter
|
|
19
|
-
* (`getQueue`, `getActiveTrack`, …) when you need the current value.
|
|
12
|
+
* It listens to native from module load. The remote-control exports and
|
|
13
|
+
* `onGate` use `LazyNativeEmitter`, which listens only once a listener is
|
|
14
|
+
* added. It keeps no payload: use the getter (`getQueue`, `getActiveTrack`, …)
|
|
15
|
+
* for the current value.
|
|
20
16
|
*
|
|
21
17
|
* @example
|
|
22
18
|
* ```typescript
|
|
@@ -33,16 +29,17 @@ class NativeUpdatedValue {
|
|
|
33
29
|
listeners = new Set();
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
32
|
+
* Events received so far, so a hook can tell whether one landed between its
|
|
33
|
+
* render and its subscription.
|
|
34
|
+
* @internal
|
|
38
35
|
*/
|
|
39
|
-
|
|
36
|
+
eventCount = 0;
|
|
40
37
|
|
|
41
38
|
/** @internal */
|
|
42
39
|
constructor(setter) {
|
|
43
40
|
// Install native callback immediately at module load
|
|
44
41
|
setter(data => {
|
|
45
|
-
this.
|
|
42
|
+
this.eventCount++;
|
|
46
43
|
for (const listener of this.listeners) {
|
|
47
44
|
listener(data);
|
|
48
45
|
}
|
|
@@ -64,7 +61,7 @@ class NativeUpdatedValue {
|
|
|
64
61
|
* Creates a native value subscription.
|
|
65
62
|
*
|
|
66
63
|
* @param setter - Function that sets the native callback property
|
|
67
|
-
* @returns The subscription instance
|
|
64
|
+
* @returns The subscription instance
|
|
68
65
|
* @internal
|
|
69
66
|
*/
|
|
70
67
|
static emitterize(setter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeUpdatedValue","listeners","Set","
|
|
1
|
+
{"version":3,"names":["NativeUpdatedValue","listeners","Set","eventCount","constructor","setter","data","listener","addListener","callback","add","delete","emitterize","exports"],"sourceRoot":"../../../src","sources":["utils/NativeUpdatedValue.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,CAAI;EACzBC,SAAS,GAAG,IAAIC,GAAG,CAAc,CAAC;;EAE1C;AACF;AACA;AACA;AACA;EACEC,UAAU,GAAG,CAAC;;EAEd;EACAC,WAAWA,CAACC,MAA6C,EAAE;IACzD;IACAA,MAAM,CAAEC,IAAO,IAAK;MAClB,IAAI,CAACH,UAAU,EAAE;MACjB,KAAK,MAAMI,QAAQ,IAAI,IAAI,CAACN,SAAS,EAAE;QACrCM,QAAQ,CAACD,IAAI,CAAC;MAChB;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,WAAWA,CAACC,QAAqB,EAAc;IAC7C,IAAI,CAACR,SAAS,CAACS,GAAG,CAACD,QAAQ,CAAC;IAC5B,OAAO,MAAM,IAAI,CAACR,SAAS,CAACU,MAAM,CAACF,QAAQ,CAAC;EAC9C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAOG,UAAUA,CACfP,MAA6C,EACtB;IACvB,OAAO,IAAIL,kBAAkB,CAACK,MAAM,CAAC;EACvC;AACF;AAACQ,OAAA,CAAAb,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -8,36 +8,28 @@ var _react = require("react");
|
|
|
8
8
|
/**
|
|
9
9
|
* Generic hook for values that are fetched from native and updated via callbacks.
|
|
10
10
|
*
|
|
11
|
-
* Reads the
|
|
12
|
-
*
|
|
11
|
+
* Reads the getter on mount, and again on subscribing only if an event landed
|
|
12
|
+
* since, so a change between render and subscription is not missed.
|
|
13
13
|
*
|
|
14
|
-
* @param getter -
|
|
15
|
-
* @param emitter - NativeUpdatedValue that
|
|
14
|
+
* @param getter - Synchronous function returning the current value
|
|
15
|
+
* @param emitter - NativeUpdatedValue that provides the subscription
|
|
16
16
|
* @param eventKey - Optional key to extract from the event object passed to the callback
|
|
17
17
|
* @returns The current value, updated when the callback fires
|
|
18
18
|
*/
|
|
19
19
|
function useNativeUpdatedValue(getter, emitter, eventKey) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
lastValue
|
|
23
|
-
} = emitter;
|
|
24
|
-
if (lastValue != null) {
|
|
25
|
-
return eventKey !== undefined ? lastValue[eventKey] : lastValue;
|
|
26
|
-
}
|
|
27
|
-
return getter();
|
|
28
|
-
});
|
|
20
|
+
const eventCountAtRender = (0, _react.useRef)(emitter.eventCount);
|
|
21
|
+
const [value, setValue] = (0, _react.useState)(getter);
|
|
29
22
|
(0, _react.useEffect)(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (lastValue != null) {
|
|
34
|
-
const newValue = eventKey !== undefined ? lastValue[eventKey] : lastValue;
|
|
35
|
-
setValue(newValue);
|
|
36
|
-
}
|
|
23
|
+
if (emitter.eventCount !== eventCountAtRender.current) setValue(getter);
|
|
24
|
+
// A re-run, for another emitter or eventKey, always reads afresh.
|
|
25
|
+
eventCountAtRender.current = NaN;
|
|
37
26
|
return emitter.addListener(event => {
|
|
38
27
|
const newValue = eventKey !== undefined ? event[eventKey] : event;
|
|
39
28
|
setValue(newValue);
|
|
40
29
|
});
|
|
30
|
+
// The getter is read once per subscription: an inline one, new each render,
|
|
31
|
+
// would otherwise overwrite every event with a re-read.
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
33
|
}, [emitter, eventKey]);
|
|
42
34
|
return value;
|
|
43
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","useNativeUpdatedValue","getter","emitter","eventKey","
|
|
1
|
+
{"version":3,"names":["_react","require","useNativeUpdatedValue","getter","emitter","eventKey","eventCountAtRender","useRef","eventCount","value","setValue","useState","useEffect","current","NaN","addListener","event","newValue","undefined"],"sourceRoot":"../../../src","sources":["utils/useNativeUpdatedValue.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CACnCC,MAAe,EACfC,OAA8B,EAC9BC,QAAkB,EACf;EACH,MAAMC,kBAAkB,GAAG,IAAAC,aAAM,EAACH,OAAO,CAACI,UAAU,CAAC;EACrD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACR,MAAM,CAAC;EAE1C,IAAAS,gBAAS,EAAC,MAAM;IACd,IAAIR,OAAO,CAACI,UAAU,KAAKF,kBAAkB,CAACO,OAAO,EAAEH,QAAQ,CAACP,MAAM,CAAC;IACvE;IACAG,kBAAkB,CAACO,OAAO,GAAGC,GAAG;IAChC,OAAOV,OAAO,CAACW,WAAW,CAAEC,KAAK,IAAK;MACpC,MAAMC,QAAQ,GAAGZ,QAAQ,KAAKa,SAAS,GAAGF,KAAK,CAACX,QAAQ,CAAC,GAAGW,KAAK;MACjEN,QAAQ,CAACO,QAAa,CAAC;IACzB,CAAC,CAAC;IACF;IACA;IACA;EACF,CAAC,EAAE,CAACb,OAAO,EAAEC,QAAQ,CAAC,CAAC;EAEvB,OAAOI,KAAK;AACd","ignoreList":[]}
|
|
@@ -5,25 +5,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useNativeValueRefreshedBy = useNativeValueRefreshedBy;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
const eventCountOf = emitters => emitters.reduce((sum, emitter) => sum + emitter.eventCount, 0);
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Hook for a native-fetched value that must stay fresh across SEVERAL event
|
|
10
12
|
* sources — e.g. the active track, which changes on a queue transition
|
|
11
13
|
* (`onActiveTrackChanged`) but is also mutated in place by a favorite toggle
|
|
12
14
|
* (`onFavoriteChanged`).
|
|
13
15
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* once after the subscriptions attach (so an event firing between render and
|
|
17
|
-
* effect cannot be missed). The getters are cheap synchronous Nitro calls.
|
|
16
|
+
* Every trigger re-reads `getter()`, and the mount effect re-reads it only if
|
|
17
|
+
* an event landed since the render read, so none is missed.
|
|
18
18
|
*
|
|
19
19
|
* @param getter - Synchronous native getter for the current value
|
|
20
20
|
* @param emitters - Event sources that invalidate the value (a stable,
|
|
21
21
|
* module-level array — identity changes resubscribe)
|
|
22
22
|
*/
|
|
23
23
|
function useNativeValueRefreshedBy(getter, emitters) {
|
|
24
|
+
const eventCountAtRender = (0, _react.useRef)(eventCountOf(emitters));
|
|
24
25
|
const [value, setValue] = (0, _react.useState)(getter);
|
|
25
26
|
(0, _react.useEffect)(() => {
|
|
26
|
-
|
|
27
|
+
if (eventCountOf(emitters) !== eventCountAtRender.current) {
|
|
28
|
+
setValue(getter());
|
|
29
|
+
}
|
|
30
|
+
// A re-run, for another getter or emitters, always reads afresh.
|
|
31
|
+
eventCountAtRender.current = NaN;
|
|
27
32
|
const cleanups = emitters.map(emitter => emitter.addListener(() => setValue(getter())));
|
|
28
33
|
return () => cleanups.forEach(cleanup => cleanup());
|
|
29
34
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","useNativeValueRefreshedBy","getter","
|
|
1
|
+
{"version":3,"names":["_react","require","eventCountOf","emitters","reduce","sum","emitter","eventCount","useNativeValueRefreshedBy","getter","eventCountAtRender","useRef","value","setValue","useState","useEffect","current","NaN","cleanups","map","addListener","forEach","cleanup"],"sourceRoot":"../../../src","sources":["utils/useNativeValueRefreshedBy.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,MAAMC,YAAY,GAAIC,QAAiC,IACrDA,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,OAAO,KAAKD,GAAG,GAAGC,OAAO,CAACC,UAAU,EAAE,CAAC,CAAC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CACvCC,MAAe,EACfN,QAAiC,EAC9B;EACH,MAAMO,kBAAkB,GAAG,IAAAC,aAAM,EAACT,YAAY,CAACC,QAAQ,CAAC,CAAC;EACzD,MAAM,CAACS,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACL,MAAM,CAAC;EAE1C,IAAAM,gBAAS,EAAC,MAAM;IACd,IAAIb,YAAY,CAACC,QAAQ,CAAC,KAAKO,kBAAkB,CAACM,OAAO,EAAE;MACzDH,QAAQ,CAACJ,MAAM,CAAC,CAAC,CAAC;IACpB;IACA;IACAC,kBAAkB,CAACM,OAAO,GAAGC,GAAG;IAChC,MAAMC,QAAQ,GAAGf,QAAQ,CAACgB,GAAG,CAAEb,OAAO,IACpCA,OAAO,CAACc,WAAW,CAAC,MAAMP,QAAQ,CAACJ,MAAM,CAAC,CAAC,CAAC,CAC9C,CAAC;IACD,OAAO,MAAMS,QAAQ,CAACG,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAAC,CAAC,CAAC;IACrD;EACF,CAAC,EAAE,CAACb,MAAM,EAAE,GAAGN,QAAQ,CAAC,CAAC;EAEzB,OAAOS,KAAK;AACd","ignoreList":[]}
|
package/lib/module/CLAUDE.md
CHANGED
|
@@ -39,8 +39,8 @@ error until it was unified.
|
|
|
39
39
|
Two emitter classes, picked by what the event _is_:
|
|
40
40
|
|
|
41
41
|
- `NativeUpdatedValue` — state with a current value (playback, options,
|
|
42
|
-
progress). Subscribes to native at module load so no update is missed
|
|
43
|
-
|
|
42
|
+
progress). Subscribes to native at module load so no update is missed; hooks
|
|
43
|
+
read the matching getter, never a cached payload.
|
|
44
44
|
- `LazyNativeEmitter` — discrete events with no current value (remote controls,
|
|
45
45
|
gate hits). Assigns the native callback on the first `addListener`, so an
|
|
46
46
|
event nobody listens to costs nothing.
|