From 56cb42d69f511759bf95ee798046f64be1f67b13 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 18 Dec 2024 20:28:29 +0100 Subject: [PATCH 1/2] Fix event handlers for file save and upload --- backend/serial/serial-bridge.js | 17 +++++++++++++++-- backend/serial/serial.js | 13 +++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/backend/serial/serial-bridge.js b/backend/serial/serial-bridge.js index 715d21a..90d4d2e 100644 --- a/backend/serial/serial-bridge.js +++ b/backend/serial/serial-bridge.js @@ -53,10 +53,23 @@ const SerialBridge = { return await ipcRenderer.invoke('serial', 'removeFile', file) }, saveFileContent: async (filename, content, dataConsumer) => { - return await ipcRenderer.invoke('serial', 'saveFileContent', filename, content, dataConsumer) + if (ipcRenderer.listeners("serial-on-file-save-progress").length > 0) { + ipcRenderer.removeAllListeners("serial-on-file-save-progress") + } + ipcRenderer.on('serial-on-file-save-progress', (event, progress) => { + dataConsumer(progress) + }) + return await ipcRenderer.invoke('serial', 'saveFileContent', filename, content) }, uploadFile: async (src, dest, dataConsumer) => { - return await ipcRenderer.invoke('serial', 'uploadFile', src, dest, dataConsumer) + if (ipcRenderer.listeners("serial-on-upload-progress").length > 0) { + ipcRenderer.removeAllListeners("serial-on-upload-progress") + } + + ipcRenderer.on('serial-on-upload-progress', (event, progress) => { + dataConsumer(progress) + }) + return await ipcRenderer.invoke('serial', 'uploadFile', src, dest) }, downloadFile: async (src, dest) => { let contents = await ipcRenderer.invoke('serial', 'loadFile', src) diff --git a/backend/serial/serial.js b/backend/serial/serial.js index e702b17..0460254 100644 --- a/backend/serial/serial.js +++ b/backend/serial/serial.js @@ -1,4 +1,5 @@ const MicroPython = require('micropython.js') +const path = require('path') class Serial { constructor(win = null) { @@ -79,12 +80,16 @@ class Serial { return await this.board.fs_rm(file) } - async saveFileContent(filename, content, dataConsumer) { - return await this.board.fs_save(content || ' ', filename, dataConsumer) + async saveFileContent(filename, content) { + return await this.board.fs_save(content || ' ', filename, (progress) => { + this.win.webContents.send('serial-on-file-save-progress', progress) + }) } - async uploadFile(src, dest, dataConsumer) { - return await this.board.fs_put(src, dest.replaceAll(path.win32.sep, path.posix.sep), dataConsumer) + async uploadFile(src, dest) { + return await this.board.fs_put(src, dest.replaceAll(path.win32.sep, path.posix.sep), (progress) => { + this.win.webContents.send('serial-on-upload-progress', progress) + }) } async renameFile(oldName, newName) { From 98c4ed08c5f2b02cc266bb262f9e55305d9dd9d0 Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 18 Dec 2024 20:44:18 +0100 Subject: [PATCH 2/2] 0.11.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42738a5..c40dfba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "arduino-lab-micropython-ide", - "version": "0.11.0", + "version": "0.11.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "arduino-lab-micropython-ide", - "version": "0.11.0", + "version": "0.11.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index e86c5ba..b3f5abb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "arduino-lab-micropython-ide", "productName": "Arduino Lab for MicroPython", - "version": "0.11.0", + "version": "0.11.1", "description": "Arduino Lab for MicroPython is a project sponsored by Arduino, based on original work by Murilo Polese.\nThis is an experimental pre-release software, please direct any questions exclusively to Github issues.", "main": "index.js", "scripts": { 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