@remix_labs/hub-client 2.2063.0-dev → 2.2067.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.
Files changed (2) hide show
  1. package/common.js +14 -21
  2. package/package.json +1 -1
package/common.js CHANGED
@@ -430,15 +430,21 @@ class Channel {
430
430
  }
431
431
  }
432
432
 
433
- // This class starts the web worker for the hub. It comes in two flavors:
434
- // - ScopedWorker: an independent instance of the worker
435
- // - Worker: the global instance of the worker, i.e. "new Worker()" gets
436
- // you every time the same worker
437
- class ScopedWorker {
433
+ // This class starts the web worker for the hub. Should only be instantiated
434
+ // once.
435
+ class Worker {
438
436
  constructor() {
437
+ if (globalThis.RmxMessagingHub) {
438
+ this.worker = globalThis.RmxMessagingHub.worker;
439
+ this.expect = globalThis.RmxMessagingHub.expect;
440
+ this.noreconfigure = true;
441
+ return;
442
+ };
443
+
439
444
  // injected by either index.js or node.js
440
445
  this.worker = globalThis.GetHubWorker();
441
446
 
447
+ globalThis.RmxMessagingHub = this;
442
448
  let thisworker = this;
443
449
  this.expect = new Array(0);
444
450
  // sigh, browser/node have a different API for this
@@ -455,6 +461,7 @@ class ScopedWorker {
455
461
  }
456
462
 
457
463
  this.noreconfigure = false;
464
+ terminate(() => thisworker.worker.terminate());
458
465
  }
459
466
 
460
467
  configure(config_obj) {
@@ -520,19 +527,5 @@ class ScopedWorker {
520
527
  }
521
528
  }
522
529
 
523
- class Worker extends ScopedWorker {
524
- constructor() {
525
- if (globalThis.RmxMessagingHub) {
526
- this.worker = globalThis.RmxMessagingHub.worker;
527
- this.expect = globalThis.RmxMessagingHub.expect;
528
- this.noreconfigure = true;
529
- return;
530
- };
531
- super();
532
- globalThis.RmxMessagingHub = this;
533
- terminate(() => thisworker.worker.terminate());
534
- }
535
- }
536
-
537
- export { Worker, ScopedWorker, Channel,
538
- JSONMessage, TextMessage, BinaryMessage, LocalMessage, EOF }
530
+ export { Worker, Channel, JSONMessage, TextMessage, BinaryMessage, LocalMessage,
531
+ EOF }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/hub-client",
3
- "version": "2.2063.0-dev",
3
+ "version": "2.2067.0",
4
4
  "description": "talk to the Hub web worker",
5
5
  "main": "node.js",
6
6
  "browser": "index.js",