@shiqianjiang/ceru-plugin-cli 0.1.0 → 0.1.2

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 (111) hide show
  1. package/README.md +4 -0
  2. package/assets/catalog.json +1 -1
  3. package/assets/sandbox.js +1 -1
  4. package/dist/dev.d.ts +2 -0
  5. package/dist/dev.js +87 -29
  6. package/dist/frameworks.d.ts +2 -2
  7. package/dist/frameworks.js +11 -29
  8. package/dist/index.js +8 -2
  9. package/dist/project.d.ts +1 -0
  10. package/dist/project.js +8 -6
  11. package/package.json +67 -67
  12. package/schemas/config.schema.json +2 -0
  13. package/templates/connected-library/js/.vscode/launch.json +8 -2
  14. package/templates/connected-library/js/.vscode/tasks.json +11 -3
  15. package/templates/connected-library/js/README.md +7 -2
  16. package/templates/connected-library/js/ceru-plugin.code-workspace +8 -0
  17. package/templates/connected-library/js/package.json +3 -2
  18. package/templates/connected-library/ts/.vscode/launch.json +8 -2
  19. package/templates/connected-library/ts/.vscode/tasks.json +11 -3
  20. package/templates/connected-library/ts/README.md +7 -2
  21. package/templates/connected-library/ts/ceru-plugin.code-workspace +8 -0
  22. package/templates/connected-library/ts/package.json +3 -2
  23. package/templates/guest-adapter/js/.vscode/launch.json +8 -2
  24. package/templates/guest-adapter/js/.vscode/tasks.json +11 -3
  25. package/templates/guest-adapter/js/README.md +7 -2
  26. package/templates/guest-adapter/js/ceru-plugin.code-workspace +8 -0
  27. package/templates/guest-adapter/js/package.json +3 -2
  28. package/templates/guest-adapter/ts/.vscode/launch.json +8 -2
  29. package/templates/guest-adapter/ts/.vscode/tasks.json +11 -3
  30. package/templates/guest-adapter/ts/README.md +7 -2
  31. package/templates/guest-adapter/ts/ceru-plugin.code-workspace +8 -0
  32. package/templates/guest-adapter/ts/package.json +3 -2
  33. package/templates/importer/js/.vscode/launch.json +8 -2
  34. package/templates/importer/js/.vscode/tasks.json +11 -3
  35. package/templates/importer/js/README.md +7 -2
  36. package/templates/importer/js/ceru-plugin.code-workspace +8 -0
  37. package/templates/importer/js/package.json +3 -2
  38. package/templates/importer/ts/.vscode/launch.json +8 -2
  39. package/templates/importer/ts/.vscode/tasks.json +11 -3
  40. package/templates/importer/ts/README.md +7 -2
  41. package/templates/importer/ts/ceru-plugin.code-workspace +8 -0
  42. package/templates/importer/ts/package.json +3 -2
  43. package/templates/react/js/.vscode/launch.json +8 -2
  44. package/templates/react/js/.vscode/tasks.json +11 -3
  45. package/templates/react/js/README.md +7 -2
  46. package/templates/react/js/ceru-plugin.code-workspace +8 -0
  47. package/templates/react/js/ceru.plugin.json +1 -5
  48. package/templates/react/js/package.json +3 -2
  49. package/templates/react/ts/.vscode/launch.json +8 -2
  50. package/templates/react/ts/.vscode/tasks.json +11 -3
  51. package/templates/react/ts/README.md +7 -2
  52. package/templates/react/ts/ceru-plugin.code-workspace +8 -0
  53. package/templates/react/ts/ceru.plugin.json +1 -5
  54. package/templates/react/ts/package.json +3 -2
  55. package/templates/snapshot.json +19 -1
  56. package/templates/source/js/.vscode/launch.json +8 -2
  57. package/templates/source/js/.vscode/tasks.json +11 -3
  58. package/templates/source/js/README.md +7 -2
  59. package/templates/source/js/ceru-plugin.code-workspace +8 -0
  60. package/templates/source/js/package.json +3 -2
  61. package/templates/source/ts/.vscode/launch.json +8 -2
  62. package/templates/source/ts/.vscode/tasks.json +11 -3
  63. package/templates/source/ts/README.md +7 -2
  64. package/templates/source/ts/ceru-plugin.code-workspace +8 -0
  65. package/templates/source/ts/package.json +3 -2
  66. package/templates/vue/js/.vscode/launch.json +8 -2
  67. package/templates/vue/js/.vscode/tasks.json +11 -3
  68. package/templates/vue/js/README.md +7 -2
  69. package/templates/vue/js/ceru-plugin.code-workspace +8 -0
  70. package/templates/vue/js/ceru.plugin.json +1 -4
  71. package/templates/vue/js/package.json +3 -2
  72. package/templates/vue/ts/.vscode/launch.json +8 -2
  73. package/templates/vue/ts/.vscode/tasks.json +11 -3
  74. package/templates/vue/ts/README.md +7 -2
  75. package/templates/vue/ts/ceru-plugin.code-workspace +8 -0
  76. package/templates/vue/ts/ceru.plugin.json +1 -4
  77. package/templates/vue/ts/package.json +3 -2
  78. package/templates/vue-tsx/js/.vscode/launch.json +8 -2
  79. package/templates/vue-tsx/js/.vscode/tasks.json +11 -3
  80. package/templates/vue-tsx/js/README.md +7 -2
  81. package/templates/vue-tsx/js/ceru-plugin.code-workspace +8 -0
  82. package/templates/vue-tsx/js/ceru.plugin.json +1 -4
  83. package/templates/vue-tsx/js/package.json +3 -2
  84. package/templates/vue-tsx/ts/.vscode/launch.json +8 -2
  85. package/templates/vue-tsx/ts/.vscode/tasks.json +11 -3
  86. package/templates/vue-tsx/ts/README.md +7 -2
  87. package/templates/vue-tsx/ts/ceru-plugin.code-workspace +8 -0
  88. package/templates/vue-tsx/ts/ceru.plugin.json +1 -4
  89. package/templates/vue-tsx/ts/package.json +3 -2
  90. package/templates/web-dist/js/.vscode/launch.json +8 -2
  91. package/templates/web-dist/js/.vscode/tasks.json +11 -3
  92. package/templates/web-dist/js/README.md +7 -2
  93. package/templates/web-dist/js/ceru-plugin.code-workspace +8 -0
  94. package/templates/web-dist/js/package.json +3 -2
  95. package/templates/web-dist/ts/.vscode/launch.json +8 -2
  96. package/templates/web-dist/ts/.vscode/tasks.json +11 -3
  97. package/templates/web-dist/ts/README.md +7 -2
  98. package/templates/web-dist/ts/ceru-plugin.code-workspace +8 -0
  99. package/templates/web-dist/ts/package.json +3 -2
  100. package/templates/web-surface/js/.vscode/launch.json +8 -2
  101. package/templates/web-surface/js/.vscode/tasks.json +11 -3
  102. package/templates/web-surface/js/README.md +7 -2
  103. package/templates/web-surface/js/ceru-plugin.code-workspace +8 -0
  104. package/templates/web-surface/js/package.json +3 -2
  105. package/templates/web-surface/ts/.vscode/launch.json +8 -2
  106. package/templates/web-surface/ts/.vscode/tasks.json +11 -3
  107. package/templates/web-surface/ts/README.md +7 -2
  108. package/templates/web-surface/ts/ceru-plugin.code-workspace +8 -0
  109. package/templates/web-surface/ts/package.json +3 -2
  110. package/assets/shared-react.js +0 -77
  111. package/assets/shared-vue.js +0 -44
package/assets/sandbox.js CHANGED
@@ -33,4 +33,4 @@ function print() { __p += __j.call(arguments, '') }
33
33
  * Released under MIT license <https://lodash.com/license>
34
34
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
35
35
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
36
- */var kd=["platform.tx","platform.kg","platform.kw","platform.wy","platform.mg","platform.local","platform.all","search","music-note","library","cloud","server","import","chart","settings","play","pause","download","share","account","heart","refresh","close","add","info"],Ud=["app.logo","placeholder.cover","placeholder.avatar"];var Gd=["chunk","compact","concat","difference","drop","dropRight","flatten","flattenDeep","head","last","intersection","uniq","uniqBy","union","zip","take","takeRight","groupBy","keyBy","countBy","orderBy","sortBy","partition","shuffle","sample","map","filter","find","some","every","reduce","includes","get","has","pick","omit","mapKeys","mapValues","cloneDeep","isEqual","isEmpty","isNil","isString","isNumber","isArray","isPlainObject","camelCase","kebabCase","snakeCase","startCase","capitalize","escape","unescape","trim","truncate","debounce","throttle","once","memoize","clamp","range","sum","sumBy","round"];var kr;globalThis.__ceruSharedModules=Object.create(null);globalThis.__ceruSharedRequire=r=>{let t=globalThis.__ceruSharedModules[r];if(!t)throw new Error("Shared runtime is not declared/available: "+r);return t};var Dp,Hd=!1,QL=0,sp=new Map,kp=new Map,Up=new Map,jp=new Map,Gp=new Set,qd=[],rP=r=>{let t=new WeakSet;try{return JSON.parse(JSON.stringify(r,(e,o)=>{if(/password|secret|api.?key|authorization|token|credential/i.test(e))return"[redacted]";if(o instanceof Error)return{name:o.name,message:o.message,stack:o.stack};if(typeof o=="object"&&o){if(t.has(o))return"[circular]";t.add(o)}return typeof o=="function"?"[function]":typeof o=="bigint"?String(o):o})??"null")}catch{return String(r)}},Pr=(r,t={})=>parent.postMessage({type:r,data:t,generation:kr?.generation},"*");for(let r of["debug","log","info","warn","error"]){let t=console[r].bind(console);console[r]=(...e)=>{t(...e),Pr("log",{level:r,values:rP(e)})}}function mt(r,t={}){let e="rpc-"+ ++QL;return new Promise((o,f)=>{sp.set(e,{resolve:o,reject:f,timer:setTimeout(()=>{sp.delete(e),f(new Error("Host RPC timed out: "+r))},2e4)}),Pr("rpc",{id:e,method:r,data:t})})}function tP(){let r={};for(let t of Gd)r[t]=Np[t];return{host:Object.freeze({apiVersion:"2.0.0",libraries:{lodash:"4.18.1",icons:"1.0.0",assets:"1.0.0",...kr.catalog.libraries},mode:"development"}),utils:{lodash:Object.freeze(r)},icons:{list:()=>kd,url:async t=>{let e=kr.catalog.icons[t];if(!e)throw new Error("Unknown Host icon: "+t);return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e)))}},assets:{list:()=>Ud,url:async t=>{if(typeof t=="string"){let o=kr.catalog.assets[t];if(!o)throw new Error("Unknown Host asset: "+t);return o}let e=kr.resources[t.id];if(!e||e.type==="json")throw new Error("Unknown image/text resource");return"data:"+(e.mime||"text/plain")+";base64,"+(e.type==="base64"?e.value:btoa(unescape(encodeURIComponent(e.value))))}}}}function eP(){let r=tP();if(kr.kind==="web")return{...r,root:document.getElementById("plugin-root"),invoke:(e,o)=>mt("surface.invoke",{action:e,input:o}),subscribe:e=>(Gp.add(e),()=>Gp.delete(e))};if(kr.kind==="guest")return{host:r.host,utils:r.utils,guestId:"development-guest",expose:(e,o)=>{if(["__proto__","constructor","prototype"].includes(e))throw new Error("Unsafe global");globalThis[e]=o},invokeHost:(e,o)=>mt("guest."+e,o)};let t=kr.manifest;return{...r,plugin:{id:t.id,version:t.version},config:{get:()=>mt("config.get")},providers:{register:(e,o)=>{if(!t.contributes?.providers?.some(f=>f.id===e))throw new Error("Undeclared provider: "+e);return kp.set(e,o),Pr("register",{kind:"provider",id:e,methods:Object.keys(o).filter(f=>typeof o[f]=="function")}),()=>{kp.delete(e),Pr("unregister",{kind:"provider",id:e})}}},actions:{register:(e,o)=>{if(!t.contributes?.commands?.some(f=>f.action===e))throw new Error("Undeclared action: "+e);return Up.set(e,o),Pr("register",{kind:"action",id:e}),()=>{Up.delete(e),Pr("unregister",{kind:"action",id:e})}}},permissions:{query:e=>mt("permissions.query",e),request:e=>mt("permissions.request",e)},http:{request:e=>mt("http.request",{...e,operation:{id:e.operation?.id,deadlineAt:e.operation?.deadlineAt}})},credentials:{get:()=>Promise.resolve(null)},media:{createLease:e=>mt("media.createLease",{...e,operation:{id:e.operation?.id}})},playback:{failure:e=>({ok:!1,error:e})},ui:{setState:(e,o)=>(Pr("state",{surfaceId:e,state:o}),Promise.resolve()),notify:e=>(Pr("notify",e),Promise.resolve()),openView:e=>(Pr("open-view",{surfaceId:e}),Promise.resolve())},storage:{get:e=>mt("storage.get",{key:e}),set:(e,o)=>mt("storage.set",{key:e,value:o}),delete:e=>mt("storage.delete",{key:e})},guests:{list:()=>Promise.resolve([]),prepareInstall:()=>Promise.reject(new Error("Guest installation requires the production Host; inspect the bootstrap module separately in this playground.")),requestInstall:()=>Promise.reject(new Error("Guest installation is unavailable in this playground.")),invoke:()=>Promise.reject(new Error("No Guest instance is installed."))},log:Object.fromEntries(["debug","info","warn","error"].map(e=>[e,(o,f)=>console[e](o,f)])),effects:{add:e=>qd.push(e)}}}async function zd(){if(!(!kr||!Dp||Hd)){Hd=!0;try{let r=eP();globalThis.__ceruContext=r;let t=await Dp(r);typeof t=="function"&&qd.push(t),Pr("active")}catch(r){console.error(r),Pr("failed",{message:String(r)})}}}globalThis.__ceruStart=r=>{Dp=r,zd()};window.addEventListener("message",async r=>{if(r.source!==parent)return;let t=r.data;if(t?.type==="init"&&!kr){kr=t.data,zd();return}if(!(!kr||t?.generation!==kr.generation)){if(t.type==="rpc-result"){let e=sp.get(t.data.id);e&&(clearTimeout(e.timer),sp.delete(t.data.id),t.data.error?e.reject(new Error(t.data.error)):e.resolve(t.data.value))}if(t.type==="state")for(let e of Gp)e(t.data);if(t.type==="cancel"&&jp.get(t.data.id)?.abort(),t.type==="invoke"){let{id:e,kind:o,target:f,method:a,args:n}=t.data,m=new AbortController;jp.set(e,m);let p=setTimeout(()=>m.abort(),15e3),s={id:e,deadlineAt:Date.now()+15e3,signal:m.signal,userIntent:{kind:"user-intent",id:e}};try{let u=o==="action"?Up.get(f):kp.get(f)?.[a];if(typeof u!="function")throw new Error("Method is not registered");let l=await u(...n,s);Pr("invoke-result",{id:e,value:l})}catch(u){Pr("invoke-result",{id:e,error:u instanceof Error?u.message:String(u)})}finally{clearTimeout(p),jp.delete(e)}}}});window.addEventListener("error",r=>Pr("failed",{message:r.message}));window.addEventListener("unhandledrejection",r=>console.error(r.reason));Pr("ready");})();
36
+ */var kd=["platform.tx","platform.kg","platform.kw","platform.wy","platform.mg","platform.local","platform.all","search","music-note","library","cloud","server","import","chart","settings","play","pause","download","share","account","heart","refresh","close","add","info"],Ud=["app.logo","placeholder.cover","placeholder.avatar"];var Gd=["chunk","compact","concat","difference","drop","dropRight","flatten","flattenDeep","head","last","intersection","uniq","uniqBy","union","zip","take","takeRight","groupBy","keyBy","countBy","orderBy","sortBy","partition","shuffle","sample","map","filter","find","some","every","reduce","includes","get","has","pick","omit","mapKeys","mapValues","cloneDeep","isEqual","isEmpty","isNil","isString","isNumber","isArray","isPlainObject","camelCase","kebabCase","snakeCase","startCase","capitalize","escape","unescape","trim","truncate","debounce","throttle","once","memoize","clamp","range","sum","sumBy","round"];var kr,Dp,Hd=!1,QL=0,sp=new Map,kp=new Map,Up=new Map,jp=new Map,Gp=new Set,qd=[],rP=r=>{let t=new WeakSet;try{return JSON.parse(JSON.stringify(r,(e,o)=>{if(/password|secret|api.?key|authorization|token|credential/i.test(e))return"[redacted]";if(o instanceof Error)return{name:o.name,message:o.message,stack:o.stack};if(typeof o=="object"&&o){if(t.has(o))return"[circular]";t.add(o)}return typeof o=="function"?"[function]":typeof o=="bigint"?String(o):o})??"null")}catch{return String(r)}},Pr=(r,t={})=>parent.postMessage({type:r,data:t,generation:kr?.generation},"*");for(let r of["debug","log","info","warn","error"]){let t=console[r].bind(console);console[r]=(...e)=>{t(...e),Pr("log",{level:r,values:rP(e)})}}function mt(r,t={}){let e="rpc-"+ ++QL;return new Promise((o,f)=>{sp.set(e,{resolve:o,reject:f,timer:setTimeout(()=>{sp.delete(e),f(new Error("Host RPC timed out: "+r))},2e4)}),Pr("rpc",{id:e,method:r,data:t})})}function tP(){let r={};for(let t of Gd)r[t]=Np[t];return{host:Object.freeze({apiVersion:"2.0.0",libraries:{lodash:"4.18.1",icons:"1.0.0",assets:"1.0.0",...kr.catalog.libraries},mode:"development"}),utils:{lodash:Object.freeze(r)},icons:{list:()=>kd,url:async t=>{let e=kr.catalog.icons[t];if(!e)throw new Error("Unknown Host icon: "+t);return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e)))}},assets:{list:()=>Ud,url:async t=>{if(typeof t=="string"){let o=kr.catalog.assets[t];if(!o)throw new Error("Unknown Host asset: "+t);return o}let e=kr.resources[t.id];if(!e||e.type==="json")throw new Error("Unknown image/text resource");return"data:"+(e.mime||"text/plain")+";base64,"+(e.type==="base64"?e.value:btoa(unescape(encodeURIComponent(e.value))))}}}}function eP(){let r=tP();if(kr.kind==="web")return{...r,root:document.getElementById("plugin-root"),invoke:(e,o)=>mt("surface.invoke",{action:e,input:o}),subscribe:e=>(Gp.add(e),()=>Gp.delete(e))};if(kr.kind==="guest")return{host:r.host,utils:r.utils,guestId:"development-guest",expose:(e,o)=>{if(["__proto__","constructor","prototype"].includes(e))throw new Error("Unsafe global");globalThis[e]=o},invokeHost:(e,o)=>mt("guest."+e,o)};let t=kr.manifest;return{...r,plugin:{id:t.id,version:t.version},config:{get:()=>mt("config.get")},providers:{register:(e,o)=>{if(!t.contributes?.providers?.some(f=>f.id===e))throw new Error("Undeclared provider: "+e);return kp.set(e,o),Pr("register",{kind:"provider",id:e,methods:Object.keys(o).filter(f=>typeof o[f]=="function")}),()=>{kp.delete(e),Pr("unregister",{kind:"provider",id:e})}}},actions:{register:(e,o)=>{if(!t.contributes?.commands?.some(f=>f.action===e))throw new Error("Undeclared action: "+e);return Up.set(e,o),Pr("register",{kind:"action",id:e}),()=>{Up.delete(e),Pr("unregister",{kind:"action",id:e})}}},permissions:{query:e=>mt("permissions.query",e),request:e=>mt("permissions.request",e)},http:{request:e=>mt("http.request",{...e,operation:{id:e.operation?.id,deadlineAt:e.operation?.deadlineAt}})},credentials:{get:()=>Promise.resolve(null)},media:{createLease:e=>mt("media.createLease",{...e,operation:{id:e.operation?.id}})},playback:{failure:e=>({ok:!1,error:e})},ui:{setState:(e,o)=>(Pr("state",{surfaceId:e,state:o}),Promise.resolve()),notify:e=>(Pr("notify",e),Promise.resolve()),openView:e=>(Pr("open-view",{surfaceId:e}),Promise.resolve())},storage:{get:e=>mt("storage.get",{key:e}),set:(e,o)=>mt("storage.set",{key:e,value:o}),delete:e=>mt("storage.delete",{key:e})},guests:{list:()=>Promise.resolve([]),prepareInstall:()=>Promise.reject(new Error("Guest installation requires the production Host; inspect the bootstrap module separately in this playground.")),requestInstall:()=>Promise.reject(new Error("Guest installation is unavailable in this playground.")),invoke:()=>Promise.reject(new Error("No Guest instance is installed."))},log:Object.fromEntries(["debug","info","warn","error"].map(e=>[e,(o,f)=>console[e](o,f)])),effects:{add:e=>qd.push(e)}}}async function zd(){if(!(!kr||!Dp||Hd)){Hd=!0;try{let r=eP();globalThis.__ceruContext=r;let t=await Dp(r);typeof t=="function"&&qd.push(t),Pr("active")}catch(r){console.error(r),Pr("failed",{message:String(r)})}}}globalThis.__ceruStart=r=>{Dp=r,zd()};window.addEventListener("message",async r=>{if(r.source!==parent)return;let t=r.data;if(t?.type==="init"&&!kr){kr=t.data,zd();return}if(!(!kr||t?.generation!==kr.generation)){if(t.type==="rpc-result"){let e=sp.get(t.data.id);e&&(clearTimeout(e.timer),sp.delete(t.data.id),t.data.error?e.reject(new Error(t.data.error)):e.resolve(t.data.value))}if(t.type==="state")for(let e of Gp)e(t.data);if(t.type==="cancel"&&jp.get(t.data.id)?.abort(),t.type==="invoke"){let{id:e,kind:o,target:f,method:a,args:n}=t.data,m=new AbortController;jp.set(e,m);let p=setTimeout(()=>m.abort(),15e3),s={id:e,deadlineAt:Date.now()+15e3,signal:m.signal,userIntent:{kind:"user-intent",id:e}};try{let u=o==="action"?Up.get(f):kp.get(f)?.[a];if(typeof u!="function")throw new Error("Method is not registered");let l=await u(...n,s);Pr("invoke-result",{id:e,value:l})}catch(u){Pr("invoke-result",{id:e,error:u instanceof Error?u.message:String(u)})}finally{clearTimeout(p),jp.delete(e)}}}});window.addEventListener("error",r=>Pr("failed",{message:r.message}));window.addEventListener("unhandledrejection",r=>console.error(r.reason));Pr("ready");})();
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>;
package/dist/dev.js CHANGED
@@ -1,18 +1,39 @@
1
- import { readFile } from 'node:fs/promises';
1
+ import { readFile, realpath } from 'node:fs/promises';
2
2
  import { watch } from 'node:fs';
3
3
  import { createServer, request as httpRequest } from 'node:http';
4
4
  import { request as httpsRequest } from 'node:https';
5
5
  import { lookup } from 'node:dns/promises';
6
6
  import { isIP } from 'node:net';
7
- import { resolve, relative } from 'node:path';
7
+ import { resolve, relative, dirname } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { createRequire } from 'node:module';
10
- import { randomBytes } from 'node:crypto';
10
+ import { randomBytes, createHash } from 'node:crypto';
11
11
  import { spawn } from 'node:child_process';
12
- import { satisfies } from 'semver';
13
12
  import { readArtifact, parseJsonStrict } from '@shiqianjiang/ceru-plugin-issuer';
14
13
  import { buildProject } from './project.js';
15
14
  const asset = (name) => fileURLToPath(new URL('../assets/' + name, import.meta.url));
15
+ async function readDebugTargets(port) {
16
+ const response = await fetch('http://127.0.0.1:' + port + '/json/list', {
17
+ signal: AbortSignal.timeout(750),
18
+ });
19
+ if (!response.ok)
20
+ throw new Error('Debugger is not ready');
21
+ const value = await response.json();
22
+ return Array.isArray(value) ? value : [];
23
+ }
24
+ async function waitForDebugger(origin, port, exited) {
25
+ const deadline = Date.now() + 15000;
26
+ while (Date.now() < deadline && !exited()) {
27
+ try {
28
+ const targets = await readDebugTargets(port);
29
+ if (targets.some((t) => t.type === 'page' && t.url === origin + '/'))
30
+ return;
31
+ }
32
+ catch { }
33
+ await new Promise((done) => setTimeout(done, 100));
34
+ }
35
+ throw new Error('Electron debug target did not become ready at ' + origin);
36
+ }
16
37
  const privateAddress = (address) => {
17
38
  const value = address.toLowerCase();
18
39
  if (value.includes(':'))
@@ -128,12 +149,50 @@ async function fetchAllowed(input, permission, privateAllowed, binary = false, r
128
149
  });
129
150
  }
130
151
  export async function runDev(project, options = {}) {
131
- const root = resolve(project);
152
+ const root = await realpath(resolve(project));
132
153
  const port = options.port ?? 4179;
133
154
  const debugPort = options.debugPort ?? 9223;
134
155
  if (![port, debugPort].every((n) => Number.isInteger(n) && n >= 0 && n <= 65535))
135
156
  throw new Error('Invalid port');
136
- let build = await buildProject(root, { development: true });
157
+ const projectKey = createHash('sha256')
158
+ .update(process.platform === 'win32' ? root.toLowerCase() : root)
159
+ .digest('hex');
160
+ if (options.ensureRunning && port > 0) {
161
+ let existing;
162
+ try {
163
+ const response = await fetch('http://127.0.0.1:' + port + '/__ceru_dev__/status', {
164
+ signal: AbortSignal.timeout(750),
165
+ });
166
+ if (response.ok)
167
+ existing = await response.json();
168
+ }
169
+ catch { }
170
+ if (existing) {
171
+ if (existing.projectKey !== projectKey || existing.debugPort !== debugPort)
172
+ throw new Error('This dev port belongs to another project or debug port. Stop it or select Attach to Ceru plugin with the correct ports.');
173
+ await waitForDebugger(existing.origin, debugPort, () => false);
174
+ console.log('Reusing existing Ceru development Host.');
175
+ console.log('CERU_DEBUG_READY ' + existing.origin + '/');
176
+ return;
177
+ }
178
+ }
179
+ const prepare = async () => {
180
+ if (!options.artifact)
181
+ return buildProject(root, { development: true });
182
+ const path = resolve(options.artifact);
183
+ const bytes = await readFile(path);
184
+ const parsed = readArtifact(bytes);
185
+ if (Object.keys(parsed.header.manifest.engines.libraries ?? {}).length)
186
+ throw new Error('This artifact still requires Host frameworks. Rebuild it with CLI 0.1.2 or later.');
187
+ // Serve the verified release functions as scripts inside the same isolated
188
+ // Surface. No project imports, transpiler, or framework is involved here.
189
+ const devModules = Object.fromEntries(Object.entries(parsed.modules).map(([id, code]) => [
190
+ id,
191
+ 'globalThis.__ceruStart(' + code + ');\n',
192
+ ]));
193
+ return { path, bytes: bytes.length, devModules };
194
+ };
195
+ let build = await prepare();
137
196
  let artifact = readArtifact(await readFile(build.path));
138
197
  let revision = 1;
139
198
  let error = null;
@@ -143,18 +202,6 @@ export async function runDev(project, options = {}) {
143
202
  const token = randomBytes(24).toString('hex');
144
203
  const nonce = randomBytes(24).toString('base64');
145
204
  const catalog = JSON.parse(await readFile(asset('catalog.json'), 'utf8'));
146
- const checkLibraries = () => {
147
- for (const [name, range] of Object.entries(artifact.header.manifest.engines.libraries ?? {})) {
148
- if (!catalog.libraries[name] || !satisfies(catalog.libraries[name], range))
149
- throw new Error('Plugin requires Host ' +
150
- name +
151
- ' ' +
152
- range +
153
- '; dev Host provides ' +
154
- catalog.libraries[name]);
155
- }
156
- };
157
- checkLibraries();
158
205
  let config = {};
159
206
  const grants = new Map();
160
207
  const storage = new Map();
@@ -168,9 +215,8 @@ export async function runDev(project, options = {}) {
168
215
  do {
169
216
  dirty = false;
170
217
  try {
171
- build = await buildProject(root, { development: true });
218
+ build = await prepare();
172
219
  artifact = readArtifact(await readFile(build.path));
173
- checkLibraries();
174
220
  revision++;
175
221
  error = null;
176
222
  grants.clear();
@@ -184,10 +230,18 @@ export async function runDev(project, options = {}) {
184
230
  } while (dirty);
185
231
  running = false;
186
232
  };
187
- const watcher = watch(root, { recursive: true }, (_event, path) => {
233
+ const watchRoot = options.artifact ? dirname(resolve(options.artifact)) : root;
234
+ const watcher = watch(watchRoot, { recursive: !options.artifact }, (_event, path) => {
188
235
  if (!path)
189
236
  return;
190
237
  const rel = path.toString().replaceAll('\\', '/');
238
+ if (options.artifact) {
239
+ if (resolve(watchRoot, path.toString()) !== resolve(options.artifact))
240
+ return;
241
+ clearTimeout(timer);
242
+ timer = setTimeout(() => void rebuild(), 250);
243
+ return;
244
+ }
191
245
  if (/^(node_modules|dist|\.git|\.keys|\.ceru-dev)(\/|$)/.test(rel) ||
192
246
  rel === relative(root, build.path).replaceAll('\\', '/') ||
193
247
  rel.includes('.tmp'))
@@ -213,6 +267,16 @@ export async function runDev(project, options = {}) {
213
267
  return;
214
268
  }
215
269
  const url = new URL(request.url ?? '/', origin);
270
+ if (url.pathname === '/__ceru_dev__/status' && request.method === 'GET') {
271
+ json(200, {
272
+ protocol: 1,
273
+ projectKey,
274
+ origin,
275
+ debugPort,
276
+ mode: options.artifact ? 'preview' : 'dev',
277
+ });
278
+ return;
279
+ }
216
280
  if (url.pathname.startsWith('/media/') && request.method === 'GET') {
217
281
  const lease = leases.get(url.pathname.slice('/media/'.length));
218
282
  const grant = lease && grants.get(lease.permissionKey);
@@ -387,16 +451,10 @@ export async function runDev(project, options = {}) {
387
451
  const moduleId = url.searchParams.get('module') ?? '';
388
452
  if (!Object.hasOwn(build.devModules, moduleId))
389
453
  throw new Error('Unknown module');
390
- const libraries = artifact.header.manifest.engines.libraries ?? {};
391
- const shared = [libraries.vue ? 'vue' : '', libraries.react ? 'react' : '']
392
- .filter(Boolean)
393
- .map((name) => '<script nonce="' + nonce + '" src="/shared/' + name + '.js"></script>')
394
- .join('');
395
454
  contents =
396
455
  '<!doctype html><meta charset="utf-8"><div id="plugin-root"></div><script nonce="' +
397
456
  nonce +
398
457
  '" src="/sandbox.js"></script>' +
399
- shared +
400
458
  '<script nonce="' +
401
459
  nonce +
402
460
  '" src="/modules/' +
@@ -419,8 +477,6 @@ export async function runDev(project, options = {}) {
419
477
  '/playground.js': 'playground.js',
420
478
  '/style.css': 'style.css',
421
479
  '/sandbox.js': 'sandbox.js',
422
- '/shared/vue.js': 'shared-vue.js',
423
- '/shared/react.js': 'shared-react.js',
424
480
  }[url.pathname];
425
481
  if (!file) {
426
482
  json(404, { error: 'Not found' });
@@ -495,7 +551,9 @@ export async function runDev(project, options = {}) {
495
551
  console.log('Electron exited: ' + code);
496
552
  close();
497
553
  });
554
+ await waitForDebugger(origin, debugPort, () => electron?.exitCode !== null);
498
555
  console.log('Electron debugger: 127.0.0.1:' + debugPort + ' (VS Code: Attach to Ceru plugin)');
556
+ console.log('CERU_DEBUG_READY ' + origin + '/');
499
557
  }
500
558
  catch (e) {
501
559
  console.error('Electron could not start. Run npm install in the generated project, or use dev --no-open and open the playground URL.');
@@ -1,6 +1,6 @@
1
1
  import { type Plugin } from 'esbuild';
2
- export declare const SHARED_IMPORTS: Record<string, string>;
3
- export declare function sharedPlugin(libraries?: Record<string, string>): Plugin;
2
+ /** Side-effect stylesheet imports must survive single-file builds (React/Vue/vanilla). */
3
+ export declare function stylesheetPlugin(): Plugin;
4
4
  export declare function vuePlugin(root: string, framework?: string): Plugin;
5
5
  /** Convert a local, already-built SPA into a Surface entry. No uploaded HTML is executed by the CLI. */
6
6
  export declare function webDistEntry(directoryInput: string): Promise<{
@@ -8,15 +8,6 @@ import { transformAsync } from '@babel/core';
8
8
  import vueJsx from '@vue/babel-plugin-jsx';
9
9
  import { parse as parseHtml, serialize } from 'parse5';
10
10
  import { parse as parseJs } from 'acorn';
11
- export const SHARED_IMPORTS = {
12
- vue: 'vue',
13
- 'vue/jsx-runtime': 'vue',
14
- react: 'react',
15
- 'react/jsx-runtime': 'react',
16
- 'react/jsx-dev-runtime': 'react',
17
- 'react-dom': 'react-dom',
18
- 'react-dom/client': 'react-dom',
19
- };
20
11
  const mime = {
21
12
  '.png': 'image/png',
22
13
  '.jpg': 'image/jpeg',
@@ -64,29 +55,20 @@ async function cssBundle(css, directory) {
64
55
  throw new Error('CSS emitted an external resource');
65
56
  return result.outputFiles[0].text;
66
57
  }
67
- export function sharedPlugin(libraries = {}) {
68
- if (!!libraries.react !== !!libraries['react-dom'])
69
- throw new Error('Share react and react-dom together to avoid duplicate React runtimes');
58
+ /** Side-effect stylesheet imports must survive single-file builds (React/Vue/vanilla). */
59
+ export function stylesheetPlugin() {
70
60
  return {
71
- name: 'ceru-host-libraries',
61
+ name: 'ceru-inline-stylesheets',
72
62
  setup(ctx) {
73
- ctx.onResolve({ filter: /^(vue(?:\/.*)?|react(?:\/.*)?|react-dom(?:\/.*)?)$/ }, (args) => {
74
- const root = SHARED_IMPORTS[args.path];
75
- const family = args.path.startsWith('vue')
76
- ? 'vue'
77
- : args.path.startsWith('react-dom')
78
- ? 'react-dom'
79
- : 'react';
80
- if (!libraries[family])
81
- return;
82
- if (!root)
83
- return { errors: [{ text: 'Unsupported shared runtime import: ' + args.path }] };
84
- return { path: args.path, namespace: 'ceru-host-library' };
63
+ ctx.onLoad({ filter: /\.css$/ }, async (args) => {
64
+ const css = await cssBundle(await readFile(args.path, 'utf8'), dirname(args.path));
65
+ const id = createHash('sha256').update(css).digest('hex').slice(0, 16);
66
+ return {
67
+ contents: 'export default ' + JSON.stringify(css) + ';' + styleCode(css, id),
68
+ loader: 'js',
69
+ resolveDir: dirname(args.path),
70
+ };
85
71
  });
86
- ctx.onLoad({ filter: /.*/, namespace: 'ceru-host-library' }, (args) => ({
87
- contents: 'module.exports = globalThis.__ceruSharedRequire(' + JSON.stringify(args.path) + ');',
88
- loader: 'js',
89
- }));
90
72
  },
91
73
  };
92
74
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { createTemplate, generateSigningKeys, parseJsonStrict, PreparedIssuer, r
6
6
  import { buildProject, scaffoldProject, TEMPLATES, writeAtomic } from './project.js';
7
7
  import { runDev } from './dev.js';
8
8
  export { buildProject, loadProject, scaffoldProject, TEMPLATES } from './project.js';
9
- const VERSION = '0.1.0';
9
+ const VERSION = '0.1.2';
10
10
  const HELP = 'Ceru Plugin CLI ' +
11
11
  VERSION +
12
12
  '\n\n' +
@@ -16,6 +16,7 @@ const HELP = 'Ceru Plugin CLI ' +
16
16
  ' list-templates\n' +
17
17
  ' build [--project directory] [--out dist/plugin.js]\n' +
18
18
  ' dev [--project directory] [--port 4179] [--debug-port 9223] [--no-open]\n' +
19
+ ' preview <plugin.js> [--port 4179] [--debug-port 9223] [--no-open]\n' +
19
20
  ' validate <plugin.js> [--trusted-key publisher.public.pem] [--json]\n' +
20
21
  ' keygen --out .keys/publisher\n' +
21
22
  ' sign <plugin.js> --key private.pem [--out signed.js] [--force]\n' +
@@ -43,6 +44,7 @@ export async function runCli(argv = process.argv.slice(2)) {
43
44
  port: { type: 'string' },
44
45
  'debug-port': { type: 'string' },
45
46
  'no-open': { type: 'boolean' },
47
+ 'ensure-running': { type: 'boolean' },
46
48
  hidden: { type: 'boolean' },
47
49
  electron: { type: 'string' },
48
50
  key: { type: 'string' },
@@ -121,13 +123,17 @@ export async function runCli(argv = process.argv.slice(2)) {
121
123
  console.log('Built ' + output.path + ' (' + output.bytes + ' bytes)');
122
124
  return;
123
125
  }
124
- if (command === 'dev') {
126
+ if (command === 'dev' || command === 'preview') {
127
+ if (command === 'preview' && !positionals[1])
128
+ throw new Error('An artifact file is required');
125
129
  await runDev(flags.project ?? '.', {
126
130
  port: Number(flags.port ?? 4179),
127
131
  debugPort: Number(flags['debug-port'] ?? 9223),
128
132
  noOpen: flags['no-open'],
129
133
  hidden: flags.hidden,
130
134
  electron: flags.electron,
135
+ artifact: command === 'preview' ? resolve(positionals[1]) : undefined,
136
+ ensureRunning: flags['ensure-running'],
131
137
  });
132
138
  return;
133
139
  }
package/dist/project.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface BuildConfig {
9
9
  }>;
10
10
  output?: string;
11
11
  framework?: 'vanilla' | 'vue' | 'react';
12
+ /** @deprecated Accepted to migrate 0.1.0 projects; frameworks are now always bundled. */
12
13
  sharedLibraries?: Partial<Record<'vue' | 'react' | 'react-dom', string>>;
13
14
  webDist?: Record<string, string>;
14
15
  }
package/dist/project.js CHANGED
@@ -6,7 +6,7 @@ import { build } from 'esbuild';
6
6
  import ts from 'typescript';
7
7
  import { spawnSync } from 'node:child_process';
8
8
  import { createRequire } from 'node:module';
9
- import { sharedPlugin, vuePlugin, webDistEntry } from './frameworks.js';
9
+ import { stylesheetPlugin, vuePlugin, webDistEntry } from './frameworks.js';
10
10
  import { encodeArtifact, parseJsonStrict, readArtifact, validateManifest, LIMITS, } from '@shiqianjiang/ceru-plugin-issuer';
11
11
  export async function writeAtomic(path, data, overwrite = false, mode = 0o644) {
12
12
  await mkdir(dirname(path), { recursive: true });
@@ -51,8 +51,10 @@ export async function loadProject(project) {
51
51
  'webDist',
52
52
  ].includes(key))
53
53
  throw new Error('Unknown build config key: ' + key);
54
- if (raw.sharedLibraries !== undefined)
55
- raw.manifest.engines.libraries = raw.sharedLibraries;
54
+ // Older scaffolds declared Host-provided Vue/React. Always migrate their output
55
+ // to standalone bundles, without requiring authors to rewrite their source.
56
+ if (raw.manifest?.engines)
57
+ delete raw.manifest.engines.libraries;
56
58
  if (raw.framework && !['vanilla', 'vue', 'react'].includes(raw.framework))
57
59
  throw new Error('Unsupported framework');
58
60
  validateManifest(raw.manifest);
@@ -95,7 +97,7 @@ export async function buildProject(project = '.', options = {}) {
95
97
  const checker = program.getTypeChecker();
96
98
  const chunks = [];
97
99
  const devModules = {};
98
- const plugins = [sharedPlugin(config.sharedLibraries), vuePlugin(root, config.framework)];
100
+ const plugins = [vuePlugin(root, config.framework), stylesheetPlugin()];
99
101
  const defines = {
100
102
  'process.env.NODE_ENV': '"production"',
101
103
  __VUE_OPTIONS_API__: 'true',
@@ -134,7 +136,7 @@ export async function buildProject(project = '.', options = {}) {
134
136
  plugins,
135
137
  define: defines,
136
138
  loader: {
137
- '.svg': 'text',
139
+ '.svg': 'dataurl',
138
140
  '.css': 'text',
139
141
  '.png': 'dataurl',
140
142
  '.jpg': 'dataurl',
@@ -174,7 +176,7 @@ export async function buildProject(project = '.', options = {}) {
174
176
  define: defines,
175
177
  footer: { js: 'globalThis.__ceruStart(__ceru_entry.default);' },
176
178
  loader: {
177
- '.svg': 'text',
179
+ '.svg': 'dataurl',
178
180
  '.css': 'text',
179
181
  '.png': 'dataurl',
180
182
  '.jpg': 'dataurl',
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "@shiqianjiang/ceru-plugin-cli",
3
- "version": "0.1.0",
4
- "description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
13
- }
14
- },
15
- "bin": {
16
- "ceru-plugin": "./dist/bin.js"
17
- },
18
- "files": [
19
- "dist",
20
- "assets",
21
- "schemas",
22
- "templates",
23
- "README.md",
24
- "LICENSE",
25
- "ASSET_LICENSE",
26
- "NOTICE"
27
- ],
28
- "license": "MIT AND AGPL-3.0-only",
29
- "author": "澜音团队",
30
- "engines": {
31
- "node": ">=22.12.0"
32
- },
33
- "dependencies": {
34
- "@shiqianjiang/ceru-plugin-issuer": "0.1.0",
35
- "@babel/core": "^7.29.7",
36
- "@vue/babel-plugin-jsx": "^2.0.1",
37
- "@vue/compiler-sfc": "3.5.43",
38
- "esbuild": "^0.28.2",
39
- "lodash-es": "^4.18.1",
40
- "parse5": "^8.0.1",
41
- "semver": "^7.7.0",
42
- "vue": "3.5.43",
43
- "vue-tsc": "^3.3.11",
44
- "react": "19.3.0",
45
- "react-dom": "19.3.0",
46
- "typescript": "~5.9.3"
47
- },
48
- "publishConfig": {
49
- "access": "public",
50
- "registry": "https://registry.npmjs.org/"
51
- },
52
- "repository": {
53
- "type": "git",
54
- "url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
55
- "directory": "packages/cli"
56
- },
57
- "bugs": {
58
- "url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
59
- },
60
- "homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
61
- "keywords": [
62
- "ceru-music",
63
- "plugin",
64
- "typescript",
65
- "electron"
66
- ]
67
- }
1
+ {
2
+ "name": "@shiqianjiang/ceru-plugin-cli",
3
+ "version": "0.1.2",
4
+ "description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "bin": {
16
+ "ceru-plugin": "./dist/bin.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "assets",
21
+ "schemas",
22
+ "templates",
23
+ "README.md",
24
+ "LICENSE",
25
+ "ASSET_LICENSE",
26
+ "NOTICE"
27
+ ],
28
+ "license": "MIT AND AGPL-3.0-only",
29
+ "author": "澜音团队",
30
+ "engines": {
31
+ "node": ">=22.12.0"
32
+ },
33
+ "dependencies": {
34
+ "@shiqianjiang/ceru-plugin-issuer": "0.1.0",
35
+ "@babel/core": "^7.29.7",
36
+ "@vue/babel-plugin-jsx": "^2.0.1",
37
+ "@vue/compiler-sfc": "3.5.43",
38
+ "esbuild": "^0.28.2",
39
+ "lodash-es": "^4.18.1",
40
+ "parse5": "^8.0.1",
41
+ "semver": "^7.7.0",
42
+ "vue": "3.5.43",
43
+ "vue-tsc": "^3.3.11",
44
+ "react": "19.3.0",
45
+ "react-dom": "19.3.0",
46
+ "typescript": "~5.9.3"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
55
+ "directory": "packages/cli"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
59
+ },
60
+ "homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
61
+ "keywords": [
62
+ "ceru-music",
63
+ "plugin",
64
+ "typescript",
65
+ "electron"
66
+ ]
67
+ }
@@ -580,6 +580,8 @@
580
580
  "default": "vanilla"
581
581
  },
582
582
  "sharedLibraries": {
583
+ "deprecated": true,
584
+ "description": "Legacy field ignored since 0.1.2. Vue and React production runtimes are bundled into the plugin.",
583
585
  "type": "object",
584
586
  "properties": {
585
587
  "vue": {
@@ -12,7 +12,10 @@
12
12
  "sourceMapPathOverrides": {
13
13
  "ceru:///*": "${workspaceFolder}/*"
14
14
  },
15
- "skipFiles": ["**/node_modules/**"]
15
+ "skipFiles": ["**/node_modules/**"],
16
+ "address": "127.0.0.1",
17
+ "urlFilter": "http://127.0.0.1:4179/",
18
+ "timeout": 30000
16
19
  },
17
20
  {
18
21
  "name": "Attach to Ceru plugin",
@@ -24,7 +27,10 @@
24
27
  "sourceMapPathOverrides": {
25
28
  "ceru:///*": "${workspaceFolder}/*"
26
29
  },
27
- "skipFiles": ["**/node_modules/**"]
30
+ "skipFiles": ["**/node_modules/**"],
31
+ "address": "127.0.0.1",
32
+ "urlFilter": "http://127.0.0.1:4179/",
33
+ "timeout": 30000
28
34
  }
29
35
  ]
30
36
  }
@@ -3,8 +3,7 @@
3
3
  "tasks": [
4
4
  {
5
5
  "label": "Ceru: dev",
6
- "type": "npm",
7
- "script": "dev",
6
+ "type": "process",
8
7
  "isBackground": true,
9
8
  "problemMatcher": {
10
9
  "owner": "ceru",
@@ -15,8 +14,17 @@
15
14
  "background": {
16
15
  "activeOnStart": true,
17
16
  "beginsPattern": "^.*$",
18
- "endsPattern": "^Electron debugger:"
17
+ "endsPattern": "^CERU_DEBUG_READY "
19
18
  }
19
+ },
20
+ "command": "node",
21
+ "args": [
22
+ "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
23
+ "dev",
24
+ "--ensure-running"
25
+ ],
26
+ "options": {
27
+ "cwd": "${workspaceFolder}"
20
28
  }
21
29
  },
22
30
  {
@@ -26,8 +26,13 @@ VS Code 按 F5 选择 Launch Ceru plugin;已有调试窗口时选择 Attach to
26
26
  - 默认封面:await ctx.assets.url('placeholder.cover')。
27
27
  - 共享工具:ctx.utils.lodash。
28
28
 
29
- 框架模板默认使用声明过版本的宿主 Vue/React 生产运行时;开发编译器不进入插件。
30
- 若需要把生产运行时一起打包,可将 ceru.plugin.json 的 sharedLibraries 改为 {}。
29
+ Vue/React 的生产运行代码、页面和样式直接编入发行 JS,宿主不提供框架。
30
+ TypeScript、Vue 编译器、构建工具与开发服务器不会进入产物。
31
+ 运行 npm run preview 可只加载 dist/plugin.js 检查发布后的行为。
32
+
33
+ 若 VS Code 打开的是父目录,请打开本工程的 ceru-plugin.code-workspace,
34
+ 再在“运行和调试”中选择 Launch Ceru plugin;已经运行 npm/pnpm dev 时选择 Attach to Ceru plugin。
35
+ F5 执行当前下拉框中的配置,不会自动选择终端所在的子工程。
31
36
 
32
37
  ## 边界
33
38
 
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".",
5
+ },
6
+ ],
7
+ "settings": {},
8
+ }