extra-react-hooks 0.1.8 → 0.1.11

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.
@@ -7,3 +7,4 @@ export * from './use-toggle';
7
7
  export * from './use-resize-observer';
8
8
  export * from './use-step';
9
9
  export * from './use-force-update';
10
+ export * from './use-finite-state-machine';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,4 +23,5 @@ __exportStar(require("./use-toggle"), exports);
19
23
  __exportStar(require("./use-resize-observer"), exports);
20
24
  __exportStar(require("./use-step"), exports);
21
25
  __exportStar(require("./use-force-update"), exports);
26
+ __exportStar(require("./use-finite-state-machine"), exports);
22
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
@@ -0,0 +1,3 @@
1
+ import { ObservableFiniteStateMachine, IFiniteStateMachineSchema } from '@blackglory/structures';
2
+ export { ObservableFiniteStateMachine, IFiniteStateMachineSchema } from '@blackglory/structures';
3
+ export declare function useFiniteStateMachine<State extends string, Event extends string>(schema: IFiniteStateMachineSchema<State, Event>, initialState: State): ObservableFiniteStateMachine<State, Event>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFiniteStateMachine = exports.ObservableFiniteStateMachine = void 0;
4
+ const react_1 = require("react");
5
+ const structures_1 = require("@blackglory/structures");
6
+ const observable_hooks_1 = require("observable-hooks");
7
+ const use_force_update_1 = require("./use-force-update");
8
+ var structures_2 = require("@blackglory/structures");
9
+ Object.defineProperty(exports, "ObservableFiniteStateMachine", { enumerable: true, get: function () { return structures_2.ObservableFiniteStateMachine; } });
10
+ function useFiniteStateMachine(schema, initialState) {
11
+ const forceUpdate = (0, use_force_update_1.useForceUpdate)();
12
+ const fsm = (0, react_1.useMemo)(() => new structures_1.ObservableFiniteStateMachine(schema, initialState), [schema]);
13
+ (0, observable_hooks_1.useSubscription)((0, observable_hooks_1.useObservable)(() => fsm.observeStateChanges(), [fsm]), forceUpdate);
14
+ return fsm;
15
+ }
16
+ exports.useFiniteStateMachine = useFiniteStateMachine;
17
+ //# sourceMappingURL=use-finite-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-finite-state-machine.js","sourceRoot":"","sources":["../../src/use-finite-state-machine.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAC/B,uDAG+B;AAC/B,uDAAiE;AACjE,yDAAmD;AAEnD,qDAG+B;AAF7B,0HAAA,4BAA4B,OAAA;AAI9B,SAAgB,qBAAqB,CACnC,MAA+C,EAC/C,YAAmB;IAEnB,MAAM,WAAW,GAAG,IAAA,iCAAc,GAAE,CAAA;IACpC,MAAM,GAAG,GAAG,IAAA,eAAO,EACjB,GAAG,EAAE,CAAC,IAAI,yCAA4B,CAAC,MAAM,EAAE,YAAY,CAAC,EAC5D,CAAC,MAAM,CAAC,CACT,CAAA;IACD,IAAA,kCAAe,EACb,IAAA,gCAAa,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EACrD,WAAW,CACZ,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAdD,sDAcC"}
@@ -7,3 +7,4 @@ export * from './use-toggle';
7
7
  export * from './use-resize-observer';
8
8
  export * from './use-step';
9
9
  export * from './use-force-update';
10
+ export * from './use-finite-state-machine';
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,4 +23,5 @@ __exportStar(require("./use-toggle"), exports);
19
23
  __exportStar(require("./use-resize-observer"), exports);
20
24
  __exportStar(require("./use-step"), exports);
21
25
  __exportStar(require("./use-force-update"), exports);
26
+ __exportStar(require("./use-finite-state-machine"), exports);
22
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
@@ -0,0 +1,3 @@
1
+ import { ObservableFiniteStateMachine, IFiniteStateMachineSchema } from '@blackglory/structures';
2
+ export { ObservableFiniteStateMachine, IFiniteStateMachineSchema } from '@blackglory/structures';
3
+ export declare function useFiniteStateMachine<State extends string, Event extends string>(schema: IFiniteStateMachineSchema<State, Event>, initialState: State): ObservableFiniteStateMachine<State, Event>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFiniteStateMachine = exports.ObservableFiniteStateMachine = void 0;
4
+ const react_1 = require("react");
5
+ const structures_1 = require("@blackglory/structures");
6
+ const observable_hooks_1 = require("observable-hooks");
7
+ const use_force_update_1 = require("./use-force-update");
8
+ var structures_2 = require("@blackglory/structures");
9
+ Object.defineProperty(exports, "ObservableFiniteStateMachine", { enumerable: true, get: function () { return structures_2.ObservableFiniteStateMachine; } });
10
+ function useFiniteStateMachine(schema, initialState) {
11
+ const forceUpdate = (0, use_force_update_1.useForceUpdate)();
12
+ const fsm = (0, react_1.useMemo)(() => new structures_1.ObservableFiniteStateMachine(schema, initialState), [schema]);
13
+ (0, observable_hooks_1.useSubscription)((0, observable_hooks_1.useObservable)(() => fsm.observeStateChanges(), [fsm]), forceUpdate);
14
+ return fsm;
15
+ }
16
+ exports.useFiniteStateMachine = useFiniteStateMachine;
17
+ //# sourceMappingURL=use-finite-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-finite-state-machine.js","sourceRoot":"","sources":["../../src/use-finite-state-machine.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAC/B,uDAG+B;AAC/B,uDAAiE;AACjE,yDAAmD;AAEnD,qDAG+B;AAF7B,0HAAA,4BAA4B,OAAA;AAI9B,SAAgB,qBAAqB,CACnC,MAA+C,EAC/C,YAAmB;IAEnB,MAAM,WAAW,GAAG,IAAA,iCAAc,GAAE,CAAA;IACpC,MAAM,GAAG,GAAG,IAAA,eAAO,EACjB,GAAG,EAAE,CAAC,IAAI,yCAA4B,CAAC,MAAM,EAAE,YAAY,CAAC,EAC5D,CAAC,MAAM,CAAC,CACT,CAAA;IACD,IAAA,kCAAe,EACb,IAAA,gCAAa,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EACrD,WAAW,CACZ,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAdD,sDAcC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-react-hooks",
3
- "version": "0.1.8",
3
+ "version": "0.1.11",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [
@@ -9,6 +9,7 @@
9
9
  ],
10
10
  "main": "lib/es2018/index.js",
11
11
  "types": "lib/es2018/index.d.ts",
12
+ "sideEffects": false,
12
13
  "repository": "git@github.com:BlackGlory/extra-react-hooks.git",
13
14
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
14
15
  "license": "MIT",
@@ -37,24 +38,24 @@
37
38
  }
38
39
  },
39
40
  "devDependencies": {
40
- "@blackglory/wait-for": "^0.3.5",
41
- "@commitlint/cli": "^15.0.0",
42
- "@commitlint/config-conventional": "^15.0.0",
43
- "@rollup/plugin-commonjs": "^21.0.1",
41
+ "@blackglory/wait-for": "^0.4.4",
42
+ "@commitlint/cli": "^16.2.3",
43
+ "@commitlint/config-conventional": "^16.2.1",
44
+ "@rollup/plugin-commonjs": "^21.0.2",
44
45
  "@rollup/plugin-json": "^4.1.0",
45
- "@rollup/plugin-node-resolve": "^13.0.6",
46
- "@rollup/plugin-replace": "^3.0.0",
47
- "@rollup/plugin-typescript": "^8.3.0",
48
- "@testing-library/react": "^12.1.2",
46
+ "@rollup/plugin-node-resolve": "^13.1.3",
47
+ "@rollup/plugin-replace": "^4.0.0",
48
+ "@rollup/plugin-typescript": "^8.3.1",
49
+ "@testing-library/react": "^12.1.4",
49
50
  "@testing-library/react-hooks": "^7.0.2",
50
- "@types/jasmine": "^3.10.2",
51
- "@types/react": "^17.0.37",
52
- "@typescript-eslint/eslint-plugin": "^5.6.0",
53
- "@typescript-eslint/parser": "^5.6.0",
54
- "eslint": "^8.4.1",
55
- "husky": "^4.3.8",
56
- "karma": "^6.3.9",
57
- "karma-chrome-launcher": "^3.1.0",
51
+ "@types/jasmine": "^4.0.0",
52
+ "@types/react": "^17.0.40",
53
+ "@typescript-eslint/eslint-plugin": "^5.15.0",
54
+ "@typescript-eslint/parser": "^5.15.0",
55
+ "eslint": "^8.11.0",
56
+ "husky": "4",
57
+ "karma": "^6.3.17",
58
+ "karma-chrome-launcher": "^3.1.1",
58
59
  "karma-jasmine": "^4.0.1",
59
60
  "karma-webpack": "^5.0.0",
60
61
  "npm-run-all": "^4.1.5",
@@ -62,20 +63,23 @@
62
63
  "react-dom": "^17.0.2",
63
64
  "react-test-renderer": "^17.0.2",
64
65
  "rimraf": "^3.0.2",
65
- "rollup": "^2.61.1",
66
+ "rollup": "^2.70.1",
66
67
  "rollup-plugin-analyzer": "^4.0.0",
67
68
  "rollup-plugin-terser": "^7.0.2",
68
69
  "standard-version": "^9.3.2",
69
- "ts-loader": "^9.2.6",
70
+ "ts-loader": "^9.2.8",
70
71
  "tsconfig-paths-webpack-plugin": "^3.5.2",
71
72
  "tscpaths": "^0.0.9",
72
73
  "tslib": "^2.3.1",
73
- "typescript": "^4.5.3",
74
- "webpack": "^5.65.0"
74
+ "typescript": "^4.6.2",
75
+ "webpack": "^5.70.0"
75
76
  },
76
77
  "dependencies": {
77
- "@blackglory/errors": "^1.1.2",
78
- "@blackglory/types": "^0.5.2"
78
+ "@blackglory/errors": "^2.2.1",
79
+ "@blackglory/structures": "^0.3.5",
80
+ "@blackglory/types": "^1.0.0",
81
+ "observable-hooks": "^4.2.0",
82
+ "rxjs": "^7.5.5"
79
83
  },
80
84
  "peerDependencies": {
81
85
  "react": ">= 16.8"
package/CHANGELOG.md DELETED
@@ -1,61 +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.1.8](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.7...v0.1.8) (2021-12-13)
6
-
7
-
8
- ### Features
9
-
10
- * add useForceUpdate ([f747227](https://github.com/BlackGlory/extra-react-hooks/commit/f747227c02c5bb2f0a0f1889de1c022bc9ca1e4d))
11
-
12
- ### [0.1.7](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.6...v0.1.7) (2021-12-10)
13
-
14
-
15
- ### Features
16
-
17
- * add useStep ([f404846](https://github.com/BlackGlory/extra-react-hooks/commit/f4048462cc254499d7fd06cd51e16e98acd978ca))
18
-
19
- ### [0.1.6](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.5...v0.1.6) (2021-11-15)
20
-
21
-
22
- ### Features
23
-
24
- * add useResizeObserver ([8a4e317](https://github.com/BlackGlory/extra-react-hooks/commit/8a4e317921387fa26e768796e52c8fe44e9b347e))
25
-
26
- ### [0.1.5](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.4...v0.1.5) (2021-10-04)
27
-
28
-
29
- ### Features
30
-
31
- * add useIncrement ([e5f1fc4](https://github.com/BlackGlory/extra-react-hooks/commit/e5f1fc442a2c69aa490fed873cc21fe4ad9ff76b))
32
-
33
- ### [0.1.4](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.3...v0.1.4) (2021-08-18)
34
-
35
-
36
- ### Features
37
-
38
- * add useIsMounted ([32a1295](https://github.com/BlackGlory/extra-react-hooks/commit/32a12951aab92ae5734f4caddf45021e2bbed793))
39
-
40
- ### [0.1.3](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.2...v0.1.3) (2021-08-18)
41
-
42
-
43
- ### Features
44
-
45
- * add useStateCycle ([a48da21](https://github.com/BlackGlory/extra-react-hooks/commit/a48da211f364688daa63a0bd5406fa2f2c61eba7))
46
-
47
- ### [0.1.2](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.1...v0.1.2) (2021-07-03)
48
-
49
- ### [0.1.1](https://github.com/BlackGlory/extra-react-hooks/compare/v0.1.0...v0.1.1) (2021-06-29)
50
-
51
-
52
- ### Features
53
-
54
- * add useMount ([070045a](https://github.com/BlackGlory/extra-react-hooks/commit/070045ac0f209712eadd0f4e79c1328d20745b04))
55
-
56
- ## 0.1.0 (2021-06-04)
57
-
58
-
59
- ### Features
60
-
61
- * add useToggle, useSingleSelection ([0b9ee92](https://github.com/BlackGlory/extra-react-hooks/commit/0b9ee92597a230989b51b7242f529f0a36590d1f))