@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":"ratings.js","sourceRoot":"","sources":["../../src/modules/ratings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,MAAM,OAAO;IACJ,MAAM,CAAC,KAAK,CAAC,SAAS,CAC3B,cAAsB,EACtB,YAAgC,EAChC,EAAU;QAEV,qBAAqB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;QAC3D,OAAO,UAAU,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;YAC7E,OAAQ,MAAwB,IAAI,IAAI,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,SAA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';\nimport { requireMusicUserToken } from '../api/require-music-user-token';\nimport type { Rating, RatingResourceType, RatingValue, ResourceIds } from '../types/rating';\nimport { MusicModule } from '../native-module';\nimport { normalizeResourceIds } from '../utils/normalize-resource-ids';\n\nclass Ratings {\n public static async getRating(\n musicUserToken: string,\n resourceType: RatingResourceType,\n id: string,\n ): Promise<Rating | null> {\n requireMusicUserToken(musicUserToken, 'Ratings.getRating');\n return callNative('Ratings.getRating', async () => {\n const result = await MusicModule.getRating(musicUserToken, resourceType, id);\n return (result as Rating | null) ?? null;\n });\n }\n\n public static async setRating(\n musicUserToken: string,\n resourceType: RatingResourceType,\n id: string,\n value: RatingValue,\n ): Promise<Rating> {\n requireMusicUserToken(musicUserToken, 'Ratings.setRating');\n return callNative('Ratings.setRating', async () =>\n (await MusicModule.setRating(musicUserToken, resourceType, id, value)) as Rating,\n );\n }\n\n public static async clearRating(\n musicUserToken: string,\n resourceType: RatingResourceType,\n id: string,\n ): Promise<void> {\n requireMusicUserToken(musicUserToken, 'Ratings.clearRating');\n await callNative('Ratings.clearRating', async () => {\n await MusicModule.clearRating(musicUserToken, resourceType, id);\n });\n }\n\n public static async addToFavorites(musicUserToken: string, resourceIds: ResourceIds): Promise<void> {\n requireMusicUserToken(musicUserToken, 'Ratings.addToFavorites');\n await callNative('Ratings.addToFavorites', async () => {\n await MusicModule.addToFavorites(musicUserToken, normalizeResourceIds(resourceIds));\n });\n }\n\n public static async removeFromFavorites(\n musicUserToken: string,\n resourceIds: ResourceIds,\n ): Promise<void> {\n requireMusicUserToken(musicUserToken, 'Ratings.removeFromFavorites');\n await callNative('Ratings.removeFromFavorites', async () => {\n await MusicModule.removeFromFavorites(musicUserToken, normalizeResourceIds(resourceIds));\n });\n }\n}\n\nexport default Ratings;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RecommendationsOptions, RecommendationsResponse, ReplayOptions, ReplayResponse } from '../types/recommendation';
|
|
2
|
+
declare class Recommendations {
|
|
3
|
+
static get(musicUserToken: string, options?: RecommendationsOptions): Promise<RecommendationsResponse>;
|
|
4
|
+
static getReplay(musicUserToken: string, options?: ReplayOptions): Promise<ReplayResponse>;
|
|
5
|
+
}
|
|
6
|
+
export default Recommendations;
|
|
7
|
+
//# sourceMappingURL=recommendations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations.d.ts","sourceRoot":"","sources":["../../src/modules/recommendations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC,cAAM,eAAe;WACC,GAAG,CACrB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,uBAAuB,CAAC;WAOf,SAAS,CAC3B,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,cAAc,CAAC;CAM3B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { callNative } from '../api/call-native';
|
|
2
|
+
import { requireMusicUserToken } from '../api/require-music-user-token';
|
|
3
|
+
import { MusicModule } from '../native-module';
|
|
4
|
+
class Recommendations {
|
|
5
|
+
static async get(musicUserToken, options) {
|
|
6
|
+
requireMusicUserToken(musicUserToken, 'Recommendations.get');
|
|
7
|
+
return callNative('Recommendations.get', async () => (await MusicModule.getRecommendations(musicUserToken, options?.ids)));
|
|
8
|
+
}
|
|
9
|
+
static async getReplay(musicUserToken, options) {
|
|
10
|
+
requireMusicUserToken(musicUserToken, 'Recommendations.getReplay');
|
|
11
|
+
return callNative('Recommendations.getReplay', async () => (await MusicModule.getReplay(musicUserToken, options?.year)));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default Recommendations;
|
|
15
|
+
//# sourceMappingURL=recommendations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommendations.js","sourceRoot":"","sources":["../../src/modules/recommendations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAOxE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,eAAe;IACZ,MAAM,CAAC,KAAK,CAAC,GAAG,CACrB,cAAsB,EACtB,OAAgC;QAEhC,qBAAqB,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAClD,CAAC,MAAM,WAAW,CAAC,kBAAkB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,CAA4B,CAChG,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,SAAS,CAC3B,cAAsB,EACtB,OAAuB;QAEvB,qBAAqB,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC;QACnE,OAAO,UAAU,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE,CACxD,CAAC,MAAM,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,CAAmB,CAC/E,CAAC;IACJ,CAAC;CACF;AAED,eAAe,eAAe,CAAC","sourcesContent":["import { callNative } from '../api/call-native';\nimport { requireMusicUserToken } from '../api/require-music-user-token';\nimport type {\n RecommendationsOptions,\n RecommendationsResponse,\n ReplayOptions,\n ReplayResponse,\n} from '../types/recommendation';\nimport { MusicModule } from '../native-module';\n\nclass Recommendations {\n public static async get(\n musicUserToken: string,\n options?: RecommendationsOptions,\n ): Promise<RecommendationsResponse> {\n requireMusicUserToken(musicUserToken, 'Recommendations.get');\n return callNative('Recommendations.get', async () =>\n (await MusicModule.getRecommendations(musicUserToken, options?.ids)) as RecommendationsResponse,\n );\n }\n\n public static async getReplay(\n musicUserToken: string,\n options?: ReplayOptions,\n ): Promise<ReplayResponse> {\n requireMusicUserToken(musicUserToken, 'Recommendations.getReplay');\n return callNative('Recommendations.getReplay', async () =>\n (await MusicModule.getReplay(musicUserToken, options?.year)) as ReplayResponse,\n );\n }\n}\n\nexport default Recommendations;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LegacyEventEmitter } from 'expo-modules-core';
|
|
2
|
+
export declare const UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM";
|
|
3
|
+
export declare const MusicModule: any;
|
|
4
|
+
export declare const musicEventEmitter: LegacyEventEmitter;
|
|
5
|
+
//# sourceMappingURL=native-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.d.ts","sourceRoot":"","sources":["../src/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAE5E,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,eAAO,MAAM,WAAW,KAAwC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,oBAAsC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LegacyEventEmitter, requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
export const UNSUPPORTED_PLATFORM = 'UNSUPPORTED_PLATFORM';
|
|
3
|
+
export const MusicModule = requireNativeModule('ExpoAppleMusic');
|
|
4
|
+
export const musicEventEmitter = new LegacyEventEmitter(MusicModule);
|
|
5
|
+
//# sourceMappingURL=native-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.js","sourceRoot":"","sources":["../src/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { LegacyEventEmitter, requireNativeModule } from 'expo-modules-core';\n\nexport const UNSUPPORTED_PLATFORM = 'UNSUPPORTED_PLATFORM';\n\nexport const MusicModule = requireNativeModule('ExpoAppleMusic');\n\nexport const musicEventEmitter = new LegacyEventEmitter(MusicModule);\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LegacyEventEmitter } from 'expo-modules-core';
|
|
2
|
+
import { type ExpoAppleMusicModule as ExpoAppleMusicModuleType } from './ExpoAppleMusicModule.web';
|
|
3
|
+
export declare const UNSUPPORTED_PLATFORM = "UNSUPPORTED_PLATFORM";
|
|
4
|
+
/**
|
|
5
|
+
* On web, `requireNativeModule` only resolves when `ExpoDomWebView` is set (see
|
|
6
|
+
* expo-modules-core `requireNativeModule.web.ts`). Import the `registerWebModule`
|
|
7
|
+
* singleton directly — same pattern as expo-font's `ExpoFontLoader.web.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MusicModule: ExpoAppleMusicModuleType;
|
|
10
|
+
export declare const musicEventEmitter: LegacyEventEmitter;
|
|
11
|
+
//# sourceMappingURL=native-module.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.web.d.ts","sourceRoot":"","sources":["../src/native-module.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAA6B,EAAE,KAAK,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEzH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,wBAA+C,CAAC;AAE1E,eAAO,MAAM,iBAAiB,oBAAsC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LegacyEventEmitter } from 'expo-modules-core';
|
|
2
|
+
import ExpoAppleMusicModule, {} from './ExpoAppleMusicModule.web';
|
|
3
|
+
export const UNSUPPORTED_PLATFORM = 'UNSUPPORTED_PLATFORM';
|
|
4
|
+
/**
|
|
5
|
+
* On web, `requireNativeModule` only resolves when `ExpoDomWebView` is set (see
|
|
6
|
+
* expo-modules-core `requireNativeModule.web.ts`). Import the `registerWebModule`
|
|
7
|
+
* singleton directly — same pattern as expo-font's `ExpoFontLoader.web.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export const MusicModule = ExpoAppleMusicModule;
|
|
10
|
+
export const musicEventEmitter = new LegacyEventEmitter(MusicModule);
|
|
11
|
+
//# sourceMappingURL=native-module.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.web.js","sourceRoot":"","sources":["../src/native-module.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,oBAAoB,EAAE,EAAyD,MAAM,4BAA4B,CAAC;AAEzH,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAA6B,oBAAoB,CAAC;AAE1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { LegacyEventEmitter } from 'expo-modules-core';\n\nimport ExpoAppleMusicModule, { type ExpoAppleMusicModule as ExpoAppleMusicModuleType } from './ExpoAppleMusicModule.web';\n\nexport const UNSUPPORTED_PLATFORM = 'UNSUPPORTED_PLATFORM';\n\n/**\n * On web, `requireNativeModule` only resolves when `ExpoDomWebView` is set (see\n * expo-modules-core `requireNativeModule.web.ts`). Import the `registerWebModule`\n * singleton directly — same pattern as expo-font's `ExpoFontLoader.web.ts`.\n */\nexport const MusicModule: ExpoAppleMusicModuleType = ExpoAppleMusicModule;\n\nexport const musicEventEmitter = new LegacyEventEmitter(MusicModule);\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CatalogRestClient } from './catalog-rest-client';
|
|
2
|
+
import { HistoryRestClient } from './history-rest-client';
|
|
3
|
+
import { LibraryMutationsRestClient } from './library-mutations-rest-client';
|
|
4
|
+
import { LibraryRestClient } from './library-rest-client';
|
|
5
|
+
import { RatingsRestClient } from './ratings-rest-client';
|
|
6
|
+
import { RecommendationsRestClient } from './recommendations-rest-client';
|
|
7
|
+
import { StorefrontRestClient } from './storefront-rest-client';
|
|
8
|
+
import type { AppleMusicRestTransport } from './apple-music-rest-transport';
|
|
9
|
+
import type { StorefrontResolver } from './storefront-rest-client';
|
|
10
|
+
export type AppleMusicRestStack = {
|
|
11
|
+
transport: AppleMusicRestTransport;
|
|
12
|
+
storefront: StorefrontRestClient;
|
|
13
|
+
catalog: CatalogRestClient;
|
|
14
|
+
library: LibraryRestClient;
|
|
15
|
+
history: HistoryRestClient;
|
|
16
|
+
ratings: RatingsRestClient;
|
|
17
|
+
libraryMutations: LibraryMutationsRestClient;
|
|
18
|
+
recommendations: RecommendationsRestClient;
|
|
19
|
+
};
|
|
20
|
+
export declare function createAppleMusicRestStack(transport: AppleMusicRestTransport, storefrontResolver?: StorefrontResolver): AppleMusicRestStack;
|
|
21
|
+
//# sourceMappingURL=apple-music-rest-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-rest-stack.d.ts","sourceRoot":"","sources":["../../src/rest/apple-music-rest-stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,uBAAuB,CAAC;IACnC,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,gBAAgB,EAAE,0BAA0B,CAAC;IAC7C,eAAe,EAAE,yBAAyB,CAAC;CAC5C,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,uBAAuB,EAClC,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,mBAAmB,CAYrB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CatalogRestClient } from './catalog-rest-client';
|
|
2
|
+
import { HistoryRestClient } from './history-rest-client';
|
|
3
|
+
import { LibraryMutationsRestClient } from './library-mutations-rest-client';
|
|
4
|
+
import { LibraryRestClient } from './library-rest-client';
|
|
5
|
+
import { RatingsRestClient } from './ratings-rest-client';
|
|
6
|
+
import { RecommendationsRestClient } from './recommendations-rest-client';
|
|
7
|
+
import { StorefrontRestClient } from './storefront-rest-client';
|
|
8
|
+
export function createAppleMusicRestStack(transport, storefrontResolver) {
|
|
9
|
+
const storefront = new StorefrontRestClient(transport, storefrontResolver);
|
|
10
|
+
return {
|
|
11
|
+
transport,
|
|
12
|
+
storefront,
|
|
13
|
+
catalog: new CatalogRestClient(transport, storefront),
|
|
14
|
+
library: new LibraryRestClient(transport),
|
|
15
|
+
history: new HistoryRestClient(transport),
|
|
16
|
+
ratings: new RatingsRestClient(transport),
|
|
17
|
+
libraryMutations: new LibraryMutationsRestClient(transport),
|
|
18
|
+
recommendations: new RecommendationsRestClient(transport),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=apple-music-rest-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-rest-stack.js","sourceRoot":"","sources":["../../src/rest/apple-music-rest-stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAehE,MAAM,UAAU,yBAAyB,CACvC,SAAkC,EAClC,kBAAuC;IAEvC,MAAM,UAAU,GAAG,IAAI,oBAAoB,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC3E,OAAO;QACL,SAAS;QACT,UAAU;QACV,OAAO,EAAE,IAAI,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC;QACrD,OAAO,EAAE,IAAI,iBAAiB,CAAC,SAAS,CAAC;QACzC,OAAO,EAAE,IAAI,iBAAiB,CAAC,SAAS,CAAC;QACzC,OAAO,EAAE,IAAI,iBAAiB,CAAC,SAAS,CAAC;QACzC,gBAAgB,EAAE,IAAI,0BAA0B,CAAC,SAAS,CAAC;QAC3D,eAAe,EAAE,IAAI,yBAAyB,CAAC,SAAS,CAAC;KAC1D,CAAC;AACJ,CAAC","sourcesContent":["import { CatalogRestClient } from './catalog-rest-client';\nimport { HistoryRestClient } from './history-rest-client';\nimport { LibraryMutationsRestClient } from './library-mutations-rest-client';\nimport { LibraryRestClient } from './library-rest-client';\nimport { RatingsRestClient } from './ratings-rest-client';\nimport { RecommendationsRestClient } from './recommendations-rest-client';\nimport { StorefrontRestClient } from './storefront-rest-client';\nimport type { AppleMusicRestTransport } from './apple-music-rest-transport';\nimport type { StorefrontResolver } from './storefront-rest-client';\n\nexport type AppleMusicRestStack = {\n transport: AppleMusicRestTransport;\n storefront: StorefrontRestClient;\n catalog: CatalogRestClient;\n library: LibraryRestClient;\n history: HistoryRestClient;\n ratings: RatingsRestClient;\n libraryMutations: LibraryMutationsRestClient;\n recommendations: RecommendationsRestClient;\n};\n\nexport function createAppleMusicRestStack(\n transport: AppleMusicRestTransport,\n storefrontResolver?: StorefrontResolver,\n): AppleMusicRestStack {\n const storefront = new StorefrontRestClient(transport, storefrontResolver);\n return {\n transport,\n storefront,\n catalog: new CatalogRestClient(transport, storefront),\n library: new LibraryRestClient(transport),\n history: new HistoryRestClient(transport),\n ratings: new RatingsRestClient(transport),\n libraryMutations: new LibraryMutationsRestClient(transport),\n recommendations: new RecommendationsRestClient(transport),\n };\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MusicKitApiResponse } from '../web/musickit-types';
|
|
2
|
+
export type AppleMusicHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
3
|
+
/** Platform HTTP adapter for Apple Music REST paths (`/v1/...`). */
|
|
4
|
+
export interface AppleMusicRestTransport {
|
|
5
|
+
request(method: AppleMusicHttpMethod, path: string, query?: Record<string, string>, body?: Record<string, unknown>, musicUserToken?: string): Promise<MusicKitApiResponse>;
|
|
6
|
+
getJson(path: string, query?: Record<string, string>, musicUserToken?: string): Promise<MusicKitApiResponse>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=apple-music-rest-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-rest-transport.d.ts","sourceRoot":"","sources":["../../src/rest/apple-music-rest-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACtC,OAAO,CACL,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-music-rest-transport.js","sourceRoot":"","sources":["../../src/rest/apple-music-rest-transport.ts"],"names":[],"mappings":"","sourcesContent":["import type { MusicKitApiResponse } from '../web/musickit-types';\n\nexport type AppleMusicHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\n\n/** Platform HTTP adapter for Apple Music REST paths (`/v1/...`). */\nexport interface AppleMusicRestTransport {\n request(\n method: AppleMusicHttpMethod,\n path: string,\n query?: Record<string, string>,\n body?: Record<string, unknown>,\n musicUserToken?: string,\n ): Promise<MusicKitApiResponse>;\n\n getJson(\n path: string,\n query?: Record<string, string>,\n musicUserToken?: string,\n ): Promise<MusicKitApiResponse>;\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CatalogResourceType } from '../types/catalog-resource-type';
|
|
2
|
+
import type { AppleMusicRestTransport } from './apple-music-rest-transport';
|
|
3
|
+
import { StorefrontRestClient } from './storefront-rest-client';
|
|
4
|
+
export type CatalogSearchResult = {
|
|
5
|
+
songs: Record<string, unknown>[];
|
|
6
|
+
albums: Record<string, unknown>[];
|
|
7
|
+
artists: Record<string, unknown>[];
|
|
8
|
+
playlists: Record<string, unknown>[];
|
|
9
|
+
stations: Record<string, unknown>[];
|
|
10
|
+
musicVideos: Record<string, unknown>[];
|
|
11
|
+
};
|
|
12
|
+
export type CatalogChartsResult = {
|
|
13
|
+
songs: Record<string, unknown>[];
|
|
14
|
+
albums: Record<string, unknown>[];
|
|
15
|
+
playlists: Record<string, unknown>[];
|
|
16
|
+
musicVideos: Record<string, unknown>[];
|
|
17
|
+
};
|
|
18
|
+
/** Catalog-domain Apple Music REST (search, resources, charts). */
|
|
19
|
+
export declare class CatalogRestClient {
|
|
20
|
+
private readonly transport;
|
|
21
|
+
private readonly storefront;
|
|
22
|
+
constructor(transport: AppleMusicRestTransport, storefront: StorefrontRestClient);
|
|
23
|
+
catalogSearch(term: string, types: string[], limit: number, offset: number): Promise<CatalogSearchResult>;
|
|
24
|
+
private getCatalogResource;
|
|
25
|
+
getCatalogSong(id: string): Promise<Record<string, unknown>>;
|
|
26
|
+
getCatalogAlbum(id: string): Promise<Record<string, unknown>>;
|
|
27
|
+
getCatalogArtist(id: string): Promise<Record<string, unknown>>;
|
|
28
|
+
getCatalogPlaylist(id: string): Promise<Record<string, unknown>>;
|
|
29
|
+
getCatalogStation(id: string): Promise<Record<string, unknown>>;
|
|
30
|
+
getCatalogMusicVideo(id: string): Promise<Record<string, unknown>>;
|
|
31
|
+
getCatalogResources(type: CatalogResourceType, ids: string[]): Promise<Record<string, unknown>[]>;
|
|
32
|
+
private getCatalogRelationship;
|
|
33
|
+
getCatalogAlbumTracks(albumId: string, limit: number, offset: number): Promise<Record<string, unknown>[]>;
|
|
34
|
+
getCatalogArtistAlbums(artistId: string, limit: number, offset: number): Promise<Record<string, unknown>[]>;
|
|
35
|
+
getCatalogPlaylistTracks(playlistId: string, limit: number, offset: number): Promise<Record<string, unknown>[]>;
|
|
36
|
+
getCatalogCharts(types: string[], limit: number, offset: number, genre?: string | null, chart?: string | null): Promise<CatalogChartsResult>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=catalog-rest-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-rest-client.d.ts","sourceRoot":"","sources":["../../src/rest/catalog-rest-client.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;AA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BAAsB,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAU/B,wBAAwB,CAC5B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAU/B,gBAAgB,CACpB,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,mBAAmB,CAAC;CA6BhC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { mapAlbum, mapArtist, mapMusicVideo, mapPlaylist, mapSong, mapStation, } from '../mappers/apple-music-json-mapper';
|
|
2
|
+
import * as errors from '../web/apple-music-errors';
|
|
3
|
+
import { mapResourceArray, mapTopLevelResourceArray } from './rest-json';
|
|
4
|
+
import { StorefrontRestClient } from './storefront-rest-client';
|
|
5
|
+
function catalogSearchTypeParam(type) {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case 'songs':
|
|
8
|
+
case 'song':
|
|
9
|
+
return 'songs';
|
|
10
|
+
case 'albums':
|
|
11
|
+
case 'album':
|
|
12
|
+
return 'albums';
|
|
13
|
+
case 'artists':
|
|
14
|
+
case 'artist':
|
|
15
|
+
return 'artists';
|
|
16
|
+
case 'playlists':
|
|
17
|
+
case 'playlist':
|
|
18
|
+
return 'playlists';
|
|
19
|
+
case 'stations':
|
|
20
|
+
case 'station':
|
|
21
|
+
return 'stations';
|
|
22
|
+
case 'music-videos':
|
|
23
|
+
case 'musicVideos':
|
|
24
|
+
case 'musicVideo':
|
|
25
|
+
return 'music-videos';
|
|
26
|
+
default:
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function catalogChartTypeParam(type) {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'songs':
|
|
33
|
+
case 'song':
|
|
34
|
+
return 'songs';
|
|
35
|
+
case 'albums':
|
|
36
|
+
case 'album':
|
|
37
|
+
return 'albums';
|
|
38
|
+
case 'playlists':
|
|
39
|
+
case 'playlist':
|
|
40
|
+
return 'playlists';
|
|
41
|
+
case 'music-videos':
|
|
42
|
+
case 'musicVideos':
|
|
43
|
+
case 'musicVideo':
|
|
44
|
+
return 'music-videos';
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function catalogResourceMapper(type) {
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 'songs':
|
|
52
|
+
return mapSong;
|
|
53
|
+
case 'albums':
|
|
54
|
+
return mapAlbum;
|
|
55
|
+
case 'artists':
|
|
56
|
+
return mapArtist;
|
|
57
|
+
case 'playlists':
|
|
58
|
+
return mapPlaylist;
|
|
59
|
+
case 'stations':
|
|
60
|
+
return mapStation;
|
|
61
|
+
case 'music-videos':
|
|
62
|
+
return mapMusicVideo;
|
|
63
|
+
default:
|
|
64
|
+
throw errors.unknownMediaType(type);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Catalog-domain Apple Music REST (search, resources, charts). */
|
|
68
|
+
export class CatalogRestClient {
|
|
69
|
+
transport;
|
|
70
|
+
storefront;
|
|
71
|
+
constructor(transport, storefront) {
|
|
72
|
+
this.transport = transport;
|
|
73
|
+
this.storefront = storefront;
|
|
74
|
+
}
|
|
75
|
+
async catalogSearch(term, types, limit, offset) {
|
|
76
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
77
|
+
const typeParam = types
|
|
78
|
+
.map((t) => catalogSearchTypeParam(t))
|
|
79
|
+
.filter((t) => t !== null)
|
|
80
|
+
.filter((t, i, arr) => arr.indexOf(t) === i)
|
|
81
|
+
.join(',') || 'songs,albums';
|
|
82
|
+
const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/search`, {
|
|
83
|
+
term,
|
|
84
|
+
types: typeParam,
|
|
85
|
+
limit: String(limit),
|
|
86
|
+
offset: String(offset),
|
|
87
|
+
});
|
|
88
|
+
const results = json.results ?? {};
|
|
89
|
+
return {
|
|
90
|
+
songs: mapResourceArray(results.songs?.data, mapSong),
|
|
91
|
+
albums: mapResourceArray(results.albums?.data, mapAlbum),
|
|
92
|
+
artists: mapResourceArray(results.artists?.data, mapArtist),
|
|
93
|
+
playlists: mapResourceArray(results.playlists?.data, mapPlaylist),
|
|
94
|
+
stations: mapResourceArray(results.stations?.data, mapStation),
|
|
95
|
+
musicVideos: mapResourceArray(results['music-videos']?.data, mapMusicVideo),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async getCatalogResource(path, mapper) {
|
|
99
|
+
const json = await this.transport.getJson(path);
|
|
100
|
+
const data = Array.isArray(json.data) ? json.data[0] : null;
|
|
101
|
+
if (!data) {
|
|
102
|
+
throw errors.itemNotFound('Catalog item', false);
|
|
103
|
+
}
|
|
104
|
+
return mapper(data);
|
|
105
|
+
}
|
|
106
|
+
async getCatalogSong(id) {
|
|
107
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
108
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/songs/${id}`, mapSong);
|
|
109
|
+
}
|
|
110
|
+
async getCatalogAlbum(id) {
|
|
111
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
112
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/albums/${id}`, mapAlbum);
|
|
113
|
+
}
|
|
114
|
+
async getCatalogArtist(id) {
|
|
115
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
116
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/artists/${id}`, mapArtist);
|
|
117
|
+
}
|
|
118
|
+
async getCatalogPlaylist(id) {
|
|
119
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
120
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/playlists/${id}`, mapPlaylist);
|
|
121
|
+
}
|
|
122
|
+
async getCatalogStation(id) {
|
|
123
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
124
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/stations/${id}`, mapStation);
|
|
125
|
+
}
|
|
126
|
+
async getCatalogMusicVideo(id) {
|
|
127
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
128
|
+
return this.getCatalogResource(`/v1/catalog/${storefrontId}/music-videos/${id}`, mapMusicVideo);
|
|
129
|
+
}
|
|
130
|
+
async getCatalogResources(type, ids) {
|
|
131
|
+
const trimmed = ids.map((id) => id.trim()).filter((id) => id.length > 0);
|
|
132
|
+
if (trimmed.length === 0) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
136
|
+
const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/${type}`, {
|
|
137
|
+
ids: trimmed.join(','),
|
|
138
|
+
});
|
|
139
|
+
const mapper = catalogResourceMapper(type);
|
|
140
|
+
return mapTopLevelResourceArray(json.data, mapper);
|
|
141
|
+
}
|
|
142
|
+
async getCatalogRelationship(path, limit, offset, mapper) {
|
|
143
|
+
const json = await this.transport.getJson(path, {
|
|
144
|
+
limit: String(limit),
|
|
145
|
+
offset: String(offset),
|
|
146
|
+
});
|
|
147
|
+
return mapTopLevelResourceArray(json.data, mapper);
|
|
148
|
+
}
|
|
149
|
+
async getCatalogAlbumTracks(albumId, limit, offset) {
|
|
150
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
151
|
+
return this.getCatalogRelationship(`/v1/catalog/${storefrontId}/albums/${albumId}/tracks`, limit, offset, mapSong);
|
|
152
|
+
}
|
|
153
|
+
async getCatalogArtistAlbums(artistId, limit, offset) {
|
|
154
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
155
|
+
return this.getCatalogRelationship(`/v1/catalog/${storefrontId}/artists/${artistId}/albums`, limit, offset, mapAlbum);
|
|
156
|
+
}
|
|
157
|
+
async getCatalogPlaylistTracks(playlistId, limit, offset) {
|
|
158
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
159
|
+
return this.getCatalogRelationship(`/v1/catalog/${storefrontId}/playlists/${playlistId}/tracks`, limit, offset, mapSong);
|
|
160
|
+
}
|
|
161
|
+
async getCatalogCharts(types, limit, offset, genre, chart) {
|
|
162
|
+
const storefrontId = await this.storefront.getStorefront();
|
|
163
|
+
const typeParam = types
|
|
164
|
+
.map((t) => catalogChartTypeParam(t))
|
|
165
|
+
.filter((t) => t !== null)
|
|
166
|
+
.filter((t, i, arr) => arr.indexOf(t) === i)
|
|
167
|
+
.join(',') || 'songs,albums';
|
|
168
|
+
const query = {
|
|
169
|
+
types: typeParam,
|
|
170
|
+
limit: String(limit),
|
|
171
|
+
offset: String(offset),
|
|
172
|
+
};
|
|
173
|
+
if (genre) {
|
|
174
|
+
query.genre = genre;
|
|
175
|
+
}
|
|
176
|
+
if (chart) {
|
|
177
|
+
query.chart = chart;
|
|
178
|
+
}
|
|
179
|
+
const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/charts`, query);
|
|
180
|
+
const results = json.results ?? {};
|
|
181
|
+
return {
|
|
182
|
+
songs: mapResourceArray(results.songs?.data, mapSong),
|
|
183
|
+
albums: mapResourceArray(results.albums?.data, mapAlbum),
|
|
184
|
+
playlists: mapResourceArray(results.playlists?.data, mapPlaylist),
|
|
185
|
+
musicVideos: mapResourceArray(results['music-videos']?.data, mapMusicVideo),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=catalog-rest-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-rest-client.js","sourceRoot":"","sources":["../../src/rest/catalog-rest-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,EACX,O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;YACV,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,eAAe,YAAY,SAAS,EAAE,KAAK,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,OAAO;YACL,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;YACrD,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC;YACxD,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC;YACjE,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC;SAC5E,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n mapAlbum,\n mapArtist,\n mapMusicVideo,\n mapPlaylist,\n mapSong,\n mapStation,\n type AppleMusicApiResource,\n} from '../mappers/apple-music-json-mapper';\nimport * as errors from '../web/apple-music-errors';\nimport type { CatalogResourceType } from '../types/catalog-resource-type';\nimport type { AppleMusicRestTransport } from './apple-music-rest-transport';\nimport { mapResourceArray, mapTopLevelResourceArray } from './rest-json';\nimport { StorefrontRestClient } from './storefront-rest-client';\n\nexport type CatalogSearchResult = {\n songs: Record<string, unknown>[];\n albums: Record<string, unknown>[];\n artists: Record<string, unknown>[];\n playlists: Record<string, unknown>[];\n stations: Record<string, unknown>[];\n musicVideos: Record<string, unknown>[];\n};\n\nexport type CatalogChartsResult = {\n songs: Record<string, unknown>[];\n albums: Record<string, unknown>[];\n playlists: Record<string, unknown>[];\n musicVideos: Record<string, unknown>[];\n};\n\nfunction catalogSearchTypeParam(type: string): string | null {\n switch (type) {\n case 'songs':\n case 'song':\n return 'songs';\n case 'albums':\n case 'album':\n return 'albums';\n case 'artists':\n case 'artist':\n return 'artists';\n case 'playlists':\n case 'playlist':\n return 'playlists';\n case 'stations':\n case 'station':\n return 'stations';\n case 'music-videos':\n case 'musicVideos':\n case 'musicVideo':\n return 'music-videos';\n default:\n return null;\n }\n}\n\nfunction catalogChartTypeParam(type: string): string | null {\n switch (type) {\n case 'songs':\n case 'song':\n return 'songs';\n case 'albums':\n case 'album':\n return 'albums';\n case 'playlists':\n case 'playlist':\n return 'playlists';\n case 'music-videos':\n case 'musicVideos':\n case 'musicVideo':\n return 'music-videos';\n default:\n return null;\n }\n}\n\nfunction catalogResourceMapper(\n type: CatalogResourceType,\n): (resource: AppleMusicApiResource) => Record<string, unknown> {\n switch (type) {\n case 'songs':\n return mapSong;\n case 'albums':\n return mapAlbum;\n case 'artists':\n return mapArtist;\n case 'playlists':\n return mapPlaylist;\n case 'stations':\n return mapStation;\n case 'music-videos':\n return mapMusicVideo;\n default:\n throw errors.unknownMediaType(type);\n }\n}\n\n/** Catalog-domain Apple Music REST (search, resources, charts). */\nexport class CatalogRestClient {\n constructor(\n private readonly transport: AppleMusicRestTransport,\n private readonly storefront: StorefrontRestClient,\n ) {}\n\n async catalogSearch(\n term: string,\n types: string[],\n limit: number,\n offset: number,\n ): Promise<CatalogSearchResult> {\n const storefrontId = await this.storefront.getStorefront();\n const typeParam =\n types\n .map((t) => catalogSearchTypeParam(t))\n .filter((t): t is string => t !== null)\n .filter((t, i, arr) => arr.indexOf(t) === i)\n .join(',') || 'songs,albums';\n\n const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/search`, {\n term,\n types: typeParam,\n limit: String(limit),\n offset: String(offset),\n });\n\n const results = json.results ?? {};\n return {\n songs: mapResourceArray(results.songs?.data, mapSong),\n albums: mapResourceArray(results.albums?.data, mapAlbum),\n artists: mapResourceArray(results.artists?.data, mapArtist),\n playlists: mapResourceArray(results.playlists?.data, mapPlaylist),\n stations: mapResourceArray(results.stations?.data, mapStation),\n musicVideos: mapResourceArray(results['music-videos']?.data, mapMusicVideo),\n };\n }\n\n private async getCatalogResource(\n path: string,\n mapper: (resource: AppleMusicApiResource) => Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n const json = await this.transport.getJson(path);\n const data = Array.isArray(json.data) ? json.data[0] : null;\n if (!data) {\n throw errors.itemNotFound('Catalog item', false);\n }\n return mapper(data as AppleMusicApiResource);\n }\n\n async getCatalogSong(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/songs/${id}`, mapSong);\n }\n\n async getCatalogAlbum(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/albums/${id}`, mapAlbum);\n }\n\n async getCatalogArtist(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/artists/${id}`, mapArtist);\n }\n\n async getCatalogPlaylist(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/playlists/${id}`, mapPlaylist);\n }\n\n async getCatalogStation(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/stations/${id}`, mapStation);\n }\n\n async getCatalogMusicVideo(id: string): Promise<Record<string, unknown>> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogResource(`/v1/catalog/${storefrontId}/music-videos/${id}`, mapMusicVideo);\n }\n\n async getCatalogResources(\n type: CatalogResourceType,\n ids: string[],\n ): Promise<Record<string, unknown>[]> {\n const trimmed = ids.map((id) => id.trim()).filter((id) => id.length > 0);\n if (trimmed.length === 0) {\n return [];\n }\n const storefrontId = await this.storefront.getStorefront();\n const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/${type}`, {\n ids: trimmed.join(','),\n });\n const mapper = catalogResourceMapper(type);\n return mapTopLevelResourceArray(json.data, mapper);\n }\n\n private async getCatalogRelationship(\n path: string,\n limit: number,\n offset: number,\n mapper: (resource: AppleMusicApiResource) => Record<string, unknown>,\n ): Promise<Record<string, unknown>[]> {\n const json = await this.transport.getJson(path, {\n limit: String(limit),\n offset: String(offset),\n });\n return mapTopLevelResourceArray(json.data, mapper);\n }\n\n async getCatalogAlbumTracks(\n albumId: string,\n limit: number,\n offset: number,\n ): Promise<Record<string, unknown>[]> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogRelationship(\n `/v1/catalog/${storefrontId}/albums/${albumId}/tracks`,\n limit,\n offset,\n mapSong,\n );\n }\n\n async getCatalogArtistAlbums(\n artistId: string,\n limit: number,\n offset: number,\n ): Promise<Record<string, unknown>[]> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogRelationship(\n `/v1/catalog/${storefrontId}/artists/${artistId}/albums`,\n limit,\n offset,\n mapAlbum,\n );\n }\n\n async getCatalogPlaylistTracks(\n playlistId: string,\n limit: number,\n offset: number,\n ): Promise<Record<string, unknown>[]> {\n const storefrontId = await this.storefront.getStorefront();\n return this.getCatalogRelationship(\n `/v1/catalog/${storefrontId}/playlists/${playlistId}/tracks`,\n limit,\n offset,\n mapSong,\n );\n }\n\n async getCatalogCharts(\n types: string[],\n limit: number,\n offset: number,\n genre?: string | null,\n chart?: string | null,\n ): Promise<CatalogChartsResult> {\n const storefrontId = await this.storefront.getStorefront();\n const typeParam =\n types\n .map((t) => catalogChartTypeParam(t))\n .filter((t): t is string => t !== null)\n .filter((t, i, arr) => arr.indexOf(t) === i)\n .join(',') || 'songs,albums';\n\n const query: Record<string, string> = {\n types: typeParam,\n limit: String(limit),\n offset: String(offset),\n };\n if (genre) {\n query.genre = genre;\n }\n if (chart) {\n query.chart = chart;\n }\n const json = await this.transport.getJson(`/v1/catalog/${storefrontId}/charts`, query);\n const results = json.results ?? {};\n return {\n songs: mapResourceArray(results.songs?.data, mapSong),\n albums: mapResourceArray(results.albums?.data, mapAlbum),\n playlists: mapResourceArray(results.playlists?.data, mapPlaylist),\n musicVideos: mapResourceArray(results['music-videos']?.data, mapMusicVideo),\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AppleMusicRestTransport } from './apple-music-rest-transport';
|
|
2
|
+
/** History-domain Apple Music REST (recently played, heavy rotation). */
|
|
3
|
+
export declare class HistoryRestClient {
|
|
4
|
+
private readonly transport;
|
|
5
|
+
constructor(transport: AppleMusicRestTransport);
|
|
6
|
+
getRecentlyPlayed(musicUserToken: string): Promise<{
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
subtitle: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[]>;
|
|
12
|
+
getRecentlyPlayedTracks(musicUserToken: string, limit: number): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
artistName: string;
|
|
16
|
+
artworkUrl: string;
|
|
17
|
+
duration: number;
|
|
18
|
+
}[]>;
|
|
19
|
+
getHeavyRotation(musicUserToken: string, limit: number): Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
subtitle: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}[]>;
|
|
25
|
+
getRecentlyPlayedStations(musicUserToken: string, limit: number): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
artworkUrl: string;
|
|
29
|
+
}[]>;
|
|
30
|
+
getRecentlyAdded(musicUserToken: string, limit: number, offset: number): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
subtitle: string;
|
|
34
|
+
type: string;
|
|
35
|
+
}[]>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=history-rest-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-rest-client.d.ts","sourceRoot":"","sources":["../../src/rest/history-rest-client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAG5E,yEAAyE;AACzE,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,uBAAuB;IAEzD,iBAAiB,CAAC,cAAc,EAAE,MAAM;;;;;;IAKxC,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;;;IAS7D,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;;IAStD,yBAAyB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;IAS/D,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;CAQ7E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mapRecentlyPlayed, mapRecentResource, mapSong, mapStation, } from '../mappers/apple-music-json-mapper';
|
|
2
|
+
import { mapTopLevelResourceArray } from './rest-json';
|
|
3
|
+
/** History-domain Apple Music REST (recently played, heavy rotation). */
|
|
4
|
+
export class HistoryRestClient {
|
|
5
|
+
transport;
|
|
6
|
+
constructor(transport) {
|
|
7
|
+
this.transport = transport;
|
|
8
|
+
}
|
|
9
|
+
async getRecentlyPlayed(musicUserToken) {
|
|
10
|
+
const json = await this.transport.getJson('/v1/me/recent/played', { limit: '10' }, musicUserToken);
|
|
11
|
+
return mapTopLevelResourceArray(json.data, mapRecentlyPlayed);
|
|
12
|
+
}
|
|
13
|
+
async getRecentlyPlayedTracks(musicUserToken, limit) {
|
|
14
|
+
const json = await this.transport.getJson('/v1/me/recent/played/tracks', { limit: String(limit) }, musicUserToken);
|
|
15
|
+
return mapTopLevelResourceArray(json.data, mapSong);
|
|
16
|
+
}
|
|
17
|
+
async getHeavyRotation(musicUserToken, limit) {
|
|
18
|
+
const json = await this.transport.getJson('/v1/me/history/heavy-rotation', { limit: String(limit) }, musicUserToken);
|
|
19
|
+
return mapTopLevelResourceArray(json.data, mapRecentResource);
|
|
20
|
+
}
|
|
21
|
+
async getRecentlyPlayedStations(musicUserToken, limit) {
|
|
22
|
+
const json = await this.transport.getJson('/v1/me/recent/radio-stations', { limit: String(limit) }, musicUserToken);
|
|
23
|
+
return mapTopLevelResourceArray(json.data, mapStation);
|
|
24
|
+
}
|
|
25
|
+
async getRecentlyAdded(musicUserToken, limit, offset) {
|
|
26
|
+
const json = await this.transport.getJson('/v1/me/library/recently-added', { limit: String(limit), offset: String(offset) }, musicUserToken);
|
|
27
|
+
return mapTopLevelResourceArray(json.data, mapRecentResource);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=history-rest-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-rest-client.js","sourceRoot":"","sources":["../../src/rest/history-rest-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,UAAU,GACX,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,yEAAyE;AACzE,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,SAAkC;QAAlC,cAAS,GAAT,SAAS,CAAyB;IAAG,CAAC;IAEnE,KAAK,CAAC,iBAAiB,CAAC,cAAsB;QAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,cAAc,CAAC,CAAC;QACnG,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,cAAsB,EAAE,KAAa;QACjE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACvC,6BAA6B,EAC7B,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EACxB,cAAc,CACf,CAAC;QACF,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,KAAa;QAC1D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACvC,+BAA+B,EAC/B,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EACxB,cAAc,CACf,CAAC;QACF,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,cAAsB,EAAE,KAAa;QACnE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACvC,8BAA8B,EAC9B,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EACxB,cAAc,CACf,CAAC;QACF,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB,EAAE,KAAa,EAAE,MAAc;QAC1E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CACvC,+BAA+B,EAC/B,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAChD,cAAc,CACf,CAAC;QACF,OAAO,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import {\n mapRecentlyPlayed,\n mapRecentResource,\n mapSong,\n mapStation,\n} from '../mappers/apple-music-json-mapper';\nimport type { AppleMusicRestTransport } from './apple-music-rest-transport';\nimport { mapTopLevelResourceArray } from './rest-json';\n\n/** History-domain Apple Music REST (recently played, heavy rotation). */\nexport class HistoryRestClient {\n constructor(private readonly transport: AppleMusicRestTransport) {}\n\n async getRecentlyPlayed(musicUserToken: string) {\n const json = await this.transport.getJson('/v1/me/recent/played', { limit: '10' }, musicUserToken);\n return mapTopLevelResourceArray(json.data, mapRecentlyPlayed);\n }\n\n async getRecentlyPlayedTracks(musicUserToken: string, limit: number) {\n const json = await this.transport.getJson(\n '/v1/me/recent/played/tracks',\n { limit: String(limit) },\n musicUserToken,\n );\n return mapTopLevelResourceArray(json.data, mapSong);\n }\n\n async getHeavyRotation(musicUserToken: string, limit: number) {\n const json = await this.transport.getJson(\n '/v1/me/history/heavy-rotation',\n { limit: String(limit) },\n musicUserToken,\n );\n return mapTopLevelResourceArray(json.data, mapRecentResource);\n }\n\n async getRecentlyPlayedStations(musicUserToken: string, limit: number) {\n const json = await this.transport.getJson(\n '/v1/me/recent/radio-stations',\n { limit: String(limit) },\n musicUserToken,\n );\n return mapTopLevelResourceArray(json.data, mapStation);\n }\n\n async getRecentlyAdded(musicUserToken: string, limit: number, offset: number) {\n const json = await this.transport.getJson(\n '/v1/me/library/recently-added',\n { limit: String(limit), offset: String(offset) },\n musicUserToken,\n );\n return mapTopLevelResourceArray(json.data, mapRecentResource);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-ids.d.ts","sourceRoot":"","sources":["../../src/rest/library-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-ids.js","sourceRoot":"","sources":["../../src/rest/library-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { isLibraryId } from '../api/library-ids';\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AppleMusicRestTransport } from './apple-music-rest-transport';
|
|
2
|
+
/** Library write/mutation Apple Music REST. */
|
|
3
|
+
export declare class LibraryMutationsRestClient {
|
|
4
|
+
private readonly transport;
|
|
5
|
+
constructor(transport: AppleMusicRestTransport);
|
|
6
|
+
addToLibrary(musicUserToken: string, resourceIds: Record<string, string[]>): Promise<void>;
|
|
7
|
+
createLibraryPlaylist(musicUserToken: string, name: string, description: string | null, isPublic: boolean, tracks: {
|
|
8
|
+
id: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}[] | null): Promise<{
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
artworkUrl: string;
|
|
15
|
+
trackCount: number;
|
|
16
|
+
}>;
|
|
17
|
+
addTracksToLibraryPlaylist(musicUserToken: string, playlistId: string, tracks: {
|
|
18
|
+
id: string;
|
|
19
|
+
type: string;
|
|
20
|
+
}[]): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=library-mutations-rest-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library-mutations-rest-client.d.ts","sourceRoot":"","sources":["../../src/rest/library-mutations-rest-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAG5E,+CAA+C;AAC/C,qBAAa,0BAA0B;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,uBAAuB;IAEzD,YAAY,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAI1E,qBAAqB,CACzB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI;;;;;;;IA4BzC,0BAA0B,CAC9B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;CAUzC"}
|