The fake Mac desktop Sirenda's test uses: two windows, the Dock, the menu bar, a pointer that moves 4 s and rests 4 s. Hotspots are outlined: join magenta, toy cyan, snooze orange, the X (dismiss) white. Clicks aren't simulated.
Or paste the code
MeetingStart
Load a siren.js (or paste its code) to play it on the fake desktop.
1:48 left
Jump to
No siren yet.
\n' : "") + (source.indexOf("Matter") >= 0 ? '\n' : "") + (source.indexOf("CANNON") >= 0 ? '\n' : "");
const desktop = { desktop: o.desktop === "bare" ? "bare" : "full", pointer: o.desktop !== "bare", begin: o.begin || 0, joinAt: o.joinAt == null ? null : o.joinAt };
let head = PAGE.head
.replace("%%MEETING%%", () => JSON.stringify(MEETINGS[o.meeting] || PAGE.demo).replace(/ JSON.stringify(desktop))
.replace("%%LIBS%%", () => libs);
const line = head.split("\n").length;
head = head.replace("%%LINES%%", () => "window.__sirenLine = " + line + "; window.__sirenLines = " + source.split("\n").length + ";");
const tail = PAGE.tail.replace("%%USES%%", () => "(" + usesScript + ")();").replace("%%BRIDGE%%", () => "(" + bridgeScript + ")();");
return head + safe(source) + tail;
}
// ---- Talking to the frame ----
let frame = null, ready = null, nextId = 1;
const calls = new Map();
addEventListener("message", (e) => {
if (!frame || e.source !== frame.contentWindow || !e.data || !e.data.sirenda) return;
if (e.data.ready) return ready && ready();
const c = calls.get(e.data.id);
if (!c) return;
calls.delete(e.data.id);
if (e.data.error) c.reject(new Error(e.data.error));
else c.resolve(e.data.result);
});
const within = (promise, ms, what) => Promise.race([promise, new Promise((_, no) => setTimeout(() => no(new Error(what + " took over " + ms / 1000 + " s")), ms))]);
function call(method, ...args) {
if (!frame) return Promise.reject(new Error("no siren loaded"));
return within(new Promise((resolve, reject) => {
const id = nextId++;
calls.set(id, { resolve, reject });
frame.contentWindow.postMessage({ sirenda: true, id, method, args }, "*");
}), 120000, method);
}
function fitStage() {
const k = testMode ? 1 : stage.clientWidth / VIEW.width;
stage.style.height = VIEW.height * k + "px";
if (frame) frame.style.transform = "scale(" + k + ")";
}
addEventListener("resize", fitStage);
/** A fresh frame for a run: `o` is { meeting: "demo" | "none" | "crowd", desktop: "full" | "bare", begin, joinAt } (seconds into the warning). */
async function load(source, o) {
for (const c of calls.values()) c.reject(new Error("the siren was reloaded"));
calls.clear();
if (frame) frame.remove();
stage.textContent = "";
frame = document.createElement("iframe");
frame.width = VIEW.width;
frame.height = VIEW.height;
frame.setAttribute("scrolling", "no");
frame.title = "siren";
const loaded = new Promise((resolve) => (ready = resolve));
frame.srcdoc = pageFor(source, o);
stage.appendChild(frame);
fitStage();
await within(loaded, 60000, "loading the page");
return call("init");
}
window.preview = { load, call, pageFor, lead: L, viewport: VIEW };
if (testMode) return;
// ---- The preview's controls ----
const ui = { source: null, meeting: "demo", start: "warning", run: null, playing: false };
const mmss = (sec) => Math.floor(sec / 60) + ":" + String(Math.floor(sec % 60)).padStart(2, "0");
const whenText = (w) => (w < L ? mmss(Math.ceil(L - w - 1e-6)) + " left" : "+" + (w - L < 10 ? (w - L).toFixed(1) + " s" : mmss(w - L)) + " after the start");
const options = () => ({ meeting: ui.meeting, desktop: ui.meeting === "none" ? "bare" : "full", begin: ui.start === "meeting" ? L : 0, joinAt: $("joins").checked ? L + 8 : null });
const sameRun = (a, b) => a && b && a.meeting === b.meeting && a.desktop === b.desktop && a.begin === b.begin && a.joinAt === b.joinAt;
function say(text, bad) {
$("console").textContent = text;
$("console").classList.toggle("bad", !!bad);
}
/** Shows the siren at `w` seconds into the warning: forward from where it is, or a fresh run when going back. */
async function show(w, quiet) {
if (!ui.source) return;
const o = options();
w = Math.max(o.begin, Math.min(END, w));
if (!ui.run || !sameRun(ui.run.o, o) || w < ui.run.w - 1e-6) {
say("Loading…");
const init = await load(ui.source, o);
ui.run = { o, w: o.begin, init };
if (!init.ok) return void (await report(true));
}
const out = await call("runTo", w - o.begin, quiet ? 1 : 0.75, quiet ? 0 : 30);
ui.run.w = out.t + o.begin;
await call("overlay", $("outline").checked);
$("scrub").value = ui.run.w;
$("when").textContent = whenText(ui.run.w);
// While playing, the facts twice a second are plenty.
if (!quiet || performance.now() - (ui.reported || 0) > 500) {
ui.reported = performance.now();
await report(false, out);
}
}
async function report(failed, out) {
const st = await call("state");
const lines = [];
if (ui.run && !ui.run.init.ok) lines.push(ui.run.init.error || "It didn't start.");
for (const e of st.errors) lines.push(e);
for (const e of st.consoleErrors) lines.push("console: " + e);
const bad = lines.length > 0 || failed;
// Advice, not errors: shown in the same line, never in red.
const unknown = [...new Set(st.soundCalls.filter((c) => c[2] && c[1] === "sound" && st.soundNames.indexOf(c[2]) < 0).map((c) => c[2]))];
if (unknown.length) lines.push("Unknown sound names (the app ignores them): " + unknown.join(", "));
// One soft ambient loop at most: an ambient name, volume 0.3 at most.
const loops = {};
for (const c of st.soundCalls) if (c[1] === "ambient" && c[2]) loops[c[2]] = Math.max(loops[c[2]] == null ? -Infinity : loops[c[2]], typeof c[3] === "number" ? c[3] : 0.3);
const loopNames = Object.keys(loops);
const strangers = loopNames.filter((n) => st.soundNames.indexOf(n) >= 0 && st.ambientNames.indexOf(n) < 0);
if (strangers.length) lines.push("Sirenda.ambient only loops the ambient sounds: " + strangers.join(", ") + " can't loop.");
if (loopNames.some((n) => loops[n] > 0.300001)) lines.push("The ambient loop is too loud: keep its volume at 0.3 or less.");
if (loopNames.length > 1) lines.push("Sirenda.ambient plays " + loopNames.length + " different loops: keep one.");
const times = out && out.times && out.times.length ? out.times : null;
const perf = times ? " Draw time " + (times.reduce((a, b) => a + b, 0) / times.length).toFixed(1) + " ms a frame on average." : "";
say((bad ? "" : "No errors." + perf + (lines.length ? "\n" : "")) + lines.join("\n"), bad);
$("name").textContent = st.name ? st.name + " (" + st.mode + ")" + (st.description ? ": " + st.description : "") : "";
if (failed) return;
const [texts, hotspots] = await Promise.all([call("texts"), call("hotspots")]);
const sounds = st.soundCalls.slice(-6).map((c) => whenText(c[0]) + ": " + (c[1] === "ambient" ? "ambient " : "") + c[2]);
const list = (items) => (items.length ? "