* add platform guards * add service management * fix types * move to zustand for servicehub * update App Updater * update tauri missing move * update app updater * refactor: move PlatformFeatures to separate const file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * change tauri fetch name * update implementation * update extension fetch * make web version run properly * disabled unused web settings * fix all tests * fix lint * fix tests * add mock for extension * fix build * update make and mise * fix tsconfig for web-extensions * fix loader type * cleanup * fix test * update error handling + mcp should be working * Update mcp init * use separate is_web_app build property * Remove fixed model catalog url * fix additional tests * fix download issue (event emitter not implemented correctly) * Update Title html * fix app logs * update root tsx render timing --------- Co-authored-by: Claude <noreply@anthropic.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { ExtensionManager } from '@/lib/extension'
|
|
import { APIs } from '@/lib/service'
|
|
import { EventEmitter } from '@/services/events/EventEmitter'
|
|
import { EngineManager, ModelManager } from '@janhq/core'
|
|
import { PropsWithChildren, useCallback, useEffect, useState } from 'react'
|
|
|
|
export function ExtensionProvider({ children }: PropsWithChildren) {
|
|
const [finishedSetup, setFinishedSetup] = useState(false)
|
|
const setupExtensions = useCallback(async () => {
|
|
// Setup core window object for both platforms
|
|
window.core = {
|
|
api: APIs,
|
|
}
|
|
|
|
window.core.events = new EventEmitter()
|
|
window.core.extensionManager = new ExtensionManager()
|
|
window.core.engineManager = new EngineManager()
|
|
window.core.modelManager = new ModelManager()
|
|
|
|
// Register extensions - same pattern for both platforms
|
|
await ExtensionManager.getInstance()
|
|
.registerActive()
|
|
.then(() => ExtensionManager.getInstance().load())
|
|
.then(() => setFinishedSetup(true))
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
setupExtensions()
|
|
|
|
return () => {
|
|
ExtensionManager.getInstance().unload()
|
|
}
|
|
}, [setupExtensions])
|
|
|
|
return <>{finishedSetup && children}</>
|
|
}
|