Files
feedBack/plugins/tuner/visualization/toilet-tuner.js
af2949677a rename: slopsmith → feedBack, byron → got-feedBack (#537)
* Update GitHub repo references from feedback* to feedBack*

* rename: slopsmith -> feedBack, byron -> got-feedBack

Renames across the entire codebase:
- slopsmith/Slopsmith/SLOPSMITH/SlopSmith -> feedBack/FeedBack/FEEDBACK/FeedBack
- byron/Byron/Byrongamatos -> got-feedBack/got-feedBack/got-feedBack
- /home/byron/ -> /opt/got-feedBack/
- byron@ougsoft.com -> hi@got-feedBack.org
- github.com/byrongamatos/ -> github.com/got-feedback/
- com.byron. -> com.got-feedback.
- SLOPSMITH_ env vars -> FEEDBACK_ with backward-compat fallback
- Protocol/storage strings migrated with read-old/write-new pattern
- window.slopsmith JS API -> window.feedBack (canonical) + backward-compat alias

Refs: #rename-slopsmith

* rename: complete regen against current main + fix backward-compat alias

Regenerated the slopsmith->feedBack / byron->got-feedBack rename on top of
current main (3 commits had landed since the branch: #572/#554/#574),
resolving the four content conflicts in favour of main's newer content
(autoplay/auto-exit, accuracy-badge, Virtuoso re-home, feedpak badge).

Completion fixes on top of the mechanical rename:
- Re-apply rename to post-branch content the original rename never saw:
  window.slopsmith(.Tour) consumers in lessons.js / notifications.js /
  onboarding-tour.js, and the matching JS + python tests (autoplay_exit,
  progression_*, test_feedpak_extension FEEDBACK_* env vars). The test env
  vars now match server.py (which reads FEEDBACK_SYNC_STARTUP /
  FEEDBACK_SKIP_STARTUP_TASKS), so the sync-startup test exercises the real
  path again.
- Restore the window.slopsmith backward-compat alias dropped during conflict
  resolution, and move the bus aliases to AFTER the _feedBackExisting merge
  block so they reference the fully-assembled object (also fixes the
  loop_api.test.js API-surface regex, which the original PR latently broke).
- Drop the stray empty data/web_library.db (runtime DB lives in CONFIG_DIR)
  and gitignore it.
- Fix stale tone-source test: feed[dB]ack -> fee[dB]ack to match shipped
  source labels.

Verified locally (org CI billing-blocked): JS 819/819 pass; pytest 1669
passed / 1683 collected with 0 import errors; zero residual slopsmith/byron
except the two intentional window.slopsmith aliases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* rename: implement advertised backward-compat + prune dead community plugins

Address gaps where PR #537's "Backward compatibility" section was advertised
but not implemented, and clean up the community plugin list.

Env vars (FEEDBACK_* canonical, legacy SLOPSMITH_* honoured):
- New lib/env_compat.py (getenv_compat / env_flag_compat) + tests. server.py
  (_env_flag + all FEEDBACK_* reads), diagnostics_hardware, gp2midi and
  tailwind_rebuild now resolve the legacy alias, so existing SLOPSMITH_UI /
  SLOPSMITH_PLUGINS_DIR / etc. deployments keep working.
- Fix the rename collapsing plugins/__init__.py and minigames/routes.py from
  `FEEDBACK_PLUGINS_DIR or SLOPSMITH_PLUGINS_DIR` into a redundant
  `FEEDBACK_ or FEEDBACK_` (the fallback was silently lost).

Storage (app.js update-channel):
- Read feedBack-update-channel, fall back to legacy slopsmith-update-channel,
  and clear the legacy key on write — so a user's update-channel preference
  survives the rename instead of resetting to "stable".

Community plugin list (README): the rename rewrote third-party repo URLs we
don't own. Probed every one; their owners never renamed, so:
- Restore the 13 live community plugins to their real slopsmith-* names.
- Prune 6 that are 404 to the public (topkoa splitscreen/stems, OmikronApex
  tuner, Jafz2001 nam-rig-builder, DeathlySin song-preview, Erikcb91 shuffle).
- Fix a pre-existing Guitar Theory clone-command typo (nam-tone -> guitar-theory).

Verified: env_compat 7/7, JS 819/819, pytest 1690 collected / 0 import errors,
rename-sensitive + startup suites green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: byrongamatos <xasiklas@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 11:03:01 +02:00

146 lines
7.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Toilet Tuner visualization for the FeedBack tuner plugin.
*
* Bathroom scene background; plunger slides left/right over the bowl based on
* cents deviation; dips into bowl when in tune (±2 cents); wall calendar shows
* the detected note name.
*
* Contract: window['_tunerViz_toilet-tuner'](container) → { update(note, cents, freq), destroy() }
* - note: string | null (null = no signal)
* - cents: number (deviation from target, −50…+50)
* - freq: number (detected frequency in Hz)
*/
(function () {
'use strict';
// ── Constants ─────────────────────────────────────────────────────
var _TUNER_TT_IN_TUNE_THR = 2;
var _TUNER_TT_ASSET_BASE = '/api/plugins/tuner/viz-assets/';
// Positions derived from Bathroom.svg 0-1024 coordinate space.
// Bowl ellipse centre: x=512 (50%), y=673 (65.7%), semi-major=99 (9.7%).
// Plunger SVG is 29.8mm wide x 69.5mm tall (ratio 1:2.33).
// At width=8%, rendered height = 8% x 2.33 = 18.6%.
// Raised: cup bottom at ~62% (above bowl top) → top = 62 - 18.6 = 43%.
// Dipped: cup inside bowl → top = 52%.
var _TUNER_TT_LEFT_PCT = 15; // x at cents=-50
var _TUNER_TT_RIGHT_PCT = 85; // x at cents=+50
var _TUNER_TT_CENTRE_PCT = 50; // x at cents=0 (bowl centre)
var _TUNER_TT_RAISED_TOP = 41; // plunger top % when hovering above bowl
var _TUNER_TT_DIPPED_TOP = 52; // plunger top % when cup inside bowl
window['_tunerViz_toilet-tuner'] = function (container) {
'use strict';
// ── Root panel — 1:1 square, full width ───────────────────────
// padding-bottom: 100% trick: reliable square even with all-absolute children.
// Background loaded as CSS background-image: bypasses browser intrinsic-size
// limits that cause SVGs with huge explicit width/height to fail as <img>.
var panel = document.createElement('div');
panel.className = 'relative w-full overflow-hidden select-none';
panel.style.height = '0';
panel.style.paddingBottom = '100%';
panel.style.backgroundImage = "url('" + _TUNER_TT_ASSET_BASE + "Bathroom.svg')";
panel.style.backgroundSize = 'cover';
panel.style.backgroundPosition = 'center';
// ── Note label (over calendar on wall) ────────────────────────
var noteEl = document.createElement('div');
noteEl.className = 'absolute font-bold pointer-events-none';
noteEl.style.right = '17.25%';
noteEl.style.top = '17%';
noteEl.style.fontSize = '1.6rem';
noteEl.style.color = '#303332';
noteEl.style.textAlign = 'center';
noteEl.style.transform = 'translateX(50%)';
noteEl.textContent = '–';
panel.appendChild(noteEl);
// ── Plunger ───────────────────────────────────────────────────
var plungerEl = document.createElement('img');
plungerEl.src = _TUNER_TT_ASSET_BASE + 'Plunger.svg';
plungerEl.className = 'absolute pointer-events-none';
plungerEl.style.width = '10%';
plungerEl.style.left = _TUNER_TT_CENTRE_PCT + '%';
plungerEl.style.top = _TUNER_TT_RAISED_TOP + '%';
plungerEl.style.transform = 'translateX(-50%)';
panel.appendChild(plungerEl);
// ── Toilet bowl overlay (hides plunger cup when dipped) ───────
var bowlEl = document.createElement('img');
bowlEl.src = _TUNER_TT_ASSET_BASE + 'Toiletbowl.svg';
bowlEl.className = 'absolute pointer-events-none';
// Bowl overlay aligned via shared path124 (lower bowl body) registration:
// Bathroom path102 ellipse centre: x=50%, y=65.8%; width=19.4% of panel.
// Toiletbowl path102 same ellipse: centre at y=0 (top of viewBox), rx=35.4% of viewBox.
// → width = 19.4% / 70.7% = 27.4%; left = 50% - 27.4%/2 = 36.3%; top = 65.8%.
// Verified: Toiletbowl path124 at y=60.93% × height(25.2%) + 65.8% = 81.2% = Bathroom path124 ✓
bowlEl.style.left = '36.3%';
bowlEl.style.top = '65.8%';
bowlEl.style.width = '27.4%';
panel.appendChild(bowlEl);
container.appendChild(panel);
// ── State ─────────────────────────────────────────────────────
var _rafId = null;
var _currentNote = null;
var _currentCents = 0;
var _plungerDipped = false;
var _lastTime = null;
var _leftPct = _TUNER_TT_CENTRE_PCT;
var _topPct = _TUNER_TT_RAISED_TOP;
// ── Animation loop ────────────────────────────────────────────
function _animate(now) {
var dt = Math.min(((now - (_lastTime || now)) / 1000), 0.1);
_lastTime = now;
var inTune = _currentNote !== null && Math.abs(_currentCents) <= _TUNER_TT_IN_TUNE_THR;
var targetLeft = _currentNote === null
? _TUNER_TT_CENTRE_PCT
: Math.min(_TUNER_TT_RIGHT_PCT, Math.max(_TUNER_TT_LEFT_PCT,
_TUNER_TT_CENTRE_PCT + (_currentCents / 50) * (_TUNER_TT_RIGHT_PCT - _TUNER_TT_CENTRE_PCT)));
if (inTune && !_plungerDipped) {
_leftPct = _TUNER_TT_CENTRE_PCT;
_topPct = _TUNER_TT_DIPPED_TOP;
_plungerDipped = true;
noteEl.textContent = '💩';
} else if (!inTune && _plungerDipped) {
_topPct = _TUNER_TT_RAISED_TOP;
_plungerDipped = false;
noteEl.textContent = _currentNote || '–';
}
if (!_plungerDipped) {
_leftPct += (targetLeft - _leftPct) * 8 * dt;
}
plungerEl.style.left = _leftPct.toFixed(2) + '%';
plungerEl.style.top = _topPct.toFixed(2) + '%';
_rafId = requestAnimationFrame(_animate);
}
// ── Public API ────────────────────────────────────────────────
function update(note, cents, freq) {
_currentNote = note;
_currentCents = note === null ? 0 : cents;
if (!_plungerDipped) { noteEl.textContent = note || '–'; }
}
function destroy() {
if (_rafId) { cancelAnimationFrame(_rafId); _rafId = null; }
panel.remove();
}
_rafId = requestAnimationFrame(_animate);
return { update: update, destroy: destroy };
};
})();