0.3.1-0-pre.2

This commit is contained in:
2026-09-20 21:30:12 +02:00
parent ba718ce4ec
commit 51371c1b24
29 changed files with 981 additions and 21 deletions

View File

@@ -0,0 +1,58 @@
/* file: crates/apps/game-snake-poc-tauri/frontend/css/main.css */
/* version: 1 */
:root {
font-family: system-ui, sans-serif;
color-scheme: dark;
background: #101418;
color: #f4f7f8;
}
* {
box-sizing: border-box;
}
html,
body {
min-height: 100%;
margin: 0;
}
body {
min-height: 100vh;
display: grid;
place-items: center;
padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom))
max(1.5rem, env(safe-area-inset-left));
}
.bootstrap-panel {
width: min(100%, 34rem);
padding: 1.5rem;
border: 1px solid currentColor;
border-radius: 0.75rem;
}
.eyebrow {
margin: 0 0 0.5rem;
opacity: 0.7;
}
h1 {
margin: 0 0 1rem;
font-size: clamp(1.6rem, 7vw, 2.4rem);
}
#runtime-status {
margin: 0 0 0.75rem;
}
#runtime-provenance {
display: block;
overflow-wrap: anywhere;
font-family: ui-monospace, monospace;
}
body[data-runtime-state="error"] #runtime-status {
font-weight: 700;
}

View File

@@ -0,0 +1,17 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>Snake POC Tauri</title>
</head>
<body>
<main class="bootstrap-panel" aria-labelledby="runtime-title">
<p class="eyebrow">games.sasedev</p>
<h1 id="runtime-title">Snake — Tauri Android</h1>
<p id="runtime-status">Initialisation du runtime…</p>
<output id="runtime-provenance" aria-live="polite">provenance en attente</output>
</main>
<script type="module" src="/ts/main.ts"></script>
</body>
</html>

View File

@@ -0,0 +1,20 @@
// file: crates/apps/game-snake-poc-tauri/frontend/ts/bridge.ts
// version: 1
import { invoke } from "@tauri-apps/api/core";
export interface RuntimeDescriptor {
deviceClass: string;
executionModel: string;
inputProfile: string;
platformFamily: string;
runtimeHost: string;
}
export async function getRuntimeDescriptor(): Promise<RuntimeDescriptor> {
return await invoke<RuntimeDescriptor>("get_runtime_descriptor");
}
export async function reportFrontendReady(): Promise<void> {
await invoke("frontend_ready");
}

View File

@@ -0,0 +1,16 @@
// file: crates/apps/game-snake-poc-tauri/frontend/ts/logging.ts
// version: 1
import { attachConsole, error, info } from "@fltsci/tauri-plugin-tracing";
export async function initializeFrontendTracing(): Promise<void> {
await attachConsole();
}
export function frontendInfo(message: string): void {
info(message);
}
export function frontendError(message: string): void {
error(message);
}

View File

@@ -0,0 +1,56 @@
// file: crates/apps/game-snake-poc-tauri/frontend/ts/main.ts
// version: 1
import init, { SnakeWasmGame } from "@snake-wasm";
import "../css/main.css";
import { getRuntimeDescriptor, reportFrontendReady } from "./bridge";
import { frontendError, frontendInfo, initializeFrontendTracing } from "./logging";
function requiredElement<T extends HTMLElement>(identifier: string): T {
const element = document.getElementById(identifier);
if (element === null) {
throw new Error(`Élément frontend requis absent : ${identifier}`);
}
return element as T;
}
async function bootstrap(): Promise<void> {
await initializeFrontendTracing();
frontendInfo("Snake Tauri frontend bootstrap started");
const descriptor = await getRuntimeDescriptor();
await init();
const game = new SnakeWasmGame();
const configured = game.configure_runtime_provenance(
descriptor.platformFamily,
descriptor.runtimeHost,
descriptor.deviceClass,
descriptor.inputProfile,
);
if (!configured) {
game.free();
throw new Error("La provenance Tauri Android n'a pas été acceptée par l'adapter Snake WASM.");
}
const status = requiredElement<HTMLParagraphElement>("runtime-status");
const provenance = requiredElement<HTMLOutputElement>("runtime-provenance");
status.textContent = "Runtime minimal initialisé. Le Canvas et les contrôles arrivent dans 0-pre.3.";
provenance.value = [
game.provenance_platform_family(),
game.provenance_runtime_host(),
game.provenance_execution_model(),
game.provenance_device_class(),
game.provenance_input_profile(),
].join(" / ");
window.addEventListener("pagehide", () => game.free(), { once: true });
await reportFrontendReady();
frontendInfo(`Snake Tauri frontend ready: ${provenance.value}`);
}
void bootstrap().catch(reason => {
const message = reason instanceof Error ? reason.message : String(reason);
document.body.dataset.runtimeState = "error";
const status = document.getElementById("runtime-status");
if (status !== null) {
status.textContent = `Échec d'initialisation : ${message}`;
}
frontendError(`Snake Tauri frontend bootstrap failed: ${message}`);
});