Minor reorganization of files
This commit is contained in:
parent
18c629ac72
commit
f10ced9384
10
AGENTS.md
10
AGENTS.md
@ -1,6 +1,6 @@
|
||||
# AGENTS.md
|
||||
|
||||
OBS/browser overlay that reads Beat Saber Plus Song Overlay events over WebSocket (`ws://localhost:2947/socket`). Serve the folder with **`deno task serve`** (see [`serve.ts`](serve.ts)) so the request-queue JSON loads from the same origin; configure the BS+ database path via `CHAT_REQUEST_DATABASE` or `chat-request-database.path`.
|
||||
OBS/browser overlay that reads Beat Saber Plus Song Overlay events over WebSocket (`ws://localhost:2947/socket`). Serve the folder with **`deno task serve`** (see [`src/server/serve.ts`](src/server/serve.ts)) so the request-queue JSON loads from the same origin; configure the BS+ database path via `CHAT_REQUEST_DATABASE` or `chat-request-database.path`.
|
||||
|
||||
## Preference: HTTP only, no `file://`
|
||||
|
||||
@ -9,11 +9,11 @@ Do **not** add or maintain code paths for opening the overlay as **`file://`**.
|
||||
## Files of interest
|
||||
|
||||
- [`index.html`](index.html) — Page shell: markup for map info, time bar, score, settings dialog; pulls `index.css` and bundled `index.js` module.
|
||||
- [`index.ts`](index.ts) — Main overlay source in TypeScript; connects to BS+ WebSocket, parses events (`gameState`, `mapInfo`, `pause`, `resume`, `score`), updates DOM, and manages settings/hash state.
|
||||
- [`types.ts`](types.ts) — Shared TypeScript types for BS+ payloads/events and chat request JSON.
|
||||
- [`index.js`](index.js) — Bundled browser output generated from `index.ts` via `deno task build`.
|
||||
- [`src/client/index.ts`](src/client/index.ts) — Main overlay source in TypeScript; connects to BS+ WebSocket, parses events (`gameState`, `mapInfo`, `pause`, `resume`, `score`), updates DOM, and manages settings/hash state.
|
||||
- [`src/client/types.ts`](src/client/types.ts) — Shared TypeScript types for BS+ payloads/events and chat request JSON.
|
||||
- [`index.js`](index.js) — Bundled browser output generated from `src/client/index.ts` via `deno task build`.
|
||||
- [`index.css`](index.css) — Layout, theming, visibility toggles driven by body classes and CSS variables from settings.
|
||||
- [`serve.ts`](serve.ts) — Deno static server + optional mapping of `ChatRequest.json` / `database.json` to the real BS+ `Database.json` path.
|
||||
- [`src/server/serve.ts`](src/server/serve.ts) — Deno static server + optional mapping of `ChatRequest.json` / `database.json` to the real BS+ `Database.json` path.
|
||||
- [`deno.json`](deno.json) — Deno tasks and TypeScript compiler options (`build`, `serve`, `dev`).
|
||||
- [`images/`](images/) — Cover fallback (`unknown.svg`), characteristic icons under `images/characteristic/` (filenames match BS+ characteristic strings).
|
||||
- [`README.md`](README.md) — User-facing usage (Deno, OBS URL, BS+ module).
|
||||
|
||||
@ -11,7 +11,7 @@ Requires [BeatSaberPlus](https://github.com/hardcpp/BeatSaberPlus)
|
||||
|
||||
Install [Deno](https://docs.deno.com/runtime/getting_started/installation/) and serve the overlay over HTTP (see below).
|
||||
|
||||
The browser overlay source is now TypeScript (`index.ts`) and is bundled to `index.js` with `deno task build` (run automatically by `deno task serve`).
|
||||
The browser overlay source is now TypeScript (`src/client/index.ts`) and is bundled to `index.js` with `deno task build` (run automatically by `deno task serve`).
|
||||
|
||||
The server must know where Beat Saber Plus stores **`ChatRequest/Database.json`**. It then serves that file as `ChatRequest.json` and `database.json` (same data) over HTTP—no symlink.
|
||||
|
||||
@ -34,6 +34,6 @@ Clone the repo and run `deno task serve` as above.
|
||||
|
||||
### Development tasks
|
||||
|
||||
- `deno task build` - bundle/check `index.ts` for browser output (`index.js`)
|
||||
- `deno task build` - bundle/check `src/client/index.ts` for browser output (`index.js`)
|
||||
- `deno task serve` - build, then serve `index.html` and JSON files
|
||||
- `deno task dev` - watch and rebuild `index.js` when `index.ts` changes
|
||||
- `deno task dev` - watch and rebuild `index.js` when client TS changes
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
"lib": ["dom", "dom.iterable", "deno.ns", "esnext"]
|
||||
},
|
||||
"tasks": {
|
||||
"build": "deno bundle --platform=browser --check index.ts -o index.js",
|
||||
"serve": "deno task build && deno run --allow-net --allow-read --allow-env serve.ts",
|
||||
"dev": "deno bundle --platform=browser --watch --check index.ts -o index.js"
|
||||
"build": "deno bundle --platform=browser --check src/client/index.ts -o index.js",
|
||||
"serve": "deno task build && deno run --allow-net --allow-read --allow-env src/server/serve.ts",
|
||||
"dev": "deno bundle --platform=browser --watch --check src/client/index.ts -o index.js"
|
||||
}
|
||||
}
|
||||
|
||||
2
index.js
2
index.js
@ -1,4 +1,4 @@
|
||||
// index.ts
|
||||
// src/client/index.ts
|
||||
function must(id) {
|
||||
const element = document.getElementById(id);
|
||||
if (!element) throw new Error(`Missing element: ${id}`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { join } from "jsr:@std/path";
|
||||
import { serveDir } from "jsr:@std/http/file-server";
|
||||
|
||||
const root = import.meta.dirname ?? ".";
|
||||
const scriptDir = import.meta.dirname ?? ".";
|
||||
const root = join(scriptDir, "..", "..");
|
||||
const port = Number(Deno.env.get("PORT") ?? "8080");
|
||||
|
||||
function trimPathLine(line: string): string {
|
||||
@ -13,7 +14,7 @@ function trimPathLine(line: string): string {
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
/** Optional one-line file next to this script: absolute path to `ChatRequest/Database.json`. */
|
||||
/** Optional one-line file in repo root: absolute path to `ChatRequest/Database.json`. */
|
||||
function readOptionalPathFile(): string | undefined {
|
||||
try {
|
||||
const pathFile = join(root, "chat-request-database.path");
|
||||
Loading…
x
Reference in New Issue
Block a user