fix: dispose persistent-store effects; close comparisonStore effect leak

Thread the new createPersistentStore.destroy() through its owners so the
save effect.root is actually torn down: LayoutManager gains destroy();
ThemeManager and typographySettings dispose their #store in their existing
destroy().

comparisonStore had its own leak — a constructor $effect.root whose disposer
was discarded, and a module-level persistent storage created at import. Move
storage into the instance (#storage, created lazily per instance), capture
the effect.root disposer, add destroy(), and adopt createSingleton so reset
runs resetAll() + destroy(). Re-export createSingleton from the $shared/lib
barrel; give the test storage mock a destroy().
This commit is contained in:
Ilia Mashkov
2026-06-03 10:16:47 +03:00
parent ded9606c30
commit 0aae710e35
6 changed files with 53 additions and 23 deletions
@@ -166,6 +166,7 @@ export class TypographySettingsStore {
*/
destroy(): void {
this.#disposeEffects();
this.#storage.destroy();
}
/**
@@ -125,6 +125,7 @@ class ThemeManager {
destroy(): void {
this.#mediaQuery?.removeEventListener('change', this.#systemChangeHandler);
this.#mediaQuery = null;
this.#store.destroy();
}
/**