@ovok/native 1.6.50 → 1.6.51
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/README.md +21 -0
- package/lib/commonjs/index.js +18 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/auth/default-translation.js +6 -1
- package/lib/commonjs/modules/auth/default-translation.js.map +1 -1
- package/lib/commonjs/modules/auth/delete-account-button/components/delete-account-button.js +9 -14
- package/lib/commonjs/modules/auth/delete-account-button/components/delete-account-button.js.map +1 -1
- package/lib/commonjs/modules/auth/hooks/use-auth-action.js +41 -0
- package/lib/commonjs/modules/auth/hooks/use-auth-action.js.map +1 -0
- package/lib/commonjs/modules/auth/hooks/use-delete-account.js +27 -0
- package/lib/commonjs/modules/auth/hooks/use-delete-account.js.map +1 -0
- package/lib/commonjs/modules/auth/hooks/use-session.js +14 -86
- package/lib/commonjs/modules/auth/hooks/use-session.js.map +1 -1
- package/lib/commonjs/modules/auth/hooks/use-sign-in.js +66 -0
- package/lib/commonjs/modules/auth/hooks/use-sign-in.js.map +1 -0
- package/lib/commonjs/modules/auth/hooks/use-sign-out.js +15 -0
- package/lib/commonjs/modules/auth/hooks/use-sign-out.js.map +1 -0
- package/lib/commonjs/modules/auth/hooks/use-social-sign-in.js +92 -0
- package/lib/commonjs/modules/auth/hooks/use-social-sign-in.js.map +1 -0
- package/lib/commonjs/modules/auth/index.js +55 -0
- package/lib/commonjs/modules/auth/index.js.map +1 -1
- package/lib/commonjs/modules/auth/logout-button/components/logout-button.js +11 -16
- package/lib/commonjs/modules/auth/logout-button/components/logout-button.js.map +1 -1
- package/lib/commonjs/modules/auth/profile/components/profile-form-provider.js +5 -3
- package/lib/commonjs/modules/auth/profile/components/profile-form-provider.js.map +1 -1
- package/lib/commonjs/modules/auth/profile/contexts/profile-form-context.js +1 -1
- package/lib/commonjs/modules/auth/profile/contexts/profile-form-context.js.map +1 -1
- package/lib/commonjs/modules/auth/profile/hooks/use-profile-form.js +1 -1
- package/lib/commonjs/modules/auth/profile/hooks/use-profile-form.js.map +1 -1
- package/lib/commonjs/modules/auth/register/components/form/register-form-provider.js +6 -4
- package/lib/commonjs/modules/auth/register/components/form/register-form-provider.js.map +1 -1
- package/lib/commonjs/modules/auth/reset-password/components/form/inputs.js +2 -4
- package/lib/commonjs/modules/auth/reset-password/components/form/inputs.js.map +1 -1
- package/lib/commonjs/modules/auth/reset-password/components/form/reset-password-form-provider.js +6 -4
- package/lib/commonjs/modules/auth/reset-password/components/form/reset-password-form-provider.js.map +1 -1
- package/lib/commonjs/modules/auth/reset-password/contexts/reset-password-form-context.js +1 -1
- package/lib/commonjs/modules/auth/reset-password/contexts/reset-password-form-context.js.map +1 -1
- package/lib/commonjs/modules/auth/reset-password/hooks/use-reset-password-form.js +1 -1
- package/lib/commonjs/modules/auth/reset-password/hooks/use-reset-password-form.js.map +1 -1
- package/lib/commonjs/modules/auth/session/logout-session.js +29 -0
- package/lib/commonjs/modules/auth/session/logout-session.js.map +1 -0
- package/lib/commonjs/modules/auth/session/session-store.js +152 -0
- package/lib/commonjs/modules/auth/session/session-store.js.map +1 -0
- package/lib/commonjs/modules/auth/sign-in/components/form/login-form-provider.js +25 -41
- package/lib/commonjs/modules/auth/sign-in/components/form/login-form-provider.js.map +1 -1
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/apple-login-button.js +13 -12
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/apple-login-button.js.map +1 -1
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/google-login-button.js +4 -4
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/google-login-button.js.map +1 -1
- package/lib/commonjs/modules/auth/sign-in/contexts/login-form-context.js +1 -1
- package/lib/commonjs/modules/auth/sign-in/contexts/login-form-context.js.map +1 -1
- package/lib/commonjs/modules/auth/sign-in/hooks/use-login-form.js +1 -1
- package/lib/commonjs/modules/auth/sign-in/hooks/use-login-form.js.map +1 -1
- package/lib/commonjs/modules/bt-device/components/device-list-provider.js +5 -4
- package/lib/commonjs/modules/bt-device/components/device-list-provider.js.map +1 -1
- package/lib/commonjs/modules/bt-device/components/hooks/use-device-list.js +1 -1
- package/lib/commonjs/modules/bt-device/components/hooks/use-device-list.js.map +1 -1
- package/lib/commonjs/modules/bt-device/contexts/device-list-context.js +1 -4
- package/lib/commonjs/modules/bt-device/contexts/device-list-context.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/bt-provider-child-wrapper.js +176 -84
- package/lib/commonjs/modules/bt-management/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/commonjs/modules/bt-management/components/bt-provider.js +3 -2
- package/lib/commonjs/modules/bt-management/components/bt-provider.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/runtime-context.js +146 -14
- package/lib/commonjs/modules/bt-management/hooks/runtime-context.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-background-sync.js +17 -11
- package/lib/commonjs/modules/bt-management/hooks/use-background-sync.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js +100 -0
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -0
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-state.js +13 -26
- package/lib/commonjs/modules/bt-management/hooks/use-bluetooth-state.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-bt-device.js +148 -0
- package/lib/commonjs/modules/bt-management/hooks/use-bt-device.js.map +1 -0
- package/lib/commonjs/modules/bt-management/hooks/use-device-connection.js +10 -26
- package/lib/commonjs/modules/bt-management/hooks/use-device-connection.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-health-import.js +7 -76
- package/lib/commonjs/modules/bt-management/hooks/use-health-import.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js +43 -57
- package/lib/commonjs/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-nearby-devices.js +12 -16
- package/lib/commonjs/modules/bt-management/hooks/use-nearby-devices.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-paired-devices.js +31 -12
- package/lib/commonjs/modules/bt-management/hooks/use-paired-devices.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-request-permissions.js +12 -55
- package/lib/commonjs/modules/bt-management/hooks/use-request-permissions.js.map +1 -1
- package/lib/commonjs/modules/bt-management/hooks/use-scan-control.js +6 -4
- package/lib/commonjs/modules/bt-management/hooks/use-scan-control.js.map +1 -1
- package/lib/commonjs/modules/bt-management/index.js +133 -11
- package/lib/commonjs/modules/bt-management/index.js.map +1 -1
- package/lib/commonjs/modules/cms/hooks/use-cms-content.js +50 -0
- package/lib/commonjs/modules/cms/hooks/use-cms-content.js.map +1 -0
- package/lib/commonjs/modules/cms/hooks/use-cms-locale.js +20 -0
- package/lib/commonjs/modules/cms/hooks/use-cms-locale.js.map +1 -0
- package/lib/commonjs/modules/cms/hooks/use-cms-translations.js +50 -0
- package/lib/commonjs/modules/cms/hooks/use-cms-translations.js.map +1 -0
- package/lib/commonjs/modules/cms/index.js +39 -0
- package/lib/commonjs/modules/cms/index.js.map +1 -0
- package/lib/commonjs/modules/cms/merge-cms-translations.js +49 -0
- package/lib/commonjs/modules/cms/merge-cms-translations.js.map +1 -0
- package/lib/commonjs/modules/data-sync/components/android/android-health-connect-authorization-provider.js +23 -18
- package/lib/commonjs/modules/data-sync/components/android/android-health-connect-authorization-provider.js.map +1 -1
- package/lib/commonjs/modules/data-sync/components/apple/apple-health-authorization-provider.js +19 -18
- package/lib/commonjs/modules/data-sync/components/apple/apple-health-authorization-provider.js.map +1 -1
- package/lib/commonjs/modules/data-sync/components/apple/apple-health-authorization-utils.js +20 -0
- package/lib/commonjs/modules/data-sync/components/apple/apple-health-authorization-utils.js.map +1 -0
- package/lib/commonjs/modules/data-sync/contexts/health-authorization-context.js +18 -0
- package/lib/commonjs/modules/data-sync/contexts/health-authorization-context.js.map +1 -0
- package/lib/commonjs/modules/data-sync/hooks/use-health-import.js +81 -0
- package/lib/commonjs/modules/data-sync/hooks/use-health-import.js.map +1 -0
- package/lib/commonjs/modules/data-sync/index.js +37 -0
- package/lib/commonjs/modules/data-sync/index.js.map +1 -1
- package/lib/commonjs/modules/helpers/hooks/use-shallow-stable-value.js +20 -0
- package/lib/commonjs/modules/helpers/hooks/use-shallow-stable-value.js.map +1 -0
- package/lib/commonjs/modules/language-switcher/components/language-switcher.js +12 -4
- package/lib/commonjs/modules/language-switcher/components/language-switcher.js.map +1 -1
- package/lib/commonjs/modules/language-switcher/components/option/context/language-option-context.js +1 -1
- package/lib/commonjs/modules/language-switcher/components/option/context/language-option-context.js.map +1 -1
- package/lib/commonjs/modules/language-switcher/components/option/language-switcher-option.js +5 -4
- package/lib/commonjs/modules/language-switcher/components/option/language-switcher-option.js.map +1 -1
- package/lib/commonjs/modules/socket/components/socket-provider.js +78 -73
- package/lib/commonjs/modules/socket/components/socket-provider.js.map +1 -1
- package/lib/commonjs/modules/tab/components/tab-provider.js +12 -1
- package/lib/commonjs/modules/tab/components/tab-provider.js.map +1 -1
- package/lib/commonjs/modules/tab/contexts/tab-context.js +1 -1
- package/lib/commonjs/modules/tab/contexts/tab-context.js.map +1 -1
- package/lib/commonjs/modules/tab/hooks/use-tab.js +1 -1
- package/lib/commonjs/modules/tab/hooks/use-tab.js.map +1 -1
- package/lib/commonjs/modules/ui/components/health-import-card.js +2 -3
- package/lib/commonjs/modules/ui/components/health-import-card.js.map +1 -1
- package/lib/commonjs/modules/ui/components/pairing-flow.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/auth/default-translation.js +3 -1
- package/lib/module/modules/auth/default-translation.js.map +1 -1
- package/lib/module/modules/auth/delete-account-button/components/delete-account-button.js +9 -14
- package/lib/module/modules/auth/delete-account-button/components/delete-account-button.js.map +1 -1
- package/lib/module/modules/auth/hooks/use-auth-action.js +36 -0
- package/lib/module/modules/auth/hooks/use-auth-action.js.map +1 -0
- package/lib/module/modules/auth/hooks/use-delete-account.js +22 -0
- package/lib/module/modules/auth/hooks/use-delete-account.js.map +1 -0
- package/lib/module/modules/auth/hooks/use-session.js +17 -88
- package/lib/module/modules/auth/hooks/use-session.js.map +1 -1
- package/lib/module/modules/auth/hooks/use-sign-in.js +61 -0
- package/lib/module/modules/auth/hooks/use-sign-in.js.map +1 -0
- package/lib/module/modules/auth/hooks/use-sign-out.js +10 -0
- package/lib/module/modules/auth/hooks/use-sign-out.js.map +1 -0
- package/lib/module/modules/auth/hooks/use-social-sign-in.js +86 -0
- package/lib/module/modules/auth/hooks/use-social-sign-in.js.map +1 -0
- package/lib/module/modules/auth/index.js +5 -0
- package/lib/module/modules/auth/index.js.map +1 -1
- package/lib/module/modules/auth/logout-button/components/logout-button.js +11 -16
- package/lib/module/modules/auth/logout-button/components/logout-button.js.map +1 -1
- package/lib/module/modules/auth/profile/components/profile-form-provider.js +5 -3
- package/lib/module/modules/auth/profile/components/profile-form-provider.js.map +1 -1
- package/lib/module/modules/auth/profile/contexts/profile-form-context.js +1 -1
- package/lib/module/modules/auth/profile/contexts/profile-form-context.js.map +1 -1
- package/lib/module/modules/auth/profile/hooks/use-profile-form.js +1 -1
- package/lib/module/modules/auth/profile/hooks/use-profile-form.js.map +1 -1
- package/lib/module/modules/auth/register/components/form/register-form-provider.js +6 -4
- package/lib/module/modules/auth/register/components/form/register-form-provider.js.map +1 -1
- package/lib/module/modules/auth/reset-password/components/form/inputs.js +2 -4
- package/lib/module/modules/auth/reset-password/components/form/inputs.js.map +1 -1
- package/lib/module/modules/auth/reset-password/components/form/reset-password-form-provider.js +6 -4
- package/lib/module/modules/auth/reset-password/components/form/reset-password-form-provider.js.map +1 -1
- package/lib/module/modules/auth/reset-password/contexts/reset-password-form-context.js +1 -1
- package/lib/module/modules/auth/reset-password/contexts/reset-password-form-context.js.map +1 -1
- package/lib/module/modules/auth/reset-password/hooks/use-reset-password-form.js +1 -1
- package/lib/module/modules/auth/reset-password/hooks/use-reset-password-form.js.map +1 -1
- package/lib/module/modules/auth/session/logout-session.js +24 -0
- package/lib/module/modules/auth/session/logout-session.js.map +1 -0
- package/lib/module/modules/auth/session/session-store.js +148 -0
- package/lib/module/modules/auth/session/session-store.js.map +1 -0
- package/lib/module/modules/auth/sign-in/components/form/login-form-provider.js +25 -41
- package/lib/module/modules/auth/sign-in/components/form/login-form-provider.js.map +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login-button.js +13 -12
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login-button.js.map +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login-button.js +4 -4
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login-button.js.map +1 -1
- package/lib/module/modules/auth/sign-in/contexts/login-form-context.js +1 -1
- package/lib/module/modules/auth/sign-in/contexts/login-form-context.js.map +1 -1
- package/lib/module/modules/auth/sign-in/hooks/use-login-form.js +1 -1
- package/lib/module/modules/auth/sign-in/hooks/use-login-form.js.map +1 -1
- package/lib/module/modules/bt-device/components/device-list-provider.js +5 -4
- package/lib/module/modules/bt-device/components/device-list-provider.js.map +1 -1
- package/lib/module/modules/bt-device/components/hooks/use-device-list.js +1 -1
- package/lib/module/modules/bt-device/components/hooks/use-device-list.js.map +1 -1
- package/lib/module/modules/bt-device/contexts/device-list-context.js +1 -4
- package/lib/module/modules/bt-device/contexts/device-list-context.js.map +1 -1
- package/lib/module/modules/bt-management/components/bt-provider-child-wrapper.js +175 -84
- package/lib/module/modules/bt-management/components/bt-provider-child-wrapper.js.map +1 -1
- package/lib/module/modules/bt-management/components/bt-provider.js +3 -2
- package/lib/module/modules/bt-management/components/bt-provider.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/runtime-context.js +144 -13
- package/lib/module/modules/bt-management/hooks/runtime-context.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-background-sync.js +17 -11
- package/lib/module/modules/bt-management/hooks/use-background-sync.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js +94 -0
- package/lib/module/modules/bt-management/hooks/use-bluetooth-permission.js.map +1 -0
- package/lib/module/modules/bt-management/hooks/use-bluetooth-state.js +13 -26
- package/lib/module/modules/bt-management/hooks/use-bluetooth-state.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-bt-device.js +142 -0
- package/lib/module/modules/bt-management/hooks/use-bt-device.js.map +1 -0
- package/lib/module/modules/bt-management/hooks/use-device-connection.js +11 -26
- package/lib/module/modules/bt-management/hooks/use-device-connection.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-health-import.js +2 -73
- package/lib/module/modules/bt-management/hooks/use-health-import.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-measurements.js +44 -58
- package/lib/module/modules/bt-management/hooks/use-measurements.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-nearby-devices.js +13 -17
- package/lib/module/modules/bt-management/hooks/use-nearby-devices.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-paired-devices.js +31 -12
- package/lib/module/modules/bt-management/hooks/use-paired-devices.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-request-permissions.js +12 -54
- package/lib/module/modules/bt-management/hooks/use-request-permissions.js.map +1 -1
- package/lib/module/modules/bt-management/hooks/use-scan-control.js +6 -4
- package/lib/module/modules/bt-management/hooks/use-scan-control.js.map +1 -1
- package/lib/module/modules/bt-management/index.js +8 -1
- package/lib/module/modules/bt-management/index.js.map +1 -1
- package/lib/module/modules/cms/hooks/use-cms-content.js +44 -0
- package/lib/module/modules/cms/hooks/use-cms-content.js.map +1 -0
- package/lib/module/modules/cms/hooks/use-cms-locale.js +16 -0
- package/lib/module/modules/cms/hooks/use-cms-locale.js.map +1 -0
- package/lib/module/modules/cms/hooks/use-cms-translations.js +45 -0
- package/lib/module/modules/cms/hooks/use-cms-translations.js.map +1 -0
- package/lib/module/modules/cms/index.js +6 -0
- package/lib/module/modules/cms/index.js.map +1 -0
- package/lib/module/modules/cms/merge-cms-translations.js +46 -0
- package/lib/module/modules/cms/merge-cms-translations.js.map +1 -0
- package/lib/module/modules/data-sync/components/android/android-health-connect-authorization-provider.js +23 -18
- package/lib/module/modules/data-sync/components/android/android-health-connect-authorization-provider.js.map +1 -1
- package/lib/module/modules/data-sync/components/apple/apple-health-authorization-provider.js +18 -17
- package/lib/module/modules/data-sync/components/apple/apple-health-authorization-provider.js.map +1 -1
- package/lib/module/modules/data-sync/components/apple/apple-health-authorization-utils.js +16 -0
- package/lib/module/modules/data-sync/components/apple/apple-health-authorization-utils.js.map +1 -0
- package/lib/module/modules/data-sync/contexts/health-authorization-context.js +13 -0
- package/lib/module/modules/data-sync/contexts/health-authorization-context.js.map +1 -0
- package/lib/module/modules/data-sync/hooks/use-health-import.js +76 -0
- package/lib/module/modules/data-sync/hooks/use-health-import.js.map +1 -0
- package/lib/module/modules/data-sync/index.js +2 -0
- package/lib/module/modules/data-sync/index.js.map +1 -1
- package/lib/module/modules/helpers/hooks/use-shallow-stable-value.js +14 -0
- package/lib/module/modules/helpers/hooks/use-shallow-stable-value.js.map +1 -0
- package/lib/module/modules/language-switcher/components/language-switcher.js +11 -4
- package/lib/module/modules/language-switcher/components/language-switcher.js.map +1 -1
- package/lib/module/modules/language-switcher/components/option/context/language-option-context.js +1 -1
- package/lib/module/modules/language-switcher/components/option/context/language-option-context.js.map +1 -1
- package/lib/module/modules/language-switcher/components/option/language-switcher-option.js +5 -4
- package/lib/module/modules/language-switcher/components/option/language-switcher-option.js.map +1 -1
- package/lib/module/modules/socket/components/socket-provider.js +78 -73
- package/lib/module/modules/socket/components/socket-provider.js.map +1 -1
- package/lib/module/modules/tab/components/tab-provider.js +11 -1
- package/lib/module/modules/tab/components/tab-provider.js.map +1 -1
- package/lib/module/modules/tab/contexts/tab-context.js +1 -1
- package/lib/module/modules/tab/contexts/tab-context.js.map +1 -1
- package/lib/module/modules/tab/hooks/use-tab.js +1 -1
- package/lib/module/modules/tab/hooks/use-tab.js.map +1 -1
- package/lib/module/modules/ui/components/health-import-card.js +1 -2
- package/lib/module/modules/ui/components/health-import-card.js.map +1 -1
- package/lib/module/modules/ui/components/pairing-flow.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/default-translation.d.ts +53 -1
- package/lib/typescript/commonjs/src/modules/auth/default-translation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/delete-account-button/components/delete-account-button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-auth-action.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-auth-action.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-delete-account.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-delete-account.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-session.d.ts +6 -4
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-session.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-in.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-in.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-out.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-sign-out.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-social-sign-in.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-social-sign-in.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/auth/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/logout-button/components/logout-button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/profile/components/profile-form-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/profile/contexts/profile-form-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/auth/profile/contexts/profile-form-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/profile/hooks/use-profile-form.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/register/components/form/register-form-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/reset-password/components/form/inputs.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/reset-password/components/form/reset-password-form-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/reset-password/contexts/reset-password-form-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/auth/reset-password/contexts/reset-password-form-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/session/logout-session.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/auth/session/logout-session.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/session/session-store.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/auth/session/session-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/form/login-form-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/apple-login-button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/google-login-button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/contexts/login-form-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/contexts/login-form-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/components/device-list-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/components/hooks/use-device-list.d.ts +1 -5
- package/lib/typescript/commonjs/src/modules/bt-device/components/hooks/use-device-list.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-device/contexts/device-list-context.d.ts +3 -2
- package/lib/typescript/commonjs/src/modules/bt-device/contexts/device-list-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/components/bt-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/runtime-context.d.ts +40 -9
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/runtime-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-background-sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bluetooth-state.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bt-device.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-bt-device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-device-connection.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-device-connection.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-health-import.d.ts +2 -15
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-health-import.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/hooks/use-nearby-devices.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-paired-devices.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-request-permissions.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-request-permissions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-scan-control.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +6 -1
- package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-props.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/bt-management/types/btprovider-props.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-content.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-locale.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-locale.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-translations.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/cms/hooks/use-cms-translations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/cms/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/cms/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/cms/merge-cms-translations.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/cms/merge-cms-translations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/components/android/android-health-connect-authorization-provider.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/data-sync/components/android/android-health-connect-authorization-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/data-sync/components/apple/apple-health-authorization-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/data-sync/components/apple/apple-health-authorization-utils.d.ts +4 -0
- package/lib/typescript/commonjs/src/modules/data-sync/components/apple/apple-health-authorization-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/components/data-sync.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/data-sync/contexts/health-authorization-context.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/data-sync/contexts/health-authorization-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/hooks/use-health-import.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/data-sync/hooks/use-health-import.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/data-sync/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/data-sync/types/health-authorization-status.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/types/health-authorization-status.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/helpers/hooks/use-shallow-stable-value.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/helpers/hooks/use-shallow-stable-value.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/language-switcher/components/language-switcher.d.ts +6 -5
- package/lib/typescript/commonjs/src/modules/language-switcher/components/language-switcher.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/language-switcher/components/option/context/language-option-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/language-switcher/components/option/context/language-option-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/socket/components/socket-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/tab/components/tab-provider.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/tab/components/tab-provider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/tab/contexts/tab-context.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/tab/contexts/tab-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/ui/components/health-import-card.d.ts +1 -2
- package/lib/typescript/commonjs/src/modules/ui/components/health-import-card.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/ui/components/pairing-flow.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/default-translation.d.ts +53 -1
- package/lib/typescript/module/src/modules/auth/default-translation.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/delete-account-button/components/delete-account-button.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/hooks/use-auth-action.d.ts +13 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-auth-action.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-delete-account.d.ts +8 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-delete-account.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-session.d.ts +6 -4
- package/lib/typescript/module/src/modules/auth/hooks/use-session.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-in.d.ts +24 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-in.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-out.d.ts +4 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-sign-out.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-social-sign-in.d.ts +14 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-social-sign-in.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/index.d.ts +5 -0
- package/lib/typescript/module/src/modules/auth/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/logout-button/components/logout-button.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/profile/components/profile-form-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/profile/contexts/profile-form-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/auth/profile/contexts/profile-form-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/profile/hooks/use-profile-form.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/register/components/form/register-form-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/reset-password/components/form/inputs.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/reset-password/components/form/reset-password-form-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/reset-password/contexts/reset-password-form-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/auth/reset-password/contexts/reset-password-form-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/session/logout-session.d.ts +6 -0
- package/lib/typescript/module/src/modules/auth/session/logout-session.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/session/session-store.d.ts +21 -0
- package/lib/typescript/module/src/modules/auth/session/session-store.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/sign-in/components/form/login-form-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/apple-login-button.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/google-login-button.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/contexts/login-form-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/contexts/login-form-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/components/device-list-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/components/hooks/use-device-list.d.ts +1 -5
- package/lib/typescript/module/src/modules/bt-device/components/hooks/use-device-list.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-device/contexts/device-list-context.d.ts +3 -2
- package/lib/typescript/module/src/modules/bt-device/contexts/device-list-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider-child-wrapper.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider.d.ts +1 -1
- package/lib/typescript/module/src/modules/bt-management/components/bt-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/runtime-context.d.ts +40 -9
- package/lib/typescript/module/src/modules/bt-management/hooks/runtime-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-background-sync.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts +17 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-permission.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bluetooth-state.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bt-device.d.ts +31 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-bt-device.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-device-connection.d.ts +2 -2
- package/lib/typescript/module/src/modules/bt-management/hooks/use-device-connection.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-health-import.d.ts +2 -15
- package/lib/typescript/module/src/modules/bt-management/hooks/use-health-import.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/hooks/use-nearby-devices.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-paired-devices.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-request-permissions.d.ts +1 -0
- package/lib/typescript/module/src/modules/bt-management/hooks/use-request-permissions.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/hooks/use-scan-control.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/index.d.ts +6 -1
- package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-props.d.ts +2 -0
- package/lib/typescript/module/src/modules/bt-management/types/btprovider-props.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-content.d.ts +9 -0
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-content.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-locale.d.ts +7 -0
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-locale.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-translations.d.ts +10 -0
- package/lib/typescript/module/src/modules/cms/hooks/use-cms-translations.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/cms/index.d.ts +4 -0
- package/lib/typescript/module/src/modules/cms/index.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/cms/merge-cms-translations.d.ts +13 -0
- package/lib/typescript/module/src/modules/cms/merge-cms-translations.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/components/android/android-health-connect-authorization-provider.d.ts +1 -1
- package/lib/typescript/module/src/modules/data-sync/components/android/android-health-connect-authorization-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/data-sync/components/apple/apple-health-authorization-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/data-sync/components/apple/apple-health-authorization-utils.d.ts +4 -0
- package/lib/typescript/module/src/modules/data-sync/components/apple/apple-health-authorization-utils.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/components/data-sync.d.ts +1 -1
- package/lib/typescript/module/src/modules/data-sync/contexts/health-authorization-context.d.ts +17 -0
- package/lib/typescript/module/src/modules/data-sync/contexts/health-authorization-context.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/hooks/use-health-import.d.ts +17 -0
- package/lib/typescript/module/src/modules/data-sync/hooks/use-health-import.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/data-sync/index.d.ts +3 -0
- package/lib/typescript/module/src/modules/data-sync/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/data-sync/types/health-authorization-status.d.ts +1 -0
- package/lib/typescript/module/src/modules/data-sync/types/health-authorization-status.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/helpers/hooks/use-shallow-stable-value.d.ts +2 -0
- package/lib/typescript/module/src/modules/helpers/hooks/use-shallow-stable-value.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/language-switcher/components/language-switcher.d.ts +6 -5
- package/lib/typescript/module/src/modules/language-switcher/components/language-switcher.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/language-switcher/components/option/context/language-option-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/language-switcher/components/option/context/language-option-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/socket/components/socket-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/tab/components/tab-provider.d.ts +2 -1
- package/lib/typescript/module/src/modules/tab/components/tab-provider.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/tab/contexts/tab-context.d.ts +1 -1
- package/lib/typescript/module/src/modules/tab/contexts/tab-context.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/ui/components/health-import-card.d.ts +1 -2
- package/lib/typescript/module/src/modules/ui/components/health-import-card.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/ui/components/pairing-flow.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -3,19 +3,42 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useRuntimeEvent = exports.useBluetoothRuntime = exports.createBluetoothRuntime = exports.BluetoothRuntimeProvider = void 0;
|
|
6
|
+
exports.useRuntimeEvent = exports.useBluetoothSelector = exports.useBluetoothRuntime = exports.createBluetoothRuntime = exports.BluetoothRuntimeProvider = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
10
|
/* eslint-disable import/group-exports, max-lines */
|
|
11
11
|
|
|
12
|
+
/** Typed union exposed when a host listens to every accepted device. */
|
|
13
|
+
|
|
12
14
|
const RuntimeContext = /*#__PURE__*/React.createContext(null);
|
|
13
|
-
const createBluetoothRuntime = bleManager => {
|
|
15
|
+
const createBluetoothRuntime = (bleManager, initialBackgroundScanEnabled) => {
|
|
14
16
|
const listeners = new Map();
|
|
15
17
|
let currentManager;
|
|
16
18
|
let currentDevices = [];
|
|
19
|
+
let backgroundScanEnabled = initialBackgroundScanEnabled ?? false;
|
|
20
|
+
let backgroundScanInitialized = initialBackgroundScanEnabled !== undefined;
|
|
21
|
+
let bluetoothState = "unknown";
|
|
17
22
|
const subscribers = new Set();
|
|
23
|
+
let currentSnapshot = {
|
|
24
|
+
devices: currentDevices,
|
|
25
|
+
backgroundScanEnabled,
|
|
26
|
+
managerReady: false,
|
|
27
|
+
bluetoothState
|
|
28
|
+
};
|
|
29
|
+
const publishState = (devices = currentDevices) => {
|
|
30
|
+
currentDevices = devices;
|
|
31
|
+
currentSnapshot = {
|
|
32
|
+
devices: currentDevices,
|
|
33
|
+
backgroundScanEnabled,
|
|
34
|
+
managerReady: currentManager !== undefined,
|
|
35
|
+
bluetoothState
|
|
36
|
+
};
|
|
37
|
+
subscribers.forEach(notify => notify());
|
|
38
|
+
};
|
|
18
39
|
const pairedState = new Map();
|
|
40
|
+
const connectionIds = new Map();
|
|
41
|
+
const resultConnectionIds = new WeakMap();
|
|
19
42
|
const getPairedState = storageKey => {
|
|
20
43
|
const current = pairedState.get(storageKey);
|
|
21
44
|
if (current) {
|
|
@@ -32,16 +55,40 @@ const createBluetoothRuntime = bleManager => {
|
|
|
32
55
|
storageKey
|
|
33
56
|
};
|
|
34
57
|
listeners.get("pairedDevices")?.forEach(callback => callback(value));
|
|
35
|
-
subscribers.forEach(notify => notify());
|
|
36
58
|
};
|
|
37
59
|
return {
|
|
38
60
|
bleManager,
|
|
39
61
|
get manager() {
|
|
40
62
|
return currentManager;
|
|
41
63
|
},
|
|
64
|
+
getSnapshot: () => currentSnapshot,
|
|
42
65
|
get devices() {
|
|
43
66
|
return currentDevices;
|
|
44
67
|
},
|
|
68
|
+
getBackgroundScanEnabled: () => backgroundScanEnabled,
|
|
69
|
+
initializeBackgroundScanEnabled: enabled => {
|
|
70
|
+
if (backgroundScanInitialized) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
backgroundScanInitialized = true;
|
|
74
|
+
backgroundScanEnabled = enabled;
|
|
75
|
+
publishState();
|
|
76
|
+
},
|
|
77
|
+
setBackgroundScanEnabled: enabled => {
|
|
78
|
+
if (backgroundScanEnabled === enabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
backgroundScanInitialized = true;
|
|
82
|
+
backgroundScanEnabled = enabled;
|
|
83
|
+
publishState();
|
|
84
|
+
},
|
|
85
|
+
setBluetoothState: state => {
|
|
86
|
+
if (bluetoothState === state) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
bluetoothState = state;
|
|
90
|
+
publishState();
|
|
91
|
+
},
|
|
45
92
|
subscribe: (event, callback) => {
|
|
46
93
|
const eventListeners = listeners.get(event) ?? new Set();
|
|
47
94
|
eventListeners.add(callback);
|
|
@@ -55,11 +102,13 @@ const createBluetoothRuntime = bleManager => {
|
|
|
55
102
|
hasListeners: event => (listeners.get(event)?.size ?? 0) > 0,
|
|
56
103
|
emit: (event, value) => {
|
|
57
104
|
listeners.get(event)?.forEach(callback => callback(value));
|
|
58
|
-
subscribers.forEach(notify => notify());
|
|
59
105
|
},
|
|
60
106
|
setManager: manager => {
|
|
107
|
+
if (currentManager === manager) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
61
110
|
currentManager = manager;
|
|
62
|
-
|
|
111
|
+
publishState();
|
|
63
112
|
},
|
|
64
113
|
setAutoConnect: (enabled, delayMs, onDeviceSelectionRequired) => {
|
|
65
114
|
currentManager?.setAutoConnect(enabled, delayMs, onDeviceSelectionRequired);
|
|
@@ -89,31 +138,92 @@ const createBluetoothRuntime = bleManager => {
|
|
|
89
138
|
},
|
|
90
139
|
setPairedDeviceIds: (storageKey, ids) => {
|
|
91
140
|
const state = getPairedState(storageKey);
|
|
141
|
+
const next = [...new Set(ids)];
|
|
142
|
+
if (state.value?.length === next.length && state.value.every((id, index) => id === next[index])) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
92
145
|
state.revision += 1;
|
|
93
|
-
state.value =
|
|
146
|
+
state.value = next;
|
|
94
147
|
notifyPairedDevices(storageKey);
|
|
95
148
|
},
|
|
96
149
|
upsertDevice: device => {
|
|
97
150
|
const existing = currentDevices.findIndex(item => item.id === device.id);
|
|
151
|
+
const previous = existing === -1 ? undefined : currentDevices[existing];
|
|
152
|
+
if (previous?.device === device && previous.deviceData === device.deviceData) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
98
155
|
const next = {
|
|
99
156
|
id: device.id,
|
|
100
157
|
deviceData: device.deviceData,
|
|
101
158
|
device,
|
|
102
|
-
status:
|
|
159
|
+
status: previous?.status,
|
|
160
|
+
latestResult: previous?.latestResult,
|
|
161
|
+
results: previous?.results ?? [],
|
|
162
|
+
events: previous?.events ?? []
|
|
103
163
|
};
|
|
104
|
-
|
|
105
|
-
|
|
164
|
+
publishState(existing === -1 ? [...currentDevices, next] : currentDevices.map((item, index) => index === existing ? next : item));
|
|
165
|
+
},
|
|
166
|
+
setDeviceResult: result => {
|
|
167
|
+
const existing = currentDevices.findIndex(item => item.id === result.deviceData.id);
|
|
168
|
+
if (existing === -1) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const device = currentDevices[existing];
|
|
172
|
+
if (!device || device.results?.some(item => item.id === result.id)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
resultConnectionIds.set(result, connectionIds.get(result.deviceData.id) ?? 0);
|
|
176
|
+
const next = {
|
|
177
|
+
...device,
|
|
178
|
+
latestResult: result,
|
|
179
|
+
results: [...(device.results ?? []), result].slice(-100)
|
|
180
|
+
};
|
|
181
|
+
publishState(currentDevices.map((item, index) => index === existing ? next : item));
|
|
182
|
+
},
|
|
183
|
+
getResultConnectionId: result => resultConnectionIds.get(result) ?? 0,
|
|
184
|
+
clearResults: () => {
|
|
185
|
+
if (!currentDevices.some(device => device.results?.length || device.latestResult)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
publishState(currentDevices.map(device => ({
|
|
189
|
+
...device,
|
|
190
|
+
latestResult: undefined,
|
|
191
|
+
results: []
|
|
192
|
+
})));
|
|
193
|
+
},
|
|
194
|
+
setDeviceConnectionEvent: event => {
|
|
195
|
+
if (event.kind === "connected" || event.kind === "bonded") {
|
|
196
|
+
const id = event.deviceData.id;
|
|
197
|
+
connectionIds.set(id, (connectionIds.get(id) ?? 0) + 1);
|
|
198
|
+
}
|
|
199
|
+
const existing = currentDevices.findIndex(item => item.id === event.deviceData.id);
|
|
200
|
+
if (existing === -1) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const device = currentDevices[existing];
|
|
204
|
+
if (!device) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const next = {
|
|
208
|
+
...device,
|
|
209
|
+
events: [...(device.events ?? []), event].slice(-100)
|
|
210
|
+
};
|
|
211
|
+
publishState(currentDevices.map((item, index) => index === existing ? next : item));
|
|
106
212
|
},
|
|
107
213
|
setDeviceStatus: ({
|
|
108
214
|
deviceData,
|
|
109
215
|
status
|
|
110
216
|
}) => {
|
|
111
|
-
|
|
217
|
+
const existing = currentDevices.findIndex(item => item.id === deviceData.id);
|
|
218
|
+
const device = currentDevices[existing];
|
|
219
|
+
if (!device || device.status === status && device.deviceData === deviceData) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
publishState(currentDevices.map((item, index) => index === existing ? {
|
|
112
223
|
...item,
|
|
113
224
|
deviceData,
|
|
114
225
|
status
|
|
115
|
-
} : item);
|
|
116
|
-
subscribers.forEach(notify => notify());
|
|
226
|
+
} : item));
|
|
117
227
|
}
|
|
118
228
|
};
|
|
119
229
|
};
|
|
@@ -140,7 +250,29 @@ const useRuntimeEvent = (event, callback) => {
|
|
|
140
250
|
callbackRef.current = callback;
|
|
141
251
|
React.useEffect(() => runtime.subscribe(event, value => callbackRef.current(value)), [event, runtime]);
|
|
142
252
|
};
|
|
143
|
-
|
|
144
|
-
/** Typed union exposed when a host listens to every accepted device. */
|
|
145
253
|
exports.useRuntimeEvent = useRuntimeEvent;
|
|
254
|
+
const useBluetoothSelector = (selector, isEqual = Object.is) => {
|
|
255
|
+
const runtime = useBluetoothRuntime();
|
|
256
|
+
const selectorRef = React.useRef(selector);
|
|
257
|
+
const equalityRef = React.useRef(isEqual);
|
|
258
|
+
const selectionRef = React.useRef({
|
|
259
|
+
hasValue: false
|
|
260
|
+
});
|
|
261
|
+
selectorRef.current = selector;
|
|
262
|
+
equalityRef.current = isEqual;
|
|
263
|
+
const getSelection = React.useCallback(() => {
|
|
264
|
+
const next = selectorRef.current(runtime.getSnapshot());
|
|
265
|
+
const previous = selectionRef.current;
|
|
266
|
+
if (previous.hasValue && equalityRef.current(previous.value, next)) {
|
|
267
|
+
return previous.value;
|
|
268
|
+
}
|
|
269
|
+
selectionRef.current = {
|
|
270
|
+
hasValue: true,
|
|
271
|
+
value: next
|
|
272
|
+
};
|
|
273
|
+
return next;
|
|
274
|
+
}, [runtime]);
|
|
275
|
+
return React.useSyncExternalStore(runtime.subscribeState, getSelection, getSelection);
|
|
276
|
+
};
|
|
277
|
+
exports.useBluetoothSelector = useBluetoothSelector;
|
|
146
278
|
//# sourceMappingURL=runtime-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RuntimeContext","createContext","createBluetoothRuntime","bleManager","listeners","Map","currentManager","currentDevices","subscribers","Set","pairedState","getPairedState","storageKey","current","next","revision","notifyPairedDevices","value","forEach","callback","notify","manager","devices","subscribe","event","eventListeners","add","delete","subscribeState","hasListeners","size","emit","setManager","setAutoConnect","enabled","delayMs","onDeviceSelectionRequired","getPairedDeviceIds","loadPairedDeviceIds","load","state","Promise","resolve","loading","then","finally","undefined","setPairedDeviceIds","ids","upsertDevice","device","existing","findIndex","item","id","deviceData","status","map","index","setDeviceStatus","exports","BluetoothRuntimeProvider","runtime","children","jsx","Provider","useBluetoothRuntime","useContext","Error","useRuntimeEvent","callbackRef","useRef","useEffect"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/hooks/runtime-context.tsx"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IA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J,OAAO,GAAGrF,KAAK,CAAC0F,UAAU,CAACnE,cAAc,CAAC;EAEhD,IAAI,CAAC8D,OAAO,EAAE;IACZ,MAAM,IAAIM,KAAK,CAAC,oDAAoD,CAAC;EACvE;EAEA,OAAON,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAM,mBAAA,GAAAA,mBAAA;AAEK,MAAMG,eAAe,GAAGA,CAC7B7C,KAAmB,EACnBL,QAA4B,KACnB;EACT,MAAM2C,OAAO,GAAGI,mBAAmB,CAAC,CAAC;EACrC,MAAMI,WAAW,GAAG7F,KAAK,CAAC8F,MAAM,CAACpD,QAAQ,CAAC;EAE1CmD,WAAW,CAACzD,OAAO,GAAGM,QAAQ;EAE9B1C,KAAK,CAAC+F,SAAS,CACb,MAAMV,OAAO,CAACvC,SAAS,CAAIC,KAAK,EAAGP,KAAK,IAAKqD,WAAW,CAACzD,OAAO,CAACI,KAAK,CAAC,CAAC,EACxE,CAACO,KAAK,EAAEsC,OAAO,CACjB,CAAC;AACH,CAAC;;AAED;AAAAF,OAAA,CAAAS,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RuntimeContext","createContext","createBluetoothRuntime","bleManager","initialBackgroundScanEnabled","listeners","Map","currentManager","currentDevices","backgroundScanEnabled","backgroundScanInitialized","undefined","bluetoothState","subscribers","Set","currentSnapshot","devices","managerReady","publishState","forEach","notify","pairedState","connectionIds","resultConnectionIds","getPairedState","storageKey","current","next","revision","notifyPairedDevices","value","callback","manager","getSnapshot","getBackgroundScanEnabled","initializeBackgroundScanEnabled","enabled","setBackgroundScanEnabled","setBluetoothState","state","subscribe","event","eventListeners","add","delete","subscribeState","hasListeners","size","emit","setManager","setAutoConnect","delayMs","onDeviceSelectionRequired","getPairedDeviceIds","loadPairedDeviceIds","load","Promise","resolve","loading","then","finally","setPairedDeviceIds","ids","length","every","id","index","upsertDevice","device","existing","findIndex","item","previous","deviceData","status","latestResult","results","events","map","setDeviceResult","result","some","slice","getResultConnectionId","clearResults","setDeviceConnectionEvent","kind","setDeviceStatus","exports","BluetoothRuntimeProvider","runtime","children","jsx","Provider","useBluetoothRuntime","useContext","Error","useRuntimeEvent","callbackRef","useRef","useEffect","useBluetoothSelector","selector","isEqual","is","selectorRef","equalityRef","selectionRef","hasValue","getSelection","useCallback","useSyncExternalStore"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/hooks/runtime-context.tsx"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CA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,CAAC2G,EAAE,KACxD;EACd,MAAMd,OAAO,GAAGI,mBAAmB,CAAC,CAAC;EACrC,MAAMW,WAAW,GAAGhI,KAAK,CAAC0H,MAAM,CAACG,QAAQ,CAAC;EAC1C,MAAMI,WAAW,GAAGjI,KAAK,CAAC0H,MAAM,CAACI,OAAO,CAAC;EAEzC,MAAMI,YAAY,GAAGlI,KAAK,CAAC0H,MAAM,CAG9B;IAAES,QAAQ,EAAE;EAAM,CAAC,CAAC;EAEvBH,WAAW,CAAC/E,OAAO,GAAG4E,QAAQ;EAC9BI,WAAW,CAAChF,OAAO,GAAG6E,OAAO;EAE7B,MAAMM,YAAY,GAAGpI,KAAK,CAACqI,WAAW,CAAC,MAAM;IAC3C,MAAMnF,IAAI,GAAG8E,WAAW,CAAC/E,OAAO,CAACgE,OAAO,CAACzD,WAAW,CAAC,CAAC,CAAC;IACvD,MAAMuC,QAAQ,GAAGmC,YAAY,CAACjF,OAAO;IAErC,IAAI8C,QAAQ,CAACoC,QAAQ,IAAIF,WAAW,CAAChF,OAAO,CAAC8C,QAAQ,CAAC1C,KAAK,EAAeH,IAAI,CAAC,EAAE;MAC/E,OAAO6C,QAAQ,CAAC1C,KAAK;IACvB;IAEA6E,YAAY,CAACjF,OAAO,GAAG;MAAEkF,QAAQ,EAAE,IAAI;MAAE9E,KAAK,EAAEH;IAAK,CAAC;IAEtD,OAAOA,IAAI;EACb,CAAC,EAAE,CAAC+D,OAAO,CAAC,CAAC;EAEb,OAAOjH,KAAK,CAACsI,oBAAoB,CAC/BrB,OAAO,CAAC7C,cAAc,EACtBgE,YAAY,EACZA,YACF,CAAC;AACH,CAAC;AAACrB,OAAA,CAAAa,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -15,30 +15,36 @@ const useBackgroundSync = ({
|
|
|
15
15
|
onEnabledChange
|
|
16
16
|
} = {}) => {
|
|
17
17
|
const runtime = (0, _runtimeContext.useBluetoothRuntime)();
|
|
18
|
-
const [enabled, setEnabledState] = React.useState(initialEnabled);
|
|
19
18
|
const [error, setError] = React.useState();
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
const canEnableRef = React.useRef(canEnable);
|
|
20
|
+
const onEnabledChangeRef = React.useRef(onEnabledChange);
|
|
21
|
+
canEnableRef.current = canEnable;
|
|
22
|
+
onEnabledChangeRef.current = onEnabledChange;
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
runtime.initializeBackgroundScanEnabled(initialEnabled);
|
|
25
|
+
}, [initialEnabled, runtime]);
|
|
26
|
+
const enabled = React.useSyncExternalStore(runtime.subscribeState, runtime.getBackgroundScanEnabled, () => initialEnabled);
|
|
27
|
+
const [statusOverride, setStatusOverride] = React.useState();
|
|
28
|
+
const status = statusOverride ?? (enabled ? "on" : "off");
|
|
22
29
|
const setEnabled = React.useCallback(async next => {
|
|
23
30
|
setError(undefined);
|
|
24
31
|
try {
|
|
25
|
-
if (next &&
|
|
26
|
-
|
|
32
|
+
if (next && canEnableRef.current && !(await canEnableRef.current())) {
|
|
33
|
+
setStatusOverride("restricted");
|
|
27
34
|
return;
|
|
28
35
|
}
|
|
29
36
|
if (next && !runtime.manager) {
|
|
30
37
|
throw new Error("Bluetooth background sync is not ready yet.");
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
setStatus(next ? "on" : "off");
|
|
39
|
+
await onEnabledChangeRef.current?.(next);
|
|
40
|
+
runtime.setBackgroundScanEnabled(next);
|
|
41
|
+
setStatusOverride(undefined);
|
|
36
42
|
} catch (cause) {
|
|
37
43
|
const nextError = cause instanceof Error ? cause : new Error(String(cause));
|
|
38
44
|
setError(nextError);
|
|
39
|
-
|
|
45
|
+
setStatusOverride("blocked");
|
|
40
46
|
}
|
|
41
|
-
}, [
|
|
47
|
+
}, [runtime]);
|
|
42
48
|
return {
|
|
43
49
|
enabled,
|
|
44
50
|
setEnabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","_runtimeContext","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useBackgroundSync","enabled","initialEnabled","canEnable","onEnabledChange","runtime","useBluetoothRuntime","
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_runtimeContext","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useBackgroundSync","enabled","initialEnabled","canEnable","onEnabledChange","runtime","useBluetoothRuntime","error","setError","useState","canEnableRef","useRef","onEnabledChangeRef","current","useEffect","initializeBackgroundScanEnabled","useSyncExternalStore","subscribeState","getBackgroundScanEnabled","statusOverride","setStatusOverride","status","setEnabled","useCallback","next","undefined","manager","Error","setBackgroundScanEnabled","cause","nextError","String","reason","exports"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/hooks/use-background-sync.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAAwD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gB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ports.useBluetoothPermission = exports.requestBluetoothPermission = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativePermissions = require("react-native-permissions");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
let sharedPermissionRequest;
|
|
12
|
+
const requestBluetoothPermissionResult = () => {
|
|
13
|
+
if (sharedPermissionRequest) {
|
|
14
|
+
return sharedPermissionRequest;
|
|
15
|
+
}
|
|
16
|
+
const requestedPermissions = _reactNative.Platform.OS === "android" ? Number(_reactNative.Platform.Version) >= 31 ? [_reactNativePermissions.PERMISSIONS.ANDROID.BLUETOOTH_CONNECT, _reactNativePermissions.PERMISSIONS.ANDROID.BLUETOOTH_SCAN] : [_reactNativePermissions.PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION] : _reactNative.Platform.OS === "ios" ? [_reactNativePermissions.PERMISSIONS.IOS.BLUETOOTH] : [];
|
|
17
|
+
const permissionRequest = (0, _reactNativePermissions.requestMultiple)(requestedPermissions).then(results => {
|
|
18
|
+
const granted = requestedPermissions.length > 0 && requestedPermissions.every(permission => results[permission] === "granted");
|
|
19
|
+
return {
|
|
20
|
+
granted,
|
|
21
|
+
status: granted ? "granted" : requestedPermissions.some(permission => results[permission] === "blocked") ? "blocked" : "denied"
|
|
22
|
+
};
|
|
23
|
+
}).finally(() => {
|
|
24
|
+
sharedPermissionRequest = undefined;
|
|
25
|
+
});
|
|
26
|
+
sharedPermissionRequest = permissionRequest;
|
|
27
|
+
return permissionRequest;
|
|
28
|
+
};
|
|
29
|
+
const requestBluetoothPermission = async () => (await requestBluetoothPermissionResult()).granted;
|
|
30
|
+
exports.requestBluetoothPermission = requestBluetoothPermission;
|
|
31
|
+
const useBluetoothPermission = ({
|
|
32
|
+
requestOnMount = false,
|
|
33
|
+
requestPermission = requestBluetoothPermission,
|
|
34
|
+
onPermissionChanged,
|
|
35
|
+
onRequestError
|
|
36
|
+
} = {}) => {
|
|
37
|
+
const [status, setStatus] = React.useState("unknown");
|
|
38
|
+
const onPermissionChangedRef = React.useRef(onPermissionChanged);
|
|
39
|
+
const onRequestErrorRef = React.useRef(onRequestError);
|
|
40
|
+
const requestPermissionRef = React.useRef(requestPermission);
|
|
41
|
+
const requestInFlightRef = React.useRef(undefined);
|
|
42
|
+
const requestOnResumeRef = React.useRef(false);
|
|
43
|
+
onPermissionChangedRef.current = onPermissionChanged;
|
|
44
|
+
onRequestErrorRef.current = onRequestError;
|
|
45
|
+
requestPermissionRef.current = requestPermission;
|
|
46
|
+
const request = React.useCallback(() => {
|
|
47
|
+
if (requestInFlightRef.current) {
|
|
48
|
+
return requestInFlightRef.current;
|
|
49
|
+
}
|
|
50
|
+
const requestPromise = requestPermissionRef.current === requestBluetoothPermission ? requestBluetoothPermissionResult() : requestPermissionRef.current().then(granted => ({
|
|
51
|
+
granted,
|
|
52
|
+
status: granted ? "granted" : "denied"
|
|
53
|
+
}));
|
|
54
|
+
const pending = requestPromise.then(({
|
|
55
|
+
granted,
|
|
56
|
+
status: nextStatus
|
|
57
|
+
}) => {
|
|
58
|
+
setStatus(nextStatus);
|
|
59
|
+
onPermissionChangedRef.current?.(granted);
|
|
60
|
+
return granted;
|
|
61
|
+
}).catch(error => {
|
|
62
|
+
setStatus("denied");
|
|
63
|
+
onPermissionChangedRef.current?.(false);
|
|
64
|
+
onRequestErrorRef.current?.(error);
|
|
65
|
+
throw error;
|
|
66
|
+
}).finally(() => {
|
|
67
|
+
requestInFlightRef.current = undefined;
|
|
68
|
+
});
|
|
69
|
+
requestInFlightRef.current = pending;
|
|
70
|
+
return pending;
|
|
71
|
+
}, []);
|
|
72
|
+
const openSettings = React.useCallback(() => {
|
|
73
|
+
requestOnResumeRef.current = true;
|
|
74
|
+
void _reactNative.Linking.openSettings();
|
|
75
|
+
}, []);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
let wasActive = _reactNative.AppState.currentState === "active";
|
|
78
|
+
const listener = _reactNative.AppState.addEventListener("change", nextState => {
|
|
79
|
+
const resumed = nextState === "active" && !wasActive;
|
|
80
|
+
wasActive = nextState === "active";
|
|
81
|
+
if (resumed && requestOnResumeRef.current) {
|
|
82
|
+
requestOnResumeRef.current = false;
|
|
83
|
+
void request().catch(() => undefined);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (requestOnMount) {
|
|
87
|
+
void request().catch(() => undefined);
|
|
88
|
+
}
|
|
89
|
+
return () => listener.remove();
|
|
90
|
+
}, [request, requestOnMount]);
|
|
91
|
+
return {
|
|
92
|
+
status,
|
|
93
|
+
request,
|
|
94
|
+
requestPermission: request,
|
|
95
|
+
openSettings,
|
|
96
|
+
accessPermission: status === "unknown" ? undefined : status === "granted"
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.useBluetoothPermission = useBluetoothPermission;
|
|
100
|
+
//# sourceMappingURL=use-bluetooth-permission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_reactNativePermissions","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","sharedPermissionRequest","requestBluetoothPermissionResult","requestedPermissions","Platform","OS","Number","Version","PERMISSIONS","ANDROID","BLUETOOTH_CONNECT","BLUETOOTH_SCAN","ACCESS_FINE_LOCATION","IOS","BLUETOOTH","permissionRequest","requestMultiple","then","results","granted","length","every","permission","status","some","finally","undefined","requestBluetoothPermission","exports","useBluetoothPermission","requestOnMount","requestPermission","onPermissionChanged","onRequestError","setStatus","useState","onPermissionChangedRef","useRef","onRequestErrorRef","requestPermissionRef","requestInFlightRef","requestOnResumeRef","current","request","useCallback","requestPromise","pending","nextStatus","catch","error","openSettings","Linking","useEffect","wasActive","AppState","currentState","listener","addEventListener","nextState","resumed","remove","accessPermission"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/hooks/use-bluetooth-permission.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AAAwE,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CA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KAAK,CAAC,MAAMtB,SAAS,CAAC;MACvC;IACF,CAAC,CAAC;IAEF,IAAII,cAAc,EAAE;MAClB,KAAKa,OAAO,CAAC,CAAC,CAACK,KAAK,CAAC,MAAMtB,SAAS,CAAC;IACvC;IAEA,OAAO,MAAM8B,QAAQ,CAACI,MAAM,CAAC,CAAC;EAChC,CAAC,EAAE,CAACjB,OAAO,EAAEb,cAAc,CAAC,CAAC;EAE7B,OAAO;IACLP,MAAM;IACNoB,OAAO;IACPZ,iBAAiB,EAAEY,OAAO;IAC1BO,YAAY;IACZW,gBAAgB,EAAEtC,MAAM,KAAK,SAAS,GAAGG,SAAS,GAAGH,MAAM,KAAK;EAClE,CAAC;AACH,CAAC;AAACK,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -5,46 +5,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useBluetoothState = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
8
|
var _reactNativeBlePlx = require("react-native-ble-plx");
|
|
10
|
-
var
|
|
9
|
+
var _runtimeContext = require("./runtime-context.js");
|
|
10
|
+
var _useBluetoothPermission = require("./use-bluetooth-permission.js");
|
|
11
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
12
|
/* eslint-disable import/group-exports */
|
|
13
13
|
|
|
14
|
-
const requestBluetoothPermission = async () => {
|
|
15
|
-
const permissions = _reactNative.Platform.select({
|
|
16
|
-
android: [_reactNativePermissions.PERMISSIONS.ANDROID.BLUETOOTH_SCAN, _reactNativePermissions.PERMISSIONS.ANDROID.BLUETOOTH_CONNECT],
|
|
17
|
-
ios: [_reactNativePermissions.PERMISSIONS.IOS.BLUETOOTH],
|
|
18
|
-
default: []
|
|
19
|
-
});
|
|
20
|
-
const result = await (0, _reactNativePermissions.requestMultiple)(permissions);
|
|
21
|
-
return Object.values(result).every(value => value === "granted");
|
|
22
|
-
};
|
|
23
14
|
const useBluetoothState = ({
|
|
24
15
|
bleManager,
|
|
25
|
-
requestPermission
|
|
16
|
+
requestPermission
|
|
26
17
|
} = {}) => {
|
|
27
|
-
const
|
|
18
|
+
const runtime = (0, _runtimeContext.useBluetoothRuntime)();
|
|
19
|
+
const runtimeState = (0, _runtimeContext.useBluetoothSelector)(snapshot => snapshot.bluetoothState);
|
|
20
|
+
const permission = (0, _useBluetoothPermission.useBluetoothPermission)({
|
|
21
|
+
requestPermission
|
|
22
|
+
});
|
|
28
23
|
React.useEffect(() => {
|
|
29
|
-
if (!bleManager) {
|
|
30
|
-
setState("unsupported");
|
|
24
|
+
if (!bleManager || bleManager === runtime.bleManager) {
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
33
27
|
const subscription = bleManager.onStateChange(nextState => {
|
|
34
|
-
|
|
28
|
+
runtime.setBluetoothState(nextState === _reactNativeBlePlx.State.PoweredOn ? "on" : nextState === _reactNativeBlePlx.State.Unsupported ? "unsupported" : nextState === _reactNativeBlePlx.State.Unauthorized ? "unauthorized" : "off");
|
|
35
29
|
}, true);
|
|
36
30
|
return () => subscription.remove();
|
|
37
|
-
}, [bleManager]);
|
|
38
|
-
const request = React.useCallback(async () => {
|
|
39
|
-
const granted = await requestPermission();
|
|
40
|
-
if (!granted) {
|
|
41
|
-
setState("unauthorized");
|
|
42
|
-
}
|
|
43
|
-
return granted;
|
|
44
|
-
}, [requestPermission]);
|
|
31
|
+
}, [bleManager, runtime]);
|
|
45
32
|
return {
|
|
46
|
-
state,
|
|
47
|
-
requestPermission: request
|
|
33
|
+
state: permission.status === "denied" || permission.status === "blocked" ? "unauthorized" : runtimeState === "unknown" ? runtime.bleManager || bleManager ? "off" : "unsupported" : runtimeState,
|
|
34
|
+
requestPermission: permission.request
|
|
48
35
|
};
|
|
49
36
|
};
|
|
50
37
|
exports.useBluetoothState = useBluetoothState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNativeBlePlx","_runtimeContext","_useBluetoothPermission","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","useBluetoothState","bleManager","requestPermission","runtime","useBluetoothRuntime","runtimeState","useBluetoothSelector","snapshot","bluetoothState","permission","useBluetoothPermission","useEffect","subscription","onStateChange","nextState","setBluetoothState","State","PoweredOn","Unsupported","Unauthorized","remove","state","status","request","exports"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/hooks/use-bluetooth-state.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAAoE,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,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