laravel-echo-api-gateway 0.5.8 → 0.5.9
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/.eslintrc.js +1 -0
- package/.github/workflows/ci.yml +49 -45
- package/README.md +93 -17
- package/dist/Channel.d.ts +89 -0
- package/dist/Connector.d.ts +92 -0
- package/dist/EventFormatter.d.ts +10 -0
- package/dist/Websocket.d.ts +78 -0
- package/dist/laravel-echo-api-gateway.common.js +403 -762
- package/dist/laravel-echo-api-gateway.iife.js +487 -846
- package/dist/laravel-echo-api-gateway.js +401 -760
- package/jest.config.js +3 -7
- package/js-src/Channel.ts +74 -62
- package/js-src/Connector.ts +100 -40
- package/js-src/EventFormatter.ts +24 -0
- package/js-src/Websocket.ts +217 -168
- package/js-tests/Connector.test.ts +295 -60
- package/js-tests/EchoCompatibility.test.ts +96 -0
- package/js-tests/helpers.ts +37 -0
- package/package.json +23 -30
- package/phpstan.neon.dist +3 -12
- package/phpunit.xml +2 -2
- package/rollup.config.mjs +14 -0
- package/tsconfig.json +6 -6
- package/dist/js-src/Channel.d.ts +0 -68
- package/dist/js-src/Connector.d.ts +0 -49
- package/dist/js-src/Websocket.d.ts +0 -38
- package/rollup.config.js +0 -31
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import typescript from '@rollup/plugin-typescript';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
input: './js-src/Connector.ts',
|
|
5
|
+
output: [
|
|
6
|
+
{ file: './dist/laravel-echo-api-gateway.js', format: 'esm' },
|
|
7
|
+
{ file: './dist/laravel-echo-api-gateway.common.js', format: 'cjs', exports: 'named' },
|
|
8
|
+
{ file: './dist/laravel-echo-api-gateway.iife.js', format: 'iife', name: 'LaravelEchoApiGateway', exports: 'named' },
|
|
9
|
+
],
|
|
10
|
+
plugins: [
|
|
11
|
+
// Declarations are emitted by `npm run declarations`.
|
|
12
|
+
typescript({ tsconfig: './tsconfig.json', declaration: false, declarationDir: undefined, outDir: undefined }),
|
|
13
|
+
],
|
|
14
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"declaration": true,
|
|
4
|
-
"
|
|
4
|
+
"declarationDir": "./dist",
|
|
5
|
+
"module": "es2015",
|
|
5
6
|
"moduleResolution": "node",
|
|
6
7
|
"outDir": "./dist",
|
|
7
8
|
"sourceMap": false,
|
|
8
|
-
"target": "
|
|
9
|
-
"
|
|
9
|
+
"target": "es2017",
|
|
10
|
+
"strict": false,
|
|
10
11
|
"esModuleInterop": true,
|
|
11
|
-
"
|
|
12
|
+
"skipLibCheck": true,
|
|
12
13
|
"typeRoots": [
|
|
13
14
|
"node_modules/@types"
|
|
14
15
|
],
|
|
@@ -19,7 +20,6 @@
|
|
|
19
20
|
},
|
|
20
21
|
"include": [
|
|
21
22
|
"./typings/",
|
|
22
|
-
"./js-src/"
|
|
23
|
-
"./node_modules/laravel-echo/src/"
|
|
23
|
+
"./js-src/"
|
|
24
24
|
]
|
|
25
25
|
}
|
package/dist/js-src/Channel.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { EventFormatter } from 'laravel-echo/src/util';
|
|
2
|
-
import { Channel as BaseChannel } from 'laravel-echo/src/channel/channel';
|
|
3
|
-
import { PresenceChannel } from "laravel-echo/src/channel";
|
|
4
|
-
import { Websocket } from "./Websocket";
|
|
5
|
-
/**
|
|
6
|
-
* This class represents a Pusher channel.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Channel extends BaseChannel implements PresenceChannel {
|
|
9
|
-
/**
|
|
10
|
-
* The Pusher client instance.
|
|
11
|
-
*/
|
|
12
|
-
socket: Websocket;
|
|
13
|
-
/**
|
|
14
|
-
* The name of the channel.
|
|
15
|
-
*/
|
|
16
|
-
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* Channel options.
|
|
19
|
-
*/
|
|
20
|
-
options: object;
|
|
21
|
-
/**
|
|
22
|
-
* The event formatter.
|
|
23
|
-
*/
|
|
24
|
-
eventFormatter: EventFormatter;
|
|
25
|
-
/**
|
|
26
|
-
* Create a new class instance.
|
|
27
|
-
*/
|
|
28
|
-
constructor(socket: Websocket, name: string, options: object);
|
|
29
|
-
/**
|
|
30
|
-
* Subscribe to a Pusher channel.
|
|
31
|
-
*/
|
|
32
|
-
subscribe(): any;
|
|
33
|
-
/**
|
|
34
|
-
* Unsubscribe from a Pusher channel.
|
|
35
|
-
*/
|
|
36
|
-
unsubscribe(): void;
|
|
37
|
-
/**
|
|
38
|
-
* Listen for an event on the channel instance.
|
|
39
|
-
*/
|
|
40
|
-
listen(event: string, callback: Function): this;
|
|
41
|
-
/**
|
|
42
|
-
* Stop listening for an event on the channel instance.
|
|
43
|
-
*/
|
|
44
|
-
stopListening(event: string, callback?: Function): this;
|
|
45
|
-
/**
|
|
46
|
-
* Register a callback to be called anytime a subscription succeeds.
|
|
47
|
-
*/
|
|
48
|
-
subscribed(callback: Function): this;
|
|
49
|
-
/**
|
|
50
|
-
* Register a callback to be called anytime a subscription error occurs.
|
|
51
|
-
*/
|
|
52
|
-
error(callback: Function): this;
|
|
53
|
-
/**
|
|
54
|
-
* Bind a channel to an event.
|
|
55
|
-
*/
|
|
56
|
-
on(event: string, callback: Function): Channel;
|
|
57
|
-
whisper(event: string, data: object): this;
|
|
58
|
-
here(callback: Function): this;
|
|
59
|
-
/**
|
|
60
|
-
* Listen for someone joining the channel.
|
|
61
|
-
*/
|
|
62
|
-
joining(callback: Function): this;
|
|
63
|
-
/**
|
|
64
|
-
* Listen for someone leaving the channel.
|
|
65
|
-
*/
|
|
66
|
-
leaving(callback: Function): this;
|
|
67
|
-
}
|
|
68
|
-
export { PresenceChannel };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Connector as BaseConnector } from "laravel-echo/src/connector/connector";
|
|
2
|
-
import { Websocket } from "./Websocket";
|
|
3
|
-
import { Channel } from "./Channel";
|
|
4
|
-
export declare const broadcaster: (options: object) => Connector;
|
|
5
|
-
export declare class Connector extends BaseConnector {
|
|
6
|
-
socket: Websocket;
|
|
7
|
-
/**
|
|
8
|
-
* All of the subscribed channel names.
|
|
9
|
-
*/
|
|
10
|
-
channels: {
|
|
11
|
-
[name: string]: Channel;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Create a new class instance.
|
|
15
|
-
*/
|
|
16
|
-
constructor(options: any);
|
|
17
|
-
/**
|
|
18
|
-
* Create a fresh Socket.io connection.
|
|
19
|
-
*/
|
|
20
|
-
connect(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Get a channel instance by name.
|
|
23
|
-
*/
|
|
24
|
-
channel(name: string): Channel;
|
|
25
|
-
/**
|
|
26
|
-
* Get a private channel instance by name.
|
|
27
|
-
*/
|
|
28
|
-
privateChannel(name: string): Channel;
|
|
29
|
-
/**
|
|
30
|
-
* Get a presence channel instance by name.
|
|
31
|
-
*/
|
|
32
|
-
presenceChannel(name: string): Channel;
|
|
33
|
-
/**
|
|
34
|
-
* Leave the given channel, as well as its private and presence variants.
|
|
35
|
-
*/
|
|
36
|
-
leave(name: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Leave the given channel.
|
|
39
|
-
*/
|
|
40
|
-
leaveChannel(name: string): void;
|
|
41
|
-
/**
|
|
42
|
-
* Get the socket ID for the connection.
|
|
43
|
-
*/
|
|
44
|
-
socketId(): string;
|
|
45
|
-
/**
|
|
46
|
-
* Disconnect socket connection.
|
|
47
|
-
*/
|
|
48
|
-
disconnect(): void;
|
|
49
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Channel } from "./Channel";
|
|
2
|
-
export type Options = {
|
|
3
|
-
authEndpoint: string;
|
|
4
|
-
host: string;
|
|
5
|
-
bearerToken: string;
|
|
6
|
-
auth: any;
|
|
7
|
-
debug: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type MessageBody = {
|
|
10
|
-
event: string;
|
|
11
|
-
channel?: string;
|
|
12
|
-
data: object;
|
|
13
|
-
};
|
|
14
|
-
export declare class Websocket {
|
|
15
|
-
buffer: Array<object>;
|
|
16
|
-
options: Options;
|
|
17
|
-
websocket: WebSocket;
|
|
18
|
-
private listeners;
|
|
19
|
-
private internalListeners;
|
|
20
|
-
private channelBacklog;
|
|
21
|
-
private socketId;
|
|
22
|
-
private closing;
|
|
23
|
-
private hasConnected;
|
|
24
|
-
private pingInterval;
|
|
25
|
-
constructor(options: Options);
|
|
26
|
-
private connect;
|
|
27
|
-
protected parseMessage(body: string): MessageBody;
|
|
28
|
-
getSocketId(): string;
|
|
29
|
-
private socketIsReady;
|
|
30
|
-
send(message: object): void;
|
|
31
|
-
close(): void;
|
|
32
|
-
subscribe(channel: Channel): void;
|
|
33
|
-
private actuallySubscribe;
|
|
34
|
-
unsubscribe(channel: Channel): void;
|
|
35
|
-
on(event: string, callback?: Function): void;
|
|
36
|
-
bind(channel: Channel, event: string, callback: Function): void;
|
|
37
|
-
unbindEvent(channel: Channel, event: string, callback?: Function): void;
|
|
38
|
-
}
|
package/rollup.config.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import babel from '@rollup/plugin-babel';
|
|
2
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
input: './js-src/Connector.ts',
|
|
6
|
-
output: [
|
|
7
|
-
{ file: './dist/laravel-echo-api-gateway.js', format: 'esm' },
|
|
8
|
-
{ file: './dist/laravel-echo-api-gateway.common.js', format: 'cjs' },
|
|
9
|
-
{ file: './dist/laravel-echo-api-gateway.iife.js', format: 'iife', name: 'LaravelEchoApiGateway' },
|
|
10
|
-
],
|
|
11
|
-
plugins: [
|
|
12
|
-
typescript({
|
|
13
|
-
tsconfig: './tsconfig.json', // Chemin explicite vers votre fichier TypeScript
|
|
14
|
-
useTsconfigDeclarationDir: true, // Respecte les options `outDir` et `declarationDir`
|
|
15
|
-
}),
|
|
16
|
-
babel({
|
|
17
|
-
babelHelpers: 'bundled',
|
|
18
|
-
exclude: 'node_modules/**',
|
|
19
|
-
extensions: ['.ts'],
|
|
20
|
-
presets: ['@babel/preset-env'],
|
|
21
|
-
plugins: [
|
|
22
|
-
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
23
|
-
'@babel/plugin-proposal-function-sent',
|
|
24
|
-
'@babel/plugin-proposal-export-namespace-from',
|
|
25
|
-
'@babel/plugin-proposal-numeric-separator',
|
|
26
|
-
'@babel/plugin-proposal-throw-expressions',
|
|
27
|
-
'@babel/plugin-transform-object-assign',
|
|
28
|
-
],
|
|
29
|
-
}),
|
|
30
|
-
],
|
|
31
|
-
};
|