@shiqianjiang/ceru-plugin-sdk 0.2.4 → 0.3.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/CHANGELOG.md +25 -0
- package/README.md +27 -0
- package/dist/compat/crypto.d.ts +13 -7
- package/dist/compat/crypto.js +6 -0
- package/dist/compat/zlib.d.ts +1 -1
- package/dist/compat/zlib.js +1 -0
- package/dist/guests.d.ts +44 -0
- package/dist/guests.js +1 -0
- package/dist/index.d.ts +28 -15
- package/dist/index.js +3 -0
- package/dist/manifest.d.ts +27 -0
- package/dist/music.js +12 -0
- package/dist/quality.js +2 -2
- package/dist/services.d.ts +3 -0
- package/dist/share.d.ts +54 -0
- package/dist/share.js +1 -0
- package/dist/storage.d.ts +18 -0
- package/dist/storage.js +1 -0
- package/package.json +153 -127
- /package/dist/{host-modules.d.ts → host-modules.d.cts} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SDK 变更记录
|
|
2
|
+
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
- 播放解析结果新增 `requestHeaders`,供 Host 在获取对应临时媒体地址时附加防盗链、认证或客户端请求头;请求头只保留在 Host 主进程,并按完整 URL 与到期时间隔离。
|
|
6
|
+
|
|
7
|
+
## 0.3.0
|
|
8
|
+
|
|
9
|
+
- 正式声明 Web Surface 的 title、presentation 和 lifecycle;界面与业务由插件实现,宿主仅提供容器。
|
|
10
|
+
- CLI 和 Core 共用 SurfaceSession,统一打开、关闭、取消请求和过期会话校验。
|
|
11
|
+
- 开发工作台按页面分发状态,支持关闭页面和私有存储持久化;页面不接收清单中的默认凭据。
|
|
12
|
+
- Core 正式导出 /guests、/surface、/surface-document,恢复已使用的 Guest 和分享能力,消除本机 node_modules 补丁。
|
|
13
|
+
- 五个工具链包与脚手架模板统一到 0.3.0。以下 0.2.5 的类型改动一并发布。
|
|
14
|
+
|
|
15
|
+
## 0.2.5
|
|
16
|
+
|
|
17
|
+
- 从根入口及 `/guests`、`/share`、`/storage` 导出 Guest、分享解析与存储类型。
|
|
18
|
+
- 同步 PluginContext 的 Guest 管理、插件更新、歌单导入参数与 Storage 空值/共享键签名。
|
|
19
|
+
- 补齐 GuestBootstrapAPI、Manifest 分享入口、命令说明、Guest 展示信息与菜单说明。
|
|
20
|
+
- 打包前自动构建并检查公开导出文件,避免源码中存在但 npm tarball 缺失。
|
|
21
|
+
- 新增真实打包、隔离安装、严格类型检查及运行时子路径导入测试。
|
|
22
|
+
- 将 CommonJS 宿主模块声明明确标为 .d.cts,兼容 NodeNext 与 Bundler 模式。
|
|
23
|
+
- 避免公开 Buffer 返回类型依赖开发环境中的 Node Buffer 泛型声明。
|
|
24
|
+
|
|
25
|
+
运行能力由 Host 决定;本次类型补充不会为旧宿主添加业务实现。
|
package/README.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Ceru Plugin SDK
|
|
2
2
|
|
|
3
|
+
## 0.2.5 类型同步
|
|
4
|
+
|
|
5
|
+
0.2.5 补齐桌面 v2 已使用的 Guest、分享解析、Storage、插件更新和导入界面契约。
|
|
6
|
+
Guest / 分享 / 存储类型可从包根入口导入,也可分别从 `/guests`、`/share`、`/storage` 导入:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import type {
|
|
10
|
+
GuestInfo,
|
|
11
|
+
GuestBootstrapAPI,
|
|
12
|
+
ShareResolverEntry,
|
|
13
|
+
PluginStorageAPI,
|
|
14
|
+
} from '@shiqianjiang/ceru-plugin-sdk'
|
|
15
|
+
import type { GuestInfo as Guest } from '@shiqianjiang/ceru-plugin-sdk/guests'
|
|
16
|
+
import type { ShareResolverEntry as Resolver } from '@shiqianjiang/ceru-plugin-sdk/share'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`PluginContext.storage` 支持桌面结构化键、`readableBy` 与 `null` 空值;
|
|
20
|
+
`guests` 补齐 `import/select/remove` 和完整信息;`GuestContext` 包含 bootstrap 契约;
|
|
21
|
+
`ui.pluginUpdate.request` 和导入窗口的可选 `importerId/title` 也已声明。
|
|
22
|
+
|
|
23
|
+
这些类型描述宿主契约,不会让旧 Host 或 CLI 工作台自动获得对应能力。
|
|
24
|
+
Manifest 的分享入口和 Guest 展示字段还需要匹配的构建器与校验器。
|
|
25
|
+
`prepareInstall/requestInstall` 保留旧声明,桌面优先使用 `guests.import`。
|
|
26
|
+
|
|
27
|
+
`npm pack` 会先编译 SDK、复制必要的 ambient 声明,并检查每个 exports 目标存在。
|
|
28
|
+
仓库的 `npm run test:sdk-package` 将真实 tarball 安装到空项目中,验证根入口、子路径和类型约束。
|
|
29
|
+
|
|
3
30
|
面向 Ceru Music v2 的 TypeScript 类型与小型作者辅助函数。
|
|
4
31
|
|
|
5
32
|
包含 PluginContext、分组 Provider、歌曲/歌词/歌单标准数据、宿主服务、权限组、Surface、资源引用、结构化错误、UI Slot、图标名和类型化 Lodash。运行能力由 Host 提供,SDK 本身不授予权限。
|
package/dist/compat/crypto.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
export function createHash(name: any): {
|
|
2
2
|
update(value: any): /*elided*/ any;
|
|
3
|
-
|
|
3
|
+
/** @returns {string | Buffer} */
|
|
4
|
+
digest(encoding: any): string | Buffer;
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
/** @returns {Buffer} */
|
|
7
|
+
export function publicEncrypt(options: any, value: any): Buffer;
|
|
6
8
|
export function createCipheriv(mode: any, key: any, iv: any): {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
/** @returns {Buffer} */
|
|
10
|
+
update(value: any): Buffer;
|
|
11
|
+
/** @returns {Buffer} */
|
|
12
|
+
final(): Buffer;
|
|
9
13
|
};
|
|
10
14
|
export function createDecipheriv(mode: any, key: any, iv: any): {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
/** @returns {Buffer} */
|
|
16
|
+
update(value: any): Buffer;
|
|
17
|
+
/** @returns {Buffer} */
|
|
18
|
+
final(): Buffer;
|
|
13
19
|
};
|
|
14
|
-
export function randomBytes(size: any): Buffer
|
|
20
|
+
export function randomBytes(size: any): Buffer;
|
|
15
21
|
export function randomUUID(): `${string}-${string}-${string}-${string}-${string}`;
|
|
16
22
|
export namespace constants {
|
|
17
23
|
let RSA_NO_PADDING: number;
|
package/dist/compat/crypto.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CryptoJS from 'crypto-js';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
const words = (value) => CryptoJS.enc.Hex.parse(Buffer.from(value).toString('hex'));
|
|
4
|
+
/** @returns {Buffer} */
|
|
4
5
|
const bytes = (value) => Buffer.from(value.toString(CryptoJS.enc.Hex), 'hex');
|
|
5
6
|
export function createHash(name) {
|
|
6
7
|
const factory = {
|
|
@@ -16,6 +17,7 @@ export function createHash(name) {
|
|
|
16
17
|
hash.update(words(value));
|
|
17
18
|
return this;
|
|
18
19
|
},
|
|
20
|
+
/** @returns {string | Buffer} */
|
|
19
21
|
digest(encoding) {
|
|
20
22
|
const result = bytes(hash.finalize());
|
|
21
23
|
return encoding ? result.toString(encoding) : result;
|
|
@@ -27,10 +29,12 @@ function cipher(mode, key, iv, decrypt) {
|
|
|
27
29
|
throw new Error('Unsupported cipher: ' + mode);
|
|
28
30
|
const chunks = [];
|
|
29
31
|
return {
|
|
32
|
+
/** @returns {Buffer} */
|
|
30
33
|
update(value) {
|
|
31
34
|
chunks.push(Buffer.from(value));
|
|
32
35
|
return Buffer.alloc(0);
|
|
33
36
|
},
|
|
37
|
+
/** @returns {Buffer} */
|
|
34
38
|
final() {
|
|
35
39
|
const data = words(Buffer.concat(chunks));
|
|
36
40
|
const options = {
|
|
@@ -46,10 +50,12 @@ function cipher(mode, key, iv, decrypt) {
|
|
|
46
50
|
}
|
|
47
51
|
export const createCipheriv = (mode, key, iv) => cipher(mode, key, iv, false);
|
|
48
52
|
export const createDecipheriv = (mode, key, iv) => cipher(mode, key, iv, true);
|
|
53
|
+
/** @returns {Buffer} */
|
|
49
54
|
export const randomBytes = (size) => Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(size)));
|
|
50
55
|
export const randomUUID = () => globalThis.crypto.randomUUID();
|
|
51
56
|
export const constants = { RSA_NO_PADDING: 3 };
|
|
52
57
|
// SPKI public-key parsing for the existing NetEase no-padding RSA request format.
|
|
58
|
+
/** @returns {Buffer} */
|
|
53
59
|
export function publicEncrypt(options, value) {
|
|
54
60
|
if (options.padding !== constants.RSA_NO_PADDING)
|
|
55
61
|
throw new Error('Unsupported RSA padding');
|
package/dist/compat/zlib.d.ts
CHANGED
package/dist/compat/zlib.js
CHANGED
package/dist/guests.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Disposable, JsonValue } from './manifest.js';
|
|
2
|
+
import type { OperationContext } from './index.js';
|
|
3
|
+
export interface GuestProvider {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** Lowest to highest, as declared by the imported script. */
|
|
7
|
+
qualities: string[];
|
|
8
|
+
protocols: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface GuestInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
adapterId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
version: string;
|
|
15
|
+
author?: string;
|
|
16
|
+
state: 'ready' | 'stopped' | 'error';
|
|
17
|
+
selected: boolean;
|
|
18
|
+
providers: GuestProvider[];
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Requires a Host with Guest management support; the SDK does not install Guest runtimes. */
|
|
22
|
+
export interface GuestAPI {
|
|
23
|
+
list(): Promise<GuestInfo[]>;
|
|
24
|
+
/** The Host owns file selection and approval. Cancellation returns null. */
|
|
25
|
+
import(adapterId: string): Promise<GuestInfo | null>;
|
|
26
|
+
select(guestId: string | null): Promise<void>;
|
|
27
|
+
remove(guestId: string): Promise<void>;
|
|
28
|
+
invoke(guestId: string, method: string, input: JsonValue, operation: OperationContext): Promise<JsonValue>;
|
|
29
|
+
}
|
|
30
|
+
export interface GuestBootstrapAPI {
|
|
31
|
+
readonly scriptInfo: Readonly<{
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
author?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
homepage?: string;
|
|
37
|
+
rawScript: string;
|
|
38
|
+
}>;
|
|
39
|
+
ready(metadata: {
|
|
40
|
+
providers: GuestProvider[];
|
|
41
|
+
}): void;
|
|
42
|
+
handle(handler: (method: string, input: JsonValue, operation: OperationContext) => Promise<JsonValue>): Disposable;
|
|
43
|
+
invokeHost(method: string, input: JsonValue): Promise<JsonValue>;
|
|
44
|
+
}
|
package/dist/guests.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference path="./host-modules.d.
|
|
1
|
+
/// <reference path="./host-modules.d.cts" />
|
|
2
2
|
/** This package defines the v2 wire/authoring contract. It does not grant Host permissions. */
|
|
3
3
|
import type { LoDashStatic } from 'lodash';
|
|
4
4
|
import type { HostIconName, HostAssetName, LODASH_METHODS } from './catalog.js';
|
|
@@ -7,10 +7,15 @@ export * from './http.js';
|
|
|
7
7
|
export * from './library.js';
|
|
8
8
|
export * from './sockets.js';
|
|
9
9
|
import type { SocketAPI } from './sockets.js';
|
|
10
|
+
import type { GuestAPI, GuestBootstrapAPI } from './guests.js';
|
|
11
|
+
import type { PluginStorageAPI } from './storage.js';
|
|
10
12
|
import type { createHttpClient, HttpClientOptions } from './http.js';
|
|
11
13
|
export * from './music.js';
|
|
12
14
|
export * from './lyrics.js';
|
|
13
15
|
export * from './quality.js';
|
|
16
|
+
export * from './guests.js';
|
|
17
|
+
export * from './share.js';
|
|
18
|
+
export * from './storage.js';
|
|
14
19
|
export * from './permissions.js';
|
|
15
20
|
export * from './services.js';
|
|
16
21
|
export * from './modules.js';
|
|
@@ -106,6 +111,8 @@ export type ResolveResult = {
|
|
|
106
111
|
ok: true;
|
|
107
112
|
url: string;
|
|
108
113
|
expiresAt?: number;
|
|
114
|
+
/** Headers the Host must attach while fetching this exact media URL. */
|
|
115
|
+
requestHeaders?: Record<string, string>;
|
|
109
116
|
} | {
|
|
110
117
|
ok: false;
|
|
111
118
|
error: MusicFault;
|
|
@@ -249,11 +256,26 @@ export interface PluginContext extends HostServices {
|
|
|
249
256
|
}): Promise<void>;
|
|
250
257
|
/** Opens the application's existing import dialog. This does not create a plugin Surface. */
|
|
251
258
|
playlistImport: {
|
|
259
|
+
/** Only this plugin's importers are offered. Omit importerId to let the user choose. */
|
|
252
260
|
open(request: {
|
|
253
|
-
importerId
|
|
261
|
+
importerId?: string;
|
|
254
262
|
initialValue?: string;
|
|
263
|
+
title?: string;
|
|
255
264
|
}): Promise<void>;
|
|
256
265
|
};
|
|
266
|
+
/** Requests an update through the Host UI. A queued result does not mean it was installed. */
|
|
267
|
+
pluginUpdate: {
|
|
268
|
+
request(request: {
|
|
269
|
+
version: string;
|
|
270
|
+
url: string;
|
|
271
|
+
notes?: string;
|
|
272
|
+
}): Promise<{
|
|
273
|
+
accepted: boolean;
|
|
274
|
+
updated: boolean;
|
|
275
|
+
version?: string;
|
|
276
|
+
queued?: boolean;
|
|
277
|
+
}>;
|
|
278
|
+
};
|
|
257
279
|
setState(surfaceId: string, state: JsonObject): Promise<void>;
|
|
258
280
|
notify(message: {
|
|
259
281
|
key: string;
|
|
@@ -262,17 +284,9 @@ export interface PluginContext extends HostServices {
|
|
|
262
284
|
}): Promise<void>;
|
|
263
285
|
openView(surfaceId: string): Promise<void>;
|
|
264
286
|
};
|
|
265
|
-
storage:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
delete(key: string): Promise<void>;
|
|
269
|
-
};
|
|
270
|
-
guests: {
|
|
271
|
-
list(): Promise<{
|
|
272
|
-
id: string;
|
|
273
|
-
name: string;
|
|
274
|
-
state: string;
|
|
275
|
-
}[]>;
|
|
287
|
+
storage: PluginStorageAPI;
|
|
288
|
+
guests: GuestAPI & {
|
|
289
|
+
/** Legacy install-draft contract; availability depends on the Host. Prefer import on desktop. */
|
|
276
290
|
prepareInstall(request: {
|
|
277
291
|
adapterId: string;
|
|
278
292
|
artifactHandle: string;
|
|
@@ -283,7 +297,6 @@ export interface PluginContext extends HostServices {
|
|
|
283
297
|
requestInstall(draftId: string, operation: OperationContext): Promise<{
|
|
284
298
|
guestId: string;
|
|
285
299
|
} | null>;
|
|
286
|
-
invoke(guestId: string, method: string, input: JsonValue, operation: OperationContext): Promise<JsonValue>;
|
|
287
300
|
};
|
|
288
301
|
log: {
|
|
289
302
|
debug(message: string, data?: JsonValue): void;
|
|
@@ -306,7 +319,7 @@ export interface SurfaceContext extends Pick<PluginContext, 'host' | 'utils' | '
|
|
|
306
319
|
invoke(action: string, input: JsonValue): Promise<JsonValue>;
|
|
307
320
|
subscribe(handler: (state: JsonObject) => void): Disposable;
|
|
308
321
|
}
|
|
309
|
-
export interface GuestContext extends Pick<PluginContext, 'host' | 'utils'
|
|
322
|
+
export interface GuestContext extends Pick<PluginContext, 'host' | 'utils'>, GuestBootstrapAPI {
|
|
310
323
|
readonly guestId: string;
|
|
311
324
|
expose(name: string, value: unknown): void;
|
|
312
325
|
invokeHost(method: string, input: JsonValue): Promise<JsonValue>;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ export * from './sockets.js';
|
|
|
5
5
|
export * from './music.js';
|
|
6
6
|
export * from './lyrics.js';
|
|
7
7
|
export * from './quality.js';
|
|
8
|
+
export * from './guests.js';
|
|
9
|
+
export * from './share.js';
|
|
10
|
+
export * from './storage.js';
|
|
8
11
|
export * from './permissions.js';
|
|
9
12
|
export * from './services.js';
|
|
10
13
|
export * from './modules.js';
|
package/dist/manifest.d.ts
CHANGED
|
@@ -36,6 +36,18 @@ export interface SurfaceDeclaration {
|
|
|
36
36
|
id: string;
|
|
37
37
|
kind: 'schema' | 'web';
|
|
38
38
|
entry: string;
|
|
39
|
+
/** Host chrome only. The plugin owns all content inside a web Surface. */
|
|
40
|
+
title?: string;
|
|
41
|
+
presentation?: {
|
|
42
|
+
kind: 'drawer';
|
|
43
|
+
placement?: 'left' | 'right' | 'top' | 'bottom';
|
|
44
|
+
size?: number;
|
|
45
|
+
};
|
|
46
|
+
/** Declared logic actions. Open runs after mounting; close runs once per session. */
|
|
47
|
+
lifecycle?: {
|
|
48
|
+
openAction?: string;
|
|
49
|
+
closeAction?: string;
|
|
50
|
+
};
|
|
39
51
|
}
|
|
40
52
|
export type HomeSectionKind = 'playlists' | 'charts' | 'custom';
|
|
41
53
|
export type UISlotName = 'home.header' | 'home.content.before' | 'home.content.after' | 'search.source-selector.after' | 'playlist.header.actions' | 'playlist.item.actions' | 'player.actions' | 'settings.sections';
|
|
@@ -91,6 +103,13 @@ export interface PluginManifest {
|
|
|
91
103
|
entry: string;
|
|
92
104
|
activation?: string[];
|
|
93
105
|
};
|
|
106
|
+
/** Separate server-side playback resolver. Requires a compatible builder and share Host. */
|
|
107
|
+
share?: {
|
|
108
|
+
entry: string;
|
|
109
|
+
configKeys?: string[];
|
|
110
|
+
guestAdapterId?: string;
|
|
111
|
+
guestGlobals?: string[];
|
|
112
|
+
};
|
|
94
113
|
surfaces?: SurfaceDeclaration[];
|
|
95
114
|
};
|
|
96
115
|
contributes?: {
|
|
@@ -123,6 +142,7 @@ export interface PluginManifest {
|
|
|
123
142
|
commands?: {
|
|
124
143
|
id: string;
|
|
125
144
|
title: string;
|
|
145
|
+
description?: string;
|
|
126
146
|
action: string;
|
|
127
147
|
view?: string;
|
|
128
148
|
}[];
|
|
@@ -139,7 +159,14 @@ export interface PluginManifest {
|
|
|
139
159
|
}[];
|
|
140
160
|
guestAdapters?: {
|
|
141
161
|
id: string;
|
|
162
|
+
title?: string;
|
|
163
|
+
extensions?: string[];
|
|
142
164
|
format: string;
|
|
165
|
+
badge?: {
|
|
166
|
+
label: string;
|
|
167
|
+
backgroundColor: string;
|
|
168
|
+
textColor: string;
|
|
169
|
+
};
|
|
143
170
|
compatibilityProfile: string;
|
|
144
171
|
bootstrap: string;
|
|
145
172
|
runtime: string;
|
package/dist/music.js
CHANGED
|
@@ -61,6 +61,18 @@ export function assertResolveResult(value) {
|
|
|
61
61
|
throw new Error('Invalid playback protocol');
|
|
62
62
|
if (value.expiresAt !== undefined && !milliseconds(value.expiresAt))
|
|
63
63
|
throw new Error('Invalid playback expiry');
|
|
64
|
+
if (value.requestHeaders !== undefined) {
|
|
65
|
+
if (!record(value.requestHeaders) || Object.keys(value.requestHeaders).length > 32)
|
|
66
|
+
throw new Error('Invalid playback request headers');
|
|
67
|
+
for (const [name, headerValue] of Object.entries(value.requestHeaders)) {
|
|
68
|
+
if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/.test(name) ||
|
|
69
|
+
/^(host|connection|content-length|transfer-encoding|proxy-.*|upgrade)$/i.test(name) ||
|
|
70
|
+
typeof headerValue !== 'string' ||
|
|
71
|
+
headerValue.length > 8192 ||
|
|
72
|
+
/[\r\n]/.test(headerValue))
|
|
73
|
+
throw new Error('Invalid playback request header');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
78
|
if (!record(value.error) || !text(value.error.code, 128) || !text(value.error.message, 65536))
|
package/dist/quality.js
CHANGED
|
@@ -6,7 +6,7 @@ export function compareQualities(order, a, b) {
|
|
|
6
6
|
return left === right ? 0 : left < right ? -1 : 1;
|
|
7
7
|
}
|
|
8
8
|
export function selectQuality(order, available = order, requested) {
|
|
9
|
-
const choices = order.filter(quality => available.includes(quality));
|
|
9
|
+
const choices = order.filter((quality) => available.includes(quality));
|
|
10
10
|
if (!choices.length)
|
|
11
11
|
return undefined;
|
|
12
12
|
if (!requested || !order.includes(requested))
|
|
@@ -14,5 +14,5 @@ export function selectQuality(order, available = order, requested) {
|
|
|
14
14
|
if (choices.includes(requested))
|
|
15
15
|
return requested;
|
|
16
16
|
const index = order.indexOf(requested);
|
|
17
|
-
return choices.filter(quality => order.indexOf(quality) <= index).at(-1) ?? choices[0];
|
|
17
|
+
return choices.filter((quality) => order.indexOf(quality) <= index).at(-1) ?? choices[0];
|
|
18
18
|
}
|
package/dist/services.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface ServiceAvailability {
|
|
|
12
12
|
service: string;
|
|
13
13
|
version: string;
|
|
14
14
|
available: boolean;
|
|
15
|
+
/** When present, only these methods are connected by the Host. */
|
|
16
|
+
methods?: string[];
|
|
15
17
|
reason?: 'host-not-connected' | 'unsupported' | 'not-logged-in' | 'disabled';
|
|
16
18
|
permissionGroups: PermissionGroup[];
|
|
17
19
|
}
|
|
@@ -312,6 +314,7 @@ export interface MenuContribution {
|
|
|
312
314
|
id: string;
|
|
313
315
|
slot: 'playlist.import' | 'playlist.actions' | 'track.actions' | 'player.actions' | 'search.tools';
|
|
314
316
|
title: string;
|
|
317
|
+
description?: string;
|
|
315
318
|
commandId: string;
|
|
316
319
|
icon?: IconRef;
|
|
317
320
|
when?: {
|
package/dist/share.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { JsonObject, MaybePromise } from './manifest.js';
|
|
2
|
+
export interface ShareMusicInfo {
|
|
3
|
+
songmid?: string | number;
|
|
4
|
+
hash?: string;
|
|
5
|
+
id?: string | number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
/** Context supplied by the separate share-resolver Host, not the desktop PluginContext. */
|
|
9
|
+
export interface ShareResolverContext<Config = JsonObject> {
|
|
10
|
+
config: Readonly<Config>;
|
|
11
|
+
plugin: {
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
author?: string;
|
|
15
|
+
};
|
|
16
|
+
sources: Record<string, {
|
|
17
|
+
name: string;
|
|
18
|
+
qualitys: string[];
|
|
19
|
+
}>;
|
|
20
|
+
request<T = unknown>(url: string, options?: {
|
|
21
|
+
method?: string;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
body?: string;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
body: T;
|
|
27
|
+
statusCode: number;
|
|
28
|
+
headers: Record<string, string>;
|
|
29
|
+
}>;
|
|
30
|
+
/** Only available when the manifest declares a selected Guest adapter. */
|
|
31
|
+
guest?: {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
author?: string;
|
|
35
|
+
rawScript: string;
|
|
36
|
+
};
|
|
37
|
+
runGuest?(bindings: Record<string, unknown>): void;
|
|
38
|
+
utils: {
|
|
39
|
+
buffer: {
|
|
40
|
+
from(data: unknown, encoding?: 'base64' | 'hex' | 'utf8'): Uint8Array;
|
|
41
|
+
bufToString(data: Uint8Array, encoding?: 'base64' | 'hex' | 'utf8'): string;
|
|
42
|
+
};
|
|
43
|
+
crypto: {
|
|
44
|
+
md5(value: string): string;
|
|
45
|
+
randomBytes(size: number): Uint8Array;
|
|
46
|
+
aesEncrypt(data: unknown, mode: string, key: unknown, iv?: unknown): Uint8Array;
|
|
47
|
+
rsaEncrypt(data: string, key: string): string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface ShareResolver {
|
|
52
|
+
musicUrl(source: string, musicInfo: ShareMusicInfo, quality: string): Promise<string>;
|
|
53
|
+
}
|
|
54
|
+
export type ShareResolverEntry<Config = JsonObject> = (context: ShareResolverContext<Config>) => MaybePromise<ShareResolver>;
|
package/dist/share.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JsonValue } from './manifest.js';
|
|
2
|
+
export type PluginStorageReadKey = string | {
|
|
3
|
+
key: string;
|
|
4
|
+
pluginId?: string;
|
|
5
|
+
};
|
|
6
|
+
export type PluginStorageWriteKey = string | {
|
|
7
|
+
key: string;
|
|
8
|
+
pluginId?: string;
|
|
9
|
+
/** Omitted preserves the existing policy; new keys are private. Empty array revokes sharing. */
|
|
10
|
+
readableBy?: '*' | string[];
|
|
11
|
+
};
|
|
12
|
+
/** JSON storage. Structured keys and shared reads require a supporting desktop Host. */
|
|
13
|
+
export interface PluginStorageAPI {
|
|
14
|
+
/** Missing local keys return null. Unauthorized shared reads reject. */
|
|
15
|
+
get<T extends JsonValue = JsonValue>(key: PluginStorageReadKey): Promise<T | null>;
|
|
16
|
+
set(key: PluginStorageWriteKey, value: JsonValue): Promise<void>;
|
|
17
|
+
delete(key: PluginStorageReadKey): Promise<void>;
|
|
18
|
+
}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,128 +1,154 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@shiqianjiang/ceru-plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Typed authoring contracts for Ceru Music v2 single-file plugins",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
1
|
+
{
|
|
2
|
+
"name": "@shiqianjiang/ceru-plugin-sdk",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Typed authoring contracts for Ceru Music v2 single-file plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -b && node scripts/prepare-package.mjs",
|
|
10
|
+
"prepack": "npm run build"
|
|
11
|
+
},
|
|
8
12
|
"exports": {
|
|
9
|
-
"./quality": {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
13
|
+
"./quality": {
|
|
14
|
+
"types": "./dist/quality.d.ts",
|
|
15
|
+
"default": "./dist/quality.js"
|
|
16
|
+
},
|
|
17
|
+
"./lyrics": {
|
|
18
|
+
"types": "./dist/lyrics.d.ts",
|
|
19
|
+
"default": "./dist/lyrics.js"
|
|
20
|
+
},
|
|
21
|
+
"./guests": {
|
|
22
|
+
"types": "./dist/guests.d.ts",
|
|
23
|
+
"import": "./dist/guests.js",
|
|
24
|
+
"default": "./dist/guests.js"
|
|
25
|
+
},
|
|
26
|
+
"./share": {
|
|
27
|
+
"types": "./dist/share.d.ts",
|
|
28
|
+
"import": "./dist/share.js",
|
|
29
|
+
"default": "./dist/share.js"
|
|
30
|
+
},
|
|
31
|
+
"./storage": {
|
|
32
|
+
"types": "./dist/storage.d.ts",
|
|
33
|
+
"import": "./dist/storage.js",
|
|
34
|
+
"default": "./dist/storage.js"
|
|
35
|
+
},
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./manifest": {
|
|
42
|
+
"types": "./dist/manifest.d.ts",
|
|
43
|
+
"import": "./dist/manifest.js",
|
|
44
|
+
"default": "./dist/manifest.js"
|
|
45
|
+
},
|
|
46
|
+
"./catalog": {
|
|
47
|
+
"types": "./dist/catalog.d.ts",
|
|
48
|
+
"import": "./dist/catalog.js",
|
|
49
|
+
"default": "./dist/catalog.js"
|
|
50
|
+
},
|
|
51
|
+
"./music": {
|
|
52
|
+
"types": "./dist/music.d.ts",
|
|
53
|
+
"import": "./dist/music.js",
|
|
54
|
+
"default": "./dist/music.js"
|
|
55
|
+
},
|
|
56
|
+
"./permissions": {
|
|
57
|
+
"types": "./dist/permissions.d.ts",
|
|
58
|
+
"import": "./dist/permissions.js",
|
|
59
|
+
"default": "./dist/permissions.js"
|
|
60
|
+
},
|
|
61
|
+
"./services": {
|
|
62
|
+
"types": "./dist/services.d.ts",
|
|
63
|
+
"import": "./dist/services.js",
|
|
64
|
+
"default": "./dist/services.js"
|
|
65
|
+
},
|
|
66
|
+
"./modules": {
|
|
67
|
+
"types": "./dist/modules.d.ts",
|
|
68
|
+
"import": "./dist/modules.js",
|
|
69
|
+
"default": "./dist/modules.js"
|
|
70
|
+
},
|
|
71
|
+
"./library": {
|
|
72
|
+
"types": "./dist/library.d.ts",
|
|
73
|
+
"import": "./dist/library.js",
|
|
74
|
+
"default": "./dist/library.js"
|
|
75
|
+
},
|
|
76
|
+
"./host-library": {
|
|
77
|
+
"types": "./dist/host-library.d.ts",
|
|
78
|
+
"import": "./dist/host-library.js",
|
|
79
|
+
"default": "./dist/host-library.js"
|
|
80
|
+
},
|
|
81
|
+
"./sockets": {
|
|
82
|
+
"types": "./dist/sockets.d.ts",
|
|
83
|
+
"import": "./dist/sockets.js",
|
|
84
|
+
"default": "./dist/sockets.js"
|
|
85
|
+
},
|
|
86
|
+
"./http": {
|
|
87
|
+
"types": "./dist/http.d.ts",
|
|
88
|
+
"import": "./dist/http.js",
|
|
89
|
+
"default": "./dist/http.js"
|
|
90
|
+
},
|
|
91
|
+
"./legacy-http": {
|
|
92
|
+
"types": "./dist/legacy-http.d.ts",
|
|
93
|
+
"import": "./dist/legacy-http.js",
|
|
94
|
+
"default": "./dist/legacy-http.js"
|
|
95
|
+
},
|
|
96
|
+
"./compat/crypto": {
|
|
97
|
+
"types": "./dist/compat/crypto.d.ts",
|
|
98
|
+
"import": "./dist/compat/crypto.js",
|
|
99
|
+
"default": "./dist/compat/crypto.js"
|
|
100
|
+
},
|
|
101
|
+
"./compat/zlib": {
|
|
102
|
+
"types": "./dist/compat/zlib.d.ts",
|
|
103
|
+
"import": "./dist/compat/zlib.js",
|
|
104
|
+
"default": "./dist/compat/zlib.js"
|
|
105
|
+
},
|
|
106
|
+
"./compat/encoding": {
|
|
107
|
+
"types": "./dist/compat/encoding.d.ts",
|
|
108
|
+
"import": "./dist/compat/encoding.js",
|
|
109
|
+
"default": "./dist/compat/encoding.js"
|
|
110
|
+
},
|
|
111
|
+
"./compat/format": {
|
|
112
|
+
"types": "./dist/compat/format.d.ts",
|
|
113
|
+
"import": "./dist/compat/format.js",
|
|
114
|
+
"default": "./dist/compat/format.js"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"files": [
|
|
118
|
+
"dist",
|
|
119
|
+
"README.md",
|
|
120
|
+
"CHANGELOG.md",
|
|
121
|
+
"LICENSE"
|
|
122
|
+
],
|
|
123
|
+
"license": "MIT",
|
|
124
|
+
"dependencies": {
|
|
125
|
+
"@types/lodash": "^4.17.25",
|
|
126
|
+
"buffer": "^6.0.3",
|
|
127
|
+
"crypto-js": "^4.2.0",
|
|
128
|
+
"fflate": "^0.8.2",
|
|
129
|
+
"json5": "^2.2.3"
|
|
130
|
+
},
|
|
131
|
+
"author": "澜音团队",
|
|
132
|
+
"engines": {
|
|
133
|
+
"node": ">=22.12.0"
|
|
134
|
+
},
|
|
135
|
+
"publishConfig": {
|
|
136
|
+
"access": "public",
|
|
137
|
+
"registry": "https://registry.npmjs.org/"
|
|
138
|
+
},
|
|
139
|
+
"repository": {
|
|
140
|
+
"type": "git",
|
|
141
|
+
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
142
|
+
"directory": "packages/sdk"
|
|
143
|
+
},
|
|
144
|
+
"bugs": {
|
|
145
|
+
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
146
|
+
},
|
|
147
|
+
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
148
|
+
"keywords": [
|
|
149
|
+
"ceru-music",
|
|
150
|
+
"plugin",
|
|
151
|
+
"typescript",
|
|
152
|
+
"electron"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
File without changes
|