diff --git a/MusicKit.d.ts b/MusicKit.d.ts
index e91dae5..8198e9e 100644
--- a/MusicKit.d.ts
+++ b/MusicKit.d.ts
@@ -1,47 +1,50 @@
-/* eslint-disable @typescript-eslint/triple-slash-reference */
-///
-///
-///
+import {
+ Artwork,
+ PlaybackBitrate
+} from './enums';
+import {
+ MusicKitInstance
+} from './MusicKitInstance';
-declare namespace MusicKit {
- export interface MusicKitConfiguration {
+export interface MusicKitConfiguration {
+ /**
+ * See https://js-cdn.music.apple.com/musickit/v3/docs/iframe.html?path=/story/get-started--page#configuring-musickit-on-the-web
+ */
+ 'developerToken': string;
+
+ /**
+ * Your application configuration
+ */
+ 'app': {
/**
- * See https://js-cdn.music.apple.com/musickit/v3/docs/iframe.html?path=/story/get-started--page#configuring-musickit-on-the-web
+ * The name of your application
*/
- 'developerToken': string;
+ 'name': string;
/**
- * Your application configuration
+ * Build or version number of application
*/
- 'app': {
- /**
- * The name of your application
- */
- 'name': string;
-
- /**
- * Build or version number of application
- */
- 'build'?: string;
-
- /**
- * A URL to your application logo. Should be square at 152x152px
- */
- 'icon'?: string;
- };
-
- 'bitrate'?: PlaybackBitrate;
+ 'build'?: string;
/**
- * Set the storefront, which is set for the API requests.
- * If unset, then the authenticated user's storefrontId will be used.
+ * A URL to your application logo. Should be square at 152x152px
*/
- 'storefrontId'?: string;
- }
+ 'icon'?: string;
+ };
- export function configure ( config: MusicKitConfiguration ): Promise;
+ 'bitrate'?: PlaybackBitrate;
- export function getInstance (): MusicKitInstance;
+ /**
+ * Set the storefront, which is set for the API requests.
+ * If unset, then the authenticated user's storefrontId will be used.
+ */
+ 'storefrontId'?: string;
+}
- export function formatArtworkURL ( artwork: Artwork, width: number, height: number ): string;
+export interface MusicKitObject {
+ 'configure': ( config: MusicKitConfiguration ) => Promise;
+
+ 'getInstance': () => MusicKitInstance;
+
+ 'formatArtworkURL': ( artwork: Artwork, width: number, height: number ) => string;
}
diff --git a/MusicKitAPI.d.ts b/MusicKitAPI.d.ts
index 3a20eb2..9866402 100644
--- a/MusicKitAPI.d.ts
+++ b/MusicKitAPI.d.ts
@@ -1,15 +1,13 @@
-declare namespace MusicKit {
- interface MusicKitAPI {
- 'music': (
- path: string,
- params: {
- [key: string]: string
- },
- opts: {
- 'fetchOptions': RequestInit
- }
- ) => Promise<{
- 'data': unknown
- }>
- }
+export interface MusicKitAPI {
+ 'music': (
+ path: string,
+ params: {
+ [key: string]: string
+ },
+ opts: {
+ 'fetchOptions': RequestInit
+ }
+ ) => Promise<{
+ 'data': unknown
+ }>
}
diff --git a/MusicKitInstance.d.ts b/MusicKitInstance.d.ts
index c8792fb..cf1c588 100644
--- a/MusicKitInstance.d.ts
+++ b/MusicKitInstance.d.ts
@@ -1,80 +1,88 @@
-declare namespace MusicKit {
- type MediaItem = object;
+import {
+ PlaybackBitrate,
+ PlaybackStates,
+ PlayerRepeatMode,
+ PlayerShuffleMode
+} from './enums';
+import type {
+ MusicKitAPI
+} from './MusicKitAPI.d.ts';
- interface Queue {
- 'currentItem': MediaItem;
- 'isEmpty': boolean;
- 'items': MediaItem[];
- 'length': number;
- 'nextPlayableItem': MediaItem;
- 'position': number;
- 'previousPlayableItem': MediaItem;
- }
+export type MediaItem = object;
- interface QueueOptions {
- 'album'?: string;
- 'albums'?: string[];
- 'musicVideo'?: string;
- 'musicVideos'?: string[];
- 'playlist'?: string;
- 'playlists'?: string[];
- 'song'?: string;
- 'songs'?: string[];
- }
+export interface Queue {
+ 'currentItem': MediaItem;
+ 'isEmpty': boolean;
+ 'items': MediaItem[];
+ 'length': number;
+ 'nextPlayableItem': MediaItem;
+ 'position': number;
+ 'previousPlayableItem': MediaItem;
+}
- interface SeekSeconds {
- 'BACK': number;
- 'FORWARD': number;
- }
+export interface QueueOptions {
+ 'album'?: string;
+ 'albums'?: string[];
+ 'musicVideo'?: string;
+ 'musicVideos'?: string[];
+ 'playlist'?: string;
+ 'playlists'?: string[];
+ 'song'?: string;
+ 'songs'?: string[];
+}
- interface MusicKitInstance {
- 'api': Readonly;
- 'bitrate': Readonly;
- 'currentPlaybackDuration': Readonly;
- 'currentPlaybackProgress': Readonly;
- 'currentPlaybackTime': Readonly;
- 'currentPlaybackTimeRemaining': Readonly;
- 'isAuthorized': Readonly;
- 'isPlaying': Readonly;
- 'nowPlayingItem': Readonly;
- 'nowPlayingItemIndex': Readonly;
- 'playbackRate': Readonly;
- 'playbackState': Readonly;
- 'previewOnly': Readonly;
- 'queue': Readonly;
- 'queueIsEmpty': Readonly;
- 'repeatMode': Readonly;
- 'seekSeconds': Readonly;
- 'shuffleMode': Readonly;
- 'storefrontCountryCode': Readonly;
- 'storefrontId': Readonly;
- 'videoContainerElement': Readonly;
- 'volume': Readonly;
- 'addEventListener': ( name: string, callback: CallableFunction, options: {
- 'once': boolean
- } ) => void;
- 'authorize': () => Promise;
- 'changeToMediaAtIndex': ( index: number ) => Promise;
- 'changeToMediaItem': ( descriptor: MediaItem | string ) => Promise;
- 'changeUserStorefront': ( storefrontId: string ) => Promise;
- 'clearQueue': () => Promise;
- 'exitFullscreen': () => void;
- 'mute': () => void;
- 'pause': () => void;
- 'play': () => void;
- 'playAt': ( position: number, options: QueueOptions ) => Promise;
- 'playLater': ( options: QueueOptions ) => Promise;
- 'playNext': ( options: QueueOptions, clear: boolean ) => Promise;
- 'removeEventListener': ( name: string, callback: CallableFunction ) => void;
- 'requestFullscreen': () => void;
- 'seekBackward': () => Promise;
- 'seekForward': () => Promise;
- 'seekToTime': ( time: number ) => Promise;
- 'setQueue': ( options: QueueOptions ) => Promise;
- 'skipToNextItem': () => Promise;
- 'skipToPreviousItem': () => Promise;
- 'stop': () => void;
- 'unauthorize': () => Promise;
- 'unmute': () => void;
- }
+export interface SeekSeconds {
+ 'BACK': number;
+ 'FORWARD': number;
+}
+
+export interface MusicKitInstance {
+ 'api': Readonly;
+ 'bitrate': Readonly;
+ 'currentPlaybackDuration': Readonly;
+ 'currentPlaybackProgress': Readonly;
+ 'currentPlaybackTime': Readonly;
+ 'currentPlaybackTimeRemaining': Readonly;
+ 'isAuthorized': Readonly;
+ 'isPlaying': Readonly;
+ 'nowPlayingItem': Readonly;
+ 'nowPlayingItemIndex': Readonly;
+ 'playbackRate': Readonly;
+ 'playbackState': Readonly;
+ 'previewOnly': Readonly;
+ 'queue': Readonly;
+ 'queueIsEmpty': Readonly;
+ 'repeatMode': Readonly;
+ 'seekSeconds': Readonly;
+ 'shuffleMode': Readonly;
+ 'storefrontCountryCode': Readonly;
+ 'storefrontId': Readonly;
+ 'videoContainerElement': Readonly;
+ 'volume': Readonly;
+ 'addEventListener': ( name: string, callback: CallableFunction, options: {
+ 'once': boolean
+ } ) => void;
+ 'authorize': () => Promise;
+ 'changeToMediaAtIndex': ( index: number ) => Promise;
+ 'changeToMediaItem': ( descriptor: MediaItem | string ) => Promise;
+ 'changeUserStorefront': ( storefrontId: string ) => Promise;
+ 'clearQueue': () => Promise;
+ 'exitFullscreen': () => void;
+ 'mute': () => void;
+ 'pause': () => void;
+ 'play': () => void;
+ 'playAt': ( position: number, options: QueueOptions ) => Promise;
+ 'playLater': ( options: QueueOptions ) => Promise;
+ 'playNext': ( options: QueueOptions, clear: boolean ) => Promise;
+ 'removeEventListener': ( name: string, callback: CallableFunction ) => void;
+ 'requestFullscreen': () => void;
+ 'seekBackward': () => Promise;
+ 'seekForward': () => Promise;
+ 'seekToTime': ( time: number ) => Promise;
+ 'setQueue': ( options: QueueOptions ) => Promise;
+ 'skipToNextItem': () => Promise;
+ 'skipToPreviousItem': () => Promise;
+ 'stop': () => void;
+ 'unauthorize': () => Promise;
+ 'unmute': () => void;
}
diff --git a/enums.d.ts b/enums.d.ts
index 35f04c5..6bb807b 100644
--- a/enums.d.ts
+++ b/enums.d.ts
@@ -1,47 +1,45 @@
-declare namespace MusicKit {
- /**
+/**
* The bitrate to choose for playback. HIGH is 256kbps, STANDARD is 64kbps
*/
- enum PlaybackBitrate {
- 'HIGH',
- 'STANDARD'
- }
+export enum PlaybackBitrate {
+ 'HIGH',
+ 'STANDARD'
+}
- /**
+/**
* State of the player. See https://js-cdn.music.apple.com/musickit/v3/docs/iframe.html?id=reference-javascript-musickit--page&viewMode=story&args=#playbackstates
*/
- enum PlaybackStates {
- 'none',
- 'loading',
- 'playing',
- 'paused',
- 'stopped',
- 'ended',
- 'seeking',
- 'waiting',
- 'stalled',
- 'completed'
- }
+export enum PlaybackStates {
+ 'none',
+ 'loading',
+ 'playing',
+ 'paused',
+ 'stopped',
+ 'ended',
+ 'seeking',
+ 'waiting',
+ 'stalled',
+ 'completed'
+}
- enum PlayerRepeatMode {
- 'all',
- 'none',
- 'one'
- }
+export enum PlayerRepeatMode {
+ 'all',
+ 'none',
+ 'one'
+}
- enum PlayerShuffleMode {
- 'on',
- 'off'
- }
+export enum PlayerShuffleMode {
+ 'on',
+ 'off'
+}
- interface Artwork {
- 'bgColor': string;
- 'height': number;
- 'width': number;
- 'textColor1': string;
- 'textColor2': string;
- 'textColor3': string;
- 'textColor4': string;
- 'url': string;
- }
+export interface Artwork {
+ 'bgColor': string;
+ 'height': number;
+ 'width': number;
+ 'textColor1': string;
+ 'textColor2': string;
+ 'textColor3': string;
+ 'textColor4': string;
+ 'url': string;
}
diff --git a/events.d.ts b/events.d.ts
deleted file mode 100644
index fcb2a21..0000000
--- a/events.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-// FIXME: TS error
-declare global {
- interface GlobalEventHandlersEventMap {
- 'musickitloaded': CustomEvent;
- }
-}
diff --git a/index.d.ts b/index.d.ts
index a4d70cc..fafb913 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,4 +1,11 @@
-/* eslint-disable @typescript-eslint/triple-slash-reference */
-///
+import {
+ MusicKitObject
+} from './MusicKit';
-declare var MusicKit: MusicKit;
+declare global {
+ var MusicKit: MusicKitObject;
+
+ interface GlobalEventHandlersEventMap {
+ 'musickitloaded': CustomEvent;
+ }
+}