@ngxs/websocket-plugin 3.8.2-dev.master-0fd1fe5 → 3.8.2
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/bundles/ngxs-websocket-plugin.umd.js +786 -0
- package/bundles/ngxs-websocket-plugin.umd.js.map +1 -0
- package/esm2015/src/public_api.js +3 -0
- package/esm2015/src/symbols.js +66 -0
- package/esm2015/src/websocket-handler.js +142 -0
- package/esm2015/src/websocket.module.js +45 -0
- package/fesm2015/ngxs-websocket-plugin.js +258 -0
- package/fesm2015/ngxs-websocket-plugin.js.map +1 -0
- package/ngxs-websocket-plugin.d.ts +5 -0
- package/package.json +11 -23
- package/src/public_api.d.ts +1 -1
- package/src/symbols.d.ts +2 -2
- package/src/websocket-handler.d.ts +27 -13
- package/src/websocket.module.d.ts +12 -2
- package/esm2020/src/providers.mjs +0 -34
- package/esm2020/src/public_api.mjs +0 -3
- package/esm2020/src/symbols.mjs +0 -65
- package/esm2020/src/websocket-handler.mjs +0 -148
- package/esm2020/src/websocket.module.mjs +0 -21
- package/fesm2015/ngxs-websocket-plugin.mjs +0 -268
- package/fesm2015/ngxs-websocket-plugin.mjs.map +0 -1
- package/fesm2020/ngxs-websocket-plugin.mjs +0 -271
- package/fesm2020/ngxs-websocket-plugin.mjs.map +0 -1
- package/src/providers.d.ts +0 -31
- /package/{esm2020/index.mjs → esm2015/index.js} +0 -0
- /package/{esm2020/ngxs-websocket-plugin.mjs → esm2015/ngxs-websocket-plugin.js} +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@ngxs/store';
|
|
4
|
+
import { ofActionDispatched, getValue } from '@ngxs/store';
|
|
5
|
+
import { Subscription } from 'rxjs';
|
|
6
|
+
import { WebSocketSubject } from 'rxjs/webSocket';
|
|
7
|
+
|
|
8
|
+
const NGXS_WEBSOCKET_OPTIONS = new InjectionToken('NGXS_WEBSOCKET_OPTIONS');
|
|
9
|
+
function noop(..._args) {
|
|
10
|
+
return function () { };
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Action to connect to the websocket. Optionally pass a URL.
|
|
14
|
+
*/
|
|
15
|
+
class ConnectWebSocket {
|
|
16
|
+
constructor(payload) {
|
|
17
|
+
this.payload = payload;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
ConnectWebSocket.type = '[WebSocket] Connect';
|
|
21
|
+
/**
|
|
22
|
+
* Action triggered when a error ocurrs
|
|
23
|
+
*/
|
|
24
|
+
class WebsocketMessageError {
|
|
25
|
+
constructor(payload) {
|
|
26
|
+
this.payload = payload;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
WebsocketMessageError.type = '[WebSocket] Message Error';
|
|
30
|
+
/**
|
|
31
|
+
* Action to disconnect the websocket.
|
|
32
|
+
*/
|
|
33
|
+
class DisconnectWebSocket {
|
|
34
|
+
}
|
|
35
|
+
DisconnectWebSocket.type = '[WebSocket] Disconnect';
|
|
36
|
+
/**
|
|
37
|
+
* Action triggered when websocket is connected
|
|
38
|
+
*/
|
|
39
|
+
class WebSocketConnected {
|
|
40
|
+
}
|
|
41
|
+
WebSocketConnected.type = '[WebSocket] Connected';
|
|
42
|
+
/**
|
|
43
|
+
* Action triggered when websocket is disconnected
|
|
44
|
+
*/
|
|
45
|
+
class WebSocketDisconnected {
|
|
46
|
+
}
|
|
47
|
+
WebSocketDisconnected.type = '[WebSocket] Disconnected';
|
|
48
|
+
/**
|
|
49
|
+
* Action to send to the server.
|
|
50
|
+
*/
|
|
51
|
+
class SendWebSocketMessage {
|
|
52
|
+
constructor(payload) {
|
|
53
|
+
this.payload = payload;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
SendWebSocketMessage.type = '[WebSocket] Send Message';
|
|
57
|
+
/**
|
|
58
|
+
* Action dispatched when the user tries to connect if the connection already exists.
|
|
59
|
+
*/
|
|
60
|
+
class WebSocketConnectionUpdated {
|
|
61
|
+
}
|
|
62
|
+
WebSocketConnectionUpdated.type = '[WebSocket] Connection Updated';
|
|
63
|
+
/**
|
|
64
|
+
* This error is thrown where there is no `type` (or custom `typeKey`) property
|
|
65
|
+
* on the message that came from the server side socket
|
|
66
|
+
*/
|
|
67
|
+
class TypeKeyPropertyMissingError extends Error {
|
|
68
|
+
constructor(typeKey) {
|
|
69
|
+
super(`Property ${typeKey} is missing on the socket message`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class WebSocketHandler {
|
|
74
|
+
constructor(store, actions$, options) {
|
|
75
|
+
this.store = store;
|
|
76
|
+
this.actions$ = actions$;
|
|
77
|
+
this.options = options;
|
|
78
|
+
this.socket = null;
|
|
79
|
+
this.config = {
|
|
80
|
+
url: this.options.url,
|
|
81
|
+
protocol: this.options.protocol,
|
|
82
|
+
// Default binary type is `blob` for the global `WebSocket`
|
|
83
|
+
binaryType: this.options.binaryType,
|
|
84
|
+
serializer: this.options.serializer,
|
|
85
|
+
deserializer: this.options.deserializer,
|
|
86
|
+
closeObserver: {
|
|
87
|
+
next: () => {
|
|
88
|
+
// ATTENTION!
|
|
89
|
+
// See https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/WebSocketSubject.ts#L340
|
|
90
|
+
// RxJS socket emits `onComplete` event only if `event.wasClean` is truthy
|
|
91
|
+
// and doesn't complete socket subject if it's falsy
|
|
92
|
+
this.disconnect();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
openObserver: {
|
|
96
|
+
next: () => this.store.dispatch(new WebSocketConnected())
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this.typeKey = this.options.typeKey;
|
|
100
|
+
this.subscription = new Subscription();
|
|
101
|
+
this.setupActionsListeners();
|
|
102
|
+
}
|
|
103
|
+
ngOnDestroy() {
|
|
104
|
+
this.closeConnection();
|
|
105
|
+
this.subscription.unsubscribe();
|
|
106
|
+
}
|
|
107
|
+
setupActionsListeners() {
|
|
108
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(({ payload }) => {
|
|
109
|
+
this.connect(payload);
|
|
110
|
+
}));
|
|
111
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(() => {
|
|
112
|
+
this.disconnect();
|
|
113
|
+
}));
|
|
114
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe(({ payload }) => {
|
|
115
|
+
this.send(payload);
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
connect(options) {
|
|
119
|
+
this.updateConnection();
|
|
120
|
+
// Users can pass the options in the connect method so
|
|
121
|
+
// if options aren't available at DI bootstrap they have access
|
|
122
|
+
// to pass them here
|
|
123
|
+
if (options) {
|
|
124
|
+
this.mergeConfigWithOptions(options);
|
|
125
|
+
}
|
|
126
|
+
this.socket = new WebSocketSubject(this.config);
|
|
127
|
+
this.socket.subscribe({
|
|
128
|
+
next: (message) => {
|
|
129
|
+
const type = getValue(message, this.typeKey);
|
|
130
|
+
if (!type) {
|
|
131
|
+
throw new TypeKeyPropertyMissingError(this.typeKey);
|
|
132
|
+
}
|
|
133
|
+
this.store.dispatch(Object.assign(Object.assign({}, message), { type }));
|
|
134
|
+
},
|
|
135
|
+
error: (error) => {
|
|
136
|
+
if (error instanceof CloseEvent) {
|
|
137
|
+
this.dispatchWebSocketDisconnected();
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.store.dispatch(new WebsocketMessageError(error));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
disconnect() {
|
|
146
|
+
if (this.socket) {
|
|
147
|
+
this.closeConnection();
|
|
148
|
+
this.dispatchWebSocketDisconnected();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
send(data) {
|
|
152
|
+
if (!this.socket) {
|
|
153
|
+
throw new Error('You must connect to the socket before sending any data');
|
|
154
|
+
}
|
|
155
|
+
this.socket.next(data);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Don't enlarge the `connect` method
|
|
159
|
+
*/
|
|
160
|
+
mergeConfigWithOptions(options) {
|
|
161
|
+
if (options.url) {
|
|
162
|
+
this.config.url = options.url;
|
|
163
|
+
}
|
|
164
|
+
if (options.serializer) {
|
|
165
|
+
this.config.serializer = options.serializer;
|
|
166
|
+
}
|
|
167
|
+
if (options.deserializer) {
|
|
168
|
+
this.config.deserializer = options.deserializer;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* To ensure we don't have any memory leaks
|
|
173
|
+
* e.g. if the user occasionally dispatched `ConnectWebSocket` twice
|
|
174
|
+
* then the previous subscription will still live in the memory
|
|
175
|
+
* to prevent such behavior - we close the previous connection if it exists
|
|
176
|
+
*/
|
|
177
|
+
updateConnection() {
|
|
178
|
+
if (this.socket) {
|
|
179
|
+
this.closeConnection();
|
|
180
|
+
this.store.dispatch(new WebSocketConnectionUpdated());
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Used in many places so it's better to move the code into function
|
|
185
|
+
*/
|
|
186
|
+
dispatchWebSocketDisconnected() {
|
|
187
|
+
this.store.dispatch(new WebSocketDisconnected());
|
|
188
|
+
}
|
|
189
|
+
closeConnection() {
|
|
190
|
+
// `socket.complete()` closes the connection
|
|
191
|
+
// also it doesn't invoke the `onComplete` callback that we passed
|
|
192
|
+
// into `socket.subscribe(...)`
|
|
193
|
+
if (this.socket !== null) {
|
|
194
|
+
this.socket.complete();
|
|
195
|
+
this.socket = null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** @nocollapse */ WebSocketHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WebSocketHandler, deps: [{ token: i1.Store }, { token: i1.Actions }, { token: NGXS_WEBSOCKET_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
200
|
+
/** @nocollapse */ WebSocketHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WebSocketHandler });
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WebSocketHandler, decorators: [{
|
|
202
|
+
type: Injectable
|
|
203
|
+
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i1.Actions }, { type: undefined, decorators: [{
|
|
204
|
+
type: Inject,
|
|
205
|
+
args: [NGXS_WEBSOCKET_OPTIONS]
|
|
206
|
+
}] }]; } });
|
|
207
|
+
|
|
208
|
+
function websocketOptionsFactory(options) {
|
|
209
|
+
return Object.assign({ reconnectInterval: 5000, reconnectAttempts: 10, typeKey: 'type', deserializer(e) {
|
|
210
|
+
return JSON.parse(e.data);
|
|
211
|
+
},
|
|
212
|
+
serializer(value) {
|
|
213
|
+
return JSON.stringify(value);
|
|
214
|
+
} }, options);
|
|
215
|
+
}
|
|
216
|
+
const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
|
|
217
|
+
class NgxsWebsocketPluginModule {
|
|
218
|
+
static forRoot(options) {
|
|
219
|
+
return {
|
|
220
|
+
ngModule: NgxsWebsocketPluginModule,
|
|
221
|
+
providers: [
|
|
222
|
+
WebSocketHandler,
|
|
223
|
+
{
|
|
224
|
+
provide: USER_OPTIONS,
|
|
225
|
+
useValue: options
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
provide: NGXS_WEBSOCKET_OPTIONS,
|
|
229
|
+
useFactory: websocketOptionsFactory,
|
|
230
|
+
deps: [USER_OPTIONS]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
provide: APP_INITIALIZER,
|
|
234
|
+
useFactory: noop,
|
|
235
|
+
deps: [WebSocketHandler],
|
|
236
|
+
multi: true
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
243
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule });
|
|
244
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule });
|
|
245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule, decorators: [{
|
|
246
|
+
type: NgModule
|
|
247
|
+
}] });
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The public api for consumers of @ngxs/websocket-plugin
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Generated bundle index. Do not edit.
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
export { ConnectWebSocket, DisconnectWebSocket, NGXS_WEBSOCKET_OPTIONS, NgxsWebsocketPluginModule, SendWebSocketMessage, WebSocketConnected, WebSocketConnectionUpdated, WebSocketDisconnected, WebsocketMessageError };
|
|
258
|
+
//# sourceMappingURL=ngxs-websocket-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngxs-websocket-plugin.js","sources":["../../../packages/websocket-plugin/src/symbols.ts","../../../packages/websocket-plugin/src/websocket-handler.ts","../../../packages/websocket-plugin/src/websocket.module.ts","../../../packages/websocket-plugin/index.ts","../../../packages/websocket-plugin/ngxs-websocket-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const NGXS_WEBSOCKET_OPTIONS = new InjectionToken('NGXS_WEBSOCKET_OPTIONS');\n\nexport interface NgxsWebsocketPluginOptions {\n /**\n * URL of the websocket.\n */\n url?: string;\n\n /**\n * Either a single protocol string or an array of protocol strings.\n * These strings are used to indicate sub-protocols, so that a single server\n * can implement multiple WebSocket sub-protocols (for example, you might want one server to be able\n * to handle different types of interactions depending on the specified protocol).\n * If you don't specify a protocol string, an empty string is assumed.\n */\n protocol?: string | string[];\n\n /**\n * Sets the `binaryType` property of the underlying WebSocket.\n */\n binaryType?: 'blob' | 'arraybuffer';\n\n /**\n * The property name to distigunish this type for the store.\n * Default: 'type'\n */\n typeKey?: string;\n\n /**\n * Interval to try and reconnect.\n * Default: 5000\n */\n reconnectInterval?: number;\n\n /**\n * Number of reconnect attemps.\n * Default: 10\n */\n reconnectAttempts?: number;\n\n /**\n * Serializer to call before sending messages\n * Default: `json.stringify`\n */\n serializer?: (data: any) => string;\n\n /**\n * Deseralizer before publishing the message.\n */\n deserializer?: (e: MessageEvent) => any;\n}\n\nexport function noop(..._args: any[]) {\n return function () {};\n}\n\n/**\n * Action to connect to the websocket. Optionally pass a URL.\n */\nexport class ConnectWebSocket {\n static readonly type = '[WebSocket] Connect';\n\n constructor(public payload?: NgxsWebsocketPluginOptions) {}\n}\n\n/**\n * Action triggered when a error ocurrs\n */\nexport class WebsocketMessageError {\n static readonly type = '[WebSocket] Message Error';\n\n constructor(public payload: any) {}\n}\n\n/**\n * Action to disconnect the websocket.\n */\nexport class DisconnectWebSocket {\n static readonly type = '[WebSocket] Disconnect';\n}\n\n/**\n * Action triggered when websocket is connected\n */\nexport class WebSocketConnected {\n static readonly type = '[WebSocket] Connected';\n}\n\n/**\n * Action triggered when websocket is disconnected\n */\nexport class WebSocketDisconnected {\n static readonly type = '[WebSocket] Disconnected';\n}\n\n/**\n * Action to send to the server.\n */\nexport class SendWebSocketMessage {\n static readonly type = '[WebSocket] Send Message';\n\n constructor(public payload: any) {}\n}\n\n/**\n * Action dispatched when the user tries to connect if the connection already exists.\n */\nexport class WebSocketConnectionUpdated {\n static readonly type = '[WebSocket] Connection Updated';\n}\n\n/**\n * This error is thrown where there is no `type` (or custom `typeKey`) property\n * on the message that came from the server side socket\n */\nexport class TypeKeyPropertyMissingError extends Error {\n constructor(typeKey: string) {\n super(`Property ${typeKey} is missing on the socket message`);\n }\n}\n","import { Injectable, Inject, OnDestroy } from '@angular/core';\nimport { Actions, Store, getValue, ofActionDispatched } from '@ngxs/store';\nimport { Subscription } from 'rxjs';\n\nimport { WebSocketSubject, WebSocketSubjectConfig } from 'rxjs/webSocket';\n\nimport {\n ConnectWebSocket,\n DisconnectWebSocket,\n SendWebSocketMessage,\n NGXS_WEBSOCKET_OPTIONS,\n NgxsWebsocketPluginOptions,\n WebsocketMessageError,\n WebSocketDisconnected,\n TypeKeyPropertyMissingError,\n WebSocketConnectionUpdated,\n WebSocketConnected\n} from './symbols';\n\n@Injectable()\nexport class WebSocketHandler implements OnDestroy {\n private socket: WebSocketSubject<any> | null = null;\n\n private config: WebSocketSubjectConfig<any> = {\n url: this.options.url!,\n protocol: this.options.protocol,\n // Default binary type is `blob` for the global `WebSocket`\n binaryType: this.options.binaryType,\n serializer: this.options.serializer,\n deserializer: this.options.deserializer,\n closeObserver: {\n next: () => {\n // ATTENTION!\n // See https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/WebSocketSubject.ts#L340\n // RxJS socket emits `onComplete` event only if `event.wasClean` is truthy\n // and doesn't complete socket subject if it's falsy\n this.disconnect();\n }\n },\n openObserver: {\n next: () => this.store.dispatch(new WebSocketConnected())\n }\n };\n\n private typeKey = this.options.typeKey!;\n\n private subscription = new Subscription();\n\n constructor(\n private store: Store,\n private actions$: Actions,\n @Inject(NGXS_WEBSOCKET_OPTIONS) private options: NgxsWebsocketPluginOptions\n ) {\n this.setupActionsListeners();\n }\n\n ngOnDestroy(): void {\n this.closeConnection();\n this.subscription.unsubscribe();\n }\n\n private setupActionsListeners(): void {\n this.subscription.add(\n this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(({ payload }) => {\n this.connect(payload);\n })\n );\n\n this.subscription.add(\n this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(() => {\n this.disconnect();\n })\n );\n\n this.subscription.add(\n this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe(({ payload }) => {\n this.send(payload);\n })\n );\n }\n\n private connect(options?: NgxsWebsocketPluginOptions): void {\n this.updateConnection();\n\n // Users can pass the options in the connect method so\n // if options aren't available at DI bootstrap they have access\n // to pass them here\n if (options) {\n this.mergeConfigWithOptions(options);\n }\n\n this.socket = new WebSocketSubject(this.config);\n\n this.socket.subscribe({\n next: (message: any) => {\n const type = getValue(message, this.typeKey);\n if (!type) {\n throw new TypeKeyPropertyMissingError(this.typeKey);\n }\n this.store.dispatch({ ...message, type });\n },\n error: (error: any) => {\n if (error instanceof CloseEvent) {\n this.dispatchWebSocketDisconnected();\n } else {\n this.store.dispatch(new WebsocketMessageError(error));\n }\n }\n });\n }\n\n private disconnect(): void {\n if (this.socket) {\n this.closeConnection();\n this.dispatchWebSocketDisconnected();\n }\n }\n\n private send(data: any): void {\n if (!this.socket) {\n throw new Error('You must connect to the socket before sending any data');\n }\n\n this.socket.next(data);\n }\n\n /**\n * Don't enlarge the `connect` method\n */\n private mergeConfigWithOptions(options: NgxsWebsocketPluginOptions): void {\n if (options.url) {\n this.config.url = options.url;\n }\n\n if (options.serializer) {\n this.config.serializer = options.serializer;\n }\n\n if (options.deserializer) {\n this.config.deserializer = options.deserializer;\n }\n }\n\n /**\n * To ensure we don't have any memory leaks\n * e.g. if the user occasionally dispatched `ConnectWebSocket` twice\n * then the previous subscription will still live in the memory\n * to prevent such behavior - we close the previous connection if it exists\n */\n private updateConnection(): void {\n if (this.socket) {\n this.closeConnection();\n this.store.dispatch(new WebSocketConnectionUpdated());\n }\n }\n\n /**\n * Used in many places so it's better to move the code into function\n */\n private dispatchWebSocketDisconnected(): void {\n this.store.dispatch(new WebSocketDisconnected());\n }\n\n private closeConnection(): void {\n // `socket.complete()` closes the connection\n // also it doesn't invoke the `onComplete` callback that we passed\n // into `socket.subscribe(...)`\n if (this.socket !== null) {\n this.socket.complete();\n this.socket = null;\n }\n }\n}\n","import { NgModule, ModuleWithProviders, APP_INITIALIZER, InjectionToken } from '@angular/core';\n\nimport { WebSocketHandler } from './websocket-handler';\nimport { NgxsWebsocketPluginOptions, NGXS_WEBSOCKET_OPTIONS, noop } from './symbols';\n\nexport function websocketOptionsFactory(options: NgxsWebsocketPluginOptions) {\n return {\n reconnectInterval: 5000,\n reconnectAttempts: 10,\n typeKey: 'type',\n deserializer(e: MessageEvent) {\n return JSON.parse(e.data);\n },\n serializer(value: any) {\n return JSON.stringify(value);\n },\n ...options\n };\n}\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsWebsocketPluginModule {\n static forRoot(\n options?: NgxsWebsocketPluginOptions\n ): ModuleWithProviders<NgxsWebsocketPluginModule> {\n return {\n ngModule: NgxsWebsocketPluginModule,\n providers: [\n WebSocketHandler,\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_WEBSOCKET_OPTIONS,\n useFactory: websocketOptionsFactory,\n deps: [USER_OPTIONS]\n },\n {\n provide: APP_INITIALIZER,\n useFactory: noop,\n deps: [WebSocketHandler],\n multi: true\n }\n ]\n };\n }\n}\n","/**\n * The public api for consumers of @ngxs/websocket-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAEa,sBAAsB,GAAG,IAAI,cAAc,CAAC,wBAAwB,EAAE;AAoDnE,SAAA,IAAI,CAAC,GAAG,KAAY,EAAA;IAClC,OAAO,YAAA,GAAc,CAAC;AACxB,CAAC;AAED;;AAEG;MACU,gBAAgB,CAAA;AAG3B,IAAA,WAAA,CA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C,IAAI,EAAE,CAAC,YAAY,CAAC;AACrB,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE,eAAe;AACxB,oBAAA,UAAU,EAAE,IAAI;oBAChB,IAAI,EAAE,CAAC,gBAAgB,CAAC;AACxB,oBAAA,KAAK,EAAE,IAAI;AACZ,iBAAA;AACF,aAAA;SACF,CAAC;KACH;;0IAzBU,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;2IAAzB,yBAAyB,EAAA,CAAA,CAAA;2IAAzB,yBAAyB,EAAA,CAAA,CAAA;4FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC,QAAQ;;;ACtBT;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "../../node_modules/ng-packagr/package.schema.json",
|
|
2
3
|
"name": "@ngxs/websocket-plugin",
|
|
3
4
|
"description": "Websocket plugin for @ngxs/store",
|
|
4
|
-
"version": "3.8.2
|
|
5
|
+
"version": "3.8.2",
|
|
5
6
|
"sideEffects": true,
|
|
6
7
|
"peerDependencies": {
|
|
7
|
-
"@angular/core": ">=12.0.0 <18.0.0",
|
|
8
8
|
"@ngxs/store": "^3.8.2 || ^3.8.2-dev",
|
|
9
|
+
"@angular/core": ">=12.0.0 <18.0.0",
|
|
9
10
|
"rxjs": ">=6.5.5"
|
|
10
11
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"fesm2015": "fesm2015/ngxs-websocket-plugin.
|
|
16
|
-
"typings": "
|
|
17
|
-
"exports": {
|
|
18
|
-
"./package.json": {
|
|
19
|
-
"default": "./package.json"
|
|
20
|
-
},
|
|
21
|
-
".": {
|
|
22
|
-
"types": "./index.d.ts",
|
|
23
|
-
"esm2020": "./esm2020/ngxs-websocket-plugin.mjs",
|
|
24
|
-
"es2020": "./fesm2020/ngxs-websocket-plugin.mjs",
|
|
25
|
-
"es2015": "./fesm2015/ngxs-websocket-plugin.mjs",
|
|
26
|
-
"node": "./fesm2015/ngxs-websocket-plugin.mjs",
|
|
27
|
-
"default": "./fesm2020/ngxs-websocket-plugin.mjs"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
12
|
+
"main": "bundles/ngxs-websocket-plugin.umd.js",
|
|
13
|
+
"module": "fesm2015/ngxs-websocket-plugin.js",
|
|
14
|
+
"es2015": "fesm2015/ngxs-websocket-plugin.js",
|
|
15
|
+
"esm2015": "esm2015/ngxs-websocket-plugin.js",
|
|
16
|
+
"fesm2015": "fesm2015/ngxs-websocket-plugin.js",
|
|
17
|
+
"typings": "ngxs-websocket-plugin.d.ts",
|
|
30
18
|
"dependencies": {
|
|
31
|
-
"tslib": "^2.
|
|
19
|
+
"tslib": "^2.2.0"
|
|
32
20
|
},
|
|
33
21
|
"repository": {
|
|
34
22
|
"type": "git",
|
|
@@ -74,4 +62,4 @@
|
|
|
74
62
|
"type": "opencollective",
|
|
75
63
|
"url": "https://opencollective.com/ngxs"
|
|
76
64
|
}
|
|
77
|
-
}
|
|
65
|
+
}
|
package/src/public_api.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { NgxsWebsocketPluginModule
|
|
1
|
+
export { NgxsWebsocketPluginModule } from './websocket.module';
|
|
2
2
|
export { NGXS_WEBSOCKET_OPTIONS, NgxsWebsocketPluginOptions, ConnectWebSocket, WebsocketMessageError, DisconnectWebSocket, WebSocketDisconnected, SendWebSocketMessage, WebSocketConnectionUpdated, WebSocketConnected } from './symbols';
|
package/src/symbols.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export declare const NGXS_WEBSOCKET_OPTIONS: InjectionToken<
|
|
3
|
-
export declare const USER_OPTIONS: InjectionToken<unknown>;
|
|
2
|
+
export declare const NGXS_WEBSOCKET_OPTIONS: InjectionToken<unknown>;
|
|
4
3
|
export interface NgxsWebsocketPluginOptions {
|
|
5
4
|
/**
|
|
6
5
|
* URL of the websocket.
|
|
@@ -43,6 +42,7 @@ export interface NgxsWebsocketPluginOptions {
|
|
|
43
42
|
*/
|
|
44
43
|
deserializer?: (e: MessageEvent) => any;
|
|
45
44
|
}
|
|
45
|
+
export declare function noop(..._args: any[]): () => void;
|
|
46
46
|
/**
|
|
47
47
|
* Action to connect to the websocket. Optionally pass a URL.
|
|
48
48
|
*/
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import { OnDestroy
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
2
|
import { Actions, Store } from '@ngxs/store';
|
|
3
3
|
import { NgxsWebsocketPluginOptions } from './symbols';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
export declare class WebSocketHandler implements OnDestroy {
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
constructor(_store: Store, _ngZone: NgZone, _actions$: Actions, _options: NgxsWebsocketPluginOptions);
|
|
6
|
+
private store;
|
|
7
|
+
private actions$;
|
|
8
|
+
private options;
|
|
9
|
+
private socket;
|
|
10
|
+
private config;
|
|
11
|
+
private typeKey;
|
|
12
|
+
private subscription;
|
|
13
|
+
constructor(store: Store, actions$: Actions, options: NgxsWebsocketPluginOptions);
|
|
15
14
|
ngOnDestroy(): void;
|
|
16
|
-
private
|
|
15
|
+
private setupActionsListeners;
|
|
17
16
|
private connect;
|
|
18
|
-
private
|
|
17
|
+
private disconnect;
|
|
19
18
|
private send;
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Don't enlarge the `connect` method
|
|
21
|
+
*/
|
|
22
|
+
private mergeConfigWithOptions;
|
|
23
|
+
/**
|
|
24
|
+
* To ensure we don't have any memory leaks
|
|
25
|
+
* e.g. if the user occasionally dispatched `ConnectWebSocket` twice
|
|
26
|
+
* then the previous subscription will still live in the memory
|
|
27
|
+
* to prevent such behavior - we close the previous connection if it exists
|
|
28
|
+
*/
|
|
29
|
+
private updateConnection;
|
|
30
|
+
/**
|
|
31
|
+
* Used in many places so it's better to move the code into function
|
|
32
|
+
*/
|
|
33
|
+
private dispatchWebSocketDisconnected;
|
|
34
|
+
private closeConnection;
|
|
21
35
|
static ɵfac: i0.ɵɵFactoryDeclaration<WebSocketHandler, never>;
|
|
22
36
|
static ɵprov: i0.ɵɵInjectableDeclaration<WebSocketHandler>;
|
|
23
37
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { ModuleWithProviders,
|
|
1
|
+
import { ModuleWithProviders, InjectionToken } from '@angular/core';
|
|
2
2
|
import { NgxsWebsocketPluginOptions } from './symbols';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
+
export declare function websocketOptionsFactory(options: NgxsWebsocketPluginOptions): {
|
|
5
|
+
url?: string | undefined;
|
|
6
|
+
protocol?: string | string[] | undefined;
|
|
7
|
+
binaryType?: "blob" | "arraybuffer" | undefined;
|
|
8
|
+
typeKey: string;
|
|
9
|
+
reconnectInterval: number;
|
|
10
|
+
reconnectAttempts: number;
|
|
11
|
+
serializer: ((data: any) => string) | ((value: any) => string);
|
|
12
|
+
deserializer: ((e: MessageEvent<any>) => any) | ((e: MessageEvent) => any);
|
|
13
|
+
};
|
|
14
|
+
export declare const USER_OPTIONS: InjectionToken<unknown>;
|
|
4
15
|
export declare class NgxsWebsocketPluginModule {
|
|
5
16
|
static forRoot(options?: NgxsWebsocketPluginOptions): ModuleWithProviders<NgxsWebsocketPluginModule>;
|
|
6
17
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgxsWebsocketPluginModule, never>;
|
|
7
18
|
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsWebsocketPluginModule, never, never, never>;
|
|
8
19
|
static ɵinj: i0.ɵɵInjectorDeclaration<NgxsWebsocketPluginModule>;
|
|
9
20
|
}
|
|
10
|
-
export declare function withNgxsWebSocketPlugin(options?: NgxsWebsocketPluginOptions): EnvironmentProviders;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { APP_INITIALIZER } from '@angular/core';
|
|
2
|
-
import { WebSocketHandler } from './websocket-handler';
|
|
3
|
-
import { USER_OPTIONS, NGXS_WEBSOCKET_OPTIONS } from './symbols';
|
|
4
|
-
export function ɵwebsocketOptionsFactory(options) {
|
|
5
|
-
return {
|
|
6
|
-
reconnectInterval: 5000,
|
|
7
|
-
reconnectAttempts: 10,
|
|
8
|
-
typeKey: 'type',
|
|
9
|
-
deserializer(e) {
|
|
10
|
-
return JSON.parse(e.data);
|
|
11
|
-
},
|
|
12
|
-
serializer(value) {
|
|
13
|
-
return JSON.stringify(value);
|
|
14
|
-
},
|
|
15
|
-
...options
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function ɵgetProviders(options) {
|
|
19
|
-
return [
|
|
20
|
-
{ provide: USER_OPTIONS, useValue: options },
|
|
21
|
-
{
|
|
22
|
-
provide: NGXS_WEBSOCKET_OPTIONS,
|
|
23
|
-
useFactory: ɵwebsocketOptionsFactory,
|
|
24
|
-
deps: [USER_OPTIONS]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
provide: APP_INITIALIZER,
|
|
28
|
-
useFactory: () => () => { },
|
|
29
|
-
deps: [WebSocketHandler],
|
|
30
|
-
multi: true
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcGFja2FnZXMvd2Vic29ja2V0LXBsdWdpbi9zcmMvcHJvdmlkZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU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iBbVVNFUl9PUFRJT05TXVxuICAgIH0sXG4gICAge1xuICAgICAgcHJvdmlkZTogQVBQX0lOSVRJQUxJWkVSLFxuICAgICAgdXNlRmFjdG9yeTogKCkgPT4gKCkgPT4ge30sXG4gICAgICBkZXBzOiBbV2ViU29ja2V0SGFuZGxlcl0sXG4gICAgICBtdWx0aTogdHJ1ZVxuICAgIH1cbiAgXTtcbn1cbiJdfQ==
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { NgxsWebsocketPluginModule, withNgxsWebSocketPlugin } from './websocket.module';
|
|
2
|
-
export { NGXS_WEBSOCKET_OPTIONS, ConnectWebSocket, WebsocketMessageError, DisconnectWebSocket, WebSocketDisconnected, SendWebSocketMessage, WebSocketConnectionUpdated, WebSocketConnected } from './symbols';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL3dlYnNvY2tldC1wbHVnaW4vc3JjL3B1YmxpY19hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLHVCQUF1QixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDeEYsT0FBTyxFQUNMLHNCQUFzQixFQUV0QixnQkFBZ0IsRUFDaEIscUJBQXFCLEVBQ3JCLG1CQUFtQixFQUNuQixxQkFBcUIsRUFDckIsb0JBQW9CLEVBQ3BCLDBCQUEwQixFQUMxQixrQkFBa0IsRUFDbkIsTUFBTSxXQUFXLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBOZ3hzV2Vic29ja2V0UGx1Z2luTW9kdWxlLCB3aXRoTmd4c1dlYlNvY2tldFBsdWdpbiB9IGZyb20gJy4vd2Vic29ja2V0Lm1vZHVsZSc7XG5leHBvcnQge1xuICBOR1hTX1dFQlNPQ0tFVF9PUFRJT05TLFxuICBOZ3hzV2Vic29ja2V0UGx1Z2luT3B0aW9ucyxcbiAgQ29ubmVjdFdlYlNvY2tldCxcbiAgV2Vic29ja2V0TWVzc2FnZUVycm9yLFxuICBEaXNjb25uZWN0V2ViU29ja2V0LFxuICBXZWJTb2NrZXREaXNjb25uZWN0ZWQsXG4gIFNlbmRXZWJTb2NrZXRNZXNzYWdlLFxuICBXZWJTb2NrZXRDb25uZWN0aW9uVXBkYXRlZCxcbiAgV2ViU29ja2V0Q29ubmVjdGVkXG59IGZyb20gJy4vc3ltYm9scyc7XG4iXX0=
|
package/esm2020/src/symbols.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
|
3
|
-
export const NGXS_WEBSOCKET_OPTIONS = new InjectionToken(NG_DEV_MODE ? 'NGXS_WEBSOCKET_OPTIONS' : '');
|
|
4
|
-
export const USER_OPTIONS = new InjectionToken(NG_DEV_MODE ? 'USER_OPTIONS' : '');
|
|
5
|
-
/**
|
|
6
|
-
* Action to connect to the websocket. Optionally pass a URL.
|
|
7
|
-
*/
|
|
8
|
-
export class ConnectWebSocket {
|
|
9
|
-
constructor(payload) {
|
|
10
|
-
this.payload = payload;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
ConnectWebSocket.type = '[WebSocket] Connect';
|
|
14
|
-
/**
|
|
15
|
-
* Action triggered when a error ocurrs
|
|
16
|
-
*/
|
|
17
|
-
export class WebsocketMessageError {
|
|
18
|
-
constructor(payload) {
|
|
19
|
-
this.payload = payload;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
WebsocketMessageError.type = '[WebSocket] Message Error';
|
|
23
|
-
/**
|
|
24
|
-
* Action to disconnect the websocket.
|
|
25
|
-
*/
|
|
26
|
-
export class DisconnectWebSocket {
|
|
27
|
-
}
|
|
28
|
-
DisconnectWebSocket.type = '[WebSocket] Disconnect';
|
|
29
|
-
/**
|
|
30
|
-
* Action triggered when websocket is connected
|
|
31
|
-
*/
|
|
32
|
-
export class WebSocketConnected {
|
|
33
|
-
}
|
|
34
|
-
WebSocketConnected.type = '[WebSocket] Connected';
|
|
35
|
-
/**
|
|
36
|
-
* Action triggered when websocket is disconnected
|
|
37
|
-
*/
|
|
38
|
-
export class WebSocketDisconnected {
|
|
39
|
-
}
|
|
40
|
-
WebSocketDisconnected.type = '[WebSocket] Disconnected';
|
|
41
|
-
/**
|
|
42
|
-
* Action to send to the server.
|
|
43
|
-
*/
|
|
44
|
-
export class SendWebSocketMessage {
|
|
45
|
-
constructor(payload) {
|
|
46
|
-
this.payload = payload;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
SendWebSocketMessage.type = '[WebSocket] Send Message';
|
|
50
|
-
/**
|
|
51
|
-
* Action dispatched when the user tries to connect if the connection already exists.
|
|
52
|
-
*/
|
|
53
|
-
export class WebSocketConnectionUpdated {
|
|
54
|
-
}
|
|
55
|
-
WebSocketConnectionUpdated.type = '[WebSocket] Connection Updated';
|
|
56
|
-
/**
|
|
57
|
-
* This error is thrown where there is no `type` (or custom `typeKey`) property
|
|
58
|
-
* on the message that came from the server side socket
|
|
59
|
-
*/
|
|
60
|
-
export class TypeKeyPropertyMissingError extends Error {
|
|
61
|
-
constructor(typeKey) {
|
|
62
|
-
super(`Property ${typeKey} is missing on the socket message`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3ltYm9scy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL3dlYnNvY2tldC1wbHVnaW4vc3JjL3N5bWJvbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGNBQWMsRUFBRS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