lx-source-type 2.0.0 → 2.0.1
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/define.d.ts +4 -4
- package/package.json +3 -2
- package/type.d.ts +151 -0
package/define.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LX } from "./type"
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
var lx: LX.API
|
|
1
|
+
import type { LX } from "./type"
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
var lx: LX.API
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lx-source-type",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Ceale",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": "https://github.com/Ceale/lx-source-type.git",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"types": "./type.d.ts"
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"README.md",
|
|
17
|
-
"
|
|
18
|
+
"type.d.ts",
|
|
18
19
|
"define.d.ts"
|
|
19
20
|
],
|
|
20
21
|
"peerDependencies": {
|
package/type.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type Zlib from "node:zlib"
|
|
2
|
+
import type Crypto from "node:crypto"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LX Music 自定义源 API 类型定义
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace LX {
|
|
8
|
+
export type Quality = "128k" | "320k" | "flac" | "flac24bit"
|
|
9
|
+
export type NetAction = "musicUrl" | "lyric" | "pic"
|
|
10
|
+
export type SupportPlatform = "kw" | "kg" | "tx" | "wy" | "mg" | "local"
|
|
11
|
+
|
|
12
|
+
export interface MusicInfo {
|
|
13
|
+
name: string
|
|
14
|
+
singer: string
|
|
15
|
+
interval: string
|
|
16
|
+
|
|
17
|
+
source: SupportPlatform
|
|
18
|
+
songmid: string
|
|
19
|
+
|
|
20
|
+
img: string
|
|
21
|
+
albumName: string
|
|
22
|
+
|
|
23
|
+
/** 仅限酷狗 */
|
|
24
|
+
hash?: string
|
|
25
|
+
/** 仅限咪咕 */
|
|
26
|
+
copyrightId?: string
|
|
27
|
+
|
|
28
|
+
[key: string]: any
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LyricResult {
|
|
32
|
+
lyric: string
|
|
33
|
+
tlyric?: string | null
|
|
34
|
+
rlyric?: string | null
|
|
35
|
+
lxlyric?: string | null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface MRequestOptions {
|
|
39
|
+
/** 默认为 Get */
|
|
40
|
+
method?: string
|
|
41
|
+
headers?: Record<string, string>
|
|
42
|
+
body?: any
|
|
43
|
+
form?: Record<string, any>
|
|
44
|
+
formData?: Record<string, any>
|
|
45
|
+
timeout?: number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MRequestResponse {
|
|
49
|
+
statusCode: number
|
|
50
|
+
statusMessage: string
|
|
51
|
+
headers: Record<string, string | string[] | undefined>
|
|
52
|
+
bytes?: number,
|
|
53
|
+
raw?: Uint8Array,
|
|
54
|
+
body: any
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface SourceInfo {
|
|
58
|
+
name: string
|
|
59
|
+
type: "music"
|
|
60
|
+
actions: NetAction[]
|
|
61
|
+
qualitys: Quality[]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface InitedPayload {
|
|
65
|
+
sources: Partial<Record<SupportPlatform, SourceInfo>>
|
|
66
|
+
openDevTools?: boolean
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface UpdateAlertPayload {
|
|
70
|
+
log: string
|
|
71
|
+
updateUrl?: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ERequestHandler {
|
|
75
|
+
(params: ERequestParams): Promise<ERequestResult>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ERequestParams {
|
|
79
|
+
source: SupportPlatform
|
|
80
|
+
action: NetAction
|
|
81
|
+
info: {
|
|
82
|
+
type?: Quality | null
|
|
83
|
+
musicInfo: MusicInfo
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type ERequestResult = string | {
|
|
88
|
+
lyric: string,
|
|
89
|
+
tlyric: string | null
|
|
90
|
+
rlyric: string | null
|
|
91
|
+
lxlyric: string | null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface EVENT_NAMES {
|
|
95
|
+
inited: "inited"
|
|
96
|
+
request: "request"
|
|
97
|
+
updateAlert: "updateAlert"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface Utils {
|
|
101
|
+
buffer: {
|
|
102
|
+
from: typeof Buffer.from
|
|
103
|
+
bufToString(buffer: WithImplicitCoercion<ArrayLike<number> | string>, format: BufferEncoding): string
|
|
104
|
+
}
|
|
105
|
+
crypto: {
|
|
106
|
+
aesEncrypt(buffer: BinaryLike, mode: string, key: string, iv: string): Buffer
|
|
107
|
+
rsaEncrypt(buffer: any, key: string): Buffer
|
|
108
|
+
randomBytes(size: number): Uint8Array
|
|
109
|
+
/** 返回 hex 字符串 */
|
|
110
|
+
md5(str: string): string
|
|
111
|
+
}
|
|
112
|
+
zlib: {
|
|
113
|
+
inflate(buffer: Zlib.InputType): Promise<NonSharedBuffer>
|
|
114
|
+
deflate(buffer: Zlib.InputType): Promise<NonSharedBuffer>
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 当前脚本信息 */
|
|
119
|
+
export interface ScriptInfo {
|
|
120
|
+
name: string
|
|
121
|
+
description: string
|
|
122
|
+
version: string
|
|
123
|
+
author: string
|
|
124
|
+
homepage: string
|
|
125
|
+
rawScript: string
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface API {
|
|
129
|
+
/** API 版本号 */
|
|
130
|
+
version: "2.0.0"
|
|
131
|
+
/** 运行环境 */
|
|
132
|
+
env: "desktop" | "mobile"
|
|
133
|
+
currentScriptInfo: ScriptInfo
|
|
134
|
+
/** 常量事件名 */
|
|
135
|
+
EVENT_NAMES: EVENT_NAMES
|
|
136
|
+
/** 注册事件监听 */
|
|
137
|
+
on(eventName: EVENT_NAMES["request"], handler: ERequestHandler): Promise<void>
|
|
138
|
+
/** 发送事件 */
|
|
139
|
+
send(eventName: EVENT_NAMES["inited"], data: InitedPayload): Promise<void>
|
|
140
|
+
send(eventName: EVENT_NAMES["updateAlert"], data: UpdateAlertPayload): Promise<void>
|
|
141
|
+
/** HTTP 请求方法 */
|
|
142
|
+
request(
|
|
143
|
+
url: string,
|
|
144
|
+
options: MRequestOptions,
|
|
145
|
+
callback: (err: any, resp: MRequestResponse | null, body: any) => void
|
|
146
|
+
): () => void
|
|
147
|
+
|
|
148
|
+
/** 工具方法 */
|
|
149
|
+
utils: LX.Utils
|
|
150
|
+
}
|
|
151
|
+
}
|