chore(lib/storage): move Storage#use initialization back to library

This commit is contained in:
PalmDevs 2025-08-12 16:50:09 +07:00
parent 333ba5622e
commit d386035342
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
5 changed files with 6 additions and 5 deletions

View file

@ -6,6 +6,9 @@
".": {
"default": "./src/index.ts"
},
"./init": {
"default": "./src/init.ts"
},
"./types": {
"types": "./src/types.ts"
}

View file

@ -76,7 +76,7 @@ export function Storage<T extends AnyObject>(
}
// React is only initialized right before the init stage, so this is a dummy method
// See define-storage-use.ts in api.storage plugin for the actual implementation
// See init.ts in api.storage plugin for the actual implementation
Storage.prototype.use = () => {
throw new Error('Storage#use can only be called after the init stage!')
}

View file

@ -4,8 +4,7 @@ import { useEffect } from 'react'
import type { StorageSubscription } from '@revenge-mod/storage'
// Actual implementation of Storage#use
const SP: Storage<any> = Storage.prototype
SP.use = function (filter) {
;(Storage.prototype as Storage<any>).use = function (filter) {
if (!this.cache) this.get()
const reRender = useReRender()

View file

@ -1,5 +1,6 @@
// Initialize init libraries
import '@revenge-mod/react/init'
import '@revenge-mod/storage/init'
import { onRunApplication } from '@revenge-mod/react/native'
import { onError } from './preinit'

View file

@ -28,8 +28,6 @@ registerPlugin(
})
},
init({ decorate }) {
require('./define-storage-use')
decorate(plugin => {
defineLazyProperty(plugin.api, 'storage', () =>
getStorage(