@shiqianjiang/ceru-plugin-cli 0.1.2 → 0.2.0
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 +6 -6
- package/assets/core-contracts.js +1 -0
- package/assets/index.html +94 -93
- package/assets/playground.js +293 -30
- package/assets/sandbox.js +50 -19
- package/assets/style.css +16 -0
- package/dist/dependencies.d.ts +6 -0
- package/dist/dependencies.js +45 -0
- package/dist/dev.js +214 -119
- package/dist/index.js +5 -3
- package/dist/project.js +41 -16
- package/dist/socket-broker.d.ts +23 -0
- package/dist/socket-broker.js +230 -0
- package/package.json +71 -67
- package/schemas/config.schema.json +347 -0
- package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/js/package.json +2 -2
- package/templates/connected-library/js/src/index.js +7 -5
- package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/ts/package.json +2 -2
- package/templates/connected-library/ts/src/index.ts +7 -5
- package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/js/package.json +2 -2
- package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/ts/package.json +2 -2
- package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/js/README.md +1 -1
- package/templates/importer/js/ceru.plugin.json +8 -24
- package/templates/importer/js/package.json +2 -2
- package/templates/importer/js/src/index.js +28 -34
- package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/ts/README.md +1 -1
- package/templates/importer/ts/ceru.plugin.json +8 -24
- package/templates/importer/ts/package.json +2 -2
- package/templates/importer/ts/src/index.ts +28 -34
- package/templates/react/js/.vscode/ceru.code-snippets +37 -9
- package/templates/react/js/package.json +2 -2
- package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/react/ts/package.json +2 -2
- package/templates/snapshot.json +4 -2
- package/templates/source/js/.vscode/ceru.code-snippets +37 -9
- package/templates/source/js/ceru.plugin.json +9 -0
- package/templates/source/js/package.json +2 -2
- package/templates/source/js/src/index.js +29 -26
- package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/source/ts/ceru.plugin.json +9 -0
- package/templates/source/ts/package.json +2 -2
- package/templates/source/ts/src/index.ts +29 -26
- package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/js/package.json +2 -2
- package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/ts/package.json +2 -2
- package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/js/package.json +2 -2
- package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/ts/package.json +2 -2
- package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/js/package.json +2 -2
- package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/ts/package.json +2 -2
- package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/js/ceru.plugin.json +9 -0
- package/templates/web-surface/js/package.json +2 -2
- package/templates/web-surface/js/src/view.js +4 -1
- package/templates/web-surface/js/ui/search-note.css +3 -0
- package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/ts/ceru.plugin.json +9 -0
- package/templates/web-surface/ts/package.json +2 -2
- package/templates/web-surface/ts/src/view.ts +4 -1
- package/templates/web-surface/ts/ui/search-note.css +3 -0
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Host platform icon": {
|
|
3
3
|
"prefix": "ceru-icon",
|
|
4
|
-
"body": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"description": "使用宿主平台图标,无需打入插件"
|
|
4
|
+
"body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
|
|
5
|
+
"description": "使用宿主平台图标,无需打入插件",
|
|
8
6
|
},
|
|
9
7
|
"Host lodash": {
|
|
10
8
|
"prefix": "ceru-lodash",
|
|
9
|
+
"body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
|
|
10
|
+
"description": "调用宿主的带类型 Lodash 工具",
|
|
11
|
+
},
|
|
12
|
+
"Host HTTP client": {
|
|
13
|
+
"prefix": "ceru-http",
|
|
14
|
+
"body": [
|
|
15
|
+
"const http = ctx.http.create({",
|
|
16
|
+
" baseURL: '${1:https://example.com}',",
|
|
17
|
+
" permissionKey: '${2:api}',",
|
|
18
|
+
" requestPermission: true,",
|
|
19
|
+
"})",
|
|
20
|
+
],
|
|
21
|
+
"description": "使用宿主 Axios 代理;无需将请求库打入插件",
|
|
22
|
+
},
|
|
23
|
+
"Permission group": {
|
|
24
|
+
"prefix": "ceru-permission-group",
|
|
11
25
|
"body": [
|
|
12
|
-
"ctx.
|
|
26
|
+
"const permission = await ctx.permissions.requestGroup({",
|
|
27
|
+
" group: '${1:libraryRead}',",
|
|
28
|
+
" intent: operation.userIntent,",
|
|
29
|
+
"})",
|
|
13
30
|
],
|
|
14
|
-
"description": "
|
|
31
|
+
"description": "一次申请一组用户可理解的能力",
|
|
32
|
+
},
|
|
33
|
+
"Grouped music provider": {
|
|
34
|
+
"prefix": "ceru-provider",
|
|
35
|
+
"body": [
|
|
36
|
+
"ctx.providers.register('${1:catalog}', {",
|
|
37
|
+
" tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
|
|
38
|
+
" playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
|
|
39
|
+
" charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
|
|
40
|
+
"})",
|
|
41
|
+
],
|
|
42
|
+
"description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
|
|
15
43
|
},
|
|
16
44
|
"Source rate limit": {
|
|
17
45
|
"prefix": "ceru-rate-limit",
|
|
@@ -20,8 +48,8 @@
|
|
|
20
48
|
" code: 'RATE_LIMITED',",
|
|
21
49
|
" message: '${1:请稍后重试}',",
|
|
22
50
|
" recovery: { mode: 'await-user', maxWaitMs: 60000 }",
|
|
23
|
-
"})"
|
|
51
|
+
"})",
|
|
24
52
|
],
|
|
25
|
-
"description": "返回结构化限流结果,由 Host 决定换源与交互"
|
|
26
|
-
}
|
|
53
|
+
"description": "返回结构化限流结果,由 Host 决定换源与交互",
|
|
54
|
+
},
|
|
27
55
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.2.0",
|
|
18
18
|
"typescript": "~5.9.3",
|
|
19
19
|
"electron": "^44.4.2",
|
|
20
20
|
"prettier": "^3.6.2"
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Host platform icon": {
|
|
3
3
|
"prefix": "ceru-icon",
|
|
4
|
-
"body": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"description": "使用宿主平台图标,无需打入插件"
|
|
4
|
+
"body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
|
|
5
|
+
"description": "使用宿主平台图标,无需打入插件",
|
|
8
6
|
},
|
|
9
7
|
"Host lodash": {
|
|
10
8
|
"prefix": "ceru-lodash",
|
|
9
|
+
"body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
|
|
10
|
+
"description": "调用宿主的带类型 Lodash 工具",
|
|
11
|
+
},
|
|
12
|
+
"Host HTTP client": {
|
|
13
|
+
"prefix": "ceru-http",
|
|
14
|
+
"body": [
|
|
15
|
+
"const http = ctx.http.create({",
|
|
16
|
+
" baseURL: '${1:https://example.com}',",
|
|
17
|
+
" permissionKey: '${2:api}',",
|
|
18
|
+
" requestPermission: true,",
|
|
19
|
+
"})",
|
|
20
|
+
],
|
|
21
|
+
"description": "使用宿主 Axios 代理;无需将请求库打入插件",
|
|
22
|
+
},
|
|
23
|
+
"Permission group": {
|
|
24
|
+
"prefix": "ceru-permission-group",
|
|
11
25
|
"body": [
|
|
12
|
-
"ctx.
|
|
26
|
+
"const permission = await ctx.permissions.requestGroup({",
|
|
27
|
+
" group: '${1:libraryRead}',",
|
|
28
|
+
" intent: operation.userIntent,",
|
|
29
|
+
"})",
|
|
13
30
|
],
|
|
14
|
-
"description": "
|
|
31
|
+
"description": "一次申请一组用户可理解的能力",
|
|
32
|
+
},
|
|
33
|
+
"Grouped music provider": {
|
|
34
|
+
"prefix": "ceru-provider",
|
|
35
|
+
"body": [
|
|
36
|
+
"ctx.providers.register('${1:catalog}', {",
|
|
37
|
+
" tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
|
|
38
|
+
" playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
|
|
39
|
+
" charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
|
|
40
|
+
"})",
|
|
41
|
+
],
|
|
42
|
+
"description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
|
|
15
43
|
},
|
|
16
44
|
"Source rate limit": {
|
|
17
45
|
"prefix": "ceru-rate-limit",
|
|
@@ -20,8 +48,8 @@
|
|
|
20
48
|
" code: 'RATE_LIMITED',",
|
|
21
49
|
" message: '${1:请稍后重试}',",
|
|
22
50
|
" recovery: { mode: 'await-user', maxWaitMs: 60000 }",
|
|
23
|
-
"})"
|
|
51
|
+
"})",
|
|
24
52
|
],
|
|
25
|
-
"description": "返回结构化限流结果,由 Host 决定换源与交互"
|
|
26
|
-
}
|
|
53
|
+
"description": "返回结构化限流结果,由 Host 决定换源与交互",
|
|
54
|
+
},
|
|
27
55
|
}
|
|
@@ -14,33 +14,22 @@
|
|
|
14
14
|
"logic": {
|
|
15
15
|
"entry": "logic.main",
|
|
16
16
|
"activation": ["onCommand:hello"]
|
|
17
|
-
}
|
|
18
|
-
"surfaces": [
|
|
19
|
-
{
|
|
20
|
-
"id": "settings",
|
|
21
|
-
"kind": "schema",
|
|
22
|
-
"entry": "schema.settings"
|
|
23
|
-
}
|
|
24
|
-
]
|
|
17
|
+
}
|
|
25
18
|
},
|
|
26
19
|
"contributes": {
|
|
27
20
|
"commands": [
|
|
28
21
|
{
|
|
29
22
|
"id": "hello",
|
|
30
|
-
"title": "
|
|
23
|
+
"title": "打开歌单导入",
|
|
31
24
|
"action": "hello"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"id": "prepare-import",
|
|
35
|
-
"title": "预览导入",
|
|
36
|
-
"action": "import.prepare"
|
|
37
25
|
}
|
|
38
26
|
],
|
|
39
|
-
"
|
|
27
|
+
"playlistImporters": [
|
|
40
28
|
{
|
|
41
|
-
"id": "
|
|
42
|
-
"title": "
|
|
43
|
-
"
|
|
29
|
+
"id": "text-list",
|
|
30
|
+
"title": "从文本清单导入(演示)",
|
|
31
|
+
"description": "复用宿主歌单导入窗口;每行一个标题",
|
|
32
|
+
"placeholder": "输入标题,以逗号分隔"
|
|
44
33
|
}
|
|
45
34
|
]
|
|
46
35
|
},
|
|
@@ -53,11 +42,6 @@
|
|
|
53
42
|
"entries": {
|
|
54
43
|
"logic.main": "src/index.js"
|
|
55
44
|
},
|
|
56
|
-
"resources": {
|
|
57
|
-
"schema.settings": {
|
|
58
|
-
"path": "ui/settings.json",
|
|
59
|
-
"type": "json"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
45
|
+
"resources": {},
|
|
62
46
|
"output": "dist/plugin.js"
|
|
63
47
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.2.0",
|
|
18
18
|
"typescript": "~5.9.3",
|
|
19
19
|
"electron": "^44.4.2",
|
|
20
20
|
"prettier": "^3.6.2"
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
|
|
2
2
|
|
|
3
|
-
export default definePlugin(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await ctx.ui.setState('settings', {
|
|
32
|
-
titles: text,
|
|
33
|
-
preview: '去重后共 ' + titles.length + ' 首:' + titles.join(' / '),
|
|
34
|
-
})
|
|
35
|
-
return plan
|
|
36
|
-
})
|
|
3
|
+
export default definePlugin((ctx) => {
|
|
4
|
+
ctx.effects.add(
|
|
5
|
+
ctx.playlistImporters.register('text-list', {
|
|
6
|
+
async getTracks(request) {
|
|
7
|
+
// Demo metadata only. A real importer resolves platform links and returns track IDs.
|
|
8
|
+
const titles = ctx.utils.lodash.uniq(
|
|
9
|
+
request.value
|
|
10
|
+
.split(/[,,\n]+/)
|
|
11
|
+
.map((title) => title.trim())
|
|
12
|
+
.filter(Boolean),
|
|
13
|
+
)
|
|
14
|
+
return {
|
|
15
|
+
name: '文本清单',
|
|
16
|
+
items: titles.map((title) => ({
|
|
17
|
+
ref: { pluginId: ctx.plugin.id, providerId: 'text-list', kind: 'track', id: title },
|
|
18
|
+
title,
|
|
19
|
+
playable: false,
|
|
20
|
+
metadata: { artists: [] },
|
|
21
|
+
capabilities: [],
|
|
22
|
+
})),
|
|
23
|
+
totalEstimate: titles.length,
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
28
|
+
ctx.effects.add(
|
|
29
|
+
ctx.actions.register('hello', () => ctx.ui.playlistImport.open({ importerId: 'text-list' })),
|
|
30
|
+
)
|
|
37
31
|
})
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Host platform icon": {
|
|
3
3
|
"prefix": "ceru-icon",
|
|
4
|
-
"body": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"description": "使用宿主平台图标,无需打入插件"
|
|
4
|
+
"body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
|
|
5
|
+
"description": "使用宿主平台图标,无需打入插件",
|
|
8
6
|
},
|
|
9
7
|
"Host lodash": {
|
|
10
8
|
"prefix": "ceru-lodash",
|
|
9
|
+
"body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
|
|
10
|
+
"description": "调用宿主的带类型 Lodash 工具",
|
|
11
|
+
},
|
|
12
|
+
"Host HTTP client": {
|
|
13
|
+
"prefix": "ceru-http",
|
|
14
|
+
"body": [
|
|
15
|
+
"const http = ctx.http.create({",
|
|
16
|
+
" baseURL: '${1:https://example.com}',",
|
|
17
|
+
" permissionKey: '${2:api}',",
|
|
18
|
+
" requestPermission: true,",
|
|
19
|
+
"})",
|
|
20
|
+
],
|
|
21
|
+
"description": "使用宿主 Axios 代理;无需将请求库打入插件",
|
|
22
|
+
},
|
|
23
|
+
"Permission group": {
|
|
24
|
+
"prefix": "ceru-permission-group",
|
|
11
25
|
"body": [
|
|
12
|
-
"ctx.
|
|
26
|
+
"const permission = await ctx.permissions.requestGroup({",
|
|
27
|
+
" group: '${1:libraryRead}',",
|
|
28
|
+
" intent: operation.userIntent,",
|
|
29
|
+
"})",
|
|
13
30
|
],
|
|
14
|
-
"description": "
|
|
31
|
+
"description": "一次申请一组用户可理解的能力",
|
|
32
|
+
},
|
|
33
|
+
"Grouped music provider": {
|
|
34
|
+
"prefix": "ceru-provider",
|
|
35
|
+
"body": [
|
|
36
|
+
"ctx.providers.register('${1:catalog}', {",
|
|
37
|
+
" tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
|
|
38
|
+
" playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
|
|
39
|
+
" charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
|
|
40
|
+
"})",
|
|
41
|
+
],
|
|
42
|
+
"description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
|
|
15
43
|
},
|
|
16
44
|
"Source rate limit": {
|
|
17
45
|
"prefix": "ceru-rate-limit",
|
|
@@ -20,8 +48,8 @@
|
|
|
20
48
|
" code: 'RATE_LIMITED',",
|
|
21
49
|
" message: '${1:请稍后重试}',",
|
|
22
50
|
" recovery: { mode: 'await-user', maxWaitMs: 60000 }",
|
|
23
|
-
"})"
|
|
51
|
+
"})",
|
|
24
52
|
],
|
|
25
|
-
"description": "返回结构化限流结果,由 Host 决定换源与交互"
|
|
26
|
-
}
|
|
53
|
+
"description": "返回结构化限流结果,由 Host 决定换源与交互",
|
|
54
|
+
},
|
|
27
55
|
}
|
|
@@ -14,33 +14,22 @@
|
|
|
14
14
|
"logic": {
|
|
15
15
|
"entry": "logic.main",
|
|
16
16
|
"activation": ["onCommand:hello"]
|
|
17
|
-
}
|
|
18
|
-
"surfaces": [
|
|
19
|
-
{
|
|
20
|
-
"id": "settings",
|
|
21
|
-
"kind": "schema",
|
|
22
|
-
"entry": "schema.settings"
|
|
23
|
-
}
|
|
24
|
-
]
|
|
17
|
+
}
|
|
25
18
|
},
|
|
26
19
|
"contributes": {
|
|
27
20
|
"commands": [
|
|
28
21
|
{
|
|
29
22
|
"id": "hello",
|
|
30
|
-
"title": "
|
|
23
|
+
"title": "打开歌单导入",
|
|
31
24
|
"action": "hello"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"id": "prepare-import",
|
|
35
|
-
"title": "预览导入",
|
|
36
|
-
"action": "import.prepare"
|
|
37
25
|
}
|
|
38
26
|
],
|
|
39
|
-
"
|
|
27
|
+
"playlistImporters": [
|
|
40
28
|
{
|
|
41
|
-
"id": "
|
|
42
|
-
"title": "
|
|
43
|
-
"
|
|
29
|
+
"id": "text-list",
|
|
30
|
+
"title": "从文本清单导入(演示)",
|
|
31
|
+
"description": "复用宿主歌单导入窗口;每行一个标题",
|
|
32
|
+
"placeholder": "输入标题,以逗号分隔"
|
|
44
33
|
}
|
|
45
34
|
]
|
|
46
35
|
},
|
|
@@ -53,11 +42,6 @@
|
|
|
53
42
|
"entries": {
|
|
54
43
|
"logic.main": "src/index.ts"
|
|
55
44
|
},
|
|
56
|
-
"resources": {
|
|
57
|
-
"schema.settings": {
|
|
58
|
-
"path": "ui/settings.json",
|
|
59
|
-
"type": "json"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
45
|
+
"resources": {},
|
|
62
46
|
"output": "dist/plugin.js"
|
|
63
47
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.2.0",
|
|
18
18
|
"typescript": "~5.9.3",
|
|
19
19
|
"electron": "^44.4.2",
|
|
20
20
|
"prettier": "^3.6.2"
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
|
|
2
2
|
|
|
3
|
-
export default definePlugin(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await ctx.ui.setState('settings', {
|
|
32
|
-
titles: text,
|
|
33
|
-
preview: '去重后共 ' + titles.length + ' 首:' + titles.join(' / '),
|
|
34
|
-
})
|
|
35
|
-
return plan
|
|
36
|
-
})
|
|
3
|
+
export default definePlugin((ctx) => {
|
|
4
|
+
ctx.effects.add(
|
|
5
|
+
ctx.playlistImporters.register('text-list', {
|
|
6
|
+
async getTracks(request) {
|
|
7
|
+
// Demo metadata only. A real importer resolves platform links and returns track IDs.
|
|
8
|
+
const titles = ctx.utils.lodash.uniq(
|
|
9
|
+
request.value
|
|
10
|
+
.split(/[,,\n]+/)
|
|
11
|
+
.map((title) => title.trim())
|
|
12
|
+
.filter(Boolean),
|
|
13
|
+
)
|
|
14
|
+
return {
|
|
15
|
+
name: '文本清单',
|
|
16
|
+
items: titles.map((title) => ({
|
|
17
|
+
ref: { pluginId: ctx.plugin.id, providerId: 'text-list', kind: 'track', id: title },
|
|
18
|
+
title,
|
|
19
|
+
playable: false,
|
|
20
|
+
metadata: { artists: [] },
|
|
21
|
+
capabilities: [],
|
|
22
|
+
})),
|
|
23
|
+
totalEstimate: titles.length,
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
28
|
+
ctx.effects.add(
|
|
29
|
+
ctx.actions.register('hello', () => ctx.ui.playlistImport.open({ importerId: 'text-list' })),
|
|
30
|
+
)
|
|
37
31
|
})
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Host platform icon": {
|
|
3
3
|
"prefix": "ceru-icon",
|
|
4
|
-
"body": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"description": "使用宿主平台图标,无需打入插件"
|
|
4
|
+
"body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
|
|
5
|
+
"description": "使用宿主平台图标,无需打入插件",
|
|
8
6
|
},
|
|
9
7
|
"Host lodash": {
|
|
10
8
|
"prefix": "ceru-lodash",
|
|
9
|
+
"body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
|
|
10
|
+
"description": "调用宿主的带类型 Lodash 工具",
|
|
11
|
+
},
|
|
12
|
+
"Host HTTP client": {
|
|
13
|
+
"prefix": "ceru-http",
|
|
14
|
+
"body": [
|
|
15
|
+
"const http = ctx.http.create({",
|
|
16
|
+
" baseURL: '${1:https://example.com}',",
|
|
17
|
+
" permissionKey: '${2:api}',",
|
|
18
|
+
" requestPermission: true,",
|
|
19
|
+
"})",
|
|
20
|
+
],
|
|
21
|
+
"description": "使用宿主 Axios 代理;无需将请求库打入插件",
|
|
22
|
+
},
|
|
23
|
+
"Permission group": {
|
|
24
|
+
"prefix": "ceru-permission-group",
|
|
11
25
|
"body": [
|
|
12
|
-
"ctx.
|
|
26
|
+
"const permission = await ctx.permissions.requestGroup({",
|
|
27
|
+
" group: '${1:libraryRead}',",
|
|
28
|
+
" intent: operation.userIntent,",
|
|
29
|
+
"})",
|
|
13
30
|
],
|
|
14
|
-
"description": "
|
|
31
|
+
"description": "一次申请一组用户可理解的能力",
|
|
32
|
+
},
|
|
33
|
+
"Grouped music provider": {
|
|
34
|
+
"prefix": "ceru-provider",
|
|
35
|
+
"body": [
|
|
36
|
+
"ctx.providers.register('${1:catalog}', {",
|
|
37
|
+
" tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
|
|
38
|
+
" playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
|
|
39
|
+
" charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
|
|
40
|
+
"})",
|
|
41
|
+
],
|
|
42
|
+
"description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
|
|
15
43
|
},
|
|
16
44
|
"Source rate limit": {
|
|
17
45
|
"prefix": "ceru-rate-limit",
|
|
@@ -20,8 +48,8 @@
|
|
|
20
48
|
" code: 'RATE_LIMITED',",
|
|
21
49
|
" message: '${1:请稍后重试}',",
|
|
22
50
|
" recovery: { mode: 'await-user', maxWaitMs: 60000 }",
|
|
23
|
-
"})"
|
|
51
|
+
"})",
|
|
24
52
|
],
|
|
25
|
-
"description": "返回结构化限流结果,由 Host 决定换源与交互"
|
|
26
|
-
}
|
|
53
|
+
"description": "返回结构化限流结果,由 Host 决定换源与交互",
|
|
54
|
+
},
|
|
27
55
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.2.0",
|
|
18
18
|
"typescript": "~5.9.3",
|
|
19
19
|
"electron": "^44.4.2",
|
|
20
20
|
"prettier": "^3.6.2",
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Host platform icon": {
|
|
3
3
|
"prefix": "ceru-icon",
|
|
4
|
-
"body": [
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
"description": "使用宿主平台图标,无需打入插件"
|
|
4
|
+
"body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
|
|
5
|
+
"description": "使用宿主平台图标,无需打入插件",
|
|
8
6
|
},
|
|
9
7
|
"Host lodash": {
|
|
10
8
|
"prefix": "ceru-lodash",
|
|
9
|
+
"body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
|
|
10
|
+
"description": "调用宿主的带类型 Lodash 工具",
|
|
11
|
+
},
|
|
12
|
+
"Host HTTP client": {
|
|
13
|
+
"prefix": "ceru-http",
|
|
14
|
+
"body": [
|
|
15
|
+
"const http = ctx.http.create({",
|
|
16
|
+
" baseURL: '${1:https://example.com}',",
|
|
17
|
+
" permissionKey: '${2:api}',",
|
|
18
|
+
" requestPermission: true,",
|
|
19
|
+
"})",
|
|
20
|
+
],
|
|
21
|
+
"description": "使用宿主 Axios 代理;无需将请求库打入插件",
|
|
22
|
+
},
|
|
23
|
+
"Permission group": {
|
|
24
|
+
"prefix": "ceru-permission-group",
|
|
11
25
|
"body": [
|
|
12
|
-
"ctx.
|
|
26
|
+
"const permission = await ctx.permissions.requestGroup({",
|
|
27
|
+
" group: '${1:libraryRead}',",
|
|
28
|
+
" intent: operation.userIntent,",
|
|
29
|
+
"})",
|
|
13
30
|
],
|
|
14
|
-
"description": "
|
|
31
|
+
"description": "一次申请一组用户可理解的能力",
|
|
32
|
+
},
|
|
33
|
+
"Grouped music provider": {
|
|
34
|
+
"prefix": "ceru-provider",
|
|
35
|
+
"body": [
|
|
36
|
+
"ctx.providers.register('${1:catalog}', {",
|
|
37
|
+
" tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
|
|
38
|
+
" playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
|
|
39
|
+
" charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
|
|
40
|
+
"})",
|
|
41
|
+
],
|
|
42
|
+
"description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
|
|
15
43
|
},
|
|
16
44
|
"Source rate limit": {
|
|
17
45
|
"prefix": "ceru-rate-limit",
|
|
@@ -20,8 +48,8 @@
|
|
|
20
48
|
" code: 'RATE_LIMITED',",
|
|
21
49
|
" message: '${1:请稍后重试}',",
|
|
22
50
|
" recovery: { mode: 'await-user', maxWaitMs: 60000 }",
|
|
23
|
-
"})"
|
|
51
|
+
"})",
|
|
24
52
|
],
|
|
25
|
-
"description": "返回结构化限流结果,由 Host 决定换源与交互"
|
|
26
|
-
}
|
|
53
|
+
"description": "返回结构化限流结果,由 Host 决定换源与交互",
|
|
54
|
+
},
|
|
27
55
|
}
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.2.0",
|
|
18
18
|
"typescript": "~5.9.3",
|
|
19
19
|
"electron": "^44.4.2",
|
|
20
20
|
"prettier": "^3.6.2",
|