larasopp 1.2.17 → 1.2.19
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/lib/Core.d.ts +2 -2
- package/lib/Listener.d.ts +7 -2
- package/lib/Listener.js +28 -0
- package/lib/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/Core.ts +2 -4
- package/src/Listener.ts +35 -2
- package/src/index.ts +1 -1
package/lib/Core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import EventEmitter from "easy-event-emitter";
|
|
2
2
|
import type { IConfig, TMessage } from "./types";
|
|
3
3
|
declare abstract class Core {
|
|
4
|
-
readonly events:
|
|
4
|
+
readonly events: EventEmitter;
|
|
5
5
|
private ws?;
|
|
6
6
|
private _socketId?;
|
|
7
7
|
private config;
|
package/lib/Listener.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EventListener } from "easy-event-emitter";
|
|
2
2
|
import type Larasopp from ".";
|
|
3
|
-
declare class Listener implements EventListener {
|
|
3
|
+
declare class Listener implements Omit<EventListener, 'events'> {
|
|
4
4
|
private readonly context;
|
|
5
5
|
private channel;
|
|
6
6
|
private listeners?;
|
|
7
7
|
private listener?;
|
|
8
8
|
private cacheEvents;
|
|
9
9
|
constructor(channel: string, constext: Larasopp);
|
|
10
|
+
get name(): string;
|
|
11
|
+
pushListener(object: EventListener<any, string | number | symbol, any>): void;
|
|
12
|
+
hasHandler(handler: (data: any) => void): boolean;
|
|
13
|
+
onEmit(handlerEmit: () => void): void;
|
|
14
|
+
onRemove(handlerRemove: () => void): void;
|
|
10
15
|
listen(event: string, callback: (data: any) => void, withCache?: boolean): this;
|
|
11
16
|
here(callback: (data: any) => void, withCache?: boolean): this;
|
|
12
17
|
joining(callback: (data: any) => void, withCache?: boolean): this;
|
package/lib/Listener.js
CHANGED
|
@@ -37,6 +37,34 @@ class Listener {
|
|
|
37
37
|
this.cacheEvents = {};
|
|
38
38
|
this.here(() => { }, true);
|
|
39
39
|
}
|
|
40
|
+
get name() {
|
|
41
|
+
return '__ws-event';
|
|
42
|
+
}
|
|
43
|
+
pushListener(object) { }
|
|
44
|
+
hasHandler(handler) {
|
|
45
|
+
if (this.listeners) {
|
|
46
|
+
for (const listener of this.listeners) {
|
|
47
|
+
if (listener.hasHandler(handler)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
onEmit(handlerEmit) {
|
|
55
|
+
if (this.listeners) {
|
|
56
|
+
for (const listener of this.listeners) {
|
|
57
|
+
listener.onEmit(handlerEmit);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
onRemove(handlerRemove) {
|
|
62
|
+
if (this.listeners) {
|
|
63
|
+
for (const listener of this.listeners) {
|
|
64
|
+
listener.onRemove(handlerRemove);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
40
68
|
listen(event, callback, withCache = false) {
|
|
41
69
|
if (!this.listeners) {
|
|
42
70
|
this.listeners = [];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EventListener } from "easy-event-emitter";
|
|
2
2
|
import Core from "./Core";
|
|
3
3
|
import Listener from "./Listener";
|
|
4
4
|
import type { IConfig, TPermissions, TSocketEvents, TListenerCallback } from "./types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "larasopp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"description": "Websocket client for laravel",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"typescript": "^5.1.6"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"easy-event-emitter": "^1.
|
|
40
|
+
"easy-event-emitter": "^1.1.2"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/Core.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import EventEmitter
|
|
2
|
-
type Events
|
|
3
|
-
} from "easy-event-emitter";
|
|
1
|
+
import EventEmitter from "easy-event-emitter";
|
|
4
2
|
import { ListenerEvents } from "./constants";
|
|
5
3
|
import type {
|
|
6
4
|
IConfig,
|
|
@@ -9,7 +7,7 @@ import type {
|
|
|
9
7
|
} from "./types";
|
|
10
8
|
|
|
11
9
|
abstract class Core {
|
|
12
|
-
public readonly events:
|
|
10
|
+
public readonly events: EventEmitter;
|
|
13
11
|
private ws?: WebSocket;
|
|
14
12
|
private _socketId?: string;
|
|
15
13
|
private config: IConfig;
|
package/src/Listener.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type
|
|
2
|
+
type EventListener
|
|
3
3
|
} from "easy-event-emitter";
|
|
4
4
|
import type Larasopp from ".";
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ type TListenerCacheEvents = {
|
|
|
7
7
|
[event: string]: unknown;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
class Listener implements EventListener {
|
|
10
|
+
class Listener implements Omit<EventListener, 'events'> {
|
|
11
11
|
private readonly context: Larasopp;
|
|
12
12
|
private channel: string;
|
|
13
13
|
private listeners?: EventListener[];
|
|
@@ -22,6 +22,39 @@ class Listener implements EventListener {
|
|
|
22
22
|
this.here(()=>{}, true);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
public get name() {
|
|
26
|
+
return '__ws-event';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public pushListener(object: EventListener<any, string | number | symbol, any>): void {}
|
|
30
|
+
|
|
31
|
+
public hasHandler(handler: (data: any) => void) {
|
|
32
|
+
if (this.listeners) {
|
|
33
|
+
for (const listener of this.listeners) {
|
|
34
|
+
if (listener.hasHandler(handler)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public onEmit(handlerEmit: () => void) {
|
|
43
|
+
if (this.listeners) {
|
|
44
|
+
for (const listener of this.listeners) {
|
|
45
|
+
listener.onEmit(handlerEmit);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public onRemove(handlerRemove: () => void) {
|
|
51
|
+
if (this.listeners) {
|
|
52
|
+
for (const listener of this.listeners) {
|
|
53
|
+
listener.onRemove(handlerRemove);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
25
58
|
public listen(event: string, callback: (data: any) => void, withCache = false) {
|
|
26
59
|
if (!this.listeners) {
|
|
27
60
|
this.listeners = [];
|
package/src/index.ts
CHANGED