using Astralis; using Invercargill; using Invercargill.DataStructures; using Inversion; using Spry; /** * AuroraCanvasEndpoint - Returns just the aurora waves for HTMX polling * * This endpoint is polled every 5 seconds by the demo page. * It evolves the aurora state and returns fresh wave HTML. */ public class AuroraCanvasEndpoint : Component { private AuroraState aurora_state = inject(); private ComponentFactory factory = inject(); public override string markup { get { return """ """; }} public override async void prepare() throws Error { // Create wave components var waves = new Series(); foreach (var wave in aurora_state.get_waves()) { var component = factory.create(); component.y_offset = wave.y_offset; component.amplitude = wave.amplitude; component.frequency = wave.frequency; component.color1 = wave.color1; component.color2 = wave.color2; component.opacity = wave.opacity; component.animation_delay = wave.animation_delay; waves.add(component); } set_outlet_children("waves", waves); } public async override void handle_action(string action) throws Error { if (action == "Poll") { // Evolve the aurora naturally when polled aurora_state.evolve(); // prepare() will be called automatically to render the waves } } }