@ovok/native 1.16.1-dev.2143 → 1.16.1-dev.2145

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.
Files changed (111) hide show
  1. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-peripheral.js +35 -0
  2. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-peripheral.js.map +1 -0
  3. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js +3 -30
  4. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -1
  5. package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js +2 -2
  6. package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -1
  7. package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -1
  8. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth-runtime.js +28 -0
  9. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth-runtime.js.map +1 -0
  10. package/lib/commonjs/modules/next/bluetooth/web/index.js +208 -0
  11. package/lib/commonjs/modules/next/bluetooth/web/index.js.map +1 -0
  12. package/lib/commonjs/modules/next/bluetooth/web/web-ble-device.js +143 -0
  13. package/lib/commonjs/modules/next/bluetooth/web/web-ble-device.js.map +1 -0
  14. package/lib/commonjs/modules/next/bluetooth/web/web-ble-shapes.js +43 -0
  15. package/lib/commonjs/modules/next/bluetooth/web/web-ble-shapes.js.map +1 -0
  16. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-permissions.js +21 -0
  17. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-permissions.js.map +1 -0
  18. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-scanner.js +133 -0
  19. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-scanner.js.map +1 -0
  20. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-services.js +28 -0
  21. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-services.js.map +1 -0
  22. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-values.js +37 -0
  23. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth-values.js.map +1 -0
  24. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth.types.js +2 -0
  25. package/lib/commonjs/modules/next/bluetooth/web/web-bluetooth.types.js.map +1 -0
  26. package/lib/commonjs/modules/next/bluetooth/web/web-gatt.js +83 -0
  27. package/lib/commonjs/modules/next/bluetooth/web/web-gatt.js.map +1 -0
  28. package/lib/module/modules/next/bluetooth/ble-plx/ble-peripheral.js +30 -0
  29. package/lib/module/modules/next/bluetooth/ble-plx/ble-peripheral.js.map +1 -0
  30. package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js +2 -27
  31. package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -1
  32. package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js +1 -1
  33. package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -1
  34. package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -1
  35. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth-runtime.js +25 -0
  36. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth-runtime.js.map +1 -0
  37. package/lib/module/modules/next/bluetooth/web/index.js +28 -0
  38. package/lib/module/modules/next/bluetooth/web/index.js.map +1 -0
  39. package/lib/module/modules/next/bluetooth/web/web-ble-device.js +140 -0
  40. package/lib/module/modules/next/bluetooth/web/web-ble-device.js.map +1 -0
  41. package/lib/module/modules/next/bluetooth/web/web-ble-shapes.js +39 -0
  42. package/lib/module/modules/next/bluetooth/web/web-ble-shapes.js.map +1 -0
  43. package/lib/module/modules/next/bluetooth/web/web-bluetooth-permissions.js +18 -0
  44. package/lib/module/modules/next/bluetooth/web/web-bluetooth-permissions.js.map +1 -0
  45. package/lib/module/modules/next/bluetooth/web/web-bluetooth-scanner.js +128 -0
  46. package/lib/module/modules/next/bluetooth/web/web-bluetooth-scanner.js.map +1 -0
  47. package/lib/module/modules/next/bluetooth/web/web-bluetooth-services.js +25 -0
  48. package/lib/module/modules/next/bluetooth/web/web-bluetooth-services.js.map +1 -0
  49. package/lib/module/modules/next/bluetooth/web/web-bluetooth-values.js +29 -0
  50. package/lib/module/modules/next/bluetooth/web/web-bluetooth-values.js.map +1 -0
  51. package/lib/module/modules/next/bluetooth/web/web-bluetooth.types.js +2 -0
  52. package/lib/module/modules/next/bluetooth/web/web-bluetooth.types.js.map +1 -0
  53. package/lib/module/modules/next/bluetooth/web/web-gatt.js +79 -0
  54. package/lib/module/modules/next/bluetooth/web/web-gatt.js.map +1 -0
  55. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +1 -1
  56. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-peripheral.d.ts +8 -0
  58. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-peripheral.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +3 -7
  60. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +2 -2
  62. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth-runtime.d.ts +23 -0
  64. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth-runtime.d.ts.map +1 -0
  65. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/index.d.ts +41 -0
  66. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/index.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-ble-device.d.ts +53 -0
  68. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-ble-device.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-ble-shapes.d.ts +27 -0
  70. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-ble-shapes.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-permissions.d.ts +8 -0
  72. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-permissions.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-scanner.d.ts +29 -0
  74. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-scanner.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-services.d.ts +10 -0
  76. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-services.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-values.d.ts +9 -0
  78. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth-values.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth.types.d.ts +56 -0
  80. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-bluetooth.types.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-gatt.d.ts +27 -0
  82. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/web-gatt.d.ts.map +1 -0
  83. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +1 -1
  84. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -1
  85. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-peripheral.d.ts +8 -0
  86. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-peripheral.d.ts.map +1 -0
  87. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +3 -7
  88. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -1
  89. package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +2 -2
  90. package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -1
  91. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth-runtime.d.ts +23 -0
  92. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth-runtime.d.ts.map +1 -0
  93. package/lib/typescript/module/src/modules/next/bluetooth/web/index.d.ts +41 -0
  94. package/lib/typescript/module/src/modules/next/bluetooth/web/index.d.ts.map +1 -0
  95. package/lib/typescript/module/src/modules/next/bluetooth/web/web-ble-device.d.ts +53 -0
  96. package/lib/typescript/module/src/modules/next/bluetooth/web/web-ble-device.d.ts.map +1 -0
  97. package/lib/typescript/module/src/modules/next/bluetooth/web/web-ble-shapes.d.ts +27 -0
  98. package/lib/typescript/module/src/modules/next/bluetooth/web/web-ble-shapes.d.ts.map +1 -0
  99. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-permissions.d.ts +8 -0
  100. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-permissions.d.ts.map +1 -0
  101. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-scanner.d.ts +29 -0
  102. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-scanner.d.ts.map +1 -0
  103. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-services.d.ts +10 -0
  104. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-services.d.ts.map +1 -0
  105. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-values.d.ts +9 -0
  106. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth-values.d.ts.map +1 -0
  107. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth.types.d.ts +56 -0
  108. package/lib/typescript/module/src/modules/next/bluetooth/web/web-bluetooth.types.d.ts.map +1 -0
  109. package/lib/typescript/module/src/modules/next/bluetooth/web/web-gatt.d.ts +27 -0
  110. package/lib/typescript/module/src/modules/next/bluetooth/web/web-gatt.d.ts.map +1 -0
  111. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.webBluetoothScanner = exports.isWebBluetoothAvailable = void 0;
7
+ var _bleErrors = require("../ble-plx/ble-errors.js");
8
+ var _blePeripheral = require("../ble-plx/ble-peripheral.js");
9
+ var _errors = require("../errors.js");
10
+ var _webBleDevice = require("./web-ble-device.js");
11
+ var _webBluetoothServices = require("./web-bluetooth-services.js");
12
+ var _webBluetoothValues = require("./web-bluetooth-values.js");
13
+ /** How long a device gets to advertise, where the browser lets the page watch, before it is reported without. */
14
+ const ADVERTISEMENT_WAIT_MS = 1500;
15
+ const CHOOSER_CLOSED = "NotFoundError";
16
+
17
+ /** What `webBluetoothScanner` needs. */
18
+
19
+ /** A `BluetoothScanner` for browsers, where a page only reaches the devices the user picks in the browser's chooser. */
20
+
21
+ const navigatorBluetooth = () => globalThis.navigator?.bluetooth;
22
+
23
+ /** Whether this browser has Web Bluetooth, such as Chrome and Edge on desktop and Android, or Bluefy on iOS. */
24
+ const isWebBluetoothAvailable = () => navigatorBluetooth() !== undefined;
25
+ exports.isWebBluetoothAvailable = isWebBluetoothAvailable;
26
+ const unsupported = () => new _errors.BluetoothError("unsupported", "This browser has no Web Bluetooth");
27
+
28
+ /** The first advertisement the browser reports, when it lets the page watch them, so names alone need not match. */
29
+ const advertisementOf = device => {
30
+ if (typeof device.watchAdvertisements !== "function") {
31
+ return Promise.resolve(undefined);
32
+ }
33
+ return new Promise(resolve => {
34
+ const watching = new AbortController();
35
+ const done = advertisement => {
36
+ clearTimeout(timer);
37
+ device.removeEventListener("advertisementreceived", received);
38
+ watching.abort();
39
+ resolve(advertisement);
40
+ };
41
+ const received = event => {
42
+ const {
43
+ uuids,
44
+ manufacturerData
45
+ } = event;
46
+ done({
47
+ serviceUUIDs: uuids?.map(_webBluetoothValues.canonicalUuid) ?? null,
48
+ manufacturerData: (0, _webBluetoothValues.manufacturerDataOf)(manufacturerData)
49
+ });
50
+ };
51
+ const timer = setTimeout(() => done(), ADVERTISEMENT_WAIT_MS);
52
+ device.addEventListener("advertisementreceived", received);
53
+ device.watchAdvertisements?.({
54
+ signal: watching.signal
55
+ }).catch(() => done());
56
+ });
57
+ };
58
+
59
+ /**
60
+ * Finds devices through Web Bluetooth. A scan reports the devices this site may already use (`getDevices`, where the
61
+ * browser has it) and every device picked with `chooseDevice`; browsers can't scan in the background or without the
62
+ * user picking.
63
+ */
64
+ const webBluetoothScanner = ({
65
+ acceptedDevices,
66
+ bluetooth = navigatorBluetooth()
67
+ } = {}) => {
68
+ const optionalServices = (0, _webBluetoothServices.webBluetoothServicesFor)(acceptedDevices);
69
+ const scans = new Set();
70
+ const devices = new Map();
71
+ const peripheralOf = async device => {
72
+ let bleDevice = devices.get(device.id);
73
+ if (!bleDevice) {
74
+ bleDevice = new _webBleDevice.WebBleDevice(device, await advertisementOf(device));
75
+ devices.set(device.id, bleDevice);
76
+ }
77
+ if (!bleDevice.serviceUUIDs?.length) {
78
+ // Devices told apart by their services alone (the SIG profiles) need them, and only a connection reveals them.
79
+ await bleDevice.connect().then(connected => connected.discoverAllServicesAndCharacteristics()).catch(() => undefined);
80
+ }
81
+ return (0, _blePeripheral.blePeripheral)(bleDevice);
82
+ };
83
+ const report = async device => {
84
+ const peripheral = await peripheralOf(device);
85
+ scans.forEach(onFound => onFound(peripheral));
86
+ return peripheral;
87
+ };
88
+ return {
89
+ watchState: listener => {
90
+ if (!bluetooth) {
91
+ listener("unsupported");
92
+ return () => undefined;
93
+ }
94
+ let watching = true;
95
+ const changed = event => watching && listener(event.value ? "on" : "off");
96
+ bluetooth.addEventListener("availabilitychanged", changed);
97
+ bluetooth.getAvailability().then(available => watching && listener(available ? "on" : "off"), () => watching && listener("unknown"));
98
+ return () => {
99
+ watching = false;
100
+ bluetooth.removeEventListener("availabilitychanged", changed);
101
+ };
102
+ },
103
+ scan: (onFound, onError) => {
104
+ if (!bluetooth) {
105
+ onError(unsupported());
106
+ return () => undefined;
107
+ }
108
+ scans.add(onFound);
109
+ bluetooth.getDevices?.().then(allowed => allowed.forEach(device => void report(device)), error => onError((0, _bleErrors.fromBleError)(error)));
110
+ return () => {
111
+ scans.delete(onFound);
112
+ };
113
+ },
114
+ chooseDevice: async () => {
115
+ if (!bluetooth) {
116
+ throw unsupported();
117
+ }
118
+ try {
119
+ return await report(await bluetooth.requestDevice({
120
+ acceptAllDevices: true,
121
+ optionalServices
122
+ }));
123
+ } catch (error) {
124
+ if (error?.name === CHOOSER_CLOSED) {
125
+ return undefined;
126
+ }
127
+ throw (0, _bleErrors.fromBleError)(error);
128
+ }
129
+ }
130
+ };
131
+ };
132
+ exports.webBluetoothScanner = webBluetoothScanner;
133
+ //# sourceMappingURL=web-bluetooth-scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_bleErrors","require","_blePeripheral","_errors","_webBleDevice","_webBluetoothServices","_webBluetoothValues","ADVERTISEMENT_WAIT_MS","CHOOSER_CLOSED","navigatorBluetooth","globalThis","navigator","bluetooth","isWebBluetoothAvailable","undefined","exports","unsupported","BluetoothError","advertisementOf","device","watchAdvertisements","Promise","resolve","watching","AbortController","done","advertisement","clearTimeout","timer","removeEventListener","received","abort","event","uuids","manufacturerData","serviceUUIDs","map","canonicalUuid","manufacturerDataOf","setTimeout","addEventListener","signal","catch","webBluetoothScanner","acceptedDevices","optionalServices","webBluetoothServicesFor","scans","Set","devices","Map","peripheralOf","bleDevice","get","id","WebBleDevice","set","length","connect","then","connected","discoverAllServicesAndCharacteristics","blePeripheral","report","peripheral","forEach","onFound","watchState","listener","changed","value","getAvailability","available","scan","onError","add","getDevices","allowed","error","fromBleError","delete","chooseDevice","requestDevice","acceptAllDevices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AAO,MAAMF,SAAS;MACxB;MAEAiC,KAAK,CAAC4B,GAAG,CAACT,OAAO,CAAC;MAClBtD,SAAS,CAACgE,UAAU,GAAG,CAAC,CAACjB,IAAI,CAC1BkB,OAAO,IAAKA,OAAO,CAACZ,OAAO,CAAE9C,MAAM,IAAK,KAAK4C,MAAM,CAAC5C,MAAM,CAAC,CAAC,EAC5D2D,KAAc,IAAKJ,OAAO,CAAC,IAAAK,uBAAY,EAACD,KAAK,CAAC,CACjD,CAAC;MAED,OAAO,MAAM;QACX/B,KAAK,CAACiC,MAAM,CAACd,OAAO,CAAC;MACvB,CAAC;IACH,CAAC;IACDe,YAAY,EAAE,MAAAA,CAAA,KAAY;MACxB,IAAI,CAACrE,SAAS,EAAE;QACd,MAAMI,WAAW,CAAC,CAAC;MACrB;MAEA,IAAI;QACF,OAAO,MAAM+C,MAAM,CAAC,MAAMnD,SAAS,CAACsE,aAAa,CAAC;UAAEC,gBAAgB,EAAE,IAAI;UAAEtC;QAAiB,CAAC,CAAC,CAAC;MAClG,CAAC,CAAC,OAAOiC,KAAK,EAAE;QACd,IAAKA,KAAK,EAAoCM,IAAI,KAAK5E,cAAc,EAAE;UACrE,OAAOM,SAAS;QAClB;QACA,MAAM,IAAAiE,uBAAY,EAACD,KAAK,CAAC;MAC3B;IACF;EACF,CAAC;AACH,CAAC;AAAC/D,OAAA,CAAA4B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.webBluetoothServicesFor = exports.WEB_BLUETOOTH_SERVICES = void 0;
7
+ var _backgroundServiceUuids = require("../../../bt-management/services/background-sync/background-service-uuids.js");
8
+ var _integratedDevices = require("../../../bt-management/types/integrated-devices.js");
9
+ var _webBluetoothValues = require("./web-bluetooth-values.js");
10
+ /** Services read on every connection, whatever the device. */
11
+ const SHARED_SERVICES = ["1800", "180a", "180f", "1805", "1804"];
12
+
13
+ /** Bluetooth SIG profiles: glucose, thermometer, heart rate, blood pressure, weight scale, pulse oximeter. */
14
+ const SIG_SERVICES = ["1808", "1809", "180d", "1810", "181d", "1822"];
15
+
16
+ /** Services the integrated devices' protocols use beyond their background-scan services. */
17
+ const PROTOCOL_SERVICES = ["1000", "18f0", "7801", "7802", "7809", "7889", "7892", "a000", "a500", "a602", "a610", "ae30", "f018", "fe60", "fee0", "ff00", "ff12", "ffb0", "ffe0", "ffe5", "fff0", "ffff", "14839ac4-7d7e-415c-9a42-167340cf2339", "e8fb0001-a14b-98f9-831b-4e2941d01248", "00002760-08c2-11e1-9073-0e8ac72e5450", "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "cdeacb80-5235-4c07-8846-93a37ee6b86d", "cdeacd80-5235-4c07-8846-93a37ee6b86d", "49535343-fe7d-4ae5-8fa9-9fafd205e455", "81eea003-e735-49ec-8a11-7e32cae1e14e", "5d4b8aa6-a26a-4a1b-99f5-cd4473c786e3", "2610fc00-494d-494c-4544-55544954414c", "233bf000-5a34-1b6d-975c-000d5690abe4", "23434100-1fe4-1eff-80cb-00ff78297d8b", "00001523-1212-efde-1523-785feabcd123", "0003cdd0-0000-1000-8000-00805f9b0131", "00010203-0405-0607-0809-0a0b0c0d1910", "fb349b5f-8000-0080-0010-0000f0180000"];
18
+
19
+ /**
20
+ * Every GATT service an integrated device uses, as a browser must be told when the user picks a device: a page can
21
+ * only reach the services it named in `navigator.bluetooth.requestDevice`'s `optionalServices`.
22
+ */
23
+ const WEB_BLUETOOTH_SERVICES = exports.WEB_BLUETOOTH_SERVICES = [...new Set([...SHARED_SERVICES, ...SIG_SERVICES, ...PROTOCOL_SERVICES, ...(0, _backgroundServiceUuids.getBackgroundServiceUUIDs)(Object.values(_integratedDevices.IntegratedDevices))].map(_webBluetoothValues.canonicalUuid))];
24
+
25
+ /** `WEB_BLUETOOTH_SERVICES` and the services of the `defineCustomDevice` declarations among `acceptedDevices`. */
26
+ const webBluetoothServicesFor = (acceptedDevices = []) => [...new Set([...WEB_BLUETOOTH_SERVICES, ...(0, _backgroundServiceUuids.getBackgroundServiceUUIDs)(acceptedDevices).map(_webBluetoothValues.canonicalUuid)])];
27
+ exports.webBluetoothServicesFor = webBluetoothServicesFor;
28
+ //# sourceMappingURL=web-bluetooth-services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_backgroundServiceUuids","require","_integratedDevices","_webBluetoothValues","SHARED_SERVICES","SIG_SERVICES","PROTOCOL_SERVICES","WEB_BLUETOOTH_SERVICES","exports","Set","getBackgroundServiceUUIDs","Object","values","IntegratedDevices","map","canonicalUuid","webBluetoothServicesFor","acceptedDevices"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/web-bluetooth-services.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AAEA;AACA,MAAMG,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;;AAEhE;AACA,MAAMC,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;;AAErE;AACA,MAAMC,iBAAiB,GAAG,CACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC9G,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC9D,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,CACvC;;AAED;AACA;AACA;AACA;AACA,MAAMC,sBAAyC,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAChD,GAAG,IAAIE,GAAG,CACR,CACE,GAAGL,eAAe,EAClB,GAAGC,YAAY,EACf,GAAGC,iBAAiB,EACpB,GAAG,IAAAI,iDAAyB,EAACC,MAAM,CAACC,MAAM,CAACC,oCAAiB,CAAC,CAAC,CAC/D,CAACC,GAAG,CAACC,iCAAa,CACrB,CAAC,CACF;;AAED;AACA,MAAMC,uBAAuB,GAAGA,CAACC,eAA0C,GAAG,EAAE,KAAe,CAC7F,GAAG,IAAIR,GAAG,CAAC,CAAC,GAAGF,sBAAsB,EAAE,GAAG,IAAAG,iDAAyB,EAACO,eAAe,CAAC,CAACH,GAAG,CAACC,iCAAa,CAAC,CAAC,CAAC,CAC1G;AAACP,OAAA,CAAAQ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toBase64 = exports.manufacturerDataOf = exports.fromBase64 = exports.canonicalUuid = exports.bytesOf = void 0;
7
+ const BASE_UUID_SUFFIX = "-0000-1000-8000-00805f9b34fb";
8
+ const SHORT_UUID = /^[0-9a-f]{4}$/;
9
+ const MEDIUM_UUID = /^[0-9a-f]{8}$/;
10
+
11
+ /** A UUID as Web Bluetooth accepts it: lower case, with a 16- or 32-bit alias expanded on the Bluetooth base UUID. */
12
+ const canonicalUuid = uuid => {
13
+ const lower = uuid.trim().toLowerCase();
14
+ if (SHORT_UUID.test(lower)) {
15
+ return `0000${lower}${BASE_UUID_SUFFIX}`;
16
+ }
17
+ return MEDIUM_UUID.test(lower) ? `${lower}${BASE_UUID_SUFFIX}` : lower;
18
+ };
19
+ exports.canonicalUuid = canonicalUuid;
20
+ const bytesOf = view => new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
21
+ exports.bytesOf = bytesOf;
22
+ const toBase64 = bytes => btoa(Array.from(bytes, byte => String.fromCharCode(byte)).join(""));
23
+ exports.toBase64 = toBase64;
24
+ const fromBase64 = base64 => Uint8Array.from(atob(base64), char => char.charCodeAt(0));
25
+
26
+ /** Manufacturer data the way `react-native-ble-plx` reports it: the company ID, little endian, then the payload. */
27
+ exports.fromBase64 = fromBase64;
28
+ const manufacturerDataOf = data => {
29
+ const [entry] = data ?? [];
30
+ if (!entry) {
31
+ return null;
32
+ }
33
+ const [companyId, payload] = entry;
34
+ return toBase64(Uint8Array.from([companyId & 0xff, companyId >> 8, ...bytesOf(payload)]));
35
+ };
36
+ exports.manufacturerDataOf = manufacturerDataOf;
37
+ //# sourceMappingURL=web-bluetooth-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BASE_UUID_SUFFIX","SHORT_UUID","MEDIUM_UUID","canonicalUuid","uuid","lower","trim","toLowerCase","test","exports","bytesOf","view","Uint8Array","buffer","byteOffset","byteLength","toBase64","bytes","btoa","Array","from","byte","String","fromCharCode","join","fromBase64","base64","atob","char","charCodeAt","manufacturerDataOf","data","entry","companyId","payload"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/web-bluetooth-values.ts"],"mappings":";;;;;;AAAA,MAAMA,gBAAgB,GAAG,8BAA8B;AACvD,MAAMC,UAAU,GAAG,eAAe;AAClC,MAAMC,WAAW,GAAG,eAAe;;AAEnC;AACA,MAAMC,aAAa,GAAIC,IAAY,IAAa;EAC9C,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EAEvC,IAAIN,UAAU,CAACO,IAAI,CAACH,KAAK,CAAC,EAAE;IAC1B,OAAO,OAAOA,KAAK,GAAGL,gBAAgB,EAAE;EAC1C;EAEA,OAAOE,WAAW,CAACM,IAAI,CAACH,KAAK,CAAC,GAAG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names":[],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/web-bluetooth.types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WebGatt = void 0;
7
+ var _webBleShapes = require("./web-ble-shapes.js");
8
+ var _webBluetoothValues = require("./web-bluetooth-values.js");
9
+ const messageOf = error => error instanceof Error ? error.message : String(error);
10
+
11
+ /**
12
+ * A device's GATT server as one queue: browsers allow one GATT operation at a time, so each runs after the previous one
13
+ * settles, and its services are discovered once per connection.
14
+ */
15
+ class WebGatt {
16
+ characteristics = new Map();
17
+ operations = Promise.resolve();
18
+ constructor(device) {
19
+ this.device = device;
20
+ }
21
+ get connected() {
22
+ return this.device.gatt?.connected ?? false;
23
+ }
24
+ server() {
25
+ if (!this.device.gatt) {
26
+ throw new _webBleShapes.WebBleError(_webBleShapes.UNKNOWN_ERROR, `Device ${this.device.id} is unsupported: it has no GATT server`);
27
+ }
28
+ return this.device.gatt;
29
+ }
30
+
31
+ /** Runs `operation` after the previous one settles; a failure comes back as a `react-native-ble-plx` error. */
32
+ queued(operation) {
33
+ const result = this.operations.then(operation, operation).catch(error => {
34
+ throw this.errorOf(error);
35
+ });
36
+ this.operations = result.catch(() => undefined);
37
+ return result;
38
+ }
39
+
40
+ /** The discovered services' UUIDs; call it inside a queued operation, so discovery never queues behind itself. */
41
+ async serviceUuids() {
42
+ await this.discover();
43
+ return [...this.characteristics.keys()];
44
+ }
45
+ async characteristicsOf(serviceUuid) {
46
+ await this.discover();
47
+ return [...(this.characteristics.get((0, _webBluetoothValues.canonicalUuid)(serviceUuid))?.values() ?? [])];
48
+ }
49
+ async characteristic(serviceUuid, characteristicUuid) {
50
+ await this.discover();
51
+ const characteristic = this.characteristics.get((0, _webBluetoothValues.canonicalUuid)(serviceUuid))?.get((0, _webBluetoothValues.canonicalUuid)(characteristicUuid));
52
+ if (!characteristic) {
53
+ throw new _webBleShapes.WebBleError(_webBleShapes.UNKNOWN_ERROR, `Characteristic ${characteristicUuid} of service ${serviceUuid} was not found on device ${this.device.id}`);
54
+ }
55
+ return characteristic;
56
+ }
57
+
58
+ /** Forgets the discovered services, as a new connection must discover them again. */
59
+ forget() {
60
+ this.discovered = undefined;
61
+ }
62
+ errorOf(error) {
63
+ if (error instanceof _webBleShapes.WebBleError) {
64
+ return error;
65
+ }
66
+ return new _webBleShapes.WebBleError(this.connected ? _webBleShapes.UNKNOWN_ERROR : _webBleShapes.DEVICE_DISCONNECTED, messageOf(error), error);
67
+ }
68
+ discover() {
69
+ this.discovered ??= (async () => {
70
+ this.characteristics.clear();
71
+ for (const service of await this.server().getPrimaryServices()) {
72
+ const characteristics = await service.getCharacteristics().catch(() => []);
73
+ this.characteristics.set((0, _webBluetoothValues.canonicalUuid)(service.uuid), new Map(characteristics.map(characteristic => [(0, _webBluetoothValues.canonicalUuid)(characteristic.uuid), characteristic])));
74
+ }
75
+ })().catch(error => {
76
+ this.discovered = undefined;
77
+ throw error;
78
+ });
79
+ return this.discovered;
80
+ }
81
+ }
82
+ exports.WebGatt = WebGatt;
83
+ //# sourceMappingURL=web-gatt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_webBleShapes","require","_webBluetoothValues","messageOf","error","Error","message","String","WebGatt","characteristics","Map","operations","Promise","resolve","constructor","device","connected","gatt","server","WebBleError","UNKNOWN_ERROR","id","queued","operation","result","then","catch","errorOf","undefined","serviceUuids","discover","keys","characteristicsOf","serviceUuid","get","canonicalUuid","values","characteristic","characteristicUuid","forget","discovered","DEVICE_DISCONNECTED","clear","service","getPrimaryServices","getCharacteristics","set","uuid","map","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/web-gatt.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAGA,MAAME,SAAS,GAAIC,KAAc,IAAcA,KAAK,YAAYC,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AAE,CAAC;QAE1E,IAAI,CAACjB,eAAe,CAACqC,GAAG,CACtB,IAAAX,iCAAa,EAACQ,OAAO,CAACI,IAAI,CAAC,EAC3B,IAAIrC,GAAG,CAACD,eAAe,CAACuC,GAAG,CAAEX,cAAc,IAAK,CAAC,IAAAF,iCAAa,EAACE,cAAc,CAACU,IAAI,CAAC,EAAEV,cAAc,CAAC,CAAC,CACvG,CAAC;MACH;IACF,CAAC,EAAE,CAAC,CAACX,KAAK,CAAEtB,KAAc,IAAK;MAC7B,IAAI,CAACoC,UAAU,GAAGZ,SAAS;MAC3B,MAAMxB,KAAK;IACb,CAAC,CAAC;IAEF,OAAO,IAAI,CAACoC,UAAU;EACxB;AACF;AAACS,OAAA,CAAAzC,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ import { openBleLink } from "./ble-link.js";
4
+ const bleDevices = new WeakMap();
5
+
6
+ /** The `react-native-ble-plx` device behind a peripheral that `blePeripheral` made. */
7
+ const bleDeviceOf = peripheral => {
8
+ const device = bleDevices.get(peripheral);
9
+ if (!device) {
10
+ throw new Error("The peripheral was not made by blePeripheral");
11
+ }
12
+ return device;
13
+ };
14
+
15
+ /** A `react-native-ble-plx` device, or a device with the same API such as a Web Bluetooth one, as a peripheral. */
16
+ const blePeripheral = device => {
17
+ const peripheral = {
18
+ id: device.id,
19
+ advertisement: {
20
+ name: device.name?.trim() || device.localName?.trim() || "",
21
+ serviceUUIDs: device.serviceUUIDs ?? [],
22
+ manufacturerData: device.manufacturerData ?? null
23
+ },
24
+ openLink: signal => openBleLink(device, signal)
25
+ };
26
+ bleDevices.set(peripheral, device);
27
+ return peripheral;
28
+ };
29
+ export { bleDeviceOf, blePeripheral };
30
+ //# sourceMappingURL=ble-peripheral.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["openBleLink","bleDevices","WeakMap","bleDeviceOf","peripheral","device","get","Error","blePeripheral","id","advertisement","name","trim","localName","serviceUUIDs","manufacturerData","openLink","signal","set"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-peripheral.ts"],"mappings":";;AAIA,SAASA,WAAW,QAAQ,eAAY;AAExC,MAAMC,UAAU,GAAG,IAAIC,OAAO,CAAqB,CAAC;;AAEpD;AACA,MAAMC,WAAW,GAAIC,UAAsB,IAAa;EACtD,MAAMC,MAAM,GAAGJ,UAAU,CAACK,GAAG,CAACF,UAAU,CAAC;EAEzC,IAAI,CAACC,MAAM,EAAE;IACX,MAAM,IAAIE,KAAK,CAAC,8CAA8C,CAAC;EACjE;EAEA,OAAOF,MAAM;AACf,CAAC;;AAED;AACA,MAAMG,aAAa,GAAIH,MAAc,IAAiB;EACpD,MAAMD,UAAsB,GAAG;IAC7BK,EAAE,EAAEJ,MAAM,CAACI,EAAE;IACbC,aAAa,EAAE;MACbC,IAAI,EAAEN,MAAM,CAACM,IAAI,EAAEC,IAAI,CAAC,CAAC,IAAIP,MAAM,CAACQ,SAAS,EAAED,IAAI,CAAC,CAAC,IAAI,EAAE;MAC3DE,YAAY,EAAET,MAAM,CAACS,YAAY,IAAI,EAAE;MACvCC,gBAAgB,EAAEV,MAAM,CAACU,gBAAgB,IAAI;IAC/C,CAAC;IACDC,QAAQ,EAAGC,MAAM,IAAKjB,WAAW,CAACK,MAAM,EAAEY,MAAM;EAClD,CAAC;EAEDhB,UAAU,CAACiB,GAAG,CAACd,UAAU,EAAEC,MAAM,CAAC;EAElC,OAAOD,UAAU;AACnB,CAAC;AAED,SAASD,WAAW,EAAEK,aAAa","ignoreList":[]}
@@ -2,38 +2,13 @@
2
2
 
3
3
  import { ScanMode, State } from "react-native-ble-plx";
4
4
  import { fromBleError } from "./ble-errors.js";
5
- import { openBleLink } from "./ble-link.js";
5
+ import { blePeripheral } from "./ble-peripheral.js";
6
6
  const ADAPTER_STATES = {
7
7
  [State.PoweredOn]: "on",
8
8
  [State.PoweredOff]: "off",
9
9
  [State.Unauthorized]: "unauthorized",
10
10
  [State.Unsupported]: "unsupported"
11
11
  };
12
- const bleDevices = new WeakMap();
13
-
14
- /** The `react-native-ble-plx` device behind a peripheral this adapter reported. */
15
- const bleDeviceOf = peripheral => {
16
- const device = bleDevices.get(peripheral);
17
- if (!device) {
18
- throw new Error("The peripheral was not found by bleManagerScanner");
19
- }
20
- return device;
21
- };
22
-
23
- /** A `react-native-ble-plx` device as a peripheral. */
24
- const blePeripheral = device => {
25
- const peripheral = {
26
- id: device.id,
27
- advertisement: {
28
- name: device.name?.trim() || device.localName?.trim() || "",
29
- serviceUUIDs: device.serviceUUIDs ?? [],
30
- manufacturerData: device.manufacturerData ?? null
31
- },
32
- openLink: signal => openBleLink(device, signal)
33
- };
34
- bleDevices.set(peripheral, device);
35
- return peripheral;
36
- };
37
12
 
38
13
  /** A scanner over a `react-native-ble-plx` `BleManager`. */
39
14
  const bleManagerScanner = bleManager => ({
@@ -65,5 +40,5 @@ const bleManagerScanner = bleManager => ({
65
40
  };
66
41
  }
67
42
  });
68
- export { bleDeviceOf, bleManagerScanner, blePeripheral };
43
+ export { bleManagerScanner };
69
44
  //# sourceMappingURL=ble-scanner.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScanMode","State","fromBleError","openBleLink","ADAPTER_STATES","PoweredOn","PoweredOff","Unauthorized","Unsupported","bleDevices","WeakMap","bleDeviceOf","peripheral","device","get","Error","blePeripheral","id","advertisement","name","trim","localName","serviceUUIDs","manufacturerData","openLink","signal","set","bleManagerScanner","bleManager","watchState","listener","subscription","onStateChange","state","remove","scan","onFound","onError","active","startDeviceScan","scanMode","Balanced","error","stopDeviceScan"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-scanner.ts"],"mappings":";;AAAA,SAA6BA,QAAQ,EAAEC,KAAK,QAAQ,sBAAsB;AAI1E,SAASC,YAAY,QAAQ,iBAAc;AAC3C,SAASC,WAAW,QAAQ,eAAY;AAExC,MAAMC,cAAoD,GAAG;EAC3D,CAACH,KAAK,CAACI,S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AC;EACpC,CAAC;EACDC,IAAI,EAAEA,CAACC,OAAO,EAAEC,OAAO,KAAK;IAC1B,IAAIC,MAAM,GAAG,IAAI;IAEjB,IAAI;MACFV,UAAU,CAACW,eAAe,CAAC,IAAI,EAAE;QAAEC,QAAQ,EAAExC,QAAQ,CAACyC;MAAS,CAAC,EAAE,CAACC,KAAK,EAAE7B,MAAM,KAAK;QACnF,IAAI,CAACyB,MAAM,EAAE;UACX;QACF;QACA,IAAII,KAAK,EAAE;UACTL,OAAO,CAACnC,YAAY,CAACwC,KAAK,CAAC,CAAC;QAC9B,CAAC,MAAM,IAAI7B,MAAM,EAAE;UACjBuB,OAAO,CAACpB,aAAa,CAACH,MAAM,CAAC,CAAC;QAChC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAO6B,KAAK,EAAE;MACdL,OAAO,CAACnC,YAAY,CAACwC,KAAK,CAAC,CAAC;IAC9B;IAEA,OAAO,MAAM;MACXJ,MAAM,GAAG,KAAK;MACdV,UAAU,CAACe,cAAc,CAAC,CAAC;IAC7B,CAAC;EACH;AACF,CAAC,CAAC;AAEF,SAAShC,WAAW,EAAEgB,iBAAiB,EAAEX,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["ScanMode","State","fromBleError","blePeripheral","ADAPTER_STATES","PoweredOn","PoweredOff","Unauthorized","Unsupported","bleManagerScanner","bleManager","watchState","listener","subscription","onStateChange","state","remove","scan","onFound","onError","active","startDeviceScan","scanMode","Balanced","error","device","stopDeviceScan"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/ble-scanner.ts"],"mappings":";;AAAA,SAAqBA,QAAQ,EAAEC,KAAK,QAAQ,sBAAsB;AAIlE,SAASC,YAAY,QAAQ,iBAAc;AAC3C,SAASC,aAAa,QAAQ,qBAAkB;AAEhD,MAAMC,cAAoD,GAAG;EAC3D,CAACH,KAAK,CAACI,SAAS,GAAG,IAAI;EACvB,CAACJ,KAAK,CAACK,UAAU,GAAG,KAAK;EACzB,CAACL,KAAK,CAACM,YAAY,GAAG,cAAc;EACpC,CAACN,KAAK,CAACO,WAAW,GAAG;AACvB,CAAC;;AAED;AACA,MAAMC,iBAAiB,GAAIC,UAAsB,KAAwB;EACvEC,UAAU,EAAGC,QAAQ,IAAK;IACxB,MAAMC,YAAY,GAAGH,UAAU,CAACI,aAAa,CAAEC,KAAK,IAAKH,QAAQ,CAACR,cAAc,CAACW,KAAK,CAAC,IAAI,SAAS,CAAC,EAAE,IAAI,CAAC;IAE5G,OAAO,MAAMF,YAAY,CAACG,MAAM,CAAC,CAAC;EACpC,CAAC;EACDC,IAAI,EAAEA,CAACC,OAAO,EAAEC,OAAO,KAAK;IAC1B,IAAIC,MAAM,GAAG,IAAI;IAEjB,IAAI;MACFV,UAAU,CAACW,eAAe,CAAC,IAAI,EAAE;QAAEC,QAAQ,EAAEtB,QAAQ,CAACuB;MAAS,CAAC,EAAE,CAACC,KAAK,EAAEC,MAAM,KAAK;QACnF,IAAI,CAACL,MAAM,EAAE;UACX;QACF;QACA,IAAII,KAAK,EAAE;UACTL,OAAO,CAACjB,YAAY,CAACsB,KAAK,CAAC,CAAC;QAC9B,CAAC,MAAM,IAAIC,MAAM,EAAE;UACjBP,OAAO,CAACf,aAAa,CAACsB,MAAM,CAAC,CAAC;QAChC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOD,KAAK,EAAE;MACdL,OAAO,CAACjB,YAAY,CAACsB,KAAK,CAAC,CAAC;IAC9B;IAEA,OAAO,MAAM;MACXJ,MAAM,GAAG,KAAK;MACdV,UAAU,CAACgB,cAAc,CAAC,CAAC;IAC7B,CAAC;EACH;AACF,CAAC,CAAC;AAEF,SAASjB,iBAAiB","ignoreList":[]}
@@ -4,7 +4,7 @@ import { DeviceStatus } from "../../../bt-management/types/device-status.js";
4
4
  import { Channel } from "../channel.js";
5
5
  import { isTimestamped } from "../driver.js";
6
6
  import { fromBleError } from "./ble-errors.js";
7
- import { bleDeviceOf } from "./ble-scanner.js";
7
+ import { bleDeviceOf } from "./ble-peripheral.js";
8
8
  const STATUSES = {
9
9
  [DeviceStatus.CONNECTED]: "connected",
10
10
  [DeviceStatus.MEASURING]: "measuring",
@@ -1 +1 @@
1
- {"version":3,"names":["DeviceStatus","Channel","isTimestamped","fromBleError","bleDeviceOf","STATUSES","CONNECTED","MEASURING","DISCONNECTED","legacyDriver","creator","deviceName","peripheral","signal","stop","events","end","removeEventListener","managed","disconnect","createDevice","device","onResult","id","data","reading","push","kind","onDeviceStatusChanged","status","mapped","onError","error","addEventListener","once","connect","catch","fail"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/legacy-driver.ts"],"mappings":";;AAKA,SAASA,YAAY,QAAQ,+CAA4C;AACzE,SAASC,OAAO,QAAQ,eAAY;AACpC,SAA8BC,aAAa,QAAQ,cAAW;AAE9D,SAASC,YAAY,QAAQ,iBAAc;AAC3C,SAASC,WAAW,QAAQ,kBAAe;AAE3C,MAAMC,QAAmF,GAAG;EAC1F,CAACL,YAAY,CAACM,SAAS,GAAG,WAAW;EACrC,CAACN,YAAY,CAACO,SAAS,GAAG,WAAW;EACrC,CAACP,YAAY,CAACQ,YAAY,GAAG;AAC/B,CAAC;;AAED;AACA,MAAMC,YAAY,GAAGA,CAACC,OAAiD,EAAEC,UAAqB,KAC5F,CAACC,UAAU,EAAEC,MAAM,KAAK;EACtB,MAAMC,IAAI,GAAGA,CAAA,KAAMC,MAAM,CAACC,GAAG,CAAC,CAAC;EAE/B,MAAMD,MAAM,GAAG,IAAId,OAAO,CAAc,MAAM;IAC5CY,MAAM,CAACI,mBAAmB,CAAC,OAAO,EAAEH,IAAI,CAAC;IACzC,KAAKI,OAAO,CAACC,UAAU,CAAC,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMD,OAAO,GAAGR,OAAO,CAACU,YAAY,CAAC;IACnCC,MAAM,EAAEjB,WAAW,CAACQ,UAAU,CAAC;IAC/BD,UAAU;IACVW,QAAQ,EAAEA,CAAC;MAAEC,EAAE;MAAEC;IAAK,CAAC,KAAK;MAC1B,MAAMC,OAAO,GAAGD,IAAmB;MAEnCT,MAAM,CAACW,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEJ,EAAE,EAAErB,aAAa,CAACuB,OAAO,CAAC,GAAGF,EAAE,GAAG,IAAI;QAAEE;MAAQ,CAAC,CAAC;IACnF,CAAC;IACDG,qBAAqB,EAAEA,CAAC;MAAEC;IAAO,CAAC,KAAK;MACrC,MAAMC,MAAM,GAAGzB,QAAQ,CAACwB,MAAM,CAAC;MAE/B,IAAIC,MAAM,EAAE;QACVf,MAAM,CAACW,IAAI,CAAC;UAAEC,IAAI,EAAE,QAAQ;UAAEE,MAAM,EAAEC;QAAO,CAAC,CAAC;MACjD;MACA,IAAID,MAAM,KAAK7B,YAAY,CAACQ,YAAY,EAAE;QACxCO,MAAM,CAACC,GAAG,CAAC,CAAC;MACd;IACF,CAAC;IACDe,OAAO,EAAEA,CAAC;MAAEC;IAAM,CAAC,KAAKjB,MAAM,CAACW,IAAI,CAAC;MAAEC,IAAI,EAAE,OAAO;MAAEK,KAAK,EAAE7B,YAAY,CAAC6B,KAAK;IAAE,CAAC;EACnF,CAAC,CAAC;EAEFnB,MAAM,CAACoB,gBAAgB,CAAC,OAAO,EAAEnB,IAAI,EAAE;IAAEoB,IAAI,EAAE;EAAK,CAAC,CAAC;EACtDhB,OAAO,CAACiB,OAAO,CAAC,CAAC,CAACC,KAAK,CAAEJ,KAAc,IAAKjB,MAAM,CAACsB,IAAI,CAAClC,YAAY,CAAC6B,KAAK,CAAC,CAAC,CAAC;EAE7E,OAAOjB,MAAM;AACf,CAAC;AAEH,SAASN,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["DeviceStatus","Channel","isTimestamped","fromBleError","bleDeviceOf","STATUSES","CONNECTED","MEASURING","DISCONNECTED","legacyDriver","creator","deviceName","peripheral","signal","stop","events","end","removeEventListener","managed","disconnect","createDevice","device","onResult","id","data","reading","push","kind","onDeviceStatusChanged","status","mapped","onError","error","addEventListener","once","connect","catch","fail"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/ble-plx/legacy-driver.ts"],"mappings":";;AAKA,SAASA,YAAY,QAAQ,+CAA4C;AACzE,SAASC,OAAO,QAAQ,eAAY;AACpC,SAA8BC,aAAa,QAAQ,cAAW;AAE9D,SAASC,YAAY,QAAQ,iBAAc;AAC3C,SAASC,WAAW,QAAQ,qBAAkB;AAE9C,MAAMC,QAAmF,GAAG;EAC1F,CAACL,YAAY,CAACM,SAAS,GAAG,WAAW;EACrC,CAACN,YAAY,CAACO,SAAS,GAAG,WAAW;EACrC,CAACP,YAAY,CAACQ,YAAY,GAAG;AAC/B,CAAC;;AAED;AACA,MAAMC,YAAY,GAAGA,CAACC,OAAiD,EAAEC,UAAqB,KAC5F,CAACC,UAAU,EAAEC,MAAM,KAAK;EACtB,MAAMC,IAAI,GAAGA,CAAA,KAAMC,MAAM,CAACC,GAAG,CAAC,CAAC;EAE/B,MAAMD,MAAM,GAAG,IAAId,OAAO,CAAc,MAAM;IAC5CY,MAAM,CAACI,mBAAmB,CAAC,OAAO,EAAEH,IAAI,CAAC;IACzC,KAAKI,OAAO,CAACC,UAAU,CAAC,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMD,OAAO,GAAGR,OAAO,CAACU,YAAY,CAAC;IACnCC,MAAM,EAAEjB,WAAW,CAACQ,UAAU,CAAC;IAC/BD,UAAU;IACVW,QAAQ,EAAEA,CAAC;MAAEC,EAAE;MAAEC;IAAK,CAAC,KAAK;MAC1B,MAAMC,OAAO,GAAGD,IAAmB;MAEnCT,MAAM,CAACW,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEJ,EAAE,EAAErB,aAAa,CAACuB,OAAO,CAAC,GAAGF,EAAE,GAAG,IAAI;QAAEE;MAAQ,CAAC,CAAC;IACnF,CAAC;IACDG,qBAAqB,EAAEA,CAAC;MAAEC;IAAO,CAAC,KAAK;MACrC,MAAMC,MAAM,GAAGzB,QAAQ,CAACwB,MAAM,CAAC;MAE/B,IAAIC,MAAM,EAAE;QACVf,MAAM,CAACW,IAAI,CAAC;UAAEC,IAAI,EAAE,QAAQ;UAAEE,MAAM,EAAEC;QAAO,CAAC,CAAC;MACjD;MACA,IAAID,MAAM,KAAK7B,YAAY,CAACQ,YAAY,EAAE;QACxCO,MAAM,CAACC,GAAG,CAAC,CAAC;MACd;IACF,CAAC;IACDe,OAAO,EAAEA,CAAC;MAAEC;IAAM,CAAC,KAAKjB,MAAM,CAACW,IAAI,CAAC;MAAEC,IAAI,EAAE,OAAO;MAAEK,KAAK,EAAE7B,YAAY,CAAC6B,KAAK;IAAE,CAAC;EACnF,CAAC,CAAC;EAEFnB,MAAM,CAACoB,gBAAgB,CAAC,OAAO,EAAEnB,IAAI,EAAE;IAAEoB,IAAI,EAAE;EAAK,CAAC,CAAC;EACtDhB,OAAO,CAACiB,OAAO,CAAC,CAAC,CAACC,KAAK,CAAEJ,KAAc,IAAKjB,MAAM,CAACsB,IAAI,CAAClC,YAAY,CAAC6B,KAAK,CAAC,CAAC,CAAC;EAE7E,OAAOjB,MAAM;AACf,CAAC;AAEH,SAASN,YAAY","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["recordedAtOf","measurement","recordedAt","Date","Number","isNaN","getTime","undefined","ovokReadingSink","client","save","id","device","result","measurements","sourceId","effectiveDateTime","name","key","localName","manufacturerData","manufacturerName","information","model","sn","serialNumber","status","flushQueued","Object","keys","offlineQueue","flush","responses"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react-native/ovok-sink.ts"],"mappings":";;AAIA;AACA,MAAMA,YAAY,GAAIC,WAAmB,IAAuB;EAC9D,MAAM;IAAEC;EAAW,CAAC,GAAGD,WAAuC;EAE9D,OAAOC,UAAU,YAAYC,IAAI,IAAI,CAACC,MAAM,CAACC,KAAK,CAACH,UAAU,CAACI,OAAO,CAAC,CAAC,CAAC,GAAGJ,UAAU,GAAGK,SAAS;AACnG,CAAC;;AAED;AACA,MAAMC,eAAe,GAAIC,MAAY,KAAmB;EACtDC,IAAI,EAAE,MAAAA,CAAO;IAAEC,EAAE;IAAEC,MAAM;IAAEX;EAAY,CAAC,KAAK;IAC3C,MAAMY,MAAM,GAAG,MAAMJ,MAAM,CAACK,YAAY,CAACJ,IAAI,CAAC;MAC5CT,WAAW;MACXc,QAAQ,EAAEJ,EAAE;MACZK,iBAAiB,EAAEhB,YAAY,CAACC,WAAW,CAAC;MAC5CW,MAAM,EAAE;QACND,EAAE,EAAEC,MAAM,CAACD,EAAE;QACbM,IAAI,EAAEL,MAAM,CAACM,GAAG;QAChBC,SAAS,EAAEP,MAAM,CAACK,IAAI;QACtBG,gBAAgB,EAAE,EAAE;QACpBC,gBAAgB,EAAET,MAAM,CAACU,WAAW,EAAED,gBAAgB;QACtDE,KAAK,EAAEX,MAAM,CAACU,WAAW,EAAEC,KAAK;QAChCC,EAAE,EAAEZ,MAAM,CAACU,WAAW,EAAEG,YAAY,IAAI;MAC1C;IACF,CAAC,CAAC;IAEF,OAAOZ,MAAM,CAACa,MAAM,KAAK,OAAO,GAAG;MAAEA,MAAM,EAAE;IAAQ,CAAC,GAAGb,MAAM;EACjE,CAAC;EACDc,WAAW,EAAE,MAAAA,CAAA,KAAYC,MAAM,CAACC,IAAI,CAAC,CAAC,MAAMpB,MAAM,CAACK,YAAY,CAACgB,YAAY,CAACC,KAAK,CAAC,CAAC,EAAEC,SAAS;AACjG,CAAC,CAAC;AAEF,SAASxB,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["recordedAtOf","measurement","recordedAt","Date","Number","isNaN","getTime","undefined","ovokReadingSink","client","save","id","device","result","measurements","sourceId","effectiveDateTime","name","key","localName","manufacturerData","manufacturerName","information","model","sn","serialNumber","status","flushQueued","Object","keys","offlineQueue","flush","responses"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react-native/ovok-sink.ts"],"mappings":";;AAIA;AACA,MAAMA,YAAY,GAAIC,WAA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etoothRuntime } from "../runtime.js";
5
+ import { webBluetoothPermissions } from "./web-bluetooth-permissions.js";
6
+
7
+ /** What `createWebBluetoothRuntime` needs. */
8
+
9
+ /** A `BluetoothRuntime` wired for browsers: Web Bluetooth through `scanner`, saving through `client`. */
10
+ const createWebBluetoothRuntime = ({
11
+ client,
12
+ scanner,
13
+ devices,
14
+ resultPolicy,
15
+ pairedStorage
16
+ }) => new BluetoothRuntime({
17
+ scanner,
18
+ permissions: webBluetoothPermissions(),
19
+ sink: ovokReadingSink(client),
20
+ devices,
21
+ resultPolicy,
22
+ pairedStorage
23
+ });
24
+ export { createWebBluetoothRuntime };
25
+ //# sourceMappingURL=create-web-bluetooth-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ovokReadingSink","BluetoothRuntime","webBluetoothPermissions","createWebBluetoothRuntime","client","scanner","devices","resultPolicy","pairedStorage","permissions","sink"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/create-web-bluetooth-runtime.ts"],"mappings":";;AAGA,SAASA,eAAe,QAAQ,8BAA2B;AAE3D,SAASC,gBAAgB,QAAQ,eAAY;AAE7C,SAASC,uBAAuB,QAAQ,gCAA6B;;AAGrE;;AAmBA;AACA,MAAMC,yBAAyB,GAAGA,CAAC;EACjCC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,YAAY;EACZC;AACgC,CAAC,KACjC,IAAIP,gBAAgB,CAAC;EACnBI,OAAO;EACPI,WAAW,EAAEP,uBAAuB,CAAC,CAAC;EACtCQ,IAAI,EAAEV,eAAe,CAACI,MAAM,CAAC;EAC7BE,OAAO;EACPC,YAAY;EACZC;AACF,CAAC,CAAC;AAEJ,SAASL,yBAAyB","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Bluetooth for `@ovok/native/next` in browsers, over Web Bluetooth: the same `BluetoothRuntime`, devices, result
5
+ * policies and hooks as `@ovok/native/next/bluetooth`, with a Web Bluetooth scanner instead of `react-native-ble-plx`.
6
+ * Nothing here loads `react-native-ble-plx` or `react-native-permissions`, so a web bundle can import it.
7
+ *
8
+ * Import from `@ovok/native/next/bluetooth/web`.
9
+ *
10
+ * @module next/bluetooth/web
11
+ */
12
+ export { createWebBluetoothRuntime } from "./create-web-bluetooth-runtime.js";
13
+ export { isWebBluetoothAvailable, webBluetoothScanner } from "./web-bluetooth-scanner.js";
14
+ export { webBluetoothPermissions } from "./web-bluetooth-permissions.js";
15
+ export { WEB_BLUETOOTH_SERVICES, webBluetoothServicesFor } from "./web-bluetooth-services.js";
16
+ export { BluetoothRuntime } from "../runtime.js";
17
+ export { BluetoothError } from "../errors.js";
18
+ export { defineDevice } from "../devices.js";
19
+ export { acceptedMemorySlots, dailyTotalsOnly, everyReading, firstReadingPerKind, keepReadings, policyByKind } from "../result-policy.js";
20
+ export { SIG_PROTOCOLS } from "../sig-profiles.js";
21
+ export { builtInDevices } from "../ble-plx/built-in-devices.js";
22
+ export { IntegratedDevices } from "../../../bt-management/types/integrated-devices.js";
23
+ export { Devices, SUPPORTED_DEVICES } from "../../../bt-device/constants/supported-devices.js";
24
+ export { resultPoliciesFor } from "../../../bt-device/utils/device-query.js";
25
+ export { ovokReadingSink } from "../react-native/ovok-sink.js";
26
+ export { BluetoothProvider, useBluetooth } from "../react/context.js";
27
+ export { useBluetoothPermission, useBluetoothState, useMeasurements, useNearbyDevice, useNearbyDevices, usePairedDevices, useScanning } from "../react/hooks.js";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createWebBluetoothRuntime","isWebBluetoothAvailable","webBluetoothScanner","webBluetoothPermissions","WEB_BLUETOOTH_SERVICES","webBluetoothServicesFor","BluetoothRuntime","BluetoothError","defineDevice","acceptedMemorySlots","dailyTotalsOnly","everyReading","firstReadingPerKind","keepReadings","policyByKind","SIG_PROTOCOLS","builtInDevices","IntegratedDevices","Devices","SUPPORTED_DEVICES","resultPoliciesFor","ovokReadingSink","BluetoothProvider","useBluetooth","useBluetoothPermission","useBluetoothState","useMeasurements","useNearbyDevice","useNearbyDevices","usePairedDevices","useScanning"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAyB,QAAQ,mCAAgC;AAE1E,SAASC,uBAAuB,EAAEC,mBAAmB,QAAQ,4BAAyB;AAEtF,SAASC,uBAAuB,QAAQ,gCAA6B;AACrE,SAASC,sBAAsB,EAAEC,uBAAuB,QAAQ,6BAA0B;AAE1F,SAASC,gBAAgB,QAAQ,eAAY;AAE7C,SAASC,cAAc,QAAQ,cAAW;AAM1C,SAASC,YAAY,QAAQ,eAAY;AAIzC,SACEC,mBAAmB,EACnBC,eAAe,EACfC,YAAY,EACZC,mBAAmB,EACnBC,YAAY,EACZC,YAAY,QACP,qBAAkB;AAEzB,SAASC,aAAa,QAAQ,oBAAiB;AAC/C,SAASC,cAAc,QAAQ,gCAA6B;AAC5D,SAASC,iBAAiB,QAAQ,oDAAiD;AAEnF,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,mDAAgD;AAE3F,SAASC,iBAAiB,QAAQ,0CAAuC;AACzE,SAASC,eAAe,QAAQ,8BAA2B;AAC3D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,qBAAkB;AAElE,SACEC,sBAAsB,EACtBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,WAAW,QACN,mBAAgB","ignoreList":[]}