@reactuses/core 6.0.5 → 6.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/README.md CHANGED
@@ -27,6 +27,20 @@ Collection of essential React Hooks Utilities.
27
27
 
28
28
  <hr>
29
29
 
30
+ ## MCP Support
31
+
32
+ If you want to use the MCP (Meta Command Protocol) integration with reactuse, you can easily set it up with the following configuration. This allows you to run the `@reactuses/mcp` utility via `npx` for enhanced command-line support and automation.
33
+
34
+ Add the following to your configuration:
35
+
36
+ ```json
37
+ "@reactuses/mcp": {
38
+ "command": "npx",
39
+ "args": ["-y", "@reactuses/mcp@latest"],
40
+ "type": "stdio"
41
+ }
42
+ ```
43
+
30
44
  ## QuickStart
31
45
 
32
46
  ```tsx harmony
@@ -50,6 +64,13 @@ Refer to [documentations](https://reactuse.com/) for more details.
50
64
 
51
65
  <hr>
52
66
 
67
+ ## Who's Using This
68
+
69
+ [![PDD](https://img.shields.io/badge/PDD-E_Commerce-orange?style=for-the-badge)](https://www.pinduoduo.com/)
70
+ [![Ctrip](https://img.shields.io/badge/Ctrip-Travel-blue?style=for-the-badge)](https://www.ctrip.com/)
71
+
72
+ <hr>
73
+
53
74
  ## Documentation & Live Examples
54
75
 
55
76
  - [Documentation](https://reactuse.com/)
package/dist/index.cjs CHANGED
@@ -206,12 +206,12 @@ function _async_to_generator$7(fn) {
206
206
  const useAsyncEffect = (effect, cleanup = noop, deps)=>{
207
207
  const mounted = useMountedState();
208
208
  React.useEffect(()=>{
209
- const execute = /*#__PURE__*/ _async_to_generator$7(function*() {
210
- if (!mounted()) {
211
- return;
212
- }
213
- yield effect();
214
- });
209
+ const execute = ()=>_async_to_generator$7(function*() {
210
+ if (!mounted()) {
211
+ return;
212
+ }
213
+ yield effect();
214
+ })();
215
215
  execute();
216
216
  return ()=>{
217
217
  cleanup();
@@ -1254,15 +1254,15 @@ function _async_to_generator$6(fn) {
1254
1254
  }
1255
1255
  const useEyeDropper = ()=>{
1256
1256
  const isSupported = useSupported(()=>typeof window !== 'undefined' && 'EyeDropper' in window, true);
1257
- const open = React.useCallback(/*#__PURE__*/ _async_to_generator$6(function*(options = {}) {
1258
- if (!isSupported) {
1259
- return {
1260
- sRGBHex: ''
1261
- };
1262
- }
1263
- const eyeDropper = new window.EyeDropper();
1264
- return eyeDropper.open(options);
1265
- }), [
1257
+ const open = React.useCallback((options = {})=>_async_to_generator$6(function*() {
1258
+ if (!isSupported) {
1259
+ return {
1260
+ sRGBHex: ''
1261
+ };
1262
+ }
1263
+ const eyeDropper = new window.EyeDropper();
1264
+ return eyeDropper.open(options);
1265
+ })(), [
1266
1266
  isSupported
1267
1267
  ]);
1268
1268
  return [
@@ -1355,20 +1355,20 @@ const useFileDialog = (options = defaultOptions$1)=>{
1355
1355
  return input;
1356
1356
  }, []);
1357
1357
  inputRef.current = initFn();
1358
- const open = /*#__PURE__*/ _async_to_generator$5(function*(localOptions) {
1359
- if (!inputRef.current) {
1360
- return;
1361
- }
1362
- const _options = _extends$3({}, DEFAULT_OPTIONS, options, localOptions);
1363
- inputRef.current.multiple = _options.multiple;
1364
- inputRef.current.accept = _options.accept;
1365
- inputRef.current.capture = _options.capture;
1366
- fileOpenPromiseRef.current = new Promise((resolve)=>{
1367
- resolveFileOpenPromiseRef.current = resolve;
1368
- });
1369
- inputRef.current.click();
1370
- return fileOpenPromiseRef.current;
1371
- });
1358
+ const open = (localOptions)=>_async_to_generator$5(function*() {
1359
+ if (!inputRef.current) {
1360
+ return;
1361
+ }
1362
+ const _options = _extends$3({}, DEFAULT_OPTIONS, options, localOptions);
1363
+ inputRef.current.multiple = _options.multiple;
1364
+ inputRef.current.accept = _options.accept;
1365
+ inputRef.current.capture = _options.capture;
1366
+ fileOpenPromiseRef.current = new Promise((resolve)=>{
1367
+ resolveFileOpenPromiseRef.current = resolve;
1368
+ });
1369
+ inputRef.current.click();
1370
+ return fileOpenPromiseRef.current;
1371
+ })();
1372
1372
  const reset = ()=>{
1373
1373
  setFiles(null);
1374
1374
  resolveFileOpenPromiseRef.current == null ? void 0 : resolveFileOpenPromiseRef.current.call(resolveFileOpenPromiseRef, null);
@@ -1821,20 +1821,20 @@ const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1821
1821
  const di = state[3][direction];
1822
1822
  useUpdateEffect(()=>{
1823
1823
  const element = getTargetElement(target);
1824
- const fn = /*#__PURE__*/ _async_to_generator$4(function*() {
1825
- var _element_scrollHeight, _element_scrollWidth;
1826
- const previous = {
1827
- height: (_element_scrollHeight = element == null ? void 0 : element.scrollHeight) != null ? _element_scrollHeight : 0,
1828
- width: (_element_scrollWidth = element == null ? void 0 : element.scrollWidth) != null ? _element_scrollWidth : 0
1829
- };
1830
- yield savedLoadMore.current(state);
1831
- if (options.preserveScrollPosition && element) {
1832
- element.scrollTo({
1833
- top: element.scrollHeight - previous.height,
1834
- left: element.scrollWidth - previous.width
1835
- });
1836
- }
1837
- });
1824
+ const fn = ()=>_async_to_generator$4(function*() {
1825
+ var _element_scrollHeight, _element_scrollWidth;
1826
+ const previous = {
1827
+ height: (_element_scrollHeight = element == null ? void 0 : element.scrollHeight) != null ? _element_scrollHeight : 0,
1828
+ width: (_element_scrollWidth = element == null ? void 0 : element.scrollWidth) != null ? _element_scrollWidth : 0
1829
+ };
1830
+ yield savedLoadMore.current(state);
1831
+ if (options.preserveScrollPosition && element) {
1832
+ element.scrollTo({
1833
+ top: element.scrollHeight - previous.height,
1834
+ left: element.scrollWidth - previous.width
1835
+ });
1836
+ }
1837
+ })();
1838
1838
  fn();
1839
1839
  }, [
1840
1840
  di,
@@ -2028,30 +2028,30 @@ const useMediaDevices = (options = {})=>{
2028
2028
  });
2029
2029
  }).catch(noop);
2030
2030
  }, []);
2031
- const ensurePermissions = React.useCallback(/*#__PURE__*/ _async_to_generator$3(function*() {
2032
- if (!isSupported) {
2033
- return false;
2034
- }
2035
- if (permissionGranted.current) {
2036
- return true;
2037
- }
2038
- let state;
2039
- try {
2040
- state = (yield navigator.permissions.query({
2041
- name: 'camera'
2042
- })).state;
2043
- } catch (error) {
2044
- state = 'prompt';
2045
- }
2046
- if (state !== 'granted') {
2047
- stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
2048
- onChange();
2049
- permissionGranted.current = true;
2050
- } else {
2051
- permissionGranted.current = false;
2052
- }
2053
- return permissionGranted.current;
2054
- }), [
2031
+ const ensurePermissions = React.useCallback(()=>_async_to_generator$3(function*() {
2032
+ if (!isSupported) {
2033
+ return false;
2034
+ }
2035
+ if (permissionGranted.current) {
2036
+ return true;
2037
+ }
2038
+ let state;
2039
+ try {
2040
+ state = (yield navigator.permissions.query({
2041
+ name: 'camera'
2042
+ })).state;
2043
+ } catch (error) {
2044
+ state = 'prompt';
2045
+ }
2046
+ if (state !== 'granted') {
2047
+ stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
2048
+ onChange();
2049
+ permissionGranted.current = true;
2050
+ } else {
2051
+ permissionGranted.current = false;
2052
+ }
2053
+ return permissionGranted.current;
2054
+ })(), [
2055
2055
  onChange,
2056
2056
  isSupported,
2057
2057
  constraints
@@ -2845,15 +2845,24 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = 'y', onScrol
2845
2845
  };
2846
2846
  };
2847
2847
 
2848
+ function checkOverflowScroll(ele) {
2849
+ const style = window.getComputedStyle(ele);
2850
+ if (style.overflowX === 'scroll' || style.overflowY === 'scroll' || style.overflowX === 'auto' && ele.clientWidth < ele.scrollWidth || style.overflowY === 'auto' && ele.clientHeight < ele.scrollHeight) {
2851
+ return true;
2852
+ } else {
2853
+ const parent = ele.parentNode;
2854
+ if (!parent || parent.tagName === 'BODY') return false;
2855
+ return checkOverflowScroll(parent);
2856
+ }
2857
+ }
2848
2858
  function preventDefault(rawEvent) {
2849
2859
  const e = rawEvent || window.event;
2860
+ const _target = e.target;
2861
+ // Do not prevent if element or parentNodes have overflow: scroll set.
2862
+ if (checkOverflowScroll(_target)) return false;
2850
2863
  // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
2851
- if (e.touches.length > 1) {
2852
- return true;
2853
- }
2854
- if (e.preventDefault) {
2855
- e.preventDefault();
2856
- }
2864
+ if (e.touches.length > 1) return true;
2865
+ if (e.preventDefault) e.preventDefault();
2857
2866
  return false;
2858
2867
  }
2859
2868
  const useScrollLock = (target, initialState = false)=>{
@@ -3166,14 +3175,14 @@ const useWebNotification = (requestPermissions = false)=>{
3166
3175
  }, [
3167
3176
  isSupported
3168
3177
  ]);
3169
- const ensurePermissions = React.useCallback(/*#__PURE__*/ _async_to_generator$2(function*() {
3170
- if (!isSupported) return;
3171
- if (!permissionGranted.current && Notification.permission !== 'denied') {
3172
- const result = yield Notification.requestPermission();
3173
- if (result === 'granted') permissionGranted.current = true;
3174
- }
3175
- return permissionGranted.current;
3176
- }), [
3178
+ const ensurePermissions = React.useCallback(()=>_async_to_generator$2(function*() {
3179
+ if (!isSupported) return;
3180
+ if (!permissionGranted.current && Notification.permission !== 'denied') {
3181
+ const result = yield Notification.requestPermission();
3182
+ if (result === 'granted') permissionGranted.current = true;
3183
+ }
3184
+ return permissionGranted.current;
3185
+ })(), [
3177
3186
  isSupported
3178
3187
  ]);
3179
3188
  React.useEffect(()=>{
@@ -3308,33 +3317,33 @@ function _async_to_generator$1(fn) {
3308
3317
  }
3309
3318
  const useClipboard = ()=>{
3310
3319
  const [text, setText] = React.useState('');
3311
- const updateText = React.useCallback(/*#__PURE__*/ _async_to_generator$1(function*() {
3312
- // Check if document is focused before attempting to read clipboard
3313
- if (!document.hasFocus()) {
3314
- return;
3315
- }
3316
- try {
3317
- const value = yield window.navigator.clipboard.readText();
3318
- setText(value);
3319
- } catch (error) {
3320
- // Handle cases where clipboard access is denied or unavailable
3321
- console.warn('Failed to read clipboard:', error);
3322
- }
3323
- }), []);
3320
+ const updateText = React.useCallback(()=>_async_to_generator$1(function*() {
3321
+ // Check if document is focused before attempting to read clipboard
3322
+ if (!document.hasFocus()) {
3323
+ return;
3324
+ }
3325
+ try {
3326
+ const value = yield window.navigator.clipboard.readText();
3327
+ setText(value);
3328
+ } catch (error) {
3329
+ // Handle cases where clipboard access is denied or unavailable
3330
+ console.warn('Failed to read clipboard:', error);
3331
+ }
3332
+ })(), []);
3324
3333
  useEventListener('copy', updateText);
3325
3334
  useEventListener('cut', updateText);
3326
3335
  // Also listen for focus events to update clipboard when window regains focus
3327
3336
  useEventListener('focus', updateText, window);
3328
- const copy = React.useCallback(/*#__PURE__*/ _async_to_generator$1(function*(txt) {
3329
- setText(txt);
3330
- try {
3331
- yield window.navigator.clipboard.writeText(txt);
3332
- } catch (error) {
3333
- console.warn('Failed to write to clipboard:', error);
3334
- throw error // Re-throw so caller can handle it
3335
- ;
3336
- }
3337
- }), []);
3337
+ const copy = React.useCallback((txt)=>_async_to_generator$1(function*() {
3338
+ setText(txt);
3339
+ try {
3340
+ yield window.navigator.clipboard.writeText(txt);
3341
+ } catch (error) {
3342
+ console.warn('Failed to write to clipboard:', error);
3343
+ throw error // Re-throw so caller can handle it
3344
+ ;
3345
+ }
3346
+ })(), []);
3338
3347
  React.useEffect(()=>{
3339
3348
  updateText();
3340
3349
  }, [
@@ -3904,98 +3913,98 @@ const useFetchEventSource = (url, options = {})=>{
3904
3913
  options.onClose == null ? void 0 : options.onClose.call(options);
3905
3914
  }
3906
3915
  });
3907
- const open = useEvent(/*#__PURE__*/ _async_to_generator(function*() {
3908
- close();
3909
- setStatus('CONNECTING');
3910
- explicitlyClosed.current = false;
3911
- retries.current = 0;
3912
- // 创建新的 AbortController
3913
- abortController.current = new AbortController();
3914
- try {
3915
- // 从选项中提取 FetchEventSourceInit 相关的选项
3916
- const { immediate, autoReconnect, onOpen, onMessage, onError, onClose, withCredentials, body } = options, fetchOptions = _object_without_properties_loose(options, [
3917
- "immediate",
3918
- "autoReconnect",
3919
- "onOpen",
3920
- "onMessage",
3921
- "onError",
3922
- "onClose",
3923
- "withCredentials",
3924
- "body"
3925
- ]);
3926
- // 构建请求配置
3927
- const finalOptions = _extends({
3928
- method: options.method || 'GET',
3929
- headers: _extends({
3930
- 'Accept': 'text/event-stream',
3931
- 'Cache-Control': 'no-cache',
3932
- 'Connection': 'keep-alive'
3933
- }, options.headers),
3934
- signal: abortController.current.signal,
3935
- credentials: withCredentials ? 'include' : 'same-origin'
3936
- }, fetchOptions);
3937
- // 只在 POST 请求时添加 body
3938
- if (options.method === 'POST' && body) {
3939
- finalOptions.body = body;
3940
- finalOptions.headers = _extends({}, finalOptions.headers, {
3941
- 'Content-Type': 'application/json'
3942
- });
3943
- }
3944
- yield fetchEventSource.fetchEventSource(url.toString(), _extends({}, finalOptions, {
3945
- onopen (response) {
3946
- return _async_to_generator(function*() {
3947
- if (response.ok) {
3948
- setStatus('CONNECTED');
3949
- setError(null);
3950
- options.onOpen == null ? void 0 : options.onOpen.call(options);
3951
- } else {
3952
- const error = new Error(`Failed to connect: ${response.status} ${response.statusText}`);
3953
- setError(error);
3954
- throw error;
3916
+ const open = useEvent(()=>_async_to_generator(function*() {
3917
+ close();
3918
+ setStatus('CONNECTING');
3919
+ explicitlyClosed.current = false;
3920
+ retries.current = 0;
3921
+ // 创建新的 AbortController
3922
+ abortController.current = new AbortController();
3923
+ try {
3924
+ // 从选项中提取 FetchEventSourceInit 相关的选项
3925
+ const { immediate, autoReconnect, onOpen, onMessage, onError, onClose, withCredentials, body } = options, fetchOptions = _object_without_properties_loose(options, [
3926
+ "immediate",
3927
+ "autoReconnect",
3928
+ "onOpen",
3929
+ "onMessage",
3930
+ "onError",
3931
+ "onClose",
3932
+ "withCredentials",
3933
+ "body"
3934
+ ]);
3935
+ // 构建请求配置
3936
+ const finalOptions = _extends({
3937
+ method: options.method || 'GET',
3938
+ headers: _extends({
3939
+ 'Accept': 'text/event-stream',
3940
+ 'Cache-Control': 'no-cache',
3941
+ 'Connection': 'keep-alive'
3942
+ }, options.headers),
3943
+ signal: abortController.current.signal,
3944
+ credentials: withCredentials ? 'include' : 'same-origin'
3945
+ }, fetchOptions);
3946
+ // 只在 POST 请求时添加 body
3947
+ if (options.method === 'POST' && body) {
3948
+ finalOptions.body = body;
3949
+ finalOptions.headers = _extends({}, finalOptions.headers, {
3950
+ 'Content-Type': 'application/json'
3951
+ });
3952
+ }
3953
+ yield fetchEventSource.fetchEventSource(url.toString(), _extends({}, finalOptions, {
3954
+ onopen (response) {
3955
+ return _async_to_generator(function*() {
3956
+ if (response.ok) {
3957
+ setStatus('CONNECTED');
3958
+ setError(null);
3959
+ options.onOpen == null ? void 0 : options.onOpen.call(options);
3960
+ } else {
3961
+ const error = new Error(`Failed to connect: ${response.status} ${response.statusText}`);
3962
+ setError(error);
3963
+ throw error;
3964
+ }
3965
+ })();
3966
+ },
3967
+ onmessage (msg) {
3968
+ if (!explicitlyClosed.current) {
3969
+ setData(msg.data);
3970
+ var _msg_id;
3971
+ setLastEventId((_msg_id = msg.id) != null ? _msg_id : null);
3972
+ setEvent(msg.event || null);
3973
+ options.onMessage == null ? void 0 : options.onMessage.call(options, msg);
3974
+ }
3975
+ },
3976
+ onerror (err) {
3977
+ setError(err);
3978
+ setStatus('DISCONNECTED');
3979
+ const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3980
+ if (options.autoReconnect && !explicitlyClosed.current) {
3981
+ const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3982
+ retries.current += 1;
3983
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3984
+ return retryDelay != null ? retryDelay : delay;
3985
+ } else {
3986
+ onFailed == null ? void 0 : onFailed();
3987
+ throw err;
3988
+ }
3989
+ }
3990
+ throw err;
3991
+ },
3992
+ onclose () {
3993
+ if (!explicitlyClosed.current) {
3994
+ setStatus('DISCONNECTED');
3995
+ options.onClose == null ? void 0 : options.onClose.call(options);
3955
3996
  }
3956
- })();
3957
- },
3958
- onmessage (msg) {
3959
- if (!explicitlyClosed.current) {
3960
- setData(msg.data);
3961
- var _msg_id;
3962
- setLastEventId((_msg_id = msg.id) != null ? _msg_id : null);
3963
- setEvent(msg.event || null);
3964
- options.onMessage == null ? void 0 : options.onMessage.call(options, msg);
3965
3997
  }
3966
- },
3967
- onerror (err) {
3998
+ }));
3999
+ } catch (err) {
4000
+ // 只处理非主动关闭导致的错误
4001
+ if (!explicitlyClosed.current) {
4002
+ console.error('EventSource Error:', err);
3968
4003
  setError(err);
3969
4004
  setStatus('DISCONNECTED');
3970
- const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3971
- if (options.autoReconnect && !explicitlyClosed.current) {
3972
- const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3973
- retries.current += 1;
3974
- if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3975
- return retryDelay != null ? retryDelay : delay;
3976
- } else {
3977
- onFailed == null ? void 0 : onFailed();
3978
- throw err;
3979
- }
3980
- }
3981
- throw err;
3982
- },
3983
- onclose () {
3984
- if (!explicitlyClosed.current) {
3985
- setStatus('DISCONNECTED');
3986
- options.onClose == null ? void 0 : options.onClose.call(options);
3987
- }
3988
4005
  }
3989
- }));
3990
- } catch (err) {
3991
- // 只处理非主动关闭导致的错误
3992
- if (!explicitlyClosed.current) {
3993
- console.error('EventSource Error:', err);
3994
- setError(err);
3995
- setStatus('DISCONNECTED');
3996
4006
  }
3997
- }
3998
- }));
4007
+ })());
3999
4008
  React.useEffect(()=>{
4000
4009
  if (options.immediate !== false) {
4001
4010
  open();
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import react__default, { DependencyList, MutableRefObject, EffectCallback, Dispatch, SetStateAction, RefObject, useEffect, useLayoutEffect, Ref, Context } from 'react';
2
+ import react__default, { DependencyList, MutableRefObject, EffectCallback, RefObject, Dispatch, SetStateAction, useEffect, useLayoutEffect, Ref, Context } from 'react';
3
3
  import Cookies from 'js-cookie';
4
4
  import { DebounceSettings, ThrottleSettings, DebouncedFunc as DebouncedFunc$1 } from 'lodash-es';
5
5
  import * as lodash from 'lodash';
@@ -3596,4 +3596,5 @@ type Use = <T>(
3596
3596
  */
3597
3597
  usable: Usable<T>) => T;
3598
3598
 
3599
- export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventSourceStatus, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type PossibleRef, type Use, type UseActiveElement, type UseAsyncEffect, type UseBroadcastChannel, type UseBroadcastChannelOptions, type UseBroadcastChannelReturn, type UseClickOutside, type UseClipboard, type UseControlled, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDevicePixelRatio, type UseDevicePixelRatioReturn, type UseDisclosure, type UseDisclosureProps, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementByPoint, type UseElementByPointOptions, type UseElementByPointReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEventSource, type UseEventSourceAutoReconnectOptions, type UseEventSourceOptions, type UseEventSourceReturn, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFetchEventSource, type UseFetchEventSourceAutoReconnectOptions, type UseFetchEventSourceMessage, type UseFetchEventSourceOptions, type UseFetchEventSourceReturn, type UseFetchEventSourceStatus, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMergedRef, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePreferredLanguages, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3599
+ export { assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3600
+ export type { ColorScheme, Contrast, DepsEqualFnType, EventSourceStatus, EventType, INetworkInformation, IUseNetworkState, KeyModifier, Pausable, Platform, PossibleRef, Use, UseActiveElement, UseAsyncEffect, UseBroadcastChannel, UseBroadcastChannelOptions, UseBroadcastChannelReturn, UseClickOutside, UseClipboard, UseControlled, UseCookie, UseCookieState, UseCountDown, UseCounter, UseCssVar, UseCssVarOptions, UseCustomCompareEffect, UseCycleList, UseDarkMode, UseDarkOptions, UseDebounce, UseDebounceFn, UseDeepCompareEffect, UseDevicePixelRatio, UseDevicePixelRatioReturn, UseDisclosure, UseDisclosureProps, UseDocumentVisibility, UseDoubleClick, UseDoubleClickProps, UseDraggable, UseDraggableOptions, UseDropZone, UseElementBounding, UseElementBoundingOptions, UseElementBoundingReturn, UseElementByPoint, UseElementByPointOptions, UseElementByPointReturn, UseElementSize, UseElementVisibility, UseEvent, UseEventEmitter, UseEventEmitterDisposable, UseEventEmitterEvent, UseEventEmitterEventOnce, UseEventEmitterListener, UseEventEmitterReturn, UseEventListener, UseEventSource, UseEventSourceAutoReconnectOptions, UseEventSourceOptions, UseEventSourceReturn, UseEyeDropper, UseEyeDropperOpenOptions, UseEyeDropperOpenReturnType, UseFavicon, UseFetchEventSource, UseFetchEventSourceAutoReconnectOptions, UseFetchEventSourceMessage, UseFetchEventSourceOptions, UseFetchEventSourceReturn, UseFetchEventSourceStatus, UseFileDialog, UseFileDialogOptions, UseFirstMountState, UseFocus, UseFps, UseFpsOptions, UseFullScreenOptions, UseFullscreen, UseGeolocation, UseHover, UseIdle, UseInfiniteScroll, UseInfiniteScrollArrivedState, UseInfiniteScrollDirection, UseInfiniteScrollLoadMore, UseInfiniteScrollOptions, UseIntersectionObserver, UseInterval, UseIntervalOptions, UseKeyModifier, UseLatest, UseLocalStorage, UseLocalStorageOptions, UseLocalStorageSerializer, UseLocationSelector, UseLongPress, UseLongPressOptions, UseMeasure, UseMeasureRect, UseMediaDeviceOptions, UseMediaDevices, UseMediaQuery, UseMergedRef, UseMobileLandscape, UseModifierOptions, UseMount, UseMountedState, UseMouse, UseMouseCursorState, UseMousePressed, UseMousePressedOptions, UseMousePressedSourceType, UseMutationObserver, UseNetwork, UseObjectUrl, UseOnline, UseOrientation, UseOrientationLockType, UseOrientationState, UseOrientationType, UsePageLeave, UsePermission, UsePermissionDescriptorNamePolyfill, UsePermissionGeneralPermissionDescriptor, UsePermissionState, UsePlatform, UsePlatformProps, UsePlatformReturn, UsePreferredColorScheme, UsePreferredContrast, UsePreferredDark, UsePreferredLanguages, UsePrevious, UseRafFn, UseRafState, UseReducedMotion, UseResizeObserver, UseScreenSafeArea, UseScriptTag, UseScriptTagOptions, UseScriptTagStatus, UseScroll, UseScrollArrivedState, UseScrollDirection, UseScrollIntoView, UseScrollIntoViewAnimation, UseScrollIntoViewParams, UseScrollLock, UseScrollOffset, UseScrollOptions, UseSessionStorage, UseSessionStorageOptions, UseSessionStorageSerializer, UseSetState, UseSticky, UseStickyParams, UseSupported, UseTextDirection, UseTextDirectionOptions, UseTextDirectionValue, UseTextSelection, UseThrottle, UseThrottleFn, UseTimeout, UseTimeoutFn, UseTimeoutFnOptions, UseTimeoutOptions, UseTitle, UseToggle, UseUnmount, UseUpdate, UseWebNotification, UseWebNotificationReturn, UseWebNotificationShow, UseWindowScroll, UseWindowScrollState, UseWindowSize, UseWindowsFocus };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import react__default, { DependencyList, MutableRefObject, EffectCallback, Dispatch, SetStateAction, RefObject, useEffect, useLayoutEffect, Ref, Context } from 'react';
2
+ import react__default, { DependencyList, MutableRefObject, EffectCallback, RefObject, Dispatch, SetStateAction, useEffect, useLayoutEffect, Ref, Context } from 'react';
3
3
  import Cookies from 'js-cookie';
4
4
  import { DebounceSettings, ThrottleSettings, DebouncedFunc as DebouncedFunc$1 } from 'lodash-es';
5
5
  import * as lodash from 'lodash';
@@ -3596,4 +3596,5 @@ type Use = <T>(
3596
3596
  */
3597
3597
  usable: Usable<T>) => T;
3598
3598
 
3599
- export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventSourceStatus, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type PossibleRef, type Use, type UseActiveElement, type UseAsyncEffect, type UseBroadcastChannel, type UseBroadcastChannelOptions, type UseBroadcastChannelReturn, type UseClickOutside, type UseClipboard, type UseControlled, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDevicePixelRatio, type UseDevicePixelRatioReturn, type UseDisclosure, type UseDisclosureProps, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementByPoint, type UseElementByPointOptions, type UseElementByPointReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEventSource, type UseEventSourceAutoReconnectOptions, type UseEventSourceOptions, type UseEventSourceReturn, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFetchEventSource, type UseFetchEventSourceAutoReconnectOptions, type UseFetchEventSourceMessage, type UseFetchEventSourceOptions, type UseFetchEventSourceReturn, type UseFetchEventSourceStatus, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMergedRef, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePreferredLanguages, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3599
+ export { assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3600
+ export type { ColorScheme, Contrast, DepsEqualFnType, EventSourceStatus, EventType, INetworkInformation, IUseNetworkState, KeyModifier, Pausable, Platform, PossibleRef, Use, UseActiveElement, UseAsyncEffect, UseBroadcastChannel, UseBroadcastChannelOptions, UseBroadcastChannelReturn, UseClickOutside, UseClipboard, UseControlled, UseCookie, UseCookieState, UseCountDown, UseCounter, UseCssVar, UseCssVarOptions, UseCustomCompareEffect, UseCycleList, UseDarkMode, UseDarkOptions, UseDebounce, UseDebounceFn, UseDeepCompareEffect, UseDevicePixelRatio, UseDevicePixelRatioReturn, UseDisclosure, UseDisclosureProps, UseDocumentVisibility, UseDoubleClick, UseDoubleClickProps, UseDraggable, UseDraggableOptions, UseDropZone, UseElementBounding, UseElementBoundingOptions, UseElementBoundingReturn, UseElementByPoint, UseElementByPointOptions, UseElementByPointReturn, UseElementSize, UseElementVisibility, UseEvent, UseEventEmitter, UseEventEmitterDisposable, UseEventEmitterEvent, UseEventEmitterEventOnce, UseEventEmitterListener, UseEventEmitterReturn, UseEventListener, UseEventSource, UseEventSourceAutoReconnectOptions, UseEventSourceOptions, UseEventSourceReturn, UseEyeDropper, UseEyeDropperOpenOptions, UseEyeDropperOpenReturnType, UseFavicon, UseFetchEventSource, UseFetchEventSourceAutoReconnectOptions, UseFetchEventSourceMessage, UseFetchEventSourceOptions, UseFetchEventSourceReturn, UseFetchEventSourceStatus, UseFileDialog, UseFileDialogOptions, UseFirstMountState, UseFocus, UseFps, UseFpsOptions, UseFullScreenOptions, UseFullscreen, UseGeolocation, UseHover, UseIdle, UseInfiniteScroll, UseInfiniteScrollArrivedState, UseInfiniteScrollDirection, UseInfiniteScrollLoadMore, UseInfiniteScrollOptions, UseIntersectionObserver, UseInterval, UseIntervalOptions, UseKeyModifier, UseLatest, UseLocalStorage, UseLocalStorageOptions, UseLocalStorageSerializer, UseLocationSelector, UseLongPress, UseLongPressOptions, UseMeasure, UseMeasureRect, UseMediaDeviceOptions, UseMediaDevices, UseMediaQuery, UseMergedRef, UseMobileLandscape, UseModifierOptions, UseMount, UseMountedState, UseMouse, UseMouseCursorState, UseMousePressed, UseMousePressedOptions, UseMousePressedSourceType, UseMutationObserver, UseNetwork, UseObjectUrl, UseOnline, UseOrientation, UseOrientationLockType, UseOrientationState, UseOrientationType, UsePageLeave, UsePermission, UsePermissionDescriptorNamePolyfill, UsePermissionGeneralPermissionDescriptor, UsePermissionState, UsePlatform, UsePlatformProps, UsePlatformReturn, UsePreferredColorScheme, UsePreferredContrast, UsePreferredDark, UsePreferredLanguages, UsePrevious, UseRafFn, UseRafState, UseReducedMotion, UseResizeObserver, UseScreenSafeArea, UseScriptTag, UseScriptTagOptions, UseScriptTagStatus, UseScroll, UseScrollArrivedState, UseScrollDirection, UseScrollIntoView, UseScrollIntoViewAnimation, UseScrollIntoViewParams, UseScrollLock, UseScrollOffset, UseScrollOptions, UseSessionStorage, UseSessionStorageOptions, UseSessionStorageSerializer, UseSetState, UseSticky, UseStickyParams, UseSupported, UseTextDirection, UseTextDirectionOptions, UseTextDirectionValue, UseTextSelection, UseThrottle, UseThrottleFn, UseTimeout, UseTimeoutFn, UseTimeoutFnOptions, UseTimeoutOptions, UseTitle, UseToggle, UseUnmount, UseUpdate, UseWebNotification, UseWebNotificationReturn, UseWebNotificationShow, UseWindowScroll, UseWindowScrollState, UseWindowSize, UseWindowsFocus };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import react__default, { DependencyList, MutableRefObject, EffectCallback, Dispatch, SetStateAction, RefObject, useEffect, useLayoutEffect, Ref, Context } from 'react';
2
+ import react__default, { DependencyList, MutableRefObject, EffectCallback, RefObject, Dispatch, SetStateAction, useEffect, useLayoutEffect, Ref, Context } from 'react';
3
3
  import Cookies from 'js-cookie';
4
4
  import { DebounceSettings, ThrottleSettings, DebouncedFunc as DebouncedFunc$1 } from 'lodash-es';
5
5
  import * as lodash from 'lodash';
@@ -3596,4 +3596,5 @@ type Use = <T>(
3596
3596
  */
3597
3597
  usable: Usable<T>) => T;
3598
3598
 
3599
- export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventSourceStatus, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type PossibleRef, type Use, type UseActiveElement, type UseAsyncEffect, type UseBroadcastChannel, type UseBroadcastChannelOptions, type UseBroadcastChannelReturn, type UseClickOutside, type UseClipboard, type UseControlled, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDevicePixelRatio, type UseDevicePixelRatioReturn, type UseDisclosure, type UseDisclosureProps, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementByPoint, type UseElementByPointOptions, type UseElementByPointReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEventSource, type UseEventSourceAutoReconnectOptions, type UseEventSourceOptions, type UseEventSourceReturn, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFetchEventSource, type UseFetchEventSourceAutoReconnectOptions, type UseFetchEventSourceMessage, type UseFetchEventSourceOptions, type UseFetchEventSourceReturn, type UseFetchEventSourceStatus, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMergedRef, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePreferredLanguages, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3599
+ export { assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
3600
+ export type { ColorScheme, Contrast, DepsEqualFnType, EventSourceStatus, EventType, INetworkInformation, IUseNetworkState, KeyModifier, Pausable, Platform, PossibleRef, Use, UseActiveElement, UseAsyncEffect, UseBroadcastChannel, UseBroadcastChannelOptions, UseBroadcastChannelReturn, UseClickOutside, UseClipboard, UseControlled, UseCookie, UseCookieState, UseCountDown, UseCounter, UseCssVar, UseCssVarOptions, UseCustomCompareEffect, UseCycleList, UseDarkMode, UseDarkOptions, UseDebounce, UseDebounceFn, UseDeepCompareEffect, UseDevicePixelRatio, UseDevicePixelRatioReturn, UseDisclosure, UseDisclosureProps, UseDocumentVisibility, UseDoubleClick, UseDoubleClickProps, UseDraggable, UseDraggableOptions, UseDropZone, UseElementBounding, UseElementBoundingOptions, UseElementBoundingReturn, UseElementByPoint, UseElementByPointOptions, UseElementByPointReturn, UseElementSize, UseElementVisibility, UseEvent, UseEventEmitter, UseEventEmitterDisposable, UseEventEmitterEvent, UseEventEmitterEventOnce, UseEventEmitterListener, UseEventEmitterReturn, UseEventListener, UseEventSource, UseEventSourceAutoReconnectOptions, UseEventSourceOptions, UseEventSourceReturn, UseEyeDropper, UseEyeDropperOpenOptions, UseEyeDropperOpenReturnType, UseFavicon, UseFetchEventSource, UseFetchEventSourceAutoReconnectOptions, UseFetchEventSourceMessage, UseFetchEventSourceOptions, UseFetchEventSourceReturn, UseFetchEventSourceStatus, UseFileDialog, UseFileDialogOptions, UseFirstMountState, UseFocus, UseFps, UseFpsOptions, UseFullScreenOptions, UseFullscreen, UseGeolocation, UseHover, UseIdle, UseInfiniteScroll, UseInfiniteScrollArrivedState, UseInfiniteScrollDirection, UseInfiniteScrollLoadMore, UseInfiniteScrollOptions, UseIntersectionObserver, UseInterval, UseIntervalOptions, UseKeyModifier, UseLatest, UseLocalStorage, UseLocalStorageOptions, UseLocalStorageSerializer, UseLocationSelector, UseLongPress, UseLongPressOptions, UseMeasure, UseMeasureRect, UseMediaDeviceOptions, UseMediaDevices, UseMediaQuery, UseMergedRef, UseMobileLandscape, UseModifierOptions, UseMount, UseMountedState, UseMouse, UseMouseCursorState, UseMousePressed, UseMousePressedOptions, UseMousePressedSourceType, UseMutationObserver, UseNetwork, UseObjectUrl, UseOnline, UseOrientation, UseOrientationLockType, UseOrientationState, UseOrientationType, UsePageLeave, UsePermission, UsePermissionDescriptorNamePolyfill, UsePermissionGeneralPermissionDescriptor, UsePermissionState, UsePlatform, UsePlatformProps, UsePlatformReturn, UsePreferredColorScheme, UsePreferredContrast, UsePreferredDark, UsePreferredLanguages, UsePrevious, UseRafFn, UseRafState, UseReducedMotion, UseResizeObserver, UseScreenSafeArea, UseScriptTag, UseScriptTagOptions, UseScriptTagStatus, UseScroll, UseScrollArrivedState, UseScrollDirection, UseScrollIntoView, UseScrollIntoViewAnimation, UseScrollIntoViewParams, UseScrollLock, UseScrollOffset, UseScrollOptions, UseSessionStorage, UseSessionStorageOptions, UseSessionStorageSerializer, UseSetState, UseSticky, UseStickyParams, UseSupported, UseTextDirection, UseTextDirectionOptions, UseTextDirectionValue, UseTextSelection, UseThrottle, UseThrottleFn, UseTimeout, UseTimeoutFn, UseTimeoutFnOptions, UseTimeoutOptions, UseTitle, UseToggle, UseUnmount, UseUpdate, UseWebNotification, UseWebNotificationReturn, UseWebNotificationShow, UseWindowScroll, UseWindowScrollState, UseWindowSize, UseWindowsFocus };
package/dist/index.mjs CHANGED
@@ -198,12 +198,12 @@ function _async_to_generator$7(fn) {
198
198
  const useAsyncEffect = (effect, cleanup = noop, deps)=>{
199
199
  const mounted = useMountedState();
200
200
  useEffect(()=>{
201
- const execute = /*#__PURE__*/ _async_to_generator$7(function*() {
202
- if (!mounted()) {
203
- return;
204
- }
205
- yield effect();
206
- });
201
+ const execute = ()=>_async_to_generator$7(function*() {
202
+ if (!mounted()) {
203
+ return;
204
+ }
205
+ yield effect();
206
+ })();
207
207
  execute();
208
208
  return ()=>{
209
209
  cleanup();
@@ -1246,15 +1246,15 @@ function _async_to_generator$6(fn) {
1246
1246
  }
1247
1247
  const useEyeDropper = ()=>{
1248
1248
  const isSupported = useSupported(()=>typeof window !== 'undefined' && 'EyeDropper' in window, true);
1249
- const open = useCallback(/*#__PURE__*/ _async_to_generator$6(function*(options = {}) {
1250
- if (!isSupported) {
1251
- return {
1252
- sRGBHex: ''
1253
- };
1254
- }
1255
- const eyeDropper = new window.EyeDropper();
1256
- return eyeDropper.open(options);
1257
- }), [
1249
+ const open = useCallback((options = {})=>_async_to_generator$6(function*() {
1250
+ if (!isSupported) {
1251
+ return {
1252
+ sRGBHex: ''
1253
+ };
1254
+ }
1255
+ const eyeDropper = new window.EyeDropper();
1256
+ return eyeDropper.open(options);
1257
+ })(), [
1258
1258
  isSupported
1259
1259
  ]);
1260
1260
  return [
@@ -1347,20 +1347,20 @@ const useFileDialog = (options = defaultOptions$1)=>{
1347
1347
  return input;
1348
1348
  }, []);
1349
1349
  inputRef.current = initFn();
1350
- const open = /*#__PURE__*/ _async_to_generator$5(function*(localOptions) {
1351
- if (!inputRef.current) {
1352
- return;
1353
- }
1354
- const _options = _extends$3({}, DEFAULT_OPTIONS, options, localOptions);
1355
- inputRef.current.multiple = _options.multiple;
1356
- inputRef.current.accept = _options.accept;
1357
- inputRef.current.capture = _options.capture;
1358
- fileOpenPromiseRef.current = new Promise((resolve)=>{
1359
- resolveFileOpenPromiseRef.current = resolve;
1360
- });
1361
- inputRef.current.click();
1362
- return fileOpenPromiseRef.current;
1363
- });
1350
+ const open = (localOptions)=>_async_to_generator$5(function*() {
1351
+ if (!inputRef.current) {
1352
+ return;
1353
+ }
1354
+ const _options = _extends$3({}, DEFAULT_OPTIONS, options, localOptions);
1355
+ inputRef.current.multiple = _options.multiple;
1356
+ inputRef.current.accept = _options.accept;
1357
+ inputRef.current.capture = _options.capture;
1358
+ fileOpenPromiseRef.current = new Promise((resolve)=>{
1359
+ resolveFileOpenPromiseRef.current = resolve;
1360
+ });
1361
+ inputRef.current.click();
1362
+ return fileOpenPromiseRef.current;
1363
+ })();
1364
1364
  const reset = ()=>{
1365
1365
  setFiles(null);
1366
1366
  resolveFileOpenPromiseRef.current == null ? void 0 : resolveFileOpenPromiseRef.current.call(resolveFileOpenPromiseRef, null);
@@ -1813,20 +1813,20 @@ const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1813
1813
  const di = state[3][direction];
1814
1814
  useUpdateEffect(()=>{
1815
1815
  const element = getTargetElement(target);
1816
- const fn = /*#__PURE__*/ _async_to_generator$4(function*() {
1817
- var _element_scrollHeight, _element_scrollWidth;
1818
- const previous = {
1819
- height: (_element_scrollHeight = element == null ? void 0 : element.scrollHeight) != null ? _element_scrollHeight : 0,
1820
- width: (_element_scrollWidth = element == null ? void 0 : element.scrollWidth) != null ? _element_scrollWidth : 0
1821
- };
1822
- yield savedLoadMore.current(state);
1823
- if (options.preserveScrollPosition && element) {
1824
- element.scrollTo({
1825
- top: element.scrollHeight - previous.height,
1826
- left: element.scrollWidth - previous.width
1827
- });
1828
- }
1829
- });
1816
+ const fn = ()=>_async_to_generator$4(function*() {
1817
+ var _element_scrollHeight, _element_scrollWidth;
1818
+ const previous = {
1819
+ height: (_element_scrollHeight = element == null ? void 0 : element.scrollHeight) != null ? _element_scrollHeight : 0,
1820
+ width: (_element_scrollWidth = element == null ? void 0 : element.scrollWidth) != null ? _element_scrollWidth : 0
1821
+ };
1822
+ yield savedLoadMore.current(state);
1823
+ if (options.preserveScrollPosition && element) {
1824
+ element.scrollTo({
1825
+ top: element.scrollHeight - previous.height,
1826
+ left: element.scrollWidth - previous.width
1827
+ });
1828
+ }
1829
+ })();
1830
1830
  fn();
1831
1831
  }, [
1832
1832
  di,
@@ -2020,30 +2020,30 @@ const useMediaDevices = (options = {})=>{
2020
2020
  });
2021
2021
  }).catch(noop);
2022
2022
  }, []);
2023
- const ensurePermissions = useCallback(/*#__PURE__*/ _async_to_generator$3(function*() {
2024
- if (!isSupported) {
2025
- return false;
2026
- }
2027
- if (permissionGranted.current) {
2028
- return true;
2029
- }
2030
- let state;
2031
- try {
2032
- state = (yield navigator.permissions.query({
2033
- name: 'camera'
2034
- })).state;
2035
- } catch (error) {
2036
- state = 'prompt';
2037
- }
2038
- if (state !== 'granted') {
2039
- stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
2040
- onChange();
2041
- permissionGranted.current = true;
2042
- } else {
2043
- permissionGranted.current = false;
2044
- }
2045
- return permissionGranted.current;
2046
- }), [
2023
+ const ensurePermissions = useCallback(()=>_async_to_generator$3(function*() {
2024
+ if (!isSupported) {
2025
+ return false;
2026
+ }
2027
+ if (permissionGranted.current) {
2028
+ return true;
2029
+ }
2030
+ let state;
2031
+ try {
2032
+ state = (yield navigator.permissions.query({
2033
+ name: 'camera'
2034
+ })).state;
2035
+ } catch (error) {
2036
+ state = 'prompt';
2037
+ }
2038
+ if (state !== 'granted') {
2039
+ stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
2040
+ onChange();
2041
+ permissionGranted.current = true;
2042
+ } else {
2043
+ permissionGranted.current = false;
2044
+ }
2045
+ return permissionGranted.current;
2046
+ })(), [
2047
2047
  onChange,
2048
2048
  isSupported,
2049
2049
  constraints
@@ -2837,15 +2837,24 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = 'y', onScrol
2837
2837
  };
2838
2838
  };
2839
2839
 
2840
+ function checkOverflowScroll(ele) {
2841
+ const style = window.getComputedStyle(ele);
2842
+ if (style.overflowX === 'scroll' || style.overflowY === 'scroll' || style.overflowX === 'auto' && ele.clientWidth < ele.scrollWidth || style.overflowY === 'auto' && ele.clientHeight < ele.scrollHeight) {
2843
+ return true;
2844
+ } else {
2845
+ const parent = ele.parentNode;
2846
+ if (!parent || parent.tagName === 'BODY') return false;
2847
+ return checkOverflowScroll(parent);
2848
+ }
2849
+ }
2840
2850
  function preventDefault(rawEvent) {
2841
2851
  const e = rawEvent || window.event;
2852
+ const _target = e.target;
2853
+ // Do not prevent if element or parentNodes have overflow: scroll set.
2854
+ if (checkOverflowScroll(_target)) return false;
2842
2855
  // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
2843
- if (e.touches.length > 1) {
2844
- return true;
2845
- }
2846
- if (e.preventDefault) {
2847
- e.preventDefault();
2848
- }
2856
+ if (e.touches.length > 1) return true;
2857
+ if (e.preventDefault) e.preventDefault();
2849
2858
  return false;
2850
2859
  }
2851
2860
  const useScrollLock = (target, initialState = false)=>{
@@ -3158,14 +3167,14 @@ const useWebNotification = (requestPermissions = false)=>{
3158
3167
  }, [
3159
3168
  isSupported
3160
3169
  ]);
3161
- const ensurePermissions = useCallback(/*#__PURE__*/ _async_to_generator$2(function*() {
3162
- if (!isSupported) return;
3163
- if (!permissionGranted.current && Notification.permission !== 'denied') {
3164
- const result = yield Notification.requestPermission();
3165
- if (result === 'granted') permissionGranted.current = true;
3166
- }
3167
- return permissionGranted.current;
3168
- }), [
3170
+ const ensurePermissions = useCallback(()=>_async_to_generator$2(function*() {
3171
+ if (!isSupported) return;
3172
+ if (!permissionGranted.current && Notification.permission !== 'denied') {
3173
+ const result = yield Notification.requestPermission();
3174
+ if (result === 'granted') permissionGranted.current = true;
3175
+ }
3176
+ return permissionGranted.current;
3177
+ })(), [
3169
3178
  isSupported
3170
3179
  ]);
3171
3180
  useEffect(()=>{
@@ -3300,33 +3309,33 @@ function _async_to_generator$1(fn) {
3300
3309
  }
3301
3310
  const useClipboard = ()=>{
3302
3311
  const [text, setText] = useState('');
3303
- const updateText = useCallback(/*#__PURE__*/ _async_to_generator$1(function*() {
3304
- // Check if document is focused before attempting to read clipboard
3305
- if (!document.hasFocus()) {
3306
- return;
3307
- }
3308
- try {
3309
- const value = yield window.navigator.clipboard.readText();
3310
- setText(value);
3311
- } catch (error) {
3312
- // Handle cases where clipboard access is denied or unavailable
3313
- console.warn('Failed to read clipboard:', error);
3314
- }
3315
- }), []);
3312
+ const updateText = useCallback(()=>_async_to_generator$1(function*() {
3313
+ // Check if document is focused before attempting to read clipboard
3314
+ if (!document.hasFocus()) {
3315
+ return;
3316
+ }
3317
+ try {
3318
+ const value = yield window.navigator.clipboard.readText();
3319
+ setText(value);
3320
+ } catch (error) {
3321
+ // Handle cases where clipboard access is denied or unavailable
3322
+ console.warn('Failed to read clipboard:', error);
3323
+ }
3324
+ })(), []);
3316
3325
  useEventListener('copy', updateText);
3317
3326
  useEventListener('cut', updateText);
3318
3327
  // Also listen for focus events to update clipboard when window regains focus
3319
3328
  useEventListener('focus', updateText, window);
3320
- const copy = useCallback(/*#__PURE__*/ _async_to_generator$1(function*(txt) {
3321
- setText(txt);
3322
- try {
3323
- yield window.navigator.clipboard.writeText(txt);
3324
- } catch (error) {
3325
- console.warn('Failed to write to clipboard:', error);
3326
- throw error // Re-throw so caller can handle it
3327
- ;
3328
- }
3329
- }), []);
3329
+ const copy = useCallback((txt)=>_async_to_generator$1(function*() {
3330
+ setText(txt);
3331
+ try {
3332
+ yield window.navigator.clipboard.writeText(txt);
3333
+ } catch (error) {
3334
+ console.warn('Failed to write to clipboard:', error);
3335
+ throw error // Re-throw so caller can handle it
3336
+ ;
3337
+ }
3338
+ })(), []);
3330
3339
  useEffect(()=>{
3331
3340
  updateText();
3332
3341
  }, [
@@ -3896,98 +3905,98 @@ const useFetchEventSource = (url, options = {})=>{
3896
3905
  options.onClose == null ? void 0 : options.onClose.call(options);
3897
3906
  }
3898
3907
  });
3899
- const open = useEvent(/*#__PURE__*/ _async_to_generator(function*() {
3900
- close();
3901
- setStatus('CONNECTING');
3902
- explicitlyClosed.current = false;
3903
- retries.current = 0;
3904
- // 创建新的 AbortController
3905
- abortController.current = new AbortController();
3906
- try {
3907
- // 从选项中提取 FetchEventSourceInit 相关的选项
3908
- const { immediate, autoReconnect, onOpen, onMessage, onError, onClose, withCredentials, body } = options, fetchOptions = _object_without_properties_loose(options, [
3909
- "immediate",
3910
- "autoReconnect",
3911
- "onOpen",
3912
- "onMessage",
3913
- "onError",
3914
- "onClose",
3915
- "withCredentials",
3916
- "body"
3917
- ]);
3918
- // 构建请求配置
3919
- const finalOptions = _extends({
3920
- method: options.method || 'GET',
3921
- headers: _extends({
3922
- 'Accept': 'text/event-stream',
3923
- 'Cache-Control': 'no-cache',
3924
- 'Connection': 'keep-alive'
3925
- }, options.headers),
3926
- signal: abortController.current.signal,
3927
- credentials: withCredentials ? 'include' : 'same-origin'
3928
- }, fetchOptions);
3929
- // 只在 POST 请求时添加 body
3930
- if (options.method === 'POST' && body) {
3931
- finalOptions.body = body;
3932
- finalOptions.headers = _extends({}, finalOptions.headers, {
3933
- 'Content-Type': 'application/json'
3934
- });
3935
- }
3936
- yield fetchEventSource(url.toString(), _extends({}, finalOptions, {
3937
- onopen (response) {
3938
- return _async_to_generator(function*() {
3939
- if (response.ok) {
3940
- setStatus('CONNECTED');
3941
- setError(null);
3942
- options.onOpen == null ? void 0 : options.onOpen.call(options);
3943
- } else {
3944
- const error = new Error(`Failed to connect: ${response.status} ${response.statusText}`);
3945
- setError(error);
3946
- throw error;
3908
+ const open = useEvent(()=>_async_to_generator(function*() {
3909
+ close();
3910
+ setStatus('CONNECTING');
3911
+ explicitlyClosed.current = false;
3912
+ retries.current = 0;
3913
+ // 创建新的 AbortController
3914
+ abortController.current = new AbortController();
3915
+ try {
3916
+ // 从选项中提取 FetchEventSourceInit 相关的选项
3917
+ const { immediate, autoReconnect, onOpen, onMessage, onError, onClose, withCredentials, body } = options, fetchOptions = _object_without_properties_loose(options, [
3918
+ "immediate",
3919
+ "autoReconnect",
3920
+ "onOpen",
3921
+ "onMessage",
3922
+ "onError",
3923
+ "onClose",
3924
+ "withCredentials",
3925
+ "body"
3926
+ ]);
3927
+ // 构建请求配置
3928
+ const finalOptions = _extends({
3929
+ method: options.method || 'GET',
3930
+ headers: _extends({
3931
+ 'Accept': 'text/event-stream',
3932
+ 'Cache-Control': 'no-cache',
3933
+ 'Connection': 'keep-alive'
3934
+ }, options.headers),
3935
+ signal: abortController.current.signal,
3936
+ credentials: withCredentials ? 'include' : 'same-origin'
3937
+ }, fetchOptions);
3938
+ // 只在 POST 请求时添加 body
3939
+ if (options.method === 'POST' && body) {
3940
+ finalOptions.body = body;
3941
+ finalOptions.headers = _extends({}, finalOptions.headers, {
3942
+ 'Content-Type': 'application/json'
3943
+ });
3944
+ }
3945
+ yield fetchEventSource(url.toString(), _extends({}, finalOptions, {
3946
+ onopen (response) {
3947
+ return _async_to_generator(function*() {
3948
+ if (response.ok) {
3949
+ setStatus('CONNECTED');
3950
+ setError(null);
3951
+ options.onOpen == null ? void 0 : options.onOpen.call(options);
3952
+ } else {
3953
+ const error = new Error(`Failed to connect: ${response.status} ${response.statusText}`);
3954
+ setError(error);
3955
+ throw error;
3956
+ }
3957
+ })();
3958
+ },
3959
+ onmessage (msg) {
3960
+ if (!explicitlyClosed.current) {
3961
+ setData(msg.data);
3962
+ var _msg_id;
3963
+ setLastEventId((_msg_id = msg.id) != null ? _msg_id : null);
3964
+ setEvent(msg.event || null);
3965
+ options.onMessage == null ? void 0 : options.onMessage.call(options, msg);
3966
+ }
3967
+ },
3968
+ onerror (err) {
3969
+ setError(err);
3970
+ setStatus('DISCONNECTED');
3971
+ const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3972
+ if (options.autoReconnect && !explicitlyClosed.current) {
3973
+ const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3974
+ retries.current += 1;
3975
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3976
+ return retryDelay != null ? retryDelay : delay;
3977
+ } else {
3978
+ onFailed == null ? void 0 : onFailed();
3979
+ throw err;
3980
+ }
3981
+ }
3982
+ throw err;
3983
+ },
3984
+ onclose () {
3985
+ if (!explicitlyClosed.current) {
3986
+ setStatus('DISCONNECTED');
3987
+ options.onClose == null ? void 0 : options.onClose.call(options);
3947
3988
  }
3948
- })();
3949
- },
3950
- onmessage (msg) {
3951
- if (!explicitlyClosed.current) {
3952
- setData(msg.data);
3953
- var _msg_id;
3954
- setLastEventId((_msg_id = msg.id) != null ? _msg_id : null);
3955
- setEvent(msg.event || null);
3956
- options.onMessage == null ? void 0 : options.onMessage.call(options, msg);
3957
3989
  }
3958
- },
3959
- onerror (err) {
3990
+ }));
3991
+ } catch (err) {
3992
+ // 只处理非主动关闭导致的错误
3993
+ if (!explicitlyClosed.current) {
3994
+ console.error('EventSource Error:', err);
3960
3995
  setError(err);
3961
3996
  setStatus('DISCONNECTED');
3962
- const retryDelay = options.onError == null ? void 0 : options.onError.call(options, err);
3963
- if (options.autoReconnect && !explicitlyClosed.current) {
3964
- const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3965
- retries.current += 1;
3966
- if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3967
- return retryDelay != null ? retryDelay : delay;
3968
- } else {
3969
- onFailed == null ? void 0 : onFailed();
3970
- throw err;
3971
- }
3972
- }
3973
- throw err;
3974
- },
3975
- onclose () {
3976
- if (!explicitlyClosed.current) {
3977
- setStatus('DISCONNECTED');
3978
- options.onClose == null ? void 0 : options.onClose.call(options);
3979
- }
3980
3997
  }
3981
- }));
3982
- } catch (err) {
3983
- // 只处理非主动关闭导致的错误
3984
- if (!explicitlyClosed.current) {
3985
- console.error('EventSource Error:', err);
3986
- setError(err);
3987
- setStatus('DISCONNECTED');
3988
3998
  }
3989
- }
3990
- }));
3999
+ })());
3991
4000
  useEffect(()=>{
3992
4001
  if (options.immediate !== false) {
3993
4002
  open();
@@ -90,14 +90,14 @@ const useQRCode = (text, options = defaultOptions)=>{
90
90
  const [qrCode, setQRCode] = React.useState('');
91
91
  const [error, setError] = React.useState(null);
92
92
  useDeepCompareEffect(()=>{
93
- const generate = /*#__PURE__*/ _async_to_generator(function*() {
94
- try {
95
- const qrCode = yield generateQRCode(text, options);
96
- setQRCode(qrCode);
97
- } catch (error) {
98
- setError(error);
99
- }
100
- });
93
+ const generate = ()=>_async_to_generator(function*() {
94
+ try {
95
+ const qrCode = yield generateQRCode(text, options);
96
+ setQRCode(qrCode);
97
+ } catch (error) {
98
+ setError(error);
99
+ }
100
+ })();
101
101
  generate();
102
102
  }, [
103
103
  text,
@@ -84,14 +84,14 @@ const useQRCode = (text, options = defaultOptions)=>{
84
84
  const [qrCode, setQRCode] = useState('');
85
85
  const [error, setError] = useState(null);
86
86
  useDeepCompareEffect(()=>{
87
- const generate = /*#__PURE__*/ _async_to_generator(function*() {
88
- try {
89
- const qrCode = yield generateQRCode(text, options);
90
- setQRCode(qrCode);
91
- } catch (error) {
92
- setError(error);
93
- }
94
- });
87
+ const generate = ()=>_async_to_generator(function*() {
88
+ try {
89
+ const qrCode = yield generateQRCode(text, options);
90
+ setQRCode(qrCode);
91
+ } catch (error) {
92
+ setError(error);
93
+ }
94
+ })();
95
95
  generate();
96
96
  }, [
97
97
  text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "6.0.5",
3
+ "version": "6.0.6",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {