Add front-end Electron application for Khoj local file syncing (#473)

* Initial version - setup a file-push architecture for generating embeddings with Khoj
* Use state.host and state.port for configuring the URL for the indexer
* Fix parsing of PDF files
* Read markdown files from streamed data and update unit tests
* On application startup, load in embeddings from configurations files, rather than regenerating the corpus based on file system
* Init: refactor indexer/batch endpoint to support a generic file ingestion format
* Add features to better support indexing from files sent by the desktop client
* Initial commit with Electron application
- Adds electron app
* Add import for pymupdf, remove import for pypdf
* Allow user to configure khoj host URL
* Remove search type configuration from index.html
* Use v1 path for current indexer routes
This commit is contained in:
sabaimran
2023-09-06 12:04:18 -07:00
committed by GitHub
parent 205dc90746
commit 76562f4250
54 changed files with 20132 additions and 82 deletions

View File

@@ -0,0 +1,49 @@
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const dependency of ['chrome', 'node', 'electron']) {
replaceText(`${dependency}-version`, process.versions[dependency])
}
})
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
setTitle: (title) => ipcRenderer.send('set-title', title)
})
contextBridge.exposeInMainWorld('storeValueAPI', {
getStoreValue: (key) => ipcRenderer.invoke('getStoreValue', key)
})
contextBridge.exposeInMainWorld('getFilesAPI', {
getFiles: () => ipcRenderer.invoke('getFiles')
})
contextBridge.exposeInMainWorld('getFoldersAPI', {
getFolders: () => ipcRenderer.invoke('getFolders')
})
contextBridge.exposeInMainWorld('updateStateAPI', {
onUpdateState: (callback) => ipcRenderer.on('update-state', callback)
})
contextBridge.exposeInMainWorld('removeFileAPI', {
removeFile: (filePath) => ipcRenderer.invoke('removeFile', filePath)
})
contextBridge.exposeInMainWorld('removeFolderAPI', {
removeFolder: (folderPath) => ipcRenderer.invoke('removeFolder', folderPath)
})
contextBridge.exposeInMainWorld('hostURLAPI', {
setURL: (url) => ipcRenderer.invoke('setURL', url),
getURL: () => ipcRenderer.invoke('getURL')
})
contextBridge.exposeInMainWorld('syncDataAPI', {
syncData: () => ipcRenderer.invoke('syncData')
})