Move @joan/procedural-glyph-engine from absolute path dep (/private/tmp/orby-pkg) to vendored local dep (web/vendor/) so the SPA builds in Docker and on other machines without the temp dir. - Vendor Orby v5.0.0 into web/vendor/ - Switch package.json dep to file:../vendor - Update Dockerfile to COPY vendor into build context - Use npm install instead of npm ci (file: deps need install) - Fix missing trailing newline in Dockerfile
85 lines
2.8 KiB
HTML
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>
|