Files
readest/apps/readest-app/src/workers/txt-converter.worker.ts
T
Huang Xin 956c71cd7b chore: migrate from ESLint to Biome for linting (#3694)
Replace ESLint with Biome for ~14x faster linting (~360ms vs ~5s).

- Add biome.json with rules matching ESLint parity (Next.js, a11y,
  TypeScript, unused vars/imports)
- Remove eslint, @typescript-eslint/*, eslint-config-next,
  eslint-plugin-jsx-a11y, @eslint/* from deps
- Remove eslint.config.mjs
- Update lint script to: tsgo --noEmit && biome check .
- Fix 11 real code issues caught by Biome (banned types, explicit any,
  unsafe finally, unreachable code, shadowed names)
- Disable Biome formatter (Prettier stays for Tailwind class sorting)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:25:04 +02:00

39 lines
1.2 KiB
TypeScript

import { TxtToEpubConverter } from '../utils/txt';
import {
TxtConverterWorkerRequest,
TxtConverterWorkerResponse,
} from '../utils/txt-worker-protocol';
const workerContext: DedicatedWorkerGlobalScope = self as unknown as DedicatedWorkerGlobalScope;
workerContext.onmessage = async (event: MessageEvent<TxtConverterWorkerRequest>) => {
if (event.data.type !== 'convert') return;
const { file, author, language } = event.data.payload;
try {
const converter = new TxtToEpubConverter();
const result = await converter.convert({ file, author, language });
const epubBuffer = await result.file.arrayBuffer();
const response: TxtConverterWorkerResponse = {
type: 'success',
payload: {
epubBuffer,
name: result.file.name,
bookTitle: result.bookTitle,
chapterCount: result.chapterCount,
language: result.language,
},
};
workerContext.postMessage(response, [epubBuffer]);
} catch (error) {
const response: TxtConverterWorkerResponse = {
type: 'error',
payload: {
message: error instanceof Error ? error.message : String(error),
},
};
workerContext.postMessage(response);
}
};