feat(web): bring the Senbei workbench to the browser

Add folder scanning, Android library and package recovery, and the localized desktop-style workbench. Keep browser-refused outputs in a fallback ZIP and include logs with folder and ZIP exports.

Align the desktop and web modal transitions and polish the desktop About and legal dialogs.
This commit is contained in:
Momoko-Ayase committed 2026-11-18 17:10:12 +08:00
1 parent 20a68b1c73
commit 21236e8b98
59 files changed
+11612 -3436

No files matched your search

+33 -8
View File
@@ -1,15 +1,22 @@
# Senbei Web
Senbei runs in the browser through the `senbei-wasm` crate. Files are read locally, unpacked in a worker, and offered back as downloads; no server receives input bytes.
Senbei runs in the browser through the `senbei-wasm` crate. Files are read locally, recovered in a Web Worker, and kept in the tab for download; no server receives input bytes.
## Features
- Protected `.exe` and `.dll` files produce `<name>.unpack.*` downloads.
- External `.exe._` and `.dll._` companions are paired by filename.
- `global-metadata.dat` produces `global-metadata.unpack.dat` when tokens change.
- Each output receives the same static integrity check as the CLI.
- Protected `.exe` and `.dll` files, with `.exe._` and `.dll._` companions paired by path.
- Protected Android AArch64 `.so` libraries, including the metadata blob a library embeds.
- `global-metadata.dat`, bound to module `0x0C` of its application when the format needs it.
- `.apk`, `.apks`, and `.xapk` packages: the manifest is read first, and only `.so` and `global-metadata.dat` entries are extracted.
- Folders, picked or dropped. A scan opens only files whose names can be targets and never enters an `unpack` directory.
- Download outputs individually or together in a ZIP with the unfiltered input logs. Where the browser can write to a folder, Senbei saves the outputs and a timestamped `senbei-*.log` under `unpack/` in the selected folder.
- The interface follows the desktop workbench and its five languages.
Every unpack uses a disposable Web Worker so a WebAssembly trap cannot freeze the page. A trapped DLL can be retried through the forced-EXE path, matching native routing.
Every recovery runs in its own worker. The worker exits when the job finishes or traps, so a WebAssembly trap does not take down the page and the worker's memory can be reclaimed. A trapped DLL is retried through the EXE-only route, matching native routing.
**Add folder** can use the browser's folder input even when the File System Access API is unavailable. Drag-and-drop scans require the browser to expose directory entries. Saving to a folder requires the File System Access API and write permission. If Chromium refuses to write some file types directly, including `.dll`, Senbei puts those files in a `senbei-remaining.*.zip` in `unpack/`. Extract it there to put them beside the files saved directly. All outputs remain downloadable from the tab.
The browser shows Overview and Log, plus Entries for packages. Use the desktop app for Dry run, Inspect, and the Research, Hex, and Compare views.
## Build
@@ -18,8 +25,26 @@ cd senbei-wasm
wasm-pack build --target web --release --out-dir ../web/pkg
```
Serve `web/` with a static HTTP server, for example `python -m http.server -d web 8000`. Opening `index.html` with `file://` does not work because browser modules require HTTP.
Serve `web/` with a static HTTP server, for example `python -m http.server -d web 8000`. Opening `index.html` with `file://` does not work because browser modules require HTTP. `node web/tools/stage.mjs <dist>` copies the files the site needs, and only those, into `<dist>`.
## Test
```cmd
npm test --prefix web
```
The tests cover the pure modules under Node. `senbei-cli/tests/wasm_parity.rs` compares the binding with the native byte API.
## Layout
`senbei-wasm/src/lib.rs` contains the bindings. `web/app.js` manages the dropzone and downloads, `web/worker.js` runs one unpack job per worker, and `web/pkg/` contains ignored wasm-pack output.
| Path | Contents |
| --- | --- |
| `senbei-wasm/src/lib.rs` | The bindings: in-memory recovery for PE files, Android libraries, and metadata. |
| `web/app.js`, `web/run.js`, `web/output.js` | Browser events, adding inputs, the run queue, and saving outputs. |
| `web/view.js`, `web/detail.js`, `web/ui.js` | Workbench, detail pane, and shared UI components. |
| `web/state.js` | Inputs, selection, and results kept in the tab. |
| `web/engine.js`, `web/worker.js` | The compiled module shared between workers, and one recovery per worker. |
| `web/scan.js`, `web/package.js`, `web/zip.js` | Folder walking, package inventory, and ZIP reading and writing over `Blob`. |
| `web/model.js`, `web/report.js` | Naming and pairing rules shared with the native front ends, and the JSON report. |
| `web/i18n/` | Language catalogs generated by `web/tools/gen-i18n.mjs` from the desktop wording, plus `web-strings.json` for browser-only text. |
| `web/pkg/` | Ignored `wasm-pack` output. |