import { Requester } from "../requester" ; import { TabRepository } from "./tab" ; import { ChildProcess } from "child_process" ; import { WithError , NullableError } from "../error" ; export type History = { title : string ; url ? : string ; } ; export class HistoryRepository { constructor ( protected readonly requester , protected readonly tabRepository ) { } public async search ( ) { const [ histories , error ] = await this . requester . execute < History [ ] > ( { method : "history/search" , params : { } , } ) ; if ( histories === null ) { return [ [ ] , error ] ; } return [ histories , error ] ; } public async remove ( urls ) { return this . requester . batchNotify ( urls . map ( url => { return { method : "history/remove" , params : { url : url } } ; } ) ) ; } public async onCreated ( callback ) { return this . requester . receiveAsyncOnEvent < History > ( { } , { body : { eventName : "historyCreated" } } , { } , callback ) ; } public async open ( url ) { return this . tabRepository . open ( url ) ; } public async tabOpen ( urls ) { return this . tabRepository . tabOpen ( urls ) ; } }