Louis 96dba2690d feat: class-based plugin manager
chore: add facades

refactor: core module export

refactor: inference plugin - deprecate function registering (#537)

* refactor: revamp inference plugin as class - deprecate function registering

* refactor: monitoring plugin - deprecate service registering (#538)

refactor: revamp inference plugin as class - deprecate function registering

chore: update import

refactor: plugin revamp - model management

chore: update build steps and remove experimental plugins

refactor: remove pluggable electron

chore: add sorting for conversations

chore: build plugins for testing

chore: consistent plugin directory name

chore: docs

chore: fix CI

chore: update conversation prefix
2023-11-06 13:46:01 +07:00

79 lines
2.0 KiB
TypeScript

'use client'
import { PropsWithChildren } from 'react'
import { ThemeWrapper } from '@helpers/ThemeWrapper'
import JotaiWrapper from '@helpers/JotaiWrapper'
import { ModalWrapper } from '@helpers/ModalWrapper'
import { useEffect, useState } from 'react'
import CompactLogo from '@containers/Logo/CompactLogo'
import EventListenerWrapper from '@helpers/EventListenerWrapper'
import { setupCoreServices } from '@services/coreService'
import {
isCorePluginInstalled,
setupBasePlugins,
} from '@services/pluginService'
import { FeatureToggleWrapper } from '@helpers/FeatureToggleWrapper'
import { pluginManager } from '../../plugin/PluginManager'
const Providers = (props: PropsWithChildren) => {
const [setupCore, setSetupCore] = useState(false)
const [activated, setActivated] = useState(false)
const { children } = props
async function setupPE() {
// Register all active plugins with their activation points
await pluginManager.registerActive()
setTimeout(async () => {
if (!isCorePluginInstalled()) {
setupBasePlugins()
return
}
pluginManager.load()
setActivated(true)
}, 500)
}
// Services Setup
useEffect(() => {
setupCoreServices()
setSetupCore(true)
}, [])
useEffect(() => {
if (setupCore) {
// Electron
if (window && window.coreAPI) {
setupPE()
} else {
// Host
setActivated(true)
}
}
}, [setupCore])
return (
<JotaiWrapper>
{setupCore && (
<ThemeWrapper>
{activated ? (
<FeatureToggleWrapper>
<EventListenerWrapper>
<ModalWrapper>{children}</ModalWrapper>
</EventListenerWrapper>
</FeatureToggleWrapper>
) : (
<div className="flex h-screen w-screen items-center justify-center bg-background">
<CompactLogo width={56} height={56} />
</div>
)}
</ThemeWrapper>
)}
</JotaiWrapper>
)
}
export default Providers