Skip to content

Commit 9160342

Browse files
authored
Merge pull request #112 from arduino/development
v0.9.0
2 parents 8b57764 + 4ef45c9 commit 9160342

File tree

535 files changed

+37999
-10265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+37999
-10265
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Arduino MicroPython Lab
1+
name: Arduino Lab for MicroPython
22

33
on:
44
push:
@@ -96,15 +96,15 @@ jobs:
9696
matrix:
9797
artifact:
9898
- path: "*-linux_x64.zip"
99-
name: Linux_X86-64
99+
name: Arduino-Lab-for-MicroPython_Linux_X86-64
100100
- path: "*-mac_x64.zip"
101-
name: macOS
101+
name: Arduino-Lab-for-MicroPython_macOS_X86-64
102102
# - path: "*Windows_64bit.exe"
103103
# name: Windows_X86-64_interactive_installer
104104
# - path: "*Windows_64bit.msi"
105105
# name: Windows_X86-64_MSI
106106
- path: "*-win_x64.zip"
107-
name: Windows_X86-64_zip
107+
name: Arduino-Lab-for-MicroPython_Windows_X86-64
108108

109109
steps:
110110
- name: Download job transfer artifact

README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
# Arduino Lab for MicroPython
22

3-
Arduino Lab for MicroPython is a lightweight editor for MicroPython programs, supporting connection with a board, code upload, file transfer, interactive REPL shell.
4-
This project is sponsored by Arduino, based on original work by Murilo Polese. This is an experimental pre-release software, please direct any questions only to Github issues.
3+
<p align="center">
4+
5+
<img src="https://github.com/arduino/lab-micropython-editor/blob/development/ui/arduino/documents/Screenshot%20from%202024-04-15%2009-48-25.png?raw=true" width="50%" />
6+
7+
</p>
8+
9+
Arduino Lab for MicroPython is a lightweight editor for MicroPython programs, supporting connection with a board, code upload, file transfer and interactive REPL shell.
10+
This project is sponsored by Arduino, based on original work by [Murilo Polese](http://www.murilopolese.com). This is an experimental pre-release software, please direct any questions only to Github issues.
511

612
## Features
713
- MicroPython's Read Eval Print Loop (REPL)
814
- Enter paste mode
915
- Enter raw repl
1016
- Software reset
17+
- Tab to autocomplete
1118
- File system management (Disk and MicroPython File System)
1219
- Create
1320
- Rename
21+
- Multiple file and folder selection
1422
- Remove
1523
- Upload
1624
- Download
17-
- Text editor with Python syntax highlight
18-
- Code execution controls
25+
- Text editor
26+
- Python syntax highlight and autocomplete
27+
- Multiple tabs
28+
- Rename tabs
29+
- Code execution
1930
- Run what's on text editor
2031
- Stop (keyboard interrupt)
2132
- Soft reset
2233

23-
## Technical
34+
## Technical overview
2435

2536
Arduino Lab for MicroPython is an [Electron](https://www.electronjs.org/) app that has its main purpose to communicate over serial with a microprocessor running [MicroPython](https://micropython.org/). All Electron code is at `/index.js`.
2637

@@ -36,33 +47,21 @@ At the root of the repository you will find:
3647

3748
- `/.github`: Github's workflow configuration.
3849
- `/build_resources`: Icons and other assets used during the build process.
39-
- `/scripts`: Scripts executed during the build process.
4050
- `/ui`: Available user interfaces.
4151
- `/index.js`: Main Electron code.
42-
- `/preload.js`: Creates Disk and Serial APIs on Electron's main process and exposes it to Electron's renderer process (context bridge).
43-
44-
## Arduino UI
52+
- `/preload.js`: Creates Disk, Serial and Window APIs on Electron's main process and exposes it to Electron's renderer process (context bridge).
4553

46-
Default UI is a [choo-choo](https://github.com/choojs/choo) app. It has pre-built dependencies so no build process is required for the interface.
54+
## User interface
4755

48-
The dependencies and source code are included manually in the `/ui/arduino/index.html` file.
49-
50-
The app is a standard [choo-choo](https://github.com/choojs/choo) app and it has:
51-
52-
- `/ui/arduino/app.js`: A router deciding which view to load.
53-
- `/ui/arduino/components`: HTML templates and components.
54-
- `/ui/arduino/store.js`: A "store" that handles events emitted by the views, change the app state and orchestrate re-rendering.
55-
- `/ui/arduino/libs`: Prebuilt dependencies.
56-
57-
It can be useful to learn more about [Choo](https://github.com/choojs/choo) or the [Elm Architecture](https://guide.elm-lang.org/architecture/).
56+
Read more at [`/ui/arduino/README.md`](./ui/arduino/README.md)
5857

5958
## Disk and Serial API
6059

6160
In order for the UI code to be independent of Electron code, there is an API defined at `/preload.js` that describes all the allowed operations.
6261

63-
There are 2 main operation "channels": Serial communication and local Filesystem operations. Both channels offer methods that always return promises and are used mostly through [`async`/`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
62+
There are 3 main operation "channels": Serial communication, local filesystem and window operations. These channels offer methods that should always return promises and are used mostly through [`async`/`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
6463

65-
While the serial communication is mediated by `/micropython.js`, the local filesystem operations are done through Electron's `ipcRenderer` calls. The handlers for these calls are defined at `/index.js`
64+
While the serial communication is mediated by `/micropython.js`, the local filesystem and window operations are done through Electron's `ipcRenderer` calls. The handlers for these calls are defined at `/index.js`
6665

6766
## Running Arduino Lab for MicroPython from source code
6867

@@ -73,7 +72,6 @@ While the serial communication is mediated by `/micropython.js`, the local files
7372

7473
Some changes on the Electron code will require reopening the app but all UI changes will only require refreshing the window (ctrl-r/cmd-r).
7574

76-
7775
## Trademarks
7876

7977
"Python" and the Python Logo are trademarks of the Python Software Foundation.

index.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ function ilistFolder(folder) {
4040
return files
4141
}
4242

43+
function getAllFiles(dirPath, arrayOfFiles) {
44+
// https://coderrocketfuel.com/article/recursively-list-all-the-files-in-a-directory-using-node-js
45+
files = ilistFolder(dirPath)
46+
arrayOfFiles = arrayOfFiles || []
47+
files.forEach(function(file) {
48+
const p = path.join(dirPath, file.path)
49+
const stat = fs.statSync(p)
50+
arrayOfFiles.push({
51+
path: p,
52+
type: stat.isDirectory() ? 'folder' : 'file'
53+
})
54+
if (stat.isDirectory()) {
55+
arrayOfFiles = getAllFiles(p, arrayOfFiles)
56+
}
57+
})
58+
return arrayOfFiles
59+
}
60+
4361
// LOCAL FILE SYSTEM ACCESS
4462
ipcMain.handle('open-folder', async (event) => {
4563
console.log('ipcMain', 'open-folder')
@@ -63,6 +81,12 @@ ipcMain.handle('ilist-files', async (event, folder) => {
6381
return ilistFolder(folder)
6482
})
6583

84+
ipcMain.handle('ilist-all-files', (event, folder) => {
85+
console.log('ipcMain', 'ilist-all-files', folder)
86+
if (!folder) return []
87+
return getAllFiles(folder)
88+
})
89+
6690
ipcMain.handle('load-file', (event, filePath) => {
6791
console.log('ipcMain', 'load-file', filePath)
6892
let content = fs.readFileSync(filePath)
@@ -98,6 +122,32 @@ ipcMain.handle('rename-file', (event, filePath, newFilePath) => {
98122
return true
99123
})
100124

125+
ipcMain.handle('create-folder', (event, folderPath) => {
126+
console.log('ipcMain', 'create-folder', folderPath)
127+
try {
128+
fs.mkdirSync(folderPath, { recursive: true })
129+
} catch(e) {
130+
console.log('error', e)
131+
return false
132+
}
133+
return true
134+
})
135+
136+
ipcMain.handle('remove-folder', (event, folderPath) => {
137+
console.log('ipcMain', 'remove-folder', folderPath)
138+
fs.rmdirSync(folderPath, { recursive: true, force: true })
139+
return true
140+
})
141+
142+
ipcMain.handle('file-exists', (event, filePath) => {
143+
console.log('ipcMain', 'file-exists', filePath)
144+
try {
145+
fs.accessSync(filePath, fs.constants.F_OK)
146+
return true
147+
} catch(err) {
148+
return false
149+
}
150+
})
101151
// WINDOW MANAGEMENT
102152

103153
ipcMain.handle('set-window-size', (event, minWidth, minHeight) => {
@@ -125,6 +175,7 @@ function createWindow () {
125175
})
126176
// and load the index.html of the app.
127177
win.loadFile('ui/arduino/index.html')
178+
// win.loadFile('ui/sandbox/index.html')
128179
}
129180

130181
// TODO: Loading splash screen

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy