refactor: migrate storage wrappers to WXT typed items#26
Open
skid-dev wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/storage/items.tswithstorage.defineItemfor the singleton keys (sync:settings,local:recent_pages) and thinstorage.getItem/setItemwrappers for the dynamic per-channel (local:news_channel_*) and per-revision (local:news_recent_*) keys.src/storage/get.ts,set.ts,viewed_pages.ts, andrevisions/*against those helpers. Public function signatures unchanged so all existing callers (background, content scripts, entrypoints) still work without edits.src/background/set_setting.tsandset_default_settings.tsto usesettings_item.getValue/setValueinstead of rawchrome.storage.sync.get/set.src/storage/revisions/common.ts(key prefix lives initems.ts) and the unusedensure_recents_existshelper (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-scriptsnpx wxt preparenpm run typecheckpassesnpm run buildsucceeds and produces 11 JS entries + 9 CSS files.output/chrome-mv3/manifest.jsonis byte-identical to the manifest produced from the migration branchSkipped browser e2e (refactor only, no behaviour change intended).
Generated with Claude Opus 4.7 (1M context).