@kq_npm/client_leaflet
Version:
KQGIS Client leaflet for Javascript
1,267 lines (1,256 loc) • 8.43 MB
JavaScript
/*!
*
* kqgis_client_leaflet.(http://www.kqgeo.com/)
* Copyright© 2000 - 2021 KqGIS Software Co.Ltd
* license: Apache-2.0
* version: v8.5.8
*
*/
/******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 9779:
/***/ (function(module, exports, __webpack_require__) {
/* module decorator */ module = __webpack_require__.nmd(module);
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
(function webpackUniversalModuleDefinition(root, factory) {
if (( false ? 0 : _typeof(exports)) === 'object' && ( false ? 0 : _typeof(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}
})(typeof self !== 'undefined' ? self : this, function () {
return /******/function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/
var installedModules = {};
/******/
/******/ // The require function
/******/
function __nested_webpack_require_1076__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/if (installedModules[moduleId]) {
/******/return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/
var module = installedModules[moduleId] = {
/******/i: moduleId,
/******/l: false,
/******/exports: {}
/******/
};
/******/
/******/ // Execute the module function
/******/
modules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_1076__);
/******/
/******/ // Flag the module as loaded
/******/
module.l = true;
/******/
/******/ // Return the exports of the module
/******/
return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/
__nested_webpack_require_1076__.m = modules;
/******/
/******/ // expose the module cache
/******/
__nested_webpack_require_1076__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/
__nested_webpack_require_1076__.d = function (exports, name, getter) {
/******/if (!__nested_webpack_require_1076__.o(exports, name)) {
/******/Object.defineProperty(exports, name, {
enumerable: true,
get: getter
});
/******/
}
/******/
};
/******/
/******/ // define __esModule on exports
/******/
__nested_webpack_require_1076__.r = function (exports) {
/******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/Object.defineProperty(exports, Symbol.toStringTag, {
value: 'Module'
});
/******/
}
/******/
Object.defineProperty(exports, '__esModule', {
value: true
});
/******/
};
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/
__nested_webpack_require_1076__.t = function (value, mode) {
/******/if (mode & 1) value = __nested_webpack_require_1076__(value);
/******/
if (mode & 8) return value;
/******/
if (mode & 4 && _typeof(value) === 'object' && value && value.__esModule) return value;
/******/
var ns = Object.create(null);
/******/
__nested_webpack_require_1076__.r(ns);
/******/
Object.defineProperty(ns, 'default', {
enumerable: true,
value: value
});
/******/
if (mode & 2 && typeof value != 'string') for (var key in value) __nested_webpack_require_1076__.d(ns, key, function (key) {
return value[key];
}.bind(null, key));
/******/
return ns;
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/
__nested_webpack_require_1076__.n = function (module) {
/******/var getter = module && module.__esModule ? /******/function getDefault() {
return module['default'];
} : /******/function getModuleExports() {
return module;
};
/******/
__nested_webpack_require_1076__.d(getter, 'a', getter);
/******/
return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/
__nested_webpack_require_1076__.o = function (object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
};
/******/
/******/ // __webpack_public_path__
/******/
__nested_webpack_require_1076__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/
return __nested_webpack_require_1076__(__nested_webpack_require_1076__.s = 0);
/******/
}
/************************************************************************/
/******/({
/***/"./src/byte.ts": (
/*!*********************!*\
!*** ./src/byte.ts ***!
\*********************/
/*! no static exports found */
/***/
function srcByteTs(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Some byte values, used as per STOMP specifications.
*
* Part of `@stomp/stompjs`.
*
* @internal
*/
exports.BYTE = {
// LINEFEED byte (octet 10)
LF: '\x0A',
// NULL byte (octet 0)
NULL: '\x00'
};
/***/
}),
/***/"./src/client.ts": (
/*!***********************!*\
!*** ./src/client.ts ***!
\***********************/
/*! no static exports found */
/***/
function srcClientTs(module, exports, __nested_webpack_require_5970__) {
"use strict";
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = this && this.__generator || function (thisArg, body) {
var _ = {
label: 0,
sent: function sent() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
},
f,
y,
t,
g;
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
return this;
}), g;
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
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;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return {
value: op[1],
done: false
};
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
if (op[0] & 5) throw op[1];
return {
value: op[0] ? op[1] : void 0,
done: true
};
}
};
Object.defineProperty(exports, "__esModule", {
value: true
});
var stomp_handler_1 = __nested_webpack_require_5970__( /*! ./stomp-handler */"./src/stomp-handler.ts");
var versions_1 = __nested_webpack_require_5970__( /*! ./versions */"./src/versions.ts");
var web_socket_state_1 = __nested_webpack_require_5970__( /*! ./web-socket-state */"./src/web-socket-state.ts");
/**
* STOMP Client Class.
*
* Part of `@stomp/stompjs`.
*/
var Client = /** @class */function () {
/**
* Create an instance.
*/
function Client(conf) {
if (conf === void 0) {
conf = {};
}
/**
* STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
*
* Example:
* ```javascript
* // Try only versions 1.0 and 1.1
* client.stompVersions = new Versions(['1.0', '1.1'])
* ```
*/
this.stompVersions = versions_1.Versions["default"];
/**
* automatically reconnect with delay in milliseconds, set to 0 to disable.
*/
this.reconnectDelay = 5000;
/**
* Incoming heartbeat interval in milliseconds. Set to 0 to disable.
*/
this.heartbeatIncoming = 10000;
/**
* Outgoing heartbeat interval in milliseconds. Set to 0 to disable.
*/
this.heartbeatOutgoing = 10000;
/**
* This switches on a non standard behavior while sending WebSocket packets.
* It splits larger (text) packets into chunks of [maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
* Only Java Spring brokers seems to use this mode.
*
* WebSockets, by itself, split large (text) packets,
* so it is not needed with a truly compliant STOMP/WebSocket broker.
* Actually setting it for such broker will cause large messages to fail.
*
* `false` by default.
*
* Binary frames are never split.
*/
this.splitLargeFrames = false;
/**
* See [splitLargeFrames]{@link Client#splitLargeFrames}.
* This has no effect if [splitLargeFrames]{@link Client#splitLargeFrames} is `false`.
*/
this.maxWebSocketChunkSize = 8 * 1024;
/**
* Usually the
* [type of WebSocket frame]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send#Parameters}
* is automatically decided by type of the payload.
* Default is `false`, which should work with all compliant brokers.
*
* Set this flag to force binary frames.
*/
this.forceBinaryWSFrames = false;
/**
* A bug in ReactNative chops a string on occurrence of a NULL.
* See issue [https://github.com/stomp-js/stompjs/issues/89]{@link https://github.com/stomp-js/stompjs/issues/89}.
* This makes incoming WebSocket messages invalid STOMP packets.
* Setting this flag attempts to reverse the damage by appending a NULL.
* If the broker splits a large message into multiple WebSocket messages,
* this flag will cause data loss and abnormal termination of connection.
*
* This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
*/
this.appendMissingNULLonIncoming = false;
this._active = false;
// Dummy callbacks
var noOp = function noOp() {};
this.debug = noOp;
this.beforeConnect = noOp;
this.onConnect = noOp;
this.onDisconnect = noOp;
this.onUnhandledMessage = noOp;
this.onUnhandledReceipt = noOp;
this.onUnhandledFrame = noOp;
this.onStompError = noOp;
this.onWebSocketClose = noOp;
this.onWebSocketError = noOp;
this.logRawCommunication = false;
// These parameters would typically get proper values before connect is called
this.connectHeaders = {};
this._disconnectHeaders = {};
// Apply configuration
this.configure(conf);
}
Object.defineProperty(Client.prototype, "webSocket", {
/**
* Underlying WebSocket instance, READONLY.
*/
get: function get() {
return this._webSocket;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Client.prototype, "disconnectHeaders", {
/**
* Disconnection headers.
*/
get: function get() {
return this._disconnectHeaders;
},
set: function set(value) {
this._disconnectHeaders = value;
if (this._stompHandler) {
this._stompHandler.disconnectHeaders = this._disconnectHeaders;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Client.prototype, "connected", {
/**
* `true` if there is a active connection with STOMP Broker
*/
get: function get() {
return !!this._stompHandler && this._stompHandler.connected;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Client.prototype, "connectedVersion", {
/**
* version of STOMP protocol negotiated with the server, READONLY
*/
get: function get() {
return this._stompHandler ? this._stompHandler.connectedVersion : undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Client.prototype, "active", {
/**
* if the client is active (connected or going to reconnect)
*/
get: function get() {
return this._active;
},
enumerable: true,
configurable: true
});
/**
* Update configuration.
*/
Client.prototype.configure = function (conf) {
// bulk assign all properties to this
Object.assign(this, conf);
};
/**
* Initiate the connection with the broker.
* If the connection breaks, as per [Client#reconnectDelay]{@link Client#reconnectDelay},
* it will keep trying to reconnect.
*
* Call [Client#deactivate]{@link Client#deactivate} to disconnect and stop reconnection attempts.
*/
Client.prototype.activate = function () {
this._active = true;
this._connect();
};
Client.prototype._connect = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.connected) {
this.debug('STOMP: already connected, nothing to do');
return [2 /*return*/];
}
return [4 /*yield*/, this.beforeConnect()];
case 1:
_a.sent();
if (!this._active) {
this.debug('Client has been marked inactive, will not attempt to connect');
return [2 /*return*/];
}
this.debug('Opening Web Socket...');
// Get the actual WebSocket (or a similar object)
this._webSocket = this._createWebSocket();
this._stompHandler = new stomp_handler_1.StompHandler(this, this._webSocket, {
debug: this.debug,
stompVersions: this.stompVersions,
connectHeaders: this.connectHeaders,
disconnectHeaders: this._disconnectHeaders,
heartbeatIncoming: this.heartbeatIncoming,
heartbeatOutgoing: this.heartbeatOutgoing,
splitLargeFrames: this.splitLargeFrames,
maxWebSocketChunkSize: this.maxWebSocketChunkSize,
forceBinaryWSFrames: this.forceBinaryWSFrames,
logRawCommunication: this.logRawCommunication,
appendMissingNULLonIncoming: this.appendMissingNULLonIncoming,
onConnect: function onConnect(frame) {
if (!_this._active) {
_this.debug('STOMP got connected while deactivate was issued, will disconnect now');
_this._disposeStompHandler();
return;
}
_this.onConnect(frame);
},
onDisconnect: function onDisconnect(frame) {
_this.onDisconnect(frame);
},
onStompError: function onStompError(frame) {
_this.onStompError(frame);
},
onWebSocketClose: function onWebSocketClose(evt) {
_this.onWebSocketClose(evt);
// The callback is called before attempting to reconnect, this would allow the client
// to be `deactivated` in the callback.
if (_this._active) {
_this._schedule_reconnect();
}
},
onWebSocketError: function onWebSocketError(evt) {
_this.onWebSocketError(evt);
},
onUnhandledMessage: function onUnhandledMessage(message) {
_this.onUnhandledMessage(message);
},
onUnhandledReceipt: function onUnhandledReceipt(frame) {
_this.onUnhandledReceipt(frame);
},
onUnhandledFrame: function onUnhandledFrame(frame) {
_this.onUnhandledFrame(frame);
}
});
this._stompHandler.start();
return [2 /*return*/];
}
});
});
};
Client.prototype._createWebSocket = function () {
var webSocket;
if (this.webSocketFactory) {
webSocket = this.webSocketFactory();
} else {
webSocket = new WebSocket(this.brokerURL, this.stompVersions.protocolVersions());
}
webSocket.binaryType = 'arraybuffer';
return webSocket;
};
Client.prototype._schedule_reconnect = function () {
var _this = this;
if (this.reconnectDelay > 0) {
this.debug("STOMP: scheduling reconnection in " + this.reconnectDelay + "ms");
this._reconnector = setTimeout(function () {
_this._connect();
}, this.reconnectDelay);
}
};
/**
* Disconnect if connected and stop auto reconnect loop.
* Appropriate callbacks will be invoked if underlying STOMP connection was connected.
*
* To reactivate you can call [Client#activate]{@link Client#activate}.
*/
Client.prototype.deactivate = function () {
// indicate that auto reconnect loop should terminate
this._active = false;
// Clear if a reconnection was scheduled
if (this._reconnector) {
clearTimeout(this._reconnector);
}
this._disposeStompHandler();
};
/**
* Force disconnect if there is an active connection by directly closing the underlying WebSocket.
* This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
* After forcing disconnect, automatic reconnect will be attempted.
* To stop further reconnects call [Client#deactivate]{@link Client#deactivate} as well.
*/
Client.prototype.forceDisconnect = function () {
if (this._webSocket) {
if (this._webSocket.readyState === web_socket_state_1.WebSocketState.CONNECTING || this._webSocket.readyState === web_socket_state_1.WebSocketState.OPEN) {
this._stompHandler._closeWebsocket();
}
}
};
Client.prototype._disposeStompHandler = function () {
// Dispose STOMP Handler
if (this._stompHandler) {
this._stompHandler.dispose();
this._stompHandler = null;
}
};
/**
* Send a message to a named destination. Refer to your STOMP broker documentation for types
* and naming of destinations.
*
* STOMP protocol specifies and suggests some headers and also allows broker specific headers.
*
* `body` must be String.
* You will need to covert the payload to string in case it is not string (e.g. JSON).
*
* To send a binary message body use binaryBody parameter. It should be a
* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
* Sometimes brokers may not support binary frames out of the box.
* Please check your broker documentation.
*
* `content-length` header is automatically added to the STOMP Frame sent to the broker.
* Set `skipContentLengthHeader` to indicate that `content-length` header should not be added.
* For binary messages `content-length` header is always added.
*
* Caution: The broker will, most likely, report an error and disconnect if message body has NULL octet(s)
* and `content-length` header is missing.
*
* ```javascript
* client.publish({destination: "/queue/test", headers: {priority: 9}, body: "Hello, STOMP"});
*
* // Only destination is mandatory parameter
* client.publish({destination: "/queue/test", body: "Hello, STOMP"});
*
* // Skip content-length header in the frame to the broker
* client.publish({"/queue/test", body: "Hello, STOMP", skipContentLengthHeader: true});
*
* var binaryData = generateBinaryData(); // This need to be of type Uint8Array
* // setting content-type header is not mandatory, however a good practice
* client.publish({destination: '/topic/special', binaryBody: binaryData,
* headers: {'content-type': 'application/octet-stream'}});
* ```
*/
Client.prototype.publish = function (params) {
this._stompHandler.publish(params);
};
/**
* STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
* To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
* The value (say receipt-id) for this header needs to be unique for each use. Typically a sequence, a UUID, a
* random number or a combination may be used.
*
* A complaint broker will send a RECEIPT frame when an operation has actually been completed.
* The operation needs to be matched based in the value of the receipt-id.
*
* This method allow watching for a receipt and invoke the callback
* when corresponding receipt has been received.
*
* The actual {@link FrameImpl} will be passed as parameter to the callback.
*
* Example:
* ```javascript
* // Subscribing with acknowledgement
* let receiptId = randomText();
*
* client.watchForReceipt(receiptId, function() {
* // Will be called after server acknowledges
* });
*
* client.subscribe(TEST.destination, onMessage, {receipt: receiptId});
*
*
* // Publishing with acknowledgement
* receiptId = randomText();
*
* client.watchForReceipt(receiptId, function() {
* // Will be called after server acknowledges
* });
* client.publish({destination: TEST.destination, headers: {receipt: receiptId}, body: msg});
* ```
*/
Client.prototype.watchForReceipt = function (receiptId, callback) {
this._stompHandler.watchForReceipt(receiptId, callback);
};
/**
* Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
* the {@link IMessage} as argument.
*
* Note: The library will generate an unique ID if there is none provided in the headers.
* To use your own ID, pass it using the headers argument.
*
* ```javascript
* callback = function(message) {
* // called when the client receives a STOMP message from the server
* if (message.body) {
* alert("got message with body " + message.body)
* } else {
* alert("got empty message");
* }
* });
*
* var subscription = client.subscribe("/queue/test", callback);
*
* // Explicit subscription id
* var mySubId = 'my-subscription-id-001';
* var subscription = client.subscribe(destination, callback, { id: mySubId });
* ```
*/
Client.prototype.subscribe = function (destination, callback, headers) {
if (headers === void 0) {
headers = {};
}
return this._stompHandler.subscribe(destination, callback, headers);
};
/**
* It is preferable to unsubscribe from a subscription by calling
* `unsubscribe()` directly on {@link StompSubscription} returned by `client.subscribe()`:
*
* ```javascript
* var subscription = client.subscribe(destination, onmessage);
* // ...
* subscription.unsubscribe();
* ```
*
* See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
*/
Client.prototype.unsubscribe = function (id, headers) {
if (headers === void 0) {
headers = {};
}
this._stompHandler.unsubscribe(id, headers);
};
/**
* Start a transaction, the returned {@link ITransaction} has methods - [commit]{@link ITransaction#commit}
* and [abort]{@link ITransaction#abort}.
*
* `transactionId` is optional, if not passed the library will generate it internally.
*/
Client.prototype.begin = function (transactionId) {
return this._stompHandler.begin(transactionId);
};
/**
* Commit a transaction.
*
* It is preferable to commit a transaction by calling [commit]{@link ITransaction#commit} directly on
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
*
* ```javascript
* var tx = client.begin(txId);
* //...
* tx.commit();
* ```
*/
Client.prototype.commit = function (transactionId) {
this._stompHandler.commit(transactionId);
};
/**
* Abort a transaction.
* It is preferable to abort a transaction by calling [abort]{@link ITransaction#abort} directly on
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
*
* ```javascript
* var tx = client.begin(txId);
* //...
* tx.abort();
* ```
*/
Client.prototype.abort = function (transactionId) {
this._stompHandler.abort(transactionId);
};
/**
* ACK a message. It is preferable to acknowledge a message by calling [ack]{@link IMessage#ack} directly
* on the {@link IMessage} handled by a subscription callback:
*
* ```javascript
* var callback = function (message) {
* // process the message
* // acknowledge it
* message.ack();
* };
* client.subscribe(destination, callback, {'ack': 'client'});
* ```
*/
Client.prototype.ack = function (messageId, subscriptionId, headers) {
if (headers === void 0) {
headers = {};
}
this._stompHandler.ack(messageId, subscriptionId, headers);
};
/**
* NACK a message. It is preferable to acknowledge a message by calling [nack]{@link IMessage#nack} directly
* on the {@link IMessage} handled by a subscription callback:
*
* ```javascript
* var callback = function (message) {
* // process the message
* // an error occurs, nack it
* message.nack();
* };
* client.subscribe(destination, callback, {'ack': 'client'});
* ```
*/
Client.prototype.nack = function (messageId, subscriptionId, headers) {
if (headers === void 0) {
headers = {};
}
this._stompHandler.nack(messageId, subscriptionId, headers);
};
return Client;
}();
exports.Client = Client;
/***/
}),
/***/"./src/compatibility/compat-client.ts": (
/*!********************************************!*\
!*** ./src/compatibility/compat-client.ts ***!
\********************************************/
/*! no static exports found */
/***/
function srcCompatibilityCompatClientTs(module, exports, __nested_webpack_require_31912__) {
"use strict";
var __extends = this && this.__extends || function () {
var _extendStatics = function extendStatics(d, b) {
_extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
return _extendStatics(d, b);
};
return function (d, b) {
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", {
value: true
});
var client_1 = __nested_webpack_require_31912__( /*! ../client */"./src/client.ts");
var heartbeat_info_1 = __nested_webpack_require_31912__( /*! ./heartbeat-info */"./src/compatibility/heartbeat-info.ts");
/**
* Available for backward compatibility, please shift to using {@link Client}.
*
* **Deprecated**
*
* Part of `@stomp/stompjs`.
*
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
*/
var CompatClient = /** @class */function (_super) {
__extends(CompatClient, _super);
/**
* Available for backward compatibility, please shift to using {@link Client}
* and [Client#webSocketFactory]{@link Client#webSocketFactory}.
*
* **Deprecated**
*
* @internal
*/
function CompatClient(webSocketFactory) {
var _this = _super.call(this) || this;
/**
* It is no op now. No longer needed. Large packets work out of the box.
*/
_this.maxWebSocketFrameSize = 16 * 1024;
_this._heartbeatInfo = new heartbeat_info_1.HeartbeatInfo(_this);
_this.reconnect_delay = 0;
_this.webSocketFactory = webSocketFactory;
// Default from previous version
_this.debug = function () {
var message = [];
for (var _i = 0; _i < arguments.length; _i++) {
message[_i] = arguments[_i];
}
console.log.apply(console, message);
};
return _this;
}
CompatClient.prototype._parseConnect = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var closeEventCallback;
var connectCallback;
var errorCallback;
var headers = {};
if (args.length < 2) {
throw new Error('Connect requires at least 2 arguments');
}
if (typeof args[1] === 'function') {
headers = args[0], connectCallback = args[1], errorCallback = args[2], closeEventCallback = args[3];
} else {
switch (args.length) {
case 6:
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4], headers.host = args[5];
break;
default:
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], closeEventCallback = args[4];
}
}
return [headers, connectCallback, errorCallback, closeEventCallback];
};
/**
* Available for backward compatibility, please shift to using [Client#activate]{@link Client#activate}.
*
* **Deprecated**
*
* The `connect` method accepts different number of arguments and types. See the Overloads list. Use the
* version with headers to pass your broker specific options.
*
* overloads:
* - connect(headers, connectCallback)
* - connect(headers, connectCallback, errorCallback)
* - connect(login, passcode, connectCallback)
* - connect(login, passcode, connectCallback, errorCallback)
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback)
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback, host)
*
* params:
* - headers, see [Client#connectHeaders]{@link Client#connectHeaders}
* - connectCallback, see [Client#onConnect]{@link Client#onConnect}
* - errorCallback, see [Client#onStompError]{@link Client#onStompError}
* - closeEventCallback, see [Client#onWebSocketClose]{@link Client#onWebSocketClose}
* - login [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
* - passcode [String], [Client#connectHeaders](../classes/Client.html#connectHeaders)
* - host [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
*
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
*/
CompatClient.prototype.connect = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var out = this._parseConnect.apply(this, args);
if (out[0]) {
this.connectHeaders = out[0];
}
if (out[1]) {
this.onConnect = out[1];
}
if (out[2]) {
this.onStompError = out[2];
}
if (out[3]) {
this.onWebSocketClose = out[3];
}
_super.prototype.activate.call(this);
};
/**
* Available for backward compatibility, please shift to using [Client#deactivate]{@link Client#deactivate}.
*
* **Deprecated**
*
* See:
* [Client#onDisconnect]{@link Client#onDisconnect}, and
* [Client#disconnectHeaders]{@link Client#disconnectHeaders}
*
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
*/
CompatClient.prototype.disconnect = function (disconnectCallback, headers) {
if (headers === void 0) {
headers = {};
}
if (disconnectCallback) {
this.onDisconnect = disconnectCallback;
}
this.disconnectHeaders = headers;
_super.prototype.deactivate.call(this);
};
/**
* Available for backward compatibility, use [Client#publish]{@link Client#publish}.
*
* Send a message to a named destination. Refer to your STOMP broker documentation for types
* and naming of destinations. The headers will, typically, be available to the subscriber.
* However, there may be special purpose headers corresponding to your STOMP broker.
*
* **Deprecated**, use [Client#publish]{@link Client#publish}
*
* Note: Body must be String. You will need to covert the payload to string in case it is not string (e.g. JSON)
*
* ```javascript
* client.send("/queue/test", {priority: 9}, "Hello, STOMP");
*
* // If you want to send a message with a body, you must also pass the headers argument.
* client.send("/queue/test", {}, "Hello, STOMP");
* ```
*
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
*/
CompatClient.prototype.send = function (destination, headers, body) {
if (headers === void 0) {
headers = {};
}
if (body === void 0) {
body = '';
}
headers = Object.assign({}, headers);
var skipContentLengthHeader = headers['content-length'] === false;
if (skipContentLengthHeader) {
delete headers['content-length'];
}
this.publish({
destination: destination,
headers: headers,
body: body,
skipContentLengthHeader: skipContentLengthHeader
});
};
Object.defineProperty(CompatClient.prototype, "reconnect_delay", {
/**
* Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
*
* **Deprecated**
*/
set: function set(value) {
this.reconnectDelay = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CompatClient.prototype, "ws", {
/**
* Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
*
* **Deprecated**
*/
get: function get() {
return this._webSocket;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CompatClient.prototype, "version", {
/**
* Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
*
* **Deprecated**
*/
get: function get() {
return this.connectedVersion;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CompatClient.prototype, "onreceive", {
/**
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
*
* **Deprecated**
*/
get: function get() {
return this.onUnhandledMessage;
},
/**
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
*
* **Deprecated**
*/
set: function set(value) {
this.onUnhandledMessage = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CompatClient.prototype, "onreceipt", {
/**
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
*
* **Deprecated**
*/
get: function get() {
return this.onUnhandledReceipt;
},
/**
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
*
* **Deprecated**
*/
set: function set(value) {
this.onUnhandledReceipt = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CompatClient.prototype, "heartbeat", {
/**
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
*
* **Deprecated**
*/
get: function get() {
return this._heartbeatInfo;
},
/**
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
*
* **Deprecated**
*/
set: function set(value) {
this.heartbeatIncoming = value.incoming;
this.heartbeatOutgoing = value.outgoing;
},
enumerable: true,
configurable: true
});
return CompatClient;
}(client_1.Client);
exports.CompatClient = CompatClient;
/***/
}),
/***/"./src/compatibility/heartbeat-info.ts": (
/*!*********************************************!*\
!*** ./src/compatibility/heartbeat-info.ts ***!
\*********************************************/
/*! no static exports found */
/***/
function srcCompatibilityHeartbeatInfoTs(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Part of `@stomp/stompjs`.
*
* @internal
*/
var HeartbeatInfo = /** @class */function () {
function HeartbeatInfo(client) {
this.client = client;
}
Object.defineProperty(HeartbeatInfo.prototype, "outgoing", {
get: function get() {
return this.client.heartbeatOutgoing;
},
set: function set(value) {
this.client.heartbeatOutgoing = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HeartbeatInfo.prototype, "incoming", {
get: function get() {
return this.client.heartbeatIncoming;
},
set: function set(value) {
this.client.heartbeatIncoming = value;
},
enumerable: true,
configurable: true
});
return HeartbeatInfo;
}();
exports.HeartbeatInfo = HeartbeatInfo;
/***/
}),
/***/"./src/compatibility/stomp.ts": (
/*!************************************!*\
!*** ./src/compatibility/stomp.ts ***!
\************************************/
/*! no static exports found */
/***/
function srcCompatibilityStompTs(module, exports, __nested_webpack_require_45656__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var versions_1 = __nested_webpack_require_45656__( /*! ../versions */"./src/versions.ts");
var compat_client_1 = __nested_webpack_require_45656__( /*! ./compat-client */"./src/compatibility/compat-client.ts");
/**
* STOMP Class, acts like a factory to create {@link Client}.
*
* Part of `@stomp/stompjs`.
*
* **Deprecated**
*
* It will be removed in next major version. Please switch to {@link Client}.
*/
var Stomp = /** @class */function () {
function Stomp() {}
/**
* This method creates a WebSocket client that is connected to
* the STOMP server located at the url.
*
* ```javascript
* var url = "ws://localhost:61614/stomp";
* var client = Stomp.client(url);
* ```
*
* **Deprecated**
*
* It will be removed in next major version. Please switch to {@link Client}
* using [Client#brokerURL]{@link Client#brokerURL}.
*/
Stomp.client = function (url, protocols) {
// This is a hack to allow another implementation than the standard
// HTML5 WebSocket class.
//
// It is possible to use another class by calling
//
// Stomp.WebSocketClass = MozWebSocket
//
// *prior* to call `Stomp.client()`.
//
// This hack is deprecated and `Stomp.over()` method should be used
// instead.
// See remarks on the function Stomp.over
if (protocols == null) {
protocols = versions_1.Versions["default"].protocolVersions();
}
var wsFn = function wsFn() {
var klass = Stomp.WebSocketClass || WebSocket;
return new klass(url, protocols);
};
return new compat_client_1.CompatClient(wsFn);
};
/**
* This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
* specify the WebSocket to use (either a standard HTML5 WebSocket or
* a similar object).
*
* In order to support reconnection, the function Client._connect should be callable more than once.
* While reconnecting
* a new instance of underlying transport (TCP Socket, WebSocket or SockJS) will be needed. So, this function
* alternatively allows passing a function that should return a new instance of the underlying socket.
*
* ```javascript
* var client = Stomp.over(function(){
* return new WebSocket('ws://localhost:15674/ws')
* });
* ```
*
* **Deprecated**
*
* It will be removed in next major version. Please switch to {@link Client}
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
*/
Stomp.over = function (ws) {
var wsFn;
if (typeof ws === 'function') {
wsFn = ws;
} else {
console.warn('Stomp.over did not receive a factory, auto reconnect will not work. ' + 'Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over');
wsFn = function wsFn() {
re