@stomp/stompjs 6.0.0-beta1 → 6.1.0

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.
@@ -96,16 +96,55 @@ return /******/ (function(modules) { // webpackBootstrap
96
96
  /************************************************************************/
97
97
  /******/ ({
98
98
 
99
+ /***/ "./src/augment-websocket.ts":
100
+ /*!**********************************!*\
101
+ !*** ./src/augment-websocket.ts ***!
102
+ \**********************************/
103
+ /*! exports provided: augmentWebsocket */
104
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
+
106
+ "use strict";
107
+ __webpack_require__.r(__webpack_exports__);
108
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "augmentWebsocket", function() { return augmentWebsocket; });
109
+ /**
110
+ * @internal
111
+ */
112
+ function augmentWebsocket(webSocket, debug) {
113
+ webSocket.terminate = function () {
114
+ const noOp = () => { };
115
+ // set all callbacks to no op
116
+ this.onerror = noOp;
117
+ this.onmessage = noOp;
118
+ this.onopen = noOp;
119
+ const ts = new Date();
120
+ const origOnClose = this.onclose;
121
+ // Track delay in actual closure of the socket
122
+ this.onclose = closeEvent => {
123
+ const delay = new Date().getTime() - ts.getTime();
124
+ debug(`Discarded socket closed after ${delay}ms, with code/reason: ${closeEvent.code}/${closeEvent.reason}`);
125
+ };
126
+ this.close();
127
+ origOnClose.call(this, {
128
+ code: 4001,
129
+ reason: 'Heartbeat failure, discarding the socket',
130
+ wasClean: false,
131
+ });
132
+ };
133
+ }
134
+
135
+
136
+ /***/ }),
137
+
99
138
  /***/ "./src/byte.ts":
100
139
  /*!*********************!*\
101
140
  !*** ./src/byte.ts ***!
102
141
  \*********************/
103
- /*! no static exports found */
104
- /***/ (function(module, exports, __webpack_require__) {
142
+ /*! exports provided: BYTE */
143
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
144
 
106
145
  "use strict";
107
-
108
- Object.defineProperty(exports, "__esModule", { value: true });
146
+ __webpack_require__.r(__webpack_exports__);
147
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BYTE", function() { return BYTE; });
109
148
  /**
110
149
  * Some byte values, used as per STOMP specifications.
111
150
  *
@@ -113,11 +152,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
113
152
  *
114
153
  * @internal
115
154
  */
116
- exports.BYTE = {
155
+ const BYTE = {
117
156
  // LINEFEED byte (octet 10)
118
157
  LF: '\x0A',
119
158
  // NULL byte (octet 0)
120
- NULL: '\x00'
159
+ NULL: '\x00',
121
160
  };
122
161
 
123
162
 
@@ -127,12 +166,16 @@ exports.BYTE = {
127
166
  /*!***********************!*\
128
167
  !*** ./src/client.ts ***!
129
168
  \***********************/
130
- /*! no static exports found */
131
- /***/ (function(module, exports, __webpack_require__) {
169
+ /*! exports provided: Client */
170
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
132
171
 
133
172
  "use strict";
134
-
135
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
173
+ __webpack_require__.r(__webpack_exports__);
174
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Client", function() { return Client; });
175
+ /* harmony import */ var _stomp_handler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./stomp-handler */ "./src/stomp-handler.ts");
176
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./src/types.ts");
177
+ /* harmony import */ var _versions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./versions */ "./src/versions.ts");
178
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
136
179
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
137
180
  return new (P || (P = Promise))(function (resolve, reject) {
138
181
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -141,48 +184,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
141
184
  step((generator = generator.apply(thisArg, _arguments || [])).next());
142
185
  });
143
186
  };
144
- var __generator = (this && this.__generator) || function (thisArg, body) {
145
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
146
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
147
- function verb(n) { return function (v) { return step([n, v]); }; }
148
- function step(op) {
149
- if (f) throw new TypeError("Generator is already executing.");
150
- while (_) try {
151
- 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;
152
- if (y = 0, t) op = [op[0] & 2, t.value];
153
- switch (op[0]) {
154
- case 0: case 1: t = op; break;
155
- case 4: _.label++; return { value: op[1], done: false };
156
- case 5: _.label++; y = op[1]; op = [0]; continue;
157
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
158
- default:
159
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
160
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
161
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
162
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
163
- if (t[2]) _.ops.pop();
164
- _.trys.pop(); continue;
165
- }
166
- op = body.call(thisArg, _);
167
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
168
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
169
- }
170
- };
171
- Object.defineProperty(exports, "__esModule", { value: true });
172
- var stomp_handler_1 = __webpack_require__(/*! ./stomp-handler */ "./src/stomp-handler.ts");
173
- var types_1 = __webpack_require__(/*! ./types */ "./src/types.ts");
174
- var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
187
+
188
+
189
+
175
190
  /**
176
191
  * STOMP Client Class.
177
192
  *
178
193
  * Part of `@stomp/stompjs`.
179
194
  */
180
- var Client = /** @class */ (function () {
195
+ class Client {
181
196
  /**
182
197
  * Create an instance.
183
198
  */
184
- function Client(conf) {
185
- if (conf === void 0) { conf = {}; }
199
+ constructor(conf = {}) {
186
200
  /**
187
201
  * STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
188
202
  *
@@ -192,7 +206,12 @@ var Client = /** @class */ (function () {
192
206
  * client.stompVersions = new Versions(['1.0', '1.1'])
193
207
  * ```
194
208
  */
195
- this.stompVersions = versions_1.Versions.default;
209
+ this.stompVersions = _versions__WEBPACK_IMPORTED_MODULE_2__["Versions"].default;
210
+ /**
211
+ * Will retry if Stomp connection is not established in specified milliseconds.
212
+ * Default 0, which implies wait for ever.
213
+ */
214
+ this.connectionTimeout = 0;
196
215
  /**
197
216
  * automatically reconnect with delay in milliseconds, set to 0 to disable.
198
217
  */
@@ -244,9 +263,15 @@ var Client = /** @class */ (function () {
244
263
  * This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
245
264
  */
246
265
  this.appendMissingNULLonIncoming = false;
247
- this._active = false;
266
+ /**
267
+ * Activation state.
268
+ *
269
+ * It will usually be ACTIVE or INACTIVE.
270
+ * When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
271
+ */
272
+ this.state = _types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].INACTIVE;
248
273
  // Dummy callbacks
249
- var noOp = function () { };
274
+ const noOp = () => { };
250
275
  this.debug = noOp;
251
276
  this.beforeConnect = noOp;
252
277
  this.onConnect = noOp;
@@ -258,75 +283,60 @@ var Client = /** @class */ (function () {
258
283
  this.onWebSocketClose = noOp;
259
284
  this.onWebSocketError = noOp;
260
285
  this.logRawCommunication = false;
286
+ this.onChangeState = noOp;
261
287
  // These parameters would typically get proper values before connect is called
262
288
  this.connectHeaders = {};
263
289
  this._disconnectHeaders = {};
264
290
  // Apply configuration
265
291
  this.configure(conf);
266
292
  }
267
- Object.defineProperty(Client.prototype, "webSocket", {
268
- /**
269
- * Underlying WebSocket instance, READONLY.
270
- */
271
- get: function () {
272
- return this._webSocket;
273
- },
274
- enumerable: true,
275
- configurable: true
276
- });
277
- Object.defineProperty(Client.prototype, "disconnectHeaders", {
278
- /**
279
- * Disconnection headers.
280
- */
281
- get: function () {
282
- return this._disconnectHeaders;
283
- },
284
- set: function (value) {
285
- this._disconnectHeaders = value;
286
- if (this._stompHandler) {
287
- this._stompHandler.disconnectHeaders = this._disconnectHeaders;
288
- }
289
- },
290
- enumerable: true,
291
- configurable: true
292
- });
293
- Object.defineProperty(Client.prototype, "connected", {
294
- /**
295
- * `true` if there is a active connection with STOMP Broker
296
- */
297
- get: function () {
298
- return (!!this._stompHandler) && this._stompHandler.connected;
299
- },
300
- enumerable: true,
301
- configurable: true
302
- });
303
- Object.defineProperty(Client.prototype, "connectedVersion", {
304
- /**
305
- * version of STOMP protocol negotiated with the server, READONLY
306
- */
307
- get: function () {
308
- return this._stompHandler ? this._stompHandler.connectedVersion : undefined;
309
- },
310
- enumerable: true,
311
- configurable: true
312
- });
313
- Object.defineProperty(Client.prototype, "active", {
314
- /**
315
- * if the client is active (connected or going to reconnect)
316
- */
317
- get: function () {
318
- return this._active;
319
- },
320
- enumerable: true,
321
- configurable: true
322
- });
293
+ /**
294
+ * Underlying WebSocket instance, READONLY.
295
+ */
296
+ get webSocket() {
297
+ return this._stompHandler ? this._stompHandler._webSocket : undefined;
298
+ }
299
+ /**
300
+ * Disconnection headers.
301
+ */
302
+ get disconnectHeaders() {
303
+ return this._disconnectHeaders;
304
+ }
305
+ set disconnectHeaders(value) {
306
+ this._disconnectHeaders = value;
307
+ if (this._stompHandler) {
308
+ this._stompHandler.disconnectHeaders = this._disconnectHeaders;
309
+ }
310
+ }
311
+ /**
312
+ * `true` if there is a active connection with STOMP Broker
313
+ */
314
+ get connected() {
315
+ return !!this._stompHandler && this._stompHandler.connected;
316
+ }
317
+ /**
318
+ * version of STOMP protocol negotiated with the server, READONLY
319
+ */
320
+ get connectedVersion() {
321
+ return this._stompHandler ? this._stompHandler.connectedVersion : undefined;
322
+ }
323
+ /**
324
+ * if the client is active (connected or going to reconnect)
325
+ */
326
+ get active() {
327
+ return this.state === _types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].ACTIVE;
328
+ }
329
+ _changeState(state) {
330
+ this.state = state;
331
+ this.onChangeState(state);
332
+ }
323
333
  /**
324
334
  * Update configuration.
325
335
  */
326
- Client.prototype.configure = function (conf) {
336
+ configure(conf) {
327
337
  // bulk assign all properties to this
328
338
  Object.assign(this, conf);
329
- };
339
+ }
330
340
  /**
331
341
  * Initiate the connection with the broker.
332
342
  * If the connection breaks, as per [Client#reconnectDelay]{@link Client#reconnectDelay},
@@ -334,86 +344,106 @@ var Client = /** @class */ (function () {
334
344
  *
335
345
  * Call [Client#deactivate]{@link Client#deactivate} to disconnect and stop reconnection attempts.
336
346
  */
337
- Client.prototype.activate = function () {
338
- this._active = true;
347
+ activate() {
348
+ if (this.state === _types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].DEACTIVATING) {
349
+ this.debug('Still DEACTIVATING, please await call to deactivate before trying to re-activate');
350
+ throw new Error('Still DEACTIVATING, can not activate now');
351
+ }
352
+ if (this.active) {
353
+ this.debug('Already ACTIVE, ignoring request to activate');
354
+ return;
355
+ }
356
+ this._changeState(_types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].ACTIVE);
339
357
  this._connect();
340
- };
341
- Client.prototype._connect = function () {
342
- return __awaiter(this, void 0, void 0, function () {
343
- var _this = this;
344
- return __generator(this, function (_a) {
345
- switch (_a.label) {
346
- case 0:
347
- if (this.connected) {
348
- this.debug('STOMP: already connected, nothing to do');
349
- return [2 /*return*/];
350
- }
351
- return [4 /*yield*/, this.beforeConnect()];
352
- case 1:
353
- _a.sent();
354
- if (!this._active) {
355
- this.debug('Client has been marked inactive, will not attempt to connect');
356
- return [2 /*return*/];
357
- }
358
- this.debug('Opening Web Socket...');
359
- // Get the actual WebSocket (or a similar object)
360
- this._webSocket = this._createWebSocket();
361
- this._stompHandler = new stomp_handler_1.StompHandler(this, this._webSocket, {
362
- debug: this.debug,
363
- stompVersions: this.stompVersions,
364
- connectHeaders: this.connectHeaders,
365
- disconnectHeaders: this._disconnectHeaders,
366
- heartbeatIncoming: this.heartbeatIncoming,
367
- heartbeatOutgoing: this.heartbeatOutgoing,
368
- splitLargeFrames: this.splitLargeFrames,
369
- maxWebSocketChunkSize: this.maxWebSocketChunkSize,
370
- forceBinaryWSFrames: this.forceBinaryWSFrames,
371
- logRawCommunication: this.logRawCommunication,
372
- appendMissingNULLonIncoming: this.appendMissingNULLonIncoming,
373
- discardWebsocketOnCommFailure: this.discardWebsocketOnCommFailure,
374
- onConnect: function (frame) {
375
- if (!_this._active) {
376
- _this.debug('STOMP got connected while deactivate was issued, will disconnect now');
377
- _this._disposeStompHandler();
378
- return;
379
- }
380
- _this.onConnect(frame);
381
- },
382
- onDisconnect: function (frame) {
383
- _this.onDisconnect(frame);
384
- },
385
- onStompError: function (frame) {
386
- _this.onStompError(frame);
387
- },
388
- onWebSocketClose: function (evt) {
389
- _this.onWebSocketClose(evt);
390
- // The callback is called before attempting to reconnect, this would allow the client
391
- // to be `deactivated` in the callback.
392
- if (_this._active) {
393
- _this._schedule_reconnect();
394
- }
395
- },
396
- onWebSocketError: function (evt) {
397
- _this.onWebSocketError(evt);
398
- },
399
- onUnhandledMessage: function (message) {
400
- _this.onUnhandledMessage(message);
401
- },
402
- onUnhandledReceipt: function (frame) {
403
- _this.onUnhandledReceipt(frame);
404
- },
405
- onUnhandledFrame: function (frame) {
406
- _this.onUnhandledFrame(frame);
407
- }
408
- });
409
- this._stompHandler.start();
410
- return [2 /*return*/];
411
- }
358
+ }
359
+ _connect() {
360
+ return __awaiter(this, void 0, void 0, function* () {
361
+ if (this.connected) {
362
+ this.debug('STOMP: already connected, nothing to do');
363
+ return;
364
+ }
365
+ yield this.beforeConnect();
366
+ if (!this.active) {
367
+ this.debug('Client has been marked inactive, will not attempt to connect');
368
+ return;
369
+ }
370
+ // setup connection watcher
371
+ if (this.connectionTimeout > 0) {
372
+ this._connectionWatcher = setTimeout(() => {
373
+ // Connection not established, close the underlying socket
374
+ // a reconnection will be attempted
375
+ this.debug(`Connection not established in ${this.connectionTimeout}ms, closing socket`);
376
+ this.forceDisconnect();
377
+ }, this.connectionTimeout);
378
+ }
379
+ this.debug('Opening Web Socket...');
380
+ // Get the actual WebSocket (or a similar object)
381
+ const webSocket = this._createWebSocket();
382
+ this._stompHandler = new _stomp_handler__WEBPACK_IMPORTED_MODULE_0__["StompHandler"](this, webSocket, {
383
+ debug: this.debug,
384
+ stompVersions: this.stompVersions,
385
+ connectHeaders: this.connectHeaders,
386
+ disconnectHeaders: this._disconnectHeaders,
387
+ heartbeatIncoming: this.heartbeatIncoming,
388
+ heartbeatOutgoing: this.heartbeatOutgoing,
389
+ splitLargeFrames: this.splitLargeFrames,
390
+ maxWebSocketChunkSize: this.maxWebSocketChunkSize,
391
+ forceBinaryWSFrames: this.forceBinaryWSFrames,
392
+ logRawCommunication: this.logRawCommunication,
393
+ appendMissingNULLonIncoming: this.appendMissingNULLonIncoming,
394
+ discardWebsocketOnCommFailure: this.discardWebsocketOnCommFailure,
395
+ onConnect: frame => {
396
+ // Successfully connected, stop the connection watcher
397
+ if (this._connectionWatcher) {
398
+ clearTimeout(this._connectionWatcher);
399
+ this._connectionWatcher = undefined;
400
+ }
401
+ if (!this.active) {
402
+ this.debug('STOMP got connected while deactivate was issued, will disconnect now');
403
+ this._disposeStompHandler();
404
+ return;
405
+ }
406
+ this.onConnect(frame);
407
+ },
408
+ onDisconnect: frame => {
409
+ this.onDisconnect(frame);
410
+ },
411
+ onStompError: frame => {
412
+ this.onStompError(frame);
413
+ },
414
+ onWebSocketClose: evt => {
415
+ this._stompHandler = undefined; // a new one will be created in case of a reconnect
416
+ if (this.state === _types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].DEACTIVATING) {
417
+ // Mark deactivation complete
418
+ this._resolveSocketClose();
419
+ this._resolveSocketClose = undefined;
420
+ this._changeState(_types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].INACTIVE);
421
+ }
422
+ this.onWebSocketClose(evt);
423
+ // The callback is called before attempting to reconnect, this would allow the client
424
+ // to be `deactivated` in the callback.
425
+ if (this.active) {
426
+ this._schedule_reconnect();
427
+ }
428
+ },
429
+ onWebSocketError: evt => {
430
+ this.onWebSocketError(evt);
431
+ },
432
+ onUnhandledMessage: message => {
433
+ this.onUnhandledMessage(message);
434
+ },
435
+ onUnhandledReceipt: frame => {
436
+ this.onUnhandledReceipt(frame);
437
+ },
438
+ onUnhandledFrame: frame => {
439
+ this.onUnhandledFrame(frame);
440
+ },
412
441
  });
442
+ this._stompHandler.start();
413
443
  });
414
- };
415
- Client.prototype._createWebSocket = function () {
416
- var webSocket;
444
+ }
445
+ _createWebSocket() {
446
+ let webSocket;
417
447
  if (this.webSocketFactory) {
418
448
  webSocket = this.webSocketFactory();
419
449
  }
@@ -422,52 +452,70 @@ var Client = /** @class */ (function () {
422
452
  }
423
453
  webSocket.binaryType = 'arraybuffer';
424
454
  return webSocket;
425
- };
426
- Client.prototype._schedule_reconnect = function () {
427
- var _this = this;
455
+ }
456
+ _schedule_reconnect() {
428
457
  if (this.reconnectDelay > 0) {
429
- this.debug("STOMP: scheduling reconnection in " + this.reconnectDelay + "ms");
430
- this._reconnector = setTimeout(function () {
431
- _this._connect();
458
+ this.debug(`STOMP: scheduling reconnection in ${this.reconnectDelay}ms`);
459
+ this._reconnector = setTimeout(() => {
460
+ this._connect();
432
461
  }, this.reconnectDelay);
433
462
  }
434
- };
463
+ }
435
464
  /**
436
465
  * Disconnect if connected and stop auto reconnect loop.
437
466
  * Appropriate callbacks will be invoked if underlying STOMP connection was connected.
438
467
  *
468
+ * This call is async, it will resolve immediately if there is no underlying active websocket,
469
+ * otherwise, it will resolve after underlying websocket is properly disposed.
470
+ *
439
471
  * To reactivate you can call [Client#activate]{@link Client#activate}.
440
472
  */
441
- Client.prototype.deactivate = function () {
442
- // indicate that auto reconnect loop should terminate
443
- this._active = false;
444
- // Clear if a reconnection was scheduled
445
- if (this._reconnector) {
446
- clearTimeout(this._reconnector);
447
- }
448
- this._disposeStompHandler();
449
- };
473
+ deactivate() {
474
+ return __awaiter(this, void 0, void 0, function* () {
475
+ let retPromise;
476
+ if (this.state !== _types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].ACTIVE) {
477
+ this.debug(`Already ${_types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"][this.state]}, ignoring call to deactivate`);
478
+ return Promise.resolve();
479
+ }
480
+ this._changeState(_types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].DEACTIVATING);
481
+ // Clear if a reconnection was scheduled
482
+ if (this._reconnector) {
483
+ clearTimeout(this._reconnector);
484
+ }
485
+ if (this._stompHandler &&
486
+ this.webSocket.readyState !== _types__WEBPACK_IMPORTED_MODULE_1__["StompSocketState"].CLOSED) {
487
+ // we need to wait for underlying websocket to close
488
+ retPromise = new Promise((resolve, reject) => {
489
+ this._resolveSocketClose = resolve;
490
+ });
491
+ }
492
+ else {
493
+ // indicate that auto reconnect loop should terminate
494
+ this._changeState(_types__WEBPACK_IMPORTED_MODULE_1__["ActivationState"].INACTIVE);
495
+ return Promise.resolve();
496
+ }
497
+ this._disposeStompHandler();
498
+ return retPromise;
499
+ });
500
+ }
450
501
  /**
451
502
  * Force disconnect if there is an active connection by directly closing the underlying WebSocket.
452
503
  * This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
453
504
  * After forcing disconnect, automatic reconnect will be attempted.
454
505
  * To stop further reconnects call [Client#deactivate]{@link Client#deactivate} as well.
455
506
  */
456
- Client.prototype.forceDisconnect = function () {
457
- if (this._webSocket) {
458
- if (this._webSocket.readyState === types_1.StompSocketState.CONNECTING
459
- || this._webSocket.readyState === types_1.StompSocketState.OPEN) {
460
- this._stompHandler._closeWebsocket();
461
- }
507
+ forceDisconnect() {
508
+ if (this._stompHandler) {
509
+ this._stompHandler.forceDisconnect();
462
510
  }
463
- };
464
- Client.prototype._disposeStompHandler = function () {
511
+ }
512
+ _disposeStompHandler() {
465
513
  // Dispose STOMP Handler
466
514
  if (this._stompHandler) {
467
515
  this._stompHandler.dispose();
468
516
  this._stompHandler = null;
469
517
  }
470
- };
518
+ }
471
519
  /**
472
520
  * Send a message to a named destination. Refer to your STOMP broker documentation for types
473
521
  * and naming of destinations.
@@ -504,9 +552,9 @@ var Client = /** @class */ (function () {
504
552
  * headers: {'content-type': 'application/octet-stream'}});
505
553
  * ```
506
554
  */
507
- Client.prototype.publish = function (params) {
555
+ publish(params) {
508
556
  this._stompHandler.publish(params);
509
- };
557
+ }
510
558
  /**
511
559
  * STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
512
560
  * To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
@@ -542,9 +590,9 @@ var Client = /** @class */ (function () {
542
590
  * client.publish({destination: TEST.destination, headers: {receipt: receiptId}, body: msg});
543
591
  * ```
544
592
  */
545
- Client.prototype.watchForReceipt = function (receiptId, callback) {
593
+ watchForReceipt(receiptId, callback) {
546
594
  this._stompHandler.watchForReceipt(receiptId, callback);
547
- };
595
+ }
548
596
  /**
549
597
  * Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
550
598
  * the {@link IMessage} as argument.
@@ -569,10 +617,9 @@ var Client = /** @class */ (function () {
569
617
  * var subscription = client.subscribe(destination, callback, { id: mySubId });
570
618
  * ```
571
619
  */
572
- Client.prototype.subscribe = function (destination, callback, headers) {
573
- if (headers === void 0) { headers = {}; }
620
+ subscribe(destination, callback, headers = {}) {
574
621
  return this._stompHandler.subscribe(destination, callback, headers);
575
- };
622
+ }
576
623
  /**
577
624
  * It is preferable to unsubscribe from a subscription by calling
578
625
  * `unsubscribe()` directly on {@link StompSubscription} returned by `client.subscribe()`:
@@ -585,19 +632,18 @@ var Client = /** @class */ (function () {
585
632
  *
586
633
  * See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
587
634
  */
588
- Client.prototype.unsubscribe = function (id, headers) {
589
- if (headers === void 0) { headers = {}; }
635
+ unsubscribe(id, headers = {}) {
590
636
  this._stompHandler.unsubscribe(id, headers);
591
- };
637
+ }
592
638
  /**
593
639
  * Start a transaction, the returned {@link ITransaction} has methods - [commit]{@link ITransaction#commit}
594
640
  * and [abort]{@link ITransaction#abort}.
595
641
  *
596
642
  * `transactionId` is optional, if not passed the library will generate it internally.
597
643
  */
598
- Client.prototype.begin = function (transactionId) {
644
+ begin(transactionId) {
599
645
  return this._stompHandler.begin(transactionId);
600
- };
646
+ }
601
647
  /**
602
648
  * Commit a transaction.
603
649
  *
@@ -610,9 +656,9 @@ var Client = /** @class */ (function () {
610
656
  * tx.commit();
611
657
  * ```
612
658
  */
613
- Client.prototype.commit = function (transactionId) {
659
+ commit(transactionId) {
614
660
  this._stompHandler.commit(transactionId);
615
- };
661
+ }
616
662
  /**
617
663
  * Abort a transaction.
618
664
  * It is preferable to abort a transaction by calling [abort]{@link ITransaction#abort} directly on
@@ -624,9 +670,9 @@ var Client = /** @class */ (function () {
624
670
  * tx.abort();
625
671
  * ```
626
672
  */
627
- Client.prototype.abort = function (transactionId) {
673
+ abort(transactionId) {
628
674
  this._stompHandler.abort(transactionId);
629
- };
675
+ }
630
676
  /**
631
677
  * ACK a message. It is preferable to acknowledge a message by calling [ack]{@link IMessage#ack} directly
632
678
  * on the {@link IMessage} handled by a subscription callback:
@@ -640,10 +686,9 @@ var Client = /** @class */ (function () {
640
686
  * client.subscribe(destination, callback, {'ack': 'client'});
641
687
  * ```
642
688
  */
643
- Client.prototype.ack = function (messageId, subscriptionId, headers) {
644
- if (headers === void 0) { headers = {}; }
689
+ ack(messageId, subscriptionId, headers = {}) {
645
690
  this._stompHandler.ack(messageId, subscriptionId, headers);
646
- };
691
+ }
647
692
  /**
648
693
  * NACK a message. It is preferable to acknowledge a message by calling [nack]{@link IMessage#nack} directly
649
694
  * on the {@link IMessage} handled by a subscription callback:
@@ -657,13 +702,10 @@ var Client = /** @class */ (function () {
657
702
  * client.subscribe(destination, callback, {'ack': 'client'});
658
703
  * ```
659
704
  */
660
- Client.prototype.nack = function (messageId, subscriptionId, headers) {
661
- if (headers === void 0) { headers = {}; }
705
+ nack(messageId, subscriptionId, headers = {}) {
662
706
  this._stompHandler.nack(messageId, subscriptionId, headers);
663
- };
664
- return Client;
665
- }());
666
- exports.Client = Client;
707
+ }
708
+ }
667
709
 
668
710
 
669
711
  /***/ }),
@@ -672,27 +714,16 @@ exports.Client = Client;
672
714
  /*!********************************************!*\
673
715
  !*** ./src/compatibility/compat-client.ts ***!
674
716
  \********************************************/
675
- /*! no static exports found */
676
- /***/ (function(module, exports, __webpack_require__) {
717
+ /*! exports provided: CompatClient */
718
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
677
719
 
678
720
  "use strict";
721
+ __webpack_require__.r(__webpack_exports__);
722
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompatClient", function() { return CompatClient; });
723
+ /* harmony import */ var _client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client */ "./src/client.ts");
724
+ /* harmony import */ var _heartbeat_info__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./heartbeat-info */ "./src/compatibility/heartbeat-info.ts");
725
+
679
726
 
680
- var __extends = (this && this.__extends) || (function () {
681
- var extendStatics = function (d, b) {
682
- extendStatics = Object.setPrototypeOf ||
683
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
684
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
685
- return extendStatics(d, b);
686
- };
687
- return function (d, b) {
688
- extendStatics(d, b);
689
- function __() { this.constructor = d; }
690
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
691
- };
692
- })();
693
- Object.defineProperty(exports, "__esModule", { value: true });
694
- var client_1 = __webpack_require__(/*! ../client */ "./src/client.ts");
695
- var heartbeat_info_1 = __webpack_require__(/*! ./heartbeat-info */ "./src/compatibility/heartbeat-info.ts");
696
727
  /**
697
728
  * Available for backward compatibility, please shift to using {@link Client}.
698
729
  *
@@ -702,8 +733,7 @@ var heartbeat_info_1 = __webpack_require__(/*! ./heartbeat-info */ "./src/compat
702
733
  *
703
734
  * To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
704
735
  */
705
- var CompatClient = /** @class */ (function (_super) {
706
- __extends(CompatClient, _super);
736
+ class CompatClient extends _client__WEBPACK_IMPORTED_MODULE_0__["Client"] {
707
737
  /**
708
738
  * Available for backward compatibility, please shift to using {@link Client}
709
739
  * and [Client#webSocketFactory]{@link Client#webSocketFactory}.
@@ -712,51 +742,55 @@ var CompatClient = /** @class */ (function (_super) {
712
742
  *
713
743
  * @internal
714
744
  */
715
- function CompatClient(webSocketFactory) {
716
- var _this = _super.call(this) || this;
745
+ constructor(webSocketFactory) {
746
+ super();
717
747
  /**
718
748
  * It is no op now. No longer needed. Large packets work out of the box.
719
749
  */
720
- _this.maxWebSocketFrameSize = 16 * 1024;
721
- _this._heartbeatInfo = new heartbeat_info_1.HeartbeatInfo(_this);
722
- _this.reconnect_delay = 0;
723
- _this.webSocketFactory = webSocketFactory;
750
+ this.maxWebSocketFrameSize = 16 * 1024;
751
+ this._heartbeatInfo = new _heartbeat_info__WEBPACK_IMPORTED_MODULE_1__["HeartbeatInfo"](this);
752
+ this.reconnect_delay = 0;
753
+ this.webSocketFactory = webSocketFactory;
724
754
  // Default from previous version
725
- _this.debug = function () {
726
- var message = [];
727
- for (var _i = 0; _i < arguments.length; _i++) {
728
- message[_i] = arguments[_i];
729
- }
730
- console.log.apply(console, message);
755
+ this.debug = (...message) => {
756
+ console.log(...message);
731
757
  };
732
- return _this;
733
758
  }
734
- CompatClient.prototype._parseConnect = function () {
735
- var args = [];
736
- for (var _i = 0; _i < arguments.length; _i++) {
737
- args[_i] = arguments[_i];
738
- }
739
- var closeEventCallback;
740
- var connectCallback;
741
- var errorCallback;
742
- var headers = {};
759
+ _parseConnect(...args) {
760
+ let closeEventCallback;
761
+ let connectCallback;
762
+ let errorCallback;
763
+ let headers = {};
743
764
  if (args.length < 2) {
744
- throw new Error(('Connect requires at least 2 arguments'));
765
+ throw new Error('Connect requires at least 2 arguments');
745
766
  }
746
- if (typeof (args[1]) === 'function') {
747
- headers = args[0], connectCallback = args[1], errorCallback = args[2], closeEventCallback = args[3];
767
+ if (typeof args[1] === 'function') {
768
+ [headers, connectCallback, errorCallback, closeEventCallback] = args;
748
769
  }
749
770
  else {
750
771
  switch (args.length) {
751
772
  case 6:
752
- headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4], headers.host = args[5];
773
+ [
774
+ headers.login,
775
+ headers.passcode,
776
+ connectCallback,
777
+ errorCallback,
778
+ closeEventCallback,
779
+ headers.host,
780
+ ] = args;
753
781
  break;
754
782
  default:
755
- headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4];
783
+ [
784
+ headers.login,
785
+ headers.passcode,
786
+ connectCallback,
787
+ errorCallback,
788
+ closeEventCallback,
789
+ ] = args;
756
790
  }
757
791
  }
758
792
  return [headers, connectCallback, errorCallback, closeEventCallback];
759
- };
793
+ }
760
794
  /**
761
795
  * Available for backward compatibility, please shift to using [Client#activate]{@link Client#activate}.
762
796
  *
@@ -784,12 +818,8 @@ var CompatClient = /** @class */ (function (_super) {
784
818
  *
785
819
  * To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
786
820
  */
787
- CompatClient.prototype.connect = function () {
788
- var args = [];
789
- for (var _i = 0; _i < arguments.length; _i++) {
790
- args[_i] = arguments[_i];
791
- }
792
- var out = this._parseConnect.apply(this, args);
821
+ connect(...args) {
822
+ const out = this._parseConnect(...args);
793
823
  if (out[0]) {
794
824
  this.connectHeaders = out[0];
795
825
  }
@@ -802,8 +832,8 @@ var CompatClient = /** @class */ (function (_super) {
802
832
  if (out[3]) {
803
833
  this.onWebSocketClose = out[3];
804
834
  }
805
- _super.prototype.activate.call(this);
806
- };
835
+ super.activate();
836
+ }
807
837
  /**
808
838
  * Available for backward compatibility, please shift to using [Client#deactivate]{@link Client#deactivate}.
809
839
  *
@@ -815,14 +845,13 @@ var CompatClient = /** @class */ (function (_super) {
815
845
  *
816
846
  * To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
817
847
  */
818
- CompatClient.prototype.disconnect = function (disconnectCallback, headers) {
819
- if (headers === void 0) { headers = {}; }
848
+ disconnect(disconnectCallback, headers = {}) {
820
849
  if (disconnectCallback) {
821
850
  this.onDisconnect = disconnectCallback;
822
851
  }
823
852
  this.disconnectHeaders = headers;
824
- _super.prototype.deactivate.call(this);
825
- };
853
+ super.deactivate();
854
+ }
826
855
  /**
827
856
  * Available for backward compatibility, use [Client#publish]{@link Client#publish}.
828
857
  *
@@ -843,124 +872,96 @@ var CompatClient = /** @class */ (function (_super) {
843
872
  *
844
873
  * To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
845
874
  */
846
- CompatClient.prototype.send = function (destination, headers, body) {
847
- if (headers === void 0) { headers = {}; }
848
- if (body === void 0) { body = ''; }
875
+ send(destination, headers = {}, body = '') {
849
876
  headers = Object.assign({}, headers);
850
- var skipContentLengthHeader = (headers['content-length'] === false);
877
+ const skipContentLengthHeader = headers['content-length'] === false;
851
878
  if (skipContentLengthHeader) {
852
879
  delete headers['content-length'];
853
880
  }
854
881
  this.publish({
855
- destination: destination,
882
+ destination,
856
883
  headers: headers,
857
- body: body,
858
- skipContentLengthHeader: skipContentLengthHeader
884
+ body,
885
+ skipContentLengthHeader,
859
886
  });
860
- };
861
- Object.defineProperty(CompatClient.prototype, "reconnect_delay", {
862
- /**
863
- * Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
864
- *
865
- * **Deprecated**
866
- */
867
- set: function (value) {
868
- this.reconnectDelay = value;
869
- },
870
- enumerable: true,
871
- configurable: true
872
- });
873
- Object.defineProperty(CompatClient.prototype, "ws", {
874
- /**
875
- * Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
876
- *
877
- * **Deprecated**
878
- */
879
- get: function () {
880
- return this._webSocket;
881
- },
882
- enumerable: true,
883
- configurable: true
884
- });
885
- Object.defineProperty(CompatClient.prototype, "version", {
886
- /**
887
- * Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
888
- *
889
- * **Deprecated**
890
- */
891
- get: function () {
892
- return this.connectedVersion;
893
- },
894
- enumerable: true,
895
- configurable: true
896
- });
897
- Object.defineProperty(CompatClient.prototype, "onreceive", {
898
- /**
899
- * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
900
- *
901
- * **Deprecated**
902
- */
903
- get: function () {
904
- return this.onUnhandledMessage;
905
- },
906
- /**
907
- * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
908
- *
909
- * **Deprecated**
910
- */
911
- set: function (value) {
912
- this.onUnhandledMessage = value;
913
- },
914
- enumerable: true,
915
- configurable: true
916
- });
917
- Object.defineProperty(CompatClient.prototype, "onreceipt", {
918
- /**
919
- * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
920
- * Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
921
- *
922
- * **Deprecated**
923
- */
924
- get: function () {
925
- return this.onUnhandledReceipt;
926
- },
927
- /**
928
- * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
929
- *
930
- * **Deprecated**
931
- */
932
- set: function (value) {
933
- this.onUnhandledReceipt = value;
934
- },
935
- enumerable: true,
936
- configurable: true
937
- });
938
- Object.defineProperty(CompatClient.prototype, "heartbeat", {
939
- /**
940
- * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
941
- * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
942
- *
943
- * **Deprecated**
944
- */
945
- get: function () {
946
- return this._heartbeatInfo;
947
- },
948
- /**
949
- * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
950
- * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
951
- *
952
- * **Deprecated**
953
- */
954
- set: function (value) {
955
- this.heartbeatIncoming = value.incoming;
956
- this.heartbeatOutgoing = value.outgoing;
957
- },
958
- enumerable: true,
959
- configurable: true
960
- });
961
- return CompatClient;
962
- }(client_1.Client));
963
- exports.CompatClient = CompatClient;
887
+ }
888
+ /**
889
+ * Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
890
+ *
891
+ * **Deprecated**
892
+ */
893
+ set reconnect_delay(value) {
894
+ this.reconnectDelay = value;
895
+ }
896
+ /**
897
+ * Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
898
+ *
899
+ * **Deprecated**
900
+ */
901
+ get ws() {
902
+ return this.webSocket;
903
+ }
904
+ /**
905
+ * Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
906
+ *
907
+ * **Deprecated**
908
+ */
909
+ get version() {
910
+ return this.connectedVersion;
911
+ }
912
+ /**
913
+ * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
914
+ *
915
+ * **Deprecated**
916
+ */
917
+ get onreceive() {
918
+ return this.onUnhandledMessage;
919
+ }
920
+ /**
921
+ * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
922
+ *
923
+ * **Deprecated**
924
+ */
925
+ set onreceive(value) {
926
+ this.onUnhandledMessage = value;
927
+ }
928
+ /**
929
+ * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
930
+ * Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
931
+ *
932
+ * **Deprecated**
933
+ */
934
+ get onreceipt() {
935
+ return this.onUnhandledReceipt;
936
+ }
937
+ /**
938
+ * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
939
+ *
940
+ * **Deprecated**
941
+ */
942
+ set onreceipt(value) {
943
+ this.onUnhandledReceipt = value;
944
+ }
945
+ /**
946
+ * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
947
+ * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
948
+ *
949
+ * **Deprecated**
950
+ */
951
+ get heartbeat() {
952
+ return this._heartbeatInfo;
953
+ }
954
+ /**
955
+ * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
956
+ * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
957
+ *
958
+ * **Deprecated**
959
+ */
960
+ set heartbeat(value) {
961
+ this.heartbeatIncoming = value.incoming;
962
+ this.heartbeatOutgoing = value.outgoing;
963
+ }
964
+ }
964
965
 
965
966
 
966
967
  /***/ }),
@@ -969,44 +970,34 @@ exports.CompatClient = CompatClient;
969
970
  /*!*********************************************!*\
970
971
  !*** ./src/compatibility/heartbeat-info.ts ***!
971
972
  \*********************************************/
972
- /*! no static exports found */
973
- /***/ (function(module, exports, __webpack_require__) {
973
+ /*! exports provided: HeartbeatInfo */
974
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
974
975
 
975
976
  "use strict";
976
-
977
- Object.defineProperty(exports, "__esModule", { value: true });
977
+ __webpack_require__.r(__webpack_exports__);
978
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HeartbeatInfo", function() { return HeartbeatInfo; });
978
979
  /**
979
980
  * Part of `@stomp/stompjs`.
980
981
  *
981
982
  * @internal
982
983
  */
983
- var HeartbeatInfo = /** @class */ (function () {
984
- function HeartbeatInfo(client) {
984
+ class HeartbeatInfo {
985
+ constructor(client) {
985
986
  this.client = client;
986
987
  }
987
- Object.defineProperty(HeartbeatInfo.prototype, "outgoing", {
988
- get: function () {
989
- return this.client.heartbeatOutgoing;
990
- },
991
- set: function (value) {
992
- this.client.heartbeatOutgoing = value;
993
- },
994
- enumerable: true,
995
- configurable: true
996
- });
997
- Object.defineProperty(HeartbeatInfo.prototype, "incoming", {
998
- get: function () {
999
- return this.client.heartbeatIncoming;
1000
- },
1001
- set: function (value) {
1002
- this.client.heartbeatIncoming = value;
1003
- },
1004
- enumerable: true,
1005
- configurable: true
1006
- });
1007
- return HeartbeatInfo;
1008
- }());
1009
- exports.HeartbeatInfo = HeartbeatInfo;
988
+ get outgoing() {
989
+ return this.client.heartbeatOutgoing;
990
+ }
991
+ set outgoing(value) {
992
+ this.client.heartbeatOutgoing = value;
993
+ }
994
+ get incoming() {
995
+ return this.client.heartbeatIncoming;
996
+ }
997
+ set incoming(value) {
998
+ this.client.heartbeatIncoming = value;
999
+ }
1000
+ }
1010
1001
 
1011
1002
 
1012
1003
  /***/ }),
@@ -1015,14 +1006,16 @@ exports.HeartbeatInfo = HeartbeatInfo;
1015
1006
  /*!************************************!*\
1016
1007
  !*** ./src/compatibility/stomp.ts ***!
1017
1008
  \************************************/
1018
- /*! no static exports found */
1019
- /***/ (function(module, exports, __webpack_require__) {
1009
+ /*! exports provided: Stomp */
1010
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1020
1011
 
1021
1012
  "use strict";
1013
+ __webpack_require__.r(__webpack_exports__);
1014
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stomp", function() { return Stomp; });
1015
+ /* harmony import */ var _versions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../versions */ "./src/versions.ts");
1016
+ /* harmony import */ var _compat_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compat-client */ "./src/compatibility/compat-client.ts");
1017
+
1022
1018
 
1023
- Object.defineProperty(exports, "__esModule", { value: true });
1024
- var versions_1 = __webpack_require__(/*! ../versions */ "./src/versions.ts");
1025
- var compat_client_1 = __webpack_require__(/*! ./compat-client */ "./src/compatibility/compat-client.ts");
1026
1019
  /**
1027
1020
  * STOMP Class, acts like a factory to create {@link Client}.
1028
1021
  *
@@ -1032,9 +1025,7 @@ var compat_client_1 = __webpack_require__(/*! ./compat-client */ "./src/compatib
1032
1025
  *
1033
1026
  * It will be removed in next major version. Please switch to {@link Client}.
1034
1027
  */
1035
- var Stomp = /** @class */ (function () {
1036
- function Stomp() {
1037
- }
1028
+ class Stomp {
1038
1029
  /**
1039
1030
  * This method creates a WebSocket client that is connected to
1040
1031
  * the STOMP server located at the url.
@@ -1049,7 +1040,7 @@ var Stomp = /** @class */ (function () {
1049
1040
  * It will be removed in next major version. Please switch to {@link Client}
1050
1041
  * using [Client#brokerURL]{@link Client#brokerURL}.
1051
1042
  */
1052
- Stomp.client = function (url, protocols) {
1043
+ static client(url, protocols) {
1053
1044
  // This is a hack to allow another implementation than the standard
1054
1045
  // HTML5 WebSocket class.
1055
1046
  //
@@ -1063,14 +1054,14 @@ var Stomp = /** @class */ (function () {
1063
1054
  // instead.
1064
1055
  // See remarks on the function Stomp.over
1065
1056
  if (protocols == null) {
1066
- protocols = versions_1.Versions.default.protocolVersions();
1057
+ protocols = _versions__WEBPACK_IMPORTED_MODULE_0__["Versions"].default.protocolVersions();
1067
1058
  }
1068
- var wsFn = function () {
1069
- var klass = Stomp.WebSocketClass || WebSocket;
1059
+ const wsFn = () => {
1060
+ const klass = Stomp.WebSocketClass || WebSocket;
1070
1061
  return new klass(url, protocols);
1071
1062
  };
1072
- return new compat_client_1.CompatClient(wsFn);
1073
- };
1063
+ return new _compat_client__WEBPACK_IMPORTED_MODULE_1__["CompatClient"](wsFn);
1064
+ }
1074
1065
  /**
1075
1066
  * This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
1076
1067
  * specify the WebSocket to use (either a standard HTML5 WebSocket or
@@ -1092,40 +1083,38 @@ var Stomp = /** @class */ (function () {
1092
1083
  * It will be removed in next major version. Please switch to {@link Client}
1093
1084
  * using [Client#webSocketFactory]{@link Client#webSocketFactory}.
1094
1085
  */
1095
- Stomp.over = function (ws) {
1096
- var wsFn;
1097
- if (typeof (ws) === 'function') {
1086
+ static over(ws) {
1087
+ let wsFn;
1088
+ if (typeof ws === 'function') {
1098
1089
  wsFn = ws;
1099
1090
  }
1100
1091
  else {
1101
1092
  console.warn('Stomp.over did not receive a factory, auto reconnect will not work. ' +
1102
1093
  'Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over');
1103
- wsFn = function () { return ws; };
1094
+ wsFn = () => ws;
1104
1095
  }
1105
- return new compat_client_1.CompatClient(wsFn);
1106
- };
1107
- /**
1108
- * In case you need to use a non standard class for WebSocket.
1109
- *
1110
- * For example when using within NodeJS environment:
1111
- *
1112
- * ```javascript
1113
- * StompJs = require('../../esm5/');
1114
- * Stomp = StompJs.Stomp;
1115
- * Stomp.WebSocketClass = require('websocket').w3cwebsocket;
1116
- * ```
1117
- *
1118
- * **Deprecated**
1119
- *
1120
- *
1121
- * It will be removed in next major version. Please switch to {@link Client}
1122
- * using [Client#webSocketFactory]{@link Client#webSocketFactory}.
1123
- */
1124
- // tslint:disable-next-line:variable-name
1125
- Stomp.WebSocketClass = null;
1126
- return Stomp;
1127
- }());
1128
- exports.Stomp = Stomp;
1096
+ return new _compat_client__WEBPACK_IMPORTED_MODULE_1__["CompatClient"](wsFn);
1097
+ }
1098
+ }
1099
+ /**
1100
+ * In case you need to use a non standard class for WebSocket.
1101
+ *
1102
+ * For example when using within NodeJS environment:
1103
+ *
1104
+ * ```javascript
1105
+ * StompJs = require('../../esm5/');
1106
+ * Stomp = StompJs.Stomp;
1107
+ * Stomp.WebSocketClass = require('websocket').w3cwebsocket;
1108
+ * ```
1109
+ *
1110
+ * **Deprecated**
1111
+ *
1112
+ *
1113
+ * It will be removed in next major version. Please switch to {@link Client}
1114
+ * using [Client#webSocketFactory]{@link Client#webSocketFactory}.
1115
+ */
1116
+ // tslint:disable-next-line:variable-name
1117
+ Stomp.WebSocketClass = null;
1129
1118
 
1130
1119
 
1131
1120
  /***/ }),
@@ -1134,26 +1123,27 @@ exports.Stomp = Stomp;
1134
1123
  /*!***************************!*\
1135
1124
  !*** ./src/frame-impl.ts ***!
1136
1125
  \***************************/
1137
- /*! no static exports found */
1138
- /***/ (function(module, exports, __webpack_require__) {
1126
+ /*! exports provided: FrameImpl */
1127
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1139
1128
 
1140
1129
  "use strict";
1130
+ __webpack_require__.r(__webpack_exports__);
1131
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FrameImpl", function() { return FrameImpl; });
1132
+ /* harmony import */ var _byte__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./byte */ "./src/byte.ts");
1141
1133
 
1142
- Object.defineProperty(exports, "__esModule", { value: true });
1143
- var byte_1 = __webpack_require__(/*! ./byte */ "./src/byte.ts");
1144
1134
  /**
1145
1135
  * Frame class represents a STOMP frame.
1146
1136
  *
1147
1137
  * @internal
1148
1138
  */
1149
- var FrameImpl = /** @class */ (function () {
1139
+ class FrameImpl {
1150
1140
  /**
1151
1141
  * Frame constructor. `command`, `headers` and `body` are available as properties.
1152
1142
  *
1153
1143
  * @internal
1154
1144
  */
1155
- function FrameImpl(params) {
1156
- var command = params.command, headers = params.headers, body = params.body, binaryBody = params.binaryBody, escapeHeaderValues = params.escapeHeaderValues, skipContentLengthHeader = params.skipContentLengthHeader;
1145
+ constructor(params) {
1146
+ const { command, headers, body, binaryBody, escapeHeaderValues, skipContentLengthHeader, } = params;
1157
1147
  this.command = command;
1158
1148
  this.headers = Object.assign({}, headers || {});
1159
1149
  if (binaryBody) {
@@ -1167,64 +1157,57 @@ var FrameImpl = /** @class */ (function () {
1167
1157
  this.escapeHeaderValues = escapeHeaderValues || false;
1168
1158
  this.skipContentLengthHeader = skipContentLengthHeader || false;
1169
1159
  }
1170
- Object.defineProperty(FrameImpl.prototype, "body", {
1171
- /**
1172
- * body of the frame
1173
- */
1174
- get: function () {
1175
- if (!this._body && this.isBinaryBody) {
1176
- this._body = new TextDecoder().decode(this._binaryBody);
1177
- }
1178
- return this._body;
1179
- },
1180
- enumerable: true,
1181
- configurable: true
1182
- });
1183
- Object.defineProperty(FrameImpl.prototype, "binaryBody", {
1184
- /**
1185
- * body as Uint8Array
1186
- */
1187
- get: function () {
1188
- if (!this._binaryBody && !this.isBinaryBody) {
1189
- this._binaryBody = new TextEncoder().encode(this._body);
1190
- }
1191
- return this._binaryBody;
1192
- },
1193
- enumerable: true,
1194
- configurable: true
1195
- });
1160
+ /**
1161
+ * body of the frame
1162
+ */
1163
+ get body() {
1164
+ if (!this._body && this.isBinaryBody) {
1165
+ this._body = new TextDecoder().decode(this._binaryBody);
1166
+ }
1167
+ return this._body;
1168
+ }
1169
+ /**
1170
+ * body as Uint8Array
1171
+ */
1172
+ get binaryBody() {
1173
+ if (!this._binaryBody && !this.isBinaryBody) {
1174
+ this._binaryBody = new TextEncoder().encode(this._body);
1175
+ }
1176
+ return this._binaryBody;
1177
+ }
1196
1178
  /**
1197
1179
  * deserialize a STOMP Frame from raw data.
1198
1180
  *
1199
1181
  * @internal
1200
1182
  */
1201
- FrameImpl.fromRawFrame = function (rawFrame, escapeHeaderValues) {
1202
- var headers = {};
1203
- var trim = function (str) { return str.replace(/^\s+|\s+$/g, ''); };
1183
+ static fromRawFrame(rawFrame, escapeHeaderValues) {
1184
+ const headers = {};
1185
+ const trim = (str) => str.replace(/^\s+|\s+$/g, '');
1204
1186
  // In case of repeated headers, as per standards, first value need to be used
1205
- for (var _i = 0, _a = rawFrame.headers.reverse(); _i < _a.length; _i++) {
1206
- var header = _a[_i];
1207
- var idx = header.indexOf(':');
1208
- var key = trim(header[0]);
1209
- var value = trim(header[1]);
1210
- if (escapeHeaderValues && (rawFrame.command !== 'CONNECT') && (rawFrame.command !== 'CONNECTED')) {
1187
+ for (const header of rawFrame.headers.reverse()) {
1188
+ const idx = header.indexOf(':');
1189
+ const key = trim(header[0]);
1190
+ let value = trim(header[1]);
1191
+ if (escapeHeaderValues &&
1192
+ rawFrame.command !== 'CONNECT' &&
1193
+ rawFrame.command !== 'CONNECTED') {
1211
1194
  value = FrameImpl.hdrValueUnEscape(value);
1212
1195
  }
1213
1196
  headers[key] = value;
1214
1197
  }
1215
1198
  return new FrameImpl({
1216
1199
  command: rawFrame.command,
1217
- headers: headers,
1200
+ headers,
1218
1201
  binaryBody: rawFrame.binaryBody,
1219
- escapeHeaderValues: escapeHeaderValues
1202
+ escapeHeaderValues,
1220
1203
  });
1221
- };
1204
+ }
1222
1205
  /**
1223
1206
  * @internal
1224
1207
  */
1225
- FrameImpl.prototype.toString = function () {
1208
+ toString() {
1226
1209
  return this.serializeCmdAndHeaders();
1227
- };
1210
+ }
1228
1211
  /**
1229
1212
  * serialize this Frame in a format suitable to be passed to WebSocket.
1230
1213
  * If the body is string the output will be string.
@@ -1232,82 +1215,90 @@ var FrameImpl = /** @class */ (function () {
1232
1215
  *
1233
1216
  * @internal
1234
1217
  */
1235
- FrameImpl.prototype.serialize = function () {
1236
- var cmdAndHeaders = this.serializeCmdAndHeaders();
1218
+ serialize() {
1219
+ const cmdAndHeaders = this.serializeCmdAndHeaders();
1237
1220
  if (this.isBinaryBody) {
1238
1221
  return FrameImpl.toUnit8Array(cmdAndHeaders, this._binaryBody).buffer;
1239
1222
  }
1240
1223
  else {
1241
- return cmdAndHeaders + this._body + byte_1.BYTE.NULL;
1224
+ return cmdAndHeaders + this._body + _byte__WEBPACK_IMPORTED_MODULE_0__["BYTE"].NULL;
1242
1225
  }
1243
- };
1244
- FrameImpl.prototype.serializeCmdAndHeaders = function () {
1245
- var lines = [this.command];
1226
+ }
1227
+ serializeCmdAndHeaders() {
1228
+ const lines = [this.command];
1246
1229
  if (this.skipContentLengthHeader) {
1247
1230
  delete this.headers['content-length'];
1248
1231
  }
1249
- for (var _i = 0, _a = Object.keys(this.headers || {}); _i < _a.length; _i++) {
1250
- var name_1 = _a[_i];
1251
- var value = this.headers[name_1];
1252
- if (this.escapeHeaderValues && (this.command !== 'CONNECT') && (this.command !== 'CONNECTED')) {
1253
- lines.push(name_1 + ":" + FrameImpl.hdrValueEscape("" + value));
1232
+ for (const name of Object.keys(this.headers || {})) {
1233
+ const value = this.headers[name];
1234
+ if (this.escapeHeaderValues &&
1235
+ this.command !== 'CONNECT' &&
1236
+ this.command !== 'CONNECTED') {
1237
+ lines.push(`${name}:${FrameImpl.hdrValueEscape(`${value}`)}`);
1254
1238
  }
1255
1239
  else {
1256
- lines.push(name_1 + ":" + value);
1240
+ lines.push(`${name}:${value}`);
1257
1241
  }
1258
1242
  }
1259
- if (this.isBinaryBody || (!this.isBodyEmpty() && !this.skipContentLengthHeader)) {
1260
- lines.push("content-length:" + this.bodyLength());
1243
+ if (this.isBinaryBody ||
1244
+ (!this.isBodyEmpty() && !this.skipContentLengthHeader)) {
1245
+ lines.push(`content-length:${this.bodyLength()}`);
1261
1246
  }
1262
- return lines.join(byte_1.BYTE.LF) + byte_1.BYTE.LF + byte_1.BYTE.LF;
1263
- };
1264
- FrameImpl.prototype.isBodyEmpty = function () {
1247
+ return lines.join(_byte__WEBPACK_IMPORTED_MODULE_0__["BYTE"].LF) + _byte__WEBPACK_IMPORTED_MODULE_0__["BYTE"].LF + _byte__WEBPACK_IMPORTED_MODULE_0__["BYTE"].LF;
1248
+ }
1249
+ isBodyEmpty() {
1265
1250
  return this.bodyLength() === 0;
1266
- };
1267
- FrameImpl.prototype.bodyLength = function () {
1268
- var binaryBody = this.binaryBody;
1251
+ }
1252
+ bodyLength() {
1253
+ const binaryBody = this.binaryBody;
1269
1254
  return binaryBody ? binaryBody.length : 0;
1270
- };
1255
+ }
1271
1256
  /**
1272
1257
  * Compute the size of a UTF-8 string by counting its number of bytes
1273
1258
  * (and not the number of characters composing the string)
1274
1259
  */
1275
- FrameImpl.sizeOfUTF8 = function (s) {
1260
+ static sizeOfUTF8(s) {
1276
1261
  return s ? new TextEncoder().encode(s).length : 0;
1277
- };
1278
- FrameImpl.toUnit8Array = function (cmdAndHeaders, binaryBody) {
1279
- var uint8CmdAndHeaders = new TextEncoder().encode(cmdAndHeaders);
1280
- var nullTerminator = new Uint8Array([0]);
1281
- var uint8Frame = new Uint8Array(uint8CmdAndHeaders.length + binaryBody.length + nullTerminator.length);
1262
+ }
1263
+ static toUnit8Array(cmdAndHeaders, binaryBody) {
1264
+ const uint8CmdAndHeaders = new TextEncoder().encode(cmdAndHeaders);
1265
+ const nullTerminator = new Uint8Array([0]);
1266
+ const uint8Frame = new Uint8Array(uint8CmdAndHeaders.length + binaryBody.length + nullTerminator.length);
1282
1267
  uint8Frame.set(uint8CmdAndHeaders);
1283
1268
  uint8Frame.set(binaryBody, uint8CmdAndHeaders.length);
1284
1269
  uint8Frame.set(nullTerminator, uint8CmdAndHeaders.length + binaryBody.length);
1285
1270
  return uint8Frame;
1286
- };
1271
+ }
1287
1272
  /**
1288
1273
  * Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker.
1289
1274
  *
1290
1275
  * @internal
1291
1276
  */
1292
- FrameImpl.marshall = function (params) {
1293
- var frame = new FrameImpl(params);
1277
+ static marshall(params) {
1278
+ const frame = new FrameImpl(params);
1294
1279
  return frame.serialize();
1295
- };
1280
+ }
1296
1281
  /**
1297
1282
  * Escape header values
1298
1283
  */
1299
- FrameImpl.hdrValueEscape = function (str) {
1300
- return str.replace(/\\/g, '\\\\').replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/:/g, '\\c');
1301
- };
1284
+ static hdrValueEscape(str) {
1285
+ return str
1286
+ .replace(/\\/g, '\\\\')
1287
+ .replace(/\r/g, '\\r')
1288
+ .replace(/\n/g, '\\n')
1289
+ .replace(/:/g, '\\c');
1290
+ }
1302
1291
  /**
1303
1292
  * UnEscape header values
1304
1293
  */
1305
- FrameImpl.hdrValueUnEscape = function (str) {
1306
- return str.replace(/\\r/g, '\r').replace(/\\n/g, '\n').replace(/\\c/g, ':').replace(/\\\\/g, '\\');
1307
- };
1308
- return FrameImpl;
1309
- }());
1310
- exports.FrameImpl = FrameImpl;
1294
+ static hdrValueUnEscape(str) {
1295
+ return str
1296
+ .replace(/\\r/g, '\r')
1297
+ .replace(/\\n/g, '\n')
1298
+ .replace(/\\c/g, ':')
1299
+ .replace(/\\\\/g, '\\');
1300
+ }
1301
+ }
1311
1302
 
1312
1303
 
1313
1304
  /***/ }),
@@ -1316,26 +1307,54 @@ exports.FrameImpl = FrameImpl;
1316
1307
  /*!**********************!*\
1317
1308
  !*** ./src/index.ts ***!
1318
1309
  \**********************/
1319
- /*! no static exports found */
1320
- /***/ (function(module, exports, __webpack_require__) {
1310
+ /*! exports provided: Client, FrameImpl, Parser, StompConfig, StompHeaders, StompSubscription, StompSocketState, ActivationState, Versions, CompatClient, Stomp */
1311
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1321
1312
 
1322
1313
  "use strict";
1314
+ __webpack_require__.r(__webpack_exports__);
1315
+ /* harmony import */ var _client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./client */ "./src/client.ts");
1316
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Client", function() { return _client__WEBPACK_IMPORTED_MODULE_0__["Client"]; });
1317
+
1318
+ /* harmony import */ var _frame_impl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./frame-impl */ "./src/frame-impl.ts");
1319
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FrameImpl", function() { return _frame_impl__WEBPACK_IMPORTED_MODULE_1__["FrameImpl"]; });
1320
+
1321
+ /* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./parser */ "./src/parser.ts");
1322
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Parser", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["Parser"]; });
1323
+
1324
+ /* harmony import */ var _stomp_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stomp-config */ "./src/stomp-config.ts");
1325
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StompConfig", function() { return _stomp_config__WEBPACK_IMPORTED_MODULE_3__["StompConfig"]; });
1326
+
1327
+ /* harmony import */ var _stomp_headers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stomp-headers */ "./src/stomp-headers.ts");
1328
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StompHeaders", function() { return _stomp_headers__WEBPACK_IMPORTED_MODULE_4__["StompHeaders"]; });
1329
+
1330
+ /* harmony import */ var _stomp_subscription__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stomp-subscription */ "./src/stomp-subscription.ts");
1331
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StompSubscription", function() { return _stomp_subscription__WEBPACK_IMPORTED_MODULE_5__["StompSubscription"]; });
1332
+
1333
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./types */ "./src/types.ts");
1334
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StompSocketState", function() { return _types__WEBPACK_IMPORTED_MODULE_6__["StompSocketState"]; });
1335
+
1336
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActivationState", function() { return _types__WEBPACK_IMPORTED_MODULE_6__["ActivationState"]; });
1337
+
1338
+ /* harmony import */ var _versions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1339
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Versions", function() { return _versions__WEBPACK_IMPORTED_MODULE_7__["Versions"]; });
1340
+
1341
+ /* harmony import */ var _compatibility_compat_client__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./compatibility/compat-client */ "./src/compatibility/compat-client.ts");
1342
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CompatClient", function() { return _compatibility_compat_client__WEBPACK_IMPORTED_MODULE_8__["CompatClient"]; });
1343
+
1344
+ /* harmony import */ var _compatibility_stomp__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./compatibility/stomp */ "./src/compatibility/stomp.ts");
1345
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stomp", function() { return _compatibility_stomp__WEBPACK_IMPORTED_MODULE_9__["Stomp"]; });
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1353
+
1323
1354
 
1324
- function __export(m) {
1325
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
1326
- }
1327
- Object.defineProperty(exports, "__esModule", { value: true });
1328
- __export(__webpack_require__(/*! ./client */ "./src/client.ts"));
1329
- __export(__webpack_require__(/*! ./frame-impl */ "./src/frame-impl.ts"));
1330
- __export(__webpack_require__(/*! ./parser */ "./src/parser.ts"));
1331
- __export(__webpack_require__(/*! ./stomp-config */ "./src/stomp-config.ts"));
1332
- __export(__webpack_require__(/*! ./stomp-headers */ "./src/stomp-headers.ts"));
1333
- __export(__webpack_require__(/*! ./stomp-subscription */ "./src/stomp-subscription.ts"));
1334
- __export(__webpack_require__(/*! ./types */ "./src/types.ts"));
1335
- __export(__webpack_require__(/*! ./versions */ "./src/versions.ts"));
1336
1355
  // Compatibility code
1337
- __export(__webpack_require__(/*! ./compatibility/compat-client */ "./src/compatibility/compat-client.ts"));
1338
- __export(__webpack_require__(/*! ./compatibility/stomp */ "./src/compatibility/stomp.ts"));
1356
+
1357
+
1339
1358
 
1340
1359
 
1341
1360
  /***/ }),
@@ -1344,28 +1363,28 @@ __export(__webpack_require__(/*! ./compatibility/stomp */ "./src/compatibility/s
1344
1363
  /*!***********************!*\
1345
1364
  !*** ./src/parser.ts ***!
1346
1365
  \***********************/
1347
- /*! no static exports found */
1348
- /***/ (function(module, exports, __webpack_require__) {
1366
+ /*! exports provided: Parser */
1367
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1349
1368
 
1350
1369
  "use strict";
1351
-
1352
- Object.defineProperty(exports, "__esModule", { value: true });
1370
+ __webpack_require__.r(__webpack_exports__);
1371
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Parser", function() { return Parser; });
1353
1372
  /**
1354
1373
  * @internal
1355
1374
  */
1356
- var NULL = 0;
1375
+ const NULL = 0;
1357
1376
  /**
1358
1377
  * @internal
1359
1378
  */
1360
- var LF = 10;
1379
+ const LF = 10;
1361
1380
  /**
1362
1381
  * @internal
1363
1382
  */
1364
- var CR = 13;
1383
+ const CR = 13;
1365
1384
  /**
1366
1385
  * @internal
1367
1386
  */
1368
- var COLON = 58;
1387
+ const COLON = 58;
1369
1388
  /**
1370
1389
  * This is an evented, rec descent parser.
1371
1390
  * A stream of Octets can be passed and whenever it recognizes
@@ -1408,8 +1427,8 @@ var COLON = 58;
1408
1427
  *
1409
1428
  * @internal
1410
1429
  */
1411
- var Parser = /** @class */ (function () {
1412
- function Parser(onFrame, onIncomingPing) {
1430
+ class Parser {
1431
+ constructor(onFrame, onIncomingPing) {
1413
1432
  this.onFrame = onFrame;
1414
1433
  this.onIncomingPing = onIncomingPing;
1415
1434
  this._encoder = new TextEncoder();
@@ -1417,10 +1436,9 @@ var Parser = /** @class */ (function () {
1417
1436
  this._token = [];
1418
1437
  this._initState();
1419
1438
  }
1420
- Parser.prototype.parseChunk = function (segment, appendMissingNULLonIncoming) {
1421
- if (appendMissingNULLonIncoming === void 0) { appendMissingNULLonIncoming = false; }
1422
- var chunk;
1423
- if ((segment instanceof ArrayBuffer)) {
1439
+ parseChunk(segment, appendMissingNULLonIncoming = false) {
1440
+ let chunk;
1441
+ if (segment instanceof ArrayBuffer) {
1424
1442
  chunk = new Uint8Array(segment);
1425
1443
  }
1426
1444
  else {
@@ -1431,35 +1449,39 @@ var Parser = /** @class */ (function () {
1431
1449
  //
1432
1450
  // Send a NULL byte, if the last byte of a Text frame was not NULL.F
1433
1451
  if (appendMissingNULLonIncoming && chunk[chunk.length - 1] !== 0) {
1434
- var chunkWithNull = new Uint8Array(chunk.length + 1);
1452
+ const chunkWithNull = new Uint8Array(chunk.length + 1);
1435
1453
  chunkWithNull.set(chunk, 0);
1436
1454
  chunkWithNull[chunk.length] = 0;
1437
1455
  chunk = chunkWithNull;
1438
1456
  }
1439
1457
  // tslint:disable-next-line:prefer-for-of
1440
- for (var i = 0; i < chunk.length; i++) {
1441
- var byte = chunk[i];
1458
+ for (let i = 0; i < chunk.length; i++) {
1459
+ const byte = chunk[i];
1442
1460
  this._onByte(byte);
1443
1461
  }
1444
- };
1462
+ }
1445
1463
  // The following implements a simple Rec Descent Parser.
1446
1464
  // The grammar is simple and just one byte tells what should be the next state
1447
- Parser.prototype._collectFrame = function (byte) {
1448
- if (byte === NULL) { // Ignore
1465
+ _collectFrame(byte) {
1466
+ if (byte === NULL) {
1467
+ // Ignore
1449
1468
  return;
1450
1469
  }
1451
- if (byte === CR) { // Ignore CR
1470
+ if (byte === CR) {
1471
+ // Ignore CR
1452
1472
  return;
1453
1473
  }
1454
- if (byte === LF) { // Incoming Ping
1474
+ if (byte === LF) {
1475
+ // Incoming Ping
1455
1476
  this.onIncomingPing();
1456
1477
  return;
1457
1478
  }
1458
1479
  this._onByte = this._collectCommand;
1459
1480
  this._reinjectByte(byte);
1460
- };
1461
- Parser.prototype._collectCommand = function (byte) {
1462
- if (byte === CR) { // Ignore CR
1481
+ }
1482
+ _collectCommand(byte) {
1483
+ if (byte === CR) {
1484
+ // Ignore CR
1463
1485
  return;
1464
1486
  }
1465
1487
  if (byte === LF) {
@@ -1468,9 +1490,10 @@ var Parser = /** @class */ (function () {
1468
1490
  return;
1469
1491
  }
1470
1492
  this._consumeByte(byte);
1471
- };
1472
- Parser.prototype._collectHeaders = function (byte) {
1473
- if (byte === CR) { // Ignore CR
1493
+ }
1494
+ _collectHeaders(byte) {
1495
+ if (byte === CR) {
1496
+ // Ignore CR
1474
1497
  return;
1475
1498
  }
1476
1499
  if (byte === LF) {
@@ -1479,20 +1502,21 @@ var Parser = /** @class */ (function () {
1479
1502
  }
1480
1503
  this._onByte = this._collectHeaderKey;
1481
1504
  this._reinjectByte(byte);
1482
- };
1483
- Parser.prototype._reinjectByte = function (byte) {
1505
+ }
1506
+ _reinjectByte(byte) {
1484
1507
  this._onByte(byte);
1485
- };
1486
- Parser.prototype._collectHeaderKey = function (byte) {
1508
+ }
1509
+ _collectHeaderKey(byte) {
1487
1510
  if (byte === COLON) {
1488
1511
  this._headerKey = this._consumeTokenAsUTF8();
1489
1512
  this._onByte = this._collectHeaderValue;
1490
1513
  return;
1491
1514
  }
1492
1515
  this._consumeByte(byte);
1493
- };
1494
- Parser.prototype._collectHeaderValue = function (byte) {
1495
- if (byte === CR) { // Ignore CR
1516
+ }
1517
+ _collectHeaderValue(byte) {
1518
+ if (byte === CR) {
1519
+ // Ignore CR
1496
1520
  return;
1497
1521
  }
1498
1522
  if (byte === LF) {
@@ -1502,9 +1526,9 @@ var Parser = /** @class */ (function () {
1502
1526
  return;
1503
1527
  }
1504
1528
  this._consumeByte(byte);
1505
- };
1506
- Parser.prototype._setupCollectBody = function () {
1507
- var contentLengthHeader = this._results.headers.filter(function (header) {
1529
+ }
1530
+ _setupCollectBody() {
1531
+ const contentLengthHeader = this._results.headers.filter((header) => {
1508
1532
  return header[0] === 'content-length';
1509
1533
  })[0];
1510
1534
  if (contentLengthHeader) {
@@ -1514,52 +1538,50 @@ var Parser = /** @class */ (function () {
1514
1538
  else {
1515
1539
  this._onByte = this._collectBodyNullTerminated;
1516
1540
  }
1517
- };
1518
- Parser.prototype._collectBodyNullTerminated = function (byte) {
1541
+ }
1542
+ _collectBodyNullTerminated(byte) {
1519
1543
  if (byte === NULL) {
1520
1544
  this._retrievedBody();
1521
1545
  return;
1522
1546
  }
1523
1547
  this._consumeByte(byte);
1524
- };
1525
- Parser.prototype._collectBodyFixedSize = function (byte) {
1548
+ }
1549
+ _collectBodyFixedSize(byte) {
1526
1550
  // It is post decrement, so that we discard the trailing NULL octet
1527
1551
  if (this._bodyBytesRemaining-- === 0) {
1528
1552
  this._retrievedBody();
1529
1553
  return;
1530
1554
  }
1531
1555
  this._consumeByte(byte);
1532
- };
1533
- Parser.prototype._retrievedBody = function () {
1556
+ }
1557
+ _retrievedBody() {
1534
1558
  this._results.binaryBody = this._consumeTokenAsRaw();
1535
1559
  this.onFrame(this._results);
1536
1560
  this._initState();
1537
- };
1561
+ }
1538
1562
  // Rec Descent Parser helpers
1539
- Parser.prototype._consumeByte = function (byte) {
1563
+ _consumeByte(byte) {
1540
1564
  this._token.push(byte);
1541
- };
1542
- Parser.prototype._consumeTokenAsUTF8 = function () {
1565
+ }
1566
+ _consumeTokenAsUTF8() {
1543
1567
  return this._decoder.decode(this._consumeTokenAsRaw());
1544
- };
1545
- Parser.prototype._consumeTokenAsRaw = function () {
1546
- var rawResult = new Uint8Array(this._token);
1568
+ }
1569
+ _consumeTokenAsRaw() {
1570
+ const rawResult = new Uint8Array(this._token);
1547
1571
  this._token = [];
1548
1572
  return rawResult;
1549
- };
1550
- Parser.prototype._initState = function () {
1573
+ }
1574
+ _initState() {
1551
1575
  this._results = {
1552
1576
  command: undefined,
1553
1577
  headers: [],
1554
- binaryBody: undefined
1578
+ binaryBody: undefined,
1555
1579
  };
1556
1580
  this._token = [];
1557
1581
  this._headerKey = undefined;
1558
1582
  this._onByte = this._collectFrame;
1559
- };
1560
- return Parser;
1561
- }());
1562
- exports.Parser = Parser;
1583
+ }
1584
+ }
1563
1585
 
1564
1586
 
1565
1587
  /***/ }),
@@ -1568,25 +1590,24 @@ exports.Parser = Parser;
1568
1590
  /*!*****************************!*\
1569
1591
  !*** ./src/stomp-config.ts ***!
1570
1592
  \*****************************/
1571
- /*! no static exports found */
1572
- /***/ (function(module, exports, __webpack_require__) {
1593
+ /*! exports provided: StompConfig */
1594
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1573
1595
 
1574
1596
  "use strict";
1575
-
1576
- Object.defineProperty(exports, "__esModule", { value: true });
1597
+ __webpack_require__.r(__webpack_exports__);
1598
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StompConfig", function() { return StompConfig; });
1577
1599
  /**
1578
1600
  * Configuration options for STOMP Client, each key corresponds to
1579
1601
  * field by the same name in {@link Client}. This can be passed to
1580
1602
  * the constructor of {@link Client} or to [Client#configure]{@link Client#configure}.
1581
1603
  *
1604
+ * There used to be a class with the same name in `@stomp/ng2-stompjs`, which has been replaced by
1605
+ * {@link RxStompConfig} and {@link InjectableRxStompConfig}.
1606
+ *
1582
1607
  * Part of `@stomp/stompjs`.
1583
1608
  */
1584
- var StompConfig = /** @class */ (function () {
1585
- function StompConfig() {
1586
- }
1587
- return StompConfig;
1588
- }());
1589
- exports.StompConfig = StompConfig;
1609
+ class StompConfig {
1610
+ }
1590
1611
 
1591
1612
 
1592
1613
  /***/ }),
@@ -1595,17 +1616,24 @@ exports.StompConfig = StompConfig;
1595
1616
  /*!******************************!*\
1596
1617
  !*** ./src/stomp-handler.ts ***!
1597
1618
  \******************************/
1598
- /*! no static exports found */
1599
- /***/ (function(module, exports, __webpack_require__) {
1619
+ /*! exports provided: StompHandler */
1620
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1600
1621
 
1601
1622
  "use strict";
1623
+ __webpack_require__.r(__webpack_exports__);
1624
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StompHandler", function() { return StompHandler; });
1625
+ /* harmony import */ var _byte__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./byte */ "./src/byte.ts");
1626
+ /* harmony import */ var _frame_impl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./frame-impl */ "./src/frame-impl.ts");
1627
+ /* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./parser */ "./src/parser.ts");
1628
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types */ "./src/types.ts");
1629
+ /* harmony import */ var _versions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1630
+ /* harmony import */ var _augment_websocket__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./augment-websocket */ "./src/augment-websocket.ts");
1631
+
1632
+
1633
+
1634
+
1635
+
1602
1636
 
1603
- Object.defineProperty(exports, "__esModule", { value: true });
1604
- var byte_1 = __webpack_require__(/*! ./byte */ "./src/byte.ts");
1605
- var frame_impl_1 = __webpack_require__(/*! ./frame-impl */ "./src/frame-impl.ts");
1606
- var parser_1 = __webpack_require__(/*! ./parser */ "./src/parser.ts");
1607
- var types_1 = __webpack_require__(/*! ./types */ "./src/types.ts");
1608
- var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1609
1637
  /**
1610
1638
  * The STOMP protocol handler
1611
1639
  *
@@ -1613,27 +1641,25 @@ var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1613
1641
  *
1614
1642
  * @internal
1615
1643
  */
1616
- var StompHandler = /** @class */ (function () {
1617
- function StompHandler(_client, _webSocket, config) {
1618
- var _this = this;
1619
- if (config === void 0) { config = {}; }
1644
+ class StompHandler {
1645
+ constructor(_client, _webSocket, config = {}) {
1620
1646
  this._client = _client;
1621
1647
  this._webSocket = _webSocket;
1622
1648
  this._serverFrameHandlers = {
1623
1649
  // [CONNECTED Frame](http://stomp.github.com/stomp-specification-1.2.html#CONNECTED_Frame)
1624
- CONNECTED: function (frame) {
1625
- _this.debug("connected to server " + frame.headers.server);
1626
- _this._connected = true;
1627
- _this._connectedVersion = frame.headers.version;
1650
+ CONNECTED: frame => {
1651
+ this.debug(`connected to server ${frame.headers.server}`);
1652
+ this._connected = true;
1653
+ this._connectedVersion = frame.headers.version;
1628
1654
  // STOMP version 1.2 needs header values to be escaped
1629
- if (_this._connectedVersion === versions_1.Versions.V1_2) {
1630
- _this._escapeHeaderValues = true;
1655
+ if (this._connectedVersion === _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_2) {
1656
+ this._escapeHeaderValues = true;
1631
1657
  }
1632
- _this._setupHeartbeat(frame.headers);
1633
- _this.onConnect(frame);
1658
+ this._setupHeartbeat(frame.headers);
1659
+ this.onConnect(frame);
1634
1660
  },
1635
1661
  // [MESSAGE Frame](http://stomp.github.com/stomp-specification-1.2.html#MESSAGE)
1636
- MESSAGE: function (frame) {
1662
+ MESSAGE: frame => {
1637
1663
  // the callback is registered when the client calls
1638
1664
  // `subscribe()`.
1639
1665
  // If there is no registered subscription for the received message,
@@ -1641,40 +1667,40 @@ var StompHandler = /** @class */ (function () {
1641
1667
  // This is useful for subscriptions that are automatically created
1642
1668
  // on the browser side (e.g. [RabbitMQ's temporary
1643
1669
  // queues](http://www.rabbitmq.com/stomp.html)).
1644
- var subscription = frame.headers.subscription;
1645
- var onReceive = _this._subscriptions[subscription] || _this.onUnhandledMessage;
1670
+ const subscription = frame.headers.subscription;
1671
+ const onReceive = this._subscriptions[subscription] || this.onUnhandledMessage;
1646
1672
  // bless the frame to be a Message
1647
- var message = frame;
1648
- var client = _this;
1649
- var messageId = _this._connectedVersion === versions_1.Versions.V1_2 ? message.headers.ack : message.headers['message-id'];
1673
+ const message = frame;
1674
+ const client = this;
1675
+ const messageId = this._connectedVersion === _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_2
1676
+ ? message.headers.ack
1677
+ : message.headers['message-id'];
1650
1678
  // add `ack()` and `nack()` methods directly to the returned frame
1651
1679
  // so that a simple call to `message.ack()` can acknowledge the message.
1652
- message.ack = function (headers) {
1653
- if (headers === void 0) { headers = {}; }
1680
+ message.ack = (headers = {}) => {
1654
1681
  return client.ack(messageId, subscription, headers);
1655
1682
  };
1656
- message.nack = function (headers) {
1657
- if (headers === void 0) { headers = {}; }
1683
+ message.nack = (headers = {}) => {
1658
1684
  return client.nack(messageId, subscription, headers);
1659
1685
  };
1660
1686
  onReceive(message);
1661
1687
  },
1662
1688
  // [RECEIPT Frame](http://stomp.github.com/stomp-specification-1.2.html#RECEIPT)
1663
- RECEIPT: function (frame) {
1664
- var callback = _this._receiptWatchers[frame.headers['receipt-id']];
1689
+ RECEIPT: frame => {
1690
+ const callback = this._receiptWatchers[frame.headers['receipt-id']];
1665
1691
  if (callback) {
1666
1692
  callback(frame);
1667
1693
  // Server will acknowledge only once, remove the callback
1668
- delete _this._receiptWatchers[frame.headers['receipt-id']];
1694
+ delete this._receiptWatchers[frame.headers['receipt-id']];
1669
1695
  }
1670
1696
  else {
1671
- _this.onUnhandledReceipt(frame);
1697
+ this.onUnhandledReceipt(frame);
1672
1698
  }
1673
1699
  },
1674
1700
  // [ERROR Frame](http://stomp.github.com/stomp-specification-1.2.html#ERROR)
1675
- ERROR: function (frame) {
1676
- _this.onStompError(frame);
1677
- }
1701
+ ERROR: frame => {
1702
+ this.onStompError(frame);
1703
+ },
1678
1704
  };
1679
1705
  // used to index subscribers
1680
1706
  this._counter = 0;
@@ -1687,71 +1713,67 @@ var StompHandler = /** @class */ (function () {
1687
1713
  this._lastServerActivityTS = Date.now();
1688
1714
  this.configure(config);
1689
1715
  }
1690
- Object.defineProperty(StompHandler.prototype, "connectedVersion", {
1691
- get: function () {
1692
- return this._connectedVersion;
1693
- },
1694
- enumerable: true,
1695
- configurable: true
1696
- });
1697
- Object.defineProperty(StompHandler.prototype, "connected", {
1698
- get: function () {
1699
- return this._connected;
1700
- },
1701
- enumerable: true,
1702
- configurable: true
1703
- });
1704
- StompHandler.prototype.configure = function (conf) {
1716
+ get connectedVersion() {
1717
+ return this._connectedVersion;
1718
+ }
1719
+ get connected() {
1720
+ return this._connected;
1721
+ }
1722
+ configure(conf) {
1705
1723
  // bulk assign all properties to this
1706
1724
  Object.assign(this, conf);
1707
- };
1708
- StompHandler.prototype.start = function () {
1709
- var _this = this;
1710
- var parser = new parser_1.Parser(
1725
+ }
1726
+ start() {
1727
+ const parser = new _parser__WEBPACK_IMPORTED_MODULE_2__["Parser"](
1711
1728
  // On Frame
1712
- function (rawFrame) {
1713
- var frame = frame_impl_1.FrameImpl.fromRawFrame(rawFrame, _this._escapeHeaderValues);
1729
+ rawFrame => {
1730
+ const frame = _frame_impl__WEBPACK_IMPORTED_MODULE_1__["FrameImpl"].fromRawFrame(rawFrame, this._escapeHeaderValues);
1714
1731
  // if this.logRawCommunication is set, the rawChunk is logged at this._webSocket.onmessage
1715
- if (!_this.logRawCommunication) {
1716
- _this.debug("<<< " + frame);
1732
+ if (!this.logRawCommunication) {
1733
+ this.debug(`<<< ${frame}`);
1717
1734
  }
1718
- var serverFrameHandler = _this._serverFrameHandlers[frame.command] || _this.onUnhandledFrame;
1735
+ const serverFrameHandler = this._serverFrameHandlers[frame.command] || this.onUnhandledFrame;
1719
1736
  serverFrameHandler(frame);
1720
1737
  },
1721
1738
  // On Incoming Ping
1722
- function () {
1723
- _this.debug('<<< PONG');
1739
+ () => {
1740
+ this.debug('<<< PONG');
1724
1741
  });
1725
- this._webSocket.onmessage = function (evt) {
1726
- _this.debug('Received data');
1727
- _this._lastServerActivityTS = Date.now();
1728
- if (_this.logRawCommunication) {
1729
- var rawChunkAsString = (evt.data instanceof ArrayBuffer) ? new TextDecoder().decode(evt.data) : evt.data;
1730
- _this.debug("<<< " + rawChunkAsString);
1742
+ this._webSocket.onmessage = (evt) => {
1743
+ this.debug('Received data');
1744
+ this._lastServerActivityTS = Date.now();
1745
+ if (this.logRawCommunication) {
1746
+ const rawChunkAsString = evt.data instanceof ArrayBuffer
1747
+ ? new TextDecoder().decode(evt.data)
1748
+ : evt.data;
1749
+ this.debug(`<<< ${rawChunkAsString}`);
1731
1750
  }
1732
- parser.parseChunk(evt.data, _this.appendMissingNULLonIncoming);
1751
+ parser.parseChunk(evt.data, this.appendMissingNULLonIncoming);
1733
1752
  };
1734
- this._onclose = function (closeEvent) {
1735
- _this.debug("Connection closed to " + _this._client.brokerURL);
1736
- _this.onWebSocketClose(closeEvent);
1737
- _this._cleanUp();
1753
+ this._onclose = (closeEvent) => {
1754
+ this.debug(`Connection closed to ${this._client.brokerURL}`);
1755
+ this._cleanUp();
1756
+ this.onWebSocketClose(closeEvent);
1738
1757
  };
1739
1758
  this._webSocket.onclose = this._onclose;
1740
- this._webSocket.onerror = function (errorEvent) {
1741
- _this.onWebSocketError(errorEvent);
1759
+ this._webSocket.onerror = (errorEvent) => {
1760
+ this.onWebSocketError(errorEvent);
1742
1761
  };
1743
- this._webSocket.onopen = function () {
1762
+ this._webSocket.onopen = () => {
1744
1763
  // Clone before updating
1745
- var connectHeaders = Object.assign({}, _this.connectHeaders);
1746
- _this.debug('Web Socket Opened...');
1747
- connectHeaders['accept-version'] = _this.stompVersions.supportedVersions();
1748
- connectHeaders['heart-beat'] = [_this.heartbeatOutgoing, _this.heartbeatIncoming].join(',');
1749
- _this._transmit({ command: 'CONNECT', headers: connectHeaders });
1764
+ const connectHeaders = Object.assign({}, this.connectHeaders);
1765
+ this.debug('Web Socket Opened...');
1766
+ connectHeaders['accept-version'] = this.stompVersions.supportedVersions();
1767
+ connectHeaders['heart-beat'] = [
1768
+ this.heartbeatOutgoing,
1769
+ this.heartbeatIncoming,
1770
+ ].join(',');
1771
+ this._transmit({ command: 'CONNECT', headers: connectHeaders });
1750
1772
  };
1751
- };
1752
- StompHandler.prototype._setupHeartbeat = function (headers) {
1753
- var _this = this;
1754
- if ((headers.version !== versions_1.Versions.V1_1 && headers.version !== versions_1.Versions.V1_2)) {
1773
+ }
1774
+ _setupHeartbeat(headers) {
1775
+ if (headers.version !== _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_1 &&
1776
+ headers.version !== _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_2) {
1755
1777
  return;
1756
1778
  }
1757
1779
  // It is valid for the server to not send this header
@@ -1762,78 +1784,76 @@ var StompHandler = /** @class */ (function () {
1762
1784
  // heart-beat header received from the server looks like:
1763
1785
  //
1764
1786
  // heart-beat: sx, sy
1765
- var _a = (headers['heart-beat']).split(',').map(function (v) { return parseInt(v, 10); }), serverOutgoing = _a[0], serverIncoming = _a[1];
1766
- if ((this.heartbeatOutgoing !== 0) && (serverIncoming !== 0)) {
1767
- var ttl = Math.max(this.heartbeatOutgoing, serverIncoming);
1768
- this.debug("send PING every " + ttl + "ms");
1769
- this._pinger = setInterval(function () {
1770
- if (_this._webSocket.readyState === types_1.StompSocketState.OPEN) {
1771
- _this._webSocket.send(byte_1.BYTE.LF);
1772
- _this.debug('>>> PING');
1787
+ const [serverOutgoing, serverIncoming] = headers['heart-beat']
1788
+ .split(',')
1789
+ .map((v) => parseInt(v, 10));
1790
+ if (this.heartbeatOutgoing !== 0 && serverIncoming !== 0) {
1791
+ const ttl = Math.max(this.heartbeatOutgoing, serverIncoming);
1792
+ this.debug(`send PING every ${ttl}ms`);
1793
+ this._pinger = setInterval(() => {
1794
+ if (this._webSocket.readyState === _types__WEBPACK_IMPORTED_MODULE_3__["StompSocketState"].OPEN) {
1795
+ this._webSocket.send(_byte__WEBPACK_IMPORTED_MODULE_0__["BYTE"].LF);
1796
+ this.debug('>>> PING');
1773
1797
  }
1774
1798
  }, ttl);
1775
1799
  }
1776
- if ((this.heartbeatIncoming !== 0) && (serverOutgoing !== 0)) {
1777
- var ttl_1 = Math.max(this.heartbeatIncoming, serverOutgoing);
1778
- this.debug("check PONG every " + ttl_1 + "ms");
1779
- this._ponger = setInterval(function () {
1780
- var delta = Date.now() - _this._lastServerActivityTS;
1800
+ if (this.heartbeatIncoming !== 0 && serverOutgoing !== 0) {
1801
+ const ttl = Math.max(this.heartbeatIncoming, serverOutgoing);
1802
+ this.debug(`check PONG every ${ttl}ms`);
1803
+ this._ponger = setInterval(() => {
1804
+ const delta = Date.now() - this._lastServerActivityTS;
1781
1805
  // We wait twice the TTL to be flexible on window's setInterval calls
1782
- if (delta > (ttl_1 * 2)) {
1783
- _this.debug("did not receive server activity for the last " + delta + "ms");
1784
- if (_this.discardWebsocketOnCommFailure) {
1785
- _this.debug('Discarding websocket, the underlying socket may linger for a while');
1786
- _this._discardWebsocket();
1787
- }
1788
- else {
1789
- _this.debug('Issuing close on the websocket');
1790
- _this._closeWebsocket();
1791
- }
1806
+ if (delta > ttl * 2) {
1807
+ this.debug(`did not receive server activity for the last ${delta}ms`);
1808
+ this._closeOrDiscardWebsocket();
1792
1809
  }
1793
- }, ttl_1);
1810
+ }, ttl);
1794
1811
  }
1795
- };
1796
- StompHandler.prototype._closeWebsocket = function () {
1797
- this._webSocket.onmessage = function () { }; // ignore messages
1798
- this._webSocket.close();
1799
- };
1800
- StompHandler.prototype._discardWebsocket = function () {
1801
- var _this = this;
1802
- var noOp = function () { };
1803
- // set all callbacks to no op
1804
- this._webSocket.onerror = noOp;
1805
- this._webSocket.onmessage = noOp;
1806
- this._webSocket.onopen = noOp;
1807
- var ts = new Date();
1808
- // Track delay in actual closure of the socket
1809
- this._webSocket.onclose = function (closeEvent) {
1810
- var delay = (new Date()).getTime() - ts.getTime();
1811
- _this.debug("Discarded socket closed after " + delay + "ms, with code/reason: " + closeEvent.code + "/" + closeEvent.reason);
1812
- };
1812
+ }
1813
+ _closeOrDiscardWebsocket() {
1814
+ if (this.discardWebsocketOnCommFailure) {
1815
+ this.debug("Discarding websocket, the underlying socket may linger for a while");
1816
+ this._discardWebsocket();
1817
+ }
1818
+ else {
1819
+ this.debug("Issuing close on the websocket");
1820
+ this._closeWebsocket();
1821
+ }
1822
+ }
1823
+ forceDisconnect() {
1824
+ if (this._webSocket) {
1825
+ if (this._webSocket.readyState === _types__WEBPACK_IMPORTED_MODULE_3__["StompSocketState"].CONNECTING ||
1826
+ this._webSocket.readyState === _types__WEBPACK_IMPORTED_MODULE_3__["StompSocketState"].OPEN) {
1827
+ this._closeOrDiscardWebsocket();
1828
+ }
1829
+ }
1830
+ }
1831
+ _closeWebsocket() {
1832
+ this._webSocket.onmessage = () => { }; // ignore messages
1813
1833
  this._webSocket.close();
1814
- var customCloseEvent = {
1815
- code: 4001,
1816
- reason: 'Heartbeat failure, discarding the socket',
1817
- wasClean: false
1818
- };
1819
- this._onclose(customCloseEvent);
1820
- };
1821
- StompHandler.prototype._transmit = function (params) {
1822
- var command = params.command, headers = params.headers, body = params.body, binaryBody = params.binaryBody, skipContentLengthHeader = params.skipContentLengthHeader;
1823
- var frame = new frame_impl_1.FrameImpl({
1824
- command: command,
1825
- headers: headers,
1826
- body: body,
1827
- binaryBody: binaryBody,
1834
+ }
1835
+ _discardWebsocket() {
1836
+ if (!this._webSocket.terminate) {
1837
+ Object(_augment_websocket__WEBPACK_IMPORTED_MODULE_5__["augmentWebsocket"])(this._webSocket, (msg) => this.debug(msg));
1838
+ }
1839
+ this._webSocket.terminate();
1840
+ }
1841
+ _transmit(params) {
1842
+ const { command, headers, body, binaryBody, skipContentLengthHeader, } = params;
1843
+ const frame = new _frame_impl__WEBPACK_IMPORTED_MODULE_1__["FrameImpl"]({
1844
+ command,
1845
+ headers,
1846
+ body,
1847
+ binaryBody,
1828
1848
  escapeHeaderValues: this._escapeHeaderValues,
1829
- skipContentLengthHeader: skipContentLengthHeader
1849
+ skipContentLengthHeader,
1830
1850
  });
1831
- var rawChunk = frame.serialize();
1851
+ let rawChunk = frame.serialize();
1832
1852
  if (this.logRawCommunication) {
1833
- this.debug(">>> " + rawChunk);
1853
+ this.debug(`>>> ${rawChunk}`);
1834
1854
  }
1835
1855
  else {
1836
- this.debug(">>> " + frame);
1856
+ this.debug(`>>> ${frame}`);
1837
1857
  }
1838
1858
  if (this.forceBinaryWSFrames && typeof rawChunk === 'string') {
1839
1859
  rawChunk = new TextEncoder().encode(rawChunk);
@@ -1842,43 +1862,42 @@ var StompHandler = /** @class */ (function () {
1842
1862
  this._webSocket.send(rawChunk);
1843
1863
  }
1844
1864
  else {
1845
- var out = rawChunk;
1865
+ let out = rawChunk;
1846
1866
  while (out.length > 0) {
1847
- var chunk = out.substring(0, this.maxWebSocketChunkSize);
1867
+ const chunk = out.substring(0, this.maxWebSocketChunkSize);
1848
1868
  out = out.substring(this.maxWebSocketChunkSize);
1849
1869
  this._webSocket.send(chunk);
1850
- this.debug("chunk sent = " + chunk.length + ", remaining = " + out.length);
1870
+ this.debug(`chunk sent = ${chunk.length}, remaining = ${out.length}`);
1851
1871
  }
1852
1872
  }
1853
- };
1854
- StompHandler.prototype.dispose = function () {
1855
- var _this = this;
1873
+ }
1874
+ dispose() {
1856
1875
  if (this.connected) {
1857
1876
  try {
1858
1877
  // clone before updating
1859
- var disconnectHeaders = Object.assign({}, this.disconnectHeaders);
1878
+ const disconnectHeaders = Object.assign({}, this.disconnectHeaders);
1860
1879
  if (!disconnectHeaders.receipt) {
1861
- disconnectHeaders.receipt = "close-" + this._counter++;
1880
+ disconnectHeaders.receipt = `close-${this._counter++}`;
1862
1881
  }
1863
- this.watchForReceipt(disconnectHeaders.receipt, function (frame) {
1864
- _this._closeWebsocket();
1865
- _this._cleanUp();
1866
- _this.onDisconnect(frame);
1882
+ this.watchForReceipt(disconnectHeaders.receipt, frame => {
1883
+ this._closeWebsocket();
1884
+ this._cleanUp();
1885
+ this.onDisconnect(frame);
1867
1886
  });
1868
1887
  this._transmit({ command: 'DISCONNECT', headers: disconnectHeaders });
1869
1888
  }
1870
1889
  catch (error) {
1871
- this.debug("Ignoring error during disconnect " + error);
1890
+ this.debug(`Ignoring error during disconnect ${error}`);
1872
1891
  }
1873
1892
  }
1874
1893
  else {
1875
- if (this._webSocket.readyState === types_1.StompSocketState.CONNECTING
1876
- || this._webSocket.readyState === types_1.StompSocketState.OPEN) {
1894
+ if (this._webSocket.readyState === _types__WEBPACK_IMPORTED_MODULE_3__["StompSocketState"].CONNECTING ||
1895
+ this._webSocket.readyState === _types__WEBPACK_IMPORTED_MODULE_3__["StompSocketState"].OPEN) {
1877
1896
  this._closeWebsocket();
1878
1897
  }
1879
1898
  }
1880
- };
1881
- StompHandler.prototype._cleanUp = function () {
1899
+ }
1900
+ _cleanUp() {
1882
1901
  this._connected = false;
1883
1902
  if (this._pinger) {
1884
1903
  clearInterval(this._pinger);
@@ -1886,104 +1905,101 @@ var StompHandler = /** @class */ (function () {
1886
1905
  if (this._ponger) {
1887
1906
  clearInterval(this._ponger);
1888
1907
  }
1889
- };
1890
- StompHandler.prototype.publish = function (params) {
1891
- var destination = params.destination, headers = params.headers, body = params.body, binaryBody = params.binaryBody, skipContentLengthHeader = params.skipContentLengthHeader;
1892
- var hdrs = Object.assign({ destination: destination }, headers);
1908
+ }
1909
+ publish(params) {
1910
+ const { destination, headers, body, binaryBody, skipContentLengthHeader, } = params;
1911
+ const hdrs = Object.assign({ destination }, headers);
1893
1912
  this._transmit({
1894
1913
  command: 'SEND',
1895
1914
  headers: hdrs,
1896
- body: body,
1897
- binaryBody: binaryBody,
1898
- skipContentLengthHeader: skipContentLengthHeader
1915
+ body,
1916
+ binaryBody,
1917
+ skipContentLengthHeader,
1899
1918
  });
1900
- };
1901
- StompHandler.prototype.watchForReceipt = function (receiptId, callback) {
1919
+ }
1920
+ watchForReceipt(receiptId, callback) {
1902
1921
  this._receiptWatchers[receiptId] = callback;
1903
- };
1904
- StompHandler.prototype.subscribe = function (destination, callback, headers) {
1905
- if (headers === void 0) { headers = {}; }
1922
+ }
1923
+ subscribe(destination, callback, headers = {}) {
1906
1924
  headers = Object.assign({}, headers);
1907
1925
  if (!headers.id) {
1908
- headers.id = "sub-" + this._counter++;
1926
+ headers.id = `sub-${this._counter++}`;
1909
1927
  }
1910
1928
  headers.destination = destination;
1911
1929
  this._subscriptions[headers.id] = callback;
1912
- this._transmit({ command: 'SUBSCRIBE', headers: headers });
1913
- var client = this;
1930
+ this._transmit({ command: 'SUBSCRIBE', headers });
1931
+ const client = this;
1914
1932
  return {
1915
1933
  id: headers.id,
1916
- unsubscribe: function (hdrs) {
1934
+ unsubscribe(hdrs) {
1917
1935
  return client.unsubscribe(headers.id, hdrs);
1918
- }
1936
+ },
1919
1937
  };
1920
- };
1921
- StompHandler.prototype.unsubscribe = function (id, headers) {
1922
- if (headers === void 0) { headers = {}; }
1938
+ }
1939
+ unsubscribe(id, headers = {}) {
1923
1940
  headers = Object.assign({}, headers);
1924
1941
  delete this._subscriptions[id];
1925
1942
  headers.id = id;
1926
- this._transmit({ command: 'UNSUBSCRIBE', headers: headers });
1927
- };
1928
- StompHandler.prototype.begin = function (transactionId) {
1929
- var txId = transactionId || ("tx-" + this._counter++);
1943
+ this._transmit({ command: 'UNSUBSCRIBE', headers });
1944
+ }
1945
+ begin(transactionId) {
1946
+ const txId = transactionId || `tx-${this._counter++}`;
1930
1947
  this._transmit({
1931
- command: 'BEGIN', headers: {
1932
- transaction: txId
1933
- }
1948
+ command: 'BEGIN',
1949
+ headers: {
1950
+ transaction: txId,
1951
+ },
1934
1952
  });
1935
- var client = this;
1953
+ const client = this;
1936
1954
  return {
1937
1955
  id: txId,
1938
- commit: function () {
1956
+ commit() {
1939
1957
  client.commit(txId);
1940
1958
  },
1941
- abort: function () {
1959
+ abort() {
1942
1960
  client.abort(txId);
1943
- }
1961
+ },
1944
1962
  };
1945
- };
1946
- StompHandler.prototype.commit = function (transactionId) {
1963
+ }
1964
+ commit(transactionId) {
1947
1965
  this._transmit({
1948
- command: 'COMMIT', headers: {
1949
- transaction: transactionId
1950
- }
1966
+ command: 'COMMIT',
1967
+ headers: {
1968
+ transaction: transactionId,
1969
+ },
1951
1970
  });
1952
- };
1953
- StompHandler.prototype.abort = function (transactionId) {
1971
+ }
1972
+ abort(transactionId) {
1954
1973
  this._transmit({
1955
- command: 'ABORT', headers: {
1956
- transaction: transactionId
1957
- }
1974
+ command: 'ABORT',
1975
+ headers: {
1976
+ transaction: transactionId,
1977
+ },
1958
1978
  });
1959
- };
1960
- StompHandler.prototype.ack = function (messageId, subscriptionId, headers) {
1961
- if (headers === void 0) { headers = {}; }
1979
+ }
1980
+ ack(messageId, subscriptionId, headers = {}) {
1962
1981
  headers = Object.assign({}, headers);
1963
- if (this._connectedVersion === versions_1.Versions.V1_2) {
1982
+ if (this._connectedVersion === _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_2) {
1964
1983
  headers.id = messageId;
1965
1984
  }
1966
1985
  else {
1967
1986
  headers['message-id'] = messageId;
1968
1987
  }
1969
1988
  headers.subscription = subscriptionId;
1970
- this._transmit({ command: 'ACK', headers: headers });
1971
- };
1972
- StompHandler.prototype.nack = function (messageId, subscriptionId, headers) {
1973
- if (headers === void 0) { headers = {}; }
1989
+ this._transmit({ command: 'ACK', headers });
1990
+ }
1991
+ nack(messageId, subscriptionId, headers = {}) {
1974
1992
  headers = Object.assign({}, headers);
1975
- if (this._connectedVersion === versions_1.Versions.V1_2) {
1993
+ if (this._connectedVersion === _versions__WEBPACK_IMPORTED_MODULE_4__["Versions"].V1_2) {
1976
1994
  headers.id = messageId;
1977
1995
  }
1978
1996
  else {
1979
1997
  headers['message-id'] = messageId;
1980
1998
  }
1981
1999
  headers.subscription = subscriptionId;
1982
- return this._transmit({ command: 'NACK', headers: headers });
1983
- };
1984
- return StompHandler;
1985
- }());
1986
- exports.StompHandler = StompHandler;
2000
+ return this._transmit({ command: 'NACK', headers });
2001
+ }
2002
+ }
1987
2003
 
1988
2004
 
1989
2005
  /***/ }),
@@ -1992,12 +2008,12 @@ exports.StompHandler = StompHandler;
1992
2008
  /*!******************************!*\
1993
2009
  !*** ./src/stomp-headers.ts ***!
1994
2010
  \******************************/
1995
- /*! no static exports found */
1996
- /***/ (function(module, exports, __webpack_require__) {
2011
+ /*! exports provided: StompHeaders */
2012
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1997
2013
 
1998
2014
  "use strict";
1999
-
2000
- Object.defineProperty(exports, "__esModule", { value: true });
2015
+ __webpack_require__.r(__webpack_exports__);
2016
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StompHeaders", function() { return StompHeaders; });
2001
2017
  /**
2002
2018
  * STOMP headers. Many functions calls will accept headers as parameters.
2003
2019
  * The headers sent by Broker will be available as [IFrame#headers]{@link IFrame#headers}.
@@ -2007,12 +2023,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
2007
2023
  *
2008
2024
  * Part of `@stomp/stompjs`.
2009
2025
  */
2010
- var StompHeaders = /** @class */ (function () {
2011
- function StompHeaders() {
2012
- }
2013
- return StompHeaders;
2014
- }());
2015
- exports.StompHeaders = StompHeaders;
2026
+ class StompHeaders {
2027
+ }
2016
2028
 
2017
2029
 
2018
2030
  /***/ }),
@@ -2021,23 +2033,19 @@ exports.StompHeaders = StompHeaders;
2021
2033
  /*!***********************************!*\
2022
2034
  !*** ./src/stomp-subscription.ts ***!
2023
2035
  \***********************************/
2024
- /*! no static exports found */
2025
- /***/ (function(module, exports, __webpack_require__) {
2036
+ /*! exports provided: StompSubscription */
2037
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2026
2038
 
2027
2039
  "use strict";
2028
-
2029
- Object.defineProperty(exports, "__esModule", { value: true });
2040
+ __webpack_require__.r(__webpack_exports__);
2041
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StompSubscription", function() { return StompSubscription; });
2030
2042
  /**
2031
2043
  * Call [Client#subscribe]{@link Client#subscribe} to create a StompSubscription.
2032
2044
  *
2033
2045
  * Part of `@stomp/stompjs`.
2034
2046
  */
2035
- var StompSubscription = /** @class */ (function () {
2036
- function StompSubscription() {
2037
- }
2038
- return StompSubscription;
2039
- }());
2040
- exports.StompSubscription = StompSubscription;
2047
+ class StompSubscription {
2048
+ }
2041
2049
 
2042
2050
 
2043
2051
  /***/ }),
@@ -2046,15 +2054,15 @@ exports.StompSubscription = StompSubscription;
2046
2054
  /*!**********************!*\
2047
2055
  !*** ./src/types.ts ***!
2048
2056
  \**********************/
2049
- /*! no static exports found */
2050
- /***/ (function(module, exports, __webpack_require__) {
2057
+ /*! exports provided: StompSocketState, ActivationState */
2058
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2051
2059
 
2052
2060
  "use strict";
2053
-
2054
- Object.defineProperty(exports, "__esModule", { value: true });
2061
+ __webpack_require__.r(__webpack_exports__);
2062
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StompSocketState", function() { return StompSocketState; });
2063
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActivationState", function() { return ActivationState; });
2055
2064
  /**
2056
2065
  * Possible states for the IStompSocket
2057
- *
2058
2066
  */
2059
2067
  var StompSocketState;
2060
2068
  (function (StompSocketState) {
@@ -2062,7 +2070,16 @@ var StompSocketState;
2062
2070
  StompSocketState[StompSocketState["OPEN"] = 1] = "OPEN";
2063
2071
  StompSocketState[StompSocketState["CLOSING"] = 2] = "CLOSING";
2064
2072
  StompSocketState[StompSocketState["CLOSED"] = 3] = "CLOSED";
2065
- })(StompSocketState = exports.StompSocketState || (exports.StompSocketState = {}));
2073
+ })(StompSocketState || (StompSocketState = {}));
2074
+ /**
2075
+ * Possible activation state
2076
+ */
2077
+ var ActivationState;
2078
+ (function (ActivationState) {
2079
+ ActivationState[ActivationState["ACTIVE"] = 0] = "ACTIVE";
2080
+ ActivationState[ActivationState["DEACTIVATING"] = 1] = "DEACTIVATING";
2081
+ ActivationState[ActivationState["INACTIVE"] = 2] = "INACTIVE";
2082
+ })(ActivationState || (ActivationState = {}));
2066
2083
 
2067
2084
 
2068
2085
  /***/ }),
@@ -2071,58 +2088,60 @@ var StompSocketState;
2071
2088
  /*!*************************!*\
2072
2089
  !*** ./src/versions.ts ***!
2073
2090
  \*************************/
2074
- /*! no static exports found */
2075
- /***/ (function(module, exports, __webpack_require__) {
2091
+ /*! exports provided: Versions */
2092
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2076
2093
 
2077
2094
  "use strict";
2078
-
2079
- Object.defineProperty(exports, "__esModule", { value: true });
2095
+ __webpack_require__.r(__webpack_exports__);
2096
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Versions", function() { return Versions; });
2080
2097
  /**
2081
2098
  * Supported STOMP versions
2082
2099
  *
2083
2100
  * Part of `@stomp/stompjs`.
2084
2101
  */
2085
- var Versions = /** @class */ (function () {
2102
+ class Versions {
2086
2103
  /**
2087
2104
  * Takes an array of string of versions, typical elements '1.0', '1.1', or '1.2'
2088
2105
  *
2089
2106
  * You will an instance if this class if you want to override supported versions to be declared during
2090
2107
  * STOMP handshake.
2091
2108
  */
2092
- function Versions(versions) {
2109
+ constructor(versions) {
2093
2110
  this.versions = versions;
2094
2111
  }
2095
2112
  /**
2096
2113
  * Used as part of CONNECT STOMP Frame
2097
2114
  */
2098
- Versions.prototype.supportedVersions = function () {
2115
+ supportedVersions() {
2099
2116
  return this.versions.join(',');
2100
- };
2117
+ }
2101
2118
  /**
2102
2119
  * Used while creating a WebSocket
2103
2120
  */
2104
- Versions.prototype.protocolVersions = function () {
2105
- return this.versions.map(function (x) { return "v" + x.replace('.', '') + ".stomp"; });
2106
- };
2107
- /**
2108
- * Indicates protocol version 1.0
2109
- */
2110
- Versions.V1_0 = '1.0';
2111
- /**
2112
- * Indicates protocol version 1.1
2113
- */
2114
- Versions.V1_1 = '1.1';
2115
- /**
2116
- * Indicates protocol version 1.2
2117
- */
2118
- Versions.V1_2 = '1.2';
2119
- /**
2120
- * @internal
2121
- */
2122
- Versions.default = new Versions([Versions.V1_0, Versions.V1_1, Versions.V1_2]);
2123
- return Versions;
2124
- }());
2125
- exports.Versions = Versions;
2121
+ protocolVersions() {
2122
+ return this.versions.map(x => `v${x.replace('.', '')}.stomp`);
2123
+ }
2124
+ }
2125
+ /**
2126
+ * Indicates protocol version 1.0
2127
+ */
2128
+ Versions.V1_0 = '1.0';
2129
+ /**
2130
+ * Indicates protocol version 1.1
2131
+ */
2132
+ Versions.V1_1 = '1.1';
2133
+ /**
2134
+ * Indicates protocol version 1.2
2135
+ */
2136
+ Versions.V1_2 = '1.2';
2137
+ /**
2138
+ * @internal
2139
+ */
2140
+ Versions.default = new Versions([
2141
+ Versions.V1_0,
2142
+ Versions.V1_1,
2143
+ Versions.V1_2,
2144
+ ]);
2126
2145
 
2127
2146
 
2128
2147
  /***/ }),