sync: sync wip stuff
This commit is contained in:
33
src/app.ts
33
src/app.ts
@@ -1,3 +1,4 @@
|
||||
import { Alert } from './gui/Alert'
|
||||
import { CreateKeyboardListeners } from './input/keyboard'
|
||||
import { Wush } from './shell/Wush'
|
||||
import { Terminal } from './terminal/Terminal'
|
||||
@@ -5,6 +6,36 @@ import { EventBroadcaster } from './utils/EventBroadcaster'
|
||||
|
||||
export const WEBSHELL_VERSION = "0.1.0"
|
||||
|
||||
// initialize object store for webfs
|
||||
let WebfsDatabase: IDBDatabase | null = null
|
||||
|
||||
const request = indexedDB.open("webshell")
|
||||
|
||||
request.onupgradeneeded = event => {
|
||||
console.log("creating database")
|
||||
WebfsDatabase = (event.target as any).result as IDBDatabase
|
||||
WebfsDatabase.createObjectStore("webfs")
|
||||
}
|
||||
|
||||
request.onerror = _ => {
|
||||
new Alert(
|
||||
"webfs error",
|
||||
"Failed to initialize the webfs database using IndexedDB. Make sure webshell does not have any IndexedDB related permissions disabled and try again.",
|
||||
'critical',
|
||||
).Show(-1)
|
||||
}
|
||||
|
||||
request.onsuccess = event => {
|
||||
WebfsDatabase = (event.target as any).result as IDBDatabase
|
||||
console.log("database initialized")
|
||||
|
||||
// initialize the app after the database
|
||||
init()
|
||||
}
|
||||
|
||||
export const GetWebfsDatabase = (): IDBDatabase | null => WebfsDatabase
|
||||
|
||||
// terminal management
|
||||
let CurrentTerminal: Terminal
|
||||
export const SetCurrentTerminal = (terminal: Terminal) => CurrentTerminal = terminal
|
||||
export const GetCurrentTerminal = (): Terminal => CurrentTerminal
|
||||
@@ -22,5 +53,3 @@ const init = () => {
|
||||
const terminal = new Terminal()
|
||||
terminal.LoadShell(new Wush(localBroadcaster, terminal))
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
Reference in New Issue
Block a user