@stomp/stompjs 5.0.0-beta.4 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +8 -8
  2. package/bundles/stomp.umd.js +310 -65
  3. package/bundles/stomp.umd.js.map +1 -1
  4. package/bundles/stomp.umd.min.js +1 -1
  5. package/bundles/stomp.umd.min.js.map +1 -1
  6. package/esm5/byte.d.ts +3 -1
  7. package/esm5/byte.js +3 -1
  8. package/esm5/byte.js.map +1 -1
  9. package/esm5/client.d.ts +12 -9
  10. package/esm5/client.js +25 -7
  11. package/esm5/client.js.map +1 -1
  12. package/esm5/compatibility/compat-client.d.ts +5 -3
  13. package/esm5/compatibility/compat-client.js +11 -34
  14. package/esm5/compatibility/compat-client.js.map +1 -1
  15. package/esm5/compatibility/heartbeat-info.d.ts +12 -0
  16. package/esm5/compatibility/heartbeat-info.js +35 -0
  17. package/esm5/compatibility/heartbeat-info.js.map +1 -0
  18. package/esm5/compatibility/stomp.d.ts +25 -2
  19. package/esm5/compatibility/stomp.js +29 -5
  20. package/esm5/compatibility/stomp.js.map +1 -1
  21. package/esm5/frame.d.ts +10 -3
  22. package/esm5/frame.js +9 -5
  23. package/esm5/frame.js.map +1 -1
  24. package/esm5/index.js +5 -0
  25. package/esm5/index.js.map +1 -1
  26. package/esm5/message.d.ts +7 -5
  27. package/esm5/message.js +29 -0
  28. package/esm5/message.js.map +1 -1
  29. package/esm5/parser.d.ts +5 -3
  30. package/esm5/parser.js +6 -3
  31. package/esm5/parser.js.map +1 -1
  32. package/esm5/stomp-config.d.ts +6 -4
  33. package/esm5/stomp-config.js +13 -0
  34. package/esm5/stomp-config.js.map +1 -1
  35. package/esm5/stomp-handler.d.ts +9 -7
  36. package/esm5/stomp-handler.js +43 -36
  37. package/esm5/stomp-handler.js.map +1 -1
  38. package/esm5/stomp-headers.d.ts +3 -1
  39. package/esm5/stomp-headers.js +15 -0
  40. package/esm5/stomp-headers.js.map +1 -1
  41. package/esm5/stomp-subscription.d.ts +6 -4
  42. package/esm5/stomp-subscription.js +11 -0
  43. package/esm5/stomp-subscription.js.map +1 -1
  44. package/esm5/transaction.d.ts +3 -1
  45. package/esm5/transaction.js +13 -0
  46. package/esm5/transaction.js.map +1 -1
  47. package/esm5/types.d.ts +38 -14
  48. package/esm5/versions.d.ts +11 -3
  49. package/esm5/versions.js +11 -3
  50. package/esm5/versions.js.map +1 -1
  51. package/esm6/byte.d.ts +3 -1
  52. package/esm6/byte.js +3 -1
  53. package/esm6/byte.js.map +1 -1
  54. package/esm6/client.d.ts +12 -9
  55. package/esm6/client.js +27 -9
  56. package/esm6/client.js.map +1 -1
  57. package/esm6/compatibility/compat-client.d.ts +5 -3
  58. package/esm6/compatibility/compat-client.js +11 -34
  59. package/esm6/compatibility/compat-client.js.map +1 -1
  60. package/esm6/compatibility/heartbeat-info.d.ts +12 -0
  61. package/esm6/compatibility/heartbeat-info.js +33 -0
  62. package/esm6/compatibility/heartbeat-info.js.map +1 -0
  63. package/esm6/compatibility/stomp.d.ts +25 -2
  64. package/esm6/compatibility/stomp.js +31 -7
  65. package/esm6/compatibility/stomp.js.map +1 -1
  66. package/esm6/frame.d.ts +10 -3
  67. package/esm6/frame.js +10 -6
  68. package/esm6/frame.js.map +1 -1
  69. package/esm6/index.js +5 -0
  70. package/esm6/index.js.map +1 -1
  71. package/esm6/message.d.ts +7 -5
  72. package/esm6/message.js +29 -0
  73. package/esm6/message.js.map +1 -1
  74. package/esm6/parser.d.ts +5 -3
  75. package/esm6/parser.js +6 -3
  76. package/esm6/parser.js.map +1 -1
  77. package/esm6/stomp-config.d.ts +6 -4
  78. package/esm6/stomp-config.js +13 -0
  79. package/esm6/stomp-config.js.map +1 -1
  80. package/esm6/stomp-handler.d.ts +9 -7
  81. package/esm6/stomp-handler.js +46 -39
  82. package/esm6/stomp-handler.js.map +1 -1
  83. package/esm6/stomp-headers.d.ts +3 -1
  84. package/esm6/stomp-headers.js +15 -0
  85. package/esm6/stomp-headers.js.map +1 -1
  86. package/esm6/stomp-subscription.d.ts +6 -4
  87. package/esm6/stomp-subscription.js +11 -0
  88. package/esm6/stomp-subscription.js.map +1 -1
  89. package/esm6/transaction.d.ts +3 -1
  90. package/esm6/transaction.js +13 -0
  91. package/esm6/transaction.js.map +1 -1
  92. package/esm6/types.d.ts +38 -14
  93. package/esm6/versions.d.ts +11 -3
  94. package/esm6/versions.js +11 -3
  95. package/esm6/versions.js.map +1 -1
  96. package/package.json +4 -5
@@ -109,9 +109,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
109
109
  /**
110
110
  * Some byte values, used as per STOMP specifications.
111
111
  *
112
+ * Part of `@stomp/stompjs`.
113
+ *
112
114
  * @internal
113
115
  */
114
- exports.Byte = {
116
+ exports.BYTE = {
115
117
  // LINEFEED byte (octet 10)
116
118
  LF: '\x0A',
117
119
  // NULL byte (octet 0)
@@ -135,6 +137,8 @@ var stomp_handler_1 = __webpack_require__(/*! ./stomp-handler */ "./src/stomp-ha
135
137
  var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
136
138
  /**
137
139
  * STOMP Client Class.
140
+ *
141
+ * Part of `@stomp/stompjs`.
138
142
  */
139
143
  var Client = /** @class */ (function () {
140
144
  /**
@@ -178,7 +182,7 @@ var Client = /** @class */ (function () {
178
182
  this.onWebSocketClose = noOp;
179
183
  // These parameters would typically get proper values before connect is called
180
184
  this.connectHeaders = {};
181
- this.disconnectHeaders = {};
185
+ this._disconnectHeaders = {};
182
186
  // Apply configuration
183
187
  this.configure(conf);
184
188
  }
@@ -192,6 +196,22 @@ var Client = /** @class */ (function () {
192
196
  enumerable: true,
193
197
  configurable: true
194
198
  });
199
+ Object.defineProperty(Client.prototype, "disconnectHeaders", {
200
+ /**
201
+ * Disconnection headers.
202
+ */
203
+ get: function () {
204
+ return this._disconnectHeaders;
205
+ },
206
+ set: function (value) {
207
+ this._disconnectHeaders = value;
208
+ if (this._stompHandler) {
209
+ this._stompHandler.disconnectHeaders = this._disconnectHeaders;
210
+ }
211
+ },
212
+ enumerable: true,
213
+ configurable: true
214
+ });
195
215
  Object.defineProperty(Client.prototype, "connected", {
196
216
  /**
197
217
  * `true` if there is a active connection with STOMP Broker
@@ -251,14 +271,14 @@ var Client = /** @class */ (function () {
251
271
  this.debug('Client has been marked inactive, will not attempt to connect');
252
272
  return;
253
273
  }
254
- this.debug("Opening Web Socket...");
274
+ this.debug('Opening Web Socket...');
255
275
  // Get the actual WebSocket (or a similar object)
256
276
  this._webSocket = this._createWebSocket();
257
277
  this._stompHandler = new stomp_handler_1.StompHandler(this, this._webSocket, {
258
278
  debug: this.debug,
259
279
  stompVersions: this.stompVersions,
260
280
  connectHeaders: this.connectHeaders,
261
- disconnectHeaders: this.disconnectHeaders,
281
+ disconnectHeaders: this._disconnectHeaders,
262
282
  heartbeatIncoming: this.heartbeatIncoming,
263
283
  heartbeatOutgoing: this.heartbeatOutgoing,
264
284
  onConnect: function (frame) {
@@ -303,7 +323,7 @@ var Client = /** @class */ (function () {
303
323
  else {
304
324
  webSocket = new WebSocket(this.brokerURL, this.stompVersions.protocolVersions());
305
325
  }
306
- webSocket.binaryType = "arraybuffer";
326
+ webSocket.binaryType = 'arraybuffer';
307
327
  return webSocket;
308
328
  };
309
329
  Client.prototype._schedule_reconnect = function () {
@@ -319,7 +339,7 @@ var Client = /** @class */ (function () {
319
339
  * Disconnect if connected and stop auto reconnect loop.
320
340
  * Appropriate callbacks will be invoked if underlying STOMP connection was connected.
321
341
  *
322
- * To reactivate the {@link Client} you can call [Client#activate]{@link Client#activate}.
342
+ * To reactivate you can call [Client#activate]{@link Client#activate}.
323
343
  */
324
344
  Client.prototype.deactivate = function () {
325
345
  // indicate that auto reconnect loop should terminate
@@ -356,7 +376,7 @@ var Client = /** @class */ (function () {
356
376
  *
357
377
  * STOMP protocol specifies and suggests some headers and also allows broker specific headers.
358
378
  *
359
- * Body must be String.
379
+ * `body` must be String.
360
380
  * You will need to covert the payload to string in case it is not string (e.g. JSON).
361
381
  *
362
382
  * To send a binary message body use binaryBody parameter. It should be a
@@ -428,7 +448,7 @@ var Client = /** @class */ (function () {
428
448
  this._stompHandler.watchForReceipt(receiptId, callback);
429
449
  };
430
450
  /**
431
- * Subscribe to a STOMP Broker location. The callbck will be invoked for each received message with
451
+ * Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
432
452
  * the {@link Message} as argument.
433
453
  *
434
454
  * Note: The library will generate an unique ID if there is none provided in the headers.
@@ -571,11 +591,14 @@ var __extends = (this && this.__extends) || (function () {
571
591
  })();
572
592
  Object.defineProperty(exports, "__esModule", { value: true });
573
593
  var client_1 = __webpack_require__(/*! ../client */ "./src/client.ts");
594
+ var heartbeat_info_1 = __webpack_require__(/*! ./heartbeat-info */ "./src/compatibility/heartbeat-info.ts");
574
595
  /**
575
596
  * Available for backward compatibility, please shift to using {@link Client}.
576
597
  *
577
598
  * **Deprecated**
578
599
  *
600
+ * Part of `@stomp/stompjs`.
601
+ *
579
602
  * To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
580
603
  */
581
604
  var CompatClient = /** @class */ (function (_super) {
@@ -594,7 +617,7 @@ var CompatClient = /** @class */ (function (_super) {
594
617
  * It is no op now. No longer needed. Large packets work out of the box.
595
618
  */
596
619
  _this.maxWebSocketFrameSize = 16 * 1024;
597
- _this._heartbeatInfo = new HeartbeatInfo(_this);
620
+ _this._heartbeatInfo = new heartbeat_info_1.HeartbeatInfo(_this);
598
621
  _this.reconnect_delay = 0;
599
622
  _this.webSocketFactory = webSocketFactory;
600
623
  // Default from previous version
@@ -612,10 +635,12 @@ var CompatClient = /** @class */ (function (_super) {
612
635
  for (var _i = 0; _i < arguments.length; _i++) {
613
636
  args[_i] = arguments[_i];
614
637
  }
615
- var closeEventCallback, connectCallback, errorCallback;
638
+ var closeEventCallback;
639
+ var connectCallback;
640
+ var errorCallback;
616
641
  var headers = {};
617
642
  if (args.length < 2) {
618
- throw ("Connect requires at least 2 arguments");
643
+ throw new Error(('Connect requires at least 2 arguments'));
619
644
  }
620
645
  if (typeof (args[1]) === 'function') {
621
646
  headers = args[0], connectCallback = args[1], errorCallback = args[2], closeEventCallback = args[3];
@@ -623,10 +648,10 @@ var CompatClient = /** @class */ (function (_super) {
623
648
  else {
624
649
  switch (args.length) {
625
650
  case 6:
626
- headers['login'] = args[0], headers['passcode'] = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4], headers['host'] = args[5];
651
+ headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4], headers.host = args[5];
627
652
  break;
628
653
  default:
629
- headers['login'] = args[0], headers['passcode'] = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4];
654
+ headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4];
630
655
  }
631
656
  }
632
657
  return [headers, connectCallback, errorCallback, closeEventCallback];
@@ -720,6 +745,7 @@ var CompatClient = /** @class */ (function (_super) {
720
745
  CompatClient.prototype.send = function (destination, headers, body) {
721
746
  if (headers === void 0) { headers = {}; }
722
747
  if (body === void 0) { body = ''; }
748
+ headers = Object.assign({}, headers);
723
749
  var skipContentLengthHeader = (headers['content-length'] === false);
724
750
  if (skipContentLengthHeader) {
725
751
  delete headers['content-length'];
@@ -834,7 +860,23 @@ var CompatClient = /** @class */ (function (_super) {
834
860
  return CompatClient;
835
861
  }(client_1.Client));
836
862
  exports.CompatClient = CompatClient;
863
+
864
+
865
+ /***/ }),
866
+
867
+ /***/ "./src/compatibility/heartbeat-info.ts":
868
+ /*!*********************************************!*\
869
+ !*** ./src/compatibility/heartbeat-info.ts ***!
870
+ \*********************************************/
871
+ /*! no static exports found */
872
+ /***/ (function(module, exports, __webpack_require__) {
873
+
874
+ "use strict";
875
+
876
+ Object.defineProperty(exports, "__esModule", { value: true });
837
877
  /**
878
+ * Part of `@stomp/stompjs`.
879
+ *
838
880
  * @internal
839
881
  */
840
882
  var HeartbeatInfo = /** @class */ (function () {
@@ -863,6 +905,7 @@ var HeartbeatInfo = /** @class */ (function () {
863
905
  });
864
906
  return HeartbeatInfo;
865
907
  }());
908
+ exports.HeartbeatInfo = HeartbeatInfo;
866
909
 
867
910
 
868
911
  /***/ }),
@@ -881,6 +924,12 @@ var versions_1 = __webpack_require__(/*! ../versions */ "./src/versions.ts");
881
924
  var compat_client_1 = __webpack_require__(/*! ./compat-client */ "./src/compatibility/compat-client.ts");
882
925
  /**
883
926
  * STOMP Class, acts like a factory to create {@link Client}.
927
+ *
928
+ * Part of `@stomp/stompjs`.
929
+ *
930
+ * **Deprecated**
931
+ *
932
+ * It will be removed in next major version. Please switch to {@link Client}.
884
933
  */
885
934
  var Stomp = /** @class */ (function () {
886
935
  function Stomp() {
@@ -893,6 +942,11 @@ var Stomp = /** @class */ (function () {
893
942
  * var url = "ws://localhost:61614/stomp";
894
943
  * var client = Stomp.client(url);
895
944
  * ```
945
+ *
946
+ * **Deprecated**
947
+ *
948
+ * It will be removed in next major version. Please switch to {@link Client}
949
+ * using [Client#brokerURL]{@link Client#brokerURL}.
896
950
  */
897
951
  Stomp.client = function (url, protocols) {
898
952
  // This is a hack to allow another implementation than the standard
@@ -910,18 +964,19 @@ var Stomp = /** @class */ (function () {
910
964
  if (protocols == null) {
911
965
  protocols = versions_1.Versions.default.protocolVersions();
912
966
  }
913
- var ws_fn = function () {
967
+ var wsFn = function () {
914
968
  var klass = Stomp.WebSocketClass || WebSocket;
915
969
  return new klass(url, protocols);
916
970
  };
917
- return new compat_client_1.CompatClient(ws_fn);
971
+ return new compat_client_1.CompatClient(wsFn);
918
972
  };
919
973
  /**
920
974
  * This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
921
975
  * specify the WebSocket to use (either a standard HTML5 WebSocket or
922
976
  * a similar object).
923
977
  *
924
- * In order to support reconnection, the function Client._connect should be callable more than once. While reconnecting
978
+ * In order to support reconnection, the function Client._connect should be callable more than once.
979
+ * While reconnecting
925
980
  * a new instance of underlying transport (TCP Socket, WebSocket or SockJS) will be needed. So, this function
926
981
  * alternatively allows passing a function that should return a new instance of the underlying socket.
927
982
  *
@@ -930,10 +985,15 @@ var Stomp = /** @class */ (function () {
930
985
  * return new WebSocket('ws://localhost:15674/ws')
931
986
  * });
932
987
  * ```
988
+ *
989
+ * **Deprecated**
990
+ *
991
+ * It will be removed in next major version. Please switch to {@link Client}
992
+ * using [Client#webSocketFactory]{@link Client#webSocketFactory}.
933
993
  */
934
994
  Stomp.over = function (ws) {
935
- var ws_fn = typeof (ws) === "function" ? ws : function () { return ws; };
936
- return new compat_client_1.CompatClient(ws_fn);
995
+ var wsFn = typeof (ws) === 'function' ? ws : function () { return ws; };
996
+ return new compat_client_1.CompatClient(wsFn);
937
997
  };
938
998
  /**
939
999
  * In case you need to use a non standard class for WebSocket.
@@ -945,7 +1005,14 @@ var Stomp = /** @class */ (function () {
945
1005
  * Stomp = StompJs.Stomp;
946
1006
  * Stomp.WebSocketClass = require('websocket').w3cwebsocket;
947
1007
  * ```
1008
+ *
1009
+ * **Deprecated**
1010
+ *
1011
+ *
1012
+ * It will be removed in next major version. Please switch to {@link Client}
1013
+ * using [Client#webSocketFactory]{@link Client#webSocketFactory}.
948
1014
  */
1015
+ // tslint:disable-next-line:variable-name
949
1016
  Stomp.WebSocketClass = null;
950
1017
  return Stomp;
951
1018
  }());
@@ -969,6 +1036,8 @@ var byte_1 = __webpack_require__(/*! ./byte */ "./src/byte.ts");
969
1036
  * Frame class represents a STOMP frame. Many of the callbacks pass the Frame received from
970
1037
  * the STOMP broker. For advanced usage you might need to access [headers]{@link Frame#headers}.
971
1038
  *
1039
+ * Part of `@stomp/stompjs`.
1040
+ *
972
1041
  * {@link Message} is an extended Frame.
973
1042
  */
974
1043
  var Frame = /** @class */ (function () {
@@ -980,7 +1049,7 @@ var Frame = /** @class */ (function () {
980
1049
  function Frame(params) {
981
1050
  var command = params.command, headers = params.headers, body = params.body, binaryBody = params.binaryBody, escapeHeaderValues = params.escapeHeaderValues, skipContentLengthHeader = params.skipContentLengthHeader;
982
1051
  this.command = command;
983
- this.headers = headers || {};
1052
+ this.headers = Object.assign({}, headers || {});
984
1053
  if (binaryBody) {
985
1054
  this._binaryBody = binaryBody;
986
1055
  this.isBinaryBody = true;
@@ -1054,6 +1123,8 @@ var Frame = /** @class */ (function () {
1054
1123
  * serialize this Frame in a format suitable to be passed to WebSocket.
1055
1124
  * If the body is string the output will be string.
1056
1125
  * If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer.
1126
+ *
1127
+ * @internal
1057
1128
  */
1058
1129
  Frame.prototype.serialize = function () {
1059
1130
  var cmdAndHeaders = this.serializeCmdAndHeaders();
@@ -1061,7 +1132,7 @@ var Frame = /** @class */ (function () {
1061
1132
  return Frame.toUnit8Array(cmdAndHeaders, this._binaryBody).buffer;
1062
1133
  }
1063
1134
  else {
1064
- return cmdAndHeaders + this._body + byte_1.Byte.NULL;
1135
+ return cmdAndHeaders + this._body + byte_1.BYTE.NULL;
1065
1136
  }
1066
1137
  };
1067
1138
  Frame.prototype.serializeCmdAndHeaders = function () {
@@ -1082,7 +1153,7 @@ var Frame = /** @class */ (function () {
1082
1153
  if (this.isBinaryBody || (!this.isBodyEmpty() && !this.skipContentLengthHeader)) {
1083
1154
  lines.push("content-length:" + this.bodyLength());
1084
1155
  }
1085
- return lines.join(byte_1.Byte.LF) + byte_1.Byte.LF + byte_1.Byte.LF;
1156
+ return lines.join(byte_1.BYTE.LF) + byte_1.BYTE.LF + byte_1.BYTE.LF;
1086
1157
  };
1087
1158
  Frame.prototype.isBodyEmpty = function () {
1088
1159
  return this.bodyLength() === 0;
@@ -1120,13 +1191,13 @@ var Frame = /** @class */ (function () {
1120
1191
  * Escape header values
1121
1192
  */
1122
1193
  Frame.hdrValueEscape = function (str) {
1123
- return str.replace(/\\/g, "\\\\").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/:/g, "\\c");
1194
+ return str.replace(/\\/g, '\\\\').replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/:/g, '\\c');
1124
1195
  };
1125
1196
  /**
1126
1197
  * UnEscape header values
1127
1198
  */
1128
1199
  Frame.hdrValueUnEscape = function (str) {
1129
- return str.replace(/\\r/g, "\r").replace(/\\n/g, "\n").replace(/\\c/g, ":").replace(/\\\\/g, "\\");
1200
+ return str.replace(/\\r/g, '\r').replace(/\\n/g, '\n').replace(/\\c/g, ':').replace(/\\\\/g, '\\');
1130
1201
  };
1131
1202
  return Frame;
1132
1203
  }());
@@ -1150,13 +1221,61 @@ function __export(m) {
1150
1221
  Object.defineProperty(exports, "__esModule", { value: true });
1151
1222
  __export(__webpack_require__(/*! ./client */ "./src/client.ts"));
1152
1223
  __export(__webpack_require__(/*! ./frame */ "./src/frame.ts"));
1224
+ __export(__webpack_require__(/*! ./message */ "./src/message.ts"));
1153
1225
  __export(__webpack_require__(/*! ./parser */ "./src/parser.ts"));
1226
+ __export(__webpack_require__(/*! ./stomp-config */ "./src/stomp-config.ts"));
1227
+ __export(__webpack_require__(/*! ./stomp-headers */ "./src/stomp-headers.ts"));
1228
+ __export(__webpack_require__(/*! ./stomp-subscription */ "./src/stomp-subscription.ts"));
1229
+ __export(__webpack_require__(/*! ./transaction */ "./src/transaction.ts"));
1154
1230
  __export(__webpack_require__(/*! ./versions */ "./src/versions.ts"));
1155
1231
  // Compatibility code
1156
1232
  __export(__webpack_require__(/*! ./compatibility/compat-client */ "./src/compatibility/compat-client.ts"));
1157
1233
  __export(__webpack_require__(/*! ./compatibility/stomp */ "./src/compatibility/stomp.ts"));
1158
1234
 
1159
1235
 
1236
+ /***/ }),
1237
+
1238
+ /***/ "./src/message.ts":
1239
+ /*!************************!*\
1240
+ !*** ./src/message.ts ***!
1241
+ \************************/
1242
+ /*! no static exports found */
1243
+ /***/ (function(module, exports, __webpack_require__) {
1244
+
1245
+ "use strict";
1246
+
1247
+ var __extends = (this && this.__extends) || (function () {
1248
+ var extendStatics = Object.setPrototypeOf ||
1249
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1250
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
1251
+ return function (d, b) {
1252
+ extendStatics(d, b);
1253
+ function __() { this.constructor = d; }
1254
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1255
+ };
1256
+ })();
1257
+ Object.defineProperty(exports, "__esModule", { value: true });
1258
+ var frame_1 = __webpack_require__(/*! ./frame */ "./src/frame.ts");
1259
+ /**
1260
+ * Instance of Message will be passed to [subscription callback]{@link Client#subscribe}
1261
+ * and [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
1262
+ * Since it is an extended {@link Frame}, you can access [headers]{@link Frame#headers}
1263
+ * and [body]{@link Frame#body} as properties.
1264
+ *
1265
+ * Part of `@stomp/stompjs`.
1266
+ *
1267
+ * See [Client#subscribe]{@link Client#subscribe} for example.
1268
+ */
1269
+ var Message = /** @class */ (function (_super) {
1270
+ __extends(Message, _super);
1271
+ function Message() {
1272
+ return _super !== null && _super.apply(this, arguments) || this;
1273
+ }
1274
+ return Message;
1275
+ }(frame_1.Frame));
1276
+ exports.Message = Message;
1277
+
1278
+
1160
1279
  /***/ }),
1161
1280
 
1162
1281
  /***/ "./src/parser.ts":
@@ -1223,6 +1342,8 @@ var COLON = 58;
1223
1342
  *
1224
1343
  * Check the parser.spec.js to understand cases that this parser is supposed to handle.
1225
1344
  *
1345
+ * Part of `@stomp/stompjs`.
1346
+ *
1226
1347
  * @internal
1227
1348
  */
1228
1349
  var Parser = /** @class */ (function () {
@@ -1242,6 +1363,7 @@ var Parser = /** @class */ (function () {
1242
1363
  else {
1243
1364
  chunk = this._encoder.encode(segment);
1244
1365
  }
1366
+ // tslint:disable-next-line:prefer-for-of
1245
1367
  for (var i = 0; i < chunk.length; i++) {
1246
1368
  var byte = chunk[i];
1247
1369
  this._onByte(byte);
@@ -1310,10 +1432,10 @@ var Parser = /** @class */ (function () {
1310
1432
  };
1311
1433
  Parser.prototype._setupCollectBody = function () {
1312
1434
  var contentLengthHeader = this._results.headers.filter(function (header) {
1313
- return header[0] === "content-length";
1435
+ return header[0] === 'content-length';
1314
1436
  })[0];
1315
1437
  if (contentLengthHeader) {
1316
- this._bodyBytesRemaining = parseInt(contentLengthHeader[1]);
1438
+ this._bodyBytesRemaining = parseInt(contentLengthHeader[1], 10);
1317
1439
  this._onByte = this._collectBodyFixedSize;
1318
1440
  }
1319
1441
  else {
@@ -1356,7 +1478,7 @@ var Parser = /** @class */ (function () {
1356
1478
  this._results = {
1357
1479
  command: undefined,
1358
1480
  headers: [],
1359
- binaryBody: undefined,
1481
+ binaryBody: undefined
1360
1482
  };
1361
1483
  this._token = [];
1362
1484
  this._headerKey = undefined;
@@ -1367,6 +1489,33 @@ var Parser = /** @class */ (function () {
1367
1489
  exports.Parser = Parser;
1368
1490
 
1369
1491
 
1492
+ /***/ }),
1493
+
1494
+ /***/ "./src/stomp-config.ts":
1495
+ /*!*****************************!*\
1496
+ !*** ./src/stomp-config.ts ***!
1497
+ \*****************************/
1498
+ /*! no static exports found */
1499
+ /***/ (function(module, exports, __webpack_require__) {
1500
+
1501
+ "use strict";
1502
+
1503
+ Object.defineProperty(exports, "__esModule", { value: true });
1504
+ /**
1505
+ * Configuration options for STOMP Client, each key corresponds to
1506
+ * field by the same name in {@link Client}. This can be passed to
1507
+ * the constructor of {@link Client} or to [Client#configure]{@link Client#configure}.
1508
+ *
1509
+ * Part of `@stomp/stompjs`.
1510
+ */
1511
+ var StompConfig = /** @class */ (function () {
1512
+ function StompConfig() {
1513
+ }
1514
+ return StompConfig;
1515
+ }());
1516
+ exports.StompConfig = StompConfig;
1517
+
1518
+
1370
1519
  /***/ }),
1371
1520
 
1372
1521
  /***/ "./src/stomp-handler.ts":
@@ -1380,12 +1529,14 @@ exports.Parser = Parser;
1380
1529
 
1381
1530
  Object.defineProperty(exports, "__esModule", { value: true });
1382
1531
  var byte_1 = __webpack_require__(/*! ./byte */ "./src/byte.ts");
1383
- var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1384
1532
  var frame_1 = __webpack_require__(/*! ./frame */ "./src/frame.ts");
1385
1533
  var parser_1 = __webpack_require__(/*! ./parser */ "./src/parser.ts");
1534
+ var versions_1 = __webpack_require__(/*! ./versions */ "./src/versions.ts");
1386
1535
  /**
1387
1536
  * The STOMP protocol handler
1388
1537
  *
1538
+ * Part of `@stomp/stompjs`.
1539
+ *
1389
1540
  * @internal
1390
1541
  */
1391
1542
  var StompHandler = /** @class */ (function () {
@@ -1396,7 +1547,7 @@ var StompHandler = /** @class */ (function () {
1396
1547
  this._webSocket = _webSocket;
1397
1548
  this._serverFrameHandlers = {
1398
1549
  // [CONNECTED Frame](http://stomp.github.com/stomp-specification-1.2.html#CONNECTED_Frame)
1399
- 'CONNECTED': function (frame) {
1550
+ CONNECTED: function (frame) {
1400
1551
  _this.debug("connected to server " + frame.headers.server);
1401
1552
  _this._connected = true;
1402
1553
  _this._connectedVersion = frame.headers.version;
@@ -1408,7 +1559,7 @@ var StompHandler = /** @class */ (function () {
1408
1559
  _this.onConnect(frame);
1409
1560
  },
1410
1561
  // [MESSAGE Frame](http://stomp.github.com/stomp-specification-1.2.html#MESSAGE)
1411
- "MESSAGE": function (frame) {
1562
+ MESSAGE: function (frame) {
1412
1563
  // the callback is registered when the client calls
1413
1564
  // `subscribe()`.
1414
1565
  // If there is no registered subscription for the received message,
@@ -1421,7 +1572,7 @@ var StompHandler = /** @class */ (function () {
1421
1572
  // bless the frame to be a Message
1422
1573
  var message = frame;
1423
1574
  var client = _this;
1424
- var messageId = _this._connectedVersion === versions_1.Versions.V1_2 ? message.headers["ack"] : message.headers["message-id"];
1575
+ var messageId = _this._connectedVersion === versions_1.Versions.V1_2 ? message.headers.ack : message.headers['message-id'];
1425
1576
  // add `ack()` and `nack()` methods directly to the returned frame
1426
1577
  // so that a simple call to `message.ack()` can acknowledge the message.
1427
1578
  message.ack = function (headers) {
@@ -1435,19 +1586,19 @@ var StompHandler = /** @class */ (function () {
1435
1586
  onReceive(message);
1436
1587
  },
1437
1588
  // [RECEIPT Frame](http://stomp.github.com/stomp-specification-1.2.html#RECEIPT)
1438
- "RECEIPT": function (frame) {
1439
- var callback = _this._receiptWatchers[frame.headers["receipt-id"]];
1589
+ RECEIPT: function (frame) {
1590
+ var callback = _this._receiptWatchers[frame.headers['receipt-id']];
1440
1591
  if (callback) {
1441
1592
  callback(frame);
1442
1593
  // Server will acknowledge only once, remove the callback
1443
- delete _this._receiptWatchers[frame.headers["receipt-id"]];
1594
+ delete _this._receiptWatchers[frame.headers['receipt-id']];
1444
1595
  }
1445
1596
  else {
1446
1597
  _this.onUnhandledReceipt(frame);
1447
1598
  }
1448
1599
  },
1449
1600
  // [ERROR Frame](http://stomp.github.com/stomp-specification-1.2.html#ERROR)
1450
- 'ERROR': function (frame) {
1601
+ ERROR: function (frame) {
1451
1602
  _this.onStompError(frame);
1452
1603
  }
1453
1604
  };
@@ -1492,7 +1643,7 @@ var StompHandler = /** @class */ (function () {
1492
1643
  },
1493
1644
  // On Incoming Ping
1494
1645
  function () {
1495
- _this.debug("<<< PONG");
1646
+ _this.debug('<<< PONG');
1496
1647
  });
1497
1648
  this._webSocket.onmessage = function (evt) {
1498
1649
  _this.debug('Received data');
@@ -1505,10 +1656,12 @@ var StompHandler = /** @class */ (function () {
1505
1656
  _this._cleanUp();
1506
1657
  };
1507
1658
  this._webSocket.onopen = function () {
1659
+ // Clone before updating
1660
+ var connectHeaders = Object.assign({}, _this.connectHeaders);
1508
1661
  _this.debug('Web Socket Opened...');
1509
- _this.connectHeaders["accept-version"] = _this.stompVersions.supportedVersions();
1510
- _this.connectHeaders["heart-beat"] = [_this.heartbeatOutgoing, _this.heartbeatIncoming].join(',');
1511
- _this._transmit({ command: "CONNECT", headers: _this.connectHeaders });
1662
+ connectHeaders['accept-version'] = _this.stompVersions.supportedVersions();
1663
+ connectHeaders['heart-beat'] = [_this.heartbeatOutgoing, _this.heartbeatIncoming].join(',');
1664
+ _this._transmit({ command: 'CONNECT', headers: connectHeaders });
1512
1665
  };
1513
1666
  };
1514
1667
  StompHandler.prototype._setupHeartbeat = function (headers) {
@@ -1519,13 +1672,13 @@ var StompHandler = /** @class */ (function () {
1519
1672
  // heart-beat header received from the server looks like:
1520
1673
  //
1521
1674
  // heart-beat: sx, sy
1522
- var _a = (headers['heart-beat']).split(",").map(function (v) { return parseInt(v); }), serverOutgoing = _a[0], serverIncoming = _a[1];
1675
+ var _a = (headers['heart-beat']).split(',').map(function (v) { return parseInt(v, 10); }), serverOutgoing = _a[0], serverIncoming = _a[1];
1523
1676
  if ((this.heartbeatOutgoing !== 0) && (serverIncoming !== 0)) {
1524
1677
  var ttl = Math.max(this.heartbeatOutgoing, serverIncoming);
1525
1678
  this.debug("send PING every " + ttl + "ms");
1526
1679
  this._pinger = setInterval(function () {
1527
- _this._webSocket.send(byte_1.Byte.LF);
1528
- _this.debug(">>> PING");
1680
+ _this._webSocket.send(byte_1.BYTE.LF);
1681
+ _this.debug('>>> PING');
1529
1682
  }, ttl);
1530
1683
  }
1531
1684
  if ((this.heartbeatIncoming !== 0) && (serverOutgoing !== 0)) {
@@ -1572,15 +1725,17 @@ var StompHandler = /** @class */ (function () {
1572
1725
  var _this = this;
1573
1726
  if (this.connected) {
1574
1727
  try {
1575
- if (!this.disconnectHeaders['receipt']) {
1576
- this.disconnectHeaders['receipt'] = "close-" + this._counter++;
1728
+ // clone before updating
1729
+ var disconnectHeaders = Object.assign({}, this.disconnectHeaders);
1730
+ if (!disconnectHeaders.receipt) {
1731
+ disconnectHeaders.receipt = "close-" + this._counter++;
1577
1732
  }
1578
- this.watchForReceipt(this.disconnectHeaders['receipt'], function (frame) {
1733
+ this.watchForReceipt(disconnectHeaders.receipt, function (frame) {
1579
1734
  _this._webSocket.close();
1580
1735
  _this._cleanUp();
1581
1736
  _this.onDisconnect(frame);
1582
1737
  });
1583
- this._transmit({ command: "DISCONNECT", headers: this.disconnectHeaders });
1738
+ this._transmit({ command: 'DISCONNECT', headers: disconnectHeaders });
1584
1739
  }
1585
1740
  catch (error) {
1586
1741
  this.debug("Ignoring error during disconnect " + error);
@@ -1603,10 +1758,10 @@ var StompHandler = /** @class */ (function () {
1603
1758
  };
1604
1759
  StompHandler.prototype.publish = function (params) {
1605
1760
  var destination = params.destination, headers = params.headers, body = params.body, binaryBody = params.binaryBody, skipContentLengthHeader = params.skipContentLengthHeader;
1606
- headers = Object.assign({ destination: destination }, headers);
1761
+ var hdrs = Object.assign({ destination: destination }, headers);
1607
1762
  this._transmit({
1608
- command: "SEND",
1609
- headers: headers,
1763
+ command: 'SEND',
1764
+ headers: hdrs,
1610
1765
  body: body,
1611
1766
  binaryBody: binaryBody,
1612
1767
  skipContentLengthHeader: skipContentLengthHeader
@@ -1617,12 +1772,13 @@ var StompHandler = /** @class */ (function () {
1617
1772
  };
1618
1773
  StompHandler.prototype.subscribe = function (destination, callback, headers) {
1619
1774
  if (headers === void 0) { headers = {}; }
1775
+ headers = Object.assign({}, headers);
1620
1776
  if (!headers.id) {
1621
1777
  headers.id = "sub-" + this._counter++;
1622
1778
  }
1623
1779
  headers.destination = destination;
1624
1780
  this._subscriptions[headers.id] = callback;
1625
- this._transmit({ command: "SUBSCRIBE", headers: headers });
1781
+ this._transmit({ command: 'SUBSCRIBE', headers: headers });
1626
1782
  var client = this;
1627
1783
  return {
1628
1784
  id: headers.id,
@@ -1633,17 +1789,15 @@ var StompHandler = /** @class */ (function () {
1633
1789
  };
1634
1790
  StompHandler.prototype.unsubscribe = function (id, headers) {
1635
1791
  if (headers === void 0) { headers = {}; }
1636
- if (headers == null) {
1637
- headers = {};
1638
- }
1792
+ headers = Object.assign({}, headers);
1639
1793
  delete this._subscriptions[id];
1640
1794
  headers.id = id;
1641
- this._transmit({ command: "UNSUBSCRIBE", headers: headers });
1795
+ this._transmit({ command: 'UNSUBSCRIBE', headers: headers });
1642
1796
  };
1643
1797
  StompHandler.prototype.begin = function (transactionId) {
1644
1798
  var txId = transactionId || ("tx-" + this._counter++);
1645
1799
  this._transmit({
1646
- command: "BEGIN", headers: {
1800
+ command: 'BEGIN', headers: {
1647
1801
  transaction: txId
1648
1802
  }
1649
1803
  });
@@ -1660,45 +1814,128 @@ var StompHandler = /** @class */ (function () {
1660
1814
  };
1661
1815
  StompHandler.prototype.commit = function (transactionId) {
1662
1816
  this._transmit({
1663
- command: "COMMIT", headers: {
1817
+ command: 'COMMIT', headers: {
1664
1818
  transaction: transactionId
1665
1819
  }
1666
1820
  });
1667
1821
  };
1668
1822
  StompHandler.prototype.abort = function (transactionId) {
1669
1823
  this._transmit({
1670
- command: "ABORT", headers: {
1824
+ command: 'ABORT', headers: {
1671
1825
  transaction: transactionId
1672
1826
  }
1673
1827
  });
1674
1828
  };
1675
1829
  StompHandler.prototype.ack = function (messageId, subscriptionId, headers) {
1676
1830
  if (headers === void 0) { headers = {}; }
1831
+ headers = Object.assign({}, headers);
1677
1832
  if (this._connectedVersion === versions_1.Versions.V1_2) {
1678
- headers["id"] = messageId;
1833
+ headers.id = messageId;
1679
1834
  }
1680
1835
  else {
1681
- headers["message-id"] = messageId;
1836
+ headers['message-id'] = messageId;
1682
1837
  }
1683
1838
  headers.subscription = subscriptionId;
1684
- this._transmit({ command: "ACK", headers: headers });
1839
+ this._transmit({ command: 'ACK', headers: headers });
1685
1840
  };
1686
1841
  StompHandler.prototype.nack = function (messageId, subscriptionId, headers) {
1687
1842
  if (headers === void 0) { headers = {}; }
1843
+ headers = Object.assign({}, headers);
1688
1844
  if (this._connectedVersion === versions_1.Versions.V1_2) {
1689
- headers["id"] = messageId;
1845
+ headers.id = messageId;
1690
1846
  }
1691
1847
  else {
1692
- headers["message-id"] = messageId;
1848
+ headers['message-id'] = messageId;
1693
1849
  }
1694
1850
  headers.subscription = subscriptionId;
1695
- return this._transmit({ command: "NACK", headers: headers });
1851
+ return this._transmit({ command: 'NACK', headers: headers });
1696
1852
  };
1697
1853
  return StompHandler;
1698
1854
  }());
1699
1855
  exports.StompHandler = StompHandler;
1700
1856
 
1701
1857
 
1858
+ /***/ }),
1859
+
1860
+ /***/ "./src/stomp-headers.ts":
1861
+ /*!******************************!*\
1862
+ !*** ./src/stomp-headers.ts ***!
1863
+ \******************************/
1864
+ /*! no static exports found */
1865
+ /***/ (function(module, exports, __webpack_require__) {
1866
+
1867
+ "use strict";
1868
+
1869
+ Object.defineProperty(exports, "__esModule", { value: true });
1870
+ /**
1871
+ * STOMP headers. Many functions calls will accept headers as parameters.
1872
+ * The headers sent by Broker will be available as [Frame#headers]{@link Frame#headers}.
1873
+ *
1874
+ * `key` and `value` must be valid strings.
1875
+ * In addition, `key` must not contain `CR`, `LF`, or `:`.
1876
+ *
1877
+ * Part of `@stomp/stompjs`.
1878
+ */
1879
+ var StompHeaders = /** @class */ (function () {
1880
+ function StompHeaders() {
1881
+ }
1882
+ return StompHeaders;
1883
+ }());
1884
+ exports.StompHeaders = StompHeaders;
1885
+
1886
+
1887
+ /***/ }),
1888
+
1889
+ /***/ "./src/stomp-subscription.ts":
1890
+ /*!***********************************!*\
1891
+ !*** ./src/stomp-subscription.ts ***!
1892
+ \***********************************/
1893
+ /*! no static exports found */
1894
+ /***/ (function(module, exports, __webpack_require__) {
1895
+
1896
+ "use strict";
1897
+
1898
+ Object.defineProperty(exports, "__esModule", { value: true });
1899
+ /**
1900
+ * Call [Client#subscribe]{@link Client#subscribe} to create a StompSubscription.
1901
+ *
1902
+ * Part of `@stomp/stompjs`.
1903
+ */
1904
+ var StompSubscription = /** @class */ (function () {
1905
+ function StompSubscription() {
1906
+ }
1907
+ return StompSubscription;
1908
+ }());
1909
+ exports.StompSubscription = StompSubscription;
1910
+
1911
+
1912
+ /***/ }),
1913
+
1914
+ /***/ "./src/transaction.ts":
1915
+ /*!****************************!*\
1916
+ !*** ./src/transaction.ts ***!
1917
+ \****************************/
1918
+ /*! no static exports found */
1919
+ /***/ (function(module, exports, __webpack_require__) {
1920
+
1921
+ "use strict";
1922
+
1923
+ Object.defineProperty(exports, "__esModule", { value: true });
1924
+ /**
1925
+ * A Transaction is created by calling [Client#begin]{@link Client#begin}
1926
+ *
1927
+ * Part of `@stomp/stompjs`.
1928
+ *
1929
+ * TODO: Example and caveat
1930
+ */
1931
+ var Transaction = /** @class */ (function () {
1932
+ function Transaction() {
1933
+ }
1934
+ return Transaction;
1935
+ }());
1936
+ exports.Transaction = Transaction;
1937
+
1938
+
1702
1939
  /***/ }),
1703
1940
 
1704
1941
  /***/ "./src/versions.ts":
@@ -1713,6 +1950,8 @@ exports.StompHandler = StompHandler;
1713
1950
  Object.defineProperty(exports, "__esModule", { value: true });
1714
1951
  /**
1715
1952
  * Supported STOMP versions
1953
+ *
1954
+ * Part of `@stomp/stompjs`.
1716
1955
  */
1717
1956
  var Versions = /** @class */ (function () {
1718
1957
  /**
@@ -1724,22 +1963,28 @@ var Versions = /** @class */ (function () {
1724
1963
  function Versions(versions) {
1725
1964
  this.versions = versions;
1726
1965
  }
1966
+ /**
1967
+ * Used as part of CONNECT STOMP Frame
1968
+ */
1727
1969
  Versions.prototype.supportedVersions = function () {
1728
1970
  return this.versions.join(',');
1729
1971
  };
1972
+ /**
1973
+ * Used while creating a WebSocket
1974
+ */
1730
1975
  Versions.prototype.protocolVersions = function () {
1731
1976
  return this.versions.map(function (x) { return "v" + x.replace('.', '') + ".stomp"; });
1732
1977
  };
1733
1978
  /**
1734
- * 1.0
1979
+ * Indicates protocol version 1.0
1735
1980
  */
1736
1981
  Versions.V1_0 = '1.0';
1737
1982
  /**
1738
- * 1.1
1983
+ * Indicates protocol version 1.1
1739
1984
  */
1740
1985
  Versions.V1_1 = '1.1';
1741
1986
  /**
1742
- * 1.2
1987
+ * Indicates protocol version 1.2
1743
1988
  */
1744
1989
  Versions.V1_2 = '1.2';
1745
1990
  /**