@lytjs/devtools 4.2.0 → 6.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.
- package/dist/index.cjs +1700 -564
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +743 -0
- package/dist/index.d.ts +743 -0
- package/dist/index.mjs +1613 -564
- package/dist/index.mjs.map +1 -0
- package/package.json +41 -26
- package/README.md +0 -153
- package/dist/types/batch-analyzer.d.ts +0 -150
- package/dist/types/batch-analyzer.d.ts.map +0 -1
- package/dist/types/component-profiler.d.ts +0 -144
- package/dist/types/component-profiler.d.ts.map +0 -1
- package/dist/types/component-tree.d.ts +0 -69
- package/dist/types/component-tree.d.ts.map +0 -1
- package/dist/types/event-panel.d.ts +0 -129
- package/dist/types/event-panel.d.ts.map +0 -1
- package/dist/types/event-tracker.d.ts +0 -80
- package/dist/types/event-tracker.d.ts.map +0 -1
- package/dist/types/hooks.d.ts +0 -177
- package/dist/types/hooks.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -185
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/memory-tracker.d.ts +0 -148
- package/dist/types/memory-tracker.d.ts.map +0 -1
- package/dist/types/panel.d.ts +0 -182
- package/dist/types/panel.d.ts.map +0 -1
- package/dist/types/perf-collector.d.ts +0 -328
- package/dist/types/perf-collector.d.ts.map +0 -1
- package/dist/types/perf-panel.d.ts +0 -231
- package/dist/types/perf-panel.d.ts.map +0 -1
- package/dist/types/render-tracker.d.ts +0 -147
- package/dist/types/render-tracker.d.ts.map +0 -1
- package/dist/types/route-panel.d.ts +0 -68
- package/dist/types/route-panel.d.ts.map +0 -1
- package/dist/types/router-panel-enhanced.d.ts +0 -118
- package/dist/types/router-panel-enhanced.d.ts.map +0 -1
- package/dist/types/state-inspector.d.ts +0 -80
- package/dist/types/state-inspector.d.ts.map +0 -1
- package/dist/types/time-travel.d.ts +0 -189
- package/dist/types/time-travel.d.ts.map +0 -1
- package/dist/types/virtual-tree.d.ts +0 -168
- package/dist/types/virtual-tree.d.ts.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lytjs/devtools - 类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* DevTools 配置选项
|
|
7
|
+
*/
|
|
8
|
+
interface DevToolsOptions {
|
|
9
|
+
/** 是否启用 */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
/** 面板位置 */
|
|
12
|
+
position?: 'right' | 'bottom' | 'left';
|
|
13
|
+
/** 面板宽度/高度 */
|
|
14
|
+
size?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 组件树节点
|
|
18
|
+
*/
|
|
19
|
+
interface ComponentTreeNode {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
props?: Record<string, any>;
|
|
23
|
+
children?: ComponentTreeNode[];
|
|
24
|
+
parent?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Store 状态信息
|
|
28
|
+
*/
|
|
29
|
+
interface StoreStateInfo {
|
|
30
|
+
id: string;
|
|
31
|
+
state: Record<string, any>;
|
|
32
|
+
getters?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 路由信息
|
|
36
|
+
*/
|
|
37
|
+
interface RouteInfo {
|
|
38
|
+
path: string;
|
|
39
|
+
name?: string | null;
|
|
40
|
+
params?: Record<string, string>;
|
|
41
|
+
query?: Record<string, string>;
|
|
42
|
+
matched: Array<{
|
|
43
|
+
path: string;
|
|
44
|
+
name?: string | null;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 信号节点信息
|
|
49
|
+
*/
|
|
50
|
+
interface SignalNode$1 {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
type: 'signal' | 'computed' | 'effect';
|
|
54
|
+
value?: unknown;
|
|
55
|
+
previousValue?: unknown;
|
|
56
|
+
dependencies: string[];
|
|
57
|
+
dependents: string[];
|
|
58
|
+
updateCount: number;
|
|
59
|
+
lastUpdateTime: number;
|
|
60
|
+
averageUpdateTime: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 快照记录
|
|
64
|
+
*/
|
|
65
|
+
interface Snapshot$1 {
|
|
66
|
+
id: string;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
label?: string;
|
|
69
|
+
signals: Record<string, SignalSnapshot$1>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 单个信号的快照
|
|
73
|
+
*/
|
|
74
|
+
interface SignalSnapshot$1 {
|
|
75
|
+
value: unknown;
|
|
76
|
+
dependencies: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 时间旅行状态
|
|
80
|
+
*/
|
|
81
|
+
interface TimeTravelState$1 {
|
|
82
|
+
snapshots: Snapshot$1[];
|
|
83
|
+
currentIndex: number;
|
|
84
|
+
canUndo: boolean;
|
|
85
|
+
canRedo: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 性能记录
|
|
89
|
+
*/
|
|
90
|
+
interface PerformanceRecord$1 {
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
type: 'signal' | 'computed' | 'effect';
|
|
94
|
+
duration: number;
|
|
95
|
+
timestamp: number;
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 依赖图节点
|
|
100
|
+
*/
|
|
101
|
+
interface DependencyGraphNode$1 {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
type: 'signal' | 'computed' | 'effect';
|
|
105
|
+
x?: number;
|
|
106
|
+
y?: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 依赖图边
|
|
110
|
+
*/
|
|
111
|
+
interface DependencyGraphEdge$1 {
|
|
112
|
+
source: string;
|
|
113
|
+
target: string;
|
|
114
|
+
type: 'dependency' | 'dependent';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 依赖图
|
|
118
|
+
*/
|
|
119
|
+
interface DependencyGraph$1 {
|
|
120
|
+
nodes: DependencyGraphNode$1[];
|
|
121
|
+
edges: DependencyGraphEdge$1[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 性能统计
|
|
125
|
+
*/
|
|
126
|
+
interface PerformanceStats$1 {
|
|
127
|
+
totalRecords: number;
|
|
128
|
+
averageDuration: number;
|
|
129
|
+
maxDuration: number;
|
|
130
|
+
minDuration: number;
|
|
131
|
+
byType: Record<string, {
|
|
132
|
+
count: number;
|
|
133
|
+
average: number;
|
|
134
|
+
max: number;
|
|
135
|
+
}>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* DevTools API
|
|
139
|
+
*/
|
|
140
|
+
interface DevToolsAPI {
|
|
141
|
+
/** 获取组件树 */
|
|
142
|
+
getComponentTree(): ComponentTreeNode[];
|
|
143
|
+
/** 获取 Store 状态 */
|
|
144
|
+
getStoreStates(): StoreStateInfo[];
|
|
145
|
+
/** 获取当前路由 */
|
|
146
|
+
getCurrentRoute(): RouteInfo | null;
|
|
147
|
+
/** 刷新 */
|
|
148
|
+
refresh(): void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @lytjs/devtools - 组件树查看器
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 获取组件树
|
|
157
|
+
*/
|
|
158
|
+
declare function getComponentTree(rootComponent?: any): ComponentTreeNode[];
|
|
159
|
+
/**
|
|
160
|
+
* 序列化组件树为字符串
|
|
161
|
+
*/
|
|
162
|
+
declare function serializeComponentTree(nodes: ComponentTreeNode[], indent?: number): string;
|
|
163
|
+
/**
|
|
164
|
+
* 注册根组件(供开发时使用)
|
|
165
|
+
*/
|
|
166
|
+
declare function registerRootComponent(component: any): void;
|
|
167
|
+
/**
|
|
168
|
+
* 清除注册的根组件
|
|
169
|
+
*/
|
|
170
|
+
declare function unregisterRootComponent(): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @lytjs/devtools - Store 状态检查器
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Store 变更回调类型
|
|
178
|
+
*/
|
|
179
|
+
type StoreChangeCallback = (storeId: string, state: Record<string, any>) => void;
|
|
180
|
+
/**
|
|
181
|
+
* 注册 Store
|
|
182
|
+
*/
|
|
183
|
+
declare function registerStore(id: string, store: any): void;
|
|
184
|
+
/**
|
|
185
|
+
* 注销 Store
|
|
186
|
+
*/
|
|
187
|
+
declare function unregisterStore(id: string): void;
|
|
188
|
+
/**
|
|
189
|
+
* 获取所有 Store 状态
|
|
190
|
+
*/
|
|
191
|
+
declare function getStoreStates(): StoreStateInfo[];
|
|
192
|
+
/**
|
|
193
|
+
* 获取特定 Store 的状态
|
|
194
|
+
*/
|
|
195
|
+
declare function getStoreState(storeId: string): StoreStateInfo | null;
|
|
196
|
+
/**
|
|
197
|
+
* 修改 Store 状态(用于开发时调试)
|
|
198
|
+
*/
|
|
199
|
+
declare function setStoreState(storeId: string, path: string, value: any): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* 触发 Store Action
|
|
202
|
+
*/
|
|
203
|
+
declare function dispatchStoreAction(storeId: string, actionName: string, ...args: any[]): any;
|
|
204
|
+
/**
|
|
205
|
+
* 序列化 Store 状态为字符串
|
|
206
|
+
*/
|
|
207
|
+
declare function serializeStoreStates(states: StoreStateInfo[]): string;
|
|
208
|
+
/**
|
|
209
|
+
* 订阅 Store 变更
|
|
210
|
+
*
|
|
211
|
+
* @description
|
|
212
|
+
* 当 Store 的 $subscribe 方法可用时自动监听变更,
|
|
213
|
+
* 变更时会触发所有通过 onStoreChange 注册的全局回调
|
|
214
|
+
*
|
|
215
|
+
* @param storeId - 要订阅的 Store ID
|
|
216
|
+
* @returns 是否订阅成功
|
|
217
|
+
*/
|
|
218
|
+
declare function subscribeStore(storeId: string): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* 取消订阅 Store 变更
|
|
221
|
+
*
|
|
222
|
+
* @param storeId - 要取消订阅的 Store ID
|
|
223
|
+
*/
|
|
224
|
+
declare function unsubscribeStore(storeId: string): void;
|
|
225
|
+
/**
|
|
226
|
+
* 注册全局 Store 变更回调
|
|
227
|
+
*
|
|
228
|
+
* @description
|
|
229
|
+
* 当任何已订阅的 Store 发生变更时,会调用此回调
|
|
230
|
+
*
|
|
231
|
+
* @param callback - 变更回调函数,接收 storeId 和当前 state
|
|
232
|
+
* @returns 取消注册的函数
|
|
233
|
+
*/
|
|
234
|
+
declare function onStoreChange(callback: StoreChangeCallback): () => void;
|
|
235
|
+
/**
|
|
236
|
+
* 清空所有注册的 Store(用于测试)
|
|
237
|
+
*/
|
|
238
|
+
declare function clearStoreRegistry(): void;
|
|
239
|
+
/**
|
|
240
|
+
* 获取已注册的 Store ID 列表
|
|
241
|
+
*/
|
|
242
|
+
declare function getRegisteredStoreIds(): string[];
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @lytjs/devtools - 路由查看器
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 注册路由器
|
|
250
|
+
*/
|
|
251
|
+
declare function registerRouter(router: any): void;
|
|
252
|
+
/**
|
|
253
|
+
* 注销路由器
|
|
254
|
+
*/
|
|
255
|
+
declare function unregisterRouter(): void;
|
|
256
|
+
/**
|
|
257
|
+
* 获取当前路由信息
|
|
258
|
+
*/
|
|
259
|
+
declare function getCurrentRoute(): RouteInfo | null;
|
|
260
|
+
/**
|
|
261
|
+
* 获取路由历史
|
|
262
|
+
*
|
|
263
|
+
* @description
|
|
264
|
+
* 返回自监听开始以来的所有路由变更记录
|
|
265
|
+
*
|
|
266
|
+
* @returns 路由变更历史数组
|
|
267
|
+
*/
|
|
268
|
+
declare function getRouteHistory(): RouteInfo[];
|
|
269
|
+
/**
|
|
270
|
+
* 监听路由变化
|
|
271
|
+
*
|
|
272
|
+
* @description
|
|
273
|
+
* 利用 router.afterEach 钩子监听路由导航,
|
|
274
|
+
* 每次导航后将路由信息记录到 routeHistory 中
|
|
275
|
+
*
|
|
276
|
+
* @returns 是否成功开始监听
|
|
277
|
+
*/
|
|
278
|
+
declare function watchRouteChanges(): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* 停止监听路由变化
|
|
281
|
+
*
|
|
282
|
+
* @description
|
|
283
|
+
* 停止路由变更监听,但已记录的历史不会被清除
|
|
284
|
+
*/
|
|
285
|
+
declare function unwatchRouteChanges(): void;
|
|
286
|
+
/**
|
|
287
|
+
* 导航到指定路径
|
|
288
|
+
*/
|
|
289
|
+
declare function navigateTo(path: string): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* 导航到指定路由名称
|
|
292
|
+
*/
|
|
293
|
+
declare function navigateToName(name: string, params?: Record<string, string>): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* 返回上一页
|
|
296
|
+
*/
|
|
297
|
+
declare function goBack(): Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* 序列化路由信息为字符串
|
|
300
|
+
*/
|
|
301
|
+
declare function serializeRouteInfo(route: RouteInfo | null): string;
|
|
302
|
+
/**
|
|
303
|
+
* 获取所有路由配置
|
|
304
|
+
*/
|
|
305
|
+
declare function getRoutes(): Array<{
|
|
306
|
+
path: string;
|
|
307
|
+
name?: string | null;
|
|
308
|
+
}>;
|
|
309
|
+
/**
|
|
310
|
+
* 检查路由器是否已注册
|
|
311
|
+
*/
|
|
312
|
+
declare function isRouterRegistered(): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* 清空路由变更历史(用于测试)
|
|
315
|
+
*/
|
|
316
|
+
declare function clearRouteHistory(): void;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @lytjs/devtools - 信号依赖追踪和快照
|
|
320
|
+
*
|
|
321
|
+
* 提供时间旅行调试、信号依赖图可视化和性能分析功能
|
|
322
|
+
*/
|
|
323
|
+
interface SignalNode {
|
|
324
|
+
id: string;
|
|
325
|
+
name: string;
|
|
326
|
+
type: 'signal' | 'computed' | 'effect';
|
|
327
|
+
value?: unknown;
|
|
328
|
+
previousValue?: unknown;
|
|
329
|
+
dependencies: string[];
|
|
330
|
+
dependents: string[];
|
|
331
|
+
updateCount: number;
|
|
332
|
+
lastUpdateTime: number;
|
|
333
|
+
averageUpdateTime: number;
|
|
334
|
+
}
|
|
335
|
+
/** 快照记录 */
|
|
336
|
+
interface Snapshot {
|
|
337
|
+
id: string;
|
|
338
|
+
timestamp: number;
|
|
339
|
+
label?: string;
|
|
340
|
+
signals: Record<string, SignalSnapshot>;
|
|
341
|
+
}
|
|
342
|
+
/** 单个信号的快照 */
|
|
343
|
+
interface SignalSnapshot {
|
|
344
|
+
value: unknown;
|
|
345
|
+
dependencies: string[];
|
|
346
|
+
}
|
|
347
|
+
/** 时间旅行状态 */
|
|
348
|
+
interface TimeTravelState {
|
|
349
|
+
snapshots: Snapshot[];
|
|
350
|
+
currentIndex: number;
|
|
351
|
+
canUndo: boolean;
|
|
352
|
+
canRedo: boolean;
|
|
353
|
+
}
|
|
354
|
+
/** 性能记录 */
|
|
355
|
+
interface PerformanceRecord {
|
|
356
|
+
id: string;
|
|
357
|
+
name: string;
|
|
358
|
+
type: 'signal' | 'computed' | 'effect';
|
|
359
|
+
duration: number;
|
|
360
|
+
timestamp: number;
|
|
361
|
+
metadata?: Record<string, unknown>;
|
|
362
|
+
}
|
|
363
|
+
/** 依赖图节点 */
|
|
364
|
+
interface DependencyGraphNode {
|
|
365
|
+
id: string;
|
|
366
|
+
name: string;
|
|
367
|
+
type: 'signal' | 'computed' | 'effect';
|
|
368
|
+
x?: number;
|
|
369
|
+
y?: number;
|
|
370
|
+
}
|
|
371
|
+
/** 依赖图边 */
|
|
372
|
+
interface DependencyGraphEdge {
|
|
373
|
+
source: string;
|
|
374
|
+
target: string;
|
|
375
|
+
type: 'dependency' | 'dependent';
|
|
376
|
+
}
|
|
377
|
+
/** 依赖图 */
|
|
378
|
+
interface DependencyGraph {
|
|
379
|
+
nodes: DependencyGraphNode[];
|
|
380
|
+
edges: DependencyGraphEdge[];
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* 注册一个信号
|
|
384
|
+
*/
|
|
385
|
+
declare function registerSignal(id: string, name: string, type: 'signal' | 'computed' | 'effect', initialValue?: unknown): void;
|
|
386
|
+
/**
|
|
387
|
+
* 注销一个信号
|
|
388
|
+
*/
|
|
389
|
+
declare function unregisterSignal(id: string): void;
|
|
390
|
+
/**
|
|
391
|
+
* 记录信号更新
|
|
392
|
+
*/
|
|
393
|
+
declare function recordSignalUpdate(id: string, newValue: unknown, duration?: number): void;
|
|
394
|
+
/**
|
|
395
|
+
* 记录依赖关系
|
|
396
|
+
*/
|
|
397
|
+
declare function recordDependency(sourceId: string, targetId: string): void;
|
|
398
|
+
/**
|
|
399
|
+
* 获取所有信号节点
|
|
400
|
+
*/
|
|
401
|
+
declare function getSignalNodes(): SignalNode[];
|
|
402
|
+
/**
|
|
403
|
+
* 获取单个信号节点
|
|
404
|
+
*/
|
|
405
|
+
declare function getSignalNode(id: string): SignalNode | undefined;
|
|
406
|
+
/**
|
|
407
|
+
* 获取依赖图
|
|
408
|
+
*/
|
|
409
|
+
declare function getDependencyGraph(): DependencyGraph;
|
|
410
|
+
/**
|
|
411
|
+
* 创建快照
|
|
412
|
+
*/
|
|
413
|
+
declare function createSnapshot(label?: string): Snapshot;
|
|
414
|
+
/**
|
|
415
|
+
* 获取所有快照
|
|
416
|
+
*/
|
|
417
|
+
declare function getSnapshots(): Snapshot[];
|
|
418
|
+
/**
|
|
419
|
+
* 获取时间旅行状态
|
|
420
|
+
*/
|
|
421
|
+
declare function getTimeTravelState(): TimeTravelState;
|
|
422
|
+
/**
|
|
423
|
+
* 恢复到指定快照
|
|
424
|
+
*/
|
|
425
|
+
declare function restoreSnapshot(index: number): Snapshot | undefined;
|
|
426
|
+
/**
|
|
427
|
+
* 清除所有快照
|
|
428
|
+
*/
|
|
429
|
+
declare function clearSnapshots(): void;
|
|
430
|
+
/**
|
|
431
|
+
* 获取性能记录
|
|
432
|
+
*/
|
|
433
|
+
declare function getPerformanceRecords(limit?: number): PerformanceRecord[];
|
|
434
|
+
/**
|
|
435
|
+
* 获取性能统计
|
|
436
|
+
*/
|
|
437
|
+
declare function getPerformanceStats(): {
|
|
438
|
+
totalRecords: number;
|
|
439
|
+
averageDuration: number;
|
|
440
|
+
maxDuration: number;
|
|
441
|
+
minDuration: number;
|
|
442
|
+
byType: Record<string, {
|
|
443
|
+
count: number;
|
|
444
|
+
average: number;
|
|
445
|
+
max: number;
|
|
446
|
+
}>;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* 清除性能记录
|
|
450
|
+
*/
|
|
451
|
+
declare function clearPerformanceRecords(): void;
|
|
452
|
+
/**
|
|
453
|
+
* 清除所有注册信号
|
|
454
|
+
*/
|
|
455
|
+
declare function clearSignalRegistry(): void;
|
|
456
|
+
/**
|
|
457
|
+
* 序列化信号节点用于显示
|
|
458
|
+
*/
|
|
459
|
+
declare function serializeSignalNode(node: SignalNode): string;
|
|
460
|
+
/**
|
|
461
|
+
* 序列化依赖图用于显示
|
|
462
|
+
*/
|
|
463
|
+
declare function serializeDependencyGraph(): string;
|
|
464
|
+
/**
|
|
465
|
+
* 序列化性能统计
|
|
466
|
+
*/
|
|
467
|
+
declare function serializePerformanceStats(): string;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @lytjs/devtools - 性能监控系统
|
|
471
|
+
*
|
|
472
|
+
* 提供性能埋点、性能指标收集、性能告警等功能
|
|
473
|
+
*/
|
|
474
|
+
/** 性能指标类型 */
|
|
475
|
+
type MetricType = 'render' | 'update' | 'effect' | 'computed' | 'reaction' | 'custom';
|
|
476
|
+
/** 性能指标 */
|
|
477
|
+
interface PerformanceMetric {
|
|
478
|
+
id: string;
|
|
479
|
+
name: string;
|
|
480
|
+
type: MetricType;
|
|
481
|
+
duration: number;
|
|
482
|
+
timestamp: number;
|
|
483
|
+
metadata?: Record<string, unknown>;
|
|
484
|
+
}
|
|
485
|
+
/** 告警级别 */
|
|
486
|
+
type AlertLevel = 'info' | 'warning' | 'error' | 'critical';
|
|
487
|
+
/** 告警规则 */
|
|
488
|
+
interface AlertRule {
|
|
489
|
+
id: string;
|
|
490
|
+
name: string;
|
|
491
|
+
level: AlertLevel;
|
|
492
|
+
condition: (metric: PerformanceMetric, stats: PerformanceStats) => boolean;
|
|
493
|
+
message: string;
|
|
494
|
+
enabled: boolean;
|
|
495
|
+
cooldown: number;
|
|
496
|
+
}
|
|
497
|
+
/** 告警 */
|
|
498
|
+
interface Alert {
|
|
499
|
+
id: string;
|
|
500
|
+
ruleId: string;
|
|
501
|
+
ruleName: string;
|
|
502
|
+
level: AlertLevel;
|
|
503
|
+
message: string;
|
|
504
|
+
metric?: PerformanceMetric;
|
|
505
|
+
timestamp: number;
|
|
506
|
+
acknowledged: boolean;
|
|
507
|
+
}
|
|
508
|
+
/** 性能统计 */
|
|
509
|
+
interface PerformanceStats {
|
|
510
|
+
count: number;
|
|
511
|
+
total: number;
|
|
512
|
+
average: number;
|
|
513
|
+
min: number;
|
|
514
|
+
max: number;
|
|
515
|
+
p50: number;
|
|
516
|
+
p90: number;
|
|
517
|
+
p99: number;
|
|
518
|
+
}
|
|
519
|
+
/** 监控配置 */
|
|
520
|
+
interface MonitorOptions {
|
|
521
|
+
/** 是否启用监控 */
|
|
522
|
+
enabled?: boolean;
|
|
523
|
+
/** 最大记录数 */
|
|
524
|
+
maxRecords?: number;
|
|
525
|
+
/** 默认采样率 (0-1) */
|
|
526
|
+
sampleRate?: number;
|
|
527
|
+
/** 是否自动记录页面指标 */
|
|
528
|
+
autoRecordPageMetrics?: boolean;
|
|
529
|
+
/** 是否自动记录长任务 */
|
|
530
|
+
autoRecordLongTasks?: boolean;
|
|
531
|
+
/** 长任务阈值 (ms) */
|
|
532
|
+
longTaskThreshold?: number;
|
|
533
|
+
}
|
|
534
|
+
type ObserverCallback = (metric: PerformanceMetric) => void;
|
|
535
|
+
/**
|
|
536
|
+
* 初始化性能监控
|
|
537
|
+
*/
|
|
538
|
+
declare function initPerformanceMonitor(opts?: MonitorOptions): void;
|
|
539
|
+
/**
|
|
540
|
+
* 记录性能指标
|
|
541
|
+
*/
|
|
542
|
+
declare function recordMetric(metric: Omit<PerformanceMetric, 'id' | 'timestamp'>): PerformanceMetric;
|
|
543
|
+
/**
|
|
544
|
+
* 获取所有性能指标
|
|
545
|
+
*/
|
|
546
|
+
declare function getMetrics(limit?: number): PerformanceMetric[];
|
|
547
|
+
/**
|
|
548
|
+
* 获取性能统计
|
|
549
|
+
*/
|
|
550
|
+
declare function getStats(type?: MetricType): PerformanceStats;
|
|
551
|
+
/**
|
|
552
|
+
* 注册告警规则
|
|
553
|
+
*/
|
|
554
|
+
declare function registerAlertRule(rule: AlertRule): void;
|
|
555
|
+
/**
|
|
556
|
+
* 注销告警规则
|
|
557
|
+
*/
|
|
558
|
+
declare function unregisterAlertRule(ruleId: string): void;
|
|
559
|
+
/**
|
|
560
|
+
* 启用/禁用告警规则
|
|
561
|
+
*/
|
|
562
|
+
declare function setAlertRuleEnabled(ruleId: string, enabled: boolean): void;
|
|
563
|
+
/**
|
|
564
|
+
* 获取所有告警规则
|
|
565
|
+
*/
|
|
566
|
+
declare function getAlertRules(): AlertRule[];
|
|
567
|
+
/**
|
|
568
|
+
* 获取当前告警
|
|
569
|
+
*/
|
|
570
|
+
declare function getAlerts(includeAcknowledged?: boolean): Alert[];
|
|
571
|
+
/**
|
|
572
|
+
* 确认告警
|
|
573
|
+
*/
|
|
574
|
+
declare function acknowledgeAlert(alertId: string): void;
|
|
575
|
+
/**
|
|
576
|
+
* 确认所有告警
|
|
577
|
+
*/
|
|
578
|
+
declare function acknowledgeAllAlerts(): void;
|
|
579
|
+
/**
|
|
580
|
+
* 清除告警记录
|
|
581
|
+
*/
|
|
582
|
+
declare function clearAlerts(): void;
|
|
583
|
+
/**
|
|
584
|
+
* 添加观察者
|
|
585
|
+
*/
|
|
586
|
+
declare function addObserver(callback: ObserverCallback): void;
|
|
587
|
+
/**
|
|
588
|
+
* 移除观察者
|
|
589
|
+
*/
|
|
590
|
+
declare function removeObserver(callback: ObserverCallback): void;
|
|
591
|
+
/**
|
|
592
|
+
* 清除所有性能记录
|
|
593
|
+
*/
|
|
594
|
+
declare function clearMetrics(): void;
|
|
595
|
+
/**
|
|
596
|
+
* 重置性能监控
|
|
597
|
+
*/
|
|
598
|
+
declare function resetPerformanceMonitor(): void;
|
|
599
|
+
/**
|
|
600
|
+
* 获取性能报告
|
|
601
|
+
*/
|
|
602
|
+
declare function getPerformanceReport(): {
|
|
603
|
+
metrics: PerformanceMetric[];
|
|
604
|
+
stats: Record<MetricType, PerformanceStats>;
|
|
605
|
+
alerts: Alert[];
|
|
606
|
+
summary: {
|
|
607
|
+
totalMetrics: number;
|
|
608
|
+
totalAlerts: number;
|
|
609
|
+
unacknowledgedAlerts: number;
|
|
610
|
+
averageDuration: number;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* 序列化性能报告(用于显示)
|
|
615
|
+
*/
|
|
616
|
+
declare function serializePerformanceReport(): string;
|
|
617
|
+
/**
|
|
618
|
+
* 创建计时器
|
|
619
|
+
*/
|
|
620
|
+
declare function startTimer(name: string, type?: MetricType): () => void;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @lytjs/devtools - 大规模性能压测基准测试
|
|
624
|
+
*
|
|
625
|
+
* 提供虚拟列表、组件渲染等大规模场景的性能基准测试
|
|
626
|
+
*/
|
|
627
|
+
/** 基准测试结果 */
|
|
628
|
+
interface BenchmarkResult {
|
|
629
|
+
name: string;
|
|
630
|
+
iterations: number;
|
|
631
|
+
totalDuration: number;
|
|
632
|
+
averageDuration: number;
|
|
633
|
+
minDuration: number;
|
|
634
|
+
maxDuration: number;
|
|
635
|
+
opsPerSecond: number;
|
|
636
|
+
timestamp: number;
|
|
637
|
+
}
|
|
638
|
+
/** 基准测试配置 */
|
|
639
|
+
interface BenchmarkConfig {
|
|
640
|
+
/** 测试名称 */
|
|
641
|
+
name: string;
|
|
642
|
+
/** 迭代次数 */
|
|
643
|
+
iterations: number;
|
|
644
|
+
/** 预热次数 */
|
|
645
|
+
warmup?: number;
|
|
646
|
+
/** 异步测试回调 */
|
|
647
|
+
fn: () => void | Promise<void>;
|
|
648
|
+
/** 异步回调 */
|
|
649
|
+
asyncFn?: () => Promise<void>;
|
|
650
|
+
}
|
|
651
|
+
/** 大规模场景配置 */
|
|
652
|
+
interface LargeScaleScenario {
|
|
653
|
+
name: string;
|
|
654
|
+
nodeCount: number;
|
|
655
|
+
description: string;
|
|
656
|
+
}
|
|
657
|
+
/** 预定义的大规模场景 */
|
|
658
|
+
declare const LARGE_SCALE_SCENARIOS: LargeScaleScenario[];
|
|
659
|
+
/**
|
|
660
|
+
* 运行同步基准测试
|
|
661
|
+
*/
|
|
662
|
+
declare function runBenchmark(config: BenchmarkConfig): BenchmarkResult;
|
|
663
|
+
/**
|
|
664
|
+
* 运行异步基准测试
|
|
665
|
+
*/
|
|
666
|
+
declare function runAsyncBenchmark(config: BenchmarkConfig): Promise<BenchmarkResult>;
|
|
667
|
+
/**
|
|
668
|
+
* 获取基准测试结果
|
|
669
|
+
*/
|
|
670
|
+
declare function getBenchmarkResults(name?: string): BenchmarkResult[];
|
|
671
|
+
/**
|
|
672
|
+
* 获取最新基准测试结果
|
|
673
|
+
*/
|
|
674
|
+
declare function getLatestBenchmarkResult(name: string): BenchmarkResult | undefined;
|
|
675
|
+
/**
|
|
676
|
+
* 清除基准测试结果
|
|
677
|
+
*/
|
|
678
|
+
declare function clearBenchmarkResults(name?: string): void;
|
|
679
|
+
/**
|
|
680
|
+
* 序列化基准测试结果
|
|
681
|
+
*/
|
|
682
|
+
declare function serializeBenchmarkResult(result: BenchmarkResult): string;
|
|
683
|
+
/**
|
|
684
|
+
* 序列化所有基准测试结果
|
|
685
|
+
*/
|
|
686
|
+
declare function serializeAllBenchmarkResults(): string;
|
|
687
|
+
/**
|
|
688
|
+
* 比较两次基准测试
|
|
689
|
+
*/
|
|
690
|
+
declare function compareBenchmarkResults(oldResult: BenchmarkResult, newResult: BenchmarkResult): {
|
|
691
|
+
durationDiff: number;
|
|
692
|
+
durationDiffPercent: number;
|
|
693
|
+
opsDiff: number;
|
|
694
|
+
opsDiffPercent: number;
|
|
695
|
+
improved: boolean;
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* 生成大规模测试场景的基准测试
|
|
699
|
+
*/
|
|
700
|
+
declare function createLargeScaleBenchmark(scenario: LargeScaleScenario, testFn: (nodeCount: number) => void | Promise<void>): BenchmarkConfig;
|
|
701
|
+
/**
|
|
702
|
+
* 内存使用情况
|
|
703
|
+
*/
|
|
704
|
+
interface MemoryUsage {
|
|
705
|
+
usedJSHeapSize: number;
|
|
706
|
+
totalJSHeapSize: number;
|
|
707
|
+
jsHeapSizeLimit: number;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* 获取当前内存使用情况
|
|
711
|
+
*/
|
|
712
|
+
declare function getMemoryUsage(): MemoryUsage | null;
|
|
713
|
+
/**
|
|
714
|
+
* 序列化内存使用情况
|
|
715
|
+
*/
|
|
716
|
+
declare function serializeMemoryUsage(usage: MemoryUsage): string;
|
|
717
|
+
/**
|
|
718
|
+
* 创建性能回归检测
|
|
719
|
+
*/
|
|
720
|
+
declare function createRegressionDetector(threshold?: number): {
|
|
721
|
+
addResult(result: BenchmarkResult): boolean;
|
|
722
|
+
getHistory(name: string): BenchmarkResult[];
|
|
723
|
+
clear(): void;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* @lytjs/devtools - 开发者工具主入口
|
|
728
|
+
*/
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* 安装 DevTools
|
|
732
|
+
*/
|
|
733
|
+
declare function installDevTools(options?: DevToolsOptions): DevToolsAPI;
|
|
734
|
+
/**
|
|
735
|
+
* 获取 DevTools 实例
|
|
736
|
+
*/
|
|
737
|
+
declare function getDevTools(): DevToolsAPI | null;
|
|
738
|
+
/**
|
|
739
|
+
* 卸载 DevTools
|
|
740
|
+
*/
|
|
741
|
+
declare function uninstallDevTools(): void;
|
|
742
|
+
|
|
743
|
+
export { type Alert, type AlertLevel, type AlertRule, type BenchmarkConfig, type BenchmarkResult, type ComponentTreeNode, type DependencyGraph$1 as DependencyGraph, type PerformanceStats$1 as DevPerformanceStats, type DevToolsAPI, type DevToolsOptions, LARGE_SCALE_SCENARIOS, type LargeScaleScenario, type MemoryUsage, type MetricType, type MonitorOptions, type PerformanceMetric, type PerformanceRecord$1 as PerformanceRecord, type RouteInfo, type SignalNode$1 as SignalNode, type Snapshot$1 as Snapshot, type StoreStateInfo, type TimeTravelState$1 as TimeTravelState, acknowledgeAlert, acknowledgeAllAlerts, addObserver, clearAlerts, clearBenchmarkResults, clearMetrics, clearPerformanceRecords, clearRouteHistory, clearSignalRegistry, clearSnapshots, clearStoreRegistry, compareBenchmarkResults, createLargeScaleBenchmark, createRegressionDetector, createSnapshot, installDevTools as default, dispatchStoreAction, getAlertRules, getAlerts, getBenchmarkResults, getComponentTree, getCurrentRoute, getDependencyGraph, getDevTools, getLatestBenchmarkResult, getMemoryUsage, getMetrics, getPerformanceRecords, getPerformanceReport, getPerformanceStats, getRegisteredStoreIds, getRouteHistory, getRoutes, getSignalNode, getSignalNodes, getSnapshots, getStats, getStoreState, getStoreStates, getTimeTravelState, goBack, initPerformanceMonitor, installDevTools, isRouterRegistered, navigateTo, navigateToName, onStoreChange, recordDependency, recordMetric, recordSignalUpdate, registerAlertRule, registerRootComponent, registerRouter, registerSignal, registerStore, removeObserver, resetPerformanceMonitor, restoreSnapshot, runAsyncBenchmark, runBenchmark, serializeAllBenchmarkResults, serializeBenchmarkResult, serializeComponentTree, serializeDependencyGraph, serializeMemoryUsage, serializePerformanceReport, serializePerformanceStats, serializeRouteInfo, serializeSignalNode, serializeStoreStates, setAlertRuleEnabled, setStoreState, startTimer, subscribeStore, uninstallDevTools, unregisterAlertRule, unregisterRootComponent, unregisterRouter, unregisterSignal, unregisterStore, unsubscribeStore, unwatchRouteChanges, watchRouteChanges };
|