mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-09-12 12:28:32 +00:00
refactor(h3d): extract color/tuning/splitscreen utils to src/utils.js (h3d-carve-3)
Moves 12 pure-function / compile-time-constant exports from the screen.js
IIFE into a new src/utils.js ES module:
Color utils: _h3dHexToInt, _clampByteI, _darkenInt, _lightenInt
String-count: resolveStringCount
Tuning/pitch: _NOTE_NAMES_SHARP, _BASE_OPEN_MIDI_BASS4/5, _BASE_OPEN_MIDI_GUITAR6/7/8,
_baseOpenStringMidis, _midiToPitchLabel, _openStringPitchLabelsForTuning
Splitscreen: _ssActive, _ssIsCanvasFocused
Free-identifier audit: all clean. resolveStringCount uses MAX_RENDER_STRINGS
and NSTR — copied as compile-time constants (both = 6) matching IIFE values.
_ssActive/_ssIsCanvasFocused read window.feedBackSplitscreen live per call.
Survey discrepancy declared: the 12 functions span two non-contiguous regions
in current screen.js (lines 741–882 and 1490–1503) rather than the plan's
original 1703–2193 range; function list from the plan is exact.
New test file highway_3d_utils.test.js: 19 class-killer tests.
Mutation-verified (3-char shorthand removal → RED, original → GREEN).
Panel-controls sandbox: 16 stubs added for the new imports.
Suite: node --test tests/js/highway_3d*.test.js plugins/highway_3d/tests/*.test.js
188→207/207 pass.
Plugin: 3.38.0 → 3.39.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f75e91088f
commit
c7f7c88c62
@@ -75,6 +75,23 @@ function loadHighway3dStatics() {
|
||||
// h3d-carve-2: T and loadThree moved to src/three-loader.js.
|
||||
T: null,
|
||||
loadThree: () => Promise.resolve(),
|
||||
// h3d-carve-3: color/tuning/splitscreen utils moved to src/utils.js.
|
||||
_h3dHexToInt: () => null,
|
||||
_clampByteI: n => n,
|
||||
_darkenInt: (hex) => hex,
|
||||
_lightenInt: (hex) => hex,
|
||||
resolveStringCount: () => 6,
|
||||
_NOTE_NAMES_SHARP: ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'],
|
||||
_BASE_OPEN_MIDI_BASS4: Object.freeze([28, 33, 38, 43]),
|
||||
_BASE_OPEN_MIDI_BASS5: Object.freeze([23, 28, 33, 38, 43]),
|
||||
_BASE_OPEN_MIDI_GUITAR6: Object.freeze([40, 45, 50, 55, 59, 64]),
|
||||
_BASE_OPEN_MIDI_GUITAR7: Object.freeze([35, 40, 45, 50, 55, 59, 64]),
|
||||
_BASE_OPEN_MIDI_GUITAR8: Object.freeze([28, 35, 40, 45, 50, 55, 59, 64]),
|
||||
_baseOpenStringMidis: () => [40, 45, 50, 55, 59, 64],
|
||||
_midiToPitchLabel: () => 'A4',
|
||||
_openStringPitchLabelsForTuning: () => [],
|
||||
_ssActive: () => false,
|
||||
_ssIsCanvasFocused: () => true,
|
||||
};
|
||||
vm.createContext(sandbox);
|
||||
vm.runInContext(instrumented, sandbox, { filename: SCREEN_JS });
|
||||
|
||||
Reference in New Issue
Block a user