addfox 0.1.1-beta.1 → 0.1.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -137
- package/bin/addfox.mjs +3 -0
- package/index.d.ts +2 -2
- package/index.mjs +2 -2
- package/package.json +9 -9
- package/bin/addmo.mjs +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 addfox
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,158 +1,54 @@
|
|
|
1
|
-
[中文](README-zh_CN.md) | English
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img width="230" src="addmo.png">
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
<h1 align="center">
|
|
10
|
-
Addmo
|
|
11
|
-
</h1>
|
|
12
1
|
<p align="center">
|
|
13
|
-
|
|
2
|
+
<img width="200" src="addfox.png" alt="Addfox">
|
|
14
3
|
</p>
|
|
15
4
|
|
|
16
|
-
|
|
5
|
+
<h1 align="center">Addfox</h1>
|
|
6
|
+
<p align="center">Browser extension framework built on Rsbuild</p>
|
|
17
7
|
|
|
18
|
-
|
|
8
|
+
<div align="center">
|
|
9
|
+
<a href="https://addfox.dev">Documentation</a> · <a href="https://www.npmjs.com/package/addfox">npm</a> · <a href="https://github.com/addfox/skills">Skills</a>
|
|
10
|
+
</div>
|
|
19
11
|
|
|
20
|
-
|
|
12
|
+
---
|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
pnpm create addmo-app
|
|
24
|
-
# or
|
|
25
|
-
npx create-addmo-app
|
|
26
|
-
```
|
|
14
|
+
## Features
|
|
27
15
|
|
|
28
|
-
|
|
16
|
+
- 🔥 **Fast dev mode and hot reload** — `addfox dev` runs watch, rebuilds on change, and hot-reloads the extension in the browser; the browser launches automatically; same bundle as production.
|
|
17
|
+
- 📦 **Auto-generated zip** — After `addfox build`, output is packed into a zip under `.addfox` by default; one command for both folder and store-ready zip.
|
|
18
|
+
- 📁 **File-based entries** — Entries are discovered from `app/` layout (background, content, popup, options, sidepanel, devtools); override or add custom entries in config when needed.
|
|
19
|
+
- 🌐 **Many Chromium browsers and Firefox** — Use `-b chrome|edge|brave|vivaldi|opera|firefox|...` to target Chrome, Edge, Brave, Vivaldi, Opera, Arc, Yandex, or Firefox; manifest can be split per browser.
|
|
20
|
+
- ⚛️ **Framework-agnostic** — Vue, React, Svelte, Solid, or vanilla; TypeScript or JavaScript; choose in scaffold or add the plugin you need.
|
|
21
|
+
- 🤖 **AI-friendly error output** — Enable `--debug` for a dev-only error panel with per-entry errors, Copy prompt, Ask ChatGPT, and Ask Cursor in one click.
|
|
22
|
+
- 🧪 **Rstest support** — Run `addfox test` for unit and e2e tests; arguments are forwarded to Rstest.
|
|
23
|
+
- 📊 **Rsdoctor bundle analysis** — Add `--report` to build or dev to open the Rsdoctor analysis report after the build.
|
|
24
|
+
- 🧩 **Full Skills support** — Install [addfox/skills](https://github.com/addfox/skills) via create-addfox-app or `skills add`; AI workflow modules in `.agents/skills/`.
|
|
25
|
+
- 🔐 **Env variable support** — `.env` is loaded; `envPrefix` controls which vars are exposed to the extension (e.g. `PUBLIC_`).
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
## Install & use
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
**New project:**
|
|
33
30
|
|
|
34
31
|
```bash
|
|
35
|
-
pnpm
|
|
36
|
-
# or
|
|
37
|
-
npm install -D addmo
|
|
38
|
-
# or
|
|
39
|
-
yarn add -D addmo
|
|
32
|
+
pnpm create addfox-app
|
|
33
|
+
# or: npx create-addfox-app
|
|
40
34
|
```
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Packages and imports
|
|
45
|
-
|
|
46
|
-
- **Core** (`defineConfig`, types, discovery, manifest, etc.) is exported from **addmo**. In config use: `import { defineConfig } from "addmo"`.
|
|
47
|
-
- **Content UI** is in **`@addmo/utils`**: `import { defineContentUI, mountContentUI } from "@addmo/utils"`. For the `browser` API, install [webextension-polyfill](https://github.com/mozilla/webextension-polyfill) and use `import browser from "webextension-polyfill"`.
|
|
48
|
-
|
|
49
|
-
## Config
|
|
50
|
-
|
|
51
|
-
Config file: `addmo.config.ts`, `addmo.config.js`, or `addmo.config.mjs`.
|
|
52
|
-
|
|
53
|
-
Return a config object from `defineConfig`. Supported fields:
|
|
54
|
-
|
|
55
|
-
| Field | Description |
|
|
56
|
-
|-------|-------------|
|
|
57
|
-
| **manifest** | Extension manifest. Single object or split as `chromium` / `firefox` |
|
|
58
|
-
| **plugins** | Rsbuild plugins array (like Vite). Use function calls, e.g. `plugins: [vue()]` (from `@addmo/rsbuild-plugin-vue`) or `plugins: [pluginReact()]` (from `@rsbuild/plugin-react`) |
|
|
59
|
-
| **rsbuild** | Override or extend Rsbuild config (like Vite’s build options). **Object**: deep-merged with base. **Function**: `(base, helpers) => config` for full control; use `helpers.merge(base, overrides)` for deep-merge |
|
|
60
|
-
| **entry** | Custom entries: object, key = entry name (reserved: popup, options, sidepanel, background, devtools, content; others custom), value = path string relative to baseDir (e.g. `'content/index.ts'`). Omit to use default discovery from appDir |
|
|
61
|
-
| **appDir** | App directory; default is `app/`. Also the base for **entry** paths |
|
|
62
|
-
| **outDir** | Output directory name under `.addmo`; default `"extension"` (output at `.addmo/extension`) |
|
|
63
|
-
| **browserPath** | Dev browser executable paths. `browserPath.chrome`, `browserPath.firefox`, etc.; used when running `addmo dev`. If unset, uses OS default install paths |
|
|
64
|
-
| **hooks** | Lifecycle hooks at “parse CLI → load config → build Rsbuild config → run build”. See “Lifecycle hooks” below |
|
|
65
|
-
|
|
66
|
-
### Lifecycle hooks
|
|
67
|
-
|
|
68
|
-
Configure `hooks` in `defineConfig`. Each hook receives `PipelineContext` (root, command, browser, config, entries, rsbuild, etc.):
|
|
69
|
-
|
|
70
|
-
| Hook | When |
|
|
71
|
-
|------|------|
|
|
72
|
-
| **afterCliParsed** | After CLI args (command, -b) are parsed |
|
|
73
|
-
| **afterConfigLoaded** | After config and entries are resolved |
|
|
74
|
-
| **beforeRsbuildConfig** | After manifest and entries are fixed, before Rsbuild config is built |
|
|
75
|
-
| **beforeBuild** | After Rsbuild config is ready, before build runs |
|
|
76
|
-
| **afterBuild** | After build finishes (only for `addmo build`; dev runs watch and does not exit) |
|
|
77
|
-
|
|
78
|
-
### Errors and exit codes
|
|
36
|
+
Choose framework (Vanilla / Vue / React / Preact / Svelte / Solid), language, package manager, entries, and optional [Skills](https://github.com/addfox/skills). A full layout and `addfox.config` are generated.
|
|
79
37
|
|
|
80
|
-
|
|
38
|
+
**Existing project:**
|
|
81
39
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
import { defineConfig } from "addmo";
|
|
86
|
-
import vue from "@addmo/rsbuild-plugin-vue";
|
|
87
|
-
|
|
88
|
-
export default defineConfig({
|
|
89
|
-
appDir: "app",
|
|
90
|
-
outDir: "extension",
|
|
91
|
-
manifest: {
|
|
92
|
-
name: "My Extension",
|
|
93
|
-
version: "1.0.0",
|
|
94
|
-
manifest_version: 3,
|
|
95
|
-
permissions: ["storage", "activeTab"],
|
|
96
|
-
},
|
|
97
|
-
plugins: [vue()],
|
|
98
|
-
// browserPath: { chrome: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", firefox: "..." },
|
|
99
|
-
// rsbuild: (base, helpers) => helpers.merge(base, { ... }),
|
|
100
|
-
// entry: { background: "background/index.ts", content: "content/index.ts", popup: "popup/index.ts" },
|
|
101
|
-
// hooks: { beforeBuild: (ctx) => console.log("Building for", ctx.browser) },
|
|
102
|
-
});
|
|
40
|
+
```bash
|
|
41
|
+
pnpm add -D addfox
|
|
103
42
|
```
|
|
104
43
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- By default, entries are discovered under **app/** or **appDir** (baseDir). You can override with **entry**:
|
|
108
|
-
- **background**, **content**: script only
|
|
109
|
-
- **popup**, **options**, **sidepanel**, **devtools**: require `index.html` + entry script in the same dir
|
|
110
|
-
- Reserved names (fixed): popup, options, sidepanel, background, devtools, content; other names are custom
|
|
111
|
-
- **entry** values are paths relative to baseDir, e.g. `'content/index.ts'`, `'src/popup/index.ts'`
|
|
112
|
-
|
|
113
|
-
## Commands
|
|
114
|
-
|
|
115
|
-
In a project that has addmo installed:
|
|
116
|
-
|
|
117
|
-
- `addmo dev` or `pnpm dev` (if `"dev": "addmo dev"` in package.json): dev mode with watch and HMR (Reload Manager extension + local WebSocket)
|
|
118
|
-
- `addmo build`: production build to `.addmo/<outDir>` (default `outDir` is `"extension"`); optionally zips to `.addmo/<outDir>.zip`
|
|
119
|
-
|
|
120
|
-
**Terminal output**: When running `addmo dev` or `addmo build`, each line is prefixed with **`[addmo]`** so you can tell addmo’s output from Rsbuild’s; full Rsbuild logs and errors are unchanged.
|
|
121
|
-
|
|
122
|
-
Use **`-b, --browser <browser>`** to choose the target browser (and thus manifest branch and dev browser): `chromium`, `firefox`, `chrome`, `edge`, `brave`, etc.
|
|
123
|
-
|
|
124
|
-
- `addmo dev -b chrome` / `addmo dev -b firefox`
|
|
125
|
-
- `addmo build -b chrome` / `addmo build -b firefox`
|
|
44
|
+
Add `addfox.config.ts` (or `.js` / `.mjs`) in the project root and entries under `app/` (or `appDir`). Then:
|
|
126
45
|
|
|
127
|
-
|
|
46
|
+
- `addfox dev` — dev with watch + HMR
|
|
47
|
+
- `addfox build` — output to `.addfox/extension` (and optional zip)
|
|
128
48
|
|
|
129
|
-
|
|
49
|
+
Use `-b chrome` or `-b firefox` to target a browser.
|
|
130
50
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- **Extension development**: `@types/chrome` (Chrome extension API types) is installed as a dev dependency if not already in the project.
|
|
134
|
-
- **Plugins**: If you use `plugins: [vue()]`, the CLI ensures `vue` is installed. For React, use `@rsbuild/plugin-react` and add `react` and `react-dom` (and `@rsbuild/plugin-react`) to your project.
|
|
135
|
-
|
|
136
|
-
To skip auto-install (e.g. in CI or when you manage deps yourself), set **`ADDMO_SKIP_DEPS=1`**.
|
|
137
|
-
|
|
138
|
-
- **addmo** brings in `@addmo/cli`, `@rsbuild/core`, and the framework plugins; you only need to add **addmo** to your project. Use `addmo dev` and `addmo build` in your scripts.
|
|
139
|
-
|
|
140
|
-
## Dev HMR
|
|
141
|
-
|
|
142
|
-
In dev, a WebSocket server is started and the extension is reloaded after each build. The Rsbuild plugin opens the browser and loads the extension after the first build; later rebuilds trigger a reload via WebSocket.
|
|
143
|
-
|
|
144
|
-
Browser paths: set **browserPath** in config to override; otherwise the framework tries OS default paths (Windows / macOS / Linux).
|
|
145
|
-
|
|
146
|
-
## Repo structure
|
|
147
|
-
|
|
148
|
-
- `packages/addmo`: **addmo** – main package users install; provides the `addmo` binary and delegates to `@addmo/cli` (same idea as installing `parcel` while internals live in `@parcel/*`)
|
|
149
|
-
- `packages/cli`: **@addmo/cli** – CLI entry and **Pipeline** (parse → config → Rsbuild config → hooks; injects ConfigLoader / CliParser)
|
|
150
|
-
- `packages/core`: Core modules; filenames match class names (camelCase): **ConfigLoader** (configLoader.ts), **CliParser** (cliParser.ts), **EntryDiscoverer** (entryDiscoverer.ts), **EntryResolver** (entryResolver.ts), **ManifestBuilder** (manifestBuilder.ts); constants, AddmoError, mergeRsbuildConfig, defineConfig, types
|
|
151
|
-
- `packages/utils`: Utilities (webextension-polyfill etc.); use `@addmo/utils` as needed
|
|
152
|
-
- `packages/plugins/rsbuild-plugin-extension-entry`: **Internal** – resolves dirs and entries, sets entry/html/output (package: `@addmo/rsbuild-plugin-extension-entry`)
|
|
153
|
-
- `packages/plugins/rsbuild-plugin-extension-manifest`: **Internal** – writes manifest.json (package: `@addmo/rsbuild-plugin-extension-manifest`)
|
|
154
|
-
- `packages/plugins/rsbuild-plugin-extension-hmr**: **Internal** – dev HMR and browser launch
|
|
155
|
-
- `packages/plugins/rsbuild-plugin-vue`: Vue 3 + Vue JSX + Less + Babel; use `plugins: [vue()]`
|
|
156
|
-
- `packages/create-addmo-app`: Scaffold CLI; generates project with `plugins: [vue()]` or `plugins: [pluginReact()]` (use `@rsbuild/plugin-react` for React)
|
|
51
|
+
---
|
|
157
52
|
|
|
158
|
-
|
|
53
|
+
**Full docs, config reference, and examples:** [https://addfox.dev](https://addfox.dev)
|
|
54
|
+
**Skills (AI workflow modules):** [https://github.com/addfox/skills](https://github.com/addfox/skills)
|
package/bin/addfox.mjs
ADDED
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "@
|
|
2
|
-
export {
|
|
1
|
+
export * from "@addfox/core";
|
|
2
|
+
export { setupAddfoxMonitor } from "@addfox/rsbuild-plugin-extension-monitor/runtime";
|
package/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "@
|
|
2
|
-
export {
|
|
1
|
+
export * from "@addfox/core";
|
|
2
|
+
export { setupAddfoxMonitor } from "@addfox/rsbuild-plugin-extension-monitor/runtime";
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "addfox",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
4
|
-
"description": "Build tool for browser extensions — one install,
|
|
3
|
+
"version": "0.1.1-beta.3",
|
|
4
|
+
"description": "Build tool for browser extensions — one install, addfox dev / build",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
7
|
+
"addfox": "./bin/addfox.mjs"
|
|
8
8
|
},
|
|
9
9
|
"main": "./index.mjs",
|
|
10
10
|
"module": "./index.mjs",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"index.mjs",
|
|
27
27
|
"index.d.ts"
|
|
28
28
|
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@addfox/cli": "0.1.1-beta.2",
|
|
31
|
+
"@addfox/core": "0.1.1-beta.2",
|
|
32
|
+
"@addfox/rsbuild-plugin-extension-monitor": "0.1.1-beta.2"
|
|
33
|
+
},
|
|
29
34
|
"scripts": {
|
|
30
35
|
"build": "echo 'No build step'",
|
|
31
36
|
"test": "node -e \"process.exit(0)\"",
|
|
32
37
|
"test:coverage": "node -e \"process.exit(0)\""
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@addmo/cli": "workspace:*",
|
|
36
|
-
"@addmo/core": "workspace:*",
|
|
37
|
-
"@addmo/rsbuild-plugin-extension-monitor": "workspace:*"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|
package/bin/addmo.mjs
DELETED