@shiqianjiang/ceru-plugin-cli 0.1.2 → 0.2.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.
Files changed (70) hide show
  1. package/README.md +6 -6
  2. package/assets/core-contracts.js +1 -0
  3. package/assets/index.html +94 -93
  4. package/assets/playground.js +293 -30
  5. package/assets/sandbox.js +50 -19
  6. package/assets/style.css +16 -0
  7. package/dist/dependencies.d.ts +6 -0
  8. package/dist/dependencies.js +45 -0
  9. package/dist/dev.js +214 -119
  10. package/dist/index.js +5 -3
  11. package/dist/project.js +41 -16
  12. package/dist/socket-broker.d.ts +23 -0
  13. package/dist/socket-broker.js +230 -0
  14. package/package.json +71 -67
  15. package/schemas/config.schema.json +347 -0
  16. package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
  17. package/templates/connected-library/js/package.json +2 -2
  18. package/templates/connected-library/js/src/index.js +7 -5
  19. package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
  20. package/templates/connected-library/ts/package.json +2 -2
  21. package/templates/connected-library/ts/src/index.ts +7 -5
  22. package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
  23. package/templates/guest-adapter/js/package.json +2 -2
  24. package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
  25. package/templates/guest-adapter/ts/package.json +2 -2
  26. package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
  27. package/templates/importer/js/README.md +1 -1
  28. package/templates/importer/js/ceru.plugin.json +8 -24
  29. package/templates/importer/js/package.json +2 -2
  30. package/templates/importer/js/src/index.js +28 -34
  31. package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
  32. package/templates/importer/ts/README.md +1 -1
  33. package/templates/importer/ts/ceru.plugin.json +8 -24
  34. package/templates/importer/ts/package.json +2 -2
  35. package/templates/importer/ts/src/index.ts +28 -34
  36. package/templates/react/js/.vscode/ceru.code-snippets +37 -9
  37. package/templates/react/js/package.json +2 -2
  38. package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
  39. package/templates/react/ts/package.json +2 -2
  40. package/templates/snapshot.json +4 -2
  41. package/templates/source/js/.vscode/ceru.code-snippets +37 -9
  42. package/templates/source/js/ceru.plugin.json +9 -0
  43. package/templates/source/js/package.json +2 -2
  44. package/templates/source/js/src/index.js +29 -26
  45. package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
  46. package/templates/source/ts/ceru.plugin.json +9 -0
  47. package/templates/source/ts/package.json +2 -2
  48. package/templates/source/ts/src/index.ts +29 -26
  49. package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
  50. package/templates/vue/js/package.json +2 -2
  51. package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
  52. package/templates/vue/ts/package.json +2 -2
  53. package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
  54. package/templates/vue-tsx/js/package.json +2 -2
  55. package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
  56. package/templates/vue-tsx/ts/package.json +2 -2
  57. package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
  58. package/templates/web-dist/js/package.json +2 -2
  59. package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
  60. package/templates/web-dist/ts/package.json +2 -2
  61. package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
  62. package/templates/web-surface/js/ceru.plugin.json +9 -0
  63. package/templates/web-surface/js/package.json +2 -2
  64. package/templates/web-surface/js/src/view.js +4 -1
  65. package/templates/web-surface/js/ui/search-note.css +3 -0
  66. package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
  67. package/templates/web-surface/ts/ceru.plugin.json +9 -0
  68. package/templates/web-surface/ts/package.json +2 -2
  69. package/templates/web-surface/ts/src/view.ts +4 -1
  70. package/templates/web-surface/ts/ui/search-note.css +3 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 1,
3
3
  "source": "https://github.com/CeruMusic/CeruMusic-Plugin-Template",
4
- "digest": "sha256:38b4adec63d19fa7d642827faa6d100b8c75a8880a32cfd4a7f0dde6e42e6b22",
4
+ "digest": "sha256:eb68b7d77e117cdbc4cf8e9fff3b0bc5d99d5aa67d962f5821ebdbb16960c63e",
5
5
  "files": [
6
6
  "connected-library/js/_gitignore",
7
7
  "connected-library/js/.prettierrc.json",
@@ -257,6 +257,7 @@
257
257
  "web-surface/js/src/index.js",
258
258
  "web-surface/js/src/view.js",
259
259
  "web-surface/js/tsconfig.json",
260
+ "web-surface/js/ui/search-note.css",
260
261
  "web-surface/ts/_gitignore",
261
262
  "web-surface/ts/.prettierrc.json",
262
263
  "web-surface/ts/.vscode/ceru.code-snippets",
@@ -270,6 +271,7 @@
270
271
  "web-surface/ts/README.md",
271
272
  "web-surface/ts/src/index.ts",
272
273
  "web-surface/ts/src/view.ts",
273
- "web-surface/ts/tsconfig.json"
274
+ "web-surface/ts/tsconfig.json",
275
+ "web-surface/ts/ui/search-note.css"
274
276
  ]
275
277
  }
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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
  }
@@ -35,6 +35,15 @@
35
35
  },
36
36
  "connectionMode": "none"
37
37
  }
38
+ ],
39
+ "homeSections": [
40
+ {
41
+ "id": "catalog-playlists",
42
+ "title": "歌单",
43
+ "kind": "playlists",
44
+ "icon": { "kind": "host", "name": "library" },
45
+ "providerIds": ["catalog"]
46
+ }
38
47
  ]
39
48
  },
40
49
  "permissions": [],
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.1",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2"
@@ -17,34 +17,37 @@ export default definePlugin((ctx) => {
17
17
  })
18
18
 
19
19
  ctx.providers.register('catalog', {
20
- async search(request) {
21
- const query = ctx.utils.lodash.trim(request.query).toLowerCase()
22
- const matches = tracks.filter((track) =>
23
- (track.title + ' ' + track.artist).toLowerCase().includes(query),
24
- )
20
+ tracks: {
21
+ async search(request) {
22
+ const query = ctx.utils.lodash.trim(request.query).toLowerCase()
23
+ const matches = tracks.filter((track) =>
24
+ (track.title + ' ' + track.artist).toLowerCase().includes(query),
25
+ )
25
26
 
26
- return {
27
- items: matches.slice(0, Math.max(1, Math.min(request.limit, 100))).map((track) => ({
28
- ref: {
29
- pluginId: ctx.plugin.id,
30
- providerId: 'catalog',
31
- kind: 'track',
32
- id: track.id,
33
- },
34
- title: track.title,
35
- subtitle: track.artist,
36
- playable: false,
37
- capabilities: [],
38
- })),
39
- }
40
- },
27
+ return {
28
+ items: matches.slice(0, Math.max(1, Math.min(request.limit, 100))).map((track) => ({
29
+ ref: {
30
+ pluginId: ctx.plugin.id,
31
+ providerId: 'catalog',
32
+ kind: 'track',
33
+ id: track.id,
34
+ },
35
+ title: track.title,
36
+ subtitle: track.artist,
37
+ playable: false,
38
+ metadata: { artists: [track.artist] },
39
+ capabilities: [],
40
+ })),
41
+ }
42
+ },
41
43
 
42
- async resolve() {
43
- // 演示不会伪造播放地址。真实解析器应返回 Host 发放的 MediaLease。
44
- return ctx.playback.failure({
45
- code: 'UNSUPPORTED',
46
- message: '这是本地搜索 demo,尚未连接真实的音源服务。',
47
- })
44
+ async resolve() {
45
+ // 演示不会伪造播放地址。真实解析器返回 { ok: true, url, expiresAt? }。
46
+ return ctx.playback.failure({
47
+ code: 'UNSUPPORTED',
48
+ message: '这是本地搜索 demo,尚未连接真实的音源服务。',
49
+ })
50
+ },
48
51
  },
49
52
  })
50
53
  })
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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
  }
@@ -35,6 +35,15 @@
35
35
  },
36
36
  "connectionMode": "none"
37
37
  }
38
+ ],
39
+ "homeSections": [
40
+ {
41
+ "id": "catalog-playlists",
42
+ "title": "歌单",
43
+ "kind": "playlists",
44
+ "icon": { "kind": "host", "name": "library" },
45
+ "providerIds": ["catalog"]
46
+ }
38
47
  ]
39
48
  },
40
49
  "permissions": [],
@@ -11,10 +11,10 @@
11
11
  "preview": "ceru-plugin preview dist/plugin.js"
12
12
  },
13
13
  "dependencies": {
14
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.1",
18
18
  "typescript": "~5.9.3",
19
19
  "electron": "^44.4.2",
20
20
  "prettier": "^3.6.2"
@@ -17,34 +17,37 @@ export default definePlugin((ctx) => {
17
17
  })
18
18
 
19
19
  ctx.providers.register('catalog', {
20
- async search(request) {
21
- const query = ctx.utils.lodash.trim(request.query).toLowerCase()
22
- const matches = tracks.filter((track) =>
23
- (track.title + ' ' + track.artist).toLowerCase().includes(query),
24
- )
20
+ tracks: {
21
+ async search(request) {
22
+ const query = ctx.utils.lodash.trim(request.query).toLowerCase()
23
+ const matches = tracks.filter((track) =>
24
+ (track.title + ' ' + track.artist).toLowerCase().includes(query),
25
+ )
25
26
 
26
- return {
27
- items: matches.slice(0, Math.max(1, Math.min(request.limit, 100))).map((track) => ({
28
- ref: {
29
- pluginId: ctx.plugin.id,
30
- providerId: 'catalog',
31
- kind: 'track',
32
- id: track.id,
33
- },
34
- title: track.title,
35
- subtitle: track.artist,
36
- playable: false,
37
- capabilities: [],
38
- })),
39
- }
40
- },
27
+ return {
28
+ items: matches.slice(0, Math.max(1, Math.min(request.limit, 100))).map((track) => ({
29
+ ref: {
30
+ pluginId: ctx.plugin.id,
31
+ providerId: 'catalog',
32
+ kind: 'track',
33
+ id: track.id,
34
+ },
35
+ title: track.title,
36
+ subtitle: track.artist,
37
+ playable: false,
38
+ metadata: { artists: [track.artist] },
39
+ capabilities: [],
40
+ })),
41
+ }
42
+ },
41
43
 
42
- async resolve() {
43
- // 演示不会伪造播放地址。真实解析器应返回 Host 发放的 MediaLease。
44
- return ctx.playback.failure({
45
- code: 'UNSUPPORTED',
46
- message: '这是本地搜索 demo,尚未连接真实的音源服务。',
47
- })
44
+ async resolve() {
45
+ // 演示不会伪造播放地址。真实解析器返回 { ok: true, url, expiresAt? }。
46
+ return ctx.playback.failure({
47
+ code: 'UNSUPPORTED',
48
+ message: '这是本地搜索 demo,尚未连接真实的音源服务。',
49
+ })
50
+ },
48
51
  },
49
52
  })
50
53
  })
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.1",
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
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.1",
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
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@shiqianjiang/ceru-plugin-cli": "^0.1.2",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.1",
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
- "{ kind: 'host', name: 'platform.${1:tx}' }"
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.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
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
  }