Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

905 B
Raw Blame
"use client";

import { useSyncExternalStore } from "react";

// Playhead frame lives OUTSIDE React so the rAF-driven playback loop can advance
// it at 60 fps without re-rendering the whole reel-editor slice. Components that
// need the current frame subscribe via useFrame(); the others (timeline lanes,
// files pane, layer panels) never re-render on a tick. Pattern mirrors the
// appshell pub/sub stores (focus-mode, badges, recents).

let frame = 30;
const subs = new Set<() => void>();

export function getFrame(): number {
  return frame;
}

export function setFrame(next: number): void {
  if (next === frame) return;
  frame = next;
  subs.forEach((cb) => cb());
}

export function subscribeFrame(cb: () => void): () => void {
  subs.add(cb);
  return () => {
    subs.delete(cb);
  };
}

export function useFrame(): number {
  return useSyncExternalStore(subscribeFrame, getFrame, getFrame);
}