loukai-app 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +558 -0
- package/bin/loukai.js +32 -0
- package/package.json +243 -0
- package/src/main/appState.js +250 -0
- package/src/main/audioEngine.js +478 -0
- package/src/main/creator/conversionService.js +503 -0
- package/src/main/creator/downloadManager.js +1128 -0
- package/src/main/creator/ffmpegService.js +487 -0
- package/src/main/creator/installLogger.js +51 -0
- package/src/main/creator/keyDetection.js +212 -0
- package/src/main/creator/llmService.js +370 -0
- package/src/main/creator/lrclibService.js +340 -0
- package/src/main/creator/python/crepe_runner.py +189 -0
- package/src/main/creator/python/demucs_runner.py +158 -0
- package/src/main/creator/python/whisper_runner.py +172 -0
- package/src/main/creator/pythonRunner.js +268 -0
- package/src/main/creator/stemBuilder.js +491 -0
- package/src/main/creator/systemChecker.js +474 -0
- package/src/main/handlers/appHandlers.js +45 -0
- package/src/main/handlers/audioHandlers.js +33 -0
- package/src/main/handlers/autotuneHandlers.js +28 -0
- package/src/main/handlers/canvasHandlers.js +84 -0
- package/src/main/handlers/creatorHandlers.js +159 -0
- package/src/main/handlers/editorHandlers.js +98 -0
- package/src/main/handlers/effectsHandlers.js +100 -0
- package/src/main/handlers/fileHandlers.js +45 -0
- package/src/main/handlers/index.js +78 -0
- package/src/main/handlers/libraryHandlers.js +96 -0
- package/src/main/handlers/mixerHandlers.js +64 -0
- package/src/main/handlers/playerHandlers.js +39 -0
- package/src/main/handlers/preferencesHandlers.js +46 -0
- package/src/main/handlers/queueHandlers.js +81 -0
- package/src/main/handlers/rendererHandlers.js +63 -0
- package/src/main/handlers/settingsHandlers.js +42 -0
- package/src/main/handlers/webServerHandlers.js +105 -0
- package/src/main/main.js +2351 -0
- package/src/main/preload.js +252 -0
- package/src/main/settingsManager.js +139 -0
- package/src/main/statePersistence.js +193 -0
- package/src/main/utils/pathValidator.js +112 -0
- package/src/main/webServer.js +2535 -0
- package/src/native/autotune.js +417 -0
- package/src/renderer/adapters/ElectronBridge.js +677 -0
- package/src/renderer/canvas.html +80 -0
- package/src/renderer/components/App.jsx +303 -0
- package/src/renderer/components/AppRoot.jsx +37 -0
- package/src/renderer/components/AudioDeviceSettings.jsx +145 -0
- package/src/renderer/components/EffectsPanelWrapper.jsx +267 -0
- package/src/renderer/components/MixerTab.jsx +233 -0
- package/src/renderer/components/MixerTabWrapper.jsx +31 -0
- package/src/renderer/components/PortalSelect.jsx +239 -0
- package/src/renderer/components/QueueTab.jsx +116 -0
- package/src/renderer/components/RequestsListWrapper.jsx +78 -0
- package/src/renderer/components/ServerTab.jsx +472 -0
- package/src/renderer/components/SongInfoBarWrapper.jsx +77 -0
- package/src/renderer/components/StatusBar.jsx +92 -0
- package/src/renderer/components/TabNavigation.jsx +77 -0
- package/src/renderer/components/TransportControlsWrapper.jsx +69 -0
- package/src/renderer/components/creator/CreateTab.jsx +1236 -0
- package/src/renderer/dist/assets/kaiPlayer-CoMx__a_.js +2 -0
- package/src/renderer/dist/assets/kaiPlayer-CoMx__a_.js.map +1 -0
- package/src/renderer/dist/assets/microphoneEngine-BaCUhhQc.js +2 -0
- package/src/renderer/dist/assets/microphoneEngine-BaCUhhQc.js.map +1 -0
- package/src/renderer/dist/assets/player-DVrqp7N5.js +3 -0
- package/src/renderer/dist/assets/player-DVrqp7N5.js.map +1 -0
- package/src/renderer/dist/assets/songLoaders-BaTgGib4.js +2 -0
- package/src/renderer/dist/assets/songLoaders-BaTgGib4.js.map +1 -0
- package/src/renderer/dist/assets/webrtcManager-BhCHWceK.js +2 -0
- package/src/renderer/dist/assets/webrtcManager-BhCHWceK.js.map +1 -0
- package/src/renderer/dist/js/autoTuneWorklet.js +224 -0
- package/src/renderer/dist/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/dist/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/dist/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/dist/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/dist/renderer.css +1 -0
- package/src/renderer/dist/renderer.js +62 -0
- package/src/renderer/dist/renderer.js.map +1 -0
- package/src/renderer/dist/renderer.woff2 +0 -0
- package/src/renderer/hooks/useKeyboardShortcuts.js +154 -0
- package/src/renderer/index.html +24 -0
- package/src/renderer/index.html.backup +372 -0
- package/src/renderer/js/PlayerInterface.js +267 -0
- package/src/renderer/js/autoTuneWorklet.js +224 -0
- package/src/renderer/js/butterchurnVerify.js +46 -0
- package/src/renderer/js/canvas-app.js +114 -0
- package/src/renderer/js/cdgPlayer.js +685 -0
- package/src/renderer/js/kaiPlayer.js +1200 -0
- package/src/renderer/js/karaokeRenderer.js +3392 -0
- package/src/renderer/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/js/microphoneEngine.js +656 -0
- package/src/renderer/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/js/player.js +232 -0
- package/src/renderer/js/referencePitchTracker.js +130 -0
- package/src/renderer/js/songLoaders.js +334 -0
- package/src/renderer/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/js/webrtcManager.js +511 -0
- package/src/renderer/lib/butterchurn.min.js +6739 -0
- package/src/renderer/lib/butterchurnPresets.min.js +1 -0
- package/src/renderer/lib/cdgraphics-wrapper.js +16 -0
- package/src/renderer/lib/cdgraphics.js +299 -0
- package/src/renderer/public/js/autoTuneWorklet.js +224 -0
- package/src/renderer/public/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/public/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/public/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/public/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/react-entry.jsx +44 -0
- package/src/renderer/styles/tailwind.css +106 -0
- package/src/renderer/utils/qrCodeGenerator.js +98 -0
- package/src/renderer/vite.config.js +31 -0
- package/src/shared/adapters/BridgeInterface.js +195 -0
- package/src/shared/components/EffectsPanel.jsx +177 -0
- package/src/shared/components/LibraryPanel.jsx +701 -0
- package/src/shared/components/LineDetailCanvas.jsx +167 -0
- package/src/shared/components/LyricLine.jsx +505 -0
- package/src/shared/components/LyricRejection.jsx +84 -0
- package/src/shared/components/LyricSuggestion.jsx +80 -0
- package/src/shared/components/LyricsEditorCanvas.jsx +271 -0
- package/src/shared/components/MixerPanel.jsx +94 -0
- package/src/shared/components/PlayerControls.jsx +206 -0
- package/src/shared/components/PortalSelect.jsx +239 -0
- package/src/shared/components/QueueList.jsx +365 -0
- package/src/shared/components/QuickSearch.jsx +126 -0
- package/src/shared/components/RequestsList.jsx +121 -0
- package/src/shared/components/SongEditor.jsx +1362 -0
- package/src/shared/components/SongInfoBar.jsx +81 -0
- package/src/shared/components/ThemeToggle.jsx +106 -0
- package/src/shared/components/Toast.jsx +30 -0
- package/src/shared/components/VisualizationSettings.jsx +243 -0
- package/src/shared/constants.js +95 -0
- package/src/shared/context/BridgeContext.jsx +32 -0
- package/src/shared/contexts/AudioContext.jsx +37 -0
- package/src/shared/contexts/PlayerContext.jsx +66 -0
- package/src/shared/contexts/SettingsContext.jsx +50 -0
- package/src/shared/defaults.js +158 -0
- package/src/shared/formatUtils.js +59 -0
- package/src/shared/formatUtils.test.js +207 -0
- package/src/shared/hooks/useAppState.js +97 -0
- package/src/shared/hooks/useAudioEngine.js +264 -0
- package/src/shared/hooks/usePlayer.js +89 -0
- package/src/shared/hooks/useSettingsPersistence.js +74 -0
- package/src/shared/hooks/useWebRTC.js +118 -0
- package/src/shared/ipcContracts.js +299 -0
- package/src/shared/package.json +3 -0
- package/src/shared/services/creatorService.js +373 -0
- package/src/shared/services/creatorService.test.js +413 -0
- package/src/shared/services/editorService.js +213 -0
- package/src/shared/services/editorService.test.js +219 -0
- package/src/shared/services/effectsService.js +271 -0
- package/src/shared/services/effectsService.test.js +418 -0
- package/src/shared/services/libraryService.js +438 -0
- package/src/shared/services/libraryService.test.js +474 -0
- package/src/shared/services/mixerService.js +172 -0
- package/src/shared/services/mixerService.test.js +399 -0
- package/src/shared/services/playerService.js +221 -0
- package/src/shared/services/playerService.test.js +357 -0
- package/src/shared/services/preferencesService.js +219 -0
- package/src/shared/services/queueService.js +226 -0
- package/src/shared/services/queueService.test.js +430 -0
- package/src/shared/services/requestsService.js +155 -0
- package/src/shared/services/requestsService.test.js +362 -0
- package/src/shared/services/serverSettingsService.js +151 -0
- package/src/shared/services/settingsService.js +257 -0
- package/src/shared/services/settingsService.test.js +295 -0
- package/src/shared/state/StateManager.js +263 -0
- package/src/shared/utils/audio.js +42 -0
- package/src/shared/utils/format.js +32 -0
- package/src/shared/utils/lyricsUtils.js +162 -0
- package/src/test/setup.js +40 -0
- package/src/utils/cdgLoader.js +180 -0
- package/src/utils/m4aLoader.js +333 -0
- package/src/web/App.jsx +578 -0
- package/src/web/adapters/WebBridge.js +428 -0
- package/src/web/components/PlayerSettingsPanel.jsx +231 -0
- package/src/web/components/SongSearch.jsx +180 -0
- package/src/web/dist/assets/index-0H-RnRrV.js +51 -0
- package/src/web/dist/assets/index-0H-RnRrV.js.map +1 -0
- package/src/web/dist/assets/index-DYW2zB0u.css +1 -0
- package/src/web/dist/index.html +15 -0
- package/src/web/index.html +14 -0
- package/src/web/main.jsx +10 -0
- package/src/web/package-lock.json +1765 -0
- package/src/web/pages/SongRequestPage.jsx +619 -0
- package/src/web/styles/tailwind.css +68 -0
- package/src/web/vite.config.js +27 -0
- package/static/fonts/material-icons.woff2 +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Potion of Spirits.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Songflower _Moss Posy_.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Storm of the Eye _Thunder_ - mash0000 - quasi pseudo meta concentrics.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi _ Geiss - Airhandler _Kali Mix_ - Canvas Mix.png +0 -0
- package/static/images/butterchurn-screenshots/An AdamFX n Martin Infusion 2 flexi - Why The Sky Looks Diffrent Today - AdamFx n Martin Infusion - Tack Tile Disfunction B.png +0 -0
- package/static/images/butterchurn-screenshots/Cope - The Neverending Explosion of Red Liquid Fire.png +0 -0
- proton lights __Krash_s beat code_ _Phat_remix02b.png +0 -0
- package/static/images/butterchurn-screenshots/Eo_S_ _ Phat - cubetrace - v2.png +0 -0
- package/static/images/butterchurn-screenshots/Eo_S_ _ Zylot - skylight _Stained Glass Majesty mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - alien fish pond.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - area 51.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - infused with the spiral.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - mindblob _shiny mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - mindblob mix.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - predator-prey-spirals.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - smashing fractals _acid etching mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - truly soft piece of software - this is generic texturing _Jelly_ .png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ Martin - astral projection.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ Martin - cascading decay swing.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ amandio c - piercing 05 - Kopie _2_ - Kopie.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ stahlregen - jelly showoff parade.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi_ fishbrain_ Geiss _ Martin - tokamak witchery.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi_ martin _ geiss - dedicated to the sherwin maxawow.png +0 -0
- package/static/images/butterchurn-screenshots/Fumbling_Foo _ Flexi_ Martin_ Orb_ Unchained - Star Nova v7b.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Cauldron - painterly 2 _saturation remix_.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Reaction Diffusion 2.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Spiral Artifact.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Thumb Drum.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss _ Flexi _ Martin - disconnected.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss_ Flexi _ Stahlregen - Thumbdrum Tokamak _crossfiring aftermath jelly mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/Goody - The Wild Vort.png +0 -0
- package/static/images/butterchurn-screenshots/Idiot - Star Of Annon.png +0 -0
- package/static/images/butterchurn-screenshots/Krash _ Illusion - Spiral Movement.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - QBikal - Surface Turbulence IIb.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - acid wiring.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - charisma.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - liquid arrows.png +0 -0
- package/static/images/butterchurn-screenshots/Milk Artist At our Best - FED - SlowFast Ft AdamFX n Martin - HD CosmoFX.png +0 -0
- package/static/images/butterchurn-screenshots/ORB - Waaa.png +0 -0
- package/static/images/butterchurn-screenshots/Phat_fiShbRaiN_Eo_S_Mandala_Chasers_remix.png +0 -0
- package/static/images/butterchurn-screenshots/Rovastar - Oozing Resistance.png +0 -0
- package/static/images/butterchurn-screenshots/Rovastar _ Loadus _ Geiss - FractalDrop _Triple Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/TonyMilkdrop - Leonardo Da Vinci_s Balloon _Flexi - merry-go-round _ techstyle_.png +0 -0
- package/static/images/butterchurn-screenshots/TonyMilkdrop - Magellan_s Nebula _Flexi - you enter first _ multiverse_.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained - Rewop.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained - Unified Drag 2.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained _ Rovastar - Wormhole Pillars _Hall of Shadows mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - Paint Spill _Music Reactive Paint Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - Star Ornament.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - True Visionary _Final Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/_Aderrasi - Wanderer in Curved Space - mash0000 - faclempt kibitzing meshuggana schmaltz _Geiss color mix_.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - Artifact 01.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - Desert Rose 2.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - untitled.png +0 -0
- package/static/images/butterchurn-screenshots/_Mig_049.png +0 -0
- package/static/images/butterchurn-screenshots/_Mig_085.png +0 -0
- package/static/images/butterchurn-screenshots/_Rovastar _ Geiss - Hurricane Nightmare _Posterize Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _197_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _220_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _431_.png +0 -0
- package/static/images/butterchurn-screenshots/cope _ martin - mother-of-pearl.png +0 -0
- package/static/images/butterchurn-screenshots/fiShbRaiN _ Flexi - witchcraft 2_0.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - bouncing balls _double mindblob neon mix_.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - mom_ why the sky looks different today.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - patternton_ district of media_ capitol of the united abstractions of fractopia.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - swing out on the spiral.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - what is the matrix.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ amandio c - organic _random mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ amandio c - organic12-3d-2_milk.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ fishbrain - neon mindblob grafitti.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ geiss - pogo cubes vs_ tokamak vs_ game of life _stahls jelly 4_5 finish_.png +0 -0
- package/static/images/butterchurn-screenshots/high-altitude basket unraveling - singh grooves nitrogen argon nz_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - The Bridge of Khazad-Dum.png +0 -0
- package/static/images/butterchurn-screenshots/martin - angel flight.png +0 -0
- package/static/images/butterchurn-screenshots/martin - another kind of groove.png +0 -0
- package/static/images/butterchurn-screenshots/martin - bombyx mori.png +0 -0
- package/static/images/butterchurn-screenshots/martin - castle in the air.png +0 -0
- package/static/images/butterchurn-screenshots/martin - chain breaker.png +0 -0
- package/static/images/butterchurn-screenshots/martin - disco mix 4.png +0 -0
- package/static/images/butterchurn-screenshots/martin - extreme heat.png +0 -0
- package/static/images/butterchurn-screenshots/martin - frosty caves 2.png +0 -0
- package/static/images/butterchurn-screenshots/martin - fruit machine.png +0 -0
- package/static/images/butterchurn-screenshots/martin - ghost city.png +0 -0
- package/static/images/butterchurn-screenshots/martin - glass corridor.png +0 -0
- package/static/images/butterchurn-screenshots/martin - infinity _2010 update_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - mandelbox explorer - high speed demo version.png +0 -0
- package/static/images/butterchurn-screenshots/martin - mucus cervix.png +0 -0
- package/static/images/butterchurn-screenshots/martin - reflections on black tiles.png +0 -0
- package/static/images/butterchurn-screenshots/martin - stormy sea _2010 update_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - witchcraft reloaded.png +0 -0
- package/static/images/butterchurn-screenshots/martin _ flexi - diamond cutter _prismaticvortex_com_ - camille - i wish i wish i wish i was constrained.png +0 -0
- package/static/images/butterchurn-screenshots/martin _shadow harlequins shape code_ - fata morgana.png +0 -0
- package/static/images/butterchurn-screenshots/martin_ flexi_ fishbrain _ sto - enterstate _random mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/sawtooth grin roam.png +0 -0
- package/static/images/butterchurn-screenshots/shifter - dark tides bdrv mix 2.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - Rovastar - Sunflower Passion _Enlightment Mix__Phat_edit _ flexi und martin shaders - circumflex in character classes in regular expression.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - heretical crosscut playpen.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - uninitialized variabowl _hydroponic chronic_.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - vector exp 1 - couldn_t not.png +0 -0
- package/static/images/butterchurn-screenshots/yin - 191 - Temporal singularities.png +0 -0
- package/static/images/logo-512.png +0 -0
- package/static/images/logo.png +0 -0
- package/static/loukai-logo.png +0 -0
- package/static/screenshot-generator.html +610 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlayerControls - Unified player transport controls
|
|
3
|
+
*
|
|
4
|
+
* Based on renderer UI (better styling than web admin)
|
|
5
|
+
* Works with both ElectronBridge and WebBridge via callbacks
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useState, useEffect, useRef } from 'react';
|
|
9
|
+
import { formatDuration } from '../formatUtils.js';
|
|
10
|
+
|
|
11
|
+
export function PlayerControls({
|
|
12
|
+
playback,
|
|
13
|
+
currentSong,
|
|
14
|
+
currentEffect,
|
|
15
|
+
isLoading,
|
|
16
|
+
onPlay,
|
|
17
|
+
onPause,
|
|
18
|
+
onRestart,
|
|
19
|
+
onNext,
|
|
20
|
+
onSeek,
|
|
21
|
+
onPreviousEffect,
|
|
22
|
+
onNextEffect,
|
|
23
|
+
onOpenCanvasWindow,
|
|
24
|
+
className = '',
|
|
25
|
+
}) {
|
|
26
|
+
const { isPlaying, position = 0, duration = 0 } = playback || {};
|
|
27
|
+
|
|
28
|
+
// Smooth position interpolation for 60fps progress bar updates
|
|
29
|
+
const [interpolatedPosition, setInterpolatedPosition] = useState(position);
|
|
30
|
+
const lastReportedPosition = useRef(position);
|
|
31
|
+
const lastReportedTime = useRef(performance.now());
|
|
32
|
+
const animationFrameRef = useRef(null);
|
|
33
|
+
|
|
34
|
+
// Derive loading state from currentSong if not explicitly provided
|
|
35
|
+
const loading = isLoading !== undefined ? isLoading : currentSong?.isLoading || false;
|
|
36
|
+
|
|
37
|
+
// Update refs when position changes from IPC
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
lastReportedPosition.current = position;
|
|
40
|
+
lastReportedTime.current = performance.now();
|
|
41
|
+
setInterpolatedPosition(position);
|
|
42
|
+
}, [position]);
|
|
43
|
+
|
|
44
|
+
// Smooth interpolation when playing
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!isPlaying) {
|
|
47
|
+
// Stop interpolation when paused
|
|
48
|
+
if (animationFrameRef.current) {
|
|
49
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
50
|
+
animationFrameRef.current = null;
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Interpolate position on every frame
|
|
56
|
+
const animate = () => {
|
|
57
|
+
const now = performance.now();
|
|
58
|
+
const elapsed = (now - lastReportedTime.current) / 1000; // Convert to seconds
|
|
59
|
+
const newPosition = Math.min(lastReportedPosition.current + elapsed, duration || Infinity);
|
|
60
|
+
setInterpolatedPosition(newPosition);
|
|
61
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
animationFrameRef.current = requestAnimationFrame(animate);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
if (animationFrameRef.current) {
|
|
68
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [isPlaying, duration]);
|
|
72
|
+
|
|
73
|
+
// Truncate effect name to 28 characters with ellipsis
|
|
74
|
+
const truncateEffectName = (name) => {
|
|
75
|
+
if (!name || name === 'No Effect') return name;
|
|
76
|
+
return name.length > 28 ? name.substring(0, 28) + '…' : name;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const handleProgressClick = (e) => {
|
|
80
|
+
if (!duration || !onSeek) return;
|
|
81
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
82
|
+
const x = e.clientX - rect.left;
|
|
83
|
+
const progress = Math.max(0, Math.min(1, x / rect.width));
|
|
84
|
+
const newPosition = progress * duration;
|
|
85
|
+
onSeek(newPosition);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Use interpolated position for smooth 60fps progress bar
|
|
89
|
+
const progress = duration > 0 ? (interpolatedPosition / duration) * 100 : 0;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className={`bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 p-4 ${className}`}
|
|
94
|
+
>
|
|
95
|
+
<div className="flex items-center gap-3">
|
|
96
|
+
{/* Transport Controls */}
|
|
97
|
+
<button
|
|
98
|
+
onClick={onRestart}
|
|
99
|
+
title="Restart Track"
|
|
100
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition disabled:opacity-50 flex items-center justify-center"
|
|
101
|
+
disabled={loading}
|
|
102
|
+
>
|
|
103
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 text-2xl leading-none">
|
|
104
|
+
replay
|
|
105
|
+
</span>
|
|
106
|
+
</button>
|
|
107
|
+
|
|
108
|
+
<button
|
|
109
|
+
onClick={isPlaying ? onPause : onPlay}
|
|
110
|
+
title={loading ? 'Loading...' : isPlaying ? 'Pause' : 'Play'}
|
|
111
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition disabled:opacity-50 flex items-center justify-center"
|
|
112
|
+
disabled={loading}
|
|
113
|
+
>
|
|
114
|
+
{loading ? (
|
|
115
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 text-2xl leading-none animate-spin">
|
|
116
|
+
hourglass_empty
|
|
117
|
+
</span>
|
|
118
|
+
) : (
|
|
119
|
+
<span className="material-icons text-blue-600 dark:text-blue-400 text-2xl leading-none">
|
|
120
|
+
{isPlaying ? 'pause' : 'play_arrow'}
|
|
121
|
+
</span>
|
|
122
|
+
)}
|
|
123
|
+
</button>
|
|
124
|
+
|
|
125
|
+
<button
|
|
126
|
+
onClick={onNext}
|
|
127
|
+
title="Next Track"
|
|
128
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition disabled:opacity-50 flex items-center justify-center"
|
|
129
|
+
disabled={loading}
|
|
130
|
+
>
|
|
131
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 text-2xl leading-none">
|
|
132
|
+
skip_next
|
|
133
|
+
</span>
|
|
134
|
+
</button>
|
|
135
|
+
|
|
136
|
+
{/* Progress Bar */}
|
|
137
|
+
<div className="flex-1 mx-4">
|
|
138
|
+
<div
|
|
139
|
+
className="relative h-2 bg-gray-200 dark:bg-gray-700 rounded-full cursor-pointer"
|
|
140
|
+
onClick={handleProgressClick}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
className="absolute inset-y-0 left-0 bg-blue-600 rounded-full"
|
|
144
|
+
style={{ width: `${progress}%` }}
|
|
145
|
+
/>
|
|
146
|
+
<div
|
|
147
|
+
className="absolute top-1/2 -translate-y-1/2 w-4 h-4 bg-blue-600 rounded-full shadow-lg"
|
|
148
|
+
style={{ left: `calc(${progress}% - 8px)` }}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
{/* Time Display */}
|
|
154
|
+
<div className="flex items-center gap-1 text-sm font-mono text-gray-700 dark:text-gray-300 flex-shrink-0">
|
|
155
|
+
<span>{formatDuration(interpolatedPosition)}</span>
|
|
156
|
+
<span>/</span>
|
|
157
|
+
<span>{formatDuration(duration)}</span>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
{/* Divider */}
|
|
161
|
+
<div className="w-px h-8 bg-gray-200 dark:bg-gray-700 mx-2" />
|
|
162
|
+
|
|
163
|
+
{/* Effects Controls */}
|
|
164
|
+
{onPreviousEffect && (
|
|
165
|
+
<button
|
|
166
|
+
onClick={onPreviousEffect}
|
|
167
|
+
title="Previous Effect"
|
|
168
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition flex items-center justify-center"
|
|
169
|
+
>
|
|
170
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 leading-none">
|
|
171
|
+
chevron_left
|
|
172
|
+
</span>
|
|
173
|
+
</button>
|
|
174
|
+
)}
|
|
175
|
+
<span
|
|
176
|
+
className="px-3 py-1 bg-gray-100 dark:bg-gray-900 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium min-w-[120px] text-center"
|
|
177
|
+
title={currentEffect || 'No Effect'}
|
|
178
|
+
>
|
|
179
|
+
{truncateEffectName(currentEffect || 'No Effect')}
|
|
180
|
+
</span>
|
|
181
|
+
{onNextEffect && (
|
|
182
|
+
<button
|
|
183
|
+
onClick={onNextEffect}
|
|
184
|
+
title="Next Effect"
|
|
185
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition flex items-center justify-center"
|
|
186
|
+
>
|
|
187
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 leading-none">
|
|
188
|
+
chevron_right
|
|
189
|
+
</span>
|
|
190
|
+
</button>
|
|
191
|
+
)}
|
|
192
|
+
{onOpenCanvasWindow && (
|
|
193
|
+
<button
|
|
194
|
+
onClick={onOpenCanvasWindow}
|
|
195
|
+
className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition flex items-center justify-center"
|
|
196
|
+
title="Open Canvas Window"
|
|
197
|
+
>
|
|
198
|
+
<span className="material-icons text-gray-700 dark:text-gray-300 leading-none">
|
|
199
|
+
open_in_new
|
|
200
|
+
</span>
|
|
201
|
+
</button>
|
|
202
|
+
)}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PortalSelect - Custom select component using portal for dropdown positioning
|
|
3
|
+
*
|
|
4
|
+
* DESIGN EXCEPTION: We normally prefer native HTML elements (see SYSTEM_ARCHITECTURE.md),
|
|
5
|
+
* but native <select> dropdowns are broken on Linux due to Electron 38+ Wayland bugs.
|
|
6
|
+
* The dropdown renders at the top-left corner instead of below the select element.
|
|
7
|
+
* See: https://github.com/electron/electron/issues/44607
|
|
8
|
+
*
|
|
9
|
+
* This component renders the dropdown via a React portal to document.body,
|
|
10
|
+
* bypassing the Wayland popup positioning bug. We maintain as much native
|
|
11
|
+
* behavior as possible: keyboard navigation, focus management, escape to close.
|
|
12
|
+
*
|
|
13
|
+
* This workaround should be removed when Electron fixes Wayland popup positioning.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
17
|
+
import { createPortal } from 'react-dom';
|
|
18
|
+
|
|
19
|
+
export function PortalSelect({
|
|
20
|
+
id,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
options = [],
|
|
24
|
+
placeholder = 'Select...',
|
|
25
|
+
className = '',
|
|
26
|
+
}) {
|
|
27
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
28
|
+
const [position, setPosition] = useState({ top: 0, left: 0, minWidth: 0, openUpward: false });
|
|
29
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
30
|
+
const triggerRef = useRef(null);
|
|
31
|
+
const dropdownRef = useRef(null);
|
|
32
|
+
|
|
33
|
+
// Estimated dropdown height for positioning calculation
|
|
34
|
+
const DROPDOWN_MAX_HEIGHT = 240; // matches max-h-60 (15rem = 240px)
|
|
35
|
+
|
|
36
|
+
// Find the selected option's label
|
|
37
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
38
|
+
const displayText = selectedOption ? selectedOption.label : placeholder;
|
|
39
|
+
|
|
40
|
+
// Find index of currently selected value
|
|
41
|
+
const selectedIndex = options.findIndex((opt) => opt.value === value);
|
|
42
|
+
|
|
43
|
+
// Update dropdown position when opened
|
|
44
|
+
const updatePosition = useCallback(() => {
|
|
45
|
+
if (triggerRef.current) {
|
|
46
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
47
|
+
const viewportHeight = window.innerHeight;
|
|
48
|
+
const spaceBelow = viewportHeight - rect.bottom;
|
|
49
|
+
const spaceAbove = rect.top;
|
|
50
|
+
|
|
51
|
+
// Determine if we should open upward
|
|
52
|
+
const estimatedHeight = Math.min(options.length * 40, DROPDOWN_MAX_HEIGHT);
|
|
53
|
+
const openUpward = spaceBelow < estimatedHeight && spaceAbove > spaceBelow;
|
|
54
|
+
|
|
55
|
+
setPosition({
|
|
56
|
+
top: openUpward ? rect.top - 2 : rect.bottom + 2,
|
|
57
|
+
left: rect.left,
|
|
58
|
+
minWidth: rect.width,
|
|
59
|
+
openUpward,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [options.length]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isOpen) {
|
|
66
|
+
updatePosition();
|
|
67
|
+
setFocusedIndex(selectedIndex >= 0 ? selectedIndex : 0);
|
|
68
|
+
}
|
|
69
|
+
}, [isOpen, updatePosition, selectedIndex]);
|
|
70
|
+
|
|
71
|
+
// Close dropdown when clicking outside
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!isOpen) return;
|
|
74
|
+
|
|
75
|
+
const handleClickOutside = (event) => {
|
|
76
|
+
if (
|
|
77
|
+
triggerRef.current &&
|
|
78
|
+
!triggerRef.current.contains(event.target) &&
|
|
79
|
+
dropdownRef.current &&
|
|
80
|
+
!dropdownRef.current.contains(event.target)
|
|
81
|
+
) {
|
|
82
|
+
setIsOpen(false);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
87
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
88
|
+
}, [isOpen]);
|
|
89
|
+
|
|
90
|
+
// Close on scroll outside dropdown to prevent misalignment
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!isOpen) return;
|
|
93
|
+
|
|
94
|
+
const handleScroll = (event) => {
|
|
95
|
+
// Don't close if scrolling within the dropdown itself
|
|
96
|
+
if (dropdownRef.current && dropdownRef.current.contains(event.target)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
setIsOpen(false);
|
|
100
|
+
};
|
|
101
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
102
|
+
return () => window.removeEventListener('scroll', handleScroll, true);
|
|
103
|
+
}, [isOpen]);
|
|
104
|
+
|
|
105
|
+
const handleSelect = useCallback(
|
|
106
|
+
(optionValue) => {
|
|
107
|
+
onChange?.({ target: { value: optionValue } });
|
|
108
|
+
setIsOpen(false);
|
|
109
|
+
triggerRef.current?.focus();
|
|
110
|
+
},
|
|
111
|
+
[onChange]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// Keyboard navigation matching native select behavior
|
|
115
|
+
const handleKeyDown = useCallback(
|
|
116
|
+
(event) => {
|
|
117
|
+
switch (event.key) {
|
|
118
|
+
case 'Enter':
|
|
119
|
+
case ' ':
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
if (isOpen && focusedIndex >= 0) {
|
|
122
|
+
handleSelect(options[focusedIndex].value);
|
|
123
|
+
} else {
|
|
124
|
+
setIsOpen(!isOpen);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case 'Escape':
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
setIsOpen(false);
|
|
130
|
+
triggerRef.current?.focus();
|
|
131
|
+
break;
|
|
132
|
+
case 'ArrowDown':
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
if (!isOpen) {
|
|
135
|
+
setIsOpen(true);
|
|
136
|
+
} else {
|
|
137
|
+
setFocusedIndex((prev) => Math.min(prev + 1, options.length - 1));
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case 'ArrowUp':
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
if (isOpen) {
|
|
143
|
+
setFocusedIndex((prev) => Math.max(prev - 1, 0));
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case 'Home':
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
if (isOpen) setFocusedIndex(0);
|
|
149
|
+
break;
|
|
150
|
+
case 'End':
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
if (isOpen) setFocusedIndex(options.length - 1);
|
|
153
|
+
break;
|
|
154
|
+
case 'Tab':
|
|
155
|
+
if (isOpen) setIsOpen(false);
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
// Type-to-search: find first option starting with pressed key
|
|
159
|
+
if (event.key.length === 1 && isOpen) {
|
|
160
|
+
const char = event.key.toLowerCase();
|
|
161
|
+
const idx = options.findIndex((opt) => opt.label.toLowerCase().startsWith(char));
|
|
162
|
+
if (idx >= 0) setFocusedIndex(idx);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
[isOpen, focusedIndex, options, handleSelect]
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// Scroll focused option into view
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
if (isOpen && dropdownRef.current && focusedIndex >= 0) {
|
|
172
|
+
const focusedElement = dropdownRef.current.children[focusedIndex];
|
|
173
|
+
focusedElement?.scrollIntoView({ block: 'nearest' });
|
|
174
|
+
}
|
|
175
|
+
}, [isOpen, focusedIndex]);
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<>
|
|
179
|
+
{/* Trigger Button - styled to match native select */}
|
|
180
|
+
<button
|
|
181
|
+
ref={triggerRef}
|
|
182
|
+
id={id}
|
|
183
|
+
type="button"
|
|
184
|
+
className={`w-full px-3 py-2 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded text-gray-900 dark:text-gray-100 cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 flex items-center justify-between text-left ${className}`}
|
|
185
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
186
|
+
onKeyDown={handleKeyDown}
|
|
187
|
+
aria-haspopup="listbox"
|
|
188
|
+
aria-expanded={isOpen}
|
|
189
|
+
aria-labelledby={id}
|
|
190
|
+
>
|
|
191
|
+
<span className="truncate">{displayText}</span>
|
|
192
|
+
<svg
|
|
193
|
+
className={`w-4 h-4 ml-2 flex-shrink-0 transition-transform ${isOpen ? 'rotate-180' : ''}`}
|
|
194
|
+
fill="none"
|
|
195
|
+
stroke="currentColor"
|
|
196
|
+
viewBox="0 0 24 24"
|
|
197
|
+
>
|
|
198
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
|
199
|
+
</svg>
|
|
200
|
+
</button>
|
|
201
|
+
|
|
202
|
+
{/* Dropdown Portal - renders at document.body to bypass Wayland positioning bug */}
|
|
203
|
+
{isOpen &&
|
|
204
|
+
createPortal(
|
|
205
|
+
<div
|
|
206
|
+
ref={dropdownRef}
|
|
207
|
+
className="fixed z-[9999] bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded shadow-lg max-h-60 overflow-y-auto"
|
|
208
|
+
style={{
|
|
209
|
+
...(position.openUpward
|
|
210
|
+
? { bottom: window.innerHeight - position.top, left: position.left }
|
|
211
|
+
: { top: position.top, left: position.left }),
|
|
212
|
+
minWidth: position.minWidth,
|
|
213
|
+
}}
|
|
214
|
+
role="listbox"
|
|
215
|
+
onKeyDown={handleKeyDown}
|
|
216
|
+
>
|
|
217
|
+
{options.map((option, index) => (
|
|
218
|
+
<div
|
|
219
|
+
key={option.value}
|
|
220
|
+
className={`px-3 py-2 cursor-pointer transition-colors whitespace-nowrap ${
|
|
221
|
+
index === focusedIndex
|
|
222
|
+
? 'bg-blue-500 text-white'
|
|
223
|
+
: option.value === value
|
|
224
|
+
? 'bg-blue-100 dark:bg-blue-900 text-blue-900 dark:text-blue-100'
|
|
225
|
+
: 'text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-600'
|
|
226
|
+
}`}
|
|
227
|
+
onClick={() => handleSelect(option.value)}
|
|
228
|
+
role="option"
|
|
229
|
+
aria-selected={option.value === value}
|
|
230
|
+
>
|
|
231
|
+
{option.label}
|
|
232
|
+
</div>
|
|
233
|
+
))}
|
|
234
|
+
</div>,
|
|
235
|
+
document.body
|
|
236
|
+
)}
|
|
237
|
+
</>
|
|
238
|
+
);
|
|
239
|
+
}
|