Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebHID API available in workers #36060

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/en-us/web/api/hid/connect_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HID.connect_event
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`connect`** event of the {{domxref("HID")}} interface fires when the user agent connects to a HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hid/disconnect_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HID.disconnect_event
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`disconnect`** event of the {{domxref("HID")}} interface fires when the user agent disconnects a HID device.

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/hid/getdevices/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ status:
browser-compat: api.HID.getDevices
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`getDevices()`** method of the {{domxref("HID")}} interface gets a list of the connected HID devices that the user has previously been granted access to in response to a {{domxref("HID.requestDevice","requestDevice()")}} call.
The **`getDevices()`** method of the {{domxref("HID")}} interface gets a list of connected HID devices that the user has previously been granted access to in response to a {{domxref("HID.requestDevice","requestDevice()")}} call.

## Syntax

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/hid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
browser-compat: api.HID
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`HID`** interface provides methods for connecting to _HID devices_, listing attached HID devices and event handlers for connected HID devices.

Expand All @@ -22,7 +22,7 @@ _This interface also inherits properties of its parent, {{domxref("EventTarget")
_This interface also inherits methods of its parent, {{domxref("EventTarget")}}._

- {{domxref("HID.getDevices","getDevices()")}} {{Experimental_Inline}}
- : Returns a {{jsxref("Promise")}} that resolves with an array of connected {{domxref("HIDDevice")}} objects.
- : Returns a {{jsxref("Promise")}} that resolves with an array of connected HID devices that the user has previously been granted access to in response to a {{domxref("HID.requestDevice","requestDevice()")}} call.
- {{domxref("HID.requestDevice","requestDevice()")}} {{Experimental_Inline}}
- : Returns a {{jsxref("Promise")}} that resolves with an array of connected {{domxref("HIDDevice")}} objects. Calling this function will trigger the user agent's permission flow in order to gain permission to access one selected device from the returned list of devices.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidconnectionevent/device/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDConnectionEvent.device
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`device`** read-only property of the {{domxref("HIDConnectionEvent")}} interface returns the {{domxref("HIDDevice")}} associated with this connection event.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDConnectionEvent.HIDConnectionEvent
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`HIDConnectionEvent()`** constructor creates a new {{domxref("HIDConnectionEvent")}} object. Typically this constructor is not used as events are created when a device's connection state changes.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidconnectionevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
browser-compat: api.HIDConnectionEvent
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`HIDConnectionEvent`** interface of the [WebHID API](/en-US/docs/Web/API/WebHID_API) represents HID connection events, and is the event type passed to {{domxref("HID/connect_event", "connect")}} and {{domxref("HID/disconnect_event", "disconnect")}} event handlers when a device's connection state changes.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/close/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.close
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`close()`** method of the {{domxref("HIDDevice")}} interface closes the connection to the HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/collections/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.collections
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`collections`** read-only property of the {{domxref("HIDDevice")}} interface returns an array of report formats

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/forget/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.forget
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`forget()`** method of the {{domxref("HIDDevice")}} interface closes the connection to the HID device and forgets the device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
browser-compat: api.HIDDevice
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`HIDDevice`** interface of the [WebHID API](/en-US/docs/Web/API/WebHID_API) represents a HID Device. It provides properties for accessing information about the device, methods for opening and closing the connection, and the sending and receiving of reports.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/inputreport_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.inputreport_event
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`inputreport`** event of the {{domxref("HIDDevice")}} interface fires when a new report is received from the HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/open/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.open
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`open()`** method of the {{domxref("HIDDevice")}} interface requests that the operating system opens the HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/opened/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.opened
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`opened`** read-only property of the {{domxref("HIDDevice")}} interface returns true if the connection to the {{domxref("HIDDevice")}} is open and ready to transfer data.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/productid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.productId
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`productId`** read-only property of the {{domxref("HIDDevice")}} interface returns the product ID of the connected HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/productname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.productName
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`productName`** read-only property of the {{domxref("HIDDevice")}} interface returns the product name of the connected HID device.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.receiveFeatureReport
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`receiveFeatureReport()`** method of the {{domxref("HIDDevice")}} interface receives a feature report from the HID device. Feature reports are a way for HID devices and applications to exchange non-standardized HID data.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/sendfeaturereport/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.sendFeatureReport
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`sendFeatureReport()`** method of the {{domxref("HIDDevice")}} interface sends a feature report to the HID device. Feature reports are a way for HID devices and applications to exchange non-standardized HID data.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/sendreport/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.sendReport
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`sendReport()`** method of the {{domxref("HIDDevice")}} interface sends an output report to the HID device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hiddevice/vendorid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDDevice.vendorId
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`vendorId`** read-only property of the {{domxref("HIDDevice")}} interface returns the vendor ID of the connected HID device. This identifies the vendor of the device.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidinputreportevent/data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDInputReportEvent.data
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`data`** property of the {{domxref("HIDInputReportEvent")}} interface returns a {{jsxref("DataView")}} containing the data from the input report, excluding the `reportId` if the HID interface uses report IDs.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidinputreportevent/device/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDInputReportEvent.device
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`device`** property of the {{domxref("HIDInputReportEvent")}} interface returns the {{domxref("HIDDevice")}} instance that represents the HID interface that sent the input report.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidinputreportevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
browser-compat: api.HIDInputReportEvent
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`HIDInputReportEvent`** interface of the [WebHID API](/en-US/docs/Web/API/WebHID_API) is passed to {{domxref("HIDDevice.inputreport_event", "inputreport")}} event of `HIDDevice` when an input report is received from any associated HID device.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ status:
browser-compat: api.HIDInputReportEvent.reportId
---

{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

The **`reportId`** property of the {{domxref("HIDInputReportEvent")}} interface returns the one-byte identification prefix for this report, or 0 if the HID interface does not use report IDs.

Expand Down
4 changes: 1 addition & 3 deletions files/en-us/web/api/navigator/hid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ browser-compat: api.Navigator.hid
{{APIRef("WebHID API")}}{{SeeCompatTable}}{{SecureContext_Header}}

The **`Navigator.hid`**
read-only property returns an {{domxref("HID")}} object providing methods
for connecting to HID devices, listing attached HID devices, and event
handlers for connected HID devices.
read-only property returns an {{domxref("HID")}} object providing methods for accessing HID device connections and events that fire when the user agent connects to or disconnects from a device.

Where a defined [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy) blocks WebHID usage, the `Navigator.hid` property will not be available.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following Web APIs are available to workers:
- {{domxref("User-Agent Client Hints API", "", "", "nocode")}}
- {{domxref("WebCodecs API", "", "", "nocode")}}
- {{domxref("Web Crypto API", "", "", "nocode")}} (e.g. {{domxref("Crypto")}})
- {{domxref("WebHID API", "", "", "nocode")}} (dedicated and service workers only)
- {{domxref("Web Locks API", "", "", "nocode")}}
- {{domxref("Web Serial API", "", "", "nocode")}}
- {{domxref("Web Periodic Background Synchronization API", "", "", "nocode")}}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/webhid_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
browser-compat: api.HID
---

{{DefaultAPISidebar("WebHID API")}}{{SeeCompatTable}}
{{DefaultAPISidebar("WebHID API")}}{{SeeCompatTable}}{{AvailableInWorkers("window_and_worker_except_shared")}}

A Human Interface Device (HID) is a type of device that takes input from or provides output to humans. It also refers to the HID protocol, a standard for bi-directional communication between a host and a device that is designed to simplify the installation procedure. The HID protocol was originally developed for USB devices but has since been implemented over many other protocols, including Bluetooth.

Expand Down
32 changes: 32 additions & 0 deletions files/en-us/web/api/workernavigator/hid/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "WorkerNavigator: hid property"
short-title: hid
slug: Web/API/WorkerNavigator/hid
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.WorkerNavigator.hid
---

{{APIRef("WebHID API")}}{{SeeCompatTable}}{{SecureContext_Header}}

The **`WorkerNavigator.hid`**
read-only property returns an {{domxref("HID")}} object providing methods for accessing HID device connections and events that fire when the user agent connects to or disconnects from a device.

Where a defined [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy) blocks WebHID usage, the `WorkerNavigator.hid` property will not be available.

## Value

An {{domxref("HID")}} object.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [WebHID API](/en-US/docs/Web/API/WebHID_API)
2 changes: 2 additions & 0 deletions files/en-us/web/api/workernavigator/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ _The `WorkerNavigator` interface doesn't inherit any property._
- : Returns the {{domxref("GPU")}} object for the current worker context. The entry point for the {{domxref("WebGPU_API", "WebGPU API", "", "nocode")}}.
- {{DOMxRef("WorkerNavigator.hardwareConcurrency")}} {{ReadOnlyInline}}
- : Returns the number of logical processor cores available.
- {{domxref("WorkerNavigator.hid")}} {{ReadOnlyInline}} {{Experimental_Inline}} {{SecureContext_Inline}}
- : Returns an {{domxref("HID")}} object providing methods for connecting to HID devices already granted permission by the user and listing attached HID devices, and event handlers for responding to HID devices connecting and disconnecting.
- {{DOMxRef("WorkerNavigator.language")}} {{ReadOnlyInline}}
- : Returns a string representing the preferred language of the user, usually the language of the browser UI. The `null` value is returned when this is unknown.
- {{DOMxRef("WorkerNavigator.languages")}} {{ReadOnlyInline}}
Expand Down
2 changes: 1 addition & 1 deletion files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@
"HIDConnectionEvent"
],
"methods": [],
"properties": ["Navigator.hid"],
"properties": ["Navigator.hid", "WorkerNavigator.hid"],
"events": []
},
"Web Locks API": {
Expand Down