fix: declare unscoped storage API using decorators instead

This commit is contained in:
PalmDevs 2025-07-21 14:06:51 +07:00
parent 7a365f93c7
commit f5ed49d4e2
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
4 changed files with 8 additions and 4 deletions

View file

@ -1,5 +1,4 @@
import * as patcher from '@revenge-mod/patcher'
import * as storage from '@revenge-mod/storage'
import { modules } from './modules'
import { plugins } from './plugins'
import { react } from './react'
@ -18,7 +17,6 @@ export const pUnscopedApi:
patcher,
plugins,
react,
storage,
}
export function spreadDescriptors<T extends object, U extends object>(

View file

@ -19,7 +19,6 @@ export interface UnscopedPreInitPluginApi<
patcher: typeof import('@revenge-mod/patcher')
plugins: PluginApiPlugins
react: PluginApiReact
storage: typeof import('@revenge-mod/storage')
}
/**

View file

@ -2,6 +2,10 @@ import type { AnyObject } from '@revenge-mod/utils/types'
import type { Storage, StorageOptions } from '.'
declare module '@revenge-mod/plugins/types' {
export interface UnscopedPreInitPluginApi {
storage: typeof import('.')
}
export interface PluginApiExtensionsOptions {
storage?: AnyObject
}

View file

@ -3,6 +3,7 @@ import {
PluginFlags,
PluginsStorageDirectory,
} from '@revenge-mod/plugins/constants'
import * as storage from '@revenge-mod/storage'
import { getStorage } from '@revenge-mod/storage'
import { defineLazyProperty } from '@revenge-mod/utils/object'
import type { AnyPlugin } from '@revenge-mod/plugins/_'
@ -19,7 +20,9 @@ registerPlugin(
icon: 'PollsIcon',
},
{
preInit({ decorate }) {
preInit({ decorate, unscoped }) {
unscoped.storage = storage
decorate((plugin, { storage }) => {
if (storage) storageOptions.set(plugin, storage)
})