@tomjs/create-app 5.4.0 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +2 -0
  2. package/README.zh_CN.md +2 -0
  3. package/dist/index.mjs +1 -1
  4. package/package.json +13 -13
  5. package/templates/config/base/package.json +2 -2
  6. package/templates/config/package.json +27 -27
  7. package/templates/config/react/pnpm-workspace.yaml +5 -0
  8. package/templates/config/vscode/_.gitignore +4 -0
  9. package/templates/config/vue/_.gitignore +63 -0
  10. package/templates/config/vue/package.json +1 -1
  11. package/templates/config/vue/pnpm-workspace.yaml +4 -0
  12. package/templates/config/vue/tsconfig.app.json +0 -1
  13. package/templates/config/vue/uno.config.ts +2 -2
  14. package/templates/crx-react/manifest.config.ts +28 -0
  15. package/templates/crx-react/package.json +14 -0
  16. package/templates/crx-react/public/logo.png +0 -0
  17. package/templates/crx-react/src/assets/crx.svg +4 -0
  18. package/templates/crx-react/src/assets/react.svg +1 -0
  19. package/templates/crx-react/src/assets/vite.svg +1 -0
  20. package/templates/crx-react/src/components/HelloWorld.tsx +35 -0
  21. package/templates/crx-react/src/content/main.tsx +14 -0
  22. package/templates/crx-react/src/content/views/App.css +56 -0
  23. package/templates/crx-react/src/content/views/App.tsx +23 -0
  24. package/templates/crx-react/src/popup/App.css +49 -0
  25. package/templates/crx-react/src/popup/App.tsx +22 -0
  26. package/templates/crx-react/src/popup/index.css +84 -0
  27. package/templates/crx-react/src/popup/index.html +10 -0
  28. package/templates/crx-react/src/popup/main.tsx +10 -0
  29. package/templates/crx-react/src/sidepanel/App.css +49 -0
  30. package/templates/crx-react/src/sidepanel/App.tsx +22 -0
  31. package/templates/crx-react/src/sidepanel/index.css +83 -0
  32. package/templates/crx-react/src/sidepanel/index.html +10 -0
  33. package/templates/crx-react/src/sidepanel/main.tsx +10 -0
  34. package/templates/crx-react/vite.config.ts +28 -0
  35. package/templates/crx-vue/README.md +1 -0
  36. package/templates/crx-vue/manifest.config.ts +28 -0
  37. package/templates/crx-vue/package.json +14 -0
  38. package/templates/crx-vue/pnpm-workspace.yaml +4 -0
  39. package/templates/crx-vue/public/logo.png +0 -0
  40. package/templates/crx-vue/src/assets/crx.svg +4 -0
  41. package/templates/crx-vue/src/assets/vite.svg +1 -0
  42. package/templates/crx-vue/src/assets/vue.svg +1 -0
  43. package/templates/crx-vue/src/components/HelloWorld.vue +38 -0
  44. package/templates/crx-vue/src/content/main.ts +17 -0
  45. package/templates/crx-vue/src/content/views/App.vue +76 -0
  46. package/templates/crx-vue/src/env.d.ts +3 -0
  47. package/templates/crx-vue/src/popup/App.vue +39 -0
  48. package/templates/crx-vue/src/popup/index.html +10 -0
  49. package/templates/crx-vue/src/popup/main.ts +5 -0
  50. package/templates/crx-vue/src/popup/style.css +84 -0
  51. package/templates/crx-vue/src/sidepanel/App.vue +39 -0
  52. package/templates/crx-vue/src/sidepanel/index.html +10 -0
  53. package/templates/crx-vue/src/sidepanel/main.ts +5 -0
  54. package/templates/crx-vue/src/sidepanel/style.css +83 -0
  55. package/templates/crx-vue/vite.config.ts +38 -0
  56. package/templates/electron-vue/package.json +1 -1
  57. package/templates/electron-vue/src/components/HelloWorld.vue +0 -1
  58. package/templates/electron-vue/src/main.ts +2 -2
  59. package/templates/electron-vue/tsconfig.app.json +5 -8
  60. package/templates/electron-vue/tsconfig.node.json +1 -1
  61. package/templates/electron-vue/vite.config.ts +5 -2
  62. package/templates/hbuilderx-vue/src/components/HelloWorld.vue +0 -2
  63. package/templates/hbuilderx-vue/src/main.ts +3 -2
  64. package/templates/hbuilderx-vue/tsconfig.app.json +0 -1
  65. package/templates/hbuilderx-vue/vite.config.ts +5 -2
  66. package/templates/vscode-vue/src/App.vue +0 -1
  67. package/templates/vscode-vue/src/main.ts +3 -1
  68. package/templates/vscode-vue/src/style.scss +0 -0
  69. package/templates/vscode-vue/vite.config.ts +5 -2
  70. package/templates/web-vue/README.md +1 -1
  71. package/templates/web-vue/src/components/HelloWorld.vue +0 -2
  72. package/templates/web-vue/src/main.ts +2 -1
  73. package/templates/web-vue/vite.config.ts +5 -2
  74. package/templates/electron-vue/src/vite-env.d.ts +0 -1
  75. /package/templates/config/vue/{env.d.ts → src/env.d.ts} +0 -0
  76. /package/templates/electron-vue/src/{style.css → style.scss} +0 -0
  77. /package/templates/hbuilderx-vue/src/{style.css → style.scss} +0 -0
package/README.md CHANGED
@@ -45,6 +45,8 @@ Options
45
45
 
46
46
  Support templates:
47
47
 
48
+ - crx-react
49
+ - crx-vue
48
50
  - electron-vue
49
51
  - electron-react
50
52
  - hbuilderx-base
package/README.zh_CN.md CHANGED
@@ -45,6 +45,8 @@ Options
45
45
 
46
46
  支持模板:
47
47
 
48
+ - crx-react
49
+ - crx-vue
48
50
  - electron-vue
49
51
  - electron-react
50
52
  - hbuilderx-base
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import e from"meow";import t from"node:fs";import n,{readdir as r}from"node:fs/promises";import i from"node:os";import a from"node:path";import{fileURLToPath as o}from"node:url";import*as s from"@clack/prompts";import{copy as c,mkdir as l,mkdirp as u,readFile as d,readJson as f,readJsonSync as p,rm as m,rmSync as h,writeFile as g,writeJson as _}from"@tomjs/node";import{camelCase as v,merge as y,upperFirst as b}from"lodash-es";import{glob as x}from"tinyglobby";import S from"chalk";import{$ as C}from"execa";import w from"@tomjs/logger";const T=o(new URL(`..`,import.meta.url)),ee=[`vue`,`react`],E=[{name:`node`,display:`Node`,color:S.green,children:[{name:`node-base`,display:`Base`,color:S.green,public:`npm`},{name:`node-cli`,display:`CLI`,color:S.green,public:`npm`},{name:`node-vite`,display:`Vite Plugin`,value:`vite-plugin-xxx`,color:S.blue,hasStyle:!0,public:`npm`}]},{name:`web`,display:`Web`,color:S.magenta,children:[{name:`web-vue`,display:`Vue`,color:S.green,hasStyle:!0},{name:`web-react`,display:`React`,color:S.blue,hasStyle:!0}]},{name:`vscode`,display:`VSCode`,color:S.blue,children:[{name:`vscode-base`,display:`Base`,color:S.yellow,public:`public`},{name:`vscode-vue`,display:`Vue`,color:S.green,commonTemplates:[`vscode`],hasStyle:!0,public:`public`},{name:`vscode-react`,display:`React`,color:S.blue,commonTemplates:[`vscode`],hasStyle:!0,public:`public`}]},{name:`electron`,display:`Electron`,color:S.cyan,children:[{name:`electron-vue`,display:`Vue`,color:S.green,commonTemplates:[`electron`],hasStyle:!0},{name:`electron-react`,display:`React`,color:S.blue,commonTemplates:[`electron`],hasStyle:!0}]},{name:`hbuilderx`,display:`HBuilderX`,color:S.yellow,children:[{name:`hbuilderx-base`,display:`Base`,color:S.yellow,public:`public`},{name:`hbuilderx-vue`,display:`Vue`,color:S.green,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`},{name:`hbuilderx-react`,display:`React`,color:S.blue,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`}]}],D=[{id:`github`,name:`Github`,url:`https://github.com`},{id:`gitcode`,name:`GitCode`,url:`https://gitcode.com`},{id:`gitee`,name:`码云`,url:`https://gitee.com`}],O=`publisher.name.displayName.type.version.private.packageManager.description.author.contributors.license.funding.homepage.repository.publishConfig.bugs.keywords.categories.sideEffects.imports.exports.main.module.unpkg.jsdelivr.types.typesVersions.bin.icon.files.engines.activationEvents.contributes.scripts.peerDependencies.peerDependenciesMeta.dependencies.optionalDependencies.devDependencies.pnpm.overrides.resolutions.husky.simple-git-hooks.lint-staged.eslintConfig`.split(`.`),k=[`dev`,`dev:`,`debug`,`debug:`,`start`,`build`,`build:`,`preview`,`release`,`release:`,`clean`,`clean:`,`test`,`lint`,`lint:`],A=new w({directory:`create-app/logs`}),te=process.platform===`win32`;let j={};function ne(e){j=e}function M(){return j}async function N(e,t){let{trim:n,...r}=Object.assign({stdio:`pipe`,shell:!0},t);Array.isArray(e)&&(e=e.join(` `));let i=e=>{M().verbose?A.debug(e):A.write(e)};i(`$ ${e}`);try{let t=(await C(r)`${e}`).stdout;return i(t),n?t.trim().replace(/\n|\r/g,``):t.trim()}catch(e){let t=e.stderr||e.message;throw i(t),Error(t)}}function P(e){if(e===`C`)return`en-US`;let t=``;try{t=Intl.getCanonicalLocales(e)[0]}catch(t){console.log(`${t.toString()}, invalid language tag: "${e}"\n`)}switch(t){case`zh-TW`:case`zh-HK`:case`zh-MO`:case`zh-CN`:case`zh-SG`:t=`zh-CN`;break;default:t=e}return t}function F(){return P((process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||Intl.DateTimeFormat().resolvedOptions().locale||`en-US`).split(`.`)[0].replace(`_`,`-`))}async function I(e){return await t.promises.readFile(e,`utf-8`).then(e=>JSON.parse(e)||{})}async function L(e){let n=F(),r=a.resolve(e,`${n}.json`),i=a.resolve(e,`en-US.json`);return t.existsSync(r)?await I(r):await I(i)}const R=await L(a.join(T,`locales`));function z(...e){if(e.length===0||!R)return``;let[t,...n]=e,r=R[t]??``;if(n[0]===null||n[0]===void 0||n[0]===``)return r;let i=typeof n[0]==`object`?n[0]:n;return r.replace(/\{([^}]+)\}/g,(e,t)=>i[t]??e)}const B=a.join(o(import.meta.url),`../../`),V=a.join(B,`templates`),H=()=>s.cancel(z(`prompt.cancel`));async function U(e){ne(e);let t=await W(e);t&&(await G(t),e.package&&await ue(t),t.template===`node-vite`&&await de(t.targetDir,t.packageName),e.package||await N(`git init`,{cwd:t.targetDir}))}async function W(e){let n=async function(){let e=await s.select({message:z(`prompt.templateType.message`),options:E.map(e=>({label:e.color(e.display||e.name),value:e.name}))});if(s.isCancel(e))return H();let t=E.find(t=>t.name===e),r=await s.select({message:z(`prompt.template.message`),options:t.children.map(e=>({label:e.color(e.display||e.name),value:e.name})).concat({label:z(`prompt.template.back`),value:`back`})});return s.isCancel(r)?H():r===`back`?await n():{template:r,templateOptions:t.children.find(e=>e.name===r)}},r=await n();if(!r)return;let o=``;await q(`user.email`)===`tom@tomgao.cc`&&(o=`tomjs`);let{template:c,templateOptions:l}=r,u=c.startsWith(`node-`),d=e.packageName;d||(d=l.value||c,o&&u&&(d=`@${o}/${d}`));let f=await s.text({message:z(`prompt.package.message`),initialValue:d,defaultValue:d,placeholder:d,validate:e=>e.length===0||ae(e)?void 0:z(`prompt.package.invalid`)});if(s.isCancel(f))return H();d=f;let p=K(d),m=await s.text({message:z(`prompt.project.message`),defaultValue:p,initialValue:p,placeholder:p,validate:e=>e.length===0||e.length>0?void 0:z(`prompt.project.invalid`)});if(s.isCancel(m))return H();if(p=a.resolve(p===`~`&&!te?i.homedir():e.cwd||process.cwd(),m),t.existsSync(p)&&!re(p)){let t=e.overwrite;if(!t){let e=await s.select({message:z(`prompt.exist.message`,p),options:[{label:z(`prompt.exist.option.no`),value:`no`},{label:z(`prompt.exist.option.yes`),value:`yes`},{label:z(`prompt.exist.option.ignore`),value:`ignore`}]});if(s.isCancel(e))return H();t=e}switch(t){case`yes`:ie(p);break;case`no`:H();return}}let h;if(e.private!==!0&&l.public){let e=await s.confirm({message:z(`prompt.public.message`),active:z(`prompt.confirm.yes`),inactive:z(`prompt.confirm.no`),initialValue:!0});if(s.isCancel(e))return H();h=e}let g;if(h){let e=await s.select({message:z(`prompt.gitUrl.message`),options:D.map(e=>({label:`${e.name} (${e.url})`,value:e.id}))});if(s.isCancel(e))return H();g=D.find(t=>t.id===e)?.url}let _;if(h){o=se(d)||o;let e=await s.text({message:z(`prompt.orgName.message`),defaultValue:o,placeholder:o,validate:e=>o&&!e||oe(e)?void 0:z(`prompt.orgName.invalid`)});if(s.isCancel(e))return H();_=e}return delete l.color,{targetDir:p,orgName:_,packageName:d,template:c,templateOptions:l,isPublic:h,gitUrl:g}}async function G(e){A.debug(`projectOptions:`,e);let{targetDir:t,packageName:o,template:s,isPublic:p,gitUrl:h,orgName:v,templateOptions:b}=e;await l(t);let S=s.includes(`vscode`),C={},w=a.join(t,`.temp`);if(await u(w),await J(C,`base`,w),b.hasStyle&&(await J(C,`style`,w),!s.includes(`vue`))){function e(e){return e.replaceAll(`vue,`,``).replaceAll(`,vue`,``)}let t=await r(a.join(V,`config/style`));for(let n of t){if(n===`package.json`){C.scripts&&Object.keys(C.scripts).forEach(t=>{C.scripts[t].includes(`vue`)&&(C.scripts[t]=e(C.scripts[t]))});continue}let t=a.join(w,n),r=await d(t);r.includes(`vue`)&&g(t,e(r))}}p&&b.public&&await J(C,b.public,w);let T=ee.find(e=>s.includes(`-${e}`));T&&await J(C,T,w);let E=b.commonTemplates;if(Array.isArray(E)&&E.length>0)for(let e of E)await J(C,e,w);if(await c(w,t),await m(w),await c(a.join(V,s),t),y(C,await f(a.join(a.join(V,s),`package.json`))),C.name=o,p){delete C.private,C.name=o,C.license=`MIT`;let e=await q(`user.name`)||i.userInfo().username,n=await q(`user.email`);e&&n?C.author={name:e,email:n}:e&&(C.author=e);let r=`${h}/${v}/${a.basename(t)}`;S&&(C.publisher=v,C.homepage=`${r}/blob/main/README.md`,C.bugs={url:`${r}/issues`},delete C.publishConfig),C.repository={type:`git`,url:`${r}.git`,directory:M().package?`packages/${a.basename(t)}`:void 0}}else C.private=!0,delete C.publishConfig,C.devDependencies&&delete C.devDependencies.publint;if(await _(a.join(t,`package.json`),X(C)),await le(t),p){let{author:e}=C,r=``;e&&(typeof e==`string`?r=e:typeof e==`object`&&(e.name&&e.email?r=`${e.name}<${e.email}>`:e.name?r=e.name:e.email&&(r=e.email)));let i={pkgName:o,dateYear:new Date().getFullYear(),gitUserName:r},s=(await n.readdir(t)).filter(e=>[`README.md`,`README.zh_CN.md`,`LICENSE`].includes(e));for(let e of s){let n=await d(a.join(t,e));Object.keys(i).forEach(e=>{n=n.replace(RegExp(`{{${e}}}`,`g`),i[e])}),await g(a.join(t,e),n)}}let D=await x(`**/_*`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:t});for(let e of D){let r=e.split(`/`);r[r.length-1]=r[r.length-1].substring(1),await n.rename(a.join(t,e),a.join(t,r.join(`/`)))}}function K(e){return(e||``).trim().replace(/^@[^/]+\//,``)}function re(e){return t.readdirSync(e).length===0}function ie(e){t.existsSync(e)&&h(e)}function ae(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function oe(e){return/^[a-z][a-z\d\-._]*$/.test(e)}async function q(e){return N(`git config --get ${e}`,{trim:!0})}function se(e){if(e.startsWith(`@`))return e.split(`/`)[0].substring(1)}async function J(e,r,i){let o=a.join(V,`config/${r}`);if(!t.existsSync(o))return;let s=await n.readdir(o);for(let t of s)[`node_modules`,`.git`].includes(t)||(t===`package.json`?y(e,await f(a.join(o,`package.json`))):await c(a.join(o,t),a.join(i,t)))}function Y(e,t){if(!e)return e;let n={};return Array.isArray(t)&&t.length>0?(t.filter(t=>t in e).forEach(t=>{n[t]=e[t]}),Object.keys(e).filter(e=>!t.includes(e)).sort().forEach(t=>{n[t]=e[t]})):Object.keys(e).sort().forEach(t=>{n[t]=e[t]}),n}function ce(e,t,n){let r={},i=Object.keys(e);{let e=i.filter(e=>e.includes(`:`));i=i.filter(e=>!e.includes(`:`)).sort().concat(e)}let a=s(t),o=s(n);return a.concat(i.filter(e=>!a.includes(e)&&!o.includes(e))).concat(o).forEach(t=>{r[t]=e[t]}),r;function s(e){let t=Array.isArray(e)?e:[];return t.length>0&&(t=t.reduce((e,t)=>{if(t.endsWith(`:`)){let n=i.filter(n=>!e.includes(n)&&n.startsWith(t));return e.concat(n)}return i.includes(t)?e.concat(t):e},[])),t}}function X(e){return e=Y(e,O),e.scripts&&=ce(e.scripts,k,[`prepare`,`prepublishOnly`]),[`dependencies`,`devDependencies`,`peerDependencies`].forEach(t=>{e[t]&&(e[t]=Y(e[t]))}),e}async function le(e){let t=p(a.join(V,`config/package.json`))?.dependencies||{},n=await x(`**/package.json`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let r of n){let n=a.join(e,r),i=await f(n);[`dependencies`,`devDependencies`].forEach(e=>{let n=i[e];n&&Object.keys(n).forEach(e=>{n[e]=t[e]||n[e]})}),_(n,X(i))}}async function ue(e){let n=e.templateOptions.hasStyle,r=[`.editorconfig`,`.gitignore`,`.gitattributes`,`commitlint.config.mjs`,`simple-git-hooks.mjs`,`pnpm-workspace.yaml`];n||r.push(`lint-staged.config.mjs`),[`vscode`,`electron`].find(t=>e.template.startsWith(t))||r.push(`.vscode`),r.forEach(n=>{let r=a.join(e.targetDir,n);t.existsSync(r)&&h(r)});let i=await f(a.join(e.targetDir,`package.json`));if(i.scripts&&delete i.scripts.prepare,!n)delete i.devDependencies;else if(i.devDependencies){let e=await f(a.join(V,`config/style/package.json`)),t=Object.keys(e.devDependencies||{});Object.keys(i.devDependencies).forEach(e=>{t.includes(e)||delete i.devDependencies[e]})}await _(a.join(e.targetDir,`package.json`),i)}async function de(e,t){let n=v((t.split(`/`).pop()||``).replace(`vite-plugin`,``)||`xxx`),r=await x([`src/**/*.ts`,`examples/*/vite.config.ts`,`examples/*/package.json`],{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let t of r){let r=a.join(e,t);await g(r,(await d(r)).replaceAll(`xxx`,n).replaceAll(`Xxx`,b(n)))}}const Z=e(`
1
+ import e from"meow";import t from"node:fs";import n,{readdir as r}from"node:fs/promises";import i from"node:os";import a from"node:path";import{fileURLToPath as o}from"node:url";import*as s from"@clack/prompts";import{copy as c,mkdir as l,mkdirp as u,readFile as d,readJson as f,readJsonSync as p,rm as m,rmSync as h,writeFile as g,writeJson as _}from"@tomjs/node";import{camelCase as v,merge as y,upperFirst as b}from"lodash-es";import{glob as x}from"tinyglobby";import S from"chalk";import{$ as C}from"execa";import w from"@tomjs/logger";const T=o(new URL(`..`,import.meta.url)),ee=[`vue`,`react`],E=[{name:`node`,display:`Node`,color:S.green,children:[{name:`node-base`,display:`Base`,color:S.green,public:`npm`},{name:`node-cli`,display:`CLI`,color:S.green,public:`npm`},{name:`node-vite`,display:`Vite Plugin`,value:`vite-plugin-xxx`,color:S.blue,hasStyle:!0,public:`npm`}]},{name:`web`,display:`Web`,color:S.magenta,children:[{name:`web-vue`,display:`Vue`,color:S.green,hasStyle:!0},{name:`web-react`,display:`React`,color:S.blue,hasStyle:!0}]},{name:`vscode`,display:`VSCode`,color:S.blue,children:[{name:`vscode-base`,display:`Base`,color:S.yellow,public:`public`},{name:`vscode-vue`,display:`Vue`,color:S.green,commonTemplates:[`vscode`],hasStyle:!0,public:`public`},{name:`vscode-react`,display:`React`,color:S.blue,commonTemplates:[`vscode`],hasStyle:!0,public:`public`}]},{name:`electron`,display:`Electron`,color:S.cyan,children:[{name:`electron-vue`,display:`Vue`,color:S.green,commonTemplates:[`electron`],hasStyle:!0},{name:`electron-react`,display:`React`,color:S.blue,commonTemplates:[`electron`],hasStyle:!0}]},{name:`hbuilderx`,display:`HBuilderX`,color:S.yellow,children:[{name:`hbuilderx-base`,display:`Base`,color:S.yellow,public:`public`},{name:`hbuilderx-vue`,display:`Vue`,color:S.green,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`},{name:`hbuilderx-react`,display:`React`,color:S.blue,commonTemplates:[`hbuilderx`],hasStyle:!0,public:`public`}]},{name:`crx`,display:`Chrome Extension`,color:S.red,children:[{name:`crx-vue`,display:`Vue`,color:S.green,hasStyle:!0},{name:`crx-react`,display:`React`,color:S.blue,hasStyle:!0}]}],D=[{id:`github`,name:`Github`,url:`https://github.com`},{id:`gitcode`,name:`GitCode`,url:`https://gitcode.com`},{id:`gitee`,name:`码云`,url:`https://gitee.com`}],O=`publisher.name.displayName.type.version.private.packageManager.description.author.contributors.license.funding.homepage.repository.publishConfig.bugs.keywords.categories.sideEffects.imports.exports.main.module.unpkg.jsdelivr.types.typesVersions.bin.icon.files.engines.activationEvents.contributes.scripts.peerDependencies.peerDependenciesMeta.dependencies.optionalDependencies.devDependencies.pnpm.overrides.resolutions.husky.simple-git-hooks.lint-staged.eslintConfig`.split(`.`),k=[`dev`,`dev:`,`debug`,`debug:`,`start`,`build`,`build:`,`preview`,`release`,`release:`,`clean`,`clean:`,`test`,`lint`,`lint:`],A=new w({directory:`create-app/logs`}),te=process.platform===`win32`;let j={};function ne(e){j=e}function M(){return j}async function N(e,t){let{trim:n,...r}=Object.assign({stdio:`pipe`,shell:!0},t);Array.isArray(e)&&(e=e.join(` `));let i=e=>{M().verbose?A.debug(e):A.write(e)};i(`$ ${e}`);try{let t=(await C(r)`${e}`).stdout;return i(t),n?t.trim().replace(/\n|\r/g,``):t.trim()}catch(e){let t=e.stderr||e.message;throw i(t),Error(t)}}function P(e){if(e===`C`)return`en-US`;let t=``;try{t=Intl.getCanonicalLocales(e)[0]}catch(t){console.log(`${t.toString()}, invalid language tag: "${e}"\n`)}switch(t){case`zh-TW`:case`zh-HK`:case`zh-MO`:case`zh-CN`:case`zh-SG`:t=`zh-CN`;break;default:t=e}return t}function F(){return P((process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||Intl.DateTimeFormat().resolvedOptions().locale||`en-US`).split(`.`)[0].replace(`_`,`-`))}async function I(e){return await t.promises.readFile(e,`utf-8`).then(e=>JSON.parse(e)||{})}async function L(e){let n=F(),r=a.resolve(e,`${n}.json`),i=a.resolve(e,`en-US.json`);return t.existsSync(r)?await I(r):await I(i)}const R=await L(a.join(T,`locales`));function z(...e){if(e.length===0||!R)return``;let[t,...n]=e,r=R[t]??``;if(n[0]===null||n[0]===void 0||n[0]===``)return r;let i=typeof n[0]==`object`?n[0]:n;return r.replace(/\{([^}]+)\}/g,(e,t)=>i[t]??e)}const B=a.join(o(import.meta.url),`../../`),V=a.join(B,`templates`),H=()=>s.cancel(z(`prompt.cancel`));async function U(e){ne(e);let t=await W(e);t&&(await G(t),e.package&&await ue(t),t.template===`node-vite`&&await de(t.targetDir,t.packageName),e.package||await N(`git init`,{cwd:t.targetDir}))}async function W(e){let n=async function(){let e=await s.select({message:z(`prompt.templateType.message`),options:E.map(e=>({label:e.color(e.display||e.name),value:e.name}))});if(s.isCancel(e))return H();let t=E.find(t=>t.name===e),r=await s.select({message:z(`prompt.template.message`),options:t.children.map(e=>({label:e.color(e.display||e.name),value:e.name})).concat({label:z(`prompt.template.back`),value:`back`})});return s.isCancel(r)?H():r===`back`?await n():{template:r,templateOptions:t.children.find(e=>e.name===r)}},r=await n();if(!r)return;let o=``;await q(`user.email`)===`tom@tomgao.cc`&&(o=`tomjs`);let{template:c,templateOptions:l}=r,u=c.startsWith(`node-`),d=e.packageName;d||(d=l.value||c,o&&u&&(d=`@${o}/${d}`));let f=await s.text({message:z(`prompt.package.message`),initialValue:d,defaultValue:d,placeholder:d,validate:e=>e.length===0||ae(e)?void 0:z(`prompt.package.invalid`)});if(s.isCancel(f))return H();d=f;let p=K(d),m=await s.text({message:z(`prompt.project.message`),defaultValue:p,initialValue:p,placeholder:p,validate:e=>e.length===0||e.length>0?void 0:z(`prompt.project.invalid`)});if(s.isCancel(m))return H();if(p=a.resolve(p===`~`&&!te?i.homedir():e.cwd||process.cwd(),m),t.existsSync(p)&&!re(p)){let t=e.overwrite;if(!t){let e=await s.select({message:z(`prompt.exist.message`,p),options:[{label:z(`prompt.exist.option.no`),value:`no`},{label:z(`prompt.exist.option.yes`),value:`yes`},{label:z(`prompt.exist.option.ignore`),value:`ignore`}]});if(s.isCancel(e))return H();t=e}switch(t){case`yes`:ie(p);break;case`no`:H();return}}let h;if(e.private!==!0&&l.public){let e=await s.confirm({message:z(`prompt.public.message`),active:z(`prompt.confirm.yes`),inactive:z(`prompt.confirm.no`),initialValue:!0});if(s.isCancel(e))return H();h=e}let g;if(h){let e=await s.select({message:z(`prompt.gitUrl.message`),options:D.map(e=>({label:`${e.name} (${e.url})`,value:e.id}))});if(s.isCancel(e))return H();g=D.find(t=>t.id===e)?.url}let _;if(h){o=se(d)||o;let e=await s.text({message:z(`prompt.orgName.message`),defaultValue:o,placeholder:o,validate:e=>o&&!e||oe(e)?void 0:z(`prompt.orgName.invalid`)});if(s.isCancel(e))return H();_=e}return delete l.color,{targetDir:p,orgName:_,packageName:d,template:c,templateOptions:l,isPublic:h,gitUrl:g}}async function G(e){A.debug(`projectOptions:`,e);let{targetDir:t,packageName:o,template:s,isPublic:p,gitUrl:h,orgName:v,templateOptions:b}=e;await l(t);let S=s.includes(`vscode`),C={},w=a.join(t,`.temp`);if(await u(w),await J(C,`base`,w),b.hasStyle&&(await J(C,`style`,w),!s.includes(`vue`))){function e(e){return e.replaceAll(`vue,`,``).replaceAll(`,vue`,``)}let t=await r(a.join(V,`config/style`));for(let n of t){if(n===`package.json`){C.scripts&&Object.keys(C.scripts).forEach(t=>{C.scripts[t].includes(`vue`)&&(C.scripts[t]=e(C.scripts[t]))});continue}let t=a.join(w,n),r=await d(t);r.includes(`vue`)&&g(t,e(r))}}p&&b.public&&await J(C,b.public,w);let T=ee.find(e=>s.includes(`-${e}`));T&&await J(C,T,w);let E=b.commonTemplates;if(Array.isArray(E)&&E.length>0)for(let e of E)await J(C,e,w);if(await c(w,t),await m(w),await c(a.join(V,s),t),y(C,await f(a.join(a.join(V,s),`package.json`))),C.name=o,p){delete C.private,C.name=o,C.license=`MIT`;let e=await q(`user.name`)||i.userInfo().username,n=await q(`user.email`);e&&n?C.author={name:e,email:n}:e&&(C.author=e);let r=`${h}/${v}/${a.basename(t)}`;S&&(C.publisher=v,C.homepage=`${r}/blob/main/README.md`,C.bugs={url:`${r}/issues`},delete C.publishConfig),C.repository={type:`git`,url:`${r}.git`,directory:M().package?`packages/${a.basename(t)}`:void 0}}else C.private=!0,delete C.publishConfig,C.devDependencies&&delete C.devDependencies.publint;if(await _(a.join(t,`package.json`),X(C)),await le(t),p){let{author:e}=C,r=``;e&&(typeof e==`string`?r=e:typeof e==`object`&&(e.name&&e.email?r=`${e.name}<${e.email}>`:e.name?r=e.name:e.email&&(r=e.email)));let i={pkgName:o,dateYear:new Date().getFullYear(),gitUserName:r},s=(await n.readdir(t)).filter(e=>[`README.md`,`README.zh_CN.md`,`LICENSE`].includes(e));for(let e of s){let n=await d(a.join(t,e));Object.keys(i).forEach(e=>{n=n.replace(RegExp(`{{${e}}}`,`g`),i[e])}),await g(a.join(t,e),n)}}let D=await x(`**/_*`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:t});for(let e of D){let r=e.split(`/`);r[r.length-1]=r[r.length-1].substring(1),await n.rename(a.join(t,e),a.join(t,r.join(`/`)))}}function K(e){return(e||``).trim().replace(/^@[^/]+\//,``)}function re(e){return t.readdirSync(e).length===0}function ie(e){t.existsSync(e)&&h(e)}function ae(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function oe(e){return/^[a-z][a-z\d\-._]*$/.test(e)}async function q(e){return N(`git config --get ${e}`,{trim:!0})}function se(e){if(e.startsWith(`@`))return e.split(`/`)[0].substring(1)}async function J(e,r,i){let o=a.join(V,`config/${r}`);if(!t.existsSync(o))return;let s=await n.readdir(o);for(let t of s)[`node_modules`,`.git`].includes(t)||(t===`package.json`?y(e,await f(a.join(o,`package.json`))):await c(a.join(o,t),a.join(i,t)))}function Y(e,t){if(!e)return e;let n={};return Array.isArray(t)&&t.length>0?(t.filter(t=>t in e).forEach(t=>{n[t]=e[t]}),Object.keys(e).filter(e=>!t.includes(e)).sort().forEach(t=>{n[t]=e[t]})):Object.keys(e).sort().forEach(t=>{n[t]=e[t]}),n}function ce(e,t,n){let r={},i=Object.keys(e);{let e=i.filter(e=>e.includes(`:`));i=i.filter(e=>!e.includes(`:`)).sort().concat(e)}let a=s(t),o=s(n);return a.concat(i.filter(e=>!a.includes(e)&&!o.includes(e))).concat(o).forEach(t=>{r[t]=e[t]}),r;function s(e){let t=Array.isArray(e)?e:[];return t.length>0&&(t=t.reduce((e,t)=>{if(t.endsWith(`:`)){let n=i.filter(n=>!e.includes(n)&&n.startsWith(t));return e.concat(n)}return i.includes(t)?e.concat(t):e},[])),t}}function X(e){return e=Y(e,O),e.scripts&&=ce(e.scripts,k,[`prepare`,`prepublishOnly`]),[`dependencies`,`devDependencies`,`peerDependencies`].forEach(t=>{e[t]&&(e[t]=Y(e[t]))}),e}async function le(e){let t=p(a.join(V,`config/package.json`))?.dependencies||{},n=await x(`**/package.json`,{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let r of n){let n=a.join(e,r),i=await f(n);[`dependencies`,`devDependencies`].forEach(e=>{let n=i[e];n&&Object.keys(n).forEach(e=>{n[e]=t[e]||n[e]})}),_(n,X(i))}}async function ue(e){let n=e.templateOptions.hasStyle,r=[`.editorconfig`,`.gitignore`,`.gitattributes`,`commitlint.config.mjs`,`simple-git-hooks.mjs`,`pnpm-workspace.yaml`];n||r.push(`lint-staged.config.mjs`),[`vscode`,`electron`].find(t=>e.template.startsWith(t))||r.push(`.vscode`),r.forEach(n=>{let r=a.join(e.targetDir,n);t.existsSync(r)&&h(r)});let i=await f(a.join(e.targetDir,`package.json`));if(i.scripts&&delete i.scripts.prepare,!n)delete i.devDependencies;else if(i.devDependencies){let e=await f(a.join(V,`config/style/package.json`)),t=Object.keys(e.devDependencies||{});Object.keys(i.devDependencies).forEach(e=>{t.includes(e)||delete i.devDependencies[e]})}await _(a.join(e.targetDir,`package.json`),i)}async function de(e,t){let n=v((t.split(`/`).pop()||``).replace(`vite-plugin`,``)||`xxx`),r=await x([`src/**/*.ts`,`examples/*/vite.config.ts`,`examples/*/package.json`],{ignore:[`**/node_modules/**`,`**/.*`],cwd:e});for(let t of r){let r=a.join(e,t);await g(r,(await d(r)).replaceAll(`xxx`,n).replaceAll(`Xxx`,b(n)))}}const Z=e(`
2
2
  Usage
3
3
  $ create-app [options] <package-name>
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tomjs/create-app",
3
3
  "type": "module",
4
- "version": "5.4.0",
4
+ "version": "5.6.0",
5
5
  "description": "Create a node/web/electron/vscode project based on tomjs",
6
6
  "author": {
7
7
  "name": "Tom Gao",
@@ -47,37 +47,37 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "dependencies": {
50
- "@clack/prompts": "^0.11.0",
50
+ "@clack/prompts": "^1.0.0",
51
51
  "@tomjs/logger": "^3.0.0",
52
52
  "@tomjs/node": "^2.2.3",
53
53
  "chalk": "^5.6.2",
54
54
  "dayjs": "^1.11.19",
55
55
  "execa": "^9.6.1",
56
- "lodash-es": "^4.17.22",
56
+ "lodash-es": "^4.17.23",
57
57
  "meow": "^14.0.0",
58
58
  "tinyglobby": "^0.2.15"
59
59
  },
60
60
  "devDependencies": {
61
- "@antfu/eslint-config": "^7.1.0",
62
- "@commitlint/cli": "^20.3.1",
61
+ "@antfu/eslint-config": "^7.4.2",
62
+ "@commitlint/cli": "^20.4.1",
63
63
  "@tomjs/commitlint": "^5.0.0",
64
64
  "@tomjs/eslint": "^7.0.0",
65
- "@tomjs/stylelint": "^8.0.0",
65
+ "@tomjs/stylelint": "^8.3.0",
66
66
  "@tomjs/tsconfig": "^3.2.0",
67
- "@tsconfig/node20": "^20.1.8",
67
+ "@tsconfig/node20": "^20.1.9",
68
68
  "@types/lodash-es": "^4.17.12",
69
- "@types/node": "^20.19.30",
70
- "dotenv": "^17.2.3",
69
+ "@types/node": "^20.19.33",
70
+ "dotenv": "^17.2.4",
71
71
  "eslint": "^9.39.2",
72
72
  "lint-staged": "^16.2.7",
73
73
  "npm-run-all2": "^8.0.4",
74
- "publint": "^0.3.16",
74
+ "publint": "^0.3.17",
75
75
  "rimraf": "^6.1.2",
76
76
  "simple-git-hooks": "^2.13.1",
77
- "stylelint": "^17.0.0",
78
- "tsdown": "~0.19.0",
77
+ "stylelint": "^17.2.0",
78
+ "tsdown": "~0.20.3",
79
79
  "tsx": "^4.21.0",
80
- "type-fest": "^5.4.1",
80
+ "type-fest": "^5.4.4",
81
81
  "typescript": "~5.9.3"
82
82
  },
83
83
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "version": "0.0.0",
4
- "packageManager": "pnpm@10.28.1",
4
+ "packageManager": "pnpm@10.28.2",
5
5
  "scripts": {
6
6
  "lint": "eslint --fix",
7
7
  "prepare": "simple-git-hooks"
@@ -10,7 +10,7 @@
10
10
  "dayjs": "^1.11.19"
11
11
  },
12
12
  "devDependencies": {
13
- "@antfu/eslint-config": "^7.1.0",
13
+ "@antfu/eslint-config": "^7.2.0",
14
14
  "@commitlint/cli": "^20.3.1",
15
15
  "@tomjs/commitlint": "^5.0.0",
16
16
  "@tomjs/eslint": "^7.0.0",
@@ -1,57 +1,57 @@
1
1
  {
2
2
  "dependencies": {
3
- "@antfu/eslint-config": "^7.1.0",
4
- "@clack/prompts": "^0.11.0",
5
- "@commitlint/cli": "^20.3.1",
6
- "@eslint-react/eslint-plugin": "^2.7.2",
3
+ "@antfu/eslint-config": "^7.4.2",
4
+ "@clack/prompts": "^1.0.0",
5
+ "@commitlint/cli": "^20.4.1",
6
+ "@eslint-react/eslint-plugin": "^2.12.2",
7
7
  "@tomjs/commitlint": "^5.0.0",
8
8
  "@tomjs/eslint": "^7.0.0",
9
9
  "@tomjs/hbuilderx": "^1.2.0",
10
10
  "@tomjs/hbuilderx-cli": "^1.3.1",
11
11
  "@tomjs/logger": "^3.0.0",
12
12
  "@tomjs/node": "^2.2.3",
13
- "@tomjs/stylelint": "^8.0.0",
13
+ "@tomjs/stylelint": "^8.3.0",
14
14
  "@tomjs/tsconfig": "^3.2.0",
15
- "@tomjs/vite-plugin-electron": "^2.4.2",
15
+ "@tomjs/vite-plugin-electron": "^2.5.1",
16
16
  "@tomjs/vite-plugin-hbuilderx": "^1.3.0",
17
- "@tomjs/vite-plugin-vscode": "^7.1.0",
17
+ "@tomjs/vite-plugin-vscode": "^7.1.1",
18
18
  "@tomjs/vscode": "^2.5.0",
19
19
  "@tomjs/vscode-dev": "^3.1.2",
20
20
  "@tomjs/vscode-webview": "^2.0.2",
21
- "@types/node": "^20.19.30",
22
- "@types/react": "^19.2.9",
21
+ "@types/node": "^20.19.33",
22
+ "@types/react": "^19.2.13",
23
23
  "@types/react-dom": "^19.2.3",
24
24
  "@types/vscode": "^1.56.0",
25
25
  "@types/vscode-webview": "^1.57.5",
26
26
  "@unocss/eslint-plugin": "^66.6.0",
27
- "@vitejs/plugin-react": "^5.1.2",
28
- "@vitejs/plugin-react-swc": "^4.2.2",
29
- "@vitejs/plugin-vue": "^6.0.3",
27
+ "@vitejs/plugin-react": "^5.1.4",
28
+ "@vitejs/plugin-react-swc": "^4.2.3",
29
+ "@vitejs/plugin-vue": "^6.0.4",
30
30
  "@vscode/webview-ui-toolkit": "^1.4.0",
31
31
  "@vue/tsconfig": "^0.8.1",
32
- "@vueuse/core": "^14.1.0",
32
+ "@vueuse/core": "^14.2.1",
33
33
  "chalk": "^5.6.2",
34
34
  "cosmiconfig": "^9.0.0",
35
35
  "cross-env": "^10.1.0",
36
36
  "dayjs": "^1.11.19",
37
- "electron": "^40.0.0",
38
- "electron-builder": "^26.4.0",
37
+ "electron": "^40.2.1",
38
+ "electron-builder": "^26.7.0",
39
39
  "eslint": "^9.39.2",
40
40
  "eslint-plugin-react-hooks": "^7.0.1",
41
- "eslint-plugin-react-refresh": "^0.4.26",
41
+ "eslint-plugin-react-refresh": "^0.5.0",
42
42
  "execa": "^9.6.1",
43
43
  "lint-staged": "^16.2.7",
44
44
  "meow": "^14.0.0",
45
45
  "npm-run-all2": "^8.0.4",
46
- "ora": "^9.0.0",
46
+ "ora": "^9.3.0",
47
47
  "pinia": "^3.0.4",
48
- "publint": "0.3.16",
49
- "react": "^19.2.3",
50
- "react-dom": "^19.2.3",
51
- "sass": "^1.97.2",
48
+ "publint": "0.3.17",
49
+ "react": "^19.2.4",
50
+ "react-dom": "^19.2.4",
51
+ "sass": "^1.97.3",
52
52
  "simple-git-hooks": "^2.13.1",
53
- "stylelint": "^17.0.0",
54
- "tsdown": "^0.19.0",
53
+ "stylelint": "^17.2.0",
54
+ "tsdown": "^0.20.3",
55
55
  "tsx": "^4.21.0",
56
56
  "typescript": "~5.9.3",
57
57
  "unocss": "^66.6.0",
@@ -59,10 +59,10 @@
59
59
  "unplugin-vue-components": "^31.0.0",
60
60
  "vite": "^7.3.1",
61
61
  "vite-plugin-electron-renderer": "^0.14.6",
62
- "vite-plugin-vue-devtools": "^8.0.5",
63
- "vue": "^3.5.27",
62
+ "vite-plugin-vue-devtools": "^8.0.6",
63
+ "vue": "^3.5.28",
64
64
  "vue-i18n": "^11.2.8",
65
- "vue-router": "^4.6.4",
66
- "vue-tsc": "^3.2.2"
65
+ "vue-router": "^5.0.2",
66
+ "vue-tsc": "^3.2.4"
67
67
  }
68
68
  }
@@ -0,0 +1,5 @@
1
+ onlyBuiltDependencies:
2
+ - '@parcel/watcher'
3
+ - '@swc/core'
4
+ - esbuild
5
+ - simple-git-hooks
@@ -60,6 +60,10 @@ build
60
60
  dist
61
61
  release
62
62
 
63
+ # generated files
64
+ auto-imports.d.ts
65
+ components.d.ts
66
+
63
67
  package.nls.json
64
68
  package.nls.*.json
65
69
  src/vscode.d.ts
@@ -0,0 +1,63 @@
1
+ # logs
2
+ *.log
3
+ lerna-debug.log*
4
+ logs
5
+ npm-debug.log*
6
+ pnpm-debug.log*
7
+ yarn-debug.log*
8
+ yarn-error.log*
9
+
10
+ # diagnostic reports (https://nodejs.org/api/report.html)
11
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12
+
13
+ # runtime data
14
+ *.pid
15
+ *.pid.lock
16
+ *.seed
17
+ pids
18
+
19
+ # dependency directory
20
+ bower_components
21
+ jspm_packages
22
+ node_modules
23
+ web_modules
24
+
25
+ # cache
26
+ .cache
27
+ .npm
28
+ .tmp
29
+ .temp
30
+ .eslintcache
31
+ .stylelintcache
32
+ tsconfig.tsbuildinfo
33
+
34
+ # environment
35
+ .env
36
+
37
+ # macOS
38
+ .DS_Store
39
+
40
+ # package files
41
+ *.7z
42
+ *.gz
43
+ *.gzip
44
+ *.rar
45
+ *.tar
46
+ *.tar.*
47
+ *.tgz
48
+ *.zip
49
+
50
+ # IDEA
51
+ .idea
52
+
53
+ # vscode
54
+ .history
55
+
56
+ # build output
57
+ build
58
+ dist
59
+ release
60
+
61
+ # generated files
62
+ auto-imports.d.ts
63
+ components.d.ts
@@ -12,6 +12,6 @@
12
12
  "unplugin-vue-components": "^31.0.0",
13
13
  "vite": "^7.3.1",
14
14
  "vite-plugin-vue-devtools": "^8.0.5",
15
- "vue-tsc": "^3.2.2"
15
+ "vue-tsc": "^3.2.4"
16
16
  }
17
17
  }
@@ -0,0 +1,4 @@
1
+ onlyBuiltDependencies:
2
+ - '@parcel/watcher'
3
+ - esbuild
4
+ - simple-git-hooks
@@ -7,7 +7,6 @@
7
7
  }
8
8
  },
9
9
  "include": [
10
- "env.d.ts",
11
10
  "src/**/*",
12
11
  "src/**/*.vue"
13
12
  ]
@@ -1,8 +1,8 @@
1
- import { defineConfig, presetAttributify, presetIcons, presetWind4 } from 'unocss';
1
+ import { defineConfig, presetAttributify, presetIcons, presetWind3 } from 'unocss';
2
2
 
3
3
  export default defineConfig({
4
4
  presets: [
5
- presetWind4(),
5
+ presetWind3(),
6
6
  presetAttributify(),
7
7
  presetIcons({ warn: true }),
8
8
  ],
@@ -0,0 +1,28 @@
1
+ import { defineManifest } from '@crxjs/vite-plugin';
2
+ import pkg from './package.json';
3
+
4
+ export default defineManifest({
5
+ manifest_version: 3,
6
+ name: pkg.name,
7
+ version: pkg.version,
8
+ icons: {
9
+ 48: 'public/logo.png',
10
+ },
11
+ action: {
12
+ default_icon: {
13
+ 48: 'public/logo.png',
14
+ },
15
+ default_popup: 'src/popup/index.html',
16
+ },
17
+ permissions: [
18
+ 'sidePanel',
19
+ 'contentSettings',
20
+ ],
21
+ content_scripts: [{
22
+ js: ['src/content/main.tsx'],
23
+ matches: ['https://*/*'],
24
+ }],
25
+ side_panel: {
26
+ default_path: 'src/sidepanel/index.html',
27
+ },
28
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "crx-react",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build"
9
+ },
10
+ "devDependencies": {
11
+ "@crxjs/vite-plugin": "^2.3.0",
12
+ "@types/chrome": "^0.1.36"
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <svg width="1200pt" height="1200pt" version="1.1" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M 737.01 736.911 C 737.01 678.236 764.861 631.584 810.593 611.455 C 856.348 591.328 907.915 602.151 947.752 638.471 C 960.533 650.102 971.7 655.694 983.37 650.253 C 995.344 644.66 997.302 624.163 997.302 611.423 L 997.302 392.795 C 997.302 363.576 975.601 342.696 946.365 342.696 L 731.973 342.696 C 660.472 342.696 644.538 282.455 681.12 241.018 C 741.347 172.79 709.081 67.292 599.496 62.714 C 489.923 67.276 457.668 172.603 517.886 240.835 C 554.463 282.291 538.543 342.692 467.042 342.692 L 255.813 342.692 C 226.593 342.692 202.699 363.572 202.699 392.792 L 202.699 1083.335 C 202.699 1112.559 226.594 1137.287 255.813 1137.287 L 946.355 1137.287 C 975.592 1137.287 997.293 1112.559 997.293 1083.335 L 997.293 866.134 C 997.293 853.393 994.377 831.952 982.17 826.265 C 970.045 820.619 955.743 826.511 942.823 838.293 C 903.146 874.487 854.555 884.556 809.295 864.635 C 763.798 844.598 737.001 797.483 737.001 738.631 L 737.01 736.911 Z" style="fill: rgb(242, 186, 228);"/>
4
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,35 @@
1
+ import { useState } from 'react';
2
+
3
+ export default function HelloWorld(props: { msg: string }) {
4
+ const [count, setCount] = useState(0);
5
+
6
+ return (
7
+ <>
8
+ <h1>{props.msg}</h1>
9
+
10
+ <div className="card">
11
+ <button type="button" onClick={() => setCount(count + 1)}>
12
+ count is
13
+ {' '}
14
+ {count}
15
+ </button>
16
+ <p>
17
+ Edit
18
+ <code>src/components/HelloWorld.tsx</code>
19
+ {' '}
20
+ to test HMR
21
+ </p>
22
+ </div>
23
+
24
+ <p>
25
+ Check out
26
+ <a href="https://github.com/crxjs/create-crxjs" target="_blank" rel="noreferrer">create-crxjs</a>
27
+ , the official starter
28
+ </p>
29
+
30
+ <p className="read-the-docs">
31
+ Click on the Vite, React and CRXJS logos to learn more
32
+ </p>
33
+ </>
34
+ );
35
+ }
@@ -0,0 +1,14 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './views/App.tsx';
4
+
5
+ console.log('[CRXJS] Hello world from content script!');
6
+
7
+ const container = document.createElement('div');
8
+ container.id = 'crxjs-app';
9
+ document.body.appendChild(container);
10
+ createRoot(container).render(
11
+ <StrictMode>
12
+ <App />
13
+ </StrictMode>,
14
+ );
@@ -0,0 +1,56 @@
1
+ .popup-container {
2
+ position: fixed;
3
+ right: 0;
4
+ bottom: 0;
5
+ z-index: 100;
6
+ display: flex;
7
+ align-items: flex-end;
8
+ margin: 1.25rem;
9
+ font-family: ui-sans-serif, system-ui, sans-serif;
10
+ line-height: 1em;
11
+ user-select: none;
12
+ }
13
+
14
+ .popup-content {
15
+ width: max-content;
16
+ height: min-content;
17
+ padding: 0.5rem 1rem;
18
+ margin: auto 0.5rem 0 0;
19
+ color: #1f2937;
20
+ background-color: white;
21
+ border-radius: 0.5rem;
22
+ box-shadow:
23
+ 0 4px 6px -1px rgb(0 0 0 / 0.1),
24
+ 0 2px 4px -2px rgb(0 0 0 / 0.1);
25
+ transition: opacity 300ms;
26
+ }
27
+
28
+ .toggle-button {
29
+ display: flex;
30
+ justify-content: center;
31
+ width: 2.5rem;
32
+ height: 2.5rem;
33
+ cursor: pointer;
34
+ background-color: #288cd7;
35
+ border: none;
36
+ border-radius: 9999px;
37
+ box-shadow:
38
+ 0 1px 3px 0 rgb(0 0 0 / 0.1),
39
+ 0 1px 2px -1px rgb(0 0 0 / 0.1);
40
+ }
41
+
42
+ .toggle-button:hover {
43
+ background-color: #1e6aa3;
44
+ }
45
+
46
+ .button-icon {
47
+ padding: 4px;
48
+ }
49
+
50
+ .opacity-100 {
51
+ opacity: 1;
52
+ }
53
+
54
+ .opacity-0 {
55
+ opacity: 0;
56
+ }
@@ -0,0 +1,23 @@
1
+ import { useState } from 'react';
2
+ import Logo from '@/assets/crx.svg';
3
+ import './App.css';
4
+
5
+ function App() {
6
+ const [show, setShow] = useState(false);
7
+ const toggle = () => setShow(!show);
8
+
9
+ return (
10
+ <div className="popup-container">
11
+ {show && (
12
+ <div className={`popup-content ${show ? 'opacity-100' : 'opacity-0'}`}>
13
+ <h1>HELLO CRXJS</h1>
14
+ </div>
15
+ )}
16
+ <button className="toggle-button" onClick={toggle}>
17
+ <img src={Logo} alt="CRXJS logo" className="button-icon" />
18
+ </button>
19
+ </div>
20
+ );
21
+ }
22
+
23
+ export default App;
@@ -0,0 +1,49 @@
1
+ #root {
2
+ max-width: 1280px;
3
+ padding: 2rem;
4
+ margin: 0 auto;
5
+ text-align: center;
6
+ }
7
+
8
+ .logo {
9
+ height: 6em;
10
+ padding: 1.5em;
11
+ transition: filter 300ms;
12
+ will-change: filter;
13
+ }
14
+
15
+ .logo:hover {
16
+ filter: drop-shadow(0 0 2em #646cffaa);
17
+ }
18
+
19
+ .logo.react:hover {
20
+ filter: drop-shadow(0 0 2em #61dafbaa);
21
+ }
22
+
23
+ .logo.crx:hover {
24
+ filter: drop-shadow(0 0 2em #f2bae4aa);
25
+ }
26
+
27
+ @keyframes logo-spin {
28
+ from {
29
+ transform: rotate(0deg);
30
+ }
31
+
32
+ to {
33
+ transform: rotate(360deg);
34
+ }
35
+ }
36
+
37
+ @media (prefers-reduced-motion: no-preference) {
38
+ a:nth-of-type(2) .logo {
39
+ animation: logo-spin infinite 20s linear;
40
+ }
41
+ }
42
+
43
+ .card {
44
+ padding: 2em;
45
+ }
46
+
47
+ .read-the-docs {
48
+ color: #888;
49
+ }
@@ -0,0 +1,22 @@
1
+ import crxLogo from '@/assets/crx.svg';
2
+ import reactLogo from '@/assets/react.svg';
3
+ import viteLogo from '@/assets/vite.svg';
4
+ import HelloWorld from '@/components/HelloWorld';
5
+ import './App.css';
6
+
7
+ export default function App() {
8
+ return (
9
+ <div>
10
+ <a href="https://vite.dev" target="_blank" rel="noreferrer">
11
+ <img src={viteLogo} className="logo" alt="Vite logo" />
12
+ </a>
13
+ <a href="https://reactjs.org/" target="_blank" rel="noreferrer">
14
+ <img src={reactLogo} className="logo react" alt="React logo" />
15
+ </a>
16
+ <a href="https://crxjs.dev/vite-plugin" target="_blank" rel="noreferrer">
17
+ <img src={crxLogo} className="logo crx" alt="crx logo" />
18
+ </a>
19
+ <HelloWorld msg="Vite + React + CRXJS" />
20
+ </div>
21
+ );
22
+ }