fox-mini-x 1.0.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.
@@ -0,0 +1,122 @@
1
+ interface ActionPayload {
2
+ type: string;
3
+ payload?: unknown;
4
+ }
5
+
6
+ type MutationHandler<S = any, P = any> = (state: S, payload?: P) => void;
7
+ type ActionHandler<S = any, P = any, R = any> = (
8
+ context: ActionContext<S>,
9
+ payload?: P
10
+ ) => R | Promise<R>;
11
+ type GetterHandler<S = any, R = any> = (
12
+ state: S,
13
+ getters: Record<string, any>,
14
+ rootState: any,
15
+ rootGetters: Record<string, any>
16
+ ) => R;
17
+
18
+ interface ActionSubscriberObject {
19
+ before?: (action: ActionPayload, state: any) => void;
20
+ after?: (action: ActionPayload, state: any) => void;
21
+ error?: (action: ActionPayload, state: any, error: unknown) => void;
22
+ }
23
+
24
+ type ActionSubscriber =
25
+ | ((action: ActionPayload, state: any) => void)
26
+ | ActionSubscriberObject;
27
+
28
+ interface ModuleOptions<S = any> {
29
+ namespaced?: boolean;
30
+ state?: S | (() => S);
31
+ getters?: Record<string, GetterHandler<S, any>>;
32
+ mutations?: Record<string, MutationHandler<S, any>>;
33
+ actions?:
34
+ | Record<string, ActionHandler<S, any, any>>
35
+ | Record<
36
+ string,
37
+ | ActionHandler<S, any, any>
38
+ | {
39
+ root?: boolean;
40
+ handler: ActionHandler<S, any, any>;
41
+ }
42
+ >;
43
+ modules?: Record<string, ModuleOptions<any>>;
44
+ }
45
+
46
+ interface StoreOptions<S = any> extends ModuleOptions<S> {
47
+ strict?: boolean;
48
+ plugins?: Array<(store: Store<S>) => void>;
49
+ }
50
+
51
+ interface ActionContext<S = any> {
52
+ dispatch: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => Promise<any>;
53
+ commit: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => void;
54
+ getters: Record<string, any>;
55
+ state: S;
56
+ rootState: any;
57
+ rootGetters: Record<string, any>;
58
+ }
59
+
60
+ interface Store<S = any> {
61
+ readonly state: S;
62
+ getters: Record<string, any>;
63
+ strict: boolean;
64
+ commit: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => void;
65
+ dispatch: (type: string | { type: string; [key: string]: any }, payload?: any) => Promise<any>;
66
+ subscribe: (subscriber: (mutation: ActionPayload, state: S) => void) => () => void;
67
+ subscribeAction: (subscriber: ActionSubscriber) => () => void;
68
+ replaceState: (newState: S) => void;
69
+ registerModule: (path: string | string[], module: ModuleOptions<any>, options?: { preserveState?: boolean }) => void;
70
+ unregisterModule: (path: string | string[]) => void;
71
+ hasModule: (path: string | string[]) => boolean;
72
+ hotUpdate: (newOptions: Partial<StoreOptions<S>>) => void;
73
+ }
74
+
75
+ declare function createStore<S = any>(options?: StoreOptions<S>): Store<S>;
76
+
77
+ declare function createLogger(options?: {
78
+ logger?: Pick<Console, "log" | "error">;
79
+ logActions?: boolean;
80
+ logMutations?: boolean;
81
+ }): (store: Store<any>) => void;
82
+
83
+ declare function mapState(
84
+ namespace: string,
85
+ mappings: string[] | Record<string, string | ((state: any) => any)>
86
+ ): Record<string, (...args: any[]) => any>;
87
+ declare function mapState(
88
+ mappings: string[] | Record<string, string | ((state: any) => any)>
89
+ ): Record<string, (...args: any[]) => any>;
90
+
91
+ declare function mapGetters(
92
+ namespace: string,
93
+ mappings: string[] | Record<string, string>
94
+ ): Record<string, (...args: any[]) => any>;
95
+ declare function mapGetters(
96
+ mappings: string[] | Record<string, string>
97
+ ): Record<string, (...args: any[]) => any>;
98
+
99
+ declare function mapMutations(
100
+ namespace: string,
101
+ mappings: string[] | Record<string, string>
102
+ ): Record<string, (...args: any[]) => any>;
103
+ declare function mapMutations(
104
+ mappings: string[] | Record<string, string>
105
+ ): Record<string, (...args: any[]) => any>;
106
+
107
+ declare function mapActions(
108
+ namespace: string,
109
+ mappings: string[] | Record<string, string>
110
+ ): Record<string, (...args: any[]) => any>;
111
+ declare function mapActions(
112
+ mappings: string[] | Record<string, string>
113
+ ): Record<string, (...args: any[]) => any>;
114
+
115
+ declare function createNamespacedHelpers(namespace: string): {
116
+ mapState: typeof mapState;
117
+ mapGetters: typeof mapGetters;
118
+ mapMutations: typeof mapMutations;
119
+ mapActions: typeof mapActions;
120
+ };
121
+
122
+ export { type ActionContext, type ActionHandler, type ActionPayload, type ActionSubscriber, type ActionSubscriberObject, type GetterHandler, type ModuleOptions, type MutationHandler, type Store, type StoreOptions, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState };
@@ -0,0 +1,122 @@
1
+ interface ActionPayload {
2
+ type: string;
3
+ payload?: unknown;
4
+ }
5
+
6
+ type MutationHandler<S = any, P = any> = (state: S, payload?: P) => void;
7
+ type ActionHandler<S = any, P = any, R = any> = (
8
+ context: ActionContext<S>,
9
+ payload?: P
10
+ ) => R | Promise<R>;
11
+ type GetterHandler<S = any, R = any> = (
12
+ state: S,
13
+ getters: Record<string, any>,
14
+ rootState: any,
15
+ rootGetters: Record<string, any>
16
+ ) => R;
17
+
18
+ interface ActionSubscriberObject {
19
+ before?: (action: ActionPayload, state: any) => void;
20
+ after?: (action: ActionPayload, state: any) => void;
21
+ error?: (action: ActionPayload, state: any, error: unknown) => void;
22
+ }
23
+
24
+ type ActionSubscriber =
25
+ | ((action: ActionPayload, state: any) => void)
26
+ | ActionSubscriberObject;
27
+
28
+ interface ModuleOptions<S = any> {
29
+ namespaced?: boolean;
30
+ state?: S | (() => S);
31
+ getters?: Record<string, GetterHandler<S, any>>;
32
+ mutations?: Record<string, MutationHandler<S, any>>;
33
+ actions?:
34
+ | Record<string, ActionHandler<S, any, any>>
35
+ | Record<
36
+ string,
37
+ | ActionHandler<S, any, any>
38
+ | {
39
+ root?: boolean;
40
+ handler: ActionHandler<S, any, any>;
41
+ }
42
+ >;
43
+ modules?: Record<string, ModuleOptions<any>>;
44
+ }
45
+
46
+ interface StoreOptions<S = any> extends ModuleOptions<S> {
47
+ strict?: boolean;
48
+ plugins?: Array<(store: Store<S>) => void>;
49
+ }
50
+
51
+ interface ActionContext<S = any> {
52
+ dispatch: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => Promise<any>;
53
+ commit: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => void;
54
+ getters: Record<string, any>;
55
+ state: S;
56
+ rootState: any;
57
+ rootGetters: Record<string, any>;
58
+ }
59
+
60
+ interface Store<S = any> {
61
+ readonly state: S;
62
+ getters: Record<string, any>;
63
+ strict: boolean;
64
+ commit: (type: string | { type: string; [key: string]: any }, payload?: any, options?: { root?: boolean }) => void;
65
+ dispatch: (type: string | { type: string; [key: string]: any }, payload?: any) => Promise<any>;
66
+ subscribe: (subscriber: (mutation: ActionPayload, state: S) => void) => () => void;
67
+ subscribeAction: (subscriber: ActionSubscriber) => () => void;
68
+ replaceState: (newState: S) => void;
69
+ registerModule: (path: string | string[], module: ModuleOptions<any>, options?: { preserveState?: boolean }) => void;
70
+ unregisterModule: (path: string | string[]) => void;
71
+ hasModule: (path: string | string[]) => boolean;
72
+ hotUpdate: (newOptions: Partial<StoreOptions<S>>) => void;
73
+ }
74
+
75
+ declare function createStore<S = any>(options?: StoreOptions<S>): Store<S>;
76
+
77
+ declare function createLogger(options?: {
78
+ logger?: Pick<Console, "log" | "error">;
79
+ logActions?: boolean;
80
+ logMutations?: boolean;
81
+ }): (store: Store<any>) => void;
82
+
83
+ declare function mapState(
84
+ namespace: string,
85
+ mappings: string[] | Record<string, string | ((state: any) => any)>
86
+ ): Record<string, (...args: any[]) => any>;
87
+ declare function mapState(
88
+ mappings: string[] | Record<string, string | ((state: any) => any)>
89
+ ): Record<string, (...args: any[]) => any>;
90
+
91
+ declare function mapGetters(
92
+ namespace: string,
93
+ mappings: string[] | Record<string, string>
94
+ ): Record<string, (...args: any[]) => any>;
95
+ declare function mapGetters(
96
+ mappings: string[] | Record<string, string>
97
+ ): Record<string, (...args: any[]) => any>;
98
+
99
+ declare function mapMutations(
100
+ namespace: string,
101
+ mappings: string[] | Record<string, string>
102
+ ): Record<string, (...args: any[]) => any>;
103
+ declare function mapMutations(
104
+ mappings: string[] | Record<string, string>
105
+ ): Record<string, (...args: any[]) => any>;
106
+
107
+ declare function mapActions(
108
+ namespace: string,
109
+ mappings: string[] | Record<string, string>
110
+ ): Record<string, (...args: any[]) => any>;
111
+ declare function mapActions(
112
+ mappings: string[] | Record<string, string>
113
+ ): Record<string, (...args: any[]) => any>;
114
+
115
+ declare function createNamespacedHelpers(namespace: string): {
116
+ mapState: typeof mapState;
117
+ mapGetters: typeof mapGetters;
118
+ mapMutations: typeof mapMutations;
119
+ mapActions: typeof mapActions;
120
+ };
121
+
122
+ export { type ActionContext, type ActionHandler, type ActionPayload, type ActionSubscriber, type ActionSubscriberObject, type GetterHandler, type ModuleOptions, type MutationHandler, type Store, type StoreOptions, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState };