@wwdrew/expo-spotify-sdk 1.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -350
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/spotifysdk/ExpoSpotifySDKModule.kt +3 -5
- package/android/src/main/java/expo/modules/spotifysdk/SpotifyAppRemoteCoordinator.kt +6 -64
- package/android/src/main/java/expo/modules/spotifysdk/SpotifyAppRemoteErrorMapping.kt +106 -0
- package/android/src/main/java/expo/modules/spotifysdk/SpotifyTokenSwapClient.kt +2 -7
- package/app.plugin.js +1 -1
- package/build/app-remote/index.d.ts +2 -2
- package/build/app-remote/index.d.ts.map +1 -1
- package/build/app-remote/index.js +11 -24
- package/build/app-remote/index.js.map +1 -1
- package/build/auth/index.d.ts +2 -2
- package/build/auth/index.d.ts.map +1 -1
- package/build/auth/index.js +17 -34
- package/build/auth/index.js.map +1 -1
- package/build/content/index.d.ts.map +1 -1
- package/build/content/index.js +12 -25
- package/build/content/index.js.map +1 -1
- package/build/hooks/index.d.ts +4 -4
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +38 -115
- package/build/hooks/index.js.map +1 -1
- package/build/images/index.d.ts +2 -2
- package/build/images/index.d.ts.map +1 -1
- package/build/images/index.js +12 -25
- package/build/images/index.js.map +1 -1
- package/build/index.d.ts +0 -18
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -27
- package/build/index.js.map +1 -1
- package/build/internal/native-errors.d.ts +14 -0
- package/build/internal/native-errors.d.ts.map +1 -0
- package/build/internal/native-errors.js +29 -0
- package/build/internal/native-errors.js.map +1 -0
- package/build/internal/sync-external-store.d.ts +14 -0
- package/build/internal/sync-external-store.d.ts.map +1 -0
- package/build/internal/sync-external-store.js +36 -0
- package/build/internal/sync-external-store.js.map +1 -0
- package/build/player/index.d.ts +1 -1
- package/build/player/index.d.ts.map +1 -1
- package/build/player/index.js +15 -27
- package/build/player/index.js.map +1 -1
- package/build/uri/index.js.map +1 -1
- package/build/user/index.d.ts +2 -2
- package/build/user/index.d.ts.map +1 -1
- package/build/user/index.js +16 -26
- package/build/user/index.js.map +1 -1
- package/ios/ExpoSpotifySDK.podspec +1 -1
- package/ios/ExpoSpotifySDKModule.swift +1 -1
- package/ios/SpotifyAppRemoteCoordinator.swift +29 -404
- package/ios/SpotifyAppRemoteErrorMapping.swift +110 -0
- package/ios/SpotifyAppRemoteErrors.swift +221 -0
- package/ios/SpotifyAppRemoteMappers.swift +88 -0
- package/package.json +28 -14
- package/plugin/build/index.d.ts +20 -3
- package/plugin/build/index.js +22 -25
- package/plugin/build/types.d.ts +17 -1
- package/plugin/build/withSpotifySdkConfig.d.ts +4 -0
- package/plugin/build/withSpotifySdkConfig.js +27 -0
- package/plugin/index.d.ts +2 -0
- package/plugin/index.js +1 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
// MARK: — App Remote error types
|
|
5
|
+
|
|
6
|
+
enum AppRemoteError: Error {
|
|
7
|
+
case connectionFailed(String)
|
|
8
|
+
case connectionLost(String)
|
|
9
|
+
case notConnected(String)
|
|
10
|
+
case unknown(String)
|
|
11
|
+
|
|
12
|
+
var code: String {
|
|
13
|
+
switch self {
|
|
14
|
+
case .connectionFailed: return "CONNECTION_FAILED"
|
|
15
|
+
case .connectionLost: return "CONNECTION_LOST"
|
|
16
|
+
case .notConnected: return "NOT_CONNECTED"
|
|
17
|
+
case .unknown: return "UNKNOWN"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var message: String {
|
|
22
|
+
switch self {
|
|
23
|
+
case .connectionFailed(let m): return m
|
|
24
|
+
case .connectionLost(let m): return m
|
|
25
|
+
case .notConnected(let m): return m
|
|
26
|
+
case .unknown(let m): return m
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Bridges an `AppRemoteError` through expo-modules-core's exception system so
|
|
32
|
+
/// JS callers receive a structured `code` and `reason`, not "undefined reason".
|
|
33
|
+
final class AppRemoteException: Exception, @unchecked Sendable {
|
|
34
|
+
private let appRemoteCode: String
|
|
35
|
+
private let appRemoteMessage: String
|
|
36
|
+
|
|
37
|
+
init(_ error: AppRemoteError, file: String = #fileID, line: UInt = #line, function: String = #function) {
|
|
38
|
+
self.appRemoteCode = error.code
|
|
39
|
+
self.appRemoteMessage = error.message
|
|
40
|
+
super.init(file: file, line: line, function: function)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override var code: String { appRemoteCode }
|
|
44
|
+
override var reason: String { appRemoteMessage }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// MARK: — Player error types
|
|
48
|
+
|
|
49
|
+
enum NativePlayerError: Error {
|
|
50
|
+
case notConnected(String)
|
|
51
|
+
case connectionLost(String)
|
|
52
|
+
case premiumRequired(String)
|
|
53
|
+
case invalidURI(String)
|
|
54
|
+
case invalidParameter(String)
|
|
55
|
+
case operationNotAllowed(String)
|
|
56
|
+
case unknown(String)
|
|
57
|
+
|
|
58
|
+
var code: String {
|
|
59
|
+
switch self {
|
|
60
|
+
case .notConnected: return "NOT_CONNECTED"
|
|
61
|
+
case .connectionLost: return "CONNECTION_LOST"
|
|
62
|
+
case .premiumRequired: return "PREMIUM_REQUIRED"
|
|
63
|
+
case .invalidURI: return "INVALID_URI"
|
|
64
|
+
case .invalidParameter: return "INVALID_PARAMETER"
|
|
65
|
+
case .operationNotAllowed: return "OPERATION_NOT_ALLOWED"
|
|
66
|
+
case .unknown: return "UNKNOWN"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var message: String {
|
|
71
|
+
switch self {
|
|
72
|
+
case .notConnected(let m): return m
|
|
73
|
+
case .connectionLost(let m): return m
|
|
74
|
+
case .premiumRequired(let m): return m
|
|
75
|
+
case .invalidURI(let m): return m
|
|
76
|
+
case .invalidParameter(let m): return m
|
|
77
|
+
case .operationNotAllowed(let m): return m
|
|
78
|
+
case .unknown(let m): return m
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
final class PlayerException: Exception, @unchecked Sendable {
|
|
84
|
+
private let playerCode: String
|
|
85
|
+
private let playerMessage: String
|
|
86
|
+
|
|
87
|
+
init(_ error: NativePlayerError, file: String = #fileID, line: UInt = #line, function: String = #function) {
|
|
88
|
+
self.playerCode = error.code
|
|
89
|
+
self.playerMessage = error.message
|
|
90
|
+
super.init(file: file, line: line, function: function)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
override var code: String { playerCode }
|
|
94
|
+
override var reason: String { playerMessage }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// MARK: — User error types
|
|
98
|
+
|
|
99
|
+
enum NativeUserError: Error {
|
|
100
|
+
case notConnected(String)
|
|
101
|
+
case connectionLost(String)
|
|
102
|
+
case invalidURI(String)
|
|
103
|
+
case operationNotAllowed(String)
|
|
104
|
+
case unknown(String)
|
|
105
|
+
|
|
106
|
+
var code: String {
|
|
107
|
+
switch self {
|
|
108
|
+
case .notConnected: return "NOT_CONNECTED"
|
|
109
|
+
case .connectionLost: return "CONNECTION_LOST"
|
|
110
|
+
case .invalidURI: return "INVALID_URI"
|
|
111
|
+
case .operationNotAllowed: return "OPERATION_NOT_ALLOWED"
|
|
112
|
+
case .unknown: return "UNKNOWN"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var message: String {
|
|
117
|
+
switch self {
|
|
118
|
+
case .notConnected(let m): return m
|
|
119
|
+
case .connectionLost(let m): return m
|
|
120
|
+
case .invalidURI(let m): return m
|
|
121
|
+
case .operationNotAllowed(let m): return m
|
|
122
|
+
case .unknown(let m): return m
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
final class UserException: Exception, @unchecked Sendable {
|
|
128
|
+
private let userCode: String
|
|
129
|
+
private let userMessage: String
|
|
130
|
+
|
|
131
|
+
init(_ error: NativeUserError, file: String = #fileID, line: UInt = #line, function: String = #function) {
|
|
132
|
+
self.userCode = error.code
|
|
133
|
+
self.userMessage = error.message
|
|
134
|
+
super.init(file: file, line: line, function: function)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
override var code: String { userCode }
|
|
138
|
+
override var reason: String { userMessage }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// MARK: — Content error types
|
|
142
|
+
|
|
143
|
+
enum NativeContentError: Error {
|
|
144
|
+
case notConnected(String)
|
|
145
|
+
case connectionLost(String)
|
|
146
|
+
case contentAPIUnavailable(String)
|
|
147
|
+
case unknown(String)
|
|
148
|
+
|
|
149
|
+
var code: String {
|
|
150
|
+
switch self {
|
|
151
|
+
case .notConnected: return "NOT_CONNECTED"
|
|
152
|
+
case .connectionLost: return "CONNECTION_LOST"
|
|
153
|
+
case .contentAPIUnavailable: return "CONTENT_API_UNAVAILABLE"
|
|
154
|
+
case .unknown: return "UNKNOWN"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
var message: String {
|
|
159
|
+
switch self {
|
|
160
|
+
case .notConnected(let m): return m
|
|
161
|
+
case .connectionLost(let m): return m
|
|
162
|
+
case .contentAPIUnavailable(let m): return m
|
|
163
|
+
case .unknown(let m): return m
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
final class ContentException: Exception, @unchecked Sendable {
|
|
169
|
+
private let contentCode: String
|
|
170
|
+
private let contentMessage: String
|
|
171
|
+
|
|
172
|
+
init(_ error: NativeContentError, file: String = #fileID, line: UInt = #line, function: String = #function) {
|
|
173
|
+
self.contentCode = error.code
|
|
174
|
+
self.contentMessage = error.message
|
|
175
|
+
super.init(file: file, line: line, function: function)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override var code: String { contentCode }
|
|
179
|
+
override var reason: String { contentMessage }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// MARK: — Images error types
|
|
183
|
+
|
|
184
|
+
enum NativeImagesError: Error {
|
|
185
|
+
case notConnected(String)
|
|
186
|
+
case invalidURI(String)
|
|
187
|
+
case imageLoadFailed(String)
|
|
188
|
+
case unknown(String)
|
|
189
|
+
|
|
190
|
+
var code: String {
|
|
191
|
+
switch self {
|
|
192
|
+
case .notConnected: return "NOT_CONNECTED"
|
|
193
|
+
case .invalidURI: return "INVALID_URI"
|
|
194
|
+
case .imageLoadFailed: return "IMAGE_LOAD_FAILED"
|
|
195
|
+
case .unknown: return "UNKNOWN"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var message: String {
|
|
200
|
+
switch self {
|
|
201
|
+
case .notConnected(let m): return m
|
|
202
|
+
case .invalidURI(let m): return m
|
|
203
|
+
case .imageLoadFailed(let m): return m
|
|
204
|
+
case .unknown(let m): return m
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
final class ImagesException: Exception, @unchecked Sendable {
|
|
210
|
+
private let imagesCode: String
|
|
211
|
+
private let imagesMessage: String
|
|
212
|
+
|
|
213
|
+
init(_ error: NativeImagesError, file: String = #fileID, line: UInt = #line, function: String = #function) {
|
|
214
|
+
self.imagesCode = error.code
|
|
215
|
+
self.imagesMessage = error.message
|
|
216
|
+
super.init(file: file, line: line, function: function)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
override var code: String { imagesCode }
|
|
220
|
+
override var reason: String { imagesMessage }
|
|
221
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SpotifyiOS
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
/// Serializes Spotify App Remote SDK objects into NSDictionary-compatible payloads
|
|
6
|
+
/// for the Expo JS bridge.
|
|
7
|
+
enum SpotifyAppRemoteMappers {
|
|
8
|
+
static func playerStateToMap(_ state: any SPTAppRemotePlayerState) -> [String: Any] {
|
|
9
|
+
let track = state.track
|
|
10
|
+
let restrictions = state.playbackRestrictions
|
|
11
|
+
let options = state.playbackOptions
|
|
12
|
+
return [
|
|
13
|
+
"track": [
|
|
14
|
+
"uri": track.uri,
|
|
15
|
+
"name": track.name,
|
|
16
|
+
"imageIdentifier": track.imageIdentifier,
|
|
17
|
+
"duration": track.duration,
|
|
18
|
+
"artist": ["name": track.artist.name, "uri": track.artist.uri],
|
|
19
|
+
"album": ["name": track.album.name, "uri": track.album.uri],
|
|
20
|
+
"isSaved": track.isSaved,
|
|
21
|
+
"isEpisode": track.isEpisode,
|
|
22
|
+
"isPodcast": track.isPodcast,
|
|
23
|
+
"isAdvertisement": track.isAdvertisement,
|
|
24
|
+
] as [String: Any],
|
|
25
|
+
"playbackPosition": state.playbackPosition,
|
|
26
|
+
"playbackSpeed": state.playbackSpeed,
|
|
27
|
+
"isPaused": state.isPaused,
|
|
28
|
+
"playbackOptions": [
|
|
29
|
+
"isShuffling": options.isShuffling,
|
|
30
|
+
"repeatMode": options.repeatMode.rawValue,
|
|
31
|
+
] as [String: Any],
|
|
32
|
+
"playbackRestrictions": [
|
|
33
|
+
"canSkipNext": restrictions.canSkipNext,
|
|
34
|
+
"canSkipPrevious": restrictions.canSkipPrevious,
|
|
35
|
+
"canRepeatTrack": restrictions.canRepeatTrack,
|
|
36
|
+
"canRepeatContext": restrictions.canRepeatContext,
|
|
37
|
+
"canToggleShuffle": restrictions.canToggleShuffle,
|
|
38
|
+
"canSeek": restrictions.canSeek,
|
|
39
|
+
] as [String: Any],
|
|
40
|
+
"contextTitle": state.contextTitle,
|
|
41
|
+
"contextUri": state.contextURI.absoluteString,
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static func capabilitiesToMap(_ capabilities: any SPTAppRemoteUserCapabilities) -> [String: Any] {
|
|
46
|
+
["canPlayOnDemand": capabilities.canPlayOnDemand]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static func libraryStateToMap(_ state: any SPTAppRemoteLibraryState) -> [String: Any] {
|
|
50
|
+
["uri": state.uri, "isAdded": state.isAdded, "canAdd": state.canAdd]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static func mapContentType(_ type: String) -> String {
|
|
54
|
+
switch type {
|
|
55
|
+
case "navigation": return SPTAppRemoteContentTypeNavigation
|
|
56
|
+
case "fitness": return SPTAppRemoteContentTypeFitness
|
|
57
|
+
case "gaming": return SPTAppRemoteContentTypeGaming
|
|
58
|
+
default: return SPTAppRemoteContentTypeDefault
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static func mapImageSize(_ size: String) -> CGSize {
|
|
63
|
+
switch size {
|
|
64
|
+
case "small": return CGSize(width: 64, height: 64)
|
|
65
|
+
case "medium": return CGSize(width: 300, height: 300)
|
|
66
|
+
default: return CGSize(width: 640, height: 640)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static func contentItemToMap(_ item: any SPTAppRemoteContentItem) -> [String: Any] {
|
|
71
|
+
var map: [String: Any] = [
|
|
72
|
+
"title": item.title as Any,
|
|
73
|
+
"subtitle": item.subtitle as Any,
|
|
74
|
+
"contentDescription": item.contentDescription as Any,
|
|
75
|
+
"identifier": item.identifier,
|
|
76
|
+
"uri": item.uri,
|
|
77
|
+
"imageIdentifier": item.imageIdentifier,
|
|
78
|
+
"isAvailableOffline": item.isAvailableOffline,
|
|
79
|
+
"isPlayable": item.isPlayable,
|
|
80
|
+
"isContainer": item.isContainer,
|
|
81
|
+
"isPinned": item.isPinned,
|
|
82
|
+
]
|
|
83
|
+
if let children = item.children {
|
|
84
|
+
map["children"] = children.map(contentItemToMap)
|
|
85
|
+
}
|
|
86
|
+
return map
|
|
87
|
+
}
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwdrew/expo-spotify-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Expo module wrapping the native Spotify iOS (v5) and Android (v4) SDKs for OAuth authentication and App Remote playback control",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./build/index.d.ts",
|
|
10
|
+
"default": "./build/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./plugin": {
|
|
13
|
+
"types": "./plugin/build/index.d.ts",
|
|
14
|
+
"default": "./plugin/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"prepublishOnly": "
|
|
14
|
-
"typecheck": "
|
|
15
|
-
"expo-module": "expo-module",
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"build:plugin": "tsc -p plugin/tsconfig.json",
|
|
20
|
+
"clean": "rm -rf build plugin/build",
|
|
21
|
+
"lint": "eslint src",
|
|
22
|
+
"test": "jest --config jest.config.js",
|
|
23
|
+
"prepublishOnly": "yarn clean && yarn build && yarn build:plugin",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
16
25
|
"open:ios": "open -a \"Xcode\" example/ios",
|
|
17
26
|
"open:android": "open -a \"Android Studio\" example/android"
|
|
18
27
|
},
|
|
@@ -24,6 +33,8 @@
|
|
|
24
33
|
"Spotify"
|
|
25
34
|
],
|
|
26
35
|
"files": [
|
|
36
|
+
"plugin/index.js",
|
|
37
|
+
"plugin/index.d.ts",
|
|
27
38
|
"plugin/build",
|
|
28
39
|
"build",
|
|
29
40
|
"android",
|
|
@@ -39,13 +50,16 @@
|
|
|
39
50
|
"license": "MIT",
|
|
40
51
|
"homepage": "https://github.com/wwdrew/expo-spotify-sdk#readme",
|
|
41
52
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
53
|
+
"@babel/runtime": "^7.29.7",
|
|
54
|
+
"@expo/config-plugins": "^56.0.8",
|
|
55
|
+
"@types/react": "^19.0.0",
|
|
56
|
+
"babel-preset-expo": "~56.0.0",
|
|
44
57
|
"eslint": "^9.0.0",
|
|
45
|
-
"expo-module-scripts": "^
|
|
46
|
-
"expo-modules-core": "^
|
|
58
|
+
"expo-module-scripts": "^56.0.2",
|
|
59
|
+
"expo-modules-core": "^56.0.13",
|
|
47
60
|
"jest": "^29.7.0",
|
|
48
|
-
"prettier": "^3.0.0"
|
|
61
|
+
"prettier": "^3.0.0",
|
|
62
|
+
"typescript": "^5.9.0"
|
|
49
63
|
},
|
|
50
64
|
"peerDependencies": {
|
|
51
65
|
"expo": "*",
|
package/plugin/build/index.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import { ConfigPlugin } from "@expo/config-plugins";
|
|
2
1
|
import { SpotifyConfig } from "./types";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Typed config plugin helper for `app.config.ts` (Expo SDK 56+).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import withSpotifySdk from "@wwdrew/expo-spotify-sdk/plugin";
|
|
7
|
+
*
|
|
8
|
+
* export default ({ config }) => ({
|
|
9
|
+
* ...config,
|
|
10
|
+
* plugins: [
|
|
11
|
+
* withSpotifySdk({
|
|
12
|
+
* clientID: "your-spotify-client-id",
|
|
13
|
+
* scheme: "myapp",
|
|
14
|
+
* host: "spotify-auth",
|
|
15
|
+
* }),
|
|
16
|
+
* ],
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
declare const _default: (props: SpotifyConfig) => [string, SpotifyConfig];
|
|
20
|
+
export default _default;
|
|
21
|
+
export type { SpotifyConfig, SpotifyScopes } from "./types";
|
package/plugin/build/index.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
exports.withSpotifySdkConfig = withSpotifySdkConfig;
|
|
27
|
-
exports.default = exports.withSpotifySdkConfig;
|
|
3
|
+
const PACKAGE_NAME = "@wwdrew/expo-spotify-sdk";
|
|
4
|
+
/**
|
|
5
|
+
* Typed config plugin helper for `app.config.ts` (Expo SDK 56+).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import withSpotifySdk from "@wwdrew/expo-spotify-sdk/plugin";
|
|
9
|
+
*
|
|
10
|
+
* export default ({ config }) => ({
|
|
11
|
+
* ...config,
|
|
12
|
+
* plugins: [
|
|
13
|
+
* withSpotifySdk({
|
|
14
|
+
* clientID: "your-spotify-client-id",
|
|
15
|
+
* scheme: "myapp",
|
|
16
|
+
* host: "spotify-auth",
|
|
17
|
+
* }),
|
|
18
|
+
* ],
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
exports.default = (props) => [
|
|
22
|
+
PACKAGE_NAME,
|
|
23
|
+
props,
|
|
24
|
+
];
|
package/plugin/build/types.d.ts
CHANGED
|
@@ -8,7 +8,23 @@ export type SpotifyScopes = "ugc-image-upload" | "user-read-playback-state" | "u
|
|
|
8
8
|
* Configuration accepted by the `@wwdrew/expo-spotify-sdk` Expo config plugin.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* // app.config.ts
|
|
11
|
+
* // app.config.ts (Expo SDK 56+ — typed import)
|
|
12
|
+
* import withSpotifySdk from "@wwdrew/expo-spotify-sdk/plugin";
|
|
13
|
+
*
|
|
14
|
+
* export default ({ config }) => ({
|
|
15
|
+
* ...config,
|
|
16
|
+
* plugins: [
|
|
17
|
+
* withSpotifySdk({
|
|
18
|
+
* clientID: "<spotify-client-id>",
|
|
19
|
+
* scheme: "myapp",
|
|
20
|
+
* host: "spotify-auth",
|
|
21
|
+
* redirectPathPattern: ".*",
|
|
22
|
+
* }),
|
|
23
|
+
* ],
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // app.config.ts / app.json (string tuple — all SDK versions)
|
|
12
28
|
* export default {
|
|
13
29
|
* plugins: [
|
|
14
30
|
* ["@wwdrew/expo-spotify-sdk", {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withSpotifySdkConfig = void 0;
|
|
4
|
+
const withSpotifyAndroidAppBuildGradle_1 = require("./android/withSpotifyAndroidAppBuildGradle");
|
|
5
|
+
const withSpotifyConfigValues_1 = require("./ios/withSpotifyConfigValues");
|
|
6
|
+
const withSpotifyQueryScheme_1 = require("./ios/withSpotifyQueryScheme");
|
|
7
|
+
const withSpotifyURLScheme_1 = require("./ios/withSpotifyURLScheme");
|
|
8
|
+
const withSpotifySdkConfig = (config, spotifyConfig) => {
|
|
9
|
+
if (!spotifyConfig.host) {
|
|
10
|
+
throw new Error("Missing required Spotify config value: host");
|
|
11
|
+
}
|
|
12
|
+
if (!spotifyConfig.scheme) {
|
|
13
|
+
throw new Error("Missing required Spotify config value: scheme");
|
|
14
|
+
}
|
|
15
|
+
if (!spotifyConfig.clientID) {
|
|
16
|
+
throw new Error("Missing required Spotify config value: clientID");
|
|
17
|
+
}
|
|
18
|
+
// Android specific
|
|
19
|
+
config = (0, withSpotifyAndroidAppBuildGradle_1.withSpotifyAndroidAppBuildGradle)(config, spotifyConfig);
|
|
20
|
+
// iOS specific
|
|
21
|
+
config = (0, withSpotifyConfigValues_1.withSpotifyConfigValues)(config, spotifyConfig);
|
|
22
|
+
config = (0, withSpotifyQueryScheme_1.withSpotifyQueryScheme)(config, spotifyConfig);
|
|
23
|
+
config = (0, withSpotifyURLScheme_1.withSpotifyURLScheme)(config, spotifyConfig);
|
|
24
|
+
return config;
|
|
25
|
+
};
|
|
26
|
+
exports.withSpotifySdkConfig = withSpotifySdkConfig;
|
|
27
|
+
exports.default = exports.withSpotifySdkConfig;
|
package/plugin/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./build").default;
|