klaudio 0.5.0 → 0.5.2
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/package.json +1 -1
- package/src/cli.js +34 -16
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -453,21 +453,10 @@ const GameSoundsScreen = ({ game, sounds, onSelectSound, onDone, onBack }) => {
|
|
|
453
453
|
// Sort files: voice first, then by priority
|
|
454
454
|
const sortedFiles = hasCategories ? sortFilesByPriority(game.files) : game.files;
|
|
455
455
|
|
|
456
|
-
//
|
|
457
|
-
useEffect(() => {
|
|
458
|
-
for (const f of sortedFiles.slice(0, 50)) {
|
|
459
|
-
if (!fileDurations[f.path]) {
|
|
460
|
-
getWavDuration(f.path).then((dur) => {
|
|
461
|
-
if (dur != null) setFileDurations((d) => ({ ...d, [f.path]: dur }));
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}, [game.files]);
|
|
466
|
-
|
|
467
|
-
// Filter files by category
|
|
456
|
+
// Filter files by category (no hard cap — SelectInput handles visible window)
|
|
468
457
|
const categoryFiles = activeCategory && activeCategory !== "all"
|
|
469
|
-
? sortedFiles.filter((f) => f.category === activeCategory)
|
|
470
|
-
: sortedFiles
|
|
458
|
+
? sortedFiles.filter((f) => f.category === activeCategory)
|
|
459
|
+
: sortedFiles;
|
|
471
460
|
|
|
472
461
|
// Stop current playback helper
|
|
473
462
|
const stopPlayback = useCallback(() => {
|
|
@@ -479,6 +468,35 @@ const GameSoundsScreen = ({ game, sounds, onSelectSound, onDone, onBack }) => {
|
|
|
479
468
|
setElapsed(0);
|
|
480
469
|
}, []);
|
|
481
470
|
|
|
471
|
+
// Pre-fetch durations: first 15 on category enter, ±15 around highlighted file
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
const end = Math.min(categoryFiles.length, 15);
|
|
474
|
+
for (let i = 0; i < end; i++) {
|
|
475
|
+
const f = categoryFiles[i];
|
|
476
|
+
if (!fileDurations[f.path]) {
|
|
477
|
+
getWavDuration(f.path).then((dur) => {
|
|
478
|
+
if (dur != null) setFileDurations((d) => ({ ...d, [f.path]: dur }));
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}, [activeCategory]);
|
|
483
|
+
|
|
484
|
+
useEffect(() => {
|
|
485
|
+
if (!highlightedFile || highlightedFile === "_skip") return;
|
|
486
|
+
const idx = categoryFiles.findIndex((f) => f.path === highlightedFile);
|
|
487
|
+
if (idx < 0) return;
|
|
488
|
+
const start = Math.max(0, idx - 15);
|
|
489
|
+
const end = Math.min(categoryFiles.length, idx + 16);
|
|
490
|
+
for (let i = start; i < end; i++) {
|
|
491
|
+
const f = categoryFiles[i];
|
|
492
|
+
if (!fileDurations[f.path]) {
|
|
493
|
+
getWavDuration(f.path).then((dur) => {
|
|
494
|
+
if (dur != null) setFileDurations((d) => ({ ...d, [f.path]: dur }));
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}, [highlightedFile, categoryFiles]);
|
|
499
|
+
|
|
482
500
|
// Auto-preview: play sound when highlighted file changes (with debounce)
|
|
483
501
|
useEffect(() => {
|
|
484
502
|
if (!autoPreview || !highlightedFile || highlightedFile === "_skip") {
|
|
@@ -537,7 +555,7 @@ const GameSoundsScreen = ({ game, sounds, onSelectSound, onDone, onBack }) => {
|
|
|
537
555
|
if (prev) stopPlayback();
|
|
538
556
|
return !prev;
|
|
539
557
|
});
|
|
540
|
-
} else if (activeCategory !== null) {
|
|
558
|
+
} else if (activeCategory !== null || !showCategoryPicker) {
|
|
541
559
|
if (key.backspace || key.delete) {
|
|
542
560
|
setFilter((f) => f.slice(0, -1));
|
|
543
561
|
} else if (input && input !== "p" && !key.ctrl && !key.meta && input.length === 1 && input.charCodeAt(0) >= 32) {
|
|
@@ -715,7 +733,7 @@ const GameSoundsScreen = ({ game, sounds, onSelectSound, onDone, onBack }) => {
|
|
|
715
733
|
const filterLower = filter.toLowerCase();
|
|
716
734
|
const allFileItems = categoryFiles.map((f) => {
|
|
717
735
|
const dur = fileDurations[f.path];
|
|
718
|
-
const durStr = dur != null ? ` (${dur > MAX_PLAY_SECONDS ?
|
|
736
|
+
const durStr = dur != null ? ` (${dur}s${dur > MAX_PLAY_SECONDS ? `, preview ${MAX_PLAY_SECONDS}s` : ""})` : "";
|
|
719
737
|
const catTag = (!activeCategory || activeCategory === "all") && f.category && f.category !== "other"
|
|
720
738
|
? `[${(CATEGORY_LABELS[f.category] || f.category).toUpperCase()}] ` : "";
|
|
721
739
|
const name = f.displayName || f.name;
|