@nextgis/geocoder 1.9.4 → 1.11.8

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.9.4; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.11.8; 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,2 +1,2 @@
1
- import e from"@nextgis/cancelable-promise";import{objectAssign as t,fixUrlStr as s}from"@nextgis/utils";import r from"@nextgis/ngw-connector";class o{constructor(e){e&&t(this,e)}}let c=0;class n extends o{constructor(e){super(e),this.providers=[],e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}async*search(e){for(const t of this.providers)try{const s=t.search(e);for await(const e of s)yield{...e,provider:t,_id:c++}}catch(e){}}result(t){return t.provider?t.provider.result(t):e.resolve(void 0)}}class i extends o{}class a extends i{constructor(e){super(e),this.caseInsensitive=!0,this.searchUrl="https://maxim.nextgis.com",this.searchResources=[],this.requests=[],this.connector=e.connector||new r({baseUrl:this.searchUrl}),this.searchResources=e.searchResources}abort(){this.requests.forEach((e=>{e.cancel()})),this.requests=[]}async*search(e){for(const t of this.searchResources){const s=this.connector.get("feature_layer.store",{headers:{RANGE:`items=0-${t.limit||300}`}},{id:t.id,like:e});this.requests.push(s),s.catch((e=>{console.warn(e)}));const r=await s,o=[];r&&r.forEach((s=>{o.push({query:e,resourceId:t.id,...s})}));for(const e of this._items(o))e.result=()=>this.result(e),yield e}}result(e){const t=this.connector.get("feature_layer.feature.item_extent",null,{id:e.resourceId,fid:e.featureId}).then((t=>{const s=t.extent;return{text:e.text,extent:[s.minLon,s.minLat,s.maxLon,s.maxLat]}}));return this.requests.push(t),t}_items(e){const t=[];return e.forEach((e=>{this.searchResources.find((t=>t.id===e.resourceId))&&t.push({query:e.query,text:e.label,featureId:e.id,resourceId:e.resourceId})})),t}}class h extends i{constructor(e){super(e),this.searchUrl="https://nominatim.openstreetmap.org",this._requests=[]}abort(){this._requests.forEach((e=>e.cancel())),this._requests=[]}async*search(t){const r=s(`${this.searchUrl}/search?format=geojson&polygon_geojson=1&q=${t}`),o=new e(((e,s,o)=>{const c=new XMLHttpRequest;c.open("GET",r,!0),c.onload=()=>{try{const s=JSON.parse(c.responseText).features.map((e=>({geom:e,extent:e.bbox,text:e.properties&&e.properties.display_name,query:t})));e(s)}catch(e){s(e)}},c.onerror=e=>{s(e)},o((()=>{c.abort()})),c.send()})).catch((e=>{throw e}));this._requests.push(o);const c=await o;if(c)for(const e of c)e.result=()=>this.result(e),yield e}result(t){return e.resolve({text:t.text,extent:t.extent||[],geom:t.geom})}}function u(e){return new n(e)}export{i as BaseProvider,n as Geocoder,a as NgwProvider,h as NominatimProvider,u as create};
1
+ import e from"@nextgis/cancelable-promise";import{objectAssign as t,fixUrlStr as s}from"@nextgis/utils";import r from"@nextgis/ngw-connector";class o{constructor(e){e&&t(this,e)}}let c=0;class n extends o{constructor(e){super(e),this.providers=[],e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}async*search(e){for(const s of this.providers)try{const t=s.search(e);for await(const e of t)yield{...e,provider:s,_id:c++}}catch(t){}}result(t){return t.provider?t.provider.result(t):e.resolve(void 0)}}class i extends o{}class a extends i{constructor(e){super(e),this.caseInsensitive=!0,this.searchUrl="https://maxim.nextgis.com",this.searchResources=[],this.requests=[],this.connector=e.connector||new r({baseUrl:this.searchUrl}),this.searchResources=e.searchResources}abort(){this.requests.forEach((e=>{e.cancel()})),this.requests=[]}async*search(e){for(const t of this.searchResources){const s=this.connector.get("feature_layer.store",{headers:{RANGE:`items=0-${t.limit||300}`}},{id:t.id,like:e});this.requests.push(s),s.catch((e=>{console.warn(e)}));const r=await s,o=[];r&&r.forEach((s=>{o.push({query:e,resourceId:t.id,...s})}));for(const e of this._items(o))e.result=()=>this.result(e),yield e}}result(e){const t=this.connector.get("feature_layer.feature.item_extent",null,{id:e.resourceId,fid:e.featureId}).then((t=>{const s=t.extent;return{text:e.text,extent:[s.minLon,s.minLat,s.maxLon,s.maxLat]}}));return this.requests.push(t),t}_items(e){const t=[];return e.forEach((e=>{this.searchResources.find((t=>t.id===e.resourceId))&&t.push({query:e.query,text:e.label,featureId:e.id,resourceId:e.resourceId})})),t}}class h extends i{constructor(e){super(e),this.searchUrl="https://nominatim.openstreetmap.org",this._requests=[]}abort(){this._requests.forEach((e=>e.cancel())),this._requests=[]}async*search(t){const r=s(`${this.searchUrl}/search?format=geojson&polygon_geojson=1&q=${t}`),o=new e(((e,s,o)=>{const c=new XMLHttpRequest;c.open("GET",r,!0),c.onload=()=>{try{const s=JSON.parse(c.responseText).features.map((e=>({geom:e,extent:e.bbox,text:e.properties&&e.properties.display_name,query:t})));e(s)}catch(r){s(r)}},c.onerror=e=>{s(e)},o((()=>{c.abort()})),c.send()})).catch((e=>{throw e}));this._requests.push(o);const c=await o;if(c)for(const e of c)e.result=()=>this.result(e),yield e}result(t){return e.resolve({text:t.text,extent:t.extent||[],geom:t.geom})}}function u(e){return new n(e)}export{i as BaseProvider,n as Geocoder,a as NgwProvider,h as NominatimProvider,u as create};
2
2
  //# sourceMappingURL=geocoder.esm-bundler.prod.js.map
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.9.4; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.11.8; author: NextGIS */
2
2
  var Geocoder = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -94,10 +94,14 @@ var Geocoder = (function (exports) {
94
94
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
95
95
  }
96
96
 
97
- function __spreadArray(to, from) {
98
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
99
- to[j] = from[i];
100
- return to;
97
+ function __spreadArray(to, from, pack) {
98
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
99
+ if (ar || !(i in from)) {
100
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
101
+ ar[i] = from[i];
102
+ }
103
+ }
104
+ return to.concat(ar || Array.prototype.slice.call(from));
101
105
  }
102
106
 
103
107
  function __await(v) {
@@ -1390,12 +1394,16 @@ var Geocoder = (function (exports) {
1390
1394
  var _this = _super.call(this) || this;
1391
1395
  _this.name = 'NetworkError';
1392
1396
  Object.setPrototypeOf(_this, NetworkError.prototype);
1393
- _this.message = "Unable to request " + url + ".\n Possibly invalid NGW URL entered or CORS not configured to get request from " + location.origin; // /control-panel/cors
1397
+ _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
1394
1398
  return _this;
1395
1399
  }
1396
1400
  return NetworkError;
1397
1401
  }(Error));
1398
1402
 
1403
+ function isObject(val) {
1404
+ return Object.prototype.toString.call(val) === '[object Object]';
1405
+ }
1406
+
1399
1407
  var loadData;
1400
1408
  // @ts-ignore
1401
1409
  {
@@ -1431,7 +1439,7 @@ var Geocoder = (function (exports) {
1431
1439
  }
1432
1440
  };
1433
1441
  xhr.onload = function () {
1434
- if ([401, 403, 404, 500].indexOf(xhr.status) !== -1) {
1442
+ if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
1435
1443
  error(new NgwError(getResponseText()));
1436
1444
  }
1437
1445
  processingResponse();
@@ -1486,7 +1494,7 @@ var Geocoder = (function (exports) {
1486
1494
  data = new FormData();
1487
1495
  data.append('file', options.file);
1488
1496
  if (options.data) {
1489
- for (var d in data) {
1497
+ for (var d in options.data) {
1490
1498
  data.append(d, data[d]);
1491
1499
  }
1492
1500
  }
@@ -1578,10 +1586,6 @@ var Geocoder = (function (exports) {
1578
1586
  }
1579
1587
  }
1580
1588
 
1581
- function isObject(val) {
1582
- return Object.prototype.toString.call(val) === '[object Object]';
1583
- }
1584
-
1585
1589
  var exclude = ['description'];
1586
1590
  /**
1587
1591
  * @remarks
@@ -1832,7 +1836,7 @@ var Geocoder = (function (exports) {
1832
1836
  ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
1833
1837
  var _this = this;
1834
1838
  var promise = function () {
1835
- return _this.connector.get('resource.item', requestOptions, { id: id }).catch();
1839
+ return _this.connector.get('resource.item', requestOptions, { id: id });
1836
1840
  };
1837
1841
  return this.cache
1838
1842
  .add('resource.item', promise, {
@@ -1879,7 +1883,7 @@ var Geocoder = (function (exports) {
1879
1883
  .then(function (apiItems) {
1880
1884
  var apiItem = apiItems && apiItems[opt.name];
1881
1885
  if (apiItem) {
1882
- apiItem = __spreadArray([], apiItem);
1886
+ apiItem = __spreadArray([], apiItem, true);
1883
1887
  var url = apiItem.shift();
1884
1888
  if (apiItem.length) {
1885
1889
  var replaceParams = {};
@@ -1901,12 +1905,12 @@ var Geocoder = (function (exports) {
1901
1905
  if (Array.isArray(paramList)) {
1902
1906
  delete params.paramList;
1903
1907
  paramList.forEach(function (x) {
1904
- paramArray_1.push(x[0] + "=" + x[1]);
1908
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1905
1909
  });
1906
1910
  }
1907
1911
  for (var p in params) {
1908
1912
  if (apiItem.indexOf(p) === -1) {
1909
- paramArray_1.push(p + "=" + params[p]);
1913
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1910
1914
  }
1911
1915
  }
1912
1916
  if (paramArray_1.length) {
@@ -2040,7 +2044,7 @@ var Geocoder = (function (exports) {
2040
2044
  headers: this.getAuthorizationHeaders(credentials),
2041
2045
  // withCredentials: true
2042
2046
  };
2043
- // Do not use request('auth.current_user') to avoid circular-references
2047
+ // Do not use apiRequest('auth.current_user') to avoid circular-references
2044
2048
  return this.makeQuery('/api/component/auth/current_user', {}, options)
2045
2049
  .then(function (data) {
2046
2050
  _this.user = data;
@@ -2067,7 +2071,7 @@ var Geocoder = (function (exports) {
2067
2071
  credentials = credentials || this.options.auth;
2068
2072
  if (credentials) {
2069
2073
  var login = credentials.login, password = credentials.password;
2070
- var str = unescape(encodeURIComponent(login + ":" + password));
2074
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
2071
2075
  // @ts-ignore
2072
2076
  {
2073
2077
  return window.btoa(str);
@@ -2377,7 +2381,7 @@ var Geocoder = (function (exports) {
2377
2381
  case 0:
2378
2382
  limit = resource.limit || 300;
2379
2383
  request = this_1.connector.get('feature_layer.store', {
2380
- headers: { RANGE: "items=0-" + limit },
2384
+ headers: { RANGE: "items=0-".concat(limit) },
2381
2385
  }, {
2382
2386
  id: resource.id,
2383
2387
  like: like,
@@ -2498,7 +2502,7 @@ var Geocoder = (function (exports) {
2498
2502
  case 0:
2499
2503
  url = fixUrlStr(
2500
2504
  // `${this.baseUrl}/search?format=geojson&polygon_geojson=1${window.locale === 'ru' ? '&accept-language=ru-RU,en-US' : ''}&q=${val}`
2501
- this.searchUrl + "/search?format=geojson&polygon_geojson=1&q=" + val);
2505
+ "".concat(this.searchUrl, "/search?format=geojson&polygon_geojson=1&q=").concat(val));
2502
2506
  request = new CancelablePromise(function (resolve, reject, onCancel) {
2503
2507
  var xhr = new XMLHttpRequest();
2504
2508
  xhr.open('GET', url, true);