@microbit/microbit-connection 0.0.0-alpha.33 → 0.0.0-alpha.35
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.md +21 -0
- package/README.md +8 -8
- package/build/cjs/bluetooth.d.ts +81 -33
- package/build/cjs/bluetooth.js +8 -4
- package/build/cjs/bluetooth.js.map +1 -1
- package/build/cjs/device.d.ts +6 -33
- package/build/cjs/device.js +2 -68
- package/build/cjs/device.js.map +1 -1
- package/build/cjs/events.d.ts +1 -2
- package/build/cjs/index.d.ts +7 -6
- package/build/cjs/index.js +10 -8
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/serial-events.d.ts +20 -0
- package/build/cjs/serial-events.js +69 -0
- package/build/cjs/serial-events.js.map +1 -0
- package/build/cjs/usb-radio-bridge.d.ts +11 -28
- package/build/cjs/usb-radio-bridge.js +7 -3
- package/build/cjs/usb-radio-bridge.js.map +1 -1
- package/build/cjs/usb.d.ts +27 -45
- package/build/cjs/usb.js +12 -7
- package/build/cjs/usb.js.map +1 -1
- package/build/esm/bluetooth.d.ts +81 -33
- package/build/esm/bluetooth.js +6 -2
- package/build/esm/bluetooth.js.map +1 -1
- package/build/esm/device.d.ts +6 -33
- package/build/esm/device.js +1 -63
- package/build/esm/device.js.map +1 -1
- package/build/esm/events.d.ts +1 -2
- package/build/esm/index.d.ts +7 -6
- package/build/esm/index.js +6 -5
- package/build/esm/index.js.map +1 -1
- package/build/esm/serial-events.d.ts +20 -0
- package/build/esm/serial-events.js +61 -0
- package/build/esm/serial-events.js.map +1 -0
- package/build/esm/usb-radio-bridge.d.ts +11 -28
- package/build/esm/usb-radio-bridge.js +5 -1
- package/build/esm/usb-radio-bridge.js.map +1 -1
- package/build/esm/usb.d.ts +27 -45
- package/build/esm/usb.js +7 -2
- package/build/esm/usb.js.map +1 -1
- package/package.json +1 -1
- package/typedoc.json +2 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Micro:bit Educational Foundation and contributors
|
|
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# micro:bit connection library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<a href="https://microbit-foundation.github.io/microbit-connection/" class="typedoc-ignore">This documentation is best viewed on the documentation site rather than GitHub or NPM package site.</a>
|
|
4
4
|
|
|
5
5
|
This is a JavaScript library for micro:bit connections in browsers via USB and Bluetooth.
|
|
6
6
|
|
|
@@ -18,12 +18,12 @@ This project is a work in progress. We are extracting WebUSB and Web Bluetooth c
|
|
|
18
18
|
|
|
19
19
|
### Flash a micro:bit
|
|
20
20
|
|
|
21
|
-
Instantiate a WebUSB connection using {@link
|
|
21
|
+
Instantiate a WebUSB connection using {@link createWebUSBConnection} class and use it to connect to a micro:bit.
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
|
-
import {
|
|
24
|
+
import { createWebUSBConnection } from "@microbit/microbit-connection";
|
|
25
25
|
|
|
26
|
-
const usb =
|
|
26
|
+
const usb = createWebUSBConnection();
|
|
27
27
|
const connectionStatus = await usb.connect();
|
|
28
28
|
|
|
29
29
|
console.log("Connection status: ", connectionStatus);
|
|
@@ -80,12 +80,12 @@ For more examples of using other methods in the {@link MicrobitWebUSBConnection}
|
|
|
80
80
|
|
|
81
81
|
By default, the micro:bit's Bluetooth service is not enabled. Visit our [Bluetooth tech site page](https://tech.microbit.org/bluetooth/) to download a hex file that would enable the bluetooth service.
|
|
82
82
|
|
|
83
|
-
Instantiate a Bluetooth connection using {@link
|
|
83
|
+
Instantiate a Bluetooth connection using {@link createWebBluetoothConnection} class and use it to connect to a micro:bit.
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
import {
|
|
86
|
+
import { createWebBluetoothConnection } from "@microbit/microbit-connection";
|
|
87
87
|
|
|
88
|
-
const bluetooth =
|
|
88
|
+
const bluetooth = createWebBluetoothConnection();
|
|
89
89
|
const connectionStatus = await bluetooth.connect();
|
|
90
90
|
|
|
91
91
|
console.log("Connection status: ", connectionStatus);
|
|
@@ -93,7 +93,7 @@ console.log("Connection status: ", connectionStatus);
|
|
|
93
93
|
|
|
94
94
|
{@link ConnectionStatus | Connection status} is `"CONNECTED"` if connection succeeds.
|
|
95
95
|
|
|
96
|
-
For more examples of using other methods in the {@link
|
|
96
|
+
For more examples of using other methods in the {@link createWebBluetoothConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).
|
|
97
97
|
|
|
98
98
|
## License
|
|
99
99
|
|
package/build/cjs/bluetooth.d.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
6
|
import { AccelerometerData } from "./accelerometer.js";
|
|
7
|
-
import {
|
|
8
|
-
import { TypedEventTarget } from "./events.js";
|
|
7
|
+
import { DeviceConnection } from "./device.js";
|
|
9
8
|
import { LedMatrix } from "./led.js";
|
|
10
9
|
import { Logging } from "./logging.js";
|
|
11
10
|
import { MagnetometerData } from "./magnetometer.js";
|
|
@@ -13,48 +12,97 @@ import { ServiceConnectionEventMap } from "./service-events.js";
|
|
|
13
12
|
export interface MicrobitWebBluetoothConnectionOptions {
|
|
14
13
|
logging?: Logging;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* The USB device we last connected to.
|
|
23
|
-
* Cleared if it is disconnected.
|
|
24
|
-
*/
|
|
25
|
-
private device;
|
|
26
|
-
private logging;
|
|
27
|
-
private connection;
|
|
28
|
-
private availabilityListener;
|
|
29
|
-
private availability;
|
|
30
|
-
private nameFilter;
|
|
31
|
-
constructor(options?: MicrobitWebBluetoothConnectionOptions);
|
|
32
|
-
protected eventActivated(type: string): void;
|
|
33
|
-
protected eventDeactivated(type: string): void;
|
|
34
|
-
private log;
|
|
35
|
-
initialize(): Promise<void>;
|
|
36
|
-
dispose(): void;
|
|
37
|
-
connect(): Promise<ConnectionStatus>;
|
|
38
|
-
getBoardVersion(): BoardVersion | undefined;
|
|
39
|
-
disconnect(): Promise<void>;
|
|
40
|
-
private setStatus;
|
|
41
|
-
serialWrite(data: string): Promise<void>;
|
|
42
|
-
clearDevice(): Promise<void>;
|
|
43
|
-
private connectInternal;
|
|
15
|
+
export interface MicrobitWebBluetoothConnection extends DeviceConnection<ServiceConnectionEventMap> {
|
|
16
|
+
/**
|
|
17
|
+
* Sets micro:bit name filter for device requesting.
|
|
18
|
+
*
|
|
19
|
+
* @param name The name of the micro:bit.
|
|
20
|
+
*/
|
|
44
21
|
setNameFilter(name: string): void;
|
|
45
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Gets micro:bit accelerometer data.
|
|
24
|
+
*
|
|
25
|
+
* @returns accelerometer data or undefined if there is no connection.
|
|
26
|
+
*/
|
|
46
27
|
getAccelerometerData(): Promise<AccelerometerData | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets micro:bit accelerometer period.
|
|
30
|
+
*
|
|
31
|
+
* @returns accelerometer period or undefined if there is no connection.
|
|
32
|
+
*/
|
|
47
33
|
getAccelerometerPeriod(): Promise<number | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Sets micro:bit accelerometer period.
|
|
36
|
+
*
|
|
37
|
+
* @param value The accelerometer period.
|
|
38
|
+
*/
|
|
48
39
|
setAccelerometerPeriod(value: number): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Sets micro:bit LED text.
|
|
42
|
+
*
|
|
43
|
+
* @param text The text displayed on micro:bit LED.
|
|
44
|
+
*/
|
|
49
45
|
setLedText(text: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets micro:bit LED scrolling delay.
|
|
48
|
+
*
|
|
49
|
+
* @returns LED scrolling delay in milliseconds.
|
|
50
|
+
*/
|
|
50
51
|
getLedScrollingDelay(): Promise<number | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Sets micro:bit LED scrolling delay.
|
|
54
|
+
*
|
|
55
|
+
* @param delayInMillis LED scrolling delay in milliseconds.
|
|
56
|
+
*/
|
|
51
57
|
setLedScrollingDelay(delayInMillis: number): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets micro:bit LED matrix.
|
|
60
|
+
*
|
|
61
|
+
* @returns a boolean matrix representing the micro:bit LED display.
|
|
62
|
+
*/
|
|
52
63
|
getLedMatrix(): Promise<LedMatrix | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Sets micro:bit LED matrix.
|
|
66
|
+
*
|
|
67
|
+
* @param matrix an boolean matrix representing the micro:bit LED display.
|
|
68
|
+
*/
|
|
53
69
|
setLedMatrix(matrix: LedMatrix): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Gets micro:bit magnetometer data.
|
|
72
|
+
*
|
|
73
|
+
* @returns magnetometer data.
|
|
74
|
+
*/
|
|
54
75
|
getMagnetometerData(): Promise<MagnetometerData | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* Gets micro:bit magnetometer bearing.
|
|
78
|
+
*
|
|
79
|
+
* @returns magnetometer bearing.
|
|
80
|
+
*/
|
|
81
|
+
getMagnetometerBearing(): Promise<number | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets micro:bit magnetometer period.
|
|
84
|
+
*
|
|
85
|
+
* @returns magnetometer period.
|
|
86
|
+
*/
|
|
55
87
|
getMagnetometerPeriod(): Promise<number | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Sets micro:bit magnetometer period.
|
|
90
|
+
*
|
|
91
|
+
* @param value magnetometer period.
|
|
92
|
+
*/
|
|
56
93
|
setMagnetometerPeriod(value: number): Promise<void>;
|
|
57
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Triggers micro:bit magnetometer calibration.
|
|
96
|
+
*/
|
|
58
97
|
triggerMagnetometerCalibration(): Promise<void>;
|
|
59
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Write UART messages.
|
|
100
|
+
*
|
|
101
|
+
* @param data UART message.
|
|
102
|
+
*/
|
|
103
|
+
uartWrite(data: Uint8Array): Promise<void>;
|
|
60
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* A Bluetooth connection factory.
|
|
107
|
+
*/
|
|
108
|
+
export declare const createWebBluetoothConnection: (options?: MicrobitWebBluetoothConnectionOptions) => MicrobitWebBluetoothConnection;
|
package/build/cjs/bluetooth.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createWebBluetoothConnection = void 0;
|
|
4
4
|
const bluetooth_device_wrapper_js_1 = require("./bluetooth-device-wrapper.js");
|
|
5
5
|
const bluetooth_profile_js_1 = require("./bluetooth-profile.js");
|
|
6
6
|
const device_js_1 = require("./device.js");
|
|
7
7
|
const events_js_1 = require("./events.js");
|
|
8
8
|
const logging_js_1 = require("./logging.js");
|
|
9
9
|
const requestDeviceTimeoutDuration = 30000;
|
|
10
|
+
/**
|
|
11
|
+
* A Bluetooth connection factory.
|
|
12
|
+
*/
|
|
13
|
+
const createWebBluetoothConnection = (options) => new MicrobitWebBluetoothConnectionImpl(options);
|
|
14
|
+
exports.createWebBluetoothConnection = createWebBluetoothConnection;
|
|
10
15
|
/**
|
|
11
16
|
* A Bluetooth connection to a micro:bit device.
|
|
12
17
|
*/
|
|
13
|
-
class
|
|
18
|
+
class MicrobitWebBluetoothConnectionImpl extends events_js_1.TypedEventTarget {
|
|
14
19
|
constructor(options = {}) {
|
|
15
20
|
super();
|
|
16
21
|
Object.defineProperty(this, "status", {
|
|
@@ -259,10 +264,9 @@ class MicrobitWebBluetoothConnection extends events_js_1.TypedEventTarget {
|
|
|
259
264
|
const magnetometerService = await this.connection?.getMagnetometerService();
|
|
260
265
|
return magnetometerService?.triggerCalibration();
|
|
261
266
|
}
|
|
262
|
-
async
|
|
267
|
+
async uartWrite(data) {
|
|
263
268
|
const uartService = await this.connection?.getUARTService();
|
|
264
269
|
uartService?.writeData(data);
|
|
265
270
|
}
|
|
266
271
|
}
|
|
267
|
-
exports.MicrobitWebBluetoothConnection = MicrobitWebBluetoothConnection;
|
|
268
272
|
//# sourceMappingURL=bluetooth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluetooth.js","sourceRoot":"","sources":["../../lib/bluetooth.ts"],"names":[],"mappings":";;;AAMA,+EAGuC;AACvC,iEAAiD;AACjD,2CAQqB;AACrB,2CAA+C;AAE/C,6CAAoD;AAOpD,MAAM,4BAA4B,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,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,KAAa;QACvC,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,sBAAsB,EAAE,CAAC;QAC5E,OAAO,mBAAmB,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,sBAAsB;QAC1B,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,sBAAsB,EAAE,CAAC;QAC5E,OAAO,mBAAmB,EAAE,UAAU,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,8BAA8B;QAClC,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,sBAAsB,EAAE,CAAC;QAC5E,OAAO,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAgB;QAC9B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC;QAC5D,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
package/build/cjs/device.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { TypedEventTarget } from "./events.js";
|
|
7
|
-
import { UARTDataEvent } from "./uart.js";
|
|
6
|
+
import { TypedEventTarget, ValueIsEvent } from "./events.js";
|
|
8
7
|
/**
|
|
9
8
|
* Specific identified error types.
|
|
10
9
|
*
|
|
@@ -123,20 +122,6 @@ export declare class ConnectionStatusEvent extends Event {
|
|
|
123
122
|
readonly status: ConnectionStatus;
|
|
124
123
|
constructor(status: ConnectionStatus);
|
|
125
124
|
}
|
|
126
|
-
export declare class SerialDataEvent extends Event {
|
|
127
|
-
readonly data: string;
|
|
128
|
-
constructor(data: string);
|
|
129
|
-
}
|
|
130
|
-
export declare class SerialResetEvent extends Event {
|
|
131
|
-
constructor();
|
|
132
|
-
}
|
|
133
|
-
export declare class SerialErrorEvent extends Event {
|
|
134
|
-
readonly error: unknown;
|
|
135
|
-
constructor(error: unknown);
|
|
136
|
-
}
|
|
137
|
-
export declare class FlashEvent extends Event {
|
|
138
|
-
constructor();
|
|
139
|
-
}
|
|
140
125
|
export declare class BeforeRequestDevice extends Event {
|
|
141
126
|
constructor();
|
|
142
127
|
}
|
|
@@ -149,16 +134,11 @@ export declare class BackgroundErrorEvent extends Event {
|
|
|
149
134
|
}
|
|
150
135
|
export declare class DeviceConnectionEventMap {
|
|
151
136
|
"status": ConnectionStatusEvent;
|
|
152
|
-
"
|
|
153
|
-
"serialreset": Event;
|
|
154
|
-
"serialerror": SerialErrorEvent;
|
|
155
|
-
"uartdata": UARTDataEvent;
|
|
156
|
-
"flash": Event;
|
|
137
|
+
"backgrounderror": BackgroundErrorEvent;
|
|
157
138
|
"beforerequestdevice": Event;
|
|
158
139
|
"afterrequestdevice": Event;
|
|
159
|
-
"backgrounderror": BackgroundErrorEvent;
|
|
160
140
|
}
|
|
161
|
-
export interface DeviceConnection extends TypedEventTarget<DeviceConnectionEventMap> {
|
|
141
|
+
export interface DeviceConnection<M extends ValueIsEvent<M>> extends TypedEventTarget<DeviceConnectionEventMap & M> {
|
|
162
142
|
status: ConnectionStatus;
|
|
163
143
|
/**
|
|
164
144
|
* Initializes the device.
|
|
@@ -178,16 +158,9 @@ export interface DeviceConnection extends TypedEventTarget<DeviceConnectionEvent
|
|
|
178
158
|
/**
|
|
179
159
|
* Get the board version.
|
|
180
160
|
*
|
|
181
|
-
* @returns the board version or
|
|
161
|
+
* @returns the board version or undefined if there is no connection.
|
|
182
162
|
*/
|
|
183
163
|
getBoardVersion(): BoardVersion | undefined;
|
|
184
|
-
/**
|
|
185
|
-
* Flash the micro:bit.
|
|
186
|
-
*
|
|
187
|
-
* @param dataSource The data to use.
|
|
188
|
-
* @param options Flash options and progress callback.
|
|
189
|
-
*/
|
|
190
|
-
flash?(dataSource: FlashDataSource, options: {}): Promise<void>;
|
|
191
164
|
/**
|
|
192
165
|
* Disconnect from the device.
|
|
193
166
|
*/
|
|
@@ -195,7 +168,7 @@ export interface DeviceConnection extends TypedEventTarget<DeviceConnectionEvent
|
|
|
195
168
|
/**
|
|
196
169
|
* Write serial data to the device.
|
|
197
170
|
*
|
|
198
|
-
* Does
|
|
171
|
+
* Does nothing if there is no connection.
|
|
199
172
|
*
|
|
200
173
|
* @param data The data to write.
|
|
201
174
|
* @returns A promise that resolves when the write is complete.
|
|
@@ -204,5 +177,5 @@ export interface DeviceConnection extends TypedEventTarget<DeviceConnectionEvent
|
|
|
204
177
|
/**
|
|
205
178
|
* Clear device to enable chooseDevice.
|
|
206
179
|
*/
|
|
207
|
-
clearDevice(): void;
|
|
180
|
+
clearDevice(): Promise<void> | void;
|
|
208
181
|
}
|
package/build/cjs/device.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeviceConnectionEventMap = exports.BackgroundErrorEvent = exports.AfterRequestDevice = exports.BeforeRequestDevice = exports.
|
|
3
|
+
exports.DeviceConnectionEventMap = exports.BackgroundErrorEvent = exports.AfterRequestDevice = exports.BeforeRequestDevice = exports.ConnectionStatusEvent = exports.FlashDataError = exports.ConnectionStatus = exports.DeviceError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Error type used for all interactions with this module.
|
|
6
6
|
*
|
|
@@ -77,42 +77,6 @@ class ConnectionStatusEvent extends Event {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
exports.ConnectionStatusEvent = ConnectionStatusEvent;
|
|
80
|
-
class SerialDataEvent extends Event {
|
|
81
|
-
constructor(data) {
|
|
82
|
-
super("serialdata");
|
|
83
|
-
Object.defineProperty(this, "data", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
configurable: true,
|
|
86
|
-
writable: true,
|
|
87
|
-
value: data
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.SerialDataEvent = SerialDataEvent;
|
|
92
|
-
class SerialResetEvent extends Event {
|
|
93
|
-
constructor() {
|
|
94
|
-
super("serialreset");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.SerialResetEvent = SerialResetEvent;
|
|
98
|
-
class SerialErrorEvent extends Event {
|
|
99
|
-
constructor(error) {
|
|
100
|
-
super("serialerror");
|
|
101
|
-
Object.defineProperty(this, "error", {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value: error
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.SerialErrorEvent = SerialErrorEvent;
|
|
110
|
-
class FlashEvent extends Event {
|
|
111
|
-
constructor() {
|
|
112
|
-
super("flash");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.FlashEvent = FlashEvent;
|
|
116
80
|
class BeforeRequestDevice extends Event {
|
|
117
81
|
constructor() {
|
|
118
82
|
super("beforerequestdevice");
|
|
@@ -145,31 +109,7 @@ class DeviceConnectionEventMap {
|
|
|
145
109
|
writable: true,
|
|
146
110
|
value: void 0
|
|
147
111
|
});
|
|
148
|
-
Object.defineProperty(this, "
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true,
|
|
152
|
-
value: void 0
|
|
153
|
-
});
|
|
154
|
-
Object.defineProperty(this, "serialreset", {
|
|
155
|
-
enumerable: true,
|
|
156
|
-
configurable: true,
|
|
157
|
-
writable: true,
|
|
158
|
-
value: void 0
|
|
159
|
-
});
|
|
160
|
-
Object.defineProperty(this, "serialerror", {
|
|
161
|
-
enumerable: true,
|
|
162
|
-
configurable: true,
|
|
163
|
-
writable: true,
|
|
164
|
-
value: void 0
|
|
165
|
-
});
|
|
166
|
-
Object.defineProperty(this, "uartdata", {
|
|
167
|
-
enumerable: true,
|
|
168
|
-
configurable: true,
|
|
169
|
-
writable: true,
|
|
170
|
-
value: void 0
|
|
171
|
-
});
|
|
172
|
-
Object.defineProperty(this, "flash", {
|
|
112
|
+
Object.defineProperty(this, "backgrounderror", {
|
|
173
113
|
enumerable: true,
|
|
174
114
|
configurable: true,
|
|
175
115
|
writable: true,
|
|
@@ -187,12 +127,6 @@ class DeviceConnectionEventMap {
|
|
|
187
127
|
writable: true,
|
|
188
128
|
value: void 0
|
|
189
129
|
});
|
|
190
|
-
Object.defineProperty(this, "backgrounderror", {
|
|
191
|
-
enumerable: true,
|
|
192
|
-
configurable: true,
|
|
193
|
-
writable: true,
|
|
194
|
-
value: void 0
|
|
195
|
-
});
|
|
196
130
|
}
|
|
197
131
|
}
|
|
198
132
|
exports.DeviceConnectionEventMap = DeviceConnectionEventMap;
|
package/build/cjs/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../lib/device.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../lib/device.ts"],"names":[],"mappings":";;;AA8CA;;;;;;;;GAQG;AACH,MAAa,WAAY,SAAQ,KAAK;IAEpC,YAAY,EAAE,IAAI,EAAE,OAAO,EAA+C;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QAFjB;;;;;WAAsB;QAGpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAND,kCAMC;AAED;;GAEG;AACH,IAAY,gBAkCX;AAlCD,WAAY,gBAAgB;IAC1B;;;OAGG;IACH,2DAAuC,CAAA;IACvC;;OAEG;IACH,mDAA+B,CAAA;IAC/B;;;;;OAKG;IACH,iEAA6C,CAAA;IAC7C;;OAEG;IACH,iDAA6B,CAAA;IAC7B;;OAEG;IACH,2CAAuB,CAAA;IACvB;;OAEG;IACH,6CAAyB,CAAA;IACzB;;;OAGG;IACH,iDAA6B,CAAA;AAC/B,CAAC,EAlCW,gBAAgB,gCAAhB,gBAAgB,QAkC3B;AAqBD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C;AAQ5C,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAA4B,MAAwB;QAClD,KAAK,CAAC,QAAQ,CAAC,CAAC;QADN;;;;mBAAgB,MAAM;WAAkB;IAEpD,CAAC;CACF;AAJD,sDAIC;AAED,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC/B,CAAC;CACF;AAJD,kDAIC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAC3C;QACE,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC9B,CAAC;CACF;AAJD,gDAIC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAA4B,YAAoB;QAC9C,KAAK,CAAC,iBAAiB,CAAC,CAAC;QADf;;;;mBAAgB,YAAY;WAAQ;IAEhD,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,wBAAwB;IAArC;QACE,4BAAA,QAAQ;;;;;WAAwB;QAChC,4BAAA,iBAAiB;;;;;WAAuB;QACxC,4BAAA,qBAAqB;;;;;WAAQ;QAC7B,4BAAA,oBAAoB;;;;;WAAQ;IAC9B,CAAC;CAAA;AALD,4DAKC"}
|
package/build/cjs/events.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface TypedEventListenerObject<M, T extends keyof M> {
|
|
|
32
32
|
* @template T The type of event to listen for (has to be keyof `M`).
|
|
33
33
|
*/
|
|
34
34
|
export type TypedEventListenerOrEventListenerObject<M, T extends keyof M> = TypedEventListener<M, T> | TypedEventListenerObject<M, T>;
|
|
35
|
-
type ValueIsEvent<T> = {
|
|
35
|
+
export type ValueIsEvent<T> = {
|
|
36
36
|
[key in keyof T]: Event;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
@@ -108,4 +108,3 @@ export declare class TypedEventTarget<M extends ValueIsEvent<M>> extends Trackin
|
|
|
108
108
|
*/
|
|
109
109
|
dispatchTypedEvent<T extends keyof M>(_type: T, event: M[T]): boolean;
|
|
110
110
|
}
|
|
111
|
-
export {};
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { AccelerometerData, AccelerometerDataEvent } from "./accelerometer.js";
|
|
2
|
-
import { MicrobitWebBluetoothConnection, MicrobitWebBluetoothConnectionOptions } from "./bluetooth.js";
|
|
2
|
+
import { createWebBluetoothConnection, MicrobitWebBluetoothConnection, MicrobitWebBluetoothConnectionOptions } from "./bluetooth.js";
|
|
3
3
|
import { BoardId } from "./board-id.js";
|
|
4
4
|
import { ButtonEvent, ButtonEventType, ButtonState } from "./buttons.js";
|
|
5
|
-
import { AfterRequestDevice, BackgroundErrorEvent, BeforeRequestDevice, BoardVersion, ConnectionStatus, ConnectionStatusEvent, DeviceConnection, DeviceConnectionEventMap, DeviceError, DeviceErrorCode, FlashDataError, FlashDataSource,
|
|
5
|
+
import { AfterRequestDevice, BackgroundErrorEvent, BeforeRequestDevice, BoardVersion, ConnectionStatus, ConnectionStatusEvent, DeviceConnection, DeviceConnectionEventMap, DeviceError, DeviceErrorCode, FlashDataError, FlashDataSource, FlashOptions } from "./device.js";
|
|
6
6
|
import { TypedEventTarget } from "./events.js";
|
|
7
7
|
import { createUniversalHexFlashDataSource } from "./hex-flash-data-source.js";
|
|
8
8
|
import { LedMatrix } from "./led.js";
|
|
9
9
|
import { Logging, LoggingEvent } from "./logging.js";
|
|
10
10
|
import { MagnetometerData, MagnetometerDataEvent } from "./magnetometer.js";
|
|
11
|
+
import { FlashEvent, SerialConnectionEventMap, SerialDataEvent, SerialErrorEvent, SerialResetEvent } from "./serial-events.js";
|
|
11
12
|
import { ServiceConnectionEventMap } from "./service-events.js";
|
|
12
13
|
import { UARTDataEvent } from "./uart.js";
|
|
13
|
-
import { MicrobitRadioBridgeConnection, MicrobitRadioBridgeConnectionOptions } from "./usb-radio-bridge.js";
|
|
14
|
-
import { MicrobitWebUSBConnection, MicrobitWebUSBConnectionOptions } from "./usb.js";
|
|
15
|
-
export { AfterRequestDevice, BackgroundErrorEvent, BeforeRequestDevice, BoardId, ConnectionStatus, ConnectionStatusEvent, createUniversalHexFlashDataSource, DeviceConnectionEventMap, DeviceError, FlashDataError, FlashEvent,
|
|
16
|
-
export type { AccelerometerData, AccelerometerDataEvent, BoardVersion, ButtonEvent, ButtonEventType, ButtonState, DeviceConnection, DeviceErrorCode, FlashDataSource, FlashOptions, LedMatrix, Logging, LoggingEvent, MagnetometerData, MagnetometerDataEvent, MicrobitRadioBridgeConnectionOptions, MicrobitWebBluetoothConnectionOptions, MicrobitWebUSBConnectionOptions, };
|
|
14
|
+
import { createRadioBridgeConnection, MicrobitRadioBridgeConnection, MicrobitRadioBridgeConnectionOptions } from "./usb-radio-bridge.js";
|
|
15
|
+
import { createWebUSBConnection, MicrobitWebUSBConnection, MicrobitWebUSBConnectionOptions } from "./usb.js";
|
|
16
|
+
export { AfterRequestDevice, BackgroundErrorEvent, BeforeRequestDevice, BoardId, ConnectionStatus, ConnectionStatusEvent, createRadioBridgeConnection, createUniversalHexFlashDataSource, createWebBluetoothConnection, createWebUSBConnection, DeviceConnectionEventMap, DeviceError, FlashDataError, FlashEvent, SerialConnectionEventMap, SerialDataEvent, SerialErrorEvent, SerialResetEvent, ServiceConnectionEventMap, TypedEventTarget, UARTDataEvent, };
|
|
17
|
+
export type { AccelerometerData, AccelerometerDataEvent, BoardVersion, ButtonEvent, ButtonEventType, ButtonState, DeviceConnection, DeviceErrorCode, FlashDataSource, FlashOptions, LedMatrix, Logging, LoggingEvent, MagnetometerData, MagnetometerDataEvent, MicrobitRadioBridgeConnection, MicrobitRadioBridgeConnectionOptions, MicrobitWebBluetoothConnection, MicrobitWebBluetoothConnectionOptions, MicrobitWebUSBConnection, MicrobitWebUSBConnectionOptions, };
|
package/build/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UARTDataEvent = exports.TypedEventTarget = exports.ServiceConnectionEventMap = exports.SerialResetEvent = exports.SerialErrorEvent = exports.SerialDataEvent = exports.
|
|
3
|
+
exports.UARTDataEvent = exports.TypedEventTarget = exports.ServiceConnectionEventMap = exports.SerialResetEvent = exports.SerialErrorEvent = exports.SerialDataEvent = exports.SerialConnectionEventMap = exports.FlashEvent = exports.FlashDataError = exports.DeviceError = exports.DeviceConnectionEventMap = exports.createWebUSBConnection = exports.createWebBluetoothConnection = exports.createUniversalHexFlashDataSource = exports.createRadioBridgeConnection = exports.ConnectionStatusEvent = exports.ConnectionStatus = exports.BoardId = exports.BeforeRequestDevice = exports.BackgroundErrorEvent = exports.AfterRequestDevice = void 0;
|
|
4
4
|
const bluetooth_js_1 = require("./bluetooth.js");
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "createWebBluetoothConnection", { enumerable: true, get: function () { return bluetooth_js_1.createWebBluetoothConnection; } });
|
|
6
6
|
const board_id_js_1 = require("./board-id.js");
|
|
7
7
|
Object.defineProperty(exports, "BoardId", { enumerable: true, get: function () { return board_id_js_1.BoardId; } });
|
|
8
8
|
const device_js_1 = require("./device.js");
|
|
@@ -14,20 +14,22 @@ Object.defineProperty(exports, "ConnectionStatusEvent", { enumerable: true, get:
|
|
|
14
14
|
Object.defineProperty(exports, "DeviceConnectionEventMap", { enumerable: true, get: function () { return device_js_1.DeviceConnectionEventMap; } });
|
|
15
15
|
Object.defineProperty(exports, "DeviceError", { enumerable: true, get: function () { return device_js_1.DeviceError; } });
|
|
16
16
|
Object.defineProperty(exports, "FlashDataError", { enumerable: true, get: function () { return device_js_1.FlashDataError; } });
|
|
17
|
-
Object.defineProperty(exports, "FlashEvent", { enumerable: true, get: function () { return device_js_1.FlashEvent; } });
|
|
18
|
-
Object.defineProperty(exports, "SerialDataEvent", { enumerable: true, get: function () { return device_js_1.SerialDataEvent; } });
|
|
19
|
-
Object.defineProperty(exports, "SerialErrorEvent", { enumerable: true, get: function () { return device_js_1.SerialErrorEvent; } });
|
|
20
|
-
Object.defineProperty(exports, "SerialResetEvent", { enumerable: true, get: function () { return device_js_1.SerialResetEvent; } });
|
|
21
17
|
const events_js_1 = require("./events.js");
|
|
22
18
|
Object.defineProperty(exports, "TypedEventTarget", { enumerable: true, get: function () { return events_js_1.TypedEventTarget; } });
|
|
23
19
|
const hex_flash_data_source_js_1 = require("./hex-flash-data-source.js");
|
|
24
20
|
Object.defineProperty(exports, "createUniversalHexFlashDataSource", { enumerable: true, get: function () { return hex_flash_data_source_js_1.createUniversalHexFlashDataSource; } });
|
|
21
|
+
const serial_events_js_1 = require("./serial-events.js");
|
|
22
|
+
Object.defineProperty(exports, "FlashEvent", { enumerable: true, get: function () { return serial_events_js_1.FlashEvent; } });
|
|
23
|
+
Object.defineProperty(exports, "SerialConnectionEventMap", { enumerable: true, get: function () { return serial_events_js_1.SerialConnectionEventMap; } });
|
|
24
|
+
Object.defineProperty(exports, "SerialDataEvent", { enumerable: true, get: function () { return serial_events_js_1.SerialDataEvent; } });
|
|
25
|
+
Object.defineProperty(exports, "SerialErrorEvent", { enumerable: true, get: function () { return serial_events_js_1.SerialErrorEvent; } });
|
|
26
|
+
Object.defineProperty(exports, "SerialResetEvent", { enumerable: true, get: function () { return serial_events_js_1.SerialResetEvent; } });
|
|
25
27
|
const service_events_js_1 = require("./service-events.js");
|
|
26
28
|
Object.defineProperty(exports, "ServiceConnectionEventMap", { enumerable: true, get: function () { return service_events_js_1.ServiceConnectionEventMap; } });
|
|
27
29
|
const uart_js_1 = require("./uart.js");
|
|
28
30
|
Object.defineProperty(exports, "UARTDataEvent", { enumerable: true, get: function () { return uart_js_1.UARTDataEvent; } });
|
|
29
31
|
const usb_radio_bridge_js_1 = require("./usb-radio-bridge.js");
|
|
30
|
-
Object.defineProperty(exports, "
|
|
32
|
+
Object.defineProperty(exports, "createRadioBridgeConnection", { enumerable: true, get: function () { return usb_radio_bridge_js_1.createRadioBridgeConnection; } });
|
|
31
33
|
const usb_js_1 = require("./usb.js");
|
|
32
|
-
Object.defineProperty(exports, "
|
|
34
|
+
Object.defineProperty(exports, "createWebUSBConnection", { enumerable: true, get: function () { return usb_js_1.createWebUSBConnection; } });
|
|
33
35
|
//# sourceMappingURL=index.js.map
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;AACA,iDAIwB;AAoDtB,6GAvDA,2CAA4B,OAuDA;AAnD9B,+CAAwC;AA8CtC,wFA9CO,qBAAO,OA8CP;AA5CT,2CAcqB;AA2BnB,mGAxCA,8BAAkB,OAwCA;AAClB,qGAxCA,gCAAoB,OAwCA;AACpB,oGAxCA,+BAAmB,OAwCA;AAEnB,iGAxCA,4BAAgB,OAwCA;AAChB,sGAxCA,iCAAqB,OAwCA;AAKrB,yGA3CA,oCAAwB,OA2CA;AACxB,4FA3CA,uBAAW,OA2CA;AACX,+FA1CA,0BAAc,OA0CA;AAtChB,2CAA+C;AA6C7C,iGA7CO,4BAAgB,OA6CP;AA5ClB,yEAA+E;AAgC7E,kHAhCO,4DAAiC,OAgCP;AA5BnC,yDAM4B;AA4B1B,2FAjCA,6BAAU,OAiCA;AACV,yGAjCA,2CAAwB,OAiCA;AACxB,gGAjCA,kCAAe,OAiCA;AACf,iGAjCA,mCAAgB,OAiCA;AAChB,iGAjCA,mCAAgB,OAiCA;AA/BlB,2DAAgE;AAgC9D,0GAhCO,6CAAyB,OAgCP;AA/B3B,uCAA0C;AAiCxC,8FAjCO,uBAAa,OAiCP;AAhCf,+DAI+B;AAc7B,4GAjBA,iDAA2B,OAiBA;AAb7B,qCAIkB;AAYhB,uGAfA,+BAAsB,OAeA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class SerialDataEvent extends Event {
|
|
2
|
+
readonly data: string;
|
|
3
|
+
constructor(data: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SerialResetEvent extends Event {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare class SerialErrorEvent extends Event {
|
|
9
|
+
readonly error: unknown;
|
|
10
|
+
constructor(error: unknown);
|
|
11
|
+
}
|
|
12
|
+
export declare class FlashEvent extends Event {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare class SerialConnectionEventMap {
|
|
16
|
+
"serialdata": SerialDataEvent;
|
|
17
|
+
"serialreset": SerialResetEvent;
|
|
18
|
+
"serialerror": SerialErrorEvent;
|
|
19
|
+
"flash": FlashEvent;
|
|
20
|
+
}
|