lx-source-type 2.0.1 → 2.0.2
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/package.json +1 -1
- package/type.d.ts +32 -17
package/package.json
CHANGED
package/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { WithImplicitCoercion } from "node:buffer"
|
|
1
2
|
import type Zlib from "node:zlib"
|
|
2
|
-
import type Crypto from "node:crypto"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* LX Music 自定义源 API 类型定义
|
|
@@ -35,7 +35,7 @@ export declare namespace LX {
|
|
|
35
35
|
lxlyric?: string | null
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface
|
|
38
|
+
export interface RequestOptions {
|
|
39
39
|
/** 默认为 Get */
|
|
40
40
|
method?: string
|
|
41
41
|
headers?: Record<string, string>
|
|
@@ -45,7 +45,7 @@ export declare namespace LX {
|
|
|
45
45
|
timeout?: number
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export interface
|
|
48
|
+
export interface RequestResponse {
|
|
49
49
|
statusCode: number
|
|
50
50
|
statusMessage: string
|
|
51
51
|
headers: Record<string, string | string[] | undefined>
|
|
@@ -71,11 +71,11 @@ export declare namespace LX {
|
|
|
71
71
|
updateUrl?: string
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export interface
|
|
75
|
-
(params:
|
|
74
|
+
export interface Provider {
|
|
75
|
+
(params: ProviderParams): Promise<ProviderResult>
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export interface
|
|
78
|
+
export interface ProviderParams {
|
|
79
79
|
source: SupportPlatform
|
|
80
80
|
action: NetAction
|
|
81
81
|
info: {
|
|
@@ -84,7 +84,7 @@ export declare namespace LX {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export type
|
|
87
|
+
export type ProviderResult = string | {
|
|
88
88
|
lyric: string,
|
|
89
89
|
tlyric: string | null
|
|
90
90
|
rlyric: string | null
|
|
@@ -125,6 +125,27 @@ export declare namespace LX {
|
|
|
125
125
|
rawScript: string
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export interface RequestCallback {
|
|
129
|
+
(err: null, resp: RequestResponse | null, body: any): void
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface OnEvent {
|
|
133
|
+
(eventName: EVENT_NAMES["request"], handler: Provider): Promise<void>
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface SendEvent {
|
|
137
|
+
(eventName: EVENT_NAMES["inited"], data: InitedPayload): Promise<void>
|
|
138
|
+
(eventName: EVENT_NAMES["updateAlert"], data: UpdateAlertPayload): Promise<void>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface Request {
|
|
142
|
+
(
|
|
143
|
+
url: string,
|
|
144
|
+
options: RequestOptions,
|
|
145
|
+
callback: RequestCallback
|
|
146
|
+
): () => void
|
|
147
|
+
}
|
|
148
|
+
|
|
128
149
|
export interface API {
|
|
129
150
|
/** API 版本号 */
|
|
130
151
|
version: "2.0.0"
|
|
@@ -134,18 +155,12 @@ export declare namespace LX {
|
|
|
134
155
|
/** 常量事件名 */
|
|
135
156
|
EVENT_NAMES: EVENT_NAMES
|
|
136
157
|
/** 注册事件监听 */
|
|
137
|
-
on
|
|
158
|
+
on: OnEvent
|
|
138
159
|
/** 发送事件 */
|
|
139
|
-
send
|
|
140
|
-
send(eventName: EVENT_NAMES["updateAlert"], data: UpdateAlertPayload): Promise<void>
|
|
160
|
+
send: SendEvent
|
|
141
161
|
/** HTTP 请求方法 */
|
|
142
|
-
request
|
|
143
|
-
url: string,
|
|
144
|
-
options: MRequestOptions,
|
|
145
|
-
callback: (err: any, resp: MRequestResponse | null, body: any) => void
|
|
146
|
-
): () => void
|
|
147
|
-
|
|
162
|
+
request: Request
|
|
148
163
|
/** 工具方法 */
|
|
149
|
-
utils:
|
|
164
|
+
utils: Utils
|
|
150
165
|
}
|
|
151
166
|
}
|