fix(lib/plugins): ignore re-registration for internal plugins

This commit is contained in:
PalmDevs 2026-08-02 00:05:18 +07:00
parent 2dd77f24b5
commit 57961ae5d7
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -345,6 +345,7 @@ export function registerInternalPlugin<O extends PluginApiExtensionsOptions>(
iflags = 0, iflags = 0,
) { ) {
manifest.version ??= InternalPluginVersion manifest.version ??= InternalPluginVersion
// TODO: This has to be shared from native somehow.
manifest.format ??= 1 manifest.format ??= 1
manifest.dependencies ??= {} manifest.dependencies ??= {}
manifest.dependencies[ApiDependencyId] ??= { version: '*' } manifest.dependencies[ApiDependencyId] ??= { version: '*' }
@ -359,8 +360,13 @@ function register<O extends PluginApiExtensionsOptions>(
defflags: number, defflags: number,
iflags: number, iflags: number,
) { ) {
if (pList.has(manifest.id)) if (pList.has(manifest.id)) {
throw new Error(`Plugin with ID "${manifest.id}" already registered`) // Ignore re-registration if internal
if (!iflags)
throw new Error(
`Plugin with ID "${manifest.id}" already registered`,
)
}
const factory = typeof options === 'function' ? options : undefined const factory = typeof options === 'function' ? options : undefined
const resolved = typeof options === 'function' ? undefined : options const resolved = typeof options === 'function' ? undefined : options