@ovok/native 1.16.1-dev.2118 → 1.16.1-dev.2131

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 (315) hide show
  1. package/lib/commonjs/modules/bt-management/components/android-bluetooth-foreground-service.js +3 -1
  2. package/lib/commonjs/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
  3. package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js +9 -141
  4. package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
  5. package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js +160 -0
  6. package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js.map +1 -0
  7. package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js +2 -1
  8. package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
  9. package/lib/commonjs/modules/bt-management/hooks/use-measurements.js +1 -1
  10. package/lib/commonjs/modules/bt-management/hooks/use-measurements.js.map +1 -1
  11. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +1 -1
  12. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  13. package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js +19 -0
  14. package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
  15. package/lib/commonjs/modules/bt-management/utils/result-identity.js +3 -25
  16. package/lib/commonjs/modules/bt-management/utils/result-identity.js.map +1 -1
  17. package/lib/commonjs/modules/next/bluetooth/auto-connect.js +32 -0
  18. package/lib/commonjs/modules/next/bluetooth/auto-connect.js.map +1 -0
  19. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js +33 -0
  20. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
  21. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js +125 -0
  22. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
  23. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js +75 -0
  24. package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
  25. package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js +34 -0
  26. package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
  27. package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js +67 -0
  28. package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
  29. package/lib/commonjs/modules/next/bluetooth/connections.js +110 -0
  30. package/lib/commonjs/modules/next/bluetooth/connections.js.map +1 -0
  31. package/lib/commonjs/modules/next/bluetooth/daily-total-day.js.map +1 -0
  32. package/lib/commonjs/modules/next/bluetooth/devices.js +41 -0
  33. package/lib/commonjs/modules/next/bluetooth/devices.js.map +1 -0
  34. package/lib/commonjs/modules/next/bluetooth/driver.js +24 -20
  35. package/lib/commonjs/modules/next/bluetooth/driver.js.map +1 -1
  36. package/lib/commonjs/modules/next/bluetooth/errors.js +26 -0
  37. package/lib/commonjs/modules/next/bluetooth/errors.js.map +1 -0
  38. package/lib/commonjs/modules/next/bluetooth/index.js +116 -11
  39. package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
  40. package/lib/commonjs/modules/next/bluetooth/link.js +0 -103
  41. package/lib/commonjs/modules/next/bluetooth/link.js.map +1 -1
  42. package/lib/commonjs/modules/next/bluetooth/paired.js +50 -0
  43. package/lib/commonjs/modules/next/bluetooth/paired.js.map +1 -0
  44. package/lib/commonjs/modules/next/bluetooth/permissions.js +2 -0
  45. package/lib/commonjs/modules/next/bluetooth/permissions.js.map +1 -0
  46. package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js +44 -0
  47. package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
  48. package/lib/commonjs/modules/next/bluetooth/react/context.js +54 -0
  49. package/lib/commonjs/modules/next/bluetooth/react/context.js.map +1 -0
  50. package/lib/commonjs/modules/next/bluetooth/react/hooks.js +86 -0
  51. package/lib/commonjs/modules/next/bluetooth/react/hooks.js.map +1 -0
  52. package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +28 -0
  53. package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
  54. package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js +32 -0
  55. package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
  56. package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js +32 -0
  57. package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
  58. package/lib/commonjs/modules/next/bluetooth/readings.js +92 -0
  59. package/lib/commonjs/modules/next/bluetooth/readings.js.map +1 -0
  60. package/lib/commonjs/modules/next/bluetooth/result-policy.js +6 -1
  61. package/lib/commonjs/modules/next/bluetooth/result-policy.js.map +1 -1
  62. package/lib/commonjs/modules/next/bluetooth/runtime.js +223 -0
  63. package/lib/commonjs/modules/next/bluetooth/runtime.js.map +1 -0
  64. package/lib/commonjs/modules/next/bluetooth/scan-loop.js +82 -0
  65. package/lib/commonjs/modules/next/bluetooth/scan-loop.js.map +1 -0
  66. package/lib/commonjs/modules/next/bluetooth/sink.js +6 -0
  67. package/lib/commonjs/modules/next/bluetooth/sink.js.map +1 -0
  68. package/lib/commonjs/modules/next/bluetooth/snapshot.js +6 -0
  69. package/lib/commonjs/modules/next/bluetooth/snapshot.js.map +1 -0
  70. package/lib/commonjs/modules/next/bluetooth/stable-hash.js +33 -0
  71. package/lib/commonjs/modules/next/bluetooth/stable-hash.js.map +1 -0
  72. package/lib/commonjs/modules/next/bluetooth/store.js +61 -0
  73. package/lib/commonjs/modules/next/bluetooth/store.js.map +1 -0
  74. package/lib/commonjs/modules/next/bluetooth/transport.js +6 -0
  75. package/lib/commonjs/modules/next/bluetooth/transport.js.map +1 -0
  76. package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js +3 -1
  77. package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
  78. package/lib/module/modules/bt-management/components/bluetooth-device-picker.js +9 -141
  79. package/lib/module/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
  80. package/lib/module/modules/bt-management/components/device-picker-sheet.js +154 -0
  81. package/lib/module/modules/bt-management/components/device-picker-sheet.js.map +1 -0
  82. package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js +4 -3
  83. package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
  84. package/lib/module/modules/bt-management/hooks/use-measurements.js +1 -1
  85. package/lib/module/modules/bt-management/hooks/use-measurements.js.map +1 -1
  86. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +1 -1
  87. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  88. package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js +14 -0
  89. package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
  90. package/lib/module/modules/bt-management/utils/result-identity.js +3 -25
  91. package/lib/module/modules/bt-management/utils/result-identity.js.map +1 -1
  92. package/lib/module/modules/next/bluetooth/auto-connect.js +28 -0
  93. package/lib/module/modules/next/bluetooth/auto-connect.js.map +1 -0
  94. package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js +28 -0
  95. package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
  96. package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js +122 -0
  97. package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
  98. package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js +69 -0
  99. package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
  100. package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js +31 -0
  101. package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
  102. package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js +63 -0
  103. package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
  104. package/lib/module/modules/next/bluetooth/connections.js +106 -0
  105. package/lib/module/modules/next/bluetooth/connections.js.map +1 -0
  106. package/lib/module/modules/next/bluetooth/daily-total-day.js.map +1 -0
  107. package/lib/module/modules/next/bluetooth/devices.js +37 -0
  108. package/lib/module/modules/next/bluetooth/devices.js.map +1 -0
  109. package/lib/module/modules/next/bluetooth/driver.js +23 -20
  110. package/lib/module/modules/next/bluetooth/driver.js.map +1 -1
  111. package/lib/module/modules/next/bluetooth/errors.js +21 -0
  112. package/lib/module/modules/next/bluetooth/errors.js.map +1 -0
  113. package/lib/module/modules/next/bluetooth/index.js +21 -3
  114. package/lib/module/modules/next/bluetooth/index.js.map +1 -1
  115. package/lib/module/modules/next/bluetooth/link.js +0 -101
  116. package/lib/module/modules/next/bluetooth/link.js.map +1 -1
  117. package/lib/module/modules/next/bluetooth/paired.js +46 -0
  118. package/lib/module/modules/next/bluetooth/paired.js.map +1 -0
  119. package/lib/module/modules/next/bluetooth/permissions.js +2 -0
  120. package/lib/module/modules/next/bluetooth/permissions.js.map +1 -0
  121. package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js +39 -0
  122. package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
  123. package/lib/module/modules/next/bluetooth/react/context.js +48 -0
  124. package/lib/module/modules/next/bluetooth/react/context.js.map +1 -0
  125. package/lib/module/modules/next/bluetooth/react/hooks.js +76 -0
  126. package/lib/module/modules/next/bluetooth/react/hooks.js.map +1 -0
  127. package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +25 -0
  128. package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
  129. package/lib/module/modules/next/bluetooth/react-native/os-permissions.js +28 -0
  130. package/lib/module/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
  131. package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js +28 -0
  132. package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
  133. package/lib/module/modules/next/bluetooth/readings.js +88 -0
  134. package/lib/module/modules/next/bluetooth/readings.js.map +1 -0
  135. package/lib/module/modules/next/bluetooth/result-policy.js +6 -1
  136. package/lib/module/modules/next/bluetooth/result-policy.js.map +1 -1
  137. package/lib/module/modules/next/bluetooth/runtime.js +220 -0
  138. package/lib/module/modules/next/bluetooth/runtime.js.map +1 -0
  139. package/lib/module/modules/next/bluetooth/scan-loop.js +78 -0
  140. package/lib/module/modules/next/bluetooth/scan-loop.js.map +1 -0
  141. package/lib/module/modules/next/bluetooth/sink.js +4 -0
  142. package/lib/module/modules/next/bluetooth/sink.js.map +1 -0
  143. package/lib/module/modules/next/bluetooth/snapshot.js +4 -0
  144. package/lib/module/modules/next/bluetooth/snapshot.js.map +1 -0
  145. package/lib/module/modules/next/bluetooth/stable-hash.js +28 -0
  146. package/lib/module/modules/next/bluetooth/stable-hash.js.map +1 -0
  147. package/lib/module/modules/next/bluetooth/store.js +57 -0
  148. package/lib/module/modules/next/bluetooth/store.js.map +1 -0
  149. package/lib/module/modules/next/bluetooth/transport.js +4 -0
  150. package/lib/module/modules/next/bluetooth/transport.js.map +1 -0
  151. package/lib/typescript/commonjs/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
  153. package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
  155. package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/modules/bt-management/utils/bluetooth-permission-list.d.ts +4 -0
  160. package/lib/typescript/commonjs/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
  163. package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
  165. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
  167. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
  169. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
  171. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
  173. package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts +25 -0
  175. package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts +30 -0
  178. package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts +21 -19
  180. package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts +17 -0
  182. package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +32 -3
  184. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
  185. package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts +2 -4
  186. package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts.map +1 -1
  187. package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts +18 -0
  188. package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts +13 -0
  190. package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
  192. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts +30 -0
  194. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
  196. package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
  198. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
  200. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
  202. package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts +21 -0
  204. package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts +3 -0
  206. package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
  207. package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts +87 -0
  208. package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
  209. package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
  210. package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
  211. package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts +20 -0
  212. package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts.map +1 -0
  213. package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts +69 -0
  214. package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
  215. package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
  216. package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
  217. package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts +16 -0
  218. package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts.map +1 -0
  219. package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts +31 -0
  220. package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts.map +1 -0
  221. package/lib/typescript/module/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
  222. package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
  223. package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
  224. package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
  225. package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
  226. package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
  227. package/lib/typescript/module/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -1
  228. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  229. package/lib/typescript/module/src/modules/bt-management/utils/bluetooth-permission-list.d.ts +4 -0
  230. package/lib/typescript/module/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
  231. package/lib/typescript/module/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
  232. package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
  233. package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
  234. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
  235. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
  236. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
  237. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
  238. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
  239. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
  240. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
  241. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
  242. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
  243. package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
  244. package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts +25 -0
  245. package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts.map +1 -0
  246. package/lib/typescript/module/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
  247. package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts +30 -0
  248. package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts.map +1 -0
  249. package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts +21 -19
  250. package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts.map +1 -1
  251. package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts +17 -0
  252. package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts.map +1 -0
  253. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +32 -3
  254. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
  255. package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts +2 -4
  256. package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts.map +1 -1
  257. package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts +18 -0
  258. package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts.map +1 -0
  259. package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts +13 -0
  260. package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
  261. package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
  262. package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
  263. package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts +30 -0
  264. package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
  265. package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
  266. package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
  267. package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
  268. package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
  269. package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
  270. package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
  271. package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
  272. package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
  273. package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts +21 -0
  274. package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts.map +1 -0
  275. package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts +3 -0
  276. package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
  277. package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts +87 -0
  278. package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
  279. package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
  280. package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
  281. package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts +20 -0
  282. package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts.map +1 -0
  283. package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts +69 -0
  284. package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
  285. package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
  286. package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
  287. package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts +16 -0
  288. package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts.map +1 -0
  289. package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts +31 -0
  290. package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts.map +1 -0
  291. package/package.json +1 -1
  292. package/lib/commonjs/modules/bt-management/utils/daily-total-day.js.map +0 -1
  293. package/lib/commonjs/modules/next/bluetooth/drivers.js +0 -20
  294. package/lib/commonjs/modules/next/bluetooth/drivers.js.map +0 -1
  295. package/lib/commonjs/modules/next/bluetooth/legacy-driver.js +0 -55
  296. package/lib/commonjs/modules/next/bluetooth/legacy-driver.js.map +0 -1
  297. package/lib/module/modules/bt-management/utils/daily-total-day.js.map +0 -1
  298. package/lib/module/modules/next/bluetooth/drivers.js +0 -17
  299. package/lib/module/modules/next/bluetooth/drivers.js.map +0 -1
  300. package/lib/module/modules/next/bluetooth/legacy-driver.js +0 -51
  301. package/lib/module/modules/next/bluetooth/legacy-driver.js.map +0 -1
  302. package/lib/typescript/commonjs/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
  303. package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts +0 -7
  304. package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
  305. package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
  306. package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
  307. package/lib/typescript/module/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
  308. package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts +0 -7
  309. package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
  310. package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
  311. package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
  312. /package/lib/commonjs/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
  313. /package/lib/module/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
  314. /package/lib/typescript/commonjs/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
  315. /package/lib/typescript/module/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useScanning = exports.usePairedDevices = exports.useNearbyDevices = exports.useNearbyDevice = exports.useMeasurements = exports.useBluetoothState = exports.useBluetoothPermission = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _context = require("./context.js");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ /** One slice of the runtime snapshot, re-rendering only when that slice changes. */
12
+ const useSnapshot = select => {
13
+ const runtime = (0, _context.useBluetooth)();
14
+ const read = () => select(runtime.getSnapshot());
15
+ return React.useSyncExternalStore(runtime.subscribe, read, read);
16
+ };
17
+
18
+ /**
19
+ * The Bluetooth adapter state.
20
+ *
21
+ * @group Hooks
22
+ */
23
+ const useBluetoothState = () => useSnapshot(snapshot => snapshot.adapter);
24
+
25
+ /**
26
+ * The Bluetooth permission, re-checked whenever the app returns to the foreground; `unknown` until first checked.
27
+ *
28
+ * @group Hooks
29
+ */
30
+ exports.useBluetoothState = useBluetoothState;
31
+ const useBluetoothPermission = () => {
32
+ const runtime = (0, _context.useBluetooth)();
33
+ React.useEffect(() => {
34
+ const subscription = _reactNative.AppState.addEventListener("change", state => {
35
+ if (state === "active") {
36
+ runtime.checkPermission().catch(() => undefined);
37
+ }
38
+ });
39
+ return () => subscription.remove();
40
+ }, [runtime]);
41
+ return useSnapshot(snapshot => snapshot.permission);
42
+ };
43
+
44
+ /**
45
+ * Whether a scan is requested.
46
+ *
47
+ * @group Hooks
48
+ */
49
+ exports.useBluetoothPermission = useBluetoothPermission;
50
+ const useScanning = () => useSnapshot(snapshot => snapshot.scanning);
51
+
52
+ /**
53
+ * The supported devices the scan found, each with its connection state.
54
+ *
55
+ * @group Hooks
56
+ */
57
+ exports.useScanning = useScanning;
58
+ const useNearbyDevices = () => useSnapshot(snapshot => snapshot.devices);
59
+
60
+ /**
61
+ * One found device, or `null` until the scan finds it.
62
+ *
63
+ * @group Hooks
64
+ */
65
+ exports.useNearbyDevices = useNearbyDevices;
66
+ const useNearbyDevice = deviceId => useSnapshot(snapshot => snapshot.devices.find(({
67
+ id
68
+ }) => id === deviceId) ?? null);
69
+
70
+ /**
71
+ * IDs of the paired devices.
72
+ *
73
+ * @group Hooks
74
+ */
75
+ exports.useNearbyDevice = useNearbyDevice;
76
+ const usePairedDevices = () => useSnapshot(snapshot => snapshot.paired);
77
+
78
+ /**
79
+ * The recent readings, oldest first, each with its save state.
80
+ *
81
+ * @group Hooks
82
+ */
83
+ exports.usePairedDevices = usePairedDevices;
84
+ const useMeasurements = () => useSnapshot(snapshot => snapshot.readings);
85
+ exports.useMeasurements = useMeasurements;
86
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_context","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useSnapshot","select","runtime","useBluetooth","read","getSnapshot","useSyncExternalStore","subscribe","useBluetoothState","snapshot","adapter","exports","useBluetoothPermission","useEffect","subscription","AppState","addEventListener","state","checkPermission","catch","undefined","remove","permission","useScanning","scanning","useNearbyDevices","devices","useNearbyDevice","deviceId","find","id","usePairedDevices","paired","useMeasurements","readings"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react/hooks.ts"],"mappings":";;;;;;AAAA,IA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ME,eAAe,GAAIC,QAAgB,IACvC5B,WAAW,CAAES,QAAQ,IAAKA,QAAQ,CAACiB,OAAO,CAACG,IAAI,CAAC,CAAC;EAAEC;AAAG,CAAC,KAAKA,EAAE,KAAKF,QAAQ,CAAC,IAAI,IAAI,CAAC;;AAEvF;AACA;AACA;AACA;AACA;AAJAjB,OAAA,CAAAgB,eAAA,GAAAA,eAAA;AAKA,MAAMI,gBAAgB,GAAGA,CAAA,KAAyB/B,WAAW,CAAES,QAAQ,IAAKA,QAAQ,CAACuB,MAAM,CAAC;;AAE5F;AACA;AACA;AACA;AACA;AAJArB,OAAA,CAAAoB,gBAAA,GAAAA,gBAAA;AAKA,MAAME,eAAe,GAAGA,CAAA,KAAgCjC,WAAW,CAAES,QAAQ,IAAKA,QAAQ,CAACyB,QAAQ,CAAC;AAACvB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createBluetoothRuntime = void 0;
7
+ var _bleScanner = require("../ble-plx/ble-scanner.js");
8
+ var _runtime = require("../runtime.js");
9
+ var _osPermissions = require("./os-permissions.js");
10
+ var _ovokSink = require("./ovok-sink.js");
11
+ /** What `createBluetoothRuntime` needs. */
12
+
13
+ /** A `BluetoothRuntime` wired for React Native: BLE through `bleManager`, OS permissions, saving through `client`. */
14
+ const createBluetoothRuntime = ({
15
+ client,
16
+ bleManager,
17
+ devices,
18
+ resultPolicy
19
+ }) => new _runtime.BluetoothRuntime({
20
+ scanner: (0, _bleScanner.bleManagerScanner)(bleManager),
21
+ permissions: (0, _osPermissions.osBluetoothPermissions)(),
22
+ sink: (0, _ovokSink.ovokReadingSink)(client),
23
+ devices,
24
+ resultPolicy,
25
+ pairedStorage: client.storage
26
+ });
27
+ exports.createBluetoothRuntime = createBluetoothRuntime;
28
+ //# sourceMappingURL=create-bluetooth-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_bleScanner","require","_runtime","_osPermissions","_ovokSink","createBluetoothRuntime","client","bleManager","devices","resultPolicy","BluetoothRuntime","scanner","bleManagerScanner","permissions","osBluetoothPermissions","sink","ovokReadingSink","pairedStorage","storage","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react-native/create-bluetooth-runtime.ts"],"mappings":";;;;;;AAIA,IAAAA,WAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA;;AAgBA;AACA,MAAMI,sBAAsB,GAAGA,CAAC;EAC9BC,MAAM;EACNC,UAAU;EACVC,OAAO;EACPC;AAC6B,CAAC,KAC9B,IAAIC,yBAAgB,CAAC;EACnBC,OAAO,EAAE,IAAAC,6BAAiB,EAACL,UAAU,CAAC;EACtCM,WAAW,EAAE,IAAAC,qCAAsB,EAAC,CAAC;EACrCC,IAAI,EAAE,IAAAC,yBAAe,EAACV,MAAM,CAAC;EAC7BE,OAAO;EACPC,YAAY;EACZQ,aAAa,EAAEX,MAAM,CAACY;AACxB,CAAC,CAAC;AAACC,OAAA,CAAAd,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.osBluetoothPermissions = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _reactNativePermissions = require("react-native-permissions");
9
+ var _bluetoothPermissionList = require("../../../bt-management/utils/bluetooth-permission-list.js");
10
+ const GRANTED = new Set(["granted", "limited"]);
11
+ const permissionOf = (permissions, results) => {
12
+ const statuses = permissions.map(permission => results[permission]);
13
+ if (statuses.length > 0 && statuses.every(status => status !== undefined && GRANTED.has(status))) {
14
+ return "granted";
15
+ }
16
+ return statuses.includes("blocked") ? "blocked" : "denied";
17
+ };
18
+
19
+ /** The platform's Bluetooth permissions through `react-native-permissions`. */
20
+ const osBluetoothPermissions = () => ({
21
+ check: async () => {
22
+ const permissions = (0, _bluetoothPermissionList.bluetoothPermissionList)();
23
+ return permissionOf(permissions, await (0, _reactNativePermissions.checkMultiple)(permissions));
24
+ },
25
+ request: async () => {
26
+ const permissions = (0, _bluetoothPermissionList.bluetoothPermissionList)();
27
+ return permissionOf(permissions, await (0, _reactNativePermissions.requestMultiple)(permissions));
28
+ },
29
+ openSettings: () => _reactNative.Linking.openSettings()
30
+ });
31
+ exports.osBluetoothPermissions = osBluetoothPermissions;
32
+ //# sourceMappingURL=os-permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_reactNativePermissions","_bluetoothPermissionList","GRANTED","Set","permissionOf","permissions","results","statuses","map","permission","length","every","status","undefined","has","includes","osBluetoothPermissions","check","bluetoothPermissionList","checkMultiple","request","requestMultiple","openSettings","Linking","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react-native/os-permissions.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,wBAAA,GAAAF,OAAA;AAGA,MAAMG,OAAsC,GAAG,IAAIC,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAE9E,MAAMC,YAAY,GAAGA,CACnBC,WAAkC,EAClCC,OAAsD,KAC9B;EACxB,MAAMC,QAAQ,GAAGF,WAAW,CAACG,GAAG,CAAEC,UAAU,IAAKH,OAAO,CAACG,UAAU,CAAC,CAAC;EAErE,IAAIF,QAAQ,CAACG,MAAM,GAAG,CAAC,IAAIH,QAAQ,CAACI,KAAK,CAAEC,MAAM,IAAKA,MAAM,KAAKC,SAAS,IAAIX,OAAO,CAACY,GAAG,CAACF,MAAM,CAAC,CAAC,EAAE;IAClG,OAAO,SAAS;EAClB;EAEA,OAAOL,QAAQ,CAACQ,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,QAAQ;AAC5D,CAAC;;AAED;AACA,MAAMC,sBAAsB,GAAGA,CAAA,MAA6B;EAC1DC,KAAK,EAAE,MAAAA,CAAA,KAAY;IACjB,MAAMZ,WAAW,GAAG,IAAAa,gDAAuB,EAAC,CAAC;IAE7C,OAAOd,YAAY,CAACC,WAAW,EAAE,MAAM,IAAAc,qCAAa,EAACd,WAAW,CAAC,CAAC;EACpE,CAAC;EACDe,OAAO,EAAE,MAAAA,CAAA,KAAY;IACnB,MAAMf,WAAW,GAAG,IAAAa,gDAAuB,EAAC,CAAC;IAE7C,OAAOd,YAAY,CAACC,WAAW,EAAE,MAAM,IAAAgB,uCAAe,EAAChB,WAAW,CAAC,CAAC;EACtE,CAAC;EACDiB,YAAY,EAAEA,CAAA,KAAMC,oBAAO,CAACD,YAAY,CAAC;AAC3C,CAAC,CAAC;AAACE,OAAA,CAAAR,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ovokReadingSink = void 0;
7
+ /** Saves readings for the signed-in account through the `Ovok` measurements API. */
8
+ const ovokReadingSink = client => ({
9
+ save: async ({
10
+ id,
11
+ device,
12
+ measurement
13
+ }) => {
14
+ const result = await client.measurements.save({
15
+ measurement,
16
+ sourceId: id,
17
+ device: {
18
+ id: device.id,
19
+ name: device.key,
20
+ localName: device.name,
21
+ manufacturerData: "",
22
+ sn: ""
23
+ }
24
+ });
25
+ return result.status === "saved" ? {
26
+ status: "saved"
27
+ } : result;
28
+ },
29
+ flushQueued: async () => Object.keys((await client.measurements.offlineQueue.flush()).responses)
30
+ });
31
+ exports.ovokReadingSink = ovokReadingSink;
32
+ //# sourceMappingURL=ovok-sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ovokReadingSink","client","save","id","device","measurement","result","measurements","sourceId","name","key","localName","manufacturerData","sn","status","flushQueued","Object","keys","offlineQueue","flush","responses","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react-native/ovok-sink.ts"],"mappings":";;;;;;AAIA;AACA,MAAMA,eAAe,GAAIC,MAAY,KAAmB;EACtDC,IAAI,EAAE,MAAAA,CAAO;IAAEC,EAAE;IAAEC,MAAM;IAAEC;EAAY,CAAC,KAAK;IAC3C,MAAMC,MAAM,GAAG,MAAML,MAAM,CAACM,YAAY,CAACL,IAAI,CAAC;MAC5CG,WAAW;MACXG,QAAQ,EAAEL,EAAE;MACZC,MAAM,EAAE;QAAED,EAAE,EAAEC,MAAM,CAACD,EAAE;QAAEM,IAAI,EAAEL,MAAM,CAACM,GAAG;QAAEC,SAAS,EAAEP,MAAM,CAACK,IAAI;QAAEG,gBAAgB,EAAE,EAAE;QAAEC,EAAE,EAAE;MAAG;IAClG,CAAC,CAAC;IAEF,OAAOP,MAAM,CAACQ,MAAM,KAAK,OAAO,GAAG;MAAEA,MAAM,EAAE;IAAQ,CAAC,GAAGR,MAAM;EACjE,CAAC;EACDS,WAAW,EAAE,MAAAA,CAAA,KAAYC,MAAM,CAACC,IAAI,CAAC,CAAC,MAAMhB,MAAM,CAACM,YAAY,CAACW,YAAY,CAACC,KAAK,CAAC,CAAC,EAAEC,SAAS;AACjG,CAAC,CAAC;AAACC,OAAA,CAAArB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReadingLog = void 0;
7
+ var _errors = require("./errors.js");
8
+ const KEPT_READINGS = 100;
9
+
10
+ /** How many recent reading IDs a resend is checked against. */
11
+ const RECOGNISED_READINGS = 1_000;
12
+ const saveFailed = error => new _errors.BluetoothError("save-failed", error instanceof Error ? error.message : String(error), error);
13
+
14
+ /** Keeps the recent readings, each resend once, and saves every new one through the sink. */
15
+ class ReadingLog {
16
+ recent = new Set();
17
+ sequence = 0;
18
+ constructor(store, sink) {
19
+ this.store = store;
20
+ this.sink = sink;
21
+ }
22
+
23
+ /** `id` is `null` for a reading that cannot be recognised when resent. */
24
+ receive(device, id, measurement) {
25
+ if (id !== null && !this.remember(id)) {
26
+ return;
27
+ }
28
+ const receivedAt = new Date();
29
+ const reading = {
30
+ id: id ?? `${device.id}:${receivedAt.getTime()}:${this.sequence += 1}`,
31
+ device: {
32
+ id: device.id,
33
+ key: device.key,
34
+ name: device.name
35
+ },
36
+ measurement,
37
+ receivedAt,
38
+ save: {
39
+ status: "saving"
40
+ }
41
+ };
42
+ this.store.set({
43
+ readings: [...this.store.get().readings, reading].slice(-KEPT_READINGS)
44
+ });
45
+ void this.save(reading);
46
+ }
47
+
48
+ /** Saves the readings whose save failed again and flushes the sink's offline queue. */
49
+ async retrySaves() {
50
+ const failed = this.store.get().readings.filter(({
51
+ save
52
+ }) => save.status === "failed");
53
+ this.store.updateReadings(reading => failed.includes(reading) ? {
54
+ ...reading,
55
+ save: {
56
+ status: "saving"
57
+ }
58
+ } : reading);
59
+ await Promise.all(failed.map(reading => this.save(reading)));
60
+ const flushed = new Set(await this.sink.flushQueued());
61
+ this.store.updateReadings(reading => reading.save.status === "queued" && flushed.has(reading.save.queueId) ? {
62
+ ...reading,
63
+ save: {
64
+ status: "saved"
65
+ }
66
+ } : reading);
67
+ }
68
+
69
+ /** Records `id`; false when it is a resend of a recent reading. */
70
+ remember(id) {
71
+ if (this.recent.has(id)) {
72
+ return false;
73
+ }
74
+ this.recent.add(id);
75
+ if (this.recent.size > RECOGNISED_READINGS) {
76
+ this.recent.delete(this.recent.values().next().value);
77
+ }
78
+ return true;
79
+ }
80
+ async save(reading) {
81
+ const save = await this.sink.save(reading).then(result => result, error => ({
82
+ status: "failed",
83
+ error: saveFailed(error)
84
+ }));
85
+ this.store.updateReadings(current => current.id === reading.id ? {
86
+ ...current,
87
+ save
88
+ } : current);
89
+ }
90
+ }
91
+ exports.ReadingLog = ReadingLog;
92
+ //# sourceMappingURL=readings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","KEPT_READINGS","RECOGNISED_READINGS","saveFailed","error","BluetoothError","Error","message","String","ReadingLog","recent","Set","sequence","constructor","store","sink","receive","device","id","measurement","remember","receivedAt","Date","reading","getTime","key","name","save","status","set","readings","get","slice","retrySaves","failed","filter","updateReadings","includes","Promise","all","map","flushed","flushQueued","has","queueId","add","size","delete","values","next","value","then","result","current","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/readings.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAKA,MAAMC,aAAa,GAAG,GAAG;;AAEzB;AACA,MAAMC,mBAAmB,GAAG,KAAK;AAEjC,MAAMC,UAAU,GAAIC,KAAc,IAChC,IAAIC,sBAAc,CAAC,aAAa,EAAED,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACG,OAAO,GAAGC,MAAM,CAACJ,KAAK,CAAC,EAAEA,KAAK,CAAC;;AAElG;AACA,MAAMK,UAAU,CAAC;EACEC,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;EACnCC,QAAQ,GAAG,CAAC;EAEbC,WAAWA,CAAkBC,KAAoB,EAAmBC,IAAiB,EAAE;IAAA,KAA1DD,KAAoB,GAApBA,KAAoB;IAAA,KAAmBC,IAAiB,GAAjBA,IAAiB;EAAG;;EAE/F;EACOC,OAAOA,CAACC,MAAoB,EAAEC,EAAiB,EAAEC,WAAwB,EAAQ;IACtF,IAAID,EAAE,KAAK,IAAI,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACF,EAAE,CAAC,EAAE;MACrC;IACF;IAEA,MAAMG,UAAU,GAAG,IAAIC,IAAI,CAAC,CAAC;IAE7B,MAAMC,OAAsB,GAAG;MAC7BL,EAAE,EAAEA,EAAE,IAAI,GAAGD,MAAM,CAACC,EAAE,IAAIG,UAAU,CAACG,OAAO,CAAC,CAAC,IAAK,IAAI,CAACZ,QAAQ,IAAI,CAAC,EAAG;MACxEK,MAAM,EAAE;QAAEC,EAAE,EA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,IAAI,CAACiB,OAAO,CAAC,GACjE;MAAE,GAAGrB,OAAO;MAAEI,IAAI,EAAE;QAAEC,MAAM,EAAE;MAAQ;IAAE,CAAC,GACzCL,OAAO,CAAC;EAChB;;EAEA;EACQH,QAAQA,CAACF,EAAU,EAAW;IACpC,IAAI,IAAI,CAACR,MAAM,CAACiC,GAAG,CAACzB,EAAE,CAAC,EAAE;MACvB,OAAO,KAAK;IACd;IAEA,IAAI,CAACR,MAAM,CAACmC,GAAG,CAAC3B,EAAE,CAAC;IACnB,IAAI,IAAI,CAACR,MAAM,CAACoC,IAAI,GAAG5C,mBAAmB,EAAE;MAC1C,IAAI,CAACQ,MAAM,CAACqC,MAAM,CAAC,IAAI,CAACrC,MAAM,CAACsC,MAAM,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,KAAe,CAAC;IACjE;IAEA,OAAO,IAAI;EACb;EAEA,MAAcvB,IAAIA,CAACJ,OAAsB,EAAiB;IACxD,MAAMI,IAAe,GAAG,MAAM,IAAI,CAACZ,IAAI,CAACY,IAAI,CAACJ,OAAO,CAAC,CAAC4B,IAAI,CACvDC,MAAkB,IAAgBA,MAAM,EACxChD,KAAc,KAAiB;MAAEwB,MAAM,EAAE,QAAQ;MAAExB,KAAK,EAAED,UAAU,CAACC,KAAK;IAAE,CAAC,CAChF,CAAC;IAED,IAAI,CAACU,KAAK,CAACsB,cAAc,CAAEiB,OAAO,IAAMA,OAAO,CAACnC,EAAE,KAAKK,OAAO,CAACL,EAAE,GAAG;MAAE,GAAGmC,OAAO;MAAE1B;IAAK,CAAC,GAAG0B,OAAQ,CAAC;EACtG;AACF;AAACC,OAAA,CAAA7C,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -6,10 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.firstReadingPerKind = exports.everyReading = exports.dailyTotalsOnly = void 0;
7
7
  exports.keepReadings = keepReadings;
8
8
  exports.policyByKind = void 0;
9
- var _dailyTotalDay = require("../../bt-management/utils/daily-total-day.js");
9
+ var _dailyTotalDay = require("./daily-total-day.js");
10
10
  /** Makes, for each connection, the test of which readings to keep. */
11
11
 
12
+ /** Keeps every reading. */
12
13
  const everyReading = () => () => true;
14
+
15
+ /** Keeps the first reading of each measurement type per connection. */
13
16
  exports.everyReading = everyReading;
14
17
  const firstReadingPerKind = () => {
15
18
  const reported = new Set();
@@ -41,6 +44,8 @@ const dailyTotalsOnly = () => {
41
44
  return true;
42
45
  };
43
46
  };
47
+
48
+ /** Applies a policy per measurement type, and `fallback` to the other types. */
44
49
  exports.dailyTotalsOnly = dailyTotalsOnly;
45
50
  const policyByKind = (policies, fallback = everyReading) => () => {
46
51
  const tests = new Map();
@@ -1 +1 @@
1
- {"version":3,"names":["_dailyTotalDay","require","everyReading","exports","firstReadingPerKind","reported","Set","measurementTypeKey","has","add","dailyTotalsOnly","reading","day","dailyTotalDay","Date","now","undefined","key","policyByKind","policies","fallback","tests","Map","fallbackTest","policy","test","get","set","keepReadings","events","keep","event","kind"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/result-policy.ts"],"mappings":";;;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAIA;;AAGA,MAAMC,YAA0B,GAAGA,CAAA,KAAM,MAAM,IAAI;AAACC,OAAA,CAAAD,YAAA,GAAAA,YAAA;AAEpD,MAAME,mBAAiC,GAAGA,CAAA,KAAM;EAC9C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAqB,CAAC;EAE9C,OAAO,CAAC;IAAEC;EAAmB,CAAC,KAAK;IACjC,IAAIF,QAAQ,CAACG,GAAG,CAACD,kBAAkB,CAAC,EAAE;MACpC,OAAO,KAAK;IACd;IAEAF,QAAQ,CAACI,GAAG,CAACF,kBAAkB,CAAC;IAEhC,OAAO,IAAI;EACb,CAAC;AACH,CAAC;;AAED;AAAAJ,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AACA,MAAMM,eAA6B,GAAGA,CAAA,KAAM;EAC1C,MAAML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jH,MAAMM,IAAI,GAAGN,MAAM,CAAC,CAAC;EAErB,WAAW,MAAMO,KAAK,IAAIF,MAAM,EAAE;IAChC,IAAIE,KAAK,CAACC,IAAI,KAAK,SAAS,IAAIF,IAAI,CAACC,KAAK,CAACpB,OAAO,CAAC,EAAE;MACnD,MAAMoB,KAAK;IACb;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_dailyTotalDay","require","everyReading","exports","firstReadingPerKind","reported","Set","measurementTypeKey","has","add","dailyTotalsOnly","reading","day","dailyTotalDay","Date","now","undefined","key","policyByKind","policies","fallback","tests","Map","fallbackTest","policy","test","get","set","keepReadings","events","keep","event","kind"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/result-policy.ts"],"mappings":";;;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAGA;;AAGA;AACA,MAAMC,YAA0B,GAAGA,CAAA,KAAM,MAAM,IAAI;;AAEnD;AAAAC,OAAA,CAAAD,YAAA,GAAAA,YAAA;AACA,MAAME,mBAAiC,GAAGA,CAAA,KAAM;EAC9C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAqB,CAAC;EAE9C,OAAO,CAAC;IAAEC;EAAmB,CAAC,KAAK;IACjC,IAAIF,QAAQ,CAACG,GAAG,CAACD,kBAAkB,CAAC,EAAE;MACpC,OAAO,KAAK;IACd;IAEAF,QAAQ,CAACI,GAAG,CAACF,kBAAkB,CAAC;IAEhC,OAAO,IAAI;EACb,CAAC;AACH,CAAC;;AAED;AAAAJ,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AACA,MAAMM,eAA6B,GAAGA,CAAA,KAAM;EAC1C,MAAML,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAElC,OAAQK,OAAO,IAAK;IAClB,MAAMC,GAAG,GAAG,IAAAC,4BAAa,EAACF,OAAO,EAAEG,IAAI,CAACC,GAAG,CAAC,CAAC,CAAC;IAE9C,IAAIH,GAAG,KAAKI,SAAS,EAAE;MACrB,O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IACb;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BluetoothRuntime = void 0;
7
+ var _autoConnect = require("./auto-connect.js");
8
+ var _connections = require("./connections.js");
9
+ var _devices = require("./devices.js");
10
+ var _errors = require("./errors.js");
11
+ var _paired = require("./paired.js");
12
+ var _readings = require("./readings.js");
13
+ var _resultPolicy = require("./result-policy.js");
14
+ var _scanLoop = require("./scan-loop.js");
15
+ var _store = require("./store.js");
16
+ /** What a `BluetoothRuntime` is built from. */
17
+
18
+ /**
19
+ * Scans for supported devices, connects to them, collects their readings and saves each one. Framework-free: React
20
+ * hooks and components sit on top of it. Every failure is a `BluetoothError`. Call `dispose()` when done.
21
+ */
22
+ class BluetoothRuntime {
23
+ store = new _store.SnapshotStore();
24
+ known = new Map();
25
+ held = new Set();
26
+ backoff = new _autoConnect.AutoConnectBackoff();
27
+ retryTimers = new Set();
28
+ scanRequest = 0;
29
+ disposed = false;
30
+ constructor(options) {
31
+ this.options = options;
32
+ this.readings = new _readings.ReadingLog(this.store, options.sink);
33
+ this.connections = new _connections.Connections(this.store, this.readings, options.resultPolicy ?? _resultPolicy.everyReading, id => this.connectionEnded(id));
34
+ this.paired = new _paired.PairedDevices(paired => this.store.set({
35
+ paired
36
+ }), options.pairedStorage);
37
+ this.scan = new _scanLoop.ScanLoop(options.scanner, this.store, peripheral => this.found(peripheral));
38
+ this.unwatchAdapter = options.scanner.watchState(adapter => {
39
+ this.store.set({
40
+ adapter
41
+ });
42
+ this.scan.sync();
43
+ });
44
+ void this.checkPermission().catch(() => undefined);
45
+ }
46
+
47
+ /** The current state. */
48
+ getSnapshot = () => this.store.get();
49
+
50
+ /** Calls `listener` after every state change; returns the unsubscribe. */
51
+ subscribe = listener => this.store.subscribe(listener);
52
+
53
+ /** Reads the permission without prompting. */
54
+ async checkPermission() {
55
+ return this.recordPermission(await this.options.permissions.check());
56
+ }
57
+
58
+ /** Prompts for the permission when the OS still can. */
59
+ async requestPermission() {
60
+ return this.recordPermission(await this.options.permissions.request());
61
+ }
62
+
63
+ /** Opens the app's system settings, where a blocked permission can be granted. */
64
+ openPermissionSettings() {
65
+ return this.options.permissions.openSettings();
66
+ }
67
+
68
+ /**
69
+ * Asks for permission when needed, then scans whenever the adapter is on, until `stopScan`.
70
+ *
71
+ * @throws BluetoothError `permission-denied` when permission is not granted; `runtime-disposed` after `dispose`.
72
+ */
73
+ async startScan() {
74
+ this.assertLive();
75
+ const request = ++this.scanRequest;
76
+ const permission = this.store.get().permission === "granted" ? "granted" : await this.requestPermission();
77
+ if (permission !== "granted") {
78
+ throw new _errors.BluetoothError("permission-denied", "Bluetooth permission is not granted");
79
+ }
80
+ if (request === this.scanRequest && !this.disposed) {
81
+ this.store.set({
82
+ scanning: true
83
+ });
84
+ this.scan.sync();
85
+ }
86
+ }
87
+
88
+ /** Stops scanning; connected devices stay connected. */
89
+ stopScan() {
90
+ this.scanRequest += 1;
91
+ this.store.set({
92
+ scanning: false
93
+ });
94
+ this.scan.sync();
95
+ }
96
+
97
+ /**
98
+ * Connects to a found device for this session; resolves once connected.
99
+ *
100
+ * @throws BluetoothError `device-not-found`, `connection-failed` or the driver's failure.
101
+ */
102
+ async connect(deviceId) {
103
+ this.assertLive();
104
+ const {
105
+ peripheral,
106
+ match
107
+ } = this.require(deviceId);
108
+ this.held.delete(deviceId);
109
+ await this.connections.connect(peripheral, match.driver);
110
+ }
111
+
112
+ /** Disconnects a device; a paired one stays disconnected until `connect` or `pair` is called again. */
113
+ async disconnect(deviceId) {
114
+ this.held.add(deviceId);
115
+ await this.connections.disconnect(deviceId);
116
+ }
117
+
118
+ /** Remembers a device, so it connects whenever the scan finds it, and connects to it now. */
119
+ async pair(deviceId) {
120
+ this.require(deviceId);
121
+ await this.paired.add(deviceId);
122
+ await this.connect(deviceId);
123
+ }
124
+
125
+ /** Forgets a paired device and disconnects it. */
126
+ async forget(deviceId) {
127
+ await this.paired.remove(deviceId);
128
+ await this.disconnect(deviceId);
129
+ }
130
+
131
+ /** Saves the readings whose save failed again, and the readings the sink queued offline. */
132
+ retrySaves() {
133
+ return this.readings.retrySaves();
134
+ }
135
+
136
+ /** Stops scanning and disconnects every device; resolves once they have disconnected, after which nothing changes. */
137
+ async dispose() {
138
+ if (this.disposed) {
139
+ return;
140
+ }
141
+ this.stopScan();
142
+ this.disposed = true;
143
+ this.scan.close();
144
+ this.unwatchAdapter();
145
+ this.retryTimers.forEach(clearTimeout);
146
+ await this.connections.disconnectAll();
147
+ this.store.close();
148
+ }
149
+ recordPermission(permission) {
150
+ this.store.set({
151
+ permission
152
+ });
153
+ return permission;
154
+ }
155
+ found(peripheral) {
156
+ const known = this.known.get(peripheral.id);
157
+ const match = known?.match ?? (0, _devices.matchDevice)(this.options.devices, peripheral.advertisement);
158
+ if (!match) {
159
+ return;
160
+ }
161
+ this.known.set(peripheral.id, {
162
+ peripheral,
163
+ match
164
+ });
165
+ if (!known) {
166
+ const device = {
167
+ id: peripheral.id,
168
+ key: match.key,
169
+ name: peripheral.advertisement.name
170
+ };
171
+ this.store.set({
172
+ devices: [...this.store.get().devices, {
173
+ ...device,
174
+ connection: "idle",
175
+ error: null
176
+ }]
177
+ });
178
+ }
179
+ this.connectIfPaired(peripheral.id);
180
+ }
181
+ connectIfPaired(id) {
182
+ const waiting = this.held.has(id) || this.connections.isActive(id) || !this.backoff.allows(id);
183
+ if (this.paired.has(id) && !waiting) {
184
+ this.connect(id).catch(() => undefined);
185
+ }
186
+ }
187
+
188
+ /** A scan reports a peripheral once, so a paired device is only found again by a fresh scan. */
189
+ connectionEnded(id) {
190
+ if (!this.paired.has(id) || this.held.has(id) || this.disposed) {
191
+ return;
192
+ }
193
+ if (this.store.device(id)?.connection !== "failed") {
194
+ this.backoff.succeeded(id);
195
+ this.restartScan();
196
+ return;
197
+ }
198
+ const timer = setTimeout(() => {
199
+ this.retryTimers.delete(timer);
200
+ this.restartScan();
201
+ }, this.backoff.failed(id));
202
+ this.retryTimers.add(timer);
203
+ }
204
+ restartScan() {
205
+ if (this.scan.running) {
206
+ this.scan.restart();
207
+ }
208
+ }
209
+ require(deviceId) {
210
+ const device = this.known.get(deviceId);
211
+ if (!device) {
212
+ throw new _errors.BluetoothError("device-not-found", `No device ${deviceId} was found by the scan`);
213
+ }
214
+ return device;
215
+ }
216
+ assertLive() {
217
+ if (this.disposed) {
218
+ throw new _errors.BluetoothError("runtime-disposed", "This BluetoothRuntime was disposed");
219
+ }
220
+ }
221
+ }
222
+ exports.BluetoothRuntime = BluetoothRuntime;
223
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_autoConnect","require","_connections","_devices","_errors","_paired","_readings","_resultPolicy","_scanLoop","_store","BluetoothRuntime","store","SnapshotStore","known","Map","held","Set","backoff","AutoConnectBackoff","retryTimers","scanRequest","disposed","constructor","options","readings","ReadingLog","sink","connections","Connections","resultPolicy","everyReading","id","connectionEnded","paired","PairedDevices","set","pairedStorage","scan","ScanLoop","scanner","peripheral","found","unwatchAdapter","watchState","adapter","sync","checkPermission","catch","undefined","getSnapshot","get","subscribe","listener","recordPermission","permissions","check","requestPermission","request","openPermissionSettings","openSettings","startScan","assertLive","permission","BluetoothError","scanning","stopScan","connect","deviceId","match","delete","driver","disconnect","add","pair","forget","remove","retrySaves","dispose","close","forEach","clearTimeout","disconnectAll","matchDevice","devices","advertisement","device","key","name","connection","error","connectIfPaired","waiting","has","isActive","allows","succeeded","restartScan","timer","setTimeout","failed","running","restart","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/runtime.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAA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