@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.
Files changed (55) hide show
  1. package/dist/index.d.ts +48 -48
  2. package/dist/index.js +5 -5
  3. package/dist/useAsyncState.d.ts +1 -1
  4. package/dist/useAudio.d.ts +1 -1
  5. package/dist/useAutoScroll.d.ts +1 -1
  6. package/dist/useBarcode.d.ts +1 -1
  7. package/dist/useBatteryStatus.d.ts +1 -1
  8. package/dist/useBodyScrollFreeze.d.ts +1 -1
  9. package/dist/useCameraCapture.d.ts +6 -4
  10. package/dist/useCameraCapture.js +46 -19
  11. package/dist/useCookies.d.ts +1 -1
  12. package/dist/useCopyToClipboard.d.ts +1 -1
  13. package/dist/useCountDown.d.ts +1 -1
  14. package/dist/useDebouncedState.d.ts +1 -1
  15. package/dist/useExternalNotifications.d.ts +9 -1
  16. package/dist/useExternalNotifications.js +1 -1
  17. package/dist/useFile.d.ts +1 -1
  18. package/dist/useFullScreen.d.ts +1 -1
  19. package/dist/useGeolocation.d.ts +1 -1
  20. package/dist/useHoverIntent.d.ts +1 -1
  21. package/dist/useIdle.d.ts +1 -1
  22. package/dist/useIndexedDB.d.ts +1 -1
  23. package/dist/useIntersectionObserver.d.ts +1 -1
  24. package/dist/useIntervalSafe.d.ts +1 -1
  25. package/dist/useList.d.ts +1 -1
  26. package/dist/useLocalNotifications.d.ts +1 -1
  27. package/dist/useLocalStorage.d.ts +1 -1
  28. package/dist/useNetworkInformation.d.ts +1 -1
  29. package/dist/useOnline.d.ts +1 -1
  30. package/dist/usePageVisibility.d.ts +7 -1
  31. package/dist/usePageVisibility.js +1 -1
  32. package/dist/usePermissions.d.ts +1 -1
  33. package/dist/usePictureInPicture.d.ts +1 -1
  34. package/dist/usePopover.d.ts +1 -1
  35. package/dist/usePreferredLanguage.d.ts +13 -2
  36. package/dist/usePreferredLanguage.js +1 -1
  37. package/dist/usePreferredTheme.d.ts +13 -1
  38. package/dist/usePreferredTheme.js +1 -1
  39. package/dist/useScreenOrientation.d.ts +1 -1
  40. package/dist/useScreenSize.d.ts +1 -1
  41. package/dist/useScreenWakeLock.d.ts +1 -1
  42. package/dist/useServerSentEvent.d.ts +1 -1
  43. package/dist/useShoppingCart.d.ts +1 -1
  44. package/dist/useSmartVideo.d.ts +1 -1
  45. package/dist/useSpeech.d.ts +1 -1
  46. package/dist/useSummarizer.d.ts +1 -1
  47. package/dist/useTaskQueue.d.ts +1 -1
  48. package/dist/useThrottledCallback.d.ts +1 -1
  49. package/dist/useTimeout.d.ts +1 -1
  50. package/dist/useToggle.d.ts +1 -1
  51. package/dist/useTranslator.d.ts +1 -1
  52. package/dist/useUserActivation.d.ts +1 -1
  53. package/dist/useVibration.d.ts +1 -1
  54. package/dist/useWebsocket.d.ts +1 -1
  55. 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 };
@@ -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 };
@@ -23,4 +23,4 @@ interface UseAudioReturn {
23
23
  */
24
24
  declare function useAudio(options?: UseAudioOptions): UseAudioReturn;
25
25
  //#endregion
26
- export { useAudio };
26
+ export { AudioStatus, UseAudioOptions, UseAudioReturn, useAudio };
@@ -44,4 +44,4 @@ declare function useAutoScroll(options?: UseAutoScrollOptions): {
44
44
  scrollToBottom: (forceSmooth?: boolean) => void;
45
45
  };
46
46
  //#endregion
47
- export { useAutoScroll };
47
+ export { UseAutoScrollOptions, useAutoScroll };
@@ -74,4 +74,4 @@ declare function useBarcode({
74
74
  onDetect
75
75
  }?: UseBarcodeOptions): UseBarcodeReturn;
76
76
  //#endregion
77
- export { useBarcode };
77
+ export { UseBarcodeOptions, UseBarcodeReturn, useBarcode };
@@ -50,4 +50,4 @@ declare global {
50
50
  */
51
51
  declare function useBatteryStatus(): UseBatteryStatusReturn;
52
52
  //#endregion
53
- export { useBatteryStatus };
53
+ export { UseBatteryStatus, UseBatteryStatusReturn, useBatteryStatus };
@@ -33,4 +33,4 @@ interface BodyScrollFreezeReturn {
33
33
  */
34
34
  declare function useBodyScrollFreeze(): BodyScrollFreezeReturn;
35
35
  //#endregion
36
- export { useBodyScrollFreeze };
36
+ export { BodyScrollFreezeOptions, BodyScrollFreezeReturn, ScrollAxis, useBodyScrollFreeze };
@@ -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
- * The height is automatically calculated to preserve the aspect ratio.
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 };
@@ -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 heightRef = React.useRef(0);
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
- if (!streamingRef.current) {
55
- const { videoHeight, videoWidth } = video;
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, width]);
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
- canvas.width = width;
80
- canvas.height = heightRef.current;
81
- context.drawImage(video, 0, 0, width, heightRef.current);
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
@@ -39,4 +39,4 @@ interface UseCookieReturn {
39
39
  */
40
40
  declare function useCookies(): UseCookieReturn;
41
41
  //#endregion
42
- export { useCookies };
42
+ export { UseCookieOptions, UseCookieReturn, useCookies };
@@ -19,4 +19,4 @@ interface CopyToClipboardReturn {
19
19
  */
20
20
  declare function useCopyToClipboard(): CopyToClipboardReturn;
21
21
  //#endregion
22
- export { useCopyToClipboard };
22
+ export { CopyToClipboardReturn, useCopyToClipboard };
@@ -77,4 +77,4 @@ declare function useCountDown({
77
77
  startOnMount
78
78
  }: CountDown): CountDownReturn;
79
79
  //#endregion
80
- export { useCountDown };
80
+ export { CountDown, CountDownControlls, CountDownOptions, CountDownReturn, CountDownStatus, useCountDown };
@@ -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 };
@@ -97,4 +97,4 @@ function useExternalNotifications() {
97
97
  }
98
98
 
99
99
  //#endregion
100
- export { useExternalNotifications };
100
+ export { notificationStore, useExternalNotifications };
package/dist/useFile.d.ts CHANGED
@@ -71,4 +71,4 @@ interface UseFileReturn {
71
71
  */
72
72
  declare function useFile(options?: UseFileOptions): UseFileReturn;
73
73
  //#endregion
74
- export { useFile };
74
+ export { UseFileOptions, UseFileReturn, useFile };
@@ -17,4 +17,4 @@ interface FullScreenReturn {
17
17
  */
18
18
  declare function useFullscreen<T extends HTMLElement>(ref: React.RefObject<T | null>): FullScreenReturn;
19
19
  //#endregion
20
- export { useFullscreen };
20
+ export { FullScreenReturn, useFullscreen };
@@ -44,4 +44,4 @@ interface UseGeolocationReturn {
44
44
  */
45
45
  declare function useGeolocation(): UseGeolocationReturn;
46
46
  //#endregion
47
- export { useGeolocation };
47
+ export { GeolocationPermissionState, UseGeolocationReturn, useGeolocation };
@@ -42,4 +42,4 @@ interface UseHoverIntentReturn {
42
42
  */
43
43
  declare function useHoverIntent(options?: UseHoverIntentOptions): UseHoverIntentReturn;
44
44
  //#endregion
45
- export { useHoverIntent };
45
+ export { UseHoverIntentOptions, UseHoverIntentReturn, useHoverIntent };
package/dist/useIdle.d.ts CHANGED
@@ -44,4 +44,4 @@ interface UseIdleReturn {
44
44
  */
45
45
  declare function useIdle(options?: UseIdleOptions): UseIdleReturn;
46
46
  //#endregion
47
- export { useIdle };
47
+ export { UseIdleOptions, UseIdleReturn, useIdle };
@@ -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 };
@@ -69,4 +69,4 @@ declare function useIntervalSafe(callback: () => void, {
69
69
  startOnMount
70
70
  }: UseIntervalOptions): UseIntervalReturn;
71
71
  //#endregion
72
- export { useIntervalSafe };
72
+ export { UseIntervalOptions, UseIntervalReturn, useIntervalSafe };
package/dist/useList.d.ts CHANGED
@@ -16,4 +16,4 @@ interface ListReturn<T> {
16
16
  */
17
17
  declare function useList<T>(defaultValue?: T[]): ListReturn<T>;
18
18
  //#endregion
19
- export { useList };
19
+ export { ListReturn, useList };
@@ -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 };
@@ -14,4 +14,4 @@ interface UseOnlineReturn {
14
14
  */
15
15
  declare function useOnline(): UseOnlineReturn;
16
16
  //#endregion
17
- export { useOnline };
17
+ export { UseOnlineReturn, useOnline };
@@ -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 };
@@ -62,4 +62,4 @@ function usePageVisibility() {
62
62
  }
63
63
 
64
64
  //#endregion
65
- export { usePageVisibility };
65
+ export { pageVisibilityStore, usePageVisibility };
@@ -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 };
@@ -44,4 +44,4 @@ interface UsePictureInPictureReturn {
44
44
  */
45
45
  declare function usePictureInPicture(): UsePictureInPictureReturn;
46
46
  //#endregion
47
- export { usePictureInPicture };
47
+ export { UsePictureInPictureReturn, usePictureInPicture };
@@ -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 };
@@ -124,4 +124,4 @@ function usePreferredLanguage() {
124
124
  }
125
125
 
126
126
  //#endregion
127
- export { usePreferredLanguage };
127
+ export { 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 };
@@ -130,4 +130,4 @@ function usePreferredTheme() {
130
130
  }
131
131
 
132
132
  //#endregion
133
- export { usePreferredTheme };
133
+ export { systemThemeStore, usePreferredTheme, userThemeStore };
@@ -45,4 +45,4 @@ interface UseScreenOrientationReturn {
45
45
  */
46
46
  declare function useScreenOrientation(): UseScreenOrientationReturn;
47
47
  //#endregion
48
- export { useScreenOrientation };
48
+ export { UseScreenOrientationReturn, useScreenOrientation };
@@ -13,4 +13,4 @@ interface ScreenSizeReturn {
13
13
  */
14
14
  declare function useScreenSize(): ScreenSizeReturn;
15
15
  //#endregion
16
- export { useScreenSize };
16
+ export { ScreenSizeReturn, useScreenSize };
@@ -34,4 +34,4 @@ interface UseScreenWakeLockReturn {
34
34
  */
35
35
  declare function useScreenWakeLock(): UseScreenWakeLockReturn;
36
36
  //#endregion
37
- export { useScreenWakeLock };
37
+ export { UseScreenWakeLockReturn, useScreenWakeLock };
@@ -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 };
@@ -32,4 +32,4 @@ interface SmartVideoReturn {
32
32
  }
33
33
  declare function useSmartVideo(options?: SmartVideoOptions): SmartVideoReturn;
34
34
  //#endregion
35
- export { useSmartVideo };
35
+ export { SmartVideoOptions, SmartVideoReturn, useSmartVideo };
@@ -71,4 +71,4 @@ interface UseSpeechReturn {
71
71
  */
72
72
  declare function useSpeech(options?: UseSpeechOptions): UseSpeechReturn;
73
73
  //#endregion
74
- export { useSpeech };
74
+ export { UseSpeechOptions, UseSpeechReturn, useSpeech };
@@ -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 };
@@ -22,4 +22,4 @@ interface UseTaskQueueReturn<T = unknown> {
22
22
  */
23
23
  declare function useTaskQueue<T = unknown>(): UseTaskQueueReturn<T>;
24
24
  //#endregion
25
- export { useTaskQueue };
25
+ export { Task, UseTaskQueueReturn, useTaskQueue };
@@ -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 };
@@ -55,4 +55,4 @@ declare function useTimeout(callback: () => void, {
55
55
  startOnMount
56
56
  }: UseTimeoutOptions): UseTimeoutReturn;
57
57
  //#endregion
58
- export { useTimeout };
58
+ export { UseTimeoutOptions, UseTimeoutReturn, useTimeout };
@@ -27,4 +27,4 @@ declare function useToggle({
27
27
  defaultValue
28
28
  }: ToggleOptions): ToggleReturn;
29
29
  //#endregion
30
- export { useToggle };
30
+ export { ToggleOptions, ToggleReturn, useToggle };
@@ -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 };
@@ -37,4 +37,4 @@ interface UseUserActivationReturn {
37
37
  */
38
38
  declare function useUserActivation(): UseUserActivationReturn;
39
39
  //#endregion
40
- export { useUserActivation };
40
+ export { UseUserActivationReturn, useUserActivation };
@@ -52,4 +52,4 @@ interface UseVibrationReturn {
52
52
  */
53
53
  declare function useVibration(): UseVibrationReturn;
54
54
  //#endregion
55
- export { useVibration };
55
+ export { UseVibrationReturn, VibrationPattern, useVibration };
@@ -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",
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",