@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.
Files changed (452) hide show
  1. package/ATTRIBUTION.md +24 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +7 -0
  4. package/README.md +81 -0
  5. package/android/build.gradle +26 -0
  6. package/android/libs/mediaplayback-release-1.1.1.aar +0 -0
  7. package/android/libs/musickitauth-release-1.1.2.aar +0 -0
  8. package/android/src/main/AndroidManifest.xml +16 -0
  9. package/android/src/main/java/expo/modules/applemusic/AndroidCatalogService.kt +86 -0
  10. package/android/src/main/java/expo/modules/applemusic/AndroidDeveloperToken.kt +39 -0
  11. package/android/src/main/java/expo/modules/applemusic/AndroidHistoryService.kt +24 -0
  12. package/android/src/main/java/expo/modules/applemusic/AndroidLibraryMutationsService.kt +30 -0
  13. package/android/src/main/java/expo/modules/applemusic/AndroidLibraryService.kt +61 -0
  14. package/android/src/main/java/expo/modules/applemusic/AndroidPlaybackController.kt +484 -0
  15. package/android/src/main/java/expo/modules/applemusic/AndroidPlaybackObserver.kt +173 -0
  16. package/android/src/main/java/expo/modules/applemusic/AndroidQueueService.kt +78 -0
  17. package/android/src/main/java/expo/modules/applemusic/AndroidRatingsService.kt +27 -0
  18. package/android/src/main/java/expo/modules/applemusic/AndroidRecommendationsService.kt +15 -0
  19. package/android/src/main/java/expo/modules/applemusic/AndroidSubscriptionService.kt +24 -0
  20. package/android/src/main/java/expo/modules/applemusic/AppleMusicErrorCodes.kt +13 -0
  21. package/android/src/main/java/expo/modules/applemusic/AppleMusicErrors.kt +46 -0
  22. package/android/src/main/java/expo/modules/applemusic/AppleMusicHttpMethod.kt +8 -0
  23. package/android/src/main/java/expo/modules/applemusic/AppleMusicJsonMapper.kt +258 -0
  24. package/android/src/main/java/expo/modules/applemusic/AppleMusicNativeLoader.kt +32 -0
  25. package/android/src/main/java/expo/modules/applemusic/AppleMusicRestJson.kt +40 -0
  26. package/android/src/main/java/expo/modules/applemusic/AppleMusicRestQuery.kt +12 -0
  27. package/android/src/main/java/expo/modules/applemusic/AppleMusicRestStack.kt +19 -0
  28. package/android/src/main/java/expo/modules/applemusic/AppleMusicRestTransport.kt +118 -0
  29. package/android/src/main/java/expo/modules/applemusic/AuthenticatedSession.kt +57 -0
  30. package/android/src/main/java/expo/modules/applemusic/BridgeResponses.kt +55 -0
  31. package/android/src/main/java/expo/modules/applemusic/CatalogRestClient.kt +306 -0
  32. package/android/src/main/java/expo/modules/applemusic/ExpoAppleMusicModule.kt +152 -0
  33. package/android/src/main/java/expo/modules/applemusic/HistoryRestClient.kt +60 -0
  34. package/android/src/main/java/expo/modules/applemusic/LibraryIds.kt +6 -0
  35. package/android/src/main/java/expo/modules/applemusic/LibraryMutationsRestClient.kt +95 -0
  36. package/android/src/main/java/expo/modules/applemusic/LibraryRestClient.kt +195 -0
  37. package/android/src/main/java/expo/modules/applemusic/MusicKitAuthContract.kt +78 -0
  38. package/android/src/main/java/expo/modules/applemusic/MusicKitAuthStorage.kt +76 -0
  39. package/android/src/main/java/expo/modules/applemusic/MusicKitTokenProvider.kt +13 -0
  40. package/android/src/main/java/expo/modules/applemusic/PaginationOptions.kt +14 -0
  41. package/android/src/main/java/expo/modules/applemusic/RatingsRestClient.kt +72 -0
  42. package/android/src/main/java/expo/modules/applemusic/RecommendationsRestClient.kt +37 -0
  43. package/android/src/main/java/expo/modules/applemusic/StorefrontRestClient.kt +44 -0
  44. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeAuth.kt +69 -0
  45. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeCatalog.kt +76 -0
  46. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeHistory.kt +35 -0
  47. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeLibrary.kt +54 -0
  48. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeLibraryMutations.kt +30 -0
  49. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgePlayer.kt +89 -0
  50. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeRatings.kt +29 -0
  51. package/android/src/main/java/expo/modules/applemusic/bridge/ExpoBridgeRecommendations.kt +18 -0
  52. package/app.plugin.js +1 -0
  53. package/build/ExpoAppleMusicModule.web.d.ts +15 -0
  54. package/build/ExpoAppleMusicModule.web.d.ts.map +1 -0
  55. package/build/ExpoAppleMusicModule.web.js +33 -0
  56. package/build/ExpoAppleMusicModule.web.js.map +1 -0
  57. package/build/api/call-native.d.ts +6 -0
  58. package/build/api/call-native.d.ts.map +1 -0
  59. package/build/api/call-native.js +35 -0
  60. package/build/api/call-native.js.map +1 -0
  61. package/build/api/decode-jwt-exp.d.ts +5 -0
  62. package/build/api/decode-jwt-exp.d.ts.map +1 -0
  63. package/build/api/decode-jwt-exp.js +28 -0
  64. package/build/api/decode-jwt-exp.js.map +1 -0
  65. package/build/api/library-ids.d.ts +4 -0
  66. package/build/api/library-ids.d.ts.map +1 -0
  67. package/build/api/library-ids.js +11 -0
  68. package/build/api/library-ids.js.map +1 -0
  69. package/build/api/pagination.d.ts +12 -0
  70. package/build/api/pagination.d.ts.map +1 -0
  71. package/build/api/pagination.js +13 -0
  72. package/build/api/pagination.js.map +1 -0
  73. package/build/api/parse-authorize-result.d.ts +3 -0
  74. package/build/api/parse-authorize-result.d.ts.map +1 -0
  75. package/build/api/parse-authorize-result.js +27 -0
  76. package/build/api/parse-authorize-result.js.map +1 -0
  77. package/build/api/require-music-user-token.d.ts +2 -0
  78. package/build/api/require-music-user-token.d.ts.map +1 -0
  79. package/build/api/require-music-user-token.js +14 -0
  80. package/build/api/require-music-user-token.js.map +1 -0
  81. package/build/api/sync-developer-token.d.ts +4 -0
  82. package/build/api/sync-developer-token.d.ts.map +1 -0
  83. package/build/api/sync-developer-token.js +27 -0
  84. package/build/api/sync-developer-token.js.map +1 -0
  85. package/build/bridge/bridge-methods.d.ts +17 -0
  86. package/build/bridge/bridge-methods.d.ts.map +1 -0
  87. package/build/bridge/bridge-methods.js +71 -0
  88. package/build/bridge/bridge-methods.js.map +1 -0
  89. package/build/bridge/bridge-responses.d.ts +64 -0
  90. package/build/bridge/bridge-responses.d.ts.map +1 -0
  91. package/build/bridge/bridge-responses.js +67 -0
  92. package/build/bridge/bridge-responses.js.map +1 -0
  93. package/build/bridge/handlers/auth-bridge.d.ts +11 -0
  94. package/build/bridge/handlers/auth-bridge.d.ts.map +1 -0
  95. package/build/bridge/handlers/auth-bridge.js +49 -0
  96. package/build/bridge/handlers/auth-bridge.js.map +1 -0
  97. package/build/bridge/handlers/catalog-bridge.d.ts +34 -0
  98. package/build/bridge/handlers/catalog-bridge.d.ts.map +1 -0
  99. package/build/bridge/handlers/catalog-bridge.js +58 -0
  100. package/build/bridge/handlers/catalog-bridge.js.map +1 -0
  101. package/build/bridge/handlers/history-bridge.d.ts +19 -0
  102. package/build/bridge/handlers/history-bridge.d.ts.map +1 -0
  103. package/build/bridge/handlers/history-bridge.js +31 -0
  104. package/build/bridge/handlers/history-bridge.js.map +1 -0
  105. package/build/bridge/handlers/index.d.ts +124 -0
  106. package/build/bridge/handlers/index.d.ts.map +1 -0
  107. package/build/bridge/handlers/index.js +21 -0
  108. package/build/bridge/handlers/index.js.map +1 -0
  109. package/build/bridge/handlers/library-bridge.d.ts +23 -0
  110. package/build/bridge/handlers/library-bridge.d.ts.map +1 -0
  111. package/build/bridge/handlers/library-bridge.js +41 -0
  112. package/build/bridge/handlers/library-bridge.js.map +1 -0
  113. package/build/bridge/handlers/library-mutations-bridge.d.ts +16 -0
  114. package/build/bridge/handlers/library-mutations-bridge.d.ts.map +1 -0
  115. package/build/bridge/handlers/library-mutations-bridge.js +20 -0
  116. package/build/bridge/handlers/library-mutations-bridge.js.map +1 -0
  117. package/build/bridge/handlers/player-bridge.d.ts +18 -0
  118. package/build/bridge/handlers/player-bridge.d.ts.map +1 -0
  119. package/build/bridge/handlers/player-bridge.js +42 -0
  120. package/build/bridge/handlers/player-bridge.js.map +1 -0
  121. package/build/bridge/handlers/ratings-bridge.d.ts +15 -0
  122. package/build/bridge/handlers/ratings-bridge.d.ts.map +1 -0
  123. package/build/bridge/handlers/ratings-bridge.js +16 -0
  124. package/build/bridge/handlers/ratings-bridge.js.map +1 -0
  125. package/build/bridge/handlers/recommendations-bridge.d.ts +10 -0
  126. package/build/bridge/handlers/recommendations-bridge.d.ts.map +1 -0
  127. package/build/bridge/handlers/recommendations-bridge.js +14 -0
  128. package/build/bridge/handlers/recommendations-bridge.js.map +1 -0
  129. package/build/constants/apple-music-error-codes.d.ts +22 -0
  130. package/build/constants/apple-music-error-codes.d.ts.map +1 -0
  131. package/build/constants/apple-music-error-codes.js +21 -0
  132. package/build/constants/apple-music-error-codes.js.map +1 -0
  133. package/build/hooks/use-current-song.d.ts +10 -0
  134. package/build/hooks/use-current-song.d.ts.map +1 -0
  135. package/build/hooks/use-current-song.js +35 -0
  136. package/build/hooks/use-current-song.js.map +1 -0
  137. package/build/hooks/use-is-playing.d.ts +6 -0
  138. package/build/hooks/use-is-playing.d.ts.map +1 -0
  139. package/build/hooks/use-is-playing.js +21 -0
  140. package/build/hooks/use-is-playing.js.map +1 -0
  141. package/build/hooks/use-playback-state.d.ts +12 -0
  142. package/build/hooks/use-playback-state.d.ts.map +1 -0
  143. package/build/hooks/use-playback-state.js +41 -0
  144. package/build/hooks/use-playback-state.js.map +1 -0
  145. package/build/index.d.ts +52 -0
  146. package/build/index.d.ts.map +1 -0
  147. package/build/index.js +44 -0
  148. package/build/index.js.map +1 -0
  149. package/build/mappers/apple-music-json-mapper.d.ts +94 -0
  150. package/build/mappers/apple-music-json-mapper.d.ts.map +1 -0
  151. package/build/mappers/apple-music-json-mapper.js +212 -0
  152. package/build/mappers/apple-music-json-mapper.js.map +1 -0
  153. package/build/modules/auth.d.ts +32 -0
  154. package/build/modules/auth.d.ts.map +1 -0
  155. package/build/modules/auth.js +60 -0
  156. package/build/modules/auth.js.map +1 -0
  157. package/build/modules/catalog.d.ts +46 -0
  158. package/build/modules/catalog.d.ts.map +1 -0
  159. package/build/modules/catalog.js +47 -0
  160. package/build/modules/catalog.js.map +1 -0
  161. package/build/modules/history.d.ts +17 -0
  162. package/build/modules/history.d.ts.map +1 -0
  163. package/build/modules/history.js +28 -0
  164. package/build/modules/history.js.map +1 -0
  165. package/build/modules/library-mutations.d.ts +9 -0
  166. package/build/modules/library-mutations.d.ts.map +1 -0
  167. package/build/modules/library-mutations.js +41 -0
  168. package/build/modules/library-mutations.js.map +1 -0
  169. package/build/modules/library.d.ts +21 -0
  170. package/build/modules/library.d.ts.map +1 -0
  171. package/build/modules/library.js +38 -0
  172. package/build/modules/library.js.map +1 -0
  173. package/build/modules/player.d.ts +53 -0
  174. package/build/modules/player.d.ts.map +1 -0
  175. package/build/modules/player.js +68 -0
  176. package/build/modules/player.js.map +1 -0
  177. package/build/modules/ratings.d.ts +10 -0
  178. package/build/modules/ratings.d.ts.map +1 -0
  179. package/build/modules/ratings.js +37 -0
  180. package/build/modules/ratings.js.map +1 -0
  181. package/build/modules/recommendations.d.ts +7 -0
  182. package/build/modules/recommendations.d.ts.map +1 -0
  183. package/build/modules/recommendations.js +15 -0
  184. package/build/modules/recommendations.js.map +1 -0
  185. package/build/native-module.d.ts +5 -0
  186. package/build/native-module.d.ts.map +1 -0
  187. package/build/native-module.js +5 -0
  188. package/build/native-module.js.map +1 -0
  189. package/build/native-module.web.d.ts +11 -0
  190. package/build/native-module.web.d.ts.map +1 -0
  191. package/build/native-module.web.js +11 -0
  192. package/build/native-module.web.js.map +1 -0
  193. package/build/rest/apple-music-rest-stack.d.ts +21 -0
  194. package/build/rest/apple-music-rest-stack.d.ts.map +1 -0
  195. package/build/rest/apple-music-rest-stack.js +21 -0
  196. package/build/rest/apple-music-rest-stack.js.map +1 -0
  197. package/build/rest/apple-music-rest-transport.d.ts +8 -0
  198. package/build/rest/apple-music-rest-transport.d.ts.map +1 -0
  199. package/build/rest/apple-music-rest-transport.js +2 -0
  200. package/build/rest/apple-music-rest-transport.js.map +1 -0
  201. package/build/rest/catalog-rest-client.d.ts +38 -0
  202. package/build/rest/catalog-rest-client.d.ts.map +1 -0
  203. package/build/rest/catalog-rest-client.js +189 -0
  204. package/build/rest/catalog-rest-client.js.map +1 -0
  205. package/build/rest/history-rest-client.d.ts +37 -0
  206. package/build/rest/history-rest-client.d.ts.map +1 -0
  207. package/build/rest/history-rest-client.js +30 -0
  208. package/build/rest/history-rest-client.js.map +1 -0
  209. package/build/rest/library-ids.d.ts +2 -0
  210. package/build/rest/library-ids.d.ts.map +1 -0
  211. package/build/rest/library-ids.js +2 -0
  212. package/build/rest/library-ids.js.map +1 -0
  213. package/build/rest/library-mutations-rest-client.d.ts +22 -0
  214. package/build/rest/library-mutations-rest-client.d.ts.map +1 -0
  215. package/build/rest/library-mutations-rest-client.js +37 -0
  216. package/build/rest/library-mutations-rest-client.js.map +1 -0
  217. package/build/rest/library-rest-client.d.ts +59 -0
  218. package/build/rest/library-rest-client.d.ts.map +1 -0
  219. package/build/rest/library-rest-client.js +141 -0
  220. package/build/rest/library-rest-client.js.map +1 -0
  221. package/build/rest/ratings-rest-client.d.ts +18 -0
  222. package/build/rest/ratings-rest-client.d.ts.map +1 -0
  223. package/build/rest/ratings-rest-client.js +37 -0
  224. package/build/rest/ratings-rest-client.js.map +1 -0
  225. package/build/rest/recommendations-rest-client.d.ts +32 -0
  226. package/build/rest/recommendations-rest-client.d.ts.map +1 -0
  227. package/build/rest/recommendations-rest-client.js +26 -0
  228. package/build/rest/recommendations-rest-client.js.map +1 -0
  229. package/build/rest/resource-ids-query.d.ts +2 -0
  230. package/build/rest/resource-ids-query.d.ts.map +1 -0
  231. package/build/rest/resource-ids-query.js +10 -0
  232. package/build/rest/resource-ids-query.js.map +1 -0
  233. package/build/rest/rest-json.d.ts +11 -0
  234. package/build/rest/rest-json.d.ts.map +1 -0
  235. package/build/rest/rest-json.js +29 -0
  236. package/build/rest/rest-json.js.map +1 -0
  237. package/build/rest/storefront-rest-client.d.ts +14 -0
  238. package/build/rest/storefront-rest-client.d.ts.map +1 -0
  239. package/build/rest/storefront-rest-client.js +36 -0
  240. package/build/rest/storefront-rest-client.js.map +1 -0
  241. package/build/types/album.d.ts +8 -0
  242. package/build/types/album.d.ts.map +1 -0
  243. package/build/types/album.js +2 -0
  244. package/build/types/album.js.map +1 -0
  245. package/build/types/albums-response.d.ts +5 -0
  246. package/build/types/albums-response.d.ts.map +1 -0
  247. package/build/types/albums-response.js +2 -0
  248. package/build/types/albums-response.js.map +1 -0
  249. package/build/types/android-authorize-options.d.ts +18 -0
  250. package/build/types/android-authorize-options.d.ts.map +1 -0
  251. package/build/types/android-authorize-options.js +2 -0
  252. package/build/types/android-authorize-options.js.map +1 -0
  253. package/build/types/artist.d.ts +9 -0
  254. package/build/types/artist.d.ts.map +1 -0
  255. package/build/types/artist.js +2 -0
  256. package/build/types/artist.js.map +1 -0
  257. package/build/types/auth-status.d.ts +19 -0
  258. package/build/types/auth-status.d.ts.map +1 -0
  259. package/build/types/auth-status.js +18 -0
  260. package/build/types/auth-status.js.map +1 -0
  261. package/build/types/authorize-result.d.ts +8 -0
  262. package/build/types/authorize-result.d.ts.map +1 -0
  263. package/build/types/authorize-result.js +2 -0
  264. package/build/types/authorize-result.js.map +1 -0
  265. package/build/types/catalog-album-tracks.d.ts +5 -0
  266. package/build/types/catalog-album-tracks.d.ts.map +1 -0
  267. package/build/types/catalog-album-tracks.js +2 -0
  268. package/build/types/catalog-album-tracks.js.map +1 -0
  269. package/build/types/catalog-charts.d.ts +25 -0
  270. package/build/types/catalog-charts.d.ts.map +1 -0
  271. package/build/types/catalog-charts.js +7 -0
  272. package/build/types/catalog-charts.js.map +1 -0
  273. package/build/types/catalog-resource-type.d.ts +11 -0
  274. package/build/types/catalog-resource-type.d.ts.map +1 -0
  275. package/build/types/catalog-resource-type.js +10 -0
  276. package/build/types/catalog-resource-type.js.map +1 -0
  277. package/build/types/catalog-search.d.ts +24 -0
  278. package/build/types/catalog-search.d.ts.map +1 -0
  279. package/build/types/catalog-search.js +9 -0
  280. package/build/types/catalog-search.js.map +1 -0
  281. package/build/types/check-subscription.d.ts +31 -0
  282. package/build/types/check-subscription.d.ts.map +1 -0
  283. package/build/types/check-subscription.js +5 -0
  284. package/build/types/check-subscription.js.map +1 -0
  285. package/build/types/library-music-videos.d.ts +5 -0
  286. package/build/types/library-music-videos.d.ts.map +1 -0
  287. package/build/types/library-music-videos.js +2 -0
  288. package/build/types/library-music-videos.js.map +1 -0
  289. package/build/types/library-mutations.d.ts +21 -0
  290. package/build/types/library-mutations.d.ts.map +1 -0
  291. package/build/types/library-mutations.js +8 -0
  292. package/build/types/library-mutations.js.map +1 -0
  293. package/build/types/library-search.d.ts +22 -0
  294. package/build/types/library-search.d.ts.map +1 -0
  295. package/build/types/library-search.js +9 -0
  296. package/build/types/library-search.js.map +1 -0
  297. package/build/types/music-item.d.ts +8 -0
  298. package/build/types/music-item.d.ts.map +1 -0
  299. package/build/types/music-item.js +7 -0
  300. package/build/types/music-item.js.map +1 -0
  301. package/build/types/music-video.d.ts +8 -0
  302. package/build/types/music-video.d.ts.map +1 -0
  303. package/build/types/music-video.js +2 -0
  304. package/build/types/music-video.js.map +1 -0
  305. package/build/types/pagination.d.ts +11 -0
  306. package/build/types/pagination.d.ts.map +1 -0
  307. package/build/types/pagination.js +2 -0
  308. package/build/types/pagination.js.map +1 -0
  309. package/build/types/playback-state.d.ts +9 -0
  310. package/build/types/playback-state.d.ts.map +1 -0
  311. package/build/types/playback-state.js +2 -0
  312. package/build/types/playback-state.js.map +1 -0
  313. package/build/types/playback-status.d.ts +10 -0
  314. package/build/types/playback-status.d.ts.map +1 -0
  315. package/build/types/playback-status.js +9 -0
  316. package/build/types/playback-status.js.map +1 -0
  317. package/build/types/playlist.d.ts +15 -0
  318. package/build/types/playlist.d.ts.map +1 -0
  319. package/build/types/playlist.js +2 -0
  320. package/build/types/playlist.js.map +1 -0
  321. package/build/types/rating.d.ts +34 -0
  322. package/build/types/rating.d.ts.map +1 -0
  323. package/build/types/rating.js +26 -0
  324. package/build/types/rating.js.map +1 -0
  325. package/build/types/recent-resource.d.ts +11 -0
  326. package/build/types/recent-resource.d.ts.map +1 -0
  327. package/build/types/recent-resource.js +2 -0
  328. package/build/types/recent-resource.js.map +1 -0
  329. package/build/types/recommendation.d.ts +37 -0
  330. package/build/types/recommendation.d.ts.map +1 -0
  331. package/build/types/recommendation.js +2 -0
  332. package/build/types/recommendation.js.map +1 -0
  333. package/build/types/song.d.ts +8 -0
  334. package/build/types/song.d.ts.map +1 -0
  335. package/build/types/song.js +2 -0
  336. package/build/types/song.js.map +1 -0
  337. package/build/types/station.d.ts +9 -0
  338. package/build/types/station.d.ts.map +1 -0
  339. package/build/types/station.js +2 -0
  340. package/build/types/station.js.map +1 -0
  341. package/build/types/storefront.d.ts +4 -0
  342. package/build/types/storefront.d.ts.map +1 -0
  343. package/build/types/storefront.js +2 -0
  344. package/build/types/storefront.js.map +1 -0
  345. package/build/types/tracks-from-library.d.ts +11 -0
  346. package/build/types/tracks-from-library.d.ts.map +1 -0
  347. package/build/types/tracks-from-library.js +2 -0
  348. package/build/types/tracks-from-library.js.map +1 -0
  349. package/build/utils/apple-music-error.d.ts +10 -0
  350. package/build/utils/apple-music-error.d.ts.map +1 -0
  351. package/build/utils/apple-music-error.js +13 -0
  352. package/build/utils/apple-music-error.js.map +1 -0
  353. package/build/utils/get-error-message.d.ts +2 -0
  354. package/build/utils/get-error-message.d.ts.map +1 -0
  355. package/build/utils/get-error-message.js +21 -0
  356. package/build/utils/get-error-message.js.map +1 -0
  357. package/build/utils/is-library-item.d.ts +2 -0
  358. package/build/utils/is-library-item.d.ts.map +1 -0
  359. package/build/utils/is-library-item.js +4 -0
  360. package/build/utils/is-library-item.js.map +1 -0
  361. package/build/utils/normalize-resource-ids.d.ts +4 -0
  362. package/build/utils/normalize-resource-ids.d.ts.map +1 -0
  363. package/build/utils/normalize-resource-ids.js +12 -0
  364. package/build/utils/normalize-resource-ids.js.map +1 -0
  365. package/build/web/MusicKitLoader.d.ts +11 -0
  366. package/build/web/MusicKitLoader.d.ts.map +1 -0
  367. package/build/web/MusicKitLoader.js +135 -0
  368. package/build/web/MusicKitLoader.js.map +1 -0
  369. package/build/web/WebAppleMusicApiClient.d.ts +151 -0
  370. package/build/web/WebAppleMusicApiClient.d.ts.map +1 -0
  371. package/build/web/WebAppleMusicApiClient.js +139 -0
  372. package/build/web/WebAppleMusicApiClient.js.map +1 -0
  373. package/build/web/WebAppleMusicRestTransport.d.ts +9 -0
  374. package/build/web/WebAppleMusicRestTransport.d.ts.map +1 -0
  375. package/build/web/WebAppleMusicRestTransport.js +31 -0
  376. package/build/web/WebAppleMusicRestTransport.js.map +1 -0
  377. package/build/web/WebPlaybackController.d.ts +12 -0
  378. package/build/web/WebPlaybackController.d.ts.map +1 -0
  379. package/build/web/WebPlaybackController.js +90 -0
  380. package/build/web/WebPlaybackController.js.map +1 -0
  381. package/build/web/WebPlaybackObserver.d.ts +22 -0
  382. package/build/web/WebPlaybackObserver.d.ts.map +1 -0
  383. package/build/web/WebPlaybackObserver.js +106 -0
  384. package/build/web/WebPlaybackObserver.js.map +1 -0
  385. package/build/web/WebQueueService.d.ts +10 -0
  386. package/build/web/WebQueueService.d.ts.map +1 -0
  387. package/build/web/WebQueueService.js +53 -0
  388. package/build/web/WebQueueService.js.map +1 -0
  389. package/build/web/WebSubscriptionService.d.ts +7 -0
  390. package/build/web/WebSubscriptionService.d.ts.map +1 -0
  391. package/build/web/WebSubscriptionService.js +24 -0
  392. package/build/web/WebSubscriptionService.js.map +1 -0
  393. package/build/web/apple-music-errors.d.ts +11 -0
  394. package/build/web/apple-music-errors.d.ts.map +1 -0
  395. package/build/web/apple-music-errors.js +31 -0
  396. package/build/web/apple-music-errors.js.map +1 -0
  397. package/build/web/extract-music-user-token.d.ts +4 -0
  398. package/build/web/extract-music-user-token.d.ts.map +1 -0
  399. package/build/web/extract-music-user-token.js +15 -0
  400. package/build/web/extract-music-user-token.js.map +1 -0
  401. package/build/web/map-auth-status.d.ts +17 -0
  402. package/build/web/map-auth-status.d.ts.map +1 -0
  403. package/build/web/map-auth-status.js +85 -0
  404. package/build/web/map-auth-status.js.map +1 -0
  405. package/build/web/music-kit-api.d.ts +18 -0
  406. package/build/web/music-kit-api.d.ts.map +1 -0
  407. package/build/web/music-kit-api.js +120 -0
  408. package/build/web/music-kit-api.js.map +1 -0
  409. package/build/web/musickit-types.d.ts +70 -0
  410. package/build/web/musickit-types.d.ts.map +1 -0
  411. package/build/web/musickit-types.js +3 -0
  412. package/build/web/musickit-types.js.map +1 -0
  413. package/build/web/pagination.d.ts +2 -0
  414. package/build/web/pagination.d.ts.map +1 -0
  415. package/build/web/pagination.js +2 -0
  416. package/build/web/pagination.js.map +1 -0
  417. package/expo-module.config.json +19 -0
  418. package/ios/AppleMusicBridgeError.swift +60 -0
  419. package/ios/AppleMusicErrorCodes.swift +11 -0
  420. package/ios/AppleMusicRestClient.swift +213 -0
  421. package/ios/AuthenticatedSession.swift +64 -0
  422. package/ios/BridgePagination.swift +17 -0
  423. package/ios/BridgeResponses.swift +82 -0
  424. package/ios/CatalogSearchStore.swift +13 -0
  425. package/ios/CatalogSearchStoreFactory.swift +31 -0
  426. package/ios/CatalogService.swift +307 -0
  427. package/ios/ExpoAppleMusic.podspec +29 -0
  428. package/ios/ExpoAppleMusicModule.swift +505 -0
  429. package/ios/HistoryService.swift +53 -0
  430. package/ios/LibraryMutationsService.swift +63 -0
  431. package/ios/LibraryService.swift +313 -0
  432. package/ios/MusicItemMapper.swift +171 -0
  433. package/ios/MusicKitAuthStorage.swift +38 -0
  434. package/ios/MusicKitCatalogSearchStore.swift +62 -0
  435. package/ios/PlaybackController.swift +201 -0
  436. package/ios/PlaybackObserver.swift +225 -0
  437. package/ios/QueueService.swift +166 -0
  438. package/ios/RatingsService.swift +66 -0
  439. package/ios/RecommendationsService.swift +34 -0
  440. package/ios/RestCatalogSearchStore.swift +62 -0
  441. package/ios/RestJsonMapper.swift +268 -0
  442. package/ios/StorefrontService.swift +55 -0
  443. package/ios/SubscriptionService.swift +119 -0
  444. package/ios/bridge/ExpoBridgeCatalog.swift +98 -0
  445. package/ios/bridge/ExpoBridgeHistory.swift +71 -0
  446. package/ios/bridge/ExpoBridgeLibrary.swift +93 -0
  447. package/ios/bridge/ExpoBridgeRecommendations.swift +28 -0
  448. package/package.json +89 -0
  449. package/plugin/build/index.d.ts +5 -0
  450. package/plugin/build/index.js +10 -0
  451. package/plugin/build/with-expo-apple-music.d.ts +10 -0
  452. package/plugin/build/with-expo-apple-music.js +50 -0
package/ATTRIBUTION.md ADDED
@@ -0,0 +1,24 @@
1
+ # Attribution
2
+
3
+ `@wwdrew/expo-apple-music` is its own project. It is **not** a drop-in replacement for any other package and does not aim to preserve third-party API shapes.
4
+
5
+ ## Inspiration
6
+
7
+ Early exploration and structure were **inspired by** [`@lomray/react-native-apple-music`](https://github.com/Lomray-Software/react-native-apple-music) (Apache-2.0). That project showed one way to wrap Apple Music on React Native; this repo extends the idea toward **full [Apple Music API](https://developer.apple.com/documentation/AppleMusicAPI) coverage** on **iOS, Android, and Web** under Expo.
8
+
9
+ We are grateful to Lomray Software for publishing their work under Apache-2.0. This package is **not affiliated** with Lomray.
10
+
11
+ ## License
12
+
13
+ - This repository: [LICENSE](./LICENSE) (Apache-2.0)
14
+ - Lomray-derived portions: acknowledged in [NOTICE](./NOTICE)
15
+
16
+ ## Coming from Lomray or `MPMediaLibrary`
17
+
18
+ There is **no migration guide** and no compatibility layer. Treat this package as a new integration:
19
+
20
+ - Read [README.md](./README.md) and [docs/AUTH.md](./docs/AUTH.md) for install and auth.
21
+ - Read [CONTEXT.md](./CONTEXT.md) for catalog vs library vs history terminology.
22
+ - Read [docs/V1_PLAN.md](./docs/V1_PLAN.md) for the public API direction (`Catalog`, `Library`, `History`, `Player`, …).
23
+
24
+ If you used `@lomray/react-native-apple-music` or `MPMediaQuery`, remap your app to this package’s domain APIs and Apple’s MusicKit / REST model — do not expect matching export names or behavior.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2022 Lomray Software
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ @lomray/react-native-apple-music v1.0.0
2
+ https://github.com/Lomray-Software/react-native-apple-music
3
+ Derived at commit: 7eedc69f58cdd233570980179a4e516dcb6f1e1f
4
+
5
+ Copyright 2022 Lomray Software
6
+
7
+ Licensed under the Apache License, Version 2.0.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @wwdrew/expo-apple-music
2
+
3
+ Cross-platform Apple Music API for **Expo** (SDK 56 · iOS 16.4+ · Android · Web).
4
+
5
+ Inspired by [`@lomray/react-native-apple-music`](https://github.com/Lomray-Software/react-native-apple-music) — not a drop-in replacement. See [ATTRIBUTION.md](./ATTRIBUTION.md).
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npx expo install @wwdrew/expo-apple-music
11
+ ```
12
+
13
+ Add the config plugin and enable **MusicKit** on your App ID in the Apple Developer portal. Full steps: **[docs/GETTING_STARTED.md](./docs/GETTING_STARTED.md)**.
14
+
15
+ ```ts
16
+ // app.config.ts
17
+ import expoAppleMusic from '@wwdrew/expo-apple-music/plugin';
18
+
19
+ export default {
20
+ plugins: [
21
+ expoAppleMusic({ musicUsageDescription: 'We use Apple Music in this app.' }),
22
+ ],
23
+ };
24
+ ```
25
+
26
+ ## Quick example
27
+
28
+ ```ts
29
+ import { Auth, AuthStatus, Catalog, CatalogSearchType, Player } from '@wwdrew/expo-apple-music';
30
+
31
+ const developerToken = await fetchDeveloperJwtFromYourApp(); // required on Android & web
32
+
33
+ const { status, musicUserToken } = await Auth.authorize(developerToken);
34
+ if (status === AuthStatus.AUTHORIZED && musicUserToken) {
35
+ await Catalog.search('Beatles', [CatalogSearchType.SONGS]);
36
+ await Player.play();
37
+ }
38
+ ```
39
+
40
+ **Developer JWT:** your app signs and serves it — not included in this package. Local dev: clone the repo and use `npm run dev-token` ([docs/CLI.md](./docs/CLI.md)).
41
+
42
+ ## Documentation
43
+
44
+ All guides live in **[docs/](./docs/)** (browse on GitHub):
45
+
46
+ | | |
47
+ | --- | --- |
48
+ | **[Getting started](./docs/GETTING_STARTED.md)** | Install → authorize → search → play |
49
+ | **[Building locally](./docs/BUILDING_LOCALLY.md)** | Clone, Android `.aar` libs, example app |
50
+ | **[Auth](./docs/AUTH.md)** | JWT, `AuthStatus`, platform requirements |
51
+ | **[iOS setup](./docs/IOS_SETUP.md)** | Portal, signing, entitlements |
52
+ | **[API coverage](./docs/APPLE_MUSIC_API.md)** | Per-method iOS / Android / web matrix |
53
+ | **[Doc index](./docs/README.md)** | Full list |
54
+
55
+ ## Platform parity (summary)
56
+
57
+ Same TypeScript API everywhere; a few features differ on Android and web.
58
+
59
+ | | iOS | Android | Web |
60
+ | --- | :---: | :---: | :---: |
61
+ | `Auth.authorize()` | ✅ | ✅ (JWT required) | ✅ (JWT required) |
62
+ | `Catalog` / `Library` / `History` | ✅ | ✅ | ✅ |
63
+ | `Player` playback | ✅ | ✅ | ⚠️ verify in Safari + Chrome |
64
+ | `Player.setQueue()` station | ✅ | ❌ | ⚠️ |
65
+ | `Auth.checkSubscription()` | ✅ | ⚠️ inferred | ⚠️ inferred |
66
+
67
+ Details: [docs/APPLE_MUSIC_API.md](./docs/APPLE_MUSIC_API.md).
68
+
69
+ ## Building locally (repo clone)
70
+
71
+ The **example app** and Android native builds need Apple’s MusicKit Android `.aar` libraries in `android/libs/`. Those binaries are **gitignored** and are **not** in the repository — download them from Apple. Full steps: **[docs/BUILDING_LOCALLY.md](./docs/BUILDING_LOCALLY.md)**.
72
+
73
+ ```sh
74
+ # After placing mediaplayback-release-1.1.1.aar and musickitauth-release-1.1.2.aar in android/libs/
75
+ npm run dev-token -- --write-env example/.env.local
76
+ cd example && npx expo start
77
+ ```
78
+
79
+ ## License
80
+
81
+ Apache-2.0 — [LICENSE](./LICENSE) · [NOTICE](./NOTICE)
@@ -0,0 +1,26 @@
1
+ plugins {
2
+ id 'com.android.library'
3
+ id 'expo-module-gradle-plugin'
4
+ }
5
+
6
+ group = 'expo.modules.applemusic'
7
+ version = '0.1.0'
8
+
9
+ android {
10
+ namespace "expo.modules.applemusic"
11
+ defaultConfig {
12
+ versionCode 1
13
+ versionName "0.1.0"
14
+ }
15
+ lint {
16
+ abortOnError true
17
+ }
18
+ }
19
+
20
+ dependencies {
21
+ implementation project(":${project.name}\$musickit-auth")
22
+ implementation project(":${project.name}\$musickit-playback")
23
+ implementation "com.squareup.okhttp3:okhttp:4.12.0"
24
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
25
+ testImplementation "junit:junit:4.13.2"
26
+ }
@@ -0,0 +1,16 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ xmlns:tools="http://schemas.android.com/tools">
3
+
4
+ <!-- Android 11+ package visibility: SDK checks com.apple.android.music via getPackageInfo -->
5
+ <queries>
6
+ <package android:name="com.apple.android.music" />
7
+ </queries>
8
+
9
+ <application>
10
+ <!-- musickitauth AAR targets API 28 and omits android:exported on SDKUriHandlerActivity -->
11
+ <activity
12
+ android:name="com.apple.android.sdk.authentication.SDKUriHandlerActivity"
13
+ android:exported="true"
14
+ tools:node="merge" />
15
+ </application>
16
+ </manifest>
@@ -0,0 +1,86 @@
1
+ package expo.modules.applemusic
2
+
3
+ import android.content.Context
4
+
5
+ internal class AndroidCatalogService(
6
+ private val catalog: CatalogRestClient,
7
+ ) {
8
+ constructor(context: Context) : this(AppleMusicRestStack.create(context).catalog)
9
+
10
+ data class SearchResult(
11
+ val songs: List<Map<String, Any?>>,
12
+ val albums: List<Map<String, Any?>>,
13
+ val artists: List<Map<String, Any?>>,
14
+ val playlists: List<Map<String, Any?>>,
15
+ val stations: List<Map<String, Any?>>,
16
+ val musicVideos: List<Map<String, Any?>>,
17
+ )
18
+
19
+ suspend fun search(
20
+ term: String,
21
+ types: List<String>,
22
+ options: PaginationOptions,
23
+ ): SearchResult {
24
+ val result = catalog.catalogSearch(term, types, options.limit, options.offset)
25
+ return SearchResult(
26
+ songs = result.songs,
27
+ albums = result.albums,
28
+ artists = result.artists,
29
+ playlists = result.playlists,
30
+ stations = result.stations,
31
+ musicVideos = result.musicVideos,
32
+ )
33
+ }
34
+
35
+ suspend fun getSong(id: String): Map<String, Any?> = catalog.getCatalogSong(id)
36
+
37
+ suspend fun getAlbum(id: String): Map<String, Any?> = catalog.getCatalogAlbum(id)
38
+
39
+ suspend fun getArtist(id: String): Map<String, Any?> = catalog.getCatalogArtist(id)
40
+
41
+ suspend fun getPlaylist(id: String): Map<String, Any?> = catalog.getCatalogPlaylist(id)
42
+
43
+ suspend fun getStation(id: String): Map<String, Any?> = catalog.getCatalogStation(id)
44
+
45
+ suspend fun getMusicVideo(id: String): Map<String, Any?> = catalog.getCatalogMusicVideo(id)
46
+
47
+ suspend fun getAlbumTracks(
48
+ albumId: String,
49
+ options: PaginationOptions,
50
+ ): List<Map<String, Any?>> = catalog.getCatalogAlbumTracks(albumId, options.limit, options.offset)
51
+
52
+ suspend fun getArtistAlbums(
53
+ artistId: String,
54
+ options: PaginationOptions,
55
+ ): List<Map<String, Any?>> = catalog.getCatalogArtistAlbums(artistId, options.limit, options.offset)
56
+
57
+ suspend fun getPlaylistTracks(
58
+ playlistId: String,
59
+ options: PaginationOptions,
60
+ ): List<Map<String, Any?>> = catalog.getCatalogPlaylistTracks(playlistId, options.limit, options.offset)
61
+
62
+ data class ChartsResult(
63
+ val songs: List<Map<String, Any?>>,
64
+ val albums: List<Map<String, Any?>>,
65
+ val playlists: List<Map<String, Any?>>,
66
+ val musicVideos: List<Map<String, Any?>>,
67
+ )
68
+
69
+ suspend fun getCharts(
70
+ types: List<String>,
71
+ options: PaginationOptions,
72
+ genre: String?,
73
+ chart: String?,
74
+ ): ChartsResult {
75
+ val result = catalog.getCatalogCharts(types, options.limit, options.offset, genre, chart)
76
+ return ChartsResult(
77
+ songs = result.songs,
78
+ albums = result.albums,
79
+ playlists = result.playlists,
80
+ musicVideos = result.musicVideos,
81
+ )
82
+ }
83
+
84
+ suspend fun getResources(type: String, ids: List<String>): List<Map<String, Any?>> =
85
+ catalog.getCatalogResources(type, ids)
86
+ }
@@ -0,0 +1,39 @@
1
+ package expo.modules.applemusic
2
+
3
+ import android.content.Context
4
+ import expo.modules.kotlin.exception.CodedException
5
+
6
+ internal object AndroidDeveloperToken {
7
+ fun require(developerToken: String?): String {
8
+ val trimmed = developerToken?.trim()
9
+ if (!trimmed.isNullOrEmpty()) {
10
+ return trimmed
11
+ }
12
+
13
+ throw CodedException(
14
+ AppleMusicErrorCodes.MISSING_DEVELOPER_TOKEN,
15
+ "Android MusicKit auth requires a developer JWT. Pass Auth.authorize(developerToken).",
16
+ null,
17
+ )
18
+ }
19
+
20
+ fun requireStored(context: Context): String {
21
+ val trimmed = MusicKitAuthStorage.getDeveloperToken(context)?.trim()
22
+ if (!trimmed.isNullOrEmpty()) {
23
+ return trimmed
24
+ }
25
+ throw CodedException(
26
+ AppleMusicErrorCodes.MISSING_DEVELOPER_TOKEN,
27
+ "Android MusicKit requires a stored developer JWT. Call Auth.authorize(developerToken) first.",
28
+ null,
29
+ )
30
+ }
31
+ }
32
+
33
+ internal fun requireMusicUserToken(musicUserToken: String?): String {
34
+ val trimmed = musicUserToken?.trim()
35
+ if (!trimmed.isNullOrEmpty()) {
36
+ return trimmed
37
+ }
38
+ throw AppleMusicErrors.missingMusicUserToken()
39
+ }
@@ -0,0 +1,24 @@
1
+ package expo.modules.applemusic
2
+
3
+ import android.content.Context
4
+
5
+ internal class AndroidHistoryService(
6
+ private val history: HistoryRestClient,
7
+ ) {
8
+ constructor(context: Context) : this(AppleMusicRestStack.create(context).history)
9
+
10
+ suspend fun getRecentlyPlayedResources(musicUserToken: String): List<Map<String, Any?>> =
11
+ history.getRecentlyPlayed(musicUserToken)
12
+
13
+ suspend fun getRecentlyPlayedTracks(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
14
+ history.getRecentlyPlayedTracks(musicUserToken, options.limit)
15
+
16
+ suspend fun getHeavyRotation(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
17
+ history.getHeavyRotation(musicUserToken, options.limit)
18
+
19
+ suspend fun getRecentlyPlayedStations(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
20
+ history.getRecentlyPlayedStations(musicUserToken, options.limit)
21
+
22
+ suspend fun getRecentlyAdded(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
23
+ history.getRecentlyAdded(musicUserToken, options.limit, options.offset)
24
+ }
@@ -0,0 +1,30 @@
1
+ package expo.modules.applemusic
2
+
3
+ import android.content.Context
4
+
5
+ internal class AndroidLibraryMutationsService(
6
+ private val libraryMutations: LibraryMutationsRestClient,
7
+ ) {
8
+ constructor(context: Context) : this(AppleMusicRestStack.create(context).libraryMutations)
9
+
10
+ suspend fun addToLibrary(musicUserToken: String, resourceIds: Map<String, List<String>>) {
11
+ libraryMutations.addToLibrary(musicUserToken, resourceIds)
12
+ }
13
+
14
+ suspend fun createPlaylist(
15
+ musicUserToken: String,
16
+ name: String,
17
+ description: String?,
18
+ isPublic: Boolean,
19
+ tracks: List<Map<String, String>>?,
20
+ ): Map<String, Any?> =
21
+ libraryMutations.createLibraryPlaylist(musicUserToken, name, description, isPublic, tracks)
22
+
23
+ suspend fun addTracksToPlaylist(
24
+ musicUserToken: String,
25
+ playlistId: String,
26
+ tracks: List<Map<String, String>>,
27
+ ) {
28
+ libraryMutations.addTracksToLibraryPlaylist(musicUserToken, playlistId, tracks)
29
+ }
30
+ }
@@ -0,0 +1,61 @@
1
+ package expo.modules.applemusic
2
+
3
+ import android.content.Context
4
+
5
+ internal class AndroidLibraryService(
6
+ private val library: LibraryRestClient,
7
+ private val storefront: StorefrontRestClient,
8
+ ) {
9
+ constructor(stack: AppleMusicRestStack) : this(stack.library, stack.storefront)
10
+
11
+ constructor(context: Context) : this(AppleMusicRestStack.create(context))
12
+
13
+ suspend fun getPlaylists(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
14
+ library.getLibraryPlaylists(musicUserToken, options.limit, options.offset)
15
+
16
+ suspend fun getSongs(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
17
+ library.getLibrarySongs(musicUserToken, options.limit, options.offset)
18
+
19
+ suspend fun getPlaylistSongs(musicUserToken: String, playlistId: String): List<Map<String, Any?>> {
20
+ val songs = library.getPlaylistTracks(musicUserToken, playlistId)
21
+ if (songs.isEmpty()) {
22
+ throw AppleMusicErrors.playlistNotFound()
23
+ }
24
+ return songs
25
+ }
26
+
27
+ suspend fun getArtists(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
28
+ library.getLibraryArtists(musicUserToken, options.limit, options.offset)
29
+
30
+ suspend fun getAlbums(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
31
+ library.getLibraryAlbums(musicUserToken, options.limit, options.offset)
32
+
33
+ suspend fun getMusicVideos(musicUserToken: String, options: PaginationOptions): List<Map<String, Any?>> =
34
+ library.getLibraryMusicVideos(musicUserToken, options.limit, options.offset)
35
+
36
+ data class LibrarySearchResult(
37
+ val songs: List<Map<String, Any?>>,
38
+ val albums: List<Map<String, Any?>>,
39
+ val artists: List<Map<String, Any?>>,
40
+ val playlists: List<Map<String, Any?>>,
41
+ val musicVideos: List<Map<String, Any?>>,
42
+ )
43
+
44
+ suspend fun search(
45
+ musicUserToken: String,
46
+ term: String,
47
+ types: List<String>,
48
+ options: PaginationOptions,
49
+ ): LibrarySearchResult {
50
+ val result = library.searchLibrary(musicUserToken, term, types, options.limit, options.offset)
51
+ return LibrarySearchResult(
52
+ songs = result.songs,
53
+ albums = result.albums,
54
+ artists = result.artists,
55
+ playlists = result.playlists,
56
+ musicVideos = result.musicVideos,
57
+ )
58
+ }
59
+
60
+ suspend fun getStorefrontId(musicUserToken: String): String = storefront.getStorefront(musicUserToken)
61
+ }