@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,374 +1,411 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store'), require('rxjs'), require('rxjs/webSocket')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@ngxs/websocket-plugin', ['exports', '@angular/core', '@ngxs/store', 'rxjs', 'rxjs/webSocket'], factory) :
|
|
4
|
-
(global = global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs[
|
|
5
|
-
}(this, function (exports,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs["websocket-plugin"] = {}), global.ng.core, global["ngxs-store"], global.rxjs, global.rxjs.webSocket));
|
|
5
|
+
})(this, (function (exports, i0, i1, rxjs, webSocket) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var extendStatics = function(d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var __assign = function() {
|
|
37
|
-
__assign = Object.assign || function __assign(t) {
|
|
38
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
|
-
s = arguments[i];
|
|
40
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
-
}
|
|
42
|
-
return t;
|
|
43
|
-
};
|
|
44
|
-
return __assign.apply(this, arguments);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function __rest(s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
-
t[p] = s[p];
|
|
51
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
-
t[p[i]] = s[p[i]];
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function __decorate(decorators, target, key, desc) {
|
|
60
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
62
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
63
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function __param(paramIndex, decorator) {
|
|
67
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function __metadata(metadataKey, metadataValue) {
|
|
71
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
75
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
76
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
77
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
78
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
79
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
80
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function __generator(thisArg, body) {
|
|
85
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
86
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
87
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
88
|
-
function step(op) {
|
|
89
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
90
|
-
while (_) try {
|
|
91
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
92
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
93
|
-
switch (op[0]) {
|
|
94
|
-
case 0: case 1: t = op; break;
|
|
95
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
96
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
97
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
98
|
-
default:
|
|
99
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
100
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
101
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
102
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
103
|
-
if (t[2]) _.ops.pop();
|
|
104
|
-
_.trys.pop(); continue;
|
|
105
|
-
}
|
|
106
|
-
op = body.call(thisArg, _);
|
|
107
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
108
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function __createBinding(o, m, k, k2) {
|
|
113
|
-
if (k2 === undefined) k2 = k;
|
|
114
|
-
o[k2] = m[k];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function __exportStar(m, exports) {
|
|
118
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function __values(o) {
|
|
122
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
123
|
-
if (m) return m.call(o);
|
|
124
|
-
if (o && typeof o.length === "number") return {
|
|
125
|
-
next: function () {
|
|
126
|
-
if (o && i >= o.length) o = void 0;
|
|
127
|
-
return { value: o && o[i++], done: !o };
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function __read(o, n) {
|
|
134
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
135
|
-
if (!m) return o;
|
|
136
|
-
var i = m.call(o), r, ar = [], e;
|
|
137
|
-
try {
|
|
138
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
139
|
-
}
|
|
140
|
-
catch (error) { e = { error: error }; }
|
|
141
|
-
finally {
|
|
142
|
-
try {
|
|
143
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
144
|
-
}
|
|
145
|
-
finally { if (e) throw e.error; }
|
|
146
|
-
}
|
|
147
|
-
return ar;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function __spread() {
|
|
151
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
152
|
-
ar = ar.concat(__read(arguments[i]));
|
|
153
|
-
return ar;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function __spreadArrays() {
|
|
157
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
158
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
159
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
160
|
-
r[k] = a[j];
|
|
161
|
-
return r;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
function __await(v) {
|
|
165
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
169
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
170
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
171
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
172
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
173
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
174
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
175
|
-
function fulfill(value) { resume("next", value); }
|
|
176
|
-
function reject(value) { resume("throw", value); }
|
|
177
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function __asyncDelegator(o) {
|
|
181
|
-
var i, p;
|
|
182
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
183
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function __asyncValues(o) {
|
|
187
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
188
|
-
var m = o[Symbol.asyncIterator], i;
|
|
189
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
190
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
191
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function __makeTemplateObject(cooked, raw) {
|
|
195
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
196
|
-
return cooked;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
function __importStar(mod) {
|
|
200
|
-
if (mod && mod.__esModule) return mod;
|
|
201
|
-
var result = {};
|
|
202
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
203
|
-
result.default = mod;
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function __importDefault(mod) {
|
|
208
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
212
|
-
if (!privateMap.has(receiver)) {
|
|
213
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
214
|
-
}
|
|
215
|
-
return privateMap.get(receiver);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
219
|
-
if (!privateMap.has(receiver)) {
|
|
220
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
221
|
-
}
|
|
222
|
-
privateMap.set(receiver, value);
|
|
223
|
-
return value;
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
224
23
|
}
|
|
225
24
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
* Default: 'type'
|
|
259
|
-
* @type {?|undefined}
|
|
260
|
-
*/
|
|
261
|
-
NgxsWebsocketPluginOptions.prototype.typeKey;
|
|
262
|
-
/**
|
|
263
|
-
* Interval to try and reconnect.
|
|
264
|
-
* Default: 5000
|
|
265
|
-
* @type {?|undefined}
|
|
266
|
-
*/
|
|
267
|
-
NgxsWebsocketPluginOptions.prototype.reconnectInterval;
|
|
268
|
-
/**
|
|
269
|
-
* Number of reconnect attemps.
|
|
270
|
-
* Default: 10
|
|
271
|
-
* @type {?|undefined}
|
|
272
|
-
*/
|
|
273
|
-
NgxsWebsocketPluginOptions.prototype.reconnectAttempts;
|
|
274
|
-
/**
|
|
275
|
-
* Serializer to call before sending messages
|
|
276
|
-
* Default: `json.stringify`
|
|
277
|
-
* @type {?|undefined}
|
|
278
|
-
*/
|
|
279
|
-
NgxsWebsocketPluginOptions.prototype.serializer;
|
|
280
|
-
/**
|
|
281
|
-
* Deseralizer before publishing the message.
|
|
282
|
-
* @type {?|undefined}
|
|
283
|
-
*/
|
|
284
|
-
NgxsWebsocketPluginOptions.prototype.deserializer;
|
|
25
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
26
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
27
|
+
|
|
28
|
+
/******************************************************************************
|
|
29
|
+
Copyright (c) Microsoft Corporation.
|
|
30
|
+
|
|
31
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
32
|
+
purpose with or without fee is hereby granted.
|
|
33
|
+
|
|
34
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
35
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
36
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
37
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
38
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
39
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
40
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
41
|
+
***************************************************************************** */
|
|
42
|
+
/* global Reflect, Promise */
|
|
43
|
+
var extendStatics = function (d, b) {
|
|
44
|
+
extendStatics = Object.setPrototypeOf ||
|
|
45
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
46
|
+
function (d, b) { for (var p in b)
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
48
|
+
d[p] = b[p]; };
|
|
49
|
+
return extendStatics(d, b);
|
|
50
|
+
};
|
|
51
|
+
function __extends(d, b) {
|
|
52
|
+
if (typeof b !== "function" && b !== null)
|
|
53
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
54
|
+
extendStatics(d, b);
|
|
55
|
+
function __() { this.constructor = d; }
|
|
56
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
285
57
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
58
|
+
var __assign = function () {
|
|
59
|
+
__assign = Object.assign || function __assign(t) {
|
|
60
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
61
|
+
s = arguments[i];
|
|
62
|
+
for (var p in s)
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
64
|
+
t[p] = s[p];
|
|
65
|
+
}
|
|
66
|
+
return t;
|
|
67
|
+
};
|
|
68
|
+
return __assign.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
function __rest(s, e) {
|
|
71
|
+
var t = {};
|
|
72
|
+
for (var p in s)
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
74
|
+
t[p] = s[p];
|
|
75
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
76
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
77
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
78
|
+
t[p[i]] = s[p[i]];
|
|
79
|
+
}
|
|
80
|
+
return t;
|
|
81
|
+
}
|
|
82
|
+
function __decorate(decorators, target, key, desc) {
|
|
83
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
84
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
85
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
86
|
+
else
|
|
87
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
88
|
+
if (d = decorators[i])
|
|
89
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
90
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
91
|
+
}
|
|
92
|
+
function __param(paramIndex, decorator) {
|
|
93
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
94
|
+
}
|
|
95
|
+
function __metadata(metadataKey, metadataValue) {
|
|
96
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
97
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
98
|
+
}
|
|
99
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
100
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
101
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
102
|
+
function fulfilled(value) { try {
|
|
103
|
+
step(generator.next(value));
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
reject(e);
|
|
107
|
+
} }
|
|
108
|
+
function rejected(value) { try {
|
|
109
|
+
step(generator["throw"](value));
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
reject(e);
|
|
113
|
+
} }
|
|
114
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
115
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function __generator(thisArg, body) {
|
|
119
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
120
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
121
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
122
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
123
|
+
function step(op) {
|
|
124
|
+
if (f)
|
|
125
|
+
throw new TypeError("Generator is already executing.");
|
|
126
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
127
|
+
try {
|
|
128
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
129
|
+
return t;
|
|
130
|
+
if (y = 0, t)
|
|
131
|
+
op = [op[0] & 2, t.value];
|
|
132
|
+
switch (op[0]) {
|
|
133
|
+
case 0:
|
|
134
|
+
case 1:
|
|
135
|
+
t = op;
|
|
136
|
+
break;
|
|
137
|
+
case 4:
|
|
138
|
+
_.label++;
|
|
139
|
+
return { value: op[1], done: false };
|
|
140
|
+
case 5:
|
|
141
|
+
_.label++;
|
|
142
|
+
y = op[1];
|
|
143
|
+
op = [0];
|
|
144
|
+
continue;
|
|
145
|
+
case 7:
|
|
146
|
+
op = _.ops.pop();
|
|
147
|
+
_.trys.pop();
|
|
148
|
+
continue;
|
|
149
|
+
default:
|
|
150
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
151
|
+
_ = 0;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
155
|
+
_.label = op[1];
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
159
|
+
_.label = t[1];
|
|
160
|
+
t = op;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (t && _.label < t[2]) {
|
|
164
|
+
_.label = t[2];
|
|
165
|
+
_.ops.push(op);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (t[2])
|
|
169
|
+
_.ops.pop();
|
|
170
|
+
_.trys.pop();
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
op = body.call(thisArg, _);
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
op = [6, e];
|
|
177
|
+
y = 0;
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
f = t = 0;
|
|
181
|
+
}
|
|
182
|
+
if (op[0] & 5)
|
|
183
|
+
throw op[1];
|
|
184
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
188
|
+
if (k2 === undefined)
|
|
189
|
+
k2 = k;
|
|
190
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
191
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
192
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
193
|
+
}
|
|
194
|
+
Object.defineProperty(o, k2, desc);
|
|
195
|
+
}) : (function (o, m, k, k2) {
|
|
196
|
+
if (k2 === undefined)
|
|
197
|
+
k2 = k;
|
|
198
|
+
o[k2] = m[k];
|
|
199
|
+
});
|
|
200
|
+
function __exportStar(m, o) {
|
|
201
|
+
for (var p in m)
|
|
202
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
203
|
+
__createBinding(o, m, p);
|
|
204
|
+
}
|
|
205
|
+
function __values(o) {
|
|
206
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
207
|
+
if (m)
|
|
208
|
+
return m.call(o);
|
|
209
|
+
if (o && typeof o.length === "number")
|
|
210
|
+
return {
|
|
211
|
+
next: function () {
|
|
212
|
+
if (o && i >= o.length)
|
|
213
|
+
o = void 0;
|
|
214
|
+
return { value: o && o[i++], done: !o };
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
218
|
+
}
|
|
219
|
+
function __read(o, n) {
|
|
220
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
221
|
+
if (!m)
|
|
222
|
+
return o;
|
|
223
|
+
var i = m.call(o), r, ar = [], e;
|
|
224
|
+
try {
|
|
225
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
226
|
+
ar.push(r.value);
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
e = { error: error };
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
try {
|
|
233
|
+
if (r && !r.done && (m = i["return"]))
|
|
234
|
+
m.call(i);
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
if (e)
|
|
238
|
+
throw e.error;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return ar;
|
|
242
|
+
}
|
|
243
|
+
/** @deprecated */
|
|
244
|
+
function __spread() {
|
|
245
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
246
|
+
ar = ar.concat(__read(arguments[i]));
|
|
247
|
+
return ar;
|
|
248
|
+
}
|
|
249
|
+
/** @deprecated */
|
|
250
|
+
function __spreadArrays() {
|
|
251
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
252
|
+
s += arguments[i].length;
|
|
253
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
254
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
255
|
+
r[k] = a[j];
|
|
256
|
+
return r;
|
|
257
|
+
}
|
|
258
|
+
function __spreadArray(to, from, pack) {
|
|
259
|
+
if (pack || arguments.length === 2)
|
|
260
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
261
|
+
if (ar || !(i in from)) {
|
|
262
|
+
if (!ar)
|
|
263
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
264
|
+
ar[i] = from[i];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
268
|
+
}
|
|
269
|
+
function __await(v) {
|
|
270
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
271
|
+
}
|
|
272
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
273
|
+
if (!Symbol.asyncIterator)
|
|
274
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
275
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
276
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
277
|
+
function verb(n) { if (g[n])
|
|
278
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
279
|
+
function resume(n, v) { try {
|
|
280
|
+
step(g[n](v));
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
settle(q[0][3], e);
|
|
284
|
+
} }
|
|
285
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
286
|
+
function fulfill(value) { resume("next", value); }
|
|
287
|
+
function reject(value) { resume("throw", value); }
|
|
288
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
289
|
+
resume(q[0][0], q[0][1]); }
|
|
290
|
+
}
|
|
291
|
+
function __asyncDelegator(o) {
|
|
292
|
+
var i, p;
|
|
293
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
294
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
295
|
+
}
|
|
296
|
+
function __asyncValues(o) {
|
|
297
|
+
if (!Symbol.asyncIterator)
|
|
298
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
299
|
+
var m = o[Symbol.asyncIterator], i;
|
|
300
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
301
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
302
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
303
|
+
}
|
|
304
|
+
function __makeTemplateObject(cooked, raw) {
|
|
305
|
+
if (Object.defineProperty) {
|
|
306
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
cooked.raw = raw;
|
|
310
|
+
}
|
|
311
|
+
return cooked;
|
|
312
|
+
}
|
|
313
|
+
;
|
|
314
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
315
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
316
|
+
}) : function (o, v) {
|
|
317
|
+
o["default"] = v;
|
|
318
|
+
};
|
|
319
|
+
function __importStar(mod) {
|
|
320
|
+
if (mod && mod.__esModule)
|
|
321
|
+
return mod;
|
|
322
|
+
var result = {};
|
|
323
|
+
if (mod != null)
|
|
324
|
+
for (var k in mod)
|
|
325
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
326
|
+
__createBinding(result, mod, k);
|
|
327
|
+
__setModuleDefault(result, mod);
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
330
|
+
function __importDefault(mod) {
|
|
331
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
332
|
+
}
|
|
333
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
334
|
+
if (kind === "a" && !f)
|
|
335
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
336
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
337
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
338
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
339
|
+
}
|
|
340
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
341
|
+
if (kind === "m")
|
|
342
|
+
throw new TypeError("Private method is not writable");
|
|
343
|
+
if (kind === "a" && !f)
|
|
344
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
345
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
346
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
347
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
348
|
+
}
|
|
349
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
350
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
|
351
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
352
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var NGXS_WEBSOCKET_OPTIONS = new i0.InjectionToken('NGXS_WEBSOCKET_OPTIONS');
|
|
290
356
|
function noop() {
|
|
291
357
|
var _args = [];
|
|
292
358
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
293
359
|
_args[_i] = arguments[_i];
|
|
294
360
|
}
|
|
295
|
-
return (
|
|
296
|
-
* @return {?}
|
|
297
|
-
*/
|
|
298
|
-
function () { });
|
|
361
|
+
return function () { };
|
|
299
362
|
}
|
|
300
363
|
/**
|
|
301
364
|
* Action to connect to the websocket. Optionally pass a URL.
|
|
302
365
|
*/
|
|
303
|
-
var
|
|
304
|
-
* Action to connect to the websocket. Optionally pass a URL.
|
|
305
|
-
*/
|
|
306
|
-
ConnectWebSocket = /** @class */ (function () {
|
|
366
|
+
var ConnectWebSocket = /** @class */ (function () {
|
|
307
367
|
function ConnectWebSocket(payload) {
|
|
308
368
|
this.payload = payload;
|
|
309
369
|
}
|
|
310
370
|
Object.defineProperty(ConnectWebSocket, "type", {
|
|
311
|
-
get:
|
|
312
|
-
* @return {?}
|
|
313
|
-
*/
|
|
314
|
-
function () {
|
|
371
|
+
get: function () {
|
|
315
372
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
316
373
|
return '[WebSocket] Connect';
|
|
317
374
|
},
|
|
318
|
-
enumerable:
|
|
375
|
+
enumerable: false,
|
|
319
376
|
configurable: true
|
|
320
377
|
});
|
|
321
378
|
return ConnectWebSocket;
|
|
322
379
|
}());
|
|
323
|
-
if (false) {
|
|
324
|
-
/** @type {?} */
|
|
325
|
-
ConnectWebSocket.prototype.payload;
|
|
326
|
-
}
|
|
327
380
|
/**
|
|
328
381
|
* Action triggered when a error ocurrs
|
|
329
382
|
*/
|
|
330
|
-
var
|
|
331
|
-
* Action triggered when a error ocurrs
|
|
332
|
-
*/
|
|
333
|
-
WebsocketMessageError = /** @class */ (function () {
|
|
383
|
+
var WebsocketMessageError = /** @class */ (function () {
|
|
334
384
|
function WebsocketMessageError(payload) {
|
|
335
385
|
this.payload = payload;
|
|
336
386
|
}
|
|
337
387
|
Object.defineProperty(WebsocketMessageError, "type", {
|
|
338
|
-
get:
|
|
339
|
-
* @return {?}
|
|
340
|
-
*/
|
|
341
|
-
function () {
|
|
388
|
+
get: function () {
|
|
342
389
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
343
390
|
return '[WebSocket] Message Error';
|
|
344
391
|
},
|
|
345
|
-
enumerable:
|
|
392
|
+
enumerable: false,
|
|
346
393
|
configurable: true
|
|
347
394
|
});
|
|
348
395
|
return WebsocketMessageError;
|
|
349
396
|
}());
|
|
350
|
-
if (false) {
|
|
351
|
-
/** @type {?} */
|
|
352
|
-
WebsocketMessageError.prototype.payload;
|
|
353
|
-
}
|
|
354
397
|
/**
|
|
355
398
|
* Action to disconnect the websocket.
|
|
356
399
|
*/
|
|
357
|
-
var
|
|
358
|
-
* Action to disconnect the websocket.
|
|
359
|
-
*/
|
|
360
|
-
DisconnectWebSocket = /** @class */ (function () {
|
|
400
|
+
var DisconnectWebSocket = /** @class */ (function () {
|
|
361
401
|
function DisconnectWebSocket() {
|
|
362
402
|
}
|
|
363
403
|
Object.defineProperty(DisconnectWebSocket, "type", {
|
|
364
|
-
get:
|
|
365
|
-
* @return {?}
|
|
366
|
-
*/
|
|
367
|
-
function () {
|
|
404
|
+
get: function () {
|
|
368
405
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
369
406
|
return '[WebSocket] Disconnect';
|
|
370
407
|
},
|
|
371
|
-
enumerable:
|
|
408
|
+
enumerable: false,
|
|
372
409
|
configurable: true
|
|
373
410
|
});
|
|
374
411
|
return DisconnectWebSocket;
|
|
@@ -376,20 +413,14 @@
|
|
|
376
413
|
/**
|
|
377
414
|
* Action triggered when websocket is connected
|
|
378
415
|
*/
|
|
379
|
-
var
|
|
380
|
-
* Action triggered when websocket is connected
|
|
381
|
-
*/
|
|
382
|
-
WebSocketConnected = /** @class */ (function () {
|
|
416
|
+
var WebSocketConnected = /** @class */ (function () {
|
|
383
417
|
function WebSocketConnected() {
|
|
384
418
|
}
|
|
385
419
|
Object.defineProperty(WebSocketConnected, "type", {
|
|
386
|
-
get:
|
|
387
|
-
* @return {?}
|
|
388
|
-
*/
|
|
389
|
-
function () {
|
|
420
|
+
get: function () {
|
|
390
421
|
return '[WebSocket] Connected';
|
|
391
422
|
},
|
|
392
|
-
enumerable:
|
|
423
|
+
enumerable: false,
|
|
393
424
|
configurable: true
|
|
394
425
|
});
|
|
395
426
|
return WebSocketConnected;
|
|
@@ -397,21 +428,15 @@
|
|
|
397
428
|
/**
|
|
398
429
|
* Action triggered when websocket is disconnected
|
|
399
430
|
*/
|
|
400
|
-
var
|
|
401
|
-
* Action triggered when websocket is disconnected
|
|
402
|
-
*/
|
|
403
|
-
WebSocketDisconnected = /** @class */ (function () {
|
|
431
|
+
var WebSocketDisconnected = /** @class */ (function () {
|
|
404
432
|
function WebSocketDisconnected() {
|
|
405
433
|
}
|
|
406
434
|
Object.defineProperty(WebSocketDisconnected, "type", {
|
|
407
|
-
get:
|
|
408
|
-
* @return {?}
|
|
409
|
-
*/
|
|
410
|
-
function () {
|
|
435
|
+
get: function () {
|
|
411
436
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
412
437
|
return '[WebSocket] Disconnected';
|
|
413
438
|
},
|
|
414
|
-
enumerable:
|
|
439
|
+
enumerable: false,
|
|
415
440
|
configurable: true
|
|
416
441
|
});
|
|
417
442
|
return WebSocketDisconnected;
|
|
@@ -419,48 +444,32 @@
|
|
|
419
444
|
/**
|
|
420
445
|
* Action to send to the server.
|
|
421
446
|
*/
|
|
422
|
-
var
|
|
423
|
-
* Action to send to the server.
|
|
424
|
-
*/
|
|
425
|
-
SendWebSocketMessage = /** @class */ (function () {
|
|
447
|
+
var SendWebSocketMessage = /** @class */ (function () {
|
|
426
448
|
function SendWebSocketMessage(payload) {
|
|
427
449
|
this.payload = payload;
|
|
428
450
|
}
|
|
429
451
|
Object.defineProperty(SendWebSocketMessage, "type", {
|
|
430
|
-
get:
|
|
431
|
-
* @return {?}
|
|
432
|
-
*/
|
|
433
|
-
function () {
|
|
452
|
+
get: function () {
|
|
434
453
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
435
454
|
return '[WebSocket] Send Message';
|
|
436
455
|
},
|
|
437
|
-
enumerable:
|
|
456
|
+
enumerable: false,
|
|
438
457
|
configurable: true
|
|
439
458
|
});
|
|
440
459
|
return SendWebSocketMessage;
|
|
441
460
|
}());
|
|
442
|
-
if (false) {
|
|
443
|
-
/** @type {?} */
|
|
444
|
-
SendWebSocketMessage.prototype.payload;
|
|
445
|
-
}
|
|
446
461
|
/**
|
|
447
462
|
* Action dispatched when the user tries to connect if the connection already exists.
|
|
448
463
|
*/
|
|
449
|
-
var
|
|
450
|
-
* Action dispatched when the user tries to connect if the connection already exists.
|
|
451
|
-
*/
|
|
452
|
-
WebSocketConnectionUpdated = /** @class */ (function () {
|
|
464
|
+
var WebSocketConnectionUpdated = /** @class */ (function () {
|
|
453
465
|
function WebSocketConnectionUpdated() {
|
|
454
466
|
}
|
|
455
467
|
Object.defineProperty(WebSocketConnectionUpdated, "type", {
|
|
456
|
-
get:
|
|
457
|
-
* @return {?}
|
|
458
|
-
*/
|
|
459
|
-
function () {
|
|
468
|
+
get: function () {
|
|
460
469
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
461
470
|
return '[WebSocket] Connection Updated';
|
|
462
471
|
},
|
|
463
|
-
enumerable:
|
|
472
|
+
enumerable: false,
|
|
464
473
|
configurable: true
|
|
465
474
|
});
|
|
466
475
|
return WebSocketConnectionUpdated;
|
|
@@ -469,11 +478,7 @@
|
|
|
469
478
|
* This error is thrown where there is no `type` (or custom `typeKey`) property
|
|
470
479
|
* on the message that came from the server side socket
|
|
471
480
|
*/
|
|
472
|
-
var /**
|
|
473
|
-
* This error is thrown where there is no `type` (or custom `typeKey`) property
|
|
474
|
-
* on the message that came from the server side socket
|
|
475
|
-
*/
|
|
476
|
-
TypeKeyPropertyMissingError = /** @class */ (function (_super) {
|
|
481
|
+
var TypeKeyPropertyMissingError = /** @class */ (function (_super) {
|
|
477
482
|
__extends(TypeKeyPropertyMissingError, _super);
|
|
478
483
|
function TypeKeyPropertyMissingError(typeKey) {
|
|
479
484
|
return _super.call(this, "Property " + typeKey + " is missing on the socket message") || this;
|
|
@@ -481,10 +486,6 @@
|
|
|
481
486
|
return TypeKeyPropertyMissingError;
|
|
482
487
|
}(Error));
|
|
483
488
|
|
|
484
|
-
/**
|
|
485
|
-
* @fileoverview added by tsickle
|
|
486
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
487
|
-
*/
|
|
488
489
|
var WebSocketHandler = /** @class */ (function () {
|
|
489
490
|
function WebSocketHandler(store, actions$, options) {
|
|
490
491
|
var _this = this;
|
|
@@ -493,89 +494,48 @@
|
|
|
493
494
|
this.options = options;
|
|
494
495
|
this.socket = null;
|
|
495
496
|
this.config = {
|
|
496
|
-
url:
|
|
497
|
+
url: this.options.url,
|
|
497
498
|
protocol: this.options.protocol,
|
|
498
499
|
// Default binary type is `blob` for the global `WebSocket`
|
|
499
500
|
binaryType: this.options.binaryType,
|
|
500
501
|
serializer: this.options.serializer,
|
|
501
502
|
deserializer: this.options.deserializer,
|
|
502
503
|
closeObserver: {
|
|
503
|
-
next: (
|
|
504
|
-
* @return {?}
|
|
505
|
-
*/
|
|
506
|
-
function () {
|
|
504
|
+
next: function () {
|
|
507
505
|
// ATTENTION!
|
|
508
506
|
// See https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/WebSocketSubject.ts#L340
|
|
509
507
|
// RxJS socket emits `onComplete` event only if `event.wasClean` is truthy
|
|
510
508
|
// and doesn't complete socket subject if it's falsy
|
|
511
509
|
_this.disconnect();
|
|
512
|
-
}
|
|
510
|
+
}
|
|
513
511
|
},
|
|
514
512
|
openObserver: {
|
|
515
|
-
next: (
|
|
516
|
-
* @return {?}
|
|
517
|
-
*/
|
|
518
|
-
function () { return _this.store.dispatch(new WebSocketConnected()); })
|
|
513
|
+
next: function () { return _this.store.dispatch(new WebSocketConnected()); }
|
|
519
514
|
}
|
|
520
515
|
};
|
|
521
|
-
this.typeKey =
|
|
516
|
+
this.typeKey = this.options.typeKey;
|
|
522
517
|
this.subscription = new rxjs.Subscription();
|
|
523
518
|
this.setupActionsListeners();
|
|
524
519
|
}
|
|
525
|
-
|
|
526
|
-
* @return {?}
|
|
527
|
-
*/
|
|
528
|
-
WebSocketHandler.prototype.ngOnDestroy = /**
|
|
529
|
-
* @return {?}
|
|
530
|
-
*/
|
|
531
|
-
function () {
|
|
520
|
+
WebSocketHandler.prototype.ngOnDestroy = function () {
|
|
532
521
|
this.closeConnection();
|
|
533
522
|
this.subscription.unsubscribe();
|
|
534
523
|
};
|
|
535
|
-
|
|
536
|
-
* @private
|
|
537
|
-
* @return {?}
|
|
538
|
-
*/
|
|
539
|
-
WebSocketHandler.prototype.setupActionsListeners = /**
|
|
540
|
-
* @private
|
|
541
|
-
* @return {?}
|
|
542
|
-
*/
|
|
543
|
-
function () {
|
|
524
|
+
WebSocketHandler.prototype.setupActionsListeners = function () {
|
|
544
525
|
var _this = this;
|
|
545
|
-
this.subscription.add(this.actions$.pipe(
|
|
546
|
-
* @param {?} __0
|
|
547
|
-
* @return {?}
|
|
548
|
-
*/
|
|
549
|
-
function (_a) {
|
|
526
|
+
this.subscription.add(this.actions$.pipe(i1.ofActionDispatched(ConnectWebSocket)).subscribe(function (_a) {
|
|
550
527
|
var payload = _a.payload;
|
|
551
528
|
_this.connect(payload);
|
|
552
|
-
}))
|
|
553
|
-
this.subscription.add(this.actions$.pipe(
|
|
554
|
-
* @return {?}
|
|
555
|
-
*/
|
|
556
|
-
function () {
|
|
529
|
+
}));
|
|
530
|
+
this.subscription.add(this.actions$.pipe(i1.ofActionDispatched(DisconnectWebSocket)).subscribe(function () {
|
|
557
531
|
_this.disconnect();
|
|
558
|
-
}))
|
|
559
|
-
this.subscription.add(this.actions$.pipe(
|
|
560
|
-
* @param {?} __0
|
|
561
|
-
* @return {?}
|
|
562
|
-
*/
|
|
563
|
-
function (_a) {
|
|
532
|
+
}));
|
|
533
|
+
this.subscription.add(this.actions$.pipe(i1.ofActionDispatched(SendWebSocketMessage)).subscribe(function (_a) {
|
|
564
534
|
var payload = _a.payload;
|
|
565
535
|
_this.send(payload);
|
|
566
|
-
}))
|
|
536
|
+
}));
|
|
567
537
|
};
|
|
568
|
-
|
|
569
|
-
* @private
|
|
570
|
-
* @param {?=} options
|
|
571
|
-
* @return {?}
|
|
572
|
-
*/
|
|
573
|
-
WebSocketHandler.prototype.connect = /**
|
|
574
|
-
* @private
|
|
575
|
-
* @param {?=} options
|
|
576
|
-
* @return {?}
|
|
577
|
-
*/
|
|
578
|
-
function (options) {
|
|
538
|
+
WebSocketHandler.prototype.connect = function (options) {
|
|
579
539
|
var _this = this;
|
|
580
540
|
this.updateConnection();
|
|
581
541
|
// Users can pass the options in the connect method so
|
|
@@ -586,57 +546,30 @@
|
|
|
586
546
|
}
|
|
587
547
|
this.socket = new webSocket.WebSocketSubject(this.config);
|
|
588
548
|
this.socket.subscribe({
|
|
589
|
-
next: (
|
|
590
|
-
|
|
591
|
-
* @return {?}
|
|
592
|
-
*/
|
|
593
|
-
function (message) {
|
|
594
|
-
/** @type {?} */
|
|
595
|
-
var type = store.getValue(message, _this.typeKey);
|
|
549
|
+
next: function (message) {
|
|
550
|
+
var type = i1.getValue(message, _this.typeKey);
|
|
596
551
|
if (!type) {
|
|
597
552
|
throw new TypeKeyPropertyMissingError(_this.typeKey);
|
|
598
553
|
}
|
|
599
|
-
_this.store.dispatch(
|
|
600
|
-
}
|
|
601
|
-
error: (
|
|
602
|
-
* @param {?} error
|
|
603
|
-
* @return {?}
|
|
604
|
-
*/
|
|
605
|
-
function (error) {
|
|
554
|
+
_this.store.dispatch(Object.assign(Object.assign({}, message), { type: type }));
|
|
555
|
+
},
|
|
556
|
+
error: function (error) {
|
|
606
557
|
if (error instanceof CloseEvent) {
|
|
607
558
|
_this.dispatchWebSocketDisconnected();
|
|
608
559
|
}
|
|
609
560
|
else {
|
|
610
561
|
_this.store.dispatch(new WebsocketMessageError(error));
|
|
611
562
|
}
|
|
612
|
-
}
|
|
563
|
+
}
|
|
613
564
|
});
|
|
614
565
|
};
|
|
615
|
-
|
|
616
|
-
* @private
|
|
617
|
-
* @return {?}
|
|
618
|
-
*/
|
|
619
|
-
WebSocketHandler.prototype.disconnect = /**
|
|
620
|
-
* @private
|
|
621
|
-
* @return {?}
|
|
622
|
-
*/
|
|
623
|
-
function () {
|
|
566
|
+
WebSocketHandler.prototype.disconnect = function () {
|
|
624
567
|
if (this.socket) {
|
|
625
568
|
this.closeConnection();
|
|
626
569
|
this.dispatchWebSocketDisconnected();
|
|
627
570
|
}
|
|
628
571
|
};
|
|
629
|
-
|
|
630
|
-
* @private
|
|
631
|
-
* @param {?} data
|
|
632
|
-
* @return {?}
|
|
633
|
-
*/
|
|
634
|
-
WebSocketHandler.prototype.send = /**
|
|
635
|
-
* @private
|
|
636
|
-
* @param {?} data
|
|
637
|
-
* @return {?}
|
|
638
|
-
*/
|
|
639
|
-
function (data) {
|
|
572
|
+
WebSocketHandler.prototype.send = function (data) {
|
|
640
573
|
if (!this.socket) {
|
|
641
574
|
throw new Error('You must connect to the socket before sending any data');
|
|
642
575
|
}
|
|
@@ -645,19 +578,7 @@
|
|
|
645
578
|
/**
|
|
646
579
|
* Don't enlarge the `connect` method
|
|
647
580
|
*/
|
|
648
|
-
|
|
649
|
-
* Don't enlarge the `connect` method
|
|
650
|
-
* @private
|
|
651
|
-
* @param {?} options
|
|
652
|
-
* @return {?}
|
|
653
|
-
*/
|
|
654
|
-
WebSocketHandler.prototype.mergeConfigWithOptions = /**
|
|
655
|
-
* Don't enlarge the `connect` method
|
|
656
|
-
* @private
|
|
657
|
-
* @param {?} options
|
|
658
|
-
* @return {?}
|
|
659
|
-
*/
|
|
660
|
-
function (options) {
|
|
581
|
+
WebSocketHandler.prototype.mergeConfigWithOptions = function (options) {
|
|
661
582
|
if (options.url) {
|
|
662
583
|
this.config.url = options.url;
|
|
663
584
|
}
|
|
@@ -674,23 +595,7 @@
|
|
|
674
595
|
* then the previous subscription will still live in the memory
|
|
675
596
|
* to prevent such behavior - we close the previous connection if it exists
|
|
676
597
|
*/
|
|
677
|
-
|
|
678
|
-
* To ensure we don't have any memory leaks
|
|
679
|
-
* e.g. if the user occasionally dispatched `ConnectWebSocket` twice
|
|
680
|
-
* then the previous subscription will still live in the memory
|
|
681
|
-
* to prevent such behavior - we close the previous connection if it exists
|
|
682
|
-
* @private
|
|
683
|
-
* @return {?}
|
|
684
|
-
*/
|
|
685
|
-
WebSocketHandler.prototype.updateConnection = /**
|
|
686
|
-
* To ensure we don't have any memory leaks
|
|
687
|
-
* e.g. if the user occasionally dispatched `ConnectWebSocket` twice
|
|
688
|
-
* then the previous subscription will still live in the memory
|
|
689
|
-
* to prevent such behavior - we close the previous connection if it exists
|
|
690
|
-
* @private
|
|
691
|
-
* @return {?}
|
|
692
|
-
*/
|
|
693
|
-
function () {
|
|
598
|
+
WebSocketHandler.prototype.updateConnection = function () {
|
|
694
599
|
if (this.socket) {
|
|
695
600
|
this.closeConnection();
|
|
696
601
|
this.store.dispatch(new WebSocketConnectionUpdated());
|
|
@@ -699,28 +604,10 @@
|
|
|
699
604
|
/**
|
|
700
605
|
* Used in many places so it's better to move the code into function
|
|
701
606
|
*/
|
|
702
|
-
|
|
703
|
-
* Used in many places so it's better to move the code into function
|
|
704
|
-
* @private
|
|
705
|
-
* @return {?}
|
|
706
|
-
*/
|
|
707
|
-
WebSocketHandler.prototype.dispatchWebSocketDisconnected = /**
|
|
708
|
-
* Used in many places so it's better to move the code into function
|
|
709
|
-
* @private
|
|
710
|
-
* @return {?}
|
|
711
|
-
*/
|
|
712
|
-
function () {
|
|
607
|
+
WebSocketHandler.prototype.dispatchWebSocketDisconnected = function () {
|
|
713
608
|
this.store.dispatch(new WebSocketDisconnected());
|
|
714
609
|
};
|
|
715
|
-
|
|
716
|
-
* @private
|
|
717
|
-
* @return {?}
|
|
718
|
-
*/
|
|
719
|
-
WebSocketHandler.prototype.closeConnection = /**
|
|
720
|
-
* @private
|
|
721
|
-
* @return {?}
|
|
722
|
-
*/
|
|
723
|
-
function () {
|
|
610
|
+
WebSocketHandler.prototype.closeConnection = function () {
|
|
724
611
|
// `socket.complete()` closes the connection
|
|
725
612
|
// also it doesn't invoke the `onComplete` callback that we passed
|
|
726
613
|
// into `socket.subscribe(...)`
|
|
@@ -729,93 +616,32 @@
|
|
|
729
616
|
this.socket = null;
|
|
730
617
|
}
|
|
731
618
|
};
|
|
732
|
-
WebSocketHandler.decorators = [
|
|
733
|
-
{ type: core.Injectable }
|
|
734
|
-
];
|
|
735
|
-
/** @nocollapse */
|
|
736
|
-
WebSocketHandler.ctorParameters = function () { return [
|
|
737
|
-
{ type: store.Store },
|
|
738
|
-
{ type: store.Actions },
|
|
739
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_WEBSOCKET_OPTIONS,] }] }
|
|
740
|
-
]; };
|
|
741
619
|
return WebSocketHandler;
|
|
742
620
|
}());
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
WebSocketHandler.prototype.config;
|
|
754
|
-
/**
|
|
755
|
-
* @type {?}
|
|
756
|
-
* @private
|
|
757
|
-
*/
|
|
758
|
-
WebSocketHandler.prototype.typeKey;
|
|
759
|
-
/**
|
|
760
|
-
* @type {?}
|
|
761
|
-
* @private
|
|
762
|
-
*/
|
|
763
|
-
WebSocketHandler.prototype.subscription;
|
|
764
|
-
/**
|
|
765
|
-
* @type {?}
|
|
766
|
-
* @private
|
|
767
|
-
*/
|
|
768
|
-
WebSocketHandler.prototype.store;
|
|
769
|
-
/**
|
|
770
|
-
* @type {?}
|
|
771
|
-
* @private
|
|
772
|
-
*/
|
|
773
|
-
WebSocketHandler.prototype.actions$;
|
|
774
|
-
/**
|
|
775
|
-
* @type {?}
|
|
776
|
-
* @private
|
|
777
|
-
*/
|
|
778
|
-
WebSocketHandler.prototype.options;
|
|
779
|
-
}
|
|
621
|
+
/** @nocollapse */ WebSocketHandler.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: WebSocketHandler, deps: [{ token: i1__namespace.Store }, { token: i1__namespace.Actions }, { token: NGXS_WEBSOCKET_OPTIONS }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
622
|
+
/** @nocollapse */ WebSocketHandler.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: WebSocketHandler });
|
|
623
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: WebSocketHandler, decorators: [{
|
|
624
|
+
type: i0.Injectable
|
|
625
|
+
}], ctorParameters: function () {
|
|
626
|
+
return [{ type: i1__namespace.Store }, { type: i1__namespace.Actions }, { type: undefined, decorators: [{
|
|
627
|
+
type: i0.Inject,
|
|
628
|
+
args: [NGXS_WEBSOCKET_OPTIONS]
|
|
629
|
+
}] }];
|
|
630
|
+
} });
|
|
780
631
|
|
|
781
|
-
/**
|
|
782
|
-
* @fileoverview added by tsickle
|
|
783
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
784
|
-
*/
|
|
785
|
-
/**
|
|
786
|
-
* @param {?} options
|
|
787
|
-
* @return {?}
|
|
788
|
-
*/
|
|
789
632
|
function websocketOptionsFactory(options) {
|
|
790
|
-
return
|
|
791
|
-
* @param {?} e
|
|
792
|
-
* @return {?}
|
|
793
|
-
*/
|
|
794
|
-
function (e) {
|
|
633
|
+
return Object.assign({ reconnectInterval: 5000, reconnectAttempts: 10, typeKey: 'type', deserializer: function (e) {
|
|
795
634
|
return JSON.parse(e.data);
|
|
796
635
|
},
|
|
797
|
-
serializer:
|
|
798
|
-
* @param {?} value
|
|
799
|
-
* @return {?}
|
|
800
|
-
*/
|
|
801
|
-
function (value) {
|
|
636
|
+
serializer: function (value) {
|
|
802
637
|
return JSON.stringify(value);
|
|
803
638
|
} }, options);
|
|
804
639
|
}
|
|
805
|
-
|
|
806
|
-
var USER_OPTIONS = new core.InjectionToken('USER_OPTIONS');
|
|
640
|
+
var USER_OPTIONS = new i0.InjectionToken('USER_OPTIONS');
|
|
807
641
|
var NgxsWebsocketPluginModule = /** @class */ (function () {
|
|
808
642
|
function NgxsWebsocketPluginModule() {
|
|
809
643
|
}
|
|
810
|
-
|
|
811
|
-
* @param {?=} options
|
|
812
|
-
* @return {?}
|
|
813
|
-
*/
|
|
814
|
-
NgxsWebsocketPluginModule.forRoot = /**
|
|
815
|
-
* @param {?=} options
|
|
816
|
-
* @return {?}
|
|
817
|
-
*/
|
|
818
|
-
function (options) {
|
|
644
|
+
NgxsWebsocketPluginModule.forRoot = function (options) {
|
|
819
645
|
return {
|
|
820
646
|
ngModule: NgxsWebsocketPluginModule,
|
|
821
647
|
providers: [
|
|
@@ -830,7 +656,7 @@
|
|
|
830
656
|
deps: [USER_OPTIONS]
|
|
831
657
|
},
|
|
832
658
|
{
|
|
833
|
-
provide:
|
|
659
|
+
provide: i0.APP_INITIALIZER,
|
|
834
660
|
useFactory: noop,
|
|
835
661
|
deps: [WebSocketHandler],
|
|
836
662
|
multi: true
|
|
@@ -838,11 +664,22 @@
|
|
|
838
664
|
]
|
|
839
665
|
};
|
|
840
666
|
};
|
|
841
|
-
NgxsWebsocketPluginModule.decorators = [
|
|
842
|
-
{ type: core.NgModule }
|
|
843
|
-
];
|
|
844
667
|
return NgxsWebsocketPluginModule;
|
|
845
668
|
}());
|
|
669
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsWebsocketPluginModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
670
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsWebsocketPluginModule });
|
|
671
|
+
/** @nocollapse */ NgxsWebsocketPluginModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsWebsocketPluginModule });
|
|
672
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsWebsocketPluginModule, decorators: [{
|
|
673
|
+
type: i0.NgModule
|
|
674
|
+
}] });
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* The public api for consumers of @ngxs/websocket-plugin
|
|
678
|
+
*/
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Generated bundle index. Do not edit.
|
|
682
|
+
*/
|
|
846
683
|
|
|
847
684
|
exports.ConnectWebSocket = ConnectWebSocket;
|
|
848
685
|
exports.DisconnectWebSocket = DisconnectWebSocket;
|
|
@@ -853,10 +690,6 @@
|
|
|
853
690
|
exports.WebSocketConnectionUpdated = WebSocketConnectionUpdated;
|
|
854
691
|
exports.WebSocketDisconnected = WebSocketDisconnected;
|
|
855
692
|
exports.WebsocketMessageError = WebsocketMessageError;
|
|
856
|
-
exports.ɵa = websocketOptionsFactory;
|
|
857
|
-
exports.ɵb = USER_OPTIONS;
|
|
858
|
-
exports.ɵc = noop;
|
|
859
|
-
exports.ɵd = WebSocketHandler;
|
|
860
693
|
|
|
861
694
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
862
695
|
|