@shiqianjiang/ceru-plugin-issuer 0.2.2 → 0.2.4
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/dist/index.js +50 -8
- package/package.json +49 -49
package/dist/index.js
CHANGED
|
@@ -128,6 +128,7 @@ export const MANIFEST_SCHEMA = object({
|
|
|
128
128
|
author: string,
|
|
129
129
|
publisher: string,
|
|
130
130
|
license: string,
|
|
131
|
+
homepage: string,
|
|
131
132
|
config: { type: 'object', additionalProperties: true },
|
|
132
133
|
engines: object({
|
|
133
134
|
hostApi: string,
|
|
@@ -148,6 +149,7 @@ export const MANIFEST_SCHEMA = object({
|
|
|
148
149
|
},
|
|
149
150
|
}),
|
|
150
151
|
contributes: object({
|
|
152
|
+
lyricConverters: { type: 'array', maxItems: 16, items: object({ id, title: string, formats: { type: 'array', items: { enum: ['auto', 'lrc', 'enhanced-lrc', 'yrc', 'qrc', 'krc', 'ttml', 'plain'] }, uniqueItems: true } }, ['id', 'title', 'formats']) },
|
|
151
153
|
menus: {
|
|
152
154
|
type: 'array',
|
|
153
155
|
maxItems: 64,
|
|
@@ -246,7 +248,7 @@ export const MANIFEST_SCHEMA = object({
|
|
|
246
248
|
playlistImporters: {
|
|
247
249
|
type: 'array',
|
|
248
250
|
maxItems: 64,
|
|
249
|
-
items: object({ id, title: string, description: string, placeholder: string }, [
|
|
251
|
+
items: object({ id, title: string, description: string, placeholder: string, providerId: id, examples: { type: 'array', maxItems: 16, items: object({ label: string, value: string }, ['label', 'value']) }, instructions: strings }, [
|
|
250
252
|
'id',
|
|
251
253
|
'title',
|
|
252
254
|
]),
|
|
@@ -258,6 +260,7 @@ export const MANIFEST_SCHEMA = object({
|
|
|
258
260
|
id,
|
|
259
261
|
name: string,
|
|
260
262
|
protocols: strings,
|
|
263
|
+
qualities: strings,
|
|
261
264
|
connectionMode: { enum: ['none', 'single', 'multiple'] },
|
|
262
265
|
icon: {
|
|
263
266
|
oneOf: [
|
|
@@ -609,6 +612,35 @@ function inspectBody(body, manifest) {
|
|
|
609
612
|
let registry;
|
|
610
613
|
const preamble = [];
|
|
611
614
|
const functions = new Map();
|
|
615
|
+
const bindings = new Map();
|
|
616
|
+
const selfContained = new Set();
|
|
617
|
+
const staticOrReference = (node, depth = 0) => {
|
|
618
|
+
ensure(depth <= 64, 'Static export nesting exceeds 64');
|
|
619
|
+
if (node.type === 'Identifier' || node.type === 'Literal')
|
|
620
|
+
return;
|
|
621
|
+
if (node.type === 'UnaryExpression' &&
|
|
622
|
+
node.operator === '-' &&
|
|
623
|
+
node.argument.type === 'Literal')
|
|
624
|
+
return;
|
|
625
|
+
if (node.type === 'ArrayExpression') {
|
|
626
|
+
for (const item of node.elements) {
|
|
627
|
+
ensure(item, 'Array holes are forbidden');
|
|
628
|
+
staticOrReference(item, depth + 1);
|
|
629
|
+
}
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
for (const [, child] of astObject(node))
|
|
633
|
+
staticOrReference(child, depth + 1);
|
|
634
|
+
};
|
|
635
|
+
const resolveBinding = (node) => {
|
|
636
|
+
const seen = new Set();
|
|
637
|
+
while (node?.type === 'Identifier' && bindings.has(node.name)) {
|
|
638
|
+
ensure(!seen.has(node.name), 'Circular top-level binding: ' + node.name);
|
|
639
|
+
seen.add(node.name);
|
|
640
|
+
node = bindings.get(node.name);
|
|
641
|
+
}
|
|
642
|
+
return node;
|
|
643
|
+
};
|
|
612
644
|
let sourceFormat = 'exports-v2';
|
|
613
645
|
if (tree.body.length === 1 &&
|
|
614
646
|
tree.body[0].type === 'ExpressionStatement' &&
|
|
@@ -645,9 +677,15 @@ function inspectBody(body, manifest) {
|
|
|
645
677
|
const isStatic = init && ['Literal', 'ObjectExpression', 'ArrayExpression'].includes(init.type);
|
|
646
678
|
ensure(isFunction || isRequire || isStatic, 'Top-level variables must be static data, functions, or require() imports');
|
|
647
679
|
if (isStatic)
|
|
648
|
-
|
|
649
|
-
if (declaration.id.type === 'Identifier'
|
|
650
|
-
|
|
680
|
+
staticOrReference(init);
|
|
681
|
+
if (declaration.id.type === 'Identifier') {
|
|
682
|
+
bindings.set(declaration.id.name, init);
|
|
683
|
+
if (isFunction) {
|
|
684
|
+
functions.set(declaration.id.name, init);
|
|
685
|
+
if (body.slice(declaration.id.end, init.start).includes('@ceru-self-contained'))
|
|
686
|
+
selfContained.add(declaration.id.name);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
651
689
|
}
|
|
652
690
|
preamble.push(body.slice(statement.start, statement.end));
|
|
653
691
|
continue;
|
|
@@ -675,21 +713,24 @@ function inspectBody(body, manifest) {
|
|
|
675
713
|
value: node,
|
|
676
714
|
});
|
|
677
715
|
if (exported.has('modules'))
|
|
678
|
-
for (const [key, node] of astObject(exported.get('modules')))
|
|
716
|
+
for (const [key, node] of astObject(resolveBinding(exported.get('modules'))))
|
|
679
717
|
addModule(key, node);
|
|
680
718
|
if (exported.has('activate')) {
|
|
681
719
|
ensure(manifest.modules.logic, 'activate requires modules.logic');
|
|
682
720
|
addModule(manifest.modules.logic.entry, exported.get('activate'));
|
|
683
721
|
}
|
|
684
722
|
if (exported.has('surfaces'))
|
|
685
|
-
for (const [id, node] of astObject(exported.get('surfaces'))) {
|
|
723
|
+
for (const [id, node] of astObject(resolveBinding(exported.get('surfaces')))) {
|
|
686
724
|
const surface = manifest.modules.surfaces?.find((item) => item.id === id && item.kind === 'web');
|
|
687
725
|
ensure(surface, 'Unknown visible surface: ' + id);
|
|
688
726
|
addModule(surface.entry, node);
|
|
689
727
|
}
|
|
690
728
|
registry = new Map([
|
|
691
729
|
['modules', { type: 'ObjectExpression', properties }],
|
|
692
|
-
[
|
|
730
|
+
[
|
|
731
|
+
'resources',
|
|
732
|
+
resolveBinding(exported.get('resources')) ?? { type: 'ObjectExpression', properties: [] },
|
|
733
|
+
],
|
|
693
734
|
]);
|
|
694
735
|
}
|
|
695
736
|
const modules = Object.create(null);
|
|
@@ -701,7 +742,8 @@ function inspectBody(body, manifest) {
|
|
|
701
742
|
!node.generator &&
|
|
702
743
|
node.params.length <= 1 &&
|
|
703
744
|
(!node.params.length || node.params[0].type === 'Identifier'), 'Module must be a function with one context parameter');
|
|
704
|
-
|
|
745
|
+
const generatedEntry = exportedNode.type === 'Identifier' && selfContained.has(exportedNode.name);
|
|
746
|
+
modules[key] = preamble.length && !generatedEntry
|
|
705
747
|
? 'async function(ctx) {\n' +
|
|
706
748
|
preamble.join('\n') +
|
|
707
749
|
'\nreturn (' +
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@shiqianjiang/ceru-plugin-issuer",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Static verification, Ed25519 signing and cached personalized issuance of Ceru single-JS 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
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"README.md",
|
|
18
|
-
"LICENSE"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"author": "澜音团队",
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": ">=22.12.0"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@shiqianjiang/ceru-plugin-sdk": "0.2.
|
|
27
|
-
"acorn": "^8.18.0",
|
|
28
|
-
"ajv": "^8.20.0"
|
|
29
|
-
},
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public",
|
|
32
|
-
"registry": "https://registry.npmjs.org/"
|
|
33
|
-
},
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
37
|
-
"directory": "packages/issuer"
|
|
38
|
-
},
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
43
|
-
"keywords": [
|
|
44
|
-
"ceru-music",
|
|
45
|
-
"plugin",
|
|
46
|
-
"typescript",
|
|
47
|
-
"electron"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@shiqianjiang/ceru-plugin-issuer",
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "Static verification, Ed25519 signing and cached personalized issuance of Ceru single-JS 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
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "澜音团队",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.12.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@shiqianjiang/ceru-plugin-sdk": "0.2.4",
|
|
27
|
+
"acorn": "^8.18.0",
|
|
28
|
+
"ajv": "^8.20.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
37
|
+
"directory": "packages/issuer"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
43
|
+
"keywords": [
|
|
44
|
+
"ceru-music",
|
|
45
|
+
"plugin",
|
|
46
|
+
"typescript",
|
|
47
|
+
"electron"
|
|
48
|
+
]
|
|
49
|
+
}
|