// THE BINDING between the shared search pipeline and this app's caches. // // Everything that used to live here — the three worker-pool drivers, the leaf // adapter, the cue/text matchers — is `lib/search/leafPipeline.ts` now, where // `lib/searchEval.ts` can reach it without `lib/` importing `components/`. // What is left is the one thing that genuinely belongs to the view layer: WHICH // FETCH. `fetchTranscript` / `fetchSubs` / `fetchPost` are the react-query-backed // page caches, and they are supplied here rather than imported there. // // Every name this module exported before is still exported from it, so the five // files that import `LayerHit` from `components/searchPipeline` (including // `export/app/lib/askRetrieval.ts`) are untouched. import { fetchTranscript } from "./transcriptCache"; import { fetchSubs } from "./subsCache"; import { fetchPost } from "./postsCache"; import { runLeafPipeline as runLeafPipelineWith, type LeafController, type LeafFetchers, type LeafPipelineOptions, } from "../lib/search/leafPipeline"; import { cacheKey, getCached, getCachedSync, putCached, } from "./searchLayerCache"; import type { SearchRuntime } from "../lib/searchEval"; export type { Hit, SubsHit, LayerHit, PipelineUpdate, PipelineController, SubsPipelineUpdate, LeafProgress, LeafResult, LeafController, } from "../lib/search/leafPipeline"; export { filterSlugs } from "../lib/search/leafPipeline"; // This app's three fetches, as one injectable bundle. const CACHE_FETCHERS: LeafFetchers = { transcript: fetchTranscript, subs: fetchSubs, post: fetchPost, }; export function runLeafPipeline( opts: Omit, ): LeafController { return runLeafPipelineWith({ ...opts, fetchers: CACHE_FETCHERS }); } // What `runQueryTree` is handed: the fetch-bound leaf runner plus the // IndexedDB-backed layer memo. `lib/searchEval.ts` owns the tree algebra and // knows nothing about either. export const searchRuntime: SearchRuntime = { runLeaf: runLeafPipeline, cache: { key: cacheKey, getSync: getCachedSync, get: getCached, put: putCached, }, };