Refactor inline AudioWorkletProcessor to separate file#88
Refactor inline AudioWorkletProcessor to separate file#88
Conversation
Move `CaptureProcessor` from inline string in `AudioEngine.ts` to `src/lib/audio/capture-processor.ts`. This improves code readability, maintainability, and enables type checking. The processor is now imported using Vite's `?worker&url` suffix and loaded via `addModule`. - Extracted `CaptureProcessor` logic to `src/lib/audio/capture-processor.ts` - Added TypeScript types and constants to the processor - Updated `AudioEngine.ts` to import the processor URL - Verified with build and instantiation tests Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Review Summary (Post r1→master merge)Status: ✅ MERGEABLE Changes: Extracts the inline AudioWorkletProcessor from a Blob URL in \AudioEngine.ts\ into a proper separate file \capture-processor.ts:
Assessment: Important maintainability improvement. Inline JS-in-strings is hard to debug, gets no TypeScript checking, and no IDE support. The extracted file is properly typed and can be tested/linted. Recommendation: ✅ Merge — Significant maintainability improvement |
Thank you for the review! I'm glad the extraction of the AudioWorkletProcessor improves the codebase's maintainability and type safety. |
- Replied to PR comments acknowledging the review. - No code changes required as the review was positive. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
LGTM. Extracting the AudioWorkletProcessor from an inline string into a proper TypeScript file significantly improves maintainability and allows for better IDE support/type checking. This addresses the tech debt identified in the AudioEngine.ts review. Recommend merging. |
Refactored the inline
CaptureProcessorstring fromsrc/lib/audio/AudioEngine.tsinto a dedicated TypeScript filesrc/lib/audio/capture-processor.ts.Changes
CaptureProcessorclass andregisterProcessorcall tosrc/lib/audio/capture-processor.ts.${windowDuration}with a constantWINDOW_DURATION = 0.080in the new file.AudioEngine.tsto import the processor usingimport captureProcessorUrl from './capture-processor.ts?worker&url';.AudioEngine.init()to load the module from the imported URL.Verification
npm run buildsuccessfully.npm test- core tests passed. One unrelated flaky test inTenVADWorkerClienttimed out.AudioEngineinstantiation and worklet loading via a temporary test file.PR created automatically by Jules for task 17365362216095794719 started by @ysdede