@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 @@
|
|
|
1
|
+
{"version":3,"file":"use-current-song.js","sourceRoot":"","sources":["../../src/hooks/use-current-song.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,MAAM,cAAc,GAAG,GAAmC,EAAE;IAC1D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAQ,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,eAAe,EAAE;aACrB,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;aAClD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE7D,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC9C,IAAI,KAAK,EAAE,WAAW,EAAE,CAAC;gBACvB,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACpB,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;YACvE,IAAI,KAAK,EAAE,WAAW,EAAE,CAAC;gBACvB,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACpB,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;QAElF,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,MAAM,EAAE,CAAC;YACtB,aAAa,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport Player from '../modules/player';\nimport type { PlaybackState } from '../types/playback-state';\nimport type { Song } from '../types/song';\nimport { getErrorMessage } from '../utils/get-error-message';\n\n/**\n * Listens for changes from the native music player and updates the currentSong state.\n */\nconst useCurrentSong = (): { song?: Song; error?: Error } => {\n const [currentSong, setCurrentSong] = useState<Song>();\n const [error, setError] = useState<Error>();\n\n useEffect(() => {\n Player.getCurrentState()\n .then((state) => setCurrentSong(state.currentSong))\n .catch((err) => setError(new Error(getErrorMessage(err))));\n\n const applyFromState = (state: PlaybackState) => {\n if (state?.currentSong) {\n setError(undefined);\n setCurrentSong(state.currentSong);\n }\n };\n\n const songListener = Player.addListener('onCurrentSongChange', (event) => {\n if (event?.currentSong) {\n setError(undefined);\n setCurrentSong(event.currentSong);\n }\n });\n const stateListener = Player.addListener('onPlaybackStateChange', applyFromState);\n\n return () => {\n songListener.remove();\n stateListener.remove();\n };\n }, []);\n\n return { song: currentSong, error };\n};\n\nexport default useCurrentSong;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-playing.d.ts","sourceRoot":"","sources":["../../src/hooks/use-is-playing.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,YAAY,QAAO;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAoB3D,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import Player from '../modules/player';
|
|
3
|
+
import { PlaybackStatus } from '../types/playback-status';
|
|
4
|
+
import { getErrorMessage } from '../utils/get-error-message';
|
|
5
|
+
const useIsPlaying = () => {
|
|
6
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
7
|
+
const [error, setError] = useState();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
Player.getCurrentState()
|
|
10
|
+
.then((state) => setIsPlaying(state.playbackStatus === PlaybackStatus.PLAYING))
|
|
11
|
+
.catch((err) => setError(new Error(getErrorMessage(err))));
|
|
12
|
+
const listener = Player.addListener('onPlaybackStateChange', (state) => {
|
|
13
|
+
setError(undefined);
|
|
14
|
+
setIsPlaying(state.playbackStatus === PlaybackStatus.PLAYING);
|
|
15
|
+
});
|
|
16
|
+
return () => listener.remove();
|
|
17
|
+
}, []);
|
|
18
|
+
return { isPlaying, error };
|
|
19
|
+
};
|
|
20
|
+
export default useIsPlaying;
|
|
21
|
+
//# sourceMappingURL=use-is-playing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-playing.js","sourceRoot":"","sources":["../../src/hooks/use-is-playing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,YAAY,GAAG,GAA0C,EAAE;IAC/D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,eAAe,EAAE;aACrB,IAAI,CAAC,CAAC,KAAoB,EAAE,EAAE,CAC7B,YAAY,CAAC,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC,OAAO,CAAC,CAC9D;aACA,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,uBAAuB,EAAE,CAAC,KAAoB,EAAE,EAAE;YACpF,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,YAAY,CAAC,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport Player from '../modules/player';\nimport type { PlaybackState } from '../types/playback-state';\nimport { PlaybackStatus } from '../types/playback-status';\nimport { getErrorMessage } from '../utils/get-error-message';\n\nconst useIsPlaying = (): { isPlaying: boolean; error?: Error } => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [error, setError] = useState<Error>();\n\n useEffect(() => {\n Player.getCurrentState()\n .then((state: PlaybackState) =>\n setIsPlaying(state.playbackStatus === PlaybackStatus.PLAYING),\n )\n .catch((err) => setError(new Error(getErrorMessage(err))));\n\n const listener = Player.addListener('onPlaybackStateChange', (state: PlaybackState) => {\n setError(undefined);\n setIsPlaying(state.playbackStatus === PlaybackStatus.PLAYING);\n });\n\n return () => listener.remove();\n }, []);\n\n return { isPlaying, error };\n};\n\nexport default useIsPlaying;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlaybackStatus } from '../types/playback-status';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to track playback state (playbackTime, playbackStatus) from native events.
|
|
4
|
+
* Use with useCurrentSong for duration and Player.seekToTime() for seeking.
|
|
5
|
+
*/
|
|
6
|
+
declare const usePlaybackState: () => {
|
|
7
|
+
playbackTime: number;
|
|
8
|
+
playbackStatus: PlaybackStatus | string;
|
|
9
|
+
error?: Error;
|
|
10
|
+
};
|
|
11
|
+
export default usePlaybackState;
|
|
12
|
+
//# sourceMappingURL=use-playback-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-playback-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-playback-state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;;GAGG;AACH,QAAA,MAAM,gBAAgB,QAAO;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,cAAc,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;CA0Cf,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import Player from '../modules/player';
|
|
3
|
+
import { getErrorMessage } from '../utils/get-error-message';
|
|
4
|
+
/**
|
|
5
|
+
* Hook to track playback state (playbackTime, playbackStatus) from native events.
|
|
6
|
+
* Use with useCurrentSong for duration and Player.seekToTime() for seeking.
|
|
7
|
+
*/
|
|
8
|
+
const usePlaybackState = () => {
|
|
9
|
+
const [playbackTime, setPlaybackTime] = useState(0);
|
|
10
|
+
const [playbackStatus, setPlaybackStatus] = useState('stopped');
|
|
11
|
+
const [error, setError] = useState();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
Player.getCurrentState()
|
|
14
|
+
.then((state) => {
|
|
15
|
+
setPlaybackTime(state.playbackTime ?? 0);
|
|
16
|
+
setPlaybackStatus(state.playbackStatus ?? 'stopped');
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => setError(new Error(getErrorMessage(err))));
|
|
19
|
+
const stateListener = Player.addListener('onPlaybackStateChange', (next) => {
|
|
20
|
+
setError(undefined);
|
|
21
|
+
if (next.playbackTime !== undefined) {
|
|
22
|
+
setPlaybackTime(next.playbackTime);
|
|
23
|
+
}
|
|
24
|
+
if (next.playbackStatus !== undefined) {
|
|
25
|
+
setPlaybackStatus(next.playbackStatus);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const timeListener = Player.addListener('onPlaybackTimeUpdate', (next) => {
|
|
29
|
+
if (next.playbackTime !== undefined) {
|
|
30
|
+
setPlaybackTime(next.playbackTime);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
stateListener.remove();
|
|
35
|
+
timeListener.remove();
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
return { playbackTime, playbackStatus, error };
|
|
39
|
+
};
|
|
40
|
+
export default usePlaybackState;
|
|
41
|
+
//# sourceMappingURL=use-playback-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-playback-state.js","sourceRoot":"","sources":["../../src/hooks/use-playback-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AG,MAAM,CAAC,WAAW,CACrC,sBAAsB,EACtB,CAAC,IAA8B,EAAE,EAAE;YACjC,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBACpC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrC,CAAC;QACH,CAAC,CACF,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,MAAM,EAAE,CAAC;YACvB,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport Player from '../modules/player';\nimport type { PlaybackState } from '../types/playback-state';\nimport type { PlaybackStatus } from '../types/playback-status';\nimport { getErrorMessage } from '../utils/get-error-message';\n\n/**\n * Hook to track playback state (playbackTime, playbackStatus) from native events.\n * Use with useCurrentSong for duration and Player.seekToTime() for seeking.\n */\nconst usePlaybackState = (): {\n playbackTime: number;\n playbackStatus: PlaybackStatus | string;\n error?: Error;\n} => {\n const [playbackTime, setPlaybackTime] = useState(0);\n const [playbackStatus, setPlaybackStatus] = useState<PlaybackStatus | string>('stopped');\n const [error, setError] = useState<Error>();\n\n useEffect(() => {\n Player.getCurrentState()\n .then((state: PlaybackState) => {\n setPlaybackTime(state.playbackTime ?? 0);\n setPlaybackStatus(state.playbackStatus ?? 'stopped');\n })\n .catch((err) => setError(new Error(getErrorMessage(err))));\n\n const stateListener = Player.addListener('onPlaybackStateChange', (next: PlaybackState) => {\n setError(undefined);\n\n if (next.playbackTime !== undefined) {\n setPlaybackTime(next.playbackTime);\n }\n\n if (next.playbackStatus !== undefined) {\n setPlaybackStatus(next.playbackStatus);\n }\n });\n\n const timeListener = Player.addListener(\n 'onPlaybackTimeUpdate',\n (next: { playbackTime: number }) => {\n if (next.playbackTime !== undefined) {\n setPlaybackTime(next.playbackTime);\n }\n },\n );\n\n return () => {\n stateListener.remove();\n timeListener.remove();\n };\n }, []);\n\n return { playbackTime, playbackStatus, error };\n};\n\nexport default usePlaybackState;\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type { PlaybackState } from './types/playback-state';
|
|
2
|
+
export * from './types/song';
|
|
3
|
+
export * from './types/playback-status';
|
|
4
|
+
export * from './types/catalog-search';
|
|
5
|
+
export * from './types/catalog-resource-type';
|
|
6
|
+
export * from './types/library-search';
|
|
7
|
+
export * from './types/library-music-videos';
|
|
8
|
+
export * from './types/album';
|
|
9
|
+
export * from './types/auth-status';
|
|
10
|
+
export type { AuthorizeResult } from './types/authorize-result';
|
|
11
|
+
export type { AndroidAuthorizeOptions } from './types/android-authorize-options';
|
|
12
|
+
export { isJwtExpired as isDeveloperTokenExpired } from './api/decode-jwt-exp';
|
|
13
|
+
export * from './types/check-subscription';
|
|
14
|
+
export * from './types/music-item';
|
|
15
|
+
export * from './types/tracks-from-library';
|
|
16
|
+
export * from './types/playlist';
|
|
17
|
+
export * from './types/pagination';
|
|
18
|
+
export * from './types/artist';
|
|
19
|
+
export * from './types/storefront';
|
|
20
|
+
export * from './types/recent-resource';
|
|
21
|
+
export * from './types/station';
|
|
22
|
+
export * from './types/music-video';
|
|
23
|
+
export * from './types/albums-response';
|
|
24
|
+
export * from './types/catalog-album-tracks';
|
|
25
|
+
export * from './types/catalog-charts';
|
|
26
|
+
export * from './types/rating';
|
|
27
|
+
export * from './types/library-mutations';
|
|
28
|
+
export * from './types/recommendation';
|
|
29
|
+
import useCurrentSong from './hooks/use-current-song';
|
|
30
|
+
import useIsPlaying from './hooks/use-is-playing';
|
|
31
|
+
import usePlaybackState from './hooks/use-playback-state';
|
|
32
|
+
import Auth from './modules/auth';
|
|
33
|
+
import Catalog from './modules/catalog';
|
|
34
|
+
import History from './modules/history';
|
|
35
|
+
import Library from './modules/library';
|
|
36
|
+
import LibraryMutations from './modules/library-mutations';
|
|
37
|
+
import Player from './modules/player';
|
|
38
|
+
import Ratings from './modules/ratings';
|
|
39
|
+
import Recommendations from './modules/recommendations';
|
|
40
|
+
export type { LibrarySongsResponse } from './modules/library';
|
|
41
|
+
export type { CatalogByIdsResult } from './modules/catalog';
|
|
42
|
+
export type { RecentlyPlayedTracksResponse } from './modules/history';
|
|
43
|
+
export type { PlayerConfig, PlaybackError, PlaybackTimeUpdate, CurrentSongChangeEvent, PlayerEventMap, } from './modules/player';
|
|
44
|
+
export type { AppleMusicError } from './utils/apple-music-error';
|
|
45
|
+
export * from './constants/apple-music-error-codes';
|
|
46
|
+
export { isLibraryId } from './api/library-ids';
|
|
47
|
+
export { isLibraryItem } from './utils/is-library-item';
|
|
48
|
+
export { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET, normalizePaginationOptions, } from './api/pagination';
|
|
49
|
+
export { normalizeNativeError } from './api/call-native';
|
|
50
|
+
export { getErrorMessage } from './utils/get-error-message';
|
|
51
|
+
export { useCurrentSong, useIsPlaying, usePlaybackState, Auth, Catalog, History, Library, LibraryMutations, Player, Ratings, Recommendations, };
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,cAAc,cAAc,CAAC;AAE7B,cAAc,yBAAyB,CAAC;AAExC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,eAAe,CAAC;AAE9B,cAAc,qBAAqB,CAAC;AAEpC,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,YAAY,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAA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E,MAAM,2BAA2B,CAAC;AAEjE,cAAc,qCAAqC,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,eAAe,GAChB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export * from './types/song';
|
|
2
|
+
export * from './types/playback-status';
|
|
3
|
+
export * from './types/catalog-search';
|
|
4
|
+
export * from './types/catalog-resource-type';
|
|
5
|
+
export * from './types/library-search';
|
|
6
|
+
export * from './types/library-music-videos';
|
|
7
|
+
export * from './types/album';
|
|
8
|
+
export * from './types/auth-status';
|
|
9
|
+
export { isJwtExpired as isDeveloperTokenExpired } from './api/decode-jwt-exp';
|
|
10
|
+
export * from './types/check-subscription';
|
|
11
|
+
export * from './types/music-item';
|
|
12
|
+
export * from './types/tracks-from-library';
|
|
13
|
+
export * from './types/playlist';
|
|
14
|
+
export * from './types/pagination';
|
|
15
|
+
export * from './types/artist';
|
|
16
|
+
export * from './types/storefront';
|
|
17
|
+
export * from './types/recent-resource';
|
|
18
|
+
export * from './types/station';
|
|
19
|
+
export * from './types/music-video';
|
|
20
|
+
export * from './types/albums-response';
|
|
21
|
+
export * from './types/catalog-album-tracks';
|
|
22
|
+
export * from './types/catalog-charts';
|
|
23
|
+
export * from './types/rating';
|
|
24
|
+
export * from './types/library-mutations';
|
|
25
|
+
export * from './types/recommendation';
|
|
26
|
+
import useCurrentSong from './hooks/use-current-song';
|
|
27
|
+
import useIsPlaying from './hooks/use-is-playing';
|
|
28
|
+
import usePlaybackState from './hooks/use-playback-state';
|
|
29
|
+
import Auth from './modules/auth';
|
|
30
|
+
import Catalog from './modules/catalog';
|
|
31
|
+
import History from './modules/history';
|
|
32
|
+
import Library from './modules/library';
|
|
33
|
+
import LibraryMutations from './modules/library-mutations';
|
|
34
|
+
import Player from './modules/player';
|
|
35
|
+
import Ratings from './modules/ratings';
|
|
36
|
+
import Recommendations from './modules/recommendations';
|
|
37
|
+
export * from './constants/apple-music-error-codes';
|
|
38
|
+
export { isLibraryId } from './api/library-ids';
|
|
39
|
+
export { isLibraryItem } from './utils/is-library-item';
|
|
40
|
+
export { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET, normalizePaginationOptions, } from './api/pagination';
|
|
41
|
+
export { normalizeNativeError } from './api/call-native';
|
|
42
|
+
export { getErrorMessage } from './utils/get-error-message';
|
|
43
|
+
export { useCurrentSong, useIsPlaying, usePlaybackState, Auth, Catalog, History, Library, LibraryMutations, Player, Ratings, Recommendations, };
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAE7B,cAAc,yBAAyB,CAAC;AAExC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,wBAAwB,CAAC;AAEvC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,eAAe,CAAC;AAE9B,cAAc,qBAAqB,CAAC;AAMpC,OAAO,EAAE,YAAY,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/E,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,kBAAkB,CAAC;AAEjC,cA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ent":["export type { PlaybackState } from './types/playback-state';\n\nexport * from './types/song';\n\nexport * from './types/playback-status';\n\nexport * from './types/catalog-search';\n\nexport * from './types/catalog-resource-type';\n\nexport * from './types/library-search';\n\nexport * from './types/library-music-videos';\n\nexport * from './types/album';\n\nexport * from './types/auth-status';\n\nexport type { AuthorizeResult } from './types/authorize-result';\n\nexport type { AndroidAuthorizeOptions } from './types/android-authorize-options';\n\nexport { isJwtExpired as isDeveloperTokenExpired } from './api/decode-jwt-exp';\n\nexport * from './types/check-subscription';\n\nexport * from './types/music-item';\n\nexport * from './types/tracks-from-library';\n\nexport * from './types/playlist';\n\nexport * from './types/pagination';\n\nexport * from './types/artist';\n\nexport * from './types/storefront';\n\nexport * from './types/recent-resource';\n\nexport * from './types/station';\n\nexport * from './types/music-video';\n\nexport * from './types/albums-response';\n\nexport * from './types/catalog-album-tracks';\n\nexport * from './types/catalog-charts';\n\nexport * from './types/rating';\n\nexport * from './types/library-mutations';\n\nexport * from './types/recommendation';\n\nimport useCurrentSong from './hooks/use-current-song';\nimport useIsPlaying from './hooks/use-is-playing';\nimport usePlaybackState from './hooks/use-playback-state';\nimport Auth from './modules/auth';\nimport Catalog from './modules/catalog';\nimport History from './modules/history';\nimport Library from './modules/library';\nimport LibraryMutations from './modules/library-mutations';\nimport Player from './modules/player';\nimport Ratings from './modules/ratings';\nimport Recommendations from './modules/recommendations';\n\nexport type { LibrarySongsResponse } from './modules/library';\n\nexport type { CatalogByIdsResult } from './modules/catalog';\n\nexport type { RecentlyPlayedTracksResponse } from './modules/history';\n\nexport type {\n PlayerConfig,\n PlaybackError,\n PlaybackTimeUpdate,\n CurrentSongChangeEvent,\n PlayerEventMap,\n} from './modules/player';\n\nexport type { AppleMusicError } from './utils/apple-music-error';\n\nexport * from './constants/apple-music-error-codes';\n\nexport { isLibraryId } from './api/library-ids';\n\nexport { isLibraryItem } from './utils/is-library-item';\n\nexport {\n DEFAULT_PAGINATION_LIMIT,\n DEFAULT_PAGINATION_OFFSET,\n normalizePaginationOptions,\n} from './api/pagination';\n\nexport { normalizeNativeError } from './api/call-native';\n\nexport { getErrorMessage } from './utils/get-error-message';\n\nexport {\n useCurrentSong,\n useIsPlaying,\n usePlaybackState,\n Auth,\n Catalog,\n History,\n Library,\n LibraryMutations,\n Player,\n Ratings,\n Recommendations,\n};\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference mapper for Apple Music API JSON — mirrors {@link AppleMusicJsonMapper.kt}.
|
|
3
|
+
* Used by fixture tests; native code remains the runtime source of truth.
|
|
4
|
+
*/
|
|
5
|
+
export interface AppleMusicApiResource {
|
|
6
|
+
id?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
attributes?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
declare function catalogPlaybackId(resource: AppleMusicApiResource): string | undefined;
|
|
11
|
+
export declare function mapSong(resource: AppleMusicApiResource): {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
artistName: string;
|
|
15
|
+
artworkUrl: string;
|
|
16
|
+
duration: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function mapAlbum(resource: AppleMusicApiResource): {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
artistName: string;
|
|
22
|
+
artworkUrl: string;
|
|
23
|
+
trackCount: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function mapArtist(resource: AppleMusicApiResource): {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
artworkUrl: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function mapPlaylist(resource: AppleMusicApiResource): {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
artworkUrl: string;
|
|
35
|
+
trackCount: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function mapRecentResource(resource: AppleMusicApiResource): {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
subtitle: string;
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function mapRecentlyPlayed(resource: AppleMusicApiResource): {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
subtitle: string;
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function mapStation(resource: AppleMusicApiResource): {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
artworkUrl: string;
|
|
53
|
+
};
|
|
54
|
+
export declare function mapMusicVideo(resource: AppleMusicApiResource): {
|
|
55
|
+
id: string;
|
|
56
|
+
title: string;
|
|
57
|
+
artistName: string;
|
|
58
|
+
artworkUrl: string;
|
|
59
|
+
duration: number;
|
|
60
|
+
};
|
|
61
|
+
export declare function mapRecommendation(resource: AppleMusicApiResource): {
|
|
62
|
+
id: string;
|
|
63
|
+
title: string;
|
|
64
|
+
resourceTypes: string[];
|
|
65
|
+
playlists: {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
artworkUrl: string;
|
|
70
|
+
trackCount: number;
|
|
71
|
+
}[];
|
|
72
|
+
albums: {
|
|
73
|
+
id: string;
|
|
74
|
+
title: string;
|
|
75
|
+
artistName: string;
|
|
76
|
+
artworkUrl: string;
|
|
77
|
+
trackCount: number;
|
|
78
|
+
}[];
|
|
79
|
+
stations: {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
artworkUrl: string;
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
/** Maps `GET/PUT /v1/me/ratings/...` envelope — same shape on iOS REST, Android, and web. */
|
|
86
|
+
export declare function mapRating(response: {
|
|
87
|
+
data?: AppleMusicApiResource[];
|
|
88
|
+
}): {
|
|
89
|
+
id: string;
|
|
90
|
+
value: number;
|
|
91
|
+
} | null;
|
|
92
|
+
export declare function mapReplaySummary(resource: AppleMusicApiResource): Record<string, unknown>;
|
|
93
|
+
export { catalogPlaybackId };
|
|
94
|
+
//# sourceMappingURL=apple-music-json-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-json-mapper.d.ts","sourceRoot":"","sources":["../../src/mappers/apple-music-json-mapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAoBD,iBAAS,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAY9E;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,qBAAqB;;;;;;EAUtD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,qBAAqB;;;;;;EASvD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,qBAAqB;;;;EAOxD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,qBAAqB;;;;;;EAgB1D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB;;;;;EAwBhE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB;;;;;EAEhE;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,qBAAqB;;;;EAOzD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,qBAAqB;;;;;;EAU5D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;EAmBhE;AA0BD,6FAA6F;AAC7F,wBAAgB,SAAS,CACvB,QAAQ,EAAE;IAAE,IAAI,CAAC,EAAE,qBAAqB,EAAE,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgBtC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,2BAiB/D;AAiBD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference mapper for Apple Music API JSON — mirrors {@link AppleMusicJsonMapper.kt}.
|
|
3
|
+
* Used by fixture tests; native code remains the runtime source of truth.
|
|
4
|
+
*/
|
|
5
|
+
function artworkUrl(artwork, width = 200, height = 200) {
|
|
6
|
+
const template = artwork?.url;
|
|
7
|
+
if (typeof template !== 'string' || !template) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
return template.replace('{w}', String(width)).replace('{h}', String(height));
|
|
11
|
+
}
|
|
12
|
+
function durationMillis(attributes) {
|
|
13
|
+
if (typeof attributes.durationInMillis === 'number') {
|
|
14
|
+
return attributes.durationInMillis;
|
|
15
|
+
}
|
|
16
|
+
if (typeof attributes.duration === 'number') {
|
|
17
|
+
return Math.floor(attributes.duration * 1000);
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
function catalogPlaybackId(resource) {
|
|
22
|
+
const playParams = resource.attributes?.playParams;
|
|
23
|
+
if (!playParams) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
if (typeof playParams.id === 'string' && playParams.id) {
|
|
27
|
+
return playParams.id;
|
|
28
|
+
}
|
|
29
|
+
if (typeof playParams.catalogId === 'string' && playParams.catalogId) {
|
|
30
|
+
return playParams.catalogId;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
export function mapSong(resource) {
|
|
35
|
+
const attributes = resource.attributes ?? {};
|
|
36
|
+
const id = catalogPlaybackId(resource) ?? resource.id ?? '';
|
|
37
|
+
return {
|
|
38
|
+
id,
|
|
39
|
+
title: String(attributes.name ?? ''),
|
|
40
|
+
artistName: String(attributes.artistName ?? ''),
|
|
41
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
42
|
+
duration: durationMillis(attributes),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function mapAlbum(resource) {
|
|
46
|
+
const attributes = resource.attributes ?? {};
|
|
47
|
+
return {
|
|
48
|
+
id: resource.id ?? '',
|
|
49
|
+
title: String(attributes.name ?? ''),
|
|
50
|
+
artistName: String(attributes.artistName ?? ''),
|
|
51
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
52
|
+
trackCount: Number(attributes.trackCount ?? 0),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function mapArtist(resource) {
|
|
56
|
+
const attributes = resource.attributes ?? {};
|
|
57
|
+
return {
|
|
58
|
+
id: resource.id ?? '',
|
|
59
|
+
name: String(attributes.name ?? ''),
|
|
60
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function mapPlaylist(resource) {
|
|
64
|
+
const attributes = resource.attributes ?? {};
|
|
65
|
+
const description = attributes.description;
|
|
66
|
+
const descriptionText = typeof description === 'string'
|
|
67
|
+
? description
|
|
68
|
+
: typeof description === 'object' && description !== null && 'standard' in description
|
|
69
|
+
? String(description.standard ?? '')
|
|
70
|
+
: '';
|
|
71
|
+
return {
|
|
72
|
+
id: resource.id ?? '',
|
|
73
|
+
name: String(attributes.name ?? ''),
|
|
74
|
+
description: descriptionText,
|
|
75
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
76
|
+
trackCount: Number(attributes.trackCount ?? 0),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function mapRecentResource(resource) {
|
|
80
|
+
const attributes = resource.attributes ?? {};
|
|
81
|
+
const apiType = resource.type ?? '';
|
|
82
|
+
const itemType = apiType.includes('album')
|
|
83
|
+
? 'album'
|
|
84
|
+
: apiType.includes('playlist')
|
|
85
|
+
? 'playlist'
|
|
86
|
+
: apiType.includes('station')
|
|
87
|
+
? 'station'
|
|
88
|
+
: 'unknown';
|
|
89
|
+
const subtitle = String(attributes.artistName ?? '').trim() ||
|
|
90
|
+
String(attributes.curatorName ?? '').trim() ||
|
|
91
|
+
(typeof attributes.description === 'object' &&
|
|
92
|
+
attributes.description !== null &&
|
|
93
|
+
'standard' in attributes.description
|
|
94
|
+
? String(attributes.description.standard ?? '')
|
|
95
|
+
: '');
|
|
96
|
+
return {
|
|
97
|
+
id: resource.id ?? '',
|
|
98
|
+
title: String(attributes.name ?? ''),
|
|
99
|
+
subtitle,
|
|
100
|
+
type: itemType,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function mapRecentlyPlayed(resource) {
|
|
104
|
+
return mapRecentResource(resource);
|
|
105
|
+
}
|
|
106
|
+
export function mapStation(resource) {
|
|
107
|
+
const attributes = resource.attributes ?? {};
|
|
108
|
+
return {
|
|
109
|
+
id: resource.id ?? '',
|
|
110
|
+
name: String(attributes.name ?? ''),
|
|
111
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export function mapMusicVideo(resource) {
|
|
115
|
+
const attributes = resource.attributes ?? {};
|
|
116
|
+
const id = catalogPlaybackId(resource) ?? resource.id ?? '';
|
|
117
|
+
return {
|
|
118
|
+
id,
|
|
119
|
+
title: String(attributes.name ?? ''),
|
|
120
|
+
artistName: String(attributes.artistName ?? ''),
|
|
121
|
+
artworkUrl: artworkUrl(attributes.artwork),
|
|
122
|
+
duration: durationMillis(attributes),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export function mapRecommendation(resource) {
|
|
126
|
+
const attributes = resource.attributes ?? {};
|
|
127
|
+
const titleObj = attributes.title;
|
|
128
|
+
const resourceTypes = [];
|
|
129
|
+
const types = attributes.resourceTypes;
|
|
130
|
+
if (Array.isArray(types)) {
|
|
131
|
+
for (const entry of types) {
|
|
132
|
+
resourceTypes.push(String(entry));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const contents = mapRecommendationContents(resource);
|
|
136
|
+
return {
|
|
137
|
+
id: resource.id ?? '',
|
|
138
|
+
title: String(titleObj?.stringForDisplay ?? ''),
|
|
139
|
+
resourceTypes,
|
|
140
|
+
playlists: contents.playlists,
|
|
141
|
+
albums: contents.albums,
|
|
142
|
+
stations: contents.stations,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function mapRecommendationContents(resource) {
|
|
146
|
+
const playlists = [];
|
|
147
|
+
const albums = [];
|
|
148
|
+
const stations = [];
|
|
149
|
+
const relationships = resource;
|
|
150
|
+
const data = relationships.relationships?.contents?.data;
|
|
151
|
+
if (!data) {
|
|
152
|
+
return { playlists, albums, stations };
|
|
153
|
+
}
|
|
154
|
+
for (const item of data) {
|
|
155
|
+
const type = item.type ?? '';
|
|
156
|
+
if (type.includes('playlist')) {
|
|
157
|
+
playlists.push(mapPlaylist(item));
|
|
158
|
+
}
|
|
159
|
+
else if (type.includes('album')) {
|
|
160
|
+
albums.push(mapAlbum(item));
|
|
161
|
+
}
|
|
162
|
+
else if (type.includes('station')) {
|
|
163
|
+
stations.push(mapStation(item));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { playlists, albums, stations };
|
|
167
|
+
}
|
|
168
|
+
/** Maps `GET/PUT /v1/me/ratings/...` envelope — same shape on iOS REST, Android, and web. */
|
|
169
|
+
export function mapRating(response) {
|
|
170
|
+
const first = response.data?.[0];
|
|
171
|
+
if (!first) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const attributes = first.attributes ?? {};
|
|
175
|
+
const raw = attributes.value;
|
|
176
|
+
const value = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : Number.NaN;
|
|
177
|
+
if (Number.isNaN(value)) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
id: first.id ?? '',
|
|
182
|
+
value,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export function mapReplaySummary(resource) {
|
|
186
|
+
const attributes = resource.attributes ?? {};
|
|
187
|
+
const topSongs = mapRelationshipResources(resource, 'top-songs', mapSong);
|
|
188
|
+
const topAlbums = mapRelationshipResources(resource, 'top-albums', mapAlbum);
|
|
189
|
+
const topArtists = mapRelationshipResources(resource, 'top-artists', mapArtist);
|
|
190
|
+
const result = {
|
|
191
|
+
id: resource.id ?? '',
|
|
192
|
+
type: resource.type ?? '',
|
|
193
|
+
name: String(attributes.name ?? ''),
|
|
194
|
+
topSongs,
|
|
195
|
+
topAlbums,
|
|
196
|
+
topArtists,
|
|
197
|
+
};
|
|
198
|
+
if (attributes.year !== undefined) {
|
|
199
|
+
result.year = Number(attributes.year);
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
function mapRelationshipResources(resource, relationshipKey, mapper) {
|
|
204
|
+
const relationships = resource;
|
|
205
|
+
const data = relationships.relationships?.[relationshipKey]?.data;
|
|
206
|
+
if (!data) {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
return data.map(mapper);
|
|
210
|
+
}
|
|
211
|
+
export { catalogPlaybackId };
|
|
212
|
+
//# sourceMappingURL=apple-music-json-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-json-mapper.js","sourceRoot":"","sources":["../../src/mappers/apple-music-json-mapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,SAAS,UAAU,CAAC,OAA4C,EAAE,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG;IACzF,MAAM,QAAQ,GAAG,OAAO,EAAE,GAAG,CAAC;IAC9B,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,cA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AE,aAAa,EAAE,SAAS,CAAC,CAAC;IAChF,MAAM,MAAM,GAA4B;QACtC,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE;QACrB,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;QACzB,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,QAAQ;QACR,SAAS;QACT,UAAU;KACX,CAAC;IACF,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,wBAAwB,CAC/B,QAA+B,EAC/B,eAAuB,EACvB,MAA0C;IAE1C,MAAM,aAAa,GAAG,QAErB,CAAC;IACF,MAAM,IAAI,GAAG,aAAa,CAAC,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC;IAClE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["/**\n * Reference mapper for Apple Music API JSON — mirrors {@link AppleMusicJsonMapper.kt}.\n * Used by fixture tests; native code remains the runtime source of truth.\n */\n\nexport interface AppleMusicApiResource {\n id?: string;\n type?: string;\n attributes?: Record<string, unknown>;\n}\n\nfunction artworkUrl(artwork: Record<string, unknown> | undefined, width = 200, height = 200): string {\n const template = artwork?.url;\n if (typeof template !== 'string' || !template) {\n return '';\n }\n return template.replace('{w}', String(width)).replace('{h}', String(height));\n}\n\nfunction durationMillis(attributes: Record<string, unknown>): number {\n if (typeof attributes.durationInMillis === 'number') {\n return attributes.durationInMillis;\n }\n if (typeof attributes.duration === 'number') {\n return Math.floor(attributes.duration * 1000);\n }\n return 0;\n}\n\nfunction catalogPlaybackId(resource: AppleMusicApiResource): string | undefined {\n const playParams = resource.attributes?.playParams as Record<string, unknown> | undefined;\n if (!playParams) {\n return undefined;\n }\n if (typeof playParams.id === 'string' && playParams.id) {\n return playParams.id;\n }\n if (typeof playParams.catalogId === 'string' && playParams.catalogId) {\n return playParams.catalogId;\n }\n return undefined;\n}\n\nexport function mapSong(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const id = catalogPlaybackId(resource) ?? resource.id ?? '';\n return {\n id,\n title: String(attributes.name ?? ''),\n artistName: String(attributes.artistName ?? ''),\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n duration: durationMillis(attributes),\n };\n}\n\nexport function mapAlbum(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n return {\n id: resource.id ?? '',\n title: String(attributes.name ?? ''),\n artistName: String(attributes.artistName ?? ''),\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n trackCount: Number(attributes.trackCount ?? 0),\n };\n}\n\nexport function mapArtist(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n return {\n id: resource.id ?? '',\n name: String(attributes.name ?? ''),\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n };\n}\n\nexport function mapPlaylist(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const description = attributes.description;\n const descriptionText =\n typeof description === 'string'\n ? description\n : typeof description === 'object' && description !== null && 'standard' in description\n ? String((description as { standard?: string }).standard ?? '')\n : '';\n return {\n id: resource.id ?? '',\n name: String(attributes.name ?? ''),\n description: descriptionText,\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n trackCount: Number(attributes.trackCount ?? 0),\n };\n}\n\nexport function mapRecentResource(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const apiType = resource.type ?? '';\n const itemType = apiType.includes('album')\n ? 'album'\n : apiType.includes('playlist')\n ? 'playlist'\n : apiType.includes('station')\n ? 'station'\n : 'unknown';\n const subtitle =\n String(attributes.artistName ?? '').trim() ||\n String(attributes.curatorName ?? '').trim() ||\n (typeof attributes.description === 'object' &&\n attributes.description !== null &&\n 'standard' in attributes.description\n ? String((attributes.description as { standard?: string }).standard ?? '')\n : '');\n return {\n id: resource.id ?? '',\n title: String(attributes.name ?? ''),\n subtitle,\n type: itemType,\n };\n}\n\nexport function mapRecentlyPlayed(resource: AppleMusicApiResource) {\n return mapRecentResource(resource);\n}\n\nexport function mapStation(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n return {\n id: resource.id ?? '',\n name: String(attributes.name ?? ''),\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n };\n}\n\nexport function mapMusicVideo(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const id = catalogPlaybackId(resource) ?? resource.id ?? '';\n return {\n id,\n title: String(attributes.name ?? ''),\n artistName: String(attributes.artistName ?? ''),\n artworkUrl: artworkUrl(attributes.artwork as Record<string, unknown> | undefined),\n duration: durationMillis(attributes),\n };\n}\n\nexport function mapRecommendation(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const titleObj = attributes.title as { stringForDisplay?: string } | undefined;\n const resourceTypes: string[] = [];\n const types = attributes.resourceTypes;\n if (Array.isArray(types)) {\n for (const entry of types) {\n resourceTypes.push(String(entry));\n }\n }\n const contents = mapRecommendationContents(resource);\n return {\n id: resource.id ?? '',\n title: String(titleObj?.stringForDisplay ?? ''),\n resourceTypes,\n playlists: contents.playlists,\n albums: contents.albums,\n stations: contents.stations,\n };\n}\n\nfunction mapRecommendationContents(resource: AppleMusicApiResource) {\n const playlists: ReturnType<typeof mapPlaylist>[] = [];\n const albums: ReturnType<typeof mapAlbum>[] = [];\n const stations: ReturnType<typeof mapStation>[] = [];\n const relationships = resource as AppleMusicApiResource & {\n relationships?: { contents?: { data?: AppleMusicApiResource[] } };\n };\n const data = relationships.relationships?.contents?.data;\n if (!data) {\n return { playlists, albums, stations };\n }\n for (const item of data) {\n const type = item.type ?? '';\n if (type.includes('playlist')) {\n playlists.push(mapPlaylist(item));\n } else if (type.includes('album')) {\n albums.push(mapAlbum(item));\n } else if (type.includes('station')) {\n stations.push(mapStation(item));\n }\n }\n return { playlists, albums, stations };\n}\n\n/** Maps `GET/PUT /v1/me/ratings/...` envelope — same shape on iOS REST, Android, and web. */\nexport function mapRating(\n response: { data?: AppleMusicApiResource[] },\n): { id: string; value: number } | null {\n const first = response.data?.[0];\n if (!first) {\n return null;\n }\n const attributes = first.attributes ?? {};\n const raw = attributes.value;\n const value =\n typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : Number.NaN;\n if (Number.isNaN(value)) {\n return null;\n }\n return {\n id: first.id ?? '',\n value,\n };\n}\n\nexport function mapReplaySummary(resource: AppleMusicApiResource) {\n const attributes = resource.attributes ?? {};\n const topSongs = mapRelationshipResources(resource, 'top-songs', mapSong);\n const topAlbums = mapRelationshipResources(resource, 'top-albums', mapAlbum);\n const topArtists = mapRelationshipResources(resource, 'top-artists', mapArtist);\n const result: Record<string, unknown> = {\n id: resource.id ?? '',\n type: resource.type ?? '',\n name: String(attributes.name ?? ''),\n topSongs,\n topAlbums,\n topArtists,\n };\n if (attributes.year !== undefined) {\n result.year = Number(attributes.year);\n }\n return result;\n}\n\nfunction mapRelationshipResources<T>(\n resource: AppleMusicApiResource,\n relationshipKey: string,\n mapper: (item: AppleMusicApiResource) => T,\n): T[] {\n const relationships = resource as AppleMusicApiResource & {\n relationships?: Record<string, { data?: AppleMusicApiResource[] }>;\n };\n const data = relationships.relationships?.[relationshipKey]?.data;\n if (!data) {\n return [];\n }\n return data.map(mapper);\n}\n\nexport { catalogPlaybackId };\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AndroidAuthorizeOptions } from '../types/android-authorize-options';
|
|
2
|
+
import type { AuthorizeResult } from '../types/authorize-result';
|
|
3
|
+
import type { CheckSubscription } from '../types/check-subscription';
|
|
4
|
+
import type { Storefront } from '../types/storefront';
|
|
5
|
+
/**
|
|
6
|
+
* Apple Music authorization and subscription checks.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://github.com/wwdrew/expo-apple-music/blob/main/docs/AUTH.md} full auth guide (developer token, return values, requirements).
|
|
9
|
+
*/
|
|
10
|
+
declare class Auth {
|
|
11
|
+
/**
|
|
12
|
+
* Requests authorization to access the user's Apple Music account.
|
|
13
|
+
*
|
|
14
|
+
* Pass a **developer JWT** you obtained in your app (`developerToken`). On Android and web it is required.
|
|
15
|
+
* On iOS it is optional (media-library permission can succeed without it); when provided it is stored for REST.
|
|
16
|
+
*
|
|
17
|
+
* Returns `musicUserToken` when `status` is `authorized` — store it in your app (e.g. Zustand).
|
|
18
|
+
* The native module does not persist the music user token.
|
|
19
|
+
*
|
|
20
|
+
* @throws On Android and web, rejects with `MISSING_DEVELOPER_TOKEN` when `developerToken` is missing or blank.
|
|
21
|
+
*/
|
|
22
|
+
static authorize(developerToken?: string, options?: AndroidAuthorizeOptions): Promise<AuthorizeResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Stores a developer JWT on native / MusicKit JS without re-running user sign-in.
|
|
25
|
+
* Your app fetches or mints the token; this method only applies the string you pass.
|
|
26
|
+
*/
|
|
27
|
+
static setDeveloperToken(developerToken: string): Promise<void>;
|
|
28
|
+
static checkSubscription(musicUserToken: string): Promise<CheckSubscription>;
|
|
29
|
+
static getStorefront(musicUserToken: string): Promise<Storefront>;
|
|
30
|
+
}
|
|
31
|
+
export default Auth;
|
|
32
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/modules/auth.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD;;;;GAIG;AACH,cAAM,IAAI;IACR;;;;;;;;;;OAUG;WACiB,SAAS,CAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,eAAe,CAAC;IAoB3B;;;OAGG;WACiB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAOxD,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;WAOrE,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAM/E;AAED,eAAe,IAAI,CAAC"}
|