Skip to content

Commit

Permalink
feat(storage): port storage api from dev
Browse files Browse the repository at this point in the history
move old storage api as legacy
  • Loading branch information
pylixonly committed Oct 13, 2024
1 parent f2f1f6a commit 122c3a1
Show file tree
Hide file tree
Showing 30 changed files with 430 additions and 443 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"yargs-parser": "^21.1.1"
},
"dependencies": {
"@gullerya/object-observer": "^6.1.3",
"@shopify/react-native-skia": "^1.3.8",
"@tanstack/react-query": "^5.51.16",
"@types/chroma-js": "~2.4.4",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/plugins/quickinstall/forumPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VdPluginManager } from "@core/vendetta/plugins";
import { findAssetId } from "@lib/api/assets";
import { isThemeSupported } from "@lib/api/native/loader";
import { after } from "@lib/api/patcher";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { installTheme, removeTheme, themes } from "@lib/addons/themes";
import { VD_DISCORD_SERVER_ID, HTTP_REGEX_MULTI, VD_PLUGINS_CHANNEL_ID, VD_THEMES_CHANNEL_ID, VD_PROXY_PREFIX } from "@lib/utils/constants";
import { lazyDestructure } from "@lib/utils/lazy";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/components/AddonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CardWrapper } from "@core/ui/components/AddonCard";
import { findAssetId } from "@lib/api/assets";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import AlertModal, { AlertActionButton } from "@lib/ui/components/wrappers/AlertModal";
import isValidHttpUrl from "@lib/utils/isValidHttpUrl";
import { lazyDestructure } from "@lib/utils/lazy";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Strings } from "@core/i18n";
import { findAssetId } from "@lib/api/assets";
import { isFontSupported, isThemeSupported } from "@lib/api/native/loader";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { registerSection } from "@ui/settings";
import { version } from "bunny-build-info";

Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Developer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { findAssetId } from "@lib/api/assets";
import { connectToDebugger } from "@lib/api/debug";
import { getReactDevToolsProp, getReactDevToolsVersion, isLoaderConfigSupported, isReactDevToolsPreloaded, isVendettaLoader } from "@lib/api/native/loader";
import { loaderConfig, settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { lazyDestructure } from "@lib/utils/lazy";
import { NavigationNative } from "@metro/common";
import { Button, LegacyFormText, Stack, TableRow, TableRowGroup, TableSwitchRow, TextInput } from "@metro/common/components";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Fonts/FontCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Strings } from "@core/i18n";
import { CardWrapper } from "@core/ui/components/AddonCard";
import { findAssetId } from "@lib/api/assets";
import { BundleUpdaterManager } from "@lib/api/native/modules";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { FontDefinition, fonts, selectFont } from "@lib/addons/fonts";
import { lazyDestructure } from "@lib/utils/lazy";
import { findByProps } from "@metro";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Fonts/FontEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatString, Strings } from "@core/i18n";
import { findAssetId } from "@lib/api/assets";
import { createProxy, useProxy } from "@lib/api/storage";
import { createProxy, useProxy } from "@core/vendetta/storage";
import { FontDefinition, fonts, removeFont, saveFont, validateFont } from "@lib/addons/fonts";
import { getCurrentTheme } from "@lib/addons/themes";
import { safeFetch } from "@lib/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Fonts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Strings } from "@core/i18n";
import AddonPage from "@core/ui/components/AddonPage";
import FontEditor from "@core/ui/settings/pages/Fonts/FontEditor";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { FontDefinition, fonts } from "@lib/addons/fonts";
import { NavigationNative } from "@metro/common";

Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/General/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Strings } from "@core/i18n";
import Version from "@core/ui/settings/pages/General/Version";
import { getDebugInfo } from "@lib/api/debug";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { Stack, TableRowGroup } from "@metro/common/components";
import { Platform, ScrollView } from "react-native";

Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/General/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import About from "@core/ui/settings/pages/General/About";
import { findAssetId } from "@lib/api/assets";
import { getDebugInfo, toggleSafeMode } from "@lib/api/debug";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { DISCORD_SERVER, GITHUB } from "@lib/utils/constants";
import { NavigationNative, url } from "@metro/common";
import { Stack, TableRow, TableRowGroup, TableSwitchRow } from "@metro/common/components";
Expand Down
8 changes: 4 additions & 4 deletions src/core/ui/settings/pages/Plugins/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import PluginCard from "@core/ui/settings/pages/Plugins/components/PluginCard";
import { VdPluginManager } from "@core/vendetta/plugins";
import { findAssetId } from "@lib/api/assets";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy as useNewProxy } from "@lib/api/storage/new";
import { useProxy } from "@core/vendetta/storage";
import { useObservable } from "@lib/api/storage";
import { showToast } from "@lib/ui/toasts";
import { BUNNY_PROXY_PREFIX, VD_PROXY_PREFIX } from "@lib/utils/constants";
import { lazyDestructure } from "@lib/utils/lazy";
Expand Down Expand Up @@ -33,7 +33,7 @@ export interface UnifiedPluginModel {
id: string;
name: string;
description?: string;
authors?: Author;
authors?: Author[];
icon?: string;

isEnabled(): boolean;
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function Plugins() {
return <PluginPage
useItems={() => {
useProxy(VdPluginManager.plugins);
useNewProxy(pluginSettings);
useObservable([pluginSettings]);

const vdPlugins = Object.values(VdPluginManager.plugins).map(unifyVdPlugin);
const bnPlugins = [...registeredPlugins.values()].filter(p => isPluginInstalled(p.id) && !isCorePlugin(p.id)).map(unifyBunnyPlugin);
Expand Down
4 changes: 2 additions & 2 deletions src/core/ui/settings/pages/Plugins/models/bunny.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useProxy } from "@lib/api/storage/new";
import { disablePlugin, enablePlugin, getId, getPluginSettingsComponent, isPluginEnabled, pluginSettings } from "@lib/addons/plugins";
import { BunnyPluginManifest } from "@lib/addons/plugins/types";

import { UnifiedPluginModel } from "..";
import { useObservable } from "@lib/api/storage";

export default function unifyBunnyPlugin(manifest: BunnyPluginManifest): UnifiedPluginModel {
return {
Expand All @@ -13,7 +13,7 @@ export default function unifyBunnyPlugin(manifest: BunnyPluginManifest): Unified
isEnabled: () => isPluginEnabled(getId(manifest)),
isInstalled: () => manifest.id in pluginSettings,
usePluginState() {
useProxy(pluginSettings);
useObservable([pluginSettings]);
},
toggle(start: boolean) {
start
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Plugins/models/vendetta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VdPluginManager, VendettaPlugin } from "@core/vendetta/plugins";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";

import { UnifiedPluginModel } from "..";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatString, Strings } from "@core/i18n";
import { VdPluginManager } from "@core/vendetta/plugins";
import { findAssetId } from "@lib/api/assets";
import { purgeStorage } from "@lib/api/storage";
import { purgeStorage } from "@core/vendetta/storage";
import { clipboard } from "@metro/common";
import { ActionSheet, ActionSheetRow, Button, TableRow, Text } from "@metro/common/components";
import { showConfirmationAlert } from "@core/vendetta/alerts";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Themes/ThemeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { formatString, Strings } from "@core/i18n";
import AddonCard, { CardWrapper } from "@core/ui/components/AddonCard";
import { findAssetId } from "@lib/api/assets";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { applyTheme, fetchTheme, removeTheme, selectTheme, Theme, themes } from "@lib/addons/themes";
import { clipboard } from "@metro/common";
import { showConfirmationAlert } from "@core/vendetta/alerts";
Expand Down
2 changes: 1 addition & 1 deletion src/core/ui/settings/pages/Themes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { formatString, Strings } from "@core/i18n";
import AddonPage from "@core/ui/components/AddonPage";
import ThemeCard from "@core/ui/settings/pages/Themes/ThemeCard";
import { settings } from "@lib/api/settings";
import { useProxy } from "@lib/api/storage";
import { useProxy } from "@core/vendetta/storage";
import { installTheme, Theme, themes } from "@lib/addons/themes";
import { Button } from "@metro/common/components";
import { Author } from "@lib/addons/types";
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/core/vendetta/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as debug from "@lib/api/debug";
import { getVendettaLoaderIdentity, isPyonLoader } from "@lib/api/native/loader";
import patcher from "@lib/api/patcher";
import { loaderConfig, settings } from "@lib/api/settings";
import * as storage from "@lib/api/storage";
import { createStorage } from "@lib/api/storage";
import * as storage from "@core/vendetta/storage";
import { createStorage } from "@core/vendetta/storage";
import * as themes from "@lib/addons/themes";
import * as utils from "@lib/utils";
import { cyrb64Hash } from "@lib/utils/cyrb64";
Expand Down
2 changes: 1 addition & 1 deletion src/core/vendetta/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Author } from "@lib/addons/types";
import { settings } from "@lib/api/settings";
import { awaitStorage, createMMKVBackend, createStorage, purgeStorage, wrapSync } from "@lib/api/storage";
import { awaitStorage, createMMKVBackend, createStorage, purgeStorage, wrapSync } from "@core/vendetta/storage";
import { safeFetch } from "@lib/utils";
import { BUNNY_PROXY_PREFIX, VD_PROXY_PREFIX } from "@lib/utils/constants";
import { LoggerClass, logger } from "@lib/utils/logger";
Expand Down
Loading

0 comments on commit 122c3a1

Please sign in to comment.