reverb-ws-client 1.0.3 → 1.0.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/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -21
- package/dist/index.mjs +28 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,7 @@ declare class Channel {
|
|
|
29
29
|
private client;
|
|
30
30
|
private listeners;
|
|
31
31
|
private subscribed;
|
|
32
|
+
private logger;
|
|
32
33
|
constructor(name: string, client: ReverbClient);
|
|
33
34
|
subscribe(): Promise<void>;
|
|
34
35
|
listen(event: string, callback: EventCallback): this;
|
|
@@ -50,6 +51,7 @@ declare class ReverbClient {
|
|
|
50
51
|
presence(name: string): Channel;
|
|
51
52
|
send(data: PusherOutgoingMessage | object): void;
|
|
52
53
|
getSocketId(): string | null;
|
|
54
|
+
getOptions(): ReverbClientOptions;
|
|
53
55
|
authorize(socketId: string, channelName: string): Promise<AuthResponse>;
|
|
54
56
|
private getChannel;
|
|
55
57
|
private handleMessage;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare class Channel {
|
|
|
29
29
|
private client;
|
|
30
30
|
private listeners;
|
|
31
31
|
private subscribed;
|
|
32
|
+
private logger;
|
|
32
33
|
constructor(name: string, client: ReverbClient);
|
|
33
34
|
subscribe(): Promise<void>;
|
|
34
35
|
listen(event: string, callback: EventCallback): this;
|
|
@@ -50,6 +51,7 @@ declare class ReverbClient {
|
|
|
50
51
|
presence(name: string): Channel;
|
|
51
52
|
send(data: PusherOutgoingMessage | object): void;
|
|
52
53
|
getSocketId(): string | null;
|
|
54
|
+
getOptions(): ReverbClientOptions;
|
|
53
55
|
authorize(socketId: string, channelName: string): Promise<AuthResponse>;
|
|
54
56
|
private getChannel;
|
|
55
57
|
private handleMessage;
|
package/dist/index.js
CHANGED
|
@@ -24,16 +24,40 @@ __export(index_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
|
|
27
|
+
// src/logger.ts
|
|
28
|
+
var Logger = class {
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
}
|
|
32
|
+
options;
|
|
33
|
+
log(...args) {
|
|
34
|
+
if (!this.options.debug) return;
|
|
35
|
+
console.log(...args);
|
|
36
|
+
}
|
|
37
|
+
warn(...args) {
|
|
38
|
+
if (!this.options.debug) return;
|
|
39
|
+
console.warn(...args);
|
|
40
|
+
}
|
|
41
|
+
error(...args) {
|
|
42
|
+
if (!this.options.debug) return;
|
|
43
|
+
console.error(...args);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
27
47
|
// src/Channel.ts
|
|
28
48
|
var Channel = class {
|
|
29
49
|
constructor(name, client) {
|
|
30
50
|
this.name = name;
|
|
31
51
|
this.client = client;
|
|
52
|
+
this.logger = new Logger({
|
|
53
|
+
debug: this.client.getOptions().debug ?? false
|
|
54
|
+
});
|
|
32
55
|
}
|
|
33
56
|
name;
|
|
34
57
|
client;
|
|
35
58
|
listeners = /* @__PURE__ */ new Map();
|
|
36
59
|
subscribed = false;
|
|
60
|
+
logger;
|
|
37
61
|
async subscribe() {
|
|
38
62
|
if (this.subscribed) return;
|
|
39
63
|
const isPrivate = this.name.startsWith("private-");
|
|
@@ -65,7 +89,7 @@ var Channel = class {
|
|
|
65
89
|
}
|
|
66
90
|
this.listeners.get(event).add(callback);
|
|
67
91
|
this.subscribe().catch((err) => {
|
|
68
|
-
|
|
92
|
+
this.logger.error("[Reverb] subscribe failed", err);
|
|
69
93
|
});
|
|
70
94
|
return this;
|
|
71
95
|
}
|
|
@@ -96,26 +120,6 @@ var Channel = class {
|
|
|
96
120
|
}
|
|
97
121
|
};
|
|
98
122
|
|
|
99
|
-
// src/logger.ts
|
|
100
|
-
var Logger = class {
|
|
101
|
-
constructor(options = {}) {
|
|
102
|
-
this.options = options;
|
|
103
|
-
}
|
|
104
|
-
options;
|
|
105
|
-
log(...args) {
|
|
106
|
-
if (!this.options.debug) return;
|
|
107
|
-
console.log(...args);
|
|
108
|
-
}
|
|
109
|
-
warn(...args) {
|
|
110
|
-
if (!this.options.debug) return;
|
|
111
|
-
console.warn(...args);
|
|
112
|
-
}
|
|
113
|
-
error(...args) {
|
|
114
|
-
if (!this.options.debug) return;
|
|
115
|
-
console.error(...args);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
123
|
// src/ConnectionManager.ts
|
|
120
124
|
var ConnectionManager = class {
|
|
121
125
|
constructor(options, onMessage) {
|
|
@@ -236,6 +240,9 @@ var ReverbClient = class {
|
|
|
236
240
|
getSocketId() {
|
|
237
241
|
return this.socketId;
|
|
238
242
|
}
|
|
243
|
+
getOptions() {
|
|
244
|
+
return this.options;
|
|
245
|
+
}
|
|
239
246
|
authorize(socketId, channelName) {
|
|
240
247
|
if (!this.options.authorizer) {
|
|
241
248
|
throw new Error("[Reverb] authorizer is required for private channels");
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
|
+
// src/logger.ts
|
|
2
|
+
var Logger = class {
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
options;
|
|
7
|
+
log(...args) {
|
|
8
|
+
if (!this.options.debug) return;
|
|
9
|
+
console.log(...args);
|
|
10
|
+
}
|
|
11
|
+
warn(...args) {
|
|
12
|
+
if (!this.options.debug) return;
|
|
13
|
+
console.warn(...args);
|
|
14
|
+
}
|
|
15
|
+
error(...args) {
|
|
16
|
+
if (!this.options.debug) return;
|
|
17
|
+
console.error(...args);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
1
21
|
// src/Channel.ts
|
|
2
22
|
var Channel = class {
|
|
3
23
|
constructor(name, client) {
|
|
4
24
|
this.name = name;
|
|
5
25
|
this.client = client;
|
|
26
|
+
this.logger = new Logger({
|
|
27
|
+
debug: this.client.getOptions().debug ?? false
|
|
28
|
+
});
|
|
6
29
|
}
|
|
7
30
|
name;
|
|
8
31
|
client;
|
|
9
32
|
listeners = /* @__PURE__ */ new Map();
|
|
10
33
|
subscribed = false;
|
|
34
|
+
logger;
|
|
11
35
|
async subscribe() {
|
|
12
36
|
if (this.subscribed) return;
|
|
13
37
|
const isPrivate = this.name.startsWith("private-");
|
|
@@ -39,7 +63,7 @@ var Channel = class {
|
|
|
39
63
|
}
|
|
40
64
|
this.listeners.get(event).add(callback);
|
|
41
65
|
this.subscribe().catch((err) => {
|
|
42
|
-
|
|
66
|
+
this.logger.error("[Reverb] subscribe failed", err);
|
|
43
67
|
});
|
|
44
68
|
return this;
|
|
45
69
|
}
|
|
@@ -70,26 +94,6 @@ var Channel = class {
|
|
|
70
94
|
}
|
|
71
95
|
};
|
|
72
96
|
|
|
73
|
-
// src/logger.ts
|
|
74
|
-
var Logger = class {
|
|
75
|
-
constructor(options = {}) {
|
|
76
|
-
this.options = options;
|
|
77
|
-
}
|
|
78
|
-
options;
|
|
79
|
-
log(...args) {
|
|
80
|
-
if (!this.options.debug) return;
|
|
81
|
-
console.log(...args);
|
|
82
|
-
}
|
|
83
|
-
warn(...args) {
|
|
84
|
-
if (!this.options.debug) return;
|
|
85
|
-
console.warn(...args);
|
|
86
|
-
}
|
|
87
|
-
error(...args) {
|
|
88
|
-
if (!this.options.debug) return;
|
|
89
|
-
console.error(...args);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
97
|
// src/ConnectionManager.ts
|
|
94
98
|
var ConnectionManager = class {
|
|
95
99
|
constructor(options, onMessage) {
|
|
@@ -210,6 +214,9 @@ var ReverbClient = class {
|
|
|
210
214
|
getSocketId() {
|
|
211
215
|
return this.socketId;
|
|
212
216
|
}
|
|
217
|
+
getOptions() {
|
|
218
|
+
return this.options;
|
|
219
|
+
}
|
|
213
220
|
authorize(socketId, channelName) {
|
|
214
221
|
if (!this.options.authorizer) {
|
|
215
222
|
throw new Error("[Reverb] authorizer is required for private channels");
|