UNPKG

mcp-quiz-server

Version:

🧠 AI-Powered Quiz Management via Model Context Protocol (MCP) - Create, manage, and take quizzes directly from VS Code, Claude, and other AI agents.

64 lines • 1.65 kB
import { EventEmitter } from '../utils/index'; export class Component extends EventEmitter { constructor(element) { super(); this.mounted = false; if (typeof element === 'string') { const found = document.querySelector(element); if (!found) { throw new Error(`Element not found: ${element}`); } this.element = found; } else { this.element = element; } } mount() { if (this.mounted) return; this.mounted = true; this.render(); this.bindEvents(); this.onMount(); } unmount() { if (!this.mounted) return; this.mounted = false; this.unbindEvents(); this.onUnmount(); } bindEvents() { } unbindEvents() { } onMount() { } onUnmount() { } updateElement(updates) { if (updates.innerHTML !== undefined) { this.element.innerHTML = updates.innerHTML; } if (updates.textContent !== undefined) { this.element.textContent = updates.textContent; } if (updates.className !== undefined) { this.element.className = updates.className; } if (updates.hidden !== undefined) { this.element.hidden = updates.hidden; } } show() { this.element.classList.remove('hidden'); } hide() { this.element.classList.add('hidden'); } toggle(force) { this.element.classList.toggle('hidden', force); } } //# sourceMappingURL=Component.js.map