@shiqianjiang/ceru-plugin-cli 0.3.16 → 3.0.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 +26 -7
- package/assets/compatibility.json +18 -0
- package/dist/compatibility.d.ts +24 -0
- package/dist/compatibility.js +119 -0
- package/dist/component.d.ts +6 -0
- package/dist/component.js +60 -0
- package/dist/dev-music.d.ts +19 -0
- package/dist/dev-music.js +81 -0
- package/dist/dev-plugin-services.d.ts +10 -0
- package/dist/dev-plugin-services.js +67 -0
- package/dist/dev.d.ts +1 -9
- package/dist/dev.js +53 -713
- package/dist/frameworks.d.ts +5 -2
- package/dist/frameworks.js +43 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -23
- package/dist/init.js +3 -3
- package/dist/migrate.d.ts +3 -0
- package/dist/migrate.js +109 -0
- package/dist/project.d.ts +5 -2
- package/dist/project.js +131 -43
- package/dist/test-hooks.d.ts +1 -0
- package/dist/test-hooks.js +209 -0
- package/dist/test-services.d.ts +4 -0
- package/dist/test-services.js +54 -0
- package/dist/watch-vue-types.d.ts +17 -0
- package/dist/watch-vue-types.js +145 -0
- package/package.json +10 -6
- package/schemas/config.schema.json +954 -452
- package/templates/account-qrcode/js/.vscode/extensions.json +3 -0
- package/templates/account-qrcode/js/.vscode/launch.json +19 -0
- package/templates/account-qrcode/js/.vscode/settings.json +20 -0
- package/templates/account-qrcode/js/.vscode/tasks.json +43 -0
- package/templates/account-qrcode/js/README.md +15 -0
- package/templates/account-qrcode/js/_gitignore +6 -0
- package/templates/account-qrcode/js/ceru-plugin.code-workspace +8 -0
- package/templates/account-qrcode/js/ceru.plugin.json +62 -0
- package/templates/account-qrcode/js/package.json +24 -0
- package/templates/account-qrcode/js/src/Login.vue +25 -0
- package/templates/account-qrcode/js/src/index.js +25 -0
- package/templates/account-qrcode/js/src/login-html.js +23 -0
- package/templates/account-qrcode/js/tsconfig.json +17 -0
- package/templates/account-qrcode/ts/.vscode/extensions.json +3 -0
- package/templates/account-qrcode/ts/.vscode/launch.json +19 -0
- package/templates/account-qrcode/ts/.vscode/settings.json +20 -0
- package/templates/account-qrcode/ts/.vscode/tasks.json +43 -0
- package/templates/account-qrcode/ts/README.md +15 -0
- package/templates/account-qrcode/ts/_gitignore +6 -0
- package/templates/account-qrcode/ts/ceru-plugin.code-workspace +8 -0
- package/templates/account-qrcode/ts/ceru.plugin.json +62 -0
- package/templates/account-qrcode/ts/package.json +24 -0
- package/templates/account-qrcode/ts/src/Login.vue +25 -0
- package/templates/account-qrcode/ts/src/index.ts +25 -0
- package/templates/account-qrcode/ts/src/login-html.ts +23 -0
- package/templates/account-qrcode/ts/tsconfig.json +17 -0
- package/templates/connected-library/js/.vscode/launch.json +12 -29
- package/templates/connected-library/js/.vscode/tasks.json +2 -3
- package/templates/connected-library/js/README.md +26 -12
- package/templates/connected-library/js/ceru.plugin.json +122 -50
- package/templates/connected-library/js/package.json +5 -5
- package/templates/connected-library/js/src/index.js +46 -5
- package/templates/connected-library/js/src/settings.js +28 -0
- package/templates/connected-library/ts/.vscode/launch.json +12 -29
- package/templates/connected-library/ts/.vscode/tasks.json +2 -3
- package/templates/connected-library/ts/README.md +26 -12
- package/templates/connected-library/ts/ceru.plugin.json +122 -50
- package/templates/connected-library/ts/package.json +5 -5
- package/templates/connected-library/ts/src/index.ts +46 -5
- package/templates/connected-library/ts/src/settings.ts +28 -0
- package/templates/encrypted-source/README.md +86 -0
- package/templates/encrypted-source/js/.prettierrc.json +5 -0
- package/templates/encrypted-source/js/.vscode/ceru.code-snippets +55 -0
- package/templates/encrypted-source/js/.vscode/extensions.json +3 -0
- package/templates/encrypted-source/js/.vscode/launch.json +15 -0
- package/templates/encrypted-source/js/.vscode/settings.json +20 -0
- package/templates/encrypted-source/js/.vscode/tasks.json +40 -0
- package/templates/encrypted-source/js/DEMO.md +77 -0
- package/templates/encrypted-source/js/README.md +13 -0
- package/templates/encrypted-source/js/_gitignore +6 -0
- package/templates/encrypted-source/js/ceru-plugin.code-workspace +8 -0
- package/templates/encrypted-source/js/ceru.plugin.json +95 -0
- package/templates/encrypted-source/js/package.json +26 -0
- package/templates/encrypted-source/js/resources/xor-byte.wasm +0 -0
- package/templates/encrypted-source/js/resources/xor-byte.wat +5 -0
- package/templates/encrypted-source/js/src/demo.js +200 -0
- package/templates/encrypted-source/js/src/fixtures.js +118 -0
- package/templates/encrypted-source/js/src/index.js +4 -0
- package/templates/encrypted-source/js/tests/demo.test.mjs +357 -0
- package/templates/encrypted-source/js/tsconfig.json +16 -0
- package/templates/encrypted-source/ts/.prettierrc.json +5 -0
- package/templates/encrypted-source/ts/.vscode/ceru.code-snippets +55 -0
- package/templates/encrypted-source/ts/.vscode/extensions.json +3 -0
- package/templates/encrypted-source/ts/.vscode/launch.json +15 -0
- package/templates/encrypted-source/ts/.vscode/settings.json +20 -0
- package/templates/encrypted-source/ts/.vscode/tasks.json +40 -0
- package/templates/encrypted-source/ts/DEMO.md +77 -0
- package/templates/encrypted-source/ts/README.md +13 -0
- package/templates/encrypted-source/ts/_gitignore +6 -0
- package/templates/encrypted-source/ts/ceru-plugin.code-workspace +8 -0
- package/templates/encrypted-source/ts/ceru.plugin.json +95 -0
- package/templates/encrypted-source/ts/package.json +26 -0
- package/templates/encrypted-source/ts/resources/xor-byte.wasm +0 -0
- package/templates/encrypted-source/ts/resources/xor-byte.wat +5 -0
- package/templates/encrypted-source/ts/src/demo.ts +212 -0
- package/templates/encrypted-source/ts/src/fixtures.ts +125 -0
- package/templates/encrypted-source/ts/src/index.ts +4 -0
- package/templates/encrypted-source/ts/tests/demo.test.mjs +357 -0
- package/templates/encrypted-source/ts/tsconfig.json +17 -0
- package/templates/guest-adapter/js/.vscode/launch.json +12 -29
- package/templates/guest-adapter/js/.vscode/tasks.json +2 -3
- package/templates/guest-adapter/js/README.md +10 -10
- package/templates/guest-adapter/js/ceru.plugin.json +67 -62
- package/templates/guest-adapter/js/package.json +5 -5
- package/templates/guest-adapter/js/src/index.js +1 -1
- package/templates/guest-adapter/js/src/settings.js +8 -0
- package/templates/guest-adapter/ts/.vscode/launch.json +12 -29
- package/templates/guest-adapter/ts/.vscode/tasks.json +2 -3
- package/templates/guest-adapter/ts/README.md +10 -10
- package/templates/guest-adapter/ts/ceru.plugin.json +67 -62
- package/templates/guest-adapter/ts/package.json +5 -5
- package/templates/guest-adapter/ts/src/index.ts +1 -1
- package/templates/guest-adapter/ts/src/settings.ts +8 -0
- package/templates/importer/js/.vscode/launch.json +12 -29
- package/templates/importer/js/.vscode/tasks.json +2 -3
- package/templates/importer/js/README.md +10 -10
- package/templates/importer/js/ceru.plugin.json +23 -21
- package/templates/importer/js/package.json +5 -5
- package/templates/importer/ts/.vscode/launch.json +12 -29
- package/templates/importer/ts/.vscode/tasks.json +2 -3
- package/templates/importer/ts/README.md +10 -10
- package/templates/importer/ts/ceru.plugin.json +23 -21
- package/templates/importer/ts/package.json +5 -5
- package/templates/page-extension/js/.vscode/extensions.json +3 -0
- package/templates/page-extension/js/.vscode/launch.json +19 -0
- package/templates/page-extension/js/.vscode/settings.json +20 -0
- package/templates/page-extension/js/.vscode/tasks.json +43 -0
- package/templates/page-extension/js/README.md +9 -0
- package/templates/page-extension/js/_gitignore +6 -0
- package/templates/page-extension/js/ceru-plugin.code-workspace +8 -0
- package/templates/page-extension/js/ceru.plugin.json +94 -0
- package/templates/page-extension/js/package.json +24 -0
- package/templates/page-extension/js/src/Open.vue +6 -0
- package/templates/page-extension/js/src/Search.vue +62 -0
- package/templates/page-extension/js/src/index.js +54 -0
- package/templates/page-extension/js/tsconfig.json +17 -0
- package/templates/page-extension/ts/.vscode/extensions.json +3 -0
- package/templates/page-extension/ts/.vscode/launch.json +19 -0
- package/templates/page-extension/ts/.vscode/settings.json +20 -0
- package/templates/page-extension/ts/.vscode/tasks.json +43 -0
- package/templates/page-extension/ts/README.md +9 -0
- package/templates/page-extension/ts/_gitignore +6 -0
- package/templates/page-extension/ts/ceru-plugin.code-workspace +8 -0
- package/templates/page-extension/ts/ceru.plugin.json +94 -0
- package/templates/page-extension/ts/package.json +24 -0
- package/templates/page-extension/ts/src/Open.vue +6 -0
- package/templates/page-extension/ts/src/Search.vue +62 -0
- package/templates/page-extension/ts/src/index.ts +54 -0
- package/templates/page-extension/ts/tsconfig.json +17 -0
- package/templates/playback-hook/js/.prettierrc.json +5 -0
- package/templates/playback-hook/js/.vscode/extensions.json +3 -0
- package/templates/playback-hook/js/.vscode/launch.json +19 -0
- package/templates/playback-hook/js/.vscode/settings.json +20 -0
- package/templates/playback-hook/js/.vscode/tasks.json +50 -0
- package/templates/playback-hook/js/README.md +24 -0
- package/templates/playback-hook/js/_gitignore +6 -0
- package/templates/playback-hook/js/ceru-plugin.code-workspace +8 -0
- package/templates/playback-hook/js/ceru.plugin.json +36 -0
- package/templates/playback-hook/js/package.json +23 -0
- package/templates/playback-hook/js/src/index.js +25 -0
- package/templates/playback-hook/js/tests/hooks.json +316 -0
- package/templates/playback-hook/js/tsconfig.json +16 -0
- package/templates/playback-hook/ts/.prettierrc.json +5 -0
- package/templates/playback-hook/ts/.vscode/extensions.json +3 -0
- package/templates/playback-hook/ts/.vscode/launch.json +19 -0
- package/templates/playback-hook/ts/.vscode/settings.json +20 -0
- package/templates/playback-hook/ts/.vscode/tasks.json +50 -0
- package/templates/playback-hook/ts/README.md +24 -0
- package/templates/playback-hook/ts/_gitignore +6 -0
- package/templates/playback-hook/ts/ceru-plugin.code-workspace +8 -0
- package/templates/playback-hook/ts/ceru.plugin.json +36 -0
- package/templates/playback-hook/ts/package.json +23 -0
- package/templates/playback-hook/ts/src/index.ts +25 -0
- package/templates/playback-hook/ts/tests/hooks.json +316 -0
- package/templates/playback-hook/ts/tsconfig.json +16 -0
- package/templates/player-skin/js/.vscode/extensions.json +3 -0
- package/templates/player-skin/js/.vscode/launch.json +19 -0
- package/templates/player-skin/js/.vscode/settings.json +20 -0
- package/templates/player-skin/js/.vscode/tasks.json +43 -0
- package/templates/player-skin/js/README.md +11 -0
- package/templates/player-skin/js/_gitignore +6 -0
- package/templates/player-skin/js/assets/studio-preview.svg +15 -0
- package/templates/player-skin/js/ceru-plugin.code-workspace +8 -0
- package/templates/player-skin/js/ceru.plugin.json +77 -0
- package/templates/player-skin/js/package.json +24 -0
- package/templates/player-skin/js/src/Artwork.vue +9 -0
- package/templates/player-skin/js/src/Background.vue +15 -0
- package/templates/player-skin/js/src/BuiltinLyrics.vue +15 -0
- package/templates/player-skin/js/src/Lyrics.vue +28 -0
- package/templates/player-skin/js/tsconfig.json +17 -0
- package/templates/player-skin/ts/.vscode/extensions.json +3 -0
- package/templates/player-skin/ts/.vscode/launch.json +19 -0
- package/templates/player-skin/ts/.vscode/settings.json +20 -0
- package/templates/player-skin/ts/.vscode/tasks.json +43 -0
- package/templates/player-skin/ts/README.md +11 -0
- package/templates/player-skin/ts/_gitignore +6 -0
- package/templates/player-skin/ts/assets/studio-preview.svg +15 -0
- package/templates/player-skin/ts/ceru-plugin.code-workspace +8 -0
- package/templates/player-skin/ts/ceru.plugin.json +77 -0
- package/templates/player-skin/ts/package.json +24 -0
- package/templates/player-skin/ts/src/Artwork.vue +9 -0
- package/templates/player-skin/ts/src/Background.vue +15 -0
- package/templates/player-skin/ts/src/BuiltinLyrics.vue +15 -0
- package/templates/player-skin/ts/src/Lyrics.vue +28 -0
- package/templates/player-skin/ts/tsconfig.json +17 -0
- package/templates/react/js/.vscode/launch.json +12 -29
- package/templates/react/js/.vscode/tasks.json +2 -3
- package/templates/react/js/README.md +10 -10
- package/templates/react/js/ceru.plugin.json +27 -22
- package/templates/react/js/package.json +5 -5
- package/templates/react/js/src/index.js +1 -1
- package/templates/react/ts/.vscode/launch.json +12 -29
- package/templates/react/ts/.vscode/tasks.json +2 -3
- package/templates/react/ts/README.md +10 -10
- package/templates/react/ts/ceru.plugin.json +27 -22
- package/templates/react/ts/package.json +5 -5
- package/templates/react/ts/src/index.ts +1 -1
- package/templates/snapshot.json +152 -6
- package/templates/source/js/.vscode/launch.json +12 -29
- package/templates/source/js/.vscode/tasks.json +2 -3
- package/templates/source/js/README.md +12 -10
- package/templates/source/js/ceru.plugin.json +44 -26
- package/templates/source/js/package.json +5 -5
- package/templates/source/js/src/index.js +10 -8
- package/templates/source/ts/.vscode/launch.json +12 -29
- package/templates/source/ts/.vscode/tasks.json +2 -3
- package/templates/source/ts/README.md +12 -10
- package/templates/source/ts/ceru.plugin.json +44 -26
- package/templates/source/ts/package.json +5 -5
- package/templates/source/ts/src/index.ts +10 -8
- package/templates/vue/js/.vscode/launch.json +12 -29
- package/templates/vue/js/.vscode/tasks.json +2 -3
- package/templates/vue/js/README.md +10 -10
- package/templates/vue/js/ceru.plugin.json +27 -22
- package/templates/vue/js/package.json +5 -5
- package/templates/vue/js/src/index.js +1 -1
- package/templates/vue/ts/.vscode/launch.json +12 -29
- package/templates/vue/ts/.vscode/tasks.json +2 -3
- package/templates/vue/ts/README.md +10 -10
- package/templates/vue/ts/ceru.plugin.json +27 -22
- package/templates/vue/ts/package.json +5 -5
- package/templates/vue/ts/src/index.ts +1 -1
- package/templates/vue-tsx/js/.vscode/launch.json +12 -29
- package/templates/vue-tsx/js/.vscode/tasks.json +2 -3
- package/templates/vue-tsx/js/README.md +10 -10
- package/templates/vue-tsx/js/ceru.plugin.json +27 -22
- package/templates/vue-tsx/js/package.json +5 -5
- package/templates/vue-tsx/js/src/index.js +1 -1
- package/templates/vue-tsx/ts/.vscode/launch.json +12 -29
- package/templates/vue-tsx/ts/.vscode/tasks.json +2 -3
- package/templates/vue-tsx/ts/README.md +10 -10
- package/templates/vue-tsx/ts/ceru.plugin.json +27 -22
- package/templates/vue-tsx/ts/package.json +5 -5
- package/templates/vue-tsx/ts/src/index.ts +1 -1
- package/templates/web-dist/js/.vscode/launch.json +12 -29
- package/templates/web-dist/js/.vscode/tasks.json +2 -3
- package/templates/web-dist/js/README.md +10 -10
- package/templates/web-dist/js/ceru.plugin.json +27 -22
- package/templates/web-dist/js/package.json +5 -5
- package/templates/web-dist/js/src/index.js +1 -1
- package/templates/web-dist/ts/.vscode/launch.json +12 -29
- package/templates/web-dist/ts/.vscode/tasks.json +2 -3
- package/templates/web-dist/ts/README.md +10 -10
- package/templates/web-dist/ts/ceru.plugin.json +27 -22
- package/templates/web-dist/ts/package.json +5 -5
- package/templates/web-dist/ts/src/index.ts +1 -1
- package/templates/web-surface/js/.vscode/launch.json +12 -29
- package/templates/web-surface/js/.vscode/tasks.json +2 -3
- package/templates/web-surface/js/README.md +10 -10
- package/templates/web-surface/js/ceru.plugin.json +35 -35
- package/templates/web-surface/js/package.json +5 -5
- package/templates/web-surface/js/src/index.js +1 -1
- package/templates/web-surface/ts/.vscode/launch.json +12 -29
- package/templates/web-surface/ts/.vscode/tasks.json +2 -3
- package/templates/web-surface/ts/README.md +10 -10
- package/templates/web-surface/ts/ceru.plugin.json +35 -35
- package/templates/web-surface/ts/package.json +5 -5
- package/templates/web-surface/ts/src/index.ts +1 -1
- package/assets/core-contracts.js +0 -1
- package/assets/electron-app/main.cjs +0 -1
- package/assets/electron-app/package.json +0 -8
- package/assets/electron.cjs +0 -42
- package/assets/index.html +0 -94
- package/assets/native-view.js +0 -197
- package/assets/playground.js +0 -883
- package/assets/sandbox.js +0 -67
- package/assets/style.css +0 -337
- package/dist/socket-broker.d.ts +0 -23
- package/dist/socket-broker.js +0 -229
- package/templates/connected-library/js/ui/settings.json +0 -24
- package/templates/connected-library/ts/ui/settings.json +0 -24
- package/templates/guest-adapter/js/ui/settings.json +0 -14
- package/templates/guest-adapter/ts/ui/settings.json +0 -14
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "未授权时保留原始点播",
|
|
4
|
+
"operation": "player.play",
|
|
5
|
+
"granted": false,
|
|
6
|
+
"input": {
|
|
7
|
+
"track": {
|
|
8
|
+
"ref": {
|
|
9
|
+
"kind": "track",
|
|
10
|
+
"providerId": "demo",
|
|
11
|
+
"id": "one"
|
|
12
|
+
},
|
|
13
|
+
"title": "[拦截示例] 测试歌曲",
|
|
14
|
+
"metadata": {
|
|
15
|
+
"artists": [
|
|
16
|
+
"Ceru Demo"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"expect": {
|
|
22
|
+
"prevented": false,
|
|
23
|
+
"input": {
|
|
24
|
+
"track": {
|
|
25
|
+
"ref": {
|
|
26
|
+
"kind": "track",
|
|
27
|
+
"providerId": "demo",
|
|
28
|
+
"id": "one"
|
|
29
|
+
},
|
|
30
|
+
"title": "[拦截示例] 测试歌曲",
|
|
31
|
+
"metadata": {
|
|
32
|
+
"artists": [
|
|
33
|
+
"Ceru Demo"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "授权后拦截标记歌曲",
|
|
42
|
+
"operation": "player.play",
|
|
43
|
+
"granted": true,
|
|
44
|
+
"input": {
|
|
45
|
+
"track": {
|
|
46
|
+
"ref": {
|
|
47
|
+
"kind": "track",
|
|
48
|
+
"providerId": "demo",
|
|
49
|
+
"id": "one"
|
|
50
|
+
},
|
|
51
|
+
"title": "[拦截示例] 测试歌曲",
|
|
52
|
+
"metadata": {
|
|
53
|
+
"artists": [
|
|
54
|
+
"Ceru Demo"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"expect": {
|
|
60
|
+
"prevented": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "普通点播执行一次",
|
|
65
|
+
"operation": "player.play",
|
|
66
|
+
"granted": true,
|
|
67
|
+
"input": {
|
|
68
|
+
"track": {
|
|
69
|
+
"ref": {
|
|
70
|
+
"kind": "track",
|
|
71
|
+
"providerId": "demo",
|
|
72
|
+
"id": "one"
|
|
73
|
+
},
|
|
74
|
+
"title": "普通演示歌曲",
|
|
75
|
+
"metadata": {
|
|
76
|
+
"artists": [
|
|
77
|
+
"Ceru Demo"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"expect": {
|
|
83
|
+
"prevented": false,
|
|
84
|
+
"input": {
|
|
85
|
+
"track": {
|
|
86
|
+
"ref": {
|
|
87
|
+
"kind": "track",
|
|
88
|
+
"providerId": "demo",
|
|
89
|
+
"id": "one"
|
|
90
|
+
},
|
|
91
|
+
"title": "普通演示歌曲",
|
|
92
|
+
"metadata": {
|
|
93
|
+
"artists": [
|
|
94
|
+
"Ceru Demo"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "优先歌曲插在当前歌曲之后",
|
|
103
|
+
"operation": "queue.add",
|
|
104
|
+
"granted": true,
|
|
105
|
+
"input": {
|
|
106
|
+
"position": "end",
|
|
107
|
+
"tracks": [
|
|
108
|
+
{
|
|
109
|
+
"ref": {
|
|
110
|
+
"kind": "track",
|
|
111
|
+
"providerId": "demo",
|
|
112
|
+
"id": "one"
|
|
113
|
+
},
|
|
114
|
+
"title": "[优先示例] 测试歌曲",
|
|
115
|
+
"metadata": {
|
|
116
|
+
"artists": [
|
|
117
|
+
"Ceru Demo"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"expect": {
|
|
124
|
+
"prevented": false,
|
|
125
|
+
"input": {
|
|
126
|
+
"position": "next",
|
|
127
|
+
"tracks": [
|
|
128
|
+
{
|
|
129
|
+
"ref": {
|
|
130
|
+
"kind": "track",
|
|
131
|
+
"providerId": "demo",
|
|
132
|
+
"id": "one"
|
|
133
|
+
},
|
|
134
|
+
"title": "[优先示例] 测试歌曲",
|
|
135
|
+
"metadata": {
|
|
136
|
+
"artists": [
|
|
137
|
+
"Ceru Demo"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "系统媒体键继续播放",
|
|
147
|
+
"operation": "player.resume",
|
|
148
|
+
"source": {
|
|
149
|
+
"kind": "system"
|
|
150
|
+
},
|
|
151
|
+
"granted": true,
|
|
152
|
+
"input": {},
|
|
153
|
+
"expect": {
|
|
154
|
+
"prevented": false,
|
|
155
|
+
"input": {}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "其他插件请求暂停",
|
|
160
|
+
"operation": "player.pause",
|
|
161
|
+
"source": {
|
|
162
|
+
"kind": "plugin",
|
|
163
|
+
"pluginId": "example.caller",
|
|
164
|
+
"runtime": 3
|
|
165
|
+
},
|
|
166
|
+
"granted": true,
|
|
167
|
+
"input": {},
|
|
168
|
+
"expect": {
|
|
169
|
+
"prevented": false,
|
|
170
|
+
"input": {}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "未授权时移除保护歌曲",
|
|
175
|
+
"operation": "queue.remove",
|
|
176
|
+
"granted": false,
|
|
177
|
+
"input": {
|
|
178
|
+
"tracks": [
|
|
179
|
+
{
|
|
180
|
+
"ref": {
|
|
181
|
+
"kind": "track",
|
|
182
|
+
"providerId": "demo",
|
|
183
|
+
"id": "one"
|
|
184
|
+
},
|
|
185
|
+
"title": "[保护示例] 测试歌曲",
|
|
186
|
+
"metadata": {
|
|
187
|
+
"artists": [
|
|
188
|
+
"Ceru Demo"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
"expect": {
|
|
195
|
+
"prevented": false,
|
|
196
|
+
"input": {
|
|
197
|
+
"tracks": [
|
|
198
|
+
{
|
|
199
|
+
"ref": {
|
|
200
|
+
"kind": "track",
|
|
201
|
+
"providerId": "demo",
|
|
202
|
+
"id": "one"
|
|
203
|
+
},
|
|
204
|
+
"title": "[保护示例] 测试歌曲",
|
|
205
|
+
"metadata": {
|
|
206
|
+
"artists": [
|
|
207
|
+
"Ceru Demo"
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "授权后保留保护歌曲",
|
|
217
|
+
"operation": "queue.remove",
|
|
218
|
+
"granted": true,
|
|
219
|
+
"input": {
|
|
220
|
+
"tracks": [
|
|
221
|
+
{
|
|
222
|
+
"ref": {
|
|
223
|
+
"kind": "track",
|
|
224
|
+
"providerId": "demo",
|
|
225
|
+
"id": "one"
|
|
226
|
+
},
|
|
227
|
+
"title": "[保护示例] 测试歌曲",
|
|
228
|
+
"metadata": {
|
|
229
|
+
"artists": [
|
|
230
|
+
"Ceru Demo"
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"expect": {
|
|
237
|
+
"prevented": true
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "普通队列歌曲仍可移除",
|
|
242
|
+
"operation": "queue.remove",
|
|
243
|
+
"granted": true,
|
|
244
|
+
"input": {
|
|
245
|
+
"tracks": [
|
|
246
|
+
{
|
|
247
|
+
"ref": {
|
|
248
|
+
"kind": "track",
|
|
249
|
+
"providerId": "demo",
|
|
250
|
+
"id": "one"
|
|
251
|
+
},
|
|
252
|
+
"title": "普通演示歌曲",
|
|
253
|
+
"metadata": {
|
|
254
|
+
"artists": [
|
|
255
|
+
"Ceru Demo"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"expect": {
|
|
262
|
+
"prevented": false,
|
|
263
|
+
"input": {
|
|
264
|
+
"tracks": [
|
|
265
|
+
{
|
|
266
|
+
"ref": {
|
|
267
|
+
"kind": "track",
|
|
268
|
+
"providerId": "demo",
|
|
269
|
+
"id": "one"
|
|
270
|
+
},
|
|
271
|
+
"title": "普通演示歌曲",
|
|
272
|
+
"metadata": {
|
|
273
|
+
"artists": [
|
|
274
|
+
"Ceru Demo"
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"name": "清空队列沿用默认行为",
|
|
284
|
+
"operation": "queue.clear",
|
|
285
|
+
"granted": true,
|
|
286
|
+
"input": {},
|
|
287
|
+
"expect": {
|
|
288
|
+
"prevented": false,
|
|
289
|
+
"input": {}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "主源成功不重试",
|
|
294
|
+
"operation": "player.resolve", "granted": true, "resolveResults": [true],
|
|
295
|
+
"input": {"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"},
|
|
296
|
+
"expect": {"prevented":false,"input":{"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"}}
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"name": "主源失败后用备用歌曲解析",
|
|
300
|
+
"operation": "player.resolve", "granted": true, "resolveResults": [false,true],
|
|
301
|
+
"input": {"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":""},
|
|
302
|
+
"expect": {"prevented":false,"input":{"track":{"ref":{"kind":"track","providerId":"demo-backup","id":"morning-alt"},"title":"Morning","metadata":{"artists":[]}},"quality":""}}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"name": "备用源失败不重复尝试",
|
|
306
|
+
"operation": "player.resolve", "granted": true, "resolveResults": [false,false],
|
|
307
|
+
"input": {"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"},
|
|
308
|
+
"expect": {"prevented":false,"input":{"track":{"ref":{"kind":"track","providerId":"demo-backup","id":"morning-alt"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"}}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"name": "未授权时不向备用源重试",
|
|
312
|
+
"operation": "player.resolve", "granted": false, "resolveResults": [false],
|
|
313
|
+
"input": {"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"},
|
|
314
|
+
"expect": {"prevented":false,"input":{"track":{"ref":{"kind":"track","providerId":"demo-primary","id":"morning"},"title":"Morning","metadata":{"artists":[]}},"quality":"128k"}}
|
|
315
|
+
}
|
|
316
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"checkJs": false,
|
|
11
|
+
"lib": ["ES2022", "DOM"],
|
|
12
|
+
"types": [],
|
|
13
|
+
"jsx": "react-jsx"
|
|
14
|
+
},
|
|
15
|
+
"include": ["src", ".ceru-dev/types/**/*.d.ts"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Watch Ceru plugin",
|
|
6
|
+
"type": "node",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"program": "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
|
|
9
|
+
"args": [
|
|
10
|
+
"dev"
|
|
11
|
+
],
|
|
12
|
+
"cwd": "${workspaceFolder}",
|
|
13
|
+
"console": "integratedTerminal",
|
|
14
|
+
"skipFiles": [
|
|
15
|
+
"<node_internals>/**"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
3
|
+
"typescript.enablePromptUseWorkspaceTsdk": true,
|
|
4
|
+
"editor.formatOnSave": true,
|
|
5
|
+
"[typescript]": {
|
|
6
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
7
|
+
},
|
|
8
|
+
"[javascript]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
"json.schemas": [
|
|
12
|
+
{
|
|
13
|
+
"fileMatch": ["/ceru.plugin.json"],
|
|
14
|
+
"url": "./node_modules/@shiqianjiang/ceru-plugin-cli/schemas/config.schema.json"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"files.exclude": {
|
|
18
|
+
"**/*.tsbuildinfo": true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "Ceru: dev",
|
|
6
|
+
"type": "process",
|
|
7
|
+
"isBackground": true,
|
|
8
|
+
"problemMatcher": {
|
|
9
|
+
"owner": "ceru",
|
|
10
|
+
"pattern": {
|
|
11
|
+
"regexp": "^CERU_ERROR (.*)$",
|
|
12
|
+
"message": 1
|
|
13
|
+
},
|
|
14
|
+
"background": {
|
|
15
|
+
"activeOnStart": true,
|
|
16
|
+
"beginsPattern": "^.*$",
|
|
17
|
+
"endsPattern": "^CERU_BUILD_READY "
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
|
|
23
|
+
"dev"
|
|
24
|
+
],
|
|
25
|
+
"options": {
|
|
26
|
+
"cwd": "${workspaceFolder}"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"label": "Ceru: typecheck",
|
|
31
|
+
"type": "npm",
|
|
32
|
+
"script": "typecheck",
|
|
33
|
+
"problemMatcher": "$tsc",
|
|
34
|
+
"group": "build"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"label": "Ceru: build",
|
|
38
|
+
"type": "npm",
|
|
39
|
+
"script": "build",
|
|
40
|
+
"problemMatcher": []
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"label": "Ceru: test playback hooks",
|
|
44
|
+
"type": "npm",
|
|
45
|
+
"script": "test",
|
|
46
|
+
"group": "test",
|
|
47
|
+
"problemMatcher": []
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 播放拦截示例
|
|
2
|
+
|
|
3
|
+
这是一个纯逻辑插件,不需要账号、网络、音源或 Electron 即可测试。编辑 src/index,把规则换成自己的。默认只处理演示前缀:点播以「[拦截示例]」开头的歌曲时取消操作;加入以「[优先示例]」开头的歌曲时改为下一首,其他歌曲不变。 定向移除带「[保护示例]」前缀的歌曲时取消该请求;这条规则不拦截清空整个队列。
|
|
4
|
+
|
|
5
|
+
1. 安装项目依赖:`npm install`。
|
|
6
|
+
2. 执行 `npm test`。命令先构建,再在独立 worker 中对 `tests/hooks.json` 的每个场景启动新插件,检查取消、未授权直通、一次性默认执行和队列位置。断言失败会给出场景名称并以非零状态退出。场景文件不会打入分发产物。
|
|
7
|
+
3. 启动 `npm run dev`,复制它打印的产物路径。在兼容 v3 的澜音中打开「设置 → 插件管理 → 管理设置 → 插件开发者模式」,添加该文件,启用插件,并在其权限设置中允许播放拦截。修改源码后自动重建;关闭权限可验证原有行为。此步骤才会接入真实播放器。
|
|
8
|
+
4. 发给别人前运行 `npm run build` 和 `npm run validate`。只分发 `dist/plugin.js`。
|
|
9
|
+
|
|
10
|
+
点播和入队输入只含公开歌曲摘要,暂停和继续的输入为 `{}`。场景可用 `source.kind` 区分 `ui`、`system` 和 `plugin`;插件来源还须填写 `pluginId` 与 `runtime`(2 或 3)。省略来源时按界面点击测试。普通播放钩子最多调用一次 `next`。每个处理器有 800 ms 执行预算,等待下游解析不计入预算。
|
|
11
|
+
|
|
12
|
+
### 测试失败换源
|
|
13
|
+
|
|
14
|
+
`player.resolve` 示例仅处理 `demo-primary` 的 `morning`:首次 `await next()` 成功就结束;失败时,改用 `demo-backup` 的 `morning-alt`,保留原音质。两个 ID 是测试数据,不假设不同平台共用歌曲 ID,也不会改写其他歌曲。真实插件应提供自己的公开歌曲映射,或在获得 `music.read` 授权后查询备用音源。
|
|
15
|
+
|
|
16
|
+
`tests/hooks.json` 中的 `resolveResults` 按顺序指定每次宿主解析是否成功。如 `[false, true]` 表示主源失败、备用源成功。`expect.input` 是最后一次解析的输入。钩子只能看到 `{ ok }`,不能读取播放地址;只有失败后才能用不同输入再试一次。`npm test` 不连接真实音源或音频设备。
|
|
17
|
+
|
|
18
|
+
### 观察操作与读取现场
|
|
19
|
+
|
|
20
|
+
`op.state` 提供冻结的 `player`、`route`、`account` 快照,分别需要声明和授予 `player.read`、`route.read`、`account.profile`。未授权时对应字段为 `null`;离线测试默认三项为空。
|
|
21
|
+
|
|
22
|
+
只想取消操作时,可以使用现有 `player.intercept` 权限注册 `ctx.events.on('player.pause', event => event.preventDefault())`,输入与来源只读。希望观察最终结果时,在清单 `manifest.uses.permissions` 添加 `player.read`,再注册 `ctx.events.on('player.pause:done', event => console.log(event.prevented, event.handledBy))`。完成事件不改变操作,在暂停全部拦截时仍然投递。`events.on` 返回的函数用于注销。
|
|
23
|
+
|
|
24
|
+
`ctx.app.operations.list()` 返回当前可主动调用的工具及输入/输出 Schema、执行权限。调用时使用 `ctx.app.call(name, input, {operation, permissionKey})`;例如清空队列为 `queue.clear`,需要 `player.control`。不要把拦截权限用于执行权限,也不要把钩子的临时私有歌曲句柄传给工具。
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest": {
|
|
3
|
+
"manifestVersion": 3,
|
|
4
|
+
"id": "local.ts",
|
|
5
|
+
"name": "ts",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "本地播放拦截与队列改写示例",
|
|
8
|
+
"dataSchemas": {
|
|
9
|
+
"config": 1,
|
|
10
|
+
"state": 1
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"hostApi": "^3.0.0",
|
|
14
|
+
"logicRuntime": "ceru-js@1"
|
|
15
|
+
},
|
|
16
|
+
"entry": {
|
|
17
|
+
"logic": {
|
|
18
|
+
"module": "logic.main"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"uses": {
|
|
22
|
+
"permissions": [
|
|
23
|
+
{
|
|
24
|
+
"key": "intercept",
|
|
25
|
+
"name": "player.intercept",
|
|
26
|
+
"reason": "处理带演示前缀的点播和队列操作,并在指定演示歌曲解析失败时尝试备用音源"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"entries": {
|
|
32
|
+
"logic.main": "src/index.ts"
|
|
33
|
+
},
|
|
34
|
+
"resources": {},
|
|
35
|
+
"output": "dist/plugin.js"
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "ceru-plugin dev",
|
|
8
|
+
"build": "ceru-plugin build",
|
|
9
|
+
"typecheck": "ceru-plugin typecheck",
|
|
10
|
+
"validate": "ceru-plugin validate dist/plugin.js",
|
|
11
|
+
"preview": "ceru-plugin preview dist/plugin.js",
|
|
12
|
+
"test": "ceru-plugin test-hooks",
|
|
13
|
+
"check:compat": "ceru-plugin check-compat"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@shiqianjiang/ceru-plugin-sdk": "^3.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@shiqianjiang/ceru-plugin-cli": "^3.0.0",
|
|
20
|
+
"typescript": "~5.9.3",
|
|
21
|
+
"prettier": "^3.6.2"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { definePlugin } from '@shiqianjiang/ceru-plugin-sdk'
|
|
2
|
+
|
|
3
|
+
export default definePlugin(async (ctx) => {
|
|
4
|
+
ctx.hooks.on('player.resolve', async (op, next) => {
|
|
5
|
+
const { ref } = op.input.track
|
|
6
|
+
if (ref.providerId !== 'demo-primary' || ref.id !== 'morning') return
|
|
7
|
+
const result = await next()
|
|
8
|
+
if (result.ok) return result
|
|
9
|
+
return next({
|
|
10
|
+
...op.input,
|
|
11
|
+
track: { ...op.input.track, ref: { kind: 'track', providerId: 'demo-backup', id: 'morning-alt' } },
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
ctx.hooks.on('player.play', (op) => {
|
|
15
|
+
if (op.input.track.title.startsWith('[拦截示例]')) op.preventDefault()
|
|
16
|
+
})
|
|
17
|
+
ctx.hooks.on('queue.remove', op => {
|
|
18
|
+
if (op.input.tracks.some(track => track.title.startsWith('[保护示例]'))) op.preventDefault()
|
|
19
|
+
})
|
|
20
|
+
ctx.hooks.on('queue.add', async (op, next) => {
|
|
21
|
+
if (op.input.tracks.some((track) => track.title.startsWith('[优先示例]'))) {
|
|
22
|
+
await next({ ...op.input, position: 'next' })
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
})
|