@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
  import CancelablePromise from '@nextgis/cancelable-promise';
3
3
  import { objectAssign, fixUrlStr } from '@nextgis/utils';
4
4
  import NgwConnector from '@nextgis/ngw-connector';
@@ -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
  var Geocoder = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1511,6 +1511,11 @@ var Geocoder = (function (exports) {
1511
1511
  xhr.abort();
1512
1512
  });
1513
1513
  }
1514
+ if (options.signal) {
1515
+ options.signal.addEventListener('abort', function () {
1516
+ xhr.abort();
1517
+ });
1518
+ }
1514
1519
  xhr.send(data);
1515
1520
  };
1516
1521
  }
@@ -1652,7 +1657,12 @@ var Geocoder = (function (exports) {
1652
1657
  forCache.id = resource;
1653
1658
  }
1654
1659
  else if (isObject(resource)) {
1655
- forCache.id = resource.id;
1660
+ if (resource.id !== undefined) {
1661
+ forCache.id = resource.id;
1662
+ }
1663
+ else if (resource.keyname) {
1664
+ forCache.keyname = resource.keyname;
1665
+ }
1656
1666
  }
1657
1667
  var makeRequest = function () {
1658
1668
  if (typeof resource === 'string') {
@@ -1754,20 +1764,35 @@ var Geocoder = (function (exports) {
1754
1764
  };
1755
1765
  ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
1756
1766
  var _this = this;
1757
- return this.getId(resource).then(function (parent) {
1758
- return _this.connector
1759
- .get('resource.collection', __assign({ cache: true }, requestOptions), {
1760
- parent: parent,
1761
- })
1762
- .then(function (items) {
1763
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1764
- var i = items_1[_i];
1765
- _this.cache.add('resource.item', CancelablePromise.resolve(i), {
1766
- id: i.resource.id,
1767
- });
1767
+ return this.getIdOrFail(resource).then(function (parent) {
1768
+ return _this._getChildrenOf(parent, requestOptions);
1769
+ });
1770
+ };
1771
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
1772
+ var _this = this;
1773
+ if (_items === void 0) { _items = []; }
1774
+ return this.connector
1775
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
1776
+ parent: parent,
1777
+ })
1778
+ .then(function (items) {
1779
+ var recursivePromises = [];
1780
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1781
+ var item = items_1[_i];
1782
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
1783
+ id: item.resource.id,
1784
+ });
1785
+ _items.push(item);
1786
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
1787
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
1768
1788
  }
1769
- return items;
1770
- });
1789
+ }
1790
+ if (recursivePromises.length) {
1791
+ return CancelablePromise.all(recursivePromises).then(function () {
1792
+ return _items;
1793
+ });
1794
+ }
1795
+ return _items;
1771
1796
  });
1772
1797
  };
1773
1798
  ResourcesControl.prototype.update = function (resource, data) {