@open-orpheus/plugin-api 0.0.0-stage → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +191 -2
- package/dist/client/index.d.ts +37 -0
- package/dist/client/index.js +53 -0
- package/dist/client/index.js.map +1 -0
- package/dist/configuration/host/src/shared/plugin/configuration/index.d.ts +21 -0
- package/dist/configuration/index.d.ts +5 -0
- package/dist/host/_native/open-orpheus__database.d.ts +50 -0
- package/dist/host/_native/open-orpheus__window.d.ts +284 -0
- package/dist/host/src/constants.d.ts +6 -0
- package/dist/host/src/main/afp.d.ts +1 -0
- package/dist/host/src/main/arguments.d.ts +4 -0
- package/dist/host/src/main/assets.d.ts +2 -0
- package/dist/host/src/main/audio/ChunkTracker.d.ts +23 -0
- package/dist/host/src/main/audio/DownloadScheduler.d.ts +53 -0
- package/dist/host/src/main/audio/MediaEngine.d.ts +47 -0
- package/dist/host/src/main/audio/OnlineStreamer.d.ts +66 -0
- package/dist/host/src/main/audio/StorageManager.d.ts +18 -0
- package/dist/host/src/main/audio.d.ts +6 -0
- package/dist/host/src/main/av3a/Av3aEngine.d.ts +24 -0
- package/dist/host/src/main/av3a/Av3aM4aSession.d.ts +101 -0
- package/dist/host/src/main/av3a/Av3aPlaybackProcess.d.ts +52 -0
- package/dist/host/src/main/av3a/detect.d.ts +6 -0
- package/dist/host/src/main/av3a/sources.d.ts +13 -0
- package/dist/host/src/main/av3a/types.d.ts +54 -0
- package/dist/host/src/main/bridge/ipc-main-bridge.d.ts +24 -0
- package/dist/host/src/main/bridge/modules/inputRegion.d.ts +1 -0
- package/dist/host/src/main/bridge/modules/lyrics.d.ts +1 -0
- package/dist/host/src/main/bridge/modules/settings.d.ts +1 -0
- package/dist/host/src/main/bridge/register.d.ts +9 -0
- package/dist/host/src/main/bridge/window.d.ts +7 -0
- package/dist/host/src/main/cache/HttpCacheStorage.d.ts +10 -0
- package/dist/host/src/main/cache/LyricCahceManager.d.ts +21 -0
- package/dist/host/src/main/cache/PlayCacheManager.d.ts +72 -0
- package/dist/host/src/main/cache.d.ts +7 -0
- package/dist/host/src/main/calls/app.d.ts +1 -0
- package/dist/host/src/main/calls/audioeffect.d.ts +1 -0
- package/dist/host/src/main/calls/browser.d.ts +1 -0
- package/dist/host/src/main/calls/desktop.d.ts +2 -0
- package/dist/host/src/main/calls/desktoppet.d.ts +1 -0
- package/dist/host/src/main/calls/download.d.ts +1 -0
- package/dist/host/src/main/calls/index.d.ts +16 -0
- package/dist/host/src/main/calls/musiclibrary.d.ts +1 -0
- package/dist/host/src/main/calls/network.d.ts +1 -0
- package/dist/host/src/main/calls/os.d.ts +1 -0
- package/dist/host/src/main/calls/player.d.ts +22 -0
- package/dist/host/src/main/calls/process.d.ts +1 -0
- package/dist/host/src/main/calls/rtc.d.ts +1 -0
- package/dist/host/src/main/calls/storage.d.ts +1 -0
- package/dist/host/src/main/calls/trayicon.d.ts +1 -0
- package/dist/host/src/main/calls/update.d.ts +1 -0
- package/dist/host/src/main/calls/winhelper.d.ts +1 -0
- package/dist/host/src/main/calls.d.ts +5 -0
- package/dist/host/src/main/channel.d.ts +1 -0
- package/dist/host/src/main/cookie.d.ts +13 -0
- package/dist/host/src/main/crypto.d.ts +46 -0
- package/dist/host/src/main/database/KeyvSqliteDriver.d.ts +6 -0
- package/dist/host/src/main/database.d.ts +5 -0
- package/dist/host/src/main/dawn.d.ts +31 -0
- package/dist/host/src/main/device.d.ts +3 -0
- package/dist/host/src/main/download.d.ts +40 -0
- package/dist/host/src/main/error.d.ts +1 -0
- package/dist/host/src/main/folders.d.ts +18 -0
- package/dist/host/src/main/fonts.d.ts +1 -0
- package/dist/host/src/main/gui.d.ts +4 -0
- package/dist/host/src/main/id3.d.ts +42 -0
- package/dist/host/src/main/lifecycle.d.ts +127 -0
- package/dist/host/src/main/logger.d.ts +12 -0
- package/dist/host/src/main/lyrics/DbusLyricsService.d.ts +115 -0
- package/dist/host/src/main/lyrics/LyricsDispatcher.d.ts +26 -0
- package/dist/host/src/main/lyrics/dbus.d.ts +16 -0
- package/dist/host/src/main/lyrics/parse.d.ts +21 -0
- package/dist/host/src/main/lyrics.d.ts +2 -0
- package/dist/host/src/main/mediaSession.d.ts +42 -0
- package/dist/host/src/main/menu/AppMenu.d.ts +35 -0
- package/dist/host/src/main/menu/anchor.d.ts +13 -0
- package/dist/host/src/main/menu/backend/DesktopWindowBackend.d.ts +30 -0
- package/dist/host/src/main/menu/backend/MenuBackend.d.ts +28 -0
- package/dist/host/src/main/menu/backend/WaylandLayerShellBackend.d.ts +35 -0
- package/dist/host/src/main/menu/backend/WaylandOverlayBackend.d.ts +15 -0
- package/dist/host/src/main/menu/backend/WaylandPopupBackend.d.ts +31 -0
- package/dist/host/src/main/menu/constants.d.ts +14 -0
- package/dist/host/src/main/menu/index.d.ts +2 -0
- package/dist/host/src/main/menu/native-popup.d.ts +16 -0
- package/dist/host/src/main/menu/patch.d.ts +3 -0
- package/dist/host/src/main/menu/skin.d.ts +3 -0
- package/dist/host/src/main/menu/surface/BaseWindowMenuSurface.d.ts +81 -0
- package/dist/host/src/main/menu/surface/CaptureLayerSurface.d.ts +22 -0
- package/dist/host/src/main/menu/surface/MenuSurface.d.ts +29 -0
- package/dist/host/src/main/menu/surface/MenuSurfacePath.d.ts +29 -0
- package/dist/host/src/main/menu/surface/SurfacePool.d.ts +15 -0
- package/dist/host/src/main/menu/workaround.d.ts +12 -0
- package/dist/host/src/main/ncae.d.ts +8 -0
- package/dist/host/src/main/network/handler.d.ts +3 -0
- package/dist/host/src/main/network/interceptor.d.ts +2 -0
- package/dist/host/src/main/network/interceptors/anonymous.d.ts +2 -0
- package/dist/host/src/main/network/pipeline.d.ts +8 -0
- package/dist/host/src/main/network/types.d.ts +70 -0
- package/dist/host/src/main/orpheus.d.ts +10 -0
- package/dist/host/src/main/pack.d.ts +27 -0
- package/dist/host/src/main/packs/Pack.d.ts +12 -0
- package/dist/host/src/main/packs/SkinPack.d.ts +6 -0
- package/dist/host/src/main/packs/WebPack.d.ts +6 -0
- package/dist/host/src/main/playback/PlaybackController.d.ts +57 -0
- package/dist/host/src/main/playback/PlayerCommandRouter.d.ts +85 -0
- package/dist/host/src/main/playback/adapters/MediaSessionAdapter.d.ts +61 -0
- package/dist/host/src/main/playback/adapters/MprisAdapter.d.ts +48 -0
- package/dist/host/src/main/playback/adapters/NowPlayingAdapter.d.ts +23 -0
- package/dist/host/src/main/playback/adapters/SmtcAdapter.d.ts +23 -0
- package/dist/host/src/main/playback/artwork.d.ts +47 -0
- package/dist/host/src/main/playback/modes.d.ts +8 -0
- package/dist/host/src/main/playback/types.d.ts +59 -0
- package/dist/host/src/main/plugin/assets.d.ts +8 -0
- package/dist/host/src/main/plugin/catalog.d.ts +42 -0
- package/dist/host/src/main/plugin/discover.d.ts +33 -0
- package/dist/host/src/main/plugin/index.d.ts +15 -0
- package/dist/host/src/main/plugin/loader.d.ts +90 -0
- package/dist/host/src/main/plugin/manager.d.ts +61 -0
- package/dist/host/src/main/plugin/metadata.d.ts +34 -0
- package/dist/host/src/main/plugin/state.d.ts +27 -0
- package/dist/host/src/main/plugin/tree.d.ts +13 -0
- package/dist/host/src/main/protocol.d.ts +4 -0
- package/dist/host/src/main/request.d.ts +16 -0
- package/dist/host/src/main/settings.d.ts +21 -0
- package/dist/host/src/main/shortcuts.d.ts +10 -0
- package/dist/host/src/main/shutdown.d.ts +50 -0
- package/dist/host/src/main/skin/color.d.ts +2 -0
- package/dist/host/src/main/skin/dui.d.ts +15 -0
- package/dist/host/src/main/tray.d.ts +8 -0
- package/dist/host/src/main/update.d.ts +2 -0
- package/dist/host/src/main/util/color.d.ts +7 -0
- package/dist/host/src/main/util/display.d.ts +3 -0
- package/dist/host/src/main/util/env.d.ts +1 -0
- package/dist/host/src/main/util/fs.d.ts +21 -0
- package/dist/host/src/main/util/image.d.ts +1 -0
- package/dist/host/src/main/util/musicFile.d.ts +1 -0
- package/dist/host/src/main/util/musicPicture.d.ts +2 -0
- package/dist/host/src/main/util/path.d.ts +2 -0
- package/dist/host/src/main/util/send.d.ts +13 -0
- package/dist/host/src/main/util/url.d.ts +19 -0
- package/dist/host/src/main/util/window.d.ts +2 -0
- package/dist/host/src/main/window.d.ts +316 -0
- package/dist/host/src/main/windows/color-picker.d.ts +3 -0
- package/dist/host/src/main/windows/desktop-lyrics.d.ts +12 -0
- package/dist/host/src/main/windows/desktop-pet.d.ts +8 -0
- package/dist/host/src/main/windows/main.d.ts +6 -0
- package/dist/host/src/main/windows/manage.d.ts +2 -0
- package/dist/host/src/main/windows/mini-player.d.ts +16 -0
- package/dist/host/src/main/windows/music-desktop.d.ts +13 -0
- package/dist/host/src/main/windows/package-download.d.ts +2 -0
- package/dist/host/src/main/windows/plugin-manager-events.d.ts +7 -0
- package/dist/host/src/main/windows/plugin-manager.d.ts +5 -0
- package/dist/host/src/main/xeapi.d.ts +48 -0
- package/dist/host/src/preload/AudioEffectManager.d.ts +124 -0
- package/dist/host/src/preload/PlaybackBackend.d.ts +34 -0
- package/dist/host/src/preload/Player.d.ts +229 -0
- package/dist/host/src/preload/av3a/Av3aPcmPlayer.d.ts +84 -0
- package/dist/host/src/preload/av3a/bridge.d.ts +21 -0
- package/dist/host/src/preload/av3a/channel.d.ts +40 -0
- package/dist/host/src/preload/av3a/detect.d.ts +6 -0
- package/dist/host/src/preload/backends/Av3aPlaybackBackend.d.ts +32 -0
- package/dist/host/src/preload/backends/MediaPlaybackBackend.d.ts +25 -0
- package/dist/host/src/shared/CallDispatcher.d.ts +12 -0
- package/dist/host/src/shared/bridge/constants.d.ts +2 -0
- package/dist/host/src/shared/bridge/endpoint.d.ts +29 -0
- package/dist/host/src/shared/bridge/hub.d.ts +136 -0
- package/dist/host/src/shared/bridge/protocol.d.ts +91 -0
- package/dist/host/src/shared/bridge/realm.d.ts +14 -0
- package/dist/host/src/shared/bridge/routes.d.ts +37 -0
- package/dist/host/src/shared/contracts/av3a-api.d.ts +50 -0
- package/dist/host/src/shared/contracts/av3a-process.d.ts +56 -0
- package/dist/host/src/shared/contracts/color-picker-api.d.ts +17 -0
- package/dist/host/src/shared/contracts/desktop-lyrics-api.d.ts +22 -0
- package/dist/host/src/shared/contracts/input-region-api.d.ts +5 -0
- package/dist/host/src/shared/contracts/lyrics-api.d.ts +11 -0
- package/dist/host/src/shared/contracts/manage-api.d.ts +31 -0
- package/dist/host/src/shared/contracts/menu-surface-api.d.ts +35 -0
- package/dist/host/src/shared/contracts/mini-player-api.d.ts +19 -0
- package/dist/host/src/shared/contracts/plugin-manager-api.d.ts +223 -0
- package/dist/host/src/shared/contracts/settings-api.d.ts +15 -0
- package/dist/host/src/shared/playbackMode.d.ts +2 -0
- package/dist/host/src/shared/plugin/cache-bust.d.ts +8 -0
- package/dist/host/src/shared/plugin/lifecycle.d.ts +217 -0
- package/dist/host/src/shared/plugin/realms/main/index.d.ts +18 -0
- package/dist/host/src/shared/plugin/registry.d.ts +69 -0
- package/dist/host/src/shared/plugin/runtime-state.d.ts +4 -0
- package/dist/host/src/shared/settings/defaults.d.ts +35 -0
- package/dist/host/src/shared/settings/index.d.ts +3 -0
- package/dist/host/src/shared/settings/keys.d.ts +21 -0
- package/dist/host/src/shared/settings/values.d.ts +13 -0
- package/dist/host/src/shared/types/desktop-lyrics.d.ts +61 -0
- package/dist/host/src/shared/types/dui.d.ts +37 -0
- package/dist/host/src/shared/types/input-region.d.ts +6 -0
- package/dist/host/src/shared/types/lyrics.d.ts +15 -0
- package/dist/host/src/shared/types/manage.d.ts +14 -0
- package/dist/host/src/shared/types/menu-surface.d.ts +43 -0
- package/dist/host/src/shared/types/menu.d.ts +29 -0
- package/dist/host/src/shared/types/mini-player.d.ts +97 -0
- package/dist/host/src/shared/types/ncae.d.ts +29 -0
- package/dist/host/src/shared/types/package-download.d.ts +14 -0
- package/dist/host/src/shared/types/playback-mode.d.ts +3 -0
- package/dist/host/src/shared/types/settings.d.ts +9 -0
- package/dist/host/src/shared/types/update.d.ts +6 -0
- package/dist/host/src/shared/util.d.ts +22 -0
- package/dist/index.d.ts +7 -0
- package/dist/plugin-manager/host/src/preload/logger.d.ts +10 -0
- package/dist/plugin-manager/host/src/preload/util.d.ts +1 -0
- package/dist/plugin-manager/host/src/shared/bridge/constants.d.ts +2 -0
- package/dist/plugin-manager/host/src/shared/bridge/endpoint.d.ts +29 -0
- package/dist/plugin-manager/host/src/shared/bridge/hub.d.ts +136 -0
- package/dist/plugin-manager/host/src/shared/bridge/protocol.d.ts +91 -0
- package/dist/plugin-manager/host/src/shared/bridge/routes.d.ts +37 -0
- package/dist/plugin-manager/host/src/shared/contracts/plugin-manager-api.d.ts +223 -0
- package/dist/plugin-manager/host/src/shared/plugin/lifecycle.d.ts +217 -0
- package/dist/plugin-manager/host/src/shared/plugin/realms/common/index.d.ts +34 -0
- package/dist/plugin-manager/host/src/shared/plugin/realms/plugin-manager/index.d.ts +11 -0
- package/dist/plugin-manager/host/src/shared/plugin/registry.d.ts +69 -0
- package/dist/plugin-manager/host/src/shared/util.d.ts +22 -0
- package/dist/plugin-manager/index.d.ts +7 -0
- package/dist/plugin-manager/registry-map.d.ts +16 -0
- package/dist/preload/host/src/constants.d.ts +6 -0
- package/dist/preload/host/src/main/network/types.d.ts +70 -0
- package/dist/preload/host/src/preload/AudioEffectManager.d.ts +124 -0
- package/dist/preload/host/src/preload/MusicRecognizer.d.ts +25 -0
- package/dist/preload/host/src/preload/PlaybackBackend.d.ts +34 -0
- package/dist/preload/host/src/preload/Player.d.ts +229 -0
- package/dist/preload/host/src/preload/YunxinIM.d.ts +15 -0
- package/dist/preload/host/src/preload/audioplayer.d.ts +4 -0
- package/dist/preload/host/src/preload/av3a/Av3aPcmPlayer.d.ts +84 -0
- package/dist/preload/host/src/preload/av3a/bridge.d.ts +21 -0
- package/dist/preload/host/src/preload/av3a/channel.d.ts +40 -0
- package/dist/preload/host/src/preload/av3a/detect.d.ts +6 -0
- package/dist/preload/host/src/preload/backends/Av3aPlaybackBackend.d.ts +32 -0
- package/dist/preload/host/src/preload/backends/MediaPlaybackBackend.d.ts +25 -0
- package/dist/preload/host/src/preload/calls/app.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/audioeffect.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/audioplayer.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/im.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/index.d.ts +6 -0
- package/dist/preload/host/src/preload/calls/network.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/nimsys.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/os.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/player.d.ts +1 -0
- package/dist/preload/host/src/preload/calls/update.d.ts +1 -0
- package/dist/preload/host/src/preload/calls.d.ts +4 -0
- package/dist/preload/host/src/preload/channel.d.ts +1 -0
- package/dist/preload/host/src/preload/logger.d.ts +10 -0
- package/dist/preload/host/src/preload/playbackMode.d.ts +13 -0
- package/dist/preload/host/src/preload/util.d.ts +1 -0
- package/dist/preload/host/src/shared/CallDispatcher.d.ts +12 -0
- package/dist/preload/host/src/shared/bridge/endpoint.d.ts +29 -0
- package/dist/preload/host/src/shared/bridge/hub.d.ts +136 -0
- package/dist/preload/host/src/shared/bridge/protocol.d.ts +91 -0
- package/dist/preload/host/src/shared/bridge/routes.d.ts +37 -0
- package/dist/preload/host/src/shared/contracts/av3a-api.d.ts +50 -0
- package/dist/preload/host/src/shared/contracts/av3a-process.d.ts +56 -0
- package/dist/preload/host/src/shared/contracts/plugin-manager-api.d.ts +223 -0
- package/dist/preload/host/src/shared/playbackMode.d.ts +2 -0
- package/dist/preload/host/src/shared/plugin/lifecycle.d.ts +217 -0
- package/dist/preload/host/src/shared/plugin/realms/common/index.d.ts +34 -0
- package/dist/preload/host/src/shared/plugin/realms/preload/index.d.ts +11 -0
- package/dist/preload/host/src/shared/plugin/registry.d.ts +69 -0
- package/dist/preload/host/src/shared/types/ncae.d.ts +29 -0
- package/dist/preload/host/src/shared/types/playback-mode.d.ts +3 -0
- package/dist/preload/host/src/shared/util.d.ts +22 -0
- package/dist/preload/index.d.ts +7 -0
- package/dist/preload/registry-map.d.ts +43 -0
- package/dist/registry-map.d.ts +164 -0
- package/package.json +73 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ChunkInterval = {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
};
|
|
5
|
+
export type ChunkInstruction = ChunkInterval & {
|
|
6
|
+
type: "hit" | "miss";
|
|
7
|
+
};
|
|
8
|
+
export default class ChunkTracker {
|
|
9
|
+
private intervals;
|
|
10
|
+
get loadedBytes(): number;
|
|
11
|
+
addInterval(start: number, end: number): number;
|
|
12
|
+
getIntervals(): {
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
}[];
|
|
16
|
+
getDownloadedEnd(start: number, limit: number): number;
|
|
17
|
+
getDownloadedSpanFrom(start: number, limit: number): number;
|
|
18
|
+
getGapEnd(start: number, limit: number): number;
|
|
19
|
+
isRangeDownloaded(start: number, end: number): boolean;
|
|
20
|
+
getMissingIntervals(start: number, end: number): ChunkInterval[];
|
|
21
|
+
getInstructions(start: number, end: number): ChunkInstruction[];
|
|
22
|
+
isComplete(totalLength: number): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type ChunkTracker from "./ChunkTracker.js";
|
|
2
|
+
import type StorageManager from "./StorageManager.js";
|
|
3
|
+
type DownloadSchedulerOptions = {
|
|
4
|
+
url: string;
|
|
5
|
+
toleranceThreshold: number;
|
|
6
|
+
tracker: ChunkTracker;
|
|
7
|
+
storage: StorageManager;
|
|
8
|
+
getTotalLength: () => number;
|
|
9
|
+
onProgress: () => void;
|
|
10
|
+
onComplete: () => void;
|
|
11
|
+
onError: (error: Error) => void;
|
|
12
|
+
};
|
|
13
|
+
export type UrgentSession = {
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
abort: (reason?: unknown) => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
};
|
|
18
|
+
export default class DownloadScheduler {
|
|
19
|
+
private readonly url;
|
|
20
|
+
private readonly toleranceThreshold;
|
|
21
|
+
private readonly tracker;
|
|
22
|
+
private readonly storage;
|
|
23
|
+
private readonly getTotalLength;
|
|
24
|
+
private readonly onProgress;
|
|
25
|
+
private readonly onComplete;
|
|
26
|
+
private readonly onError;
|
|
27
|
+
private readonly activeRequests;
|
|
28
|
+
private readonly backgroundController;
|
|
29
|
+
private urgentController;
|
|
30
|
+
private backgroundStarted;
|
|
31
|
+
private destroyed;
|
|
32
|
+
private completeEmitted;
|
|
33
|
+
private writeChain;
|
|
34
|
+
private activeUrgentRange;
|
|
35
|
+
private urgentRangeVersion;
|
|
36
|
+
private backgroundRetryDelay;
|
|
37
|
+
private readonly urgentRangeWaiters;
|
|
38
|
+
constructor(options: DownloadSchedulerOptions);
|
|
39
|
+
startBackground(): void;
|
|
40
|
+
createUrgentSession(signal?: AbortSignal): UrgentSession;
|
|
41
|
+
streamUrgent(start: number, end: number, signal: AbortSignal): AsyncGenerator<Buffer<ArrayBuffer>, void, unknown>;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
private runBackground;
|
|
44
|
+
private findBackgroundGap;
|
|
45
|
+
private getUrgentReservedEnd;
|
|
46
|
+
private waitForUrgentRangeChange;
|
|
47
|
+
private notifyUrgentRangeChanged;
|
|
48
|
+
private downloadRange;
|
|
49
|
+
private waitForRangeResponse;
|
|
50
|
+
private checkBeforeWrite;
|
|
51
|
+
private emitCompleteIfNeeded;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AudioPlayInfo } from "../../preload/Player.js";
|
|
2
|
+
/**
|
|
3
|
+
* Main-process engine for media-element playback. It never decodes — Chromium
|
|
4
|
+
* plays the `<audio>` element — it only serves that element over `audio://audio`
|
|
5
|
+
* from the current load: a local file (ranged reads) or an `OnlineStreamer`
|
|
6
|
+
* (URL, cache-on-complete). Distinct from `Av3aEngine`, which manages the AV3A
|
|
7
|
+
* decode utility process; exactly one of them is active at a time and the
|
|
8
|
+
* renderer routes which one.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MediaEngine {
|
|
11
|
+
private state;
|
|
12
|
+
/**
|
|
13
|
+
* Deletions `stop()` started but did not wait for.
|
|
14
|
+
*
|
|
15
|
+
* A song switch must not block on deleting the previous file, so those
|
|
16
|
+
* deletions run unattended — but a shutdown has to wait for them, or a file
|
|
17
|
+
* whose deletion was still in flight outlives the process and is only
|
|
18
|
+
* reclaimed by the next launch's cleanup.
|
|
19
|
+
*/
|
|
20
|
+
private pendingDestructions;
|
|
21
|
+
get active(): boolean;
|
|
22
|
+
/** Delete a retired streamer's file without blocking the caller. */
|
|
23
|
+
private destroyInBackground;
|
|
24
|
+
private sendProgress;
|
|
25
|
+
/**
|
|
26
|
+
* Register the serving state for a media-element (non-AV3A) play info.
|
|
27
|
+
* Local files are served by path; URLs get an `OnlineStreamer` whose
|
|
28
|
+
* completion writes the download into the play cache.
|
|
29
|
+
*/
|
|
30
|
+
activate(playInfo: AudioPlayInfo): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Retire the current serving state. Any streamer is destroyed in the
|
|
33
|
+
* background (its file deletion must not block a fast song switch).
|
|
34
|
+
*/
|
|
35
|
+
stop(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Retire the current serving state and wait for every streamer's file to be
|
|
38
|
+
* deleted, including deletions {@link stop} left running.
|
|
39
|
+
*
|
|
40
|
+
* Distinct from {@link stop}, which deliberately does not wait: a song switch
|
|
41
|
+
* must not block on deleting the previous file, but a shutdown has nothing
|
|
42
|
+
* after it and wants the temp file gone rather than left for the next launch.
|
|
43
|
+
*/
|
|
44
|
+
dispose(): Promise<void>;
|
|
45
|
+
/** Serve an `audio://audio` request (the `<audio>` element) for this state. */
|
|
46
|
+
serve(request: Request): Promise<Response>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import Emittery from "emittery";
|
|
3
|
+
export type OnlineStreamerEvents = {
|
|
4
|
+
progress: {
|
|
5
|
+
loaded: number;
|
|
6
|
+
total: number;
|
|
7
|
+
};
|
|
8
|
+
complete: undefined;
|
|
9
|
+
error: Error;
|
|
10
|
+
};
|
|
11
|
+
export interface StreamerOptions {
|
|
12
|
+
toleranceThreshold?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class OnlineStreamer extends Emittery<OnlineStreamerEvents> {
|
|
15
|
+
static tempDir: string;
|
|
16
|
+
private static readonly activeTempFiles;
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly tempFilePath: string;
|
|
19
|
+
totalLength: number;
|
|
20
|
+
private readonly tracker;
|
|
21
|
+
private readonly storage;
|
|
22
|
+
private readonly scheduler;
|
|
23
|
+
private readonly metaAbortController;
|
|
24
|
+
private readonly metaReadyPromise;
|
|
25
|
+
private readonly emittedErrors;
|
|
26
|
+
private mimeType;
|
|
27
|
+
private _destroyed;
|
|
28
|
+
get destroyed(): boolean;
|
|
29
|
+
static cleanup(): Promise<void>;
|
|
30
|
+
constructor(url: string, options?: StreamerOptions);
|
|
31
|
+
handleRequest(request: Request): Promise<Response>;
|
|
32
|
+
getDownloadedIntervals(): {
|
|
33
|
+
start: number;
|
|
34
|
+
end: number;
|
|
35
|
+
}[];
|
|
36
|
+
/**
|
|
37
|
+
* Length of the contiguous downloaded prefix starting at byte 0.
|
|
38
|
+
*
|
|
39
|
+
* A decoder that reads the sparse temp file directly must not read past
|
|
40
|
+
* this point: bytes beyond it are still zeros until the background worker
|
|
41
|
+
* persists them.
|
|
42
|
+
*/
|
|
43
|
+
downloadedPrefixEnd(): number;
|
|
44
|
+
/** Resolves once the source metadata (total length) is known. */
|
|
45
|
+
whenReady(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Download `[start, end)` with urgent priority and resolve once the bytes
|
|
48
|
+
* are persisted in the temp file (so a decoder can read them). Aborts when
|
|
49
|
+
* `signal` is aborted or the streamer is destroyed.
|
|
50
|
+
*/
|
|
51
|
+
ensureRangeDownloaded(start: number, end: number, signal?: AbortSignal): Promise<void>;
|
|
52
|
+
readBuffer(start?: number, end?: number): Promise<Buffer<ArrayBuffer>>;
|
|
53
|
+
createReadStream(start?: number, end?: number): Readable;
|
|
54
|
+
destroy(): Promise<void>;
|
|
55
|
+
private prepare;
|
|
56
|
+
private fetchMetadata;
|
|
57
|
+
private fetchHeadMetadata;
|
|
58
|
+
private fetchRangeMetadata;
|
|
59
|
+
private normalizeReadRange;
|
|
60
|
+
private createReadStreamIterator;
|
|
61
|
+
private assertNotDestroyed;
|
|
62
|
+
private emitProgress;
|
|
63
|
+
private emitComplete;
|
|
64
|
+
private emitError;
|
|
65
|
+
}
|
|
66
|
+
export default OnlineStreamer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
export default class StorageManager {
|
|
3
|
+
readonly filePath: string;
|
|
4
|
+
private fileHandle;
|
|
5
|
+
private openingPromise;
|
|
6
|
+
private writeQueue;
|
|
7
|
+
private closed;
|
|
8
|
+
constructor(filePath: string);
|
|
9
|
+
open(): Promise<void>;
|
|
10
|
+
setLength(length: number): Promise<void>;
|
|
11
|
+
write(position: number, chunk: Uint8Array): Promise<void>;
|
|
12
|
+
readBuffer(start: number, end: number): Promise<Buffer<ArrayBuffer>>;
|
|
13
|
+
readRange(start: number, end: number): AsyncGenerator<Buffer<ArrayBuffer>, void, unknown>;
|
|
14
|
+
createReadStream(start: number, end: number): Readable;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
delete(): Promise<void>;
|
|
17
|
+
private getFileHandle;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AudioPlayInfo } from "../../preload/Player.js";
|
|
2
|
+
/**
|
|
3
|
+
* Main-process manager for AV3A playback: a decode utility process plus the
|
|
4
|
+
* file it reads (a streamed temp file or a local one). Distinct from
|
|
5
|
+
* `MediaEngine` (the media-element engine): AV3A is never served over
|
|
6
|
+
* `audio://audio`; PCM and renderer flow control travel on a direct
|
|
7
|
+
* renderer<->utility channel.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Av3aEngine {
|
|
10
|
+
private state;
|
|
11
|
+
/** Monotonic sequence for AV3A start requests (only the newest may win). */
|
|
12
|
+
private requestSeq;
|
|
13
|
+
get active(): boolean;
|
|
14
|
+
/** Push a fallback `av3a.<event>` to the player window. */
|
|
15
|
+
private sendEvent;
|
|
16
|
+
/** Stop the currently active AV3A session. Has no freshness side effects. */
|
|
17
|
+
stopActive(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* External stop (user stop / play-info change): cancels any pending startup
|
|
20
|
+
* too, by advancing the request sequence before stopping active playback.
|
|
21
|
+
*/
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
start(playInfo: AudioPlayInfo): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Av3aDecodeExecutor, Av3aDecodedFrame, Av3aTrackInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Source abstraction over anything that can supply an AV3A-in-M4A file that
|
|
4
|
+
* may still be downloading. `OnlineStreamer` satisfies this interface: the
|
|
5
|
+
* sparse temp file grows in place, `prefixEnd()` reports how many contiguous
|
|
6
|
+
* bytes are readable, and `ensureRange()` downloads a byte range urgently.
|
|
7
|
+
*/
|
|
8
|
+
export type Av3aM4aSource = {
|
|
9
|
+
/** Absolute path to the (possibly partial) M4A/MP4 file. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Total expected file size in bytes. */
|
|
12
|
+
totalLength: number;
|
|
13
|
+
/** Contiguous downloaded prefix length starting at byte 0. */
|
|
14
|
+
prefixEnd(): number;
|
|
15
|
+
/** Download `[start, end)` and resolve once the bytes are on disk. */
|
|
16
|
+
ensureRange(start: number, end: number, signal?: AbortSignal): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
/** `pts` is the presentation timestamp of the frame in milliseconds. */
|
|
19
|
+
export type Av3aPcmFrame = Av3aDecodedFrame & {
|
|
20
|
+
pts: number;
|
|
21
|
+
};
|
|
22
|
+
export type Av3aM4aSessionCallbacks = {
|
|
23
|
+
/** Fired once the `moov` box has been indexed. */
|
|
24
|
+
onOpened?: (info: Av3aTrackInfo) => void;
|
|
25
|
+
/** Fired for every decoded frame. */
|
|
26
|
+
onPcm?: (frame: Av3aPcmFrame) => void;
|
|
27
|
+
/** Fired when the last frame of the track has been decoded. */
|
|
28
|
+
onDone?: () => void;
|
|
29
|
+
/** Fired on a fatal error (e.g. the file has no AV3A track). */
|
|
30
|
+
onError?: (error: Error) => void;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Drives an [`Av3aDecodeExecutor`] against a progressively downloaded M4A file.
|
|
34
|
+
*
|
|
35
|
+
* Decoding starts as early as possible:
|
|
36
|
+
* 1. The decoder is opened (retried) as soon as the `moov` box is readable;
|
|
37
|
+
* if the prefix stops growing, the tail is probed in case `moov` sits at
|
|
38
|
+
* the end of the file.
|
|
39
|
+
* 2. Before each frame is decoded, the session ensures the bytes that sample
|
|
40
|
+
* needs are on disk (`nextSampleRange` + `ensureRange`), so a sparse temp
|
|
41
|
+
* file is never read through its zero-filled holes. It only asks the source
|
|
42
|
+
* when the frame reaches past the source's known contiguous prefix, so
|
|
43
|
+
* steady-state decode never round-trips the data owner.
|
|
44
|
+
*
|
|
45
|
+
* PCM frames are delivered through `onPcm`; a consumer that cannot keep up can
|
|
46
|
+
* call [`pause`] (decode stops at the next frame boundary) and [`resume`].
|
|
47
|
+
*/
|
|
48
|
+
export declare class Av3aM4aSession {
|
|
49
|
+
private readonly executor;
|
|
50
|
+
private readonly source;
|
|
51
|
+
private readonly callbacks;
|
|
52
|
+
private readonly abortController;
|
|
53
|
+
private running;
|
|
54
|
+
private runPromise;
|
|
55
|
+
/** Track info from the last successful open (reused when restarting). */
|
|
56
|
+
private info;
|
|
57
|
+
private paused;
|
|
58
|
+
private resumeWaiter;
|
|
59
|
+
/** Absolute frame index to reposition to on the next decode-loop pass. */
|
|
60
|
+
private pendingSeekFrame;
|
|
61
|
+
constructor(executor: Av3aDecodeExecutor, source: Av3aM4aSource, callbacks?: Av3aM4aSessionCallbacks);
|
|
62
|
+
get signal(): AbortSignal;
|
|
63
|
+
get isRunning(): boolean;
|
|
64
|
+
/** Pause after the current frame; no-op when already paused or idle. */
|
|
65
|
+
pause(): void;
|
|
66
|
+
/** Resume decoding. */
|
|
67
|
+
resume(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Reposition the decode to an absolute track frame index. Applied on the
|
|
70
|
+
* next decode-loop iteration; also unblocks a paused session so the request
|
|
71
|
+
* is processed promptly.
|
|
72
|
+
*/
|
|
73
|
+
seekToFrame(frameIndex: number): void;
|
|
74
|
+
/** Abort the session. The worker is closed by `run()`'s cleanup. */
|
|
75
|
+
destroy(): void;
|
|
76
|
+
/** Run the decode loop until the track ends, is aborted, or fails. */
|
|
77
|
+
run(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Restart decoding from an absolute track frame after a previous run already
|
|
80
|
+
* finished (e.g. the user seeks after the track ended). The decoder is
|
|
81
|
+
* reopened (runs close it when they finish) and decoding resumes at
|
|
82
|
+
* `frameIndex` without re-emitting `onOpened`.
|
|
83
|
+
*/
|
|
84
|
+
runFrom(frameIndex: number): Promise<void>;
|
|
85
|
+
/** Decode again from `info` starting at `pendingSeekFrame` (already set). */
|
|
86
|
+
private restartLoop;
|
|
87
|
+
/**
|
|
88
|
+
* Abort the session and wait until the decode worker has fully stopped, so
|
|
89
|
+
* callers can safely release the underlying file afterwards.
|
|
90
|
+
*/
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
private runLoop;
|
|
93
|
+
/**
|
|
94
|
+
* Retry `open` until the `moov` box is readable. For non-faststart files the
|
|
95
|
+
* `moov` sits at the end: once the sequential prefix stops advancing, probe
|
|
96
|
+
* the tail instead of waiting for the whole file to download.
|
|
97
|
+
*/
|
|
98
|
+
private openUntilReady;
|
|
99
|
+
private decodeLoop;
|
|
100
|
+
private waitIfPaused;
|
|
101
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { WebContents } from "electron";
|
|
2
|
+
import type { Av3aM4aSource } from "./Av3aM4aSession.js";
|
|
3
|
+
/**
|
|
4
|
+
* Main-process side of the AV3A decode utility process.
|
|
5
|
+
*
|
|
6
|
+
* Owns the child process lifecycle and the `MessageChannelMain` whose renderer
|
|
7
|
+
* end is handed to the player window (`av3a.channel`). PCM and renderer flow
|
|
8
|
+
* control (pause/resume/seek) travel on that channel directly between the
|
|
9
|
+
* renderer and the utility process — never through main — so playback keeps
|
|
10
|
+
* flowing while main is blocked (e.g. a Windows modal window-drag loop).
|
|
11
|
+
*
|
|
12
|
+
* Main stays on the data path only for what it owns: answering `ensureRange`
|
|
13
|
+
* requests (the file is downloaded here by `OnlineStreamer`) and periodically
|
|
14
|
+
* pushing the contiguous download frontier so the utility can decode ahead
|
|
15
|
+
* without asking. All decode events and PCM go renderer<->utility over the
|
|
16
|
+
* channel; main only pushes a fallback `av3a.error` if the process dies
|
|
17
|
+
* unexpectedly.
|
|
18
|
+
*/
|
|
19
|
+
export type Av3aPlaybackProcessOptions = {
|
|
20
|
+
/** The sparse temp file + download control (an `OnlineStreamer` adapter). */
|
|
21
|
+
source: Av3aM4aSource;
|
|
22
|
+
/** The window that hosts the player; receives the renderer channel end. */
|
|
23
|
+
rendererWebContents: WebContents;
|
|
24
|
+
/** Push a fallback `av3a.error` to the renderer (decode process crash). */
|
|
25
|
+
sendEvent: (event: string, ...args: unknown[]) => void;
|
|
26
|
+
};
|
|
27
|
+
/** Best-effort synchronous kill of every live decode process (used on quit). */
|
|
28
|
+
export declare function killAllAv3aProcesses(): void;
|
|
29
|
+
export declare class Av3aPlaybackProcess {
|
|
30
|
+
private readonly options;
|
|
31
|
+
private child;
|
|
32
|
+
private rendererPort;
|
|
33
|
+
private frontierTimer;
|
|
34
|
+
private lastFrontier;
|
|
35
|
+
private stopped;
|
|
36
|
+
constructor(options: Av3aPlaybackProcessOptions);
|
|
37
|
+
get alive(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Fork the decode service, wire the renderer channel, and start pushing the
|
|
40
|
+
* download frontier. Resolves once the child has spawned and init is sent.
|
|
41
|
+
*/
|
|
42
|
+
start(): Promise<void>;
|
|
43
|
+
/** Stop the child and release the channel. Safe to call twice. */
|
|
44
|
+
stop(): Promise<void>;
|
|
45
|
+
/** Best-effort synchronous kill (used on app quit). */
|
|
46
|
+
killQuietly(): void;
|
|
47
|
+
private pushFrontier;
|
|
48
|
+
private onChildMessage;
|
|
49
|
+
private onChildExit;
|
|
50
|
+
private clearTimer;
|
|
51
|
+
private closeRendererPort;
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `path` is an ISO-BMFF file carrying an AV3A track. Detection is a
|
|
3
|
+
* few small reads (never the media payload), so it is deliberately uncached —
|
|
4
|
+
* callers re-sniff per load and the cost is negligible.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isAv3aFile(path: string): Promise<boolean>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OnlineStreamer } from "../audio/OnlineStreamer.js";
|
|
2
|
+
import type { Av3aM4aSource } from "./Av3aM4aSession.js";
|
|
3
|
+
/**
|
|
4
|
+
* `Av3aM4aSource` for a fully-present local file: the whole file is always
|
|
5
|
+
* available, so the frontier is the full size and `ensureRange` is a no-op.
|
|
6
|
+
* The decode utility process reads the file path directly.
|
|
7
|
+
*/
|
|
8
|
+
export declare function localAv3aSource(path: string): Promise<Av3aM4aSource>;
|
|
9
|
+
/**
|
|
10
|
+
* Adapts an `OnlineStreamer` (a progressively downloaded sparse temp file)
|
|
11
|
+
* to the `Av3aM4aSource` the decode session paces against.
|
|
12
|
+
*/
|
|
13
|
+
export declare function onlineStreamerToAv3aSource(streamer: OnlineStreamer): Av3aM4aSource;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AV3A decode types + executor contract used by the decode session
|
|
3
|
+
* (`Av3aM4aSession`) and its transport. The transport may be anything that
|
|
4
|
+
* exposes the same async surface (a worker-thread RPC, direct native calls in
|
|
5
|
+
* a utility process, ...); the session only depends on this interface.
|
|
6
|
+
*/
|
|
7
|
+
import type { Av3aTrackInfo } from "../../shared/contracts/av3a-api.js";
|
|
8
|
+
export type { Av3aTrackInfo };
|
|
9
|
+
/** Byte range of the next sample (`done: true` at the end of the track). */
|
|
10
|
+
export type Av3aSampleRange = {
|
|
11
|
+
done: boolean;
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
};
|
|
15
|
+
/** One decoded frame; `data` is little-endian PCM16 (zero-copy where possible). */
|
|
16
|
+
export type Av3aDecodedFrame = {
|
|
17
|
+
done: true;
|
|
18
|
+
frameIndex: number;
|
|
19
|
+
sampleRate: 0;
|
|
20
|
+
channels: 0;
|
|
21
|
+
data: null;
|
|
22
|
+
} | {
|
|
23
|
+
done: false;
|
|
24
|
+
frameIndex: number;
|
|
25
|
+
sampleRate: number;
|
|
26
|
+
channels: number;
|
|
27
|
+
data: ArrayBuffer;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The asynchronous decode surface the session paces against.
|
|
31
|
+
*
|
|
32
|
+
* Implementations may talk to a native decoder directly or proxy it through a
|
|
33
|
+
* process boundary; the session treats every call as async so a transport can
|
|
34
|
+
* yield between native calls.
|
|
35
|
+
*/
|
|
36
|
+
export interface Av3aDecodeExecutor {
|
|
37
|
+
/** Open an M4A/MP4 file and index its AV3A track. Throws when not ready. */
|
|
38
|
+
open(path: string): Promise<void>;
|
|
39
|
+
/** Track information for the opened file. */
|
|
40
|
+
info(): Promise<Av3aTrackInfo>;
|
|
41
|
+
/** Move to an exact track frame (warm-up frames handled internally). */
|
|
42
|
+
seekToFrame(frameIndex: number): Promise<void>;
|
|
43
|
+
/** Byte range of the sample the next `decodeNext` reads. */
|
|
44
|
+
nextSampleRange(): Promise<Av3aSampleRange>;
|
|
45
|
+
/**
|
|
46
|
+
* Byte range the next `decodeNext` reads (after a seek this also spans the
|
|
47
|
+
* warm-up frames the decoder fast-forwards through).
|
|
48
|
+
*/
|
|
49
|
+
decodeWindowRange(): Promise<Av3aSampleRange>;
|
|
50
|
+
/** Decode the next frame. */
|
|
51
|
+
decodeNext(): Promise<Av3aDecodedFrame>;
|
|
52
|
+
/** Release the underlying file handle. */
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main-process side of the IPC bridge.
|
|
3
|
+
*
|
|
4
|
+
* One `IpcMainBridge` exists per `WebContents`; frames from a renderer are
|
|
5
|
+
* dispatched to the bridge registered for that sender. Outbound frames are
|
|
6
|
+
* addressed to the owning `WebContents`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Bridge, BridgeInfo } from "../../shared/bridge/hub.js";
|
|
9
|
+
import type { Realm } from "../../shared/bridge/realm.js";
|
|
10
|
+
import type { Frame } from "../../shared/bridge/protocol.js";
|
|
11
|
+
export declare class IpcMainBridge implements Bridge<Realm> {
|
|
12
|
+
private readonly contents;
|
|
13
|
+
readonly info: BridgeInfo<Realm>;
|
|
14
|
+
private readonly handlers;
|
|
15
|
+
private readonly seenSessions;
|
|
16
|
+
private session;
|
|
17
|
+
private destroyed;
|
|
18
|
+
constructor(contents: Electron.WebContents);
|
|
19
|
+
send(frame: Frame): void;
|
|
20
|
+
onFrame(handler: (frame: Frame) => void): () => void;
|
|
21
|
+
close(): void;
|
|
22
|
+
/** Called by the shared IPC listener when a frame arrives from this sender. */
|
|
23
|
+
receive(frame: Frame): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerInputRegionHandlers(wnd: Electron.BrowserWindow): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerLyricsHandlers(wnd: Electron.BrowserWindow): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerSettingsHandlers(wnd: Electron.BrowserWindow): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WebContents, IpcMainInvokeEvent } from "electron";
|
|
2
|
+
type HasFunctionDeep<T> = T extends (...args: never[]) => unknown ? true : T extends Record<string, unknown> ? T extends unknown[] ? false : keyof T extends never ? false : {
|
|
3
|
+
[K in keyof T]: HasFunctionDeep<T[K]>;
|
|
4
|
+
}[keyof T] : false;
|
|
5
|
+
type DeepIpcHandlers<T> = {
|
|
6
|
+
[K in keyof T as K extends "events" ? never : T[K] extends (...args: never[]) => unknown ? K : T[K] extends Record<string, unknown> ? T[K] extends unknown[] ? never : HasFunctionDeep<T[K]> extends true ? K : never : never]: T[K] extends (...args: infer A) => infer R ? (event: IpcMainInvokeEvent, ...args: A) => R | Promise<R> : T[K] extends Record<string, unknown> ? DeepIpcHandlers<T[K]> : never;
|
|
7
|
+
};
|
|
8
|
+
export declare function registerIpcHandlers<T>(wc: WebContents, prefix: string, handlers: DeepIpcHandlers<T>): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WebContents } from "electron";
|
|
2
|
+
import { type Handlers, type HubImpl, type Mount } from "../../shared/bridge/hub.js";
|
|
3
|
+
import type { Realm } from "../../shared/bridge/realm.js";
|
|
4
|
+
/** The bridge hub for a window, created on first mount and disposed with it. */
|
|
5
|
+
export declare function windowHub(contents: WebContents): HubImpl<Realm>;
|
|
6
|
+
/** Mount a typed contract for one window. */
|
|
7
|
+
export declare function mountIpcHandlers<T>(contents: WebContents, prefix: string, impl: Handlers<T, Realm>): Mount<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyvSqlite } from "@keyv/sqlite";
|
|
2
|
+
import { Keyv } from "keyv";
|
|
3
|
+
export default class HttpCacheStorage extends Keyv {
|
|
4
|
+
private driver;
|
|
5
|
+
constructor(driver: KeyvSqlite);
|
|
6
|
+
vacuum(): Promise<void>;
|
|
7
|
+
totalSize(): Promise<number>;
|
|
8
|
+
diskSize(): Promise<number>;
|
|
9
|
+
entryCount(): Promise<number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default class LyricCacheManager {
|
|
2
|
+
private readonly cacheDir;
|
|
3
|
+
private readonly maxSizeBytes;
|
|
4
|
+
private readonly entries;
|
|
5
|
+
private totalSizeBytes;
|
|
6
|
+
private readonly initPromise;
|
|
7
|
+
private evictionPromise;
|
|
8
|
+
constructor(cacheDir: string, maxSizeBytes?: number);
|
|
9
|
+
private buildEntriesIndex;
|
|
10
|
+
private ready;
|
|
11
|
+
private getEntryKey;
|
|
12
|
+
private resolveEntryPath;
|
|
13
|
+
get(songId: string): Promise<string | null>;
|
|
14
|
+
set(songId: string, content: string): Promise<void>;
|
|
15
|
+
getStats(): Promise<{
|
|
16
|
+
entryCount: number;
|
|
17
|
+
sizeBytes: number;
|
|
18
|
+
}>;
|
|
19
|
+
clear(): Promise<void>;
|
|
20
|
+
private evictIfNeeded;
|
|
21
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type PlayCacheConfig = {
|
|
2
|
+
ABName: string;
|
|
3
|
+
autoCacheSize: string;
|
|
4
|
+
configJson: string;
|
|
5
|
+
groupName: string;
|
|
6
|
+
manuSetting: unknown;
|
|
7
|
+
settingLowLimit: string;
|
|
8
|
+
settingUpLimit: string;
|
|
9
|
+
userSettingSize: string;
|
|
10
|
+
};
|
|
11
|
+
export type PlayCacheInfo = {
|
|
12
|
+
ABName: string;
|
|
13
|
+
autoCacheSize: number;
|
|
14
|
+
autoCacheSizeReal: number;
|
|
15
|
+
cachePath: string;
|
|
16
|
+
clearLimitMax: number;
|
|
17
|
+
clearToLimit: number;
|
|
18
|
+
configJson: string;
|
|
19
|
+
currentCachedSize: number;
|
|
20
|
+
diskFreeSize: number;
|
|
21
|
+
groupName: string;
|
|
22
|
+
manuSetting: boolean;
|
|
23
|
+
settingLowLimit: number;
|
|
24
|
+
settingUpLimit: number;
|
|
25
|
+
userSettingSize: number;
|
|
26
|
+
userSettingSizeReal: number;
|
|
27
|
+
};
|
|
28
|
+
export type CacheTrackMeta = {
|
|
29
|
+
bitrate: number;
|
|
30
|
+
cached: number;
|
|
31
|
+
dfsId: string;
|
|
32
|
+
format: string;
|
|
33
|
+
lastAccessTime: number;
|
|
34
|
+
lastModifyTime: number;
|
|
35
|
+
md5: string;
|
|
36
|
+
playInfoExist: boolean;
|
|
37
|
+
playInfoStr: string;
|
|
38
|
+
songId: string;
|
|
39
|
+
volumeGain: number;
|
|
40
|
+
fileSize: number;
|
|
41
|
+
};
|
|
42
|
+
export default class PlayCacheManager {
|
|
43
|
+
private config;
|
|
44
|
+
/** In-memory index of cached tracks, keyed by songId */
|
|
45
|
+
private trackIndex;
|
|
46
|
+
private initPromise;
|
|
47
|
+
private cachePath;
|
|
48
|
+
constructor(cachePath: string);
|
|
49
|
+
private buildIndex;
|
|
50
|
+
private ready;
|
|
51
|
+
setConfig(config: PlayCacheConfig): void;
|
|
52
|
+
getInfo(): Promise<PlayCacheInfo>;
|
|
53
|
+
queryCacheTracks(): Promise<CacheTrackMeta[]>;
|
|
54
|
+
getCachedTrack(songId: string): Promise<{
|
|
55
|
+
meta: CacheTrackMeta;
|
|
56
|
+
audioPath: string;
|
|
57
|
+
} | null>;
|
|
58
|
+
cacheTrack(songId: string, audioBuffer: Buffer, info: {
|
|
59
|
+
md5: string;
|
|
60
|
+
bitrate: number;
|
|
61
|
+
playInfoStr: string;
|
|
62
|
+
volumeGain: number;
|
|
63
|
+
fileSize: number;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
private evictIfNeeded;
|
|
66
|
+
private removeTrack;
|
|
67
|
+
clearAll(): Promise<void>;
|
|
68
|
+
private writeMeta;
|
|
69
|
+
private notifyPlayCacheUpdate;
|
|
70
|
+
private getCachedSizeGB;
|
|
71
|
+
private getDiskFreeGB;
|
|
72
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import LyricCacheManager from "./cache/LyricCahceManager.js";
|
|
2
|
+
import PlayCacheManager from "./cache/PlayCacheManager.js";
|
|
3
|
+
import HttpCacheStorage from "./cache/HttpCacheStorage.js";
|
|
4
|
+
export declare let lyricCacheManager: LyricCacheManager | null;
|
|
5
|
+
export declare let playCacheManager: PlayCacheManager | null;
|
|
6
|
+
export declare let httpCacheStorage: HttpCacheStorage | null;
|
|
7
|
+
export default function createCacheManager(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|