@ngxs/websocket-plugin 18.1.2-dev.master-cbc269d → 18.1.2-dev.master-eaf3f9d

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2018 <amcdaniel2@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.d.ts CHANGED
@@ -1,8 +1,104 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, ModuleWithProviders, EnvironmentProviders } from '@angular/core';
3
+
4
+ declare const NGXS_WEBSOCKET_OPTIONS: InjectionToken<NgxsWebSocketPluginOptions>;
5
+ interface NgxsWebSocketPluginOptions {
6
+ /**
7
+ * URL of the websocket.
8
+ */
9
+ url?: string;
10
+ /**
11
+ * Either a single protocol string or an array of protocol strings.
12
+ * These strings are used to indicate sub-protocols, so that a single server
13
+ * can implement multiple WebSocket sub-protocols (for example, you might want one server to be able
14
+ * to handle different types of interactions depending on the specified protocol).
15
+ * If you don't specify a protocol string, an empty string is assumed.
16
+ */
17
+ protocol?: string | string[];
18
+ /**
19
+ * Sets the `binaryType` property of the underlying WebSocket.
20
+ */
21
+ binaryType?: 'blob' | 'arraybuffer';
22
+ /**
23
+ * The property name to distigunish this type for the store.
24
+ * Default: 'type'
25
+ */
26
+ typeKey?: string;
27
+ /**
28
+ * Interval to try and reconnect.
29
+ * Default: 5000
30
+ */
31
+ reconnectInterval?: number;
32
+ /**
33
+ * Number of reconnect attemps.
34
+ * Default: 10
35
+ */
36
+ reconnectAttempts?: number;
37
+ /**
38
+ * Serializer to call before sending messages
39
+ * Default: `json.stringify`
40
+ */
41
+ serializer?: (data: any) => string;
42
+ /**
43
+ * Deseralizer before publishing the message.
44
+ */
45
+ deserializer?: (e: MessageEvent) => any;
46
+ }
1
47
  /**
2
- * The public api for consumers of @ngxs/websocket-plugin
48
+ * Action to connect to the websocket. Optionally pass a URL.
3
49
  */
4
- export * from './src/public_api';
50
+ declare class ConnectWebSocket {
51
+ payload?: NgxsWebSocketPluginOptions | undefined;
52
+ static readonly type = "[WebSocket] Connect";
53
+ constructor(payload?: NgxsWebSocketPluginOptions | undefined);
54
+ }
5
55
  /**
6
- * The private api for consumers of @ngxs/websocket-plugin
56
+ * Action triggered when a error ocurrs
7
57
  */
8
- export * from './src/private_api';
58
+ declare class WebSocketMessageError {
59
+ payload: any;
60
+ static readonly type = "[WebSocket] Message Error";
61
+ constructor(payload: any);
62
+ }
63
+ /**
64
+ * Action to disconnect the websocket.
65
+ */
66
+ declare class DisconnectWebSocket {
67
+ static readonly type = "[WebSocket] Disconnect";
68
+ }
69
+ /**
70
+ * Action triggered when websocket is connected
71
+ */
72
+ declare class WebSocketConnected {
73
+ static readonly type = "[WebSocket] Connected";
74
+ }
75
+ /**
76
+ * Action triggered when websocket is disconnected
77
+ */
78
+ declare class WebSocketDisconnected {
79
+ static readonly type = "[WebSocket] Disconnected";
80
+ }
81
+ /**
82
+ * Action to send to the server.
83
+ */
84
+ declare class SendWebSocketMessage {
85
+ payload: any;
86
+ static readonly type = "[WebSocket] Send Message";
87
+ constructor(payload: any);
88
+ }
89
+ /**
90
+ * Action dispatched when the user tries to connect if the connection already exists.
91
+ */
92
+ declare class WebSocketConnectionUpdated {
93
+ static readonly type = "[WebSocket] Connection Updated";
94
+ }
95
+
96
+ declare class NgxsWebSocketPluginModule {
97
+ static forRoot(options?: NgxsWebSocketPluginOptions): ModuleWithProviders<NgxsWebSocketPluginModule>;
98
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsWebSocketPluginModule, never>;
99
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsWebSocketPluginModule, never, never, never>;
100
+ static ɵinj: i0.ɵɵInjectorDeclaration<NgxsWebSocketPluginModule>;
101
+ }
102
+ declare function withNgxsWebSocketPlugin(options?: NgxsWebSocketPluginOptions): EnvironmentProviders;
103
+
104
+ export { ConnectWebSocket, DisconnectWebSocket, NgxsWebSocketPluginModule, SendWebSocketMessage, WebSocketConnected, WebSocketConnectionUpdated, WebSocketDisconnected, WebSocketMessageError, withNgxsWebSocketPlugin, NGXS_WEBSOCKET_OPTIONS as ɵNGXS_WEBSOCKET_OPTIONS };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ngxs/websocket-plugin",
3
3
  "description": "WebSocket plugin for @ngxs/store",
4
- "version": "18.1.2-dev.master-cbc269d",
4
+ "version": "18.1.2-dev.master-eaf3f9d",
5
5
  "sideEffects": true,
6
6
  "peerDependencies": {
7
7
  "@angular/core": ">=16.0.0 <19.0.0",
@@ -1 +0,0 @@
1
- export { NGXS_WEBSOCKET_OPTIONS as ɵNGXS_WEBSOCKET_OPTIONS } from './symbols';
@@ -1,31 +0,0 @@
1
- import { WebSocketHandler } from './websocket-handler';
2
- import { NgxsWebSocketPluginOptions } from './symbols';
3
- export declare function ɵwebsocketOptionsFactory(options: NgxsWebSocketPluginOptions): {
4
- url?: string | undefined;
5
- protocol?: string | string[] | undefined;
6
- binaryType?: "blob" | "arraybuffer" | undefined;
7
- typeKey: string;
8
- reconnectInterval: number;
9
- reconnectAttempts: number;
10
- serializer: (data: any) => string;
11
- deserializer: (e: MessageEvent<any>) => any;
12
- };
13
- export declare function ɵgetProviders(options?: NgxsWebSocketPluginOptions): ({
14
- provide: import("@angular/core").InjectionToken<unknown>;
15
- useValue: NgxsWebSocketPluginOptions | undefined;
16
- useFactory?: undefined;
17
- deps?: undefined;
18
- multi?: undefined;
19
- } | {
20
- provide: import("@angular/core").InjectionToken<NgxsWebSocketPluginOptions>;
21
- useFactory: typeof ɵwebsocketOptionsFactory;
22
- deps: import("@angular/core").InjectionToken<unknown>[];
23
- useValue?: undefined;
24
- multi?: undefined;
25
- } | {
26
- provide: import("@angular/core").InjectionToken<readonly (() => void | import("rxjs").Observable<unknown> | Promise<unknown>)[]>;
27
- useFactory: () => () => void;
28
- deps: (typeof WebSocketHandler)[];
29
- multi: boolean;
30
- useValue?: undefined;
31
- })[];
@@ -1,2 +0,0 @@
1
- export { NgxsWebSocketPluginModule, withNgxsWebSocketPlugin } from './websocket.module';
2
- export { ConnectWebSocket, WebSocketMessageError, DisconnectWebSocket, WebSocketDisconnected, SendWebSocketMessage, WebSocketConnectionUpdated, WebSocketConnected } from './symbols';
package/src/symbols.d.ts DELETED
@@ -1,100 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- export declare const NGXS_WEBSOCKET_OPTIONS: InjectionToken<NgxsWebSocketPluginOptions>;
3
- export declare const USER_OPTIONS: InjectionToken<unknown>;
4
- export interface NgxsWebSocketPluginOptions {
5
- /**
6
- * URL of the websocket.
7
- */
8
- url?: string;
9
- /**
10
- * Either a single protocol string or an array of protocol strings.
11
- * These strings are used to indicate sub-protocols, so that a single server
12
- * can implement multiple WebSocket sub-protocols (for example, you might want one server to be able
13
- * to handle different types of interactions depending on the specified protocol).
14
- * If you don't specify a protocol string, an empty string is assumed.
15
- */
16
- protocol?: string | string[];
17
- /**
18
- * Sets the `binaryType` property of the underlying WebSocket.
19
- */
20
- binaryType?: 'blob' | 'arraybuffer';
21
- /**
22
- * The property name to distigunish this type for the store.
23
- * Default: 'type'
24
- */
25
- typeKey?: string;
26
- /**
27
- * Interval to try and reconnect.
28
- * Default: 5000
29
- */
30
- reconnectInterval?: number;
31
- /**
32
- * Number of reconnect attemps.
33
- * Default: 10
34
- */
35
- reconnectAttempts?: number;
36
- /**
37
- * Serializer to call before sending messages
38
- * Default: `json.stringify`
39
- */
40
- serializer?: (data: any) => string;
41
- /**
42
- * Deseralizer before publishing the message.
43
- */
44
- deserializer?: (e: MessageEvent) => any;
45
- }
46
- /**
47
- * Action to connect to the websocket. Optionally pass a URL.
48
- */
49
- export declare class ConnectWebSocket {
50
- payload?: NgxsWebSocketPluginOptions | undefined;
51
- static readonly type = "[WebSocket] Connect";
52
- constructor(payload?: NgxsWebSocketPluginOptions | undefined);
53
- }
54
- /**
55
- * Action triggered when a error ocurrs
56
- */
57
- export declare class WebSocketMessageError {
58
- payload: any;
59
- static readonly type = "[WebSocket] Message Error";
60
- constructor(payload: any);
61
- }
62
- /**
63
- * Action to disconnect the websocket.
64
- */
65
- export declare class DisconnectWebSocket {
66
- static readonly type = "[WebSocket] Disconnect";
67
- }
68
- /**
69
- * Action triggered when websocket is connected
70
- */
71
- export declare class WebSocketConnected {
72
- static readonly type = "[WebSocket] Connected";
73
- }
74
- /**
75
- * Action triggered when websocket is disconnected
76
- */
77
- export declare class WebSocketDisconnected {
78
- static readonly type = "[WebSocket] Disconnected";
79
- }
80
- /**
81
- * Action to send to the server.
82
- */
83
- export declare class SendWebSocketMessage {
84
- payload: any;
85
- static readonly type = "[WebSocket] Send Message";
86
- constructor(payload: any);
87
- }
88
- /**
89
- * Action dispatched when the user tries to connect if the connection already exists.
90
- */
91
- export declare class WebSocketConnectionUpdated {
92
- static readonly type = "[WebSocket] Connection Updated";
93
- }
94
- /**
95
- * This error is thrown where there is no `type` (or custom `typeKey`) property
96
- * on the message that came from the server side socket
97
- */
98
- export declare class TypeKeyPropertyMissingError extends Error {
99
- constructor(typeKey: string);
100
- }
@@ -1,23 +0,0 @@
1
- import { OnDestroy, NgZone } from '@angular/core';
2
- import { Actions, Store } from '@ngxs/store';
3
- import { NgxsWebSocketPluginOptions } from './symbols';
4
- import * as i0 from "@angular/core";
5
- export declare class WebSocketHandler implements OnDestroy {
6
- private _store;
7
- private _ngZone;
8
- private _actions$;
9
- private _options;
10
- private _socket;
11
- private readonly _socketClosed$;
12
- private readonly _typeKey;
13
- private readonly _destroy$;
14
- constructor(_store: Store, _ngZone: NgZone, _actions$: Actions, _options: NgxsWebSocketPluginOptions);
15
- ngOnDestroy(): void;
16
- private _setupActionsListeners;
17
- private connect;
18
- private _disconnect;
19
- private send;
20
- private _closeConnection;
21
- static ɵfac: i0.ɵɵFactoryDeclaration<WebSocketHandler, never>;
22
- static ɵprov: i0.ɵɵInjectableDeclaration<WebSocketHandler>;
23
- }
@@ -1,10 +0,0 @@
1
- import { ModuleWithProviders, EnvironmentProviders } from '@angular/core';
2
- import { NgxsWebSocketPluginOptions } from './symbols';
3
- import * as i0 from "@angular/core";
4
- export declare class NgxsWebSocketPluginModule {
5
- static forRoot(options?: NgxsWebSocketPluginOptions): ModuleWithProviders<NgxsWebSocketPluginModule>;
6
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxsWebSocketPluginModule, never>;
7
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsWebSocketPluginModule, never, never, never>;
8
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxsWebSocketPluginModule>;
9
- }
10
- export declare function withNgxsWebSocketPlugin(options?: NgxsWebSocketPluginOptions): EnvironmentProviders;