Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import type { ChartSourceKind, LibraryChart, LibraryFolder } from '@be-music/player-scene-model';
import type { BrowserDroppedFile } from './dropped-file.ts';
/**
* Asset payload kept inside a {@link BrowserAssetSource}. Each file from the dropped bundle is either:
*
* - **`Uint8Array`** — bytes already in memory. Used for small files that are accessed synchronously by parsers / image
* decoders (`.bms`, `.bmson`, `.bmp`, `.png`, `.tga`, `.csv`, `.dxa`, `.lr2skin`, …).
* - **`File` / `DeferredDroppedFile`** — lazy reference. The bytes haven't been materialized yet and will be read on
* demand via `loadAssetBytes`; a `DeferredDroppedFile` from a folder drop hasn't even been opened yet. Used for audio (`.wav`, `.ogg`, `.mp3`, `.opus`, `.flac`, `.oga`) where a single drop can carry
* gigabytes of WAV samples that are only needed for the currently-playing chart.
*
* Consumers that always hand a non-audio path call the existing sync helpers and receive the `Uint8Array` branch by
* construction. Audio consumers go through `loadAssetBytes` / `resolveChartAudioAsset` to handle the lazy branch
* transparently.
*/
export type BrowserAssetEntry = Uint8Array | BrowserDroppedFile;
export interface BrowserAssetSource {
id: string;
kind: ChartSourceKind;
label: string;
files: ReadonlyMap<string, BrowserAssetEntry>;
/** Composite charts retain each stage's ordered codec/folder candidates under the stitched resource path. */
audioFallbacks?: ReadonlyMap<string, readonly BrowserAssetEntry[]>;
}
/** The charts loaded from every dropped source: a `Library` of `@be-music/player-scene-model` a select screen browses. */
export interface BrowserChartCollection {
sources: BrowserAssetSource[];
charts: LibraryChart[];
errors: Array<{ sourceId: string; path?: string; message: string }>;
/** Course folders (see `resolveCourseFolders`), listed after the chart folders at the root of a select view. */
courseFolders?: LibraryFolder[];
}
/**
* Phases reported by the dropped-folder loaders so a host UI can show a meaningful "Loading…" state instead of a frozen
* unresponsive screen.
*
* - `enumerating` — walking the dropped FileSystem entries to collect every nested file. Total is unknown while
* walking, so `total` is `-1` and `current` ticks upward.
* - `reading` — slurping each collected `File` into a `Uint8Array`. This is the dominant cost for large zip / folder
* drops.
* - `parsing` — running `parseBMS` / `parseBmson` on each chart file inside the source, building `LibraryChart`s.
* - `theme` — loading the LR2 theme bundle (skins + BGM + system sounds). Theme work happens in parallel internally;
* events fire as each sub-task lands so the bar still moves.
*/
export type LoadProgressPhase = 'enumerating' | 'reading' | 'parsing' | 'theme';
export interface LoadProgress {
phase: LoadProgressPhase;
/** 1-based "items completed so far" — 0 when the phase starts. */
current: number;
/** Expected total. `-1` while still being discovered. */
total: number;
/** Friendly per-item label (filename / sub-task) for the UI. */
label?: string;
}
export type LoadProgressCallback = (progress: LoadProgress) => void;
|