tempest-react-sdk 0.47.0 → 0.49.0
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/dist/audio/sfx-pool.cjs +1 -1
- package/dist/audio/sfx-pool.cjs.map +1 -1
- package/dist/audio/sfx-pool.js +16 -7
- package/dist/audio/sfx-pool.js.map +1 -1
- package/dist/audio/use-sfx-pool.cjs +1 -1
- package/dist/audio/use-sfx-pool.cjs.map +1 -1
- package/dist/audio/use-sfx-pool.js +3 -8
- package/dist/audio/use-sfx-pool.js.map +1 -1
- package/dist/auth/passkey.cjs +1 -1
- package/dist/auth/passkey.cjs.map +1 -1
- package/dist/auth/passkey.js +79 -81
- package/dist/auth/passkey.js.map +1 -1
- package/dist/charts.cjs +1 -1
- package/dist/charts.js +4 -4
- package/dist/components/AIChat/AIChatTurn.cjs +1 -1
- package/dist/components/AIChat/AIChatTurn.js +4 -4
- package/dist/components/AppBar/use-sticky-body-warning.cjs.map +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.js.map +1 -1
- package/dist/components/BarList/BarList.cjs +1 -1
- package/dist/components/BarList/BarList.cjs.map +1 -1
- package/dist/components/BarList/BarList.js +31 -24
- package/dist/components/BarList/BarList.js.map +1 -1
- package/dist/components/BarList/bar-list-model.cjs +1 -1
- package/dist/components/BarList/bar-list-model.cjs.map +1 -1
- package/dist/components/BarList/bar-list-model.js +5 -5
- package/dist/components/BarList/bar-list-model.js.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.js +13 -14
- package/dist/components/ClickOutside/ClickOutside.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +131 -129
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.cjs.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.js.map +1 -1
- package/dist/components/FilterBar/filter-apply.cjs +1 -1
- package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
- package/dist/components/FilterBar/filter-apply.js +35 -38
- package/dist/components/FilterBar/filter-apply.js.map +1 -1
- package/dist/components/FilterBar/filter-query.cjs +1 -1
- package/dist/components/FilterBar/filter-query.cjs.map +1 -1
- package/dist/components/FilterBar/filter-query.js +16 -13
- package/dist/components/FilterBar/filter-query.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js +21 -21
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js +91 -38
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.module.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.module.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.module.js +12 -8
- package/dist/components/Sidebar/Sidebar.module.js.map +1 -1
- package/dist/forms/masked-inputs.cjs +1 -1
- package/dist/forms/masked-inputs.js +12 -12
- package/dist/geo/use-position-tracker.cjs +1 -1
- package/dist/geo/use-position-tracker.cjs.map +1 -1
- package/dist/geo/use-position-tracker.js +25 -26
- package/dist/geo/use-position-tracker.js.map +1 -1
- package/dist/hooks/use-async.cjs +1 -1
- package/dist/hooks/use-async.cjs.map +1 -1
- package/dist/hooks/use-async.js +27 -30
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-click-outside.cjs +1 -1
- package/dist/hooks/use-click-outside.cjs.map +1 -1
- package/dist/hooks/use-click-outside.js +8 -9
- package/dist/hooks/use-click-outside.js.map +1 -1
- package/dist/hooks/use-countdown.cjs +1 -1
- package/dist/hooks/use-countdown.cjs.map +1 -1
- package/dist/hooks/use-countdown.js +8 -13
- package/dist/hooks/use-countdown.js.map +1 -1
- package/dist/hooks/use-event-listener.cjs +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-event-listener.js +6 -6
- package/dist/hooks/use-event-listener.js.map +1 -1
- package/dist/hooks/use-interval.cjs +1 -1
- package/dist/hooks/use-interval.cjs.map +1 -1
- package/dist/hooks/use-interval.js +5 -6
- package/dist/hooks/use-interval.js.map +1 -1
- package/dist/hooks/use-latest-ref.cjs.map +1 -1
- package/dist/hooks/use-latest-ref.js.map +1 -1
- package/dist/hooks/use-long-press-handlers.cjs +1 -1
- package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
- package/dist/hooks/use-long-press-handlers.js +8 -10
- package/dist/hooks/use-long-press-handlers.js.map +1 -1
- package/dist/hooks/use-long-press.cjs +1 -1
- package/dist/hooks/use-long-press.cjs.map +1 -1
- package/dist/hooks/use-long-press.js +6 -6
- package/dist/hooks/use-long-press.js.map +1 -1
- package/dist/hooks/use-online.cjs +1 -1
- package/dist/hooks/use-online.cjs.map +1 -1
- package/dist/hooks/use-online.js +10 -10
- package/dist/hooks/use-online.js.map +1 -1
- package/dist/hooks/use-service-worker-update.cjs +1 -1
- package/dist/hooks/use-service-worker-update.cjs.map +1 -1
- package/dist/hooks/use-service-worker-update.js +24 -25
- package/dist/hooks/use-service-worker-update.js.map +1 -1
- package/dist/hooks/use-stable-callback.cjs +1 -1
- package/dist/hooks/use-stable-callback.cjs.map +1 -1
- package/dist/hooks/use-stable-callback.js +4 -3
- package/dist/hooks/use-stable-callback.js.map +1 -1
- package/dist/hooks/use-timeout.cjs +1 -1
- package/dist/hooks/use-timeout.cjs.map +1 -1
- package/dist/hooks/use-timeout.js +5 -6
- package/dist/hooks/use-timeout.js.map +1 -1
- package/dist/hooks/use-typewriter.cjs +1 -1
- package/dist/hooks/use-typewriter.cjs.map +1 -1
- package/dist/hooks/use-typewriter.js +9 -18
- package/dist/hooks/use-typewriter.js.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +55 -46
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/describe-api-error.cjs +1 -1
- package/dist/http/describe-api-error.cjs.map +1 -1
- package/dist/http/describe-api-error.js +15 -14
- package/dist/http/describe-api-error.js.map +1 -1
- package/dist/http/errors.cjs +1 -1
- package/dist/http/errors.cjs.map +1 -1
- package/dist/http/errors.js +49 -20
- package/dist/http/errors.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +60 -61
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/retry.cjs +1 -1
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.js +20 -16
- package/dist/http/retry.js.map +1 -1
- package/dist/http/use-describe-api-error.cjs +1 -1
- package/dist/http/use-describe-api-error.cjs.map +1 -1
- package/dist/http/use-describe-api-error.js +14 -10
- package/dist/http/use-describe-api-error.js.map +1 -1
- package/dist/i18n/create-i18n.cjs +1 -1
- package/dist/i18n/create-i18n.cjs.map +1 -1
- package/dist/i18n/create-i18n.js +6 -6
- package/dist/i18n/create-i18n.js.map +1 -1
- package/dist/icons/Icon.cjs +1 -1
- package/dist/icons/Icon.cjs.map +1 -1
- package/dist/icons/Icon.js +15 -14
- package/dist/icons/Icon.js.map +1 -1
- package/dist/icons/IconPicker.cjs +2 -0
- package/dist/icons/IconPicker.cjs.map +1 -0
- package/dist/icons/IconPicker.js +49 -0
- package/dist/icons/IconPicker.js.map +1 -0
- package/dist/icons/IconPicker.module.cjs +2 -0
- package/dist/icons/IconPicker.module.cjs.map +1 -0
- package/dist/icons/IconPicker.module.js +10 -0
- package/dist/icons/IconPicker.module.js.map +1 -0
- package/dist/icons/alias.cjs +2 -0
- package/dist/icons/alias.cjs.map +1 -0
- package/dist/icons/alias.js +9 -0
- package/dist/icons/alias.js.map +1 -0
- package/dist/icons/generated/loaders.cjs +1 -1
- package/dist/icons/generated/loaders.cjs.map +1 -1
- package/dist/icons/generated/loaders.js +273 -28
- package/dist/icons/generated/loaders.js.map +1 -1
- package/dist/icons/generated/shard-00.cjs +2 -0
- package/dist/icons/generated/shard-00.cjs.map +1 -0
- package/dist/icons/generated/shard-00.js +48 -0
- package/dist/icons/generated/shard-00.js.map +1 -0
- package/dist/icons/generated/shard-01.cjs +2 -0
- package/dist/icons/generated/shard-01.cjs.map +1 -0
- package/dist/icons/generated/shard-01.js +48 -0
- package/dist/icons/generated/shard-01.js.map +1 -0
- package/dist/icons/generated/shard-02.cjs +2 -0
- package/dist/icons/generated/shard-02.cjs.map +1 -0
- package/dist/icons/generated/shard-02.js +48 -0
- package/dist/icons/generated/shard-02.js.map +1 -0
- package/dist/icons/generated/shard-03.cjs +2 -0
- package/dist/icons/generated/shard-03.cjs.map +1 -0
- package/dist/icons/generated/shard-03.js +48 -0
- package/dist/icons/generated/shard-03.js.map +1 -0
- package/dist/icons/generated/shard-04.cjs +2 -0
- package/dist/icons/generated/shard-04.cjs.map +1 -0
- package/dist/icons/generated/shard-04.js +48 -0
- package/dist/icons/generated/shard-04.js.map +1 -0
- package/dist/icons/generated/shard-05.cjs +2 -0
- package/dist/icons/generated/shard-05.cjs.map +1 -0
- package/dist/icons/generated/shard-05.js +48 -0
- package/dist/icons/generated/shard-05.js.map +1 -0
- package/dist/icons/generated/shard-06.cjs +2 -0
- package/dist/icons/generated/shard-06.cjs.map +1 -0
- package/dist/icons/generated/shard-06.js +48 -0
- package/dist/icons/generated/shard-06.js.map +1 -0
- package/dist/icons/generated/shard-07.cjs +2 -0
- package/dist/icons/generated/shard-07.cjs.map +1 -0
- package/dist/icons/generated/shard-07.js +48 -0
- package/dist/icons/generated/shard-07.js.map +1 -0
- package/dist/icons/generated/shard-08.cjs +2 -0
- package/dist/icons/generated/shard-08.cjs.map +1 -0
- package/dist/icons/generated/shard-08.js +48 -0
- package/dist/icons/generated/shard-08.js.map +1 -0
- package/dist/icons/generated/shard-09.cjs +2 -0
- package/dist/icons/generated/shard-09.cjs.map +1 -0
- package/dist/icons/generated/shard-09.js +48 -0
- package/dist/icons/generated/shard-09.js.map +1 -0
- package/dist/icons/generated/shard-10.cjs +2 -0
- package/dist/icons/generated/shard-10.cjs.map +1 -0
- package/dist/icons/generated/shard-10.js +48 -0
- package/dist/icons/generated/shard-10.js.map +1 -0
- package/dist/icons/generated/shard-11.cjs +2 -0
- package/dist/icons/generated/shard-11.cjs.map +1 -0
- package/dist/icons/generated/shard-11.js +48 -0
- package/dist/icons/generated/shard-11.js.map +1 -0
- package/dist/icons/generated/shard-12.cjs +2 -0
- package/dist/icons/generated/shard-12.cjs.map +1 -0
- package/dist/icons/generated/shard-12.js +48 -0
- package/dist/icons/generated/shard-12.js.map +1 -0
- package/dist/icons/generated/shard-13.cjs +2 -0
- package/dist/icons/generated/shard-13.cjs.map +1 -0
- package/dist/icons/generated/shard-13.js +48 -0
- package/dist/icons/generated/shard-13.js.map +1 -0
- package/dist/icons/generated/shard-14.cjs +2 -0
- package/dist/icons/generated/shard-14.cjs.map +1 -0
- package/dist/icons/generated/shard-14.js +48 -0
- package/dist/icons/generated/shard-14.js.map +1 -0
- package/dist/icons/generated/shard-15.cjs +2 -0
- package/dist/icons/generated/shard-15.cjs.map +1 -0
- package/dist/icons/generated/shard-15.js +48 -0
- package/dist/icons/generated/shard-15.js.map +1 -0
- package/dist/icons/generated/shard-16.cjs +2 -0
- package/dist/icons/generated/shard-16.cjs.map +1 -0
- package/dist/icons/generated/shard-16.js +48 -0
- package/dist/icons/generated/shard-16.js.map +1 -0
- package/dist/icons/generated/shard-17.cjs +2 -0
- package/dist/icons/generated/shard-17.cjs.map +1 -0
- package/dist/icons/generated/shard-17.js +48 -0
- package/dist/icons/generated/shard-17.js.map +1 -0
- package/dist/icons/generated/shard-18.cjs +2 -0
- package/dist/icons/generated/shard-18.cjs.map +1 -0
- package/dist/icons/generated/shard-18.js +48 -0
- package/dist/icons/generated/shard-18.js.map +1 -0
- package/dist/icons/generated/shard-19.cjs +2 -0
- package/dist/icons/generated/shard-19.cjs.map +1 -0
- package/dist/icons/generated/shard-19.js +48 -0
- package/dist/icons/generated/shard-19.js.map +1 -0
- package/dist/icons/generated/shard-20.cjs +2 -0
- package/dist/icons/generated/shard-20.cjs.map +1 -0
- package/dist/icons/generated/shard-20.js +48 -0
- package/dist/icons/generated/shard-20.js.map +1 -0
- package/dist/icons/generated/shard-21.cjs +2 -0
- package/dist/icons/generated/shard-21.cjs.map +1 -0
- package/dist/icons/generated/shard-21.js +48 -0
- package/dist/icons/generated/shard-21.js.map +1 -0
- package/dist/icons/generated/shard-22.cjs +2 -0
- package/dist/icons/generated/shard-22.cjs.map +1 -0
- package/dist/icons/generated/shard-22.js +48 -0
- package/dist/icons/generated/shard-22.js.map +1 -0
- package/dist/icons/generated/shard-23.cjs +2 -0
- package/dist/icons/generated/shard-23.cjs.map +1 -0
- package/dist/icons/generated/shard-23.js +48 -0
- package/dist/icons/generated/shard-23.js.map +1 -0
- package/dist/icons/generated/shard-24.cjs +2 -0
- package/dist/icons/generated/shard-24.cjs.map +1 -0
- package/dist/icons/generated/shard-24.js +48 -0
- package/dist/icons/generated/shard-24.js.map +1 -0
- package/dist/icons/generated/shard-25.cjs +2 -0
- package/dist/icons/generated/shard-25.cjs.map +1 -0
- package/dist/icons/generated/shard-25.js +48 -0
- package/dist/icons/generated/shard-25.js.map +1 -0
- package/dist/icons/generated/shard-26.cjs +2 -0
- package/dist/icons/generated/shard-26.cjs.map +1 -0
- package/dist/icons/generated/shard-26.js +48 -0
- package/dist/icons/generated/shard-26.js.map +1 -0
- package/dist/icons/generated/shard-27.cjs +2 -0
- package/dist/icons/generated/shard-27.cjs.map +1 -0
- package/dist/icons/generated/shard-27.js +48 -0
- package/dist/icons/generated/shard-27.js.map +1 -0
- package/dist/icons/generated/shard-28.cjs +2 -0
- package/dist/icons/generated/shard-28.cjs.map +1 -0
- package/dist/icons/generated/shard-28.js +48 -0
- package/dist/icons/generated/shard-28.js.map +1 -0
- package/dist/icons/generated/shard-29.cjs +2 -0
- package/dist/icons/generated/shard-29.cjs.map +1 -0
- package/dist/icons/generated/shard-29.js +48 -0
- package/dist/icons/generated/shard-29.js.map +1 -0
- package/dist/icons/generated/shard-30.cjs +2 -0
- package/dist/icons/generated/shard-30.cjs.map +1 -0
- package/dist/icons/generated/shard-30.js +48 -0
- package/dist/icons/generated/shard-30.js.map +1 -0
- package/dist/icons/generated/shard-31.cjs +2 -0
- package/dist/icons/generated/shard-31.cjs.map +1 -0
- package/dist/icons/generated/shard-31.js +48 -0
- package/dist/icons/generated/shard-31.js.map +1 -0
- package/dist/icons/generated/shard-32.cjs +2 -0
- package/dist/icons/generated/shard-32.cjs.map +1 -0
- package/dist/icons/generated/shard-32.js +48 -0
- package/dist/icons/generated/shard-32.js.map +1 -0
- package/dist/icons/generated/shard-33.cjs +2 -0
- package/dist/icons/generated/shard-33.cjs.map +1 -0
- package/dist/icons/generated/shard-33.js +48 -0
- package/dist/icons/generated/shard-33.js.map +1 -0
- package/dist/icons/generated/shard-34.cjs +2 -0
- package/dist/icons/generated/shard-34.cjs.map +1 -0
- package/dist/icons/generated/shard-34.js +48 -0
- package/dist/icons/generated/shard-34.js.map +1 -0
- package/dist/icons/generated/shard-35.cjs +2 -0
- package/dist/icons/generated/shard-35.cjs.map +1 -0
- package/dist/icons/generated/shard-35.js +48 -0
- package/dist/icons/generated/shard-35.js.map +1 -0
- package/dist/icons/generated/shard-36.cjs +2 -0
- package/dist/icons/generated/shard-36.cjs.map +1 -0
- package/dist/icons/generated/shard-36.js +48 -0
- package/dist/icons/generated/shard-36.js.map +1 -0
- package/dist/icons/generated/shard-37.cjs +2 -0
- package/dist/icons/generated/shard-37.cjs.map +1 -0
- package/dist/icons/generated/shard-37.js +48 -0
- package/dist/icons/generated/shard-37.js.map +1 -0
- package/dist/icons/generated/shard-38.cjs +2 -0
- package/dist/icons/generated/shard-38.cjs.map +1 -0
- package/dist/icons/generated/shard-38.js +48 -0
- package/dist/icons/generated/shard-38.js.map +1 -0
- package/dist/icons/generated/shard-39.cjs +2 -0
- package/dist/icons/generated/shard-39.cjs.map +1 -0
- package/dist/icons/generated/shard-39.js +48 -0
- package/dist/icons/generated/shard-39.js.map +1 -0
- package/dist/icons/generated/shard-40.cjs +2 -0
- package/dist/icons/generated/shard-40.cjs.map +1 -0
- package/dist/icons/generated/shard-40.js +48 -0
- package/dist/icons/generated/shard-40.js.map +1 -0
- package/dist/icons/generated/shard-41.cjs +2 -0
- package/dist/icons/generated/shard-41.cjs.map +1 -0
- package/dist/icons/generated/shard-41.js +48 -0
- package/dist/icons/generated/shard-41.js.map +1 -0
- package/dist/icons/generated/shard-42.cjs +2 -0
- package/dist/icons/generated/shard-42.cjs.map +1 -0
- package/dist/icons/generated/shard-42.js +48 -0
- package/dist/icons/generated/shard-42.js.map +1 -0
- package/dist/icons/generated/shard-43.cjs +2 -0
- package/dist/icons/generated/shard-43.cjs.map +1 -0
- package/dist/icons/generated/shard-43.js +48 -0
- package/dist/icons/generated/shard-43.js.map +1 -0
- package/dist/icons/generated/shard-44.cjs +2 -0
- package/dist/icons/generated/shard-44.cjs.map +1 -0
- package/dist/icons/generated/shard-44.js +15 -0
- package/dist/icons/generated/shard-44.js.map +1 -0
- package/dist/icons/material-symbols.cjs +1 -1
- package/dist/icons/material-symbols.cjs.map +1 -1
- package/dist/icons/material-symbols.js +240 -1
- package/dist/icons/material-symbols.js.map +1 -1
- package/dist/icons/normalize-icon-name.cjs +2 -0
- package/dist/icons/normalize-icon-name.cjs.map +1 -0
- package/dist/icons/normalize-icon-name.js +9 -0
- package/dist/icons/normalize-icon-name.js.map +1 -0
- package/dist/icons/shard-cache.cjs +1 -1
- package/dist/icons/shard-cache.cjs.map +1 -1
- package/dist/icons/shard-cache.js +85 -32
- package/dist/icons/shard-cache.js.map +1 -1
- package/dist/icons/validate-icon-name.cjs +2 -0
- package/dist/icons/validate-icon-name.cjs.map +1 -0
- package/dist/icons/validate-icon-name.js +11 -0
- package/dist/icons/validate-icon-name.js.map +1 -0
- package/dist/icons-virtual-id.d.ts +24 -0
- package/dist/icons-virtual.cjs +2 -0
- package/dist/icons-virtual.cjs.map +1 -0
- package/dist/icons-virtual.d.ts +30 -22
- package/dist/icons-virtual.js +6 -0
- package/dist/icons-virtual.js.map +1 -0
- package/dist/icons.cjs +1 -1
- package/dist/icons.d.ts +282 -33
- package/dist/icons.js +11 -7
- package/dist/offline/create-offline-sync.cjs +1 -1
- package/dist/offline/create-offline-sync.cjs.map +1 -1
- package/dist/offline/create-offline-sync.js +17 -9
- package/dist/offline/create-offline-sync.js.map +1 -1
- package/dist/offline/use-offline-sync.cjs +1 -1
- package/dist/offline/use-offline-sync.cjs.map +1 -1
- package/dist/offline/use-offline-sync.js +7 -8
- package/dist/offline/use-offline-sync.js.map +1 -1
- package/dist/push/use-push-subscription.cjs +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/push/use-push-subscription.js +13 -12
- package/dist/push/use-push-subscription.js.map +1 -1
- package/dist/query/retry-policy.cjs +1 -1
- package/dist/query/retry-policy.cjs.map +1 -1
- package/dist/query/retry-policy.js +3 -3
- package/dist/query/retry-policy.js.map +1 -1
- package/dist/sse/use-event-stream.cjs +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/sse/use-event-stream.js +19 -20
- package/dist/sse/use-event-stream.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tabular/use-tabular-predictor.cjs +1 -1
- package/dist/tabular/use-tabular-predictor.cjs.map +1 -1
- package/dist/tabular/use-tabular-predictor.js +20 -17
- package/dist/tabular/use-tabular-predictor.js.map +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +458 -213
- package/dist/tempest-react-sdk.js +328 -329
- package/dist/theme/ThemeProvider.cjs +1 -1
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.js +12 -17
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/utils/base64.cjs +2 -0
- package/dist/utils/base64.cjs.map +1 -0
- package/dist/utils/base64.js +16 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/compare-values.cjs +1 -1
- package/dist/utils/compare-values.cjs.map +1 -1
- package/dist/utils/compare-values.js +4 -3
- package/dist/utils/compare-values.js.map +1 -1
- package/dist/utils/compressed-storage.cjs +1 -1
- package/dist/utils/compressed-storage.cjs.map +1 -1
- package/dist/utils/compressed-storage.js +16 -46
- package/dist/utils/compressed-storage.js.map +1 -1
- package/dist/utils/dev-mode.cjs.map +1 -1
- package/dist/utils/dev-mode.js.map +1 -1
- package/dist/utils/storage.cjs +1 -1
- package/dist/utils/storage.cjs.map +1 -1
- package/dist/utils/storage.js +37 -17
- package/dist/utils/storage.js.map +1 -1
- package/dist/vision/use-camera-stream.cjs +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-camera-stream.js +34 -33
- package/dist/vision/use-camera-stream.js.map +1 -1
- package/dist/vite/base-url.cjs +2 -0
- package/dist/vite/base-url.cjs.map +1 -0
- package/dist/vite/base-url.js +8 -0
- package/dist/vite/base-url.js.map +1 -0
- package/dist/vite/tempest-icons.cjs +4 -4
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-icons.js +26 -26
- package/dist/vite/tempest-icons.js.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.js +54 -29
- package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
- package/dist/vite/tempest-pwa-manifest.cjs +2 -2
- package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
- package/dist/vite/tempest-pwa-manifest.js +15 -14
- package/dist/vite/tempest-pwa-manifest.js.map +1 -1
- package/dist/vite.d.ts +3 -3
- package/dist/ws/use-web-socket.cjs +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js +40 -42
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +5 -2
- package/dist/icons/generated/shard-a.cjs +0 -2
- package/dist/icons/generated/shard-a.cjs.map +0 -1
- package/dist/icons/generated/shard-a.js +0 -114
- package/dist/icons/generated/shard-a.js.map +0 -1
- package/dist/icons/generated/shard-b.cjs +0 -2
- package/dist/icons/generated/shard-b.cjs.map +0 -1
- package/dist/icons/generated/shard-b.js +0 -158
- package/dist/icons/generated/shard-b.js.map +0 -1
- package/dist/icons/generated/shard-c.cjs +0 -2
- package/dist/icons/generated/shard-c.cjs.map +0 -1
- package/dist/icons/generated/shard-c.js +0 -269
- package/dist/icons/generated/shard-c.js.map +0 -1
- package/dist/icons/generated/shard-d.cjs +0 -2
- package/dist/icons/generated/shard-d.cjs.map +0 -1
- package/dist/icons/generated/shard-d.js +0 -62
- package/dist/icons/generated/shard-d.js.map +0 -1
- package/dist/icons/generated/shard-e.cjs +0 -2
- package/dist/icons/generated/shard-e.cjs.map +0 -1
- package/dist/icons/generated/shard-e.js +0 -33
- package/dist/icons/generated/shard-e.js.map +0 -1
- package/dist/icons/generated/shard-f.cjs +0 -2
- package/dist/icons/generated/shard-f.cjs.map +0 -1
- package/dist/icons/generated/shard-f.js +0 -145
- package/dist/icons/generated/shard-f.js.map +0 -1
- package/dist/icons/generated/shard-g.cjs +0 -2
- package/dist/icons/generated/shard-g.cjs.map +0 -1
- package/dist/icons/generated/shard-g.js +0 -61
- package/dist/icons/generated/shard-g.js.map +0 -1
- package/dist/icons/generated/shard-h.cjs +0 -2
- package/dist/icons/generated/shard-h.cjs.map +0 -1
- package/dist/icons/generated/shard-h.js +0 -62
- package/dist/icons/generated/shard-h.js.map +0 -1
- package/dist/icons/generated/shard-i.cjs +0 -2
- package/dist/icons/generated/shard-i.cjs.map +0 -1
- package/dist/icons/generated/shard-i.js +0 -30
- package/dist/icons/generated/shard-i.js.map +0 -1
- package/dist/icons/generated/shard-j.cjs +0 -2
- package/dist/icons/generated/shard-j.cjs.map +0 -1
- package/dist/icons/generated/shard-j.js +0 -10
- package/dist/icons/generated/shard-j.js.map +0 -1
- package/dist/icons/generated/shard-k.cjs +0 -2
- package/dist/icons/generated/shard-k.cjs.map +0 -1
- package/dist/icons/generated/shard-k.js +0 -16
- package/dist/icons/generated/shard-k.js.map +0 -1
- package/dist/icons/generated/shard-l.cjs +0 -2
- package/dist/icons/generated/shard-l.cjs.map +0 -1
- package/dist/icons/generated/shard-l.js +0 -92
- package/dist/icons/generated/shard-l.js.map +0 -1
- package/dist/icons/generated/shard-m.cjs +0 -2
- package/dist/icons/generated/shard-m.cjs.map +0 -1
- package/dist/icons/generated/shard-m.js +0 -143
- package/dist/icons/generated/shard-m.js.map +0 -1
- package/dist/icons/generated/shard-n.cjs +0 -2
- package/dist/icons/generated/shard-n.cjs.map +0 -1
- package/dist/icons/generated/shard-n.js +0 -24
- package/dist/icons/generated/shard-n.js.map +0 -1
- package/dist/icons/generated/shard-o.cjs +0 -2
- package/dist/icons/generated/shard-o.cjs.map +0 -1
- package/dist/icons/generated/shard-o.js +0 -17
- package/dist/icons/generated/shard-o.js.map +0 -1
- package/dist/icons/generated/shard-p.cjs +0 -2
- package/dist/icons/generated/shard-p.cjs.map +0 -1
- package/dist/icons/generated/shard-p.js +0 -114
- package/dist/icons/generated/shard-p.js.map +0 -1
- package/dist/icons/generated/shard-q.cjs +0 -2
- package/dist/icons/generated/shard-q.cjs.map +0 -1
- package/dist/icons/generated/shard-q.js +0 -10
- package/dist/icons/generated/shard-q.js.map +0 -1
- package/dist/icons/generated/shard-r.cjs +0 -2
- package/dist/icons/generated/shard-r.cjs.map +0 -1
- package/dist/icons/generated/shard-r.js +0 -79
- package/dist/icons/generated/shard-r.js.map +0 -1
- package/dist/icons/generated/shard-s.cjs +0 -2
- package/dist/icons/generated/shard-s.cjs.map +0 -1
- package/dist/icons/generated/shard-s.js +0 -256
- package/dist/icons/generated/shard-s.js.map +0 -1
- package/dist/icons/generated/shard-t.cjs +0 -2
- package/dist/icons/generated/shard-t.cjs.map +0 -1
- package/dist/icons/generated/shard-t.js +0 -109
- package/dist/icons/generated/shard-t.js.map +0 -1
- package/dist/icons/generated/shard-u.cjs +0 -2
- package/dist/icons/generated/shard-u.cjs.map +0 -1
- package/dist/icons/generated/shard-u.js +0 -50
- package/dist/icons/generated/shard-u.js.map +0 -1
- package/dist/icons/generated/shard-v.cjs +0 -2
- package/dist/icons/generated/shard-v.cjs.map +0 -1
- package/dist/icons/generated/shard-v.js +0 -30
- package/dist/icons/generated/shard-v.js.map +0 -1
- package/dist/icons/generated/shard-w.cjs +0 -2
- package/dist/icons/generated/shard-w.cjs.map +0 -1
- package/dist/icons/generated/shard-w.js +0 -48
- package/dist/icons/generated/shard-w.js.map +0 -1
- package/dist/icons/generated/shard-x.cjs +0 -2
- package/dist/icons/generated/shard-x.cjs.map +0 -1
- package/dist/icons/generated/shard-x.js +0 -10
- package/dist/icons/generated/shard-x.js.map +0 -1
- package/dist/icons/generated/shard-z.cjs +0 -2
- package/dist/icons/generated/shard-z.cjs.map +0 -1
- package/dist/icons/generated/shard-z.js +0 -25
- package/dist/icons/generated/shard-z.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-click-outside.cjs","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef =
|
|
1
|
+
{"version":3,"file":"use-click-outside.cjs","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useLatestRef(handler);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, [handlerRef]);\n\n return ref;\n}\n"],"mappings":"+DAYA,SAAgB,EACZ,EACmB,CACnB,IAAM,GAAA,EAAM,EAAA,OAAA,CAAU,IAAI,EACpB,EAAa,EAAA,aAAa,CAAO,EAmBvC,OAjBA,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,OAAO,SAAa,IAAa,OAErC,IAAM,EAAY,GAAyC,CACvD,IAAM,EAAS,EAAM,OACjB,CAAC,EAAI,SAAY,GAAU,EAAI,QAAQ,SAAS,CAAM,GAC1D,EAAW,QAAQ,CACvB,EAIA,OAFA,SAAS,iBAAiB,YAAa,CAAQ,EAC/C,SAAS,iBAAiB,aAAc,CAAQ,MACnC,CACT,SAAS,oBAAoB,YAAa,CAAQ,EAClD,SAAS,oBAAoB,aAAc,CAAQ,CACvD,CACJ,EAAG,CAAC,CAAU,CAAC,EAER,CACX"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useEffect as t, useRef as n } from "react";
|
|
2
3
|
//#region src/hooks/use-click-outside.ts
|
|
3
|
-
function
|
|
4
|
-
let
|
|
5
|
-
return
|
|
6
|
-
i.current = n;
|
|
7
|
-
}, [n]), e(() => {
|
|
4
|
+
function r(r) {
|
|
5
|
+
let i = n(null), a = e(r);
|
|
6
|
+
return t(() => {
|
|
8
7
|
if (typeof document > "u") return;
|
|
9
8
|
let e = (e) => {
|
|
10
9
|
let t = e.target;
|
|
11
|
-
!
|
|
10
|
+
!i.current || t && i.current.contains(t) || a.current();
|
|
12
11
|
};
|
|
13
12
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
|
|
14
13
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
|
|
15
14
|
};
|
|
16
|
-
}, []),
|
|
15
|
+
}, [a]), i;
|
|
17
16
|
}
|
|
18
17
|
//#endregion
|
|
19
|
-
export {
|
|
18
|
+
export { r as useClickOutside };
|
|
20
19
|
|
|
21
20
|
//# sourceMappingURL=use-click-outside.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-click-outside.js","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef =
|
|
1
|
+
{"version":3,"file":"use-click-outside.js","names":[],"sources":["../../src/hooks/use-click-outside.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { RefObject } from \"react\";\n\n/**\n * Call `handler` when a `mousedown` / `touchstart` occurs outside the returned\n * ref's element. SSR-safe — listeners are only attached in the browser.\n *\n * @typeParam T - element type to attach the ref to.\n * @param handler - invoked on an outside interaction.\n * @returns A ref to attach to the element treated as \"inside\".\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: () => void,\n): RefObject<T | null> {\n const ref = useRef<T>(null);\n const handlerRef = useLatestRef(handler);\n\n useEffect(() => {\n if (typeof document === \"undefined\") return;\n\n const listener = (event: MouseEvent | TouchEvent): void => {\n const target = event.target as Node | null;\n if (!ref.current || (target && ref.current.contains(target))) return;\n handlerRef.current();\n };\n\n document.addEventListener(\"mousedown\", listener);\n document.addEventListener(\"touchstart\", listener);\n return () => {\n document.removeEventListener(\"mousedown\", listener);\n document.removeEventListener(\"touchstart\", listener);\n };\n }, [handlerRef]);\n\n return ref;\n}\n"],"mappings":";;;AAYA,SAAgB,EACZ,GACmB;CACnB,IAAM,IAAM,EAAU,IAAI,GACpB,IAAa,EAAa,CAAO;CAmBvC,OAjBA,QAAgB;EACZ,IAAI,OAAO,WAAa,KAAa;EAErC,IAAM,KAAY,MAAyC;GACvD,IAAM,IAAS,EAAM;GACjB,CAAC,EAAI,WAAY,KAAU,EAAI,QAAQ,SAAS,CAAM,KAC1D,EAAW,QAAQ;EACvB;EAIA,OAFA,SAAS,iBAAiB,aAAa,CAAQ,GAC/C,SAAS,iBAAiB,cAAc,CAAQ,SACnC;GAET,AADA,SAAS,oBAAoB,aAAa,CAAQ,GAClD,SAAS,oBAAoB,cAAc,CAAQ;EACvD;CACJ,GAAG,CAAC,CAAU,CAAC,GAER;AACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-interval.cjs");let t=require("react");function n(n,r,i={}){let{tickMs:a=1e3}=i,o=(0,t.useCallback)(()=>Math.max(0,n-(Date.now()-r)),[n,r]),[s,c]=(0,t.useState)(o);return(0,t.useEffect)(()=>{c(o())},[o]),e.useInterval(()=>c(o()),s>0?a:null),s}exports.useCountdown=n;
|
|
2
2
|
//# sourceMappingURL=use-countdown.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-countdown.cjs","names":[],"sources":["../../src/hooks/use-countdown.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\n/** Options for {@link useCountdown}. */\nexport interface UseCountdownOptions {\n /**\n * How often the remaining time is recomputed, in ms. Default `1000`, which\n * suits a \"try again in 3s\" label; drop it to ~50 to drive a progress bar.\n */\n tickMs?: number;\n}\n\n/**\n * Counts down the time left on a window that started at a known instant.\n *\n * Written around a timestamp rather than a decrementing counter on purpose: the\n * remaining time is recomputed from `Date.now()` on every tick, so a throttled\n * background tab, a slow frame or a `setInterval` that drifts cannot make the\n * countdown disagree with the clock. Remounting recovers the correct value too,\n * which a counter held in state cannot do.\n *\n * The interval stops once it reaches zero instead of ticking forever behind a\n * clamp.\n *\n * @param durationMs - Length of the window.\n * @param startedAt - Epoch ms the window opened (`Date.now()` when it started).\n * @param options - Tick cadence.\n * @returns Milliseconds remaining, never below `0`.\n *\n * @example\n * const remaining = useCountdown(60_000, lastSentAt);\n *\n * <button disabled={remaining > 0}>\n * {remaining > 0 ? `Reenviar em ${Math.ceil(remaining / 1000)}s` : \"Reenviar código\"}\n * </button>\n */\nexport function useCountdown(\n durationMs: number,\n startedAt: number,\n options: UseCountdownOptions = {},\n): number {\n const { tickMs = 1000 } = options;\n\n const compute = useCallback(\n () => Math.max(0, durationMs - (Date.now() - startedAt)),\n [durationMs, startedAt],\n );\n\n const [remaining, setRemaining] = useState(compute);\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"use-countdown.cjs","names":[],"sources":["../../src/hooks/use-countdown.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport { useInterval } from \"./use-interval\";\n\n/** Options for {@link useCountdown}. */\nexport interface UseCountdownOptions {\n /**\n * How often the remaining time is recomputed, in ms. Default `1000`, which\n * suits a \"try again in 3s\" label; drop it to ~50 to drive a progress bar.\n */\n tickMs?: number;\n}\n\n/**\n * Counts down the time left on a window that started at a known instant.\n *\n * Written around a timestamp rather than a decrementing counter on purpose: the\n * remaining time is recomputed from `Date.now()` on every tick, so a throttled\n * background tab, a slow frame or a `setInterval` that drifts cannot make the\n * countdown disagree with the clock. Remounting recovers the correct value too,\n * which a counter held in state cannot do.\n *\n * The interval stops once it reaches zero instead of ticking forever behind a\n * clamp — `useInterval` pauses on a `null` delay, so reaching zero is what tears\n * the timer down.\n *\n * @param durationMs - Length of the window.\n * @param startedAt - Epoch ms the window opened (`Date.now()` when it started).\n * @param options - Tick cadence.\n * @returns Milliseconds remaining, never below `0`.\n *\n * @example\n * const remaining = useCountdown(60_000, lastSentAt);\n *\n * <button disabled={remaining > 0}>\n * {remaining > 0 ? `Reenviar em ${Math.ceil(remaining / 1000)}s` : \"Reenviar código\"}\n * </button>\n */\nexport function useCountdown(\n durationMs: number,\n startedAt: number,\n options: UseCountdownOptions = {},\n): number {\n const { tickMs = 1000 } = options;\n\n const compute = useCallback(\n () => Math.max(0, durationMs - (Date.now() - startedAt)),\n [durationMs, startedAt],\n );\n\n const [remaining, setRemaining] = useState(compute);\n\n useEffect(() => {\n setRemaining(compute());\n }, [compute]);\n\n useInterval(() => setRemaining(compute()), remaining > 0 ? tickMs : null);\n\n return remaining;\n}\n"],"mappings":"6DAqCA,SAAgB,EACZ,EACA,EACA,EAA+B,CAAC,EAC1B,CACN,GAAM,CAAE,SAAS,KAAS,EAEpB,GAAA,EAAU,EAAA,YAAA,KACN,KAAK,IAAI,EAAG,GAAc,KAAK,IAAI,EAAI,EAAU,EACvD,CAAC,EAAY,CAAS,CAC1B,EAEM,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAS,CAAO,EAQlD,OANA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAa,EAAQ,CAAC,CAC1B,EAAG,CAAC,CAAO,CAAC,EAEZ,EAAA,gBAAkB,EAAa,EAAQ,CAAC,EAAG,EAAY,EAAI,EAAS,IAAI,EAEjE,CACX"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useInterval as e } from "./use-interval.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useState as r } from "react";
|
|
2
3
|
//#region src/hooks/use-countdown.ts
|
|
3
|
-
function
|
|
4
|
-
let { tickMs:
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let t = setInterval(() => {
|
|
9
|
-
let e = s();
|
|
10
|
-
l(e), e <= 0 && clearInterval(t);
|
|
11
|
-
}, o);
|
|
12
|
-
return () => clearInterval(t);
|
|
13
|
-
}, [s, o]), c;
|
|
4
|
+
function i(i, a, o = {}) {
|
|
5
|
+
let { tickMs: s = 1e3 } = o, c = t(() => Math.max(0, i - (Date.now() - a)), [i, a]), [l, u] = r(c);
|
|
6
|
+
return n(() => {
|
|
7
|
+
u(c());
|
|
8
|
+
}, [c]), e(() => u(c()), l > 0 ? s : null), l;
|
|
14
9
|
}
|
|
15
10
|
//#endregion
|
|
16
|
-
export {
|
|
11
|
+
export { i as useCountdown };
|
|
17
12
|
|
|
18
13
|
//# sourceMappingURL=use-countdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-countdown.js","names":[],"sources":["../../src/hooks/use-countdown.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\n/** Options for {@link useCountdown}. */\nexport interface UseCountdownOptions {\n /**\n * How often the remaining time is recomputed, in ms. Default `1000`, which\n * suits a \"try again in 3s\" label; drop it to ~50 to drive a progress bar.\n */\n tickMs?: number;\n}\n\n/**\n * Counts down the time left on a window that started at a known instant.\n *\n * Written around a timestamp rather than a decrementing counter on purpose: the\n * remaining time is recomputed from `Date.now()` on every tick, so a throttled\n * background tab, a slow frame or a `setInterval` that drifts cannot make the\n * countdown disagree with the clock. Remounting recovers the correct value too,\n * which a counter held in state cannot do.\n *\n * The interval stops once it reaches zero instead of ticking forever behind a\n * clamp.\n *\n * @param durationMs - Length of the window.\n * @param startedAt - Epoch ms the window opened (`Date.now()` when it started).\n * @param options - Tick cadence.\n * @returns Milliseconds remaining, never below `0`.\n *\n * @example\n * const remaining = useCountdown(60_000, lastSentAt);\n *\n * <button disabled={remaining > 0}>\n * {remaining > 0 ? `Reenviar em ${Math.ceil(remaining / 1000)}s` : \"Reenviar código\"}\n * </button>\n */\nexport function useCountdown(\n durationMs: number,\n startedAt: number,\n options: UseCountdownOptions = {},\n): number {\n const { tickMs = 1000 } = options;\n\n const compute = useCallback(\n () => Math.max(0, durationMs - (Date.now() - startedAt)),\n [durationMs, startedAt],\n );\n\n const [remaining, setRemaining] = useState(compute);\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"use-countdown.js","names":[],"sources":["../../src/hooks/use-countdown.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport { useInterval } from \"./use-interval\";\n\n/** Options for {@link useCountdown}. */\nexport interface UseCountdownOptions {\n /**\n * How often the remaining time is recomputed, in ms. Default `1000`, which\n * suits a \"try again in 3s\" label; drop it to ~50 to drive a progress bar.\n */\n tickMs?: number;\n}\n\n/**\n * Counts down the time left on a window that started at a known instant.\n *\n * Written around a timestamp rather than a decrementing counter on purpose: the\n * remaining time is recomputed from `Date.now()` on every tick, so a throttled\n * background tab, a slow frame or a `setInterval` that drifts cannot make the\n * countdown disagree with the clock. Remounting recovers the correct value too,\n * which a counter held in state cannot do.\n *\n * The interval stops once it reaches zero instead of ticking forever behind a\n * clamp — `useInterval` pauses on a `null` delay, so reaching zero is what tears\n * the timer down.\n *\n * @param durationMs - Length of the window.\n * @param startedAt - Epoch ms the window opened (`Date.now()` when it started).\n * @param options - Tick cadence.\n * @returns Milliseconds remaining, never below `0`.\n *\n * @example\n * const remaining = useCountdown(60_000, lastSentAt);\n *\n * <button disabled={remaining > 0}>\n * {remaining > 0 ? `Reenviar em ${Math.ceil(remaining / 1000)}s` : \"Reenviar código\"}\n * </button>\n */\nexport function useCountdown(\n durationMs: number,\n startedAt: number,\n options: UseCountdownOptions = {},\n): number {\n const { tickMs = 1000 } = options;\n\n const compute = useCallback(\n () => Math.max(0, durationMs - (Date.now() - startedAt)),\n [durationMs, startedAt],\n );\n\n const [remaining, setRemaining] = useState(compute);\n\n useEffect(() => {\n setRemaining(compute());\n }, [compute]);\n\n useInterval(() => setRemaining(compute()), remaining > 0 ? tickMs : null);\n\n return remaining;\n}\n"],"mappings":";;;AAqCA,SAAgB,EACZ,GACA,GACA,IAA+B,CAAC,GAC1B;CACN,IAAM,EAAE,YAAS,QAAS,GAEpB,IAAU,QACN,KAAK,IAAI,GAAG,KAAc,KAAK,IAAI,IAAI,EAAU,GACvD,CAAC,GAAY,CAAS,CAC1B,GAEM,CAAC,GAAW,KAAgB,EAAS,CAAO;CAQlD,OANA,QAAgB;EACZ,EAAa,EAAQ,CAAC;CAC1B,GAAG,CAAC,CAAO,CAAC,GAEZ,QAAkB,EAAa,EAAQ,CAAC,GAAG,IAAY,IAAI,IAAS,IAAI,GAEjE;AACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-latest-ref.cjs");let t=require("react");function n(n,r,i,a){let o=e.useLatestRef(r);(0,t.useEffect)(()=>{let e=i===void 0?typeof window>`u`?null:window:`current`in i?i.current??null:i;if(!e?.addEventListener)return;let t=e=>o.current(e);return e.addEventListener(n,t,a),()=>e.removeEventListener(n,t,a)},[n,i,a,o])}exports.useEventListener=n;
|
|
2
2
|
//# sourceMappingURL=use-event-listener.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-listener.cjs","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-event-listener.cjs","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n *\n * @tempest-limits param-count — deliberately the same positional shape as\n * `addEventListener(type, listener, options)`, with the target inserted where React\n * needs it. A hook that mirrors a DOM API is read by everyone who already knows the\n * DOM API; a bespoke options bag would make the familiar call unfamiliar.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useLatestRef(handler);\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options, handlerRef]);\n}\n"],"mappings":"+DAqCA,SAAgB,EACZ,EACA,EACA,EACA,EACI,CACJ,IAAM,EAAa,EAAA,aAAa,CAAO,GAEvC,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EACF,IAAW,IAAA,GACL,OAAO,OAAW,IACd,KACA,OACJ,YAAc,EACV,EAA2C,SAAW,KACvD,EAEb,GAAI,CAAC,GAAgB,iBAAkB,OAEvC,IAAM,EAA2B,GAAU,EAAW,QAAQ,CAAK,EAEnE,OADA,EAAe,iBAAiB,EAAW,EAAU,CAAO,MAC/C,EAAe,oBAAoB,EAAW,EAAU,CAAO,CAChF,EAAG,CAAC,EAAW,EAAQ,EAAS,CAAU,CAAC,CAC/C"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
2
3
|
//#region src/hooks/use-event-listener.ts
|
|
3
4
|
function n(n, r, i, a) {
|
|
4
|
-
let o =
|
|
5
|
-
|
|
6
|
-
o.current = r;
|
|
7
|
-
}, [r]), e(() => {
|
|
5
|
+
let o = e(r);
|
|
6
|
+
t(() => {
|
|
8
7
|
let e = i === void 0 ? typeof window > "u" ? null : window : "current" in i ? i.current ?? null : i;
|
|
9
8
|
if (!e?.addEventListener) return;
|
|
10
9
|
let t = (e) => o.current(e);
|
|
@@ -12,7 +11,8 @@ function n(n, r, i, a) {
|
|
|
12
11
|
}, [
|
|
13
12
|
n,
|
|
14
13
|
i,
|
|
15
|
-
a
|
|
14
|
+
a,
|
|
15
|
+
o
|
|
16
16
|
]);
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-listener.js","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-event-listener.js","names":[],"sources":["../../src/hooks/use-event-listener.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\ntype AnyEventTarget = EventTarget | { current: EventTarget | null } | null | undefined;\n\n/**\n * Subscribe to a DOM event with React-friendly semantics.\n *\n * - Handler is stored in a ref so callers can pass inline functions without\n * resubscribing on every render.\n * - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,\n * element) OR a ref pointing at one.\n * - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.\n *\n * @tempest-limits param-count — deliberately the same positional shape as\n * `addEventListener(type, listener, options)`, with the target inserted where React\n * needs it. A hook that mirrors a DOM API is read by everyone who already knows the\n * DOM API; a bespoke options bag would make the familiar call unfamiliar.\n */\nexport function useEventListener<K extends keyof WindowEventMap>(\n eventName: K,\n handler: (event: WindowEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof DocumentEventMap>(\n eventName: K,\n handler: (event: DocumentEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener<K extends keyof HTMLElementEventMap>(\n eventName: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void;\nexport function useEventListener(\n eventName: string,\n handler: (event: Event) => void,\n target?: AnyEventTarget,\n options?: AddEventListenerOptions | boolean,\n): void {\n const handlerRef = useLatestRef(handler);\n\n useEffect(() => {\n const resolvedTarget: EventTarget | null =\n target === undefined\n ? typeof window === \"undefined\"\n ? null\n : window\n : \"current\" in (target as { current: unknown })\n ? ((target as { current: EventTarget | null }).current ?? null)\n : (target as EventTarget | null);\n\n if (!resolvedTarget?.addEventListener) return;\n\n const listener: EventListener = (event) => handlerRef.current(event);\n resolvedTarget.addEventListener(eventName, listener, options);\n return () => resolvedTarget.removeEventListener(eventName, listener, options);\n }, [eventName, target, options, handlerRef]);\n}\n"],"mappings":";;;AAqCA,SAAgB,EACZ,GACA,GACA,GACA,GACI;CACJ,IAAM,IAAa,EAAa,CAAO;CAEvC,QAAgB;EACZ,IAAM,IACF,MAAW,KAAA,IACL,OAAO,SAAW,MACd,OACA,SACJ,aAAc,IACV,EAA2C,WAAW,OACvD;EAEb,IAAI,CAAC,GAAgB,kBAAkB;EAEvC,IAAM,KAA2B,MAAU,EAAW,QAAQ,CAAK;EAEnE,OADA,EAAe,iBAAiB,GAAW,GAAU,CAAO,SAC/C,EAAe,oBAAoB,GAAW,GAAU,CAAO;CAChF,GAAG;EAAC;EAAW;EAAQ;EAAS;CAAU,CAAC;AAC/C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-latest-ref.cjs");let t=require("react");function n(n,r){let i=e.useLatestRef(n);(0,t.useEffect)(()=>{if(r===null)return;let e=setInterval(()=>i.current(),r);return()=>clearInterval(e)},[r,i])}exports.useInterval=n;
|
|
2
2
|
//# sourceMappingURL=use-interval.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interval.cjs","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-interval.cjs","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useLatestRef(fn);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay, fnRef]);\n}\n"],"mappings":"+DAUA,SAAgB,EAAY,EAAgB,EAA4B,CACpE,IAAM,EAAQ,EAAA,aAAa,CAAE,GAE7B,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,IAAU,KAAM,OACpB,IAAM,EAAK,gBAAkB,EAAM,QAAQ,EAAG,CAAK,EACnD,UAAa,cAAc,CAAE,CACjC,EAAG,CAAC,EAAO,CAAK,CAAC,CACrB"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
2
3
|
//#region src/hooks/use-interval.ts
|
|
3
4
|
function n(n, r) {
|
|
4
|
-
let i =
|
|
5
|
-
|
|
6
|
-
i.current = n;
|
|
7
|
-
}, [n]), e(() => {
|
|
5
|
+
let i = e(n);
|
|
6
|
+
t(() => {
|
|
8
7
|
if (r === null) return;
|
|
9
8
|
let e = setInterval(() => i.current(), r);
|
|
10
9
|
return () => clearInterval(e);
|
|
11
|
-
}, [r]);
|
|
10
|
+
}, [r, i]);
|
|
12
11
|
}
|
|
13
12
|
//#endregion
|
|
14
13
|
export { n as useInterval };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-interval.js","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-interval.js","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\n/**\n * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in\n * a ref so inline callbacks don't reset the interval on every render.\n *\n * @example\n * useInterval(() => poll(), enabled ? 5000 : null);\n */\nexport function useInterval(fn: () => void, delay: number | null): void {\n const fnRef = useLatestRef(fn);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(() => fnRef.current(), delay);\n return () => clearInterval(id);\n }, [delay, fnRef]);\n}\n"],"mappings":";;;AAUA,SAAgB,EAAY,GAAgB,GAA4B;CACpE,IAAM,IAAQ,EAAa,CAAE;CAE7B,QAAgB;EACZ,IAAI,MAAU,MAAM;EACpB,IAAM,IAAK,kBAAkB,EAAM,QAAQ,GAAG,CAAK;EACnD,aAAa,cAAc,CAAE;CACjC,GAAG,CAAC,GAAO,CAAK,CAAC;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-latest-ref.cjs","names":[],"sources":["../../src/hooks/use-latest-ref.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- writing at render time is deliberate; an effect would add a staleness window (see the docstring) */\nimport { useRef, type RefObject } from \"react\";\n\n/**\n * Keeps a ref pointing at the most recent value it was given.\n *\n * The escape hatch for reading fresh state inside something that must not be\n * re-created when that state changes: an interval, a subscription, an event\n * listener registered once on mount. Listing the value in the effect's\n * dependencies would tear the effect down and set it back up on every change;\n * omitting it captures the value from the render that created the closure and\n * never sees another. The ref is neither — a stable object whose `current` is\n * always current.\n *\n * The assignment happens **during render**, for the same reason\n * {@link useStableCallback} does it: moving it into an effect opens a\n * one-commit staleness window, where an effect declared earlier in the same\n * commit reads the previous render's value.\n *\n * Reach for {@link useStableCallback} instead when the value is a function you\n * want to *call* — it hands back a callable with a stable identity, rather than\n * making every call site reach through `.current`.\n *\n * @typeParam T - The tracked value.\n * @param value - The value to track. Written on every render.\n * @returns A stable ref whose `current` holds the latest `value`.\n *\n * @example\n * const optionsRef = useLatestRef(options);\n *\n * useEffect(() => {\n * const id = setInterval(() => poll(optionsRef.current), 5_000);\n * return () => clearInterval(id);\n * }, []); // the interval survives every options change, and still reads the latest\n */\nexport function useLatestRef<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-latest-ref.cjs","names":[],"sources":["../../src/hooks/use-latest-ref.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- writing at render time is deliberate; an effect would add a staleness window (see the docstring) */\nimport { useRef, type RefObject } from \"react\";\n\n/**\n * Keeps a ref pointing at the most recent value it was given.\n *\n * The escape hatch for reading fresh state inside something that must not be\n * re-created when that state changes: an interval, a subscription, an event\n * listener registered once on mount. Listing the value in the effect's\n * dependencies would tear the effect down and set it back up on every change;\n * omitting it captures the value from the render that created the closure and\n * never sees another. The ref is neither — a stable object whose `current` is\n * always current.\n *\n * The assignment happens **during render**, for the same reason\n * {@link useStableCallback} does it: moving it into an effect opens a\n * one-commit staleness window, where an effect declared earlier in the same\n * commit reads the previous render's value.\n *\n * Reach for {@link useStableCallback} instead when the value is a function you\n * want to *call* — it hands back a callable with a stable identity, rather than\n * making every call site reach through `.current`.\n *\n * **List the returned ref in your effect's dependencies.** It is a stable object,\n * so the effect never re-runs because of it, but `react-hooks/exhaustive-deps`\n * cannot prove that for a custom hook the way it does for a bare `useRef`.\n * Listing it lets the rule verify the array instead of taking an omission on\n * trust.\n *\n * **Not for holding the previous value.** The write happens during render, so\n * `.current` is already the current value by the time any effect reads it. A hook\n * that wants the value from the *previous* commit — `usePrevious` — needs the\n * effect-based write, and swapping it for this would make it return the present.\n *\n * @typeParam T - The tracked value.\n * @param value - The value to track. Written on every render.\n * @returns A stable ref whose `current` holds the latest `value`.\n *\n * @example\n * const optionsRef = useLatestRef(options);\n *\n * useEffect(() => {\n * const id = setInterval(() => poll(optionsRef.current), 5_000);\n * return () => clearInterval(id);\n * }, []); // the interval survives every options change, and still reads the latest\n */\nexport function useLatestRef<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n"],"mappings":"uBA8CA,SAAgB,EAAgB,EAAwB,CACpD,IAAM,GAAA,EAAM,EAAA,OAAA,CAAO,CAAK,EAExB,MADA,GAAI,QAAU,EACP,CACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-latest-ref.js","names":[],"sources":["../../src/hooks/use-latest-ref.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- writing at render time is deliberate; an effect would add a staleness window (see the docstring) */\nimport { useRef, type RefObject } from \"react\";\n\n/**\n * Keeps a ref pointing at the most recent value it was given.\n *\n * The escape hatch for reading fresh state inside something that must not be\n * re-created when that state changes: an interval, a subscription, an event\n * listener registered once on mount. Listing the value in the effect's\n * dependencies would tear the effect down and set it back up on every change;\n * omitting it captures the value from the render that created the closure and\n * never sees another. The ref is neither — a stable object whose `current` is\n * always current.\n *\n * The assignment happens **during render**, for the same reason\n * {@link useStableCallback} does it: moving it into an effect opens a\n * one-commit staleness window, where an effect declared earlier in the same\n * commit reads the previous render's value.\n *\n * Reach for {@link useStableCallback} instead when the value is a function you\n * want to *call* — it hands back a callable with a stable identity, rather than\n * making every call site reach through `.current`.\n *\n * @typeParam T - The tracked value.\n * @param value - The value to track. Written on every render.\n * @returns A stable ref whose `current` holds the latest `value`.\n *\n * @example\n * const optionsRef = useLatestRef(options);\n *\n * useEffect(() => {\n * const id = setInterval(() => poll(optionsRef.current), 5_000);\n * return () => clearInterval(id);\n * }, []); // the interval survives every options change, and still reads the latest\n */\nexport function useLatestRef<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use-latest-ref.js","names":[],"sources":["../../src/hooks/use-latest-ref.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- writing at render time is deliberate; an effect would add a staleness window (see the docstring) */\nimport { useRef, type RefObject } from \"react\";\n\n/**\n * Keeps a ref pointing at the most recent value it was given.\n *\n * The escape hatch for reading fresh state inside something that must not be\n * re-created when that state changes: an interval, a subscription, an event\n * listener registered once on mount. Listing the value in the effect's\n * dependencies would tear the effect down and set it back up on every change;\n * omitting it captures the value from the render that created the closure and\n * never sees another. The ref is neither — a stable object whose `current` is\n * always current.\n *\n * The assignment happens **during render**, for the same reason\n * {@link useStableCallback} does it: moving it into an effect opens a\n * one-commit staleness window, where an effect declared earlier in the same\n * commit reads the previous render's value.\n *\n * Reach for {@link useStableCallback} instead when the value is a function you\n * want to *call* — it hands back a callable with a stable identity, rather than\n * making every call site reach through `.current`.\n *\n * **List the returned ref in your effect's dependencies.** It is a stable object,\n * so the effect never re-runs because of it, but `react-hooks/exhaustive-deps`\n * cannot prove that for a custom hook the way it does for a bare `useRef`.\n * Listing it lets the rule verify the array instead of taking an omission on\n * trust.\n *\n * **Not for holding the previous value.** The write happens during render, so\n * `.current` is already the current value by the time any effect reads it. A hook\n * that wants the value from the *previous* commit — `usePrevious` — needs the\n * effect-based write, and swapping it for this would make it return the present.\n *\n * @typeParam T - The tracked value.\n * @param value - The value to track. Written on every render.\n * @returns A stable ref whose `current` holds the latest `value`.\n *\n * @example\n * const optionsRef = useLatestRef(options);\n *\n * useEffect(() => {\n * const id = setInterval(() => poll(optionsRef.current), 5_000);\n * return () => clearInterval(id);\n * }, []); // the interval survives every options change, and still reads the latest\n */\nexport function useLatestRef<T>(value: T): RefObject<T> {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n"],"mappings":";;AA8CA,SAAgB,EAAgB,GAAwB;CACpD,IAAM,IAAM,EAAO,CAAK;CAExB,OADA,EAAI,UAAU,GACP;AACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-latest-ref.cjs");let t=require("react");function n(n,r={}){let{delayMs:i=500,disabled:a=!1}=r,o=(0,t.useRef)(null),s=(0,t.useRef)(!1),c=e.useLatestRef(n),l=(0,t.useCallback)(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),u=(0,t.useCallback)(()=>{a||(s.current=!1,l(),o.current=window.setTimeout(()=>{s.current=!0,c.current()},i))},[a,l,i,c]);return{onMouseDown:u,onMouseUp:l,onMouseLeave:l,onTouchStart:u,onTouchEnd:l,onTouchMove:l,onContextMenu:(0,t.useCallback)(e=>{a||(e.preventDefault(),s.current=!0,c.current())},[a,c]),wasLongPress:()=>s.current}}exports.useLongPressHandlers=n;
|
|
2
2
|
//# sourceMappingURL=use-long-press-handlers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-long-press-handlers.cjs","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback,
|
|
1
|
+
{"version":3,"file":"use-long-press-handlers.cjs","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from \"react\";\n\n/**\n * DOM event handlers produced by {@link useLongPressHandlers}, ready to spread\n * onto a JSX element (`<div {...handlers}>`).\n */\nexport interface LongPressHandlers {\n /** Starts the hold timer on mouse press. */\n onMouseDown: (event: ReactMouseEvent) => void;\n /** Cancels the pending hold when the mouse is released. */\n onMouseUp: () => void;\n /** Cancels the pending hold when the pointer leaves the element. */\n onMouseLeave: () => void;\n /** Starts the hold timer on touch start. */\n onTouchStart: (event: ReactTouchEvent) => void;\n /** Cancels the pending hold when the touch ends. */\n onTouchEnd: () => void;\n /** Cancels the pending hold when the finger moves. */\n onTouchMove: () => void;\n /** Fires the long-press immediately (desktop right-click parity). */\n onContextMenu: (event: ReactMouseEvent) => void;\n}\n\n/** Options accepted by {@link useLongPressHandlers}. */\nexport interface UseLongPressHandlersOptions {\n /** Hold duration in ms before `onLongPress` fires. Defaults to `500`. */\n delayMs?: number;\n /** When `true`, the hook is inert and every handler is a no-op. */\n disabled?: boolean;\n}\n\n/** Return shape of {@link useLongPressHandlers}. */\nexport type UseLongPressHandlersResult = LongPressHandlers & {\n /**\n * Reads whether the most recent interaction fired a long-press. Use it in\n * the element's `onClick` to suppress the click that follows a long-press.\n */\n wasLongPress: () => boolean;\n};\n\n/**\n * Returns DOM event handlers that detect a long press (touch or mouse hold)\n * and invoke `onLongPress` once after `delayMs`.\n *\n * Cancels on touch movement or pointer release. Also wires `contextmenu` to\n * fire `onLongPress` immediately so a right-click on desktop opens selection\n * mode the same way an Android long-press does on mobile.\n *\n * The hook does not `preventDefault` on the underlying click — the consumer\n * decides whether the subsequent click should still fire. Track that with the\n * returned `wasLongPress()` guard to tell \"long-press fired\" apart from a\n * \"regular click\".\n *\n * Unlike {@link useLongPress}, which attaches pointer listeners to a `ref`,\n * this variant returns handler props you spread directly onto an element and\n * exposes a `wasLongPress()` guard.\n *\n * @param onLongPress - Callback invoked once the hold threshold is reached.\n * @param options - Optional `delayMs` and `disabled` flags.\n * @returns The spreadable handlers plus a `wasLongPress()` guard.\n *\n * @example\n * const longPress = useLongPressHandlers(() => enterSelectionMode(), { delayMs: 600 });\n * <button {...longPress} onClick={() => { if (!longPress.wasLongPress()) navigate(); }}>\n * Item\n * </button>\n */\nexport function useLongPressHandlers(\n onLongPress: () => void,\n options: UseLongPressHandlersOptions = {},\n): UseLongPressHandlersResult {\n const { delayMs = 500, disabled = false } = options;\n const timerRef = useRef<number | null>(null);\n const firedRef = useRef<boolean>(false);\n const callbackRef = useLatestRef(onLongPress);\n\n const clear = useCallback((): void => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n }, []);\n\n const start = useCallback((): void => {\n if (disabled) return;\n firedRef.current = false;\n clear();\n timerRef.current = window.setTimeout(() => {\n firedRef.current = true;\n callbackRef.current();\n }, delayMs);\n }, [disabled, clear, delayMs, callbackRef]);\n\n const onContextMenu = useCallback(\n (event: ReactMouseEvent): void => {\n if (disabled) return;\n event.preventDefault();\n firedRef.current = true;\n callbackRef.current();\n },\n [disabled, callbackRef],\n );\n\n return {\n onMouseDown: start,\n onMouseUp: clear,\n onMouseLeave: clear,\n onTouchStart: start,\n onTouchEnd: clear,\n onTouchMove: clear,\n onContextMenu,\n wasLongPress: () => firedRef.current,\n };\n}\n"],"mappings":"+DAqEA,SAAgB,EACZ,EACA,EAAuC,CAAC,EACd,CAC1B,GAAM,CAAE,UAAU,IAAK,WAAW,IAAU,EACtC,GAAA,EAAW,EAAA,OAAA,CAAsB,IAAI,EACrC,GAAA,EAAW,EAAA,OAAA,CAAgB,EAAK,EAChC,EAAc,EAAA,aAAa,CAAW,EAEtC,GAAA,EAAQ,EAAA,YAAA,KAAwB,CAC9B,EAAS,UAAY,OACrB,OAAO,aAAa,EAAS,OAAO,EACpC,EAAS,QAAU,KAE3B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAQ,EAAA,YAAA,KAAwB,CAC9B,IACJ,EAAS,QAAU,GACnB,EAAM,EACN,EAAS,QAAU,OAAO,eAAiB,CACvC,EAAS,QAAU,GACnB,EAAY,QAAQ,CACxB,EAAG,CAAO,EACd,EAAG,CAAC,EAAU,EAAO,EAAS,CAAW,CAAC,EAY1C,MAAO,CACH,YAAa,EACb,UAAW,EACX,aAAc,EACd,aAAc,EACd,WAAY,EACZ,YAAa,EACb,eAAA,EAjBkB,EAAA,YAAA,CACjB,GAAiC,CAC1B,IACJ,EAAM,eAAe,EACrB,EAAS,QAAU,GACnB,EAAY,QAAQ,EACxB,EACA,CAAC,EAAU,CAAW,CAUtB,EACA,iBAAoB,EAAS,OACjC,CACJ"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useCallback as t, useRef as n } from "react";
|
|
2
3
|
//#region src/hooks/use-long-press-handlers.ts
|
|
3
4
|
function r(r, i = {}) {
|
|
4
|
-
let { delayMs: a = 500, disabled: o = !1 } = i, s = n(null), c = n(!1), l =
|
|
5
|
-
t(() => {
|
|
6
|
-
l.current = r;
|
|
7
|
-
}, [r]);
|
|
8
|
-
let u = e(() => {
|
|
5
|
+
let { delayMs: a = 500, disabled: o = !1 } = i, s = n(null), c = n(!1), l = e(r), u = t(() => {
|
|
9
6
|
s.current !== null && (window.clearTimeout(s.current), s.current = null);
|
|
10
|
-
}, []), d =
|
|
7
|
+
}, []), d = t(() => {
|
|
11
8
|
o || (c.current = !1, u(), s.current = window.setTimeout(() => {
|
|
12
9
|
c.current = !0, l.current();
|
|
13
10
|
}, a));
|
|
14
11
|
}, [
|
|
15
12
|
o,
|
|
16
13
|
u,
|
|
17
|
-
a
|
|
14
|
+
a,
|
|
15
|
+
l
|
|
18
16
|
]);
|
|
19
17
|
return {
|
|
20
18
|
onMouseDown: d,
|
|
@@ -23,9 +21,9 @@ function r(r, i = {}) {
|
|
|
23
21
|
onTouchStart: d,
|
|
24
22
|
onTouchEnd: u,
|
|
25
23
|
onTouchMove: u,
|
|
26
|
-
onContextMenu:
|
|
24
|
+
onContextMenu: t((e) => {
|
|
27
25
|
o || (e.preventDefault(), c.current = !0, l.current());
|
|
28
|
-
}, [o]),
|
|
26
|
+
}, [o, l]),
|
|
29
27
|
wasLongPress: () => c.current
|
|
30
28
|
};
|
|
31
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-long-press-handlers.js","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback,
|
|
1
|
+
{"version":3,"file":"use-long-press-handlers.js","names":[],"sources":["../../src/hooks/use-long-press-handlers.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from \"react\";\n\n/**\n * DOM event handlers produced by {@link useLongPressHandlers}, ready to spread\n * onto a JSX element (`<div {...handlers}>`).\n */\nexport interface LongPressHandlers {\n /** Starts the hold timer on mouse press. */\n onMouseDown: (event: ReactMouseEvent) => void;\n /** Cancels the pending hold when the mouse is released. */\n onMouseUp: () => void;\n /** Cancels the pending hold when the pointer leaves the element. */\n onMouseLeave: () => void;\n /** Starts the hold timer on touch start. */\n onTouchStart: (event: ReactTouchEvent) => void;\n /** Cancels the pending hold when the touch ends. */\n onTouchEnd: () => void;\n /** Cancels the pending hold when the finger moves. */\n onTouchMove: () => void;\n /** Fires the long-press immediately (desktop right-click parity). */\n onContextMenu: (event: ReactMouseEvent) => void;\n}\n\n/** Options accepted by {@link useLongPressHandlers}. */\nexport interface UseLongPressHandlersOptions {\n /** Hold duration in ms before `onLongPress` fires. Defaults to `500`. */\n delayMs?: number;\n /** When `true`, the hook is inert and every handler is a no-op. */\n disabled?: boolean;\n}\n\n/** Return shape of {@link useLongPressHandlers}. */\nexport type UseLongPressHandlersResult = LongPressHandlers & {\n /**\n * Reads whether the most recent interaction fired a long-press. Use it in\n * the element's `onClick` to suppress the click that follows a long-press.\n */\n wasLongPress: () => boolean;\n};\n\n/**\n * Returns DOM event handlers that detect a long press (touch or mouse hold)\n * and invoke `onLongPress` once after `delayMs`.\n *\n * Cancels on touch movement or pointer release. Also wires `contextmenu` to\n * fire `onLongPress` immediately so a right-click on desktop opens selection\n * mode the same way an Android long-press does on mobile.\n *\n * The hook does not `preventDefault` on the underlying click — the consumer\n * decides whether the subsequent click should still fire. Track that with the\n * returned `wasLongPress()` guard to tell \"long-press fired\" apart from a\n * \"regular click\".\n *\n * Unlike {@link useLongPress}, which attaches pointer listeners to a `ref`,\n * this variant returns handler props you spread directly onto an element and\n * exposes a `wasLongPress()` guard.\n *\n * @param onLongPress - Callback invoked once the hold threshold is reached.\n * @param options - Optional `delayMs` and `disabled` flags.\n * @returns The spreadable handlers plus a `wasLongPress()` guard.\n *\n * @example\n * const longPress = useLongPressHandlers(() => enterSelectionMode(), { delayMs: 600 });\n * <button {...longPress} onClick={() => { if (!longPress.wasLongPress()) navigate(); }}>\n * Item\n * </button>\n */\nexport function useLongPressHandlers(\n onLongPress: () => void,\n options: UseLongPressHandlersOptions = {},\n): UseLongPressHandlersResult {\n const { delayMs = 500, disabled = false } = options;\n const timerRef = useRef<number | null>(null);\n const firedRef = useRef<boolean>(false);\n const callbackRef = useLatestRef(onLongPress);\n\n const clear = useCallback((): void => {\n if (timerRef.current !== null) {\n window.clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n }, []);\n\n const start = useCallback((): void => {\n if (disabled) return;\n firedRef.current = false;\n clear();\n timerRef.current = window.setTimeout(() => {\n firedRef.current = true;\n callbackRef.current();\n }, delayMs);\n }, [disabled, clear, delayMs, callbackRef]);\n\n const onContextMenu = useCallback(\n (event: ReactMouseEvent): void => {\n if (disabled) return;\n event.preventDefault();\n firedRef.current = true;\n callbackRef.current();\n },\n [disabled, callbackRef],\n );\n\n return {\n onMouseDown: start,\n onMouseUp: clear,\n onMouseLeave: clear,\n onTouchStart: start,\n onTouchEnd: clear,\n onTouchMove: clear,\n onContextMenu,\n wasLongPress: () => firedRef.current,\n };\n}\n"],"mappings":";;;AAqEA,SAAgB,EACZ,GACA,IAAuC,CAAC,GACd;CAC1B,IAAM,EAAE,aAAU,KAAK,cAAW,OAAU,GACtC,IAAW,EAAsB,IAAI,GACrC,IAAW,EAAgB,EAAK,GAChC,IAAc,EAAa,CAAW,GAEtC,IAAQ,QAAwB;EAClC,AAAI,EAAS,YAAY,SACrB,OAAO,aAAa,EAAS,OAAO,GACpC,EAAS,UAAU;CAE3B,GAAG,CAAC,CAAC,GAEC,IAAQ,QAAwB;EAC9B,MACJ,EAAS,UAAU,IACnB,EAAM,GACN,EAAS,UAAU,OAAO,iBAAiB;GAEvC,AADA,EAAS,UAAU,IACnB,EAAY,QAAQ;EACxB,GAAG,CAAO;CACd,GAAG;EAAC;EAAU;EAAO;EAAS;CAAW,CAAC;CAY1C,OAAO;EACH,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,aAAa;EACb,eAjBkB,GACjB,MAAiC;GAC1B,MACJ,EAAM,eAAe,GACrB,EAAS,UAAU,IACnB,EAAY,QAAQ;EACxB,GACA,CAAC,GAAU,CAAW,CAUtB;EACA,oBAAoB,EAAS;CACjC;AACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-latest-ref.cjs");let t=require("react");function n(n,r,i={}){let{delay:a=500,moveThreshold:o=10}=i,s=e.useLatestRef(r);(0,t.useEffect)(()=>{let e=n.current;if(!e)return;let t=null,r=0,i=0,c=()=>{t&&=(clearTimeout(t),null)},l=e=>{r=e.clientX,i=e.clientY,c(),t=setTimeout(()=>{t=null,s.current()},a)},u=e=>{if(t===null)return;let n=e.clientX-r,a=e.clientY-i;Math.hypot(n,a)>o&&c()};return e.addEventListener(`pointerdown`,l),e.addEventListener(`pointermove`,u),e.addEventListener(`pointerup`,c),e.addEventListener(`pointercancel`,c),e.addEventListener(`pointerleave`,c),()=>{c(),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`pointermove`,u),e.removeEventListener(`pointerup`,c),e.removeEventListener(`pointercancel`,c),e.removeEventListener(`pointerleave`,c)}},[n,a,o,s])}exports.useLongPress=n;
|
|
2
2
|
//# sourceMappingURL=use-long-press.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-long-press.cjs","names":[],"sources":["../../src/hooks/use-long-press.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-long-press.cjs","names":[],"sources":["../../src/hooks/use-long-press.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { RefObject } from \"react\";\n\nexport interface UseLongPressOptions {\n /** Press duration in ms. Default `500`. */\n delay?: number;\n /** Pixel threshold — finger/mouse movement beyond this cancels the press. Default `10`. */\n moveThreshold?: number;\n}\n\n/**\n * Detect long-press / long-tap gestures. Fires `fn` after `delay` ms\n * while the element is held. Cancels on move beyond `moveThreshold` or\n * pointer up before `delay`.\n *\n * @example\n * const ref = useRef<HTMLDivElement>(null);\n * useLongPress(ref, () => openContextMenu(), { delay: 600 });\n */\nexport function useLongPress<T extends HTMLElement>(\n ref: RefObject<T | null>,\n fn: () => void,\n options: UseLongPressOptions = {},\n): void {\n const { delay = 500, moveThreshold = 10 } = options;\n const fnRef = useLatestRef(fn);\n\n useEffect(() => {\n const node = ref.current;\n if (!node) return;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let startX = 0;\n let startY = 0;\n\n const cancel = (): void => {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n };\n\n const onDown = (event: PointerEvent): void => {\n startX = event.clientX;\n startY = event.clientY;\n cancel();\n timer = setTimeout(() => {\n timer = null;\n fnRef.current();\n }, delay);\n };\n\n const onMove = (event: PointerEvent): void => {\n if (timer === null) return;\n const dx = event.clientX - startX;\n const dy = event.clientY - startY;\n if (Math.hypot(dx, dy) > moveThreshold) cancel();\n };\n\n node.addEventListener(\"pointerdown\", onDown);\n node.addEventListener(\"pointermove\", onMove);\n node.addEventListener(\"pointerup\", cancel);\n node.addEventListener(\"pointercancel\", cancel);\n node.addEventListener(\"pointerleave\", cancel);\n return () => {\n cancel();\n node.removeEventListener(\"pointerdown\", onDown);\n node.removeEventListener(\"pointermove\", onMove);\n node.removeEventListener(\"pointerup\", cancel);\n node.removeEventListener(\"pointercancel\", cancel);\n node.removeEventListener(\"pointerleave\", cancel);\n };\n }, [ref, delay, moveThreshold, fnRef]);\n}\n"],"mappings":"+DAoBA,SAAgB,EACZ,EACA,EACA,EAA+B,CAAC,EAC5B,CACJ,GAAM,CAAE,QAAQ,IAAK,gBAAgB,IAAO,EACtC,EAAQ,EAAA,aAAa,CAAE,GAE7B,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAO,EAAI,QACjB,GAAI,CAAC,EAAM,OACX,IAAI,EAA8C,KAC9C,EAAS,EACT,EAAS,EAEP,MAAqB,CACvB,AAEI,KADA,aAAa,CAAK,EACV,KAEhB,EAEM,EAAU,GAA8B,CAC1C,EAAS,EAAM,QACf,EAAS,EAAM,QACf,EAAO,EACP,EAAQ,eAAiB,CACrB,EAAQ,KACR,EAAM,QAAQ,CAClB,EAAG,CAAK,CACZ,EAEM,EAAU,GAA8B,CAC1C,GAAI,IAAU,KAAM,OACpB,IAAM,EAAK,EAAM,QAAU,EACrB,EAAK,EAAM,QAAU,EACvB,KAAK,MAAM,EAAI,CAAE,EAAI,GAAe,EAAO,CACnD,EAOA,OALA,EAAK,iBAAiB,cAAe,CAAM,EAC3C,EAAK,iBAAiB,cAAe,CAAM,EAC3C,EAAK,iBAAiB,YAAa,CAAM,EACzC,EAAK,iBAAiB,gBAAiB,CAAM,EAC7C,EAAK,iBAAiB,eAAgB,CAAM,MAC/B,CACT,EAAO,EACP,EAAK,oBAAoB,cAAe,CAAM,EAC9C,EAAK,oBAAoB,cAAe,CAAM,EAC9C,EAAK,oBAAoB,YAAa,CAAM,EAC5C,EAAK,oBAAoB,gBAAiB,CAAM,EAChD,EAAK,oBAAoB,eAAgB,CAAM,CACnD,CACJ,EAAG,CAAC,EAAK,EAAO,EAAe,CAAK,CAAC,CACzC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
2
3
|
//#region src/hooks/use-long-press.ts
|
|
3
4
|
function n(n, r, i = {}) {
|
|
4
|
-
let { delay: a = 500, moveThreshold: o = 10 } = i, s =
|
|
5
|
-
|
|
6
|
-
s.current = r;
|
|
7
|
-
}, [r]), e(() => {
|
|
5
|
+
let { delay: a = 500, moveThreshold: o = 10 } = i, s = e(r);
|
|
6
|
+
t(() => {
|
|
8
7
|
let e = n.current;
|
|
9
8
|
if (!e) return;
|
|
10
9
|
let t = null, r = 0, i = 0, c = () => {
|
|
@@ -24,7 +23,8 @@ function n(n, r, i = {}) {
|
|
|
24
23
|
}, [
|
|
25
24
|
n,
|
|
26
25
|
a,
|
|
27
|
-
o
|
|
26
|
+
o,
|
|
27
|
+
s
|
|
28
28
|
]);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-long-press.js","names":[],"sources":["../../src/hooks/use-long-press.ts"],"sourcesContent":["import { useEffect
|
|
1
|
+
{"version":3,"file":"use-long-press.js","names":[],"sources":["../../src/hooks/use-long-press.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\nimport type { RefObject } from \"react\";\n\nexport interface UseLongPressOptions {\n /** Press duration in ms. Default `500`. */\n delay?: number;\n /** Pixel threshold — finger/mouse movement beyond this cancels the press. Default `10`. */\n moveThreshold?: number;\n}\n\n/**\n * Detect long-press / long-tap gestures. Fires `fn` after `delay` ms\n * while the element is held. Cancels on move beyond `moveThreshold` or\n * pointer up before `delay`.\n *\n * @example\n * const ref = useRef<HTMLDivElement>(null);\n * useLongPress(ref, () => openContextMenu(), { delay: 600 });\n */\nexport function useLongPress<T extends HTMLElement>(\n ref: RefObject<T | null>,\n fn: () => void,\n options: UseLongPressOptions = {},\n): void {\n const { delay = 500, moveThreshold = 10 } = options;\n const fnRef = useLatestRef(fn);\n\n useEffect(() => {\n const node = ref.current;\n if (!node) return;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let startX = 0;\n let startY = 0;\n\n const cancel = (): void => {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n };\n\n const onDown = (event: PointerEvent): void => {\n startX = event.clientX;\n startY = event.clientY;\n cancel();\n timer = setTimeout(() => {\n timer = null;\n fnRef.current();\n }, delay);\n };\n\n const onMove = (event: PointerEvent): void => {\n if (timer === null) return;\n const dx = event.clientX - startX;\n const dy = event.clientY - startY;\n if (Math.hypot(dx, dy) > moveThreshold) cancel();\n };\n\n node.addEventListener(\"pointerdown\", onDown);\n node.addEventListener(\"pointermove\", onMove);\n node.addEventListener(\"pointerup\", cancel);\n node.addEventListener(\"pointercancel\", cancel);\n node.addEventListener(\"pointerleave\", cancel);\n return () => {\n cancel();\n node.removeEventListener(\"pointerdown\", onDown);\n node.removeEventListener(\"pointermove\", onMove);\n node.removeEventListener(\"pointerup\", cancel);\n node.removeEventListener(\"pointercancel\", cancel);\n node.removeEventListener(\"pointerleave\", cancel);\n };\n }, [ref, delay, moveThreshold, fnRef]);\n}\n"],"mappings":";;;AAoBA,SAAgB,EACZ,GACA,GACA,IAA+B,CAAC,GAC5B;CACJ,IAAM,EAAE,WAAQ,KAAK,mBAAgB,OAAO,GACtC,IAAQ,EAAa,CAAE;CAE7B,QAAgB;EACZ,IAAM,IAAO,EAAI;EACjB,IAAI,CAAC,GAAM;EACX,IAAI,IAA8C,MAC9C,IAAS,GACT,IAAS,GAEP,UAAqB;GACvB,AAEI,OADA,aAAa,CAAK,GACV;EAEhB,GAEM,KAAU,MAA8B;GAI1C,AAHA,IAAS,EAAM,SACf,IAAS,EAAM,SACf,EAAO,GACP,IAAQ,iBAAiB;IAErB,AADA,IAAQ,MACR,EAAM,QAAQ;GAClB,GAAG,CAAK;EACZ,GAEM,KAAU,MAA8B;GAC1C,IAAI,MAAU,MAAM;GACpB,IAAM,IAAK,EAAM,UAAU,GACrB,IAAK,EAAM,UAAU;GAC3B,AAAI,KAAK,MAAM,GAAI,CAAE,IAAI,KAAe,EAAO;EACnD;EAOA,OALA,EAAK,iBAAiB,eAAe,CAAM,GAC3C,EAAK,iBAAiB,eAAe,CAAM,GAC3C,EAAK,iBAAiB,aAAa,CAAM,GACzC,EAAK,iBAAiB,iBAAiB,CAAM,GAC7C,EAAK,iBAAiB,gBAAgB,CAAM,SAC/B;GAMT,AALA,EAAO,GACP,EAAK,oBAAoB,eAAe,CAAM,GAC9C,EAAK,oBAAoB,eAAe,CAAM,GAC9C,EAAK,oBAAoB,aAAa,CAAM,GAC5C,EAAK,oBAAoB,iBAAiB,CAAM,GAChD,EAAK,oBAAoB,gBAAgB,CAAM;EACnD;CACJ,GAAG;EAAC;EAAK;EAAO;EAAe;CAAK,CAAC;AACzC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./use-latest-ref.cjs");let t=require("react");function n(n={}){let{pingUrl:r,intervalMs:i=3e4,timeoutMs:a=5e3}=n,[o,s]=(0,t.useState)(()=>typeof navigator>`u`||navigator.onLine),[c,l]=(0,t.useState)(!0),u=e.useLatestRef({pingUrl:r,timeoutMs:a});return(0,t.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>s(!0),t=()=>s(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)}},[]),(0,t.useEffect)(()=>{if(!r||typeof window>`u`)return;let e=!1,t=async()=>{if(typeof navigator<`u`&&!navigator.onLine){e||l(!1);return}let t=new AbortController,n=window.setTimeout(()=>t.abort(),u.current.timeoutMs);try{await fetch(u.current.pingUrl,{method:`HEAD`,cache:`no-store`,signal:t.signal}),e||l(!0)}catch{e||l(!1)}finally{window.clearTimeout(n)}};t();let n=window.setInterval(()=>void t(),i),a=()=>void t();return window.addEventListener(`online`,a),document.addEventListener(`visibilitychange`,a),()=>{e=!0,window.clearInterval(n),window.removeEventListener(`online`,a),document.removeEventListener(`visibilitychange`,a)}},[r,i,u]),r?o&&c:o}exports.useOnline=n;
|
|
2
2
|
//# sourceMappingURL=use-online.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-online.cjs","names":[],"sources":["../../src/hooks/use-online.ts"],"sourcesContent":["import { useEffect,
|
|
1
|
+
{"version":3,"file":"use-online.cjs","names":[],"sources":["../../src/hooks/use-online.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\n/**\n * Options for {@link useOnline}. Omit them for the cheap `navigator.onLine`\n * behaviour; pass `pingUrl` to add a real-reachability probe on top.\n */\nexport interface UseOnlineOptions {\n /**\n * URL to probe for real connectivity. `navigator.onLine` reports `true`\n * behind a captive portal or when the machine has a link but no internet;\n * a periodic `HEAD` to this URL catches those cases. When set, the result\n * is `navigator.onLine && lastProbeSucceeded`.\n */\n pingUrl?: string;\n /** How often to probe, in ms. Default `30000`. */\n intervalMs?: number;\n /** Abort a probe after this many ms and treat it as offline. Default `5000`. */\n timeoutMs?: number;\n}\n\n/**\n * Track connectivity and re-render on changes.\n *\n * With no options it mirrors `navigator.onLine` (assuming online during SSR and\n * before the first event). Pass `pingUrl` to additionally probe real\n * reachability — the browser's `onLine` flag lies behind captive portals and\n * dead links, so the probe downgrades the result to `false` when the network is\n * unusable even though `navigator.onLine` is `true`.\n *\n * @param options - Optional reachability-probe configuration.\n * @returns `true` when the device is online (and reachable, when probing).\n *\n * @example\n * const online = useOnline(); // navigator.onLine only\n * const reallyOnline = useOnline({ pingUrl: \"/health\", intervalMs: 15_000 });\n */\nexport function useOnline(options: UseOnlineOptions = {}): boolean {\n const { pingUrl, intervalMs = 30_000, timeoutMs = 5_000 } = options;\n\n const [navOnline, setNavOnline] = useState<boolean>(() =>\n typeof navigator === \"undefined\" ? true : navigator.onLine,\n );\n const [reachable, setReachable] = useState<boolean>(true);\n\n const optionsRef = useLatestRef({ pingUrl, timeoutMs });\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const handleOnline = (): void => setNavOnline(true);\n const handleOffline = (): void => setNavOnline(false);\n window.addEventListener(\"online\", handleOnline);\n window.addEventListener(\"offline\", handleOffline);\n return () => {\n window.removeEventListener(\"online\", handleOnline);\n window.removeEventListener(\"offline\", handleOffline);\n };\n }, []);\n\n useEffect(() => {\n if (!pingUrl || typeof window === \"undefined\") return;\n\n let cancelled = false;\n const probe = async (): Promise<void> => {\n if (typeof navigator !== \"undefined\" && !navigator.onLine) {\n if (!cancelled) setReachable(false);\n return;\n }\n const controller = new AbortController();\n const timer = window.setTimeout(() => controller.abort(), optionsRef.current.timeoutMs);\n try {\n await fetch(optionsRef.current.pingUrl!, {\n method: \"HEAD\",\n cache: \"no-store\",\n signal: controller.signal,\n });\n if (!cancelled) setReachable(true);\n } catch {\n if (!cancelled) setReachable(false);\n } finally {\n window.clearTimeout(timer);\n }\n };\n\n void probe();\n const id = window.setInterval(() => void probe(), intervalMs);\n const onWake = (): void => void probe();\n window.addEventListener(\"online\", onWake);\n document.addEventListener(\"visibilitychange\", onWake);\n return () => {\n cancelled = true;\n window.clearInterval(id);\n window.removeEventListener(\"online\", onWake);\n document.removeEventListener(\"visibilitychange\", onWake);\n };\n }, [pingUrl, intervalMs, optionsRef]);\n\n return pingUrl ? navOnline && reachable : navOnline;\n}\n"],"mappings":"+DAqCA,SAAgB,EAAU,EAA4B,CAAC,EAAY,CAC/D,GAAM,CAAE,UAAS,aAAa,IAAQ,YAAY,KAAU,EAEtD,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,KAC9B,OAAO,UAAc,KAAqB,UAAU,MACxD,EACM,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAkB,EAAI,EAElD,EAAa,EAAA,aAAa,CAAE,UAAS,WAAU,CAAC,EAoDtD,OAlDA,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,OAAO,OAAW,IAAa,OACnC,IAAM,MAA2B,EAAa,EAAI,EAC5C,MAA4B,EAAa,EAAK,EAGpD,OAFA,OAAO,iBAAiB,SAAU,CAAY,EAC9C,OAAO,iBAAiB,UAAW,CAAa,MACnC,CACT,OAAO,oBAAoB,SAAU,CAAY,EACjD,OAAO,oBAAoB,UAAW,CAAa,CACvD,CACJ,EAAG,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,GAAW,OAAO,OAAW,IAAa,OAE/C,IAAI,EAAY,GACV,EAAQ,SAA2B,CACrC,GAAI,OAAO,UAAc,KAAe,CAAC,UAAU,OAAQ,CAClD,GAAW,EAAa,EAAK,EAClC,MACJ,CACA,IAAM,EAAa,IAAI,gBACjB,EAAQ,OAAO,eAAiB,EAAW,MAAM,EAAG,EAAW,QAAQ,SAAS,EACtF,GAAI,CACA,MAAM,MAAM,EAAW,QAAQ,QAAU,CACrC,OAAQ,OACR,MAAO,WACP,OAAQ,EAAW,MACvB,CAAC,EACI,GAAW,EAAa,EAAI,CACrC,MAAQ,CACC,GAAW,EAAa,EAAK,CACtC,QAAU,CACN,OAAO,aAAa,CAAK,CAC7B,CACJ,EAEA,EAAW,EACX,IAAM,EAAK,OAAO,gBAAkB,KAAK,EAAM,EAAG,CAAU,EACtD,MAAqB,KAAK,EAAM,EAGtC,OAFA,OAAO,iBAAiB,SAAU,CAAM,EACxC,SAAS,iBAAiB,mBAAoB,CAAM,MACvC,CACT,EAAY,GACZ,OAAO,cAAc,CAAE,EACvB,OAAO,oBAAoB,SAAU,CAAM,EAC3C,SAAS,oBAAoB,mBAAoB,CAAM,CAC3D,CACJ,EAAG,CAAC,EAAS,EAAY,CAAU,CAAC,EAE7B,EAAU,GAAa,EAAY,CAC9C"}
|
package/dist/hooks/use-online.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLatestRef as e } from "./use-latest-ref.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
2
3
|
//#region src/hooks/use-online.ts
|
|
3
4
|
function r(r = {}) {
|
|
4
|
-
let { pingUrl: i, intervalMs: a = 3e4, timeoutMs: o = 5e3 } = r, [s, c] = n(() => typeof navigator > "u" || navigator.onLine), [l, u] = n(!0), d =
|
|
5
|
+
let { pingUrl: i, intervalMs: a = 3e4, timeoutMs: o = 5e3 } = r, [s, c] = n(() => typeof navigator > "u" || navigator.onLine), [l, u] = n(!0), d = e({
|
|
5
6
|
pingUrl: i,
|
|
6
7
|
timeoutMs: o
|
|
7
8
|
});
|
|
8
|
-
return
|
|
9
|
-
d.current = {
|
|
10
|
-
pingUrl: i,
|
|
11
|
-
timeoutMs: o
|
|
12
|
-
};
|
|
13
|
-
}, [i, o]), e(() => {
|
|
9
|
+
return t(() => {
|
|
14
10
|
if (typeof window > "u") return;
|
|
15
11
|
let e = () => c(!0), t = () => c(!1);
|
|
16
12
|
return window.addEventListener("online", e), window.addEventListener("offline", t), () => {
|
|
17
13
|
window.removeEventListener("online", e), window.removeEventListener("offline", t);
|
|
18
14
|
};
|
|
19
|
-
}, []),
|
|
15
|
+
}, []), t(() => {
|
|
20
16
|
if (!i || typeof window > "u") return;
|
|
21
17
|
let e = !1, t = async () => {
|
|
22
18
|
if (typeof navigator < "u" && !navigator.onLine) {
|
|
@@ -41,7 +37,11 @@ function r(r = {}) {
|
|
|
41
37
|
return window.addEventListener("online", r), document.addEventListener("visibilitychange", r), () => {
|
|
42
38
|
e = !0, window.clearInterval(n), window.removeEventListener("online", r), document.removeEventListener("visibilitychange", r);
|
|
43
39
|
};
|
|
44
|
-
}, [
|
|
40
|
+
}, [
|
|
41
|
+
i,
|
|
42
|
+
a,
|
|
43
|
+
d
|
|
44
|
+
]), i ? s && l : s;
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
47
|
export { r as useOnline };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-online.js","names":[],"sources":["../../src/hooks/use-online.ts"],"sourcesContent":["import { useEffect,
|
|
1
|
+
{"version":3,"file":"use-online.js","names":[],"sources":["../../src/hooks/use-online.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\n/**\n * Options for {@link useOnline}. Omit them for the cheap `navigator.onLine`\n * behaviour; pass `pingUrl` to add a real-reachability probe on top.\n */\nexport interface UseOnlineOptions {\n /**\n * URL to probe for real connectivity. `navigator.onLine` reports `true`\n * behind a captive portal or when the machine has a link but no internet;\n * a periodic `HEAD` to this URL catches those cases. When set, the result\n * is `navigator.onLine && lastProbeSucceeded`.\n */\n pingUrl?: string;\n /** How often to probe, in ms. Default `30000`. */\n intervalMs?: number;\n /** Abort a probe after this many ms and treat it as offline. Default `5000`. */\n timeoutMs?: number;\n}\n\n/**\n * Track connectivity and re-render on changes.\n *\n * With no options it mirrors `navigator.onLine` (assuming online during SSR and\n * before the first event). Pass `pingUrl` to additionally probe real\n * reachability — the browser's `onLine` flag lies behind captive portals and\n * dead links, so the probe downgrades the result to `false` when the network is\n * unusable even though `navigator.onLine` is `true`.\n *\n * @param options - Optional reachability-probe configuration.\n * @returns `true` when the device is online (and reachable, when probing).\n *\n * @example\n * const online = useOnline(); // navigator.onLine only\n * const reallyOnline = useOnline({ pingUrl: \"/health\", intervalMs: 15_000 });\n */\nexport function useOnline(options: UseOnlineOptions = {}): boolean {\n const { pingUrl, intervalMs = 30_000, timeoutMs = 5_000 } = options;\n\n const [navOnline, setNavOnline] = useState<boolean>(() =>\n typeof navigator === \"undefined\" ? true : navigator.onLine,\n );\n const [reachable, setReachable] = useState<boolean>(true);\n\n const optionsRef = useLatestRef({ pingUrl, timeoutMs });\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const handleOnline = (): void => setNavOnline(true);\n const handleOffline = (): void => setNavOnline(false);\n window.addEventListener(\"online\", handleOnline);\n window.addEventListener(\"offline\", handleOffline);\n return () => {\n window.removeEventListener(\"online\", handleOnline);\n window.removeEventListener(\"offline\", handleOffline);\n };\n }, []);\n\n useEffect(() => {\n if (!pingUrl || typeof window === \"undefined\") return;\n\n let cancelled = false;\n const probe = async (): Promise<void> => {\n if (typeof navigator !== \"undefined\" && !navigator.onLine) {\n if (!cancelled) setReachable(false);\n return;\n }\n const controller = new AbortController();\n const timer = window.setTimeout(() => controller.abort(), optionsRef.current.timeoutMs);\n try {\n await fetch(optionsRef.current.pingUrl!, {\n method: \"HEAD\",\n cache: \"no-store\",\n signal: controller.signal,\n });\n if (!cancelled) setReachable(true);\n } catch {\n if (!cancelled) setReachable(false);\n } finally {\n window.clearTimeout(timer);\n }\n };\n\n void probe();\n const id = window.setInterval(() => void probe(), intervalMs);\n const onWake = (): void => void probe();\n window.addEventListener(\"online\", onWake);\n document.addEventListener(\"visibilitychange\", onWake);\n return () => {\n cancelled = true;\n window.clearInterval(id);\n window.removeEventListener(\"online\", onWake);\n document.removeEventListener(\"visibilitychange\", onWake);\n };\n }, [pingUrl, intervalMs, optionsRef]);\n\n return pingUrl ? navOnline && reachable : navOnline;\n}\n"],"mappings":";;;AAqCA,SAAgB,EAAU,IAA4B,CAAC,GAAY;CAC/D,IAAM,EAAE,YAAS,gBAAa,KAAQ,eAAY,QAAU,GAEtD,CAAC,GAAW,KAAgB,QAC9B,OAAO,YAAc,OAAqB,UAAU,MACxD,GACM,CAAC,GAAW,KAAgB,EAAkB,EAAI,GAElD,IAAa,EAAa;EAAE;EAAS;CAAU,CAAC;CAoDtD,OAlDA,QAAgB;EACZ,IAAI,OAAO,SAAW,KAAa;EACnC,IAAM,UAA2B,EAAa,EAAI,GAC5C,UAA4B,EAAa,EAAK;EAGpD,OAFA,OAAO,iBAAiB,UAAU,CAAY,GAC9C,OAAO,iBAAiB,WAAW,CAAa,SACnC;GAET,AADA,OAAO,oBAAoB,UAAU,CAAY,GACjD,OAAO,oBAAoB,WAAW,CAAa;EACvD;CACJ,GAAG,CAAC,CAAC,GAEL,QAAgB;EACZ,IAAI,CAAC,KAAW,OAAO,SAAW,KAAa;EAE/C,IAAI,IAAY,IACV,IAAQ,YAA2B;GACrC,IAAI,OAAO,YAAc,OAAe,CAAC,UAAU,QAAQ;IACvD,AAAK,KAAW,EAAa,EAAK;IAClC;GACJ;GACA,IAAM,IAAa,IAAI,gBAAgB,GACjC,IAAQ,OAAO,iBAAiB,EAAW,MAAM,GAAG,EAAW,QAAQ,SAAS;GACtF,IAAI;IAMA,AALA,MAAM,MAAM,EAAW,QAAQ,SAAU;KACrC,QAAQ;KACR,OAAO;KACP,QAAQ,EAAW;IACvB,CAAC,GACI,KAAW,EAAa,EAAI;GACrC,QAAQ;IACJ,AAAK,KAAW,EAAa,EAAK;GACtC,UAAU;IACN,OAAO,aAAa,CAAK;GAC7B;EACJ;EAEA,EAAW;EACX,IAAM,IAAK,OAAO,kBAAkB,KAAK,EAAM,GAAG,CAAU,GACtD,UAAqB,KAAK,EAAM;EAGtC,OAFA,OAAO,iBAAiB,UAAU,CAAM,GACxC,SAAS,iBAAiB,oBAAoB,CAAM,SACvC;GAIT,AAHA,IAAY,IACZ,OAAO,cAAc,CAAE,GACvB,OAAO,oBAAoB,UAAU,CAAM,GAC3C,SAAS,oBAAoB,oBAAoB,CAAM;EAC3D;CACJ,GAAG;EAAC;EAAS;EAAY;CAAU,CAAC,GAE7B,IAAU,KAAa,IAAY;AAC9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../sw/register-service-worker.cjs");let
|
|
1
|
+
const e=require("./use-latest-ref.cjs"),t=require("../sw/register-service-worker.cjs");let n=require("react");function r(r){let[i,a]=(0,n.useState)(!1),[o,s]=(0,n.useState)(null),c=(0,n.useRef)(null),l=e.useLatestRef(r);return(0,n.useEffect)(()=>{let e=!1;return t.registerServiceWorker({...l.current,onUpdate:(e,t)=>{c.current=e,s(t),a(!0)},onReady:t=>{e||(s(t),t.waiting&&navigator.serviceWorker.controller&&(c.current=t.waiting,a(!0)),l.current.onReady?.(t))}}).then(t=>{!e&&t&&s(t)}),()=>{e=!0}},[r.url,l]),{updateAvailable:i,applyUpdate:(0,n.useCallback)(()=>{let e=c.current;if(!e||typeof navigator>`u`)return;let n=!1;navigator.serviceWorker.addEventListener(`controllerchange`,()=>{n||(n=!0,window.location.reload())}),t.skipWaiting(e)},[]),registration:o}}exports.useServiceWorkerUpdate=r;
|
|
2
2
|
//# sourceMappingURL=use-service-worker-update.cjs.map
|