versacall-core-library-react 2.0.87-dev → 2.0.88-dev

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.
@@ -39,7 +39,7 @@ let packetIdCounter = 0;
39
39
  * topic string → { channelKey, channelName }
40
40
  * Maintained across reconnects so we can resubscribe automatically.
41
41
  */
42
- const activeSubscriptions = new Map(); // lookupKey → {channelKey, channelName, ports: Set}
42
+ const activeSubscriptions = new Map();
43
43
 
44
44
  // ─── Helpers ─────────────────────────────────────────────────────────────────
45
45
 
@@ -57,18 +57,6 @@ function concat(a, b) {
57
57
  out.set(b, a.length);
58
58
  return out;
59
59
  }
60
- function cleanupPortSubscriptions(port) {
61
- for (const [lookupKey, sub] of activeSubscriptions) {
62
- sub.ports.delete(port);
63
- if (sub.ports.size === 0) {
64
- activeSubscriptions.delete(lookupKey);
65
- const mqttTopic = "".concat(sub.channelKey, "/").concat(sub.channelName, "/");
66
- if (mqttConnected) {
67
- wsSend(buildUnsubscribe(nextPacketId(), mqttTopic));
68
- }
69
- }
70
- }
71
- }
72
60
 
73
61
  // ─── MQTT encoding ───────────────────────────────────────────────────────────
74
62
 
@@ -380,34 +368,22 @@ function handlePortMessage(port, msg) {
380
368
  {
381
369
  const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
382
370
  const lookupKey = "".concat(msg.channelName, "/");
383
- const existing = activeSubscriptions.get(lookupKey);
384
- if (existing) {
385
- existing.ports.add(port);
386
- } else {
387
- activeSubscriptions.set(lookupKey, {
388
- channelKey: msg.channelKey,
389
- channelName: msg.channelName,
390
- ports: new Set([port])
391
- });
392
- if (mqttConnected) {
393
- wsSend(buildSubscribe(nextPacketId(), mqttTopic));
394
- }
371
+ activeSubscriptions.set(lookupKey, {
372
+ channelKey: msg.channelKey,
373
+ channelName: msg.channelName
374
+ });
375
+ if (mqttConnected) {
376
+ wsSend(buildSubscribe(nextPacketId(), mqttTopic));
395
377
  }
396
378
  break;
397
379
  }
398
380
  case 'UNSUBSCRIBE':
399
381
  {
400
382
  const lookupKey = "".concat(msg.channelName, "/");
401
- const existing = activeSubscriptions.get(lookupKey);
402
- if (existing) {
403
- existing.ports.delete(port);
404
- if (existing.ports.size === 0) {
405
- activeSubscriptions.delete(lookupKey);
406
- const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
407
- if (mqttConnected) {
408
- wsSend(buildUnsubscribe(nextPacketId(), mqttTopic));
409
- }
410
- }
383
+ activeSubscriptions.delete(lookupKey);
384
+ const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
385
+ if (mqttConnected) {
386
+ wsSend(buildUnsubscribe(nextPacketId(), mqttTopic));
411
387
  }
412
388
  break;
413
389
  }
@@ -426,9 +402,6 @@ self.onconnect = event => {
426
402
  const port = event.ports[0];
427
403
  ports.add(port);
428
404
  port.onmessage = ev => handlePortMessage(port, ev.data);
429
- port.onmessageerror = () => {
430
- ports.delete(port);
431
- cleanupPortSubscriptions(port);
432
- };
405
+ port.onmessageerror = () => ports.delete(port);
433
406
  port.start();
434
407
  };
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "versacall": {
3
3
  "title": "Versacall Core Library React",
4
4
  "applicationType": "react-library",
5
- "build": 87
5
+ "build": 88
6
6
  },
7
7
  "name": "versacall-core-library-react",
8
- "version": "2.0.87-dev",
8
+ "version": "2.0.88-dev",
9
9
  "description": "Versacall Core Library",
10
10
  "main": "dist/index.js",
11
11
  "module": "dist/index.js",