extension-create 2.0.0-alpha.24 → 2.0.0-alpha.27

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 (57) hide show
  1. package/dist/module.js +21 -21
  2. package/dist/test-template-config-babel/README.md +35 -0
  3. package/dist/test-template-config-babel/babel.config.json +4 -0
  4. package/dist/test-template-config-babel/extension.config.js +17 -0
  5. package/dist/test-template-config-babel/images/babel.png +0 -0
  6. package/dist/test-template-config-babel/images/extension_128.png +0 -0
  7. package/dist/test-template-config-babel/images/extension_16.png +0 -0
  8. package/dist/test-template-config-babel/images/extension_48.png +0 -0
  9. package/dist/test-template-config-babel/manifest.json +15 -0
  10. package/dist/test-template-config-babel/newtab/index.html +40 -0
  11. package/dist/test-template-config-babel/newtab/scripts.js +11 -0
  12. package/dist/test-template-config-babel/newtab/styles.css +22 -0
  13. package/dist/test-template-config-babel/package.json +24 -0
  14. package/dist/test-template-config-stylelint/.stylelintrc.json +3 -0
  15. package/dist/test-template-config-stylelint/newtab/index.html +1 -1
  16. package/dist/test-template-config-stylelint/package.json +3 -2
  17. package/dist/test-template-content-extension-config/README.md +35 -0
  18. package/dist/test-template-content-extension-config/background.ts +1 -0
  19. package/dist/test-template-content-extension-config/content/ContentApp.tsx +82 -0
  20. package/dist/test-template-content-extension-config/content/scripts.tsx +17 -0
  21. package/dist/test-template-content-extension-config/content/styles.css +10 -0
  22. package/dist/test-template-content-extension-config/extension.config.js +22 -0
  23. package/dist/test-template-content-extension-config/images/chromeWindow.png +0 -0
  24. package/dist/test-template-content-extension-config/images/extension_128.png +0 -0
  25. package/dist/test-template-content-extension-config/images/extension_16.png +0 -0
  26. package/dist/test-template-content-extension-config/images/extension_48.png +0 -0
  27. package/dist/test-template-content-extension-config/images/logo.svg +9 -0
  28. package/dist/test-template-content-extension-config/images/tailwind.png +0 -0
  29. package/dist/test-template-content-extension-config/images/tailwind_bg.png +0 -0
  30. package/dist/test-template-content-extension-config/images/typescript.png +0 -0
  31. package/dist/test-template-content-extension-config/manifest.json +28 -0
  32. package/dist/test-template-content-extension-config/package.json +34 -0
  33. package/dist/test-template-content-extension-config/postcss.config.js +6 -0
  34. package/dist/test-template-content-extension-config/tailwind.config.js +8 -0
  35. package/dist/test-template-content-extension-config/tsconfig.json +22 -0
  36. package/dist/test-template-content-react-svgr/README.md +35 -0
  37. package/dist/test-template-content-react-svgr/background.ts +1 -0
  38. package/dist/test-template-content-react-svgr/content/ContentApp.tsx +82 -0
  39. package/dist/test-template-content-react-svgr/content/scripts.tsx +17 -0
  40. package/dist/test-template-content-react-svgr/content/styles.css +10 -0
  41. package/dist/test-template-content-react-svgr/extension.config.js +22 -0
  42. package/dist/test-template-content-react-svgr/images/chromeWindow.png +0 -0
  43. package/dist/test-template-content-react-svgr/images/extension_128.png +0 -0
  44. package/dist/test-template-content-react-svgr/images/extension_16.png +0 -0
  45. package/dist/test-template-content-react-svgr/images/extension_48.png +0 -0
  46. package/dist/test-template-content-react-svgr/images/logo.svg +9 -0
  47. package/dist/test-template-content-react-svgr/images/tailwind.png +0 -0
  48. package/dist/test-template-content-react-svgr/images/tailwind_bg.png +0 -0
  49. package/dist/test-template-content-react-svgr/images/typescript.png +0 -0
  50. package/dist/test-template-content-react-svgr/manifest.json +28 -0
  51. package/dist/test-template-content-react-svgr/package.json +34 -0
  52. package/dist/test-template-content-react-svgr/postcss.config.js +6 -0
  53. package/dist/test-template-content-react-svgr/tailwind.config.js +8 -0
  54. package/dist/test-template-content-react-svgr/tsconfig.json +22 -0
  55. package/package.json +1 -1
  56. package/dist/test-template-config-stylelint/stylelint.config.json +0 -1
  57. /package/dist/test-template-config-stylelint/newtab/{styles.css → styles.scss} +0 -0
package/dist/module.js CHANGED
@@ -1,31 +1,31 @@
1
- "use strict";var Ve=Object.create;var k=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var qe=(e,n)=>{for(var o in n)k(e,o,{get:n[o],enumerable:!0})},j=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Le(n))!Ye.call(e,i)&&i!==o&&k(e,i,{get:()=>n[i],enumerable:!(r=Xe(n,i))||r.enumerable});return e};var a=(e,n,o)=>(o=e!=null?Ve(Ue(e)):{},j(n||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),He=e=>j(k({},"__esModule",{value:!0}),e);var mn={};qe(mn,{extensionCreate:()=>ln});module.exports=He(mn);var C=a(require("path"));var x=a(require("path")),t=require("@colors/colors/safe"),A=a(require("fs/promises")),G=require("package-manager-detector");function O(e){let n=x.default.basename(e);return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write in the destination directory
1
+ "use strict";var Ae=Object.create;var v=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var o in t)v(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of We(t))!ze.call(e,i)&&i!==o&&v(e,i,{get:()=>t[i],enumerable:!(r=Ge(t,i))||r.enumerable});return e};var a=(e,t,o)=>(o=e!=null?Ae(Oe(e)):{},N(t||!e||!e.__esModule?v(o,"default",{value:e,enumerable:!0}):o,e)),Ve=e=>N(v({},"__esModule",{value:!0}),e);var rt={};Le(rt,{extensionCreate:()=>it});module.exports=Ve(rt);var _=a(require("path"));var y=a(require("path")),n=require("@colors/colors/safe"),j=a(require("fs/promises")),A=require("package-manager-detector");function G(e){let t=y.default.basename(e);return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write in the destination directory
2
2
 
3
3
  Path is not writable. Ensure you have write permissions for this folder.
4
- ${(0,t.red)("NOT WRITEABLE")}: ${(0,t.underline)(n)}`}async function W(e,n){let o=x.default.basename(e),r=`
5
- Conflict! Path to ${(0,t.cyan)(o)} includes conflicting files:
4
+ ${(0,n.red)("NOT WRITEABLE")}: ${(0,n.underline)(t)}`}async function W(e,t){let o=y.default.basename(e),r=`
5
+ Conflict! Path to ${(0,n.cyan)(o)} includes conflicting files:
6
6
 
7
- `;for(let i of n){let s=await A.default.lstat(x.default.join(e,i));r+=s.isDirectory()?`${(0,t.gray)("-")} ${(0,t.brightYellow)(i)}
8
- `:`${(0,t.gray)("-")} ${(0,t.brightYellow)(i)}
7
+ `;for(let i of t){let s=await j.default.lstat(y.default.join(e,i));r+=s.isDirectory()?`${(0,n.gray)("-")} ${(0,n.brightYellow)(i)}
8
+ `:`${(0,n.gray)("-")} ${(0,n.brightYellow)(i)}
9
9
  `}return r+=`
10
10
  You need to either rename/remove the files listed above, or choose a new directory name for your extension.
11
11
 
12
- Path to conflicting directory: ${(0,t.underline)(e)}`,r}function z(){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} You need to provide an extension name to create one. See ${(0,t.brightYellow)("--help")} for command info.`}function V(){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} URLs are not allowed as a project path. Either write a name or a path to a local folder.`}async function X(e,n){let o=x.default.relative(process.cwd(),e),r=await(0,G.detect)(),i="npm run";switch(r?.name){case"yarn":i="yarn dev";break;case"pnpm":i="pnpm dev";break;default:i="npm run dev"}return process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("pnpm")&&(i="pnpm dev"),`\u{1F9E9} - ${(0,t.brightGreen)("Success!")} Extension ${(0,t.cyan)(n)} created.
12
+ Path to conflicting directory: ${(0,n.underline)(e)}`,r}function O(){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} You need to provide an extension name to create one. See ${(0,n.brightYellow)("--help")} for command info.`}function z(){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} URLs are not allowed as a project path. Either write a name or a path to a local folder.`}async function L(e,t){let o=y.default.relative(process.cwd(),e),r=await(0,A.detect)(),i="npm run";switch(r?.name){case"yarn":i="yarn dev";break;case"pnpm":i="pnpm dev";break;default:i="npm run dev"}return process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("pnpm")&&(i="pnpm dev"),`\u{1F9E9} - ${(0,n.brightGreen)("Success!")} Extension ${(0,n.cyan)(t)} created.
13
13
 
14
- Now ${(0,t.magenta)(`cd ${(0,t.underline)(o)}`)} and ${(0,t.magenta)(`${i}`)} to open a new browser instance
14
+ Now ${(0,n.magenta)(`cd ${(0,n.underline)(o)}`)} and ${(0,n.magenta)(`${i}`)} to open a new browser instance
15
15
  with your extension installed, loaded, and enabled for development.
16
16
 
17
- ${(0,t.brightGreen)("You are ready")}. Time to hack on your extension!`}function L(e){return`\u{1F423} - Starting a new browser extension named ${(0,t.cyan)(e)}...`}function U(){return"\u{1F91E} - Checking if destination path is writeable..."}function Y(){return"\u{1F50E} - Scanning for potential conflicting files..."}function q(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't create directory ${(0,t.cyan)(e)}:
18
- ${(0,t.red)(n)}`}function H(e){return`\u{1F537} - Writing type definitions for ${(0,t.cyan)(e)}...`}function B(e){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write the extension type definition.
19
- ${(0,t.red)(e)}`}function h(e,n){return n==="init"?`\u{1F9F0} - Installing ${(0,t.cyan)(e)}...`:`\u{1F9F0} - Installing ${(0,t.cyan)(e)} from template ${(0,t.magenta)(n)}...`}function b(e,n,o){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't find template ${(0,t.magenta)(n)} for ${(0,t.cyan)(e)}:
20
- ${(0,t.red)(o)}`}function K(e){return`\u{1F332} - Initializing git repository for ${(0,t.cyan)(e)}...`}function Q(e,n,o){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${(0,t.brightYellow)(e)} ${(0,t.brightYellow)(n.join(" "))} failed with exit code ${o}`}function Z(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't initialize ${(0,t.brightYellow)("git")} for ${(0,t.cyan)(e)}:
21
- ${(0,t.red)(n.message)}`}function ee(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't initialize ${(0,t.brightYellow)("git")} for ${(0,t.cyan)(e)}:
22
- ${(0,t.red)(n.message||n.toString())}`}function ne(){return"\u{1F6E0} - Installing dependencies... (takes a moment)"}function te(e,n,o){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${e} ${n.join(" ")} failed with exit code ${o}`}function ie(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't install dependencies for ${(0,t.cyan)(e)}:
23
- ${(0,t.red)(n)}`}function re(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't install dependencies for ${(0,t.cyan)(e)}:
24
- ${(0,t.red)(n.message||n.toString())}`}function oe(){return"Symlink created successfully."}function se(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to create symlink: ${(0,t.red)(e)} ${(0,t.red)(n.join(" "))}`}function ae(){return`\u{1F4DD} - Writing ${(0,t.brightYellow)("package.json")} metadata...`}function ce(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${(0,t.brightYellow)("package.json")} for ${(0,t.cyan)(e)}:
25
- ${(0,t.red)(n)}`}function le(){return`\u{1F4DC} - Writing ${(0,t.brightYellow)("manifest.json")} metadata...`}function me(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${(0,t.brightYellow)("manifest.json")} for ${(0,t.cyan)(e)}:
26
- ${(0,t.red)(n)}`}function pe(){return`\u{1F4C4} - Writing ${(0,t.brightYellow)("README.md")} metadata...`}function ge(){return`\u{1F648} - Writing ${(0,t.brightYellow)(".gitignore")} lines...`}function de(e,n){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write the ${(0,t.brightYellow)("README.md")} file for ${(0,t.cyan)(e)}:
27
- ${(0,t.red)(n)}`}function fe(e){return`\u{1F91D} - Ensuring ${(0,t.cyan)(e)} folder exists...`}function ue(e){return`${(0,t.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Error while checking directory writability:
28
- `+(0,t.red)(e)}var E=a(require("fs/promises")),$=a(require("path")),we=require("package-manager-detector");async function _(e,n){let o=await E.default.readdir(e,{withFileTypes:!0});return await E.default.mkdir(n,{recursive:!0}),await Promise.all(o.map(async r=>{let i=$.default.join(e,r.name),s=$.default.join(n,r.name);r.isDirectory()?await _(i,s):await E.default.copyFile(i,s)}))}async function y(){let e=await(0,we.detect)(),n="npm";if(process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("pnpm"))return"pnpm";switch(e?.name){case"yarn":n="yarn";break;case"pnpm":n="pnpm";break;default:n="npm"}return n}function ye(e){let n=$.default.resolve(__dirname,"template");return $.default.resolve(e,n)}async function xe(e,n){try{return console.log(fe(n)),await E.default.mkdir(e,{recursive:!0}),!0}catch(o){return console.log(ue(o)),!1}}function he(e){return e!=="init"}function Ee(e){return e.includes("typescript")||e.includes("react")||e.includes("preact")||e.includes("svelte")||e.includes("solid")}var $e=a(require("path")),S=a(require("fs/promises"));var Be=["LICENSE","node_modules"];async function ve(e,n){console.log(L(n));try{let o=await xe(e,n);console.log(U()),o||(console.error(O(e)),process.exit(1));let r=await S.default.readdir(e);console.log(Y());let i=await Promise.all(r.filter(s=>!s.startsWith(".")).filter(s=>!s.endsWith(".log")).filter(s=>!Be.includes(s)).map(async s=>(await S.default.lstat($e.default.join(e,s))).isDirectory()?`${s}/`:`${s}`));if(i.length>0){let s=await W(e,i);throw new Error(s)}}catch(o){console.error(q(n,o)),process.exit(1)}}var ke=a(require("path"));async function be(e,n,o){let r=ke.default.resolve(__dirname,"template");try{console.log(h(n,o)),await _(r,e)}catch(i){console.error(b(n,o,i)),process.exit(1)}}var p=a(require("path")),f=a(require("fs/promises")),De=a(require("go-git-it"));async function Fe(e,n,o){let r=p.default.dirname(e),i=p.default.basename(o),c=`https://github.com/extension-js/extension.js/tree/main/examples/${o}`;try{await f.default.mkdir(e,{recursive:!0});let l="";if(process.env.EXTENSION_ENV==="development"?(console.log(h(n,o)),l=p.default.join(e,i),await f.default.cp(p.default.join(__dirname,"..","..","..","examples",i),l,{recursive:!0})):(await(0,De.default)(c,r,h(n,i)),l=p.default.join(r,i)),n!==i){let m=p.default.join(r,n);await f.default.mkdir(m,{recursive:!0});let g=await f.default.readdir(l);for(let u of g)await f.default.rename(p.default.join(l,u),p.default.join(m,u));await f.default.rm(l,{recursive:!0,force:!0})}else{let m=p.default.join(r,n+"-temp");await f.default.rename(l,m);let g=p.default.join(m,i),u=p.default.join(r,n);await f.default.mkdir(u,{recursive:!0});let ze=await f.default.readdir(g);for(let N of ze)await f.default.rename(p.default.join(g,N),p.default.join(u,N));await f.default.rm(m,{recursive:!0,force:!0})}}catch(l){console.error(b(n,i,l)),process.exit(1)}}var v=a(require("path")),P=a(require("fs/promises"));var Ke={dev:process.env.EXTENSION_ENV==="development"?"node node_modules/extension dev":"extension dev",start:process.env.EXTENSION_ENV==="development"?"node node_modules/extension start":"extension start",build:process.env.EXTENSION_ENV==="development"?"node node_modules/extension build":"extension build"};async function Te(e,n,o){let r=ye(process.cwd()),i=he(o)?v.default.join(e,"package.json"):v.default.join(r,"package.json"),s=await P.default.readFile(i),c=JSON.parse(s.toString());c.scripts=c.scripts||{},c.dependencies=c.dependencies||{},c.devDependencies={...c.devDependencies||{},extension:process.env.EXTENSION_ENV==="development"?"*":"latest"};let l={...c,name:v.default.basename(e),private:!0,scripts:{...c.scripts,...Ke},dependencies:c.dependencies,devDependencies:c.devDependencies,author:{name:"Your Name",email:"your@email.com",url:"https://yourwebsite.com"}};try{console.log(ae()),await P.default.writeFile(v.default.join(e,"package.json"),JSON.stringify(l,null,2))}catch(m){console.error(ce(n,m)),process.exit(1)}}var Se=a(require("path")),Pe=require("cross-spawn"),Ie=a(require("fs"));var Ce=a(require("path")),I=require("cross-spawn");async function _e(e){let n=Ce.default.join(__dirname,"../../cli"),o=await y(),r=["link"];await new Promise((i,s)=>{(0,I.spawn)(o,r,{cwd:n}).on("close",()=>{(0,I.spawn)(o,[...r,"extension"],{stdio:"inherit",cwd:e}).on("close",m=>{m===0?(console.log(oe()),i()):s(new Error(se(o,r)))})})}),console.log("Symlink creation completed.")}function Qe(){return["install","--silent"]}async function Je(e,n){let o=Se.default.join(e,"node_modules"),r=await y(),i=Qe();console.log(ne()),process.env.EXTENSION_ENV==="development"&&await _e(e);try{let s=process.cwd();process.chdir(e),await Ie.default.promises.mkdir(o,{recursive:!0});let c=process.env.EXTENSION_ENV==="development"?"inherit":"ignore",l=(0,Pe.spawn)(r,i,{stdio:c});await new Promise((m,g)=>{l.on("close",u=>{process.chdir(s),u!==0?g(new Error(te(r,i,u))):m()}),l.on("error",u=>{process.chdir(s),console.error(ie(n,u)),g(u)})})}catch(s){console.error(re(n,s)),process.exit(1)}}var D=a(require("path")),F=a(require("fs/promises"));async function Me(e,n){let o=await F.default.readFile(D.default.join(__dirname,"template","README.md"),"utf-8"),r=await y(),i=require(D.default.join(e,"manifest.json")),s=o.replaceAll("[projectName]",n).replaceAll("[templateDescription]",i.description).replaceAll("[runCommand]",r);try{console.log(pe()),await F.default.mkdir(e,{recursive:!0}),await F.default.writeFile(D.default.join(e,"README.md"),s)}catch(c){console.error(de(n,c)),process.exit(1)}}var T=a(require("path")),J=a(require("fs/promises"));async function Re(e,n){let o=T.default.join(e,"manifest.json"),r=await J.default.readFile(o),s={...JSON.parse(r.toString()),name:T.default.basename(e),author:"Your Name"};try{console.log(le()),await J.default.writeFile(T.default.join(e,"manifest.json"),JSON.stringify(s,null,2))}catch(c){console.error(me(n,c)),process.exit(1)}}var M=a(require("path")),R=a(require("fs/promises"));async function Ne(e,n){let o=M.default.join(e,"extension-env.d.ts"),r=process.env.EXTENSION_ENV==="development"?M.default.resolve(process.cwd(),"programs/cli/types"):"extension/dist/types",i=`// Required Extension.js types for TypeScript projects.
17
+ ${(0,n.brightGreen)("You are ready")}. Time to hack on your extension!`}function V(e){return`\u{1F423} - Starting a new browser extension named ${(0,n.cyan)(e)}...`}function X(){return"\u{1F91E} - Checking if destination path is writeable..."}function U(){return"\u{1F50E} - Scanning for potential conflicting files..."}function Y(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't create directory ${(0,n.cyan)(e)}:
18
+ ${(0,n.red)(t)}`}function q(e){return`\u{1F537} - Writing type definitions for ${(0,n.cyan)(e)}...`}function H(e){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write the extension type definition.
19
+ ${(0,n.red)(e)}`}function x(e,t){return t==="init"?`\u{1F9F0} - Installing ${(0,n.cyan)(e)}...`:`\u{1F9F0} - Installing ${(0,n.cyan)(e)} from template ${(0,n.magenta)(t)}...`}function b(e,t,o){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't find template ${(0,n.magenta)(t)} for ${(0,n.cyan)(e)}:
20
+ ${(0,n.red)(o)}`}function B(e){return`\u{1F332} - Initializing git repository for ${(0,n.cyan)(e)}...`}function K(e,t,o){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${(0,n.brightYellow)(e)} ${(0,n.brightYellow)(t.join(" "))} failed with exit code ${o}`}function Q(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't initialize ${(0,n.brightYellow)("git")} for ${(0,n.cyan)(e)}:
21
+ ${(0,n.red)(t.message)}`}function Z(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't initialize ${(0,n.brightYellow)("git")} for ${(0,n.cyan)(e)}:
22
+ ${(0,n.red)(t.message||t.toString())}`}function ee(){return"\u{1F6E0} - Installing dependencies... (takes a moment)"}function te(e,t,o){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${e} ${t.join(" ")} failed with exit code ${o}`}function ne(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't install dependencies for ${(0,n.cyan)(e)}:
23
+ ${(0,n.red)(t)}`}function ie(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't install dependencies for ${(0,n.cyan)(e)}:
24
+ ${(0,n.red)(t.message||t.toString())}`}function re(){return`\u{1F4DD} - Writing ${(0,n.brightYellow)("package.json")} metadata...`}function oe(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${(0,n.brightYellow)("package.json")} for ${(0,n.cyan)(e)}:
25
+ ${(0,n.red)(t)}`}function se(){return`\u{1F4DC} - Writing ${(0,n.brightYellow)("manifest.json")} metadata...`}function ae(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${(0,n.brightYellow)("manifest.json")} for ${(0,n.cyan)(e)}:
26
+ ${(0,n.red)(t)}`}function ce(){return`\u{1F4C4} - Writing ${(0,n.brightYellow)("README.md")} metadata...`}function le(){return`\u{1F648} - Writing ${(0,n.brightYellow)(".gitignore")} lines...`}function me(e,t){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write the ${(0,n.brightYellow)("README.md")} file for ${(0,n.cyan)(e)}:
27
+ ${(0,n.red)(t)}`}function pe(e){return`\u{1F91D} - Ensuring ${(0,n.cyan)(e)} folder exists...`}function ge(e){return`${(0,n.red)("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Error while checking directory writability:
28
+ `+(0,n.red)(e)}var h=a(require("fs/promises")),E=a(require("path")),de=require("package-manager-detector");async function C(e,t){let o=await h.default.readdir(e,{withFileTypes:!0});return await h.default.mkdir(t,{recursive:!0}),await Promise.all(o.map(async r=>{let i=E.default.join(e,r.name),s=E.default.join(t,r.name);r.isDirectory()?await C(i,s):await h.default.copyFile(i,s)}))}async function D(){let e=await(0,de.detect)(),t="npm";if(process.env.npm_config_user_agent&&process.env.npm_config_user_agent.includes("pnpm"))return"pnpm";switch(e?.name){case"yarn":t="yarn";break;case"pnpm":t="pnpm";break;default:t="npm"}return t}function fe(e){let t=E.default.resolve(__dirname,"template");return E.default.resolve(e,t)}async function ue(e,t){try{return console.log(pe(t)),await h.default.mkdir(e,{recursive:!0}),!0}catch(o){return console.log(ge(o)),!1}}function we(e){return e!=="init"}function ye(e){return e.includes("typescript")||e.includes("react")||e.includes("preact")||e.includes("svelte")||e.includes("solid")}var xe=a(require("path")),P=a(require("fs/promises"));var Xe=["LICENSE","node_modules"];async function he(e,t){console.log(V(t));try{let o=await ue(e,t);console.log(X()),o||(console.error(G(e)),process.exit(1));let r=await P.default.readdir(e);console.log(U());let i=await Promise.all(r.filter(s=>!s.startsWith(".")).filter(s=>!s.endsWith(".log")).filter(s=>!Xe.includes(s)).map(async s=>(await P.default.lstat(xe.default.join(e,s))).isDirectory()?`${s}/`:`${s}`));if(i.length>0){let s=await W(e,i);throw new Error(s)}}catch(o){console.error(Y(t,o)),process.exit(1)}}var Ee=a(require("path"));async function $e(e,t,o){let r=Ee.default.resolve(__dirname,"template");try{console.log(x(t,o)),await C(r,e)}catch(i){console.error(b(t,o,i)),process.exit(1)}}var m=a(require("path")),f=a(require("fs/promises")),ve=a(require("go-git-it"));async function be(e,t,o){let r=m.default.dirname(e),i=m.default.basename(o),c=`https://github.com/extension-js/extension.js/tree/main/examples/${o}`;try{await f.default.mkdir(e,{recursive:!0});let l="";if(process.env.EXTENSION_ENV==="development"?(console.log(x(t,o)),l=m.default.join(e,i),await f.default.cp(m.default.join(__dirname,"..","..","..","examples",i),l,{recursive:!0})):(await(0,ve.default)(c,r,x(t,i)),l=m.default.join(r,i)),t!==i){let p=m.default.join(r,t);await f.default.mkdir(p,{recursive:!0});let g=await f.default.readdir(l);for(let u of g)await f.default.rename(m.default.join(l,u),m.default.join(p,u));await f.default.rm(l,{recursive:!0,force:!0})}else{let p=m.default.join(r,t+"-temp");await f.default.rename(l,p);let g=m.default.join(p,i),u=m.default.join(r,t);await f.default.mkdir(u,{recursive:!0});let je=await f.default.readdir(g);for(let R of je)await f.default.rename(m.default.join(g,R),m.default.join(u,R));await f.default.rm(p,{recursive:!0,force:!0})}}catch(l){console.error(b(t,i,l)),process.exit(1)}}var $=a(require("path")),S=a(require("fs/promises"));var Ue={dev:process.env.EXTENSION_ENV==="development"?"node node_modules/extension dev":"extension dev",start:process.env.EXTENSION_ENV==="development"?"node node_modules/extension start":"extension start",build:process.env.EXTENSION_ENV==="development"?"node node_modules/extension build":"extension build"};async function De(e,t,o){let r=fe(process.cwd()),i=we(o)?$.default.join(e,"package.json"):$.default.join(r,"package.json"),s=await S.default.readFile(i),c=JSON.parse(s.toString());c.scripts=c.scripts||{},c.dependencies=c.dependencies||{},c.devDependencies={...c.devDependencies||{},extension:process.env.EXTENSION_ENV==="development"?"*":"latest"};let l={...c,name:$.default.basename(e),private:!0,scripts:{...c.scripts,...Ue},dependencies:c.dependencies,devDependencies:c.devDependencies,author:{name:"Your Name",email:"your@email.com",url:"https://yourwebsite.com"}};try{console.log(re()),await S.default.writeFile($.default.join(e,"package.json"),JSON.stringify(l,null,2))}catch(p){console.error(oe(t,p)),process.exit(1)}}var Fe=a(require("path")),Te=require("cross-spawn"),ke=a(require("fs"));function Ye(){return["install","--silent"]}async function _e(e,t){let o=Fe.default.join(e,"node_modules"),r=await D(),i=Ye();console.log(ee());try{let s=process.cwd();process.chdir(e),await ke.default.promises.mkdir(o,{recursive:!0});let c=process.env.EXTENSION_ENV==="development"?"inherit":"ignore",l=(0,Te.spawn)(r,i,{stdio:c});await new Promise((p,g)=>{l.on("close",u=>{process.chdir(s),u!==0?g(new Error(te(r,i,u))):p()}),l.on("error",u=>{process.chdir(s),console.error(ne(t,u)),g(u)})})}catch(s){console.error(ie(t,s)),process.exit(1)}}var F=a(require("path")),T=a(require("fs/promises"));async function Ce(e,t){let o=await T.default.readFile(F.default.join(__dirname,"template","README.md"),"utf-8"),r=await D(),i=require(F.default.join(e,"manifest.json")),s=o.replaceAll("[projectName]",t).replaceAll("[templateDescription]",i.description).replaceAll("[runCommand]",r);try{console.log(ce()),await T.default.mkdir(e,{recursive:!0}),await T.default.writeFile(F.default.join(e,"README.md"),s)}catch(c){console.error(me(t,c)),process.exit(1)}}var k=a(require("path")),I=a(require("fs/promises"));async function Pe(e,t){let o=k.default.join(e,"manifest.json"),r=await I.default.readFile(o),s={...JSON.parse(r.toString()),name:k.default.basename(e),author:"Your Name"};try{console.log(se()),await I.default.writeFile(k.default.join(e,"manifest.json"),JSON.stringify(s,null,2))}catch(c){console.error(ae(t,c)),process.exit(1)}}var J=a(require("path")),M=a(require("fs/promises"));async function Se(e,t){let o=J.default.join(e,"extension-env.d.ts"),r=process.env.EXTENSION_ENV==="development"?J.default.resolve(process.cwd(),"programs/cli/types"):"extension/dist/types",i=`// Required Extension.js types for TypeScript projects.
29
29
  // This file is auto-generated and should not be excluded.
30
30
  // If you need additional types, consider creating a new *.d.ts file and
31
31
  // referencing it in the "include" array of your tsconfig.json file.
@@ -34,5 +34,5 @@ ${(0,t.red)(n)}`}function fe(e){return`\u{1F91D} - Ensuring ${(0,t.cyan)(e)} fol
34
34
 
35
35
  // Polyfill types for browser.* APIs.
36
36
  /// <reference types="${r}/polyfill.d.ts" />
37
- `;try{await R.default.mkdir(e,{recursive:!0}),console.log(H(n)),await R.default.writeFile(o,i)}catch(s){console.error(B(s)),process.exit(1)}}var je=a(require("fs/promises")),Ae=a(require("path"));var Ze=["","# dependencies","node_modules"],en=["","# testing","coverage"],nn=["","# production","dist"],tn=["","# misc",".DS_Store"],rn=["","# local env files",".env.local",".env.development.local",".env.test.local",".env.production.local"],on=["","# debug files","npm-debug.log*","yarn-debug.log*","yarn-error.log*"],sn=["","# lock files","yarn.lock","package-lock.json"],an=["","# extension.js","extension-env.d.ts"],cn=["# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.",...Ze,...en,...nn,...tn,...rn,...sn,...on,...an];async function Ge(e){let n=Ae.default.join(e,".gitignore"),o=await je.default.open(n,"a+").catch(s=>{console.error(s),process.exit(1)}),r=new Set;for await(let s of o.readLines({autoClose:!1}))s=s.trim(),s.length!==0&&r.add(s);let i=cn.filter(s=>!r.has(s));for(;i[i.length-1]==="";)i.pop();console.log(ge()),await o.appendFile(i.join(`
38
- `),{flush:!0}).catch(s=>{console.error(s),process.exit(1)})}var Oe=require("cross-spawn");async function We(e,n){let o="git",r=["init","--quiet"];console.log(K(n));try{let i=process.cwd();process.chdir(e);let s=process.env.EXTENSION_ENV==="development"?"inherit":"ignore",c=(0,Oe.spawn)(o,r,{stdio:s});await new Promise((l,m)=>{c.on("close",g=>{process.chdir(i),g!==0?m(new Error(Q(o,r,g))):l()}),c.on("error",g=>{process.chdir(i),console.error(Z(n,g)),m(g)})})}catch(i){console.error(ee(n,i)),process.exit(1)}}async function ln(e,{template:n="init",install:o=!0}){if(!e)throw new Error(z());if(e.startsWith("http"))throw new Error(V());let r=C.default.isAbsolute(e)?e:C.default.join(process.cwd(),e),i=C.default.basename(r);try{await ve(r,i),n==="init"?await be(r,i,n):await Fe(r,i,n),await Te(r,i,n),o&&await Je(r,i),await Me(r,i),await Re(r,i),await We(r,i),await Ge(r),Ee(n)&&await Ne(r,i);let s=await X(r,i);console.log(s)}catch(s){throw console.error(s),s}}0&&(module.exports={extensionCreate});
37
+ `;try{await M.default.mkdir(e,{recursive:!0}),console.log(q(t)),await M.default.writeFile(o,i)}catch(s){console.error(H(s)),process.exit(1)}}var Ie=a(require("fs/promises")),Je=a(require("path"));var qe=["","# dependencies","node_modules"],He=["","# testing","coverage"],Be=["","# production","dist"],Ke=["","# misc",".DS_Store"],Qe=["","# local env files",".env.local",".env.development.local",".env.test.local",".env.production.local"],Ze=["","# debug files","npm-debug.log*","yarn-debug.log*","yarn-error.log*"],et=["","# lock files","yarn.lock","package-lock.json"],tt=["","# extension.js","extension-env.d.ts"],nt=["# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.",...qe,...He,...Be,...Ke,...Qe,...et,...Ze,...tt];async function Me(e){let t=Je.default.join(e,".gitignore"),o=await Ie.default.open(t,"a+").catch(s=>{console.error(s),process.exit(1)}),r=new Set;for await(let s of o.readLines({autoClose:!1}))s=s.trim(),s.length!==0&&r.add(s);let i=nt.filter(s=>!r.has(s));for(;i[i.length-1]==="";)i.pop();console.log(le()),await o.appendFile(i.join(`
38
+ `),{flush:!0}).catch(s=>{console.error(s),process.exit(1)})}var Re=require("cross-spawn");async function Ne(e,t){let o="git",r=["init","--quiet"];console.log(B(t));try{let i=process.cwd();process.chdir(e);let s=process.env.EXTENSION_ENV==="development"?"inherit":"ignore",c=(0,Re.spawn)(o,r,{stdio:s});await new Promise((l,p)=>{c.on("close",g=>{process.chdir(i),g!==0?p(new Error(K(o,r,g))):l()}),c.on("error",g=>{process.chdir(i),console.error(Q(t,g)),p(g)})})}catch(i){console.error(Z(t,i)),process.exit(1)}}async function it(e,{template:t="init",install:o=!0}){if(!e)throw new Error(O());if(e.startsWith("http"))throw new Error(z());let r=_.default.isAbsolute(e)?e:_.default.join(process.cwd(),e),i=_.default.basename(r);try{await he(r,i),t==="init"?await $e(r,i,t):await be(r,i,t),await De(r,i,t),o&&await _e(r,i),await Ce(r,i),await Pe(r,i),await Ne(r,i),await Me(r),ye(t)&&await Se(r,i);let s=await L(r,i);console.log(s)}catch(s){throw console.error(s),s}}0&&(module.exports={extensionCreate});
@@ -0,0 +1,35 @@
1
+ # test-template-config-babel
2
+
3
+ > An Extension.js example.
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run the following scripts:
8
+
9
+ ### pnpm dev
10
+
11
+ **Development Mode**: This command runs your extension in development mode. It will launch a new browser instance with your extension loaded. The page will automatically reload whenever you make changes to your code, allowing for a smooth development experience.
12
+
13
+ ```bash
14
+ pnpm dev
15
+ ```
16
+
17
+ ### pnpm start
18
+
19
+ **Production Preview**: This command runs your extension in production mode. It will launch a new browser instance with your extension loaded, simulating the environment and behavior of your extension as it will appear once published.
20
+
21
+ ```bash
22
+ pnpm start
23
+ ```
24
+
25
+ ### pnpm build
26
+
27
+ **Build for Production**: This command builds your extension for production. It optimizes and bundles your extension, preparing it for deployment to the target browser's store.
28
+
29
+ ```bash
30
+ pnpm build
31
+ ```
32
+
33
+ ## Learn More
34
+
35
+ To learn more about creating cross-browser extensions with Extension.js, visit the [official documentation](https://extension.js.org).
@@ -0,0 +1,4 @@
1
+ {
2
+ "presets": ["modern-browser-extension"],
3
+ "plugins": []
4
+ }
@@ -0,0 +1,17 @@
1
+ /** @type {import('extension-develop').FileConfig} */
2
+ module.exports = {
3
+ config: (config) => {
4
+ config.module.rules.push(
5
+ // https://webpack.js.org/loaders/babel-loader/
6
+ // https://babeljs.io/docs/en/babel-loader
7
+ {
8
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
9
+ include: __dirname,
10
+ exclude: /node_modules/,
11
+ loader: require.resolve('babel-loader')
12
+ }
13
+ )
14
+
15
+ return config
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "version": "0.0.1",
4
+ "name": "test-template-config-babel",
5
+ "description": "An Extension.js example.",
6
+ "icons": {
7
+ "16": "images/extension_16.png",
8
+ "48": "images/extension_48.png",
9
+ "128": "images/extension_128.png"
10
+ },
11
+ "chrome_url_overrides": {
12
+ "newtab": "newtab/index.html"
13
+ },
14
+ "author": "Your Name"
15
+ }
@@ -0,0 +1,40 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Babel Extension</title>
7
+ <link
8
+ rel="stylesheet"
9
+ href="https://unpkg.com/sakura.css/css/sakura.css"
10
+ media="screen"
11
+ />
12
+ <link
13
+ rel="stylesheet"
14
+ href="https://unpkg.com/sakura.css/css/sakura-dark.css"
15
+ media="screen and (prefers-color-scheme: dark)"
16
+ />
17
+ <link rel="stylesheet" href="./styles.css" media="screen" />
18
+ </head>
19
+ <body>
20
+ <header>
21
+ <h1>
22
+ <img
23
+ class="babel"
24
+ src="../images/babel.png"
25
+ alt="The Babel logo"
26
+ width="120px"
27
+ />
28
+ <br />
29
+ Welcome to your Babel Extension
30
+ </h1>
31
+ <p>
32
+ Learn more about creating cross-browser extensions at
33
+ <a href="https://extension.js.org" target="_blank"
34
+ >https://extension.js.org</a
35
+ >.
36
+ </p>
37
+ </header>
38
+ </body>
39
+ <script src="./scripts.js"></script>
40
+ </html>
@@ -0,0 +1,11 @@
1
+ function getManifest() {
2
+ return chrome.runtime.getManifest()
3
+ }
4
+
5
+ const manifest = getManifest()
6
+
7
+ console.table({
8
+ name: manifest.name,
9
+ version: manifest.version,
10
+ description: manifest.description
11
+ })
@@ -0,0 +1,22 @@
1
+ body {
2
+ display: flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ height: calc(100vh - 26px);
6
+ }
7
+
8
+ h1 {
9
+ font-size: 4.7em;
10
+ }
11
+
12
+ .babel:hover {
13
+ filter: grayscale(1);
14
+ transition:
15
+ filter 2s,
16
+ border-color 2s;
17
+ }
18
+
19
+ .new:hover {
20
+ filter: grayscale(0);
21
+ border-color: aquamarine;
22
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "private": true,
3
+ "name": "test-template-config-babel",
4
+ "description": "An Extension.js example.",
5
+ "version": "0.0.1",
6
+ "author": {
7
+ "name": "Your Name",
8
+ "email": "your@email.com",
9
+ "url": "https://yourwebsite.com"
10
+ },
11
+ "devDependencies": {
12
+ "@babel/core": "^7.24.9",
13
+ "babel-loader": "^9.1.3",
14
+ "babel-preset-modern-browser-extension": "^0.7.0",
15
+ "stylelint": "^16.7.0",
16
+ "extension": "latest"
17
+ },
18
+ "scripts": {
19
+ "dev": "extension dev",
20
+ "start": "extension start",
21
+ "build": "extension build"
22
+ },
23
+ "dependencies": {}
24
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "stylelint-config-standard-scss"
3
+ }
@@ -14,7 +14,7 @@
14
14
  href="https://unpkg.com/sakura.css/css/sakura-dark.css"
15
15
  media="screen and (prefers-color-scheme: dark)"
16
16
  />
17
- <link rel="stylesheet" href="./styles.css" media="screen" />
17
+ <link rel="stylesheet" href="./styles.scss" media="screen" />
18
18
  </head>
19
19
  <body>
20
20
  <header>
@@ -9,14 +9,15 @@
9
9
  "url": "https://yourwebsite.com"
10
10
  },
11
11
  "scripts": {
12
- "lint:css": "stylelint '**/*.css'",
12
+ "lint:css": "npx stylelint '**/*.scss'",
13
13
  "dev": "extension dev",
14
14
  "start": "extension start",
15
15
  "build": "extension build"
16
16
  },
17
17
  "devDependencies": {
18
+ "sass": "^1.77.8",
18
19
  "stylelint": "^16.7.0",
19
- "stylelint-config-standard": "^36.0.1",
20
+ "stylelint-config-standard-scss": "^13.1.0",
20
21
  "extension": "latest"
21
22
  },
22
23
  "dependencies": {}
@@ -0,0 +1,35 @@
1
+ # test-template-content-extension-config
2
+
3
+ > An Extension.js example.
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run the following scripts:
8
+
9
+ ### pnpm dev
10
+
11
+ **Development Mode**: This command runs your extension in development mode. It will launch a new browser instance with your extension loaded. The page will automatically reload whenever you make changes to your code, allowing for a smooth development experience.
12
+
13
+ ```bash
14
+ pnpm dev
15
+ ```
16
+
17
+ ### pnpm start
18
+
19
+ **Production Preview**: This command runs your extension in production mode. It will launch a new browser instance with your extension loaded, simulating the environment and behavior of your extension as it will appear once published.
20
+
21
+ ```bash
22
+ pnpm start
23
+ ```
24
+
25
+ ### pnpm build
26
+
27
+ **Build for Production**: This command builds your extension for production. It optimizes and bundles your extension, preparing it for deployment to the target browser's store.
28
+
29
+ ```bash
30
+ pnpm build
31
+ ```
32
+
33
+ ## Learn More
34
+
35
+ To learn more about creating cross-browser extensions with Extension.js, visit the [official documentation](https://extension.js.org).
@@ -0,0 +1 @@
1
+ console.log('Hello from the background script!')
@@ -0,0 +1,82 @@
1
+ import React from 'react'
2
+ import ReactLogo from '../images/logo.svg'
3
+ import tailwindBg from '../images/tailwind_bg.png'
4
+ import typescriptLogo from '../images/typescript.png'
5
+ import tailwindLogo from '../images/tailwind.png'
6
+ import chromeWindowBg from '../images/chromeWindow.png'
7
+
8
+ export default function ContentApp() {
9
+ const [isdialogOpen, setIsDialogOpen] = React.useState(true)
10
+
11
+ if (!isdialogOpen) {
12
+ return (
13
+ <div className="mx-auto p-6">
14
+ <button
15
+ onClick={() => setIsDialogOpen(true)}
16
+ className="bg-white rounded-md p-3 text-sm font-semibold text-gray-900 shadow-sm hover:bg-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
17
+ >
18
+ 🧩 Open content script hint <span aria-hidden="true">+</span>
19
+ </button>
20
+ </div>
21
+ )
22
+ }
23
+
24
+ return (
25
+ <div className="mx-auto max-w-7xl md:px-0 lg:p-6">
26
+ <div className="relative isolate overflow-hidden bg-gray-900 px-6 pt-16 shadow-2xl lg:rounded-3xl md:pt-24 md:h-full sm:h-[100vh] lg:flex lg:gap-x-20 lg:px-24 lg:pt-0">
27
+ <div className="absolute z-20 top-0 inset-x-0 flex justify-center overflow-hidden pointer-events-none">
28
+ <div className="w-[108rem] flex-none flex justify-end">
29
+ <picture>
30
+ <img
31
+ src={tailwindBg}
32
+ alt=""
33
+ className="w-[90rem] flex-none max-w-none hidden dark:block"
34
+ decoding="async"
35
+ />
36
+ </picture>
37
+ </div>
38
+ </div>
39
+ <div className="mx-auto max-w-md text-center lg:py-12 lg:mx-0 lg:flex-auto lg:text-left">
40
+ <div className="flex items-center justify-center space-x-4 my-4 mx-auto">
41
+ <ReactLogo className="relative inline-block w-12" />
42
+ <div className="text-3xl text-white">+</div>
43
+ <img
44
+ alt="TypeScript logo"
45
+ src={typescriptLogo}
46
+ className="relative inline-block w-12"
47
+ />
48
+ <div className="text-3xl text-white">+</div>
49
+ <img
50
+ alt="Tailwind logo"
51
+ src={tailwindLogo}
52
+ className="relative inline-block w-12"
53
+ />
54
+ </div>
55
+ <h2 className="text-3xl font-bold tracking-tight text-white sm:text-4xl">
56
+ This is a content script running React, TypeScript, and Tailwind.css
57
+ </h2>
58
+ <p className="mt-6 text-lg leading-8 text-gray-300">
59
+ Learn more about creating cross-browser extensions by{' '}
60
+ <button
61
+ onClick={() => setIsDialogOpen(false)}
62
+ className="underline hover:no-underline
63
+ "
64
+ >
65
+ closing this hint
66
+ </button>
67
+ .
68
+ </p>
69
+ </div>
70
+ <div className="relative mt-16 h-80 lg:mt-8">
71
+ <img
72
+ className="absolute left-0 top-0 w-[57rem] max-w-none rounded-md bg-white/5 ring-1 ring-white/10"
73
+ src={chromeWindowBg}
74
+ alt="Chrome window screenshot"
75
+ width="1824"
76
+ height="1080"
77
+ />
78
+ </div>
79
+ </div>
80
+ </div>
81
+ )
82
+ }
@@ -0,0 +1,17 @@
1
+ import ReactDOM from 'react-dom/client'
2
+ import ContentApp from './ContentApp'
3
+ import './styles.css'
4
+
5
+ setTimeout(initial, 1000)
6
+
7
+ function initial() {
8
+ // Create a new div element and append it to the document's body
9
+ const rootDiv = document.createElement('div')
10
+ rootDiv.id = 'extension-root'
11
+ document.body.appendChild(rootDiv)
12
+
13
+ // Use `createRoot` to create a root, then render the <App /> component
14
+ // Note that `createRoot` takes the container DOM node, not the React element
15
+ const root = ReactDOM.createRoot(rootDiv)
16
+ root.render(<ContentApp />)
17
+ }
@@ -0,0 +1,10 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ #extension-root {
6
+ position: fixed;
7
+ bottom: 0;
8
+ right: 0;
9
+ z-index: 99999;
10
+ }
@@ -0,0 +1,22 @@
1
+ /** @type {import('extension-develop').FileConfig} */
2
+ module.exports = {
3
+ config: (config) => {
4
+ config.module.rules.push(
5
+ {
6
+ test: /\.svg$/i,
7
+ type: 'asset',
8
+ // *.svg?url
9
+ resourceQuery: /url/
10
+ },
11
+ {
12
+ test: /\.svg$/i,
13
+ issuer: /\.[jt]sx?$/,
14
+ // exclude react component if *.svg?url
15
+ resourceQuery: {not: [/url/]},
16
+ use: ['@svgr/webpack']
17
+ }
18
+ )
19
+
20
+ return config
21
+ }
22
+ }
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="-11.5 -10.23174 23 20.46348">
2
+ <title>React Logo</title>
3
+ <circle cx="0" cy="0" r="2.05" fill="#61dafb"/>
4
+ <g stroke="#61dafb" stroke-width="1" fill="none">
5
+ <ellipse rx="11" ry="4.2"/>
6
+ <ellipse rx="11" ry="4.2" transform="rotate(60)"/>
7
+ <ellipse rx="11" ry="4.2" transform="rotate(120)"/>
8
+ </g>
9
+ </svg>
@@ -0,0 +1,28 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "version": "0.0.1",
4
+ "name": "test-template-content-extension-config",
5
+ "description": "An Extension.js example.",
6
+ "background": {
7
+ "chromium:service_worker": "background.ts",
8
+ "firefox:scripts": [
9
+ "background.ts"
10
+ ]
11
+ },
12
+ "content_scripts": [
13
+ {
14
+ "matches": [
15
+ "https://extension.js.org/*"
16
+ ],
17
+ "js": [
18
+ "./content/scripts.tsx"
19
+ ]
20
+ }
21
+ ],
22
+ "icons": {
23
+ "16": "images/extension_16.png",
24
+ "48": "images/extension_48.png",
25
+ "128": "images/extension_128.png"
26
+ },
27
+ "author": "Your Name"
28
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "private": true,
3
+ "license": "MIT",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/cezaraugusto/extension.git",
7
+ "directory": "programs/create/templates/content-extension-config"
8
+ },
9
+ "name": "test-template-content-extension-config",
10
+ "description": "An Extension.js example.",
11
+ "version": "0.0.1",
12
+ "author": {
13
+ "name": "Your Name",
14
+ "email": "your@email.com",
15
+ "url": "https://yourwebsite.com"
16
+ },
17
+ "dependencies": {
18
+ "@svgr/webpack": "^8.1.0",
19
+ "react": "^18.1.0",
20
+ "react-dom": "^18.1.0",
21
+ "tailwindcss": "^3.4.1"
22
+ },
23
+ "devDependencies": {
24
+ "@types/react": "^18.0.9",
25
+ "@types/react-dom": "^18.0.5",
26
+ "typescript": "5.3.3",
27
+ "extension": "latest"
28
+ },
29
+ "scripts": {
30
+ "dev": "extension dev",
31
+ "start": "extension start",
32
+ "build": "extension build"
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {}
5
+ }
6
+ }
@@ -0,0 +1,8 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ['./content/**/*.tsx'],
4
+ theme: {
5
+ extend: {}
6
+ },
7
+ plugins: []
8
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "isolatedModules": true,
8
+ "jsx": "react-jsx",
9
+ "lib": ["dom", "dom.iterable", "esnext"],
10
+ "moduleResolution": "node",
11
+ "module": "esnext",
12
+ "noEmit": true,
13
+ "resolveJsonModule": true,
14
+ "strict": true,
15
+ "target": "esnext",
16
+ "verbatimModuleSyntax": true,
17
+ "useDefineForClassFields": true,
18
+ "skipLibCheck": true
19
+ },
20
+ "include": ["./"],
21
+ "exclude": ["node_modules", "dist"]
22
+ }
@@ -0,0 +1,35 @@
1
+ # test-template-content-react-svgr
2
+
3
+ > An Extension.js example.
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run the following scripts:
8
+
9
+ ### pnpm dev
10
+
11
+ **Development Mode**: This command runs your extension in development mode. It will launch a new browser instance with your extension loaded. The page will automatically reload whenever you make changes to your code, allowing for a smooth development experience.
12
+
13
+ ```bash
14
+ pnpm dev
15
+ ```
16
+
17
+ ### pnpm start
18
+
19
+ **Production Preview**: This command runs your extension in production mode. It will launch a new browser instance with your extension loaded, simulating the environment and behavior of your extension as it will appear once published.
20
+
21
+ ```bash
22
+ pnpm start
23
+ ```
24
+
25
+ ### pnpm build
26
+
27
+ **Build for Production**: This command builds your extension for production. It optimizes and bundles your extension, preparing it for deployment to the target browser's store.
28
+
29
+ ```bash
30
+ pnpm build
31
+ ```
32
+
33
+ ## Learn More
34
+
35
+ To learn more about creating cross-browser extensions with Extension.js, visit the [official documentation](https://extension.js.org).
@@ -0,0 +1 @@
1
+ console.log('Hello from the background script!')
@@ -0,0 +1,82 @@
1
+ import React from 'react'
2
+ import ReactLogo from '../images/logo.svg'
3
+ import tailwindBg from '../images/tailwind_bg.png'
4
+ import typescriptLogo from '../images/typescript.png'
5
+ import tailwindLogo from '../images/tailwind.png'
6
+ import chromeWindowBg from '../images/chromeWindow.png'
7
+
8
+ export default function ContentApp() {
9
+ const [isdialogOpen, setIsDialogOpen] = React.useState(true)
10
+
11
+ if (!isdialogOpen) {
12
+ return (
13
+ <div className="mx-auto p-6">
14
+ <button
15
+ onClick={() => setIsDialogOpen(true)}
16
+ className="bg-white rounded-md p-3 text-sm font-semibold text-gray-900 shadow-sm hover:bg-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white"
17
+ >
18
+ 🧩 Open content script hint <span aria-hidden="true">+</span>
19
+ </button>
20
+ </div>
21
+ )
22
+ }
23
+
24
+ return (
25
+ <div className="mx-auto max-w-7xl md:px-0 lg:p-6">
26
+ <div className="relative isolate overflow-hidden bg-gray-900 px-6 pt-16 shadow-2xl lg:rounded-3xl md:pt-24 md:h-full sm:h-[100vh] lg:flex lg:gap-x-20 lg:px-24 lg:pt-0">
27
+ <div className="absolute z-20 top-0 inset-x-0 flex justify-center overflow-hidden pointer-events-none">
28
+ <div className="w-[108rem] flex-none flex justify-end">
29
+ <picture>
30
+ <img
31
+ src={tailwindBg}
32
+ alt=""
33
+ className="w-[90rem] flex-none max-w-none hidden dark:block"
34
+ decoding="async"
35
+ />
36
+ </picture>
37
+ </div>
38
+ </div>
39
+ <div className="mx-auto max-w-md text-center lg:py-12 lg:mx-0 lg:flex-auto lg:text-left">
40
+ <div className="flex items-center justify-center space-x-4 my-4 mx-auto">
41
+ <ReactLogo className="relative inline-block w-12" />
42
+ <div className="text-3xl text-white">+</div>
43
+ <img
44
+ alt="TypeScript logo"
45
+ src={typescriptLogo}
46
+ className="relative inline-block w-12"
47
+ />
48
+ <div className="text-3xl text-white">+</div>
49
+ <img
50
+ alt="Tailwind logo"
51
+ src={tailwindLogo}
52
+ className="relative inline-block w-12"
53
+ />
54
+ </div>
55
+ <h2 className="text-3xl font-bold tracking-tight text-white sm:text-4xl">
56
+ This is a content script running React, TypeScript, and Tailwind.css
57
+ </h2>
58
+ <p className="mt-6 text-lg leading-8 text-gray-300">
59
+ Learn more about creating cross-browser extensions by{' '}
60
+ <button
61
+ onClick={() => setIsDialogOpen(false)}
62
+ className="underline hover:no-underline
63
+ "
64
+ >
65
+ closing this hint
66
+ </button>
67
+ .
68
+ </p>
69
+ </div>
70
+ <div className="relative mt-16 h-80 lg:mt-8">
71
+ <img
72
+ className="absolute left-0 top-0 w-[57rem] max-w-none rounded-md bg-white/5 ring-1 ring-white/10"
73
+ src={chromeWindowBg}
74
+ alt="Chrome window screenshot"
75
+ width="1824"
76
+ height="1080"
77
+ />
78
+ </div>
79
+ </div>
80
+ </div>
81
+ )
82
+ }
@@ -0,0 +1,17 @@
1
+ import ReactDOM from 'react-dom/client'
2
+ import ContentApp from './ContentApp'
3
+ import './styles.css'
4
+
5
+ setTimeout(initial, 1000)
6
+
7
+ function initial() {
8
+ // Create a new div element and append it to the document's body
9
+ const rootDiv = document.createElement('div')
10
+ rootDiv.id = 'extension-root'
11
+ document.body.appendChild(rootDiv)
12
+
13
+ // Use `createRoot` to create a root, then render the <App /> component
14
+ // Note that `createRoot` takes the container DOM node, not the React element
15
+ const root = ReactDOM.createRoot(rootDiv)
16
+ root.render(<ContentApp />)
17
+ }
@@ -0,0 +1,10 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ #extension-root {
6
+ position: fixed;
7
+ bottom: 0;
8
+ right: 0;
9
+ z-index: 99999;
10
+ }
@@ -0,0 +1,22 @@
1
+ /** @type {import('extension-develop').FileConfig} */
2
+ module.exports = {
3
+ config: (config) => {
4
+ config.module.rules.push(
5
+ {
6
+ test: /\.svg$/i,
7
+ type: 'asset',
8
+ // *.svg?url
9
+ resourceQuery: /url/
10
+ },
11
+ {
12
+ test: /\.svg$/i,
13
+ issuer: /\.[jt]sx?$/,
14
+ // exclude react component if *.svg?url
15
+ resourceQuery: {not: [/url/]},
16
+ use: ['@svgr/webpack']
17
+ }
18
+ )
19
+
20
+ return config
21
+ }
22
+ }
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="-11.5 -10.23174 23 20.46348">
2
+ <title>React Logo</title>
3
+ <circle cx="0" cy="0" r="2.05" fill="#61dafb"/>
4
+ <g stroke="#61dafb" stroke-width="1" fill="none">
5
+ <ellipse rx="11" ry="4.2"/>
6
+ <ellipse rx="11" ry="4.2" transform="rotate(60)"/>
7
+ <ellipse rx="11" ry="4.2" transform="rotate(120)"/>
8
+ </g>
9
+ </svg>
@@ -0,0 +1,28 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "version": "0.0.1",
4
+ "name": "test-template-content-react-svgr",
5
+ "description": "An Extension.js example.",
6
+ "background": {
7
+ "chromium:service_worker": "background.ts",
8
+ "firefox:scripts": [
9
+ "background.ts"
10
+ ]
11
+ },
12
+ "content_scripts": [
13
+ {
14
+ "matches": [
15
+ "https://extension.js.org/*"
16
+ ],
17
+ "js": [
18
+ "./content/scripts.tsx"
19
+ ]
20
+ }
21
+ ],
22
+ "icons": {
23
+ "16": "images/extension_16.png",
24
+ "48": "images/extension_48.png",
25
+ "128": "images/extension_128.png"
26
+ },
27
+ "author": "Your Name"
28
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "private": true,
3
+ "license": "MIT",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/cezaraugusto/extension.git",
7
+ "directory": "programs/create/templates/content-react-svgr"
8
+ },
9
+ "name": "test-template-content-react-svgr",
10
+ "description": "An Extension.js example.",
11
+ "version": "0.0.1",
12
+ "author": {
13
+ "name": "Your Name",
14
+ "email": "your@email.com",
15
+ "url": "https://yourwebsite.com"
16
+ },
17
+ "dependencies": {
18
+ "@svgr/webpack": "^8.1.0",
19
+ "react": "^18.1.0",
20
+ "react-dom": "^18.1.0",
21
+ "tailwindcss": "^3.4.1"
22
+ },
23
+ "devDependencies": {
24
+ "@types/react": "^18.0.9",
25
+ "@types/react-dom": "^18.0.5",
26
+ "typescript": "5.3.3",
27
+ "extension": "latest"
28
+ },
29
+ "scripts": {
30
+ "dev": "extension dev",
31
+ "start": "extension start",
32
+ "build": "extension build"
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {}
5
+ }
6
+ }
@@ -0,0 +1,8 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ['./content/**/*.tsx'],
4
+ theme: {
5
+ extend: {}
6
+ },
7
+ plugins: []
8
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "isolatedModules": true,
8
+ "jsx": "react-jsx",
9
+ "lib": ["dom", "dom.iterable", "esnext"],
10
+ "moduleResolution": "node",
11
+ "module": "esnext",
12
+ "noEmit": true,
13
+ "resolveJsonModule": true,
14
+ "strict": true,
15
+ "target": "esnext",
16
+ "verbatimModuleSyntax": true,
17
+ "useDefineForClassFields": true,
18
+ "skipLibCheck": true
19
+ },
20
+ "include": ["./"],
21
+ "exclude": ["node_modules", "dist"]
22
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node": ">=18"
10
10
  },
11
11
  "name": "extension-create",
12
- "version": "2.0.0-alpha.24",
12
+ "version": "2.0.0-alpha.27",
13
13
  "description": "The Extension.js create step",
14
14
  "main": "./dist/module.js",
15
15
  "types": "./dist/module.d.ts",
@@ -1 +0,0 @@
1
- {"extends": ["stylelint-config-standard"]}