@discord-player/plugin-host 8.0.0-dev.1 → 8.0.0-dev.3
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 +92 -28
- package/dist/compat/base-extractor.d.ts +6 -0
- package/dist/compat/base-extractor.js.map +1 -1
- package/dist/compat/extractor-execution-context.js.map +1 -1
- package/dist/compat/extractor-plugin.js +107 -75
- package/dist/compat/extractor-plugin.js.map +1 -1
- package/dist/compat/utils.js.map +1 -1
- package/dist/errors.d.ts +15 -2
- package/dist/errors.js +17 -2
- package/dist/errors.js.map +1 -1
- package/dist/host.js +81 -20
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-player.d.ts +1 -1
- package/dist/lyrics.d.ts +56 -0
- package/dist/lyrics.js +110 -0
- package/dist/lyrics.js.map +1 -0
- package/dist/media.js.map +1 -1
- package/dist/plugins/execution-options.d.ts +4 -0
- package/dist/plugins/operation-dispatch.js +43 -6
- package/dist/plugins/operation-dispatch.js.map +1 -1
- package/dist/plugins/plugin-error.js.map +1 -1
- package/dist/plugins/registry-internals.d.ts +5 -3
- package/dist/plugins/registry.d.ts +103 -5
- package/dist/plugins/registry.js +403 -24
- package/dist/plugins/registry.js.map +1 -1
- package/dist/plugins/stream-resolver.js +39 -3
- package/dist/plugins/stream-resolver.js.map +1 -1
- package/dist/plugins/types.d.ts +62 -25
- package/dist/plugins/types.js.map +1 -1
- package/dist/protocol.d.ts +35 -0
- package/dist/protocol.js.map +1 -1
- package/dist/providers/lrclib.d.ts +120 -0
- package/dist/providers/lrclib.js +183 -0
- package/dist/providers/lrclib.js.map +1 -0
- package/dist/remote.d.ts +29 -0
- package/dist/remote.js +142 -0
- package/dist/remote.js.map +1 -0
- package/dist/runtime.d.ts +0 -8
- package/dist/runtime.js +55 -44
- package/dist/runtime.js.map +1 -1
- package/dist/structures/search-result.js.map +1 -1
- package/dist/structures/track-types.d.ts +7 -3
- package/dist/structures/track.d.ts +4 -11
- package/dist/structures/track.js +8 -10
- package/dist/structures/track.js.map +1 -1
- package/dist/types.d.ts +2 -4
- package/dist/utils/legacy-serialization-schemas.d.ts +10 -0
- package/dist/utils/serialization-schemas.d.ts +15 -0
- package/dist/utils/serialization-schemas.js +1 -0
- package/dist/utils/serialization-schemas.js.map +1 -1
- package/dist/utils/serialization.js.map +1 -1
- package/docs/remedia-contract.md +9 -8
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DispatchPolicy, HandlerOptions, OperationInput, OperationContext, OperationName, OperationResult, PluginRegistration,
|
|
1
|
+
import type { DispatchPolicy, HandlerOptions, OperationInput, OperationContext, OperationName, OperationResult, PluginRegistration, PluginContext } from './types.js';
|
|
2
2
|
import type { ExecuteOptions } from './execution-options.js';
|
|
3
3
|
/** Internal registration ownership record. */
|
|
4
4
|
export type Entry = {
|
|
@@ -7,11 +7,13 @@ export type Entry = {
|
|
|
7
7
|
/** Registration-local declaration and options. */
|
|
8
8
|
registration: PluginRegistration<any>;
|
|
9
9
|
/** Registration-local setup context. */
|
|
10
|
-
context:
|
|
10
|
+
context: PluginContext<any>;
|
|
11
11
|
/** Registration lifetime cancellation. */
|
|
12
12
|
controller: AbortController;
|
|
13
13
|
/** Owned cleanup callbacks in registration order. */
|
|
14
14
|
cleanups: Array<() => void | Promise<void>>;
|
|
15
|
+
/** Subscriptions owned by this registration, including dynamic additions. */
|
|
16
|
+
handlers: Set<Handler>;
|
|
15
17
|
/** Handler promises that teardown must drain. */
|
|
16
18
|
pending: Set<Promise<unknown>>;
|
|
17
19
|
/** Setup completion, including failed-setup cleanup. */
|
|
@@ -48,7 +50,7 @@ export type OperationRunner = <K extends OperationName>(operation: K, input: Ope
|
|
|
48
50
|
/** Host state read by operation dispatch. */
|
|
49
51
|
export interface DispatchState {
|
|
50
52
|
/** Subscriptions visible to the current dispatch. */
|
|
51
|
-
handlers: Handler[]
|
|
53
|
+
handlers: ReadonlyMap<OperationName, readonly Handler[]>;
|
|
52
54
|
/** Operation dispatch policies. */
|
|
53
55
|
definitions: Map<OperationName, DispatchPolicy>;
|
|
54
56
|
/** Owning Player's disabled provider IDs. */
|
|
@@ -1,20 +1,47 @@
|
|
|
1
|
+
import { type SerializedEntityUnion } from '../utils/serde.js';
|
|
2
|
+
import type { Playlist } from '../structures/playlist.js';
|
|
3
|
+
import { type RemotePluginHostOptions } from '../remote.js';
|
|
1
4
|
import type { MediaSource } from '@remedia/client';
|
|
2
5
|
import type { Track } from '../structures/track.js';
|
|
3
6
|
import type { ExecuteOptions, StreamResolutionOptions } from './execution-options.js';
|
|
4
|
-
import type { OperationInput, OperationName, OperationResult, PluginRegistration,
|
|
7
|
+
import type { OperationInput, OperationName, OperationResult, PluginRegistration, ProviderReference, OperationMap, ProviderMap } from './types.js';
|
|
5
8
|
import type { LegacyPlayerContext } from '../legacy-player.js';
|
|
6
9
|
export { PluginError } from './plugin-error.js';
|
|
7
10
|
export type { ExecuteOptions, StreamResolutionOptions } from './execution-options.js';
|
|
8
|
-
/** Context-owned
|
|
11
|
+
/** Context-owned capability registry. Removal aborts and drains calls before teardown. */
|
|
9
12
|
export declare class PluginRegistry {
|
|
10
13
|
readonly player: LegacyPlayerContext;
|
|
11
14
|
private readonly blocked;
|
|
12
15
|
private readonly hostId?;
|
|
16
|
+
private providerNames;
|
|
17
|
+
private sealedProviders;
|
|
18
|
+
private providersIndex;
|
|
19
|
+
/** Enable a local singleton capability before setup. Source hosts do not enable playback providers.
|
|
20
|
+
* @param name Provider capability name.
|
|
21
|
+
*/
|
|
22
|
+
defineProvider<K extends keyof ProviderMap>(name: K): void;
|
|
23
|
+
/** Read the selected provider registration lifetime.
|
|
24
|
+
* @param name Provider capability name.
|
|
25
|
+
* @returns Registration cancellation signal, absent for the default implementation.
|
|
26
|
+
*/
|
|
27
|
+
providerSignal<K extends keyof ProviderMap>(name: K): AbortSignal | undefined;
|
|
28
|
+
/** Select and seal a provider before resource initialization. Later replacement registrations fail.
|
|
29
|
+
* @param name Provider capability name.
|
|
30
|
+
* @param dispose Release owned framework resources before plugin teardown.
|
|
31
|
+
* @returns The active implementation, or undefined for the framework default.
|
|
32
|
+
*/
|
|
33
|
+
selectProvider<K extends keyof ProviderMap>(name: K, dispose: () => Promise<void>): ProviderMap[K] | undefined;
|
|
34
|
+
private advertisements;
|
|
13
35
|
private entries;
|
|
14
36
|
private handlers;
|
|
37
|
+
private synchronous;
|
|
38
|
+
private dispatching;
|
|
39
|
+
private calls;
|
|
40
|
+
private initializing;
|
|
15
41
|
private order;
|
|
16
42
|
private resultOwners;
|
|
17
43
|
private destroyed;
|
|
44
|
+
private readonly lifetime;
|
|
18
45
|
/** Create an independent host.
|
|
19
46
|
* @param player Structural source context.
|
|
20
47
|
* @param blocked Default disabled source IDs supplied by the owning Player.
|
|
@@ -25,17 +52,61 @@ export declare class PluginRegistry {
|
|
|
25
52
|
/** Define a declaration-merged operation before registering handlers.
|
|
26
53
|
* @param name Operation name.
|
|
27
54
|
* @param policy Dispatch policy matching its contract.
|
|
55
|
+
* @param synchronous Whether callbacks must complete before returning; required for interception.
|
|
28
56
|
*/
|
|
29
|
-
defineOperation<K extends OperationName>(name: K, policy:
|
|
57
|
+
defineOperation<K extends OperationName>(name: K, policy: OperationMap[K]['policy'], synchronous?: boolean): void;
|
|
30
58
|
/** Whether an ID is reserved or active.
|
|
31
59
|
* @param id Plugin ID.
|
|
60
|
+
* @param hostId Optional deployment constraint.
|
|
61
|
+
*/
|
|
62
|
+
has(id: string, hostId?: string): boolean;
|
|
63
|
+
/** List active provider/deployment references in priority and registration order.
|
|
64
|
+
* @param operation Capability to inspect.
|
|
65
|
+
* @returns Unique eligible provider/deployment references.
|
|
66
|
+
*/
|
|
67
|
+
providers(operation: OperationName): ProviderReference[];
|
|
68
|
+
/** Check whether a deployment has an owned registration.
|
|
69
|
+
* @param hostId Deployment identity.
|
|
70
|
+
*/
|
|
71
|
+
hasHost(hostId: string): boolean;
|
|
72
|
+
/** Advertise only active local operation handlers and supplied provider capabilities.
|
|
73
|
+
* @returns Serializable provider capability descriptions.
|
|
32
74
|
*/
|
|
33
|
-
|
|
75
|
+
describe(): {
|
|
76
|
+
id: string;
|
|
77
|
+
provides: never[];
|
|
78
|
+
operations: (keyof OperationMap)[];
|
|
79
|
+
protocols: string[];
|
|
80
|
+
priorities: {
|
|
81
|
+
[k: string]: number;
|
|
82
|
+
};
|
|
83
|
+
subscriptions: {
|
|
84
|
+
operation: keyof OperationMap;
|
|
85
|
+
priority: number;
|
|
86
|
+
guildIds: readonly string[] | undefined;
|
|
87
|
+
order: number;
|
|
88
|
+
}[];
|
|
89
|
+
}[];
|
|
90
|
+
/** Register all advertised providers from an existing HTTP deployment.
|
|
91
|
+
* @param host Existing deployment and authentication.
|
|
92
|
+
* @param signal Caller lifetime.
|
|
93
|
+
*/
|
|
94
|
+
registerHost(host: RemotePluginHostOptions, signal?: AbortSignal): Promise<void>;
|
|
34
95
|
/** Whether an active matching handler explicitly accepts a protocol.
|
|
35
96
|
* @param protocol Query prefix without punctuation.
|
|
36
97
|
* @param options Source targeting and block list.
|
|
37
98
|
*/
|
|
38
99
|
supportsProtocol(protocol: string, options?: ExecuteOptions): boolean;
|
|
100
|
+
/** Ordered owners of a custom query protocol.
|
|
101
|
+
* @param protocol Registered protocol prefix.
|
|
102
|
+
* @param options Targeting and block list.
|
|
103
|
+
* @returns Eligible provider identities, in dispatch order.
|
|
104
|
+
*/
|
|
105
|
+
protocolMatches(protocol: string, options?: ExecuteOptions): {
|
|
106
|
+
pluginId: string;
|
|
107
|
+
hostId: string | undefined;
|
|
108
|
+
score: number;
|
|
109
|
+
}[];
|
|
39
110
|
/** Register and initialize a source descriptor, reserving its ID synchronously.
|
|
40
111
|
* @param registration Descriptor produced by definePlugin.
|
|
41
112
|
*/
|
|
@@ -43,13 +114,28 @@ export declare class PluginRegistry {
|
|
|
43
114
|
private cleanup;
|
|
44
115
|
/** Abort new and active work, drain handlers, and release resources. Handlers must cooperate with cancellation.
|
|
45
116
|
* @param id Plugin ID.
|
|
117
|
+
* @param hostId Optional deployment identity when the provider exists on multiple hosts.
|
|
46
118
|
* @returns Whether the registration existed.
|
|
47
119
|
*/
|
|
48
|
-
unregister(id: string): Promise<boolean>;
|
|
120
|
+
unregister(id: string, hostId?: string): Promise<boolean>;
|
|
49
121
|
/** Initialize pending registrations before dispatch. */
|
|
50
122
|
ready(): Promise<void>;
|
|
51
123
|
/** Destroy all registrations, attempting every cleanup even when one fails. */
|
|
52
124
|
destroy(): Promise<void>;
|
|
125
|
+
/** Whether an operation has active subscribers. Does not scan unrelated registrations.
|
|
126
|
+
* @param operation Capability name.
|
|
127
|
+
* @returns Whether at least one active handler exists.
|
|
128
|
+
*/
|
|
129
|
+
hasCapability(operation: OperationName): boolean;
|
|
130
|
+
/** Reject reentrant application operations from synchronous capability handlers. */
|
|
131
|
+
assertNotDispatching(): void;
|
|
132
|
+
/** Dispatch a synchronous local capability without scheduling promises.
|
|
133
|
+
* @param operation Capability defined with synchronous execution.
|
|
134
|
+
* @param input Validated operation payload.
|
|
135
|
+
* @param options Scope and cancellation constraints.
|
|
136
|
+
* @returns The selected result, or transformed input for pipe operations.
|
|
137
|
+
*/
|
|
138
|
+
executeSync<K extends OperationName>(operation: K, input: OperationInput<K>, options?: ExecuteOptions): OperationResult<K>;
|
|
53
139
|
/** Execute using the operation's declared policy. Genuine failures reject immediately.
|
|
54
140
|
* @param operation Typed operation name.
|
|
55
141
|
* @param input Operation payload.
|
|
@@ -58,6 +144,18 @@ export declare class PluginRegistry {
|
|
|
58
144
|
*/
|
|
59
145
|
execute<K extends OperationName>(operation: K, input: OperationInput<K>, options?: ExecuteOptions): Promise<OperationResult<K>>;
|
|
60
146
|
private run;
|
|
147
|
+
/** Serialize using modern application-metadata transformations. Plain model serialization remains synchronous.
|
|
148
|
+
* @param entity Track or playlist to persist.
|
|
149
|
+
* @param options Cancellation and provider scope.
|
|
150
|
+
* @returns A validated JSON persistence payload, without playback grants or live streams.
|
|
151
|
+
*/
|
|
152
|
+
serialize(entity: Track | Playlist, options?: ExecuteOptions): Promise<SerializedEntityUnion>;
|
|
153
|
+
/** Restore through modern metadata transformations and the existing schema validator.
|
|
154
|
+
* @param payload Untrusted persistence payload.
|
|
155
|
+
* @param options Cancellation and provider scope.
|
|
156
|
+
* @returns A restored entity without ephemeral playback state.
|
|
157
|
+
*/
|
|
158
|
+
restore(payload: unknown, options?: ExecuteOptions): Promise<Track | Playlist>;
|
|
61
159
|
/** Resolve and normalize a track for the already selected Remedia node.
|
|
62
160
|
* @param track Data model with a portable provider reference.
|
|
63
161
|
* @param options Target node mode and cancellation.
|