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> constructor(container, options = {}) {<br> this.container = container;<br> this.options = options;<br> this.messages = [];<br> }<br><br> // Public API<br> clearChat() { /* ... */ }<br> addMessage(message) { /* ... */ }<br> setIndicator(type, message) { /* ... */ }<br> <br> // Events for customization<br> on(event, callback) { /* ... */ }<br> <br> // Let consumers handle rendering<br> render() {<br> this.container.dispatchEvent(new CustomEvent('agui:render', {<br> detail: { messages: this.messages }<br> }));<br> }<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