@shiqianjiang/ceru-plugin-cli 0.2.6 → 0.3.2
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 +8 -0
- package/assets/core-contracts.js +1 -1
- package/assets/index.html +94 -94
- package/assets/native-view.js +125 -0
- package/assets/playground.js +109 -11
- package/assets/sandbox.js +22 -22
- package/assets/style.css +46 -0
- package/dist/dev.js +9 -14
- package/dist/storage.d.ts +12 -0
- package/dist/storage.js +65 -0
- package/package.json +71 -71
- package/schemas/config.schema.json +166 -1
- package/templates/connected-library/js/README.md +6 -2
- package/templates/connected-library/js/ceru.plugin.json +11 -2
- package/templates/connected-library/js/package.json +22 -22
- package/templates/connected-library/js/src/index.js +52 -1
- package/templates/connected-library/ts/README.md +6 -2
- package/templates/connected-library/ts/ceru.plugin.json +11 -2
- package/templates/connected-library/ts/package.json +22 -22
- package/templates/connected-library/ts/src/index.ts +52 -1
- package/templates/guest-adapter/js/package.json +22 -22
- package/templates/guest-adapter/ts/package.json +22 -22
- package/templates/importer/js/package.json +22 -22
- package/templates/importer/ts/package.json +22 -22
- package/templates/react/js/package.json +26 -26
- package/templates/react/ts/package.json +26 -26
- package/templates/snapshot.json +1 -1
- package/templates/source/js/package.json +22 -22
- package/templates/source/ts/package.json +22 -22
- package/templates/vue/js/package.json +23 -23
- package/templates/vue/ts/package.json +23 -23
- package/templates/vue-tsx/js/package.json +23 -23
- package/templates/vue-tsx/ts/package.json +23 -23
- package/templates/web-dist/js/package.json +22 -22
- package/templates/web-dist/ts/package.json +22 -22
- package/templates/web-surface/js/ceru.plugin.json +31 -2
- package/templates/web-surface/js/package.json +22 -22
- package/templates/web-surface/js/src/index.js +7 -0
- package/templates/web-surface/ts/ceru.plugin.json +31 -2
- package/templates/web-surface/ts/package.json +22 -22
- package/templates/web-surface/ts/src/index.ts +7 -0
package/assets/style.css
CHANGED
|
@@ -186,6 +186,52 @@ pre {
|
|
|
186
186
|
.preview {
|
|
187
187
|
min-height: 150px;
|
|
188
188
|
}
|
|
189
|
+
.native-actions {
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-wrap: wrap;
|
|
192
|
+
gap: 8px;
|
|
193
|
+
margin: 8px 0;
|
|
194
|
+
}
|
|
195
|
+
.native-section { margin: 20px 0; }
|
|
196
|
+
.native-grid {
|
|
197
|
+
display: grid;
|
|
198
|
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
199
|
+
gap: 20px;
|
|
200
|
+
}
|
|
201
|
+
.native-item { min-width: 0; }
|
|
202
|
+
.native-item-title {
|
|
203
|
+
display: block;
|
|
204
|
+
padding: 0;
|
|
205
|
+
margin: 8px 0;
|
|
206
|
+
border: 0;
|
|
207
|
+
text-align: left;
|
|
208
|
+
background: transparent;
|
|
209
|
+
color: inherit;
|
|
210
|
+
}
|
|
211
|
+
.native-item .hint {
|
|
212
|
+
overflow: hidden;
|
|
213
|
+
display: -webkit-box;
|
|
214
|
+
-webkit-box-orient: vertical;
|
|
215
|
+
-webkit-line-clamp: 2;
|
|
216
|
+
}
|
|
217
|
+
.native-artwork {
|
|
218
|
+
display: block;
|
|
219
|
+
width: 100%;
|
|
220
|
+
aspect-ratio: 1;
|
|
221
|
+
object-fit: cover;
|
|
222
|
+
border-radius: 8px;
|
|
223
|
+
background: var(--line);
|
|
224
|
+
}
|
|
225
|
+
.native-list .native-item {
|
|
226
|
+
display: flex;
|
|
227
|
+
justify-content: space-between;
|
|
228
|
+
align-items: center;
|
|
229
|
+
gap: 16px;
|
|
230
|
+
border-bottom: 1px solid var(--line);
|
|
231
|
+
padding: 10px 0;
|
|
232
|
+
}
|
|
233
|
+
.native-list .native-item-content { display: flex; gap: 12px; align-items: center; }
|
|
234
|
+
.native-list .native-artwork { width: 48px; flex-shrink: 0; }
|
|
189
235
|
.preview iframe {
|
|
190
236
|
width: 100%;
|
|
191
237
|
min-height: 280px;
|
package/dist/dev.js
CHANGED
|
@@ -13,6 +13,7 @@ import { randomBytes, createHash } from 'node:crypto';
|
|
|
13
13
|
import { spawn } from 'node:child_process';
|
|
14
14
|
import { readArtifact, parseJsonStrict, resolveArtifactConfig, } from '@shiqianjiang/ceru-plugin-issuer';
|
|
15
15
|
import { buildProject } from './project.js';
|
|
16
|
+
import { DevelopmentStorage } from './storage.js';
|
|
16
17
|
const asset = (name) => fileURLToPath(new URL('../assets/' + name, import.meta.url));
|
|
17
18
|
function mergeConfig(base, override) {
|
|
18
19
|
const result = structuredClone(base);
|
|
@@ -237,7 +238,7 @@ export async function runDev(project, options = {}) {
|
|
|
237
238
|
const effectiveConfig = () => mergeConfig(resolveArtifactConfig(artifact.header), configOverride);
|
|
238
239
|
const sockets = new SocketBroker();
|
|
239
240
|
const operations = new Map();
|
|
240
|
-
|
|
241
|
+
let storage = new DevelopmentStorage(root, artifact.header.manifest.id);
|
|
241
242
|
const rebuild = async () => {
|
|
242
243
|
if (running) {
|
|
243
244
|
dirty = true;
|
|
@@ -249,6 +250,7 @@ export async function runDev(project, options = {}) {
|
|
|
249
250
|
try {
|
|
250
251
|
build = await prepare();
|
|
251
252
|
artifact = readArtifact(await readFile(build.path));
|
|
253
|
+
storage = new DevelopmentStorage(root, artifact.header.manifest.id);
|
|
252
254
|
revision++;
|
|
253
255
|
error = null;
|
|
254
256
|
sockets.closeAll();
|
|
@@ -428,18 +430,10 @@ export async function runDev(project, options = {}) {
|
|
|
428
430
|
});
|
|
429
431
|
return;
|
|
430
432
|
}
|
|
431
|
-
if (
|
|
432
|
-
json(200, {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if (input.method === 'storage.set') {
|
|
436
|
-
storage.set(String(data.key), data.value);
|
|
437
|
-
json(200, { value: null });
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (input.method === 'storage.delete') {
|
|
441
|
-
storage.delete(String(data.key));
|
|
442
|
-
json(200, { value: null });
|
|
433
|
+
if (['storage.get', 'storage.set', 'storage.delete'].includes(input.method)) {
|
|
434
|
+
json(200, {
|
|
435
|
+
value: await storage.invoke(input.method.slice(8), data.key, data.value),
|
|
436
|
+
});
|
|
443
437
|
return;
|
|
444
438
|
}
|
|
445
439
|
if (input.method === 'permissions.query') {
|
|
@@ -552,7 +546,7 @@ export async function runDev(project, options = {}) {
|
|
|
552
546
|
type = 'text/html';
|
|
553
547
|
response.setHeader('Content-Security-Policy', "default-src 'none'; script-src 'self' 'nonce-" +
|
|
554
548
|
nonce +
|
|
555
|
-
"'; style-src 'self'; img-src 'self' data:; media-src 'self' http: https: data: blob:; connect-src 'self'; frame-src 'self'; frame-ancestors 'none'; base-uri 'none'; object-src 'none'");
|
|
549
|
+
"'; style-src 'self'; img-src 'self' data: http: https:; media-src 'self' http: https: data: blob:; connect-src 'self'; frame-src 'self'; frame-ancestors 'none'; base-uri 'none'; object-src 'none'");
|
|
556
550
|
}
|
|
557
551
|
else if (url.pathname === '/sandbox.html') {
|
|
558
552
|
const moduleId = url.searchParams.get('module') ?? '';
|
|
@@ -582,6 +576,7 @@ export async function runDev(project, options = {}) {
|
|
|
582
576
|
else {
|
|
583
577
|
const file = {
|
|
584
578
|
'/playground.js': 'playground.js',
|
|
579
|
+
'/native-view.js': 'native-view.js',
|
|
585
580
|
'/core-contracts.js': 'core-contracts.js',
|
|
586
581
|
'/style.css': 'style.css',
|
|
587
582
|
'/sandbox.js': 'sandbox.js',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Private development data; persists across preview restarts and never enters the artifact. */
|
|
2
|
+
export declare class DevelopmentStorage {
|
|
3
|
+
private readonly pluginId;
|
|
4
|
+
private values;
|
|
5
|
+
private initialized?;
|
|
6
|
+
private writes;
|
|
7
|
+
private readonly path;
|
|
8
|
+
constructor(root: string, pluginId: string);
|
|
9
|
+
private initialize;
|
|
10
|
+
private key;
|
|
11
|
+
invoke(method: 'get' | 'set' | 'delete', ref: unknown, value?: unknown): Promise<unknown>;
|
|
12
|
+
}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile, rename } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
/** Private development data; persists across preview restarts and never enters the artifact. */
|
|
5
|
+
export class DevelopmentStorage {
|
|
6
|
+
pluginId;
|
|
7
|
+
values = new Map();
|
|
8
|
+
initialized;
|
|
9
|
+
writes = Promise.resolve();
|
|
10
|
+
path;
|
|
11
|
+
constructor(root, pluginId) {
|
|
12
|
+
this.pluginId = pluginId;
|
|
13
|
+
this.path = resolve(root, '.ceru-dev/storage', createHash('sha256').update(pluginId).digest('hex') + '.json');
|
|
14
|
+
}
|
|
15
|
+
initialize() {
|
|
16
|
+
return (this.initialized ??= (async () => {
|
|
17
|
+
try {
|
|
18
|
+
const values = JSON.parse(await readFile(this.path, 'utf8'));
|
|
19
|
+
if (!Array.isArray(values))
|
|
20
|
+
throw new Error('Invalid development storage');
|
|
21
|
+
this.values = new Map(values);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error.code !== 'ENOENT')
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
})());
|
|
28
|
+
}
|
|
29
|
+
key(value) {
|
|
30
|
+
if (value?.pluginId && value.pluginId !== this.pluginId)
|
|
31
|
+
throw new Error('Cross-plugin storage requires an installed Host');
|
|
32
|
+
const key = typeof value === 'string' ? value : value?.key;
|
|
33
|
+
if (typeof key !== 'string' || !key || key.length > 256)
|
|
34
|
+
throw new Error('Invalid storage key');
|
|
35
|
+
return key;
|
|
36
|
+
}
|
|
37
|
+
async invoke(method, ref, value) {
|
|
38
|
+
await this.initialize();
|
|
39
|
+
const key = this.key(ref);
|
|
40
|
+
if (method === 'get') {
|
|
41
|
+
await this.writes;
|
|
42
|
+
return structuredClone(this.values.get(key) ?? null);
|
|
43
|
+
}
|
|
44
|
+
const job = this.writes
|
|
45
|
+
.catch(() => { })
|
|
46
|
+
.then(async () => {
|
|
47
|
+
const next = new Map(this.values);
|
|
48
|
+
if (method === 'set')
|
|
49
|
+
next.set(key, value);
|
|
50
|
+
else
|
|
51
|
+
next.delete(key);
|
|
52
|
+
const data = JSON.stringify([...next]);
|
|
53
|
+
if (Buffer.byteLength(data) > 10 * 1024 * 1024)
|
|
54
|
+
throw new Error('Storage exceeds 10 MiB');
|
|
55
|
+
await mkdir(resolve(this.path, '..'), { recursive: true });
|
|
56
|
+
const temporary = this.path + '.' + randomUUID() + '.tmp';
|
|
57
|
+
await writeFile(temporary, data, { mode: 0o600 });
|
|
58
|
+
await rename(temporary, this.path);
|
|
59
|
+
this.values = next;
|
|
60
|
+
return null;
|
|
61
|
+
});
|
|
62
|
+
this.writes = job.catch(() => { });
|
|
63
|
+
return job;
|
|
64
|
+
}
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@shiqianjiang/ceru-plugin-cli",
|
|
3
|
-
"version": "0.2
|
|
4
|
-
"description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"default": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"ceru-plugin": "dist/bin.js"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"assets",
|
|
21
|
-
"schemas",
|
|
22
|
-
"templates",
|
|
23
|
-
"README.md",
|
|
24
|
-
"LICENSE",
|
|
25
|
-
"ASSET_LICENSE",
|
|
26
|
-
"NOTICE"
|
|
27
|
-
],
|
|
28
|
-
"license": "MIT AND AGPL-3.0-only",
|
|
29
|
-
"author": "澜音团队",
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=22.12.0"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.29.7",
|
|
35
|
-
"@shiqianjiang/ceru-plugin-issuer": "0.2
|
|
36
|
-
"@shiqianjiang/ceru-plugin-sdk": "0.2
|
|
37
|
-
"@vue/babel-plugin-jsx": "^2.0.1",
|
|
38
|
-
"@vue/compiler-sfc": "3.5.43",
|
|
39
|
-
"axios": "^1.20.0",
|
|
40
|
-
"esbuild": "^0.28.2",
|
|
41
|
-
"lodash-es": "^4.18.1",
|
|
42
|
-
"parse5": "^8.0.1",
|
|
43
|
-
"react": "19.3.0",
|
|
44
|
-
"react-dom": "19.3.0",
|
|
45
|
-
"semver": "^7.7.0",
|
|
46
|
-
"socket.io-client": "^4.8.3",
|
|
47
|
-
"typescript": "~5.9.3",
|
|
48
|
-
"vue": "3.5.43",
|
|
49
|
-
"vue-tsc": "^3.3.11",
|
|
50
|
-
"ws": "^8.21.3"
|
|
51
|
-
},
|
|
52
|
-
"publishConfig": {
|
|
53
|
-
"access": "public",
|
|
54
|
-
"registry": "https://registry.npmjs.org/"
|
|
55
|
-
},
|
|
56
|
-
"repository": {
|
|
57
|
-
"type": "git",
|
|
58
|
-
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
59
|
-
"directory": "packages/cli"
|
|
60
|
-
},
|
|
61
|
-
"bugs": {
|
|
62
|
-
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
63
|
-
},
|
|
64
|
-
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
65
|
-
"keywords": [
|
|
66
|
-
"ceru-music",
|
|
67
|
-
"plugin",
|
|
68
|
-
"typescript",
|
|
69
|
-
"electron"
|
|
70
|
-
]
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@shiqianjiang/ceru-plugin-cli",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"ceru-plugin": "dist/bin.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"assets",
|
|
21
|
+
"schemas",
|
|
22
|
+
"templates",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"ASSET_LICENSE",
|
|
26
|
+
"NOTICE"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT AND AGPL-3.0-only",
|
|
29
|
+
"author": "澜音团队",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22.12.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/core": "^7.29.7",
|
|
35
|
+
"@shiqianjiang/ceru-plugin-issuer": "0.3.2",
|
|
36
|
+
"@shiqianjiang/ceru-plugin-sdk": "0.3.2",
|
|
37
|
+
"@vue/babel-plugin-jsx": "^2.0.1",
|
|
38
|
+
"@vue/compiler-sfc": "3.5.43",
|
|
39
|
+
"axios": "^1.20.0",
|
|
40
|
+
"esbuild": "^0.28.2",
|
|
41
|
+
"lodash-es": "^4.18.1",
|
|
42
|
+
"parse5": "^8.0.1",
|
|
43
|
+
"react": "19.3.0",
|
|
44
|
+
"react-dom": "19.3.0",
|
|
45
|
+
"semver": "^7.7.0",
|
|
46
|
+
"socket.io-client": "^4.8.3",
|
|
47
|
+
"typescript": "~5.9.3",
|
|
48
|
+
"vue": "3.5.43",
|
|
49
|
+
"vue-tsc": "^3.3.11",
|
|
50
|
+
"ws": "^8.21.3"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
59
|
+
"directory": "packages/cli"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
65
|
+
"keywords": [
|
|
66
|
+
"ceru-music",
|
|
67
|
+
"plugin",
|
|
68
|
+
"typescript",
|
|
69
|
+
"electron"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
@@ -126,6 +126,43 @@
|
|
|
126
126
|
],
|
|
127
127
|
"additionalProperties": false
|
|
128
128
|
},
|
|
129
|
+
"share": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"properties": {
|
|
132
|
+
"entry": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
135
|
+
},
|
|
136
|
+
"configKeys": {
|
|
137
|
+
"type": "array",
|
|
138
|
+
"items": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"minLength": 1,
|
|
141
|
+
"maxLength": 4096
|
|
142
|
+
},
|
|
143
|
+
"maxItems": 128,
|
|
144
|
+
"uniqueItems": true
|
|
145
|
+
},
|
|
146
|
+
"guestAdapterId": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
149
|
+
},
|
|
150
|
+
"guestGlobals": {
|
|
151
|
+
"type": "array",
|
|
152
|
+
"items": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"minLength": 1,
|
|
155
|
+
"maxLength": 4096
|
|
156
|
+
},
|
|
157
|
+
"maxItems": 128,
|
|
158
|
+
"uniqueItems": true
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"required": [
|
|
162
|
+
"entry"
|
|
163
|
+
],
|
|
164
|
+
"additionalProperties": false
|
|
165
|
+
},
|
|
129
166
|
"surfaces": {
|
|
130
167
|
"type": "array",
|
|
131
168
|
"maxItems": 64,
|
|
@@ -139,12 +176,58 @@
|
|
|
139
176
|
"kind": {
|
|
140
177
|
"enum": [
|
|
141
178
|
"schema",
|
|
142
|
-
"web"
|
|
179
|
+
"web",
|
|
180
|
+
"native"
|
|
143
181
|
]
|
|
144
182
|
},
|
|
145
183
|
"entry": {
|
|
146
184
|
"type": "string",
|
|
147
185
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
186
|
+
},
|
|
187
|
+
"title": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"minLength": 1,
|
|
190
|
+
"maxLength": 100
|
|
191
|
+
},
|
|
192
|
+
"presentation": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"properties": {
|
|
195
|
+
"kind": {
|
|
196
|
+
"const": "drawer"
|
|
197
|
+
},
|
|
198
|
+
"placement": {
|
|
199
|
+
"enum": [
|
|
200
|
+
"left",
|
|
201
|
+
"right",
|
|
202
|
+
"top",
|
|
203
|
+
"bottom"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
"size": {
|
|
207
|
+
"type": "integer",
|
|
208
|
+
"minimum": 280,
|
|
209
|
+
"maximum": 1200
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"required": [
|
|
213
|
+
"kind"
|
|
214
|
+
],
|
|
215
|
+
"additionalProperties": false
|
|
216
|
+
},
|
|
217
|
+
"lifecycle": {
|
|
218
|
+
"type": "object",
|
|
219
|
+
"properties": {
|
|
220
|
+
"openAction": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
223
|
+
},
|
|
224
|
+
"closeAction": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"required": [],
|
|
230
|
+
"additionalProperties": false
|
|
148
231
|
}
|
|
149
232
|
},
|
|
150
233
|
"required": [
|
|
@@ -221,6 +304,11 @@
|
|
|
221
304
|
"type": "string",
|
|
222
305
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
223
306
|
},
|
|
307
|
+
"description": {
|
|
308
|
+
"type": "string",
|
|
309
|
+
"minLength": 1,
|
|
310
|
+
"maxLength": 4096
|
|
311
|
+
},
|
|
224
312
|
"slot": {
|
|
225
313
|
"enum": [
|
|
226
314
|
"playlist.import",
|
|
@@ -298,6 +386,39 @@
|
|
|
298
386
|
"additionalProperties": false
|
|
299
387
|
}
|
|
300
388
|
},
|
|
389
|
+
"accountItems": {
|
|
390
|
+
"type": "array",
|
|
391
|
+
"maxItems": 16,
|
|
392
|
+
"items": {
|
|
393
|
+
"type": "object",
|
|
394
|
+
"properties": {
|
|
395
|
+
"id": {
|
|
396
|
+
"type": "string",
|
|
397
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
398
|
+
},
|
|
399
|
+
"title": {
|
|
400
|
+
"type": "string",
|
|
401
|
+
"minLength": 1,
|
|
402
|
+
"maxLength": 4096
|
|
403
|
+
},
|
|
404
|
+
"view": {
|
|
405
|
+
"type": "string",
|
|
406
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
407
|
+
},
|
|
408
|
+
"action": {
|
|
409
|
+
"type": "string",
|
|
410
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
"required": [
|
|
414
|
+
"id",
|
|
415
|
+
"title",
|
|
416
|
+
"view",
|
|
417
|
+
"action"
|
|
418
|
+
],
|
|
419
|
+
"additionalProperties": false
|
|
420
|
+
}
|
|
421
|
+
},
|
|
301
422
|
"homeSections": {
|
|
302
423
|
"type": "array",
|
|
303
424
|
"maxItems": 32,
|
|
@@ -704,6 +825,11 @@
|
|
|
704
825
|
"minLength": 1,
|
|
705
826
|
"maxLength": 4096
|
|
706
827
|
},
|
|
828
|
+
"description": {
|
|
829
|
+
"type": "string",
|
|
830
|
+
"minLength": 1,
|
|
831
|
+
"maxLength": 4096
|
|
832
|
+
},
|
|
707
833
|
"action": {
|
|
708
834
|
"type": "string",
|
|
709
835
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
@@ -802,6 +928,45 @@
|
|
|
802
928
|
"minLength": 1,
|
|
803
929
|
"maxLength": 4096
|
|
804
930
|
},
|
|
931
|
+
"title": {
|
|
932
|
+
"type": "string",
|
|
933
|
+
"minLength": 1,
|
|
934
|
+
"maxLength": 4096
|
|
935
|
+
},
|
|
936
|
+
"extensions": {
|
|
937
|
+
"type": "array",
|
|
938
|
+
"items": {
|
|
939
|
+
"type": "string",
|
|
940
|
+
"minLength": 1,
|
|
941
|
+
"maxLength": 4096
|
|
942
|
+
},
|
|
943
|
+
"maxItems": 128,
|
|
944
|
+
"uniqueItems": true
|
|
945
|
+
},
|
|
946
|
+
"badge": {
|
|
947
|
+
"type": "object",
|
|
948
|
+
"properties": {
|
|
949
|
+
"label": {
|
|
950
|
+
"type": "string",
|
|
951
|
+
"minLength": 1,
|
|
952
|
+
"maxLength": 24
|
|
953
|
+
},
|
|
954
|
+
"backgroundColor": {
|
|
955
|
+
"type": "string",
|
|
956
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"
|
|
957
|
+
},
|
|
958
|
+
"textColor": {
|
|
959
|
+
"type": "string",
|
|
960
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
"required": [
|
|
964
|
+
"label",
|
|
965
|
+
"backgroundColor",
|
|
966
|
+
"textColor"
|
|
967
|
+
],
|
|
968
|
+
"additionalProperties": false
|
|
969
|
+
},
|
|
805
970
|
"bootstrap": {
|
|
806
971
|
"type": "string",
|
|
807
972
|
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
|
|
@@ -36,8 +36,12 @@ F5 执行当前下拉框中的配置,不会自动选择终端所在的子工
|
|
|
36
36
|
|
|
37
37
|
## 边界
|
|
38
38
|
|
|
39
|
-
本模板面向 v2
|
|
39
|
+
本模板面向 v2 协议,需要支持 native Surface 的 Host。
|
|
40
40
|
凭据保险箱、完整音乐业务和 Guest 安装需要正式 Host;不支持的调试调用会明确报错。
|
|
41
41
|
不要把私人 API Key、卡密或发行私钥提交到仓库。
|
|
42
42
|
|
|
43
|
-
此 demo
|
|
43
|
+
此 demo 展示原生歌单网格、歌曲列表、账号菜单贡献、导入及播放动作,还有连接表单和状态更新;点击“演示连接”不会联网或保存密码。元数据来自本地常量,播放前需实现自己的 tracks.resolve。
|
|
44
|
+
|
|
45
|
+
原生页面由 src/index.js 中的 defineNativeView 返回标准 JSON 内容,Host 使用自己的组件呈现。打开歌单传递完整 ResourceRef,进入 Host 歌单详情;播放调用 Host 队列和播放器;导入调用 Host 现有导入窗口。独立工作台渲染原生预览并记录导航,完整音乐业务由正式 Host 实现。
|
|
46
|
+
|
|
47
|
+
账号摘要返回 signedIn、displayName、可选 avatarUrl/badge;账号变化通过 ctx.ui.setState 通知 Host。自定义账号登录页面也可使用 Vue 或 React 打包为 Web Surface,与原生音乐库页面同时存在。
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"activation": ["onCommand:hello", "onProvider:catalog"]
|
|
17
17
|
},
|
|
18
18
|
"surfaces": [
|
|
19
|
+
{ "id": "library", "kind": "native", "entry": "render.library" },
|
|
19
20
|
{
|
|
20
21
|
"id": "settings",
|
|
21
22
|
"kind": "schema",
|
|
@@ -25,6 +26,11 @@
|
|
|
25
26
|
},
|
|
26
27
|
"contributes": {
|
|
27
28
|
"commands": [
|
|
29
|
+
{ "id": "account.summary", "title": "账号状态", "action": "account.summary" },
|
|
30
|
+
{ "id": "render.library", "title": "渲染音乐库", "action": "render.library" },
|
|
31
|
+
{ "id": "playlist.open", "title": "打开歌单", "action": "playlist.open" },
|
|
32
|
+
{ "id": "playlist.import", "title": "导入歌单", "action": "playlist.import" },
|
|
33
|
+
{ "id": "track.play", "title": "播放", "action": "track.play" },
|
|
28
34
|
{
|
|
29
35
|
"id": "hello",
|
|
30
36
|
"title": "Hello",
|
|
@@ -41,7 +47,7 @@
|
|
|
41
47
|
{
|
|
42
48
|
"id": "catalog",
|
|
43
49
|
"name": "js",
|
|
44
|
-
"protocols": ["music.search@1", "music.resolve@1"],
|
|
50
|
+
"protocols": ["music.search@1", "music.resolve@1", "music.playlists@1"],
|
|
45
51
|
"icon": {
|
|
46
52
|
"kind": "host",
|
|
47
53
|
"name": "music-note"
|
|
@@ -49,6 +55,9 @@
|
|
|
49
55
|
"connectionMode": "multiple"
|
|
50
56
|
}
|
|
51
57
|
],
|
|
58
|
+
"homeSections": [{ "id": "library", "title": "我的音乐库", "kind": "custom", "view": "library" }],
|
|
59
|
+
"accountItems": [{ "id": "catalog", "title": "音乐库账号", "view": "settings", "action": "account.summary" }],
|
|
60
|
+
"playlistImporters": [{ "id": "catalog", "title": "演示歌单", "providerId": "catalog" }],
|
|
52
61
|
"settingsPages": [
|
|
53
62
|
{
|
|
54
63
|
"id": "settings",
|
|
@@ -57,7 +66,7 @@
|
|
|
57
66
|
}
|
|
58
67
|
]
|
|
59
68
|
},
|
|
60
|
-
"permissions": [],
|
|
69
|
+
"permissions": [{ "key": "playback", "name": "player.control", "reason": "使用 Host 的播放器和队列播放音乐库歌曲" }],
|
|
61
70
|
"dataSchemas": {
|
|
62
71
|
"config": 1,
|
|
63
72
|
"state": 1
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "js",
|
|
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": "tsc --noEmit",
|
|
10
|
-
"validate": "ceru-plugin validate dist/plugin.js",
|
|
11
|
-
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@shiqianjiang/ceru-plugin-sdk": "^0.2
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@shiqianjiang/ceru-plugin-cli": "^0.2
|
|
18
|
-
"typescript": "~5.9.3",
|
|
19
|
-
"electron": "^44.4.2",
|
|
20
|
-
"prettier": "^3.6.2"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "js",
|
|
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": "tsc --noEmit",
|
|
10
|
+
"validate": "ceru-plugin validate dist/plugin.js",
|
|
11
|
+
"preview": "ceru-plugin preview dist/plugin.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@shiqianjiang/ceru-plugin-sdk": "^0.3.2"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@shiqianjiang/ceru-plugin-cli": "^0.3.2",
|
|
18
|
+
"typescript": "~5.9.3",
|
|
19
|
+
"electron": "^44.4.2",
|
|
20
|
+
"prettier": "^3.6.2"
|
|
21
|
+
}
|
|
22
|
+
}
|