Skip to content

Commit b6b5252

Browse files
committed
♻️ refactor: complete TypeScript migration to Thunderbird WebExtension
Migrate from legacy JS background/options scripts to fully typed TypeScript modules with esbuild bundling. Changes include: - Convert all background scripts (background.js, options.js, etc.) to src/**/*.ts with proper type definitions - Add esbuild build pipeline with TypeScript config - Restruct into modular architecture (ai, email, folders, batch, auto-sort, shared, options, types) - Add Vitest test suite with fixtures and mocks - Remove legacy JS files and bundled .xpi - Fix auto-sort extractEmailContext to use direct import instead of window global access (fixes Thunderbird DevTools error) - Add ollamaNumCtx to AutoSortSettings type definition
1 parent 96c2e92 commit b6b5252

94 files changed

Lines changed: 10092 additions & 4736 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Build artifacts
2+
dist/
23
*.xpi
34
*.zip
45

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"arrowParens": "always",
8+
"endOfLine": "lf"
9+
}

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ Choose from **5 leading cloud AI providers** or run a **local Ollama** model:
128128
```bash
129129
git clone https://github.com/Nigel1992/AutoSort-Plus.git
130130
cd AutoSort-Plus
131-
zip -r autosortplus.xpi manifest.json background.js options.js options.html styles.css content.js icons/ js/ _locales/
131+
npm install
132+
npm run build
133+
npm run xpi
132134
```
133135

136+
Then load `autosortplus.xpi` as described in Option 1.
137+
134138
<div align="center">
135139

136140
**[📥 Download Latest Release](https://github.com/Nigel1992/AutoSort-Plus/releases)[📖 View Changelog](#-changelog)**
@@ -620,6 +624,67 @@ If you encounter any issues, please [open an issue on GitHub](https://github.com
620624

621625
---
622626

627+
## Development
628+
629+
### Prerequisites
630+
631+
- Node.js 18+
632+
- npm
633+
634+
### Setup
635+
636+
```bash
637+
git clone https://github.com/Nigel1992/AutoSort-Plus.git
638+
cd AutoSort-Plus
639+
npm install
640+
```
641+
642+
### Architecture
643+
644+
```
645+
src/
646+
├── background/ Background script (AI, batch, folders, auto-sort)
647+
├── options/ Options page UI
648+
├── shared/ Shared utilities (logger, storage, i18n, tab-fetch)
649+
├── types/ TypeScript type definitions
650+
├── content.ts Content script
651+
├── ollama.ts Ollama API client
652+
├── workers/ Web Workers
653+
└── popup/ Web-accessible popups
654+
```
655+
656+
### Commands
657+
658+
| Command | Description |
659+
|---------|-------------|
660+
| `npm run build` | Build extension to `dist/` |
661+
| `npm run watch` | Build and watch for changes |
662+
| `npm run test` | Run tests |
663+
| `npm run test:watch` | Run tests in watch mode |
664+
| `npm run test:coverage` | Run tests with coverage report |
665+
| `npm run lint` | Lint source code |
666+
| `npm run format` | Check formatting |
667+
| `npm run format:fix` | Fix formatting |
668+
| `npm run typecheck` | TypeScript type checking |
669+
| `npm run check` | Full check (typecheck + lint + test) |
670+
| `npm run xpi` | Build + package as `.xpi` |
671+
672+
### Load in Thunderbird
673+
674+
1. `npm run build`
675+
2. In Thunderbird, go to `about:debugging` → This Thunderbird → Load Temporary Add-on
676+
3. Select `dist/manifest.json`
677+
678+
### Tech Stack
679+
680+
- TypeScript (strict mode)
681+
- esbuild (bundler)
682+
- Vitest (test framework)
683+
- ESLint + Prettier (code quality)
684+
- Thunderbird WebExtension APIs
685+
686+
---
687+
623688
## 🙏 Contributing
624689

625690
We welcome contributions! Here's how to help:

api_ollama/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ <h2>AutoSort+ - Ollama Chat</h2>
4545
<div id="messages"></div>
4646
<div id="response"></div>
4747
<div id="status">Initializing...</div>
48-
<script src="ollama-popup.js" type="module"></script>
48+
<script src="ollama-popup.js"></script>
4949
</body>
5050
</html>

api_ollama/ollama-popup.js

Lines changed: 0 additions & 134 deletions
This file was deleted.

autosortplus.xpi

-60.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)