@potatosalad775/eqcaps-device-bridge 0.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/LICENSE +21 -0
- package/NOTICE.md +54 -0
- package/README.md +112 -0
- package/dist/analysis.d.ts +34 -0
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +92 -0
- package/dist/analysis.js.map +1 -0
- package/dist/biquad.d.ts +9 -0
- package/dist/biquad.d.ts.map +1 -0
- package/dist/biquad.js +50 -0
- package/dist/biquad.js.map +1 -0
- package/dist/browser/index.d.ts +14 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +12 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/stream.d.ts +15 -0
- package/dist/browser/stream.d.ts.map +1 -0
- package/dist/browser/stream.js +51 -0
- package/dist/browser/stream.js.map +1 -0
- package/dist/browser/web-apis.d.ts +136 -0
- package/dist/browser/web-apis.d.ts.map +1 -0
- package/dist/browser/web-apis.js +13 -0
- package/dist/browser/web-apis.js.map +1 -0
- package/dist/browser/webbluetooth.d.ts +30 -0
- package/dist/browser/webbluetooth.d.ts.map +1 -0
- package/dist/browser/webbluetooth.js +80 -0
- package/dist/browser/webbluetooth.js.map +1 -0
- package/dist/browser/webhid.d.ts +33 -0
- package/dist/browser/webhid.d.ts.map +1 -0
- package/dist/browser/webhid.js +90 -0
- package/dist/browser/webhid.js.map +1 -0
- package/dist/browser/webserial.d.ts +34 -0
- package/dist/browser/webserial.d.ts.map +1 -0
- package/dist/browser/webserial.js +133 -0
- package/dist/browser/webserial.js.map +1 -0
- package/dist/bytes.d.ts +40 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +74 -0
- package/dist/bytes.js.map +1 -0
- package/dist/chooser.d.ts +40 -0
- package/dist/chooser.d.ts.map +1 -0
- package/dist/chooser.js +49 -0
- package/dist/chooser.js.map +1 -0
- package/dist/device.d.ts +51 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +94 -0
- package/dist/device.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/handler.d.ts +161 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +3 -0
- package/dist/handler.js.map +1 -0
- package/dist/handlers/airoha.d.ts +12 -0
- package/dist/handlers/airoha.d.ts.map +1 -0
- package/dist/handlers/airoha.js +135 -0
- package/dist/handlers/airoha.js.map +1 -0
- package/dist/handlers/conexant-usb-hid.d.ts +4 -0
- package/dist/handlers/conexant-usb-hid.d.ts.map +1 -0
- package/dist/handlers/conexant-usb-hid.js +103 -0
- package/dist/handlers/conexant-usb-hid.js.map +1 -0
- package/dist/handlers/edifier-serial.d.ts +6 -0
- package/dist/handlers/edifier-serial.d.ts.map +1 -0
- package/dist/handlers/edifier-serial.js +111 -0
- package/dist/handlers/edifier-serial.js.map +1 -0
- package/dist/handlers/fiio-f110.d.ts +7 -0
- package/dist/handlers/fiio-f110.d.ts.map +1 -0
- package/dist/handlers/fiio-f110.js +101 -0
- package/dist/handlers/fiio-f110.js.map +1 -0
- package/dist/handlers/fiio-usb-hid.d.ts +39 -0
- package/dist/handlers/fiio-usb-hid.d.ts.map +1 -0
- package/dist/handlers/fiio-usb-hid.js +143 -0
- package/dist/handlers/fiio-usb-hid.js.map +1 -0
- package/dist/handlers/fiio-usb-serial.d.ts +9 -0
- package/dist/handlers/fiio-usb-serial.d.ts.map +1 -0
- package/dist/handlers/fiio-usb-serial.js +122 -0
- package/dist/handlers/fiio-usb-serial.js.map +1 -0
- package/dist/handlers/fosi-audio-usb-hid.d.ts +19 -0
- package/dist/handlers/fosi-audio-usb-hid.d.ts.map +1 -0
- package/dist/handlers/fosi-audio-usb-hid.js +165 -0
- package/dist/handlers/fosi-audio-usb-hid.js.map +1 -0
- package/dist/handlers/index.d.ts +25 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +36 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/jds-labs-usb-serial.d.ts +5 -0
- package/dist/handlers/jds-labs-usb-serial.d.ts.map +1 -0
- package/dist/handlers/jds-labs-usb-serial.js +156 -0
- package/dist/handlers/jds-labs-usb-serial.js.map +1 -0
- package/dist/handlers/ktmicro-usb-hid.d.ts +20 -0
- package/dist/handlers/ktmicro-usb-hid.d.ts.map +1 -0
- package/dist/handlers/ktmicro-usb-hid.js +144 -0
- package/dist/handlers/ktmicro-usb-hid.js.map +1 -0
- package/dist/handlers/moondrop-edge-serial.d.ts +8 -0
- package/dist/handlers/moondrop-edge-serial.d.ts.map +1 -0
- package/dist/handlers/moondrop-edge-serial.js +100 -0
- package/dist/handlers/moondrop-edge-serial.js.map +1 -0
- package/dist/handlers/moondrop-old-fashioned-hid.d.ts +4 -0
- package/dist/handlers/moondrop-old-fashioned-hid.d.ts.map +1 -0
- package/dist/handlers/moondrop-old-fashioned-hid.js +102 -0
- package/dist/handlers/moondrop-old-fashioned-hid.js.map +1 -0
- package/dist/handlers/moondrop-usb-hid.d.ts +8 -0
- package/dist/handlers/moondrop-usb-hid.d.ts.map +1 -0
- package/dist/handlers/moondrop-usb-hid.js +134 -0
- package/dist/handlers/moondrop-usb-hid.js.map +1 -0
- package/dist/handlers/nothing-usb-serial.d.ts +19 -0
- package/dist/handlers/nothing-usb-serial.d.ts.map +1 -0
- package/dist/handlers/nothing-usb-serial.js +141 -0
- package/dist/handlers/nothing-usb-serial.js.map +1 -0
- package/dist/handlers/qudelix-usb-hid.d.ts +16 -0
- package/dist/handlers/qudelix-usb-hid.d.ts.map +1 -0
- package/dist/handlers/qudelix-usb-hid.js +127 -0
- package/dist/handlers/qudelix-usb-hid.js.map +1 -0
- package/dist/handlers/tanchjim-rita-serial.d.ts +5 -0
- package/dist/handlers/tanchjim-rita-serial.d.ts.map +1 -0
- package/dist/handlers/tanchjim-rita-serial.js +89 -0
- package/dist/handlers/tanchjim-rita-serial.js.map +1 -0
- package/dist/handlers/walkplay-hid.d.ts +12 -0
- package/dist/handlers/walkplay-hid.d.ts.map +1 -0
- package/dist/handlers/walkplay-hid.js +150 -0
- package/dist/handlers/walkplay-hid.js.map +1 -0
- package/dist/identity.d.ts +20 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +30 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +50 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +119 -0
- package/dist/io.js.map +1 -0
- package/dist/platform.d.ts +9 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +59 -0
- package/dist/platform.js.map +1 -0
- package/dist/protocols.d.ts +52 -0
- package/dist/protocols.d.ts.map +1 -0
- package/dist/protocols.js +204 -0
- package/dist/protocols.js.map +1 -0
- package/dist/transport.d.ts +59 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +12 -0
- package/dist/transport.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 potatosalad775
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Notices
|
|
2
|
+
|
|
3
|
+
`@potatosalad775/eqcaps-device-bridge` is MIT-licensed (see `LICENSE`). Its device handlers are
|
|
4
|
+
ported from the two projects below.
|
|
5
|
+
|
|
6
|
+
## modernGraphTool
|
|
7
|
+
|
|
8
|
+
<https://github.com/potatosalad775/modernGraphTool>, `src/lib/device-peq/`: the TypeScript port
|
|
9
|
+
of devicePEQ these handlers started from.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2026 potatosalad775
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## devicePEQ
|
|
36
|
+
|
|
37
|
+
<https://github.com/jeromeof/devicePEQ> at commit `0617f38`: the handlers' protocols, the
|
|
38
|
+
per-device protocol settings and preset slots (now in the eqcaps profiles' `protocol` blocks), and
|
|
39
|
+
the recorded device captures in the repository's tests.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Copyright 2024 Jerome O'Flaherty (jerome.oflaherty@icloud.com)
|
|
43
|
+
|
|
44
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
45
|
+
purpose with or without fee is hereby granted.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
48
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
49
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
50
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
51
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
52
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
53
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
54
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @potatosalad775/eqcaps-device-bridge
|
|
2
|
+
|
|
3
|
+
Reads and writes parametric EQ on audio hardware: FiiO, Walkplay-chipset dongles, Moondrop,
|
|
4
|
+
KT Micro, Fosi Audio, Qudelix, JDS Labs, Nothing, Tanchjim, Edifier, Audeze and others, every
|
|
5
|
+
hardware device in the [eqcaps](https://github.com/potatosalad775/eqcaps) database. Protocols from
|
|
6
|
+
[devicePEQ](https://github.com/jeromeof/devicePEQ).
|
|
7
|
+
|
|
8
|
+
- **No platform types.** Handlers talk to two small transport interfaces (`HidTransport`,
|
|
9
|
+
`StreamTransport`). Browser transports for WebHID, Web Serial and Web Bluetooth are in
|
|
10
|
+
`@potatosalad775/eqcaps-device-bridge/browser`; a native app (an Android Capacitor plugin, say)
|
|
11
|
+
implements the interfaces over its own USB stack.
|
|
12
|
+
- **Driven by the database.** The bridge knows how to talk to a device, not what it accepts or
|
|
13
|
+
which device it is. The client matches a connected device to its eqcaps profile; the profile
|
|
14
|
+
says what the device accepts (fit and complete with `@potatosalad775/eqcaps-core` before
|
|
15
|
+
writing) and, in its `protocol`, which handler drives it with which settings.
|
|
16
|
+
`protocolForMatches(matches)` gives the protocol of the most specific match that has one this
|
|
17
|
+
bridge can drive; `protocolOf(profile)` reads one profile's or index entry's. A device added to
|
|
18
|
+
the database on a protocol the bridge already speaks needs no new bridge release.
|
|
19
|
+
- **Writes exactly what it is given.** No clamping, padding, type conversion or compensation. A
|
|
20
|
+
value the wire can't carry or a type the protocol has no code for is a `BridgeError`, before
|
|
21
|
+
anything is sent.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { createClient } from '@potatosalad775/eqcaps-client';
|
|
25
|
+
import { complete, fit } from '@potatosalad775/eqcaps-core';
|
|
26
|
+
import {
|
|
27
|
+
guessProtocol,
|
|
28
|
+
identityOf,
|
|
29
|
+
openDevice,
|
|
30
|
+
protocolForMatches
|
|
31
|
+
} from '@potatosalad775/eqcaps-device-bridge';
|
|
32
|
+
import { requestHidDevice } from '@potatosalad775/eqcaps-device-bridge/browser';
|
|
33
|
+
|
|
34
|
+
const client = createClient();
|
|
35
|
+
const index = await client.loadIndex();
|
|
36
|
+
// The browser's chooser, offering the database's devices; null if cancelled.
|
|
37
|
+
const transport = await requestHidDevice({ entries: index?.profiles ?? [] });
|
|
38
|
+
if (transport) {
|
|
39
|
+
const { best, matches } = await client.matchDevice(identityOf(transport));
|
|
40
|
+
const profile = best ? await client.loadProfile(best.id) : null;
|
|
41
|
+
const protocol =
|
|
42
|
+
protocolForMatches(matches)?.protocol ?? guessProtocol(transport.vendorId);
|
|
43
|
+
if (protocol) {
|
|
44
|
+
const device = openDevice(transport, protocol, profile ? { profile } : {});
|
|
45
|
+
|
|
46
|
+
// Read: written values, as the device holds them.
|
|
47
|
+
const state = await device.pull();
|
|
48
|
+
|
|
49
|
+
// Write: what the user wants, fitted to the device, every band filled.
|
|
50
|
+
if (profile) {
|
|
51
|
+
const result = fit(profile, wantedFilters, wantedPreamp);
|
|
52
|
+
const filters = complete(profile, result.slots).filters;
|
|
53
|
+
const preamp = profile.preamp.mode === 'manual' ? result.preamp : undefined;
|
|
54
|
+
await device.push({ filters, ...(preamp === undefined ? {} : { preamp }) });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Offline, match against an embedded `bundle.json` with the client's `matchDevice` instead.
|
|
61
|
+
Serial ports and BLE devices are chosen first and opened once the protocol is known:
|
|
62
|
+
`requestSerialPort()` and `requestBleDevice()` return the device's `identity` and an
|
|
63
|
+
`open(protocol)`. A Bluetooth serial port shows only its service class, which several devices
|
|
64
|
+
share: ask the user which device it is.
|
|
65
|
+
|
|
66
|
+
`device.capabilities` says what the protocol can do (`canRead`, `canWrite`, `readsPreamp`,
|
|
67
|
+
`readsSlot`, `writesPreamp`, `writesSlot`, `needsBandCount`, the filter `types` it has wire codes for, the
|
|
68
|
+
`wire` grid it can carry, preset `slots`, `disconnectOnSave`, `experimental`). A push with a
|
|
69
|
+
`preamp` or `slot` the protocol can't write is refused, not sent without it, and so is a pull of
|
|
70
|
+
a `slot` the protocol can't read. Each handler's `codec`
|
|
71
|
+
turns a push request into frames and back without a device, for checking what a value becomes on
|
|
72
|
+
the wire. `analyzeCodec(protocol)` works out offline what a protocol's writes can carry: the band
|
|
73
|
+
counts one write takes, the filter types with wire codes, and each field's wire range and
|
|
74
|
+
resolution as an eqcaps domain. That is `handler-code` knowledge (SPEC §10): what a device can be
|
|
75
|
+
sent, not what it accepts. `handlerCodeUrl(handler, commit)` is the source `ref` for it.
|
|
76
|
+
|
|
77
|
+
## Handlers and their options
|
|
78
|
+
|
|
79
|
+
A profile's `protocol` (eqcaps SPEC §9) names one of these handlers, with the options its device
|
|
80
|
+
needs. Byte options may be written as hex strings (`"0x21"`). `protocolProblem(protocol)` says
|
|
81
|
+
why a block can't be driven: an unknown handler (data newer than this bridge) or option.
|
|
82
|
+
|
|
83
|
+
| Handler | Transports | Options |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `fiio-usb-hid` | HID | `reportId` (default 7), `saveCommand` (default `0x19`; `0x21` on newer models) |
|
|
86
|
+
| `walkplay-hid` | HID | `defaultSlot` (slot of a write that names none, default 101) |
|
|
87
|
+
| `moondrop-usb-hid` | HID | – |
|
|
88
|
+
| `moondrop-old-fashioned-hid` | HID | – |
|
|
89
|
+
| `conexant-usb-hid` | HID | – |
|
|
90
|
+
| `ktmicro-usb-hid` | HID | `baseRegister` (default `0x26`), `bandRegisters` (`[{ "freq", "q" }]` per band, for models that skip or reorder registers), `customSlot` (default 3) |
|
|
91
|
+
| `fosi-audio-usb-hid` | HID | `reportId` (default 1), `bandwidth` (default 0), `defaultSlot` (default 7) |
|
|
92
|
+
| `qudelix-usb-hid` | HID | – (the report comes from the descriptor) |
|
|
93
|
+
| `jds-labs-usb-serial` | serial | – |
|
|
94
|
+
| `nothing-usb-serial` | serial | `customSlot` (default 5) |
|
|
95
|
+
| `fiio-usb-serial` | serial | `saveCommand` (default `0x19`) |
|
|
96
|
+
| `fiio-f110` | serial, BLE | – |
|
|
97
|
+
| `tanchjim-rita-serial` | serial | – |
|
|
98
|
+
| `moondrop-edge-serial` | serial | – |
|
|
99
|
+
| `edifier-serial` | serial | – |
|
|
100
|
+
| `airoha` | serial, BLE | – |
|
|
101
|
+
|
|
102
|
+
The rest of the block is the same for every handler: `presets` (`[{ "id", "name" }]`, the
|
|
103
|
+
device's EQ memories), `disconnectOnSave`, `baudRate` (serial; default 115200 over USB, 9600 over
|
|
104
|
+
Bluetooth) and `experimental`. A preset marked `"bypass": true` is the one that turns the EQ off:
|
|
105
|
+
`setEnabled(false)` selects it, and reading it back reports no current slot. Only `fiio-usb-hid`
|
|
106
|
+
and `ktmicro-usb-hid` turn the EQ off with a preset (KT Micro's default is slot 2); the others
|
|
107
|
+
refuse a `bypass` preset. A new option goes in `src/protocols.ts` (`OPTIONS`) and this table.
|
|
108
|
+
|
|
109
|
+
Errors are `BridgeError`s with a `code`: `unsupported-type`, `unrepresentable`, `unsupported`,
|
|
110
|
+
`timeout`, `bad-response`, `rejected`, `transport` or `invalid-request`.
|
|
111
|
+
|
|
112
|
+
License: MIT; see `NOTICE.md` for the projects it is ported from.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Domain, FilterType } from '@potatosalad775/eqcaps-core';
|
|
2
|
+
import type { WireGrid } from './handler.ts';
|
|
3
|
+
import type { Protocol } from './protocols.ts';
|
|
4
|
+
/** The most bands the analysis tries to encode. */
|
|
5
|
+
export declare const MAX_ANALYSED_BANDS = 128;
|
|
6
|
+
export interface CodecAnalysis {
|
|
7
|
+
handler: Protocol['handler'];
|
|
8
|
+
/**
|
|
9
|
+
* Band counts one write can carry, every count from `min` to `max`. `max` is
|
|
10
|
+
* `MAX_ANALYSED_BANDS` when the codec takes more.
|
|
11
|
+
*/
|
|
12
|
+
bands: {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
};
|
|
16
|
+
/** Filter types with wire codes, in the codec's order. */
|
|
17
|
+
types: readonly FilterType[];
|
|
18
|
+
/**
|
|
19
|
+
* Each field as a domain over its wire grid, or null where the field is a float with no limit
|
|
20
|
+
* of its own (the wire says nothing). `q` is null too when the write carries no Q, and
|
|
21
|
+
* `preamp` when it carries no preamp.
|
|
22
|
+
*/
|
|
23
|
+
freq: Domain | null;
|
|
24
|
+
q: Domain | null;
|
|
25
|
+
gain: Domain | null;
|
|
26
|
+
preamp: Domain | null;
|
|
27
|
+
/** The raw grid, for display. */
|
|
28
|
+
wire: WireGrid;
|
|
29
|
+
}
|
|
30
|
+
/** What `protocol`'s codec can write, worked out offline. */
|
|
31
|
+
export declare function analyzeCodec(protocol: Protocol): CodecAnalysis;
|
|
32
|
+
/** Where a handler's code lives in this repository, at `commit`. */
|
|
33
|
+
export declare function handlerCodeUrl(handler: Protocol['handler'], commit: string): string;
|
|
34
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAU,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,0DAA0D;IAC1D,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B;;;;OAIG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iCAAiC;IACjC,IAAI,EAAE,QAAQ,CAAC;CACf;AAiED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAc9D;AAED,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnF"}
|
package/dist/analysis.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Offline codec analysis (INSPECTOR §4): what a protocol's write frames can carry,
|
|
2
|
+
// learnt from its codec alone, with no device. It gives the band counts a write can hold, the
|
|
3
|
+
// filter types with wire codes, and each field's wire range and resolution as an eqcaps domain:
|
|
4
|
+
// the `handler-code` knowledge of a device (SPEC §10). Wire limits bound what a device can be
|
|
5
|
+
// sent; they say nothing about what its firmware accepts, which only the vendor shows.
|
|
6
|
+
import { isBridgeError } from "./errors.js";
|
|
7
|
+
import { HANDLERS } from "./handlers/index.js";
|
|
8
|
+
/** The most bands the analysis tries to encode. */
|
|
9
|
+
export const MAX_ANALYSED_BANDS = 128;
|
|
10
|
+
/** A flat band every codec can carry: its first type, at 1 kHz or its first listed frequency. */
|
|
11
|
+
function plainBand(protocol) {
|
|
12
|
+
const codec = HANDLERS[protocol.handler].codec;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- options of this handler
|
|
14
|
+
const wire = codec.wire((protocol.options ?? {}));
|
|
15
|
+
const freq = 'values' in wire.freq ? wire.freq.values[0] : 1000;
|
|
16
|
+
return {
|
|
17
|
+
type: codec.types.includes('PK') ? 'PK' : codec.types[0],
|
|
18
|
+
freq,
|
|
19
|
+
q: 1,
|
|
20
|
+
gain: 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Whether the codec encodes `count` bands; false when it refuses the count itself. */
|
|
24
|
+
function encodes(protocol, count) {
|
|
25
|
+
const codec = HANDLERS[protocol.handler].codec;
|
|
26
|
+
const band = plainBand(protocol);
|
|
27
|
+
try {
|
|
28
|
+
codec.encode({ filters: Array.from({ length: count }, () => ({ ...band })) },
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- options of this handler
|
|
30
|
+
(protocol.options ?? {}));
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (isBridgeError(error))
|
|
35
|
+
return false;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Band counts a write can carry: the codecs take one contiguous run of counts. */
|
|
40
|
+
function bandRange(protocol) {
|
|
41
|
+
let min = 0;
|
|
42
|
+
for (let n = 1; n <= MAX_ANALYSED_BANDS; n++) {
|
|
43
|
+
if (encodes(protocol, n)) {
|
|
44
|
+
min = n;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (min === 0)
|
|
49
|
+
return { min: 0, max: 0 };
|
|
50
|
+
let max = min;
|
|
51
|
+
while (max < MAX_ANALYSED_BANDS && encodes(protocol, max + 1))
|
|
52
|
+
max++;
|
|
53
|
+
return { min, max };
|
|
54
|
+
}
|
|
55
|
+
/** Wire values a decoder reads as "unset" are already left out of the grid (D33). */
|
|
56
|
+
function fieldDomain(w, positive) {
|
|
57
|
+
if ('values' in w)
|
|
58
|
+
return { values: [...w.values] };
|
|
59
|
+
if (w.step === undefined)
|
|
60
|
+
return null;
|
|
61
|
+
const step = w.step;
|
|
62
|
+
// Grids are anchored at 0 (SPEC §4); freq and q must stay above it.
|
|
63
|
+
const tidy = (x) => Number((Math.round(x / step) * step).toPrecision(12));
|
|
64
|
+
let min = tidy(w.min);
|
|
65
|
+
const max = tidy(w.max);
|
|
66
|
+
if (positive && min <= 0)
|
|
67
|
+
min = tidy(step);
|
|
68
|
+
if (min > max)
|
|
69
|
+
return null;
|
|
70
|
+
return { min, max, step };
|
|
71
|
+
}
|
|
72
|
+
/** What `protocol`'s codec can write, worked out offline. */
|
|
73
|
+
export function analyzeCodec(protocol) {
|
|
74
|
+
const handler = HANDLERS[protocol.handler];
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- options of this handler
|
|
76
|
+
const wire = handler.codec.wire((protocol.options ?? {}));
|
|
77
|
+
return {
|
|
78
|
+
handler: protocol.handler,
|
|
79
|
+
bands: bandRange(protocol),
|
|
80
|
+
types: handler.codec.types,
|
|
81
|
+
freq: fieldDomain(wire.freq, true),
|
|
82
|
+
q: wire.q ? fieldDomain(wire.q, true) : null,
|
|
83
|
+
gain: fieldDomain(wire.gain, false),
|
|
84
|
+
preamp: wire.preamp ? fieldDomain(wire.preamp, false) : null,
|
|
85
|
+
wire
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** Where a handler's code lives in this repository, at `commit`. */
|
|
89
|
+
export function handlerCodeUrl(handler, commit) {
|
|
90
|
+
return `https://github.com/potatosalad775/eqcaps/blob/${commit}/packages/device-bridge/src/handlers/${handler}.ts`;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.js","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,8FAA8F;AAC9F,gGAAgG;AAChG,8FAA8F;AAC9F,uFAAuF;AAGvF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,mDAAmD;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAwBtC,iGAAiG;AACjG,SAAS,SAAS,CAAC,QAAkB;IACpC,MA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ps-core';
|
|
2
|
+
/**
|
|
3
|
+
* [b0, b1, b2, −a1, −a2] normalized by a0 and scaled by 2^30: low and high shelves, and peaking
|
|
4
|
+
* for every other type (these protocols have no other coefficient form).
|
|
5
|
+
*/
|
|
6
|
+
export declare function biquadQ30(type: FilterType, freq: number, gain: number, q: number, sampleRate: number): [number, number, number, number, number];
|
|
7
|
+
/** Five coefficients as 20 little-endian int32 bytes. */
|
|
8
|
+
export declare function coefficientBytes(coeffs: readonly number[]): number[];
|
|
9
|
+
//# sourceMappingURL=biquad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biquad.d.ts","sourceRoot":"","sources":["../src/biquad.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D;;;GAGG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAmC1C;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAEpE"}
|
package/dist/biquad.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// RBJ-cookbook biquads quantized to Q2.30, as Walkplay, Moondrop and Conexant firmware take them
|
|
2
|
+
// alongside the band's own parameters.
|
|
3
|
+
const Q30 = 1073741824;
|
|
4
|
+
/**
|
|
5
|
+
* [b0, b1, b2, −a1, −a2] normalized by a0 and scaled by 2^30: low and high shelves, and peaking
|
|
6
|
+
* for every other type (these protocols have no other coefficient form).
|
|
7
|
+
*/
|
|
8
|
+
export function biquadQ30(type, freq, gain, q, sampleRate) {
|
|
9
|
+
const A = Math.pow(10, gain / 40);
|
|
10
|
+
const w0 = (2 * Math.PI * freq) / sampleRate;
|
|
11
|
+
const sin = Math.sin(w0);
|
|
12
|
+
const cos = Math.cos(w0);
|
|
13
|
+
let b0, b1, b2, a0, a1, a2;
|
|
14
|
+
if (type === 'LSC' || type === 'HSC') {
|
|
15
|
+
const alpha = (sin / 2) * Math.sqrt((A + 1 / A) * (1 / q - 1) + 2);
|
|
16
|
+
const s = 2 * Math.sqrt(A) * alpha;
|
|
17
|
+
if (type === 'LSC') {
|
|
18
|
+
b0 = A * (A + 1 - (A - 1) * cos + s);
|
|
19
|
+
b1 = 2 * A * (A - 1 - (A + 1) * cos);
|
|
20
|
+
b2 = A * (A + 1 - (A - 1) * cos - s);
|
|
21
|
+
a0 = A + 1 + (A - 1) * cos + s;
|
|
22
|
+
a1 = -2 * (A - 1 + (A + 1) * cos);
|
|
23
|
+
a2 = A + 1 + (A - 1) * cos - s;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
b0 = A * (A + 1 + (A - 1) * cos + s);
|
|
27
|
+
b1 = -2 * A * (A - 1 + (A + 1) * cos);
|
|
28
|
+
b2 = A * (A + 1 + (A - 1) * cos - s);
|
|
29
|
+
a0 = A + 1 - (A - 1) * cos + s;
|
|
30
|
+
a1 = 2 * (A - 1 - (A + 1) * cos);
|
|
31
|
+
a2 = A + 1 - (A - 1) * cos - s;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const alpha = sin / (2 * q);
|
|
36
|
+
b0 = 1 + alpha * A;
|
|
37
|
+
b1 = -2 * cos;
|
|
38
|
+
b2 = 1 - alpha * A;
|
|
39
|
+
a0 = 1 + alpha / A;
|
|
40
|
+
a1 = -2 * cos;
|
|
41
|
+
a2 = 1 - alpha / A;
|
|
42
|
+
}
|
|
43
|
+
const r = (c) => Math.round(c * Q30);
|
|
44
|
+
return [r(b0 / a0), r(b1 / a0), r(b2 / a0), r(-a1 / a0), r(-a2 / a0)];
|
|
45
|
+
}
|
|
46
|
+
/** Five coefficients as 20 little-endian int32 bytes. */
|
|
47
|
+
export function coefficientBytes(coeffs) {
|
|
48
|
+
return coeffs.flatMap((v) => [v & 0xff, (v >> 8) & 0xff, (v >> 16) & 0xff, (v >> 24) & 0xff]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=biquad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biquad.js","sourceRoot":"","sources":["../src/biquad.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,uCAAuC;AAIvC,MAAM,GAAG,GAAG,UAAU,CAAC;AAEvB;;;GAGG;AACH,MAAM,UAAU,SAAS,CACxB,IAAgB,EAChB,IAAY,EACZ,IAAY,EACZ,CAAS,EACT,UAAkB;IAElB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACzB,IAAI,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,CAAC;IAC3E,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QACnC,IAA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,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { grantedHidDevice, hidCollections, hidTransport, requestHidDevice } from './webhid.ts';
|
|
2
|
+
export type { RequestHidOptions } from './webhid.ts';
|
|
3
|
+
export { baudRateFor, requestSerialPort, serialTransport } from './webserial.ts';
|
|
4
|
+
export type { RequestSerialOptions, SerialPortChoice } from './webserial.ts';
|
|
5
|
+
export { bleTransport, requestBleDevice } from './webbluetooth.ts';
|
|
6
|
+
export type { BleChoice, RequestBleOptions } from './webbluetooth.ts';
|
|
7
|
+
export type { BluetoothDeviceLike, BluetoothLike, HidDeviceLike, HidLike, SerialLike, SerialPortLike } from './web-apis.ts';
|
|
8
|
+
/** Which device APIs this browser offers. */
|
|
9
|
+
export declare function deviceApis(): {
|
|
10
|
+
hid: boolean;
|
|
11
|
+
serial: boolean;
|
|
12
|
+
bluetooth: boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/F,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjF,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtE,YAAY,EACX,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,eAAe,CAAC;AAIvB,6CAA6C;AAC7C,wBAAgB,UAAU,IAAI;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAGlF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Browser transports for @potatosalad775/eqcaps-device-bridge: WebHID, Web Serial and Web
|
|
2
|
+
// Bluetooth. Device APIs need Chromium over HTTPS; check `deviceApis()` before offering them.
|
|
3
|
+
export { grantedHidDevice, hidCollections, hidTransport, requestHidDevice } from "./webhid.js";
|
|
4
|
+
export { baudRateFor, requestSerialPort, serialTransport } from "./webserial.js";
|
|
5
|
+
export { bleTransport, requestBleDevice } from "./webbluetooth.js";
|
|
6
|
+
import { browserApis } from "./web-apis.js";
|
|
7
|
+
/** Which device APIs this browser offers. */
|
|
8
|
+
export function deviceApis() {
|
|
9
|
+
const apis = browserApis();
|
|
10
|
+
return { hid: !!apis.hid, serial: !!apis.serial, bluetooth: !!apis.bluetooth };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,8FAA8F;AAE9F,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAWnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,6CAA6C;AAC7C,MAAM,UAAU,UAAU;IACzB,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffers received chunks for `StreamTransport.read`, so bytes that arrive between two reads
|
|
3
|
+
* are kept rather than lost.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ChunkQueue {
|
|
6
|
+
private readonly chunks;
|
|
7
|
+
private readonly waiters;
|
|
8
|
+
private failure;
|
|
9
|
+
push(chunk: Uint8Array): void;
|
|
10
|
+
/** Ends the stream: pending and later reads reject with a transport error. */
|
|
11
|
+
fail(cause: unknown): void;
|
|
12
|
+
read(timeoutMs: number): Promise<Uint8Array | null>;
|
|
13
|
+
private closed;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/browser/stream.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;IACtE,OAAO,CAAC,OAAO,CAAU;IAEzB,IAAI,CAAC,KAAK,EAAE,UAAU;IAMtB,8EAA8E;IAC9E,IAAI,CAAC,KAAK,EAAE,OAAO;IAKnB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmBnD,OAAO,CAAC,MAAM;CAGd"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BridgeError } from "../errors.js";
|
|
2
|
+
import { after } from "../platform.js";
|
|
3
|
+
/**
|
|
4
|
+
* Buffers received chunks for `StreamTransport.read`, so bytes that arrive between two reads
|
|
5
|
+
* are kept rather than lost.
|
|
6
|
+
*/
|
|
7
|
+
export class ChunkQueue {
|
|
8
|
+
chunks = [];
|
|
9
|
+
waiters = [];
|
|
10
|
+
failure;
|
|
11
|
+
push(chunk) {
|
|
12
|
+
const waiter = this.waiters.shift();
|
|
13
|
+
if (waiter)
|
|
14
|
+
waiter(chunk);
|
|
15
|
+
else
|
|
16
|
+
this.chunks.push(chunk);
|
|
17
|
+
}
|
|
18
|
+
/** Ends the stream: pending and later reads reject with a transport error. */
|
|
19
|
+
fail(cause) {
|
|
20
|
+
this.failure = cause ?? new Error('closed');
|
|
21
|
+
for (const w of this.waiters.splice(0))
|
|
22
|
+
w(null);
|
|
23
|
+
}
|
|
24
|
+
read(timeoutMs) {
|
|
25
|
+
const chunk = this.chunks.shift();
|
|
26
|
+
if (chunk)
|
|
27
|
+
return Promise.resolve(chunk);
|
|
28
|
+
if (this.failure !== undefined)
|
|
29
|
+
return Promise.reject(this.closed());
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const waiter = (c) => {
|
|
32
|
+
cancel();
|
|
33
|
+
if (c)
|
|
34
|
+
resolve(c);
|
|
35
|
+
else
|
|
36
|
+
reject(this.closed());
|
|
37
|
+
};
|
|
38
|
+
const cancel = after(timeoutMs, () => {
|
|
39
|
+
const i = this.waiters.indexOf(waiter);
|
|
40
|
+
if (i >= 0)
|
|
41
|
+
this.waiters.splice(i, 1);
|
|
42
|
+
resolve(null);
|
|
43
|
+
});
|
|
44
|
+
this.waiters.push(waiter);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
closed() {
|
|
48
|
+
return new BridgeError('transport', 'The device stream is closed', { cause: this.failure });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/brow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,CAAC;YAC5B,CAAC,CAAC;YACF,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE;gBACpC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACvC,IAAI,CAAC,IAAI,CAAC;oBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtC,OAAO,CAAC,IAAI,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,MAAM;QACb,OAAO,IAAI,WAAW,CAAC,WAAW,EAAE,6BAA6B,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7F,CAAC;CACD"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export interface HidReportItemLike {
|
|
2
|
+
reportSize?: number;
|
|
3
|
+
reportCount?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface HidReportInfoLike {
|
|
6
|
+
reportId?: number;
|
|
7
|
+
items?: readonly HidReportItemLike[];
|
|
8
|
+
}
|
|
9
|
+
export interface HidCollectionInfoLike {
|
|
10
|
+
usagePage?: number;
|
|
11
|
+
usage?: number;
|
|
12
|
+
inputReports?: readonly HidReportInfoLike[];
|
|
13
|
+
outputReports?: readonly HidReportInfoLike[];
|
|
14
|
+
featureReports?: readonly HidReportInfoLike[];
|
|
15
|
+
children?: readonly HidCollectionInfoLike[];
|
|
16
|
+
}
|
|
17
|
+
export interface HidInputReportEventLike {
|
|
18
|
+
reportId: number;
|
|
19
|
+
data: DataViewLike;
|
|
20
|
+
}
|
|
21
|
+
export interface DataViewLike {
|
|
22
|
+
readonly buffer: ArrayBufferLike;
|
|
23
|
+
readonly byteOffset: number;
|
|
24
|
+
readonly byteLength: number;
|
|
25
|
+
}
|
|
26
|
+
export interface HidDeviceLike {
|
|
27
|
+
readonly opened: boolean;
|
|
28
|
+
readonly vendorId: number;
|
|
29
|
+
readonly productId: number;
|
|
30
|
+
readonly productName: string;
|
|
31
|
+
readonly collections: readonly HidCollectionInfoLike[];
|
|
32
|
+
open(): Promise<void>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
sendReport(reportId: number, data: Uint8Array): Promise<void>;
|
|
35
|
+
sendFeatureReport(reportId: number, data: Uint8Array): Promise<void>;
|
|
36
|
+
receiveFeatureReport(reportId: number): Promise<DataViewLike>;
|
|
37
|
+
addEventListener(type: 'inputreport', listener: (event: HidInputReportEventLike) => void): void;
|
|
38
|
+
removeEventListener(type: 'inputreport', listener: (event: HidInputReportEventLike) => void): void;
|
|
39
|
+
}
|
|
40
|
+
export interface HidLike {
|
|
41
|
+
requestDevice(options: {
|
|
42
|
+
filters: {
|
|
43
|
+
vendorId?: number;
|
|
44
|
+
productId?: number;
|
|
45
|
+
usagePage?: number;
|
|
46
|
+
}[];
|
|
47
|
+
}): Promise<HidDeviceLike[]>;
|
|
48
|
+
getDevices(): Promise<HidDeviceLike[]>;
|
|
49
|
+
}
|
|
50
|
+
export interface ReadableStreamReaderLike {
|
|
51
|
+
read(): Promise<{
|
|
52
|
+
value?: Uint8Array;
|
|
53
|
+
done: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
cancel(): Promise<void>;
|
|
56
|
+
releaseLock(): void;
|
|
57
|
+
}
|
|
58
|
+
export interface WritableStreamWriterLike {
|
|
59
|
+
write(data: Uint8Array): Promise<void>;
|
|
60
|
+
releaseLock(): void;
|
|
61
|
+
}
|
|
62
|
+
export interface SerialPortLike {
|
|
63
|
+
getInfo(): {
|
|
64
|
+
usbVendorId?: number;
|
|
65
|
+
usbProductId?: number;
|
|
66
|
+
bluetoothServiceClassId?: string;
|
|
67
|
+
};
|
|
68
|
+
open(options: {
|
|
69
|
+
baudRate: number;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
readonly readable: {
|
|
73
|
+
getReader(): ReadableStreamReaderLike;
|
|
74
|
+
} | null;
|
|
75
|
+
readonly writable: {
|
|
76
|
+
getWriter(): WritableStreamWriterLike;
|
|
77
|
+
} | null;
|
|
78
|
+
}
|
|
79
|
+
export interface SerialLike {
|
|
80
|
+
requestPort(options?: {
|
|
81
|
+
filters?: {
|
|
82
|
+
usbVendorId?: number;
|
|
83
|
+
bluetoothServiceClassId?: string;
|
|
84
|
+
}[];
|
|
85
|
+
allowedBluetoothServiceClassIds?: string[];
|
|
86
|
+
}): Promise<SerialPortLike>;
|
|
87
|
+
}
|
|
88
|
+
export interface GattCharacteristicLike {
|
|
89
|
+
readonly properties: {
|
|
90
|
+
write?: boolean;
|
|
91
|
+
writeWithoutResponse?: boolean;
|
|
92
|
+
};
|
|
93
|
+
readonly value?: DataViewLike | null;
|
|
94
|
+
writeValueWithResponse(data: Uint8Array): Promise<void>;
|
|
95
|
+
writeValueWithoutResponse(data: Uint8Array): Promise<void>;
|
|
96
|
+
startNotifications(): Promise<unknown>;
|
|
97
|
+
stopNotifications?(): Promise<unknown>;
|
|
98
|
+
addEventListener(type: 'characteristicvaluechanged', listener: (event: {
|
|
99
|
+
target: unknown;
|
|
100
|
+
}) => void): void;
|
|
101
|
+
}
|
|
102
|
+
export interface BluetoothDeviceLike {
|
|
103
|
+
readonly name?: string;
|
|
104
|
+
readonly gatt?: {
|
|
105
|
+
readonly connected: boolean;
|
|
106
|
+
connect(): Promise<{
|
|
107
|
+
getPrimaryService(uuid: string): Promise<{
|
|
108
|
+
getCharacteristic(uuid: string): Promise<GattCharacteristicLike>;
|
|
109
|
+
}>;
|
|
110
|
+
}>;
|
|
111
|
+
disconnect(): void;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface BluetoothLike {
|
|
115
|
+
requestDevice(options: {
|
|
116
|
+
filters?: {
|
|
117
|
+
name?: string;
|
|
118
|
+
namePrefix?: string;
|
|
119
|
+
services?: string[];
|
|
120
|
+
}[];
|
|
121
|
+
acceptAllDevices?: boolean;
|
|
122
|
+
optionalServices?: string[];
|
|
123
|
+
}): Promise<BluetoothDeviceLike>;
|
|
124
|
+
}
|
|
125
|
+
interface Navigator {
|
|
126
|
+
hid?: HidLike;
|
|
127
|
+
serial?: SerialLike;
|
|
128
|
+
bluetooth?: BluetoothLike;
|
|
129
|
+
}
|
|
130
|
+
/** The browser's device APIs, where present. */
|
|
131
|
+
export declare function browserApis(): Navigator;
|
|
132
|
+
export declare const bytesOf: (view: DataViewLike) => Uint8Array<ArrayBuffer>;
|
|
133
|
+
/** A browser's chooser was dismissed: WebHID returns no device, the others throw NotFoundError. */
|
|
134
|
+
export declare const isCancel: (error: unknown) => boolean;
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=web-apis.d.ts.map
|