mirror of
https://github.com/tiennm99/noitu.git
synced 2026-10-11 03:13:45 +00:00
The board, the home screen and the game-over panel, in Vietnamese, served by the Go binary as a static single-page app. The store is a reducer over ServerMessage and computes nothing. Validity, turn order, scores and the result are read from the wire, which is what lets one screen serve the bot now and online play later. Every Vietnamese string lives in one module, including the map from RejectReason to a message, so the server can send UI keys instead of prose. The word field is uncontrolled. A Telex or VNI input method composes a diacritic across several keystrokes, and writing the value back on each one cancels the composition. It is read on submit and cleared only there. The countdown is drawn against the server's clock, estimated from the ping round trip, and settles 300ms early so the ring never claims more time than the server allows. The screen owns the socket and the game while it is mounted, and gives the current game up on the way out. Asking for a game is stored intent rather than a condition inferred from the board being empty: clearing the board for a rematch is that same condition, so the inference sent a second StartBotGame and the server built two rooms that then destroyed each other. A test greps the built bundle for dictionary words and holds a size budget, so the wordlist cannot reach the browser unnoticed. Another reads the error codes out of the Go transport and fails when one has no Vietnamese message.
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { fileURLToPath } from 'node:url';
|
|
import { sveltekit } from '@sveltejs/kit/vite';
|
|
// vitest/config, not vite: the `test` block below is Vitest's, and vite's own
|
|
// config type does not know about it.
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
export default defineConfig({
|
|
plugins: [sveltekit()],
|
|
server: {
|
|
// Dev runs Vite and the Go binary on different ports, so the socket has
|
|
// to be proxied. That keeps the client's URL logic identical in both
|
|
// environments: it always connects to its own origin.
|
|
proxy: {
|
|
'/ws': { target: 'ws://localhost:8080', ws: true },
|
|
'/healthz': 'http://localhost:8080'
|
|
}
|
|
},
|
|
test: {
|
|
// The default node environment: the cross-language fixture test reads
|
|
// files through import.meta.url, which jsdom rewrites to an http URL.
|
|
// The two suites that need a DOM opt in with a per-file docblock.
|
|
include: ['tests/**/*.test.js'],
|
|
// SvelteKit resolves $lib during a build, not under Vitest, so the test
|
|
// run needs the same mapping stated explicitly. It points at the same
|
|
// directory the framework uses, so there is one meaning of $lib.
|
|
alias: {
|
|
$lib: fileURLToPath(new URL('./src/lib', import.meta.url))
|
|
}
|
|
}
|
|
});
|