Initial commit

This commit is contained in:
2026-05-08 00:00:00 +00:00
commit 530ec7a144
110 changed files with 18537 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
MAIN_VITE_SERVER_URL=http://localhost:5000
MAIN_VITE_CLIENT_VERSION=latest
+2
View File
@@ -0,0 +1,2 @@
MAIN_VITE_SERVER_URL=https://octowow.st
MAIN_VITE_CLIENT_VERSION=latest
+4
View File
@@ -0,0 +1,4 @@
# Force LF on shell scripts so git-bash can execute them as hooks on Windows
hooks/* text eol=lf
*.sh text eol=lf
*.py text eol=lf
+34
View File
@@ -0,0 +1,34 @@
name: Build check
on:
push:
branches: [main, master]
pull_request:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install JS dependencies (skip native compile)
run: npm install --ignore-scripts --no-audit --no-fund
- name: Download Electron binary
run: node node_modules/electron/install.js
- name: Rebuild native modules for Electron ABI
run: node_modules/.bin/electron-builder.cmd install-app-deps
- name: Build bundles
run: npm run build
env:
ELECTRON_RUN_AS_NODE: ''
+62
View File
@@ -0,0 +1,62 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install VS 2022 Build Tools (node-gyp requirement)
run: |
choco install visualstudio2022buildtools `
--package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --includeRecommended --passive" `
--no-progress -y
shell: powershell
- name: Install JS dependencies (skip native compile)
run: npm install --ignore-scripts --no-audit --no-fund
- name: Download Electron binary
run: node node_modules/electron/install.js
- name: Rebuild native modules for Electron ABI
run: node_modules/.bin/electron-builder.cmd install-app-deps
- name: Build and package
run: npm run dist
env:
ELECTRON_RUN_AS_NODE: ''
- name: Upload portable exe
uses: actions/upload-artifact@v4
with:
name: OctoLauncher-portable
path: dist/OctoLauncher.exe
- name: Upload installer
uses: actions/upload-artifact@v4
with:
name: OctoLauncher-installer
path: dist/OctoLauncher_Installer.exe
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/OctoLauncher.exe
dist/OctoLauncher_Installer.exe
dist/latest.yml
dist/OctoLauncher_Installer.exe.blockmap
+20
View File
@@ -0,0 +1,20 @@
node_modules/
dist/
out/
release/
*.tsbuildinfo
Tools/launcher/node/
.env
.env.local
*.log
.DS_Store
Thumbs.db
scripts/
hooks/
+134
View File
@@ -0,0 +1,134 @@
# OctoLauncher Build Guide (Windows)
End-to-end setup that gets `npm run dev` and `npm run dist` working on a fresh Windows machine. Captured from a working build on Windows 10 / April 2026.
## Changes made to the dev environment
The project as checked out does **not** build on a default up-to-date Windows dev machine. These are the deltas applied to get it working, in order:
1. **Added a Node version manager (`fnm`) and installed Node 20** alongside the existing Node 24. Node 24 was the system default and caused `nan` / `dll-inject` compile failures. Node 20 is now the fnm default but Node 24 is still available via `fnm use system`.
2. **Installed Visual Studio 2022 Build Tools** with the `VCTools` workload and Windows 11 SDK. Machine already had VS2026 (v18), but `node-gyp` v10 (shipped with Node 20's npm) doesn't detect it. VS2022 now lives side-by-side under `C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools`.
3. **Unset `ELECTRON_RUN_AS_NODE`** per-shell before launching Electron. This var is set globally by VSCode's integrated terminal (inherited from the extension host) — it is not something we can remove permanently without breaking VSCode. It has to be unset in each shell that runs `npm run dev` / `dist`.
4. **Populated `node_modules`** in both `main/` and `main/server/`. The tree was checked in empty.
Nothing in the repo itself was modified — all fixes were environmental. If another developer checks this repo out, they need to apply items 14 on their own machine. The sections below are that recipe.
---
## Prerequisites
### 1. Node.js 20 (not 22, not 24)
Node 24 breaks the `dll-inject` native module — its `nan` C++ bindings don't compile against V8 in Node 22+. Stick to Node 20 LTS.
Install via `fnm` so you can keep your system Node separate:
```bash
winget install Schniz.fnm --accept-source-agreements --accept-package-agreements
fnm install 20
fnm default 20
```
Verify: `node -v` should print `v20.x.x`.
### 2. Visual Studio 2022 Build Tools (C++ workload)
`dll-inject` and `stormlib-node` compile native addons via `node-gyp`. `node-gyp` v10 (bundled with Node 20's npm) only recognizes VS20172022 — newer VS versions (2026 / v18) are not detected.
```bash
winget install Microsoft.VisualStudio.2022.BuildTools \
--accept-source-agreements --accept-package-agreements \
--override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --includeRecommended"
```
~6 GB download, requires admin. Even if you already have VS2026, you need VS2022 side-by-side for node-gyp.
### 3. Python 3 (usually already present)
`node-gyp` needs Python on PATH. Any 3.x works.
## Install dependencies
From the repo root:
```bash
npm install --ignore-scripts
node node_modules/electron/install.js
node_modules/.bin/electron-builder.cmd install-app-deps
```
Why the three-step approach: `dll-inject` requires ClangCL if compiled against the system Node, but compiles fine against Electron's bundled V8 headers (which `electron-builder install-app-deps` uses). Running plain `npm install` fails if your VS2022 installation doesn't include the LLVM/ClangCL component; `--ignore-scripts` skips that step and lets `install-app-deps` handle it correctly.
Or, use the provided build script which downloads a portable Node 20 and handles everything automatically:
```powershell
.\Tools\launcher\install.ps1
```
Then the server (only needed if running a local CDN, see `server/.env.example`):
```bash
cd server
npm install
cd ..
```
## Critical env var: `ELECTRON_RUN_AS_NODE`
**VSCode's integrated terminal sets `ELECTRON_RUN_AS_NODE=1`** (inherited from VSCode's extension host). This makes Electron binaries launch as plain Node, so `require('electron')` returns a path string instead of the API — the app crashes with `TypeError: Cannot read properties of undefined (reading 'isPackaged')`.
Before any `npm run dev` / `npm run build` / `npm run dist`:
```bash
unset ELECTRON_RUN_AS_NODE
```
```powershell
Remove-Item Env:ELECTRON_RUN_AS_NODE
```
An external terminal (Windows Terminal, cmd, plain PowerShell) doesn't have this problem — the variable is only set inside VSCode.
## Running in dev
```bash
npm run dev
```
Starts electron-vite, builds main + preload + renderer, opens an Electron window on `http://localhost:5173` (or `5174` if 5173 is taken). Closing the window ends the session.
You'll see benign warnings in the console:
- `ERROR:cache_util_win.cc ... Access is denied` — OneDrive sync locking Electron's user-data cache. Cosmetic. To silence, move the project out of OneDrive or set a custom user-data dir.
- `Browserslist: caniuse-lite is outdated` — cosmetic.
## Building for distribution
The `dist` script runs `tsc && npm run build && npm run pack`:
```bash
unset ELECTRON_RUN_AS_NODE
npm run dist
```
Outputs land in `dist/`:
- `OctoLauncher.exe` — portable single-file build
- `OctoLauncher_Installer.exe` — NSIS installer
Targets are configured in [electron-builder.yml](electron-builder.yml).
### Before publishing
- The build uses `.env.production` (committed) which already points to `https://octowow.st` — no `.env` file needed for production builds.
- Code signing is not configured. Unsigned Windows builds trigger SmartScreen warnings. To sign, add a `win.certificateFile` + password (or use env-based signing) to the electron-builder config.
## Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| `nan_scriptorigin.h ... cannot convert 'v8::Isolate *'` during `npm install` | Node 22+ breaks `nan` | Switch to Node 20 |
| `gyp ERR! find VS Could not find any Visual Studio installation` | Only VS2023+ installed | Install VS2022 Build Tools |
| `error MSB8020: The build tools for ClangCL cannot be found` | Missing LLVM component during plain `npm install` | Use `npm install --ignore-scripts` + `electron-builder install-app-deps` (see above) |
| `TypeError: Cannot read properties of undefined (reading 'isPackaged')` at launch | `ELECTRON_RUN_AS_NODE=1` set by VSCode | `unset ELECTRON_RUN_AS_NODE` |
| `Port 5173 is in use` | Prior dev server didn't exit cleanly | Ignore (vite falls back to 5174) or kill the stale process |
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 OctoWoW Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+92
View File
@@ -0,0 +1,92 @@
# News feed
**Note:** The launcher no longer uses a static `news.json` file. The News tab now pulls live from the OctoWoW announcements forum via the website's `/news.json` endpoint, which is backed by `ForumFeedService` on the Laravel side. To publish a news item in the launcher, simply post in the configured announcements forum — the launcher will pick it up within the cache TTL (default 10 minutes). There is no JSON file to edit or deploy.
The launcher's News tab fetches `${MAIN_VITE_SERVER_URL}/news.json` and renders the entries on the landing screen. The endpoint is dynamic: it mirrors the same forum posts the website's homepage shows in its "Recent forum posts" cards, so updating the forum updates the launcher.
## Endpoint
`GET ${MAIN_VITE_SERVER_URL}/news.json``200 application/json`
`MAIN_VITE_SERVER_URL` comes from [main/.env](.env) at build time. With the current production setup that resolves to the public site origin (e.g. `https://octowow.st/news.json`).
The route is served by Laravel (`routes/web.php``news.json`) and reads from `App\Services\ForumFeedService`, which fetches the configured phpBB Atom feed (`FORUM_FEED_BASE_URL`/`FORUM_FEED_MODE`/`FORUM_FEED_FORUM_ID` in `config/customs.php``forum_feed`). The same service backs the homepage's `recent-forum-posts` Livewire component, so what shows in the launcher is exactly what shows on the site.
No auth. The launcher times out after 8 seconds and validates the body against the schema below — malformed payloads surface as the "Couldn't reach the news feed" error state (with a Try again button).
## Payload contract
```jsonc
{
"items": [
{
"id": "2026-04-24-launch", // required, stable, used as React key
"title": "Welcome to the new client", // required
"date": "2026-04-24", // required, anything Date.parse() accepts
"body": "Multi-line\nbody text supported.", // required, \n preserved
"author": "example", // optional
"url": "https://example.com/changelog" // optional, must be a full URL
}
]
}
```
Source of truth for the schema: [src/common/schemas.ts](src/common/schemas.ts) (`NewsItemSchema`, `NewsFeedSchema`). If you change the contract, update both ends.
Notes:
- `items` is rendered in the order returned — sort newest-first on the server.
- `body` is rendered as plain text with `whitespace-pre-wrap`. No HTML/markdown.
- `url`, when present, becomes a "Read more" button that opens in the user's default browser via `shell.openExternal`. Skip it for inline-only posts.
- `id` should never change for an existing post (stable React keys, future bookmarking/read-state).
## Publishing
There is no static file to edit anymore. To change what the launcher shows, post on the forum (`FORUM_FEED_BASE_URL`, e.g. `https://octowow.st/forum`). The next launcher fetch picks it up subject to two cache layers:
- `forum_feed.cache_ttl` (default 600 s, env `FORUM_FEED_CACHE_TTL`) — Laravel server-side cache of the parsed Atom feed.
- `Cache-Control: public, max-age=120` on the `/news.json` response — short edge cache so launcher launches in a burst don't all hit Laravel.
The launcher's react-query cache also holds for 5 minutes per session; users can hit the refresh icon in the News header to force a re-fetch (which still hits the two cache layers above).
### Tuning what shows
- **Which forum / mode shows**: set `FORUM_FEED_MODE` (`topics_active` | `topics` | `news` | `forum`) and, if `forum`, `FORUM_FEED_FORUM_ID` in the website container's environment.
- **How fresh**: lower `FORUM_FEED_CACHE_TTL` for fresher news at the cost of more upstream forum fetches. Pair with the route's 120-second `Cache-Control` if you also want to relax the edge cache.
- **How many items**: the route currently caps at 10; the homepage shows 3. Edit the `recent(10)` argument in `routes/web.php``news.json` to change the launcher cap independently of the homepage.
## Testing
**Confirm Laravel is serving it:**
```bash
curl -s ${MAIN_VITE_SERVER_URL}/news.json | jq .
```
Expected: a `{"items": [...]}` body. An empty `items: []` means the forum feed is reachable but has nothing matching the configured mode (or the cache is still warm with an empty result — bust it by `php artisan cache:clear` inside the website container, or wait `FORUM_FEED_CACHE_TTL` seconds).
**No items / errors:**
- `{"items": []}``FORUM_FEED_BASE_URL` is unset, the feed returned non-2xx, the body wasn't parseable Atom XML, or the configured forum has no posts. Check the website container's `storage/logs/laravel.log` for `ForumFeedService` warnings.
- `Couldn't reach the news feed` in the launcher — Laravel returned a 5xx (route exception, missing `ForumFeedService` binding) or the schema validator rejected the body. Check the launcher's main-process log at `%APPDATA%\octo-launcher\logs\main.log` for `Malformed news feed`.
**End-to-end check in the launcher:**
1. Open the launcher (the News tab is the default view when no other tab is selected).
2. Click the refresh icon in the News header.
3. Entries should appear within ~1 second once Laravel + the forum cache are warm.
## Failure modes the launcher already handles
| Server response | UI behaviour |
| --- | --- |
| `200` with valid JSON | Renders entries |
| `200` with empty `items: []` | "No news yet — check back later." |
| `200` with malformed JSON or missing required fields | Error state + Try again. Reason logged in main-process logs (`%APPDATA%\octo-launcher\logs\main.log`). |
| `404`, `5xx`, network unreachable, > 8s timeout | Error state + Try again. |
You don't need to ship a placeholder `news.json` to avoid 404s — the empty/error state is intentional.
## Where the code lives
- Main-process fetcher + schema validation: [src/main/api/routers/news.ts](src/main/api/routers/news.ts)
- Schema: [src/common/schemas.ts](src/common/schemas.ts) (`NewsItemSchema`, `NewsFeedSchema`)
- Renderer UI: [src/renderer/components/tabs/NewsTab.tsx](src/renderer/components/tabs/NewsTab.tsx)
- Router wiring: [src/main/api/root.ts](src/main/api/root.ts) (`news`)
+120
View File
@@ -0,0 +1,120 @@
# OctoLauncher
Desktop launcher for the OctoWoW (World of Warcraft 1.12.1 private server) client. Built with Electron, React, and tRPC.
**What it does:**
- Downloads and patches the OctoWoW game client via a manifest-based CDN updater
- Rewrites `Config.wtf` with the correct realm/patch-list on every launch
- Optionally applies binary tweaks to `WoW.exe` (FOV, far-clip, large-address flag, etc.)
- Injects client mods (VanillaFixes, DXVK, nampower, etc.) via a DLL chainloader
- Manages git-based addon installations
- Self-updates via NSIS
---
## Quick start (players)
1. Grab `OctoLauncher.exe` (portable) or `OctoLauncher_Installer.exe` from the [Releases](../../releases) page.
2. Run it and set your WoW client directory when prompted.
3. Click **Verify** to download any missing game files, then **Play**.
No server configuration needed — the launcher connects to `octowow.st` by default.
---
## Building from source
### Prerequisites
| Requirement | Version | Notes |
|---|---|---|
| Node.js | 20 LTS | Node 22+ breaks `dll-inject` native bindings — use Node 20 |
| VS 2022 Build Tools | C++ workload + Win SDK | `node-gyp` v10 only detects VS20172022 |
| Python | 3.x | Required by `node-gyp` |
Install Node 20 with `fnm`:
```powershell
winget install Schniz.fnm
fnm install 20
fnm default 20
```
Install VS 2022 Build Tools:
```powershell
winget install Microsoft.VisualStudio.2022.BuildTools `
--override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --includeRecommended"
```
### Install dependencies
```powershell
npm install
```
`postinstall` rebuilds the native modules (`dll-inject`, `stormlib-node`) against the Electron ABI — expect C++ compiler output.
### Run in development
> **VSCode users:** The integrated terminal sets `ELECTRON_RUN_AS_NODE=1`, which crashes Electron. Unset it first:
> ```powershell
> Remove-Item Env:ELECTRON_RUN_AS_NODE
> ```
```powershell
npm run dev
```
Opens the app in a hot-reloading Electron window. The dev build points to `http://localhost:5000` by default — create a `.env` file from `.env.example` if you want to run against a local server, otherwise it falls back to `https://octowow.st`.
### Build for distribution
```powershell
Remove-Item Env:ELECTRON_RUN_AS_NODE
npm run dist
```
Outputs to `dist/`:
- `OctoLauncher.exe` — portable single-file
- `OctoLauncher_Installer.exe` — NSIS installer
The production build uses `.env.production` (committed) which points to `https://octowow.st`. No `.env` file needed.
---
## Running the dev backend
The `server/` subdirectory is a standalone Express server that simulates the production CDN for local development. It is **not** bundled into the Electron app.
```powershell
cd server
npm install
```
Create `server/.env` from `server/.env.example` and set `SOURCE_DIR` to your local WoW client directory, then:
```powershell
npm run dev
```
The server listens on `http://localhost:5000` and serves:
- `GET /api/file/:version/manifest.json`
- `GET /client/:version/*` — per-file downloads
- `GET /api/addons.json`
---
## Architecture overview
Three Vite bundles tied together by tRPC over Electron IPC:
- **Main** ([src/main/](src/main/)) — Electron main process; owns all filesystem/native work and the tRPC router
- **Preload** ([src/preload/](src/preload/)) — secure IPC bridge via `exposeElectronTRPC()`
- **Renderer** ([src/renderer/](src/renderer/)) — React 18 + Tailwind UI; no direct Node access
All cross-process data shapes are Zod schemas in [src/common/schemas.ts](src/common/schemas.ts). All renderer→main calls go through tRPC procedures in [src/main/api/routers/](src/main/api/routers/) — never raw `ipcMain.handle`.
---
## License
MIT
+17
View File
@@ -0,0 +1,17 @@
# Launcher build tool
`install.ps1` downloads a portable Node.js 20 LTS into `node/` and runs the
full build pipeline (`npm install --ignore-scripts`, Electron binary install,
`electron-builder install-app-deps`, `npm run build`, `npm run pack`).
Use this instead of a global Node install to avoid the ClangCL / Node version
issues documented in the repo root `BUILD.md`.
```powershell
cd Tools\launcher
.\install.ps1
```
Output: `dist\OctoLauncher.exe` (portable) and `dist\OctoLauncher_Installer.exe` (NSIS).
The `node/` directory is gitignored — it is recreated by `install.ps1`.
+71
View File
@@ -0,0 +1,71 @@
$ErrorActionPreference = 'Stop'
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$nodeDir = Join-Path $here 'node'
$mainDir = Split-Path -Parent (Split-Path -Parent $here)
$distDir = Join-Path $mainDir 'dist'
$nodeVersion = '20.18.1'
$nodeZipName = "node-v$nodeVersion-win-x64.zip"
$nodeUrl = "https://nodejs.org/dist/v$nodeVersion/$nodeZipName"
$nodeExe = Join-Path $nodeDir "node-v$nodeVersion-win-x64\node.exe"
if (Test-Path $nodeExe) {
Write-Host "Node.js already present at $nodeExe." -ForegroundColor Yellow
} else {
if (-not (Test-Path $nodeDir)) { New-Item -ItemType Directory -Path $nodeDir | Out-Null }
$zipPath = Join-Path $nodeDir $nodeZipName
Write-Host "Downloading Node.js $nodeVersion (~30 MB)..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $nodeUrl -OutFile $zipPath -UseBasicParsing
Write-Host "Extracting to $nodeDir..." -ForegroundColor Cyan
Expand-Archive -Path $zipPath -DestinationPath $nodeDir -Force
Remove-Item $zipPath
}
$nodeBinDir = Split-Path -Parent $nodeExe
$env:PATH = "$nodeBinDir;$env:PATH"
Write-Host ""
Write-Host "node : $(& $nodeExe --version)" -ForegroundColor Green
Write-Host "npm : $(& (Join-Path $nodeBinDir 'npm.cmd') --version)" -ForegroundColor Green
Write-Host ""
Write-Host "Building Electron launcher at $mainDir..." -ForegroundColor Cyan
Push-Location $mainDir
try {
if (-not (Test-Path (Join-Path $mainDir 'node_modules'))) {
Write-Host "[npm] install --ignore-scripts (JS packages only)" -ForegroundColor Cyan
& (Join-Path $nodeBinDir 'npm.cmd') install --ignore-scripts --no-audit --no-fund
if ($LASTEXITCODE -ne 0) { throw "npm install failed" }
Write-Host "[electron] install binary" -ForegroundColor Cyan
& $nodeExe (Join-Path $mainDir 'node_modules\electron\install.js')
if ($LASTEXITCODE -ne 0) { throw "electron install failed" }
Write-Host "[electron-builder] install-app-deps (native modules)" -ForegroundColor Cyan
& (Join-Path $mainDir 'node_modules\.bin\electron-builder.cmd') install-app-deps
if ($LASTEXITCODE -ne 0) { throw "electron-builder install-app-deps failed" }
} else {
Write-Host "node_modules already exists - skipping npm install (delete it to force reinstall)." -ForegroundColor Yellow
}
Write-Host "[npm] run build (electron-vite)" -ForegroundColor Cyan
& (Join-Path $nodeBinDir 'npm.cmd') run build
if ($LASTEXITCODE -ne 0) { throw "npm run build failed" }
Write-Host "[npm] run pack (electron-builder -> dist\)" -ForegroundColor Cyan
& (Join-Path $nodeBinDir 'npm.cmd') run pack
if ($LASTEXITCODE -ne 0) { throw "npm run pack failed" }
} finally {
Pop-Location
}
Write-Host ""
Write-Host "Done." -ForegroundColor Green
if (Test-Path $distDir) {
Get-ChildItem $distDir -Filter '*.exe' | ForEach-Object {
$size = [math]::Round($_.Length / 1MB, 1)
Write-Host " $($_.FullName) ($size MB)" -ForegroundColor Green
}
}
Write-Host ""
+66
View File
@@ -0,0 +1,66 @@
# opentracker — OctoWow launcher torrent swarm
BitTorrent tracker the launcher's webtorrent clients announce to. Runs
on your VPS alongside the companion update server. Tiny (~2 MB RSS),
near-zero CPU, zero disk IO after boot.
**Why your own tracker**: public trackers (opentrackr.org, etc.) are
reliable enough for hobby swarms but add a single-point-of-failure you
don't control, and often rate-limit new info-hashes. The launcher also
announces over DHT, so your tracker is redundant with DHT — but it's
the fastest path for a fresh peer to find the swarm before DHT has
warmed up.
## Deploy (VPS, Linux)
SSH into the VPS, clone this repo, run:
```
cd Tools/launcher/tracker
chmod +x install.sh
./install.sh
```
`install.sh` is idempotent — re-run to update. It builds opentracker
from CVS (only distribution upstream offers), installs it under
`/opt/opentracker/bin/`, drops a hardened systemd unit, and starts the
service bound to `0.0.0.0:6969`.
**Firewall**: open `6969/tcp` + `6969/udp`. On a typical Ubuntu VPS
with ufw: `sudo ufw allow 6969`.
## Verify
```
sudo systemctl status opentracker
curl http://127.0.0.1:6969/stats?mode=tpbs # shows torrents / peers / bytes
```
The launcher's webtorrent client will announce to this URL the moment
a dev runs the companion server with `TRACKER_URL` set to match.
## Wire the companion server to use this tracker
Set the `TRACKER_URL` env var when running the companion server so
every `.torrent` it generates announces to your VPS:
```
TRACKER_URL=http://<your-vps-ip>:6969/announce npm run server
```
Default is `http://127.0.0.1:6969/announce` (assumes tracker + companion
server run on the same VPS, which is the normal deployment).
Clients pull the `.torrent` blob from the companion server — the URL
is already baked in by `create-torrent` at generation time, so no
launcher-side config needed.
## Uninstall
```
sudo systemctl stop opentracker
sudo systemctl disable opentracker
sudo rm /etc/systemd/system/opentracker.service
sudo rm -rf /opt/opentracker
sudo userdel opentracker
```
+42
View File
@@ -0,0 +1,42 @@
set -euo pipefail
INSTALL_PREFIX="${INSTALL_PREFIX:-/opt/opentracker}"
BUILD_DIR="$(mktemp -d)"
trap "rm -rf $BUILD_DIR" EXIT
echo "=== Installing build deps ==="
sudo apt-get update
sudo apt-get install -y build-essential cvs zlib1g-dev
echo "=== Fetching libowfat ==="
cd "$BUILD_DIR"
cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat
cd libowfat
make
echo "=== Fetching opentracker ==="
cd "$BUILD_DIR"
cvs -d :pserver:anoncvs@cvs.fefe.de:/cvs -z9 co opentracker
cd opentracker
make FEATURES='-DWANT_V6 -DWANT_FULLSCRAPE'
echo "=== Installing to $INSTALL_PREFIX ==="
sudo mkdir -p "$INSTALL_PREFIX/bin"
sudo cp opentracker "$INSTALL_PREFIX/bin/"
sudo cp opentracker.conf.sample "$INSTALL_PREFIX/opentracker.conf" || true
sudo useradd --system --home "$INSTALL_PREFIX" --shell /usr/sbin/nologin opentracker 2>/dev/null || true
sudo chown -R opentracker:opentracker "$INSTALL_PREFIX"
echo "=== Installing systemd unit ==="
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
sudo cp "$SCRIPT_DIR/opentracker.service" /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable opentracker
sudo systemctl start opentracker
echo
echo "Done. Check status:"
echo " sudo systemctl status opentracker"
echo " curl http://127.0.0.1:6969/stats?mode=tpbs"
echo
echo "Don't forget to open port 6969/tcp + 6969/udp on your VPS firewall."
@@ -0,0 +1,31 @@
[Unit]
Description=opentracker — BitTorrent tracker for OctoWow launcher swarm
After=network.target
[Service]
Type=simple
User=opentracker
Group=opentracker
WorkingDirectory=/opt/opentracker
ExecStart=/opt/opentracker/bin/opentracker -i 0.0.0.0 -p 6969 -P 6969
Restart=on-failure
RestartSec=5
# Hardening — opentracker does no filesystem IO after boot, so most of
# the namespace can be locked down.
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictNamespaces=true
RestrictRealtime=true
RestrictSUIDSGID=true
LockPersonality=true
MemoryDenyWriteExecute=true
SystemCallArchitectures=native
[Install]
WantedBy=multi-user.target
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

+41
View File
@@ -0,0 +1,41 @@
productName: OctoLauncher
directories:
buildResources: build
output: dist
files:
- '!**/.vscode/*'
- '!src/*'
- '!electron.vite.config.{js,ts,mjs,cjs}'
# Strip every project-root .md file from the asar bundle
- '!*.md'
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,.prettierrc.cjs,dev-app-update.yml}'
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
- '!{tailwind.config.ts,postcss.config.cjs}'
- '!{dist,dist-new,dist-test,out/main/chunks}/**'
- '!.launcher/**'
- '!WTF/**'
- '!server/**'
- '!scripts/**'
- '!**/node_modules/**/{__tests__,test,tests,docs,example,examples,demo,demos,benchmark,benchmarks}/**'
- '!**/node_modules/**/*.{tsx,map,markdown}'
- '!**/node_modules/**/build/Release/obj/**'
- '!**/node_modules/**/build/Release/{*.iobj,*.ipdb,*.recipe}'
- '!**/node_modules/**/*.{vcxproj,vcxproj.filters}'
asarUnpack:
- resources/**
npmRebuild: false
electronLanguages: en
win:
artifactName: ${productName}.${ext}
target:
- portable
- nsis
nsis:
artifactName: ${productName}_Installer.${ext}
uninstallDisplayName: ${productName}
oneClick: false
removeDefaultUninstallWelcomePage: true
publish:
- provider: generic
url: 'https://octowow.st/launcher-updates/'
+25
View File
@@ -0,0 +1,25 @@
import { resolve } from 'path';
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
import react from '@vitejs/plugin-react';
const alias = {
'~common': resolve('src/common'),
'~main': resolve('src/main'),
'~renderer': resolve('src/renderer'),
'~build': resolve('build')
};
export default defineConfig({
main: {
resolve: { alias },
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: { alias },
plugins: [react()]
}
});
+8880
View File
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
{
"name": "octo-launcher",
"version": "1.0.27",
"description": "An Electron application for launching and updating the OctoWoW client",
"author": "OctoWoW",
"copyright": "Copyright © 2026 OctoWoW",
"main": "./out/main/index.js",
"scripts": {
"start": "electron-vite preview",
"dev": "electron-vite dev",
"server": "cd server && npm run dev",
"postinstall": "electron-builder install-app-deps && node scripts/scrub-native-paths.cjs",
"build": "electron-vite build",
"build:test": "electron-vite build --mode test",
"pack": "electron-builder --config",
"dist": "tsc && npm run build && npm run pack"
},
"dependencies": {
"@electron-toolkit/preload": "^1.0.3",
"@electron-toolkit/utils": "^1.0.2",
"@hookform/resolvers": "^3.3.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^4.36.1",
"@trpc/client": "^10.43.3",
"@trpc/react-query": "^10.43.3",
"@trpc/server": "^10.43.3",
"adm-zip": "^0.5.17",
"classnames": "^2.3.2",
"dll-inject": "^0.0.3",
"electron-log": "^5.1.5",
"electron-trpc": "^0.5.2",
"electron-updater": "^5.3.0",
"fs-extra": "^11.1.1",
"isomorphic-git": "^1.25.0",
"lucide-react": "^0.399.0",
"node-fetch": "^2.7.0",
"react-hook-form": "^7.48.2",
"stormlib-node": "^1.3.6",
"superjson": "^1.13.3",
"zod": "^3.22.4"
},
"devDependencies": {
"@electron-toolkit/tsconfig": "^1.0.1",
"@haaxor1689/eslint-config": "^3.0.0",
"@haaxor1689/prettier-config": "^3.0.0",
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
"@tanstack/react-query-devtools": "^4.36.1",
"@types/adm-zip": "^0.5.8",
"@types/fs-extra": "^11.0.4",
"@types/node": "16.18.21",
"@types/node-fetch": "^2.6.9",
"@types/react": "18.0.30",
"@types/react-dom": "18.0.11",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-react": "^3.1.0",
"autoprefixer": "^10.4.16",
"electron": "^27.0.4",
"electron-builder": "^24.6.4",
"electron-vite": "^1.0.28",
"eslint": "^8.53.0",
"eslint-config-next": "^13.5.6",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.33.2",
"postcss": "^8.4.31",
"postcss-nested": "^6.0.1",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.2.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.3.5",
"typescript": "^5.2.2",
"vite": "^4.5.0"
},
"eslintConfig": {
"extends": "@haaxor1689/eslint-config",
"parserOptions": {
"project": [
"./tsconfig.node.json",
"./tsconfig.web.json"
]
},
"rules": {
"@next/next/no-img-element": "off"
}
},
"prettier": "@haaxor1689/prettier-config"
}
+7
View File
@@ -0,0 +1,7 @@
module.exports = {
plugins: {
'tailwindcss/nesting': 'postcss-nested',
'tailwindcss': {},
'autoprefixer': {}
}
};
+7
View File
@@ -0,0 +1,7 @@
# Copy this file to server/.env and set SOURCE_DIR to your local WoW client directory.
# This is the root of the WoW 1.12.1 client tree that the dev server will serve as CDN.
# The directory should contain WoW.exe, Data/, Interface/, etc.
SOURCE_DIR=C:\WoW\client
# optional: path to a JSON file overriding the bundled addon sources list.
# ADDONS_SOURCES_PATH=/path/to/addons-sources.json
+951
View File
@@ -0,0 +1,951 @@
{
"name": "server",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "server",
"version": "1.0.0",
"dependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20.9.0",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg=="
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
"integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA=="
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag=="
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow=="
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA=="
},
"node_modules/@types/body-parser": {
"version": "1.19.5",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
"integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==",
"dependencies": {
"@types/connect": "*",
"@types/node": "*"
}
},
"node_modules/@types/connect": {
"version": "3.4.38",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/express": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
"integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==",
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.33",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.41",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz",
"integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==",
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*",
"@types/send": "*"
}
},
"node_modules/@types/http-errors": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
"integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA=="
},
"node_modules/@types/mime": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w=="
},
"node_modules/@types/node": {
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@types/qs": {
"version": "6.9.10",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz",
"integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw=="
},
"node_modules/@types/range-parser": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
"integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ=="
},
"node_modules/@types/send": {
"version": "0.17.4",
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",
"integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==",
"dependencies": {
"@types/mime": "^1",
"@types/node": "*"
}
},
"node_modules/@types/serve-static": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz",
"integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==",
"dependencies": {
"@types/http-errors": "*",
"@types/mime": "*",
"@types/node": "*"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/acorn": {
"version": "8.11.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
"integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz",
"integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/body-parser": {
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.11.0",
"raw-body": "2.5.1",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz",
"integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==",
"dependencies": {
"function-bind": "^1.1.2",
"get-intrinsic": "^1.2.1",
"set-function-length": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/define-data-property": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz",
"integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==",
"dependencies": {
"get-intrinsic": "^1.2.1",
"gopd": "^1.0.1",
"has-property-descriptors": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.1",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.5.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.2.0",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.7",
"qs": "6.11.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.18.0",
"serve-static": "1.15.0",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/finalhandler": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fs-extra": {
"version": "11.1.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz",
"integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=14.14"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz",
"integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==",
"dependencies": {
"function-bind": "^1.1.2",
"has-proto": "^1.0.1",
"has-symbols": "^1.0.3",
"hasown": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/gopd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"dependencies": {
"get-intrinsic": "^1.1.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
},
"node_modules/has-property-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz",
"integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==",
"dependencies": {
"get-intrinsic": "^1.2.2"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
"integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
"integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"dependencies": {
"side-channel": "^1.0.4"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/serve-static": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.18.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/set-function-length": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz",
"integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==",
"dependencies": {
"define-data-property": "^1.1.1",
"get-intrinsic": "^1.2.1",
"gopd": "^1.0.1",
"has-property-descriptors": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dependencies": {
"call-bind": "^1.0.0",
"get-intrinsic": "^1.0.2",
"object-inspect": "^1.9.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/ts-node": {
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg=="
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"engines": {
"node": ">=6"
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"name": "server",
"version": "1.0.0",
"main": "index.ts",
"type": "module",
"scripts": {
"dev": "node --loader ts-node/esm src/index.ts"
},
"dependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20.9.0",
"dotenv": "^16.0.0",
"express": "^4.18.2",
"fs-extra": "^11.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"eslintConfig": {
"extends": "@haaxor1689/eslint-config"
},
"prettier": "@haaxor1689/prettier-config"
}
+680
View File
@@ -0,0 +1,680 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@types/express':
specifier: ^4.17.21
version: 4.17.21
'@types/node':
specifier: ^20.9.0
version: 20.9.0
express:
specifier: ^4.18.2
version: 4.18.2
fs-extra:
specifier: ^11.1.1
version: 11.1.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/node@20.9.0)(typescript@5.2.2)
typescript:
specifier: ^5.2.2
version: 5.2.2
packages:
/@cspotcode/source-map-support@0.8.1:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/trace-mapping': 0.3.9
dev: false
/@jridgewell/resolve-uri@3.1.1:
resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==}
engines: {node: '>=6.0.0'}
dev: false
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
dev: false
/@jridgewell/trace-mapping@0.3.9:
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
dependencies:
'@jridgewell/resolve-uri': 3.1.1
'@jridgewell/sourcemap-codec': 1.4.15
dev: false
/@tsconfig/node10@1.0.9:
resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==}
dev: false
/@tsconfig/node12@1.0.11:
resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
dev: false
/@tsconfig/node14@1.0.3:
resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
dev: false
/@tsconfig/node16@1.0.4:
resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
dev: false
/@types/body-parser@1.19.5:
resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==}
dependencies:
'@types/connect': 3.4.38
'@types/node': 20.9.0
dev: false
/@types/connect@3.4.38:
resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==}
dependencies:
'@types/node': 20.9.0
dev: false
/@types/express-serve-static-core@4.17.41:
resolution: {integrity: sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==}
dependencies:
'@types/node': 20.9.0
'@types/qs': 6.9.10
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
dev: false
/@types/express@4.17.21:
resolution: {integrity: sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==}
dependencies:
'@types/body-parser': 1.19.5
'@types/express-serve-static-core': 4.17.41
'@types/qs': 6.9.10
'@types/serve-static': 1.15.5
dev: false
/@types/http-errors@2.0.4:
resolution: {integrity: sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==}
dev: false
/@types/mime@1.3.5:
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
dev: false
/@types/mime@3.0.4:
resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==}
dev: false
/@types/node@20.9.0:
resolution: {integrity: sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==}
dependencies:
undici-types: 5.26.5
dev: false
/@types/qs@6.9.10:
resolution: {integrity: sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==}
dev: false
/@types/range-parser@1.2.7:
resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==}
dev: false
/@types/send@0.17.4:
resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==}
dependencies:
'@types/mime': 1.3.5
'@types/node': 20.9.0
dev: false
/@types/serve-static@1.15.5:
resolution: {integrity: sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==}
dependencies:
'@types/http-errors': 2.0.4
'@types/mime': 3.0.4
'@types/node': 20.9.0
dev: false
/accepts@1.3.8:
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
engines: {node: '>= 0.6'}
dependencies:
mime-types: 2.1.35
negotiator: 0.6.3
dev: false
/acorn-walk@8.3.0:
resolution: {integrity: sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==}
engines: {node: '>=0.4.0'}
dev: false
/acorn@8.11.2:
resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: false
/arg@4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: false
/array-flatten@1.1.1:
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
dev: false
/body-parser@1.20.1:
resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
dependencies:
bytes: 3.1.2
content-type: 1.0.5
debug: 2.6.9
depd: 2.0.0
destroy: 1.2.0
http-errors: 2.0.0
iconv-lite: 0.4.24
on-finished: 2.4.1
qs: 6.11.0
raw-body: 2.5.1
type-is: 1.6.18
unpipe: 1.0.0
transitivePeerDependencies:
- supports-color
dev: false
/bytes@3.1.2:
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
engines: {node: '>= 0.8'}
dev: false
/call-bind@1.0.5:
resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==}
dependencies:
function-bind: 1.1.2
get-intrinsic: 1.2.2
set-function-length: 1.1.1
dev: false
/content-disposition@0.5.4:
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
engines: {node: '>= 0.6'}
dependencies:
safe-buffer: 5.2.1
dev: false
/content-type@1.0.5:
resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==}
engines: {node: '>= 0.6'}
dev: false
/cookie-signature@1.0.6:
resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==}
dev: false
/cookie@0.5.0:
resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==}
engines: {node: '>= 0.6'}
dev: false
/create-require@1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: false
/debug@2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.0.0
dev: false
/define-data-property@1.1.1:
resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==}
engines: {node: '>= 0.4'}
dependencies:
get-intrinsic: 1.2.2
gopd: 1.0.1
has-property-descriptors: 1.0.1
dev: false
/depd@2.0.0:
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
engines: {node: '>= 0.8'}
dev: false
/destroy@1.2.0:
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
dev: false
/diff@4.0.2:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
dev: false
/ee-first@1.1.1:
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
dev: false
/encodeurl@1.0.2:
resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==}
engines: {node: '>= 0.8'}
dev: false
/escape-html@1.0.3:
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
dev: false
/etag@1.8.1:
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
engines: {node: '>= 0.6'}
dev: false
/express@4.18.2:
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
engines: {node: '>= 0.10.0'}
dependencies:
accepts: 1.3.8
array-flatten: 1.1.1
body-parser: 1.20.1
content-disposition: 0.5.4
content-type: 1.0.5
cookie: 0.5.0
cookie-signature: 1.0.6
debug: 2.6.9
depd: 2.0.0
encodeurl: 1.0.2
escape-html: 1.0.3
etag: 1.8.1
finalhandler: 1.2.0
fresh: 0.5.2
http-errors: 2.0.0
merge-descriptors: 1.0.1
methods: 1.1.2
on-finished: 2.4.1
parseurl: 1.3.3
path-to-regexp: 0.1.7
proxy-addr: 2.0.7
qs: 6.11.0
range-parser: 1.2.1
safe-buffer: 5.2.1
send: 0.18.0
serve-static: 1.15.0
setprototypeof: 1.2.0
statuses: 2.0.1
type-is: 1.6.18
utils-merge: 1.0.1
vary: 1.1.2
transitivePeerDependencies:
- supports-color
dev: false
/finalhandler@1.2.0:
resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==}
engines: {node: '>= 0.8'}
dependencies:
debug: 2.6.9
encodeurl: 1.0.2
escape-html: 1.0.3
on-finished: 2.4.1
parseurl: 1.3.3
statuses: 2.0.1
unpipe: 1.0.0
transitivePeerDependencies:
- supports-color
dev: false
/forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'}
dev: false
/fresh@0.5.2:
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
engines: {node: '>= 0.6'}
dev: false
/fs-extra@11.1.1:
resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==}
engines: {node: '>=14.14'}
dependencies:
graceful-fs: 4.2.11
jsonfile: 6.1.0
universalify: 2.0.1
dev: false
/function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
dev: false
/get-intrinsic@1.2.2:
resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==}
dependencies:
function-bind: 1.1.2
has-proto: 1.0.1
has-symbols: 1.0.3
hasown: 2.0.0
dev: false
/gopd@1.0.1:
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
dependencies:
get-intrinsic: 1.2.2
dev: false
/graceful-fs@4.2.11:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
dev: false
/has-property-descriptors@1.0.1:
resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==}
dependencies:
get-intrinsic: 1.2.2
dev: false
/has-proto@1.0.1:
resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==}
engines: {node: '>= 0.4'}
dev: false
/has-symbols@1.0.3:
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
engines: {node: '>= 0.4'}
dev: false
/hasown@2.0.0:
resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==}
engines: {node: '>= 0.4'}
dependencies:
function-bind: 1.1.2
dev: false
/http-errors@2.0.0:
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
engines: {node: '>= 0.8'}
dependencies:
depd: 2.0.0
inherits: 2.0.4
setprototypeof: 1.2.0
statuses: 2.0.1
toidentifier: 1.0.1
dev: false
/iconv-lite@0.4.24:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
engines: {node: '>=0.10.0'}
dependencies:
safer-buffer: 2.1.2
dev: false
/inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: false
/ipaddr.js@1.9.1:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
engines: {node: '>= 0.10'}
dev: false
/jsonfile@6.1.0:
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
dependencies:
universalify: 2.0.1
optionalDependencies:
graceful-fs: 4.2.11
dev: false
/make-error@1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
dev: false
/media-typer@0.3.0:
resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}
engines: {node: '>= 0.6'}
dev: false
/merge-descriptors@1.0.1:
resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==}
dev: false
/methods@1.1.2:
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
engines: {node: '>= 0.6'}
dev: false
/mime-db@1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types@2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/mime@1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
engines: {node: '>=4'}
hasBin: true
dev: false
/ms@2.0.0:
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
dev: false
/ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: false
/negotiator@0.6.3:
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
engines: {node: '>= 0.6'}
dev: false
/object-inspect@1.13.1:
resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==}
dev: false
/on-finished@2.4.1:
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
engines: {node: '>= 0.8'}
dependencies:
ee-first: 1.1.1
dev: false
/parseurl@1.3.3:
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
engines: {node: '>= 0.8'}
dev: false
/path-to-regexp@0.1.7:
resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==}
dev: false
/proxy-addr@2.0.7:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
dependencies:
forwarded: 0.2.0
ipaddr.js: 1.9.1
dev: false
/qs@6.11.0:
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
engines: {node: '>=0.6'}
dependencies:
side-channel: 1.0.4
dev: false
/range-parser@1.2.1:
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
engines: {node: '>= 0.6'}
dev: false
/raw-body@2.5.1:
resolution: {integrity: sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==}
engines: {node: '>= 0.8'}
dependencies:
bytes: 3.1.2
http-errors: 2.0.0
iconv-lite: 0.4.24
unpipe: 1.0.0
dev: false
/safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: false
/safer-buffer@2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
dev: false
/send@0.18.0:
resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==}
engines: {node: '>= 0.8.0'}
dependencies:
debug: 2.6.9
depd: 2.0.0
destroy: 1.2.0
encodeurl: 1.0.2
escape-html: 1.0.3
etag: 1.8.1
fresh: 0.5.2
http-errors: 2.0.0
mime: 1.6.0
ms: 2.1.3
on-finished: 2.4.1
range-parser: 1.2.1
statuses: 2.0.1
transitivePeerDependencies:
- supports-color
dev: false
/serve-static@1.15.0:
resolution: {integrity: sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==}
engines: {node: '>= 0.8.0'}
dependencies:
encodeurl: 1.0.2
escape-html: 1.0.3
parseurl: 1.3.3
send: 0.18.0
transitivePeerDependencies:
- supports-color
dev: false
/set-function-length@1.1.1:
resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==}
engines: {node: '>= 0.4'}
dependencies:
define-data-property: 1.1.1
get-intrinsic: 1.2.2
gopd: 1.0.1
has-property-descriptors: 1.0.1
dev: false
/setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
dev: false
/side-channel@1.0.4:
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
dependencies:
call-bind: 1.0.5
get-intrinsic: 1.2.2
object-inspect: 1.13.1
dev: false
/statuses@2.0.1:
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
engines: {node: '>= 0.8'}
dev: false
/toidentifier@1.0.1:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
dev: false
/ts-node@10.9.1(@types/node@20.9.0)(typescript@5.2.2):
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
'@swc/core': '>=1.2.50'
'@swc/wasm': '>=1.2.50'
'@types/node': '*'
typescript: '>=2.7'
peerDependenciesMeta:
'@swc/core':
optional: true
'@swc/wasm':
optional: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.4
'@types/node': 20.9.0
acorn: 8.11.2
acorn-walk: 8.3.0
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.2.2
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: false
/type-is@1.6.18:
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
engines: {node: '>= 0.6'}
dependencies:
media-typer: 0.3.0
mime-types: 2.1.35
dev: false
/typescript@5.2.2:
resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==}
engines: {node: '>=14.17'}
hasBin: true
dev: false
/undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
dev: false
/universalify@2.0.1:
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
engines: {node: '>= 10.0.0'}
dev: false
/unpipe@1.0.0:
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
engines: {node: '>= 0.8'}
dev: false
/utils-merge@1.0.1:
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
engines: {node: '>= 0.4.0'}
dev: false
/v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
dev: false
/vary@1.1.2:
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
engines: {node: '>= 0.8'}
dev: false
/yn@3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}
dev: false
+192
View File
@@ -0,0 +1,192 @@
import fs from 'fs-extra';
import path from 'path';
import { defaultSources, type AddonSource } from './addons-sources.js';
const CACHE_TTL_MS = 60 * 60 * 1000;
const FETCH_CONCURRENCY = 8;
const FETCH_TIMEOUT_MS = 10_000;
const SOURCES_OVERRIDE_PATH = process.env.ADDONS_SOURCES_PATH ?? '';
export type TocData = Record<string, string>;
export type ResolvedAddon = {
name: string;
owner: string;
git: string;
branch?: string;
ref?: string;
toc?: TocData;
description?: string;
lastUpdated?: string;
stars?: number;
};
type CacheEntry = { at: number; data: ResolvedAddon[] };
let cache: CacheEntry | undefined;
let inFlight: Promise<ResolvedAddon[]> | undefined;
const parseToc = (content: string): TocData =>
content
.split('\n')
.filter(l => l.startsWith('## '))
.map(l => l.slice(3))
.map(l => {
const idx = l.indexOf(':');
if (idx === -1) return null;
return [l.slice(0, idx).trim(), l.slice(idx + 1).trim()] as const;
})
.filter((e): e is readonly [string, string] => !!e)
.reduce<TocData>((acc, [k, v]) => {
acc[k] = v;
return acc;
}, {});
const fetchWithTimeout = async (url: string, init?: RequestInit) => {
const controller = new AbortController();
const t = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
try {
return await fetch(url, { ...init, signal: controller.signal });
} finally {
clearTimeout(t);
}
};
const parseGitUrl = (git: string) => {
// https://github.com/{owner}/{repo}.git
const m = git.match(/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);
if (!m || !m[1] || !m[2]) throw Error(`Unsupported git URL: ${git}`);
return { owner: m[1], repo: m[2] };
};
const resolveOne = async (src: AddonSource): Promise<ResolvedAddon | null> => {
try {
const { owner, repo } = parseGitUrl(src.git);
const name = src.name ?? repo;
const branch = src.branch ?? 'master';
const tocRef = src.ref ?? branch;
const tocUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${tocRef}/${name}.toc`;
const apiUrl = `https://api.github.com/repos/${owner}/${repo}`;
const [tocRes, apiRes] = await Promise.all([
fetchWithTimeout(tocUrl).catch(() => null),
fetchWithTimeout(apiUrl, {
headers: {
Accept: 'application/vnd.github+json',
...(process.env.GITHUB_TOKEN && {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`
})
}
}).catch(() => null)
]);
let toc: TocData | undefined;
if (tocRes?.ok) {
const parsed = parseToc(await tocRes.text());
const required = ['Interface', 'Title', 'Author', 'Notes', 'Version'];
if (required.every(k => typeof parsed[k] === 'string')) {
toc = parsed;
}
}
let description: string | undefined;
let lastUpdated: string | undefined;
let stars: number | undefined;
if (apiRes?.ok) {
const meta = (await apiRes.json()) as {
description?: string;
pushed_at?: string;
stargazers_count?: number;
};
description = meta.description ?? undefined;
lastUpdated = meta.pushed_at;
stars = meta.stargazers_count;
}
if (src.description) {
description = src.description;
if (toc) toc = { ...toc, Notes: src.description };
}
const result: ResolvedAddon = { name, owner, git: src.git };
if (src.branch !== undefined) result.branch = src.branch;
if (src.ref !== undefined) result.ref = src.ref;
if (toc !== undefined) result.toc = toc;
if (description !== undefined) result.description = description;
if (lastUpdated !== undefined) result.lastUpdated = lastUpdated;
if (stars !== undefined) result.stars = stars;
return result;
} catch (e) {
console.error(`Failed to resolve ${src.git}:`, e);
return null;
}
};
const poolMap = async <T, R>(
items: T[],
concurrency: number,
fn: (item: T) => Promise<R>
): Promise<R[]> => {
const results: R[] = new Array(items.length);
let idx = 0;
const worker = async () => {
while (true) {
const i = idx++;
if (i >= items.length) return;
const item = items[i];
if (item === undefined) return;
results[i] = await fn(item);
}
};
await Promise.all(Array.from({ length: concurrency }, worker));
return results;
};
const loadSources = async (): Promise<AddonSource[]> => {
if (!SOURCES_OVERRIDE_PATH) return defaultSources;
try {
if (await fs.pathExists(SOURCES_OVERRIDE_PATH)) {
const override = (await fs.readJSON(SOURCES_OVERRIDE_PATH)) as AddonSource[];
if (Array.isArray(override) && override.length > 0) {
console.log(`Using addon sources override from ${SOURCES_OVERRIDE_PATH}`);
return override;
}
}
} catch (e) {
console.error(`Failed to read override at ${SOURCES_OVERRIDE_PATH}, using defaults:`, e);
}
return defaultSources;
};
const buildList = async (): Promise<ResolvedAddon[]> => {
const sources = await loadSources();
console.log(`Resolving metadata for ${sources.length} addons (concurrency=${FETCH_CONCURRENCY})...`);
const t0 = Date.now();
const results = await poolMap(sources, FETCH_CONCURRENCY, resolveOne);
const ok = results.filter((r): r is ResolvedAddon => r !== null);
ok.sort((a, b) => a.name.localeCompare(b.name));
console.log(`Resolved ${ok.length}/${sources.length} addons in ${Date.now() - t0}ms`);
return ok;
};
export const getAddons = async (force = false): Promise<ResolvedAddon[]> => {
if (!force && cache && Date.now() - cache.at < CACHE_TTL_MS) {
return cache.data;
}
// Deduplicate concurrent callers — only one scrape in flight at a time.
if (inFlight) return inFlight;
inFlight = buildList()
.then(data => {
cache = { at: Date.now(), data };
return data;
})
.finally(() => {
inFlight = undefined;
});
return inFlight;
};
export const warmUp = () => {
getAddons().catch(e => console.error('Addon resolver warm-up failed:', e));
};
+196
View File
@@ -0,0 +1,196 @@
export type AddonSource = {
git: string;
branch?: string;
name?: string;
description?: string;
ref?: string;
};
export const defaultSources: AddonSource[] = [
{ git: 'https://github.com/CosminPOP/AtlasLoot.git', name: 'AtlasLoot' },
{
git: 'https://github.com/byCFM2/Atlas-TW.git',
branch: 'main',
ref: 'pre-rewrite-backup'
},
{
git: 'https://github.com/shirsig/aux-addon-vanilla.git',
name: 'aux-addon',
description: 'Auction House replacement with advanced filtering and search'
},
{ git: 'https://github.com/absir/Bagshui.git', branch: 'main' },
{ git: 'https://github.com/pepopo978/BetterCharacterStats.git', branch: 'main' },
{ git: 'https://github.com/pepopo978/BigWigs.git' },
{
git: 'https://github.com/DBFBlackbull/BitesCookBook.git',
description: 'Tracks which items are used in cooking and what they create'
},
{ git: 'https://github.com/bhhandley/CleveRoidMacros.git', branch: 'main' },
{
git: 'https://github.com/Cinecom/ConsumesManager.git',
branch: 'main',
description: 'Tracks consumables and food buffs across alts, bank, and mail'
},
{
git: 'https://github.com/Kirchlive/cursive-raid.git',
name: 'Cursive-Raid',
description: 'Raid debuff tracker with profiles and multi-curse assist (SuperWoW)'
},
{ git: 'https://github.com/Player-Doite/DoiteAuras.git', branch: 'main' },
{ git: 'https://github.com/Stormhand-dev/DragonflightUI-Reforged.git', branch: 'main' },
{
git: 'https://github.com/Fiurs-Hearth/ExtraResourceBars.git',
description: 'Adds extra resource bars (mana, energy, rage) to the UI'
},
{ git: 'https://github.com/tilare/FlightTracker.git', branch: 'main' },
{ git: 'https://github.com/lookino/Flyout.git', branch: 'main' },
{
git: 'https://github.com/trumpetx/GetHead.git',
description: 'Recovers Onyxia and Nefarian heads from disenchant grief'
},
{
git: 'https://github.com/zanthor/GNS.git',
branch: 'main',
description: 'Custom naming for Goblin Brainwashing Device specializations'
},
{ git: 'https://github.com/vatichild/guda.git', name: 'Guda', branch: 'main' },
{ git: 'https://github.com/vatichild/GudaPlates.git', branch: 'main' },
{ git: 'https://github.com/andresuarezschou/HCDeaths.git', branch: 'main' },
{
git: 'https://github.com/Arthur-Helias/InstanceJournal.git',
description: "Encounter Journal reimagined for Turtle WoW"
},
{
git: 'https://github.com/Einherjarn/ItemRack.git',
description: 'Item set manager with quick-swap menus for inventory'
},
{
git: 'https://github.com/CosminPOP/_LazyPig.git',
name: '_LazyPig',
description: 'Auto-dismount, auto-accept, auto-roll, and chat spam filter. /lp to configure'
},
{ git: 'https://github.com/Spartelfant/LevelRange-Turtle.git', branch: 'main' },
{ git: 'https://github.com/tilare/MessageBox.git', branch: 'main' },
{
git: 'https://github.com/tdymel/ModifiedPowerAuras.git',
description: "Advanced version of Sinesther's Power Auras"
},
{
git: 'https://github.com/tilare/ModernMapMarkers.git',
branch: 'main',
description: 'Shows dungeons, raids, world bosses, and travel routes on the world map'
},
{
git: 'https://github.com/vegeta1k95/ModernSpellBook.git',
description: 'Retail-style spellbook UI for vanilla'
},
{ git: 'https://github.com/tilare/MovementTracker.git', branch: 'main' },
{
git: 'https://github.com/pepopo978/NampowerSettings.git',
description: 'Settings panel for the Nampower spellqueue addon'
},
{
git: 'https://github.com/BlackHobbiT/necrosis-twow.git',
branch: 'main',
description: 'Warlock helper: pets, soul shards, summoning, demon timers'
},
{
git: 'https://github.com/zanthor/OG-RaidHelper.git',
branch: 'main',
description: 'Raid management: roles, trade distribution, soft-reserve validation'
},
{
git: 'https://github.com/CosminPOP/PallyPower.git',
description: 'Paladin buff and assignment manager for raids and parties'
},
{
git: 'https://github.com/Cliencer/pfExtend.git',
branch: 'main',
description: 'pfQuest extension showing all monster drops and quest chains. /pfex'
},
{ git: 'https://github.com/shagu/pfQuest.git' },
{ git: 'https://github.com/shagu/pfQuest-turtle.git' },
{ git: 'https://github.com/shagu/pfUI.git' },
{
git: 'https://github.com/jrc13245/pfUI-addonskinner.git',
branch: 'main',
description: 'pfUI module that re-skins other addons to match the pfUI theme'
},
{
git: 'https://github.com/Bombg/pfUI-bettertotems.git',
branch: 'main',
description: 'pfUI module with improved Shaman totem timers'
},
{
git: 'https://github.com/Arthur-Helias/pfUI-LocationPlus.git',
name: 'pfUI-locplus',
description: 'Adds a location panel and zone info to pfUI'
},
{ git: 'https://github.com/acid9000/PizzaWorldBuffs.git', branch: 'main' },
{
git: 'https://github.com/npfs666/ProcDoc.git',
branch: 'main',
description: 'Visual proc alerts with pulsing images so you never miss them'
},
{ git: 'https://github.com/SabineWren/Quiver.git', branch: 'main' },
{
git: 'https://github.com/hazlema/Rested.git',
description: 'Progress bar showing your rested XP while resting'
},
{ git: 'https://github.com/Otari98/Rinse.git' },
{
git: 'https://github.com/anzz1/SellValue.git',
description: 'Shows item vendor sell value in tooltips when not at a vendor'
},
{ git: 'https://github.com/shagu/ShaguDPS.git' },
{
git: 'https://github.com/shagu/ShaguPlates.git',
description: 'Nameplates with castbars and class colors. /splates'
},
{ git: 'https://github.com/shagu/ShaguTweaks.git' },
{
git: 'https://github.com/shagu/ShaguTweaks-extras.git',
description: 'Extras module for ShaguTweaks (additional UI tweaks)'
},
{ git: 'https://github.com/pepopo978/SimpleActionSets.git' },
{ git: 'https://github.com/Siventt/AttackBar.git' },
{
git: 'https://github.com/Player-Doite/Tactica.git',
branch: 'main',
description: 'Auto-build raids: invite/gearcheck, tactics, masterloot, role sync'
},
{
git: 'https://github.com/Otari98/Tmog.git',
description: 'Transmog item browser with collection info in tooltips'
},
{
git: 'https://github.com/whtmst/T-RestedXP.git',
branch: 'main',
description: 'Tracks 0% and 100% rested XP thresholds'
},
{ git: 'https://github.com/sica42/TurtleCalendar.git', branch: 'main' },
{
git: 'https://github.com/sica42/TurtleMail.git',
description: 'Mailbox UI enhancement: bulk send, search, multi-mail'
},
{ git: 'https://github.com/tempranova/turtlerp.git', name: 'TurtleRP', branch: 'main' },
{ git: 'https://github.com/CosminPOP/TWThreat.git' },
{
git: 'https://github.com/whtmst/UnitXP_SP3_Addon.git',
branch: 'main',
description: 'Settings UI for the UnitXP SuperWoW client patch'
},
{
git: 'https://github.com/tdymel/VCB.git',
description: 'Smart consolidated buff frames with extensive customization'
},
{
git: 'https://github.com/Fiurs-Hearth/WIIIUI.git',
description: 'Compact custom UI replacement for Turtle WoW'
},
{ git: 'https://github.com/refaim/WIM.git' },
{
git: 'https://github.com/Arthur-Helias/ZonesLevel.git',
description: "Shows zone level range under the title on the world map"
}
];
+123
View File
@@ -0,0 +1,123 @@
import crypto from 'crypto';
import path from 'path';
import fs from 'fs-extra';
const allowedExtra = [
'.launcher',
'Data',
'Errors',
'Interface\\AddOns',
'Logs',
'Screenshots',
'WDB',
'WTF\\Account'
];
const vanillaFixes = ['VfPatcher.dll', 'd3d9.dll', 'dxvk.conf'];
const skipFiles = new Set(['manifest.json', 'wow-client.zip', '.gitkeep']);
type FolderTags = 'allowExtra';
type FileTags = 'vanillaFixes';
type FileManifest = { name: string } & (
| { type: 'dir'; files: FileManifest[]; tags?: FolderTags[] }
| { type: 'mpq'; files: FileManifest[]; hash: string; size: number }
| {
type: 'file';
hash: string;
version?: number;
size: number;
tags?: FileTags[];
}
);
const getHash = (...filePath: string[]): Promise<string> =>
new Promise((resolve, reject) => {
const hash = crypto.createHash('sha1');
const stream = fs.createReadStream(path.join(...filePath));
stream.on('error', reject);
stream.on('data', (chunk: Buffer) => hash.update(chunk));
stream.on('end', () => resolve(hash.digest('hex').toLocaleUpperCase()));
});
export const buildCache = async (clientPath: string) => {
console.log('Building cache...');
const buildTree = async (...filePath: string[]): Promise<FileManifest[]> => {
const files = await fs.readdir(path.join(clientPath, ...filePath));
const patches: string[] = [];
const tree: FileManifest[] = [];
for (const file of files.sort()) {
if (skipFiles.has(file)) continue;
const stats = await fs.stat(path.join(clientPath, ...filePath, file));
if (stats.isDirectory()) {
if (file.match(/patch-./)) {
patches.push(file);
tree.push({
type: 'mpq',
name: file,
files: await buildTree(...filePath, file),
size: (
await fs.stat(path.join(clientPath, ...filePath, `${file}.mpq`))
).size,
hash: await getHash(clientPath, ...filePath, `${file}.mpq`)
});
} else {
const tags: FolderTags[] = [];
allowedExtra.includes(path.join(...filePath, file)) &&
tags.push('allowExtra');
tree.push({
type: 'dir',
name: file,
files: await buildTree(...filePath, file),
tags: tags.length ? tags : undefined
});
}
continue;
}
// Skip if extracted mpq patch
if (patches.find(v => file.match(v))) continue;
const allowModifiedPaths = new Set([
'WTF/Config.wtf',
'Data/fonts.MPQ',
'Data/sound.MPQ',
'Data/speech.MPQ'
]);
const fullPath = path
.join(...filePath, file)
.split(path.sep)
.join('/');
const allowModified =
file === 'WoW.exe' || allowModifiedPaths.has(fullPath);
const tags: FileTags[] = [];
vanillaFixes.includes(file) && tags.push('vanillaFixes');
tree.push({
type: 'file',
name: file,
hash: await getHash(clientPath, ...filePath, file),
version: allowModified ? stats.mtimeMs : undefined,
size: stats.size,
tags: tags.length ? tags : undefined
});
}
return tree;
};
await fs.writeJSON(path.join(clientPath, 'manifest.json'), {
build: 3,
buildName: '3',
root: {
type: 'dir',
name: '',
files: await buildTree()
}
});
};
+88
View File
@@ -0,0 +1,88 @@
import path from 'path';
import { config as loadEnv } from 'dotenv';
import express from 'express';
loadEnv();
import fs from 'fs-extra';
import { buildCache } from './cache.js';
import { getAddons, warmUp as warmUpAddons } from './addons-resolver.js';
// Set SOURCE_DIR to your local WoW client directory (see server/.env.example).
const SourceDir: string = (() => {
const dir = process.env.SOURCE_DIR;
if (!dir) {
console.error(
'ERROR: SOURCE_DIR is not set.\n' +
'Set it to your local WoW client directory.\n' +
'Example: SOURCE_DIR="C:\\\\WoW\\\\client" npm run dev\n' +
'Or create server/.env — see server/.env.example.'
);
process.exit(1);
}
return dir;
})();
const app = express();
const port = 5000;
let buildInFlight: Promise<void> | null = null;
const ensureManifestBuilt = (): Promise<void> => {
if (buildInFlight) return buildInFlight;
buildInFlight = buildCache(SourceDir).catch(e => {
buildInFlight = null;
throw e;
});
return buildInFlight;
};
app.get('/api/file/:version/manifest.json', async (_req, res) => {
console.log(`Fetching manifest`);
const filePath = path.join(SourceDir, 'manifest.json');
if (!fs.existsSync(filePath)) await ensureManifestBuilt();
res.json(await fs.readJSON(filePath));
});
app.get(
'/api/file/:version/*',
async (req: express.Request<{ 0: string }>, res) => {
const filePath = req.params[0];
const resolved = path.resolve(SourceDir, filePath);
if (!resolved.startsWith(path.resolve(SourceDir) + path.sep)) {
res.status(403).send('Forbidden');
return;
}
console.log(`Fetching file: ${filePath}`);
res.sendFile(resolved);
}
);
app.get('/api/addons.json', async (req, res) => {
try {
const force = req.query.refresh === '1';
const addons = await getAddons(force);
res.json(addons);
} catch (e) {
console.error('Failed to resolve addons:', e);
res.status(500).json({ error: 'Failed to resolve addons' });
}
});
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
warmUpAddons();
void (async () => {
const manifestPath = path.join(SourceDir, 'manifest.json');
if (fs.existsSync(manifestPath)) return;
console.log(`Pre-warming manifest cache for ${SourceDir}...`);
try {
await ensureManifestBuilt();
console.log(`Manifest cache pre-warm complete.`);
} catch (e) {
console.error('Manifest pre-warm failed:', e);
}
})();
});
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"noUncheckedIndexedAccess": true,
"rootDir": "src"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"],
}
+180
View File
@@ -0,0 +1,180 @@
import { z } from 'zod';
export const ModIdSchema = z.enum([
'dxvk',
'nampower',
'multiMonitorFix',
'transmogFix',
'unitXp',
'vanillaFixes',
'vanillaHelpers'
]);
export type ModId = z.infer<typeof ModIdSchema>;
export type ModSource =
| {
kind: 'directFile';
url: string;
versionUrl?: string;
latestVersionUrl?: string;
parseLatest?: 'githubRelease' | 'gitlabRelease' | 'codebergRelease';
apiUrl?: string;
pinnedTag?: string;
assetName: string;
}
| {
kind: 'archive';
url: string;
latestVersionUrl?: string;
apiUrl?: string;
parseLatest?: 'githubRelease' | 'gitlabRelease' | 'codebergRelease';
pinnedTag?: string;
format: 'zip' | 'tar.gz';
extractMap: Record<string, string>;
}
| { kind: 'managed' };
export type ModEntry = {
id: ModId;
name: string;
version: string;
description: string;
recommended?: boolean;
requires?: ModId[];
repoUrl: string;
source: ModSource;
registerInDllsTxt?: string;
};
export const MODS: ModEntry[] = [
{
id: 'dxvk',
name: 'dxvk',
version: 'v2.7.1-1',
description: 'Enables Vulkan based rendering mode for better performance.',
recommended: true,
repoUrl: 'https://gitlab.com/Ph42oN/dxvk-gplasync',
source: {
kind: 'archive',
url: 'https://gitlab.com/Ph42oN/dxvk-gplasync/-/raw/main/releases/dxvk-gplasync-v2.7.1-1.tar.gz?ref_type=heads',
pinnedTag: 'v2.7.1-1',
format: 'tar.gz',
extractMap: {
'dxvk-gplasync-v2.7.1-1/x32/d3d9.dll': 'd3d9.dll'
}
}
},
{
id: 'nampower',
name: 'nampower',
version: 'v4.6.0',
description:
'A client modification that minimizes your input lag if you have higher latency.',
repoUrl: 'https://gitea.com/avitasia/nampower',
requires: ['vanillaFixes'],
source: {
kind: 'directFile',
url: 'https://gitea.com/avitasia/nampower/releases/download/v4.6.0/nampower.dll',
pinnedTag: 'v4.6.0',
assetName: 'nampower.dll'
},
registerInDllsTxt: 'nampower.dll'
},
{
id: 'multiMonitorFix',
name: 'no1600x1200',
version: '0.2',
description: 'Fix for larger resolutions or multi monitor setups.',
repoUrl: 'https://github.com/Mates1500/VanillaMultiMonitorFix',
requires: ['vanillaFixes'],
source: {
kind: 'archive',
url: 'https://github.com/Mates1500/VanillaMultiMonitorFix/releases/download/0.2/release.zip',
apiUrl:
'https://api.github.com/repos/Mates1500/VanillaMultiMonitorFix/releases/latest',
parseLatest: 'githubRelease',
pinnedTag: '0.2',
format: 'zip',
extractMap: {
'VanillaMultiMonitorFix.dll': 'VanillaMultiMonitorFix.dll'
}
},
registerInDllsTxt: 'VanillaMultiMonitorFix.dll'
},
{
id: 'transmogFix',
name: 'transmogFix',
version: 'v0.7.0',
description:
"A client-side fix that eliminates frame drops caused by the server's transmogrification durability workaround.",
repoUrl: 'https://codeberg.org/MarcelineVQ/WeirdUtils',
requires: ['vanillaFixes'],
source: {
kind: 'directFile',
url: 'https://codeberg.org/MarcelineVQ/WeirdUtils/releases/download/v0.7.0/transmogfix.dll',
pinnedTag: 'v0.7.0',
assetName: 'transmogfix.dll'
},
registerInDllsTxt: 'transmogfix.dll'
},
{
id: 'unitXp',
name: 'unitXp',
version: 'v89',
description: 'An attempt to make Vanilla 1.12 modern.',
repoUrl: 'https://codeberg.org/konaka/UnitXP_SP3',
requires: ['vanillaFixes'],
source: {
kind: 'archive',
url: 'https://codeberg.org/konaka/UnitXP_SP3/releases/download/v89/UnitXP_SP3%20v89.zip',
pinnedTag: 'v89',
format: 'zip',
extractMap: {
'UnitXP_SP3.dll': 'UnitXP_SP3.dll'
}
},
registerInDllsTxt: 'UnitXP_SP3.dll'
},
{
id: 'vanillaFixes',
name: 'vanillaFixes',
version: 'v1.5.3',
description: 'A client modification that eliminates stutter and animation lag.',
recommended: true,
repoUrl: 'https://github.com/hannesmann/vanillafixes',
source: {
kind: 'archive',
url: 'https://github.com/hannesmann/vanillafixes/releases/download/v1.5.3/vanillafixes-1.5.3.zip',
apiUrl:
'https://api.github.com/repos/hannesmann/vanillafixes/releases/latest',
parseLatest: 'githubRelease',
pinnedTag: 'v1.5.3',
format: 'zip',
extractMap: {
'VfPatcher.dll': 'VfPatcher.dll',
'VanillaFixes.exe': 'VanillaFixes.exe'
}
}
},
{
id: 'vanillaHelpers',
name: 'vanillaHelpers',
version: 'v1.1.2',
description: 'Utility library that might be required by other patches and addons.',
repoUrl: 'https://github.com/isfir/VanillaHelpers',
requires: ['vanillaFixes'],
source: {
kind: 'directFile',
url: 'https://github.com/isfir/VanillaHelpers/releases/download/v1.1.2/VanillaHelpers.dll',
apiUrl:
'https://api.github.com/repos/isfir/VanillaHelpers/releases/latest',
parseLatest: 'githubRelease',
pinnedTag: 'v1.1.2',
assetName: 'VanillaHelpers.dll'
},
registerInDllsTxt: 'VanillaHelpers.dll'
}
];
export const getMod = (id: ModId): ModEntry | undefined =>
MODS.find(m => m.id === id);
+110
View File
@@ -0,0 +1,110 @@
import { z } from 'zod';
const f = {
boolean: (defaultValue?: boolean) =>
z.boolean().nullish().default(!!defaultValue),
number: (defaultValue?: number, val?: (v: z.ZodNumber) => z.ZodNumber) =>
z.preprocess(
v =>
v === '' || v === undefined
? defaultValue ?? null
: typeof v === 'string'
? Number(v)
: v,
(val?.(z.number()) ?? z.number()).nullish()
)
};
export const ConfigWtfSchema = z.object({
vanillaFixes: f.boolean(),
largeAddress: f.boolean(true),
nameplateRange: f.number(41),
alwaysAutoLoot: f.boolean(),
fieldOfView: f.number(110),
farClip: f.number(777),
frillDistance: f.number(70),
cameraDistance: f.number(50),
soundInBackground: f.boolean(true)
});
export type ConfigWtfSchema = z.infer<typeof ConfigWtfSchema>;
export const ModStateSchema = z.object({
enabled: z.boolean().default(false),
installedVersion: z.string().optional(),
installedFiles: z.array(z.string()).default([]),
ignoreUpdates: z.boolean().default(false)
});
export type ModState = z.infer<typeof ModStateSchema>;
export const PreferencesSchema = z.object({
isPortable: z.boolean().optional(),
server: z.enum(['live', 'ptr']).default('live'),
clientDir: z.string().optional(),
version: z.string().optional(),
lastPatchedLauncherVersion: z.string().optional(),
expectedPatchedWowHash: z.string().optional(),
minimizeToTrayOnPlay: f.boolean(true),
cleanWdb: f.boolean(),
rememberPosition: f.boolean(),
windowPosition: z
.object({
x: z.number(),
y: z.number(),
width: z.number(),
height: z.number()
})
.nullish(),
config: ConfigWtfSchema.default({}),
mods: z.record(ModStateSchema).default({})
});
export type PreferencesSchema = z.infer<typeof PreferencesSchema>;
export const TocDataSchema = z.object({
Interface: z.string(),
Title: z.string(),
Author: z.string(),
Notes: z.string(),
Version: z.string(),
Dependencies: z.string().optional(),
OptionalDeps: z.string().optional()
});
export type TocData = z.infer<typeof TocDataSchema>;
export const AddonDataSchema = z.object({
status: z.enum([
'available',
'fetching',
'unknown',
'upToDate',
'outOfDate',
'downloading',
'invalid'
]),
git: z.string().optional(),
toc: TocDataSchema.optional(),
description: z.string().optional(),
error: z.string().optional(),
branch: z.string().optional(),
ref: z.string().optional(),
folder: z.string(),
progress: z.string().optional(),
preview: z.string().optional()
});
export type AddonData = z.infer<typeof AddonDataSchema>;
export const NewsItemSchema = z.object({
id: z.string(),
title: z.string(),
date: z.string(),
body: z.string(),
url: z.string().url().optional(),
author: z.string().optional()
});
export type NewsItem = z.infer<typeof NewsItemSchema>;
export const NewsFeedSchema = z.object({
items: z.array(NewsItemSchema)
});
export type NewsFeed = z.infer<typeof NewsFeedSchema>;
+74
View File
@@ -0,0 +1,74 @@
type Path = readonly (string | number)[];
export const nestedGet = <T>(object: unknown, path: Path) =>
path.reduce((obj, key) => obj?.[key], object) as T;
export const nestedSet = (obj: any, path: Path, value: unknown) => {
const [key, ...rest] = path;
if (path.length === 1) {
obj[key] = value;
return;
}
if (obj[key] === undefined) {
obj[key] = typeof rest[0] === 'number' ? [] : {};
}
nestedSet(obj[key], rest as never, value);
};
export const asyncReduce = async <T, U>(
arr: T[],
reducer: (acc: U, cur: T) => Promise<U>,
init: U
): Promise<U> => {
let acc: U = init;
for (const i of arr) acc = await reducer(acc, i);
return acc;
};
export const asyncMap = async <T, U>(
arr: T[],
map: (cur: T) => Promise<U>
): Promise<U[]> => {
const acc: U[] = [];
for (const i of arr) acc.push(await map(i));
return acc;
};
export const isNotUndef = <T>(obj: T): obj is Exclude<T, undefined> =>
obj !== undefined;
export const formatFileSize = (bytes: number) => {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
let size = bytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${size.toFixed(2)} ${units[unitIndex]}`;
};
export const formatDuration = (remaining: number) => {
const hours = Math.floor(remaining / 3600);
const minutes = Math.floor((remaining % 3600) / 60);
const seconds = Math.floor(remaining % 60);
return `${hours ? `${hours}h ` : ''}${
minutes ? `${minutes}m ` : ''
}${seconds}s`;
};
export const omit = <T extends object, const K extends keyof T>(
obj: T,
keys: K[]
): Omit<T, K> => {
const result = { ...obj };
keys.forEach(key => {
delete result[key];
});
return result;
};
+24
View File
@@ -0,0 +1,24 @@
import { createTRPCRouter } from './trpc';
import { addonsRouter } from './routers/addonts';
import { launcherRouter } from './routers/launcher';
import { updaterRouter } from './routers/updater';
import { patcherRouter } from './routers/patcher';
import { generalRouter } from './routers/general';
import { preferencesRouter } from './routers/preferences';
import { newsRouter } from './routers/news';
import { modsRouter } from './routers/mods';
import { selfUpdaterRouter } from './routers/selfUpdater';
export const appRouter = createTRPCRouter({
addons: addonsRouter,
general: generalRouter,
preferences: preferencesRouter,
launcher: launcherRouter,
patcher: patcherRouter,
updater: updaterRouter,
news: newsRouter,
mods: modsRouter,
selfUpdater: selfUpdaterRouter
});
export type AppRouter = typeof appRouter;
+25
View File
@@ -0,0 +1,25 @@
import { z } from 'zod';
import Addons from '~main/modules/addons';
import { AddonDataSchema } from '~common/schemas';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const addonsRouter = createTRPCRouter({
verify: publicProcedure.mutation(() => {
Addons.verify();
}),
update: publicProcedure
.input(z.object({ toUpdate: z.array(z.string()).optional() }))
.mutation(({ input }) => Addons.update(input.toUpdate)),
install: publicProcedure
.input(AddonDataSchema)
.mutation(({ input }) => Addons.install(input)),
remove: publicProcedure
.input(z.object({ toDelete: z.array(z.string()) }))
.mutation(({ input }) => Addons.remove(input.toDelete)),
checkGitUrl: publicProcedure
.input(z.string())
.query(({ input }) => Addons.checkGitUrl(input)),
observe: publicProcedure.subscription(() => Addons.observe())
});
+69
View File
@@ -0,0 +1,69 @@
import { app, dialog, shell } from 'electron';
import Logger from 'electron-log/main';
import { z } from 'zod';
import { mainWindow } from '~main/index';
import Preferences from '~main/modules/preferences';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const generalRouter = createTRPCRouter({
appVersion: publicProcedure.query(() => app.getVersion()),
quit: publicProcedure.mutation(() => app.quit()),
minimize: publicProcedure.mutation(() => mainWindow?.minimize()),
openLink: publicProcedure
.input(z.string().url())
.mutation(({ input }) => shell.openExternal(input)),
openInstallFolder: publicProcedure.mutation(() => {
const dir = Preferences.data.clientDir;
if (dir) shell.openPath(dir);
}),
openLogFile: publicProcedure.mutation(() => {
const file = Logger.transports.file.getFile().path;
shell.openPath(file);
}),
filePicker: publicProcedure
.input(
z.object({
title: z.string().optional(),
message: z.string().optional(),
filters: z
.array(
z.object({
name: z.string(),
extensions: z.array(z.string())
})
)
.optional(),
properties: z
.array(
z.enum([
'openDirectory',
'openFile',
'multiSelections',
'showHiddenFiles',
'createDirectory',
'promptToCreate',
'noResolveAliases',
'treatPackageAsDirectory',
'dontAddToRecent'
])
)
.optional()
})
)
.mutation(async ({ input }) => {
if (!mainWindow) return { canceled: true } as const;
const { canceled, filePaths } = await dialog.showOpenDialog(
mainWindow,
input
);
return canceled
? ({ canceled: true } as const)
: ({
canceled: false,
path: filePaths as [string, ...string[]]
} as const);
})
});
+104
View File
@@ -0,0 +1,104 @@
import path from 'path';
import { spawn } from 'child_process';
import fs from 'fs-extra';
import { inject } from 'dll-inject';
import Logger from 'electron-log/main';
import Preferences from '~main/modules/preferences';
import Mods from '~main/modules/mods';
import { mainWindow } from '~main/index';
import { isGameRunning } from '~main/modules/updater';
import { patchConfig } from '~main/modules/patcher';
import { minimizeToTray, restoreFromTray } from '~main/modules/tray';
import { getMod } from '~common/mods';
import { createTRPCRouter, publicProcedure } from '../trpc';
const ensureChainloaderTweak = async (clientDir: string): Promise<boolean> => {
if (Preferences.data.config.vanillaFixes) return true;
const installedMods = Mods.status.mods.filter(r => r.installedVersion);
const anyDependsOnVf = installedMods.some(r =>
getMod(r.id)?.requires?.includes('vanillaFixes')
);
let dllsTxtHasEntries = false;
const dllsPath = path.join(clientDir, 'dlls.txt');
if (await fs.pathExists(dllsPath)) {
const raw = await fs.readFile(dllsPath, 'utf8');
dllsTxtHasEntries = raw
.split(/\r?\n/)
.some(l => l.trim() && !l.trim().startsWith('#'));
}
if (!anyDependsOnVf && !dllsTxtHasEntries) return false;
Logger.info(
`Auto-enabling vanillaFixes Tweak (chainloader required): ${
anyDependsOnVf ? 'a dependent mod is installed' : ''
}${anyDependsOnVf && dllsTxtHasEntries ? ' + ' : ''}${
dllsTxtHasEntries ? 'dlls.txt has user entries' : ''
}.`
);
Preferences.data = {
config: { ...Preferences.data.config, vanillaFixes: true }
};
return true;
};
export const launcherRouter = createTRPCRouter({
start: publicProcedure.mutation(async () => {
const { cleanWdb, minimizeToTrayOnPlay, config, clientDir } =
Preferences.data;
if (!clientDir) return false;
const clientPath = path.join(clientDir, 'WoW.exe');
Logger.log(`Launching ${clientPath}...`);
if (await isGameRunning(clientPath)) return false;
if (cleanWdb) {
Logger.log('Cleaning up WDB...');
await fs.remove(path.join(clientPath, 'WDB'));
}
Logger.log('Checking Config.wtf...');
await patchConfig();
Logger.log('Launching WoW...');
const process = spawn(clientPath, { detached: !minimizeToTrayOnPlay });
const wantChainloader = await ensureChainloaderTweak(clientDir);
if (wantChainloader) {
Logger.log('Injecting VanillaFixes...');
const vfPath = path.join(clientDir, 'VfPatcher.dll');
if (!(await fs.pathExists(vfPath))) {
Logger.warn(
`VfPatcher.dll missing at ${vfPath} — chainloader needed but ` +
'the vanillaFixes mod is not installed. Skipping inject; ' +
'dlls.txt entries and dependent mods will not load. Install ' +
"vanillaFixes from the Mods tab to fix."
);
} else {
const status = inject('WoW.exe', vfPath);
if (status) {
Logger.error(`Injecting failed with error code ${status}...`);
return true;
}
}
}
if (!minimizeToTrayOnPlay) {
mainWindow?.close();
return true;
}
minimizeToTray();
process.on('exit', () => {
Logger.log('WoW stopped');
restoreFromTray();
});
return true;
})
});
+19
View File
@@ -0,0 +1,19 @@
import { z } from 'zod';
import Mods from '~main/modules/mods';
import { ModIdSchema } from '~common/mods';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const modsRouter = createTRPCRouter({
list: publicProcedure.query(() => Mods.status),
verify: publicProcedure.mutation(() => Mods.verify()),
toggle: publicProcedure
.input(z.object({ id: ModIdSchema, enabled: z.boolean() }))
.mutation(({ input }) => Mods.toggle(input.id, input.enabled)),
setIgnoreUpdates: publicProcedure
.input(z.object({ id: ModIdSchema, ignore: z.boolean() }))
.mutation(({ input }) => Mods.setIgnoreUpdates(input.id, input.ignore)),
applyAll: publicProcedure.mutation(() => Mods.applyAll()),
observe: publicProcedure.subscription(() => Mods.observe())
});
+37
View File
@@ -0,0 +1,37 @@
import fetch from 'node-fetch';
import Logger from 'electron-log/main';
import { NewsFeedSchema, type NewsItem } from '~common/schemas';
import { createTRPCRouter, publicProcedure } from '../trpc';
const FETCH_TIMEOUT_MS = 8_000;
const fetchNews = async (): Promise<NewsItem[]> => {
const url = `${import.meta.env.MAIN_VITE_SERVER_URL || 'https://octowow.st'}/news.json`;
const controller = new AbortController();
const t = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
try {
const res = await fetch(url, { signal: controller.signal });
if (!res.ok) throw Error(`HTTP ${res.status}`);
const parsed = NewsFeedSchema.safeParse(await res.json());
if (!parsed.success) {
Logger.error('News feed failed schema validation', parsed.error.flatten());
throw Error('Malformed news feed');
}
return parsed.data.items;
} finally {
clearTimeout(t);
}
};
export const newsRouter = createTRPCRouter({
list: publicProcedure.query(async () => {
try {
return await fetchNews();
} catch (e) {
Logger.error('Failed to fetch news', e);
throw e;
}
})
});
+13
View File
@@ -0,0 +1,13 @@
import { patchConfig, patchExecutable } from '~main/modules/patcher';
import Preferences from '~main/modules/preferences';
import { getClientVersion } from '~main/utils';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const patcherRouter = createTRPCRouter({
apply: publicProcedure.mutation(async () => {
await patchExecutable();
await patchConfig();
Preferences.data = { version: await getClientVersion() };
})
});
+19
View File
@@ -0,0 +1,19 @@
import { z } from 'zod';
import { PreferencesSchema } from '~common/schemas';
import Preferences from '~main/modules/preferences';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const preferencesRouter = createTRPCRouter({
get: publicProcedure.output(PreferencesSchema).query(() => Preferences.data),
set: publicProcedure
.input(PreferencesSchema.partial())
.mutation(async ({ input }) => {
Preferences.data = input;
return Preferences.data;
}),
isValidClientDir: publicProcedure
.input(z.string().optional())
.query(({ input }) => Preferences.isValidClientDir(input))
});
+8
View File
@@ -0,0 +1,8 @@
import SelfUpdater from '~main/modules/selfUpdater';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const selfUpdaterRouter = createTRPCRouter({
observe: publicProcedure.subscription(() => SelfUpdater.observe()),
install: publicProcedure.mutation(() => SelfUpdater.triggerInstall())
});
+13
View File
@@ -0,0 +1,13 @@
import { z } from 'zod';
import Updater from '~main/modules/updater';
import { createTRPCRouter, publicProcedure } from '../trpc';
export const updaterRouter = createTRPCRouter({
verify: publicProcedure.mutation(() => Updater.verify()),
update: publicProcedure
.input(z.boolean().optional())
.mutation(async ({ input }) => Updater.update(input)),
observe: publicProcedure.subscription(() => Updater.observe())
});
+18
View File
@@ -0,0 +1,18 @@
import { initTRPC } from '@trpc/server';
import superjson from 'superjson';
import { ZodError } from 'zod';
const t = initTRPC.create({
transformer: superjson,
errorFormatter: ({ shape, error }) => ({
...shape,
data: {
...shape.data,
zodError: error.cause instanceof ZodError ? error.cause.flatten() : null
}
})
});
export const createTRPCRouter = t.router;
export const publicProcedure = t.procedure;
+107
View File
@@ -0,0 +1,107 @@
import { join } from 'path';
import { app, shell, BrowserWindow } from 'electron';
import { electronApp, optimizer, is } from '@electron-toolkit/utils';
import { createIPCHandler } from 'electron-trpc/main';
import Logger from 'electron-log/main';
import icon from '~build/icon.png?asset';
import { appRouter } from './api/root';
import Preferences from './modules/preferences';
import Updater from './modules/updater';
import Addons from './modules/addons';
import Mods from './modules/mods';
import { initSelfUpdater } from './modules/selfUpdater';
Logger.initialize();
Logger.errorHandler.startCatching();
Logger.info('Launcher starting...');
app.disableHardwareAcceleration();
export let mainWindow: BrowserWindow | null = null;
const createWindow = async () => {
const position = Preferences.data.rememberPosition
? Preferences.data.windowPosition
: { width: 1000, height: 700 };
mainWindow = new BrowserWindow({
...position,
minWidth: 1000,
minHeight: 700,
icon,
frame: false,
maximizable: false,
fullscreenable: false,
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
contextIsolation: true,
sandbox: false,
devTools: true
}
});
mainWindow.webContents.on('render-process-gone', (_e, details) => {
Logger.error('Renderer process gone:', details);
});
mainWindow.webContents.on('unresponsive', () => {
Logger.error('Renderer unresponsive');
});
mainWindow.webContents.on('console-message', (_e, level, message, line, sourceId) => {
const lvl = level === 3 ? 'error' : level === 2 ? 'warn' : 'info';
Logger[lvl](`[renderer:${lvl}] ${message} (${sourceId}:${line})`);
});
mainWindow.webContents.on('before-input-event', (_e, input) => {
if (input.type !== 'keyDown') return;
if (input.key === 'F12') {
mainWindow?.webContents.toggleDevTools();
}
});
createIPCHandler({ router: appRouter, windows: [mainWindow] });
mainWindow.on('ready-to-show', () => {
mainWindow?.show();
});
mainWindow.webContents.setWindowOpenHandler(details => {
shell.openExternal(details.url);
return { action: 'deny' };
});
mainWindow.on('close', () => {
if (!mainWindow) return;
const [x = 0, y = 0] = mainWindow.getPosition();
const [width = 0, height = 0] = mainWindow.getSize();
Preferences.data = { windowPosition: { x, y, width, height } };
});
if (is.dev && process.env.ELECTRON_RENDERER_URL) {
mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL);
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'));
}
};
app.whenReady().then(async () => {
Preferences.data = await Preferences.load();
Addons.verify();
Updater.verify();
Mods.verify();
initSelfUpdater();
electronApp.setAppUserModelId('com.electron');
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window);
});
await createWindow();
});
app.on('window-all-closed', async () => {
app.quit();
});
+400
View File
@@ -0,0 +1,400 @@
import path from 'node:path';
import git, { type ProgressCallback } from 'isomorphic-git';
import http from 'isomorphic-git/http/node';
import fs from 'fs-extra';
import fetch from 'node-fetch';
import Logger from 'electron-log/main';
import { isNotUndef } from '~common/utils';
import { type AddonData, type TocData } from '~common/schemas';
import { runWorker } from '~main/utils';
import gitPull from '~main/workers/gitPull?nodeWorker';
import gitClone from '~main/workers/gitClone?nodeWorker';
import Preferences from './preferences';
import Observable from './observable';
export type AddonsStatus = {
state: 'verifying' | 'done';
addons: { [name: string]: AddonData };
available: AddonData[];
};
type AddonsList = {
name: string;
owner: string;
branch?: string;
ref?: string;
git: string;
toc?: TocData;
description?: string;
lastUpdated?: string;
stars?: number;
dependencies?: string[];
}[];
const readTocData = (content: string) =>
content
.split('\n')
.filter(l => l.startsWith('## '))
.map(l => l.slice(3))
.map(l => {
const [key, value] = l.split(':');
return [key.trim(), value.trim()];
})
.reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {} as TocData);
const fetchAddons = async () => {
try {
const response = await fetch(`${import.meta.env.MAIN_VITE_SERVER_URL || 'https://octowow.st'}/api/addons.json`);
return (await response.json()) as AddonsList;
} catch (e) {
Logger.error('Failed to reach update server', e);
return [];
}
};
class AddonsClass extends Observable<AddonsStatus> {
protected _value: AddonsStatus = {
state: 'done',
addons: {},
available: []
};
get status() {
return this._value;
}
private set status(v: AddonsStatus) {
this._value = v;
this._notifyObservers(v);
}
#onProgress =
(folder: string, data: AddonData): ProgressCallback =>
progress => {
const getPhase = (step: string) => {
switch (step) {
case 'Counting objects':
return 1;
case 'Compressing objects':
return 2;
case 'Receiving objects':
return 3;
case 'Resolving deltas':
return 4;
case 'Analyzing workdir':
return 5;
case 'Updating workdir':
return 6;
default:
return 0;
}
};
this.#setAddon(folder, {
...data,
progress: `${Math.round(
(progress.loaded / (progress.total ?? progress.loaded)) * 100
)}% (${getPhase(progress.phase)}/6)`
});
};
async checkGitUrl(url: string) {
const gitUrl = url.endsWith('.git') ? url : `${url}.git`;
try {
await git.getRemoteInfo({
http,
url: gitUrl
});
// Only fetch preview from known public git hosts to prevent SSRF.
const allowed = ['github.com', 'gitlab.com', 'gitea.com', 'codeberg.org'];
let preview: string | undefined;
try {
const host = new URL(url).hostname.toLowerCase();
if (allowed.some(h => host === h || host.endsWith('.' + h))) {
const response = await fetch(url).then(r => r.text());
preview = response.match(
/property="og:image" content="([^"]*)"/
)?.[1];
}
} catch {
// preview stays undefined
}
return {
status: 'available',
folder: gitUrl.slice(0, -4).split('/').at(-1),
git: gitUrl,
preview
} as AddonData;
} catch (e) {
return undefined;
}
}
async verify() {
if (this.status.state !== 'done') return;
this.status = {
...this.status,
state: 'verifying'
};
const remoteAddons = await fetchAddons();
const available: AddonData[] = remoteAddons.map(a => ({
status: 'available',
git: a.git,
toc: a.toc,
description: a.description,
folder: a.name,
branch: a.branch,
ref: a.ref
}));
const clientPath = Preferences.data.clientDir;
if (!clientPath) {
this.status = { state: 'done', addons: {}, available };
return;
}
const addonsPath = path.join(clientPath, 'Interface', 'Addons');
const dirs = await fs.pathExists(addonsPath)
? await fs.readdir(addonsPath)
: [];
const addons: AddonsStatus['addons'] = Object.fromEntries(
dirs
.filter(d => !d.startsWith('Blizzard_'))
.map(name => [name, { status: 'fetching' as const, folder: name }])
);
this.status = { state: 'verifying', addons, available };
const verifyOne = async (folder: string) => {
const dir = path.join(addonsPath, folder);
if (!fs.existsSync(path.join(dir, `${folder}.toc`))) {
this.#setAddon(folder, {
status: 'invalid',
error: 'Missing .toc file',
folder
});
return;
}
const toc = await readTocData(
await fs.readFile(path.join(dir, `${folder}.toc`), 'utf-8')
);
const remote = await git
.listRemotes({ fs, dir })
.then(r => r[0])
.catch(() => null);
const avail = remoteAddons.find(a => a.name === folder);
if (!remote) {
Logger.log(`Addon "${folder}" is not a git repository`);
this.#setAddon(
folder,
avail
? {
status: 'outOfDate',
git: avail.git,
toc,
description: avail.description,
folder
}
: { status: 'unknown', toc, folder }
);
return;
}
try {
await git.fetch({ fs, dir, http, tags: true });
const branch = await git.currentBranch({ fs, dir });
const localCommit = await git
.log({ fs, dir, ref: 'HEAD', depth: 1 })
.then(r => r[0].oid)
.catch(() => null);
const remoteCommit = avail?.ref
? await git
.resolveRef({ fs, dir, ref: avail.ref })
.catch(() => null)
: await git
.log({ fs, dir, ref: `${remote.remote}/${branch}`, depth: 1 })
.then(r => r[0].oid)
.catch(() => null);
const status = await git.statusMatrix({ fs, dir });
const hasChanges = status.some(
([_, HEAD, index, workdir]) => HEAD !== index || index !== workdir
);
const isUpToDate =
!hasChanges && remoteCommit && localCommit === remoteCommit;
this.#setAddon(folder, {
git: remote.url,
status: isUpToDate ? 'upToDate' : 'outOfDate',
toc,
description: avail?.description,
ref: avail?.ref,
folder
});
Logger.log(
isUpToDate
? `Addon "${folder}" is up to date${avail?.ref ? ` (pinned ${avail.ref})` : ''}`
: `Addon "${folder}" has an update available`
);
} catch (e) {
this.#setAddon(folder, {
git: remote.url,
status: 'invalid',
error: 'Failed to verify',
toc,
folder
});
Logger.error(`Addon "${folder}" failed to verify`, e);
}
};
const folders = Object.keys(addons);
const VERIFY_CONCURRENCY = 6;
let idx = 0;
await Promise.all(
Array.from({ length: Math.min(VERIFY_CONCURRENCY, folders.length) }, async () => {
while (true) {
const i = idx++;
if (i >= folders.length) return;
await verifyOne(folders[i]);
}
})
);
this.status = { ...this.status, state: 'done' };
}
async update(
toUpdate = Object.values(this.status.addons)
.filter(e => e.status === 'outOfDate')
.map(e => e.folder)
.filter(isNotUndef)
) {
const clientPath = Preferences.data.clientDir;
if (!clientPath) return;
if (this.status.state !== 'done') return;
const addonsPath = path.join(clientPath, 'Interface', 'Addons');
for (const folder of toUpdate) {
if (this.status.addons[folder]?.status === 'downloading') continue;
const dir = path.join(addonsPath, folder);
const avail = this.status.available.find(a => a.folder === folder);
const data: AddonData = {
...avail,
...this.status.addons[folder],
status: 'downloading'
};
this.#setAddon(folder, data);
const remote = await git
.listRemotes({ fs, dir })
.then(r => r?.[0])
.catch(() => null);
try {
if (!remote) {
await runWorker(
gitClone,
{ dir, url: data.git, ref: data.ref ?? data.branch },
{ onProgress: this.#onProgress(folder, data) }
);
} else {
const branch =
(await git.currentBranch({ fs, dir })) ?? avail?.branch ?? 'master';
await runWorker(
gitPull,
{
dir,
remote: remote.remote,
branch,
ref: avail?.ref
},
{ onProgress: this.#onProgress(folder, data) }
);
}
const toc = await readTocData(
await fs.readFile(path.join(dir, `${folder}.toc`), 'utf-8')
);
this.#setAddon(folder, { ...data, toc, status: 'upToDate' });
Logger.log(`Updated addon "${folder}"`);
} catch (e) {
this.#setAddon(folder, {
...data,
status: 'invalid',
error: 'Failed to update'
});
Logger.error(`Addon "${folder}" failed to update`, e);
}
}
}
async remove(toRemove: string[]) {
const clientPath = Preferences.data.clientDir;
if (!clientPath) return;
if (this.status.state !== 'done') return;
for (const folder of toRemove) {
const dir = path.join(clientPath, 'Interface', 'Addons', folder);
if (fs.existsSync(dir)) await fs.remove(dir);
this.#setAddon(folder);
Logger.log(`Removed addon "${folder}"`);
}
}
async install(data: AddonData) {
const clientPath = Preferences.data.clientDir;
if (!clientPath) return;
const addonsPath = path.join(clientPath, 'Interface', 'Addons');
const dir = path.join(addonsPath, data.folder);
try {
await runWorker(
gitClone,
{ dir, url: data.git, ref: data.ref ?? data.branch },
{ onProgress: this.#onProgress(data.folder, data) }
);
const toc = await readTocData(
await fs.readFile(path.join(dir, `${data.folder}.toc`), 'utf-8')
);
this.#setAddon(data.folder, { ...data, toc, status: 'upToDate' });
Logger.log(`Installed addon "${data.folder}"`);
} catch (e) {
this.#setAddon(data.folder, {
...data,
status: 'invalid',
error: 'Failed to install'
});
Logger.error(`Addon "${data.folder}" failed to install`, e);
}
}
#setAddon(folder: string, data?: AddonData) {
const { [folder]: _, ...addons } = this.status.addons;
this.status = {
...this.status,
addons: data ? { ...addons, [folder]: data } : addons
};
}
}
const Addons = new AddonsClass();
export default Addons;
+55
View File
@@ -0,0 +1,55 @@
import path from 'path';
import fs from 'fs-extra';
let queue: Promise<unknown> = Promise.resolve();
const serial = <T>(fn: () => Promise<T>): Promise<T> => {
const next = queue.then(fn, fn);
queue = next.catch(() => {});
return next;
};
const dllsPath = (clientDir: string) => path.join(clientDir, 'dlls.txt');
const readLines = async (clientDir: string): Promise<string[]> => {
const file = dllsPath(clientDir);
if (!(await fs.pathExists(file))) return [];
const text = await fs.readFile(file, 'utf8');
return text.split(/\r?\n/);
};
const writeLines = async (clientDir: string, lines: string[]) => {
const file = dllsPath(clientDir);
const trimmed = lines.join('\n').replace(/\n+$/, '');
if (!trimmed.trim()) {
if (await fs.pathExists(file)) await fs.remove(file);
return;
}
await fs.writeFile(file, trimmed + '\n', 'utf8');
};
const matches = (line: string, name: string) =>
line.trim().toLowerCase() === name.toLowerCase();
export const addDll = (clientDir: string, name: string) =>
serial(async () => {
const lines = await readLines(clientDir);
if (lines.some(l => matches(l, name))) return;
lines.push(name);
await writeLines(clientDir, lines);
});
export const removeDll = (clientDir: string, name: string) =>
serial(async () => {
const lines = await readLines(clientDir);
const next = lines.filter(l => !matches(l, name));
if (next.length === lines.length) return;
await writeLines(clientDir, next);
});
export const hasDll = (clientDir: string, name: string) =>
serial(async () => {
const lines = await readLines(clientDir);
return lines.some(l => matches(l, name));
});
+389
View File
@@ -0,0 +1,389 @@
import path from 'path';
import os from 'os';
import fs from 'fs-extra';
import fetch from 'node-fetch';
import AdmZip from 'adm-zip';
import * as tar from 'tar';
import Logger from 'electron-log/main';
import { MODS, type ModEntry, type ModId, getMod } from '~common/mods';
import { type ModState } from '~common/schemas';
import Preferences from './preferences';
import Observable from './observable';
import { addDll, removeDll } from './dllsTxt';
export type ModRowStatus = {
id: ModId;
name: string;
description: string;
repoUrl: string;
recommended: boolean;
requires: ModId[];
enabled: boolean;
ignoreUpdates: boolean;
installedVersion?: string;
latestVersion: string;
state: 'idle' | 'downloading' | 'installing' | 'uninstalling' | 'error';
progress?: number;
error?: string;
};
export type ModsStatus = {
state: 'verifying' | 'idle' | 'busy';
dirty: boolean;
mods: ModRowStatus[];
};
const VERSION_CACHE_MS = 10 * 60 * 1000;
class ModsClass extends Observable<ModsStatus> {
protected _value: ModsStatus = {
state: 'verifying',
dirty: false,
mods: []
};
#latestCache = new Map<ModId, { v: string; ts: number }>();
installedFilePaths(): Set<string> {
const set = new Set<string>();
const mods = Preferences.data?.mods ?? {};
for (const id of Object.keys(mods) as ModId[]) {
const state = mods[id];
if (!state?.installedFiles?.length) continue;
for (const rel of state.installedFiles) {
set.add(rel.replace(/\\/g, '/').toLowerCase());
}
}
return set;
}
get status(): ModsStatus {
return this._value;
}
#initialRow(m: ModEntry): ModRowStatus {
const state = Preferences.data?.mods?.[m.id];
return {
id: m.id,
name: m.name,
description: m.description,
repoUrl: m.repoUrl,
recommended: !!m.recommended,
requires: m.requires ?? [],
enabled: !!state?.enabled,
ignoreUpdates: !!state?.ignoreUpdates,
installedVersion: state?.installedVersion,
latestVersion: m.version,
state: 'idle'
};
}
#patchRow(id: ModId, patch: Partial<ModRowStatus>) {
this._value = {
...this._value,
mods: this._value.mods.map(r => (r.id === id ? { ...r, ...patch } : r))
};
this._value = { ...this._value, dirty: this.#computeDirty() };
this._notifyObservers();
}
#computeDirty(): boolean {
return this._value.mods.some(r => {
const wantInstalled = r.enabled;
const isInstalled = !!r.installedVersion;
if (wantInstalled !== isInstalled) return true;
if (
r.installedVersion &&
r.installedVersion !== r.latestVersion &&
!r.ignoreUpdates
)
return true;
return false;
});
}
load() {
this._value = {
state: 'verifying',
dirty: false,
mods: MODS.map(m => this.#initialRow(m))
};
}
async verify() {
this.load();
this._notifyObservers();
const clientDir = Preferences.data?.clientDir;
for (const m of MODS) {
const state = Preferences.data?.mods?.[m.id];
let installedVersion = state?.installedVersion;
if (clientDir && installedVersion) {
const filesPresent = await Promise.all(
(state?.installedFiles ?? []).map(rel =>
fs.pathExists(path.join(clientDir, rel))
)
);
if (state?.installedFiles?.length && !filesPresent.every(Boolean)) {
installedVersion = undefined;
await this.#savePref(m.id, {
enabled: state?.enabled ?? false,
installedVersion: undefined,
installedFiles: [],
ignoreUpdates: state?.ignoreUpdates ?? false
});
}
}
const latest = await this.#fetchLatestVersion(m).catch(() => m.version);
this.#patchRow(m.id, {
installedVersion,
latestVersion: latest,
enabled: !!state?.enabled,
ignoreUpdates: !!state?.ignoreUpdates
});
}
this._value = { ...this._value, state: 'idle', dirty: this.#computeDirty() };
this._notifyObservers();
}
async #fetchLatestVersion(m: ModEntry): Promise<string> {
if (m.source.kind === 'managed') return m.version;
const cached = this.#latestCache.get(m.id);
if (cached && Date.now() - cached.ts < VERSION_CACHE_MS) return cached.v;
const apiUrl =
'apiUrl' in m.source && m.source.apiUrl ? m.source.apiUrl : undefined;
const parser =
'parseLatest' in m.source && m.source.parseLatest
? m.source.parseLatest
: undefined;
if (!apiUrl || !parser) {
const v = ('pinnedTag' in m.source && m.source.pinnedTag) || m.version;
this.#latestCache.set(m.id, { v, ts: Date.now() });
return v;
}
try {
const res = await fetch(apiUrl, {
headers: { 'User-Agent': 'OctoLauncher' }
});
if (!res.ok) throw new Error(`${apiUrl}${res.status}`);
const json = (await res.json()) as { tag_name?: string };
const tag = json.tag_name ?? m.version;
this.#latestCache.set(m.id, { v: tag, ts: Date.now() });
return tag;
} catch (e) {
Logger.warn(`Could not check latest version for ${m.id}:`, e);
const v = ('pinnedTag' in m.source && m.source.pinnedTag) || m.version;
return v;
}
}
async toggle(id: ModId, enabled: boolean) {
const cur = Preferences.data?.mods?.[id];
await this.#savePref(id, {
enabled,
installedVersion: cur?.installedVersion,
installedFiles: cur?.installedFiles ?? [],
ignoreUpdates: cur?.ignoreUpdates ?? false
});
this.#patchRow(id, { enabled });
}
async setIgnoreUpdates(id: ModId, ignore: boolean) {
const cur = Preferences.data?.mods?.[id];
await this.#savePref(id, {
enabled: cur?.enabled ?? false,
installedVersion: cur?.installedVersion,
installedFiles: cur?.installedFiles ?? [],
ignoreUpdates: ignore
});
this.#patchRow(id, { ignoreUpdates: ignore });
}
async applyAll() {
const clientDir = Preferences.data?.clientDir;
if (!clientDir) {
Logger.warn('No clientDir set; cannot apply mods.');
return;
}
this._value = { ...this._value, state: 'busy' };
this._notifyObservers();
const queue = [...this._value.mods];
queue.sort((a, b) => {
if (a.id === 'vanillaFixes') return -1;
if (b.id === 'vanillaFixes') return 1;
return 0;
});
for (const row of queue) {
const m = getMod(row.id);
if (!m) continue;
const wantInstalled = row.enabled;
const isInstalled = !!row.installedVersion;
const updateAvailable =
isInstalled &&
row.installedVersion !== row.latestVersion &&
!row.ignoreUpdates;
try {
if (wantInstalled && !isInstalled) {
await this.#install(m);
} else if (!wantInstalled && isInstalled) {
await this.#uninstall(m);
} else if (wantInstalled && updateAvailable) {
await this.#uninstall(m);
await this.#install(m);
}
} catch (e) {
Logger.error(`Failed to apply ${m.id}:`, e);
this.#patchRow(m.id, {
state: 'error',
error: e instanceof Error ? e.message : String(e)
});
}
}
this._value = { ...this._value, state: 'idle' };
await this.verify();
}
async #install(m: ModEntry) {
const clientDir = Preferences.data?.clientDir;
if (!clientDir) throw new Error('No client dir');
if (m.source.kind === 'managed') return;
Logger.info(`Installing mod ${m.id}...`);
this.#patchRow(m.id, { state: 'downloading', progress: 0, error: undefined });
const written: string[] = [];
if (m.source.kind === 'directFile') {
const dest = path.join(clientDir, m.source.assetName);
await this.#downloadTo(m.source.url, dest);
written.push(m.source.assetName);
} else if (m.source.kind === 'archive') {
const tmp = path.join(
os.tmpdir(),
`octolauncher-${m.id}-${Date.now()}.${m.source.format}`
);
await this.#downloadTo(m.source.url, tmp);
this.#patchRow(m.id, { state: 'installing' });
const map = m.source.extractMap;
if (m.source.format === 'zip') {
const zip = new AdmZip(tmp);
const entries = zip.getEntries();
for (const [src, dst] of Object.entries(map)) {
const entry = entries.find(e => e.entryName === src);
if (!entry) {
Logger.warn(`Mod ${m.id}: zip entry ${src} not found.`);
continue;
}
const target = path.join(clientDir, dst);
await fs.ensureDir(path.dirname(target));
await fs.writeFile(target, entry.getData());
written.push(dst);
}
} else {
const stagingDir = path.join(
os.tmpdir(),
`octolauncher-${m.id}-${Date.now()}-extract`
);
await fs.ensureDir(stagingDir);
await tar.x({ file: tmp, cwd: stagingDir });
for (const [src, dst] of Object.entries(map)) {
const srcPath = path.join(stagingDir, src);
if (!(await fs.pathExists(srcPath))) {
Logger.warn(`Mod ${m.id}: tar entry ${src} not found.`);
continue;
}
const target = path.join(clientDir, dst);
await fs.ensureDir(path.dirname(target));
await fs.copy(srcPath, target);
written.push(dst);
}
await fs.remove(stagingDir).catch(() => {});
}
await fs.remove(tmp).catch(() => {});
}
if (m.registerInDllsTxt) {
await addDll(clientDir, m.registerInDllsTxt);
}
await this.#savePref(m.id, {
enabled: true,
installedVersion: m.version,
installedFiles: written,
ignoreUpdates: Preferences.data?.mods?.[m.id]?.ignoreUpdates ?? false
});
this.#patchRow(m.id, {
state: 'idle',
installedVersion: m.version,
progress: 1
});
}
async #uninstall(m: ModEntry) {
const clientDir = Preferences.data?.clientDir;
if (!clientDir) throw new Error('No client dir');
if (m.source.kind === 'managed') return;
Logger.info(`Uninstalling mod ${m.id}...`);
this.#patchRow(m.id, { state: 'uninstalling', error: undefined });
const cur = Preferences.data?.mods?.[m.id];
const files = cur?.installedFiles ?? [];
for (const rel of files) {
const fullPath = path.join(clientDir, rel);
await fs
.remove(fullPath)
.catch(err => Logger.warn(`Couldn't remove ${fullPath}:`, err));
}
if (m.registerInDllsTxt) {
await removeDll(clientDir, m.registerInDllsTxt);
}
await this.#savePref(m.id, {
enabled: cur?.enabled ?? false,
installedVersion: undefined,
installedFiles: [],
ignoreUpdates: cur?.ignoreUpdates ?? false
});
this.#patchRow(m.id, { state: 'idle', installedVersion: undefined });
}
async #downloadTo(url: string, dest: string) {
const res = await fetch(url, {
headers: { 'User-Agent': 'OctoLauncher' }
});
if (!res.ok) throw new Error(`Download failed ${res.status}: ${url}`);
await fs.ensureDir(path.dirname(dest));
const buf = await res.arrayBuffer();
await fs.writeFile(dest, Buffer.from(buf));
}
async #savePref(id: ModId, state: ModState) {
const allMods = { ...(Preferences.data?.mods ?? {}), [id]: state };
Preferences.data = { mods: allMods };
}
}
const Mods = new ModsClass();
export default Mods;
+36
View File
@@ -0,0 +1,36 @@
import { observable } from '@trpc/server/observable';
type Func<T> = (arg: T) => void;
abstract class Observable<T> {
private _listeners: Func<T>[] = [];
protected abstract _value: T;
protected _notifyObservers(v = this._value) {
this._listeners = this._listeners.filter(l => {
try {
l(v);
return true;
} catch {
return false;
}
});
}
observe() {
return observable<T>(e => {
e.next(this._value);
this._listeners.push(e.next);
return () => {
this._listeners = this._listeners.filter(v => v !== e.next);
};
});
}
clearObservers() {
this._listeners = [];
}
}
export default Observable;
+229
View File
@@ -0,0 +1,229 @@
import path from 'path';
import { screen } from 'electron';
import fs from 'fs-extra';
import Logger from 'electron-log/main';
import Preferences from '~main/modules/preferences';
import { ConfigWtfSchema, type PreferencesSchema } from '~common/schemas';
import { isNotUndef } from '~common/utils';
import { fetchFile } from '~main/modules/updater';
const Servers = {
live: {
realmList: 'octowow.st',
patchList: 'octowow.st',
realmName: 'OctoWoW'
},
ptr: {
realmList: 'octowow.st',
patchList: 'octowow.st',
realmName: 'OctoWoW PTR'
}
} as const;
type Tweak = { key: keyof PreferencesSchema['config']; default?: unknown; forced?: boolean } & (
| {
type: 'bytes';
tweaks: [number, number[]][];
}
| {
type: 'int8' | 'uint16' | 'float';
offset: number;
value?: number;
}
);
export const patchExecutable = async () => {
Logger.log('Patching WoW.exe...');
const { clientDir, config } = Preferences.data;
if (!clientDir) return;
const exePath = path.join(clientDir, 'WoW.exe');
try {
Logger.log('Fetching clean WoW.exe...');
const file = await fetchFile('WoW.exe');
const buffer = Buffer.from(file);
const Tweaks = [
{
key: 'largeAddress',
type: 'uint16',
offset: 0x126,
value: buffer.readUint16LE(0x126) | 0x20,
default: false
},
{ key: 'farClip', type: 'float', offset: 0x40fed8 },
{
key: 'fieldOfView',
type: 'float',
offset: 0x4089b4,
value: (config.fieldOfView ?? 1) * (Math.PI / 180),
default: 90
},
{ key: 'frillDistance', type: 'float', offset: 0x467958 },
{
key: 'soundInBackground',
type: 'int8',
offset: 0x3a4869,
value: config.soundInBackground ? 0x27 : 0x14,
default: false
},
{
key: 'alwaysAutoLoot',
type: 'bytes',
tweaks: [
[0x0c1ecf, [0x75]],
[0x0c2b25, [0x75]]
]
},
{ key: 'nameplateRange', type: 'float', offset: 0x40c448 },
{ key: 'cameraDistance', type: 'float', offset: 0x4089a4 },
{
key: 'crossFactionResurrect' as never,
type: 'bytes',
default: true,
tweaks: [
[0x006e5fb8, [0x006e5fb9]],
[0x006e62a8, [0x006e62a9]]
]
},
{
key: 'skillUiGateHijack' as never,
type: 'bytes',
default: true,
forced: true,
tweaks: [
[
0x002ddf90,
[
0x55, 0x8b, 0xec, 0x83, 0xec, 0x08, 0x53, 0x56,
0x57, 0x8b, 0x3d, 0x60, 0xab, 0xce, 0x00, 0x83,
0xff, 0xff, 0x89, 0x55, 0xfc, 0x89, 0x4d, 0xf8,
0x74, 0x79, 0x8b, 0x75, 0x08, 0x8b, 0x15, 0x58,
0xab, 0xce, 0x00, 0x8b, 0xc7, 0x23, 0xc6, 0x8d,
0x04, 0x40, 0x8b, 0x4c, 0x82, 0x08, 0xf6, 0xc1,
0x01, 0x8d, 0x44, 0x82, 0x04, 0x75, 0x04, 0x85,
0xc9, 0x75, 0x05, 0x33, 0xc9, 0x8d, 0x49, 0x00,
0xf6, 0xc1, 0x01, 0x75, 0x4e, 0x85, 0xc9, 0x74,
0x4a, 0x39, 0x31, 0x74, 0x13, 0x8b, 0xc7, 0x23,
0xc6, 0x8d, 0x04, 0x40, 0x8d, 0x04, 0x82, 0x8b,
0x00, 0x03, 0xc1, 0x8b, 0x48, 0x04, 0xeb, 0xe0,
0x8b, 0x59, 0x1c, 0x8b, 0x71, 0x18, 0x33, 0xff,
0x85, 0xdb, 0x7e, 0x27, 0x8d, 0x64, 0x24, 0x00,
0x8b, 0x4e, 0x0c, 0x8b, 0x56, 0x08, 0x6a, 0x00,
0x6a, 0x00, 0x51, 0x8b, 0x4d, 0xf8, 0x52, 0x8b,
0x55, 0xfc, 0xe8, 0xb9, 0xfd, 0xff, 0xff, 0x84,
0xc0, 0x75, 0x13, 0x47, 0x83, 0xc6, 0x20, 0x3b,
0xfb, 0x7c, 0xdd, 0x5f, 0x5e, 0x33, 0xc0, 0x5b,
0x8b, 0xe5, 0x5d, 0xc2, 0x04, 0x00, 0x5f, 0x8b,
0xc6, 0x5e, 0x5b, 0x8b, 0xe5, 0x5d, 0xc2, 0x04,
0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
]
]
]
}
] satisfies Tweak[];
// Apply patches
Tweaks.forEach(t => {
const val =
config[t.key] ?? t.default ?? ConfigWtfSchema.parse({})[t.key];
Logger.log(`Applying "${t.key}" patch with value: ${val}`);
if (t.type === 'float') {
buffer.writeFloatLE(t.value ?? (val as never), t.offset);
} else if (t.type === 'int8') {
buffer.writeInt8(t.value ?? (val as never), t.offset);
} else if (t.type === 'uint16') {
if (!t.forced && !val) return;
buffer.writeUInt16LE(t.value ?? (val as never), t.offset);
} else if (t.type === 'bytes') {
if (!t.forced && !val) return;
t.tweaks.forEach(([offset, bytes]) =>
Buffer.from(bytes).copy(buffer, offset)
);
}
});
await fs.writeFile(exePath, buffer);
Logger.log('WoW.exe successfully patched');
} catch (e) {
Logger.error('Failed to patch WoW.exe', e);
}
};
export const patchConfig = async () => {
const { clientDir, server, config } = Preferences.data;
if (!clientDir) return;
const configPath = path.join(clientDir, 'WTF', 'Config.wtf');
await fs.ensureDir(path.dirname(configPath));
const raw = (await fs.pathExists(configPath))
? await fs.readFile(configPath, { encoding: 'utf-8' })
: '';
if (raw) await fs.remove(configPath);
const configWtf = Object.fromEntries(
raw
.split('\n')
.map(l => {
const [_, k, v] = l.match(/SET (\w+) "(.+)"/) ?? [];
return !k || !v ? undefined : [k, v];
})
.filter(isNotUndef)
);
const primaryDisplay = screen.getPrimaryDisplay();
const { width, height } = primaryDisplay.bounds;
const parsed = {
scriptMemory: 512000,
gxResolution: `${width}x${height}`,
gxColorBits: primaryDisplay.colorDepth,
gxDepthBits: primaryDisplay.colorDepth,
gxRefresh: 60,
gxMultisample: 8,
gxMultisampleQuality: 0,
gxTripleBuffer: 1,
anisotropic: 16,
frillDensity: 48,
fullAlpha: 1,
SmallCull: 0.01,
DistCull: 888.8,
shadowLevel: 0,
trilinear: 1,
specular: 1,
pixelShaders: 1,
M2UsePixelShaders: 1,
particleDensity: 1,
unitDrawDist: 300,
weatherDensity: 3,
movieSubtitle: 1,
minimapZoom: 0,
minimapInsideZoom: 0,
SoundZoneMusicNoDelay: 1,
patchList: configWtf['patchList'] ?? Servers[server].patchList,
realmName: configWtf['realmName'] ?? Servers[server].realmName,
gxWindow: configWtf['gxWindow'] ?? 1,
gxMaximize: configWtf['gxMaximize'] ?? 1,
gxCursor: configWtf['gxCursor'] ?? 1,
checkAddonVersion: configWtf['checkAddonVersion'] ?? 0,
...configWtf,
CameraDistanceMax: config.cameraDistance,
farClip: config.farClip,
realmList: Servers[server].realmList,
hwDetect: 0,
M2UseShaders: 1
};
await fs.writeFile(
configPath,
Object.entries(parsed)
.filter(v => v[1] !== undefined && v[1] !== null)
.map(l => `SET ${l[0]} "${l[1]}"`)
.join('\n')
);
Logger.log('Config.wtf successfully patched');
};
+59
View File
@@ -0,0 +1,59 @@
import path from 'path';
import fs from 'fs-extra';
import { type z } from 'zod';
import { app } from 'electron';
import { PreferencesSchema } from '~common/schemas';
import { omit } from '~common/utils';
const portableDir = process.env.PORTABLE_EXECUTABLE_DIR;
abstract class Preferences {
static #data: z.infer<typeof PreferencesSchema>;
static readonly userDataDir = process.env.PORTABLE_EXECUTABLE_DIR
? path.join(process.env.PORTABLE_EXECUTABLE_DIR, '.launcher')
: app.getPath('userData');
static async load() {
await fs.ensureDir(this.userDataDir);
const userDataPath = path.join(this.userDataDir, 'settings.json');
try {
const json = await fs.readJSON(userDataPath);
return PreferencesSchema.parse({
...json,
isPortable: !!portableDir,
clientDir: portableDir ?? json.clientDir
});
} catch (e) {
return PreferencesSchema.parse({
isPortable: !!portableDir,
clientDir: portableDir
});
}
}
static get data(): PreferencesSchema {
return this.#data;
}
static set data(newData: Partial<Omit<PreferencesSchema, 'portableDir'>>) {
this.#data = { ...this.#data, ...newData };
fs.writeJSON(
path.join(this.userDataDir, 'settings.json'),
omit(
this.#data,
portableDir ? ['isPortable', 'clientDir'] : ['isPortable']
),
{ spaces: 2 }
);
}
static async isValidClientDir(clientDir?: string) {
return !!clientDir && (await fs.exists(path.join(clientDir, 'WoW.exe')));
}
}
export default Preferences;
+115
View File
@@ -0,0 +1,115 @@
import { app } from 'electron';
import { autoUpdater } from 'electron-updater';
import Logger from 'electron-log/main';
import { is } from '@electron-toolkit/utils';
import Observable from './observable';
export type SelfUpdaterStatus =
| { state: 'idle'; currentVersion: string }
| { state: 'checking'; currentVersion: string }
| { state: 'unavailable'; currentVersion: string }
| { state: 'available'; currentVersion: string; nextVersion: string }
| { state: 'downloading'; currentVersion: string; nextVersion: string; progress: number }
| { state: 'ready'; currentVersion: string; nextVersion: string }
| { state: 'error'; currentVersion: string; message: string };
class SelfUpdaterClass extends Observable<SelfUpdaterStatus> {
protected _value: SelfUpdaterStatus = {
state: 'idle',
currentVersion: app.getVersion()
};
#initialized = false;
#nextVersion: string | undefined;
get status(): SelfUpdaterStatus {
return this._value;
}
private set status(v: SelfUpdaterStatus) {
this._value = v;
this._notifyObservers();
}
init() {
if (this.#initialized) return;
this.#initialized = true;
if (is.dev) {
Logger.info('[selfUpdater] dev mode — skipping');
return;
}
const currentVersion = app.getVersion();
autoUpdater.logger = Logger;
autoUpdater.autoDownload = true;
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater.on('checking-for-update', () => {
Logger.info('[selfUpdater] checking');
this.status = { state: 'checking', currentVersion };
});
autoUpdater.on('update-available', info => {
Logger.info(`[selfUpdater] update available: ${info.version}`);
this.#nextVersion = info.version;
this.status = {
state: 'available',
currentVersion,
nextVersion: info.version
};
});
autoUpdater.on('update-not-available', info => {
Logger.info(`[selfUpdater] up to date (current: ${info.version})`);
this.status = { state: 'unavailable', currentVersion };
});
autoUpdater.on('error', err => {
Logger.error('[selfUpdater] error', err);
this.status = {
state: 'error',
currentVersion,
message: err?.message ?? String(err)
};
});
autoUpdater.on('download-progress', p => {
Logger.info(`[selfUpdater] downloading ${Math.round(p.percent)}%`);
this.status = {
state: 'downloading',
currentVersion,
nextVersion: this.#nextVersion ?? '',
progress: Math.max(0, Math.min(1, p.percent / 100))
};
});
autoUpdater.on('update-downloaded', info => {
Logger.info(
`[selfUpdater] downloaded ${info.version} — awaiting user click`
);
this.status = {
state: 'ready',
currentVersion,
nextVersion: info.version
};
});
autoUpdater.checkForUpdates().catch(err => {
Logger.error('[selfUpdater] checkForUpdates failed', err);
});
}
triggerInstall() {
if (this._value.state !== 'ready') {
Logger.warn(
`[selfUpdater] triggerInstall called in state ${this._value.state} — ignoring`
);
return;
}
Logger.info('[selfUpdater] user clicked install — quitting + running installer');
autoUpdater.quitAndInstall(false, true);
}
}
const SelfUpdater = new SelfUpdaterClass();
export default SelfUpdater;
export const initSelfUpdater = () => SelfUpdater.init();
+53
View File
@@ -0,0 +1,53 @@
import { Tray, Menu, nativeImage, app } from 'electron';
import Logger from 'electron-log/main';
import icon from '~build/icon.png?asset';
import { mainWindow } from '~main/index';
let tray: Tray | null = null;
let isMinimizedToTray = false;
const restoreWindow = () => {
if (!mainWindow) return;
mainWindow.show();
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
isMinimizedToTray = false;
};
const ensureTray = () => {
if (tray) return tray;
const trayIcon = nativeImage.createFromPath(icon).resize({ width: 16, height: 16 });
tray = new Tray(trayIcon);
tray.setToolTip('OctoLauncher');
tray.setContextMenu(
Menu.buildFromTemplate([
{ label: 'Show launcher', click: restoreWindow },
{ type: 'separator' },
{ label: 'Quit', click: () => app.quit() }
])
);
tray.on('click', restoreWindow);
return tray;
};
export const minimizeToTray = () => {
if (!mainWindow) return;
ensureTray();
mainWindow.hide();
isMinimizedToTray = true;
Logger.info('Minimized to tray');
};
export const restoreFromTray = () => {
if (!isMinimizedToTray) return;
restoreWindow();
};
export const isInTray = () => isMinimizedToTray;
export const destroyTray = () => {
tray?.destroy();
tray = null;
};
+973
View File
@@ -0,0 +1,973 @@
import path from 'node:path';
import crypto from 'node:crypto';
import { exec } from 'node:child_process';
import os from 'node:os';
import { app } from 'electron';
import fetch from 'node-fetch';
import fs from 'fs-extra';
import {
SFileOpenArchive,
type HANDLE,
SFileHasFile,
SFileCloseArchive,
SFileOpenFileEx,
SFileReadFile,
SFileGetFileSize,
SFileCloseFile,
SFileCreateFile,
SFileWriteFile,
SFileFinishFile,
SFileFlushArchive,
SFileRemoveFile,
SFileCompactArchive
} from 'stormlib-node';
import {
MPQ_COMPRESSION,
MPQ_FILE,
STREAM_FLAG
} from 'stormlib-node/dist/enums';
import Logger from 'electron-log/main';
import {
asyncMap,
formatFileSize,
isNotUndef,
nestedGet,
nestedSet
} from '~common/utils';
import { mainWindow } from '~main/index';
import { patchExecutable } from '~main/modules/patcher';
import { getClientVersion } from '~main/utils';
import Preferences from './preferences';
import Observable from './observable';
const getAvailableDiskSpace = async (probePath?: string): Promise<number> => {
const target =
probePath ||
Preferences.data?.clientDir ||
os.homedir() ||
(os.platform() === 'win32' ? 'C:\\' : '/');
try {
const s = await fs.promises.statfs(target);
return Number(s.bsize) * Number(s.bavail);
} catch (e) {
Logger.warn(
`fs.statfs("${target}") failed; treating disk-space check as ` +
`unavailable. Error: ${e instanceof Error ? e.message : String(e)}`
);
return Number.POSITIVE_INFINITY;
}
};
const isReadOnly = async (filePath: string) => {
try {
const { mode } = await fs.stat(filePath);
return !(mode & fs.constants.S_IWUSR);
} catch (e) {
return false;
}
};
type FolderTags = 'allowExtra';
type FileTags = 'vanillaFixes';
type FileManifest = { name: string } & (
| { type: 'del' }
| { type: 'dir'; files: FileManifest[]; tags?: FolderTags[] }
| { type: 'mpq'; files: FileManifest[]; hash: string; size: number }
| {
type: 'file';
hash: string;
version?: number;
size: number;
tags?: FileTags[];
}
);
type CacheEntry = [hash: string, mtime: number];
type CacheTree = { [key: string]: CacheTree & CacheEntry };
const getManifestSize = (m?: FileManifest): number =>
(m?.type === 'del'
? 0
: m?.type === 'file'
? m?.size
: m?.files?.reduce((acc, v) => acc + getManifestSize(v), 0)) ?? 0;
const getManifestFiles = (m?: FileManifest, p = ''): string[] =>
(m?.type === 'del'
? [`-- ${path.join(p, m?.name)}`]
: m?.type === 'file'
? [`++ ${path.join(p, m?.name)}`]
: m?.files?.flatMap(v => getManifestFiles(v, path.join(p, m?.name)))) ?? [];
const getManifestItem = (
m?: FileManifest,
p?: string[]
): FileManifest | undefined => {
if (!p?.length) return m;
if (m?.type === 'file' || m?.type === 'del')
throw Error(`Can't access ${p.join('.')} from file ${m.name}`);
const [next, ...rest] = p;
return getManifestItem(
m?.files.find(f => f.name === next),
rest
);
};
export const isGameRunning = (executablePath: string) =>
os.platform() === 'win32'
? new Promise<boolean>(resolve => {
const exeName = path.basename(executablePath);
exec(
`tasklist /FI "IMAGENAME eq ${exeName}" /FO CSV /NH`,
(error, stdout) => {
if (error) {
Logger.warn(
`tasklist probe for "${exeName}" failed; assuming game ` +
`is not running. Error: ${error.message}`
);
resolve(false);
return;
}
resolve(
stdout.toLowerCase().includes(`"${exeName.toLowerCase()}"`)
);
}
);
})
: false;
const toUrlPath = (p: string) => p.split(path.sep).map(encodeURIComponent).join('/');
const CDN_VERSION = import.meta.env.MAIN_VITE_CLIENT_VERSION || 'latest';
const fetchManifest = async () => {
try {
const r = await fetch(
`${import.meta.env.MAIN_VITE_SERVER_URL || 'https://octowow.st'}/api/file/${CDN_VERSION}/manifest.json`
);
const j = await r.json();
await fs.writeJSON(path.join(Preferences.userDataDir, 'manifest.json'), j);
return j.root as FileManifest;
} catch (e) {
Logger.error('Failed to reach update server', e);
return null;
}
};
const buildClientUrl = (filePath: string) =>
`${import.meta.env.MAIN_VITE_SERVER_URL || 'https://octowow.st'}/client/${CDN_VERSION}/${toUrlPath(
path.normalize(filePath)
)}`;
export const fetchFile = async (
filePath: string,
onChunk?: (deltaBytes: number) => void
) => {
try {
const response = await fetch(buildClientUrl(filePath));
if (!response.ok) throw Error(`HTTP ${response.status}`);
if (!onChunk || !response.body) return await response.arrayBuffer();
const chunks: Buffer[] = [];
for await (const chunk of response.body as NodeJS.ReadableStream) {
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk as Uint8Array);
chunks.push(buf);
onChunk(buf.byteLength);
}
const total = chunks.reduce((acc, c) => acc + c.byteLength, 0);
const out = Buffer.concat(chunks, total);
return out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength);
} catch (e) {
Logger.error(`Failed to download ${path.normalize(filePath)}`, e);
throw Error(`Failed to download ${path.normalize(filePath)}`);
}
};
export const downloadFileToDisk = async (
filePath: string,
fullPath: string,
expectedSize: number,
onChunk: (deltaBytes: number) => void
) => {
const partPath = `${fullPath}.part`;
await fs.ensureFile(partPath);
let resumeFrom = 0;
try {
const stats = await fs.stat(partPath);
if (stats.size > 0 && stats.size < expectedSize) resumeFrom = stats.size;
else if (stats.size >= expectedSize) {
await fs.truncate(partPath, 0);
}
} catch {
}
if (resumeFrom > 0) onChunk(resumeFrom);
const url = buildClientUrl(filePath);
const headers: Record<string, string> = {};
if (resumeFrom > 0) headers.Range = `bytes=${resumeFrom}-`;
let response;
try {
response = await fetch(url, { headers });
} catch (e) {
Logger.error(`Network error downloading ${filePath}`, e);
throw Error(`Failed to download ${path.normalize(filePath)}`);
}
if (!response.ok && response.status !== 206) {
throw Error(`Failed to download ${path.normalize(filePath)}: HTTP ${response.status}`);
}
// If we got 200, the server gave us the whole file
// roll back and truncate
if (resumeFrom > 0 && response.status === 200) {
onChunk(-resumeFrom);
await fs.truncate(partPath, 0);
resumeFrom = 0;
}
const writeStream = fs.createWriteStream(partPath, {
flags: resumeFrom > 0 ? 'a' : 'w'
});
try {
await new Promise<void>((resolve, reject) => {
if (!response.body) {
reject(Error('No response body'));
return;
}
const body = response.body as NodeJS.ReadableStream;
body.on('data', (chunk: Buffer | Uint8Array) => {
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
if (!writeStream.write(buf)) body.pause();
onChunk(buf.byteLength);
});
writeStream.on('drain', () => body.resume());
body.on('end', () => writeStream.end(resolve));
body.on('error', reject);
writeStream.on('error', reject);
});
} catch (e) {
writeStream.destroy();
Logger.error(`Download interrupted for ${filePath}`, e);
throw Error(`Failed to download ${path.normalize(filePath)}`);
}
const finalStats = await fs.stat(partPath);
if (finalStats.size !== expectedSize) {
throw Error(
`Size mismatch for ${path.normalize(filePath)}: got ${finalStats.size}, expected ${expectedSize}. Will retry on next run.`
);
}
await fs.move(partPath, fullPath, { overwrite: true });
};
type UpdaterState =
| 'verifying'
| 'serverUnreachable'
| 'noClient'
| 'updateAvailable'
| 'updating'
| 'upToDate'
| 'failed';
export type UpdaterStatus = {
state: UpdaterState;
progress?: number;
message?: string;
bytesDone?: number;
bytesTotal?: number;
bytesPerSecond?: number;
etaSeconds?: number;
};
const RATE_WINDOW_MS = 5_000;
const ETA_WARMUP_MS = 10_000;
const ETA_PADDING = 1.15;
class ProgressTracker {
#startedAt = Date.now();
#samples: { t: number; bytesDone: number }[] = [];
bytesDone: number;
#baseline: number;
constructor(baseline = 0) {
this.bytesDone = baseline;
this.#baseline = baseline;
}
add(delta: number) {
this.bytesDone = Math.max(this.#baseline, this.bytesDone + delta);
const now = Date.now();
this.#samples.push({ t: now, bytesDone: this.bytesDone });
const cutoff = now - RATE_WINDOW_MS;
while (this.#samples.length > 2 && this.#samples[0].t < cutoff)
this.#samples.shift();
}
bytesPerSecond() {
if (this.#samples.length < 2) return 0;
const first = this.#samples[0];
const last = this.#samples[this.#samples.length - 1];
const dt = (last.t - first.t) / 1000;
if (dt <= 0) return 0;
return Math.max(0, (last.bytesDone - first.bytesDone) / dt);
}
etaSeconds(bytesTotal: number) {
if (Date.now() - this.#startedAt < ETA_WARMUP_MS) return undefined;
const rate = this.bytesPerSecond();
if (rate <= 0) return undefined;
const remaining = bytesTotal - this.bytesDone;
if (remaining <= 0) return 0;
return (remaining / rate) * ETA_PADDING;
}
}
class UpdaterClass extends Observable<UpdaterStatus> {
#manifest?: FileManifest;
#clientTotalBytes = 0;
#bytesAlreadyOnDisk = 0;
#cachePath = path.join(Preferences.userDataDir, 'cache.json');
#cache: CacheTree = fs.existsSync(this.#cachePath)
? fs.readJSONSync(this.#cachePath)
: {};
async #saveCache() {
await fs.writeJSON(this.#cachePath, this.#cache);
}
async #getHash(
{
clientPath,
...m
}: { clientPath: string } & (
| { hMpq: HANDLE; mpqPath: string[] }
| { hMpq?: never }
),
...filePath: string[]
) {
if (m.hMpq) {
if (!SFileHasFile(m.hMpq, path.join(...filePath))) {
nestedSet(this.#cache, filePath, undefined);
return undefined;
}
const c = nestedGet<CacheEntry>(this.#cache, [...m.mpqPath, ...filePath]);
if (c?.[0]) return c[0];
const hFile = SFileOpenFileEx(m.hMpq, path.join(...filePath), 0);
try {
const fileSize = Number(SFileGetFileSize(hFile).toString());
const buffer = new ArrayBuffer(fileSize);
if (fileSize > 0) SFileReadFile(hFile, buffer);
const newHash = crypto
.createHash('sha1')
.update(new Uint8Array(buffer))
.digest('hex')
.toLocaleUpperCase();
nestedSet(this.#cache, [...m.mpqPath, ...filePath], { [0]: newHash });
return newHash;
} finally {
SFileCloseFile(hFile);
}
}
if (!(await fs.exists(path.join(clientPath, ...filePath)))) {
nestedSet(this.#cache, filePath, undefined);
return undefined;
}
const stats = await fs.stat(path.join(clientPath, ...filePath));
if (stats.isDirectory())
throw Error(`Tried to get hash of directory ${path.join(...filePath)}`);
const c = nestedGet<CacheEntry>(this.#cache, filePath);
if (c?.[0] && c[1] === stats.mtimeMs) return c[0];
const newHash = crypto
.createHash('sha1')
.update(await fs.readFile(path.join(clientPath, ...filePath)))
.digest('hex')
.toLocaleUpperCase();
nestedSet(this.#cache, filePath, {
...c,
[0]: newHash,
[1]: stats.mtimeMs
});
return newHash;
}
protected _value: UpdaterStatus = { state: 'failed' };
get status() {
return this._value;
}
private set status(v: UpdaterStatus) {
this._value = v;
this._notifyObservers(v);
if (this.status.state === 'failed') {
mainWindow?.setProgressBar(1, { mode: 'error' });
} else if (this.status.progress === 1) {
mainWindow?.setProgressBar(0);
} else {
mainWindow?.setProgressBar(this.status.progress ?? 0, {
mode: this.status.progress === -1 ? 'indeterminate' : 'normal'
});
}
}
async verify() {
if (this.status?.state === 'verifying' || this.status?.state === 'updating')
return;
const clientPath = Preferences.data.clientDir;
if (!clientPath) {
this.status = { state: 'noClient' };
return;
}
if (os.platform() === 'win32' && clientPath.length > 220) {
this.status = {
state: 'failed',
message:
'Path to current install location is too long and may cause issues.'
};
return;
}
if (await isGameRunning(path.join(clientPath, 'WoW.exe'))) {
this.status = {
state: 'failed',
message: 'Please close WoW first, before updating.'
};
return;
}
Logger.log(`Verifying client files at ${path.join(clientPath)}...`);
this.status = {
state: 'verifying',
progress: -1,
message: 'Looking for updates...'
};
try {
const vanillaFixes = Preferences.data.config.vanillaFixes;
const hashTree = await fetchManifest();
if (!hashTree) {
this.status = { state: 'serverUnreachable' };
return;
}
this.#manifest = { type: 'dir', name: 'root', files: [] };
const totalSize = getManifestSize(hashTree);
let i = 0;
const buildMpqTree = async (
hMpq: HANDLE,
mpqPath: string[],
...filePath: string[]
): Promise<FileManifest | undefined> => {
const item = getManifestItem(hashTree, [...mpqPath, ...filePath]);
if (!item) return undefined;
if (item.type === 'del') return item;
if (item.type === 'dir') {
const files = (
await asyncMap(item.files, f =>
buildMpqTree(hMpq, mpqPath, ...filePath, f.name)
)
).filter(isNotUndef);
return !files.length ? undefined : { ...item, files };
}
if (item.type === 'mpq')
throw Error(
`There can't be an mpq archive inside mpq at path ${path.join(
...mpqPath,
...filePath
)}`
);
this.status = {
state: 'verifying',
progress: i / totalSize,
message: `Verifying: [${mpqPath.at(-1)}] "${path.join(
...filePath
)}"...`
};
i += item.size;
if (
(await this.#getHash({ clientPath, hMpq, mpqPath }, ...filePath)) ===
item.hash
)
return undefined;
return item;
};
const buildTree = async (
...filePath: string[]
): Promise<FileManifest | undefined> => {
const item = getManifestItem(hashTree, filePath);
if (!item) return undefined;
if (item.type === 'del') return item;
if (item.type === 'dir') {
const files = (
await asyncMap(item.files, f => buildTree(...filePath, f.name))
).filter(isNotUndef);
return !files.length ? undefined : { ...item, files };
}
if (item.type === 'mpq') {
const patchPath = [
...filePath.slice(0, -1),
`${filePath.at(-1)}.mpq`
];
this.status = {
state: 'verifying',
progress: i / totalSize,
message: `Verifying: "${path.join(...patchPath)}"...`
};
if (!(await fs.exists(path.join(clientPath, ...patchPath)))) {
i += item.size;
return {
type: 'file',
name: `${item.name}.mpq`,
hash: item.hash,
size: item.size
};
}
if (
(await this.#getHash({ clientPath }, ...patchPath)) === item.hash
) {
i += item.size;
return undefined;
}
try {
const hMpq = SFileOpenArchive(
path.join(clientPath, ...patchPath),
STREAM_FLAG.READ_ONLY
);
try {
const files = (
await asyncMap(item.files, f =>
buildMpqTree(hMpq, filePath, f.name)
)
).filter(isNotUndef);
return !files.length ? undefined : { ...item, files };
} finally {
SFileCloseArchive(hMpq);
}
} catch (e) {
Logger.log(
`Failed to verify ${path.join(
...patchPath
)}, will be downloaded fresh`,
'warning',
e
);
return {
type: 'file',
name: `${item.name}.mpq`,
hash: item.hash,
size: item.size
};
}
}
if (item.tags?.includes('vanillaFixes') && !vanillaFixes) {
if (await fs.exists(path.join(clientPath, ...filePath))) {
return {
type: 'del',
name: item.name
};
} else {
return undefined;
}
}
this.status = {
state: 'verifying',
progress: i / totalSize,
message: `Verifying: "${path.join(...filePath)}"...`
};
i += item.size;
const hash = await this.#getHash({ clientPath }, ...filePath);
if (hash === item.hash) return undefined;
if (
filePath.length === 1 &&
filePath[0] === 'WoW.exe' &&
hash &&
hash === Preferences.data.expectedPatchedWowHash
)
return undefined;
if (hash && item.version) {
const stats = await fs.stat(path.join(clientPath, ...filePath));
if (item.version <= stats.mtimeMs) return undefined;
}
return item;
};
this.#manifest = await buildTree();
await this.#saveCache();
const toDownload = getManifestSize(this.#manifest);
this.#clientTotalBytes = getManifestSize(hashTree);
this.#bytesAlreadyOnDisk = Math.max(
0,
this.#clientTotalBytes - toDownload
);
const availableSpace = await getAvailableDiskSpace();
if (toDownload > availableSpace) {
this.status = {
state: 'failed',
message: `Not enough disk space. Required: ${formatFileSize(
toDownload
)}, Available: ${formatFileSize(availableSpace)}`
};
return;
}
this.status = this.#manifest
? {
state: 'updateAvailable',
message: formatFileSize(toDownload),
progress: this.#bytesAlreadyOnDisk / this.#clientTotalBytes,
bytesDone: this.#bytesAlreadyOnDisk,
bytesTotal: this.#clientTotalBytes
}
: { state: 'upToDate', progress: 1 };
this.#manifest &&
Logger.log(
`Detected changes:\n\t${getManifestFiles(this.#manifest).join(
',\n\t'
)}`
);
const currentLauncherVersion = app.getVersion();
if (
this.status.state === 'upToDate' &&
Preferences.data.lastPatchedLauncherVersion !==
currentLauncherVersion
) {
Logger.log(
`Launcher version changed (${
Preferences.data.lastPatchedLauncherVersion ?? 'unset'
} -> ${currentLauncherVersion}); silently re-applying tweaks via patchExecutable`
);
void (async () => {
try {
await patchExecutable();
const cd = Preferences.data.clientDir;
if (cd) {
const patchedHash = await this.#getHash(
{ clientPath: cd },
'WoW.exe'
);
await this.#saveCache();
Preferences.data = {
lastPatchedLauncherVersion: currentLauncherVersion,
expectedPatchedWowHash: patchedHash
};
}
} catch (e) {
Logger.error(
'Auto-rerun patchExecutable after launcher version bump failed',
e
);
}
})();
}
} catch (e) {
const message =
e instanceof Error ? e.message : 'Unexpected error occurred';
Logger.error(`Verification failed: ${message}`, e);
this.status = { state: 'failed', message };
}
}
async update(clean?: boolean) {
if (this.status?.state === 'verifying' || this.status?.state === 'updating')
return;
const clientPath = Preferences.data.clientDir;
if (!clientPath) {
this.status = { state: 'noClient' };
return;
}
if (await isGameRunning(path.join(clientPath, 'WoW.exe'))) {
this.status = {
state: 'failed',
message: 'Please close WoW first, before updating.'
};
return;
}
Logger.log(`Updating client files at ${path.join(clientPath)}...`);
this.status = {
state: 'updating',
progress: -1,
message: 'Preparing files...'
};
try {
if (clean) {
this.status = {
state: 'updating',
progress: -1,
message: 'Cleaning up old files...'
};
const files = await fs.readdir(clientPath);
for (const file of files) {
if (file === 'OctoLauncher.exe') continue;
await fs.rm(path.join(clientPath, file), {
recursive: true,
force: true
});
}
this.#bytesAlreadyOnDisk = 0;
}
const hashTree =
(clean ? undefined : this.#manifest) ?? (await fetchManifest());
if (!hashTree) {
this.status = { state: 'serverUnreachable' };
return;
}
const fullClientTotal =
this.#clientTotalBytes > 0
? this.#clientTotalBytes
: getManifestSize(hashTree);
this.#clientTotalBytes = fullClientTotal;
const baseline = this.#bytesAlreadyOnDisk;
const tracker = new ProgressTracker(baseline);
let executableUpdate = false;
let lastEmit = 0;
const STATUS_EMIT_INTERVAL_MS = 250;
const emitProgress = (message: string, force = false) => {
const now = Date.now();
if (!force && now - lastEmit < STATUS_EMIT_INTERVAL_MS) return;
lastEmit = now;
this.status = {
state: 'updating',
progress: tracker.bytesDone / fullClientTotal,
message,
bytesDone: tracker.bytesDone,
bytesTotal: fullClientTotal,
bytesPerSecond: tracker.bytesPerSecond(),
etaSeconds: tracker.etaSeconds(fullClientTotal)
};
};
const iterateMpqTree = async (
hMpq: HANDLE,
mpqPath: string[],
...filePath: string[]
) => {
const item = getManifestItem(hashTree, [...mpqPath, ...filePath]);
if (!item) return undefined;
if (item.type === 'del') {
throw Error(
`TODO: Deleting of files from MPQ not implemented at path ${path.join(
...mpqPath,
...filePath
)}`
);
}
if (item.type === 'dir') {
for (const f of item.files)
await iterateMpqTree(hMpq, mpqPath, ...filePath, f.name);
return;
}
if (item.type === 'mpq')
throw Error(
`There can't be an mpq archive inside mpq at path ${path.join(
...mpqPath,
...filePath
)}`
);
const label = `Patching: [${mpqPath.at(-1)}] "${path.join(...filePath)}"`;
emitProgress(label, true);
const data = await fetchFile(
path.join(...mpqPath, ...filePath),
delta => {
tracker.add(delta);
emitProgress(label);
}
);
if (SFileHasFile(hMpq, path.join(...filePath)))
SFileRemoveFile(hMpq, path.join(...filePath));
const hFile = SFileCreateFile(
hMpq,
path.join(...filePath),
0,
data.byteLength,
0,
MPQ_FILE.COMPRESS
);
try {
SFileWriteFile(hFile, data, MPQ_COMPRESSION.ZLIB);
} finally {
SFileFinishFile(hFile);
}
};
const iterateTree = async (...filePath: string[]) => {
const item = getManifestItem(hashTree, filePath);
if (!item) return undefined;
if (item.type === 'del') {
const fullPath = path.join(clientPath, ...filePath);
if (await isReadOnly(fullPath))
throw Error(
`Failed to delete "${fullPath}" because it's read-only.`
);
await fs.remove(fullPath);
await this.#getHash({ clientPath }, ...filePath);
return;
}
if (item.type === 'dir') {
for (const i of item.files) await iterateTree(...filePath, i.name);
return;
}
if (item.type === 'mpq') {
const patchPath = [
...filePath.slice(0, -1),
`${filePath.at(-1)}.mpq`
];
const patchFile = path.join(clientPath, ...patchPath);
const label = `Downloading: "${path.join(...patchPath)}"`;
emitProgress(label, true);
if (!(await fs.exists(patchFile))) {
await downloadFileToDisk(
path.join(...patchPath),
patchFile,
item.size,
delta => {
tracker.add(delta);
emitProgress(label);
}
);
return;
}
if (await isReadOnly(patchFile))
throw Error(
`Failed to update "${patchFile}" because it's read-only.`
);
const hMpq = SFileOpenArchive(path.join(clientPath, ...patchPath), 0);
try {
for (const f of item.files)
await iterateMpqTree(hMpq, filePath, f.name);
SFileFlushArchive(hMpq);
SFileCompactArchive(hMpq);
} finally {
SFileCloseArchive(hMpq);
}
return;
}
const label = `Downloading: "${path.join(...filePath)}"`;
emitProgress(label, true);
if (item.name === 'WoW.exe') executableUpdate = true;
const fullPath = path.join(clientPath, ...filePath);
if (await fs.exists(fullPath) && (await isReadOnly(fullPath)))
throw Error(`Failed to update "${fullPath}" because it's read-only.`);
await downloadFileToDisk(
path.join(...filePath),
fullPath,
item.size,
delta => {
tracker.add(delta);
emitProgress(label);
}
);
await this.#getHash({ clientPath }, ...filePath);
};
await iterateTree();
await this.#saveCache();
const currentLauncherVersion = app.getVersion();
const launcherVersionChanged =
Preferences.data.lastPatchedLauncherVersion !== currentLauncherVersion;
if (executableUpdate || launcherVersionChanged) {
await patchExecutable();
await this.#getHash({ clientPath }, 'WoW.exe');
const patchedWowHash = await this.#getHash({ clientPath }, 'WoW.exe');
await this.#saveCache();
Preferences.data = {
version: await getClientVersion(),
lastPatchedLauncherVersion: currentLauncherVersion,
expectedPatchedWowHash: patchedWowHash
};
}
this.#bytesAlreadyOnDisk = fullClientTotal;
this.status = { state: 'upToDate', progress: 1 };
} catch (e) {
console.error(e);
this.status = {
state: 'failed',
message: e instanceof Error ? e.message : 'Unexpected error occurred'
};
}
}
}
const Updater = new UpdaterClass();
export default Updater;
+8
View File
@@ -0,0 +1,8 @@
export { type AppRouter } from './api/root';
export { type UpdaterStatus } from './modules/updater';
export { type AddonsStatus, type AddonData } from './modules/addons';
export {
type ModsStatus,
type ModRowStatus
} from './modules/mods';
export { type NewsItem, type NewsFeed } from '../common/schemas';
+43
View File
@@ -0,0 +1,43 @@
import { type Worker, type WorkerOptions } from 'node:worker_threads';
import path from 'node:path';
import Logger from 'electron-log/main';
import fs from 'fs-extra';
import Preferences from './modules/preferences';
const isCallbackResponse = (data: any): data is { cb: string; args: any[] } =>
data && typeof data === 'object' && 'cb' in data && 'args' in data;
export const runWorker = <T>(
worker: (o: WorkerOptions) => Worker,
workerData: Record<string, unknown>,
callbacks?: Record<string, (...data: any[]) => void>
) =>
new Promise<T>((resolve, reject) =>
worker({ workerData })
.on('message', m =>
isCallbackResponse(m) ? callbacks?.[m.cb](...m.args) : resolve(m)
)
.on('error', reject)
);
export const getClientVersion = async () => {
Logger.log('Reading client version...');
const exePath = path.join(Preferences.data.clientDir ?? '', 'WoW.exe');
if (!(await fs.exists(exePath))) {
Logger.log('Client not found...');
return undefined;
}
const file = await fs.readFile(exePath);
const buffer = Buffer.from(file);
const version = buffer.toString('utf-8', 0x00437c04, 0x00437c04 + 6);
const build = buffer.toString('utf-8', 0x00437bfc, 0x00437bfc + 4);
Logger.log(`Client version is: ${version} (${build})`);
return `${version} (${build})`;
};
+23
View File
@@ -0,0 +1,23 @@
import { workerData, parentPort } from 'worker_threads';
import git from 'isomorphic-git';
import http from 'isomorphic-git/http/node';
import fs from 'fs-extra';
const port = parentPort;
if (!port) throw new Error('IllegalState');
const { dir, url, ref } = workerData;
fs.removeSync(dir);
git
.clone({
dir,
fs,
http,
url,
ref,
singleBranch: !ref || ref === 'master' || ref === 'main',
onProgress: (...args) => port.postMessage({ cb: 'onProgress', args })
})
.then(() => port.postMessage(true));
+56
View File
@@ -0,0 +1,56 @@
import { workerData, parentPort } from 'worker_threads';
import git from 'isomorphic-git';
import http from 'isomorphic-git/http/node';
import fs from 'fs-extra';
const port = parentPort;
if (!port) throw new Error('IllegalState');
const { dir, remote, branch, ref } = workerData as {
dir: string;
remote: string;
branch: string;
ref?: string;
};
const onProgress = (...args: unknown[]) =>
port.postMessage({ cb: 'onProgress', args });
const removeUntrackedFiles = async () => {
const status = await git.statusMatrix({ fs, dir });
await Promise.all(
status
.filter(([, HEAD]) => HEAD === 0)
.map(([filepath]) => fs.remove(`${dir}/${filepath}`))
);
};
const run = async () => {
if (ref) {
await git.fetch({ fs, http, dir, tags: true, singleBranch: false, onProgress });
await git.checkout({ fs, dir, force: true, ref, onProgress });
await removeUntrackedFiles();
return;
}
await git.checkout({
fs,
dir,
force: true,
ref: `${remote}/${branch}`,
onProgress
});
await removeUntrackedFiles();
await git.pull({
fs,
http,
dir,
ref: branch,
singleBranch: true,
author: { name: 'Octo Launcher' },
onProgress
});
};
run().then(() => port.postMessage(true));
+16
View File
@@ -0,0 +1,16 @@
import path from 'path';
import { contextBridge } from 'electron';
import { electronAPI } from '@electron-toolkit/preload';
import { exposeElectronTRPC } from 'electron-trpc/main';
try {
contextBridge.exposeInMainWorld('electron', electronAPI);
contextBridge.exposeInMainWorld('path', path);
} catch (error) {
console.error(error);
}
process.once('loaded', async () => {
exposeElectronTRPC();
});
+10
View File
@@ -0,0 +1,10 @@
import type path from 'path';
import { type ElectronAPI } from '@electron-toolkit/preload';
declare global {
interface Window {
electron: ElectronAPI;
path: typeof path;
}
}
+51
View File
@@ -0,0 +1,51 @@
import { useState } from 'react';
import { api } from './utils/api';
import PageBackground from './assets/background.png';
import Header from './components/Header';
import LaunchPanel from './components/LaunchPanel';
import SelfUpdateBanner from './components/SelfUpdateBanner';
import TabsPanel, { type TabType } from './components/TabsPanel';
import TopBar from './components/TopBar';
import IconSpinner from './components/styled/IconSpinner';
import usePreventDefaultEvents from './utils/usePreventDefaultEvents';
const App = () => {
const { isLoading } = api.preferences.get.useQuery();
const { data: appVersion } = api.general.appVersion.useQuery();
const [activeTab, setActiveTab] = useState<TabType>();
usePreventDefaultEvents();
return (
<div
className="relative flex grow flex-col gap-3 overflow-hidden bg-cover bg-top bg-no-repeat p-[44px]"
style={{ backgroundImage: `url(${PageBackground})` }}
>
<TopBar />
<SelfUpdateBanner />
<Header {...{ activeTab, setActiveTab }} />
{isLoading ? (
<div className="flex flex-grow items-center justify-center">
<IconSpinner />
</div>
) : (
<>
<TabsPanel activeTab={activeTab} />
<LaunchPanel />
</>
)}
{/* Launcher build label, anchored bottom-right.*/}
{appVersion && (
<span className="pointer-events-none absolute bottom-2 right-3 text-[10px] font-mono uppercase tracking-wider text-white/40 select-none">
v{appVersion}
</span>
)}
</div>
);
};
export default App;
+77
View File
@@ -0,0 +1,77 @@
import { Clipboard, RefreshCw, ServerCrash } from 'lucide-react';
import { Component, type ErrorInfo, type ReactNode } from 'react';
import log from 'electron-log/renderer';
import PageBackground from './assets/background.png';
import TextButton from './components/styled/TextButton';
type State = {
didCatch?: boolean;
error?: Error;
errorInfo?: ErrorInfo;
};
type Props = {
children: ReactNode;
};
class ErrorBoundary extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
log.error('Client crash:', error, errorInfo);
this.setState({ didCatch: true, error, errorInfo });
}
render() {
if (!this.state.didCatch) return this.props.children;
const { error, errorInfo } = this.state;
const title = `Uncaught ${error?.name}: ${
error?.message ?? 'Unknown error'
}`;
const detail = errorInfo?.componentStack.slice(1);
return (
<div
className="relative flex h-screen w-screen grow flex-col overflow-hidden border border-blueGray/10 bg-cover bg-top bg-no-repeat p-3"
style={{ backgroundImage: `url(${PageBackground})` }}
>
<div className="tw-surface flex grow flex-col gap-3">
<div className="flex items-center gap-2">
<ServerCrash size={26} className="text-red" />
<h3 className="text-red">Something went wrong!</h3>
</div>
<hr />
<div className="text-white">{title}</div>
<pre className="s1 -mt-2 grow overflow-auto text-blueGray">
{detail}
</pre>
<hr />
<div className="-mx-3 -mb-3 flex justify-end gap-2">
<TextButton
icon={Clipboard}
onClick={() =>
navigator.clipboard.writeText(
`\`\`\`\n${title}\n${detail}\n\`\`\``
)
}
>
Copy error
</TextButton>
<TextButton
icon={RefreshCw}
onClick={() => window.location.reload()}
className="text-warmGreen"
>
Reload
</TextButton>
</div>
</div>
</div>
);
}
}
export default ErrorBoundary;
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 KiB

+124
View File
@@ -0,0 +1,124 @@
import { useForm } from 'react-hook-form';
import { useEffect } from 'react';
import { PreferencesSchema } from '~common/schemas';
import zodResolver from '~renderer/utils/zodResolver';
import { api } from '~renderer/utils/api';
import TextButton from './styled/TextButton';
import FilePickerInput from './form/FilePickerInput';
import CloseButton from './styled/CloseButton';
type Props = { close: () => void };
const ClientDirDialog = ({ close }: Props) => {
const { data: pref } = api.preferences.get.useQuery();
const setPref = api.preferences.set.useMutation();
const isValidClientDir = api.preferences.isValidClientDir.useQuery(
pref?.clientDir,
{ enabled: !!pref?.isPortable }
);
const verify = api.updater.verify.useMutation();
const {
register,
handleSubmit,
watch,
formState,
setValue,
setError,
reset
} = useForm({
defaultValues: { clientDir: pref?.clientDir ?? '' },
resolver: zodResolver(PreferencesSchema.pick({ clientDir: true }))
});
useEffect(() => {
pref && reset(pref);
}, [reset, pref]);
if (pref?.isPortable) {
return (
<form className="tw-dialog">
<CloseButton close={close} />
<h2 className="color mb-2 text-xl">Install location</h2>
<p>
You are using the portable version of the launcher. Install location
is determined by the location of the launcher executable.
</p>
{!isValidClientDir.isLoading && !isValidClientDir.data && (
<p>
<span className="text-secondary">Error: </span>
WoW.exe not found in current folder. Please close the launcher and
move it to your WoW 1.12 client directory.
</p>
)}
</form>
);
}
return (
<form
className="tw-dialog"
onSubmit={handleSubmit(async ({ clientDir }) => {
try {
await setPref.mutateAsync({ clientDir });
verify.mutateAsync();
close();
} catch (e) {
setError('clientDir', {
message: e instanceof Error ? e.message : JSON.stringify(e)
});
}
})}
>
<CloseButton
close={() => {
reset();
close();
}}
/>
<h3 className="tw-color">Install location</h3>
<hr />
<p className="text-blueGray">
Select a directory for the game client installation.
</p>
<p className="text-blueGray">
You may also choose a directory with an existing Turtle WoW or Vanilla
WoW installation, and it will be automatically upgraded.
</p>
<div className="flex items-center gap-3">
<label htmlFor="clientDir">Install directory:</label>
<FilePickerInput
{...register('clientDir')}
title={watch('clientDir') ?? undefined}
setValue={v =>
setValue('clientDir', v, {
shouldTouch: true,
shouldDirty: true,
shouldValidate: true
})
}
options={{ properties: ['openDirectory', 'createDirectory'] }}
/>
</div>
{formState.errors.clientDir && (
<p className="text-secondary text-sm">
{formState.errors.clientDir.message}
</p>
)}
<TextButton
type="submit"
loading={formState.isSubmitting}
className="self-end text-green"
>
Confirm
</TextButton>
</form>
);
};
export default ClientDirDialog;
+32
View File
@@ -0,0 +1,32 @@
import OctoLogo from '~renderer/assets/logo.png';
import TextButton from './styled/TextButton';
import { TabNames, type TabType } from './TabsPanel';
type Props = {
activeTab?: TabType;
setActiveTab: (tab?: TabType) => void;
};
const Header = ({ activeTab, setActiveTab }: Props) => (
<div className="-mb-3 flex select-none items-center gap-1">
<button
onClick={() => setActiveTab(undefined)}
className="z-10 -my-3 mx-3 w-[180px] cursor-pointer"
>
<img src={OctoLogo} alt="OctoWoW" className="pointer-events-none" />
</button>
{TabNames.map(t => (
<TextButton
key={t}
onClick={() => setActiveTab(t)}
active={activeTab === t}
className="uppercase"
>
{t}
</TextButton>
))}
</div>
);
export default Header;
+218
View File
@@ -0,0 +1,218 @@
import { useState, type ReactElement } from 'react';
import cls from 'classnames';
import { type UpdaterStatus, type ModsStatus } from '~main/types';
import { formatFileSize } from '~common/utils';
import { api } from '~renderer/utils/api';
import Button from './styled/Button';
import DialogButton from './styled/DialogButton';
import ClientDirDialog from './ClientDirDialog';
const formatDuration = (seconds: number) => {
const s = Math.max(0, Math.round(seconds));
if (s < 60) return `${s}s`;
const m = Math.floor(s / 60);
const rem = s % 60;
if (m < 60) return rem ? `${m}m ${rem}s` : `${m}m`;
const h = Math.floor(m / 60);
const minRem = m % 60;
return minRem ? `${h}h ${minRem}m` : `${h}h`;
};
const ProgressDetails = ({ status }: { status: UpdaterStatus }) => {
const { bytesDone, bytesTotal, bytesPerSecond, etaSeconds, progress } = status;
if (bytesTotal === undefined || bytesDone === undefined) return null;
const pct = progress !== undefined && progress >= 0
? `${(progress * 100).toFixed(1)}%`
: '—';
return (
<p className="s1 text-blueGray">
<span className="tw-color">{pct}</span>
<span> · {formatFileSize(bytesDone)} / {formatFileSize(bytesTotal)}</span>
{bytesPerSecond !== undefined && bytesPerSecond > 0 && (
<span> · {formatFileSize(bytesPerSecond)}/s</span>
)}
<span>
{' · '}
{etaSeconds !== undefined
? `~${formatDuration(etaSeconds)} remaining`
: 'calculating…'}
</span>
</p>
);
};
const LaunchPanel = () => {
const [status, setStatus] = useState<UpdaterStatus>({ state: 'verifying' });
api.updater.observe.useSubscription(undefined, {
onData: data => {
console.log({ data });
setStatus(data);
},
onError: err => console.log({ err }),
onStarted: () => console.log('Started')
});
const { data: pref } = api.preferences.get.useQuery();
const [modsStatus, setModsStatus] = useState<ModsStatus>();
api.mods.observe.useSubscription(undefined, {
onData: setModsStatus
});
const verify = api.updater.verify.useMutation();
const update = api.updater.update.useMutation();
const start = api.launcher.start.useMutation();
const applyMods = api.mods.applyAll.useMutation();
const props: Record<
UpdaterStatus['state'],
{ button: ReactElement; helperText?: ReactElement }
> = {
verifying: { button: <Button disabled>Verifying</Button> },
serverUnreachable: {
button: pref?.version ? (
<Button onClick={() => start.mutateAsync()}>Play</Button>
) : (
<Button onClick={() => verify.mutateAsync()}>Retry</Button>
),
helperText: (
<div className="-mb-2">
<p>
<span className="text-orange">Error: </span> Failed to reach update
server
</p>
<p className="s1 text-blueGray">
{pref?.version
? `You can launch local version ${pref?.version}`
: 'Please try again later'}
</p>
</div>
)
},
noClient: {
button: (
<DialogButton
clickAway
dialog={close => <ClientDirDialog close={close} />}
>
{open => (
<Button primary onClick={open}>
Install
</Button>
)}
</DialogButton>
)
},
updateAvailable: {
button: <Button onClick={() => update.mutateAsync()}>Update</Button>,
helperText: (
<div className="-mb-2 flex flex-col gap-1">
<p>Update available!</p>
<p className="s1 text-blueGray">
{status.progress !== undefined &&
status.bytesDone !== undefined &&
status.bytesTotal !== undefined && (
<>
<span className="tw-color">
{(status.progress * 100).toFixed(1)}%
</span>
<span>
{' '}
· {formatFileSize(status.bytesDone)} /{' '}
{formatFileSize(status.bytesTotal)} on disk ·{' '}
</span>
</>
)}
<span className="break-all">{status.message}</span> remaining
</p>
</div>
)
},
updating: {
button: <Button disabled>Updating</Button>,
helperText: (
<div className="-mb-2 flex flex-col gap-1">
{status.message && (
<p className="s1 truncate text-blueGray">{status.message}</p>
)}
<ProgressDetails status={status} />
</div>
)
},
upToDate: {
button: modsStatus?.dirty ? (
<Button
primary
onClick={() => applyMods.mutateAsync()}
disabled={applyMods.isLoading || modsStatus?.state === 'busy'}
>
{modsStatus?.state === 'busy' ? 'Applying' : 'Update'}
</Button>
) : (
<Button primary onClick={() => start.mutateAsync()}>
Play
</Button>
),
helperText: (
<div className="-mb-2">
{modsStatus?.dirty ? (
<p>Mods changed apply before playing</p>
) : (
<p>Everything up to date!</p>
)}
<p className="s1 text-blueGray">Version: {pref?.version}</p>
</div>
)
},
failed: {
button: <Button onClick={() => verify.mutateAsync()}>Retry</Button>,
helperText: (
<div className="-mb-2">
<p>
<span className="text-orange">Error: </span>
{status.message}
</p>
<p className="s1 text-blueGray">
Verify your game data by clicking Retry.
</p>
</div>
)
}
};
return (
<div className="flex gap-3">
<div className="flex flex-grow flex-col justify-end gap-3">
{props[status.state].helperText ??
(status.message && (
<p className="s1 -mb-2 text-blueGray">{status.message}</p>
))}
<div className="tw-loading-wrapper">
{status.progress !== undefined && (
<div
className={cls('tw-loading', {
'tw-loading-unknown': status.progress === -1
})}
style={
status.progress !== -1
? {
clipPath: `inset(0 ${
100 - Math.ceil(Math.abs(status.progress) * 100)
}% 0 0)`
}
: undefined
}
/>
)}
</div>
</div>
{props[status.state].button}
</div>
);
};
export default LaunchPanel;
@@ -0,0 +1,171 @@
import { useForm } from 'react-hook-form';
import { useEffect, useState } from 'react';
import {
FilePen,
FolderOpen,
RefreshCw,
ScrollText,
ShieldCheck
} from 'lucide-react';
import { PreferencesSchema } from '~common/schemas';
import { api } from '~renderer/utils/api';
import zodResolver from '~renderer/utils/zodResolver';
import TextButton from './styled/TextButton';
import CheckboxInput from './form/CheckboxInput';
import DialogButton from './styled/DialogButton';
import ClientDirDialog from './ClientDirDialog';
import CloseButton from './styled/CloseButton';
const MirrorStatus = () => {
const [state, setState] = useState<string>('verifying');
api.updater.observe.useSubscription(undefined, {
onData: ({ state }) => setState(state)
});
if (state === 'serverUnreachable')
return <span className="s1 text-red">offline</span>;
if (state === 'verifying' || state === 'updating')
return <span className="s1 text-blueGray">checking</span>;
return <span className="s1 text-warmGreen">online</span>;
};
type Props = { close: () => void };
const PreferencesDialog = ({ close }: Props) => {
const { data: pref } = api.preferences.get.useQuery();
const setPref = api.preferences.set.useMutation();
const verify = api.updater.verify.useMutation();
const openInstallFolder = api.general.openInstallFolder.useMutation();
const openLogFile = api.general.openLogFile.useMutation();
const { handleSubmit, watch, setValue, reset } = useForm({
defaultValues: pref ?? {},
resolver: zodResolver(PreferencesSchema)
});
useEffect(() => {
pref && reset(pref);
}, [reset, pref]);
const setBool = (key: keyof PreferencesSchema) => (v: boolean) =>
setValue(key, v, {
shouldTouch: true,
shouldDirty: true,
shouldValidate: true
});
return (
<form
className="tw-dialog !w-fit min-w-[480px] max-w-[640px] !gap-1 whitespace-nowrap"
onSubmit={handleSubmit(async v => {
await setPref.mutateAsync(v);
close();
})}
>
<CloseButton
close={() => {
reset();
close();
}}
/>
<h3 className="tw-color">SETTINGS</h3>
<hr className="mb-1" />
<div className="flex items-center gap-3">
<h4 className="tw-color">INSTALL LOCATION:</h4>
<TextButton
icon={FolderOpen}
size={14}
onClick={() => openInstallFolder.mutateAsync()}
className="!p-1 text-blueGray"
>
Open folder
</TextButton>
</div>
<div className="flex items-center gap-2 border border-blueGray/20 bg-darkGray/40 px-3 py-1">
<span
title={pref?.clientDir}
className="min-w-0 shrink grow overflow-hidden text-ellipsis"
>
{pref?.clientDir ?? 'Not selected'}
</span>
<DialogButton
dialog={closeInner => (
<ClientDirDialog
close={() => {
closeInner();
close();
}}
/>
)}
clickAway={pref?.isPortable}
>
{open => (
<TextButton icon={FilePen} size={14} onClick={open} className="!p-1">
Change
</TextButton>
)}
</DialogButton>
</div>
<div className="mt-1 flex items-center gap-3">
<h4 className="tw-color">DOWNLOAD MIRROR:</h4>
</div>
<div className="flex items-center gap-2 pl-2">
<input type="radio" checked readOnly className="accent-warmGreen" />
<span>Iceland</span>
<MirrorStatus />
<TextButton
icon={RefreshCw}
size={12}
onClick={() => verify.mutateAsync()}
title="Re-check"
className="!p-0 text-blueGray"
/>
</div>
<div className="flex items-start gap-3">
<div className="flex flex-col">
<h4 className="tw-color">TROUBLESHOOTING:</h4>
<TextButton
icon={ShieldCheck}
onClick={() => verify.mutateAsync().then(close)}
className="text-warmGreen"
>
Verify game files
</TextButton>
<TextButton
icon={ScrollText}
onClick={() => openLogFile.mutateAsync()}
className="text-pink"
>
Open log file
</TextButton>
</div>
<div className="flex flex-col">
<h4 className="tw-color">GENERAL SETTINGS:</h4>
<CheckboxInput
value={!!watch('cleanWdb')}
setValue={setBool('cleanWdb')}
label="Clean WDB on each launch"
/>
<CheckboxInput
value={!!watch('minimizeToTrayOnPlay')}
setValue={setBool('minimizeToTrayOnPlay')}
label="Minimize to tray while playing"
/>
</div>
</div>
<TextButton type="submit" className="mt-1 self-end text-green">
Save
</TextButton>
</form>
);
};
export default PreferencesDialog;
@@ -0,0 +1,71 @@
import { useState } from 'react';
import { api } from '~renderer/utils/api';
import Button from './styled/Button';
type Status =
| { state: 'idle'; currentVersion: string }
| { state: 'checking'; currentVersion: string }
| { state: 'unavailable'; currentVersion: string }
| { state: 'available'; currentVersion: string; nextVersion: string }
| {
state: 'downloading';
currentVersion: string;
nextVersion: string;
progress: number;
}
| { state: 'ready'; currentVersion: string; nextVersion: string }
| { state: 'error'; currentVersion: string; message: string };
const SelfUpdateBanner = () => {
const [status, setStatus] = useState<Status>({
state: 'idle',
currentVersion: ''
});
api.selfUpdater.observe.useSubscription(undefined, {
onData: setStatus
});
const install = api.selfUpdater.install.useMutation();
if (
status.state === 'idle' ||
status.state === 'checking' ||
status.state === 'unavailable'
) {
return null;
}
const tone = status.state === 'error' ? 'border-red/40' : 'border-tw/40';
const label =
status.state === 'error'
? `Update check failed: ${status.message}`
: status.state === 'available'
? `Launcher update ${'nextVersion' in status ? status.nextVersion : ''} available — preparing download…`
: status.state === 'downloading'
? `Downloading update ${status.nextVersion} · ${Math.round(
status.progress * 100
)}%`
: status.state === 'ready'
? `Launcher update ${status.nextVersion} ready to install`
: '';
return (
<div
className={`relative z-10 flex items-center gap-3 rounded-md border ${tone} bg-black/60 px-4 py-2 text-sm`}
>
<span className="flex-grow break-all">{label}</span>
{status.state === 'ready' && (
<Button
primary
onClick={() => install.mutateAsync()}
disabled={install.isLoading}
>
Install now
</Button>
)}
</div>
);
};
export default SelfUpdateBanner;
@@ -0,0 +1,68 @@
import { AlertTriangle, RefreshCw } from 'lucide-react';
import { Component, type ErrorInfo, type ReactNode } from 'react';
import log from 'electron-log/renderer';
import TextButton from './styled/TextButton';
type Props = {
tabName: string;
children: ReactNode;
};
type State = {
error?: Error;
componentStack?: string;
};
class TabErrorBoundary extends Component<Props, State> {
state: State = {};
static getDerivedStateFromError(error: Error): State {
return { error };
}
componentDidCatch(error: Error, info: ErrorInfo) {
log.error(`Tab "${this.props.tabName}" crashed:`, error, info);
this.setState({ error, componentStack: info.componentStack ?? undefined });
}
componentDidUpdate(prevProps: Props) {
if (prevProps.tabName !== this.props.tabName) {
this.setState({ error: undefined, componentStack: undefined });
}
}
#reset = () => this.setState({ error: undefined, componentStack: undefined });
render() {
if (!this.state.error) return this.props.children;
const { error, componentStack } = this.state;
return (
<div className="tw-surface flex min-h-0 flex-grow flex-col gap-3">
<div className="flex items-center gap-2">
<AlertTriangle size={22} className="text-red" />
<h4 className="text-red">{this.props.tabName} crashed</h4>
</div>
<hr />
<p className="text-white">
{error.name}: {error.message}
</p>
{componentStack && (
<pre className="s1 max-h-[200px] overflow-auto whitespace-pre-wrap text-blueGray">
{componentStack.trim()}
</pre>
)}
<hr />
<TextButton
icon={RefreshCw}
onClick={this.#reset}
className="self-end text-warmGreen"
>
Try again
</TextButton>
</div>
);
}
}
export default TabErrorBoundary;
+30
View File
@@ -0,0 +1,30 @@
import AddonsTab from './tabs/AddonsTab';
import ModsTab from './tabs/ModsTab';
import NewsTab from './tabs/NewsTab';
import TweaksTab from './tabs/TweaksTab';
import TabErrorBoundary from './TabErrorBoundary';
const Tabs = {
'news': NewsTab,
'tweaks': TweaksTab,
'addons': AddonsTab,
'mods': ModsTab
} as const;
export const TabNames = Object.keys(Tabs) as TabType[];
export type TabType = keyof typeof Tabs;
type Props = { activeTab?: TabType };
const TabsPanel = ({ activeTab }: Props) => {
const tab: TabType = activeTab ?? 'news';
const Component = Tabs[tab];
return (
<TabErrorBoundary key={tab} tabName={tab}>
<Component />
</TabErrorBoundary>
);
};
export default TabsPanel;
+79
View File
@@ -0,0 +1,79 @@
import { Settings, Minus, X } from 'lucide-react';
import { useState } from 'react';
import { api } from '~renderer/utils/api';
import DialogButton from './styled/DialogButton';
import PreferencesDialog from './PreferencesDialog';
import TextButton from './styled/TextButton';
const TopBar = () => {
const [safeToQuit, setSafeToQuit] = useState(true);
api.updater.observe.useSubscription(undefined, {
onData: ({ state }) =>
setSafeToQuit(state !== 'verifying' && state !== 'updating')
});
const minimize = api.general.minimize.useMutation();
const quit = api.general.quit.useMutation();
return (
<div
style={{ WebkitAppRegion: 'drag' } as React.CSSProperties}
className="absolute left-0 right-0 top-0 flex justify-end pr-2 pt-2 opacity-50"
>
<div style={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties} className="flex">
<DialogButton dialog={close => <PreferencesDialog close={close} />}>
{open => (
<TextButton
icon={Settings}
title="Settings"
onClick={open}
size={16}
className="!p-1"
/>
)}
</DialogButton>
<TextButton
icon={Minus}
title="Minimize"
onClick={() => minimize.mutateAsync()}
size={16}
className="!p-1"
/>
<DialogButton
dialog={close => (
<div className="tw-dialog">
<h3 className="tw-color">Quit?</h3>
<hr />
<p className="text-blueGray">
Your game is currently being updated. Quitting now may cause
problems.
</p>
<div className="flex gap-2 self-end">
<TextButton onClick={close}>Return</TextButton>
<TextButton
onClick={() => quit.mutateAsync()}
className="text-red"
>
Quit
</TextButton>
</div>
</div>
)}
>
{open => (
<TextButton
icon={X}
title="Quit"
onClick={() => (!safeToQuit ? open() : quit.mutateAsync())}
size={16}
className="!p-1 hocus:text-red"
/>
)}
</DialogButton>
</div>
</div>
);
};
export default TopBar;
@@ -0,0 +1,50 @@
import cls from 'classnames';
import { type ReactNode } from 'react';
import TextButton from '../styled/TextButton';
const Checkbox = () => (
<svg
width={16}
height={16}
viewBox="0 0 12 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="shrink-0"
>
<rect
x="1"
y="1"
width="10"
height="10"
rx="1"
stroke="currentColor"
strokeWidth="1.5"
/>
<rect x="3.5" y="3.5" width="5" height="5" fill="white" />
</svg>
);
type Props = {
label?: ReactNode;
value: boolean;
setValue: (v: boolean) => void;
disabled?: boolean;
className?: cls.Value;
};
const CheckboxInput = ({ label, value, setValue, disabled, className }: Props) => (
<TextButton
onClick={() => !disabled && setValue(!value)}
icon={Checkbox}
className={cls(
'text-blueGray',
{ '[&_*]:fill-none': !value, 'pointer-events-none opacity-40': disabled },
className
)}
>
{label}
</TextButton>
);
export default CheckboxInput;
@@ -0,0 +1,47 @@
import cls from 'classnames';
import { forwardRef, type HTMLProps } from 'react';
import { AppWindow, FolderOpen } from 'lucide-react';
import { api, type RouterInputs } from '~renderer/utils/api';
import TextButton from '../styled/TextButton';
type Props = HTMLProps<HTMLInputElement> & {
setValue: (newVal: string) => void;
options: RouterInputs['general']['filePicker'];
};
const FilePickerInput = forwardRef<HTMLInputElement, Props>(
({ setValue, options, className, ...props }, ref) => {
const filePicker = api.general.filePicker.useMutation();
return (
<div className="relative flex grow">
<input
ref={ref}
id={props.name}
{...props}
className={cls(
'grow border-b border-blueGray bg-inherit p-1 pr-[44px] hocus:border-orange',
className
)}
/>
<TextButton
className="absolute right-1 top-0 h-full"
icon={
options.properties?.includes('openDirectory')
? FolderOpen
: AppWindow
}
title="Pick file"
onClick={async () => {
const r = await filePicker.mutateAsync(options);
if (r.canceled) return;
setValue(r.path[0]);
}}
/>
</div>
);
}
);
export default FilePickerInput;
@@ -0,0 +1,59 @@
import cls from 'classnames';
import { type ChangeEvent, type FocusEvent, type HTMLProps, forwardRef } from 'react';
type Props = Omit<
HTMLProps<HTMLInputElement>,
'value' | 'min' | 'max' | 'step'
> & {
setValue: (v: number) => void;
min?: number;
max?: number;
step?: number;
sensitivity?: number;
};
const NumberGrabInput = forwardRef<HTMLInputElement, Props>(
(
{
setValue,
className,
max = Infinity,
min = -Infinity,
step: _step,
sensitivity: _sensitivity,
type: _ignored,
onChange,
onBlur,
...props
},
ref
) => (
<input
ref={ref}
type="text"
inputMode="numeric"
{...props}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
const n = Number(e.currentTarget.value);
if (Number.isFinite(n) && n > max) {
e.currentTarget.value = String(max);
}
onChange?.(e);
}}
onBlur={(e: FocusEvent<HTMLInputElement>) => {
const n = Number(e.currentTarget.value);
const clamped = Math.max(
Math.min(Number.isFinite(n) ? n : min, max),
min
);
setValue(clamped);
onBlur?.(e);
}}
onWheel={e => !e.shiftKey && e.currentTarget.blur()}
className={cls(
className,
'w-[70px] cursor-text border-b border-blueGray bg-inherit p-1 text-center hocus:border-orange'
)}
/>
)
);
export default NumberGrabInput;
@@ -0,0 +1,44 @@
import cls from 'classnames';
import TextButton from '../styled/TextButton';
const Radio = () => (
<svg
width={16}
height={16}
viewBox="0 0 12 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="6" cy="6" r="5.5" stroke="currentColor" />
<path
d="M8 6C8 7.10429 7.10429 8 6 8C4.89571 8 4 7.10429 4 6C4 4.8957 4.89571 4 6 4C7.10429 4 8 4.8957 8 6Z"
fill="white"
/>
</svg>
);
type Props<T> = {
value: T;
setValue: (val: T) => void;
options: { label: string; value: T }[];
};
const RadioInput = <const T,>({ value, setValue, options }: Props<T>) => (
<div className="flex justify-start">
{options.map(o => (
<TextButton
key={`${o.value}`}
onClick={() => setValue(o.value)}
icon={Radio}
className={cls('text-blueGray', {
'[&_*]:fill-none': value !== o.value
})}
>
{o.label}
</TextButton>
))}
</div>
);
export default RadioInput;
@@ -0,0 +1,17 @@
import cls from 'classnames';
import { forwardRef, type HTMLProps } from 'react';
const TextInput = forwardRef<HTMLInputElement, HTMLProps<HTMLInputElement>>(
(props, ref) => (
<input
ref={ref}
{...props}
className={cls(
'cursor-text border-b border-blueGray bg-inherit p-1 hocus:border-orange',
props.className
)}
/>
)
);
export default TextInput;
+44
View File
@@ -0,0 +1,44 @@
import type { ButtonHTMLAttributes } from 'react';
import cls from 'classnames';
import { type LucideIcon } from 'lucide-react';
import IconSpinner from './IconSpinner';
type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
primary?: boolean;
loading?: boolean;
disabled?: boolean;
icon?: LucideIcon;
};
const Button = ({
primary,
loading,
disabled,
icon: Icon,
children,
className,
...props
}: Props) => (
<button
{...props}
onClick={props.onClick}
tabIndex={!!loading || !!disabled ? -1 : props.tabIndex}
className={cls('tw-button', className, {
'pointer-events-none': !!disabled || !!loading,
'grayscale': disabled,
'tw-button-primary': primary
})}
>
<span className={cls('select-none', { 'ml-[-12px]': !!loading || !!Icon })}>
{loading ? (
<IconSpinner size={23} strokeWidth={1.5} />
) : Icon ? (
<Icon size={23} strokeWidth={1.5} />
) : null}
{children}
</span>
</button>
);
export default Button;
@@ -0,0 +1,14 @@
import { X } from 'lucide-react';
import TextButton from './TextButton';
const CloseButton = ({ close }: { close: () => void }) => (
<TextButton
title="Close"
icon={X}
size={16}
onClick={close}
className="absolute right-1 top-1 text-blueGray hocus:text-red"
/>
);
export default CloseButton;
@@ -0,0 +1,54 @@
type Run = { text: string; color?: string };
const tokenize = (s: string): Run[] => {
const runs: Run[] = [];
const re = /\|c([0-9a-fA-F]{8})|\|r/g;
let i = 0;
let color: string | undefined;
let m: RegExpExecArray | null;
while ((m = re.exec(s)) !== null) {
if (m.index > i) runs.push({ text: s.slice(i, m.index), color });
if (m[0].toLowerCase() === '|r') {
color = undefined;
} else if (m[1]) {
color = `#${m[1].slice(2).toLowerCase()}`;
}
i = re.lastIndex;
}
if (i < s.length) runs.push({ text: s.slice(i), color });
return runs.filter(r => r.text.length > 0);
};
export const stripColorCodes = (s: string) =>
tokenize(s)
.map(r => r.text)
.join('');
export const ColoredText = ({
children,
className,
style
}: {
children: string;
className?: string;
style?: React.CSSProperties;
}) => {
const runs = tokenize(children);
return (
<p className={className} style={style}>
{runs.map((r, i) =>
r.color ? (
<span
key={i}
className="text-size-inherit text-inherit"
style={{ color: r.color }}
>
{r.text}
</span>
) : (
<span key={i}>{r.text}</span>
)
)}
</p>
);
};
@@ -0,0 +1,80 @@
import cls from 'classnames';
import {
useRef,
type ReactElement,
useEffect,
useCallback,
type FC,
isValidElement
} from 'react';
import { createPortal } from 'react-dom';
type Props = {
clickAway?: boolean;
noBlur?: boolean;
focusOnOpen?: boolean;
afterClose?: () => void;
dialog: ReactElement | ((close: () => void) => ReactElement);
children: ReactElement | ((open: () => void) => ReactElement);
};
const DialogButton = ({
clickAway,
noBlur,
focusOnOpen,
afterClose,
dialog,
children
}: Props) => {
const ref = useRef<HTMLDialogElement>(null);
const open = useCallback(() => {
if (!ref.current) return;
!focusOnOpen && (ref.current.inert = true);
ref.current.showModal();
!focusOnOpen && (ref.current.inert = false);
}, [focusOnOpen]);
const close = useCallback(() => {
ref.current?.close();
}, []);
// Click away
useEffect(() => {
if (!clickAway) return;
const callback = (e: MouseEvent) => e.target === ref.current && close();
window.addEventListener('click', callback);
return () => window.removeEventListener('click', callback);
}, [clickAway, close]);
useEffect(() => {
const callback = () => {
afterClose?.();
return (document.activeElement as HTMLElement)?.blur();
};
const r = ref.current;
r?.addEventListener('close', callback);
return () => r?.removeEventListener('close', callback);
}, [afterClose]);
return (
<>
{createPortal(
<dialog
ref={ref}
onSubmit={e => e.stopPropagation()}
className={cls(
'h-full w-full items-center justify-center bg-[transparent] [&[open]]:flex',
{ 'backdrop:backdrop-blur-md': !noBlur }
)}
>
{typeof dialog === 'function' ? dialog(close) : dialog}
</dialog>,
document.body
)}
{typeof children === 'function' ? children(open) : children}
</>
);
};
export default DialogButton;
@@ -0,0 +1,8 @@
import cls from 'classnames';
import { Loader2, type LucideProps } from 'lucide-react';
const IconSpinner = ({ className, ...props }: LucideProps) => (
<Loader2 {...props} className={cls(className, 'animate-spin')} />
);
export default IconSpinner;
@@ -0,0 +1,66 @@
import cls from 'classnames';
import { type LucideIcon } from 'lucide-react';
import { type ReactNode } from 'react';
import IconSpinner from './IconSpinner';
type Props = {
active?: boolean;
loading?: boolean;
disabled?: boolean;
size?: number;
className?: cls.Value;
style?: React.CSSProperties;
} & (
| { type: 'submit'; onClick?: never }
| { type?: never; onClick: () => void }
) &
(
| { children: ReactNode; icon?: LucideIcon; title?: never }
| { children?: never; icon: LucideIcon; title: string }
);
const TextButton = ({
title,
type,
active,
loading,
disabled,
icon: Icon,
size,
onClick,
className,
children,
...props
}: Props) => (
<button
title={title ?? (typeof children === 'string' ? children : undefined)}
type={type ?? 'button'}
onClick={onClick}
tabIndex={!!loading || !!disabled ? -1 : undefined}
className={cls(
'flex cursor-pointer items-center gap-2 border-0 p-2',
className,
{
'tw-color drop-shadow-[0px_0px_10px_white]':
active && !loading && !disabled,
'pointer-events-none text-gray': !!loading || !!disabled,
'tw-hocus': !loading && !disabled
}
)}
{...props}
>
{loading ? (
<IconSpinner size={size ?? 24} strokeWidth={1.5} />
) : (
Icon && <Icon size={size} />
)}
{children && (
<span className="cursor-pointer select-none tracking-wide text-inherit [font-size:_inherit]">
{children}
</span>
)}
</button>
);
export default TextButton;
+131
View File
@@ -0,0 +1,131 @@
import { useState } from 'react';
import { Plus, RefreshCw, Search } from 'lucide-react';
import { type AddonData, type AddonsStatus } from '~main/types';
import { api } from '~renderer/utils/api';
import TextButton from '~renderer/components/styled/TextButton';
import useScrollHint from '~renderer/utils/useScrollHint';
import DialogButton from '../styled/DialogButton';
import IconSpinner from '../styled/IconSpinner';
import AddonList from './addons/AddonList';
import { type Dependencies } from './addons/AddonListItem';
import CustomAddonDialog from './addons/CustomAddonDialog';
const localeFilter = (l: AddonData[], filter: string) => {
const seen = new Set<string>();
const deduped = l.filter(a => {
if (seen.has(a.folder)) return false;
seen.add(a.folder);
return true;
});
return deduped
.filter(
a =>
a.folder.toLocaleLowerCase().indexOf(filter.toLocaleLowerCase()) !== -1
)
.sort((a, b) => a.folder.localeCompare(b.folder));
};
const AddonsTab = () => {
const [data, setData] = useState<AddonsStatus>({
state: 'verifying',
addons: {},
available: []
});
api.addons.observe.useSubscription(undefined, { onData: setData });
const isUpdateAvailable = Object.values(data.addons).some(
a => a.status === 'outOfDate' || a.status === 'downloading'
);
const dependencies: Dependencies = Object.fromEntries([
...data.available.map(a => [a.folder, 'available']),
...Object.values(data.addons).map(a => [
a.folder,
a.progress ?? (a.status === 'upToDate' ? 'installed' : 'available')
])
]);
const [filter, setFilter] = useState('');
const verify = api.addons.verify.useMutation();
const update = api.addons.update.useMutation();
const scrollRef = useScrollHint<HTMLDivElement>();
return (
<div className="tw-surface relative flex min-h-0 flex-grow flex-col gap-3">
<div
ref={scrollRef}
className="relative -m-4 -mb-3 flex flex-grow flex-col gap-3 overflow-y-auto overflow-x-hidden p-4 pb-3"
>
<AddonList
title="Installed"
addons={localeFilter(Object.values(data.addons), filter)}
dependencies={dependencies}
/>
<AddonList
title="Available"
addons={localeFilter(
data.available.filter(a => !(a.folder in data.addons)),
filter
)}
dependencies={dependencies}
/>
</div>
<hr />
<div className="-mb-4 -mt-3 grid grid-cols-[1fr_1fr_1fr] items-center justify-between gap-2 py-2">
<TextButton
onClick={() => verify.mutateAsync()}
className="-ml-2 text-blueGray"
icon={RefreshCw}
size={18}
loading={data.state !== 'done'}
>
Check for updates
</TextButton>
<DialogButton
clickAway
dialog={close => <CustomAddonDialog close={close} />}
>
{open => (
<TextButton
icon={Plus}
size={18}
onClick={open}
className="s1 text-pink"
>
Add custom git addon
</TextButton>
)}
</DialogButton>
{data.state === 'verifying' ? (
<IconSpinner size={18} className="justify-self-end" />
) : isUpdateAvailable ? (
<TextButton
onClick={() => update.mutateAsync({})}
className="justify-self-end text-warmGreen"
>
Update all
</TextButton>
) : (
<p className="s1 justify-self-end text-blueGray">
Everything is up to date.
</p>
)}
</div>
<div className="absolute right-3 top-3">
<div className="flex items-center gap-1 border-b border-blueGray bg-darkGray/70 p-1 hocus:border-orange">
<input
className="cursor-text bg-inherit"
value={filter}
onChange={e => setFilter(e.target.value)}
/>
<Search size={18} />
</div>
</div>
</div>
);
};
export default AddonsTab;
@@ -0,0 +1,7 @@
const ComingSoonTab = () => (
<div className="tw-surface flex flex-grow flex-col items-center justify-center gap-2">
<p className="italic text-blueGray">Coming soon...</p>
</div>
);
export default ComingSoonTab;
+123
View File
@@ -0,0 +1,123 @@
import { useEffect, useState } from 'react';
import { ExternalLink, AlertTriangle, Sparkles } from 'lucide-react';
import cls from 'classnames';
import { api } from '~renderer/utils/api';
import useScrollHint from '~renderer/utils/useScrollHint';
import { type ModRowStatus, type ModsStatus } from '~main/types';
import TextButton from '../styled/TextButton';
import CheckboxInput from '../form/CheckboxInput';
import IconSpinner from '../styled/IconSpinner';
const RowState = ({ row }: { row: ModRowStatus }) => {
if (row.state === 'downloading' || row.state === 'installing')
return <IconSpinner className="text-blueGray" />;
if (row.state === 'uninstalling')
return <IconSpinner className="text-blueGray" />;
if (row.state === 'error')
return (
<span title={row.error}>
<AlertTriangle size={14} className="text-red" />
</span>
);
if (row.installedVersion && row.installedVersion !== row.latestVersion && !row.ignoreUpdates)
return <span className="s1 text-pink">update</span>;
return null;
};
const ModRow = ({ row }: { row: ModRowStatus }) => {
const toggle = api.mods.toggle.useMutation();
const setIgnore = api.mods.setIgnoreUpdates.useMutation();
const openLink = api.general.openLink.useMutation();
return (
<>
<div className="flex items-baseline gap-2">
{row.recommended && (
<Sparkles size={12} className="shrink-0 text-warmGreen" />
)}
<span className={cls(row.recommended && 'text-warmGreen')}>{row.name}</span>
<span className="s1 text-warmGreen">{row.latestVersion}</span>
</div>
<CheckboxInput
value={row.enabled}
setValue={v => toggle.mutate({ id: row.id, enabled: v })}
className="justify-self-center"
/>
<div className="flex items-center gap-2">
<p className="s1 text-blueGray">{row.description}</p>
<TextButton
icon={ExternalLink}
size={14}
title={row.repoUrl}
onClick={() => openLink.mutateAsync(row.repoUrl)}
className="!p-0 text-blueGray"
/>
<RowState row={row} />
</div>
<CheckboxInput
value={row.ignoreUpdates}
setValue={v => setIgnore.mutate({ id: row.id, ignore: v })}
label={<span className="s1">Ignore updates</span>}
/>
</>
);
};
const ModsTab = () => {
const [status, setStatus] = useState<ModsStatus>();
api.mods.observe.useSubscription(undefined, {
onData: setStatus
});
const list = api.mods.list.useQuery(undefined, {
refetchOnMount: true
});
useEffect(() => {
if (!status && list.data) setStatus(list.data);
}, [list.data, status]);
const apply = api.mods.applyAll.useMutation();
const scrollRef = useScrollHint<HTMLDivElement>();
return (
<div className="tw-surface flex min-h-0 flex-grow flex-col gap-3">
<div className="flex items-baseline justify-between">
<h4 className="tw-color">CUSTOM MODS</h4>
{status?.dirty && (
<span className="s1 text-pink">unsaved changes</span>
)}
</div>
<p className="s1 text-blueGray">
<span className="text-orange"></span> Enabling custom mods may not provide
any performance benefits or may even cause game crashes depending on your
system. Please try disabling them if you experience any issues.
</p>
<hr />
<div
ref={scrollRef}
className="relative -m-4 -mt-0 grid flex-grow grid-cols-[auto_auto_1fr_auto] content-start items-center gap-x-4 gap-y-2 overflow-y-auto p-4 pt-0"
>
{status?.mods.map(row => <ModRow key={row.id} row={row} />)}
</div>
<hr />
<div className="-mb-4 -mt-3 flex items-center gap-2 py-2">
<p className="s1 flex-grow text-blueGray">
<span className="text-warmGreen">Highlighted</span> mods are recommended.
</p>
<TextButton
type="button"
loading={apply.isLoading || status?.state === 'busy'}
onClick={() => apply.mutateAsync()}
className={cls(status?.dirty && 'text-green')}
>
Apply
</TextButton>
</div>
</div>
);
};
export default ModsTab;
+102
View File
@@ -0,0 +1,102 @@
import { AlertTriangle, ExternalLink, RefreshCw } from 'lucide-react';
import { type NewsItem } from '~main/types';
import { api } from '~renderer/utils/api';
import useScrollHint from '~renderer/utils/useScrollHint';
import IconSpinner from '../styled/IconSpinner';
import TextButton from '../styled/TextButton';
const formatDate = (raw: string) => {
const d = new Date(raw);
if (Number.isNaN(d.getTime())) return raw;
return d.toLocaleDateString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric'
});
};
const NewsEntry = ({ item }: { item: NewsItem }) => {
const openLink = api.general.openLink.useMutation();
return (
<article className="flex flex-col gap-1 border-b border-blueGray/30 pb-3 last:border-0">
<div className="flex items-baseline justify-between gap-3">
<h5 className="tw-color">{item.title}</h5>
<span className="s1 shrink-0 text-blueGray">{formatDate(item.date)}</span>
</div>
{item.author && (
<span className="s1 italic text-blueGray">by {item.author}</span>
)}
<p className="whitespace-pre-wrap text-sm leading-relaxed">{item.body}</p>
{item.url && (
<TextButton
icon={ExternalLink}
size={14}
className="-ml-2 self-start text-pink"
onClick={() => openLink.mutateAsync(item.url!)}
>
Read more
</TextButton>
)}
</article>
);
};
const NewsTab = () => {
const query = api.news.list.useQuery(undefined, {
staleTime: 5 * 60 * 1000,
refetchOnWindowFocus: false,
retry: 1
});
const scrollRef = useScrollHint<HTMLDivElement>();
return (
<div className="tw-surface flex min-h-0 flex-grow flex-col gap-3">
<div className="flex items-center justify-between">
<h4 className="tw-color">News</h4>
<TextButton
icon={RefreshCw}
size={18}
className="-mr-2 text-blueGray"
loading={query.isFetching}
onClick={() => query.refetch()}
title="Refresh"
/>
</div>
<hr />
<div
ref={scrollRef}
className="relative -m-4 -mt-0 flex flex-grow flex-col gap-3 overflow-y-auto overflow-x-hidden p-4 pt-0"
>
{query.isLoading ? (
<div className="flex flex-grow flex-col items-center justify-center gap-2">
<IconSpinner className="text-blueGray" />
<p className="italic text-blueGray">Loading news...</p>
</div>
) : query.isError ? (
<div className="flex flex-grow flex-col items-center justify-center gap-3">
<AlertTriangle size={32} className="text-red" />
<p className="italic text-blueGray">Couldn't reach the news feed.</p>
<TextButton
icon={RefreshCw}
size={18}
className="text-pink"
onClick={() => query.refetch()}
>
Try again
</TextButton>
</div>
) : !query.data?.length ? (
<div className="flex flex-grow flex-col items-center justify-center">
<p className="italic text-blueGray">No news yet check back later.</p>
</div>
) : (
query.data.map(item => <NewsEntry key={item.id} item={item} />)
)}
</div>
</div>
);
};
export default NewsTab;
+196
View File
@@ -0,0 +1,196 @@
import { useForm, type UseFormReturn } from 'react-hook-form';
import { useEffect } from 'react';
import cls from 'classnames';
import { api } from '~renderer/utils/api';
import { ConfigWtfSchema } from '~common/schemas';
import zodResolver from '~renderer/utils/zodResolver';
import useScrollHint from '~renderer/utils/useScrollHint';
import TextButton from '../styled/TextButton';
import CheckboxInput from '../form/CheckboxInput';
import NumberGrabInput from '../form/NumberGrabInput';
type ItemProps = {
type?: 'checkbox' | 'number';
id: keyof ConfigWtfSchema;
label: string;
recommended?: boolean;
text: string;
min?: number;
max?: number;
step?: number;
sensitivity?: number;
form: UseFormReturn<ConfigWtfSchema>;
};
const Item = ({
type = 'checkbox',
id,
label,
recommended,
text,
form,
...props
}: ItemProps) => {
const { watch, setValue, register } = form;
const setOpts = {
shouldTouch: true,
shouldDirty: true,
shouldValidate: true
} as const;
const watched = type === 'checkbox' ? watch(id) : undefined;
const registered = type === 'number' ? register(id) : undefined;
return (
<>
<p className={cls({ 'text-warmGreen': recommended })}>{label}</p>
{type === 'checkbox' && (
<CheckboxInput
value={!!watched}
setValue={v => setValue(id, v, setOpts)}
className="justify-self-center"
/>
)}
{type === 'number' && registered && (
<NumberGrabInput
{...registered}
{...props}
setValue={v => setValue(id, v, setOpts)}
/>
)}
<p className="s1 text-blueGray">{text}</p>
</>
);
};
const TweaksTab = () => {
const { data: pref } = api.preferences.get.useQuery();
const setPref = api.preferences.set.useMutation();
const applyPatch = api.patcher.apply.useMutation();
const verify = api.updater.verify.useMutation();
const form = useForm<ConfigWtfSchema>({
defaultValues: pref?.config ?? {},
resolver: zodResolver(ConfigWtfSchema)
});
const { handleSubmit, reset } = form;
useEffect(() => {
pref && reset(pref.config);
}, [reset, pref]);
const scrollRef = useScrollHint<HTMLDivElement>();
return (
<form
onSubmit={handleSubmit(async config => {
await setPref.mutateAsync({ config });
await applyPatch.mutateAsync();
await verify.mutateAsync();
reset(config);
})}
className="tw-surface flex min-h-0 flex-grow flex-col gap-3"
>
<div
ref={scrollRef}
className="relative -m-4 -mb-3 grid flex-grow grid-cols-[auto_auto_1fr] content-start items-center gap-x-3 gap-y-1 overflow-y-auto p-4 pb-3"
>
<Item
form={form}
id="alwaysAutoLoot"
label="Always auto-loot"
text="Reverses auto-loot behavior to always auto-loot and disable auto-with bound key."
/>
<Item
form={form}
id="largeAddress"
label="Large Address Aware"
text="Allows the game to use more than 2GB of memory."
recommended
/>
<Item
form={form}
type="number"
id="nameplateRange"
label="Nameplate range"
text="Increases distance at which nameplates are visible. [Vanilla: 20] [Classic: 41]"
min={0}
max={41}
/>
<h4 className="tw-color col-span-3 mt-3">Camera</h4>
<Item
form={form}
id="fieldOfView"
label="Field of View"
type="number"
text="Recommended for widescreen window resolutions. [Vanilla: 90] [Tweaks: 110]"
min={90}
max={180}
step={5}
/>
<Item
form={form}
id="farClip"
label="Render distance"
type="number"
text="Increases maximum render distance. [Vanilla: 777] [Tweaks: 10000]"
min={100}
max={10000}
sensitivity={3}
/>
<Item
form={form}
id="frillDistance"
label="Ground clutter distance"
type="number"
text="Changes ground clutter render distance. [Vanilla: 70] [Tweaks: 300]"
min={0}
max={300}
sensitivity={0.3}
/>
<Item
form={form}
id="cameraDistance"
label="Camera distance"
type="number"
text="Increases maximum camera (zoom out) distance. [Vanilla: 50] [Max:100]"
min={50}
max={100}
/>
<h4 className="tw-color col-span-3 mt-3">Sounds</h4>
<Item
form={form}
id="soundInBackground"
label="Background sounds"
text="Allows game sounds to play while the game is minimized."
recommended
/>
</div>
<hr />
<div className="-mb-4 -mt-3 flex items-center gap-2 py-2">
<p className="s1 flex-grow text-blueGray">
<span className="s1 text-warmGreen">Highlighted</span> options are
recommended and enabled by default
</p>
<TextButton
onClick={async () => {
const config = ConfigWtfSchema.parse({});
await setPref.mutateAsync({ config });
reset(config);
}}
>
Reset
</TextButton>
<TextButton type="submit" className="text-green">
Apply
</TextButton>
</div>
</form>
);
};
export default TweaksTab;
@@ -0,0 +1,138 @@
import { type ReactNode, type PropsWithChildren } from 'react';
import {
AlertOctagon,
ExternalLink,
X,
AlertTriangle,
Check,
Dot,
DownloadCloud
} from 'lucide-react';
import { type AddonData } from '~main/types';
import { api } from '~renderer/utils/api';
import TextButton from '~renderer/components/styled/TextButton';
import { ColoredText } from '~renderer/components/styled/ColoredText';
import useScrollHint from '~renderer/utils/useScrollHint';
import IconSpinner from '~renderer/components/styled/IconSpinner';
import CloseButton from '~renderer/components/styled/CloseButton';
import { type LocalDependencies } from './AddonListItem';
const AddonDetailItem = ({
name,
children
}: PropsWithChildren<{ name: string }>) =>
children ? (
<div className="s1 pl-4 -indent-4 text-blueGray">
{name}:{' '}
{typeof children === 'string' ? (
<ColoredText className="inline">{children}</ColoredText>
) : (
children
)}
</div>
) : null;
type Props = AddonData & {
close: () => void;
warnings: { full: ReactNode; short: ReactNode }[];
dependencies: LocalDependencies;
};
const AddonDetail = ({ close, warnings, dependencies, ...addon }: Props) => {
const openLink = api.general.openLink.useMutation();
const update = api.addons.update.useMutation();
const scrollRef = useScrollHint<HTMLDivElement>();
return (
<div
ref={scrollRef}
className="tw-surface flex max-h-[calc(100vh_-_256px)] w-full max-w-md flex-col gap-3 overflow-y-auto"
>
<CloseButton close={close} />
<ColoredText className="text-2xl">
{addon.toc?.Title ?? addon.folder}
</ColoredText>
<hr />
{addon.error && (
<p className="s1 text-red">
<AlertOctagon size={14} className="inline text-inherit" />{' '}
{addon.error}
</p>
)}
{warnings.map((w, i) => (
<p key={i} className="s1 text-yellow">
<AlertTriangle size={14} className="inline text-inherit" /> {w.full}
</p>
))}
{(addon.toc?.Notes || addon.description) && (
<ColoredText>{addon.toc?.Notes ?? addon.description ?? ''}</ColoredText>
)}
<div>
<AddonDetailItem name="Source">
{addon.git && (
<TextButton
onClick={() => openLink.mutateAsync(addon.git)}
className="s1 -m-2 !inline"
>
Open on GitHub
<ExternalLink size={12} className="ml-1 inline" />
</TextButton>
)}
</AddonDetailItem>
{addon.toc && (
<>
<AddonDetailItem name="Contributions">
{addon.toc.Author}
</AddonDetailItem>
<AddonDetailItem name="Addon version">
{addon.toc.Version}
</AddonDetailItem>
<AddonDetailItem name="Dependencies">
{!!dependencies.length && (
<ul className="pl-2">
{dependencies.map(({ name, optional, status }) => (
<li key={name}>
{status === 'installed' ? (
<Check size={16} className="inline text-darkGreen" />
) : status === 'available' ? (
<TextButton
title="Download"
icon={DownloadCloud}
size={16}
onClick={() =>
update.mutateAsync({ toUpdate: [name] })
}
className="-m-2 !inline text-warmGreen"
/>
) : status === 'missing' ? (
optional ? (
<Dot size={16} className="inline text-blueGray" />
) : (
<X size={16} className="inline text-red" />
)
) : (
<IconSpinner size={16} className="inline" />
)}
<p className="inline"> {name} </p>
{!['installed', 'available', 'missing'].includes(
status
) ? (
<p className="s1 inline text-blueGray">{status}</p>
) : optional ? (
<p className="s1 inline text-blueGray">(optional)</p>
) : null}
</li>
))}
</ul>
)}
</AddonDetailItem>
</>
)}
</div>
</div>
);
};
export default AddonDetail;
@@ -0,0 +1,37 @@
import { Component, type ErrorInfo, type ReactNode } from 'react';
import log from 'electron-log/renderer';
type Props = { children: ReactNode; folder: string; row: number };
type State = { hasError: boolean; message?: string };
class AddonItemErrorBoundary extends Component<Props, State> {
state: State = { hasError: false };
static getDerivedStateFromError(error: Error): State {
return { hasError: true, message: error.message };
}
componentDidCatch(error: Error, info: ErrorInfo) {
log.error(
`[AddonListItem] crash row=${this.props.row} folder=${this.props.folder}:`,
error,
info
);
}
render() {
if (!this.state.hasError) return this.props.children;
return (
<div
className="contents"
style={{ gridRow: this.props.row + 1 }}
>
<div style={{ gridRow: this.props.row + 1, gridColumn: '1/5' }} className="-mx-4 px-4 py-1 text-red s1">
Failed to render &quot;{this.props.folder}&quot;: {this.state.message ?? 'unknown error'}
</div>
</div>
);
}
}
export default AddonItemErrorBoundary;
@@ -0,0 +1,56 @@
import { useState } from 'react';
import { ChevronDown, ChevronRight } from 'lucide-react';
import cls from 'classnames';
import { type AddonData } from '~main/types';
import AddonListItem, { type Dependencies } from './AddonListItem';
import AddonItemErrorBoundary from './AddonItemErrorBoundary';
type Props = {
title: string;
addons: AddonData[];
dependencies: Dependencies;
};
const AddonList = ({ title, addons, dependencies }: Props) => {
const [open, setOpen] = useState(true);
if (!addons.length) return null;
return (
<div>
<button
type="button"
onClick={() => setOpen(o => !o)}
className="mb-2 flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0"
>
{open ? <ChevronDown size={18} /> : <ChevronRight size={18} />}
<h4 className="tw-color">{title}</h4>
</button>
<div
className={cls(
'grid grid-cols-[auto_auto_1fr_auto] items-center gap-x-3 gap-y-1',
!open && 'hidden'
)}
>
{addons.map((addon, i) => {
const { ref: gitRef, ...rest } = addon;
return (
<AddonItemErrorBoundary
key={`${addon.folder}#${i}`}
folder={addon.folder}
row={i}
>
<AddonListItem
row={i}
dependencies={dependencies}
gitRef={gitRef}
{...rest}
/>
</AddonItemErrorBoundary>
);
})}
</div>
</div>
);
};
export default AddonList;
@@ -0,0 +1,233 @@
import {
AlertOctagon,
AlertTriangle,
DownloadCloud,
Github,
HelpCircle,
Trash2
} from 'lucide-react';
import cls from 'classnames';
import { type AddonData } from '~main/types';
import { api } from '~renderer/utils/api';
import TextButton from '~renderer/components/styled/TextButton';
import { ColoredText } from '~renderer/components/styled/ColoredText';
import IconSpinner from '~renderer/components/styled/IconSpinner';
import DialogButton from '~renderer/components/styled/DialogButton';
import { isNotUndef } from '~common/utils';
import CloseButton from '~renderer/components/styled/CloseButton';
import AddonDetail from './AddonDetail';
export type Dependencies = {
[folder: string]: 'installed' | 'available' | string;
};
export type LocalDependencies = {
name: string;
optional: boolean;
status: 'installed' | 'available' | 'missing' | string;
}[];
type Props = Omit<AddonData, 'ref'> & {
row: number;
dependencies: Dependencies;
gitRef?: string;
};
const toRepoUrl = (git?: string) =>
git ? git.replace(/\.git$/, '') : undefined;
const AddonListItem = ({ row, dependencies, ...addon }: Props) => {
const update = api.addons.update.useMutation();
const remove = api.addons.remove.useMutation();
const openLink = api.general.openLink.useMutation();
const repoUrl = toRepoUrl(addon.git);
const localDependencies: LocalDependencies = [
...(addon.toc?.Dependencies?.split(', ')?.map(d => [d, false] as const) ??
[]),
...(addon.toc?.OptionalDeps?.split(', ')?.map(d => [d, true] as const) ??
[])
].map<LocalDependencies[number]>(([d, optional]) => ({
name: d,
optional,
status: dependencies[d] ?? 'missing'
}));
const warnings = [
addon.toc && addon.toc?.Interface !== '11200'
? {
full: `This addon seems to be made for different game version (${addon.toc?.Interface}) and it may not function correctly`,
short: 'Incorrect version'
}
: undefined,
localDependencies.some(d => d.status !== 'installed' && !d.optional)
? {
full: `This addon has missing dependencies: ${localDependencies
.filter(d => d.status !== 'installed' && !d.optional)
.map(d => d.name)
.join(', ')}`,
short: 'Missing dependencies'
}
: undefined
].filter(isNotUndef);
return (
<div className="contents hover-row:bg-purple/30">
<div
className="-mx-4 h-full w-[200%]"
style={{ gridRow: row + 1, gridColumn: '1/4' }}
/>
{addon.status === 'fetching' ? (
<IconSpinner
className="text-blueGray"
size={18}
style={{ gridRow: row + 1, gridColumn: 1 }}
/>
) : (
<DialogButton
clickAway
dialog={close => (
<AddonDetail
close={close}
warnings={warnings}
dependencies={localDependencies}
{...addon}
/>
)}
>
{open => (
<TextButton
icon={
addon.status === 'invalid'
? AlertOctagon
: warnings.length
? AlertTriangle
: HelpCircle
}
onClick={open}
title="Details"
size={18}
className={cls(
'-mx-2',
addon.status === 'invalid'
? 'text-red'
: warnings.length
? 'text-yellow'
: 'text-blueGray'
)}
style={{ gridRow: row + 1, gridColumn: 1 }}
/>
)}
</DialogButton>
)}
<div
className="-ml-2 flex items-center gap-1 whitespace-nowrap"
style={{ gridRow: row + 1, gridColumn: 2 }}
>
<ColoredText>{addon.toc?.Title ?? addon.folder}</ColoredText>
{repoUrl && (
<TextButton
icon={Github}
size={14}
title={`Open ${repoUrl} on GitHub`}
onClick={() => openLink.mutateAsync(repoUrl)}
className="!p-1 text-blueGray/60 hocus:text-pink"
/>
)}
</div>
<ColoredText
className="s1 py-1 text-blueGray"
style={{ gridRow: row + 1, gridColumn: 3 }}
>
{addon.toc?.Notes ?? addon.description ?? ''}
</ColoredText>
<div
className="-m-2 flex items-center justify-end gap-2"
style={{ gridRow: row + 1, gridColumn: 4 }}
>
{addon.status === 'downloading' ? (
<>
<p className="s1 text-blueGray">{addon.progress}</p>
<IconSpinner size={18} className="text-blueGray" />
</>
) : addon.status === 'invalid' ? (
<p className="s1 text-red">{addon.error}</p>
) : warnings.length ? (
<p className="s1 text-yellow">{warnings[0].short}</p>
) : (
<p className="s1 text-blueGray/50">
{addon.status === 'upToDate'
? 'Up to date'
: !addon.git
? 'Not versioned'
: ''}
</p>
)}
{addon.status === 'outOfDate' && (
<TextButton
onClick={() => update.mutateAsync({ toUpdate: [addon.folder] })}
className="s1 -mx-2 justify-self-end"
>
Update
</TextButton>
)}
{addon.status === 'available' ? (
<TextButton
// TODO: With dependencies checkbox
onClick={() => update.mutateAsync({ toUpdate: [addon.folder] })}
className="text-warmGreen"
icon={DownloadCloud}
size={18}
title="Download"
/>
) : (
<DialogButton
clickAway
dialog={close => (
<div className="tw-dialog">
<CloseButton close={close} />
<h4 className="tw-color">Are you sure?</h4>
<hr />
<p className="text-blueGray">
Are you sure you want to delete <span>{addon.folder}</span>{' '}
addon?
</p>
<p className="text-blueGray">
This will delete all files in the addon folder.
</p>
<TextButton
icon={Trash2}
onClick={async () => {
await remove.mutateAsync({ toDelete: [addon.folder] });
close();
}}
disabled={remove.isLoading}
className="self-end text-red"
>
Delete
</TextButton>
</div>
)}
>
{open => (
<TextButton
onClick={open}
className="text-red/50"
icon={Trash2}
size={18}
title="Remove"
/>
)}
</DialogButton>
)}
</div>
</div>
);
};
export default AddonListItem;
@@ -0,0 +1,76 @@
import { Check, X } from 'lucide-react';
import { useEffect, useState } from 'react';
import CloseButton from '~renderer/components/styled/CloseButton';
import IconSpinner from '~renderer/components/styled/IconSpinner';
import TextButton from '~renderer/components/styled/TextButton';
import { api } from '~renderer/utils/api';
const useDebounced = (value: string, delay: number) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const timeout = setTimeout(() => setDebouncedValue(value), delay);
return () => clearTimeout(timeout);
}, [value, delay]);
return debouncedValue;
};
const CustomAddonDialog = ({ close }: { close: () => void }) => {
const [url, setUrl] = useState('');
const debouncedUrl = useDebounced(url, 500);
const response = api.addons.checkGitUrl.useQuery(debouncedUrl, {
enabled: !!debouncedUrl
});
const update = api.addons.install.useMutation();
return (
<div className="tw-dialog">
<CloseButton close={close} />
<h3 className="tw-color">Install addon</h3>
<hr />
{response.data ? (
<img src={response.data?.preview} alt="Preview" className="w-full" />
) : (
<div className="flex h-[191px] w-full items-center justify-center bg-darkPurple">
{response.isFetching && <IconSpinner />}
</div>
)}
<div className="flex items-center gap-1 border-b border-blueGray bg-darkGray/70 p-1 hocus:border-orange">
<input
className="w-full cursor-text bg-inherit"
value={url}
onChange={e => setUrl(e.target.value)}
/>
{response.isFetching ? (
<IconSpinner size={18} />
) : response.data ? (
<Check size={18} />
) : (
<X size={18} />
)}
</div>
<div className="flex items-center justify-end gap-2">
<p className="s1 text-blueGray">
{response.data
? 'Ready to install'
: 'Not a valid git repository URL'}
</p>
<TextButton
onClick={() => {
if (!response.data) return;
update.mutateAsync(response.data);
close();
setUrl('');
}}
className={response.data ? 'text-warmGreen' : 'text-blueGray'}
disabled={!response.data || response.isLoading}
>
Install
</TextButton>
</div>
</div>
);
};
export default CustomAddonDialog;
+6
View File
@@ -0,0 +1,6 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly MAIN_VITE_SERVER_URL: string;
readonly MAIN_VITE_CLIENT_VERSION: string;
}
+374
View File
@@ -0,0 +1,374 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@font-face {
font-family: 'fontin';
src: url('./assets/FontinSans-Regular.otf');
}
@font-face {
font-family: 'din';
src: url('./assets/DINPro-Regular.otf');
}
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
height: 100vh;
}
#root {
position: relative;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
overflow-x: auto;
}
*:focus {
outline: none;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
appearance: none;
margin: 0;
}
input[type='number'] {
-moz-appearance: textfield;
appearance: textfield;
}
::-webkit-scrollbar {
@apply w-2;
@apply h-2;
&-track {
background: transparent;
}
&-thumb {
display: none;
@apply bg-blueGray/40;
:hover& {
display: initial;
cursor: pointer;
}
&:hover {
@apply bg-blueGray;
}
}
&-corner {
display: none;
}
}
.gutter {
background: transparent;
@apply transition-colors;
&:hover {
@apply bg-orange/40;
}
&&-horizontal {
@apply -mx-1;
cursor: col-resize;
}
&&-vertical {
@apply -my-1;
cursor: row-resize;
}
}
@layer components {
:not(svg, svg *) {
color: white;
@apply font-din;
font-style: normal;
font-weight: 400;
font-size: 16px;
line-height: 26px;
cursor: default;
}
h1,
.h1 {
@apply font-fontin;
font-style: normal;
font-weight: 700;
font-size: 78px;
line-height: 76px;
letter-spacing: 0.03em;
text-transform: uppercase;
}
h2,
.h2 {
@apply font-fontin;
font-weight: 700;
font-size: 54px;
line-height: 58px;
letter-spacing: 0.03em;
text-transform: uppercase;
}
h3,
.h3 {
@apply font-fontin;
font-weight: 400;
font-size: 32px;
line-height: 38px;
letter-spacing: 0.03em;
text-transform: uppercase;
}
h4,
.h4 {
@apply font-fontin;
font-weight: 400;
font-size: 20px;
line-height: 26px;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.l1 {
font-size: 18px;
line-height: 32px;
}
.l2 {
font-size: 24px;
line-height: 36px;
}
.s1 {
font-size: 14px;
line-height: 20px;
}
.tw-color {
display: inline;
@apply bg-gradient-to-t from-yellow to-pink;
-webkit-box-decoration-break: clone;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.tw-surface {
position: relative;
@apply border border-blueGray/20 bg-darkGray/70 p-4;
box-shadow: rgb(0 0 0 / 45%) 0px 25px 20px -20px;
& hr {
@apply -mx-4 text-blueGray/20;
}
}
.tw-dialog {
position: relative;
@apply border border-blueGray/20 bg-darkGray/70 p-3;
box-shadow: rgb(0 0 0 / 45%) 0px 25px 20px -20px;
@apply relative flex w-3/5 flex-col gap-2;
& hr {
@apply -mx-3 text-blueGray/20;
}
}
.tw-hocus {
@apply hocus:text-orange hocus:drop-shadow-[0px_0px_15px_white];
}
.tw-input {
@apply rounded-[1px];
@apply border border-gray/40 bg-darkerGray;
@apply p-2;
@apply placeholder:text-gray;
@apply focus:border-blueGray;
&-underline {
@apply tw-input;
@apply border-0;
@apply border-b;
@apply bg-[transparent];
}
}
.tw-button {
overflow: hidden;
position: relative;
cursor: pointer;
flex-shrink: 0;
@apply py-2;
@apply px-4;
@apply bg-darkGray;
@apply border;
@apply rounded-[1px];
&:not(&-primary) {
background: linear-gradient(#f1c22d40, #ff775740);
@apply border-darkBrown;
& > span {
background: linear-gradient(#f1c22d, #ff7757);
-webkit-background-clip: text;
}
& svg {
stroke: #fb9f3a;
}
&::before {
@apply bg-orange;
}
}
&&-primary {
@apply bg-darkGreen/30;
@apply border-[#C8FF0022];
& > span {
background: linear-gradient(#f7ff8a, #8dd958);
-webkit-background-clip: text;
}
& svg {
stroke: #ccf068;
}
&::before {
@apply bg-warmGreen;
}
&:hover,
&:focus {
&::after {
@apply bg-warmGreen;
}
}
}
& > span {
@apply flex items-center justify-center;
@apply gap-2;
@apply font-fontin;
@apply font-bold;
@apply uppercase;
font-size: 20px;
line-height: 30px;
letter-spacing: 2px;
-webkit-box-decoration-break: clone;
-webkit-text-fill-color: transparent;
}
& svg {
font-size: 10px;
line-height: 30px;
}
&:hover,
&:focus {
& > span {
background: white;
-webkit-background-clip: text;
}
& svg {
stroke: white;
}
&::before {
top: 9px;
bottom: 22px;
left: 22px;
right: 22px;
}
&::after {
content: '';
position: absolute;
top: 12px;
bottom: -46px;
left: 12px;
right: 12px;
border-radius: 50%;
@apply bg-orange;
opacity: 0.75;
mix-blend-mode: hard-light;
filter: blur(25px);
}
}
&::before {
content: '';
position: absolute;
top: 5px;
bottom: 5px;
left: 18px;
right: 18px;
border-radius: 50%;
opacity: 0.75;
mix-blend-mode: hard-light;
filter: blur(25px);
}
}
.tw-loading {
@apply absolute inset-0 transition-all;
background: linear-gradient(
90deg,
rgba(255, 119, 87, 0) 0%,
#f89c42 30%,
#f1c22d 50%,
#f89c42 70%,
rgba(255, 119, 87, 0) 100%
);
transition-duration: 300ms;
&-wrapper {
@apply relative w-full before:absolute;
height: 6px;
&::before {
@apply inset-0 opacity-20;
background: linear-gradient(
90deg,
rgba(146, 147, 145, 0) 0%,
#929391 13%,
#929391 87%,
rgba(146, 147, 145, 0) 100%
);
}
}
&-unknown {
@apply animate-progress opacity-20;
background-image: linear-gradient(
-45deg,
#929391,
#929391 33%,
transparent 33%,
transparent 66%,
#929391 66%,
#929391
);
background-size: 1rem 100%;
}
}
}

Some files were not shown because too many files have changed in this diff Show More