Files
oikos/web/vendor/examples/state-sequence.html
dtoro 8ff382a50d
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
ci / web (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled
0.28.1 — vendor @joan/procedural-glyph-engine for portable SPA builds (fixes deploy)
The procedural-glyph-engine dep pointed at a non-portable file:/private/tmp/orby-pkg
path, breaking npm ci in Docker and every main deploy since v0.20.0 (the build
cache masked it until it busted ~Aug 5). Vendor Orby v5.0.0 into web/vendor/,
switch the dep to file:../vendor, and use npm install in the web Dockerfile
(file: deps need install, not ci). Cherry-picked from 3cd4cf9.
2026-08-08 21:41:51 +02:00

85 lines
2.8 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Orby · State sequence example</title>
<link rel="stylesheet" href="./example.css" />
</head>
<body>
<main>
<h1>Timed sequence</h1>
<p>
Define a product-owned timeline, then pause, resume, stop, or replay it
through one controller.
</p>
<div class="glyph-stage">
<canvas id="aiGlyph" width="440" height="440" aria-label="Animated AI state sequence"></canvas>
</div>
<div class="actions" role="group" aria-label="Sequence controls">
<button id="replay" type="button">Replay</button>
<button id="pause" type="button">Pause</button>
<button id="resume" type="button">Resume</button>
<button id="stop" type="button">Stop</button>
</div>
<p id="stateStatus" role="status">Sequence ready</p>
</main>
<script type="module">
import { createGlyph } from "../src/joan-engine.js";
import { playStateSequence } from "../src/state-sequence.js";
const glyph = createGlyph("#aiGlyph", {
sprite: "ai.idle",
seed: "self-service-sequence",
gridSize: 68,
});
const status = document.querySelector("#stateStatus");
let playback;
const play = () => {
playback?.stop();
const nextPlayback = playStateSequence(glyph, [
{ sprite: "ai.idle", holdMs: 1_200 },
{ sprite: "ai.thinking", holdMs: 2_000 },
{ sprite: "ai.progress", holdMs: 1_200 },
{ sprite: "status.success", transition: "path-draw" },
]);
playback = nextPlayback;
status.textContent = "Sequence playing";
nextPlayback.finished.then(
() => {
if (playback === nextPlayback) status.textContent = "Sequence complete";
},
(error) => {
if (playback === nextPlayback) {
status.textContent = `Sequence ended: ${error.name}`;
}
},
);
};
document.querySelector("#replay").addEventListener("click", play);
document.querySelector("#pause").addEventListener("click", () => {
playback?.pause();
status.textContent = "Sequence paused";
});
document.querySelector("#resume").addEventListener("click", () => {
playback?.resume();
status.textContent = "Sequence playing";
});
document.querySelector("#stop").addEventListener("click", () => {
playback?.stop();
status.textContent = "Sequence stopped";
});
window.addEventListener("pagehide", () => {
playback?.stop();
glyph.destroy();
}, { once: true });
play();
</script>
</body>
</html>