fix(highway_3d): _bgPanelKey rejects non-integer panel index; JSDoc bridge fns

- _bgPanelKey() treated any non-null panelIndexFor() return as a valid panel id,
  so a NaN/non-finite index minted a bogus "panelNaN" localStorage key instead
  of falling back to "main". Gate on Number.isInteger(idx) && idx >= 0. (The
  camera path is already NaN-safe — panelsMap[NaN] misses and falls through.)
- Add a NaN/negative-index case to the resolver tests (drum 22, keys 57, pass).
- Convert the camera-bridge helpers' comments to JSDoc (_bgPanelKey, _freeCamFor,
  _resolveFreeCam, _ssApi across the three plugins) to lift docstring coverage on
  the changed surface. Comment/robustness only; no behavior change beyond the
  NaN guard.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Kris Anderson <topkoa@gmail.com>
This commit is contained in:
Kris Anderson
2026-07-09 16:27:56 -04:00
co-authored by Claude Opus 4.8
parent a6a5186180
commit bcee2e8610
5 changed files with 68 additions and 24 deletions
+16 -7
View File
@@ -1365,15 +1365,24 @@
* Camera Director bridge resolver (pure — exported via createFactory.__test)
* ====================================================================== */
// Resolve the active splitscreen API, defensive on the global-name rename in
// flight (feedBackSplitscreen is canonical; slopsmithSplitscreen is the legacy
// alias). Returns null when splitscreen isn't present.
/**
* The active splitscreen API, defensive on the global-name rename in flight
* (feedBackSplitscreen is canonical; slopsmithSplitscreen is the legacy alias).
* @returns {object|null} the splitscreen API, or null when not present
*/
function _ssApi() { return window.feedBackSplitscreen || window.slopsmithSplitscreen || null; }
// Given the splitscreen API, THIS window's per-panel camera map, and the
// global camera, return this panel's camera under splitscreen, else the
// global, else null (Camera Director absent → stock framing). Throw-safe on
// panelIndexFor so a misbehaving splitscreen build can't break framing.
/**
* Resolve the Camera Director camera for a canvas: this panel's camera under
* splitscreen, else the global, else null (Camera Director absent → stock
* framing). Throw-safe on panelIndexFor so a misbehaving splitscreen build
* can't break framing.
* @param {HTMLCanvasElement} canvas this renderer's highway canvas
* @param {object|null} ss the splitscreen API (see _ssApi)
* @param {object|null} panelsMap window.__h3dCamCtlPanels (per-panel cameras by index)
* @param {object|null} globalCam window.__h3dCamCtl (single global camera)
* @returns {object|null} the resolved free-camera bridge, or null
*/
function _resolveFreeCam(canvas, ss, panelsMap, globalCam) {
if (panelsMap && ss && typeof ss.panelIndexFor === 'function') {
try {