Skip to content

Commit

Permalink
feat: migrate to wxt
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartek532 committed Nov 19, 2024
1 parent 4ba47f9 commit 9a3d960
Show file tree
Hide file tree
Showing 54 changed files with 391 additions and 592 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Supabase
PLASMO_PUBLIC_SUPABASE_URL=""
PLASMO_PUBLIC_SUPABASE_ANON_KEY=""
VITE_SUPABASE_URL=""
VITE_SUPABASE_ANON_KEY=""

# OpenPanel Analytics
PLASMO_PUBLIC_OPEN_PANEL_KEY=""
VITE_OPEN_PANEL_KEY=""
21 changes: 14 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: chrome-${{ github.sha }}
path: build/chrome-mv3-prod
path: build/*-chrome.zip

- name: 🗃️ Archive Firefox artifact
uses: actions/upload-artifact@v4
with:
name: firefox-${{ github.sha }}
path: build/firefox-mv2-prod
path: build/*-firefox.zip

- name: 💨 Publish!
uses: PlasmoHQ/bpp@v3
with:
chrome-file: build/chrome-mv3-prod.zip
firefox-file: build/firefox-mv2-prod.zip
keys: ${{ secrets.SUBMIT_KEYS }}
run: |
bun wxt submit \
--chrome-zip build/*-chrome.zip \
--firefox-zip build/*-firefox.zip --firefox-sources-zip build/*-sources.zip
env:
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }}
FIREFOX_JWT_ISSUER: ${{ secrets.FIREFOX_JWT_ISSUER }}
FIREFOX_JWT_SECRET: ${{ secrets.FIREFOX_JWT_SECRET }}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ node_modules
.pnp.js

# extension
.plasmo
build/
.cache
keys.json
stats.html
stats-*.json
.wxt
web-ext.config.ts

# misc
.DS_Store
Expand Down
Binary file modified bun.lockb
Binary file not shown.
21 changes: 0 additions & 21 deletions keys.template.json

This file was deleted.

34 changes: 13 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
"author": "Bartosz Zagrodzki",
"scripts": {
"build": "run-p build:chrome build:firefox",
"build:chrome": "plasmo build --src-path=src/app --zip",
"build:firefox": "plasmo build --src-path=src/app --target=firefox-mv2 --zip",
"build:chrome": "wxt zip",
"build:firefox": "wxt -b firefox zip",
"dev": "bun dev:chrome",
"dev:chrome": "plasmo dev --src-path=src/app",
"dev:firefox": "plasmo dev --src-path=src/app --target=firefox-mv2",
"dev:chrome": "wxt",
"dev:firefox": "wxt -b firefox",
"lint": "biome check",
"lint:fix": "biome check --write",
"prepare": "husky",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"postinstall": "wxt prepare"
},
"dependencies": {
"@biomejs/biome": "^1.9.4",
"@hookform/resolvers": "^3.9.1",
"@openpanel/web": "^1.0.1",
"@plasmohq/messaging": "0.6.2",
"@plasmohq/storage": "1.12.0",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-label": "^2.1.0",
Expand All @@ -39,13 +38,13 @@
"marked": "^14.1.3",
"next-themes": "^0.3.0",
"npm-run-all": "^4.1.5",
"plasmo": "0.89.4",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-hook-form": "^7.53.1",
"sonner": "^1.5.0",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
"vite-plugin-svgr": "^4.3.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -54,23 +53,16 @@
"@commitlint/types": "19.0.3",
"@tailwindcss/typography": "^0.5.15",
"@total-typescript/ts-reset": "^0.6.1",
"@types/bun": "latest",
"@types/bun": "^1.1.13",
"@types/chrome": "0.0.270",
"@types/node": "20.16.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@wxt-dev/auto-icons": "^1.0.2",
"@wxt-dev/module-react": "^1.1.2",
"husky": "^9.1.6",
"typescript": "^5.6.3"
},
"manifest": {
"name": "__MSG_extensionName__",
"default_locale": "en",
"host_permissions": ["<all_urls>"],
"permissions": ["storage", "sidePanel", "scripting", "cookies"],
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
}
"typescript": "^5.6.3",
"vitest": "^2.1.5",
"wxt": "^0.19.16"
}
}
8 changes: 3 additions & 5 deletions src/app/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { setupStorage } from "~/lib/storage";

const main = async () => {
await setupStorage();
import { defineBackground } from "wxt/sandbox";

const main = () => {
console.log(
"Background service worker is running! Edit `src/app/background` and save to reload.",
);
};

void main();
export default defineBackground(main);
18 changes: 0 additions & 18 deletions src/app/background/messages/user.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/contents/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/app/contents/ui.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions src/app/devtools/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DevTools</title>
<meta name="manifest.type" content="browser_action" />
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
32 changes: 0 additions & 32 deletions src/app/devtools/index.tsx

This file was deleted.

34 changes: 34 additions & 0 deletions src/app/devtools/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { browser } from "wxt/browser";

import { Main } from "~/components/common/main";
import { Layout } from "~/components/layout/layout";

browser.devtools.panels.create(
browser.i18n.getMessage("extensionName"),
"icons/128.png",
"popup.html",
);

browser.devtools.panels.elements
.createSidebarPane(browser.i18n.getMessage("extensionName"))
.then((sidebar) => {
sidebar.setPage("<p>siema</p>");
});

console.log("siema");

const DevTools = () => {
return (
<Layout className="p-8">
<Main filename="app/devtools" />
</Layout>
);
};

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<DevTools />
</React.StrictMode>,
);
12 changes: 6 additions & 6 deletions src/app/devtools/panels/panel/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!doctype html>
<html>
<html lang="en">
<head>
<title>TurboStarter Panel</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="url:~src/styles/globals.css" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DevTools Panel</title>
<meta name="manifest.type" content="browser_action" />
</head>

<body>
<div id="root"></div>
<script src="url:./index.tsx" type="module"></script>
<script type="module" src="./main.tsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRoot } from "react-dom/client";
import React from "react";
import ReactDOM from "react-dom/client";

import { Main } from "~/components/common/main";
import { Layout } from "~/components/layout/layout";
Expand All @@ -11,7 +12,8 @@ const Panel = () => {
);
};

const element = document.getElementById("root");

const root = element ? createRoot(element) : null;
root?.render(<Panel />);
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<Panel />
</React.StrictMode>,
);
13 changes: 0 additions & 13 deletions src/app/devtools/panels/sidebar/index.html

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/devtools/panels/sidebar/index.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions src/app/newtab/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>New Tab</title>
<meta name="manifest.type" content="browser_action" />
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
10 changes: 8 additions & 2 deletions src/app/newtab/index.tsx → src/app/newtab/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import ReactDOM from "react-dom/client";

import { Main } from "~/components/common/main";
import { Layout } from "~/components/layout/layout";
import "~/styles/globals.css";

const NewTab = () => {
return (
Expand All @@ -10,4 +12,8 @@ const NewTab = () => {
);
};

export default NewTab;
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<NewTab />
</React.StrictMode>,
);
Loading

0 comments on commit 9a3d960

Please sign in to comment.