1
0

chore: 添加 @types/w3c-web-serial

This commit is contained in:
2026-02-15 15:23:00 +08:00
parent 40e1ad2b48
commit 0783f51203
7 changed files with 243 additions and 0 deletions

13
node_modules/.package-lock.json generated vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"name": "msu2-usb-monitor-controller",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@types/w3c-web-serial": {
"version": "1.0.8",
"resolved": "http://mirrors.tencentyun.com/npm/@types/w3c-web-serial/-/w3c-web-serial-1.0.8.tgz",
"integrity": "sha512-QQOT+bxQJhRGXoZDZGLs3ksLud1dMNnMiSQtBA0w8KXvLpXX4oM4TZb6J0GgJ8UbCaHo5s9/4VQT8uXy9JER2A=="
}
}
}

21
node_modules/@types/w3c-web-serial/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

15
node_modules/@types/w3c-web-serial/README.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/w3c-web-serial`
# Summary
This package contains type definitions for w3c-web-serial (https://wicg.github.io/serial).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/w3c-web-serial.
### Additional Details
* Last updated: Sat, 01 Mar 2025 01:29:33 GMT
* Dependencies: none
# Credits
These definitions were written by [Reilly Grant](https://github.com/reillyeon).

134
node_modules/@types/w3c-web-serial/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,134 @@
/*~ https://wicg.github.io/serial/#dom-paritytype */
type ParityType = "none" | "even" | "odd";
/*~ https://wicg.github.io/serial/#dom-flowcontroltype */
type FlowControlType = "none" | "hardware";
/*~ https://wicg.github.io/serial/#dom-serialoptions */
interface SerialOptions {
baudRate: number;
dataBits?: 7 | 8 | undefined;
stopBits?: 1 | 2 | undefined;
parity?: ParityType | undefined;
bufferSize?: number | undefined;
flowControl?: FlowControlType | undefined;
}
/*~ https://wicg.github.io/serial/#dom-serialoutputsignals */
interface SerialOutputSignals {
dataTerminalReady?: boolean | undefined;
requestToSend?: boolean | undefined;
break?: boolean | undefined;
}
/*~ https://wicg.github.io/serial/#dom-serialinputsignals */
interface SerialInputSignals {
dataCarrierDetect: boolean;
clearToSend: boolean;
ringIndicator: boolean;
dataSetReady: boolean;
}
/*~ https://wicg.github.io/serial/#serialportinfo-dictionary */
interface SerialPortInfo {
usbVendorId?: number | undefined;
usbProductId?: number | undefined;
/** If the port is a service on a Bluetooth device this member will be a BluetoothServiceUUID
* containing the service class UUID. Otherwise it will be undefined. */
bluetoothServiceClassId?: number | string | undefined;
}
/*~ https://wicg.github.io/serial/#dom-serialport */
declare class SerialPort extends EventTarget {
onconnect: ((this: this, ev: Event) => void) | null;
ondisconnect: ((this: this, ev: Event) => void) | null;
/** A flag indicating the logical connection state of serial port */
readonly connected: boolean;
readonly readable: ReadableStream<Uint8Array> | null;
readonly writable: WritableStream<Uint8Array> | null;
open(options: SerialOptions): Promise<void>;
setSignals(signals: SerialOutputSignals): Promise<void>;
getSignals(): Promise<SerialInputSignals>;
getInfo(): SerialPortInfo;
close(): Promise<void>;
forget(): Promise<void>;
addEventListener(
type: "connect" | "disconnect",
listener: (this: this, ev: Event) => void,
useCapture?: boolean,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener(
type: "connect" | "disconnect",
callback: (this: this, ev: Event) => void,
useCapture?: boolean,
): void;
removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean,
): void;
}
/*~ https://wicg.github.io/serial/#dom-serialportfilter */
interface SerialPortFilter {
usbVendorId?: number | undefined;
usbProductId?: number | undefined;
bluetoothServiceClassId?: number | string | undefined;
}
/*~ https://wicg.github.io/serial/#dom-serialportrequestoptions */
interface SerialPortRequestOptions {
filters?: SerialPortFilter[] | undefined;
/** A list of BluetoothServiceUUID values representing Bluetooth service class IDs.
* Bluetooth ports with custom service class IDs are excluded from the list of ports
* presented to the user unless the service class ID is included in this list.
*
* {@link https://wicg.github.io/serial/#serialportrequestoptions-dictionary} */
allowedBluetoothServiceClassIds?: Array<number | string> | undefined;
}
/*~ https://wicg.github.io/serial/#dom-serial */
declare class Serial extends EventTarget {
onconnect: ((this: this, ev: Event) => void) | null;
ondisconnect: ((this: this, ev: Event) => void) | null;
getPorts(): Promise<SerialPort[]>;
requestPort(options?: SerialPortRequestOptions): Promise<SerialPort>;
addEventListener(
type: "connect" | "disconnect",
listener: (this: this, ev: Event) => void,
useCapture?: boolean,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject | null,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener(
type: "connect" | "disconnect",
callback: (this: this, ev: Event) => void,
useCapture?: boolean,
): void;
removeEventListener(
type: string,
callback: EventListenerOrEventListenerObject | null,
options?: EventListenerOptions | boolean,
): void;
}
/*~ https://wicg.github.io/serial/#extensions-to-the-navigator-interface */
interface Navigator {
readonly serial: Serial;
}
/*~ https://wicg.github.io/serial/#extensions-to-workernavigator-interface */
interface WorkerNavigator {
readonly serial: Serial;
}

27
node_modules/@types/w3c-web-serial/package.json generated vendored Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "@types/w3c-web-serial",
"version": "1.0.8",
"description": "TypeScript definitions for w3c-web-serial",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/w3c-web-serial",
"license": "MIT",
"contributors": [
{
"name": "Reilly Grant",
"githubUsername": "reillyeon",
"url": "https://github.com/reillyeon"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/w3c-web-serial"
},
"scripts": {},
"dependencies": {},
"peerDependencies": {},
"typesPublisherContentHash": "65266e1703600c207e33ead89e5dced16e5c16067f0144a0e074ad4d3829d1d0",
"typeScriptVersion": "5.0",
"nonNpm": true
}

21
package-lock.json generated Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "msu2-usb-monitor-controller",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "msu2-usb-monitor-controller",
"version": "1.0.0",
"license": "GPL-3.0-only",
"dependencies": {
"@types/w3c-web-serial": "^1.0.8"
}
},
"node_modules/@types/w3c-web-serial": {
"version": "1.0.8",
"resolved": "http://mirrors.tencentyun.com/npm/@types/w3c-web-serial/-/w3c-web-serial-1.0.8.tgz",
"integrity": "sha512-QQOT+bxQJhRGXoZDZGLs3ksLud1dMNnMiSQtBA0w8KXvLpXX4oM4TZb6J0GgJ8UbCaHo5s9/4VQT8uXy9JER2A=="
}
}
}

12
package.json Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "msu2-usb-monitor-controller",
"version": "1.0.0",
"description": "MSU2 USB 小屏幕控制网页 Demo使用 TRAE 辅助编写,参考了原 Python 程序的代码。",
"author": "Frost-ZX",
"keywords": ["demo", "web"],
"license": "GPL-3.0-only",
"scripts": {},
"dependencies": {
"@types/w3c-web-serial": "^1.0.8"
}
}