8000 Remove residues from rebase · arduino/lab-micropython-editor@0792f2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 0792f2f

Browse files
committed
Remove residues from rebase
1 parent 041468f commit 0792f2f

File tree

1 file changed

+0
-101
lines changed

1 file changed

+0
-101
lines changed

preload.js

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,10 @@
11
console.log('preload')
22
const { contextBridge, ipcRenderer } = require('electron')
33
const path = require('path')
4-
const Serial = require('./backend/serial.js')
54
const shortcuts = require('./backend/shortcuts.js').global
6-
const MicroPython = require('micropython.js')
75
const { emit, platform } = require('process')
86
const SerialBridge = require('./backend/bridge/serial-bridge.js')
97

10-
const board = new MicroPython()
11-
board.chunk_size = 192
12-
board.chunk_sleep = 200
13-
14-
const Serial = {
15-
loadPorts: async () => {
16-
let ports = await board.list_ports()
17-
return ports.filter(p => p.vendorId && p.productId)
18-
},
19-
connect: async (path) => {
20-
return board.open(path)
21-
},
22-
disconnect: async () => {
23-
return board.close()
24-
},
25-
run: async (code) => {
26-
return board.run(code)
27-
},
28-
execFile: async (path) => {
29-
return board.execfile(path)
30-
},
31-
getPrompt: async () => {
32-
return board.get_prompt()
33-
},
34-
keyboardInterrupt: async () => {
35-
await board.stop()
36-
return Promise.resolve()
37-
},
38-
reset: async () => {
39-
await board.stop()
40-
await board.exit_raw_repl()
41-
await board.reset()
42-
return Promise.resolve()
43-
},
44-
eval: (d) => {
45-
return board.eval(d)
46-
},
47-
onData: (fn) => {
48-
board.serial.on('data', fn)
49-
},
50-
listFiles: async (folder) => {
51-
return board.fs_ls(folder)
52-
},
53-
ilistFiles: async (folder) => {
54-
return board.fs_ils(folder)
55-
},
56-
loadFile: async (file) => {
57-
const output = await board.fs_cat_binary(file)
58-
return output || ''
59-
},
60-
removeFile: async (file) => {
61-
return board.fs_rm(file)
62-
},
63-
saveFileContent: async (filename, content, dataConsumer) => {
64-
return board.fs_save(content || ' ', filename, dataConsumer)
65-
},
66-
uploadFile: async (src, dest, dataConsumer) => {
67-
return board.fs_put(src, dest.replaceAll(path.win32.sep, path.posix.sep), dataConsumer)
68-
},
69-
downloadFile: async (src, dest) => {
70-
let contents = await Serial.loadFile(src)
71-
return ipcRenderer.invoke('save-file', dest, contents)
72-
},
73-
renameFile: async (oldName, newName) => {
74-
return board.fs_rename(oldName, newName)
75-
},
76-
onDisconnect: async (fn) => {
77-
board.serial.on('close', fn)
78-
},
79-
createFolder: async (folder) => {
80-
return await board.fs_mkdir(folder)
81-
},
82-
removeFolder: async (folder) => {
83-
return await board.fs_rmdir(folder)
84-
},
85-
getNavigationPath: (navigation, target) => {
86-
return path.posix.join(navigation, target)
87-
},
88-
getFullPath: (root, navigation, file) => {
89-
return path.posix.join(root, navigation, file)
90-
},
91-
getParentPath: (navigation) => {
92-
return path.posix.dirname(navigation)
93-
},
94-
fileExists: async (filePath) => {
95-
// !!!: Fix this on micropython.js level
96-
// ???: Check if file exists is not part of mpremote specs
97-
const output = await board.run(`
98-
import os
99-
try:
100-
os.stat("${filePath}")
101-
print(0)
102-
except OSError:
103-
print(1)
104-
`)
105-
return output[2] === '0'
106-
}
107-
}
108-
1098
const Disk = {
1109
openFolder: async () => {
11110
return ipcRenderer.invoke('open-folder')

0 commit comments

Comments
 (0)
0