@nuclearplayer/plugin-sdk 2.2.0 → 2.4.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 +7 -1
- package/dist/index.d.ts +171 -4
- package/dist/index.js +493 -423
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -108,13 +108,19 @@ The `api` object passed to lifecycle hooks provides access to these domain APIs:
|
|
|
108
108
|
|-----|-------------|
|
|
109
109
|
| `api.Settings` | Define, read, and persist plugin settings |
|
|
110
110
|
| `api.Queue` | Read and manipulate the playback queue |
|
|
111
|
+
| `api.Playback` | Control audio transport: play, pause, stop, seek |
|
|
112
|
+
| `api.Events` | Subscribe to player lifecycle events (e.g. track finished) |
|
|
111
113
|
| `api.Favorites` | Manage the user's favorite tracks |
|
|
114
|
+
| `api.Playlists` | Create, update, and delete playlists |
|
|
112
115
|
| `api.Providers` | Register and unregister providers |
|
|
113
116
|
| `api.Streaming` | Resolve audio stream URLs for tracks |
|
|
114
117
|
| `api.Metadata` | Search and fetch artist/album/track details |
|
|
115
118
|
| `api.Dashboard` | Fetch dashboard content (top tracks, new releases, etc.) |
|
|
119
|
+
| `api.Http` | Make HTTP requests from plugins and bypass CORS |
|
|
120
|
+
| `api.Logger` | Structured logging |
|
|
121
|
+
| `api.Ytdlp` | yt-dlp integration |
|
|
116
122
|
|
|
117
|
-
See the [full documentation](https://docs.nuclearplayer.com
|
|
123
|
+
See the [full documentation](https://docs.nuclearplayer.com) for detailed guides on each API.
|
|
118
124
|
|
|
119
125
|
## Permissions
|
|
120
126
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
export declare type Album = {
|
|
@@ -96,6 +97,27 @@ export declare type BooleanWidget = {
|
|
|
96
97
|
type: 'toggle';
|
|
97
98
|
};
|
|
98
99
|
|
|
100
|
+
export declare type CustomSettingDefinition = {
|
|
101
|
+
id: string;
|
|
102
|
+
title: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
category: SettingCategory;
|
|
105
|
+
kind: 'custom';
|
|
106
|
+
widgetId: string;
|
|
107
|
+
default?: SettingValue;
|
|
108
|
+
hidden?: boolean;
|
|
109
|
+
source?: SettingSource;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export declare type CustomWidgetComponent<API = unknown> = FC<CustomWidgetProps<API>>;
|
|
113
|
+
|
|
114
|
+
export declare type CustomWidgetProps<API = unknown> = {
|
|
115
|
+
value: SettingValue | undefined;
|
|
116
|
+
setValue: (value: SettingValue) => void;
|
|
117
|
+
definition: CustomSettingDefinition;
|
|
118
|
+
api: API;
|
|
119
|
+
};
|
|
120
|
+
|
|
99
121
|
export declare class DashboardAPI {
|
|
100
122
|
#private;
|
|
101
123
|
constructor(host?: DashboardHost);
|
|
@@ -150,6 +172,17 @@ export declare type EnumWidget = {
|
|
|
150
172
|
type: 'radio';
|
|
151
173
|
};
|
|
152
174
|
|
|
175
|
+
export declare class EventsAPI {
|
|
176
|
+
#private;
|
|
177
|
+
constructor(host?: EventsHost);
|
|
178
|
+
on<E extends keyof PluginEventMap>(event: E, listener: PluginEventListener<E>): () => void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export declare type EventsHost = {
|
|
182
|
+
on<E extends keyof PluginEventMap>(event: E, listener: PluginEventListener<E>): () => void;
|
|
183
|
+
emit<E extends keyof PluginEventMap>(event: E, payload: PluginEventMap[E]): void;
|
|
184
|
+
};
|
|
185
|
+
|
|
153
186
|
export declare type FavoriteEntry<T> = {
|
|
154
187
|
ref: T;
|
|
155
188
|
addedAtIso: string;
|
|
@@ -220,6 +253,95 @@ export declare type HttpResponseData = {
|
|
|
220
253
|
body: string;
|
|
221
254
|
};
|
|
222
255
|
|
|
256
|
+
export declare type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
|
|
257
|
+
[key: string]: JsonSerializable;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export declare const legacyConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
261
|
+
playlists: z.ZodArray<z.ZodUnknown, "many">;
|
|
262
|
+
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
playlists: unknown[];
|
|
264
|
+
}, {
|
|
265
|
+
playlists: unknown[];
|
|
266
|
+
}>, {
|
|
267
|
+
playlists: unknown[];
|
|
268
|
+
}, {
|
|
269
|
+
playlists: unknown[];
|
|
270
|
+
}>;
|
|
271
|
+
|
|
272
|
+
export declare type LegacyPlaylist = z.infer<typeof legacyPlaylistSchema>;
|
|
273
|
+
|
|
274
|
+
export declare const legacyPlaylistSchema: z.ZodObject<{
|
|
275
|
+
name: z.ZodString;
|
|
276
|
+
tracks: z.ZodArray<z.ZodObject<{
|
|
277
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
278
|
+
artist: z.ZodOptional<z.ZodString>;
|
|
279
|
+
name: z.ZodOptional<z.ZodString>;
|
|
280
|
+
album: z.ZodOptional<z.ZodString>;
|
|
281
|
+
thumbnail: z.ZodOptional<z.ZodString>;
|
|
282
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodString, number, string>]>, number, string | number>>;
|
|
283
|
+
}, "strip", z.ZodTypeAny, {
|
|
284
|
+
thumbnail?: string | undefined;
|
|
285
|
+
name?: string | undefined;
|
|
286
|
+
uuid?: string | undefined;
|
|
287
|
+
artist?: string | undefined;
|
|
288
|
+
album?: string | undefined;
|
|
289
|
+
duration?: number | undefined;
|
|
290
|
+
}, {
|
|
291
|
+
thumbnail?: string | undefined;
|
|
292
|
+
name?: string | undefined;
|
|
293
|
+
uuid?: string | undefined;
|
|
294
|
+
artist?: string | undefined;
|
|
295
|
+
album?: string | undefined;
|
|
296
|
+
duration?: string | number | undefined;
|
|
297
|
+
}>, "many">;
|
|
298
|
+
}, "strip", z.ZodTypeAny, {
|
|
299
|
+
name: string;
|
|
300
|
+
tracks: {
|
|
301
|
+
thumbnail?: string | undefined;
|
|
302
|
+
name?: string | undefined;
|
|
303
|
+
uuid?: string | undefined;
|
|
304
|
+
artist?: string | undefined;
|
|
305
|
+
album?: string | undefined;
|
|
306
|
+
duration?: number | undefined;
|
|
307
|
+
}[];
|
|
308
|
+
}, {
|
|
309
|
+
name: string;
|
|
310
|
+
tracks: {
|
|
311
|
+
thumbnail?: string | undefined;
|
|
312
|
+
name?: string | undefined;
|
|
313
|
+
uuid?: string | undefined;
|
|
314
|
+
artist?: string | undefined;
|
|
315
|
+
album?: string | undefined;
|
|
316
|
+
duration?: string | number | undefined;
|
|
317
|
+
}[];
|
|
318
|
+
}>;
|
|
319
|
+
|
|
320
|
+
export declare type LegacyTrack = z.infer<typeof legacyTrackSchema>;
|
|
321
|
+
|
|
322
|
+
export declare const legacyTrackSchema: z.ZodObject<{
|
|
323
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
324
|
+
artist: z.ZodOptional<z.ZodString>;
|
|
325
|
+
name: z.ZodOptional<z.ZodString>;
|
|
326
|
+
album: z.ZodOptional<z.ZodString>;
|
|
327
|
+
thumbnail: z.ZodOptional<z.ZodString>;
|
|
328
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodString, number, string>]>, number, string | number>>;
|
|
329
|
+
}, "strip", z.ZodTypeAny, {
|
|
330
|
+
thumbnail?: string | undefined;
|
|
331
|
+
name?: string | undefined;
|
|
332
|
+
uuid?: string | undefined;
|
|
333
|
+
artist?: string | undefined;
|
|
334
|
+
album?: string | undefined;
|
|
335
|
+
duration?: number | undefined;
|
|
336
|
+
}, {
|
|
337
|
+
thumbnail?: string | undefined;
|
|
338
|
+
name?: string | undefined;
|
|
339
|
+
uuid?: string | undefined;
|
|
340
|
+
artist?: string | undefined;
|
|
341
|
+
album?: string | undefined;
|
|
342
|
+
duration?: string | number | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
|
|
223
345
|
export declare type LoadedPlugin = {
|
|
224
346
|
metadata: PluginMetadata;
|
|
225
347
|
instance: NuclearPlugin;
|
|
@@ -313,6 +435,8 @@ export declare class NuclearAPI {
|
|
|
313
435
|
readonly Dashboard: DashboardAPI;
|
|
314
436
|
readonly Playback: PlaybackAPI;
|
|
315
437
|
readonly Playlists: PlaylistsAPI;
|
|
438
|
+
readonly Events: EventsAPI;
|
|
439
|
+
readonly Shell: ShellAPI;
|
|
316
440
|
constructor(opts?: {
|
|
317
441
|
settingsHost?: SettingsHost;
|
|
318
442
|
providersHost?: ProvidersHost;
|
|
@@ -326,6 +450,10 @@ export declare class NuclearAPI {
|
|
|
326
450
|
dashboardHost?: DashboardHost;
|
|
327
451
|
playbackHost?: PlaybackHost;
|
|
328
452
|
playlistsHost?: PlaylistsHost;
|
|
453
|
+
eventsHost?: EventsHost;
|
|
454
|
+
shellHost?: ShellHost;
|
|
455
|
+
widgetRegistry?: WidgetRegistry;
|
|
456
|
+
pluginId?: string;
|
|
329
457
|
});
|
|
330
458
|
}
|
|
331
459
|
|
|
@@ -929,6 +1057,7 @@ export declare const playlistExportSchema: z.ZodObject<{
|
|
|
929
1057
|
export declare type PlaylistIndexEntry = Pick<Playlist, 'id' | 'name' | 'createdAtIso' | 'lastModifiedIso' | 'isReadOnly' | 'artwork'> & {
|
|
930
1058
|
itemCount: number;
|
|
931
1059
|
totalDurationMs: number;
|
|
1060
|
+
thumbnails: string[];
|
|
932
1061
|
};
|
|
933
1062
|
|
|
934
1063
|
export declare const playlistIndexEntrySchema: z.ZodObject<{
|
|
@@ -1004,6 +1133,7 @@ export declare const playlistIndexEntrySchema: z.ZodObject<{
|
|
|
1004
1133
|
}>>;
|
|
1005
1134
|
itemCount: z.ZodNumber;
|
|
1006
1135
|
totalDurationMs: z.ZodNumber;
|
|
1136
|
+
thumbnails: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
1007
1137
|
}, "strip", z.ZodTypeAny, {
|
|
1008
1138
|
id: string;
|
|
1009
1139
|
name: string;
|
|
@@ -1012,6 +1142,7 @@ export declare const playlistIndexEntrySchema: z.ZodObject<{
|
|
|
1012
1142
|
isReadOnly: boolean;
|
|
1013
1143
|
itemCount: number;
|
|
1014
1144
|
totalDurationMs: number;
|
|
1145
|
+
thumbnails: string[];
|
|
1015
1146
|
artwork?: {
|
|
1016
1147
|
items: {
|
|
1017
1148
|
url: string;
|
|
@@ -1046,6 +1177,7 @@ export declare const playlistIndexEntrySchema: z.ZodObject<{
|
|
|
1046
1177
|
} | undefined;
|
|
1047
1178
|
}[];
|
|
1048
1179
|
} | undefined;
|
|
1180
|
+
thumbnails?: string[] | undefined;
|
|
1049
1181
|
}>;
|
|
1050
1182
|
|
|
1051
1183
|
export declare const playlistIndexSchema: z.ZodArray<z.ZodObject<{
|
|
@@ -1121,6 +1253,7 @@ export declare const playlistIndexSchema: z.ZodArray<z.ZodObject<{
|
|
|
1121
1253
|
}>>;
|
|
1122
1254
|
itemCount: z.ZodNumber;
|
|
1123
1255
|
totalDurationMs: z.ZodNumber;
|
|
1256
|
+
thumbnails: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
1124
1257
|
}, "strip", z.ZodTypeAny, {
|
|
1125
1258
|
id: string;
|
|
1126
1259
|
name: string;
|
|
@@ -1129,6 +1262,7 @@ export declare const playlistIndexSchema: z.ZodArray<z.ZodObject<{
|
|
|
1129
1262
|
isReadOnly: boolean;
|
|
1130
1263
|
itemCount: number;
|
|
1131
1264
|
totalDurationMs: number;
|
|
1265
|
+
thumbnails: string[];
|
|
1132
1266
|
artwork?: {
|
|
1133
1267
|
items: {
|
|
1134
1268
|
url: string;
|
|
@@ -1163,6 +1297,7 @@ export declare const playlistIndexSchema: z.ZodArray<z.ZodObject<{
|
|
|
1163
1297
|
} | undefined;
|
|
1164
1298
|
}[];
|
|
1165
1299
|
} | undefined;
|
|
1300
|
+
thumbnails?: string[] | undefined;
|
|
1166
1301
|
}>, "many">;
|
|
1167
1302
|
|
|
1168
1303
|
export declare type PlaylistItem<T extends Track = Track> = {
|
|
@@ -1172,6 +1307,11 @@ export declare type PlaylistItem<T extends Track = Track> = {
|
|
|
1172
1307
|
addedAtIso: string;
|
|
1173
1308
|
};
|
|
1174
1309
|
|
|
1310
|
+
export declare type PlaylistProvider = ProviderDescriptor<'playlists'> & {
|
|
1311
|
+
matchesUrl: (url: string) => boolean;
|
|
1312
|
+
fetchPlaylistByUrl: (url: string) => Promise<Playlist>;
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1175
1315
|
export declare type PlaylistRef = {
|
|
1176
1316
|
id: string;
|
|
1177
1317
|
name: string;
|
|
@@ -1603,6 +1743,13 @@ export declare type PlaylistsHost = {
|
|
|
1603
1743
|
|
|
1604
1744
|
export declare type PlaylistsListener = (index: PlaylistIndexEntry[]) => void;
|
|
1605
1745
|
|
|
1746
|
+
export declare type PluginEventListener<E extends keyof PluginEventMap> = (payload: PluginEventMap[E]) => void | Promise<void>;
|
|
1747
|
+
|
|
1748
|
+
export declare type PluginEventMap = {
|
|
1749
|
+
trackFinished: Track;
|
|
1750
|
+
trackStarted: Track;
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1606
1753
|
export declare type PluginIcon = {
|
|
1607
1754
|
type: 'link';
|
|
1608
1755
|
link: string;
|
|
@@ -1641,7 +1788,7 @@ export declare type ProviderDescriptor<K extends ProviderKind = ProviderKind> =
|
|
|
1641
1788
|
pluginId?: string;
|
|
1642
1789
|
};
|
|
1643
1790
|
|
|
1644
|
-
export declare type ProviderKind = 'metadata' | 'streaming' | 'lyrics' | 'dashboard' | (string & {});
|
|
1791
|
+
export declare type ProviderKind = 'metadata' | 'streaming' | 'lyrics' | 'dashboard' | 'playlists' | (string & {});
|
|
1645
1792
|
|
|
1646
1793
|
export declare type ProviderRef = {
|
|
1647
1794
|
provider: string;
|
|
@@ -1755,15 +1902,17 @@ export declare type SearchResults = {
|
|
|
1755
1902
|
|
|
1756
1903
|
export declare type SettingCategory = string;
|
|
1757
1904
|
|
|
1758
|
-
export declare type SettingDefinition = BooleanSettingDefinition | NumberSettingDefinition | StringSettingDefinition | EnumSettingDefinition;
|
|
1905
|
+
export declare type SettingDefinition = BooleanSettingDefinition | NumberSettingDefinition | StringSettingDefinition | EnumSettingDefinition | CustomSettingDefinition;
|
|
1759
1906
|
|
|
1760
1907
|
declare class Settings {
|
|
1761
1908
|
#private;
|
|
1762
|
-
constructor(host?: SettingsHost);
|
|
1909
|
+
constructor(host?: SettingsHost, widgetRegistry?: WidgetRegistry, pluginId?: string);
|
|
1763
1910
|
register(defs: SettingDefinition[]): Promise<SettingsRegistrationResult>;
|
|
1764
1911
|
get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
|
|
1765
1912
|
set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
|
|
1766
1913
|
subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
|
|
1914
|
+
registerWidget(widgetId: string, component: CustomWidgetComponent): void;
|
|
1915
|
+
unregisterWidget(widgetId: string): void;
|
|
1767
1916
|
}
|
|
1768
1917
|
|
|
1769
1918
|
export declare type SettingsHost = {
|
|
@@ -1789,7 +1938,17 @@ export declare type SettingsRegistrationResult = {
|
|
|
1789
1938
|
registered: string[];
|
|
1790
1939
|
};
|
|
1791
1940
|
|
|
1792
|
-
export declare type SettingValue =
|
|
1941
|
+
export declare type SettingValue = JsonSerializable | undefined;
|
|
1942
|
+
|
|
1943
|
+
export declare class ShellAPI {
|
|
1944
|
+
#private;
|
|
1945
|
+
constructor(host?: ShellHost);
|
|
1946
|
+
openExternal(url: string): Promise<void>;
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
export declare type ShellHost = {
|
|
1950
|
+
openExternal(url: string): Promise<void>;
|
|
1951
|
+
};
|
|
1793
1952
|
|
|
1794
1953
|
export declare type Stream = {
|
|
1795
1954
|
url: string;
|
|
@@ -1869,6 +2028,8 @@ export declare type StringWidget = {
|
|
|
1869
2028
|
type: 'textarea';
|
|
1870
2029
|
placeholder?: string;
|
|
1871
2030
|
rows?: number;
|
|
2031
|
+
} | {
|
|
2032
|
+
type: 'info';
|
|
1872
2033
|
};
|
|
1873
2034
|
|
|
1874
2035
|
export declare type Track = {
|
|
@@ -1894,6 +2055,12 @@ export declare type TrackRef = {
|
|
|
1894
2055
|
|
|
1895
2056
|
export declare const useSetting: <T extends SettingValue = SettingValue>(host: SettingsHost | undefined, id: string) => readonly [T | undefined, (nextValue: T) => void];
|
|
1896
2057
|
|
|
2058
|
+
export declare type WidgetRegistry = {
|
|
2059
|
+
register(pluginId: string, widgetId: string, component: CustomWidgetComponent): void;
|
|
2060
|
+
unregister(pluginId: string, widgetId: string): void;
|
|
2061
|
+
get(pluginId: string, widgetId: string): CustomWidgetComponent | undefined;
|
|
2062
|
+
};
|
|
2063
|
+
|
|
1897
2064
|
export declare class YtdlpAPI {
|
|
1898
2065
|
private host?;
|
|
1899
2066
|
constructor(host?: YtdlpHost);
|