@nuclearplayer/plugin-sdk 0.0.11 → 1.0.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/dist/index.d.ts CHANGED
@@ -1,8 +1,586 @@
1
- export { NuclearPluginAPI, NuclearAPI } from './api';
2
- export * from './types';
3
- export * from './types/settings';
4
- export * from './types/search';
5
- export type { ProvidersHost } from './types/providers';
6
- export { useSetting } from './react/useSetting';
7
- export * from '@nuclearplayer/model';
8
- //# sourceMappingURL=index.d.ts.map
1
+ export declare type Album = {
2
+ title: string;
3
+ artists: ArtistCredit[];
4
+ tracks?: TrackRef[];
5
+ releaseDate?: {
6
+ precision: 'year' | 'month' | 'day';
7
+ dateIso: string;
8
+ };
9
+ genres?: string[];
10
+ artwork?: ArtworkSet;
11
+ source: ProviderRef;
12
+ };
13
+
14
+ export declare type AlbumMetadataCapability = 'albumDetails';
15
+
16
+ export declare type AlbumRef = {
17
+ title: string;
18
+ artists?: ArtistRef[];
19
+ artwork?: ArtworkSet;
20
+ source: ProviderRef;
21
+ };
22
+
23
+ export declare type Artist = {
24
+ name: string;
25
+ disambiguation?: string;
26
+ bio?: string;
27
+ onTour?: boolean;
28
+ artwork?: ArtworkSet;
29
+ tags?: string[];
30
+ source: ProviderRef;
31
+ };
32
+
33
+ export declare type ArtistCredit = {
34
+ name: string;
35
+ roles: string[];
36
+ source?: ProviderRef;
37
+ };
38
+
39
+ export declare type ArtistMetadataCapability = 'artistDetails' | 'artistAlbums' | 'artistTopTracks' | 'artistRelatedArtists';
40
+
41
+ export declare type ArtistRef = {
42
+ name: string;
43
+ disambiguation?: string;
44
+ artwork?: ArtworkSet;
45
+ source: ProviderRef;
46
+ };
47
+
48
+ export declare type Artwork = {
49
+ url: string;
50
+ width?: number;
51
+ height?: number;
52
+ purpose?: ArtworkPurpose;
53
+ source?: ProviderRef;
54
+ };
55
+
56
+ export declare type ArtworkPurpose = 'avatar' | 'cover' | 'background' | 'thumbnail';
57
+
58
+ export declare type ArtworkSet = {
59
+ items: Artwork[];
60
+ };
61
+
62
+ export declare type BooleanSettingDefinition = {
63
+ id: string;
64
+ title: string;
65
+ description?: string;
66
+ category: SettingCategory;
67
+ kind: 'boolean';
68
+ default?: boolean;
69
+ hidden?: boolean;
70
+ source?: SettingSource;
71
+ widget?: BooleanWidget;
72
+ };
73
+
74
+ export declare type BooleanWidget = {
75
+ type: 'toggle';
76
+ };
77
+
78
+ export declare type EnumOption = {
79
+ value: string;
80
+ label: string;
81
+ };
82
+
83
+ export declare type EnumSettingDefinition = {
84
+ id: string;
85
+ title: string;
86
+ description?: string;
87
+ category: SettingCategory;
88
+ kind: 'enum';
89
+ options: EnumOption[];
90
+ default?: string;
91
+ hidden?: boolean;
92
+ source?: SettingSource;
93
+ widget?: EnumWidget;
94
+ };
95
+
96
+ export declare type EnumWidget = {
97
+ type: 'select';
98
+ } | {
99
+ type: 'radio';
100
+ };
101
+
102
+ export declare type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
103
+
104
+ export declare class HttpAPI {
105
+ readonly fetch: FetchFunction;
106
+ constructor(host?: HttpHost);
107
+ }
108
+
109
+ export declare type HttpHost = {
110
+ fetch: (url: string, init?: HttpRequestInit) => Promise<HttpResponseData>;
111
+ };
112
+
113
+ export declare type HttpRequestInit = {
114
+ method?: string;
115
+ headers?: Record<string, string>;
116
+ body?: string;
117
+ };
118
+
119
+ export declare type HttpResponseData = {
120
+ status: number;
121
+ headers: Record<string, string>;
122
+ body: string;
123
+ };
124
+
125
+ export declare type LoadedPlugin = {
126
+ metadata: PluginMetadata;
127
+ instance: NuclearPlugin;
128
+ path: string;
129
+ };
130
+
131
+ export declare type LocalFileInfo = {
132
+ fileUri: string;
133
+ fileSize?: number;
134
+ format?: string;
135
+ bitrateKbps?: number;
136
+ sampleRateHz?: number;
137
+ channels?: number;
138
+ fingerprint?: string;
139
+ scannedAtIso?: string;
140
+ };
141
+
142
+ declare class MetadataAPI {
143
+ #private;
144
+ constructor(host?: MetadataHost);
145
+ search(params: SearchParams, providerId?: string): Promise<SearchResults>;
146
+ fetchArtistDetails(artistId: string, providerId?: string): Promise<Artist>;
147
+ fetchArtistAlbums(artistId: string, providerId?: string): Promise<AlbumRef[]>;
148
+ fetchArtistTopTracks(artistId: string, providerId?: string): Promise<TrackRef[]>;
149
+ fetchArtistRelatedArtists(artistId: string, providerId?: string): Promise<ArtistRef[]>;
150
+ fetchAlbumDetails(albumId: string, providerId?: string): Promise<Album>;
151
+ }
152
+
153
+ export declare type MetadataHost = {
154
+ search: (params: SearchParams, providerId?: string) => Promise<SearchResults>;
155
+ fetchArtistDetails: (artistId: string, providerId?: string) => Promise<Artist>;
156
+ fetchArtistAlbums: (artistId: string, providerId?: string) => Promise<AlbumRef[]>;
157
+ fetchArtistTopTracks: (artistId: string, providerId?: string) => Promise<TrackRef[]>;
158
+ fetchArtistRelatedArtists: (artistId: string, providerId?: string) => Promise<ArtistRef[]>;
159
+ fetchAlbumDetails: (albumId: string, providerId?: string) => Promise<Album>;
160
+ };
161
+
162
+ export declare type MetadataProvider = ProviderDescriptor<'metadata'> & {
163
+ searchCapabilities?: SearchCapability[];
164
+ artistMetadataCapabilities?: ArtistMetadataCapability[];
165
+ albumMetadataCapabilities?: AlbumMetadataCapability[];
166
+ search?: (params: SearchParams) => Promise<SearchResults>;
167
+ searchArtists?: (params: Omit<SearchParams, 'types'>) => Promise<ArtistRef[]>;
168
+ searchAlbums?: (params: Omit<SearchParams, 'types'>) => Promise<AlbumRef[]>;
169
+ searchTracks?: (params: Omit<SearchParams, 'types'>) => Promise<Track[]>;
170
+ searchPlaylists?: (params: Omit<SearchParams, 'types'>) => Promise<PlaylistRef[]>;
171
+ fetchArtistDetails?: (query: string) => Promise<Artist>;
172
+ fetchAlbumDetails?: (query: string) => Promise<Album>;
173
+ fetchArtistAlbums?: (artistId: string) => Promise<AlbumRef[]>;
174
+ fetchArtistTopTracks?: (artistId: string) => Promise<TrackRef[]>;
175
+ fetchArtistRelatedArtists?: (artistId: string) => Promise<ArtistRef[]>;
176
+ };
177
+
178
+ export declare class MissingCapabilityError extends Error {
179
+ constructor(capability: string);
180
+ }
181
+
182
+ export declare class NuclearAPI {
183
+ readonly Settings: Settings;
184
+ readonly Providers: Providers;
185
+ readonly Queue: QueueAPI;
186
+ readonly Streaming: StreamingAPI;
187
+ readonly Metadata: MetadataAPI;
188
+ readonly Http: HttpAPI;
189
+ readonly Ytdlp: YtdlpAPI;
190
+ constructor(opts?: {
191
+ settingsHost?: SettingsHost;
192
+ providersHost?: ProvidersHost;
193
+ queueHost?: QueueHost;
194
+ streamingHost?: StreamingHost;
195
+ metadataHost?: MetadataHost;
196
+ httpHost?: HttpHost;
197
+ ytdlpHost?: YtdlpHost;
198
+ });
199
+ }
200
+
201
+ export declare type NuclearPlugin = {
202
+ onLoad?(api: NuclearPluginAPI): void | Promise<void>;
203
+ onUnload?(api: NuclearPluginAPI): void | Promise<void>;
204
+ onEnable?(api: NuclearPluginAPI): void | Promise<void>;
205
+ onDisable?(api: NuclearPluginAPI): void | Promise<void>;
206
+ };
207
+
208
+ export declare class NuclearPluginAPI extends NuclearAPI {
209
+ }
210
+
211
+ export declare type NumberSettingDefinition = {
212
+ id: string;
213
+ title: string;
214
+ description?: string;
215
+ category: SettingCategory;
216
+ kind: 'number';
217
+ default?: number;
218
+ hidden?: boolean;
219
+ source?: SettingSource;
220
+ widget?: NumberWidget;
221
+ min?: number;
222
+ max?: number;
223
+ step?: number;
224
+ unit?: string;
225
+ };
226
+
227
+ export declare type NumberWidget = {
228
+ type: 'slider';
229
+ min?: number;
230
+ max?: number;
231
+ step?: number;
232
+ unit?: string;
233
+ } | {
234
+ type: 'number-input';
235
+ min?: number;
236
+ max?: number;
237
+ step?: number;
238
+ unit?: string;
239
+ };
240
+
241
+ export declare function pickArtwork(set: ArtworkSet | undefined, purpose: ArtworkPurpose, targetPx: number): Artwork | undefined;
242
+
243
+ export declare type Playlist = {
244
+ id: string;
245
+ name: string;
246
+ lastModifiedIso?: string;
247
+ items: PlaylistItem[];
248
+ };
249
+
250
+ export declare type PlaylistItem = {
251
+ id: string;
252
+ title: string;
253
+ artists: ArtistCredit[];
254
+ album?: string;
255
+ durationMs?: number;
256
+ artwork?: ArtworkSet;
257
+ note?: string;
258
+ addedAtIso?: string;
259
+ source: ProviderRef;
260
+ };
261
+
262
+ export declare type PlaylistRef = {
263
+ id: string;
264
+ name: string;
265
+ artwork?: ArtworkSet;
266
+ source: ProviderRef;
267
+ };
268
+
269
+ export declare type PluginIcon = {
270
+ type: 'link';
271
+ link: string;
272
+ };
273
+
274
+ export declare type PluginManifest = {
275
+ name: string;
276
+ version: string;
277
+ description: string;
278
+ author: string;
279
+ main?: string;
280
+ nuclear?: {
281
+ displayName?: string;
282
+ category?: string;
283
+ icon?: PluginIcon;
284
+ permissions?: string[];
285
+ };
286
+ };
287
+
288
+ export declare type PluginMetadata = {
289
+ id: string;
290
+ name: string;
291
+ displayName: string;
292
+ version: string;
293
+ description: string;
294
+ author: string;
295
+ category?: string;
296
+ icon?: PluginIcon;
297
+ permissions: string[];
298
+ };
299
+
300
+ export declare type ProviderDescriptor<K extends ProviderKind = ProviderKind> = {
301
+ id: string;
302
+ kind: K;
303
+ name: string;
304
+ pluginId?: string;
305
+ };
306
+
307
+ export declare type ProviderKind = 'metadata' | 'streaming' | 'lyrics' | (string & {});
308
+
309
+ export declare type ProviderRef = {
310
+ provider: string;
311
+ id: string;
312
+ url?: string;
313
+ };
314
+
315
+ declare class Providers {
316
+ #private;
317
+ constructor(host?: ProvidersHost);
318
+ register<T extends ProviderDescriptor>(p: T): string;
319
+ unregister(id: string): boolean;
320
+ list<K extends ProviderKind = ProviderKind>(kind?: K): ProviderDescriptor<K>[];
321
+ get<T extends ProviderDescriptor>(id: string): T | undefined;
322
+ }
323
+
324
+ export declare type ProvidersHost = {
325
+ register<T extends ProviderDescriptor>(provider: T): string;
326
+ unregister(providerId: string): boolean;
327
+ list<K extends ProviderKind = ProviderKind>(kind?: K): ProviderDescriptor<K>[];
328
+ get<T extends ProviderDescriptor>(providerId: string): T | undefined;
329
+ clear(): void;
330
+ };
331
+
332
+ export declare type Queue = {
333
+ items: QueueItem[];
334
+ currentIndex: number;
335
+ repeatMode: RepeatMode;
336
+ shuffleEnabled: boolean;
337
+ };
338
+
339
+ declare class QueueAPI {
340
+ #private;
341
+ constructor(host?: QueueHost);
342
+ getQueue(): Promise<Queue>;
343
+ getCurrentItem(): Promise<QueueItem | undefined>;
344
+ addToQueue(tracks: Track[]): Promise<void>;
345
+ addNext(tracks: Track[]): Promise<void>;
346
+ addAt(tracks: Track[], index: number): Promise<void>;
347
+ removeByIds(ids: string[]): Promise<void>;
348
+ removeByIndices(indices: number[]): Promise<void>;
349
+ clearQueue(): Promise<void>;
350
+ reorder(fromIndex: number, toIndex: number): Promise<void>;
351
+ updateItemState(id: string, updates: QueueItemStateUpdate): Promise<void>;
352
+ goToNext(): Promise<void>;
353
+ goToPrevious(): Promise<void>;
354
+ goToIndex(index: number): Promise<void>;
355
+ goToId(id: string): Promise<void>;
356
+ setRepeatMode(mode: RepeatMode): Promise<void>;
357
+ setShuffleEnabled(enabled: boolean): Promise<void>;
358
+ subscribe(listener: (queue: Queue) => void): () => void;
359
+ subscribeToCurrentItem(listener: (item: QueueItem | undefined) => void): () => void;
360
+ }
361
+
362
+ export declare type QueueHost = {
363
+ getQueue: () => Promise<Queue>;
364
+ getCurrentItem: () => Promise<QueueItem | undefined>;
365
+ addToQueue: (tracks: Track[]) => Promise<void>;
366
+ addNext: (tracks: Track[]) => Promise<void>;
367
+ addAt: (tracks: Track[], index: number) => Promise<void>;
368
+ removeByIds: (ids: string[]) => Promise<void>;
369
+ removeByIndices: (indices: number[]) => Promise<void>;
370
+ clearQueue: () => Promise<void>;
371
+ reorder: (fromIndex: number, toIndex: number) => Promise<void>;
372
+ updateItemState: (id: string, updates: QueueItemStateUpdate) => Promise<void>;
373
+ goToNext: () => Promise<void>;
374
+ goToPrevious: () => Promise<void>;
375
+ goToIndex: (index: number) => Promise<void>;
376
+ goToId: (id: string) => Promise<void>;
377
+ setRepeatMode: (mode: RepeatMode) => Promise<void>;
378
+ setShuffleEnabled: (enabled: boolean) => Promise<void>;
379
+ subscribe: (listener: QueueListener) => () => void;
380
+ subscribeToCurrentItem: (listener: QueueItemListener) => () => void;
381
+ };
382
+
383
+ export declare type QueueItem = {
384
+ id: string;
385
+ track: Track;
386
+ status: 'idle' | 'loading' | 'success' | 'error';
387
+ error?: string;
388
+ addedAtIso: string;
389
+ };
390
+
391
+ export declare type QueueItemListener = (item: QueueItem | undefined) => void;
392
+
393
+ export declare type QueueItemStateUpdate = Partial<{
394
+ status: QueueItem['status'];
395
+ error: QueueItem['error'];
396
+ }>;
397
+
398
+ export declare type QueueListener = (queue: Queue) => void;
399
+
400
+ export declare type RepeatMode = 'off' | 'all' | 'one';
401
+
402
+ export declare type SearchCapability = SearchCategory | 'unified';
403
+
404
+ export declare type SearchCategory = 'artists' | 'albums' | 'tracks' | 'playlists';
405
+
406
+ export declare type SearchParams = {
407
+ query: string;
408
+ types?: SearchCategory[];
409
+ limit?: number;
410
+ };
411
+
412
+ export declare type SearchResults = {
413
+ artists?: ArtistRef[];
414
+ albums?: AlbumRef[];
415
+ tracks?: Track[];
416
+ playlists?: PlaylistRef[];
417
+ };
418
+
419
+ export declare type SettingCategory = string;
420
+
421
+ export declare type SettingDefinition = BooleanSettingDefinition | NumberSettingDefinition | StringSettingDefinition | EnumSettingDefinition;
422
+
423
+ declare class Settings {
424
+ #private;
425
+ constructor(host?: SettingsHost);
426
+ register(defs: SettingDefinition[]): Promise<SettingsRegistrationResult>;
427
+ get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
428
+ set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
429
+ subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
430
+ }
431
+
432
+ export declare type SettingsHost = {
433
+ register(defs: SettingDefinition[]): Promise<SettingsRegistrationResult>;
434
+ get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
435
+ set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
436
+ subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
437
+ };
438
+
439
+ export declare type SettingSource = {
440
+ type: 'core';
441
+ } | {
442
+ type: 'plugin';
443
+ pluginId: string;
444
+ pluginName?: string;
445
+ };
446
+
447
+ export declare type SettingsRegistration = {
448
+ settings: SettingDefinition[];
449
+ };
450
+
451
+ export declare type SettingsRegistrationResult = {
452
+ registered: string[];
453
+ };
454
+
455
+ export declare type SettingValue = boolean | number | string | undefined;
456
+
457
+ export declare type Stream = {
458
+ url: string;
459
+ protocol: 'file' | 'http' | 'https' | 'hls';
460
+ mimeType?: string;
461
+ bitrateKbps?: number;
462
+ codec?: string;
463
+ container?: string;
464
+ qualityLabel?: string;
465
+ durationMs?: number;
466
+ contentLengthBytes?: number;
467
+ source: ProviderRef;
468
+ };
469
+
470
+ export declare type StreamCandidate = {
471
+ id: string;
472
+ title: string;
473
+ durationMs?: number;
474
+ thumbnail?: string;
475
+ stream?: Stream;
476
+ lastResolvedAtIso?: string;
477
+ failed: boolean;
478
+ source: ProviderRef;
479
+ };
480
+
481
+ declare class StreamingAPI {
482
+ #private;
483
+ constructor(host?: StreamingHost);
484
+ resolveCandidatesForTrack(track: Track): Promise<StreamResolutionResult>;
485
+ resolveStreamForCandidate(candidate: StreamCandidate): Promise<StreamCandidate | undefined>;
486
+ }
487
+
488
+ export declare type StreamingHost = {
489
+ resolveCandidatesForTrack: (track: Track) => Promise<StreamResolutionResult>;
490
+ resolveStreamForCandidate: (candidate: StreamCandidate) => Promise<StreamCandidate | undefined>;
491
+ };
492
+
493
+ export declare type StreamingProvider = ProviderDescriptor<'streaming'> & {
494
+ searchForTrack: (artist: string, title: string, album?: string) => Promise<StreamCandidate[]>;
495
+ getStreamUrl: (candidateId: string) => Promise<Stream>;
496
+ supportsLocalFiles?: boolean;
497
+ };
498
+
499
+ export declare type StreamResolutionResult = {
500
+ success: true;
501
+ candidates: StreamCandidate[];
502
+ } | {
503
+ success: false;
504
+ error: string;
505
+ };
506
+
507
+ export declare type StringFormat = 'text' | 'url' | 'path' | 'token' | 'language';
508
+
509
+ export declare type StringSettingDefinition = {
510
+ id: string;
511
+ title: string;
512
+ description?: string;
513
+ category: SettingCategory;
514
+ kind: 'string';
515
+ default?: string;
516
+ hidden?: boolean;
517
+ source?: SettingSource;
518
+ widget?: StringWidget;
519
+ format?: StringFormat;
520
+ pattern?: string;
521
+ minLength?: number;
522
+ maxLength?: number;
523
+ };
524
+
525
+ export declare type StringWidget = {
526
+ type: 'text';
527
+ placeholder?: string;
528
+ } | {
529
+ type: 'password';
530
+ placeholder?: string;
531
+ } | {
532
+ type: 'textarea';
533
+ placeholder?: string;
534
+ rows?: number;
535
+ };
536
+
537
+ export declare type Track = {
538
+ title: string;
539
+ artists: ArtistCredit[];
540
+ album?: AlbumRef;
541
+ durationMs?: number;
542
+ trackNumber?: number;
543
+ disc?: string;
544
+ artwork?: ArtworkSet;
545
+ tags?: string[];
546
+ source: ProviderRef;
547
+ localFile?: LocalFileInfo;
548
+ streamCandidates?: StreamCandidate[];
549
+ };
550
+
551
+ export declare type TrackRef = {
552
+ title: string;
553
+ artists: ArtistRef[];
554
+ artwork?: ArtworkSet;
555
+ source: ProviderRef;
556
+ };
557
+
558
+ export declare const useSetting: <T extends SettingValue = SettingValue>(host: SettingsHost | undefined, id: string) => readonly [T | undefined, (nextValue: T) => void];
559
+
560
+ export declare class YtdlpAPI {
561
+ private host?;
562
+ constructor(host?: YtdlpHost);
563
+ get available(): boolean;
564
+ search(query: string, maxResults?: number): Promise<YtdlpSearchResult[]>;
565
+ getStream(videoId: string): Promise<YtdlpStreamInfo>;
566
+ }
567
+
568
+ export declare type YtdlpHost = {
569
+ search: (query: string, maxResults?: number) => Promise<YtdlpSearchResult[]>;
570
+ getStream: (videoId: string) => Promise<YtdlpStreamInfo>;
571
+ };
572
+
573
+ export declare type YtdlpSearchResult = {
574
+ id: string;
575
+ title: string;
576
+ duration: number | null;
577
+ thumbnail: string | null;
578
+ };
579
+
580
+ export declare type YtdlpStreamInfo = {
581
+ stream_url: string;
582
+ duration: number | null;
583
+ title: string | null;
584
+ };
585
+
586
+ export { }
package/dist/index.js CHANGED
@@ -1,5 +1,72 @@
1
- import { useState as g, useEffect as f, useMemo as b } from "react";
1
+ import { useState as l, useEffect as f, useMemo as g } from "react";
2
+ const b = (s) => {
3
+ if (s instanceof Headers) {
4
+ const t = {};
5
+ return s.forEach((e, r) => {
6
+ t[r] = e;
7
+ }), t;
8
+ }
9
+ return Array.isArray(s) ? Object.fromEntries(s) : s;
10
+ };
11
+ function m(s) {
12
+ return async (t, e) => {
13
+ 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, {
14
+ method: e?.method,
15
+ headers: a,
16
+ body: o
17
+ });
18
+ return new Response(u.body, {
19
+ status: u.status,
20
+ headers: new Headers(u.headers)
21
+ });
22
+ };
23
+ }
24
+ const A = {
25
+ fetch: async () => ({
26
+ status: 501,
27
+ headers: {},
28
+ body: "HTTP host not configured"
29
+ })
30
+ };
2
31
  class p {
32
+ fetch;
33
+ constructor(t) {
34
+ this.fetch = m(t ?? A);
35
+ }
36
+ }
37
+ class v {
38
+ #e;
39
+ constructor(t) {
40
+ this.#e = t;
41
+ }
42
+ #t(t) {
43
+ const e = this.#e;
44
+ if (!e)
45
+ throw new Error("Metadata host not available");
46
+ return t(e);
47
+ }
48
+ search(t, e) {
49
+ return this.#t((r) => r.search(t, e));
50
+ }
51
+ fetchArtistDetails(t, e) {
52
+ return this.#t((r) => r.fetchArtistDetails(t, e));
53
+ }
54
+ fetchArtistAlbums(t, e) {
55
+ return this.#t((r) => r.fetchArtistAlbums(t, e));
56
+ }
57
+ fetchArtistTopTracks(t, e) {
58
+ return this.#t((r) => r.fetchArtistTopTracks(t, e));
59
+ }
60
+ fetchArtistRelatedArtists(t, e) {
61
+ return this.#t(
62
+ (r) => r.fetchArtistRelatedArtists(t, e)
63
+ );
64
+ }
65
+ fetchAlbumDetails(t, e) {
66
+ return this.#t((r) => r.fetchAlbumDetails(t, e));
67
+ }
68
+ }
69
+ class w {
3
70
  #e;
4
71
  constructor(t) {
5
72
  this.#e = t;
@@ -23,7 +90,73 @@ class p {
23
90
  return this.#t((e) => e.get(t));
24
91
  }
25
92
  }
26
- class d {
93
+ class I {
94
+ #e;
95
+ constructor(t) {
96
+ this.#e = t;
97
+ }
98
+ #t(t) {
99
+ const e = this.#e;
100
+ if (!e)
101
+ throw new Error("Queue host not available");
102
+ return t(e);
103
+ }
104
+ getQueue() {
105
+ return this.#t((t) => t.getQueue());
106
+ }
107
+ getCurrentItem() {
108
+ return this.#t((t) => t.getCurrentItem());
109
+ }
110
+ addToQueue(t) {
111
+ return this.#t((e) => e.addToQueue(t));
112
+ }
113
+ addNext(t) {
114
+ return this.#t((e) => e.addNext(t));
115
+ }
116
+ addAt(t, e) {
117
+ return this.#t((r) => r.addAt(t, e));
118
+ }
119
+ removeByIds(t) {
120
+ return this.#t((e) => e.removeByIds(t));
121
+ }
122
+ removeByIndices(t) {
123
+ return this.#t((e) => e.removeByIndices(t));
124
+ }
125
+ clearQueue() {
126
+ return this.#t((t) => t.clearQueue());
127
+ }
128
+ reorder(t, e) {
129
+ return this.#t((r) => r.reorder(t, e));
130
+ }
131
+ updateItemState(t, e) {
132
+ return this.#t((r) => r.updateItemState(t, e));
133
+ }
134
+ goToNext() {
135
+ return this.#t((t) => t.goToNext());
136
+ }
137
+ goToPrevious() {
138
+ return this.#t((t) => t.goToPrevious());
139
+ }
140
+ goToIndex(t) {
141
+ return this.#t((e) => e.goToIndex(t));
142
+ }
143
+ goToId(t) {
144
+ return this.#t((e) => e.goToId(t));
145
+ }
146
+ setRepeatMode(t) {
147
+ return this.#t((e) => e.setRepeatMode(t));
148
+ }
149
+ setShuffleEnabled(t) {
150
+ return this.#t((e) => e.setShuffleEnabled(t));
151
+ }
152
+ subscribe(t) {
153
+ return this.#t((e) => e.subscribe(t));
154
+ }
155
+ subscribeToCurrentItem(t) {
156
+ return this.#t((e) => e.subscribeToCurrentItem(t));
157
+ }
158
+ }
159
+ class T {
27
160
  #e;
28
161
  constructor(t) {
29
162
  this.#e = t;
@@ -34,64 +167,107 @@ class d {
34
167
  throw new Error("Settings host not available");
35
168
  return t(e);
36
169
  }
37
- register(t, e) {
38
- return this.#t((i) => i.register(t, e));
170
+ register(t) {
171
+ return this.#t((e) => e.register(t));
39
172
  }
40
173
  get(t) {
41
174
  return this.#t((e) => e.get(t));
42
175
  }
43
176
  set(t, e) {
44
- return this.#t((i) => i.set(t, e));
177
+ return this.#t((r) => r.set(t, e));
45
178
  }
46
179
  subscribe(t, e) {
47
- return this.#t((i) => i.subscribe(t, e));
180
+ return this.#t((r) => r.subscribe(t, e));
48
181
  }
49
182
  }
50
- class v {
183
+ class y {
184
+ #e;
185
+ constructor(t) {
186
+ this.#e = t;
187
+ }
188
+ #t(t) {
189
+ const e = this.#e;
190
+ if (!e)
191
+ throw new Error("Streaming host not available");
192
+ return t(e);
193
+ }
194
+ resolveCandidatesForTrack(t) {
195
+ return this.#t((e) => e.resolveCandidatesForTrack(t));
196
+ }
197
+ resolveStreamForCandidate(t) {
198
+ return this.#t((e) => e.resolveStreamForCandidate(t));
199
+ }
200
+ }
201
+ class H {
202
+ host;
203
+ constructor(t) {
204
+ this.host = t;
205
+ }
206
+ get available() {
207
+ return !!this.host;
208
+ }
209
+ async search(t, e) {
210
+ if (!this.host)
211
+ throw new Error("YtdlpAPI: No host configured");
212
+ return this.host.search(t, e);
213
+ }
214
+ async getStream(t) {
215
+ if (!this.host)
216
+ throw new Error("YtdlpAPI: No host configured");
217
+ return this.host.getStream(t);
218
+ }
219
+ }
220
+ class S {
51
221
  Settings;
52
222
  Providers;
223
+ Queue;
224
+ Streaming;
225
+ Metadata;
226
+ Http;
227
+ Ytdlp;
228
+ // All these are optional so we don't have to provide all of them in tests
53
229
  constructor(t) {
54
- this.Settings = new d(t?.settingsHost), this.Providers = new p(t?.providersHost);
230
+ 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);
55
231
  }
56
232
  }
57
- class w extends v {
233
+ class P extends S {
58
234
  }
59
235
  class M extends Error {
60
236
  constructor(t) {
61
237
  super(`Missing capability: ${t}`), this.name = "MissingCapabilityError";
62
238
  }
63
239
  }
64
- const A = (s, t) => {
65
- const [e, i] = g(void 0);
240
+ const C = (s, t) => {
241
+ const [e, r] = l(void 0);
66
242
  f(() => {
67
243
  if (!s)
68
244
  return;
69
- let u = !0, c = !1;
70
- const r = s.subscribe(t, (n) => {
71
- u && (c = !0, i(n));
245
+ let o = !0, u = !1;
246
+ const i = s.subscribe(t, (n) => {
247
+ o && (u = !0, r(n));
72
248
  });
73
249
  return s.get(t).then((n) => {
74
- u && (c || i(n));
250
+ o && (u || r(n));
75
251
  }), () => {
76
- u = !1, r && r();
252
+ o = !1, i && i();
77
253
  };
78
254
  }, [t, s]);
79
- const o = b(
80
- () => (u) => {
81
- s && s.set(t, u);
255
+ const a = g(
256
+ () => (o) => {
257
+ s && s.set(t, o);
82
258
  },
83
259
  [t, s]
84
260
  );
85
- return [e, o];
261
+ return [e, a];
86
262
  };
87
- function E(s, t, e) {
263
+ function R(s, t, e) {
88
264
  if (!s?.items?.length)
89
265
  return;
90
- const i = s.items.filter((r) => !(r.purpose && r.purpose !== t || !r.url));
91
- if (!i.length)
266
+ const r = s.items.filter((i) => !(i.purpose && i.purpose !== t || !i.url));
267
+ if (!r.length)
92
268
  return s.items[0];
93
- const o = (r) => !r.width || !r.height ? 1 : r.width / r.height, c = ((r) => {
94
- switch (r) {
269
+ const a = (i) => !i.width || !i.height ? 1 : i.width / i.height, u = ((i) => {
270
+ switch (i) {
95
271
  case "avatar":
96
272
  case "thumbnail":
97
273
  return 1;
@@ -103,18 +279,20 @@ function E(s, t, e) {
103
279
  return 1;
104
280
  }
105
281
  })(t);
106
- return i.map((r) => {
107
- const n = Math.min(r.width || 0, r.height || 0), a = Math.abs(o(r) - c), h = Math.abs(n - e), l = n < e ? e / n : 1;
282
+ return r.map((i) => {
283
+ 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;
108
284
  return {
109
- artwork: r,
110
- score: (l > 1.5 ? -1e3 : 0) + -a * 50 + -h * 0.1
285
+ artwork: i,
286
+ score: (d > 1.5 ? -1e3 : 0) + -h * 50 + -c * 0.1
111
287
  };
112
- }).sort((r, n) => n.score - r.score)[0]?.artwork;
288
+ }).sort((i, n) => n.score - i.score)[0]?.artwork;
113
289
  }
114
290
  export {
291
+ p as HttpAPI,
115
292
  M as MissingCapabilityError,
116
- v as NuclearAPI,
117
- w as NuclearPluginAPI,
118
- E as pickArtwork,
119
- A as useSetting
293
+ S as NuclearAPI,
294
+ P as NuclearPluginAPI,
295
+ H as YtdlpAPI,
296
+ R as pickArtwork,
297
+ C as useSetting
120
298
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuclearplayer/plugin-sdk",
3
- "version": "0.0.11",
3
+ "version": "1.0.0",
4
4
  "description": "Plugin SDK for Nuclear music player",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,6 +24,7 @@
24
24
  "tailwind-merge": "^3.3.1"
25
25
  },
26
26
  "devDependencies": {
27
+ "@microsoft/api-extractor": "^7.51.1",
27
28
  "@tailwindcss/vite": "^4.1.11",
28
29
  "@testing-library/jest-dom": "^6.6.4",
29
30
  "@testing-library/react": "^16.3.0",
@@ -37,8 +38,8 @@
37
38
  "vite": "^7.1.3",
38
39
  "vite-plugin-dts": "^4.5.4",
39
40
  "vitest": "^3.2.4",
40
- "@nuclearplayer/eslint-config": "0.0.9",
41
- "@nuclearplayer/tailwind-config": "0.0.9"
41
+ "@nuclearplayer/tailwind-config": "0.0.10",
42
+ "@nuclearplayer/eslint-config": "0.0.10"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "react": "^18.3.1"
@@ -67,8 +68,9 @@
67
68
  },
68
69
  "scripts": {
69
70
  "dev": "vite",
70
- "build": "tsc && vite build",
71
- "build:npm": "vite build --mode npm",
71
+ "build": "tsc && vite build && api-extractor run --local && pnpm clean:dts",
72
+ "build:npm": "tsc && vite build --mode npm && api-extractor run --local && pnpm clean:dts",
73
+ "clean:dts": "rm -rf dist/api dist/react dist/test dist/types dist/types.d.ts dist/*.d.ts.map dist/tsdoc-metadata.json",
72
74
  "test": "vitest --run",
73
75
  "test:watch": "vitest",
74
76
  "test:coverage": "vitest --run --coverage",
@@ -1,15 +0,0 @@
1
- import { ProvidersHost } from '../types/providers';
2
- import { SettingsHost } from '../types/settings';
3
- import { Providers } from './providers';
4
- import { Settings } from './settings';
5
- export declare class NuclearAPI {
6
- readonly Settings: Settings;
7
- readonly Providers: Providers;
8
- constructor(opts?: {
9
- settingsHost?: SettingsHost;
10
- providersHost?: ProvidersHost;
11
- });
12
- }
13
- export declare class NuclearPluginAPI extends NuclearAPI {
14
- }
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,UAAU;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;gBAElB,IAAI,CAAC,EAAE;QACjB,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;KAC/B;CAIF;AAED,qBAAa,gBAAiB,SAAQ,UAAU;CAAG"}
@@ -1,11 +0,0 @@
1
- import { ProvidersHost } from '../types/providers';
2
- import { ProviderDescriptor, ProviderKind } from '../types/search';
3
- export declare class Providers {
4
- #private;
5
- constructor(host?: ProvidersHost);
6
- register<T extends ProviderDescriptor>(p: T): string;
7
- unregister(id: string): boolean;
8
- list<K extends ProviderKind = ProviderKind>(kind?: K): ProviderDescriptor<K>[];
9
- get<T extends ProviderDescriptor>(id: string): T | undefined;
10
- }
11
- //# sourceMappingURL=providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/api/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAExE,qBAAa,SAAS;;gBAGR,IAAI,CAAC,EAAE,aAAa;IAYhC,QAAQ,CAAC,CAAC,SAAS,kBAAkB,EAAE,CAAC,EAAE,CAAC;IAI3C,UAAU,CAAC,EAAE,EAAE,MAAM;IAIrB,IAAI,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC;IAIpD,GAAG,CAAC,CAAC,SAAS,kBAAkB,EAAE,EAAE,EAAE,MAAM;CAG7C"}
@@ -1,10 +0,0 @@
1
- import { SettingDefinition, SettingsHost, SettingSource, SettingValue } from '../types/settings';
2
- export declare class Settings {
3
- #private;
4
- constructor(host?: SettingsHost);
5
- register(defs: SettingDefinition[], source: SettingSource): Promise<import('..').SettingsRegistrationResult>;
6
- get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
7
- set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
8
- subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
9
- }
10
- //# sourceMappingURL=settings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/api/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,QAAQ;;gBAGP,IAAI,CAAC,EAAE,YAAY;IAY/B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,aAAa;IAIzD,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAAE,EAAE,MAAM;IAIrD,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAI/D,SAAS,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAC7C,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI;CAI3C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACrD,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,cAAc,sBAAsB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { SettingsHost, SettingValue } from '../types/settings';
2
- export declare const useSetting: <T extends SettingValue = SettingValue>(host: SettingsHost | undefined, id: string) => readonly [T | undefined, (nextValue: T) => void];
3
- //# sourceMappingURL=useSetting.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSetting.d.ts","sourceRoot":"","sources":["../../src/react/useSetting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,YAAY,GAAG,YAAY,EAC9D,MAAM,YAAY,GAAG,SAAS,EAC9B,IAAI,MAAM,0CAkCU,CAAC,UAUtB,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
@@ -1,16 +0,0 @@
1
- import { SettingDefinition, SettingsHost, SettingSource, SettingValue } from '../../types/settings';
2
- export declare class InMemorySettingsHost implements SettingsHost {
3
- private definitions;
4
- private values;
5
- private listeners;
6
- private readonly source;
7
- constructor(source: SettingSource);
8
- private fullyQualified;
9
- register(definitions: SettingDefinition[], _source: SettingSource): Promise<{
10
- registered: string[];
11
- }>;
12
- get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
13
- set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
14
- subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
15
- }
16
- //# sourceMappingURL=inMemorySettingsHost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inMemorySettingsHost.d.ts","sourceRoot":"","sources":["../../../src/test/utils/inMemorySettingsHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,SAAS,CAGb;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,MAAM,EAAE,aAAa;IAIjC,OAAO,CAAC,cAAc;IAOhB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,aAAa;;;IAsBjE,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAAE,EAAE,MAAM;IAKrD,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAWrE,SAAS,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAC7C,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI;CAmB3C"}
@@ -1,9 +0,0 @@
1
- import { ProviderDescriptor, ProviderKind } from './search';
2
- export type ProvidersHost = {
3
- register<T extends ProviderDescriptor>(provider: T): string;
4
- unregister(providerId: string): boolean;
5
- list<K extends ProviderKind = ProviderKind>(kind?: K): ProviderDescriptor<K>[];
6
- get<T extends ProviderDescriptor>(providerId: string): T | undefined;
7
- clear(): void;
8
- };
9
- //# sourceMappingURL=providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEjE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,CAAC,SAAS,kBAAkB,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC;IAC5D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC,IAAI,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EACxC,IAAI,CAAC,EAAE,CAAC,GACP,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,SAAS,kBAAkB,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IACrE,KAAK,IAAI,IAAI,CAAC;CACf,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Album, AlbumRef, Artist, ArtistRef, PlaylistRef, Track, TrackRef } from '@nuclearplayer/model';
2
- export type SearchCategory = 'artists' | 'albums' | 'tracks' | 'playlists';
3
- export type SearchCapability = SearchCategory | 'unified';
4
- export type ArtistMetadataCapability = 'artistDetails' | 'artistAlbums' | 'artistTopTracks' | 'artistRelatedArtists';
5
- export type SearchParams = {
6
- query: string;
7
- types?: SearchCategory[];
8
- limit?: number;
9
- };
10
- export type SearchResults = {
11
- artists?: ArtistRef[];
12
- albums?: AlbumRef[];
13
- tracks?: Track[];
14
- playlists?: PlaylistRef[];
15
- };
16
- export type ProviderKind = 'metadata' | 'streaming' | 'lyrics' | (string & {});
17
- export type ProviderDescriptor<K extends ProviderKind = ProviderKind> = {
18
- id: string;
19
- kind: K;
20
- name: string;
21
- pluginId?: string;
22
- };
23
- export type MetadataProvider = ProviderDescriptor<'metadata'> & {
24
- searchCapabilities?: SearchCapability[];
25
- artistMetadataCapabilities?: ArtistMetadataCapability[];
26
- search?: (params: SearchParams) => Promise<SearchResults>;
27
- searchArtists?: (params: Omit<SearchParams, 'types'>) => Promise<ArtistRef[]>;
28
- searchAlbums?: (params: Omit<SearchParams, 'types'>) => Promise<AlbumRef[]>;
29
- searchTracks?: (params: Omit<SearchParams, 'types'>) => Promise<Track[]>;
30
- searchPlaylists?: (params: Omit<SearchParams, 'types'>) => Promise<PlaylistRef[]>;
31
- fetchArtistDetails?: (query: string) => Promise<Artist>;
32
- fetchAlbumDetails?: (query: string) => Promise<Album>;
33
- fetchArtistAlbums?: (artistId: string) => Promise<AlbumRef[]>;
34
- fetchArtistTopTracks?: (artistId: string) => Promise<TrackRef[]>;
35
- fetchArtistRelatedArtists?: (artistId: string) => Promise<ArtistRef[]>;
36
- };
37
- export declare class MissingCapabilityError extends Error {
38
- constructor(capability: string);
39
- }
40
- //# sourceMappingURL=search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/types/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,KAAK,EACL,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC3E,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,SAAS,CAAC;AAE1D,MAAM,MAAM,wBAAwB,GAChC,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE/E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAA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1,113 +0,0 @@
1
- export type SettingSource = {
2
- type: 'core';
3
- } | {
4
- type: 'plugin';
5
- pluginId: string;
6
- pluginName?: string;
7
- };
8
- export type SettingCategory = string;
9
- export type BooleanWidget = {
10
- type: 'toggle';
11
- };
12
- export type NumberWidget = {
13
- type: 'slider';
14
- min?: number;
15
- max?: number;
16
- step?: number;
17
- unit?: string;
18
- } | {
19
- type: 'number-input';
20
- min?: number;
21
- max?: number;
22
- step?: number;
23
- unit?: string;
24
- };
25
- export type StringWidget = {
26
- type: 'text';
27
- placeholder?: string;
28
- } | {
29
- type: 'password';
30
- placeholder?: string;
31
- } | {
32
- type: 'textarea';
33
- placeholder?: string;
34
- rows?: number;
35
- };
36
- export type EnumWidget = {
37
- type: 'select';
38
- } | {
39
- type: 'radio';
40
- };
41
- export type BooleanSettingDefinition = {
42
- id: string;
43
- title: string;
44
- description?: string;
45
- category: SettingCategory;
46
- kind: 'boolean';
47
- default?: boolean;
48
- hidden?: boolean;
49
- source?: SettingSource;
50
- widget?: BooleanWidget;
51
- };
52
- export type NumberSettingDefinition = {
53
- id: string;
54
- title: string;
55
- description?: string;
56
- category: SettingCategory;
57
- kind: 'number';
58
- default?: number;
59
- hidden?: boolean;
60
- source?: SettingSource;
61
- widget?: NumberWidget;
62
- min?: number;
63
- max?: number;
64
- step?: number;
65
- unit?: string;
66
- };
67
- export type StringFormat = 'text' | 'url' | 'path' | 'token' | 'language';
68
- export type StringSettingDefinition = {
69
- id: string;
70
- title: string;
71
- description?: string;
72
- category: SettingCategory;
73
- kind: 'string';
74
- default?: string;
75
- hidden?: boolean;
76
- source?: SettingSource;
77
- widget?: StringWidget;
78
- format?: StringFormat;
79
- pattern?: string;
80
- minLength?: number;
81
- maxLength?: number;
82
- };
83
- export type EnumOption = {
84
- value: string;
85
- label: string;
86
- };
87
- export type EnumSettingDefinition = {
88
- id: string;
89
- title: string;
90
- description?: string;
91
- category: SettingCategory;
92
- kind: 'enum';
93
- options: EnumOption[];
94
- default?: string;
95
- hidden?: boolean;
96
- source?: SettingSource;
97
- widget?: EnumWidget;
98
- };
99
- export type SettingDefinition = BooleanSettingDefinition | NumberSettingDefinition | StringSettingDefinition | EnumSettingDefinition;
100
- export type SettingValue = boolean | number | string | undefined;
101
- export type SettingsRegistration = {
102
- settings: SettingDefinition[];
103
- };
104
- export type SettingsRegistrationResult = {
105
- registered: string[];
106
- };
107
- export type SettingsHost = {
108
- register(defs: SettingDefinition[], source: SettingSource): Promise<SettingsRegistrationResult>;
109
- get<T extends SettingValue = SettingValue>(id: string): Promise<T | undefined>;
110
- set<T extends SettingValue = SettingValue>(id: string, value: T): Promise<void>;
111
- subscribe<T extends SettingValue = SettingValue>(id: string, listener: (value: T | undefined) => void): () => void;
112
- };
113
- //# sourceMappingURL=settings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/types/settings.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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M,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CACN,IAAI,EAAE,iBAAiB,EAAE,EACzB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACvC,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EACvC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1B,GAAG,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EACvC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,CAAC,GACP,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,SAAS,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAC7C,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GACvC,MAAM,IAAI,CAAC;CACf,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { NuclearPluginAPI } from './api';
2
- export type PluginIcon = {
3
- type: 'link';
4
- link: string;
5
- };
6
- export type PluginManifest = {
7
- name: string;
8
- version: string;
9
- description: string;
10
- author: string;
11
- main?: string;
12
- nuclear?: {
13
- displayName?: string;
14
- category?: string;
15
- icon?: PluginIcon;
16
- permissions?: string[];
17
- };
18
- };
19
- export type NuclearPlugin = {
20
- onLoad?(api: NuclearPluginAPI): void | Promise<void>;
21
- onUnload?(): void | Promise<void>;
22
- onEnable?(api: NuclearPluginAPI): void | Promise<void>;
23
- onDisable?(): void | Promise<void>;
24
- };
25
- export type PluginMetadata = {
26
- id: string;
27
- name: string;
28
- displayName: string;
29
- version: string;
30
- description: string;
31
- author: string;
32
- category?: string;
33
- icon?: PluginIcon;
34
- permissions: string[];
35
- };
36
- export type LoadedPlugin = {
37
- metadata: PluginMetadata;
38
- instance: NuclearPlugin;
39
- path: string;
40
- };
41
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,UAAU,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,QAAQ,CAAC,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,M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