Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3967af110 | ||
|
|
92b98b6579 | ||
|
|
58f3e5010a | ||
|
|
7cc19ef696 | ||
|
|
86a3270f1c | ||
|
|
e9d6edc2c8 | ||
|
|
b3b7b29007 | ||
|
|
62c34fe80c | ||
|
|
4c6a2b8f76 | ||
|
|
9313c9e42a |
@@ -303,9 +303,11 @@ below. Nothing is installed without someone clicking.
|
||||
status, NOW and NEXT labels, slide count, progress bar, the next list and
|
||||
its item tags, plus tidy titles.
|
||||
- **Timers** — live ProPresenter timers (countdown, countdown-to-time,
|
||||
elapsed) and LTC timecode as auto-sized cards. The + picker lists every
|
||||
discovered timer (and the LTC card) as its own tile, or add "All timers"
|
||||
and pick a selection via the tile's "Timers ▾" menu; overruns are
|
||||
elapsed), the **video countdown** (time left on what ProPresenter is
|
||||
playing, with a per-tile "Looping videos" switch so looping backgrounds
|
||||
stay hidden) and LTC timecode as auto-sized cards. The + picker lists
|
||||
every discovered timer (and the LTC card) as its own tile, or add "All
|
||||
timers" and pick a selection via the tile's "Timers ▾" menu; overruns are
|
||||
unmistakably red. Read-only — no start/stop controls. Admin config is in
|
||||
three groups: **ProPresenter** (endpoint host : port, API password),
|
||||
**LTC Timecode** (the listener switch, and — when it's on — the audio
|
||||
|
||||
@@ -391,7 +391,8 @@ const menu = moduleApi.header.addMenu({
|
||||
build(menuEl) {
|
||||
// called on every open with an emptied menu element — fill it with
|
||||
// buttons (give them your scoped classes; the container is styled and
|
||||
// fixed-positioned by the shell, so the tile's overflow can't clip it)
|
||||
// positioned by the shell, hosted on the body under an element carrying
|
||||
// your data-module, so your scoped CSS applies and nothing clips it)
|
||||
},
|
||||
});
|
||||
menu.setLabel('Channels (2/4) ▾'); // update the button text any time
|
||||
|
||||
@@ -81,8 +81,8 @@ export default function create({ root, moduleApi }) {
|
||||
moduleApi.saveInstanceSettings({ textSize: Math.min(48, Math.max(10, current + delta)) });
|
||||
applyInstanceSettings();
|
||||
}
|
||||
moduleApi.header.addButton({ icon: MINUS_SVG, title: 'Smaller text', onClick: () => bumpTextSize(-2) });
|
||||
moduleApi.header.addButton({ icon: PLUS_SVG, title: 'Larger text', onClick: () => bumpTextSize(2) });
|
||||
const minusBtn = moduleApi.header.addButton({ icon: MINUS_SVG, title: 'Smaller text', onClick: () => bumpTextSize(-2) });
|
||||
const plusBtn = moduleApi.header.addButton({ icon: PLUS_SVG, title: 'Larger text', onClick: () => bumpTextSize(2) });
|
||||
|
||||
// icon and tooltip track the current direction — applyInstanceSettings sets both
|
||||
const flowBtn = moduleApi.header.addButton({
|
||||
@@ -95,7 +95,7 @@ export default function create({ root, moduleApi }) {
|
||||
},
|
||||
});
|
||||
|
||||
moduleApi.header.addButton({
|
||||
const latestBtn = moduleApi.header.addButton({
|
||||
icon: JUMP_SVG,
|
||||
title: 'Latest',
|
||||
onClick() {
|
||||
@@ -112,6 +112,82 @@ export default function create({ root, moduleApi }) {
|
||||
});
|
||||
clearBtn.classList.add('pt-clear');
|
||||
|
||||
/* ── a narrow tile: the bar keeps Channels, the rest fold into ⋯ ──
|
||||
Seven controls need ~175 px, and the shell clips whatever the bar
|
||||
cannot fit — on a 3-column tile among many, or one squeezed by the
|
||||
fullscreen fit, that used to take the channel filter with it. Below
|
||||
COMPACT_PX the six secondary controls hide and a single ⋯ menu offers
|
||||
the same actions, so the filter button is the last thing to go. */
|
||||
const MORE_SVG = '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/></svg>';
|
||||
const COMPACT_PX = 380; // tile width below which the full bar no longer fits
|
||||
|
||||
let moreMenuEl = null;
|
||||
const moreMenu = moduleApi.header.addMenu({
|
||||
icon: MORE_SVG,
|
||||
title: 'More',
|
||||
build(menu) {
|
||||
menu.classList.add('pt-menu');
|
||||
moreMenuEl = menu;
|
||||
rebuildMoreMenu();
|
||||
},
|
||||
});
|
||||
const moreWrap = moreMenu.button.parentElement; // the shell's .tile-dd
|
||||
const secondaryBtns = [timeBtn, minusBtn, plusBtn, flowBtn, latestBtn, clearBtn];
|
||||
|
||||
function addMoreItem(label, { on = null, onClick } = {}) {
|
||||
const item = document.createElement('button');
|
||||
item.className = 'pt-channel-item' + (on ? ' on' : '');
|
||||
if (on !== null) {
|
||||
item.setAttribute('role', 'menuitemcheckbox');
|
||||
item.setAttribute('aria-checked', String(on));
|
||||
} else {
|
||||
item.setAttribute('role', 'menuitem');
|
||||
}
|
||||
const check = document.createElement('span');
|
||||
check.className = 'check';
|
||||
check.textContent = '✓';
|
||||
const name = document.createElement('span');
|
||||
name.className = 'name';
|
||||
name.textContent = label;
|
||||
item.append(check, name);
|
||||
item.addEventListener('click', (e) => {
|
||||
e.stopPropagation(); // the rebuild detaches this item — keep the menu open
|
||||
onClick();
|
||||
});
|
||||
moreMenuEl.appendChild(item);
|
||||
}
|
||||
|
||||
function rebuildMoreMenu() {
|
||||
if (!moreMenuEl) return;
|
||||
moreMenuEl.innerHTML = '';
|
||||
const s = moduleApi.instanceSettings;
|
||||
addMoreItem('Timestamps', { on: Boolean(s.showTimes), onClick: () => timeBtn.click() });
|
||||
addMoreItem('Newest first', { on: newestFirst(), onClick: () => flowBtn.click() });
|
||||
const divider = document.createElement('div');
|
||||
divider.className = 'pt-menu-divider';
|
||||
moreMenuEl.appendChild(divider);
|
||||
addMoreItem('Smaller text', { onClick: () => bumpTextSize(-2) });
|
||||
addMoreItem('Larger text', { onClick: () => bumpTextSize(2) });
|
||||
addMoreItem('Latest', { onClick: () => { moreMenu.close(); latestBtn.click(); } });
|
||||
addMoreItem('Clear', { onClick: () => { moreMenu.close(); clearView(); } });
|
||||
}
|
||||
|
||||
let compact = null; // unknown until the first measurement
|
||||
function applyCompact(width) {
|
||||
const next = width > 0 && width < COMPACT_PX;
|
||||
if (next === compact) return;
|
||||
compact = next;
|
||||
for (const btn of secondaryBtns) btn.hidden = compact;
|
||||
moreWrap.hidden = !compact;
|
||||
if (!compact) moreMenu.close();
|
||||
}
|
||||
// the tile's own body tells the width; onResize only knows grid cells
|
||||
const sizeWatch = new ResizeObserver((entries) => {
|
||||
applyCompact(entries[0]?.contentRect.width || root.clientWidth);
|
||||
});
|
||||
sizeWatch.observe(root);
|
||||
applyCompact(root.clientWidth);
|
||||
|
||||
function applyInstanceSettings() {
|
||||
const s = moduleApi.instanceSettings;
|
||||
const size = Math.min(48, Math.max(10, Number(s.textSize) || 15));
|
||||
@@ -126,6 +202,7 @@ export default function create({ root, moduleApi }) {
|
||||
flowBtn.classList.toggle('active', up);
|
||||
flowBtn.title = up ? 'Newest first' : 'Oldest first';
|
||||
jumpBtn.textContent = (up ? '↑' : '↓') + ' New messages';
|
||||
rebuildMoreMenu(); // its checkmarks mirror the buttons
|
||||
}
|
||||
applyInstanceSettings();
|
||||
|
||||
@@ -415,6 +492,7 @@ export default function create({ root, moduleApi }) {
|
||||
},
|
||||
stop() {
|
||||
stopped = true;
|
||||
sizeWatch.disconnect();
|
||||
stream?.close();
|
||||
root.innerHTML = ''; // header controls are removed by the shell
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "prodcom-transcript",
|
||||
"name": "ProdCom",
|
||||
"version": "1.3.2",
|
||||
"version": "1.3.3",
|
||||
"proddash": ">=1.1.0",
|
||||
"description": "Live ProdCom transcript",
|
||||
"permissions": [
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
}
|
||||
[data-module="prodcom-transcript"] .pt-count[hidden] { display: none; }
|
||||
|
||||
/* narrow tile: the secondary controls fold into the ⋯ menu (client.js) */
|
||||
[data-module="prodcom-transcript"] .tile-btn[hidden],
|
||||
[data-module="prodcom-transcript"] .tile-dd[hidden] { display: none; }
|
||||
|
||||
/* ── channels menu ──
|
||||
The menu container is created and positioned by the shell (.tile-menu);
|
||||
it lives inside the tile, so [data-module] scoping still applies. */
|
||||
it hangs off the body under a [data-module] host, so scoping still applies. */
|
||||
|
||||
[data-module="prodcom-transcript"] .pt-channel-item {
|
||||
display: flex;
|
||||
|
||||
@@ -70,6 +70,7 @@ const DEFAULTS = {
|
||||
showDetail: true,
|
||||
showSeconds: true,
|
||||
leadingZeros: false,
|
||||
showLoops: false,
|
||||
clock24h: true,
|
||||
clockSeconds: true,
|
||||
clockDate: false,
|
||||
@@ -384,7 +385,12 @@ export default function create({ root, moduleApi }) {
|
||||
for (const source of state.sources) {
|
||||
for (const timer of source.timers) {
|
||||
if (keyOf(source, timer) !== solo) continue;
|
||||
return [{ id: source.id, source, items: [{ key: solo, source, timer }] }];
|
||||
// A solo video tile with looping media hidden must not sit empty:
|
||||
// it shows a quiet card instead of a countdown nobody should read.
|
||||
const shown = timer.looping && pref('showLoops') !== true
|
||||
? { ...timer, state: 'idle', remainingMs: null, elapsedMs: null, startedAt: null, asOf: null, status: { text: 'Looping', tone: 'muted' } }
|
||||
: timer;
|
||||
return [{ id: source.id, source, items: [{ key: solo, source, timer: shown }] }];
|
||||
}
|
||||
}
|
||||
// The timer this tile was added for is not offered right now. Nothing is
|
||||
@@ -398,7 +404,11 @@ export default function create({ root, moduleApi }) {
|
||||
const items = [];
|
||||
for (const timer of source.timers) {
|
||||
const key = keyOf(source, timer);
|
||||
if (!hidden.has(key)) items.push({ key, source, timer });
|
||||
if (hidden.has(key)) continue;
|
||||
// A looping background's time means nothing — the card sits out
|
||||
// while a loop plays (per tile: the "Looping videos" switch).
|
||||
if (timer.looping && pref('showLoops') !== true) continue;
|
||||
items.push({ key, source, timer });
|
||||
}
|
||||
// Every timer of a live source hidden on purpose: nothing to say.
|
||||
if (!items.length && source.timers.length) continue;
|
||||
@@ -666,7 +676,9 @@ export default function create({ root, moduleApi }) {
|
||||
card.mono = null;
|
||||
}
|
||||
text = value === null ? '—' : fmtDuration(value, { ...digits, up: timer.kind === 'countdown' });
|
||||
tone = toneFor(timer, value);
|
||||
// A shown loop never warns or overruns — it wraps at zero by design,
|
||||
// and a background flashing red every pass would cry wolf all service.
|
||||
tone = timer.looping ? (timer.state === 'running' ? 'ok' : 'muted') : toneFor(timer, value);
|
||||
statusText = timer.status?.text || defaultStatus(timer, value, tone);
|
||||
statusTone = timer.status?.tone || tone;
|
||||
detailText = timer.detail || '';
|
||||
|
||||
@@ -191,9 +191,13 @@ function createLtcListener({ device, channel, moduleDir, log, onUpdate }) {
|
||||
});
|
||||
if (!tool.ready) {
|
||||
report({ error: tool.error, detail: tool.detail });
|
||||
// A build in flight restarts us itself when it lands; anything else is
|
||||
// config-shaped and should back off hard rather than spin.
|
||||
if (tool.error !== TOOL_BUILDING) scheduleRestart(BAD_CONFIG_RETRY_MS);
|
||||
// onReady is only the FAST path (a successful build restarts us at
|
||||
// once). The slow retry must stay armed regardless: a failed build
|
||||
// never calls back, and a binary can also arrive from outside — scp'd
|
||||
// in on a machine whose toolchain can't build (AB's broken CLT).
|
||||
// Waiting on onReady alone deadlocked exactly that way in production:
|
||||
// "Capture tool building…" forever, with a working binary on disk.
|
||||
scheduleRestart(BAD_CONFIG_RETRY_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "propresenter-timers",
|
||||
"name": "Timers",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"proddash": ">=1.4.0",
|
||||
"description": "Timers, Clocks, and LTC From configured Modules",
|
||||
"provides": [
|
||||
@@ -161,6 +161,12 @@
|
||||
"default": false,
|
||||
"group": "Show"
|
||||
},
|
||||
"showLoops": {
|
||||
"type": "switch",
|
||||
"label": "Looping videos",
|
||||
"default": false,
|
||||
"group": "Show"
|
||||
},
|
||||
"showHeadings": {
|
||||
"type": "switch",
|
||||
"label": "Source headings",
|
||||
|
||||
@@ -255,6 +255,21 @@ function createProPresenterSource({ config, log }) {
|
||||
/** uuid → phase tracker: whole-second reports → one stable anchor (see phase.js). */
|
||||
const phases = new Map();
|
||||
|
||||
/* The video countdown — time left on what the presentation layer is
|
||||
playing, from the transport routes (verified live on ProPresenter 21.4):
|
||||
GET /v1/transport/presentation/current → { is_playing, uuid, name,
|
||||
artist, audio_only, duration } (no looping flag exists — inferred)
|
||||
GET /v1/transport/presentation/time → bare seconds, sub-second
|
||||
float — better than /v1/timer/video_countdown's whole-second string,
|
||||
so no quantization phase lock is needed, only an anchor hold. */
|
||||
let media = null; // { uuid, name, duration, playing } from the slow lane
|
||||
let mediaAt = 0;
|
||||
let transportOk = null; // null until the first answer; false = no transport route (older ProPresenter)
|
||||
let videoPos = null; // playback position in seconds (float)
|
||||
let videoAsOf = 0; // server ms when videoPos was measured
|
||||
let videoAnchor = null; // published { remainingMs, asOf }, held while it predicts the measurements
|
||||
let loopingUuid = ''; // media seen wrapping — a looping background
|
||||
|
||||
function url(target) {
|
||||
const built = new URL(`http://${host}:${port}${target}`);
|
||||
if (password) built.searchParams.set('password', password);
|
||||
@@ -390,6 +405,121 @@ function createProPresenterSource({ config, log }) {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the presentation transport layer. Failures here only drop the
|
||||
* video card, never the whole source — the timers must survive a
|
||||
* ProPresenter build with transport quirks.
|
||||
*/
|
||||
async function pollVideo() {
|
||||
if (tick % SLOW_EVERY === 1) {
|
||||
try {
|
||||
const raw = await requestJson('/v1/transport/presentation/current');
|
||||
const uuid = String(raw?.uuid || '');
|
||||
if (!media || media.uuid !== uuid) {
|
||||
if (media && media.uuid !== uuid) loopingUuid = '';
|
||||
videoPos = null;
|
||||
videoAnchor = null;
|
||||
}
|
||||
media = uuid ? {
|
||||
uuid,
|
||||
name: String(raw.name || ''),
|
||||
duration: Number(raw.duration) > 0 ? Number(raw.duration) : 0,
|
||||
playing: Boolean(raw.is_playing),
|
||||
} : null;
|
||||
mediaAt = Date.now();
|
||||
transportOk = true;
|
||||
} catch (err) {
|
||||
media = null; // the slow lane retries in ~2 s
|
||||
if (err && err.status === 404) transportOk = false; // no transport route on this build
|
||||
}
|
||||
}
|
||||
if (!media) {
|
||||
videoPos = null;
|
||||
videoAnchor = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const pos = Number(await requestJson('/v1/transport/presentation/time'));
|
||||
if (Number.isFinite(pos) && pos >= 0) {
|
||||
// Same media, position jumped back by more than a stutter: it
|
||||
// wrapped — a looping background. Sticks until the media changes.
|
||||
// (A video manually re-triggered from the start looks the same and
|
||||
// is mislabeled for that pass; loops re-wrap, replays don't recur.)
|
||||
if (videoPos !== null && media.playing && videoPos - pos > 1.5) loopingUuid = media.uuid;
|
||||
videoPos = pos;
|
||||
videoAsOf = Date.now();
|
||||
} else {
|
||||
videoPos = null;
|
||||
}
|
||||
} catch {
|
||||
videoPos = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The video countdown as one synthetic timer card (id 'video'). The card
|
||||
persists as an idle "—" between videos — a wall tile must not appear
|
||||
and vanish with the media — and is only absent entirely on a
|
||||
ProPresenter without transport routes. */
|
||||
function videoTimer() {
|
||||
if (transportOk !== true) return null;
|
||||
if (!media) {
|
||||
return {
|
||||
id: 'video',
|
||||
label: 'Video',
|
||||
kind: 'countdown',
|
||||
state: 'idle',
|
||||
asOf: mediaAt || updatedAt,
|
||||
startedAt: null,
|
||||
elapsedMs: null,
|
||||
remainingMs: null,
|
||||
targetMs: null,
|
||||
looping: false,
|
||||
status: null,
|
||||
detail: '',
|
||||
};
|
||||
}
|
||||
const playing = media.playing;
|
||||
const dur = media.duration > 0 ? media.duration * 1000 : null;
|
||||
let remainingMs = null;
|
||||
let asOf = videoAsOf || mediaAt;
|
||||
if (videoPos !== null && dur !== null) {
|
||||
remainingMs = Math.max(0, dur - videoPos * 1000);
|
||||
if (playing) {
|
||||
// Hold the published anchor while it still predicts the measured
|
||||
// position: the tiles extrapolate locally, and a fresh anchor per
|
||||
// poll would broadcast a frame every 500 ms for nothing.
|
||||
const p = videoAnchor;
|
||||
const predicted = p ? p.remainingMs - (videoAsOf - p.asOf) : NaN;
|
||||
if (p && Math.abs(predicted - remainingMs) < 120) {
|
||||
remainingMs = p.remainingMs;
|
||||
asOf = p.asOf;
|
||||
} else {
|
||||
videoAnchor = { remainingMs, asOf };
|
||||
}
|
||||
} else {
|
||||
videoAnchor = null;
|
||||
}
|
||||
} else {
|
||||
videoAnchor = null;
|
||||
}
|
||||
const looping = media.uuid === loopingUuid;
|
||||
return {
|
||||
id: 'video',
|
||||
label: 'Video',
|
||||
kind: 'countdown',
|
||||
state: playing ? 'running' : videoPos > 0 ? 'paused' : 'idle',
|
||||
asOf,
|
||||
startedAt: null,
|
||||
elapsedMs: remainingMs !== null && dur !== null ? dur - remainingMs : null,
|
||||
remainingMs,
|
||||
targetMs: dur,
|
||||
looping,
|
||||
status: looping ? { text: playing ? 'Looping' : 'Paused', tone: 'muted' } : null,
|
||||
// The media name, without the file extension nobody reads on a wall.
|
||||
detail: media.name.replace(/\.(mp4|mov|m4v|mxf|avi|mkv|mp3|wav|aiff?)$/i, ''),
|
||||
};
|
||||
}
|
||||
|
||||
function status() {
|
||||
if (!configured) return 'error';
|
||||
if (reachable) return 'ok';
|
||||
@@ -429,6 +559,9 @@ function createProPresenterSource({ config, log }) {
|
||||
const currentTimes = await requestJson('/v1/timers/current');
|
||||
updatedAt = Date.now();
|
||||
timers = mergeTimers(currentTimes, updatedAt);
|
||||
await pollVideo();
|
||||
const video = videoTimer();
|
||||
if (video) timers.push(video);
|
||||
reachable = true;
|
||||
lastError = '';
|
||||
} catch (err) {
|
||||
@@ -970,6 +1103,8 @@ const GEAR = {
|
||||
all: { instanceSchema: FULL_SCHEMA, instanceGroups: FULL_GROUPS },
|
||||
/** One ProPresenter or module timer: its elements, and the tone its digits take per state. */
|
||||
timer: gearOf([...TIMER_ELEMENTS, ...COLOURS], OPEN_COLOURS),
|
||||
/** The video countdown: a timer card, plus whether looping media counts. */
|
||||
video: gearOf([...TIMER_ELEMENTS, 'showLoops', ...COLOURS], OPEN_COLOURS),
|
||||
/** The timecode: running, no signal (warning) and stopped (idle) — it never overruns, and frames are frames. */
|
||||
ltc: gearOf(['showNames', 'showStatus', 'runningColor', 'warningColor', 'idleColor'], OPEN_COLOURS),
|
||||
/** The time of day: plain digits, so only how they read. */
|
||||
@@ -983,6 +1118,7 @@ function gearFor(source, timer) {
|
||||
if (source.kind === 'ltc') return GEAR.ltc;
|
||||
if (source.kind === 'clock') return GEAR.clock;
|
||||
if (timer.kind === 'clock') return GEAR.providerClock;
|
||||
if (source.id === 'propresenter' && timer.id === 'video') return GEAR.video;
|
||||
return GEAR.timer;
|
||||
}
|
||||
|
||||
@@ -1191,6 +1327,7 @@ module.exports = {
|
||||
for (const t of src.timers) {
|
||||
const description = src.kind === 'ltc' ? 'The incoming LTC timecode on its own'
|
||||
: src.kind === 'clock' ? 'The time of day on its own'
|
||||
: src.id === 'propresenter' && t.id === 'video' ? 'Time left on the video ProPresenter is playing'
|
||||
: `This ${src.label} ${KIND_WORD[t.kind] || 'timer'} on its own`;
|
||||
// Layouts from before 1.3.0 hold 'timer:<uuid>' / 'ltc' — the same tiles.
|
||||
const aliases = src.id === 'propresenter' ? [`timer:${t.id}`] : src.kind === 'ltc' ? ['ltc'] : [];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "spl-meter",
|
||||
"name": "SPL Meter",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.3",
|
||||
"proddash": ">=1.5.0",
|
||||
"description": "Calibrated sound level, Leq and RTA from an audio input on this machine",
|
||||
"permissions": [
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const { createSplListener } = require('./spl-listener');
|
||||
const { createSplListener, ensureCaptureBinary } = require('./spl-listener');
|
||||
|
||||
/** Reference level of a sound level calibrator. Effectively always 94 dB. */
|
||||
const CALIBRATOR_DB = 94;
|
||||
@@ -114,11 +114,19 @@ module.exports = {
|
||||
error: '',
|
||||
streams: new Set(),
|
||||
silentSince: null,
|
||||
toolMissing: '',
|
||||
listener: null,
|
||||
lastSent: '',
|
||||
pinger: null,
|
||||
};
|
||||
|
||||
// Before anything else: the device picker shells out to this tool, so a
|
||||
// machine that installed the module from the catalog (source only — the
|
||||
// binary is gitignored) needs the build kicked off here. Waiting for a
|
||||
// listener would never happen: no tool means no device list, and no
|
||||
// device means no listener.
|
||||
state.toolMissing = ensureCaptureBinary({ moduleDir, log });
|
||||
|
||||
if (!config.enabled) {
|
||||
state.error = 'Sound level measurement is off — turn it on in ProdDash settings';
|
||||
return { stop() { teardown(); }, health: () => ({ status: 'error', message: state.error }) };
|
||||
@@ -177,6 +185,9 @@ module.exports = {
|
||||
return {
|
||||
stop() { teardown(); },
|
||||
health() {
|
||||
if (state.toolMissing && !fsExists(path.join(moduleDir, 'spl-capture'))) {
|
||||
return { status: 'error', message: state.toolMissing };
|
||||
}
|
||||
if (state.error) return { status: 'error', message: state.error };
|
||||
if (!state.frame) return { status: 'connecting', message: 'waiting for the first reading' };
|
||||
const quiet = silentMs();
|
||||
@@ -300,6 +311,13 @@ module.exports = {
|
||||
/** Device list for the admin page. Runs the capture tool's --list,
|
||||
which is the only thing that knows what CoreAudio can see. */
|
||||
'GET /devices': async (req, res) => {
|
||||
const missing = ensureCaptureBinary({ moduleDir: __dirname, log });
|
||||
if (missing) {
|
||||
if (state) state.toolMissing = missing;
|
||||
log(`device list unavailable — ${missing}`);
|
||||
json(res, 200, { options: [] });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const devices = await listDevices();
|
||||
json(res, 200, {
|
||||
@@ -438,6 +456,10 @@ function listDevices() {
|
||||
});
|
||||
}
|
||||
|
||||
function fsExists(p) {
|
||||
try { return require('fs').existsSync(p); } catch { return false; }
|
||||
}
|
||||
|
||||
function json(res, code, body) {
|
||||
const text = JSON.stringify(body);
|
||||
res.writeHead(code, {
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
* module's ltc-capture. It normally arrives already built — compiled beside
|
||||
* the app, or copied from any Mac of the same architecture. When it is
|
||||
* missing this will build it, but in the background and never on the event
|
||||
* loop: see ensureBinary for what that cost the first time it was wrong.
|
||||
* loop, and from module scope so the device picker can trigger it too — see
|
||||
* ensureCaptureBinary for what both of those cost the first time round.
|
||||
*
|
||||
* The same macOS gotcha applies as for LTC, and is worth repeating because
|
||||
* it costs an afternoon every time: a ProdDash launched over SSH or from a
|
||||
@@ -30,6 +31,74 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
const BUILD_HELP = 'Sound level capture tool missing — build it on any Apple Silicon Mac with '
|
||||
+ '`swiftc -O -o modules/spl-meter/spl-capture modules/spl-meter/spl-capture.swift` '
|
||||
+ 'and copy it next to spl-capture.swift';
|
||||
const BUILDING = 'Building the capture tool — this takes a minute or two';
|
||||
|
||||
/**
|
||||
* Build the capture tool if it is missing, WITHOUT blocking, and shared by
|
||||
* everything that needs it.
|
||||
*
|
||||
* This lives at module scope rather than inside a listener because of a trap
|
||||
* the first version walked into: the admin page's device picker runs the tool
|
||||
* with --list, but the build only ran when a listener started, and a listener
|
||||
* only starts once a device has been picked. On a machine that got the module
|
||||
* from the catalog — source only, the binary being gitignored — the picker
|
||||
* was empty, and nothing would ever fill it.
|
||||
*
|
||||
* It also must never block. It was a spawnSync once, copied from the LTC
|
||||
* listener where the source is a third the size and builds in seconds. Here
|
||||
* it took nearly two minutes on the production Mac and held the Node event
|
||||
* loop for all of it, freezing every other module, then did it again on the
|
||||
* next retry.
|
||||
*
|
||||
* The binary should normally already be there: built beside the app, or
|
||||
* copied from any Mac of the same architecture. This is the fallback.
|
||||
*
|
||||
* @returns {string} '' when the tool is ready, otherwise what to say.
|
||||
*/
|
||||
let building = false;
|
||||
let buildFailed = false;
|
||||
|
||||
function ensureCaptureBinary({ moduleDir, log, onReady }) {
|
||||
const bin = path.join(moduleDir, 'spl-capture');
|
||||
if (fs.existsSync(bin)) return '';
|
||||
const src = bin + '.swift';
|
||||
if (!fs.existsSync(src)) return 'spl-capture.swift is missing from the module folder';
|
||||
if (building) return BUILDING;
|
||||
if (buildFailed) return BUILD_HELP;
|
||||
|
||||
building = true;
|
||||
log('spl-capture binary missing — building it in the background');
|
||||
const build = spawn('swiftc', ['-O', '-o', bin, src], { stdio: ['ignore', 'ignore', 'pipe'] });
|
||||
let buildErr = '';
|
||||
build.stderr.setEncoding('utf8');
|
||||
build.stderr.on('data', (t) => { buildErr = (buildErr + t).slice(-800); });
|
||||
const giveUp = setTimeout(() => {
|
||||
try { build.kill('SIGKILL'); } catch { /* already gone */ }
|
||||
}, 300000);
|
||||
build.on('error', (err) => {
|
||||
clearTimeout(giveUp);
|
||||
building = false; buildFailed = true;
|
||||
log(`swiftc could not be run: ${err.message}`);
|
||||
});
|
||||
build.on('exit', (code) => {
|
||||
clearTimeout(giveUp);
|
||||
building = false;
|
||||
if (code === 0 && fs.existsSync(bin)) {
|
||||
log('spl-capture built');
|
||||
buildFailed = false;
|
||||
if (typeof onReady === 'function') onReady();
|
||||
return;
|
||||
}
|
||||
buildFailed = true;
|
||||
log(`spl-capture build failed (exit ${code})`
|
||||
+ (buildErr ? `: ${buildErr.trim().split('\n').pop()}` : ''));
|
||||
});
|
||||
return BUILDING;
|
||||
}
|
||||
|
||||
const RESTART_MS = 5000;
|
||||
/** An immediate exit is config-shaped (bad device, channel out of range) —
|
||||
retrying every 5 s would only fill the log with the same sentence. */
|
||||
@@ -53,64 +122,13 @@ function createSplListener(opts) {
|
||||
let stallTimer = null;
|
||||
let startedAt = 0;
|
||||
let meta = null;
|
||||
let building = false;
|
||||
let buildFailed = false;
|
||||
let lastFrameWall = 0;
|
||||
|
||||
const BUILD_HELP = 'Sound level capture tool missing — build it on any Apple Silicon Mac with '
|
||||
+ '`swiftc -O -o modules/spl-meter/spl-capture modules/spl-meter/spl-capture.swift` '
|
||||
+ 'and copy it next to spl-capture.swift';
|
||||
|
||||
/**
|
||||
* Build the capture tool if it is missing, WITHOUT blocking.
|
||||
*
|
||||
* This used to be a spawnSync, copied from the LTC listener where the
|
||||
* source is a third the size and builds in a few seconds. Here it took
|
||||
* nearly two minutes on the production Mac and froze the entire ProdDash
|
||||
* server for every second of it — one module's optional helper took the
|
||||
* whole dashboard down, then did it again on every retry. Nothing that
|
||||
* runs while a service might be on is allowed to hold the event loop.
|
||||
*
|
||||
* The build is a fallback for a module installed from the catalog on a
|
||||
* machine with a Swift toolchain. The normal path is a binary built
|
||||
* alongside the app, or copied from any same-architecture Mac.
|
||||
*
|
||||
* @returns {string} '' when the binary is ready, otherwise what to say.
|
||||
*/
|
||||
/** '' when the tool is ready, otherwise what to say about it. */
|
||||
function ensureBinary() {
|
||||
if (fs.existsSync(bin)) return '';
|
||||
const src = bin + '.swift';
|
||||
if (!fs.existsSync(src)) return 'spl-capture.swift is missing from the module folder';
|
||||
if (building) return 'Building the capture tool — this takes a minute or two';
|
||||
if (buildFailed) return BUILD_HELP;
|
||||
|
||||
building = true;
|
||||
log('spl-capture binary missing — building it in the background');
|
||||
const build = spawn('swiftc', ['-O', '-o', bin, src], { stdio: ['ignore', 'ignore', 'pipe'] });
|
||||
let buildErr = '';
|
||||
build.stderr.setEncoding('utf8');
|
||||
build.stderr.on('data', (t) => { buildErr = (buildErr + t).slice(-800); });
|
||||
const giveUp = setTimeout(() => {
|
||||
try { build.kill('SIGKILL'); } catch { /* already gone */ }
|
||||
}, 300000);
|
||||
build.on('error', (err) => {
|
||||
clearTimeout(giveUp);
|
||||
building = false; buildFailed = true;
|
||||
log(`swiftc could not be run: ${err.message}`);
|
||||
});
|
||||
build.on('exit', (code) => {
|
||||
clearTimeout(giveUp);
|
||||
building = false;
|
||||
if (code === 0 && fs.existsSync(bin)) {
|
||||
log('spl-capture built');
|
||||
buildFailed = false;
|
||||
return ensureCaptureBinary({ moduleDir, log, onReady() {
|
||||
if (!stopped) { clearTimeout(restartTimer); restartTimer = null; start(); }
|
||||
return;
|
||||
}
|
||||
buildFailed = true;
|
||||
log(`spl-capture build failed (exit ${code})` + (buildErr ? `: ${buildErr.trim().split('\n').pop()}` : ''));
|
||||
});
|
||||
return 'Building the capture tool — this takes a minute or two';
|
||||
} });
|
||||
}
|
||||
|
||||
function scheduleRestart(ms) {
|
||||
@@ -135,9 +153,13 @@ function createSplListener(opts) {
|
||||
const missing = ensureBinary();
|
||||
if (missing) {
|
||||
onUpdate({ error: missing });
|
||||
// A build in flight calls start() itself when it lands; anything else
|
||||
// is config-shaped and should back off hard rather than spin.
|
||||
if (!building) scheduleRestart(BAD_CONFIG_RETRY_MS);
|
||||
// onReady is only the FAST path (a successful build restarts us at
|
||||
// once). The slow retry must stay armed regardless: a failed build
|
||||
// never calls back, and a binary can also arrive from outside — scp'd
|
||||
// in on a machine whose toolchain can't build (AB's broken CLT).
|
||||
// Waiting on onReady alone deadlocked exactly that way in the Timers
|
||||
// module: "building…" forever, with a working binary on disk.
|
||||
scheduleRestart(BAD_CONFIG_RETRY_MS);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,4 +258,4 @@ function createSplListener(opts) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { createSplListener };
|
||||
module.exports = { createSplListener, ensureCaptureBinary };
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "proddash",
|
||||
"version": "1.9.2",
|
||||
"version": "1.9.4",
|
||||
"private": true,
|
||||
"description": "Modular production dashboard for Waters Church \u2014 zero-dependency Node server + vanilla client",
|
||||
"license": "UNLICENSED",
|
||||
|
||||
+41
-10
@@ -639,8 +639,10 @@ function buildTile(tile) {
|
||||
el.addEventListener('pointermove', (ev) => {
|
||||
if (!headIsOff(tile)) return;
|
||||
// Mid-drag the tile moves under the pointer, and mid-resize the edges do
|
||||
// — neither is a moment to take the bar away.
|
||||
// — neither is a moment to take the bar away. Nor is an open header
|
||||
// menu, which hangs below the bar and is about to be pointed at.
|
||||
if (el.classList.contains('dragging') || el.classList.contains('resizing')) return;
|
||||
if (el.classList.contains('menu-open')) return;
|
||||
const y = ev.clientY - el.getBoundingClientRect().top;
|
||||
const shown = el.classList.contains('head-peek');
|
||||
// It takes less to hold the bar open than to open it, so a bar that
|
||||
@@ -651,6 +653,7 @@ function buildTile(tile) {
|
||||
|
||||
el.addEventListener('pointerleave', () => {
|
||||
if (el.classList.contains('dragging') || el.classList.contains('resizing')) return;
|
||||
if (el.classList.contains('menu-open')) return; // the pointer is on its way to the menu
|
||||
el.classList.remove('head-peek');
|
||||
});
|
||||
|
||||
@@ -658,7 +661,7 @@ function buildTile(tile) {
|
||||
applyHeadState(tile, el);
|
||||
grid.appendChild(el);
|
||||
|
||||
const entry = { el, body, dot, titleEl: title, controls, instance: null };
|
||||
const entry = { el, body, dot, titleEl: title, controls, instance: null, openMenus: new Set() };
|
||||
tileEls.set(tile.id, entry);
|
||||
applyRect(tile);
|
||||
|
||||
@@ -1416,34 +1419,60 @@ function buildModuleApi(tile, man, entry) {
|
||||
menu.className = 'tile-menu';
|
||||
menu.hidden = true;
|
||||
|
||||
/* The menu lives on the body, not in the bar. A folded-away bar
|
||||
(auto-hide, fullscreen) carries a backdrop-filter and a transform,
|
||||
and either one makes a fixed-positioned descendant position
|
||||
itself against the bar instead of the viewport — the menu landed
|
||||
a screen-height below its button, inside the tile's overflow, and
|
||||
never showed. Its host carries the tile's data-module so the
|
||||
module's scoped CSS still reaches the items. */
|
||||
const host = document.createElement('div');
|
||||
host.className = 'tile-menu-host';
|
||||
if (man) host.dataset.module = man.id;
|
||||
host.appendChild(menu);
|
||||
|
||||
const setOpen = (on) => {
|
||||
if (on === !menu.hidden) return;
|
||||
menu.hidden = !on;
|
||||
btn.classList.toggle('is-open', on);
|
||||
if (on) entry.openMenus.add(menu);
|
||||
else entry.openMenus.delete(menu);
|
||||
// an open menu holds a folded-away bar out; when the last one
|
||||
// closes with the pointer elsewhere, the bar goes back
|
||||
entry.el.classList.toggle('menu-open', entry.openMenus.size > 0);
|
||||
if (!on && !entry.openMenus.size && !entry.el.matches(':hover')) entry.el.classList.remove('head-peek');
|
||||
};
|
||||
const open = () => {
|
||||
if (typeof build === 'function') {
|
||||
menu.innerHTML = '';
|
||||
build(menu);
|
||||
}
|
||||
menu.hidden = false;
|
||||
// fixed positioning (escapes the tile's overflow): under the
|
||||
// button, right-aligned, clamped to the viewport
|
||||
setOpen(true);
|
||||
// under the button, right-aligned, kept whole inside the viewport
|
||||
const r = btn.getBoundingClientRect();
|
||||
menu.style.top = Math.min(r.bottom + 6, window.innerHeight - 80) + 'px';
|
||||
menu.style.left = '0px';
|
||||
menu.style.top = '0px';
|
||||
const w = menu.offsetWidth;
|
||||
const h = menu.offsetHeight;
|
||||
menu.style.top = Math.max(8, Math.min(r.bottom + 6, window.innerHeight - h - 8)) + 'px';
|
||||
menu.style.left = Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8)) + 'px';
|
||||
};
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (menu.hidden) open();
|
||||
else menu.hidden = true;
|
||||
else setOpen(false);
|
||||
});
|
||||
const onDocClick = (e) => {
|
||||
if (!menu.hidden && !menu.contains(e.target) && !btn.contains(e.target)) menu.hidden = true;
|
||||
if (!menu.hidden && !menu.contains(e.target) && !btn.contains(e.target)) setOpen(false);
|
||||
};
|
||||
document.addEventListener('click', onDocClick);
|
||||
docListeners.add(onDocClick);
|
||||
|
||||
wrap.append(btn, menu);
|
||||
wrap.append(btn);
|
||||
entry.controls.appendChild(wrap);
|
||||
document.body.appendChild(host);
|
||||
headerEls.add(wrap);
|
||||
headerEls.add(host);
|
||||
return {
|
||||
button: btn,
|
||||
menu,
|
||||
@@ -1451,7 +1480,7 @@ function buildModuleApi(tile, man, entry) {
|
||||
btn.textContent = text;
|
||||
},
|
||||
close() {
|
||||
menu.hidden = true;
|
||||
setOpen(false);
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -1463,6 +1492,8 @@ function buildModuleApi(tile, man, entry) {
|
||||
for (const handle of [...sseHandles]) handle.close();
|
||||
for (const el of headerEls) el.remove();
|
||||
headerEls.clear();
|
||||
entry.openMenus.clear();
|
||||
entry.el.classList.remove('menu-open');
|
||||
for (const fn of docListeners) document.removeEventListener('click', fn);
|
||||
docListeners.clear();
|
||||
},
|
||||
|
||||
+3
-2
@@ -445,8 +445,9 @@ body.menu-hidden #topbar {
|
||||
}
|
||||
.tile-dd { position: relative; display: inline-flex; }
|
||||
|
||||
/* a module header menu — fixed-positioned by the shell so the tile's
|
||||
overflow:hidden can't clip it */
|
||||
/* a module header menu — hosted on the body (shell.js addMenu) so neither
|
||||
the tile's overflow nor a folded-away bar's backdrop-filter can touch it */
|
||||
.tile-menu-host { display: contents; }
|
||||
.tile-menu {
|
||||
position: fixed;
|
||||
z-index: 70;
|
||||
|
||||
@@ -152,10 +152,39 @@ const server = http.createServer((req, res) => {
|
||||
if (p === '/v1/timers') return sendJson(res, TIMERS.filter((t) => !DROP.has(t.id.uuid)));
|
||||
if (p === '/v1/timers/current') return sendJson(res, currentTimes().filter((t) => !DROP.has(t.id.uuid)));
|
||||
if (p === '/v1/timecode/status' && !NO_LTC) return sendJson(res, timecodeStatus());
|
||||
if (p === '/v1/transport/presentation/current') return sendJson(res, transport().current);
|
||||
if (p === '/v1/transport/presentation/time') return sendJson(res, transport().time);
|
||||
|
||||
sendJson(res, { error: 'not found' }, 404);
|
||||
});
|
||||
|
||||
/* ── transport (video countdown): a 4-minute cycle ─────────────────
|
||||
0–60 s "Sermon Bumper.mp4" (3:00) playing
|
||||
60–75 s the same bumper paused at 1:00
|
||||
75–90 s playing again
|
||||
90–120 s nothing loaded
|
||||
120–240 s "Autumn Loop.mp4" (0:15) playing and wrapping — the module
|
||||
must infer looping from the position jumping back.
|
||||
Shapes match ProPresenter 21.4 live: `current` = { is_playing, uuid,
|
||||
name, artist, audio_only, duration }, `time` = bare seconds (float). */
|
||||
function transport() {
|
||||
const phase = ((Date.now() - startedAt) / 1000) % 240;
|
||||
const none = { current: { is_playing: false, uuid: '', name: '', artist: '', audio_only: false, duration: 0 }, time: -1 };
|
||||
if (phase < 90) {
|
||||
const playing = phase < 60 || phase >= 75;
|
||||
const pos = Math.min(phase, 60) + (phase >= 75 ? phase - 75 : 0);
|
||||
return {
|
||||
current: { is_playing: playing, uuid: 'MEDIA-BUMPER', name: 'Sermon Bumper.mp4', artist: '', audio_only: false, duration: 180 },
|
||||
time: Math.round(pos * 10) / 10,
|
||||
};
|
||||
}
|
||||
if (phase < 120) return none;
|
||||
return {
|
||||
current: { is_playing: true, uuid: 'MEDIA-LOOP', name: 'Autumn Loop.mp4', artist: '', audio_only: false, duration: 15 },
|
||||
time: Math.round(((phase - 120) % 15) * 10) / 10,
|
||||
};
|
||||
}
|
||||
|
||||
/* ── stage-display websocket (/stagedisplay) ─────────────────────── */
|
||||
|
||||
const cryptoMod = require('crypto');
|
||||
|
||||
Reference in New Issue
Block a user