@nolag/notify 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @nolag/notify
3
+ * React Native entry point.
4
+ *
5
+ * Identical to the browser entry: this SDK is transport-agnostic and attaches
6
+ * to an injected NoLag client, so it has no platform-specific code of its own.
7
+ * The entry exists purely so Metro has a `react-native` condition to resolve.
8
+ * Metro matches "react-native" then "import"/"require" and does not understand
9
+ * the "browser" condition, so without this it resolves the Node build of this
10
+ * package and, through it, the Node build of @nolag/js-sdk (which imports
11
+ * `ws` and fails to bundle).
12
+ */
13
+ export * from "./browser";
@@ -0,0 +1,919 @@
1
+ /**
2
+ * Tiny typed event emitter — framework-agnostic base for NoLag SDKs.
3
+ */
4
+ class EventEmitter {
5
+ constructor() {
6
+ this._handlers = new Map();
7
+ }
8
+ on(event, handler) {
9
+ if (!this._handlers.has(event)) {
10
+ this._handlers.set(event, new Set());
11
+ }
12
+ this._handlers.get(event).add(handler);
13
+ return this;
14
+ }
15
+ off(event, handler) {
16
+ if (handler) {
17
+ this._handlers.get(event)?.delete(handler);
18
+ }
19
+ else {
20
+ this._handlers.delete(event);
21
+ }
22
+ return this;
23
+ }
24
+ removeAllListeners() {
25
+ this._handlers.clear();
26
+ return this;
27
+ }
28
+ emit(event, ...args) {
29
+ const handlers = this._handlers.get(event);
30
+ if (!handlers)
31
+ return;
32
+ for (const handler of handlers) {
33
+ try {
34
+ handler(...args);
35
+ }
36
+ catch (e) {
37
+ console.error(`Error in ${String(event)} handler:`, e);
38
+ }
39
+ }
40
+ }
41
+ listenerCount(event) {
42
+ return this._handlers.get(event)?.size ?? 0;
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Bounded, deduplicated notification cache ordered by timestamp,
48
+ * with read/unread tracking.
49
+ */
50
+ class NotificationStore {
51
+ constructor(maxSize) {
52
+ this._notifications = [];
53
+ this._ids = new Set();
54
+ this._maxSize = maxSize;
55
+ }
56
+ /**
57
+ * Add a notification. Returns true if the notification was new (not a duplicate).
58
+ */
59
+ add(notification) {
60
+ if (this._ids.has(notification.id)) {
61
+ return false;
62
+ }
63
+ this._ids.add(notification.id);
64
+ this._notifications.push(notification);
65
+ // Keep sorted by timestamp
66
+ if (this._notifications.length > 1 &&
67
+ notification.timestamp < this._notifications[this._notifications.length - 2].timestamp) {
68
+ this._notifications.sort((a, b) => a.timestamp - b.timestamp);
69
+ }
70
+ // Trim if over capacity
71
+ while (this._notifications.length > this._maxSize) {
72
+ const removed = this._notifications.shift();
73
+ this._ids.delete(removed.id);
74
+ }
75
+ return true;
76
+ }
77
+ /**
78
+ * Mark a notification as read by id.
79
+ * Returns true if the notification was found.
80
+ */
81
+ markRead(id) {
82
+ const notification = this._notifications.find((n) => n.id === id);
83
+ if (!notification)
84
+ return false;
85
+ notification.read = true;
86
+ return true;
87
+ }
88
+ /**
89
+ * Mark all notifications as read.
90
+ */
91
+ markAllRead() {
92
+ for (const notification of this._notifications) {
93
+ notification.read = true;
94
+ }
95
+ }
96
+ /**
97
+ * Get all notifications in timestamp order.
98
+ */
99
+ getAll() {
100
+ return [...this._notifications];
101
+ }
102
+ /**
103
+ * Get all unread notifications.
104
+ */
105
+ getUnread() {
106
+ return this._notifications.filter((n) => !n.read);
107
+ }
108
+ /**
109
+ * Get the number of unread notifications.
110
+ */
111
+ get unreadCount() {
112
+ return this._notifications.filter((n) => !n.read).length;
113
+ }
114
+ /**
115
+ * Get notification count.
116
+ */
117
+ get size() {
118
+ return this._notifications.length;
119
+ }
120
+ /**
121
+ * Check if a notification ID exists.
122
+ */
123
+ has(id) {
124
+ return this._ids.has(id);
125
+ }
126
+ /**
127
+ * Clear all notifications.
128
+ */
129
+ clear() {
130
+ this._notifications = [];
131
+ this._ids.clear();
132
+ }
133
+ }
134
+
135
+ function generateId() {
136
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
137
+ return crypto.randomUUID();
138
+ }
139
+ return 'xxxx-xxxx-xxxx-xxxx'.replace(/x/g, () => Math.floor(Math.random() * 16).toString(16));
140
+ }
141
+ function createLogger(prefix, enabled) {
142
+ if (!enabled) {
143
+ return (..._args) => { };
144
+ }
145
+ return (...args) => {
146
+ console.log(`[${prefix}]`, ...args);
147
+ };
148
+ }
149
+ // ============ Wrapper registry ============
150
+ // One wrapper instance per (client, appName): two wrappers sharing an app on
151
+ // one connection would collide on topics, presence and the online lobby.
152
+ // Warn (not throw): HMR and tests legitimately construct before disposing.
153
+ const wrapperRegistry = new WeakMap();
154
+ /** Register a wrapper against a client + appName; warns on collision. */
155
+ function registerWrapper(client, appName, wrapperName) {
156
+ let apps = wrapperRegistry.get(client);
157
+ if (!apps) {
158
+ apps = new Map();
159
+ wrapperRegistry.set(client, apps);
160
+ }
161
+ const existing = apps.get(appName);
162
+ if (existing) {
163
+ console.warn(`[${wrapperName}] Another wrapper (${existing}) is already attached to this client for app "${appName}". ` +
164
+ `Use one wrapper per (client, app) — detach the other instance first.`);
165
+ }
166
+ apps.set(appName, wrapperName);
167
+ }
168
+ /** Release a wrapper's (client, appName) registration on detach. */
169
+ function releaseWrapper(client, appName) {
170
+ wrapperRegistry.get(client)?.delete(appName);
171
+ }
172
+
173
+ /** Default app name for channel topic prefixes */
174
+ const DEFAULT_APP_NAME = 'notify';
175
+ /** Default max notifications kept per channel */
176
+ const DEFAULT_MAX_NOTIFICATION_CACHE = 500;
177
+ /** Topic name for notifications within a channel */
178
+ const TOPIC_NOTIFICATIONS = 'notifications';
179
+ /** Topic name for read receipts within a channel */
180
+ const TOPIC_READ = '_read';
181
+ /** Lobby ID for global online presence */
182
+ const LOBBY_ID = 'online';
183
+ /** Delay before the post-setup lobby presence refetch (catches simultaneous joiners) */
184
+ const LOBBY_REFRESH_DELAY_MS = 2000;
185
+
186
+ /**
187
+ * NotifyChannel — a single notification channel with read/unread tracking.
188
+ *
189
+ * Created via `NoLagNotify.subscribe(name)`. Do not instantiate directly.
190
+ */
191
+ class NotifyChannel extends EventEmitter {
192
+ /** @internal */
193
+ constructor(name, roomContext, options, log, isConnected) {
194
+ super();
195
+ this._active = false;
196
+ // Stored topic handler refs — cleanup removes exactly these, never all
197
+ // handlers for a topic (the client may be shared with other consumers).
198
+ this._onNotificationsRef = null;
199
+ this._onReadRef = null;
200
+ this.name = name;
201
+ this._roomContext = roomContext;
202
+ this._options = options;
203
+ this._store = new NotificationStore(options.maxNotificationCache);
204
+ this._log = log;
205
+ this._isConnected = isConnected;
206
+ }
207
+ // ============ Public Properties ============
208
+ /** All notifications in this channel (timestamp order) */
209
+ get notifications() {
210
+ return this._store.getAll();
211
+ }
212
+ /** Number of unread notifications */
213
+ get unreadCount() {
214
+ return this._store.unreadCount;
215
+ }
216
+ /** Whether this channel is currently active */
217
+ get active() {
218
+ return this._active;
219
+ }
220
+ // ============ Sending ============
221
+ /**
222
+ * Send a notification to this channel.
223
+ */
224
+ send(title, opts) {
225
+ const notification = {
226
+ id: generateId(),
227
+ channel: this.name,
228
+ title,
229
+ body: opts?.body,
230
+ icon: opts?.icon,
231
+ data: opts?.data,
232
+ timestamp: Date.now()};
233
+ this._roomContext.emit(TOPIC_NOTIFICATIONS, {
234
+ id: notification.id,
235
+ channel: notification.channel,
236
+ title: notification.title,
237
+ body: notification.body,
238
+ icon: notification.icon,
239
+ data: notification.data,
240
+ timestamp: notification.timestamp,
241
+ });
242
+ }
243
+ // ============ Read Tracking ============
244
+ /**
245
+ * Mark a single notification as read by id.
246
+ * Emits the read receipt to the _read topic for cross-tab sync.
247
+ */
248
+ markRead(id) {
249
+ if (this._store.markRead(id)) {
250
+ this._log('Mark read:', id);
251
+ this._roomContext.emit(TOPIC_READ, { id, channel: this.name });
252
+ this.emit('read', id);
253
+ }
254
+ }
255
+ /**
256
+ * Mark all notifications in this channel as read.
257
+ */
258
+ markAllRead() {
259
+ this._store.markAllRead();
260
+ this._log('Mark all read:', this.name);
261
+ this._roomContext.emit(TOPIC_READ, { all: true, channel: this.name });
262
+ this.emit('readAll');
263
+ }
264
+ /**
265
+ * Get all notifications (alias for the notifications getter).
266
+ */
267
+ getNotifications() {
268
+ return this._store.getAll();
269
+ }
270
+ /**
271
+ * Get all unread notifications.
272
+ */
273
+ getUnread() {
274
+ return this._store.getUnread();
275
+ }
276
+ // ============ Internal (called by NoLagNotify) ============
277
+ /** @internal Subscribe to notifications and _read topics */
278
+ _subscribe() {
279
+ this._log('Channel subscribe:', this.name);
280
+ this._roomContext.subscribe(TOPIC_NOTIFICATIONS);
281
+ this._roomContext.subscribe(TOPIC_READ);
282
+ // Listen for notifications (refs stored for handler-specific removal)
283
+ this._onNotificationsRef = (data, meta) => {
284
+ this._handleIncomingNotification(data, meta);
285
+ };
286
+ this._roomContext.on(TOPIC_NOTIFICATIONS, this._onNotificationsRef);
287
+ this._onReadRef = (data) => {
288
+ this._handleIncomingRead(data);
289
+ };
290
+ this._roomContext.on(TOPIC_READ, this._onReadRef);
291
+ }
292
+ /** @internal Activate this channel (mark as visible/active) */
293
+ _activate() {
294
+ this._log('Channel activate:', this.name);
295
+ this._active = true;
296
+ }
297
+ /** @internal Deactivate this channel */
298
+ _deactivate() {
299
+ this._log('Channel deactivate:', this.name);
300
+ this._active = false;
301
+ }
302
+ /** @internal Handle replay start event */
303
+ _handleReplayStart(count) {
304
+ this.emit('replayStart', { count });
305
+ }
306
+ /** @internal Handle replay end event */
307
+ _handleReplayEnd(replayed) {
308
+ this.emit('replayEnd', { replayed });
309
+ }
310
+ /** @internal Unsubscribe and clean up */
311
+ _cleanup() {
312
+ this._log('Channel cleanup:', this.name);
313
+ // Server unsubscribes need a live socket; skip when disconnected
314
+ // (best-effort — the core would no-op with an error callback anyway).
315
+ if (this._isConnected()) {
316
+ this._roomContext.unsubscribe(TOPIC_NOTIFICATIONS);
317
+ this._roomContext.unsubscribe(TOPIC_READ);
318
+ }
319
+ // Handler-specific removal only: the client may be shared, and a bare
320
+ // off(topic) would strip other consumers' handlers too.
321
+ if (this._onNotificationsRef)
322
+ this._roomContext.off(TOPIC_NOTIFICATIONS, this._onNotificationsRef);
323
+ if (this._onReadRef)
324
+ this._roomContext.off(TOPIC_READ, this._onReadRef);
325
+ this._onNotificationsRef = null;
326
+ this._onReadRef = null;
327
+ this._store.clear();
328
+ this.removeAllListeners();
329
+ }
330
+ // ============ Private ============
331
+ _handleIncomingNotification(data, meta) {
332
+ const raw = data;
333
+ const notification = {
334
+ id: raw.id || generateId(),
335
+ channel: this.name,
336
+ title: raw.title,
337
+ body: raw.body,
338
+ icon: raw.icon,
339
+ data: raw.data,
340
+ timestamp: raw.timestamp || Date.now(),
341
+ read: false,
342
+ isReplay: meta.isReplay ?? false,
343
+ };
344
+ if (this._store.add(notification)) {
345
+ this._log('Notification received:', notification.id, notification.title);
346
+ this.emit('notification', notification);
347
+ }
348
+ }
349
+ _handleIncomingRead(data) {
350
+ const raw = data;
351
+ if (raw.all === true) {
352
+ this._store.markAllRead();
353
+ this.emit('readAll');
354
+ }
355
+ else if (typeof raw.id === 'string') {
356
+ if (this._store.markRead(raw.id)) {
357
+ this.emit('read', raw.id);
358
+ }
359
+ }
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Aggregates unread notification counts across channels.
365
+ */
366
+ class BadgeManager {
367
+ constructor() {
368
+ this._counts = new Map();
369
+ }
370
+ /**
371
+ * Update the unread count for a channel.
372
+ */
373
+ update(channel, unreadCount) {
374
+ this._counts.set(channel, unreadCount);
375
+ }
376
+ /**
377
+ * Get the unread count for a specific channel.
378
+ */
379
+ get(channel) {
380
+ return this._counts.get(channel) ?? 0;
381
+ }
382
+ /**
383
+ * Get all badge counts — total and per-channel breakdown.
384
+ */
385
+ getAll() {
386
+ const byChannel = {};
387
+ let total = 0;
388
+ for (const [channel, count] of this._counts) {
389
+ byChannel[channel] = count;
390
+ total += count;
391
+ }
392
+ return { total, byChannel };
393
+ }
394
+ /**
395
+ * Clear all counts.
396
+ */
397
+ clear() {
398
+ this._counts.clear();
399
+ }
400
+ }
401
+
402
+ /**
403
+ * Maps actorTokenId to NotifyUser for global presence tracking.
404
+ */
405
+ class PresenceManager {
406
+ constructor() {
407
+ this._users = new Map();
408
+ this._actorToUserId = new Map();
409
+ }
410
+ /**
411
+ * Add or update a user from presence data.
412
+ * Returns the NotifyUser, or null if presence data is invalid.
413
+ */
414
+ addFromPresence(actorTokenId, presenceData, joinedAt) {
415
+ if (!presenceData?.userId)
416
+ return null;
417
+ const existing = this._actorToUserId.get(actorTokenId);
418
+ const userId = presenceData.userId || existing || actorTokenId;
419
+ const user = {
420
+ userId,
421
+ actorTokenId,
422
+ metadata: presenceData.metadata,
423
+ joinedAt: joinedAt || Date.now(),
424
+ };
425
+ this._users.set(userId, user);
426
+ this._actorToUserId.set(actorTokenId, userId);
427
+ return user;
428
+ }
429
+ /**
430
+ * Remove a user by actorTokenId.
431
+ * Returns the removed user, or null if not found.
432
+ */
433
+ removeByActorId(actorTokenId) {
434
+ const userId = this._actorToUserId.get(actorTokenId);
435
+ if (!userId)
436
+ return null;
437
+ const user = this._users.get(userId) || null;
438
+ this._users.delete(userId);
439
+ this._actorToUserId.delete(actorTokenId);
440
+ return user;
441
+ }
442
+ /**
443
+ * Get a user by userId.
444
+ */
445
+ getUser(userId) {
446
+ return this._users.get(userId);
447
+ }
448
+ /**
449
+ * Get a user by actorTokenId.
450
+ */
451
+ getUserByActorId(actorTokenId) {
452
+ const userId = this._actorToUserId.get(actorTokenId);
453
+ return userId ? this._users.get(userId) : undefined;
454
+ }
455
+ /**
456
+ * Get all tracked users.
457
+ */
458
+ getAll() {
459
+ return Array.from(this._users.values());
460
+ }
461
+ /**
462
+ * Clear all tracked users.
463
+ */
464
+ clear() {
465
+ this._users.clear();
466
+ this._actorToUserId.clear();
467
+ }
468
+ }
469
+
470
+ /**
471
+ * NoLagNotify — high-level notifications SDK built on @nolag/js-sdk.
472
+ *
473
+ * Provides multi-channel notifications, read/unread tracking, badge counts,
474
+ * message replay, and global presence — all framework-agnostic via events.
475
+ *
476
+ * The wrapper NEVER manages the connection. The app owns one core NoLag
477
+ * client (shared by any number of wrappers on distinct apps) and the
478
+ * wrapper attaches to it at construction and releases it via `detach()`.
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * import { NoLag } from '@nolag/js-sdk';
483
+ * import { NoLagNotify } from '@nolag/notify';
484
+ *
485
+ * const client = NoLag(async () => (await (await fetch('/api/nolag-token')).json()).token);
486
+ * const notify = new NoLagNotify({ client, appName: 'my-notify' });
487
+ *
488
+ * notify.on('notification', (n) => console.log('New notification:', n.title));
489
+ *
490
+ * await client.connect(); // the app owns the connection
491
+ * await notify.ready(); // wrapper setup done (identity, lobby, channels)
492
+ *
493
+ * const alerts = notify.subscribe('alerts');
494
+ * alerts.on('notification', (n) => console.log(n.title));
495
+ *
496
+ * notify.detach(); // wrapper releases its handlers and topics
497
+ * client.disconnect(); // the app closes the socket
498
+ * ```
499
+ */
500
+ class NoLagNotify extends EventEmitter {
501
+ constructor(options) {
502
+ super();
503
+ this._channels = new Map();
504
+ this._lobby = null;
505
+ this._badgeManager = new BadgeManager();
506
+ this._presenceManager = new PresenceManager();
507
+ this._actorToUserId = new Map();
508
+ // Lifecycle: one setup run per connection epoch; detach is terminal.
509
+ this._epoch = 0;
510
+ this._detached = false;
511
+ this._isReady = false;
512
+ this._lobbyRefreshTimer = null;
513
+ // Stored client handler refs. INVARIANT: every client.on() below has a
514
+ // matching client.off() in detach() — never bare off(event), never inline
515
+ // closures on the client.
516
+ this._onConnectRef = () => this._onConnect();
517
+ this._onDisconnectRef = (reason) => {
518
+ this._log('Disconnected:', reason);
519
+ this.emit('disconnected', reason);
520
+ };
521
+ this._onReconnectRef = () => {
522
+ this._log('Reconnecting...');
523
+ this.emit('reconnecting');
524
+ };
525
+ this._onErrorRef = (error) => {
526
+ this._log('Error:', error);
527
+ this.emit('error', error);
528
+ };
529
+ this._onReplayStartRef = (data) => {
530
+ const event = data;
531
+ for (const channel of this._channels.values()) {
532
+ channel._handleReplayStart(event.count);
533
+ }
534
+ };
535
+ this._onReplayEndRef = (data) => {
536
+ const event = data;
537
+ for (const channel of this._channels.values()) {
538
+ channel._handleReplayEnd(event.replayed);
539
+ }
540
+ };
541
+ this._onPresenceJoinRef = (data) => this._handleRoomPresenceJoin(data);
542
+ this._onPresenceLeaveRef = (data) => this._handleRoomPresenceLeave(data);
543
+ this._onPresenceUpdateRef = (data) => this._handleRoomPresenceUpdate(data);
544
+ this._onLobbyJoinRef = (data) => this._handleLobbyJoin(data);
545
+ this._onLobbyLeaveRef = (data) => this._handleLobbyLeave(data);
546
+ this._onLobbyUpdateRef = (data) => this._handleLobbyUpdate(data);
547
+ if (!options?.client) {
548
+ throw new TypeError('NoLagNotify requires an injected NoLag client: new NoLagNotify({ client, ... })');
549
+ }
550
+ this._client = options.client;
551
+ this._userId = generateId();
552
+ this._options = {
553
+ metadata: options.metadata,
554
+ appName: options.appName ?? DEFAULT_APP_NAME,
555
+ maxNotificationCache: options.maxNotificationCache ?? DEFAULT_MAX_NOTIFICATION_CACHE,
556
+ debug: options.debug ?? false,
557
+ channels: options.channels ?? [],
558
+ };
559
+ this._log = createLogger('NoLagNotify', this._options.debug);
560
+ this._readyPromise = new Promise((resolve, reject) => {
561
+ this._readyResolve = resolve;
562
+ this._readyReject = reject;
563
+ });
564
+ // ready() rejection is only meaningful to callers that await it
565
+ this._readyPromise.catch(() => { });
566
+ registerWrapper(this._client, this._options.appName, 'NoLagNotify');
567
+ // Construction = attach: wire everything now, with stored refs.
568
+ this._client.on('connect', this._onConnectRef);
569
+ this._client.on('disconnect', this._onDisconnectRef);
570
+ this._client.on('reconnect', this._onReconnectRef);
571
+ this._client.on('error', this._onErrorRef);
572
+ this._client.on('replay:start', this._onReplayStartRef);
573
+ this._client.on('replay:end', this._onReplayEndRef);
574
+ this._client.on('presence:join', this._onPresenceJoinRef);
575
+ this._client.on('presence:leave', this._onPresenceLeaveRef);
576
+ this._client.on('presence:update', this._onPresenceUpdateRef);
577
+ this._client.on('lobbyPresence:join', this._onLobbyJoinRef);
578
+ this._client.on('lobbyPresence:leave', this._onLobbyLeaveRef);
579
+ this._client.on('lobbyPresence:update', this._onLobbyUpdateRef);
580
+ // Attach-to-connected: if the client is already authenticated, run setup.
581
+ // The microtask lets the caller wire wrapper event handlers synchronously
582
+ // first; a racing real 'connect' event wins via the epoch guard.
583
+ queueMicrotask(() => {
584
+ if (this._epoch === 0 && !this._detached && this._client.connected) {
585
+ this._onConnect();
586
+ }
587
+ });
588
+ }
589
+ // ============ Public Properties ============
590
+ /** Whether the underlying connection is established (connected ≠ ready) */
591
+ get connected() {
592
+ return !this._detached && this._client.connected;
593
+ }
594
+ /** The injected core client (owned by the app, not the wrapper) */
595
+ get client() {
596
+ return this._client;
597
+ }
598
+ /** All currently subscribed channels */
599
+ get channels() {
600
+ return this._channels;
601
+ }
602
+ // ============ Lifecycle ============
603
+ /**
604
+ * Resolves once the wrapper's first setup completed (identity, lobby and
605
+ * configured channels ready — equivalently, once 'connected' has fired).
606
+ * Rejects only if detach() is called before that. Client auth failures
607
+ * surface via the app's own `await client.connect()`, not here.
608
+ */
609
+ ready() {
610
+ return this._readyPromise;
611
+ }
612
+ /**
613
+ * Detach from the client: remove every handler this wrapper added,
614
+ * unsubscribe its topics and lobby (when connected), clear state.
615
+ * Terminal and idempotent; never touches the socket. To use notify again,
616
+ * construct a new instance.
617
+ */
618
+ detach() {
619
+ if (this._detached)
620
+ return;
621
+ this._log('Detaching...');
622
+ this._detached = true;
623
+ this._epoch++; // aborts any in-flight setup at its next checkpoint
624
+ if (this._lobbyRefreshTimer) {
625
+ clearTimeout(this._lobbyRefreshTimer);
626
+ this._lobbyRefreshTimer = null;
627
+ }
628
+ // Remove all client handlers by stored ref
629
+ this._client.off('connect', this._onConnectRef);
630
+ this._client.off('disconnect', this._onDisconnectRef);
631
+ this._client.off('reconnect', this._onReconnectRef);
632
+ this._client.off('error', this._onErrorRef);
633
+ this._client.off('replay:start', this._onReplayStartRef);
634
+ this._client.off('replay:end', this._onReplayEndRef);
635
+ this._client.off('presence:join', this._onPresenceJoinRef);
636
+ this._client.off('presence:leave', this._onPresenceLeaveRef);
637
+ this._client.off('presence:update', this._onPresenceUpdateRef);
638
+ this._client.off('lobbyPresence:join', this._onLobbyJoinRef);
639
+ this._client.off('lobbyPresence:leave', this._onLobbyLeaveRef);
640
+ this._client.off('lobbyPresence:update', this._onLobbyUpdateRef);
641
+ // Channels: handler-specific off + connected-gated server unsubscribe
642
+ for (const name of [...this._channels.keys()]) {
643
+ this._channels.get(name)._cleanup();
644
+ this._channels.delete(name);
645
+ }
646
+ // Lobby: server unsubscribe is best-effort and needs a live socket
647
+ if (this._lobby && this._client.connected) {
648
+ try {
649
+ this._lobby.unsubscribe();
650
+ }
651
+ catch {
652
+ /* best-effort */
653
+ }
654
+ }
655
+ this._lobby = null;
656
+ this._badgeManager.clear();
657
+ this._presenceManager.clear();
658
+ this._actorToUserId.clear();
659
+ releaseWrapper(this._client, this._options.appName);
660
+ if (!this._isReady) {
661
+ this._readyReject(new Error('NoLagNotify detached before ready'));
662
+ }
663
+ }
664
+ // ============ Private: Epoch Setup ============
665
+ _onConnect() {
666
+ this._epoch++;
667
+ void this._runSetup(this._epoch);
668
+ }
669
+ /**
670
+ * One setup pass per connection epoch. Serves both initial setup (epoch 1)
671
+ * and reconnect restore (epoch > 1). Aborts silently whenever a newer
672
+ * epoch started or the wrapper detached — checked after every await.
673
+ */
674
+ async _runSetup(epoch) {
675
+ const stale = () => epoch !== this._epoch || this._detached;
676
+ this._log(this._isReady ? 'Restoring after reconnect...' : 'Setting up...');
677
+ this._log('Local userId:', this._userId, '→ actorId:', this._client.actorId);
678
+ // Lobby: subscribe every epoch (idempotent server-side) and diff-hydrate
679
+ // from the returned snapshot — one path for setup and restore.
680
+ if (!this._lobby) {
681
+ this._lobby = this._client.setApp(this._options.appName).setLobby(LOBBY_ID);
682
+ }
683
+ try {
684
+ const state = await this._lobby.subscribe();
685
+ if (stale())
686
+ return;
687
+ this._diffHydratePresence(state);
688
+ this._log('Lobby subscribed');
689
+ }
690
+ catch (err) {
691
+ if (stale())
692
+ return;
693
+ this._log('Lobby subscription failed:', err);
694
+ }
695
+ // First successful setup: pre-subscribe configured channels. The core
696
+ // auto-restores topic subscriptions on reconnect, so later epochs skip it.
697
+ if (!this._isReady) {
698
+ for (const channelName of this._options.channels) {
699
+ this._subscribeChannel(channelName);
700
+ }
701
+ }
702
+ if (stale())
703
+ return;
704
+ // Ready keys on the first setup that COMPLETES, not on epoch 1: an
705
+ // epoch aborted by a racing reconnect must not strand ready().
706
+ if (!this._isReady) {
707
+ this._isReady = true;
708
+ this._readyResolve();
709
+ this.emit('connected');
710
+ }
711
+ else {
712
+ this.emit('reconnected');
713
+ }
714
+ // Deferred lobby refetch: catches users who joined during the setup
715
+ // window (e.g. simultaneous multi-tab connects).
716
+ this._scheduleLobbyRefresh(epoch);
717
+ }
718
+ _scheduleLobbyRefresh(epoch) {
719
+ if (this._lobbyRefreshTimer)
720
+ clearTimeout(this._lobbyRefreshTimer);
721
+ this._lobbyRefreshTimer = setTimeout(() => {
722
+ this._lobbyRefreshTimer = null;
723
+ if (epoch !== this._epoch || this._detached || !this._client.connected || !this._lobby) {
724
+ return;
725
+ }
726
+ this._lobby
727
+ .fetchPresence()
728
+ .then((state) => {
729
+ if (epoch !== this._epoch || this._detached)
730
+ return;
731
+ this._diffHydratePresence(state);
732
+ })
733
+ .catch(() => {
734
+ /* best-effort */
735
+ });
736
+ }, LOBBY_REFRESH_DELAY_MS);
737
+ }
738
+ // ============ Channel Management ============
739
+ /**
740
+ * Subscribe to a notification channel (idempotent).
741
+ * Returns the NotifyChannel instance.
742
+ */
743
+ subscribe(channelName) {
744
+ this._assertUsable();
745
+ const existing = this._channels.get(channelName);
746
+ if (existing)
747
+ return existing;
748
+ const channel = this._subscribeChannel(channelName);
749
+ channel._activate();
750
+ return channel;
751
+ }
752
+ /**
753
+ * Unsubscribe from a notification channel.
754
+ */
755
+ unsubscribe(channelName) {
756
+ const channel = this._channels.get(channelName);
757
+ if (!channel)
758
+ return;
759
+ this._log('Unsubscribing channel:', channelName);
760
+ channel._cleanup();
761
+ this._channels.delete(channelName);
762
+ this._badgeManager.update(channelName, 0);
763
+ this._emitBadgeUpdated();
764
+ }
765
+ // ============ Badge Counts ============
766
+ /**
767
+ * Get the current badge counts across all channels.
768
+ */
769
+ getBadgeCounts() {
770
+ return this._badgeManager.getAll();
771
+ }
772
+ // ============ Read Tracking ============
773
+ /**
774
+ * Mark all notifications as read across all channels.
775
+ */
776
+ markAllRead() {
777
+ for (const channel of this._channels.values()) {
778
+ channel.markAllRead();
779
+ }
780
+ }
781
+ // ============ Private: Guards ============
782
+ _assertUsable() {
783
+ if (this._detached) {
784
+ throw new Error('NoLagNotify has been detached — construct a new instance');
785
+ }
786
+ if (!this._isReady) {
787
+ throw new Error('NoLagNotify not ready — await ready() or the "connected" event');
788
+ }
789
+ }
790
+ // ============ Private: Channel Setup ============
791
+ _subscribeChannel(name) {
792
+ this._log('Subscribing channel:', name);
793
+ const roomContext = this._client.setApp(this._options.appName).setRoom(name);
794
+ const channel = new NotifyChannel(name, roomContext, this._options, createLogger(`NotifyChannel:${name}`, this._options.debug), () => this._client.connected);
795
+ this._channels.set(name, channel);
796
+ channel._subscribe();
797
+ // Relay notifications up to the main client and update badges
798
+ channel.on('notification', (notification) => {
799
+ this._badgeManager.update(name, channel.unreadCount);
800
+ this._emitBadgeUpdated();
801
+ this.emit('notification', notification);
802
+ });
803
+ channel.on('read', () => {
804
+ this._badgeManager.update(name, channel.unreadCount);
805
+ this._emitBadgeUpdated();
806
+ });
807
+ channel.on('readAll', () => {
808
+ this._badgeManager.update(name, 0);
809
+ this._emitBadgeUpdated();
810
+ });
811
+ return channel;
812
+ }
813
+ _emitBadgeUpdated() {
814
+ this.emit('badgeUpdated', this._badgeManager.getAll());
815
+ }
816
+ // ============ Private: Scope Filtering ============
817
+ /**
818
+ * On a shared client, presence events from other apps' wrappers arrive on
819
+ * the same connection-level events. Wrappers stamp their presence with a
820
+ * `__scope` (their appName); a mismatched tag means another app's data.
821
+ * Untagged presence is accepted (older peers in this same app).
822
+ */
823
+ _foreignScope(data) {
824
+ const scope = data?.__scope;
825
+ return typeof scope === 'string' && scope !== this._options.appName;
826
+ }
827
+ // ============ Private: Room Presence ============
828
+ _handleRoomPresenceJoin(data) {
829
+ if (data.actorTokenId === this._client.actorId)
830
+ return;
831
+ const presenceData = data.presence;
832
+ if (!presenceData?.userId || this._foreignScope(presenceData))
833
+ return;
834
+ const user = this._presenceManager.addFromPresence(data.actorTokenId, presenceData);
835
+ if (user) {
836
+ this._actorToUserId.set(data.actorTokenId, user.userId);
837
+ }
838
+ }
839
+ _handleRoomPresenceLeave(data) {
840
+ if (data.actorTokenId === this._client.actorId)
841
+ return;
842
+ this._presenceManager.removeByActorId(data.actorTokenId);
843
+ }
844
+ _handleRoomPresenceUpdate(data) {
845
+ if (data.actorTokenId === this._client.actorId)
846
+ return;
847
+ const presenceData = data.presence;
848
+ if (!presenceData?.userId || this._foreignScope(presenceData))
849
+ return;
850
+ this._presenceManager.addFromPresence(data.actorTokenId, presenceData);
851
+ }
852
+ // ============ Private: Lobby ============
853
+ _handleLobbyJoin(event) {
854
+ const { actorId, data } = event;
855
+ if (actorId === this._client.actorId)
856
+ return;
857
+ const presenceData = data;
858
+ if (!presenceData?.userId || this._foreignScope(presenceData))
859
+ return;
860
+ const user = this._presenceManager.addFromPresence(actorId, presenceData);
861
+ if (user) {
862
+ this._actorToUserId.set(actorId, user.userId);
863
+ }
864
+ }
865
+ _handleLobbyLeave(event) {
866
+ const { actorId, data } = event;
867
+ if (actorId === this._client.actorId)
868
+ return;
869
+ const presenceData = data;
870
+ if (this._foreignScope(presenceData))
871
+ return;
872
+ this._presenceManager.removeByActorId(actorId);
873
+ this._actorToUserId.delete(actorId);
874
+ }
875
+ _handleLobbyUpdate(event) {
876
+ const { actorId, data } = event;
877
+ if (actorId === this._client.actorId)
878
+ return;
879
+ const presenceData = data;
880
+ if (!presenceData?.userId || this._foreignScope(presenceData))
881
+ return;
882
+ this._presenceManager.addFromPresence(actorId, presenceData);
883
+ }
884
+ /**
885
+ * Reconcile tracked presence against a fresh lobby snapshot. One path for
886
+ * initial hydration, reconnect restore, and the deferred refetch.
887
+ */
888
+ _diffHydratePresence(state) {
889
+ // Build the fresh actor set from the snapshot
890
+ const freshActors = new Set();
891
+ for (const roomId of Object.keys(state)) {
892
+ const roomPresence = state[roomId];
893
+ for (const actorId of Object.keys(roomPresence)) {
894
+ if (actorId === this._client.actorId)
895
+ continue;
896
+ const raw = roomPresence[actorId];
897
+ // Server returns full actor records with presence nested under .presence
898
+ const presenceData = (raw?.presence ?? raw);
899
+ if (presenceData?.userId && !this._foreignScope(presenceData)) {
900
+ freshActors.add(actorId);
901
+ const user = this._presenceManager.addFromPresence(actorId, presenceData);
902
+ if (user) {
903
+ this._actorToUserId.set(actorId, user.userId);
904
+ }
905
+ }
906
+ }
907
+ }
908
+ // Vanished actors: present locally but absent from the fresh snapshot
909
+ for (const [actorId] of [...this._actorToUserId]) {
910
+ if (!freshActors.has(actorId)) {
911
+ this._presenceManager.removeByActorId(actorId);
912
+ this._actorToUserId.delete(actorId);
913
+ }
914
+ }
915
+ }
916
+ }
917
+
918
+ export { EventEmitter, NoLagNotify, NotifyChannel };
919
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.js","sources":["../src/EventEmitter.ts","../src/NotificationStore.ts","../src/utils.ts","../src/constants.ts","../src/NotifyChannel.ts","../src/BadgeManager.ts","../src/PresenceManager.ts","../src/NoLagNotify.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":[],"mappings":"AAAA;;AAEG;MACU,YAAY,CAAA;AAAzB,IAAA,WAAA,GAAA;AACU,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAAiD;IAuC9E;IArCE,EAAE,CAA2B,KAAQ,EAAE,OAAuC,EAAA;QAC5E,IAAI,CAAC,IAAI,CAAC,S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": "@nolag/notify",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -9,9 +9,14 @@
9
9
  "main": "./dist/index.cjs",
10
10
  "module": "./dist/index.mjs",
11
11
  "browser": "./dist/browser.js",
12
+ "react-native": "./dist/react-native.js",
12
13
  "types": "./dist/index.d.ts",
13
14
  "exports": {
14
15
  ".": {
16
+ "react-native": {
17
+ "types": "./dist/react-native.d.ts",
18
+ "default": "./dist/react-native.js"
19
+ },
15
20
  "browser": {
16
21
  "types": "./dist/browser.d.ts",
17
22
  "default": "./dist/browser.js"
@@ -25,7 +30,8 @@
25
30
  "default": "./dist/index.cjs"
26
31
  },
27
32
  "default": "./dist/index.mjs"
28
- }
33
+ },
34
+ "./package.json": "./package.json"
29
35
  },
30
36
  "files": [
31
37
  "dist"
@@ -46,10 +52,10 @@
46
52
  "license": "MIT",
47
53
  "homepage": "https://nolag.app",
48
54
  "devDependencies": {
49
- "@nolag/js-sdk": "^1.11.0"
55
+ "@nolag/js-sdk": "^1.12.0"
50
56
  },
51
57
  "peerDependencies": {
52
- "@nolag/js-sdk": "^1.11.0"
58
+ "@nolag/js-sdk": "^1.12.0"
53
59
  },
54
60
  "publishConfig": {
55
61
  "access": "public"