react-native-audio-browser 0.2.0-next.53 → 0.2.0-next.55

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 (599) hide show
  1. package/README.md +32 -19
  2. package/android/src/cast/java/com/audiobrowser/cast/CastSupport.kt +8 -10
  3. package/android/src/main/java/com/audiobrowser/AudioBrowser.kt +96 -243
  4. package/android/src/main/java/com/audiobrowser/AudioBrowserLifecycleModule.kt +8 -12
  5. package/android/src/main/java/com/audiobrowser/AudioBrowserPackage.kt +1 -3
  6. package/android/src/main/java/com/audiobrowser/Callbacks.kt +1 -10
  7. package/android/src/main/java/com/audiobrowser/ForegroundStart.kt +13 -18
  8. package/android/src/main/java/com/audiobrowser/HeadlessTaskService.kt +3 -7
  9. package/android/src/main/java/com/audiobrowser/RemoteOutputs.kt +8 -10
  10. package/android/src/main/java/com/audiobrowser/Service.kt +20 -61
  11. package/android/src/main/java/com/audiobrowser/ServiceBinding.kt +9 -17
  12. package/android/src/main/java/com/audiobrowser/browser/ArtworkResolutionRegistry.kt +10 -9
  13. package/android/src/main/java/com/audiobrowser/browser/BrowseArtworkRegistry.kt +11 -8
  14. package/android/src/main/java/com/audiobrowser/browser/BrowserManager.kt +117 -448
  15. package/android/src/main/java/com/audiobrowser/browser/BrowserUrlResolution.kt +21 -60
  16. package/android/src/main/java/com/audiobrowser/browser/InertStyleDiagnostic.kt +20 -80
  17. package/android/src/main/java/com/audiobrowser/browser/JsonArtwork.kt +6 -10
  18. package/android/src/main/java/com/audiobrowser/browser/JsonModels.kt +7 -24
  19. package/android/src/main/java/com/audiobrowser/browser/RouteMatch.kt +2 -4
  20. package/android/src/main/java/com/audiobrowser/browser/SectionScope.kt +13 -31
  21. package/android/src/main/java/com/audiobrowser/browser/SimpleRouter.kt +12 -40
  22. package/android/src/main/java/com/audiobrowser/browser/StyleResolver.kt +15 -26
  23. package/android/src/main/java/com/audiobrowser/browser/TrackLoadHandler.kt +5 -15
  24. package/android/src/main/java/com/audiobrowser/extension/EnumExtensions.kt +1 -0
  25. package/android/src/main/java/com/audiobrowser/extension/NumberExt.kt +2 -0
  26. package/android/src/main/java/com/audiobrowser/extension/ResolvedTrackExt.kt +4 -8
  27. package/android/src/main/java/com/audiobrowser/extension/TappedTrack.kt +4 -6
  28. package/android/src/main/java/com/audiobrowser/extension/TrackIdentity.kt +3 -7
  29. package/android/src/main/java/com/audiobrowser/http/HttpClient.kt +13 -22
  30. package/android/src/main/java/com/audiobrowser/http/RequestConfigBuilder.kt +17 -38
  31. package/android/src/main/java/com/audiobrowser/model/IcyTitle.kt +5 -6
  32. package/android/src/main/java/com/audiobrowser/model/PlaybackMetadata.kt +4 -9
  33. package/android/src/main/java/com/audiobrowser/model/PlayerSetupOptions.kt +18 -29
  34. package/android/src/main/java/com/audiobrowser/model/PlayerUpdateOptions.kt +6 -16
  35. package/android/src/main/java/com/audiobrowser/player/AutomaticBufferManager.kt +15 -45
  36. package/android/src/main/java/com/audiobrowser/player/CapabilityControls.kt +23 -59
  37. package/android/src/main/java/com/audiobrowser/player/CrossOriginHeaderStripper.kt +14 -26
  38. package/android/src/main/java/com/audiobrowser/player/DynamicLoadControl.kt +15 -43
  39. package/android/src/main/java/com/audiobrowser/player/EnginePlayback.kt +4 -4
  40. package/android/src/main/java/com/audiobrowser/player/EqualizerController.kt +15 -21
  41. package/android/src/main/java/com/audiobrowser/player/InterceptingPlayer.kt +14 -31
  42. package/android/src/main/java/com/audiobrowser/player/LocalEngine.kt +8 -8
  43. package/android/src/main/java/com/audiobrowser/player/MediaFactory.kt +16 -27
  44. package/android/src/main/java/com/audiobrowser/player/MediaSessionCallback.kt +119 -237
  45. package/android/src/main/java/com/audiobrowser/player/MediaSessionCommandManager.kt +48 -145
  46. package/android/src/main/java/com/audiobrowser/player/NowPlayingUpdater.kt +39 -100
  47. package/android/src/main/java/com/audiobrowser/player/PlaybackErrorClassifier.kt +16 -26
  48. package/android/src/main/java/com/audiobrowser/player/PlaybackStateMachine.kt +22 -28
  49. package/android/src/main/java/com/audiobrowser/player/PlaybackStateStore.kt +28 -64
  50. package/android/src/main/java/com/audiobrowser/player/PlaybackTimer.kt +8 -4
  51. package/android/src/main/java/com/audiobrowser/player/Player.kt +117 -405
  52. package/android/src/main/java/com/audiobrowser/player/PlayerCapabilitiesExt.kt +1 -1
  53. package/android/src/main/java/com/audiobrowser/player/PlayerEngineFactory.kt +11 -19
  54. package/android/src/main/java/com/audiobrowser/player/PlayerListener.kt +30 -96
  55. package/android/src/main/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicy.kt +39 -95
  56. package/android/src/main/java/com/audiobrowser/player/ShuffleOrderLedBy.kt +7 -13
  57. package/android/src/main/java/com/audiobrowser/player/SleepTimer.kt +13 -30
  58. package/android/src/main/java/com/audiobrowser/player/SleepTimerManager.kt +7 -11
  59. package/android/src/main/java/com/audiobrowser/player/StuckRecoveryPolicy.kt +9 -22
  60. package/android/src/main/java/com/audiobrowser/player/TransformingDataSource.kt +22 -54
  61. package/android/src/main/java/com/audiobrowser/player/VolumeFader.kt +8 -15
  62. package/android/src/main/java/com/audiobrowser/remote/RemoteItem.kt +9 -8
  63. package/android/src/main/java/com/audiobrowser/remote/RemoteOutputsController.kt +13 -10
  64. package/android/src/main/java/com/audiobrowser/remote/RemotePlayback.kt +8 -8
  65. package/android/src/main/java/com/audiobrowser/remote/RemoteQueue.kt +12 -5
  66. package/android/src/main/java/com/audiobrowser/remote/RemoteSwitchingPlayer.kt +28 -48
  67. package/android/src/main/java/com/audiobrowser/sonos/DeviceDescriptionParser.kt +11 -19
  68. package/android/src/main/java/com/audiobrowser/sonos/DidlLite.kt +2 -2
  69. package/android/src/main/java/com/audiobrowser/sonos/SoapClient.kt +6 -6
  70. package/android/src/main/java/com/audiobrowser/sonos/SoapEnvelopes.kt +8 -9
  71. package/android/src/main/java/com/audiobrowser/sonos/SoapResponseParser.kt +11 -18
  72. package/android/src/main/java/com/audiobrowser/sonos/SonosDiscoverer.kt +10 -10
  73. package/android/src/main/java/com/audiobrowser/sonos/SonosOutputs.kt +10 -10
  74. package/android/src/main/java/com/audiobrowser/sonos/SonosPlayer.kt +21 -33
  75. package/android/src/main/java/com/audiobrowser/sonos/SonosRemote.kt +4 -6
  76. package/android/src/main/java/com/audiobrowser/sonos/SonosRouteProviderService.kt +9 -10
  77. package/android/src/main/java/com/audiobrowser/sonos/SonosStreamUri.kt +7 -7
  78. package/android/src/main/java/com/audiobrowser/sonos/SonosTransport.kt +5 -4
  79. package/android/src/main/java/com/audiobrowser/sonos/SsdpDiscovery.kt +8 -3
  80. package/android/src/main/java/com/audiobrowser/sonos/SsdpMessages.kt +4 -6
  81. package/android/src/main/java/com/audiobrowser/sonos/ZoneGroupState.kt +13 -11
  82. package/android/src/main/java/com/audiobrowser/tls/AiaCertChaser.kt +34 -71
  83. package/android/src/main/java/com/audiobrowser/tls/AiaChasingExtendedTrustManager.kt +20 -37
  84. package/android/src/main/java/com/audiobrowser/tls/AiaChasingTrustManager.kt +18 -27
  85. package/android/src/main/java/com/audiobrowser/tls/AiaTls.kt +14 -29
  86. package/android/src/main/java/com/audiobrowser/tls/CachingCertificateFetcher.kt +68 -133
  87. package/android/src/main/java/com/audiobrowser/util/ArtworkContentProvider.kt +10 -22
  88. package/android/src/main/java/com/audiobrowser/util/ArtworkRoutes.kt +6 -6
  89. package/android/src/main/java/com/audiobrowser/util/ArtworkUris.kt +4 -3
  90. package/android/src/main/java/com/audiobrowser/util/ArtworkVariant.kt +2 -13
  91. package/android/src/main/java/com/audiobrowser/util/Automotive.kt +2 -4
  92. package/android/src/main/java/com/audiobrowser/util/BatteryOptimizationHelper.kt +3 -9
  93. package/android/src/main/java/com/audiobrowser/util/BatteryWarningStore.kt +4 -14
  94. package/android/src/main/java/com/audiobrowser/util/BrowserPathHelper.kt +21 -85
  95. package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoader.kt +7 -7
  96. package/android/src/main/java/com/audiobrowser/util/CoilArtworkLoaderHolder.kt +5 -8
  97. package/android/src/main/java/com/audiobrowser/util/CoilBitmapLoader.kt +8 -24
  98. package/android/src/main/java/com/audiobrowser/util/EqualizerManager.kt +7 -39
  99. package/android/src/main/java/com/audiobrowser/util/MediaExtrasBuilder.kt +10 -14
  100. package/android/src/main/java/com/audiobrowser/util/MetadataAdapter.kt +5 -9
  101. package/android/src/main/java/com/audiobrowser/util/NetworkConnectivityMonitor.kt +5 -9
  102. package/android/src/main/java/com/audiobrowser/util/OutputMonitor.kt +21 -50
  103. package/android/src/main/java/com/audiobrowser/util/OutputSwitcher.kt +7 -20
  104. package/android/src/main/java/com/audiobrowser/util/PlayingStateFactory.kt +3 -5
  105. package/android/src/main/java/com/audiobrowser/util/RatingFavorites.kt +4 -5
  106. package/android/src/main/java/com/audiobrowser/util/StyleWire.kt +5 -5
  107. package/android/src/main/java/com/audiobrowser/util/SvgArtworkRenderer.kt +5 -9
  108. package/android/src/main/java/com/audiobrowser/util/SystemVolumeMonitor.kt +6 -9
  109. package/android/src/main/java/com/audiobrowser/util/TrackFactory.kt +25 -47
  110. package/android/src/nocast/java/com/audiobrowser/cast/CastSupport.kt +0 -2
  111. package/android/src/test/java/com/audiobrowser/ForegroundStartTest.kt +1 -2
  112. package/android/src/test/java/com/audiobrowser/LegacyRatingTest.kt +3 -3
  113. package/android/src/test/java/com/audiobrowser/ServiceBindingTest.kt +0 -13
  114. package/android/src/test/java/com/audiobrowser/ServiceTaskRemovedTest.kt +2 -3
  115. package/android/src/test/java/com/audiobrowser/TestFixtures.kt +5 -14
  116. package/android/src/test/java/com/audiobrowser/browser/BrowseArtworkRegistryTest.kt +1 -1
  117. package/android/src/test/java/com/audiobrowser/browser/BrowserManagerBuildApiRequestTest.kt +2 -8
  118. package/android/src/test/java/com/audiobrowser/browser/BrowserManagerFavoritesTest.kt +2 -12
  119. package/android/src/test/java/com/audiobrowser/browser/BrowserManagerLayerResolutionTest.kt +5 -28
  120. package/android/src/test/java/com/audiobrowser/browser/BrowserManagerTest.kt +11 -43
  121. package/android/src/test/java/com/audiobrowser/browser/BrowserUrlResolutionTest.kt +4 -13
  122. package/android/src/test/java/com/audiobrowser/browser/InertStyleDiagnosticTest.kt +2 -11
  123. package/android/src/test/java/com/audiobrowser/browser/JsonArtworkTest.kt +0 -2
  124. package/android/src/test/java/com/audiobrowser/browser/JsonStyleTest.kt +3 -8
  125. package/android/src/test/java/com/audiobrowser/browser/SectionScopeTest.kt +2 -14
  126. package/android/src/test/java/com/audiobrowser/browser/SimpleRouterTest.kt +1 -5
  127. package/android/src/test/java/com/audiobrowser/browser/StyleResolverTest.kt +2 -13
  128. package/android/src/test/java/com/audiobrowser/extension/TappedTrackTest.kt +1 -7
  129. package/android/src/test/java/com/audiobrowser/extension/TrackIdentityTest.kt +0 -5
  130. package/android/src/test/java/com/audiobrowser/http/RequestConfigBuilderTest.kt +8 -16
  131. package/android/src/test/java/com/audiobrowser/model/IcyTitleTest.kt +1 -1
  132. package/android/src/test/java/com/audiobrowser/player/BrowseTilesTest.kt +12 -29
  133. package/android/src/test/java/com/audiobrowser/player/CapabilityControlsTest.kt +3 -12
  134. package/android/src/test/java/com/audiobrowser/player/CrossOriginHeaderStripperTest.kt +0 -7
  135. package/android/src/test/java/com/audiobrowser/player/DynamicLoadControlTest.kt +0 -1
  136. package/android/src/test/java/com/audiobrowser/player/EqualizerControllerTest.kt +0 -9
  137. package/android/src/test/java/com/audiobrowser/player/LiveSeekCommandTest.kt +1 -2
  138. package/android/src/test/java/com/audiobrowser/player/MediaSessionSlotMappingTest.kt +0 -9
  139. package/android/src/test/java/com/audiobrowser/player/NowPlayingUpdaterTest.kt +15 -22
  140. package/android/src/test/java/com/audiobrowser/player/PlaybackErrorClassifierTest.kt +1 -24
  141. package/android/src/test/java/com/audiobrowser/player/PlaybackStateMachineTest.kt +0 -20
  142. package/android/src/test/java/com/audiobrowser/player/PlaybackStateStoreTrackJsonTest.kt +1 -6
  143. package/android/src/test/java/com/audiobrowser/player/PlaybackTimerTest.kt +2 -4
  144. package/android/src/test/java/com/audiobrowser/player/PlayerCastTest.kt +2 -2
  145. package/android/src/test/java/com/audiobrowser/player/PlayerEngineFactoryTest.kt +0 -3
  146. package/android/src/test/java/com/audiobrowser/player/PlayerInvalidTrackTest.kt +0 -1
  147. package/android/src/test/java/com/audiobrowser/player/PlayerSetupTest.kt +3 -2
  148. package/android/src/test/java/com/audiobrowser/player/PlayerSonosTest.kt +5 -1
  149. package/android/src/test/java/com/audiobrowser/player/PlayerSuppressionTest.kt +5 -7
  150. package/android/src/test/java/com/audiobrowser/player/RetryLoadErrorHandlingPolicyTest.kt +4 -35
  151. package/android/src/test/java/com/audiobrowser/player/SessionErrorMaskTest.kt +0 -5
  152. package/android/src/test/java/com/audiobrowser/player/ShuffleOrderLedByTest.kt +1 -8
  153. package/android/src/test/java/com/audiobrowser/player/StandardSkipTest.kt +4 -6
  154. package/android/src/test/java/com/audiobrowser/player/StuckRecoveryPolicyTest.kt +11 -11
  155. package/android/src/test/java/com/audiobrowser/player/TransformingDataSourceTest.kt +2 -23
  156. package/android/src/test/java/com/audiobrowser/remote/FakeRemote.kt +9 -10
  157. package/android/src/test/java/com/audiobrowser/remote/RemoteSwitchingPlayerTest.kt +0 -1
  158. package/android/src/test/java/com/audiobrowser/sonos/DeviceDescriptionParserTest.kt +1 -3
  159. package/android/src/test/java/com/audiobrowser/sonos/DidlLiteTest.kt +0 -1
  160. package/android/src/test/java/com/audiobrowser/sonos/SoapClientTest.kt +0 -3
  161. package/android/src/test/java/com/audiobrowser/sonos/SoapEnvelopesTest.kt +0 -1
  162. package/android/src/test/java/com/audiobrowser/sonos/SoapResponseParserTest.kt +0 -1
  163. package/android/src/test/java/com/audiobrowser/sonos/SonosDiscovererTest.kt +2 -0
  164. package/android/src/test/java/com/audiobrowser/sonos/SonosPlayerTest.kt +0 -1
  165. package/android/src/test/java/com/audiobrowser/sonos/SonosRemoteTest.kt +1 -1
  166. package/android/src/test/java/com/audiobrowser/sonos/SonosRoutesTest.kt +2 -0
  167. package/android/src/test/java/com/audiobrowser/sonos/SonosTransportTest.kt +2 -6
  168. package/android/src/test/java/com/audiobrowser/sonos/SsdpMessagesTest.kt +0 -2
  169. package/android/src/test/java/com/audiobrowser/tls/AiaCertChaserTest.kt +13 -37
  170. package/android/src/test/java/com/audiobrowser/tls/AiaChasingTrustManagerTest.kt +10 -24
  171. package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherCallSiteTest.kt +15 -39
  172. package/android/src/test/java/com/audiobrowser/tls/CachingCertificateFetcherTest.kt +4 -10
  173. package/android/src/test/java/com/audiobrowser/util/ArtworkContentProviderTest.kt +2 -11
  174. package/android/src/test/java/com/audiobrowser/util/ArtworkUrisTest.kt +0 -1
  175. package/android/src/test/java/com/audiobrowser/util/BrowserPathHelperTest.kt +0 -4
  176. package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderHolderTest.kt +1 -1
  177. package/android/src/test/java/com/audiobrowser/util/CoilArtworkLoaderTest.kt +0 -5
  178. package/android/src/test/java/com/audiobrowser/util/FakeImageLoader.kt +2 -2
  179. package/android/src/test/java/com/audiobrowser/util/MediaExtrasBuilderTest.kt +4 -12
  180. package/android/src/test/java/com/audiobrowser/util/OutputMonitorTest.kt +1 -1
  181. package/android/src/test/java/com/audiobrowser/util/PlayingStateFactoryTest.kt +0 -4
  182. package/android/src/test/java/com/audiobrowser/util/TrackFactoryBrowseTest.kt +1 -1
  183. package/android/src/test/java/com/audiobrowser/util/TrackFactoryMediaIdTest.kt +4 -6
  184. package/android/src/testCast/java/com/audiobrowser/cast/CastEndsTest.kt +1 -1
  185. package/android/src/testCast/java/com/audiobrowser/cast/SendingMediaItemConverterTest.kt +1 -0
  186. package/ios/AVPlayerEngine.swift +13 -21
  187. package/ios/AVPlayerEngineCallbacks.swift +2 -4
  188. package/ios/Browser/BrowseGate.swift +7 -8
  189. package/ios/Browser/BrowserConfig.swift +19 -34
  190. package/ios/Browser/BrowserError.swift +0 -1
  191. package/ios/Browser/BrowserManager.swift +29 -75
  192. package/ios/Browser/BrowserPathHelper.swift +13 -93
  193. package/ios/Browser/FavoriteSet.swift +7 -10
  194. package/ios/Browser/InertStyleDiagnostic.swift +17 -82
  195. package/ios/Browser/JsonModels.swift +11 -51
  196. package/ios/Browser/NavigationErrorState.swift +3 -2
  197. package/ios/Browser/PageResolver.swift +13 -23
  198. package/ios/Browser/RequestLayer.swift +16 -20
  199. package/ios/Browser/RequestPipeline.swift +33 -43
  200. package/ios/Browser/SearchDrillIn.swift +7 -13
  201. package/ios/Browser/SectionScope.swift +14 -26
  202. package/ios/Browser/SimpleRouter.swift +8 -15
  203. package/ios/Browser/StyleResolver.swift +12 -29
  204. package/ios/Browser/TabBarEntries.swift +6 -11
  205. package/ios/Browser/TrackIdTemplate.swift +6 -14
  206. package/ios/CarPlay/CPInterfaceController+Safe.swift +19 -28
  207. package/ios/CarPlay/CarPlayArtworkResolver.swift +5 -9
  208. package/ios/CarPlay/CarPlayController.swift +4 -4
  209. package/ios/CarPlay/CarPlayImageLoader.swift +11 -26
  210. package/ios/CarPlay/CarPlayListItemFactory.swift +30 -80
  211. package/ios/CarPlay/CarPlayNowPlayingManager.swift +19 -54
  212. package/ios/CarPlay/CarPlaySession+Navigator.swift +10 -10
  213. package/ios/CarPlay/CarPlaySession+PageLoader.swift +6 -5
  214. package/ios/CarPlay/CarPlaySession+Refresher.swift +2 -2
  215. package/ios/CarPlay/CarPlaySession+TabBar.swift +19 -26
  216. package/ios/CarPlay/CarPlaySession.swift +13 -17
  217. package/ios/CarPlay/CarPlayTemplates.swift +6 -7
  218. package/ios/CarPlay/IntentHandlers.swift +3 -5
  219. package/ios/CarPlay/MediaIntentCriteria.swift +15 -29
  220. package/ios/CarPlay/MediaIntentHandler.swift +4 -7
  221. package/ios/CarPlay/MediaIntentPlayback.swift +9 -8
  222. package/ios/CarPlay/NowPlayingButtonRules.swift +3 -4
  223. package/ios/CarPlay/SectionPresentation.swift +18 -28
  224. package/ios/CarPlay/TopTemplateReplacer.swift +8 -9
  225. package/ios/Extension/Capability+RemoteCommand.swift +3 -3
  226. package/ios/Extension/ChapterMetadata+AVFoundation.swift +2 -5
  227. package/ios/Extension/CxxVectorConformances.swift +4 -16
  228. package/ios/Extension/NavigationError+Conversion.swift +4 -7
  229. package/ios/Extension/PlayerCapabilities+Favorite.swift +0 -1
  230. package/ios/Extension/RequestConfig+Copying.swift +2 -6
  231. package/ios/Extension/ResolvedTrack+Copying.swift +2 -8
  232. package/ios/Extension/SearchParams+Query.swift +4 -4
  233. package/ios/Extension/Section+Copying.swift +3 -6
  234. package/ios/Extension/String+IcyCharset.swift +5 -5
  235. package/ios/Extension/TimedMetadata+AVFoundation.swift +6 -12
  236. package/ios/Extension/Track+AVPlayer.swift +1 -2
  237. package/ios/Extension/Track+Copying.swift +2 -8
  238. package/ios/Extension/Track+Identity.swift +4 -9
  239. package/ios/Extension/TrackMetadata+AVFoundation.swift +10 -13
  240. package/ios/Extension/UIApplication+ActiveScene.swift +6 -14
  241. package/ios/Extension/Variant+Artwork.swift +8 -22
  242. package/ios/Http/HttpClient.swift +3 -3
  243. package/ios/HybridAudioBrowser+Browser.swift +10 -16
  244. package/ios/HybridAudioBrowser+Options.swift +6 -9
  245. package/ios/HybridAudioBrowser+Player.swift +8 -16
  246. package/ios/HybridAudioBrowser+PlayerCallbacks.swift +4 -5
  247. package/ios/HybridAudioBrowser+Stubs.swift +5 -7
  248. package/ios/HybridAudioBrowser.swift +54 -79
  249. package/ios/Model/NitroTypeStubs.swift +15 -22
  250. package/ios/Model/PlayerUpdateOptions.swift +6 -21
  251. package/ios/Model/RemoteCommand.swift +2 -2
  252. package/ios/Model/TrackPlayerError.swift +9 -22
  253. package/ios/NowPlayingInfo/NowPlayingInfoController.swift +21 -40
  254. package/ios/NowPlayingInfo/SilentAudioPrimer.swift +10 -16
  255. package/ios/Observer/ItemObserver.swift +7 -5
  256. package/ios/Observer/PlayerObserver.swift +5 -5
  257. package/ios/PlaybackEvent.swift +2 -2
  258. package/ios/Player/AirPlayStallJudgement.swift +7 -9
  259. package/ios/Player/AudioSessionController.swift +14 -15
  260. package/ios/Player/DeferredSeek.swift +2 -2
  261. package/ios/Player/EndOfTrackJudgement.swift +6 -13
  262. package/ios/Player/ErrorStatus.swift +8 -7
  263. package/ios/Player/MediaLoader.swift +20 -24
  264. package/ios/Player/NowPlayingLines.swift +1 -4
  265. package/ios/Player/NowPlayingUpdater.swift +35 -61
  266. package/ios/Player/PersistedPlaybackState.swift +1 -2
  267. package/ios/Player/PlaybackFailure.swift +20 -24
  268. package/ios/Player/PlaybackPersistence.swift +5 -6
  269. package/ios/Player/PlaybackStateMachine.swift +8 -11
  270. package/ios/Player/PlaybackTimer.swift +8 -11
  271. package/ios/Player/Player.swift +6 -13
  272. package/ios/Player/PlayerEngine.swift +20 -20
  273. package/ios/Player/PlayerStatusTypes.swift +1 -2
  274. package/ios/Player/QueueManager.swift +23 -67
  275. package/ios/Player/RetryLoop.swift +39 -50
  276. package/ios/Player/ShuffleOrder.swift +17 -57
  277. package/ios/Player/SleepTimerManager.swift +13 -28
  278. package/ios/Player/VolumeFader.swift +16 -16
  279. package/ios/RemoteCommand/RemoteCommandCallbacks.swift +6 -16
  280. package/ios/RemoteCommand/RemoteCommandController.swift +8 -10
  281. package/ios/Tests/AirPlayStallJudgementTests.swift +4 -4
  282. package/ios/Tests/BrowserPathHelperTests.swift +3 -6
  283. package/ios/Tests/DeferredSeekTests.swift +1 -3
  284. package/ios/Tests/EmitterTests.swift +0 -1
  285. package/ios/Tests/EndOfTrackJudgementTests.swift +1 -6
  286. package/ios/Tests/FavoriteSetTests.swift +1 -0
  287. package/ios/Tests/GenerationMemoTests.swift +2 -2
  288. package/ios/Tests/InertStyleDiagnosticTests.swift +4 -10
  289. package/ios/Tests/JsonModelsTests.swift +5 -12
  290. package/ios/Tests/LRUCacheTests.swift +1 -5
  291. package/ios/Tests/MediaIntentCriteriaTests.swift +2 -7
  292. package/ios/Tests/MediaLoaderTests.swift +3 -12
  293. package/ios/Tests/ObserverTests.swift +3 -3
  294. package/ios/Tests/PlaybackErrorTests.swift +7 -9
  295. package/ios/Tests/PlaybackFailureTests.swift +9 -17
  296. package/ios/Tests/PlaybackPersistenceTests.swift +1 -0
  297. package/ios/Tests/PlaybackStateMachineTests.swift +1 -16
  298. package/ios/Tests/PlaybackTimerTests.swift +2 -3
  299. package/ios/Tests/PlayerPolicyTests.swift +10 -26
  300. package/ios/Tests/PlayerTests.swift +53 -88
  301. package/ios/Tests/PlayingStateTests.swift +0 -1
  302. package/ios/Tests/QueueManagerTests.swift +30 -80
  303. package/ios/Tests/RemoteCommandControllerTests.swift +5 -13
  304. package/ios/Tests/ResolvedTrackCopyingTests.swift +0 -2
  305. package/ios/Tests/RetryLoopTests.swift +12 -35
  306. package/ios/Tests/SearchDrillInTests.swift +4 -5
  307. package/ios/Tests/SectionPresentationTests.swift +3 -16
  308. package/ios/Tests/SectionScopeTests.swift +3 -6
  309. package/ios/Tests/SimpleRouterTests.swift +1 -5
  310. package/ios/Tests/SleepTimerManagerTests.swift +8 -11
  311. package/ios/Tests/StyleResolverTests.swift +4 -13
  312. package/ios/Tests/Support/ManualSleepTimerScheduler.swift +3 -8
  313. package/ios/Tests/Support/TestTypes.swift +5 -15
  314. package/ios/Tests/TabBarEntriesTests.swift +0 -2
  315. package/ios/Tests/TimedMetadataAVFoundationTests.swift +2 -3
  316. package/ios/Tests/TopTemplateReplacerTests.swift +1 -1
  317. package/ios/Tests/TrackIdTemplateTests.swift +2 -6
  318. package/ios/Tests/TrackMetadataAVFoundationTests.swift +1 -4
  319. package/ios/Tests/TrackSelectorTests.swift +3 -15
  320. package/ios/TrackSelector.swift +13 -25
  321. package/ios/Util/ArtworkFreshness.swift +6 -6
  322. package/ios/Util/ArtworkImageFetcher.swift +19 -20
  323. package/ios/Util/ConcurrentMap.swift +2 -2
  324. package/ios/Util/Emitter.swift +8 -13
  325. package/ios/Util/NetworkMonitor.swift +4 -6
  326. package/ios/Util/OutputPicker.swift +1 -1
  327. package/ios/Util/ReadyValue.swift +3 -2
  328. package/ios/Util/SFSymbolRenderer.swift +17 -30
  329. package/ios/Util/SVGProcessor.swift +5 -9
  330. package/lib/commonjs/CLAUDE.md +7 -2
  331. package/lib/commonjs/features/battery.js +16 -12
  332. package/lib/commonjs/features/battery.js.map +1 -1
  333. package/lib/commonjs/features/browser-config.js +1 -1
  334. package/lib/commonjs/features/browser.js +74 -24
  335. package/lib/commonjs/features/browser.js.map +1 -1
  336. package/lib/commonjs/features/carConnection.js +3 -4
  337. package/lib/commonjs/features/carConnection.js.map +1 -1
  338. package/lib/commonjs/features/equalizer.js +9 -5
  339. package/lib/commonjs/features/equalizer.js.map +1 -1
  340. package/lib/commonjs/features/errors.js +35 -21
  341. package/lib/commonjs/features/errors.js.map +1 -1
  342. package/lib/commonjs/features/favorites.js +15 -13
  343. package/lib/commonjs/features/favorites.js.map +1 -1
  344. package/lib/commonjs/features/gate.js +12 -6
  345. package/lib/commonjs/features/gate.js.map +1 -1
  346. package/lib/commonjs/features/metadata.js +16 -14
  347. package/lib/commonjs/features/metadata.js.map +1 -1
  348. package/lib/commonjs/features/network.js +5 -1
  349. package/lib/commonjs/features/network.js.map +1 -1
  350. package/lib/commonjs/features/nowPlaying.js +28 -14
  351. package/lib/commonjs/features/nowPlaying.js.map +1 -1
  352. package/lib/commonjs/features/output.js +8 -4
  353. package/lib/commonjs/features/output.js.map +1 -1
  354. package/lib/commonjs/features/playback/controls.js +10 -5
  355. package/lib/commonjs/features/playback/controls.js.map +1 -1
  356. package/lib/commonjs/features/playback/playWhenReady.js +6 -5
  357. package/lib/commonjs/features/playback/playWhenReady.js.map +1 -1
  358. package/lib/commonjs/features/playback/playing.js +5 -3
  359. package/lib/commonjs/features/playback/playing.js.map +1 -1
  360. package/lib/commonjs/features/playback/progress.js +11 -5
  361. package/lib/commonjs/features/playback/progress.js.map +1 -1
  362. package/lib/commonjs/features/playback/state.js +3 -3
  363. package/lib/commonjs/features/playback/state.js.map +1 -1
  364. package/lib/commonjs/features/playback/trackPlaybackTime.js +6 -1
  365. package/lib/commonjs/features/playback/trackPlaybackTime.js.map +1 -1
  366. package/lib/commonjs/features/playback/volume.js +6 -5
  367. package/lib/commonjs/features/playback/volume.js.map +1 -1
  368. package/lib/commonjs/features/player/options.js +20 -10
  369. package/lib/commonjs/features/player/options.js.map +1 -1
  370. package/lib/commonjs/features/player/setup.js +34 -38
  371. package/lib/commonjs/features/player/setup.js.map +1 -1
  372. package/lib/commonjs/features/queue/activeTrack.js +0 -1
  373. package/lib/commonjs/features/queue/activeTrack.js.map +1 -1
  374. package/lib/commonjs/features/queue/queue.js +48 -20
  375. package/lib/commonjs/features/queue/queue.js.map +1 -1
  376. package/lib/commonjs/features/queue/repeatMode.js +2 -1
  377. package/lib/commonjs/features/queue/repeatMode.js.map +1 -1
  378. package/lib/commonjs/features/queue/shuffle.js +0 -1
  379. package/lib/commonjs/features/queue/shuffle.js.map +1 -1
  380. package/lib/commonjs/features/remoteControls.js +59 -35
  381. package/lib/commonjs/features/remoteControls.js.map +1 -1
  382. package/lib/commonjs/features/sleepTimer.js +15 -6
  383. package/lib/commonjs/features/sleepTimer.js.map +1 -1
  384. package/lib/commonjs/utils/LazyNativeEmitter.js +6 -9
  385. package/lib/commonjs/utils/LazyNativeEmitter.js.map +1 -1
  386. package/lib/commonjs/utils/NativeUpdatedValue.js +13 -12
  387. package/lib/commonjs/utils/NativeUpdatedValue.js.map +1 -1
  388. package/lib/commonjs/utils/getTrackIdentity.js +6 -4
  389. package/lib/commonjs/utils/getTrackIdentity.js.map +1 -1
  390. package/lib/commonjs/utils/useDebug.js +16 -3
  391. package/lib/commonjs/utils/useDebug.js.map +1 -1
  392. package/lib/commonjs/web/NativeAudioBrowser.js +2 -4
  393. package/lib/commonjs/web/NativeAudioBrowser.js.map +1 -1
  394. package/lib/commonjs/web/browser/parseSearchResponse.js +3 -4
  395. package/lib/commonjs/web/browser/parseSearchResponse.js.map +1 -1
  396. package/lib/commonjs/web/browser/sections.js +1 -1
  397. package/lib/commonjs/web/util/BrowserPathHelper.js +1 -3
  398. package/lib/commonjs/web/util/BrowserPathHelper.js.map +1 -1
  399. package/lib/module/CLAUDE.md +7 -2
  400. package/lib/module/features/battery.js +16 -12
  401. package/lib/module/features/battery.js.map +1 -1
  402. package/lib/module/features/browser-config.js +1 -1
  403. package/lib/module/features/browser.js +74 -24
  404. package/lib/module/features/browser.js.map +1 -1
  405. package/lib/module/features/carConnection.js +3 -4
  406. package/lib/module/features/carConnection.js.map +1 -1
  407. package/lib/module/features/equalizer.js +9 -5
  408. package/lib/module/features/equalizer.js.map +1 -1
  409. package/lib/module/features/errors.js +35 -21
  410. package/lib/module/features/errors.js.map +1 -1
  411. package/lib/module/features/favorites.js +15 -13
  412. package/lib/module/features/favorites.js.map +1 -1
  413. package/lib/module/features/gate.js +12 -6
  414. package/lib/module/features/gate.js.map +1 -1
  415. package/lib/module/features/metadata.js +16 -14
  416. package/lib/module/features/metadata.js.map +1 -1
  417. package/lib/module/features/network.js +5 -1
  418. package/lib/module/features/network.js.map +1 -1
  419. package/lib/module/features/nowPlaying.js +28 -14
  420. package/lib/module/features/nowPlaying.js.map +1 -1
  421. package/lib/module/features/output.js +8 -4
  422. package/lib/module/features/output.js.map +1 -1
  423. package/lib/module/features/playback/controls.js +10 -5
  424. package/lib/module/features/playback/controls.js.map +1 -1
  425. package/lib/module/features/playback/playWhenReady.js +6 -5
  426. package/lib/module/features/playback/playWhenReady.js.map +1 -1
  427. package/lib/module/features/playback/playing.js +5 -3
  428. package/lib/module/features/playback/playing.js.map +1 -1
  429. package/lib/module/features/playback/progress.js +11 -5
  430. package/lib/module/features/playback/progress.js.map +1 -1
  431. package/lib/module/features/playback/state.js +3 -3
  432. package/lib/module/features/playback/state.js.map +1 -1
  433. package/lib/module/features/playback/trackPlaybackTime.js +6 -1
  434. package/lib/module/features/playback/trackPlaybackTime.js.map +1 -1
  435. package/lib/module/features/playback/volume.js +6 -5
  436. package/lib/module/features/playback/volume.js.map +1 -1
  437. package/lib/module/features/player/options.js +20 -10
  438. package/lib/module/features/player/options.js.map +1 -1
  439. package/lib/module/features/player/setup.js +34 -38
  440. package/lib/module/features/player/setup.js.map +1 -1
  441. package/lib/module/features/queue/activeTrack.js +0 -1
  442. package/lib/module/features/queue/activeTrack.js.map +1 -1
  443. package/lib/module/features/queue/queue.js +48 -20
  444. package/lib/module/features/queue/queue.js.map +1 -1
  445. package/lib/module/features/queue/repeatMode.js +2 -1
  446. package/lib/module/features/queue/repeatMode.js.map +1 -1
  447. package/lib/module/features/queue/shuffle.js +0 -1
  448. package/lib/module/features/queue/shuffle.js.map +1 -1
  449. package/lib/module/features/remoteControls.js +59 -35
  450. package/lib/module/features/remoteControls.js.map +1 -1
  451. package/lib/module/features/sleepTimer.js +15 -6
  452. package/lib/module/features/sleepTimer.js.map +1 -1
  453. package/lib/module/utils/LazyNativeEmitter.js +6 -9
  454. package/lib/module/utils/LazyNativeEmitter.js.map +1 -1
  455. package/lib/module/utils/NativeUpdatedValue.js +13 -12
  456. package/lib/module/utils/NativeUpdatedValue.js.map +1 -1
  457. package/lib/module/utils/getTrackIdentity.js +6 -4
  458. package/lib/module/utils/getTrackIdentity.js.map +1 -1
  459. package/lib/module/utils/useDebug.js +16 -3
  460. package/lib/module/utils/useDebug.js.map +1 -1
  461. package/lib/module/web/NativeAudioBrowser.js +2 -4
  462. package/lib/module/web/NativeAudioBrowser.js.map +1 -1
  463. package/lib/module/web/browser/parseSearchResponse.js +3 -4
  464. package/lib/module/web/browser/parseSearchResponse.js.map +1 -1
  465. package/lib/module/web/browser/sections.js +1 -1
  466. package/lib/module/web/util/BrowserPathHelper.js +1 -3
  467. package/lib/module/web/util/BrowserPathHelper.js.map +1 -1
  468. package/lib/typescript/src/features/battery.d.ts +17 -12
  469. package/lib/typescript/src/features/battery.d.ts.map +1 -1
  470. package/lib/typescript/src/features/browser.d.ts +64 -24
  471. package/lib/typescript/src/features/browser.d.ts.map +1 -1
  472. package/lib/typescript/src/features/carConnection.d.ts +3 -4
  473. package/lib/typescript/src/features/carConnection.d.ts.map +1 -1
  474. package/lib/typescript/src/features/equalizer.d.ts +9 -5
  475. package/lib/typescript/src/features/equalizer.d.ts.map +1 -1
  476. package/lib/typescript/src/features/errors.d.ts +37 -22
  477. package/lib/typescript/src/features/errors.d.ts.map +1 -1
  478. package/lib/typescript/src/features/favorites.d.ts +15 -13
  479. package/lib/typescript/src/features/favorites.d.ts.map +1 -1
  480. package/lib/typescript/src/features/gate.d.ts +14 -8
  481. package/lib/typescript/src/features/gate.d.ts.map +1 -1
  482. package/lib/typescript/src/features/metadata.d.ts +37 -17
  483. package/lib/typescript/src/features/metadata.d.ts.map +1 -1
  484. package/lib/typescript/src/features/network.d.ts +5 -1
  485. package/lib/typescript/src/features/network.d.ts.map +1 -1
  486. package/lib/typescript/src/features/nowPlaying.d.ts +28 -14
  487. package/lib/typescript/src/features/nowPlaying.d.ts.map +1 -1
  488. package/lib/typescript/src/features/output.d.ts +8 -4
  489. package/lib/typescript/src/features/output.d.ts.map +1 -1
  490. package/lib/typescript/src/features/playback/controls.d.ts +10 -5
  491. package/lib/typescript/src/features/playback/controls.d.ts.map +1 -1
  492. package/lib/typescript/src/features/playback/playWhenReady.d.ts +6 -5
  493. package/lib/typescript/src/features/playback/playWhenReady.d.ts.map +1 -1
  494. package/lib/typescript/src/features/playback/playing.d.ts +16 -3
  495. package/lib/typescript/src/features/playback/playing.d.ts.map +1 -1
  496. package/lib/typescript/src/features/playback/progress.d.ts +11 -5
  497. package/lib/typescript/src/features/playback/progress.d.ts.map +1 -1
  498. package/lib/typescript/src/features/playback/state.d.ts +8 -3
  499. package/lib/typescript/src/features/playback/state.d.ts.map +1 -1
  500. package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts +9 -2
  501. package/lib/typescript/src/features/playback/trackPlaybackTime.d.ts.map +1 -1
  502. package/lib/typescript/src/features/playback/volume.d.ts +6 -5
  503. package/lib/typescript/src/features/playback/volume.d.ts.map +1 -1
  504. package/lib/typescript/src/features/player/options.d.ts +52 -37
  505. package/lib/typescript/src/features/player/options.d.ts.map +1 -1
  506. package/lib/typescript/src/features/player/setup.d.ts +65 -60
  507. package/lib/typescript/src/features/player/setup.d.ts.map +1 -1
  508. package/lib/typescript/src/features/queue/activeTrack.d.ts +0 -1
  509. package/lib/typescript/src/features/queue/activeTrack.d.ts.map +1 -1
  510. package/lib/typescript/src/features/queue/queue.d.ts +48 -20
  511. package/lib/typescript/src/features/queue/queue.d.ts.map +1 -1
  512. package/lib/typescript/src/features/queue/repeatMode.d.ts +1 -1
  513. package/lib/typescript/src/features/queue/repeatMode.d.ts.map +1 -1
  514. package/lib/typescript/src/features/queue/shuffle.d.ts +0 -1
  515. package/lib/typescript/src/features/queue/shuffle.d.ts.map +1 -1
  516. package/lib/typescript/src/features/remoteControls.d.ts +58 -25
  517. package/lib/typescript/src/features/remoteControls.d.ts.map +1 -1
  518. package/lib/typescript/src/features/sleepTimer.d.ts +15 -7
  519. package/lib/typescript/src/features/sleepTimer.d.ts.map +1 -1
  520. package/lib/typescript/src/types/browser-nodes.d.ts +54 -57
  521. package/lib/typescript/src/types/browser-nodes.d.ts.map +1 -1
  522. package/lib/typescript/src/types/browser.d.ts +181 -144
  523. package/lib/typescript/src/types/browser.d.ts.map +1 -1
  524. package/lib/typescript/src/utils/LazyNativeEmitter.d.ts +6 -9
  525. package/lib/typescript/src/utils/LazyNativeEmitter.d.ts.map +1 -1
  526. package/lib/typescript/src/utils/NativeUpdatedValue.d.ts +13 -12
  527. package/lib/typescript/src/utils/NativeUpdatedValue.d.ts.map +1 -1
  528. package/lib/typescript/src/utils/getTrackIdentity.d.ts +6 -4
  529. package/lib/typescript/src/utils/getTrackIdentity.d.ts.map +1 -1
  530. package/lib/typescript/src/utils/useDebug.d.ts +16 -3
  531. package/lib/typescript/src/utils/useDebug.d.ts.map +1 -1
  532. package/package.json +1 -1
  533. package/src/CLAUDE.md +7 -2
  534. package/src/docs-floors.test.ts +71 -0
  535. package/src/features/battery.ts +17 -13
  536. package/src/features/browser-config.ts +1 -1
  537. package/src/features/browser.ts +65 -24
  538. package/src/features/carConnection.ts +3 -4
  539. package/src/features/equalizer.ts +9 -5
  540. package/src/features/errors.ts +37 -22
  541. package/src/features/favorites.ts +15 -13
  542. package/src/features/gate.ts +14 -8
  543. package/src/features/metadata.ts +37 -17
  544. package/src/features/network.ts +5 -1
  545. package/src/features/nowPlaying.ts +28 -14
  546. package/src/features/output.ts +8 -4
  547. package/src/features/playback/controls.ts +10 -5
  548. package/src/features/playback/playWhenReady.ts +6 -5
  549. package/src/features/playback/playing.ts +16 -3
  550. package/src/features/playback/progress.ts +11 -5
  551. package/src/features/playback/state.ts +8 -3
  552. package/src/features/playback/trackPlaybackTime.ts +9 -2
  553. package/src/features/playback/volume.ts +6 -5
  554. package/src/features/player/options.ts +54 -43
  555. package/src/features/player/setup.ts +67 -61
  556. package/src/features/queue/activeTrack.ts +0 -1
  557. package/src/features/queue/queue.ts +48 -20
  558. package/src/features/queue/repeatMode.ts +1 -1
  559. package/src/features/queue/shuffle.ts +0 -1
  560. package/src/features/remoteControls.ts +59 -35
  561. package/src/features/sleepTimer.ts +15 -7
  562. package/src/types/browser-nodes.ts +54 -57
  563. package/src/types/browser.ts +183 -146
  564. package/src/utils/LazyNativeEmitter.ts +6 -9
  565. package/src/utils/NativeUpdatedValue.ts +13 -12
  566. package/src/utils/getTrackIdentity.ts +6 -4
  567. package/src/utils/useDebug.ts +16 -3
  568. package/src/web/NativeAudioBrowser.ts +2 -4
  569. package/src/web/browser/parseSearchResponse.ts +3 -4
  570. package/src/web/browser/sections.ts +1 -1
  571. package/src/web/util/BrowserPathHelper.ts +1 -3
  572. package/website/guide/android-auto.md +25 -13
  573. package/website/guide/android-certificates.md +199 -120
  574. package/website/guide/artwork.md +93 -48
  575. package/website/guide/audio-output.md +86 -68
  576. package/website/guide/automotive.md +15 -10
  577. package/website/guide/basic-usage.md +5 -2
  578. package/website/guide/battery.md +50 -23
  579. package/website/guide/browser.md +155 -68
  580. package/website/guide/carplay.md +132 -49
  581. package/website/guide/configuration.md +85 -49
  582. package/website/guide/equalizer.md +36 -32
  583. package/website/guide/errors.md +106 -64
  584. package/website/guide/favorites.md +41 -31
  585. package/website/guide/gate.md +24 -10
  586. package/website/guide/getting-started.md +55 -2
  587. package/website/guide/hooks.md +53 -47
  588. package/website/guide/live-streams.md +80 -49
  589. package/website/guide/metadata.md +87 -53
  590. package/website/guide/migrating-from-track-player.md +94 -49
  591. package/website/guide/native-callback-fetch.md +46 -36
  592. package/website/guide/network.md +36 -20
  593. package/website/guide/now-playing.md +72 -44
  594. package/website/guide/playback.md +112 -35
  595. package/website/guide/queue.md +77 -43
  596. package/website/guide/remote-controls.md +87 -29
  597. package/website/guide/search.md +37 -22
  598. package/website/guide/sleep-timer.md +35 -14
  599. package/website/guide/track.md +59 -35
@@ -8,17 +8,15 @@ import os.log
8
8
  final class RequestPipeline {
9
9
  let logger = Logger(subsystem: "com.audiobrowser", category: "RequestPipeline")
10
10
  private let httpClient = HttpClient()
11
- /// The request/browse thunks resolve once per content generation.
12
11
  private let layers = GenerationMemo<ResolvedLayers>()
13
12
 
14
- /// Set by `BrowserManager`; a new config resolves the layers again.
15
13
  var config = BrowserConfig() {
16
14
  didSet { layers.invalidate() }
17
15
  }
18
16
 
19
17
  nonisolated init() {}
20
18
 
21
- /// Resolves the request and browse layers again on next use (e.g. after a locale change).
19
+ /// Resolves the request and browse layers again on next use, as after a locale change.
22
20
  func invalidateLayers() {
23
21
  layers.invalidate()
24
22
  }
@@ -28,25 +26,25 @@ final class RequestPipeline {
28
26
  let browse: TransformableRequestConfig?
29
27
  }
30
28
 
31
- /// The request and browse layers of the current config: each resolver's result, or the
32
- /// static layer when it has none. The resolvers run one after the other, request first, as on
33
- /// Android and web, and a config change or `invalidateAll` while they run resolves them
34
- /// again.
29
+ /// The request and browse layers: each resolver's result, else the static layer. A
30
+ /// successful run is kept until the next invalidation, and a failed one runs again on next
31
+ /// use. The resolvers run one after the other, request first, as on Android and web; an
32
+ /// invalidation while they run resolves them again.
35
33
  func resolvedLayers() async throws -> ResolvedLayers {
36
34
  try await layers.value { [weak self] in
37
35
  guard let self else { throw CancellationError() }
38
- // Read on every run: a retry after a config change must resolve the new config's layers.
36
+ // Read on every run: a retry after a config change must resolve the new config.
39
37
  let config = self.config
40
- // The resolver is Promise-only (the TS layer wraps a sync-or-async thunk in
41
- // Promise.resolve), so its result is the JS promise behind the bridge promise.
38
+ // Double await: the TS side wraps a sync-or-async thunk in a JS promise, behind the
39
+ // bridge's promise.
42
40
  let request = try await config.requestResolver?().await().await() ?? config.request
43
41
  let browse = try await config.browseResolver?().await().await() ?? config.browse
44
42
  return ResolvedLayers(request: request, browse: browse)
45
43
  }
46
44
  }
47
45
 
48
- /// Applies one Request-Config Layer (request / browse / media / route) onto `base`: its
49
- /// transforms (async, then sync) when it has any, else its static fields (`RequestLayer.apply`).
46
+ /// `layer` onto `base`: its transforms (async, then sync) when it has any, else its static
47
+ /// fields (`RequestLayer.apply`).
50
48
  func applyLayer(
51
49
  _ layer: (some TransformableLayer)?,
52
50
  to base: RequestConfig,
@@ -63,14 +61,11 @@ final class RequestPipeline {
63
61
  return try await RequestLayer.apply(RequestConfig(fieldsOf: layer), transforms: transforms, to: base)
64
62
  }
65
63
 
66
- /// Builds the HTTP request for an API-backed route by layering
67
- /// request → kind → route configs. `initialQuery` seeds request-level query
68
- /// params (e.g. search q/mode/…) onto the base before the route layer, so they
69
- /// survive into `request.query` even when a layer's transform "wins
70
- /// completely" (it is handed only the base, so the route config's own static
71
- /// query would otherwise be dropped). `routeConfig` is nil for the implicit
72
- /// browse default; `kind` names the per-kind layer, nil for kinds with none. The request and
73
- /// kind layers come from one resolution; `routeConfig` from the caller's config.
64
+ /// The HTTP request for an API-backed route: the request layer, then the `kind` layer (nil
65
+ /// for kinds with none), then `routeConfig` (nil for the implicit browse default).
66
+ /// `initialQuery` goes onto the request after the request layer, so it reaches the URL even
67
+ /// when a later layer's transforms replace that layer's static query. Throws
68
+ /// `invalidConfiguration` when no layer sets a base URL.
74
69
  func buildApiRequest(
75
70
  kind: KeyPath<ResolvedLayers, TransformableRequestConfig?>?,
76
71
  _ routeConfig: TransformableRequestConfig?,
@@ -100,8 +95,6 @@ final class RequestPipeline {
100
95
  )
101
96
  }
102
97
 
103
- /// Fetches a page object (`{title,path,children:[…]}`) through the request → browse → route
104
- /// layers.
105
98
  func fetchPage(
106
99
  _ routeConfig: TransformableRequestConfig?,
107
100
  path: String,
@@ -126,9 +119,9 @@ final class RequestPipeline {
126
119
  return nitroResult
127
120
  }
128
121
 
129
- /// Fetches a search route's bare Track array through the request → search route layers. The
130
- /// search params go through `initialQuery`, so they reach the URL even when a transform wins;
131
- /// the config's static path seeds the base, since a layer's static path never applies.
122
+ /// A search route's tracks, through the request layer and `searchConfig`. The search params
123
+ /// go in as `initialQuery`; the config's path seeds the base, since a layer's static path
124
+ /// never applies.
132
125
  func fetchSearch(_ searchConfig: TransformableRequestConfig, params: SearchParams) async throws -> [Track] {
133
126
  let request = try await buildApiRequest(
134
127
  kind: nil, searchConfig, path: searchConfig.path ?? "", params: ["q": params.query],
@@ -141,9 +134,10 @@ final class RequestPipeline {
141
134
 
142
135
  // MARK: - Media URL Resolution
143
136
 
144
- /// The media request for `originalUrl`: the shared `request` layer, then the `media` layer,
145
- /// then `media.resolve(track)` merged over them. `track` only feeds `resolve`; its own
146
- /// `request` is not merged here. A failing layer leaves the URL as it is.
137
+ /// The media request for `originalUrl`: the request layer, the media layer, then what
138
+ /// `media.resolve(track)` produces over them. `track` only feeds `resolve`; its own `request`
139
+ /// is not merged here. A failing layer
140
+ /// leaves the URL as it is, with no headers.
147
141
  func resolveMediaUrl(_ originalUrl: String, track: Track? = nil) async -> MediaResolvedUrl {
148
142
  let base: RequestConfig
149
143
  do {
@@ -173,14 +167,13 @@ final class RequestPipeline {
173
167
  }
174
168
  }
175
169
 
176
- /// The config the `media.resolve` / `resolveSync(track)` callbacks produce, nil when neither is
177
- /// configured or there is no track.
170
+ /// What the `media` config's `resolve` and `resolveSync` produce for `track`; nil without a
171
+ /// track or a media config.
178
172
  func resolveMediaTrackConfig(_ track: Track?) async throws -> RequestConfig? {
179
173
  guard let track, let media = config.media else { return nil }
180
174
  return try await resolved(media.resolve, media.resolveSync, for: track)
181
175
  }
182
176
 
183
- /// What a `resolve` (async) and `resolveSync` produce for `track`, the sync one winning.
184
177
  private func resolved(
185
178
  _ resolve: ((Track) -> Promise<Promise<RequestConfig>>)?,
186
179
  _ resolveSync: ((Track) -> Promise<RequestConfig>)?,
@@ -195,8 +188,8 @@ final class RequestPipeline {
195
188
 
196
189
  // MARK: - Artwork URL Resolution
197
190
 
198
- /// The image source for `track`'s artwork: an SF Symbol rendered to a file, the artwork URL
199
- /// as is without an artwork config, else the shared `request` layer and the artwork config in
191
+ /// The image source for `track`'s artwork: an SF Symbol rendered to a file; the artwork URL
192
+ /// as is when no artwork config applies; else the request layer and the artwork config, in
200
193
  /// `RequestLayer.artwork`'s order. `perRouteConfig` replaces the global artwork config;
201
194
  /// `imageContext` is the display size, nil at browse time. Nil when there is no artwork or a
202
195
  /// callback fails.
@@ -242,7 +235,7 @@ final class RequestPipeline {
242
235
  ) else { return nil }
243
236
 
244
237
  let uri = RequestLayer.buildUrl(request)
245
- // An unfilled `{id}` stays in the URL, so the request fails visibly.
238
+ // The unfilled `{id}` stays in the URL, so the request fails visibly.
246
239
  if RequestLayer.hasUnfilledIdToken(request) {
247
240
  logger.warning("nowPlayingArtwork: track has no id — '{id}' left unfilled in \(uri)")
248
241
  }
@@ -261,17 +254,14 @@ final class RequestPipeline {
261
254
 
262
255
  // MARK: - Config Utilities
263
256
 
264
- /// Awaits an **async** config callback and copies the result out of the Nitro
265
- /// bridge. The callback lowers to `Promise<Promise<RequestConfig>>` (bridge hop →
266
- /// JS promise), so it is a DOUBLE await. This await depth is the bug-prone part
267
- /// (single-awaiting an async callback hands a `Promise` downstream — the original
268
- /// "empty config" bug), so it lives in exactly one place. Pairs with `awaitSyncConfig`.
257
+ /// Awaits an async config callback, which crosses the bridge as `Promise<Promise<…>>` (the
258
+ /// bridge hop, then the JS promise): a single await hands a `Promise` downstream. Copies the
259
+ /// result out.
269
260
  func awaitAsyncConfig(_ promise: Promise<Promise<RequestConfig>>) async throws -> RequestConfig {
270
261
  try await extractConfig(promise.await().await())
271
262
  }
272
263
 
273
- /// Awaits a **sync** config callback (lowers to `Promise<RequestConfig>` — a single
274
- /// bridge await) and copies the result out. Pairs with `awaitAsyncConfig`.
264
+ /// Awaits a sync config callback (one bridge await) and copies the result out.
275
265
  func awaitSyncConfig(_ promise: Promise<RequestConfig>) async throws -> RequestConfig {
276
266
  try await extractConfig(promise.await())
277
267
  }
@@ -295,8 +285,8 @@ extension TransformableRequestConfig: TransformableLayer {}
295
285
  extension MediaRequestConfig: TransformableLayer {}
296
286
 
297
287
  extension RequestPipeline: MediaResolving {
298
- /// Runs the `nowPlayingArtwork` config for every playing track, id or not: an id-less track
299
- /// leaves an `{id}` token unfilled, so the request visibly fails rather than being skipped.
288
+ /// Runs for every playing track, id or not: an id-less track leaves `{id}` unfilled, so the
289
+ /// request fails visibly rather than being skipped.
300
290
  func resolveNowPlayingArtwork(track: Track, imageContext: ImageContext?) async -> ImageSource? {
301
291
  await resolveArtworkUrl(track: track, perRouteConfig: config.nowPlayingArtwork, imageContext: imageContext)
302
292
  }
@@ -1,23 +1,18 @@
1
1
  import Foundation
2
2
 
3
- /// A search result that may or may not be directly playable. `src` is the
4
- /// playable stream; `path` is a browsable container path. Abstracting these two
5
- /// fields keeps the drill-in decision free of the Nitro `Track` type so it can
6
- /// be unit-tested.
3
+ /// A search result: `src` plays it, `path` browses it. Keeps the drill-in free of the Nitro
4
+ /// `Track` so it can be unit-tested.
7
5
  protocol PlayableSearchItem {
8
6
  var src: String? { get }
9
7
  var path: String? { get }
10
8
  }
11
9
 
12
10
  enum SearchDrillIn {
13
- /// Picks the playable items for a "play «X»" voice search.
11
+ /// The items a "play «X»" voice search plays, or nil when none is playable.
14
12
  ///
15
- /// If the first result is browsable-only (a `path` container with no `src` — a
16
- /// place/genre page), drills into it via `resolveChildren` and uses its
17
- /// playable children, so we play the first station *inside* the page rather
18
- /// than skipping the page for a later inline station. Falls back to the flat
19
- /// playable results when the first result is already playable or the drill-in
20
- /// yields nothing. Returns nil when nothing is playable.
13
+ /// Only the first result is drilled into: when it is browsable but not playable, its playable
14
+ /// children win over later playable results, so the first station inside a place or genre page
15
+ /// plays. Falls back to the playable results when the drill-in yields none.
21
16
  static func playable<Item: PlayableSearchItem>(
22
17
  from children: [Item],
23
18
  resolveChildren: sending (String) async throws -> [Item],
@@ -37,8 +32,7 @@ enum SearchDrillIn {
37
32
  }
38
33
  }
39
34
 
40
- // The real Nitro `Track` already carries `src`/`path`; conform it for the app
41
- // build. (The testable target builds without NitroModules and uses a stub item.)
35
+ // The test target builds without NitroModules and uses its own item.
42
36
  #if canImport(NitroModules)
43
37
  extension Track: PlayableSearchItem {}
44
38
  #endif
@@ -1,27 +1,18 @@
1
- // Queue scope is the tapped section, not the whole page (ADR 0006): the
2
- // playback context a listener expects is the list they tapped in — a page
3
- // aggregating several sections must not leak next/previous across them.
4
- // Sections are structural (ADR 0010), so scoping is a lookup, not a
5
- // groupTitle-run derivation.
1
+ // Queue scope is the tapped section, not the whole page: ADR 0006.
6
2
  enum SectionScope {
7
- /// The section containing the tapped identity, plus the tapped child's
8
- /// offset within it — non-nil only when the stamped flat index pinned the
9
- /// exact copy.
3
+ /// `tappedOffset` is the tapped child's offset in `section`, non-nil only when the stamped
4
+ /// index pinned that exact copy.
10
5
  struct Scoped {
11
6
  let section: Section
12
7
  let tappedOffset: Int?
13
8
  }
14
9
 
15
- /// The section of `sections` containing the playable `trackId` (a track
16
- /// identity: id when non-blank, else src), or nil when not found.
10
+ /// The section containing the track identity `trackId`, or nil when none does.
17
11
  ///
18
- /// `tappedIndex` — the flat page position stamped into the contextual URL
19
- /// (children concatenated in section order) — is a tie-breaker, never an
20
- /// identifier: when the child at that position still carries the tapped
21
- /// identity, it pins which section (and which copy) was tapped; when it
22
- /// doesn't (the list shifted), resolution falls back to the first section
23
- /// containing the identity. A stale index can therefore never select a
24
- /// different track — at worst a different copy of the same one.
12
+ /// `tappedIndex` is the flat page position (children concatenated in section order) and only
13
+ /// breaks ties: when the child there still has `trackId`, it pins the section and copy; otherwise
14
+ /// the first section containing `trackId` wins. A stale index can at worst pick another copy of
15
+ /// the same track, never a different track.
25
16
  static func scoped(
26
17
  in sections: [Section],
27
18
  containing trackId: String,
@@ -48,10 +39,10 @@ enum SectionScope {
48
39
  return nil
49
40
  }
50
41
 
51
- /// The queue a tap on the contextual `path` plays: the playable tracks of the tapped section,
52
- /// at the tapped copy when the stamped index still pins it, else at the first identity match;
53
- /// only that track when `singleTrack`. Nil when the identity is gone from the page or the
54
- /// tapped track is not playable, so the caller falls back to the stored track.
42
+ /// The queue a tap on the contextual `path` plays: the tapped section's playable tracks, at the
43
+ /// pinned copy, else the first identity match; only that track when `singleTrack`. Nil when the
44
+ /// identity is gone from the page or the tapped track is not playable, so the caller falls back
45
+ /// to the stored track.
55
46
  static func queue(
56
47
  in sections: [Section],
57
48
  path: String,
@@ -77,17 +68,14 @@ enum SectionScope {
77
68
  // MARK: - Page shape helpers (ADR 0010)
78
69
 
79
70
  extension ResolvedTrack {
80
- /// The canonical sectioned shape: `sections` wins when present; plain
81
- /// `children` is authoring sugar for one untitled section.
71
+ /// `sections` when present, else plain `children` as one untitled section.
82
72
  var normalizedSections: [Section]? {
83
73
  if let sections { return sections }
84
74
  guard let children else { return nil }
85
75
  return [.untitled(children)]
86
76
  }
87
77
 
88
- /// The page's children concatenated in section order — the flattening
89
- /// that defines contextual `__index` positions and the flat views (tabs,
90
- /// search) of a sectioned page.
78
+ /// Children concatenated in section order: the order contextual `__index` positions count in.
91
79
  var flattenedChildren: [Track]? {
92
80
  normalizedSections.map { $0.flatMap(\.children) }
93
81
  }
@@ -1,27 +1,19 @@
1
1
  import Foundation
2
2
 
3
- /// Result of a successful route match.
4
3
  struct RouteMatch {
5
- /// Extracted parameters from the path (e.g., {id} → "123")
6
- /// For tail wildcards, the remaining path is stored in params["tail"]
4
+ /// `{name}` segments by name; a tail wildcard's remaining path under `tail`, absent when nothing remains.
7
5
  let params: [String: String]
8
6
 
9
- /// Specificity score (higher = more specific match)
10
7
  let specificity: Int
11
8
  }
12
9
 
13
- /// Protocol for route entries that can be matched.
14
10
  protocol RouteEntry {
15
11
  var path: String { get }
16
12
  }
17
13
 
18
- /// Route pattern matching with parameter extraction.
19
- ///
20
- /// Supports patterns like:
21
- /// - /artists - exact match
22
- /// - /artists/{id} - parameter extraction
23
- /// - /artists/* - wildcard match (matches any single segment)
24
- /// - /files/** - tail wildcard (matches remaining path segments, captured as `tail`)
14
+ /// Route pattern matching: `/artists` exact, `/artists/{id}` a parameter, `/artists/*` any one
15
+ /// segment, `/files/**` the remaining segments (zero or more), captured as `tail` when there is
16
+ /// at least one.
25
17
  ///
26
18
  /// The most specific route wins, the first on a tie: constant segments over parameters over
27
19
  /// wildcards over the tail wildcard, then more segments.
@@ -31,8 +23,8 @@ enum SimpleRouter {
31
23
  static let tabsRoutePath = "__tabs__"
32
24
  static let searchRoutePath = "__search__"
33
25
 
34
- /// The route that browses `path`: the best match among the routes that are not tabs, search or
35
- /// the default, else the default route with `path` as its `path` param.
26
+ /// The best match among the routes that are not tabs, search or the default, else the default
27
+ /// route with `path` as its `path` param.
36
28
  static func browseRoute<T: RouteEntry>(for path: String, in routes: [T]) -> (route: T, match: RouteMatch)? {
37
29
  let browseRoutes = routes.filter {
38
30
  $0.path != tabsRoutePath && $0.path != searchRoutePath && $0.path != defaultRoutePath
@@ -44,7 +36,7 @@ enum SimpleRouter {
44
36
  return (defaultRoute, RouteMatch(params: ["path": path], specificity: 0))
45
37
  }
46
38
 
47
- /// The most specific of `routes` matching `path`, or nil when none does.
39
+ /// The most specific of `routes` matching `path`, the first on a tie; nil when none matches.
48
40
  static func findBestMatch<T: RouteEntry>(path: String, routes: [T]) -> (route: T, match: RouteMatch)? {
49
41
  var best: (route: T, match: RouteMatch)?
50
42
  for route in routes {
@@ -71,6 +63,7 @@ enum SimpleRouter {
71
63
  }
72
64
  }
73
65
 
66
+ // 10x apart, so one stronger segment outweighs up to nine weaker ones.
74
67
  var specificity: Int {
75
68
  switch self {
76
69
  case .constant: 1000
@@ -2,30 +2,13 @@
2
2
  import NitroModules
3
3
  #endif
4
4
 
5
- /// The one place style declarations resolve to effective values (ADR 0011).
6
- ///
7
- /// Two mechanisms, deliberately distinct:
8
- /// - **Inherited item properties** resolve `track ?? section ?? page`,
9
- /// per property — a track's own declaration wins over the blocks that
10
- /// contain it.
11
- /// - **Container properties and the positional `display`** resolve by scope
12
- /// override: `section ?? page` — the page declares for its whole scope, a
13
- /// section overrides for its own children. `display` is never inherited
14
- /// item-to-container: each holder describes its own children, and a
15
- /// track's `display` is the promise for the page *it* opens, not its
16
- /// rendering inside this section.
17
- ///
18
- /// Every key of `SectionStyle` must be read by `sectionStyle(section:page:)`
19
- /// and every inherited key of `TrackStyle` by `trackStyle(track:section:)` —
20
- /// Nitro flattens the spec's `extends`, so `src/style-resolution.test.ts`
21
- /// enforces this completeness, not the type system.
5
+ /// Resolves style declarations to effective values (ADR 0011). Nitro flattens the spec's
6
+ /// `extends`, so nothing in the types makes these merges read a new style key:
7
+ /// `src/style-resolution.test.ts` does.
22
8
  enum StyleResolver {
23
- /// Folds the page block into a section's block: every `SectionStyle` key
24
- /// resolves `section ?? page`. The result is the section's effective
25
- /// block; item resolution then only needs `track ?? section`.
9
+ /// A section's effective block: each key is the section's own value, else the page's,
10
+ /// `display` included.
26
11
  static func sectionStyle(section: SectionStyle?, page: SectionStyle?) -> SectionStyle {
27
- // Argument order is the generated init's (own properties before inherited
28
- // ones — Nitro flattens `extends` own-props-first); the stub mirrors it.
29
12
  SectionStyle(
30
13
  gridWrap: section?.gridWrap ?? page?.gridWrap,
31
14
  gridTile: section?.gridTile ?? page?.gridTile,
@@ -38,18 +21,18 @@ enum StyleResolver {
38
21
  )
39
22
  }
40
23
 
41
- /// Resolves a track's effective item properties against its (page-folded)
42
- /// section block.
24
+ /// A track's effective item properties: each key is the track's own value, else its
25
+ /// section's. Pass the section block `sectionStyle` returned, so the page's values reach
26
+ /// the track. `display` is always nil.
43
27
  static func trackStyle(track: TrackStyle?, section: SectionStyle?) -> TrackStyle {
44
28
  TrackStyle(
45
- // Positional deny-list: `display` is never inherited onto an item —
46
- // resolved nil, so no renderer can mistake the handle's page promise
47
- // for this item's own layout.
29
+ // A track's `display` describes the page it opens, not its own layout here, so it is
30
+ // never inherited onto an item.
48
31
  display: nil,
49
32
  artworkRendering: track?.artworkRendering ?? section?.artworkRendering,
50
33
  imageShape: track?.imageShape ?? section?.imageShape,
51
- // `'none'` resolves like any value — it is the renderer that treats it
52
- // as "no accessory, derived behavior" (the inheritance escape).
34
+ // `'none'` stays a value here; the renderer reads it as no accessory. As nil it would
35
+ // inherit the section's symbol.
53
36
  accessorySymbol: track?.accessorySymbol ?? section?.accessorySymbol,
54
37
  cardTint: track?.cardTint ?? section?.cardTint,
55
38
  cardImage: track?.cardImage ?? section?.cardImage,
@@ -1,20 +1,15 @@
1
- /// Compares the tab-list fields the CarPlay tab bar actually renders.
2
1
  enum TabBarEntries {
3
- /// Whether two tab lists produce identical tab-bar entries — title, path,
4
- /// the artwork inputs of `applyTabBarEntry`, and `disabled`. Used to suppress
5
- /// `tabsChanged` when a tabs re-query (e.g. from `invalidateAllContent()`)
6
- /// resolves to the same entries, so an unchanged result never churns the
7
- /// tab bar or resets its selection.
8
- ///
9
- /// `disabled` counts even though it renders nothing itself: a disabled tab is
10
- /// filtered out of the tab bar entirely (`showTabBar`), so a tab flipping it
11
- /// with otherwise-identical fields changes which tabs exist. Omitting it here
12
- /// swallowed the emit, and the tab never appeared or disappeared.
2
+ /// Whether two tab lists produce the same CarPlay tab-bar entries, so a re-query that
3
+ /// changes nothing the bar shows emits no `tabsChanged` and keeps the selection. Compares
4
+ /// title, path, artwork, the artwork source's uri and `disabled`; not the style, artwork
5
+ /// headers or other track fields that `applyTabBarEntry`'s artwork load (and its resolve
6
+ /// transform) can read.
13
7
  static func same(_ old: [Track]?, _ new: [Track]) -> Bool {
14
8
  guard let old, old.count == new.count else { return false }
15
9
  return zip(old, new).allSatisfy {
16
10
  $0.title == $1.title && $0.path == $1.path && $0.artwork == $1.artwork
17
11
  && $0.artworkSource?.uri == $1.artworkSource?.uri
12
+ // `showTabBar` drops disabled tabs, so flipping `disabled` changes which tabs exist.
18
13
  && $0.disabled == $1.disabled
19
14
  }
20
15
  }
@@ -1,36 +1,28 @@
1
1
  import Foundation
2
2
 
3
- /// `{id}` template-token substitution for request-config string values (path, query values,
4
- /// header values), used by artwork URL resolution so a `nowPlayingArtwork` like
5
- /// `{ path: "/artwork/{id}" }` resolves per track.
6
- ///
7
- /// A track without a non-blank id leaves the token LITERALLY in place — the request then
8
- /// visibly 404s, which is intended (garbage in, garbage out with a self-describing error
9
- /// trail; the caller logs a single warning when `containsToken` still matches after
10
- /// substitution). Mirrors Android's `substituteTrackId` / `configContainsIdToken` in
11
- /// `BrowserUrlResolution.kt` — keep the two in sync.
3
+ /// `{id}` substitution in request-config strings, so an artwork config like
4
+ /// `{ path: "/artwork/{id}" }` resolves per track. Mirrors Android's `substituteTrackId` and
5
+ /// `configContainsIdToken` in `BrowserUrlResolution.kt`; keep the two in sync.
12
6
  enum TrackIdTemplate {
13
7
  static let token = "{id}"
14
8
 
15
- /// Replaces the token when `id` is non-blank; otherwise returns the value unchanged
16
- /// (token left literal).
9
+ /// Replaces every token with `id`. A nil or empty `id` returns `value` with the token left
10
+ /// in, on purpose: the request fails visibly and the caller warns via `containsToken`.
17
11
  static func substitute(_ value: String?, id: String?) -> String? {
18
12
  guard let id, !id.isEmpty else { return value }
19
13
  return value?.replacingOccurrences(of: token, with: id)
20
14
  }
21
15
 
22
- /// Dictionary-value variant of `substitute` (query / header values).
16
+ /// `substitute` over each value of a query or header map.
23
17
  static func substitute(_ values: [String: String]?, id: String?) -> [String: String]? {
24
18
  guard let id, !id.isEmpty else { return values }
25
19
  return values?.mapValues { $0.replacingOccurrences(of: token, with: id) }
26
20
  }
27
21
 
28
- /// Whether the value still carries the token (an unfilled `{id}`).
29
22
  static func containsToken(_ value: String?) -> Bool {
30
23
  value?.contains(token) == true
31
24
  }
32
25
 
33
- /// Whether any dictionary value still carries the token.
34
26
  static func containsToken(_ values: [String: String]?) -> Bool {
35
27
  values?.values.contains { $0.contains(token) } == true
36
28
  }
@@ -1,21 +1,16 @@
1
1
  import CarPlay
2
2
  import os.log
3
3
 
4
- /// Logged, precondition-guarded wrappers around `CPInterfaceController`'s
5
- /// template-stack mutations.
4
+ /// Logged, guarded wrappers around `CPInterfaceController`'s template-stack mutations.
6
5
  ///
7
- /// Per the SDK header, an unsuccessful push/setRoot/present with a nil
8
- /// completion doesn't fail quietly — it throws an Objective-C exception (depth
9
- /// limit included) that takes down the whole app, not just the CarPlay scene;
10
- /// pushing a template that is already in the hierarchy raises regardless.
11
- /// Every stack mutation therefore goes through these helpers: the raise-prone
12
- /// preconditions are checked up front, the underlying call always gets a
13
- /// completion, and every failure is logged, with an optional caller completion
14
- /// for call sites that chain on the result.
6
+ /// Per the SDK header, a failed push/setRoot/present with a nil completion raises an
7
+ /// Objective-C exception (depth limit included) that takes down the whole app, not just the
8
+ /// CarPlay scene; pushing a template already in the hierarchy raises regardless. So every
9
+ /// stack mutation goes through here: raise-prone preconditions are checked first, the
10
+ /// underlying call always gets a completion, and every failure is logged.
15
11
  ///
16
- /// A push onto a full stack replaces the top template (`TopTemplateReplacer`).
17
- /// The stack mutations wait for that replacement to settle before they run,
18
- /// so none of them lands between its pop and its push.
12
+ /// A push onto a full stack replaces the top template (`TopTemplateReplacer`); every mutation
13
+ /// waits for a replacement to settle, so none lands between its pop and its push.
19
14
  @MainActor
20
15
  extension CPInterfaceController {
21
16
  private static let stackLogger = Logger(subsystem: "com.audiobrowser", category: "TemplateStack")
@@ -24,10 +19,8 @@ extension CPInterfaceController {
24
19
  String(describing: type(of: template))
25
20
  }
26
21
 
27
- /// CarPlay's template-stack depth cap for audio apps. Not exposed by the SDK;
28
- /// exceeding it raises `NSGenericException` ("Application exceeded the
29
- /// hierarchy depth limit") synchronously — even through the completion-based
30
- /// push — taking down the whole app, not just the CarPlay scene.
22
+ // CarPlay's stack depth cap for audio apps, which the SDK does not expose. Exceeding it
23
+ // raises `NSGenericException` synchronously, even through the completion-based push.
31
24
  private static let maximumStackDepth = 5
32
25
 
33
26
  private static var topReplacerKey: UInt8 = 0
@@ -48,8 +41,8 @@ extension CPInterfaceController {
48
41
  }
49
42
  }
50
43
 
51
- /// Pushes `template`, skipping the raise case (already in the hierarchy). At
52
- /// the depth limit it replaces the top template.
44
+ /// Pushes `template`, skipping one already in the hierarchy. At the depth limit it replaces
45
+ /// the top template.
53
46
  func safePush(_ template: CPTemplate, animated: Bool, completion: ((Bool, Error?) -> Void)? = nil) {
54
47
  whenStackSettled { controller in
55
48
  let templates = controller.templates
@@ -64,8 +57,8 @@ extension CPInterfaceController {
64
57
  }
65
58
  }
66
59
 
67
- /// Replaces `expected` with `template` while `expected` is still the top template, restoring
68
- /// it if the push fails; a no-op once the user has moved on.
60
+ /// Replaces `expected` while it is still the top template, restoring it if the push fails; a
61
+ /// no-op once the user has moved on.
69
62
  func safeReplaceTop(_ expected: CPTemplate, with template: CPTemplate, animated: Bool) {
70
63
  whenStackSettled { controller in
71
64
  guard controller.topTemplate === expected else { return }
@@ -75,8 +68,6 @@ extension CPInterfaceController {
75
68
  }
76
69
  }
77
70
 
78
- /// Pushes `template`, skipping the raise cases (already in the hierarchy,
79
- /// stack at the depth limit).
80
71
  fileprivate func guardedPush(_ template: CPTemplate, animated: Bool, completion: ((Bool, Error?) -> Void)?) {
81
72
  guard !templates.contains(where: { $0 === template }) else {
82
73
  Self.stackLogger.warning("push skipped: \(Self.name(of: template)) is already in the stack")
@@ -96,7 +87,7 @@ extension CPInterfaceController {
96
87
  }
97
88
  }
98
89
 
99
- /// Pops the top template, skipping the raise case (nothing above the root).
90
+ /// Skips the pop when only the root is left, which would raise.
100
91
  fileprivate func guardedPop(animated: Bool, completion: ((Bool, Error?) -> Void)?) {
101
92
  guard templates.count > 1 else {
102
93
  Self.stackLogger.warning("pop skipped: already at the root template")
@@ -111,8 +102,8 @@ extension CPInterfaceController {
111
102
  }
112
103
  }
113
104
 
114
- /// Pops back to `template`, skipping the raise case (not in the hierarchy).
115
- /// A no-op success when it is already the top template.
105
+ /// Pops back to `template`, skipping one not in the hierarchy. Succeeds without popping
106
+ /// when it is already the top template.
116
107
  func safePop(to template: CPTemplate, animated: Bool, completion: ((Bool, Error?) -> Void)? = nil) {
117
108
  whenStackSettled { controller in
118
109
  guard controller.templates.contains(where: { $0 === template }) else {
@@ -156,8 +147,8 @@ extension CPInterfaceController {
156
147
  }
157
148
  }
158
149
 
159
- /// The guarded pop and push a replacement is made of, so a push that still
160
- /// cannot fit skips and logs rather than raising.
150
+ /// The guarded pop and push a replacement is made of, so a push that still cannot fit is
151
+ /// skipped and logged rather than raising.
161
152
  @MainActor
162
153
  private struct GuardedTemplateStack: TemplateStack {
163
154
  let controller: CPInterfaceController