Fix TTS module initialization and dependency issues. Update module IDs for consistency, improve circular dependency detection, and fix UI Controller event handling.

This commit is contained in:
2025-04-04 19:15:28 +00:00
parent 02c7b9ef28
commit 49a5af252c
33 changed files with 7227 additions and 4060 deletions
+25 -33
View File
@@ -1,10 +1,9 @@
import { BaseModule } from './base-module.js';
import { moduleRegistry } from './module-registry.js';
import { ModuleEvent } from './base-module.js';
class UIEffects extends BaseModule {
constructor() {
super('ui-effects');
super('ui-effects', 'UI Effects');
// No external dependencies
this.dependencies = [];
@@ -13,8 +12,8 @@ class UIEffects extends BaseModule {
this.activeEffects = new Map();
this.ambientEffectsActive = false;
// Effects configuration
this.effectsConfig = {
// Effects configuration - use the config object from BaseModule
this.updateConfig({
candleFlicker: {
intensity: 0.5,
speed: 0.8
@@ -26,32 +25,25 @@ class UIEffects extends BaseModule {
backgroundEffects: {
enabled: true
}
};
});
// Bind methods that use 'this' internally or are used as callbacks/event handlers
this.initialize = this.initialize.bind(this); // Bind initialize as it calls dispatchEvent
this.updateCandleEffect = this.updateCandleEffect.bind(this); // Used with requestAnimationFrame
this.setupEffectElements = this.setupEffectElements.bind(this);
this.createEffectsOverlay = this.createEffectsOverlay.bind(this);
this.createCandleEffect = this.createCandleEffect.bind(this);
this.createLightingElement = this.createLightingElement.bind(this);
this.setupAmbientEffects = this.setupAmbientEffects.bind(this);
this.setupCandleFlickerEffect = this.setupCandleFlickerEffect.bind(this);
this.startAmbientEffects = this.startAmbientEffects.bind(this);
this.stopAmbientEffects = this.stopAmbientEffects.bind(this);
this.applyEffect = this.applyEffect.bind(this);
this.applyShakeEffect = this.applyShakeEffect.bind(this);
this.applyFlashEffect = this.applyFlashEffect.bind(this);
this.applyTextEmphasis = this.applyTextEmphasis.bind(this);
this.processCommand = this.processCommand.bind(this);
// Store a bound version of dispatchEvent for use in methods
this._dispatchModuleEvent = (name, detail) => {
document.dispatchEvent(new CustomEvent(name, {
detail: { moduleId: this.id, ...detail },
bubbles: true
}));
};
// Use bindMethods from parent class
this.bindMethods([
'updateCandleEffect',
'setupEffectElements',
'createEffectsOverlay',
'createCandleEffect',
'createLightingElement',
'setupAmbientEffects',
'setupCandleFlickerEffect',
'startAmbientEffects',
'stopAmbientEffects',
'applyEffect',
'applyShakeEffect',
'applyFlashEffect',
'applyTextEmphasis',
'processCommand'
]);
console.log('UIEffects: Constructor initialized');
}
@@ -72,8 +64,8 @@ class UIEffects extends BaseModule {
this.reportProgress(100, 'UI Effects ready');
// Use the DOM event API directly instead of this.dispatchEvent
this._dispatchModuleEvent('ui:effects:ready', {});
// Use the parent's dispatchEvent method
this.dispatchEvent('ui:effects:ready', {});
return true;
} catch (error) {
@@ -124,7 +116,7 @@ class UIEffects extends BaseModule {
setupAmbientEffects() {
// Initialize candle flicker effect
if (this.candleEffectElement && this.effectsConfig.candleFlicker.enabled !== false) {
if (this.candleEffectElement && this.config.candleFlicker.enabled !== false) {
this.setupCandleFlickerEffect();
}
}
@@ -137,7 +129,7 @@ class UIEffects extends BaseModule {
updateCandleEffect() {
if (!this.candleEffectElement || !this.ambientEffectsActive) return;
const { intensity, speed } = this.effectsConfig.candleFlicker;
const { intensity, speed } = this.config.candleFlicker;
// Create subtle random flickering effect
const flickerAmount = Math.random() * intensity;