@nextgis/geocoder 3.0.0-alpha.9 → 3.0.0
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/lib/geocoder.cjs.js +14 -13
- package/lib/geocoder.cjs.js.map +1 -1
- package/lib/geocoder.cjs.prod.js +1 -1
- package/lib/geocoder.cjs.prod.js.map +1 -1
- package/lib/geocoder.esm-browser.js +608 -529
- 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 +14 -13
- package/lib/geocoder.esm-bundler.js.map +1 -1
- package/lib/geocoder.esm-bundler.prod.js +1 -1
- package/lib/geocoder.esm-bundler.prod.js.map +1 -1
- package/lib/geocoder.global.js +608 -529
- 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/lib/index.d.ts +21 -19
- package/package.json +7 -7
package/lib/geocoder.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 3.0.0
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 3.0.0; author: NextGIS */
|
|
2
2
|
var Geocoder = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -9,14 +9,6 @@ var Geocoder = (function (exports) {
|
|
|
9
9
|
return typeof val === "string" ? !!val : defined(val);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function getBoundsCoordinates(b) {
|
|
13
|
-
const westNorth = [b[0], b[1]];
|
|
14
|
-
const eastNorth = [b[2], b[1]];
|
|
15
|
-
const eastSouth = [b[2], b[3]];
|
|
16
|
-
const westSouth = [b[0], b[3]];
|
|
17
|
-
return [westNorth, eastNorth, eastSouth, westSouth, westNorth];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
function degrees2meters(lng, lat) {
|
|
21
13
|
lat = lat > 85.06 ? 85.06 : lat < -85.06 ? -85.06 : lat;
|
|
22
14
|
const x = lng * 2003750834e-2 / 180;
|
|
@@ -25,10 +17,23 @@ var Geocoder = (function (exports) {
|
|
|
25
17
|
return [x, y];
|
|
26
18
|
}
|
|
27
19
|
|
|
20
|
+
function getBoundsCoordinates(b) {
|
|
21
|
+
const westNorth = [b[0], b[1]];
|
|
22
|
+
const eastNorth = [b[2], b[1]];
|
|
23
|
+
const eastSouth = [b[2], b[3]];
|
|
24
|
+
const westSouth = [b[0], b[3]];
|
|
25
|
+
return [westNorth, eastNorth, eastSouth, westSouth, westNorth];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
28
|
function isLngLatBoundsArray(array) {
|
|
29
29
|
return Array.isArray(array) && array.length === 4 && array.every((x) => typeof x === "number");
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function round(val, toFixed) {
|
|
33
|
+
const n = 1;
|
|
34
|
+
return Math.round((val + Number.EPSILON) * n) / n;
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
function objectAssign(target, ...sources) {
|
|
33
38
|
for (const source of sources) {
|
|
34
39
|
for (const prop of Object.getOwnPropertyNames(source)) {
|
|
@@ -83,11 +88,6 @@ var Geocoder = (function (exports) {
|
|
|
83
88
|
return newObj;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
function round(val, toFixed) {
|
|
87
|
-
const n = 1;
|
|
88
|
-
return Math.round((val + Number.EPSILON) * n) / n;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
91
|
function isObject$1(val) {
|
|
92
92
|
return Object.prototype.toString.call(val) === "[object Object]";
|
|
93
93
|
}
|
|
@@ -107,27 +107,27 @@ var Geocoder = (function (exports) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
var __defProp$
|
|
111
|
-
var __defProps$
|
|
112
|
-
var __getOwnPropDescs$
|
|
110
|
+
var __defProp$i = Object.defineProperty;
|
|
111
|
+
var __defProps$5 = Object.defineProperties;
|
|
112
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
113
113
|
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
114
114
|
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
115
115
|
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
116
116
|
var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
117
|
-
var __defNormalProp$
|
|
117
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
118
118
|
var __spreadValues$8 = (a, b) => {
|
|
119
119
|
for (var prop in b || (b = {}))
|
|
120
120
|
if (__hasOwnProp$8.call(b, prop))
|
|
121
|
-
__defNormalProp$
|
|
121
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
122
122
|
if (__getOwnPropSymbols$8)
|
|
123
123
|
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
124
124
|
if (__propIsEnum$8.call(b, prop))
|
|
125
|
-
__defNormalProp$
|
|
125
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
126
126
|
}
|
|
127
127
|
return a;
|
|
128
128
|
};
|
|
129
|
-
var __spreadProps$
|
|
130
|
-
var __publicField$
|
|
129
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
130
|
+
var __publicField$d = (obj, key, value) => __defNormalProp$i(obj, key + "" , value);
|
|
131
131
|
var __async$7 = (__this, __arguments, generator) => {
|
|
132
132
|
return new Promise((resolve, reject) => {
|
|
133
133
|
var fulfilled = (value) => {
|
|
@@ -168,7 +168,7 @@ var Geocoder = (function (exports) {
|
|
|
168
168
|
class Geocoder extends BaseGeocoder {
|
|
169
169
|
constructor(options) {
|
|
170
170
|
super(options);
|
|
171
|
-
__publicField$
|
|
171
|
+
__publicField$d(this, "providers", []);
|
|
172
172
|
if (options && options.providers) {
|
|
173
173
|
this.providers = options.providers;
|
|
174
174
|
}
|
|
@@ -192,7 +192,7 @@ var Geocoder = (function (exports) {
|
|
|
192
192
|
for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
|
|
193
193
|
const r = temp.value;
|
|
194
194
|
allProvidersFailed = false;
|
|
195
|
-
yield __spreadProps$
|
|
195
|
+
yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
|
|
196
196
|
}
|
|
197
197
|
} catch (temp) {
|
|
198
198
|
error = [temp];
|
|
@@ -206,7 +206,7 @@ var Geocoder = (function (exports) {
|
|
|
206
206
|
}
|
|
207
207
|
} catch (err) {
|
|
208
208
|
const er = err;
|
|
209
|
-
if (er.name !== "
|
|
209
|
+
if (er.name !== "AbortError") {
|
|
210
210
|
errors.push(er);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -235,7 +235,7 @@ var Geocoder = (function (exports) {
|
|
|
235
235
|
try {
|
|
236
236
|
for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
|
|
237
237
|
const r = temp.value;
|
|
238
|
-
yield __spreadProps$
|
|
238
|
+
yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
|
|
239
239
|
}
|
|
240
240
|
} catch (temp) {
|
|
241
241
|
error = [temp];
|
|
@@ -247,7 +247,7 @@ var Geocoder = (function (exports) {
|
|
|
247
247
|
throw error[0];
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
} catch (
|
|
250
|
+
} catch (e) {
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
});
|
|
@@ -288,9 +288,9 @@ var Geocoder = (function (exports) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
var __defProp$
|
|
292
|
-
var __defNormalProp$
|
|
293
|
-
var __publicField$
|
|
291
|
+
var __defProp$h = Object.defineProperty;
|
|
292
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
293
|
+
var __publicField$c = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
294
294
|
class BaseProvider extends BaseGeocoder {
|
|
295
295
|
constructor() {
|
|
296
296
|
super(...arguments);
|
|
@@ -298,14 +298,253 @@ var Geocoder = (function (exports) {
|
|
|
298
298
|
* URL endpoint for the search service.
|
|
299
299
|
* This is where queries will be sent to obtain search results.
|
|
300
300
|
*/
|
|
301
|
-
__publicField$
|
|
301
|
+
__publicField$c(this, "searchUrl");
|
|
302
302
|
/**
|
|
303
303
|
* Label to represent the provider.
|
|
304
304
|
* Useful for user interfaces to display the source of search results.
|
|
305
305
|
*/
|
|
306
|
-
__publicField$
|
|
306
|
+
__publicField$c(this, "label");
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const templateRe = /\{ *([\w_-]+) *\}/g;
|
|
311
|
+
function template(str, data) {
|
|
312
|
+
return str.replace(templateRe, (s, key) => {
|
|
313
|
+
let value = data[key];
|
|
314
|
+
if (value === void 0) {
|
|
315
|
+
throw new Error("No value provided for letiable " + s);
|
|
316
|
+
} else if (typeof value === "function") {
|
|
317
|
+
value = value(data);
|
|
318
|
+
}
|
|
319
|
+
return value;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
var __defProp$g = Object.defineProperty;
|
|
324
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
325
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
326
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
327
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
328
|
+
var __spreadValues$7 = (a, b) => {
|
|
329
|
+
for (var prop in b || (b = {}))
|
|
330
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
331
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
332
|
+
if (__getOwnPropSymbols$7)
|
|
333
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
334
|
+
if (__propIsEnum$7.call(b, prop))
|
|
335
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
336
|
+
}
|
|
337
|
+
return a;
|
|
338
|
+
};
|
|
339
|
+
var __async$6 = (__this, __arguments, generator) => {
|
|
340
|
+
return new Promise((resolve, reject) => {
|
|
341
|
+
var fulfilled = (value) => {
|
|
342
|
+
try {
|
|
343
|
+
step(generator.next(value));
|
|
344
|
+
} catch (e) {
|
|
345
|
+
reject(e);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var rejected = (value) => {
|
|
349
|
+
try {
|
|
350
|
+
step(generator.throw(value));
|
|
351
|
+
} catch (e) {
|
|
352
|
+
reject(e);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
356
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
function apiRequest(opt) {
|
|
360
|
+
return __async$6(this, null, function* () {
|
|
361
|
+
const { params, name, connector, requestOptions } = opt;
|
|
362
|
+
const apiItems = yield connector.connect();
|
|
363
|
+
let apiItem = apiItems && apiItems[name];
|
|
364
|
+
if (apiItem) {
|
|
365
|
+
apiItem = [...apiItem];
|
|
366
|
+
let url = apiItem.shift();
|
|
367
|
+
if (apiItem.length) {
|
|
368
|
+
const replaceParams = {};
|
|
369
|
+
for (let fry = 0; fry < apiItem.length; fry++) {
|
|
370
|
+
const arg = apiItem[fry];
|
|
371
|
+
replaceParams[fry] = `{${arg}}`;
|
|
372
|
+
if (params[arg] === void 0) {
|
|
373
|
+
throw new Error(`\`${arg}\` URL API argument is not specified`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (url) {
|
|
377
|
+
url = template(url, replaceParams);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (params) {
|
|
381
|
+
const paramArray = [];
|
|
382
|
+
const paramList = params.paramList;
|
|
383
|
+
if (Array.isArray(paramList)) {
|
|
384
|
+
paramList.forEach(([key, value]) => {
|
|
385
|
+
paramArray.push(`${key}=${value}`);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
for (const p in params) {
|
|
389
|
+
if (apiItem.indexOf(p) === -1) {
|
|
390
|
+
paramArray.push(`${p}=${params[p]}`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (paramArray.length) {
|
|
394
|
+
url = `${url}?${paramArray.join("&")}`;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (url) {
|
|
398
|
+
return connector.makeQuery(url, params, __spreadValues$7({
|
|
399
|
+
cacheName: name
|
|
400
|
+
}, requestOptions));
|
|
401
|
+
} else {
|
|
402
|
+
throw new Error("Request URL is not set");
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
return void 0;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
var __defProp$f = Object.defineProperty;
|
|
411
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
412
|
+
var __publicField$b = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
413
|
+
const _Cache = class _Cache {
|
|
414
|
+
constructor(options = {}) {
|
|
415
|
+
__publicField$b(this, "cache", []);
|
|
416
|
+
var _a;
|
|
417
|
+
const namespace = (_a = options.namespace) != null ? _a : "default";
|
|
418
|
+
if (_Cache.instance[namespace]) {
|
|
419
|
+
return _Cache.instance[namespace];
|
|
420
|
+
}
|
|
421
|
+
_Cache.instance[namespace] = this;
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
clean() {
|
|
425
|
+
this.cache.length = 0;
|
|
426
|
+
}
|
|
427
|
+
all() {
|
|
428
|
+
return this.cache;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Caching only a non-empty value.
|
|
432
|
+
*
|
|
433
|
+
* Useful for get or create strategy
|
|
434
|
+
* @example
|
|
435
|
+
* ```javascript
|
|
436
|
+
* const cache = new Cache();
|
|
437
|
+
* const getItemFunc = () => fetch(url).then((data) => {
|
|
438
|
+
* return data.json(); // undefined
|
|
439
|
+
* });
|
|
440
|
+
* const item = await cache.addFull('foo', getItemFunc);
|
|
441
|
+
* if (!item) {
|
|
442
|
+
* await createItem(); // 'New item'
|
|
443
|
+
* }
|
|
444
|
+
*
|
|
445
|
+
* // somewhere else in the code
|
|
446
|
+
* const item = await cache.addFull('foo', getItemFunc).then((resp) => {
|
|
447
|
+
* console.log(resp); // 'New item'
|
|
448
|
+
* });
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
addFull(key, valueToSet, propsOrOptions, expirationTime) {
|
|
452
|
+
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
453
|
+
propsOrOptions.onlyFull = true;
|
|
454
|
+
}
|
|
455
|
+
return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
|
|
456
|
+
}
|
|
457
|
+
add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
|
|
458
|
+
let opt;
|
|
459
|
+
let props;
|
|
460
|
+
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
461
|
+
opt = propsOrOptions;
|
|
462
|
+
onlyFull = opt.onlyFull;
|
|
463
|
+
expirationTime = opt.expirationTime;
|
|
464
|
+
props = opt.props;
|
|
465
|
+
} else {
|
|
466
|
+
props = propsOrOptions;
|
|
467
|
+
}
|
|
468
|
+
const exist = this._find(key, props);
|
|
469
|
+
if (!exist) {
|
|
470
|
+
let value;
|
|
471
|
+
if (valueToSet instanceof Function) {
|
|
472
|
+
value = valueToSet();
|
|
473
|
+
} else {
|
|
474
|
+
value = valueToSet;
|
|
475
|
+
}
|
|
476
|
+
const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
|
|
477
|
+
expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
|
|
478
|
+
const cacheItem = {
|
|
479
|
+
key,
|
|
480
|
+
value,
|
|
481
|
+
props: nonEmptyProps,
|
|
482
|
+
expirationTime
|
|
483
|
+
};
|
|
484
|
+
if (onlyFull && !full(value)) {
|
|
485
|
+
return value;
|
|
486
|
+
}
|
|
487
|
+
this.cache.push(cacheItem);
|
|
488
|
+
if (value instanceof Promise) {
|
|
489
|
+
value.catch(() => {
|
|
490
|
+
this.delete(key, props);
|
|
491
|
+
});
|
|
492
|
+
if (onlyFull) {
|
|
493
|
+
value.then((x) => {
|
|
494
|
+
if (!full(x)) {
|
|
495
|
+
this.delete(key, props);
|
|
496
|
+
}
|
|
497
|
+
return x;
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return value;
|
|
501
|
+
}
|
|
502
|
+
return value;
|
|
503
|
+
} else {
|
|
504
|
+
return exist.value;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
match(key, props) {
|
|
508
|
+
const cacheRecord = this._find(key, props);
|
|
509
|
+
if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
|
|
510
|
+
this.delete(cacheRecord);
|
|
511
|
+
return void 0;
|
|
512
|
+
}
|
|
513
|
+
return cacheRecord == null ? void 0 : cacheRecord.value;
|
|
514
|
+
}
|
|
515
|
+
matchAll(key, props) {
|
|
516
|
+
const now = Date.now();
|
|
517
|
+
this.cache.forEach((item) => {
|
|
518
|
+
if (item.expirationTime && now > item.expirationTime) {
|
|
519
|
+
this.delete(item);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
if (key) {
|
|
523
|
+
return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
|
|
524
|
+
}
|
|
525
|
+
return this.cache.map((x) => x.value);
|
|
526
|
+
}
|
|
527
|
+
delete(keyOrItem, props) {
|
|
528
|
+
const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
|
|
529
|
+
for (const item of itemsToDelete) {
|
|
530
|
+
const index = this.cache.indexOf(item);
|
|
531
|
+
if (index !== -1) {
|
|
532
|
+
this.cache.splice(index, 1);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
_find(key, props) {
|
|
537
|
+
return this.cache.find((x) => this._filter(x, key, props));
|
|
538
|
+
}
|
|
539
|
+
_filter(item, key, props) {
|
|
540
|
+
if (item.key !== key) return false;
|
|
541
|
+
if (!props) return true;
|
|
542
|
+
const itemProps = item.props;
|
|
543
|
+
return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
|
|
307
544
|
}
|
|
308
|
-
}
|
|
545
|
+
};
|
|
546
|
+
__publicField$b(_Cache, "instance", {});
|
|
547
|
+
let Cache = _Cache;
|
|
309
548
|
|
|
310
549
|
var domain;
|
|
311
550
|
|
|
@@ -779,148 +1018,9 @@ var Geocoder = (function (exports) {
|
|
|
779
1018
|
return ret;
|
|
780
1019
|
}
|
|
781
1020
|
|
|
782
|
-
var __defProp$f = Object.defineProperty;
|
|
783
|
-
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
784
|
-
var __publicField$a = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
785
|
-
const _Cache = class _Cache {
|
|
786
|
-
constructor(options = {}) {
|
|
787
|
-
__publicField$a(this, "cache", []);
|
|
788
|
-
var _a;
|
|
789
|
-
const namespace = (_a = options.namespace) != null ? _a : "default";
|
|
790
|
-
if (_Cache.instance[namespace]) {
|
|
791
|
-
return _Cache.instance[namespace];
|
|
792
|
-
}
|
|
793
|
-
_Cache.instance[namespace] = this;
|
|
794
|
-
return this;
|
|
795
|
-
}
|
|
796
|
-
clean() {
|
|
797
|
-
this.cache.length = 0;
|
|
798
|
-
}
|
|
799
|
-
all() {
|
|
800
|
-
return this.cache;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Caching only a non-empty value.
|
|
804
|
-
*
|
|
805
|
-
* Useful for get or create strategy
|
|
806
|
-
* @example
|
|
807
|
-
* ```javascript
|
|
808
|
-
* const cache = new Cache();
|
|
809
|
-
* const getItemFunc = () => fetch(url).then((data) => {
|
|
810
|
-
* return data.json(); // undefined
|
|
811
|
-
* });
|
|
812
|
-
* const item = await cache.addFull('foo', getItemFunc);
|
|
813
|
-
* if (!item) {
|
|
814
|
-
* await createItem(); // 'New item'
|
|
815
|
-
* }
|
|
816
|
-
*
|
|
817
|
-
* // somewhere else in the code
|
|
818
|
-
* const item = await cache.addFull('foo', getItemFunc).then((resp) => {
|
|
819
|
-
* console.log(resp); // 'New item'
|
|
820
|
-
* });
|
|
821
|
-
* ```
|
|
822
|
-
*/
|
|
823
|
-
addFull(key, valueToSet, propsOrOptions, expirationTime) {
|
|
824
|
-
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
825
|
-
propsOrOptions.onlyFull = true;
|
|
826
|
-
}
|
|
827
|
-
return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
|
|
828
|
-
}
|
|
829
|
-
add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
|
|
830
|
-
let opt;
|
|
831
|
-
let props;
|
|
832
|
-
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
833
|
-
opt = propsOrOptions;
|
|
834
|
-
onlyFull = opt.onlyFull;
|
|
835
|
-
expirationTime = opt.expirationTime;
|
|
836
|
-
props = opt.props;
|
|
837
|
-
} else {
|
|
838
|
-
props = propsOrOptions;
|
|
839
|
-
}
|
|
840
|
-
const exist = this._find(key, props);
|
|
841
|
-
if (!exist) {
|
|
842
|
-
let value;
|
|
843
|
-
if (valueToSet instanceof Function) {
|
|
844
|
-
value = valueToSet();
|
|
845
|
-
} else {
|
|
846
|
-
value = valueToSet;
|
|
847
|
-
}
|
|
848
|
-
const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
|
|
849
|
-
expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
|
|
850
|
-
const cacheItem = {
|
|
851
|
-
key,
|
|
852
|
-
value,
|
|
853
|
-
props: nonEmptyProps,
|
|
854
|
-
expirationTime
|
|
855
|
-
};
|
|
856
|
-
if (onlyFull && !full(value)) {
|
|
857
|
-
return value;
|
|
858
|
-
}
|
|
859
|
-
this.cache.push(cacheItem);
|
|
860
|
-
if (value instanceof Promise) {
|
|
861
|
-
value.catch((er) => {
|
|
862
|
-
this.delete(key, props);
|
|
863
|
-
});
|
|
864
|
-
if (onlyFull) {
|
|
865
|
-
value.then((x) => {
|
|
866
|
-
if (!full(x)) {
|
|
867
|
-
this.delete(key, props);
|
|
868
|
-
}
|
|
869
|
-
return x;
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
return value;
|
|
873
|
-
}
|
|
874
|
-
return value;
|
|
875
|
-
} else {
|
|
876
|
-
return exist.value;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
match(key, props) {
|
|
880
|
-
const cacheRecord = this._find(key, props);
|
|
881
|
-
if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
|
|
882
|
-
this.delete(cacheRecord);
|
|
883
|
-
return void 0;
|
|
884
|
-
}
|
|
885
|
-
return cacheRecord == null ? void 0 : cacheRecord.value;
|
|
886
|
-
}
|
|
887
|
-
matchAll(key, props) {
|
|
888
|
-
const now = Date.now();
|
|
889
|
-
this.cache.forEach((item) => {
|
|
890
|
-
if (item.expirationTime && now > item.expirationTime) {
|
|
891
|
-
this.delete(item);
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
if (key) {
|
|
895
|
-
return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
|
|
896
|
-
}
|
|
897
|
-
return this.cache.map((x) => x.value);
|
|
898
|
-
}
|
|
899
|
-
delete(keyOrItem, props) {
|
|
900
|
-
const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
|
|
901
|
-
for (const item of itemsToDelete) {
|
|
902
|
-
const index = this.cache.indexOf(item);
|
|
903
|
-
if (index !== -1) {
|
|
904
|
-
this.cache.splice(index, 1);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
_find(key, props) {
|
|
909
|
-
return this.cache.find((x) => this._filter(x, key, props));
|
|
910
|
-
}
|
|
911
|
-
_filter(item, key, props) {
|
|
912
|
-
if (item.key !== key) return false;
|
|
913
|
-
if (!props) return true;
|
|
914
|
-
const itemProps = item.props;
|
|
915
|
-
return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
__publicField$a(_Cache, "instance", {});
|
|
919
|
-
let Cache = _Cache;
|
|
920
|
-
|
|
921
1021
|
var pkg = {
|
|
922
1022
|
name: "@nextgis/ngw-connector",
|
|
923
|
-
version: "3.0.0
|
|
1023
|
+
version: "3.0.0",
|
|
924
1024
|
_priority: 12,
|
|
925
1025
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
926
1026
|
main: "index.js",
|
|
@@ -929,15 +1029,15 @@ var Geocoder = (function (exports) {
|
|
|
929
1029
|
jsdelivr: "lib/ngw-connector.global.prod.js",
|
|
930
1030
|
types: "lib/index.d.ts",
|
|
931
1031
|
dependencies: {
|
|
932
|
-
"@nextgis/cache": "
|
|
933
|
-
"@nextgis/cancelable-promise": "
|
|
934
|
-
"@nextgis/utils": "
|
|
1032
|
+
"@nextgis/cache": "3.0.0",
|
|
1033
|
+
"@nextgis/cancelable-promise": "3.0.0",
|
|
1034
|
+
"@nextgis/utils": "3.0.0",
|
|
935
1035
|
"@types/events": "^3.0.0",
|
|
936
1036
|
events: "*",
|
|
937
1037
|
"form-data": "^4.0.0"
|
|
938
1038
|
},
|
|
939
1039
|
devDependencies: {
|
|
940
|
-
"@nextgis/build-tools": "
|
|
1040
|
+
"@nextgis/build-tools": "3.0.0"
|
|
941
1041
|
},
|
|
942
1042
|
scripts: {
|
|
943
1043
|
clean: "rimraf ./lib",
|
|
@@ -977,30 +1077,6 @@ var Geocoder = (function (exports) {
|
|
|
977
1077
|
gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
|
|
978
1078
|
};
|
|
979
1079
|
|
|
980
|
-
const CONNECTORS = [];
|
|
981
|
-
function addConnector(connector) {
|
|
982
|
-
CONNECTORS.push(connector);
|
|
983
|
-
}
|
|
984
|
-
function findConnector(options) {
|
|
985
|
-
return CONNECTORS.find((x) => {
|
|
986
|
-
if (x.options.baseUrl === options.baseUrl) {
|
|
987
|
-
if (options.auth) {
|
|
988
|
-
if (x.options.auth) {
|
|
989
|
-
return objectDeepEqual(x.options.auth, options.auth);
|
|
990
|
-
}
|
|
991
|
-
} else {
|
|
992
|
-
return true;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
function removeConnector(connector) {
|
|
998
|
-
const index = CONNECTORS.indexOf(connector);
|
|
999
|
-
if (index !== -1) {
|
|
1000
|
-
CONNECTORS.splice(index, 1);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
1080
|
class AbortError extends Error {
|
|
1005
1081
|
constructor(message = "AbortError") {
|
|
1006
1082
|
super(message);
|
|
@@ -1010,18 +1086,18 @@ var Geocoder = (function (exports) {
|
|
|
1010
1086
|
|
|
1011
1087
|
var __defProp$e = Object.defineProperty;
|
|
1012
1088
|
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1013
|
-
var __publicField$
|
|
1089
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1014
1090
|
class NgwError extends Error {
|
|
1015
1091
|
constructor(er) {
|
|
1016
1092
|
super();
|
|
1017
|
-
__publicField$
|
|
1018
|
-
__publicField$
|
|
1019
|
-
__publicField$
|
|
1020
|
-
__publicField$
|
|
1021
|
-
__publicField$
|
|
1022
|
-
__publicField$
|
|
1023
|
-
__publicField$
|
|
1024
|
-
__publicField$
|
|
1093
|
+
__publicField$a(this, "name", "NgwError");
|
|
1094
|
+
__publicField$a(this, "title");
|
|
1095
|
+
__publicField$a(this, "message");
|
|
1096
|
+
__publicField$a(this, "detail");
|
|
1097
|
+
__publicField$a(this, "exception");
|
|
1098
|
+
__publicField$a(this, "status_code");
|
|
1099
|
+
__publicField$a(this, "data");
|
|
1100
|
+
__publicField$a(this, "guru_meditation");
|
|
1025
1101
|
Object.assign(this, er);
|
|
1026
1102
|
Object.setPrototypeOf(this, NgwError.prototype);
|
|
1027
1103
|
}
|
|
@@ -1029,35 +1105,105 @@ var Geocoder = (function (exports) {
|
|
|
1029
1105
|
|
|
1030
1106
|
var __defProp$d = Object.defineProperty;
|
|
1031
1107
|
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1032
|
-
var __publicField$
|
|
1108
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1033
1109
|
class InsufficientPermissionsError extends NgwError {
|
|
1034
1110
|
constructor(obj) {
|
|
1035
1111
|
super(obj);
|
|
1036
|
-
__publicField$
|
|
1037
|
-
__publicField$
|
|
1112
|
+
__publicField$9(this, "name", "InsufficientPermissionsError");
|
|
1113
|
+
__publicField$9(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
|
|
1038
1114
|
Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
|
|
1039
1115
|
}
|
|
1040
1116
|
}
|
|
1041
1117
|
|
|
1042
1118
|
var __defProp$c = Object.defineProperty;
|
|
1043
1119
|
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1044
|
-
var __publicField$
|
|
1045
|
-
class
|
|
1120
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1121
|
+
let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
|
|
1046
1122
|
constructor(obj) {
|
|
1047
1123
|
super(obj);
|
|
1048
|
-
__publicField$
|
|
1049
|
-
__publicField$
|
|
1050
|
-
|
|
1124
|
+
__publicField$8(this, "message", "There is no response from the server or problem connecting to server.");
|
|
1125
|
+
__publicField$8(this, "title", "Network error");
|
|
1126
|
+
__publicField$8(this, "detail", "Check network connectivity and try again later.");
|
|
1127
|
+
Object.setPrototypeOf(this, NetworksResponseError.prototype);
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
function extractError(error) {
|
|
1132
|
+
if (isObject$1(error)) {
|
|
1133
|
+
if (error.name && error.message && error.title) {
|
|
1134
|
+
return {
|
|
1135
|
+
title: error.title,
|
|
1136
|
+
message: error.message,
|
|
1137
|
+
detail: error.detail || null,
|
|
1138
|
+
data: error.data && error.data.data ? error.data.data : null
|
|
1139
|
+
};
|
|
1140
|
+
} else if (error.exception) {
|
|
1141
|
+
if (error.status === void 0 || error.status === 0 || error.data === void 0) {
|
|
1142
|
+
return new NetworksResponseError$1({
|
|
1143
|
+
title: error.title,
|
|
1144
|
+
status_code: error.status_code,
|
|
1145
|
+
exception: error.exception
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
return {
|
|
1150
|
+
title: typeof error.title === "string" ? error.title : "Unexpected error",
|
|
1151
|
+
message: typeof error.message === "string" ? error.message : "Something went wrong."
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
function isError(error) {
|
|
1157
|
+
if (isObject$1(error)) {
|
|
1158
|
+
return error.status_code && error.exception && error.title;
|
|
1051
1159
|
}
|
|
1160
|
+
return false;
|
|
1052
1161
|
}
|
|
1053
1162
|
|
|
1054
1163
|
var __defProp$b = Object.defineProperty;
|
|
1055
1164
|
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1056
|
-
var __publicField$
|
|
1165
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$b(obj, key + "" , value);
|
|
1166
|
+
class NetworkError extends Error {
|
|
1167
|
+
constructor(url) {
|
|
1168
|
+
super();
|
|
1169
|
+
__publicField$7(this, "name", "NetworkError");
|
|
1170
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1171
|
+
this.message = `Unable to request ${url}.
|
|
1172
|
+
Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
var __defProp$a = Object.defineProperty;
|
|
1177
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1178
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1179
|
+
class ResourceNotFoundError extends NgwError {
|
|
1180
|
+
constructor(obj) {
|
|
1181
|
+
super(obj);
|
|
1182
|
+
__publicField$6(this, "name", "ResourceNotFoundError");
|
|
1183
|
+
__publicField$6(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
|
|
1184
|
+
Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
var errors = /*#__PURE__*/Object.freeze({
|
|
1189
|
+
__proto__: null,
|
|
1190
|
+
AbortError: AbortError,
|
|
1191
|
+
InsufficientPermissionsError: InsufficientPermissionsError,
|
|
1192
|
+
NetworkError: NetworkError,
|
|
1193
|
+
NetworksResponseError: NetworksResponseError$1,
|
|
1194
|
+
NgwError: NgwError,
|
|
1195
|
+
ResourceNotFoundError: ResourceNotFoundError,
|
|
1196
|
+
extractError: extractError,
|
|
1197
|
+
isError: isError
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
var __defProp$9 = Object.defineProperty;
|
|
1201
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1202
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1057
1203
|
class BaseAPIError extends Error {
|
|
1058
1204
|
constructor(message) {
|
|
1059
1205
|
super(message || "Something went wrong.");
|
|
1060
|
-
__publicField$
|
|
1206
|
+
__publicField$5(this, "title");
|
|
1061
1207
|
this.name = "BaseAPIError";
|
|
1062
1208
|
this.title = "Unknown API error";
|
|
1063
1209
|
if (Error.captureStackTrace) {
|
|
@@ -1069,7 +1215,7 @@ var Geocoder = (function (exports) {
|
|
|
1069
1215
|
// prettier-ignore
|
|
1070
1216
|
constructor(message) {
|
|
1071
1217
|
super(message || "There is no response from the server or problem connecting to server.");
|
|
1072
|
-
__publicField$
|
|
1218
|
+
__publicField$5(this, "detail");
|
|
1073
1219
|
this.title = "Network error";
|
|
1074
1220
|
this.detail = "Check network connectivity and try again later.";
|
|
1075
1221
|
}
|
|
@@ -1083,8 +1229,8 @@ var Geocoder = (function (exports) {
|
|
|
1083
1229
|
class ServerResponseError extends BaseAPIError {
|
|
1084
1230
|
constructor(data) {
|
|
1085
1231
|
super(data.message);
|
|
1086
|
-
__publicField$
|
|
1087
|
-
__publicField$
|
|
1232
|
+
__publicField$5(this, "detail");
|
|
1233
|
+
__publicField$5(this, "data");
|
|
1088
1234
|
this.title = data.title || this.title;
|
|
1089
1235
|
this.detail = data.detail || null;
|
|
1090
1236
|
this.data = data;
|
|
@@ -1094,8 +1240,8 @@ var Geocoder = (function (exports) {
|
|
|
1094
1240
|
// prettier-ignore
|
|
1095
1241
|
constructor(message, data = {}) {
|
|
1096
1242
|
super(message || "Unexpected error while processing long-running request.");
|
|
1097
|
-
__publicField$
|
|
1098
|
-
__publicField$
|
|
1243
|
+
__publicField$5(this, "title");
|
|
1244
|
+
__publicField$5(this, "data");
|
|
1099
1245
|
this.name = "LunkwillError";
|
|
1100
1246
|
this.title = "Long-running request error";
|
|
1101
1247
|
this.data = data;
|
|
@@ -1115,35 +1261,35 @@ var Geocoder = (function (exports) {
|
|
|
1115
1261
|
}
|
|
1116
1262
|
}
|
|
1117
1263
|
|
|
1118
|
-
var __defProp$
|
|
1119
|
-
var __getOwnPropSymbols$
|
|
1120
|
-
var __hasOwnProp$
|
|
1121
|
-
var __propIsEnum$
|
|
1122
|
-
var __defNormalProp$
|
|
1123
|
-
var __spreadValues$
|
|
1264
|
+
var __defProp$8 = Object.defineProperty;
|
|
1265
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1266
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1267
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1268
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1269
|
+
var __spreadValues$6 = (a, b) => {
|
|
1124
1270
|
for (var prop in b || (b = {}))
|
|
1125
|
-
if (__hasOwnProp$
|
|
1126
|
-
__defNormalProp$
|
|
1127
|
-
if (__getOwnPropSymbols$
|
|
1128
|
-
for (var prop of __getOwnPropSymbols$
|
|
1129
|
-
if (__propIsEnum$
|
|
1130
|
-
__defNormalProp$
|
|
1271
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1272
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
1273
|
+
if (__getOwnPropSymbols$6)
|
|
1274
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1275
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1276
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
1131
1277
|
}
|
|
1132
1278
|
return a;
|
|
1133
1279
|
};
|
|
1134
1280
|
var __objRest$2 = (source, exclude) => {
|
|
1135
1281
|
var target = {};
|
|
1136
1282
|
for (var prop in source)
|
|
1137
|
-
if (__hasOwnProp$
|
|
1283
|
+
if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1138
1284
|
target[prop] = source[prop];
|
|
1139
|
-
if (source != null && __getOwnPropSymbols$
|
|
1140
|
-
for (var prop of __getOwnPropSymbols$
|
|
1141
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1285
|
+
if (source != null && __getOwnPropSymbols$6)
|
|
1286
|
+
for (var prop of __getOwnPropSymbols$6(source)) {
|
|
1287
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
|
|
1142
1288
|
target[prop] = source[prop];
|
|
1143
1289
|
}
|
|
1144
1290
|
return target;
|
|
1145
1291
|
};
|
|
1146
|
-
var __async$
|
|
1292
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
1147
1293
|
return new Promise((resolve, reject) => {
|
|
1148
1294
|
var fulfilled = (value) => {
|
|
1149
1295
|
try {
|
|
@@ -1168,7 +1314,7 @@ var Geocoder = (function (exports) {
|
|
|
1168
1314
|
return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
|
|
1169
1315
|
}
|
|
1170
1316
|
function responseJson(response) {
|
|
1171
|
-
return __async$
|
|
1317
|
+
return __async$5(this, null, function* () {
|
|
1172
1318
|
try {
|
|
1173
1319
|
return response.json();
|
|
1174
1320
|
} catch (e) {
|
|
@@ -1177,7 +1323,7 @@ var Geocoder = (function (exports) {
|
|
|
1177
1323
|
});
|
|
1178
1324
|
}
|
|
1179
1325
|
function lunkwillResponseUrl(lwResp) {
|
|
1180
|
-
return __async$
|
|
1326
|
+
return __async$5(this, null, function* () {
|
|
1181
1327
|
const lwData = yield responseJson(lwResp);
|
|
1182
1328
|
let delay = lwData.delay_ms;
|
|
1183
1329
|
const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
|
|
@@ -1221,7 +1367,7 @@ var Geocoder = (function (exports) {
|
|
|
1221
1367
|
});
|
|
1222
1368
|
}
|
|
1223
1369
|
function lunkwillFetch(lwRespUrl) {
|
|
1224
|
-
return __async$
|
|
1370
|
+
return __async$5(this, null, function* () {
|
|
1225
1371
|
try {
|
|
1226
1372
|
return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
|
|
1227
1373
|
} catch (e) {
|
|
@@ -1269,14 +1415,14 @@ var Geocoder = (function (exports) {
|
|
|
1269
1415
|
return path + urlParams;
|
|
1270
1416
|
}
|
|
1271
1417
|
function request(path, options, cacheEngine) {
|
|
1272
|
-
return __async$
|
|
1273
|
-
var _b;
|
|
1418
|
+
return __async$5(this, null, function* () {
|
|
1419
|
+
var _b, _c;
|
|
1274
1420
|
const defaults = {
|
|
1275
1421
|
method: "GET",
|
|
1276
1422
|
credentials: "same-origin",
|
|
1277
1423
|
headers: {}
|
|
1278
1424
|
};
|
|
1279
|
-
const _a = __spreadValues$
|
|
1425
|
+
const _a = __spreadValues$6(__spreadValues$6({}, defaults), options), {
|
|
1280
1426
|
withCredentials,
|
|
1281
1427
|
responseType,
|
|
1282
1428
|
cacheProps,
|
|
@@ -1295,6 +1441,7 @@ var Geocoder = (function (exports) {
|
|
|
1295
1441
|
"query",
|
|
1296
1442
|
"json"
|
|
1297
1443
|
]);
|
|
1444
|
+
opt.method = (_b = opt.method) == null ? void 0 : _b.toUpperCase();
|
|
1298
1445
|
if (withCredentials) {
|
|
1299
1446
|
opt.credentials = "include";
|
|
1300
1447
|
}
|
|
@@ -1312,12 +1459,12 @@ var Geocoder = (function (exports) {
|
|
|
1312
1459
|
opt.headers = headers;
|
|
1313
1460
|
}
|
|
1314
1461
|
const url = generateUrl(path, query);
|
|
1315
|
-
const makeRequest = () => __async$
|
|
1462
|
+
const makeRequest = () => __async$5(null, null, function* () {
|
|
1316
1463
|
let response;
|
|
1317
1464
|
try {
|
|
1318
1465
|
response = yield fetch(url, opt);
|
|
1319
1466
|
} catch (e) {
|
|
1320
|
-
if (
|
|
1467
|
+
if (opt.signal && opt.signal.aborted) {
|
|
1321
1468
|
throw e;
|
|
1322
1469
|
}
|
|
1323
1470
|
throw new NetworksResponseError();
|
|
@@ -1352,49 +1499,61 @@ var Geocoder = (function (exports) {
|
|
|
1352
1499
|
}
|
|
1353
1500
|
return body;
|
|
1354
1501
|
});
|
|
1355
|
-
if (cacheEngine
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1502
|
+
if (cacheEngine) {
|
|
1503
|
+
if (((_c = opt.method) == null ? void 0 : _c.toUpperCase()) === "GET") {
|
|
1504
|
+
if (cache !== false) {
|
|
1505
|
+
const props = cacheProps ? cacheProps : __spreadValues$6({}, objectRemoveEmpty({
|
|
1506
|
+
withCredentials,
|
|
1507
|
+
responseType
|
|
1508
|
+
}));
|
|
1509
|
+
return cacheEngine.add(cacheName || url, makeRequest, {
|
|
1510
|
+
props,
|
|
1511
|
+
expirationTime: cache ? void 0 : 500
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
} else {
|
|
1515
|
+
const ignoredForClean = ["api/feature_layer/identify"];
|
|
1516
|
+
if (ignoredForClean.every((part) => !path.includes(part))) {
|
|
1517
|
+
cacheEngine.clean();
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1361
1520
|
}
|
|
1362
1521
|
return makeRequest();
|
|
1363
1522
|
});
|
|
1364
1523
|
}
|
|
1365
1524
|
|
|
1366
|
-
var __defProp$
|
|
1367
|
-
var __defProps$
|
|
1368
|
-
var __getOwnPropDescs$
|
|
1369
|
-
var __getOwnPropSymbols$
|
|
1370
|
-
var __hasOwnProp$
|
|
1371
|
-
var __propIsEnum$
|
|
1372
|
-
var __defNormalProp$
|
|
1373
|
-
var __spreadValues$
|
|
1374
|
-
for (var prop in b || (b = {}))
|
|
1375
|
-
if (__hasOwnProp$
|
|
1376
|
-
__defNormalProp$
|
|
1377
|
-
if (__getOwnPropSymbols$
|
|
1378
|
-
for (var prop of __getOwnPropSymbols$
|
|
1379
|
-
if (__propIsEnum$
|
|
1380
|
-
__defNormalProp$
|
|
1525
|
+
var __defProp$7 = Object.defineProperty;
|
|
1526
|
+
var __defProps$4 = Object.defineProperties;
|
|
1527
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1528
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1529
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1530
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1531
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1532
|
+
var __spreadValues$5 = (a, b) => {
|
|
1533
|
+
for (var prop in b || (b = {}))
|
|
1534
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1535
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
1536
|
+
if (__getOwnPropSymbols$5)
|
|
1537
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1538
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1539
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
1381
1540
|
}
|
|
1382
1541
|
return a;
|
|
1383
1542
|
};
|
|
1384
|
-
var __spreadProps$
|
|
1543
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
1385
1544
|
var __objRest$1 = (source, exclude) => {
|
|
1386
1545
|
var target = {};
|
|
1387
1546
|
for (var prop in source)
|
|
1388
|
-
if (__hasOwnProp$
|
|
1547
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1389
1548
|
target[prop] = source[prop];
|
|
1390
|
-
if (source != null && __getOwnPropSymbols$
|
|
1391
|
-
for (var prop of __getOwnPropSymbols$
|
|
1392
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1549
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
1550
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
1551
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
1393
1552
|
target[prop] = source[prop];
|
|
1394
1553
|
}
|
|
1395
1554
|
return target;
|
|
1396
1555
|
};
|
|
1397
|
-
var __async$
|
|
1556
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1398
1557
|
return new Promise((resolve, reject) => {
|
|
1399
1558
|
var fulfilled = (value) => {
|
|
1400
1559
|
try {
|
|
@@ -1445,7 +1604,7 @@ var Geocoder = (function (exports) {
|
|
|
1445
1604
|
}
|
|
1446
1605
|
function route(name, connector, ...rest) {
|
|
1447
1606
|
const result = {
|
|
1448
|
-
url: (opt) => __async$
|
|
1607
|
+
url: (opt) => __async$4(null, null, function* () {
|
|
1449
1608
|
var _a;
|
|
1450
1609
|
const routeData = yield connector.connect();
|
|
1451
1610
|
const template = routeURL(
|
|
@@ -1459,45 +1618,37 @@ var Geocoder = (function (exports) {
|
|
|
1459
1618
|
};
|
|
1460
1619
|
const methods = ["get", "post", "put", "delete", "patch"];
|
|
1461
1620
|
for (const method of methods) {
|
|
1462
|
-
const methodResp = (requestOptions) =>
|
|
1621
|
+
const methodResp = (requestOptions) => {
|
|
1463
1622
|
var _b;
|
|
1464
1623
|
const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$1(_a, ["headers"]);
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1624
|
+
if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
|
|
1625
|
+
throw new AbortError();
|
|
1626
|
+
}
|
|
1627
|
+
return connector.connect().then((routeData) => {
|
|
1628
|
+
var _a2;
|
|
1629
|
+
const template = routeURL(
|
|
1630
|
+
name,
|
|
1631
|
+
(_a2 = connector.options.baseUrl) != null ? _a2 : "",
|
|
1632
|
+
routeData,
|
|
1633
|
+
...rest
|
|
1634
|
+
);
|
|
1635
|
+
const headers = objectRemoveEmpty(__spreadValues$5(__spreadValues$5({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
|
|
1636
|
+
return request(
|
|
1637
|
+
template,
|
|
1638
|
+
__spreadProps$4(__spreadValues$5({
|
|
1639
|
+
headers
|
|
1640
|
+
}, restOpt), {
|
|
1641
|
+
method
|
|
1642
|
+
}),
|
|
1643
|
+
connector.cache
|
|
1644
|
+
);
|
|
1645
|
+
});
|
|
1646
|
+
};
|
|
1483
1647
|
result[method] = methodResp;
|
|
1484
1648
|
}
|
|
1485
1649
|
return result;
|
|
1486
1650
|
}
|
|
1487
1651
|
|
|
1488
|
-
var __defProp$8 = Object.defineProperty;
|
|
1489
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1490
|
-
var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
|
|
1491
|
-
class NetworkError extends Error {
|
|
1492
|
-
constructor(url) {
|
|
1493
|
-
super();
|
|
1494
|
-
__publicField$5(this, "name", "NetworkError");
|
|
1495
|
-
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1496
|
-
this.message = `Unable to request ${url}.
|
|
1497
|
-
Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
1652
|
function isObject(val) {
|
|
1502
1653
|
return Object.prototype.toString.call(val) === "[object Object]";
|
|
1503
1654
|
}
|
|
@@ -1514,7 +1665,7 @@ var Geocoder = (function (exports) {
|
|
|
1514
1665
|
const getResponseText = () => {
|
|
1515
1666
|
try {
|
|
1516
1667
|
return JSON.parse(xhr.responseText);
|
|
1517
|
-
} catch (
|
|
1668
|
+
} catch (e) {
|
|
1518
1669
|
return xhr.responseText;
|
|
1519
1670
|
}
|
|
1520
1671
|
};
|
|
@@ -1584,52 +1735,63 @@ var Geocoder = (function (exports) {
|
|
|
1584
1735
|
};
|
|
1585
1736
|
}
|
|
1586
1737
|
|
|
1587
|
-
const
|
|
1588
|
-
function
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1738
|
+
const CONNECTORS = [];
|
|
1739
|
+
function addConnector(connector) {
|
|
1740
|
+
CONNECTORS.push(connector);
|
|
1741
|
+
}
|
|
1742
|
+
function findConnector(options) {
|
|
1743
|
+
return CONNECTORS.find((x) => {
|
|
1744
|
+
if (x.options.baseUrl === options.baseUrl) {
|
|
1745
|
+
if (options.auth) {
|
|
1746
|
+
if (x.options.auth) {
|
|
1747
|
+
return objectDeepEqual(x.options.auth, options.auth);
|
|
1748
|
+
}
|
|
1749
|
+
} else {
|
|
1750
|
+
return true;
|
|
1751
|
+
}
|
|
1595
1752
|
}
|
|
1596
|
-
return value;
|
|
1597
1753
|
});
|
|
1598
1754
|
}
|
|
1755
|
+
function removeConnector(connector) {
|
|
1756
|
+
const index = CONNECTORS.indexOf(connector);
|
|
1757
|
+
if (index !== -1) {
|
|
1758
|
+
CONNECTORS.splice(index, 1);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1599
1761
|
|
|
1600
|
-
var __defProp$
|
|
1601
|
-
var __defProps$
|
|
1602
|
-
var __getOwnPropDescs$
|
|
1603
|
-
var __getOwnPropSymbols$
|
|
1604
|
-
var __hasOwnProp$
|
|
1605
|
-
var __propIsEnum$
|
|
1606
|
-
var __defNormalProp$
|
|
1607
|
-
var __spreadValues$
|
|
1762
|
+
var __defProp$6 = Object.defineProperty;
|
|
1763
|
+
var __defProps$3 = Object.defineProperties;
|
|
1764
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1765
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1766
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1767
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1768
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1769
|
+
var __spreadValues$4 = (a, b) => {
|
|
1608
1770
|
for (var prop in b || (b = {}))
|
|
1609
|
-
if (__hasOwnProp$
|
|
1610
|
-
__defNormalProp$
|
|
1611
|
-
if (__getOwnPropSymbols$
|
|
1612
|
-
for (var prop of __getOwnPropSymbols$
|
|
1613
|
-
if (__propIsEnum$
|
|
1614
|
-
__defNormalProp$
|
|
1771
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1772
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1773
|
+
if (__getOwnPropSymbols$4)
|
|
1774
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1775
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1776
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1615
1777
|
}
|
|
1616
1778
|
return a;
|
|
1617
1779
|
};
|
|
1618
|
-
var __spreadProps$
|
|
1780
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
1619
1781
|
var __objRest = (source, exclude) => {
|
|
1620
1782
|
var target = {};
|
|
1621
1783
|
for (var prop in source)
|
|
1622
|
-
if (__hasOwnProp$
|
|
1784
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1623
1785
|
target[prop] = source[prop];
|
|
1624
|
-
if (source != null && __getOwnPropSymbols$
|
|
1625
|
-
for (var prop of __getOwnPropSymbols$
|
|
1626
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1786
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
1787
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
1788
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
1627
1789
|
target[prop] = source[prop];
|
|
1628
1790
|
}
|
|
1629
1791
|
return target;
|
|
1630
1792
|
};
|
|
1631
|
-
var __publicField$4 = (obj, key, value) => __defNormalProp$
|
|
1632
|
-
var __async$
|
|
1793
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1794
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
1633
1795
|
return new Promise((resolve, reject) => {
|
|
1634
1796
|
var fulfilled = (value) => {
|
|
1635
1797
|
try {
|
|
@@ -1659,12 +1821,16 @@ var Geocoder = (function (exports) {
|
|
|
1659
1821
|
__publicField$4(this, "user");
|
|
1660
1822
|
__publicField$4(this, "cache");
|
|
1661
1823
|
__publicField$4(this, "withCredentials");
|
|
1824
|
+
// Dedicated cache for route requests, as these are executed before any other requests.
|
|
1825
|
+
// This cache does not need to be cleared during the session.
|
|
1826
|
+
__publicField$4(this, "routeCache");
|
|
1662
1827
|
__publicField$4(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
|
|
1663
1828
|
__publicField$4(this, "routeStr", "/api/component/pyramid/route");
|
|
1664
1829
|
__publicField$4(this, "activeRequests", {});
|
|
1665
1830
|
__publicField$4(this, "requestTransform");
|
|
1666
1831
|
const exist = findConnector(options);
|
|
1667
1832
|
this.cache = new Cache({ namespace: options.cacheId });
|
|
1833
|
+
this.routeCache = new Cache({ namespace: "routecache" });
|
|
1668
1834
|
if (exist) {
|
|
1669
1835
|
return exist;
|
|
1670
1836
|
} else {
|
|
@@ -1714,7 +1880,9 @@ var Geocoder = (function (exports) {
|
|
|
1714
1880
|
* ```
|
|
1715
1881
|
*/
|
|
1716
1882
|
connect() {
|
|
1717
|
-
return __async$
|
|
1883
|
+
return __async$3(this, arguments, function* ({
|
|
1884
|
+
signal
|
|
1885
|
+
} = {}) {
|
|
1718
1886
|
const auth = this.options.auth;
|
|
1719
1887
|
if (auth) {
|
|
1720
1888
|
const { login, password } = auth;
|
|
@@ -1723,18 +1891,9 @@ var Geocoder = (function (exports) {
|
|
|
1723
1891
|
}
|
|
1724
1892
|
}
|
|
1725
1893
|
const routeUrl = `${this.routeStr}?client=${this.client}`;
|
|
1726
|
-
return
|
|
1727
|
-
|
|
1728
|
-
{}
|
|
1729
|
-
{
|
|
1730
|
-
cacheName: "route",
|
|
1731
|
-
cache: true,
|
|
1732
|
-
cacheProps: {
|
|
1733
|
-
id: this.id,
|
|
1734
|
-
auth,
|
|
1735
|
-
baseUrl: this.options.baseUrl
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1894
|
+
return this.routeCache.add(
|
|
1895
|
+
this.options.baseUrl || String(this.id),
|
|
1896
|
+
() => this.makeQuery(routeUrl, null, { signal, cache: false })
|
|
1738
1897
|
);
|
|
1739
1898
|
});
|
|
1740
1899
|
}
|
|
@@ -1755,18 +1914,19 @@ var Geocoder = (function (exports) {
|
|
|
1755
1914
|
removeConnector(this);
|
|
1756
1915
|
this.options.auth = void 0;
|
|
1757
1916
|
this.user = void 0;
|
|
1917
|
+
this.routeCache.clean();
|
|
1758
1918
|
this.clearCache();
|
|
1759
1919
|
this.emitter.emit("logout");
|
|
1760
1920
|
}
|
|
1761
1921
|
getUserInfo(credentials, options) {
|
|
1762
|
-
return __async$
|
|
1922
|
+
return __async$3(this, null, function* () {
|
|
1763
1923
|
if (this.user && this.user.id) {
|
|
1764
1924
|
return this.user;
|
|
1765
1925
|
}
|
|
1766
1926
|
if (credentials) {
|
|
1767
1927
|
this.options.auth = credentials;
|
|
1768
1928
|
}
|
|
1769
|
-
const options_ = __spreadValues$
|
|
1929
|
+
const options_ = __spreadValues$4({
|
|
1770
1930
|
headers: this.getAuthorizationHeaders(credentials),
|
|
1771
1931
|
cache: true
|
|
1772
1932
|
}, options);
|
|
@@ -1807,7 +1967,7 @@ var Geocoder = (function (exports) {
|
|
|
1807
1967
|
this.activeRequests = {};
|
|
1808
1968
|
}
|
|
1809
1969
|
getActiveApiRequests() {
|
|
1810
|
-
return __spreadValues$
|
|
1970
|
+
return __spreadValues$4({}, this.activeRequests);
|
|
1811
1971
|
}
|
|
1812
1972
|
route(name, ...rest) {
|
|
1813
1973
|
return route(name, this, ...rest);
|
|
@@ -1819,7 +1979,7 @@ var Geocoder = (function (exports) {
|
|
|
1819
1979
|
* @param options - Request options
|
|
1820
1980
|
*/
|
|
1821
1981
|
makeQuery(_0, _1) {
|
|
1822
|
-
return __async$
|
|
1982
|
+
return __async$3(this, arguments, function* (url, params, options = {}) {
|
|
1823
1983
|
var _b;
|
|
1824
1984
|
url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
|
|
1825
1985
|
if (!url) {
|
|
@@ -1830,7 +1990,7 @@ var Geocoder = (function (exports) {
|
|
|
1830
1990
|
url = template(url, restParams);
|
|
1831
1991
|
}
|
|
1832
1992
|
url = encodeURI(fixUrlStr(url));
|
|
1833
|
-
options = __spreadValues$
|
|
1993
|
+
options = __spreadValues$4({ withCredentials: this.withCredentials }, options);
|
|
1834
1994
|
const {
|
|
1835
1995
|
cache,
|
|
1836
1996
|
signal: externalSignal,
|
|
@@ -1852,7 +2012,7 @@ var Geocoder = (function (exports) {
|
|
|
1852
2012
|
});
|
|
1853
2013
|
}
|
|
1854
2014
|
options.signal = internalSignal;
|
|
1855
|
-
const createPromise = () => __async$
|
|
2015
|
+
const createPromise = () => __async$3(this, null, function* () {
|
|
1856
2016
|
const id = REQUEST_ID++;
|
|
1857
2017
|
this.activeRequests[id] = internalAbortController;
|
|
1858
2018
|
try {
|
|
@@ -1861,8 +2021,8 @@ var Geocoder = (function (exports) {
|
|
|
1861
2021
|
this._cleanActiveRequest(id);
|
|
1862
2022
|
}
|
|
1863
2023
|
});
|
|
1864
|
-
if (method === "GET") {
|
|
1865
|
-
const cacheOptions = cacheProps ? cacheProps : __spreadProps$
|
|
2024
|
+
if (method === "GET" && cache !== false) {
|
|
2025
|
+
const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$4({}, objectRemoveEmpty({
|
|
1866
2026
|
headers,
|
|
1867
2027
|
withCredentials,
|
|
1868
2028
|
responseType,
|
|
@@ -1885,7 +2045,7 @@ var Geocoder = (function (exports) {
|
|
|
1885
2045
|
var _a;
|
|
1886
2046
|
if (this.user) {
|
|
1887
2047
|
options = options || {};
|
|
1888
|
-
options.headers = __spreadValues$
|
|
2048
|
+
options.headers = __spreadValues$4(__spreadValues$4({}, this.getAuthorizationHeaders()), options.headers);
|
|
1889
2049
|
}
|
|
1890
2050
|
if (this.requestTransform) {
|
|
1891
2051
|
const [transUrl, transOptions] = this.requestTransform(url, options);
|
|
@@ -1916,7 +2076,7 @@ var Geocoder = (function (exports) {
|
|
|
1916
2076
|
});
|
|
1917
2077
|
}
|
|
1918
2078
|
_login(credentials, options) {
|
|
1919
|
-
return __async$
|
|
2079
|
+
return __async$3(this, null, function* () {
|
|
1920
2080
|
try {
|
|
1921
2081
|
const data = yield this.getUserInfo(credentials, options);
|
|
1922
2082
|
this.user = data;
|
|
@@ -1944,10 +2104,7 @@ var Geocoder = (function (exports) {
|
|
|
1944
2104
|
return er;
|
|
1945
2105
|
}
|
|
1946
2106
|
}
|
|
1947
|
-
__publicField$4(NgwConnector, "errors",
|
|
1948
|
-
NgwError,
|
|
1949
|
-
ResourceNotFoundError
|
|
1950
|
-
});
|
|
2107
|
+
__publicField$4(NgwConnector, "errors", errors);
|
|
1951
2108
|
|
|
1952
2109
|
function resourceCompare(res1, res2) {
|
|
1953
2110
|
return objectDeepEqual(res1, res2);
|
|
@@ -1961,7 +2118,10 @@ var Geocoder = (function (exports) {
|
|
|
1961
2118
|
if (exclude.indexOf(key) === -1) {
|
|
1962
2119
|
if (isObject(value)) {
|
|
1963
2120
|
if (key === "owner_user") {
|
|
1964
|
-
const children = resourceToQuery(
|
|
2121
|
+
const children = resourceToQuery(
|
|
2122
|
+
value,
|
|
2123
|
+
key
|
|
2124
|
+
);
|
|
1965
2125
|
Object.assign(query, children);
|
|
1966
2126
|
} else if (key === "parent" && "id" in value) {
|
|
1967
2127
|
query.parent_id = value.id;
|
|
@@ -1974,24 +2134,27 @@ var Geocoder = (function (exports) {
|
|
|
1974
2134
|
return query;
|
|
1975
2135
|
}
|
|
1976
2136
|
|
|
1977
|
-
var __defProp$
|
|
1978
|
-
var
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
1981
|
-
var
|
|
1982
|
-
var
|
|
2137
|
+
var __defProp$5 = Object.defineProperty;
|
|
2138
|
+
var __defProps$2 = Object.defineProperties;
|
|
2139
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
2140
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
2141
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
2142
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
2143
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2144
|
+
var __spreadValues$3 = (a, b) => {
|
|
1983
2145
|
for (var prop in b || (b = {}))
|
|
1984
|
-
if (__hasOwnProp$
|
|
1985
|
-
__defNormalProp$
|
|
1986
|
-
if (__getOwnPropSymbols$
|
|
1987
|
-
for (var prop of __getOwnPropSymbols$
|
|
1988
|
-
if (__propIsEnum$
|
|
1989
|
-
__defNormalProp$
|
|
2146
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
2147
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
2148
|
+
if (__getOwnPropSymbols$3)
|
|
2149
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
2150
|
+
if (__propIsEnum$3.call(b, prop))
|
|
2151
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1990
2152
|
}
|
|
1991
2153
|
return a;
|
|
1992
2154
|
};
|
|
1993
|
-
var
|
|
1994
|
-
var
|
|
2155
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
2156
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2157
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
1995
2158
|
return new Promise((resolve, reject) => {
|
|
1996
2159
|
var fulfilled = (value) => {
|
|
1997
2160
|
try {
|
|
@@ -2032,7 +2195,7 @@ var Geocoder = (function (exports) {
|
|
|
2032
2195
|
* Fetching resource would be cached to speed up next call
|
|
2033
2196
|
*/
|
|
2034
2197
|
getOne(resource, requestOptions) {
|
|
2035
|
-
const opt = __spreadValues$
|
|
2198
|
+
const opt = __spreadValues$3({}, requestOptions);
|
|
2036
2199
|
if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
|
|
2037
2200
|
if (resource.id !== void 0) {
|
|
2038
2201
|
resource.id;
|
|
@@ -2109,9 +2272,11 @@ var Geocoder = (function (exports) {
|
|
|
2109
2272
|
} else {
|
|
2110
2273
|
Object.assign(query, resourceToQuery(resource));
|
|
2111
2274
|
}
|
|
2112
|
-
return this.connector.
|
|
2113
|
-
|
|
2114
|
-
|
|
2275
|
+
return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
|
|
2276
|
+
query: __spreadValues$3({
|
|
2277
|
+
serialization: "full"
|
|
2278
|
+
}, query)
|
|
2279
|
+
})).then((resources) => {
|
|
2115
2280
|
if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
|
|
2116
2281
|
for (const x of resources) {
|
|
2117
2282
|
this.cache.add("resource.item", Promise.resolve(x), {
|
|
@@ -2127,7 +2292,8 @@ var Geocoder = (function (exports) {
|
|
|
2127
2292
|
}
|
|
2128
2293
|
getParent(resource, requestOptions) {
|
|
2129
2294
|
return this.getOne(resource, requestOptions).then((child) => {
|
|
2130
|
-
|
|
2295
|
+
var _a, _b;
|
|
2296
|
+
if ((_b = (_a = child == null ? void 0 : child.resource) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) {
|
|
2131
2297
|
return this.getOne(child.resource.parent.id, requestOptions);
|
|
2132
2298
|
}
|
|
2133
2299
|
return Promise.resolve(void 0);
|
|
@@ -2159,10 +2325,21 @@ var Geocoder = (function (exports) {
|
|
|
2159
2325
|
}
|
|
2160
2326
|
});
|
|
2161
2327
|
}
|
|
2162
|
-
_getChildrenOf(
|
|
2163
|
-
return this
|
|
2164
|
-
parent
|
|
2165
|
-
|
|
2328
|
+
_getChildrenOf(_0, _1) {
|
|
2329
|
+
return __async$2(this, arguments, function* (parentDef, requestOptions, _items = []) {
|
|
2330
|
+
let parent = void 0;
|
|
2331
|
+
if (typeof parentDef === "string") {
|
|
2332
|
+
parent = yield this.getId(parentDef, requestOptions);
|
|
2333
|
+
} else if (typeof parentDef === "object") {
|
|
2334
|
+
parent = parentDef.id;
|
|
2335
|
+
} else {
|
|
2336
|
+
parent = parentDef;
|
|
2337
|
+
}
|
|
2338
|
+
const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
|
|
2339
|
+
query: {
|
|
2340
|
+
parent
|
|
2341
|
+
}
|
|
2342
|
+
}));
|
|
2166
2343
|
const recursivePromises = [];
|
|
2167
2344
|
for (const item of items) {
|
|
2168
2345
|
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
@@ -2186,7 +2363,7 @@ var Geocoder = (function (exports) {
|
|
|
2186
2363
|
});
|
|
2187
2364
|
}
|
|
2188
2365
|
_cleanResourceItemCache(id) {
|
|
2189
|
-
return __async$
|
|
2366
|
+
return __async$2(this, null, function* () {
|
|
2190
2367
|
var _a;
|
|
2191
2368
|
const all = this.cache.all();
|
|
2192
2369
|
const toDelete = [];
|
|
@@ -2211,7 +2388,7 @@ var Geocoder = (function (exports) {
|
|
|
2211
2388
|
});
|
|
2212
2389
|
}
|
|
2213
2390
|
_fetchResourceById(id, requestOptions) {
|
|
2214
|
-
return this.connector.
|
|
2391
|
+
return this.connector.route("resource.item", { id }).get(requestOptions);
|
|
2215
2392
|
}
|
|
2216
2393
|
_fetchResourceBy(resource, requestOptions) {
|
|
2217
2394
|
return this.getMany(resource, requestOptions).then((resources) => {
|
|
@@ -2239,93 +2416,6 @@ var Geocoder = (function (exports) {
|
|
|
2239
2416
|
}
|
|
2240
2417
|
}
|
|
2241
2418
|
|
|
2242
|
-
var __defProp$5 = Object.defineProperty;
|
|
2243
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
2244
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
2245
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
2246
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2247
|
-
var __spreadValues$3 = (a, b) => {
|
|
2248
|
-
for (var prop in b || (b = {}))
|
|
2249
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
2250
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
2251
|
-
if (__getOwnPropSymbols$3)
|
|
2252
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
2253
|
-
if (__propIsEnum$3.call(b, prop))
|
|
2254
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
2255
|
-
}
|
|
2256
|
-
return a;
|
|
2257
|
-
};
|
|
2258
|
-
var __async$2 = (__this, __arguments, generator) => {
|
|
2259
|
-
return new Promise((resolve, reject) => {
|
|
2260
|
-
var fulfilled = (value) => {
|
|
2261
|
-
try {
|
|
2262
|
-
step(generator.next(value));
|
|
2263
|
-
} catch (e) {
|
|
2264
|
-
reject(e);
|
|
2265
|
-
}
|
|
2266
|
-
};
|
|
2267
|
-
var rejected = (value) => {
|
|
2268
|
-
try {
|
|
2269
|
-
step(generator.throw(value));
|
|
2270
|
-
} catch (e) {
|
|
2271
|
-
reject(e);
|
|
2272
|
-
}
|
|
2273
|
-
};
|
|
2274
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2275
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2276
|
-
});
|
|
2277
|
-
};
|
|
2278
|
-
function apiRequest(opt) {
|
|
2279
|
-
return __async$2(this, null, function* () {
|
|
2280
|
-
const { params, name, connector, requestOptions } = opt;
|
|
2281
|
-
const apiItems = yield connector.connect();
|
|
2282
|
-
let apiItem = apiItems && apiItems[name];
|
|
2283
|
-
if (apiItem) {
|
|
2284
|
-
apiItem = [...apiItem];
|
|
2285
|
-
let url = apiItem.shift();
|
|
2286
|
-
if (apiItem.length) {
|
|
2287
|
-
const replaceParams = {};
|
|
2288
|
-
for (let fry = 0; fry < apiItem.length; fry++) {
|
|
2289
|
-
const arg = apiItem[fry];
|
|
2290
|
-
replaceParams[fry] = `{${arg}}`;
|
|
2291
|
-
if (params[arg] === void 0) {
|
|
2292
|
-
throw new Error(`\`${arg}\` URL API argument is not specified`);
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
if (url) {
|
|
2296
|
-
url = template(url, replaceParams);
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
if (params) {
|
|
2300
|
-
const paramArray = [];
|
|
2301
|
-
const paramList = params.paramList;
|
|
2302
|
-
if (Array.isArray(paramList)) {
|
|
2303
|
-
paramList.forEach(([key, value]) => {
|
|
2304
|
-
paramArray.push(`${key}=${value}`);
|
|
2305
|
-
});
|
|
2306
|
-
}
|
|
2307
|
-
for (const p in params) {
|
|
2308
|
-
if (apiItem.indexOf(p) === -1) {
|
|
2309
|
-
paramArray.push(`${p}=${params[p]}`);
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
if (paramArray.length) {
|
|
2313
|
-
url = `${url}?${paramArray.join("&")}`;
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
if (url) {
|
|
2317
|
-
return connector.makeQuery(url, params, __spreadValues$3({
|
|
2318
|
-
cacheName: name
|
|
2319
|
-
}, requestOptions));
|
|
2320
|
-
} else {
|
|
2321
|
-
throw new Error("Request URL is not set");
|
|
2322
|
-
}
|
|
2323
|
-
} else {
|
|
2324
|
-
return void 0;
|
|
2325
|
-
}
|
|
2326
|
-
});
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
2419
|
var __defProp$4 = Object.defineProperty;
|
|
2330
2420
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2331
2421
|
var __publicField$2 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
@@ -2653,19 +2743,17 @@ var Geocoder = (function (exports) {
|
|
|
2653
2743
|
};
|
|
2654
2744
|
const FEATURE_REQUEST_PARAMS = {
|
|
2655
2745
|
srs: 4326,
|
|
2656
|
-
geom_format: "geojson"
|
|
2746
|
+
geom_format: "geojson",
|
|
2747
|
+
dt_format: "iso"
|
|
2657
2748
|
};
|
|
2658
2749
|
function updateItemRequestParam(params, options) {
|
|
2659
2750
|
const { extensions, geom, fields, srs, ilike, like } = options;
|
|
2660
|
-
|
|
2661
|
-
if (
|
|
2662
|
-
params.
|
|
2663
|
-
}
|
|
2664
|
-
if (fields !== void 0 && fields !== null) {
|
|
2665
|
-
params.fields = Array.isArray(fields) ? fields.join(",") : "";
|
|
2751
|
+
params.extensions = extensions ? extensions : [];
|
|
2752
|
+
if (fields) {
|
|
2753
|
+
params.fields = fields;
|
|
2666
2754
|
}
|
|
2667
2755
|
if (geom !== void 0) {
|
|
2668
|
-
params.geom = geom
|
|
2756
|
+
params.geom = geom;
|
|
2669
2757
|
if (!geom) {
|
|
2670
2758
|
delete params.srs;
|
|
2671
2759
|
delete params.geom_format;
|
|
@@ -2680,6 +2768,15 @@ var Geocoder = (function (exports) {
|
|
|
2680
2768
|
params.srs = srs;
|
|
2681
2769
|
}
|
|
2682
2770
|
}
|
|
2771
|
+
function paramListToQuery(paramList) {
|
|
2772
|
+
return paramList.reduce(
|
|
2773
|
+
(acc, [key, value]) => {
|
|
2774
|
+
acc[key] = value;
|
|
2775
|
+
return acc;
|
|
2776
|
+
},
|
|
2777
|
+
{}
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2683
2780
|
function createFeatureFieldFilterQueries(opt) {
|
|
2684
2781
|
return __async$1(this, null, function* () {
|
|
2685
2782
|
const queries = getQueries(opt);
|
|
@@ -2730,13 +2827,7 @@ var Geocoder = (function (exports) {
|
|
|
2730
2827
|
}))
|
|
2731
2828
|
);
|
|
2732
2829
|
} else {
|
|
2733
|
-
getQueries(
|
|
2734
|
-
__spreadProps$1(__spreadValues$2({}, opt), {
|
|
2735
|
-
filters: f
|
|
2736
|
-
}),
|
|
2737
|
-
_queries,
|
|
2738
|
-
[..._parentAllParams]
|
|
2739
|
-
);
|
|
2830
|
+
getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: f }), _queries, [..._parentAllParams]);
|
|
2740
2831
|
}
|
|
2741
2832
|
}
|
|
2742
2833
|
} else if (logic === "all") {
|
|
@@ -2751,13 +2842,10 @@ var Geocoder = (function (exports) {
|
|
|
2751
2842
|
}
|
|
2752
2843
|
if (propertiesFilterList.length) {
|
|
2753
2844
|
for (const x of propertiesFilterList) {
|
|
2754
|
-
getQueries(
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
_queries,
|
|
2759
|
-
[..._parentAllParams, ...filters2]
|
|
2760
|
-
);
|
|
2845
|
+
getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: x }), _queries, [
|
|
2846
|
+
..._parentAllParams,
|
|
2847
|
+
...filters2
|
|
2848
|
+
]);
|
|
2761
2849
|
}
|
|
2762
2850
|
} else {
|
|
2763
2851
|
_queries.push(
|
|
@@ -2780,6 +2868,7 @@ var Geocoder = (function (exports) {
|
|
|
2780
2868
|
const params = __spreadValues$2({}, FEATURE_REQUEST_PARAMS);
|
|
2781
2869
|
const {
|
|
2782
2870
|
limit,
|
|
2871
|
+
query,
|
|
2783
2872
|
cache,
|
|
2784
2873
|
signal,
|
|
2785
2874
|
offset,
|
|
@@ -2790,12 +2879,8 @@ var Geocoder = (function (exports) {
|
|
|
2790
2879
|
intersects,
|
|
2791
2880
|
resourceId
|
|
2792
2881
|
} = options;
|
|
2793
|
-
if (limit) {
|
|
2794
|
-
|
|
2795
|
-
params.limit = limit;
|
|
2796
|
-
}
|
|
2797
|
-
} else {
|
|
2798
|
-
params.limit = 7e3;
|
|
2882
|
+
if (typeof limit === "number" && limit !== Number.POSITIVE_INFINITY) {
|
|
2883
|
+
params.limit = limit;
|
|
2799
2884
|
}
|
|
2800
2885
|
if (offset) {
|
|
2801
2886
|
params.offset = offset;
|
|
@@ -2814,16 +2899,9 @@ var Geocoder = (function (exports) {
|
|
|
2814
2899
|
params.intersects = intersects;
|
|
2815
2900
|
}
|
|
2816
2901
|
if (paramList) {
|
|
2817
|
-
params
|
|
2818
|
-
}
|
|
2819
|
-
|
|
2820
|
-
id: resourceId
|
|
2821
|
-
}, params);
|
|
2822
|
-
return connector.get(
|
|
2823
|
-
"feature_layer.feature.collection",
|
|
2824
|
-
{ cache, signal },
|
|
2825
|
-
reqParams
|
|
2826
|
-
);
|
|
2902
|
+
Object.assign(params, paramListToQuery(paramList));
|
|
2903
|
+
}
|
|
2904
|
+
return connector.route("feature_layer.feature.collection", { id: Number(resourceId) }).get({ query: __spreadValues$2(__spreadValues$2({}, params), query), cache, signal });
|
|
2827
2905
|
}
|
|
2828
2906
|
|
|
2829
2907
|
function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
@@ -3025,7 +3103,7 @@ var Geocoder = (function (exports) {
|
|
|
3025
3103
|
yield item;
|
|
3026
3104
|
}
|
|
3027
3105
|
} catch (er) {
|
|
3028
|
-
if (er && "name" in er && er.name !== "
|
|
3106
|
+
if (er && "name" in er && er.name !== "AbortError") {
|
|
3029
3107
|
console.warn(er);
|
|
3030
3108
|
}
|
|
3031
3109
|
}
|
|
@@ -3034,15 +3112,16 @@ var Geocoder = (function (exports) {
|
|
|
3034
3112
|
}
|
|
3035
3113
|
result(item) {
|
|
3036
3114
|
const signal = this._makeSignal();
|
|
3037
|
-
const req = this.connector.
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3115
|
+
const req = this.connector.route("feature_layer.feature.item_extent", {
|
|
3116
|
+
id: item.resourceId,
|
|
3117
|
+
fid: item.featureId
|
|
3118
|
+
}).get({ signal }).then((x) => {
|
|
3119
|
+
const e = x.extent || {
|
|
3120
|
+
minLon: 0,
|
|
3121
|
+
minLat: 0,
|
|
3122
|
+
maxLon: 0,
|
|
3123
|
+
maxLat: 0
|
|
3124
|
+
};
|
|
3046
3125
|
return {
|
|
3047
3126
|
text: item.text,
|
|
3048
3127
|
extent: [e.minLon, e.minLat, e.maxLon, e.maxLat]
|