crossws 0.2.2 → 0.2.4
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.
- package/dist/adapters/bun.cjs +2 -2
- package/dist/adapters/bun.d.cts +1 -1
- package/dist/adapters/bun.d.mts +1 -1
- package/dist/adapters/bun.d.ts +1 -1
- package/dist/adapters/bun.mjs +2 -2
- package/dist/adapters/cloudflare.cjs +2 -2
- package/dist/adapters/cloudflare.d.cts +1 -1
- package/dist/adapters/cloudflare.d.mts +1 -1
- package/dist/adapters/cloudflare.d.ts +1 -1
- package/dist/adapters/cloudflare.mjs +2 -2
- package/dist/adapters/deno.cjs +2 -2
- package/dist/adapters/deno.d.cts +1 -1
- package/dist/adapters/deno.d.mts +1 -1
- package/dist/adapters/deno.d.ts +1 -1
- package/dist/adapters/deno.mjs +2 -2
- package/dist/adapters/node.cjs +22 -4
- package/dist/adapters/node.d.cts +1 -1
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.d.ts +1 -1
- package/dist/adapters/node.mjs +22 -4
- package/dist/adapters/uws.cjs +2 -2
- package/dist/adapters/uws.d.cts +1 -1
- package/dist/adapters/uws.d.mts +1 -1
- package/dist/adapters/uws.d.ts +1 -1
- package/dist/adapters/uws.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{crossws.c13afbe7.cjs → crossws.36b9e66f.cjs} +15 -5
- package/dist/shared/{crossws.a2e5c71e.d.cts → crossws.381454fe.d.cts} +4 -1
- package/dist/shared/{crossws.a2e5c71e.d.mts → crossws.381454fe.d.mts} +4 -1
- package/dist/shared/{crossws.a2e5c71e.d.ts → crossws.381454fe.d.ts} +4 -1
- package/dist/shared/{crossws.34cfc8d0.mjs → crossws.77e89680.mjs} +15 -5
- package/package.json +1 -1
package/dist/adapters/bun.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types = require('../shared/crossws.
|
|
3
|
+
const types = require('../shared/crossws.36b9e66f.cjs');
|
|
4
4
|
|
|
5
5
|
const bun = types.defineWebSocketAdapter(
|
|
6
6
|
(options = {}) => {
|
|
@@ -58,7 +58,7 @@ const bun = types.defineWebSocketAdapter(
|
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
class BunPeer extends types.Peer {
|
|
61
|
-
get
|
|
61
|
+
get addr() {
|
|
62
62
|
let addr = this.ctx.bun.ws.remoteAddress;
|
|
63
63
|
if (addr.includes(":")) {
|
|
64
64
|
addr = `[${addr}]`;
|
package/dist/adapters/bun.d.cts
CHANGED
package/dist/adapters/bun.d.mts
CHANGED
package/dist/adapters/bun.d.ts
CHANGED
package/dist/adapters/bun.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineWebSocketAdapter, M as Message, c as createCrossWS, P as Peer, t as toBufferLike } from '../shared/crossws.
|
|
1
|
+
import { d as defineWebSocketAdapter, M as Message, c as createCrossWS, P as Peer, t as toBufferLike } from '../shared/crossws.77e89680.mjs';
|
|
2
2
|
|
|
3
3
|
const bun = defineWebSocketAdapter(
|
|
4
4
|
(options = {}) => {
|
|
@@ -56,7 +56,7 @@ const bun = defineWebSocketAdapter(
|
|
|
56
56
|
}
|
|
57
57
|
);
|
|
58
58
|
class BunPeer extends Peer {
|
|
59
|
-
get
|
|
59
|
+
get addr() {
|
|
60
60
|
let addr = this.ctx.bun.ws.remoteAddress;
|
|
61
61
|
if (addr.includes(":")) {
|
|
62
62
|
addr = `[${addr}]`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types = require('../shared/crossws.
|
|
3
|
+
const types = require('../shared/crossws.36b9e66f.cjs');
|
|
4
4
|
const index = require('../index.cjs');
|
|
5
5
|
|
|
6
6
|
const cloudflare = types.defineWebSocketAdapter(
|
|
@@ -44,7 +44,7 @@ const cloudflare = types.defineWebSocketAdapter(
|
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
class CloudflarePeer extends types.Peer {
|
|
47
|
-
get
|
|
47
|
+
get addr() {
|
|
48
48
|
return void 0;
|
|
49
49
|
}
|
|
50
50
|
get url() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.
|
|
1
|
+
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.77e89680.mjs';
|
|
2
2
|
import { WSError } from '../index.mjs';
|
|
3
3
|
|
|
4
4
|
const cloudflare = defineWebSocketAdapter(
|
|
@@ -42,7 +42,7 @@ const cloudflare = defineWebSocketAdapter(
|
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
44
|
class CloudflarePeer extends Peer {
|
|
45
|
-
get
|
|
45
|
+
get addr() {
|
|
46
46
|
return void 0;
|
|
47
47
|
}
|
|
48
48
|
get url() {
|
package/dist/adapters/deno.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types = require('../shared/crossws.
|
|
3
|
+
const types = require('../shared/crossws.36b9e66f.cjs');
|
|
4
4
|
const index = require('../index.cjs');
|
|
5
5
|
|
|
6
6
|
const deno = types.defineWebSocketAdapter(
|
|
@@ -42,7 +42,7 @@ const deno = types.defineWebSocketAdapter(
|
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
44
|
class DenoPeer extends types.Peer {
|
|
45
|
-
get
|
|
45
|
+
get addr() {
|
|
46
46
|
return this.ctx.deno.ws.remoteAddress;
|
|
47
47
|
}
|
|
48
48
|
get readyState() {
|
package/dist/adapters/deno.d.cts
CHANGED
package/dist/adapters/deno.d.mts
CHANGED
package/dist/adapters/deno.d.ts
CHANGED
package/dist/adapters/deno.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.
|
|
1
|
+
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.77e89680.mjs';
|
|
2
2
|
import { WSError } from '../index.mjs';
|
|
3
3
|
|
|
4
4
|
const deno = defineWebSocketAdapter(
|
|
@@ -40,7 +40,7 @@ const deno = defineWebSocketAdapter(
|
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
42
|
class DenoPeer extends Peer {
|
|
43
|
-
get
|
|
43
|
+
get addr() {
|
|
44
44
|
return this.ctx.deno.ws.remoteAddress;
|
|
45
45
|
}
|
|
46
46
|
get readyState() {
|
package/dist/adapters/node.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const websocket = require('../shared/crossws.2ed26345.cjs');
|
|
|
5
5
|
const require$$0 = require('events');
|
|
6
6
|
const require$$2 = require('http');
|
|
7
7
|
const require$$1 = require('crypto');
|
|
8
|
-
const types = require('../shared/crossws.
|
|
8
|
+
const types = require('../shared/crossws.36b9e66f.cjs');
|
|
9
9
|
const index = require('../index.cjs');
|
|
10
10
|
require('https');
|
|
11
11
|
require('net');
|
|
@@ -691,13 +691,22 @@ const node = types.defineWebSocketAdapter(
|
|
|
691
691
|
}
|
|
692
692
|
);
|
|
693
693
|
class NodePeer extends types.Peer {
|
|
694
|
-
|
|
694
|
+
constructor(ctx) {
|
|
695
|
+
super(ctx);
|
|
696
|
+
ctx.node.ws._peer = this;
|
|
697
|
+
}
|
|
698
|
+
get addr() {
|
|
695
699
|
const socket = this.ctx.node.req.socket;
|
|
696
700
|
if (!socket) {
|
|
697
701
|
return void 0;
|
|
698
702
|
}
|
|
699
|
-
const
|
|
700
|
-
|
|
703
|
+
const headers = this.ctx.node.req.headers;
|
|
704
|
+
let addr = headers["x-forwarded-for"] || socket.remoteAddress || "??";
|
|
705
|
+
if (addr.includes(":")) {
|
|
706
|
+
addr = `[${addr}]`;
|
|
707
|
+
}
|
|
708
|
+
const port = headers["x-forwarded-port"] || socket.remotePort || "??";
|
|
709
|
+
return `${addr}:${port}`;
|
|
701
710
|
}
|
|
702
711
|
get url() {
|
|
703
712
|
return this.ctx.node.req.url || "/";
|
|
@@ -716,6 +725,15 @@ class NodePeer extends types.Peer {
|
|
|
716
725
|
});
|
|
717
726
|
return 0;
|
|
718
727
|
}
|
|
728
|
+
publish(topic, message) {
|
|
729
|
+
message = types.toBufferLike(message);
|
|
730
|
+
for (const client of this.ctx.node.server.clients) {
|
|
731
|
+
const peer = client._peer;
|
|
732
|
+
if (peer && peer !== this && peer._subscriptions.has(topic)) {
|
|
733
|
+
peer.send(message);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
719
737
|
}
|
|
720
738
|
|
|
721
739
|
module.exports = node;
|
package/dist/adapters/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.381454fe.cjs';
|
|
2
2
|
import { IncomingMessage as IncomingMessage$1 } from 'node:http';
|
|
3
3
|
import { Duplex as Duplex$1 } from 'node:stream';
|
|
4
4
|
import { EventEmitter } from 'events';
|
package/dist/adapters/node.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.381454fe.mjs';
|
|
2
2
|
import { IncomingMessage as IncomingMessage$1 } from 'node:http';
|
|
3
3
|
import { Duplex as Duplex$1 } from 'node:stream';
|
|
4
4
|
import { EventEmitter } from 'events';
|
package/dist/adapters/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.381454fe.js';
|
|
2
2
|
import { IncomingMessage as IncomingMessage$1 } from 'node:http';
|
|
3
3
|
import { Duplex as Duplex$1 } from 'node:stream';
|
|
4
4
|
import { EventEmitter } from 'events';
|
package/dist/adapters/node.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { v as validationExports, g as getDefaultExportFromCjs, e as extension$1,
|
|
|
3
3
|
import require$$0 from 'events';
|
|
4
4
|
import require$$2 from 'http';
|
|
5
5
|
import require$$1 from 'crypto';
|
|
6
|
-
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.
|
|
6
|
+
import { d as defineWebSocketAdapter, M as Message, P as Peer, t as toBufferLike, c as createCrossWS } from '../shared/crossws.77e89680.mjs';
|
|
7
7
|
import { WSError } from '../index.mjs';
|
|
8
8
|
import 'https';
|
|
9
9
|
import 'net';
|
|
@@ -683,13 +683,22 @@ const node = defineWebSocketAdapter(
|
|
|
683
683
|
}
|
|
684
684
|
);
|
|
685
685
|
class NodePeer extends Peer {
|
|
686
|
-
|
|
686
|
+
constructor(ctx) {
|
|
687
|
+
super(ctx);
|
|
688
|
+
ctx.node.ws._peer = this;
|
|
689
|
+
}
|
|
690
|
+
get addr() {
|
|
687
691
|
const socket = this.ctx.node.req.socket;
|
|
688
692
|
if (!socket) {
|
|
689
693
|
return void 0;
|
|
690
694
|
}
|
|
691
|
-
const
|
|
692
|
-
|
|
695
|
+
const headers = this.ctx.node.req.headers;
|
|
696
|
+
let addr = headers["x-forwarded-for"] || socket.remoteAddress || "??";
|
|
697
|
+
if (addr.includes(":")) {
|
|
698
|
+
addr = `[${addr}]`;
|
|
699
|
+
}
|
|
700
|
+
const port = headers["x-forwarded-port"] || socket.remotePort || "??";
|
|
701
|
+
return `${addr}:${port}`;
|
|
693
702
|
}
|
|
694
703
|
get url() {
|
|
695
704
|
return this.ctx.node.req.url || "/";
|
|
@@ -708,6 +717,15 @@ class NodePeer extends Peer {
|
|
|
708
717
|
});
|
|
709
718
|
return 0;
|
|
710
719
|
}
|
|
720
|
+
publish(topic, message) {
|
|
721
|
+
message = toBufferLike(message);
|
|
722
|
+
for (const client of this.ctx.node.server.clients) {
|
|
723
|
+
const peer = client._peer;
|
|
724
|
+
if (peer && peer !== this && peer._subscriptions.has(topic)) {
|
|
725
|
+
peer.send(message);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
711
729
|
}
|
|
712
730
|
|
|
713
731
|
export { node as default };
|
package/dist/adapters/uws.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types = require('../shared/crossws.
|
|
3
|
+
const types = require('../shared/crossws.36b9e66f.cjs');
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -107,7 +107,7 @@ class UWSPeer extends types.Peer {
|
|
|
107
107
|
__publicField(this, "_headers");
|
|
108
108
|
__publicField(this, "_decoder", new TextDecoder());
|
|
109
109
|
}
|
|
110
|
-
get
|
|
110
|
+
get addr() {
|
|
111
111
|
try {
|
|
112
112
|
const addr = this._decoder.decode(
|
|
113
113
|
this.ctx.uws.ws?.getRemoteAddressAsText()
|
package/dist/adapters/uws.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.381454fe.cjs';
|
|
2
2
|
import { WebSocketBehavior, HttpRequest, HttpResponse } from 'uWebSockets.js';
|
|
3
3
|
|
|
4
4
|
type UserData = {
|
package/dist/adapters/uws.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, b as Adapter } from '../shared/crossws.381454fe.mjs';
|
|
2
2
|
import { WebSocketBehavior, HttpRequest, HttpResponse } from 'uWebSockets.js';
|
|
3
3
|
|
|
4
4
|
type UserData = {
|
package/dist/adapters/uws.d.ts
CHANGED
package/dist/adapters/uws.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineWebSocketAdapter, c as createCrossWS, M as Message, P as Peer, t as toBufferLike } from '../shared/crossws.
|
|
1
|
+
import { d as defineWebSocketAdapter, c as createCrossWS, M as Message, P as Peer, t as toBufferLike } from '../shared/crossws.77e89680.mjs';
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -105,7 +105,7 @@ class UWSPeer extends Peer {
|
|
|
105
105
|
__publicField(this, "_headers");
|
|
106
106
|
__publicField(this, "_decoder", new TextDecoder());
|
|
107
107
|
}
|
|
108
|
-
get
|
|
108
|
+
get addr() {
|
|
109
109
|
try {
|
|
110
110
|
const addr = this._decoder.decode(
|
|
111
111
|
this.ctx.uws.ws?.getRemoteAddressAsText()
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.
|
|
2
|
-
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.381454fe.cjs';
|
|
2
|
+
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.381454fe.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createCrossWS(opts?: AdapterOptions): CrossWS;
|
|
5
5
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.
|
|
2
|
-
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.381454fe.mjs';
|
|
2
|
+
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.381454fe.mjs';
|
|
3
3
|
|
|
4
4
|
declare function createCrossWS(opts?: AdapterOptions): CrossWS;
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.
|
|
2
|
-
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.
|
|
1
|
+
import { A as AdapterOptions, C as CrossWS } from './shared/crossws.381454fe.js';
|
|
2
|
+
export { b as Adapter, f as AdapterHooks, a as Caller, H as Hooks, M as Message, P as Peer, R as ResolveHooks, W as WSError, c as WSRequest, e as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.381454fe.js';
|
|
3
3
|
|
|
4
4
|
declare function createCrossWS(opts?: AdapterOptions): CrossWS;
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as Message, P as Peer, c as createCrossWS, a as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.
|
|
1
|
+
export { M as Message, P as Peer, c as createCrossWS, a as defineHooks, d as defineWebSocketAdapter } from './shared/crossws.77e89680.mjs';
|
|
2
2
|
|
|
3
3
|
class WSError extends Error {
|
|
4
4
|
constructor(...args) {
|
|
@@ -98,13 +98,18 @@ const ReadyStateMap = {
|
|
|
98
98
|
2: "closing",
|
|
99
99
|
3: "closed"
|
|
100
100
|
};
|
|
101
|
-
class
|
|
101
|
+
const _Peer = class _Peer {
|
|
102
102
|
constructor(ctx) {
|
|
103
103
|
this.ctx = ctx;
|
|
104
104
|
__publicField(this, "_subscriptions", /* @__PURE__ */ new Set());
|
|
105
|
+
__publicField(this, "_id");
|
|
106
|
+
this._id = ++_Peer._idCounter + "";
|
|
105
107
|
}
|
|
106
108
|
get id() {
|
|
107
|
-
return
|
|
109
|
+
return this._id.toString();
|
|
110
|
+
}
|
|
111
|
+
get addr() {
|
|
112
|
+
return void 0;
|
|
108
113
|
}
|
|
109
114
|
get url() {
|
|
110
115
|
return "/";
|
|
@@ -124,12 +129,17 @@ class Peer {
|
|
|
124
129
|
this._subscriptions.delete(topic);
|
|
125
130
|
}
|
|
126
131
|
toString() {
|
|
127
|
-
return
|
|
132
|
+
return `#${this.id}`;
|
|
128
133
|
}
|
|
129
134
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
130
|
-
|
|
135
|
+
const _id = this.toString();
|
|
136
|
+
const _addr = this.addr ? ` (${this.addr})` : "";
|
|
137
|
+
const _state = this.readyState === 1 || this.readyState === -1 ? "" : ` [${ReadyStateMap[this.readyState]}]`;
|
|
138
|
+
return `${_id}${_addr}${_state}`;
|
|
131
139
|
}
|
|
132
|
-
}
|
|
140
|
+
};
|
|
141
|
+
__publicField(_Peer, "_idCounter", 0);
|
|
142
|
+
let Peer = _Peer;
|
|
133
143
|
|
|
134
144
|
function defineWebSocketAdapter(factory) {
|
|
135
145
|
return factory;
|
|
@@ -14,8 +14,11 @@ type ReadyState = 0 | 1 | 2 | 3;
|
|
|
14
14
|
declare abstract class Peer<AdapterContext = any> implements WSRequest {
|
|
15
15
|
ctx: AdapterContext;
|
|
16
16
|
_subscriptions: Set<string>;
|
|
17
|
+
static _idCounter: number;
|
|
18
|
+
private _id;
|
|
17
19
|
constructor(ctx: AdapterContext);
|
|
18
|
-
get id(): string
|
|
20
|
+
get id(): string;
|
|
21
|
+
get addr(): string | undefined;
|
|
19
22
|
get url(): string;
|
|
20
23
|
get headers(): HeadersInit;
|
|
21
24
|
get readyState(): ReadyState | -1;
|
|
@@ -14,8 +14,11 @@ type ReadyState = 0 | 1 | 2 | 3;
|
|
|
14
14
|
declare abstract class Peer<AdapterContext = any> implements WSRequest {
|
|
15
15
|
ctx: AdapterContext;
|
|
16
16
|
_subscriptions: Set<string>;
|
|
17
|
+
static _idCounter: number;
|
|
18
|
+
private _id;
|
|
17
19
|
constructor(ctx: AdapterContext);
|
|
18
|
-
get id(): string
|
|
20
|
+
get id(): string;
|
|
21
|
+
get addr(): string | undefined;
|
|
19
22
|
get url(): string;
|
|
20
23
|
get headers(): HeadersInit;
|
|
21
24
|
get readyState(): ReadyState | -1;
|
|
@@ -14,8 +14,11 @@ type ReadyState = 0 | 1 | 2 | 3;
|
|
|
14
14
|
declare abstract class Peer<AdapterContext = any> implements WSRequest {
|
|
15
15
|
ctx: AdapterContext;
|
|
16
16
|
_subscriptions: Set<string>;
|
|
17
|
+
static _idCounter: number;
|
|
18
|
+
private _id;
|
|
17
19
|
constructor(ctx: AdapterContext);
|
|
18
|
-
get id(): string
|
|
20
|
+
get id(): string;
|
|
21
|
+
get addr(): string | undefined;
|
|
19
22
|
get url(): string;
|
|
20
23
|
get headers(): HeadersInit;
|
|
21
24
|
get readyState(): ReadyState | -1;
|
|
@@ -96,13 +96,18 @@ const ReadyStateMap = {
|
|
|
96
96
|
2: "closing",
|
|
97
97
|
3: "closed"
|
|
98
98
|
};
|
|
99
|
-
class
|
|
99
|
+
const _Peer = class _Peer {
|
|
100
100
|
constructor(ctx) {
|
|
101
101
|
this.ctx = ctx;
|
|
102
102
|
__publicField(this, "_subscriptions", /* @__PURE__ */ new Set());
|
|
103
|
+
__publicField(this, "_id");
|
|
104
|
+
this._id = ++_Peer._idCounter + "";
|
|
103
105
|
}
|
|
104
106
|
get id() {
|
|
105
|
-
return
|
|
107
|
+
return this._id.toString();
|
|
108
|
+
}
|
|
109
|
+
get addr() {
|
|
110
|
+
return void 0;
|
|
106
111
|
}
|
|
107
112
|
get url() {
|
|
108
113
|
return "/";
|
|
@@ -122,12 +127,17 @@ class Peer {
|
|
|
122
127
|
this._subscriptions.delete(topic);
|
|
123
128
|
}
|
|
124
129
|
toString() {
|
|
125
|
-
return
|
|
130
|
+
return `#${this.id}`;
|
|
126
131
|
}
|
|
127
132
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
128
|
-
|
|
133
|
+
const _id = this.toString();
|
|
134
|
+
const _addr = this.addr ? ` (${this.addr})` : "";
|
|
135
|
+
const _state = this.readyState === 1 || this.readyState === -1 ? "" : ` [${ReadyStateMap[this.readyState]}]`;
|
|
136
|
+
return `${_id}${_addr}${_state}`;
|
|
129
137
|
}
|
|
130
|
-
}
|
|
138
|
+
};
|
|
139
|
+
__publicField(_Peer, "_idCounter", 0);
|
|
140
|
+
let Peer = _Peer;
|
|
131
141
|
|
|
132
142
|
function defineWebSocketAdapter(factory) {
|
|
133
143
|
return factory;
|