@ovok/native 1.17.0-dev.2215 → 1.17.0-dev.2219

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 (243) hide show
  1. package/lib/commonjs/modules/next/bluetooth/adapters/android-foreground-service.js +58 -5
  2. package/lib/commonjs/modules/next/bluetooth/adapters/android-foreground-service.js.map +1 -1
  3. package/lib/commonjs/modules/next/bluetooth/adapters/ecg-measurements.js +25 -0
  4. package/lib/commonjs/modules/next/bluetooth/adapters/ecg-measurements.js.map +1 -0
  5. package/lib/commonjs/modules/next/bluetooth/adapters/live-supersession.js +62 -0
  6. package/lib/commonjs/modules/next/bluetooth/adapters/live-supersession.js.map +1 -0
  7. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-outbox-watch.js +42 -0
  8. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-outbox-watch.js.map +1 -0
  9. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js +97 -96
  10. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
  11. package/lib/commonjs/modules/next/bluetooth/adapters/reading-source-id.js +33 -0
  12. package/lib/commonjs/modules/next/bluetooth/adapters/reading-source-id.js.map +1 -0
  13. package/lib/commonjs/modules/next/bluetooth/adapters/reading-values.js +38 -0
  14. package/lib/commonjs/modules/next/bluetooth/adapters/reading-values.js.map +1 -0
  15. package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js +101 -0
  16. package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js.map +1 -0
  17. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js +24 -0
  18. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -0
  19. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-rows.js +65 -0
  20. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-rows.js.map +1 -0
  21. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +53 -0
  22. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -0
  23. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.js +82 -0
  24. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.js.map +1 -0
  25. package/lib/commonjs/modules/next/bluetooth/adapters/storage-paired-devices.js +1 -0
  26. package/lib/commonjs/modules/next/bluetooth/adapters/storage-paired-devices.js.map +1 -1
  27. package/lib/commonjs/modules/next/bluetooth/core/bluetooth.js +9 -3
  28. package/lib/commonjs/modules/next/bluetooth/core/bluetooth.js.map +1 -1
  29. package/lib/commonjs/modules/next/bluetooth/core/device-deps.js +6 -0
  30. package/lib/commonjs/modules/next/bluetooth/core/device-deps.js.map +1 -0
  31. package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js +3 -1
  32. package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
  33. package/lib/commonjs/modules/next/bluetooth/core/device.js +19 -6
  34. package/lib/commonjs/modules/next/bluetooth/core/device.js.map +1 -1
  35. package/lib/commonjs/modules/next/bluetooth/core/live-ledger.js +54 -0
  36. package/lib/commonjs/modules/next/bluetooth/core/live-ledger.js.map +1 -0
  37. package/lib/commonjs/modules/next/bluetooth/core/measuring-watch.js +45 -0
  38. package/lib/commonjs/modules/next/bluetooth/core/measuring-watch.js.map +1 -0
  39. package/lib/commonjs/modules/next/bluetooth/core/outbox-watch.js +17 -0
  40. package/lib/commonjs/modules/next/bluetooth/core/outbox-watch.js.map +1 -0
  41. package/lib/commonjs/modules/next/bluetooth/core/paired-device.js +1 -0
  42. package/lib/commonjs/modules/next/bluetooth/core/paired-device.js.map +1 -1
  43. package/lib/commonjs/modules/next/bluetooth/core/ports.js.map +1 -1
  44. package/lib/commonjs/modules/next/bluetooth/core/reading-log.js +89 -7
  45. package/lib/commonjs/modules/next/bluetooth/core/reading-log.js.map +1 -1
  46. package/lib/commonjs/modules/next/bluetooth/core/series-slots.js +94 -0
  47. package/lib/commonjs/modules/next/bluetooth/core/series-slots.js.map +1 -0
  48. package/lib/commonjs/modules/next/bluetooth/core/stream-recorder.js +219 -0
  49. package/lib/commonjs/modules/next/bluetooth/core/stream-recorder.js.map +1 -0
  50. package/lib/commonjs/modules/next/bluetooth/core/waveform-segments.js +110 -0
  51. package/lib/commonjs/modules/next/bluetooth/core/waveform-segments.js.map +1 -0
  52. package/lib/commonjs/modules/next/bluetooth/create-bluetooth.js +19 -11
  53. package/lib/commonjs/modules/next/bluetooth/create-bluetooth.js.map +1 -1
  54. package/lib/commonjs/modules/next/bluetooth/index.js +9 -1
  55. package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
  56. package/lib/commonjs/modules/next/bluetooth/shared.js +14 -0
  57. package/lib/commonjs/modules/next/bluetooth/shared.js.map +1 -1
  58. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth.js +2 -0
  59. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth.js.map +1 -1
  60. package/lib/module/modules/next/bluetooth/adapters/android-foreground-service.js +59 -6
  61. package/lib/module/modules/next/bluetooth/adapters/android-foreground-service.js.map +1 -1
  62. package/lib/module/modules/next/bluetooth/adapters/ecg-measurements.js +22 -0
  63. package/lib/module/modules/next/bluetooth/adapters/ecg-measurements.js.map +1 -0
  64. package/lib/module/modules/next/bluetooth/adapters/live-supersession.js +59 -0
  65. package/lib/module/modules/next/bluetooth/adapters/live-supersession.js.map +1 -0
  66. package/lib/module/modules/next/bluetooth/adapters/ovok-outbox-watch.js +38 -0
  67. package/lib/module/modules/next/bluetooth/adapters/ovok-outbox-watch.js.map +1 -0
  68. package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js +76 -75
  69. package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
  70. package/lib/module/modules/next/bluetooth/adapters/reading-source-id.js +27 -0
  71. package/lib/module/modules/next/bluetooth/adapters/reading-source-id.js.map +1 -0
  72. package/lib/module/modules/next/bluetooth/adapters/reading-values.js +33 -0
  73. package/lib/module/modules/next/bluetooth/adapters/reading-values.js.map +1 -0
  74. package/lib/module/modules/next/bluetooth/adapters/series-saving.js +94 -0
  75. package/lib/module/modules/next/bluetooth/adapters/series-saving.js.map +1 -0
  76. package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js +20 -0
  77. package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -0
  78. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-rows.js +59 -0
  79. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-rows.js.map +1 -0
  80. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +49 -0
  81. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -0
  82. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.js +79 -0
  83. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.js.map +1 -0
  84. package/lib/module/modules/next/bluetooth/adapters/storage-paired-devices.js +1 -0
  85. package/lib/module/modules/next/bluetooth/adapters/storage-paired-devices.js.map +1 -1
  86. package/lib/module/modules/next/bluetooth/core/bluetooth.js +9 -3
  87. package/lib/module/modules/next/bluetooth/core/bluetooth.js.map +1 -1
  88. package/lib/module/modules/next/bluetooth/core/device-deps.js +4 -0
  89. package/lib/module/modules/next/bluetooth/core/device-deps.js.map +1 -0
  90. package/lib/module/modules/next/bluetooth/core/device-snapshot.js +3 -1
  91. package/lib/module/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
  92. package/lib/module/modules/next/bluetooth/core/device.js +19 -6
  93. package/lib/module/modules/next/bluetooth/core/device.js.map +1 -1
  94. package/lib/module/modules/next/bluetooth/core/live-ledger.js +50 -0
  95. package/lib/module/modules/next/bluetooth/core/live-ledger.js.map +1 -0
  96. package/lib/module/modules/next/bluetooth/core/measuring-watch.js +41 -0
  97. package/lib/module/modules/next/bluetooth/core/measuring-watch.js.map +1 -0
  98. package/lib/module/modules/next/bluetooth/core/outbox-watch.js +14 -0
  99. package/lib/module/modules/next/bluetooth/core/outbox-watch.js.map +1 -0
  100. package/lib/module/modules/next/bluetooth/core/paired-device.js +1 -0
  101. package/lib/module/modules/next/bluetooth/core/paired-device.js.map +1 -1
  102. package/lib/module/modules/next/bluetooth/core/ports.js.map +1 -1
  103. package/lib/module/modules/next/bluetooth/core/reading-log.js +89 -7
  104. package/lib/module/modules/next/bluetooth/core/reading-log.js.map +1 -1
  105. package/lib/module/modules/next/bluetooth/core/series-slots.js +90 -0
  106. package/lib/module/modules/next/bluetooth/core/series-slots.js.map +1 -0
  107. package/lib/module/modules/next/bluetooth/core/stream-recorder.js +215 -0
  108. package/lib/module/modules/next/bluetooth/core/stream-recorder.js.map +1 -0
  109. package/lib/module/modules/next/bluetooth/core/waveform-segments.js +106 -0
  110. package/lib/module/modules/next/bluetooth/core/waveform-segments.js.map +1 -0
  111. package/lib/module/modules/next/bluetooth/create-bluetooth.js +19 -11
  112. package/lib/module/modules/next/bluetooth/create-bluetooth.js.map +1 -1
  113. package/lib/module/modules/next/bluetooth/index.js +1 -0
  114. package/lib/module/modules/next/bluetooth/index.js.map +1 -1
  115. package/lib/module/modules/next/bluetooth/shared.js +2 -0
  116. package/lib/module/modules/next/bluetooth/shared.js.map +1 -1
  117. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth.js +2 -0
  118. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth.js.map +1 -1
  119. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts +17 -4
  120. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts +6 -0
  122. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/live-supersession.d.ts +9 -0
  124. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/live-supersession.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts +8 -0
  126. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +9 -3
  128. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-source-id.d.ts +9 -0
  130. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-source-id.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-values.d.ts +9 -0
  132. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-values.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts +28 -0
  134. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +23 -0
  136. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts +29 -0
  138. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts.map +1 -0
  139. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts +6 -0
  140. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +38 -0
  142. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/storage-paired-devices.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth-options.d.ts +3 -0
  145. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth-options.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-deps.d.ts +16 -0
  148. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-deps.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts +5 -0
  150. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts +6 -13
  152. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-ledger.d.ts +13 -0
  154. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-ledger.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/measuring-watch.d.ts +17 -0
  156. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/measuring-watch.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/outbox-watch.d.ts +27 -0
  158. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/outbox-watch.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/paired-device.d.ts +3 -1
  160. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/paired-device.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/ports.d.ts +3 -2
  162. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/ports.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading-log.d.ts +25 -6
  164. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading-log.d.ts.map +1 -1
  165. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts +16 -1
  166. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/series-slots.d.ts +35 -0
  168. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/series-slots.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/stream-recorder.d.ts +58 -0
  170. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/stream-recorder.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/waveform-segments.d.ts +26 -0
  172. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/waveform-segments.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/src/modules/next/bluetooth/create-bluetooth.d.ts +3 -2
  174. package/lib/typescript/commonjs/src/modules/next/bluetooth/create-bluetooth.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +4 -1
  176. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts +5 -1
  178. package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts +3 -2
  180. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts.map +1 -1
  181. package/lib/typescript/module/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts +17 -4
  182. package/lib/typescript/module/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts.map +1 -1
  183. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts +6 -0
  184. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts.map +1 -0
  185. package/lib/typescript/module/src/modules/next/bluetooth/adapters/live-supersession.d.ts +9 -0
  186. package/lib/typescript/module/src/modules/next/bluetooth/adapters/live-supersession.d.ts.map +1 -0
  187. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts +8 -0
  188. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts.map +1 -0
  189. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +9 -3
  190. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
  191. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-source-id.d.ts +9 -0
  192. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-source-id.d.ts.map +1 -0
  193. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-values.d.ts +9 -0
  194. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-values.d.ts.map +1 -0
  195. package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts +28 -0
  196. package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -0
  197. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +23 -0
  198. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -0
  199. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts +29 -0
  200. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts.map +1 -0
  201. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts +6 -0
  202. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts.map +1 -0
  203. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +38 -0
  204. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -0
  205. package/lib/typescript/module/src/modules/next/bluetooth/adapters/storage-paired-devices.d.ts.map +1 -1
  206. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth-options.d.ts +3 -0
  207. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth-options.d.ts.map +1 -1
  208. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth.d.ts.map +1 -1
  209. package/lib/typescript/module/src/modules/next/bluetooth/core/device-deps.d.ts +16 -0
  210. package/lib/typescript/module/src/modules/next/bluetooth/core/device-deps.d.ts.map +1 -0
  211. package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts +5 -0
  212. package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
  213. package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts +6 -13
  214. package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
  215. package/lib/typescript/module/src/modules/next/bluetooth/core/live-ledger.d.ts +13 -0
  216. package/lib/typescript/module/src/modules/next/bluetooth/core/live-ledger.d.ts.map +1 -0
  217. package/lib/typescript/module/src/modules/next/bluetooth/core/measuring-watch.d.ts +17 -0
  218. package/lib/typescript/module/src/modules/next/bluetooth/core/measuring-watch.d.ts.map +1 -0
  219. package/lib/typescript/module/src/modules/next/bluetooth/core/outbox-watch.d.ts +27 -0
  220. package/lib/typescript/module/src/modules/next/bluetooth/core/outbox-watch.d.ts.map +1 -0
  221. package/lib/typescript/module/src/modules/next/bluetooth/core/paired-device.d.ts +3 -1
  222. package/lib/typescript/module/src/modules/next/bluetooth/core/paired-device.d.ts.map +1 -1
  223. package/lib/typescript/module/src/modules/next/bluetooth/core/ports.d.ts +3 -2
  224. package/lib/typescript/module/src/modules/next/bluetooth/core/ports.d.ts.map +1 -1
  225. package/lib/typescript/module/src/modules/next/bluetooth/core/reading-log.d.ts +25 -6
  226. package/lib/typescript/module/src/modules/next/bluetooth/core/reading-log.d.ts.map +1 -1
  227. package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts +16 -1
  228. package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
  229. package/lib/typescript/module/src/modules/next/bluetooth/core/series-slots.d.ts +35 -0
  230. package/lib/typescript/module/src/modules/next/bluetooth/core/series-slots.d.ts.map +1 -0
  231. package/lib/typescript/module/src/modules/next/bluetooth/core/stream-recorder.d.ts +58 -0
  232. package/lib/typescript/module/src/modules/next/bluetooth/core/stream-recorder.d.ts.map +1 -0
  233. package/lib/typescript/module/src/modules/next/bluetooth/core/waveform-segments.d.ts +26 -0
  234. package/lib/typescript/module/src/modules/next/bluetooth/core/waveform-segments.d.ts.map +1 -0
  235. package/lib/typescript/module/src/modules/next/bluetooth/create-bluetooth.d.ts +3 -2
  236. package/lib/typescript/module/src/modules/next/bluetooth/create-bluetooth.d.ts.map +1 -1
  237. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +4 -1
  238. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
  239. package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts +5 -1
  240. package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts.map +1 -1
  241. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts +3 -2
  242. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts.map +1 -1
  243. package/package.json +7 -3
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StreamRecorder = void 0;
7
+ var _errors = require("./errors.js");
8
+ var _liveLedger = require("./live-ledger.js");
9
+ var _seriesSlots = require("./series-slots.js");
10
+ var _waveformSegments = require("./waveform-segments.js");
11
+ const MS_PER_SECOND = 1_000;
12
+ const SAVE_OPEN_EVERY_MS = 60_000;
13
+
14
+ /** The device being recorded. */
15
+
16
+ /**
17
+ * Records what one device streams live and saves it through the sink: numbers as series of one-second slots, waveforms
18
+ * as segments of five minutes at the waveform's own sample rate. It does the same for every device.
19
+ */
20
+ class StreamRecorder {
21
+ open = new Map();
22
+ segments = new Map();
23
+ ledger = new _liveLedger.LiveLedger();
24
+ replacing = new Map();
25
+ unsupported = new Set();
26
+ saving = Promise.resolve();
27
+ streaming = false;
28
+ constructor(device, sink, deps) {
29
+ this.device = device;
30
+ this.sink = sink;
31
+ this.deps = deps;
32
+ this.origin = {
33
+ modelId: deps.model.id,
34
+ protocolId: deps.protocol.id,
35
+ address: device.address,
36
+ recordId: null
37
+ };
38
+ }
39
+
40
+ /** Records from the device's events: live numbers and samples, and the end of the stream. */
41
+ follow(events) {
42
+ events.add(event => this.observe(event));
43
+ }
44
+
45
+ /** Takes one device event: numbers and samples while recording is on, and the end of the stream. */
46
+ observe(event) {
47
+ if (event.kind === "state") {
48
+ this.followStream(event.snapshot.live);
49
+ } else if (event.kind === "live" && this.device.snapshot().record) {
50
+ this.recordNumbers(event.values);
51
+ } else if (event.kind === "waveform" && this.device.snapshot().record) {
52
+ this.recordWaveform(event.waveform);
53
+ }
54
+ }
55
+
56
+ /** Marks the live recordings a stored record replaces, which the sink removes once it has saved the record. */
57
+ supersede(recordId, record) {
58
+ const spans = this.ledger.inside(record);
59
+ if (spans.length === 0) {
60
+ return record;
61
+ }
62
+ this.replacing.set(recordId, spans);
63
+ return {
64
+ ...record,
65
+ supersedes: spans
66
+ };
67
+ }
68
+
69
+ /** The record was saved, so the recordings it replaced are gone for good. */
70
+ acknowledged(recordId) {
71
+ this.ledger.remove(this.replacing.get(recordId) ?? []);
72
+ this.replacing.delete(recordId);
73
+ }
74
+
75
+ /** Saves everything still open, and resolves once every save has finished. */
76
+ close() {
77
+ this.stopTimer();
78
+ [...this.open.keys()].forEach(metric => this.finish(metric));
79
+ this.segments.forEach(segment => segment.flush().forEach(reading => this.saveSettled(reading)));
80
+ this.segments.clear();
81
+ return this.saving;
82
+ }
83
+ followStream(streaming) {
84
+ if (this.streaming && !streaming) {
85
+ void this.close();
86
+ }
87
+ this.streaming = streaming;
88
+ }
89
+ recordNumbers({
90
+ values,
91
+ at
92
+ }) {
93
+ Object.entries(values).forEach(([metric, quantity]) => {
94
+ const type = _seriesSlots.RECORDED_METRICS[metric];
95
+ if (quantity && type && Number.isFinite(quantity.value) && !this.unsupported.has(metric)) {
96
+ const takenAt = at.getTime();
97
+ this.seriesFor({
98
+ metric,
99
+ type,
100
+ unit: quantity.unit
101
+ }, takenAt).put(quantity.value, takenAt);
102
+ }
103
+ });
104
+ }
105
+ seriesFor(kind, at) {
106
+ const current = this.open.get(kind.metric);
107
+ if (current?.takes(kind.unit, at)) {
108
+ return current;
109
+ }
110
+ if (current) {
111
+ this.finish(kind.metric);
112
+ }
113
+ const series = new _seriesSlots.SlotSeries(kind, at);
114
+ this.open.set(kind.metric, series);
115
+ this.timer ??= setInterval(() => this.saveOpenSeries(), SAVE_OPEN_EVERY_MS);
116
+ return series;
117
+ }
118
+ recordWaveform(waveform) {
119
+ if (this.unsupported.has(waveform.metric) || !(waveform.sampleRateHz > 0)) {
120
+ return;
121
+ }
122
+ const arrivedAt = this.deps.now().getTime();
123
+ waveform.channels.forEach((channel, index) => {
124
+ const samples = waveform.samples[index];
125
+ const firstAt = waveform.firstSampleAt?.getTime() ?? arrivedAt - (samples?.length ?? 0) / waveform.sampleRateHz * MS_PER_SECOND;
126
+ if (samples?.length) {
127
+ this.segmentFor(waveform, channel).add(samples, firstAt).forEach(reading => this.saveSettled(reading));
128
+ }
129
+ });
130
+ }
131
+ segmentFor(waveform, channel) {
132
+ const {
133
+ metric,
134
+ sampleRateHz,
135
+ unit,
136
+ scale
137
+ } = waveform;
138
+ const key = [metric, channel, sampleRateHz, unit, scale].join("|");
139
+ const segment = this.segments.get(key) ?? new _waveformSegments.ChannelSegment({
140
+ metric,
141
+ channel,
142
+ sampleRateHz,
143
+ unit,
144
+ scale
145
+ }, this.origin);
146
+ this.segments.set(key, segment);
147
+ return segment;
148
+ }
149
+
150
+ /** The 60-second save: an open series that grew goes out again under its own name, so the outbox keeps one copy. */
151
+ saveOpenSeries() {
152
+ const now = this.deps.now().getTime();
153
+ [...this.open.entries()].forEach(([metric, series]) => {
154
+ if (series.isQuiet(now)) {
155
+ this.finish(metric);
156
+ } else if (series.unsaved) {
157
+ this.enqueue(series.reading(this.origin), () => undefined);
158
+ series.markSaved();
159
+ }
160
+ });
161
+ if (this.open.size === 0) {
162
+ this.stopTimer();
163
+ }
164
+ }
165
+ finish(metric) {
166
+ const series = this.open.get(metric);
167
+ this.open.delete(metric);
168
+ if (series) {
169
+ this.saveSettled(series.reading(this.origin));
170
+ }
171
+ }
172
+ saveSettled(reading) {
173
+ this.enqueue(reading, ({
174
+ live
175
+ }) => {
176
+ if (live) {
177
+ this.ledger.add(live);
178
+ }
179
+ });
180
+ }
181
+
182
+ /** Saves one at a time, in the order they were made. */
183
+ enqueue(reading, onSaved) {
184
+ this.saving = this.saving.then(async () => {
185
+ if (reading.live && this.unsupported.has(reading.live.metric)) {
186
+ return;
187
+ }
188
+ try {
189
+ await this.sink.save(reading, this.device.snapshot());
190
+ onSaved(reading);
191
+ } catch (error) {
192
+ this.failed(reading, error);
193
+ }
194
+ });
195
+ }
196
+ failed(reading, error) {
197
+ const metric = reading.live?.metric ?? null;
198
+ const protocol = this.origin.protocolId;
199
+ if (error instanceof _errors.DeviceError && error.code === "unsupported" && reading.live) {
200
+ this.unsupported.add(reading.live.metric);
201
+ this.deps.logger.warn("bluetooth.stream.unsupported", {
202
+ protocol,
203
+ metric
204
+ });
205
+ } else {
206
+ this.deps.logger.error("bluetooth.stream.save-failed", {
207
+ protocol,
208
+ metric,
209
+ code: error instanceof _errors.DeviceError ? error.code : null
210
+ });
211
+ }
212
+ }
213
+ stopTimer() {
214
+ clearInterval(this.timer);
215
+ this.timer = undefined;
216
+ }
217
+ }
218
+ exports.StreamRecorder = StreamRecorder;
219
+ //# sourceMappingURL=stream-recorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_liveLedger","_seriesSlots","_waveformSegments","MS_PER_SECOND","SAVE_OPEN_EVERY_MS","StreamRecorder","open","Map","segments","ledger","LiveLedger","replacing","unsupported","Set","saving","Promise","resolve","streaming","constructor","device","sink","deps","origin","modelId","model","id","protocolId","protocol","address","recordId","follow","events","add","event","observe","kind","followStream","snapshot","live","record","recordNumbers","values","recordWaveform","waveform","supersede","spans","inside","length","set","supersedes","acknowledged","remove","get","delete","close","stopTimer","keys","forEach","metric","finish","segment","flush","reading","saveSettled","clear","at","Object","entries","quantity","type","RECORDED_METRICS","Number","isFinite","value","has","takenAt","getTime","seriesFor","unit","put","current","takes","series","SlotSeries","timer","setInterval","saveOpenSeries","sampleRateHz","arrivedAt","now","channels","channel","index","samples","firstAt","firstSampleAt","segmentFor","scale","key","join","ChannelSegment","isQuiet","unsaved","enqueue","undefined","markSaved","size","onSaved","then","save","error","failed","DeviceError","code","logger","warn","clearInterval","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/core/stream-recorder.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAG,KAAK;AAC3B,MAAMC,kBAAkB,GAAG,MAAM;;AAEjC;;AAYA;AACA;AACA;AACA;AACA,MAAMC,cAAc,CAAC;EACFC,IAAI,GAAG,IAAIC,GAAG,CAAyB,CAAC;EACxCC,QAAQ,GAAG,IAAID,GAAG,CAAyB,CAAC;EAC5CE,MAAM,GAAG,IAAIC,sBAAU,CAAC,CAAC;EACzBC,SAAS,GAAG,IAAIJ,GAAG,CAA8B,CAAC;EAClDK,WAAW,GAAG,IAAIC,GAAG,CAAqB,CAAC;EACpDC,MAAM,GAAkBC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEzCC,SAAS,GAAG,KAAK;EAGlBC,WAAWA,CACCC,MAAsB,EACtBC,IAAiB,EACjBC,IAAkB,EACnC;IAAA,KAHiBF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,mBAAW,GAAGF,KAAK,CAACG,IAAI,GAAG;MAAK,CAAC,CAAC;IACtI;EACF;EAEQ1D,SAASA,CAAA,EAAS;IACxB6D,aAAa,CAAC,IAAI,CAAChC,KAAK,CAAC;IACzB,IAAI,CAACA,KAAK,GAAGoB,SAAS;EACxB;AACF;AAACa,OAAA,CAAAhH,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ChannelSegment = void 0;
7
+ const MS_PER_SECOND = 1_000;
8
+ const SEGMENT_MS = 5 * 60_000;
9
+
10
+ /** Samples that arrive this much later than the ones before them leave a hole, so they start a new segment. */
11
+ const MAX_GAP_MS = 5_000;
12
+ const MEASUREMENT_OF_WAVEFORM = {
13
+ ecg_waveform: "ecg",
14
+ pleth_waveform: "oxygen_saturation"
15
+ };
16
+
17
+ /** What stays the same while one channel of a waveform streams. */
18
+
19
+ /** One channel's samples, collected until they fill five minutes, a gap opens, or the stream ends. */
20
+ class ChannelSegment {
21
+ chunks = [];
22
+ count = 0;
23
+ from = 0;
24
+ constructor(shape, origin) {
25
+ this.shape = shape;
26
+ this.origin = origin;
27
+ }
28
+
29
+ /** Adds samples whose first was taken at `at`; returns the segments they completed. */
30
+ add(samples, at) {
31
+ const completed = this.count > 0 && at - this.endsAt() > MAX_GAP_MS ? this.flush() : [];
32
+ let rest = samples;
33
+ let restAt = at;
34
+ while (rest.length > 0) {
35
+ const part = rest.subarray(0, this.capacity() - this.count);
36
+ this.append(part, restAt);
37
+ rest = rest.subarray(part.length);
38
+ restAt += this.durationOf(part.length);
39
+ completed.push(...(this.count >= this.capacity() ? this.flush() : []));
40
+ }
41
+ return completed;
42
+ }
43
+
44
+ /** Hands over what is collected as one reading, none when it is empty. */
45
+ flush() {
46
+ if (this.count === 0) {
47
+ return [];
48
+ }
49
+ const samples = new Int16Array(this.count);
50
+ let filled = 0;
51
+ this.chunks.forEach(chunk => {
52
+ samples.set(chunk, filled);
53
+ filled += chunk.length;
54
+ });
55
+ const reading = this.readingOf(samples);
56
+ this.chunks = [];
57
+ this.count = 0;
58
+ return [reading];
59
+ }
60
+ append(part, at) {
61
+ if (this.count === 0) {
62
+ this.from = at;
63
+ }
64
+ this.chunks.push(part.slice());
65
+ this.count += part.length;
66
+ }
67
+ readingOf(samples) {
68
+ const from = new Date(this.from);
69
+ const {
70
+ metric,
71
+ channel,
72
+ sampleRateHz,
73
+ unit,
74
+ scale
75
+ } = this.shape;
76
+ return {
77
+ type: MEASUREMENT_OF_WAVEFORM[metric],
78
+ takenAt: from,
79
+ values: {},
80
+ deviceFlags: [],
81
+ waveform: {
82
+ metric,
83
+ sampleRateHz,
84
+ unit,
85
+ scale,
86
+ channels: [channel],
87
+ samples: [samples],
88
+ firstSampleAt: from
89
+ },
90
+ live: {
91
+ metric,
92
+ channel,
93
+ from,
94
+ to: new Date(this.endsAt())
95
+ },
96
+ source: this.origin
97
+ };
98
+ }
99
+ capacity() {
100
+ return Math.round(this.shape.sampleRateHz * SEGMENT_MS / MS_PER_SECOND);
101
+ }
102
+ endsAt() {
103
+ return this.from + this.durationOf(this.count);
104
+ }
105
+ durationOf(samples) {
106
+ return samples / this.shape.sampleRateHz * MS_PER_SECOND;
107
+ }
108
+ }
109
+ exports.ChannelSegment = ChannelSegment;
110
+ //# sourceMappingURL=waveform-segments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MS_PER_SECOND","SEGMENT_MS","MAX_GAP_MS","MEASUREMENT_OF_WAVEFORM","ecg_waveform","pleth_waveform","ChannelSegment","chunks","count","from","constructor","shape","origin","add","samples","at","completed","endsAt","flush","rest","restAt","length","part","subarray","capacity","append","durationOf","push","Int16Array","filled","forEach","chunk","set","reading","readingOf","slice","Date","metric","channel","sampleRateHz","unit","scale","type","takenAt","values","deviceFlags","waveform","channels","firstSampleAt","live","to","source","Math","round","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/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ACbmC,MAAM,EAAE,CAAC,CAAC;MACVC,WAAW,EAAE,EAAE;MACfC,QAAQ,EAAE;QAAET,MAAM;QAAEE,YAAY;QAAEC,IAAI;QAAEC,KAAK;QAAEM,QAAQ,EAAE,CAACT,OAAO,CAAC;QAAExB,OAAO,EAAE,CAACA,OAAO,CAAC;QAAEkC,aAAa,EAAEvC;MAAK,CAAC;MAC7GwC,IAAI,EAAE;QAAEZ,MAAM;QAAEC,OAAO;QAAE7B,IAAI;QAAEyC,EAAE,EAAE,IAAId,IAAI,CAAC,IAAI,CAACnB,MAAM,CAAC,CAAC;MAAE,CAAC;MAC5DkC,MAAM,EAAE,IAAI,CAACvC;IACf,CAAC;EACH;EAEQY,QAAQA,CAAA,EAAW;IACzB,OAAO4B,IAAI,CAACC,KAAK,CAAE,IAAI,CAAC1C,KAAK,CAAC4B,YAAY,GAAGtC,UAAU,GAAID,aAAa,CAAC;EAC3E;EAEQiB,MAAMA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACR,IAAI,GAAG,IAAI,CAACiB,UAAU,CAAC,IAAI,CAAClB,KAAK,CAAC;EAChD;EAEQkB,UAAUA,CAACZ,OAAe,EAAU;IAC1C,OAAQA,OAAO,GAAG,IAAI,CAACH,KAAK,CAAC4B,YAAY,GAAIvC,aAAa;EAC5D;AACF;AAACsD,OAAA,CAAAhD,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -8,6 +8,7 @@ var _reactNativeBlePlx = require("react-native-ble-plx");
8
8
  var _androidForegroundService = require("./adapters/android-foreground-service.js");
9
9
  var _blePlxCentral = require("./adapters/ble-plx-central.js");
10
10
  var _osPermissions = require("./adapters/os-permissions.js");
11
+ var _ovokOutboxWatch = require("./adapters/ovok-outbox-watch.js");
11
12
  var _ovokReadingSink = require("./adapters/ovok-reading-sink.js");
12
13
  var _reactNativeLifecycle = require("./adapters/react-native-lifecycle.js");
13
14
  var _storagePairedDevices = require("./adapters/storage-paired-devices.js");
@@ -20,16 +21,23 @@ const createBluetooth = ({
20
21
  ovok,
21
22
  storage,
22
23
  ...overrides
23
- }) => new _bluetooth.Bluetooth({
24
- central: (0, _blePlxCentral.blePlxCentral)(new _reactNativeBlePlx.BleManager()),
25
- store: (0, _storagePairedDevices.storagePairedDevices)(storage),
26
- sink: (0, _ovokReadingSink.ovokReadingSink)(ovok),
27
- permissions: (0, _osPermissions.osBluetoothPermissions)(),
28
- models: _builtIn.BUILT_IN_MODELS,
29
- protocols: _builtIn.BUILT_IN_PROTOCOLS,
30
- lifecycle: (0, _reactNativeLifecycle.reactNativeLifecycle)(),
31
- keepAlive: (0, _androidForegroundService.androidForegroundService)(),
32
- ...overrides
33
- });
24
+ }) => {
25
+ const outbox = (0, _ovokOutboxWatch.ovokOutboxWatch)(ovok.outbox, overrides.logger);
26
+ return new _bluetooth.Bluetooth({
27
+ central: (0, _blePlxCentral.blePlxCentral)(new _reactNativeBlePlx.BleManager()),
28
+ store: (0, _storagePairedDevices.storagePairedDevices)(storage),
29
+ sink: (0, _ovokReadingSink.ovokReadingSink)(ovok),
30
+ permissions: (0, _osPermissions.osBluetoothPermissions)(),
31
+ models: _builtIn.BUILT_IN_MODELS,
32
+ protocols: _builtIn.BUILT_IN_PROTOCOLS,
33
+ lifecycle: (0, _reactNativeLifecycle.reactNativeLifecycle)(),
34
+ keepAlive: (0, _androidForegroundService.androidForegroundService)({}, {
35
+ outbox,
36
+ logger: overrides.logger
37
+ }),
38
+ outbox,
39
+ ...overrides
40
+ });
41
+ };
34
42
  exports.createBluetooth = createBluetooth;
35
43
  //# sourceMappingURL=create-bluetooth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeBlePlx","require","_androidForegroundService","_blePlxCentral","_osPermissions","_ovokReadingSink","_reactNativeLifecycle","_storagePairedDevices","_bluetooth","_builtIn","createBluetooth","ovok","storage","overrides","Bluetooth","central","blePlxCentral","BleManager","store","storagePairedDevices","sink","ovokReadingSink","permissions","osBluetoothPermissions","models","BUILT_IN_MODELS","protocols","BUILT_IN_PROTOCOLS","lifecycle","reactNativeLifecycle","keepAlive","androidForegroundService","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/create-bluetooth.ts"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA;;AAUA;AACA,MAAMS,eAAe,GAAGA,CAAC;EAAEC,IAAI;EAAEC,OAAO;EAAE,GAAGC;AAAkC,CAAC,KAC9E,IAAIC,oBAAS,CAAC;EACZC,OAAO,EAAE,IAAAC,4BAAa,EAAC,IAAIC,6BAAU,CAAC,CAAC,CAAC;EACxCC,KAAK,EAAE,IAAAC,0CAAoB,EAACP,OAAO,CAAC;EACpCQ,IAAI,EAAE,IAAAC,gCAAe,EAACV,IAAI,CAAC;EAC3BW,WAAW,EAAE,IAAAC,qCAAsB,EAAC,CAAC;EACrCC,MAAM,EAAEC,wBAAe;EACvBC,SAAS,EAAEC,2BAAkB;EAC7BC,SAAS,EAAE,IAAAC,0CAAoB,EAAC,CAAC;EACjCC,SAAS,EAAE,IAAAC,kDAAwB,EAAC,CAAC;EACrC,GAAGlB;AACL,CAAC,CAAC;AAACmB,OAAA,CAAAtB,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeBlePlx","require","_androidForegroundService","_blePlxCentral","_osPermissions","_ovokOutboxWatch","_ovokReadingSink","_reactNativeLifecycle","_storagePairedDevices","_bluetooth","_builtIn","createBluetooth","ovok","storage","overrides","outbox","ovokOutboxWatch","logger","Bluetooth","central","blePlxCentral","BleManager","store","storagePairedDevices","sink","ovokReadingSink","permissions","osBluetoothPermissions","models","BUILT_IN_MODELS","protocols","BUILT_IN_PROTOCOLS","lifecycle","reactNativeLifecycle","keepAlive","androidForegroundService","exports"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/create-bluetooth.ts"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAEA;;AAUA;AACA,MAAMU,eAAe,GAAGA,CAAC;EAAEC,IAAI;EAAEC,OAAO;EAAE,GAAGC;AAAkC,CAAC,KAAgB;EAC9F,MAAMC,MAAM,GAAG,IAAAC,gCAAe,EAACJ,IAAI,CAACG,MAAM,EAAED,SAAS,CAACG,MAAM,CAAC;EAE7D,OAAO,IAAIC,oBAAS,CAAC;IACnBC,OAAO,EAAE,IAAAC,4BAAa,EAAC,IAAIC,6BAAU,CAAC,CAAC,CAAC;IACxCC,KAAK,EAAE,IAAAC,0CAAoB,EAACV,OAAO,CAAC;IACpCW,IAAI,EAAE,IAAAC,gCAAe,EAACb,IAAI,CAAC;IAC3Bc,WAAW,EAAE,IAAAC,qCAAsB,EAAC,CAAC;IACrCC,MAAM,EAAEC,wBAAe;IACvBC,SAAS,EAAEC,2BAAkB;IAC7BC,SAAS,EAAE,IAAAC,0CAAoB,EAAC,CAAC;IACjCC,SAAS,EAAE,IAAAC,kDAAwB,EAAC,CAAC,CAAC,EAAE;MAAEpB,MAAM;MAAEE,MAAM,EAAEH,SAAS,CAACG;IAAO,CAAC,CAAC;IAC7EF,MAAM;IACN,GAAGD;EACL,CAAC,CAAC;AACJ,CAAC;AAACsB,OAAA,CAAAzB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -8,8 +8,15 @@ var _exportNames = {
8
8
  blePlxCentral: true,
9
9
  osBluetoothPermissions: true,
10
10
  reactNativeLifecycle: true,
11
- createBluetooth: true
11
+ createBluetooth: true,
12
+ SqliteOutboxStore: true
12
13
  };
14
+ Object.defineProperty(exports, "SqliteOutboxStore", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _sqliteOutboxStore.SqliteOutboxStore;
18
+ }
19
+ });
13
20
  Object.defineProperty(exports, "androidForegroundService", {
14
21
  enumerable: true,
15
22
  get: function () {
@@ -57,4 +64,5 @@ var _blePlxCentral = require("./adapters/ble-plx-central.js");
57
64
  var _osPermissions = require("./adapters/os-permissions.js");
58
65
  var _reactNativeLifecycle = require("./adapters/react-native-lifecycle.js");
59
66
  var _createBluetooth = require("./create-bluetooth.js");
67
+ var _sqliteOutboxStore = require("./adapters/sqlite-outbox-store.js");
60
68
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_androidForegroundService","_blePlxCentral","_osPermissions","_reactNativeLifecycle","_createBluetooth"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,yBAAA,GAAAb,OAAA;AAEA,IAAAc,cAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAf,OAAA;AACA,IAAAgB,qBAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_androidForegroundService","_blePlxCentral","_osPermissions","_reactNativeLifecycle","_createBluetooth","_sqliteOutboxStore"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,yBAAA,GAAAb,OAAA;AAEA,IAAAc,cAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAf,OAAA;AACA,IAAAgB,qBAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AAEA,IAAAkB,kBAAA,GAAAlB,OAAA","ignoreList":[]}
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "Discovery", {
51
51
  return _discovery.Discovery;
52
52
  }
53
53
  });
54
+ Object.defineProperty(exports, "ovokOutboxWatch", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _ovokOutboxWatch.ovokOutboxWatch;
58
+ }
59
+ });
54
60
  Object.defineProperty(exports, "ovokReadingSink", {
55
61
  enumerable: true,
56
62
  get: function () {
@@ -99,6 +105,12 @@ Object.defineProperty(exports, "useLiveValues", {
99
105
  return _useDevice.useLiveValues;
100
106
  }
101
107
  });
108
+ Object.defineProperty(exports, "useOutbox", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _react.useOutbox;
112
+ }
113
+ });
102
114
  Object.defineProperty(exports, "usePairedDevices", {
103
115
  enumerable: true,
104
116
  get: function () {
@@ -117,6 +129,7 @@ Object.defineProperty(exports, "useWaveform", {
117
129
  return _useDevice.useWaveform;
118
130
  }
119
131
  });
132
+ var _ovokOutboxWatch = require("./adapters/ovok-outbox-watch.js");
120
133
  var _ovokReadingSink = require("./adapters/ovok-reading-sink.js");
121
134
  var _storagePairedDevices = require("./adapters/storage-paired-devices.js");
122
135
  var _bluetooth = require("./core/bluetooth.js");
@@ -129,4 +142,5 @@ var _context = require("./react/context.js");
129
142
  var _hooks = require("./react/hooks.js");
130
143
  var _useDevice = require("./react/use-device.js");
131
144
  var _useDiscovery = require("./react/use-discovery.js");
145
+ var _react = require("@ovok/core/next/react");
132
146
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ovokReadingSink","require","_storagePairedDevices","_bluetooth","_catalog","_device","_discovery","_errors","_builtIn","_context","_hooks","_useDevice","_useDiscovery"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,UAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AAwBA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AAEA,IAAAW,aAAA,GAAAX,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ovokOutboxWatch","require","_ovokReadingSink","_storagePairedDevices","_bluetooth","_catalog","_device","_discovery","_errors","_builtIn","_context","_hooks","_useDevice","_useDiscovery","_react"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,UAAA,GAAAN,OAAA;AAEA,IAAAO,OAAA,GAAAP,OAAA;AA0BA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAEA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AAEA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA","ignoreList":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createWebBluetooth = void 0;
7
+ var _ovokOutboxWatch = require("../adapters/ovok-outbox-watch.js");
7
8
  var _ovokReadingSink = require("../adapters/ovok-reading-sink.js");
8
9
  var _storagePairedDevices = require("../adapters/storage-paired-devices.js");
9
10
  var _webBluetoothCentral = require("../adapters/web-bluetooth-central.js");
@@ -28,6 +29,7 @@ const createWebBluetooth = ({
28
29
  central: (0, _webBluetoothCentral.webBluetoothCentral)(browserBluetooth()),
29
30
  store: (0, _storagePairedDevices.storagePairedDevices)(storage),
30
31
  sink: (0, _ovokReadingSink.ovokReadingSink)(ovok),
32
+ outbox: (0, _ovokOutboxWatch.ovokOutboxWatch)(ovok.outbox, overrides.logger),
31
33
  permissions: chooserPermissions,
32
34
  models: _builtIn.BUILT_IN_MODELS,
33
35
  protocols: _builtIn.BUILT_IN_PROTOCOLS,
@@ -1 +1 @@
1
- {"version":3,"names":["_ovokReadingSink","require","_storagePairedDevices","_webBluetoothCentral","_bluetooth","_builtIn","chooserPermissions","check","request","openSettings","undefined","browserBluetooth","globalThis","navigator","bluetooth","createWebBluetooth","ovok","storage","overrides","Bluetooth","central","webBluetoothCentral","store","storagePairedDevices","sink","ovokReadingSink","permissions","models","BUILT_IN_MODELS","protocols","BUILT_IN_PROTOCOLS","autoSync","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/create-web-bluetooth.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAEA;;AAUA;AACA,MAAMK,kBAAwC,GAAG;EAC/CC,KAAK,EAAE,MAAAA,CAAA,KAAY,SAAS;EAC5BC,OAAO,EAAE,MAAAA,CAAA,KAAY,SAAS;EAC9BC,YAAY,EAAE,MAAAA,CAAA,KAAYC;AAC5B,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAAA,KACtBC,UAAU,CAAkDC,SAAS,EAAEC,SAAS;;AAEnF;AACA,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,OAAO;EAAE,GAAGC;AAAqC,CAAC,KACpF,IAAIC,oBAAS,CAAC;EACZC,OAAO,EAAE,IAAAC,wCAAmB,EAACV,gBAAgB,CAAC,CAAC,CAAC;EAChDW,KAAK,EAAE,IAAAC,0CAAoB,EAACN,OAAO,CAAC;EACpCO,IAAI,EAAE,IAAAC,gCAAe,EAACT,IAAI,CAAC;EAC3BU,WAAW,EAAEpB,kBAAkB;EAC/BqB,MAAM,EAAEC,wBAAe;EACvBC,SAAS,EAAEC,2BAAkB;EAC7BC,QAAQ,EAAE,KAAK;EACf,GAAGb;AACL,CAAC,CAAC;AAACc,OAAA,CAAAjB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ovokOutboxWatch","require","_ovokReadingSink","_storagePairedDevices","_webBluetoothCentral","_bluetooth","_builtIn","chooserPermissions","check","request","openSettings","undefined","browserBluetooth","globalThis","navigator","bluetooth","createWebBluetooth","ovok","storage","overrides","Bluetooth","central","webBluetoothCentral","store","storagePairedDevices","sink","ovokReadingSink","outbox","ovokOutboxWatch","logger","permissions","models","BUILT_IN_MODELS","protocols","BUILT_IN_PROTOCOLS","autoSync","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/create-web-bluetooth.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AAEA;;AAUA;AACA,MAAMM,kBAAwC,GAAG;EAC/CC,KAAK,EAAE,MAAAA,CAAA,KAAY,SAAS;EAC5BC,OAAO,EAAE,MAAAA,CAAA,KAAY,SAAS;EAC9BC,YAAY,EAAE,MAAAA,CAAA,KAAYC;AAC5B,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAAA,KACtBC,UAAU,CAAkDC,SAAS,EAAEC,SAAS;;AAEnF;AACA,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,OAAO;EAAE,GAAGC;AAAqC,CAAC,KACpF,IAAIC,oBAAS,CAAC;EACZC,OAAO,EAAE,IAAAC,wCAAmB,EAACV,gBAAgB,CAAC,CAAC,CAAC;EAChDW,KAAK,EAAE,IAAAC,0CAAoB,EAACN,OAAO,CAAC;EACpCO,IAAI,EAAE,IAAAC,gCAAe,EAACT,IAAI,CAAC;EAC3BU,MAAM,EAAE,IAAAC,gCAAe,EAACX,IAAI,CAACU,MAAM,EAAER,SAAS,CAACU,MAAM,CAAC;EACtDC,WAAW,EAAEvB,kBAAkB;EAC/BwB,MAAM,EAAEC,wBAAe;EACvBC,SAAS,EAAEC,2BAAkB;EAC7BC,QAAQ,EAAE,KAAK;EACf,GAAGhB;AACL,CAAC,CAAC;AAACiB,OAAA,CAAApB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  import { NativeModules, Platform } from "react-native";
4
- import { noKeepAlive } from "../core/ports.js";
4
+ import { noOutboxWatch } from "../core/outbox-watch.js";
5
+ import { noKeepAlive, silentLogger } from "../core/ports.js";
5
6
 
6
7
  /** The notification Android shows while the service runs. */
7
8
 
9
+ /** What the service watches and reports besides its text. */
10
+
8
11
  const nativeService = () => {
9
12
  const service = NativeModules.OvokBackgroundSync;
10
13
  if (!service) {
@@ -12,11 +15,61 @@ const nativeService = () => {
12
15
  }
13
16
  return service;
14
17
  };
18
+ const describeUnsent = unsent => `${unsent} ${unsent === 1 ? "reading" : "readings"} waiting to upload`;
19
+
20
+ /** The text for the native module: the function is dropped, and the body names the unsent count while there is one. */
21
+ const textFor = ({
22
+ unsentBody = describeUnsent,
23
+ ...text
24
+ }, unsent) => unsent > 0 ? {
25
+ ...text,
26
+ notificationBody: unsentBody(unsent)
27
+ } : text;
28
+
29
+ /** Android re-posts the same notification when the service is started again, which is how the text changes. */
30
+ class AndroidForegroundService {
31
+ stopWatching = null;
32
+ shownUnsent = 0;
33
+ constructor(text, outbox, logger) {
34
+ this.text = text;
35
+ this.outbox = outbox;
36
+ this.logger = logger;
37
+ }
38
+ start = async () => {
39
+ this.stopWatching?.();
40
+ this.shownUnsent = 0;
41
+
42
+ // Watch before the first await, so a stop that follows at once also ends the watching.
43
+ this.stopWatching = this.outbox.subscribe(({
44
+ waiting
45
+ }) => this.showCount(waiting.size));
46
+ await this.show();
47
+ };
48
+ stop = async () => {
49
+ this.stopWatching?.();
50
+ this.stopWatching = null;
51
+ await nativeService().stopBluetoothForegroundService();
52
+ };
53
+ showCount(unsent) {
54
+ if (unsent !== this.shownUnsent) {
55
+ this.shownUnsent = unsent;
56
+ this.show().catch(() => this.logger.error("bluetooth.keep-alive.notification-failed", {
57
+ unsent
58
+ }));
59
+ }
60
+ }
61
+ show() {
62
+ return nativeService().startBluetoothForegroundService(textFor(this.text, this.shownUnsent));
63
+ }
64
+ }
15
65
 
16
- /** Android's connected-device foreground service, which keeps the process alive for background sync; nothing elsewhere. */
17
- const androidForegroundService = (text = {}) => Platform.OS === "android" ? {
18
- start: async () => nativeService().startBluetoothForegroundService(text),
19
- stop: async () => nativeService().stopBluetoothForegroundService()
20
- } : noKeepAlive;
66
+ /**
67
+ * Android's connected-device foreground service, which keeps the process alive for background sync; nothing elsewhere.
68
+ * With an `outbox`, its notification says how many readings wait to upload.
69
+ */
70
+ const androidForegroundService = (text = {}, {
71
+ outbox = noOutboxWatch,
72
+ logger = silentLogger
73
+ } = {}) => Platform.OS === "android" ? new AndroidForegroundService(text, outbox, logger) : noKeepAlive;
21
74
  export { androidForegroundService };
22
75
  //# sourceMappingURL=android-foreground-service.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","noKeepAlive","nativeService","service","OvokBackgroundSync","Error","androidForegroundService","text","OS","start","startBluetoothForegroundService","stop","stopBluetoothForegroundService"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/android-foreground-service.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,SAAoBC,WAAW,QAAQ,kBAAe;;AAEtD;;AAeA,MAAMC,aAAa,GAAGA,CAAA,KAA+B;EACnD,MAAMC,OAAO,GAAGJ,aAAa,CAACK,kBAAyD;EAEvF,IAAI,CAACD,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,2FAA2F,CAAC;EAC9G;EAEA,OAAOF,OAAO;AAChB,CAAC;;AAED;AACA,MAAMG,wBAAwB,GAAGA,CAACC,IAA2B,GAAG,CAAC,CAAC,KAChEP,QAAQ,CAACQ,EAAE,KAAK,SAAS,GACrB;EACEC,KAAK,EAAE,MAAAA,CAAA,KAAYP,aAAa,CAAC,CAAC,CAACQ,+BAA+B,CAACH,IAAI,CAAC;EACxEI,IAAI,EAAE,MAAAA,CAAA,KAAYT,aAAa,CAAC,CAAC,CAACU,8BAA8B,CAAC;AACnE,CAAC,GACDX,WAAW;AAEjB,SAASK,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","noOutboxWatch","noKeepAlive","silentLogger","nativeService","service","OvokBackgroundSync","Error","describeUnsent","unsent","textFor","unsentBody","text","notificationBody","AndroidForegroundService","stopWatching","shownUnsent","constructor","outbox","logger","start","subscribe","waiting","showCount","size","show","stop","stopBluetoothForegroundService","catch","error","startBluetoothForegroundService","androidForegroundService","OS"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/android-foreground-service.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,SAASC,aAAa,QAAqB,yBAAsB;AACjE,SAA4BC,WAAW,EAAEC,YAAY,QAAQ,kBAAe;;A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AACA,YAAY,GAAG,IAAI;IACxB,MAAMX,aAAa,CAAC,CAAC,CAACuB,8BAA8B,CAAC,CAAC;EACxD,CAAC;EAEOJ,SAASA,CAACd,MAAc,EAAQ;IACtC,IAAIA,MAAM,KAAK,IAAI,CAACO,WAAW,EAAE;MAC/B,IAAI,CAACA,WAAW,GAAGP,MAAM;MACzB,IAAI,CAACgB,IAAI,CAAC,CAAC,CAACG,KAAK,CAAC,MAAM,IAAI,CAACT,MAAM,CAACU,KAAK,CAAC,0CAA0C,EAAE;QAAEpB;MAAO,CAAC,CAAC,CAAC;IACpG;EACF;EAEQgB,IAAIA,CAAA,EAAkB;IAC5B,OAAOrB,aAAa,CAAC,CAAC,CAAC0B,+BAA+B,CAACpB,OAAO,CAAC,IAAI,CAACE,IAAI,EAAE,IAAI,CAACI,WAAW,CAAC,CAAC;EAC9F;AACF;;AAEA;AACA;AACA;AACA;AACA,MAAMe,wBAAwB,GAAGA,CAC/BnB,IAA2B,GAAG,CAAC,CAAC,EAChC;EAAEM,MAAM,GAAGjB,aAAa;EAAEkB,MAAM,GAAGhB;AAAuC,CAAC,GAAG,CAAC,CAAC,KACjEH,QAAQ,CAACgC,EAAE,KAAK,SAAS,GAAG,IAAIlB,wBAAwB,CAACF,IAAI,EAAEM,MAAM,EAAEC,MAAM,CAAC,GAAGjB,WAAY;AAE9G,SAAS6B,wBAAwB","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ import { MeasurementTypeKey } from "@ovok/core/next";
4
+ import { valueOf } from "./reading-values.js";
5
+
6
+ /** Ovok stores ECG points in millivolts; a trace in any other unit is left out rather than mislabelled. */
7
+ const ECG_POINT_UNIT = "mV";
8
+
9
+ /** One ECG recording per channel, each in millivolts at the waveform's sample rate; the heart rate goes with the first. */
10
+ const ecgMeasurements = reading => {
11
+ const waveform = reading.waveform?.unit === ECG_POINT_UNIT ? reading.waveform : undefined;
12
+ const channels = waveform?.samples ?? [new Int16Array(0)];
13
+ return channels.map((samples, index) => ({
14
+ measurementTypeKey: MeasurementTypeKey.ecg,
15
+ heartRate: index === 0 ? valueOf(reading, "heart_rate") : undefined,
16
+ diagramPoints: Array.from(samples, sample => sample * (waveform?.scale ?? 1)),
17
+ duration: waveform ? samples.length / waveform.sampleRateHz : undefined,
18
+ recordedAt: reading.takenAt ?? undefined
19
+ }));
20
+ };
21
+ export { ecgMeasurements };
22
+ //# sourceMappingURL=ecg-measurements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MeasurementTypeKey","valueOf","ECG_POINT_UNIT","ecgMeasurements","reading","waveform","unit","undefined","channels","samples","Int16Array","map","index","measurementTypeKey","ecg","heartRate","diagramPoints","Array","from","sample","scale","duration","length","sampleRateHz","recordedAt","takenAt"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ecg-measurements.ts"],"mappings":";;AAAA,SAAyBA,kBAAkB,QAAQ,iBAAiB;AAIpE,SAASC,OAAO,QAAQ,qBAAkB;;AAE1C;AACA,MAAMC,cAAc,GAAG,IAAI;;AAE3B;AACA,MAAMC,eAAe,GAAIC,OAAgB,IAAuB;EAC9D,MAAMC,QAAQ,GAAGD,OAAO,CAACC,QAAQ,EAAEC,IAAI,KAAKJ,cAAc,GAAGE,OAAO,CAACC,QAAQ,GAAGE,SAAS;EACzF,MAAMC,QAAQ,GAAGH,QAAQ,EAAEI,OAAO,IAAI,CAAC,IAAIC,UAAU,CAAC,CAAC,CAAC,CAAC;EAEzD,OAAOF,QAAQ,CAACG,GAAG,CAAC,CAACF,OAAO,EAAEG,KAAK,MAAM;IACvCC,kBAAkB,EAAEb,kBAAkB,CAACc,GAAG;IAC1CC,SAAS,EAAEH,KAAK,KAAK,CAAC,GAAGX,OAAO,CAACG,OAAO,EAAE,YAAY,CAAC,GAAGG,SAAS;IACnES,aAAa,EAAEC,KAAK,CAACC,IAAI,CAACT,OAAO,EAAGU,MAAM,IAAKA,MAAM,IAAId,QAAQ,EAAEe,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/EC,QAAQ,EAAEhB,QAAQ,GAAGI,OAAO,CAACa,MAAM,GAAGjB,QAAQ,CAACkB,YAAY,GAAGhB,SAAS;IACvEiB,UAAU,EAAEpB,OAAO,CAACqB,OAAO,IAAIlB;EACjC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAASJ,eAAe","ignoreList":[]}