Abstract Core utils vs SDC
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3571369. --> Reported by: [b_sharpe](https://www.drupal.org/user/2512258) Related to !6 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Keep the SDC but refactor the JS into a decoupled library pattern something like:</p> <pre>export class AguiChat {<br>&nbsp; constructor(container, options = {}) {<br>&nbsp;&nbsp;&nbsp; this.container = container;<br>&nbsp;&nbsp;&nbsp; this.options = options;<br>&nbsp;&nbsp;&nbsp; this.messages = [];<br>&nbsp; }<br><br>&nbsp; // Public API<br>&nbsp; clearChat() { /* ... */ }<br>&nbsp; addMessage(message) { /* ... */ }<br>&nbsp; setIndicator(type, message) { /* ... */ }<br>&nbsp; <br>&nbsp; // Events for customization<br>&nbsp; on(event, callback) { /* ... */ }<br>&nbsp; <br>&nbsp; // Let consumers handle rendering<br>&nbsp; render() {<br>&nbsp;&nbsp;&nbsp; this.container.dispatchEvent(new CustomEvent('agui:render', {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; detail: { messages: this.messages }<br>&nbsp;&nbsp;&nbsp; }));<br>&nbsp; }<br>}</pre><p>This lets:</p> <ul> <li>SDC users get it working immediately</li> <li>Power users override rendering while keeping your logic</li> <li>Everyone benefits from updates to the core library</li> </ul>
issue