@myshkouski/web-serial-polyfill 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -8
- package/serial.ts +5 -5
- package/tsconfig.json +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myshkouski/web-serial-polyfill",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "An implementation of the [Serial API](https://wicg.github.io/serial) on top of the [WebUSB API](https://wicg.github.io/webusb) for use with USB-to-serial adapters. Use of this library is limited to hardware and platforms where the device is accessible via the WebUSB API because it has not been claimed by a built-in device driver. This project will be used to prototype the design of the Serial API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/serial.js",
|
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
},
|
|
17
17
|
"author": "James C Hollyer",
|
|
18
18
|
"license": "Apache",
|
|
19
|
-
"
|
|
19
|
+
"dependencies": {
|
|
20
20
|
"@types/w3c-web-serial": "^1.0.8",
|
|
21
|
-
"@types/w3c-web-usb": "^1.0.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"@
|
|
25
|
-
"eslint": "^
|
|
21
|
+
"@types/w3c-web-usb": "^1.0.14"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/web": "^0.0.356",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
26
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
27
|
+
"eslint": "^8.57.1",
|
|
26
28
|
"eslint-config-google": "^0.14.0",
|
|
27
|
-
"typescript": "^
|
|
29
|
+
"typescript": "^7.0.2"
|
|
28
30
|
}
|
|
29
31
|
}
|
package/serial.ts
CHANGED
|
@@ -144,7 +144,7 @@ class UsbEndpointUnderlyingSource implements UnderlyingByteSource {
|
|
|
144
144
|
controller.enqueue(chunk);
|
|
145
145
|
}
|
|
146
146
|
} catch (error) {
|
|
147
|
-
controller.error(error
|
|
147
|
+
controller.error(error);
|
|
148
148
|
this.onError_();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -182,17 +182,17 @@ class UsbEndpointUnderlyingSink implements UnderlyingSink<Uint8Array> {
|
|
|
182
182
|
* @param {WritableStreamDefaultController} controller
|
|
183
183
|
*/
|
|
184
184
|
async write(
|
|
185
|
-
chunk: Uint8Array<
|
|
185
|
+
chunk: Uint8Array<ArrayBufferLike>,
|
|
186
186
|
controller: WritableStreamDefaultController): Promise<void> {
|
|
187
187
|
try {
|
|
188
188
|
const result =
|
|
189
|
-
await this.device_.transferOut(this.endpoint_.endpointNumber, chunk);
|
|
189
|
+
await this.device_.transferOut(this.endpoint_.endpointNumber, new Uint8Array(chunk));
|
|
190
190
|
if (result.status != 'ok') {
|
|
191
191
|
controller.error(result.status);
|
|
192
192
|
this.onError_();
|
|
193
193
|
}
|
|
194
194
|
} catch (error) {
|
|
195
|
-
controller.error(error
|
|
195
|
+
controller.error(error);
|
|
196
196
|
this.onError_();
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -333,7 +333,7 @@ class SerialPortPolyfill implements BaseSerialPort {
|
|
|
333
333
|
await this.releaseInterfaces_();
|
|
334
334
|
await this.device_.close();
|
|
335
335
|
}
|
|
336
|
-
throw new Error('Error setting up device
|
|
336
|
+
throw new Error('Error setting up device', { cause: error });
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
|
package/tsconfig.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"module": "esnext",
|
|
4
|
-
"lib": ["
|
|
4
|
+
"lib": ["ESNext", "DOM", "DOM.AsyncIterable"],
|
|
5
|
+
"types": [
|
|
6
|
+
"w3c-web-serial",
|
|
7
|
+
"w3c-web-usb"
|
|
8
|
+
],
|
|
5
9
|
"outDir": "./dist/",
|
|
6
10
|
"sourceMap": true,
|
|
7
11
|
"noImplicitAny": true,
|