fix(lib/plugins): move unscoped.externals to its own pkg
This commit is contained in:
parent
627e5c4634
commit
2c56aa87c1
6 changed files with 24 additions and 12 deletions
6
lib/externals/package.json
vendored
6
lib/externals/package.json
vendored
|
|
@ -6,6 +6,9 @@
|
|||
"./browserify": {
|
||||
"default": "./src/browserify.ts"
|
||||
},
|
||||
"./init": {
|
||||
"default": "./src/init.ts"
|
||||
},
|
||||
"./react-native-clipboard": {
|
||||
"default": "./src/react-native-clipboard.ts"
|
||||
},
|
||||
|
|
@ -14,6 +17,9 @@
|
|||
},
|
||||
"./shopify": {
|
||||
"default": "./src/shopify.ts"
|
||||
},
|
||||
"./types": {
|
||||
"default": "./src/types.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
/** biome-ignore-all lint/complexity/useArrowFunction: Rolldown issue: Bug requires us to use normal functions instead of arrow functions */
|
||||
|
||||
import { _uapi } from '@revenge-mod/plugins/_'
|
||||
import { defineLazyProperty } from '@revenge-mod/utils/objects'
|
||||
import type { UnscopedInitPluginApi } from '@revenge-mod/plugins/types'
|
||||
import type { PluginApiExternals } from './types'
|
||||
|
||||
export interface PluginApiExternals {
|
||||
Browserify: typeof import('@revenge-mod/externals/browserify')
|
||||
ReactNativeClipboard: typeof import('@revenge-mod/externals/react-native-clipboard')
|
||||
ReactNavigation: typeof import('@revenge-mod/externals/react-navigation')
|
||||
Shopify: typeof import('@revenge-mod/externals/shopify')
|
||||
}
|
||||
|
||||
export const externals = {} as PluginApiExternals
|
||||
const uapi = _uapi as UnscopedInitPluginApi
|
||||
const externals = (uapi.externals = {} as PluginApiExternals)
|
||||
|
||||
defineLazyProperty(externals, 'Browserify', function () {
|
||||
return require('@revenge-mod/externals/browserify')
|
||||
12
lib/externals/src/types.ts
vendored
Normal file
12
lib/externals/src/types.ts
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export interface PluginApiExternals {
|
||||
Browserify: typeof import('@revenge-mod/externals/browserify')
|
||||
ReactNativeClipboard: typeof import('@revenge-mod/externals/react-native-clipboard')
|
||||
ReactNavigation: typeof import('@revenge-mod/externals/react-navigation')
|
||||
Shopify: typeof import('@revenge-mod/externals/shopify')
|
||||
}
|
||||
|
||||
declare module '@revenge-mod/plugins/types' {
|
||||
export interface UnscopedInitPluginApi {
|
||||
externals: PluginApiExternals
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ import * as AssetsLibrary from '@revenge-mod/assets'
|
|||
import { onRunApplication } from '@revenge-mod/react/native'
|
||||
import { _plugins, initPlugin, startPlugin } from './_internal'
|
||||
import { _uapi } from './apis'
|
||||
import { externals } from './apis/externals'
|
||||
import { react } from './apis/react'
|
||||
import { PluginFlags } from './constants'
|
||||
import type { UnscopedInitPluginApi } from './types'
|
||||
|
|
@ -10,7 +9,6 @@ import type { UnscopedInitPluginApi } from './types'
|
|||
// Setup init plugin APIs
|
||||
const uapi = _uapi as UnscopedInitPluginApi
|
||||
uapi.assets = AssetsLibrary
|
||||
uapi.externals = externals
|
||||
uapi.react = react
|
||||
|
||||
for (const plugin of _plugins.values())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { Storage, StorageOptions } from '@revenge-mod/storage'
|
||||
import type { AnyObject } from '@revenge-mod/utils/types'
|
||||
import type { PluginApiExternals } from './apis/externals'
|
||||
import type { PluginApiModules } from './apis/modules'
|
||||
import type { PluginApiPlugins } from './apis/plugins'
|
||||
import type { PluginApiReact } from './apis/react'
|
||||
|
|
@ -23,7 +22,6 @@ export interface UnscopedPreInitPluginApi {
|
|||
*/
|
||||
export interface UnscopedInitPluginApi extends UnscopedPreInitPluginApi {
|
||||
assets: typeof import('@revenge-mod/assets')
|
||||
externals: PluginApiExternals
|
||||
react: PluginApiReact
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
|
|||
onModuleInitialized(IndexModuleId, function onIndexInitialized() {
|
||||
runCatching(() => {
|
||||
// Initialize init libraries
|
||||
require('@revenge-mod/externals/init')
|
||||
require('@revenge-mod/discord/init')
|
||||
|
||||
// Run all init plugins
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue