@nextgis/geocoder 1.12.0 → 1.12.1

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/geocoder; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.12.1; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.12.0; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.12.1; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -1508,6 +1508,11 @@ var loadData;
1508
1508
  xhr.abort();
1509
1509
  });
1510
1510
  }
1511
+ if (options.signal) {
1512
+ options.signal.addEventListener('abort', function () {
1513
+ xhr.abort();
1514
+ });
1515
+ }
1511
1516
  xhr.send(data);
1512
1517
  };
1513
1518
  }
@@ -1649,7 +1654,12 @@ var ResourcesControl = /** @class */ (function () {
1649
1654
  forCache.id = resource;
1650
1655
  }
1651
1656
  else if (isObject(resource)) {
1652
- forCache.id = resource.id;
1657
+ if (resource.id !== undefined) {
1658
+ forCache.id = resource.id;
1659
+ }
1660
+ else if (resource.keyname) {
1661
+ forCache.keyname = resource.keyname;
1662
+ }
1653
1663
  }
1654
1664
  var makeRequest = function () {
1655
1665
  if (typeof resource === 'string') {
@@ -1751,20 +1761,35 @@ var ResourcesControl = /** @class */ (function () {
1751
1761
  };
1752
1762
  ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
1753
1763
  var _this = this;
1754
- return this.getId(resource).then(function (parent) {
1755
- return _this.connector
1756
- .get('resource.collection', __assign({ cache: true }, requestOptions), {
1757
- parent: parent,
1758
- })
1759
- .then(function (items) {
1760
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1761
- var i = items_1[_i];
1762
- _this.cache.add('resource.item', CancelablePromise.resolve(i), {
1763
- id: i.resource.id,
1764
- });
1764
+ return this.getIdOrFail(resource).then(function (parent) {
1765
+ return _this._getChildrenOf(parent, requestOptions);
1766
+ });
1767
+ };
1768
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
1769
+ var _this = this;
1770
+ if (_items === void 0) { _items = []; }
1771
+ return this.connector
1772
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
1773
+ parent: parent,
1774
+ })
1775
+ .then(function (items) {
1776
+ var recursivePromises = [];
1777
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1778
+ var item = items_1[_i];
1779
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
1780
+ id: item.resource.id,
1781
+ });
1782
+ _items.push(item);
1783
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
1784
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
1765
1785
  }
1766
- return items;
1767
- });
1786
+ }
1787
+ if (recursivePromises.length) {
1788
+ return CancelablePromise.all(recursivePromises).then(function () {
1789
+ return _items;
1790
+ });
1791
+ }
1792
+ return _items;
1768
1793
  });
1769
1794
  };
1770
1795
  ResourcesControl.prototype.update = function (resource, data) {