yummies 5.4.6 → 5.4.7
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/async.d.ts +28 -0
- package/async.d.ts.map +1 -0
- package/async.js +62 -0
- package/{src/common.ts → common.d.ts} +3 -14
- package/common.d.ts.map +1 -0
- package/common.js +14 -0
- package/complex/counter.d.ts +15 -0
- package/complex/counter.d.ts.map +1 -0
- package/complex/counter.js +17 -0
- package/complex/global-config.d.ts +11 -0
- package/complex/global-config.d.ts.map +1 -0
- package/complex/global-config.js +41 -0
- package/complex/index.d.ts +4 -0
- package/complex/index.d.ts.map +1 -0
- package/complex/modules-factory.d.ts +49 -0
- package/complex/modules-factory.d.ts.map +1 -0
- package/complex/modules-factory.js +46 -0
- package/cookie.d.ts +3 -0
- package/cookie.d.ts.map +1 -0
- package/cookie.js +9 -0
- package/css.d.ts +36 -0
- package/css.d.ts.map +1 -0
- package/css.js +20 -0
- package/data.d.ts +4 -0
- package/data.d.ts.map +1 -0
- package/data.js +52 -0
- package/date-time.d.ts +28 -0
- package/date-time.d.ts.map +1 -0
- package/date-time.js +160 -0
- package/device.d.ts +8 -0
- package/device.d.ts.map +1 -0
- package/device.js +21 -0
- package/encodings.d.ts +2 -0
- package/encodings.d.ts.map +1 -0
- package/encodings.js +267 -0
- package/errors.d.ts +19 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +30 -0
- package/file.d.ts +3 -0
- package/file.d.ts.map +1 -0
- package/file.js +24 -0
- package/format/_exports.d.ts +5 -0
- package/format/_exports.d.ts.map +1 -0
- package/format/constants.d.ts +4 -0
- package/format/constants.d.ts.map +1 -0
- package/{src/format/constants.ts → format/constants.js} +0 -2
- package/format/index.d.ts +3 -0
- package/format/index.d.ts.map +1 -0
- package/{src/format/index.ts → format/index.js} +0 -1
- package/format/number.d.ts +36 -0
- package/format/number.d.ts.map +1 -0
- package/format/number.js +44 -0
- package/format/percent.d.ts +15 -0
- package/format/percent.d.ts.map +1 -0
- package/format/percent.js +23 -0
- package/format/skip-spaces.d.ts +5 -0
- package/format/skip-spaces.d.ts.map +1 -0
- package/format/skip-spaces.js +4 -0
- package/html.d.ts +44 -0
- package/html.d.ts.map +1 -0
- package/html.js +182 -0
- package/id.d.ts +63 -0
- package/id.d.ts.map +1 -0
- package/{src/id.ts → id.js} +6 -16
- package/imports.d.ts +15 -0
- package/imports.d.ts.map +1 -0
- package/imports.js +40 -0
- package/math.d.ts +13 -0
- package/math.d.ts.map +1 -0
- package/math.js +17 -0
- package/media.d.ts +20 -0
- package/media.d.ts.map +1 -0
- package/media.js +103 -0
- package/mobx/apply-observable.d.ts +4 -0
- package/mobx/apply-observable.d.ts.map +1 -0
- package/mobx/apply-observable.js +12 -0
- package/mobx/create-enhanced-atom.d.ts +11 -0
- package/mobx/create-enhanced-atom.d.ts.map +1 -0
- package/mobx/create-enhanced-atom.js +12 -0
- package/mobx/deep-observable-struct.d.ts +7 -0
- package/mobx/deep-observable-struct.d.ts.map +1 -0
- package/mobx/deep-observable-struct.js +57 -0
- package/mobx/get-mobx-administration.d.ts +6 -0
- package/mobx/get-mobx-administration.d.ts.map +1 -0
- package/mobx/get-mobx-administration.js +2 -0
- package/mobx/index.d.ts +6 -0
- package/mobx/index.d.ts.map +1 -0
- package/mobx/lazy-observe.d.ts +8 -0
- package/mobx/lazy-observe.d.ts.map +1 -0
- package/mobx/lazy-observe.js +43 -0
- package/ms.d.ts +19 -0
- package/ms.d.ts.map +1 -0
- package/ms.js +18 -0
- package/number.d.ts +8 -0
- package/number.d.ts.map +1 -0
- package/number.js +13 -0
- package/package.json +399 -3
- package/parser/_exports.d.ts +4 -0
- package/parser/_exports.d.ts.map +1 -0
- package/parser/index.d.ts +3 -0
- package/parser/index.d.ts.map +1 -0
- package/{src/parser/index.ts → parser/index.js} +0 -1
- package/parser/number.d.ts +21 -0
- package/parser/number.d.ts.map +1 -0
- package/parser/number.js +44 -0
- package/parser/percent.d.ts +4 -0
- package/parser/percent.d.ts.map +1 -0
- package/parser/percent.js +4 -0
- package/parser/string.d.ts +7 -0
- package/parser/string.d.ts.map +1 -0
- package/parser/string.js +14 -0
- package/price.d.ts +6 -0
- package/price.d.ts.map +1 -0
- package/price.js +17 -0
- package/random.d.ts +9 -0
- package/random.d.ts.map +1 -0
- package/random.js +14 -0
- package/react/hooks/index.d.ts +22 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/use-abort-controller.d.ts +2 -0
- package/react/hooks/use-abort-controller.d.ts.map +1 -0
- package/react/hooks/use-abort-controller.js +11 -0
- package/react/hooks/use-abort-signal.d.ts +2 -0
- package/react/hooks/use-abort-signal.d.ts.map +1 -0
- package/{src/react/hooks/use-abort-signal.ts → react/hooks/use-abort-signal.js} +1 -2
- package/react/hooks/use-click-outside.d.ts +9 -0
- package/react/hooks/use-click-outside.d.ts.map +1 -0
- package/react/hooks/use-click-outside.js +13 -0
- package/react/hooks/use-constant.d.ts +9 -0
- package/react/hooks/use-constant.d.ts.map +1 -0
- package/{src/react/hooks/use-constant.ts → react/hooks/use-constant.js} +6 -9
- package/react/hooks/use-define-ref.d.ts +10 -0
- package/react/hooks/use-define-ref.d.ts.map +1 -0
- package/{src/react/hooks/use-define-ref.ts → react/hooks/use-define-ref.js} +7 -10
- package/react/hooks/use-element-ref.d.ts +2 -0
- package/react/hooks/use-element-ref.d.ts.map +1 -0
- package/react/hooks/use-element-ref.js +8 -0
- package/react/hooks/use-event-listener.d.ts +8 -0
- package/react/hooks/use-event-listener.d.ts.map +1 -0
- package/react/hooks/use-event-listener.js +13 -0
- package/react/hooks/use-event.d.ts +3 -0
- package/react/hooks/use-event.d.ts.map +1 -0
- package/react/hooks/use-event.js +19 -0
- package/react/hooks/use-flag.d.ts +8 -0
- package/react/hooks/use-flag.d.ts.map +1 -0
- package/react/hooks/use-flag.js +15 -0
- package/react/hooks/use-force-update.d.ts +2 -0
- package/react/hooks/use-force-update.d.ts.map +1 -0
- package/react/hooks/use-force-update.js +7 -0
- package/react/hooks/use-initial-height.d.ts +5 -0
- package/react/hooks/use-initial-height.d.ts.map +1 -0
- package/react/hooks/use-initial-height.js +11 -0
- package/react/hooks/use-instance.d.ts +27 -0
- package/react/hooks/use-instance.d.ts.map +1 -0
- package/{src/react/hooks/use-instance.ts → react/hooks/use-instance.js} +7 -29
- package/react/hooks/use-intersection-observer.d.ts +2 -0
- package/react/hooks/use-intersection-observer.d.ts.map +1 -0
- package/react/hooks/use-intersection-observer.js +10 -0
- package/react/hooks/use-last-defined-value.d.ts +2 -0
- package/react/hooks/use-last-defined-value.d.ts.map +1 -0
- package/react/hooks/use-last-defined-value.js +8 -0
- package/react/hooks/use-last-value-ref.d.ts +2 -0
- package/react/hooks/use-last-value-ref.d.ts.map +1 -0
- package/react/hooks/use-last-value-ref.js +8 -0
- package/react/hooks/use-life-cycle.d.ts +5 -0
- package/react/hooks/use-life-cycle.d.ts.map +1 -0
- package/react/hooks/use-life-cycle.js +10 -0
- package/react/hooks/use-resize-observer.d.ts +2 -0
- package/react/hooks/use-resize-observer.d.ts.map +1 -0
- package/react/hooks/use-resize-observer.js +11 -0
- package/react/hooks/use-sync-ref.d.ts +2 -0
- package/react/hooks/use-sync-ref.d.ts.map +1 -0
- package/react/hooks/use-sync-ref.js +6 -0
- package/react/hooks/use-toggle.d.ts +2 -0
- package/react/hooks/use-toggle.d.ts.map +1 -0
- package/react/hooks/use-toggle.js +6 -0
- package/react/hooks/use-value.d.ts +5 -0
- package/react/hooks/use-value.d.ts.map +1 -0
- package/react/hooks/use-value.js +8 -0
- package/react/hooks/use-visibility-state.d.ts +2 -0
- package/react/hooks/use-visibility-state.d.ts.map +1 -0
- package/react/hooks/use-visibility-state.js +14 -0
- package/react/index.d.ts +2 -0
- package/react/index.d.ts.map +1 -0
- package/sound.d.ts +7 -0
- package/sound.d.ts.map +1 -0
- package/sound.js +12 -0
- package/storage.d.ts +39 -0
- package/storage.d.ts.map +1 -0
- package/storage.js +43 -0
- package/text.d.ts +15 -0
- package/text.d.ts.map +1 -0
- package/text.js +48 -0
- package/type-guard/_exports.d.ts +86 -0
- package/type-guard/_exports.d.ts.map +1 -0
- package/type-guard/_exports.js +125 -0
- package/type-guard/index.d.ts +3 -0
- package/type-guard/index.d.ts.map +1 -0
- package/{src/type-guard/index.ts → type-guard/index.js} +0 -1
- package/utility-types.d.ts +395 -0
- package/utils/types.d.ts +395 -0
- package/utils/types.d.ts.map +1 -0
- package/utils/types.js +1 -0
- package/vibrate.d.ts +5 -0
- package/vibrate.d.ts.map +1 -0
- package/vibrate.js +8 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.github/FUNDING.yml +0 -1
- package/.github/workflows/main.yml +0 -34
- package/.github/workflows/version-or-publish.yml +0 -45
- package/.nvmrc +0 -1
- package/.vscode/settings.json +0 -19
- package/CHANGELOG.md +0 -215
- package/CONTRIBUTING.md +0 -8
- package/Makefile +0 -7
- package/biome.json +0 -3
- package/commitfmt.toml +0 -18
- package/lefthook.yml +0 -14
- package/scripts/post-build.ts +0 -71
- package/src/async.ts +0 -86
- package/src/complex/counter.test.ts +0 -41
- package/src/complex/counter.ts +0 -40
- package/src/complex/global-config.ts +0 -55
- package/src/complex/modules-factory.ts +0 -65
- package/src/cookie.ts +0 -11
- package/src/css.ts +0 -60
- package/src/data.test.ts +0 -99
- package/src/data.ts +0 -65
- package/src/date-time.test.ts +0 -119
- package/src/date-time.ts +0 -236
- package/src/device.ts +0 -42
- package/src/encodings.ts +0 -270
- package/src/errors.ts +0 -40
- package/src/file.ts +0 -25
- package/src/format/number.test.ts +0 -16
- package/src/format/number.ts +0 -96
- package/src/format/percent.ts +0 -40
- package/src/format/skip-spaces.ts +0 -4
- package/src/html.ts +0 -238
- package/src/imports.ts +0 -52
- package/src/math.ts +0 -20
- package/src/media.ts +0 -134
- package/src/mobx/apply-observable.ts +0 -20
- package/src/mobx/create-enhanced-atom.ts +0 -28
- package/src/mobx/deep-observable-struct.test.ts +0 -69
- package/src/mobx/deep-observable-struct.ts +0 -69
- package/src/mobx/get-mobx-administration.ts +0 -10
- package/src/mobx/lazy-observe.ts +0 -59
- package/src/ms.ts +0 -20
- package/src/number.ts +0 -14
- package/src/parser/number.test.ts +0 -38
- package/src/parser/number.ts +0 -73
- package/src/parser/percent.ts +0 -11
- package/src/parser/string.ts +0 -29
- package/src/price.ts +0 -33
- package/src/random.ts +0 -27
- package/src/react/hooks/use-abort-controller.ts +0 -15
- package/src/react/hooks/use-click-outside.ts +0 -27
- package/src/react/hooks/use-element-ref.ts +0 -11
- package/src/react/hooks/use-event-listener.ts +0 -29
- package/src/react/hooks/use-event.ts +0 -23
- package/src/react/hooks/use-flag.ts +0 -27
- package/src/react/hooks/use-force-update.ts +0 -9
- package/src/react/hooks/use-initial-height.ts +0 -16
- package/src/react/hooks/use-intersection-observer.ts +0 -18
- package/src/react/hooks/use-last-defined-value.ts +0 -9
- package/src/react/hooks/use-last-value-ref.ts +0 -11
- package/src/react/hooks/use-life-cycle.ts +0 -17
- package/src/react/hooks/use-resize-observer.ts +0 -14
- package/src/react/hooks/use-sync-ref.ts +0 -7
- package/src/react/hooks/use-toggle.ts +0 -9
- package/src/react/hooks/use-value.ts +0 -10
- package/src/react/hooks/use-visibility-state.ts +0 -19
- package/src/sound.ts +0 -15
- package/src/storage.ts +0 -137
- package/src/text.test.ts +0 -91
- package/src/text.ts +0 -60
- package/src/type-guard/_exports.ts +0 -154
- package/src/type-guard/index.test.ts +0 -127
- package/src/vibrate.ts +0 -8
- package/tsconfig.json +0 -26
- package/tsconfig.test.json +0 -33
- package/vitest.config.ts +0 -20
- /package/{src/complex/index.ts → complex/index.js} +0 -0
- /package/{src/format/_exports.ts → format/_exports.js} +0 -0
- /package/{src/mobx/index.ts → mobx/index.js} +0 -0
- /package/{src/parser/_exports.ts → parser/_exports.js} +0 -0
- /package/{src/react/hooks/index.ts → react/hooks/index.js} +0 -0
- /package/{src/react/index.ts → react/index.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useConstant } from './use-constant.js';
|
|
3
|
+
export const useAbortController = () => {
|
|
4
|
+
const controller = useConstant(() => new AbortController());
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
return () => {
|
|
7
|
+
controller.abort();
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return controller;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-abort-signal.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-abort-signal.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,mBAE1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
type ClickOutsideInput = {
|
|
3
|
+
contentRef: MutableRefObject<HTMLElement | null>;
|
|
4
|
+
onClick: VoidFunction;
|
|
5
|
+
options?: AddEventListenerOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const useClickOutside: ({ contentRef, onClick, options, }: ClickOutsideInput) => void;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=use-click-outside.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-click-outside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG9C,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjD,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,mCAI7B,iBAAiB,SAanB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEventListener } from './use-event-listener.js';
|
|
2
|
+
export const useClickOutside = ({ contentRef, onClick, options, }) => {
|
|
3
|
+
useEventListener({
|
|
4
|
+
event: 'mousedown',
|
|
5
|
+
handler: (event) => {
|
|
6
|
+
if (contentRef.current &&
|
|
7
|
+
!contentRef.current.contains(event.target)) {
|
|
8
|
+
onClick();
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
options,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook for creating a value exactly once.
|
|
3
|
+
* useMemo doesn't give this guarantee unfortunately -
|
|
4
|
+
* https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
|
|
5
|
+
* https://reactjs.org/docs/hooks-reference.html#usememo
|
|
6
|
+
* @param defineValue Function which returns defined value.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useConstant: <T>(defineValue: () => T) => T;
|
|
9
|
+
//# sourceMappingURL=use-constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-constant.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-constant.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,aAAa,MAAM,CAAC,KAAG,CAQrD,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* React hook for creating a value exactly once.
|
|
5
4
|
* useMemo doesn't give this guarantee unfortunately -
|
|
@@ -7,12 +6,10 @@ import { useRef } from 'react';
|
|
|
7
6
|
* https://reactjs.org/docs/hooks-reference.html#usememo
|
|
8
7
|
* @param defineValue Function which returns defined value.
|
|
9
8
|
*/
|
|
10
|
-
export const useConstant =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return ref.current.value;
|
|
9
|
+
export const useConstant = (defineValue) => {
|
|
10
|
+
const ref = useRef();
|
|
11
|
+
if (!ref.current) {
|
|
12
|
+
ref.current = { value: defineValue() };
|
|
13
|
+
}
|
|
14
|
+
return ref.current.value;
|
|
18
15
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* React hook for creating a value exactly once.
|
|
4
|
+
* useMemo doesn't give this guarantee unfortunately -
|
|
5
|
+
* https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
|
|
6
|
+
* https://reactjs.org/docs/hooks-reference.html#usememo
|
|
7
|
+
* @param defineFn Function which returns defined value.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useDefineRef: <T>(defineFn: () => T) => MutableRefObject<T>;
|
|
10
|
+
//# sourceMappingURL=use-define-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-define-ref.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-define-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAU,MAAM,OAAO,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,UAAU,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAQrE,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { useRef } from 'react';
|
|
3
2
|
/**
|
|
4
3
|
* React hook for creating a value exactly once.
|
|
5
4
|
* useMemo doesn't give this guarantee unfortunately -
|
|
@@ -7,12 +6,10 @@ import { type MutableRefObject, useRef } from 'react';
|
|
|
7
6
|
* https://reactjs.org/docs/hooks-reference.html#usememo
|
|
8
7
|
* @param defineFn Function which returns defined value.
|
|
9
8
|
*/
|
|
10
|
-
export const useDefineRef =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return ref;
|
|
9
|
+
export const useDefineRef = (defineFn) => {
|
|
10
|
+
const ref = useRef(void 0);
|
|
11
|
+
if (!ref.current) {
|
|
12
|
+
ref.current = defineFn();
|
|
13
|
+
}
|
|
14
|
+
return ref;
|
|
18
15
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-element-ref.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-element-ref.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,EAAE,UAAU,MAAM,CAAC,oDAQrE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useEventListener: <EventName extends keyof HTMLElementEventMap>({ event, handler, options, deps, node, }: {
|
|
2
|
+
event: EventName;
|
|
3
|
+
handler: (e: HTMLElementEventMap[EventName]) => void;
|
|
4
|
+
options?: boolean | AddEventListenerOptions;
|
|
5
|
+
deps?: unknown[];
|
|
6
|
+
node?: HTMLElement | Document | Window;
|
|
7
|
+
}) => void;
|
|
8
|
+
//# sourceMappingURL=use-event-listener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-event-listener.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-event-listener.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,MAAM,mBAAmB,EAAE,0CAM3E;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,CAAC,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,CAAC;IAC5C,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC,SAYA,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useSyncRef } from './use-sync-ref.js';
|
|
4
|
+
export const useEventListener = ({ event, handler, options, deps = [], node = document, }) => {
|
|
5
|
+
const handlerRef = useSyncRef(handler);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handleEvent = (e) => handlerRef.current(e);
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
node.addEventListener(event, handleEvent, options);
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
return () => node.removeEventListener(event, handleEvent, options);
|
|
12
|
+
}, deps);
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-event.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-event.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,WAAW,EAAE,SAAS,CAAC,KAAG,CAa5D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Hook to define an event handler with an always-stable function identity.
|
|
3
|
+
*
|
|
4
|
+
* borrowed from @gaeron
|
|
5
|
+
* https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
|
6
|
+
*/
|
|
7
|
+
import { useCallback, useLayoutEffect, useRef } from 'react';
|
|
8
|
+
export const useEvent = (handler) => {
|
|
9
|
+
const handlerRef = useRef(handler);
|
|
10
|
+
// In a real implementation, this would run before layout effects
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
handlerRef.current = handler;
|
|
13
|
+
});
|
|
14
|
+
return useCallback((...args) => {
|
|
15
|
+
// In a real implementation, this would throw if called during render
|
|
16
|
+
const fn = handlerRef.current;
|
|
17
|
+
return fn(...args);
|
|
18
|
+
}, []);
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-flag.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-flag.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,OAAO,GAAI,sBAAoB,KAAG,QAiB9C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
export const useFlag = (defaultValue = false) => {
|
|
3
|
+
const [enabled, setEnabled] = useState(defaultValue);
|
|
4
|
+
const toggle = useCallback(() => setEnabled((value) => !value), []);
|
|
5
|
+
const enable = useCallback(() => setEnabled(true), []);
|
|
6
|
+
const disable = useCallback(() => setEnabled(false), []);
|
|
7
|
+
const flagObjRef = useRef({
|
|
8
|
+
enabled,
|
|
9
|
+
toggle,
|
|
10
|
+
enable,
|
|
11
|
+
disable,
|
|
12
|
+
});
|
|
13
|
+
flagObjRef.current.enabled = enabled;
|
|
14
|
+
return flagObjRef.current;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-force-update.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-force-update.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,kBAM1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-initial-height.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-initial-height.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,WAAW;;;CAarD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export const useInitialHeight = () => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
const [initialHeight, setInitialHeight] = useState(undefined);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (ref.current && !initialHeight) {
|
|
7
|
+
setInitialHeight(ref.current.offsetHeight);
|
|
8
|
+
}
|
|
9
|
+
}, [initialHeight]);
|
|
10
|
+
return { ref, initialHeight };
|
|
11
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type InstanceCreateConfig<TPayload, TExtension = {}> = TExtension & {
|
|
2
|
+
abortSignal: AbortSignal;
|
|
3
|
+
payload: TPayload;
|
|
4
|
+
};
|
|
5
|
+
export declare const createUseInstanceHook: <TExtension = {}>(extension?: TExtension) => <TInstance, TPayload>(factory: (config: InstanceCreateConfig<NoInfer<TPayload>, TExtension>) => TInstance, config?: {
|
|
6
|
+
payload?: TPayload;
|
|
7
|
+
onUpdate?: (payload: TPayload) => void;
|
|
8
|
+
}) => TInstance;
|
|
9
|
+
/**
|
|
10
|
+
* The `useInstance` hook is used to create and manage an instance of an object
|
|
11
|
+
* that requires access to the root store and an abort signal.
|
|
12
|
+
*
|
|
13
|
+
* You can create YOUR OWN CUSTOM `useInstance` hook using `createUseInstanceHook` if you need
|
|
14
|
+
* to provide some specific data
|
|
15
|
+
*
|
|
16
|
+
* @param factory - A factory function that takes a configuration and returns an instance.
|
|
17
|
+
* @param config - An optional configuration containing additional input parameters and an update function.
|
|
18
|
+
* @returns An instance created by the factory function.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useInstance: <TInstance, TPayload>(factory: (config: {
|
|
21
|
+
abortSignal: AbortSignal;
|
|
22
|
+
payload: NoInfer<TPayload>;
|
|
23
|
+
}) => TInstance, config?: {
|
|
24
|
+
payload?: TPayload | undefined;
|
|
25
|
+
onUpdate?: ((payload: TPayload) => void) | undefined;
|
|
26
|
+
} | undefined) => TInstance;
|
|
27
|
+
//# sourceMappingURL=use-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-instance.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-instance.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,IAAI,UAAU,GAAG;IACzE,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAC/B,UAAU,GAAG,EAAE,EAAE,YAAY,UAAU,MACvC,SAAS,EAAE,QAAQ,EAClB,SAAS,CACP,MAAM,EAAE,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,KACxD,SAAS,EACd,SAAS;IACP,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;CACxC,cAiBF,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GArCrB,SAAS,EAAE,QAAQ;iBANP,WAAW;;;;uCAYc,IAAI;2BA+BM,CAAC"}
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
2
|
import { useAbortSignal } from './use-abort-signal.js';
|
|
3
3
|
import { useConstant } from './use-constant.js';
|
|
4
|
-
|
|
5
|
-
export type InstanceCreateConfig<TPayload, TExtension = {}> = TExtension & {
|
|
6
|
-
abortSignal: AbortSignal;
|
|
7
|
-
payload: TPayload;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const createUseInstanceHook =
|
|
11
|
-
<TExtension = {}>(extension?: TExtension) =>
|
|
12
|
-
<TInstance, TPayload>(
|
|
13
|
-
factory: (
|
|
14
|
-
config: InstanceCreateConfig<NoInfer<TPayload>, TExtension>,
|
|
15
|
-
) => TInstance,
|
|
16
|
-
config?: {
|
|
17
|
-
payload?: TPayload;
|
|
18
|
-
onUpdate?: (payload: TPayload) => void;
|
|
19
|
-
},
|
|
20
|
-
) => {
|
|
4
|
+
export const createUseInstanceHook = (extension) => (factory, config) => {
|
|
21
5
|
const abortSignal = useAbortSignal();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
factory({
|
|
25
|
-
...(extension as TExtension),
|
|
6
|
+
const instance = useConstant(() => factory({
|
|
7
|
+
...extension,
|
|
26
8
|
abortSignal,
|
|
27
|
-
payload: config?.payload
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
|
|
9
|
+
payload: config?.payload,
|
|
10
|
+
}));
|
|
31
11
|
useLayoutEffect(() => {
|
|
32
|
-
|
|
12
|
+
config?.onUpdate?.(config.payload);
|
|
33
13
|
}, [config?.payload]);
|
|
34
|
-
|
|
35
14
|
return instance;
|
|
36
|
-
|
|
37
|
-
|
|
15
|
+
};
|
|
38
16
|
/**
|
|
39
17
|
* The `useInstance` hook is used to create and manage an instance of an object
|
|
40
18
|
* that requires access to the root store and an abort signal.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intersection-observer.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-intersection-observer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,GAClC,UAAU,4BAA4B,EACtC,UAAU,wBAAwB,yBAanC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export const useIntersectionObserver = (callback, options) => {
|
|
3
|
+
const [intersectionObserver] = useState(() => new IntersectionObserver(callback, options));
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
return () => {
|
|
6
|
+
intersectionObserver.disconnect();
|
|
7
|
+
};
|
|
8
|
+
}, []);
|
|
9
|
+
return intersectionObserver;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-last-defined-value.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-last-defined-value.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,OAAO,CAAC,MAM9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-last-value-ref.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-last-value-ref.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,2DAQ7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-life-cycle.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-life-cycle.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,GACvB,IAAI,MAAM;IACR,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,SASF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useSyncRef } from './use-sync-ref.js';
|
|
3
|
+
export const useLifeCycle = (fn) => {
|
|
4
|
+
const fnRef = useSyncRef(fn);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const fnOperation = fnRef.current();
|
|
7
|
+
fnOperation.mount?.();
|
|
8
|
+
return fnOperation.unmount?.();
|
|
9
|
+
}, []);
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resize-observer.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-resize-observer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,GAAI,UAAU,sBAAsB,qDAUjE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { useDefineRef } from './use-define-ref.js';
|
|
3
|
+
export const useResizeObserver = (callback) => {
|
|
4
|
+
const resizeObserverRef = useDefineRef(() => new ResizeObserver(callback));
|
|
5
|
+
useLayoutEffect(() => {
|
|
6
|
+
return () => {
|
|
7
|
+
resizeObserverRef.current.disconnect();
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return resizeObserverRef;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sync-ref.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-sync-ref.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,wCAIrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toggle.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-toggle.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,eAAe,OAAO,sGAM/C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
export const useToggle = (initialState) => {
|
|
3
|
+
const [toggled, setToggled] = useState(!!initialState);
|
|
4
|
+
const toggle = useCallback(() => setToggled((toggled) => !toggled), []);
|
|
5
|
+
return [toggled, toggle, setToggled];
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-value.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-value.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;;;CAOlD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-visibility-state.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-visibility-state.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,2CAgB9B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export const useVisibilityState = () => {
|
|
3
|
+
const [state, setState] = useState();
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const handleVisibilityChange = () => {
|
|
6
|
+
setState(document.visibilityState);
|
|
7
|
+
};
|
|
8
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
9
|
+
return () => {
|
|
10
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
return state;
|
|
14
|
+
};
|
package/react/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/sound.d.ts
ADDED
package/sound.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sound.d.ts","sourceRoot":"","sources":["../src/sound.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,EACZ,aAAgB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,kBASzC,CAAC"}
|
package/sound.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Воспроизводит звук из файла
|
|
3
|
+
*/
|
|
4
|
+
export const playSound = async (file, { volume = 1 } = {}) => {
|
|
5
|
+
let audio = new Audio(file);
|
|
6
|
+
audio.volume = volume;
|
|
7
|
+
audio.muted = !volume;
|
|
8
|
+
await audio.play();
|
|
9
|
+
audio.remove();
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
audio = null;
|
|
12
|
+
};
|
package/storage.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type StorageType = 'session' | 'local';
|
|
2
|
+
export declare const createStorageKey: (prefix: string, key: string, namespace?: string) => string;
|
|
3
|
+
export interface SetToStorageConfig<V> extends Omit<GetFromStorageConfig<V>, 'fallback'> {
|
|
4
|
+
value: V;
|
|
5
|
+
}
|
|
6
|
+
export interface GetFromStorageConfig<V> {
|
|
7
|
+
/**
|
|
8
|
+
* Ключ по которому можно получить значение из хранилища (имя ключа не полное, оно дополняется неймпспейсом проекта)
|
|
9
|
+
*/
|
|
10
|
+
key: string;
|
|
11
|
+
/**
|
|
12
|
+
* Тип хранилища
|
|
13
|
+
*/
|
|
14
|
+
type: StorageType;
|
|
15
|
+
/**
|
|
16
|
+
* дефолтное значение, которое будет использоваться если значения нет в хранилище
|
|
17
|
+
*/
|
|
18
|
+
fallback?: V;
|
|
19
|
+
/**
|
|
20
|
+
* Доп. делитель в ключ/utils/types'е
|
|
21
|
+
*/
|
|
22
|
+
namespace?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Доп. делитель
|
|
25
|
+
*/
|
|
26
|
+
prefix?: string;
|
|
27
|
+
}
|
|
28
|
+
export type SetToStorageWrappedConfig<V, BaseConfig extends StorageConfigBase> = Omit<SetToStorageConfig<V>, Extract<keyof SetToStorageConfig<V>, keyof BaseConfig>> & Partial<Pick<SetToStorageConfig<V>, Extract<keyof SetToStorageConfig<V>, keyof BaseConfig>>> & Pick<BaseConfig, Exclude<keyof BaseConfig, keyof SetToStorageConfig<V>>>;
|
|
29
|
+
export type GetFromStorageWrappedConfig<V, BaseConfig extends StorageConfigBase> = Omit<GetFromStorageConfig<V>, Extract<keyof GetFromStorageConfig<V>, keyof BaseConfig>> & Partial<Pick<GetFromStorageConfig<V>, Extract<keyof GetFromStorageConfig<V>, keyof BaseConfig>>> & Pick<BaseConfig, Exclude<keyof BaseConfig, keyof GetFromStorageConfig<V>>>;
|
|
30
|
+
export type StorageConfigBase = Partial<Pick<GetFromStorageConfig<any>, 'prefix' | 'type'>>;
|
|
31
|
+
export interface StorageApi<BaseConfig extends StorageConfigBase> {
|
|
32
|
+
set<Value>(config: SetToStorageWrappedConfig<Value, BaseConfig>): void;
|
|
33
|
+
get<Value>(config: GetFromStorageWrappedConfig<Value, BaseConfig>): Value | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Создает интерфейс для работы с хранилищем (localStorage, sessionStorage)
|
|
37
|
+
*/
|
|
38
|
+
export declare function createStorage<BaseConfig extends StorageConfigBase>(storageConfig: BaseConfig): StorageApi<BaseConfig>;
|
|
39
|
+
//# sourceMappingURL=storage.d.ts.map
|