@nsshunt/stssocketioutils 2.0.5 → 2.0.6
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.
|
@@ -2,8 +2,7 @@ import { io } from "socket.io-client";
|
|
|
2
2
|
import { Sleep } from "@nsshunt/stsutils";
|
|
3
3
|
import { Server } from "socket.io";
|
|
4
4
|
import { Redis } from "ioredis";
|
|
5
|
-
import
|
|
6
|
-
import require$$1 from "socket.io-adapter";
|
|
5
|
+
import { createAdapter as createAdapter$1 } from "@socket.io/cluster-adapter";
|
|
7
6
|
import { createAdapter } from "@socket.io/redis-streams-adapter";
|
|
8
7
|
var STSNamespace = /* @__PURE__ */ ((STSNamespace2) => {
|
|
9
8
|
STSNamespace2["STSMonitor"] = "stsinstrumentmanager/stsmonitor";
|
|
@@ -287,563 +286,6 @@ class SocketIoClient extends tinyEmitterExports.TinyEmitter {
|
|
|
287
286
|
});
|
|
288
287
|
}
|
|
289
288
|
}
|
|
290
|
-
var dist = {};
|
|
291
|
-
var browser = { exports: {} };
|
|
292
|
-
var ms;
|
|
293
|
-
var hasRequiredMs;
|
|
294
|
-
function requireMs() {
|
|
295
|
-
if (hasRequiredMs) return ms;
|
|
296
|
-
hasRequiredMs = 1;
|
|
297
|
-
var s = 1e3;
|
|
298
|
-
var m = s * 60;
|
|
299
|
-
var h = m * 60;
|
|
300
|
-
var d = h * 24;
|
|
301
|
-
var w = d * 7;
|
|
302
|
-
var y = d * 365.25;
|
|
303
|
-
ms = function(val, options) {
|
|
304
|
-
options = options || {};
|
|
305
|
-
var type = typeof val;
|
|
306
|
-
if (type === "string" && val.length > 0) {
|
|
307
|
-
return parse(val);
|
|
308
|
-
} else if (type === "number" && isFinite(val)) {
|
|
309
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
310
|
-
}
|
|
311
|
-
throw new Error(
|
|
312
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
313
|
-
);
|
|
314
|
-
};
|
|
315
|
-
function parse(str) {
|
|
316
|
-
str = String(str);
|
|
317
|
-
if (str.length > 100) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
321
|
-
str
|
|
322
|
-
);
|
|
323
|
-
if (!match) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
var n = parseFloat(match[1]);
|
|
327
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
328
|
-
switch (type) {
|
|
329
|
-
case "years":
|
|
330
|
-
case "year":
|
|
331
|
-
case "yrs":
|
|
332
|
-
case "yr":
|
|
333
|
-
case "y":
|
|
334
|
-
return n * y;
|
|
335
|
-
case "weeks":
|
|
336
|
-
case "week":
|
|
337
|
-
case "w":
|
|
338
|
-
return n * w;
|
|
339
|
-
case "days":
|
|
340
|
-
case "day":
|
|
341
|
-
case "d":
|
|
342
|
-
return n * d;
|
|
343
|
-
case "hours":
|
|
344
|
-
case "hour":
|
|
345
|
-
case "hrs":
|
|
346
|
-
case "hr":
|
|
347
|
-
case "h":
|
|
348
|
-
return n * h;
|
|
349
|
-
case "minutes":
|
|
350
|
-
case "minute":
|
|
351
|
-
case "mins":
|
|
352
|
-
case "min":
|
|
353
|
-
case "m":
|
|
354
|
-
return n * m;
|
|
355
|
-
case "seconds":
|
|
356
|
-
case "second":
|
|
357
|
-
case "secs":
|
|
358
|
-
case "sec":
|
|
359
|
-
case "s":
|
|
360
|
-
return n * s;
|
|
361
|
-
case "milliseconds":
|
|
362
|
-
case "millisecond":
|
|
363
|
-
case "msecs":
|
|
364
|
-
case "msec":
|
|
365
|
-
case "ms":
|
|
366
|
-
return n;
|
|
367
|
-
default:
|
|
368
|
-
return void 0;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function fmtShort(ms2) {
|
|
372
|
-
var msAbs = Math.abs(ms2);
|
|
373
|
-
if (msAbs >= d) {
|
|
374
|
-
return Math.round(ms2 / d) + "d";
|
|
375
|
-
}
|
|
376
|
-
if (msAbs >= h) {
|
|
377
|
-
return Math.round(ms2 / h) + "h";
|
|
378
|
-
}
|
|
379
|
-
if (msAbs >= m) {
|
|
380
|
-
return Math.round(ms2 / m) + "m";
|
|
381
|
-
}
|
|
382
|
-
if (msAbs >= s) {
|
|
383
|
-
return Math.round(ms2 / s) + "s";
|
|
384
|
-
}
|
|
385
|
-
return ms2 + "ms";
|
|
386
|
-
}
|
|
387
|
-
function fmtLong(ms2) {
|
|
388
|
-
var msAbs = Math.abs(ms2);
|
|
389
|
-
if (msAbs >= d) {
|
|
390
|
-
return plural(ms2, msAbs, d, "day");
|
|
391
|
-
}
|
|
392
|
-
if (msAbs >= h) {
|
|
393
|
-
return plural(ms2, msAbs, h, "hour");
|
|
394
|
-
}
|
|
395
|
-
if (msAbs >= m) {
|
|
396
|
-
return plural(ms2, msAbs, m, "minute");
|
|
397
|
-
}
|
|
398
|
-
if (msAbs >= s) {
|
|
399
|
-
return plural(ms2, msAbs, s, "second");
|
|
400
|
-
}
|
|
401
|
-
return ms2 + " ms";
|
|
402
|
-
}
|
|
403
|
-
function plural(ms2, msAbs, n, name) {
|
|
404
|
-
var isPlural = msAbs >= n * 1.5;
|
|
405
|
-
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
|
|
406
|
-
}
|
|
407
|
-
return ms;
|
|
408
|
-
}
|
|
409
|
-
var common;
|
|
410
|
-
var hasRequiredCommon;
|
|
411
|
-
function requireCommon() {
|
|
412
|
-
if (hasRequiredCommon) return common;
|
|
413
|
-
hasRequiredCommon = 1;
|
|
414
|
-
function setup(env) {
|
|
415
|
-
createDebug.debug = createDebug;
|
|
416
|
-
createDebug.default = createDebug;
|
|
417
|
-
createDebug.coerce = coerce;
|
|
418
|
-
createDebug.disable = disable;
|
|
419
|
-
createDebug.enable = enable;
|
|
420
|
-
createDebug.enabled = enabled;
|
|
421
|
-
createDebug.humanize = requireMs();
|
|
422
|
-
createDebug.destroy = destroy;
|
|
423
|
-
Object.keys(env).forEach((key) => {
|
|
424
|
-
createDebug[key] = env[key];
|
|
425
|
-
});
|
|
426
|
-
createDebug.names = [];
|
|
427
|
-
createDebug.skips = [];
|
|
428
|
-
createDebug.formatters = {};
|
|
429
|
-
function selectColor(namespace) {
|
|
430
|
-
let hash = 0;
|
|
431
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
432
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
433
|
-
hash |= 0;
|
|
434
|
-
}
|
|
435
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
436
|
-
}
|
|
437
|
-
createDebug.selectColor = selectColor;
|
|
438
|
-
function createDebug(namespace) {
|
|
439
|
-
let prevTime;
|
|
440
|
-
let enableOverride = null;
|
|
441
|
-
let namespacesCache;
|
|
442
|
-
let enabledCache;
|
|
443
|
-
function debug(...args) {
|
|
444
|
-
if (!debug.enabled) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const self = debug;
|
|
448
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
449
|
-
const ms2 = curr - (prevTime || curr);
|
|
450
|
-
self.diff = ms2;
|
|
451
|
-
self.prev = prevTime;
|
|
452
|
-
self.curr = curr;
|
|
453
|
-
prevTime = curr;
|
|
454
|
-
args[0] = createDebug.coerce(args[0]);
|
|
455
|
-
if (typeof args[0] !== "string") {
|
|
456
|
-
args.unshift("%O");
|
|
457
|
-
}
|
|
458
|
-
let index = 0;
|
|
459
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
460
|
-
if (match === "%%") {
|
|
461
|
-
return "%";
|
|
462
|
-
}
|
|
463
|
-
index++;
|
|
464
|
-
const formatter = createDebug.formatters[format];
|
|
465
|
-
if (typeof formatter === "function") {
|
|
466
|
-
const val = args[index];
|
|
467
|
-
match = formatter.call(self, val);
|
|
468
|
-
args.splice(index, 1);
|
|
469
|
-
index--;
|
|
470
|
-
}
|
|
471
|
-
return match;
|
|
472
|
-
});
|
|
473
|
-
createDebug.formatArgs.call(self, args);
|
|
474
|
-
const logFn = self.log || createDebug.log;
|
|
475
|
-
logFn.apply(self, args);
|
|
476
|
-
}
|
|
477
|
-
debug.namespace = namespace;
|
|
478
|
-
debug.useColors = createDebug.useColors();
|
|
479
|
-
debug.color = createDebug.selectColor(namespace);
|
|
480
|
-
debug.extend = extend;
|
|
481
|
-
debug.destroy = createDebug.destroy;
|
|
482
|
-
Object.defineProperty(debug, "enabled", {
|
|
483
|
-
enumerable: true,
|
|
484
|
-
configurable: false,
|
|
485
|
-
get: () => {
|
|
486
|
-
if (enableOverride !== null) {
|
|
487
|
-
return enableOverride;
|
|
488
|
-
}
|
|
489
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
490
|
-
namespacesCache = createDebug.namespaces;
|
|
491
|
-
enabledCache = createDebug.enabled(namespace);
|
|
492
|
-
}
|
|
493
|
-
return enabledCache;
|
|
494
|
-
},
|
|
495
|
-
set: (v) => {
|
|
496
|
-
enableOverride = v;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
if (typeof createDebug.init === "function") {
|
|
500
|
-
createDebug.init(debug);
|
|
501
|
-
}
|
|
502
|
-
return debug;
|
|
503
|
-
}
|
|
504
|
-
function extend(namespace, delimiter) {
|
|
505
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
506
|
-
newDebug.log = this.log;
|
|
507
|
-
return newDebug;
|
|
508
|
-
}
|
|
509
|
-
function enable(namespaces) {
|
|
510
|
-
createDebug.save(namespaces);
|
|
511
|
-
createDebug.namespaces = namespaces;
|
|
512
|
-
createDebug.names = [];
|
|
513
|
-
createDebug.skips = [];
|
|
514
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
515
|
-
for (const ns of split) {
|
|
516
|
-
if (ns[0] === "-") {
|
|
517
|
-
createDebug.skips.push(ns.slice(1));
|
|
518
|
-
} else {
|
|
519
|
-
createDebug.names.push(ns);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function matchesTemplate(search, template) {
|
|
524
|
-
let searchIndex = 0;
|
|
525
|
-
let templateIndex = 0;
|
|
526
|
-
let starIndex = -1;
|
|
527
|
-
let matchIndex = 0;
|
|
528
|
-
while (searchIndex < search.length) {
|
|
529
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
530
|
-
if (template[templateIndex] === "*") {
|
|
531
|
-
starIndex = templateIndex;
|
|
532
|
-
matchIndex = searchIndex;
|
|
533
|
-
templateIndex++;
|
|
534
|
-
} else {
|
|
535
|
-
searchIndex++;
|
|
536
|
-
templateIndex++;
|
|
537
|
-
}
|
|
538
|
-
} else if (starIndex !== -1) {
|
|
539
|
-
templateIndex = starIndex + 1;
|
|
540
|
-
matchIndex++;
|
|
541
|
-
searchIndex = matchIndex;
|
|
542
|
-
} else {
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
547
|
-
templateIndex++;
|
|
548
|
-
}
|
|
549
|
-
return templateIndex === template.length;
|
|
550
|
-
}
|
|
551
|
-
function disable() {
|
|
552
|
-
const namespaces = [
|
|
553
|
-
...createDebug.names,
|
|
554
|
-
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
555
|
-
].join(",");
|
|
556
|
-
createDebug.enable("");
|
|
557
|
-
return namespaces;
|
|
558
|
-
}
|
|
559
|
-
function enabled(name) {
|
|
560
|
-
for (const skip of createDebug.skips) {
|
|
561
|
-
if (matchesTemplate(name, skip)) {
|
|
562
|
-
return false;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
for (const ns of createDebug.names) {
|
|
566
|
-
if (matchesTemplate(name, ns)) {
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
function coerce(val) {
|
|
573
|
-
if (val instanceof Error) {
|
|
574
|
-
return val.stack || val.message;
|
|
575
|
-
}
|
|
576
|
-
return val;
|
|
577
|
-
}
|
|
578
|
-
function destroy() {
|
|
579
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
580
|
-
}
|
|
581
|
-
createDebug.enable(createDebug.load());
|
|
582
|
-
return createDebug;
|
|
583
|
-
}
|
|
584
|
-
common = setup;
|
|
585
|
-
return common;
|
|
586
|
-
}
|
|
587
|
-
var hasRequiredBrowser;
|
|
588
|
-
function requireBrowser() {
|
|
589
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
590
|
-
hasRequiredBrowser = 1;
|
|
591
|
-
(function(module, exports) {
|
|
592
|
-
exports.formatArgs = formatArgs;
|
|
593
|
-
exports.save = save;
|
|
594
|
-
exports.load = load;
|
|
595
|
-
exports.useColors = useColors;
|
|
596
|
-
exports.storage = localstorage();
|
|
597
|
-
exports.destroy = /* @__PURE__ */ (() => {
|
|
598
|
-
let warned = false;
|
|
599
|
-
return () => {
|
|
600
|
-
if (!warned) {
|
|
601
|
-
warned = true;
|
|
602
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
})();
|
|
606
|
-
exports.colors = [
|
|
607
|
-
"#0000CC",
|
|
608
|
-
"#0000FF",
|
|
609
|
-
"#0033CC",
|
|
610
|
-
"#0033FF",
|
|
611
|
-
"#0066CC",
|
|
612
|
-
"#0066FF",
|
|
613
|
-
"#0099CC",
|
|
614
|
-
"#0099FF",
|
|
615
|
-
"#00CC00",
|
|
616
|
-
"#00CC33",
|
|
617
|
-
"#00CC66",
|
|
618
|
-
"#00CC99",
|
|
619
|
-
"#00CCCC",
|
|
620
|
-
"#00CCFF",
|
|
621
|
-
"#3300CC",
|
|
622
|
-
"#3300FF",
|
|
623
|
-
"#3333CC",
|
|
624
|
-
"#3333FF",
|
|
625
|
-
"#3366CC",
|
|
626
|
-
"#3366FF",
|
|
627
|
-
"#3399CC",
|
|
628
|
-
"#3399FF",
|
|
629
|
-
"#33CC00",
|
|
630
|
-
"#33CC33",
|
|
631
|
-
"#33CC66",
|
|
632
|
-
"#33CC99",
|
|
633
|
-
"#33CCCC",
|
|
634
|
-
"#33CCFF",
|
|
635
|
-
"#6600CC",
|
|
636
|
-
"#6600FF",
|
|
637
|
-
"#6633CC",
|
|
638
|
-
"#6633FF",
|
|
639
|
-
"#66CC00",
|
|
640
|
-
"#66CC33",
|
|
641
|
-
"#9900CC",
|
|
642
|
-
"#9900FF",
|
|
643
|
-
"#9933CC",
|
|
644
|
-
"#9933FF",
|
|
645
|
-
"#99CC00",
|
|
646
|
-
"#99CC33",
|
|
647
|
-
"#CC0000",
|
|
648
|
-
"#CC0033",
|
|
649
|
-
"#CC0066",
|
|
650
|
-
"#CC0099",
|
|
651
|
-
"#CC00CC",
|
|
652
|
-
"#CC00FF",
|
|
653
|
-
"#CC3300",
|
|
654
|
-
"#CC3333",
|
|
655
|
-
"#CC3366",
|
|
656
|
-
"#CC3399",
|
|
657
|
-
"#CC33CC",
|
|
658
|
-
"#CC33FF",
|
|
659
|
-
"#CC6600",
|
|
660
|
-
"#CC6633",
|
|
661
|
-
"#CC9900",
|
|
662
|
-
"#CC9933",
|
|
663
|
-
"#CCCC00",
|
|
664
|
-
"#CCCC33",
|
|
665
|
-
"#FF0000",
|
|
666
|
-
"#FF0033",
|
|
667
|
-
"#FF0066",
|
|
668
|
-
"#FF0099",
|
|
669
|
-
"#FF00CC",
|
|
670
|
-
"#FF00FF",
|
|
671
|
-
"#FF3300",
|
|
672
|
-
"#FF3333",
|
|
673
|
-
"#FF3366",
|
|
674
|
-
"#FF3399",
|
|
675
|
-
"#FF33CC",
|
|
676
|
-
"#FF33FF",
|
|
677
|
-
"#FF6600",
|
|
678
|
-
"#FF6633",
|
|
679
|
-
"#FF9900",
|
|
680
|
-
"#FF9933",
|
|
681
|
-
"#FFCC00",
|
|
682
|
-
"#FFCC33"
|
|
683
|
-
];
|
|
684
|
-
function useColors() {
|
|
685
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
686
|
-
return true;
|
|
687
|
-
}
|
|
688
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
689
|
-
return false;
|
|
690
|
-
}
|
|
691
|
-
let m;
|
|
692
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
693
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
694
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
695
|
-
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
696
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
697
|
-
}
|
|
698
|
-
function formatArgs(args) {
|
|
699
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
700
|
-
if (!this.useColors) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
const c = "color: " + this.color;
|
|
704
|
-
args.splice(1, 0, c, "color: inherit");
|
|
705
|
-
let index = 0;
|
|
706
|
-
let lastC = 0;
|
|
707
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
708
|
-
if (match === "%%") {
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
index++;
|
|
712
|
-
if (match === "%c") {
|
|
713
|
-
lastC = index;
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
args.splice(lastC, 0, c);
|
|
717
|
-
}
|
|
718
|
-
exports.log = console.debug || console.log || (() => {
|
|
719
|
-
});
|
|
720
|
-
function save(namespaces) {
|
|
721
|
-
try {
|
|
722
|
-
if (namespaces) {
|
|
723
|
-
exports.storage.setItem("debug", namespaces);
|
|
724
|
-
} else {
|
|
725
|
-
exports.storage.removeItem("debug");
|
|
726
|
-
}
|
|
727
|
-
} catch (error) {
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
function load() {
|
|
731
|
-
let r;
|
|
732
|
-
try {
|
|
733
|
-
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
734
|
-
} catch (error) {
|
|
735
|
-
}
|
|
736
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
737
|
-
r = process.env.DEBUG;
|
|
738
|
-
}
|
|
739
|
-
return r;
|
|
740
|
-
}
|
|
741
|
-
function localstorage() {
|
|
742
|
-
try {
|
|
743
|
-
return localStorage;
|
|
744
|
-
} catch (error) {
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
module.exports = requireCommon()(exports);
|
|
748
|
-
const { formatters } = module.exports;
|
|
749
|
-
formatters.j = function(v) {
|
|
750
|
-
try {
|
|
751
|
-
return JSON.stringify(v);
|
|
752
|
-
} catch (error) {
|
|
753
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
})(browser, browser.exports);
|
|
757
|
-
return browser.exports;
|
|
758
|
-
}
|
|
759
|
-
var hasRequiredDist;
|
|
760
|
-
function requireDist() {
|
|
761
|
-
if (hasRequiredDist) return dist;
|
|
762
|
-
hasRequiredDist = 1;
|
|
763
|
-
var __importDefault = dist && dist.__importDefault || function(mod) {
|
|
764
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
765
|
-
};
|
|
766
|
-
Object.defineProperty(dist, "__esModule", { value: true });
|
|
767
|
-
dist.NodeClusterAdapter = void 0;
|
|
768
|
-
dist.createAdapter = createAdapter2;
|
|
769
|
-
dist.setupPrimary = setupPrimary;
|
|
770
|
-
const node_cluster_1 = __importDefault(require$$0);
|
|
771
|
-
const socket_io_adapter_1 = require$$1;
|
|
772
|
-
const debug_1 = __importDefault(requireBrowser());
|
|
773
|
-
const debug = (0, debug_1.default)("socket.io-cluster-adapter");
|
|
774
|
-
const MESSAGE_SOURCE = "_sio_adapter";
|
|
775
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
776
|
-
function ignoreError() {
|
|
777
|
-
}
|
|
778
|
-
function createAdapter2(opts = {}) {
|
|
779
|
-
return function(nsp) {
|
|
780
|
-
return new NodeClusterAdapter(nsp, opts);
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
class NodeClusterAdapter extends socket_io_adapter_1.ClusterAdapterWithHeartbeat {
|
|
784
|
-
constructor(nsp, opts = {}) {
|
|
785
|
-
super(nsp, opts);
|
|
786
|
-
process.on("message", (message) => {
|
|
787
|
-
const isValidSource = (message === null || message === void 0 ? void 0 : message.source) === MESSAGE_SOURCE;
|
|
788
|
-
if (!isValidSource) {
|
|
789
|
-
debug("[%s] ignore unknown source", this.uid);
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
if (message.nsp !== this.nsp.name) {
|
|
793
|
-
debug("[%s] ignore other namespace", this.uid);
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
this.onMessage(message);
|
|
797
|
-
});
|
|
798
|
-
this.init();
|
|
799
|
-
}
|
|
800
|
-
doPublish(message) {
|
|
801
|
-
message.source = MESSAGE_SOURCE;
|
|
802
|
-
process.send(message, null, {}, ignoreError);
|
|
803
|
-
return Promise.resolve("");
|
|
804
|
-
}
|
|
805
|
-
doPublishResponse(requesterUid, response) {
|
|
806
|
-
response.source = MESSAGE_SOURCE;
|
|
807
|
-
response.requesterUid = requesterUid;
|
|
808
|
-
process.send(response, null, {}, ignoreError);
|
|
809
|
-
return Promise.resolve();
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
dist.NodeClusterAdapter = NodeClusterAdapter;
|
|
813
|
-
const UIDS = /* @__PURE__ */ Symbol("uids");
|
|
814
|
-
function setupPrimary() {
|
|
815
|
-
node_cluster_1.default.on("message", (worker, message) => {
|
|
816
|
-
var _a;
|
|
817
|
-
const isValidSource = (message === null || message === void 0 ? void 0 : message.source) === MESSAGE_SOURCE;
|
|
818
|
-
if (!isValidSource) {
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
worker[UIDS] = worker[UIDS] || /* @__PURE__ */ new Set();
|
|
822
|
-
worker[UIDS].add(message.uid);
|
|
823
|
-
switch (message.type) {
|
|
824
|
-
case socket_io_adapter_1.MessageType.FETCH_SOCKETS_RESPONSE:
|
|
825
|
-
case socket_io_adapter_1.MessageType.SERVER_SIDE_EMIT_RESPONSE:
|
|
826
|
-
const requesterUid = message.requesterUid;
|
|
827
|
-
for (const workerId in node_cluster_1.default.workers) {
|
|
828
|
-
if (hasOwnProperty.call(node_cluster_1.default.workers, workerId) && ((_a = node_cluster_1.default.workers[workerId][UIDS]) === null || _a === void 0 ? void 0 : _a.has(requesterUid))) {
|
|
829
|
-
node_cluster_1.default.workers[workerId].send(message, null, ignoreError);
|
|
830
|
-
break;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
break;
|
|
834
|
-
default:
|
|
835
|
-
const emitterIdAsString = String(worker.id);
|
|
836
|
-
for (const workerId in node_cluster_1.default.workers) {
|
|
837
|
-
if (hasOwnProperty.call(node_cluster_1.default.workers, workerId) && workerId !== emitterIdAsString) {
|
|
838
|
-
node_cluster_1.default.workers[workerId].send(message, null, ignoreError);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
return dist;
|
|
845
|
-
}
|
|
846
|
-
var distExports = requireDist();
|
|
847
289
|
class SocketIoServer extends tinyEmitterExports.TinyEmitter {
|
|
848
290
|
namespace;
|
|
849
291
|
socketionamespace;
|
|
@@ -902,7 +344,7 @@ class SocketIoServer extends tinyEmitterExports.TinyEmitter {
|
|
|
902
344
|
this.redisClient = new Redis(socketIoServeroptions.ioRedisMessageProcessorUrl);
|
|
903
345
|
options.adapter = createAdapter(this.redisClient);
|
|
904
346
|
} else if (socketIoServeroptions.serverClusterMode && socketIoServeroptions.serverClusterMode === true) {
|
|
905
|
-
options.adapter =
|
|
347
|
+
options.adapter = createAdapter$1();
|
|
906
348
|
}
|
|
907
349
|
if (socketIoServeroptions.wssCustomPath && socketIoServeroptions.wssCustomPath.localeCompare("") !== 0) {
|
|
908
350
|
options.path = socketIoServeroptions.wssCustomPath;
|
|
@@ -970,7 +412,7 @@ class SocketIoServer extends tinyEmitterExports.TinyEmitter {
|
|
|
970
412
|
this.redisClient = new Redis(this.ioRedisMessageProcessorUrl);
|
|
971
413
|
options.adapter = createAdapter(this.redisClient);
|
|
972
414
|
} else if (this.serverClusterMode && this.serverClusterMode === true) {
|
|
973
|
-
options.adapter =
|
|
415
|
+
options.adapter = createAdapter$1();
|
|
974
416
|
}
|
|
975
417
|
if (this.socketIoCustomPath && this.socketIoCustomPath.localeCompare("") !== 0) {
|
|
976
418
|
options.path = this.socketIoCustomPath;
|