@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,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest": {
|
|
3
|
+
"manifestVersion": 3,
|
|
4
|
+
"id": "local.encrypted-source-ts",
|
|
5
|
+
"name": "Encrypted Source (ts)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "Self-contained AES-CTR, worker WASM transform and local HTTP audio providers",
|
|
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
|
+
"activation": [
|
|
19
|
+
"onCommand:demo.start",
|
|
20
|
+
"onProvider:builtin-decrypt",
|
|
21
|
+
"onProvider:wasm-transform",
|
|
22
|
+
"onProvider:own-service"
|
|
23
|
+
],
|
|
24
|
+
"module": "logic.main"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"provides": {
|
|
28
|
+
"providers": [
|
|
29
|
+
{
|
|
30
|
+
"id": "builtin-decrypt",
|
|
31
|
+
"name": "Encrypted Demo / AES-CTR",
|
|
32
|
+
"protocols": ["music.search@1", "music.resolve@1", "music.lyrics@1"],
|
|
33
|
+
"icon": {
|
|
34
|
+
"kind": "host",
|
|
35
|
+
"name": "music-note"
|
|
36
|
+
},
|
|
37
|
+
"connectionMode": "none"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "wasm-transform",
|
|
41
|
+
"name": "Encrypted Demo / WASM XOR",
|
|
42
|
+
"protocols": ["music.search@1", "music.resolve@1", "music.lyrics@1"],
|
|
43
|
+
"icon": {
|
|
44
|
+
"kind": "host",
|
|
45
|
+
"name": "music-note"
|
|
46
|
+
},
|
|
47
|
+
"connectionMode": "none"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "own-service",
|
|
51
|
+
"name": "Encrypted Demo / Own Service",
|
|
52
|
+
"protocols": ["music.search@1", "music.resolve@1", "music.lyrics@1"],
|
|
53
|
+
"icon": {
|
|
54
|
+
"kind": "host",
|
|
55
|
+
"name": "music-note"
|
|
56
|
+
},
|
|
57
|
+
"connectionMode": "none"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"actions": [
|
|
61
|
+
{
|
|
62
|
+
"id": "demo.start",
|
|
63
|
+
"title": "启动本地音频 Demo"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"uses": {
|
|
68
|
+
"permissions": [
|
|
69
|
+
{
|
|
70
|
+
"key": "demo-server",
|
|
71
|
+
"name": "network.serve",
|
|
72
|
+
"reason": "在随机本机端口提供本插件生成的演示音频和密文;不开放局域网访问"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"key": "demo-transform",
|
|
76
|
+
"name": "streams.transform",
|
|
77
|
+
"optional": true,
|
|
78
|
+
"reason": "仅 WASM XOR 音源需要:在插件 Worker 中将音频字节还原为 WAV"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"config": {},
|
|
84
|
+
"entries": {
|
|
85
|
+
"logic.main": "src/index.ts"
|
|
86
|
+
},
|
|
87
|
+
"resources": {
|
|
88
|
+
"xor-byte": {
|
|
89
|
+
"type": "base64",
|
|
90
|
+
"path": "resources/xor-byte.wasm",
|
|
91
|
+
"mime": "application/wasm"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"output": "dist/plugin.js"
|
|
95
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "encrypted-source-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:demo": "node --test tests/demo.test.mjs",
|
|
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
|
+
"engines": {
|
|
24
|
+
"node": ">=22.18.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PluginContext,
|
|
3
|
+
ResourceRef,
|
|
4
|
+
ResolveResult,
|
|
5
|
+
ServerHandle,
|
|
6
|
+
StreamTransformFactory,
|
|
7
|
+
UserIntentHandle,
|
|
8
|
+
} from '@shiqianjiang/ceru-plugin-sdk'
|
|
9
|
+
import {
|
|
10
|
+
AES_KEY,
|
|
11
|
+
AES_IV,
|
|
12
|
+
XOR_MASK,
|
|
13
|
+
DURATION_MS,
|
|
14
|
+
createFixtures,
|
|
15
|
+
createHandler,
|
|
16
|
+
} from './fixtures.ts'
|
|
17
|
+
|
|
18
|
+
export const PROVIDERS = [
|
|
19
|
+
{ id: 'builtin-decrypt', title: 'Encrypted Demo / AES-CTR', path: '/aes.wav.enc' },
|
|
20
|
+
{ id: 'wasm-transform', title: 'Encrypted Demo / WASM XOR', path: '/xor.wav.enc' },
|
|
21
|
+
{ id: 'own-service', title: 'Encrypted Demo / Own Service', path: '/plain.wav' },
|
|
22
|
+
] as const
|
|
23
|
+
|
|
24
|
+
// One private WASM instance per media request, including concurrent seeks.
|
|
25
|
+
export function createWasmFactory(ctx: Pick<PluginContext, 'wasm'>): StreamTransformFactory {
|
|
26
|
+
return {
|
|
27
|
+
// XOR is length preserving and independent of the starting byte offset.
|
|
28
|
+
seekable: true,
|
|
29
|
+
async create({ signal }) {
|
|
30
|
+
signal?.throwIfAborted()
|
|
31
|
+
const { instance } = await ctx.wasm.instantiate('xor-byte')
|
|
32
|
+
const decode = instance.exports.decode
|
|
33
|
+
if (typeof decode !== 'function')
|
|
34
|
+
throw new Error('xor-byte.wasm must export decode(i32, i32) -> i32')
|
|
35
|
+
return {
|
|
36
|
+
transform(chunk) {
|
|
37
|
+
signal?.throwIfAborted()
|
|
38
|
+
const output = new Uint8Array(chunk.length)
|
|
39
|
+
for (let index = 0; index < chunk.length; index++)
|
|
40
|
+
output[index] = decode(chunk[index], XOR_MASK)
|
|
41
|
+
return output
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class PermissionRequired extends Error {}
|
|
49
|
+
|
|
50
|
+
export function installDemo(ctx: PluginContext): void {
|
|
51
|
+
let server: ServerHandle | undefined
|
|
52
|
+
let starting: Promise<ServerHandle> | undefined
|
|
53
|
+
let disposed = false
|
|
54
|
+
ctx.effects.add(ctx.streams.registerTransform('xor-byte', createWasmFactory(ctx)))
|
|
55
|
+
ctx.effects.add(async () => {
|
|
56
|
+
disposed = true
|
|
57
|
+
const active = server ?? (await starting?.catch(() => undefined))
|
|
58
|
+
await active?.close()
|
|
59
|
+
server = undefined
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
async function requireGrant(
|
|
63
|
+
key: string,
|
|
64
|
+
group: 'localServer' | 'audioTransform',
|
|
65
|
+
intent?: UserIntentHandle,
|
|
66
|
+
) {
|
|
67
|
+
let { status } = await ctx.permissions.query({ key })
|
|
68
|
+
if (status !== 'granted')
|
|
69
|
+
({ status } = await ctx.permissions.requestGroup({ group, keys: [key], intent }))
|
|
70
|
+
if (status !== 'granted')
|
|
71
|
+
throw new PermissionRequired(
|
|
72
|
+
`权限 ${key} 当前为 ${status}。请运行“启动本地音频 Demo”,允许对应权限后重试。`,
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function ensureServer(intent?: UserIntentHandle): Promise<ServerHandle> {
|
|
77
|
+
if (disposed) throw new Error('插件正在停止')
|
|
78
|
+
await requireGrant('demo-server', 'localServer', intent)
|
|
79
|
+
if (server) return server
|
|
80
|
+
if (!starting) {
|
|
81
|
+
starting = (async () => {
|
|
82
|
+
const fixtures = await createFixtures(ctx)
|
|
83
|
+
if (disposed) throw new Error('插件正在停止')
|
|
84
|
+
const active = await ctx.server.serve(createHandler(fixtures), {
|
|
85
|
+
permissionKey: 'demo-server',
|
|
86
|
+
})
|
|
87
|
+
if (disposed) {
|
|
88
|
+
await active.close()
|
|
89
|
+
throw new Error('插件正在停止')
|
|
90
|
+
}
|
|
91
|
+
server = active
|
|
92
|
+
ctx.log.info(`Encrypted demo listening: ${active.url} (${fixtures.plain.length} WAV bytes)`)
|
|
93
|
+
return active
|
|
94
|
+
})().finally(() => {
|
|
95
|
+
starting = undefined
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
return starting
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
ctx.actions.register('demo.start', async (_input, operation) => {
|
|
102
|
+
try {
|
|
103
|
+
const local = await ctx.permissions.requestGroup({
|
|
104
|
+
group: 'localServer',
|
|
105
|
+
keys: ['demo-server'],
|
|
106
|
+
intent: operation.userIntent,
|
|
107
|
+
})
|
|
108
|
+
if (local.status !== 'granted')
|
|
109
|
+
throw new PermissionRequired(`本机服务权限为 ${local.status};三个 Demo 均需要它。`)
|
|
110
|
+
const active = await ensureServer(operation.userIntent)
|
|
111
|
+
await ctx.ui.notify({
|
|
112
|
+
key: 'encrypted-demo',
|
|
113
|
+
level: 'info',
|
|
114
|
+
message: `本地音频 Demo:${active.url}。搜索 Encrypted Demo。AES-CTR 与 Own Service 已就绪;首次播放 WASM XOR 时会申请音频流处理权限。`,
|
|
115
|
+
})
|
|
116
|
+
} catch (error) {
|
|
117
|
+
await ctx.ui.notify({
|
|
118
|
+
key: 'encrypted-demo',
|
|
119
|
+
level: 'error',
|
|
120
|
+
message: error instanceof Error ? error.message : String(error),
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
for (const provider of PROVIDERS) {
|
|
126
|
+
const matches = (ref: ResourceRef) =>
|
|
127
|
+
ref.kind === 'track' &&
|
|
128
|
+
ref.id === 'tone-440' &&
|
|
129
|
+
ref.providerId === provider.id &&
|
|
130
|
+
(!ref.pluginId || ref.pluginId === ctx.plugin.id)
|
|
131
|
+
ctx.providers.register(provider.id, {
|
|
132
|
+
tracks: {
|
|
133
|
+
async search(request) {
|
|
134
|
+
const query = request.query.trim().toLowerCase()
|
|
135
|
+
if (
|
|
136
|
+
request.cursor ||
|
|
137
|
+
!`${provider.title} Ceru Demo 440`.toLowerCase().includes(query) ||
|
|
138
|
+
request.limit <= 0
|
|
139
|
+
)
|
|
140
|
+
return { items: [] }
|
|
141
|
+
return {
|
|
142
|
+
items: [
|
|
143
|
+
{
|
|
144
|
+
ref: {
|
|
145
|
+
pluginId: ctx.plugin.id,
|
|
146
|
+
providerId: provider.id,
|
|
147
|
+
kind: 'track',
|
|
148
|
+
id: 'tone-440',
|
|
149
|
+
},
|
|
150
|
+
title: provider.title,
|
|
151
|
+
subtitle: 'Ceru Demo · 440 Hz · 3 seconds',
|
|
152
|
+
playable: true,
|
|
153
|
+
capabilities: ['play'],
|
|
154
|
+
durationMs: DURATION_MS,
|
|
155
|
+
metadata: { artists: ['Ceru Demo'] },
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
async resolve(ref, _quality, operation): Promise<ResolveResult> {
|
|
161
|
+
if (!matches(ref))
|
|
162
|
+
return ctx.playback.failure({ code: 'NOT_FOUND', message: '没有这条演示音频。' })
|
|
163
|
+
try {
|
|
164
|
+
if (provider.id === 'wasm-transform')
|
|
165
|
+
await requireGrant('demo-transform', 'audioTransform', operation.userIntent)
|
|
166
|
+
const active = await ensureServer(operation.userIntent)
|
|
167
|
+
const url = new URL(provider.path, active.url).href
|
|
168
|
+
const metadata = { contentType: 'audio/wav', contentLength: 96044 }
|
|
169
|
+
if (provider.id === 'builtin-decrypt')
|
|
170
|
+
return {
|
|
171
|
+
ok: true,
|
|
172
|
+
url,
|
|
173
|
+
stream: {
|
|
174
|
+
...metadata,
|
|
175
|
+
decrypt: { algorithm: 'aes-128-ctr', key: AES_KEY, iv: AES_IV, encoding: 'hex' },
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
if (provider.id === 'wasm-transform')
|
|
179
|
+
return { ok: true, url, stream: { ...metadata, transform: 'xor-byte' } }
|
|
180
|
+
return { ok: true, url }
|
|
181
|
+
} catch (error) {
|
|
182
|
+
return ctx.playback.failure({
|
|
183
|
+
code: error instanceof PermissionRequired ? 'PERMISSION_DENIED' : 'INTERNAL',
|
|
184
|
+
message: error instanceof Error ? error.message : String(error),
|
|
185
|
+
recovery: {
|
|
186
|
+
mode: 'await-user',
|
|
187
|
+
actions: [
|
|
188
|
+
{ kind: 'plugin-command', commandId: 'demo.start', label: '启动本地音频 Demo' },
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
async lyrics(ref) {
|
|
195
|
+
return {
|
|
196
|
+
format: 'crlyric',
|
|
197
|
+
version: 1,
|
|
198
|
+
track: ref,
|
|
199
|
+
offsetMs: 0,
|
|
200
|
+
lines: matches(ref)
|
|
201
|
+
? [
|
|
202
|
+
{ startTimeMs: 0, text: provider.title },
|
|
203
|
+
{ startTimeMs: 1000, text: '440 Hz 合成纯音,无人声;此处是演示歌词。' },
|
|
204
|
+
{ startTimeMs: 2000, text: '本地生成 · 无需账号或付费 API' },
|
|
205
|
+
]
|
|
206
|
+
: [],
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { PluginContext } from '@shiqianjiang/ceru-plugin-sdk'
|
|
2
|
+
|
|
3
|
+
// Public, fixed demo material, never production credentials or fresh nonces.
|
|
4
|
+
export const AES_KEY = '00112233445566778899aabbccddeeff'
|
|
5
|
+
export const AES_IV = '102132435465768798a9bacbdcedfe0f'
|
|
6
|
+
export const XOR_MASK = 90
|
|
7
|
+
export const DURATION_MS = 3000
|
|
8
|
+
|
|
9
|
+
/** Generate a quiet 440 Hz, mono, 16-bit PCM WAV without external assets. */
|
|
10
|
+
export function createWav(): Uint8Array {
|
|
11
|
+
const sampleRate = 16000
|
|
12
|
+
const samples = (sampleRate * DURATION_MS) / 1000
|
|
13
|
+
const bytes = new Uint8Array(44 + samples * 2)
|
|
14
|
+
const view = new DataView(bytes.buffer)
|
|
15
|
+
const text = (offset: number, value: string) => {
|
|
16
|
+
for (let index = 0; index < value.length; index++)
|
|
17
|
+
bytes[offset + index] = value.charCodeAt(index)
|
|
18
|
+
}
|
|
19
|
+
text(0, 'RIFF')
|
|
20
|
+
view.setUint32(4, bytes.length - 8, true)
|
|
21
|
+
text(8, 'WAVE')
|
|
22
|
+
text(12, 'fmt ')
|
|
23
|
+
view.setUint32(16, 16, true)
|
|
24
|
+
view.setUint16(20, 1, true)
|
|
25
|
+
view.setUint16(22, 1, true)
|
|
26
|
+
view.setUint32(24, sampleRate, true)
|
|
27
|
+
view.setUint32(28, sampleRate * 2, true)
|
|
28
|
+
view.setUint16(32, 2, true)
|
|
29
|
+
view.setUint16(34, 16, true)
|
|
30
|
+
text(36, 'data')
|
|
31
|
+
view.setUint32(40, samples * 2, true)
|
|
32
|
+
for (let index = 0; index < samples; index++) {
|
|
33
|
+
const fade = Math.min(1, index / 320, (samples - 1 - index) / 320)
|
|
34
|
+
view.setInt16(
|
|
35
|
+
44 + index * 2,
|
|
36
|
+
Math.round(Math.sin((index * 2 * Math.PI * 440) / sampleRate) * 3000 * fade),
|
|
37
|
+
true,
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
return bytes
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function through(
|
|
44
|
+
bytes: Uint8Array,
|
|
45
|
+
stream: TransformStream<Uint8Array, Uint8Array>,
|
|
46
|
+
): Promise<Uint8Array> {
|
|
47
|
+
const source = new ReadableStream<Uint8Array>({
|
|
48
|
+
start(controller) {
|
|
49
|
+
controller.enqueue(bytes)
|
|
50
|
+
controller.close()
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
return new Uint8Array(await new Response(source.pipeThrough(stream)).arrayBuffer())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function createFixtures(ctx: Pick<PluginContext, 'crypto'>) {
|
|
57
|
+
const wav = createWav()
|
|
58
|
+
const aes = await through(wav, ctx.crypto.createCipher('aes-128-ctr', AES_KEY, AES_IV))
|
|
59
|
+
// Own-service provider does its decryption here, then serves ordinary audio.
|
|
60
|
+
// Caching this tiny fixture lets all three routes support exact byte ranges.
|
|
61
|
+
const plain = await through(aes, ctx.crypto.createDecipher('aes-128-ctr', AES_KEY, AES_IV))
|
|
62
|
+
const xor = wav.map((byte) => byte ^ XOR_MASK)
|
|
63
|
+
return { aes, xor, plain }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type Fixtures = Awaited<ReturnType<typeof createFixtures>>
|
|
67
|
+
|
|
68
|
+
/** Single-range GET/HEAD serving for encrypted upstreams and decoded audio. */
|
|
69
|
+
export function serveBytes(request: Request, bytes: Uint8Array, contentType: string): Response {
|
|
70
|
+
const headers = new Headers({
|
|
71
|
+
'content-type': contentType,
|
|
72
|
+
'accept-ranges': 'bytes',
|
|
73
|
+
'cache-control': 'no-store',
|
|
74
|
+
})
|
|
75
|
+
let start = 0
|
|
76
|
+
let end = bytes.length - 1
|
|
77
|
+
const range = request.headers.get('range')
|
|
78
|
+
if (range) {
|
|
79
|
+
const match = /^bytes=(\d*)-(\d*)$/.exec(range)
|
|
80
|
+
if (match && (match[1] || match[2])) {
|
|
81
|
+
start = match[1] ? Number(match[1]) : Math.max(0, bytes.length - Number(match[2]))
|
|
82
|
+
end = match[1] && match[2] ? Math.min(Number(match[2]), end) : end
|
|
83
|
+
}
|
|
84
|
+
if (
|
|
85
|
+
!match ||
|
|
86
|
+
(!match[1] && !match[2]) ||
|
|
87
|
+
(!match[1] && Number(match[2]) <= 0) ||
|
|
88
|
+
!Number.isSafeInteger(start) ||
|
|
89
|
+
!Number.isSafeInteger(end) ||
|
|
90
|
+
start > end ||
|
|
91
|
+
start >= bytes.length
|
|
92
|
+
) {
|
|
93
|
+
headers.set('content-range', `bytes */${bytes.length}`)
|
|
94
|
+
return new Response(null, { status: 416, headers })
|
|
95
|
+
}
|
|
96
|
+
headers.set('content-range', `bytes ${start}-${end}/${bytes.length}`)
|
|
97
|
+
}
|
|
98
|
+
headers.set('content-length', String(end - start + 1))
|
|
99
|
+
return new Response(request.method === 'HEAD' ? null : bytes.slice(start, end + 1), {
|
|
100
|
+
status: range ? 206 : 200,
|
|
101
|
+
headers,
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function createHandler(fixtures: Fixtures) {
|
|
106
|
+
return (request: Request): Response => {
|
|
107
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
108
|
+
return new Response(null, { status: 405, headers: { allow: 'GET, HEAD' } })
|
|
109
|
+
}
|
|
110
|
+
switch (new URL(request.url).pathname) {
|
|
111
|
+
case '/aes.wav.enc':
|
|
112
|
+
return serveBytes(request, fixtures.aes, 'application/octet-stream')
|
|
113
|
+
case '/xor.wav.enc':
|
|
114
|
+
return serveBytes(request, fixtures.xor, 'application/octet-stream')
|
|
115
|
+
case '/plain.wav':
|
|
116
|
+
return serveBytes(request, fixtures.plain, 'audio/wav')
|
|
117
|
+
case '/health':
|
|
118
|
+
return new Response(request.method === 'HEAD' ? null : 'encrypted-source ready\n', {
|
|
119
|
+
headers: { 'content-type': 'text/plain', 'cache-control': 'no-store' },
|
|
120
|
+
})
|
|
121
|
+
default:
|
|
122
|
+
return new Response(null, { status: 404 })
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|