feat: improved types, changes coming

This commit is contained in:
janishutz committed 2026-08-29 15:17:10 +02:00
1 parent abbd0b48c5
commit 95338f676e
6 files changed
+142 -3

No files matched your search

+11 -2
View File
@@ -1,5 +1,10 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="MusicKitInstance.d.ts" />
/// <reference path="enums.d.ts" />
/// <reference path="MusicKitAPI.d.ts" />
declare namespace MusicKit {
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
*/
@@ -34,5 +39,9 @@ declare namespace MusicKit {
'storefrontId'?: string;
}
function configure ( config: MusicKitConfiguration ): Promise<MusicKitInstance>;
export function configure ( config: MusicKitConfiguration ): Promise<MusicKitInstance>;
export function getInstance (): MusicKitInstance;
export function formatArtworkURL ( artwork: Artwork, width: number, height: number ): string;
}
+15
View File
@@ -0,0 +1,15 @@
declare namespace MusicKit {
interface MusicKitAPI {
'music': (
path: string,
params: {
[key: string]: string
},
opts: {
'fetchOptions': RequestInit
}
) => Promise<{
'data': unknown
}>
}
}
+78 -1
View File
@@ -1,3 +1,80 @@
declare namespace MusicKit {
interface MusicKitInstance {}
type MediaItem = object;
interface Queue {
'currentItem': MediaItem;
'isEmpty': boolean;
'items': MediaItem[];
'length': number;
'nextPlayableItem': MediaItem;
'position': number;
'previousPlayableItem': MediaItem;
}
interface QueueOptions {
'album'?: string;
'albums'?: string[];
'musicVideo'?: string;
'musicVideos'?: string[];
'playlist'?: string;
'playlists'?: string[];
'song'?: string;
'songs'?: string[];
}
interface SeekSeconds {
'BACK': number;
'FORWARD': number;
}
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
+11
View File
@@ -33,4 +33,15 @@ declare namespace MusicKit {
'on',
'off'
}
interface Artwork {
'bgColor': string;
'height': number;
'width': number;
'textColor1': string;
'textColor2': string;
'textColor3': string;
'textColor4': string;
'url': string;
}
}
Vendored
+4
View File
@@ -0,0 +1,4 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="MusicKit.d.ts">
declare var MusicKit: MusicKit;
+23
View File
@@ -1,4 +1,27 @@
{
"name": "musickitjs-v3-types",
"version": "1.0.0",
"description": "Types for musickit js version 3.0",
"keywords": [
"musickitjs",
"types"
],
"homepage": "https://github.com/janishutz/musickitjs-v3-types#readme",
"bugs": {
"url": "https://github.com/janishutz/musickitjs-v3-types/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/janishutz/musickitjs-v3-types.git"
},
"license": "GPL-3.0-or-later",
"author": "Janis Hutz",
"type": "module",
"main": "index.js",
"types": "./index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@stylistic/eslint-plugin": "^5.10.0",