Skip to content

refactor: migrate storage wrappers to WXT typed items#26

Open
skid-dev wants to merge 1 commit into
claude/recursing-goldberg-5b5636from
claude/recursing-goldberg-storage-wxt
Open

refactor: migrate storage wrappers to WXT typed items#26
skid-dev wants to merge 1 commit into
claude/recursing-goldberg-5b5636from
claude/recursing-goldberg-storage-wxt

Conversation

@skid-dev
Copy link
Copy Markdown
Owner

Summary

  • Add src/storage/items.ts with storage.defineItem for the singleton keys (sync:settings, local:recent_pages) and thin storage.getItem/setItem wrappers for the dynamic per-channel (local:news_channel_*) and per-revision (local:news_recent_*) keys.
  • Rewrite src/storage/get.ts, set.ts, viewed_pages.ts, and revisions/* against those helpers. Public function signatures unchanged so all existing callers (background, content scripts, entrypoints) still work without edits.
  • Update src/background/set_setting.ts and set_default_settings.ts to use settings_item.getValue / setValue instead of raw chrome.storage.sync.get/set.
  • Drop the now-empty src/storage/revisions/common.ts (key prefix lives in items.ts) and the unused ensure_recents_exists helper (fallback: [] makes it a no-op).

Storage area per key is preserved exactly — sync for settings, local for everything else — so this is a behaviour-preserving refactor only.

Test plan

  • npm install --ignore-scripts
  • npx wxt prepare
  • npm run typecheck passes
  • npm run build succeeds and produces 11 JS entries + 9 CSS files
  • .output/chrome-mv3/manifest.json is byte-identical to the manifest produced from the migration branch

Skipped browser e2e (refactor only, no behaviour change intended).

Generated with Claude Opus 4.7 (1M context).

Replace raw chrome.storage.sync/local calls in src/storage/* and
src/background/set_setting.ts with WXT's storage.defineItem and
storage.getItem/setItem helpers. Storage areas are preserved per key
(sync for settings, local for news channels / recents / revisions).

- Add src/storage/items.ts: typed singletons (settings_item, recents_item)
  and small wrappers (get_/set_news_channel_items, get_/set_revision_entry,
  list_news_channel_names) over storage.getItem/setItem for the dynamic
  per-channel and per-revision keys.
- Rewrite get.ts / set.ts / viewed_pages.ts / revisions/* against those
  helpers. Public function signatures unchanged so existing callers in
  background, content scripts, and entrypoints keep working.
- Update set_default_settings.ts + set_setting.ts to read/write the
  Settings object through settings_item instead of poking storage directly.
- Drop revisions/common.ts (the legacy news_recent_ prefix now lives in
  items.ts) and the unused ensure_recents_exists() helper that the
  fallback: [] default makes unnecessary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant