@ngxs/websocket-plugin 3.7.6 → 3.8.0-dev.master-c341c15
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 +426 -593
- package/bundles/ngxs-websocket-plugin.umd.js.map +1 -1
- package/esm2015/index.js +2 -6
- package/esm2015/ngxs-websocket-plugin.js +2 -9
- package/esm2015/src/public_api.js +1 -5
- package/esm2015/src/symbols.js +2 -113
- package/esm2015/src/websocket-handler.js +27 -130
- package/esm2015/src/websocket.module.js +9 -26
- package/fesm2015/ngxs-websocket-plugin.js +38 -277
- package/fesm2015/ngxs-websocket-plugin.js.map +1 -1
- package/ngxs-websocket-plugin.d.ts +1 -3
- package/package.json +5 -8
- package/src/symbols.d.ts +8 -8
- package/src/websocket-handler.d.ts +3 -0
- package/src/websocket.module.d.ts +6 -2
- package/bundles/ngxs-websocket-plugin.umd.min.js +0 -16
- package/bundles/ngxs-websocket-plugin.umd.min.js.map +0 -1
- package/esm5/index.js +0 -9
- package/esm5/ngxs-websocket-plugin.js +0 -12
- package/esm5/src/public_api.js +0 -7
- package/esm5/src/symbols.js +0 -293
- package/esm5/src/websocket-handler.js +0 -304
- package/esm5/src/websocket.module.js +0 -71
- package/fesm5/ngxs-websocket-plugin.js +0 -644
- package/fesm5/ngxs-websocket-plugin.js.map +0 -1
- package/ngxs-websocket-plugin.metadata.json +0 -1
- package/tests/typings.d.ts +0 -18
|
@@ -1,129 +1,42 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
1
2
|
import { InjectionToken, Injectable, Inject, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
2
|
-
import
|
|
3
|
+
import * as i1 from '@ngxs/store';
|
|
4
|
+
import { ofActionDispatched, getValue } from '@ngxs/store';
|
|
3
5
|
import { Subscription } from 'rxjs';
|
|
4
6
|
import { WebSocketSubject } from 'rxjs/webSocket';
|
|
5
7
|
|
|
6
|
-
/**
|
|
7
|
-
* @fileoverview added by tsickle
|
|
8
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
9
|
-
*/
|
|
10
|
-
/** @type {?} */
|
|
11
8
|
const NGXS_WEBSOCKET_OPTIONS = new InjectionToken('NGXS_WEBSOCKET_OPTIONS');
|
|
12
|
-
/**
|
|
13
|
-
* @record
|
|
14
|
-
*/
|
|
15
|
-
function NgxsWebsocketPluginOptions() { }
|
|
16
|
-
if (false) {
|
|
17
|
-
/**
|
|
18
|
-
* URL of the websocket.
|
|
19
|
-
* @type {?|undefined}
|
|
20
|
-
*/
|
|
21
|
-
NgxsWebsocketPluginOptions.prototype.url;
|
|
22
|
-
/**
|
|
23
|
-
* Either a single protocol string or an array of protocol strings.
|
|
24
|
-
* These strings are used to indicate sub-protocols, so that a single server
|
|
25
|
-
* can implement multiple WebSocket sub-protocols (for example, you might want one server to be able
|
|
26
|
-
* to handle different types of interactions depending on the specified protocol).
|
|
27
|
-
* If you don't specify a protocol string, an empty string is assumed.
|
|
28
|
-
* @type {?|undefined}
|
|
29
|
-
*/
|
|
30
|
-
NgxsWebsocketPluginOptions.prototype.protocol;
|
|
31
|
-
/**
|
|
32
|
-
* Sets the `binaryType` property of the underlying WebSocket.
|
|
33
|
-
* @type {?|undefined}
|
|
34
|
-
*/
|
|
35
|
-
NgxsWebsocketPluginOptions.prototype.binaryType;
|
|
36
|
-
/**
|
|
37
|
-
* The property name to distigunish this type for the store.
|
|
38
|
-
* Default: 'type'
|
|
39
|
-
* @type {?|undefined}
|
|
40
|
-
*/
|
|
41
|
-
NgxsWebsocketPluginOptions.prototype.typeKey;
|
|
42
|
-
/**
|
|
43
|
-
* Interval to try and reconnect.
|
|
44
|
-
* Default: 5000
|
|
45
|
-
* @type {?|undefined}
|
|
46
|
-
*/
|
|
47
|
-
NgxsWebsocketPluginOptions.prototype.reconnectInterval;
|
|
48
|
-
/**
|
|
49
|
-
* Number of reconnect attemps.
|
|
50
|
-
* Default: 10
|
|
51
|
-
* @type {?|undefined}
|
|
52
|
-
*/
|
|
53
|
-
NgxsWebsocketPluginOptions.prototype.reconnectAttempts;
|
|
54
|
-
/**
|
|
55
|
-
* Serializer to call before sending messages
|
|
56
|
-
* Default: `json.stringify`
|
|
57
|
-
* @type {?|undefined}
|
|
58
|
-
*/
|
|
59
|
-
NgxsWebsocketPluginOptions.prototype.serializer;
|
|
60
|
-
/**
|
|
61
|
-
* Deseralizer before publishing the message.
|
|
62
|
-
* @type {?|undefined}
|
|
63
|
-
*/
|
|
64
|
-
NgxsWebsocketPluginOptions.prototype.deserializer;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @param {...?} _args
|
|
68
|
-
* @return {?}
|
|
69
|
-
*/
|
|
70
9
|
function noop(..._args) {
|
|
71
|
-
return (
|
|
72
|
-
* @return {?}
|
|
73
|
-
*/
|
|
74
|
-
function () { });
|
|
10
|
+
return function () { };
|
|
75
11
|
}
|
|
76
12
|
/**
|
|
77
13
|
* Action to connect to the websocket. Optionally pass a URL.
|
|
78
14
|
*/
|
|
79
15
|
class ConnectWebSocket {
|
|
80
|
-
/**
|
|
81
|
-
* @param {?=} payload
|
|
82
|
-
*/
|
|
83
16
|
constructor(payload) {
|
|
84
17
|
this.payload = payload;
|
|
85
18
|
}
|
|
86
|
-
/**
|
|
87
|
-
* @return {?}
|
|
88
|
-
*/
|
|
89
19
|
static get type() {
|
|
90
20
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
91
21
|
return '[WebSocket] Connect';
|
|
92
22
|
}
|
|
93
23
|
}
|
|
94
|
-
if (false) {
|
|
95
|
-
/** @type {?} */
|
|
96
|
-
ConnectWebSocket.prototype.payload;
|
|
97
|
-
}
|
|
98
24
|
/**
|
|
99
25
|
* Action triggered when a error ocurrs
|
|
100
26
|
*/
|
|
101
27
|
class WebsocketMessageError {
|
|
102
|
-
/**
|
|
103
|
-
* @param {?} payload
|
|
104
|
-
*/
|
|
105
28
|
constructor(payload) {
|
|
106
29
|
this.payload = payload;
|
|
107
30
|
}
|
|
108
|
-
/**
|
|
109
|
-
* @return {?}
|
|
110
|
-
*/
|
|
111
31
|
static get type() {
|
|
112
32
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
113
33
|
return '[WebSocket] Message Error';
|
|
114
34
|
}
|
|
115
35
|
}
|
|
116
|
-
if (false) {
|
|
117
|
-
/** @type {?} */
|
|
118
|
-
WebsocketMessageError.prototype.payload;
|
|
119
|
-
}
|
|
120
36
|
/**
|
|
121
37
|
* Action to disconnect the websocket.
|
|
122
38
|
*/
|
|
123
39
|
class DisconnectWebSocket {
|
|
124
|
-
/**
|
|
125
|
-
* @return {?}
|
|
126
|
-
*/
|
|
127
40
|
static get type() {
|
|
128
41
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
129
42
|
return '[WebSocket] Disconnect';
|
|
@@ -133,9 +46,6 @@ class DisconnectWebSocket {
|
|
|
133
46
|
* Action triggered when websocket is connected
|
|
134
47
|
*/
|
|
135
48
|
class WebSocketConnected {
|
|
136
|
-
/**
|
|
137
|
-
* @return {?}
|
|
138
|
-
*/
|
|
139
49
|
static get type() {
|
|
140
50
|
return '[WebSocket] Connected';
|
|
141
51
|
}
|
|
@@ -144,9 +54,6 @@ class WebSocketConnected {
|
|
|
144
54
|
* Action triggered when websocket is disconnected
|
|
145
55
|
*/
|
|
146
56
|
class WebSocketDisconnected {
|
|
147
|
-
/**
|
|
148
|
-
* @return {?}
|
|
149
|
-
*/
|
|
150
57
|
static get type() {
|
|
151
58
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
152
59
|
return '[WebSocket] Disconnected';
|
|
@@ -156,31 +63,18 @@ class WebSocketDisconnected {
|
|
|
156
63
|
* Action to send to the server.
|
|
157
64
|
*/
|
|
158
65
|
class SendWebSocketMessage {
|
|
159
|
-
/**
|
|
160
|
-
* @param {?} payload
|
|
161
|
-
*/
|
|
162
66
|
constructor(payload) {
|
|
163
67
|
this.payload = payload;
|
|
164
68
|
}
|
|
165
|
-
/**
|
|
166
|
-
* @return {?}
|
|
167
|
-
*/
|
|
168
69
|
static get type() {
|
|
169
70
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
170
71
|
return '[WebSocket] Send Message';
|
|
171
72
|
}
|
|
172
73
|
}
|
|
173
|
-
if (false) {
|
|
174
|
-
/** @type {?} */
|
|
175
|
-
SendWebSocketMessage.prototype.payload;
|
|
176
|
-
}
|
|
177
74
|
/**
|
|
178
75
|
* Action dispatched when the user tries to connect if the connection already exists.
|
|
179
76
|
*/
|
|
180
77
|
class WebSocketConnectionUpdated {
|
|
181
|
-
/**
|
|
182
|
-
* @return {?}
|
|
183
|
-
*/
|
|
184
78
|
static get type() {
|
|
185
79
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
186
80
|
return '[WebSocket] Connection Updated';
|
|
@@ -191,97 +85,56 @@ class WebSocketConnectionUpdated {
|
|
|
191
85
|
* on the message that came from the server side socket
|
|
192
86
|
*/
|
|
193
87
|
class TypeKeyPropertyMissingError extends Error {
|
|
194
|
-
/**
|
|
195
|
-
* @param {?} typeKey
|
|
196
|
-
*/
|
|
197
88
|
constructor(typeKey) {
|
|
198
89
|
super(`Property ${typeKey} is missing on the socket message`);
|
|
199
90
|
}
|
|
200
91
|
}
|
|
201
92
|
|
|
202
|
-
/**
|
|
203
|
-
* @fileoverview added by tsickle
|
|
204
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
205
|
-
*/
|
|
206
93
|
class WebSocketHandler {
|
|
207
|
-
/**
|
|
208
|
-
* @param {?} store
|
|
209
|
-
* @param {?} actions$
|
|
210
|
-
* @param {?} options
|
|
211
|
-
*/
|
|
212
94
|
constructor(store, actions$, options) {
|
|
213
95
|
this.store = store;
|
|
214
96
|
this.actions$ = actions$;
|
|
215
97
|
this.options = options;
|
|
216
98
|
this.socket = null;
|
|
217
99
|
this.config = {
|
|
218
|
-
url:
|
|
100
|
+
url: this.options.url,
|
|
219
101
|
protocol: this.options.protocol,
|
|
220
102
|
// Default binary type is `blob` for the global `WebSocket`
|
|
221
103
|
binaryType: this.options.binaryType,
|
|
222
104
|
serializer: this.options.serializer,
|
|
223
105
|
deserializer: this.options.deserializer,
|
|
224
106
|
closeObserver: {
|
|
225
|
-
next: (
|
|
226
|
-
* @return {?}
|
|
227
|
-
*/
|
|
228
|
-
() => {
|
|
107
|
+
next: () => {
|
|
229
108
|
// ATTENTION!
|
|
230
109
|
// See https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/WebSocketSubject.ts#L340
|
|
231
110
|
// RxJS socket emits `onComplete` event only if `event.wasClean` is truthy
|
|
232
111
|
// and doesn't complete socket subject if it's falsy
|
|
233
112
|
this.disconnect();
|
|
234
|
-
}
|
|
113
|
+
}
|
|
235
114
|
},
|
|
236
115
|
openObserver: {
|
|
237
|
-
next: (
|
|
238
|
-
* @return {?}
|
|
239
|
-
*/
|
|
240
|
-
() => this.store.dispatch(new WebSocketConnected()))
|
|
116
|
+
next: () => this.store.dispatch(new WebSocketConnected())
|
|
241
117
|
}
|
|
242
118
|
};
|
|
243
|
-
this.typeKey =
|
|
119
|
+
this.typeKey = this.options.typeKey;
|
|
244
120
|
this.subscription = new Subscription();
|
|
245
121
|
this.setupActionsListeners();
|
|
246
122
|
}
|
|
247
|
-
/**
|
|
248
|
-
* @return {?}
|
|
249
|
-
*/
|
|
250
123
|
ngOnDestroy() {
|
|
251
124
|
this.closeConnection();
|
|
252
125
|
this.subscription.unsubscribe();
|
|
253
126
|
}
|
|
254
|
-
/**
|
|
255
|
-
* @private
|
|
256
|
-
* @return {?}
|
|
257
|
-
*/
|
|
258
127
|
setupActionsListeners() {
|
|
259
|
-
this.subscription.add(this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe((
|
|
260
|
-
* @param {?} __0
|
|
261
|
-
* @return {?}
|
|
262
|
-
*/
|
|
263
|
-
({ payload }) => {
|
|
128
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(ConnectWebSocket)).subscribe(({ payload }) => {
|
|
264
129
|
this.connect(payload);
|
|
265
|
-
}))
|
|
266
|
-
this.subscription.add(this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe((
|
|
267
|
-
* @return {?}
|
|
268
|
-
*/
|
|
269
|
-
() => {
|
|
130
|
+
}));
|
|
131
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(DisconnectWebSocket)).subscribe(() => {
|
|
270
132
|
this.disconnect();
|
|
271
|
-
}))
|
|
272
|
-
this.subscription.add(this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe((
|
|
273
|
-
* @param {?} __0
|
|
274
|
-
* @return {?}
|
|
275
|
-
*/
|
|
276
|
-
({ payload }) => {
|
|
133
|
+
}));
|
|
134
|
+
this.subscription.add(this.actions$.pipe(ofActionDispatched(SendWebSocketMessage)).subscribe(({ payload }) => {
|
|
277
135
|
this.send(payload);
|
|
278
|
-
}))
|
|
136
|
+
}));
|
|
279
137
|
}
|
|
280
|
-
/**
|
|
281
|
-
* @private
|
|
282
|
-
* @param {?=} options
|
|
283
|
-
* @return {?}
|
|
284
|
-
*/
|
|
285
138
|
connect(options) {
|
|
286
139
|
this.updateConnection();
|
|
287
140
|
// Users can pass the options in the connect method so
|
|
@@ -292,47 +145,29 @@ class WebSocketHandler {
|
|
|
292
145
|
}
|
|
293
146
|
this.socket = new WebSocketSubject(this.config);
|
|
294
147
|
this.socket.subscribe({
|
|
295
|
-
next: (
|
|
296
|
-
* @param {?} message
|
|
297
|
-
* @return {?}
|
|
298
|
-
*/
|
|
299
|
-
(message) => {
|
|
300
|
-
/** @type {?} */
|
|
148
|
+
next: (message) => {
|
|
301
149
|
const type = getValue(message, this.typeKey);
|
|
302
150
|
if (!type) {
|
|
303
151
|
throw new TypeKeyPropertyMissingError(this.typeKey);
|
|
304
152
|
}
|
|
305
|
-
this.store.dispatch(Object.assign({}, message, { type }));
|
|
306
|
-
}
|
|
307
|
-
error: (
|
|
308
|
-
* @param {?} error
|
|
309
|
-
* @return {?}
|
|
310
|
-
*/
|
|
311
|
-
(error) => {
|
|
153
|
+
this.store.dispatch(Object.assign(Object.assign({}, message), { type }));
|
|
154
|
+
},
|
|
155
|
+
error: (error) => {
|
|
312
156
|
if (error instanceof CloseEvent) {
|
|
313
157
|
this.dispatchWebSocketDisconnected();
|
|
314
158
|
}
|
|
315
159
|
else {
|
|
316
160
|
this.store.dispatch(new WebsocketMessageError(error));
|
|
317
161
|
}
|
|
318
|
-
}
|
|
162
|
+
}
|
|
319
163
|
});
|
|
320
164
|
}
|
|
321
|
-
/**
|
|
322
|
-
* @private
|
|
323
|
-
* @return {?}
|
|
324
|
-
*/
|
|
325
165
|
disconnect() {
|
|
326
166
|
if (this.socket) {
|
|
327
167
|
this.closeConnection();
|
|
328
168
|
this.dispatchWebSocketDisconnected();
|
|
329
169
|
}
|
|
330
170
|
}
|
|
331
|
-
/**
|
|
332
|
-
* @private
|
|
333
|
-
* @param {?} data
|
|
334
|
-
* @return {?}
|
|
335
|
-
*/
|
|
336
171
|
send(data) {
|
|
337
172
|
if (!this.socket) {
|
|
338
173
|
throw new Error('You must connect to the socket before sending any data');
|
|
@@ -341,9 +176,6 @@ class WebSocketHandler {
|
|
|
341
176
|
}
|
|
342
177
|
/**
|
|
343
178
|
* Don't enlarge the `connect` method
|
|
344
|
-
* @private
|
|
345
|
-
* @param {?} options
|
|
346
|
-
* @return {?}
|
|
347
179
|
*/
|
|
348
180
|
mergeConfigWithOptions(options) {
|
|
349
181
|
if (options.url) {
|
|
@@ -361,8 +193,6 @@ class WebSocketHandler {
|
|
|
361
193
|
* e.g. if the user occasionally dispatched `ConnectWebSocket` twice
|
|
362
194
|
* then the previous subscription will still live in the memory
|
|
363
195
|
* to prevent such behavior - we close the previous connection if it exists
|
|
364
|
-
* @private
|
|
365
|
-
* @return {?}
|
|
366
196
|
*/
|
|
367
197
|
updateConnection() {
|
|
368
198
|
if (this.socket) {
|
|
@@ -372,16 +202,10 @@ class WebSocketHandler {
|
|
|
372
202
|
}
|
|
373
203
|
/**
|
|
374
204
|
* Used in many places so it's better to move the code into function
|
|
375
|
-
* @private
|
|
376
|
-
* @return {?}
|
|
377
205
|
*/
|
|
378
206
|
dispatchWebSocketDisconnected() {
|
|
379
207
|
this.store.dispatch(new WebSocketDisconnected());
|
|
380
208
|
}
|
|
381
|
-
/**
|
|
382
|
-
* @private
|
|
383
|
-
* @return {?}
|
|
384
|
-
*/
|
|
385
209
|
closeConnection() {
|
|
386
210
|
// `socket.complete()` closes the connection
|
|
387
211
|
// also it doesn't invoke the `onComplete` callback that we passed
|
|
@@ -392,84 +216,25 @@ class WebSocketHandler {
|
|
|
392
216
|
}
|
|
393
217
|
}
|
|
394
218
|
}
|
|
395
|
-
WebSocketHandler
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
];
|
|
404
|
-
if (false) {
|
|
405
|
-
/**
|
|
406
|
-
* @type {?}
|
|
407
|
-
* @private
|
|
408
|
-
*/
|
|
409
|
-
WebSocketHandler.prototype.socket;
|
|
410
|
-
/**
|
|
411
|
-
* @type {?}
|
|
412
|
-
* @private
|
|
413
|
-
*/
|
|
414
|
-
WebSocketHandler.prototype.config;
|
|
415
|
-
/**
|
|
416
|
-
* @type {?}
|
|
417
|
-
* @private
|
|
418
|
-
*/
|
|
419
|
-
WebSocketHandler.prototype.typeKey;
|
|
420
|
-
/**
|
|
421
|
-
* @type {?}
|
|
422
|
-
* @private
|
|
423
|
-
*/
|
|
424
|
-
WebSocketHandler.prototype.subscription;
|
|
425
|
-
/**
|
|
426
|
-
* @type {?}
|
|
427
|
-
* @private
|
|
428
|
-
*/
|
|
429
|
-
WebSocketHandler.prototype.store;
|
|
430
|
-
/**
|
|
431
|
-
* @type {?}
|
|
432
|
-
* @private
|
|
433
|
-
*/
|
|
434
|
-
WebSocketHandler.prototype.actions$;
|
|
435
|
-
/**
|
|
436
|
-
* @type {?}
|
|
437
|
-
* @private
|
|
438
|
-
*/
|
|
439
|
-
WebSocketHandler.prototype.options;
|
|
440
|
-
}
|
|
219
|
+
/** @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 });
|
|
220
|
+
/** @nocollapse */ WebSocketHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WebSocketHandler });
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: WebSocketHandler, decorators: [{
|
|
222
|
+
type: Injectable
|
|
223
|
+
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i1.Actions }, { type: undefined, decorators: [{
|
|
224
|
+
type: Inject,
|
|
225
|
+
args: [NGXS_WEBSOCKET_OPTIONS]
|
|
226
|
+
}] }]; } });
|
|
441
227
|
|
|
442
|
-
/**
|
|
443
|
-
* @fileoverview added by tsickle
|
|
444
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
445
|
-
*/
|
|
446
|
-
/**
|
|
447
|
-
* @param {?} options
|
|
448
|
-
* @return {?}
|
|
449
|
-
*/
|
|
450
228
|
function websocketOptionsFactory(options) {
|
|
451
|
-
return Object.assign({ reconnectInterval: 5000, reconnectAttempts: 10, typeKey: 'type',
|
|
452
|
-
* @param {?} e
|
|
453
|
-
* @return {?}
|
|
454
|
-
*/
|
|
455
|
-
deserializer(e) {
|
|
229
|
+
return Object.assign({ reconnectInterval: 5000, reconnectAttempts: 10, typeKey: 'type', deserializer(e) {
|
|
456
230
|
return JSON.parse(e.data);
|
|
457
231
|
},
|
|
458
|
-
/**
|
|
459
|
-
* @param {?} value
|
|
460
|
-
* @return {?}
|
|
461
|
-
*/
|
|
462
232
|
serializer(value) {
|
|
463
233
|
return JSON.stringify(value);
|
|
464
234
|
} }, options);
|
|
465
235
|
}
|
|
466
|
-
/** @type {?} */
|
|
467
236
|
const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
|
|
468
237
|
class NgxsWebsocketPluginModule {
|
|
469
|
-
/**
|
|
470
|
-
* @param {?=} options
|
|
471
|
-
* @return {?}
|
|
472
|
-
*/
|
|
473
238
|
static forRoot(options) {
|
|
474
239
|
return {
|
|
475
240
|
ngModule: NgxsWebsocketPluginModule,
|
|
@@ -494,24 +259,20 @@ class NgxsWebsocketPluginModule {
|
|
|
494
259
|
};
|
|
495
260
|
}
|
|
496
261
|
}
|
|
497
|
-
NgxsWebsocketPluginModule
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
504
|
-
*/
|
|
262
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
263
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule });
|
|
264
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule });
|
|
265
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsWebsocketPluginModule, decorators: [{
|
|
266
|
+
type: NgModule
|
|
267
|
+
}] });
|
|
505
268
|
|
|
506
269
|
/**
|
|
507
|
-
*
|
|
508
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
270
|
+
* The public api for consumers of @ngxs/websocket-plugin
|
|
509
271
|
*/
|
|
510
272
|
|
|
511
273
|
/**
|
|
512
|
-
*
|
|
513
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
274
|
+
* Generated bundle index. Do not edit.
|
|
514
275
|
*/
|
|
515
276
|
|
|
516
|
-
export { ConnectWebSocket, DisconnectWebSocket, NGXS_WEBSOCKET_OPTIONS, NgxsWebsocketPluginModule, SendWebSocketMessage, WebSocketConnected, WebSocketConnectionUpdated, WebSocketDisconnected, WebsocketMessageError
|
|
277
|
+
export { ConnectWebSocket, DisconnectWebSocket, NGXS_WEBSOCKET_OPTIONS, NgxsWebsocketPluginModule, SendWebSocketMessage, WebSocketConnected, WebSocketConnectionUpdated, WebSocketDisconnected, WebsocketMessageError };
|
|
517
278
|
//# sourceMappingURL=ngxs-websocket-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-websocket-plugin.js","sources":["ng://@ngxs/websocket-plugin/src/symbols.ts","ng://@ngxs/websocket-plugin/src/websocket-handler.ts","ng://@ngxs/websocket-plugin/src/websocket.module.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 get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Connect';\n }\n constructor(public payload?: NgxsWebsocketPluginOptions) {}\n}\n\n/**\n * Action triggered when a error ocurrs\n */\nexport class WebsocketMessageError {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Message Error';\n }\n constructor(public payload: any) {}\n}\n\n/**\n * Action to disconnect the websocket.\n */\nexport class DisconnectWebSocket {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Disconnect';\n }\n}\n\n/**\n * Action triggered when websocket is connected\n */\nexport class WebSocketConnected {\n static get type() {\n return '[WebSocket] Connected';\n }\n}\n\n/**\n * Action triggered when websocket is disconnected\n */\nexport class WebSocketDisconnected {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Disconnected';\n }\n}\n\n/**\n * Action to send to the server.\n */\nexport class SendWebSocketMessage {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[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 get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Connection Updated';\n }\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"],"names":[],"mappings":";;;;;;;;;AAAA;AAEA,MAAa,sBAAs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;YAAd,OAAO;4CAkDX,MAAM,SAAC,sBAAsB;;;;;;;IA9BhC,kCAAoD;;;;;IAEpD,kCAmBE;;;;;IAEF,mCAAwC;;;;;IAExC,wCAA0C;;;;;IAGxC,iCAAoB;;;;;IACpB,oCAAyB;;;;;IACzB,mCAA2E;;;;;;;ACnD/E;;;;AAKA,SAAgB,uBAAuB,CAAC,OAAmC;IACzE,uBACE,iBAAiB,EAAE,IAAI,EACvB,iBAAiB,EAAE,EAAE,EACrB,OAAO,EAAE,MAAM;;;;QACf,YAAY,CAAC,CAAe;YAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC3B;;;;;QACD,UAAU,CAAC,KAAU;YACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAC9B,IACE,OAAO,EACV;CACH;;AAED,MAAa,YAAY,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC;AAG9D,MAAa,yBAAyB;;;;;IACpC,OAAO,OAAO,CACZ,OAAoC;QAEpC,OAAO;YACL,QAAQ,EAAE,yBAAyB;YACnC,SAAS,EAAE;gBACT,gBAAgB;gBAChB;oBACE,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,OAAO;iBAClB;gBACD;oBACE,OAAO,EAAE,sBAAsB;oBAC/B,UAAU,EAAE,uBAAuB;oBACnC,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;gBACD;oBACE,OAAO,EAAE,eAAe;oBACxB,UAAU,EAAE,IAAI;oBAChB,IAAI,EAAE,CAAC,gBAAgB,CAAC;oBACxB,KAAK,EAAE,IAAI;iBACZ;aACF;SACF,CAAC;KACH;;;YA1BF,QAAQ;;;;;;;;;;;;;;;;;;;;"}
|
|
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 get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Connect';\n }\n constructor(public payload?: NgxsWebsocketPluginOptions) {}\n}\n\n/**\n * Action triggered when a error ocurrs\n */\nexport class WebsocketMessageError {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Message Error';\n }\n constructor(public payload: any) {}\n}\n\n/**\n * Action to disconnect the websocket.\n */\nexport class DisconnectWebSocket {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Disconnect';\n }\n}\n\n/**\n * Action triggered when websocket is connected\n */\nexport class WebSocketConnected {\n static get type() {\n return '[WebSocket] Connected';\n }\n}\n\n/**\n * Action triggered when websocket is disconnected\n */\nexport class WebSocketDisconnected {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Disconnected';\n }\n}\n\n/**\n * Action to send to the server.\n */\nexport class SendWebSocketMessage {\n static get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[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 get type() {\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\n return '[WebSocket] Connection Updated';\n }\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,GAAa,CAAC;AACvB,CAAC;AAED;;AAEG;MACU,gBAAgB,CAAA;AAK3B,IAAA,WAAA,CAAmB,OAAoC,EAAA;QAApC,IAAO,CAAA,OAAA,GAAP,OAAO,CAA6B;KAAI;AAJ3D,IAAA,WAAW,IAAI,GAAA;;AAEb,QAAA,OAAO,qBAAqB,CAAC;KAC9B;AAEF,CAAA;AAED;;AAEG;MACU,qBAAqB,CAAA;AAKhC,IAAA,WAAA,CAAmB,OAAY,EAAA;QAAZ,IAAO,CAAA,OAAA,GAAP,OAAO,CAAK;KAAI;AAJnC,IAAA,WAAW,IAAI,GAAA;;AAEb,QAAA,OAAO,2BAA2B,CAAC;KACpC;AAEF,CAAA;AAED;;AAEG;MACU,mBAAmB,CAAA;AAC9B,IAAA,WAAW,IAAI,GAAA;;AAEb,QAAA,OAAO,wBAAwB,CAAC;KACjC;AACF,CAAA;AAED;;AAEG;MACU,kBAAkB,CAAA;AAC7B,IAAA,WAAW,IAAI,GAAA;AACb,QAAA,OAAO,uBAAuB,CAAC;KAChC;AACF,CAAA;AAED;;AAEG;MACU,qBAAqB,CAAA;AAChC,IAAA,WAAW,IAAI,GAAA;;AAEb,QAAA,OAAO,0BAA0B,CAAC;KACnC;AACF,CAAA;AAED;;AAEG;MACU,oBAAoB,CAAA;AAK/B,IAAA,WAAA,CAAmB,OAAY,EAAA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
1
1
|
/**
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
|
+
/// <amd-module name="@ngxs/websocket-plugin" />
|
|
4
5
|
export * from './index';
|
|
5
|
-
export { noop as ɵc } from './src/symbols';
|
|
6
|
-
export { WebSocketHandler as ɵd } from './src/websocket-handler';
|
|
7
|
-
export { USER_OPTIONS as ɵb, websocketOptionsFactory as ɵa } from './src/websocket.module';
|
package/package.json
CHANGED
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
"$schema": "../../node_modules/ng-packagr/package.schema.json",
|
|
3
3
|
"name": "@ngxs/websocket-plugin",
|
|
4
4
|
"description": "Websocket plugin for @ngxs/store",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.8.0-dev.master-c341c15",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@ngxs/store": "^3.7.6 || ^3.7.6-dev",
|
|
9
8
|
"@angular/core": ">=6.1.0 <16.0.0",
|
|
9
|
+
"@ngxs/store": "^3.8.0 || ^3.8.0-dev",
|
|
10
10
|
"rxjs": ">=6.5.5"
|
|
11
11
|
},
|
|
12
12
|
"main": "bundles/ngxs-websocket-plugin.umd.js",
|
|
13
|
-
"module": "
|
|
13
|
+
"module": "fesm2015/ngxs-websocket-plugin.js",
|
|
14
14
|
"es2015": "fesm2015/ngxs-websocket-plugin.js",
|
|
15
|
-
"esm5": "esm5/ngxs-websocket-plugin.js",
|
|
16
15
|
"esm2015": "esm2015/ngxs-websocket-plugin.js",
|
|
17
|
-
"fesm5": "fesm5/ngxs-websocket-plugin.js",
|
|
18
16
|
"fesm2015": "fesm2015/ngxs-websocket-plugin.js",
|
|
19
17
|
"typings": "ngxs-websocket-plugin.d.ts",
|
|
20
|
-
"metadata": "ngxs-websocket-plugin.metadata.json",
|
|
21
18
|
"dependencies": {
|
|
22
|
-
"tslib": "^
|
|
19
|
+
"tslib": "^2.2.0"
|
|
23
20
|
},
|
|
24
21
|
"repository": {
|
|
25
22
|
"type": "git",
|
|
@@ -65,4 +62,4 @@
|
|
|
65
62
|
"type": "opencollective",
|
|
66
63
|
"url": "https://opencollective.com/ngxs"
|
|
67
64
|
}
|
|
68
|
-
}
|
|
65
|
+
}
|