jan/web/services/coreService.ts
2025-03-31 20:13:31 +07:00

27 lines
701 B
TypeScript

import { EngineManager, ToolManager } from '@janhq/core'
import { appService } from './appService'
import { EventEmitter } from './eventsService'
import { restAPI } from './restService'
import { tauriAPI } from './tauriService'
export const setupCoreServices = () => {
if (typeof window === 'undefined') {
console.debug('undefine', window)
return
} else {
console.debug('Setting up core services')
}
if (!window.core) {
window.core = {
events: new EventEmitter(),
engineManager: new EngineManager(),
toolManager: new ToolManager(),
api: {
...(window.electronAPI ?? (IS_TAURI ? tauriAPI : restAPI)),
...appService,
},
}
}
}