@nextgis/geocoder 1.12.0 → 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.
- package/index.js +3 -3
- package/lib/geocoder.cjs.js +1 -1
- package/lib/geocoder.esm-browser.js +84 -31
- package/lib/geocoder.esm-browser.js.map +1 -1
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-browser.prod.js.map +1 -1
- package/lib/geocoder.esm-bundler.js +1 -1
- package/lib/geocoder.global.js +84 -31
- package/lib/geocoder.global.js.map +1 -1
- package/lib/geocoder.global.prod.js +1 -1
- package/lib/geocoder.global.prod.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 1.13.5; 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';
|
package/lib/geocoder.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 1.13.5; author: NextGIS */
|
|
2
2
|
var Geocoder = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1373,31 +1373,31 @@ var Geocoder = (function (exports) {
|
|
|
1373
1373
|
/**
|
|
1374
1374
|
* Thrown when...
|
|
1375
1375
|
*/
|
|
1376
|
-
var
|
|
1377
|
-
__extends(
|
|
1378
|
-
function
|
|
1376
|
+
var NetworkError = /** @class */ (function (_super) {
|
|
1377
|
+
__extends(NetworkError, _super);
|
|
1378
|
+
function NetworkError(url) {
|
|
1379
1379
|
var _this = _super.call(this) || this;
|
|
1380
|
-
_this.name = '
|
|
1381
|
-
Object.
|
|
1382
|
-
|
|
1380
|
+
_this.name = 'NetworkError';
|
|
1381
|
+
Object.setPrototypeOf(_this, NetworkError.prototype);
|
|
1382
|
+
_this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
|
|
1383
1383
|
return _this;
|
|
1384
1384
|
}
|
|
1385
|
-
return
|
|
1385
|
+
return NetworkError;
|
|
1386
1386
|
}(Error));
|
|
1387
1387
|
|
|
1388
1388
|
/**
|
|
1389
1389
|
* Thrown when...
|
|
1390
1390
|
*/
|
|
1391
|
-
var
|
|
1392
|
-
__extends(
|
|
1393
|
-
function
|
|
1391
|
+
var NgwError = /** @class */ (function (_super) {
|
|
1392
|
+
__extends(NgwError, _super);
|
|
1393
|
+
function NgwError(er) {
|
|
1394
1394
|
var _this = _super.call(this) || this;
|
|
1395
|
-
_this.name = '
|
|
1396
|
-
Object.
|
|
1397
|
-
|
|
1395
|
+
_this.name = 'NgwError';
|
|
1396
|
+
Object.assign(_this, er);
|
|
1397
|
+
Object.setPrototypeOf(_this, NgwError.prototype);
|
|
1398
1398
|
return _this;
|
|
1399
1399
|
}
|
|
1400
|
-
return
|
|
1400
|
+
return NgwError;
|
|
1401
1401
|
}(Error));
|
|
1402
1402
|
|
|
1403
1403
|
function isObject(val) {
|
|
@@ -1652,7 +1652,12 @@ var Geocoder = (function (exports) {
|
|
|
1652
1652
|
forCache.id = resource;
|
|
1653
1653
|
}
|
|
1654
1654
|
else if (isObject(resource)) {
|
|
1655
|
-
|
|
1655
|
+
if (resource.id !== undefined) {
|
|
1656
|
+
forCache.id = resource.id;
|
|
1657
|
+
}
|
|
1658
|
+
else if (resource.keyname) {
|
|
1659
|
+
forCache.keyname = resource.keyname;
|
|
1660
|
+
}
|
|
1656
1661
|
}
|
|
1657
1662
|
var makeRequest = function () {
|
|
1658
1663
|
if (typeof resource === 'string') {
|
|
@@ -1754,20 +1759,35 @@ var Geocoder = (function (exports) {
|
|
|
1754
1759
|
};
|
|
1755
1760
|
ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
|
|
1756
1761
|
var _this = this;
|
|
1757
|
-
return this.
|
|
1758
|
-
return _this.
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1762
|
+
return this.getIdOrFail(resource).then(function (parent) {
|
|
1763
|
+
return _this._getChildrenOf(parent, requestOptions);
|
|
1764
|
+
});
|
|
1765
|
+
};
|
|
1766
|
+
ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
|
|
1767
|
+
var _this = this;
|
|
1768
|
+
if (_items === void 0) { _items = []; }
|
|
1769
|
+
return this.connector
|
|
1770
|
+
.get('resource.collection', __assign({ cache: true }, requestOptions), {
|
|
1771
|
+
parent: parent,
|
|
1772
|
+
})
|
|
1773
|
+
.then(function (items) {
|
|
1774
|
+
var recursivePromises = [];
|
|
1775
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
1776
|
+
var item = items_1[_i];
|
|
1777
|
+
_this.cache.add('resource.item', CancelablePromise.resolve(item), {
|
|
1778
|
+
id: item.resource.id,
|
|
1779
|
+
});
|
|
1780
|
+
_items.push(item);
|
|
1781
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
|
|
1782
|
+
recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
|
|
1768
1783
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1784
|
+
}
|
|
1785
|
+
if (recursivePromises.length) {
|
|
1786
|
+
return CancelablePromise.all(recursivePromises).then(function () {
|
|
1787
|
+
return _items;
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
return _items;
|
|
1771
1791
|
});
|
|
1772
1792
|
};
|
|
1773
1793
|
ResourcesControl.prototype.update = function (resource, data) {
|
|
@@ -1941,6 +1961,7 @@ var Geocoder = (function (exports) {
|
|
|
1941
1961
|
this.id = ID++;
|
|
1942
1962
|
this.emitter = new events.exports.EventEmitter();
|
|
1943
1963
|
this.routeStr = '/api/component/pyramid/route';
|
|
1964
|
+
this.activeRequests = [];
|
|
1944
1965
|
var exist = findConnector(options);
|
|
1945
1966
|
if (exist) {
|
|
1946
1967
|
return exist;
|
|
@@ -2026,6 +2047,7 @@ var Geocoder = (function (exports) {
|
|
|
2026
2047
|
* Disconnecting a user. Aborting all current requests
|
|
2027
2048
|
*/
|
|
2028
2049
|
NgwConnector.prototype.logout = function () {
|
|
2050
|
+
this.abort();
|
|
2029
2051
|
removeConnector(this);
|
|
2030
2052
|
this.options.auth = undefined;
|
|
2031
2053
|
this.user = undefined;
|
|
@@ -2078,6 +2100,17 @@ var Geocoder = (function (exports) {
|
|
|
2078
2100
|
}
|
|
2079
2101
|
}
|
|
2080
2102
|
};
|
|
2103
|
+
/** Stop all api requests */
|
|
2104
|
+
NgwConnector.prototype.abort = function () {
|
|
2105
|
+
for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
|
|
2106
|
+
var req = _a[_i];
|
|
2107
|
+
req.cancel();
|
|
2108
|
+
}
|
|
2109
|
+
this.activeRequests = [];
|
|
2110
|
+
};
|
|
2111
|
+
NgwConnector.prototype.getActiveApiRequests = function () {
|
|
2112
|
+
return __spreadArray([], this.activeRequests, true);
|
|
2113
|
+
};
|
|
2081
2114
|
/**
|
|
2082
2115
|
* Send request to NGW api router.
|
|
2083
2116
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -2292,14 +2325,20 @@ var Geocoder = (function (exports) {
|
|
|
2292
2325
|
NgwConnector.prototype._loadData = function (url, options) {
|
|
2293
2326
|
var _this = this;
|
|
2294
2327
|
options.responseType = options.responseType || 'json';
|
|
2295
|
-
|
|
2328
|
+
var request = new CancelablePromise(function (resolve, reject, onCancel) {
|
|
2296
2329
|
if (_this.user) {
|
|
2297
2330
|
options = options || {};
|
|
2298
2331
|
// options.withCredentials = true;
|
|
2299
2332
|
options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
|
|
2300
2333
|
}
|
|
2301
2334
|
loadData(url, resolve, options, reject, onCancel);
|
|
2302
|
-
})
|
|
2335
|
+
})
|
|
2336
|
+
.then(function (resp) {
|
|
2337
|
+
_this._cleanActiveRequests(request);
|
|
2338
|
+
return resp;
|
|
2339
|
+
})
|
|
2340
|
+
.catch(function (httpError) {
|
|
2341
|
+
_this._cleanActiveRequests(request);
|
|
2303
2342
|
if (httpError instanceof CancelablePromise.CancelError) ;
|
|
2304
2343
|
else {
|
|
2305
2344
|
// @ts-ignore
|
|
@@ -2312,6 +2351,20 @@ var Geocoder = (function (exports) {
|
|
|
2312
2351
|
}
|
|
2313
2352
|
}
|
|
2314
2353
|
});
|
|
2354
|
+
if (options.signal &&
|
|
2355
|
+
typeof options.signal.addEventListener === 'function') {
|
|
2356
|
+
options.signal.addEventListener('abort', function () {
|
|
2357
|
+
request.cancel();
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
this.activeRequests.push(request);
|
|
2361
|
+
return request;
|
|
2362
|
+
};
|
|
2363
|
+
NgwConnector.prototype._cleanActiveRequests = function (request) {
|
|
2364
|
+
var activeRequestIndex = this.activeRequests.indexOf(request);
|
|
2365
|
+
if (activeRequestIndex !== -1) {
|
|
2366
|
+
this.activeRequests.splice(activeRequestIndex, 1);
|
|
2367
|
+
}
|
|
2315
2368
|
};
|
|
2316
2369
|
NgwConnector.prototype._handleHttpError = function (er) {
|
|
2317
2370
|
if (er) {
|