diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4c1bf..16d94c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,21 @@ # Changelog All notable changes to this project will be documented in this file. -## [2.10.0] - 2022-09-08 +## [2.11.0] - 2022-09-27 + +### Changed +- When using Web Serial API, the interactions between the client library + (as an example, the Arduino `arduino-chromeos-uploader` libray) has been simplified. +- A new parameter `dialogCustomizations` has been added to the upload functionality. It's used + to provide custom confirmation dialogs when using the Web Serial API. + It has no effect with other daemons. + +### Removed +- `cdcReset` functionality, now it's embedded in the `upload` functionality + in the Web Serial daemon. +### Changed + +## [2.10.1] - 2022-09-08 ### Changed - Fixed a bug released in 2.9.1 caused by the wrong assumption that the build filename is always at the end of the command line. This fix makes the library backward compatible with older ESP boards. diff --git a/package.json b/package.json index e800e36..e4446e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arduino-create-agent-js-client", - "version": "2.10.1", + "version": "2.11.0-alpha.2", "description": "JS module providing discovery of the Arduino Create Plugin and communication with it", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/daemon.js b/src/daemon.js index 2e3d769..0474f90 100644 --- a/src/daemon.js +++ b/src/daemon.js @@ -115,8 +115,12 @@ export default class Daemon { * @param {string} sketchName * @param {Object} compilationResult * @param {boolean} verbose + * @param {any[]} dialogCustomizations Optional - Used in Web Serial API to customize the permission dialogs. + * It's an array because the Web Serial API library can use more than one dialog, e.g. one to + * ask permission and one to give instruction to save an UF2 file. + * It's called 'customizations' because the library already provides a basic non-styled dialog. */ - uploadSerial(target, sketchName, compilationResult, verbose = true) { + uploadSerial(target, sketchName, compilationResult, verbose = true, dialogCustomizations) { this.uploadingPort = target.port; this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: 'Upload started' }); this.serialDevicesBeforeUpload = this.devicesList.getValue().serial; @@ -142,7 +146,8 @@ export default class Daemon { commandline: uploadCommandInfo.commandline, filename: `${sketchName}.${ext}`, hex: data, // For desktop agent - data // For chromeOS plugin, consider to align this + data, // For chromeOS plugin, consider to align this + dialogCustomizations // used only in Web Serial API uploader }; this.uploadingDone.subscribe(() => { diff --git a/src/web-serial-daemon.js b/src/web-serial-daemon.js index 0fa2b8c..d44ee45 100644 --- a/src/web-serial-daemon.js +++ b/src/web-serial-daemon.js @@ -190,6 +190,21 @@ export default class WebSerialDaemon extends Daemon { } } + /** + * Send the 'writePort' message to the serial port + * @param {string} port the port name + * @param {string} message the text to be sent to serial + */ + writeSerial(port, message) { + this.channel.postMessage({ + command: 'writePort', + data: { + name: port, + data: message + } + }); + } + /** * Request serial port open * @param {string} port the port name @@ -247,23 +262,12 @@ export default class WebSerialDaemon extends Daemon { }); } - cdcReset({ fqbn, port }) { - this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: 'CDC reset started' }); - this.channel.postMessage({ - command: 'cdcReset', - data: { - fqbn, - port - } - }); - } - - connectToSerialDevice({ fqbn }) { - this.uploading.next({ status: this.UPLOAD_IN_PROGRESS, msg: 'Board selection started' }); + connectToSerialDevice({ from, dialogCustomization }) { this.channel.postMessage({ command: 'connectToSerial', data: { - fqbn + from, + dialogCustomization } }); } @@ -274,9 +278,11 @@ export default class WebSerialDaemon extends Daemon { */ _upload(uploadPayload, uploadCommandInfo) { const { - board, port, commandline, data, pid, vid + board, port, commandline, data, pid, vid, dialogCustomizations } = uploadPayload; + const extrafiles = uploadCommandInfo && uploadCommandInfo.files && Array.isArray(uploadCommandInfo.files) ? uploadCommandInfo.files : []; + try { window.oauth.getAccessToken().then(token => { this.channel.postMessage({ @@ -289,7 +295,8 @@ export default class WebSerialDaemon extends Daemon { token: token.token, extrafiles, pid, - vid + vid, + dialogCustomizations } }); });