Use a deno runtime to read the bs+ bsr queue file (Database.json)

This commit is contained in:
pleb
2026-04-11 16:13:45 -07:00
parent 4b4c74f31b
commit 4b0cf034bb
13 changed files with 432 additions and 34 deletions
+3 -4
View File
@@ -2,15 +2,14 @@
## Static web app with typed JavaScript
The overlay loads inside OBS from a URL or `file://` path, with no install step for streamers.
The overlay is plain HTML/CSS/JS with no bundler: run it locally with **`deno task serve`** or host the files on any static server. OBS uses an **http(s) URL** to the page.
Consequences: Ease of use
- Adding or updating the overlay is **copy or point OBS at `index.html`** (hosted or local); nothing to build before use.
- We avoid a toolchain that would complicate “drop this folder in” or quick Netlify-style hosting.
- Adding or updating the overlay is **copy files or point OBS at a URL**; nothing to build before use beyond optional Deno for local serving and the chat-request database path.
- Type safety is **optional IDE assistance**, not enforced at publish time (there is no `tsc` in CI by default).
This static, dependency-free shape exists **because** it stays easy to wire up as an OBS Browser Source while keeping the codebase maintainable through JSDoc and `types.d.ts`.
This dependency-free client shape stays easy to wire as an OBS Browser Source while keeping the codebase maintainable through JSDoc and `types.d.ts`.
## BeatSaberPlus
+11 -13
View File
@@ -1,39 +1,37 @@
# Testing in a browser
The overlay is a static page. You can exercise the UI and wiring without OBS by opening it in any Chromium-based browser (Chrome, Edge) or Firefox.
Run **`deno task serve`** from the repo (see [README](../README.md)), then open the overlay in Chromium (Chrome, Edge) or Firefox.
## Open the page
Use a **`file://` URL** (same idea as OBS): absolute path to `index.html`, forward slashes. This clone:
Use the URL the server prints, for example:
`file:///C:/Users/example/ops/BeatSaber-Overlay/index.html?scale=1.5`
`http://127.0.0.1:8080/index.html?scale=1.5`
Paste that into the address bar, or drag `index.html` into a browser window.
Settings live in the **URL fragment** (after `#`). Put query parameters **before** the hash if you use both: `index.html?debug=1#…`
Settings are stored in the **URL fragment** (after `#`). Using a full `file://` URL (not only picking “Open file” in a way that strips the hash) keeps hash-based settings working, same idea as in the [README](../README.md).
## Preview the song overlay (no Beat Saber)
## Debug mode (no Beat Saber)
**Click anywhere** on the page (outside the settings dialog) to toggle **preview** mode. The song overlay appears with the built-in placeholder labels so you can check layout, toggles, scale, and fade without a game connection.
Without the game, the overlay normally hides outside **Playing** (and during BeatSaver loading). Add a **query parameter** so it stays visible for layout or WebSocket checks:
## Request list simulation
- Enable: `?debug=1`
- Example: `file:///C:/Users/example/ops/BeatSaber-Overlay/index.html?debug=1`
Enable **Debug** in the settings dialog (or add **`?debug=1`** to the URL). The song requests list then uses the **`history`** array from the JSON instead of **`queue`**, so you can see how entries look with the same shape as real data (`key`, `rqn`, `npr`, etc.). The header title is unchanged.
Put `?debug` **before** the `#` hash if you use both: `index.html?debug=1#…`
The Deno server exposes Beat Saber Plus data as **`ChatRequest.json`** and **`database.json`** (same file). With debug, the page tries **`ChatRequest.json`** first, then **`database.json`**. To load a different filename, add **`?requests=yourfile.json`**.
## What you should see
- The overlay layout with placeholder labels until live data arrives.
- **Developer tools → Console:** log lines such as `Connecting to ws://localhost:2947/socket` on load. If [Beat Saber Plus](https://github.com/hardcpp/BeatSaberPlus) is **not** running with the Song Overlay module listening on that port, the socket will close and the script **retries every 10 seconds**—that is expected.
- **With Beat Saber running** and BS+ Song Overlay enabled: you should see `Connection open.` when the WebSocket succeeds, and map info, time, and score update while you play.
## Quick UI checks without the game
- Click the page (outside the settings dialog) to toggle the **preview** / settings visibility.
- **Click** the page (outside the settings dialog) to toggle **preview** and open the settings strip.
- Change checkboxes and values in the dialog; the **URL hash** should update and layout should reflect toggles and scale.
## Live data path
End-to-end testing needs the same pieces as streaming: **Beat Saber**, **Beat Saber Plus** with the **Song Overlay** module active, so `ws://localhost:2947/socket` accepts connections. The browser page only connects to that local WebSocket; it does not start the server.
End-to-end testing needs the same pieces as streaming: **Beat Saber**, **Beat Saber Plus** with the **Song Overlay** module active, so `ws://localhost:2947/socket` accepts connections. The browser page only connects to that local WebSocket; it does not start the game server.
For custom maps, the overlay may request **BeatSaver** over HTTPS; use **Network** in devtools if those requests fail (offline, blocked, or API errors).