mirror of
https://github.com/janishutz/musickitjs-v3-types.git
synced 2026-10-08 20:56:23 +02:00
feat: working types
This commit is contained in:
1 parent
95338f676e
commit
bba6fd185e
6 files changed
+178
-170
No files matched your search
Vendored
+37
-34
@@ -1,47 +1,50 @@
|
||||
/* eslint-disable @typescript-eslint/triple-slash-reference */
|
||||
/// <reference path="MusicKitInstance.d.ts" />
|
||||
/// <reference path="enums.d.ts" />
|
||||
/// <reference path="MusicKitAPI.d.ts" />
|
||||
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<MusicKitInstance>;
|
||||
'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<MusicKitInstance>;
|
||||
|
||||
'getInstance': () => MusicKitInstance;
|
||||
|
||||
'formatArtworkURL': ( artwork: Artwork, width: number, height: number ) => string;
|
||||
}
|
||||
Vendored
+12
-14
@@ -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
|
||||
}>
|
||||
}
|
||||
Vendored
+83
-75
@@ -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<MusicKitAPI>;
|
||||
'bitrate': Readonly<PlaybackBitrate>;
|
||||
'currentPlaybackDuration': Readonly<number>;
|
||||
'currentPlaybackProgress': Readonly<number>;
|
||||
'currentPlaybackTime': Readonly<number>;
|
||||
'currentPlaybackTimeRemaining': Readonly<number>;
|
||||
'isAuthorized': Readonly<boolean>;
|
||||
'isPlaying': Readonly<boolean>;
|
||||
'nowPlayingItem': Readonly<MediaItem>;
|
||||
'nowPlayingItemIndex': Readonly<number>;
|
||||
'playbackRate': Readonly<number>;
|
||||
'playbackState': Readonly<PlaybackStates>;
|
||||
'previewOnly': Readonly<boolean>;
|
||||
'queue': Readonly<Queue>;
|
||||
'queueIsEmpty': Readonly<boolean>;
|
||||
'repeatMode': Readonly<PlayerRepeatMode>;
|
||||
'seekSeconds': Readonly<SeekSeconds | undefined>;
|
||||
'shuffleMode': Readonly<PlayerShuffleMode>;
|
||||
'storefrontCountryCode': Readonly<string>;
|
||||
'storefrontId': Readonly<string>;
|
||||
'videoContainerElement': Readonly<HTMLVideoElement | undefined>;
|
||||
'volume': Readonly<number>;
|
||||
'addEventListener': ( name: string, callback: CallableFunction, options: {
|
||||
'once': boolean
|
||||
} ) => void;
|
||||
'authorize': () => Promise<string | void>;
|
||||
'changeToMediaAtIndex': ( index: number ) => Promise<void>;
|
||||
'changeToMediaItem': ( descriptor: MediaItem | string ) => Promise<void>;
|
||||
'changeUserStorefront': ( storefrontId: string ) => Promise<void>;
|
||||
'clearQueue': () => Promise<Queue>;
|
||||
'exitFullscreen': () => void;
|
||||
'mute': () => void;
|
||||
'pause': () => void;
|
||||
'play': () => void;
|
||||
'playAt': ( position: number, options: QueueOptions ) => Promise<Queue | void>;
|
||||
'playLater': ( options: QueueOptions ) => Promise<Queue | void>;
|
||||
'playNext': ( options: QueueOptions, clear: boolean ) => Promise<Queue | void>;
|
||||
'removeEventListener': ( name: string, callback: CallableFunction ) => void;
|
||||
'requestFullscreen': () => void;
|
||||
'seekBackward': () => Promise<void>;
|
||||
'seekForward': () => Promise<void>;
|
||||
'seekToTime': ( time: number ) => Promise<void>;
|
||||
'setQueue': ( options: QueueOptions ) => Promise<Queue | void>;
|
||||
'skipToNextItem': () => Promise<void>;
|
||||
'skipToPreviousItem': () => Promise<void>;
|
||||
'stop': () => void;
|
||||
'unauthorize': () => Promise<void>;
|
||||
'unmute': () => void;
|
||||
}
|
||||
export interface SeekSeconds {
|
||||
'BACK': number;
|
||||
'FORWARD': number;
|
||||
}
|
||||
|
||||
export interface MusicKitInstance {
|
||||
'api': Readonly<MusicKitAPI>;
|
||||
'bitrate': Readonly<PlaybackBitrate>;
|
||||
'currentPlaybackDuration': Readonly<number>;
|
||||
'currentPlaybackProgress': Readonly<number>;
|
||||
'currentPlaybackTime': Readonly<number>;
|
||||
'currentPlaybackTimeRemaining': Readonly<number>;
|
||||
'isAuthorized': Readonly<boolean>;
|
||||
'isPlaying': Readonly<boolean>;
|
||||
'nowPlayingItem': Readonly<MediaItem>;
|
||||
'nowPlayingItemIndex': Readonly<number>;
|
||||
'playbackRate': Readonly<number>;
|
||||
'playbackState': Readonly<PlaybackStates>;
|
||||
'previewOnly': Readonly<boolean>;
|
||||
'queue': Readonly<Queue>;
|
||||
'queueIsEmpty': Readonly<boolean>;
|
||||
'repeatMode': Readonly<PlayerRepeatMode>;
|
||||
'seekSeconds': Readonly<SeekSeconds | undefined>;
|
||||
'shuffleMode': Readonly<PlayerShuffleMode>;
|
||||
'storefrontCountryCode': Readonly<string>;
|
||||
'storefrontId': Readonly<string>;
|
||||
'videoContainerElement': Readonly<HTMLVideoElement | undefined>;
|
||||
'volume': Readonly<number>;
|
||||
'addEventListener': ( name: string, callback: CallableFunction, options: {
|
||||
'once': boolean
|
||||
} ) => void;
|
||||
'authorize': () => Promise<string | void>;
|
||||
'changeToMediaAtIndex': ( index: number ) => Promise<void>;
|
||||
'changeToMediaItem': ( descriptor: MediaItem | string ) => Promise<void>;
|
||||
'changeUserStorefront': ( storefrontId: string ) => Promise<void>;
|
||||
'clearQueue': () => Promise<Queue>;
|
||||
'exitFullscreen': () => void;
|
||||
'mute': () => void;
|
||||
'pause': () => void;
|
||||
'play': () => void;
|
||||
'playAt': ( position: number, options: QueueOptions ) => Promise<Queue | void>;
|
||||
'playLater': ( options: QueueOptions ) => Promise<Queue | void>;
|
||||
'playNext': ( options: QueueOptions, clear: boolean ) => Promise<Queue | void>;
|
||||
'removeEventListener': ( name: string, callback: CallableFunction ) => void;
|
||||
'requestFullscreen': () => void;
|
||||
'seekBackward': () => Promise<void>;
|
||||
'seekForward': () => Promise<void>;
|
||||
'seekToTime': ( time: number ) => Promise<void>;
|
||||
'setQueue': ( options: QueueOptions ) => Promise<Queue | void>;
|
||||
'skipToNextItem': () => Promise<void>;
|
||||
'skipToPreviousItem': () => Promise<void>;
|
||||
'stop': () => void;
|
||||
'unauthorize': () => Promise<void>;
|
||||
'unmute': () => void;
|
||||
}
|
||||
Vendored
+36
-38
@@ -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;
|
||||
}
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
// FIXME: TS error
|
||||
declare global {
|
||||
interface GlobalEventHandlersEventMap {
|
||||
'musickitloaded': CustomEvent<void>;
|
||||
}
|
||||
}
|
||||
Vendored
+10
-3
@@ -1,4 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/triple-slash-reference */
|
||||
/// <reference path="MusicKit.d.ts">
|
||||
import {
|
||||
MusicKitObject
|
||||
} from './MusicKit';
|
||||
|
||||
declare var MusicKit: MusicKit;
|
||||
declare global {
|
||||
var MusicKit: MusicKitObject;
|
||||
|
||||
interface GlobalEventHandlersEventMap {
|
||||
'musickitloaded': CustomEvent<void>;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user