@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.
Files changed (153) hide show
  1. package/README.md +9 -5
  2. package/assets/catalog.json +1 -1
  3. package/assets/core-contracts.js +1 -0
  4. package/assets/index.html +94 -93
  5. package/assets/playground.js +293 -30
  6. package/assets/sandbox.js +50 -19
  7. package/assets/style.css +16 -0
  8. package/dist/dependencies.d.ts +6 -0
  9. package/dist/dependencies.js +45 -0
  10. package/dist/dev.d.ts +2 -0
  11. package/dist/dev.js +297 -144
  12. package/dist/frameworks.d.ts +2 -2
  13. package/dist/frameworks.js +11 -29
  14. package/dist/index.js +12 -4
  15. package/dist/project.d.ts +1 -0
  16. package/dist/project.js +48 -21
  17. package/dist/socket-broker.d.ts +23 -0
  18. package/dist/socket-broker.js +230 -0
  19. package/package.json +71 -67
  20. package/schemas/config.schema.json +349 -0
  21. package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
  22. package/templates/connected-library/js/.vscode/launch.json +36 -46
  23. package/templates/connected-library/js/.vscode/tasks.json +11 -3
  24. package/templates/connected-library/js/README.md +7 -2
  25. package/templates/connected-library/js/ceru-plugin.code-workspace +8 -0
  26. package/templates/connected-library/js/package.json +4 -3
  27. package/templates/connected-library/js/src/index.js +7 -5
  28. package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
  29. package/templates/connected-library/ts/.vscode/launch.json +36 -46
  30. package/templates/connected-library/ts/.vscode/tasks.json +11 -3
  31. package/templates/connected-library/ts/README.md +7 -2
  32. package/templates/connected-library/ts/ceru-plugin.code-workspace +8 -0
  33. package/templates/connected-library/ts/package.json +4 -3
  34. package/templates/connected-library/ts/src/index.ts +7 -5
  35. package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
  36. package/templates/guest-adapter/js/.vscode/launch.json +36 -46
  37. package/templates/guest-adapter/js/.vscode/tasks.json +11 -3
  38. package/templates/guest-adapter/js/README.md +7 -2
  39. package/templates/guest-adapter/js/ceru-plugin.code-workspace +8 -0
  40. package/templates/guest-adapter/js/package.json +4 -3
  41. package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
  42. package/templates/guest-adapter/ts/.vscode/launch.json +36 -46
  43. package/templates/guest-adapter/ts/.vscode/tasks.json +11 -3
  44. package/templates/guest-adapter/ts/README.md +7 -2
  45. package/templates/guest-adapter/ts/ceru-plugin.code-workspace +8 -0
  46. package/templates/guest-adapter/ts/package.json +4 -3
  47. package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
  48. package/templates/importer/js/.vscode/launch.json +36 -46
  49. package/templates/importer/js/.vscode/tasks.json +11 -3
  50. package/templates/importer/js/README.md +8 -3
  51. package/templates/importer/js/ceru-plugin.code-workspace +8 -0
  52. package/templates/importer/js/ceru.plugin.json +8 -24
  53. package/templates/importer/js/package.json +4 -3
  54. package/templates/importer/js/src/index.js +28 -34
  55. package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
  56. package/templates/importer/ts/.vscode/launch.json +36 -46
  57. package/templates/importer/ts/.vscode/tasks.json +11 -3
  58. package/templates/importer/ts/README.md +8 -3
  59. package/templates/importer/ts/ceru-plugin.code-workspace +8 -0
  60. package/templates/importer/ts/ceru.plugin.json +8 -24
  61. package/templates/importer/ts/package.json +4 -3
  62. package/templates/importer/ts/src/index.ts +28 -34
  63. package/templates/react/js/.vscode/ceru.code-snippets +37 -9
  64. package/templates/react/js/.vscode/launch.json +36 -46
  65. package/templates/react/js/.vscode/tasks.json +11 -3
  66. package/templates/react/js/README.md +7 -2
  67. package/templates/react/js/ceru-plugin.code-workspace +8 -0
  68. package/templates/react/js/ceru.plugin.json +1 -5
  69. package/templates/react/js/package.json +4 -3
  70. package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
  71. package/templates/react/ts/.vscode/launch.json +36 -46
  72. package/templates/react/ts/.vscode/tasks.json +11 -3
  73. package/templates/react/ts/README.md +7 -2
  74. package/templates/react/ts/ceru-plugin.code-workspace +8 -0
  75. package/templates/react/ts/ceru.plugin.json +1 -5
  76. package/templates/react/ts/package.json +4 -3
  77. package/templates/snapshot.json +22 -2
  78. package/templates/source/js/.vscode/ceru.code-snippets +37 -9
  79. package/templates/source/js/.vscode/launch.json +36 -46
  80. package/templates/source/js/.vscode/tasks.json +11 -3
  81. package/templates/source/js/README.md +7 -2
  82. package/templates/source/js/ceru-plugin.code-workspace +8 -0
  83. package/templates/source/js/ceru.plugin.json +9 -0
  84. package/templates/source/js/package.json +4 -3
  85. package/templates/source/js/src/index.js +29 -26
  86. package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
  87. package/templates/source/ts/.vscode/launch.json +36 -46
  88. package/templates/source/ts/.vscode/tasks.json +11 -3
  89. package/templates/source/ts/README.md +7 -2
  90. package/templates/source/ts/ceru-plugin.code-workspace +8 -0
  91. package/templates/source/ts/ceru.plugin.json +9 -0
  92. package/templates/source/ts/package.json +4 -3
  93. package/templates/source/ts/src/index.ts +29 -26
  94. package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
  95. package/templates/vue/js/.vscode/launch.json +36 -46
  96. package/templates/vue/js/.vscode/tasks.json +11 -3
  97. package/templates/vue/js/README.md +7 -2
  98. package/templates/vue/js/ceru-plugin.code-workspace +8 -0
  99. package/templates/vue/js/ceru.plugin.json +1 -4
  100. package/templates/vue/js/package.json +4 -3
  101. package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
  102. package/templates/vue/ts/.vscode/launch.json +36 -46
  103. package/templates/vue/ts/.vscode/tasks.json +11 -3
  104. package/templates/vue/ts/README.md +7 -2
  105. package/templates/vue/ts/ceru-plugin.code-workspace +8 -0
  106. package/templates/vue/ts/ceru.plugin.json +1 -4
  107. package/templates/vue/ts/package.json +4 -3
  108. package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
  109. package/templates/vue-tsx/js/.vscode/launch.json +36 -46
  110. package/templates/vue-tsx/js/.vscode/tasks.json +11 -3
  111. package/templates/vue-tsx/js/README.md +7 -2
  112. package/templates/vue-tsx/js/ceru-plugin.code-workspace +8 -0
  113. package/templates/vue-tsx/js/ceru.plugin.json +1 -4
  114. package/templates/vue-tsx/js/package.json +4 -3
  115. package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
  116. package/templates/vue-tsx/ts/.vscode/launch.json +36 -46
  117. package/templates/vue-tsx/ts/.vscode/tasks.json +11 -3
  118. package/templates/vue-tsx/ts/README.md +7 -2
  119. package/templates/vue-tsx/ts/ceru-plugin.code-workspace +8 -0
  120. package/templates/vue-tsx/ts/ceru.plugin.json +1 -4
  121. package/templates/vue-tsx/ts/package.json +4 -3
  122. package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
  123. package/templates/web-dist/js/.vscode/launch.json +36 -46
  124. package/templates/web-dist/js/.vscode/tasks.json +11 -3
  125. package/templates/web-dist/js/README.md +7 -2
  126. package/templates/web-dist/js/ceru-plugin.code-workspace +8 -0
  127. package/templates/web-dist/js/package.json +4 -3
  128. package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
  129. package/templates/web-dist/ts/.vscode/launch.json +36 -46
  130. package/templates/web-dist/ts/.vscode/tasks.json +11 -3
  131. package/templates/web-dist/ts/README.md +7 -2
  132. package/templates/web-dist/ts/ceru-plugin.code-workspace +8 -0
  133. package/templates/web-dist/ts/package.json +4 -3
  134. package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
  135. package/templates/web-surface/js/.vscode/launch.json +36 -46
  136. package/templates/web-surface/js/.vscode/tasks.json +11 -3
  137. package/templates/web-surface/js/README.md +7 -2
  138. package/templates/web-surface/js/ceru-plugin.code-workspace +8 -0
  139. package/templates/web-surface/js/ceru.plugin.json +9 -0
  140. package/templates/web-surface/js/package.json +4 -3
  141. package/templates/web-surface/js/src/view.js +4 -1
  142. package/templates/web-surface/js/ui/search-note.css +3 -0
  143. package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
  144. package/templates/web-surface/ts/.vscode/launch.json +36 -46
  145. package/templates/web-surface/ts/.vscode/tasks.json +11 -3
  146. package/templates/web-surface/ts/README.md +7 -2
  147. package/templates/web-surface/ts/ceru-plugin.code-workspace +8 -0
  148. package/templates/web-surface/ts/ceru.plugin.json +9 -0
  149. package/templates/web-surface/ts/package.json +4 -3
  150. package/templates/web-surface/ts/src/view.ts +4 -1
  151. package/templates/web-surface/ts/ui/search-note.css +3 -0
  152. package/assets/shared-react.js +0 -77
  153. 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
+ }
package/dist/dev.d.ts CHANGED
@@ -4,4 +4,6 @@ export declare function runDev(project: string, options?: {
4
4
  debugPort?: number;
5
5
  hidden?: boolean;
6
6
  electron?: string;
7
+ artifact?: string;
8
+ ensureRunning?: boolean;
7
9
  }): Promise<void>;