refactor: (bb64)occupied -> ~(Bb64)PIECE_EMPTY

This commit is contained in:
2026-01-07 20:17:55 +01:00
parent 5a5a392c8b
commit bb3d99b011
9 changed files with 71 additions and 83 deletions

View File

@@ -2,25 +2,24 @@ let exports;
async function init() {
const resp = await fetch("./chess.wasm");
if (!resp.ok) {
throw new Error("fetch wasm failed ${resp.status} ${resp.statusText}");
}
const { instance } =
await WebAssembly.instantiateStreaming(resp, {});
if (!resp.ok) throw new Error(`fetch wasm failed ${resp.status} ${resp.statusText}`);
const { instance } = await WebAssembly.instantiateStreaming(resp, {});
exports = instance.exports;
}
await init();
self.postMessage({ type: "ready" });
self.onmessage = (e) => {
const { id, method, args = [] } = e.data;
try {
const value = exports[method](...args);
let value;
value = exports[method](...args);
self.postMessage({ id, ok: true, value });
} catch (err) {
self.postMessage({ id, ok: false, error: String(err?.message ?? err) });
self.postMessage({
id, ok: false, error: String(err?.message ?? err)
});
}
};