@wwdrew/expo-apple-music 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ATTRIBUTION.md +24 -0
- package/LICENSE +190 -0
- package/NOTICE +7 -0
- package/README.md +81 -0
- package/android/build.gradle +26 -0
- package/android/libs/mediaplayback-release-1.1.1.aar +0 -0
- package/android/libs/musickitauth-release-1.1.2.aar +0 -0
- package/android/src/main/AndroidManifest.xml +16 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidCatalogService.kt +86 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidDeveloperToken.kt +39 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidHistoryService.kt +24 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidLibraryMutationsService.kt +30 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidLibraryService.kt +61 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidPlaybackController.kt +484 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidPlaybackObserver.kt +173 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidQueueService.kt +78 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidRatingsService.kt +27 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidRecommendationsService.kt +15 -0
- package/android/src/main/java/expo/modules/applemusic/AndroidSubscriptionService.kt +24 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicErrorCodes.kt +13 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicErrors.kt +46 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicHttpMethod.kt +8 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicJsonMapper.kt +258 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicNativeLoader.kt +32 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicRestJson.kt +40 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicRestQuery.kt +12 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicRestStack.kt +19 -0
- package/android/src/main/java/expo/modules/applemusic/AppleMusicRestTransport.kt +118 -0
- package/android/src/main/java/expo/modules/applemusic/AuthenticatedSession.kt +57 -0
- package/android/src/main/java/expo/modules/applemusic/BridgeResponses.kt +55 -0
- package/android/src/main/java/expo/modules/applemusic/CatalogRestClient.kt +306 -0
- package/android/src/main/java/expo/modules/applemusic/ExpoAppleMusicModule.kt +152 -0
- package/android/src/main/java/expo/modules/applemusic/HistoryRestClient.kt +60 -0
- package/android/src/main/java/expo/modules/applemusic/LibraryIds.kt +6 -0
- package/android/src/main/java/expo/modules/applemusic/LibraryMutationsRestClient.kt +95 -0
- package/android/src/main/java/expo/modules/applemusic/LibraryRestClient.kt +195 -0
- package/android/src/main/java/expo/modules/applemusic/MusicKitAuthContract.kt +78 -0
- package/android/src/main/java/expo/modules/applemusic/MusicKitAuthStorage.kt +76 -0
- package/android/src/main/java/expo/modules/applemusic/MusicKitTokenProvider.kt +13 -0
- package/android/src/main/java/expo/modules/applemusic/PaginationOptions.kt +14 -0
- package/android/src/main/java/expo/modules/applemusic/RatingsRestClient.kt +72 -0
- package/android/src/main/java/expo/modules/applemusic/RecommendationsRestClient.kt +37 -0
- package/android/src/main/java/expo/modules/applemusic/StorefrontRestClient.kt +44 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeAuth.kt +69 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeCatalog.kt +76 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeHistory.kt +35 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeLibrary.kt +54 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeLibraryMutations.kt +30 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgePlayer.kt +89 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeRatings.kt +29 -0
- package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeRecommendations.kt +18 -0
- package/app.plugin.js +1 -0
- package/build/ExpoAppleMusicModule.web.d.ts +15 -0
- package/build/ExpoAppleMusicModule.web.d.ts.map +1 -0
- package/build/ExpoAppleMusicModule.web.js +33 -0
- package/build/ExpoAppleMusicModule.web.js.map +1 -0
- package/build/api/call-native.d.ts +6 -0
- package/build/api/call-native.d.ts.map +1 -0
- package/build/api/call-native.js +35 -0
- package/build/api/call-native.js.map +1 -0
- package/build/api/decode-jwt-exp.d.ts +5 -0
- package/build/api/decode-jwt-exp.d.ts.map +1 -0
- package/build/api/decode-jwt-exp.js +28 -0
- package/build/api/decode-jwt-exp.js.map +1 -0
- package/build/api/library-ids.d.ts +4 -0
- package/build/api/library-ids.d.ts.map +1 -0
- package/build/api/library-ids.js +11 -0
- package/build/api/library-ids.js.map +1 -0
- package/build/api/pagination.d.ts +12 -0
- package/build/api/pagination.d.ts.map +1 -0
- package/build/api/pagination.js +13 -0
- package/build/api/pagination.js.map +1 -0
- package/build/api/parse-authorize-result.d.ts +3 -0
- package/build/api/parse-authorize-result.d.ts.map +1 -0
- package/build/api/parse-authorize-result.js +27 -0
- package/build/api/parse-authorize-result.js.map +1 -0
- package/build/api/require-music-user-token.d.ts +2 -0
- package/build/api/require-music-user-token.d.ts.map +1 -0
- package/build/api/require-music-user-token.js +14 -0
- package/build/api/require-music-user-token.js.map +1 -0
- package/build/api/sync-developer-token.d.ts +4 -0
- package/build/api/sync-developer-token.d.ts.map +1 -0
- package/build/api/sync-developer-token.js +27 -0
- package/build/api/sync-developer-token.js.map +1 -0
- package/build/bridge/bridge-methods.d.ts +17 -0
- package/build/bridge/bridge-methods.d.ts.map +1 -0
- package/build/bridge/bridge-methods.js +71 -0
- package/build/bridge/bridge-methods.js.map +1 -0
- package/build/bridge/bridge-responses.d.ts +64 -0
- package/build/bridge/bridge-responses.d.ts.map +1 -0
- package/build/bridge/bridge-responses.js +67 -0
- package/build/bridge/bridge-responses.js.map +1 -0
- package/build/bridge/handlers/auth-bridge.d.ts +11 -0
- package/build/bridge/handlers/auth-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/auth-bridge.js +49 -0
- package/build/bridge/handlers/auth-bridge.js.map +1 -0
- package/build/bridge/handlers/catalog-bridge.d.ts +34 -0
- package/build/bridge/handlers/catalog-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/catalog-bridge.js +58 -0
- package/build/bridge/handlers/catalog-bridge.js.map +1 -0
- package/build/bridge/handlers/history-bridge.d.ts +19 -0
- package/build/bridge/handlers/history-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/history-bridge.js +31 -0
- package/build/bridge/handlers/history-bridge.js.map +1 -0
- package/build/bridge/handlers/index.d.ts +124 -0
- package/build/bridge/handlers/index.d.ts.map +1 -0
- package/build/bridge/handlers/index.js +21 -0
- package/build/bridge/handlers/index.js.map +1 -0
- package/build/bridge/handlers/library-bridge.d.ts +23 -0
- package/build/bridge/handlers/library-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/library-bridge.js +41 -0
- package/build/bridge/handlers/library-bridge.js.map +1 -0
- package/build/bridge/handlers/library-mutations-bridge.d.ts +16 -0
- package/build/bridge/handlers/library-mutations-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/library-mutations-bridge.js +20 -0
- package/build/bridge/handlers/library-mutations-bridge.js.map +1 -0
- package/build/bridge/handlers/player-bridge.d.ts +18 -0
- package/build/bridge/handlers/player-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/player-bridge.js +42 -0
- package/build/bridge/handlers/player-bridge.js.map +1 -0
- package/build/bridge/handlers/ratings-bridge.d.ts +15 -0
- package/build/bridge/handlers/ratings-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/ratings-bridge.js +16 -0
- package/build/bridge/handlers/ratings-bridge.js.map +1 -0
- package/build/bridge/handlers/recommendations-bridge.d.ts +10 -0
- package/build/bridge/handlers/recommendations-bridge.d.ts.map +1 -0
- package/build/bridge/handlers/recommendations-bridge.js +14 -0
- package/build/bridge/handlers/recommendations-bridge.js.map +1 -0
- package/build/constants/apple-music-error-codes.d.ts +22 -0
- package/build/constants/apple-music-error-codes.d.ts.map +1 -0
- package/build/constants/apple-music-error-codes.js +21 -0
- package/build/constants/apple-music-error-codes.js.map +1 -0
- package/build/hooks/use-current-song.d.ts +10 -0
- package/build/hooks/use-current-song.d.ts.map +1 -0
- package/build/hooks/use-current-song.js +35 -0
- package/build/hooks/use-current-song.js.map +1 -0
- package/build/hooks/use-is-playing.d.ts +6 -0
- package/build/hooks/use-is-playing.d.ts.map +1 -0
- package/build/hooks/use-is-playing.js +21 -0
- package/build/hooks/use-is-playing.js.map +1 -0
- package/build/hooks/use-playback-state.d.ts +12 -0
- package/build/hooks/use-playback-state.d.ts.map +1 -0
- package/build/hooks/use-playback-state.js +41 -0
- package/build/hooks/use-playback-state.js.map +1 -0
- package/build/index.d.ts +52 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +44 -0
- package/build/index.js.map +1 -0
- package/build/mappers/apple-music-json-mapper.d.ts +94 -0
- package/build/mappers/apple-music-json-mapper.d.ts.map +1 -0
- package/build/mappers/apple-music-json-mapper.js +212 -0
- package/build/mappers/apple-music-json-mapper.js.map +1 -0
- package/build/modules/auth.d.ts +32 -0
- package/build/modules/auth.d.ts.map +1 -0
- package/build/modules/auth.js +60 -0
- package/build/modules/auth.js.map +1 -0
- package/build/modules/catalog.d.ts +46 -0
- package/build/modules/catalog.d.ts.map +1 -0
- package/build/modules/catalog.js +47 -0
- package/build/modules/catalog.js.map +1 -0
- package/build/modules/history.d.ts +17 -0
- package/build/modules/history.d.ts.map +1 -0
- package/build/modules/history.js +28 -0
- package/build/modules/history.js.map +1 -0
- package/build/modules/library-mutations.d.ts +9 -0
- package/build/modules/library-mutations.d.ts.map +1 -0
- package/build/modules/library-mutations.js +41 -0
- package/build/modules/library-mutations.js.map +1 -0
- package/build/modules/library.d.ts +21 -0
- package/build/modules/library.d.ts.map +1 -0
- package/build/modules/library.js +38 -0
- package/build/modules/library.js.map +1 -0
- package/build/modules/player.d.ts +53 -0
- package/build/modules/player.d.ts.map +1 -0
- package/build/modules/player.js +68 -0
- package/build/modules/player.js.map +1 -0
- package/build/modules/ratings.d.ts +10 -0
- package/build/modules/ratings.d.ts.map +1 -0
- package/build/modules/ratings.js +37 -0
- package/build/modules/ratings.js.map +1 -0
- package/build/modules/recommendations.d.ts +7 -0
- package/build/modules/recommendations.d.ts.map +1 -0
- package/build/modules/recommendations.js +15 -0
- package/build/modules/recommendations.js.map +1 -0
- package/build/native-module.d.ts +5 -0
- package/build/native-module.d.ts.map +1 -0
- package/build/native-module.js +5 -0
- package/build/native-module.js.map +1 -0
- package/build/native-module.web.d.ts +11 -0
- package/build/native-module.web.d.ts.map +1 -0
- package/build/native-module.web.js +11 -0
- package/build/native-module.web.js.map +1 -0
- package/build/rest/apple-music-rest-stack.d.ts +21 -0
- package/build/rest/apple-music-rest-stack.d.ts.map +1 -0
- package/build/rest/apple-music-rest-stack.js +21 -0
- package/build/rest/apple-music-rest-stack.js.map +1 -0
- package/build/rest/apple-music-rest-transport.d.ts +8 -0
- package/build/rest/apple-music-rest-transport.d.ts.map +1 -0
- package/build/rest/apple-music-rest-transport.js +2 -0
- package/build/rest/apple-music-rest-transport.js.map +1 -0
- package/build/rest/catalog-rest-client.d.ts +38 -0
- package/build/rest/catalog-rest-client.d.ts.map +1 -0
- package/build/rest/catalog-rest-client.js +189 -0
- package/build/rest/catalog-rest-client.js.map +1 -0
- package/build/rest/history-rest-client.d.ts +37 -0
- package/build/rest/history-rest-client.d.ts.map +1 -0
- package/build/rest/history-rest-client.js +30 -0
- package/build/rest/history-rest-client.js.map +1 -0
- package/build/rest/library-ids.d.ts +2 -0
- package/build/rest/library-ids.d.ts.map +1 -0
- package/build/rest/library-ids.js +2 -0
- package/build/rest/library-ids.js.map +1 -0
- package/build/rest/library-mutations-rest-client.d.ts +22 -0
- package/build/rest/library-mutations-rest-client.d.ts.map +1 -0
- package/build/rest/library-mutations-rest-client.js +37 -0
- package/build/rest/library-mutations-rest-client.js.map +1 -0
- package/build/rest/library-rest-client.d.ts +59 -0
- package/build/rest/library-rest-client.d.ts.map +1 -0
- package/build/rest/library-rest-client.js +141 -0
- package/build/rest/library-rest-client.js.map +1 -0
- package/build/rest/ratings-rest-client.d.ts +18 -0
- package/build/rest/ratings-rest-client.d.ts.map +1 -0
- package/build/rest/ratings-rest-client.js +37 -0
- package/build/rest/ratings-rest-client.js.map +1 -0
- package/build/rest/recommendations-rest-client.d.ts +32 -0
- package/build/rest/recommendations-rest-client.d.ts.map +1 -0
- package/build/rest/recommendations-rest-client.js +26 -0
- package/build/rest/recommendations-rest-client.js.map +1 -0
- package/build/rest/resource-ids-query.d.ts +2 -0
- package/build/rest/resource-ids-query.d.ts.map +1 -0
- package/build/rest/resource-ids-query.js +10 -0
- package/build/rest/resource-ids-query.js.map +1 -0
- package/build/rest/rest-json.d.ts +11 -0
- package/build/rest/rest-json.d.ts.map +1 -0
- package/build/rest/rest-json.js +29 -0
- package/build/rest/rest-json.js.map +1 -0
- package/build/rest/storefront-rest-client.d.ts +14 -0
- package/build/rest/storefront-rest-client.d.ts.map +1 -0
- package/build/rest/storefront-rest-client.js +36 -0
- package/build/rest/storefront-rest-client.js.map +1 -0
- package/build/types/album.d.ts +8 -0
- package/build/types/album.d.ts.map +1 -0
- package/build/types/album.js +2 -0
- package/build/types/album.js.map +1 -0
- package/build/types/albums-response.d.ts +5 -0
- package/build/types/albums-response.d.ts.map +1 -0
- package/build/types/albums-response.js +2 -0
- package/build/types/albums-response.js.map +1 -0
- package/build/types/android-authorize-options.d.ts +18 -0
- package/build/types/android-authorize-options.d.ts.map +1 -0
- package/build/types/android-authorize-options.js +2 -0
- package/build/types/android-authorize-options.js.map +1 -0
- package/build/types/artist.d.ts +9 -0
- package/build/types/artist.d.ts.map +1 -0
- package/build/types/artist.js +2 -0
- package/build/types/artist.js.map +1 -0
- package/build/types/auth-status.d.ts +19 -0
- package/build/types/auth-status.d.ts.map +1 -0
- package/build/types/auth-status.js +18 -0
- package/build/types/auth-status.js.map +1 -0
- package/build/types/authorize-result.d.ts +8 -0
- package/build/types/authorize-result.d.ts.map +1 -0
- package/build/types/authorize-result.js +2 -0
- package/build/types/authorize-result.js.map +1 -0
- package/build/types/catalog-album-tracks.d.ts +5 -0
- package/build/types/catalog-album-tracks.d.ts.map +1 -0
- package/build/types/catalog-album-tracks.js +2 -0
- package/build/types/catalog-album-tracks.js.map +1 -0
- package/build/types/catalog-charts.d.ts +25 -0
- package/build/types/catalog-charts.d.ts.map +1 -0
- package/build/types/catalog-charts.js +7 -0
- package/build/types/catalog-charts.js.map +1 -0
- package/build/types/catalog-resource-type.d.ts +11 -0
- package/build/types/catalog-resource-type.d.ts.map +1 -0
- package/build/types/catalog-resource-type.js +10 -0
- package/build/types/catalog-resource-type.js.map +1 -0
- package/build/types/catalog-search.d.ts +24 -0
- package/build/types/catalog-search.d.ts.map +1 -0
- package/build/types/catalog-search.js +9 -0
- package/build/types/catalog-search.js.map +1 -0
- package/build/types/check-subscription.d.ts +31 -0
- package/build/types/check-subscription.d.ts.map +1 -0
- package/build/types/check-subscription.js +5 -0
- package/build/types/check-subscription.js.map +1 -0
- package/build/types/library-music-videos.d.ts +5 -0
- package/build/types/library-music-videos.d.ts.map +1 -0
- package/build/types/library-music-videos.js +2 -0
- package/build/types/library-music-videos.js.map +1 -0
- package/build/types/library-mutations.d.ts +21 -0
- package/build/types/library-mutations.d.ts.map +1 -0
- package/build/types/library-mutations.js +8 -0
- package/build/types/library-mutations.js.map +1 -0
- package/build/types/library-search.d.ts +22 -0
- package/build/types/library-search.d.ts.map +1 -0
- package/build/types/library-search.js +9 -0
- package/build/types/library-search.js.map +1 -0
- package/build/types/music-item.d.ts +8 -0
- package/build/types/music-item.d.ts.map +1 -0
- package/build/types/music-item.js +7 -0
- package/build/types/music-item.js.map +1 -0
- package/build/types/music-video.d.ts +8 -0
- package/build/types/music-video.d.ts.map +1 -0
- package/build/types/music-video.js +2 -0
- package/build/types/music-video.js.map +1 -0
- package/build/types/pagination.d.ts +11 -0
- package/build/types/pagination.d.ts.map +1 -0
- package/build/types/pagination.js +2 -0
- package/build/types/pagination.js.map +1 -0
- package/build/types/playback-state.d.ts +9 -0
- package/build/types/playback-state.d.ts.map +1 -0
- package/build/types/playback-state.js +2 -0
- package/build/types/playback-state.js.map +1 -0
- package/build/types/playback-status.d.ts +10 -0
- package/build/types/playback-status.d.ts.map +1 -0
- package/build/types/playback-status.js +9 -0
- package/build/types/playback-status.js.map +1 -0
- package/build/types/playlist.d.ts +15 -0
- package/build/types/playlist.d.ts.map +1 -0
- package/build/types/playlist.js +2 -0
- package/build/types/playlist.js.map +1 -0
- package/build/types/rating.d.ts +34 -0
- package/build/types/rating.d.ts.map +1 -0
- package/build/types/rating.js +26 -0
- package/build/types/rating.js.map +1 -0
- package/build/types/recent-resource.d.ts +11 -0
- package/build/types/recent-resource.d.ts.map +1 -0
- package/build/types/recent-resource.js +2 -0
- package/build/types/recent-resource.js.map +1 -0
- package/build/types/recommendation.d.ts +37 -0
- package/build/types/recommendation.d.ts.map +1 -0
- package/build/types/recommendation.js +2 -0
- package/build/types/recommendation.js.map +1 -0
- package/build/types/song.d.ts +8 -0
- package/build/types/song.d.ts.map +1 -0
- package/build/types/song.js +2 -0
- package/build/types/song.js.map +1 -0
- package/build/types/station.d.ts +9 -0
- package/build/types/station.d.ts.map +1 -0
- package/build/types/station.js +2 -0
- package/build/types/station.js.map +1 -0
- package/build/types/storefront.d.ts +4 -0
- package/build/types/storefront.d.ts.map +1 -0
- package/build/types/storefront.js +2 -0
- package/build/types/storefront.js.map +1 -0
- package/build/types/tracks-from-library.d.ts +11 -0
- package/build/types/tracks-from-library.d.ts.map +1 -0
- package/build/types/tracks-from-library.js +2 -0
- package/build/types/tracks-from-library.js.map +1 -0
- package/build/utils/apple-music-error.d.ts +10 -0
- package/build/utils/apple-music-error.d.ts.map +1 -0
- package/build/utils/apple-music-error.js +13 -0
- package/build/utils/apple-music-error.js.map +1 -0
- package/build/utils/get-error-message.d.ts +2 -0
- package/build/utils/get-error-message.d.ts.map +1 -0
- package/build/utils/get-error-message.js +21 -0
- package/build/utils/get-error-message.js.map +1 -0
- package/build/utils/is-library-item.d.ts +2 -0
- package/build/utils/is-library-item.d.ts.map +1 -0
- package/build/utils/is-library-item.js +4 -0
- package/build/utils/is-library-item.js.map +1 -0
- package/build/utils/normalize-resource-ids.d.ts +4 -0
- package/build/utils/normalize-resource-ids.d.ts.map +1 -0
- package/build/utils/normalize-resource-ids.js +12 -0
- package/build/utils/normalize-resource-ids.js.map +1 -0
- package/build/web/MusicKitLoader.d.ts +11 -0
- package/build/web/MusicKitLoader.d.ts.map +1 -0
- package/build/web/MusicKitLoader.js +135 -0
- package/build/web/MusicKitLoader.js.map +1 -0
- package/build/web/WebAppleMusicApiClient.d.ts +151 -0
- package/build/web/WebAppleMusicApiClient.d.ts.map +1 -0
- package/build/web/WebAppleMusicApiClient.js +139 -0
- package/build/web/WebAppleMusicApiClient.js.map +1 -0
- package/build/web/WebAppleMusicRestTransport.d.ts +9 -0
- package/build/web/WebAppleMusicRestTransport.d.ts.map +1 -0
- package/build/web/WebAppleMusicRestTransport.js +31 -0
- package/build/web/WebAppleMusicRestTransport.js.map +1 -0
- package/build/web/WebPlaybackController.d.ts +12 -0
- package/build/web/WebPlaybackController.d.ts.map +1 -0
- package/build/web/WebPlaybackController.js +90 -0
- package/build/web/WebPlaybackController.js.map +1 -0
- package/build/web/WebPlaybackObserver.d.ts +22 -0
- package/build/web/WebPlaybackObserver.d.ts.map +1 -0
- package/build/web/WebPlaybackObserver.js +106 -0
- package/build/web/WebPlaybackObserver.js.map +1 -0
- package/build/web/WebQueueService.d.ts +10 -0
- package/build/web/WebQueueService.d.ts.map +1 -0
- package/build/web/WebQueueService.js +53 -0
- package/build/web/WebQueueService.js.map +1 -0
- package/build/web/WebSubscriptionService.d.ts +7 -0
- package/build/web/WebSubscriptionService.d.ts.map +1 -0
- package/build/web/WebSubscriptionService.js +24 -0
- package/build/web/WebSubscriptionService.js.map +1 -0
- package/build/web/apple-music-errors.d.ts +11 -0
- package/build/web/apple-music-errors.d.ts.map +1 -0
- package/build/web/apple-music-errors.js +31 -0
- package/build/web/apple-music-errors.js.map +1 -0
- package/build/web/extract-music-user-token.d.ts +4 -0
- package/build/web/extract-music-user-token.d.ts.map +1 -0
- package/build/web/extract-music-user-token.js +15 -0
- package/build/web/extract-music-user-token.js.map +1 -0
- package/build/web/map-auth-status.d.ts +17 -0
- package/build/web/map-auth-status.d.ts.map +1 -0
- package/build/web/map-auth-status.js +85 -0
- package/build/web/map-auth-status.js.map +1 -0
- package/build/web/music-kit-api.d.ts +18 -0
- package/build/web/music-kit-api.d.ts.map +1 -0
- package/build/web/music-kit-api.js +120 -0
- package/build/web/music-kit-api.js.map +1 -0
- package/build/web/musickit-types.d.ts +70 -0
- package/build/web/musickit-types.d.ts.map +1 -0
- package/build/web/musickit-types.js +3 -0
- package/build/web/musickit-types.js.map +1 -0
- package/build/web/pagination.d.ts +2 -0
- package/build/web/pagination.d.ts.map +1 -0
- package/build/web/pagination.js +2 -0
- package/build/web/pagination.js.map +1 -0
- package/expo-module.config.json +19 -0
- package/ios/AppleMusicBridgeError.swift +60 -0
- package/ios/AppleMusicErrorCodes.swift +11 -0
- package/ios/AppleMusicRestClient.swift +213 -0
- package/ios/AuthenticatedSession.swift +64 -0
- package/ios/BridgePagination.swift +17 -0
- package/ios/BridgeResponses.swift +82 -0
- package/ios/CatalogSearchStore.swift +13 -0
- package/ios/CatalogSearchStoreFactory.swift +31 -0
- package/ios/CatalogService.swift +307 -0
- package/ios/ExpoAppleMusic.podspec +29 -0
- package/ios/ExpoAppleMusicModule.swift +505 -0
- package/ios/HistoryService.swift +53 -0
- package/ios/LibraryMutationsService.swift +63 -0
- package/ios/LibraryService.swift +313 -0
- package/ios/MusicItemMapper.swift +171 -0
- package/ios/MusicKitAuthStorage.swift +38 -0
- package/ios/MusicKitCatalogSearchStore.swift +62 -0
- package/ios/PlaybackController.swift +201 -0
- package/ios/PlaybackObserver.swift +225 -0
- package/ios/QueueService.swift +166 -0
- package/ios/RatingsService.swift +66 -0
- package/ios/RecommendationsService.swift +34 -0
- package/ios/RestCatalogSearchStore.swift +62 -0
- package/ios/RestJsonMapper.swift +268 -0
- package/ios/StorefrontService.swift +55 -0
- package/ios/SubscriptionService.swift +119 -0
- package/ios/bridge/ExpoBridgeCatalog.swift +98 -0
- package/ios/bridge/ExpoBridgeHistory.swift +71 -0
- package/ios/bridge/ExpoBridgeLibrary.swift +93 -0
- package/ios/bridge/ExpoBridgeRecommendations.swift +28 -0
- package/package.json +89 -0
- package/plugin/build/index.d.ts +5 -0
- package/plugin/build/index.js +10 -0
- package/plugin/build/with-expo-apple-music.d.ts +10 -0
- package/plugin/build/with-expo-apple-music.js +50 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
export declare function createHistoryBridge(api: WebAppleMusicApiClient): {
|
|
3
|
+
getRecentlyPlayedResources(musicUserToken: string): Promise<{
|
|
4
|
+
recentlyPlayedItems: unknown[];
|
|
5
|
+
}>;
|
|
6
|
+
getRecentlyPlayedTracks(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
7
|
+
songs: unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
getHeavyRotation(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
10
|
+
items: unknown[];
|
|
11
|
+
}>;
|
|
12
|
+
getRecentlyPlayedStations(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
13
|
+
stations: unknown[];
|
|
14
|
+
}>;
|
|
15
|
+
getRecentlyAdded(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
16
|
+
items: unknown[];
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=history-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/history-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG/E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,sBAAsB;+CAEV,MAAM;;;4CAKT,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;qCAM/C,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;8CAM/B,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;qCAMjD,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;EAMlF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { paginationFromMap } from '../../web/pagination';
|
|
2
|
+
import { BridgeResponses } from '../bridge-responses';
|
|
3
|
+
export function createHistoryBridge(api) {
|
|
4
|
+
return {
|
|
5
|
+
async getRecentlyPlayedResources(musicUserToken) {
|
|
6
|
+
const tracks = await api.getRecentlyPlayed(musicUserToken);
|
|
7
|
+
return BridgeResponses.recentlyPlayedResources(tracks);
|
|
8
|
+
},
|
|
9
|
+
async getRecentlyPlayedTracks(musicUserToken, options) {
|
|
10
|
+
const pagination = paginationFromMap(options);
|
|
11
|
+
const songs = await api.getRecentlyPlayedTracks(musicUserToken, pagination.limit);
|
|
12
|
+
return BridgeResponses.songs(songs);
|
|
13
|
+
},
|
|
14
|
+
async getHeavyRotation(musicUserToken, options) {
|
|
15
|
+
const pagination = paginationFromMap(options);
|
|
16
|
+
const items = await api.getHeavyRotation(musicUserToken, pagination.limit);
|
|
17
|
+
return BridgeResponses.recentItems(items);
|
|
18
|
+
},
|
|
19
|
+
async getRecentlyPlayedStations(musicUserToken, options) {
|
|
20
|
+
const pagination = paginationFromMap(options);
|
|
21
|
+
const stations = await api.getRecentlyPlayedStations(musicUserToken, pagination.limit);
|
|
22
|
+
return BridgeResponses.stations(stations);
|
|
23
|
+
},
|
|
24
|
+
async getRecentlyAdded(musicUserToken, options) {
|
|
25
|
+
const pagination = paginationFromMap(options);
|
|
26
|
+
const items = await api.getRecentlyAdded(musicUserToken, pagination.limit, pagination.offset);
|
|
27
|
+
return BridgeResponses.recentItems(items);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=history-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/history-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,UAAU,mBAAmB,CAAC,GAA2B;IAC7D,OAAO;QACL,KAAK,CAAC,0BAA0B,CAAC,cAAsB;YACrD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;YAC3D,OAAO,eAAe,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC;QAED,KAAK,CAAC,uBAAuB,CAAC,cAAsB,EAAE,OAAgC;YACpF,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,uBAAuB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAClF,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,OAAgC;YAC7E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAC3E,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,KAAK,CAAC,yBAAyB,CAAC,cAAsB,EAAE,OAAgC;YACtF,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,yBAAyB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YACvF,OAAO,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,OAAgC;YAC7E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAC9F,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { paginationFromMap } from '../../web/pagination';\nimport type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\nimport { BridgeResponses } from '../bridge-responses';\n\nexport function createHistoryBridge(api: WebAppleMusicApiClient) {\n return {\n async getRecentlyPlayedResources(musicUserToken: string) {\n const tracks = await api.getRecentlyPlayed(musicUserToken);\n return BridgeResponses.recentlyPlayedResources(tracks);\n },\n\n async getRecentlyPlayedTracks(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const songs = await api.getRecentlyPlayedTracks(musicUserToken, pagination.limit);\n return BridgeResponses.songs(songs);\n },\n\n async getHeavyRotation(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const items = await api.getHeavyRotation(musicUserToken, pagination.limit);\n return BridgeResponses.recentItems(items);\n },\n\n async getRecentlyPlayedStations(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const stations = await api.getRecentlyPlayedStations(musicUserToken, pagination.limit);\n return BridgeResponses.stations(stations);\n },\n\n async getRecentlyAdded(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const items = await api.getRecentlyAdded(musicUserToken, pagination.limit, pagination.offset);\n return BridgeResponses.recentItems(items);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
import type { WebPlaybackController } from '../../web/WebPlaybackController';
|
|
3
|
+
import type { WebQueueService } from '../../web/WebQueueService';
|
|
4
|
+
import type { WebSubscriptionService } from '../../web/WebSubscriptionService';
|
|
5
|
+
export type WebBridgeHandlers = ReturnType<typeof createWebBridgeHandlers>;
|
|
6
|
+
export declare function createWebBridgeHandlers(deps: {
|
|
7
|
+
api: WebAppleMusicApiClient;
|
|
8
|
+
subscription: WebSubscriptionService;
|
|
9
|
+
queue: WebQueueService;
|
|
10
|
+
playback: WebPlaybackController;
|
|
11
|
+
}): {
|
|
12
|
+
getRecommendations(musicUserToken: string, ids: string[] | null): Promise<{
|
|
13
|
+
recommendations: unknown[];
|
|
14
|
+
}>;
|
|
15
|
+
getReplay(musicUserToken: string, year: number | null): Promise<{
|
|
16
|
+
summaries: unknown[];
|
|
17
|
+
}>;
|
|
18
|
+
addToLibrary: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
19
|
+
createLibraryPlaylist(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
artworkUrl: string;
|
|
24
|
+
trackCount: number;
|
|
25
|
+
}>;
|
|
26
|
+
addTracksToLibraryPlaylist: (musicUserToken: string, playlistId: string, tracks: {
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
}[]) => Promise<void>;
|
|
30
|
+
getRating: (musicUserToken: string, resourceType: string, id: string) => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
value: number;
|
|
33
|
+
} | null>;
|
|
34
|
+
setRating: (musicUserToken: string, resourceType: string, id: string, value: number) => Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
value: number;
|
|
37
|
+
} | null>;
|
|
38
|
+
clearRating: (musicUserToken: string, resourceType: string, id: string) => Promise<void>;
|
|
39
|
+
addToFavorites: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
40
|
+
removeFromFavorites: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
41
|
+
setPlaybackQueue(itemId: string, type: string): Promise<string>;
|
|
42
|
+
playLibrarySong(musicUserToken: string, songId: string): Promise<string>;
|
|
43
|
+
playLibraryPlaylist(musicUserToken: string, playlistId: string, startingAt: number): Promise<string>;
|
|
44
|
+
configurePlayer(mixWithOthers: boolean): Record<string, unknown>;
|
|
45
|
+
getCurrentState: () => Promise<Record<string, unknown>>;
|
|
46
|
+
play: () => void;
|
|
47
|
+
pause: () => void;
|
|
48
|
+
skipToNextEntry: () => void;
|
|
49
|
+
skipToPreviousEntry: () => void;
|
|
50
|
+
restartCurrentEntry: () => void;
|
|
51
|
+
seekToTime: (time: number) => void;
|
|
52
|
+
togglePlayerState: () => void;
|
|
53
|
+
getRecentlyPlayedResources(musicUserToken: string): Promise<{
|
|
54
|
+
recentlyPlayedItems: unknown[];
|
|
55
|
+
}>;
|
|
56
|
+
getRecentlyPlayedTracks(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
57
|
+
songs: unknown[];
|
|
58
|
+
}>;
|
|
59
|
+
getHeavyRotation(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
60
|
+
items: unknown[];
|
|
61
|
+
}>;
|
|
62
|
+
getRecentlyPlayedStations(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
63
|
+
stations: unknown[];
|
|
64
|
+
}>;
|
|
65
|
+
getRecentlyAdded(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
66
|
+
items: unknown[];
|
|
67
|
+
}>;
|
|
68
|
+
getUserPlaylists(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
69
|
+
playlists: unknown[];
|
|
70
|
+
}>;
|
|
71
|
+
getLibrarySongs(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
72
|
+
songs: unknown[];
|
|
73
|
+
}>;
|
|
74
|
+
getPlaylistSongs(musicUserToken: string, playlistId: string, _options: Record<string, unknown>): Promise<{
|
|
75
|
+
songs: unknown[];
|
|
76
|
+
}>;
|
|
77
|
+
getLibraryArtists(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
78
|
+
artists: unknown[];
|
|
79
|
+
}>;
|
|
80
|
+
getLibraryAlbums(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
81
|
+
albums: unknown[];
|
|
82
|
+
}>;
|
|
83
|
+
getLibraryMusicVideos(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
84
|
+
musicVideos: unknown[];
|
|
85
|
+
}>;
|
|
86
|
+
librarySearch(musicUserToken: string, term: string, types: string[], options: Record<string, unknown>): Promise<import("../bridge-responses").LibrarySearchPayload>;
|
|
87
|
+
catalogSearch(term: string, types: string[], options: Record<string, unknown>): Promise<import("../bridge-responses").CatalogSearchPayload>;
|
|
88
|
+
getCatalogSong: (id: string) => Promise<Record<string, unknown>>;
|
|
89
|
+
getCatalogAlbum: (id: string) => Promise<Record<string, unknown>>;
|
|
90
|
+
getCatalogArtist: (id: string) => Promise<Record<string, unknown>>;
|
|
91
|
+
getCatalogPlaylist: (id: string) => Promise<Record<string, unknown>>;
|
|
92
|
+
getCatalogStation: (id: string) => Promise<Record<string, unknown>>;
|
|
93
|
+
getCatalogMusicVideo: (id: string) => Promise<Record<string, unknown>>;
|
|
94
|
+
getCatalogAlbumTracks(albumId: string, options: Record<string, unknown>): Promise<{
|
|
95
|
+
songs: unknown[];
|
|
96
|
+
}>;
|
|
97
|
+
getCatalogArtistAlbums(artistId: string, options: Record<string, unknown>): Promise<{
|
|
98
|
+
albums: unknown[];
|
|
99
|
+
}>;
|
|
100
|
+
getCatalogPlaylistTracks(playlistId: string, options: Record<string, unknown>): Promise<{
|
|
101
|
+
songs: unknown[];
|
|
102
|
+
}>;
|
|
103
|
+
getCatalogCharts(types: string[], options: Record<string, unknown>): Promise<import("../bridge-responses").CatalogChartsPayload>;
|
|
104
|
+
getCatalogResources(type: string, ids: string[]): Promise<{
|
|
105
|
+
musicVideos: unknown[];
|
|
106
|
+
} | {
|
|
107
|
+
songs: unknown[];
|
|
108
|
+
} | {
|
|
109
|
+
albums: unknown[];
|
|
110
|
+
} | {
|
|
111
|
+
artists: unknown[];
|
|
112
|
+
} | {
|
|
113
|
+
playlists: unknown[];
|
|
114
|
+
} | {
|
|
115
|
+
stations: unknown[];
|
|
116
|
+
}>;
|
|
117
|
+
setDeveloperToken(token: string): Promise<void>;
|
|
118
|
+
authorization(developerToken: string | null, _startScreenMessage: string | null, _hideStartScreen: boolean | null): Promise<Record<string, string | undefined>>;
|
|
119
|
+
checkSubscription: (musicUserToken: string) => Promise<Record<string, unknown>>;
|
|
120
|
+
getStorefront(musicUserToken: string): Promise<{
|
|
121
|
+
id: string;
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAU/E,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,sBAAsB,CAAC;IAC5B,YAAY,EAAE,sBAAsB,CAAC;IACrC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,qBAAqB,CAAC;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createAuthBridge } from './auth-bridge';
|
|
2
|
+
import { createCatalogBridge } from './catalog-bridge';
|
|
3
|
+
import { createHistoryBridge } from './history-bridge';
|
|
4
|
+
import { createLibraryBridge } from './library-bridge';
|
|
5
|
+
import { createLibraryMutationsBridge } from './library-mutations-bridge';
|
|
6
|
+
import { createPlayerBridge } from './player-bridge';
|
|
7
|
+
import { createRatingsBridge } from './ratings-bridge';
|
|
8
|
+
import { createRecommendationsBridge } from './recommendations-bridge';
|
|
9
|
+
export function createWebBridgeHandlers(deps) {
|
|
10
|
+
return {
|
|
11
|
+
...createAuthBridge(deps.api, deps.subscription),
|
|
12
|
+
...createCatalogBridge(deps.api),
|
|
13
|
+
...createLibraryBridge(deps.api),
|
|
14
|
+
...createHistoryBridge(deps.api),
|
|
15
|
+
...createPlayerBridge(deps.api, deps.queue, deps.playback),
|
|
16
|
+
...createRatingsBridge(deps.api),
|
|
17
|
+
...createLibraryMutationsBridge(deps.api),
|
|
18
|
+
...createRecommendationsBridge(deps.api),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/handlers/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAIvE,MAAM,UAAU,uBAAuB,CAAC,IAKvC;IACC,OAAO;QACL,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC;QAChD,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAChC,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAChC,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAChC,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;QAC1D,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAChC,GAAG,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC;QACzC,GAAG,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\nimport type { WebPlaybackController } from '../../web/WebPlaybackController';\nimport type { WebQueueService } from '../../web/WebQueueService';\nimport type { WebSubscriptionService } from '../../web/WebSubscriptionService';\nimport { createAuthBridge } from './auth-bridge';\nimport { createCatalogBridge } from './catalog-bridge';\nimport { createHistoryBridge } from './history-bridge';\nimport { createLibraryBridge } from './library-bridge';\nimport { createLibraryMutationsBridge } from './library-mutations-bridge';\nimport { createPlayerBridge } from './player-bridge';\nimport { createRatingsBridge } from './ratings-bridge';\nimport { createRecommendationsBridge } from './recommendations-bridge';\n\nexport type WebBridgeHandlers = ReturnType<typeof createWebBridgeHandlers>;\n\nexport function createWebBridgeHandlers(deps: {\n api: WebAppleMusicApiClient;\n subscription: WebSubscriptionService;\n queue: WebQueueService;\n playback: WebPlaybackController;\n}) {\n return {\n ...createAuthBridge(deps.api, deps.subscription),\n ...createCatalogBridge(deps.api),\n ...createLibraryBridge(deps.api),\n ...createHistoryBridge(deps.api),\n ...createPlayerBridge(deps.api, deps.queue, deps.playback),\n ...createRatingsBridge(deps.api),\n ...createLibraryMutationsBridge(deps.api),\n ...createRecommendationsBridge(deps.api),\n };\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
export declare function createLibraryBridge(api: WebAppleMusicApiClient): {
|
|
3
|
+
getUserPlaylists(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
4
|
+
playlists: unknown[];
|
|
5
|
+
}>;
|
|
6
|
+
getLibrarySongs(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
7
|
+
songs: unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
getPlaylistSongs(musicUserToken: string, playlistId: string, _options: Record<string, unknown>): Promise<{
|
|
10
|
+
songs: unknown[];
|
|
11
|
+
}>;
|
|
12
|
+
getLibraryArtists(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
13
|
+
artists: unknown[];
|
|
14
|
+
}>;
|
|
15
|
+
getLibraryAlbums(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
16
|
+
albums: unknown[];
|
|
17
|
+
}>;
|
|
18
|
+
getLibraryMusicVideos(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
19
|
+
musicVideos: unknown[];
|
|
20
|
+
}>;
|
|
21
|
+
librarySearch(musicUserToken: string, term: string, types: string[], options: Record<string, unknown>): Promise<import("../bridge-responses").LibrarySearchPayload>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=library-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/library-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG/E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,sBAAsB;qCAEpB,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;oCAMzC,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;qCAMvC,MAAM,cAAc,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;sCAK5D,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;qCAMzC,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;0CAMnC,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;kCAWlE,MAAM,QAChB,MAAM,SACL,MAAM,EAAE,WACN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAarC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { paginationFromMap } from '../../web/pagination';
|
|
2
|
+
import { BridgeResponses } from '../bridge-responses';
|
|
3
|
+
export function createLibraryBridge(api) {
|
|
4
|
+
return {
|
|
5
|
+
async getUserPlaylists(musicUserToken, options) {
|
|
6
|
+
const pagination = paginationFromMap(options);
|
|
7
|
+
const playlists = await api.getUserPlaylists(musicUserToken, pagination.limit, pagination.offset);
|
|
8
|
+
return BridgeResponses.playlists(playlists);
|
|
9
|
+
},
|
|
10
|
+
async getLibrarySongs(musicUserToken, options) {
|
|
11
|
+
const pagination = paginationFromMap(options);
|
|
12
|
+
const songs = await api.getLibrarySongs(musicUserToken, pagination.limit, pagination.offset);
|
|
13
|
+
return BridgeResponses.songs(songs);
|
|
14
|
+
},
|
|
15
|
+
async getPlaylistSongs(musicUserToken, playlistId, _options) {
|
|
16
|
+
const songs = await api.getPlaylistTracks(musicUserToken, playlistId);
|
|
17
|
+
return BridgeResponses.songs(songs);
|
|
18
|
+
},
|
|
19
|
+
async getLibraryArtists(musicUserToken, options) {
|
|
20
|
+
const pagination = paginationFromMap(options);
|
|
21
|
+
const artists = await api.getLibraryArtists(musicUserToken, pagination.limit, pagination.offset);
|
|
22
|
+
return BridgeResponses.artists(artists);
|
|
23
|
+
},
|
|
24
|
+
async getLibraryAlbums(musicUserToken, options) {
|
|
25
|
+
const pagination = paginationFromMap(options);
|
|
26
|
+
const albums = await api.getLibraryAlbums(musicUserToken, pagination.limit, pagination.offset);
|
|
27
|
+
return BridgeResponses.albums(albums);
|
|
28
|
+
},
|
|
29
|
+
async getLibraryMusicVideos(musicUserToken, options) {
|
|
30
|
+
const pagination = paginationFromMap(options);
|
|
31
|
+
const musicVideos = await api.getLibraryMusicVideos(musicUserToken, pagination.limit, pagination.offset);
|
|
32
|
+
return BridgeResponses.musicVideos(musicVideos);
|
|
33
|
+
},
|
|
34
|
+
async librarySearch(musicUserToken, term, types, options) {
|
|
35
|
+
const pagination = paginationFromMap(options);
|
|
36
|
+
const result = await api.librarySearch(musicUserToken, term, types, pagination.limit, pagination.offset);
|
|
37
|
+
return BridgeResponses.librarySearch(result);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=library-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/library-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,UAAU,mBAAmB,CAAC,GAA2B;IAC7D,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,OAAgC;YAC7E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAClG,OAAO,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;QAED,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,OAAgC;YAC5E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAC7F,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,UAAkB,EAAE,QAAiC;YAClG,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;YACtE,OAAO,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,iBAAiB,CAAC,cAAsB,EAAE,OAAgC;YAC9E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACjG,OAAO,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,OAAgC;YAC7E,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YAC/F,OAAO,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,qBAAqB,CAAC,cAAsB,EAAE,OAAgC;YAClF,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,qBAAqB,CACjD,cAAc,EACd,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CAClB,CAAC;YACF,OAAO,eAAe,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,KAAK,CAAC,aAAa,CACjB,cAAsB,EACtB,IAAY,EACZ,KAAe,EACf,OAAgC;YAEhC,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,aAAa,CACpC,cAAc,EACd,IAAI,EACJ,KAAK,EACL,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CAClB,CAAC;YACF,OAAO,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { paginationFromMap } from '../../web/pagination';\nimport type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\nimport { BridgeResponses } from '../bridge-responses';\n\nexport function createLibraryBridge(api: WebAppleMusicApiClient) {\n return {\n async getUserPlaylists(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const playlists = await api.getUserPlaylists(musicUserToken, pagination.limit, pagination.offset);\n return BridgeResponses.playlists(playlists);\n },\n\n async getLibrarySongs(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const songs = await api.getLibrarySongs(musicUserToken, pagination.limit, pagination.offset);\n return BridgeResponses.songs(songs);\n },\n\n async getPlaylistSongs(musicUserToken: string, playlistId: string, _options: Record<string, unknown>) {\n const songs = await api.getPlaylistTracks(musicUserToken, playlistId);\n return BridgeResponses.songs(songs);\n },\n\n async getLibraryArtists(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const artists = await api.getLibraryArtists(musicUserToken, pagination.limit, pagination.offset);\n return BridgeResponses.artists(artists);\n },\n\n async getLibraryAlbums(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const albums = await api.getLibraryAlbums(musicUserToken, pagination.limit, pagination.offset);\n return BridgeResponses.albums(albums);\n },\n\n async getLibraryMusicVideos(musicUserToken: string, options: Record<string, unknown>) {\n const pagination = paginationFromMap(options);\n const musicVideos = await api.getLibraryMusicVideos(\n musicUserToken,\n pagination.limit,\n pagination.offset,\n );\n return BridgeResponses.musicVideos(musicVideos);\n },\n\n async librarySearch(\n musicUserToken: string,\n term: string,\n types: string[],\n options: Record<string, unknown>,\n ) {\n const pagination = paginationFromMap(options);\n const result = await api.librarySearch(\n musicUserToken,\n term,\n types,\n pagination.limit,\n pagination.offset,\n );\n return BridgeResponses.librarySearch(result);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
export declare function createLibraryMutationsBridge(api: WebAppleMusicApiClient): {
|
|
3
|
+
addToLibrary: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
4
|
+
createLibraryPlaylist(musicUserToken: string, options: Record<string, unknown>): Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
artworkUrl: string;
|
|
9
|
+
trackCount: number;
|
|
10
|
+
}>;
|
|
11
|
+
addTracksToLibraryPlaylist: (musicUserToken: string, playlistId: string, tracks: {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}[]) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=library-mutations-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-mutations-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/library-mutations-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE/E,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,sBAAsB;mCAE/B,MAAM,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;0CAItC,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;iDAWlE,MAAM,cACV,MAAM,UACV;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;EAK3C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function createLibraryMutationsBridge(api) {
|
|
2
|
+
return {
|
|
3
|
+
addToLibrary: async (musicUserToken, resourceIds) => {
|
|
4
|
+
await api.addToLibrary(musicUserToken, resourceIds);
|
|
5
|
+
},
|
|
6
|
+
async createLibraryPlaylist(musicUserToken, options) {
|
|
7
|
+
const name = String(options.name ?? '');
|
|
8
|
+
const description = options.description != null ? String(options.description) : null;
|
|
9
|
+
const isPublic = Boolean(options.isPublic ?? false);
|
|
10
|
+
const tracks = Array.isArray(options.tracks)
|
|
11
|
+
? options.tracks
|
|
12
|
+
: null;
|
|
13
|
+
return api.createLibraryPlaylist(musicUserToken, name, description, isPublic, tracks);
|
|
14
|
+
},
|
|
15
|
+
addTracksToLibraryPlaylist: async (musicUserToken, playlistId, tracks) => {
|
|
16
|
+
await api.addTracksToLibraryPlaylist(musicUserToken, playlistId, tracks);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=library-mutations-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-mutations-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/library-mutations-bridge.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B,CAAC,GAA2B;IACtE,OAAO;QACL,YAAY,EAAE,KAAK,EAAE,cAAsB,EAAE,WAAqC,EAAE,EAAE;YACpF,MAAM,GAAG,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,qBAAqB,CAAC,cAAsB,EAAE,OAAgC;YAClF,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACxC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACrF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;YACpD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;gBAC1C,CAAC,CAAE,OAAO,CAAC,MAAyC;gBACpD,CAAC,CAAC,IAAI,CAAC;YACT,OAAO,GAAG,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxF,CAAC;QAED,0BAA0B,EAAE,KAAK,EAC/B,cAAsB,EACtB,UAAkB,EAClB,MAAsC,EACtC,EAAE;YACF,MAAM,GAAG,CAAC,0BAA0B,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\n\nexport function createLibraryMutationsBridge(api: WebAppleMusicApiClient) {\n return {\n addToLibrary: async (musicUserToken: string, resourceIds: Record<string, string[]>) => {\n await api.addToLibrary(musicUserToken, resourceIds);\n },\n\n async createLibraryPlaylist(musicUserToken: string, options: Record<string, unknown>) {\n const name = String(options.name ?? '');\n const description = options.description != null ? String(options.description) : null;\n const isPublic = Boolean(options.isPublic ?? false);\n const tracks = Array.isArray(options.tracks)\n ? (options.tracks as { id: string; type: string }[])\n : null;\n return api.createLibraryPlaylist(musicUserToken, name, description, isPublic, tracks);\n },\n\n addTracksToLibraryPlaylist: async (\n musicUserToken: string,\n playlistId: string,\n tracks: { id: string; type: string }[],\n ) => {\n await api.addTracksToLibraryPlaylist(musicUserToken, playlistId, tracks);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
import type { WebPlaybackController } from '../../web/WebPlaybackController';
|
|
3
|
+
import type { WebQueueService } from '../../web/WebQueueService';
|
|
4
|
+
export declare function createPlayerBridge(api: WebAppleMusicApiClient, queue: WebQueueService, playback: WebPlaybackController): {
|
|
5
|
+
setPlaybackQueue(itemId: string, type: string): Promise<string>;
|
|
6
|
+
playLibrarySong(musicUserToken: string, songId: string): Promise<string>;
|
|
7
|
+
playLibraryPlaylist(musicUserToken: string, playlistId: string, startingAt: number): Promise<string>;
|
|
8
|
+
configurePlayer(mixWithOthers: boolean): Record<string, unknown>;
|
|
9
|
+
getCurrentState: () => Promise<Record<string, unknown>>;
|
|
10
|
+
play: () => void;
|
|
11
|
+
pause: () => void;
|
|
12
|
+
skipToNextEntry: () => void;
|
|
13
|
+
skipToPreviousEntry: () => void;
|
|
14
|
+
restartCurrentEntry: () => void;
|
|
15
|
+
seekToTime: (time: number) => void;
|
|
16
|
+
togglePlayerState: () => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=player-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/player-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,sBAAsB,EAC3B,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,qBAAqB;6BAGE,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;oCAK/B,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;wCAM5D,MAAM,cACV,MAAM,cACN,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC;mCAKa,OAAO;;;;;;;uBAqBnB,MAAM;;EAO5B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function createPlayerBridge(api, queue, playback) {
|
|
2
|
+
return {
|
|
3
|
+
async setPlaybackQueue(itemId, type) {
|
|
4
|
+
await queue.setQueue(itemId, type);
|
|
5
|
+
return 'Track(s) added to queue';
|
|
6
|
+
},
|
|
7
|
+
async playLibrarySong(musicUserToken, songId) {
|
|
8
|
+
await queue.playLibrarySong(musicUserToken, songId);
|
|
9
|
+
return 'Library song added to queue';
|
|
10
|
+
},
|
|
11
|
+
async playLibraryPlaylist(musicUserToken, playlistId, startingAt) {
|
|
12
|
+
await queue.playLibraryPlaylist(musicUserToken, playlistId, startingAt);
|
|
13
|
+
return 'Library playlist added to queue';
|
|
14
|
+
},
|
|
15
|
+
configurePlayer(mixWithOthers) {
|
|
16
|
+
return playback.configurePlayer(mixWithOthers);
|
|
17
|
+
},
|
|
18
|
+
getCurrentState: () => playback.currentState(),
|
|
19
|
+
play: () => {
|
|
20
|
+
void playback.play();
|
|
21
|
+
},
|
|
22
|
+
pause: () => {
|
|
23
|
+
void playback.pause();
|
|
24
|
+
},
|
|
25
|
+
skipToNextEntry: () => {
|
|
26
|
+
void playback.skipToNextEntry();
|
|
27
|
+
},
|
|
28
|
+
skipToPreviousEntry: () => {
|
|
29
|
+
void playback.skipToPreviousEntry();
|
|
30
|
+
},
|
|
31
|
+
restartCurrentEntry: () => {
|
|
32
|
+
void playback.restartCurrentEntry();
|
|
33
|
+
},
|
|
34
|
+
seekToTime: (time) => {
|
|
35
|
+
void playback.seekToTime(time);
|
|
36
|
+
},
|
|
37
|
+
togglePlayerState: () => {
|
|
38
|
+
void playback.togglePlayerState();
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=player-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/player-bridge.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,kBAAkB,CAChC,GAA2B,EAC3B,KAAsB,EACtB,QAA+B;IAE/B,OAAO;QACL,KAAK,CAAC,gBAAgB,CAAC,MAAc,EAAE,IAAY;YACjD,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACnC,OAAO,yBAAyB,CAAC;QACnC,CAAC;QAED,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,MAAc;YAC1D,MAAM,KAAK,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;YACpD,OAAO,6BAA6B,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,mBAAmB,CACvB,cAAsB,EACtB,UAAkB,EAClB,UAAkB;YAElB,MAAM,KAAK,CAAC,mBAAmB,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;YACxE,OAAO,iCAAiC,CAAC;QAC3C,CAAC;QAED,eAAe,CAAC,aAAsB;YACpC,OAAO,QAAQ,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACjD,CAAC;QAED,eAAe,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE;QAE9C,IAAI,EAAE,GAAG,EAAE;YACT,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,KAAK,QAAQ,CAAC,eAAe,EAAE,CAAC;QAClC,CAAC;QACD,mBAAmB,EAAE,GAAG,EAAE;YACxB,KAAK,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QACtC,CAAC;QACD,mBAAmB,EAAE,GAAG,EAAE;YACxB,KAAK,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QACtC,CAAC;QACD,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE;YAC3B,KAAK,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,iBAAiB,EAAE,GAAG,EAAE;YACtB,KAAK,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\nimport type { WebPlaybackController } from '../../web/WebPlaybackController';\nimport type { WebQueueService } from '../../web/WebQueueService';\n\nexport function createPlayerBridge(\n api: WebAppleMusicApiClient,\n queue: WebQueueService,\n playback: WebPlaybackController,\n) {\n return {\n async setPlaybackQueue(itemId: string, type: string): Promise<string> {\n await queue.setQueue(itemId, type);\n return 'Track(s) added to queue';\n },\n\n async playLibrarySong(musicUserToken: string, songId: string): Promise<string> {\n await queue.playLibrarySong(musicUserToken, songId);\n return 'Library song added to queue';\n },\n\n async playLibraryPlaylist(\n musicUserToken: string,\n playlistId: string,\n startingAt: number,\n ): Promise<string> {\n await queue.playLibraryPlaylist(musicUserToken, playlistId, startingAt);\n return 'Library playlist added to queue';\n },\n\n configurePlayer(mixWithOthers: boolean) {\n return playback.configurePlayer(mixWithOthers);\n },\n\n getCurrentState: () => playback.currentState(),\n\n play: () => {\n void playback.play();\n },\n pause: () => {\n void playback.pause();\n },\n skipToNextEntry: () => {\n void playback.skipToNextEntry();\n },\n skipToPreviousEntry: () => {\n void playback.skipToPreviousEntry();\n },\n restartCurrentEntry: () => {\n void playback.restartCurrentEntry();\n },\n seekToTime: (time: number) => {\n void playback.seekToTime(time);\n },\n togglePlayerState: () => {\n void playback.togglePlayerState();\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
export declare function createRatingsBridge(api: WebAppleMusicApiClient): {
|
|
3
|
+
getRating: (musicUserToken: string, resourceType: string, id: string) => Promise<{
|
|
4
|
+
id: string;
|
|
5
|
+
value: number;
|
|
6
|
+
} | null>;
|
|
7
|
+
setRating: (musicUserToken: string, resourceType: string, id: string, value: number) => Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
value: number;
|
|
10
|
+
} | null>;
|
|
11
|
+
clearRating: (musicUserToken: string, resourceType: string, id: string) => Promise<void>;
|
|
12
|
+
addToFavorites: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
13
|
+
removeFromFavorites: (musicUserToken: string, resourceIds: Record<string, string[]>) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=ratings-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ratings-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/ratings-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE/E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,sBAAsB;gCAE/B,MAAM,gBAAgB,MAAM,MAAM,MAAM;;;;gCAExC,MAAM,gBAAgB,MAAM,MAAM,MAAM,SAAS,MAAM;;;;kCAE/C,MAAM,gBAAgB,MAAM,MAAM,MAAM;qCAGrC,MAAM,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;0CAGxC,MAAM,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;EAI5F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function createRatingsBridge(api) {
|
|
2
|
+
return {
|
|
3
|
+
getRating: (musicUserToken, resourceType, id) => api.getRating(musicUserToken, resourceType, id),
|
|
4
|
+
setRating: (musicUserToken, resourceType, id, value) => api.setRating(musicUserToken, resourceType, id, value),
|
|
5
|
+
clearRating: async (musicUserToken, resourceType, id) => {
|
|
6
|
+
await api.clearRating(musicUserToken, resourceType, id);
|
|
7
|
+
},
|
|
8
|
+
addToFavorites: async (musicUserToken, resourceIds) => {
|
|
9
|
+
await api.addToFavorites(musicUserToken, resourceIds);
|
|
10
|
+
},
|
|
11
|
+
removeFromFavorites: async (musicUserToken, resourceIds) => {
|
|
12
|
+
await api.removeFromFavorites(musicUserToken, resourceIds);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ratings-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ratings-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/ratings-bridge.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,GAA2B;IAC7D,OAAO;QACL,SAAS,EAAE,CAAC,cAAsB,EAAE,YAAoB,EAAE,EAAU,EAAE,EAAE,CACtE,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,CAAC;QACjD,SAAS,EAAE,CAAC,cAAsB,EAAE,YAAoB,EAAE,EAAU,EAAE,KAAa,EAAE,EAAE,CACrF,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,CAAC;QACxD,WAAW,EAAE,KAAK,EAAE,cAAsB,EAAE,YAAoB,EAAE,EAAU,EAAE,EAAE;YAC9E,MAAM,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,cAAc,EAAE,KAAK,EAAE,cAAsB,EAAE,WAAqC,EAAE,EAAE;YACtF,MAAM,GAAG,CAAC,cAAc,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACxD,CAAC;QACD,mBAAmB,EAAE,KAAK,EAAE,cAAsB,EAAE,WAAqC,EAAE,EAAE;YAC3F,MAAM,GAAG,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\n\nexport function createRatingsBridge(api: WebAppleMusicApiClient) {\n return {\n getRating: (musicUserToken: string, resourceType: string, id: string) =>\n api.getRating(musicUserToken, resourceType, id),\n setRating: (musicUserToken: string, resourceType: string, id: string, value: number) =>\n api.setRating(musicUserToken, resourceType, id, value),\n clearRating: async (musicUserToken: string, resourceType: string, id: string) => {\n await api.clearRating(musicUserToken, resourceType, id);\n },\n addToFavorites: async (musicUserToken: string, resourceIds: Record<string, string[]>) => {\n await api.addToFavorites(musicUserToken, resourceIds);\n },\n removeFromFavorites: async (musicUserToken: string, resourceIds: Record<string, string[]>) => {\n await api.removeFromFavorites(musicUserToken, resourceIds);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';
|
|
2
|
+
export declare function createRecommendationsBridge(api: WebAppleMusicApiClient): {
|
|
3
|
+
getRecommendations(musicUserToken: string, ids: string[] | null): Promise<{
|
|
4
|
+
recommendations: unknown[];
|
|
5
|
+
}>;
|
|
6
|
+
getReplay(musicUserToken: string, year: number | null): Promise<{
|
|
7
|
+
summaries: unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=recommendations-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/handlers/recommendations-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG/E,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,sBAAsB;uCAE1B,MAAM,OAAO,MAAM,EAAE,GAAG,IAAI;;;8BAKrC,MAAM,QAAQ,MAAM,GAAG,IAAI;;;EAK9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BridgeResponses } from '../bridge-responses';
|
|
2
|
+
export function createRecommendationsBridge(api) {
|
|
3
|
+
return {
|
|
4
|
+
async getRecommendations(musicUserToken, ids) {
|
|
5
|
+
const recommendations = await api.getRecommendations(musicUserToken, ids);
|
|
6
|
+
return BridgeResponses.recommendations(recommendations);
|
|
7
|
+
},
|
|
8
|
+
async getReplay(musicUserToken, year) {
|
|
9
|
+
const summaries = await api.getReplay(musicUserToken, year);
|
|
10
|
+
return BridgeResponses.replaySummaries(summaries);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=recommendations-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations-bridge.js","sourceRoot":"","sources":["../../../src/bridge/handlers/recommendations-bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,UAAU,2BAA2B,CAAC,GAA2B;IACrE,OAAO;QACL,KAAK,CAAC,kBAAkB,CAAC,cAAsB,EAAE,GAAoB;YACnE,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,kBAAkB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;YAC1E,OAAO,eAAe,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QAC1D,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,cAAsB,EAAE,IAAmB;YACzD,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YAC5D,OAAO,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WebAppleMusicApiClient } from '../../web/WebAppleMusicApiClient';\nimport { BridgeResponses } from '../bridge-responses';\n\nexport function createRecommendationsBridge(api: WebAppleMusicApiClient) {\n return {\n async getRecommendations(musicUserToken: string, ids: string[] | null) {\n const recommendations = await api.getRecommendations(musicUserToken, ids);\n return BridgeResponses.recommendations(recommendations);\n },\n\n async getReplay(musicUserToken: string, year: number | null) {\n const summaries = await api.getReplay(musicUserToken, year);\n return BridgeResponses.replaySummaries(summaries);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge rejection codes shared across TypeScript, Android, and web.
|
|
3
|
+
* Native iOS maps the same strings where {@link Exception} is thrown; other iOS
|
|
4
|
+
* paths may surface {@link AppleMusicErrorCode.error} with a descriptive message.
|
|
5
|
+
*
|
|
6
|
+
* @see docs/ERROR_CODES.md
|
|
7
|
+
*/
|
|
8
|
+
export declare const AppleMusicErrorCode: {
|
|
9
|
+
/** Generic failure (message carries detail). */
|
|
10
|
+
readonly error: "ERROR";
|
|
11
|
+
/** Missing or invalid auth, subscription, or HTTP 403 from Apple Music API. */
|
|
12
|
+
readonly permissionDenied: "permissionDenied";
|
|
13
|
+
/** `Auth.authorize()` on Android/web without a developer JWT. */
|
|
14
|
+
readonly missingDeveloperToken: "MISSING_DEVELOPER_TOKEN";
|
|
15
|
+
readonly missingMusicUserToken: "MISSING_MUSIC_USER_TOKEN";
|
|
16
|
+
/** `Library` / `Player` called with a catalog id instead of `i.` / `l.` / `p.`. */
|
|
17
|
+
readonly invalidLibraryId: "INVALID_LIBRARY_ID";
|
|
18
|
+
/** Native playback queue / transport failure (Android; iOS playback events). */
|
|
19
|
+
readonly playbackError: "PLAYBACK_ERROR";
|
|
20
|
+
};
|
|
21
|
+
export type AppleMusicErrorCode = (typeof AppleMusicErrorCode)[keyof typeof AppleMusicErrorCode];
|
|
22
|
+
//# sourceMappingURL=apple-music-error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-error-codes.d.ts","sourceRoot":"","sources":["../../src/constants/apple-music-error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;IAC9B,gDAAgD;;IAEhD,+EAA+E;;IAE/E,iEAAiE;;;IAGjE,mFAAmF;;IAEnF,gFAAgF;;CAExE,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge rejection codes shared across TypeScript, Android, and web.
|
|
3
|
+
* Native iOS maps the same strings where {@link Exception} is thrown; other iOS
|
|
4
|
+
* paths may surface {@link AppleMusicErrorCode.error} with a descriptive message.
|
|
5
|
+
*
|
|
6
|
+
* @see docs/ERROR_CODES.md
|
|
7
|
+
*/
|
|
8
|
+
export const AppleMusicErrorCode = {
|
|
9
|
+
/** Generic failure (message carries detail). */
|
|
10
|
+
error: 'ERROR',
|
|
11
|
+
/** Missing or invalid auth, subscription, or HTTP 403 from Apple Music API. */
|
|
12
|
+
permissionDenied: 'permissionDenied',
|
|
13
|
+
/** `Auth.authorize()` on Android/web without a developer JWT. */
|
|
14
|
+
missingDeveloperToken: 'MISSING_DEVELOPER_TOKEN',
|
|
15
|
+
missingMusicUserToken: 'MISSING_MUSIC_USER_TOKEN',
|
|
16
|
+
/** `Library` / `Player` called with a catalog id instead of `i.` / `l.` / `p.`. */
|
|
17
|
+
invalidLibraryId: 'INVALID_LIBRARY_ID',
|
|
18
|
+
/** Native playback queue / transport failure (Android; iOS playback events). */
|
|
19
|
+
playbackError: 'PLAYBACK_ERROR',
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=apple-music-error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-error-codes.js","sourceRoot":"","sources":["../../src/constants/apple-music-error-codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,gDAAgD;IAChD,KAAK,EAAE,OAAO;IACd,+EAA+E;IAC/E,gBAAgB,EAAE,kBAAkB;IACpC,iEAAiE;IACjE,qBAAqB,EAAE,yBAAyB;IAChD,qBAAqB,EAAE,0BAA0B;IACjD,mFAAmF;IACnF,gBAAgB,EAAE,oBAAoB;IACtC,gFAAgF;IAChF,aAAa,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["/**\n * Bridge rejection codes shared across TypeScript, Android, and web.\n * Native iOS maps the same strings where {@link Exception} is thrown; other iOS\n * paths may surface {@link AppleMusicErrorCode.error} with a descriptive message.\n *\n * @see docs/ERROR_CODES.md\n */\nexport const AppleMusicErrorCode = {\n /** Generic failure (message carries detail). */\n error: 'ERROR',\n /** Missing or invalid auth, subscription, or HTTP 403 from Apple Music API. */\n permissionDenied: 'permissionDenied',\n /** `Auth.authorize()` on Android/web without a developer JWT. */\n missingDeveloperToken: 'MISSING_DEVELOPER_TOKEN',\n missingMusicUserToken: 'MISSING_MUSIC_USER_TOKEN',\n /** `Library` / `Player` called with a catalog id instead of `i.` / `l.` / `p.`. */\n invalidLibraryId: 'INVALID_LIBRARY_ID',\n /** Native playback queue / transport failure (Android; iOS playback events). */\n playbackError: 'PLAYBACK_ERROR',\n} as const;\n\nexport type AppleMusicErrorCode =\n (typeof AppleMusicErrorCode)[keyof typeof AppleMusicErrorCode];\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Song } from '../types/song';
|
|
2
|
+
/**
|
|
3
|
+
* Listens for changes from the native music player and updates the currentSong state.
|
|
4
|
+
*/
|
|
5
|
+
declare const useCurrentSong: () => {
|
|
6
|
+
song?: Song;
|
|
7
|
+
error?: Error;
|
|
8
|
+
};
|
|
9
|
+
export default useCurrentSong;
|
|
10
|
+
//# sourceMappingURL=use-current-song.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-current-song.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-song.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C;;GAEG;AACH,QAAA,MAAM,cAAc,QAAO;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CA+BtD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import Player from '../modules/player';
|
|
3
|
+
import { getErrorMessage } from '../utils/get-error-message';
|
|
4
|
+
/**
|
|
5
|
+
* Listens for changes from the native music player and updates the currentSong state.
|
|
6
|
+
*/
|
|
7
|
+
const useCurrentSong = () => {
|
|
8
|
+
const [currentSong, setCurrentSong] = useState();
|
|
9
|
+
const [error, setError] = useState();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
Player.getCurrentState()
|
|
12
|
+
.then((state) => setCurrentSong(state.currentSong))
|
|
13
|
+
.catch((err) => setError(new Error(getErrorMessage(err))));
|
|
14
|
+
const applyFromState = (state) => {
|
|
15
|
+
if (state?.currentSong) {
|
|
16
|
+
setError(undefined);
|
|
17
|
+
setCurrentSong(state.currentSong);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const songListener = Player.addListener('onCurrentSongChange', (event) => {
|
|
21
|
+
if (event?.currentSong) {
|
|
22
|
+
setError(undefined);
|
|
23
|
+
setCurrentSong(event.currentSong);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const stateListener = Player.addListener('onPlaybackStateChange', applyFromState);
|
|
27
|
+
return () => {
|
|
28
|
+
songListener.remove();
|
|
29
|
+
stateListener.remove();
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
return { song: currentSong, error };
|
|
33
|
+
};
|
|
34
|
+
export default useCurrentSong;
|
|
35
|
+
//# sourceMappingURL=use-current-song.js.map
|