mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-09-12 04:28:30 +00:00
refactor(h3d-carve-1): extract pure geometry helpers to src/geometry.js
Moves 7 exports from screen.js to a new ES module src/geometry.js: geoFretX (was fretX, now 2-arg), dZ, slideTrailEnd, camBaseDistU, camLowFretPullbackU, computeBPM, _makeGaussTex. Internal helpers _fretXLog / _fretXUniStep / _fretXUni are module-private inside geometry.js. Module-level constants (SCALE, K, FRET_SCALE, NFRETS, FRET_SPACING_*, TS) are duplicated at geometry.js module scope — values are compile-time and never vary at runtime. screen.js keeps a 1-arg delegator (1 beyond-subst): const fretX = f => geoFretX(f, _h3dFretUniform); No call site changes; fretMid / fretColumnWorldW / slideOffsetWorldX / _recomputeFretSpacingDerived stay in screen.js and use the delegator. Tests: - highway_3d_geometry.test.js: class-killer via import() with 9 known-answer assertions (geoFretX uniform/log invariants, dZ linearity, slideTrailEnd, computeBPM BPM estimate). - highway_3d_fret_spacing: test updated to match delegator pattern + adds GEOMETRY_JS read to verify geoFretX export. - highway_3d_sustain_bloom: retargeted _makeGaussTex check to GEOMETRY_JS (definition moved); call-site check stays on SCREEN_JS. - highway_3d_panel_controls: vm loader strips ES import line and injects geometry stubs; all factory-statics tests unaffected. Suite: 169/169 pass node --test tests/js/highway_3d*.test.js plugins/highway_3d/tests/*.test.js Version bump: 3.35.0 -> 3.36.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
d5f622f31b
commit
84d33769b8
@@ -28,7 +28,11 @@ function loadHighway3dStatics() {
|
||||
1,
|
||||
'expected exactly one factory-registration anchor in screen.js',
|
||||
);
|
||||
const instrumented = src.replace(
|
||||
// Since h3d-carve-1 screen.js starts with an ES module import statement.
|
||||
// vm.runInContext does not support static import — strip the import line
|
||||
// and provide stub implementations of the geometry exports in the sandbox.
|
||||
const stripped = src.replace(/^import\s+\{[^}]+\}\s+from\s+['"][^'"]+['"];\s*\/\/[^\n]*\n/m, '');
|
||||
const instrumented = stripped.replace(
|
||||
ANCHOR,
|
||||
`${ANCHOR}\n window.__h3dTestExports = { BG_DEFAULTS };`,
|
||||
);
|
||||
@@ -50,6 +54,15 @@ function loadHighway3dStatics() {
|
||||
register() {},
|
||||
},
|
||||
},
|
||||
// Geometry stubs — panel-controls test only reads factory statics;
|
||||
// it never invokes the render path where these are called (h3d-carve-1).
|
||||
geoFretX: (f, _uniform) => f * 0.1,
|
||||
dZ: dt => -dt,
|
||||
slideTrailEnd: () => null,
|
||||
camBaseDistU: span => span,
|
||||
camLowFretPullbackU: () => 0,
|
||||
computeBPM: () => 120,
|
||||
_makeGaussTex: () => ({}),
|
||||
};
|
||||
vm.createContext(sandbox);
|
||||
vm.runInContext(instrumented, sandbox, { filename: SCREEN_JS });
|
||||
|
||||
Reference in New Issue
Block a user