@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
export declare class VueWatchTypes {
|
|
3
|
+
private readonly root;
|
|
4
|
+
private accepted?;
|
|
5
|
+
private readonly shapes;
|
|
6
|
+
private readonly cache;
|
|
7
|
+
private readonly create;
|
|
8
|
+
private readonly options;
|
|
9
|
+
private readonly host;
|
|
10
|
+
private readonly extensions;
|
|
11
|
+
private readonly configPath;
|
|
12
|
+
private previous?;
|
|
13
|
+
constructor(root: string);
|
|
14
|
+
private config;
|
|
15
|
+
private independentTemplates;
|
|
16
|
+
check(declarations: string, changed: string[]): ts.Program;
|
|
17
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { parse } from '@vue/compiler-sfc';
|
|
4
|
+
import { createParsedCommandLine, createVueLanguagePlugin, getAllExtensions, } from '@vue/language-core';
|
|
5
|
+
import { proxyCreateProgram } from '@volar/typescript/lib/node/proxyCreateProgram.js';
|
|
6
|
+
const normalized = (path) => resolve(path).replaceAll('\\', '/');
|
|
7
|
+
function checkedShape(source, file) {
|
|
8
|
+
const { descriptor, errors } = parse(source, { filename: file });
|
|
9
|
+
const template = descriptor.template;
|
|
10
|
+
if (errors.length || !template?.ast || template.lang || template.src)
|
|
11
|
+
return { types: source, source };
|
|
12
|
+
const spans = [];
|
|
13
|
+
const visit = (node) => {
|
|
14
|
+
if (node.type === 2 && node.content.trim()) {
|
|
15
|
+
spans.push({ start: node.loc.start.offset, end: node.loc.end.offset });
|
|
16
|
+
}
|
|
17
|
+
else if (node.type === 1 && node.tag !== 'script' && node.tag !== 'style') {
|
|
18
|
+
node.children.forEach(visit);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
template.ast.children.forEach(visit);
|
|
22
|
+
let shape = source;
|
|
23
|
+
for (const span of spans.reverse())
|
|
24
|
+
shape = shape.slice(0, span.start) + '\u0000' + shape.slice(span.end);
|
|
25
|
+
return { types: shape, source, outsideTemplate: JSON.stringify([source.slice(0, template.loc.start.offset), source.slice(template.loc.end.offset)]) };
|
|
26
|
+
}
|
|
27
|
+
export class VueWatchTypes {
|
|
28
|
+
root;
|
|
29
|
+
accepted;
|
|
30
|
+
shapes = new Map();
|
|
31
|
+
cache = new Map();
|
|
32
|
+
create;
|
|
33
|
+
options;
|
|
34
|
+
host;
|
|
35
|
+
extensions;
|
|
36
|
+
configPath;
|
|
37
|
+
previous;
|
|
38
|
+
constructor(root) {
|
|
39
|
+
this.root = root;
|
|
40
|
+
this.configPath = normalized(resolve(root, 'tsconfig.json'));
|
|
41
|
+
const { vueOptions } = createParsedCommandLine(ts, ts.sys, this.configPath);
|
|
42
|
+
this.extensions = getAllExtensions(vueOptions).map((extension) => ({
|
|
43
|
+
extension,
|
|
44
|
+
isMixedContent: true,
|
|
45
|
+
scriptKind: ts.ScriptKind.Deferred,
|
|
46
|
+
}));
|
|
47
|
+
const config = this.config();
|
|
48
|
+
this.options = { ...config.options, noEmit: true, allowNonTsExtensions: true };
|
|
49
|
+
this.host = ts.createIncrementalCompilerHost(this.options);
|
|
50
|
+
const getSource = this.host.getSourceFile.bind(this.host);
|
|
51
|
+
this.host.getSourceFile = (file, ...args) => {
|
|
52
|
+
const key = normalized(file);
|
|
53
|
+
const cached = this.cache.get(key);
|
|
54
|
+
if (cached && !args[2])
|
|
55
|
+
return cached;
|
|
56
|
+
const source = getSource(file, ...args);
|
|
57
|
+
if (source)
|
|
58
|
+
this.cache.set(key, source);
|
|
59
|
+
return source;
|
|
60
|
+
};
|
|
61
|
+
this.create = proxyCreateProgram(ts, ts.createProgram, () => [
|
|
62
|
+
createVueLanguagePlugin(ts, this.options, vueOptions, (id) => id),
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
config() {
|
|
66
|
+
const input = ts.readConfigFile(this.configPath, ts.sys.readFile);
|
|
67
|
+
if (input.error)
|
|
68
|
+
throw Error(ts.flattenDiagnosticMessageText(input.error.messageText, '\n'));
|
|
69
|
+
return ts.parseJsonConfigFileContent(input.config, ts.sys, this.root, undefined, this.configPath, undefined, this.extensions);
|
|
70
|
+
}
|
|
71
|
+
independentTemplates(before, program, edits) {
|
|
72
|
+
if (!before || edits.length !== 1 || !edits[0].endsWith('.vue') || program.getProjectReferences()?.length)
|
|
73
|
+
return;
|
|
74
|
+
const localModule = (source) => source && ts.isExternalModule(source) &&
|
|
75
|
+
!source.statements.some(statement => ts.isModuleDeclaration(statement) || ts.isNamespaceExportDeclaration(statement));
|
|
76
|
+
const roots = program.getRootFileNames();
|
|
77
|
+
if (!roots.includes(edits[0]) || roots.length !== before.getRootFileNames().length ||
|
|
78
|
+
roots.some((root, index) => root !== before.getRootFileNames()[index]))
|
|
79
|
+
return;
|
|
80
|
+
const sources = program.getSourceFiles();
|
|
81
|
+
if (sources.length !== before.getSourceFiles().length)
|
|
82
|
+
return;
|
|
83
|
+
const changed = sources.filter(source => before.getSourceFile(source.fileName) !== source);
|
|
84
|
+
if (!changed.length || changed.some(source => {
|
|
85
|
+
const prior = before.getSourceFile(source.fileName);
|
|
86
|
+
return !source.fileName.endsWith('.vue') || !roots.includes(source.fileName) || !localModule(prior) || !localModule(source);
|
|
87
|
+
}))
|
|
88
|
+
return;
|
|
89
|
+
const names = new Set(changed.map(source => source.fileName));
|
|
90
|
+
if (!names.has(edits[0]))
|
|
91
|
+
return;
|
|
92
|
+
// TypeScript still follows imports, aliases and references after these files cease to be roots.
|
|
93
|
+
const remaining = this.create({ rootNames: roots.filter(root => !names.has(root)), options: this.options,
|
|
94
|
+
host: { ...this.host }, oldProgram: program });
|
|
95
|
+
if (changed.some(source => remaining.getSourceFile(source.fileName)) || remaining.getSourceFiles().length !== sources.length - changed.length)
|
|
96
|
+
return;
|
|
97
|
+
return changed;
|
|
98
|
+
}
|
|
99
|
+
check(declarations, changed) {
|
|
100
|
+
const edits = changed.map((file) => normalized(resolve(this.root, file)));
|
|
101
|
+
const shapes = new Map();
|
|
102
|
+
for (const file of edits) {
|
|
103
|
+
this.cache.delete(file);
|
|
104
|
+
const source = file.endsWith('.vue') ? ts.sys.readFile(file) : undefined;
|
|
105
|
+
if (source !== undefined)
|
|
106
|
+
shapes.set(file, checkedShape(source, file));
|
|
107
|
+
}
|
|
108
|
+
if (this.accepted &&
|
|
109
|
+
edits.length &&
|
|
110
|
+
edits.every((file) => shapes.has(file) && shapes.get(file).types === this.shapes.get(file)?.types))
|
|
111
|
+
return this.accepted;
|
|
112
|
+
const accepted = this.accepted;
|
|
113
|
+
this.accepted = undefined;
|
|
114
|
+
const config = this.config();
|
|
115
|
+
const program = this.create({
|
|
116
|
+
rootNames: [...new Set([...config.fileNames.map(normalized), normalized(declarations)])],
|
|
117
|
+
options: this.options,
|
|
118
|
+
host: { ...this.host },
|
|
119
|
+
oldProgram: accepted ?? this.previous?.getProgram(),
|
|
120
|
+
projectReferences: config.projectReferences,
|
|
121
|
+
});
|
|
122
|
+
const outsideTemplate = shapes.get(edits[0])?.outsideTemplate;
|
|
123
|
+
const independent = outsideTemplate !== undefined && outsideTemplate === this.shapes.get(edits[0])?.outsideTemplate
|
|
124
|
+
? this.independentTemplates(accepted, program, edits) : undefined;
|
|
125
|
+
if (!independent)
|
|
126
|
+
this.previous = ts.createSemanticDiagnosticsBuilderProgram(program, this.host, this.previous);
|
|
127
|
+
const errors = [
|
|
128
|
+
...config.errors,
|
|
129
|
+
...program.getOptionsDiagnostics(),
|
|
130
|
+
...program.getGlobalDiagnostics(),
|
|
131
|
+
...program.getSyntacticDiagnostics(),
|
|
132
|
+
...(independent ? independent.flatMap(source => program.getSemanticDiagnostics(source)) : this.previous.getSemanticDiagnostics()),
|
|
133
|
+
];
|
|
134
|
+
if (errors.length)
|
|
135
|
+
throw Error(ts.formatDiagnostics(errors, this.host));
|
|
136
|
+
this.shapes.clear();
|
|
137
|
+
for (const file of program.getRootFileNames().filter((file) => file.endsWith('.vue'))) {
|
|
138
|
+
const key = normalized(file), edit = shapes.get(key), source = edit?.source ?? ts.sys.readFile(key);
|
|
139
|
+
if (source !== undefined && program.getSourceFile(file)?.text.startsWith(source))
|
|
140
|
+
this.shapes.set(key, edit ?? checkedShape(source, key));
|
|
141
|
+
}
|
|
142
|
+
this.accepted = program;
|
|
143
|
+
return program;
|
|
144
|
+
}
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shiqianjiang/ceru-plugin-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
-
"assets",
|
|
20
|
+
"assets/catalog.json",
|
|
21
|
+
"assets/compatibility.json",
|
|
22
|
+
"assets/originals",
|
|
23
|
+
"assets/vendor-licenses",
|
|
21
24
|
"schemas",
|
|
22
25
|
"templates",
|
|
23
26
|
"README.md",
|
|
@@ -32,8 +35,10 @@
|
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"@babel/core": "^7.29.7",
|
|
35
|
-
"@shiqianjiang/ceru-plugin-issuer": "0.
|
|
36
|
-
"@shiqianjiang/ceru-plugin-sdk": "0.
|
|
38
|
+
"@shiqianjiang/ceru-plugin-issuer": "3.0.0",
|
|
39
|
+
"@shiqianjiang/ceru-plugin-sdk": "3.0.0",
|
|
40
|
+
"@volar/typescript": "2.4.28",
|
|
41
|
+
"@vue/language-core": "3.3.11",
|
|
37
42
|
"@vue/babel-plugin-jsx": "^2.0.1",
|
|
38
43
|
"@vue/compiler-sfc": "3.5.43",
|
|
39
44
|
"axios": "^1.20.0",
|
|
@@ -43,11 +48,10 @@
|
|
|
43
48
|
"react": "19.3.0",
|
|
44
49
|
"react-dom": "19.3.0",
|
|
45
50
|
"semver": "^7.7.0",
|
|
46
|
-
"socket.io-client": "^4.8.3",
|
|
47
51
|
"typescript": "~5.9.3",
|
|
48
52
|
"vue": "3.5.43",
|
|
49
53
|
"vue-tsc": "^3.3.11",
|
|
50
|
-
"
|
|
54
|
+
"@shiqianjiang/ceru-plugin-core": "3.0.0"
|
|
51
55
|
},
|
|
52
56
|
"publishConfig": {
|
|
53
57
|
"access": "public",
|