versacall-core-library-react 2.0.84-dev → 2.0.86-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.
@@ -172,8 +172,6 @@ function initWorkerPort(host, secure, log) {
172
172
  type
173
173
  } = ev.data;
174
174
  if (type === 'MESSAGE') {
175
- // ev.data.channel is the raw MQTT topic "{channelKey}/{channelName}/"
176
- // — identical to what emitter-io exposed as msg.channel.
177
175
  processMessage(ev.data.channel, ev.data.data);
178
176
  } else if (type === 'CONNECTION_CHANGED') {
179
177
  log('system', namespace, 'workerPort.onmessage', ev.data.connected ? 'Emitter Connect' : 'Emitter Disconnect');
@@ -166,7 +166,6 @@ function decodeVarInt(buf, offset) {
166
166
  * Leaves any trailing incomplete bytes in receiveBuffer.
167
167
  */
168
168
  function drainBuffer() {
169
- console.log('[vc-worker] drainBuffer called, buffer length:', receiveBuffer.length);
170
169
  let offset = 0;
171
170
  while (offset < receiveBuffer.length) {
172
171
  const firstByte = receiveBuffer[offset];
@@ -187,7 +186,6 @@ function drainBuffer() {
187
186
 
188
187
  /** Route a decoded MQTT packet to the appropriate handler. */
189
188
  function dispatchMqttPacket(type, flags, body) {
190
- console.log('[vc-worker] dispatchMqttPacket type:', type, 'body length:', body.length);
191
189
  switch (type) {
192
190
  case 2:
193
191
  return onConnack(body);
@@ -216,8 +214,8 @@ function onConnack(body) {
216
214
  // Resubscribe every channel the app has asked for.
217
215
  // This handles both initial subscription after connect AND
218
216
  // re-subscription after an unintended disconnect / reconnect.
219
- activeSubscriptions.forEach((_, topic) => {
220
- wsSend(buildSubscribe(nextPacketId(), topic));
217
+ activeSubscriptions.forEach(sub => {
218
+ wsSend(buildSubscribe(nextPacketId(), "".concat(sub.channelKey, "/").concat(sub.channelName, "/")));
221
219
  });
222
220
  }
223
221
 
@@ -228,27 +226,13 @@ function onConnack(body) {
228
226
  * forward it unchanged — ChannelsConsumer handlers will match as before.
229
227
  */
230
228
  function onPublish(flags, body) {
231
- console.log('[vc-worker] onPublish called, body length:', body.length);
232
229
  if (body.length < 2) return;
233
230
  const topicLen = body[0] << 8 | body[1];
234
231
  if (2 + topicLen > body.length) return;
235
232
  const topic = textDecoder.decode(body.slice(2, 2 + topicLen));
236
- console.log('[vc-worker] topic:', topic);
237
233
  const qos = flags >> 1 & 0x03;
238
- console.log('[vc-worker] qos:', qos);
239
234
  const payloadStart = 2 + topicLen + (qos > 0 ? 2 : 0);
240
235
  const payloadStr = textDecoder.decode(body.slice(payloadStart));
241
- console.log('[vc-worker] payload first 200 chars:', payloadStr.substring(0, 200));
242
-
243
- // TEMPORARY DEBUG - remove after diagnosis
244
- ports.forEach(port => {
245
- try {
246
- port.postMessage({
247
- type: 'LOG',
248
- message: 'RAW TOPIC: ' + topic + ' | QOS: ' + qos + ' | PAYLOAD: ' + payloadStr.substring(0, 200)
249
- });
250
- } catch (_) {}
251
- });
252
236
  let data;
253
237
  try {
254
238
  data = JSON.parse(payloadStr);
@@ -259,7 +243,7 @@ function onPublish(flags, body) {
259
243
  // Look up channelName from activeSubscriptions — emitter-io only
260
244
  // exposes the channelName (not the full key/name/ MQTT topic)
261
245
  const sub = activeSubscriptions.get(topic);
262
- const channelName = sub ? sub.channelName : topic.replace(/\/$/, '').split('/').slice(1).join('/');
246
+ const channelName = sub ? sub.channelName : topic.replace(/\/$/, '');
263
247
  broadcast({
264
248
  type: 'MESSAGE',
265
249
  channel: channelName,
@@ -308,7 +292,6 @@ function openWebSocket(config) {
308
292
  pingIntervalId = setInterval(() => wsSend(PINGREQ), 25000);
309
293
  };
310
294
  ws.onmessage = ev => {
311
- console.log('[vc-worker] WebSocket data received, bytes:', ev.data.byteLength);
312
295
  receiveBuffer = concat(receiveBuffer, new Uint8Array(ev.data));
313
296
  drainBuffer();
314
297
  };
@@ -369,10 +352,6 @@ function handlePortMessage(port, msg) {
369
352
  // First INIT — record config and open the connection.
370
353
  wsConfig = config;
371
354
  openWebSocket(config);
372
- port.postMessage({
373
- type: 'LOG',
374
- message: 'Worker: first INIT, opening WebSocket'
375
- });
376
355
  } else if (mqttConnected) {
377
356
  // Subsequent INIT from a later iframe — we're already live.
378
357
  // Immediately tell the new port so it can update connection-state UI.
@@ -380,10 +359,6 @@ function handlePortMessage(port, msg) {
380
359
  type: 'CONNECTION_CHANGED',
381
360
  connected: true
382
361
  });
383
- port.postMessage({
384
- type: 'LOG',
385
- message: 'Worker: subsequent INIT, reusing existing connection. Total ports: ' + ports.size
386
- });
387
362
  }
388
363
  // If !mqttConnected and wsConfig is already set we're in the middle of
389
364
  // connecting; the CONNACK broadcast will reach the new port once ready.
@@ -391,25 +366,24 @@ function handlePortMessage(port, msg) {
391
366
  }
392
367
  case 'SUBSCRIBE':
393
368
  {
394
- // topic format matches emitter-io: "{channelKey}/{channelName}/"
395
- const topic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
396
- activeSubscriptions.set(topic, {
369
+ const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
370
+ const lookupKey = "".concat(msg.channelName, "/");
371
+ activeSubscriptions.set(lookupKey, {
397
372
  channelKey: msg.channelKey,
398
373
  channelName: msg.channelName
399
374
  });
400
- // Send SUBSCRIBE immediately if already connected; otherwise the topic
401
- // will be replayed in onConnack() when the connection comes up.
402
375
  if (mqttConnected) {
403
- wsSend(buildSubscribe(nextPacketId(), topic));
376
+ wsSend(buildSubscribe(nextPacketId(), mqttTopic));
404
377
  }
405
378
  break;
406
379
  }
407
380
  case 'UNSUBSCRIBE':
408
381
  {
409
- const topic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
410
- activeSubscriptions.delete(topic);
382
+ const lookupKey = "".concat(msg.channelName, "/");
383
+ activeSubscriptions.delete(lookupKey);
384
+ const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
411
385
  if (mqttConnected) {
412
- wsSend(buildUnsubscribe(nextPacketId(), topic));
386
+ wsSend(buildUnsubscribe(nextPacketId(), mqttTopic));
413
387
  }
414
388
  break;
415
389
  }
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": 84
5
+ "build": 86
6
6
  },
7
7
  "name": "versacall-core-library-react",
8
- "version": "2.0.84-dev",
8
+ "version": "2.0.86-dev",
9
9
  "description": "Versacall Core Library",
10
10
  "main": "dist/index.js",
11
11
  "module": "dist/index.js",