@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
@@ -0,0 +1,34 @@
1
+ /** Apple Music API path segment for `GET/PUT/DELETE /v1/me/ratings/{type}/{id}`. */
2
+ export declare const RatingResourceType: {
3
+ readonly SONG: "songs";
4
+ readonly ALBUM: "albums";
5
+ readonly PLAYLIST: "playlists";
6
+ readonly MUSIC_VIDEO: "music-videos";
7
+ readonly STATION: "stations";
8
+ readonly LIBRARY_SONG: "library-songs";
9
+ readonly LIBRARY_ALBUM: "library-albums";
10
+ readonly LIBRARY_PLAYLIST: "library-playlists";
11
+ readonly LIBRARY_MUSIC_VIDEO: "library-music-videos";
12
+ };
13
+ export type RatingResourceType = (typeof RatingResourceType)[keyof typeof RatingResourceType];
14
+ /** Like (`1`) or dislike (`-1`) — only values Apple accepts. */
15
+ export declare const RatingValue: {
16
+ readonly LIKE: 1;
17
+ readonly DISLIKE: -1;
18
+ };
19
+ export type RatingValue = (typeof RatingValue)[keyof typeof RatingValue];
20
+ export interface Rating {
21
+ id: string;
22
+ value: RatingValue;
23
+ }
24
+ /** Query keys for `ids[{type}]` on favorites and add-to-library endpoints. */
25
+ export declare const LibraryResourceType: {
26
+ readonly SONGS: "songs";
27
+ readonly ALBUMS: "albums";
28
+ readonly PLAYLISTS: "playlists";
29
+ readonly MUSIC_VIDEOS: "music-videos";
30
+ readonly STATIONS: "stations";
31
+ };
32
+ export type LibraryResourceType = (typeof LibraryResourceType)[keyof typeof LibraryResourceType];
33
+ export type ResourceIds = Partial<Record<LibraryResourceType, string[]>>;
34
+ //# sourceMappingURL=rating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating.d.ts","sourceRoot":"","sources":["../../src/types/rating.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,eAAO,MAAM,kBAAkB;;;;;;;;;;CAUrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE9F,gEAAgE;AAChE,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjG,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** Apple Music API path segment for `GET/PUT/DELETE /v1/me/ratings/{type}/{id}`. */
2
+ export const RatingResourceType = {
3
+ SONG: 'songs',
4
+ ALBUM: 'albums',
5
+ PLAYLIST: 'playlists',
6
+ MUSIC_VIDEO: 'music-videos',
7
+ STATION: 'stations',
8
+ LIBRARY_SONG: 'library-songs',
9
+ LIBRARY_ALBUM: 'library-albums',
10
+ LIBRARY_PLAYLIST: 'library-playlists',
11
+ LIBRARY_MUSIC_VIDEO: 'library-music-videos',
12
+ };
13
+ /** Like (`1`) or dislike (`-1`) — only values Apple accepts. */
14
+ export const RatingValue = {
15
+ LIKE: 1,
16
+ DISLIKE: -1,
17
+ };
18
+ /** Query keys for `ids[{type}]` on favorites and add-to-library endpoints. */
19
+ export const LibraryResourceType = {
20
+ SONGS: 'songs',
21
+ ALBUMS: 'albums',
22
+ PLAYLISTS: 'playlists',
23
+ MUSIC_VIDEOS: 'music-videos',
24
+ STATIONS: 'stations',
25
+ };
26
+ //# sourceMappingURL=rating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating.js","sourceRoot":"","sources":["../../src/types/rating.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,eAAe;IAC7B,aAAa,EAAE,gBAAgB;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,mBAAmB,EAAE,sBAAsB;CACnC,CAAC;AAIX,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC,CAAC;CACH,CAAC;AASX,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;CACZ,CAAC","sourcesContent":["/** Apple Music API path segment for `GET/PUT/DELETE /v1/me/ratings/{type}/{id}`. */\nexport const RatingResourceType = {\n SONG: 'songs',\n ALBUM: 'albums',\n PLAYLIST: 'playlists',\n MUSIC_VIDEO: 'music-videos',\n STATION: 'stations',\n LIBRARY_SONG: 'library-songs',\n LIBRARY_ALBUM: 'library-albums',\n LIBRARY_PLAYLIST: 'library-playlists',\n LIBRARY_MUSIC_VIDEO: 'library-music-videos',\n} as const;\n\nexport type RatingResourceType = (typeof RatingResourceType)[keyof typeof RatingResourceType];\n\n/** Like (`1`) or dislike (`-1`) — only values Apple accepts. */\nexport const RatingValue = {\n LIKE: 1,\n DISLIKE: -1,\n} as const;\n\nexport type RatingValue = (typeof RatingValue)[keyof typeof RatingValue];\n\nexport interface Rating {\n id: string;\n value: RatingValue;\n}\n\n/** Query keys for `ids[{type}]` on favorites and add-to-library endpoints. */\nexport const LibraryResourceType = {\n SONGS: 'songs',\n ALBUMS: 'albums',\n PLAYLISTS: 'playlists',\n MUSIC_VIDEOS: 'music-videos',\n STATIONS: 'stations',\n} as const;\n\nexport type LibraryResourceType = (typeof LibraryResourceType)[keyof typeof LibraryResourceType];\n\nexport type ResourceIds = Partial<Record<LibraryResourceType, string[]>>;\n"]}
@@ -0,0 +1,11 @@
1
+ /** Album, playlist, or station from history / heavy-rotation / recently-added endpoints. */
2
+ export interface RecentResource {
3
+ id: string;
4
+ title: string;
5
+ subtitle: string;
6
+ type: string;
7
+ }
8
+ export interface RecentResourcesResponse {
9
+ items: RecentResource[];
10
+ }
11
+ //# sourceMappingURL=recent-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recent-resource.d.ts","sourceRoot":"","sources":["../../src/types/recent-resource.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=recent-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recent-resource.js","sourceRoot":"","sources":["../../src/types/recent-resource.ts"],"names":[],"mappings":"","sourcesContent":["/** Album, playlist, or station from history / heavy-rotation / recently-added endpoints. */\nexport interface RecentResource {\n id: string;\n title: string;\n subtitle: string;\n type: string;\n}\n\nexport interface RecentResourcesResponse {\n items: RecentResource[];\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { Album } from './album';
2
+ import type { Artist } from './artist';
3
+ import type { Playlist } from './playlist';
4
+ import type { Song } from './song';
5
+ import type { Station } from './station';
6
+ export interface Recommendation {
7
+ id: string;
8
+ title: string;
9
+ resourceTypes: string[];
10
+ playlists: Playlist[];
11
+ albums: Album[];
12
+ stations: Station[];
13
+ }
14
+ export interface RecommendationsResponse {
15
+ recommendations: Recommendation[];
16
+ }
17
+ export interface ReplaySummary {
18
+ id: string;
19
+ type: string;
20
+ name: string;
21
+ year?: number;
22
+ topSongs: Song[];
23
+ topAlbums: Album[];
24
+ topArtists: Artist[];
25
+ }
26
+ export interface ReplayResponse {
27
+ summaries: ReplaySummary[];
28
+ }
29
+ export interface RecommendationsOptions {
30
+ /** Personal-recommendation ids (e.g. `6-27s5hU6azhJY`). Omit to fetch all via native/REST. */
31
+ ids?: string[];
32
+ }
33
+ export interface ReplayOptions {
34
+ /** Calendar year; omit for the latest eligible year Apple returns. */
35
+ year?: number;
36
+ }
37
+ //# sourceMappingURL=recommendation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendation.d.ts","sourceRoot":"","sources":["../../src/types/recommendation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,SAAS,EAAE,KAAK,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,8FAA8F;IAC9F,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=recommendation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommendation.js","sourceRoot":"","sources":["../../src/types/recommendation.ts"],"names":[],"mappings":"","sourcesContent":["import type { Album } from './album';\nimport type { Artist } from './artist';\nimport type { Playlist } from './playlist';\nimport type { Song } from './song';\nimport type { Station } from './station';\n\nexport interface Recommendation {\n id: string;\n title: string;\n resourceTypes: string[];\n playlists: Playlist[];\n albums: Album[];\n stations: Station[];\n}\n\nexport interface RecommendationsResponse {\n recommendations: Recommendation[];\n}\n\nexport interface ReplaySummary {\n id: string;\n type: string;\n name: string;\n year?: number;\n topSongs: Song[];\n topAlbums: Album[];\n topArtists: Artist[];\n}\n\nexport interface ReplayResponse {\n summaries: ReplaySummary[];\n}\n\nexport interface RecommendationsOptions {\n /** Personal-recommendation ids (e.g. `6-27s5hU6azhJY`). Omit to fetch all via native/REST. */\n ids?: string[];\n}\n\nexport interface ReplayOptions {\n /** Calendar year; omit for the latest eligible year Apple returns. */\n year?: number;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export interface Song {
2
+ artistName: string;
3
+ title: string;
4
+ artworkUrl: string;
5
+ id: string;
6
+ duration: number;
7
+ }
8
+ //# sourceMappingURL=song.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"song.d.ts","sourceRoot":"","sources":["../../src/types/song.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=song.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"song.js","sourceRoot":"","sources":["../../src/types/song.ts"],"names":[],"mappings":"","sourcesContent":["export interface Song {\n artistName: string;\n title: string;\n artworkUrl: string;\n id: string;\n duration: number;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export interface Station {
2
+ id: string;
3
+ name: string;
4
+ artworkUrl: string;
5
+ }
6
+ export interface StationsResponse {
7
+ stations: Station[];
8
+ }
9
+ //# sourceMappingURL=station.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"station.d.ts","sourceRoot":"","sources":["../../src/types/station.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=station.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"station.js","sourceRoot":"","sources":["../../src/types/station.ts"],"names":[],"mappings":"","sourcesContent":["export interface Station {\n id: string;\n name: string;\n artworkUrl: string;\n}\n\nexport interface StationsResponse {\n stations: Station[];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export interface Storefront {
2
+ id: string;
3
+ }
4
+ //# sourceMappingURL=storefront.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront.d.ts","sourceRoot":"","sources":["../../src/types/storefront.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;CACZ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=storefront.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront.js","sourceRoot":"","sources":["../../src/types/storefront.ts"],"names":[],"mappings":"","sourcesContent":["export interface Storefront {\n id: string;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { MusicItem } from './music-item';
2
+ export interface UserTrack {
3
+ id: string;
4
+ title: string;
5
+ subtitle: string;
6
+ type: MusicItem | string;
7
+ }
8
+ export interface TracksFromLibrary {
9
+ recentlyPlayedItems: UserTrack[];
10
+ }
11
+ //# sourceMappingURL=tracks-from-library.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracks-from-library.d.ts","sourceRoot":"","sources":["../../src/types/tracks-from-library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,EAAE,SAAS,EAAE,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tracks-from-library.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracks-from-library.js","sourceRoot":"","sources":["../../src/types/tracks-from-library.ts"],"names":[],"mappings":"","sourcesContent":["import type { MusicItem } from './music-item';\n\nexport interface UserTrack {\n id: string;\n title: string;\n subtitle: string;\n type: MusicItem | string;\n}\n\nexport interface TracksFromLibrary {\n recentlyPlayedItems: UserTrack[];\n}\n"]}
@@ -0,0 +1,10 @@
1
+ export type AppleMusicError = {
2
+ code: string;
3
+ message: string;
4
+ operation?: string;
5
+ };
6
+ export type AppleMusicErrorInstance = Error & AppleMusicError;
7
+ export declare function isAppleMusicError(error: unknown): error is AppleMusicError;
8
+ /** Throw shape for bridge rejections — `instanceof Error` and readable `String(error)`. */
9
+ export declare function asThrownAppleMusicError(error: AppleMusicError): AppleMusicErrorInstance;
10
+ //# sourceMappingURL=apple-music-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-music-error.d.ts","sourceRoot":"","sources":["../../src/utils/apple-music-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,eAAe,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAS1E;AAED,2FAA2F;AAC3F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,uBAAuB,CAEvF"}
@@ -0,0 +1,13 @@
1
+ export function isAppleMusicError(error) {
2
+ return (typeof error === 'object' &&
3
+ error !== null &&
4
+ 'code' in error &&
5
+ 'message' in error &&
6
+ typeof error.code === 'string' &&
7
+ typeof error.message === 'string');
8
+ }
9
+ /** Throw shape for bridge rejections — `instanceof Error` and readable `String(error)`. */
10
+ export function asThrownAppleMusicError(error) {
11
+ return Object.assign(new Error(error.message), error);
12
+ }
13
+ //# sourceMappingURL=apple-music-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-music-error.js","sourceRoot":"","sources":["../../src/utils/apple-music-error.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,SAAS,IAAI,KAAK;QAClB,OAAQ,KAAyB,CAAC,IAAI,KAAK,QAAQ;QACnD,OAAQ,KAAyB,CAAC,OAAO,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,uBAAuB,CAAC,KAAsB;IAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC","sourcesContent":["export type AppleMusicError = {\n code: string;\n message: string;\n operation?: string;\n};\n\nexport type AppleMusicErrorInstance = Error & AppleMusicError;\n\nexport function isAppleMusicError(error: unknown): error is AppleMusicError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n 'message' in error &&\n typeof (error as AppleMusicError).code === 'string' &&\n typeof (error as AppleMusicError).message === 'string'\n );\n}\n\n/** Throw shape for bridge rejections — `instanceof Error` and readable `String(error)`. */\nexport function asThrownAppleMusicError(error: AppleMusicError): AppleMusicErrorInstance {\n return Object.assign(new Error(error.message), error);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const getErrorMessage: (error: unknown, fallback?: string) => string;
2
+ //# sourceMappingURL=get-error-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-error-message.d.ts","sourceRoot":"","sources":["../../src/utils/get-error-message.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,iBAA0B,KAAG,MAsB5E,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { AppleMusicErrorCode } from '../constants/apple-music-error-codes';
2
+ import { isAppleMusicError } from './apple-music-error';
3
+ export const getErrorMessage = (error, fallback = 'Unknown error') => {
4
+ if (isAppleMusicError(error)) {
5
+ const prefix = error.code && error.code !== AppleMusicErrorCode.error ? `${error.code}: ` : '';
6
+ const operation = error.operation ? ` (${error.operation})` : '';
7
+ return `${prefix}${error.message}${operation}`;
8
+ }
9
+ if (error instanceof Error && error.message.trim().length > 0) {
10
+ return error.message;
11
+ }
12
+ const e = error;
13
+ if (typeof e?.message === 'string' && e.message.trim().length > 0) {
14
+ return e.message;
15
+ }
16
+ if (typeof error === 'string' && error.trim().length > 0) {
17
+ return error;
18
+ }
19
+ return fallback;
20
+ };
21
+ //# sourceMappingURL=get-error-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-error-message.js","sourceRoot":"","sources":["../../src/utils/get-error-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAAE,QAAQ,GAAG,eAAe,EAAU,EAAE;IACpF,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,MAAM,GACV,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC;IACjD,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,GAAG,KAA6B,CAAC;IACxC,IAAI,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { AppleMusicErrorCode } from '../constants/apple-music-error-codes';\nimport { isAppleMusicError } from './apple-music-error';\n\nexport const getErrorMessage = (error: unknown, fallback = 'Unknown error'): string => {\n if (isAppleMusicError(error)) {\n const prefix =\n error.code && error.code !== AppleMusicErrorCode.error ? `${error.code}: ` : '';\n const operation = error.operation ? ` (${error.operation})` : '';\n return `${prefix}${error.message}${operation}`;\n }\n\n if (error instanceof Error && error.message.trim().length > 0) {\n return error.message;\n }\n\n const e = error as { message?: string };\n if (typeof e?.message === 'string' && e.message.trim().length > 0) {\n return e.message;\n }\n\n if (typeof error === 'string' && error.trim().length > 0) {\n return error;\n }\n\n return fallback;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const isLibraryItem: (id: string) => boolean;
2
+ //# sourceMappingURL=is-library-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-library-item.d.ts","sourceRoot":"","sources":["../../src/utils/is-library-item.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,KAAG,OAED,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const isLibraryItem = (id) =>
2
+ // Library items typically start with 'i.' or 'l.' or contain non-numeric characters
3
+ /^[a-z]\./.test(id) || !/^\d+$/.test(id);
4
+ //# sourceMappingURL=is-library-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-library-item.js","sourceRoot":"","sources":["../../src/utils/is-library-item.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAU,EAAW,EAAE;AACnD,oFAAoF;AACpF,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC","sourcesContent":["export const isLibraryItem = (id: string): boolean =>\n // Library items typically start with 'i.' or 'l.' or contain non-numeric characters\n /^[a-z]\\./.test(id) || !/^\\d+$/.test(id);\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ResourceIds } from '../types/rating';
2
+ /** Drops empty type keys before sending to native REST helpers. */
3
+ export declare function normalizeResourceIds(resourceIds: ResourceIds): Record<string, string[]>;
4
+ //# sourceMappingURL=normalize-resource-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-resource-ids.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-resource-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CASvF"}
@@ -0,0 +1,12 @@
1
+ /** Drops empty type keys before sending to native REST helpers. */
2
+ export function normalizeResourceIds(resourceIds) {
3
+ const result = {};
4
+ for (const [type, ids] of Object.entries(resourceIds)) {
5
+ const filtered = ids?.filter((id) => id.length > 0) ?? [];
6
+ if (filtered.length > 0) {
7
+ result[type] = filtered;
8
+ }
9
+ }
10
+ return result;
11
+ }
12
+ //# sourceMappingURL=normalize-resource-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-resource-ids.js","sourceRoot":"","sources":["../../src/utils/normalize-resource-ids.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,MAAM,GAA6B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACtD,MAAM,QAAQ,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ResourceIds } from '../types/rating';\n\n/** Drops empty type keys before sending to native REST helpers. */\nexport function normalizeResourceIds(resourceIds: ResourceIds): Record<string, string[]> {\n const result: Record<string, string[]> = {};\n for (const [type, ids] of Object.entries(resourceIds)) {\n const filtered = ids?.filter((id) => id.length > 0) ?? [];\n if (filtered.length > 0) {\n result[type] = filtered;\n }\n }\n return result;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { MusicKitInstance } from './musickit-types';
2
+ export declare function getStoredDeveloperToken(): string | null;
3
+ export declare function configureMusicKit(token: string): Promise<MusicKitInstance>;
4
+ export declare function isMusicKitConfigured(): boolean;
5
+ /** Returns null when `authorize()` has not configured MusicKit yet (or configure failed). */
6
+ export declare function getMusicIfConfigured(): Promise<MusicKitInstance | null>;
7
+ export declare function getMusic(): Promise<MusicKitInstance>;
8
+ /** Prefer after `authorize()` — MusicKit may update the singleton instance in place. */
9
+ export declare function getMusicKitInstance(): Promise<MusicKitInstance>;
10
+ export declare function resetMusicKitForTests(): void;
11
+ //# sourceMappingURL=MusicKitLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MusicKitLoader.d.ts","sourceRoot":"","sources":["../../src/web/MusicKitLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,kBAAkB,CAAC;AAmFzE,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,IAAI,CAEvD;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA6BhF;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,6FAA6F;AAC7F,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAS7E;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAM1D;AAED,wFAAwF;AACxF,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAOrE;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C"}
@@ -0,0 +1,135 @@
1
+ const MUSIC_KIT_SCRIPT = 'https://js-cdn.music.apple.com/musickit/v3/musickit.js';
2
+ const MUSIC_KIT_LOADED_EVENT = 'musickitloaded';
3
+ let configurePromise = null;
4
+ let configuredToken = null;
5
+ function assertBrowser() {
6
+ if (typeof window === 'undefined') {
7
+ throw new Error('Apple Music web APIs require a browser environment');
8
+ }
9
+ }
10
+ /**
11
+ * Expo / Metro define `process.env` in the browser but often omit `process.versions`.
12
+ * MusicKit JS tests `null !== process.versions` (true when `versions` is `undefined`), then
13
+ * reads `process.versions.node` and throws. Force a null `versions` so it picks `window.Buffer`.
14
+ */
15
+ function patchProcessForMusicKit() {
16
+ if (typeof process === 'undefined') {
17
+ return;
18
+ }
19
+ if (process.versions == null) {
20
+ // Intentionally null — see docstring above.
21
+ Object.assign(process, { versions: null });
22
+ }
23
+ }
24
+ function waitForMusicKitLoaded() {
25
+ return new Promise((resolve, reject) => {
26
+ const onLoaded = () => {
27
+ cleanup();
28
+ resolve();
29
+ };
30
+ const onError = () => {
31
+ cleanup();
32
+ reject(new Error('MusicKit JS failed to load'));
33
+ };
34
+ const cleanup = () => {
35
+ document.removeEventListener(MUSIC_KIT_LOADED_EVENT, onLoaded);
36
+ document.removeEventListener('musickiterror', onError);
37
+ };
38
+ document.addEventListener(MUSIC_KIT_LOADED_EVENT, onLoaded, { once: true });
39
+ document.addEventListener('musickiterror', onError, { once: true });
40
+ // Script may have fired the event before we subscribed.
41
+ if (window.MusicKit?.configure) {
42
+ cleanup();
43
+ resolve();
44
+ }
45
+ });
46
+ }
47
+ async function loadMusicKitScript() {
48
+ assertBrowser();
49
+ patchProcessForMusicKit();
50
+ if (window.MusicKit?.configure) {
51
+ return window.MusicKit;
52
+ }
53
+ const existing = document.querySelector(`script[src="${MUSIC_KIT_SCRIPT}"]`);
54
+ if (!existing) {
55
+ await new Promise((resolve, reject) => {
56
+ const script = document.createElement('script');
57
+ script.src = MUSIC_KIT_SCRIPT;
58
+ script.async = true;
59
+ script.onload = () => resolve();
60
+ script.onerror = () => reject(new Error('MusicKit JS failed to load'));
61
+ document.head.appendChild(script);
62
+ });
63
+ }
64
+ await waitForMusicKitLoaded();
65
+ if (!window.MusicKit?.configure) {
66
+ throw new Error('MusicKit JS is unavailable after script load');
67
+ }
68
+ return window.MusicKit;
69
+ }
70
+ export function getStoredDeveloperToken() {
71
+ return configuredToken;
72
+ }
73
+ export async function configureMusicKit(token) {
74
+ assertBrowser();
75
+ const trimmed = token.trim();
76
+ const tokenChanged = configuredToken !== null && configuredToken !== trimmed;
77
+ configuredToken = trimmed;
78
+ if (configurePromise && tokenChanged) {
79
+ configurePromise = null;
80
+ }
81
+ if (!configurePromise) {
82
+ configurePromise = (async () => {
83
+ const MusicKit = await loadMusicKitScript();
84
+ await MusicKit.configure({
85
+ developerToken: trimmed,
86
+ app: {
87
+ name: 'Expo Apple Music',
88
+ build: '0.1.0',
89
+ },
90
+ });
91
+ const instance = MusicKit.getInstance();
92
+ if (!instance) {
93
+ throw new Error('MusicKit JS did not return an instance after configure()');
94
+ }
95
+ return instance;
96
+ })();
97
+ }
98
+ return configurePromise;
99
+ }
100
+ export function isMusicKitConfigured() {
101
+ return configurePromise !== null;
102
+ }
103
+ /** Returns null when `authorize()` has not configured MusicKit yet (or configure failed). */
104
+ export async function getMusicIfConfigured() {
105
+ if (!configurePromise) {
106
+ return null;
107
+ }
108
+ try {
109
+ return await configurePromise;
110
+ }
111
+ catch {
112
+ return null;
113
+ }
114
+ }
115
+ export async function getMusic() {
116
+ const music = await getMusicIfConfigured();
117
+ if (!music) {
118
+ throw new Error('MusicKit is not configured. Call Auth.authorize(developerToken) first.');
119
+ }
120
+ return music;
121
+ }
122
+ /** Prefer after `authorize()` — MusicKit may update the singleton instance in place. */
123
+ export async function getMusicKitInstance() {
124
+ const MusicKit = await loadMusicKitScript();
125
+ const instance = MusicKit.getInstance();
126
+ if (!instance) {
127
+ throw new Error('MusicKit JS did not return an instance');
128
+ }
129
+ return instance;
130
+ }
131
+ export function resetMusicKitForTests() {
132
+ configurePromise = null;
133
+ configuredToken = null;
134
+ }
135
+ //# sourceMappingURL=MusicKitLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MusicKitLoader.js","sourceRoot":"","sources":["../../src/web/MusicKitLoader.ts"],"names":[],"mappings":"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","sourcesContent":["import type { MusicKitInstance, MusicKitStatic } from './musickit-types';\n\nconst MUSIC_KIT_SCRIPT = 'https://js-cdn.music.apple.com/musickit/v3/musickit.js';\nconst MUSIC_KIT_LOADED_EVENT = 'musickitloaded';\n\nlet configurePromise: Promise<MusicKitInstance> | null = null;\nlet configuredToken: string | null = null;\n\nfunction assertBrowser(): void {\n if (typeof window === 'undefined') {\n throw new Error('Apple Music web APIs require a browser environment');\n }\n}\n\n/**\n * Expo / Metro define `process.env` in the browser but often omit `process.versions`.\n * MusicKit JS tests `null !== process.versions` (true when `versions` is `undefined`), then\n * reads `process.versions.node` and throws. Force a null `versions` so it picks `window.Buffer`.\n */\nfunction patchProcessForMusicKit(): void {\n if (typeof process === 'undefined') {\n return;\n }\n if (process.versions == null) {\n // Intentionally null — see docstring above.\n Object.assign(process, { versions: null });\n }\n}\n\nfunction waitForMusicKitLoaded(): Promise<void> {\n return new Promise((resolve, reject) => {\n const onLoaded = () => {\n cleanup();\n resolve();\n };\n const onError = () => {\n cleanup();\n reject(new Error('MusicKit JS failed to load'));\n };\n const cleanup = () => {\n document.removeEventListener(MUSIC_KIT_LOADED_EVENT, onLoaded);\n document.removeEventListener('musickiterror', onError);\n };\n\n document.addEventListener(MUSIC_KIT_LOADED_EVENT, onLoaded, { once: true });\n document.addEventListener('musickiterror', onError, { once: true });\n\n // Script may have fired the event before we subscribed.\n if (window.MusicKit?.configure) {\n cleanup();\n resolve();\n }\n });\n}\n\nasync function loadMusicKitScript(): Promise<MusicKitStatic> {\n assertBrowser();\n patchProcessForMusicKit();\n\n if (window.MusicKit?.configure) {\n return window.MusicKit;\n }\n\n const existing = document.querySelector(`script[src=\"${MUSIC_KIT_SCRIPT}\"]`);\n if (!existing) {\n await new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = MUSIC_KIT_SCRIPT;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error('MusicKit JS failed to load'));\n document.head.appendChild(script);\n });\n }\n\n await waitForMusicKitLoaded();\n\n if (!window.MusicKit?.configure) {\n throw new Error('MusicKit JS is unavailable after script load');\n }\n return window.MusicKit;\n}\n\nexport function getStoredDeveloperToken(): string | null {\n return configuredToken;\n}\n\nexport async function configureMusicKit(token: string): Promise<MusicKitInstance> {\n assertBrowser();\n const trimmed = token.trim();\n const tokenChanged = configuredToken !== null && configuredToken !== trimmed;\n configuredToken = trimmed;\n\n if (configurePromise && tokenChanged) {\n configurePromise = null;\n }\n\n if (!configurePromise) {\n configurePromise = (async () => {\n const MusicKit = await loadMusicKitScript();\n await MusicKit.configure({\n developerToken: trimmed,\n app: {\n name: 'Expo Apple Music',\n build: '0.1.0',\n },\n });\n const instance = MusicKit.getInstance();\n if (!instance) {\n throw new Error('MusicKit JS did not return an instance after configure()');\n }\n return instance;\n })();\n }\n\n return configurePromise;\n}\n\nexport function isMusicKitConfigured(): boolean {\n return configurePromise !== null;\n}\n\n/** Returns null when `authorize()` has not configured MusicKit yet (or configure failed). */\nexport async function getMusicIfConfigured(): Promise<MusicKitInstance | null> {\n if (!configurePromise) {\n return null;\n }\n try {\n return await configurePromise;\n } catch {\n return null;\n }\n}\n\nexport async function getMusic(): Promise<MusicKitInstance> {\n const music = await getMusicIfConfigured();\n if (!music) {\n throw new Error('MusicKit is not configured. Call Auth.authorize(developerToken) first.');\n }\n return music;\n}\n\n/** Prefer after `authorize()` — MusicKit may update the singleton instance in place. */\nexport async function getMusicKitInstance(): Promise<MusicKitInstance> {\n const MusicKit = await loadMusicKitScript();\n const instance = MusicKit.getInstance();\n if (!instance) {\n throw new Error('MusicKit JS did not return an instance');\n }\n return instance;\n}\n\nexport function resetMusicKitForTests(): void {\n configurePromise = null;\n configuredToken = null;\n}\n"]}