diff --git a/core/src/core.ts b/core/src/core.ts index 2478434d3..4f221f172 100644 --- a/core/src/core.ts +++ b/core/src/core.ts @@ -41,9 +41,8 @@ const downloadFile: (url: string, fileName: string) => Promise = ( window.electronAPI?.downloadFile(url, fileName); /** - * Deletes a file from the local file system. - * @param {string} path - The path of the file to delete. - * @returns {Promise} A promise that resolves when the file is deleted. + * @deprecated This object is deprecated and should not be used. + * Use fs module instead. */ const deleteFile: (path: string) => Promise = (path) => window.coreAPI?.deleteFile(path) ?? window.electronAPI?.deleteFile(path); @@ -55,6 +54,13 @@ const deleteFile: (path: string) => Promise = (path) => */ const appDataPath: () => Promise = () => window.coreAPI?.appDataPath(); +/** + * Gets the user space path. + * @returns {Promise} A Promise that resolves with the user space path. + */ +const getUserSpace = (): Promise => + window.coreAPI?.getUserSpace() ?? window.electronAPI?.getUserSpace(); + /** Register extension point function type definition * */ @@ -75,6 +81,7 @@ export const core = { downloadFile, deleteFile, appDataPath, + getUserSpace, }; /** @@ -86,4 +93,5 @@ export { downloadFile, deleteFile, appDataPath, + getUserSpace, }; diff --git a/core/src/fs.ts b/core/src/fs.ts index 73ac31636..2c94a2ce8 100644 --- a/core/src/fs.ts +++ b/core/src/fs.ts @@ -8,13 +8,6 @@ const writeFile: (path: string, data: string) => Promise = (path, data) => window.coreAPI?.writeFile(path, data) ?? window.electronAPI?.writeFile(path, data); -/** - * Gets the user space path. - * @returns {Promise} A Promise that resolves with the user space path. - */ -const getUserSpace = (): Promise => - window.coreAPI?.getUserSpace() ?? window.electronAPI?.getUserSpace(); - /** * Checks whether the path is a directory. * @param path - The path to check. @@ -64,7 +57,6 @@ const deleteFile: (path: string) => Promise = (path) => export const fs = { isDirectory, - getUserSpace, writeFile, readFile, listFiles, diff --git a/core/src/index.ts b/core/src/index.ts index 76827f6b3..9e3954c4b 100644 --- a/core/src/index.ts +++ b/core/src/index.ts @@ -8,7 +8,7 @@ export { core, deleteFile, invokePluginFunc } from "./core"; * Core module exports. * @module */ -export { downloadFile, executeOnMain, appDataPath } from "./core"; +export { downloadFile, executeOnMain, appDataPath, getUserSpace } from "./core"; /** * Events module exports. diff --git a/plugins/inference-plugin/src/index.ts b/plugins/inference-plugin/src/index.ts index 4f358dc56..167ce0626 100644 --- a/plugins/inference-plugin/src/index.ts +++ b/plugins/inference-plugin/src/index.ts @@ -20,7 +20,7 @@ import { InferencePlugin } from "@janhq/core/lib/plugins"; import { requestInference } from "./helpers/sse"; import { ulid } from "ulid"; import { join } from "path"; -import { fs } from "@janhq/core"; +import { getUserSpace } from "@janhq/core"; /** * A class that implements the InferencePlugin interface from the @janhq/core package. @@ -60,7 +60,7 @@ export default class JanInferencePlugin implements InferencePlugin { * @returns {Promise} A promise that resolves when the model is initialized. */ async initModel(modelFileName: string): Promise { - const userSpacePath = await fs.getUserSpace(); + const userSpacePath = await getUserSpace(); const modelFullPath = join(userSpacePath, modelFileName); return executeOnMain(MODULE, "initModel", modelFullPath);