@shiqianjiang/ceru-plugin-cli 0.1.1 → 0.2.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 +9 -5
- package/assets/catalog.json +1 -1
- package/assets/core-contracts.js +1 -0
- package/assets/index.html +94 -93
- package/assets/playground.js +293 -30
- package/assets/sandbox.js +50 -19
- package/assets/style.css +16 -0
- package/dist/dependencies.d.ts +6 -0
- package/dist/dependencies.js +45 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.js +297 -144
- package/dist/frameworks.d.ts +2 -2
- package/dist/frameworks.js +11 -29
- package/dist/index.js +12 -4
- package/dist/project.d.ts +1 -0
- package/dist/project.js +48 -21
- package/dist/socket-broker.d.ts +23 -0
- package/dist/socket-broker.js +230 -0
- package/package.json +71 -67
- package/schemas/config.schema.json +349 -0
- package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/js/.vscode/launch.json +36 -46
- package/templates/connected-library/js/.vscode/tasks.json +11 -3
- package/templates/connected-library/js/README.md +7 -2
- package/templates/connected-library/js/ceru-plugin.code-workspace +8 -0
- package/templates/connected-library/js/package.json +4 -3
- package/templates/connected-library/js/src/index.js +7 -5
- package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/ts/.vscode/launch.json +36 -46
- package/templates/connected-library/ts/.vscode/tasks.json +11 -3
- package/templates/connected-library/ts/README.md +7 -2
- package/templates/connected-library/ts/ceru-plugin.code-workspace +8 -0
- package/templates/connected-library/ts/package.json +4 -3
- package/templates/connected-library/ts/src/index.ts +7 -5
- package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/js/.vscode/launch.json +36 -46
- package/templates/guest-adapter/js/.vscode/tasks.json +11 -3
- package/templates/guest-adapter/js/README.md +7 -2
- package/templates/guest-adapter/js/ceru-plugin.code-workspace +8 -0
- package/templates/guest-adapter/js/package.json +4 -3
- package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/ts/.vscode/launch.json +36 -46
- package/templates/guest-adapter/ts/.vscode/tasks.json +11 -3
- package/templates/guest-adapter/ts/README.md +7 -2
- package/templates/guest-adapter/ts/ceru-plugin.code-workspace +8 -0
- package/templates/guest-adapter/ts/package.json +4 -3
- package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/js/.vscode/launch.json +36 -46
- package/templates/importer/js/.vscode/tasks.json +11 -3
- package/templates/importer/js/README.md +8 -3
- package/templates/importer/js/ceru-plugin.code-workspace +8 -0
- package/templates/importer/js/ceru.plugin.json +8 -24
- package/templates/importer/js/package.json +4 -3
- package/templates/importer/js/src/index.js +28 -34
- package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/ts/.vscode/launch.json +36 -46
- package/templates/importer/ts/.vscode/tasks.json +11 -3
- package/templates/importer/ts/README.md +8 -3
- package/templates/importer/ts/ceru-plugin.code-workspace +8 -0
- package/templates/importer/ts/ceru.plugin.json +8 -24
- package/templates/importer/ts/package.json +4 -3
- package/templates/importer/ts/src/index.ts +28 -34
- package/templates/react/js/.vscode/ceru.code-snippets +37 -9
- package/templates/react/js/.vscode/launch.json +36 -46
- package/templates/react/js/.vscode/tasks.json +11 -3
- package/templates/react/js/README.md +7 -2
- package/templates/react/js/ceru-plugin.code-workspace +8 -0
- package/templates/react/js/ceru.plugin.json +1 -5
- package/templates/react/js/package.json +4 -3
- package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/react/ts/.vscode/launch.json +36 -46
- package/templates/react/ts/.vscode/tasks.json +11 -3
- package/templates/react/ts/README.md +7 -2
- package/templates/react/ts/ceru-plugin.code-workspace +8 -0
- package/templates/react/ts/ceru.plugin.json +1 -5
- package/templates/react/ts/package.json +4 -3
- package/templates/snapshot.json +22 -2
- package/templates/source/js/.vscode/ceru.code-snippets +37 -9
- package/templates/source/js/.vscode/launch.json +36 -46
- package/templates/source/js/.vscode/tasks.json +11 -3
- package/templates/source/js/README.md +7 -2
- package/templates/source/js/ceru-plugin.code-workspace +8 -0
- package/templates/source/js/ceru.plugin.json +9 -0
- package/templates/source/js/package.json +4 -3
- package/templates/source/js/src/index.js +29 -26
- package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/source/ts/.vscode/launch.json +36 -46
- package/templates/source/ts/.vscode/tasks.json +11 -3
- package/templates/source/ts/README.md +7 -2
- package/templates/source/ts/ceru-plugin.code-workspace +8 -0
- package/templates/source/ts/ceru.plugin.json +9 -0
- package/templates/source/ts/package.json +4 -3
- package/templates/source/ts/src/index.ts +29 -26
- package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/js/.vscode/launch.json +36 -46
- package/templates/vue/js/.vscode/tasks.json +11 -3
- package/templates/vue/js/README.md +7 -2
- package/templates/vue/js/ceru-plugin.code-workspace +8 -0
- package/templates/vue/js/ceru.plugin.json +1 -4
- package/templates/vue/js/package.json +4 -3
- package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/ts/.vscode/launch.json +36 -46
- package/templates/vue/ts/.vscode/tasks.json +11 -3
- package/templates/vue/ts/README.md +7 -2
- package/templates/vue/ts/ceru-plugin.code-workspace +8 -0
- package/templates/vue/ts/ceru.plugin.json +1 -4
- package/templates/vue/ts/package.json +4 -3
- package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/js/.vscode/launch.json +36 -46
- package/templates/vue-tsx/js/.vscode/tasks.json +11 -3
- package/templates/vue-tsx/js/README.md +7 -2
- package/templates/vue-tsx/js/ceru-plugin.code-workspace +8 -0
- package/templates/vue-tsx/js/ceru.plugin.json +1 -4
- package/templates/vue-tsx/js/package.json +4 -3
- package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/ts/.vscode/launch.json +36 -46
- package/templates/vue-tsx/ts/.vscode/tasks.json +11 -3
- package/templates/vue-tsx/ts/README.md +7 -2
- package/templates/vue-tsx/ts/ceru-plugin.code-workspace +8 -0
- package/templates/vue-tsx/ts/ceru.plugin.json +1 -4
- package/templates/vue-tsx/ts/package.json +4 -3
- package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/js/.vscode/launch.json +36 -46
- package/templates/web-dist/js/.vscode/tasks.json +11 -3
- package/templates/web-dist/js/README.md +7 -2
- package/templates/web-dist/js/ceru-plugin.code-workspace +8 -0
- package/templates/web-dist/js/package.json +4 -3
- package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/ts/.vscode/launch.json +36 -46
- package/templates/web-dist/ts/.vscode/tasks.json +11 -3
- package/templates/web-dist/ts/README.md +7 -2
- package/templates/web-dist/ts/ceru-plugin.code-workspace +8 -0
- package/templates/web-dist/ts/package.json +4 -3
- package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/js/.vscode/launch.json +36 -46
- package/templates/web-surface/js/.vscode/tasks.json +11 -3
- package/templates/web-surface/js/README.md +7 -2
- package/templates/web-surface/js/ceru-plugin.code-workspace +8 -0
- package/templates/web-surface/js/ceru.plugin.json +9 -0
- package/templates/web-surface/js/package.json +4 -3
- package/templates/web-surface/js/src/view.js +4 -1
- package/templates/web-surface/js/ui/search-note.css +3 -0
- package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/ts/.vscode/launch.json +36 -46
- package/templates/web-surface/ts/.vscode/tasks.json +11 -3
- package/templates/web-surface/ts/README.md +7 -2
- package/templates/web-surface/ts/ceru-plugin.code-workspace +8 -0
- package/templates/web-surface/ts/ceru.plugin.json +9 -0
- package/templates/web-surface/ts/package.json +4 -3
- package/templates/web-surface/ts/src/view.ts +4 -1
- package/templates/web-surface/ts/ui/search-note.css +3 -0
- package/assets/shared-react.js +0 -77
- package/assets/shared-vue.js +0 -44
package/assets/style.css
CHANGED
|
@@ -117,6 +117,15 @@ aside .item {
|
|
|
117
117
|
gap: 8px;
|
|
118
118
|
margin: 10px 0;
|
|
119
119
|
}
|
|
120
|
+
.permission-group {
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
gap: 8px;
|
|
125
|
+
margin: 16px 0 6px;
|
|
126
|
+
padding-top: 12px;
|
|
127
|
+
border-top: 1px solid var(--line);
|
|
128
|
+
}
|
|
120
129
|
.hint {
|
|
121
130
|
font-size: 12px;
|
|
122
131
|
color: var(--muted);
|
|
@@ -192,6 +201,13 @@ pre {
|
|
|
192
201
|
display: block;
|
|
193
202
|
width: 100%;
|
|
194
203
|
}
|
|
204
|
+
.host-content-preview {
|
|
205
|
+
margin: 12px 0;
|
|
206
|
+
padding: 24px;
|
|
207
|
+
border: 1px dashed var(--green);
|
|
208
|
+
border-radius: 8px;
|
|
209
|
+
color: var(--muted);
|
|
210
|
+
}
|
|
195
211
|
.log-column {
|
|
196
212
|
position: sticky;
|
|
197
213
|
top: 16px;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from 'esbuild';
|
|
2
|
+
export declare const HOST_MODULES: Set<string>;
|
|
3
|
+
/** Only explicitly named Host modules are replaced. All other packages go through esbuild. */
|
|
4
|
+
export declare function hostModulesPlugin(): Plugin;
|
|
5
|
+
/** Catch unresolved/dynamic CommonJS loading after bundling, including aliases. */
|
|
6
|
+
export declare function assertBundledDependencies(code: string): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { parse } from 'acorn';
|
|
2
|
+
import { HOST_MODULE_NAMES } from '@shiqianjiang/ceru-plugin-sdk/catalog';
|
|
3
|
+
export const HOST_MODULES = new Set(HOST_MODULE_NAMES);
|
|
4
|
+
/** Only explicitly named Host modules are replaced. All other packages go through esbuild. */
|
|
5
|
+
export function hostModulesPlugin() {
|
|
6
|
+
return {
|
|
7
|
+
name: 'ceru-host-modules',
|
|
8
|
+
setup(build) {
|
|
9
|
+
build.onResolve({ filter: /^(?:ceru|@ceru\/[^/]+|lodash)$/ }, (args) => {
|
|
10
|
+
if (!HOST_MODULES.has(args.path))
|
|
11
|
+
return { errors: [{ text: 'Unknown Host module: ' + args.path }] };
|
|
12
|
+
return { path: args.path, namespace: 'ceru-host' };
|
|
13
|
+
});
|
|
14
|
+
build.onLoad({ filter: /.*/, namespace: 'ceru-host' }, (args) => ({
|
|
15
|
+
contents: 'module.exports = globalThis.__ceruRequire(' + JSON.stringify(args.path) + ')',
|
|
16
|
+
loader: 'js',
|
|
17
|
+
}));
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Catch unresolved/dynamic CommonJS loading after bundling, including aliases. */
|
|
22
|
+
export function assertBundledDependencies(code) {
|
|
23
|
+
const tree = parse(code, { ecmaVersion: 2022, sourceType: 'script' });
|
|
24
|
+
const stack = [tree];
|
|
25
|
+
while (stack.length) {
|
|
26
|
+
const node = stack.pop();
|
|
27
|
+
if (node.type === 'ImportExpression')
|
|
28
|
+
throw new Error('Dynamic import remains in the output; use a static import');
|
|
29
|
+
if (node.type === 'CallExpression' &&
|
|
30
|
+
node.callee?.type === 'Identifier' &&
|
|
31
|
+
(node.callee.name === 'require' || /^__require\d*$/.test(node.callee.name)) &&
|
|
32
|
+
node.arguments.length) {
|
|
33
|
+
throw new Error('Unresolved require() remains in the output. Use a literal local/package import, or a documented Host module.');
|
|
34
|
+
}
|
|
35
|
+
for (const value of Object.values(node)) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
for (const child of value)
|
|
38
|
+
if (child?.type)
|
|
39
|
+
stack.push(child);
|
|
40
|
+
}
|
|
41
|
+
else if (value && typeof value === 'object' && 'type' in value)
|
|
42
|
+
stack.push(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|