Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nuclearplayer/plugin-sdk

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuclearplayer/plugin-sdk - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+49
-0
dist/index.d.ts

@@ -102,2 +102,49 @@ export declare type Album = {

export declare type FavoriteEntry<T> = {
ref: T;
addedAtIso: string;
};
export declare class FavoritesAPI {
#private;
constructor(host?: FavoritesHost);
getTracks(): Promise<FavoriteEntry<Track>[]>;
getAlbums(): Promise<FavoriteEntry<AlbumRef>[]>;
getArtists(): Promise<FavoriteEntry<ArtistRef>[]>;
addTrack(track: Track): Promise<void>;
removeTrack(source: ProviderRef): Promise<void>;
isTrackFavorite(source: ProviderRef): Promise<boolean>;
addAlbum(ref: AlbumRef): Promise<void>;
removeAlbum(source: ProviderRef): Promise<void>;
isAlbumFavorite(source: ProviderRef): Promise<boolean>;
addArtist(ref: ArtistRef): Promise<void>;
removeArtist(source: ProviderRef): Promise<void>;
isArtistFavorite(source: ProviderRef): Promise<boolean>;
subscribe(listener: FavoritesListener): () => void;
}
export declare type FavoritesData = {
tracks: FavoriteEntry<Track>[];
albums: FavoriteEntry<AlbumRef>[];
artists: FavoriteEntry<ArtistRef>[];
};
export declare type FavoritesHost = {
getTracks: () => Promise<FavoriteEntry<Track>[]>;
getAlbums: () => Promise<FavoriteEntry<AlbumRef>[]>;
getArtists: () => Promise<FavoriteEntry<ArtistRef>[]>;
addTrack: (track: Track) => Promise<void>;
removeTrack: (source: ProviderRef) => Promise<void>;
isTrackFavorite: (source: ProviderRef) => Promise<boolean>;
addAlbum: (ref: AlbumRef) => Promise<void>;
removeAlbum: (source: ProviderRef) => Promise<void>;
isAlbumFavorite: (source: ProviderRef) => Promise<boolean>;
addArtist: (ref: ArtistRef) => Promise<void>;
removeArtist: (source: ProviderRef) => Promise<void>;
isArtistFavorite: (source: ProviderRef) => Promise<boolean>;
subscribe: (listener: FavoritesListener) => () => void;
};
export declare type FavoritesListener = (favorites: FavoritesData) => void;
export declare type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;

@@ -191,2 +238,3 @@

readonly Ytdlp: YtdlpAPI;
readonly Favorites: FavoritesAPI;
constructor(opts?: {

@@ -200,2 +248,3 @@ settingsHost?: SettingsHost;

ytdlpHost?: YtdlpHost;
favoritesHost?: FavoritesHost;
});

@@ -202,0 +251,0 @@ }

+80
-28
import { useState as l, useEffect as f, useMemo as g } from "react";
const b = (s) => {
class b {
#e;
constructor(t) {
this.#e = t;
}
#t(t) {
const e = this.#e;
if (!e)
throw new Error("Favorites host not available");
return t(e);
}
getTracks() {
return this.#t((t) => t.getTracks());
}
getAlbums() {
return this.#t((t) => t.getAlbums());
}
getArtists() {
return this.#t((t) => t.getArtists());
}
addTrack(t) {
return this.#t((e) => e.addTrack(t));
}
removeTrack(t) {
return this.#t((e) => e.removeTrack(t));
}
isTrackFavorite(t) {
return this.#t((e) => e.isTrackFavorite(t));
}
addAlbum(t) {
return this.#t((e) => e.addAlbum(t));
}
removeAlbum(t) {
return this.#t((e) => e.removeAlbum(t));
}
isAlbumFavorite(t) {
return this.#t((e) => e.isAlbumFavorite(t));
}
addArtist(t) {
return this.#t((e) => e.addArtist(t));
}
removeArtist(t) {
return this.#t((e) => e.removeArtist(t));
}
isArtistFavorite(t) {
return this.#t((e) => e.isArtistFavorite(t));
}
subscribe(t) {
return this.#t((e) => e.subscribe(t));
}
}
const m = (s) => {
if (s instanceof Headers) {

@@ -11,8 +62,8 @@ const t = {};

};
function m(s) {
function A(s) {
return async (t, e) => {
const r = String(t instanceof Request ? t.url : t), a = e?.headers ? b(e.headers) : void 0, o = typeof e?.body == "string" ? e.body : void 0, u = await s.fetch(r, {
const r = String(t instanceof Request ? t.url : t), a = e?.headers ? m(e.headers) : void 0, n = typeof e?.body == "string" ? e.body : void 0, u = await s.fetch(r, {
method: e?.method,
headers: a,
body: o
body: n
});

@@ -25,3 +76,3 @@ return new Response(u.body, {

}
const A = {
const v = {
fetch: async () => ({

@@ -33,9 +84,9 @@ status: 501,

};
class p {
class w {
fetch;
constructor(t) {
this.fetch = m(t ?? A);
this.fetch = A(t ?? v);
}
}
class v {
class T {
#e;

@@ -72,3 +123,3 @@ constructor(t) {

}
class w {
class p {
#e;

@@ -163,3 +214,3 @@ constructor(t) {

}
class T {
class H {
#e;

@@ -206,3 +257,3 @@ constructor(t) {

}
class H {
class S {
host;

@@ -226,3 +277,3 @@ constructor(t) {

}
class S {
class F {
Settings;

@@ -235,8 +286,8 @@ Providers;

Ytdlp;
// All these are optional so we don't have to provide all of them in tests
Favorites;
constructor(t) {
this.Settings = new T(t?.settingsHost), this.Providers = new w(t?.providersHost), this.Queue = new I(t?.queueHost), this.Streaming = new y(t?.streamingHost), this.Metadata = new v(t?.metadataHost), this.Http = new p(t?.httpHost), this.Ytdlp = new H(t?.ytdlpHost);
this.Settings = new H(t?.settingsHost), this.Providers = new p(t?.providersHost), this.Queue = new I(t?.queueHost), this.Streaming = new y(t?.streamingHost), this.Metadata = new T(t?.metadataHost), this.Http = new w(t?.httpHost), this.Ytdlp = new S(t?.ytdlpHost), this.Favorites = new b(t?.favoritesHost);
}
}
class P extends S {
class P extends F {
}

@@ -253,15 +304,15 @@ class M extends Error {

return;
let o = !0, u = !1;
const i = s.subscribe(t, (n) => {
o && (u = !0, r(n));
let n = !0, u = !1;
const i = s.subscribe(t, (o) => {
n && (u = !0, r(o));
});
return s.get(t).then((n) => {
o && (u || r(n));
return s.get(t).then((o) => {
n && (u || r(o));
}), () => {
o = !1, i && i();
n = !1, i && i();
};
}, [t, s]);
const a = g(
() => (o) => {
s && s.set(t, o);
() => (n) => {
s && s.set(t, n);
},

@@ -292,3 +343,3 @@ [t, s]

return r.map((i) => {
const n = Math.min(i.width || 0, i.height || 0), h = Math.abs(a(i) - u), c = Math.abs(n - e), d = n < e ? e / n : 1;
const o = Math.min(i.width || 0, i.height || 0), h = Math.abs(a(i) - u), c = Math.abs(o - e), d = o < e ? e / o : 1;
return {

@@ -298,12 +349,13 @@ artwork: i,

};
}).sort((i, n) => n.score - i.score)[0]?.artwork;
}).sort((i, o) => o.score - i.score)[0]?.artwork;
}
export {
p as HttpAPI,
b as FavoritesAPI,
w as HttpAPI,
M as MissingCapabilityError,
S as NuclearAPI,
F as NuclearAPI,
P as NuclearPluginAPI,
H as YtdlpAPI,
S as YtdlpAPI,
R as pickArtwork,
C as useSetting
};
{
"name": "@nuclearplayer/plugin-sdk",
"version": "1.0.0",
"version": "1.1.0",
"description": "Plugin SDK for Nuclear music player",

@@ -41,4 +41,4 @@ "type": "module",

"vitest": "^3.2.4",
"@nuclearplayer/tailwind-config": "0.0.10",
"@nuclearplayer/eslint-config": "0.0.10"
"@nuclearplayer/eslint-config": "0.0.10",
"@nuclearplayer/tailwind-config": "0.0.10"
},

@@ -45,0 +45,0 @@ "peerDependencies": {