@nolag/signal 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/signal
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,835 @@
1
+ /**
2
+ * Tiny typed event emitter — framework-agnostic base for NoLag SDKs.
3
+ *
4
+ * EventMap is a record of event name → tuple of handler arguments.
5
+ */
6
+ class EventEmitter {
7
+ constructor() {
8
+ this._handlers = new Map();
9
+ }
10
+ on(event, handler) {
11
+ if (!this._handlers.has(event)) {
12
+ this._handlers.set(event, new Set());
13
+ }
14
+ this._handlers.get(event).add(handler);
15
+ return this;
16
+ }
17
+ off(event, handler) {
18
+ if (handler) {
19
+ this._handlers.get(event)?.delete(handler);
20
+ }
21
+ else {
22
+ this._handlers.delete(event);
23
+ }
24
+ return this;
25
+ }
26
+ removeAllListeners() {
27
+ this._handlers.clear();
28
+ return this;
29
+ }
30
+ emit(event, ...args) {
31
+ const handlers = this._handlers.get(event);
32
+ if (!handlers)
33
+ return;
34
+ for (const handler of handlers) {
35
+ try {
36
+ handler(...args);
37
+ }
38
+ catch (e) {
39
+ console.error(`Error in ${String(event)} handler:`, e);
40
+ }
41
+ }
42
+ }
43
+ listenerCount(event) {
44
+ return this._handlers.get(event)?.size ?? 0;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Maps actorTokenId ↔ Peer, filtering self.
50
+ */
51
+ class PeerManager {
52
+ constructor(localActorId) {
53
+ this._peers = new Map();
54
+ this._actorToPeerId = new Map();
55
+ this._localActorId = localActorId;
56
+ }
57
+ /**
58
+ * Add or update a peer from presence data.
59
+ * Returns the Peer if it's a remote peer, null if it's self.
60
+ */
61
+ addFromPresence(actorTokenId, presence, joinedAt) {
62
+ const isLocal = actorTokenId === this._localActorId;
63
+ // Skip self
64
+ if (isLocal)
65
+ return null;
66
+ const existing = this._actorToPeerId.get(actorTokenId);
67
+ const peerId = presence.peerId || existing || actorTokenId;
68
+ const peer = {
69
+ peerId,
70
+ actorTokenId,
71
+ connectionState: 'new',
72
+ metadata: presence.metadata,
73
+ joinedAt: joinedAt || Date.now(),
74
+ isLocal: false,
75
+ };
76
+ this._peers.set(peerId, peer);
77
+ this._actorToPeerId.set(actorTokenId, peerId);
78
+ return peer;
79
+ }
80
+ /**
81
+ * Remove a peer by actorTokenId.
82
+ * Returns the removed peer, or null if not found / is self.
83
+ */
84
+ removeByActorId(actorTokenId) {
85
+ if (actorTokenId === this._localActorId)
86
+ return null;
87
+ const peerId = this._actorToPeerId.get(actorTokenId);
88
+ if (!peerId)
89
+ return null;
90
+ const peer = this._peers.get(peerId) || null;
91
+ this._peers.delete(peerId);
92
+ this._actorToPeerId.delete(actorTokenId);
93
+ return peer;
94
+ }
95
+ /**
96
+ * Get a peer by peerId.
97
+ */
98
+ getPeer(peerId) {
99
+ return this._peers.get(peerId);
100
+ }
101
+ /**
102
+ * Get a peer by actorTokenId.
103
+ */
104
+ getPeerByActorId(actorTokenId) {
105
+ const peerId = this._actorToPeerId.get(actorTokenId);
106
+ return peerId ? this._peers.get(peerId) : undefined;
107
+ }
108
+ /**
109
+ * Get all remote peers.
110
+ */
111
+ getAll() {
112
+ return Array.from(this._peers.values());
113
+ }
114
+ /**
115
+ * Get the peers Map (readonly view).
116
+ */
117
+ get peers() {
118
+ return this._peers;
119
+ }
120
+ /**
121
+ * Clear all tracked peers.
122
+ */
123
+ clear() {
124
+ this._peers.clear();
125
+ this._actorToPeerId.clear();
126
+ }
127
+ }
128
+
129
+ function generateId() {
130
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
131
+ return crypto.randomUUID();
132
+ }
133
+ return 'xxxx-xxxx-xxxx-xxxx'.replace(/x/g, () => Math.floor(Math.random() * 16).toString(16));
134
+ }
135
+ function createLogger(prefix, enabled) {
136
+ if (!enabled) {
137
+ return (..._args) => { };
138
+ }
139
+ return (...args) => {
140
+ console.log(`[${prefix}]`, ...args);
141
+ };
142
+ }
143
+ // ============ Wrapper registry ============
144
+ // One wrapper instance per (client, appName): two wrappers sharing an app on
145
+ // one connection would collide on topics, presence and the online lobby.
146
+ // Warn (not throw): HMR and tests legitimately construct before disposing.
147
+ const wrapperRegistry = new WeakMap();
148
+ /** Register a wrapper against a client + appName; warns on collision. */
149
+ function registerWrapper(client, appName, wrapperName) {
150
+ let apps = wrapperRegistry.get(client);
151
+ if (!apps) {
152
+ apps = new Map();
153
+ wrapperRegistry.set(client, apps);
154
+ }
155
+ const existing = apps.get(appName);
156
+ if (existing) {
157
+ console.warn(`[${wrapperName}] Another wrapper (${existing}) is already attached to this client for app "${appName}". ` +
158
+ `Use one wrapper per (client, app) — detach the other instance first.`);
159
+ }
160
+ apps.set(appName, wrapperName);
161
+ }
162
+ /** Release a wrapper's (client, appName) registration on detach. */
163
+ function releaseWrapper(client, appName) {
164
+ wrapperRegistry.get(client)?.delete(appName);
165
+ }
166
+
167
+ /** Default app name for NoLag signal SDK */
168
+ const DEFAULT_APP_NAME = 'signal';
169
+ /** Topic name for signaling messages within a room */
170
+ const TOPIC_SIGNALING = 'signaling';
171
+ /** Lobby ID for global online presence */
172
+ const LOBBY_ID = 'online';
173
+ /** Delay before the post-setup lobby presence refetch (catches simultaneous joiners) */
174
+ const LOBBY_REFRESH_DELAY_MS = 2000;
175
+
176
+ /**
177
+ * SignalRoom — a single signaling room for WebRTC peer discovery and exchange.
178
+ *
179
+ * Created via `NoLagSignal.joinRoom(name)`. Do not instantiate directly.
180
+ */
181
+ class SignalRoom extends EventEmitter {
182
+ /** @internal */
183
+ constructor(name, roomContext, localPeer, options, log, isConnected) {
184
+ super();
185
+ // Stored topic handler ref — cleanup removes exactly this, never all
186
+ // handlers for a topic (the client may be shared with other consumers).
187
+ this._onSignalingRef = null;
188
+ this.name = name;
189
+ this._roomContext = roomContext;
190
+ this._localPeer = localPeer;
191
+ this._options = options;
192
+ this._log = log;
193
+ this._isConnected = isConnected;
194
+ this._peerManager = new PeerManager(localPeer.actorTokenId);
195
+ }
196
+ // ============ Public Properties ============
197
+ /** All remote peers currently in this room */
198
+ get peers() {
199
+ return this._peerManager.peers;
200
+ }
201
+ // ============ Signaling ============
202
+ /**
203
+ * Send an SDP offer to a specific peer.
204
+ */
205
+ sendOffer(toPeerId, offer) {
206
+ this.signal(toPeerId, 'offer', offer);
207
+ }
208
+ /**
209
+ * Send an SDP answer to a specific peer.
210
+ */
211
+ sendAnswer(toPeerId, answer) {
212
+ this.signal(toPeerId, 'answer', answer);
213
+ }
214
+ /**
215
+ * Send an ICE candidate to a specific peer.
216
+ */
217
+ sendIceCandidate(toPeerId, candidate) {
218
+ this.signal(toPeerId, 'ice-candidate', candidate);
219
+ }
220
+ /**
221
+ * Send a bye signal to a specific peer (graceful close).
222
+ */
223
+ sendBye(toPeerId) {
224
+ this.signal(toPeerId, 'bye', {});
225
+ }
226
+ /**
227
+ * Send a generic signal message to a specific peer.
228
+ */
229
+ signal(toPeerId, type, payload) {
230
+ const message = {
231
+ id: generateId(),
232
+ type,
233
+ fromPeerId: this._localPeer.peerId,
234
+ toPeerId,
235
+ payload,
236
+ timestamp: Date.now(),
237
+ };
238
+ this._log('Sending signal:', type, '→', toPeerId);
239
+ this._roomContext.emit(TOPIC_SIGNALING, message, { echo: false });
240
+ }
241
+ // ============ Peers ============
242
+ /**
243
+ * Get all remote peers in this room.
244
+ */
245
+ getPeers() {
246
+ return this._peerManager.getAll();
247
+ }
248
+ /**
249
+ * Get a specific peer by peerId.
250
+ */
251
+ getPeer(peerId) {
252
+ return this._peerManager.getPeer(peerId);
253
+ }
254
+ // ============ Internal (called by NoLagSignal) ============
255
+ /** @internal Subscribe to signaling topic and attach listeners */
256
+ _subscribe() {
257
+ this._log('Room subscribe:', this.name);
258
+ this._roomContext.subscribe(TOPIC_SIGNALING);
259
+ // Listen for signals (ref stored for handler-specific removal)
260
+ this._onSignalingRef = (data) => {
261
+ this._handleIncomingSignal(data);
262
+ };
263
+ this._roomContext.on(TOPIC_SIGNALING, this._onSignalingRef);
264
+ }
265
+ /** @internal Set presence and fetch room members */
266
+ _activate() {
267
+ this._log('Room activate:', this.name);
268
+ this._setPresence();
269
+ this._roomContext.fetchPresence().then((actors) => {
270
+ this._log('Room presence fetched:', this.name, actors.length, 'actors');
271
+ for (const actor of actors) {
272
+ if (actor.presence) {
273
+ const peer = this._peerManager.addFromPresence(actor.actorTokenId, actor.presence, actor.joinedAt);
274
+ if (peer) {
275
+ this.emit('peerJoined', peer);
276
+ }
277
+ }
278
+ }
279
+ }).catch((err) => {
280
+ this._log('Failed to fetch room presence:', err);
281
+ });
282
+ }
283
+ /** @internal Re-set presence after reconnect */
284
+ _updateLocalPresence() {
285
+ this._setPresence();
286
+ }
287
+ /** @internal Handle a presence:join event */
288
+ _handlePresenceJoin(actorTokenId, presenceData) {
289
+ const peer = this._peerManager.addFromPresence(actorTokenId, presenceData);
290
+ if (peer) {
291
+ this._log('Peer joined room:', this.name, peer.peerId);
292
+ this.emit('peerJoined', peer);
293
+ }
294
+ }
295
+ /** @internal Handle a presence:leave event */
296
+ _handlePresenceLeave(actorTokenId) {
297
+ const peer = this._peerManager.removeByActorId(actorTokenId);
298
+ if (peer) {
299
+ this._log('Peer left room:', this.name, peer.peerId);
300
+ this.emit('peerLeft', peer);
301
+ }
302
+ }
303
+ /** @internal Handle a presence:update event */
304
+ _handlePresenceUpdate(actorTokenId, presenceData) {
305
+ this._peerManager.addFromPresence(actorTokenId, presenceData);
306
+ }
307
+ /** @internal Unsubscribe and clean up */
308
+ _cleanup() {
309
+ this._log('Room cleanup:', this.name);
310
+ // Server unsubscribes need a live socket; skip when disconnected
311
+ // (best-effort — the core would no-op with an error callback anyway).
312
+ if (this._isConnected()) {
313
+ this._roomContext.unsubscribe(TOPIC_SIGNALING);
314
+ }
315
+ // Handler-specific removal only: the client may be shared, and a bare
316
+ // off(topic) would strip other consumers' handlers too.
317
+ if (this._onSignalingRef)
318
+ this._roomContext.off(TOPIC_SIGNALING, this._onSignalingRef);
319
+ this._onSignalingRef = null;
320
+ this._peerManager.clear();
321
+ this.removeAllListeners();
322
+ }
323
+ // ============ Private ============
324
+ _handleIncomingSignal(data) {
325
+ const message = data;
326
+ // Only process messages targeted at this peer
327
+ if (message.toPeerId !== this._localPeer.peerId)
328
+ return;
329
+ this._log('Received signal:', message.type, 'from', message.fromPeerId);
330
+ this.emit('signal', message);
331
+ }
332
+ _setPresence() {
333
+ const presenceData = {
334
+ peerId: this._localPeer.peerId,
335
+ metadata: this._localPeer.metadata,
336
+ // Scope tag: on a shared client, other apps' wrappers filter our
337
+ // presence out by this (and we filter theirs).
338
+ __scope: this._options.appName,
339
+ };
340
+ this._roomContext.setPresence(presenceData);
341
+ }
342
+ }
343
+
344
+ /**
345
+ * NoLagSignal — high-level WebRTC signaling SDK built on @nolag/js-sdk.
346
+ *
347
+ * Provides peer discovery, offer/answer/ICE exchange, and global presence
348
+ * tracking — all framework-agnostic via events.
349
+ *
350
+ * The wrapper NEVER manages the connection. The app owns one core NoLag
351
+ * client (shared by any number of wrappers on distinct apps) and the
352
+ * wrapper attaches to it at construction and releases it via `detach()`.
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * import { NoLag } from '@nolag/js-sdk';
357
+ * import { NoLagSignal } from '@nolag/signal';
358
+ *
359
+ * const client = NoLag(async () => (await (await fetch('/api/nolag-token')).json()).token);
360
+ * const signal = new NoLagSignal({ client, appName: 'my-signal' });
361
+ *
362
+ * signal.on('peerOnline', (peer) => console.log(peer.peerId, 'is online'));
363
+ *
364
+ * await client.connect(); // the app owns the connection
365
+ * await signal.ready(); // wrapper setup done (identity, lobby)
366
+ *
367
+ * const room = signal.joinRoom('call-room');
368
+ * room.on('signal', (msg) => {
369
+ * if (msg.type === 'offer') handleOffer(msg);
370
+ * });
371
+ * room.sendOffer(remotePeerId, offer);
372
+ *
373
+ * signal.detach(); // wrapper releases its handlers and topics
374
+ * client.disconnect(); // the app closes the socket
375
+ * ```
376
+ */
377
+ class NoLagSignal extends EventEmitter {
378
+ constructor(options) {
379
+ super();
380
+ this._localPeer = null;
381
+ this._rooms = new Map();
382
+ this._lobby = null;
383
+ this._onlinePeers = new Map();
384
+ this._actorToPeerId = new Map();
385
+ // Lifecycle: one setup run per connection epoch; detach is terminal.
386
+ this._epoch = 0;
387
+ this._detached = false;
388
+ this._isReady = false;
389
+ this._lobbyRefreshTimer = null;
390
+ // Stored client handler refs. INVARIANT: every client.on() below has a
391
+ // matching client.off() in detach() — never bare off(event), never inline
392
+ // closures on the client.
393
+ this._onConnectRef = () => this._onConnect();
394
+ this._onDisconnectRef = (reason) => {
395
+ this._log('Disconnected:', reason);
396
+ this.emit('disconnected', reason);
397
+ };
398
+ this._onReconnectRef = () => {
399
+ this._log('Reconnecting...');
400
+ this.emit('reconnecting');
401
+ };
402
+ this._onErrorRef = (error) => {
403
+ this._log('Error:', error);
404
+ this.emit('error', error);
405
+ };
406
+ this._onPresenceJoinRef = (data) => this._handleRoomPresenceJoin(data);
407
+ this._onPresenceLeaveRef = (data) => this._handleRoomPresenceLeave(data);
408
+ this._onPresenceUpdateRef = (data) => this._handleRoomPresenceUpdate(data);
409
+ this._onLobbyJoinRef = (data) => this._handleLobbyJoin(data);
410
+ this._onLobbyLeaveRef = (data) => this._handleLobbyLeave(data);
411
+ this._onLobbyUpdateRef = (data) => this._handleLobbyUpdate(data);
412
+ if (!options?.client) {
413
+ throw new TypeError('NoLagSignal requires an injected NoLag client: new NoLagSignal({ client, ... })');
414
+ }
415
+ this._client = options.client;
416
+ this._peerId = generateId();
417
+ this._options = {
418
+ metadata: options.metadata,
419
+ appName: options.appName ?? DEFAULT_APP_NAME,
420
+ debug: options.debug ?? false,
421
+ };
422
+ this._log = createLogger('NoLagSignal', this._options.debug);
423
+ this._readyPromise = new Promise((resolve, reject) => {
424
+ this._readyResolve = resolve;
425
+ this._readyReject = reject;
426
+ });
427
+ // ready() rejection is only meaningful to callers that await it
428
+ this._readyPromise.catch(() => { });
429
+ registerWrapper(this._client, this._options.appName, 'NoLagSignal');
430
+ // Construction = attach: wire everything now, with stored refs.
431
+ this._client.on('connect', this._onConnectRef);
432
+ this._client.on('disconnect', this._onDisconnectRef);
433
+ this._client.on('reconnect', this._onReconnectRef);
434
+ this._client.on('error', this._onErrorRef);
435
+ this._client.on('presence:join', this._onPresenceJoinRef);
436
+ this._client.on('presence:leave', this._onPresenceLeaveRef);
437
+ this._client.on('presence:update', this._onPresenceUpdateRef);
438
+ this._client.on('lobbyPresence:join', this._onLobbyJoinRef);
439
+ this._client.on('lobbyPresence:leave', this._onLobbyLeaveRef);
440
+ this._client.on('lobbyPresence:update', this._onLobbyUpdateRef);
441
+ // Attach-to-connected: if the client is already authenticated, run setup.
442
+ // The microtask lets the caller wire wrapper event handlers synchronously
443
+ // first; a racing real 'connect' event wins via the epoch guard.
444
+ queueMicrotask(() => {
445
+ if (this._epoch === 0 && !this._detached && this._client.connected) {
446
+ this._onConnect();
447
+ }
448
+ });
449
+ }
450
+ // ============ Public Properties ============
451
+ /** Whether the underlying connection is established (connected ≠ ready) */
452
+ get connected() {
453
+ return !this._detached && this._client.connected;
454
+ }
455
+ /** The injected core client (owned by the app, not the wrapper) */
456
+ get client() {
457
+ return this._client;
458
+ }
459
+ /** The local peer's info (available after ready) */
460
+ get localPeer() {
461
+ return this._localPeer;
462
+ }
463
+ /** All currently joined rooms */
464
+ get rooms() {
465
+ return this._rooms;
466
+ }
467
+ // ============ Lifecycle ============
468
+ /**
469
+ * Resolves once the wrapper's first setup completed (identity and lobby
470
+ * ready — equivalently, once 'connected' has fired). Rejects only if
471
+ * detach() is called before that. Client auth failures surface via the
472
+ * app's own `await client.connect()`, not here.
473
+ */
474
+ ready() {
475
+ return this._readyPromise;
476
+ }
477
+ /**
478
+ * Detach from the client: remove every handler this wrapper added,
479
+ * unsubscribe its topics and lobby (when connected), clear state.
480
+ * Terminal and idempotent; never touches the socket. To use signaling
481
+ * again, construct a new instance.
482
+ */
483
+ detach() {
484
+ if (this._detached)
485
+ return;
486
+ this._log('Detaching...');
487
+ this._detached = true;
488
+ this._epoch++; // aborts any in-flight setup at its next checkpoint
489
+ if (this._lobbyRefreshTimer) {
490
+ clearTimeout(this._lobbyRefreshTimer);
491
+ this._lobbyRefreshTimer = null;
492
+ }
493
+ // Remove all client handlers by stored ref
494
+ this._client.off('connect', this._onConnectRef);
495
+ this._client.off('disconnect', this._onDisconnectRef);
496
+ this._client.off('reconnect', this._onReconnectRef);
497
+ this._client.off('error', this._onErrorRef);
498
+ this._client.off('presence:join', this._onPresenceJoinRef);
499
+ this._client.off('presence:leave', this._onPresenceLeaveRef);
500
+ this._client.off('presence:update', this._onPresenceUpdateRef);
501
+ this._client.off('lobbyPresence:join', this._onLobbyJoinRef);
502
+ this._client.off('lobbyPresence:leave', this._onLobbyLeaveRef);
503
+ this._client.off('lobbyPresence:update', this._onLobbyUpdateRef);
504
+ // Rooms: handler-specific off + connected-gated server unsubscribe
505
+ for (const name of [...this._rooms.keys()]) {
506
+ this._rooms.get(name)._cleanup();
507
+ this._rooms.delete(name);
508
+ }
509
+ // Lobby: server unsubscribe is best-effort and needs a live socket
510
+ if (this._lobby && this._client.connected) {
511
+ try {
512
+ this._lobby.unsubscribe();
513
+ }
514
+ catch {
515
+ /* best-effort */
516
+ }
517
+ }
518
+ this._lobby = null;
519
+ this._onlinePeers.clear();
520
+ this._actorToPeerId.clear();
521
+ this._localPeer = null;
522
+ releaseWrapper(this._client, this._options.appName);
523
+ if (!this._isReady) {
524
+ this._readyReject(new Error('NoLagSignal detached before ready'));
525
+ }
526
+ }
527
+ // ============ Private: Epoch Setup ============
528
+ _onConnect() {
529
+ this._epoch++;
530
+ void this._runSetup(this._epoch);
531
+ }
532
+ /**
533
+ * One setup pass per connection epoch. Serves both initial setup (epoch 1)
534
+ * and reconnect restore (epoch > 1). Aborts silently whenever a newer
535
+ * epoch started or the wrapper detached — checked after every await.
536
+ */
537
+ async _runSetup(epoch) {
538
+ const stale = () => epoch !== this._epoch || this._detached;
539
+ this._log(this._isReady ? 'Restoring after reconnect...' : 'Setting up...');
540
+ // Identity (client.actorId is guaranteed post-auth)
541
+ if (!this._localPeer) {
542
+ this._localPeer = {
543
+ peerId: this._peerId,
544
+ actorTokenId: this._client.actorId,
545
+ connectionState: 'new',
546
+ metadata: this._options.metadata,
547
+ joinedAt: Date.now(),
548
+ isLocal: true,
549
+ };
550
+ this._log('Local peer:', this._localPeer.peerId, '→', this._localPeer.actorTokenId);
551
+ }
552
+ else {
553
+ this._localPeer.actorTokenId = this._client.actorId;
554
+ }
555
+ // Lobby: subscribe every epoch (idempotent server-side) and diff-hydrate
556
+ // from the returned snapshot — one path for setup and restore.
557
+ if (!this._lobby) {
558
+ this._lobby = this._client.setApp(this._options.appName).setLobby(LOBBY_ID);
559
+ }
560
+ try {
561
+ const state = await this._lobby.subscribe();
562
+ if (stale())
563
+ return;
564
+ this._diffHydrateOnlinePeers(state);
565
+ this._log('Lobby subscribed, online peers:', this._onlinePeers.size);
566
+ }
567
+ catch (err) {
568
+ if (stale())
569
+ return;
570
+ this._log('Lobby subscription failed:', err);
571
+ }
572
+ if (this._isReady) {
573
+ // Server auto-restored topic subscriptions; only room-scoped presence
574
+ // needs re-applying (the core does not restore it).
575
+ for (const room of this._rooms.values()) {
576
+ room._updateLocalPresence();
577
+ }
578
+ }
579
+ if (stale())
580
+ return;
581
+ // Ready keys on the first setup that COMPLETES, not on epoch 1: an
582
+ // epoch aborted by a racing reconnect must not strand ready().
583
+ if (!this._isReady) {
584
+ this._isReady = true;
585
+ this._readyResolve();
586
+ this.emit('connected');
587
+ }
588
+ else {
589
+ this.emit('reconnected');
590
+ }
591
+ // Deferred lobby refetch: catches peers who joined during the setup
592
+ // window (e.g. simultaneous multi-tab connects).
593
+ this._scheduleLobbyRefresh(epoch);
594
+ }
595
+ _scheduleLobbyRefresh(epoch) {
596
+ if (this._lobbyRefreshTimer)
597
+ clearTimeout(this._lobbyRefreshTimer);
598
+ this._lobbyRefreshTimer = setTimeout(() => {
599
+ this._lobbyRefreshTimer = null;
600
+ if (epoch !== this._epoch || this._detached || !this._client.connected || !this._lobby) {
601
+ return;
602
+ }
603
+ this._lobby
604
+ .fetchPresence()
605
+ .then((state) => {
606
+ if (epoch !== this._epoch || this._detached)
607
+ return;
608
+ this._diffHydrateOnlinePeers(state);
609
+ })
610
+ .catch(() => {
611
+ /* best-effort */
612
+ });
613
+ }, LOBBY_REFRESH_DELAY_MS);
614
+ }
615
+ // ============ Room Management ============
616
+ /**
617
+ * Join a signaling room. Creates, subscribes, and activates it.
618
+ * Returns an existing room if already joined.
619
+ */
620
+ joinRoom(name) {
621
+ this._assertUsable();
622
+ let room = this._rooms.get(name);
623
+ if (!room) {
624
+ room = this._subscribeRoom(name);
625
+ room._activate();
626
+ }
627
+ return room;
628
+ }
629
+ /**
630
+ * Leave a signaling room. Fully unsubscribes and removes it.
631
+ */
632
+ leaveRoom(name) {
633
+ const room = this._rooms.get(name);
634
+ if (!room)
635
+ return;
636
+ this._log('Leaving room:', name);
637
+ room._cleanup();
638
+ this._rooms.delete(name);
639
+ }
640
+ /**
641
+ * Get all joined rooms.
642
+ */
643
+ getRooms() {
644
+ return Array.from(this._rooms.values());
645
+ }
646
+ // ============ Global Presence ============
647
+ /**
648
+ * Get all peers currently online across all rooms.
649
+ */
650
+ getOnlinePeers() {
651
+ return Array.from(this._onlinePeers.values());
652
+ }
653
+ // ============ Private: Guards ============
654
+ _assertUsable() {
655
+ if (this._detached) {
656
+ throw new Error('NoLagSignal has been detached — construct a new instance');
657
+ }
658
+ if (!this._isReady || !this._localPeer) {
659
+ throw new Error('NoLagSignal not ready — await ready() or the "connected" event');
660
+ }
661
+ }
662
+ // ============ Private: Room Setup ============
663
+ _subscribeRoom(name) {
664
+ this._log('Subscribing room:', name);
665
+ const roomContext = this._client.setApp(this._options.appName).setRoom(name);
666
+ const room = new SignalRoom(name, roomContext, this._localPeer, this._options, createLogger(`SignalRoom:${name}`, this._options.debug), () => this._client.connected);
667
+ this._rooms.set(name, room);
668
+ room._subscribe();
669
+ return room;
670
+ }
671
+ // ============ Private: Scope Filtering ============
672
+ /**
673
+ * On a shared client, presence events from other apps' wrappers arrive on
674
+ * the same connection-level events. Wrappers stamp their presence with a
675
+ * `__scope` (their appName); a mismatched tag means another app's data.
676
+ * Untagged presence is accepted (older peers in this same app).
677
+ */
678
+ _foreignScope(data) {
679
+ const scope = data?.__scope;
680
+ return typeof scope === 'string' && scope !== this._options.appName;
681
+ }
682
+ // ============ Private: Room Presence ============
683
+ _handleRoomPresenceJoin(data) {
684
+ if (data.actorTokenId === this._localPeer?.actorTokenId)
685
+ return;
686
+ const presenceData = data.presence;
687
+ if (!presenceData?.peerId || this._foreignScope(presenceData))
688
+ return;
689
+ const peer = this._presenceToPeer(data.actorTokenId, presenceData);
690
+ this._actorToPeerId.set(data.actorTokenId, peer.peerId);
691
+ if (!this._onlinePeers.has(peer.peerId)) {
692
+ this._onlinePeers.set(peer.peerId, peer);
693
+ this.emit('peerOnline', peer);
694
+ }
695
+ // Route to all rooms
696
+ for (const room of this._rooms.values()) {
697
+ room._handlePresenceJoin(data.actorTokenId, presenceData);
698
+ }
699
+ }
700
+ _handleRoomPresenceLeave(data) {
701
+ if (data.actorTokenId === this._localPeer?.actorTokenId)
702
+ return;
703
+ // Route to all rooms
704
+ for (const room of this._rooms.values()) {
705
+ room._handlePresenceLeave(data.actorTokenId);
706
+ }
707
+ }
708
+ _handleRoomPresenceUpdate(data) {
709
+ if (data.actorTokenId === this._localPeer?.actorTokenId)
710
+ return;
711
+ const presenceData = data.presence;
712
+ if (!presenceData?.peerId || this._foreignScope(presenceData))
713
+ return;
714
+ if (this._onlinePeers.has(presenceData.peerId)) {
715
+ const peer = this._presenceToPeer(data.actorTokenId, presenceData);
716
+ this._onlinePeers.set(peer.peerId, peer);
717
+ }
718
+ // Route to all rooms
719
+ for (const room of this._rooms.values()) {
720
+ room._handlePresenceUpdate(data.actorTokenId, presenceData);
721
+ }
722
+ }
723
+ // ============ Private: Lobby ============
724
+ _handleLobbyJoin(event) {
725
+ const { actorId, data } = event;
726
+ if (actorId === this._localPeer?.actorTokenId)
727
+ return;
728
+ const presenceData = data;
729
+ if (!presenceData.peerId || this._foreignScope(presenceData))
730
+ return;
731
+ const peer = this._presenceToPeer(actorId, presenceData);
732
+ this._actorToPeerId.set(actorId, peer.peerId);
733
+ if (!this._onlinePeers.has(peer.peerId)) {
734
+ this._onlinePeers.set(peer.peerId, peer);
735
+ this.emit('peerOnline', peer);
736
+ }
737
+ }
738
+ _handleLobbyLeave(event) {
739
+ const { actorId, data } = event;
740
+ if (actorId === this._localPeer?.actorTokenId)
741
+ return;
742
+ const presenceData = data;
743
+ if (this._foreignScope(presenceData))
744
+ return;
745
+ const peerId = presenceData?.peerId
746
+ || this._actorToPeerId.get(actorId)
747
+ || this._findPeerIdByActorId(actorId);
748
+ if (peerId) {
749
+ const peer = this._onlinePeers.get(peerId);
750
+ if (peer) {
751
+ this._onlinePeers.delete(peerId);
752
+ this._actorToPeerId.delete(actorId);
753
+ this.emit('peerOffline', peer);
754
+ }
755
+ }
756
+ }
757
+ _handleLobbyUpdate(event) {
758
+ const { actorId, data } = event;
759
+ if (actorId === this._localPeer?.actorTokenId)
760
+ return;
761
+ const presenceData = data;
762
+ if (!presenceData.peerId || this._foreignScope(presenceData))
763
+ return;
764
+ const peer = this._presenceToPeer(actorId, presenceData);
765
+ this._onlinePeers.set(peer.peerId, peer);
766
+ }
767
+ /**
768
+ * Reconcile the online-peer map against a fresh lobby snapshot, emitting
769
+ * only the deltas (peerOffline for vanished, peerOnline for new). One path
770
+ * for initial hydration, reconnect restore, and the deferred refetch.
771
+ */
772
+ _diffHydrateOnlinePeers(state) {
773
+ // Build the fresh peer set from the snapshot
774
+ const fresh = new Map();
775
+ const freshActors = new Map();
776
+ for (const roomId of Object.keys(state)) {
777
+ const roomPresence = state[roomId];
778
+ for (const actorId of Object.keys(roomPresence)) {
779
+ if (actorId === this._localPeer?.actorTokenId)
780
+ continue;
781
+ const raw = roomPresence[actorId];
782
+ // Server returns full actor records with presence nested under .presence
783
+ const presenceData = (raw?.presence ?? raw);
784
+ if (presenceData?.peerId && !this._foreignScope(presenceData)) {
785
+ if (!fresh.has(presenceData.peerId)) {
786
+ fresh.set(presenceData.peerId, this._presenceToPeer(actorId, presenceData));
787
+ }
788
+ freshActors.set(actorId, presenceData.peerId);
789
+ }
790
+ }
791
+ }
792
+ // Vanished peers
793
+ for (const [peerId, peer] of [...this._onlinePeers]) {
794
+ if (!fresh.has(peerId)) {
795
+ this._onlinePeers.delete(peerId);
796
+ for (const [actorId, mappedPeerId] of [...this._actorToPeerId]) {
797
+ if (mappedPeerId === peerId)
798
+ this._actorToPeerId.delete(actorId);
799
+ }
800
+ this.emit('peerOffline', peer);
801
+ }
802
+ }
803
+ // New peers
804
+ for (const [peerId, peer] of fresh) {
805
+ if (!this._onlinePeers.has(peerId)) {
806
+ this._onlinePeers.set(peerId, peer);
807
+ this.emit('peerOnline', peer);
808
+ }
809
+ }
810
+ for (const [actorId, peerId] of freshActors) {
811
+ this._actorToPeerId.set(actorId, peerId);
812
+ }
813
+ }
814
+ // ============ Private: Helpers ============
815
+ _presenceToPeer(actorTokenId, data) {
816
+ return {
817
+ peerId: data.peerId,
818
+ actorTokenId,
819
+ connectionState: 'new',
820
+ metadata: data.metadata,
821
+ joinedAt: Date.now(),
822
+ isLocal: false,
823
+ };
824
+ }
825
+ _findPeerIdByActorId(actorTokenId) {
826
+ for (const peer of this._onlinePeers.values()) {
827
+ if (peer.actorTokenId === actorTokenId)
828
+ return peer.peerId;
829
+ }
830
+ return undefined;
831
+ }
832
+ }
833
+
834
+ export { EventEmitter, NoLagSignal, SignalRoom };
835
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native.js","sources":["../src/EventEmitter.ts","../src/PeerManager.ts","../src/utils.ts","../src/constants.ts","../src/SignalRoom.ts","../src/NoLagSignal.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":"AAAA;;;;AAIG;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,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC;QACtC;AACA,QAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,OAAO,CAAC;AACvC,QAAA,OAAO,IAAI;IACb;IAEA,GAAG,CAA2B,KAAQ,EAAE,OAAwC,EAAA;QAC9E,IAAI,OAAO,EAAE;AACX,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;QAC5C;aAAO;AACL,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9B;AACA,QAAA,OAAO,IAAI;IACb;IAEA,kBAAkB,GAAA;AAChB,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AACtB,QAAA,OAAO,IAAI;IACb;AAEU,IAAA,IAAI,CAA2B,KAAQ,EAAE,GAAG,IAAiB,EAAA;QACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;AAC1C,QAAA,IA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,IAAI,KAAK,EAAE;YAClC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;AACnC,gBAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;YAC/B;QACF;QACA,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,WAAW,EAAE;YAC3C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;QAC1C;IACF;;IAIQ,eAAe,CAAC,YAAoB,EAAE,IAAwB,EAAA;QACpE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY;AACZ,YAAA,eAAe,EAAE,KAAK;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACvB,YAAA,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;AACpB,YAAA,OAAO,EAAE,KAAK;SACf;IACH;AAEQ,IAAA,oBAAoB,CAAC,YAAoB,EAAA;QAC/C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;AAC7C,YAAA,IAAI,IAAI,CAAC,YAAY,KAAK,YAAY;gBAAE,OAAO,IAAI,CAAC,MAAM;QAC5D;AACA,QAAA,OAAO,SAAS;IAClB;AACD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolag/signal",
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"