@mado/hooks 0.3.3 → 0.4.1
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/CHANGELOG.md +13 -0
- package/LICENSE +1 -1
- package/dist/index.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{useDebounce.cjs → use-debounce.cjs} +4 -4
- package/dist/use-debounce.cjs.map +1 -0
- package/dist/{useDebounce.js → use-debounce.js} +4 -4
- package/dist/use-debounce.js.map +1 -0
- package/dist/{useEvent.cjs → use-event.cjs} +4 -4
- package/dist/use-event.cjs.map +1 -0
- package/dist/{useEvent.js → use-event.js} +4 -4
- package/dist/use-event.js.map +1 -0
- package/dist/{useIsMounted.cjs → use-is-mounted.cjs} +3 -3
- package/dist/use-is-mounted.cjs.map +1 -0
- package/dist/{useIsMounted.js → use-is-mounted.js} +3 -3
- package/dist/use-is-mounted.js.map +1 -0
- package/dist/{useIsomorphicLayoutEffect.cjs → use-isomorphic-layout-effect.cjs} +3 -3
- package/dist/use-isomorphic-layout-effect.cjs.map +1 -0
- package/dist/{useIsomorphicLayoutEffect.js → use-isomorphic-layout-effect.js} +3 -3
- package/dist/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/use-media-query.cjs +36 -0
- package/dist/use-media-query.cjs.map +1 -0
- package/dist/use-media-query.d.cts +3 -0
- package/dist/use-media-query.d.ts +3 -0
- package/dist/use-media-query.js +34 -0
- package/dist/use-media-query.js.map +1 -0
- package/dist/{useOnline.cjs → use-online.cjs} +3 -3
- package/dist/use-online.cjs.map +1 -0
- package/dist/{useOnline.js → use-online.js} +3 -3
- package/dist/use-online.js.map +1 -0
- package/dist/{useRerender.cjs → use-rerender.cjs} +3 -3
- package/dist/use-rerender.cjs.map +1 -0
- package/dist/{useRerender.js → use-rerender.js} +3 -3
- package/dist/use-rerender.js.map +1 -0
- package/dist/{useVisibilityState.cjs → use-visibility-state.cjs} +3 -3
- package/dist/use-visibility-state.cjs.map +1 -0
- package/dist/{useVisibilityState.js → use-visibility-state.js} +3 -3
- package/dist/use-visibility-state.js.map +1 -0
- package/package.json +9 -9
- package/src/index.ts +8 -7
- package/src/{useDebounce.ts → use-debounce.ts} +3 -2
- package/src/{useEvent.ts → use-event.ts} +2 -4
- package/src/use-isomorphic-layout-effect.ts +3 -0
- package/src/use-media-query.ts +34 -0
- package/src/{useRerender.ts → use-rerender.ts} +2 -1
- package/dist/useDebounce.cjs.map +0 -1
- package/dist/useDebounce.js.map +0 -1
- package/dist/useEvent.cjs.map +0 -1
- package/dist/useEvent.js.map +0 -1
- package/dist/useIsMounted.cjs.map +0 -1
- package/dist/useIsMounted.js.map +0 -1
- package/dist/useIsomorphicLayoutEffect.cjs.map +0 -1
- package/dist/useIsomorphicLayoutEffect.js.map +0 -1
- package/dist/useOnline.cjs.map +0 -1
- package/dist/useOnline.js.map +0 -1
- package/dist/useRerender.cjs.map +0 -1
- package/dist/useRerender.js.map +0 -1
- package/dist/useVisibilityState.cjs.map +0 -1
- package/dist/useVisibilityState.js.map +0 -1
- package/src/useIsomorphicLayoutEffect.ts +0 -4
- /package/dist/{useDebounce.d.cts → use-debounce.d.cts} +0 -0
- /package/dist/{useDebounce.d.ts → use-debounce.d.ts} +0 -0
- /package/dist/{useEvent.d.cts → use-event.d.cts} +0 -0
- /package/dist/{useEvent.d.ts → use-event.d.ts} +0 -0
- /package/dist/{useIsMounted.d.cts → use-is-mounted.d.cts} +0 -0
- /package/dist/{useIsMounted.d.ts → use-is-mounted.d.ts} +0 -0
- /package/dist/{useIsomorphicLayoutEffect.d.cts → use-isomorphic-layout-effect.d.cts} +0 -0
- /package/dist/{useIsomorphicLayoutEffect.d.ts → use-isomorphic-layout-effect.d.ts} +0 -0
- /package/dist/{useOnline.d.cts → use-online.d.cts} +0 -0
- /package/dist/{useOnline.d.ts → use-online.d.ts} +0 -0
- /package/dist/{useRerender.d.cts → use-rerender.d.cts} +0 -0
- /package/dist/{useRerender.d.ts → use-rerender.d.ts} +0 -0
- /package/dist/{useVisibilityState.d.cts → use-visibility-state.d.cts} +0 -0
- /package/dist/{useVisibilityState.d.ts → use-visibility-state.d.ts} +0 -0
- /package/src/{useIsMounted.ts → use-is-mounted.ts} +0 -0
- /package/src/{useOnline.ts → use-online.ts} +0 -0
- /package/src/{useVisibilityState.ts → use-visibility-state.ts} +0 -0
package/CHANGELOG.md
CHANGED
package/LICENSE
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var useDebounce_cjs = require('./
|
|
4
|
-
var useEvent_cjs = require('./
|
|
5
|
-
var useIsMounted_cjs = require('./
|
|
6
|
-
var useIsomorphicLayoutEffect_cjs = require('./
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
3
|
+
var useDebounce_cjs = require('./use-debounce.cjs');
|
|
4
|
+
var useEvent_cjs = require('./use-event.cjs');
|
|
5
|
+
var useIsMounted_cjs = require('./use-is-mounted.cjs');
|
|
6
|
+
var useIsomorphicLayoutEffect_cjs = require('./use-isomorphic-layout-effect.cjs');
|
|
7
|
+
var useMediaQuery_cjs = require('./use-media-query.cjs');
|
|
8
|
+
var useOnline_cjs = require('./use-online.cjs');
|
|
9
|
+
var useRerender_cjs = require('./use-rerender.cjs');
|
|
10
|
+
var useVisibilityState_cjs = require('./use-visibility-state.cjs');
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
@@ -34,6 +35,12 @@ Object.keys(useIsomorphicLayoutEffect_cjs).forEach(function (k) {
|
|
|
34
35
|
get: function () { return useIsomorphicLayoutEffect_cjs[k]; }
|
|
35
36
|
});
|
|
36
37
|
});
|
|
38
|
+
Object.keys(useMediaQuery_cjs).forEach(function (k) {
|
|
39
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return useMediaQuery_cjs[k]; }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
37
44
|
Object.keys(useOnline_cjs).forEach(function (k) {
|
|
38
45
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
39
46
|
enumerable: true,
|
|
@@ -52,5 +59,5 @@ Object.keys(useVisibilityState_cjs).forEach(function (k) {
|
|
|
52
59
|
get: function () { return useVisibilityState_cjs[k]; }
|
|
53
60
|
});
|
|
54
61
|
});
|
|
55
|
-
//# sourceMappingURL=
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
56
63
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { useDebounce } from './
|
|
2
|
-
export { useEvent } from './
|
|
3
|
-
export { useIsMounted } from './
|
|
4
|
-
export { useIsomorphicLayoutEffect } from './
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
1
|
+
export { useDebounce } from './use-debounce.cjs';
|
|
2
|
+
export { useEvent } from './use-event.cjs';
|
|
3
|
+
export { useIsMounted } from './use-is-mounted.cjs';
|
|
4
|
+
export { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.cjs';
|
|
5
|
+
export { useMediaQuery } from './use-media-query.cjs';
|
|
6
|
+
export { useOnline } from './use-online.cjs';
|
|
7
|
+
export { useRerender } from './use-rerender.cjs';
|
|
8
|
+
export { useVisibilityState } from './use-visibility-state.cjs';
|
|
8
9
|
import '@mado/utils';
|
|
9
10
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { useDebounce } from './
|
|
2
|
-
export { useEvent } from './
|
|
3
|
-
export { useIsMounted } from './
|
|
4
|
-
export { useIsomorphicLayoutEffect } from './
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
1
|
+
export { useDebounce } from './use-debounce.js';
|
|
2
|
+
export { useEvent } from './use-event.js';
|
|
3
|
+
export { useIsMounted } from './use-is-mounted.js';
|
|
4
|
+
export { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.js';
|
|
5
|
+
export { useMediaQuery } from './use-media-query.js';
|
|
6
|
+
export { useOnline } from './use-online.js';
|
|
7
|
+
export { useRerender } from './use-rerender.js';
|
|
8
|
+
export { useVisibilityState } from './use-visibility-state.js';
|
|
8
9
|
import '@mado/utils';
|
|
9
10
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
|
|
1
|
+
export * from './use-debounce.js';
|
|
2
|
+
export * from './use-event.js';
|
|
3
|
+
export * from './use-is-mounted.js';
|
|
4
|
+
export * from './use-isomorphic-layout-effect.js';
|
|
5
|
+
export * from './use-media-query.js';
|
|
6
|
+
export * from './use-online.js';
|
|
7
|
+
export * from './use-rerender.js';
|
|
8
|
+
export * from './use-visibility-state.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require('@mado/utils');
|
|
4
4
|
var react = require('react');
|
|
5
|
-
var useEvent_cjs = require('./
|
|
5
|
+
var useEvent_cjs = require('./use-event.cjs');
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/use-debounce.ts
|
|
8
8
|
function useDebounce(fn, wait) {
|
|
9
9
|
const callback = useEvent_cjs.useEvent(fn);
|
|
10
10
|
const debounced = react.useMemo(() => utils.debounce(callback, wait), [callback, wait]);
|
|
@@ -17,5 +17,5 @@ function useDebounce(fn, wait) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
exports.useDebounce = useDebounce;
|
|
20
|
-
//# sourceMappingURL=
|
|
21
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=use-debounce.cjs.map
|
|
21
|
+
//# sourceMappingURL=use-debounce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-debounce.ts"],"names":["useEvent","useMemo","debounce","useEffect"],"mappings":";;;;;;;AAMO,SAAS,WAAA,CACd,IACA,IAAA,EACkC;AAClC,EAAA,MAAM,QAAA,GAAWA,sBAAS,EAAE,CAAA;AAE5B,EAAA,MAAM,SAAA,GAAYC,aAAA,CAAQ,MAAMC,cAAA,CAAS,QAAA,EAAU,IAAI,CAAA,EAAG,CAAC,QAAA,EAAU,IAAI,CAAC,CAAA;AAE1E,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,CAAU,MAAA,EAAO;AAAA,IACnB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,OAAO,SAAA;AACT","file":"use-debounce.cjs","sourcesContent":["import type { Cancelable } from '@mado/utils';\nimport { debounce } from '@mado/utils';\nimport { useEffect, useMemo } from 'react';\n\nimport { useEvent } from './use-event';\n\nexport function useDebounce<T extends any[], U>(\n fn: (...args: T) => U,\n wait?: number,\n): ((...args: T) => U) & Cancelable {\n const callback = useEvent(fn);\n\n const debounced = useMemo(() => debounce(callback, wait), [callback, wait]);\n\n useEffect(() => {\n return () => {\n debounced.cancel();\n };\n }, [debounced]);\n\n return debounced;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { debounce } from '@mado/utils';
|
|
2
2
|
import { useMemo, useEffect } from 'react';
|
|
3
|
-
import { useEvent } from './
|
|
3
|
+
import { useEvent } from './use-event.js';
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-debounce.ts
|
|
6
6
|
function useDebounce(fn, wait) {
|
|
7
7
|
const callback = useEvent(fn);
|
|
8
8
|
const debounced = useMemo(() => debounce(callback, wait), [callback, wait]);
|
|
@@ -15,5 +15,5 @@ function useDebounce(fn, wait) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { useDebounce };
|
|
18
|
-
//# sourceMappingURL=
|
|
19
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=use-debounce.js.map
|
|
19
|
+
//# sourceMappingURL=use-debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-debounce.ts"],"names":[],"mappings":";;;;;AAMO,SAAS,WAAA,CACd,IACA,IAAA,EACkC;AAClC,EAAA,MAAM,QAAA,GAAW,SAAS,EAAE,CAAA;AAE5B,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,MAAM,QAAA,CAAS,QAAA,EAAU,IAAI,CAAA,EAAG,CAAC,QAAA,EAAU,IAAI,CAAC,CAAA;AAE1E,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,CAAU,MAAA,EAAO;AAAA,IACnB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,OAAO,SAAA;AACT","file":"use-debounce.js","sourcesContent":["import type { Cancelable } from '@mado/utils';\nimport { debounce } from '@mado/utils';\nimport { useEffect, useMemo } from 'react';\n\nimport { useEvent } from './use-event';\n\nexport function useDebounce<T extends any[], U>(\n fn: (...args: T) => U,\n wait?: number,\n): ((...args: T) => U) & Cancelable {\n const callback = useEvent(fn);\n\n const debounced = useMemo(() => debounce(callback, wait), [callback, wait]);\n\n useEffect(() => {\n return () => {\n debounced.cancel();\n };\n }, [debounced]);\n\n return debounced;\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var useIsomorphicLayoutEffect_cjs = require('./
|
|
4
|
+
var useIsomorphicLayoutEffect_cjs = require('./use-isomorphic-layout-effect.cjs');
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/use-event.ts
|
|
7
7
|
function useEvent(fn) {
|
|
8
8
|
const ref = react.useRef(fn);
|
|
9
9
|
useIsomorphicLayoutEffect_cjs.useIsomorphicLayoutEffect(() => {
|
|
@@ -13,5 +13,5 @@ function useEvent(fn) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
exports.useEvent = useEvent;
|
|
16
|
-
//# sourceMappingURL=
|
|
17
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=use-event.cjs.map
|
|
17
|
+
//# sourceMappingURL=use-event.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-event.ts"],"names":["useRef","useIsomorphicLayoutEffect"],"mappings":";;;;;;AAIO,SAAS,SAAiC,EAAA,EAA0C;AACzF,EAAA,MAAM,GAAA,GAAMA,aAAO,EAAE,CAAA;AAErB,EAAAC,uDAAA,CAA0B,MAAM;AAC9B,IAAA,GAAA,CAAI,OAAA,GAAU,EAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,OAAOD,YAAA,CAAO,IAAI,IAAA,KAAA,IAAgB,IAAI,OAAA,EAAS,GAAG,IAAI,CAAC,CAAA,CAAE,OAAA;AAC3D","file":"use-event.cjs","sourcesContent":["import { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\n\nexport function useEvent<T extends unknown[], U>(fn: (...args: T) => U): (...args: T) => U {\n const ref = useRef(fn);\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n\n return useRef((...args: T) => (0, ref.current)(...args)).current;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
import { useIsomorphicLayoutEffect } from './
|
|
2
|
+
import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.js';
|
|
3
3
|
|
|
4
|
-
// src/
|
|
4
|
+
// src/use-event.ts
|
|
5
5
|
function useEvent(fn) {
|
|
6
6
|
const ref = useRef(fn);
|
|
7
7
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -11,5 +11,5 @@ function useEvent(fn) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { useEvent };
|
|
14
|
-
//# sourceMappingURL=
|
|
15
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=use-event.js.map
|
|
15
|
+
//# sourceMappingURL=use-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-event.ts"],"names":[],"mappings":";;;;AAIO,SAAS,SAAiC,EAAA,EAA0C;AACzF,EAAA,MAAM,GAAA,GAAM,OAAO,EAAE,CAAA;AAErB,EAAA,yBAAA,CAA0B,MAAM;AAC9B,IAAA,GAAA,CAAI,OAAA,GAAU,EAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,OAAO,MAAA,CAAO,IAAI,IAAA,KAAA,IAAgB,IAAI,OAAA,EAAS,GAAG,IAAI,CAAC,CAAA,CAAE,OAAA;AAC3D","file":"use-event.js","sourcesContent":["import { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\n\nexport function useEvent<T extends unknown[], U>(fn: (...args: T) => U): (...args: T) => U {\n const ref = useRef(fn);\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n\n return useRef((...args: T) => (0, ref.current)(...args)).current;\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-is-mounted.ts
|
|
6
6
|
function useIsMounted() {
|
|
7
7
|
const [isMounted, setIsMounted] = react.useState(false);
|
|
8
8
|
react.useEffect(() => {
|
|
@@ -12,5 +12,5 @@ function useIsMounted() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
exports.useIsMounted = useIsMounted;
|
|
15
|
-
//# sourceMappingURL=
|
|
16
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=use-is-mounted.cjs.map
|
|
16
|
+
//# sourceMappingURL=use-is-mounted.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-is-mounted.ts"],"names":["useState","useEffect"],"mappings":";;;;;AAEO,SAAS,YAAA,GAAwB;AACtC,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIA,eAAS,KAAK,CAAA;AAEhD,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,YAAA,CAAa,IAAI,CAAA;AAAA,EACnB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,SAAA;AACT","file":"use-is-mounted.cjs","sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useIsMounted(): boolean {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n return isMounted;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/use-is-mounted.ts
|
|
4
4
|
function useIsMounted() {
|
|
5
5
|
const [isMounted, setIsMounted] = useState(false);
|
|
6
6
|
useEffect(() => {
|
|
@@ -10,5 +10,5 @@ function useIsMounted() {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { useIsMounted };
|
|
13
|
-
//# sourceMappingURL=
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=use-is-mounted.js.map
|
|
14
|
+
//# sourceMappingURL=use-is-mounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-is-mounted.ts"],"names":[],"mappings":";;;AAEO,SAAS,YAAA,GAAwB;AACtC,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAEhD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,YAAA,CAAa,IAAI,CAAA;AAAA,EACnB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,SAAA;AACT","file":"use-is-mounted.js","sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useIsMounted(): boolean {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n return isMounted;\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-isomorphic-layout-effect.ts
|
|
6
6
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
7
7
|
|
|
8
8
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
9
|
-
//# sourceMappingURL=
|
|
10
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=use-isomorphic-layout-effect.cjs.map
|
|
10
|
+
//# sourceMappingURL=use-isomorphic-layout-effect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-isomorphic-layout-effect.ts"],"names":["useEffect","useLayoutEffect"],"mappings":";;;;;AAEO,IAAM,yBAAA,GAA4B,OAAO,MAAA,KAAW,WAAA,GAAcA,eAAA,GAAYC","file":"use-isomorphic-layout-effect.cjs","sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nexport const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/use-isomorphic-layout-effect.ts
|
|
4
4
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5
5
|
|
|
6
6
|
export { useIsomorphicLayoutEffect };
|
|
7
|
-
//# sourceMappingURL=
|
|
8
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=use-isomorphic-layout-effect.js.map
|
|
8
|
+
//# sourceMappingURL=use-isomorphic-layout-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-isomorphic-layout-effect.ts"],"names":[],"mappings":";;;AAEO,IAAM,yBAAA,GAA4B,OAAO,MAAA,KAAW,WAAA,GAAc,SAAA,GAAY","file":"use-isomorphic-layout-effect.js","sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nexport const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var shim = require('use-sync-external-store/shim');
|
|
5
|
+
|
|
6
|
+
// src/use-media-query.ts
|
|
7
|
+
function useMediaQuery(query, defaultMatches = false) {
|
|
8
|
+
const [subscribe, getSnapshot, getServerSnapshot] = react.useMemo(() => {
|
|
9
|
+
const matchMedia = typeof window !== "undefined" && window.matchMedia;
|
|
10
|
+
const getDefaultSnapshot = () => {
|
|
11
|
+
return defaultMatches;
|
|
12
|
+
};
|
|
13
|
+
if (!matchMedia) {
|
|
14
|
+
return [() => () => {
|
|
15
|
+
}, getDefaultSnapshot, getDefaultSnapshot];
|
|
16
|
+
}
|
|
17
|
+
const mediaQueryList = matchMedia(query);
|
|
18
|
+
return [
|
|
19
|
+
(onStoreChange) => {
|
|
20
|
+
mediaQueryList.addListener(onStoreChange);
|
|
21
|
+
return () => {
|
|
22
|
+
mediaQueryList.removeListener(onStoreChange);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
() => {
|
|
26
|
+
return mediaQueryList.matches;
|
|
27
|
+
},
|
|
28
|
+
getDefaultSnapshot
|
|
29
|
+
];
|
|
30
|
+
}, [defaultMatches, query]);
|
|
31
|
+
return shim.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.useMediaQuery = useMediaQuery;
|
|
35
|
+
//# sourceMappingURL=use-media-query.cjs.map
|
|
36
|
+
//# sourceMappingURL=use-media-query.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-media-query.ts"],"names":["useMemo","useSyncExternalStore"],"mappings":";;;;;;AAGO,SAAS,aAAA,CAAc,KAAA,EAAe,cAAA,GAAiB,KAAA,EAAgB;AAC5E,EAAA,MAAM,CAAC,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA,GAAIA,cAAQ,MAAM;AAChE,IAAA,MAAM,UAAA,GAAa,OAAO,MAAA,KAAW,WAAA,IAAe,MAAA,CAAO,UAAA;AAE3D,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,OAAO,cAAA;AAAA,IACT,CAAA;AAEA,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,OAAO,CAAC,MAAM,MAAM;AAAA,MAAC,CAAA,EAAG,oBAAoB,kBAAkB,CAAA;AAAA,IAChE;AAEA,IAAA,MAAM,cAAA,GAAiB,WAAW,KAAK,CAAA;AAEvC,IAAA,OAAO;AAAA,MACL,CAAC,aAAA,KAAgC;AAC/B,QAAA,cAAA,CAAe,YAAY,aAAa,CAAA;AAExC,QAAA,OAAO,MAAM;AACX,UAAA,cAAA,CAAe,eAAe,aAAa,CAAA;AAAA,QAC7C,CAAA;AAAA,MACF,CAAA;AAAA,MACA,MAAM;AACJ,QAAA,OAAO,cAAA,CAAe,OAAA;AAAA,MACxB,CAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,cAAA,EAAgB,KAAK,CAAC,CAAA;AAE1B,EAAA,OAAOC,yBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-media-query.cjs","sourcesContent":["import { useMemo } from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nexport function useMediaQuery(query: string, defaultMatches = false): boolean {\n const [subscribe, getSnapshot, getServerSnapshot] = useMemo(() => {\n const matchMedia = typeof window !== 'undefined' && window.matchMedia;\n\n const getDefaultSnapshot = () => {\n return defaultMatches;\n };\n\n if (!matchMedia) {\n return [() => () => {}, getDefaultSnapshot, getDefaultSnapshot];\n }\n\n const mediaQueryList = matchMedia(query);\n\n return [\n (onStoreChange: VoidFunction) => {\n mediaQueryList.addListener(onStoreChange);\n\n return () => {\n mediaQueryList.removeListener(onStoreChange);\n };\n },\n () => {\n return mediaQueryList.matches;\n },\n getDefaultSnapshot,\n ];\n }, [defaultMatches, query]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
|
+
|
|
4
|
+
// src/use-media-query.ts
|
|
5
|
+
function useMediaQuery(query, defaultMatches = false) {
|
|
6
|
+
const [subscribe, getSnapshot, getServerSnapshot] = useMemo(() => {
|
|
7
|
+
const matchMedia = typeof window !== "undefined" && window.matchMedia;
|
|
8
|
+
const getDefaultSnapshot = () => {
|
|
9
|
+
return defaultMatches;
|
|
10
|
+
};
|
|
11
|
+
if (!matchMedia) {
|
|
12
|
+
return [() => () => {
|
|
13
|
+
}, getDefaultSnapshot, getDefaultSnapshot];
|
|
14
|
+
}
|
|
15
|
+
const mediaQueryList = matchMedia(query);
|
|
16
|
+
return [
|
|
17
|
+
(onStoreChange) => {
|
|
18
|
+
mediaQueryList.addListener(onStoreChange);
|
|
19
|
+
return () => {
|
|
20
|
+
mediaQueryList.removeListener(onStoreChange);
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
() => {
|
|
24
|
+
return mediaQueryList.matches;
|
|
25
|
+
},
|
|
26
|
+
getDefaultSnapshot
|
|
27
|
+
];
|
|
28
|
+
}, [defaultMatches, query]);
|
|
29
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useMediaQuery };
|
|
33
|
+
//# sourceMappingURL=use-media-query.js.map
|
|
34
|
+
//# sourceMappingURL=use-media-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-media-query.ts"],"names":[],"mappings":";;;;AAGO,SAAS,aAAA,CAAc,KAAA,EAAe,cAAA,GAAiB,KAAA,EAAgB;AAC5E,EAAA,MAAM,CAAC,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA,GAAI,QAAQ,MAAM;AAChE,IAAA,MAAM,UAAA,GAAa,OAAO,MAAA,KAAW,WAAA,IAAe,MAAA,CAAO,UAAA;AAE3D,IAAA,MAAM,qBAAqB,MAAM;AAC/B,MAAA,OAAO,cAAA;AAAA,IACT,CAAA;AAEA,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,OAAO,CAAC,MAAM,MAAM;AAAA,MAAC,CAAA,EAAG,oBAAoB,kBAAkB,CAAA;AAAA,IAChE;AAEA,IAAA,MAAM,cAAA,GAAiB,WAAW,KAAK,CAAA;AAEvC,IAAA,OAAO;AAAA,MACL,CAAC,aAAA,KAAgC;AAC/B,QAAA,cAAA,CAAe,YAAY,aAAa,CAAA;AAExC,QAAA,OAAO,MAAM;AACX,UAAA,cAAA,CAAe,eAAe,aAAa,CAAA;AAAA,QAC7C,CAAA;AAAA,MACF,CAAA;AAAA,MACA,MAAM;AACJ,QAAA,OAAO,cAAA,CAAe,OAAA;AAAA,MACxB,CAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,cAAA,EAAgB,KAAK,CAAC,CAAA;AAE1B,EAAA,OAAO,oBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-media-query.js","sourcesContent":["import { useMemo } from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nexport function useMediaQuery(query: string, defaultMatches = false): boolean {\n const [subscribe, getSnapshot, getServerSnapshot] = useMemo(() => {\n const matchMedia = typeof window !== 'undefined' && window.matchMedia;\n\n const getDefaultSnapshot = () => {\n return defaultMatches;\n };\n\n if (!matchMedia) {\n return [() => () => {}, getDefaultSnapshot, getDefaultSnapshot];\n }\n\n const mediaQueryList = matchMedia(query);\n\n return [\n (onStoreChange: VoidFunction) => {\n mediaQueryList.addListener(onStoreChange);\n\n return () => {\n mediaQueryList.removeListener(onStoreChange);\n };\n },\n () => {\n return mediaQueryList.matches;\n },\n getDefaultSnapshot,\n ];\n }, [defaultMatches, query]);\n\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var shim = require('use-sync-external-store/shim');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-online.ts
|
|
6
6
|
function subscribe(onStoreChange) {
|
|
7
7
|
window.addEventListener("online", onStoreChange, {
|
|
8
8
|
passive: true
|
|
@@ -27,5 +27,5 @@ function useOnline() {
|
|
|
27
27
|
/* istanbul ignore next -- @preserve */
|
|
28
28
|
|
|
29
29
|
exports.useOnline = useOnline;
|
|
30
|
-
//# sourceMappingURL=
|
|
31
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=use-online.cjs.map
|
|
31
|
+
//# sourceMappingURL=use-online.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-online.ts"],"names":["useSyncExternalStore"],"mappings":";;;;;AAEA,SAAS,UAAU,aAAA,EAA2C;AAC5D,EAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,aAAA,EAAe;AAAA,IAC/C,OAAA,EAAS;AAAA,GACV,CAAA;AACD,EAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,aAAA,EAAe;AAAA,IAChD,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,aAAa,CAAA;AAClD,IAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,aAAa,CAAA;AAAA,EACrD,CAAA;AACF;AAEA,SAAS,WAAA,GAAuB;AAC9B,EAAA,OAAO,SAAA,CAAU,MAAA;AACnB;AAGA,SAAS,iBAAA,GAA6B;AACpC,EAAA,OAAO,IAAA;AACT;AAEO,SAAS,SAAA,GAAqB;AACnC,EAAA,OAAOA,yBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-online.cjs","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/use-online.ts
|
|
4
4
|
function subscribe(onStoreChange) {
|
|
5
5
|
window.addEventListener("online", onStoreChange, {
|
|
6
6
|
passive: true
|
|
@@ -25,5 +25,5 @@ function useOnline() {
|
|
|
25
25
|
/* istanbul ignore next -- @preserve */
|
|
26
26
|
|
|
27
27
|
export { useOnline };
|
|
28
|
-
//# sourceMappingURL=
|
|
29
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=use-online.js.map
|
|
29
|
+
//# sourceMappingURL=use-online.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-online.ts"],"names":[],"mappings":";;;AAEA,SAAS,UAAU,aAAA,EAA2C;AAC5D,EAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,aAAA,EAAe;AAAA,IAC/C,OAAA,EAAS;AAAA,GACV,CAAA;AACD,EAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,aAAA,EAAe;AAAA,IAChD,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,aAAa,CAAA;AAClD,IAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,aAAa,CAAA;AAAA,EACrD,CAAA;AACF;AAEA,SAAS,WAAA,GAAuB;AAC9B,EAAA,OAAO,SAAA,CAAU,MAAA;AACnB;AAGA,SAAS,iBAAA,GAA6B;AACpC,EAAA,OAAO,IAAA;AACT;AAEO,SAAS,SAAA,GAAqB;AACnC,EAAA,OAAO,oBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-online.js","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-rerender.ts
|
|
6
6
|
var initialState = {};
|
|
7
7
|
function reducer() {
|
|
8
8
|
return {};
|
|
@@ -12,5 +12,5 @@ function useRerender() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
exports.useRerender = useRerender;
|
|
15
|
-
//# sourceMappingURL=
|
|
16
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=use-rerender.cjs.map
|
|
16
|
+
//# sourceMappingURL=use-rerender.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-rerender.ts"],"names":["useReducer"],"mappings":";;;;;AAGA,IAAM,eAAe,EAAC;AAEtB,SAAS,OAAA,GAAU;AACjB,EAAA,OAAO,EAAC;AACV;AAEO,SAAS,WAAA,GAAqC;AACnD,EAAA,OAAOA,gBAAA,CAAW,OAAA,EAAS,YAAY,CAAA,CAAE,CAAC,CAAA;AAC5C","file":"use-rerender.cjs","sourcesContent":["import type { DispatchWithoutAction } from 'react';\nimport { useReducer } from 'react';\n\nconst initialState = {};\n\nfunction reducer() {\n return {};\n}\n\nexport function useRerender(): DispatchWithoutAction {\n return useReducer(reducer, initialState)[1];\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useReducer } from 'react';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/use-rerender.ts
|
|
4
4
|
var initialState = {};
|
|
5
5
|
function reducer() {
|
|
6
6
|
return {};
|
|
@@ -10,5 +10,5 @@ function useRerender() {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { useRerender };
|
|
13
|
-
//# sourceMappingURL=
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=use-rerender.js.map
|
|
14
|
+
//# sourceMappingURL=use-rerender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-rerender.ts"],"names":[],"mappings":";;;AAGA,IAAM,eAAe,EAAC;AAEtB,SAAS,OAAA,GAAU;AACjB,EAAA,OAAO,EAAC;AACV;AAEO,SAAS,WAAA,GAAqC;AACnD,EAAA,OAAO,UAAA,CAAW,OAAA,EAAS,YAAY,CAAA,CAAE,CAAC,CAAA;AAC5C","file":"use-rerender.js","sourcesContent":["import type { DispatchWithoutAction } from 'react';\nimport { useReducer } from 'react';\n\nconst initialState = {};\n\nfunction reducer() {\n return {};\n}\n\nexport function useRerender(): DispatchWithoutAction {\n return useReducer(reducer, initialState)[1];\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var shim = require('use-sync-external-store/shim');
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/use-visibility-state.ts
|
|
6
6
|
function subscribe(onStoreChange) {
|
|
7
7
|
document.addEventListener("visibilitychange", onStoreChange, {
|
|
8
8
|
passive: true
|
|
@@ -23,5 +23,5 @@ function useVisibilityState() {
|
|
|
23
23
|
/* istanbul ignore next -- @preserve */
|
|
24
24
|
|
|
25
25
|
exports.useVisibilityState = useVisibilityState;
|
|
26
|
-
//# sourceMappingURL=
|
|
27
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=use-visibility-state.cjs.map
|
|
27
|
+
//# sourceMappingURL=use-visibility-state.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-visibility-state.ts"],"names":["useSyncExternalStore"],"mappings":";;;;;AAEA,SAAS,UAAU,aAAA,EAA2C;AAC5D,EAAA,QAAA,CAAS,gBAAA,CAAiB,oBAAoB,aAAA,EAAe;AAAA,IAC3D,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,QAAA,CAAS,mBAAA,CAAoB,oBAAoB,aAAa,CAAA;AAAA,EAChE,CAAA;AACF;AAEA,SAAS,WAAA,GAAuC;AAC9C,EAAA,OAAO,QAAA,CAAS,eAAA;AAClB;AAGA,SAAS,iBAAA,GAA6C;AACpD,EAAA,OAAO,SAAA;AACT;AAEO,SAAS,kBAAA,GAA8C;AAC5D,EAAA,OAAOA,yBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-visibility-state.cjs","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/use-visibility-state.ts
|
|
4
4
|
function subscribe(onStoreChange) {
|
|
5
5
|
document.addEventListener("visibilitychange", onStoreChange, {
|
|
6
6
|
passive: true
|
|
@@ -21,5 +21,5 @@ function useVisibilityState() {
|
|
|
21
21
|
/* istanbul ignore next -- @preserve */
|
|
22
22
|
|
|
23
23
|
export { useVisibilityState };
|
|
24
|
-
//# sourceMappingURL=
|
|
25
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=use-visibility-state.js.map
|
|
25
|
+
//# sourceMappingURL=use-visibility-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-visibility-state.ts"],"names":[],"mappings":";;;AAEA,SAAS,UAAU,aAAA,EAA2C;AAC5D,EAAA,QAAA,CAAS,gBAAA,CAAiB,oBAAoB,aAAA,EAAe;AAAA,IAC3D,OAAA,EAAS;AAAA,GACV,CAAA;AAED,EAAA,OAAO,MAAM;AACX,IAAA,QAAA,CAAS,mBAAA,CAAoB,oBAAoB,aAAa,CAAA;AAAA,EAChE,CAAA;AACF;AAEA,SAAS,WAAA,GAAuC;AAC9C,EAAA,OAAO,QAAA,CAAS,eAAA;AAClB;AAGA,SAAS,iBAAA,GAA6C;AACpD,EAAA,OAAO,SAAA;AACT;AAEO,SAAS,kBAAA,GAA8C;AAC5D,EAAA,OAAO,oBAAA,CAAqB,SAAA,EAAW,WAAA,EAAa,iBAAiB,CAAA;AACvE","file":"use-visibility-state.js","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mado/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"repository": {
|
|
39
39
|
"directory": "packages/mado-hooks",
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/doinki/mado.git"
|
|
41
|
+
"url": "git+https://github.com/doinki/mado.git"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"type": "module",
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"use-sync-external-store": "^1.
|
|
50
|
-
"@mado/utils": "^0.
|
|
49
|
+
"use-sync-external-store": "^1.6.0",
|
|
50
|
+
"@mado/utils": "^0.4.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/use-sync-external-store": "^
|
|
54
|
-
"react": "^
|
|
55
|
-
"react-dom": "^
|
|
53
|
+
"@types/use-sync-external-store": "^1.5.0",
|
|
54
|
+
"react": "^19.2.0",
|
|
55
|
+
"react-dom": "^19.2.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsup",
|
|
59
59
|
"test": "vitest run",
|
|
60
60
|
"test:coverage": "vitest run --coverage",
|
|
61
|
-
"lint": "eslint
|
|
61
|
+
"lint": "eslint",
|
|
62
62
|
"publint": "publint",
|
|
63
|
-
"typecheck": "tsc"
|
|
63
|
+
"typecheck": "tsc --noEmit"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
1
|
+
export * from './use-debounce';
|
|
2
|
+
export * from './use-event';
|
|
3
|
+
export * from './use-is-mounted';
|
|
4
|
+
export * from './use-isomorphic-layout-effect';
|
|
5
|
+
export * from './use-media-query';
|
|
6
|
+
export * from './use-online';
|
|
7
|
+
export * from './use-rerender';
|
|
8
|
+
export * from './use-visibility-state';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Cancelable } from '@mado/utils';
|
|
2
|
+
import { debounce } from '@mado/utils';
|
|
2
3
|
import { useEffect, useMemo } from 'react';
|
|
3
4
|
|
|
4
|
-
import { useEvent } from './
|
|
5
|
+
import { useEvent } from './use-event';
|
|
5
6
|
|
|
6
7
|
export function useDebounce<T extends any[], U>(
|
|
7
8
|
fn: (...args: T) => U,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useIsomorphicLayoutEffect } from './
|
|
3
|
+
import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';
|
|
4
4
|
|
|
5
|
-
export function useEvent<T extends unknown[], U>(
|
|
6
|
-
fn: (...args: T) => U,
|
|
7
|
-
): (...args: T) => U {
|
|
5
|
+
export function useEvent<T extends unknown[], U>(fn: (...args: T) => U): (...args: T) => U {
|
|
8
6
|
const ref = useRef(fn);
|
|
9
7
|
|
|
10
8
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
|
+
|
|
4
|
+
export function useMediaQuery(query: string, defaultMatches = false): boolean {
|
|
5
|
+
const [subscribe, getSnapshot, getServerSnapshot] = useMemo(() => {
|
|
6
|
+
const matchMedia = typeof window !== 'undefined' && window.matchMedia;
|
|
7
|
+
|
|
8
|
+
const getDefaultSnapshot = () => {
|
|
9
|
+
return defaultMatches;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
if (!matchMedia) {
|
|
13
|
+
return [() => () => {}, getDefaultSnapshot, getDefaultSnapshot];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const mediaQueryList = matchMedia(query);
|
|
17
|
+
|
|
18
|
+
return [
|
|
19
|
+
(onStoreChange: VoidFunction) => {
|
|
20
|
+
mediaQueryList.addListener(onStoreChange);
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
mediaQueryList.removeListener(onStoreChange);
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
() => {
|
|
27
|
+
return mediaQueryList.matches;
|
|
28
|
+
},
|
|
29
|
+
getDefaultSnapshot,
|
|
30
|
+
];
|
|
31
|
+
}, [defaultMatches, query]);
|
|
32
|
+
|
|
33
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
34
|
+
}
|
package/dist/useDebounce.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useDebounce.ts"],"names":[],"mappings":";AAAA,SAA0B,gBAAgB;AAC1C,SAAS,WAAW,eAAe;AAEnC,SAAS,gBAAgB;AAElB,SAAS,YACd,IACA,MACkC;AAClC,QAAM,WAAW,SAAS,EAAE;AAE5B,QAAM,YAAY,QAAQ,MAAM,SAAS,UAAU,IAAI,GAAG,CAAC,UAAU,IAAI,CAAC;AAE1E,YAAU,MAAM;AACd,WAAO,MAAM;AACX,gBAAU,OAAO;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO;AACT","sourcesContent":["import { type Cancelable, debounce } from '@mado/utils';\nimport { useEffect, useMemo } from 'react';\n\nimport { useEvent } from './useEvent';\n\nexport function useDebounce<T extends any[], U>(\n fn: (...args: T) => U,\n wait?: number,\n): ((...args: T) => U) & Cancelable {\n const callback = useEvent(fn);\n\n const debounced = useMemo(() => debounce(callback, wait), [callback, wait]);\n\n useEffect(() => {\n return () => {\n debounced.cancel();\n };\n }, [debounced]);\n\n return debounced;\n}\n"]}
|
package/dist/useDebounce.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useDebounce.ts"],"names":[],"mappings":";AAAA,SAA0B,gBAAgB;AAC1C,SAAS,WAAW,eAAe;AAEnC,SAAS,gBAAgB;AAElB,SAAS,YACd,IACA,MACkC;AAClC,QAAM,WAAW,SAAS,EAAE;AAE5B,QAAM,YAAY,QAAQ,MAAM,SAAS,UAAU,IAAI,GAAG,CAAC,UAAU,IAAI,CAAC;AAE1E,YAAU,MAAM;AACd,WAAO,MAAM;AACX,gBAAU,OAAO;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO;AACT","sourcesContent":["import { type Cancelable, debounce } from '@mado/utils';\nimport { useEffect, useMemo } from 'react';\n\nimport { useEvent } from './useEvent';\n\nexport function useDebounce<T extends any[], U>(\n fn: (...args: T) => U,\n wait?: number,\n): ((...args: T) => U) & Cancelable {\n const callback = useEvent(fn);\n\n const debounced = useMemo(() => debounce(callback, wait), [callback, wait]);\n\n useEffect(() => {\n return () => {\n debounced.cancel();\n };\n }, [debounced]);\n\n return debounced;\n}\n"]}
|
package/dist/useEvent.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useEvent.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,iCAAiC;AAEnC,SAAS,SACd,IACmB;AACnB,QAAM,MAAM,OAAO,EAAE;AAErB,4BAA0B,MAAM;AAC9B,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,OAAO,IAAI,UAAa,GAAG,IAAI,SAAS,GAAG,IAAI,CAAC,EAAE;AAC3D","sourcesContent":["import { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\nexport function useEvent<T extends unknown[], U>(\n fn: (...args: T) => U,\n): (...args: T) => U {\n const ref = useRef(fn);\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n\n return useRef((...args: T) => (0, ref.current)(...args)).current;\n}\n"]}
|
package/dist/useEvent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useEvent.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,iCAAiC;AAEnC,SAAS,SACd,IACmB;AACnB,QAAM,MAAM,OAAO,EAAE;AAErB,4BAA0B,MAAM;AAC9B,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,OAAO,IAAI,UAAa,GAAG,IAAI,SAAS,GAAG,IAAI,CAAC,EAAE;AAC3D","sourcesContent":["import { useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n\nexport function useEvent<T extends unknown[], U>(\n fn: (...args: T) => U,\n): (...args: T) => U {\n const ref = useRef(fn);\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n\n return useRef((...args: T) => (0, ref.current)(...args)).current;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useIsMounted.ts"],"names":[],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AAE7B,SAAS,eAAwB;AACtC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT","sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useIsMounted(): boolean {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n return isMounted;\n}\n"]}
|
package/dist/useIsMounted.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useIsMounted.ts"],"names":[],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AAE7B,SAAS,eAAwB;AACtC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT","sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useIsMounted(): boolean {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n return isMounted;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":";AAAA,SAAS,WAAW,uBAAuB;AAEpC,IAAM,4BACX,OAAO,WAAW,cAAc,YAAY","sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nexport const useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":";AAAA,SAAS,WAAW,uBAAuB;AAEpC,IAAM,4BACX,OAAO,WAAW,cAAc,YAAY","sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nexport const useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n"]}
|
package/dist/useOnline.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
package/dist/useOnline.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOnline.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,SAAO,iBAAiB,UAAU,eAAe;AAAA,IAC/C,SAAS;AAAA,EACX,CAAC;AACD,SAAO,iBAAiB,WAAW,eAAe;AAAA,IAChD,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,WAAO,oBAAoB,UAAU,aAAa;AAClD,WAAO,oBAAoB,WAAW,aAAa;AAAA,EACrD;AACF;AAEA,SAAS,cAAuB;AAC9B,SAAO,UAAU;AACnB;AAGA,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,YAAqB;AACnC,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n window.addEventListener('online', onStoreChange, {\n passive: true,\n });\n window.addEventListener('offline', onStoreChange, {\n passive: true,\n });\n\n return () => {\n window.removeEventListener('online', onStoreChange);\n window.removeEventListener('offline', onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return navigator.onLine;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): boolean {\n return true;\n}\n\nexport function useOnline(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
package/dist/useRerender.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useRerender.ts"],"names":[],"mappings":";AAAA,SAAqC,kBAAkB;AAEvD,IAAM,eAAe,CAAC;AAEtB,SAAS,UAAU;AACjB,SAAO,CAAC;AACV;AAEO,SAAS,cAAqC;AACnD,SAAO,WAAW,SAAS,YAAY,EAAE,CAAC;AAC5C","sourcesContent":["import { type DispatchWithoutAction, useReducer } from 'react';\n\nconst initialState = {};\n\nfunction reducer() {\n return {};\n}\n\nexport function useRerender(): DispatchWithoutAction {\n return useReducer(reducer, initialState)[1];\n}\n"]}
|
package/dist/useRerender.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useRerender.ts"],"names":[],"mappings":";AAAA,SAAqC,kBAAkB;AAEvD,IAAM,eAAe,CAAC;AAEtB,SAAS,UAAU;AACjB,SAAO,CAAC;AACV;AAEO,SAAS,cAAqC;AACnD,SAAO,WAAW,SAAS,YAAY,EAAE,CAAC;AAC5C","sourcesContent":["import { type DispatchWithoutAction, useReducer } from 'react';\n\nconst initialState = {};\n\nfunction reducer() {\n return {};\n}\n\nexport function useRerender(): DispatchWithoutAction {\n return useReducer(reducer, initialState)[1];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useVisibilityState.ts"],"names":[],"mappings":";AAAA,SAAS,4BAA4B;AAErC,SAAS,UAAU,eAA2C;AAC5D,WAAS,iBAAiB,oBAAoB,eAAe;AAAA,IAC3D,SAAS;AAAA,EACX,CAAC;AAED,SAAO,MAAM;AACX,aAAS,oBAAoB,oBAAoB,aAAa;AAAA,EAChE;AACF;AAEA,SAAS,cAAuC;AAC9C,SAAO,SAAS;AAClB;AAGA,SAAS,oBAA6C;AACpD,SAAO;AACT;AAEO,SAAS,qBAA8C;AAC5D,SAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE","sourcesContent":["import { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nfunction subscribe(onStoreChange: VoidFunction): VoidFunction {\n document.addEventListener('visibilitychange', onStoreChange, {\n passive: true,\n });\n\n return () => {\n document.removeEventListener('visibilitychange', onStoreChange);\n };\n}\n\nfunction getSnapshot(): DocumentVisibilityState {\n return document.visibilityState;\n}\n\n/* istanbul ignore next -- @preserve */\nfunction getServerSnapshot(): DocumentVisibilityState {\n return 'visible';\n}\n\nexport function useVisibilityState(): DocumentVisibilityState {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|