@lavalogic/scoria 0.37.51 → 0.37.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -711,14 +711,35 @@ export class FocusState {
|
|
|
711
711
|
* the call-site signature clean for cell consumers.
|
|
712
712
|
*/
|
|
713
713
|
getFocusDetailsFor(cell) {
|
|
714
|
-
|
|
715
|
-
if (
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
714
|
+
const cached = this._focusDetailsCache.get(cell);
|
|
715
|
+
if (cached) {
|
|
716
|
+
return cached;
|
|
717
|
+
}
|
|
718
|
+
// The TableContext ref is supplied via a thunk to keep this
|
|
719
|
+
// sub-context decoupled from the parent.
|
|
720
|
+
const parent = this._deps.getTableContextRef();
|
|
721
|
+
// `TableFocusDetails` exposes its whole surface as `$derived` /
|
|
722
|
+
// `$derived.by` fields. This factory is invoked by cell components
|
|
723
|
+
// from inside a `$derived(...)` expression, so constructing the
|
|
724
|
+
// instance inline would bind those deriveds to whichever cell
|
|
725
|
+
// component first missed the cache. That component is destroyed on
|
|
726
|
+
// the next re-render / scroll, leaving the cached instance's
|
|
727
|
+
// deriveds owned by a dead scope - Svelte's `derived_inert` warning,
|
|
728
|
+
// and stale focus-outline values for every later reader. Building it
|
|
729
|
+
// inside an `$effect.root` gives the deriveds a standalone owner that
|
|
730
|
+
// outlives any single cell. The root is reachable only through the
|
|
731
|
+
// `WeakMap`-cached instance, so it is collected together with the
|
|
732
|
+
// cell and needs no explicit teardown.
|
|
733
|
+
let created;
|
|
734
|
+
$effect.root(() => {
|
|
735
|
+
created = new TableFocusDetails(cell, parent);
|
|
736
|
+
});
|
|
737
|
+
if (!created) {
|
|
738
|
+
// `$effect.root` runs its callback synchronously, so this is
|
|
739
|
+
// unreachable; it exists only to narrow the type below.
|
|
740
|
+
throw new Error('getFocusDetailsFor: TableFocusDetails was not constructed');
|
|
741
|
+
}
|
|
742
|
+
this._focusDetailsCache.set(cell, created);
|
|
743
|
+
return created;
|
|
723
744
|
}
|
|
724
745
|
}
|