css2class 2.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 (57) hide show
  1. package/API.md +1143 -0
  2. package/CHANGELOG.md +291 -0
  3. package/CONFIG.md +1096 -0
  4. package/CONTRIBUTING.md +571 -0
  5. package/MIGRATION.md +402 -0
  6. package/README.md +634 -0
  7. package/bin/class2css.js +380 -0
  8. package/class2css.config.js +124 -0
  9. package/common.css +3 -0
  10. package/configs/colors.config.js +62 -0
  11. package/configs/layout.config.js +110 -0
  12. package/configs/spacing.config.js +37 -0
  13. package/configs/typography.config.js +41 -0
  14. package/docs/.vitepress/config.mjs +65 -0
  15. package/docs/.vitepress/theme/custom.css +74 -0
  16. package/docs/.vitepress/theme/index.js +7 -0
  17. package/docs/guide/cli.md +97 -0
  18. package/docs/guide/concepts.md +63 -0
  19. package/docs/guide/config-template.md +365 -0
  20. package/docs/guide/config.md +275 -0
  21. package/docs/guide/faq.md +202 -0
  22. package/docs/guide/getting-started.md +83 -0
  23. package/docs/guide/important-and-static.md +67 -0
  24. package/docs/guide/incremental.md +162 -0
  25. package/docs/guide/rules-reference.md +354 -0
  26. package/docs/guide/units.md +57 -0
  27. package/docs/index.md +68 -0
  28. package/package.json +49 -0
  29. package/run.js +90 -0
  30. package/src/README.md +571 -0
  31. package/src/core/CacheManager.js +650 -0
  32. package/src/core/CompatibilityAdapter.js +264 -0
  33. package/src/core/ConfigManager.js +431 -0
  34. package/src/core/ConfigValidator.js +350 -0
  35. package/src/core/EventBus.js +77 -0
  36. package/src/core/FullScanManager.js +430 -0
  37. package/src/core/StateManager.js +631 -0
  38. package/src/docs/DocsServer.js +179 -0
  39. package/src/example.js +106 -0
  40. package/src/generators/DynamicClassGenerator.js +674 -0
  41. package/src/index.js +1046 -0
  42. package/src/parsers/ClassParser.js +572 -0
  43. package/src/parsers/ImportantParser.js +279 -0
  44. package/src/parsers/RegexCompiler.js +200 -0
  45. package/src/utils/ClassChangeTracker.js +366 -0
  46. package/src/utils/ConfigDiagnostics.js +673 -0
  47. package/src/utils/CssFormatter.js +261 -0
  48. package/src/utils/FileUtils.js +230 -0
  49. package/src/utils/Logger.js +150 -0
  50. package/src/utils/Throttle.js +172 -0
  51. package/src/utils/UnitProcessor.js +334 -0
  52. package/src/utils/WxssClassExtractor.js +137 -0
  53. package/src/watchers/ConfigWatcher.js +413 -0
  54. package/src/watchers/FileWatcher.js +133 -0
  55. package/src/writers/FileWriter.js +302 -0
  56. package/src/writers/UnifiedWriter.js +370 -0
  57. package/styles.config.js +250 -0
@@ -0,0 +1,631 @@
1
+ /*
2
+ * @LastEditors: biz
3
+ */
4
+ class StateManager {
5
+ constructor(eventBus) {
6
+ this.eventBus = eventBus;
7
+
8
+ // 核心状态集合
9
+ this.classListSet = new Set();
10
+ this.userStaticClassListSet = new Set();
11
+ this.userBaseClassListSet = new Set();
12
+ this.cssWrite = new Set();
13
+
14
+ // 扫描状态
15
+ this.isScanning = false;
16
+ this.scanCompletedTime = null;
17
+ this.initialScanComplete = false;
18
+
19
+ // 全量扫描只读数据
20
+ this.fullScanReadOnlyData = {
21
+ classListSet: new Set(),
22
+ userStaticClassListSet: new Set(),
23
+ userBaseClassListSet: new Set(),
24
+ scanTime: null,
25
+ isLocked: false,
26
+ };
27
+
28
+ // 全局样式缓存
29
+ this.globalStyleCache = {
30
+ classListSet: new Set(),
31
+ userStaticClassListSet: new Set(),
32
+ userBaseClassListSet: new Set(),
33
+ fileClassMap: new Map(),
34
+ lastUpdateTime: Date.now(),
35
+ };
36
+
37
+ // 配置状态管理
38
+ this.configState = {
39
+ currentConfig: null,
40
+ configHash: null,
41
+ lastConfigUpdate: null,
42
+ configHistory: [],
43
+ maxHistorySize: 10,
44
+ };
45
+
46
+ // 状态变更追踪
47
+ this.changeTracker = {
48
+ pendingChanges: new Set(),
49
+ lastStateSnapshot: null,
50
+ changeTimestamp: null,
51
+ impactedModules: new Set(),
52
+ };
53
+
54
+ // 影响分析缓存
55
+ this.impactAnalysisCache = new Map();
56
+
57
+ // 同步状态
58
+ this.syncState = {
59
+ isSyncing: false,
60
+ lastSyncTime: null,
61
+ syncQueue: [],
62
+ failedSyncs: [],
63
+ };
64
+
65
+ // 性能监控
66
+ this.performanceMetrics = {
67
+ stateUpdateCount: 0,
68
+ averageUpdateTime: 0,
69
+ lastUpdateDuration: 0,
70
+ totalUpdateTime: 0,
71
+ };
72
+ }
73
+
74
+ // 状态获取方法
75
+ getClassListSet() {
76
+ return this.classListSet;
77
+ }
78
+
79
+ getUserStaticClassListSet() {
80
+ return this.userStaticClassListSet;
81
+ }
82
+
83
+ getUserBaseClassListSet() {
84
+ return this.userBaseClassListSet;
85
+ }
86
+
87
+ getCssWrite() {
88
+ return this.cssWrite;
89
+ }
90
+
91
+ getFullScanData() {
92
+ return this.fullScanReadOnlyData;
93
+ }
94
+
95
+ getGlobalStyleCache() {
96
+ return this.globalStyleCache;
97
+ }
98
+
99
+ // 扫描状态管理
100
+ setScanning(scanning) {
101
+ this.isScanning = scanning;
102
+ this.eventBus.emit('scanning:changed', scanning);
103
+ }
104
+
105
+ isCurrentlyScanning() {
106
+ return this.isScanning;
107
+ }
108
+
109
+ setScanCompleted() {
110
+ this.scanCompletedTime = Date.now();
111
+ this.initialScanComplete = true;
112
+ this.eventBus.emit('scan:completed', this.scanCompletedTime);
113
+ }
114
+
115
+ isInitialScanComplete() {
116
+ return this.initialScanComplete;
117
+ }
118
+
119
+ // 状态更新方法
120
+ updateClassListSet(classList) {
121
+ this.classListSet.clear();
122
+ classList.forEach((cls) => this.classListSet.add(cls));
123
+ this.eventBus.emit('classList:updated', this.classListSet);
124
+ }
125
+
126
+ updateUserStaticClassListSet(staticClassList) {
127
+ this.userStaticClassListSet.clear();
128
+ staticClassList.forEach((cls) => this.userStaticClassListSet.add(cls));
129
+ this.eventBus.emit('staticClassList:updated', this.userStaticClassListSet);
130
+ }
131
+
132
+ updateFullScanData(data) {
133
+ this.fullScanReadOnlyData = {
134
+ ...data,
135
+ isLocked: true,
136
+ scanTime: Date.now(),
137
+ };
138
+ this.eventBus.emit('fullScanData:updated', this.fullScanReadOnlyData);
139
+ }
140
+
141
+ // 缓存管理
142
+ clearCssWrite() {
143
+ this.cssWrite.clear();
144
+ this.eventBus.emit('cssWrite:cleared');
145
+ }
146
+
147
+ addToCssWrite(key) {
148
+ this.cssWrite.add(key);
149
+ }
150
+
151
+ hasInCssWrite(key) {
152
+ return this.cssWrite.has(key);
153
+ }
154
+
155
+ // 状态重置
156
+ reset() {
157
+ this.classListSet.clear();
158
+ this.userStaticClassListSet.clear();
159
+ this.userBaseClassListSet.clear();
160
+ this.cssWrite.clear();
161
+ this.isScanning = false;
162
+ this.scanCompletedTime = null;
163
+ this.initialScanComplete = false;
164
+
165
+ this.fullScanReadOnlyData = {
166
+ classListSet: new Set(),
167
+ userStaticClassListSet: new Set(),
168
+ userBaseClassListSet: new Set(),
169
+ scanTime: null,
170
+ isLocked: false,
171
+ };
172
+
173
+ this.globalStyleCache = {
174
+ classListSet: new Set(),
175
+ userStaticClassListSet: new Set(),
176
+ userBaseClassListSet: new Set(),
177
+ fileClassMap: new Map(),
178
+ lastUpdateTime: Date.now(),
179
+ };
180
+
181
+ this.eventBus.emit('state:reset');
182
+ }
183
+
184
+ // 统一文件模式状态管理
185
+ setUnifiedFileMode(enabled) {
186
+ this.isUnifiedFileMode = enabled;
187
+ this.eventBus.emit('unifiedFileMode:changed', enabled);
188
+ }
189
+
190
+ isInUnifiedFileMode() {
191
+ return this.isUnifiedFileMode || false;
192
+ }
193
+
194
+ // 全量扫描管理器状态同步
195
+ syncWithFullScanManager(fullScanManagerData) {
196
+ this.fullScanReadOnlyData = {
197
+ classListSet: new Set(fullScanManagerData.classListSet),
198
+ userStaticClassListSet: new Set(fullScanManagerData.userStaticClassListSet),
199
+ scanTime: fullScanManagerData.scanTime,
200
+ isLocked: fullScanManagerData.isLocked,
201
+ };
202
+ this.eventBus.emit('fullScanData:synced', this.fullScanReadOnlyData);
203
+ }
204
+
205
+ // ==================== 配置变更影响分析 ====================
206
+
207
+ // 更新配置状态
208
+ updateConfigState(config, configHash) {
209
+ const previousConfig = this.configState.currentConfig;
210
+ const previousHash = this.configState.configHash;
211
+
212
+ // 保存配置历史
213
+ if (previousConfig) {
214
+ this.configState.configHistory.unshift({
215
+ config: previousConfig,
216
+ hash: previousHash,
217
+ timestamp: this.configState.lastConfigUpdate,
218
+ });
219
+
220
+ // 限制历史大小
221
+ if (this.configState.configHistory.length > this.configState.maxHistorySize) {
222
+ this.configState.configHistory.pop();
223
+ }
224
+ }
225
+
226
+ // 更新当前配置
227
+ this.configState.currentConfig = config;
228
+ this.configState.configHash = configHash;
229
+ this.configState.lastConfigUpdate = Date.now();
230
+
231
+ // 分析配置变更影响
232
+ if (previousConfig) {
233
+ const impactAnalysis = this.analyzeConfigChangeImpact(previousConfig, config);
234
+ this.eventBus.emit('config:impact:analyzed', impactAnalysis);
235
+
236
+ // 如果有重大影响,触发状态同步
237
+ if (impactAnalysis.requiresStateSync) {
238
+ this.scheduleStateSync('config_change', impactAnalysis);
239
+ }
240
+ }
241
+
242
+ this.eventBus.emit('config:state:updated', {
243
+ configHash,
244
+ timestamp: this.configState.lastConfigUpdate,
245
+ hasHistory: this.configState.configHistory.length > 0,
246
+ });
247
+ }
248
+
249
+ // 分析配置变更影响
250
+ analyzeConfigChangeImpact(oldConfig, newConfig) {
251
+ const cacheKey = `${this.getConfigHash(oldConfig)}-${this.getConfigHash(newConfig)}`;
252
+
253
+ // 检查缓存
254
+ if (this.impactAnalysisCache.has(cacheKey)) {
255
+ return this.impactAnalysisCache.get(cacheKey);
256
+ }
257
+
258
+ const impact = {
259
+ timestamp: Date.now(),
260
+ requiresStateSync: false,
261
+ requiresCacheReset: false,
262
+ requiresFullRescan: false,
263
+ affectedModules: new Set(),
264
+ changedProperties: [],
265
+ severity: 'low', // low, medium, high, critical
266
+ };
267
+
268
+ // 分析具体变更
269
+ const changes = this.detectConfigChanges(oldConfig, newConfig);
270
+ impact.changedProperties = changes;
271
+
272
+ // 评估影响严重程度
273
+ for (const change of changes) {
274
+ this.evaluateChangeImpact(change, impact);
275
+ }
276
+
277
+ // 确定整体严重程度
278
+ if (impact.affectedModules.has('parser') || impact.affectedModules.has('generator')) {
279
+ impact.severity = 'high';
280
+ impact.requiresStateSync = true;
281
+ } else if (impact.affectedModules.has('cache') || impact.affectedModules.has('config')) {
282
+ impact.severity = 'medium';
283
+ impact.requiresCacheReset = true;
284
+ }
285
+
286
+ // 缓存分析结果
287
+ this.impactAnalysisCache.set(cacheKey, impact);
288
+
289
+ // 限制缓存大小
290
+ if (this.impactAnalysisCache.size > 100) {
291
+ const firstKey = this.impactAnalysisCache.keys().next().value;
292
+ this.impactAnalysisCache.delete(firstKey);
293
+ }
294
+
295
+ return impact;
296
+ }
297
+
298
+ // 检测配置变更
299
+ detectConfigChanges(oldConfig, newConfig) {
300
+ const changes = [];
301
+ const allKeys = new Set([...Object.keys(oldConfig), ...Object.keys(newConfig)]);
302
+
303
+ for (const key of allKeys) {
304
+ const oldValue = oldConfig[key];
305
+ const newValue = newConfig[key];
306
+
307
+ if (JSON.stringify(oldValue) !== JSON.stringify(newValue)) {
308
+ changes.push({
309
+ property: key,
310
+ oldValue,
311
+ newValue,
312
+ type: this.getChangeType(oldValue, newValue),
313
+ });
314
+ }
315
+ }
316
+
317
+ return changes;
318
+ }
319
+
320
+ // 获取变更类型
321
+ getChangeType(oldValue, newValue) {
322
+ if (oldValue === undefined) return 'added';
323
+ if (newValue === undefined) return 'removed';
324
+ return 'modified';
325
+ }
326
+
327
+ // 评估单个变更的影响
328
+ evaluateChangeImpact(change, impact) {
329
+ const { property, type } = change;
330
+
331
+ // 关键配置属性的影响评估
332
+ const criticalProperties = ['cssName', 'baseClassName', 'atomicClassMap'];
333
+ const moduleProperties = {
334
+ system: ['cache', 'config'],
335
+ output: ['writer'],
336
+ cssName: ['parser', 'generator'],
337
+ baseClassName: ['parser', 'generator'],
338
+ atomicClassMap: ['parser', 'generator'],
339
+ importantFlags: ['parser'],
340
+ multiFile: ['writer'],
341
+ variants: ['generator'],
342
+ };
343
+
344
+ if (criticalProperties.includes(property)) {
345
+ impact.requiresFullRescan = true;
346
+ impact.severity = 'critical';
347
+ }
348
+
349
+ if (moduleProperties[property]) {
350
+ moduleProperties[property].forEach((module) => {
351
+ impact.affectedModules.add(module);
352
+ });
353
+ }
354
+ }
355
+
356
+ // 获取配置哈希
357
+ getConfigHash(config) {
358
+ return require('crypto').createHash('md5').update(JSON.stringify(config)).digest('hex');
359
+ }
360
+
361
+ // ==================== 状态同步逻辑 ====================
362
+
363
+ // 调度状态同步
364
+ scheduleStateSync(reason, metadata = {}) {
365
+ const syncTask = {
366
+ id: this.generateSyncId(),
367
+ reason,
368
+ metadata,
369
+ timestamp: Date.now(),
370
+ priority: this.getSyncPriority(reason),
371
+ };
372
+
373
+ this.syncState.syncQueue.push(syncTask);
374
+ this.syncState.syncQueue.sort((a, b) => b.priority - a.priority);
375
+
376
+ this.eventBus.emit('state:sync:scheduled', syncTask);
377
+
378
+ // 如果当前没有在同步,立即开始
379
+ if (!this.syncState.isSyncing) {
380
+ this.processNextSync();
381
+ }
382
+ }
383
+
384
+ // 处理下一个同步任务
385
+ async processNextSync() {
386
+ if (this.syncState.syncQueue.length === 0 || this.syncState.isSyncing) {
387
+ return;
388
+ }
389
+
390
+ this.syncState.isSyncing = true;
391
+ const syncTask = this.syncState.syncQueue.shift();
392
+
393
+ const startTime = Date.now();
394
+
395
+ try {
396
+ this.eventBus.emit('state:sync:started', syncTask);
397
+
398
+ await this.executeSyncTask(syncTask);
399
+
400
+ const duration = Date.now() - startTime;
401
+ this.syncState.lastSyncTime = Date.now();
402
+
403
+ this.eventBus.emit('state:sync:completed', {
404
+ ...syncTask,
405
+ duration,
406
+ success: true,
407
+ });
408
+ } catch (error) {
409
+ const duration = Date.now() - startTime;
410
+
411
+ this.syncState.failedSyncs.push({
412
+ ...syncTask,
413
+ error: error.message,
414
+ duration,
415
+ timestamp: Date.now(),
416
+ });
417
+
418
+ this.eventBus.emit('state:sync:failed', {
419
+ ...syncTask,
420
+ error: error.message,
421
+ duration,
422
+ });
423
+
424
+ // 限制失败记录数量
425
+ if (this.syncState.failedSyncs.length > 50) {
426
+ this.syncState.failedSyncs.shift();
427
+ }
428
+ } finally {
429
+ this.syncState.isSyncing = false;
430
+
431
+ // 处理下一个同步任务
432
+ if (this.syncState.syncQueue.length > 0) {
433
+ setTimeout(() => this.processNextSync(), 10);
434
+ }
435
+ }
436
+ }
437
+
438
+ // 执行同步任务
439
+ async executeSyncTask(syncTask) {
440
+ const { reason, metadata } = syncTask;
441
+
442
+ switch (reason) {
443
+ case 'config_change':
444
+ await this.syncConfigChange(metadata);
445
+ break;
446
+ case 'file_change':
447
+ await this.syncFileChange(metadata);
448
+ break;
449
+ case 'cache_update':
450
+ await this.syncCacheUpdate(metadata);
451
+ break;
452
+ case 'full_rescan':
453
+ await this.syncFullRescan(metadata);
454
+ break;
455
+ default:
456
+ await this.syncGeneric(metadata);
457
+ }
458
+ }
459
+
460
+ // 配置变更同步
461
+ async syncConfigChange(impactAnalysis) {
462
+ if (impactAnalysis.requiresFullRescan) {
463
+ this.eventBus.emit('state:sync:triggerFullRescan', impactAnalysis);
464
+ }
465
+
466
+ if (impactAnalysis.requiresCacheReset) {
467
+ this.eventBus.emit('state:sync:triggerCacheReset', impactAnalysis);
468
+ }
469
+
470
+ // 更新影响的模块状态
471
+ for (const module of impactAnalysis.affectedModules) {
472
+ this.eventBus.emit(`state:sync:updateModule`, { module, impactAnalysis });
473
+ }
474
+ }
475
+
476
+ // 文件变更同步
477
+ async syncFileChange(metadata) {
478
+ // 标记需要重新扫描的文件
479
+ this.changeTracker.pendingChanges.add('file_change');
480
+ this.changeTracker.impactedModules.add('parser');
481
+ this.changeTracker.changeTimestamp = Date.now();
482
+ }
483
+
484
+ // 缓存更新同步
485
+ async syncCacheUpdate(metadata) {
486
+ this.changeTracker.pendingChanges.add('cache_update');
487
+ this.changeTracker.impactedModules.add('cache');
488
+ }
489
+
490
+ // 全量重扫描同步
491
+ async syncFullRescan(metadata) {
492
+ this.reset();
493
+ this.eventBus.emit('state:sync:fullRescanRequested', metadata);
494
+ }
495
+
496
+ // 通用同步
497
+ async syncGeneric(metadata) {
498
+ this.eventBus.emit('state:sync:generic', metadata);
499
+ }
500
+
501
+ // 生成同步ID
502
+ generateSyncId() {
503
+ return `sync_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
504
+ }
505
+
506
+ // 获取同步优先级
507
+ getSyncPriority(reason) {
508
+ const priorities = {
509
+ config_change: 10,
510
+ full_rescan: 9,
511
+ file_change: 5,
512
+ cache_update: 3,
513
+ generic: 1,
514
+ };
515
+ return priorities[reason] || 1;
516
+ }
517
+
518
+ // ==================== 性能监控 ====================
519
+
520
+ // 开始状态更新监控
521
+ startUpdateMonitoring() {
522
+ this.updateStartTime = Date.now();
523
+ }
524
+
525
+ // 结束状态更新监控
526
+ endUpdateMonitoring() {
527
+ if (this.updateStartTime) {
528
+ const duration = Date.now() - this.updateStartTime;
529
+ this.performanceMetrics.stateUpdateCount++;
530
+ this.performanceMetrics.lastUpdateDuration = duration;
531
+ this.performanceMetrics.totalUpdateTime += duration;
532
+ this.performanceMetrics.averageUpdateTime =
533
+ this.performanceMetrics.totalUpdateTime / this.performanceMetrics.stateUpdateCount;
534
+
535
+ this.eventBus.emit('state:performance:updated', {
536
+ duration,
537
+ averageTime: this.performanceMetrics.averageUpdateTime,
538
+ updateCount: this.performanceMetrics.stateUpdateCount,
539
+ });
540
+
541
+ this.updateStartTime = null;
542
+ }
543
+ }
544
+
545
+ // ==================== 增强的状态统计 ====================
546
+
547
+ // 获取完整状态统计
548
+ getStats() {
549
+ return {
550
+ // 基础状态
551
+ classListCount: this.classListSet.size,
552
+ staticClassCount: this.userStaticClassListSet.size,
553
+ baseClassCount: this.userBaseClassListSet.size,
554
+ cssWriteCount: this.cssWrite.size,
555
+ isScanning: this.isScanning,
556
+ initialScanComplete: this.initialScanComplete,
557
+ fullScanDataLocked: this.fullScanReadOnlyData.isLocked,
558
+ fullScanDataTime: this.fullScanReadOnlyData.scanTime,
559
+ isUnifiedFileMode: this.isInUnifiedFileMode(),
560
+
561
+ // 配置状态
562
+ config: {
563
+ hasCurrentConfig: this.configState.currentConfig !== null,
564
+ lastUpdate: this.configState.lastConfigUpdate,
565
+ historySize: this.configState.configHistory.length,
566
+ currentHash: this.configState.configHash,
567
+ },
568
+
569
+ // 变更追踪
570
+ changeTracking: {
571
+ pendingChanges: this.changeTracker.pendingChanges.size,
572
+ lastChangeTime: this.changeTracker.changeTimestamp,
573
+ impactedModules: Array.from(this.changeTracker.impactedModules),
574
+ hasSnapshot: this.changeTracker.lastStateSnapshot !== null,
575
+ },
576
+
577
+ // 同步状态
578
+ sync: {
579
+ isSyncing: this.syncState.isSyncing,
580
+ queueSize: this.syncState.syncQueue.length,
581
+ lastSyncTime: this.syncState.lastSyncTime,
582
+ failedSyncsCount: this.syncState.failedSyncs.length,
583
+ },
584
+
585
+ // 性能指标
586
+ performance: {
587
+ ...this.performanceMetrics,
588
+ impactAnalysisCacheSize: this.impactAnalysisCache.size,
589
+ },
590
+ };
591
+ }
592
+
593
+ // 获取配置历史
594
+ getConfigHistory() {
595
+ return this.configState.configHistory;
596
+ }
597
+
598
+ // 获取同步队列状态
599
+ getSyncQueueStatus() {
600
+ return {
601
+ queue: this.syncState.syncQueue,
602
+ isSyncing: this.syncState.isSyncing,
603
+ failedSyncs: this.syncState.failedSyncs.slice(-10), // 最近10个失败记录
604
+ };
605
+ }
606
+
607
+ // 清理状态
608
+ cleanup() {
609
+ this.impactAnalysisCache.clear();
610
+ this.changeTracker.pendingChanges.clear();
611
+ this.changeTracker.impactedModules.clear();
612
+ this.syncState.syncQueue.length = 0;
613
+ this.syncState.failedSyncs.length = 0;
614
+
615
+ this.eventBus.emit('state:cleaned');
616
+ }
617
+
618
+ // 重置性能指标
619
+ resetPerformanceMetrics() {
620
+ this.performanceMetrics = {
621
+ stateUpdateCount: 0,
622
+ averageUpdateTime: 0,
623
+ lastUpdateDuration: 0,
624
+ totalUpdateTime: 0,
625
+ };
626
+
627
+ this.eventBus.emit('state:performance:reset');
628
+ }
629
+ }
630
+
631
+ module.exports = StateManager;