@tomjs/create-app 0.12.1 → 0.13.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/dist/index.mjs +6 -7
- package/package.json +7 -7
- package/{template-node/.eslintrc.cjs → template-electron-react/_eslintrc.cjs} +1 -1
- package/template-electron-react/package.json +10 -10
- package/{template-vscode/.eslintrc.cjs → template-electron-vue/_eslintrc.cjs} +1 -1
- package/template-electron-vue/package.json +10 -10
- package/{template-vscode-vue/.eslintrc.cjs → template-node/_eslintrc.cjs} +1 -1
- package/template-node/package.json +11 -11
- package/{template-electron-vue/.eslintrc.cjs → template-react/_eslintrc.cjs} +1 -1
- package/template-react/package.json +7 -7
- package/template-vscode/_eslintrc.cjs +7 -0
- package/template-vscode/package.json +6 -8
- package/template-vscode/src/index.ts +7 -8
- package/template-vscode-react/_eslintrc.cjs +7 -0
- package/template-vscode-react/extension/env.d.ts +1 -0
- package/template-vscode-react/extension/index.ts +8 -9
- package/template-vscode-react/extension/views/helper.ts +27 -0
- package/template-vscode-react/extension/views/panel.ts +48 -0
- package/template-vscode-react/package.json +9 -12
- package/template-vscode-react/src/utils/vscode.ts +0 -1
- package/template-vscode-react/tsconfig.node.json +1 -1
- package/template-vscode-vue/_eslintrc.cjs +7 -0
- package/template-vscode-vue/extension/env.d.ts +1 -0
- package/template-vscode-vue/extension/index.ts +8 -9
- package/template-vscode-vue/extension/views/helper.ts +27 -0
- package/template-vscode-vue/extension/views/panel.ts +48 -0
- package/template-vscode-vue/package.json +9 -12
- package/template-vscode-vue/src/utils/vscode.ts +0 -1
- package/template-vscode-vue/tsconfig.node.json +1 -1
- package/template-vue/_eslintrc.cjs +7 -0
- package/template-vue/package.json +7 -7
- package/template-electron-react/.eslintrc.cjs +0 -7
- package/template-react/.eslintrc.cjs +0 -7
- package/template-vscode-react/.eslintrc.cjs +0 -7
- package/template-vscode-react/extension/panels/MainPanel.ts +0 -168
- package/template-vscode-vue/extension/panels/MainPanel.ts +0 -168
- package/template-vue/.eslintrc.cjs +0 -7
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Scaffolding project in ${a}...`);let _=y||R?.name||i||"",I=n=>s.join(Je(import.meta.url),"../..",`template-${n}`),Pe=I(_),V=_.includes("node");[Pe,I("config")].forEach(n=>{let t=l.readdirSync(n);for(let r of t){let o=r.startsWith("_")?r.replace("_","."):r;if((V&&!m.includes("examples")||_==="vscode")&&r.includes("stylelint"))continue;let u=s.join(a,o);H(s.join(n,r),u)}});let f=U||w(),J={name:ke("user.name")||Ve.userInfo().username,email:ke("user.email")||""},M={"pkg.name":f,"user.name":J.name,"user.email":J.email,"git.org":W(),"git.url":Re(),"git.fullUrl":ie()};function Re(){return`${E||`https://github.com/${W()}`}/${f.substring(f.indexOf("/")+1)}`}function W(){return E?E.substring(E.lastIndexOf("/")+1):f.startsWith("@")?f.split("/")[0].substring(1):ze(J.name)}function ie(n=!1){let t=E||`https://github.com/${W()}`;return n&&(t=t.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${t}/${f.substring(f.indexOf("/")+1)}.git`}$e(),V&&(Ae(),Ce(),De());let re=me(process.env.npm_config_user_agent),z=re?re.name:"npm";T.which("git")&&(T.exec(`cd ${a} && git init`),m.includes("publish")&&T.exec(`cd ${a} && git remote add origin ${ie(m.includes("ssh"))}`));let L=s.relative(te,a);switch(console.log(`
|
|
1
|
+
import l,{renameSync as Ie}from"fs";import Ve from"os";import s from"path";import{fileURLToPath as Je}from"url";import{lightBlue as D,lightCyan as Me,lightGreen as G,lightYellow as we,red as Se,reset as j,yellow as We}from"kolorist";import{camelCase as ze}from"lodash-es";import Le from"minimist";import Ye from"prompts";import T from"shelljs";import ye from"os";import he from"path";import{blue as Te,red as O,reset as F}from"kolorist";import Ne from"minimist";import Q from"prompts";import p from"fs";import Y from"path";function A(e){return[["t","template"],["g","git"]].forEach(([i,c])=>{e[c]=e[c]??e[i]}),e}function ae(e){return p.readdirSync(e).length===0}function B(e){return e?.trim().replace(/\/+$/g,"")}function Ge(e,i){p.mkdirSync(i,{recursive:!0});for(let c of p.readdirSync(e)){let w=Y.resolve(e,c),u=Y.resolve(i,c);H(w,u)}}function H(e,i){p.statSync(e).isDirectory()?Ge(e,i):p.copyFileSync(e,i)}function le(e){if(p.existsSync(e))for(let i of p.readdirSync(e))p.rmSync(Y.resolve(e,i),{recursive:!0,force:!0})}function K(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function pe(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function me(e){if(!e)return;let c=e.split(" ")[0].split("/");return{name:c[0],version:c[1]}}function S(e){if(p.existsSync(e))try{return JSON.parse(p.readFileSync(e,"utf8"))}catch(i){console.error(i)}}function h(e,i){p.writeFileSync(e,JSON.stringify(i,null,2)+`
|
|
2
|
+
`)}function ue(e){return p.existsSync(e)?p.readFileSync(e,"utf8"):""}function $(e){p.existsSync(e)&&p.rmSync(e,{recursive:!0,force:!0})}function ge(e){p.existsSync(e)||p.mkdirSync(e,{recursive:!0})}var Ue=A(Ne(process.argv.slice(2),{string:["_"]})),fe={repo:"https://github.com",owner:ye.userInfo().username};function X(e){let{repo:i,owner:c}=e;return`${i}${i.endsWith("/")?"":"/"}${c}`}async function de(e){let i=await Q([{type:"text",name:"repo",message:F("Git repository url:"),initial:e?.repo||fe.repo},{type:"text",name:"owner",message:F("Git repository owner:"),initial:e?.owner||fe.owner}],{onCancel:()=>{throw console.log(O("\u2716")+" Operation cancelled"),new Error}});return{id:e?.id||Date.now().toString(),repo:i.repo,owner:i.owner}}var ve=he.join(ye.homedir(),".tomjs","create-app"),xe=he.join(ve,"config.json");function C(){return ge(ve),Object.assign({gitRepos:[]},S(xe))}function _e(e){let i=C();i.createTime?i.updateTime=Date.now():i.createTime=Date.now(),h(xe,Object.assign(i,e))}function q(e){_e({gitRepos:e})}async function Z(){let{gitRepos:e}=C();(e.length===0||Ue.git)&&(e.length===0&&console.log(`You need to set the ${Te("git remote repository")} for the first time.`),await i());async function i(){let c=e.map(y=>({title:X(y),value:y.id})).concat([{title:"Add",value:"add"},{title:O("Exit"),value:"exit"}]),w=await Q({type:"select",name:"repoId",message:e.length===0?"You choose to add or exit:":"You can choose the repository to be operated, or choose to add or exit:",choices:c},{onCancel:()=>{throw console.log(O("\u2716")+" Operation cancelled"),new Error}}),{repoId:u}=w;if(u==="exit")return;if(u==="add"){let y=await de();return e.push(y),q(e),i()}let k=e.findIndex(y=>y.id===u),P=await Q([{type:"select",name:"action",message:F("Select an action?"),choices:[{title:"Edit",value:"edit"},{title:"Remove",value:"remove"},{title:"Exit",value:"exit"}]},{type:y=>y==="remove"&&"toggle",name:"confirmRemove",message:F("Where confirm to remove?"),initial:!0,active:"Yes",inactive:"No"}],{onCancel:()=>{throw console.log(O("\u2716")+" Operation cancelled"),new Error}}),{action:R,confirmRemove:N}=P;if(R==="exit")return Z();if(R==="remove")return N&&(e.splice(k,1),q(e)),i();let U=await de(e[k]);return e[k]=U,q(e),i()}}var ee=A(Le(process.argv.slice(2),{string:["_"]})),te=process.cwd(),Be=["test","vite","electron","examples"],Ee=[{name:"web",display:"Web App",color:G,variants:[{name:"vue",display:"Vue",color:G},{name:"react",display:"React",color:D}]},{name:"electron",display:"Electron App",color:D,variants:[{name:"electron-vue",display:"Vue",color:G},{name:"electron-react",display:"React",color:D}]},{name:"vscode",display:"VSCode Extension",color:Me,options:[{id:"publish",name:"Git Repository"},{id:"ssh",name:"Git init by SSH"}],variants:[{name:"vscode",display:"Base",color:we},{name:"vscode-vue",display:"Vue",color:G},{name:"vscode-react",display:"React",color:D}]},{name:"node",display:"Node",color:we,options:[{id:"test",name:"Test"},{id:"publish",name:"Git Repository + NPM Publish"},{id:"ssh",name:"Git init by SSH"},{id:"vite",name:"Vite Plugin"},{id:"tsup",name:"Use tsup build"},{id:"electron",name:"Electron"},{id:"examples",name:"Examples"}]}],je=Ee.map(e=>e.variants&&e.variants.map(i=>i.name)||[e.name]).reduce((e,i)=>e.concat(i),[]),ne="my-app";function ke(e){let i=T.exec(`git config --get ${e}`,{silent:!0});if(i.code===0)return i.stdout.trim()}function be(e){return e.length>1?e.substring(e.indexOf("/")+1):e}async function He(){let e=B(ee._[0]),i=ee.template||ee.t,c=e||ne,w=()=>c==="."?s.basename(s.resolve()):c,u=be(c),{gitRepos:k}=C(),P=await Ye([{type:e?null:"text",name:"projectName",message:j("Project name:"),initial:ne,onState:n=>{c=B(n.value)||ne,u=be(c)}},{type:()=>!l.existsSync(u)||ae(u)?null:"toggle",name:"overwrite",message:()=>(u==="."?"Current directory":`Target directory "${u}"`)+" is not empty. Remove existing files and continue?",initial:!1,active:"Yes",inactive:"No"},{type:(n,{overwrite:t})=>{if(t===!1)throw console.log(Se("\u2716")+" Operation cancelled"),new Error;return null},name:"overwriteChecker"},{type:()=>K(w())?null:"text",name:"packageName",message:j("Package name:"),initial:()=>pe(w()),validate:n=>K(n)||"Invalid package.json name"},{type:i&&je.includes(i)?null:"select",name:"framework",message:typeof i=="string"&&!je.includes(i)?j(`"${i}" isn't a valid template. Please choose from below: `):j("Select a framework:"),initial:0,choices:Ee.map(n=>{let t=n.color;return{title:t(n.display||n.name),value:n}})},{type:n=>n&&n.variants?"select":null,name:"variant",message:j("Select a variant:"),choices:n=>n?.variants?.map(t=>{let r=t.color;return{title:r(t.display||t.name),value:t.name}})},{type:(n,t)=>{let{framework:r}=t;return r&&Array.isArray(r.options)&&r.options.length?"multiselect":null},name:"options",message:j("Select optional options:"),instructions:!1,choices:(n,t)=>{let{framework:r}=t;return r?.options?.map(o=>({title:o.name,value:o.id}))}},{type:(n,t)=>k.length&&Array.isArray(t.options)&&t.options.includes("publish")?"select":null,name:"gitUserUrl",message:j("Which git repository to publish to?"),choices:k.map(n=>{let t=X(n);return{title:t,value:t}})}],{onCancel:()=>{throw console.log(Se("\u2716")+" Operation cancelled"),new Error}}),{framework:R,overwrite:N,packageName:U,variant:y,gitUserUrl:E}=P,m=P.options||[],a=s.join(te,u);N?le(a):l.existsSync(a)||l.mkdirSync(a,{recursive:!0}),console.log(`
|
|
3
|
+
Scaffolding project in ${a}...`);let _=y||R?.name||i||"",I=n=>s.join(Je(import.meta.url),"../..",`template-${n}`),Pe=I(_),V=_.includes("node");[I("config"),Pe].forEach(n=>{let t=l.readdirSync(n);for(let r of t){let o=r.startsWith("_")?r.replace("_","."):r;(V&&!m.includes("examples")||_==="vscode")&&r.includes("stylelint")||H(s.join(n,r),s.join(a,o))}});let g=U||w(),J={name:ke("user.name")||Ve.userInfo().username,email:ke("user.email")||""},M={"pkg.name":g,"user.name":J.name,"user.email":J.email,"git.org":W(),"git.url":Re(),"git.fullUrl":ie()};function Re(){return`${E||`https://github.com/${W()}`}/${g.substring(g.indexOf("/")+1)}`}function W(){return E?E.substring(E.lastIndexOf("/")+1):g.startsWith("@")?g.split("/")[0].substring(1):ze(J.name)}function ie(n=!1){let t=E||`https://github.com/${W()}`;return n&&(t=t.replace(/http(s):\/\//g,"git@").replace(/\//,":")),`${t}/${g.substring(g.indexOf("/")+1)}.git`}$e(),V&&(Ae(),Ce(),De());let re=me(process.env.npm_config_user_agent),z=re?re.name:"npm";T.which("git")&&(T.exec(`cd ${a} && git init`),m.includes("publish")&&T.exec(`cd ${a} && git remote add origin ${ie(m.includes("ssh"))}`));let L=s.relative(te,a);switch(console.log(`
|
|
5
4
|
Done. Now run:
|
|
6
|
-
`),a!==te&&console.log(` cd ${L.includes(" ")?`"${L}"`:L}`),z){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${z} install`),console.log(` ${z} run dev`);break}function Ae(){Fe(".lintstagedrc.cjs","jest.config.cjs","tsconfig.json");let n=m.find(r=>["vite"].includes(r)),t=["#pnpm",`pnpm add ${
|
|
7
|
-
`);["LICENSE","README.md","README.zh_CN.md"].forEach(r=>{let o=s.join(a,r);if(!m.includes("publish")&&l.existsSync(o)){l.rmSync(o),r==="README.md"&&l.writeFileSync(o,`# ${
|
|
8
|
-
`,{encoding:"utf-8"});return}if(!l.existsSync(o))return;let
|
|
5
|
+
`),a!==te&&console.log(` cd ${L.includes(" ")?`"${L}"`:L}`),z){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${z} install`),console.log(` ${z} run dev`);break}function Ae(){Fe(".lintstagedrc.cjs","jest.config.cjs","tsconfig.json");let n=m.find(r=>["vite"].includes(r)),t=["#pnpm",`pnpm add ${g}${n?" -D":""}`,"","#yarn",`yarn add ${g}${n?" -D":""}`,"","#npm",`npm i ${g}${n?" --save-dev":""}`].join(`
|
|
6
|
+
`);["LICENSE","README.md","README.zh_CN.md"].forEach(r=>{let o=s.join(a,r);if(!m.includes("publish")&&l.existsSync(o)){l.rmSync(o),r==="README.md"&&l.writeFileSync(o,`# ${g}
|
|
7
|
+
`,{encoding:"utf-8"});return}if(!l.existsSync(o))return;let f=Object.assign({},M,{"pkg.install":t}),d=l.readFileSync(o,"utf-8");Object.keys(f).forEach(x=>{d=d.replace(new RegExp("{{"+x+"}}","g"),f[x])}),l.writeFileSync(o,d,"utf8")})}function v(n,...t){["dependencies","devDependencies"].forEach(r=>{Object.keys(n[r]||{}).forEach(o=>{t.find(f=>o.includes(f))&&delete n[r][o]})})}function b(...n){!Array.isArray(n)||n.length===0||n.forEach(t=>{let r=s.join(a,t);l.existsSync(r)&&$(r)})}function $e(){let n=s.join(a,"package.json"),t=S(n);t.name=g,m.includes("publish")||(delete t.author,delete t.publishConfig,delete t.repository,delete t.scripts.prepublishOnly,delete t.devDependencies.np),V&&(m.includes("electron")||(v(t,"electron"),t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",electron","")),m.includes("vite")||m.includes("tsup")&&v(t,"vite"),m.includes("tsup")?(t.scripts.dev="tsup --watch",t.scripts.build="tsup",b("vite.config.ts")):(t.scripts.dev="vite",t.scripts.build="vite build",v(t,"tsup"),b("tsup.config.ts"))),h(n,t);let r=ue(n);Object.keys(M).forEach(o=>{r=r.replace(new RegExp("{{"+o+"}}","g"),M[o])}),l.writeFileSync(n,r)}function Oe(n,t){let r=n.lastIndexOf("."),o=n.substring(0,r)+"."+t+n.substring(r),f=s.join(a,n),d=s.join(a,o);l.existsSync(d)&&(m.includes(t)?($(f),Ie(d,f)):$(d))}function Fe(...n){n.forEach(t=>{Be.forEach(r=>{Oe(t,r)})})}function Ce(){let n=s.join(a,"package.json"),t=S(n);if(m.includes("test")){m.includes("electron")?(t.scripts.test="jest",v(t,"vitest"),h(n,t),b("test/simple.test.ts")):(t.scripts.test="vitest",v(t,"jest"),h(n,t),b("test/electron.test.ts"),b("jest.config.cjs"));return}delete t.scripts.test,t.scripts["lint:eslint"]=t.scripts["lint:eslint"].replace(",test",""),v(t,"jest","vitest"),h(n,t),b("jest.config.cjs","test")}function De(){if(!m.includes("examples")){let r=S(s.join(a,"package.json"));r.scripts.lint=r.scripts.lint.replace(" lint:stylelint",""),r.scripts["lint:eslint"]=r.scripts["lint:eslint"].replace(",examples",""),delete r.scripts["lint:stylelint"],v(r,"stylelint"),h(s.join(a,"package.json"),r);return}let n=s.join(a,"examples");l.mkdirSync(n);let t=m.includes("electron");["vue","react"].forEach(r=>{let o=I(t?`electron-${r}`:r),f=s.join(n,r);if(!l.existsSync(o)){console.log(`${We(o)} template is not exist`);return}l.cpSync(o,f,{recursive:!0});let d=S(s.join(f,"package.json"));Object.keys(d.scripts).forEach(x=>{(x.startsWith("lint")||["prepare"].includes(x))&&delete d.scripts[x]}),v(d,"eslint","prettier","stylelint","commitlint","husky","lint-staged","tsconfig","lint-staged","npm-run-all"),h(s.join(f,"package.json"),d),["_lintstagedrc.cjs"].forEach(x=>{let oe=s.join(f,x);l.existsSync(oe)&&l.rmSync(oe,{recursive:!0})})}),l.writeFileSync(s.join(a,"pnpm-workspace.yaml"),`packages:
|
|
9
8
|
- 'examples/*'`,{encoding:"utf-8"})}}Z().then(async()=>He().catch(e=>{e.message&&console.error(e)})).catch(e=>{e.message&&console.error(e)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "create tomjs web app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tomjs",
|
|
@@ -50,26 +50,26 @@
|
|
|
50
50
|
"shelljs": "^0.8.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@tomjs/commitlint": "^
|
|
55
|
-
"@tomjs/eslint": "^
|
|
53
|
+
"@commitlint/cli": "^19.2.0",
|
|
54
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
55
|
+
"@tomjs/eslint": "^2.0.1",
|
|
56
56
|
"@tomjs/prettier": "^1.3.0",
|
|
57
57
|
"@tomjs/stylelint": "^2.3.0",
|
|
58
58
|
"@tomjs/tsconfig": "^1.4.0",
|
|
59
59
|
"@types/lodash-es": "^4.17.12",
|
|
60
60
|
"@types/minimist": "^1.2.5",
|
|
61
|
-
"@types/node": "^18.19.
|
|
61
|
+
"@types/node": "^18.19.24",
|
|
62
62
|
"@types/prompts": "^2.4.9",
|
|
63
63
|
"@types/shelljs": "^0.8.15",
|
|
64
64
|
"cross-env": "^7.0.3",
|
|
65
65
|
"eslint": "^8.57.0",
|
|
66
66
|
"husky": "^9.0.11",
|
|
67
67
|
"lint-staged": "^15.2.2",
|
|
68
|
-
"np": "^
|
|
68
|
+
"np": "^10.0.1",
|
|
69
69
|
"npm-run-all": "^4.1.5",
|
|
70
70
|
"prettier": "^3.2.5",
|
|
71
71
|
"stylelint": "^16.2.1",
|
|
72
|
-
"tsup": "^8.0.
|
|
72
|
+
"tsup": "^8.0.2",
|
|
73
73
|
"typescript": "~5.3.3"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"prepare": "husky"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tomjs/electron-devtools-installer": "^2.1.
|
|
23
|
+
"@tomjs/electron-devtools-installer": "^2.1.1",
|
|
24
24
|
"react": "^18.2.0",
|
|
25
25
|
"react-dom": "^18.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@commitlint/cli": "^
|
|
29
|
-
"@tomjs/commitlint": "^
|
|
30
|
-
"@tomjs/eslint": "^
|
|
28
|
+
"@commitlint/cli": "^19.2.0",
|
|
29
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
30
|
+
"@tomjs/eslint": "^2.0.1",
|
|
31
31
|
"@tomjs/prettier": "^1.3.0",
|
|
32
32
|
"@tomjs/stylelint": "^2.3.0",
|
|
33
33
|
"@tomjs/tsconfig": "^1.4.0",
|
|
34
34
|
"@tomjs/vite-plugin-electron": "^1.9.0",
|
|
35
|
-
"@types/node": "^18.19.
|
|
36
|
-
"@types/react": "^18.2.
|
|
37
|
-
"@types/react-dom": "^18.2.
|
|
35
|
+
"@types/node": "^18.19.24",
|
|
36
|
+
"@types/react": "^18.2.66",
|
|
37
|
+
"@types/react-dom": "^18.2.22",
|
|
38
38
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"electron": "^28.2.
|
|
41
|
-
"electron-builder": "^24.
|
|
40
|
+
"electron": "^28.2.7",
|
|
41
|
+
"electron-builder": "^24.13.3",
|
|
42
42
|
"eslint": "^8.57.0",
|
|
43
43
|
"husky": "^9.0.11",
|
|
44
44
|
"lint-staged": "^15.2.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"stylelint": "^16.2.1",
|
|
49
49
|
"tsx": "^4.7.1",
|
|
50
50
|
"typescript": "~5.3.3",
|
|
51
|
-
"vite": "^5.1.
|
|
51
|
+
"vite": "^5.1.6",
|
|
52
52
|
"vite-plugin-electron-renderer": "^0.14.5"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"prepare": "husky"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tomjs/electron-devtools-installer": "^2.1.
|
|
24
|
-
"vue": "
|
|
23
|
+
"@tomjs/electron-devtools-installer": "^2.1.1",
|
|
24
|
+
"vue": "^3.4.21"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@commitlint/cli": "^
|
|
28
|
-
"@tomjs/commitlint": "^
|
|
29
|
-
"@tomjs/eslint": "^
|
|
27
|
+
"@commitlint/cli": "^19.2.0",
|
|
28
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
29
|
+
"@tomjs/eslint": "^2.0.1",
|
|
30
30
|
"@tomjs/prettier": "^1.3.0",
|
|
31
31
|
"@tomjs/stylelint": "^2.3.0",
|
|
32
32
|
"@tomjs/tsconfig": "^1.4.0",
|
|
33
33
|
"@tomjs/vite-plugin-electron": "^1.9.0",
|
|
34
|
-
"@types/node": "^18.19.
|
|
34
|
+
"@types/node": "^18.19.24",
|
|
35
35
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
|
-
"electron": "^28.2.
|
|
38
|
-
"electron-builder": "^24.
|
|
37
|
+
"electron": "^28.2.7",
|
|
38
|
+
"electron-builder": "^24.13.3",
|
|
39
39
|
"eslint": "^8.57.0",
|
|
40
40
|
"husky": "^9.0.11",
|
|
41
41
|
"lint-staged": "^15.2.2",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"stylelint": "^16.2.1",
|
|
46
46
|
"tsx": "^4.7.1",
|
|
47
47
|
"typescript": "~5.3.3",
|
|
48
|
-
"vite": "^5.1.
|
|
48
|
+
"vite": "^5.1.6",
|
|
49
49
|
"vite-plugin-electron-renderer": "^0.14.5",
|
|
50
|
-
"vue-tsc": "^
|
|
50
|
+
"vue-tsc": "^2.0.6"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -44,40 +44,40 @@
|
|
|
44
44
|
"lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
|
|
45
45
|
"lint:prettier": "prettier --write .",
|
|
46
46
|
"prepare": "husky",
|
|
47
|
-
"prepublishOnly": "npm run build && np --any-branch --
|
|
47
|
+
"prepublishOnly": "npm run build && np --any-branch --yolo --no-publish --message \"chore: release v%s\""
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"kolorist": "^1.8.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
53
|
+
"@commitlint/cli": "^19.2.0",
|
|
54
54
|
"@jest/globals": "^29.7.0",
|
|
55
55
|
"@kayahr/jest-electron-runner": "^29.11.0",
|
|
56
|
-
"@tomjs/commitlint": "^
|
|
57
|
-
"@tomjs/eslint": "^
|
|
56
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
57
|
+
"@tomjs/eslint": "^2.0.1",
|
|
58
58
|
"@tomjs/prettier": "^1.3.0",
|
|
59
59
|
"@tomjs/stylelint": "^2.3.0",
|
|
60
60
|
"@tomjs/tsconfig": "^1.4.0",
|
|
61
61
|
"@types/jest": "^29.5.12",
|
|
62
|
-
"@types/node": "^18.19.
|
|
62
|
+
"@types/node": "^18.19.24",
|
|
63
63
|
"cross-env": "^7.0.3",
|
|
64
|
-
"electron": "^28.2.
|
|
64
|
+
"electron": "^28.2.7",
|
|
65
65
|
"eslint": "^8.57.0",
|
|
66
66
|
"husky": "^9.0.11",
|
|
67
67
|
"jest": "^29.7.0",
|
|
68
68
|
"lint-staged": "^15.2.2",
|
|
69
|
-
"np": "^
|
|
69
|
+
"np": "^10.0.1",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"prettier": "^3.2.5",
|
|
72
72
|
"rimraf": "^5.0.5",
|
|
73
73
|
"stylelint": "^16.2.1",
|
|
74
74
|
"ts-jest": "^29.1.2",
|
|
75
|
-
"tsup": "^8.0.
|
|
75
|
+
"tsup": "^8.0.2",
|
|
76
76
|
"tsx": "^4.7.1",
|
|
77
77
|
"typescript": "~5.3.3",
|
|
78
|
-
"vite": "^5.1.
|
|
79
|
-
"vite-plugin-dts": "^3.7.
|
|
80
|
-
"vitest": "^1.
|
|
78
|
+
"vite": "^5.1.6",
|
|
79
|
+
"vite-plugin-dts": "^3.7.3",
|
|
80
|
+
"vitest": "^1.3.1"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"vite": ">=2.0.0"
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"react-dom": "^18.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@commitlint/cli": "^
|
|
25
|
-
"@tomjs/commitlint": "^
|
|
26
|
-
"@tomjs/eslint": "^
|
|
24
|
+
"@commitlint/cli": "^19.2.0",
|
|
25
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
26
|
+
"@tomjs/eslint": "^2.0.1",
|
|
27
27
|
"@tomjs/prettier": "^1.3.0",
|
|
28
28
|
"@tomjs/stylelint": "^2.3.0",
|
|
29
29
|
"@tomjs/tsconfig": "^1.4.0",
|
|
30
|
-
"@types/node": "^18.19.
|
|
31
|
-
"@types/react": "^18.2.
|
|
32
|
-
"@types/react-dom": "^18.2.
|
|
30
|
+
"@types/node": "^18.19.24",
|
|
31
|
+
"@types/react": "^18.2.66",
|
|
32
|
+
"@types/react-dom": "^18.2.22",
|
|
33
33
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
34
34
|
"cross-env": "^7.0.3",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"prettier": "^3.2.5",
|
|
40
40
|
"stylelint": "^16.2.1",
|
|
41
41
|
"typescript": "~5.3.3",
|
|
42
|
-
"vite": "^5.1.
|
|
42
|
+
"vite": "^5.1.6"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"categories": [
|
|
17
17
|
"Other"
|
|
18
18
|
],
|
|
19
|
-
"activationEvents": [
|
|
20
|
-
"onCommand:hello-world.showHelloWorld"
|
|
21
|
-
],
|
|
19
|
+
"activationEvents": [],
|
|
22
20
|
"contributes": {
|
|
23
21
|
"commands": [
|
|
24
22
|
{
|
|
@@ -49,12 +47,12 @@
|
|
|
49
47
|
"prepare": "husky"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "^
|
|
53
|
-
"@tomjs/commitlint": "^
|
|
54
|
-
"@tomjs/eslint": "^
|
|
50
|
+
"@commitlint/cli": "^19.2.0",
|
|
51
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
52
|
+
"@tomjs/eslint": "^2.0.1",
|
|
55
53
|
"@tomjs/prettier": "^1.3.0",
|
|
56
54
|
"@tomjs/tsconfig": "^1.4.0",
|
|
57
|
-
"@types/node": "^18.19.
|
|
55
|
+
"@types/node": "^18.19.24",
|
|
58
56
|
"@types/vscode": "^1.75.0",
|
|
59
57
|
"eslint": "^8.57.0",
|
|
60
58
|
"husky": "^9.0.11",
|
|
@@ -62,7 +60,7 @@
|
|
|
62
60
|
"npm-run-all": "^4.1.5",
|
|
63
61
|
"prettier": "^3.2.5",
|
|
64
62
|
"rimraf": "^5.0.5",
|
|
65
|
-
"tsup": "^8.0.
|
|
63
|
+
"tsup": "^8.0.2",
|
|
66
64
|
"typescript": "~5.3.3"
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { commands, window } from 'vscode';
|
|
2
3
|
|
|
3
4
|
export function activate(context: ExtensionContext) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Add command to the extension context
|
|
10
|
-
context.subscriptions.push(showHelloWorldCommand);
|
|
5
|
+
context.subscriptions.push(
|
|
6
|
+
commands.registerCommand('hello-world.showHelloWorld', async () => {
|
|
7
|
+
window.showInformationMessage('Hello World');
|
|
8
|
+
}),
|
|
9
|
+
);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export function deactivate() {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-vscode/env" />
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { commands } from 'vscode';
|
|
3
|
+
import { MainPanel } from './views/panel';
|
|
3
4
|
|
|
4
5
|
export function activate(context: ExtensionContext) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Add command to the extension context
|
|
11
|
-
context.subscriptions.push(showHelloWorldCommand);
|
|
6
|
+
context.subscriptions.push(
|
|
7
|
+
commands.registerCommand('hello-world.showHelloWorld', async () => {
|
|
8
|
+
MainPanel.render(context.extensionUri);
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function deactivate() {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, Webview } from 'vscode';
|
|
2
|
+
import { window } from 'vscode';
|
|
3
|
+
|
|
4
|
+
export class WebviewHelper {
|
|
5
|
+
public static setupHtml(webview: Webview, context: ExtensionContext) {
|
|
6
|
+
return process.env.VITE_DEV_SERVER_URL
|
|
7
|
+
? __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL)
|
|
8
|
+
: __getWebviewHtml__(webview, context);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
|
|
12
|
+
webview.onDidReceiveMessage(
|
|
13
|
+
(message: any) => {
|
|
14
|
+
const command = message.command;
|
|
15
|
+
const text = message.text;
|
|
16
|
+
console.log(`command: ${command}`);
|
|
17
|
+
switch (command) {
|
|
18
|
+
case 'hello':
|
|
19
|
+
window.showInformationMessage(text);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
undefined,
|
|
24
|
+
disposables,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
|
|
2
|
+
import { ViewColumn, window } from 'vscode';
|
|
3
|
+
import { WebviewHelper } from './helper';
|
|
4
|
+
|
|
5
|
+
export class MainPanel {
|
|
6
|
+
public static currentPanel: MainPanel | undefined;
|
|
7
|
+
private readonly _panel: WebviewPanel;
|
|
8
|
+
private _disposables: Disposable[] = [];
|
|
9
|
+
|
|
10
|
+
private constructor(panel: WebviewPanel, context: ExtensionContext) {
|
|
11
|
+
this._panel = panel;
|
|
12
|
+
|
|
13
|
+
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
14
|
+
this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
|
|
15
|
+
|
|
16
|
+
WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static render(context: ExtensionContext) {
|
|
20
|
+
if (MainPanel.currentPanel) {
|
|
21
|
+
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
22
|
+
} else {
|
|
23
|
+
const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
|
|
24
|
+
enableScripts: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
MainPanel.currentPanel = new MainPanel(panel, context);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
33
|
+
*/
|
|
34
|
+
public dispose() {
|
|
35
|
+
MainPanel.currentPanel = undefined;
|
|
36
|
+
|
|
37
|
+
// Dispose of the current webview panel
|
|
38
|
+
this._panel.dispose();
|
|
39
|
+
|
|
40
|
+
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
41
|
+
while (this._disposables.length) {
|
|
42
|
+
const disposable = this._disposables.pop();
|
|
43
|
+
if (disposable) {
|
|
44
|
+
disposable.dispose();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"categories": [
|
|
17
17
|
"Other"
|
|
18
18
|
],
|
|
19
|
-
"activationEvents": [
|
|
20
|
-
"onCommand:hello-world.showHelloWorld"
|
|
21
|
-
],
|
|
19
|
+
"activationEvents": [],
|
|
22
20
|
"contributes": {
|
|
23
21
|
"commands": [
|
|
24
22
|
{
|
|
@@ -56,17 +54,16 @@
|
|
|
56
54
|
"react-dom": "^18.2.0"
|
|
57
55
|
},
|
|
58
56
|
"devDependencies": {
|
|
59
|
-
"@commitlint/cli": "^
|
|
60
|
-
"@tomjs/commitlint": "^
|
|
61
|
-
"@tomjs/eslint": "^
|
|
57
|
+
"@commitlint/cli": "^19.2.0",
|
|
58
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
59
|
+
"@tomjs/eslint": "^2.0.1",
|
|
62
60
|
"@tomjs/prettier": "^1.3.0",
|
|
63
61
|
"@tomjs/stylelint": "^2.3.0",
|
|
64
62
|
"@tomjs/tsconfig": "^1.4.0",
|
|
65
|
-
"@tomjs/vite-plugin-vscode": "^2.
|
|
66
|
-
"@
|
|
67
|
-
"@types/
|
|
68
|
-
"@types/react": "^18.2.
|
|
69
|
-
"@types/react-dom": "^18.2.18",
|
|
63
|
+
"@tomjs/vite-plugin-vscode": "^2.2.0",
|
|
64
|
+
"@types/node": "^18.19.24",
|
|
65
|
+
"@types/react": "^18.2.66",
|
|
66
|
+
"@types/react-dom": "^18.2.22",
|
|
70
67
|
"@types/vscode": "^1.75.0",
|
|
71
68
|
"@types/vscode-webview": "^1.57.5",
|
|
72
69
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
@@ -80,6 +77,6 @@
|
|
|
80
77
|
"stylelint": "^16.2.1",
|
|
81
78
|
"tsx": "^4.7.1",
|
|
82
79
|
"typescript": "~5.3.3",
|
|
83
|
-
"vite": "^5.1.
|
|
80
|
+
"vite": "^5.1.6"
|
|
84
81
|
}
|
|
85
82
|
}
|
|
@@ -13,7 +13,6 @@ class VSCodeAPIWrapper {
|
|
|
13
13
|
private readonly vsCodeApi: WebviewApi<unknown> | undefined;
|
|
14
14
|
|
|
15
15
|
constructor() {
|
|
16
|
-
console.log(typeof acquireVsCodeApi);
|
|
17
16
|
// Check if the acquireVsCodeApi function exists in the current development
|
|
18
17
|
// context (i.e. VS Code development window or web browser)
|
|
19
18
|
if (typeof acquireVsCodeApi === 'function') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/vite-plugin-vscode/env" />
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExtensionContext } from 'vscode';
|
|
2
|
+
import { commands } from 'vscode';
|
|
3
|
+
import { MainPanel } from './views/panel';
|
|
3
4
|
|
|
4
5
|
export function activate(context: ExtensionContext) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Add command to the extension context
|
|
11
|
-
context.subscriptions.push(showHelloWorldCommand);
|
|
6
|
+
context.subscriptions.push(
|
|
7
|
+
commands.registerCommand('hello-world.showHelloWorld', async () => {
|
|
8
|
+
MainPanel.render(context.extensionUri);
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function deactivate() {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, Webview } from 'vscode';
|
|
2
|
+
import { window } from 'vscode';
|
|
3
|
+
|
|
4
|
+
export class WebviewHelper {
|
|
5
|
+
public static setupHtml(webview: Webview, context: ExtensionContext) {
|
|
6
|
+
return process.env.VITE_DEV_SERVER_URL
|
|
7
|
+
? __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL)
|
|
8
|
+
: __getWebviewHtml__(webview, context);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
|
|
12
|
+
webview.onDidReceiveMessage(
|
|
13
|
+
(message: any) => {
|
|
14
|
+
const command = message.command;
|
|
15
|
+
const text = message.text;
|
|
16
|
+
console.log(`command: ${command}`);
|
|
17
|
+
switch (command) {
|
|
18
|
+
case 'hello':
|
|
19
|
+
window.showInformationMessage(text);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
undefined,
|
|
24
|
+
disposables,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
|
|
2
|
+
import { ViewColumn, window } from 'vscode';
|
|
3
|
+
import { WebviewHelper } from './helper';
|
|
4
|
+
|
|
5
|
+
export class MainPanel {
|
|
6
|
+
public static currentPanel: MainPanel | undefined;
|
|
7
|
+
private readonly _panel: WebviewPanel;
|
|
8
|
+
private _disposables: Disposable[] = [];
|
|
9
|
+
|
|
10
|
+
private constructor(panel: WebviewPanel, context: ExtensionContext) {
|
|
11
|
+
this._panel = panel;
|
|
12
|
+
|
|
13
|
+
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
14
|
+
this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
|
|
15
|
+
|
|
16
|
+
WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static render(context: ExtensionContext) {
|
|
20
|
+
if (MainPanel.currentPanel) {
|
|
21
|
+
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
22
|
+
} else {
|
|
23
|
+
const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
|
|
24
|
+
enableScripts: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
MainPanel.currentPanel = new MainPanel(panel, context);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
33
|
+
*/
|
|
34
|
+
public dispose() {
|
|
35
|
+
MainPanel.currentPanel = undefined;
|
|
36
|
+
|
|
37
|
+
// Dispose of the current webview panel
|
|
38
|
+
this._panel.dispose();
|
|
39
|
+
|
|
40
|
+
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
41
|
+
while (this._disposables.length) {
|
|
42
|
+
const disposable = this._disposables.pop();
|
|
43
|
+
if (disposable) {
|
|
44
|
+
disposable.dispose();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"categories": [
|
|
17
17
|
"Other"
|
|
18
18
|
],
|
|
19
|
-
"activationEvents": [
|
|
20
|
-
"onCommand:hello-world.showHelloWorld"
|
|
21
|
-
],
|
|
19
|
+
"activationEvents": [],
|
|
22
20
|
"contributes": {
|
|
23
21
|
"commands": [
|
|
24
22
|
{
|
|
@@ -52,18 +50,17 @@
|
|
|
52
50
|
},
|
|
53
51
|
"dependencies": {
|
|
54
52
|
"@vscode/webview-ui-toolkit": "^1.4.0",
|
|
55
|
-
"vue": "
|
|
53
|
+
"vue": "^3.4.21"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
|
-
"@commitlint/cli": "^
|
|
59
|
-
"@tomjs/commitlint": "^
|
|
60
|
-
"@tomjs/eslint": "^
|
|
56
|
+
"@commitlint/cli": "^19.2.0",
|
|
57
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
58
|
+
"@tomjs/eslint": "^2.0.1",
|
|
61
59
|
"@tomjs/prettier": "^1.3.0",
|
|
62
60
|
"@tomjs/stylelint": "^2.3.0",
|
|
63
61
|
"@tomjs/tsconfig": "^1.4.0",
|
|
64
|
-
"@tomjs/vite-plugin-vscode": "^2.
|
|
65
|
-
"@
|
|
66
|
-
"@types/node": "^18.19.19",
|
|
62
|
+
"@tomjs/vite-plugin-vscode": "^2.2.0",
|
|
63
|
+
"@types/node": "^18.19.24",
|
|
67
64
|
"@types/vscode": "^1.75.0",
|
|
68
65
|
"@types/vscode-webview": "^1.57.5",
|
|
69
66
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
@@ -77,7 +74,7 @@
|
|
|
77
74
|
"stylelint": "^16.2.1",
|
|
78
75
|
"tsx": "^4.7.1",
|
|
79
76
|
"typescript": "~5.3.3",
|
|
80
|
-
"vite": "^5.1.
|
|
81
|
-
"vue-tsc": "^
|
|
77
|
+
"vite": "^5.1.6",
|
|
78
|
+
"vue-tsc": "^2.0.6"
|
|
82
79
|
}
|
|
83
80
|
}
|
|
@@ -13,7 +13,6 @@ class VSCodeAPIWrapper {
|
|
|
13
13
|
private readonly vsCodeApi: WebviewApi<unknown> | undefined;
|
|
14
14
|
|
|
15
15
|
constructor() {
|
|
16
|
-
console.log(typeof acquireVsCodeApi);
|
|
17
16
|
// Check if the acquireVsCodeApi function exists in the current development
|
|
18
17
|
// context (i.e. VS Code development window or web browser)
|
|
19
18
|
if (typeof acquireVsCodeApi === 'function') {
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"prepare": "husky"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"vue": "
|
|
20
|
+
"vue": "^3.4.21"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@commitlint/cli": "^
|
|
24
|
-
"@tomjs/commitlint": "^
|
|
25
|
-
"@tomjs/eslint": "^
|
|
23
|
+
"@commitlint/cli": "^19.2.0",
|
|
24
|
+
"@tomjs/commitlint": "^3.0.0",
|
|
25
|
+
"@tomjs/eslint": "^2.0.1",
|
|
26
26
|
"@tomjs/prettier": "^1.3.0",
|
|
27
27
|
"@tomjs/stylelint": "^2.3.0",
|
|
28
28
|
"@tomjs/tsconfig": "^1.4.0",
|
|
29
|
-
"@types/node": "^18.19.
|
|
29
|
+
"@types/node": "^18.19.24",
|
|
30
30
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
31
31
|
"cross-env": "^7.0.3",
|
|
32
32
|
"eslint": "^8.57.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prettier": "^3.2.5",
|
|
37
37
|
"stylelint": "^16.2.1",
|
|
38
38
|
"typescript": "~5.3.3",
|
|
39
|
-
"vite": "^5.1.
|
|
40
|
-
"vue-tsc": "^
|
|
39
|
+
"vite": "^5.1.6",
|
|
40
|
+
"vue-tsc": "^2.0.6"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { Disposable, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode';
|
|
2
|
-
|
|
3
|
-
function uuid() {
|
|
4
|
-
let text = '';
|
|
5
|
-
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
6
|
-
for (let i = 0; i < 32; i++) {
|
|
7
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
8
|
-
}
|
|
9
|
-
return text;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
|
|
13
|
-
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* This class manages the state and behavior of Main webview panels.
|
|
18
|
-
*
|
|
19
|
-
* It contains all the data and methods for:
|
|
20
|
-
*
|
|
21
|
-
* - Creating and rendering Main webview panels
|
|
22
|
-
* - Properly cleaning up and disposing of webview resources when the panel is closed
|
|
23
|
-
* - Setting the HTML (and by proxy CSS/JavaScript) content of the webview panel
|
|
24
|
-
* - Setting message listeners so data can be passed between the webview and extension
|
|
25
|
-
*/
|
|
26
|
-
export class MainPanel {
|
|
27
|
-
public static currentPanel: MainPanel | undefined;
|
|
28
|
-
private readonly _panel: WebviewPanel;
|
|
29
|
-
private _disposables: Disposable[] = [];
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The MainPanel class private constructor (called only from the render method).
|
|
33
|
-
*
|
|
34
|
-
* @param panel A reference to the webview panel
|
|
35
|
-
* @param extensionUri The URI of the directory containing the extension
|
|
36
|
-
*/
|
|
37
|
-
private constructor(panel: WebviewPanel, extensionUri: Uri) {
|
|
38
|
-
this._panel = panel;
|
|
39
|
-
|
|
40
|
-
// Set an event listener to listen for when the panel is disposed (i.e. when the user closes
|
|
41
|
-
// the panel or when the panel is closed programmatically)
|
|
42
|
-
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
43
|
-
|
|
44
|
-
// Set the HTML content for the webview panel
|
|
45
|
-
this._panel.webview.html = this._getWebviewContent(this._panel.webview, extensionUri);
|
|
46
|
-
|
|
47
|
-
// Set an event listener to listen for messages passed from the webview context
|
|
48
|
-
this._setWebviewMessageListener(this._panel.webview);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Renders the current webview panel if it exists otherwise a new webview panel
|
|
53
|
-
* will be created and displayed.
|
|
54
|
-
*
|
|
55
|
-
* @param extensionUri The URI of the directory containing the extension.
|
|
56
|
-
*/
|
|
57
|
-
public static render(extensionUri: Uri) {
|
|
58
|
-
if (MainPanel.currentPanel) {
|
|
59
|
-
// If the webview panel already exists reveal it
|
|
60
|
-
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
61
|
-
} else {
|
|
62
|
-
// If a webview panel does not already exist create and show a new one
|
|
63
|
-
const panel = window.createWebviewPanel(
|
|
64
|
-
// Panel view type
|
|
65
|
-
'showHelloWorld',
|
|
66
|
-
// Panel title
|
|
67
|
-
'Hello World',
|
|
68
|
-
// The editor column the panel should be displayed in
|
|
69
|
-
ViewColumn.One,
|
|
70
|
-
// Extra panel configurations
|
|
71
|
-
{
|
|
72
|
-
// Enable JavaScript in the webview
|
|
73
|
-
enableScripts: true,
|
|
74
|
-
// Restrict the webview to only load resources from the `dist/webview` directories
|
|
75
|
-
localResourceRoots: [Uri.joinPath(extensionUri, 'dist/webview')],
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
MainPanel.currentPanel = new MainPanel(panel, extensionUri);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
85
|
-
*/
|
|
86
|
-
public dispose() {
|
|
87
|
-
MainPanel.currentPanel = undefined;
|
|
88
|
-
|
|
89
|
-
// Dispose of the current webview panel
|
|
90
|
-
this._panel.dispose();
|
|
91
|
-
|
|
92
|
-
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
93
|
-
while (this._disposables.length) {
|
|
94
|
-
const disposable = this._disposables.pop();
|
|
95
|
-
if (disposable) {
|
|
96
|
-
disposable.dispose();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Defines and returns the HTML that should be rendered within the webview panel.
|
|
103
|
-
*
|
|
104
|
-
* @remarks This is also the place where references to the Vue webview build files
|
|
105
|
-
* are created and inserted into the webview HTML.
|
|
106
|
-
*
|
|
107
|
-
* @param webview A reference to the extension webview
|
|
108
|
-
* @param extensionUri The URI of the directory containing the extension
|
|
109
|
-
* @returns A template string literal containing the HTML that should be
|
|
110
|
-
* rendered within the webview panel
|
|
111
|
-
*/
|
|
112
|
-
private _getWebviewContent(webview: Webview, extensionUri: Uri) {
|
|
113
|
-
// The file from the vite build output
|
|
114
|
-
const stylesUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.css']);
|
|
115
|
-
const scriptUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.js']);
|
|
116
|
-
|
|
117
|
-
const nonce = uuid();
|
|
118
|
-
|
|
119
|
-
if (process.env.VITE_DEV_SERVER_URL) {
|
|
120
|
-
return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return /*html*/ `
|
|
124
|
-
<!doctype html>
|
|
125
|
-
<html lang="en">
|
|
126
|
-
<head>
|
|
127
|
-
<meta charset="UTF-8" />
|
|
128
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
129
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
|
130
|
-
<script type="module" crossorigin nonce="${nonce}" src="${scriptUri}"></script>
|
|
131
|
-
<link rel="stylesheet" crossorigin href="${stylesUri}">
|
|
132
|
-
<title>Hello World</title>
|
|
133
|
-
</head>
|
|
134
|
-
<body>
|
|
135
|
-
<div id="app"></div>
|
|
136
|
-
</body>
|
|
137
|
-
</html>
|
|
138
|
-
`;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Sets up an event listener to listen for messages passed from the webview context and
|
|
143
|
-
* executes code based on the message that is recieved.
|
|
144
|
-
*
|
|
145
|
-
* @param webview A reference to the extension webview
|
|
146
|
-
* @param context A reference to the extension context
|
|
147
|
-
*/
|
|
148
|
-
private _setWebviewMessageListener(webview: Webview) {
|
|
149
|
-
webview.onDidReceiveMessage(
|
|
150
|
-
(message: any) => {
|
|
151
|
-
const command = message.command;
|
|
152
|
-
const text = message.text;
|
|
153
|
-
console.log(`command: ${command}`);
|
|
154
|
-
|
|
155
|
-
switch (command) {
|
|
156
|
-
case 'hello':
|
|
157
|
-
// Code that should run in response to the hello message command
|
|
158
|
-
window.showInformationMessage(text);
|
|
159
|
-
return;
|
|
160
|
-
// Add more switch case statements here as more webview message commands
|
|
161
|
-
// are created within the webview context (i.e. inside media/main.js)
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
undefined,
|
|
165
|
-
this._disposables,
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { Disposable, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode';
|
|
2
|
-
|
|
3
|
-
function uuid() {
|
|
4
|
-
let text = '';
|
|
5
|
-
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
6
|
-
for (let i = 0; i < 32; i++) {
|
|
7
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
8
|
-
}
|
|
9
|
-
return text;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
|
|
13
|
-
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* This class manages the state and behavior of Main webview panels.
|
|
18
|
-
*
|
|
19
|
-
* It contains all the data and methods for:
|
|
20
|
-
*
|
|
21
|
-
* - Creating and rendering Main webview panels
|
|
22
|
-
* - Properly cleaning up and disposing of webview resources when the panel is closed
|
|
23
|
-
* - Setting the HTML (and by proxy CSS/JavaScript) content of the webview panel
|
|
24
|
-
* - Setting message listeners so data can be passed between the webview and extension
|
|
25
|
-
*/
|
|
26
|
-
export class MainPanel {
|
|
27
|
-
public static currentPanel: MainPanel | undefined;
|
|
28
|
-
private readonly _panel: WebviewPanel;
|
|
29
|
-
private _disposables: Disposable[] = [];
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The MainPanel class private constructor (called only from the render method).
|
|
33
|
-
*
|
|
34
|
-
* @param panel A reference to the webview panel
|
|
35
|
-
* @param extensionUri The URI of the directory containing the extension
|
|
36
|
-
*/
|
|
37
|
-
private constructor(panel: WebviewPanel, extensionUri: Uri) {
|
|
38
|
-
this._panel = panel;
|
|
39
|
-
|
|
40
|
-
// Set an event listener to listen for when the panel is disposed (i.e. when the user closes
|
|
41
|
-
// the panel or when the panel is closed programmatically)
|
|
42
|
-
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
|
43
|
-
|
|
44
|
-
// Set the HTML content for the webview panel
|
|
45
|
-
this._panel.webview.html = this._getWebviewContent(this._panel.webview, extensionUri);
|
|
46
|
-
|
|
47
|
-
// Set an event listener to listen for messages passed from the webview context
|
|
48
|
-
this._setWebviewMessageListener(this._panel.webview);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Renders the current webview panel if it exists otherwise a new webview panel
|
|
53
|
-
* will be created and displayed.
|
|
54
|
-
*
|
|
55
|
-
* @param extensionUri The URI of the directory containing the extension.
|
|
56
|
-
*/
|
|
57
|
-
public static render(extensionUri: Uri) {
|
|
58
|
-
if (MainPanel.currentPanel) {
|
|
59
|
-
// If the webview panel already exists reveal it
|
|
60
|
-
MainPanel.currentPanel._panel.reveal(ViewColumn.One);
|
|
61
|
-
} else {
|
|
62
|
-
// If a webview panel does not already exist create and show a new one
|
|
63
|
-
const panel = window.createWebviewPanel(
|
|
64
|
-
// Panel view type
|
|
65
|
-
'showHelloWorld',
|
|
66
|
-
// Panel title
|
|
67
|
-
'Hello World',
|
|
68
|
-
// The editor column the panel should be displayed in
|
|
69
|
-
ViewColumn.One,
|
|
70
|
-
// Extra panel configurations
|
|
71
|
-
{
|
|
72
|
-
// Enable JavaScript in the webview
|
|
73
|
-
enableScripts: true,
|
|
74
|
-
// Restrict the webview to only load resources from the `dist/webview` directories
|
|
75
|
-
localResourceRoots: [Uri.joinPath(extensionUri, 'dist/webview')],
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
MainPanel.currentPanel = new MainPanel(panel, extensionUri);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Cleans up and disposes of webview resources when the webview panel is closed.
|
|
85
|
-
*/
|
|
86
|
-
public dispose() {
|
|
87
|
-
MainPanel.currentPanel = undefined;
|
|
88
|
-
|
|
89
|
-
// Dispose of the current webview panel
|
|
90
|
-
this._panel.dispose();
|
|
91
|
-
|
|
92
|
-
// Dispose of all disposables (i.e. commands) for the current webview panel
|
|
93
|
-
while (this._disposables.length) {
|
|
94
|
-
const disposable = this._disposables.pop();
|
|
95
|
-
if (disposable) {
|
|
96
|
-
disposable.dispose();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Defines and returns the HTML that should be rendered within the webview panel.
|
|
103
|
-
*
|
|
104
|
-
* @remarks This is also the place where references to the Vue webview build files
|
|
105
|
-
* are created and inserted into the webview HTML.
|
|
106
|
-
*
|
|
107
|
-
* @param webview A reference to the extension webview
|
|
108
|
-
* @param extensionUri The URI of the directory containing the extension
|
|
109
|
-
* @returns A template string literal containing the HTML that should be
|
|
110
|
-
* rendered within the webview panel
|
|
111
|
-
*/
|
|
112
|
-
private _getWebviewContent(webview: Webview, extensionUri: Uri) {
|
|
113
|
-
// The file from the vite build output
|
|
114
|
-
const stylesUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.css']);
|
|
115
|
-
const scriptUri = getUri(webview, extensionUri, ['dist', 'webview', 'assets', 'index.js']);
|
|
116
|
-
|
|
117
|
-
const nonce = uuid();
|
|
118
|
-
|
|
119
|
-
if (process.env.VITE_DEV_SERVER_URL) {
|
|
120
|
-
return __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return /*html*/ `
|
|
124
|
-
<!doctype html>
|
|
125
|
-
<html lang="en">
|
|
126
|
-
<head>
|
|
127
|
-
<meta charset="UTF-8" />
|
|
128
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
129
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
|
130
|
-
<script type="module" crossorigin nonce="${nonce}" src="${scriptUri}"></script>
|
|
131
|
-
<link rel="stylesheet" crossorigin href="${stylesUri}">
|
|
132
|
-
<title>Hello World</title>
|
|
133
|
-
</head>
|
|
134
|
-
<body>
|
|
135
|
-
<div id="app"></div>
|
|
136
|
-
</body>
|
|
137
|
-
</html>
|
|
138
|
-
`;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Sets up an event listener to listen for messages passed from the webview context and
|
|
143
|
-
* executes code based on the message that is recieved.
|
|
144
|
-
*
|
|
145
|
-
* @param webview A reference to the extension webview
|
|
146
|
-
* @param context A reference to the extension context
|
|
147
|
-
*/
|
|
148
|
-
private _setWebviewMessageListener(webview: Webview) {
|
|
149
|
-
webview.onDidReceiveMessage(
|
|
150
|
-
(message: any) => {
|
|
151
|
-
const command = message.command;
|
|
152
|
-
const text = message.text;
|
|
153
|
-
console.log(`command: ${command}`);
|
|
154
|
-
|
|
155
|
-
switch (command) {
|
|
156
|
-
case 'hello':
|
|
157
|
-
// Code that should run in response to the hello message command
|
|
158
|
-
window.showInformationMessage(text);
|
|
159
|
-
return;
|
|
160
|
-
// Add more switch case statements here as more webview message commands
|
|
161
|
-
// are created within the webview context (i.e. inside media/main.js)
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
undefined,
|
|
165
|
-
this._disposables,
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|