fix(shared): give createPersistentStore a destroy() to dispose its effect.root

The store created an $effect.root for the save-on-change sync but returned no
disposer, so the effect leaked for the life of the process — contradicting
the rule that $effect.root owners must expose destroy(). Capture and expose
the disposer.

- add destroy() to the returned store; covered by tests (flushSync proves the
  save effect runs before destroy and stops after)
- trim the bloated header (two near-duplicate @example blocks) to one concise
  JSDoc — no fluff
- update typographySettings test mocks to satisfy the now-required destroy()

Consumers (LayoutManager, ThemeManager, typographySettings, comparisonStore)
do not yet call it — threading + the createSingleton migration follow.
This commit is contained in:
Ilia Mashkov
2026-06-03 10:00:21 +03:00
parent f0736f4d35
commit ded9606c30
3 changed files with 62 additions and 61 deletions
@@ -51,6 +51,7 @@ describe('TypographySettingsStore - Unit Tests', () => {
let mockPersistentStore: {
value: TypographySettings;
clear: () => void;
destroy: () => void;
};
const createMockPersistentStore = (initialValue: TypographySettings) => {
@@ -70,6 +71,7 @@ describe('TypographySettingsStore - Unit Tests', () => {
letterSpacing: DEFAULT_LETTER_SPACING,
};
},
destroy() {},
};
};
@@ -535,6 +537,7 @@ describe('TypographySettingsStore - Unit Tests', () => {
mockStorage = v;
},
clear: clearSpy,
destroy() {},
};
const manager = new TypographySettingsStore(