@lytjs/devtools 6.0.0 → 6.5.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.d.ts CHANGED
@@ -19,7 +19,7 @@ interface DevToolsOptions {
19
19
  interface ComponentTreeNode {
20
20
  id: string;
21
21
  name: string;
22
- props?: Record<string, any>;
22
+ props?: Record<string, unknown>;
23
23
  children?: ComponentTreeNode[];
24
24
  parent?: string;
25
25
  }
@@ -28,8 +28,8 @@ interface ComponentTreeNode {
28
28
  */
29
29
  interface StoreStateInfo {
30
30
  id: string;
31
- state: Record<string, any>;
32
- getters?: Record<string, any>;
31
+ state: Record<string, unknown>;
32
+ getters?: Record<string, unknown>;
33
33
  }
34
34
  /**
35
35
  * 路由信息
@@ -44,96 +44,6 @@ interface RouteInfo {
44
44
  name?: string | null;
45
45
  }>;
46
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
47
  /**
138
48
  * DevTools API
139
49
  */
@@ -155,7 +65,12 @@ interface DevToolsAPI {
155
65
  /**
156
66
  * 获取组件树
157
67
  */
158
- declare function getComponentTree(rootComponent?: any): ComponentTreeNode[];
68
+ declare function getComponentTree(rootComponent?: {
69
+ name?: string;
70
+ displayName?: string;
71
+ props?: Record<string, unknown>;
72
+ children?: unknown[];
73
+ }): ComponentTreeNode[];
159
74
  /**
160
75
  * 序列化组件树为字符串
161
76
  */
@@ -163,7 +78,7 @@ declare function serializeComponentTree(nodes: ComponentTreeNode[], indent?: num
163
78
  /**
164
79
  * 注册根组件(供开发时使用)
165
80
  */
166
- declare function registerRootComponent(component: any): void;
81
+ declare function registerRootComponent(component: unknown): void;
167
82
  /**
168
83
  * 清除注册的根组件
169
84
  */
@@ -173,14 +88,20 @@ declare function unregisterRootComponent(): void;
173
88
  * @lytjs/devtools - Store 状态检查器
174
89
  */
175
90
 
91
+ interface StoreInstance {
92
+ $state?: Record<string, unknown>;
93
+ $id?: string;
94
+ $subscribe?: (cb: (mutation: unknown, state: Record<string, unknown>) => void) => () => void;
95
+ [key: string]: unknown;
96
+ }
176
97
  /**
177
98
  * Store 变更回调类型
178
99
  */
179
- type StoreChangeCallback = (storeId: string, state: Record<string, any>) => void;
100
+ type StoreChangeCallback = (storeId: string, state: Record<string, unknown>) => void;
180
101
  /**
181
102
  * 注册 Store
182
103
  */
183
- declare function registerStore(id: string, store: any): void;
104
+ declare function registerStore(id: string, store: StoreInstance): void;
184
105
  /**
185
106
  * 注销 Store
186
107
  */
@@ -196,11 +117,11 @@ declare function getStoreState(storeId: string): StoreStateInfo | null;
196
117
  /**
197
118
  * 修改 Store 状态(用于开发时调试)
198
119
  */
199
- declare function setStoreState(storeId: string, path: string, value: any): boolean;
120
+ declare function setStoreState(storeId: string, path: string, value: unknown): boolean;
200
121
  /**
201
122
  * 触发 Store Action
202
123
  */
203
- declare function dispatchStoreAction(storeId: string, actionName: string, ...args: any[]): any;
124
+ declare function dispatchStoreAction(storeId: string, actionName: string, ...args: unknown[]): unknown;
204
125
  /**
205
126
  * 序列化 Store 状态为字符串
206
127
  */
@@ -245,10 +166,28 @@ declare function getRegisteredStoreIds(): string[];
245
166
  * @lytjs/devtools - 路由查看器
246
167
  */
247
168
 
169
+ interface RouterMatched {
170
+ path?: string;
171
+ name?: string | null;
172
+ }
173
+ interface RouterLocation {
174
+ path?: string;
175
+ name?: string | null;
176
+ params?: Record<string, string>;
177
+ query?: Record<string, string>;
178
+ matched?: RouterMatched[];
179
+ }
180
+ interface RouterInstance {
181
+ currentRoute?: () => RouterLocation;
182
+ afterEach?: (cb: (to: RouterLocation) => void) => void;
183
+ getRoutes?: () => RouterMatched[];
184
+ push?: (path: string) => Promise<void>;
185
+ back?: () => void;
186
+ }
248
187
  /**
249
188
  * 注册路由器
250
189
  */
251
- declare function registerRouter(router: any): void;
190
+ declare function registerRouter(router: RouterInstance): void;
252
191
  /**
253
192
  * 注销路由器
254
193
  */
@@ -379,6 +318,45 @@ interface DependencyGraph {
379
318
  nodes: DependencyGraphNode[];
380
319
  edges: DependencyGraphEdge[];
381
320
  }
321
+ /** 可视化布局节点 */
322
+ interface VisualLayoutNode {
323
+ id: string;
324
+ name: string;
325
+ type: 'signal' | 'computed' | 'effect';
326
+ x: number;
327
+ y: number;
328
+ level: number;
329
+ width: number;
330
+ height: number;
331
+ inDegree: number;
332
+ outDegree: number;
333
+ }
334
+ /** 可视化布局边 */
335
+ interface VisualLayoutEdge {
336
+ source: string;
337
+ target: string;
338
+ sourceX: number;
339
+ sourceY: number;
340
+ targetX: number;
341
+ targetY: number;
342
+ type: 'dependency';
343
+ }
344
+ /** 可视化布局图 */
345
+ interface VisualLayoutGraph {
346
+ nodes: VisualLayoutNode[];
347
+ edges: VisualLayoutEdge[];
348
+ width: number;
349
+ height: number;
350
+ }
351
+ /** 布局选项 */
352
+ interface LayoutOptions {
353
+ nodeWidth: number;
354
+ nodeHeight: number;
355
+ horizontalSpacing: number;
356
+ verticalSpacing: number;
357
+ centerX: number;
358
+ centerY: number;
359
+ }
382
360
  /**
383
361
  * 注册一个信号
384
362
  */
@@ -465,6 +443,80 @@ declare function serializeDependencyGraph(): string;
465
443
  * 序列化性能统计
466
444
  */
467
445
  declare function serializePerformanceStats(): string;
446
+ /**
447
+ * 获取可视化布局图
448
+ */
449
+ declare function getVisualLayoutGraph(options?: Partial<LayoutOptions>): VisualLayoutGraph;
450
+ /**
451
+ * 获取以指定节点为中心的子图
452
+ */
453
+ declare function getSubgraph(centerId: string, depth?: number): VisualLayoutGraph;
454
+ /**
455
+ * 搜索信号节点
456
+ */
457
+ declare function searchSignals(query: string): SignalNode[];
458
+ /**
459
+ * 过滤信号节点
460
+ */
461
+ declare function filterSignals(options: {
462
+ types?: Array<'signal' | 'computed' | 'effect'>;
463
+ minUpdateCount?: number;
464
+ hasDependencies?: boolean;
465
+ hasDependents?: boolean;
466
+ }): SignalNode[];
467
+ /** 快照差异 */
468
+ interface SnapshotDiff {
469
+ added: Array<{
470
+ id: string;
471
+ value: unknown;
472
+ }>;
473
+ removed: Array<{
474
+ id: string;
475
+ value: unknown;
476
+ }>;
477
+ changed: Array<{
478
+ id: string;
479
+ oldValue: unknown;
480
+ newValue: unknown;
481
+ }>;
482
+ }
483
+ /**
484
+ * 比较两个快照的差异
485
+ */
486
+ declare function compareSnapshots(snapshot1: Snapshot, snapshot2: Snapshot): SnapshotDiff;
487
+ /**
488
+ * 序列化快照差异
489
+ */
490
+ declare function serializeSnapshotDiff(diff: SnapshotDiff): string;
491
+ /**
492
+ * 获取相邻快照的差异
493
+ */
494
+ declare function getDiffBetweenSnapshots(index1: number, index2: number): SnapshotDiff | null;
495
+ /**
496
+ * 时间旅行导航
497
+ */
498
+ interface TimeTravelNavigator {
499
+ currentIndex: number;
500
+ total: number;
501
+ canGoBack: boolean;
502
+ canGoForward: boolean;
503
+ currentSnapshot: Snapshot | null;
504
+ previousSnapshot: Snapshot | null;
505
+ nextSnapshot: Snapshot | null;
506
+ diff: SnapshotDiff | null;
507
+ }
508
+ /**
509
+ * 获取时间旅行导航状态
510
+ */
511
+ declare function getTimeTravelNavigator(index?: number): TimeTravelNavigator;
512
+ /**
513
+ * 恢复到上一个快照
514
+ */
515
+ declare function timeTravelBack(): Snapshot | null;
516
+ /**
517
+ * 前进到下一个快照
518
+ */
519
+ declare function timeTravelForward(): Snapshot | null;
468
520
 
469
521
  /**
470
522
  * @lytjs/devtools - 性能监控系统
@@ -618,6 +670,59 @@ declare function serializePerformanceReport(): string;
618
670
  * 创建计时器
619
671
  */
620
672
  declare function startTimer(name: string, type?: MetricType): () => void;
673
+ /** 时序事件 */
674
+ interface TimelineEvent {
675
+ id: string;
676
+ name: string;
677
+ category: 'render' | 'effect' | 'custom';
678
+ startTime: number;
679
+ duration: number;
680
+ depth: number;
681
+ metadata?: Record<string, unknown>;
682
+ }
683
+ /** 火焰图节点 */
684
+ interface FlameGraphNode {
685
+ name: string;
686
+ value: number;
687
+ children?: FlameGraphNode[];
688
+ category?: 'render' | 'effect' | 'custom';
689
+ }
690
+ /**
691
+ * 开始时序事件
692
+ */
693
+ declare function beginTimelineEvent(name: string, category?: TimelineEvent['category'], metadata?: Record<string, unknown>): string;
694
+ /**
695
+ * 结束指定时序事件
696
+ */
697
+ declare function endTimelineEvent(id: string): TimelineEvent | null;
698
+ /**
699
+ * 获取所有时序事件
700
+ */
701
+ declare function getTimelineEvents(): TimelineEvent[];
702
+ /**
703
+ * 获取指定时间范围内的时序事件
704
+ */
705
+ declare function getTimelineEventsInRange(startTime: number, endTime: number): TimelineEvent[];
706
+ /**
707
+ * 获取慢操作
708
+ */
709
+ declare function getSlowOperations(limit?: number, threshold?: number): TimelineEvent[];
710
+ /**
711
+ * 获取火焰图数据
712
+ */
713
+ declare function getFlameGraphData(): FlameGraphNode;
714
+ /**
715
+ * 清除时序事件
716
+ */
717
+ declare function clearTimelineEvents(): void;
718
+ /**
719
+ * 导出时序事件为 JSON
720
+ */
721
+ declare function exportTimelineAsJSON(): string;
722
+ /**
723
+ * 序列化为可读文本
724
+ */
725
+ declare function serializeTimelineEvents(): string;
621
726
 
622
727
  /**
623
728
  * @lytjs/devtools - 大规模性能压测基准测试
@@ -740,4 +845,26 @@ declare function getDevTools(): DevToolsAPI | null;
740
845
  */
741
846
  declare function uninstallDevTools(): void;
742
847
 
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 };
848
+ /**
849
+ * @lytjs/devtools - VDOM 节点树检查器
850
+ *
851
+ * 提供虚拟 DOM 树的可视化和检查功能
852
+ */
853
+
854
+ interface VDOMNodeInfo {
855
+ id: string;
856
+ type: string;
857
+ tagName?: string;
858
+ text?: string;
859
+ props?: Record<string, unknown>;
860
+ children: VDOMNodeInfo[];
861
+ parentId?: string;
862
+ depth: number;
863
+ componentId?: string;
864
+ isComponent: boolean;
865
+ key?: string | number;
866
+ ref?: string;
867
+ domElement?: HTMLElement | null;
868
+ }
869
+
870
+ export { type Alert, type AlertLevel, type AlertRule, type BenchmarkConfig, type BenchmarkResult, type ComponentTreeNode, type DependencyGraph, type DevToolsAPI, type DevToolsOptions, type FlameGraphNode, LARGE_SCALE_SCENARIOS, type LargeScaleScenario, type MemoryUsage, type MetricType, type MonitorOptions, type PerformanceMetric, type PerformanceRecord, type PerformanceStats, type RouteInfo, type SignalNode, type Snapshot, type SnapshotDiff, type StoreStateInfo, type TimeTravelNavigator, type TimeTravelState, type TimelineEvent, type VDOMNodeInfo, type VisualLayoutEdge, type VisualLayoutGraph, type VisualLayoutNode, acknowledgeAlert, acknowledgeAllAlerts, addObserver, beginTimelineEvent, clearAlerts, clearBenchmarkResults, clearMetrics, clearPerformanceRecords, clearRouteHistory, clearSignalRegistry, clearSnapshots, clearStoreRegistry, clearTimelineEvents, compareBenchmarkResults, compareSnapshots, createLargeScaleBenchmark, createRegressionDetector, createSnapshot, installDevTools as default, dispatchStoreAction, endTimelineEvent, exportTimelineAsJSON, filterSignals, getAlertRules, getAlerts, getBenchmarkResults, getComponentTree, getCurrentRoute, getDependencyGraph, getDevTools, getDiffBetweenSnapshots, getFlameGraphData, getLatestBenchmarkResult, getMemoryUsage, getMetrics, getPerformanceRecords, getPerformanceReport, getPerformanceStats, getRegisteredStoreIds, getRouteHistory, getRoutes, getSignalNode, getSignalNodes, getSlowOperations, getSnapshots, getStats, getStoreState, getStoreStates, getSubgraph, getTimeTravelNavigator, getTimeTravelState, getTimelineEvents, getTimelineEventsInRange, getVisualLayoutGraph, goBack, initPerformanceMonitor, installDevTools, isRouterRegistered, navigateTo, navigateToName, onStoreChange, recordDependency, recordMetric, recordSignalUpdate, registerAlertRule, registerRootComponent, registerRouter, registerSignal, registerStore, removeObserver, resetPerformanceMonitor, restoreSnapshot, runAsyncBenchmark, runBenchmark, searchSignals, serializeAllBenchmarkResults, serializeBenchmarkResult, serializeComponentTree, serializeDependencyGraph, serializeMemoryUsage, serializePerformanceReport, serializePerformanceStats, serializeRouteInfo, serializeSignalNode, serializeSnapshotDiff, serializeStoreStates, serializeTimelineEvents, setAlertRuleEnabled, setStoreState, startTimer, subscribeStore, timeTravelBack, timeTravelForward, uninstallDevTools, unregisterAlertRule, unregisterRootComponent, unregisterRouter, unregisterSignal, unregisterStore, unsubscribeStore, unwatchRouteChanges, watchRouteChanges };