@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.
Files changed (42) hide show
  1. package/dist/index.cjs +1700 -564
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +743 -0
  4. package/dist/index.d.ts +743 -0
  5. package/dist/index.mjs +1613 -564
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +41 -26
  8. package/README.md +0 -153
  9. package/dist/types/batch-analyzer.d.ts +0 -150
  10. package/dist/types/batch-analyzer.d.ts.map +0 -1
  11. package/dist/types/component-profiler.d.ts +0 -144
  12. package/dist/types/component-profiler.d.ts.map +0 -1
  13. package/dist/types/component-tree.d.ts +0 -69
  14. package/dist/types/component-tree.d.ts.map +0 -1
  15. package/dist/types/event-panel.d.ts +0 -129
  16. package/dist/types/event-panel.d.ts.map +0 -1
  17. package/dist/types/event-tracker.d.ts +0 -80
  18. package/dist/types/event-tracker.d.ts.map +0 -1
  19. package/dist/types/hooks.d.ts +0 -177
  20. package/dist/types/hooks.d.ts.map +0 -1
  21. package/dist/types/index.d.ts +0 -185
  22. package/dist/types/index.d.ts.map +0 -1
  23. package/dist/types/memory-tracker.d.ts +0 -148
  24. package/dist/types/memory-tracker.d.ts.map +0 -1
  25. package/dist/types/panel.d.ts +0 -182
  26. package/dist/types/panel.d.ts.map +0 -1
  27. package/dist/types/perf-collector.d.ts +0 -328
  28. package/dist/types/perf-collector.d.ts.map +0 -1
  29. package/dist/types/perf-panel.d.ts +0 -231
  30. package/dist/types/perf-panel.d.ts.map +0 -1
  31. package/dist/types/render-tracker.d.ts +0 -147
  32. package/dist/types/render-tracker.d.ts.map +0 -1
  33. package/dist/types/route-panel.d.ts +0 -68
  34. package/dist/types/route-panel.d.ts.map +0 -1
  35. package/dist/types/router-panel-enhanced.d.ts +0 -118
  36. package/dist/types/router-panel-enhanced.d.ts.map +0 -1
  37. package/dist/types/state-inspector.d.ts +0 -80
  38. package/dist/types/state-inspector.d.ts.map +0 -1
  39. package/dist/types/time-travel.d.ts +0 -189
  40. package/dist/types/time-travel.d.ts.map +0 -1
  41. package/dist/types/virtual-tree.d.ts +0 -168
  42. package/dist/types/virtual-tree.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,619 +1,1668 @@
1
- var Ce=`
2
- /* === Lyt DevTools \u9762\u677F\u57FA\u7840\u6837\u5F0F === */
3
- .lyt-devtools-panel {
4
- position: fixed;
5
- z-index: 999999;
6
- background: #1e1e2e;
7
- border: 1px solid #313244;
8
- border-radius: 8px;
9
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
10
- font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
11
- font-size: 12px;
12
- color: #cdd6f4;
13
- display: flex;
14
- flex-direction: column;
15
- overflow: hidden;
16
- user-select: none;
17
- transition: opacity 0.2s ease;
18
- }
1
+ import { isObject, isFunction } from '@lytjs/common-is';
19
2
 
20
- /* === \u6807\u9898\u680F === */
21
- .lyt-devtools-header {
22
- display: flex;
23
- align-items: center;
24
- justify-content: space-between;
25
- padding: 0 12px;
26
- height: 36px;
27
- min-height: 36px;
28
- background: #181825;
29
- border-bottom: 1px solid #313244;
30
- cursor: move;
31
- border-radius: 8px 8px 0 0;
3
+ // src/componentTree.ts
4
+ var componentIdCounter = 0;
5
+ function generateComponentId() {
6
+ return `component-${++componentIdCounter}`;
32
7
  }
33
-
34
- .lyt-devtools-title {
35
- font-size: 13px;
36
- font-weight: 600;
37
- color: #cba6f7;
38
- display: flex;
39
- align-items: center;
40
- gap: 6px;
8
+ function extractComponentInfo(component) {
9
+ if (!component) return null;
10
+ const id = generateComponentId();
11
+ const name = component.name || component.displayName || "Anonymous";
12
+ const props = {};
13
+ if (component.props && isObject(component.props)) {
14
+ for (const [key, value] of Object.entries(component.props)) {
15
+ if (typeof value !== "function") {
16
+ props[key] = value;
17
+ }
18
+ }
19
+ }
20
+ return {
21
+ id,
22
+ name,
23
+ props: Object.keys(props).length > 0 ? props : void 0
24
+ };
41
25
  }
42
-
43
- .lyt-devtools-title-icon {
44
- font-size: 14px;
26
+ function buildComponentTreeRecursive(component, parentId) {
27
+ const node = extractComponentInfo(component);
28
+ if (!node) return null;
29
+ if (parentId) {
30
+ node.parent = parentId;
31
+ }
32
+ if (component.children && Array.isArray(component.children)) {
33
+ const children = [];
34
+ for (const child of component.children) {
35
+ const childNode = buildComponentTreeRecursive(child, node.id);
36
+ if (childNode) {
37
+ children.push(childNode);
38
+ }
39
+ }
40
+ if (children.length > 0) {
41
+ node.children = children;
42
+ }
43
+ }
44
+ return node;
45
45
  }
46
-
47
- .lyt-devtools-header-actions {
48
- display: flex;
49
- align-items: center;
50
- gap: 4px;
46
+ function getComponentTree(rootComponent) {
47
+ if (!rootComponent) {
48
+ const globalRoot = globalThis.__LYTJS_ROOT__;
49
+ if (!globalRoot) {
50
+ return [];
51
+ }
52
+ rootComponent = globalRoot;
53
+ }
54
+ const tree = buildComponentTreeRecursive(rootComponent);
55
+ return tree ? [tree] : [];
51
56
  }
52
-
53
- .lyt-devtools-btn {
54
- background: transparent;
55
- border: 1px solid transparent;
56
- color: #a6adc8;
57
- cursor: pointer;
58
- padding: 2px 6px;
59
- border-radius: 4px;
60
- font-size: 14px;
61
- line-height: 1;
62
- display: flex;
63
- align-items: center;
64
- justify-content: center;
65
- width: 24px;
66
- height: 24px;
67
- transition: all 0.15s ease;
57
+ function serializeComponentTree(nodes, indent = 0) {
58
+ let result = "";
59
+ const prefix = " ".repeat(indent);
60
+ for (const node of nodes) {
61
+ result += `${prefix}- ${node.name}`;
62
+ if (node.props && Object.keys(node.props).length > 0) {
63
+ const propsStr = Object.entries(node.props).map(([k, v]) => `${k}=${JSON.stringify(v)}`).join(", ");
64
+ result += ` (${propsStr})`;
65
+ }
66
+ result += "\n";
67
+ if (node.children && node.children.length > 0) {
68
+ result += serializeComponentTree(node.children, indent + 1);
69
+ }
70
+ }
71
+ return result;
68
72
  }
69
-
70
- .lyt-devtools-btn:hover {
71
- background: #313244;
72
- color: #cdd6f4;
73
- border-color: #45475a;
73
+ function registerRootComponent(component) {
74
+ globalThis.__LYTJS_ROOT__ = component;
74
75
  }
75
-
76
- .lyt-devtools-btn-close:hover {
77
- background: #f38ba8;
78
- color: #1e1e2e;
79
- border-color: #f38ba8;
76
+ function unregisterRootComponent() {
77
+ delete globalThis.__LYTJS_ROOT__;
80
78
  }
81
-
82
- /* === \u6807\u7B7E\u680F === */
83
- .lyt-devtools-tabs {
84
- display: flex;
85
- background: #181825;
86
- border-bottom: 1px solid #313244;
87
- padding: 0 8px;
88
- min-height: 32px;
79
+ var storeRegistry = /* @__PURE__ */ new Map();
80
+ var subscribers = /* @__PURE__ */ new Map();
81
+ var globalChangeCallbacks = /* @__PURE__ */ new Set();
82
+ function registerStore(id, store) {
83
+ storeRegistry.set(id, store);
89
84
  }
90
-
91
- .lyt-devtools-tab {
92
- padding: 6px 12px;
93
- cursor: pointer;
94
- color: #a6adc8;
95
- border-bottom: 2px solid transparent;
96
- transition: all 0.15s ease;
97
- font-size: 12px;
98
- display: flex;
99
- align-items: center;
100
- gap: 4px;
101
- white-space: nowrap;
85
+ function unregisterStore(id) {
86
+ storeRegistry.delete(id);
102
87
  }
103
-
104
- .lyt-devtools-tab:hover {
105
- color: #cdd6f4;
106
- background: #1e1e2e;
88
+ function getStoreStates() {
89
+ const states = [];
90
+ for (const [id, store] of storeRegistry.entries()) {
91
+ const stateInfo = {
92
+ id,
93
+ state: {}
94
+ };
95
+ if (store.$state) {
96
+ stateInfo.state = deepClone(store.$state);
97
+ } else if (isObject(store)) {
98
+ for (const [key, value] of Object.entries(store)) {
99
+ if (!key.startsWith("$") && !isFunction(value)) {
100
+ stateInfo.state[key] = deepClone(value);
101
+ }
102
+ }
103
+ }
104
+ if (store.$id) {
105
+ stateInfo.id = store.$id;
106
+ }
107
+ states.push(stateInfo);
108
+ }
109
+ return states;
107
110
  }
108
-
109
- .lyt-devtools-tab.active {
110
- color: #cba6f7;
111
- border-bottom-color: #cba6f7;
111
+ function getStoreState(storeId) {
112
+ const store = storeRegistry.get(storeId);
113
+ if (!store) return null;
114
+ const stateInfo = {
115
+ id: storeId,
116
+ state: {}
117
+ };
118
+ if (store.$state) {
119
+ stateInfo.state = deepClone(store.$state);
120
+ } else if (isObject(store)) {
121
+ for (const [key, value] of Object.entries(store)) {
122
+ if (!key.startsWith("$") && !isFunction(value)) {
123
+ stateInfo.state[key] = deepClone(value);
124
+ }
125
+ }
126
+ }
127
+ return stateInfo;
112
128
  }
113
-
114
- .lyt-devtools-tab-icon {
115
- font-size: 12px;
129
+ function setStoreState(storeId, path, value) {
130
+ const store = storeRegistry.get(storeId);
131
+ if (!store) return false;
132
+ const keys = path.split(".");
133
+ let current = store.$state || store;
134
+ for (let i = 0; i < keys.length - 1; i++) {
135
+ const key = keys[i];
136
+ if (!isObject(current[key])) {
137
+ return false;
138
+ }
139
+ current = current[key];
140
+ }
141
+ const lastKey = keys[keys.length - 1];
142
+ if (lastKey) {
143
+ current[lastKey] = value;
144
+ }
145
+ return true;
116
146
  }
117
-
118
- /* === \u5185\u5BB9\u533A\u57DF === */
119
- .lyt-devtools-content {
120
- flex: 1;
121
- overflow: auto;
122
- padding: 8px;
123
- background: #1e1e2e;
147
+ function dispatchStoreAction(storeId, actionName, ...args) {
148
+ const store = storeRegistry.get(storeId);
149
+ if (!store) return null;
150
+ const action = store[actionName];
151
+ if (!isFunction(action)) {
152
+ throw new Error(`Action "${actionName}" not found in store "${storeId}"`);
153
+ }
154
+ return action.apply(store, args);
124
155
  }
125
-
126
- .lyt-devtools-content::-webkit-scrollbar {
127
- width: 6px;
128
- height: 6px;
156
+ function serializeStoreStates(states) {
157
+ return JSON.stringify(states, null, 2);
129
158
  }
130
-
131
- .lyt-devtools-content::-webkit-scrollbar-track {
132
- background: transparent;
159
+ function deepClone(obj) {
160
+ if (obj === null || typeof obj !== "object") {
161
+ return obj;
162
+ }
163
+ if (obj instanceof Date) {
164
+ return new Date(obj.getTime());
165
+ }
166
+ if (Array.isArray(obj)) {
167
+ return obj.map((item) => deepClone(item));
168
+ }
169
+ if (isObject(obj)) {
170
+ const cloned = {};
171
+ for (const [key, value] of Object.entries(obj)) {
172
+ cloned[key] = deepClone(value);
173
+ }
174
+ return cloned;
175
+ }
176
+ return obj;
133
177
  }
134
-
135
- .lyt-devtools-content::-webkit-scrollbar-thumb {
136
- background: #45475a;
137
- border-radius: 3px;
178
+ function subscribeStore(storeId) {
179
+ const store = storeRegistry.get(storeId);
180
+ if (!store) return false;
181
+ if (subscribers.has(storeId)) {
182
+ unsubscribeStore(storeId);
183
+ }
184
+ if (isFunction(store.$subscribe)) {
185
+ const unsubscribe = store.$subscribe((_mutation, state) => {
186
+ const currentState = isObject(state) ? deepClone(state) : {};
187
+ globalChangeCallbacks.forEach((cb) => cb(storeId, currentState));
188
+ });
189
+ subscribers.set(storeId, isFunction(unsubscribe) ? unsubscribe : () => {
190
+ });
191
+ return true;
192
+ }
193
+ return false;
138
194
  }
139
-
140
- .lyt-devtools-content::-webkit-scrollbar-thumb:hover {
141
- background: #585b70;
195
+ function unsubscribeStore(storeId) {
196
+ const unsubscribe = subscribers.get(storeId);
197
+ if (unsubscribe) {
198
+ unsubscribe();
199
+ subscribers.delete(storeId);
200
+ }
142
201
  }
143
-
144
- /* === \u5E95\u90E8\u72B6\u6001\u680F === */
145
- .lyt-devtools-statusbar {
146
- display: flex;
147
- align-items: center;
148
- justify-content: space-between;
149
- padding: 0 12px;
150
- height: 24px;
151
- min-height: 24px;
152
- background: #181825;
153
- border-top: 1px solid #313244;
154
- font-size: 11px;
155
- color: #6c7086;
156
- border-radius: 0 0 8px 8px;
202
+ function onStoreChange(callback) {
203
+ globalChangeCallbacks.add(callback);
204
+ return () => {
205
+ globalChangeCallbacks.delete(callback);
206
+ };
157
207
  }
158
-
159
- .lyt-devtools-status-left {
160
- display: flex;
161
- align-items: center;
162
- gap: 8px;
208
+ function clearStoreRegistry() {
209
+ for (const storeId of subscribers.keys()) {
210
+ unsubscribeStore(storeId);
211
+ }
212
+ globalChangeCallbacks.clear();
213
+ storeRegistry.clear();
163
214
  }
164
-
165
- .lyt-devtools-status-right {
166
- display: flex;
167
- align-items: center;
168
- gap: 8px;
215
+ function getRegisteredStoreIds() {
216
+ return Array.from(storeRegistry.keys());
169
217
  }
170
-
171
- .lyt-devtools-status-dot {
172
- width: 6px;
173
- height: 6px;
174
- border-radius: 50%;
175
- background: #a6e3a1;
218
+ var routerInstance = null;
219
+ var routeHistory = [];
220
+ var afterEachHandler = null;
221
+ function registerRouter(router) {
222
+ routerInstance = router;
176
223
  }
177
-
178
- .lyt-devtools-status-dot.disconnected {
179
- background: #f38ba8;
224
+ function unregisterRouter() {
225
+ unwatchRouteChanges();
226
+ routerInstance = null;
180
227
  }
181
-
182
- /* === \u8C03\u6574\u5927\u5C0F\u624B\u67C4 === */
183
- .lyt-devtools-resize-handle {
184
- position: absolute;
185
- bottom: 0;
186
- right: 0;
187
- width: 16px;
188
- height: 16px;
189
- cursor: nwse-resize;
190
- z-index: 10;
228
+ function getCurrentRoute() {
229
+ if (!routerInstance) return null;
230
+ const currentRoute = routerInstance.currentRoute?.();
231
+ if (!currentRoute) return null;
232
+ return {
233
+ path: currentRoute.path || "/",
234
+ name: currentRoute.name || null,
235
+ params: currentRoute.params || {},
236
+ query: currentRoute.query || {},
237
+ matched: (currentRoute.matched || []).map((m) => ({
238
+ path: m.path || "",
239
+ name: m.name || null
240
+ }))
241
+ };
191
242
  }
192
-
193
- .lyt-devtools-resize-handle::after {
194
- content: '';
195
- position: absolute;
196
- bottom: 3px;
197
- right: 3px;
198
- width: 8px;
199
- height: 8px;
200
- border-right: 2px solid #585b70;
201
- border-bottom: 2px solid #585b70;
243
+ function getRouteHistory() {
244
+ return [...routeHistory];
202
245
  }
203
-
204
- /* === \u6298\u53E0\u72B6\u6001 === */
205
- .lyt-devtools-panel.collapsed .lyt-devtools-tabs,
206
- .lyt-devtools-panel.collapsed .lyt-devtools-content,
207
- .lyt-devtools-panel.collapsed .lyt-devtools-statusbar,
208
- .lyt-devtools-panel.collapsed .lyt-devtools-resize-handle {
209
- display: none;
246
+ function watchRouteChanges() {
247
+ if (!routerInstance) return false;
248
+ if (!isFunction(routerInstance.afterEach)) return false;
249
+ if (afterEachHandler !== null) {
250
+ unwatchRouteChanges();
251
+ }
252
+ routerInstance.afterEach((to) => {
253
+ const routeInfo = {
254
+ path: to.path || "/",
255
+ name: to.name || null,
256
+ params: to.params || {},
257
+ query: to.query || {},
258
+ matched: (to.matched || []).map((m) => ({
259
+ path: m.path || "",
260
+ name: m.name || null
261
+ }))
262
+ };
263
+ routeHistory.push(routeInfo);
264
+ });
265
+ afterEachHandler = () => {
266
+ afterEachHandler = null;
267
+ };
268
+ return true;
210
269
  }
211
-
212
- .lyt-devtools-panel.collapsed {
213
- width: auto !important;
214
- height: auto !important;
215
- border-radius: 8px;
270
+ function unwatchRouteChanges() {
271
+ if (afterEachHandler) {
272
+ afterEachHandler();
273
+ afterEachHandler = null;
274
+ }
216
275
  }
217
-
218
- /* === \u901A\u7528\u7EC4\u4EF6\u6837\u5F0F === */
219
- .lyt-devtools-search {
220
- width: 100%;
221
- padding: 6px 8px;
222
- background: #181825;
223
- border: 1px solid #313244;
224
- border-radius: 4px;
225
- color: #cdd6f4;
226
- font-size: 12px;
227
- font-family: inherit;
228
- outline: none;
229
- box-sizing: border-box;
230
- margin-bottom: 8px;
276
+ function navigateTo(path) {
277
+ if (!routerInstance) {
278
+ return Promise.reject(new Error("Router not registered"));
279
+ }
280
+ return routerInstance.push?.(path) || Promise.resolve();
231
281
  }
232
-
233
- .lyt-devtools-search:focus {
234
- border-color: #cba6f7;
282
+ function navigateToName(name, params) {
283
+ if (!routerInstance) {
284
+ return Promise.reject(new Error("Router not registered"));
285
+ }
286
+ return routerInstance.push?.({ name, params }) || Promise.resolve();
235
287
  }
236
-
237
- .lyt-devtools-search::placeholder {
238
- color: #585b70;
288
+ function goBack() {
289
+ if (!routerInstance) {
290
+ return Promise.reject(new Error("Router not registered"));
291
+ }
292
+ return routerInstance.back?.() || Promise.resolve();
293
+ }
294
+ function serializeRouteInfo(route) {
295
+ if (!route) return "No route information available";
296
+ let result = `Path: ${route.path}
297
+ `;
298
+ result += `Name: ${route.name || "N/A"}
299
+ `;
300
+ result += `Params: ${JSON.stringify(route.params)}
301
+ `;
302
+ result += `Query: ${JSON.stringify(route.query)}
303
+ `;
304
+ result += `Matched Routes:
305
+ `;
306
+ if (route.matched.length === 0) {
307
+ result += " (none)\n";
308
+ } else {
309
+ for (const match of route.matched) {
310
+ result += ` - ${match.path}${match.name ? ` (${match.name})` : ""}
311
+ `;
312
+ }
313
+ }
314
+ return result;
315
+ }
316
+ function getRoutes() {
317
+ if (!routerInstance) return [];
318
+ const routes = routerInstance.getRoutes?.() || [];
319
+ return routes.map((r) => ({
320
+ path: r.path || "",
321
+ name: r.name || null
322
+ }));
323
+ }
324
+ function isRouterRegistered() {
325
+ return routerInstance !== null;
326
+ }
327
+ function clearRouteHistory() {
328
+ routeHistory.length = 0;
239
329
  }
240
330
 
241
- .lyt-devtools-empty {
242
- text-align: center;
243
- color: #585b70;
244
- padding: 24px;
245
- font-style: italic;
331
+ // src/signalsInspector.ts
332
+ var signalRegistry = /* @__PURE__ */ new Map();
333
+ var snapshotManager = {
334
+ snapshots: [],
335
+ maxSnapshots: 100,
336
+ add(snapshot) {
337
+ this.snapshots.push(snapshot);
338
+ if (this.snapshots.length > this.maxSnapshots) {
339
+ this.snapshots.shift();
340
+ }
341
+ },
342
+ getAll() {
343
+ return [...this.snapshots];
344
+ },
345
+ get(index) {
346
+ return this.snapshots[index];
347
+ },
348
+ clear() {
349
+ this.snapshots = [];
350
+ },
351
+ getLength() {
352
+ return this.snapshots.length;
353
+ }
354
+ };
355
+ var performanceRecords = [];
356
+ var maxPerformanceRecords = 1e3;
357
+ function registerSignal(id, name, type, initialValue) {
358
+ signalRegistry.set(id, {
359
+ type,
360
+ name,
361
+ dependencies: /* @__PURE__ */ new Set(),
362
+ dependents: /* @__PURE__ */ new Set(),
363
+ value: initialValue,
364
+ updateCount: 0,
365
+ updateTimes: [],
366
+ lastUpdateTime: 0
367
+ });
368
+ }
369
+ function unregisterSignal(id) {
370
+ const node = signalRegistry.get(id);
371
+ if (node) {
372
+ node.dependencies.forEach((depId) => {
373
+ const dep = signalRegistry.get(depId);
374
+ if (dep) {
375
+ dep.dependents.delete(id);
376
+ }
377
+ });
378
+ node.dependents.forEach((depId) => {
379
+ const dep = signalRegistry.get(depId);
380
+ if (dep) {
381
+ dep.dependencies.delete(id);
382
+ }
383
+ });
384
+ }
385
+ signalRegistry.delete(id);
386
+ }
387
+ function recordSignalUpdate(id, newValue, duration) {
388
+ const node = signalRegistry.get(id);
389
+ if (node) {
390
+ node.previousValue = node.value;
391
+ node.value = newValue;
392
+ node.updateCount++;
393
+ node.lastUpdateTime = Date.now();
394
+ if (duration !== void 0) {
395
+ node.updateTimes.push(duration);
396
+ if (node.updateTimes.length > 10) {
397
+ node.updateTimes.shift();
398
+ }
399
+ }
400
+ if (duration !== void 0) {
401
+ recordPerformance({
402
+ id,
403
+ name: node.name,
404
+ type: node.type,
405
+ duration,
406
+ timestamp: Date.now()
407
+ });
408
+ }
409
+ }
410
+ }
411
+ function recordDependency(sourceId, targetId) {
412
+ const source = signalRegistry.get(sourceId);
413
+ const target = signalRegistry.get(targetId);
414
+ if (source && target) {
415
+ source.dependencies.add(targetId);
416
+ target.dependents.add(sourceId);
417
+ }
418
+ }
419
+ function getSignalNodes() {
420
+ return Array.from(signalRegistry.entries()).map(([id, node]) => ({
421
+ id,
422
+ name: node.name,
423
+ type: node.type,
424
+ value: node.value,
425
+ previousValue: node.previousValue,
426
+ dependencies: Array.from(node.dependencies),
427
+ dependents: Array.from(node.dependents),
428
+ updateCount: node.updateCount,
429
+ lastUpdateTime: node.lastUpdateTime,
430
+ averageUpdateTime: node.updateTimes.length > 0 ? node.updateTimes.reduce((a, b) => a + b, 0) / node.updateTimes.length : 0
431
+ }));
432
+ }
433
+ function getSignalNode(id) {
434
+ const node = signalRegistry.get(id);
435
+ if (!node) return void 0;
436
+ return {
437
+ id,
438
+ name: node.name,
439
+ type: node.type,
440
+ value: node.value,
441
+ previousValue: node.previousValue,
442
+ dependencies: Array.from(node.dependencies),
443
+ dependents: Array.from(node.dependents),
444
+ updateCount: node.updateCount,
445
+ lastUpdateTime: node.lastUpdateTime,
446
+ averageUpdateTime: node.updateTimes.length > 0 ? node.updateTimes.reduce((a, b) => a + b, 0) / node.updateTimes.length : 0
447
+ };
448
+ }
449
+ function getDependencyGraph() {
450
+ const nodes = [];
451
+ const edges = [];
452
+ signalRegistry.forEach((node, id) => {
453
+ nodes.push({
454
+ id,
455
+ name: node.name,
456
+ type: node.type
457
+ });
458
+ node.dependencies.forEach((depId) => {
459
+ edges.push({
460
+ source: depId,
461
+ target: id,
462
+ type: "dependency"
463
+ });
464
+ });
465
+ });
466
+ return { nodes, edges };
467
+ }
468
+ function createSnapshot(label) {
469
+ const snapshot = {
470
+ id: `snapshot_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
471
+ timestamp: Date.now(),
472
+ label,
473
+ signals: {}
474
+ };
475
+ signalRegistry.forEach((node, id) => {
476
+ snapshot.signals[id] = {
477
+ value: node.value,
478
+ dependencies: Array.from(node.dependencies)
479
+ };
480
+ });
481
+ snapshotManager.add(snapshot);
482
+ return snapshot;
483
+ }
484
+ function getSnapshots() {
485
+ return snapshotManager.getAll();
486
+ }
487
+ function getTimeTravelState() {
488
+ const length = snapshotManager.getLength();
489
+ return {
490
+ snapshots: snapshotManager.getAll(),
491
+ currentIndex: length - 1,
492
+ canUndo: length > 1,
493
+ canRedo: false
494
+ };
495
+ }
496
+ function restoreSnapshot(index) {
497
+ const snapshot = snapshotManager.get(index);
498
+ if (!snapshot) return void 0;
499
+ Object.entries(snapshot.signals).forEach(([id, signalSnapshot]) => {
500
+ const node = signalRegistry.get(id);
501
+ if (node) {
502
+ node.value = signalSnapshot.value;
503
+ }
504
+ });
505
+ return snapshot;
506
+ }
507
+ function clearSnapshots() {
508
+ snapshotManager.clear();
509
+ }
510
+ function recordPerformance(record) {
511
+ performanceRecords.push(record);
512
+ if (performanceRecords.length > maxPerformanceRecords) {
513
+ performanceRecords.shift();
514
+ }
515
+ }
516
+ function getPerformanceRecords(limit) {
517
+ const records = [...performanceRecords];
518
+ if (limit !== void 0) {
519
+ return records.slice(-limit);
520
+ }
521
+ return records;
522
+ }
523
+ function getPerformanceStats() {
524
+ if (performanceRecords.length === 0) {
525
+ return {
526
+ totalRecords: 0,
527
+ averageDuration: 0,
528
+ maxDuration: 0,
529
+ minDuration: 0,
530
+ byType: {}
531
+ };
532
+ }
533
+ const durations = performanceRecords.map((r) => r.duration);
534
+ const byType = {};
535
+ performanceRecords.forEach((record) => {
536
+ if (!byType[record.type]) {
537
+ byType[record.type] = { count: 0, total: 0, max: 0 };
538
+ }
539
+ const typeStats = byType[record.type];
540
+ typeStats.count++;
541
+ typeStats.total += record.duration;
542
+ typeStats.max = Math.max(typeStats.max, record.duration);
543
+ });
544
+ const byTypeResult = {};
545
+ Object.entries(byType).forEach(([type, data]) => {
546
+ byTypeResult[type] = {
547
+ count: data.count,
548
+ average: data.total / data.count,
549
+ max: data.max
550
+ };
551
+ });
552
+ return {
553
+ totalRecords: performanceRecords.length,
554
+ averageDuration: durations.reduce((a, b) => a + b, 0) / durations.length,
555
+ maxDuration: Math.max(...durations),
556
+ minDuration: Math.min(...durations),
557
+ byType: byTypeResult
558
+ };
559
+ }
560
+ function clearPerformanceRecords() {
561
+ performanceRecords.length = 0;
246
562
  }
563
+ function clearSignalRegistry() {
564
+ signalRegistry.clear();
565
+ }
566
+ function serializeSignalNode(node) {
567
+ let result = `\u{1F4CA} ${node.name} (${node.type})
568
+ `;
569
+ result += ` ID: ${node.id}
570
+ `;
571
+ result += ` \u66F4\u65B0\u6B21\u6570: ${node.updateCount}
572
+ `;
573
+ result += ` \u6700\u540E\u66F4\u65B0: ${new Date(node.lastUpdateTime).toLocaleTimeString()}
574
+ `;
575
+ if (node.averageUpdateTime > 0) {
576
+ result += ` \u5E73\u5747\u66F4\u65B0\u8017\u65F6: ${node.averageUpdateTime.toFixed(2)}ms
577
+ `;
578
+ }
579
+ if (node.dependencies.length > 0) {
580
+ result += ` \u4F9D\u8D56: ${node.dependencies.join(", ")}
581
+ `;
582
+ }
583
+ if (node.dependents.length > 0) {
584
+ result += ` \u88AB\u4F9D\u8D56: ${node.dependents.join(", ")}
585
+ `;
586
+ }
587
+ return result;
588
+ }
589
+ function serializeDependencyGraph() {
590
+ const graph = getDependencyGraph();
591
+ if (graph.nodes.length === 0) {
592
+ return "\u6682\u65E0\u4FE1\u53F7\u6570\u636E";
593
+ }
594
+ let result = `\u{1F4C8} \u4F9D\u8D56\u56FE (${graph.nodes.length} \u4E2A\u8282\u70B9, ${graph.edges.length} \u6761\u8FB9)
247
595
 
248
- .lyt-devtools-badge {
249
- display: inline-block;
250
- padding: 1px 5px;
251
- border-radius: 3px;
252
- font-size: 10px;
253
- font-weight: 600;
596
+ `;
597
+ graph.nodes.forEach((node) => {
598
+ const nodeInfo = signalRegistry.get(node.id);
599
+ const deps = nodeInfo?.dependencies || /* @__PURE__ */ new Set();
600
+ const dependents = nodeInfo?.dependents || /* @__PURE__ */ new Set();
601
+ result += `\u{1F539} ${node.name} (${node.type})
602
+ `;
603
+ if (deps.size > 0) {
604
+ result += ` \u2193 \u4F9D\u8D56: ${Array.from(deps).join(", ")}
605
+ `;
606
+ }
607
+ if (dependents.size > 0) {
608
+ result += ` \u2191 \u88AB\u4F9D\u8D56: ${Array.from(dependents).join(", ")}
609
+ `;
610
+ }
611
+ result += "\n";
612
+ });
613
+ return result;
254
614
  }
615
+ function serializePerformanceStats() {
616
+ const stats = getPerformanceStats();
617
+ if (stats.totalRecords === 0) {
618
+ return "\u6682\u65E0\u6027\u80FD\u6570\u636E";
619
+ }
620
+ let result = `\u26A1 \u6027\u80FD\u7EDF\u8BA1
255
621
 
256
- .lyt-devtools-badge-blue {
257
- background: #89b4fa;
258
- color: #1e1e2e;
622
+ `;
623
+ result += `\u603B\u8BB0\u5F55\u6570: ${stats.totalRecords}
624
+ `;
625
+ result += `\u5E73\u5747\u8017\u65F6: ${stats.averageDuration.toFixed(2)}ms
626
+ `;
627
+ result += `\u6700\u5927\u8017\u65F6: ${stats.maxDuration.toFixed(2)}ms
628
+ `;
629
+ result += `\u6700\u5C0F\u8017\u65F6: ${stats.minDuration.toFixed(2)}ms
630
+
631
+ `;
632
+ result += `\u6309\u7C7B\u578B\u7EDF\u8BA1:
633
+ `;
634
+ Object.entries(stats.byType).forEach(([type, data]) => {
635
+ result += ` ${type}: ${data.count} \u6B21, \u5E73\u5747 ${data.average.toFixed(2)}ms, \u6700\u5927 ${data.max.toFixed(2)}ms
636
+ `;
637
+ });
638
+ return result;
259
639
  }
260
640
 
261
- .lyt-devtools-badge-green {
262
- background: #a6e3a1;
263
- color: #1e1e2e;
641
+ // src/performance.ts
642
+ var DEFAULT_OPTIONS = {
643
+ enabled: true,
644
+ maxRecords: 1e3,
645
+ sampleRate: 1,
646
+ autoRecordPageMetrics: true,
647
+ autoRecordLongTasks: true,
648
+ longTaskThreshold: 50
649
+ };
650
+ var metrics = [];
651
+ var alertRules = /* @__PURE__ */ new Map();
652
+ var alerts = [];
653
+ var alertCooldowns = /* @__PURE__ */ new Map();
654
+ var options = { ...DEFAULT_OPTIONS };
655
+ var observers = /* @__PURE__ */ new Set();
656
+ function initPerformanceMonitor(opts) {
657
+ options = { ...DEFAULT_OPTIONS, ...opts };
658
+ if (options.enabled) {
659
+ if (options.autoRecordPageMetrics) {
660
+ initPageMetrics();
661
+ }
662
+ if (options.autoRecordLongTasks) {
663
+ initLongTaskObserver();
664
+ }
665
+ initDefaultAlertRules();
666
+ }
667
+ }
668
+ function initPageMetrics() {
669
+ if (typeof window === "undefined") return;
670
+ if (typeof PerformanceObserver !== "undefined") {
671
+ try {
672
+ new PerformanceObserver((list) => {
673
+ for (const entry of list.getEntries()) {
674
+ if (entry.entryType === "paint") {
675
+ recordMetric({
676
+ name: entry.name,
677
+ type: "custom",
678
+ duration: entry.startTime,
679
+ metadata: { entryType: entry.entryType }
680
+ });
681
+ }
682
+ }
683
+ }).observe({ type: "paint", buffered: true });
684
+ } catch (e) {
685
+ console.warn("[LytJS Performance] Failed to observe paint metrics:", e);
686
+ }
687
+ try {
688
+ new PerformanceObserver((list) => {
689
+ for (const entry of list.getEntries()) {
690
+ const firstInputEntry = entry;
691
+ if (firstInputEntry.processingStart !== void 0) {
692
+ recordMetric({
693
+ name: "First Input Delay",
694
+ type: "custom",
695
+ duration: firstInputEntry.processingStart - firstInputEntry.startTime,
696
+ metadata: { entryType: entry.entryType }
697
+ });
698
+ }
699
+ }
700
+ }).observe({ type: "first-input", buffered: true });
701
+ } catch (e) {
702
+ console.warn("[LytJS Performance] Failed to observe first-input:", e);
703
+ }
704
+ }
705
+ }
706
+ function initLongTaskObserver() {
707
+ if (typeof PerformanceObserver === "undefined") return;
708
+ try {
709
+ new PerformanceObserver((list) => {
710
+ for (const entry of list.getEntries()) {
711
+ if (entry.entryType === "longtask") {
712
+ recordMetric({
713
+ name: "Long Task",
714
+ type: "custom",
715
+ duration: entry.duration,
716
+ metadata: { attribution: entry.attribution }
717
+ });
718
+ }
719
+ }
720
+ }).observe({ type: "longtask", buffered: true });
721
+ } catch (e) {
722
+ console.warn("[LytJS Performance] Failed to observe long tasks:", e);
723
+ }
724
+ }
725
+ function initDefaultAlertRules() {
726
+ registerAlertRule({
727
+ id: "long_task_warning",
728
+ name: "\u957F\u4EFB\u52A1\u8B66\u544A",
729
+ level: "warning",
730
+ condition: (metric) => metric.duration > options.longTaskThreshold,
731
+ message: "\u68C0\u6D4B\u5230\u957F\u4EFB\u52A1: {{name}}, \u8017\u65F6 {{duration}}ms",
732
+ enabled: true,
733
+ cooldown: 5e3
734
+ });
735
+ registerAlertRule({
736
+ id: "slow_render_error",
737
+ name: "\u6E32\u67D3\u8FC7\u6162",
738
+ level: "error",
739
+ condition: (metric, stats) => metric.duration > stats.p99 * 1.5 && stats.count > 10,
740
+ message: "\u6E32\u67D3\u6027\u80FD\u5F02\u5E38: {{name}}, \u8017\u65F6 {{duration}}ms",
741
+ enabled: true,
742
+ cooldown: 1e4
743
+ });
744
+ registerAlertRule({
745
+ id: "critical_render",
746
+ name: "\u4E25\u91CD\u6E32\u67D3\u95EE\u9898",
747
+ level: "critical",
748
+ condition: (metric) => metric.duration > 500,
749
+ message: "\u4E25\u91CD\u6027\u80FD\u95EE\u9898: {{name}} \u8017\u65F6\u8D85\u8FC7 500ms!",
750
+ enabled: true,
751
+ cooldown: 3e4
752
+ });
753
+ }
754
+ function recordMetric(metric) {
755
+ if (!options.enabled) {
756
+ return { id: "", timestamp: 0, ...metric };
757
+ }
758
+ if (Math.random() > options.sampleRate) {
759
+ return { id: "", timestamp: 0, ...metric };
760
+ }
761
+ const fullMetric = {
762
+ id: `metric_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
763
+ timestamp: Date.now(),
764
+ ...metric
765
+ };
766
+ metrics.push(fullMetric);
767
+ if (metrics.length > options.maxRecords) {
768
+ metrics.shift();
769
+ }
770
+ observers.forEach((cb) => cb(fullMetric));
771
+ checkAlertRules(fullMetric);
772
+ return fullMetric;
773
+ }
774
+ function getMetrics(limit) {
775
+ const result = [...metrics];
776
+ if (limit !== void 0) {
777
+ return result.slice(-limit);
778
+ }
779
+ return result;
780
+ }
781
+ function getStats(type) {
782
+ const filteredMetrics = type ? metrics.filter((m) => m.type === type) : [...metrics];
783
+ if (filteredMetrics.length === 0) {
784
+ return {
785
+ count: 0,
786
+ total: 0,
787
+ average: 0,
788
+ min: 0,
789
+ max: 0,
790
+ p50: 0,
791
+ p90: 0,
792
+ p99: 0
793
+ };
794
+ }
795
+ const durations = filteredMetrics.map((m) => m.duration).sort((a, b) => a - b);
796
+ const total = durations.reduce((a, b) => a + b, 0);
797
+ return {
798
+ count: durations.length,
799
+ total,
800
+ average: total / durations.length,
801
+ min: durations[0] ?? 0,
802
+ max: durations[durations.length - 1] ?? 0,
803
+ p50: percentile(durations, 50),
804
+ p90: percentile(durations, 90),
805
+ p99: percentile(durations, 99)
806
+ };
807
+ }
808
+ function percentile(sortedArray, p) {
809
+ if (sortedArray.length === 0) return 0;
810
+ const index = Math.ceil(sortedArray.length * p / 100) - 1;
811
+ return sortedArray[Math.max(0, index)] ?? 0;
812
+ }
813
+ function registerAlertRule(rule) {
814
+ alertRules.set(rule.id, rule);
815
+ }
816
+ function unregisterAlertRule(ruleId) {
817
+ alertRules.delete(ruleId);
818
+ }
819
+ function setAlertRuleEnabled(ruleId, enabled) {
820
+ const rule = alertRules.get(ruleId);
821
+ if (rule) {
822
+ rule.enabled = enabled;
823
+ }
824
+ }
825
+ function getAlertRules() {
826
+ return Array.from(alertRules.values());
827
+ }
828
+ function getAlerts(includeAcknowledged = true) {
829
+ if (includeAcknowledged) {
830
+ return [...alerts];
831
+ }
832
+ return alerts.filter((a) => !a.acknowledged);
833
+ }
834
+ function acknowledgeAlert(alertId) {
835
+ const alert = alerts.find((a) => a.id === alertId);
836
+ if (alert) {
837
+ alert.acknowledged = true;
838
+ }
264
839
  }
840
+ function acknowledgeAllAlerts() {
841
+ alerts.forEach((alert) => {
842
+ alert.acknowledged = true;
843
+ });
844
+ }
845
+ function clearAlerts() {
846
+ alerts.length = 0;
847
+ }
848
+ function checkAlertRules(metric) {
849
+ const stats = getStats(metric.type);
850
+ alertRules.forEach((rule) => {
851
+ if (!rule.enabled) return;
852
+ const lastTriggered = alertCooldowns.get(rule.id) || 0;
853
+ if (Date.now() - lastTriggered < rule.cooldown) return;
854
+ if (rule.condition(metric, stats)) {
855
+ const alert = {
856
+ id: `alert_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
857
+ ruleId: rule.id,
858
+ ruleName: rule.name,
859
+ level: rule.level,
860
+ message: interpolateMessage(rule.message, metric),
861
+ metric,
862
+ timestamp: Date.now(),
863
+ acknowledged: false
864
+ };
865
+ alerts.push(alert);
866
+ alertCooldowns.set(rule.id, Date.now());
867
+ if (alerts.length > 100) {
868
+ alerts.shift();
869
+ }
870
+ outputAlert(alert);
871
+ }
872
+ });
873
+ }
874
+ function interpolateMessage(message, metric) {
875
+ return message.replace(/\{\{name\}\}/g, metric.name).replace(/\{\{duration\}\}/g, metric.duration.toFixed(2)).replace(/\{\{type\}\}/g, metric.type);
876
+ }
877
+ function outputAlert(alert) {
878
+ const levelStyles = {
879
+ info: "color: #1890ff;",
880
+ warning: "color: #faad14;",
881
+ error: "color: #ff4d4f;",
882
+ critical: "color: #722ed1; background: #ff4d4f; padding: 2px 5px;"
883
+ };
884
+ console.log(
885
+ `%c[LytJS Alert] ${alert.ruleName}%c ${alert.message}`,
886
+ levelStyles[alert.level],
887
+ "color: inherit;"
888
+ );
889
+ }
890
+ function addObserver(callback) {
891
+ observers.add(callback);
892
+ }
893
+ function removeObserver(callback) {
894
+ observers.delete(callback);
895
+ }
896
+ function clearMetrics() {
897
+ metrics.length = 0;
898
+ }
899
+ function resetPerformanceMonitor() {
900
+ metrics.length = 0;
901
+ alerts.length = 0;
902
+ observers.clear();
903
+ alertCooldowns.clear();
904
+ alertRules.clear();
905
+ }
906
+ function getPerformanceReport() {
907
+ const stats = {
908
+ render: getStats("render"),
909
+ update: getStats("update"),
910
+ effect: getStats("effect"),
911
+ computed: getStats("computed"),
912
+ reaction: getStats("reaction"),
913
+ custom: getStats("custom")
914
+ };
915
+ const allStats = getStats();
916
+ return {
917
+ metrics: [...metrics],
918
+ stats,
919
+ alerts: [...alerts],
920
+ summary: {
921
+ totalMetrics: metrics.length,
922
+ totalAlerts: alerts.length,
923
+ unacknowledgedAlerts: alerts.filter((a) => !a.acknowledged).length,
924
+ averageDuration: allStats.average
925
+ }
926
+ };
927
+ }
928
+ function serializePerformanceReport() {
929
+ const report = getPerformanceReport();
930
+ let result = `\u26A1 \u6027\u80FD\u62A5\u544A
265
931
 
266
- .lyt-devtools-badge-yellow {
267
- background: #f9e2af;
268
- color: #1e1e2e;
932
+ `;
933
+ result += `\u{1F4CA} \u7EDF\u8BA1\u6458\u8981:
934
+ `;
935
+ result += ` \u603B\u8BB0\u5F55\u6570: ${report.summary.totalMetrics}
936
+ `;
937
+ result += ` \u5E73\u5747\u8017\u65F6: ${report.summary.averageDuration.toFixed(2)}ms
938
+ `;
939
+ result += ` \u603B\u544A\u8B66\u6570: ${report.summary.totalAlerts}
940
+ `;
941
+ result += ` \u672A\u786E\u8BA4\u544A\u8B66: ${report.summary.unacknowledgedAlerts}
942
+
943
+ `;
944
+ result += `\u{1F4C8} \u5206\u7C7B\u578B\u7EDF\u8BA1:
945
+ `;
946
+ Object.entries(report.stats).forEach(([type, stats]) => {
947
+ if (stats.count > 0) {
948
+ result += ` ${type}: ${stats.count} \u6B21, \u5E73\u5747 ${stats.average.toFixed(2)}ms, \u6700\u5927 ${stats.max.toFixed(2)}ms
949
+ `;
950
+ }
951
+ });
952
+ if (report.alerts.length > 0) {
953
+ result += `
954
+ \u{1F6A8} \u6700\u8FD1\u544A\u8B66:
955
+ `;
956
+ report.alerts.slice(-5).forEach((alert) => {
957
+ const levelIcon = alert.level === "critical" ? "\u{1F534}" : alert.level === "error" ? "\u274C" : alert.level === "warning" ? "\u26A0\uFE0F" : "\u2139\uFE0F";
958
+ result += ` ${levelIcon} [${alert.level}] ${alert.ruleName}: ${alert.message}
959
+ `;
960
+ });
961
+ }
962
+ return result;
963
+ }
964
+ function startTimer(name, type = "custom") {
965
+ const startTime = performance.now();
966
+ return () => {
967
+ const duration = performance.now() - startTime;
968
+ recordMetric({ name, type, duration });
969
+ };
269
970
  }
270
971
 
271
- .lyt-devtools-badge-red {
272
- background: #f38ba8;
273
- color: #1e1e2e;
972
+ // src/benchmark.ts
973
+ var LARGE_SCALE_SCENARIOS = [
974
+ { name: "\u865A\u62DF\u5217\u8868-1000\u8282\u70B9", nodeCount: 1e3, description: "1000 \u4E2A\u865A\u62DF\u5217\u8868\u8282\u70B9\u6E32\u67D3" },
975
+ { name: "\u865A\u62DF\u5217\u8868-5000\u8282\u70B9", nodeCount: 5e3, description: "5000 \u4E2A\u865A\u62DF\u5217\u8868\u8282\u70B9\u6E32\u67D3" },
976
+ { name: "\u865A\u62DF\u5217\u8868-10000\u8282\u70B9", nodeCount: 1e4, description: "10000 \u4E2A\u865A\u62DF\u5217\u8868\u8282\u70B9\u6E32\u67D3" },
977
+ { name: "\u7EC4\u4EF6\u6811-100\u7EC4\u4EF6", nodeCount: 100, description: "100 \u4E2A\u7EC4\u4EF6\u540C\u65F6\u6E32\u67D3" },
978
+ { name: "\u7EC4\u4EF6\u6811-500\u7EC4\u4EF6", nodeCount: 500, description: "500 \u4E2A\u7EC4\u4EF6\u540C\u65F6\u6E32\u67D3" },
979
+ { name: "\u7EC4\u4EF6\u6811-1000\u7EC4\u4EF6", nodeCount: 1e3, description: "1000 \u4E2A\u7EC4\u4EF6\u540C\u65F6\u6E32\u67D3" },
980
+ { name: "\u4FE1\u53F7\u8FFD\u8E2A-500\u4FE1\u53F7", nodeCount: 500, description: "500 \u4E2A\u4FE1\u53F7\u540C\u65F6\u8FFD\u8E2A" },
981
+ { name: "\u4FE1\u53F7\u8FFD\u8E2A-1000\u4FE1\u53F7", nodeCount: 1e3, description: "1000 \u4E2A\u4FE1\u53F7\u540C\u65F6\u8FFD\u8E2A" }
982
+ ];
983
+ var benchmarkResults = /* @__PURE__ */ new Map();
984
+ function runBenchmark(config) {
985
+ const { name, iterations, warmup = 10, fn } = config;
986
+ for (let i = 0; i < warmup; i++) {
987
+ fn();
988
+ }
989
+ const durations = [];
990
+ const startTime = performance.now();
991
+ for (let i = 0; i < iterations; i++) {
992
+ const iterStart = performance.now();
993
+ fn();
994
+ durations.push(performance.now() - iterStart);
995
+ }
996
+ const totalDuration = performance.now() - startTime;
997
+ const result = {
998
+ name,
999
+ iterations,
1000
+ totalDuration,
1001
+ averageDuration: durations.reduce((a, b) => a + b, 0) / durations.length,
1002
+ minDuration: Math.min(...durations),
1003
+ maxDuration: Math.max(...durations),
1004
+ opsPerSecond: iterations / totalDuration * 1e3,
1005
+ timestamp: Date.now()
1006
+ };
1007
+ storeBenchmarkResult(name, result);
1008
+ return result;
1009
+ }
1010
+ async function runAsyncBenchmark(config) {
1011
+ const { name, iterations, warmup = 10, asyncFn } = config;
1012
+ if (!asyncFn) {
1013
+ throw new Error("asyncFn is required for async benchmark");
1014
+ }
1015
+ for (let i = 0; i < warmup; i++) {
1016
+ await asyncFn();
1017
+ }
1018
+ const durations = [];
1019
+ const startTime = performance.now();
1020
+ for (let i = 0; i < iterations; i++) {
1021
+ const iterStart = performance.now();
1022
+ await asyncFn();
1023
+ durations.push(performance.now() - iterStart);
1024
+ }
1025
+ const totalDuration = performance.now() - startTime;
1026
+ const result = {
1027
+ name,
1028
+ iterations,
1029
+ totalDuration,
1030
+ averageDuration: durations.reduce((a, b) => a + b, 0) / durations.length,
1031
+ minDuration: Math.min(...durations),
1032
+ maxDuration: Math.max(...durations),
1033
+ opsPerSecond: iterations / totalDuration * 1e3,
1034
+ timestamp: Date.now()
1035
+ };
1036
+ storeBenchmarkResult(name, result);
1037
+ return result;
1038
+ }
1039
+ function storeBenchmarkResult(name, result) {
1040
+ if (!benchmarkResults.has(name)) {
1041
+ benchmarkResults.set(name, []);
1042
+ }
1043
+ const results = benchmarkResults.get(name);
1044
+ results.push(result);
1045
+ if (results.length > 100) {
1046
+ results.shift();
1047
+ }
1048
+ }
1049
+ function getBenchmarkResults(name) {
1050
+ if (name) {
1051
+ return benchmarkResults.get(name) || [];
1052
+ }
1053
+ const allResults = [];
1054
+ benchmarkResults.forEach((results) => {
1055
+ allResults.push(...results);
1056
+ });
1057
+ return allResults.sort((a, b) => b.timestamp - a.timestamp);
1058
+ }
1059
+ function getLatestBenchmarkResult(name) {
1060
+ const results = benchmarkResults.get(name);
1061
+ if (!results || results.length === 0) return void 0;
1062
+ return results[results.length - 1];
274
1063
  }
1064
+ function clearBenchmarkResults(name) {
1065
+ if (name) {
1066
+ benchmarkResults.delete(name);
1067
+ } else {
1068
+ benchmarkResults.clear();
1069
+ }
1070
+ }
1071
+ function serializeBenchmarkResult(result) {
1072
+ return `
1073
+ \u{1F4CA} ${result.name}
1074
+ \u8FED\u4EE3\u6B21\u6570: ${result.iterations}
1075
+ \u603B\u8017\u65F6: ${result.totalDuration.toFixed(2)}ms
1076
+ \u5E73\u5747\u8017\u65F6: ${result.averageDuration.toFixed(4)}ms
1077
+ \u6700\u5C0F\u8017\u65F6: ${result.minDuration.toFixed(4)}ms
1078
+ \u6700\u5927\u8017\u65F6: ${result.maxDuration.toFixed(4)}ms
1079
+ OPS: ${result.opsPerSecond.toFixed(2)} ops/s
1080
+ \u65F6\u95F4: ${new Date(result.timestamp).toLocaleString()}
1081
+ `.trim();
1082
+ }
1083
+ function serializeAllBenchmarkResults() {
1084
+ const allResults = getBenchmarkResults();
1085
+ if (allResults.length === 0) {
1086
+ return "\u6682\u65E0\u57FA\u51C6\u6D4B\u8BD5\u7ED3\u679C";
1087
+ }
1088
+ let result = `\u{1F4C8} \u57FA\u51C6\u6D4B\u8BD5\u62A5\u544A (${allResults.length} \u6761\u8BB0\u5F55)
275
1089
 
276
- /* === \u9AD8\u4EAE\u52A8\u753B === */
277
- @keyframes lyt-devtools-highlight {
278
- 0% { background-color: rgba(203, 166, 247, 0.3); }
279
- 100% { background-color: transparent; }
1090
+ `;
1091
+ const grouped = /* @__PURE__ */ new Map();
1092
+ allResults.forEach((r) => {
1093
+ if (!grouped.has(r.name)) {
1094
+ grouped.set(r.name, []);
1095
+ }
1096
+ grouped.get(r.name).push(r);
1097
+ });
1098
+ grouped.forEach((results, name) => {
1099
+ const latest = results[results.length - 1];
1100
+ if (latest) {
1101
+ result += `\u{1F539} ${name}
1102
+ `;
1103
+ result += ` \u6700\u65B0: ${latest.averageDuration.toFixed(4)}ms (${latest.opsPerSecond.toFixed(2)} ops/s)
1104
+ `;
1105
+ result += ` \u5386\u53F2: ${results.length} \u6B21\u6D4B\u8BD5
1106
+ `;
1107
+ result += "\n";
1108
+ }
1109
+ });
1110
+ return result;
1111
+ }
1112
+ function compareBenchmarkResults(oldResult, newResult) {
1113
+ const durationDiff = oldResult.averageDuration - newResult.averageDuration;
1114
+ const durationDiffPercent = durationDiff / oldResult.averageDuration * 100;
1115
+ const opsDiff = newResult.opsPerSecond - oldResult.opsPerSecond;
1116
+ const opsDiffPercent = opsDiff / oldResult.opsPerSecond * 100;
1117
+ return {
1118
+ durationDiff,
1119
+ durationDiffPercent,
1120
+ opsDiff,
1121
+ opsDiffPercent,
1122
+ improved: durationDiff > 0
1123
+ };
1124
+ }
1125
+ function createLargeScaleBenchmark(scenario, testFn) {
1126
+ return {
1127
+ name: `\u5927\u89C4\u6A21\u6D4B\u8BD5-${scenario.name}`,
1128
+ iterations: 100,
1129
+ warmup: 10,
1130
+ fn: () => testFn(scenario.nodeCount)
1131
+ };
1132
+ }
1133
+ function getMemoryUsage() {
1134
+ if (typeof performance === "undefined") return null;
1135
+ const memory = performance.memory;
1136
+ if (!memory) return null;
1137
+ return {
1138
+ usedJSHeapSize: memory.usedJSHeapSize,
1139
+ totalJSHeapSize: memory.totalJSHeapSize,
1140
+ jsHeapSizeLimit: memory.jsHeapSizeLimit
1141
+ };
1142
+ }
1143
+ function serializeMemoryUsage(usage) {
1144
+ const formatBytes = (bytes) => {
1145
+ if (bytes < 1024) return `${bytes} B`;
1146
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
1147
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
1148
+ };
1149
+ return `
1150
+ \u{1F4BE} \u5185\u5B58\u4F7F\u7528
1151
+ \u5DF2\u4F7F\u7528\u5806: ${formatBytes(usage.usedJSHeapSize)}
1152
+ \u603B\u5806\u5927\u5C0F: ${formatBytes(usage.totalJSHeapSize)}
1153
+ \u5806\u5927\u5C0F\u9650\u5236: ${formatBytes(usage.jsHeapSizeLimit)}
1154
+ \u4F7F\u7528\u7387: ${(usage.usedJSHeapSize / usage.totalJSHeapSize * 100).toFixed(2)}%
1155
+ `.trim();
1156
+ }
1157
+ function createRegressionDetector(threshold = 0.1) {
1158
+ const history = /* @__PURE__ */ new Map();
1159
+ return {
1160
+ addResult(result) {
1161
+ if (!history.has(result.name)) {
1162
+ history.set(result.name, []);
1163
+ }
1164
+ const results = history.get(result.name);
1165
+ results.push(result);
1166
+ if (results.length < 2) return false;
1167
+ const previous = results[results.length - 2];
1168
+ if (!previous) return false;
1169
+ const regression = previous.averageDuration < result.averageDuration && (result.averageDuration - previous.averageDuration) / previous.averageDuration > threshold;
1170
+ return regression;
1171
+ },
1172
+ getHistory(name) {
1173
+ return history.get(name) || [];
1174
+ },
1175
+ clear() {
1176
+ history.clear();
1177
+ }
1178
+ };
280
1179
  }
281
1180
 
282
- .lyt-devtools-highlight {
283
- animation: lyt-devtools-highlight 1s ease-out;
284
- }
285
- `,Ee=[{id:"components",label:"\u7EC4\u4EF6\u6811",icon:"\u{1F333}"},{id:"state",label:"\u72B6\u6001",icon:"\u{1F4CA}"},{id:"events",label:"\u4E8B\u4EF6",icon:"\u26A1"},{id:"router",label:"\u8DEF\u7531",icon:"\u{1F517}"}],D=class{constructor(e){this.activeTab="components";this.tabRenderers=new Map;this._visible=!0;this._collapsed=!1;this.highlightOverlay=null;this._resizeHandle=null;this.onWindowResize=()=>{if(!(typeof window!="undefined"&&typeof document!="undefined"))return;let t=this.panelEl.getBoundingClientRect(),n=window.innerWidth-100,r=window.innerHeight-36;t.left>n&&(this.panelEl.style.left=`${n}px`),t.top>r&&(this.panelEl.style.top=`${r}px`)};var n,r,o,s,l,p,c,a;this.config={width:(n=e==null?void 0:e.width)!=null?n:420,height:(r=e==null?void 0:e.height)!=null?r:560,x:(s=e==null?void 0:e.x)!=null?s:typeof window!="undefined"?window.innerWidth-((o=e==null?void 0:e.width)!=null?o:420)-20:100,y:(l=e==null?void 0:e.y)!=null?l:60,minWidth:(p=e==null?void 0:e.minWidth)!=null?p:320,minHeight:(c=e==null?void 0:e.minHeight)!=null?c:200,title:(a=e==null?void 0:e.title)!=null?a:"Lyt DevTools"},this.dragState={isDragging:!1,startX:0,startY:0,startLeft:0,startTop:0},this.resizeState={isResizing:!1,startX:0,startY:0,startWidth:0,startHeight:0};let t=typeof window!="undefined"&&typeof document!="undefined";if(t?(this.styleEl=document.createElement("style"),this.styleEl.textContent=Ce,document.head.appendChild(this.styleEl)):this.styleEl={},t){let{panel:d,header:u,tabs:h,content:f,statusbar:m,statusLeft:x,statusRight:v,resizeHandle:y}=this.createPanelElementWithRefs();this.panelEl=d,this.headerEl=u,this.tabsEl=h,this.contentEl=f,this.statusbarEl=m,this.statusLeftEl=x,this.statusRightEl=v,this._resizeHandle=y}else this.panelEl=this.createMockPanelElement(),this.headerEl=this.panelEl.headerEl,this.tabsEl=this.panelEl.tabsEl,this.contentEl=this.panelEl.contentEl,this.statusbarEl=this.panelEl.statusbarEl,this.statusLeftEl=this.panelEl.statusLeftEl,this.statusRightEl=this.panelEl.statusRightEl,this._resizeHandle=this.panelEl.resizeHandleEl;t&&document.body.appendChild(this.panelEl),t&&(this.bindDragEvents(),this.bindResizeEvents(),this.bindKeyboardEvents(),window.addEventListener("resize",this.onWindowResize))}createPanelElementWithRefs(){let e=document.createElement("div");e.className="lyt-devtools-panel",e.style.width=`${this.config.width}px`,e.style.height=`${this.config.height}px`,e.style.left=`${this.config.x}px`,e.style.top=`${this.config.y}px`;let t=document.createElement("div");t.className="lyt-devtools-header";let n=document.createElement("span");n.className="lyt-devtools-title",n.innerHTML=`<span class="lyt-devtools-title-icon">\u{1F50D}</span>${this.config.title}`;let r=document.createElement("div");r.className="lyt-devtools-header-actions";let o=document.createElement("button");o.className="lyt-devtools-btn",o.textContent="\u2014",o.title="\u6298\u53E0/\u5C55\u5F00",o.addEventListener("click",h=>{h.stopPropagation(),this.toggleCollapse()});let s=document.createElement("button");s.className="lyt-devtools-btn lyt-devtools-btn-close",s.textContent="\u2715",s.title="\u5173\u95ED\u9762\u677F",s.addEventListener("click",h=>{h.stopPropagation(),this.hide()}),r.appendChild(o),r.appendChild(s),t.appendChild(n),t.appendChild(r);let l=document.createElement("div");l.className="lyt-devtools-tabs";for(let h of Ee){let f=document.createElement("div");f.className=`lyt-devtools-tab${h.id===this.activeTab?" active":""}`,f.dataset?f.dataset.tab=h.id:f.setAttribute("data-tab",h.id),f.innerHTML=`<span class="lyt-devtools-tab-icon">${h.icon}</span>${h.label}`,f.addEventListener("click",()=>this.switchTab(h.id)),l.appendChild(f)}let p=document.createElement("div");p.className="lyt-devtools-content";let c=document.createElement("div");c.className="lyt-devtools-statusbar";let a=document.createElement("span");a.className="lyt-devtools-status-left",a.innerHTML='<span class="lyt-devtools-status-dot"></span><span>\u5C31\u7EEA</span>';let d=document.createElement("span");d.className="lyt-devtools-status-right",d.textContent="v0.0.1",c.appendChild(a),c.appendChild(d);let u=document.createElement("div");return u.className="lyt-devtools-resize-handle",e.appendChild(t),e.appendChild(l),e.appendChild(p),e.appendChild(c),e.appendChild(u),{panel:e,header:t,tabs:l,content:p,statusbar:c,statusLeft:a,statusRight:d,resizeHandle:u}}createPanelElement(){return this.createPanelElementWithRefs().panel}createMockPanelElement(){let e=n=>({className:n,classList:{add:()=>{},remove:()=>{},toggle:()=>{},contains:()=>!1},style:{},dataset:{},querySelector:r=>r===".lyt-devtools-header"?t.headerEl:r===".lyt-devtools-tabs"?t.tabsEl:r===".lyt-devtools-content"?t.contentEl:r===".lyt-devtools-statusbar"?t.statusbarEl:r===".lyt-devtools-status-left"?t.statusLeftEl:r===".lyt-devtools-status-right"?t.statusRightEl:r===".lyt-devtools-resize-handle"?t.resizeHandleEl:null,querySelectorAll:()=>[],appendChild:()=>{},addEventListener:()=>{},removeEventListener:()=>{},offsetLeft:0,offsetTop:0,offsetWidth:100,offsetHeight:100,getBoundingClientRect:()=>({left:0,top:0,right:100,bottom:100,width:100,height:100})}),t=e("lyt-devtools-panel");return t.headerEl=e("lyt-devtools-header"),t.tabsEl=e("lyt-devtools-tabs"),t.contentEl=e("lyt-devtools-content"),t.statusbarEl=e("lyt-devtools-statusbar"),t.statusLeftEl=e("lyt-devtools-status-left"),t.statusRightEl=e("lyt-devtools-status-right"),t.resizeHandleEl=e("lyt-devtools-resize-handle"),t}switchTab(e){if(this.activeTab===e)return;this.activeTab=e,typeof window!="undefined"&&typeof document!="undefined"&&this.tabsEl&&this.tabsEl.querySelectorAll&&this.tabsEl.querySelectorAll(".lyt-devtools-tab").forEach(r=>{let o=r;o.classList&&o.dataset&&o.classList.toggle("active",o.dataset.tab===e)}),this.renderContent()}registerTabRenderer(e,t){this.tabRenderers.set(e,t),this.activeTab===e&&this.renderContent()}renderContent(){if(typeof window!="undefined"&&typeof document!="undefined"&&this.contentEl){this.contentEl.innerHTML="";let t=this.tabRenderers.get(this.activeTab);t?t(this.contentEl):this.contentEl.innerHTML='<div class="lyt-devtools-empty">\u6682\u65E0\u5185\u5BB9</div>'}}getActiveTab(){return this.activeTab}getContentElement(){return this.contentEl}show(){this._visible=!0,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="flex")}hide(){this._visible=!1,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.style&&(this.panelEl.style.display="none")}toggle(){this._visible?this.hide():this.show()}isVisible(){return this._visible}toggleCollapse(){this._collapsed=!this._collapsed,typeof window!="undefined"&&typeof document!="undefined"&&this.panelEl&&this.panelEl.classList&&this.panelEl.classList.toggle("collapsed",this._collapsed)}isCollapsed(){return this._collapsed}bindDragEvents(){typeof window!="undefined"&&typeof document!="undefined"&&(this.headerEl.addEventListener("mousedown",t=>{t.target.closest(".lyt-devtools-btn")||(this.dragState.isDragging=!0,this.dragState.startX=t.clientX,this.dragState.startY=t.clientY,this.dragState.startLeft=this.panelEl.offsetLeft,this.dragState.startTop=this.panelEl.offsetTop,t.preventDefault())}),document.addEventListener("mousemove",t=>{if(!this.dragState.isDragging)return;let n=t.clientX-this.dragState.startX,r=t.clientY-this.dragState.startY,o=this.dragState.startLeft+n,s=this.dragState.startTop+r;o=Math.max(0,Math.min(o,window.innerWidth-100)),s=Math.max(0,Math.min(s,window.innerHeight-36)),this.panelEl.style.left=`${o}px`,this.panelEl.style.top=`${s}px`}),document.addEventListener("mouseup",()=>{this.dragState.isDragging=!1}))}bindResizeEvents(){typeof window!="undefined"&&typeof document!="undefined"&&this._resizeHandle&&(this._resizeHandle.addEventListener("mousedown",t=>{this.resizeState.isResizing=!0,this.resizeState.startX=t.clientX,this.resizeState.startY=t.clientY,this.resizeState.startWidth=this.panelEl.offsetWidth,this.resizeState.startHeight=this.panelEl.offsetHeight,t.preventDefault(),t.stopPropagation()}),document.addEventListener("mousemove",t=>{if(!this.resizeState.isResizing)return;let n=t.clientX-this.resizeState.startX,r=t.clientY-this.resizeState.startY,o=Math.max(this.config.minWidth,this.resizeState.startWidth+n),s=Math.max(this.config.minHeight,this.resizeState.startHeight+r);this.panelEl.style.width=`${o}px`,this.panelEl.style.height=`${s}px`}),document.addEventListener("mouseup",()=>{this.resizeState.isResizing=!1}))}bindKeyboardEvents(){typeof window!="undefined"&&typeof document!="undefined"&&document.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&t.key==="D"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this._visible&&this.hide()})}setStatusLeft(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&(this.statusLeftEl.innerHTML=e)}setStatusRight(e){typeof window!="undefined"&&typeof document!="undefined"&&this.statusRightEl&&(this.statusRightEl.textContent=e)}setConnected(e){if(typeof window!="undefined"&&typeof document!="undefined"&&this.statusLeftEl&&this.statusLeftEl.querySelector){let n=this.statusLeftEl.querySelector(".lyt-devtools-status-dot");n&&n.classList&&n.classList.toggle("disconnected",!e)}}highlightElement(e){if(this.clearHighlight(),!e)return;if(typeof window!="undefined"&&typeof document!="undefined"){this.highlightOverlay=document.createElement("div"),this.highlightOverlay.style.cssText=`
286
- position: fixed;
287
- z-index: 999998;
288
- pointer-events: none;
289
- border: 2px solid #cba6f7;
290
- background: rgba(203, 166, 247, 0.1);
291
- border-radius: 2px;
292
- transition: all 0.15s ease;
293
- `;let n=e.getBoundingClientRect();this.highlightOverlay.style.left=`${n.left}px`,this.highlightOverlay.style.top=`${n.top}px`,this.highlightOverlay.style.width=`${n.width}px`,this.highlightOverlay.style.height=`${n.height}px`,document.body.appendChild(this.highlightOverlay)}}clearHighlight(){typeof window!="undefined"&&typeof document!="undefined"&&this.highlightOverlay&&(this.highlightOverlay.remove(),this.highlightOverlay=null)}destroy(){let e=typeof window!="undefined"&&typeof document!="undefined";e&&this.styleEl&&this.styleEl.remove&&this.styleEl.remove(),e&&this.panelEl&&this.panelEl.remove&&this.panelEl.remove(),this.clearHighlight(),e&&window.removeEventListener("resize",this.onWindowResize),this.tabRenderers.clear()}};var E=new Map,M=[],S=[],ye=0,H=null,C={},_=!1;function we(){return`comp_${++ye}`}function Se(){return`evt_${++ye}`}function ge(i){var t;if(!i)return"Unknown";let e=i.type||i.options;return e?e.name?e.name:e.render&&e.render.name?e.render.name:e.setup&&e.setup.name?e.setup.name:e._isComponentDefine&&((t=e.options)!=null&&t.name)?e.options.name:"Anonymous":"Anonymous"}function w(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(t=>w(t));let e={};for(let t of Object.keys(i))e[t]=w(i[t]);return e}function Re(i,e){return i===e?!1:typeof i!=typeof e?!0:i===null||e===null?i!==e:typeof i=="object"?JSON.stringify(i)!==JSON.stringify(e):i!==e}function Me(i,e){let t=e.split("."),n=i;for(let r of t){if(n==null||typeof n!="object")return;n=n[r]}return n}function Le(i,e,t){let n=e.split("."),r=i;for(let o=0;o<n.length-1;o++)(r[n[o]]===null||r[n[o]]===void 0||typeof r[n[o]]!="object")&&(r[n[o]]={}),r=r[n[o]];r[n[n.length-1]]=t}function J(i,e){_||(e&&Object.assign(C,e),_=!0,ke(i),i._instance&&(U(i._instance,null),V()))}function ke(i){let e=i.mount.bind(i);i.mount=function(t){let n=e(t);return i._instance&&(U(i._instance,null),V()),n}}function U(i,e){var o,s,l,p,c,a,d,u;if(!i)return;let t=ve(i),n=!t;if(n){let h=we();t={id:h,name:ge(i),parentId:e,childIds:[],props:{},state:{},computed:{},isMounted:(o=i.isMounted)!=null?o:!1,isUnmounted:(s=i.isUnmounted)!=null?s:!1,el:(l=i.el)!=null?l:null,renderTime:0,lastUpdateTime:Date.now(),instance:i},E.set(h,t)}else t&&(t.parentId=e,t.name=ge(i),t.isMounted=(p=i.isMounted)!=null?p:!1,t.isUnmounted=(c=i.isUnmounted)!=null?c:!1,t.el=(a=i.el)!=null?a:null,t.lastUpdateTime=Date.now());t&&i.props&&(t.props=w(i.props)),t&&i.state&&(t.state=w(i.state)),t&&i.computedCache&&(t.computed=w(i.computedCache)),n&&t&&i.state&&typeof i.state=="object"&&Pe(t.id,i),n&&t&&i.emit&&typeof i.emit=="function"&&De(t.id,i),n&&t?(d=C.onComponentCreated)==null||d.call(C,t):t&&((u=C.onComponentUpdated)==null||u.call(C,t));let r=i.subTree;r&&t&&xe(r,t.id)}function xe(i,e){if(i){if(i.component){U(i.component,e);let t=E.get(e);if(t&&!t.childIds.includes(i.component.id||i.component._id)){let n=He(i.component);n&&!t.childIds.includes(n)&&t.childIds.push(n)}return}if(i.children&&Array.isArray(i.children))for(let t of i.children)t&&typeof t=="object"&&xe(t,e)}}function Pe(i,e){if(!e.state||typeof e.state!="object")return;let t=e.state,n=E.get(i);if(n&&!t.__devtools_intercepted__)try{Object.defineProperty(t,"__devtools_intercepted__",{value:!0,enumerable:!1,configurable:!1});let r=new Proxy(t,{set(o,s,l){var a;let p=o[s],c=Reflect.set(o,s,l);if(Re(p,l)){let d=String(s),u={componentId:i,componentName:n.name,path:d,oldValue:w(p),newValue:w(l),timestamp:Date.now()};S.push(u),S.length>1e3&&S.splice(0,S.length-1e3),n.state=w(o),n.lastUpdateTime=Date.now(),(a=C.onStateChanged)==null||a.call(C,u)}return c}});Object.defineProperty(e,"__devtools_state_proxy__",{value:r,enumerable:!1,configurable:!0})}catch(r){}}function De(i,e){if(!e.emit||typeof e.emit!="function")return;let t=e.emit,n=E.get(i);n&&(e.emit=function(r,...o){var l;let s={id:Se(),name:r,timestamp:Date.now(),args:w(o),componentId:i,componentName:n.name};return M.push(s),M.length>500&&M.splice(0,M.length-500),(l=C.onEventEmitted)==null||l.call(C,s),t.call(this,r,...o)})}function V(){typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("lyt-devtools-update"))}function ve(i){for(let e of E.values())if(e.instance===i)return e;return null}function He(i){let e=ve(i);return e?e.id:null}function k(){return Array.from(E.values())}function W(){for(let i of E.values())if(i.parentId===null)return i;return null}function I(i){var e;return(e=E.get(i))!=null?e:null}function Y(i){let e=E.get(i);return e?e.childIds.map(t=>E.get(t)).filter(Boolean):[]}function K(){return[...M]}function Ie(){return[...S]}function X(i){return S.filter(e=>e.componentId===i)}function Be(i){return M.filter(e=>e.componentId===i)}function G(i){H=i}function Q(){var i;return H&&(i=E.get(H))!=null?i:null}function P(){return H}function Z(i,e,t){var l;let n=E.get(i);if(!n||!n.instance)return!1;let r=n.instance.state;if(!r||typeof r!="object")return!1;let o=Me(r,e);Le(r,e,t);let s={componentId:i,componentName:n.name,path:e,oldValue:w(o),newValue:w(t),timestamp:Date.now()};return S.push(s),n.state=w(r),n.lastUpdateTime=Date.now(),(l=C.onStateChanged)==null||l.call(C,s),!0}function ee(i){E.clear(),i._instance&&(U(i._instance,null),V())}function te(){M.length=0,S.length=0}function ne(){E.clear(),M.length=0,S.length=0,H=null,_=!1}function ze(){return _}function Ne(){return E.size}var B=class{constructor(e,t){this.searchKeyword="";this.expandedNodes=new Set;this.container=null;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderTree()},100)};this.panel=e,this.onSelect=t||(()=>{});let n=W();n&&this.expandedNodes.add(n.id),typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderTree()}renderTree(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("input");e.type="text",e.className="lyt-devtools-search",e.placeholder="\u641C\u7D22\u7EC4\u4EF6...",e.value=this.searchKeyword,e.addEventListener("input",r=>{this.searchKeyword=r.target.value,this.renderTree()}),this.container.appendChild(e);let t=k();if(t.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent="\u6682\u65E0\u7EC4\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5E94\u7528\u5DF2\u6302\u8F7D\u3002",this.container.appendChild(r);return}let n=this.buildTree();for(let r of n){let o=this.renderTreeNode(r);o&&this.container.appendChild(o)}this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${t.length} \u4E2A\u7EC4\u4EF6</span>`)}buildTree(){let e=k(),t=new Map,n=[];for(let r of e){if(this.searchKeyword){let s=this.searchKeyword.toLowerCase(),l=r.name.toLowerCase().includes(s),p=r.id.toLowerCase().includes(s);if(!l&&!p)continue}let o={info:r,children:[],depth:0,expanded:this.expandedNodes.has(r.id)};t.set(r.id,o)}for(let r of t.values()){let o=r.info.parentId;if(o&&t.has(o)){let s=t.get(o);s.children.push(r),r.depth=s.depth+1}else n.push(r)}return n}renderTreeNode(e){let{info:t,depth:n,expanded:r}=e,o=P(),s=t.id===o,l=document.createElement("div");l.className="lyt-tree-node",l.style.cssText=`
294
- display: flex;
295
- align-items: center;
296
- padding: 3px 8px;
297
- cursor: pointer;
298
- border-radius: 3px;
299
- margin-bottom: 1px;
300
- transition: background 0.1s ease;
301
- ${s?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
302
- `,l.addEventListener("mouseenter",()=>{s||(l.style.background="rgba(69, 71, 90, 0.5)")}),l.addEventListener("mouseleave",()=>{s||(l.style.background="")});let p=document.createElement("span");p.style.cssText=`display: inline-block; width: ${n*16}px; flex-shrink: 0;`,l.appendChild(p);let c=t.childIds.length>0,a=document.createElement("span");a.style.cssText=`
303
- display: inline-flex;
304
- align-items: center;
305
- justify-content: center;
306
- width: 16px;
307
- height: 16px;
308
- font-size: 10px;
309
- color: #6c7086;
310
- flex-shrink: 0;
311
- transition: transform 0.15s ease;
312
- ${c?"":"visibility: hidden;"}
313
- ${r?"transform: rotate(90deg);":""}
314
- `,a.textContent="\u25B6",l.appendChild(a);let d=document.createElement("span");d.style.cssText=`
315
- display: inline-flex;
316
- align-items: center;
317
- justify-content: center;
318
- width: 16px;
319
- height: 16px;
320
- font-size: 12px;
321
- margin-right: 4px;
322
- flex-shrink: 0;
323
- `,d.textContent=t.isUnmounted?"\u{1F480}":"\u{1F4E6}",l.appendChild(d);let u=document.createElement("span");u.style.cssText=`
324
- flex: 1;
325
- overflow: hidden;
326
- text-overflow: ellipsis;
327
- white-space: nowrap;
1181
+ // src/devtools.ts
1182
+ var devtoolsInstance = null;
1183
+ var DevTools = class {
1184
+ constructor(options2 = {}) {
1185
+ this.isOpen = false;
1186
+ // API 方法
1187
+ this.getComponentTree = getComponentTree;
1188
+ this.getStoreStates = getStoreStates;
1189
+ this.getCurrentRoute = getCurrentRoute;
1190
+ this.options = {
1191
+ enabled: options2.enabled ?? true,
1192
+ position: options2.position ?? "right",
1193
+ size: options2.size ?? 300
1194
+ };
1195
+ if (this.options.enabled) {
1196
+ this.init();
1197
+ }
1198
+ }
1199
+ /**
1200
+ * 初始化 DevTools
1201
+ */
1202
+ init() {
1203
+ if (typeof window === "undefined") return;
1204
+ this.createPanel();
1205
+ window.addEventListener("keydown", (e) => {
1206
+ if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === "D") {
1207
+ e.preventDefault();
1208
+ this.toggle();
1209
+ }
1210
+ });
1211
+ console.log("[LytJS DevTools] Initialized. Press Ctrl+Shift+D to toggle.");
1212
+ }
1213
+ /**
1214
+ * 创建 DevTools 面板
1215
+ */
1216
+ createPanel() {
1217
+ if (typeof document === "undefined") return;
1218
+ if (document.getElementById("lytjs-devtools")) return;
1219
+ const panel = document.createElement("div");
1220
+ panel.id = "lytjs-devtools";
1221
+ panel.style.cssText = `
1222
+ position: fixed;
1223
+ top: 0;
1224
+ ${this.options.position}: -${this.options.size}px;
1225
+ width: ${this.options.size}px;
1226
+ height: 100vh;
1227
+ background: #1e1e1e;
1228
+ color: #d4d4d4;
1229
+ font-family: 'Consolas', 'Monaco', monospace;
328
1230
  font-size: 12px;
329
- color: ${s?"#cba6f7":"#cdd6f4"};
330
- `,u.textContent=t.name,l.appendChild(u);let h=Object.keys(t.state).length;if(h>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-blue",m.textContent=`${h}`,m.title=`${h} \u4E2A\u72B6\u6001\u5C5E\u6027`,l.appendChild(m)}let f=Object.keys(t.computed).length;if(f>0){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-green",m.textContent=`C:${f}`,m.title=`${f} \u4E2A\u8BA1\u7B97\u5C5E\u6027`,m.style.marginLeft="3px",l.appendChild(m)}if(!t.isMounted&&!t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-yellow",m.textContent="\u672A\u6302\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}else if(t.isUnmounted){let m=document.createElement("span");m.className="lyt-devtools-badge lyt-devtools-badge-red",m.textContent="\u5DF2\u5378\u8F7D",m.style.marginLeft="3px",l.appendChild(m)}if(l.addEventListener("click",m=>{m.stopPropagation(),c&&(this.expandedNodes.has(t.id)?this.expandedNodes.delete(t.id):this.expandedNodes.add(t.id)),G(t.id),this.onSelect(t.id),this.panel.highlightElement(t.el),this.renderTree()}),l.addEventListener("mouseenter",()=>{this.panel.highlightElement(t.el)}),l.addEventListener("mouseleave",()=>{var v;let m=P(),x=m?I(m):null;this.panel.highlightElement((v=x==null?void 0:x.el)!=null?v:null)}),r&&c){let m=Y(t.id);for(let x of m){if(this.searchKeyword){let g=this.searchKeyword.toLowerCase(),b=x.name.toLowerCase().includes(g),T=x.id.toLowerCase().includes(g);if(!b&&!T)continue}let v={info:x,children:[],depth:n+1,expanded:this.expandedNodes.has(x.id)},y=this.renderTreeNode(v);y&&l.appendChild(y)}}return l}refresh(){this.renderTree()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function $e(i){return i===null?"null":i===void 0?"undefined":typeof i=="string"?"string":typeof i=="number"?"number":typeof i=="boolean"?"boolean":typeof i=="function"?"function":Array.isArray(i)?`Array[${i.length}]`:i instanceof Date?"Date":i instanceof RegExp?"RegExp":typeof i=="object"?"Object":typeof i}function re(i,e=80){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function be(i){return i!==null&&typeof i=="object"&&!(i instanceof Date)&&!(i instanceof RegExp)}var z=class{constructor(e){this.container=null;this.expandedPaths=new Set;this.changedPaths=new Map;this.highlightTimer=null;this.showHistory=!1;this.updateTimer=null;this.onUpdate=()=>{this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderState()},150)};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderState()}renderState(){if(!this.container)return;this.container.innerHTML="";let e=Q();if(!e){let p=document.createElement("div");p.className="lyt-devtools-empty",p.textContent="\u8BF7\u5148\u5728\u7EC4\u4EF6\u6811\u4E2D\u9009\u62E9\u4E00\u4E2A\u7EC4\u4EF6\u3002",this.container.appendChild(p);return}let t=document.createElement("div");t.style.cssText=`
1231
+ z-index: 999999;
1232
+ transition: ${this.options.position} 0.3s ease;
331
1233
  display: flex;
332
- align-items: center;
333
- justify-content: space-between;
334
- padding: 6px 8px;
335
- margin-bottom: 8px;
336
- background: #181825;
337
- border-radius: 4px;
338
- border: 1px solid #313244;
339
- `;let n=document.createElement("span");n.style.cssText="font-weight: 600; color: #cba6f7; font-size: 13px;",n.textContent=e.name;let r=document.createElement("button");r.style.cssText=`
340
- background: ${this.showHistory?"#cba6f7":"transparent"};
341
- color: ${this.showHistory?"#1e1e2e":"#a6adc8"};
342
- border: 1px solid ${this.showHistory?"#cba6f7":"#313244"};
343
- padding: 2px 8px;
344
- border-radius: 3px;
345
- cursor: pointer;
346
- font-size: 11px;
347
- font-family: inherit;
348
- `,r.textContent="\u53D8\u5316\u5386\u53F2",r.addEventListener("click",()=>{this.showHistory=!this.showHistory,this.renderState()}),t.appendChild(n),t.appendChild(r),this.container.appendChild(t),this.showHistory?this.renderHistory(e):(this.renderCategory(this.container,"props",e.props,!0,!1,!1),this.renderCategory(this.container,"state",e.state,!1,!0,!1),this.renderCategory(this.container,"computed",e.computed,!1,!1,!0));let o=Object.keys(e.state).length,s=Object.keys(e.props).length,l=Object.keys(e.computed).length;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${e.name}</span><span style="color: #585b70;">|</span><span>P:${s} S:${o} C:${l}</span>`)}renderCategory(e,t,n,r,o,s){let l=Object.keys(n);if(l.length===0)return;let p=document.createElement("div");p.style.cssText=`
1234
+ flex-direction: column;
1235
+ box-shadow: 2px 0 8px rgba(0,0,0,0.3);
1236
+ `;
1237
+ const header = document.createElement("div");
1238
+ header.style.cssText = `
1239
+ padding: 10px 15px;
1240
+ background: #2d2d2d;
1241
+ border-bottom: 1px solid #3d3d3d;
349
1242
  display: flex;
1243
+ justify-content: space-between;
350
1244
  align-items: center;
351
- padding: 4px 8px;
352
- margin-top: 6px;
353
- margin-bottom: 2px;
354
- font-size: 11px;
355
- font-weight: 600;
356
- color: #6c7086;
357
- text-transform: uppercase;
358
- letter-spacing: 0.5px;
359
- `;let c={props:"Props",state:"State",computed:"Computed"},a={props:"#89b4fa",state:"#a6e3a1",computed:"#f9e2af"};p.innerHTML=`
360
- <span style="color: ${a[t]}; margin-right: 6px;">\u25CF</span>
361
- ${c[t]}
362
- <span style="color: #585b70; margin-left: 4px;">(${l.length})</span>
363
- ${r?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u53EA\u8BFB]</span>':""}
364
- ${o?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u54CD\u5E94\u5F0F]</span>':""}
365
- ${s?'<span style="color: #585b70; margin-left: 6px; font-size: 10px;">[\u7F13\u5B58]</span>':""}
366
- `,e.appendChild(p);for(let d of l){let u=n[d],h=`${t}.${d}`,f=this.changedPaths.has(h),m=be(u);this.renderProperty(e,{key:d,value:u,category:t,isReactive:o,isCached:s,isReadonly:r},h,0,m)}}renderProperty(e,t,n,r,o){let s=document.createElement("div");s.style.cssText=`
1245
+ `;
1246
+ header.innerHTML = `
1247
+ <span style="font-weight: bold; color: #4fc08d;">\u{1F6E0}\uFE0F LytJS DevTools</span>
1248
+ <button id="lytjs-devtools-close" style="
1249
+ background: transparent;
1250
+ border: none;
1251
+ color: #d4d4d4;
1252
+ cursor: pointer;
1253
+ font-size: 16px;
1254
+ ">\u2715</button>
1255
+ `;
1256
+ const tabs = document.createElement("div");
1257
+ tabs.style.cssText = `
367
1258
  display: flex;
368
- align-items: flex-start;
369
- padding: 2px 8px;
370
- border-radius: 2px;
371
- cursor: default;
372
- transition: background 0.1s ease;
373
- ${this.changedPaths.has(n)?"background: rgba(249, 226, 175, 0.1);":""}
374
- `,s.addEventListener("mouseenter",()=>{s.style.background="rgba(69, 71, 90, 0.3)"}),s.addEventListener("mouseleave",()=>{s.style.background=this.changedPaths.has(n)?"rgba(249, 226, 175, 0.1)":""});let l=document.createElement("span");l.style.cssText=`display: inline-block; width: ${r*16}px; flex-shrink: 0;`,s.appendChild(l);let p=document.createElement("span");p.style.cssText=`
375
- display: inline-flex;
376
- align-items: center;
377
- justify-content: center;
378
- width: 14px;
379
- height: 14px;
380
- font-size: 9px;
381
- color: #6c7086;
382
- flex-shrink: 0;
383
- transition: transform 0.15s ease;
384
- ${o?"":"visibility: hidden;"}
385
- ${this.expandedPaths.has(n)?"transform: rotate(90deg);":""}
386
- `,p.textContent="\u25B6",s.appendChild(p);let c=document.createElement("span");c.style.cssText=`
387
- color: #89b4fa;
388
- margin-right: 6px;
389
- flex-shrink: 0;
390
- font-size: 12px;
391
- min-width: 60px;
392
- `,c.textContent=t.key,s.appendChild(c);let a=document.createElement("span");a.style.cssText="color: #6c7086; margin-right: 6px; flex-shrink: 0;",a.textContent=":",s.appendChild(a);let d=document.createElement("span"),u=$e(t.value),h={string:"#a6e3a1",number:"#fab387",boolean:"#89b4fa",null:"#6c7086",undefined:"#6c7086",function:"#cba6f7",Object:"#cdd6f4",Array:"#f9e2af",Date:"#f38ba8",RegExp:"#f38ba8"};d.style.cssText=`
393
- color: ${h[u]||"#cdd6f4"};
394
- font-size: 12px;
395
- flex: 1;
396
- overflow: hidden;
397
- text-overflow: ellipsis;
398
- white-space: nowrap;
399
- cursor: ${t.isReadonly?"default":"text"};
400
- `,d.textContent=re(t.value),s.appendChild(d);let f=document.createElement("span");if(f.style.cssText=`
401
- color: #585b70;
402
- font-size: 10px;
403
- flex-shrink: 0;
404
- margin-left: 6px;
405
- `,f.textContent=u,s.appendChild(f),o&&s.addEventListener("click",m=>{m.stopPropagation(),this.expandedPaths.has(n)?this.expandedPaths.delete(n):this.expandedPaths.add(n),this.renderState()}),!t.isReadonly&&t.category==="state"&&d.addEventListener("dblclick",m=>{m.stopPropagation(),this.startEdit(s,t,n,d)}),e.appendChild(s),o&&this.expandedPaths.has(n)){let m=t.value,x=Object.keys(m);for(let v of x){let y=`${n}.${v}`,g=m[v],b=be(g);this.renderProperty(e,{key:v,value:g,category:t.category,isReactive:t.isReactive,isCached:t.isCached,isReadonly:t.isReadonly},y,r+1,b)}}}startEdit(e,t,n,r){let o=P();if(!o)return;let s=document.createElement("input");s.type="text",s.style.cssText=`
406
- background: #181825;
407
- border: 1px solid #cba6f7;
408
- color: #cdd6f4;
409
- font-size: 12px;
410
- font-family: inherit;
411
- padding: 1px 4px;
412
- border-radius: 2px;
413
- outline: none;
414
- width: 100%;
415
- box-sizing: border-box;
416
- `;let l;typeof t.value=="string"?(l=t.value,s.value=t.value):(l=JSON.stringify(t.value),s.value=l),r.style.display="none",e.insertBefore(s,r.nextSibling),s.focus(),s.select();let p=()=>{let a,d=s.value;try{a=JSON.parse(d)}catch(h){a=d}let u=n.replace(/^state\./,"");Z(o,u,a),s.remove(),r.style.display="",this.renderState()},c=()=>{s.remove(),r.style.display=""};s.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),p()):a.key==="Escape"&&(a.preventDefault(),c())}),s.addEventListener("blur",()=>{p()})}renderHistory(e){let t=X(e.id);if(t.length===0){let o=document.createElement("div");o.className="lyt-devtools-empty",o.textContent="\u6682\u65E0\u72B6\u6001\u53D8\u5316\u8BB0\u5F55\u3002",this.container.appendChild(o);return}let n=document.createElement("div");n.style.cssText="max-height: 400px; overflow-y: auto;";let r=[...t].reverse();for(let o=0;o<r.length;o++){let s=r[o],l=document.createElement("div");l.style.cssText=`
417
- padding: 6px 8px;
418
- border-bottom: 1px solid #313244;
419
- font-size: 11px;
420
- cursor: default;
421
- transition: background 0.1s ease;
422
- `,l.addEventListener("mouseenter",()=>{l.style.background="rgba(69, 71, 90, 0.3)"}),l.addEventListener("mouseleave",()=>{l.style.background=""});let p=new Date(s.timestamp).toLocaleTimeString();l.innerHTML=`
423
- <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px;">
424
- <span style="color: #89b4fa; font-weight: 600;">${s.path}</span>
425
- <span style="color: #585b70;">${p}</span>
426
- </div>
427
- <div style="display: flex; align-items: center; gap: 6px;">
428
- <span style="color: #f38ba8; text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${re(s.oldValue,40)}</span>
429
- <span style="color: #6c7086;">\u2192</span>
430
- <span style="color: #a6e3a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;">${re(s.newValue,40)}</span>
431
- </div>
432
- `,n.appendChild(l)}this.container.appendChild(n)}markChanged(e){this.changedPaths.set(e,Date.now()),this.highlightTimer&&clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{this.changedPaths.clear(),this.renderState()},3e3)}refresh(){this.renderState()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.highlightTimer&&clearTimeout(this.highlightTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.expandedPaths.clear(),this.changedPaths.clear()}};function Ae(i,e=60){if(i===null)return"null";if(i===void 0)return"undefined";if(typeof i=="string")return i.length>e?`"${i.slice(0,e)}..."`:`"${i}"`;if(typeof i=="function")return`fn(${i.name||"anonymous"})`;if(typeof i=="object")try{let t=JSON.stringify(i);return t.length>e?`${t.slice(0,e)}...`:t}catch(t){return"[Object]"}return String(i)}function Te(i){let e=new Date(i);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}function Fe(i){let t=Date.now()-i;return t<1e3?`${t}ms \u524D`:t<6e4?`${Math.floor(t/1e3)}s \u524D`:`${Math.floor(t/6e4)}m \u524D`}var N=class{constructor(e){this.container=null;this.nameFilter="";this.componentFilter="";this.paused=!1;this.selectedEventId=null;this.updateTimer=null;this.autoScrollTimer=null;this.onUpdate=()=>{this.paused||(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.renderEvents()},100))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}render(e){this.container=e,this.renderEvents()}renderEvents(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";let t=document.createElement("input");t.type="text",t.className="lyt-devtools-search",t.placeholder="\u6309\u4E8B\u4EF6\u540D\u79F0\u8FC7\u6EE4...",t.value=this.nameFilter,t.style.marginBottom="0",t.style.flex="1",t.addEventListener("input",a=>{this.nameFilter=a.target.value,this.renderEvents()}),e.appendChild(t);let n=document.createElement("input");n.type="text",n.className="lyt-devtools-search",n.placeholder="\u6309\u7EC4\u4EF6\u8FC7\u6EE4...",n.value=this.componentFilter,n.style.marginBottom="0",n.style.flex="1",n.addEventListener("input",a=>{this.componentFilter=a.target.value,this.renderEvents()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=`
433
- background: ${this.paused?"#f38ba8":"transparent"};
434
- color: ${this.paused?"#1e1e2e":"#a6adc8"};
435
- border: 1px solid ${this.paused?"#f38ba8":"#313244"};
436
- padding: 4px 8px;
437
- border-radius: 4px;
438
- cursor: pointer;
439
- font-size: 11px;
440
- font-family: inherit;
441
- white-space: nowrap;
442
- flex-shrink: 0;
443
- `,r.textContent=this.paused?"\u7EE7\u7EED":"\u6682\u505C",r.addEventListener("click",()=>{this.paused=!this.paused,this.renderEvents()}),e.appendChild(r);let o=document.createElement("button");o.style.cssText=`
444
- background: transparent;
445
- color: #a6adc8;
446
- border: 1px solid #313244;
447
- padding: 4px 8px;
448
- border-radius: 4px;
449
- cursor: pointer;
450
- font-size: 11px;
451
- font-family: inherit;
452
- white-space: nowrap;
453
- flex-shrink: 0;
454
- `,o.textContent="\u6E05\u7A7A",o.addEventListener("click",()=>{this.clearEvents()}),e.appendChild(o),this.container.appendChild(e);let s=K();if(this.nameFilter){let a=this.nameFilter.toLowerCase();s=s.filter(d=>d.name.toLowerCase().includes(a))}if(this.componentFilter){let a=this.componentFilter.toLowerCase();s=s.filter(d=>d.componentName.toLowerCase().includes(a))}if(this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${s.length} \u4E2A\u4E8B\u4EF6${this.paused?" (\u5DF2\u6682\u505C)":""}</span>`),s.length===0){let a=document.createElement("div");a.className="lyt-devtools-empty",a.textContent=this.nameFilter||this.componentFilter?"\u6CA1\u6709\u5339\u914D\u7684\u4E8B\u4EF6\u8BB0\u5F55\u3002":"\u6682\u65E0\u4E8B\u4EF6\u8BB0\u5F55\uFF0C\u7B49\u5F85\u7EC4\u4EF6\u89E6\u53D1\u4E8B\u4EF6...",this.container.appendChild(a);return}if(this.selectedEventId){let a=s.find(d=>d.id===this.selectedEventId);a&&this.renderEventDetail(a)}let l=document.createElement("div");l.style.cssText="max-height: 360px; overflow-y: auto;";let p=[...s].reverse(),c=Math.min(p.length,200);for(let a=0;a<c;a++){let d=p[a],u=d.id===this.selectedEventId,h=document.createElement("div");h.style.cssText=`
455
- display: flex;
456
- align-items: center;
457
- padding: 4px 8px;
458
- border-bottom: 1px solid rgba(49, 50, 68, 0.5);
1259
+ background: #252526;
1260
+ border-bottom: 1px solid #3d3d3d;
1261
+ `;
1262
+ tabs.innerHTML = `
1263
+ <button class="lytjs-devtools-tab active" data-tab="components" style="
1264
+ flex: 1;
1265
+ padding: 10px;
1266
+ background: #1e1e1e;
1267
+ border: none;
1268
+ color: #d4d4d4;
459
1269
  cursor: pointer;
460
- font-size: 11px;
461
- transition: background 0.1s ease;
462
- ${u?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
463
- `,h.addEventListener("mouseenter",()=>{u||(h.style.background="rgba(69, 71, 90, 0.3)")}),h.addEventListener("mouseleave",()=>{u||(h.style.background="")});let f=document.createElement("span");f.style.cssText="color: #585b70; margin-right: 8px; flex-shrink: 0; font-size: 10px;",f.textContent=Te(d.timestamp),h.appendChild(f);let m=document.createElement("span");m.style.cssText=`
464
- color: #f9e2af;
465
- font-weight: 600;
466
- margin-right: 8px;
467
- flex-shrink: 0;
468
- max-width: 120px;
469
- overflow: hidden;
470
- text-overflow: ellipsis;
471
- white-space: nowrap;
472
- `,m.textContent=d.name,m.title=d.name,h.appendChild(m);let x=document.createElement("span");x.style.cssText=`
473
- color: #89b4fa;
474
- margin-right: 8px;
475
- flex-shrink: 0;
476
- max-width: 80px;
477
- overflow: hidden;
478
- text-overflow: ellipsis;
479
- white-space: nowrap;
480
- `,x.textContent=d.componentName,x.title=d.componentName,h.appendChild(x);let v=d.args.map(b=>Ae(b,30)).join(", "),y=document.createElement("span");y.style.cssText=`
481
- color: #6c7086;
1270
+ border-bottom: 2px solid #4fc08d;
1271
+ ">Components</button>
1272
+ <button class="lytjs-devtools-tab" data-tab="store" style="
482
1273
  flex: 1;
483
- overflow: hidden;
484
- text-overflow: ellipsis;
485
- white-space: nowrap;
486
- font-size: 10px;
487
- `,y.textContent=d.args.length>0?`(${v})`:"()",y.title=d.args.length>0?v:"\u65E0\u53C2\u6570",h.appendChild(y);let g=document.createElement("span");g.style.cssText="color: #45475a; flex-shrink: 0; font-size: 10px; margin-left: 4px;",g.textContent=Fe(d.timestamp),h.appendChild(g),h.addEventListener("click",()=>{this.selectedEventId===d.id?this.selectedEventId=null:this.selectedEventId=d.id,this.renderEvents()}),l.appendChild(h)}if(p.length>c){let a=document.createElement("div");a.style.cssText="padding: 6px 8px; text-align: center; color: #585b70; font-size: 11px;",a.textContent=`\u8FD8\u6709 ${p.length-c} \u6761\u8BB0\u5F55\u672A\u663E\u793A...`,l.appendChild(a)}this.container.appendChild(l)}renderEventDetail(e){let t=document.createElement("div");t.style.cssText=`
488
- background: #181825;
489
- border: 1px solid #313244;
490
- border-radius: 4px;
491
- padding: 8px;
492
- margin-bottom: 8px;
493
- `;let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="font-weight: 600; color: #f9e2af; font-size: 12px;",r.textContent=`\u4E8B\u4EF6: ${e.name}`;let o=document.createElement("span");o.style.cssText="cursor: pointer; color: #6c7086; font-size: 14px;",o.textContent="\u2715",o.addEventListener("click",()=>{this.selectedEventId=null,this.renderEvents()}),n.appendChild(r),n.appendChild(o),t.appendChild(n);let s=document.createElement("div");if(s.style.cssText="display: flex; gap: 12px; margin-bottom: 6px; font-size: 11px;",s.innerHTML=`
494
- <span><span style="color: #6c7086;">\u6765\u6E90\u7EC4\u4EF6:</span> <span style="color: #89b4fa;">${e.componentName}</span></span>
495
- <span><span style="color: #6c7086;">\u7EC4\u4EF6 ID:</span> <span style="color: #585b70;">${e.componentId}</span></span>
496
- <span><span style="color: #6c7086;">\u65F6\u95F4:</span> <span style="color: #585b70;">${Te(e.timestamp)}</span></span>
497
- `,t.appendChild(s),e.args.length>0){let l=document.createElement("div");l.style.cssText="color: #6c7086; font-size: 11px; margin-bottom: 4px; font-weight: 600;",l.textContent=`\u53C2\u6570 (${e.args.length}):`,t.appendChild(l);for(let p=0;p<e.args.length;p++){let c=document.createElement("div");c.style.cssText=`
498
- padding: 3px 8px;
499
- background: #1e1e2e;
500
- border-radius: 2px;
501
- margin-bottom: 2px;
502
- font-size: 11px;
503
- font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
504
- `;let a=e.args[p],d=typeof a,u;try{u=JSON.stringify(a,null,2)}catch(h){u=String(a)}u.length>500&&(u=u.slice(0,500)+`
505
- ... (\u5DF2\u622A\u65AD)`),c.innerHTML=`
506
- <span style="color: #6c7086;">[${p}]</span>
507
- <span style="color: #585b70; margin: 0 4px;">${d}:</span>
508
- <span style="color: #a6e3a1; white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(u)}</span>
509
- `,t.appendChild(c)}}else{let l=document.createElement("div");l.style.cssText="color: #585b70; font-size: 11px; font-style: italic;",l.textContent="\u6B64\u4E8B\u4EF6\u65E0\u53C2\u6570\u3002",t.appendChild(l)}this.container.appendChild(t)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}clearEvents(){this.selectedEventId=null,this.renderEvents()}setPaused(e){this.paused=e}isPaused(){return this.paused}refresh(){this.renderEvents()}destroy(){this.updateTimer&&clearTimeout(this.updateTimer),this.autoScrollTimer&&clearInterval(this.autoScrollTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null}};function L(i){if(i===null||typeof i!="object")return i;if(i instanceof Map){let t=new Map;for(let[n,r]of i)t.set(n,L(r));return t}if(Array.isArray(i))return i.map(t=>L(t));let e={};for(let t of Object.keys(i))e[t]=L(i[t]);return e}function _e(i){let e=new Date(i);return e.toLocaleTimeString("zh-CN",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})+`.${String(e.getMilliseconds()).padStart(3,"0")}`}var $=class{constructor(e){this.container=null;this.snapshots=[];this.snapshotCounter=0;this.maxSnapshots=100;this.currentIndex=-1;this.playState="stopped";this.playSpeed=500;this.playTimer=null;this.autoSnapshot=!0;this.updateTimer=null;this.onUpdate=()=>{this.autoSnapshot&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.takeSnapshot("\u81EA\u52A8\u5FEB\u7167")},300))};this.panel=e,typeof window!="undefined"&&window.addEventListener("lyt-devtools-update",this.onUpdate)}takeSnapshot(e,t){let n=k(),r=new Map;for(let s of n)r.set(s.id,{id:s.id,name:s.name,state:L(s.state),props:L(s.props),computed:L(s.computed),isMounted:s.isMounted});let o={id:++this.snapshotCounter,timestamp:Date.now(),description:e||`\u5FEB\u7167 #${this.snapshotCounter}`,components:r,trigger:t};return this.snapshots.push(o),this.snapshots.length>this.maxSnapshots&&this.snapshots.splice(0,this.snapshots.length-this.maxSnapshots),(this.currentIndex===-1||this.currentIndex===this.snapshots.length-2)&&(this.currentIndex=this.snapshots.length-1),o}getSnapshots(){return[...this.snapshots]}getSnapshot(e){var t;return(t=this.snapshots[e])!=null?t:null}getCurrentIndex(){return this.currentIndex}clearSnapshots(){this.snapshots=[],this.snapshotCounter=0,this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}setAutoSnapshot(e){this.autoSnapshot=e}travelTo(e){e<0||e>=this.snapshots.length||(this.currentIndex=e,this.renderTimeTravel())}stepBack(){this.currentIndex>0&&this.travelTo(this.currentIndex-1)}stepForward(){this.currentIndex<this.snapshots.length-1&&this.travelTo(this.currentIndex+1)}goToLatest(){this.currentIndex=-1,this.stopPlayback(),this.renderTimeTravel()}restoreSnapshot(e){let t=this.snapshots[e];if(!t)return!1;for(let[n,r]of t.components){let o=I(n);if(!(!o||!o.instance)&&o.instance.state&&typeof o.instance.state=="object"){let s=Object.keys(r.state);for(let l of s)try{o.instance.state[l]=L(r.state[l])}catch(p){}}}return!0}startPlayback(){this.playState!=="playing"&&((this.currentIndex===-1||this.currentIndex>=this.snapshots.length-1)&&(this.currentIndex=0),this.playState="playing",this.renderTimeTravel(),this.playTimer=setInterval(()=>{this.currentIndex<this.snapshots.length-1?(this.currentIndex++,this.renderTimeTravel()):this.stopPlayback()},this.playSpeed))}pausePlayback(){this.playState==="playing"&&(this.playState="paused",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel())}stopPlayback(){this.playState="stopped",this.playTimer&&(clearInterval(this.playTimer),this.playTimer=null),this.renderTimeTravel()}setPlaySpeed(e){this.playSpeed=e,this.playState==="playing"&&(this.pausePlayback(),this.startPlayback())}getPlayState(){return this.playState}render(e){this.container=e,this.renderTimeTravel()}renderTimeTravel(){if(!this.container)return;this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 4px; margin-bottom: 8px; align-items: center; flex-wrap: wrap;";let t=document.createElement("button");t.style.cssText=this.createButtonStyle("#a6e3a1","#1e1e2e"),t.textContent="\u{1F4F8} \u5FEB\u7167",t.title="\u624B\u52A8\u521B\u5EFA\u5FEB\u7167",t.addEventListener("click",()=>{this.takeSnapshot("\u624B\u52A8\u5FEB\u7167"),this.renderTimeTravel()}),e.appendChild(t);let n=document.createElement("button");n.style.cssText=this.createButtonStyle("#89b4fa","#1e1e2e"),n.textContent="\u{1F504} \u6700\u65B0",n.title="\u56DE\u5230\u6700\u65B0\u72B6\u6001",n.addEventListener("click",()=>{this.goToLatest()}),e.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createButtonStyle("#f38ba8","#1e1e2e"),r.textContent="\u{1F5D1} \u6E05\u7A7A",r.title="\u6E05\u7A7A\u6240\u6709\u5FEB\u7167",r.addEventListener("click",()=>{this.clearSnapshots()}),e.appendChild(r);let o=document.createElement("label");o.style.cssText="display: flex; align-items: center; gap: 4px; font-size: 11px; color: #a6adc8; margin-left: 8px; cursor: pointer;";let s=document.createElement("input");s.type="checkbox",s.checked=this.autoSnapshot,s.style.cssText="cursor: pointer;",s.addEventListener("change",()=>{this.autoSnapshot=s.checked}),o.appendChild(s),o.appendChild(document.createTextNode("\u81EA\u52A8\u5FEB\u7167")),e.appendChild(o),this.container.appendChild(e),this.snapshots.length>0&&this.renderPlaybackControls(this.container),this.renderSnapshotList(this.container);let l=this.currentIndex===-1;this.panel.setStatusLeft(`<span class="lyt-devtools-status-dot"></span><span>${this.snapshots.length} \u4E2A\u5FEB\u7167</span><span style="color: #585b70;">|</span><span>${l?"\u5B9E\u65F6":`\u5386\u53F2 #${this.currentIndex+1}`}</span>`)}renderPlaybackControls(e){let t=document.createElement("div");t.style.cssText=`
510
- display: flex;
511
- align-items: center;
512
- gap: 6px;
513
- padding: 8px;
514
- background: #181825;
515
- border: 1px solid #313244;
516
- border-radius: 4px;
517
- margin-bottom: 8px;
518
- `;let n=document.createElement("button");n.style.cssText=this.createSmallButtonStyle(),n.textContent="\u23EE",n.title="\u6B65\u9000",n.disabled=this.currentIndex<=0,n.addEventListener("click",()=>this.stepBack()),t.appendChild(n);let r=document.createElement("button");r.style.cssText=this.createSmallButtonStyle(),this.playState==="playing"?(r.textContent="\u23F8",r.title="\u6682\u505C",r.addEventListener("click",()=>this.pausePlayback())):(r.textContent="\u25B6",r.title="\u64AD\u653E",r.addEventListener("click",()=>this.startPlayback())),t.appendChild(r);let o=document.createElement("button");o.style.cssText=this.createSmallButtonStyle(),o.textContent="\u23F9",o.title="\u505C\u6B62",o.disabled=this.playState==="stopped",o.addEventListener("click",()=>this.stopPlayback()),t.appendChild(o);let s=document.createElement("button");s.style.cssText=this.createSmallButtonStyle(),s.textContent="\u23ED",s.title="\u6B65\u8FDB",s.disabled=this.currentIndex>=this.snapshots.length-1,s.addEventListener("click",()=>this.stepForward()),t.appendChild(s);let l=document.createElement("input");l.type="range",l.min="0",l.max=String(Math.max(0,this.snapshots.length-1)),l.value=String(Math.max(0,this.currentIndex)),l.style.cssText=`
519
- flex: 1;
520
- height: 4px;
521
- -webkit-appearance: none;
522
- appearance: none;
523
- background: #313244;
524
- border-radius: 2px;
525
- outline: none;
526
- cursor: pointer;
527
- `,l.addEventListener("input",d=>{let u=parseInt(d.target.value,10);this.travelTo(u)}),t.appendChild(l);let p=document.createElement("select");p.style.cssText=`
528
- background: #1e1e2e;
529
- color: #cdd6f4;
530
- border: 1px solid #313244;
531
- border-radius: 3px;
532
- padding: 2px 4px;
533
- font-size: 11px;
534
- font-family: inherit;
535
- cursor: pointer;
536
- outline: none;
537
- `;let c=[{value:200,label:"0.5x"},{value:500,label:"1x"},{value:1e3,label:"2x"},{value:2e3,label:"4x"}];for(let d of c){let u=document.createElement("option");u.value=String(d.value),u.textContent=d.label,d.value===this.playSpeed&&(u.selected=!0),p.appendChild(u)}p.addEventListener("change",d=>{this.setPlaySpeed(parseInt(d.target.value,10))}),t.appendChild(p);let a=document.createElement("span");a.style.cssText="color: #6c7086; font-size: 11px; flex-shrink: 0; min-width: 40px; text-align: right;",a.textContent=this.currentIndex===-1?`--/${this.snapshots.length}`:`${this.currentIndex+1}/${this.snapshots.length}`,t.appendChild(a),e.appendChild(t)}renderSnapshotList(e){if(this.snapshots.length===0){let r=document.createElement("div");r.className="lyt-devtools-empty",r.textContent='\u6682\u65E0\u5FEB\u7167\u3002\u70B9\u51FB"\u5FEB\u7167"\u6309\u94AE\u624B\u52A8\u521B\u5EFA\uFF0C\u6216\u5F00\u542F"\u81EA\u52A8\u5FEB\u7167"\u3002',e.appendChild(r);return}let t=document.createElement("div");t.style.cssText="max-height: 300px; overflow-y: auto;";let n=[...this.snapshots].reverse();for(let r=n.length-1;r>=0;r--){let o=n[r],s=this.snapshots.indexOf(o),l=s===this.currentIndex,p=document.createElement("div");p.style.cssText=`
538
- display: flex;
539
- align-items: center;
540
- padding: 4px 8px;
541
- border-bottom: 1px solid rgba(49, 50, 68, 0.5);
1274
+ padding: 10px;
1275
+ background: transparent;
1276
+ border: none;
1277
+ color: #d4d4d4;
542
1278
  cursor: pointer;
543
- font-size: 11px;
544
- transition: background 0.1s ease;
545
- ${l?"background: rgba(203, 166, 247, 0.15); border-left: 2px solid #cba6f7;":""}
546
- `,p.addEventListener("mouseenter",()=>{l||(p.style.background="rgba(69, 71, 90, 0.3)")}),p.addEventListener("mouseleave",()=>{l||(p.style.background="")});let c=document.createElement("span");c.style.cssText="color: #585b70; margin-right: 6px; flex-shrink: 0; min-width: 24px;",c.textContent=`#${o.id}`,p.appendChild(c);let a=document.createElement("span");a.style.cssText="color: #585b70; margin-right: 8px; flex-shrink: 0; font-size: 10px;",a.textContent=_e(o.timestamp),p.appendChild(a);let d=document.createElement("span");d.style.cssText="color: #cdd6f4; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",d.textContent=o.description,p.appendChild(d);let u=document.createElement("span");u.style.cssText="color: #6c7086; flex-shrink: 0; font-size: 10px; margin-left: 4px;",u.textContent=`${o.components.size} \u7EC4\u4EF6`,p.appendChild(u);let h=document.createElement("span");h.style.cssText=`
547
- color: #585b70;
1279
+ border-bottom: 2px solid transparent;
1280
+ ">Store</button>
1281
+ <button class="lytjs-devtools-tab" data-tab="router" style="
1282
+ flex: 1;
1283
+ padding: 10px;
1284
+ background: transparent;
1285
+ border: none;
1286
+ color: #d4d4d4;
548
1287
  cursor: pointer;
549
- margin-left: 6px;
550
- font-size: 10px;
551
- padding: 1px 4px;
552
- border: 1px solid #313244;
553
- border-radius: 2px;
554
- flex-shrink: 0;
555
- transition: all 0.15s ease;
556
- `,h.textContent="\u6062\u590D",h.title="\u6062\u590D\u6B64\u5FEB\u7167\u7684\u72B6\u6001",h.addEventListener("mouseenter",()=>{h.style.color="#f9e2af",h.style.borderColor="#f9e2af"}),h.addEventListener("mouseleave",()=>{h.style.color="#585b70",h.style.borderColor="#313244"}),h.addEventListener("click",f=>{f.stopPropagation(),confirm(`\u786E\u5B9A\u8981\u6062\u590D\u5FEB\u7167 #${o.id} \u7684\u72B6\u6001\u5417\uFF1F
557
- \u8FD9\u5C06\u4FEE\u6539\u7EC4\u4EF6\u7684\u5B9E\u9645\u72B6\u6001\u3002`)&&this.restoreSnapshot(s)}),p.appendChild(h),p.addEventListener("click",()=>{this.travelTo(s)}),t.appendChild(p)}e.appendChild(t)}createButtonStyle(e,t){return`
558
- background: ${e};
559
- color: ${t};
560
- border: none;
561
- padding: 4px 8px;
562
- border-radius: 4px;
563
- cursor: pointer;
564
- font-size: 11px;
565
- font-family: inherit;
566
- white-space: nowrap;
567
- flex-shrink: 0;
568
- transition: opacity 0.15s ease;
569
- `}createSmallButtonStyle(){return`
570
- background: transparent;
571
- color: #cdd6f4;
572
- border: 1px solid #313244;
573
- width: 28px;
574
- height: 28px;
575
- border-radius: 4px;
576
- cursor: pointer;
577
- font-size: 14px;
578
- display: flex;
579
- align-items: center;
580
- justify-content: center;
581
- flex-shrink: 0;
582
- transition: all 0.15s ease;
583
- padding: 0;
584
- `}refresh(){this.renderTimeTravel()}destroy(){this.stopPlayback(),this.updateTimer&&clearTimeout(this.updateTimer),typeof window!="undefined"&&window.removeEventListener("lyt-devtools-update",this.onUpdate),this.container=null,this.snapshots=[]}};var oe=class{constructor(e,t){this.history=[];this.currentPath="/";this.currentParams={};this.currentQuery={};var n;this.container=e,this.maxHistory=(n=t==null?void 0:t.maxHistory)!=null?n:50,this.render()}updateRoute(e,t,n){this.history.push({path:e,params:t?{...t}:void 0,query:n?{...n}:void 0,timestamp:Date.now()}),this.history.length>this.maxHistory&&this.history.shift(),this.currentPath=e,this.currentParams=t?{...t}:{},this.currentQuery=n?{...n}:{},this.render()}getHistory(){return[...this.history].reverse()}getCurrentPath(){return this.currentPath}clearHistory(){this.history=[],this.render()}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="margin-bottom: 16px;";let t=document.createElement("div");t.style.cssText="font-size: 11px; color: #a6adc8; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;",t.textContent="Current Route",e.appendChild(t);let n=document.createElement("div");n.style.cssText="display: flex; align-items: center; gap: 8px; margin-bottom: 6px;";let r=document.createElement("span");r.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",r.textContent="Path:";let o=document.createElement("span");if(o.style.cssText="color: #cba6f7; font-size: 13px; font-weight: 600;",o.textContent=this.currentPath||"/",n.appendChild(r),n.appendChild(o),e.appendChild(n),Object.keys(this.currentParams).length>0){let c=document.createElement("div");c.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Params:";let d=document.createElement("span");d.style.cssText="color: #a6e3a1; font-size: 12px;",d.textContent=JSON.stringify(this.currentParams),c.appendChild(a),c.appendChild(d),e.appendChild(c)}if(Object.keys(this.currentQuery).length>0){let c=document.createElement("div");c.style.cssText="display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;";let a=document.createElement("span");a.style.cssText="color: #585b70; font-size: 11px; min-width: 50px;",a.textContent="Query:";let d=document.createElement("span");d.style.cssText="color: #89b4fa; font-size: 12px;",d.textContent=JSON.stringify(this.currentQuery),c.appendChild(a),c.appendChild(d),e.appendChild(c)}this.container.appendChild(e);let s=document.createElement("div");s.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let l=document.createElement("span");l.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",l.textContent=`History (${this.history.length})`,s.appendChild(l);let p=document.createElement("button");if(p.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",p.textContent="Clear",p.addEventListener("click",()=>this.clearHistory()),s.appendChild(p),this.container.appendChild(s),this.history.length===0){let c=document.createElement("div");c.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",c.textContent="No navigation history",this.container.appendChild(c)}else{let c=document.createElement("div");c.style.cssText="max-height: 300px; overflow-y: auto;";let a=[...this.history].reverse();for(let d of a){let u=document.createElement("div");u.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-radius: 3px; font-size: 12px; transition: background 0.15s; cursor: default;",u.addEventListener("mouseenter",()=>{u.style.background="#313244"}),u.addEventListener("mouseleave",()=>{u.style.background="transparent"});let h=document.createElement("span");h.style.cssText="color: #cdd6f4; font-family: inherit;",h.textContent=d.path;let f=document.createElement("span");f.style.cssText="color: #585b70; font-size: 10px; white-space: nowrap;";let m=new Date(d.timestamp);f.textContent=`${m.getHours().toString().padStart(2,"0")}:${m.getMinutes().toString().padStart(2,"0")}:${m.getSeconds().toString().padStart(2,"0")}.${m.getMilliseconds().toString().padStart(3,"0")}`,u.appendChild(h),u.appendChild(f),c.appendChild(u)}this.container.appendChild(c)}}destroy(){this.container.innerHTML="",this.history=[]}};var R=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Ue=100,Oe=16,A=class{constructor(e=Ue){this.pendingMarks=new Map;this.componentUpdateCounts=new Map;this._isRecording=!1;this.bufferSize=e,this.fcpBuffer=new R(e),this.inpBuffer=new R(e),this.renderBuffer=new R(e),this.updateFrequencyBuffer=new R(e),this.memoryBuffer=new R(e),this.customMarkBuffer=new R(e),this.fpsBuffer=new R(e),this.fpsState={isMonitoring:!1,frameCount:0,lastTime:0,rafId:null}}recordFCP(e){if(e===void 0)if(typeof performance!="undefined"&&performance.getEntriesByType){let n=performance.getEntriesByType("paint").find(r=>r.name==="first-contentful-paint");e=n?n.startTime:0}else e=0;this.fcpBuffer.push({type:"fcp",value:e,timestamp:Date.now()})}recordINP(e,t,n){this.inpBuffer.push({type:"inp",value:e,eventName:t,componentName:n,timestamp:Date.now()})}recordRender(e,t,n="update",r){this.renderBuffer.push({type:"render",value:t,componentName:e,componentId:r,phase:n,timestamp:Date.now()}),this.trackComponentUpdate(e)}trackComponentUpdate(e){let t=Date.now(),n=this.componentUpdateCounts.get(e);if(!n){this.componentUpdateCounts.set(e,{count:1,startTime:t});return}n.count++;let r=t-n.startTime;r>=1e3&&(this.updateFrequencyBuffer.push({type:"update-frequency",componentName:e,count:n.count,windowMs:r,timestamp:t}),n.count=0,n.startTime=t)}recordMemory(e,t){this.memoryBuffer.push({type:"memory",proxyCount:e,reactiveCount:t,timestamp:Date.now()})}startMark(e){this.pendingMarks.set(e,performance.now())}endMark(e){let t=this.pendingMarks.get(e);if(t===void 0)return-1;let n=performance.now()-t;return this.pendingMarks.delete(e),this.customMarkBuffer.push({type:"custom",name:e,value:n,timestamp:Date.now()}),n}startFPSMonitor(){if(this.fpsState.isMonitoring||typeof requestAnimationFrame!="function")return;this.fpsState.isMonitoring=!0,this.fpsState.frameCount=0,this.fpsState.lastTime=performance.now();let e=t=>{if(!this.fpsState.isMonitoring)return;this.fpsState.frameCount++;let n=t-this.fpsState.lastTime;if(n>=1e3){let r=this.fpsState.frameCount/n*1e3;this.fpsBuffer.push({type:"fps",value:Math.round(r),timestamp:Date.now()}),this.fpsState.frameCount=0,this.fpsState.lastTime=t}this.fpsState.rafId=requestAnimationFrame(e)};this.fpsState.rafId=requestAnimationFrame(e)}stopFPSMonitor(){this.fpsState.isMonitoring=!1,this.fpsState.rafId!==null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.fpsState.rafId),this.fpsState.rafId=null)}isFPSMonitoring(){return this.fpsState.isMonitoring}startRecording(){this._isRecording=!0,this.startFPSMonitor()}stopRecording(){this._isRecording=!1,this.stopFPSMonitor()}isRecording(){return this._isRecording}getMetrics(){return[...this.fcpBuffer.getAll(),...this.inpBuffer.getAll(),...this.renderBuffer.getAll(),...this.updateFrequencyBuffer.getAll(),...this.memoryBuffer.getAll(),...this.customMarkBuffer.getAll(),...this.fpsBuffer.getAll()]}getMetricsByType(e){return this.getMetrics().filter(n=>n.type===e)}getCurrentFPS(){let e=this.fpsBuffer.getAll();return e.length===0?0:e[e.length-1].value}getRenderRankings(){let e=new Map;for(let t of this.renderBuffer.getAll()){let n=e.get(t.componentName)||{renderCount:0,totalTime:0,maxTime:0};n.renderCount++,n.totalTime+=t.value,n.maxTime=Math.max(n.maxTime,t.value),e.set(t.componentName,n)}return Array.from(e.entries()).map(([t,n])=>({componentName:t,renderCount:n.renderCount,avgRenderTime:n.renderCount>0?n.totalTime/n.renderCount:0,maxRenderTime:n.maxTime,totalRenderTime:n.totalTime})).sort((t,n)=>n.avgRenderTime-t.avgRenderTime)}getProxyCount(){let e=this.memoryBuffer.getAll();return e.length===0?0:e[e.length-1].proxyCount}getSlowRenders(){return this.renderBuffer.getAll().filter(e=>e.value>Oe)}getReport(){let e=this.fcpBuffer.getAll(),t=e.length>0?e[e.length-1]:null,r=this.inpBuffer.getAll().map(y=>y.value),o={avg:r.length>0?r.reduce((y,g)=>y+g,0)/r.length:0,max:r.length>0?Math.max(...r):0,min:r.length>0?Math.min(...r):0,count:r.length},s=this.getRenderRankings(),l=this.updateFrequencyBuffer.getAll(),p=new Map;for(let y of l){let g=y.count/y.windowMs*1e3,b=p.get(y.componentName)||[];b.push(g),p.set(y.componentName,b)}let c=Array.from(p.entries()).map(([y,g])=>({componentName:y,avgFrequency:g.reduce((b,T)=>b+T,0)/g.length})),a=this.memoryBuffer.getAll(),d=a.length>0?a[a.length-1]:null,h=this.fpsBuffer.getAll().map(y=>y.value),f={avg:h.length>0?h.reduce((y,g)=>y+g,0)/h.length:0,min:h.length>0?Math.min(...h):0,count:h.length},m=this.customMarkBuffer.getAll(),x=new Map;for(let y of m){let g=x.get(y.name)||[];g.push(y.value),x.set(y.name,g)}let v=Array.from(x.entries()).map(([y,g])=>({name:y,avg:g.reduce((b,T)=>b+T,0)/g.length,max:Math.max(...g),count:g.length}));return{generatedAt:Date.now(),fcp:t,inp:o,renderStats:s,updateFrequencyStats:c,memory:d,fps:f,customMarks:v}}exportJSON(){return JSON.stringify({metrics:this.getMetrics(),report:this.getReport()},null,2)}clear(){this.fcpBuffer.clear(),this.inpBuffer.clear(),this.renderBuffer.clear(),this.updateFrequencyBuffer.clear(),this.memoryBuffer.clear(),this.customMarkBuffer.clear(),this.fpsBuffer.clear(),this.pendingMarks.clear(),this.componentUpdateCounts.clear()}destroy(){this.stopFPSMonitor(),this.clear()}};var F=class{constructor(e=16){this.activeProfiles=new Map;this.slowThreshold=e}startProfile(e){return this.activeProfiles.has(e)?!1:(this.activeProfiles.set(e,{componentName:e,startTime:performance.now(),records:[],slowThreshold:this.slowThreshold}),!0)}stopProfile(e){let t=this.activeProfiles.get(e);return t?(this.activeProfiles.delete(e),this.buildResult(t)):null}stopAllProfiles(){let e=[];for(let t of this.activeProfiles.values())e.push(this.buildResult(t));return this.activeProfiles.clear(),e}recordRender(e,t){let n=this.activeProfiles.get(e);if(!n)return;let r={duration:t,timestamp:Date.now(),isSlow:t>n.slowThreshold};n.records.push(r)}getSnapshot(e){let t=this.activeProfiles.get(e);return t?this.buildResult(t):null}isProfiling(e){return this.activeProfiles.has(e)}getActiveProfileNames(){return Array.from(this.activeProfiles.keys())}getActiveProfileCount(){return this.activeProfiles.size}getSlowRenders(e){let t=this.activeProfiles.get(e);return t?t.records.filter(n=>n.isSlow):[]}setSlowThreshold(e){this.slowThreshold=e;for(let t of this.activeProfiles.values()){t.slowThreshold=e;for(let n of t.records)n.isSlow=n.duration>e}}getSlowThreshold(){return this.slowThreshold}clear(){this.activeProfiles.clear()}destroy(){this.clear()}buildResult(e){let t=e.records,n=t.length,r=t.reduce((a,d)=>a+d.duration,0),o=n>0?r/n:0,s=n>0?Math.max(...t.map(a=>a.duration)):0,l=n>0?Math.min(...t.map(a=>a.duration)):0,p=t.filter(a=>a.isSlow).length,c=performance.now()-e.startTime;return{componentName:e.componentName,renderCount:n,avgRenderTime:o,maxRenderTime:s,minRenderTime:l,totalRenderTime:r,slowRenderCount:p,slowThreshold:e.slowThreshold,records:[...t],profileDuration:c}}};var se=class{constructor(e,t){this.entries=new Map;this.isRecording=!1;this.fpsUpdateTimer=null;var n,r;this.container=e,this.config={autoStartFPS:(n=t==null?void 0:t.autoStartFPS)!=null?n:!1,fpsUpdateInterval:(r=t==null?void 0:t.fpsUpdateInterval)!=null?r:1e3},this.fpsUpdateInterval=this.config.fpsUpdateInterval,this.collector=new A,this.profiler=new F,this.config.autoStartFPS&&this.collector.startFPSMonitor(),this.render()}recordRender(e,t){let n=this.entries.get(e)||{name:e,renders:0,totalTime:0,avgTime:0,maxTime:0,lastTime:0};n.renders++,n.totalTime+=t,n.avgTime=n.totalTime/n.renders,n.maxTime=Math.max(n.maxTime,t),n.lastTime=t,this.entries.set(e,n),this.collector.recordRender(e,t,"update"),this.profiler.recordRender(e,t),this.render()}getStats(){return Array.from(this.entries.values()).sort((e,t)=>t.totalTime-e.totalTime)}getEntry(e){return this.entries.get(e)||null}getTotalRenders(){let e=0;for(let t of this.entries.values())e+=t.renders;return e}getTotalTime(){let e=0;for(let t of this.entries.values())e+=t.totalTime;return e}clear(){this.entries.clear(),this.collector.clear(),this.profiler.clear(),this.render()}getCurrentFPS(){return this.collector.getCurrentFPS()}startFPSMonitor(){this.collector.startFPSMonitor(),this.startFPSUpdateLoop()}stopFPSMonitor(){this.collector.stopFPSMonitor(),this.stopFPSUpdateLoop()}isFPSMonitoring(){return this.collector.isFPSMonitoring()}getRenderRankings(){return this.collector.getRenderRankings()}getUpdateFrequencyStats(){return this.collector.getReport().updateFrequencyStats}recordProxyCount(e,t){this.collector.recordMemory(e,t)}getProxyCount(){return this.collector.getProxyCount()}startRecording(){this.isRecording=!0,this.collector.startRecording(),this.startFPSUpdateLoop(),this.render()}stopRecording(){this.isRecording=!1,this.collector.stopRecording(),this.stopFPSUpdateLoop(),this.render()}isRecordingActive(){return this.isRecording}exportJSON(){return this.collector.exportJSON()}getReport(){return this.collector.getReport()}startProfile(e){return this.profiler.startProfile(e)}stopProfile(e){return this.profiler.stopProfile(e)}getProfileSnapshot(e){return this.profiler.getSnapshot(e)}getSlowRenders(){return this.getStats().filter(e=>e.maxTime>16)}getCollector(){return this.collector}getProfiler(){return this.profiler}render(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;";let t=this.getCurrentFPS(),n=t>=55?"#a6e3a1":t>=30?"#f9e2af":"#f38ba8",r=this.createStatCard("FPS",String(t),n),o=this.createStatCard("Proxies",String(this.getProxyCount()),"#cba6f7"),s=this.createStatCard("Total Renders",String(this.getTotalRenders()),"#89b4fa"),l=this.createStatCard("Total Time",`${this.getTotalTime().toFixed(2)}ms`,"#a6e3a1"),p=this.createStatCard("Components",String(this.entries.size),"#f9e2af");e.appendChild(r),e.appendChild(o),e.appendChild(s),e.appendChild(l),e.appendChild(p),this.container.appendChild(e);let c=document.createElement("div");c.style.cssText="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;";let a=document.createElement("span");a.style.cssText="font-size: 11px; color: #a6adc8; text-transform: uppercase; letter-spacing: 0.5px;",a.textContent="Render Performance",c.appendChild(a);let d=document.createElement("div");d.style.cssText="display: flex; gap: 4px;";let u=document.createElement("button");u.style.cssText=this.getRecordButtonStyle(),u.textContent=this.isRecording?"Stop":"Record",u.addEventListener("click",()=>{this.isRecording?this.stopRecording():this.startRecording()}),d.appendChild(u);let h=document.createElement("button");h.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",h.textContent="Export",h.addEventListener("click",()=>{let x=this.exportJSON(),v=new Blob([x],{type:"application/json"}),y=URL.createObjectURL(v),g=document.createElement("a");g.href=y,g.download=`lyt-perf-${Date.now()}.json`,g.click(),URL.revokeObjectURL(y)}),d.appendChild(h);let f=document.createElement("button");f.style.cssText="background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;",f.textContent="Clear",f.addEventListener("click",()=>this.clear()),d.appendChild(f),c.appendChild(d),this.container.appendChild(c);let m=this.getStats().sort((x,v)=>v.avgTime-x.avgTime);if(m.length===0){let x=document.createElement("div");x.style.cssText="color: #585b70; font-size: 12px; text-align: center; padding: 16px 0; font-style: italic;",x.textContent="No performance data recorded",this.container.appendChild(x)}else{let x=document.createElement("div");x.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 4px 8px; font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #313244; margin-bottom: 4px;",x.innerHTML="<span>Component</span><span>Renders</span><span>Avg</span><span>Max</span><span>Last</span>",this.container.appendChild(x);let v=document.createElement("div");v.style.cssText="max-height: 300px; overflow-y: auto;";for(let y of m){let g=document.createElement("div");g.style.cssText="display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 4px; padding: 6px 8px; font-size: 12px; border-radius: 3px; transition: background 0.15s; cursor: default;",g.addEventListener("mouseenter",()=>{g.style.background="#313244"}),g.addEventListener("mouseleave",()=>{g.style.background="transparent"});let b=document.createElement("span");b.style.cssText="color: #cdd6f4; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",b.textContent=y.name;let T=document.createElement("span");T.style.cssText="color: #89b4fa;",T.textContent=String(y.renders);let O=document.createElement("span");O.style.cssText=this.getPerfColor(y.avgTime),O.textContent=`${y.avgTime.toFixed(2)}ms`;let q=document.createElement("span");q.style.cssText=this.getPerfColor(y.maxTime),q.textContent=`${y.maxTime.toFixed(2)}ms`;let j=document.createElement("span");j.style.cssText=this.getPerfColor(y.lastTime),j.textContent=`${y.lastTime.toFixed(2)}ms`,g.appendChild(b),g.appendChild(T),g.appendChild(O),g.appendChild(q),g.appendChild(j),v.appendChild(g)}this.container.appendChild(v)}}createStatCard(e,t,n){let r=document.createElement("div");r.style.cssText="flex: 1; padding: 8px 12px; background: #181825; border: 1px solid #313244; border-radius: 4px; min-width: 70px;";let o=document.createElement("div");o.style.cssText=`font-size: 16px; font-weight: 600; color: ${n}; margin-bottom: 2px;`,o.textContent=t;let s=document.createElement("div");return s.style.cssText="font-size: 10px; color: #585b70; text-transform: uppercase; letter-spacing: 0.5px;",s.textContent=e,r.appendChild(o),r.appendChild(s),r}getRecordButtonStyle(){return this.isRecording?"background: #f38ba8; border: 1px solid #f38ba8; color: #1e1e2e; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit; font-weight: 600;":"background: transparent; border: 1px solid #45475a; color: #a6adc8; cursor: pointer; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-family: inherit;"}getPerfColor(e){return e<1?"color: #a6e3a1;":e<5?"color: #f9e2af;":e<16?"color: #fab387;":"color: #f38ba8;"}startFPSUpdateLoop(){this.stopFPSUpdateLoop(),this.fpsUpdateTimer=window.setInterval(()=>{this.render()},this.fpsUpdateInterval)}stopFPSUpdateLoop(){this.fpsUpdateTimer!==null&&(clearInterval(this.fpsUpdateTimer),this.fpsUpdateTimer=null)}destroy(){this.stopFPSUpdateLoop(),this.collector.destroy(),this.profiler.destroy(),this.container.innerHTML="",this.entries.clear()}};var ie=class{constructor(e){this.buffer=[];this._paused=!1;this.filterPattern="";this.counter=0;this.writeIndex=0;this.bufferFull=!1;this.element=null;var t,n,r;this.maxBuffer=(t=e==null?void 0:e.maxBuffer)!=null?t:200,this.autoScroll=(n=e==null?void 0:e.autoScroll)!=null?n:!0,this.title=(r=e==null?void 0:e.title)!=null?r:"\u4E8B\u4EF6\u9762\u677F"}captureEvent(e,t,n){if(this._paused)return;let r={name:e,payload:t,sourceComponent:n,timestamp:Date.now(),index:this.counter++};this.bufferFull?this.buffer[this.writeIndex]=r:(this.buffer.push(r),this.buffer.length>=this.maxBuffer&&(this.bufferFull=!0)),this.writeIndex=(this.writeIndex+1)%this.maxBuffer}getEvents(){let e=this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer];if(this.filterPattern){let t=this.filterPattern.toLowerCase();e=e.filter(n=>n.name.toLowerCase().includes(t)||n.sourceComponent&&n.sourceComponent.toLowerCase().includes(t))}return e}getAllEvents(){return this.bufferFull?this.buffer.slice(this.writeIndex).concat(this.buffer.slice(0,this.writeIndex)):[...this.buffer]}clear(){this.buffer=[],this.writeIndex=0,this.bufferFull=!1}setFilter(e){this.filterPattern=e}getFilter(){return this.filterPattern}pause(){this._paused=!0}resume(){this._paused=!1}isPaused(){return this._paused}exportJSON(){let e=this.getEvents();return JSON.stringify(e,null,2)}getCount(){return this.bufferFull?this.maxBuffer:this.buffer.length}getMaxBuffer(){return this.maxBuffer}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-event-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("div");r.style.cssText="display: flex; gap: 4px;";let o=document.createElement("button");o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",o.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",o.addEventListener("click",()=>{this._paused?this.resume():this.pause(),o.textContent=this._paused?"\u6062\u590D":"\u6682\u505C",this.render()}),r.appendChild(o);let s=document.createElement("button");s.textContent="\u6E05\u9664",s.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",s.addEventListener("click",()=>{this.clear(),this.render()}),r.appendChild(s);let l=document.createElement("button");l.textContent="\u5BFC\u51FA",l.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",l.addEventListener("click",()=>{let u=this.exportJSON(),h=new Blob([u],{type:"application/json"}),f=URL.createObjectURL(h),m=document.createElement("a");m.href=f,m.download=`lyt-events-${Date.now()}.json`,m.click(),URL.revokeObjectURL(f)}),r.appendChild(l),t.appendChild(r),e.appendChild(t);let p=document.createElement("div");p.style.cssText="padding: 6px 12px; background: #181825; border-bottom: 1px solid #313244;";let c=document.createElement("input");c.type="text",c.placeholder="\u8FC7\u6EE4\u4E8B\u4EF6\u540D\u79F0...",c.value=this.filterPattern,c.style.cssText="width: 100%; padding: 4px 8px; border: 1px solid #45475a; background: #1e1e2e; color: #cdd6f4; border-radius: 3px; font-size: 11px; box-sizing: border-box;",c.addEventListener("input",()=>{this.setFilter(c.value),this.render()}),p.appendChild(c),e.appendChild(p);let a=document.createElement("div");a.style.cssText="max-height: 400px; overflow-y: auto; padding: 4px 0;";let d=this.getEvents();if(d.length===0){let u=document.createElement("div");u.style.cssText="padding: 20px; text-align: center; color: #585b70;",u.textContent="\u6682\u65E0\u4E8B\u4EF6",a.appendChild(u)}else for(let u of d){let h=document.createElement("div");h.style.cssText="padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;";let f=new Date(u.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}.${String(f.getMilliseconds()).padStart(3,"0")}`,x="";try{x=JSON.stringify(u.payload),x.length>50&&(x=x.slice(0,50)+"...")}catch(y){x=String(u.payload)}let v=u.sourceComponent?` [${u.sourceComponent}]`:"";h.textContent=`${m} ${u.name}${v} ${x}`,a.appendChild(h)}return e.appendChild(a),this.autoScroll&&(a.scrollTop=a.scrollHeight),this.element=e,e}destroy(){this.element&&(this.element.remove(),this.element=null),this.clear()}};var ae=class{constructor(e){this.currentRoute=null;this.history=[];this.navCounter=0;this.element=null;this.selectedHistoryIndex=-1;var t,n;this.maxHistory=(t=e==null?void 0:e.maxHistory)!=null?t:50,this.title=(n=e==null?void 0:e.title)!=null?n:"\u8DEF\u7531\u9762\u677F"}onRouteChange(e,t,n){let r={index:this.navCounter++,to:{...e},from:{...t},timestamp:Date.now(),type:n!=null?n:"push"};this.history.push(r),this.history.length>this.maxHistory&&(this.history=this.history.slice(this.history.length-this.maxHistory)),this.currentRoute={...e},this.selectedHistoryIndex=-1}getCurrentRoute(){return this.currentRoute?{...this.currentRoute}:null}getHistory(){return this.history.map(e=>({...e,to:{...e.to},from:{...e.from}}))}clearHistory(){this.history=[],this.navCounter=0,this.selectedHistoryIndex=-1}getHistoryCount(){return this.history.length}getMaxHistory(){return this.maxHistory}selectHistoryEntry(e){e>=0&&e<this.history.length&&(this.selectedHistoryIndex=e)}getSelectedHistoryEntry(){if(this.selectedHistoryIndex>=0&&this.selectedHistoryIndex<this.history.length){let e=this.history[this.selectedHistoryIndex];return{...e,to:{...e.to},from:{...e.from}}}return null}render(){this.element&&this.element.remove();let e=document.createElement("div");e.className="lyt-router-panel",e.style.cssText="font-family: monospace; font-size: 12px; color: #cdd6f4;";let t=document.createElement("div");t.style.cssText="display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let n=document.createElement("span");n.textContent=this.title,n.style.cssText="font-weight: bold; font-size: 13px;",t.appendChild(n);let r=document.createElement("button");r.textContent="\u6E05\u9664\u5386\u53F2",r.style.cssText="padding: 2px 8px; border: 1px solid #45475a; background: #313244; color: #cdd6f4; cursor: pointer; border-radius: 3px; font-size: 11px;",r.addEventListener("click",()=>{this.clearHistory(),this.render()}),t.appendChild(r),e.appendChild(t);let o=document.createElement("div");o.style.cssText="padding: 8px 12px; background: #181825; border-bottom: 1px solid #313244;";let s=document.createElement("div");if(s.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",s.textContent="\u5F53\u524D\u8DEF\u7531",o.appendChild(s),this.currentRoute){let a=document.createElement("div");if(a.style.cssText="font-weight: bold; font-size: 14px; color: #89b4fa;",a.textContent=this.currentRoute.path,o.appendChild(a),this.currentRoute.params&&Object.keys(this.currentRoute.params).length>0){let d=document.createElement("div");d.style.cssText="margin-top: 4px; color: #a6e3a1; font-size: 11px;",d.textContent=`params: ${JSON.stringify(this.currentRoute.params)}`,o.appendChild(d)}if(this.currentRoute.query&&Object.keys(this.currentRoute.query).length>0){let d=document.createElement("div");d.style.cssText="margin-top: 2px; color: #f9e2af; font-size: 11px;",d.textContent=`query: ${JSON.stringify(this.currentRoute.query)}`,o.appendChild(d)}if(this.currentRoute.name){let d=document.createElement("div");d.style.cssText="margin-top: 2px; color: #cba6f7; font-size: 11px;",d.textContent=`name: ${this.currentRoute.name}`,o.appendChild(d)}}else{let a=document.createElement("div");a.style.cssText="color: #585b70; font-size: 11px;",a.textContent="\u6682\u65E0\u8DEF\u7531\u4FE1\u606F",o.appendChild(a)}e.appendChild(o);let l=document.createElement("div");l.style.cssText="padding: 8px 12px; background: #1e1e2e; border-bottom: 1px solid #313244;";let p=document.createElement("div");p.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",p.textContent=`\u5BFC\u822A\u5386\u53F2 (${this.history.length})`,l.appendChild(p),e.appendChild(l);let c=document.createElement("div");if(c.style.cssText="max-height: 300px; overflow-y: auto;",this.history.length===0){let a=document.createElement("div");a.style.cssText="padding: 20px; text-align: center; color: #585b70;",a.textContent="\u6682\u65E0\u5BFC\u822A\u8BB0\u5F55",c.appendChild(a)}else for(let a=this.history.length-1;a>=0;a--){let d=this.history[a],u=document.createElement("div"),h=a===this.selectedHistoryIndex;u.style.cssText=`padding: 4px 12px; border-bottom: 1px solid #1e1e2e; cursor: pointer;${h?" background: #313244;":""}`;let f=new Date(d.timestamp),m=`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`,x=d.type==="pop"?"<-":d.type==="replace"?"=":">";u.textContent=`${m} ${x} ${d.from.path} -> ${d.to.path}`;let v=a;u.addEventListener("click",()=>{this.selectHistoryEntry(v),this.render()}),c.appendChild(u)}if(e.appendChild(c),this.selectedHistoryIndex>=0){let a=this.history[this.selectedHistoryIndex];if(a){let d=document.createElement("div");d.style.cssText="padding: 8px 12px; background: #181825; border-top: 1px solid #313244;";let u=document.createElement("div");u.style.cssText="color: #a6adc8; font-size: 11px; margin-bottom: 4px;",u.textContent="\u5BFC\u822A\u8BE6\u60C5",d.appendChild(u);let h=document.createElement("div");h.style.cssText="font-size: 11px; line-height: 1.6;";let f=a.from,m=a.to;h.innerHTML=`
585
- <div><span style="color:#a6adc8;">\u7C7B\u578B:</span> ${a.type}</div>
586
- <div><span style="color:#a6adc8;">\u6765\u6E90:</span> ${f.path}</div>
587
- ${f.params?`<div><span style="color:#a6adc8;">\u6765\u6E90\u53C2\u6570:</span> ${JSON.stringify(f.params)}</div>`:""}
588
- ${f.query?`<div><span style="color:#a6adc8;">\u6765\u6E90\u67E5\u8BE2:</span> ${JSON.stringify(f.query)}</div>`:""}
589
- <div><span style="color:#a6adc8;">\u76EE\u6807:</span> ${m.path}</div>
590
- ${m.params?`<div><span style="color:#a6adc8;">\u76EE\u6807\u53C2\u6570:</span> ${JSON.stringify(m.params)}</div>`:""}
591
- ${m.query?`<div><span style="color:#a6adc8;">\u76EE\u6807\u67E5\u8BE2:</span> ${JSON.stringify(m.query)}</div>`:""}
592
- <div><span style="color:#a6adc8;">\u65F6\u95F4:</span> ${new Date(a.timestamp).toLocaleString("zh-CN")}</div>
593
- `,d.appendChild(h),e.appendChild(d)}}return this.element=e,e}destroy(){this.element&&(this.element.remove(),this.element=null),this.clearHistory(),this.currentRoute=null}};var le=class{constructor(e,t){this.components=[];this.flatNodes=[];this.expandedMap=new Map;this.filterQuery="";this.selectedId=null;this.scrollTop=0;this.scrollContainer=null;this.contentContainer=null;this.viewportContainer=null;this.destroyed=!1;var n,r,o,s;this.container=e,this.nodeHeight=(n=t==null?void 0:t.nodeHeight)!=null?n:28,this.visibleHeight=(r=t==null?void 0:t.visibleHeight)!=null?r:400,this.indentWidth=(o=t==null?void 0:t.indentWidth)!=null?o:20,this.onNodeClick=t==null?void 0:t.onNodeClick,this.defaultExpandAll=(s=t==null?void 0:t.defaultExpandAll)!=null?s:!1,this.boundScrollHandler=this.handleScroll.bind(this),this.renderContainer()}setComponents(e){this.components=e,this.defaultExpandAll&&this.components.length>0&&this.expandAllInternal(),this.flatten(),this.renderNodes()}setSelectedComponent(e){this.selectedId=e,this.renderNodes()}setFilter(e){this.filterQuery=e,this.flatten(),this.renderNodes()}expandAll(){this.expandAllInternal(),this.flatten(),this.renderNodes()}collapseAll(){this.expandedMap.clear(),this.flatten(),this.renderNodes()}destroy(){this.destroyed=!0,this.scrollContainer&&this.scrollContainer.removeEventListener("scroll",this.boundScrollHandler),this.container.innerHTML="",this.flatNodes=[],this.expandedMap.clear(),this.components=[],this.scrollContainer=null,this.contentContainer=null,this.viewportContainer=null}isAllExpanded(){if(this.components.length===0)return!1;for(let e of this.components)if(!this.expandedMap.get(e.id))return!1;return!0}expandAllInternal(){let e=t=>{for(let n of t)n.children&&n.children.length>0&&(this.expandedMap.set(n.id,!0),e(n.children))};e(this.components)}flatten(){this.flatNodes=[];let e=0,t=this.filterQuery.toLowerCase(),n=o=>!t||o.name.toLowerCase().includes(t)?!0:o.children?o.children.some(s=>n(s)):!1,r=(o,s,l)=>{var p;for(let c of o){let a=!t||c.name.toLowerCase().includes(t),d=n(c),u=(p=this.expandedMap.get(c.id))!=null?p:!1,h;t?h=l&&d:h=l;let f={node:c,depth:s,expanded:u,visible:h,flatIndex:e++};this.flatNodes.push(f),c.children&&c.children.length>0&&(t?r(c.children,s+1,h):r(c.children,s+1,h&&u))}};r(this.components,0,!0)}getVisibleNodes(){return this.flatNodes.filter(e=>e.visible)}renderContainer(){this.container.innerHTML="";let e=document.createElement("div");e.style.cssText="position: relative; overflow: hidden;",this.scrollContainer=document.createElement("div"),this.scrollContainer.style.cssText=`overflow-y: auto; height: ${this.visibleHeight}px; position: relative;`,this.scrollContainer.addEventListener("scroll",this.boundScrollHandler),this.contentContainer=document.createElement("div"),this.contentContainer.style.cssText="position: relative; width: 100%;",this.viewportContainer=document.createElement("div"),this.viewportContainer.style.cssText="position: absolute; top: 0; left: 0; right: 0;",this.contentContainer.appendChild(this.viewportContainer),this.scrollContainer.appendChild(this.contentContainer),e.appendChild(this.scrollContainer),this.container.appendChild(e)}renderNodes(){if(!this.contentContainer||!this.viewportContainer||this.destroyed)return;let e=this.getVisibleNodes(),t=e.length*this.nodeHeight;this.contentContainer.style.height=`${t}px`;let n=Math.floor(this.scrollTop/this.nodeHeight),r=Math.min(n+Math.ceil(this.visibleHeight/this.nodeHeight)+1,e.length);this.viewportContainer.innerHTML="";for(let o=n;o<r;o++){let s=e[o],l=this.createNodeElement(s,o);this.viewportContainer.appendChild(l)}}createNodeElement(e,t){let n=document.createElement("div"),r=e.node.id===this.selectedId,o=e.node.active,s=e.node.children&&e.node.children.length>0;n.style.cssText=`
594
- position: absolute;
595
- top: ${t*this.nodeHeight}px;
596
- left: 0;
597
- right: 0;
598
- height: ${this.nodeHeight}px;
599
- line-height: ${this.nodeHeight}px;
600
- padding-left: ${e.depth*this.indentWidth+8}px;
601
- cursor: pointer;
602
- font-family: monospace;
603
- font-size: 12px;
604
- white-space: nowrap;
605
- overflow: hidden;
606
- text-overflow: ellipsis;
607
- box-sizing: border-box;
608
- background: ${r?"#313244":"transparent"};
609
- color: ${o?"#89b4fa":"#cdd6f4"};
610
- border-bottom: 1px solid #1e1e2e;
611
- `;let l=document.createElement("span");l.style.cssText="display: inline-block; width: 14px; text-align: center; margin-right: 4px; font-size: 10px; color: #585b70;",s?l.textContent=e.expanded?"\u25BC":"\u25B6":l.textContent="\xB7",n.appendChild(l);let p=document.createElement("span");if(p.textContent=e.node.name,p.style.cssText="font-weight: bold;",n.appendChild(p),e.node.stateSummary){let d=document.createElement("span");d.textContent=` ${e.node.stateSummary}`,d.style.cssText="color: #a6adc8; font-size: 10px; margin-left: 6px;",n.appendChild(d)}if(e.node.propsCount!==void 0&&e.node.propsCount>0){let d=document.createElement("span");d.textContent=` [${e.node.propsCount} props]`,d.style.cssText="color: #585b70; font-size: 10px; margin-left: 4px;",n.appendChild(d)}let c=e.node,a=c.id;return n.addEventListener("click",()=>{var d;if(s){let u=(d=this.expandedMap.get(a))!=null?d:!1;this.expandedMap.set(a,!u),this.flatten(),this.renderNodes()}this.selectedId=a,this.onNodeClick&&this.onNodeClick(c)}),n}handleScroll(e){if(this.destroyed)return;let t=e.target;this.scrollTop=t.scrollTop,this.renderNodes()}getFlatNodes(){return[...this.flatNodes]}getVisibleNodeCount(){return this.getVisibleNodes().length}getTotalNodeCount(){return this.flatNodes.length}};var de=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},qe=100,je=1024,Je=.7,Ve=5,pe=class{constructor(e){this.counter=0;var t,n,r,o;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:qe,leakGrowthThreshold:(n=e==null?void 0:e.leakGrowthThreshold)!=null?n:je,leakRSquaredThreshold:(r=e==null?void 0:e.leakRSquaredThreshold)!=null?r:Je,leakMinSnapshots:(o=e==null?void 0:e.leakMinSnapshots)!=null?o:Ve},this.snapshots=new de(this.config.bufferSize)}trackMemoryUsage(e,t,n,r){if(e===void 0){let s=performance.memory;s&&(e=s.usedJSHeapSize,t=s.totalJSHeapSize,n=s.jsHeapSizeLimit)}if(e===void 0)return null;let o={timestamp:r!=null?r:Date.now(),usedJSHeapSize:e,totalJSHeapSize:t!=null?t:0,jsHeapSizeLimit:n!=null?n:0,index:this.counter++};return this.snapshots.push(o),o}getMemoryTrend(){let e=this.snapshots.getAll();return e.length===0?[]:e.map((t,n)=>{let r=n>0?e[n-1]:null,o=r?t.usedJSHeapSize-r.usedJSHeapSize:0,s=t.jsHeapSizeLimit>0?t.usedJSHeapSize/t.jsHeapSizeLimit*100:0;return{timestamp:t.timestamp,usedJSHeapSize:t.usedJSHeapSize,delta:o,usagePercent:s}})}detectMemoryLeak(){let e=this.snapshots.getAll();if(e.length<this.config.leakMinSnapshots)return{hasLeak:!1,severity:"none",description:`\u5FEB\u7167\u6570\u91CF\u4E0D\u8DB3\uFF08\u9700\u8981\u81F3\u5C11 ${this.config.leakMinSnapshots} \u4E2A\uFF0C\u5F53\u524D ${e.length} \u4E2A\uFF09`,snapshotCount:e.length,growthRate:0,rSquared:0};let t=e.length,n=0,r=0,o=0,s=0,l=0;for(let g=0;g<t;g++){let b=g,T=e[g].usedJSHeapSize;n+=b,r+=T,o+=b*T,s+=b*b,l+=T*T}let p=t*s-n*n,c=p!==0?(t*o-n*r)/p:0,a=r/t,d=0,u=0;for(let g=0;g<t;g++){let b=e[g].usedJSHeapSize,T=c*g+(r-c*n)/t;d+=(b-a)*(b-a),u+=(b-T)*(b-T)}let h=d!==0?1-u/d:0,f=(e[t-1].timestamp-e[0].timestamp)/1e3,m=f>0?c/f:0,x=h>=this.config.leakRSquaredThreshold&&m>=this.config.leakGrowthThreshold,v="none",y="\u672A\u68C0\u6D4B\u5230\u5185\u5B58\u6CC4\u6F0F";return x&&(m>=this.config.leakGrowthThreshold*10?(v="high",y=`\u68C0\u6D4B\u5230\u4E25\u91CD\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):m>=this.config.leakGrowthThreshold*3?(v="medium",y=`\u68C0\u6D4B\u5230\u4E2D\u7B49\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`):(v="low",y=`\u68C0\u6D4B\u5230\u8F7B\u5FAE\u5185\u5B58\u6CC4\u6F0F\uFF0C\u589E\u957F\u901F\u7387 ${Math.round(m)} bytes/s\uFF0CR\xB2=${h.toFixed(3)}`)),{hasLeak:x,severity:v,description:y,snapshotCount:t,growthRate:m,rSquared:h}}getMemoryReport(){let e=this.snapshots.getAll(),t=this.getMemoryTrend(),n=this.detectMemoryLeak(),r=null,o=0,s=0,l=0,p=1/0;for(let d of e)(!r||d.timestamp>r.timestamp)&&(r=d),d.usedJSHeapSize>o&&(o=d.usedJSHeapSize,s=d.timestamp),l+=d.usedJSHeapSize,d.usedJSHeapSize<p&&(p=d.usedJSHeapSize);let c=e.length>0?l/e.length:0;p===1/0&&(p=0);let a=e.length>=2?e[e.length-1].usedJSHeapSize-e[0].usedJSHeapSize:0;return{generatedAt:Date.now(),current:r,peakUsage:o,peakTimestamp:s,averageUsage:c,minUsage:p,totalGrowth:a,trend:t,leakDetection:n,snapshotCount:e.length}}getSnapshots(){return this.snapshots.getAll()}getSnapshotCount(){return this.snapshots.size}clear(){this.snapshots.clear(),this.counter=0}destroy(){this.clear()}};var ce=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},We=200,Ye=16,ue=class{constructor(e){this.counter=0;var t,n;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:We,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Ye},this.records=new ce(this.config.bufferSize)}trackRender(e,t){this.records.push({componentName:e,duration:t,timestamp:Date.now(),index:this.counter++})}getSlowRenderers(e){let t=e!=null?e:this.config.slowThreshold;return this.records.getAll().filter(r=>r.duration>t).map(r=>({componentName:r.componentName,duration:r.duration,timestamp:r.timestamp,overThreshold:r.duration-t})).sort((r,o)=>o.duration-r.duration)}getRenderStats(){let e=this.records.getAll(),t=this.config.slowThreshold;if(e.length===0)return{totalRenders:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,slowRenderCount:0,slowRenderRatio:0,byComponent:[]};let n=0,r=-1/0,o=1/0,s=0,l=new Map;for(let c of e){n+=c.duration,c.duration>r&&(r=c.duration),c.duration<o&&(o=c.duration),c.duration>t&&s++;let a=l.get(c.componentName);a||(a={renderCount:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,slowCount:0},l.set(c.componentName,a)),a.renderCount++,a.totalDuration+=c.duration,c.duration>a.maxDuration&&(a.maxDuration=c.duration),c.duration<a.minDuration&&(a.minDuration=c.duration),c.duration>t&&a.slowCount++}let p=Array.from(l.entries()).map(([c,a])=>({componentName:c,renderCount:a.renderCount,avgDuration:a.totalDuration/a.renderCount,maxDuration:a.maxDuration===-1/0?0:a.maxDuration,minDuration:a.minDuration===1/0?0:a.minDuration,totalDuration:a.totalDuration,slowCount:a.slowCount})).sort((c,a)=>a.avgDuration-c.avgDuration);return{totalRenders:e.length,totalDuration:n,avgDuration:n/e.length,maxDuration:r===-1/0?0:r,minDuration:o===1/0?0:o,slowRenderCount:s,slowRenderRatio:s/e.length,byComponent:p}}getRenderTimeline(){let e=this.records.getAll(),t=this.config.slowThreshold;return e.map((n,r)=>({componentName:n.componentName,duration:n.duration,timestamp:n.timestamp,isSlow:n.duration>t,gap:r>0?n.timestamp-e[r-1].timestamp:-1}))}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}clear(){this.records.clear(),this.counter=0}destroy(){this.clear()}};var he=class{constructor(e){this.head=0;this.count=0;this.capacity=e,this.buffer=new Array(e).fill(void 0)}push(e){let t=(this.head+this.count)%this.capacity;this.buffer[t]=e,this.count<this.capacity?this.count++:this.head=(this.head+1)%this.capacity}getAll(){let e=[];for(let t=0;t<this.count;t++){let n=this.buffer[(this.head+t)%this.capacity];n!==void 0&&e.push(n)}return e}get size(){return this.count}get isEmpty(){return this.count===0}clear(){this.buffer.fill(void 0),this.head=0,this.count=0}},Ke=100,Xe=1e3,Ge=2,me=class{constructor(e){this.pending=new Map;this.counter=0;var t,n,r;this.config={bufferSize:(t=e==null?void 0:e.bufferSize)!=null?t:Ke,slowThreshold:(n=e==null?void 0:e.slowThreshold)!=null?n:Xe,outlierSigmaThreshold:(r=e==null?void 0:e.outlierSigmaThreshold)!=null?r:Ge},this.records=new he(this.config.bufferSize)}startBatch(e){return this.pending.has(e)?!1:(this.pending.set(e,Date.now()),!0)}endBatch(e){let t=this.pending.get(e);if(t===void 0)return null;let n=Date.now(),r=n-t;this.pending.delete(e);let o={name:e,startTime:t,endTime:n,duration:r,index:this.counter++};return this.records.push(o),o}getBatchStats(){let e=this.records.getAll();if(e.length===0)return{totalBatches:0,totalDuration:0,avgDuration:0,maxDuration:0,minDuration:0,byName:[]};let t=0,n=-1/0,r=1/0,o=new Map;for(let l of e){t+=l.duration,l.duration>n&&(n=l.duration),l.duration<r&&(r=l.duration);let p=o.get(l.name);p||(p={count:0,totalDuration:0,maxDuration:-1/0,minDuration:1/0,durations:[]},o.set(l.name,p)),p.count++,p.totalDuration+=l.duration,l.duration>p.maxDuration&&(p.maxDuration=l.duration),l.duration<p.minDuration&&(p.minDuration=l.duration),p.durations.push(l.duration)}let s=Array.from(o.entries()).map(([l,p])=>{let c=p.totalDuration/p.count,a=0;for(let u of p.durations)a+=(u-c)*(u-c);a/=p.count;let d=Math.sqrt(a);return{name:l,count:p.count,avgDuration:c,maxDuration:p.maxDuration===-1/0?0:p.maxDuration,minDuration:p.minDuration===1/0?0:p.minDuration,totalDuration:p.totalDuration,stdDev:d}});return{totalBatches:e.length,totalDuration:t,avgDuration:t/e.length,maxDuration:n===-1/0?0:n,minDuration:r===1/0?0:r,byName:s}}detectAnomalousBatches(){let e=this.records.getAll();if(e.length===0)return[];let t=this.getBatchStats(),n=[],r=new Map;for(let o of t.byName)r.set(o.name,o);for(let o of e){let s=r.get(o.name);if(o.duration>this.config.slowThreshold){n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:"slow",description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u8D85\u8FC7\u6162\u64CD\u4F5C\u9608\u503C ${this.config.slowThreshold}ms`,deviationSigma:s&&s.stdDev>0?(o.duration-s.avgDuration)/s.stdDev:0});continue}if(s&&s.count>=2&&s.stdDev>0){let l=(o.duration-s.avgDuration)/s.stdDev;if(Math.abs(l)>this.config.outlierSigmaThreshold){let p=l>0?"slow":"fast";n.push({name:o.name,duration:o.duration,timestamp:o.endTime,anomalyType:p,description:`\u64CD\u4F5C "${o.name}" \u8017\u65F6 ${o.duration.toFixed(1)}ms\uFF0C\u504F\u79BB\u5E73\u5747\u503C ${l.toFixed(1)} \u4E2A\u6807\u51C6\u5DEE`,deviationSigma:l})}}}return n.sort((o,s)=>o.timestamp-s.timestamp),n}getRecords(){return this.records.getAll()}getRecordCount(){return this.records.size}getPendingBatches(){return Array.from(this.pending.keys())}clear(){this.records.clear(),this.pending.clear(),this.counter=0}destroy(){this.clear()}};var fe=class{constructor(e){this._installed=!1;this.app=null;var t,n,r,o,s,l;this.config={width:(t=e==null?void 0:e.width)!=null?t:420,height:(n=e==null?void 0:e.height)!=null?n:560,x:(r=e==null?void 0:e.x)!=null?r:0,y:(o=e==null?void 0:e.y)!=null?o:0,autoShow:(s=e==null?void 0:e.autoShow)!=null?s:!0,title:(l=e==null?void 0:e.title)!=null?l:"Lyt DevTools"},this.panel=new D({width:this.config.width,height:this.config.height,x:this.config.x,y:this.config.y,title:this.config.title}),this.componentTree=new B(this.panel,p=>{this.panel.switchTab("state"),this.stateInspector.refresh()}),this.stateInspector=new z(this.panel),this.eventTracker=new N(this.panel),this.timeTravel=new $(this.panel),this.panel.registerTabRenderer("components",p=>{this.componentTree.render(p)}),this.panel.registerTabRenderer("state",p=>{this.stateInspector.render(p)}),this.panel.registerTabRenderer("events",p=>{this.eventTracker.render(p)}),this.panel.registerTabRenderer("router",p=>{this.renderRouterTab(p)}),this.panel.renderContent(),this.config.autoShow||this.panel.hide()}install(e){if(this._installed)return;this.app=e,this._installed=!0,J(e,{onComponentCreated:n=>{this.componentTree.refresh()},onComponentUpdated:n=>{this.componentTree.refresh(),this.stateInspector.refresh()},onComponentUnmounted:n=>{this.componentTree.refresh()},onStateChanged:n=>{this.stateInspector.markChanged(`state.${n.path}`),this.stateInspector.refresh()},onEventEmitted:n=>{this.eventTracker.refresh()}}),this.panel.setConnected(!0)}show(){this.panel.show()}hide(){this.panel.hide()}toggle(){this.panel.toggle()}isVisible(){return this.panel.isVisible()}renderRouterTab(e){e.innerHTML="";let t=document.createElement("div");t.className="lyt-devtools-empty",t.style.cssText="padding: 40px 24px;",t.innerHTML=`
612
- <div style="font-size: 32px; margin-bottom: 12px;">\u{1F517}</div>
613
- <div style="color: #cdd6f4; font-size: 14px; margin-bottom: 8px; font-style: normal;">\u8DEF\u7531\u68C0\u67E5\u5668</div>
614
- <div style="color: #585b70; font-size: 12px;">
615
- \u6B64\u529F\u80FD\u9700\u8981\u5B89\u88C5 @lytjs/router \u5305\u3002<br>
616
- \u8DEF\u7531\u68C0\u67E5\u5668\u5C06\u663E\u793A\u5F53\u524D\u8DEF\u7531\u4FE1\u606F\u3001<br>
617
- \u8DEF\u7531\u5B88\u536B\u548C\u5BFC\u822A\u5386\u53F2\u3002
1288
+ border-bottom: 2px solid transparent;
1289
+ ">Router</button>
1290
+ <button class="lytjs-devtools-tab" data-tab="signals" style="
1291
+ flex: 1;
1292
+ padding: 10px;
1293
+ background: transparent;
1294
+ border: none;
1295
+ color: #d4d4d4;
1296
+ cursor: pointer;
1297
+ border-bottom: 2px solid transparent;
1298
+ ">Signals</button>
1299
+ <button class="lytjs-devtools-tab" data-tab="performance" style="
1300
+ flex: 1;
1301
+ padding: 10px;
1302
+ background: transparent;
1303
+ border: none;
1304
+ color: #d4d4d4;
1305
+ cursor: pointer;
1306
+ border-bottom: 2px solid transparent;
1307
+ ">Performance</button>
1308
+ `;
1309
+ const content = document.createElement("div");
1310
+ content.id = "lytjs-devtools-content";
1311
+ content.style.cssText = `
1312
+ flex: 1;
1313
+ overflow: auto;
1314
+ padding: 15px;
1315
+ `;
1316
+ panel.appendChild(header);
1317
+ panel.appendChild(tabs);
1318
+ panel.appendChild(content);
1319
+ document.body.appendChild(panel);
1320
+ document.getElementById("lytjs-devtools-close")?.addEventListener("click", () => this.close());
1321
+ tabs.querySelectorAll(".lytjs-devtools-tab").forEach((tab) => {
1322
+ tab.addEventListener("click", (e) => {
1323
+ const target = e.target;
1324
+ const tabName = target.dataset.tab;
1325
+ tabs.querySelectorAll(".lytjs-devtools-tab").forEach((t) => {
1326
+ t.style.background = "transparent";
1327
+ t.style.borderBottomColor = "transparent";
1328
+ });
1329
+ target.style.background = "#1e1e1e";
1330
+ target.style.borderBottomColor = "#4fc08d";
1331
+ this.renderTab(tabName || "components");
1332
+ });
1333
+ });
1334
+ this.renderTab("components");
1335
+ }
1336
+ /**
1337
+ * 渲染标签页内容
1338
+ */
1339
+ renderTab(tab) {
1340
+ const content = document.getElementById("lytjs-devtools-content");
1341
+ if (!content) return;
1342
+ switch (tab) {
1343
+ case "components":
1344
+ content.innerHTML = this.renderComponentsTab();
1345
+ break;
1346
+ case "store":
1347
+ content.innerHTML = this.renderStoreTab();
1348
+ break;
1349
+ case "router":
1350
+ content.innerHTML = this.renderRouterTab();
1351
+ break;
1352
+ case "signals":
1353
+ content.innerHTML = this.renderSignalsTab();
1354
+ break;
1355
+ case "performance":
1356
+ content.innerHTML = this.renderPerformanceTab();
1357
+ break;
1358
+ }
1359
+ }
1360
+ /**
1361
+ * 渲染组件标签页
1362
+ */
1363
+ renderComponentsTab() {
1364
+ const tree = getComponentTree();
1365
+ if (tree.length === 0) {
1366
+ return '<div style="color: #666; text-align: center; padding: 40px;">No components found.<br>Register your root component with registerRootComponent().</div>';
1367
+ }
1368
+ return `<pre style="margin: 0; white-space: pre-wrap; word-break: break-all;">${serializeComponentTree(tree)}</pre>`;
1369
+ }
1370
+ /**
1371
+ * 渲染 Store 标签页
1372
+ */
1373
+ renderStoreTab() {
1374
+ const states = getStoreStates();
1375
+ if (states.length === 0) {
1376
+ return '<div style="color: #666; text-align: center; padding: 40px;">No stores registered.<br>Use registerStore() to register your stores.</div>';
1377
+ }
1378
+ let html = '<div style="margin-bottom: 10px;">';
1379
+ html += `<strong>Registered Stores:</strong> ${getRegisteredStoreIds().join(", ")}`;
1380
+ html += "</div>";
1381
+ html += `<pre style="margin: 0; white-space: pre-wrap; word-break: break-all;">${serializeStoreStates(states)}</pre>`;
1382
+ return html;
1383
+ }
1384
+ /**
1385
+ * 渲染 Signals 标签页
1386
+ */
1387
+ renderSignalsTab() {
1388
+ const nodes = getSignalNodes();
1389
+ let html = `
1390
+ <div style="margin-bottom: 15px;">
1391
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
1392
+ <strong>\u{1F4CA} Signals (${nodes.length})</strong>
1393
+ <div>
1394
+ <button id="lytjs-devtools-create-snapshot" style="
1395
+ background: #4fc08d;
1396
+ border: none;
1397
+ color: white;
1398
+ padding: 5px 10px;
1399
+ border-radius: 4px;
1400
+ cursor: pointer;
1401
+ font-size: 11px;
1402
+ ">\u521B\u5EFA\u5FEB\u7167</button>
1403
+ <button id="lytjs-devtools-clear-signals" style="
1404
+ background: #ff4d4f;
1405
+ border: none;
1406
+ color: white;
1407
+ padding: 5px 10px;
1408
+ border-radius: 4px;
1409
+ cursor: pointer;
1410
+ font-size: 11px;
1411
+ margin-left: 5px;
1412
+ ">\u6E05\u7A7A</button>
1413
+ </div>
1414
+ </div>
1415
+
1416
+ <div style="display: flex; gap: 10px; margin-bottom: 10px;">
1417
+ <button id="lytjs-devtools-tab-signals-list" style="
1418
+ flex: 1;
1419
+ padding: 8px;
1420
+ background: #4fc08d;
1421
+ border: none;
1422
+ color: white;
1423
+ border-radius: 4px;
1424
+ cursor: pointer;
1425
+ font-size: 11px;
1426
+ ">\u5217\u8868\u89C6\u56FE</button>
1427
+ <button id="lytjs-devtools-tab-signals-graph" style="
1428
+ flex: 1;
1429
+ padding: 8px;
1430
+ background: #333;
1431
+ border: none;
1432
+ color: #d4d4d4;
1433
+ border-radius: 4px;
1434
+ cursor: pointer;
1435
+ font-size: 11px;
1436
+ ">\u4F9D\u8D56\u56FE</button>
1437
+ <button id="lytjs-devtools-tab-signals-timetravel" style="
1438
+ flex: 1;
1439
+ padding: 8px;
1440
+ background: #333;
1441
+ border: none;
1442
+ color: #d4d4d4;
1443
+ border-radius: 4px;
1444
+ cursor: pointer;
1445
+ font-size: 11px;
1446
+ ">\u65F6\u95F4\u65C5\u884C</button>
1447
+ </div>
1448
+
1449
+ <div id="lytjs-devtools-signals-content">
1450
+ ${this.renderSignalsList(nodes)}
1451
+ </div>
618
1452
  </div>
619
- `,e.appendChild(t)}refreshTree(){this.app&&ee(this.app),this.componentTree.refresh()}clearAllRecords(){te(),this.eventTracker.refresh(),this.stateInspector.refresh()}getPanel(){return this.panel}getComponentTree(){return this.componentTree}getStateInspector(){return this.stateInspector}getEventTracker(){return this.eventTracker}getTimeTravel(){return this.timeTravel}destroy(){this.componentTree.destroy(),this.stateInspector.destroy(),this.eventTracker.destroy(),this.timeTravel.destroy(),this.panel.destroy(),ne(),this._installed=!1,this.app=null}};function Dt(i){let e=null;return{install(t){if(e)return;e=new fe(i),t.globalProperties&&(t.globalProperties.__LYT_DEVTOOLS__=e);let n=t;(n._instance!==void 0||n.mount)&&e.install(n)}}}export{me as BatchAnalyzer,F as ComponentProfiler,B as ComponentTreeInspector,fe as DevTools,D as DevToolsPanel,ie as EventPanel,N as EventTracker,pe as MemoryTracker,se as PerfPanel,A as PerformanceCollector,ue as RenderTracker,oe as RoutePanel,ae as RouterPanel,z as StateInspector,$ as TimeTravelDebugger,le as VirtualComponentTree,te as clearRecords,J as connectToApp,Dt as createDevTools,ne as disconnect,k as getAllComponents,Y as getChildComponents,I as getComponentById,Ne as getComponentCount,Be as getComponentEvents,X as getComponentStateChanges,K as getEventRecords,W as getRootComponent,Q as getSelectedComponent,P as getSelectedComponentId,Ie as getStateChangeRecords,ze as isAppConnected,ee as refreshComponentTree,G as selectComponent,Z as setComponentState};
1453
+ `;
1454
+ return html;
1455
+ }
1456
+ /**
1457
+ * 渲染信号列表
1458
+ */
1459
+ renderSignalsList(nodes) {
1460
+ if (nodes.length === 0) {
1461
+ return '<div style="color: #666; text-align: center; padding: 40px;">\u6682\u65E0\u4FE1\u53F7\u6570\u636E<br>\u4F7F\u7528 registerSignal() \u6CE8\u518C\u4FE1\u53F7</div>';
1462
+ }
1463
+ let html = '<div style="max-height: 400px; overflow-y: auto;">';
1464
+ nodes.forEach((node) => {
1465
+ const typeIcon = node.type === "signal" ? "\u{1F4CC}" : node.type === "computed" ? "\u{1F9EE}" : "\u26A1";
1466
+ const typeColor = node.type === "signal" ? "#4fc08d" : node.type === "computed" ? "#1890ff" : "#faad14";
1467
+ html += `
1468
+ <div style="
1469
+ background: #252526;
1470
+ border-radius: 4px;
1471
+ padding: 10px;
1472
+ margin-bottom: 8px;
1473
+ border-left: 3px solid ${typeColor};
1474
+ ">
1475
+ <div style="display: flex; justify-content: space-between; align-items: center;">
1476
+ <span style="font-weight: bold;">${typeIcon} ${node.name}</span>
1477
+ <span style="color: #888; font-size: 10px;">${node.type}</span>
1478
+ </div>
1479
+ <div style="color: #888; font-size: 11px; margin-top: 5px;">
1480
+ \u66F4\u65B0\u6B21\u6570: ${node.updateCount} |
1481
+ \u6700\u540E\u66F4\u65B0: ${node.lastUpdateTime ? new Date(node.lastUpdateTime).toLocaleTimeString() : "N/A"}
1482
+ </div>
1483
+ ${node.averageUpdateTime > 0 ? `<div style="color: #888; font-size: 11px;">\u5E73\u5747\u8017\u65F6: ${node.averageUpdateTime.toFixed(2)}ms</div>` : ""}
1484
+ <div style="color: #888; font-size: 10px; margin-top: 5px;">
1485
+ \u4F9D\u8D56: ${node.dependencies.length > 0 ? node.dependencies.join(", ") : "\u65E0"} |
1486
+ \u88AB\u4F9D\u8D56: ${node.dependents.length > 0 ? node.dependents.join(", ") : "\u65E0"}
1487
+ </div>
1488
+ </div>
1489
+ `;
1490
+ });
1491
+ html += "</div>";
1492
+ return html;
1493
+ }
1494
+ /**
1495
+ * 渲染 Performance 标签页
1496
+ */
1497
+ renderPerformanceTab() {
1498
+ const stats = getPerformanceStats();
1499
+ const records = getPerformanceRecords(50);
1500
+ let html = `
1501
+ <div style="margin-bottom: 15px;">
1502
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
1503
+ <strong>\u26A1 Performance</strong>
1504
+ <button id="lytjs-devtools-clear-performance" style="
1505
+ background: #ff4d4f;
1506
+ border: none;
1507
+ color: white;
1508
+ padding: 5px 10px;
1509
+ border-radius: 4px;
1510
+ cursor: pointer;
1511
+ font-size: 11px;
1512
+ ">\u6E05\u7A7A\u8BB0\u5F55</button>
1513
+ </div>
1514
+
1515
+ <div style="background: #252526; border-radius: 4px; padding: 15px; margin-bottom: 15px;">
1516
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
1517
+ <div style="text-align: center;">
1518
+ <div style="color: #888; font-size: 11px;">\u603B\u8BB0\u5F55\u6570</div>
1519
+ <div style="font-size: 24px; font-weight: bold; color: #4fc08d;">${stats.totalRecords}</div>
1520
+ </div>
1521
+ <div style="text-align: center;">
1522
+ <div style="color: #888; font-size: 11px;">\u5E73\u5747\u8017\u65F6</div>
1523
+ <div style="font-size: 24px; font-weight: bold; color: #1890ff;">${stats.averageDuration.toFixed(2)}ms</div>
1524
+ </div>
1525
+ <div style="text-align: center;">
1526
+ <div style="color: #888; font-size: 11px;">\u6700\u5927\u8017\u65F6</div>
1527
+ <div style="font-size: 24px; font-weight: bold; color: #ff4d4f;">${stats.maxDuration.toFixed(2)}ms</div>
1528
+ </div>
1529
+ <div style="text-align: center;">
1530
+ <div style="color: #888; font-size: 11px;">\u6700\u5C0F\u8017\u65F6</div>
1531
+ <div style="font-size: 24px; font-weight: bold; color: #52c41a;">${stats.minDuration.toFixed(2)}ms</div>
1532
+ </div>
1533
+ </div>
1534
+ </div>
1535
+ `;
1536
+ if (Object.keys(stats.byType).length > 0) {
1537
+ html += `
1538
+ <div style="margin-bottom: 15px;">
1539
+ <strong style="display: block; margin-bottom: 10px;">\u6309\u7C7B\u578B\u7EDF\u8BA1</strong>
1540
+ <div style="background: #252526; border-radius: 4px; padding: 10px;">
1541
+ `;
1542
+ Object.entries(stats.byType).forEach(([type, data]) => {
1543
+ const typeColor = type === "signal" ? "#4fc08d" : type === "computed" ? "#1890ff" : "#faad14";
1544
+ html += `
1545
+ <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #333;">
1546
+ <span style="color: ${typeColor};">${type}</span>
1547
+ <span>${data.count} \u6B21 | \u5E73\u5747 ${data.average.toFixed(2)}ms | \u6700\u5927 ${data.max.toFixed(2)}ms</span>
1548
+ </div>
1549
+ `;
1550
+ });
1551
+ html += "</div></div>";
1552
+ }
1553
+ if (records.length > 0) {
1554
+ html += `
1555
+ <div>
1556
+ <strong style="display: block; margin-bottom: 10px;">\u6700\u8FD1\u8BB0\u5F55 (50\u6761)</strong>
1557
+ <div style="background: #252526; border-radius: 4px; padding: 10px; max-height: 300px; overflow-y: auto;">
1558
+ `;
1559
+ records.slice().reverse().forEach((record) => {
1560
+ const durationColor = record.duration > 16 ? "#ff4d4f" : record.duration > 8 ? "#faad14" : "#4fc08d";
1561
+ html += `
1562
+ <div style="display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #333; font-size: 11px;">
1563
+ <span>${record.name}</span>
1564
+ <span style="color: ${durationColor};">${record.duration.toFixed(2)}ms</span>
1565
+ <span style="color: #888;">${new Date(record.timestamp).toLocaleTimeString()}</span>
1566
+ </div>
1567
+ `;
1568
+ });
1569
+ html += "</div></div>";
1570
+ } else {
1571
+ html += '<div style="color: #666; text-align: center; padding: 40px;">\u6682\u65E0\u6027\u80FD\u6570\u636E</div>';
1572
+ }
1573
+ html += "</div>";
1574
+ return html;
1575
+ }
1576
+ /**
1577
+ * 渲染 Router 标签页
1578
+ */
1579
+ renderRouterTab() {
1580
+ if (!isRouterRegistered()) {
1581
+ return '<div style="color: #666; text-align: center; padding: 40px;">Router not registered.<br>Use registerRouter() to register your router.</div>';
1582
+ }
1583
+ const route = getCurrentRoute();
1584
+ const routes = getRoutes();
1585
+ let html = '<div style="margin-bottom: 15px;">';
1586
+ html += "<strong>Current Route:</strong>";
1587
+ html += "</div>";
1588
+ html += `<pre style="margin: 0 0 15px 0; white-space: pre-wrap; word-break: break-all; background: #252526; padding: 10px; border-radius: 4px;">${serializeRouteInfo(route)}</pre>`;
1589
+ if (routes.length > 0) {
1590
+ html += '<div style="margin-bottom: 10px;">';
1591
+ html += "<strong>All Routes:</strong>";
1592
+ html += "</div>";
1593
+ html += '<ul style="margin: 0; padding-left: 20px;">';
1594
+ for (const r of routes) {
1595
+ html += `<li>${r.path}${r.name ? ` (${r.name})` : ""}</li>`;
1596
+ }
1597
+ html += "</ul>";
1598
+ }
1599
+ return html;
1600
+ }
1601
+ /**
1602
+ * 打开面板
1603
+ */
1604
+ open() {
1605
+ if (!this.options.enabled) return;
1606
+ const panel = document.getElementById("lytjs-devtools");
1607
+ if (panel) {
1608
+ panel.style[this.options.position] = "0";
1609
+ this.isOpen = true;
1610
+ this.refresh();
1611
+ }
1612
+ }
1613
+ /**
1614
+ * 关闭面板
1615
+ */
1616
+ close() {
1617
+ if (typeof document === "undefined") return;
1618
+ const panel = document.getElementById("lytjs-devtools");
1619
+ if (panel) {
1620
+ panel.style[this.options.position] = `-${this.options.size}px`;
1621
+ this.isOpen = false;
1622
+ }
1623
+ }
1624
+ /**
1625
+ * 切换面板
1626
+ */
1627
+ toggle() {
1628
+ if (this.isOpen) {
1629
+ this.close();
1630
+ } else {
1631
+ this.open();
1632
+ }
1633
+ }
1634
+ /**
1635
+ * 刷新内容
1636
+ */
1637
+ refresh() {
1638
+ const activeTab = document.querySelector(".lytjs-devtools-tab.active");
1639
+ if (activeTab) {
1640
+ this.renderTab(activeTab.dataset.tab || "components");
1641
+ }
1642
+ }
1643
+ };
1644
+ function installDevTools(options2) {
1645
+ if (!devtoolsInstance) {
1646
+ devtoolsInstance = new DevTools(options2);
1647
+ }
1648
+ return devtoolsInstance;
1649
+ }
1650
+ function getDevTools() {
1651
+ return devtoolsInstance;
1652
+ }
1653
+ function uninstallDevTools() {
1654
+ if (devtoolsInstance) {
1655
+ devtoolsInstance.close();
1656
+ devtoolsInstance = null;
1657
+ }
1658
+ if (typeof document !== "undefined") {
1659
+ const panel = document.getElementById("lytjs-devtools");
1660
+ if (panel) {
1661
+ panel.remove();
1662
+ }
1663
+ }
1664
+ }
1665
+
1666
+ export { LARGE_SCALE_SCENARIOS, 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 };
1667
+ //# sourceMappingURL=index.mjs.map
1668
+ //# sourceMappingURL=index.mjs.map