fix: declare unscoped storage API using decorators instead
This commit is contained in:
parent
7a365f93c7
commit
f5ed49d4e2
4 changed files with 8 additions and 4 deletions
|
|
@ -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>(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ export interface UnscopedPreInitPluginApi<
|
|||
patcher: typeof import('@revenge-mod/patcher')
|
||||
plugins: PluginApiPlugins
|
||||
react: PluginApiReact
|
||||
storage: typeof import('@revenge-mod/storage')
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue