Files
MajoorWaldi-ComfyUI-Majoor-…/ui/features/viewer/viewerOpenRequest.ts
T
Ewald ALOEBOETOE ee5bc6ead5 Remove the classic viewer and its player; keep only the Studio viewer
The Studio viewer now covers everything the classic overlay did, so the
classic runtime (toolbar, panzoom, A/B and side-by-side engine, scopes,
loupe, probe, grading and WebGL video processors, filmstrip, context menu,
keyboard handling), its styles and its tests are deleted.

- Every open request goes to the Studio viewer; requestViewerOpen no longer
  falls back to a viewer singleton.
- Drop the classic-only settings (use classic viewer, pan without zoom,
  disable WebGL) and their internal options and constants.
- Studio tells the grid which asset it ended on when it closes, and the
  rating hotkeys yield to it while it is open.
- Remove dead helpers left behind (image processor, media player helpers,
  3D helpers, metadata block, viewerbar controls variant) and unused CSS.
- Update the viewer tutorial, hotkeys doc and changelog.
2026-11-04 13:04:25 +00:00

44 lines
1.3 KiB
TypeScript

import { EVENTS } from "../../app/events.js";
function normalizeViewerMode(mode: any) {
const normalized = String(mode || "")
.trim()
.toLowerCase();
if (normalized === "ab" || normalized === "sidebyside") return normalized;
return "";
}
function normalizeAssets(assets: any, asset: any) {
const list = Array.isArray(assets) ? assets.filter(Boolean) : [];
if (list.length) return list;
return asset ? [asset] : [];
}
/**
* Ask the main (Studio) viewer to open. Resolves true when a viewer handled
* the request (the Studio overlay listens for OPEN_VIEWER).
*/
export function requestViewerOpen({
assets = [],
asset = null,
index = 0,
mode = "",
}: { assets?: unknown[]; asset?: unknown; index?: number; mode?: string } = {}): boolean {
const list = normalizeAssets(assets, asset);
if (!list.length) return false;
const safeIndex = Math.max(0, Math.min(Number(index) || 0, list.length - 1));
const detail = {
assets: list,
index: safeIndex,
mode: normalizeViewerMode(mode),
handled: false,
};
try {
window.dispatchEvent(new CustomEvent(EVENTS.OPEN_VIEWER, { detail }));
} catch (e: any) {
console.debug?.(e);
}
return detail.handled === true;
}