@nextgis/ngw-leaflet 1.13.2 → 1.13.5

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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.5; author: NextGIS */
2
2
  import 'leaflet/dist/leaflet.css';
3
3
  import { Icon } from 'leaflet';
4
4
  import { NgwMap } from '@nextgis/ngw-map';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.5; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -18707,6 +18707,7 @@ var NgwLeaflet = (function () {
18707
18707
  this.id = ID$1++;
18708
18708
  this.emitter = new events.exports.EventEmitter();
18709
18709
  this.routeStr = '/api/component/pyramid/route';
18710
+ this.activeRequests = [];
18710
18711
  var exist = findConnector(options);
18711
18712
  if (exist) {
18712
18713
  return exist;
@@ -18792,6 +18793,7 @@ var NgwLeaflet = (function () {
18792
18793
  * Disconnecting a user. Aborting all current requests
18793
18794
  */
18794
18795
  NgwConnector.prototype.logout = function () {
18796
+ this.abort();
18795
18797
  removeConnector(this);
18796
18798
  this.options.auth = undefined;
18797
18799
  this.user = undefined;
@@ -18844,6 +18846,17 @@ var NgwLeaflet = (function () {
18844
18846
  }
18845
18847
  }
18846
18848
  };
18849
+ /** Stop all api requests */
18850
+ NgwConnector.prototype.abort = function () {
18851
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
18852
+ var req = _a[_i];
18853
+ req.cancel();
18854
+ }
18855
+ this.activeRequests = [];
18856
+ };
18857
+ NgwConnector.prototype.getActiveApiRequests = function () {
18858
+ return __spreadArray([], this.activeRequests, true);
18859
+ };
18847
18860
  /**
18848
18861
  * Send request to NGW api router.
18849
18862
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -19065,7 +19078,13 @@ var NgwLeaflet = (function () {
19065
19078
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
19066
19079
  }
19067
19080
  loadData(url, resolve, options, reject, onCancel);
19068
- }).catch(function (httpError) {
19081
+ })
19082
+ .then(function (resp) {
19083
+ _this._cleanActiveRequests(request);
19084
+ return resp;
19085
+ })
19086
+ .catch(function (httpError) {
19087
+ _this._cleanActiveRequests(request);
19069
19088
  if (httpError instanceof CancelablePromise.CancelError) ;
19070
19089
  else {
19071
19090
  // @ts-ignore
@@ -19084,8 +19103,15 @@ var NgwLeaflet = (function () {
19084
19103
  request.cancel();
19085
19104
  });
19086
19105
  }
19106
+ this.activeRequests.push(request);
19087
19107
  return request;
19088
19108
  };
19109
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
19110
+ var activeRequestIndex = this.activeRequests.indexOf(request);
19111
+ if (activeRequestIndex !== -1) {
19112
+ this.activeRequests.splice(activeRequestIndex, 1);
19113
+ }
19114
+ };
19089
19115
  NgwConnector.prototype._handleHttpError = function (er) {
19090
19116
  if (er) {
19091
19117
  if (er instanceof NgwError) {