( bookId: string, filePath: string, onProgress?: VectorizeStatusCallback, )
| 21 | * then delegates to the core pipeline. |
| 22 | */ |
| 23 | export async function triggerVectorizeBook( |
| 24 | bookId: string, |
| 25 | filePath: string, |
| 26 | onProgress?: VectorizeStatusCallback, |
| 27 | ): Promise<void> { |
| 28 | // Resolve managed relative paths (e.g., "books/{id}.epub") to the active desktop library root. |
| 29 | const resolvedPath = await resolveDesktopDataPath(filePath); |
| 30 | |
| 31 | const vmState = useVectorModelStore.getState(); |
| 32 | |
| 33 | // Build platform-agnostic config from Zustand store |
| 34 | const config: VectorizeTriggerConfig = { |
| 35 | vectorModelEnabled: vmState.vectorModelEnabled, |
| 36 | vectorModelMode: vmState.vectorModelMode, |
| 37 | selectedBuiltinModelId: vmState.selectedBuiltinModelId, |
| 38 | remoteModel: (() => { |
| 39 | const selected = vmState.getSelectedVectorModel(); |
| 40 | if (!selected) return null; |
| 41 | return { |
| 42 | url: selected.url, |
| 43 | apiKey: selected.apiKey, |
| 44 | modelId: selected.modelId, |
| 45 | }; |
| 46 | })(), |
| 47 | }; |
| 48 | |
| 49 | // Build callbacks that write back to Zustand store |
| 50 | const callbacks = { |
| 51 | onBookUpdate: useLibraryStore.getState().updateBook, |
| 52 | }; |
| 53 | |
| 54 | // Extract chapters from the book file (platform-specific: Tauri + foliate-js) |
| 55 | const chapters = await extractBookChapters(resolvedPath); |
| 56 | |
| 57 | // Delegate to core |
| 58 | await coreTriggerVectorizeBook(bookId, chapters, config, callbacks, onProgress); |
| 59 | } |
no test coverage detected