reca 0.0.13 → 1.1.0
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/config.d.ts +9 -9
- package/dist/config.js +17 -17
- package/dist/decorators/NotAuto.d.ts +1 -1
- package/dist/decorators/NotAuto.js +3 -3
- package/dist/decorators/NotAuto.js.map +1 -1
- package/dist/decorators/NotRedraw.d.ts +1 -1
- package/dist/decorators/NotRedraw.js +3 -3
- package/dist/hooks/UseStore.d.ts +9 -9
- package/dist/hooks/UseStore.js +65 -66
- package/dist/hooks/UseStore.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/stores/AutoStore.d.ts +14 -13
- package/dist/stores/AutoStore.js +79 -77
- package/dist/stores/AutoStore.js.map +1 -1
- package/dist/stores/Store.d.ts +82 -82
- package/dist/stores/Store.js +111 -111
- package/package.json +23 -22
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/config.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ClassConstructor } from "first-di/dist/typings/class-constructor";
|
|
2
|
-
export declare class DiConfig {
|
|
3
|
-
resolver: <T extends object>(constructor: ClassConstructor<T>, options?: any) => T;
|
|
4
|
-
}
|
|
5
|
-
export declare class Config {
|
|
6
|
-
di: DiConfig;
|
|
7
|
-
readonly isBrowser: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const config: Config;
|
|
1
|
+
import type { ClassConstructor } from "first-di/dist/typings/class-constructor";
|
|
2
|
+
export declare class DiConfig {
|
|
3
|
+
resolver: <T extends object>(constructor: ClassConstructor<T>, options?: any) => T;
|
|
4
|
+
}
|
|
5
|
+
export declare class Config {
|
|
6
|
+
di: DiConfig;
|
|
7
|
+
readonly isBrowser: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const config: Config;
|
package/dist/config.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { resolve } from "first-di";
|
|
3
|
-
export class DiConfig {
|
|
4
|
-
constructor() {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
this.resolver = resolve;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export class Config {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.di = new DiConfig();
|
|
12
|
-
// From https://gist.github.com/rhysburnie/498bfd98f24b7daf5fd5930c7f3c1b7b
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/no-unnecessary-condition
|
|
14
|
-
this.isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export const config = new Config();
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { resolve } from "first-di";
|
|
3
|
+
export class DiConfig {
|
|
4
|
+
constructor() {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
this.resolver = resolve;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class Config {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.di = new DiConfig();
|
|
12
|
+
// From https://gist.github.com/rhysburnie/498bfd98f24b7daf5fd5930c7f3c1b7b
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/no-unnecessary-condition
|
|
14
|
+
this.isBrowser = !(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const config = new Config();
|
|
18
18
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const notAuto: () => MethodDecorator;
|
|
1
|
+
export declare const notAuto: () => MethodDecorator | PropertyDecorator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const notAuto = () => (target, propertyKey) => {
|
|
2
|
-
Reflect.defineMetadata("reca:notAuto", true, target, propertyKey);
|
|
3
|
-
};
|
|
1
|
+
export const notAuto = () => (target, propertyKey) => {
|
|
2
|
+
Reflect.defineMetadata("reca:notAuto", true, target, propertyKey);
|
|
3
|
+
};
|
|
4
4
|
//# sourceMappingURL=NotAuto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotAuto.js","sourceRoot":"","sources":["../../src/decorators/NotAuto.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"NotAuto.js","sourceRoot":"","sources":["../../src/decorators/NotAuto.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,GAAwC,EAAE,CAAC,CAC9D,MAAc,EACd,WAA4B,EACxB,EAAE;IACN,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACtE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const notRedraw: () => MethodDecorator;
|
|
1
|
+
export declare const notRedraw: () => MethodDecorator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const notRedraw = () => (target, propertyKey) => {
|
|
2
|
-
Reflect.defineMetadata("reca:notRedraw", true, target, propertyKey);
|
|
3
|
-
};
|
|
1
|
+
export const notRedraw = () => (target, propertyKey) => {
|
|
2
|
+
Reflect.defineMetadata("reca:notRedraw", true, target, propertyKey);
|
|
3
|
+
};
|
|
4
4
|
//# sourceMappingURL=NotRedraw.js.map
|
package/dist/hooks/UseStore.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Store } from "../stores/Store.js";
|
|
2
|
-
/**
|
|
3
|
-
* Todo: add DI here
|
|
4
|
-
*
|
|
5
|
-
* @param store
|
|
6
|
-
* @param props
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare const useStore: <P extends object, T extends Store<P>>(store: new (...params: any[]) => T, props?: P | undefined) => T;
|
|
1
|
+
import type { Store } from "../stores/Store.js";
|
|
2
|
+
/**
|
|
3
|
+
* Todo: add DI here
|
|
4
|
+
*
|
|
5
|
+
* @param store
|
|
6
|
+
* @param props
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const useStore: <P extends object, T extends Store<P>>(store: new (...params: any[]) => T, props?: P | undefined) => T;
|
package/dist/hooks/UseStore.js
CHANGED
|
@@ -1,67 +1,66 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { config } from "../config.js";
|
|
3
|
-
/**
|
|
4
|
-
* Todo: add DI here
|
|
5
|
-
*
|
|
6
|
-
* @param store
|
|
7
|
-
* @param props
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export const useStore = (
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
store, props) => {
|
|
13
|
-
// Render function
|
|
14
|
-
const [, setSeed] = useState(0);
|
|
15
|
-
// Constructor
|
|
16
|
-
let isInit = false;
|
|
17
|
-
const [stateStore] = useState(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
stateStore.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { config } from "../config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Todo: add DI here
|
|
5
|
+
*
|
|
6
|
+
* @param store
|
|
7
|
+
* @param props
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export const useStore = (
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
store, props) => {
|
|
13
|
+
// Render function
|
|
14
|
+
const [, setSeed] = useState(0);
|
|
15
|
+
// Constructor
|
|
16
|
+
let isInit = false;
|
|
17
|
+
const [stateStore] = useState(() => {
|
|
18
|
+
isInit = true;
|
|
19
|
+
// Resolve dependencies
|
|
20
|
+
const constructorParams = Reflect
|
|
21
|
+
.getMetadata("design:paramtypes", store) ?? [];
|
|
22
|
+
const resolvedParams = constructorParams.map((param) => {
|
|
23
|
+
if (typeof param === "function" && "prototype" in param) { // Check is class
|
|
24
|
+
if (param.prototype === Object.prototype) { // Typescript interface in props (props: P)
|
|
25
|
+
return props;
|
|
26
|
+
}
|
|
27
|
+
// True class
|
|
28
|
+
return config.di.resolver(param);
|
|
29
|
+
}
|
|
30
|
+
// Else props object
|
|
31
|
+
return props;
|
|
32
|
+
});
|
|
33
|
+
// eslint-disable-next-line new-cap
|
|
34
|
+
const resolvedStore = new store(...resolvedParams);
|
|
35
|
+
resolvedStore.setRedrawFunction(() => {
|
|
36
|
+
setSeed(Math.random());
|
|
37
|
+
});
|
|
38
|
+
return resolvedStore;
|
|
39
|
+
});
|
|
40
|
+
stateStore.isDrawTime = true;
|
|
41
|
+
// Activate and Dispose(Destructor) methods
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
stateStore.activate(props ?? {});
|
|
44
|
+
return () => stateStore.dispose(props ?? {});
|
|
45
|
+
}, []);
|
|
46
|
+
// Update method
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
48
|
+
if (!isInit) {
|
|
49
|
+
stateStore.update(props ?? {});
|
|
50
|
+
}
|
|
51
|
+
// PropsUpdate method
|
|
52
|
+
useMemo(() => {
|
|
53
|
+
if (!isInit) {
|
|
54
|
+
stateStore.propsUpdate(props ?? {});
|
|
55
|
+
}
|
|
56
|
+
}, [props ?? {}]);
|
|
57
|
+
// AfterUpdate method
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!isInit) {
|
|
60
|
+
stateStore.afterUpdate(props ?? {});
|
|
61
|
+
}
|
|
62
|
+
stateStore.isDrawTime = false;
|
|
63
|
+
});
|
|
64
|
+
return stateStore;
|
|
65
|
+
};
|
|
67
66
|
//# sourceMappingURL=UseStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseStore.js","sourceRoot":"","sources":["../../src/hooks/UseStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;AACpB,8DAA8D;AAC9D,KAAkC,EAClC,KAAS,EACR,EAAE;IACH,kBAAkB;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEhC,cAAc;IACd,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE
|
|
1
|
+
{"version":3,"file":"UseStore.js","sourceRoot":"","sources":["../../src/hooks/UseStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;AACpB,8DAA8D;AAC9D,KAAkC,EAClC,KAAS,EACR,EAAE;IACH,kBAAkB;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEhC,cAAc;IACd,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC/B,MAAM,GAAG,IAAI,CAAC;QAEd,uBAAuB;QACvB,MAAM,iBAAiB,GAAc,OAAO;aACvC,WAAW,CAAC,mBAAmB,EAAE,KAAK,CAAgB,IAAI,EAAE,CAAC;QAElE,MAAM,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5D,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,WAAW,IAAI,KAAK,EAAE,EAAE,iBAAiB;gBACxE,IAAI,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,2CAA2C;oBACnF,OAAO,KAAK,CAAC;iBAChB;gBAED,aAAa;gBACb,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAiC,CAAC,CAAC;aAChE;YAED,oBAAoB;YACpB,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,mCAAmC;QACnC,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,GAAG,cAAc,CAAC,CAAC;QAEnD,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE;YACjC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC;IAE7B,2CAA2C;IAC3C,SAAS,CAAC,GAAG,EAAE;QACX,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAO,CAAC,CAAC;QAEtC,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,EAAO,CAAC,CAAC;IACtD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,gBAAgB;IAChB,uEAAuE;IACvE,IAAI,CAAC,MAAM,EAAE;QACT,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,EAAO,CAAC,CAAC;KACvC;IAED,qBAAqB;IACrB,OAAO,CACH,GAAG,EAAE;QACD,IAAI,CAAC,MAAM,EAAE;YACT,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,EAAO,CAAC,CAAC;SAC5C;IACL,CAAC,EACD,CAAC,KAAK,IAAI,EAAE,CAAC,CAChB,CAAC;IAEF,qBAAqB;IACrB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,MAAM,EAAE;YACT,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,EAAO,CAAC,CAAC;SAC5C;QACD,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./hooks/UseStore.js";
|
|
2
|
-
export * from "./stores/Store.js";
|
|
3
|
-
export * from "./stores/AutoStore.js";
|
|
4
|
-
export * from "./decorators/NotAuto.js";
|
|
5
|
-
export * from "./decorators/NotRedraw.js";
|
|
6
|
-
export { reflection } from "first-di";
|
|
7
|
-
export * from "./config.js";
|
|
1
|
+
export * from "./hooks/UseStore.js";
|
|
2
|
+
export * from "./stores/Store.js";
|
|
3
|
+
export * from "./stores/AutoStore.js";
|
|
4
|
+
export * from "./decorators/NotAuto.js";
|
|
5
|
+
export * from "./decorators/NotRedraw.js";
|
|
6
|
+
export { reflection } from "first-di";
|
|
7
|
+
export * from "./config.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./hooks/UseStore.js";
|
|
2
|
-
export * from "./stores/Store.js";
|
|
3
|
-
export * from "./stores/AutoStore.js";
|
|
4
|
-
export * from "./decorators/NotAuto.js";
|
|
5
|
-
export * from "./decorators/NotRedraw.js";
|
|
6
|
-
export { reflection } from "first-di";
|
|
7
|
-
export * from "./config.js";
|
|
1
|
+
export * from "./hooks/UseStore.js";
|
|
2
|
+
export * from "./stores/Store.js";
|
|
3
|
+
export * from "./stores/AutoStore.js";
|
|
4
|
+
export * from "./decorators/NotAuto.js";
|
|
5
|
+
export * from "./decorators/NotRedraw.js";
|
|
6
|
+
export { reflection } from "first-di";
|
|
7
|
+
export * from "./config.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Store } from "./Store.js";
|
|
3
|
+
export declare class AutoStore<T extends object = object> extends Store<T> {
|
|
4
|
+
protected dontObserveProperties: (string | symbol)[];
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Replace properties by getters and setters, inject redraw
|
|
8
|
+
*/
|
|
9
|
+
protected injectProperties(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Wrap methods, inject redraw
|
|
12
|
+
*/
|
|
13
|
+
protected injectMethods(): void;
|
|
14
|
+
}
|
package/dist/stores/AutoStore.js
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Reflect.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Store } from "./Store.js";
|
|
3
|
+
export class AutoStore extends Store {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.dontObserveProperties = [
|
|
7
|
+
// Methods
|
|
8
|
+
"constructor",
|
|
9
|
+
"activate",
|
|
10
|
+
"update",
|
|
11
|
+
"propsUpdate",
|
|
12
|
+
"afterUpdate",
|
|
13
|
+
"dispose",
|
|
14
|
+
"setRedrawFunction",
|
|
15
|
+
"redraw",
|
|
16
|
+
"forceRedraw",
|
|
17
|
+
// Properties
|
|
18
|
+
"isDrawTime",
|
|
19
|
+
"dontOverrideMethods",
|
|
20
|
+
"redrawFunction"
|
|
21
|
+
];
|
|
22
|
+
this.injectProperties();
|
|
23
|
+
this.injectMethods();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Replace properties by getters and setters, inject redraw
|
|
27
|
+
*/
|
|
28
|
+
injectProperties() {
|
|
29
|
+
const properties = Reflect.ownKeys(this);
|
|
30
|
+
for (const property of properties) {
|
|
31
|
+
const isNotAuto = Reflect.getMetadata("reca:notAuto", this, property);
|
|
32
|
+
if (!this.dontObserveProperties.includes(property) && isNotAuto !== true) {
|
|
33
|
+
let propValue = Reflect.get(this, property);
|
|
34
|
+
Object.defineProperty(this, property, {
|
|
35
|
+
get: () => propValue,
|
|
36
|
+
set: (value) => {
|
|
37
|
+
propValue = value;
|
|
38
|
+
this.redraw();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wrap methods, inject redraw
|
|
46
|
+
*/
|
|
47
|
+
injectMethods() {
|
|
48
|
+
const methods = Reflect.ownKeys(Object.getPrototypeOf(this));
|
|
49
|
+
for (const method of methods) {
|
|
50
|
+
const isNotAuto = Reflect.getMetadata("reca:notAuto", this, method);
|
|
51
|
+
if (!this.dontObserveProperties.includes(method) || isNotAuto !== true) {
|
|
52
|
+
const methodFunction = Reflect.get(this, method);
|
|
53
|
+
const isNotRedraw = Reflect.getMetadata("reca:notRedraw", this, method);
|
|
54
|
+
Reflect.set(this, method, (...params) => {
|
|
55
|
+
if (isNotRedraw !== true) {
|
|
56
|
+
this.redraw(); // Before method because in method can be error, how stop flow
|
|
57
|
+
}
|
|
58
|
+
const maybePromise = methodFunction.apply(this, [...params]);
|
|
59
|
+
if (maybePromise instanceof Promise) {
|
|
60
|
+
return maybePromise
|
|
61
|
+
.then((data) => {
|
|
62
|
+
if (isNotRedraw !== true) {
|
|
63
|
+
this.redraw();
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
})
|
|
67
|
+
.catch((error) => {
|
|
68
|
+
if (isNotRedraw !== true) {
|
|
69
|
+
this.redraw();
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return maybePromise;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
78
80
|
//# sourceMappingURL=AutoStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoStore.js","sourceRoot":"","sources":["../../src/stores/AutoStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAO,SAAqC,SAAQ,KAAQ;IAqB9D;QACI,KAAK,EAAE,CAAC;QApBF,0BAAqB,GAAyB;YACpD,UAAU;YACV,aAAa;YACb,UAAU;YACV,QAAQ;YACR,aAAa;YACb,aAAa;YACb,SAAS;YACT,mBAAmB;YACnB,QAAQ;YACR,aAAa;YAEb,aAAa;YACb,YAAY;YACZ,qBAAqB;YACrB,gBAAgB;SAEnB,CAAC;QAIE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACO,gBAAgB;QACtB,MAAM,UAAU,GAAwB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE9D,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YAC/B,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"AutoStore.js","sourceRoot":"","sources":["../../src/stores/AutoStore.ts"],"names":[],"mappings":"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"}
|
package/dist/stores/Store.d.ts
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
export declare class Store<T extends object = object> {
|
|
2
|
-
/**
|
|
3
|
-
* Property for prevent cycle redraw if call method ot set props in AutoStore
|
|
4
|
-
* in view redraw time
|
|
5
|
-
*/
|
|
6
|
-
isDrawTime: boolean;
|
|
7
|
-
protected redrawFunction: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* Method for override in nested store.
|
|
10
|
-
* Run after first rendering component in DOM.
|
|
11
|
-
*
|
|
12
|
-
* @description
|
|
13
|
-
* Encapsulate:
|
|
14
|
-
* useEffect(() => {
|
|
15
|
-
* stateStore.activate(props);
|
|
16
|
-
*
|
|
17
|
-
* return () => stateStore.dispose(props);
|
|
18
|
-
* }, []);
|
|
19
|
-
*/
|
|
20
|
-
activate(props: T): void;
|
|
21
|
-
/**
|
|
22
|
-
* Method for override in nested store.
|
|
23
|
-
* Run before second and others time of rendering component in DOM.
|
|
24
|
-
*
|
|
25
|
-
* @description
|
|
26
|
-
* Encapsulate:
|
|
27
|
-
* if (!isInit) {
|
|
28
|
-
* stateStore.update(props);
|
|
29
|
-
* }
|
|
30
|
-
*/
|
|
31
|
-
update(props: T): void;
|
|
32
|
-
/**
|
|
33
|
-
* Method for override in nested store.
|
|
34
|
-
* Run only if props changed.
|
|
35
|
-
* Run before second and others time of rendering component in DOM.
|
|
36
|
-
*
|
|
37
|
-
* @description
|
|
38
|
-
* Encapsulate:
|
|
39
|
-
* useMemo(
|
|
40
|
-
* () => {
|
|
41
|
-
* stateStore.propsUpdate(props);
|
|
42
|
-
* },
|
|
43
|
-
* [props]
|
|
44
|
-
* );
|
|
45
|
-
*/
|
|
46
|
-
propsUpdate(props: T): void;
|
|
47
|
-
/**
|
|
48
|
-
* Method for override in nested store.
|
|
49
|
-
* Run after second and others time of rendering component in DOM.
|
|
50
|
-
*
|
|
51
|
-
* @description
|
|
52
|
-
* Encapsulate:
|
|
53
|
-
* useEffect(() => {
|
|
54
|
-
* if (!isInit) {
|
|
55
|
-
* stateStore.afterUpdate(props);
|
|
56
|
-
* }
|
|
57
|
-
* });
|
|
58
|
-
*/
|
|
59
|
-
afterUpdate(props: T): void;
|
|
60
|
-
/**
|
|
61
|
-
* Method for override in nested store.
|
|
62
|
-
* Run after second and others rendering component in DOM.
|
|
63
|
-
*
|
|
64
|
-
* @description
|
|
65
|
-
* Encapsulate:
|
|
66
|
-
* useEffect(() => {
|
|
67
|
-
* stateStore.activate(props);
|
|
68
|
-
*
|
|
69
|
-
* return () => stateStore.dispose(props);
|
|
70
|
-
* }, []);
|
|
71
|
-
*/
|
|
72
|
-
dispose(props: T): void;
|
|
73
|
-
setRedrawFunction(updateFunction: () => void): void;
|
|
74
|
-
/**
|
|
75
|
-
* Update view on next requestAnimationFrame
|
|
76
|
-
*/
|
|
77
|
-
redraw(): void;
|
|
78
|
-
/**
|
|
79
|
-
* Update view component immediately
|
|
80
|
-
*/
|
|
81
|
-
forceRedraw(): void;
|
|
82
|
-
}
|
|
1
|
+
export declare class Store<T extends object = object> {
|
|
2
|
+
/**
|
|
3
|
+
* Property for prevent cycle redraw if call method ot set props in AutoStore
|
|
4
|
+
* in view redraw time
|
|
5
|
+
*/
|
|
6
|
+
isDrawTime: boolean;
|
|
7
|
+
protected redrawFunction: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Method for override in nested store.
|
|
10
|
+
* Run after first rendering component in DOM.
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Encapsulate:
|
|
14
|
+
* useEffect(() => {
|
|
15
|
+
* stateStore.activate(props);
|
|
16
|
+
*
|
|
17
|
+
* return () => stateStore.dispose(props);
|
|
18
|
+
* }, []);
|
|
19
|
+
*/
|
|
20
|
+
activate(props: T): void;
|
|
21
|
+
/**
|
|
22
|
+
* Method for override in nested store.
|
|
23
|
+
* Run before second and others time of rendering component in DOM.
|
|
24
|
+
*
|
|
25
|
+
* @description
|
|
26
|
+
* Encapsulate:
|
|
27
|
+
* if (!isInit) {
|
|
28
|
+
* stateStore.update(props);
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
update(props: T): void;
|
|
32
|
+
/**
|
|
33
|
+
* Method for override in nested store.
|
|
34
|
+
* Run only if props changed.
|
|
35
|
+
* Run before second and others time of rendering component in DOM.
|
|
36
|
+
*
|
|
37
|
+
* @description
|
|
38
|
+
* Encapsulate:
|
|
39
|
+
* useMemo(
|
|
40
|
+
* () => {
|
|
41
|
+
* stateStore.propsUpdate(props);
|
|
42
|
+
* },
|
|
43
|
+
* [props]
|
|
44
|
+
* );
|
|
45
|
+
*/
|
|
46
|
+
propsUpdate(props: T): void;
|
|
47
|
+
/**
|
|
48
|
+
* Method for override in nested store.
|
|
49
|
+
* Run after second and others time of rendering component in DOM.
|
|
50
|
+
*
|
|
51
|
+
* @description
|
|
52
|
+
* Encapsulate:
|
|
53
|
+
* useEffect(() => {
|
|
54
|
+
* if (!isInit) {
|
|
55
|
+
* stateStore.afterUpdate(props);
|
|
56
|
+
* }
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
afterUpdate(props: T): void;
|
|
60
|
+
/**
|
|
61
|
+
* Method for override in nested store.
|
|
62
|
+
* Run after second and others rendering component in DOM.
|
|
63
|
+
*
|
|
64
|
+
* @description
|
|
65
|
+
* Encapsulate:
|
|
66
|
+
* useEffect(() => {
|
|
67
|
+
* stateStore.activate(props);
|
|
68
|
+
*
|
|
69
|
+
* return () => stateStore.dispose(props);
|
|
70
|
+
* }, []);
|
|
71
|
+
*/
|
|
72
|
+
dispose(props: T): void;
|
|
73
|
+
setRedrawFunction(updateFunction: () => void): void;
|
|
74
|
+
/**
|
|
75
|
+
* Update view on next requestAnimationFrame
|
|
76
|
+
*/
|
|
77
|
+
redraw(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Update view component immediately
|
|
80
|
+
*/
|
|
81
|
+
forceRedraw(): void;
|
|
82
|
+
}
|
package/dist/stores/Store.js
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { config } from "../config.js";
|
|
3
|
-
export class Store {
|
|
4
|
-
constructor() {
|
|
5
|
-
/**
|
|
6
|
-
* Property for prevent cycle redraw if call method ot set props in AutoStore
|
|
7
|
-
* in view redraw time
|
|
8
|
-
*/
|
|
9
|
-
this.isDrawTime = true;
|
|
10
|
-
this.redrawFunction = () => void 0;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Method for override in nested store.
|
|
14
|
-
* Run after first rendering component in DOM.
|
|
15
|
-
*
|
|
16
|
-
* @description
|
|
17
|
-
* Encapsulate:
|
|
18
|
-
* useEffect(() => {
|
|
19
|
-
* stateStore.activate(props);
|
|
20
|
-
*
|
|
21
|
-
* return () => stateStore.dispose(props);
|
|
22
|
-
* }, []);
|
|
23
|
-
*/
|
|
24
|
-
activate(props) {
|
|
25
|
-
// Override
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Method for override in nested store.
|
|
29
|
-
* Run before second and others time of rendering component in DOM.
|
|
30
|
-
*
|
|
31
|
-
* @description
|
|
32
|
-
* Encapsulate:
|
|
33
|
-
* if (!isInit) {
|
|
34
|
-
* stateStore.update(props);
|
|
35
|
-
* }
|
|
36
|
-
*/
|
|
37
|
-
update(props) {
|
|
38
|
-
// Override
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Method for override in nested store.
|
|
42
|
-
* Run only if props changed.
|
|
43
|
-
* Run before second and others time of rendering component in DOM.
|
|
44
|
-
*
|
|
45
|
-
* @description
|
|
46
|
-
* Encapsulate:
|
|
47
|
-
* useMemo(
|
|
48
|
-
* () => {
|
|
49
|
-
* stateStore.propsUpdate(props);
|
|
50
|
-
* },
|
|
51
|
-
* [props]
|
|
52
|
-
* );
|
|
53
|
-
*/
|
|
54
|
-
propsUpdate(props) {
|
|
55
|
-
// Override
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Method for override in nested store.
|
|
59
|
-
* Run after second and others time of rendering component in DOM.
|
|
60
|
-
*
|
|
61
|
-
* @description
|
|
62
|
-
* Encapsulate:
|
|
63
|
-
* useEffect(() => {
|
|
64
|
-
* if (!isInit) {
|
|
65
|
-
* stateStore.afterUpdate(props);
|
|
66
|
-
* }
|
|
67
|
-
* });
|
|
68
|
-
*/
|
|
69
|
-
afterUpdate(props) {
|
|
70
|
-
// Override
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Method for override in nested store.
|
|
74
|
-
* Run after second and others rendering component in DOM.
|
|
75
|
-
*
|
|
76
|
-
* @description
|
|
77
|
-
* Encapsulate:
|
|
78
|
-
* useEffect(() => {
|
|
79
|
-
* stateStore.activate(props);
|
|
80
|
-
*
|
|
81
|
-
* return () => stateStore.dispose(props);
|
|
82
|
-
* }, []);
|
|
83
|
-
*/
|
|
84
|
-
dispose(props) {
|
|
85
|
-
// Override
|
|
86
|
-
}
|
|
87
|
-
setRedrawFunction(updateFunction) {
|
|
88
|
-
this.redrawFunction = updateFunction;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Update view on next requestAnimationFrame
|
|
92
|
-
*/
|
|
93
|
-
redraw() {
|
|
94
|
-
if (this.isDrawTime) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (config.isBrowser) {
|
|
98
|
-
requestAnimationFrame(() => this.redrawFunction());
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// SSR don't use redraw, its for unit tests
|
|
102
|
-
this.redrawFunction();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Update view component immediately
|
|
107
|
-
*/
|
|
108
|
-
forceRedraw() {
|
|
109
|
-
this.redrawFunction();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { config } from "../config.js";
|
|
3
|
+
export class Store {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Property for prevent cycle redraw if call method ot set props in AutoStore
|
|
7
|
+
* in view redraw time
|
|
8
|
+
*/
|
|
9
|
+
this.isDrawTime = true;
|
|
10
|
+
this.redrawFunction = () => void 0;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Method for override in nested store.
|
|
14
|
+
* Run after first rendering component in DOM.
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Encapsulate:
|
|
18
|
+
* useEffect(() => {
|
|
19
|
+
* stateStore.activate(props);
|
|
20
|
+
*
|
|
21
|
+
* return () => stateStore.dispose(props);
|
|
22
|
+
* }, []);
|
|
23
|
+
*/
|
|
24
|
+
activate(props) {
|
|
25
|
+
// Override
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Method for override in nested store.
|
|
29
|
+
* Run before second and others time of rendering component in DOM.
|
|
30
|
+
*
|
|
31
|
+
* @description
|
|
32
|
+
* Encapsulate:
|
|
33
|
+
* if (!isInit) {
|
|
34
|
+
* stateStore.update(props);
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
update(props) {
|
|
38
|
+
// Override
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Method for override in nested store.
|
|
42
|
+
* Run only if props changed.
|
|
43
|
+
* Run before second and others time of rendering component in DOM.
|
|
44
|
+
*
|
|
45
|
+
* @description
|
|
46
|
+
* Encapsulate:
|
|
47
|
+
* useMemo(
|
|
48
|
+
* () => {
|
|
49
|
+
* stateStore.propsUpdate(props);
|
|
50
|
+
* },
|
|
51
|
+
* [props]
|
|
52
|
+
* );
|
|
53
|
+
*/
|
|
54
|
+
propsUpdate(props) {
|
|
55
|
+
// Override
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Method for override in nested store.
|
|
59
|
+
* Run after second and others time of rendering component in DOM.
|
|
60
|
+
*
|
|
61
|
+
* @description
|
|
62
|
+
* Encapsulate:
|
|
63
|
+
* useEffect(() => {
|
|
64
|
+
* if (!isInit) {
|
|
65
|
+
* stateStore.afterUpdate(props);
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
69
|
+
afterUpdate(props) {
|
|
70
|
+
// Override
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Method for override in nested store.
|
|
74
|
+
* Run after second and others rendering component in DOM.
|
|
75
|
+
*
|
|
76
|
+
* @description
|
|
77
|
+
* Encapsulate:
|
|
78
|
+
* useEffect(() => {
|
|
79
|
+
* stateStore.activate(props);
|
|
80
|
+
*
|
|
81
|
+
* return () => stateStore.dispose(props);
|
|
82
|
+
* }, []);
|
|
83
|
+
*/
|
|
84
|
+
dispose(props) {
|
|
85
|
+
// Override
|
|
86
|
+
}
|
|
87
|
+
setRedrawFunction(updateFunction) {
|
|
88
|
+
this.redrawFunction = updateFunction;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Update view on next requestAnimationFrame
|
|
92
|
+
*/
|
|
93
|
+
redraw() {
|
|
94
|
+
if (this.isDrawTime) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (config.isBrowser) {
|
|
98
|
+
requestAnimationFrame(() => this.redrawFunction());
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// SSR don't use redraw, its for unit tests
|
|
102
|
+
this.redrawFunction();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Update view component immediately
|
|
107
|
+
*/
|
|
108
|
+
forceRedraw() {
|
|
109
|
+
this.redrawFunction();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
112
|
//# sourceMappingURL=Store.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reca",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "ReCA - React Clean Architecture state manager",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"clean": "rimraf ./dist",
|
|
10
10
|
"cs:eslint": "eslint --fix -c .eslintrc.cjs --ext .tsx,.ts,.jsx,.js ./src/",
|
|
11
11
|
"clean:dist-tests": "rimraf ./dist/__fixtures__ && rimraf ./dist/__tests__",
|
|
12
|
-
"test": "
|
|
13
|
-
"test:watch": "
|
|
12
|
+
"test": "mocha --parallel src/__tests__/*.spec.tsx",
|
|
13
|
+
"test:watch": "mocha --parallel --watch --watch-files src/**/*.ts,src/**/*.tsx src/__tests__/*.spec.tsx",
|
|
14
14
|
"test:module": "node ./dist/index.js",
|
|
15
15
|
"prepublishOnly": "npm run test && npm run build && npm run release",
|
|
16
16
|
"release": "standard-version",
|
|
@@ -28,30 +28,31 @@
|
|
|
28
28
|
"author": "LabEG",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"first-di": "^0.
|
|
31
|
+
"first-di": "^1.0.5"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"react": ">=16.0.0"
|
|
34
|
+
"react": ">=16.0.0",
|
|
35
|
+
"reflect-metadata": ">=0.1.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@commitlint/
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/react": "^18.0.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"husky": "^8.0.
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"react": "^18.
|
|
51
|
-
"react-dom": "^18.
|
|
38
|
+
"@commitlint/cli": "^17.3.0",
|
|
39
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
40
|
+
"@labeg/code-style": "^2.0.59",
|
|
41
|
+
"@testing-library/react": "^13.4.0",
|
|
42
|
+
"@types/chai": "^4.3.4",
|
|
43
|
+
"@types/mocha": "^10.0.0",
|
|
44
|
+
"@types/react": "^18.0.25",
|
|
45
|
+
"chai": "^4.3.7",
|
|
46
|
+
"global-jsdom": "^8.6.0",
|
|
47
|
+
"husky": "^8.0.2",
|
|
48
|
+
"jsdom": "^20.0.3",
|
|
49
|
+
"lint-staged": "^13.0.3",
|
|
50
|
+
"mocha": "^10.1.0",
|
|
51
|
+
"react": "^18.2.0",
|
|
52
|
+
"react-dom": "^18.2.0",
|
|
53
|
+
"reflect-metadata": "^0.1.13",
|
|
52
54
|
"rimraf": "^3.0.2",
|
|
53
55
|
"standard-version": "^9.5.0",
|
|
54
|
-
"
|
|
55
|
-
"typescript": "^4.6.4"
|
|
56
|
+
"typescript": "^4.9.3"
|
|
56
57
|
}
|
|
57
58
|
}
|