Skip to content

Commit 40b7830

Browse files
committed
feat(chrome-devtool): migrate to Manifest V3 with Plasmo framework
- Refactor architecture to comply with Manifest V3 security requirements - Preserve devtools functionality with updated service worker lifecycle - Fix requestIdleCallback() bug in backend.ts - Replace legacy toolkit with Plasmo framework for enhanced DX - Implement automatic HMR for popup/options UI components - Update build chain and dependency tree (React 18.3.1) - Add release devtools workflow configuration BREAKING CHANGE: Requires Chrome 88+ due to Manifest V3 changes
1 parent 9616194 commit 40b7830

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+482
-577
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ packages/element
1313
esm
1414
doc-site
1515
public
16-
package
16+
package
17+
assets
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release Devtools
2+
on:
3+
workflow_dispatch:
4+
remote_debug:
5+
description: 'Enable remote debug session?'
6+
type: boolean
7+
required: false
8+
default: false
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
env:
15+
DEVTOOLS_ZIP_PATH: devtools/chrome-extension/build/chrome-mv3-prod.zip
16+
DEVTOOLS_ARTIFACT_NAME: formily-devtools
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Start debug session (when enabled)
23+
if: ${{ inputs.remote_debug }}
24+
uses: lhotari/action-upterm@v1
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 16
30+
registry-url: https://registry.npmjs.org/
31+
cache: yarn
32+
33+
- name: Verify environment
34+
run: |
35+
node --version
36+
yarn -v
37+
38+
- name: Maintain debug session (when enabled)
39+
run: |
40+
sleep 3600
41+
if: ${{ inputs.remote_debug }}
42+
43+
- name: Install dependencies
44+
run: |
45+
yarn install --ignore-engines
46+
47+
- name: Build packages
48+
run: |
49+
yarn build
50+
env:
51+
# avoid core dump, see: https://github.com/parcel-bundler/parcel/issues/10081
52+
PARCEL_WORKER_BACKEND: process
53+
54+
- name: Validate artifact
55+
run: test -f ${{ env.DEVTOOLS_ZIP_PATH }}
56+
57+
- name: Upload Artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: ${{ env.DEVTOOLS_ARTIFACT_NAME }}
61+
path: ${{ env.DEVTOOLS_ZIP_PATH }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3+
4+
# dependencies
5+
/node_modules
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
# misc
13+
.DS_Store
14+
*.pem
15+
16+
# debug
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
.pnpm-debug.log*
21+
22+
# local env files
23+
.env*.local
24+
25+
out/
26+
build/
27+
dist/
28+
29+
# plasmo
30+
.plasmo
31+
32+
# typescript
33+
.tsbuildinfo
34+
35+
# backend.js is generated from src/webAccessible/backend.ts
36+
assets/backend.js

devtools/chrome-extension/.npmignore

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @type {import('prettier').Options}
3+
*/
4+
export default {
5+
printWidth: 80,
6+
tabWidth: 2,
7+
useTabs: false,
8+
semi: false,
9+
singleQuote: true,
10+
trailingComma: 'all',
11+
bracketSpacing: true,
12+
bracketSameLine: true,
13+
plugins: ['@ianvs/prettier-plugin-sort-imports'],
14+
importOrder: [
15+
'<BUILTIN_MODULES>', // Node.js built-in modules
16+
'<THIRD_PARTY_MODULES>', // Imports not matched by other special words or groups.
17+
'', // Empty line
18+
'^@plasmo/(.*)$',
19+
'',
20+
'^@plasmohq/(.*)$',
21+
'',
22+
'^~(.*)$',
23+
'',
24+
'^[./]',
25+
],
26+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Formily DevTools
2+
3+
This is a [Plasmo extension](https://docs.plasmo.com/) project bootstrapped with [`plasmo init`](https://www.npmjs.com/package/plasmo).
4+
5+
## 🚀 Getting Started
6+
7+
### Development Setup
8+
9+
1. **Install dependencies**:
10+
```bash
11+
yarn install
12+
```
13+
14+
2. **Start the development server**:
15+
```bash
16+
yarn run dev
17+
```
18+
19+
3. **Load the extension in your browser**:
20+
• For Chrome (Manifest V3):
21+
Navigate to `build/chrome-mv3-dev` using your browser's extension developer mode
22+
23+
24+
Open your browser and load the appropriate development build. For example, if you are developing for the chrome browser, using manifest v3, use: `build/chrome-mv3-dev`.
25+
26+
You can start editing the popup by modifying `popup.tsx`. It should auto-update as you make changes. To add an options page, simply add a `options.tsx` file to the root of the project, with a react component default exported. Likewise to add a content page, add a `content.ts` file to the root of the project, importing some module and do some logic, then reload the extension on your browser.
27+
28+
For further guidance, [visit our Documentation](https://docs.plasmo.com/)
29+
30+
### 🔥 Hot Reload Notes
31+
32+
**Special Case for webAccessibleResources/backend.ts**:
33+
```bash
34+
# After modifying webAccessibleResources/backend.ts
35+
# 1. Stop the dev server (Ctrl+C)
36+
# 2. Rerun the dev command to pick up changes:
37+
yarn run dev
38+
```
39+
40+
This is due to Plasmo's limitations.
41+
42+
## Making production build
43+
44+
Run the following:
45+
46+
```bash
47+
# Build the extension for production
48+
yarn run build
49+
50+
# Package the extension into zip file for distribution
51+
yarn run package
52+
```
53+
54+
This should create a production bundle for your extension, ready to be published to the stores.
55+
56+
## Submit to the webstores
57+
58+
The easiest way to deploy your Plasmo extension is to use the built-in [bpp](https://bpp.browser.market) GitHub action. Prior to using this action however, make sure to build your extension and upload the first version to the store to establish the basic credentials. Then, simply follow [this setup instruction](https://docs.plasmo.com/framework/workflows/submit) and you should be on your way for automated submission!
File renamed without changes.

devtools/chrome-extension/assets/img/loading.svg

Lines changed: 0 additions & 42 deletions
This file was deleted.
-6.49 KB
Binary file not shown.
-777 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)