Files
brk/website_next/ask/tools/source/index.js
T
2026-07-29 10:50:14 +02:00

35 lines
869 B
JavaScript

import { WorkerClient } from "../worker-client.js";
const WORKER_URL = import.meta.resolve("./worker.js");
export class AskSource {
#client = new WorkerClient(WORKER_URL, {
failed: "The source worker failed",
stopped: "Source search stopped",
});
prewarm() {
return this.#client.request("prewarm", {});
}
/**
* @param {string} query
* @param {string | undefined} path
* @param {"definition" | "implementation" | "availability" | undefined} focus
* @param {((progress: { loaded: number, total: number }) => void) | undefined} [onProgress]
*/
search(query, path, focus, onProgress) {
return this.#client.request(
"search",
{ query, path, focus },
onProgress
? ({ loaded, total }) => onProgress({ loaded, total })
: undefined,
);
}
terminate() {
this.#client.terminate();
}
}