@vibehooks/react 0.0.4 → 0.0.6
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/index.d.ts +48 -48
- package/dist/index.js +5 -5
- package/dist/useAsyncState.d.ts +1 -1
- package/dist/useAudio.d.ts +1 -1
- package/dist/useAutoScroll.d.ts +1 -1
- package/dist/useBarcode.d.ts +1 -1
- package/dist/useBatteryStatus.d.ts +1 -1
- package/dist/useBodyScrollFreeze.d.ts +1 -1
- package/dist/useCameraCapture.d.ts +6 -4
- package/dist/useCameraCapture.js +46 -19
- package/dist/useCookies.d.ts +1 -1
- package/dist/useCopyToClipboard.d.ts +1 -1
- package/dist/useCountDown.d.ts +1 -1
- package/dist/useDebouncedState.d.ts +1 -1
- package/dist/useExternalNotifications.d.ts +9 -1
- package/dist/useExternalNotifications.js +1 -1
- package/dist/useFile.d.ts +1 -1
- package/dist/useFullScreen.d.ts +1 -1
- package/dist/useGeolocation.d.ts +1 -1
- package/dist/useHoverIntent.d.ts +1 -1
- package/dist/useIdle.d.ts +1 -1
- package/dist/useIndexedDB.d.ts +1 -1
- package/dist/useIntersectionObserver.d.ts +1 -1
- package/dist/useIntervalSafe.d.ts +1 -1
- package/dist/useList.d.ts +1 -1
- package/dist/useLocalNotifications.d.ts +1 -1
- package/dist/useLocalStorage.d.ts +1 -1
- package/dist/useNetworkInformation.d.ts +1 -1
- package/dist/useOnline.d.ts +1 -1
- package/dist/usePageVisibility.d.ts +7 -1
- package/dist/usePageVisibility.js +1 -1
- package/dist/usePermissions.d.ts +1 -1
- package/dist/usePictureInPicture.d.ts +1 -1
- package/dist/usePopover.d.ts +1 -1
- package/dist/usePreferredLanguage.d.ts +13 -2
- package/dist/usePreferredLanguage.js +1 -1
- package/dist/usePreferredTheme.d.ts +13 -1
- package/dist/usePreferredTheme.js +1 -1
- package/dist/useScreenOrientation.d.ts +1 -1
- package/dist/useScreenSize.d.ts +1 -1
- package/dist/useScreenWakeLock.d.ts +1 -1
- package/dist/useServerSentEvent.d.ts +1 -1
- package/dist/useShoppingCart.d.ts +1 -1
- package/dist/useSmartVideo.d.ts +1 -1
- package/dist/useSpeech.d.ts +1 -1
- package/dist/useSummarizer.d.ts +1 -1
- package/dist/useTaskQueue.d.ts +1 -1
- package/dist/useThrottledCallback.d.ts +1 -1
- package/dist/useTimeout.d.ts +1 -1
- package/dist/useToggle.d.ts +1 -1
- package/dist/useTranslator.d.ts +1 -1
- package/dist/useUserActivation.d.ts +1 -1
- package/dist/useVibration.d.ts +1 -1
- package/dist/useWebsocket.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useAudio } from "./useAudio.js";
|
|
2
|
-
import { useAsyncState } from "./useAsyncState.js";
|
|
3
|
-
import { useAutoScroll } from "./useAutoScroll.js";
|
|
4
|
-
import { useBarcode } from "./useBarcode.js";
|
|
5
|
-
import { useBatteryStatus } from "./useBatteryStatus.js";
|
|
6
|
-
import { useBodyScrollFreeze } from "./useBodyScrollFreeze.js";
|
|
7
|
-
import { useCameraCapture } from "./useCameraCapture.js";
|
|
8
|
-
import { useCookies } from "./useCookies.js";
|
|
9
|
-
import { useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
10
|
-
import { useCountDown } from "./useCountDown.js";
|
|
11
|
-
import { useDebouncedState } from "./useDebouncedState.js";
|
|
12
|
-
import { useExternalNotifications } from "./useExternalNotifications.js";
|
|
13
|
-
import { useGeolocation } from "./useGeolocation.js";
|
|
14
|
-
import { useHoverIntent } from "./useHoverIntent.js";
|
|
15
|
-
import { useFile } from "./useFile.js";
|
|
16
|
-
import { useFullscreen } from "./useFullScreen.js";
|
|
17
|
-
import { useIdle } from "./useIdle.js";
|
|
18
|
-
import { useIndexedDB } from "./useIndexedDB.js";
|
|
19
|
-
import { useIntersectionObserver } from "./useIntersectionObserver.js";
|
|
20
|
-
import { useIntervalSafe } from "./useIntervalSafe.js";
|
|
1
|
+
import { AudioStatus, UseAudioOptions, UseAudioReturn, useAudio } from "./useAudio.js";
|
|
2
|
+
import { AsyncState, FetchConfig, UseAsyncStateOptions, UseAsyncStateReturn, useAsyncState } from "./useAsyncState.js";
|
|
3
|
+
import { UseAutoScrollOptions, useAutoScroll } from "./useAutoScroll.js";
|
|
4
|
+
import { UseBarcodeOptions, UseBarcodeReturn, useBarcode } from "./useBarcode.js";
|
|
5
|
+
import { UseBatteryStatus, UseBatteryStatusReturn, useBatteryStatus } from "./useBatteryStatus.js";
|
|
6
|
+
import { BodyScrollFreezeOptions, BodyScrollFreezeReturn, ScrollAxis, useBodyScrollFreeze } from "./useBodyScrollFreeze.js";
|
|
7
|
+
import { CameraCaptureFormat, CameraCaptureOutput, UseCameraCaptureOptions, UseCameraCaptureReturn, useCameraCapture } from "./useCameraCapture.js";
|
|
8
|
+
import { UseCookieOptions, UseCookieReturn, useCookies } from "./useCookies.js";
|
|
9
|
+
import { CopyToClipboardReturn, useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
10
|
+
import { CountDown, CountDownControlls, CountDownOptions, CountDownReturn, CountDownStatus, useCountDown } from "./useCountDown.js";
|
|
11
|
+
import { UseDebouncedStateOptions, UseDebouncedStateReturn, useDebouncedState } from "./useDebouncedState.js";
|
|
12
|
+
import { NotificationPayload, UseExternalNotificationReturn, notificationStore, useExternalNotifications } from "./useExternalNotifications.js";
|
|
13
|
+
import { GeolocationPermissionState, UseGeolocationReturn, useGeolocation } from "./useGeolocation.js";
|
|
14
|
+
import { UseHoverIntentOptions, UseHoverIntentReturn, useHoverIntent } from "./useHoverIntent.js";
|
|
15
|
+
import { UseFileOptions, UseFileReturn, useFile } from "./useFile.js";
|
|
16
|
+
import { FullScreenReturn, useFullscreen } from "./useFullScreen.js";
|
|
17
|
+
import { UseIdleOptions, UseIdleReturn, useIdle } from "./useIdle.js";
|
|
18
|
+
import { UseIndexedDBOptions, UseIndexedDBTransactionOptions, UseIndexedDBTransactionReturn, useIndexedDB } from "./useIndexedDB.js";
|
|
19
|
+
import { IntersectionObserverOptions, IntersectionObserverReturn, useIntersectionObserver } from "./useIntersectionObserver.js";
|
|
20
|
+
import { UseIntervalOptions, UseIntervalReturn, useIntervalSafe } from "./useIntervalSafe.js";
|
|
21
21
|
import { useIsClient } from "./useIsClient.js";
|
|
22
22
|
import { useIsDesktop } from "./useIsDesktop.js";
|
|
23
23
|
import { useIsFirstRender } from "./useIsFirstRender.js";
|
|
24
|
-
import { useList } from "./useList.js";
|
|
25
|
-
import { useLocalStorage } from "./useLocalStorage.js";
|
|
26
|
-
import { useLocalNotifications } from "./useLocalNotifications.js";
|
|
27
|
-
import { useNetworkInformation } from "./useNetworkInformation.js";
|
|
28
|
-
import { usePageVisibility } from "./usePageVisibility.js";
|
|
29
|
-
import { usePermissions } from "./usePermissions.js";
|
|
30
|
-
import { usePictureInPicture } from "./usePictureInPicture.js";
|
|
31
|
-
import { usePopover } from "./usePopover.js";
|
|
32
|
-
import { usePreferredTheme } from "./usePreferredTheme.js";
|
|
33
|
-
import { usePreferredLanguage } from "./usePreferredLanguage.js";
|
|
24
|
+
import { ListReturn, useList } from "./useList.js";
|
|
25
|
+
import { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from "./useLocalStorage.js";
|
|
26
|
+
import { UseLocalNotificationReturn, UseNotificationOptions, useLocalNotifications } from "./useLocalNotifications.js";
|
|
27
|
+
import { NetworkInformation, NetworkInformationSnapshot, UseNetworkInformationReturn, useNetworkInformation } from "./useNetworkInformation.js";
|
|
28
|
+
import { PageVisibilityReturn, pageVisibilityStore, usePageVisibility } from "./usePageVisibility.js";
|
|
29
|
+
import { PermissionState, PermissionsSnapshot, UsePermissionReturn, usePermissions } from "./usePermissions.js";
|
|
30
|
+
import { UsePictureInPictureReturn, usePictureInPicture } from "./usePictureInPicture.js";
|
|
31
|
+
import { UsePopoverReturn, usePopover } from "./usePopover.js";
|
|
32
|
+
import { PreferredThemeReturn, Theme, systemThemeStore, usePreferredTheme, userThemeStore } from "./usePreferredTheme.js";
|
|
33
|
+
import { PreferredLanguageReturn, systemLanguageStore, usePreferredLanguage, userLanguageStore } from "./usePreferredLanguage.js";
|
|
34
34
|
import { usePreviousDistinct } from "./usePreviousDistinct.js";
|
|
35
35
|
import { useResettableState } from "./useResettableState.js";
|
|
36
|
-
import { useScreenOrientation } from "./useScreenOrientation.js";
|
|
37
|
-
import { useScreenSize } from "./useScreenSize.js";
|
|
38
|
-
import { useScreenWakeLock } from "./useScreenWakeLock.js";
|
|
39
|
-
import { useServerSentEvent } from "./useServerSentEvent.js";
|
|
40
|
-
import { useShoppingCart } from "./useShoppingCart.js";
|
|
41
|
-
import { useSmartVideo } from "./useSmartVideo.js";
|
|
42
|
-
import { useSpeech } from "./useSpeech.js";
|
|
43
|
-
import { useSummarizer } from "./useSummarizer.js";
|
|
44
|
-
import { useTaskQueue } from "./useTaskQueue.js";
|
|
45
|
-
import { useTimeout } from "./useTimeout.js";
|
|
46
|
-
import { useThrottledCallback } from "./useThrottledCallback.js";
|
|
36
|
+
import { UseScreenOrientationReturn, useScreenOrientation } from "./useScreenOrientation.js";
|
|
37
|
+
import { ScreenSizeReturn, useScreenSize } from "./useScreenSize.js";
|
|
38
|
+
import { UseScreenWakeLockReturn, useScreenWakeLock } from "./useScreenWakeLock.js";
|
|
39
|
+
import { SSEReadyState, UseServerSentEventOptions, UseServerSentEventReturn, useServerSentEvent } from "./useServerSentEvent.js";
|
|
40
|
+
import { ShoppingCartItemDetail, UseShoppingCartOptions, UseShoppingCartReturn, useShoppingCart } from "./useShoppingCart.js";
|
|
41
|
+
import { SmartVideoOptions, SmartVideoReturn, useSmartVideo } from "./useSmartVideo.js";
|
|
42
|
+
import { UseSpeechOptions, UseSpeechReturn, useSpeech } from "./useSpeech.js";
|
|
43
|
+
import { BrowserSummarizer, SummarizerAvailability, SummarizerCreateOptions, SummarizerFormat, SummarizerLength, SummarizerStatic, SummarizerType, UseSummarizerReturn, useSummarizer } from "./useSummarizer.js";
|
|
44
|
+
import { Task, UseTaskQueueReturn, useTaskQueue } from "./useTaskQueue.js";
|
|
45
|
+
import { UseTimeoutOptions, UseTimeoutReturn, useTimeout } from "./useTimeout.js";
|
|
46
|
+
import { ThrottledCallbackReturn, UseThrottledCallbackOptions, useThrottledCallback } from "./useThrottledCallback.js";
|
|
47
47
|
import { useTraceUpdates } from "./useTraceUpdates.js";
|
|
48
|
-
import { useTranslator } from "./useTranslator.js";
|
|
49
|
-
import { useToggle } from "./useToggle.js";
|
|
50
|
-
import { useOnline } from "./useOnline.js";
|
|
51
|
-
import { useUserActivation } from "./useUserActivation.js";
|
|
52
|
-
import { useVibration } from "./useVibration.js";
|
|
53
|
-
import { useWebsocket } from "./useWebsocket.js";
|
|
54
|
-
export { useAsyncState, useAudio, useAutoScroll, useBarcode, useBatteryStatus, useBodyScrollFreeze, useCameraCapture, useCookies, useCopyToClipboard, useCountDown, useDebouncedState, useExternalNotifications, useFile, useFullscreen, useGeolocation, useHoverIntent, useIdle, useIndexedDB, useIntersectionObserver, useIntervalSafe, useIsClient, useIsDesktop, useIsFirstRender, useList, useLocalNotifications, useLocalStorage, useNetworkInformation, useOnline, usePageVisibility, usePermissions, usePictureInPicture, usePopover, usePreferredLanguage, usePreferredTheme, usePreviousDistinct, useResettableState, useScreenOrientation, useScreenSize, useScreenWakeLock, useServerSentEvent, useShoppingCart, useSmartVideo, useSpeech, useSummarizer, useTaskQueue, useThrottledCallback, useTimeout, useToggle, useTraceUpdates, useTranslator, useUserActivation, useVibration, useWebsocket };
|
|
48
|
+
import { BCP47LanguageTag, TranslatorTranslateOptions, UseTranslatorReturn, useTranslator } from "./useTranslator.js";
|
|
49
|
+
import { ToggleOptions, ToggleReturn, useToggle } from "./useToggle.js";
|
|
50
|
+
import { UseOnlineReturn, useOnline } from "./useOnline.js";
|
|
51
|
+
import { UseUserActivationReturn, useUserActivation } from "./useUserActivation.js";
|
|
52
|
+
import { UseVibrationReturn, VibrationPattern, useVibration } from "./useVibration.js";
|
|
53
|
+
import { UseWebsocketOptions, UseWebsocketReturn, useWebsocket } from "./useWebsocket.js";
|
|
54
|
+
export { AsyncState, AudioStatus, BCP47LanguageTag, BodyScrollFreezeOptions, BodyScrollFreezeReturn, BrowserSummarizer, CameraCaptureFormat, CameraCaptureOutput, CopyToClipboardReturn, CountDown, CountDownControlls, CountDownOptions, CountDownReturn, CountDownStatus, FetchConfig, FullScreenReturn, GeolocationPermissionState, IntersectionObserverOptions, IntersectionObserverReturn, ListReturn, NetworkInformation, NetworkInformationSnapshot, NotificationPayload, PageVisibilityReturn, PermissionState, PermissionsSnapshot, PreferredLanguageReturn, PreferredThemeReturn, SSEReadyState, ScreenSizeReturn, ScrollAxis, ShoppingCartItemDetail, SmartVideoOptions, SmartVideoReturn, SummarizerAvailability, SummarizerCreateOptions, SummarizerFormat, SummarizerLength, SummarizerStatic, SummarizerType, Task, Theme, ThrottledCallbackReturn, ToggleOptions, ToggleReturn, TranslatorTranslateOptions, UseAsyncStateOptions, UseAsyncStateReturn, UseAudioOptions, UseAudioReturn, UseAutoScrollOptions, UseBarcodeOptions, UseBarcodeReturn, UseBatteryStatus, UseBatteryStatusReturn, UseCameraCaptureOptions, UseCameraCaptureReturn, UseCookieOptions, UseCookieReturn, UseDebouncedStateOptions, UseDebouncedStateReturn, UseExternalNotificationReturn, UseFileOptions, UseFileReturn, UseGeolocationReturn, UseHoverIntentOptions, UseHoverIntentReturn, UseIdleOptions, UseIdleReturn, UseIndexedDBOptions, UseIndexedDBTransactionOptions, UseIndexedDBTransactionReturn, UseIntervalOptions, UseIntervalReturn, UseLocalNotificationReturn, UseLocalStorageOptions, UseLocalStorageReturn, UseNetworkInformationReturn, UseNotificationOptions, UseOnlineReturn, UsePermissionReturn, UsePictureInPictureReturn, UsePopoverReturn, UseScreenOrientationReturn, UseScreenWakeLockReturn, UseServerSentEventOptions, UseServerSentEventReturn, UseShoppingCartOptions, UseShoppingCartReturn, UseSpeechOptions, UseSpeechReturn, UseSummarizerReturn, UseTaskQueueReturn, UseThrottledCallbackOptions, UseTimeoutOptions, UseTimeoutReturn, UseTranslatorReturn, UseUserActivationReturn, UseVibrationReturn, UseWebsocketOptions, UseWebsocketReturn, VibrationPattern, notificationStore, pageVisibilityStore, systemLanguageStore, systemThemeStore, useAsyncState, useAudio, useAutoScroll, useBarcode, useBatteryStatus, useBodyScrollFreeze, useCameraCapture, useCookies, useCopyToClipboard, useCountDown, useDebouncedState, useExternalNotifications, useFile, useFullscreen, useGeolocation, useHoverIntent, useIdle, useIndexedDB, useIntersectionObserver, useIntervalSafe, useIsClient, useIsDesktop, useIsFirstRender, useList, useLocalNotifications, useLocalStorage, useNetworkInformation, useOnline, usePageVisibility, usePermissions, usePictureInPicture, usePopover, usePreferredLanguage, usePreferredTheme, usePreviousDistinct, useResettableState, useScreenOrientation, useScreenSize, useScreenWakeLock, useServerSentEvent, useShoppingCart, useSmartVideo, useSpeech, useSummarizer, useTaskQueue, useThrottledCallback, useTimeout, useToggle, useTraceUpdates, useTranslator, useUserActivation, useVibration, useWebsocket, userLanguageStore, userThemeStore };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { useCookies } from "./useCookies.js";
|
|
|
9
9
|
import { useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
10
10
|
import { useCountDown } from "./useCountDown.js";
|
|
11
11
|
import { useDebouncedState } from "./useDebouncedState.js";
|
|
12
|
-
import { useExternalNotifications } from "./useExternalNotifications.js";
|
|
12
|
+
import { notificationStore, useExternalNotifications } from "./useExternalNotifications.js";
|
|
13
13
|
import { useGeolocation } from "./useGeolocation.js";
|
|
14
14
|
import { useHoverIntent } from "./useHoverIntent.js";
|
|
15
15
|
import { useFile } from "./useFile.js";
|
|
@@ -26,12 +26,12 @@ import { useList } from "./useList.js";
|
|
|
26
26
|
import { useLocalStorage } from "./useLocalStorage.js";
|
|
27
27
|
import { useLocalNotifications } from "./useLocalNotifications.js";
|
|
28
28
|
import { useNetworkInformation } from "./useNetworkInformation.js";
|
|
29
|
-
import { usePageVisibility } from "./usePageVisibility.js";
|
|
29
|
+
import { pageVisibilityStore, usePageVisibility } from "./usePageVisibility.js";
|
|
30
30
|
import { usePermissions } from "./usePermissions.js";
|
|
31
31
|
import { usePictureInPicture } from "./usePictureInPicture.js";
|
|
32
32
|
import { usePopover } from "./usePopover.js";
|
|
33
|
-
import { usePreferredTheme } from "./usePreferredTheme.js";
|
|
34
|
-
import { usePreferredLanguage } from "./usePreferredLanguage.js";
|
|
33
|
+
import { systemThemeStore, usePreferredTheme, userThemeStore } from "./usePreferredTheme.js";
|
|
34
|
+
import { systemLanguageStore, usePreferredLanguage, userLanguageStore } from "./usePreferredLanguage.js";
|
|
35
35
|
import { usePreviousDistinct } from "./usePreviousDistinct.js";
|
|
36
36
|
import { useResettableState } from "./useResettableState.js";
|
|
37
37
|
import { useScreenOrientation } from "./useScreenOrientation.js";
|
|
@@ -52,4 +52,4 @@ import { useUserActivation } from "./useUserActivation.js";
|
|
|
52
52
|
import { useVibration } from "./useVibration.js";
|
|
53
53
|
import { useWebsocket } from "./useWebsocket.js";
|
|
54
54
|
|
|
55
|
-
export { useAsyncState, useAudio, useAutoScroll, useBarcode, useBatteryStatus, useBodyScrollFreeze, useCameraCapture, useCookies, useCopyToClipboard, useCountDown, useDebouncedState, useExternalNotifications, useFile, useFullscreen, useGeolocation, useHoverIntent, useIdle, useIndexedDB, useIntersectionObserver, useIntervalSafe, useIsClient, useIsDesktop, useIsFirstRender, useList, useLocalNotifications, useLocalStorage, useNetworkInformation, useOnline, usePageVisibility, usePermissions, usePictureInPicture, usePopover, usePreferredLanguage, usePreferredTheme, usePreviousDistinct, useResettableState, useScreenOrientation, useScreenSize, useScreenWakeLock, useServerSentEvent, useShoppingCart, useSmartVideo, useSpeech, useSummarizer, useTaskQueue, useThrottledCallback, useTimeout, useToggle, useTraceUpdates, useTranslator, useUserActivation, useVibration, useWebsocket };
|
|
55
|
+
export { notificationStore, pageVisibilityStore, systemLanguageStore, systemThemeStore, useAsyncState, useAudio, useAutoScroll, useBarcode, useBatteryStatus, useBodyScrollFreeze, useCameraCapture, useCookies, useCopyToClipboard, useCountDown, useDebouncedState, useExternalNotifications, useFile, useFullscreen, useGeolocation, useHoverIntent, useIdle, useIndexedDB, useIntersectionObserver, useIntervalSafe, useIsClient, useIsDesktop, useIsFirstRender, useList, useLocalNotifications, useLocalStorage, useNetworkInformation, useOnline, usePageVisibility, usePermissions, usePictureInPicture, usePopover, usePreferredLanguage, usePreferredTheme, usePreviousDistinct, useResettableState, useScreenOrientation, useScreenSize, useScreenWakeLock, useServerSentEvent, useShoppingCart, useSmartVideo, useSpeech, useSummarizer, useTaskQueue, useThrottledCallback, useTimeout, useToggle, useTraceUpdates, useTranslator, useUserActivation, useVibration, useWebsocket, userLanguageStore, userThemeStore };
|
package/dist/useAsyncState.d.ts
CHANGED
|
@@ -49,4 +49,4 @@ interface UseAsyncStateOptions<T> {
|
|
|
49
49
|
*/
|
|
50
50
|
declare function useAsyncState<T>(options?: UseAsyncStateOptions<T>): UseAsyncStateReturn<T>;
|
|
51
51
|
//#endregion
|
|
52
|
-
export { useAsyncState };
|
|
52
|
+
export { AsyncState, FetchConfig, UseAsyncStateOptions, UseAsyncStateReturn, useAsyncState };
|
package/dist/useAudio.d.ts
CHANGED
package/dist/useAutoScroll.d.ts
CHANGED
package/dist/useBarcode.d.ts
CHANGED
|
@@ -22,9 +22,7 @@ interface UseCameraCaptureOptions {
|
|
|
22
22
|
onCapture?: (dataUrl: string, blob: Blob) => void;
|
|
23
23
|
/**
|
|
24
24
|
* Desired output width for the captured image.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @default 320
|
|
25
|
+
* If ommited, the image is captured at native camera resolution.
|
|
28
26
|
*/
|
|
29
27
|
width?: number;
|
|
30
28
|
}
|
|
@@ -50,6 +48,10 @@ interface UseCameraCaptureReturn {
|
|
|
50
48
|
* Stops all active media tracks and releases the camera.
|
|
51
49
|
*/
|
|
52
50
|
stop: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Toggles between front and back camera if available.
|
|
53
|
+
*/
|
|
54
|
+
toggleCamera: () => void;
|
|
53
55
|
/**
|
|
54
56
|
* Indicates whether camera permissions has been granted.
|
|
55
57
|
*/
|
|
@@ -73,4 +75,4 @@ interface UseCameraCaptureReturn {
|
|
|
73
75
|
*/
|
|
74
76
|
declare function useCameraCapture(options?: UseCameraCaptureOptions): UseCameraCaptureReturn;
|
|
75
77
|
//#endregion
|
|
76
|
-
export { useCameraCapture };
|
|
78
|
+
export { CameraCaptureFormat, CameraCaptureOutput, UseCameraCaptureOptions, UseCameraCaptureReturn, useCameraCapture };
|
package/dist/useCameraCapture.js
CHANGED
|
@@ -33,17 +33,37 @@ function useCameraCapture(options = {}) {
|
|
|
33
33
|
const imageRef = React.useRef(null);
|
|
34
34
|
const streamRef = React.useRef(null);
|
|
35
35
|
const streamingRef = React.useRef(false);
|
|
36
|
-
const
|
|
36
|
+
const devicesRef = React.useRef([]);
|
|
37
|
+
const currentDeviceIndexRef = React.useRef(0);
|
|
37
38
|
const isBrowser = typeof window !== "undefined";
|
|
38
39
|
const permissionStoreRef = React.useRef(createExternalStore(() => !!streamRef.current));
|
|
39
40
|
const streamingStoreRef = React.useRef(createExternalStore(() => streamingRef.current));
|
|
41
|
+
const isTouchDevice = () => {
|
|
42
|
+
if (!isBrowser) return false;
|
|
43
|
+
return "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
44
|
+
};
|
|
45
|
+
const loadVideDevices = React.useCallback(async () => {
|
|
46
|
+
if (!navigator.mediaDevices?.enumerateDevices) return;
|
|
47
|
+
const videoInputs = (await navigator.mediaDevices.enumerateDevices()).filter((device) => device.kind === "videoinput");
|
|
48
|
+
devicesRef.current = videoInputs;
|
|
49
|
+
if (videoInputs.length === 0) return;
|
|
50
|
+
const touch = isTouchDevice();
|
|
51
|
+
const backCameraIndex = videoInputs.findIndex((device) => /back|rear|environment/i.test(device.label));
|
|
52
|
+
if (touch && backCameraIndex !== -1) currentDeviceIndexRef.current = backCameraIndex;
|
|
53
|
+
else currentDeviceIndexRef.current = 0;
|
|
54
|
+
}, [isBrowser]);
|
|
40
55
|
const requestPermission = React.useCallback(async () => {
|
|
41
56
|
if (!isBrowser) return false;
|
|
42
57
|
if (!navigator.mediaDevices?.getUserMedia) return false;
|
|
43
58
|
try {
|
|
59
|
+
if (devicesRef.current.length === 0) {
|
|
60
|
+
(await navigator.mediaDevices.getUserMedia({ video: true })).getTracks().forEach((track) => track.stop());
|
|
61
|
+
await loadVideDevices();
|
|
62
|
+
}
|
|
63
|
+
const device = devicesRef.current[currentDeviceIndexRef.current];
|
|
44
64
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
45
65
|
audio: false,
|
|
46
|
-
video: true
|
|
66
|
+
video: device ? { deviceId: { exact: device.deviceId } } : true
|
|
47
67
|
});
|
|
48
68
|
streamRef.current = stream;
|
|
49
69
|
permissionStoreRef.current.notify();
|
|
@@ -51,24 +71,13 @@ function useCameraCapture(options = {}) {
|
|
|
51
71
|
if (!video) return false;
|
|
52
72
|
video.srcObject = stream;
|
|
53
73
|
await video.play();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
heightRef.current = videoHeight / (videoWidth / width);
|
|
57
|
-
video.width = width;
|
|
58
|
-
video.height = heightRef.current;
|
|
59
|
-
const canvas = canvasRef.current;
|
|
60
|
-
if (canvas) {
|
|
61
|
-
canvas.width = width;
|
|
62
|
-
canvas.height = heightRef.current;
|
|
63
|
-
}
|
|
64
|
-
streamingRef.current = true;
|
|
65
|
-
streamingStoreRef.current.notify();
|
|
66
|
-
}
|
|
74
|
+
streamingRef.current = true;
|
|
75
|
+
streamingStoreRef.current.notify();
|
|
67
76
|
return true;
|
|
68
77
|
} catch {
|
|
69
78
|
return false;
|
|
70
79
|
}
|
|
71
|
-
}, [isBrowser,
|
|
80
|
+
}, [isBrowser, loadVideDevices]);
|
|
72
81
|
const capture = React.useCallback(() => {
|
|
73
82
|
const video = videoRef.current;
|
|
74
83
|
const canvas = canvasRef.current;
|
|
@@ -76,9 +85,19 @@ function useCameraCapture(options = {}) {
|
|
|
76
85
|
if (!video || !canvas || !streamingRef.current) return null;
|
|
77
86
|
const context = canvas.getContext("2d");
|
|
78
87
|
if (!context) return null;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
const videoWidth = video.videoWidth;
|
|
89
|
+
const videoHeight = video.videoHeight;
|
|
90
|
+
if (!videoWidth || !videoHeight) return null;
|
|
91
|
+
if (width) {
|
|
92
|
+
const scaledHeight = videoHeight / (videoWidth / width);
|
|
93
|
+
canvas.width = width;
|
|
94
|
+
canvas.height = scaledHeight;
|
|
95
|
+
context.drawImage(video, 0, 0, width, scaledHeight);
|
|
96
|
+
} else {
|
|
97
|
+
canvas.width = videoWidth;
|
|
98
|
+
canvas.height = videoHeight;
|
|
99
|
+
context.drawImage(video, 0, 0, videoWidth, videoHeight);
|
|
100
|
+
}
|
|
82
101
|
const dataUrl = canvas.toDataURL(output.type, output.quality);
|
|
83
102
|
image?.setAttribute("src", dataUrl);
|
|
84
103
|
if (onCapture) canvas.toBlob((blob) => {
|
|
@@ -93,11 +112,18 @@ function useCameraCapture(options = {}) {
|
|
|
93
112
|
]);
|
|
94
113
|
const stop = React.useCallback(() => {
|
|
95
114
|
streamRef.current?.getTracks().forEach((track) => track.stop());
|
|
115
|
+
if (videoRef.current) videoRef.current.srcObject = null;
|
|
96
116
|
streamRef.current = null;
|
|
97
117
|
streamingRef.current = false;
|
|
98
118
|
permissionStoreRef.current.notify();
|
|
99
119
|
streamingStoreRef.current.notify();
|
|
100
120
|
}, []);
|
|
121
|
+
const toggleCamera = React.useCallback(async () => {
|
|
122
|
+
if (devicesRef.current.length <= 1) return false;
|
|
123
|
+
stop();
|
|
124
|
+
currentDeviceIndexRef.current = (currentDeviceIndexRef.current + 1) / devicesRef.current.length;
|
|
125
|
+
return await requestPermission();
|
|
126
|
+
}, [requestPermission, stop]);
|
|
101
127
|
const usePermission = () => React.useSyncExternalStore(permissionStoreRef.current.subscribe, permissionStoreRef.current.getSnapshot, () => false);
|
|
102
128
|
const useStreaming = () => React.useSyncExternalStore(streamingStoreRef.current.subscribe, streamingStoreRef.current.getSnapshot, () => false);
|
|
103
129
|
return {
|
|
@@ -106,6 +132,7 @@ function useCameraCapture(options = {}) {
|
|
|
106
132
|
imageRef,
|
|
107
133
|
requestPermission,
|
|
108
134
|
stop,
|
|
135
|
+
toggleCamera,
|
|
109
136
|
usePermission,
|
|
110
137
|
useStreaming,
|
|
111
138
|
videoRef
|
package/dist/useCookies.d.ts
CHANGED
package/dist/useCountDown.d.ts
CHANGED
|
@@ -44,4 +44,4 @@ interface UseDebouncedStateReturn<T> {
|
|
|
44
44
|
*/
|
|
45
45
|
declare function useDebouncedState<T>(initialValue: T, options: UseDebouncedStateOptions): UseDebouncedStateReturn<T>;
|
|
46
46
|
//#endregion
|
|
47
|
-
export { useDebouncedState };
|
|
47
|
+
export { UseDebouncedStateOptions, UseDebouncedStateReturn, useDebouncedState };
|
|
@@ -4,6 +4,14 @@ interface NotificationPayload extends NotificationOptions {
|
|
|
4
4
|
id?: string;
|
|
5
5
|
title: string;
|
|
6
6
|
}
|
|
7
|
+
type Listener = () => void;
|
|
8
|
+
declare function suscribe(listener: Listener): () => void;
|
|
9
|
+
declare function getSnapshot(): NotificationPayload[];
|
|
10
|
+
declare const notificationStore: {
|
|
11
|
+
getSnapshot: typeof getSnapshot;
|
|
12
|
+
push(notification: NotificationPayload): void;
|
|
13
|
+
suscribe: typeof suscribe;
|
|
14
|
+
};
|
|
7
15
|
interface UseExternalNotificationReturn {
|
|
8
16
|
isSupported: boolean;
|
|
9
17
|
notifications: NotificationPayload[] | null;
|
|
@@ -33,4 +41,4 @@ interface UseExternalNotificationReturn {
|
|
|
33
41
|
*/
|
|
34
42
|
declare function useExternalNotifications(): UseExternalNotificationReturn;
|
|
35
43
|
//#endregion
|
|
36
|
-
export { useExternalNotifications };
|
|
44
|
+
export { NotificationPayload, UseExternalNotificationReturn, notificationStore, useExternalNotifications };
|
package/dist/useFile.d.ts
CHANGED
package/dist/useFullScreen.d.ts
CHANGED
package/dist/useGeolocation.d.ts
CHANGED
package/dist/useHoverIntent.d.ts
CHANGED
package/dist/useIdle.d.ts
CHANGED
package/dist/useIndexedDB.d.ts
CHANGED
|
@@ -57,4 +57,4 @@ interface UseIndexedDBTransactionReturn {
|
|
|
57
57
|
*/
|
|
58
58
|
declare function useIndexedDB(options: UseIndexedDBOptions): UseIndexedDBTransactionReturn;
|
|
59
59
|
//#endregion
|
|
60
|
-
export { useIndexedDB };
|
|
60
|
+
export { UseIndexedDBOptions, UseIndexedDBTransactionOptions, UseIndexedDBTransactionReturn, useIndexedDB };
|
|
@@ -42,4 +42,4 @@ interface IntersectionObserverReturn<T extends Element> {
|
|
|
42
42
|
*/
|
|
43
43
|
declare function useIntersectionObserver<T extends Element = HTMLElement>(options?: IntersectionObserverOptions, externalRef?: React.RefObject<T | null>): IntersectionObserverReturn<T>;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { useIntersectionObserver };
|
|
45
|
+
export { IntersectionObserverOptions, IntersectionObserverReturn, useIntersectionObserver };
|
package/dist/useList.d.ts
CHANGED
|
@@ -20,4 +20,4 @@ interface UseNotificationOptions extends NotificationOptions {
|
|
|
20
20
|
*/
|
|
21
21
|
declare function useLocalNotifications(): UseLocalNotificationReturn;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { useLocalNotifications };
|
|
23
|
+
export { UseLocalNotificationReturn, UseNotificationOptions, useLocalNotifications };
|
|
@@ -42,4 +42,4 @@ interface UseLocalStorageReturn<T> {
|
|
|
42
42
|
*/
|
|
43
43
|
declare function useLocalStorage<T>(key: string, options: UseLocalStorageOptions<T>): UseLocalStorageReturn<T>;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { useLocalStorage };
|
|
45
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage };
|
|
@@ -135,4 +135,4 @@ interface UseNetworkInformationReturn extends NetworkInformationSnapshot {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function useNetworkInformation(): UseNetworkInformationReturn;
|
|
137
137
|
//#endregion
|
|
138
|
-
export { useNetworkInformation };
|
|
138
|
+
export { NetworkInformation, NetworkInformationSnapshot, UseNetworkInformationReturn, useNetworkInformation };
|
package/dist/useOnline.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ interface PageVisibilityReturn {
|
|
|
9
9
|
*/
|
|
10
10
|
visibilityState: DocumentVisibilityState;
|
|
11
11
|
}
|
|
12
|
+
type Listener = () => void;
|
|
13
|
+
declare const pageVisibilityStore: {
|
|
14
|
+
readonly getServerSnapshot: () => DocumentVisibilityState;
|
|
15
|
+
readonly getSnapshot: () => DocumentVisibilityState;
|
|
16
|
+
readonly subscribe: (listener: Listener) => () => void;
|
|
17
|
+
};
|
|
12
18
|
/**
|
|
13
19
|
* `usePageVisibility` is a React hook that exposes the current visibility
|
|
14
20
|
* state of the document using the Page Visibility API.
|
|
@@ -29,4 +35,4 @@ interface PageVisibilityReturn {
|
|
|
29
35
|
*/
|
|
30
36
|
declare function usePageVisibility(): PageVisibilityReturn;
|
|
31
37
|
//#endregion
|
|
32
|
-
export { usePageVisibility };
|
|
38
|
+
export { PageVisibilityReturn, pageVisibilityStore, usePageVisibility };
|
package/dist/usePermissions.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ interface UsePermissionReturn {
|
|
|
25
25
|
*/
|
|
26
26
|
declare function usePermissions<T extends readonly PermissionName[]>(permissionNames: T): UsePermissionReturn;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { usePermissions };
|
|
28
|
+
export { PermissionState, PermissionsSnapshot, UsePermissionReturn, usePermissions };
|
package/dist/usePopover.d.ts
CHANGED
|
@@ -51,4 +51,4 @@ interface UsePopoverReturn<TAnchor extends HTMLElement, TPopover extends HTMLEle
|
|
|
51
51
|
*/
|
|
52
52
|
declare function usePopover<TAnchor extends HTMLElement = HTMLElement, TPopover extends HTMLElement = HTMLElement>(): UsePopoverReturn<TAnchor, TPopover>;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { usePopover };
|
|
54
|
+
export { UsePopoverReturn, usePopover };
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
//#region src/usePreferredLanguage.d.ts
|
|
2
|
-
|
|
2
|
+
type Listener = () => void;
|
|
3
|
+
declare const systemLanguageStore: {
|
|
4
|
+
readonly getServerSnapshot: () => string;
|
|
5
|
+
readonly getSnapshot: () => string;
|
|
6
|
+
readonly subscribe: (listener: Listener) => () => void;
|
|
7
|
+
};
|
|
8
|
+
declare const userLanguageStore: {
|
|
9
|
+
readonly getServerSnapshot: () => string;
|
|
10
|
+
readonly getSnapshot: () => string;
|
|
11
|
+
readonly setLanguage: (lang: string) => void;
|
|
12
|
+
readonly subscribe: (listener: Listener) => () => void;
|
|
13
|
+
};
|
|
3
14
|
interface PreferredLanguageReturn {
|
|
4
15
|
/**
|
|
5
16
|
* Language effectively used by the application.
|
|
@@ -52,4 +63,4 @@ interface PreferredLanguageReturn {
|
|
|
52
63
|
*/
|
|
53
64
|
declare function usePreferredLanguage(): PreferredLanguageReturn;
|
|
54
65
|
//#endregion
|
|
55
|
-
export { usePreferredLanguage };
|
|
66
|
+
export { PreferredLanguageReturn, systemLanguageStore, usePreferredLanguage, userLanguageStore };
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
//#region src/usePreferredTheme.d.ts
|
|
2
2
|
type Theme = string;
|
|
3
|
+
type Listener = () => void;
|
|
4
|
+
declare const systemThemeStore: {
|
|
5
|
+
getServerSnapshot(): Theme;
|
|
6
|
+
getSnapshot(): Theme;
|
|
7
|
+
suscribe(listener: Listener): () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const userThemeStore: {
|
|
10
|
+
getSeverSnapshot(): Theme | null;
|
|
11
|
+
getSnapshot(): Theme | null;
|
|
12
|
+
setTheme(theme: Theme | null): void;
|
|
13
|
+
suscribe(listener: Listener): () => void;
|
|
14
|
+
};
|
|
3
15
|
interface PreferredThemeReturn {
|
|
4
16
|
/**
|
|
5
17
|
* Sets a user-selected theme.
|
|
@@ -64,4 +76,4 @@ interface PreferredThemeReturn {
|
|
|
64
76
|
*/
|
|
65
77
|
declare function usePreferredTheme(): PreferredThemeReturn;
|
|
66
78
|
//#endregion
|
|
67
|
-
export { usePreferredTheme };
|
|
79
|
+
export { PreferredThemeReturn, Theme, systemThemeStore, usePreferredTheme, userThemeStore };
|
package/dist/useScreenSize.d.ts
CHANGED
|
@@ -54,4 +54,4 @@ type SSEReadyState = 0 | 1 | 2;
|
|
|
54
54
|
*/
|
|
55
55
|
declare function useServerSentEvent(url: string, options?: UseServerSentEventOptions): UseServerSentEventReturn;
|
|
56
56
|
//#endregion
|
|
57
|
-
export { useServerSentEvent };
|
|
57
|
+
export { SSEReadyState, UseServerSentEventOptions, UseServerSentEventReturn, useServerSentEvent };
|
|
@@ -51,4 +51,4 @@ interface UseShoppingCartReturn<T extends object> {
|
|
|
51
51
|
*/
|
|
52
52
|
declare function useShoppingCart<T extends object>(options: UseShoppingCartOptions<T>): UseShoppingCartReturn<T>;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { useShoppingCart };
|
|
54
|
+
export { ShoppingCartItemDetail, UseShoppingCartOptions, UseShoppingCartReturn, useShoppingCart };
|
package/dist/useSmartVideo.d.ts
CHANGED
package/dist/useSpeech.d.ts
CHANGED
package/dist/useSummarizer.d.ts
CHANGED
|
@@ -89,4 +89,4 @@ interface UseSummarizerReturn {
|
|
|
89
89
|
*/
|
|
90
90
|
declare function useSummarizer(): UseSummarizerReturn;
|
|
91
91
|
//#endregion
|
|
92
|
-
export { useSummarizer };
|
|
92
|
+
export { BrowserSummarizer, SummarizerAvailability, SummarizerCreateOptions, SummarizerFormat, SummarizerLength, SummarizerStatic, SummarizerType, UseSummarizerReturn, useSummarizer };
|
package/dist/useTaskQueue.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ type ThrottledCallbackReturn<TArgs extends readonly unknown[]> = (...args: TArgs
|
|
|
29
29
|
*/
|
|
30
30
|
declare function useThrottledCallback<TArgs extends readonly unknown[]>(callback: (...args: TArgs) => void, options: UseThrottledCallbackOptions): ThrottledCallbackReturn<TArgs>;
|
|
31
31
|
//#endregion
|
|
32
|
-
export { useThrottledCallback };
|
|
32
|
+
export { ThrottledCallbackReturn, UseThrottledCallbackOptions, useThrottledCallback };
|
package/dist/useTimeout.d.ts
CHANGED
package/dist/useToggle.d.ts
CHANGED
package/dist/useTranslator.d.ts
CHANGED
|
@@ -107,4 +107,4 @@ interface UseTranslatorReturn {
|
|
|
107
107
|
*/
|
|
108
108
|
declare function useTranslator(options: TranslatorTranslateOptions): UseTranslatorReturn;
|
|
109
109
|
//#endregion
|
|
110
|
-
export { useTranslator };
|
|
110
|
+
export { BCP47LanguageTag, TranslatorTranslateOptions, UseTranslatorReturn, useTranslator };
|
package/dist/useVibration.d.ts
CHANGED
package/dist/useWebsocket.d.ts
CHANGED
|
@@ -77,4 +77,4 @@ interface UseWebsocketReturn<TMessage = unknown> {
|
|
|
77
77
|
*/
|
|
78
78
|
declare function useWebsocket<TMessage = unknown>(options: UseWebsocketOptions<TMessage>): UseWebsocketReturn<TMessage>;
|
|
79
79
|
//#endregion
|
|
80
|
-
export { useWebsocket };
|
|
80
|
+
export { UseWebsocketOptions, UseWebsocketReturn, useWebsocket };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibehooks/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"description": "Modern React and Next.js hooks, unopinionated and focused on developer experience.",
|
|
6
6
|
"author": "Sebastian Marat Urdanegui Bisalaya <sebasurdanegui@gmail.com>",
|
|
7
7
|
"license": "MIT",
|