chore: refactor core folder structure - module based

This commit is contained in:
Louis 2024-03-25 13:24:49 +07:00
parent 77cbdc2dcf
commit 14a67463dc
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
28 changed files with 51 additions and 56 deletions

View File

@ -1,4 +1,4 @@
import { DownloadRequest, FileStat, NetworkConfig, SystemInformation } from './types'
import { DownloadRequest, FileStat, NetworkConfig, SystemInformation } from '../types'
/**
* Execute a extension module function in main process

View File

@ -1,4 +1,4 @@
import { Assistant, AssistantInterface } from '../index'
import { Assistant, AssistantInterface } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'
/**

View File

@ -1,4 +1,4 @@
import { Thread, ThreadInterface, ThreadMessage, MessageInterface } from '../index'
import { Thread, ThreadInterface, ThreadMessage, MessageInterface } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'
/**

View File

@ -2,7 +2,7 @@ import { getJanDataFolderPath, joinPath } from '../../core'
import { events } from '../../events'
import { BaseExtension } from '../../extension'
import { fs } from '../../fs'
import { MessageRequest, Model, ModelEvent } from '../../types'
import { MessageRequest, Model, ModelEvent } from '../../../types'
import { EngineManager } from './EngineManager'
/**

View File

@ -1,4 +1,3 @@
import { log } from '../../core'
import { AIEngine } from './AIEngine'
/**
@ -28,7 +27,3 @@ export class EngineManager {
return window.core?.engineManager as EngineManager
}
}
/**
* The singleton instance of the ExtensionManager.
*/

View File

@ -1,6 +1,6 @@
import { executeOnMain, getJanDataFolderPath, joinPath, systemInformation } from '../../core'
import { events } from '../../events'
import { Model, ModelEvent } from '../../types'
import { Model, ModelEvent } from '../../../types'
import { OAIEngine } from './OAIEngine'
/**

View File

@ -13,7 +13,7 @@ import {
ModelInfo,
ThreadContent,
ThreadMessage,
} from '../../types'
} from '../../../types'
import { events } from '../../events'
/**

View File

@ -1,5 +1,5 @@
import { Observable } from 'rxjs'
import { ModelRuntimeParams } from '../../../types'
import { ModelRuntimeParams } from '../../../../types'
/**
* Sends a request to the inference server to generate a response based on the recent messages.
* @param recentMessages - An array of recent messages to use as context for the inference.

View File

@ -1,6 +1,6 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { HuggingFaceInterface, HuggingFaceRepoData, Quantization } from '../types/huggingface'
import { Model } from '../types/model'
import { HuggingFaceInterface, HuggingFaceRepoData, Quantization } from '../../types/huggingface'
import { Model } from '../../types/model'
/**
* Hugging Face extension for converting HF models to GGUF.

View File

@ -1,4 +1,4 @@
import { InferenceInterface, MessageRequest, ThreadMessage } from '../index'
import { InferenceInterface, MessageRequest, ThreadMessage } from '../../types'
import { BaseExtension, ExtensionTypeEnum } from '../extension'
/**

View File

@ -1,5 +1,5 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { GpuSetting, ImportingModel, Model, ModelInterface, OptionType } from '../index'
import { GpuSetting, ImportingModel, Model, ModelInterface, OptionType } from '../../types'
/**
* Model extension for managing models.

View File

@ -1,5 +1,5 @@
import { BaseExtension, ExtensionTypeEnum } from '../extension'
import { GpuSetting, MonitoringInterface, OperatingSystemInfo } from '../index'
import { GpuSetting, MonitoringInterface, OperatingSystemInfo } from '../../types'
/**
* Monitoring extension for system monitoring.

View File

@ -1,4 +1,4 @@
import { FileStat } from './types'
import { FileStat } from '../types'
/**
* Writes data to a file at the specified path.

29
core/src/browser/index.ts Normal file
View File

@ -0,0 +1,29 @@
/**
* Export Core module
* @module
*/
export * from './core'
/**
* Export Event module.
* @module
*/
export * from './events'
/**
* Export Filesystem module.
* @module
*/
export * from './fs'
/**
* Export Extension module.
* @module
*/
export * from './extension'
/**
* Export all base extensions.
* @module
*/
export * from './extensions'

View File

@ -2,42 +2,13 @@
* Export all types.
* @module
*/
export * from './types/index'
export * from './types'
/**
* Export all routes
*/
export * from './api'
/**
* Export Core module
* Export browser module
* @module
*/
export * from './core'
/**
* Export Event module.
* @module
*/
export * from './events'
/**
* Export Filesystem module.
* @module
*/
export * from './fs'
/**
* Export Extension module.
* @module
*/
export * from './extension'
/**
* Export all base extensions.
* @module
*/
export * from './extensions/index'
export * from './browser'
/**
* Declare global object

View File

@ -4,7 +4,7 @@ import {
ExtensionRoute,
FileManagerRoute,
FileSystemRoute,
} from '../../../api'
} from '../../../types/api'
import { Downloader } from '../processors/download'
import { FileSystem } from '../processors/fs'
import { Extension } from '../processors/extension'

View File

@ -1,4 +1,4 @@
import { CoreRoutes } from '../../../api'
import { CoreRoutes } from '../../../types/api'
import { RequestAdapter } from './adapter'
export type Handler = (route: string, args: any) => any

View File

@ -1,5 +1,5 @@
import { resolve, sep } from 'path'
import { DownloadEvent } from '../../../api'
import { DownloadEvent } from '../../../types/api'
import { normalizeFilePath } from '../../helper/path'
import { getJanDataFolderPath } from '../../helper'
import { DownloadManager } from '../../helper/download'

View File

@ -1,4 +1,4 @@
import { DownloadRoute } from '../../../../api'
import { DownloadRoute } from '../../../../types/api'
import { DownloadManager } from '../../../helper/download'
import { HttpServer } from '../../HttpServer'

View File

@ -5,4 +5,4 @@ export * from './extension/store'
export * from './api'
export * from './helper'
export * from './../types'
export * from './../api'
export * from '../types/api'

View File

@ -8,3 +8,4 @@ export * from './file'
export * from './config'
export * from './huggingface'
export * from './miscellaneous'
export * from './api'

View File

@ -7,7 +7,6 @@ import { toaster } from '@/containers/Toast'
import { LAST_USED_MODEL_ID } from './useRecommendedModel'
import { extensionManager } from '@/extension'
import { downloadedModelsAtom } from '@/helpers/atoms/Model.atom'
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'