@shiqianjiang/ceru-plugin-cli 0.3.15 → 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
package/dist/frameworks.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type Plugin } from 'esbuild';
|
|
2
2
|
/** Side-effect stylesheet imports must survive single-file builds (React/Vue/vanilla). */
|
|
3
|
-
export declare function stylesheetPlugin(): Plugin;
|
|
4
|
-
export declare function vuePlugin(root: string, framework?: string
|
|
3
|
+
export declare function stylesheetPlugin(styles?: Set<string>): Plugin;
|
|
4
|
+
export declare function vuePlugin(root: string, framework?: string, styles?: Set<string>, track?: {
|
|
5
|
+
dependency(): void;
|
|
6
|
+
source(file: string, text: string): void;
|
|
7
|
+
}): Plugin;
|
|
5
8
|
/** Convert a local, already-built SPA into a Surface entry. No uploaded HTML is executed by the CLI. */
|
|
6
9
|
export declare function webDistEntry(directoryInput: string): Promise<{
|
|
7
10
|
plugin: Plugin;
|
package/dist/frameworks.js
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname, resolve, relative, isAbsolute, sep, extname } from 'node:path'
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { build } from 'esbuild';
|
|
6
|
-
import { parse as parseSfc, compileScript, compileStyleAsync } from '@vue/compiler-sfc';
|
|
6
|
+
import { parse as parseSfc, compileScript, compileStyleAsync, compileTemplate } from '@vue/compiler-sfc';
|
|
7
7
|
import { transformAsync } from '@babel/core';
|
|
8
8
|
import vueJsx from '@vue/babel-plugin-jsx';
|
|
9
9
|
import { parse as parseHtml, serialize } from 'parse5';
|
|
@@ -30,11 +30,12 @@ function styleCode(css, id) {
|
|
|
30
30
|
JSON.stringify(css) +
|
|
31
31
|
';document.head.append(s); }\n');
|
|
32
32
|
}
|
|
33
|
-
async function cssBundle(css, directory) {
|
|
33
|
+
async function cssBundle(css, directory, dependency) {
|
|
34
34
|
const result = await build({
|
|
35
35
|
stdin: { contents: css, loader: 'css', resolveDir: directory },
|
|
36
36
|
bundle: true,
|
|
37
37
|
write: false,
|
|
38
|
+
metafile: !!dependency,
|
|
38
39
|
outfile: 'style.css',
|
|
39
40
|
loader: loaders,
|
|
40
41
|
logLevel: 'silent',
|
|
@@ -53,15 +54,21 @@ async function cssBundle(css, directory) {
|
|
|
53
54
|
});
|
|
54
55
|
if (result.outputFiles.length !== 1)
|
|
55
56
|
throw new Error('CSS emitted an external resource');
|
|
57
|
+
if (result.metafile && Object.keys(result.metafile.inputs).some(input => input !== '<stdin>'))
|
|
58
|
+
dependency?.();
|
|
56
59
|
return result.outputFiles[0].text;
|
|
57
60
|
}
|
|
58
61
|
/** Side-effect stylesheet imports must survive single-file builds (React/Vue/vanilla). */
|
|
59
|
-
export function stylesheetPlugin() {
|
|
62
|
+
export function stylesheetPlugin(styles) {
|
|
60
63
|
return {
|
|
61
64
|
name: 'ceru-inline-stylesheets',
|
|
62
65
|
setup(ctx) {
|
|
63
66
|
ctx.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
64
67
|
const css = await cssBundle(await readFile(args.path, 'utf8'), dirname(args.path));
|
|
68
|
+
if (styles) {
|
|
69
|
+
styles.add(css);
|
|
70
|
+
return { contents: 'export default ' + JSON.stringify(css), loader: 'js' };
|
|
71
|
+
}
|
|
65
72
|
const id = createHash('sha256').update(css).digest('hex').slice(0, 16);
|
|
66
73
|
return {
|
|
67
74
|
contents: 'export default ' + JSON.stringify(css) + ';' + styleCode(css, id),
|
|
@@ -72,17 +79,24 @@ export function stylesheetPlugin() {
|
|
|
72
79
|
},
|
|
73
80
|
};
|
|
74
81
|
}
|
|
75
|
-
export function vuePlugin(root, framework) {
|
|
82
|
+
export function vuePlugin(root, framework, styles, track) {
|
|
76
83
|
return {
|
|
77
84
|
name: 'ceru-vue',
|
|
78
85
|
setup(ctx) {
|
|
86
|
+
ctx.onResolve({ filter: /^ceru:sfc-render$/, namespace: 'file' }, args => args.pluginData?.renderCode === undefined ? undefined : {
|
|
87
|
+
path: args.importer, namespace: 'ceru-sfc-render', pluginData: args.pluginData,
|
|
88
|
+
});
|
|
89
|
+
ctx.onLoad({ filter: /.*/, namespace: 'ceru-sfc-render' }, args => ({
|
|
90
|
+
contents: args.pluginData.renderCode, loader: 'ts', resolveDir: dirname(args.path),
|
|
91
|
+
}));
|
|
79
92
|
ctx.onLoad({ filter: /\.vue$/ }, async (args) => {
|
|
80
93
|
const original = await readFile(args.path, 'utf8');
|
|
94
|
+
track?.source(args.path, original);
|
|
81
95
|
let parsed = parseSfc(original, { filename: args.path, sourceMap: true });
|
|
82
96
|
if (parsed.errors.length)
|
|
83
97
|
throw new Error(parsed.errors.map(String).join('\n'));
|
|
84
98
|
if (!parsed.descriptor.script && !parsed.descriptor.scriptSetup)
|
|
85
|
-
parsed = parseSfc('<script>
|
|
99
|
+
parsed = parseSfc('<script setup>void 0</script>\n' + original, {
|
|
86
100
|
filename: args.path,
|
|
87
101
|
});
|
|
88
102
|
const descriptor = parsed.descriptor;
|
|
@@ -97,7 +111,25 @@ export function vuePlugin(root, framework) {
|
|
|
97
111
|
genDefaultAs: '__ceru_component',
|
|
98
112
|
});
|
|
99
113
|
let contents = compiled.content;
|
|
114
|
+
let renderCode;
|
|
115
|
+
if (descriptor.template && !descriptor.scriptSetup) {
|
|
116
|
+
const template = compileTemplate({
|
|
117
|
+
filename: args.path, id, source: descriptor.template.content,
|
|
118
|
+
scoped: descriptor.styles.some(style => style.scoped), slotted: descriptor.slotted,
|
|
119
|
+
preprocessLang: descriptor.template.lang,
|
|
120
|
+
preprocessCustomRequire: createRequire(resolve(root, 'package.json')),
|
|
121
|
+
compilerOptions: { bindingMetadata: compiled.bindings, isTS: ['ts', 'tsx'].includes(descriptor.script?.lang ?? '') },
|
|
122
|
+
});
|
|
123
|
+
if (template.errors.length)
|
|
124
|
+
throw new Error(template.errors.map(String).join('\n'));
|
|
125
|
+
renderCode = template.code;
|
|
126
|
+
contents += '\nimport {render as __ceru_template_render} from "ceru:sfc-render";\n__ceru_component.render = __ceru_template_render;\n';
|
|
127
|
+
}
|
|
128
|
+
if (compiled.deps?.length)
|
|
129
|
+
track?.dependency();
|
|
100
130
|
for (const style of descriptor.styles) {
|
|
131
|
+
if (style.lang && style.lang !== 'css')
|
|
132
|
+
track?.dependency();
|
|
101
133
|
const result = await compileStyleAsync({
|
|
102
134
|
filename: args.path,
|
|
103
135
|
source: style.content,
|
|
@@ -108,7 +140,11 @@ export function vuePlugin(root, framework) {
|
|
|
108
140
|
});
|
|
109
141
|
if (result.errors.length)
|
|
110
142
|
throw new Error(result.errors.map(String).join('\n'));
|
|
111
|
-
|
|
143
|
+
const css = await cssBundle(result.code, dirname(args.path), track?.dependency);
|
|
144
|
+
if (styles)
|
|
145
|
+
styles.add(css);
|
|
146
|
+
else
|
|
147
|
+
contents += styleCode(css, id + String(descriptor.styles.indexOf(style)));
|
|
112
148
|
}
|
|
113
149
|
if (descriptor.styles.some((s) => s.scoped))
|
|
114
150
|
contents += '\n__ceru_component.__scopeId = ' + JSON.stringify('data-v-' + id) + ';';
|
|
@@ -119,6 +155,7 @@ export function vuePlugin(root, framework) {
|
|
|
119
155
|
Buffer.from(JSON.stringify(compiled.map)).toString('base64');
|
|
120
156
|
return {
|
|
121
157
|
contents,
|
|
158
|
+
pluginData: renderCode === undefined ? undefined : { renderCode },
|
|
122
159
|
loader: descriptor.scriptSetup?.lang === 'tsx' || descriptor.script?.lang === 'tsx'
|
|
123
160
|
? 'tsx'
|
|
124
161
|
: 'ts',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { buildProject, loadProject, scaffoldProject, TEMPLATES } from './project.js';
|
|
2
|
-
export declare function runCli(argv?: string[]): Promise<void>;
|
|
2
|
+
export declare function runCli(argv?: string[]): Promise<void | string>;
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,14 @@ import { readFileSync } from 'node:fs';
|
|
|
3
3
|
import { readFile, stat } from 'node:fs/promises';
|
|
4
4
|
import { resolve, extname } from 'node:path';
|
|
5
5
|
import { createTemplate, generateSigningKeys, parseJsonStrict, PreparedIssuer, readArtifact, signArtifact, } from '@shiqianjiang/ceru-plugin-issuer';
|
|
6
|
-
import { buildProject, scaffoldProject, TEMPLATES, writeAtomic } from './project.js';
|
|
7
|
-
import {
|
|
6
|
+
import { buildProject, scaffoldProject, TEMPLATES, typecheckProject, writeAtomic } from './project.js';
|
|
7
|
+
import { migrateProject } from './migrate.js';
|
|
8
|
+
import { testHooks } from './test-hooks.js';
|
|
9
|
+
import { testServices } from './test-services.js';
|
|
10
|
+
import { watchProject } from './dev.js';
|
|
8
11
|
import { printInitSummary, promptInit } from './init.js';
|
|
9
12
|
import { PromptCancelled } from './tui.js';
|
|
13
|
+
import { checkCompatibility, formatCompatibility } from './compatibility.js';
|
|
10
14
|
export { buildProject, loadProject, scaffoldProject, TEMPLATES } from './project.js';
|
|
11
15
|
const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
12
16
|
const HELP = 'Ceru Plugin CLI ' +
|
|
@@ -16,16 +20,21 @@ const HELP = 'Ceru Plugin CLI ' +
|
|
|
16
20
|
TEMPLATES.join('|') +
|
|
17
21
|
'] [--lang ts|js]\n' +
|
|
18
22
|
' list-templates\n' +
|
|
23
|
+
' test-hooks [--project directory] [--config tests/hooks.json] Build and run offline playback hook scenarios\n' +
|
|
24
|
+
' test-services [--project directory] [--config tests/services.json] Run actions against local mockServices\n' +
|
|
25
|
+
' migrate [--project directory]\n' +
|
|
26
|
+
' typecheck [--project directory] Check manifest, config types, TS and Vue without writing dist\n' +
|
|
27
|
+
' check-compat [--project directory] [--host profile.json] [--json] Check host API, component libraries and region versions\n' +
|
|
19
28
|
' build [--project directory] [--out dist/plugin.js]\n' +
|
|
20
|
-
' dev [--project directory]
|
|
21
|
-
' preview <plugin.js>
|
|
29
|
+
' dev [--project directory] Watch and build for the desktop developer mode\n' +
|
|
30
|
+
' preview <plugin.js> Check the artifact and print desktop preview instructions\n' +
|
|
22
31
|
' validate <plugin.js> [--trusted-key publisher.public.pem] [--json]\n' +
|
|
23
32
|
' keygen --out .keys/publisher\n' +
|
|
24
33
|
' sign <plugin.js> --key private.pem [--out signed.js] [--force]\n' +
|
|
25
34
|
' template <plugin.js> --key publisher.private.pem --issuer-key issuer.public.pem --out template.js [--policy policy.json]\n' +
|
|
26
35
|
' issue <template.js> --key issuer.private.pem --config delivery.json --out customer.js [--id delivery-id]\n\n' +
|
|
27
36
|
'TypeScript is type-checked before build. Final output is one .js file.\n' +
|
|
28
|
-
'
|
|
37
|
+
'v3 Host integration is required. Validation does not execute or sandbox plugin code.\n';
|
|
29
38
|
async function jsOutput(path, bytes, force) {
|
|
30
39
|
if (extname(path) !== '.js')
|
|
31
40
|
throw new Error('Output must be .js containing compiled JavaScript');
|
|
@@ -42,13 +51,9 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
42
51
|
template: { type: 'string' },
|
|
43
52
|
lang: { type: 'string' },
|
|
44
53
|
project: { type: 'string' },
|
|
45
|
-
|
|
46
|
-
port: { type: 'string' },
|
|
47
|
-
'debug-port': { type: 'string' },
|
|
54
|
+
host: { type: 'string' },
|
|
48
55
|
'no-open': { type: 'boolean' },
|
|
49
|
-
|
|
50
|
-
hidden: { type: 'boolean' },
|
|
51
|
-
electron: { type: 'string' },
|
|
56
|
+
out: { type: 'string' },
|
|
52
57
|
key: { type: 'string' },
|
|
53
58
|
'issuer-key': { type: 'string', multiple: true },
|
|
54
59
|
'trusted-key': { type: 'string', multiple: true },
|
|
@@ -80,6 +85,19 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
80
85
|
throw new Error('--' + name + ' is required');
|
|
81
86
|
return v;
|
|
82
87
|
};
|
|
88
|
+
if (command === 'test-hooks')
|
|
89
|
+
return testHooks(flags.project ?? positionals[1] ?? '.', flags.config);
|
|
90
|
+
if (command === 'test-services')
|
|
91
|
+
return testServices(flags.project ?? positionals[1] ?? '.', flags.config);
|
|
92
|
+
if (command === 'migrate')
|
|
93
|
+
return migrateProject(flags.project ?? positionals[1] ?? '.');
|
|
94
|
+
if (command === 'check-compat') {
|
|
95
|
+
const result = await checkCompatibility(flags.project ?? positionals[1] ?? '.', flags.host);
|
|
96
|
+
console.log(flags.json ? JSON.stringify(result, null, 2) : formatCompatibility(result));
|
|
97
|
+
if (!result.compatible)
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
83
101
|
if (command === 'init') {
|
|
84
102
|
let destination = positionals[1];
|
|
85
103
|
let template = flags.template;
|
|
@@ -105,6 +123,11 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
105
123
|
throw new Error('Specify a project directory');
|
|
106
124
|
const path = await scaffoldProject(destination, { template, language });
|
|
107
125
|
printInitSummary(process.stdout, path, interactive);
|
|
126
|
+
return path;
|
|
127
|
+
}
|
|
128
|
+
if (command === 'typecheck') {
|
|
129
|
+
await typecheckProject(flags.project ?? positionals[1] ?? '.');
|
|
130
|
+
console.log('Typecheck passed. No distribution artifact was written.');
|
|
108
131
|
return;
|
|
109
132
|
}
|
|
110
133
|
if (command === 'build') {
|
|
@@ -112,18 +135,25 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
112
135
|
console.log('Built ' + output.path + ' (' + output.bytes + ' bytes)');
|
|
113
136
|
return;
|
|
114
137
|
}
|
|
115
|
-
if (command === 'dev'
|
|
116
|
-
|
|
138
|
+
if (command === 'dev') {
|
|
139
|
+
const controller = new AbortController(), stop = () => controller.abort();
|
|
140
|
+
process.once('SIGINT', stop);
|
|
141
|
+
process.once('SIGTERM', stop);
|
|
142
|
+
try {
|
|
143
|
+
await watchProject(flags.project ?? '.', controller.signal);
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
process.off('SIGINT', stop);
|
|
147
|
+
process.off('SIGTERM', stop);
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (command === 'preview') {
|
|
152
|
+
if (!positionals[1])
|
|
117
153
|
throw new Error('An artifact file is required');
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
noOpen: flags['no-open'],
|
|
122
|
-
hidden: flags.hidden,
|
|
123
|
-
electron: flags.electron,
|
|
124
|
-
artifact: command === 'preview' ? resolve(positionals[1]) : undefined,
|
|
125
|
-
ensureRunning: flags['ensure-running'],
|
|
126
|
-
});
|
|
154
|
+
const file = resolve(positionals[1]);
|
|
155
|
+
const { header } = readArtifact(await readFile(file));
|
|
156
|
+
console.log('插件 ' + header.manifest.id + ' 已校验。请在澜音「设置 → 插件管理 → 管理设置 → 插件开发者模式」添加此文件:' + file);
|
|
127
157
|
return;
|
|
128
158
|
}
|
|
129
159
|
if (command === 'keygen') {
|
|
@@ -158,6 +188,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
158
188
|
const summary = {
|
|
159
189
|
id: result.header.manifest.id,
|
|
160
190
|
version: result.header.manifest.version,
|
|
191
|
+
manifestVersion: result.header.manifest.manifestVersion,
|
|
161
192
|
bytes: bytes.length,
|
|
162
193
|
modules: Object.keys(result.modules),
|
|
163
194
|
resources: Object.keys(result.resources),
|
|
@@ -170,7 +201,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
170
201
|
};
|
|
171
202
|
console.log(flags.json
|
|
172
203
|
? JSON.stringify(summary, null, 2)
|
|
173
|
-
: 'Valid Ceru
|
|
204
|
+
: 'Valid Ceru v3 artifact\n' + JSON.stringify(summary, null, 2));
|
|
174
205
|
return;
|
|
175
206
|
}
|
|
176
207
|
if (command === 'sign') {
|
package/dist/init.js
CHANGED
|
@@ -52,14 +52,14 @@ export function printInitSummary(output, path, interactive) {
|
|
|
52
52
|
path +
|
|
53
53
|
'\n\nNext:\n cd ' +
|
|
54
54
|
JSON.stringify(path) +
|
|
55
|
-
'\n npm install\n npm run
|
|
55
|
+
'\n npm install\n npm run dev # watch; add dist/plugin.js in desktop developer mode\n\nFor distribution, stop the watcher, then run npm run build and npm run validate. Share only dist/plugin.js. A v3-compatible Host is required.\n');
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
const style = createStyle(output);
|
|
59
59
|
const steps = [
|
|
60
60
|
['cd ' + JSON.stringify(path), ''],
|
|
61
61
|
['npm install', '安装模板依赖'],
|
|
62
|
-
['npm run dev', '
|
|
62
|
+
['npm run dev', '监听构建,在澜音开发者模式添加产物'],
|
|
63
63
|
['npm run build', '产出 dist/plugin.js'],
|
|
64
64
|
];
|
|
65
65
|
const width = Math.max(...steps.map(([command]) => command.length));
|
|
@@ -67,5 +67,5 @@ export function printInitSummary(output, path, interactive) {
|
|
|
67
67
|
output.write('\n ' + style.bold('下一步') + '\n');
|
|
68
68
|
for (const [command, note] of steps)
|
|
69
69
|
output.write(' ' + style.accent(command.padEnd(width)) + (note ? ' ' + style.dim(note) : '') + '\n');
|
|
70
|
-
output.write('\n ' + style.dim('只分发 dist/plugin.js;安装需要
|
|
70
|
+
output.write('\n ' + style.dim('只分发 dist/plugin.js;安装需要 v3 兼容的澜音 Host。') + '\n\n');
|
|
71
71
|
}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { parseJsonStrict, validateManifest } from '@shiqianjiang/ceru-plugin-issuer';
|
|
4
|
+
import { writeAtomic } from './project.js';
|
|
5
|
+
function checkFields(value, fields, label) {
|
|
6
|
+
for (const key of Object.keys(value))
|
|
7
|
+
if (!fields.includes(key))
|
|
8
|
+
throw new Error('Cannot migrate unknown ' + label + '.' + key);
|
|
9
|
+
}
|
|
10
|
+
export function migrateManifest(source) {
|
|
11
|
+
if (source.manifestVersion !== 2)
|
|
12
|
+
throw new Error('Expected a v2 manifest');
|
|
13
|
+
const { modules, contributes = {}, engines, permissions, ...metadata } = source;
|
|
14
|
+
if (!modules || !engines)
|
|
15
|
+
throw new Error('Missing v2 modules or engines');
|
|
16
|
+
checkFields(modules, ['logic', 'share', 'surfaces'], 'modules');
|
|
17
|
+
checkFields(contributes, [
|
|
18
|
+
'providers',
|
|
19
|
+
'playlistImporters',
|
|
20
|
+
'lyricConverters',
|
|
21
|
+
'accountItems',
|
|
22
|
+
'commands',
|
|
23
|
+
'guestAdapters',
|
|
24
|
+
'sidebarItems',
|
|
25
|
+
'settingsPages',
|
|
26
|
+
'homeSections',
|
|
27
|
+
'playlistSections',
|
|
28
|
+
'uiExtensions',
|
|
29
|
+
'menus',
|
|
30
|
+
'styles',
|
|
31
|
+
], 'contributes');
|
|
32
|
+
if (modules.surfaces?.some((view) => view.kind === 'schema'))
|
|
33
|
+
throw new Error('modules.surfaces: convert schema views to native or web views first; project left unchanged');
|
|
34
|
+
if (contributes.accountItems?.length)
|
|
35
|
+
throw new Error('contributes.accountItems: implement the v3 account login methods first; project left unchanged');
|
|
36
|
+
const renameEntry = ({ entry, ...options }) => ({
|
|
37
|
+
...options,
|
|
38
|
+
module: entry,
|
|
39
|
+
});
|
|
40
|
+
const actionIds = new Map((contributes.commands ?? []).map((item) => [item.id, item.action]));
|
|
41
|
+
const entry = {};
|
|
42
|
+
for (const key of ['logic', 'share'])
|
|
43
|
+
if (modules[key])
|
|
44
|
+
entry[key] = renameEntry(modules[key]);
|
|
45
|
+
if (entry.logic?.activation)
|
|
46
|
+
entry.logic.activation = entry.logic.activation.map((event) => event.startsWith('onCommand:')
|
|
47
|
+
? 'onCommand:' + (actionIds.get(event.slice(10)) ?? event.slice(10))
|
|
48
|
+
: event);
|
|
49
|
+
if (modules.surfaces)
|
|
50
|
+
entry.views = modules.surfaces.map(renameEntry);
|
|
51
|
+
const provides = {}, ui = {};
|
|
52
|
+
for (const key of ['providers', 'lyricConverters', 'guestAdapters'])
|
|
53
|
+
if (contributes[key])
|
|
54
|
+
provides[key] = contributes[key];
|
|
55
|
+
if (contributes.playlistImporters)
|
|
56
|
+
provides.importers = contributes.playlistImporters;
|
|
57
|
+
if (contributes.commands)
|
|
58
|
+
provides.actions = contributes.commands.map(({ action, ...item }) => ({
|
|
59
|
+
...item,
|
|
60
|
+
id: action,
|
|
61
|
+
}));
|
|
62
|
+
const pages = [
|
|
63
|
+
...(contributes.sidebarItems ?? []).map((item) => ({
|
|
64
|
+
...item,
|
|
65
|
+
mount: 'sidebar',
|
|
66
|
+
group: ['discover', 'library', 'tools'].includes(item.group) ? item.group : 'tools',
|
|
67
|
+
})),
|
|
68
|
+
...(contributes.settingsPages ?? []).map((item) => ({ ...item, mount: 'settings' })),
|
|
69
|
+
...(contributes.playlistSections ?? []).map((item) => ({
|
|
70
|
+
...item,
|
|
71
|
+
mount: 'playlist-section',
|
|
72
|
+
})),
|
|
73
|
+
...(contributes.homeSections ?? [])
|
|
74
|
+
.filter((item) => item.kind === 'custom')
|
|
75
|
+
.map(({ kind, providerIds, ...item }) => ({ ...item, mount: 'home-tab' })),
|
|
76
|
+
];
|
|
77
|
+
if (pages.length)
|
|
78
|
+
ui.pages = pages;
|
|
79
|
+
if (contributes.homeSections)
|
|
80
|
+
ui.homeSections = contributes.homeSections.filter((item) => item.kind !== 'custom');
|
|
81
|
+
if (contributes.uiExtensions)
|
|
82
|
+
ui.slots = contributes.uiExtensions;
|
|
83
|
+
if (contributes.styles)
|
|
84
|
+
ui.styles = contributes.styles;
|
|
85
|
+
if (contributes.menus)
|
|
86
|
+
ui.menus = contributes.menus.map((item) => ({
|
|
87
|
+
...item,
|
|
88
|
+
commandId: actionIds.get(item.commandId) ?? item.commandId,
|
|
89
|
+
}));
|
|
90
|
+
const { uiSchema, ...runtime } = engines;
|
|
91
|
+
const manifest = {
|
|
92
|
+
...metadata,
|
|
93
|
+
manifestVersion: 3,
|
|
94
|
+
engines: { ...runtime, hostApi: '^3.0.0' },
|
|
95
|
+
entry,
|
|
96
|
+
...(Object.keys(provides).length ? { provides } : {}),
|
|
97
|
+
...(permissions ? { uses: { permissions } } : {}),
|
|
98
|
+
...(Object.keys(ui).length ? { ui } : {}),
|
|
99
|
+
};
|
|
100
|
+
validateManifest(manifest);
|
|
101
|
+
return manifest;
|
|
102
|
+
}
|
|
103
|
+
export async function migrateProject(directory) {
|
|
104
|
+
const file = resolve(directory, 'ceru.plugin.json');
|
|
105
|
+
const config = parseJsonStrict(await readFile(file, 'utf8'));
|
|
106
|
+
config.manifest = migrateManifest(config.manifest);
|
|
107
|
+
await writeAtomic(file, JSON.stringify(config, null, 2) + '\n', true);
|
|
108
|
+
console.log('Migrated manifest only. Review provider methods: search/resolve/lyrics → tracks.*, categories/list → playlists.*, share → sharing.describe. Plugin source and dependencies were not modified.');
|
|
109
|
+
}
|
package/dist/project.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { type WatchComponentCache } from './component.js';
|
|
1
3
|
import { type ArtifactHeader } from '@shiqianjiang/ceru-plugin-issuer';
|
|
2
4
|
import type { JsonObject } from '@shiqianjiang/ceru-plugin-sdk';
|
|
3
5
|
export interface BuildConfig {
|
|
@@ -20,16 +22,17 @@ export declare function loadProject(project: string): Promise<{
|
|
|
20
22
|
root: string;
|
|
21
23
|
config: BuildConfig;
|
|
22
24
|
}>;
|
|
25
|
+
export declare function typecheckProject(project?: string): Promise<void>;
|
|
23
26
|
export declare function buildProject(project?: string, options?: {
|
|
24
27
|
out?: string;
|
|
25
28
|
overwrite?: boolean;
|
|
26
29
|
development?: boolean;
|
|
27
|
-
}): Promise<{
|
|
30
|
+
}, watchVueTypes?: (root: string, declarations: string) => ts.Program, isCurrent?: () => boolean, componentCache?: WatchComponentCache): Promise<{
|
|
28
31
|
path: string;
|
|
29
32
|
bytes: number;
|
|
30
33
|
devModules: Record<string, string>;
|
|
31
34
|
}>;
|
|
32
|
-
export declare const TEMPLATES: readonly ["source", "connected-library", "importer", "guest-adapter", "web-surface", "vue", "vue-tsx", "react", "web-dist"];
|
|
35
|
+
export declare const TEMPLATES: readonly ["source", "connected-library", "account-qrcode", "importer", "guest-adapter", "web-surface", "vue", "vue-tsx", "react", "web-dist", "page-extension", "playback-hook", "player-skin", "encrypted-source"];
|
|
33
36
|
export type TemplateName = (typeof TEMPLATES)[number];
|
|
34
37
|
export declare const TEMPLATE_INFO: Record<TemplateName, string>;
|
|
35
38
|
export declare function scaffoldProject(destination: string, options?: {
|