extra-react-hooks 0.4.3 → 0.5.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/README.md CHANGED
@@ -54,6 +54,22 @@ function useMount(effect: EffectCallback): void
54
54
  function useUnmount(effect: () => void): void
55
55
  ```
56
56
 
57
+ ### useEffectAsync
58
+ ```ts
59
+ function useEffectAsync(
60
+ effect: (signal: AbortSignal) => Promise<void>
61
+ , deps?: DependencyList
62
+ ): void
63
+ ```
64
+
65
+ ### useCallbackAsync
66
+ ```ts
67
+ function useCallbackAsync<Args extends unknown[]>(
68
+ callback: (...args: [...args: Args, signal: AbortSignal]) => Promise<void>
69
+ , deps: DependencyList
70
+ ): (...args: Args) => void
71
+ ```
72
+
57
73
  ### useUpdateEffect
58
74
  ```ts
59
75
  function useUpdateEffect(
package/lib/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export * from './use-is-first-render.js';
4
4
  export * from './use-render-counter.js';
5
5
  export * from './use-mount.js';
6
6
  export * from './use-unmount.js';
7
+ export * from './use-effect-async.js';
8
+ export * from './use-callback-async.js';
7
9
  export * from './use-update-effect.js';
8
10
  export * from './use-single-selection.js';
9
11
  export * from './use-multiple-selection.js';
package/lib/index.js CHANGED
@@ -4,6 +4,8 @@ export * from './use-is-first-render.js';
4
4
  export * from './use-render-counter.js';
5
5
  export * from './use-mount.js';
6
6
  export * from './use-unmount.js';
7
+ export * from './use-effect-async.js';
8
+ export * from './use-callback-async.js';
7
9
  export * from './use-update-effect.js';
8
10
  export * from './use-single-selection.js';
9
11
  export * from './use-multiple-selection.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { DependencyList } from 'react';
2
+ export declare function useCallbackAsync<Args extends unknown[]>(callback: (...args: [...args: Args, signal: AbortSignal]) => Promise<void>, deps: DependencyList): (...args: Args) => void;
@@ -0,0 +1,20 @@
1
+ import { useEffect, useCallback, useMemo } from 'react';
2
+ import { go } from '@blackglory/prelude';
3
+ import { AbortController } from 'extra-abort';
4
+ const abort = Symbol();
5
+ export function useCallbackAsync(callback, deps) {
6
+ const controller = useMemo(() => new AbortController(), deps);
7
+ useEffect(() => () => controller.abort(abort), deps);
8
+ return useCallback((...args) => {
9
+ go(async () => {
10
+ try {
11
+ await callback(...args, controller.signal);
12
+ }
13
+ catch (err) {
14
+ if (err !== abort)
15
+ throw err;
16
+ }
17
+ });
18
+ }, deps);
19
+ }
20
+ //# sourceMappingURL=use-callback-async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-callback-async.js","sourceRoot":"","sources":["../src/use-callback-async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;AAEtB,MAAM,UAAU,gBAAgB,CAC9B,QAA0E,EAC1E,IAAoB;IAEpB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,eAAe,EAAE,EAAE,IAAI,CAAC,CAAA;IAC7D,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;IAEpD,OAAO,WAAW,CAAC,CAAC,GAAG,IAAU,EAAE,EAAE;QACnC,EAAE,CAAC,KAAK,IAAI,EAAE;YACZ,IAAI;gBACF,MAAM,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;aAC3C;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,KAAK,KAAK;oBAAE,MAAM,GAAG,CAAA;aAC7B;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { DependencyList } from 'react';
2
+ export declare function useEffectAsync(effect: (signal: AbortSignal) => Promise<void>, deps?: DependencyList): void;
@@ -0,0 +1,20 @@
1
+ import { useEffect } from 'react';
2
+ import { go } from '@blackglory/prelude';
3
+ import { AbortController } from 'extra-abort';
4
+ const abort = Symbol();
5
+ export function useEffectAsync(effect, deps) {
6
+ useEffect(() => {
7
+ const controller = new AbortController();
8
+ go(async () => {
9
+ try {
10
+ await effect(controller.signal);
11
+ }
12
+ catch (err) {
13
+ if (err !== abort)
14
+ throw err;
15
+ }
16
+ });
17
+ return () => controller.abort();
18
+ }, deps);
19
+ }
20
+ //# sourceMappingURL=use-effect-async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-effect-async.js","sourceRoot":"","sources":["../src/use-effect-async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;AAEtB,MAAM,UAAU,cAAc,CAC5B,MAA8C,EAC9C,IAAqB;IAErB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;QAExC,EAAE,CAAC,KAAK,IAAI,EAAE;YACZ,IAAI;gBACF,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;aAChC;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,KAAK,KAAK;oBAAE,MAAM,GAAG,CAAA;aAC7B;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;IACjC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
@@ -1,4 +1,4 @@
1
- import { NonEmptyArray } from 'justypes';
1
+ import { NonEmptyArray } from '@blackglory/prelude';
2
2
  import { IOptionState } from "./types.js";
3
3
  export declare function useMultipleSelection<T>(options: NonEmptyArray<T>, defaultSelectedIndexes?: number[]): {
4
4
  selectedIndexes: number[];
@@ -1,6 +1,5 @@
1
1
  import { useState, useMemo, useCallback } from 'react';
2
- import { assert } from '@blackglory/errors';
3
- import { toArray } from 'iterable-operator';
2
+ import { assert, toArray } from '@blackglory/prelude';
4
3
  import { useIIFE } from "./use-iife.js";
5
4
  export function useMultipleSelection(options, defaultSelectedIndexes = []) {
6
5
  useIIFE(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-multiple-selection.js","sourceRoot":"","sources":["../src/use-multiple-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3C,OAAO,EAAE,OAAO,EAAE,sBAAwB;AAE1C,MAAM,UAAU,oBAAoB,CAClC,OAAyB,EACzB,yBAAmC,EAAE;IAQrC,OAAO,CAAC,GAAG,EAAE;QACX,KAAK,MAAM,KAAK,IAAI,sBAAsB,EAAE;YAC1C,MAAM,CACJ,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,EACpC,0FAA0F,CAC3F,CAAA;SACF;IACH,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAA;IAE5B,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAA;IAEvF,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAC3E,YAAY,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACrE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,eAAe,CAAC,CAAC;QAC9C,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QAC/B,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,E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AAA;SAChB;aAAM;YACL,MAAM,CAAC,KAAK,CAAC,CAAA;SACd;IACH,CAAC;IAED,SAAS,MAAM,CAAC,KAAa;QAC3B,kBAAkB,CAAC,eAAe,CAAC,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAA;YACvC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,SAAS,QAAQ,CAAC,KAAa;QAC7B,kBAAkB,CAAC,eAAe,CAAC,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAA;YACvC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACpB,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { useEffect } from 'react';
2
- import { isntNull } from 'extra-utils';
2
+ import { isntNull } from '@blackglory/prelude';
3
3
  export function useResizeObserver(callback, refs) {
4
4
  const deps = refs.map(x => x.current);
5
5
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-resize-observer.js","sourceRoot":"","sources":["../src/use-resize-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,UAAU,iBAAiB,CAC/B,QAAgC,EAChC,IAAmE;IAEnE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;QAE7C,IAAI;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACnB,MAAM,CAAC,QAAQ,CAAC;aAChB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEpC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
1
+ {"version":3,"file":"use-resize-observer.js","sourceRoot":"","sources":["../src/use-resize-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,MAAM,UAAU,iBAAiB,CAC/B,QAAgC,EAChC,IAAmE;IAEnE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;QAE7C,IAAI;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aACnB,MAAM,CAAC,QAAQ,CAAC;aAChB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAEpC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
@@ -1,4 +1,4 @@
1
- import { NonEmptyArray } from 'justypes';
1
+ import { NonEmptyArray } from '@blackglory/prelude';
2
2
  import { IOptionState } from "./types.js";
3
3
  export declare function useSingleSelection<T>(options: NonEmptyArray<T>, defaultSelectedIndex: number): {
4
4
  selectedIndex: number;
@@ -1,5 +1,5 @@
1
1
  import { useState, useMemo, useCallback } from 'react';
2
- import { assert } from '@blackglory/errors';
2
+ import { assert } from '@blackglory/prelude';
3
3
  import { useIIFE } from "./use-iife.js";
4
4
  export function useSingleSelection(options, defaultSelectedIndex) {
5
5
  useIIFE(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../src/use-single-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAG3C,OAAO,EAAE,OAAO,EAAE,sBAAwB;AAE1C,MAAM,UAAU,kBAAkB,CAChC,OAAyB,EACzB,oBAA4B;IAM5B,OAAO,CAAC,GAAG,EAAE;QACX,MAAM,CACJ,oBAAoB,IAAI,CAAC,IAAI,oBAAoB,GAAG,OAAO,CAAC,MAAM,EAClE,+EAA+E,CAChF,CAAA;IACH,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAE1B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAExE,OAAO;QACL,aAAa;QACb,YAAY,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;KAChC,CAAA;IAED,SAAS,kBAAkB;QACzB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,QAAQ,EAAE,KAAK,KAAK,aAAa;SAClC,CAAC,CAAC,CAAA;IACL,CAAC;IAED,SAAS,MAAM,CAAC,KAAa;QAC3B,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"use-single-selection.js","sourceRoot":"","sources":["../src/use-single-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACtD,OAAO,EAAE,MAAM,EAAiB,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,sBAAwB;AAE1C,MAAM,UAAU,kBAAkB,CAChC,OAAyB,EACzB,oBAA4B;IAM5B,OAAO,CAAC,GAAG,EAAE;QACX,MAAM,CACJ,oBAAoB,IAAI,CAAC,IAAI,oBAAoB,GAAG,OAAO,CAAC,MAAM,EAClE,+EAA+E,CAChF,CAAA;IACH,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAE1B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAExE,OAAO;QACL,aAAa;QACb,YAAY,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;KAChC,CAAA;IAED,SAAS,kBAAkB;QACzB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,QAAQ,EAAE,KAAK,KAAK,aAAa;SAClC,CAAC,CAAC,CAAA;IACL,CAAC;IAED,SAAS,MAAM,CAAC,KAAa;QAC3B,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;AACH,CAAC"}
@@ -1,2 +1,2 @@
1
- import { NonEmptyArray } from 'justypes';
1
+ import { NonEmptyArray } from '@blackglory/prelude';
2
2
  export declare function useStateCycle<T>(orderedStates: NonEmptyArray<T>, initialStateIndex?: number): [state: T, next: () => void];
package/lib/use-step.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { NonEmptyArray } from 'justypes';
1
+ import { NonEmptyArray } from '@blackglory/prelude';
2
2
  export declare function useStep<T>(steps: NonEmptyArray<T>, initialStepIndex?: number): [currentStep: T, next: () => void, previous: () => void];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-react-hooks",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [
@@ -10,6 +10,9 @@
10
10
  "main": "lib/index.js",
11
11
  "types": "lib/index.d.ts",
12
12
  "sideEffects": false,
13
+ "engines": {
14
+ "node": ">=16"
15
+ },
13
16
  "repository": "git@github.com:BlackGlory/extra-react-hooks.git",
14
17
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
15
18
  "license": "MIT",
@@ -30,16 +33,15 @@
30
33
  }
31
34
  },
32
35
  "devDependencies": {
33
- "@blackglory/wait-for": "^0.5.4",
34
- "@commitlint/cli": "^17.4.2",
35
- "@commitlint/config-conventional": "^17.4.2",
36
- "@testing-library/react": "^13.4.0",
37
- "@testing-library/react-hooks": "^8.0.1",
36
+ "@blackglory/wait-for": "^0.7.3",
37
+ "@commitlint/cli": "^17.6.1",
38
+ "@commitlint/config-conventional": "^17.6.1",
39
+ "@testing-library/react": "^14.0.0",
38
40
  "@types/jasmine": "^4.3.1",
39
- "@types/react": "^17.0.40",
40
- "@typescript-eslint/eslint-plugin": "^5.48.2",
41
- "@typescript-eslint/parser": "^5.48.2",
42
- "eslint": "^8.32.0",
41
+ "@types/react": "^18.0.35",
42
+ "@typescript-eslint/eslint-plugin": "^5.58.0",
43
+ "@typescript-eslint/parser": "^5.58.0",
44
+ "eslint": "^8.38.0",
43
45
  "eslint-plugin-react-hooks": "^4.6.0",
44
46
  "husky": "4",
45
47
  "karma": "^6.4.1",
@@ -50,22 +52,20 @@
50
52
  "react": "^18.2.0",
51
53
  "react-dom": "^18.2.0",
52
54
  "react-test-renderer": "^18.2.0",
53
- "rimraf": "^4.1.1",
55
+ "rimraf": "^4.3.0",
54
56
  "standard-version": "^9.3.2",
55
57
  "ts-loader": "^9.4.2",
56
58
  "ts-patch": "^2.1.0",
57
- "tsconfig-paths-webpack-plugin": "^4.0.0",
59
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
58
60
  "tslib": "^2.4.1",
59
- "typescript": "4.8",
61
+ "typescript": "4.9.5",
60
62
  "typescript-transform-paths": "^3.4.6",
61
- "webpack": "^5.75.0"
63
+ "webpack": "^5.79.0"
62
64
  },
63
65
  "dependencies": {
64
- "@blackglory/errors": "^2.4.3",
65
- "extra-fsm": "^0.1.1",
66
- "extra-utils": "^5.0.1",
67
- "iterable-operator": "^2.5.0",
68
- "justypes": "^4.1.0",
66
+ "@blackglory/prelude": "^0.3.2",
67
+ "extra-abort": "^0.3.6",
68
+ "extra-fsm": "^0.2.0",
69
69
  "rxjs": "^7.8.0"
70
70
  },
71
71
  "peerDependencies": {
package/CHANGELOG.md DELETED
@@ -1,167 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [0.4.3](https://github.com/BlackGlory/extra-react-hooks/compare/v0.4.2...v0.4.3) (2023-01-28)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * dependencies ([c04a0ac](https://github.com/BlackGlory/extra-react-hooks/commit/c04a0acf76476c37f7dbc52de843df828d333d52))
11
-
12
- ### [0.4.2](https://github.com/BlackGlory/extra-react-hooks/compare/v0.4.1...v0.4.2) (2023-01-22)
13
-
14
- ### [0.4.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.4.0...v0.4.1) (2023-01-21)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * exports ([6782f4a](https://github.com/BlackGlory/extra-react-hooks/commit/6782f4a40921a8d5bc0fa4f38fc37b218ba5a989))
20
-
21
- ## [0.4.0](https://github.com/BlackGlory/extra-react-hooks/compare/v0.3.4...v0.4.0) (2023-01-21)
22
-
23
-
24
- ### ⚠ BREAKING CHANGES
25
-
26
- * CommonJS => ESM
27
-
28
- * commonjs => esm, remove es2015 support ([a560890](https://github.com/BlackGlory/extra-react-hooks/commit/a560890e0d48892c37efa1e3e0a474816ecedae4))
29
-
30
- ### [0.3.4](https://github.com/BlackGlory/extra-react-hooks/compare/v0.3.3...v0.3.4) (2023-01-21)
31
-
32
- ### [0.3.3](https://github.com/BlackGlory/extra-react-hooks/compare/v0.3.2...v0.3.3) (2022-10-24)
33
-
34
- ### [0.3.2](https://github.com/BlackGlory/extra-react-hooks/compare/v0.3.1...v0.3.2) (2022-09-24)
35
-
36
- ### [0.3.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.3.0...v0.3.1) (2022-07-22)
37
-
38
-
39
- ### Bug Fixes
40
-
41
- * toggle ([3075106](https://github.com/BlackGlory/extra-react-hooks/commit/307510652ed2e286d729c12e303231df1aa2bc20))
42
-
43
- ## [0.3.0](https://github.com/BlackGlory/extra-react-hooks/compare/v0.2.1...v0.3.0) (2022-07-22)
44
-
45
-
46
- ### ⚠ BREAKING CHANGES
47
-
48
- * - Rewrite `useSingleSelection`
49
- - Rewrite `useMultipleSelection`
50
-
51
- ### Features
52
-
53
- * add useUnmount, useIIFE ([fb5eb9d](https://github.com/BlackGlory/extra-react-hooks/commit/fb5eb9d181c461c2eeac9f497b7a551482763049))
54
-
55
-
56
- ### Bug Fixes
57
-
58
- * add props into deps ([def8482](https://github.com/BlackGlory/extra-react-hooks/commit/def8482f3d944bd304cf834e89fa5154b0dbb223))
59
-
60
-
61
- * improve hooks ([69932c2](https://github.com/BlackGlory/extra-react-hooks/commit/69932c2d2a420dc04225dcf245a2bbc3fd03f1fd))
62
-
63
- ### [0.2.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.2.0...v0.2.1) (2022-07-21)
64
-
65
- ## [0.2.0](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.15...v0.2.0) (2022-07-21)
66
-
67
-
68
- ### ⚠ BREAKING CHANGES
69
-
70
- * - The return value of `useSingleSelection`:
71
- - Rename `value` to `selectedValue`
72
- - The return value of `useMultipleSelection`:
73
- - Rename `values` to `selectedValues`
74
-
75
- * rename props of return values ([87e357b](https://github.com/BlackGlory/extra-react-hooks/commit/87e357be9e502cd915b4505979184bf85f2819ba))
76
-
77
- ### [0.1.15](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.14...v0.1.15) (2022-07-21)
78
-
79
-
80
- ### Features
81
-
82
- * add useRenderCounter ([c522357](https://github.com/BlackGlory/extra-react-hooks/commit/c5223571d7e1d83cd49349b8e17c005a898e4b0a))
83
-
84
- ### [0.1.14](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.13...v0.1.14) (2022-07-21)
85
-
86
-
87
- ### Features
88
-
89
- * add useIsFirstRender, useUpdateEffect ([b4f315b](https://github.com/BlackGlory/extra-react-hooks/commit/b4f315bcd8f6fd367bdb8044bade741bbdc8d9b9))
90
-
91
- ### [0.1.13](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.12...v0.1.13) (2022-07-21)
92
-
93
-
94
- ### Features
95
-
96
- * add useMultipleSelection ([2dcfbe6](https://github.com/BlackGlory/extra-react-hooks/commit/2dcfbe65f713bf35915eec967d400c5c44b86e7c))
97
-
98
- ### [0.1.12](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.11...v0.1.12) (2022-06-20)
99
-
100
- ### [0.1.11](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.10...v0.1.11) (2022-03-19)
101
-
102
- ### [0.1.10](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.9...v0.1.10) (2022-01-05)
103
-
104
- ### [0.1.9](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.8...v0.1.9) (2021-12-13)
105
-
106
-
107
- ### Features
108
-
109
- * add useFiniteStateMachine ([e6e8962](https://github.com/BlackGlory/extra-react-hooks/commit/e6e8962724774a8b217a1fd5332c13ba4ee051f7))
110
-
111
- ### [0.1.8](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.7...v0.1.8) (2021-12-13)
112
-
113
-
114
- ### Features
115
-
116
- * add useForceUpdate ([f747227](https://github.com/BlackGlory/extra-react-hooks/commit/f747227c02c5bb2f0a0f1889de1c022bc9ca1e4d))
117
-
118
- ### [0.1.7](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.6...v0.1.7) (2021-12-10)
119
-
120
-
121
- ### Features
122
-
123
- * add useStep ([f404846](https://github.com/BlackGlory/extra-react-hooks/commit/f4048462cc254499d7fd06cd51e16e98acd978ca))
124
-
125
- ### [0.1.6](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.5...v0.1.6) (2021-11-15)
126
-
127
-
128
- ### Features
129
-
130
- * add useResizeObserver ([8a4e317](https://github.com/BlackGlory/extra-react-hooks/commit/8a4e317921387fa26e768796e52c8fe44e9b347e))
131
-
132
- ### [0.1.5](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.4...v0.1.5) (2021-10-04)
133
-
134
-
135
- ### Features
136
-
137
- * add useIncrement ([e5f1fc4](https://github.com/BlackGlory/extra-react-hooks/commit/e5f1fc442a2c69aa490fed873cc21fe4ad9ff76b))
138
-
139
- ### [0.1.4](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.3...v0.1.4) (2021-08-18)
140
-
141
-
142
- ### Features
143
-
144
- * add useIsMounted ([32a1295](https://github.com/BlackGlory/extra-react-hooks/commit/32a12951aab92ae5734f4caddf45021e2bbed793))
145
-
146
- ### [0.1.3](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.2...v0.1.3) (2021-08-18)
147
-
148
-
149
- ### Features
150
-
151
- * add useStateCycle ([a48da21](https://github.com/BlackGlory/extra-react-hooks/commit/a48da211f364688daa63a0bd5406fa2f2c61eba7))
152
-
153
- ### [0.1.2](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.1...v0.1.2) (2021-07-03)
154
-
155
- ### [0.1.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.0...v0.1.1) (2021-06-29)
156
-
157
-
158
- ### Features
159
-
160
- * add useMount ([070045a](https://github.com/BlackGlory/extra-react-hooks/commit/070045ac0f209712eadd0f4e79c1328d20745b04))
161
-
162
- ## 0.1.0 (2021-06-04)
163
-
164
-
165
- ### Features
166
-
167
- * add useToggle, useSingleSelection ([0b9ee92](https://github.com/BlackGlory/extra-react-hooks/commit/0b9ee92597a230989b51b7242f529f0a36590d1f))