@ledgerhq/react-native-hw-transport-ble 6.25.1-alpha.3 → 6.25.1

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.
@@ -1,41 +0,0 @@
1
- // @flow
2
-
3
- import { Observable } from "rxjs";
4
- import { TransportError } from "@ledgerhq/errors";
5
- import type { Characteristic } from "./types";
6
- import { log } from "@ledgerhq/logs";
7
-
8
- export const monitorCharacteristic = (
9
- characteristic: Characteristic
10
- ): Observable<Buffer> =>
11
- Observable.create((o) => {
12
- log("ble-verbose", "start monitor " + characteristic.uuid);
13
- const subscription = characteristic.monitor((error, c) => {
14
- if (error) {
15
- log(
16
- "ble-verbose",
17
- "error monitor " + characteristic.uuid + ": " + error
18
- );
19
- o.error(error);
20
- } else if (!c) {
21
- o.error(
22
- new TransportError(
23
- "characteristic monitor null value",
24
- "CharacteristicMonitorNull"
25
- )
26
- );
27
- } else {
28
- try {
29
- const value = Buffer.from(c.value, "base64");
30
- o.next(value);
31
- } catch (error) {
32
- o.error(error);
33
- }
34
- }
35
- });
36
-
37
- return () => {
38
- log("ble-verbose", "end monitor " + characteristic.uuid);
39
- subscription.remove();
40
- };
41
- });
@@ -1,20 +0,0 @@
1
- // @flow
2
- import { DisconnectedDevice } from "@ledgerhq/errors";
3
-
4
- export const remapError = (error: ?Error) => {
5
- if (!error || !error.message) return error;
6
- if (
7
- error.message.includes("was disconnected") ||
8
- error.message.includes("not found")
9
- ) {
10
- return new DisconnectedDevice();
11
- }
12
- return error;
13
- };
14
-
15
- export const rethrowError = (e: ?Error) => {
16
- throw remapError(e);
17
- };
18
-
19
- export const decoratePromiseErrors = <A>(promise: Promise<A>): Promise<A> =>
20
- promise.catch(rethrowError);
@@ -1,27 +0,0 @@
1
- // @flow
2
-
3
- const timer =
4
- process.env.NODE_ENV === "development"
5
- ? {
6
- timeout: (fn: Function, ms: number) => {
7
- // hack for a bug in RN https://github.com/facebook/react-native/issues/9030
8
- const startTime = Date.now();
9
- const interval = setInterval(() => {
10
- if (Date.now() - startTime >= ms) {
11
- clearInterval(interval);
12
- fn();
13
- }
14
- }, 100);
15
- return () => {
16
- clearInterval(interval);
17
- };
18
- },
19
- }
20
- : {
21
- timeout: (fn: Function, ms: number) => {
22
- const timeout = setTimeout(fn, ms);
23
- return () => clearTimeout(timeout);
24
- },
25
- };
26
-
27
- export default timer;
@@ -1,4 +0,0 @@
1
- // @flow
2
- export type { BleManager } from "react-native-ble-plx";
3
- export type Device = *;
4
- export type Characteristic = *;