Repository navigation
Expand file tree
/
Copy pathapp.ts
More file actions
72 lines (58 loc) · 1.49 KB
/
Copy pathapp.ts
File metadata and controls
72 lines (58 loc) · 1.49 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
// import { newServer } from './server';
import { App, TerminalInterface } from './types';
import { getIo } from './io';
import { newSamples } from './samples';
import { getHexFile } from './lib/hexlify';
async function newApp(): Promise<App> {
// const client = await newServer();
const io = getIo();
const samples = newSamples();
function runCode(code: string) {
// return client.runCode(code);
}
function openFile() {
return io.openFile();
}
function saveFile(data: string | Uint8Array, ext: string, type: string) {
return io.saveFile(data, ext, type);
}
function saveHex(python: string) {
const hex = getHexFile(python);
return io.saveFile(hex, 'hex', 'application/octet-stream');
}
function assignTerminal(terminal: TerminalInterface) {
// client.on('data', (data) => terminal.write(data));
// client.on('reconnect', () => {
// terminal.reset();
// client.resizeTerminal(terminal.cols, terminal.rows);
// });
// terminal.on('data', client.sendData);
// terminal.on('resize', client.resizeTerminal);
// if (terminal.cols && terminal.rows) {
// client.resizeTerminal(terminal.cols, terminal.rows);
// }
}
function getThemes() {
return [
'Default',
'Tangerine',
'Vivid',
'DarkRed',
'Celestial',
'Pacific',
'Dark',
];
}
return {
runCode,
openFile,
saveFile,
saveHex,
assignTerminal,
getThemes,
...samples,
};
}
export {
newApp,
};