From 24092bf05eda8e223b11c3c639e7d2372bab2076 Mon Sep 17 00:00:00 2001 From: windowsair Date: Fri, 15 Mar 2024 23:21:17 +0800 Subject: [PATCH] example: Deprecate the webusb package dependency The webusb feature is already included in the usb package. Let's deprecate the extra webusb package. --- examples/daplink-flash/webusb.js | 4 ++-- examples/daplink-serial/webusb.js | 4 ++-- examples/execute/webusb.js | 4 ++-- examples/read-registers/webusb.js | 4 ++-- examples/typescript/node.ts | 6 +++--- examples/typescript/package.json | 2 +- package.json | 3 +-- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/daplink-flash/webusb.js b/examples/daplink-flash/webusb.js index fbd4e4c..f54fe38 100644 --- a/examples/daplink-flash/webusb.js +++ b/examples/daplink-flash/webusb.js @@ -20,7 +20,7 @@ * SOFTWARE. */ -const USB = require('webusb').USB; +const WebUSB = require('usb').WebUSB; const common = require('./common'); const DAPjs = require('../../'); @@ -33,7 +33,7 @@ const devicesFound = async (devices) => { return common.selectDevice(devices); } -const usb = new USB({ devicesFound }); +const usb = new WebUSB({devicesFound: devicesFound}); (async () => { try { diff --git a/examples/daplink-serial/webusb.js b/examples/daplink-serial/webusb.js index b3a29eb..8af9e94 100644 --- a/examples/daplink-serial/webusb.js +++ b/examples/daplink-serial/webusb.js @@ -20,7 +20,7 @@ * SOFTWARE. */ -const USB = require('webusb').USB; +const WebUSB = require('usb').WebUSB; const common = require('./common'); const DAPjs = require('../../'); @@ -33,7 +33,7 @@ const devicesFound = async (devices) => { return common.selectDevice(devices); } -const usb = new USB({ devicesFound }); +const usb = new WebUSB({devicesFound: devicesFound}); (async () => { try { diff --git a/examples/execute/webusb.js b/examples/execute/webusb.js index 7465710..e643327 100644 --- a/examples/execute/webusb.js +++ b/examples/execute/webusb.js @@ -20,7 +20,7 @@ * SOFTWARE. */ -const USB = require('webusb').USB; +const WebUSB = require('usb').WebUSB; const common = require('./common'); const DAPjs = require('../../'); @@ -35,7 +35,7 @@ const devicesFound = async (devices) => { return common.selectDevice(devices); } -const usb = new USB({ devicesFound }); +const usb = new WebUSB({devicesFound: devicesFound}); (async () => { try { diff --git a/examples/read-registers/webusb.js b/examples/read-registers/webusb.js index b0b8d19..4f07052 100644 --- a/examples/read-registers/webusb.js +++ b/examples/read-registers/webusb.js @@ -20,7 +20,7 @@ * SOFTWARE. */ -const USB = require('webusb').USB; +const WebUSB = require('usb').WebUSB; const common = require('./common'); const DAPjs = require('../../'); @@ -33,7 +33,7 @@ const devicesFound = async (devices) => { return common.selectDevice(devices); } -const usb = new USB({ devicesFound }); +const usb = new WebUSB({devicesFound: devicesFound}); (async () => { try { diff --git a/examples/typescript/node.ts b/examples/typescript/node.ts index afaa3a8..f0b1e74 100644 --- a/examples/typescript/node.ts +++ b/examples/typescript/node.ts @@ -21,7 +21,7 @@ */ import { stdin } from 'process'; -import { USB } from 'webusb'; +import { WebUSB } from 'usb'; import { Registers } from './registers'; // Handle single character input from the user @@ -74,7 +74,7 @@ const devicesFound = async (devices: USBDevice[]): Promise { @@ -84,7 +84,7 @@ const registers = new Registers(usb); console.log(`R${index}: ${register}`); }); } catch(error) { - console.error(error.message || error); + console.error(error); } process.exit(); })(); diff --git a/examples/typescript/package.json b/examples/typescript/package.json index 1251130..83ed5f9 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -12,6 +12,6 @@ "dapjs": "next", "tsify": "^4.0.1", "typescript": "^3.4.5", - "webusb": "^2.0.2" + "usb": "^2.11.0" } } diff --git a/package.json b/package.json index 0df2836..cbd9220 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "tslib": "^2.6.2", "typedoc": "^0.25.7", "typescript": "^5.3.3", - "usb": "^2.11.0", - "webusb": "^2.2.0" + "usb": "^2.11.0" } }