@ovok/native 1.16.1-dev.2118 → 1.16.1-dev.2129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/modules/bt-management/components/android-bluetooth-foreground-service.js +3 -1
- package/lib/commonjs/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js +9 -141
- package/lib/commonjs/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js +160 -0
- package/lib/commonjs/modules/bt-management/components/device-picker-sheet.js.map +1 -0
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js +2 -1
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +1 -1
- package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js +19 -0
- package/lib/commonjs/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
- package/lib/commonjs/modules/bt-management/utils/result-identity.js +3 -25
- package/lib/commonjs/modules/bt-management/utils/result-identity.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/auto-connect.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/auto-connect.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js +33 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js +125 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js +75 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js +34 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js +67 -0
- package/lib/commonjs/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/connections.js +110 -0
- package/lib/commonjs/modules/next/bluetooth/connections.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/daily-total-day.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/devices.js +41 -0
- package/lib/commonjs/modules/next/bluetooth/devices.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/driver.js +24 -20
- package/lib/commonjs/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/errors.js +26 -0
- package/lib/commonjs/modules/next/bluetooth/errors.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/index.js +116 -11
- package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/link.js +0 -103
- package/lib/commonjs/modules/next/bluetooth/link.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/paired.js +50 -0
- package/lib/commonjs/modules/next/bluetooth/paired.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/permissions.js +2 -0
- package/lib/commonjs/modules/next/bluetooth/permissions.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js +44 -0
- package/lib/commonjs/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/context.js +54 -0
- package/lib/commonjs/modules/next/bluetooth/react/context.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react/hooks.js +86 -0
- package/lib/commonjs/modules/next/bluetooth/react/hooks.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +28 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/readings.js +92 -0
- package/lib/commonjs/modules/next/bluetooth/readings.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/result-policy.js +6 -1
- package/lib/commonjs/modules/next/bluetooth/result-policy.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/runtime.js +223 -0
- package/lib/commonjs/modules/next/bluetooth/runtime.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/scan-loop.js +82 -0
- package/lib/commonjs/modules/next/bluetooth/scan-loop.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/sink.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/sink.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/snapshot.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/snapshot.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/stable-hash.js +33 -0
- package/lib/commonjs/modules/next/bluetooth/stable-hash.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/store.js +61 -0
- package/lib/commonjs/modules/next/bluetooth/store.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/transport.js +6 -0
- package/lib/commonjs/modules/next/bluetooth/transport.js.map +1 -0
- package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js +3 -1
- package/lib/module/modules/bt-management/components/android-bluetooth-foreground-service.js.map +1 -1
- package/lib/module/modules/bt-management/components/bluetooth-device-picker.js +9 -141
- package/lib/module/modules/bt-management/components/bluetooth-device-picker.js.map +1 -1
- package/lib/module/modules/bt-management/components/device-picker-sheet.js +154 -0
- package/lib/module/modules/bt-management/components/device-picker-sheet.js.map +1 -0
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js +4 -3
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-measurements.js +1 -1
- package/lib/module/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +1 -1
- package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
- package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js +14 -0
- package/lib/module/modules/bt-management/utils/bluetooth-permission-list.js.map +1 -0
- package/lib/module/modules/bt-management/utils/result-identity.js +3 -25
- package/lib/module/modules/bt-management/utils/result-identity.js.map +1 -1
- package/lib/module/modules/next/bluetooth/auto-connect.js +28 -0
- package/lib/module/modules/next/bluetooth/auto-connect.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js +28 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-errors.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js +122 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-link.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js +69 -0
- package/lib/module/modules/next/bluetooth/ble-plx/ble-scanner.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js +31 -0
- package/lib/module/modules/next/bluetooth/ble-plx/built-in-devices.js.map +1 -0
- package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js +63 -0
- package/lib/module/modules/next/bluetooth/ble-plx/legacy-driver.js.map +1 -0
- package/lib/module/modules/next/bluetooth/connections.js +106 -0
- package/lib/module/modules/next/bluetooth/connections.js.map +1 -0
- package/lib/module/modules/next/bluetooth/daily-total-day.js.map +1 -0
- package/lib/module/modules/next/bluetooth/devices.js +37 -0
- package/lib/module/modules/next/bluetooth/devices.js.map +1 -0
- package/lib/module/modules/next/bluetooth/driver.js +23 -20
- package/lib/module/modules/next/bluetooth/driver.js.map +1 -1
- package/lib/module/modules/next/bluetooth/errors.js +21 -0
- package/lib/module/modules/next/bluetooth/errors.js.map +1 -0
- package/lib/module/modules/next/bluetooth/index.js +21 -3
- package/lib/module/modules/next/bluetooth/index.js.map +1 -1
- package/lib/module/modules/next/bluetooth/link.js +0 -101
- package/lib/module/modules/next/bluetooth/link.js.map +1 -1
- package/lib/module/modules/next/bluetooth/paired.js +46 -0
- package/lib/module/modules/next/bluetooth/paired.js.map +1 -0
- package/lib/module/modules/next/bluetooth/permissions.js +2 -0
- package/lib/module/modules/next/bluetooth/permissions.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js +39 -0
- package/lib/module/modules/next/bluetooth/react/bluetooth-device-picker.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/context.js +48 -0
- package/lib/module/modules/next/bluetooth/react/context.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react/hooks.js +76 -0
- package/lib/module/modules/next/bluetooth/react/hooks.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js +25 -0
- package/lib/module/modules/next/bluetooth/react-native/create-bluetooth-runtime.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/os-permissions.js +28 -0
- package/lib/module/modules/next/bluetooth/react-native/os-permissions.js.map +1 -0
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js +28 -0
- package/lib/module/modules/next/bluetooth/react-native/ovok-sink.js.map +1 -0
- package/lib/module/modules/next/bluetooth/readings.js +88 -0
- package/lib/module/modules/next/bluetooth/readings.js.map +1 -0
- package/lib/module/modules/next/bluetooth/result-policy.js +6 -1
- package/lib/module/modules/next/bluetooth/result-policy.js.map +1 -1
- package/lib/module/modules/next/bluetooth/runtime.js +220 -0
- package/lib/module/modules/next/bluetooth/runtime.js.map +1 -0
- package/lib/module/modules/next/bluetooth/scan-loop.js +78 -0
- package/lib/module/modules/next/bluetooth/scan-loop.js.map +1 -0
- package/lib/module/modules/next/bluetooth/sink.js +4 -0
- package/lib/module/modules/next/bluetooth/sink.js.map +1 -0
- package/lib/module/modules/next/bluetooth/snapshot.js +4 -0
- package/lib/module/modules/next/bluetooth/snapshot.js.map +1 -0
- package/lib/module/modules/next/bluetooth/stable-hash.js +28 -0
- package/lib/module/modules/next/bluetooth/stable-hash.js.map +1 -0
- package/lib/module/modules/next/bluetooth/store.js +57 -0
- package/lib/module/modules/next/bluetooth/store.js.map +1 -0
- package/lib/module/modules/next/bluetooth/transport.js +4 -0
- package/lib/module/modules/next/bluetooth/transport.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/bluetooth-permission-list.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts +25 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/connections.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/devices.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts +21 -19
- package/lib/typescript/commonjs/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +32 -3
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts +2 -4
- package/lib/typescript/commonjs/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/paired.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts +30 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/readings.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts +87 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts +20 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/sink.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts +69 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts +16 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/transport.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/components/android-bluetooth-foreground-service.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bluetooth-device-picker.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts +25 -0
- package/lib/typescript/module/src/modules/bt-management/components/device-picker-sheet.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-measurements.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/utils/bluetooth-permission-list.d.ts +4 -0
- package/lib/typescript/module/src/modules/bt-management/utils/bluetooth-permission-list.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/utils/result-identity.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts +10 -0
- package/lib/typescript/module/src/modules/next/bluetooth/auto-connect.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts +4 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-errors.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-link.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts +10 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/ble-scanner.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/built-in-devices.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts +8 -0
- package/lib/typescript/module/src/modules/next/bluetooth/ble-plx/legacy-driver.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts +25 -0
- package/lib/typescript/module/src/modules/next/bluetooth/connections.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/daily-total-day.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts +30 -0
- package/lib/typescript/module/src/modules/next/bluetooth/devices.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts +21 -19
- package/lib/typescript/module/src/modules/next/bluetooth/driver.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts +17 -0
- package/lib/typescript/module/src/modules/next/bluetooth/errors.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +32 -3
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts +2 -4
- package/lib/typescript/module/src/modules/next/bluetooth/link.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts +18 -0
- package/lib/typescript/module/src/modules/next/bluetooth/paired.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts +13 -0
- package/lib/typescript/module/src/modules/next/bluetooth/permissions.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts +35 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/bluetooth-device-picker.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts +30 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/context.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts +47 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts +21 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/create-bluetooth-runtime.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts +5 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/os-permissions.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/react-native/ovok-sink.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts +21 -0
- package/lib/typescript/module/src/modules/next/bluetooth/readings.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/result-policy.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts +87 -0
- package/lib/typescript/module/src/modules/next/bluetooth/runtime.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts +23 -0
- package/lib/typescript/module/src/modules/next/bluetooth/scan-loop.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts +20 -0
- package/lib/typescript/module/src/modules/next/bluetooth/sink.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts +69 -0
- package/lib/typescript/module/src/modules/next/bluetooth/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/stable-hash.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts +16 -0
- package/lib/typescript/module/src/modules/next/bluetooth/store.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts +31 -0
- package/lib/typescript/module/src/modules/next/bluetooth/transport.d.ts.map +1 -0
- package/package.json +1 -1
- package/lib/commonjs/modules/bt-management/utils/daily-total-day.js.map +0 -1
- package/lib/commonjs/modules/next/bluetooth/drivers.js +0 -20
- package/lib/commonjs/modules/next/bluetooth/drivers.js.map +0 -1
- package/lib/commonjs/modules/next/bluetooth/legacy-driver.js +0 -55
- package/lib/commonjs/modules/next/bluetooth/legacy-driver.js.map +0 -1
- package/lib/module/modules/bt-management/utils/daily-total-day.js.map +0 -1
- package/lib/module/modules/next/bluetooth/drivers.js +0 -17
- package/lib/module/modules/next/bluetooth/drivers.js.map +0 -1
- package/lib/module/modules/next/bluetooth/legacy-driver.js +0 -51
- package/lib/module/modules/next/bluetooth/legacy-driver.js.map +0 -1
- package/lib/typescript/commonjs/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts +0 -7
- package/lib/typescript/commonjs/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
- package/lib/typescript/commonjs/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/bt-management/utils/daily-total-day.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts +0 -7
- package/lib/typescript/module/src/modules/next/bluetooth/drivers.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts +0 -8
- package/lib/typescript/module/src/modules/next/bluetooth/legacy-driver.d.ts.map +0 -1
- /package/lib/commonjs/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
- /package/lib/module/modules/{bt-management/utils → next/bluetooth}/daily-total-day.js +0 -0
- /package/lib/typescript/commonjs/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
- /package/lib/typescript/module/src/modules/{bt-management/utils → next/bluetooth}/daily-total-day.d.ts +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { asBluetoothError, BluetoothError } from "./errors.js";
|
|
4
|
+
import { keepReadings } from "./result-policy.js";
|
|
5
|
+
const endedBeforeConnecting = () => new BluetoothError("connection-failed", "The device disconnected before it connected");
|
|
6
|
+
|
|
7
|
+
/** One driver run per connected device, its events folded into the snapshot. */
|
|
8
|
+
class Connections {
|
|
9
|
+
sessions = new Map();
|
|
10
|
+
constructor(store, readings, policy, onEnded) {
|
|
11
|
+
this.store = store;
|
|
12
|
+
this.readings = readings;
|
|
13
|
+
this.policy = policy;
|
|
14
|
+
this.onEnded = onEnded;
|
|
15
|
+
}
|
|
16
|
+
isActive(id) {
|
|
17
|
+
return this.sessions.has(id);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Resolves once connected; joins a connection still opening or open, and waits out one being closed. */
|
|
21
|
+
async connect(peripheral, driver) {
|
|
22
|
+
const current = this.sessions.get(peripheral.id);
|
|
23
|
+
if (current?.controller.signal.aborted) {
|
|
24
|
+
await current.ended;
|
|
25
|
+
return this.connect(peripheral, driver);
|
|
26
|
+
}
|
|
27
|
+
return (current ?? this.start(peripheral, driver)).connected;
|
|
28
|
+
}
|
|
29
|
+
async disconnect(id) {
|
|
30
|
+
const session = this.sessions.get(id);
|
|
31
|
+
session?.controller.abort();
|
|
32
|
+
await session?.ended;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Disconnects every device; resolves once every connection has ended. */
|
|
36
|
+
async disconnectAll() {
|
|
37
|
+
await Promise.all([...this.sessions.keys()].map(id => this.disconnect(id)));
|
|
38
|
+
}
|
|
39
|
+
start(peripheral, driver) {
|
|
40
|
+
const {
|
|
41
|
+
id
|
|
42
|
+
} = peripheral;
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
let markConnected = () => undefined;
|
|
45
|
+
let failConnecting = () => undefined;
|
|
46
|
+
const connected = new Promise((resolve, reject) => {
|
|
47
|
+
markConnected = resolve;
|
|
48
|
+
failConnecting = reject;
|
|
49
|
+
});
|
|
50
|
+
this.store.updateDevice(id, {
|
|
51
|
+
connection: "connecting",
|
|
52
|
+
error: null
|
|
53
|
+
});
|
|
54
|
+
const ended = this.run(peripheral, driver, controller.signal, () => markConnected()).then(() => {
|
|
55
|
+
this.store.updateDevice(id, {
|
|
56
|
+
connection: "disconnected"
|
|
57
|
+
});
|
|
58
|
+
failConnecting(endedBeforeConnecting());
|
|
59
|
+
}).catch(error => {
|
|
60
|
+
const failure = asBluetoothError(error, "connection-failed");
|
|
61
|
+
this.store.updateDevice(id, controller.signal.aborted ? {
|
|
62
|
+
connection: "disconnected"
|
|
63
|
+
} : {
|
|
64
|
+
connection: "failed",
|
|
65
|
+
error: failure
|
|
66
|
+
});
|
|
67
|
+
failConnecting(failure);
|
|
68
|
+
}).finally(() => {
|
|
69
|
+
this.sessions.delete(id);
|
|
70
|
+
this.onEnded(id);
|
|
71
|
+
});
|
|
72
|
+
const session = {
|
|
73
|
+
controller,
|
|
74
|
+
connected,
|
|
75
|
+
ended
|
|
76
|
+
};
|
|
77
|
+
this.sessions.set(id, session);
|
|
78
|
+
return session;
|
|
79
|
+
}
|
|
80
|
+
async run(peripheral, driver, signal, connected) {
|
|
81
|
+
for await (const event of keepReadings(driver(peripheral, signal), this.policy)) {
|
|
82
|
+
this.apply(peripheral.id, event, connected);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
apply(id, event, connected) {
|
|
86
|
+
if (event.kind === "status") {
|
|
87
|
+
if (event.status !== "disconnected") {
|
|
88
|
+
connected();
|
|
89
|
+
}
|
|
90
|
+
this.store.updateDevice(id, {
|
|
91
|
+
connection: event.status
|
|
92
|
+
});
|
|
93
|
+
} else if (event.kind === "reading") {
|
|
94
|
+
const device = this.store.device(id);
|
|
95
|
+
if (device) {
|
|
96
|
+
this.readings.receive(device, event.id, event.reading);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
this.store.updateDevice(id, {
|
|
100
|
+
error: event.error
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export { Connections };
|
|
106
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asBluetoothError","BluetoothError","keepReadings","endedBeforeConnecting","Connections","sessions","Map","constructor","store","readings","policy","onEnded","isActive","id","has","connect","peripheral","driver","current","get","controller","signal","aborted","ended","start","connected","disconnect","session","abort","disconnectAll","Promise","all","keys","map","AbortController","markConnected","undefined","failConnecting","resolve","reject","updateDevice","connection","error","run","then","catch","failure","finally","delete","set","event","apply","kind","status","device","receive","reading"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/connections.ts"],"mappings":";;AACA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,aAAU;AAE3D,SAASC,YAAY,QAAsB,oBAAiB;AAM5D,MAAMC,qBAAqB,GAAGA,CAAA,KAC5B,IAAIF,cAAc,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;;AAExF;AACA,MAAMG,WAAW,CAAC;EACCC,QAAQ,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAE/CC,WAAWA,CACCC,KA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C,CAAC;IACrD;EACF;AACF;AAEA,SAAStC,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["dailyTotalDay","data","now","temporal","end","Date","getTime","day","start","recordedAt","toISOString","slice","undefined"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/daily-total-day.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAGA,CAC3BC,IAAY,EACZC,GAAW,KACY;EACvB,MAAMC,QAAQ,GAAGF,IAAuD;EAExE,IAAIE,QAAQ,CAACC,GAAG,YAAYC,IAAI,IAAIF,QAAQ,CAACC,GAAG,CAACE,OAAO,CAAC,CAAC,GAAGJ,GAAG,EAAE;IAChE,OAAO,QAAQ;EACjB;EAEA,MAAMK,GAAG,GAAGJ,QAAQ,CAACC,GAAG,IAAID,QAAQ,CAACK,KAAK,IAAIL,QAAQ,CAACM,UAAU;EAEjE,OAAOF,GAAG,YAAYF,IAAI,GAAGE,GAAG,CAACG,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGC,SAAS;AACzE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { gattDriver } from "./driver.js";
|
|
4
|
+
|
|
5
|
+
/** A peripheral a support recognised: the device key its readings carry and the driver that runs it. */
|
|
6
|
+
|
|
7
|
+
/** Recognises peripherals by their advertisement. */
|
|
8
|
+
|
|
9
|
+
/** A device a third party adds: how to recognise it and the protocol that reads it. */
|
|
10
|
+
|
|
11
|
+
/** Support for one device a third party defines with its own protocol. */
|
|
12
|
+
const defineDevice = ({
|
|
13
|
+
key,
|
|
14
|
+
matches,
|
|
15
|
+
protocol
|
|
16
|
+
}) => {
|
|
17
|
+
const driver = gattDriver(key, protocol);
|
|
18
|
+
return {
|
|
19
|
+
match: advertisement => matches(advertisement) ? {
|
|
20
|
+
key,
|
|
21
|
+
driver
|
|
22
|
+
} : undefined
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** The first support's match for an advertisement. */
|
|
27
|
+
const matchDevice = (devices, advertisement) => {
|
|
28
|
+
for (const support of devices) {
|
|
29
|
+
const match = support.match(advertisement);
|
|
30
|
+
if (match) {
|
|
31
|
+
return match;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
export { defineDevice, matchDevice };
|
|
37
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["gattDriver","defineDevice","key","matches","protocol","driver","match","advertisement","undefined","matchDevice","devices","support"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/devices.ts"],"mappings":";;AAAA,SAAiCA,UAAU,QAAQ,aAAU;;AAG7D;;AAUA;;AAOA;;AAaA;AACA,MAAMC,YAAY,GAAGA,CAAC;EAAEC,GAAG;EAAEC,OAAO;EAAEC;AAA2B,CAAC,KAAoB;EACpF,MAAMC,MAAM,GAAGL,UAAU,CAACE,GAAG,EAAEE,QAAQ,CAAC;EAExC,OAAO;IAAEE,KAAK,EAAGC,aAAa,IAAMJ,OAAO,CAACI,aAAa,CAAC,GAAG;MAAEL,GAAG;MAAEG;IAAO,CAAC,GAAGG;EAAW,CAAC;AAC7F,CAAC;;AAED;AACA,MAAMC,WAAW,GAAGA,CAACC,OAAiC,EAAEH,aAA4B,KAA8B;EAChH,KAAK,MAAMI,OAAO,IAAID,OAAO,EAAE;IAC7B,MAAMJ,KAAK,GAAGK,OAAO,CAACL,KAAK,CAACC,aAAa,CAAC;IAE1C,IAAID,KAAK,EAAE;MACT,OAAOA,KAAK;IACd;EACF;EAEA,OAAOE,SAAS;AAClB,CAAC;AAED,SAASP,YAAY,EAAEQ,WAAW","ignoreList":[]}
|
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { createStableResultId } from "../../bt-management/utils/result-identity.js";
|
|
5
|
-
import { openBleLink } from "./link.js";
|
|
3
|
+
import { stableHash } from "./stable-hash.js";
|
|
6
4
|
|
|
7
|
-
/**
|
|
5
|
+
/** What a driver reports while it runs. */
|
|
6
|
+
|
|
7
|
+
/** Connects to a peripheral and reports what happens until it disconnects or `signal` aborts. */
|
|
8
8
|
|
|
9
9
|
/** One device's conversation over a link, as the readings it produces. */
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
/** Whether a reading carries the time it was taken, which makes a stored reading recognisable when resent. */
|
|
12
|
+
const isTimestamped = reading => {
|
|
13
|
+
const temporal = reading;
|
|
14
|
+
return [temporal.recordedAt, temporal.start, temporal.end].some(value => value instanceof Date);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The same for every resend of a timestamped reading; `null` for a reading without a time. */
|
|
18
|
+
const readingId = (key, peripheral, reading) => isTimestamped(reading) ? `ovok:${stableHash({
|
|
19
|
+
key,
|
|
20
|
+
peripheral: peripheral.id,
|
|
21
|
+
reading
|
|
22
|
+
})}` : null;
|
|
19
23
|
|
|
20
|
-
/** Runs a protocol over a fresh
|
|
21
|
-
const gattDriver = (
|
|
22
|
-
const link = await
|
|
23
|
-
const identity = readingIdentity(deviceName, device);
|
|
24
|
+
/** Runs a protocol over a fresh link. */
|
|
25
|
+
const gattDriver = (key, protocol) => async function* (peripheral, signal) {
|
|
26
|
+
const link = await peripheral.openLink(signal);
|
|
24
27
|
try {
|
|
25
28
|
yield {
|
|
26
29
|
kind: "status",
|
|
27
|
-
status:
|
|
30
|
+
status: "connected"
|
|
28
31
|
};
|
|
29
32
|
for await (const reading of protocol(link)) {
|
|
30
33
|
yield {
|
|
31
34
|
kind: "reading",
|
|
32
|
-
id:
|
|
35
|
+
id: readingId(key, peripheral, reading),
|
|
33
36
|
reading
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
yield {
|
|
37
40
|
kind: "status",
|
|
38
|
-
status:
|
|
41
|
+
status: "disconnected"
|
|
39
42
|
};
|
|
40
43
|
} finally {
|
|
41
44
|
await link.close();
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
|
-
export { gattDriver };
|
|
47
|
+
export { gattDriver, isTimestamped };
|
|
45
48
|
//# sourceMappingURL=driver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["stableHash","isTimestamped","reading","temporal","recordedAt","start","end","some","value","Date","readingId","key","peripheral","id","gattDriver","protocol","signal","link","openLink","kind","status","close"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/driver.ts"],"mappings":";;AAIA,SAASA,UAAU,QAAQ,kBAAe;;AAG1C;;AA8BA;;AAGA;;AAGA;AACA,MAAMC,aAAa,GAAIC,OAAoB,IAAc;EACvD,MAAMC,QAAQ,GAAGD,OAAmE;EAEpF,OAAO,CAACC,QAAQ,CAACC,UAAU,EAAED,QAAQ,CAACE,KAAK,EAAEF,QAAQ,CAACG,GAAG,CAAC,CAACC,IAAI,CAAEC,KAAK,IAAKA,KAAK,YAAYC,IAAI,CAAC;AACnG,CAAC;;AAED;AACA,MAAMC,SAAS,GAAGA,CAACC,GAAW,EAAEC,UAAsB,EAAEV,OAAoB,KAC1ED,aAAa,CAACC,OAAO,CAAC,GAAG,QAAQF,UAAU,CAAC;EAAEW,GAAG;EAAEC,UAAU,EAAEA,UAAU,CAACC,EAAE;EAAEX;AAAQ,CAAC,CAAC,EAAE,GAAG,IAAI;;AAEnG;AACA,MAAMY,UAAU,GAAGA,CAACH,GAAW,EAAEI,QAAwB,KACvD,iBAAiBH,UAAU,EAAEI,MAAM,EAAE;EACnC,MAAMC,IAAI,GAAG,MAAML,UAAU,CAACM,QAAQ,CAACF,MAAM,CAAC;EAE9C,IAAI;IACF,MAAM;MAAEG,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE;IAAY,CAAC;IAC7C,WAAW,MAAMlB,OAAO,IAAIa,QAAQ,CAACE,IAAI,CAAC,EAAE;MAC1C,MAAM;QAAEE,IAAI,EAAE,SAAS;QAAEN,EAAE,EAAEH,SAAS,CAACC,GAAG,EAAEC,UAAU,EAAEV,OAAO,CAAC;QAAEA;MAAQ,CAAC;IAC7E;IACA,MAAM;MAAEiB,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE;IAAe,CAAC;EAClD,CAAC,SAAS;IACR,MAAMH,IAAI,CAACI,KAAK,CAAC,CAAC;EACpB;AACF,CAAC;AAEH,SAASP,UAAU,EAAEb,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Why a Bluetooth operation failed. */
|
|
4
|
+
|
|
5
|
+
/** Every failure the Bluetooth runtime reports; `cause` holds the underlying error, when any. */
|
|
6
|
+
class BluetoothError extends Error {
|
|
7
|
+
/** Always `"BluetoothError"`. */
|
|
8
|
+
name = "BluetoothError";
|
|
9
|
+
constructor(/** Why it failed. */
|
|
10
|
+
code, message, cause) {
|
|
11
|
+
super(message, {
|
|
12
|
+
cause
|
|
13
|
+
});
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** `error` as a `BluetoothError`, classified as `code` unless it already is one. */
|
|
19
|
+
const asBluetoothError = (error, code) => error instanceof BluetoothError ? error : new BluetoothError(code, error instanceof Error ? error.message : String(error), error);
|
|
20
|
+
export { asBluetoothError, BluetoothError };
|
|
21
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BluetoothError","Error","name","constructor","code","message","cause","asBluetoothError","error","String"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/errors.ts"],"mappings":";;AAAA;;AAiBA;AACA,MAAMA,cAAc,SAASC,KAAK,CAAC;EACjC;EACgBC,IAAI,GAAG,gBAAgB;EAEhCC,WAAWA,CAEhB;EACgBC,IAAwB,EACxCC,OAAe,EACfC,KAAe,EACf;IACA,KAAK,CAACD,OAAO,EAAE;MAAEC;IAAM,CAAC,CAAC;IAAC,KAJVF,IAAwB,GAAxBA,IAAwB;EAK1C;AACF;;AAEA;AACA,MAAMG,gBAAgB,GAAGA,CAACC,KAAc,EAAEJ,IAAwB,KAChEI,KAAK,YAAYR,cAAc,GAC3BQ,KAAK,GACL,IAAIR,cAAc,CAACI,IAAI,EAAEI,KAAK,YAAYP,KAAK,GAAGO,KAAK,CAACH,OAAO,GAAGI,MAAM,CAACD,KAAK,CAAC,EAAEA,KAAK,CAAC;AAE7F,SAASD,gBAAgB,EAAEP,cAAc","ignoreList":[]}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Bluetooth for `@ovok/native/next`, in layers: the framework-free `BluetoothRuntime` and its ports, device drivers,
|
|
5
|
+
* the `react-native-ble-plx` and React Native adapters, React hooks over the runtime, and optional UI built only from
|
|
6
|
+
* those hooks.
|
|
7
|
+
*
|
|
8
|
+
* Import from `@ovok/native/next/bluetooth`.
|
|
9
|
+
*
|
|
10
|
+
* @module next/bluetooth
|
|
11
|
+
*/
|
|
12
|
+
export { BluetoothRuntime } from "./runtime.js";
|
|
13
|
+
export { BluetoothError } from "./errors.js";
|
|
14
|
+
export { defineDevice } from "./devices.js";
|
|
6
15
|
export { dailyTotalsOnly, everyReading, firstReadingPerKind, keepReadings, policyByKind } from "./result-policy.js";
|
|
7
16
|
export { SIG_PROTOCOLS } from "./sig-profiles.js";
|
|
17
|
+
export { bleManagerScanner } from "./ble-plx/ble-scanner.js";
|
|
18
|
+
export { builtInDevices } from "./ble-plx/built-in-devices.js";
|
|
19
|
+
export { IntegratedDevices } from "../../bt-management/types/integrated-devices.js";
|
|
20
|
+
export { osBluetoothPermissions } from "./react-native/os-permissions.js";
|
|
21
|
+
export { ovokReadingSink } from "./react-native/ovok-sink.js";
|
|
22
|
+
export { createBluetoothRuntime } from "./react-native/create-bluetooth-runtime.js";
|
|
23
|
+
export { BluetoothProvider, useBluetooth } from "./react/context.js";
|
|
24
|
+
export { useBluetoothPermission, useBluetoothState, useMeasurements, useNearbyDevice, useNearbyDevices, usePairedDevices, useScanning } from "./react/hooks.js";
|
|
25
|
+
export { BluetoothDevicePicker } from "./react/bluetooth-device-picker.js";
|
|
8
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BluetoothRuntime","BluetoothError","defineDevice","dailyTotalsOnly","everyReading","firstReadingPerKind","keepReadings","policyByKind","SIG_PROTOCOLS","bleManagerScanner","builtInDevices","IntegratedDevices","osBluetoothPermissions","ovokReadingSink","createBluetoothRuntime","BluetoothProvider","useBluetooth","useBluetoothPermission","useBluetoothState","useMeasurements","useNearbyDevice","useNearbyDevices","usePairedDevices","useScanning","BluetoothDevicePicker"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,cAAW;AAE5C,SAASC,cAAc,QAAQ,aAAU;AAOzC,SAASC,YAAY,QAAQ,cAAW;AAIxC,SAASC,eAAe,EAAEC,YAAY,EAAEC,mBAAmB,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAiB;AAEhH,SAASC,aAAa,QAAQ,mBAAgB;AAE9C,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,iBAAiB,QAAQ,iDAA8C;AAEhF,SAASC,sBAAsB,QAAQ,kCAA+B;AACtE,SAASC,eAAe,QAAQ,6BAA0B;AAC1D,SAASC,sBAAsB,QAAQ,4CAAyC;AAGhF,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,oBAAiB;AAEjE,SACEC,sBAAsB,EACtBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,WAAW,QACN,kBAAe;AACtB,SAASC,qBAAqB,QAAQ,oCAAiC","ignoreList":[]}
|
|
@@ -1,103 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
import { toBluetoothError } from "../../bt-management/types/bluetooth-error.js";
|
|
4
|
-
import { sentryLogger } from "../../helpers/utils/sentry-logger.js";
|
|
5
|
-
import { Channel } from "./channel.js";
|
|
6
|
-
|
|
7
|
-
/** An open GATT connection: bytes in, bytes out, no knowledge of any device. */
|
|
8
|
-
|
|
9
|
-
const CONNECT_ATTEMPTS = 5;
|
|
10
|
-
const FIRST_RETRY_DELAY_MS = 1000;
|
|
11
|
-
const MAX_RETRY_DELAY_MS = 5000;
|
|
12
|
-
|
|
13
|
-
/** BleErrorCode.OperationCancelled and DeviceDisconnected; the enum is not available at runtime. */
|
|
14
|
-
const ENDS_THE_LINK = new Set([2, 201]);
|
|
15
|
-
const toBytes = base64 => Uint8Array.from(atob(base64), char => char.charCodeAt(0));
|
|
16
|
-
const toBase64 = bytes => btoa(String.fromCharCode(...bytes));
|
|
17
|
-
const retryDelay = attempt => Math.min(FIRST_RETRY_DELAY_MS * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
18
|
-
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
-
const abortReason = signal => signal.reason ?? new Error("The Bluetooth connection was cancelled");
|
|
20
|
-
async function connectWithRetries(device, signal) {
|
|
21
|
-
for (let attempt = 1;; attempt += 1) {
|
|
22
|
-
if (signal.aborted) {
|
|
23
|
-
throw abortReason(signal);
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
if (!(await device.isConnected())) {
|
|
27
|
-
await device.connect();
|
|
28
|
-
}
|
|
29
|
-
return;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
if (attempt >= CONNECT_ATTEMPTS) {
|
|
32
|
-
sentryLogger("error", "BLUETOOTH: Connection failed", {
|
|
33
|
-
errorCode: toBluetoothError(error).code,
|
|
34
|
-
attempts: attempt
|
|
35
|
-
});
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
await wait(retryDelay(attempt));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class BleLink {
|
|
43
|
-
channels = new Set();
|
|
44
|
-
ended = false;
|
|
45
|
-
constructor(device) {
|
|
46
|
-
this.device = device;
|
|
47
|
-
this.disconnected = device.onDisconnected(() => this.endAll());
|
|
48
|
-
}
|
|
49
|
-
subscribe(service, characteristic) {
|
|
50
|
-
const channel = new Channel(() => {
|
|
51
|
-
subscription.remove();
|
|
52
|
-
this.channels.delete(channel);
|
|
53
|
-
});
|
|
54
|
-
const subscription = this.device.monitorCharacteristicForService(service, characteristic, (error, value) => {
|
|
55
|
-
if (error) {
|
|
56
|
-
this.endOrFail(channel, error);
|
|
57
|
-
} else if (value?.value) {
|
|
58
|
-
channel.push(toBytes(value.value));
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
this.channels.add(channel);
|
|
62
|
-
if (this.ended) {
|
|
63
|
-
channel.end();
|
|
64
|
-
}
|
|
65
|
-
return channel;
|
|
66
|
-
}
|
|
67
|
-
async write(service, characteristic, bytes) {
|
|
68
|
-
await this.device.writeCharacteristicWithResponseForService(service, characteristic, toBase64(bytes));
|
|
69
|
-
}
|
|
70
|
-
async close() {
|
|
71
|
-
this.endAll();
|
|
72
|
-
this.disconnected.remove();
|
|
73
|
-
await this.device.cancelConnection().catch(() => undefined);
|
|
74
|
-
}
|
|
75
|
-
endOrFail(channel, error) {
|
|
76
|
-
if (ENDS_THE_LINK.has(error.errorCode)) {
|
|
77
|
-
channel.end();
|
|
78
|
-
} else {
|
|
79
|
-
channel.fail(toBluetoothError(error));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
endAll() {
|
|
83
|
-
this.ended = true;
|
|
84
|
-
[...this.channels].forEach(channel => channel.end());
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Connects (retrying with backoff) and discovers services; aborting `signal` closes the link. */
|
|
89
|
-
async function openBleLink(device, signal) {
|
|
90
|
-
await connectWithRetries(device, signal);
|
|
91
|
-
await device.discoverAllServicesAndCharacteristics();
|
|
92
|
-
const link = new BleLink(device);
|
|
93
|
-
if (signal.aborted) {
|
|
94
|
-
await link.close();
|
|
95
|
-
throw abortReason(signal);
|
|
96
|
-
}
|
|
97
|
-
signal.addEventListener("abort", () => void link.close(), {
|
|
98
|
-
once: true
|
|
99
|
-
});
|
|
100
|
-
return link;
|
|
101
|
-
}
|
|
102
|
-
export { openBleLink };
|
|
103
2
|
//# sourceMappingURL=link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/link.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_PAIRED_KEY = "@ovok/native/next/paired-bluetooth-devices";
|
|
4
|
+
const parseIds = value => {
|
|
5
|
+
try {
|
|
6
|
+
const parsed = value ? JSON.parse(value) : [];
|
|
7
|
+
return Array.isArray(parsed) ? parsed.filter(id => typeof id === "string") : [];
|
|
8
|
+
} catch {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** The paired device IDs, persisted when storage is given. */
|
|
14
|
+
class PairedDevices {
|
|
15
|
+
ids = [];
|
|
16
|
+
constructor(onChange, storage, key = DEFAULT_PAIRED_KEY) {
|
|
17
|
+
this.onChange = onChange;
|
|
18
|
+
this.storage = storage;
|
|
19
|
+
this.key = key;
|
|
20
|
+
this.loaded = this.load();
|
|
21
|
+
}
|
|
22
|
+
has(id) {
|
|
23
|
+
return this.ids.includes(id);
|
|
24
|
+
}
|
|
25
|
+
async add(id) {
|
|
26
|
+
await this.change(ids => [...new Set([...ids, id])]);
|
|
27
|
+
}
|
|
28
|
+
async remove(id) {
|
|
29
|
+
await this.change(ids => ids.filter(candidate => candidate !== id));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Waits for the stored list, so a change never overwrites IDs not read yet. */
|
|
33
|
+
async change(update) {
|
|
34
|
+
await this.loaded;
|
|
35
|
+
this.ids = update(this.ids);
|
|
36
|
+
this.onChange(this.ids);
|
|
37
|
+
await this.storage?.setItem(this.key, JSON.stringify(this.ids));
|
|
38
|
+
}
|
|
39
|
+
async load() {
|
|
40
|
+
const stored = await Promise.resolve(this.storage?.getItem(this.key) ?? null).catch(() => null);
|
|
41
|
+
this.ids = parseIds(stored);
|
|
42
|
+
this.onChange(this.ids);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export { PairedDevices };
|
|
46
|
+
//# sourceMappingURL=paired.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_PAIRED_KEY","parseIds","value","parsed","JSON","parse","Array","isArray","filter","id","PairedDevices","ids","constructor","onChange","storage","key","loaded","load","has","includes","add","change","Set","remove","candidate","update","setItem","stringify","stored","Promise","resolve","getItem","catch"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/paired.ts"],"mappings":";;AAEA,MAAMA,kBAAkB,GAAG,4CAA4C;AAEvE,MAAMC,QAAQ,GAAIC,KAAoB,IAAe;EACnD,IAAI;IACF,MAAMC,MAAe,GAAGD,KAAK,GAAGE,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC,GAAG,EAAE;IAEtD,OAAOI,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,GAAGA,MAAM,CAACK,MAAM,CAAEC,EAAE,IAA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,EAAkB;IAClC,MAAMW,MAAM,GAAG,MAAMC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAChB,OAAO,EAAEiB,OAAO,CAAC,IAAI,CAAChB,GAAG,CAAC,IAAI,IAAI,CAAC,CAACiB,KAAK,CAAC,MAAM,IAAI,CAAC;IAE/F,IAAI,CAACrB,GAAG,GAAGV,QAAQ,CAAC2B,MAAM,CAAC;IAC3B,IAAI,CAACf,QAAQ,CAAC,IAAI,CAACF,GAAG,CAAC;EACzB;AACF;AAEA,SAASD,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/permissions.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { DevicePickerSheet } from "../../../bt-management/components/device-picker-sheet.js";
|
|
5
|
+
import { useBluetooth } from "./context.js";
|
|
6
|
+
import { useNearbyDevices } from "./hooks.js";
|
|
7
|
+
|
|
8
|
+
/** Props of {@link BluetoothDevicePicker}. */
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* A bottom sheet listing the found devices; picking one connects to it. Built only from public hooks.
|
|
12
|
+
*
|
|
13
|
+
* @group Components
|
|
14
|
+
*/
|
|
15
|
+
const BluetoothDevicePicker = ({
|
|
16
|
+
onSelect,
|
|
17
|
+
title = "Choose a device",
|
|
18
|
+
dismissLabel = "Not now",
|
|
19
|
+
labelForDevice = device => device.name || device.key,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const runtime = useBluetooth();
|
|
23
|
+
const devices = useNearbyDevices();
|
|
24
|
+
const select = device => {
|
|
25
|
+
runtime.connect(device.id).catch(() => undefined);
|
|
26
|
+
onSelect?.(device);
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/_jsx(DevicePickerSheet, {
|
|
29
|
+
...props,
|
|
30
|
+
devices: devices,
|
|
31
|
+
onSelect: select,
|
|
32
|
+
title: title,
|
|
33
|
+
dismissLabel: dismissLabel,
|
|
34
|
+
labelForDevice: labelForDevice,
|
|
35
|
+
modelForDevice: device => device.key
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export { BluetoothDevicePicker };
|
|
39
|
+
//# sourceMappingURL=bluetooth-device-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","DevicePickerSheet","useBluetooth","useNearbyDevices","jsx","_jsx","BluetoothDevicePicker","onSelect","title","dismissLabel","labelForDevice","device","name","key","props","runtime","devices","select","connect","id","catch","undefined","modelForDevice"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react/bluetooth-device-picker.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B,SAASC,iBAAiB,QAAQ,0DAAuD;AAGzF,SAASC,YAAY,QAAQ,cAAW;AACxC,SAASC,gBAAgB,QAAQ,YAAS;;AAE1C;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA+BA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAGA,CAAC;EAC7BC,QAAQ;EACRC,KAAK,GAAG,iBAAiB;EACzBC,YAAY,GAAG,SAAS;EACxBC,cAAc,GAAIC,MAAM,IAAKA,MAAM,CAACC,IAAI,IAAID,MAAM,CAACE,GAAG;EACtD,GAAGC;AACuB,CAAC,KAAK;EAChC,MAAMC,OAAO,GAAGb,YAAY,CAAC,CAAC;EAC9B,MAAMc,OAAO,GAAGb,gBAAgB,CAAC,CAAC;EAElC,MAAMc,MAAM,GAAIN,MAAoB,IAAK;IACvCI,OAAO,CAACG,OAAO,CAACP,MAAM,CAACQ,EAAE,CAAC,CAACC,KAAK,CAAC,MAAMC,SAAS,CAAC;IACjDd,QAAQ,GAAGI,MAAM,CAAC;EACpB,CAAC;EAED,oBACEN,IAAA,CAACJ,iBAAiB;IAAA,GACZa,KAAK;IACTE,OAAO,EAAEA,OAAQ;IACjBT,QAAQ,EAAEU,MAAO;IACjBT,KAAK,EAAEA,KAAM;IACbC,YAAY,EAAEA,YAAa;IAC3BC,cAAc,EAAEA,cAAe;IAC/BY,cAAc,EAAGX,MAAM,IAAKA,MAAM,CAACE;EAAI,CACxC,CAAC;AAEN,CAAC;AAED,SAASP,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { AndroidBluetoothForegroundService } from "../../../bt-management/components/android-bluetooth-foreground-service.js";
|
|
5
|
+
import { fromBleError } from "../ble-plx/ble-errors.js";
|
|
6
|
+
|
|
7
|
+
/** Props of {@link BluetoothProvider}. */
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const RuntimeContext = /*#__PURE__*/React.createContext(null);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gives the Bluetooth hooks below it a runtime.
|
|
13
|
+
*
|
|
14
|
+
* @group Components
|
|
15
|
+
*/
|
|
16
|
+
const BluetoothProvider = ({
|
|
17
|
+
runtime,
|
|
18
|
+
androidForegroundService,
|
|
19
|
+
onForegroundServiceError,
|
|
20
|
+
children
|
|
21
|
+
}) => /*#__PURE__*/_jsx(RuntimeContext.Provider, {
|
|
22
|
+
value: runtime,
|
|
23
|
+
children: /*#__PURE__*/_jsx(AndroidBluetoothForegroundService, {
|
|
24
|
+
enabled: androidForegroundService !== undefined,
|
|
25
|
+
options: androidForegroundService,
|
|
26
|
+
onError: ({
|
|
27
|
+
error
|
|
28
|
+
}) => onForegroundServiceError?.(fromBleError(error)),
|
|
29
|
+
children: children
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The runtime of the enclosing `BluetoothProvider`: every Bluetooth action is a call on it.
|
|
35
|
+
*
|
|
36
|
+
* @throws When rendered outside `BluetoothProvider`.
|
|
37
|
+
*
|
|
38
|
+
* @group Hooks
|
|
39
|
+
*/
|
|
40
|
+
const useBluetooth = () => {
|
|
41
|
+
const runtime = React.useContext(RuntimeContext);
|
|
42
|
+
if (!runtime) {
|
|
43
|
+
throw new Error("Bluetooth hooks must be rendered inside BluetoothProvider");
|
|
44
|
+
}
|
|
45
|
+
return runtime;
|
|
46
|
+
};
|
|
47
|
+
export { BluetoothProvider, useBluetooth };
|
|
48
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","AndroidBluetoothForegroundService","fromBleError","jsx","_jsx","RuntimeContext","createContext","BluetoothProvider","runtime","androidForegroundService","onForegroundServiceError","children","Provider","value","enabled","undefined","options","onError","error","useBluetooth","useContext","Error"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/react/context.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B,SAASC,iCAAiC,QAAQ,2EAAwE;AAC1H,SAASC,YAAY,QAAQ,0BAAuB;;AAKpD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAaA,MAAMC,cAAc,gBAAGL,KAAK,CAACM,aAAa,CAA0B,IAAI,CAAC;;AAEzE;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGA,CAAC;EACzBC,OAAO;EACPC,wBAAwB;EACxBC,wBAAwB;EACxBC;AACsB,CAAC,kBACvBP,IAAA,CAACC,cAAc,CAACO,QAAQ;EAACC,KAAK,EAAEL,OAAQ;EAAAG,QAAA,eACtCP,IAAA,CAACH,iCAAiC;IAChCa,OAAO,EAAEL,wBAAwB,KAAKM,SAAU;IAChDC,OAAO,EAAEP,wBAAyB;IAClCQ,OAAO,EAAEA,CAAC;MAAEC;IAAM,CAAC,KAAKR,wBAAwB,GAAGR,YAAY,CAACgB,KAAK,CAAC,CAAE;IAAAP,QAAA,EAEvEA;EAAQ,CACwB;AAAC,CACb,CAC1B;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMQ,YAAY,GAAGA,CAAA,KAAwB;EAC3C,MAAMX,OAAO,GAAGR,KAAK,CAACoB,UAAU,CAACf,cAAc,CAAC;EAEhD,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIa,KAAK,CAAC,2DAA2D,CAAC;EAC9E;EAEA,OAAOb,OAAO;AAChB,CAAC;AAED,SAASD,iBAAiB,EAAEY,YAAY","ignoreList":[]}
|