mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Compare commits
4
Commits
v0.3.5-b26
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fdb2b7ce1 | ||
|
|
65fbc775ce | ||
|
|
b57dd74445 | ||
|
|
31287bdeb7 |
No files matched your search
@@ -306,6 +306,34 @@ Two independent apps that talk over HTTP:
|
||||
cached. The header itself is read by `core/mp3_gapless.py`, which skips
|
||||
the ID3v2 tag first — a check that did not once misread every real MP3
|
||||
as header-less.
|
||||
- `file_block.py` — **Traktor's own block INSIDE the audio file**, and
|
||||
removing it from copies (measured in Traktor 4.5, 2026-10-24: 2MUCH /
|
||||
Alone (Vip)). Traktor writes a `DMRT` chunk tree (reversed 4CCs; chunk =
|
||||
name + u32 size + u32 child count + payload) into every file it tags:
|
||||
MP4 `ilst` atom `NITR` (mutagen: `_failed_atoms`, or a parsed key), ID3
|
||||
`PRIV` owner `TRAKTOR4` (MP3/AIFF/WAV), Vorbis `traktor4` (FLAC). It
|
||||
holds `HBPM` (float32 BPM), `CUEP` (cues), `AUID` (= the NML AUDIO_ID
|
||||
after a 4-byte length), `TRN3` transients, tags. **An entry with no
|
||||
MODIFIED_DATE — every entry Konduktor creates — makes Traktor re-read
|
||||
the file and take `HBPM` over the NML's BPM, LOCK or not** (anchor
|
||||
kept; it then stamps MODIFIED_DATE/TIME = the file's mtime, UTC
|
||||
seconds). So a grid fixed after Traktor last wrote the block reverted on
|
||||
every export/push. Measured alternatives: AUDIO_ID added — no effect;
|
||||
MODIFIED_DATE later than the file — grid kept but Traktor skips the
|
||||
file entirely, cover art lost. Block removed (no date, no AUDIO_ID) —
|
||||
grid, lock, cues AND art right, a stale `tmpo` ignored, and Traktor
|
||||
writes a fresh, correct block on deck load. Hence the TraktorExporter's
|
||||
`prepare_copy` and the adapter's optional `prepare_copied_audio`
|
||||
(importer copies only): ONLY a copy Konduktor wrote is touched, never a
|
||||
file referenced in place or an upload. The runners
|
||||
(`exporter.prepare_copy` / `prepare_kept`, also used by `local_push`)
|
||||
record `prepared` per copy in the manifest / push ledger, so a KEPT copy
|
||||
from an older export, or one a new Traktor target joins, is cleaned IN
|
||||
PLACE rather than copied again. Not covered: a Traktor collection
|
||||
edited directly — a tag write at Save makes the file newer than the
|
||||
entry, which by the same rule should make Traktor re-read it
|
||||
(untested). Flexible grids are a separate rule: Traktor rounds every
|
||||
segment to a whole number of beats on load, whatever the file says.
|
||||
- `adapters/rekordbox/` — **track metadata, playlists and hot cues writable;
|
||||
the beatgrid still read-only** (milestones 2 and 3a). Also home to
|
||||
`anlz_writer.py`, which BUILDS analysis files from nothing — Pioneer's format,
|
||||
@@ -1790,6 +1818,17 @@ serialization path.** It enforces:
|
||||
only that set and deletes the other's files. On a temp copy of the local
|
||||
rekordbox library (skipped when absent): merge, backup, a refused removal
|
||||
kept and reported then retried, overwrite with a stale WAL.
|
||||
- `test_traktor_file_block.py` — Traktor's block inside the file, on
|
||||
GENERATED MP3 / M4A / FLAC carrying one that says 175 while the library's
|
||||
grid says 176, with collections built from the empty Traktor skeleton:
|
||||
each format's block removed with everything else kept (audio
|
||||
sample-identical, a foreign PRIV frame, the cover, the ID3 version), a file
|
||||
without one never rewritten; an export's copies lose it while the sources
|
||||
keep it, the manifest records `prepared`, a re-export rewrites nothing, a
|
||||
kept copy from an older export is cleaned in place (same inode), a target
|
||||
without the hook (Rekordbox Export) leaves it and adding Traktor cleans the
|
||||
kept copies; a local push's shared copies and an import's copies lose it,
|
||||
a file added in place is never touched.
|
||||
- `test_auto_hotcues.py` — Auto Hotcues in three layers: `structure.analyse`
|
||||
on SYNTHETIC audio with known sections (the intro with a kick is not a drop;
|
||||
no breakdown after the last drop), `plan`'s outcomes and beat-counted offsets
|
||||
@@ -2093,6 +2132,18 @@ frontend at `http://localhost:5173`.
|
||||
`ConfirmDialog` by the `ConfirmHost` mounted once in `main.tsx`. `tone` is
|
||||
`danger` (default, pink) or `primary`. Components that already hold dialog
|
||||
state may still render `ConfirmDialog` directly.
|
||||
- **Every dialog is a `<Modal>`** (`components/Modal.tsx`; decided 2026-11-02):
|
||||
the portal, backdrop, `aria-modal`, Esc and outside click in ONE place —
|
||||
never a hand-rolled backdrop or a per-dialog Esc listener. `onDismiss` is
|
||||
what the dialog's Cancel / Close (or Hide, while a job runs) does, `null`
|
||||
while that is unavailable (busy): Esc and the backdrop then do nothing. An
|
||||
outside click closes only when the press AND the release are both on the
|
||||
backdrop — a plain `onClick` fires on the common ancestor, so a text
|
||||
selection dragged out of the dialog closed it. Esc reaches only the TOP
|
||||
modal (by opening order) and never while a menu is open. `layer="nested"`
|
||||
= `z-[60]` (a dialog opened from a dialog, QuitGuard). The one exception is
|
||||
`RelocateDialog`'s `backdropDismiss={false}` (Esc only: "Not now" lasts
|
||||
until the library is reopened).
|
||||
|
||||
## Theme — "dark liquid glass"
|
||||
|
||||
@@ -2117,7 +2168,7 @@ easy to break:
|
||||
opened far from the cursor. `.glass`'s blur and tint therefore live on its
|
||||
`::after` (z-index -1 under `isolation: isolate`), not on the panel.
|
||||
- **Every overlay renders through `createPortal(…, document.body)`** — all
|
||||
dialogs, `ContextMenu` and `Toast`. Each `.glass` panel is a stacking context
|
||||
dialogs (via `Modal`), `ContextMenu` and `Toast`. Each `.glass` panel is a stacking context
|
||||
(`isolation`), so an overlay rendered INSIDE one can never rise above a
|
||||
neighbouring panel, whatever its z-index: New Export (from the sidebar) sat
|
||||
behind the library, and the deck's Auto Hotcues dialog behind both. One
|
||||
|
||||
@@ -512,6 +512,15 @@ class TraktorAdapter:
|
||||
track uploaded there is stored as that computer would have stored it."""
|
||||
self._store.set_write_stored_paths(enabled)
|
||||
|
||||
def prepare_copied_audio(self, path: Path) -> bool:
|
||||
"""OPTIONAL: ready a file the importer just COPIED for this library —
|
||||
Traktor's own block removed (`file_block`), which Traktor would
|
||||
otherwise restore over the entry's grid. Never called for a file
|
||||
added in place."""
|
||||
from . import file_block
|
||||
|
||||
return file_block.strip(path)
|
||||
|
||||
def unresolved_path_groups(self) -> list[PathGroup]:
|
||||
return self._store.unresolved_path_groups()
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ from pathlib import Path
|
||||
from ...core.adapter import NewTrack
|
||||
from ...core.export import OTHER_PLAYLIST, ExportPayload, WrittenLibrary, write_playlist_tree
|
||||
from .adapter import TraktorAdapter
|
||||
from . import file_block
|
||||
from .capabilities import capabilities_for
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -68,6 +69,12 @@ class TraktorExporter:
|
||||
#: analysis, which overwrites only ANALYZED_DB).
|
||||
writes_auto_gain = True
|
||||
|
||||
@staticmethod
|
||||
def prepare_copy(path: Path) -> bool:
|
||||
"""Remove Traktor's own block from a copy (`file_block`): left in, it
|
||||
is restored over this entry's grid when Traktor opens the collection."""
|
||||
return file_block.strip(path)
|
||||
|
||||
def capabilities(self):
|
||||
"""What a Traktor library can hold — answered with no library to read.
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
"""Traktor's own block INSIDE an audio file, and removing it from a copy.
|
||||
|
||||
Traktor writes a binary block of its analysis into every file it tags — the
|
||||
same `DMRT` chunk tree in each format, stored where the format allows:
|
||||
|
||||
- MP4 (`.m4a`, stem files): the `ilst` atom `NITR`
|
||||
- ID3 (MP3, AIFF, WAV): a `PRIV` frame owned by `TRAKTOR4`
|
||||
- Vorbis comments (FLAC, Ogg): the field `traktor4`
|
||||
|
||||
It holds a BPM (`HBPM`), the cues (`CUEP`), the audio id, transients, tags.
|
||||
Measured in Traktor 4.5 (2026-10-24, 2MUCH / Alone (Vip)): on an entry it did
|
||||
not write itself — no MODIFIED_DATE, as every entry Konduktor creates — Traktor
|
||||
re-reads the file and takes the block's BPM over the collection's, LOCK or not,
|
||||
keeping the anchor. A grid fixed after Traktor last wrote the block (in
|
||||
Konduktor, or in Traktor without a tag write) is reverted on every export.
|
||||
|
||||
Giving the entry a MODIFIED_DATE later than the file stops that, but Traktor
|
||||
then skips the file altogether, cover art included. Giving it the block's
|
||||
AUDIO_ID changes nothing. Removing the block from the copy does both: Traktor
|
||||
imports the file as new — art, file facts and analysis from the file; BPM,
|
||||
grid, lock and cues from the entry — and writes a fresh, correct block itself
|
||||
when the track is first loaded. A stale `TBPM`/`tmpo` tag is ignored.
|
||||
|
||||
Only ever applied to a COPY Konduktor wrote. A file the user's library
|
||||
references in place is the user's, and is never touched.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
#: The ID3 PRIV owner and the Vorbis field name Traktor writes the block under.
|
||||
_PRIV_OWNER = "TRAKTOR4"
|
||||
_VORBIS_FIELD = "traktor4"
|
||||
#: The MP4 atom. mutagen keeps it among the atoms it could not parse — or, in
|
||||
#: some files, parses it into an ordinary key; both are checked.
|
||||
_MP4_ATOM = "NITR"
|
||||
|
||||
|
||||
def has_block(path: Path) -> bool:
|
||||
"""Whether the file carries Traktor's block. False for anything unreadable."""
|
||||
audio = _open(path)
|
||||
return audio is not None and bool(_remove(audio, dry_run=True))
|
||||
|
||||
|
||||
def strip(path: Path) -> bool:
|
||||
"""Remove Traktor's block from `path`, in place; True if it held one.
|
||||
|
||||
Everything else in the file is kept: other tags, cover, the stem box, the
|
||||
audio. A file without a block is not rewritten at all. A file that cannot
|
||||
be read or written is left as it is — a copy that still carries the block
|
||||
is the old behaviour, never a failed export — and the reason is logged.
|
||||
"""
|
||||
audio = _open(path)
|
||||
if audio is None or not _remove(audio, dry_run=False):
|
||||
return False
|
||||
try:
|
||||
version = getattr(audio.tags, "version", None)
|
||||
if version is not None and _is_id3(audio):
|
||||
# Keep the file's own ID3 version: nothing else in it is changing.
|
||||
audio.save(v2_version=3 if version[1] == 3 else 4)
|
||||
else:
|
||||
audio.save()
|
||||
except Exception as ex: # noqa: BLE001 — see the docstring
|
||||
log.warning("could not remove Traktor's block from %s: %s", path, ex)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _open(path: Path):
|
||||
try:
|
||||
import mutagen
|
||||
|
||||
audio = mutagen.File(path)
|
||||
except Exception as ex: # noqa: BLE001 — an unreadable file has no block we can see
|
||||
log.debug("cannot read tags of %s: %s", path, ex)
|
||||
return None
|
||||
if audio is None or audio.tags is None:
|
||||
return None
|
||||
return audio
|
||||
|
||||
|
||||
def _is_id3(audio) -> bool:
|
||||
from mutagen.id3 import ID3
|
||||
|
||||
return isinstance(audio.tags, ID3)
|
||||
|
||||
|
||||
def _remove(audio, *, dry_run: bool) -> int:
|
||||
"""How many block entries `audio`'s tags hold, removing them unless
|
||||
`dry_run`. Never saves."""
|
||||
from mutagen.mp4 import MP4Tags
|
||||
|
||||
tags = audio.tags
|
||||
found = 0
|
||||
if isinstance(tags, MP4Tags):
|
||||
failed = getattr(tags, "_failed_atoms", {})
|
||||
if _MP4_ATOM in failed:
|
||||
found += 1
|
||||
if not dry_run:
|
||||
del failed[_MP4_ATOM]
|
||||
if _MP4_ATOM in tags:
|
||||
found += 1
|
||||
if not dry_run:
|
||||
del tags[_MP4_ATOM]
|
||||
elif _is_id3(audio):
|
||||
keys = [k for k, frame in tags.items()
|
||||
if k.startswith("PRIV:") and getattr(frame, "owner", None) == _PRIV_OWNER]
|
||||
found += len(keys)
|
||||
if not dry_run:
|
||||
for k in keys:
|
||||
del tags[k]
|
||||
elif hasattr(tags, "keys"): # Vorbis comments: case-insensitive field names
|
||||
keys = [k for k in tags.keys() if k.lower() == _VORBIS_FIELD]
|
||||
found += len(keys)
|
||||
if not dry_run:
|
||||
for k in keys:
|
||||
del tags[k]
|
||||
return found
|
||||
@@ -192,6 +192,14 @@ class LibraryExporter(Protocol):
|
||||
#: destination, so this is a warning the UI raises, not a refusal: the other
|
||||
#: targets in the same export are still perfectly valid in any folder.
|
||||
drive_root: bool = False
|
||||
#: Optional, and not a protocol member so a target needs nothing to opt
|
||||
#: out: `prepare_copy(path) -> bool` readies one audio COPY for this
|
||||
#: library, in place, before its size is recorded or a library refers to
|
||||
#: it, returning True if it changed the file. Called once per copy and
|
||||
#: target (the runner records which targets have prepared it, so a kept
|
||||
#: copy is prepared when a target joins the set). Traktor's removes its
|
||||
#: own block from the file (`adapters/traktor/file_block.py`). Never
|
||||
#: called on a file a library references in place.
|
||||
|
||||
def capabilities(self) -> Capabilities:
|
||||
"""What this target can represent — STATIC, with no library to read."""
|
||||
|
||||
@@ -126,6 +126,9 @@ class PlannedTrack:
|
||||
level_outcome: str | None = None
|
||||
#: The run needs this source's loudness (it normalises, or writes auto gain).
|
||||
needs_loudness: bool = False
|
||||
#: The targets whose `prepare_copy` the copy has been through (sorted
|
||||
#: platforms; recorded in the manifest, missing = none).
|
||||
prepared: tuple[str, ...] = ()
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -321,9 +324,43 @@ def _record(planned: PlannedTrack, copy: Path) -> dict:
|
||||
# The level the copy was written at: a copy kept by a later export must
|
||||
# be at the level THAT export wants (missing = 0, every older manifest).
|
||||
"gain_db": planned.gain_db,
|
||||
# The targets that have prepared the copy (`prepare_copy`): a kept copy
|
||||
# is prepared for any target not listed (missing = none, every older
|
||||
# manifest — which is how existing exports lose Traktor's block).
|
||||
"prepared": list(planned.prepared),
|
||||
}
|
||||
|
||||
|
||||
def prepare_copy(path: Path, exporters, done=()) -> tuple[str, ...]:
|
||||
"""Run each target's optional `prepare_copy` on one copy, in place,
|
||||
skipping the targets in `done` (already prepared it). Returns every target
|
||||
that now has — `done` included, so a target leaving the set does not make
|
||||
a later one prepare the copy twice."""
|
||||
ready = set(done)
|
||||
for exporter in exporters:
|
||||
hook = getattr(exporter, "prepare_copy", None)
|
||||
if hook is None or exporter.platform in ready:
|
||||
continue
|
||||
hook(path)
|
||||
ready.add(exporter.platform)
|
||||
return tuple(sorted(ready))
|
||||
|
||||
|
||||
def prepare_kept(path: Path, planned: PlannedTrack, record: dict, exporters) -> dict:
|
||||
"""Prepare a KEPT copy for any target that has not yet (an export made
|
||||
before a target's `prepare_copy` existed, or a target new to the set), and
|
||||
the record that now describes it — the copy's size and mtime as they are
|
||||
after, so a rollback's manifest still matches the file."""
|
||||
done = record.get("prepared")
|
||||
done = tuple(done) if isinstance(done, list) else ()
|
||||
planned.prepared = prepare_copy(path, exporters, done)
|
||||
if planned.prepared == tuple(sorted(done)):
|
||||
return record
|
||||
st = path.stat()
|
||||
return {**record, "copy_size": st.st_size, "copy_mtime_ns": st.st_mtime_ns,
|
||||
"prepared": list(planned.prepared)}
|
||||
|
||||
|
||||
def _previous_copies(destination: Path) -> dict[str, tuple[Path, dict]]:
|
||||
"""The last export's copies, by SOURCE path — not by where they sit, since
|
||||
adding a track from another folder moves the shared root and with it every
|
||||
@@ -599,6 +636,10 @@ def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *,
|
||||
if reused:
|
||||
handle.progress(message=f"Keeping {len(reused)} unchanged track{'' if len(reused) == 1 else 's'}…")
|
||||
_move_kept(destination, reused, kept)
|
||||
for planned in reused:
|
||||
handle.raise_if_cancelled()
|
||||
path = Path(planned.destination)
|
||||
kept[path] = prepare_kept(path, planned, kept[path], exporters)
|
||||
|
||||
payload_tracks: list[ExportTrack] = []
|
||||
for planned in items:
|
||||
@@ -618,6 +659,7 @@ def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *,
|
||||
handle.progress(done=done)
|
||||
|
||||
write_copy(adapter, planned, partial, handle, advance)
|
||||
planned.prepared = prepare_copy(partial, exporters)
|
||||
os.replace(partial, target)
|
||||
payload_tracks.append(
|
||||
ExportTrack(
|
||||
|
||||
@@ -347,6 +347,10 @@ def run(
|
||||
# a folder on the server, instead of copied here. Nothing can be left in
|
||||
# place — the server cannot see this computer's files.
|
||||
uploads = not places and uploads_audio(dest)
|
||||
# The library's optional readying of a file copied FOR it (Traktor: its
|
||||
# own block removed from the copy). Only copies made here: never a file
|
||||
# added in place, nor an upload (written on the server).
|
||||
prepare = getattr(dest, "prepare_copied_audio", None)
|
||||
if uploads and reference and not getattr(source, "on_library_host", False):
|
||||
raise ValueError("A remote library cannot reference files on this computer")
|
||||
if not reference and not places and not uploads:
|
||||
@@ -404,6 +408,8 @@ def run(
|
||||
handle.progress(message=f"Copying {planned.title}")
|
||||
created.append(target) # registered BEFORE the write, so a cancel
|
||||
copy_file(planned.source_path, target, handle, bump) # mid-file is cleaned
|
||||
if prepare is not None:
|
||||
prepare(target)
|
||||
copied.append((planned, target))
|
||||
|
||||
handle.raise_if_cancelled()
|
||||
|
||||
@@ -86,6 +86,8 @@ from .exporter import (
|
||||
_measure_missing,
|
||||
_record,
|
||||
assign_reuse,
|
||||
prepare_copy,
|
||||
prepare_kept,
|
||||
set_level,
|
||||
write_copy,
|
||||
)
|
||||
@@ -551,10 +553,18 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
_measure_missing(adapter, built.audio, handle, store=store, level=level,
|
||||
previous=built.previous)
|
||||
items = built.audio.exportable
|
||||
# The targets' writers, for `prepare_copy` (Traktor's removes its own
|
||||
# block from the file, which it would restore over the pushed grid).
|
||||
writers = [w for w in (core_export.for_platform(t.platform) for t in built.active) if w]
|
||||
handle.progress(done=0, total=built.audio.total_bytes, unit="bytes", message="Copying…")
|
||||
for planned in items:
|
||||
handle.raise_if_cancelled()
|
||||
if planned.reuse is not None:
|
||||
# Kept: prepared for any target that has not yet. In place —
|
||||
# no target app is running (refused above), and a library
|
||||
# already holding the file re-reads its tags on its own.
|
||||
old = built.previous.get(str(planned.source_path))
|
||||
prepare_kept(planned.reuse, planned, old[1] if old else {}, writers)
|
||||
continue
|
||||
target = Path(planned.destination)
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -568,6 +578,7 @@ def run(adapter, export_set, built: PushPlan, handle: JobHandle, *, lock_grids:
|
||||
|
||||
handle.progress(message=f"Copying {planned.title}")
|
||||
write_copy(adapter, planned, partial, handle, advance)
|
||||
planned.prepared = prepare_copy(partial, writers)
|
||||
written.add(planned.track_id)
|
||||
if target.exists():
|
||||
# A library may be playing this file: it is replaced only
|
||||
|
||||
@@ -6,7 +6,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
source .venv/bin/activate
|
||||
|
||||
fail=0
|
||||
for t in test_layering.py test_save_fidelity.py test_timebase.py test_stem_file.py test_stem_swap.py test_engine_manager.py test_stems_batch.py test_stem_playback.py test_traktor_adapter.py test_rekordbox_adapter.py test_rekordbox_fidelity.py test_onelibrary_adapter.py test_onelibrary_fidelity.py test_onelibrary_anlz.py test_onelibrary_pdb.py test_onelibrary_tracks.py test_import.py test_grid_detect.py test_key_detect.py test_loudness.py test_loudness_store.py test_level_plan.py test_level_edit.py test_aac_gain.py test_normalize.py test_auto_hotcues.py test_grid_batch.py test_bulk_remove.py test_folders.py test_picker.py test_prefs.py test_relocate.py test_library_id.py test_exports.py test_export.py test_export_pioneer.py test_export_level.py test_local_push.py test_device_export.py test_phase3.py test_history.py test_discard.py test_remote_protocol.py test_remote_server.py test_remote_adapter.py test_remote_stems.py test_remote_normalize.py; do
|
||||
for t in test_layering.py test_save_fidelity.py test_timebase.py test_stem_file.py test_stem_swap.py test_engine_manager.py test_stems_batch.py test_stem_playback.py test_traktor_adapter.py test_rekordbox_adapter.py test_rekordbox_fidelity.py test_onelibrary_adapter.py test_onelibrary_fidelity.py test_onelibrary_anlz.py test_onelibrary_pdb.py test_onelibrary_tracks.py test_import.py test_grid_detect.py test_key_detect.py test_loudness.py test_loudness_store.py test_level_plan.py test_level_edit.py test_aac_gain.py test_normalize.py test_auto_hotcues.py test_grid_batch.py test_bulk_remove.py test_folders.py test_picker.py test_prefs.py test_relocate.py test_library_id.py test_exports.py test_export.py test_export_pioneer.py test_export_level.py test_local_push.py test_traktor_file_block.py test_device_export.py test_phase3.py test_history.py test_discard.py test_remote_protocol.py test_remote_server.py test_remote_adapter.py test_remote_stems.py test_remote_normalize.py; do
|
||||
echo "──────────────────────────────────────────"
|
||||
echo "▶ $t"
|
||||
echo "──────────────────────────────────────────"
|
||||
|
||||
@@ -0,0 +1,353 @@
|
||||
"""Traktor's own block inside an audio file — removed from every copy made for a
|
||||
Traktor library, so Traktor cannot restore its stale grid over the entry's.
|
||||
|
||||
Measured in Traktor 4.5 (2026-10-24, see `adapters/traktor/file_block.py`): an
|
||||
entry Konduktor wrote has no MODIFIED_DATE, so Traktor re-reads the file and
|
||||
takes the block's BPM (`HBPM`) over the collection's, LOCK or not. With the
|
||||
block removed from the copy, the entry's grid, lock, cues — and the art, which
|
||||
Traktor still imports from the file's ordinary tags — all survive.
|
||||
|
||||
Self-contained: generated audio in each format carrying a block that says 175
|
||||
while the library's grid says 176, and collections built from Konduktor's own
|
||||
empty Traktor skeleton. Pins:
|
||||
- `file_block`: each format's block found and removed, everything else in
|
||||
the file kept (audio sample-identical, other tags, a foreign PRIV frame),
|
||||
a file without one never rewritten, a garbage file refused quietly;
|
||||
- export: every copy for a Traktor target loses the block, the SOURCE keeps
|
||||
it, the manifest records `prepared`, a re-export rewrites nothing, a copy
|
||||
kept from an export made before this (no `prepared`) is cleaned IN PLACE
|
||||
rather than copied again, a target without the hook leaves the block, and
|
||||
adding Traktor to such a set cleans the kept copies;
|
||||
- local push: the shared folder's copies lose it, the ledger records it;
|
||||
- import: a copied file loses it, a file added in place is never touched.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import struct
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
os.environ["KONDUKTOR_DATA_DIR"] = tempfile.mkdtemp(prefix="konduktor-fileblock-appdata-")
|
||||
os.environ.pop("KONDUKTOR_NML", None)
|
||||
|
||||
import av # noqa: E402
|
||||
import numpy as np # noqa: E402
|
||||
import soundfile as sf # noqa: E402
|
||||
from mutagen import File as MutagenFile # noqa: E402
|
||||
from mutagen.flac import FLAC # noqa: E402
|
||||
from mutagen.id3 import APIC, ID3, PRIV, TIT2 # noqa: E402
|
||||
from mutagen.mp4 import MP4, MP4Cover # noqa: E402
|
||||
|
||||
from konduktor import exporter, exports, importer, local_push, prefs # noqa: E402
|
||||
from konduktor.adapters.traktor import file_block # noqa: E402
|
||||
from konduktor.adapters.traktor.adapter import TraktorAdapter # noqa: E402
|
||||
from konduktor.adapters.traktor.export import SKELETON # noqa: E402
|
||||
from konduktor.app_state import STATE # noqa: E402
|
||||
from konduktor.core import apps_running, pyav # noqa: E402
|
||||
from konduktor.core import export as core_export # noqa: E402
|
||||
from konduktor.core.export import ExportPayload, ExportTrack # noqa: E402
|
||||
from konduktor.core.model import GridMarker, Track, TrackCues # noqa: E402
|
||||
from konduktor.exporter import _read_manifest as read_manifest # noqa: E402
|
||||
from konduktor.jobs import JOBS # noqa: E402
|
||||
|
||||
failed = False
|
||||
ROOT = Path(tempfile.mkdtemp(prefix="konduktor-fileblock-"))
|
||||
def _jpeg() -> bytes:
|
||||
import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
buf = io.BytesIO()
|
||||
Image.new("RGB", (8, 8), (200, 40, 90)).save(buf, "JPEG")
|
||||
return buf.getvalue()
|
||||
|
||||
|
||||
JPEG = _jpeg() # a real (tiny) cover, so the exporters read it
|
||||
|
||||
|
||||
def check(label, cond, detail=""):
|
||||
global failed
|
||||
print(f" [{'PASS' if cond else 'FAIL'}] {label}" + (f" — {detail}" if detail and not cond else ""))
|
||||
if not cond:
|
||||
failed = True
|
||||
|
||||
|
||||
# ---- generated audio, each carrying a block that says 175 BPM ------------------------
|
||||
|
||||
def block(bpm: float) -> bytes:
|
||||
"""A minimal `DMRT` tree as Traktor writes it: reversed 4CCs, each chunk
|
||||
= name + payload size + child count + payload."""
|
||||
def chunk(name: str, payload: bytes, children: int = 0) -> bytes:
|
||||
return name[::-1].encode() + struct.pack("<II", len(payload), children) + payload
|
||||
data = chunk("DATA", chunk("HBPM", struct.pack("<f", bpm)), 1)
|
||||
hdr = chunk("HDR ", chunk("VRSN", struct.pack("<I", 7)), 1)
|
||||
return chunk("DMRT", hdr + data, 2)
|
||||
|
||||
|
||||
def music(seconds=6, sr=44100, seed=0):
|
||||
t = np.arange(int(sr * seconds)) / sr
|
||||
rng = np.random.default_rng(seed)
|
||||
beat = (np.sin(2 * np.pi * 2 * t) > 0.6).astype(float)
|
||||
return np.vstack([0.3 * (0.5 * np.sin(2 * np.pi * 90 * t) * beat + 0.2 * rng.standard_normal(t.size))
|
||||
for _ in range(2)]).astype(np.float32)
|
||||
|
||||
|
||||
def encode(path: Path, fmt: str, codec: str, frame: int, seed: int):
|
||||
x = music(seed=seed)
|
||||
with av.open(str(path), "w", format=fmt) as c:
|
||||
s = c.add_stream(codec, rate=44100, layout="stereo")
|
||||
s.bit_rate = 192_000
|
||||
for o in range(0, x.shape[1], frame):
|
||||
f = av.AudioFrame.from_ndarray(np.ascontiguousarray(x[:, o:o + frame]), format="fltp", layout="stereo")
|
||||
f.sample_rate, f.pts = 44100, o
|
||||
for p in s.encode(f):
|
||||
c.mux(p)
|
||||
for p in s.encode(None):
|
||||
c.mux(p)
|
||||
|
||||
|
||||
def make(path: Path, seed: int, *, with_block: bool = True) -> Path:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
ext = path.suffix
|
||||
if ext == ".mp3":
|
||||
encode(path, "mp3", "libmp3lame", 1152, seed)
|
||||
tags = ID3()
|
||||
tags.add(TIT2(encoding=3, text=path.stem))
|
||||
tags.add(APIC(encoding=3, mime="image/jpeg", type=3, desc="", data=JPEG))
|
||||
tags.add(PRIV(owner="SomeOtherApp", data=b"keep me"))
|
||||
if with_block:
|
||||
tags.add(PRIV(owner="TRAKTOR4", data=block(175.0)))
|
||||
tags.save(path, v2_version=3)
|
||||
elif ext == ".m4a":
|
||||
encode(path, "ipod", "aac", 1024, seed)
|
||||
m = MP4(path)
|
||||
if m.tags is None:
|
||||
m.add_tags()
|
||||
m.tags["\xa9nam"] = [path.stem]
|
||||
m.tags["covr"] = [MP4Cover(JPEG, imageformat=MP4Cover.FORMAT_JPEG)]
|
||||
m.save()
|
||||
if with_block:
|
||||
m = MP4(path)
|
||||
# As Traktor writes it: an atom mutagen cannot parse, kept raw.
|
||||
m.tags._failed_atoms["NITR"] = [b"\x00\x00\x00\x08NTKB" + b"\x00" * 4 + block(175.0)]
|
||||
m.save()
|
||||
elif ext == ".flac":
|
||||
sf.write(str(path), music(seed=seed).T, 44100, subtype="PCM_16")
|
||||
f = FLAC(path)
|
||||
f["title"] = path.stem
|
||||
if with_block:
|
||||
f["traktor4"] = base64.b64encode(block(175.0)).decode()
|
||||
f.save()
|
||||
return path
|
||||
|
||||
|
||||
def pcm(path: Path) -> list[np.ndarray]:
|
||||
out = []
|
||||
with pyav.open_input(str(path)) as c:
|
||||
for s in c.streams.audio:
|
||||
c.seek(0)
|
||||
out.append(np.concatenate([f.to_ndarray().ravel() for f in c.decode(s)]))
|
||||
return out
|
||||
|
||||
|
||||
def tag_keys(path: Path) -> set[str]:
|
||||
tags = MutagenFile(path).tags
|
||||
return set(tags.keys()) | set(getattr(tags, "_failed_atoms", {}))
|
||||
|
||||
|
||||
print("== file_block on each format ==")
|
||||
unit = ROOT / "unit"
|
||||
for name in ("a.mp3", "b.m4a", "c.flac"):
|
||||
src = make(unit / "src" / name, seed=1)
|
||||
copy = unit / "copy" / (name + ".konduktor-partial") # as the runners strip it
|
||||
copy.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(src, copy)
|
||||
before = tag_keys(copy)
|
||||
check(f"{name}: the block is found", file_block.has_block(copy))
|
||||
check(f"{name}: strip reports it removed one", file_block.strip(copy) is True)
|
||||
check(f"{name}: none is left", not file_block.has_block(copy))
|
||||
lost = before - tag_keys(copy)
|
||||
check(f"{name}: only the block is gone from the tags",
|
||||
len(lost) == 1 and ("TRAKTOR4" in next(iter(lost)) or next(iter(lost)) in ("NITR", "traktor4")),
|
||||
str(lost))
|
||||
check(f"{name}: the audio is sample-identical",
|
||||
all(np.array_equal(a, b) for a, b in zip(pcm(src), pcm(copy))))
|
||||
data, mtime = copy.read_bytes(), copy.stat().st_mtime_ns
|
||||
check(f"{name}: a second strip changes nothing, and does not rewrite the file",
|
||||
file_block.strip(copy) is False and copy.read_bytes() == data and copy.stat().st_mtime_ns == mtime)
|
||||
mp3 = unit / "copy" / "a.mp3.konduktor-partial"
|
||||
id3 = ID3(mp3)
|
||||
check("mp3: a foreign PRIV frame and the cover stay", "PRIV:SomeOtherApp:keep me" in id3 and id3.getall("APIC"))
|
||||
check("mp3: the file keeps its ID3 version (2.3)", id3.version[:2] == (2, 3))
|
||||
check("m4a: the cover stays", "covr" in MP4(unit / "copy" / "b.m4a.konduktor-partial").tags)
|
||||
clean = make(unit / "clean.mp3", seed=2, with_block=False)
|
||||
data, mtime = clean.read_bytes(), clean.stat().st_mtime_ns
|
||||
check("a file without a block is never rewritten",
|
||||
file_block.strip(clean) is False and clean.read_bytes() == data and clean.stat().st_mtime_ns == mtime)
|
||||
junk = unit / "junk.mp3"
|
||||
junk.write_bytes(b"ID3" + b"\xff" * 64)
|
||||
check("an unreadable file is refused quietly", file_block.strip(junk) is False and not file_block.has_block(junk))
|
||||
|
||||
|
||||
# ---- a source library whose grids (176) disagree with the files' blocks (175) ---------
|
||||
|
||||
lib_root = ROOT / "MyMusic"
|
||||
files = [make(lib_root / "DnB" / n, seed=i) for i, n in enumerate(("one.mp3", "two.m4a", "three.flac"))]
|
||||
files.append(make(lib_root / "DnB" / "plain.mp3", seed=9, with_block=False))
|
||||
seed = []
|
||||
for i, path in enumerate(files):
|
||||
track = Track(id=f"seed{i}", title=path.stem, artist="Test")
|
||||
cues = TrackCues(grid_markers=[GridMarker(start=0.25, bpm=176.0)], grid_locked=True)
|
||||
seed.append(ExportTrack(track=track, destination=path, cues=cues))
|
||||
core_export.for_platform("traktor").write(
|
||||
ExportPayload(name="Source", tracks=seed, playlists=[], root_folder=True), lib_root)
|
||||
source_bytes = {p: p.read_bytes() for p in files}
|
||||
STATE.open(lib_root / "collection.nml")
|
||||
ad = STATE.adapter
|
||||
LIB = STATE.library_id
|
||||
ids = [t.id for t in ad.tracks]
|
||||
check("the source library holds the four tracks", len(ids) == 4, str(ids))
|
||||
|
||||
|
||||
def run_job(kind, fn):
|
||||
job = JOBS.submit(kind, fn)
|
||||
while not job.finished:
|
||||
time.sleep(0.02)
|
||||
assert job.error is None, job.error
|
||||
return job.result
|
||||
|
||||
|
||||
def copies(dest: Path) -> dict[str, Path]:
|
||||
return {p.name: p for p in (dest / "Contents").rglob("*") if p.is_file() and not p.name.startswith(".")}
|
||||
|
||||
|
||||
def records(dest: Path) -> dict[str, dict]:
|
||||
return {Path(rel).name: r for rel, r in (read_manifest(dest).get("audio") or {}).items()}
|
||||
|
||||
|
||||
def bpms(nml: Path) -> dict[str, float]:
|
||||
a = TraktorAdapter(nml)
|
||||
return {Path(a.audio_path(t.id)).name: a.track_cues(t.id).grid_markers[0].bpm for t in a.tracks}
|
||||
|
||||
|
||||
print("== an export to Traktor ==")
|
||||
dest = ROOT / "GIG"
|
||||
gig = exports.create(LIB, name="GIG", targets=["traktor"], destination=str(dest))
|
||||
exports.add(LIB, gig.id, track_ids=ids)
|
||||
gig = exports.get(LIB, gig.id)
|
||||
run_job("export", lambda h: exporter.run(ad, gig, exporter.plan(ad, gig), h))
|
||||
out = copies(dest)
|
||||
check("every track was copied", set(out) == {p.name for p in files}, str(sorted(out)))
|
||||
check("no copy carries Traktor's block", not any(file_block.has_block(p) for p in out.values()))
|
||||
check("the SOURCE files are untouched", all(p.read_bytes() == b for p, b in source_bytes.items()))
|
||||
check("a file that had no block is copied byte for byte", out["plain.mp3"].read_bytes() == source_bytes[files[3]])
|
||||
check("the covers are still in the copies",
|
||||
ID3(out["one.mp3"]).getall("APIC") and "covr" in MP4(out["two.m4a"]).tags)
|
||||
recs = records(dest)
|
||||
check("the manifest records each copy as prepared for Traktor",
|
||||
all(r.get("prepared") == ["traktor"] for r in recs.values()), str(recs))
|
||||
check("and records the copy's size as it is now (after the strip)",
|
||||
all(r["copy_size"] == out[n].stat().st_size for n, r in recs.items()))
|
||||
check("the exported grids are the library's (176)", all(abs(b - 176.0) < 0.01 for b in bpms(dest / "collection.nml").values()))
|
||||
|
||||
print("== a re-export rewrites nothing ==")
|
||||
stamp = {n: (p.stat().st_ino, p.stat().st_mtime_ns) for n, p in out.items()}
|
||||
run_job("export", lambda h: exporter.run(ad, gig, exporter.plan(ad, gig), h))
|
||||
check("every copy kept as it was (same inode, same mtime)",
|
||||
{n: (p.stat().st_ino, p.stat().st_mtime_ns) for n, p in copies(dest).items()} == stamp)
|
||||
|
||||
print("== a copy kept from an export made before this fix is cleaned in place ==")
|
||||
# Put the block back into one copy and drop `prepared`, as an older export's
|
||||
# manifest and stick would be — the record matching the file, so it is kept.
|
||||
old_copy = copies(dest)["one.mp3"]
|
||||
tags = ID3(old_copy)
|
||||
tags.add(PRIV(owner="TRAKTOR4", data=block(175.0)))
|
||||
tags.save(old_copy, v2_version=3)
|
||||
manifest = read_manifest(dest)
|
||||
for rel, r in manifest["audio"].items():
|
||||
r.pop("prepared", None)
|
||||
if Path(rel).name == "one.mp3":
|
||||
st = old_copy.stat()
|
||||
r["copy_size"], r["copy_mtime_ns"] = st.st_size, st.st_mtime_ns
|
||||
exporter.manifest_path(dest).write_text(json.dumps(manifest))
|
||||
inode = old_copy.stat().st_ino
|
||||
again = exporter.plan(ad, gig)
|
||||
check("the old copy is planned as KEPT, not copied again",
|
||||
next(t for t in again.exportable if t.destination.name == "one.mp3").reuse is not None)
|
||||
run_job("export", lambda h: exporter.run(ad, gig, again, h))
|
||||
cleaned = copies(dest)["one.mp3"]
|
||||
check("its block is gone", not file_block.has_block(cleaned))
|
||||
check("in place: the same file, not a new copy", cleaned.stat().st_ino == inode)
|
||||
check("every record says prepared again", all(r.get("prepared") == ["traktor"] for r in records(dest).values()))
|
||||
check("and the next export keeps it as it is",
|
||||
next(t for t in exporter.plan(ad, gig).exportable if t.destination.name == "one.mp3").reuse is not None)
|
||||
|
||||
print("== a target without the hook leaves the block; adding Traktor cleans the kept copies ==")
|
||||
pdest = ROOT / "PIONEER"
|
||||
pio = exports.create(LIB, name="PIONEER", targets=["rekordbox_export"], destination=str(pdest))
|
||||
exports.add(LIB, pio.id, track_ids=ids)
|
||||
pio = exports.get(LIB, pio.id)
|
||||
run_job("export", lambda h: exporter.run(ad, pio, exporter.plan(ad, pio), h))
|
||||
pout = copies(pdest)
|
||||
check("a Rekordbox Export's copies keep Traktor's block (none of its business)",
|
||||
file_block.has_block(pout["one.mp3"]) and file_block.has_block(pout["two.m4a"]))
|
||||
check("and are recorded as prepared by nobody", all(r.get("prepared") == [] for r in records(pdest).values()))
|
||||
inodes = {n: p.stat().st_ino for n, p in pout.items()}
|
||||
pio = exports.update(LIB, pio.id, targets=["rekordbox_export", "traktor"])
|
||||
run_job("export", lambda h: exporter.run(ad, pio, exporter.plan(ad, pio), h))
|
||||
pout = copies(pdest)
|
||||
check("with Traktor added, no copy carries the block", not any(file_block.has_block(p) for p in pout.values()))
|
||||
check("cleaned in place, none copied again", {n: p.stat().st_ino for n, p in pout.items()} == inodes)
|
||||
check("recorded as prepared for Traktor", all(r.get("prepared") == ["traktor"] for r in records(pdest).values()))
|
||||
|
||||
print("== a local push into this computer's Traktor ==")
|
||||
laptop = ROOT / "laptop" / "collection.nml"
|
||||
laptop.parent.mkdir(parents=True)
|
||||
laptop.write_text(SKELETON, encoding="utf-8")
|
||||
AUDIO = ROOT / "LocalAudio"
|
||||
apps_running.running = lambda platforms: set()
|
||||
prefs.update_prefs({"localLibraries": {"traktor": str(laptop), "rekordbox": str(ROOT / "none" / "master.db")},
|
||||
"localAudioRoot": str(AUDIO), "localNormalise": False})
|
||||
push = exports.create(LIB, name="Push", targets=["traktor"], destination="", kind="computer", mode="merge")
|
||||
exports.add(LIB, push.id, track_ids=ids)
|
||||
push = exports.get(LIB, push.id)
|
||||
built = local_push.plan(ad, push)
|
||||
check("the push can run", built.blocked is None, str(built.blocked))
|
||||
run_job("local-push", lambda h: local_push.run(ad, push, built, h))
|
||||
pushed = {p.name: p for p in AUDIO.rglob("*") if p.is_file() and p.suffix in (".mp3", ".m4a", ".flac")}
|
||||
check("every track's copy is in the shared folder", set(pushed) == {p.name for p in files}, str(sorted(pushed)))
|
||||
check("none of them carries Traktor's block", not any(file_block.has_block(p) for p in pushed.values()))
|
||||
ledger = local_push._read_ledger()["audio"][str(AUDIO)]
|
||||
check("the ledger records them as prepared for Traktor",
|
||||
all(r.get("prepared") == ["traktor"] for r in ledger.values()), str(ledger))
|
||||
check("the laptop's collection has the library's grids (176)",
|
||||
all(abs(b - 176.0) < 0.01 for b in bpms(laptop).values()), str(bpms(laptop)))
|
||||
check("the SOURCE files are still untouched", all(p.read_bytes() == b for p, b in source_bytes.items()))
|
||||
|
||||
print("== an import into a Traktor collection ==")
|
||||
into = ROOT / "into" / "collection.nml"
|
||||
into.parent.mkdir(parents=True)
|
||||
into.write_text(SKELETON, encoding="utf-8")
|
||||
dest_ad = TraktorAdapter(into)
|
||||
folder = ROOT / "into" / "Imported"
|
||||
run_job("import", lambda h: importer.run(ad, dest_ad, importer.plan(ad, dest_ad, folder, track_ids=ids[:2]), h))
|
||||
imported = [p for p in folder.rglob("*") if p.is_file()]
|
||||
check("the copied files arrived", len(imported) == 2, str(imported))
|
||||
check("and carry no block", imported and not any(file_block.has_block(p) for p in imported))
|
||||
ref = ROOT / "ref" / "collection.nml"
|
||||
ref.parent.mkdir(parents=True)
|
||||
ref.write_text(SKELETON, encoding="utf-8")
|
||||
ref_ad = TraktorAdapter(ref)
|
||||
run_job("import", lambda h: importer.run(ad, ref_ad, importer.plan(ad, ref_ad, None, track_ids=ids[:2]), h,
|
||||
reference=True))
|
||||
check("a file added IN PLACE is never touched", all(p.read_bytes() == b for p, b in source_bytes.items()))
|
||||
check("so it keeps its block (it is the user's file)", file_block.has_block(files[0]))
|
||||
|
||||
shutil.rmtree(ROOT, ignore_errors=True)
|
||||
print("\nALL PASS" if not failed else "\nSOME CHECKS FAILED")
|
||||
raise SystemExit(1 if failed else 0)
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.3.5",
|
||||
"version": "0.3.6",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, isServerPath, type FolderAddPreview, type FolderAddRequest, type JobStatus, type TrackOrigin } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Add browsed files to the collection — and, optionally, to a playlist or export.
|
||||
@@ -253,7 +253,7 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
</label>
|
||||
)
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -267,10 +267,7 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
>
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">{title}</h2>
|
||||
@@ -461,9 +458,8 @@ export function AddFilesDialog({ trackIds, target: requested, note, onClose, onD
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type AnalyzeOptions, type AnalyzePreview, type TrackOrigin } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
/** The selected tracks. */
|
||||
@@ -100,12 +100,6 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
const nothingTicked = !!what && !(what.bpm || what.grid || what.key || what.loudness || what.gain)
|
||||
const count = nothingTicked ? 0 : (p?.tracks_to_analyze ?? 0)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const run = async () => {
|
||||
if (!opts || busy || count === 0) return
|
||||
setBusy(true)
|
||||
@@ -186,13 +180,9 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
if (p.grid_locked) gridLines.push(<div key="lk" className="text-faint">{plural(p.grid_locked, 'locked grid')} — skipped</div>)
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Analyze</div>
|
||||
<div className="text-xs text-muted">{plural(ids.length, 'track')} selected</div>
|
||||
@@ -265,7 +255,6 @@ export function AnalyzeDialog({ ids, origin, gridWhy, keyWhy, gainWhy, preset, o
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Konduktor: preferences about the app itself rather than about a
|
||||
@@ -42,12 +42,6 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
const levelCeiling = useAppSetting('levelCeiling')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const set = async (patch: Partial<typeof APP_SETTING_DEFAULTS>) => {
|
||||
setError(null)
|
||||
try {
|
||||
@@ -57,13 +51,9 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay">
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Konduktor settings</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -166,8 +156,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
type Track,
|
||||
} from '../api'
|
||||
import { formatDuration } from '../lib/format'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Auto Hotcues: bind each hotcue slot to a structural event plus an offset in
|
||||
@@ -109,14 +109,6 @@ export function AutoCueDialog(props: Props) {
|
||||
if (rows === null && (prefs.data || prefs.isError)) setRows(loadTemplate(prefs.data, slotCount))
|
||||
}, [prefs.data, prefs.isError, rows, slotCount])
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) onClose()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const setRow = (i: number, patch: Partial<Row>) =>
|
||||
setRows((rs) => rs && rs.map((r, j) => (j === i ? { ...r, ...patch } : r)))
|
||||
const nudge = (i: number, by: number) =>
|
||||
@@ -152,11 +144,10 @@ export function AutoCueDialog(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6" onClick={() => !busy && onClose()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Auto Hotcues</div>
|
||||
@@ -294,7 +285,6 @@ export function AutoCueDialog(props: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
export interface ConfirmRequest {
|
||||
title: string
|
||||
@@ -42,7 +42,6 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) onClose()
|
||||
// A focused button handles its own Enter — otherwise tabbing to Cancel
|
||||
// and pressing Enter would run the destructive action.
|
||||
if (e.key === 'Enter' && !(e.target instanceof HTMLButtonElement)) {
|
||||
@@ -54,16 +53,9 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div
|
||||
className="w-full max-w-sm overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
{title}
|
||||
</div>
|
||||
@@ -101,7 +93,6 @@ export function ConfirmDialog({ title, body, confirmLabel, tone = 'danger', altL
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { useServerFolder } from './AddFilesDialog'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Convert to Stems — one dialog (decided, see the stem-conversion discussion
|
||||
@@ -224,7 +224,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
)
|
||||
|
||||
const count = trackIds.length
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && opts && (
|
||||
<FolderPicker
|
||||
@@ -239,11 +239,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
onKeyDown={(e) => e.key === 'Escape' && !starting && onClose()}
|
||||
>
|
||||
<Modal onDismiss={starting ? null : onClose} padding="p-4">
|
||||
<div className="flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -477,8 +473,7 @@ export function ConvertStemsDialog({ trackIds, onClose, onStarted, onDownloading
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type Track } from '../api'
|
||||
@@ -7,6 +6,7 @@ import { useCaps } from '../lib/capabilities'
|
||||
import { RatingStars } from './RatingStars'
|
||||
import { writeHint } from '../lib/platformCopy'
|
||||
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
track: Track
|
||||
@@ -96,14 +96,10 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
|
||||
apply.mutate()
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Edit Tags</div>
|
||||
@@ -240,7 +236,6 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api, type ExportSet, type LocalLibrary } from '../api'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Create or edit an export: its name, its target platforms and where it lands.
|
||||
@@ -119,7 +119,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -128,7 +128,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -336,8 +336,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ExportPreview, type ExportRunOptions, type ExportSet, type JobStatus, type NormalizeOptions } from '../api'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Run an export: confirm what is about to happen, then watch it happen.
|
||||
@@ -175,7 +175,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
: null
|
||||
const blocked = p?.blocked ?? null
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -184,7 +184,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Export “{set.name}”</h2>
|
||||
@@ -472,9 +472,8 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { FileBrowser, useFsListing, type Listing } from './FileBrowser'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Pick a FOLDER, by browsing.
|
||||
@@ -33,8 +33,8 @@ export function FolderPicker({ value, onChange, onClose, listing = 'host' }: Pro
|
||||
onClose()
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
return (
|
||||
<Modal onDismiss={onClose} layer="nested" padding="p-4">
|
||||
<div className="flex h-[70vh] w-full max-w-2xl flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Choose a folder</h2>
|
||||
@@ -84,7 +84,6 @@ export function FolderPicker({ value, onChange, onClose, listing = 'host' }: Pro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type HistoryEntry } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { restoreWarning } from '../lib/platformCopy'
|
||||
import type { ToastMsg } from './Toast'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -79,14 +79,10 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
|
||||
|
||||
const entries = history.data ?? []
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Version History</div>
|
||||
@@ -208,7 +204,6 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ImportPreview, type JobStatus } from '../api'
|
||||
@@ -7,6 +6,7 @@ import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import type { AddTarget } from './AddFilesDialog'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { useServerImportFolder, usePlaylistToggle } from './AddFilesDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Import a browsed device into the loaded collection.
|
||||
@@ -173,7 +173,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
const finished = job != null && job.state !== 'running'
|
||||
const pct = job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{browsing && (
|
||||
<FolderPicker
|
||||
@@ -187,7 +187,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
onClose={() => setBrowsing(false)}
|
||||
/>
|
||||
)}
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -373,8 +373,7 @@ export function ImportDialog({ playlistId, trackIds, target: requested, deviceLa
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type NormalizeOptions } from '../api'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Local libraries: where a "This computer" set is pushed.
|
||||
@@ -32,12 +32,6 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
const [picking, setPicking] = useState<string | null>(null) // a platform, or 'audio'
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !picking && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose, picking])
|
||||
|
||||
const p = prefs.data ?? {}
|
||||
const overrides = (p.localLibraries as Record<string, string | null> | undefined) ?? {}
|
||||
const normalise = p.localNormalise === true
|
||||
@@ -74,17 +68,13 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
? d?.audio_root ?? ''
|
||||
: (d?.libraries.find((l) => l.platform === picking)?.path ?? '').replace(/[\\/][^\\/]*$/, '')
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{picking && (
|
||||
<FolderPicker value={pickerValue} onChange={choose} onClose={() => setPicking(null)} />
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex max-h-full w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex max-h-full w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Local libraries</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -198,8 +188,7 @@ export function LocalLibrariesSettings({ onClose }: { onClose: () => void }) {
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type AriaRole, type ReactNode } from 'react'
|
||||
|
||||
// Open modals by opening order (taken at first render, so a dialog opened
|
||||
// from another always ranks above it). Esc is answered by the top one only.
|
||||
const open = new Set<number>()
|
||||
let opened = 0
|
||||
|
||||
const menuOpen = () => document.querySelector('[role="menu"]') != null
|
||||
|
||||
interface Props {
|
||||
/** What Esc and a click on the backdrop do: the dialog's Cancel / Close.
|
||||
* `null` while that is not available (a run in progress), so neither
|
||||
* can close the dialog when its own Cancel could not. */
|
||||
onDismiss: (() => void) | null
|
||||
/** `false`: Esc only. For a dialog whose dismissal decides something a
|
||||
* stray click should not (RelocateDialog). */
|
||||
backdropDismiss?: boolean
|
||||
/** `nested` for a dialog opened from a dialog or above every other one. */
|
||||
layer?: 'dialog' | 'nested'
|
||||
/** The backdrop's padding (default `p-6`). */
|
||||
padding?: string
|
||||
role?: AriaRole
|
||||
'aria-label'?: string
|
||||
'aria-labelledby'?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
/** The ONE modal container: portal, dimmed backdrop, Esc and outside click.
|
||||
*
|
||||
* An outside click closes only when the press AND the release are both on
|
||||
* the backdrop. A `click` alone fires on the nearest common ancestor, so a
|
||||
* text selection started inside the dialog and released outside it used to
|
||||
* land on the backdrop and close the dialog. */
|
||||
export function Modal({
|
||||
onDismiss,
|
||||
backdropDismiss = true,
|
||||
layer = 'dialog',
|
||||
padding = 'p-6',
|
||||
role,
|
||||
children,
|
||||
...aria
|
||||
}: Props) {
|
||||
const [id] = useState(() => ++opened)
|
||||
const dismissRef = useRef(onDismiss)
|
||||
dismissRef.current = onDismiss
|
||||
|
||||
useEffect(() => {
|
||||
open.add(id)
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key !== 'Escape' || e.defaultPrevented) return
|
||||
if (id !== Math.max(...open)) return
|
||||
// A menu over the dialog closes itself on Esc; the dialog stays.
|
||||
if (menuOpen()) return
|
||||
const dismiss = dismissRef.current
|
||||
if (!dismiss) return
|
||||
e.preventDefault()
|
||||
dismiss()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => {
|
||||
open.delete(id)
|
||||
window.removeEventListener('keydown', onKey)
|
||||
}
|
||||
}, [id])
|
||||
|
||||
const pressed = useRef(false)
|
||||
const released = useRef(false)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
role={role}
|
||||
{...aria}
|
||||
className={`fixed inset-0 ${layer === 'nested' ? 'z-[60]' : 'z-50'} flex items-center justify-center bg-black/40 backdrop-blur-[3px] ${padding}`}
|
||||
// React bubbles events through portals, so a nested dialog's or menu's
|
||||
// pointer events reach here too; `target === currentTarget` keeps only
|
||||
// the ones on THIS backdrop.
|
||||
onPointerDown={(e) => {
|
||||
// A press that closes an open menu closes only the menu.
|
||||
pressed.current = e.target === e.currentTarget && e.button === 0 && !menuOpen()
|
||||
released.current = false
|
||||
}}
|
||||
onPointerUp={(e) => {
|
||||
released.current = e.target === e.currentTarget
|
||||
}}
|
||||
onClick={(e) => {
|
||||
const outside = pressed.current && released.current && e.target === e.currentTarget
|
||||
pressed.current = released.current = false
|
||||
if (outside && backdropDismiss) dismissRef.current?.()
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query'
|
||||
import { api, type NormalizeOptions, type NormalizePreview, type NormalizeRow } from '../api'
|
||||
import { LevelInput, useAppSetting } from './AppSettings'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
ids: string[]
|
||||
@@ -58,12 +58,6 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
const p: NormalizePreview | undefined = preview.data
|
||||
const count = p?.tracks_to_process ?? 0
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [busy, onClose])
|
||||
|
||||
const summary = useMemo(() => {
|
||||
if (!p) return []
|
||||
const rows = p.rows
|
||||
@@ -105,13 +99,9 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
|
||||
const measureUnit = opts?.measure === 'rms' ? 'dB' : 'LUFS'
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={() => !busy && onClose()}
|
||||
>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : onClose}>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Normalize</div>
|
||||
<div className="text-xs text-muted">
|
||||
@@ -198,7 +188,6 @@ export function NormalizeDialog({ ids, onRun, onClose, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type RemapPreview } from '../api'
|
||||
import type { ToastMsg } from './Toast'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -107,14 +107,10 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
||||
const collides = (preview?.collisions ?? 0) > 0
|
||||
const canCommit = !!from.trim() && !!to.trim() && !collides
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Path Remapping</div>
|
||||
@@ -264,8 +260,7 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ExportRunOptions, type ExportSet, type JobStatus, type PushPreview, type PushTarget } from '../api'
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { localLibraryProblem } from '../lib/platformCopy'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Push a "computer" set into this computer's Traktor / rekordbox: confirm what
|
||||
@@ -136,8 +136,8 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
job?.state === 'done' ? 100 : job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
|
||||
const results = ((job?.result as { targets?: TargetResult[] } | null)?.targets ?? [])
|
||||
|
||||
return createPortal(
|
||||
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="w-full max-w-lg glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">
|
||||
@@ -323,8 +323,7 @@ export function PushRunDialog({ set, onClose, onDone, onError }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { flushPrefs } from '../lib/prefs'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Ask before quitting with unsaved changes: Save · Discard · Cancel.
|
||||
@@ -99,21 +99,9 @@ export function QuitGuard() {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!asking) return
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !busy) void cancel()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
if (!asking) return null
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : () => void cancel()} layer="nested">
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
Save changes before quitting?
|
||||
@@ -147,7 +135,6 @@ export function QuitGuard() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { api, type PathMapping, type RelocationVolume } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
volumes: RelocationVolume[]
|
||||
@@ -51,21 +51,12 @@ export function RelocateDialog({ volumes, onAnswered, onOpenManual, onError }: P
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !busy && answer([])
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
const set = (root: string, to: string | null) => setChoice((c) => ({ ...c, [root]: to }))
|
||||
|
||||
return createPortal(
|
||||
// No close on a backdrop click: dismissing lasts until the library is
|
||||
// reopened, which is too much for a stray click to decide.
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
>
|
||||
return (
|
||||
// Esc is "Not now", but a backdrop click is not: dismissing lasts until
|
||||
// the library is reopened, which is too much for a stray click to decide.
|
||||
<Modal onDismiss={busy ? null : () => void answer([])} backdropDismiss={false}>
|
||||
<div className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Tracks not found</div>
|
||||
@@ -116,8 +107,7 @@ export function RelocateDialog({ volumes, onAnswered, onOpenManual, onError }: P
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { size } from './ConvertStemsDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Remote audio: this computer's copies of a remote library's audio.
|
||||
@@ -21,12 +21,6 @@ export function RemoteCacheSettings({ onClose }: { onClose: () => void }) {
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const u = usage.data
|
||||
const capGb = u ? Math.round(u.cap / 1024 ** 3) : null
|
||||
|
||||
@@ -54,13 +48,9 @@ export function RemoteCacheSettings({ onClose }: { onClose: () => void }) {
|
||||
}
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay">
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Remote audio</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
@@ -107,7 +97,6 @@ export function RemoteCacheSettings({ onClose }: { onClose: () => void }) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
api,
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { remoteHolder } from '../lib/platformCopy'
|
||||
import { Modal } from './Modal'
|
||||
import { OptionCard } from './OptionCard'
|
||||
|
||||
/**
|
||||
@@ -329,12 +329,8 @@ function PendingEditsDialog({
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onKeyDown={(e) => e.key === 'Escape' && !busy && void choose('later')}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : () => void choose('later')}>
|
||||
<div className="w-full max-w-sm overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-4 text-[15px] font-semibold tracking-tight">
|
||||
Unsaved edits from {edits.machine || 'another computer'}
|
||||
@@ -369,7 +365,6 @@ function PendingEditsDialog({
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import type { SortingState } from '@tanstack/react-table'
|
||||
import { maxPosition, moveToPosition } from '../lib/playlistOrder'
|
||||
import { COLUMN_MENU } from '../lib/trackColumns'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
/** The playlist's full entry order — never the sorted or filtered view, so
|
||||
@@ -50,14 +50,6 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
onClose()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') onClose()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const option = (value: 'playlist' | 'sorted', label: string, detail: ReactNode) => (
|
||||
<label
|
||||
className={`flex cursor-pointer gap-3 rounded-lg px-3 py-2 ${
|
||||
@@ -80,15 +72,10 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
|
||||
const span = (p: number) => (count > 1 ? `#${p}–${p + count - 1}` : `#${p}`)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<form
|
||||
className="w-full max-w-sm overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
submit()
|
||||
@@ -152,7 +139,6 @@ export function SetPositionDialog({ order, ids, sorting, onMove, onClose }: Prop
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Icon } from '../lib/icons'
|
||||
@@ -24,6 +23,7 @@ import {
|
||||
type Layer,
|
||||
type MouseGesture,
|
||||
} from '../lib/shortcuts'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
onClose: () => void
|
||||
@@ -162,15 +162,10 @@ export function ShortcutsDialog({ onClose }: Props) {
|
||||
onPick: pickLayer,
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-full w-full max-w-[960px] flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-3 border-b border-line py-3.5 pl-5 pr-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">Keyboard Shortcuts</div>
|
||||
@@ -309,8 +304,7 @@ export function ShortcutsDialog({ onClose }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect } from 'react'
|
||||
import type { StemBatchResult } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* The Details behind a finished conversion's toast: every track that was
|
||||
@@ -8,24 +7,14 @@ import type { StemBatchResult } from '../api'
|
||||
* into a toast).
|
||||
*/
|
||||
export function StemReportDialog({ result, onClose }: { result: StemBatchResult; onClose: () => void }) {
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const rows = [
|
||||
...result.failed.map((s) => ({ ...s, failed: true })),
|
||||
...result.skipped.map((s) => ({ ...s, failed: false })),
|
||||
]
|
||||
const n = result.converted.length
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay" onClick={(e) => e.stopPropagation()}>
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4">
|
||||
<div className="flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden glass-overlay">
|
||||
<div className="border-b border-line px-5 py-3 text-sm font-semibold text-text">
|
||||
{n} converted to stems · {result.skipped.length} skipped · {result.failed.length} failed
|
||||
</div>
|
||||
@@ -49,7 +38,6 @@ export function StemReportDialog({ result, onClose }: { result: StemBatchResult;
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type StemTarget } from '../api'
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
import { size } from './ConvertStemsDialog'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Settings → Stems (decided contents): the engine (status, download, install
|
||||
@@ -40,12 +40,6 @@ export function StemsSettings({ onClose }: Props) {
|
||||
}
|
||||
}, [install.data, qc])
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && !picking && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose, picking])
|
||||
|
||||
const act = async (fn: () => Promise<unknown>) => {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
@@ -72,7 +66,7 @@ export function StemsSettings({ onClose }: Props) {
|
||||
const targetLabel = (t: StemTarget) =>
|
||||
t === 'macos-arm64' ? 'Apple silicon (GPU)' : t === 'windows-x64-cuda' ? 'NVIDIA GPU' : 'processor only'
|
||||
|
||||
return createPortal(
|
||||
return (
|
||||
<>
|
||||
{picking && (
|
||||
<FolderPicker
|
||||
@@ -81,14 +75,9 @@ export function StemsSettings({ onClose }: Props) {
|
||||
onClose={() => setPicking(null)}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
aria-modal="true"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-6 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
<Modal onDismiss={onClose}>
|
||||
<div
|
||||
className="flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Stems</h2>
|
||||
@@ -241,8 +230,7 @@ export function StemsSettings({ onClose }: Props) {
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
document.body,
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import type { Track } from '../api'
|
||||
import { formatBpm, formatDuration, keyColor } from '../lib/format'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { RatingStars } from './RatingStars'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
interface Props {
|
||||
track: Track
|
||||
@@ -27,12 +27,6 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
const [artFailed, setArtFailed] = useState(false)
|
||||
const showArt = artUrl != null && !artFailed
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const grid =
|
||||
track.grid_marker_count === 0
|
||||
? null
|
||||
@@ -60,17 +54,10 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
] as [string, ReactNode][]
|
||||
).filter(([, v]) => v != null && v !== '')
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true"
|
||||
role="dialog"
|
||||
aria-label={track.title ?? 'Track info'}
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 backdrop-blur-[3px]"
|
||||
onClick={onClose}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={onClose} padding="p-4" role="dialog" aria-label={track.title ?? 'Track info'}>
|
||||
<div
|
||||
className="track-info-pop glass-overlay flex max-h-[90vh] w-full max-w-[860px] flex-col overflow-hidden sm:flex-row"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* The sleeve, bled into the card behind everything: a soft wash of the
|
||||
art's own colours. `filter` on this leaf is safe — nothing can open
|
||||
@@ -166,8 +153,7 @@ export function TrackInfoDialog({ track, artUrl, onClose, onEditTags }: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { Modal } from './Modal'
|
||||
|
||||
/**
|
||||
* Startup update check against GitHub Releases.
|
||||
@@ -285,14 +285,10 @@ export function UpdateCheck() {
|
||||
const sections = newer.map((r) => ({ tag: r.tag_name, changes: whatsChanged(r.body) }))
|
||||
const grouped = sections.length > 1
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
|
||||
onClick={close}
|
||||
>
|
||||
return (
|
||||
<Modal onDismiss={busy ? null : close}>
|
||||
<div
|
||||
className="flex max-h-[80vh] w-full max-w-md flex-col overflow-hidden glass-overlay"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<div className="border-b border-line px-5 py-4">
|
||||
<div className="text-[15px] font-semibold tracking-tight">{title}</div>
|
||||
@@ -418,7 +414,6 @@ export function UpdateCheck() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user