Files
Claude 3adebb731f Rename FunPack to FunUI (5.0.3 Classy Chopper): /fun endpoint, wink logo, load-time migration of old names
Old project/workflow names and browser settings migrate on load; /funpack redirects to /fun.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016acRss69eH1235eRdFTZHY
2026-10-25 13:11:03 +00:00

29 lines
1.2 KiB
JavaScript

// Look at a bin file on the monitor: click a tile and it shows over the picture (a picture, a clip with controls, a sound with controls);
// click it again, press ✕ or Esc and the cut is back. Nothing in the project changes.
import { composer as c } from "../../composer/composer.js";
const url = (id) => `/fun/api/media/${encodeURIComponent(id)}/file`;
export default {
id: "media-peek",
mount: "preview",
needs: ["project", "playhead", "keys"],
setup({ host, app }) {
let now = null;
const layer = c.viewer.cover({ onClose: () => { now = null; } });
host.append(layer.node);
function open(item) {
layer.close();
app.say("play.pause");
now = item.id;
layer.show({ src: url(item.id), kind: item.kind });
}
const off = [app.on((what) => {
if (what === "media.peek") { const item = app.mediaPeek && app.mediaPeek.item; if (!item) return; if (now === item.id) layer.close(); else open(item); }
else if (now && (what === "open" || what === "play.start" || what === "play.toggle")) layer.close();
}), app.keys.bind("escape", () => (now ? (layer.close(), true) : false))];
return () => { off.forEach((f) => f()); layer.destroy(); };
},
};