import { WxtStorageItem } from "wxt/storage"; export const defaultPreferences = { enabled: [ "favoritedPlaces", "bestFriends", "forumMentions", "improvedFriendLists", "irlBrickPrice", "storeOwnedTags", "tryItems", "outfitCost", "placeRevenue", "accurateOwners", ], config: { irlBrickPrice: { currency: "USD", }, membershipThemes: { themeId: "plus", }, placeManagement: { activityToggle: true, download: true, multipleWhitelist: true, clearWhitelist: true, }, }, }; export type preferencesSchema = typeof defaultPreferences & { [key: string]: any; }; // Sync interface PreferencesStorageItem extends WxtStorageItem { /** * Wrapper for the standard `.getValue()` method that merges the user's saved preferences with the default preferences to make sure there are no unexpected errors. */ getPreferences: () => Promise; } export const preferences: PreferencesStorageItem = storage.defineItem( "sync:preferences", { fallback: defaultPreferences, version: 3, migrations: { 3: () => defaultPreferences, }, }, ) as PreferencesStorageItem; export const _favoritedPlaces = storage.defineItem( "sync:favoritedPlaces", { fallback: [], version: 1, }, ); export const _bestFriends = storage.defineItem("sync:bestFriends", { fallback: [], version: 1, }); preferences.getPreferences = async function () { const userPreferences = await this.getValue(); return { ...defaultPreferences, ...userPreferences }; }; // Cache export const cache = storage.defineItem("local:cache", { fallback: { favoritedPlaces: [], bestFriends: [], inventory: [], userIDs: {}, avatars: {}, items: {}, placeRevenue: {}, ownerCount: {}, }, version: 1, });