* feat: adding create bot functionality Signed-off-by: James <james@jan.ai> * update the temperature progress bar Signed-off-by: James <james@jan.ai> * WIP baselayout * Mapping plugins with available preferences * Added loader component * WIP working another screen * Cleanup types and avoid import one by one * Prepare bottom bar * Add css variables colors to enable user select the accent * Enable change accent color * Seperate css variable * Fix conflict * Add blank state of my model empty * Restyle explore models page * Enable user config left sidebar * Restyle my models page * WIP styling chat page * Restyling chat message * Fix conflict * Adde form preferences setting plugins * Fixed form bot info * Sidebar bot chat * Showing rightbar for both setting when user created bot * Fix style bot info * Using overflow auto intead of scroll * Remove script built UI from root package * Fix missig import * Resolve error linter * fix e2e tests Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
'use client'
|
|
|
|
import { PropsWithChildren } from 'react'
|
|
import { PluginService } from '@janhq/core'
|
|
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 {
|
|
setup,
|
|
plugins,
|
|
activationPoints,
|
|
extensionPoints,
|
|
} from '../../../electron/core/plugin-manager/execution/index'
|
|
import {
|
|
isCorePluginInstalled,
|
|
setupBasePlugins,
|
|
} from '@services/pluginService'
|
|
import EventListenerWrapper from '@helpers/EventListenerWrapper'
|
|
import { setupCoreServices } from '@services/coreService'
|
|
import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager'
|
|
|
|
const Providers = (props: PropsWithChildren) => {
|
|
const [setupCore, setSetupCore] = useState(false)
|
|
const [activated, setActivated] = useState(false)
|
|
|
|
const { children } = props
|
|
|
|
async function setupPE() {
|
|
// Enable activation point management
|
|
setup({
|
|
importer: (plugin: string) =>
|
|
import(/* webpackIgnore: true */ plugin).catch((err) => {
|
|
console.log(err)
|
|
}),
|
|
})
|
|
|
|
// Register all active plugins with their activation points
|
|
await plugins.registerActive()
|
|
setTimeout(async () => {
|
|
// Trigger activation points
|
|
await activationPoints.trigger('init')
|
|
if (!isCorePluginInstalled()) {
|
|
setupBasePlugins()
|
|
return
|
|
}
|
|
if (extensionPoints.get(PluginService.OnStart)) {
|
|
await executeSerial(PluginService.OnStart)
|
|
}
|
|
setActivated(true)
|
|
}, 500)
|
|
}
|
|
|
|
// Services Setup
|
|
useEffect(() => {
|
|
setupCoreServices()
|
|
setSetupCore(true)
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (setupCore) {
|
|
// Electron
|
|
if (window && window.electronAPI) {
|
|
setupPE()
|
|
} else {
|
|
// Host
|
|
setActivated(true)
|
|
}
|
|
}
|
|
}, [setupCore])
|
|
|
|
return (
|
|
<JotaiWrapper>
|
|
{setupCore && (
|
|
<EventListenerWrapper>
|
|
<ThemeWrapper>
|
|
{activated ? (
|
|
<ModalWrapper>{children}</ModalWrapper>
|
|
) : (
|
|
<div className="bg-background flex h-screen w-screen items-center justify-center">
|
|
<CompactLogo width={56} height={56} />
|
|
</div>
|
|
)}
|
|
</ThemeWrapper>
|
|
</EventListenerWrapper>
|
|
)}
|
|
</JotaiWrapper>
|
|
)
|
|
}
|
|
|
|
export default Providers
|