@siberiacancode/reactuse 0.0.2 → 0.0.4

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 (107) hide show
  1. package/dist/cjs/_rollupPluginBabelHelpers-DKURZ6hh.js +3 -0
  2. package/dist/cjs/_rollupPluginBabelHelpers-DKURZ6hh.js.map +1 -0
  3. package/dist/cjs/hooks/index.js +2 -2
  4. package/dist/cjs/hooks/useBattery/useBattery.js +3 -0
  5. package/dist/cjs/hooks/useBattery/useBattery.js.map +1 -0
  6. package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
  7. package/dist/cjs/hooks/useClickOutside/useClickOutside.js +1 -1
  8. package/dist/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -1
  9. package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  10. package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
  11. package/dist/cjs/hooks/useCounter/useCounter.js.map +1 -1
  12. package/dist/cjs/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  13. package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  14. package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
  15. package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  16. package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
  17. package/dist/cjs/hooks/useEventListener/useEventListener.js +2 -2
  18. package/dist/cjs/hooks/useEventListener/useEventListener.js.map +1 -1
  19. package/dist/cjs/hooks/useHover/useHover.js +2 -2
  20. package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  21. package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
  22. package/dist/cjs/hooks/useKeyPress/useKeyPress.js.map +1 -1
  23. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  24. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
  25. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
  26. package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
  27. package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
  28. package/dist/cjs/hooks/useMount/useMount.js +1 -1
  29. package/dist/cjs/hooks/useMutationObserver.js +1 -1
  30. package/dist/cjs/hooks/useNetwork/useNetwork.js +1 -1
  31. package/dist/cjs/hooks/useNetwork/useNetwork.js.map +1 -1
  32. package/dist/cjs/hooks/useNonInitialEffect/useNonInitialEffect.js +1 -1
  33. package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
  34. package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
  35. package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
  36. package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
  37. package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
  38. package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
  39. package/dist/cjs/hooks/useStorage/useStorage.js.map +1 -1
  40. package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
  41. package/dist/cjs/hooks/useToggle.js +2 -2
  42. package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
  43. package/dist/cjs/hooks/useUnmount/useUnmount.js.map +1 -1
  44. package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
  45. package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
  46. package/dist/cjs/hooks/useWindowSize/useWindowSize.js.map +1 -1
  47. package/dist/cjs/index.js +2 -2
  48. package/dist/cjs/utils/helpers/debounce.js +1 -1
  49. package/dist/cjs/utils/helpers/index.js +1 -1
  50. package/dist/cjs/utils/helpers/isClient.js +1 -1
  51. package/dist/cjs/utils/helpers/isShallowEqual.js +1 -1
  52. package/dist/esm/{_rollupPluginBabelHelpers-BDc6tlcX.js → _rollupPluginBabelHelpers-CVdsimvi.js} +3 -3
  53. package/dist/esm/_rollupPluginBabelHelpers-CVdsimvi.js.map +1 -0
  54. package/dist/esm/hooks/index.js +2 -2
  55. package/dist/esm/hooks/useBattery/useBattery.js +3 -0
  56. package/dist/esm/hooks/useBattery/useBattery.js.map +1 -0
  57. package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
  58. package/dist/esm/hooks/useClickOutside/useClickOutside.js +1 -1
  59. package/dist/esm/hooks/useClickOutside/useClickOutside.js.map +1 -1
  60. package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  61. package/dist/esm/hooks/useCounter/useCounter.js +2 -2
  62. package/dist/esm/hooks/useCounter/useCounter.js.map +1 -1
  63. package/dist/esm/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  64. package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  65. package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
  66. package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  67. package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
  68. package/dist/esm/hooks/useEventListener/useEventListener.js +2 -2
  69. package/dist/esm/hooks/useEventListener/useEventListener.js.map +1 -1
  70. package/dist/esm/hooks/useHover/useHover.js +2 -2
  71. package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  72. package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
  73. package/dist/esm/hooks/useKeyPress/useKeyPress.js.map +1 -1
  74. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  75. package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
  76. package/dist/esm/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
  77. package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
  78. package/dist/esm/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
  79. package/dist/esm/hooks/useMount/useMount.js +1 -1
  80. package/dist/esm/hooks/useMutationObserver.js +1 -1
  81. package/dist/esm/hooks/useNetwork/useNetwork.js +1 -1
  82. package/dist/esm/hooks/useNetwork/useNetwork.js.map +1 -1
  83. package/dist/esm/hooks/useNonInitialEffect/useNonInitialEffect.js +1 -1
  84. package/dist/esm/hooks/useOnline/useOnline.js +1 -1
  85. package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
  86. package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
  87. package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
  88. package/dist/esm/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
  89. package/dist/esm/hooks/useStorage/useStorage.js +2 -2
  90. package/dist/esm/hooks/useStorage/useStorage.js.map +1 -1
  91. package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
  92. package/dist/esm/hooks/useToggle.js +2 -2
  93. package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
  94. package/dist/esm/hooks/useUnmount/useUnmount.js.map +1 -1
  95. package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
  96. package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
  97. package/dist/esm/hooks/useWindowSize/useWindowSize.js.map +1 -1
  98. package/dist/esm/index.js +2 -2
  99. package/dist/esm/utils/helpers/debounce.js +1 -1
  100. package/dist/esm/utils/helpers/index.js +1 -1
  101. package/dist/esm/utils/helpers/isClient.js +1 -1
  102. package/dist/esm/utils/helpers/isShallowEqual.js +1 -1
  103. package/dist/index.d.ts +115 -36
  104. package/package.json +4 -7
  105. package/dist/cjs/_rollupPluginBabelHelpers-9eGFsb-q.js +0 -3
  106. package/dist/cjs/_rollupPluginBabelHelpers-9eGFsb-q.js.map +0 -1
  107. package/dist/esm/_rollupPluginBabelHelpers-BDc6tlcX.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\nexport interface UseStorageOptions<Value> {\n serializer?: (value: Value) => string;\n deserializer?: (value: string) => Value;\n storage: Storage;\n}\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = <Value>(\n storage: Storage,\n key: string,\n deserializer: (value: string) => Value\n) => {\n const value = storage.getItem(key);\n if (!value) return null;\n return deserializer(value);\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getStorageServerSnapshot = <Value>(initialValue: UseStorageInitialValue<Value>) =>\n initialValue instanceof Function ? initialValue() : initialValue;\n\n/**\n * @name useStorage\n * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities\n *\n * @example\n * text\n */\nexport function useStorage<Value = string | null>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) {\n const storage = options?.storage ?? window.localStorage;\n const serializer = React.useCallback<(value: Value) => string>(\n (value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n },\n [options?.serializer]\n );\n\n const deserializer = React.useCallback<(value: string) => Value>(\n (value) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n },\n [options, initialValue]\n );\n\n const getSnapshot = () => getStorageItem<Value>(storage, key, deserializer);\n const getServerSnapshot = () => getStorageServerSnapshot(initialValue);\n const store = React.useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const setState = React.useCallback(\n (value: Value) => {\n if (value === undefined || value === null) {\n return removeStorageItem(storage, key);\n }\n\n setStorageItem(storage, key, serializer(value));\n },\n [key, store]\n );\n\n React.useEffect(() => {\n const value = getStorageItem<Value>(storage, key, deserializer);\n if (value !== null || !initialValue) return;\n\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }, [key]);\n\n return {\n value:\n store ??\n ((initialValue\n ? initialValue instanceof Function\n ? initialValue()\n : initialValue\n : null) as Value),\n set: setState,\n clear: () => removeStorageItem(storage, key)\n };\n}\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","deserializer","storageSubscribe","callback","addEventListener","removeEventListener","useStorage","initialValue","options","_options$storage","localStorage","serializer","React","useCallback","JSON","stringify","parse","error","store","useSyncExternalStore","Function","getStorageServerSnapshot","setState","useEffect","set","clear"],"mappings":";yBASaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SACrBV,EACAC,EACAU,GAEA,IAAMT,EAAQF,EAAQI,QAAQH,GAC9B,OAAKC,EACES,EAAaT,GADD,IAErB,EAEMU,EAAmB,SAACC,GAExB,OADAjB,OAAOkB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMjB,OAAOmB,oBAAoB,UAAWF,EAAS,CAC9D,EAYO,SAASG,EACdf,EACAgB,EACAC,GACA,IAAAC,EACMnB,UAAOmB,EAAGD,aAAAA,EAAAA,EAASlB,eAAO,IAAAmB,EAAAA,EAAIvB,OAAOwB,aACrCC,EAAaC,EAAMC,aACvB,SAACrB,GACC,OAAIgB,SAAAA,EAASG,WAAmBH,EAAQG,WAAWnB,GAC5CsB,KAAKC,UAAUvB,KAExB,CAACgB,eAAAA,EAASG,aAGNV,EAAeW,EAAMC,aACzB,SAACrB,GACC,GAAIgB,SAAAA,EAASP,aAAc,OAAOO,EAAQP,aAAaT,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKE,MAAMxB,EACnB,CAAC,MAAOyB,GACP,OAAOzB,CACT,CACF,GACA,CAACgB,EAASD,IAKNW,EAAQN,EAAMO,qBAAqBjB,GAFrB,WAAH,OAASF,EAAsBV,EAASC,EAAKU,EAAa,IACjD,WAAH,OA1CQ,SAAQM,GAA2C,OAClFA,aAAwBa,SAAWb,IAAiBA,CAAY,CAyChCc,CAAyBd,EAAa,IAGhEe,EAAWV,EAAMC,aACrB,SAACrB,GACC,GAAIA,QACF,OAAOM,EAAkBR,EAASC,GAGpCF,EAAeC,EAASC,EAAKoB,EAAWnB,GAC1C,GACA,CAACD,EAAK2B,IAcR,OAXAN,EAAMW,WAAU,WAEA,OADAvB,EAAsBV,EAASC,EAAKU,IAC3BM,GAEvBlB,EACEC,EACAC,EACAoB,EAAWJ,aAAwBa,SAAWb,IAAiBA,GAEnE,GAAG,CAAChB,IAEG,CACLC,MACE0B,QAAAA,EACEX,EACEA,aAAwBa,SACtBb,IACAA,EACF,KACNiB,IAAKF,EACLG,MAAO,WAAA,OAAM3B,EAAkBR,EAASC,EAAI,EAEhD"}
1
+ {"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\nexport interface UseStorageOptions<Value> {\n serializer?: (value: Value) => string;\n deserializer?: (value: string) => Value;\n storage?: Storage;\n initialValue?: UseStorageInitialValue<Value>;\n}\n\nexport type UseStorageReturn<Value> = [\n value: Value,\n set: (value: Value) => void,\n remove: () => void\n];\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = <Value>(\n storage: Storage,\n key: string,\n deserializer: (value: string) => Value\n) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return deserializer(value);\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getStorageServerSnapshot = <Value>(initialValue: UseStorageInitialValue<Value>) =>\n initialValue instanceof Function ? initialValue() : initialValue;\n\n/**\n * @name useStorage\n * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities\n *\n * @example\n * text\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n const storage = options?.storage ?? window.localStorage;\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem<Value>(storage, key, deserializer);\n const getServerSnapshot = () => getStorageServerSnapshot(initialValue);\n const store = React.useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n\n React.useEffect(() => {\n const value = getStorageItem<Value>(storage, key, deserializer);\n if (value !== undefined || !initialValue) return;\n\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n\n setStorageItem(storage, key, serializer(defaultValue));\n }, [key]);\n\n const remove = () => removeStorageItem(storage, key);\n\n return [store, set, remove] as const;\n};\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","deserializer","storageSubscribe","callback","addEventListener","removeEventListener","useStorage","_options$storage","options","_typeof","undefined","initialValue","localStorage","serializer","JSON","stringify","parse","error","store","React","useSyncExternalStore","Function","getStorageServerSnapshot","useEffect","defaultValue"],"mappings":";yFAgBaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SACrBV,EACAC,EACAU,GAEA,IAAMT,EAAQF,EAAQI,QAAQH,GAC9B,GAAKC,EACL,OAAOS,EAAaT,EACtB,EAEMU,EAAmB,SAACC,GAExB,OADAjB,OAAOkB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMjB,OAAOmB,oBAAoB,UAAWF,EAAS,CAC9D,EAYaG,EAAa,SACxBf,EACAN,GACG,IAAAsB,EACGC,EAA6B,WAAlBC,EAAOxB,GAAsBA,OAASyB,EACjDC,EAAgBH,EAAUA,aAAO,EAAPA,EAASG,aAAe1B,EAElDK,UAAOiB,EAAGC,aAAAA,EAAAA,EAASlB,eAAO,IAAAiB,EAAAA,EAAIrB,OAAO0B,aACrCC,EAAa,SAACrB,GAClB,OAAIgB,SAAAA,EAASK,WAAmBL,EAAQK,WAAWrB,GAC5CsB,KAAKC,UAAUvB,IAGlBS,EAAe,SAACT,GACpB,GAAIgB,SAAAA,EAASP,aAAc,OAAOO,EAAQP,aAAaT,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKE,MAAMxB,EACnB,CAAC,MAAOyB,GACP,OAAOzB,CACT,GAKI0B,EAAQC,EAAMC,qBAAqBlB,GAFrB,WAAH,OAASF,EAAsBV,EAASC,EAAKU,EAAa,IACjD,WAAH,OAtCQ,SAAQU,GAA2C,OAClFA,aAAwBU,SAAWV,IAAiBA,CAAY,CAqChCW,CAAyBX,EAAa,IAQtEQ,EAAMI,WAAU,WAEd,QAAcb,IADAV,EAAsBV,EAASC,EAAKU,IACtBU,EAA5B,CAEA,IAAMa,EAAeb,aAAwBU,SAAWV,IAAiBA,EAEzEtB,EAAeC,EAASC,EAAKsB,EAAWW,GAJE,CAK5C,GAAG,CAACjC,IAIJ,MAAO,CAAC2B,EAhBI,SAAC1B,GACX,GAAc,OAAVA,EAAgB,OAAOM,EAAkBR,EAASC,GACtDF,EAAeC,EAASC,EAAKsB,EAAWrB,KAY3B,WAAH,OAASM,EAAkBR,EAASC,EAAI,EAGtD"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{_ as e}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import r from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";function u(u,o){var n=r.useState(!1),c=e(n,2),i=c[0],f=c[1],s=r.useRef(u),m=r.useRef();t((function(){s.current=u}),[u]),r.useEffect((function(){return m.current=setTimeout((function(){s.current(),f(!0)}),o),function(){clearTimeout(m.current)}}),[o]);return{ready:i,clear:function(){clearTimeout(m.current),f(!0)}}}export{u as useTimeout};
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
+ import{_ as e}from"../../_rollupPluginBabelHelpers-CVdsimvi.js";import r from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";function u(u,o){var n=r.useState(!1),c=e(n,2),i=c[0],f=c[1],s=r.useRef(u),m=r.useRef();t((function(){s.current=u}),[u]),r.useEffect((function(){return m.current=setTimeout((function(){s.current(),f(!0)}),o),function(){clearTimeout(m.current)}}),[o]);return{ready:i,clear:function(){clearTimeout(m.current),f(!0)}}}export{u as useTimeout};
3
3
  //# sourceMappingURL=useTimeout.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{_ as r}from"../_rollupPluginBabelHelpers-BDc6tlcX.js";import e from"react";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[!1,!0],t=e.useReducer((function(r,e){var n=e instanceof Function?e(r[0]):e,t=Math.abs(r.indexOf(n));return r.slice(t).concat(r.slice(0,t))}),n),o=r(t,2);return[r(o[0],1)[0],o[1]]};export{n as useToggle};
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
+ import{_ as r}from"../_rollupPluginBabelHelpers-CVdsimvi.js";import e from"react";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[!1,!0],t=e.useReducer((function(r,e){var n=e instanceof Function?e(r[0]):e,t=Math.abs(r.indexOf(n));return r.slice(t).concat(r.slice(0,t))}),n),o=r(t,2);return[r(o[0],1)[0],o[1]]};export{n as useToggle};
3
3
  //# sourceMappingURL=useToggle.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  import r from"react";var t=function(t){var e=r.useRef(t);e.current=t,r.useEffect((function(){return function(){e.current()}}),[])};export{t as useUnmount};
3
3
  //# sourceMappingURL=useUnmount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUnmount.js","sources":["../../../../src/hooks/useUnmount/useUnmount.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * @name useUnmount\n * @description - Hook that defines the logic when unmounting a component\n *\n * @param {() => void} callback The callback function to be invoked on component unmount\n *\n * @returns {void}\n *\n * @example\n * useUnmount(() => console.log('Component unmounted'));\n */\n\nexport const useUnmount = (callback: () => void) => {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n React.useEffect(\n () => () => {\n callbackRef.current();\n },\n []\n );\n};\n"],"names":["useUnmount","callback","callbackRef","React","useRef","current","useEffect"],"mappings":";yBAcaA,EAAa,SAACC,GACzB,IAAMC,EAAcC,EAAMC,OAAOH,GACjCC,EAAYG,QAAUJ,EAEtBE,EAAMG,WACJ,WAAA,OAAM,WACJJ,EAAYG,UACb,GACD,GAEJ"}
1
+ {"version":3,"file":"useUnmount.js","sources":["../../../../src/hooks/useUnmount/useUnmount.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * @name useUnmount\n * @description - Hook that defines the logic when unmounting a component\n *\n * @param {() => void} callback The callback function to be invoked on component unmount\n * @returns {void}\n *\n * @example\n * useUnmount(() => console.log('Component unmounted'));\n */\n\nexport const useUnmount = (callback: () => void) => {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n React.useEffect(\n () => () => {\n callbackRef.current();\n },\n []\n );\n};\n"],"names":["useUnmount","callback","callbackRef","React","useRef","current","useEffect"],"mappings":";yBAaaA,EAAa,SAACC,GACzB,IAAMC,EAAcC,EAAMC,OAAOH,GACjCC,EAAYG,QAAUJ,EAEtBE,EAAMG,WACJ,WAAA,OAAM,WACJJ,EAAYG,UACb,GACD,GAEJ"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  import{useEventListener as e}from"../useEventListener/useEventListener.js";import"react";var r=function(r,t,n){return e(window,r,t,n)};export{r as useWindowEvent};
3
3
  //# sourceMappingURL=useWindowEvent.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{_ as i}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import{useState as n}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var o,l,d=n({width:e?window.innerWidth:null!==(o=null==r?void 0:r.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY,height:e?window.innerHeight:null!==(l=null==r?void 0:r.initialWidth)&&void 0!==l?l:Number.POSITIVE_INFINITY}),u=i(d,2),h=u[0],s=u[1];return t(window,"resize",(function(){s({width:window.innerWidth,height:window.innerHeight})})),h};export{r as useWindowSize};
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
+ import{_ as i}from"../../_rollupPluginBabelHelpers-CVdsimvi.js";import{useState as n}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var o,l,d=n({width:e?window.innerWidth:null!==(o=null==r?void 0:r.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY,height:e?window.innerHeight:null!==(l=null==r?void 0:r.initialWidth)&&void 0!==l?l:Number.POSITIVE_INFINITY}),u=i(d,2),h=u[0],s=u[1];return t(window,"resize",(function(){s({width:window.innerWidth,height:window.innerHeight})})),h};export{r as useWindowSize};
3
3
  //# sourceMappingURL=useWindowSize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowSize.js","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use window size return type */\ninterface UseWindowSizeParams {\n /** The initial window width */\n initialWidth?: number;\n /** The initial window height */\n initialHeight?: number;\n}\n\n/** The use window size return type */\nexport interface UseWindowSizeReturn {\n /** The current window width */\n width: number;\n /** The current window height */\n height: number;\n}\n\n/**\n * @name useWindowSize\n * @description - Hook that manages a window size\n *\n * @param {UseWindowSizeParams} [useWindowSizeParams] The use copy to clipboard params\n * @returns {UseWindowSizeReturn} An object containing the current window width and height\n *\n * @example\n * const { width, height } = useWindowSize()\n */\nexport const useWindowSize = (params?: UseWindowSizeParams) => {\n const [size, setSize] = useState({\n width: isClient ? window.innerWidth : params?.initialWidth ?? Number.POSITIVE_INFINITY,\n height: isClient ? window.innerHeight : params?.initialWidth ?? Number.POSITIVE_INFINITY\n });\n\n useEventListener(window, 'resize', () => {\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n });\n\n return size;\n};\n"],"names":["useWindowSize","params","_params$initialWidth","_params$initialWidth2","_useState","useState","width","isClient","window","innerWidth","initialWidth","Number","POSITIVE_INFINITY","height","innerHeight","_useState2","_slicedToArray","size","setSize","useEventListener"],"mappings":";2OAgCaA,EAAgB,SAACC,GAAiC,IAAAC,EAAAC,EAC7DC,EAAwBC,EAAS,CAC/BC,MAAOC,EAAWC,OAAOC,WAAiCP,QAAvBA,EAAGD,aAAAA,EAAAA,EAAQS,wBAAYR,EAAAA,EAAIS,OAAOC,kBACrEC,OAAQN,EAAWC,OAAOM,YAAkC,QAAvBX,EAAGF,aAAAA,EAAAA,EAAQS,oBAAYP,IAAAA,EAAAA,EAAIQ,OAAOC,oBACvEG,EAAAC,EAAAZ,EAAA,GAHKa,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAYpB,OAPAI,EAAiBX,OAAQ,UAAU,WACjCU,EAAQ,CACNZ,MAAOE,OAAOC,WACdI,OAAQL,OAAOM,aAEnB,IAEOG,CACT"}
1
+ {"version":3,"file":"useWindowSize.js","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use window size return type */\ninterface UseWindowSizeParams {\n /** The initial window width */\n initialWidth?: number;\n /** The initial window height */\n initialHeight?: number;\n}\n\n/** The use window size return type */\nexport interface UseWindowSizeReturn {\n /** The current window width */\n width: number;\n /** The current window height */\n height: number;\n}\n\n/**\n * @name useWindowSize\n * @description - Hook that manages a window size\n *\n * @param {number} [params.initialWidth=Number.POSITIVE_INFINITY] The initial window width\n * @param {number} [params.initialHeight=Number.POSITIVE_INFINITY] The initial window height\n * @returns {UseWindowSizeReturn} An object containing the current window width and height\n *\n * @example\n * const { width, height } = useWindowSize()\n */\nexport const useWindowSize = (params?: UseWindowSizeParams) => {\n const [size, setSize] = useState({\n width: isClient ? window.innerWidth : params?.initialWidth ?? Number.POSITIVE_INFINITY,\n height: isClient ? window.innerHeight : params?.initialWidth ?? Number.POSITIVE_INFINITY\n });\n\n useEventListener(window, 'resize', () => {\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n });\n\n return size;\n};\n"],"names":["useWindowSize","params","_params$initialWidth","_params$initialWidth2","_useState","useState","width","isClient","window","innerWidth","initialWidth","Number","POSITIVE_INFINITY","height","innerHeight","_useState2","_slicedToArray","size","setSize","useEventListener"],"mappings":";2OAiCaA,EAAgB,SAACC,GAAiC,IAAAC,EAAAC,EAC7DC,EAAwBC,EAAS,CAC/BC,MAAOC,EAAWC,OAAOC,WAAiCP,QAAvBA,EAAGD,aAAAA,EAAAA,EAAQS,wBAAYR,EAAAA,EAAIS,OAAOC,kBACrEC,OAAQN,EAAWC,OAAOM,YAAkC,QAAvBX,EAAGF,aAAAA,EAAAA,EAAQS,oBAAYP,IAAAA,EAAAA,EAAIQ,OAAOC,oBACvEG,EAAAC,EAAAZ,EAAA,GAHKa,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAYpB,OAPAI,EAAiBX,OAAQ,UAAU,WACjCU,EAAQ,CACNZ,MAAOE,OAAOC,WACdI,OAAQL,OAAOM,aAEnB,IAEOG,CACT"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useNonInitialEffect}from"./hooks/useNonInitialEffect/useNonInitialEffect.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";import"./_rollupPluginBabelHelpers-BDc6tlcX.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/isShallowEqual.js";
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
+ export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useNonInitialEffect}from"./hooks/useNonInitialEffect/useNonInitialEffect.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";import"./_rollupPluginBabelHelpers-CVdsimvi.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/isShallowEqual.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  var r=function(r,n){var t;return function(){for(var e=arguments.length,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return r.apply(void 0,o)}),n)}};export{r as debounce};
3
3
  //# sourceMappingURL=debounce.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  export{debounce}from"./debounce.js";export{isClient}from"./isClient.js";export{isShallowEqual}from"./isShallowEqual.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  var n,d,e=!("undefined"==typeof window||null===(n=window)||void 0===n||!n.document||null===(d=window)||void 0===d||null===(d=d.document)||void 0===d||!d.createElement);export{e as isClient};
3
3
  //# sourceMappingURL=isClient.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.3 */
2
2
  var r=function(r,e){var t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(var a=0,f=t;a<f.length;a++){var u=f[a];if(r[u]!==e[u])return!1}return!0};export{r as isShallowEqual};
3
3
  //# sourceMappingURL=isShallowEqual.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,31 @@
1
1
  import React from 'react';
2
2
 
3
+ /** State for hook use battery */
4
+ interface UseBatteryStateReturn {
5
+ /** Is battery API supported? */
6
+ supported: boolean;
7
+ /** Is battery information loading? */
8
+ loading: boolean;
9
+ /** Is charging battery? */
10
+ charging: boolean;
11
+ /** Time until the battery is fully charged */
12
+ chargingTime: number;
13
+ /** Time until the battery is completely discharged */
14
+ dischargingTime: number;
15
+ /** Battery charge level from 0 to 1 */
16
+ level: number;
17
+ }
18
+ /**
19
+ * @name useBattery
20
+ * @description - Hook for getting information about battery status
21
+ *
22
+ * @returns {UseBatteryStateReturn} Object containing battery information & Battery API support
23
+ *
24
+ * @example
25
+ * const battery = useBattery();
26
+ */
27
+ declare const useBattery: () => UseBatteryStateReturn;
28
+
3
29
  /** The use boolean return type */
4
30
  type UseBooleanReturn = [
5
31
  /** The current boolean state value */
@@ -25,13 +51,6 @@ type UseClickOutside = {
25
51
  <Target extends UseClickOutsideTarget | Array<UseClickOutsideTarget> = any>(target: Target, callback: (event: Event) => void): void;
26
52
  <Target extends UseClickOutsideTarget | Array<UseClickOutsideTarget> = any>(callback: (event: Event) => void, target?: never): UseClickOutsideReturn<Target>;
27
53
  };
28
- /**
29
- * @name useClickOutside
30
- * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities
31
- *
32
- * @example
33
- * const { count, dec, inc, reset, set } = useCounter(5);
34
- */
35
54
  declare const useClickOutside: UseClickOutside;
36
55
 
37
56
  declare const legacyCopyToClipboard: (value: string) => void;
@@ -91,11 +110,14 @@ type UseCounter = {
91
110
  *
92
111
  * @overload
93
112
  * @param {number} [initialValue=0] The initial number value
94
- * @param {UseCounterOptions} [useCounterOptions] The use counter options
113
+ * @param {number} [options.min=Number.NEGATIVE_INFINITY] The min of count value
114
+ * @param {number} [options.max=Number.POSITIVE_INFINITY] The max of count value
95
115
  * @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter
96
116
 
97
117
  * @overload
98
- * @param {UseCounterParams} [useCounterParams] The use counter params
118
+ * @param {number} [params.initialValue=0] The initial number value
119
+ * @param {number} [params.min=Number.NEGATIVE_INFINITY] The min of count value
120
+ * @param {number} [params.max=Number.POSITIVE_INFINITY] The max of count value
99
121
  * @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter
100
122
  *
101
123
  * @example
@@ -118,10 +140,12 @@ interface UseDebouncedValueOptions {
118
140
  */
119
141
  declare const useDebouncedValue: <Value>(value: Value, delay: number, options?: UseDebouncedValueOptions) => readonly [Value, (value: Value) => void];
120
142
 
143
+ /** The use document title options type */
121
144
  interface UseDocumentTitleOptions {
122
145
  /** Restore the previous title on unmount */
123
146
  restoreOnUnmount?: boolean;
124
147
  }
148
+ /** The use document title return type */
125
149
  type UseDocumentTitleReturn = [
126
150
  /** The current title */
127
151
  title: string,
@@ -133,7 +157,7 @@ type UseDocumentTitleReturn = [
133
157
  * @description - Hook that manages the document title and allows updating it
134
158
  *
135
159
  * @param {string} [value] The initial title. If not provided, the current document title will be used
136
- * @param {UseDocumentTitleOptions} [options] The use document title options
160
+ * @param {boolean} [options.restoreOnUnmount] Restore the previous title on unmount
137
161
  * @returns {UseDocumentTitleReturn} An array containing the current title and a function to update the title
138
162
  *
139
163
  * @example
@@ -141,16 +165,25 @@ type UseDocumentTitleReturn = [
141
165
  */
142
166
  declare function useDocumentTitle(value?: string, options?: UseDocumentTitleOptions): UseDocumentTitleReturn;
143
167
 
168
+ /**
169
+ * @name useDocumentVisibility
170
+ * @description – Hook that provides the current visibility state of the document
171
+ *
172
+ * @returns {DocumentVisibilityState} The current visibility state of the document, which can be 'visible' or 'hidden'
173
+ *
174
+ * @example
175
+ * const visibilityState = useDocumentVisibility();
176
+ */
144
177
  declare const useDocumentVisibility: () => DocumentVisibilityState;
145
178
 
146
179
  type UseEventListenerTarget = React.RefObject<Element | null> | (() => Element) | Element | Window | Document;
147
180
  type UseEventListenerOptions = boolean | AddEventListenerOptions;
148
181
  type UseEventListenerReturn<Target extends UseEventListenerTarget = any> = React.RefObject<Target>;
149
182
  type UseEventListener = {
150
- <Event extends keyof WindowEventMap = keyof WindowEventMap>(target: Window, event: Event, listener: (this: Window, event: WindowEventMap[Event]) => void, options?: UseEventListenerOptions): void;
151
- <Event extends keyof DocumentEventMap = keyof DocumentEventMap>(target: Document, event: Event, listener: (this: Document, event: DocumentEventMap[Event]) => void, options?: UseEventListenerOptions): void;
152
- <Target extends UseEventListenerTarget, Event extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(target: Target, event: Event, listener: (this: Target, event: HTMLElementEventMap[Event]) => void, options?: UseEventListenerOptions): void;
153
- <Target extends Element, Event extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(event: Event, listener: (this: Target, event: HTMLElementEventMap[Event]) => void, options?: UseEventListenerOptions, target?: never): UseEventListenerReturn<Target>;
183
+ <Event extends keyof WindowEventMap = keyof WindowEventMap>(target: Window, event: Event | Event[], listener: (this: Window, event: WindowEventMap[Event]) => void, options?: UseEventListenerOptions): void;
184
+ <Event extends keyof DocumentEventMap = keyof DocumentEventMap>(target: Document, event: Event | Event[], listener: (this: Document, event: DocumentEventMap[Event]) => void, options?: UseEventListenerOptions): void;
185
+ <Target extends UseEventListenerTarget, Event extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(target: Target, event: Event | Event[], listener: (this: Target, event: HTMLElementEventMap[Event]) => void, options?: UseEventListenerOptions): void;
186
+ <Target extends Element, Event extends keyof HTMLElementEventMap = keyof HTMLElementEventMap>(event: Event | Event[], listener: (this: Target, event: HTMLElementEventMap[Event]) => void, options?: UseEventListenerOptions, target?: never): UseEventListenerReturn<Target>;
154
187
  };
155
188
  /**
156
189
  * @name useEventListener
@@ -186,12 +219,26 @@ declare const useHover: UseHover;
186
219
  * @example
187
220
  * useIsomorphicLayoutEffect(() => console.log('effect'), [])
188
221
  */
189
- declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
222
+ declare const useIsomorphicLayoutEffect: typeof React.useEffect;
190
223
 
224
+ /** The key or keys to listen for */
191
225
  type UseKeyPressKey = string | string[];
226
+ /** The use key press options */
192
227
  type UseKeyPressOptions = {
193
- target: UseEventListenerTarget;
228
+ /** The target to attach the event listeners to */
229
+ target?: UseEventListenerTarget;
194
230
  };
231
+ /**
232
+ * @name useKeyPress
233
+ * @description - Hook that listens for key press events
234
+ *
235
+ * @param {UseKeyPressKey} key The key or keys to listen for
236
+ * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to
237
+ * @returns {useKeyPressReturns} Return boolean type (`true` if the specified keys are currently pressed)
238
+ *
239
+ * @example
240
+ * const isKeyPressed = useKeyPress('a');
241
+ */
195
242
  declare const useKeyPress: (key: UseKeyPressKey, options?: UseKeyPressOptions) => boolean;
196
243
 
197
244
  type UseKeyPressEventKey = string | string[];
@@ -203,14 +250,41 @@ type UseKeyPressEvent = {
203
250
  };
204
251
  declare const useKeyPressEvent: UseKeyPressEvent;
205
252
 
206
- declare const useKeysPressed: (target?: UseEventListenerTarget) => string[];
253
+ /** The use keys pressed params */
254
+ interface UseKeysPressedParams {
255
+ /** The target to attach the event listeners to */
256
+ target?: UseEventListenerTarget;
257
+ /** Enable or disable the event listeners */
258
+ enabled?: boolean;
259
+ }
260
+ /**
261
+ * @name useKeysPressed
262
+ * @description - Hook that listens for key press events
263
+ *
264
+ * @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to
265
+ * @param {boolean} [params.enabled=bollean] Enable or disable the event listeners
266
+ * @returns {useKeysPressedReturns} Array of strings with keys that were press
267
+ *
268
+ * @example
269
+ * const pressedKeys = useKeysPressed();
270
+ */
271
+ declare const useKeysPressed: (params?: UseKeysPressedParams) => {
272
+ key: string;
273
+ code: string;
274
+ }[];
207
275
 
208
276
  type UseStorageInitialValue<Value> = Value | (() => Value);
209
277
  interface UseStorageOptions<Value> {
210
278
  serializer?: (value: Value) => string;
211
279
  deserializer?: (value: string) => Value;
212
- storage: Storage;
280
+ storage?: Storage;
281
+ initialValue?: UseStorageInitialValue<Value>;
213
282
  }
283
+ type UseStorageReturn<Value> = [
284
+ value: Value,
285
+ set: (value: Value) => void,
286
+ remove: () => void
287
+ ];
214
288
  declare const dispatchStorageEvent: (params: Partial<StorageEvent>) => boolean;
215
289
  /**
216
290
  * @name useStorage
@@ -219,32 +293,41 @@ declare const dispatchStorageEvent: (params: Partial<StorageEvent>) => boolean;
219
293
  * @example
220
294
  * text
221
295
  */
222
- declare function useStorage<Value = string | null>(key: string, initialValue?: UseStorageInitialValue<Value>, options?: UseStorageOptions<Value>): {
223
- value: Value;
224
- set: (value: Value) => void;
225
- clear: () => void;
226
- };
296
+ declare const useStorage: <Value>(key: string, params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>) => readonly [Value | undefined, (value: Value) => void, () => void];
227
297
 
228
- declare const useLocalStorage: <Value>(key: string, initialValue?: UseStorageInitialValue<Value>, options?: UseStorageOptions<Value>) => {
229
- value: Value;
230
- set: (value: Value) => void;
231
- clear: () => void;
232
- };
298
+ declare const useLocalStorage: <Value>(key: string, initialValue?: UseStorageInitialValue<Value>, options?: UseStorageOptions<Value>) => readonly [Value | undefined, (value: Value) => void, () => void];
233
299
 
234
300
  declare const useMount: (effect: React.EffectCallback) => void;
235
301
 
236
302
  type ConnectionType = Connection['type'];
237
303
  type ConnectionEffectiveType = Connection['effectiveType'];
304
+ /** The use network return type */
238
305
  interface UseNetworkReturn {
306
+ /** Indicates if the device is currently online */
239
307
  online: boolean;
308
+ /** The estimated downlink speed in megabits per seconds */
240
309
  downlink?: Connection['downlink'];
310
+ /** The maximum downlink speed, if available */
241
311
  downlinkMax?: Connection['downlinkMax'];
312
+ /** The effective type of connection (e.g., '2g', '3g', '4g') */
242
313
  effectiveType?: Connection['effectiveType'];
314
+ /** The estimated round-trip time in milliseconds */
243
315
  rtt?: Connection['rtt'];
316
+ /** Indicates if the user has enabled data saving mode */
244
317
  saveData?: Connection['saveData'];
318
+ /** The type of network connection (e.g., 'wifi', 'cellular') */
245
319
  type?: Connection['type'];
246
320
  }
247
321
  declare const getConnection: () => Connection;
322
+ /**
323
+ * @name useNetwork
324
+ * @description - Hook to track network status.
325
+ *
326
+ * @returns {UseNetworkReturn} An object containing the network status.
327
+ *
328
+ * @example
329
+ * const network = useNetwork();
330
+ */
248
331
  declare const useNetwork: () => UseNetworkReturn;
249
332
 
250
333
  declare const useNonInitialEffect: (effect: React.EffectCallback, deps?: React.DependencyList) => void;
@@ -267,11 +350,7 @@ declare const useOrientation: () => {
267
350
  */
268
351
  declare const useRenderCount: () => number;
269
352
 
270
- declare const useSessionStorage: <Value>(key: string, initialValue?: UseStorageInitialValue<Value>, options?: UseStorageOptions<Value>) => {
271
- value: Value;
272
- set: (value: Value) => void;
273
- clear: () => void;
274
- };
353
+ declare const useSessionStorage: <Value>(key: string, initialValue?: UseStorageInitialValue<Value>, options?: UseStorageOptions<Value>) => readonly [Value | undefined, (value: Value) => void, () => void];
275
354
 
276
355
  declare function useTimeout(callback: () => void, delay: number): {
277
356
  ready: boolean;
@@ -283,7 +362,6 @@ declare function useTimeout(callback: () => void, delay: number): {
283
362
  * @description - Hook that defines the logic when unmounting a component
284
363
  *
285
364
  * @param {() => void} callback The callback function to be invoked on component unmount
286
- *
287
365
  * @returns {void}
288
366
  *
289
367
  * @example
@@ -324,7 +402,8 @@ interface UseWindowSizeReturn {
324
402
  * @name useWindowSize
325
403
  * @description - Hook that manages a window size
326
404
  *
327
- * @param {UseWindowSizeParams} [useWindowSizeParams] The use copy to clipboard params
405
+ * @param {number} [params.initialWidth=Number.POSITIVE_INFINITY] The initial window width
406
+ * @param {number} [params.initialHeight=Number.POSITIVE_INFINITY] The initial window height
328
407
  * @returns {UseWindowSizeReturn} An object containing the current window width and height
329
408
  *
330
409
  * @example
@@ -335,4 +414,4 @@ declare const useWindowSize: (params?: UseWindowSizeParams) => {
335
414
  height: number;
336
415
  };
337
416
 
338
- export { type ConnectionEffectiveType, type ConnectionType, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseHover, type UseHoverReturn, type UseHoverTarget, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseNetworkReturn, type UseStorageInitialValue, type UseStorageOptions, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, legacyCopyToClipboard, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDocumentTitle, useDocumentVisibility, useEventListener, useHover, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useMount, useNetwork, useNonInitialEffect, useOnline, useOrientation, useRenderCount, useSessionStorage, useStorage, useTimeout, useUnmount, useWindowEvent, useWindowSize };
417
+ export { type ConnectionEffectiveType, type ConnectionType, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseHover, type UseHoverReturn, type UseHoverTarget, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseNetworkReturn, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, legacyCopyToClipboard, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDocumentTitle, useDocumentVisibility, useEventListener, useHover, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useMount, useNetwork, useNonInitialEffect, useOnline, useOrientation, useRenderCount, useSessionStorage, useStorage, useTimeout, useUnmount, useWindowEvent, useWindowSize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siberiacancode/reactuse",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Ultimate tool",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/siberiacancode/webcam.git"
24
+ "url": "https://github.com/siberiacancode/reactuse.git"
25
25
  },
26
- "homepage": "https://github.com/siberiacancode/webcam",
27
- "bugs": "https://github.com/siberiacancode/webcam/issues",
26
+ "homepage": "https://github.com/siberiacancode/reactuse",
27
+ "bugs": "https://github.com/siberiacancode/reactuse/issues",
28
28
  "files": [
29
29
  "dist/**/*"
30
30
  ],
@@ -59,9 +59,6 @@
59
59
  "optional": true
60
60
  }
61
61
  },
62
- "dependencies": {
63
- "@webcam/core": "*"
64
- },
65
62
  "devDependencies": {
66
63
  "@siberiacancode/builder": "^1.3.0",
67
64
  "@siberiacancode/eslint": "^1.1.0",
@@ -1,3 +0,0 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- "use strict";function t(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function r(){r=function(){return e};var t,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof m?r:m,a=Object.create(o.prototype),c=new k(n||[]);return i(a,"_invoke",{value:S(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var y="suspendedStart",p="suspendedYield",v="executing",d="completed",g={};function m(){}function b(){}function w(){}var O={};f(O,c,(function(){return this}));var j=Object.getPrototypeOf,x=j&&j(j(G([])));x&&x!==n&&o.call(x,c)&&(O=x);var E=w.prototype=m.prototype=Object.create(O);function L(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function P(t,r){function e(n,i,a,c){var u=h(t[n],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function S(r,e,n){var o=y;return function(i,a){if(o===v)throw new Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=h(r,e,n);if("normal"===l.type){if(o=n.done?d:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function _(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function A(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function T(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function G(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return b.prototype=w,i(E,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:b,configurable:!0}),b.displayName=f(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(E),t},e.awrap=function(t){return{__await:t}},L(P.prototype),f(P.prototype,u,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(E),f(E,l,"Generator"),f(E,c,(function(){return this})),f(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=G,k.prototype={constructor:k,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),g},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),T(e),g}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;T(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:G(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function e(t){var r=function(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof r?r:String(r)}function n(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function o(t,r,n){return(r=e(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function i(t,r){if(t){if("string"==typeof t)return a(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(t,r):void 0}}function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}exports._asyncToGenerator=function(t){return function(){var r=this,e=arguments;return new Promise((function(o,i){var a=t.apply(r,e);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}},exports._objectSpread2=function(r){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?t(Object(n),!0).forEach((function(t){o(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))}))}return r},exports._regeneratorRuntime=r,exports._slicedToArray=function(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(t,r)||i(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},exports._toConsumableArray=function(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()};
3
- //# sourceMappingURL=_rollupPluginBabelHelpers-9eGFsb-q.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-9eGFsb-q.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-BDc6tlcX.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}