@zhin.js/client 1.0.3 → 1.0.5
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 +117 -3
- package/{src → client}/index.ts +0 -1
- package/{src → client}/store/index.ts +22 -1
- package/client/store/reducers/config.ts +135 -0
- package/{src → client}/store/reducers/index.ts +4 -1
- package/client/websocket/hooks.ts +280 -0
- package/client/websocket/index.ts +48 -0
- package/client/websocket/instance.ts +46 -0
- package/client/websocket/manager.ts +412 -0
- package/client/websocket/messageHandler.ts +166 -0
- package/client/websocket/types.ts +208 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -0
- package/dist/router/index.d.ts +25 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +49 -0
- package/dist/router/index.js.map +1 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +67 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/reducers/config.d.ts +54 -0
- package/dist/store/reducers/config.d.ts.map +1 -0
- package/dist/store/reducers/config.js +78 -0
- package/dist/store/reducers/config.js.map +1 -0
- package/dist/store/reducers/index.d.ts +13 -0
- package/dist/store/reducers/index.d.ts.map +1 -0
- package/dist/store/reducers/index.js +11 -0
- package/dist/store/reducers/index.js.map +1 -0
- package/dist/store/reducers/route.d.ts +37 -0
- package/dist/store/reducers/route.d.ts.map +1 -0
- package/dist/store/reducers/route.js +85 -0
- package/dist/store/reducers/route.js.map +1 -0
- package/dist/store/reducers/script.d.ts +17 -0
- package/dist/store/reducers/script.d.ts.map +1 -0
- package/dist/store/reducers/script.js +74 -0
- package/dist/store/reducers/script.js.map +1 -0
- package/dist/store/reducers/ui.d.ts +14 -0
- package/dist/store/reducers/ui.d.ts.map +1 -0
- package/dist/store/reducers/ui.js +23 -0
- package/dist/store/reducers/ui.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/websocket/hooks.d.ts +55 -0
- package/dist/websocket/hooks.d.ts.map +1 -0
- package/dist/websocket/hooks.js +225 -0
- package/dist/websocket/hooks.js.map +1 -0
- package/dist/websocket/index.d.ts +13 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +31 -0
- package/dist/websocket/index.js.map +1 -0
- package/dist/websocket/instance.d.ts +18 -0
- package/dist/websocket/instance.d.ts.map +1 -0
- package/dist/websocket/instance.js +39 -0
- package/dist/websocket/instance.js.map +1 -0
- package/dist/websocket/manager.d.ts +110 -0
- package/dist/websocket/manager.d.ts.map +1 -0
- package/dist/websocket/manager.js +341 -0
- package/dist/websocket/manager.js.map +1 -0
- package/dist/websocket/messageHandler.d.ts +48 -0
- package/dist/websocket/messageHandler.d.ts.map +1 -0
- package/dist/websocket/messageHandler.js +140 -0
- package/dist/websocket/messageHandler.js.map +1 -0
- package/dist/websocket/types.d.ts +125 -0
- package/dist/websocket/types.d.ts.map +1 -0
- package/dist/websocket/types.js +43 -0
- package/dist/websocket/types.js.map +1 -0
- package/package.json +8 -18
- package/app/index.html +0 -13
- package/app/postcss.config.js +0 -5
- package/app/src/components/ThemeToggle.tsx +0 -21
- package/app/src/hooks/useTheme.ts +0 -17
- package/app/src/layouts/dashboard.tsx +0 -259
- package/app/src/main.tsx +0 -121
- package/app/src/pages/dashboard-bots.tsx +0 -198
- package/app/src/pages/dashboard-home.tsx +0 -301
- package/app/src/pages/dashboard-logs.tsx +0 -298
- package/app/src/pages/dashboard-plugin-detail.tsx +0 -349
- package/app/src/pages/dashboard-plugins.tsx +0 -166
- package/app/src/style.css +0 -1105
- package/app/src/theme/index.ts +0 -92
- package/app/tailwind.config.js +0 -70
- package/app/tsconfig.json +0 -16
- package/src/websocket/index.ts +0 -193
- package/src/websocket/useWebSocket.ts +0 -42
- /package/{src → client}/router/index.tsx +0 -0
- /package/{src → client}/store/reducers/route.ts +0 -0
- /package/{src → client}/store/reducers/script.ts +0 -0
- /package/{src → client}/store/reducers/ui.ts +0 -0
- /package/{src → client}/types.ts +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket 相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// 基础消息类型
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
export interface BaseMessage {
|
|
10
|
+
type: string
|
|
11
|
+
timestamp?: number
|
|
12
|
+
requestId?: number
|
|
13
|
+
error?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// 脚本管理消息类型
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
export interface ScriptSyncMessage extends BaseMessage {
|
|
21
|
+
type: 'sync'
|
|
22
|
+
data: {
|
|
23
|
+
key: 'entries'
|
|
24
|
+
value: string[]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ScriptAddMessage extends BaseMessage {
|
|
29
|
+
type: 'add'
|
|
30
|
+
data: {
|
|
31
|
+
key: 'entries'
|
|
32
|
+
value: string
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ScriptDeleteMessage extends BaseMessage {
|
|
37
|
+
type: 'delete'
|
|
38
|
+
data: {
|
|
39
|
+
key: 'entries'
|
|
40
|
+
value: string
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// 配置管理消息类型
|
|
46
|
+
// ============================================================================
|
|
47
|
+
|
|
48
|
+
export interface ConfigGetMessage extends BaseMessage {
|
|
49
|
+
type: 'config:get'
|
|
50
|
+
pluginName: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ConfigSetMessage extends BaseMessage {
|
|
54
|
+
type: 'config:set'
|
|
55
|
+
pluginName: string
|
|
56
|
+
data: any
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ConfigUpdatedMessage extends BaseMessage {
|
|
60
|
+
type: 'config:updated'
|
|
61
|
+
pluginName: string
|
|
62
|
+
data: any
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ConfigBatchMessage extends BaseMessage {
|
|
66
|
+
type: 'config:batch'
|
|
67
|
+
data: Record<string, any>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ConfigErrorMessage extends BaseMessage {
|
|
71
|
+
type: 'config:error'
|
|
72
|
+
pluginName: string
|
|
73
|
+
error: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface SchemaGetMessage extends BaseMessage {
|
|
77
|
+
type: 'schema:get'
|
|
78
|
+
pluginName: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface SchemaUpdatedMessage extends BaseMessage {
|
|
82
|
+
type: 'schema:updated'
|
|
83
|
+
pluginName: string
|
|
84
|
+
data: any
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface SchemaBatchMessage extends BaseMessage {
|
|
88
|
+
type: 'schema:batch'
|
|
89
|
+
data: Record<string, any>
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// 系统消息类型
|
|
94
|
+
// ============================================================================
|
|
95
|
+
|
|
96
|
+
export interface InitDataMessage extends BaseMessage {
|
|
97
|
+
type: 'init-data'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface DataUpdateMessage extends BaseMessage {
|
|
101
|
+
type: 'data-update'
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// 联合类型
|
|
106
|
+
// ============================================================================
|
|
107
|
+
|
|
108
|
+
export type WebSocketMessage =
|
|
109
|
+
| ScriptSyncMessage
|
|
110
|
+
| ScriptAddMessage
|
|
111
|
+
| ScriptDeleteMessage
|
|
112
|
+
| ConfigGetMessage
|
|
113
|
+
| ConfigSetMessage
|
|
114
|
+
| ConfigUpdatedMessage
|
|
115
|
+
| ConfigBatchMessage
|
|
116
|
+
| ConfigErrorMessage
|
|
117
|
+
| SchemaGetMessage
|
|
118
|
+
| SchemaUpdatedMessage
|
|
119
|
+
| SchemaBatchMessage
|
|
120
|
+
| InitDataMessage
|
|
121
|
+
| DataUpdateMessage
|
|
122
|
+
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// 配置选项类型
|
|
125
|
+
// ============================================================================
|
|
126
|
+
|
|
127
|
+
export interface WebSocketConfig {
|
|
128
|
+
/** WebSocket 服务器 URL */
|
|
129
|
+
url?: string
|
|
130
|
+
/** 重连间隔时间(毫秒) */
|
|
131
|
+
reconnectInterval?: number
|
|
132
|
+
/** 最大重连尝试次数 */
|
|
133
|
+
maxReconnectAttempts?: number
|
|
134
|
+
/** 请求超时时间(毫秒) */
|
|
135
|
+
requestTimeout?: number
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface WebSocketCallbacks {
|
|
139
|
+
/** 连接建立回调 */
|
|
140
|
+
onConnect?: () => void
|
|
141
|
+
/** 连接断开回调 */
|
|
142
|
+
onDisconnect?: () => void
|
|
143
|
+
/** 连接错误回调 */
|
|
144
|
+
onError?: (error: Event) => void
|
|
145
|
+
/** 消息接收回调 */
|
|
146
|
+
onMessage?: (message: WebSocketMessage) => void
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// Hook 配置类型
|
|
151
|
+
// ============================================================================
|
|
152
|
+
|
|
153
|
+
export interface UseConfigOptions {
|
|
154
|
+
/** 是否自动加载配置 */
|
|
155
|
+
autoLoad?: boolean
|
|
156
|
+
/** 是否自动加载 Schema */
|
|
157
|
+
autoLoadSchema?: boolean
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface UseWebSocketOptions {
|
|
161
|
+
/** 是否自动连接 */
|
|
162
|
+
autoConnect?: boolean
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ============================================================================
|
|
166
|
+
// 连接状态枚举
|
|
167
|
+
// ============================================================================
|
|
168
|
+
|
|
169
|
+
export enum ConnectionState {
|
|
170
|
+
DISCONNECTED = 'disconnected',
|
|
171
|
+
CONNECTING = 'connecting',
|
|
172
|
+
CONNECTED = 'connected',
|
|
173
|
+
RECONNECTING = 'reconnecting',
|
|
174
|
+
ERROR = 'error'
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ============================================================================
|
|
178
|
+
// 错误类型
|
|
179
|
+
// ============================================================================
|
|
180
|
+
|
|
181
|
+
export class WebSocketError extends Error {
|
|
182
|
+
constructor(
|
|
183
|
+
message: string,
|
|
184
|
+
public code: string,
|
|
185
|
+
public originalError?: Error
|
|
186
|
+
) {
|
|
187
|
+
super(message)
|
|
188
|
+
this.name = 'WebSocketError'
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export class RequestTimeoutError extends WebSocketError {
|
|
193
|
+
constructor(requestId: number) {
|
|
194
|
+
super(`Request ${requestId} timed out`, 'REQUEST_TIMEOUT')
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export class ConnectionError extends WebSocketError {
|
|
199
|
+
constructor(message: string, originalError?: Error) {
|
|
200
|
+
super(message, 'CONNECTION_ERROR', originalError)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export class MessageError extends WebSocketError {
|
|
205
|
+
constructor(message: string, originalError?: Error) {
|
|
206
|
+
super(message, 'MESSAGE_ERROR', originalError)
|
|
207
|
+
}
|
|
208
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ClassValue } from 'clsx';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './store';
|
|
4
|
+
export * from './router';
|
|
5
|
+
export * as Icons from 'lucide-react';
|
|
6
|
+
export * from './websocket';
|
|
7
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,cAAc,SAAS,CAAA;AAGvB,cAAc,SAAS,CAAA;AAGvB,cAAc,UAAU,CAAA;AACxB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,cAAc,aAAa,CAAA;AAE3B,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,QAAQ;AACR,cAAc,SAAS,CAAA;AAEvB,cAAc;AACd,cAAc,SAAS,CAAA;AAEvB,SAAS;AACT,cAAc,UAAU,CAAA;AACxB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,YAAY;AACZ,cAAc,aAAa,CAAA;AAE3B,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RouteMenuItem } from '../store';
|
|
2
|
+
export { useOutlet, Outlet, Link, useNavigate, useParams } from 'react-router';
|
|
3
|
+
export declare const addPage: (route: RouteMenuItem) => {
|
|
4
|
+
payload: RouteMenuItem;
|
|
5
|
+
type: "route/addRoute";
|
|
6
|
+
};
|
|
7
|
+
export declare const removePage: (path: string) => {
|
|
8
|
+
payload: string;
|
|
9
|
+
type: "route/removeRoute";
|
|
10
|
+
};
|
|
11
|
+
export declare const updatePage: (path: string, route: RouteMenuItem) => {
|
|
12
|
+
payload: {
|
|
13
|
+
path: string;
|
|
14
|
+
updates: Partial<RouteMenuItem>;
|
|
15
|
+
};
|
|
16
|
+
type: "route/updateRoute";
|
|
17
|
+
};
|
|
18
|
+
export declare const getPage: (path: string) => RouteMenuItem | undefined;
|
|
19
|
+
export declare const getAllPages: () => RouteMenuItem[];
|
|
20
|
+
export declare const clearPages: () => {
|
|
21
|
+
payload: undefined;
|
|
22
|
+
type: "route/clearRoutes";
|
|
23
|
+
};
|
|
24
|
+
export declare function DynamicRouter(): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../client/router/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA0D,aAAa,EAAe,MAAM,UAAU,CAAA;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAK9E,eAAO,MAAM,OAAO,GAAI,OAAO,aAAa;;;CAAoC,CAAA;AAChF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM;;;CAAsC,CAAA;AAC7E,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,OAAO,aAAa;;;;;;CAG1D,CAAA;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,8BAAqE,CAAA;AACzG,eAAO,MAAM,WAAW,uBAAsC,CAAA;AAC9D,eAAO,MAAM,UAAU;;;CAAsC,CAAA;AAG7D,wBAAgB,aAAa,4CAmC5B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { createBrowserRouter, RouterProvider as ReactRouterProvider, Outlet } from 'react-router';
|
|
4
|
+
import { store, addRoute, removeRoute, updateRoute, clearRoutes, useSelector } from '../store';
|
|
5
|
+
export { useOutlet, Outlet, Link, useNavigate, useParams } from 'react-router';
|
|
6
|
+
export const addPage = (route) => store.dispatch(addRoute(route));
|
|
7
|
+
export const removePage = (path) => store.dispatch(removeRoute(path));
|
|
8
|
+
export const updatePage = (path, route) => store.dispatch(updateRoute({
|
|
9
|
+
path,
|
|
10
|
+
updates: route
|
|
11
|
+
}));
|
|
12
|
+
export const getPage = (path) => store.getState().route.routes.find(route => route.path === path);
|
|
13
|
+
export const getAllPages = () => store.getState().route.routes;
|
|
14
|
+
export const clearPages = () => store.dispatch(clearRoutes());
|
|
15
|
+
// 动态路由组件(从 Redux store 读取)
|
|
16
|
+
export function DynamicRouter() {
|
|
17
|
+
const storeRoutes = useSelector((state) => state.route.routes);
|
|
18
|
+
console.log(storeRoutes);
|
|
19
|
+
const router = useMemo(() => {
|
|
20
|
+
// 递归转换路由(支持多层嵌套)
|
|
21
|
+
const convertRoute = (route) => {
|
|
22
|
+
const routeObj = {
|
|
23
|
+
path: route.path,
|
|
24
|
+
element: route.element,
|
|
25
|
+
Component: route.Component,
|
|
26
|
+
};
|
|
27
|
+
// 递归处理子路由
|
|
28
|
+
if (route.children && route.children.length > 0) {
|
|
29
|
+
routeObj.children = route.children.map((child) => convertRoute(child));
|
|
30
|
+
}
|
|
31
|
+
return routeObj;
|
|
32
|
+
};
|
|
33
|
+
const routeObjects = storeRoutes.map(convertRoute);
|
|
34
|
+
const defaultRoutes = [
|
|
35
|
+
{
|
|
36
|
+
path: '/',
|
|
37
|
+
element: _jsx(Outlet, {}),
|
|
38
|
+
children: routeObjects,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: '*',
|
|
42
|
+
element: _jsx("div", { children: "404 - Page Not Found" }),
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
return createBrowserRouter(defaultRoutes);
|
|
46
|
+
}, [storeRoutes]);
|
|
47
|
+
return _jsx(ReactRouterProvider, { router: router });
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../client/router/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,cAAc,IAAI,mBAAmB,EAAe,MAAM,EAAC,MAAM,cAAc,CAAA;AAC7G,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAiB,WAAW,EAAE,MAAM,UAAU,CAAA;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAK9E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC3F,IAAI;IACJ,OAAO,EAAE,KAAK;CACf,CAAC,CAAC,CAAA;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;AACzG,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK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,CAAA;IAEjB,OAAO,KAAC,mBAAmB,IAAC,MAAM,EAAE,MAAM,GAAI,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Reducer, Action } from '@reduxjs/toolkit';
|
|
2
|
+
import { Reducers } from './reducers';
|
|
3
|
+
import { TypedUseSelectorHook } from 'react-redux';
|
|
4
|
+
export declare const store: import("@reduxjs/toolkit").EnhancedStore<Reducers, import("@reduxjs/toolkit").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("@reduxjs/toolkit").StoreEnhancer<{
|
|
5
|
+
dispatch: import("@reduxjs/toolkit").ThunkDispatch<Reducers, undefined, import("@reduxjs/toolkit").UnknownAction>;
|
|
6
|
+
}>, import("@reduxjs/toolkit").StoreEnhancer]>>;
|
|
7
|
+
export declare const persistor: import("redux-persist").Persistor;
|
|
8
|
+
export declare function addReducer<T, A extends Action>(name: keyof Reducers, reducer: Reducer<T, A>): void;
|
|
9
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
10
|
+
export type AppDispatch = typeof store.dispatch;
|
|
11
|
+
export declare const useDispatch: () => AppDispatch;
|
|
12
|
+
export declare const useSelector: TypedUseSelectorHook<RootState>;
|
|
13
|
+
export { toggleSidebar, setSidebarOpen, setActiveMenu } from './reducers/ui';
|
|
14
|
+
export { addRoute, removeRoute, updateRoute, setRoutes, clearRoutes } from './reducers/route';
|
|
15
|
+
export { syncEntries, addEntry, removeEntry, loadScript, loadScripts, unloadScript } from './reducers/script';
|
|
16
|
+
export { setConnected, setLoading, setError, updateConfig, updateSchema, updateConfigs, updateSchemas, removeConfig, clearConfigs, selectConfig, selectSchema, selectConfigLoading, selectConfigError, selectConfigConnected, selectAllConfigs, selectAllSchemas } from './reducers/config';
|
|
17
|
+
export type { RouteMenuItem } from './reducers/route';
|
|
18
|
+
export type { ConfigMessage } from './reducers/config';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { configureStore, combineReducers } from '@reduxjs/toolkit';
|
|
2
|
+
import { FLUSH, PAUSE, PERSIST, persistReducer, persistStore, PURGE, REGISTER, REHYDRATE, createTransform, } from 'redux-persist';
|
|
3
|
+
import storage from 'redux-persist/es/storage';
|
|
4
|
+
import { reducers } from './reducers';
|
|
5
|
+
import { useDispatch as useReduxDispatch, useSelector as useReduxSelector } from 'react-redux';
|
|
6
|
+
// 创建 transform 过滤不可序列化的字段
|
|
7
|
+
const routeTransform = createTransform((inboundState) => {
|
|
8
|
+
const { routes, ...rest } = inboundState;
|
|
9
|
+
return rest;
|
|
10
|
+
}, (outboundState) => {
|
|
11
|
+
return { ...outboundState, routes: [] };
|
|
12
|
+
}, { whitelist: ['route'] });
|
|
13
|
+
const scriptTransform = createTransform((inboundState) => {
|
|
14
|
+
const { entries, loadedScripts, ...rest } = inboundState;
|
|
15
|
+
return rest;
|
|
16
|
+
}, (outboundState) => {
|
|
17
|
+
return { ...outboundState, entries: [], loadedScripts: [] };
|
|
18
|
+
}, { whitelist: ['script'] });
|
|
19
|
+
const persistConfig = {
|
|
20
|
+
key: 'root',
|
|
21
|
+
storage: storage,
|
|
22
|
+
transforms: [routeTransform, scriptTransform],
|
|
23
|
+
};
|
|
24
|
+
const persistedReducer = persistReducer(persistConfig, combineReducers(reducers));
|
|
25
|
+
export const store = configureStore({
|
|
26
|
+
reducer: persistedReducer,
|
|
27
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
28
|
+
serializableCheck: {
|
|
29
|
+
ignoredActions: [
|
|
30
|
+
FLUSH,
|
|
31
|
+
REHYDRATE,
|
|
32
|
+
PAUSE,
|
|
33
|
+
PERSIST,
|
|
34
|
+
PURGE,
|
|
35
|
+
REGISTER,
|
|
36
|
+
// 忽略包含 React 组件的路由 actions
|
|
37
|
+
'route/addRoute',
|
|
38
|
+
'route/updateRoute',
|
|
39
|
+
'route/setRoutes',
|
|
40
|
+
],
|
|
41
|
+
// 忽略 state 中的 routes 字段
|
|
42
|
+
ignoredPaths: ['route.routes'],
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
export const persistor = persistStore(store);
|
|
47
|
+
// 将 store 挂载到 window 以供 DynamicRouter 使用
|
|
48
|
+
if (typeof window !== 'undefined') {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
window.__REDUX_STORE__ = store;
|
|
51
|
+
}
|
|
52
|
+
export function addReducer(name, reducer) {
|
|
53
|
+
reducers[name] = reducer;
|
|
54
|
+
const newPersistedReducer = persistReducer(persistConfig, combineReducers(reducers));
|
|
55
|
+
store.replaceReducer(newPersistedReducer);
|
|
56
|
+
}
|
|
57
|
+
export const useDispatch = useReduxDispatch;
|
|
58
|
+
export const useSelector = useReduxSelector;
|
|
59
|
+
// 导出 UI actions
|
|
60
|
+
export { toggleSidebar, setSidebarOpen, setActiveMenu } from './reducers/ui';
|
|
61
|
+
// 导出 Route actions
|
|
62
|
+
export { addRoute, removeRoute, updateRoute, setRoutes, clearRoutes } from './reducers/route';
|
|
63
|
+
// 导出 Script actions 和 thunks
|
|
64
|
+
export { syncEntries, addEntry, removeEntry, loadScript, loadScripts, unloadScript } from './reducers/script';
|
|
65
|
+
// 导出 Config actions 和 selectors
|
|
66
|
+
export { setConnected, setLoading, setError, updateConfig, updateSchema, updateConfigs, updateSchemas, removeConfig, clearConfigs, selectConfig, selectSchema, selectConfigLoading, selectConfigError, selectConfigConnected, selectAllConfigs, selectAllSchemas } from './reducers/config';
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../client/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAkB,eAAe,EAAC,MAAM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Q,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACf,MAAM,mBAAmB,CAAA;AAE1B,gCAAgC;AAChC,OAAO,EACH,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置管理 Redux Slice
|
|
3
|
+
* 通过 WebSocket 管理插件配置
|
|
4
|
+
*/
|
|
5
|
+
export interface ConfigState {
|
|
6
|
+
configs: Record<string, any>;
|
|
7
|
+
schemas: Record<string, any>;
|
|
8
|
+
loading: Record<string, boolean>;
|
|
9
|
+
errors: Record<string, string | null>;
|
|
10
|
+
connected: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ConfigMessage {
|
|
13
|
+
type: 'config:get' | 'config:set' | 'config:updated' | 'schema:get' | 'schema:updated';
|
|
14
|
+
pluginName: string;
|
|
15
|
+
data?: any;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const setConnected: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "config/setConnected">, setLoading: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
19
|
+
pluginName: string;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
}, "config/setLoading">, setError: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
22
|
+
pluginName: string;
|
|
23
|
+
error: string | null;
|
|
24
|
+
}, "config/setError">, updateConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
25
|
+
pluginName: string;
|
|
26
|
+
config: any;
|
|
27
|
+
}, "config/updateConfig">, updateSchema: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
28
|
+
pluginName: string;
|
|
29
|
+
schema: any;
|
|
30
|
+
}, "config/updateSchema">, updateConfigs: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<string, any>, "config/updateConfigs">, updateSchemas: import("@reduxjs/toolkit").ActionCreatorWithPayload<Record<string, any>, "config/updateSchemas">, removeConfig: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "config/removeConfig">, clearConfigs: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"config/clearConfigs">;
|
|
31
|
+
declare const _default: import("@reduxjs/toolkit").Reducer<ConfigState>;
|
|
32
|
+
export default _default;
|
|
33
|
+
export declare const selectConfig: (state: {
|
|
34
|
+
config: ConfigState;
|
|
35
|
+
}, pluginName: string) => any;
|
|
36
|
+
export declare const selectSchema: (state: {
|
|
37
|
+
config: ConfigState;
|
|
38
|
+
}, pluginName: string) => any;
|
|
39
|
+
export declare const selectConfigLoading: (state: {
|
|
40
|
+
config: ConfigState;
|
|
41
|
+
}, pluginName: string) => boolean;
|
|
42
|
+
export declare const selectConfigError: (state: {
|
|
43
|
+
config: ConfigState;
|
|
44
|
+
}, pluginName: string) => string | null;
|
|
45
|
+
export declare const selectConfigConnected: (state: {
|
|
46
|
+
config: ConfigState;
|
|
47
|
+
}) => boolean;
|
|
48
|
+
export declare const selectAllConfigs: (state: {
|
|
49
|
+
config: ConfigState;
|
|
50
|
+
}) => Record<string, any>;
|
|
51
|
+
export declare const selectAllSchemas: (state: {
|
|
52
|
+
config: ConfigState;
|
|
53
|
+
}) => Record<string, any>;
|
|
54
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../client/store/reducers/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,WAAW;IAE1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,C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O;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,wBACzC,CAAA;AAEtB,eAAO,MAAM,gBAAgB,GAAI,OAAO;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,wBACzC,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置管理 Redux Slice
|
|
3
|
+
* 通过 WebSocket 管理插件配置
|
|
4
|
+
*/
|
|
5
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
6
|
+
const initialState = {
|
|
7
|
+
configs: {},
|
|
8
|
+
schemas: {},
|
|
9
|
+
loading: {},
|
|
10
|
+
errors: {},
|
|
11
|
+
connected: false
|
|
12
|
+
};
|
|
13
|
+
const configSlice = createSlice({
|
|
14
|
+
name: 'config',
|
|
15
|
+
initialState,
|
|
16
|
+
reducers: {
|
|
17
|
+
// WebSocket 连接状态
|
|
18
|
+
setConnected: (state, action) => {
|
|
19
|
+
state.connected = action.payload;
|
|
20
|
+
},
|
|
21
|
+
// 设置配置加载状态
|
|
22
|
+
setLoading: (state, action) => {
|
|
23
|
+
const { pluginName, loading } = action.payload;
|
|
24
|
+
state.loading[pluginName] = loading;
|
|
25
|
+
},
|
|
26
|
+
// 设置错误信息
|
|
27
|
+
setError: (state, action) => {
|
|
28
|
+
const { pluginName, error } = action.payload;
|
|
29
|
+
state.errors[pluginName] = error;
|
|
30
|
+
},
|
|
31
|
+
// 更新插件配置
|
|
32
|
+
updateConfig: (state, action) => {
|
|
33
|
+
const { pluginName, config } = action.payload;
|
|
34
|
+
state.configs[pluginName] = config;
|
|
35
|
+
state.loading[pluginName] = false;
|
|
36
|
+
state.errors[pluginName] = null;
|
|
37
|
+
},
|
|
38
|
+
// 更新插件 Schema
|
|
39
|
+
updateSchema: (state, action) => {
|
|
40
|
+
const { pluginName, schema } = action.payload;
|
|
41
|
+
state.schemas[pluginName] = schema;
|
|
42
|
+
},
|
|
43
|
+
// 批量更新配置
|
|
44
|
+
updateConfigs: (state, action) => {
|
|
45
|
+
state.configs = { ...state.configs, ...action.payload };
|
|
46
|
+
},
|
|
47
|
+
// 批量更新 Schema
|
|
48
|
+
updateSchemas: (state, action) => {
|
|
49
|
+
state.schemas = { ...state.schemas, ...action.payload };
|
|
50
|
+
},
|
|
51
|
+
// 清除插件配置
|
|
52
|
+
removeConfig: (state, action) => {
|
|
53
|
+
const pluginName = action.payload;
|
|
54
|
+
delete state.configs[pluginName];
|
|
55
|
+
delete state.schemas[pluginName];
|
|
56
|
+
delete state.loading[pluginName];
|
|
57
|
+
delete state.errors[pluginName];
|
|
58
|
+
},
|
|
59
|
+
// 清除所有配置
|
|
60
|
+
clearConfigs: (state) => {
|
|
61
|
+
state.configs = {};
|
|
62
|
+
state.schemas = {};
|
|
63
|
+
state.loading = {};
|
|
64
|
+
state.errors = {};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export const { setConnected, setLoading, setError, updateConfig, updateSchema, updateConfigs, updateSchemas, removeConfig, clearConfigs } = configSlice.actions;
|
|
69
|
+
export default configSlice.reducer;
|
|
70
|
+
// Selectors
|
|
71
|
+
export const selectConfig = (state, pluginName) => state.config.configs[pluginName];
|
|
72
|
+
export const selectSchema = (state, pluginName) => state.config.schemas[pluginName];
|
|
73
|
+
export const selectConfigLoading = (state, pluginName) => state.config.loading[pluginName] || false;
|
|
74
|
+
export const selectConfigError = (state, pluginName) => state.config.errors[pluginName] || null;
|
|
75
|
+
export const selectConfigConnected = (state) => state.config.connected;
|
|
76
|
+
export const selectAllConfigs = (state) => state.config.configs;
|
|
77
|
+
export const selectAllSchemas = (state) => state.config.schemas;
|
|
78
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../client/store/reducers/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAmC,MAAM,kBAAkB,CAAA;AAe/E,MAAM,YAAY,G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C,OAAO,CAAA;AAElC,YAAY;AACZ,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA8B,EAAE,UAAkB,EAAE,EAAE,CACjF,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA8B,EAAE,UAAkB,EAAE,EAAE,CACjF,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA8B,EAAE,UAAkB,EAAE,EAAE,CACxF,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,CAAA;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA8B,EAAE,UAAkB,EAAE,EAAE,CACtF,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,CAAA;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA8B,EAAE,EAAE,CACtE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAA;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA8B,EAAE,EAAE,CACjE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAA;AAEtB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA8B,EAAE,EAAE,CACjE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Reducer } from "@reduxjs/toolkit";
|
|
2
|
+
import ui from "./ui";
|
|
3
|
+
import route from "./route";
|
|
4
|
+
import script from "./script";
|
|
5
|
+
import config from "./config";
|
|
6
|
+
export interface Reducers {
|
|
7
|
+
ui: ReturnType<typeof ui>;
|
|
8
|
+
route: ReturnType<typeof route>;
|
|
9
|
+
script: ReturnType<typeof script>;
|
|
10
|
+
config: ReturnType<typeof config>;
|
|
11
|
+
}
|
|
12
|
+
export declare const reducers: Record<keyof Reducers, Reducer<any, any>>;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../client/store/reducers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,MAAM,MAAM,UAAU,CAAA;AAE7B,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;IACzB,KAAK,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAA;IAC/B,MAAM,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAA;CACpC;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAK9D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../client/store/reducers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,MAAM,CAAA;AACrB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,MAAM,MAAM,UAAU,CAAA;AAS7B,MAAM,CAAC,MAAM,QAAQ,GAA8C;IAC/D,EAAE;IACF,KAAK;IACL,MAAM;IACN,MAAM;CACT,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { ComponentType, ReactNode } from "react";
|
|
3
|
+
export interface RouteMenuItem {
|
|
4
|
+
key: string;
|
|
5
|
+
path: string;
|
|
6
|
+
title: string;
|
|
7
|
+
index?: boolean;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
element?: ReactNode;
|
|
10
|
+
Component?: ComponentType;
|
|
11
|
+
children?: RouteMenuItem[];
|
|
12
|
+
meta?: {
|
|
13
|
+
hideInMenu?: boolean;
|
|
14
|
+
requiresAuth?: boolean;
|
|
15
|
+
order?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface RouteState {
|
|
19
|
+
routes: RouteMenuItem[];
|
|
20
|
+
}
|
|
21
|
+
export declare const routeSlice: import("@reduxjs/toolkit").Slice<RouteState, {
|
|
22
|
+
addRoute: (state: import("@reduxjs/toolkit").WritableDraft<RouteState>, action: PayloadAction<RouteMenuItem>) => void;
|
|
23
|
+
removeRoute: (state: import("@reduxjs/toolkit").WritableDraft<RouteState>, action: PayloadAction<string>) => void;
|
|
24
|
+
updateRoute: (state: import("@reduxjs/toolkit").WritableDraft<RouteState>, action: PayloadAction<{
|
|
25
|
+
path: string;
|
|
26
|
+
updates: Partial<RouteMenuItem>;
|
|
27
|
+
}>) => void;
|
|
28
|
+
setRoutes: (state: import("@reduxjs/toolkit").WritableDraft<RouteState>, action: PayloadAction<RouteMenuItem[]>) => void;
|
|
29
|
+
clearRoutes: (state: import("@reduxjs/toolkit").WritableDraft<RouteState>) => void;
|
|
30
|
+
}, "route", "route", import("@reduxjs/toolkit").SliceSelectors<RouteState>>;
|
|
31
|
+
export declare const addRoute: import("@reduxjs/toolkit").ActionCreatorWithPayload<RouteMenuItem, "route/addRoute">, removeRoute: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "route/removeRoute">, updateRoute: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
32
|
+
path: string;
|
|
33
|
+
updates: Partial<RouteMenuItem>;
|
|
34
|
+
}, "route/updateRoute">, setRoutes: import("@reduxjs/toolkit").ActionCreatorWithPayload<RouteMenuItem[], "route/setRoutes">, clearRoutes: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"route/clearRoutes">;
|
|
35
|
+
declare const _default: import("@reduxjs/toolkit").Reducer<RouteState>;
|
|
36
|
+
export default _default;
|
|
37
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../client/store/reducers/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGhD,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAA;IAC1B,IAAI,CAAC,EAAE;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,KAAK,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;CACJ;AAED,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,aAAa,EAAE,CAAA;CAC1B;AAyBD,eAAO,MAAM,UAAU;oFAIW,aAAa,CAAC,aAAa,CAAC;uFAezB,aAAa,CAAC,MAAM,CAAC;uFAqBrB,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;KAAE,CAAC;qFAqBlE,aAAa,CAAC,aAAa,EAAE,CAAC;;2EAS/D,CAAA;AAEF,eAAO,MAAQ,QAAQ,wFAAE,WAAW,oFAAE,WAAW;UAhCU,MAAM;aAAW,OAAO,CAAC,aAAa,CAAC;yBAgC/C,SAAS,2FAAE,WAAW,6EAAuB,CAAA;;AAChG,wBAAiC"}
|