diff --git a/.gitignore b/.gitignore index cb826ac5..6132c937 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ wbindgen/ *.cmd/ *.result.json game.json +node_modules/ diff --git a/README.md b/README.md index 8d4db502..3f9b49c4 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,18 @@ ### Run local web client - `cd client` -- `./wasm-bindgen-macroquad.sh local_client` - In the `client` directory, run `basic-http-server .` in `dist/` and open `http://localhost:4000` in a browser. +- `./build-local.sh local_client` +- `cd dist` +- `basic-http-server .` +- open `http://localhost:4000` in a browser. + +### Run remote web client locally + +- `cd client` +- `./build-remote.sh` +- `cd remote_client/dist` +- `basic-http-server .` +- `google-chrome --disable-web-security --user-data-dir=/tmp http://localhost:8612` ### Server wrapper @@ -24,6 +34,11 @@ # Notes - https://stackoverflow.com/questions/40102686/how-to-install-package-with-local-path-by-yarn-it-couldnt-find-package +- class:d-none={!stateSent} + +# Todo + +- Add https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js to scripts ## Boardgamers Mono @@ -43,13 +58,13 @@ old .tool-versions ``` -nodejs 14.21.3 +nodejs 16.x pnpm 6.14.1 ``` ### Bypass npm publish -``` +```diff Index: apps/game-server/app/services/engines.ts IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP @@ -71,6 +86,37 @@ diff --git a/apps/game-server/app/services/engines.ts b/apps/game-server/app/ser export async function getEngine(name: string, version: number): Promise { ``` +### Set viewer directly + +```diff +Index: apps/api/app/resources.ts +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/apps/api/app/resources.ts b/apps/api/app/resources.ts +--- a/apps/api/app/resources.ts (revision 741eecd403ed7c5b38b3b98b1e26be8a502cafc0) ++++ b/apps/api/app/resources.ts (date 1726922668897) +@@ -31,7 +31,8 @@ + + const viewer: ViewerInfo = + gameInfo?.viewer?.alternate?.url && ctx.query.alternate === "1" ? gameInfo?.viewer.alternate : gameInfo.viewer; +- const viewerUrl = ctx.query.customViewerUrl || viewer.url; ++ const viewerUrl = "/home/gregor/source/clash/client/remote_client/index.js"; + + ctx.body = ` + +@@ -48,7 +49,9 @@ + + + <${"script"} type='text/javascript'> +- const gameObj = window.${viewer.topLevelVariable}.launch('#app'); ++ const gameObj = window.clash.launch('#app'); + window.addEventListener('message', event => { + console.log('received message from controller', event.data.type, JSON.parse(JSON.stringify(event.data))); + switch (event.data.type) { +``` + ## Docs - [Game API](https://docs.boardgamers.space/guide/engine-api.html) diff --git a/client/Cargo.lock b/client/Cargo.lock index 1c5ad1df..bad4fcd6 100644 --- a/client/Cargo.lock +++ b/client/Cargo.lock @@ -204,11 +204,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" name = "client" version = "0.1.0" dependencies = [ + "async-std", "hex2d", "itertools", "lazy_static", "log", "macroquad", + "serde-wasm-bindgen", "serde_json", "server", "wasm-bindgen", diff --git a/client/Cargo.toml b/client/Cargo.toml index 7f5eb4ad..f37b1739 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -2,6 +2,13 @@ name = "client" version = "0.1.0" edition = "2021" +default-run = "local_client" + +[profile.dev] +debug = true + +[profile.release] +debug = true [features] # disable file import and export @@ -22,7 +29,13 @@ wasm-bindgen = "0.2.83" wasm-bindgen-futures = "0.4.33" lazy_static = "1.4.0" log = "0.4.20" +async-std = "1.13.0" +serde-wasm-bindgen = "0.6.5" [[bin]] name = "local_client" path = "src/local_client/bin/main.rs" + +[[bin]] +name = "remote_client" +path = "src/remote_client/bin/main.rs" diff --git a/client/wasm-bindgen-macroquad.sh b/client/build-local.sh similarity index 95% rename from client/wasm-bindgen-macroquad.sh rename to client/build-local.sh index 629e21a2..05638215 100755 --- a/client/wasm-bindgen-macroquad.sh +++ b/client/build-local.sh @@ -80,7 +80,7 @@ HTML=$( } - +