refactor(launcher): split history.ts into focused modules

- Extract types → history-types.ts, DB layer → history-db.ts, navigation → history-navigation.ts
- history.ts becomes a re-export barrel
- Fix findNextEpisode: deleted-file fallback now advances to next season
- Add isReadonlyWalRetryError (WAL-mode guard before read-write retry)
- Strengthen bun-sqlite.d.ts with generics on Statement/query/prepare
This commit is contained in:
2026-07-05 00:57:06 -07:00
parent f4c98278c1
commit 651e541ea8
6 changed files with 324 additions and 239 deletions
+11 -7
View File
@@ -7,10 +7,10 @@ declare module 'bun:sqlite' {
lastInsertRowid: number | bigint;
}
export interface Statement {
all(...params: unknown[]): unknown[];
get(...params: unknown[]): unknown;
run(...params: unknown[]): RunResult;
export interface Statement<ReturnType = unknown, ParamsType extends unknown[] = unknown[]> {
all(...params: ParamsType): ReturnType[];
get(...params: ParamsType): ReturnType | undefined;
run(...params: ParamsType): RunResult;
}
export class Database {
@@ -18,9 +18,13 @@ declare module 'bun:sqlite' {
filename: string,
options?: { readonly?: boolean; readwrite?: boolean; create?: boolean },
);
query(sql: string): Statement;
prepare(sql: string): Statement;
query<ReturnType = unknown, ParamsType extends unknown[] = unknown[]>(
sql: string,
): Statement<ReturnType, ParamsType>;
prepare<ReturnType = unknown, ParamsType extends unknown[] = unknown[]>(
sql: string,
): Statement<ReturnType, ParamsType>;
run(sql: string, ...params: unknown[]): RunResult;
close(): void;
close(throwOnError?: boolean): void;
}
}