Returns a corpus-keyed cache function that builds an ItemSearchIndex<T>
on first access for a given corpus reference and returns the same instance
on subsequent calls with the same reference.
Callers hold the returned getter at module scope so the WeakMap lifetime
matches the module, not any component tree. When the corpus array is
replaced (e.g. after a DB mutation via useSyncExternalStore), the old
entry is automatically garbage-collected.
Returns a corpus-keyed cache function that builds an
ItemSearchIndex<T>on first access for a given corpus reference and returns the same instance on subsequent calls with the same reference.Callers hold the returned getter at module scope so the
WeakMaplifetime matches the module, not any component tree. When the corpus array is replaced (e.g. after a DB mutation viauseSyncExternalStore), the old entry is automatically garbage-collected.