-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkernel.js
More file actions
95 lines (80 loc) · 2.22 KB
/
Copy pathkernel.js
File metadata and controls
95 lines (80 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//vars
let userName = "user";
let inputHistory = [];
let inputHistoryCursor = inputHistory.length;
let wd;
let appManager;
let functionLoader;
//boot
async function boot() {
await initFilesystem(); // load the filesystem
await initInputManager(); //load the input manager
await initAppManager(); //load the app manager
await initDialog(); //load the dialog
setup();
await functionLoaderInit();
// create a new Session
await initTerminal();
}
/**
* Loads the filesystem
* @returns {Promise<void>}
*/
async function initFilesystem() {
const {FileSystem, WorkingDirectory} = await import('./filesystem/FileSystem.js');
new FileSystem();
wd = new WorkingDirectory();
}
/**
* Loads the InputManager
* @returns {Promise<void>}
*/
async function initInputManager() {
const {InputManager} = await import('./inputManager.js');
new InputManager();
}
/**
* Loads the AppManager and install the apps
* @returns {Promise<void>}
*/
async function initAppManager() {
const {AppManager} = await import('./appManager.js');
appManager = new AppManager();
await appManager.load();
}
async function initDialog() {
const {Dialog} = await import('./utils/dialog.js');
Dialog.globalInstance = new Dialog();
}
/**
* Loads the terminal
* @returns {Promise<void>}
*/
async function initTerminal() {
const {Terminal} = await import('./terminal.js');
const terminal = new Terminal();
terminal.div = document.getElementById("lines");
terminal.wd = wd;
terminal.init();
}
function setup() {
if (localStorage.getItem("userName")) userName = localStorage.getItem("userName");
if (localStorage.getItem("inputHistory")) inputHistory = localStorage.getItem("inputHistory").split(",");
inputHistoryCursor = inputHistory.length;
}
/**
* loads the functionLoader.js file and sets the functions
* @returns {Promise}
*/
function functionLoaderInit() {
return new Promise(async (resolve, reject) => {
import('./functionLoader.js').then((module) => {
functionLoader = module.default;
// custom functions
functionLoader.wd = wd;
resolve();
}).catch((error) => {
reject(error);
});
});
}