chore(format): run prettier over src/ and scripts/
Formatting was configured but never enforced: `bun run format:check` reported 199 unformatted files and ran in no workflow and in no git hook, so .prettierrc (printWidth 100, trailing commas) described an intention rather than the tree. This is the one-time sweep that makes the check gateable. Whitespace and token-reflow only -- no behavioural change: `bun run check` reports 0 errors and all 1053 frontend tests pass before and after. Kept out of every other commit on purpose. A 199-file diff mixed with real changes is unreviewable, and the next commit turns format:check into a hard CI gate so this cannot silently accumulate again.
This commit is contained in:
@@ -82,14 +82,14 @@ describe("createAdapter", () => {
|
||||
|
||||
it("requires a bridge for the HTML5 adapter", () => {
|
||||
expect(() =>
|
||||
createAdapter({ backendKind: "html5", host, experimentalNativeVideo: false })
|
||||
createAdapter({ backendKind: "html5", host, experimentalNativeVideo: false }),
|
||||
).toThrow(/bridge/i);
|
||||
});
|
||||
|
||||
// The native adapter owns no DOM element, so it must not demand a bridge.
|
||||
it("does not require a bridge for the native adapter", () => {
|
||||
expect(() =>
|
||||
createAdapter({ backendKind: "native", host, experimentalNativeVideo: true })
|
||||
createAdapter({ backendKind: "native", host, experimentalNativeVideo: true }),
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,9 @@ function makeBridge(overrides: Partial<Html5ElementBridge> = {}): Html5ElementBr
|
||||
return {
|
||||
getElement: () => null,
|
||||
getSeekOffset: () => offset,
|
||||
setSeekOffset: vi.fn((o: number) => { offset = o; }),
|
||||
setSeekOffset: vi.fn((o: number) => {
|
||||
offset = o;
|
||||
}),
|
||||
setStreamUrl: vi.fn(),
|
||||
destroyHls: vi.fn(),
|
||||
getMediaSourceId: () => "msid-1",
|
||||
@@ -102,7 +104,7 @@ describe("Html5PlayerAdapter", () => {
|
||||
it("play() does not report an interrupted-by-pause AbortError as an error", async () => {
|
||||
const abort = new DOMException(
|
||||
"The play() request was interrupted by a call to pause().",
|
||||
"AbortError"
|
||||
"AbortError",
|
||||
);
|
||||
video.play = vi.fn(async () => {
|
||||
throw abort;
|
||||
@@ -135,7 +137,7 @@ describe("Html5PlayerAdapter", () => {
|
||||
video.paused = false;
|
||||
r();
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const first = adapter.play();
|
||||
|
||||
@@ -257,11 +257,7 @@ export class Html5PlayerAdapter implements PlayerAdapter {
|
||||
* distinction is the caller's to act on: a missing `seeked` is cosmetic, a
|
||||
* missing `canplay` means the reload failed.
|
||||
*/
|
||||
private waitForEvent(
|
||||
el: HTMLVideoElement,
|
||||
event: string,
|
||||
timeoutMs: number
|
||||
): Promise<boolean> {
|
||||
private waitForEvent(el: HTMLVideoElement, event: string, timeoutMs: number): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
const done = (fired: boolean) => {
|
||||
el.removeEventListener(event, listener);
|
||||
|
||||
@@ -30,8 +30,14 @@ import type { AdapterHost } from "./types";
|
||||
|
||||
function makeHost(): AdapterHost {
|
||||
return {
|
||||
onState: vi.fn(), onPosition: vi.fn(), onMediaLoaded: vi.fn(), onEnded: vi.fn(),
|
||||
onError: vi.fn(), onStreamUrlChanged: vi.fn(), onBuffering: vi.fn(), onReady: vi.fn(),
|
||||
onState: vi.fn(),
|
||||
onPosition: vi.fn(),
|
||||
onMediaLoaded: vi.fn(),
|
||||
onEnded: vi.fn(),
|
||||
onError: vi.fn(),
|
||||
onStreamUrlChanged: vi.fn(),
|
||||
onBuffering: vi.fn(),
|
||||
onReady: vi.fn(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,9 +73,14 @@ describe("NativePlayerAdapter", () => {
|
||||
|
||||
it("load() seeds a resume position", async () => {
|
||||
await adapter.load("url", {
|
||||
mediaId: "m", mediaSourceId: null, needsTranscoding: false,
|
||||
initialPosition: 90, isLive: false, audioTrackIndex: null,
|
||||
knownDuration: 0, subtitleTracks: [],
|
||||
mediaId: "m",
|
||||
mediaSourceId: null,
|
||||
needsTranscoding: false,
|
||||
initialPosition: 90,
|
||||
isLive: false,
|
||||
audioTrackIndex: null,
|
||||
knownDuration: 0,
|
||||
subtitleTracks: [],
|
||||
});
|
||||
expect(adapter.getPosition()).toBe(90);
|
||||
});
|
||||
@@ -80,18 +91,28 @@ describe("NativePlayerAdapter", () => {
|
||||
// adapter must actually *issue* the seek.
|
||||
it("load() issues the resume seek to the backend, not just records it", async () => {
|
||||
await adapter.load("url", {
|
||||
mediaId: "m", mediaSourceId: null, needsTranscoding: false,
|
||||
initialPosition: 90, isLive: false, audioTrackIndex: null,
|
||||
knownDuration: 0, subtitleTracks: [],
|
||||
mediaId: "m",
|
||||
mediaSourceId: null,
|
||||
needsTranscoding: false,
|
||||
initialPosition: 90,
|
||||
isLive: false,
|
||||
audioTrackIndex: null,
|
||||
knownDuration: 0,
|
||||
subtitleTracks: [],
|
||||
});
|
||||
expect(playerSeek).toHaveBeenCalledWith(90);
|
||||
});
|
||||
|
||||
it("load() does not seek when starting from the beginning", async () => {
|
||||
await adapter.load("url", {
|
||||
mediaId: "m", mediaSourceId: null, needsTranscoding: false,
|
||||
initialPosition: 0, isLive: false, audioTrackIndex: null,
|
||||
knownDuration: 0, subtitleTracks: [],
|
||||
mediaId: "m",
|
||||
mediaSourceId: null,
|
||||
needsTranscoding: false,
|
||||
initialPosition: 0,
|
||||
isLive: false,
|
||||
audioTrackIndex: null,
|
||||
knownDuration: 0,
|
||||
subtitleTracks: [],
|
||||
});
|
||||
expect(playerSeek).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -100,9 +121,14 @@ describe("NativePlayerAdapter", () => {
|
||||
// no-op and at worst knocks the HLS window off its live edge.
|
||||
it("load() never seeks a live stream", async () => {
|
||||
await adapter.load("url", {
|
||||
mediaId: "m", mediaSourceId: null, needsTranscoding: false,
|
||||
initialPosition: 90, isLive: true, audioTrackIndex: null,
|
||||
knownDuration: 0, subtitleTracks: [],
|
||||
mediaId: "m",
|
||||
mediaSourceId: null,
|
||||
needsTranscoding: false,
|
||||
initialPosition: 90,
|
||||
isLive: true,
|
||||
audioTrackIndex: null,
|
||||
knownDuration: 0,
|
||||
subtitleTracks: [],
|
||||
});
|
||||
expect(playerSeek).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ export class NativePlayerAdapter implements PlayerAdapter {
|
||||
}
|
||||
|
||||
async selectSubtitle(streamIndex: number | null, arrayIndex?: number): Promise<void> {
|
||||
const indexToUse = streamIndex === null ? null : arrayIndex ?? streamIndex;
|
||||
const indexToUse = streamIndex === null ? null : (arrayIndex ?? streamIndex);
|
||||
await commands.playerSetSubtitleTrack(indexToUse);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ let lastPositionReport = 0;
|
||||
|
||||
export async function reportState(
|
||||
state: "playing" | "paused" | "loading" | "stopped" | "idle",
|
||||
mediaId: string | null
|
||||
mediaId: string | null,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await commands.playerReportState(state, mediaId);
|
||||
@@ -47,7 +47,7 @@ export async function reportState(
|
||||
export async function reportPosition(
|
||||
position: number,
|
||||
duration: number,
|
||||
{ force = false }: ReportPositionOptions = {}
|
||||
{ force = false }: ReportPositionOptions = {},
|
||||
): Promise<void> {
|
||||
const now = Date.now();
|
||||
if (!force && now - lastPositionReport < POSITION_REPORT_INTERVAL_MS) {
|
||||
@@ -81,7 +81,9 @@ export function resetReporting(): void {
|
||||
*/
|
||||
export function createRustReportHost(
|
||||
mediaId: string,
|
||||
view: Partial<Pick<AdapterHost, "onStreamUrlChanged" | "onBuffering" | "onReady" | "onEnded" | "onError">> = {}
|
||||
view: Partial<
|
||||
Pick<AdapterHost, "onStreamUrlChanged" | "onBuffering" | "onReady" | "onEnded" | "onError">
|
||||
> = {},
|
||||
): AdapterHost {
|
||||
return {
|
||||
onState: (state) => void reportState(state, mediaId),
|
||||
|
||||
+7
-10
@@ -136,7 +136,7 @@ async function seek(positionSeconds: number) {
|
||||
async function seekVideo(
|
||||
positionSeconds: number,
|
||||
mediaSourceId: string | null,
|
||||
audioTrackIndex: number | null
|
||||
audioTrackIndex: number | null,
|
||||
): Promise<void> {
|
||||
const adapter = activeAdapter;
|
||||
if (!adapter) {
|
||||
@@ -148,7 +148,7 @@ async function seekVideo(
|
||||
positionSeconds,
|
||||
mediaSourceId,
|
||||
audioTrackIndex,
|
||||
adapter.kind === "html5"
|
||||
adapter.kind === "html5",
|
||||
)) as any;
|
||||
// Serde keeps these snake_case (only the "strategy" tag is camelCase).
|
||||
if (response.strategy === "reloadStream") {
|
||||
@@ -169,7 +169,7 @@ async function switchAudioTrack(
|
||||
streamIndex: number,
|
||||
arrayIndex: number,
|
||||
currentPosition: number | null,
|
||||
mediaSourceId: string | null
|
||||
mediaSourceId: string | null,
|
||||
): Promise<void> {
|
||||
const adapter = activeAdapter;
|
||||
if (!adapter) return;
|
||||
@@ -179,7 +179,7 @@ async function switchAudioTrack(
|
||||
arrayIndex,
|
||||
adapter.kind === "html5",
|
||||
currentPosition,
|
||||
mediaSourceId
|
||||
mediaSourceId,
|
||||
)) as any;
|
||||
if (response.strategy === "reloadStream") {
|
||||
await adapter.reloadSource(response.new_url!, response.position!);
|
||||
@@ -198,7 +198,7 @@ async function setStreamQuality(
|
||||
quality: StreamingQuality,
|
||||
currentPosition: number | null,
|
||||
mediaSourceId: string | null,
|
||||
audioTrackIndex: number | null
|
||||
audioTrackIndex: number | null,
|
||||
): Promise<void> {
|
||||
const adapter = activeAdapter;
|
||||
if (!adapter) return;
|
||||
@@ -208,7 +208,7 @@ async function setStreamQuality(
|
||||
adapter.kind === "html5",
|
||||
currentPosition,
|
||||
mediaSourceId,
|
||||
audioTrackIndex
|
||||
audioTrackIndex,
|
||||
)) as any;
|
||||
// Serde keeps these snake_case (only the "strategy" tag is camelCase).
|
||||
if (response.strategy === "reloadStream") {
|
||||
@@ -305,10 +305,7 @@ async function addTrackById(trackId: string, position: "next" | "end" = "end") {
|
||||
}
|
||||
|
||||
/** Add multiple tracks to the queue by ID. */
|
||||
async function addTracksByIds(
|
||||
trackIds: string[],
|
||||
position: "next" | "end" = "end"
|
||||
) {
|
||||
async function addTracksByIds(trackIds: string[], position: "next" | "end" = "end") {
|
||||
await commands.playerAddTracksByIds(requireHandle(), { trackIds, position });
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("downloadedFilePath", () => {
|
||||
// Rows only hold a relative path before the worker completes them, but a
|
||||
// half-migrated database can still carry one.
|
||||
expect(downloadedFilePath("/var/data/jellytau", "videos/film.mp4")).toBe(
|
||||
"/var/data/jellytau/videos/film.mp4"
|
||||
"/var/data/jellytau/videos/film.mp4",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user