mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-08-10 18:59:56 +00:00
The option-heavy player UIs (mixer, camera director, viz, audio routing)
all live in the rail popovers, which are exclusive: openPopFor() closes
the last one before opening the next. You cannot watch the mixer while
riding the camera, and both vanish the moment you look at the highway.
Add `window.feedBack.panes` — a core registry for live UI that is
authored once as `mount(root, ctx)` and hosted anywhere. Panes are
non-exclusive, and they survive song switches structurally: the dock is a
body child outside every .screen, so the per-song teardown never sees it.
The adoption cost for a plugin is two calls:
feedBack.panes.register({ id, title, icon, mount, unmount });
feedBack.panes.attachChip(myExistingDialogEl, id);
attachChip injects THE standard pop-out chip. Clicking it opens the pane
and hides the plugin's dialog, leaving a stub to bring it back. Core owns
the hide/restore, so every plugin's pop-out looks and behaves the same —
which is the point. It hides via a dedicated .fb-pane-detached class, not
.hidden/[hidden], because the dialogs we attach to already toggle those.
Everything a pane may touch arrives through `ctx` — never a global. That
is what will let the same mount() run inside a pop-out window, a separate
JS realm with no window.feedBack, no window.highway and no audio graph:
ctx.call(domain, cmd, payload) -> the capability bus
ctx.on(event, fn) -> the feedBack bus (allowlisted)
ctx.subscribe(stream, fn) -> playhead / meters
ctx.state.get/set -> persisted, main realm is the only writer
ctx.playhead(), ctx.song(), ctx.toast(), ctx.close()
ctx tracks every subscription it hands out and drops them on unmount, so
a pane cannot leak listeners across a dock/undock cycle.
Streams exist because an AnalyserNode cannot cross a window boundary:
levels are reduced to numbers in the realm that owns the audio graph.
One shared rAF loop, refcounted against live subscriptions, dirty-checked
before fan-out, and stopped dead when the last pane closes.
Hosts register themselves with the manager rather than being imported by
it — the dock lands at priority 0 (the floor, always available), so the
OS pane window can drop in later without this code changing.
Ships two built-in panes: Now Playing (the reference pane — reads the bus,
a stream, and levels, and touches no globals) and Mixer (the same faders
as the rail, via ctx.call('audio-mix', ...), with the chip attached to the
real #mixer-control). Plus a "Panes" rail popover to open panes that have
no dialog of their own; the system tray will mirror that list.
Note the dock sits at z-index 110, not on the docs/plugin-v3-ui.md ladder
(transport 20, rail 30, popovers 40) — those live INSIDE #player's
stacking context, and #player is itself fixed at z-index 100. A dock below
100 is invisible on the one screen panes exist for. Body-level ladder:
#player 100 < dock 110 < toasts 120 < modals 200.
Pop-out windows, the system tray, manifest-declared panes and mirrorGlobal
(the window.__h3dCamCtl proxy the camera director needs) follow.
Signed-off-by: topkoa <topkoa@gmail.com>
62 lines
2.3 KiB
JavaScript
62 lines
2.3 KiB
JavaScript
/*
|
|
* fee[dB]ack — pane launcher (the "Panes" rail popover).
|
|
*
|
|
* A chip only works for a pane that already has a dialog to hide. Panes with no
|
|
* dialog — a readout, a plugin's optional extra — need somewhere to be opened
|
|
* from, so every registered pane gets one: a checkbox list in the rail.
|
|
*
|
|
* The rail popover is the right home for this precisely because it IS exclusive
|
|
* and transient. It's a menu, not a workspace; the panes it opens are the
|
|
* workspace, and they persist.
|
|
*
|
|
* Populated from the registry, so a plugin that calls panes.register() appears
|
|
* here with no further work. (The system tray will mirror this list.)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
const panes = window.feedBack && window.feedBack.panes;
|
|
const bus = window.feedBack;
|
|
if (!panes || !bus || typeof bus.on !== 'function') return;
|
|
|
|
let listEl = null;
|
|
|
|
function render() {
|
|
if (!listEl || !listEl.isConnected) listEl = document.getElementById('v3-rail-panes-list');
|
|
if (!listEl) return;
|
|
const all = panes.list();
|
|
listEl.replaceChildren();
|
|
|
|
if (!all.length) {
|
|
const empty = document.createElement('div');
|
|
empty.className = 'v3-pop-empty';
|
|
empty.textContent = 'No panes available.';
|
|
listEl.appendChild(empty);
|
|
return;
|
|
}
|
|
|
|
all.forEach((p) => {
|
|
const b = document.createElement('button');
|
|
b.type = 'button';
|
|
b.className = 'v3-pop-btn';
|
|
b.setAttribute('aria-pressed', p.open ? 'true' : 'false');
|
|
b.textContent = (p.open ? '● ' : '○ ') + p.icon + ' ' + p.title;
|
|
b.addEventListener('click', (e) => {
|
|
e.stopPropagation();
|
|
if (panes.isOpen(p.id)) panes.close(p.id); else panes.detach(p.id);
|
|
});
|
|
listEl.appendChild(b);
|
|
});
|
|
}
|
|
|
|
// The registry changes when plugins load and when panes open/close. Render is
|
|
// cheap and rare (never on a playback path), so just re-run it.
|
|
bus.on('panes:registered', render);
|
|
bus.on('panes:unregistered', render);
|
|
bus.on('panes:opened', render);
|
|
bus.on('panes:closed', render);
|
|
|
|
if (document.readyState !== 'complete') document.addEventListener('DOMContentLoaded', render);
|
|
else render();
|
|
})();
|