@siberiacancode/reactuse 0.0.116 → 0.0.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs +1 -1
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs.map +1 -1
- package/dist/cjs/hooks/useFul/useFul.cjs +2 -0
- package/dist/cjs/hooks/useFul/useFul.cjs.map +1 -0
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +2 -0
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -0
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs +2 -0
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs +14 -13
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs.map +1 -1
- package/dist/esm/hooks/useFul/useFul.mjs +8 -0
- package/dist/esm/hooks/useFul/useFul.mjs.map +1 -0
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +56 -0
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -0
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs +24 -0
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs.map +1 -0
- package/dist/esm/index.mjs +231 -225
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/useDidUpdate/useDidUpdate.d.ts +1 -1
- package/dist/types/hooks/useIntersectionObserver/useIntersectionObserver.d.ts +2 -0
- package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +59 -0
- package/dist/types/hooks/useWakeLock/useWakeLock.d.ts +32 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),t=require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),s=(r,u)=>{const e=o.useRef(!1);t.useIsomorphicLayoutEffect(()=>()=>{e.current=!1},[]),t.useIsomorphicLayoutEffect(()=>{if(e.current)return r();e.current=!0},u)};exports.useDidUpdate=s;
|
|
2
2
|
//# sourceMappingURL=useDidUpdate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDidUpdate.cjs","sources":["../../../../src/hooks/useDidUpdate/useDidUpdate.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/**\n * @name useDidUpdate\n * @description – Hook that triggers the effect callback on updates\n * @category Lifecycle\n *\n * @param {EffectCallback} effect The effect callback\n * @param {DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useDidUpdate(() => console.log(\"effect runs on updates\"),
|
|
1
|
+
{"version":3,"file":"useDidUpdate.cjs","sources":["../../../../src/hooks/useDidUpdate/useDidUpdate.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\r\n\r\nimport { useRef } from 'react';\r\n\r\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\r\n\r\n/**\r\n * @name useDidUpdate\r\n * @description – Hook that triggers the effect callback on updates\r\n * @category Lifecycle\r\n *\r\n * @param {EffectCallback} effect The effect callback\r\n * @param {DependencyList} [deps] The dependencies list for the effect\r\n *\r\n * @example\r\n * useDidUpdate(() => console.log(\"effect runs on updates\"), deps);\r\n */\r\nexport const useDidUpdate = (effect: EffectCallback, deps?: DependencyList) => {\r\n const mounted = useRef(false);\r\n\r\n useIsomorphicLayoutEffect(\r\n () => () => {\r\n mounted.current = false;\r\n },\r\n []\r\n );\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (mounted.current) {\r\n return effect();\r\n }\r\n\r\n mounted.current = true;\r\n return undefined;\r\n }, deps);\r\n};\r\n"],"names":["useDidUpdate","effect","deps","mounted","useRef","useIsomorphicLayoutEffect"],"mappings":"iLAiBaA,EAAe,CAACC,EAAwBC,IAA0B,CACvE,MAAAC,EAAUC,SAAO,EAAK,EAE5BC,EAAA,0BACE,IAAM,IAAM,CACVF,EAAQ,QAAU,EACpB,EACA,CAAA,CACF,EAEAE,EAAAA,0BAA0B,IAAM,CAC9B,GAAIF,EAAQ,QACV,OAAOF,EAAO,EAGhBE,EAAQ,QAAU,IAEjBD,CAAI,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFul.cjs","sources":["../../../../src/hooks/useFul/useFul.ts"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * @name useFul\n * @description - Hook that can be so useful\n * @category Humor\n *\n * @warning - This hook is a joke. Please do not use it in production code!\n *\n * @template Value The type of the value\n * @param {Value} [value] The value to be returned\n * @returns {Value} The value passed to the hook\n *\n * @example\n * const value = useFul(state);\n */\nexport const useFul = <Value>(value?: Value) => {\n useEffect(() => {\n console.warn(\"Warning: You forgot to delete the 'useFul' hook.\");\n }, []);\n\n return value;\n};\n"],"names":["useFul","value","useEffect"],"mappings":"yGAgBaA,EAAiBC,IAC5BC,EAAAA,UAAU,IAAM,CACd,QAAQ,KAAK,kDAAkD,CACjE,EAAG,EAAE,EAEED"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionObserver.cjs","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The intersection observer options type */\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n root?: HookTarget;\n onChange?: (entry: IntersectionObserverEntry) => void;\n}\n\n/** The intersection observer return type */\nexport interface UseIntersectionObserverReturn {\n entry?: IntersectionObserverEntry;\n inView: boolean;\n}\n\nexport interface UseIntersectionObserver {\n <Target extends Element>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;\n}\n\n/**\n * @name useIntersectionObserver\n * @description - Hook that gives you intersection observer state\n * @category Browser\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn} An object containing the state and the supported status\n *\n * @example\n * const { ref, entry, inView } = useIntersectionObserver();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entry, inView } = useIntersectionObserver(ref);\n */\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalOnChangeRef = useRef<UseIntersectionObserverOptions['onChange']>(options?.onChange);\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled && !target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n internalOnChangeRef.current?.(entry);\n },\n {\n ...options,\n root: options?.root ? (getElement(options.root) as Document | Element) : document\n }\n );\n\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return {\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","params","target","isTarget","options","enabled","entry","setEntry","useState","internalRef","useRefState","internalOnChangeRef","useRef","useEffect","element","getElement","observer","_a"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.cjs","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The intersection observer options type */\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n root?: HookTarget;\n onChange?: (entry: IntersectionObserverEntry) => void;\n}\n\n/** The intersection observer return type */\nexport interface UseIntersectionObserverReturn {\n entry?: IntersectionObserverEntry;\n inView: boolean;\n}\n\nexport interface UseIntersectionObserver {\n <Target extends Element>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;\n}\n\n/**\n * @name useIntersectionObserver\n * @description - Hook that gives you intersection observer state\n * @category Browser\n *\n * @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn} An object containing the state and the supported status\n *\n * @example\n * const { ref, entry, inView } = useIntersectionObserver();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entry, inView } = useIntersectionObserver(ref);\n */\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalOnChangeRef = useRef<UseIntersectionObserverOptions['onChange']>(options?.onChange);\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled && !target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n internalOnChangeRef.current?.(entry);\n },\n {\n ...options,\n root: options?.root ? (getElement(options.root) as Document | Element) : document\n }\n );\n\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return {\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","params","target","isTarget","options","enabled","entry","setEntry","useState","internalRef","useRefState","internalOnChangeRef","useRef","useEffect","element","getElement","observer","_a"],"mappings":"mPA2DaA,EAA2B,IAAIC,IAAkB,CACtD,MAAAC,EAAUC,WAASF,EAAO,CAAC,CAAC,EAAIA,EAAO,CAAC,EAAI,OAC5CG,EAAWF,EAASD,EAAO,CAAC,EAAIA,EAAO,CAAC,EACxCI,GAAUD,GAAA,YAAAA,EAAS,UAAW,GAE9B,CAACE,EAAOC,CAAQ,EAAIC,WAAoC,EAExDC,EAAcC,EAAAA,YAAqB,EACnCC,EAAsBC,EAAAA,OAAmDR,GAAA,YAAAA,EAAS,QAAQ,EA2B5F,OA1BJO,EAAoB,QAAUP,GAAA,YAAAA,EAAS,SAEvCS,EAAAA,UAAU,IAAM,CACd,GAAI,CAACR,GAAW,CAACH,GAAU,CAACO,EAAY,MAAO,OAE/C,MAAMK,EAAUZ,EAASa,EAAAA,WAAWb,CAAM,EAAIO,EAAY,QAC1D,GAAI,CAACK,EAAS,OAEd,MAAME,EAAW,IAAI,qBACnB,CAAC,CAACV,CAAK,IAAM,OACXC,EAASD,CAAK,GACdW,EAAAN,EAAoB,UAApB,MAAAM,EAAA,KAAAN,EAA8BL,EAChC,EACA,CACE,GAAGF,EACH,KAAMA,GAAA,MAAAA,EAAS,KAAQW,EAAW,WAAAX,EAAQ,IAAI,EAA2B,QAAA,CAE7E,EAEA,OAAAY,EAAS,QAAQF,CAAkB,EAE5B,IAAM,CACXE,EAAS,WAAW,CACtB,CACC,EAAA,CAACd,EAAQO,EAAY,MAAOL,GAAA,YAAAA,EAAS,WAAYA,GAAA,YAAAA,EAAS,UAAWA,GAAA,YAAAA,EAAS,KAAMC,CAAO,CAAC,EAE3FH,EAAe,CAAE,MAAAI,EAAO,OAAQ,CAAC,EAACA,GAAA,MAAAA,EAAO,eAAe,EACrD,CACL,IAAKG,EACL,MAAAH,EACA,OAAQ,CAAC,EAACA,GAAA,MAAAA,EAAO,eACnB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),R=(h={})=>{const r=typeof window<"u"&&"speechSynthesis"in window,{text:i="",lang:a="en-US",pitch:l=1,rate:p=1,voice:w=null,volume:f=1}=h,[S,s]=u.useState(!1),[y,c]=u.useState("init"),[g,m]=u.useState(),t=u.useRef(null),d=e=>{e.lang=a,e.pitch=l,e.rate=p,e.volume=f,e.voice=w,e.onstart=()=>{s(!0),c("play")},e.onpause=()=>{s(!1),c("pause")},e.onresume=()=>{s(!0),c("play")},e.onend=()=>{s(!1),c("end")},e.onerror=n=>{s(!1),m(n)}};u.useEffect(()=>{if(!r)return;const e=new SpeechSynthesisUtterance(i);return d(e),t.current=e,()=>{var n;(n=window.speechSynthesis)==null||n.cancel()}},[i,a,l,p,w,f]);const v=e=>{var n,o;r&&(e&&(t.current=new SpeechSynthesisUtterance(e),d(t.current)),(n=window.speechSynthesis)==null||n.cancel(),t.current&&((o=window.speechSynthesis)==null||o.speak(t.current)))},b=()=>{var e;r&&((e=window.speechSynthesis)==null||e.cancel(),s(!1))},k=(e=!S)=>{var n,o;r&&(e?(n=window.speechSynthesis)==null||n.resume():(o=window.speechSynthesis)==null||o.pause(),s(e))},E=()=>{var e;s(!0),(e=window.speechSynthesis)==null||e.resume()},P=()=>{var e;s(!1),(e=window.speechSynthesis)==null||e.pause()};return{supported:r,playing:S,status:y,utterance:t.current,error:g,stop:b,toggle:k,speak:v,resume:E,pause:P}};exports.useSpeechSynthesis=R;
|
|
2
|
+
//# sourceMappingURL=useSpeechSynthesis.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpeechSynthesis.cjs","sources":["../../../../src/hooks/useSpeechSynthesis/useSpeechSynthesis.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\n/** The use speech synthesis status type */\nexport type UseSpeechSynthesisStatus = 'end' | 'init' | 'pause' | 'play';\n\n/** The use speech synthesis options type */\nexport interface UseSpeechSynthesisOptions {\n /** Language for SpeechSynthesis */\n lang?: string;\n /** Gets and sets the pitch at which the utterance will be spoken at. */\n pitch?: number;\n /** Gets and sets the speed at which the utterance will be spoken at. */\n rate?: number;\n /** The text to be spoken */\n text?: string;\n /** Gets and sets the voice that will be used to speak the utterance. */\n voice?: SpeechSynthesisVoice | null;\n /** Gets and sets the volume that the utterance will be spoken at. */\n volume?: number;\n}\n\n/** The use speech synthesis return type */\nexport interface UseSpeechSynthesisReturn {\n /** Any error that occurred during speech synthesis. */\n error: SpeechSynthesisErrorEvent | undefined;\n /** Indicates if speech is currently playing. */\n playing: boolean;\n /** The current status of speech synthesis. */\n status: UseSpeechSynthesisStatus;\n /** Indicates if the SpeechSynthesis API is supported in the current environment. */\n supported: boolean;\n /** The SpeechSynthesisUtterance instance. */\n utterance: SpeechSynthesisUtterance | null;\n /** Function to pause speech synthesis. */\n pause: () => void;\n /** Function to resume speech synthesis. */\n resume: () => void;\n /** Function to start speech synthesis. */\n speak: () => void;\n /** Function to stop speech synthesis. */\n stop: () => void;\n /** Function to toggle between play and pause. */\n toggle: (value?: boolean) => void;\n}\n\n/**\n * @name useSpeechSynthesis\n * @description - Hook that provides speech synthesis functionality\n * @category Sensors\n *\n * @browserapi SpeechSynthesis https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis\n *\n * @params {string} [options.text] - The text to be spoken\n * @params {string} [options.lang] - The language to be spoken\n * @params {number} [options.pitch] - The pitch to be spoken\n * @params {number} [options.rate] - The rate to be spoken\n * @params {SpeechSynthesisVoice} [options.voice] - The voice to be spoken\n * @params {number} [options.volume] - The volume to be spoken\n * @returns {UseSpeechSynthesisReturn} An object containing the speech synthesis state and control methods\n *\n * @example\n * const { supported, playing, status, utterance, error, stop, toggle, speak, resume, pause } = useSpeechSynthesis();\n */\nexport const useSpeechSynthesis = (\n options: UseSpeechSynthesisOptions = {}\n): UseSpeechSynthesisReturn => {\n const supported = typeof window !== 'undefined' && 'speechSynthesis' in window;\n\n const { text = '', lang = 'en-US', pitch = 1, rate = 1, voice = null, volume = 1 } = options;\n\n const [playing, setPlaying] = useState(false);\n const [status, setStatus] = useState<UseSpeechSynthesisStatus>('init');\n const [error, setError] = useState<SpeechSynthesisErrorEvent>();\n const speechSynthesisUtteranceRef = useRef<SpeechSynthesisUtterance | null>(null);\n\n const bindSpeechSynthesisUtterance = (speechSynthesisUtterance: SpeechSynthesisUtterance) => {\n speechSynthesisUtterance.lang = lang;\n speechSynthesisUtterance.pitch = pitch;\n speechSynthesisUtterance.rate = rate;\n speechSynthesisUtterance.volume = volume;\n speechSynthesisUtterance.voice = voice;\n\n speechSynthesisUtterance.onstart = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onpause = () => {\n setPlaying(false);\n setStatus('pause');\n };\n\n speechSynthesisUtterance.onresume = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onend = () => {\n setPlaying(false);\n setStatus('end');\n };\n\n speechSynthesisUtterance.onerror = (event) => {\n setPlaying(false);\n setError(event);\n };\n };\n\n useEffect(() => {\n if (!supported) return;\n\n const speechSynthesisUtterance = new SpeechSynthesisUtterance(text);\n bindSpeechSynthesisUtterance(speechSynthesisUtterance);\n speechSynthesisUtteranceRef.current = speechSynthesisUtterance;\n\n return () => {\n window.speechSynthesis?.cancel();\n };\n }, [text, lang, pitch, rate, voice, volume]);\n\n const speak = (text?: string) => {\n if (!supported) return;\n\n if (text) {\n speechSynthesisUtteranceRef.current = new SpeechSynthesisUtterance(text);\n bindSpeechSynthesisUtterance(speechSynthesisUtteranceRef.current);\n }\n\n window.speechSynthesis?.cancel();\n if (speechSynthesisUtteranceRef.current)\n window.speechSynthesis?.speak(speechSynthesisUtteranceRef.current);\n };\n\n const stop = () => {\n if (!supported) return;\n\n window.speechSynthesis?.cancel();\n setPlaying(false);\n };\n\n const toggle = (value = !playing) => {\n if (!supported) return;\n\n if (value) {\n window.speechSynthesis?.resume();\n } else {\n window.speechSynthesis?.pause();\n }\n setPlaying(value);\n };\n\n const resume = () => {\n setPlaying(true);\n window.speechSynthesis?.resume();\n };\n\n const pause = () => {\n setPlaying(false);\n window.speechSynthesis?.pause();\n };\n\n return {\n supported,\n playing,\n status,\n utterance: speechSynthesisUtteranceRef.current,\n error,\n\n stop,\n toggle,\n speak,\n resume,\n pause\n };\n};\n"],"names":["useSpeechSynthesis","options","supported","text","lang","pitch","rate","voice","volume","playing","setPlaying","useState","status","setStatus","error","setError","speechSynthesisUtteranceRef","useRef","bindSpeechSynthesisUtterance","speechSynthesisUtterance","event","useEffect","_a","speak","_b","stop","toggle","value","resume","pause"],"mappings":"yGA+DaA,EAAqB,CAChCC,EAAqC,KACR,CAC7B,MAAMC,EAAY,OAAO,OAAW,KAAe,oBAAqB,OAElE,CAAE,KAAAC,EAAO,GAAI,KAAAC,EAAO,QAAS,MAAAC,EAAQ,EAAG,KAAAC,EAAO,EAAG,MAAAC,EAAQ,KAAM,OAAAC,EAAS,CAAM,EAAAP,EAE/E,CAACQ,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EACtC,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAmC,MAAM,EAC/D,CAACG,EAAOC,CAAQ,EAAIJ,WAAoC,EACxDK,EAA8BC,SAAwC,IAAI,EAE1EC,EAAgCC,GAAuD,CAC3FA,EAAyB,KAAOf,EAChCe,EAAyB,MAAQd,EACjCc,EAAyB,KAAOb,EAChCa,EAAyB,OAASX,EAClCW,EAAyB,MAAQZ,EAEjCY,EAAyB,QAAU,IAAM,CACvCT,EAAW,EAAI,EACfG,EAAU,MAAM,CAClB,EAEAM,EAAyB,QAAU,IAAM,CACvCT,EAAW,EAAK,EAChBG,EAAU,OAAO,CACnB,EAEAM,EAAyB,SAAW,IAAM,CACxCT,EAAW,EAAI,EACfG,EAAU,MAAM,CAClB,EAEAM,EAAyB,MAAQ,IAAM,CACrCT,EAAW,EAAK,EAChBG,EAAU,KAAK,CACjB,EAEyBM,EAAA,QAAWC,GAAU,CAC5CV,EAAW,EAAK,EAChBK,EAASK,CAAK,CAChB,CACF,EAEAC,EAAAA,UAAU,IAAM,CACd,GAAI,CAACnB,EAAW,OAEV,MAAAiB,EAA2B,IAAI,yBAAyBhB,CAAI,EAClE,OAAAe,EAA6BC,CAAwB,EACrDH,EAA4B,QAAUG,EAE/B,IAAM,QACXG,EAAA,OAAO,kBAAP,MAAAA,EAAwB,QAC1B,CAAA,EACC,CAACnB,EAAMC,EAAMC,EAAOC,EAAMC,EAAOC,CAAM,CAAC,EAErC,MAAAe,EAASpB,GAAkB,SAC1BD,IAEDC,IAC0Ba,EAAA,QAAU,IAAI,yBAAyBb,CAAI,EACvEe,EAA6BF,EAA4B,OAAO,IAGlEM,EAAA,OAAO,kBAAP,MAAAA,EAAwB,SACpBN,EAA4B,WACvBQ,EAAA,OAAA,kBAAA,MAAAA,EAAiB,MAAMR,EAA4B,UAC9D,EAEMS,EAAO,IAAM,OACZvB,KAELoB,EAAA,OAAO,kBAAP,MAAAA,EAAwB,SACxBZ,EAAW,EAAK,EAClB,EAEMgB,EAAS,CAACC,EAAQ,CAAClB,IAAY,SAC9BP,IAEDyB,GACFL,EAAA,OAAO,kBAAP,MAAAA,EAAwB,UAExBE,EAAA,OAAO,kBAAP,MAAAA,EAAwB,QAE1Bd,EAAWiB,CAAK,EAClB,EAEMC,EAAS,IAAM,OACnBlB,EAAW,EAAI,GACfY,EAAA,OAAO,kBAAP,MAAAA,EAAwB,QAC1B,EAEMO,EAAQ,IAAM,OAClBnB,EAAW,EAAK,GAChBY,EAAA,OAAO,kBAAP,MAAAA,EAAwB,OAC1B,EAEO,MAAA,CACL,UAAApB,EACA,QAAAO,EACA,OAAAG,EACA,UAAWI,EAA4B,QACvC,MAAAF,EAEA,KAAAW,EACA,OAAAC,EACA,MAAAH,EACA,OAAAK,EACA,MAAAC,CACF,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),v=e=>{const r=typeof navigator<"u"&&"wakeLock"in navigator,[l,c]=i.useState(!1),t=i.useRef(),d=(e==null?void 0:e.immediately)??!1,n=(e==null?void 0:e.type)??"screen",s=async a=>{r&&(t.current=await navigator.wakeLock.request(a??(e==null?void 0:e.type)),t.current.addEventListener("release",()=>{c(!1),t.current=void 0}),c(!0))},u=async()=>{!r||!t.current||(await t.current.release(),t.current=void 0,c(!1))};return i.useEffect(()=>{if(!r||!d||document.visibilityState!=="visible"||n!=="screen")return;const a=async()=>{await u(),await s(n)};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[n]),{supported:r,active:l,request:s,release:u}};exports.useWakeLock=v;
|
|
2
|
+
//# sourceMappingURL=useWakeLock.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWakeLock.cjs","sources":["../../../../src/hooks/useWakeLock/useWakeLock.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\n/** The use wake lock options type */\nexport interface UseWakeLockOptions {\n /** Determines if the wake lock should be automatically reacquired when the document becomes visible. */\n immediately?: boolean;\n /** A string specifying the screen wake lock type. */\n type?: WakeLockType;\n}\n\n/** The use wake lock return type */\nexport interface UseWakeLockReturn {\n /** Indicates if the wake lock is currently active. */\n active: boolean;\n /** Indicates if the Wake Lock API is supported in the current environment. */\n supported: boolean;\n /** Function to release the wake lock. */\n release: () => Promise<void>;\n /** Function to request the wake lock. */\n request: () => Promise<void>;\n}\n\n/**\n * @name useWakeLock\n * @description - Hook that provides a wake lock functionality\n * @category Browser\n *\n * @browserapi navigator.wakeLock https://developer.mozilla.org/en-US/docs/Web/API/WakeLock\n *\n * @param {immediately} [options] Configuration options for the hook.\n * @returns {UseWakeLockReturn} An object containing the wake lock state and control methods.\n *\n * @example\n * const { supported, active, request, release } = useWakeLock();\n */\nexport const useWakeLock = (options?: UseWakeLockOptions): UseWakeLockReturn => {\n const supported = typeof navigator !== 'undefined' && 'wakeLock' in navigator;\n\n const [active, setActive] = useState(false);\n const sentinel = useRef<WakeLockSentinel>();\n\n const immediately = options?.immediately ?? false;\n const type = options?.type ?? 'screen';\n\n const request = async (type?: WakeLockType) => {\n if (!supported) return;\n\n sentinel.current = await navigator.wakeLock.request(type ?? options?.type);\n sentinel.current.addEventListener('release', () => {\n setActive(false);\n sentinel.current = undefined;\n });\n\n setActive(true);\n };\n\n const release = async () => {\n if (!supported || !sentinel.current) return;\n\n await sentinel.current.release();\n sentinel.current = undefined;\n setActive(false);\n };\n\n useEffect(() => {\n if (!supported || !immediately || document.visibilityState !== 'visible' || type !== 'screen')\n return;\n\n const onVisibilityChange = async () => {\n await release();\n await request(type);\n };\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n return () => {\n document.removeEventListener('visibilitychange', onVisibilityChange);\n };\n }, [type]);\n\n return { supported, active, request, release };\n};\n"],"names":["useWakeLock","options","supported","active","setActive","useState","sentinel","useRef","immediately","type","request","release","useEffect","onVisibilityChange"],"mappings":"yGAmCaA,EAAeC,GAAoD,CAC9E,MAAMC,EAAY,OAAO,UAAc,KAAe,aAAc,UAE9D,CAACC,EAAQC,CAAS,EAAIC,EAAAA,SAAS,EAAK,EACpCC,EAAWC,EAAAA,OAAyB,EAEpCC,GAAcP,GAAA,YAAAA,EAAS,cAAe,GACtCQ,GAAOR,GAAA,YAAAA,EAAS,OAAQ,SAExBS,EAAU,MAAOD,GAAwB,CACxCP,IAELI,EAAS,QAAU,MAAM,UAAU,SAAS,QAAQG,IAAQR,GAAA,YAAAA,EAAS,KAAI,EAChEK,EAAA,QAAQ,iBAAiB,UAAW,IAAM,CACjDF,EAAU,EAAK,EACfE,EAAS,QAAU,MAAA,CACpB,EAEDF,EAAU,EAAI,EAChB,EAEMO,EAAU,SAAY,CACtB,CAACT,GAAa,CAACI,EAAS,UAEtB,MAAAA,EAAS,QAAQ,QAAQ,EAC/BA,EAAS,QAAU,OACnBF,EAAU,EAAK,EACjB,EAEAQ,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAI,CAACV,GAAa,CAACM,GAAe,SAAS,kBAAoB,WAAaC,IAAS,SACnF,OAEF,MAAMI,EAAqB,SAAY,CACrC,MAAMF,EAAQ,EACd,MAAMD,EAAQD,CAAI,CACpB,EAES,gBAAA,iBAAiB,mBAAoBI,CAAkB,EACzD,IAAM,CACF,SAAA,oBAAoB,mBAAoBA,CAAkB,CACrE,CAAA,EACC,CAACJ,CAAI,CAAC,EAEF,CAAE,UAAAP,EAAW,OAAAC,EAAQ,QAAAO,EAAS,QAAAC,CAAQ,CAC/C"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./hooks/useActiveElement/useActiveElement.cjs"),C=require("./hooks/useAsync/useAsync.cjs"),E=require("./hooks/useBattery/useBattery.cjs"),m=require("./hooks/useBluetooth/useBluetooth.cjs"),p=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),R=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),O=require("./hooks/useClickOutside/useClickOutside.cjs"),y=require("./hooks/useClipboard/useClipboard.cjs"),I=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),u=require("./hooks/useCookies/useCookies.cjs"),k=require("./hooks/useCopy/useCopy.cjs"),v=require("./hooks/useCounter/useCounter.cjs"),D=require("./hooks/useCssVar/useCssVar.cjs"),b=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),A=require("./hooks/useDebounceValue/useDebounceValue.cjs"),M=require("./hooks/useDefault/useDefault.cjs"),f=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),L=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),h=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),_=require("./hooks/useDidUpdate/useDidUpdate.cjs"),N=require("./hooks/useDisclosure/useDisclosure.cjs"),B=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),K=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),V=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),F=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),w=require("./hooks/useDoubleClick/useDoubleClick.cjs"),W=require("./hooks/useElementSize/useElementSize.cjs"),x=require("./hooks/useEvent/useEvent.cjs"),H=require("./hooks/useEventListener/useEventListener.cjs"),U=require("./hooks/useEyeDropper/useEyeDropper.cjs"),z=require("./hooks/useFavicon/useFavicon.cjs"),G=require("./hooks/useField/useField.cjs"),Q=require("./hooks/useFileDialog/useFileDialog.cjs"),X=require("./hooks/useFocus/useFocus.cjs"),j=require("./hooks/useFps/useFps.cjs"),J=require("./hooks/useFullscreen/useFullscreen.cjs"),i=require("./hooks/useGamepad/useGamepad.cjs"),Y=require("./hooks/useGeolocation/useGeolocation.cjs"),Z=require("./hooks/useHash/useHash.cjs"),n=require("./hooks/useHotkeys/useHotkeys.cjs"),$=require("./hooks/useHover/useHover.cjs"),ee=require("./hooks/useIdle/useIdle.cjs"),se=require("./hooks/useImage/useImage.cjs"),ue=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),re=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),te=require("./hooks/useInterval/useInterval.cjs"),oe=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),ie=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),ne=require("./hooks/useKeyboard/useKeyboard.cjs"),ce=require("./hooks/useKeyPress/useKeyPress.cjs"),ae=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),le=require("./hooks/useKeysPressed/useKeysPressed.cjs"),qe=require("./hooks/useLastChanged/useLastChanged.cjs"),Se=require("./hooks/useLatest/useLatest.cjs"),de=require("./hooks/useLess/useLess.cjs"),ge=require("./hooks/useList/useList.cjs"),Te=require("./hooks/useLocalStorage/useLocalStorage.cjs"),Pe=require("./hooks/useLockCallback/useLockCallback.cjs"),Ce=require("./hooks/useLogger/useLogger.cjs"),Ee=require("./hooks/useLongPress/useLongPress.cjs"),me=require("./hooks/useMap/useMap.cjs"),pe=require("./hooks/useMeasure/useMeasure.cjs"),Re=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Oe=require("./hooks/useMemory/useMemory.cjs"),ye=require("./hooks/useMount/useMount.cjs"),Ie=require("./hooks/useMouse/useMouse.cjs"),ke=require("./hooks/useMutation/useMutation.cjs"),ve=require("./hooks/useMutationObserver/useMutationObserver.cjs"),c=require("./hooks/useNetwork/useNetwork.cjs"),De=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),be=require("./hooks/useOnce/useOnce.cjs"),Ae=require("./hooks/useOnline/useOnline.cjs"),a=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Me=require("./hooks/useOptimistic/useOptimistic.cjs"),fe=require("./hooks/useOrientation/useOrientation.cjs"),Le=require("./hooks/useOtpCredential/useOtpCredential.cjs"),he=require("./hooks/usePageLeave/usePageLeave.cjs"),r=require("./hooks/usePaint/usePaint.cjs"),_e=require("./hooks/useParallax/useParallax.cjs"),Ne=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),Be=require("./hooks/usePermission/usePermission.cjs"),Ke=require("./hooks/usePointerLock/usePointerLock.cjs"),Ve=require("./hooks/usePostMessage/usePostMessage.cjs"),Fe=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),we=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),We=require("./hooks/usePreferredDark/usePreferredDark.cjs"),xe=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),He=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),Ue=require("./hooks/usePrevious/usePrevious.cjs"),ze=require("./hooks/useQuery/useQuery.cjs"),Ge=require("./hooks/useQueue/useQueue.cjs"),Qe=require("./hooks/useRaf/useRaf.cjs"),Xe=require("./hooks/useRafValue/useRafValue.cjs"),je=require("./hooks/useRefState/useRefState.cjs"),Je=require("./hooks/useRenderCount/useRenderCount.cjs"),Ye=require("./hooks/useRenderInfo/useRenderInfo.cjs"),Ze=require("./hooks/useRerender/useRerender.cjs"),$e=require("./hooks/useResizeObserver/useResizeObserver.cjs"),es=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),l=require("./hooks/useScript/useScript.cjs"),ss=require("./hooks/useScroll/useScroll.cjs"),us=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),rs=require("./hooks/useScrollTo/useScrollTo.cjs"),ts=require("./hooks/useSessionStorage/useSessionStorage.cjs"),os=require("./hooks/useSet/useSet.cjs"),is=require("./hooks/useShare/useShare.cjs"),q=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),ns=require("./hooks/useStateHistory/useStateHistory.cjs"),cs=require("./hooks/useStep/useStep.cjs"),as=require("./hooks/useSticky/useSticky.cjs"),ls=require("./hooks/useStopwatch/useStopwatch.cjs"),t=require("./hooks/useStorage/useStorage.cjs"),qs=require("./hooks/useTextDirection/useTextDirection.cjs"),S=require("./hooks/useTextSelection/useTextSelection.cjs"),Ss=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),ds=require("./hooks/useThrottleValue/useThrottleValue.cjs"),gs=require("./hooks/useTime/useTime.cjs"),Ts=require("./hooks/useTimeout/useTimeout.cjs"),d=require("./hooks/useTimer/useTimer.cjs"),Ps=require("./hooks/useToggle/useToggle.cjs"),Cs=require("./hooks/useUnmount/useUnmount.cjs"),Es=require("./hooks/useVibrate/useVibrate.cjs"),ms=require("./hooks/useWebSocket/useWebSocket.cjs"),ps=require("./hooks/useWindowEvent/useWindowEvent.cjs"),Rs=require("./hooks/useWindowFocus/useWindowFocus.cjs"),g=require("./hooks/useWindowScroll/useWindowScroll.cjs"),Os=require("./hooks/useWindowSize/useWindowSize.cjs"),ys=require("./hooks/useWizard/useWizard.cjs"),T=require("./utils/helpers/copy.cjs"),Is=require("./utils/helpers/debounce.cjs"),ks=require("./utils/helpers/getDate.cjs"),o=require("./utils/helpers/getElement.cjs"),vs=require("./utils/helpers/getRetry.cjs"),Ds=require("./utils/helpers/isTarget.cjs"),bs=require("./utils/helpers/throttle.cjs");exports.useActiveElement=P.useActiveElement;exports.useAsync=C.useAsync;exports.useBattery=E.useBattery;exports.useBluetooth=m.useBluetooth;exports.useBoolean=p.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=R.useBrowserLanguage;exports.useClickOutside=O.useClickOutside;exports.useClipboard=y.useClipboard;exports.useConst=I.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=u.clearCookies;exports.getParsedCookies=u.getParsedCookies;exports.useCookies=u.useCookies;exports.useCopy=k.useCopy;exports.useCounter=v.useCounter;exports.useCssVar=D.useCssVar;exports.useDebounceCallback=b.useDebounceCallback;exports.useDebounceValue=A.useDebounceValue;exports.useDefault=M.useDefault;exports.useDeviceMotion=f.useDeviceMotion;exports.useDeviceOrientation=L.useDeviceOrientation;exports.useDevicePixelRatio=h.useDevicePixelRatio;exports.useDidUpdate=_.useDidUpdate;exports.useDisclosure=N.useDisclosure;exports.useDisplayMedia=B.useDisplayMedia;exports.useDocumentEvent=K.useDocumentEvent;exports.useDocumentTitle=V.useDocumentTitle;exports.useDocumentVisibility=F.useDocumentVisibility;exports.useDoubleClick=w.useDoubleClick;exports.useElementSize=W.useElementSize;exports.useEvent=x.useEvent;exports.useEventListener=H.useEventListener;exports.useEyeDropper=U.useEyeDropper;exports.useFavicon=z.useFavicon;exports.useField=G.useField;exports.useFileDialog=Q.useFileDialog;exports.useFocus=X.useFocus;exports.useFps=j.useFps;exports.useFullscreen=J.useFullscreen;exports.mapGamepadToXbox360Controller=i.mapGamepadToXbox360Controller;exports.useGamepad=i.useGamepad;exports.useGeolocation=Y.useGeolocation;exports.useHash=Z.useHash;exports.isHotkeyMatch=n.isHotkeyMatch;exports.useHotkeys=n.useHotkeys;exports.useHover=$.useHover;exports.useIdle=ee.useIdle;exports.useImage=se.useImage;exports.useInfiniteScroll=ue.useInfiniteScroll;exports.useIntersectionObserver=re.useIntersectionObserver;exports.useInterval=te.useInterval;exports.useIsFirstRender=oe.useIsFirstRender;exports.useIsomorphicLayoutEffect=ie.useIsomorphicLayoutEffect;exports.useKeyboard=ne.useKeyboard;exports.useKeyPress=ce.useKeyPress;exports.useKeyPressEvent=ae.useKeyPressEvent;exports.useKeysPressed=le.useKeysPressed;exports.useLastChanged=qe.useLastChanged;exports.useLatest=Se.useLatest;exports.useLess=de.useLess;exports.useList=ge.useList;exports.useLocalStorage=Te.useLocalStorage;exports.useLockCallback=Pe.useLockCallback;exports.useLogger=Ce.useLogger;exports.useLongPress=Ee.useLongPress;exports.useMap=me.useMap;exports.useMeasure=pe.useMeasure;exports.useMediaQuery=Re.useMediaQuery;exports.useMemory=Oe.useMemory;exports.useMount=ye.useMount;exports.useMouse=Ie.useMouse;exports.useMutation=ke.useMutation;exports.useMutationObserver=ve.useMutationObserver;exports.getConnection=c.getConnection;exports.useNetwork=c.useNetwork;exports.useOffsetPagination=De.useOffsetPagination;exports.useOnce=be.useOnce;exports.useOnline=Ae.useOnline;exports.getOperatingSystem=a.getOperatingSystem;exports.useOperatingSystem=a.useOperatingSystem;exports.useOptimistic=Me.useOptimistic;exports.useOrientation=fe.useOrientation;exports.useOtpCredential=Le.useOtpCredential;exports.usePageLeave=he.usePageLeave;exports.Paint=r.Paint;exports.Pointer=r.Pointer;exports.usePaint=r.usePaint;exports.useParallax=_e.useParallax;exports.usePerformanceObserver=Ne.usePerformanceObserver;exports.usePermission=Be.usePermission;exports.usePointerLock=Ke.usePointerLock;exports.usePostMessage=Ve.usePostMessage;exports.usePreferredColorScheme=Fe.usePreferredColorScheme;exports.usePreferredContrast=we.usePreferredContrast;exports.usePreferredDark=We.usePreferredDark;exports.usePreferredLanguages=xe.usePreferredLanguages;exports.usePreferredReducedMotion=He.usePreferredReducedMotion;exports.usePrevious=Ue.usePrevious;exports.useQuery=ze.useQuery;exports.useQueue=Ge.useQueue;exports.useRaf=Qe.useRaf;exports.useRafValue=Xe.useRafValue;exports.useRefState=je.useRefState;exports.useRenderCount=Je.useRenderCount;exports.useRenderInfo=Ye.useRenderInfo;exports.useRerender=Ze.useRerender;exports.useResizeObserver=$e.useResizeObserver;exports.useScreenOrientation=es.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=l.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=l.useScript;exports.useScroll=ss.useScroll;exports.useScrollIntoView=us.useScrollIntoView;exports.useScrollTo=rs.useScrollTo;exports.useSessionStorage=ts.useSessionStorage;exports.useSet=os.useSet;exports.useShare=is.useShare;exports.getSpeechRecognition=q.getSpeechRecognition;exports.useSpeechRecognition=q.useSpeechRecognition;exports.useStateHistory=ns.useStateHistory;exports.useStep=cs.useStep;exports.useSticky=as.useSticky;exports.useStopwatch=ls.useStopwatch;exports.STORAGE_EVENT=t.STORAGE_EVENT;exports.dispatchStorageEvent=t.dispatchStorageEvent;exports.useStorage=t.useStorage;exports.useTextDirection=qs.useTextDirection;exports.getRangesSelection=S.getRangesSelection;exports.useTextSelection=S.useTextSelection;exports.useThrottleCallback=Ss.useThrottleCallback;exports.useThrottleValue=ds.useThrottleValue;exports.useTime=gs.useTime;exports.useTimeout=Ts.useTimeout;exports.getTimeFromSeconds=d.getTimeFromSeconds;exports.useTimer=d.useTimer;exports.useToggle=Ps.useToggle;exports.useUnmount=Cs.useUnmount;exports.useVibrate=Es.useVibrate;exports.useWebSocket=ms.useWebSocket;exports.useWindowEvent=ps.useWindowEvent;exports.useWindowFocus=Rs.useWindowFocus;exports.scrollTo=g.scrollTo;exports.useWindowScroll=g.useWindowScroll;exports.useWindowSize=Os.useWindowSize;exports.useWizard=ys.useWizard;exports.copy=T.copy;exports.legacyCopyToClipboard=T.legacyCopyToClipboard;exports.debounce=Is.debounce;exports.getDate=ks.getDate;exports.getElement=o.getElement;exports.target=o.target;exports.targetSymbol=o.targetSymbol;exports.getRetry=vs.getRetry;exports.isTarget=Ds.isTarget;exports.throttle=bs.throttle;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./hooks/useActiveElement/useActiveElement.cjs"),C=require("./hooks/useAsync/useAsync.cjs"),E=require("./hooks/useBattery/useBattery.cjs"),m=require("./hooks/useBluetooth/useBluetooth.cjs"),p=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),y=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),R=require("./hooks/useClickOutside/useClickOutside.cjs"),O=require("./hooks/useClipboard/useClipboard.cjs"),k=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),u=require("./hooks/useCookies/useCookies.cjs"),I=require("./hooks/useCopy/useCopy.cjs"),v=require("./hooks/useCounter/useCounter.cjs"),D=require("./hooks/useCssVar/useCssVar.cjs"),b=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),A=require("./hooks/useDebounceValue/useDebounceValue.cjs"),L=require("./hooks/useDefault/useDefault.cjs"),M=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),f=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),h=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),_=require("./hooks/useDidUpdate/useDidUpdate.cjs"),N=require("./hooks/useDisclosure/useDisclosure.cjs"),B=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),K=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),F=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),V=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),w=require("./hooks/useDoubleClick/useDoubleClick.cjs"),W=require("./hooks/useElementSize/useElementSize.cjs"),x=require("./hooks/useEvent/useEvent.cjs"),H=require("./hooks/useEventListener/useEventListener.cjs"),U=require("./hooks/useEyeDropper/useEyeDropper.cjs"),z=require("./hooks/useFavicon/useFavicon.cjs"),G=require("./hooks/useField/useField.cjs"),Q=require("./hooks/useFileDialog/useFileDialog.cjs"),X=require("./hooks/useFocus/useFocus.cjs"),j=require("./hooks/useFps/useFps.cjs"),J=require("./hooks/useFul/useFul.cjs"),Y=require("./hooks/useFullscreen/useFullscreen.cjs"),i=require("./hooks/useGamepad/useGamepad.cjs"),Z=require("./hooks/useGeolocation/useGeolocation.cjs"),$=require("./hooks/useHash/useHash.cjs"),n=require("./hooks/useHotkeys/useHotkeys.cjs"),ee=require("./hooks/useHover/useHover.cjs"),se=require("./hooks/useIdle/useIdle.cjs"),ue=require("./hooks/useImage/useImage.cjs"),re=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),te=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),oe=require("./hooks/useInterval/useInterval.cjs"),ie=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),ne=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),ce=require("./hooks/useKeyboard/useKeyboard.cjs"),ae=require("./hooks/useKeyPress/useKeyPress.cjs"),le=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),qe=require("./hooks/useKeysPressed/useKeysPressed.cjs"),Se=require("./hooks/useLastChanged/useLastChanged.cjs"),de=require("./hooks/useLatest/useLatest.cjs"),ge=require("./hooks/useLess/useLess.cjs"),Te=require("./hooks/useList/useList.cjs"),Pe=require("./hooks/useLocalStorage/useLocalStorage.cjs"),Ce=require("./hooks/useLockCallback/useLockCallback.cjs"),Ee=require("./hooks/useLogger/useLogger.cjs"),me=require("./hooks/useLongPress/useLongPress.cjs"),pe=require("./hooks/useMap/useMap.cjs"),ye=require("./hooks/useMeasure/useMeasure.cjs"),Re=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Oe=require("./hooks/useMemory/useMemory.cjs"),ke=require("./hooks/useMount/useMount.cjs"),Ie=require("./hooks/useMouse/useMouse.cjs"),ve=require("./hooks/useMutation/useMutation.cjs"),De=require("./hooks/useMutationObserver/useMutationObserver.cjs"),c=require("./hooks/useNetwork/useNetwork.cjs"),be=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),Ae=require("./hooks/useOnce/useOnce.cjs"),Le=require("./hooks/useOnline/useOnline.cjs"),a=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Me=require("./hooks/useOptimistic/useOptimistic.cjs"),fe=require("./hooks/useOrientation/useOrientation.cjs"),he=require("./hooks/useOtpCredential/useOtpCredential.cjs"),_e=require("./hooks/usePageLeave/usePageLeave.cjs"),r=require("./hooks/usePaint/usePaint.cjs"),Ne=require("./hooks/useParallax/useParallax.cjs"),Be=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),Ke=require("./hooks/usePermission/usePermission.cjs"),Fe=require("./hooks/usePointerLock/usePointerLock.cjs"),Ve=require("./hooks/usePostMessage/usePostMessage.cjs"),we=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),We=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),xe=require("./hooks/usePreferredDark/usePreferredDark.cjs"),He=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),Ue=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),ze=require("./hooks/usePrevious/usePrevious.cjs"),Ge=require("./hooks/useQuery/useQuery.cjs"),Qe=require("./hooks/useQueue/useQueue.cjs"),Xe=require("./hooks/useRaf/useRaf.cjs"),je=require("./hooks/useRafValue/useRafValue.cjs"),Je=require("./hooks/useRefState/useRefState.cjs"),Ye=require("./hooks/useRenderCount/useRenderCount.cjs"),Ze=require("./hooks/useRenderInfo/useRenderInfo.cjs"),$e=require("./hooks/useRerender/useRerender.cjs"),es=require("./hooks/useResizeObserver/useResizeObserver.cjs"),ss=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),l=require("./hooks/useScript/useScript.cjs"),us=require("./hooks/useScroll/useScroll.cjs"),rs=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),ts=require("./hooks/useScrollTo/useScrollTo.cjs"),os=require("./hooks/useSessionStorage/useSessionStorage.cjs"),is=require("./hooks/useSet/useSet.cjs"),ns=require("./hooks/useShare/useShare.cjs"),q=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),cs=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),as=require("./hooks/useStateHistory/useStateHistory.cjs"),ls=require("./hooks/useStep/useStep.cjs"),qs=require("./hooks/useSticky/useSticky.cjs"),Ss=require("./hooks/useStopwatch/useStopwatch.cjs"),t=require("./hooks/useStorage/useStorage.cjs"),ds=require("./hooks/useTextDirection/useTextDirection.cjs"),S=require("./hooks/useTextSelection/useTextSelection.cjs"),gs=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),Ts=require("./hooks/useThrottleValue/useThrottleValue.cjs"),Ps=require("./hooks/useTime/useTime.cjs"),Cs=require("./hooks/useTimeout/useTimeout.cjs"),d=require("./hooks/useTimer/useTimer.cjs"),Es=require("./hooks/useToggle/useToggle.cjs"),ms=require("./hooks/useUnmount/useUnmount.cjs"),ps=require("./hooks/useVibrate/useVibrate.cjs"),ys=require("./hooks/useWakeLock/useWakeLock.cjs"),Rs=require("./hooks/useWebSocket/useWebSocket.cjs"),Os=require("./hooks/useWindowEvent/useWindowEvent.cjs"),ks=require("./hooks/useWindowFocus/useWindowFocus.cjs"),g=require("./hooks/useWindowScroll/useWindowScroll.cjs"),Is=require("./hooks/useWindowSize/useWindowSize.cjs"),vs=require("./hooks/useWizard/useWizard.cjs"),T=require("./utils/helpers/copy.cjs"),Ds=require("./utils/helpers/debounce.cjs"),bs=require("./utils/helpers/getDate.cjs"),o=require("./utils/helpers/getElement.cjs"),As=require("./utils/helpers/getRetry.cjs"),Ls=require("./utils/helpers/isTarget.cjs"),Ms=require("./utils/helpers/throttle.cjs");exports.useActiveElement=P.useActiveElement;exports.useAsync=C.useAsync;exports.useBattery=E.useBattery;exports.useBluetooth=m.useBluetooth;exports.useBoolean=p.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=y.useBrowserLanguage;exports.useClickOutside=R.useClickOutside;exports.useClipboard=O.useClipboard;exports.useConst=k.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=u.clearCookies;exports.getParsedCookies=u.getParsedCookies;exports.useCookies=u.useCookies;exports.useCopy=I.useCopy;exports.useCounter=v.useCounter;exports.useCssVar=D.useCssVar;exports.useDebounceCallback=b.useDebounceCallback;exports.useDebounceValue=A.useDebounceValue;exports.useDefault=L.useDefault;exports.useDeviceMotion=M.useDeviceMotion;exports.useDeviceOrientation=f.useDeviceOrientation;exports.useDevicePixelRatio=h.useDevicePixelRatio;exports.useDidUpdate=_.useDidUpdate;exports.useDisclosure=N.useDisclosure;exports.useDisplayMedia=B.useDisplayMedia;exports.useDocumentEvent=K.useDocumentEvent;exports.useDocumentTitle=F.useDocumentTitle;exports.useDocumentVisibility=V.useDocumentVisibility;exports.useDoubleClick=w.useDoubleClick;exports.useElementSize=W.useElementSize;exports.useEvent=x.useEvent;exports.useEventListener=H.useEventListener;exports.useEyeDropper=U.useEyeDropper;exports.useFavicon=z.useFavicon;exports.useField=G.useField;exports.useFileDialog=Q.useFileDialog;exports.useFocus=X.useFocus;exports.useFps=j.useFps;exports.useFul=J.useFul;exports.useFullscreen=Y.useFullscreen;exports.mapGamepadToXbox360Controller=i.mapGamepadToXbox360Controller;exports.useGamepad=i.useGamepad;exports.useGeolocation=Z.useGeolocation;exports.useHash=$.useHash;exports.isHotkeyMatch=n.isHotkeyMatch;exports.useHotkeys=n.useHotkeys;exports.useHover=ee.useHover;exports.useIdle=se.useIdle;exports.useImage=ue.useImage;exports.useInfiniteScroll=re.useInfiniteScroll;exports.useIntersectionObserver=te.useIntersectionObserver;exports.useInterval=oe.useInterval;exports.useIsFirstRender=ie.useIsFirstRender;exports.useIsomorphicLayoutEffect=ne.useIsomorphicLayoutEffect;exports.useKeyboard=ce.useKeyboard;exports.useKeyPress=ae.useKeyPress;exports.useKeyPressEvent=le.useKeyPressEvent;exports.useKeysPressed=qe.useKeysPressed;exports.useLastChanged=Se.useLastChanged;exports.useLatest=de.useLatest;exports.useLess=ge.useLess;exports.useList=Te.useList;exports.useLocalStorage=Pe.useLocalStorage;exports.useLockCallback=Ce.useLockCallback;exports.useLogger=Ee.useLogger;exports.useLongPress=me.useLongPress;exports.useMap=pe.useMap;exports.useMeasure=ye.useMeasure;exports.useMediaQuery=Re.useMediaQuery;exports.useMemory=Oe.useMemory;exports.useMount=ke.useMount;exports.useMouse=Ie.useMouse;exports.useMutation=ve.useMutation;exports.useMutationObserver=De.useMutationObserver;exports.getConnection=c.getConnection;exports.useNetwork=c.useNetwork;exports.useOffsetPagination=be.useOffsetPagination;exports.useOnce=Ae.useOnce;exports.useOnline=Le.useOnline;exports.getOperatingSystem=a.getOperatingSystem;exports.useOperatingSystem=a.useOperatingSystem;exports.useOptimistic=Me.useOptimistic;exports.useOrientation=fe.useOrientation;exports.useOtpCredential=he.useOtpCredential;exports.usePageLeave=_e.usePageLeave;exports.Paint=r.Paint;exports.Pointer=r.Pointer;exports.usePaint=r.usePaint;exports.useParallax=Ne.useParallax;exports.usePerformanceObserver=Be.usePerformanceObserver;exports.usePermission=Ke.usePermission;exports.usePointerLock=Fe.usePointerLock;exports.usePostMessage=Ve.usePostMessage;exports.usePreferredColorScheme=we.usePreferredColorScheme;exports.usePreferredContrast=We.usePreferredContrast;exports.usePreferredDark=xe.usePreferredDark;exports.usePreferredLanguages=He.usePreferredLanguages;exports.usePreferredReducedMotion=Ue.usePreferredReducedMotion;exports.usePrevious=ze.usePrevious;exports.useQuery=Ge.useQuery;exports.useQueue=Qe.useQueue;exports.useRaf=Xe.useRaf;exports.useRafValue=je.useRafValue;exports.useRefState=Je.useRefState;exports.useRenderCount=Ye.useRenderCount;exports.useRenderInfo=Ze.useRenderInfo;exports.useRerender=$e.useRerender;exports.useResizeObserver=es.useResizeObserver;exports.useScreenOrientation=ss.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=l.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=l.useScript;exports.useScroll=us.useScroll;exports.useScrollIntoView=rs.useScrollIntoView;exports.useScrollTo=ts.useScrollTo;exports.useSessionStorage=os.useSessionStorage;exports.useSet=is.useSet;exports.useShare=ns.useShare;exports.getSpeechRecognition=q.getSpeechRecognition;exports.useSpeechRecognition=q.useSpeechRecognition;exports.useSpeechSynthesis=cs.useSpeechSynthesis;exports.useStateHistory=as.useStateHistory;exports.useStep=ls.useStep;exports.useSticky=qs.useSticky;exports.useStopwatch=Ss.useStopwatch;exports.STORAGE_EVENT=t.STORAGE_EVENT;exports.dispatchStorageEvent=t.dispatchStorageEvent;exports.useStorage=t.useStorage;exports.useTextDirection=ds.useTextDirection;exports.getRangesSelection=S.getRangesSelection;exports.useTextSelection=S.useTextSelection;exports.useThrottleCallback=gs.useThrottleCallback;exports.useThrottleValue=Ts.useThrottleValue;exports.useTime=Ps.useTime;exports.useTimeout=Cs.useTimeout;exports.getTimeFromSeconds=d.getTimeFromSeconds;exports.useTimer=d.useTimer;exports.useToggle=Es.useToggle;exports.useUnmount=ms.useUnmount;exports.useVibrate=ps.useVibrate;exports.useWakeLock=ys.useWakeLock;exports.useWebSocket=Rs.useWebSocket;exports.useWindowEvent=Os.useWindowEvent;exports.useWindowFocus=ks.useWindowFocus;exports.scrollTo=g.scrollTo;exports.useWindowScroll=g.useWindowScroll;exports.useWindowSize=Is.useWindowSize;exports.useWizard=vs.useWizard;exports.copy=T.copy;exports.legacyCopyToClipboard=T.legacyCopyToClipboard;exports.debounce=Ds.debounce;exports.getDate=bs.getDate;exports.getElement=o.getElement;exports.target=o.target;exports.targetSymbol=o.targetSymbol;exports.getRetry=As.getRetry;exports.isTarget=Ls.isTarget;exports.throttle=Ms.throttle;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useIsomorphicLayoutEffect as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
1
|
+
import { useRef as u } from "react";
|
|
2
|
+
import { useIsomorphicLayoutEffect as e } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
|
|
3
|
+
const s = (t, o) => {
|
|
4
|
+
const r = u(!1);
|
|
5
|
+
e(
|
|
6
|
+
() => () => {
|
|
7
|
+
r.current = !1;
|
|
8
|
+
},
|
|
9
|
+
[]
|
|
10
|
+
), e(() => {
|
|
11
|
+
if (r.current)
|
|
12
|
+
return t();
|
|
13
|
+
r.current = !0;
|
|
13
14
|
}, o);
|
|
14
15
|
};
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
s as useDidUpdate
|
|
17
18
|
};
|
|
18
19
|
//# sourceMappingURL=useDidUpdate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDidUpdate.mjs","sources":["../../../../src/hooks/useDidUpdate/useDidUpdate.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/**\n * @name useDidUpdate\n * @description – Hook that triggers the effect callback on updates\n * @category Lifecycle\n *\n * @param {EffectCallback} effect The effect callback\n * @param {DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useDidUpdate(() => console.log(\"effect runs on updates\"),
|
|
1
|
+
{"version":3,"file":"useDidUpdate.mjs","sources":["../../../../src/hooks/useDidUpdate/useDidUpdate.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\r\n\r\nimport { useRef } from 'react';\r\n\r\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\r\n\r\n/**\r\n * @name useDidUpdate\r\n * @description – Hook that triggers the effect callback on updates\r\n * @category Lifecycle\r\n *\r\n * @param {EffectCallback} effect The effect callback\r\n * @param {DependencyList} [deps] The dependencies list for the effect\r\n *\r\n * @example\r\n * useDidUpdate(() => console.log(\"effect runs on updates\"), deps);\r\n */\r\nexport const useDidUpdate = (effect: EffectCallback, deps?: DependencyList) => {\r\n const mounted = useRef(false);\r\n\r\n useIsomorphicLayoutEffect(\r\n () => () => {\r\n mounted.current = false;\r\n },\r\n []\r\n );\r\n\r\n useIsomorphicLayoutEffect(() => {\r\n if (mounted.current) {\r\n return effect();\r\n }\r\n\r\n mounted.current = true;\r\n return undefined;\r\n }, deps);\r\n};\r\n"],"names":["useDidUpdate","effect","deps","mounted","useRef","useIsomorphicLayoutEffect"],"mappings":";;AAiBa,MAAAA,IAAe,CAACC,GAAwBC,MAA0B;AACvE,QAAAC,IAAUC,EAAO,EAAK;AAE5B,EAAAC;AAAA,IACE,MAAM,MAAM;AACV,MAAAF,EAAQ,UAAU;AAAA,IACpB;AAAA,IACA,CAAA;AAAA,EACF,GAEAE,EAA0B,MAAM;AAC9B,QAAIF,EAAQ;AACV,aAAOF,EAAO;AAGhB,IAAAE,EAAQ,UAAU;AAAA,KAEjBD,CAAI;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFul.mjs","sources":["../../../../src/hooks/useFul/useFul.ts"],"sourcesContent":["import { useEffect } from 'react';\n\n/**\n * @name useFul\n * @description - Hook that can be so useful\n * @category Humor\n *\n * @warning - This hook is a joke. Please do not use it in production code!\n *\n * @template Value The type of the value\n * @param {Value} [value] The value to be returned\n * @returns {Value} The value passed to the hook\n *\n * @example\n * const value = useFul(state);\n */\nexport const useFul = <Value>(value?: Value) => {\n useEffect(() => {\n console.warn(\"Warning: You forgot to delete the 'useFul' hook.\");\n }, []);\n\n return value;\n};\n"],"names":["useFul","value","useEffect"],"mappings":";AAgBa,MAAAA,IAAS,CAAQC,OAC5BC,EAAU,MAAM;AACd,UAAQ,KAAK,kDAAkD;AACjE,GAAG,EAAE,GAEED;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionObserver.mjs","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The intersection observer options type */\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n root?: HookTarget;\n onChange?: (entry: IntersectionObserverEntry) => void;\n}\n\n/** The intersection observer return type */\nexport interface UseIntersectionObserverReturn {\n entry?: IntersectionObserverEntry;\n inView: boolean;\n}\n\nexport interface UseIntersectionObserver {\n <Target extends Element>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;\n}\n\n/**\n * @name useIntersectionObserver\n * @description - Hook that gives you intersection observer state\n * @category Browser\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn} An object containing the state and the supported status\n *\n * @example\n * const { ref, entry, inView } = useIntersectionObserver();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entry, inView } = useIntersectionObserver(ref);\n */\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalOnChangeRef = useRef<UseIntersectionObserverOptions['onChange']>(options?.onChange);\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled && !target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n internalOnChangeRef.current?.(entry);\n },\n {\n ...options,\n root: options?.root ? (getElement(options.root) as Document | Element) : document\n }\n );\n\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return {\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","params","target","isTarget","options","enabled","entry","setEntry","useState","internalRef","useRefState","internalOnChangeRef","useRef","useEffect","element","getElement","observer","_a"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.mjs","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The intersection observer options type */\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n root?: HookTarget;\n onChange?: (entry: IntersectionObserverEntry) => void;\n}\n\n/** The intersection observer return type */\nexport interface UseIntersectionObserverReturn {\n entry?: IntersectionObserverEntry;\n inView: boolean;\n}\n\nexport interface UseIntersectionObserver {\n <Target extends Element>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;\n}\n\n/**\n * @name useIntersectionObserver\n * @description - Hook that gives you intersection observer state\n * @category Browser\n *\n * @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn} An object containing the state and the supported status\n *\n * @example\n * const { ref, entry, inView } = useIntersectionObserver();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entry, inView } = useIntersectionObserver(ref);\n */\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalOnChangeRef = useRef<UseIntersectionObserverOptions['onChange']>(options?.onChange);\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled && !target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n internalOnChangeRef.current?.(entry);\n },\n {\n ...options,\n root: options?.root ? (getElement(options.root) as Document | Element) : document\n }\n );\n\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return {\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","params","target","isTarget","options","enabled","entry","setEntry","useState","internalRef","useRefState","internalOnChangeRef","useRef","useEffect","element","getElement","observer","_a"],"mappings":";;;;AA2Da,MAAAA,IAA2B,IAAIC,MAAkB;AACtD,QAAAC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC5CG,IAAWF,IAASD,EAAO,CAAC,IAAIA,EAAO,CAAC,GACxCI,KAAUD,KAAA,gBAAAA,EAAS,YAAW,IAE9B,CAACE,GAAOC,CAAQ,IAAIC,EAAoC,GAExDC,IAAcC,EAAqB,GACnCC,IAAsBC,EAAmDR,KAAA,gBAAAA,EAAS,QAAQ;AA2B5F,SA1BJO,EAAoB,UAAUP,KAAA,gBAAAA,EAAS,UAEvCS,EAAU,MAAM;AACd,QAAI,CAACR,KAAW,CAACH,KAAU,CAACO,EAAY,MAAO;AAE/C,UAAMK,IAAUZ,IAASa,EAAWb,CAAM,IAAIO,EAAY;AAC1D,QAAI,CAACK,EAAS;AAEd,UAAME,IAAW,IAAI;AAAA,MACnB,CAAC,CAACV,CAAK,MAAM;;AACX,QAAAC,EAASD,CAAK,IACdW,IAAAN,EAAoB,YAApB,QAAAM,EAAA,KAAAN,GAA8BL;AAAAA,MAChC;AAAA,MACA;AAAA,QACE,GAAGF;AAAA,QACH,MAAMA,KAAA,QAAAA,EAAS,OAAQW,EAAWX,EAAQ,IAAI,IAA2B;AAAA,MAAA;AAAA,IAE7E;AAEA,WAAAY,EAAS,QAAQF,CAAkB,GAE5B,MAAM;AACX,MAAAE,EAAS,WAAW;AAAA,IACtB;AAAA,EACC,GAAA,CAACd,GAAQO,EAAY,OAAOL,KAAA,gBAAAA,EAAS,YAAYA,KAAA,gBAAAA,EAAS,WAAWA,KAAA,gBAAAA,EAAS,MAAMC,CAAO,CAAC,GAE3FH,IAAe,EAAE,OAAAI,GAAO,QAAQ,CAAC,EAACA,KAAA,QAAAA,EAAO,gBAAe,IACrD;AAAA,IACL,KAAKG;AAAA,IACL,OAAAH;AAAA,IACA,QAAQ,CAAC,EAACA,KAAA,QAAAA,EAAO;AAAA,EACnB;AACF;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useState as i, useRef as x, useEffect as P } from "react";
|
|
2
|
+
const q = (S = {}) => {
|
|
3
|
+
const r = typeof window < "u" && "speechSynthesis" in window, { text: c = "", lang: a = "en-US", pitch: p = 1, rate: l = 1, voice: w = null, volume: f = 1 } = S, [d, s] = i(!1), [y, u] = i("init"), [m, g] = i(), t = x(null), h = (e) => {
|
|
4
|
+
e.lang = a, e.pitch = p, e.rate = l, e.volume = f, e.voice = w, e.onstart = () => {
|
|
5
|
+
s(!0), u("play");
|
|
6
|
+
}, e.onpause = () => {
|
|
7
|
+
s(!1), u("pause");
|
|
8
|
+
}, e.onresume = () => {
|
|
9
|
+
s(!0), u("play");
|
|
10
|
+
}, e.onend = () => {
|
|
11
|
+
s(!1), u("end");
|
|
12
|
+
}, e.onerror = (n) => {
|
|
13
|
+
s(!1), g(n);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
P(() => {
|
|
17
|
+
if (!r) return;
|
|
18
|
+
const e = new SpeechSynthesisUtterance(c);
|
|
19
|
+
return h(e), t.current = e, () => {
|
|
20
|
+
var n;
|
|
21
|
+
(n = window.speechSynthesis) == null || n.cancel();
|
|
22
|
+
};
|
|
23
|
+
}, [c, a, p, l, w, f]);
|
|
24
|
+
const v = (e) => {
|
|
25
|
+
var n, o;
|
|
26
|
+
r && (e && (t.current = new SpeechSynthesisUtterance(e), h(t.current)), (n = window.speechSynthesis) == null || n.cancel(), t.current && ((o = window.speechSynthesis) == null || o.speak(t.current)));
|
|
27
|
+
}, k = () => {
|
|
28
|
+
var e;
|
|
29
|
+
r && ((e = window.speechSynthesis) == null || e.cancel(), s(!1));
|
|
30
|
+
}, E = (e = !d) => {
|
|
31
|
+
var n, o;
|
|
32
|
+
r && (e ? (n = window.speechSynthesis) == null || n.resume() : (o = window.speechSynthesis) == null || o.pause(), s(e));
|
|
33
|
+
}, R = () => {
|
|
34
|
+
var e;
|
|
35
|
+
s(!0), (e = window.speechSynthesis) == null || e.resume();
|
|
36
|
+
}, b = () => {
|
|
37
|
+
var e;
|
|
38
|
+
s(!1), (e = window.speechSynthesis) == null || e.pause();
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
supported: r,
|
|
42
|
+
playing: d,
|
|
43
|
+
status: y,
|
|
44
|
+
utterance: t.current,
|
|
45
|
+
error: m,
|
|
46
|
+
stop: k,
|
|
47
|
+
toggle: E,
|
|
48
|
+
speak: v,
|
|
49
|
+
resume: R,
|
|
50
|
+
pause: b
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
q as useSpeechSynthesis
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=useSpeechSynthesis.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpeechSynthesis.mjs","sources":["../../../../src/hooks/useSpeechSynthesis/useSpeechSynthesis.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\n/** The use speech synthesis status type */\nexport type UseSpeechSynthesisStatus = 'end' | 'init' | 'pause' | 'play';\n\n/** The use speech synthesis options type */\nexport interface UseSpeechSynthesisOptions {\n /** Language for SpeechSynthesis */\n lang?: string;\n /** Gets and sets the pitch at which the utterance will be spoken at. */\n pitch?: number;\n /** Gets and sets the speed at which the utterance will be spoken at. */\n rate?: number;\n /** The text to be spoken */\n text?: string;\n /** Gets and sets the voice that will be used to speak the utterance. */\n voice?: SpeechSynthesisVoice | null;\n /** Gets and sets the volume that the utterance will be spoken at. */\n volume?: number;\n}\n\n/** The use speech synthesis return type */\nexport interface UseSpeechSynthesisReturn {\n /** Any error that occurred during speech synthesis. */\n error: SpeechSynthesisErrorEvent | undefined;\n /** Indicates if speech is currently playing. */\n playing: boolean;\n /** The current status of speech synthesis. */\n status: UseSpeechSynthesisStatus;\n /** Indicates if the SpeechSynthesis API is supported in the current environment. */\n supported: boolean;\n /** The SpeechSynthesisUtterance instance. */\n utterance: SpeechSynthesisUtterance | null;\n /** Function to pause speech synthesis. */\n pause: () => void;\n /** Function to resume speech synthesis. */\n resume: () => void;\n /** Function to start speech synthesis. */\n speak: () => void;\n /** Function to stop speech synthesis. */\n stop: () => void;\n /** Function to toggle between play and pause. */\n toggle: (value?: boolean) => void;\n}\n\n/**\n * @name useSpeechSynthesis\n * @description - Hook that provides speech synthesis functionality\n * @category Sensors\n *\n * @browserapi SpeechSynthesis https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis\n *\n * @params {string} [options.text] - The text to be spoken\n * @params {string} [options.lang] - The language to be spoken\n * @params {number} [options.pitch] - The pitch to be spoken\n * @params {number} [options.rate] - The rate to be spoken\n * @params {SpeechSynthesisVoice} [options.voice] - The voice to be spoken\n * @params {number} [options.volume] - The volume to be spoken\n * @returns {UseSpeechSynthesisReturn} An object containing the speech synthesis state and control methods\n *\n * @example\n * const { supported, playing, status, utterance, error, stop, toggle, speak, resume, pause } = useSpeechSynthesis();\n */\nexport const useSpeechSynthesis = (\n options: UseSpeechSynthesisOptions = {}\n): UseSpeechSynthesisReturn => {\n const supported = typeof window !== 'undefined' && 'speechSynthesis' in window;\n\n const { text = '', lang = 'en-US', pitch = 1, rate = 1, voice = null, volume = 1 } = options;\n\n const [playing, setPlaying] = useState(false);\n const [status, setStatus] = useState<UseSpeechSynthesisStatus>('init');\n const [error, setError] = useState<SpeechSynthesisErrorEvent>();\n const speechSynthesisUtteranceRef = useRef<SpeechSynthesisUtterance | null>(null);\n\n const bindSpeechSynthesisUtterance = (speechSynthesisUtterance: SpeechSynthesisUtterance) => {\n speechSynthesisUtterance.lang = lang;\n speechSynthesisUtterance.pitch = pitch;\n speechSynthesisUtterance.rate = rate;\n speechSynthesisUtterance.volume = volume;\n speechSynthesisUtterance.voice = voice;\n\n speechSynthesisUtterance.onstart = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onpause = () => {\n setPlaying(false);\n setStatus('pause');\n };\n\n speechSynthesisUtterance.onresume = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onend = () => {\n setPlaying(false);\n setStatus('end');\n };\n\n speechSynthesisUtterance.onerror = (event) => {\n setPlaying(false);\n setError(event);\n };\n };\n\n useEffect(() => {\n if (!supported) return;\n\n const speechSynthesisUtterance = new SpeechSynthesisUtterance(text);\n bindSpeechSynthesisUtterance(speechSynthesisUtterance);\n speechSynthesisUtteranceRef.current = speechSynthesisUtterance;\n\n return () => {\n window.speechSynthesis?.cancel();\n };\n }, [text, lang, pitch, rate, voice, volume]);\n\n const speak = (text?: string) => {\n if (!supported) return;\n\n if (text) {\n speechSynthesisUtteranceRef.current = new SpeechSynthesisUtterance(text);\n bindSpeechSynthesisUtterance(speechSynthesisUtteranceRef.current);\n }\n\n window.speechSynthesis?.cancel();\n if (speechSynthesisUtteranceRef.current)\n window.speechSynthesis?.speak(speechSynthesisUtteranceRef.current);\n };\n\n const stop = () => {\n if (!supported) return;\n\n window.speechSynthesis?.cancel();\n setPlaying(false);\n };\n\n const toggle = (value = !playing) => {\n if (!supported) return;\n\n if (value) {\n window.speechSynthesis?.resume();\n } else {\n window.speechSynthesis?.pause();\n }\n setPlaying(value);\n };\n\n const resume = () => {\n setPlaying(true);\n window.speechSynthesis?.resume();\n };\n\n const pause = () => {\n setPlaying(false);\n window.speechSynthesis?.pause();\n };\n\n return {\n supported,\n playing,\n status,\n utterance: speechSynthesisUtteranceRef.current,\n error,\n\n stop,\n toggle,\n speak,\n resume,\n pause\n };\n};\n"],"names":["useSpeechSynthesis","options","supported","text","lang","pitch","rate","voice","volume","playing","setPlaying","useState","status","setStatus","error","setError","speechSynthesisUtteranceRef","useRef","bindSpeechSynthesisUtterance","speechSynthesisUtterance","event","useEffect","_a","speak","_b","stop","toggle","value","resume","pause"],"mappings":";AA+DO,MAAMA,IAAqB,CAChCC,IAAqC,OACR;AAC7B,QAAMC,IAAY,OAAO,SAAW,OAAe,qBAAqB,QAElE,EAAE,MAAAC,IAAO,IAAI,MAAAC,IAAO,SAAS,OAAAC,IAAQ,GAAG,MAAAC,IAAO,GAAG,OAAAC,IAAQ,MAAM,QAAAC,IAAS,EAAM,IAAAP,GAE/E,CAACQ,GAASC,CAAU,IAAIC,EAAS,EAAK,GACtC,CAACC,GAAQC,CAAS,IAAIF,EAAmC,MAAM,GAC/D,CAACG,GAAOC,CAAQ,IAAIJ,EAAoC,GACxDK,IAA8BC,EAAwC,IAAI,GAE1EC,IAA+B,CAACC,MAAuD;AAC3F,IAAAA,EAAyB,OAAOf,GAChCe,EAAyB,QAAQd,GACjCc,EAAyB,OAAOb,GAChCa,EAAyB,SAASX,GAClCW,EAAyB,QAAQZ,GAEjCY,EAAyB,UAAU,MAAM;AACvC,MAAAT,EAAW,EAAI,GACfG,EAAU,MAAM;AAAA,IAClB,GAEAM,EAAyB,UAAU,MAAM;AACvC,MAAAT,EAAW,EAAK,GAChBG,EAAU,OAAO;AAAA,IACnB,GAEAM,EAAyB,WAAW,MAAM;AACxC,MAAAT,EAAW,EAAI,GACfG,EAAU,MAAM;AAAA,IAClB,GAEAM,EAAyB,QAAQ,MAAM;AACrC,MAAAT,EAAW,EAAK,GAChBG,EAAU,KAAK;AAAA,IACjB,GAEyBM,EAAA,UAAU,CAACC,MAAU;AAC5C,MAAAV,EAAW,EAAK,GAChBK,EAASK,CAAK;AAAA,IAChB;AAAA,EACF;AAEA,EAAAC,EAAU,MAAM;AACd,QAAI,CAACnB,EAAW;AAEV,UAAAiB,IAA2B,IAAI,yBAAyBhB,CAAI;AAClE,WAAAe,EAA6BC,CAAwB,GACrDH,EAA4B,UAAUG,GAE/B,MAAM;;AACX,OAAAG,IAAA,OAAO,oBAAP,QAAAA,EAAwB;AAAA,IAC1B;AAAA,EAAA,GACC,CAACnB,GAAMC,GAAMC,GAAOC,GAAMC,GAAOC,CAAM,CAAC;AAErC,QAAAe,IAAQ,CAACpB,MAAkB;;AAC/B,IAAKD,MAEDC,MAC0Ba,EAAA,UAAU,IAAI,yBAAyBb,CAAI,GACvEe,EAA6BF,EAA4B,OAAO,KAGlEM,IAAA,OAAO,oBAAP,QAAAA,EAAwB,UACpBN,EAA4B,aACvBQ,IAAA,OAAA,oBAAA,QAAAA,EAAiB,MAAMR,EAA4B;AAAA,EAC9D,GAEMS,IAAO,MAAM;;AACjB,IAAKvB,OAELoB,IAAA,OAAO,oBAAP,QAAAA,EAAwB,UACxBZ,EAAW,EAAK;AAAA,EAClB,GAEMgB,IAAS,CAACC,IAAQ,CAAClB,MAAY;;AACnC,IAAKP,MAEDyB,KACFL,IAAA,OAAO,oBAAP,QAAAA,EAAwB,YAExBE,IAAA,OAAO,oBAAP,QAAAA,EAAwB,SAE1Bd,EAAWiB,CAAK;AAAA,EAClB,GAEMC,IAAS,MAAM;;AACnB,IAAAlB,EAAW,EAAI,IACfY,IAAA,OAAO,oBAAP,QAAAA,EAAwB;AAAA,EAC1B,GAEMO,IAAQ,MAAM;;AAClB,IAAAnB,EAAW,EAAK,IAChBY,IAAA,OAAO,oBAAP,QAAAA,EAAwB;AAAA,EAC1B;AAEO,SAAA;AAAA,IACL,WAAApB;AAAA,IACA,SAAAO;AAAA,IACA,QAAAG;AAAA,IACA,WAAWI,EAA4B;AAAA,IACvC,OAAAF;AAAA,IAEA,MAAAW;AAAA,IACA,QAAAC;AAAA,IACA,OAAAH;AAAA,IACA,QAAAK;AAAA,IACA,OAAAC;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState as v, useRef as d, useEffect as f } from "react";
|
|
2
|
+
const m = (e) => {
|
|
3
|
+
const r = typeof navigator < "u" && "wakeLock" in navigator, [u, n] = v(!1), t = d(), l = (e == null ? void 0 : e.immediately) ?? !1, c = (e == null ? void 0 : e.type) ?? "screen", i = async (a) => {
|
|
4
|
+
r && (t.current = await navigator.wakeLock.request(a ?? (e == null ? void 0 : e.type)), t.current.addEventListener("release", () => {
|
|
5
|
+
n(!1), t.current = void 0;
|
|
6
|
+
}), n(!0));
|
|
7
|
+
}, s = async () => {
|
|
8
|
+
!r || !t.current || (await t.current.release(), t.current = void 0, n(!1));
|
|
9
|
+
};
|
|
10
|
+
return f(() => {
|
|
11
|
+
if (!r || !l || document.visibilityState !== "visible" || c !== "screen")
|
|
12
|
+
return;
|
|
13
|
+
const a = async () => {
|
|
14
|
+
await s(), await i(c);
|
|
15
|
+
};
|
|
16
|
+
return document.addEventListener("visibilitychange", a), () => {
|
|
17
|
+
document.removeEventListener("visibilitychange", a);
|
|
18
|
+
};
|
|
19
|
+
}, [c]), { supported: r, active: u, request: i, release: s };
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
m as useWakeLock
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=useWakeLock.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWakeLock.mjs","sources":["../../../../src/hooks/useWakeLock/useWakeLock.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\n/** The use wake lock options type */\nexport interface UseWakeLockOptions {\n /** Determines if the wake lock should be automatically reacquired when the document becomes visible. */\n immediately?: boolean;\n /** A string specifying the screen wake lock type. */\n type?: WakeLockType;\n}\n\n/** The use wake lock return type */\nexport interface UseWakeLockReturn {\n /** Indicates if the wake lock is currently active. */\n active: boolean;\n /** Indicates if the Wake Lock API is supported in the current environment. */\n supported: boolean;\n /** Function to release the wake lock. */\n release: () => Promise<void>;\n /** Function to request the wake lock. */\n request: () => Promise<void>;\n}\n\n/**\n * @name useWakeLock\n * @description - Hook that provides a wake lock functionality\n * @category Browser\n *\n * @browserapi navigator.wakeLock https://developer.mozilla.org/en-US/docs/Web/API/WakeLock\n *\n * @param {immediately} [options] Configuration options for the hook.\n * @returns {UseWakeLockReturn} An object containing the wake lock state and control methods.\n *\n * @example\n * const { supported, active, request, release } = useWakeLock();\n */\nexport const useWakeLock = (options?: UseWakeLockOptions): UseWakeLockReturn => {\n const supported = typeof navigator !== 'undefined' && 'wakeLock' in navigator;\n\n const [active, setActive] = useState(false);\n const sentinel = useRef<WakeLockSentinel>();\n\n const immediately = options?.immediately ?? false;\n const type = options?.type ?? 'screen';\n\n const request = async (type?: WakeLockType) => {\n if (!supported) return;\n\n sentinel.current = await navigator.wakeLock.request(type ?? options?.type);\n sentinel.current.addEventListener('release', () => {\n setActive(false);\n sentinel.current = undefined;\n });\n\n setActive(true);\n };\n\n const release = async () => {\n if (!supported || !sentinel.current) return;\n\n await sentinel.current.release();\n sentinel.current = undefined;\n setActive(false);\n };\n\n useEffect(() => {\n if (!supported || !immediately || document.visibilityState !== 'visible' || type !== 'screen')\n return;\n\n const onVisibilityChange = async () => {\n await release();\n await request(type);\n };\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n return () => {\n document.removeEventListener('visibilitychange', onVisibilityChange);\n };\n }, [type]);\n\n return { supported, active, request, release };\n};\n"],"names":["useWakeLock","options","supported","active","setActive","useState","sentinel","useRef","immediately","type","request","release","useEffect","onVisibilityChange"],"mappings":";AAmCa,MAAAA,IAAc,CAACC,MAAoD;AAC9E,QAAMC,IAAY,OAAO,YAAc,OAAe,cAAc,WAE9D,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpCC,IAAWC,EAAyB,GAEpCC,KAAcP,KAAA,gBAAAA,EAAS,gBAAe,IACtCQ,KAAOR,KAAA,gBAAAA,EAAS,SAAQ,UAExBS,IAAU,OAAOD,MAAwB;AAC7C,IAAKP,MAELI,EAAS,UAAU,MAAM,UAAU,SAAS,QAAQG,MAAQR,KAAA,gBAAAA,EAAS,KAAI,GAChEK,EAAA,QAAQ,iBAAiB,WAAW,MAAM;AACjD,MAAAF,EAAU,EAAK,GACfE,EAAS,UAAU;AAAA,IAAA,CACpB,GAEDF,EAAU,EAAI;AAAA,EAChB,GAEMO,IAAU,YAAY;AAC1B,IAAI,CAACT,KAAa,CAACI,EAAS,YAEtB,MAAAA,EAAS,QAAQ,QAAQ,GAC/BA,EAAS,UAAU,QACnBF,EAAU,EAAK;AAAA,EACjB;AAEA,SAAAQ,EAAU,MAAM;AACd,QAAI,CAACV,KAAa,CAACM,KAAe,SAAS,oBAAoB,aAAaC,MAAS;AACnF;AAEF,UAAMI,IAAqB,YAAY;AACrC,YAAMF,EAAQ,GACd,MAAMD,EAAQD,CAAI;AAAA,IACpB;AAES,oBAAA,iBAAiB,oBAAoBI,CAAkB,GACzD,MAAM;AACF,eAAA,oBAAoB,oBAAoBA,CAAkB;AAAA,IACrE;AAAA,EAAA,GACC,CAACJ,CAAI,CAAC,GAEF,EAAE,WAAAP,GAAW,QAAAC,GAAQ,SAAAO,GAAS,SAAAC,EAAQ;AAC/C;"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { useBrowserLanguage as R } from "./hooks/useBrowserLanguage/useBrowserLa
|
|
|
8
8
|
import { useClickOutside as k } from "./hooks/useClickOutside/useClickOutside.mjs";
|
|
9
9
|
import { useClipboard as A } from "./hooks/useClipboard/useClipboard.mjs";
|
|
10
10
|
import { useConst as D } from "./hooks/useConst/useConst.mjs";
|
|
11
|
-
import { COOKIE_EVENT as b, dispatchCookieEvent as M, getCookie as N, getCookies as L, removeCookie as
|
|
11
|
+
import { COOKIE_EVENT as b, dispatchCookieEvent as M, getCookie as N, getCookies as L, removeCookie as h, removeCookieItem as B, setCookie as K, setCookieItem as F, useCookie as V } from "./hooks/useCookie/useCookie.mjs";
|
|
12
12
|
import { clearCookies as W, getParsedCookies as U, useCookies as G } from "./hooks/useCookies/useCookies.mjs";
|
|
13
13
|
import { useCopy as z } from "./hooks/useCopy/useCopy.mjs";
|
|
14
14
|
import { useCounter as X } from "./hooks/useCounter/useCounter.mjs";
|
|
@@ -32,109 +32,112 @@ import { useEventListener as Ae } from "./hooks/useEventListener/useEventListene
|
|
|
32
32
|
import { useEyeDropper as De } from "./hooks/useEyeDropper/useEyeDropper.mjs";
|
|
33
33
|
import { useFavicon as be } from "./hooks/useFavicon/useFavicon.mjs";
|
|
34
34
|
import { useField as Ne } from "./hooks/useField/useField.mjs";
|
|
35
|
-
import { useFileDialog as
|
|
35
|
+
import { useFileDialog as he } from "./hooks/useFileDialog/useFileDialog.mjs";
|
|
36
36
|
import { useFocus as Ke } from "./hooks/useFocus/useFocus.mjs";
|
|
37
|
-
import { useFps as
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
90
|
-
import {
|
|
91
|
-
import {
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import {
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import {
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
107
|
-
import {
|
|
108
|
-
import {
|
|
109
|
-
import {
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
112
|
-
import {
|
|
113
|
-
import {
|
|
114
|
-
import {
|
|
115
|
-
import {
|
|
116
|
-
import {
|
|
117
|
-
import {
|
|
118
|
-
import {
|
|
119
|
-
import {
|
|
120
|
-
import {
|
|
121
|
-
import {
|
|
122
|
-
import {
|
|
123
|
-
import {
|
|
124
|
-
import {
|
|
125
|
-
import {
|
|
126
|
-
import {
|
|
127
|
-
import {
|
|
128
|
-
import {
|
|
129
|
-
import {
|
|
130
|
-
import {
|
|
131
|
-
import {
|
|
132
|
-
import {
|
|
133
|
-
import {
|
|
134
|
-
import {
|
|
135
|
-
import {
|
|
136
|
-
import {
|
|
137
|
-
import {
|
|
37
|
+
import { useFps as Ve } from "./hooks/useFps/useFps.mjs";
|
|
38
|
+
import { useFul as We } from "./hooks/useFul/useFul.mjs";
|
|
39
|
+
import { useFullscreen as Ge } from "./hooks/useFullscreen/useFullscreen.mjs";
|
|
40
|
+
import { mapGamepadToXbox360Controller as ze, useGamepad as Qe } from "./hooks/useGamepad/useGamepad.mjs";
|
|
41
|
+
import { useGeolocation as je } from "./hooks/useGeolocation/useGeolocation.mjs";
|
|
42
|
+
import { useHash as Je } from "./hooks/useHash/useHash.mjs";
|
|
43
|
+
import { isHotkeyMatch as Ze, useHotkeys as $e } from "./hooks/useHotkeys/useHotkeys.mjs";
|
|
44
|
+
import { useHover as oo } from "./hooks/useHover/useHover.mjs";
|
|
45
|
+
import { useIdle as to } from "./hooks/useIdle/useIdle.mjs";
|
|
46
|
+
import { useImage as mo } from "./hooks/useImage/useImage.mjs";
|
|
47
|
+
import { useInfiniteScroll as po } from "./hooks/useInfiniteScroll/useInfiniteScroll.mjs";
|
|
48
|
+
import { useIntersectionObserver as xo } from "./hooks/useIntersectionObserver/useIntersectionObserver.mjs";
|
|
49
|
+
import { useInterval as ao } from "./hooks/useInterval/useInterval.mjs";
|
|
50
|
+
import { useIsFirstRender as lo } from "./hooks/useIsFirstRender/useIsFirstRender.mjs";
|
|
51
|
+
import { useIsomorphicLayoutEffect as So } from "./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
|
|
52
|
+
import { useKeyboard as go } from "./hooks/useKeyboard/useKeyboard.mjs";
|
|
53
|
+
import { useKeyPress as Co } from "./hooks/useKeyPress/useKeyPress.mjs";
|
|
54
|
+
import { useKeyPressEvent as Io } from "./hooks/useKeyPressEvent/useKeyPressEvent.mjs";
|
|
55
|
+
import { useKeysPressed as Oo } from "./hooks/useKeysPressed/useKeysPressed.mjs";
|
|
56
|
+
import { useLastChanged as yo } from "./hooks/useLastChanged/useLastChanged.mjs";
|
|
57
|
+
import { useLatest as vo } from "./hooks/useLatest/useLatest.mjs";
|
|
58
|
+
import { useLess as _o } from "./hooks/useLess/useLess.mjs";
|
|
59
|
+
import { useList as Mo } from "./hooks/useList/useList.mjs";
|
|
60
|
+
import { useLocalStorage as Lo } from "./hooks/useLocalStorage/useLocalStorage.mjs";
|
|
61
|
+
import { useLockCallback as Bo } from "./hooks/useLockCallback/useLockCallback.mjs";
|
|
62
|
+
import { useLogger as Fo } from "./hooks/useLogger/useLogger.mjs";
|
|
63
|
+
import { useLongPress as wo } from "./hooks/useLongPress/useLongPress.mjs";
|
|
64
|
+
import { useMap as Uo } from "./hooks/useMap/useMap.mjs";
|
|
65
|
+
import { useMeasure as Ho } from "./hooks/useMeasure/useMeasure.mjs";
|
|
66
|
+
import { useMediaQuery as Qo } from "./hooks/useMediaQuery/useMediaQuery.mjs";
|
|
67
|
+
import { useMemory as jo } from "./hooks/useMemory/useMemory.mjs";
|
|
68
|
+
import { useMount as Jo } from "./hooks/useMount/useMount.mjs";
|
|
69
|
+
import { useMouse as Zo } from "./hooks/useMouse/useMouse.mjs";
|
|
70
|
+
import { useMutation as er } from "./hooks/useMutation/useMutation.mjs";
|
|
71
|
+
import { useMutationObserver as rr } from "./hooks/useMutationObserver/useMutationObserver.mjs";
|
|
72
|
+
import { getConnection as sr, useNetwork as mr } from "./hooks/useNetwork/useNetwork.mjs";
|
|
73
|
+
import { useOffsetPagination as pr } from "./hooks/useOffsetPagination/useOffsetPagination.mjs";
|
|
74
|
+
import { useOnce as xr } from "./hooks/useOnce/useOnce.mjs";
|
|
75
|
+
import { useOnline as ar } from "./hooks/useOnline/useOnline.mjs";
|
|
76
|
+
import { getOperatingSystem as lr, useOperatingSystem as cr } from "./hooks/useOperatingSystem/useOperatingSystem.mjs";
|
|
77
|
+
import { useOptimistic as Tr } from "./hooks/useOptimistic/useOptimistic.mjs";
|
|
78
|
+
import { useOrientation as dr } from "./hooks/useOrientation/useOrientation.mjs";
|
|
79
|
+
import { useOtpCredential as Cr } from "./hooks/useOtpCredential/useOtpCredential.mjs";
|
|
80
|
+
import { usePageLeave as Ir } from "./hooks/usePageLeave/usePageLeave.mjs";
|
|
81
|
+
import { Paint as Or, Pointer as kr, usePaint as yr } from "./hooks/usePaint/usePaint.mjs";
|
|
82
|
+
import { useParallax as vr } from "./hooks/useParallax/useParallax.mjs";
|
|
83
|
+
import { usePerformanceObserver as _r } from "./hooks/usePerformanceObserver/usePerformanceObserver.mjs";
|
|
84
|
+
import { usePermission as Mr } from "./hooks/usePermission/usePermission.mjs";
|
|
85
|
+
import { usePointerLock as Lr } from "./hooks/usePointerLock/usePointerLock.mjs";
|
|
86
|
+
import { usePostMessage as Br } from "./hooks/usePostMessage/usePostMessage.mjs";
|
|
87
|
+
import { usePreferredColorScheme as Fr } from "./hooks/usePreferredColorScheme/usePreferredColorScheme.mjs";
|
|
88
|
+
import { usePreferredContrast as wr } from "./hooks/usePreferredContrast/usePreferredContrast.mjs";
|
|
89
|
+
import { usePreferredDark as Ur } from "./hooks/usePreferredDark/usePreferredDark.mjs";
|
|
90
|
+
import { usePreferredLanguages as Hr } from "./hooks/usePreferredLanguages/usePreferredLanguages.mjs";
|
|
91
|
+
import { usePreferredReducedMotion as Qr } from "./hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs";
|
|
92
|
+
import { usePrevious as jr } from "./hooks/usePrevious/usePrevious.mjs";
|
|
93
|
+
import { useQuery as Jr } from "./hooks/useQuery/useQuery.mjs";
|
|
94
|
+
import { useQueue as Zr } from "./hooks/useQueue/useQueue.mjs";
|
|
95
|
+
import { useRaf as et } from "./hooks/useRaf/useRaf.mjs";
|
|
96
|
+
import { useRafValue as rt } from "./hooks/useRafValue/useRafValue.mjs";
|
|
97
|
+
import { useRefState as st } from "./hooks/useRefState/useRefState.mjs";
|
|
98
|
+
import { useRenderCount as ut } from "./hooks/useRenderCount/useRenderCount.mjs";
|
|
99
|
+
import { useRenderInfo as ft } from "./hooks/useRenderInfo/useRenderInfo.mjs";
|
|
100
|
+
import { useRerender as it } from "./hooks/useRerender/useRerender.mjs";
|
|
101
|
+
import { useResizeObserver as nt } from "./hooks/useResizeObserver/useResizeObserver.mjs";
|
|
102
|
+
import { useScreenOrientation as ct } from "./hooks/useScreenOrientation/useScreenOrientation.mjs";
|
|
103
|
+
import { SCRIPT_STATUS_ATTRIBUTE_NAME as Tt, useScript as gt } from "./hooks/useScript/useScript.mjs";
|
|
104
|
+
import { useScroll as Et } from "./hooks/useScroll/useScroll.mjs";
|
|
105
|
+
import { useScrollIntoView as Pt } from "./hooks/useScrollIntoView/useScrollIntoView.mjs";
|
|
106
|
+
import { useScrollTo as Rt } from "./hooks/useScrollTo/useScrollTo.mjs";
|
|
107
|
+
import { useSessionStorage as kt } from "./hooks/useSessionStorage/useSessionStorage.mjs";
|
|
108
|
+
import { useSet as At } from "./hooks/useSet/useSet.mjs";
|
|
109
|
+
import { useShare as Dt } from "./hooks/useShare/useShare.mjs";
|
|
110
|
+
import { getSpeechRecognition as bt, useSpeechRecognition as Mt } from "./hooks/useSpeechRecognition/useSpeechRecognition.mjs";
|
|
111
|
+
import { useSpeechSynthesis as Lt } from "./hooks/useSpeechSynthesis/useSpeechSynthesis.mjs";
|
|
112
|
+
import { useStateHistory as Bt } from "./hooks/useStateHistory/useStateHistory.mjs";
|
|
113
|
+
import { useStep as Ft } from "./hooks/useStep/useStep.mjs";
|
|
114
|
+
import { useSticky as wt } from "./hooks/useSticky/useSticky.mjs";
|
|
115
|
+
import { useStopwatch as Ut } from "./hooks/useStopwatch/useStopwatch.mjs";
|
|
116
|
+
import { STORAGE_EVENT as Ht, dispatchStorageEvent as zt, useStorage as Qt } from "./hooks/useStorage/useStorage.mjs";
|
|
117
|
+
import { useTextDirection as jt } from "./hooks/useTextDirection/useTextDirection.mjs";
|
|
118
|
+
import { getRangesSelection as Jt, useTextSelection as Yt } from "./hooks/useTextSelection/useTextSelection.mjs";
|
|
119
|
+
import { useThrottleCallback as $t } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
|
|
120
|
+
import { useThrottleValue as os } from "./hooks/useThrottleValue/useThrottleValue.mjs";
|
|
121
|
+
import { useTime as ts } from "./hooks/useTime/useTime.mjs";
|
|
122
|
+
import { useTimeout as ms } from "./hooks/useTimeout/useTimeout.mjs";
|
|
123
|
+
import { getTimeFromSeconds as ps, useTimer as fs } from "./hooks/useTimer/useTimer.mjs";
|
|
124
|
+
import { useToggle as is } from "./hooks/useToggle/useToggle.mjs";
|
|
125
|
+
import { useUnmount as ns } from "./hooks/useUnmount/useUnmount.mjs";
|
|
126
|
+
import { useVibrate as cs } from "./hooks/useVibrate/useVibrate.mjs";
|
|
127
|
+
import { useWakeLock as Ts } from "./hooks/useWakeLock/useWakeLock.mjs";
|
|
128
|
+
import { useWebSocket as ds } from "./hooks/useWebSocket/useWebSocket.mjs";
|
|
129
|
+
import { useWindowEvent as Cs } from "./hooks/useWindowEvent/useWindowEvent.mjs";
|
|
130
|
+
import { useWindowFocus as Is } from "./hooks/useWindowFocus/useWindowFocus.mjs";
|
|
131
|
+
import { scrollTo as Os, useWindowScroll as ks } from "./hooks/useWindowScroll/useWindowScroll.mjs";
|
|
132
|
+
import { useWindowSize as As } from "./hooks/useWindowSize/useWindowSize.mjs";
|
|
133
|
+
import { useWizard as Ds } from "./hooks/useWizard/useWizard.mjs";
|
|
134
|
+
import { copy as bs, legacyCopyToClipboard as Ms } from "./utils/helpers/copy.mjs";
|
|
135
|
+
import { debounce as Ls } from "./utils/helpers/debounce.mjs";
|
|
136
|
+
import { getDate as Bs } from "./utils/helpers/getDate.mjs";
|
|
137
|
+
import { getElement as Fs, target as Vs, targetSymbol as ws } from "./utils/helpers/getElement.mjs";
|
|
138
|
+
import { getRetry as Us } from "./utils/helpers/getRetry.mjs";
|
|
139
|
+
import { isTarget as Hs } from "./utils/helpers/isTarget.mjs";
|
|
140
|
+
import { throttle as Qs } from "./utils/helpers/throttle.mjs";
|
|
138
141
|
export {
|
|
139
142
|
n as BREAKPOINTS_ANT_DESIGN,
|
|
140
143
|
l as BREAKPOINTS_BOOTSTRAP_V5,
|
|
@@ -146,38 +149,38 @@ export {
|
|
|
146
149
|
E as BREAKPOINTS_SEMANTIC,
|
|
147
150
|
C as BREAKPOINTS_TAILWIND,
|
|
148
151
|
b as COOKIE_EVENT,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
Or as Paint,
|
|
153
|
+
kr as Pointer,
|
|
154
|
+
Tt as SCRIPT_STATUS_ATTRIBUTE_NAME,
|
|
155
|
+
Ht as STORAGE_EVENT,
|
|
153
156
|
W as clearCookies,
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
bs as copy,
|
|
158
|
+
Ls as debounce,
|
|
156
159
|
M as dispatchCookieEvent,
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
zt as dispatchStorageEvent,
|
|
161
|
+
sr as getConnection,
|
|
159
162
|
N as getCookie,
|
|
160
163
|
L as getCookies,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
Bs as getDate,
|
|
165
|
+
Fs as getElement,
|
|
166
|
+
lr as getOperatingSystem,
|
|
164
167
|
U as getParsedCookies,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
Jt as getRangesSelection,
|
|
169
|
+
Us as getRetry,
|
|
170
|
+
bt as getSpeechRecognition,
|
|
171
|
+
ps as getTimeFromSeconds,
|
|
172
|
+
Ze as isHotkeyMatch,
|
|
173
|
+
Hs as isTarget,
|
|
174
|
+
Ms as legacyCopyToClipboard,
|
|
175
|
+
ze as mapGamepadToXbox360Controller,
|
|
176
|
+
h as removeCookie,
|
|
177
|
+
B as removeCookieItem,
|
|
178
|
+
Os as scrollTo,
|
|
176
179
|
K as setCookie,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
F as setCookieItem,
|
|
181
|
+
Vs as target,
|
|
182
|
+
ws as targetSymbol,
|
|
183
|
+
Qs as throttle,
|
|
181
184
|
r as useActiveElement,
|
|
182
185
|
s as useAsync,
|
|
183
186
|
u as useBattery,
|
|
@@ -188,7 +191,7 @@ export {
|
|
|
188
191
|
k as useClickOutside,
|
|
189
192
|
A as useClipboard,
|
|
190
193
|
D as useConst,
|
|
191
|
-
|
|
194
|
+
V as useCookie,
|
|
192
195
|
G as useCookies,
|
|
193
196
|
z as useCopy,
|
|
194
197
|
X as useCounter,
|
|
@@ -212,101 +215,104 @@ export {
|
|
|
212
215
|
De as useEyeDropper,
|
|
213
216
|
be as useFavicon,
|
|
214
217
|
Ne as useField,
|
|
215
|
-
|
|
218
|
+
he as useFileDialog,
|
|
216
219
|
Ke as useFocus,
|
|
217
|
-
|
|
218
|
-
We as
|
|
219
|
-
|
|
220
|
-
Qe as
|
|
221
|
-
je as
|
|
222
|
-
|
|
223
|
-
$e as
|
|
224
|
-
oo as
|
|
225
|
-
to as
|
|
226
|
-
mo as
|
|
227
|
-
po as
|
|
228
|
-
xo as
|
|
229
|
-
ao as
|
|
230
|
-
lo as
|
|
231
|
-
|
|
232
|
-
Co as
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Oo as
|
|
236
|
-
yo as
|
|
237
|
-
vo as
|
|
238
|
-
_o as
|
|
239
|
-
Mo as
|
|
240
|
-
Lo as
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
wo as
|
|
244
|
-
Uo as
|
|
245
|
-
Ho as
|
|
246
|
-
Qo as
|
|
247
|
-
jo as
|
|
248
|
-
Jo as
|
|
249
|
-
Zo as
|
|
250
|
-
er as
|
|
251
|
-
|
|
252
|
-
mr as
|
|
253
|
-
pr as
|
|
254
|
-
xr as
|
|
255
|
-
|
|
256
|
-
cr as
|
|
257
|
-
Tr as
|
|
258
|
-
dr as
|
|
259
|
-
Cr as
|
|
260
|
-
|
|
261
|
-
yr as
|
|
262
|
-
vr as
|
|
263
|
-
_r as
|
|
264
|
-
Mr as
|
|
265
|
-
Lr as
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
wr as
|
|
269
|
-
Ur as
|
|
270
|
-
Hr as
|
|
271
|
-
Qr as
|
|
272
|
-
jr as
|
|
273
|
-
Jr as
|
|
274
|
-
Zr as
|
|
275
|
-
et as
|
|
276
|
-
rt as
|
|
277
|
-
st as
|
|
278
|
-
ut as
|
|
279
|
-
ft as
|
|
280
|
-
it as
|
|
281
|
-
nt as
|
|
282
|
-
|
|
283
|
-
gt as
|
|
284
|
-
Et as
|
|
285
|
-
Pt as
|
|
286
|
-
Rt as
|
|
287
|
-
kt as
|
|
288
|
-
At as
|
|
289
|
-
|
|
290
|
-
Mt as
|
|
291
|
-
Lt as
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
Yt as
|
|
299
|
-
$t as
|
|
300
|
-
os as
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
fs as
|
|
304
|
-
is as
|
|
305
|
-
ns as
|
|
306
|
-
cs as
|
|
307
|
-
Ts as
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
220
|
+
Ve as useFps,
|
|
221
|
+
We as useFul,
|
|
222
|
+
Ge as useFullscreen,
|
|
223
|
+
Qe as useGamepad,
|
|
224
|
+
je as useGeolocation,
|
|
225
|
+
Je as useHash,
|
|
226
|
+
$e as useHotkeys,
|
|
227
|
+
oo as useHover,
|
|
228
|
+
to as useIdle,
|
|
229
|
+
mo as useImage,
|
|
230
|
+
po as useInfiniteScroll,
|
|
231
|
+
xo as useIntersectionObserver,
|
|
232
|
+
ao as useInterval,
|
|
233
|
+
lo as useIsFirstRender,
|
|
234
|
+
So as useIsomorphicLayoutEffect,
|
|
235
|
+
Co as useKeyPress,
|
|
236
|
+
Io as useKeyPressEvent,
|
|
237
|
+
go as useKeyboard,
|
|
238
|
+
Oo as useKeysPressed,
|
|
239
|
+
yo as useLastChanged,
|
|
240
|
+
vo as useLatest,
|
|
241
|
+
_o as useLess,
|
|
242
|
+
Mo as useList,
|
|
243
|
+
Lo as useLocalStorage,
|
|
244
|
+
Bo as useLockCallback,
|
|
245
|
+
Fo as useLogger,
|
|
246
|
+
wo as useLongPress,
|
|
247
|
+
Uo as useMap,
|
|
248
|
+
Ho as useMeasure,
|
|
249
|
+
Qo as useMediaQuery,
|
|
250
|
+
jo as useMemory,
|
|
251
|
+
Jo as useMount,
|
|
252
|
+
Zo as useMouse,
|
|
253
|
+
er as useMutation,
|
|
254
|
+
rr as useMutationObserver,
|
|
255
|
+
mr as useNetwork,
|
|
256
|
+
pr as useOffsetPagination,
|
|
257
|
+
xr as useOnce,
|
|
258
|
+
ar as useOnline,
|
|
259
|
+
cr as useOperatingSystem,
|
|
260
|
+
Tr as useOptimistic,
|
|
261
|
+
dr as useOrientation,
|
|
262
|
+
Cr as useOtpCredential,
|
|
263
|
+
Ir as usePageLeave,
|
|
264
|
+
yr as usePaint,
|
|
265
|
+
vr as useParallax,
|
|
266
|
+
_r as usePerformanceObserver,
|
|
267
|
+
Mr as usePermission,
|
|
268
|
+
Lr as usePointerLock,
|
|
269
|
+
Br as usePostMessage,
|
|
270
|
+
Fr as usePreferredColorScheme,
|
|
271
|
+
wr as usePreferredContrast,
|
|
272
|
+
Ur as usePreferredDark,
|
|
273
|
+
Hr as usePreferredLanguages,
|
|
274
|
+
Qr as usePreferredReducedMotion,
|
|
275
|
+
jr as usePrevious,
|
|
276
|
+
Jr as useQuery,
|
|
277
|
+
Zr as useQueue,
|
|
278
|
+
et as useRaf,
|
|
279
|
+
rt as useRafValue,
|
|
280
|
+
st as useRefState,
|
|
281
|
+
ut as useRenderCount,
|
|
282
|
+
ft as useRenderInfo,
|
|
283
|
+
it as useRerender,
|
|
284
|
+
nt as useResizeObserver,
|
|
285
|
+
ct as useScreenOrientation,
|
|
286
|
+
gt as useScript,
|
|
287
|
+
Et as useScroll,
|
|
288
|
+
Pt as useScrollIntoView,
|
|
289
|
+
Rt as useScrollTo,
|
|
290
|
+
kt as useSessionStorage,
|
|
291
|
+
At as useSet,
|
|
292
|
+
Dt as useShare,
|
|
293
|
+
Mt as useSpeechRecognition,
|
|
294
|
+
Lt as useSpeechSynthesis,
|
|
295
|
+
Bt as useStateHistory,
|
|
296
|
+
Ft as useStep,
|
|
297
|
+
wt as useSticky,
|
|
298
|
+
Ut as useStopwatch,
|
|
299
|
+
Qt as useStorage,
|
|
300
|
+
jt as useTextDirection,
|
|
301
|
+
Yt as useTextSelection,
|
|
302
|
+
$t as useThrottleCallback,
|
|
303
|
+
os as useThrottleValue,
|
|
304
|
+
ts as useTime,
|
|
305
|
+
ms as useTimeout,
|
|
306
|
+
fs as useTimer,
|
|
307
|
+
is as useToggle,
|
|
308
|
+
ns as useUnmount,
|
|
309
|
+
cs as useVibrate,
|
|
310
|
+
Ts as useWakeLock,
|
|
311
|
+
ds as useWebSocket,
|
|
312
|
+
Cs as useWindowEvent,
|
|
313
|
+
Is as useWindowFocus,
|
|
314
|
+
ks as useWindowScroll,
|
|
315
|
+
As as useWindowSize,
|
|
316
|
+
Ds as useWizard
|
|
311
317
|
};
|
|
312
318
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -35,6 +35,7 @@ export * from './useField/useField';
|
|
|
35
35
|
export * from './useFileDialog/useFileDialog';
|
|
36
36
|
export * from './useFocus/useFocus';
|
|
37
37
|
export * from './useFps/useFps';
|
|
38
|
+
export * from './useFul/useFul';
|
|
38
39
|
export * from './useFullscreen/useFullscreen';
|
|
39
40
|
export * from './useGamepad/useGamepad';
|
|
40
41
|
export * from './useGeolocation/useGeolocation';
|
|
@@ -107,6 +108,7 @@ export * from './useSessionStorage/useSessionStorage';
|
|
|
107
108
|
export * from './useSet/useSet';
|
|
108
109
|
export * from './useShare/useShare';
|
|
109
110
|
export * from './useSpeechRecognition/useSpeechRecognition';
|
|
111
|
+
export * from './useSpeechSynthesis/useSpeechSynthesis';
|
|
110
112
|
export * from './useStateHistory/useStateHistory';
|
|
111
113
|
export * from './useStep/useStep';
|
|
112
114
|
export * from './useSticky/useSticky';
|
|
@@ -122,6 +124,7 @@ export * from './useTimer/useTimer';
|
|
|
122
124
|
export * from './useToggle/useToggle';
|
|
123
125
|
export * from './useUnmount/useUnmount';
|
|
124
126
|
export * from './useVibrate/useVibrate';
|
|
127
|
+
export * from './useWakeLock/useWakeLock';
|
|
125
128
|
export * from './useWebSocket/useWebSocket';
|
|
126
129
|
export * from './useWindowEvent/useWindowEvent';
|
|
127
130
|
export * from './useWindowFocus/useWindowFocus';
|
|
@@ -8,6 +8,6 @@ import { DependencyList, EffectCallback } from 'react';
|
|
|
8
8
|
* @param {DependencyList} [deps] The dependencies list for the effect
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* useDidUpdate(() => console.log("effect runs on updates"),
|
|
11
|
+
* useDidUpdate(() => console.log("effect runs on updates"), deps);
|
|
12
12
|
*/
|
|
13
13
|
export declare const useDidUpdate: (effect: EffectCallback, deps?: DependencyList) => void;
|
|
@@ -22,6 +22,8 @@ export interface UseIntersectionObserver {
|
|
|
22
22
|
* @description - Hook that gives you intersection observer state
|
|
23
23
|
* @category Browser
|
|
24
24
|
*
|
|
25
|
+
* @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
|
|
26
|
+
*
|
|
25
27
|
* @overload
|
|
26
28
|
* @param {HookTarget} target The target element to detect intersection
|
|
27
29
|
* @param {boolean} [options.enabled=true] The IntersectionObserver options
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** The use speech synthesis status type */
|
|
2
|
+
export type UseSpeechSynthesisStatus = 'end' | 'init' | 'pause' | 'play';
|
|
3
|
+
/** The use speech synthesis options type */
|
|
4
|
+
export interface UseSpeechSynthesisOptions {
|
|
5
|
+
/** Language for SpeechSynthesis */
|
|
6
|
+
lang?: string;
|
|
7
|
+
/** Gets and sets the pitch at which the utterance will be spoken at. */
|
|
8
|
+
pitch?: number;
|
|
9
|
+
/** Gets and sets the speed at which the utterance will be spoken at. */
|
|
10
|
+
rate?: number;
|
|
11
|
+
/** The text to be spoken */
|
|
12
|
+
text?: string;
|
|
13
|
+
/** Gets and sets the voice that will be used to speak the utterance. */
|
|
14
|
+
voice?: SpeechSynthesisVoice | null;
|
|
15
|
+
/** Gets and sets the volume that the utterance will be spoken at. */
|
|
16
|
+
volume?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The use speech synthesis return type */
|
|
19
|
+
export interface UseSpeechSynthesisReturn {
|
|
20
|
+
/** Any error that occurred during speech synthesis. */
|
|
21
|
+
error: SpeechSynthesisErrorEvent | undefined;
|
|
22
|
+
/** Indicates if speech is currently playing. */
|
|
23
|
+
playing: boolean;
|
|
24
|
+
/** The current status of speech synthesis. */
|
|
25
|
+
status: UseSpeechSynthesisStatus;
|
|
26
|
+
/** Indicates if the SpeechSynthesis API is supported in the current environment. */
|
|
27
|
+
supported: boolean;
|
|
28
|
+
/** The SpeechSynthesisUtterance instance. */
|
|
29
|
+
utterance: SpeechSynthesisUtterance | null;
|
|
30
|
+
/** Function to pause speech synthesis. */
|
|
31
|
+
pause: () => void;
|
|
32
|
+
/** Function to resume speech synthesis. */
|
|
33
|
+
resume: () => void;
|
|
34
|
+
/** Function to start speech synthesis. */
|
|
35
|
+
speak: () => void;
|
|
36
|
+
/** Function to stop speech synthesis. */
|
|
37
|
+
stop: () => void;
|
|
38
|
+
/** Function to toggle between play and pause. */
|
|
39
|
+
toggle: (value?: boolean) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @name useSpeechSynthesis
|
|
43
|
+
* @description - Hook that provides speech synthesis functionality
|
|
44
|
+
* @category Sensors
|
|
45
|
+
*
|
|
46
|
+
* @browserapi SpeechSynthesis https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis
|
|
47
|
+
*
|
|
48
|
+
* @params {string} [options.text] - The text to be spoken
|
|
49
|
+
* @params {string} [options.lang] - The language to be spoken
|
|
50
|
+
* @params {number} [options.pitch] - The pitch to be spoken
|
|
51
|
+
* @params {number} [options.rate] - The rate to be spoken
|
|
52
|
+
* @params {SpeechSynthesisVoice} [options.voice] - The voice to be spoken
|
|
53
|
+
* @params {number} [options.volume] - The volume to be spoken
|
|
54
|
+
* @returns {UseSpeechSynthesisReturn} An object containing the speech synthesis state and control methods
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const { supported, playing, status, utterance, error, stop, toggle, speak, resume, pause } = useSpeechSynthesis();
|
|
58
|
+
*/
|
|
59
|
+
export declare const useSpeechSynthesis: (options?: UseSpeechSynthesisOptions) => UseSpeechSynthesisReturn;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The use wake lock options type */
|
|
2
|
+
export interface UseWakeLockOptions {
|
|
3
|
+
/** Determines if the wake lock should be automatically reacquired when the document becomes visible. */
|
|
4
|
+
immediately?: boolean;
|
|
5
|
+
/** A string specifying the screen wake lock type. */
|
|
6
|
+
type?: WakeLockType;
|
|
7
|
+
}
|
|
8
|
+
/** The use wake lock return type */
|
|
9
|
+
export interface UseWakeLockReturn {
|
|
10
|
+
/** Indicates if the wake lock is currently active. */
|
|
11
|
+
active: boolean;
|
|
12
|
+
/** Indicates if the Wake Lock API is supported in the current environment. */
|
|
13
|
+
supported: boolean;
|
|
14
|
+
/** Function to release the wake lock. */
|
|
15
|
+
release: () => Promise<void>;
|
|
16
|
+
/** Function to request the wake lock. */
|
|
17
|
+
request: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @name useWakeLock
|
|
21
|
+
* @description - Hook that provides a wake lock functionality
|
|
22
|
+
* @category Browser
|
|
23
|
+
*
|
|
24
|
+
* @browserapi navigator.wakeLock https://developer.mozilla.org/en-US/docs/Web/API/WakeLock
|
|
25
|
+
*
|
|
26
|
+
* @param {immediately} [options] Configuration options for the hook.
|
|
27
|
+
* @returns {UseWakeLockReturn} An object containing the wake lock state and control methods.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const { supported, active, request, release } = useWakeLock();
|
|
31
|
+
*/
|
|
32
|
+
export declare const useWakeLock: (options?: UseWakeLockOptions) => UseWakeLockReturn;
|