@ws-ui/shared 0.0.1 → 0.0.2
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/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/use-enhanced-state/setupDevTools.d.ts +27 -0
- package/dist/hooks/use-enhanced-state/useEnhancedState.d.ts +17 -0
- package/dist/hooks/useIdentity.d.ts +5 -0
- package/dist/hooks/useStateObject.d.ts +11 -0
- package/dist/index.cjs.js +40 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +6810 -3101
- package/dist/index.es.js.map +1 -1
- package/package.json +6 -2
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DevToolsMessageType = 'DISPATCH' | string;
|
|
2
|
+
export type DevToolsMessagePayload = {
|
|
3
|
+
type?: string;
|
|
4
|
+
state?: any;
|
|
5
|
+
};
|
|
6
|
+
export type DevToolsMessage = {
|
|
7
|
+
type?: DevToolsMessageType;
|
|
8
|
+
payload?: DevToolsMessagePayload;
|
|
9
|
+
};
|
|
10
|
+
export type DevTools = {
|
|
11
|
+
init: (state: any) => void;
|
|
12
|
+
connect: (options: {
|
|
13
|
+
name: string;
|
|
14
|
+
trace: boolean;
|
|
15
|
+
}) => any;
|
|
16
|
+
subscribe: (message: DevToolsMessage) => any;
|
|
17
|
+
send: (action: {
|
|
18
|
+
type: string;
|
|
19
|
+
state?: any;
|
|
20
|
+
}, newState: any) => any;
|
|
21
|
+
unsubscribe: () => any;
|
|
22
|
+
dispatch: (action: {
|
|
23
|
+
type: string;
|
|
24
|
+
}) => any;
|
|
25
|
+
disconnect: () => any;
|
|
26
|
+
};
|
|
27
|
+
export declare const devtools: DevTools | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Draft } from '@reduxjs/toolkit';
|
|
2
|
+
export type EnhancedStateController<T> = {
|
|
3
|
+
[key: string]: (state: Draft<T>, payload: any) => void;
|
|
4
|
+
};
|
|
5
|
+
export type EnhancedStateDispatch<T extends Record<string, (state: any, payload: any) => void>> = {
|
|
6
|
+
[Key in keyof T]: Parameters<T[Key]>['1'] extends undefined ? () => EnhancedStateDispatch<T> : (payload: Parameters<T[Key]>['1']) => EnhancedStateDispatch<T>;
|
|
7
|
+
};
|
|
8
|
+
export type EnhanceFunction = <T, K extends {
|
|
9
|
+
[key: string]: (state: Draft<T>, payload: any) => void;
|
|
10
|
+
}>(state: T, controller: K, store_name?: string) => {
|
|
11
|
+
state: T;
|
|
12
|
+
dispatch: {
|
|
13
|
+
[Property in keyof typeof controller]: Parameters<(typeof controller)[Property]>['1'] extends undefined ? () => EnhancedStateDispatch<K> : (payload: Parameters<(typeof controller)[Property]>['1']) => EnhancedStateDispatch<K>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const useEnhanceState: EnhanceFunction;
|
|
17
|
+
export default useEnhanceState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function useStateObject<T extends object>(initialState: T): {
|
|
3
|
+
state: T;
|
|
4
|
+
actions: InternalActions<T> & {
|
|
5
|
+
set: React.Dispatch<React.SetStateAction<T>>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
type InternalActions<T> = {
|
|
9
|
+
[Property in keyof T as `set${Capitalize<Property & string>}`]: (value: T[Property]) => void;
|
|
10
|
+
};
|
|
11
|
+
export {};
|