@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
@@ -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
  }
@@ -38,6 +38,15 @@
38
38
  "title": "js",
39
39
  "view": "page"
40
40
  }
41
+ ],
42
+ "uiExtensions": [
43
+ {
44
+ "id": "search-note",
45
+ "slot": "search.source-selector.after",
46
+ "mode": "append",
47
+ "view": "page",
48
+ "order": 10
49
+ }
41
50
  ]
42
51
  },
43
52
  "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"
@@ -2,7 +2,10 @@ import { defineSurface } from '@shiqianjiang/ceru-plugin-sdk'
2
2
 
3
3
  export default defineSurface((ctx) => {
4
4
  const heading = document.createElement('h1')
5
- heading.textContent = 'Hello from an isolated Ceru Surface'
5
+ heading.textContent =
6
+ ctx.mount.kind === 'slot'
7
+ ? `Injected into ${ctx.mount.slot} (${ctx.mount.mode})`
8
+ : 'Hello from an isolated Ceru Surface'
6
9
  ctx.root.replaceChildren(heading)
7
10
  return () => ctx.root.replaceChildren()
8
11
  })
@@ -0,0 +1,3 @@
1
+ :where([data-ceru-plugin-slot]) {
2
+ --example-plugin-accent: #2f9e89;
3
+ }
@@ -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
  }
@@ -38,6 +38,15 @@
38
38
  "title": "ts",
39
39
  "view": "page"
40
40
  }
41
+ ],
42
+ "uiExtensions": [
43
+ {
44
+ "id": "search-note",
45
+ "slot": "search.source-selector.after",
46
+ "mode": "append",
47
+ "view": "page",
48
+ "order": 10
49
+ }
41
50
  ]
42
51
  },
43
52
  "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"
@@ -2,7 +2,10 @@ import { defineSurface } from '@shiqianjiang/ceru-plugin-sdk'
2
2
 
3
3
  export default defineSurface((ctx) => {
4
4
  const heading = document.createElement('h1')
5
- heading.textContent = 'Hello from an isolated Ceru Surface'
5
+ heading.textContent =
6
+ ctx.mount.kind === 'slot'
7
+ ? `Injected into ${ctx.mount.slot} (${ctx.mount.mode})`
8
+ : 'Hello from an isolated Ceru Surface'
6
9
  ctx.root.replaceChildren(heading)
7
10
  return () => ctx.root.replaceChildren()
8
11
  })
@@ -0,0 +1,3 @@
1
+ :where([data-ceru-plugin-slot]) {
2
+ --example-plugin-accent: #2f9e89;
3
+ }