@reactuses/core 3.0.1 → 3.0.3
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.cjs +14 -11
- package/dist/index.d.ts +3 -6
- package/dist/index.mjs +13 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ const createUpdateEffect = (hook) => (effect, deps) => {
|
|
|
44
44
|
|
|
45
45
|
var useUpdateEffect = createUpdateEffect(React.useEffect);
|
|
46
46
|
|
|
47
|
-
var index$
|
|
47
|
+
var index$3 = createUpdateEffect(React.useLayoutEffect);
|
|
48
48
|
|
|
49
49
|
var _a;
|
|
50
50
|
const isFunction$1 = (val) => typeof val === "function";
|
|
@@ -3441,8 +3441,9 @@ var __async$4 = (__this, __arguments, generator) => {
|
|
|
3441
3441
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
3442
3442
|
});
|
|
3443
3443
|
};
|
|
3444
|
+
const defaultConstints = { audio: true, video: true };
|
|
3444
3445
|
function useMediaDevices(options = {}) {
|
|
3445
|
-
const { requestPermissions, constraints =
|
|
3446
|
+
const { requestPermissions, constraints = defaultConstints } = options;
|
|
3446
3447
|
const [state, setState] = React.useState({ devices: [] });
|
|
3447
3448
|
const isSupported = useSupported(
|
|
3448
3449
|
() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices
|
|
@@ -3472,10 +3473,15 @@ function useMediaDevices(options = {}) {
|
|
|
3472
3473
|
if (permissionGranted.current) {
|
|
3473
3474
|
return true;
|
|
3474
3475
|
}
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3476
|
+
let state2;
|
|
3477
|
+
try {
|
|
3478
|
+
state2 = (yield navigator.permissions.query({
|
|
3479
|
+
name: "camera"
|
|
3480
|
+
})).state;
|
|
3481
|
+
} catch (error) {
|
|
3482
|
+
state2 = "prompt";
|
|
3483
|
+
}
|
|
3484
|
+
if (state2 !== "granted") {
|
|
3479
3485
|
stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
3480
3486
|
onChange();
|
|
3481
3487
|
permissionGranted.current = true;
|
|
@@ -3499,9 +3505,6 @@ function useMediaDevices(options = {}) {
|
|
|
3499
3505
|
}, [onChange, isSupported, requestPermissions, ensurePermissions]);
|
|
3500
3506
|
return [state, ensurePermissions];
|
|
3501
3507
|
}
|
|
3502
|
-
const useMediaDevicesMock = () => [{ devices: [] }, () => {
|
|
3503
|
-
}];
|
|
3504
|
-
var index$3 = isNavigator && !!navigator.mediaDevices ? useMediaDevices : useMediaDevicesMock;
|
|
3505
3508
|
|
|
3506
3509
|
function useTextDirection(options = {}) {
|
|
3507
3510
|
const { selector = "html", initialValue = "ltr" } = options;
|
|
@@ -5656,7 +5659,7 @@ exports.useLatest = useLatest;
|
|
|
5656
5659
|
exports.useLocalStorage = useLocalStorage;
|
|
5657
5660
|
exports.useLongPress = useLongPress;
|
|
5658
5661
|
exports.useMeasure = useMeasure;
|
|
5659
|
-
exports.useMediaDevices =
|
|
5662
|
+
exports.useMediaDevices = useMediaDevices;
|
|
5660
5663
|
exports.useMediaQuery = useMediaQuery;
|
|
5661
5664
|
exports.useMount = useMount;
|
|
5662
5665
|
exports.useMountedState = useMountedState;
|
|
@@ -5698,7 +5701,7 @@ exports.useToggle = useToggle;
|
|
|
5698
5701
|
exports.useUnmount = useUnmount;
|
|
5699
5702
|
exports.useUpdate = useUpdate;
|
|
5700
5703
|
exports.useUpdateEffect = useUpdateEffect;
|
|
5701
|
-
exports.useUpdateLayoutEffect = index$
|
|
5704
|
+
exports.useUpdateLayoutEffect = index$3;
|
|
5702
5705
|
exports.useVirtualList = useVirtualList;
|
|
5703
5706
|
exports.useWindowScroll = useWindowScroll;
|
|
5704
5707
|
exports.useWindowSize = useWindowSize;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ declare function useLatest<T>(value: T): MutableRefObject<T>;
|
|
|
9
9
|
|
|
10
10
|
declare function useFirstMountState(): boolean;
|
|
11
11
|
|
|
12
|
-
declare const _default$
|
|
12
|
+
declare const _default$4: typeof useEffect | typeof react.useLayoutEffect;
|
|
13
13
|
|
|
14
|
-
declare const _default$
|
|
14
|
+
declare const _default$3: typeof react.useEffect | typeof useLayoutEffect;
|
|
15
15
|
|
|
16
16
|
interface Serializer<T> {
|
|
17
17
|
read(raw: string): T;
|
|
@@ -310,9 +310,6 @@ declare function useMediaDevices(options?: UseMediaDeviceOptions): readonly [{
|
|
|
310
310
|
label: string;
|
|
311
311
|
}[];
|
|
312
312
|
}, () => Promise<boolean>];
|
|
313
|
-
declare const _default$3: typeof useMediaDevices | (() => ((() => void) | {
|
|
314
|
-
devices: never[];
|
|
315
|
-
})[]);
|
|
316
313
|
|
|
317
314
|
type UseTextDirectionValue = "ltr" | "rtl" | "auto";
|
|
318
315
|
interface UseTextDirectionOptions {
|
|
@@ -869,4 +866,4 @@ declare function useSetState<T extends Record<string, any>>(initialState: T): re
|
|
|
869
866
|
type UseMeasureRect = Omit<DOMRectReadOnly, "toJSON">;
|
|
870
867
|
declare function useMeasure(target: BasicTarget, options?: ResizeObserverOptions): readonly [UseMeasureRect, () => void];
|
|
871
868
|
|
|
872
|
-
export { ColorScheme, Contrast, CookieOptions, CookieState, CursorState, EyeDropperOpenReturnType, GeneralPermissionDescriptor, IDisposable, IEvent, IEventOnce, IListener, INetworkInformation, IState, IUseNetworkState, KeyModifier, MousePressedOptions, MouseSourceType, OrientationState, RafLoopReturns, ScrollIntoViewAnimation, ScrollIntoViewParams, State, Status, Target, UseDarkOptions, UseDraggableOptions, UseElementBoundingOptions, UseEventEmitterReturn, UseEyeDropperReturn, UseFileDialogOptions, UseFpsOptions, UseFullScreenOptions, UseInfiniteScrollOptions, UseLongPressOptions, UseMeasureRect, UseMediaDeviceOptions, UseModifierOptions, UseScriptTagOptions, UseScrollOptions, UseStickyParams, UseTextDirectionOptions, UseTextDirectionValue, UseTimeoutFnOptions, UseVirtualListItem, UseVirtualListOptions, UseVirtualListReturn, WindowSize, getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, _default$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure,
|
|
869
|
+
export { ColorScheme, Contrast, CookieOptions, CookieState, CursorState, EyeDropperOpenReturnType, GeneralPermissionDescriptor, IDisposable, IEvent, IEventOnce, IListener, INetworkInformation, IState, IUseNetworkState, KeyModifier, MousePressedOptions, MouseSourceType, OrientationState, RafLoopReturns, ScrollIntoViewAnimation, ScrollIntoViewParams, State, Status, Target, UseDarkOptions, UseDraggableOptions, UseElementBoundingOptions, UseEventEmitterReturn, UseEyeDropperReturn, UseFileDialogOptions, UseFpsOptions, UseFullScreenOptions, UseInfiniteScrollOptions, UseLongPressOptions, UseMeasureRect, UseMediaDeviceOptions, UseModifierOptions, UseScriptTagOptions, UseScrollOptions, UseStickyParams, UseTextDirectionOptions, UseTextDirectionValue, UseTimeoutFnOptions, UseVirtualListItem, UseVirtualListOptions, UseVirtualListReturn, WindowSize, getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, _default$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, _default$1 as useOnceEffect, _default as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, _default$4 as useUpdateEffect, _default$3 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.mjs
CHANGED
|
@@ -36,7 +36,7 @@ const createUpdateEffect = (hook) => (effect, deps) => {
|
|
|
36
36
|
|
|
37
37
|
var useUpdateEffect = createUpdateEffect(useEffect);
|
|
38
38
|
|
|
39
|
-
var index$
|
|
39
|
+
var index$3 = createUpdateEffect(useLayoutEffect);
|
|
40
40
|
|
|
41
41
|
var _a;
|
|
42
42
|
const isFunction$1 = (val) => typeof val === "function";
|
|
@@ -3433,8 +3433,9 @@ var __async$4 = (__this, __arguments, generator) => {
|
|
|
3433
3433
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
3434
3434
|
});
|
|
3435
3435
|
};
|
|
3436
|
+
const defaultConstints = { audio: true, video: true };
|
|
3436
3437
|
function useMediaDevices(options = {}) {
|
|
3437
|
-
const { requestPermissions, constraints =
|
|
3438
|
+
const { requestPermissions, constraints = defaultConstints } = options;
|
|
3438
3439
|
const [state, setState] = useState({ devices: [] });
|
|
3439
3440
|
const isSupported = useSupported(
|
|
3440
3441
|
() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices
|
|
@@ -3464,10 +3465,15 @@ function useMediaDevices(options = {}) {
|
|
|
3464
3465
|
if (permissionGranted.current) {
|
|
3465
3466
|
return true;
|
|
3466
3467
|
}
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3468
|
+
let state2;
|
|
3469
|
+
try {
|
|
3470
|
+
state2 = (yield navigator.permissions.query({
|
|
3471
|
+
name: "camera"
|
|
3472
|
+
})).state;
|
|
3473
|
+
} catch (error) {
|
|
3474
|
+
state2 = "prompt";
|
|
3475
|
+
}
|
|
3476
|
+
if (state2 !== "granted") {
|
|
3471
3477
|
stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
3472
3478
|
onChange();
|
|
3473
3479
|
permissionGranted.current = true;
|
|
@@ -3491,9 +3497,6 @@ function useMediaDevices(options = {}) {
|
|
|
3491
3497
|
}, [onChange, isSupported, requestPermissions, ensurePermissions]);
|
|
3492
3498
|
return [state, ensurePermissions];
|
|
3493
3499
|
}
|
|
3494
|
-
const useMediaDevicesMock = () => [{ devices: [] }, () => {
|
|
3495
|
-
}];
|
|
3496
|
-
var index$3 = isNavigator && !!navigator.mediaDevices ? useMediaDevices : useMediaDevicesMock;
|
|
3497
3500
|
|
|
3498
3501
|
function useTextDirection(options = {}) {
|
|
3499
3502
|
const { selector = "html", initialValue = "ltr" } = options;
|
|
@@ -5605,4 +5608,4 @@ function useMeasure(target, options = {}) {
|
|
|
5605
5608
|
return [rect, stop];
|
|
5606
5609
|
}
|
|
5607
5610
|
|
|
5608
|
-
export { getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, index$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure,
|
|
5611
|
+
export { getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, index$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, index$1 as useOnceEffect, index as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, index$3 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
|