Changeset 0.28.3 (#187)

This commit is contained in:
2026-03-14 12:30:57 +00:00
parent b2c03be001
commit f68a58b073
46 changed files with 1589 additions and 107 deletions

View File

@@ -9,8 +9,13 @@
// Events.on('chat.message.*', (payload, meta) => { ... });
// Events.emit('chat.typing.abc123', { user: 'jeff' });
// Events.connect('/ws');
//
// Exports: window.Events
// ==========================================
(function() {
'use strict';
const Events = {
_handlers: new Map(), // label → Set<{fn, once}>
@@ -191,9 +196,9 @@ const Events = {
}
// Add auth token as query param (WebSocket doesn't support headers)
const tokens = JSON.parse(localStorage.getItem(typeof _storageKey !== 'undefined' ? _storageKey : 'sb_auth') || '{}');
if (tokens.accessToken) {
url += (url.includes('?') ? '&' : '?') + `token=${encodeURIComponent(tokens.accessToken)}`;
const token = (typeof API !== 'undefined' && API.accessToken) ? API.accessToken : null;
if (token) {
url += (url.includes('?') ? '&' : '?') + `token=${encodeURIComponent(token)}`;
} else {
console.warn('[EventBus] No auth token — skipping WebSocket');
return;
@@ -325,3 +330,6 @@ const Events = {
return subs;
}
};
window.Events = Events;
})();