lx-source-type 2.0.3 → 2.0.5

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +1 -1
  3. package/type.d.ts +79 -68
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 筱莱Ceale
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lx-source-type",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "author": "Ceale",
6
6
  "license": "MIT",
package/type.d.ts CHANGED
@@ -1,13 +1,30 @@
1
1
  import type { WithImplicitCoercion } from "node:buffer"
2
+ import type { BinaryLike } from "node:crypto"
2
3
  import type Zlib from "node:zlib"
3
4
 
4
5
  /**
5
6
  * LX Music 自定义源 API 类型定义
6
7
  */
7
8
  export declare namespace LX {
8
- export type Quality = "128k" | "320k" | "flac" | "flac24bit"
9
- export type NetAction = "musicUrl" | "lyric" | "pic"
10
9
  export type SupportPlatform = "kw" | "kg" | "tx" | "wy" | "mg" | "local"
10
+ export type NetAction = "musicUrl" | "lyric" | "pic"
11
+ export type Quality = "128k" | "320k" | "flac" | "flac24bit"
12
+
13
+ /** 当前脚本信息 */
14
+ export interface ScriptInfo {
15
+ name: string
16
+ description: string
17
+ version: string
18
+ author: string
19
+ homepage: string
20
+ rawScript: string
21
+ }
22
+
23
+ export interface EVENT_NAMES {
24
+ inited: "inited"
25
+ request: "request"
26
+ updateAlert: "updateAlert"
27
+ }
11
28
 
12
29
  export interface MusicInfo {
13
30
  name: string
@@ -28,30 +45,30 @@ export declare namespace LX {
28
45
  [key: string]: any
29
46
  }
30
47
 
48
+ export interface ProviderParams {
49
+ source: SupportPlatform
50
+ action: NetAction
51
+ info: {
52
+ type?: Quality | null
53
+ musicInfo: MusicInfo
54
+ }
55
+ }
56
+
31
57
  export interface LyricResult {
32
58
  lyric: string
33
59
  tlyric?: string | null
34
60
  rlyric?: string | null
35
61
  lxlyric?: string | null
36
62
  }
63
+
64
+ export type ProviderResult = string | LyricResult
37
65
 
38
- export interface RequestOptions {
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
66
+ export interface Provider {
67
+ (params: ProviderParams): Promise<ProviderResult>
46
68
  }
47
69
 
48
- export interface RequestResponse {
49
- statusCode: number
50
- statusMessage: string
51
- headers: Record<string, string | string[] | undefined>
52
- bytes?: number,
53
- raw?: Uint8Array,
54
- body: any
70
+ export interface OnEvent {
71
+ (eventName: EVENT_NAMES["request"], handler: Provider): Promise<void>
55
72
  }
56
73
 
57
74
  export interface SourceInfo {
@@ -71,30 +88,44 @@ export declare namespace LX {
71
88
  updateUrl?: string
72
89
  }
73
90
 
74
- export interface Provider {
75
- (params: ProviderParams): Promise<ProviderResult>
91
+ export interface EventPayloadMap {
92
+ "inited": InitedPayload
93
+ "updateAlert": UpdateAlertPayload
76
94
  }
77
95
 
78
- export interface ProviderParams {
79
- source: SupportPlatform
80
- action: NetAction
81
- info: {
82
- type?: Quality | null
83
- musicInfo: MusicInfo
84
- }
96
+ export interface SendEvent {
97
+ <K extends keyof EventPayloadMap>(eventName: K, payload: EventPayloadMap[K]): Promise<void>
85
98
  }
86
-
87
- export type ProviderResult = string | {
88
- lyric: string,
89
- tlyric: string | null
90
- rlyric: string | null
91
- lxlyric: string | null
99
+
100
+ export interface RequestOptions {
101
+ /** 默认为 Get */
102
+ method?: string
103
+ headers?: Record<string, string>
104
+ body?: any
105
+ form?: Record<string, any>
106
+ formData?: Record<string, any>
107
+ timeout?: number
92
108
  }
93
109
 
94
- export interface EVENT_NAMES {
95
- inited: "inited"
96
- request: "request"
97
- updateAlert: "updateAlert"
110
+ export interface RequestResponse {
111
+ statusCode: number
112
+ statusMessage: string
113
+ headers: Record<string, string | string[] | undefined>
114
+ bytes?: number,
115
+ raw?: Uint8Array,
116
+ body: any
117
+ }
118
+
119
+ export interface RequestCallback {
120
+ (err: any, resp: RequestResponse | null, body: any): void
121
+ }
122
+
123
+ export interface Request {
124
+ (
125
+ url: string,
126
+ options: RequestOptions,
127
+ callback: RequestCallback
128
+ ): () => void
98
129
  }
99
130
 
100
131
  export interface Utils {
@@ -115,37 +146,6 @@ export declare namespace LX {
115
146
  }
116
147
  }
117
148
 
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 RequestCallback {
129
- (err: any, 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
-
149
149
  export interface API {
150
150
  /** API 版本号 */
151
151
  version: "2.0.0"
@@ -163,4 +163,15 @@ export declare namespace LX {
163
163
  /** 工具方法 */
164
164
  utils: Utils
165
165
  }
166
- }
166
+ }
167
+
168
+ const a = {} as LX.SendEvent
169
+
170
+ a("inited", {
171
+
172
+ })
173
+
174
+ a("updateAlert", {
175
+ log: "log",
176
+ updateUrl: "updateUrl"
177
+ })