@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,14 @@
|
|
|
1
|
+
type StoreListener = () => void;
|
|
2
|
+
export interface SyncExternalStore<T> {
|
|
3
|
+
subscribe: (listener: StoreListener) => () => void;
|
|
4
|
+
getSnapshot: () => T;
|
|
5
|
+
getState: () => T;
|
|
6
|
+
update: (next: T | ((prev: T) => T)) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Module-level store backing `useSyncExternalStore` hooks. Initialises lazily on
|
|
10
|
+
* first subscription and notifies subscribers when `update` changes the snapshot.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSyncExternalStore<T>(initialState: T, init: (store: SyncExternalStore<T>) => void): SyncExternalStore<T>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=sync-external-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-external-store.d.ts","sourceRoot":"","sources":["../../src/internal/sync-external-store.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,MAAM,IAAI,CAAC;AAEhC,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,SAAS,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,YAAY,EAAE,CAAC,EACf,IAAI,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,iBAAiB,CAAC,CAAC,CAAC,CA+BtB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level store backing `useSyncExternalStore` hooks. Initialises lazily on
|
|
3
|
+
* first subscription and notifies subscribers when `update` changes the snapshot.
|
|
4
|
+
*/
|
|
5
|
+
export function createSyncExternalStore(initialState, init) {
|
|
6
|
+
let state = initialState;
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
let initialised = false;
|
|
9
|
+
const store = {
|
|
10
|
+
getState: () => state,
|
|
11
|
+
getSnapshot: () => state,
|
|
12
|
+
update(next) {
|
|
13
|
+
const resolved = typeof next === "function" ? next(state) : next;
|
|
14
|
+
if (Object.is(resolved, state))
|
|
15
|
+
return;
|
|
16
|
+
state = resolved;
|
|
17
|
+
listeners.forEach((listener) => listener());
|
|
18
|
+
},
|
|
19
|
+
subscribe(listener) {
|
|
20
|
+
if (!initialised) {
|
|
21
|
+
initialised = true;
|
|
22
|
+
try {
|
|
23
|
+
init(store);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
initialised = false;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
listeners.add(listener);
|
|
31
|
+
return () => listeners.delete(listener);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return store;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=sync-external-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-external-store.js","sourceRoot":"","sources":["../../src/internal/sync-external-store.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAe,EACf,IAA2C;IAE3C,IAAI,KAAK,GAAG,YAAY,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;IAC3C,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,KAAK,GAAyB;QAClC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,MAAM,CAAC,IAAI;YACT,MAAM,QAAQ,GACZ,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAE,IAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACtE,IAAI,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;gBAAE,OAAO;YACvC,KAAK,GAAG,QAAQ,CAAC;YACjB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,SAAS,CAAC,QAAQ;YAChB,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,WAAW,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC;oBACH,IAAI,CAAC,KAAK,CAAC,CAAC;gBACd,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,WAAW,GAAG,KAAK,CAAC;oBACpB,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["type StoreListener = () => void;\n\nexport interface SyncExternalStore<T> {\n subscribe: (listener: StoreListener) => () => void;\n getSnapshot: () => T;\n getState: () => T;\n update: (next: T | ((prev: T) => T)) => void;\n}\n\n/**\n * Module-level store backing `useSyncExternalStore` hooks. Initialises lazily on\n * first subscription and notifies subscribers when `update` changes the snapshot.\n */\nexport function createSyncExternalStore<T>(\n initialState: T,\n init: (store: SyncExternalStore<T>) => void,\n): SyncExternalStore<T> {\n let state = initialState;\n const listeners = new Set<StoreListener>();\n let initialised = false;\n\n const store: SyncExternalStore<T> = {\n getState: () => state,\n getSnapshot: () => state,\n update(next) {\n const resolved =\n typeof next === \"function\" ? (next as (prev: T) => T)(state) : next;\n if (Object.is(resolved, state)) return;\n state = resolved;\n listeners.forEach((listener) => listener());\n },\n subscribe(listener) {\n if (!initialised) {\n initialised = true;\n try {\n init(store);\n } catch (error) {\n initialised = false;\n throw error;\n }\n }\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n\n return store;\n}\n"]}
|
package/build/player/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/player/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/player/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC,0CAA0C;AAC1C,MAAM,MAAM,UAAU,GAClB,CAAC,CAAC,UAAU,GACZ,CAAC,CAAC,2BAA2B,GAC7B,CAAC,CAAC,C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,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAwBD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM;IACjB;;;;OAIG;yBACO,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,uBAAuB;0BACd,OAAO,CAAC,IAAI,CAAC;IAItB,+BAA+B;2BACrB,OAAO,CAAC,IAAI,CAAC;IAIvB,uDAAuD;6BAC3C,OAAO,CAAC,IAAI,CAAC;IAIzB,mCAAmC;iCACnB,OAAO,CAAC,IAAI,CAAC;IAM7B;;;OAGG;kCACgB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;IAMzC,mCAAmC;mCACf,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;IAM3C;;;OAGG;mCACiB,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC;IAM9C;;;OAGG;8CAC4B,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;IAMnE,iEAAiE;0BACtD,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,kEAAkE;mCAChD,OAAO,CAAC,WAAW,CAAC;IAMtC,qEAAqE;sCAChD,OAAO,CAAC,cAAc,CAAC;IAM5C;;;;;;;;;;;;;;;OAeG;kCAEM,mBAAmB,YAChB,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,KACrC,iBAAiB;CAMZ,CAAC"}
|
package/build/player/index.js
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
import ExpoSpotifySDKModule from "../ExpoSpotifySDKModule";
|
|
2
|
+
import { createNativeErrorRethrow } from "../internal/native-errors";
|
|
3
|
+
import { SpotifyURI } from "../uri";
|
|
2
4
|
import { PlayerError } from "./error";
|
|
3
5
|
export { PlayerError } from "./error";
|
|
4
6
|
// ---------------------------------------------------------------------------
|
|
5
7
|
// Internal helpers
|
|
6
8
|
// ---------------------------------------------------------------------------
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
function rethrowAsPlayerError(err) {
|
|
22
|
-
if (err instanceof PlayerError)
|
|
23
|
-
throw err;
|
|
24
|
-
if (err instanceof Error) {
|
|
25
|
-
const reason = unwrapReason(err.message);
|
|
26
|
-
const maybeCode = err.code;
|
|
27
|
-
if (maybeCode && VALID_PLAYER_CODES.has(maybeCode)) {
|
|
28
|
-
throw new PlayerError(maybeCode, reason);
|
|
29
|
-
}
|
|
30
|
-
throw new PlayerError("UNKNOWN", reason);
|
|
31
|
-
}
|
|
32
|
-
throw new PlayerError("UNKNOWN", String(err));
|
|
33
|
-
}
|
|
9
|
+
const rethrowAsPlayerError = createNativeErrorRethrow({
|
|
10
|
+
ErrorClass: PlayerError,
|
|
11
|
+
unknownCode: "UNKNOWN",
|
|
12
|
+
validCodes: new Set([
|
|
13
|
+
"NOT_CONNECTED",
|
|
14
|
+
"CONNECTION_LOST",
|
|
15
|
+
"PREMIUM_REQUIRED",
|
|
16
|
+
"INVALID_URI",
|
|
17
|
+
"INVALID_PARAMETER",
|
|
18
|
+
"OPERATION_NOT_ALLOWED",
|
|
19
|
+
"UNKNOWN",
|
|
20
|
+
]),
|
|
21
|
+
});
|
|
34
22
|
// ---------------------------------------------------------------------------
|
|
35
23
|
// Player namespace
|
|
36
24
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/player/index.ts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,CAAC;IACJ,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,GAAe;QACnB,OAAO,oBAAoB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;IAED,kEAAkE;IAClE,cAAc;QACZ,OAAO,oBAAoB,CAAC,oBAAoB,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACjF,CAAC;IAED,qEAAqE;IACrE,iBAAiB;QACf,OAAO,oBAAoB,CAAC,uBAAuB,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACpF,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACT,KAA0B,EAC1B,QAAsC;QAEtC,OAAO,oBAAoB,CAAC,WAAW,CACrC,qBAAqB,EACrB,QAAoC,CAChB,CAAC;IACzB,CAAC;CACO,CAAC","sourcesContent":["import { EventSubscription } from \"expo-modules-core\";\n\nimport ExpoSpotifySDKModule from \"../ExpoSpotifySDKModule\";\nimport { SpotifyURI } from \"../uri\";\nimport { PlayerError, PlayerErrorCode } from \"./error\";\n\nexport type { PlayerErrorCode } from \"./error\";\nexport { PlayerError } from \"./error\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Repeat mode for the Spotify player. */\nexport type RepeatMode =\n | 0 /** off */\n | 1 /** repeat current track */\n | 2; /** repeat current context */\n\n/** Valid podcast playback speed multipliers. */\nexport type PodcastPlaybackSpeed = 0.5 | 0.8 | 1.0 | 1.2 | 1.5 | 2.0 | 3.0;\n\n/** A Spotify artist. */\nexport interface Artist {\n name: string;\n uri: string;\n}\n\n/** A Spotify album. */\nexport interface Album {\n name: string;\n uri: string;\n}\n\n/** A track currently loaded in the Spotify player. */\nexport interface Track {\n uri: string;\n name: string;\n /** Identifier used by `Images.load(...)`. */\n imageIdentifier?: string;\n /** Duration in milliseconds. */\n duration: number;\n artist: Artist;\n album: Album;\n isSaved: boolean;\n isEpisode: boolean;\n isPodcast: boolean;\n isAdvertisement: boolean;\n}\n\n/** Current playback options (shuffle / repeat). */\nexport interface PlaybackOptions {\n isShuffling: boolean;\n /** 0 = off, 1 = repeat track, 2 = repeat context. */\n repeatMode: RepeatMode;\n}\n\n/** Actions currently permitted by Spotify (gate UI buttons on these). */\nexport interface PlaybackRestrictions {\n canSkipNext: boolean;\n canSkipPrevious: boolean;\n canRepeatTrack: boolean;\n canRepeatContext: boolean;\n canToggleShuffle: boolean;\n canSeek: boolean;\n}\n\n/** Full snapshot of the Spotify player at a point in time. */\nexport interface PlayerState {\n track: Track;\n /** Current playback position in milliseconds. */\n playbackPosition: number;\n playbackSpeed: number;\n isPaused: boolean;\n playbackOptions: PlaybackOptions;\n playbackRestrictions: PlaybackRestrictions;\n contextTitle: string;\n contextUri: string;\n}\n\n/** Crossfade configuration from the Spotify app. */\nexport interface CrossfadeState {\n isEnabled: boolean;\n /** Crossfade duration in milliseconds (only meaningful when enabled). */\n duration: number;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nconst VALID_PLAYER_CODES = new Set<PlayerErrorCode>([\n \"NOT_CONNECTED\",\n \"CONNECTION_LOST\",\n \"PREMIUM_REQUIRED\",\n \"INVALID_URI\",\n \"INVALID_PARAMETER\",\n \"OPERATION_NOT_ALLOWED\",\n \"UNKNOWN\",\n]);\n\nconst CAUSE_SEPARATOR = \"→ Caused by: \";\n\nfunction unwrapReason(message: string): string {\n const idx = message.lastIndexOf(CAUSE_SEPARATOR);\n return idx === -1 ? message : message.slice(idx + CAUSE_SEPARATOR.length);\n}\n\nfunction rethrowAsPlayerError(err: unknown): never {\n if (err instanceof PlayerError) throw err;\n if (err instanceof Error) {\n const reason = unwrapReason(err.message);\n const maybeCode = (err as Error & { code?: string }).code;\n if (maybeCode && VALID_PLAYER_CODES.has(maybeCode as PlayerErrorCode)) {\n throw new PlayerError(maybeCode as PlayerErrorCode, reason);\n }\n throw new PlayerError(\"UNKNOWN\", reason);\n }\n throw new PlayerError(\"UNKNOWN\", String(err));\n}\n\n// ---------------------------------------------------------------------------\n// Player namespace\n// ---------------------------------------------------------------------------\n\n/**\n * Spotify Player namespace. Transport controls, queue management, and\n * player-state subscriptions. Requires `AppRemote.connect()` to be resolved\n * before any call.\n *\n * @example\n * ```ts\n * import { Player, SpotifyURI } from \"@wwdrew/expo-spotify-sdk\";\n *\n * await Player.play(SpotifyURI.from(\"spotify:track:4uLU6hMCjMI75M1A2tKUQC\"));\n * const state = await Player.getPlayerState();\n *\n * const sub = Player.addListener(\"playerStateChange\", (state) => {\n * console.log(\"now playing:\", state.track.name, \"paused:\", state.isPaused);\n * });\n * ```\n */\nexport const Player = {\n /**\n * Asks Spotify to play the entity identified by the given URI.\n * Requires Spotify Premium for on-demand track playback; throws\n * `PlayerError(\"PREMIUM_REQUIRED\", ...)` for Free users.\n */\n play(uri: SpotifyURI): Promise<void> {\n return ExpoSpotifySDKModule.playerPlay(uri).catch(rethrowAsPlayerError);\n },\n\n /** Pauses playback. */\n pause(): Promise<void> {\n return ExpoSpotifySDKModule.playerPause().catch(rethrowAsPlayerError);\n },\n\n /** Resumes paused playback. */\n resume(): Promise<void> {\n return ExpoSpotifySDKModule.playerResume().catch(rethrowAsPlayerError);\n },\n\n /** Skips to the next track in the queue or context. */\n skipNext(): Promise<void> {\n return ExpoSpotifySDKModule.playerSkipNext().catch(rethrowAsPlayerError);\n },\n\n /** Skips to the previous track. */\n skipPrevious(): Promise<void> {\n return ExpoSpotifySDKModule.playerSkipPrevious().catch(rethrowAsPlayerError);\n },\n\n /**\n * Seeks to the given position in milliseconds.\n * Only valid when `PlaybackRestrictions.canSeek` is `true`.\n */\n seekTo(positionMs: number): Promise<void> {\n return ExpoSpotifySDKModule.playerSeekTo(positionMs).catch(rethrowAsPlayerError);\n },\n\n /** Enables or disables shuffle. */\n setShuffle(enabled: boolean): Promise<void> {\n return ExpoSpotifySDKModule.playerSetShuffle(enabled).catch(rethrowAsPlayerError);\n },\n\n /**\n * Sets the repeat mode.\n * @param mode 0 = off, 1 = repeat track, 2 = repeat context.\n */\n setRepeatMode(mode: RepeatMode): Promise<void> {\n return ExpoSpotifySDKModule.playerSetRepeatMode(mode).catch(rethrowAsPlayerError);\n },\n\n /**\n * Sets the podcast playback speed. Only takes effect when a podcast episode\n * is playing; valid speeds are `0.5 | 0.8 | 1.0 | 1.2 | 1.5 | 2.0 | 3.0`.\n */\n setPodcastPlaybackSpeed(speed: PodcastPlaybackSpeed): Promise<void> {\n return ExpoSpotifySDKModule.playerSetPodcastPlaybackSpeed(speed).catch(\n rethrowAsPlayerError,\n );\n },\n\n /** Adds a track URI to the end of the current playback queue. */\n queue(uri: SpotifyURI): Promise<void> {\n return ExpoSpotifySDKModule.playerQueue(uri).catch(rethrowAsPlayerError);\n },\n\n /** Returns the current {@link PlayerState} as a one-shot pull. */\n getPlayerState(): Promise<PlayerState> {\n return ExpoSpotifySDKModule.playerGetPlayerState().catch(rethrowAsPlayerError);\n },\n\n /** Returns the current {@link CrossfadeState} as a one-shot pull. */\n getCrossfadeState(): Promise<CrossfadeState> {\n return ExpoSpotifySDKModule.playerGetCrossfadeState().catch(rethrowAsPlayerError);\n },\n\n /**\n * Subscribes to player state changes. The callback fires whenever the\n * Spotify app reports a state update (track change, pause/resume, seek,\n * shuffle/repeat change, etc.).\n *\n * Returns a `Subscription` — call `.remove()` to unsubscribe.\n *\n * @example\n * ```ts\n * const sub = Player.addListener(\"playerStateChange\", (state) => {\n * console.log(\"track:\", state.track.name, \"paused:\", state.isPaused);\n * });\n * // ...later:\n * sub.remove();\n * ```\n */\n addListener(\n event: \"playerStateChange\",\n listener: (state: PlayerState) => void,\n ): EventSubscription {\n return ExpoSpotifySDKModule.addListener(\n \"onPlayerStateChange\",\n listener as (event: unknown) => void,\n ) as EventSubscription;\n },\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/player/index.ts"],"names":[],"mappings":"AAEA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IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAkB;QACvB,OAAO,oBAAoB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CACxD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,mCAAmC;IACnC,UAAU,CAAC,OAAgB;QACzB,OAAO,oBAAoB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,CACzD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,IAAgB;QAC5B,OAAO,oBAAoB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,KAAK,CACzD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,uBAAuB,CAAC,KAA2B;QACjD,OAAO,oBAAoB,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,KAAK,CACpE,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,GAAe;QACnB,OAAO,oBAAoB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;IAED,kEAAkE;IAClE,cAAc;QACZ,OAAO,oBAAoB,CAAC,oBAAoB,EAAE,CAAC,KAAK,CACtD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,qEAAqE;IACrE,iBAAiB;QACf,OAAO,oBAAoB,CAAC,uBAAuB,EAAE,CAAC,KAAK,CACzD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACT,KAA0B,EAC1B,QAAsC;QAEtC,OAAO,oBAAoB,CAAC,WAAW,CACrC,qBAAqB,EACrB,QAAoC,CAChB,CAAC;IACzB,CAAC;CACO,CAAC","sourcesContent":["import type { EventSubscription } from \"expo-modules-core\";\n\nimport ExpoSpotifySDKModule from \"../ExpoSpotifySDKModule\";\nimport { createNativeErrorRethrow } from \"../internal/native-errors\";\nimport { SpotifyURI } from \"../uri\";\nimport { PlayerError, type PlayerErrorCode } from \"./error\";\n\nexport type { PlayerErrorCode } from \"./error\";\nexport { PlayerError } from \"./error\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Repeat mode for the Spotify player. */\nexport type RepeatMode =\n | 0 /** off */\n | 1 /** repeat current track */\n | 2; /** repeat current context */\n\n/** Valid podcast playback speed multipliers. */\nexport type PodcastPlaybackSpeed = 0.5 | 0.8 | 1.0 | 1.2 | 1.5 | 2.0 | 3.0;\n\n/** A Spotify artist. */\nexport interface Artist {\n name: string;\n uri: string;\n}\n\n/** A Spotify album. */\nexport interface Album {\n name: string;\n uri: string;\n}\n\n/** A track currently loaded in the Spotify player. */\nexport interface Track {\n uri: string;\n name: string;\n /** Identifier used by `Images.load(...)`. */\n imageIdentifier?: string;\n /** Duration in milliseconds. */\n duration: number;\n artist: Artist;\n album: Album;\n isSaved: boolean;\n isEpisode: boolean;\n isPodcast: boolean;\n isAdvertisement: boolean;\n}\n\n/** Current playback options (shuffle / repeat). */\nexport interface PlaybackOptions {\n isShuffling: boolean;\n /** 0 = off, 1 = repeat track, 2 = repeat context. */\n repeatMode: RepeatMode;\n}\n\n/** Actions currently permitted by Spotify (gate UI buttons on these). */\nexport interface PlaybackRestrictions {\n canSkipNext: boolean;\n canSkipPrevious: boolean;\n canRepeatTrack: boolean;\n canRepeatContext: boolean;\n canToggleShuffle: boolean;\n canSeek: boolean;\n}\n\n/** Full snapshot of the Spotify player at a point in time. */\nexport interface PlayerState {\n track: Track;\n /** Current playback position in milliseconds. */\n playbackPosition: number;\n playbackSpeed: number;\n isPaused: boolean;\n playbackOptions: PlaybackOptions;\n playbackRestrictions: PlaybackRestrictions;\n contextTitle: string;\n contextUri: string;\n}\n\n/** Crossfade configuration from the Spotify app. */\nexport interface CrossfadeState {\n isEnabled: boolean;\n /** Crossfade duration in milliseconds (only meaningful when enabled). */\n duration: number;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nconst rethrowAsPlayerError = createNativeErrorRethrow({\n ErrorClass: PlayerError,\n unknownCode: \"UNKNOWN\",\n validCodes: new Set<PlayerErrorCode>([\n \"NOT_CONNECTED\",\n \"CONNECTION_LOST\",\n \"PREMIUM_REQUIRED\",\n \"INVALID_URI\",\n \"INVALID_PARAMETER\",\n \"OPERATION_NOT_ALLOWED\",\n \"UNKNOWN\",\n ]),\n});\n\n// ---------------------------------------------------------------------------\n// Player namespace\n// ---------------------------------------------------------------------------\n\n/**\n * Spotify Player namespace. Transport controls, queue management, and\n * player-state subscriptions. Requires `AppRemote.connect()` to be resolved\n * before any call.\n *\n * @example\n * ```ts\n * import { Player, SpotifyURI } from \"@wwdrew/expo-spotify-sdk\";\n *\n * await Player.play(SpotifyURI.from(\"spotify:track:4uLU6hMCjMI75M1A2tKUQC\"));\n * const state = await Player.getPlayerState();\n *\n * const sub = Player.addListener(\"playerStateChange\", (state) => {\n * console.log(\"now playing:\", state.track.name, \"paused:\", state.isPaused);\n * });\n * ```\n */\nexport const Player = {\n /**\n * Asks Spotify to play the entity identified by the given URI.\n * Requires Spotify Premium for on-demand track playback; throws\n * `PlayerError(\"PREMIUM_REQUIRED\", ...)` for Free users.\n */\n play(uri: SpotifyURI): Promise<void> {\n return ExpoSpotifySDKModule.playerPlay(uri).catch(rethrowAsPlayerError);\n },\n\n /** Pauses playback. */\n pause(): Promise<void> {\n return ExpoSpotifySDKModule.playerPause().catch(rethrowAsPlayerError);\n },\n\n /** Resumes paused playback. */\n resume(): Promise<void> {\n return ExpoSpotifySDKModule.playerResume().catch(rethrowAsPlayerError);\n },\n\n /** Skips to the next track in the queue or context. */\n skipNext(): Promise<void> {\n return ExpoSpotifySDKModule.playerSkipNext().catch(rethrowAsPlayerError);\n },\n\n /** Skips to the previous track. */\n skipPrevious(): Promise<void> {\n return ExpoSpotifySDKModule.playerSkipPrevious().catch(\n rethrowAsPlayerError,\n );\n },\n\n /**\n * Seeks to the given position in milliseconds.\n * Only valid when `PlaybackRestrictions.canSeek` is `true`.\n */\n seekTo(positionMs: number): Promise<void> {\n return ExpoSpotifySDKModule.playerSeekTo(positionMs).catch(\n rethrowAsPlayerError,\n );\n },\n\n /** Enables or disables shuffle. */\n setShuffle(enabled: boolean): Promise<void> {\n return ExpoSpotifySDKModule.playerSetShuffle(enabled).catch(\n rethrowAsPlayerError,\n );\n },\n\n /**\n * Sets the repeat mode.\n * @param mode 0 = off, 1 = repeat track, 2 = repeat context.\n */\n setRepeatMode(mode: RepeatMode): Promise<void> {\n return ExpoSpotifySDKModule.playerSetRepeatMode(mode).catch(\n rethrowAsPlayerError,\n );\n },\n\n /**\n * Sets the podcast playback speed. Only takes effect when a podcast episode\n * is playing; valid speeds are `0.5 | 0.8 | 1.0 | 1.2 | 1.5 | 2.0 | 3.0`.\n */\n setPodcastPlaybackSpeed(speed: PodcastPlaybackSpeed): Promise<void> {\n return ExpoSpotifySDKModule.playerSetPodcastPlaybackSpeed(speed).catch(\n rethrowAsPlayerError,\n );\n },\n\n /** Adds a track URI to the end of the current playback queue. */\n queue(uri: SpotifyURI): Promise<void> {\n return ExpoSpotifySDKModule.playerQueue(uri).catch(rethrowAsPlayerError);\n },\n\n /** Returns the current {@link PlayerState} as a one-shot pull. */\n getPlayerState(): Promise<PlayerState> {\n return ExpoSpotifySDKModule.playerGetPlayerState().catch(\n rethrowAsPlayerError,\n );\n },\n\n /** Returns the current {@link CrossfadeState} as a one-shot pull. */\n getCrossfadeState(): Promise<CrossfadeState> {\n return ExpoSpotifySDKModule.playerGetCrossfadeState().catch(\n rethrowAsPlayerError,\n );\n },\n\n /**\n * Subscribes to player state changes. The callback fires whenever the\n * Spotify app reports a state update (track change, pause/resume, seek,\n * shuffle/repeat change, etc.).\n *\n * Returns a `Subscription` — call `.remove()` to unsubscribe.\n *\n * @example\n * ```ts\n * const sub = Player.addListener(\"playerStateChange\", (state) => {\n * console.log(\"track:\", state.track.name, \"paused:\", state.isPaused);\n * });\n * // ...later:\n * sub.remove();\n * ```\n */\n addListener(\n event: \"playerStateChange\",\n listener: (state: PlayerState) => void,\n ): EventSubscription {\n return ExpoSpotifySDKModule.addListener(\n \"onPlayerStateChange\",\n listener as (event: unknown) => void,\n ) as EventSubscription;\n },\n} as const;\n"]}
|
package/build/uri/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/uri/index.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,GACV,qEAAqE,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;;;;OAIG;IACH,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,yBAAyB,GAAG,wCAAwC;gBAClE,kEAAkE,CACrE,CAAC;QACJ,CAAC;QACD,OAAO,GAAiB,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,GAAiB,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAe;QACnB,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,GAAG,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAwB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/uri/index.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,GACV,qEAAqE,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;;;;OAIG;IACH,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,yBAAyB,GAAG,wCAAwC;gBAClE,kEAAkE,CACrE,CAAC;QACJ,CAAC;QACD,OAAO,GAAiB,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,GAAiB,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAe;QACnB,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,GAAG,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAwB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAyB,EAAE,EAAU;QACzC,OAAO,WAAW,IAAI,IAAI,EAAE,EAAgB,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACO,CAAC","sourcesContent":["/**\n * The six Spotify resource types accepted by App Remote APIs.\n */\nexport type SpotifyResourceType =\n | \"track\"\n | \"album\"\n | \"playlist\"\n | \"artist\"\n | \"show\"\n | \"episode\";\n\n/**\n * Branded string type for Spotify URIs (`spotify:<type>:<id>`).\n *\n * Construct via `SpotifyURI.from(str)` (validates) or\n * `SpotifyURI.unsafe(str)` (skips validation — use only when the source is\n * trusted, e.g. a URI that came back from the Spotify SDK itself).\n */\nexport type SpotifyURI = string & { readonly __brand: \"SpotifyURI\" };\n\nconst URI_RE =\n /^spotify:(track|album|playlist|artist|show|episode):([A-Za-z0-9]+)$/;\n\n/**\n * Helpers for constructing, validating and decomposing {@link SpotifyURI}\n * values.\n *\n * @example\n * ```ts\n * const uri = SpotifyURI.from(\"spotify:track:4uLU6hMCjMI75M1A2tKUQC\");\n * const { type, id } = SpotifyURI.parse(uri);\n * const rebuilt = SpotifyURI.build(\"track\", id);\n * ```\n */\nexport const SpotifyURI = {\n /**\n * Cast `uri` to {@link SpotifyURI} after validation.\n * Throws a plain `Error` if the URI does not match the `spotify:<type>:<id>`\n * format — use at app-code call sites where you want early feedback.\n */\n from(uri: string): SpotifyURI {\n if (!SpotifyURI.isValid(uri)) {\n throw new Error(\n `Invalid Spotify URI: \"${uri}\". Expected spotify:<type>:<id> where ` +\n `<type> is one of: track, album, playlist, artist, show, episode.`,\n );\n }\n return uri as SpotifyURI;\n },\n\n /**\n * Cast `uri` to {@link SpotifyURI} without validation.\n * Use only for URIs that originate from the Spotify SDK itself (i.e. already\n * known-valid values coming back over the bridge).\n */\n unsafe(uri: string): SpotifyURI {\n return uri as SpotifyURI;\n },\n\n /**\n * Decompose a {@link SpotifyURI} into its `{ type, id }` parts.\n */\n parse(uri: SpotifyURI): { type: SpotifyResourceType; id: string } {\n const m = uri.match(URI_RE);\n if (!m) {\n throw new Error(`Cannot parse Spotify URI: \"${uri}\"`);\n }\n return { type: m[1] as SpotifyResourceType, id: m[2]! };\n },\n\n /**\n * Build a {@link SpotifyURI} from a resource type and ID.\n */\n build(type: SpotifyResourceType, id: string): SpotifyURI {\n return `spotify:${type}:${id}` as SpotifyURI;\n },\n\n /**\n * Type-guard: returns `true` if `uri` is a valid Spotify URI string.\n */\n isValid(uri: string): uri is SpotifyURI {\n return URI_RE.test(uri);\n },\n} as const;\n"]}
|
package/build/user/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { EventSubscription } from "expo-modules-core";
|
|
2
|
+
import type { SpotifyURI as SpotifyURIType } from "../uri";
|
|
1
3
|
export type { UserErrorCode } from "./error";
|
|
2
4
|
export { UserError } from "./error";
|
|
3
|
-
import { EventSubscription } from "expo-modules-core";
|
|
4
|
-
import type { SpotifyURI as SpotifyURIType } from "../uri";
|
|
5
5
|
/** Capabilities of the current user in Spotify's App Remote context. */
|
|
6
6
|
export interface Capabilities {
|
|
7
7
|
/** `true` for Premium users with on-demand playback capability. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG3D,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AA2BD;;;GAGG;AACH,eAAO,MAAM,IAAI;IACf,+CAA+C;oCAC5B,OAAO,CAAC,YAAY,CAAC;IAIxC,kEAAkE;oCAC7C,cAAc,KAAG,OAAO,CAAC,YAAY,CAAC;IAM3D,uDAAuD;iCAC/B,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC;IAOtD,4DAA4D;sCAC/B,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC;IAO3D;;;OAGG;kCAEM,oBAAoB,YACjB,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KACtC,iBAAiB;IAOpB;;;;;;;OAOG;4CAEI,cAAc,YACT,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KACtC,iBAAiB;CAiBZ,CAAC"}
|
package/build/user/index.js
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Types
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
2
4
|
import ExpoSpotifySDKModule from "../ExpoSpotifySDKModule";
|
|
5
|
+
import { createNativeErrorRethrow } from "../internal/native-errors";
|
|
3
6
|
import { UserError } from "./error";
|
|
7
|
+
export { UserError } from "./error";
|
|
4
8
|
// ---------------------------------------------------------------------------
|
|
5
9
|
// Internal helpers
|
|
6
10
|
// ---------------------------------------------------------------------------
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
function rethrowAsUserError(err) {
|
|
20
|
-
if (err instanceof UserError)
|
|
21
|
-
throw err;
|
|
22
|
-
if (err instanceof Error) {
|
|
23
|
-
const reason = unwrapReason(err.message);
|
|
24
|
-
const maybeCode = err.code;
|
|
25
|
-
if (maybeCode && VALID_USER_CODES.has(maybeCode)) {
|
|
26
|
-
throw new UserError(maybeCode, reason);
|
|
27
|
-
}
|
|
28
|
-
throw new UserError("UNKNOWN", reason);
|
|
29
|
-
}
|
|
30
|
-
throw new UserError("UNKNOWN", String(err));
|
|
31
|
-
}
|
|
11
|
+
const rethrowAsUserError = createNativeErrorRethrow({
|
|
12
|
+
ErrorClass: UserError,
|
|
13
|
+
unknownCode: "UNKNOWN",
|
|
14
|
+
validCodes: new Set([
|
|
15
|
+
"NOT_CONNECTED",
|
|
16
|
+
"CONNECTION_LOST",
|
|
17
|
+
"INVALID_URI",
|
|
18
|
+
"OPERATION_NOT_ALLOWED",
|
|
19
|
+
"UNKNOWN",
|
|
20
|
+
]),
|
|
21
|
+
});
|
|
32
22
|
const libraryListeners = new Map();
|
|
33
23
|
function notifyLibraryState(state) {
|
|
34
24
|
const set = libraryListeners.get(state.uri);
|
package/build/user/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAI9E,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,SAAS,EAAsB,MAAM,SAAS,CAAC;AAGxD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAepC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;IAClD,UAAU,EAAE,SAAS;IACrB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE,IAAI,GAAG,CAAgB;QACjC,eAAe;QACf,iBAAiB;QACjB,aAAa;QACb,uBAAuB;QACvB,SAAS;KACV,CAAC;CACH,CAAC,CAAC;AAGH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAgC,CAAC;AAEjE,SAAS,kBAAkB,CAAC,KAAmB;IAC7C,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,+CAA+C;IAC/C,eAAe;QACb,OAAO,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9E,CAAC;IAED,kEAAk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O;gBACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACzB,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;oBAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvD,CAAC;SACmB,CAAC;IACzB,CAAC;CACO,CAAC","sourcesContent":["// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nimport type { EventSubscription } from \"expo-modules-core\";\n\nimport ExpoSpotifySDKModule from \"../ExpoSpotifySDKModule\";\nimport { createNativeErrorRethrow } from \"../internal/native-errors\";\nimport type { SpotifyURI as SpotifyURIType } from \"../uri\";\nimport { UserError, type UserErrorCode } from \"./error\";\n\nexport type { UserErrorCode } from \"./error\";\nexport { UserError } from \"./error\";\n\n/** Capabilities of the current user in Spotify's App Remote context. */\nexport interface Capabilities {\n /** `true` for Premium users with on-demand playback capability. */\n canPlayOnDemand: boolean;\n}\n\n/** Library save state for a specific album/track URI. */\nexport interface LibraryState {\n uri: string;\n isAdded: boolean;\n canAdd: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nconst rethrowAsUserError = createNativeErrorRethrow({\n ErrorClass: UserError,\n unknownCode: \"UNKNOWN\",\n validCodes: new Set<UserErrorCode>([\n \"NOT_CONNECTED\",\n \"CONNECTION_LOST\",\n \"INVALID_URI\",\n \"OPERATION_NOT_ALLOWED\",\n \"UNKNOWN\",\n ]),\n});\n\ntype LibraryListener = (state: LibraryState) => void;\nconst libraryListeners = new Map<string, Set<LibraryListener>>();\n\nfunction notifyLibraryState(state: LibraryState) {\n const set = libraryListeners.get(state.uri);\n if (!set) return;\n set.forEach((listener) => listener(state));\n}\n\n/**\n * Spotify User namespace. Capabilities and library-state operations.\n * Requires `AppRemote.connect()` to be resolved before any call.\n */\nexport const User = {\n /** Returns the current user's capabilities. */\n getCapabilities(): Promise<Capabilities> {\n return ExpoSpotifySDKModule.userGetCapabilities().catch(rethrowAsUserError);\n },\n\n /** Returns the current library state for a track or album URI. */\n getLibraryState(uri: SpotifyURIType): Promise<LibraryState> {\n return ExpoSpotifySDKModule.userGetLibraryState(uri).catch(\n rethrowAsUserError,\n );\n },\n\n /** Adds a track or album URI to the user's library. */\n async addToLibrary(uri: SpotifyURIType): Promise<void> {\n const state = (await ExpoSpotifySDKModule.userAddToLibrary(uri).catch(\n rethrowAsUserError,\n )) as LibraryState;\n notifyLibraryState(state);\n },\n\n /** Removes a track or album URI from the user's library. */\n async removeFromLibrary(uri: SpotifyURIType): Promise<void> {\n const state = (await ExpoSpotifySDKModule.userRemoveFromLibrary(uri).catch(\n rethrowAsUserError,\n )) as LibraryState;\n notifyLibraryState(state);\n },\n\n /**\n * Subscribes to user-scoped events.\n * Supported event: `\"capabilitiesChange\"`.\n */\n addListener(\n event: \"capabilitiesChange\",\n listener: (event: Capabilities) => void,\n ): EventSubscription {\n return ExpoSpotifySDKModule.addListener(\n \"onCapabilitiesChange\",\n listener as (event: unknown) => void,\n ) as EventSubscription;\n },\n\n /**\n * Subscribes to library state changes for a specific URI.\n *\n * There is no native push stream for per-URI library state updates on all\n * platforms, so this listener is updated whenever library mutations are\n * performed via this SDK and can be manually seeded by calling\n * `User.getLibraryState(uri)` before subscribing.\n */\n addLibraryStateListener(\n uri: SpotifyURIType,\n listener: (state: LibraryState) => void,\n ): EventSubscription {\n const key = String(uri);\n let set = libraryListeners.get(key);\n if (!set) {\n set = new Set();\n libraryListeners.set(key, set);\n }\n set.add(listener);\n return {\n remove() {\n const current = libraryListeners.get(key);\n if (!current) return;\n current.delete(listener);\n if (current.size === 0) libraryListeners.delete(key);\n },\n } as EventSubscription;\n },\n} as const;\n"]}
|
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '16.4'
|
|
14
14
|
s.swift_version = '5.9'
|
|
15
15
|
s.source = { git: 'https://github.com/wwdrew/expo-spotify-sdk' }
|
|
16
16
|
s.static_framework = true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import SpotifyiOS
|
|
3
3
|
|
|
4
|
-
private let SDK_VERSION = "1.0
|
|
4
|
+
private let SDK_VERSION = "2.1.0" // x-release-please-version
|
|
5
5
|
private let EVENT_SESSION_CHANGE = "onSessionChange"
|
|
6
6
|
private let EVENT_CONNECTION_STATE_CHANGE = "onConnectionStateChange"
|
|
7
7
|
private let EVENT_CONNECTION_ERROR = "onConnectionError"
|