@nextgis/ngw-map 2.5.0 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 2.5.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.1; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -474,308 +474,6 @@ var NgwMap = (function (exports) {
474
474
  return ret;
475
475
  }
476
476
 
477
- var __defProp$N = Object.defineProperty;
478
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
479
- var __publicField$z = (obj, key, value) => __defNormalProp$N(obj, key + "" , value);
480
- class CancelError extends Error {
481
- constructor() {
482
- super();
483
- __publicField$z(this, "name", "CancelError");
484
- Object.setPrototypeOf(this, CancelError.prototype);
485
- }
486
- }
487
-
488
- var __defProp$M = Object.defineProperty;
489
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
490
- var __publicField$y = (obj, key, value) => __defNormalProp$M(obj, key + "" , value);
491
- class PromiseControl {
492
- constructor(options = {}) {
493
- this.options = options;
494
- __publicField$y(this, "_promises", /* @__PURE__ */ new Map());
495
- }
496
- get isLoaded() {
497
- return this._promises.size > 0;
498
- }
499
- remove(promise) {
500
- if (this._promises.has(promise)) {
501
- this._promises.delete(promise);
502
- this._onStop();
503
- }
504
- }
505
- get(promise) {
506
- return this._promises.get(promise);
507
- }
508
- add(promise, name) {
509
- const key = name ? name : promise;
510
- const exist = this._promises.get(key);
511
- if (this.options.onStart && !this.isLoaded) {
512
- this.options.onStart();
513
- }
514
- if (exist) {
515
- return exist;
516
- }
517
- this._promises.set(key, promise);
518
- promise.finally(() => {
519
- this.remove(key);
520
- });
521
- return promise;
522
- }
523
- abort() {
524
- if (this.isLoaded) {
525
- this._promises.forEach((x) => {
526
- if (x.cancel) {
527
- x.cancel();
528
- }
529
- });
530
- this._promises.clear();
531
- this._onStop();
532
- }
533
- }
534
- waitFunc(func, name = "") {
535
- name = name || func.name;
536
- const exist = this.get(name);
537
- if (exist) {
538
- return exist;
539
- }
540
- return this.add(func(), name);
541
- }
542
- WaitForMe(name = "") {
543
- const get = this.get.bind(this);
544
- const add = this.add.bind(this);
545
- return function(target, key, descriptor) {
546
- const originalMethod = descriptor.value;
547
- name = name || key;
548
- descriptor.value = function(...args) {
549
- const exist = get(name);
550
- if (exist) {
551
- return exist;
552
- }
553
- const result = add(originalMethod.apply(this, args), name);
554
- return result;
555
- };
556
- return descriptor;
557
- };
558
- }
559
- /** @deprecated use {@link PromiseControl.WaitForMe } instead */
560
- GetOrCreateDecorator(name = "") {
561
- return this.WaitForMe(name);
562
- }
563
- _onStop() {
564
- if (this.options.onStop && !this.isLoaded) {
565
- this.options.onStop();
566
- }
567
- }
568
- }
569
-
570
- var __defProp$L = Object.defineProperty;
571
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
572
- var __publicField$x = (obj, key, value) => __defNormalProp$L(obj, key + "" , value);
573
- class TimeoutError extends Error {
574
- constructor() {
575
- super();
576
- __publicField$x(this, "name", "TimeoutError");
577
- Object.setPrototypeOf(this, TimeoutError.prototype);
578
- }
579
- }
580
-
581
- var __defProp$K = Object.defineProperty;
582
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
583
- var __publicField$w = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
584
- var _a;
585
- const handleCallback = (resolve, reject, callback, r) => {
586
- try {
587
- resolve(callback(r));
588
- } catch (e) {
589
- reject(e);
590
- }
591
- };
592
- let ID$3 = 0;
593
- _a = Symbol.toStringTag;
594
- const _CancelablePromise = class _CancelablePromise {
595
- constructor(executor, timeout) {
596
- // @ts-ignore
597
- __publicField$w(this, _a);
598
- __publicField$w(this, "id", ID$3++);
599
- __publicField$w(this, "_isCanceled", false);
600
- __publicField$w(this, "_isPending", true);
601
- __publicField$w(this, "_promise");
602
- __publicField$w(this, "_cancelPromise");
603
- __publicField$w(this, "_cancelHandlers", []);
604
- __publicField$w(this, "_setCanceledCallback");
605
- __publicField$w(this, "_parentPromise");
606
- __publicField$w(this, "_children", []);
607
- this._cancelPromise = new Promise((resolve_, reject_) => {
608
- this._setCanceledCallback = (er) => resolve_(er || new CancelError());
609
- });
610
- const promises = [
611
- this._cancelPromise,
612
- new Promise((resolve, reject) => {
613
- const onResolve = (value) => {
614
- if (value instanceof _CancelablePromise) {
615
- this.attach(value);
616
- } else {
617
- this._isPending = false;
618
- }
619
- resolve(value);
620
- };
621
- const onReject = (error) => {
622
- this._isPending = false;
623
- reject(error);
624
- };
625
- const onCancel = (handler) => {
626
- if (!this._isPending) {
627
- throw new Error(
628
- "The `onCancel` handler was attached after the promise settled."
629
- );
630
- }
631
- this._cancelHandlers.push(handler);
632
- };
633
- return executor(onResolve, onReject, onCancel);
634
- })
635
- ];
636
- if (timeout) {
637
- promises.push(
638
- new Promise((resolve, reject) => {
639
- setTimeout(() => {
640
- if (this._isPending) {
641
- try {
642
- this.cancel();
643
- } finally {
644
- reject(new TimeoutError());
645
- }
646
- }
647
- }, timeout);
648
- })
649
- );
650
- }
651
- this._promise = Promise.race(promises);
652
- }
653
- static createControl(opt) {
654
- return new PromiseControl(opt);
655
- }
656
- static resolve(value) {
657
- return new _CancelablePromise((resolve) => resolve(value));
658
- }
659
- static reject(value) {
660
- return new _CancelablePromise((resolve, reject) => reject(value));
661
- }
662
- static all(values) {
663
- return new _CancelablePromise((resolve, reject) => {
664
- Promise.all(values).then(resolve).catch(reject);
665
- }).catch((er) => {
666
- if (er instanceof this.CancelError) {
667
- for (const v of values) {
668
- const v_ = v;
669
- if ("cancel" in v_) {
670
- v_.cancel();
671
- }
672
- }
673
- }
674
- throw er;
675
- });
676
- }
677
- attach(p) {
678
- if (this._isCanceled) {
679
- p.cancel();
680
- } else {
681
- this._children.push(p);
682
- }
683
- }
684
- then(onfulfilled, onrejected) {
685
- const p = new _CancelablePromise((resolve, reject) => {
686
- if (this._promise) {
687
- const reject_ = (r) => {
688
- if (onrejected) {
689
- handleCallback(resolve, reject, onrejected, r);
690
- } else {
691
- reject(r);
692
- }
693
- };
694
- this._promise.then((r) => {
695
- if (this._isCanceled) {
696
- reject_(r);
697
- } else {
698
- if (onfulfilled) {
699
- handleCallback(resolve, reject, onfulfilled, r);
700
- } else {
701
- resolve(r);
702
- }
703
- }
704
- }, reject_);
705
- }
706
- });
707
- p._parentPromise = this;
708
- this._children.push(p);
709
- return p;
710
- }
711
- catch(onrejected) {
712
- if (this._isCanceled && onrejected) {
713
- onrejected(new CancelError());
714
- }
715
- return this.then(void 0, onrejected);
716
- }
717
- finally(onfinally) {
718
- if (this._promise) {
719
- return this._promise.finally(onfinally);
720
- }
721
- if (this._isCanceled) {
722
- return Promise.reject(new CancelError());
723
- }
724
- return Promise.reject(onfinally);
725
- }
726
- cancel() {
727
- if (this._isCanceled || !this._isPending) {
728
- return this;
729
- }
730
- this._isCanceled = true;
731
- const parent = this._getTopParent();
732
- if (parent) {
733
- parent.cancel();
734
- }
735
- if (this._children) {
736
- this._children.forEach((x) => x.cancel());
737
- }
738
- if (this._isPending) {
739
- if (this._cancelHandlers.length) {
740
- try {
741
- for (const handler of this._cancelHandlers) {
742
- handler();
743
- }
744
- } catch (error) {
745
- }
746
- }
747
- if (this._setCanceledCallback) {
748
- this._setCanceledCallback();
749
- }
750
- }
751
- this._destroy();
752
- return this;
753
- }
754
- _getTopParent() {
755
- let parent = this._parentPromise;
756
- let hasParent = !!parent;
757
- while (hasParent) {
758
- if (parent && parent._parentPromise) {
759
- parent = parent._parentPromise;
760
- hasParent = !!parent;
761
- } else {
762
- hasParent = false;
763
- }
764
- }
765
- return parent;
766
- }
767
- _destroy() {
768
- this._setCanceledCallback = void 0;
769
- this._cancelPromise = void 0;
770
- this._promise = void 0;
771
- }
772
- };
773
- __publicField$w(_CancelablePromise, "CancelError", CancelError);
774
- __publicField$w(_CancelablePromise, "TimeoutError", TimeoutError);
775
- __publicField$w(_CancelablePromise, "PromiseControl", PromiseControl);
776
- let CancelablePromise = _CancelablePromise;
777
- Object.setPrototypeOf(CancelablePromise.prototype, Promise.prototype);
778
-
779
477
  const svgPath = {
780
478
  brill: '<path d="m6 0-5 6 5 6 5-6z"/>',
781
479
  circle: '<circle cx="6" cy="6" r="6"/>',
@@ -1129,9 +827,9 @@ var NgwMap = (function (exports) {
1129
827
  return url.replace(/([^:]\/)\/+/g, "$1");
1130
828
  }
1131
829
 
1132
- var __defProp$J = Object.defineProperty;
1133
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1134
- var __publicField$v = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
830
+ var __defProp$K = Object.defineProperty;
831
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
832
+ var __publicField$v = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
1135
833
  const _Cache = class _Cache {
1136
834
  constructor(options = {}) {
1137
835
  __publicField$v(this, "cache", []);
@@ -1167,8 +865,7 @@ var NgwMap = (function (exports) {
1167
865
  * // somewhere else in the code
1168
866
  * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
1169
867
  * console.log(resp); // 'New item'
1170
- * })
1171
- *
868
+ * });
1172
869
  * ```
1173
870
  */
1174
871
  addFull(key, valueToSet, props) {
@@ -1183,13 +880,11 @@ var NgwMap = (function (exports) {
1183
880
  } else {
1184
881
  value = valueToSet;
1185
882
  }
1186
- const props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
883
+ const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1187
884
  const cacheItem = {
1188
885
  key,
1189
886
  value,
1190
- props: props_,
1191
- // TODO: remove backward compatibility use only props
1192
- options: props_
887
+ props: nonEmptyProps
1193
888
  };
1194
889
  if (onlyFull && !full(value)) {
1195
890
  return value;
@@ -1198,7 +893,6 @@ var NgwMap = (function (exports) {
1198
893
  if (value instanceof Promise) {
1199
894
  value.catch((er) => {
1200
895
  this.delete(key, props);
1201
- throw er;
1202
896
  });
1203
897
  if (onlyFull) {
1204
898
  value.then((x) => {
@@ -1217,9 +911,7 @@ var NgwMap = (function (exports) {
1217
911
  }
1218
912
  match(key, props) {
1219
913
  const cacheRecord = this._find(key, props);
1220
- if (cacheRecord) {
1221
- return cacheRecord.value;
1222
- }
914
+ return cacheRecord == null ? void 0 : cacheRecord.value;
1223
915
  }
1224
916
  matchAll(key, props) {
1225
917
  if (key) {
@@ -1228,37 +920,30 @@ var NgwMap = (function (exports) {
1228
920
  return this.cache.map((x) => x.value);
1229
921
  }
1230
922
  delete(keyOrItem, props) {
1231
- let exist = [];
1232
- if (typeof keyOrItem === "string") {
1233
- exist = this.cache.filter((x) => this._filter(x, keyOrItem, props));
1234
- } else {
1235
- exist.push(keyOrItem);
1236
- }
1237
- for (const e of exist) {
1238
- const index = this.cache.indexOf(e);
1239
- this.cache.splice(index, 1);
923
+ const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
924
+ for (const item of itemsToDelete) {
925
+ const index = this.cache.indexOf(item);
926
+ if (index !== -1) {
927
+ this.cache.splice(index, 1);
928
+ }
1240
929
  }
1241
930
  }
1242
931
  _find(key, props) {
1243
932
  return this.cache.find((x) => this._filter(x, key, props));
1244
933
  }
1245
934
  _filter(item, key, props) {
1246
- if (item.key === key) {
1247
- if (props) {
1248
- const itemProps = item.props || item.options;
1249
- return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1250
- }
1251
- return true;
1252
- }
1253
- return false;
935
+ if (item.key !== key) return false;
936
+ if (!props) return true;
937
+ const itemProps = item.props;
938
+ return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1254
939
  }
1255
940
  };
1256
941
  __publicField$v(_Cache, "instance", {});
1257
942
  let Cache = _Cache;
1258
943
 
1259
- var __defProp$I = Object.defineProperty;
1260
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1261
- var __publicField$u = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
944
+ var __defProp$J = Object.defineProperty;
945
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
946
+ var __publicField$u = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
1262
947
  class NgwError extends Error {
1263
948
  constructor(er) {
1264
949
  super();
@@ -1275,9 +960,9 @@ var NgwMap = (function (exports) {
1275
960
  }
1276
961
  }
1277
962
 
1278
- var __defProp$H = Object.defineProperty;
1279
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1280
- var __publicField$t = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
963
+ var __defProp$I = Object.defineProperty;
964
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
965
+ var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
1281
966
  class ResourceNotFoundError extends NgwError {
1282
967
  constructor(obj) {
1283
968
  super(obj);
@@ -1316,27 +1001,24 @@ var NgwMap = (function (exports) {
1316
1001
  return query;
1317
1002
  }
1318
1003
 
1319
- var __defProp$G = Object.defineProperty;
1320
- var __defProps$f = Object.defineProperties;
1321
- var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
1322
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1323
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1324
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1325
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1326
- var __spreadValues$t = (a, b) => {
1004
+ var __defProp$H = Object.defineProperty;
1005
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1006
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1007
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1008
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1009
+ var __spreadValues$v = (a, b) => {
1327
1010
  for (var prop in b || (b = {}))
1328
- if (__hasOwnProp$u.call(b, prop))
1329
- __defNormalProp$G(a, prop, b[prop]);
1330
- if (__getOwnPropSymbols$u)
1331
- for (var prop of __getOwnPropSymbols$u(b)) {
1332
- if (__propIsEnum$u.call(b, prop))
1333
- __defNormalProp$G(a, prop, b[prop]);
1011
+ if (__hasOwnProp$w.call(b, prop))
1012
+ __defNormalProp$H(a, prop, b[prop]);
1013
+ if (__getOwnPropSymbols$w)
1014
+ for (var prop of __getOwnPropSymbols$w(b)) {
1015
+ if (__propIsEnum$w.call(b, prop))
1016
+ __defNormalProp$H(a, prop, b[prop]);
1334
1017
  }
1335
1018
  return a;
1336
1019
  };
1337
- var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
1338
- var __publicField$s = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1339
- var __async$l = (__this, __arguments, generator) => {
1020
+ var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1021
+ var __async$s = (__this, __arguments, generator) => {
1340
1022
  return new Promise((resolve, reject) => {
1341
1023
  var fulfilled = (value) => {
1342
1024
  try {
@@ -1377,39 +1059,27 @@ var NgwMap = (function (exports) {
1377
1059
  * Fetching resource would be cached to speed up next call
1378
1060
  */
1379
1061
  getOne(resource, requestOptions) {
1380
- const cache = this.cache;
1381
- const forCache = {};
1382
- const opt = __spreadProps$f(__spreadValues$t({}, requestOptions), { cache: false });
1383
- if (typeof resource === "string") {
1384
- forCache.keyname = resource;
1385
- } else if (typeof resource === "number") {
1386
- forCache.id = resource;
1387
- } else if (isObject(resource)) {
1062
+ const opt = __spreadValues$v({}, requestOptions);
1063
+ if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1388
1064
  if (resource.id !== void 0) {
1389
- forCache.id = resource.id;
1065
+ resource.id;
1390
1066
  } else {
1391
1067
  if (resource.keyname) {
1392
- forCache.keyname = resource.keyname;
1068
+ resource.keyname;
1393
1069
  }
1394
1070
  if (resource.display_name) {
1395
- forCache.display_name = resource.display_name;
1071
+ resource.display_name;
1396
1072
  }
1397
1073
  }
1398
1074
  }
1399
- const makeRequest = () => {
1400
- if (typeof resource === "string") {
1401
- return this._fetchResourceBy({ keyname: resource }, opt);
1402
- } else if (typeof resource === "number") {
1403
- return this._fetchResourceById(resource, opt);
1404
- } else if (isObject(resource)) {
1405
- return this._fetchResourceBy(resource, opt);
1406
- }
1407
- return CancelablePromise.resolve(void 0);
1408
- };
1409
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1410
- return cache.addFull("resource", makeRequest, forCache);
1075
+ if (typeof resource === "string") {
1076
+ return this._fetchResourceBy({ keyname: resource }, opt);
1077
+ } else if (typeof resource === "number") {
1078
+ return this._fetchResourceById(resource, opt);
1079
+ } else if (isObject(resource)) {
1080
+ return this._fetchResourceBy(resource, opt);
1411
1081
  }
1412
- return makeRequest();
1082
+ return Promise.resolve(void 0);
1413
1083
  }
1414
1084
  getOneOrFail(resource, requestOptions) {
1415
1085
  return this.getOne(resource, requestOptions).then((res) => {
@@ -1431,7 +1101,7 @@ var NgwMap = (function (exports) {
1431
1101
  */
1432
1102
  getId(resource, requestOptions) {
1433
1103
  if (typeof resource === "number") {
1434
- return CancelablePromise.resolve(resource);
1104
+ return Promise.resolve(resource);
1435
1105
  } else if (typeof resource === "string" || isObject(resource)) {
1436
1106
  return this.getOne(resource, requestOptions).then((res) => {
1437
1107
  if (res) {
@@ -1439,7 +1109,7 @@ var NgwMap = (function (exports) {
1439
1109
  }
1440
1110
  });
1441
1111
  }
1442
- return CancelablePromise.resolve(void 0);
1112
+ return Promise.resolve(void 0);
1443
1113
  }
1444
1114
  /**
1445
1115
  * A fast way to retrieve resource ID for any resource definition.
@@ -1466,12 +1136,12 @@ var NgwMap = (function (exports) {
1466
1136
  } else {
1467
1137
  Object.assign(query, resourceToQuery(resource));
1468
1138
  }
1469
- return this.connector.get("resource.search", requestOptions, __spreadValues$t({
1139
+ return this.connector.get("resource.search", requestOptions, __spreadValues$v({
1470
1140
  serialization: "full"
1471
1141
  }, query)).then((resources) => {
1472
- if (resources) {
1142
+ if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
1473
1143
  for (const x of resources) {
1474
- this.cache.add("resource.item", CancelablePromise.resolve(x), {
1144
+ this.cache.add("resource.item", Promise.resolve(x), {
1475
1145
  id: x.resource.id
1476
1146
  });
1477
1147
  }
@@ -1487,7 +1157,7 @@ var NgwMap = (function (exports) {
1487
1157
  if (child) {
1488
1158
  return this.getOne(child.resource.parent.id, requestOptions);
1489
1159
  }
1490
- return CancelablePromise.resolve(void 0);
1160
+ return Promise.resolve(void 0);
1491
1161
  });
1492
1162
  }
1493
1163
  getChildrenOf(resource, requestOptions) {
@@ -1517,18 +1187,16 @@ var NgwMap = (function (exports) {
1517
1187
  });
1518
1188
  }
1519
1189
  _getChildrenOf(parent, requestOptions, _items = []) {
1520
- return this.connector.get(
1521
- "resource.collection",
1522
- __spreadValues$t({ cache: true }, requestOptions),
1523
- {
1524
- parent
1525
- }
1526
- ).then((items) => {
1190
+ return this.connector.get("resource.collection", requestOptions, {
1191
+ parent
1192
+ }).then((items) => {
1527
1193
  const recursivePromises = [];
1528
1194
  for (const item of items) {
1529
- this.cache.add("resource.item", CancelablePromise.resolve(item), {
1530
- id: item.resource.id
1531
- });
1195
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
1196
+ this.cache.add("resource.item", Promise.resolve(item), {
1197
+ id: item.resource.id
1198
+ });
1199
+ }
1532
1200
  _items.push(item);
1533
1201
  if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
1534
1202
  recursivePromises.push(
@@ -1537,7 +1205,7 @@ var NgwMap = (function (exports) {
1537
1205
  }
1538
1206
  }
1539
1207
  if (recursivePromises.length) {
1540
- return CancelablePromise.all(recursivePromises).then(() => {
1208
+ return Promise.all(recursivePromises).then(() => {
1541
1209
  return _items;
1542
1210
  });
1543
1211
  }
@@ -1545,11 +1213,12 @@ var NgwMap = (function (exports) {
1545
1213
  });
1546
1214
  }
1547
1215
  _cleanResourceItemCache(id) {
1548
- return __async$l(this, null, function* () {
1216
+ return __async$s(this, null, function* () {
1217
+ var _a;
1549
1218
  const all = this.cache.all();
1550
1219
  const toDelete = [];
1551
1220
  for (const c of all) {
1552
- const cid = c.options && c.options.id;
1221
+ const cid = (_a = c.props) == null ? void 0 : _a.id;
1553
1222
  if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
1554
1223
  if (typeof cid === "number") {
1555
1224
  if (cid === id) {
@@ -1569,18 +1238,7 @@ var NgwMap = (function (exports) {
1569
1238
  });
1570
1239
  }
1571
1240
  _fetchResourceById(id, requestOptions) {
1572
- const promise = () => this.connector.get("resource.item", requestOptions, { id });
1573
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1574
- return this.cache.add("resource.item", promise, {
1575
- id
1576
- }).catch((er) => {
1577
- if (!(er instanceof ResourceNotFoundError)) {
1578
- throw er;
1579
- }
1580
- return void 0;
1581
- });
1582
- }
1583
- return promise();
1241
+ return this.connector.get("resource.item", requestOptions, { id });
1584
1242
  }
1585
1243
  _fetchResourceBy(resource, requestOptions) {
1586
1244
  return this.getMany(resource, requestOptions).then((resources) => {
@@ -1588,7 +1246,7 @@ var NgwMap = (function (exports) {
1588
1246
  });
1589
1247
  }
1590
1248
  _resourceCacheFilter(resource) {
1591
- return CancelablePromise.all(this.cache.matchAll("resource.item")).then(
1249
+ return Promise.all(this.cache.matchAll("resource.item")).then(
1592
1250
  (resources) => {
1593
1251
  const items = [];
1594
1252
  resources.filter((x) => {
@@ -1632,9 +1290,16 @@ var NgwMap = (function (exports) {
1632
1290
  }
1633
1291
  }
1634
1292
 
1635
- var __defProp$F = Object.defineProperty;
1636
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1637
- var __publicField$r = (obj, key, value) => __defNormalProp$F(obj, typeof key !== "symbol" ? key + "" : key, value);
1293
+ class AbortError extends Error {
1294
+ constructor(message = "AbortError") {
1295
+ super(message);
1296
+ this.name = "AbortError";
1297
+ }
1298
+ }
1299
+
1300
+ var __defProp$G = Object.defineProperty;
1301
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1302
+ var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1638
1303
  class InsufficientPermissionsError extends NgwError {
1639
1304
  constructor(obj) {
1640
1305
  super(obj);
@@ -1657,58 +1322,90 @@ var NgwMap = (function (exports) {
1657
1322
  });
1658
1323
  }
1659
1324
 
1325
+ var __defProp$F = Object.defineProperty;
1326
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1327
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1328
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1329
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1330
+ var __spreadValues$u = (a, b) => {
1331
+ for (var prop in b || (b = {}))
1332
+ if (__hasOwnProp$v.call(b, prop))
1333
+ __defNormalProp$F(a, prop, b[prop]);
1334
+ if (__getOwnPropSymbols$v)
1335
+ for (var prop of __getOwnPropSymbols$v(b)) {
1336
+ if (__propIsEnum$v.call(b, prop))
1337
+ __defNormalProp$F(a, prop, b[prop]);
1338
+ }
1339
+ return a;
1340
+ };
1341
+ var __async$r = (__this, __arguments, generator) => {
1342
+ return new Promise((resolve, reject) => {
1343
+ var fulfilled = (value) => {
1344
+ try {
1345
+ step(generator.next(value));
1346
+ } catch (e) {
1347
+ reject(e);
1348
+ }
1349
+ };
1350
+ var rejected = (value) => {
1351
+ try {
1352
+ step(generator.throw(value));
1353
+ } catch (e) {
1354
+ reject(e);
1355
+ }
1356
+ };
1357
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1358
+ step((generator = generator.apply(__this, __arguments)).next());
1359
+ });
1360
+ };
1660
1361
  function apiRequest(opt) {
1661
- const params = opt.params;
1662
- return new CancelablePromise((resolve, reject) => {
1663
- return opt.connector.connect().then((apiItems) => {
1664
- let apiItem = apiItems && apiItems[opt.name];
1665
- if (apiItem) {
1666
- apiItem = [...apiItem];
1667
- let url = apiItem.shift();
1668
- if (apiItem.length) {
1669
- const replaceParams = {};
1670
- for (let fry = 0; fry < apiItem.length; fry++) {
1671
- const arg = apiItem[fry];
1672
- replaceParams[fry] = "{" + arg + "}";
1673
- if (params[arg] === void 0) {
1674
- throw new Error(
1675
- "`" + arg + "` url api argument is not specified"
1676
- );
1677
- }
1678
- }
1679
- if (url) {
1680
- url = template(url, replaceParams);
1362
+ return __async$r(this, null, function* () {
1363
+ const { params, name, connector, requestOptions } = opt;
1364
+ const apiItems = yield connector.connect();
1365
+ let apiItem = apiItems && apiItems[name];
1366
+ if (apiItem) {
1367
+ apiItem = [...apiItem];
1368
+ let url = apiItem.shift();
1369
+ if (apiItem.length) {
1370
+ const replaceParams = {};
1371
+ for (let fry = 0; fry < apiItem.length; fry++) {
1372
+ const arg = apiItem[fry];
1373
+ replaceParams[fry] = `{${arg}}`;
1374
+ if (params[arg] === void 0) {
1375
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
1681
1376
  }
1682
1377
  }
1683
- if (params) {
1684
- const paramArray = [];
1685
- const paramList = params.paramList;
1686
- if (Array.isArray(paramList)) {
1687
- delete params.paramList;
1688
- paramList.forEach((x) => {
1689
- paramArray.push(`${x[0]}=${x[1]}`);
1690
- });
1691
- }
1692
- for (const p in params) {
1693
- if (apiItem.indexOf(p) === -1) {
1694
- paramArray.push(`${p}=${params[p]}`);
1695
- }
1696
- }
1697
- if (paramArray.length) {
1698
- url = url + "?" + paramArray.join("&");
1378
+ if (url) {
1379
+ url = template(url, replaceParams);
1380
+ }
1381
+ }
1382
+ if (params) {
1383
+ const paramArray = [];
1384
+ const paramList = params.paramList;
1385
+ if (Array.isArray(paramList)) {
1386
+ paramList.forEach(([key, value]) => {
1387
+ paramArray.push(`${key}=${value}`);
1388
+ });
1389
+ }
1390
+ for (const p in params) {
1391
+ if (apiItem.indexOf(p) === -1) {
1392
+ paramArray.push(`${p}=${params[p]}`);
1699
1393
  }
1700
1394
  }
1701
- if (url) {
1702
- resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1703
- } else {
1704
- reject(new Error("request url is not set"));
1395
+ if (paramArray.length) {
1396
+ url = `${url}?${paramArray.join("&")}`;
1705
1397
  }
1398
+ }
1399
+ if (url) {
1400
+ return connector.makeQuery(url, params, __spreadValues$u({
1401
+ cacheName: name
1402
+ }, requestOptions));
1706
1403
  } else {
1707
- resolve(void 0);
1404
+ throw new Error("Request URL is not set");
1708
1405
  }
1709
- }).catch((er) => {
1710
- reject(er);
1711
- });
1406
+ } else {
1407
+ return void 0;
1408
+ }
1712
1409
  });
1713
1410
  }
1714
1411
 
@@ -1808,23 +1505,59 @@ var NgwMap = (function (exports) {
1808
1505
  }
1809
1506
 
1810
1507
  var __defProp$D = Object.defineProperty;
1811
- var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
1812
- var __hasOwnProp$t = Object.prototype.hasOwnProperty;
1813
- var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
1508
+ var __defProps$f = Object.defineProperties;
1509
+ var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
1510
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1511
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1512
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1814
1513
  var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1815
- var __spreadValues$s = (a, b) => {
1514
+ var __spreadValues$t = (a, b) => {
1816
1515
  for (var prop in b || (b = {}))
1817
- if (__hasOwnProp$t.call(b, prop))
1516
+ if (__hasOwnProp$u.call(b, prop))
1818
1517
  __defNormalProp$D(a, prop, b[prop]);
1819
- if (__getOwnPropSymbols$t)
1820
- for (var prop of __getOwnPropSymbols$t(b)) {
1821
- if (__propIsEnum$t.call(b, prop))
1518
+ if (__getOwnPropSymbols$u)
1519
+ for (var prop of __getOwnPropSymbols$u(b)) {
1520
+ if (__propIsEnum$u.call(b, prop))
1822
1521
  __defNormalProp$D(a, prop, b[prop]);
1823
1522
  }
1824
1523
  return a;
1825
1524
  };
1525
+ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
1526
+ var __objRest$2 = (source, exclude) => {
1527
+ var target = {};
1528
+ for (var prop in source)
1529
+ if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
1530
+ target[prop] = source[prop];
1531
+ if (source != null && __getOwnPropSymbols$u)
1532
+ for (var prop of __getOwnPropSymbols$u(source)) {
1533
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
1534
+ target[prop] = source[prop];
1535
+ }
1536
+ return target;
1537
+ };
1826
1538
  var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
1539
+ var __async$q = (__this, __arguments, generator) => {
1540
+ return new Promise((resolve, reject) => {
1541
+ var fulfilled = (value) => {
1542
+ try {
1543
+ step(generator.next(value));
1544
+ } catch (e) {
1545
+ reject(e);
1546
+ }
1547
+ };
1548
+ var rejected = (value) => {
1549
+ try {
1550
+ step(generator.throw(value));
1551
+ } catch (e) {
1552
+ reject(e);
1553
+ }
1554
+ };
1555
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1556
+ step((generator = generator.apply(__this, __arguments)).next());
1557
+ });
1558
+ };
1827
1559
  let ID$2 = 0;
1560
+ let REQUEST_ID = 0;
1828
1561
  class NgwConnector {
1829
1562
  constructor(options) {
1830
1563
  this.options = options;
@@ -1835,7 +1568,7 @@ var NgwMap = (function (exports) {
1835
1568
  __publicField$p(this, "cache");
1836
1569
  __publicField$p(this, "withCredentials");
1837
1570
  __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1838
- __publicField$p(this, "activeRequests", []);
1571
+ __publicField$p(this, "activeRequests", {});
1839
1572
  __publicField$p(this, "requestTransform");
1840
1573
  const exist = findConnector(options);
1841
1574
  this.cache = new Cache({ namespace: options.cacheId });
@@ -1896,29 +1629,27 @@ var NgwMap = (function (exports) {
1896
1629
  * ```
1897
1630
  */
1898
1631
  connect() {
1899
- const auth = this.options.auth;
1900
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1901
- const makeQuery = () => {
1902
- return this.makeQuery(this.routeStr, {}, {}).then((route) => {
1903
- resolve(route);
1904
- }).catch((er) => {
1905
- reject(er);
1906
- });
1907
- };
1632
+ return __async$q(this, null, function* () {
1633
+ const auth = this.options.auth;
1908
1634
  if (auth) {
1909
1635
  const { login, password } = auth;
1910
1636
  if (login && password) {
1911
- return this._login({ login, password }).then(() => {
1912
- return makeQuery();
1913
- }).catch((er) => reject(er));
1637
+ yield this._login({ login, password });
1914
1638
  }
1915
1639
  }
1916
- return makeQuery();
1917
- });
1918
- return this.cache.add("route", makeConnect, {
1919
- id: this.id,
1920
- auth,
1921
- baseUrl: this.options.baseUrl
1640
+ return yield this.makeQuery(
1641
+ this.routeStr,
1642
+ {},
1643
+ {
1644
+ cacheName: "route",
1645
+ cache: true,
1646
+ cacheProps: {
1647
+ id: this.id,
1648
+ auth,
1649
+ baseUrl: this.options.baseUrl
1650
+ }
1651
+ }
1652
+ );
1922
1653
  });
1923
1654
  }
1924
1655
  /**
@@ -1942,20 +1673,22 @@ var NgwMap = (function (exports) {
1942
1673
  this.emitter.emit("logout");
1943
1674
  }
1944
1675
  getUserInfo(credentials, options) {
1945
- if (this.user && this.user.id) {
1946
- return CancelablePromise.resolve(this.user);
1947
- }
1948
- if (credentials) {
1949
- this.options.auth = credentials;
1950
- }
1951
- const options_ = __spreadValues$s({
1952
- headers: this.getAuthorizationHeaders(credentials)
1953
- }, options);
1954
- return this.makeQuery(
1955
- "/api/component/auth/current_user",
1956
- {},
1957
- options_
1958
- );
1676
+ return __async$q(this, null, function* () {
1677
+ if (this.user && this.user.id) {
1678
+ return this.user;
1679
+ }
1680
+ if (credentials) {
1681
+ this.options.auth = credentials;
1682
+ }
1683
+ const options_ = __spreadValues$t({
1684
+ headers: this.getAuthorizationHeaders(credentials)
1685
+ }, options);
1686
+ return this.makeQuery(
1687
+ "/api/component/auth/current_user",
1688
+ {},
1689
+ options_
1690
+ );
1691
+ });
1959
1692
  }
1960
1693
  /**
1961
1694
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -1964,7 +1697,7 @@ var NgwMap = (function (exports) {
1964
1697
  const client = this.makeClientId(credentials);
1965
1698
  if (client) {
1966
1699
  return {
1967
- Authorization: "Basic " + client
1700
+ Authorization: `Basic ${client}`
1968
1701
  };
1969
1702
  }
1970
1703
  }
@@ -1972,21 +1705,22 @@ var NgwMap = (function (exports) {
1972
1705
  credentials = credentials || this.options.auth;
1973
1706
  if (credentials) {
1974
1707
  const { login, password } = credentials;
1975
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1708
+ const str = `${login}:${password}`;
1709
+ const encodedStr = encodeURIComponent(str);
1976
1710
  {
1977
- return window.btoa(str);
1711
+ return window.btoa(encodedStr);
1978
1712
  }
1979
1713
  }
1980
1714
  }
1981
1715
  /** Stop all api requests */
1982
1716
  abort() {
1983
- for (const req of this.activeRequests) {
1984
- req.cancel();
1717
+ for (const abortController of Object.values(this.activeRequests)) {
1718
+ abortController.abort();
1985
1719
  }
1986
- this.activeRequests = [];
1720
+ this.activeRequests = {};
1987
1721
  }
1988
1722
  getActiveApiRequests() {
1989
- return [...this.activeRequests];
1723
+ return __spreadValues$t({}, this.activeRequests);
1990
1724
  }
1991
1725
  /**
1992
1726
  * Send request to NGW api router.
@@ -2018,26 +1752,10 @@ var NgwMap = (function (exports) {
2018
1752
  * ```
2019
1753
  */
2020
1754
  apiRequest(name, params_ = {}, requestOptions = {}) {
2021
- var _a, _b;
2022
- requestOptions = __spreadValues$s({
2023
- withCredentials: this.withCredentials
2024
- }, requestOptions);
2025
- const { method, headers, withCredentials, responseType } = requestOptions;
1755
+ var _a;
2026
1756
  params_ = (_a = requestOptions.params) != null ? _a : params_;
2027
1757
  const params = objectRemoveEmpty(params_);
2028
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
2029
- if (requestOptions.cache && method === "GET") {
2030
- return this.cache.add(name, makeApiRequest, __spreadValues$s({
2031
- params
2032
- }, objectRemoveEmpty({
2033
- headers,
2034
- withCredentials,
2035
- responseType,
2036
- baseUrl: this.options.baseUrl,
2037
- userId: (_b = this.user) == null ? void 0 : _b.id
2038
- })));
2039
- }
2040
- return makeApiRequest();
1758
+ return apiRequest({ name, params, requestOptions, connector: this });
2041
1759
  }
2042
1760
  /**
2043
1761
  * Shortcut method for send POST request to NGW.
@@ -2127,17 +1845,68 @@ var NgwMap = (function (exports) {
2127
1845
  * @param params - Query params
2128
1846
  * @param options - Request options
2129
1847
  */
2130
- makeQuery(url, params, options = {}) {
2131
- url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
2132
- if (url) {
1848
+ makeQuery(_0, _1) {
1849
+ return __async$q(this, arguments, function* (url, params, options = {}) {
1850
+ var _b;
1851
+ url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1852
+ if (!url) {
1853
+ throw new Error("Empty `url` not allowed");
1854
+ }
2133
1855
  if (params) {
2134
- url = template(url, params);
1856
+ const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1857
+ url = template(url, restParams);
1858
+ }
1859
+ url = encodeURI(fixUrlStr(url));
1860
+ options = __spreadValues$t({ withCredentials: this.withCredentials }, options);
1861
+ const {
1862
+ cache,
1863
+ signal: externalSignal,
1864
+ method = "GET",
1865
+ headers,
1866
+ cacheName,
1867
+ cacheProps,
1868
+ responseType,
1869
+ withCredentials
1870
+ } = options;
1871
+ const internalAbortController = new AbortController();
1872
+ const internalSignal = internalAbortController.signal;
1873
+ if (externalSignal) {
1874
+ if (externalSignal.aborted) {
1875
+ throw new AbortError();
1876
+ }
1877
+ externalSignal.addEventListener("abort", () => {
1878
+ internalAbortController.abort();
1879
+ });
1880
+ }
1881
+ options.signal = internalSignal;
1882
+ const createPromise = () => __async$q(this, null, function* () {
1883
+ const id = REQUEST_ID++;
1884
+ this.activeRequests[id] = internalAbortController;
1885
+ try {
1886
+ return this._loadData(url, options);
1887
+ } finally {
1888
+ this._cleanActiveRequest(id);
1889
+ }
1890
+ });
1891
+ if (cache && method === "GET") {
1892
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$f(__spreadValues$t({}, objectRemoveEmpty({
1893
+ headers,
1894
+ withCredentials,
1895
+ responseType,
1896
+ baseUrl: this.options.baseUrl,
1897
+ userId: (_b = this.user) == null ? void 0 : _b.id
1898
+ })), {
1899
+ params
1900
+ });
1901
+ return this.cache.add(
1902
+ cacheName || url,
1903
+ createPromise,
1904
+ cacheOptions,
1905
+ false
1906
+ );
2135
1907
  }
2136
- url = encodeURI(fixUrlStr(url));
2137
- return this._loadData(url, options);
2138
- } else {
2139
- throw new Error("Empty `url` not allowed");
2140
- }
1908
+ return createPromise();
1909
+ });
2141
1910
  }
2142
1911
  // -------------------------------------------------------------------------
2143
1912
  // Resource Methods
@@ -2219,26 +1988,29 @@ var NgwMap = (function (exports) {
2219
1988
  */
2220
1989
  _loadData(url, options) {
2221
1990
  options.responseType = options.responseType || "json";
2222
- if (options.signal && options.signal.aborted) {
2223
- return CancelablePromise.reject(new CancelablePromise.CancelError());
2224
- }
2225
- const request = new CancelablePromise((resolve, reject, onCancel) => {
1991
+ return new Promise((resolve, reject) => {
1992
+ var _a;
2226
1993
  if (this.user) {
2227
1994
  options = options || {};
2228
- options.headers = __spreadValues$s(__spreadValues$s({}, this.getAuthorizationHeaders()), options.headers);
1995
+ options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
2229
1996
  }
2230
1997
  if (this.requestTransform) {
2231
1998
  const [transUrl, transOptions] = this.requestTransform(url, options);
2232
1999
  url = transUrl;
2233
2000
  options = transOptions;
2234
2001
  }
2235
- loadData(url, resolve, options, reject, onCancel);
2236
- }).then((resp) => {
2237
- this._cleanActiveRequests(request);
2238
- return resp;
2002
+ let runOnAbort = void 0;
2003
+ loadData(url, resolve, options, reject, (handler) => {
2004
+ runOnAbort = handler;
2005
+ });
2006
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2007
+ if (runOnAbort !== void 0) {
2008
+ runOnAbort();
2009
+ }
2010
+ reject(new AbortError());
2011
+ });
2239
2012
  }).catch((httpError) => {
2240
- this._cleanActiveRequests(request);
2241
- if (httpError instanceof CancelablePromise.CancelError) ; else {
2013
+ if (httpError.name !== "AbortError") {
2242
2014
  {
2243
2015
  console.warn("DEV WARN", httpError);
2244
2016
  }
@@ -2247,31 +2019,24 @@ var NgwMap = (function (exports) {
2247
2019
  throw er;
2248
2020
  }
2249
2021
  }
2022
+ throw httpError;
2250
2023
  });
2251
- if (options.signal && typeof options.signal.addEventListener === "function") {
2252
- options.signal.addEventListener("abort", () => {
2253
- request.cancel();
2254
- this._cleanActiveRequests(request);
2255
- });
2256
- }
2257
- this.activeRequests.push(request);
2258
- return request;
2259
2024
  }
2260
2025
  _login(credentials, options) {
2261
- return this.getUserInfo(credentials, options).then((data) => {
2262
- this.user = data;
2263
- this.emitter.emit("login", data);
2264
- return data;
2265
- }).catch((er) => {
2266
- this.emitter.emit("login:error", er);
2267
- throw er;
2026
+ return __async$q(this, null, function* () {
2027
+ try {
2028
+ const data = yield this.getUserInfo(credentials, options);
2029
+ this.user = data;
2030
+ this.emitter.emit("login", data);
2031
+ return data;
2032
+ } catch (er) {
2033
+ this.emitter.emit("login:error", er);
2034
+ throw er;
2035
+ }
2268
2036
  });
2269
2037
  }
2270
- _cleanActiveRequests(request) {
2271
- const activeRequestIndex = this.activeRequests.indexOf(request);
2272
- if (activeRequestIndex !== -1) {
2273
- this.activeRequests.splice(activeRequestIndex, 1);
2274
- }
2038
+ _cleanActiveRequest(requestId) {
2039
+ delete this.activeRequests[requestId];
2275
2040
  }
2276
2041
  _handleHttpError(er) {
2277
2042
  if (er) {
@@ -2292,17 +2057,17 @@ var NgwMap = (function (exports) {
2292
2057
  });
2293
2058
 
2294
2059
  var __defProp$C = Object.defineProperty;
2295
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2296
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2297
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2060
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2061
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2062
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2298
2063
  var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2299
- var __spreadValues$r = (a, b) => {
2064
+ var __spreadValues$s = (a, b) => {
2300
2065
  for (var prop in b || (b = {}))
2301
- if (__hasOwnProp$s.call(b, prop))
2066
+ if (__hasOwnProp$t.call(b, prop))
2302
2067
  __defNormalProp$C(a, prop, b[prop]);
2303
- if (__getOwnPropSymbols$s)
2304
- for (var prop of __getOwnPropSymbols$s(b)) {
2305
- if (__propIsEnum$s.call(b, prop))
2068
+ if (__getOwnPropSymbols$t)
2069
+ for (var prop of __getOwnPropSymbols$t(b)) {
2070
+ if (__propIsEnum$t.call(b, prop))
2306
2071
  __defNormalProp$C(a, prop, b[prop]);
2307
2072
  }
2308
2073
  return a;
@@ -2350,7 +2115,7 @@ var NgwMap = (function (exports) {
2350
2115
  return false;
2351
2116
  }
2352
2117
  function featureFilter(feature, filters) {
2353
- const properties = __spreadValues$r({}, feature.properties);
2118
+ const properties = __spreadValues$s({}, feature.properties);
2354
2119
  if (properties) {
2355
2120
  properties.$id = feature.id;
2356
2121
  return propertiesFilter(properties, filters);
@@ -2388,22 +2153,42 @@ var NgwMap = (function (exports) {
2388
2153
  var __defProp$B = Object.defineProperty;
2389
2154
  var __defProps$e = Object.defineProperties;
2390
2155
  var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2391
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2392
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2393
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2156
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2157
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2158
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2394
2159
  var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2395
- var __spreadValues$q = (a, b) => {
2160
+ var __spreadValues$r = (a, b) => {
2396
2161
  for (var prop in b || (b = {}))
2397
- if (__hasOwnProp$r.call(b, prop))
2162
+ if (__hasOwnProp$s.call(b, prop))
2398
2163
  __defNormalProp$B(a, prop, b[prop]);
2399
- if (__getOwnPropSymbols$r)
2400
- for (var prop of __getOwnPropSymbols$r(b)) {
2401
- if (__propIsEnum$r.call(b, prop))
2164
+ if (__getOwnPropSymbols$s)
2165
+ for (var prop of __getOwnPropSymbols$s(b)) {
2166
+ if (__propIsEnum$s.call(b, prop))
2402
2167
  __defNormalProp$B(a, prop, b[prop]);
2403
2168
  }
2404
2169
  return a;
2405
2170
  };
2406
2171
  var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2172
+ var __async$p = (__this, __arguments, generator) => {
2173
+ return new Promise((resolve, reject) => {
2174
+ var fulfilled = (value) => {
2175
+ try {
2176
+ step(generator.next(value));
2177
+ } catch (e) {
2178
+ reject(e);
2179
+ }
2180
+ };
2181
+ var rejected = (value) => {
2182
+ try {
2183
+ step(generator.throw(value));
2184
+ } catch (e) {
2185
+ reject(e);
2186
+ }
2187
+ };
2188
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2189
+ step((generator = generator.apply(__this, __arguments)).next());
2190
+ });
2191
+ };
2407
2192
  const FEATURE_REQUEST_PARAMS = {
2408
2193
  srs: 4326,
2409
2194
  geom_format: "geojson"
@@ -2444,10 +2229,9 @@ var NgwMap = (function (exports) {
2444
2229
  }
2445
2230
  }
2446
2231
  function createFeatureFieldFilterQueries(opt) {
2447
- const queries = getQueries(
2448
- opt
2449
- );
2450
- return CancelablePromise.all(queries).then((itemsParts) => {
2232
+ return __async$p(this, null, function* () {
2233
+ const queries = getQueries(opt);
2234
+ const itemsParts = yield Promise.all(queries);
2451
2235
  const ids = [];
2452
2236
  const items = [];
2453
2237
  for (const part of itemsParts) {
@@ -2489,13 +2273,13 @@ var NgwMap = (function (exports) {
2489
2273
  for (const f of filters_) {
2490
2274
  if (isPropertyFilter(f)) {
2491
2275
  _queries.push(
2492
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$q({}, opt), {
2276
+ fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2493
2277
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
2494
2278
  }))
2495
2279
  );
2496
2280
  } else {
2497
2281
  getQueries(
2498
- __spreadProps$e(__spreadValues$q({}, opt), {
2282
+ __spreadProps$e(__spreadValues$r({}, opt), {
2499
2283
  filters: f
2500
2284
  }),
2501
2285
  _queries,
@@ -2516,7 +2300,7 @@ var NgwMap = (function (exports) {
2516
2300
  if (propertiesFilterList.length) {
2517
2301
  for (const x of propertiesFilterList) {
2518
2302
  getQueries(
2519
- __spreadProps$e(__spreadValues$q({}, opt), {
2303
+ __spreadProps$e(__spreadValues$r({}, opt), {
2520
2304
  filters: x
2521
2305
  }),
2522
2306
  _queries,
@@ -2525,7 +2309,7 @@ var NgwMap = (function (exports) {
2525
2309
  }
2526
2310
  } else {
2527
2311
  _queries.push(
2528
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$q({}, opt), {
2312
+ fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2529
2313
  paramList: [..._parentAllParams, ...paramList, ...filters2]
2530
2314
  }))
2531
2315
  );
@@ -2541,7 +2325,7 @@ var NgwMap = (function (exports) {
2541
2325
  return `POLYGON((${polygon.join(", ")}))`;
2542
2326
  }
2543
2327
  function fetchNgwLayerItemsRequest(options) {
2544
- const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2328
+ const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2545
2329
  const {
2546
2330
  limit,
2547
2331
  cache,
@@ -2580,7 +2364,7 @@ var NgwMap = (function (exports) {
2580
2364
  if (paramList) {
2581
2365
  params.paramList = paramList;
2582
2366
  }
2583
- const reqParams = __spreadValues$q({
2367
+ const reqParams = __spreadValues$r({
2584
2368
  id: resourceId
2585
2369
  }, params);
2586
2370
  return connector.get(
@@ -2593,52 +2377,90 @@ var NgwMap = (function (exports) {
2593
2377
  var __defProp$A = Object.defineProperty;
2594
2378
  var __defProps$d = Object.defineProperties;
2595
2379
  var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
2596
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2597
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2598
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2380
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2381
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2382
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2599
2383
  var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2600
- var __spreadValues$p = (a, b) => {
2384
+ var __spreadValues$q = (a, b) => {
2601
2385
  for (var prop in b || (b = {}))
2602
- if (__hasOwnProp$q.call(b, prop))
2386
+ if (__hasOwnProp$r.call(b, prop))
2603
2387
  __defNormalProp$A(a, prop, b[prop]);
2604
- if (__getOwnPropSymbols$q)
2605
- for (var prop of __getOwnPropSymbols$q(b)) {
2606
- if (__propIsEnum$q.call(b, prop))
2388
+ if (__getOwnPropSymbols$r)
2389
+ for (var prop of __getOwnPropSymbols$r(b)) {
2390
+ if (__propIsEnum$r.call(b, prop))
2607
2391
  __defNormalProp$A(a, prop, b[prop]);
2608
2392
  }
2609
2393
  return a;
2610
2394
  };
2611
2395
  var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
2396
+ var __async$o = (__this, __arguments, generator) => {
2397
+ return new Promise((resolve, reject) => {
2398
+ var fulfilled = (value) => {
2399
+ try {
2400
+ step(generator.next(value));
2401
+ } catch (e) {
2402
+ reject(e);
2403
+ }
2404
+ };
2405
+ var rejected = (value) => {
2406
+ try {
2407
+ step(generator.throw(value));
2408
+ } catch (e) {
2409
+ reject(e);
2410
+ }
2411
+ };
2412
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2413
+ step((generator = generator.apply(__this, __arguments)).next());
2414
+ });
2415
+ };
2612
2416
  function fetchNgwLayerItem(options) {
2613
- const params = __spreadValues$p({}, FEATURE_REQUEST_PARAMS);
2614
- updateItemRequestParam(params, options);
2615
- const queryParams = __spreadValues$p({
2616
- id: options.resourceId,
2617
- fid: options.featureId
2618
- }, params);
2619
- const cache = options.cache || true;
2620
- return options.connector.get("feature_layer.feature.item", { cache }, queryParams).then((resp) => {
2621
- return __spreadProps$d(__spreadValues$p({}, resp), {
2622
- toGeojson: () => {
2623
- if (resp.geom) {
2624
- return CancelablePromise.resolve(createGeoJsonFeature(resp));
2625
- } else {
2626
- return fetchNgwLayerItem(__spreadProps$d(__spreadValues$p({}, options), {
2627
- geom: true,
2628
- fields: null,
2629
- extensions: null
2630
- })).then((onlyGeomItem) => {
2631
- const geom = onlyGeomItem.geom;
2632
- return createGeoJsonFeature(__spreadProps$d(__spreadValues$p({}, resp), { geom }));
2633
- });
2634
- }
2417
+ return __async$o(this, null, function* () {
2418
+ const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2419
+ updateItemRequestParam(params, options);
2420
+ const queryParams = __spreadValues$q({
2421
+ id: options.resourceId,
2422
+ fid: options.featureId
2423
+ }, params);
2424
+ const resp = yield options.connector.get(
2425
+ "feature_layer.feature.item",
2426
+ options,
2427
+ queryParams
2428
+ );
2429
+ const toGeojson = () => __async$o(this, null, function* () {
2430
+ if (resp.geom) {
2431
+ return createGeoJsonFeature(resp);
2432
+ } else {
2433
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$d(__spreadValues$q({}, options), {
2434
+ geom: true,
2435
+ fields: null,
2436
+ extensions: null
2437
+ }));
2438
+ const geom = onlyGeomItem.geom;
2439
+ return createGeoJsonFeature(__spreadProps$d(__spreadValues$q({}, resp), { geom }));
2635
2440
  }
2636
2441
  });
2442
+ return __spreadProps$d(__spreadValues$q({}, resp), {
2443
+ toGeojson
2444
+ });
2637
2445
  });
2638
2446
  }
2639
2447
 
2640
2448
  var __defProp$z = Object.defineProperty;
2449
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2450
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2451
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2641
2452
  var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2453
+ var __spreadValues$p = (a, b) => {
2454
+ for (var prop in b || (b = {}))
2455
+ if (__hasOwnProp$q.call(b, prop))
2456
+ __defNormalProp$z(a, prop, b[prop]);
2457
+ if (__getOwnPropSymbols$q)
2458
+ for (var prop of __getOwnPropSymbols$q(b)) {
2459
+ if (__propIsEnum$q.call(b, prop))
2460
+ __defNormalProp$z(a, prop, b[prop]);
2461
+ }
2462
+ return a;
2463
+ };
2642
2464
  var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2643
2465
  class BookmarkItem {
2644
2466
  constructor(options) {
@@ -2656,11 +2478,11 @@ var NgwMap = (function (exports) {
2656
2478
  this.name = String(item.id);
2657
2479
  }
2658
2480
  }
2659
- extent() {
2481
+ extent(opt) {
2660
2482
  if (this._extent) {
2661
- return CancelablePromise.resolve(this._extent);
2483
+ return Promise.resolve(this._extent);
2662
2484
  }
2663
- return this.options.connector.get("feature_layer.feature.item_extent", null, {
2485
+ return this.options.connector.get("feature_layer.feature.item_extent", opt, {
2664
2486
  id: this.resourceId,
2665
2487
  fid: this.item.id
2666
2488
  }).then((resp) => {
@@ -2670,18 +2492,18 @@ var NgwMap = (function (exports) {
2670
2492
  return lonLat;
2671
2493
  });
2672
2494
  }
2673
- geoJson() {
2495
+ geoJson(opt) {
2674
2496
  if (this.item.geom) {
2675
- return CancelablePromise.resolve(createGeoJsonFeature(this.item));
2497
+ return Promise.resolve(createGeoJsonFeature(this.item));
2676
2498
  } else {
2677
- return fetchNgwLayerItem({
2499
+ return fetchNgwLayerItem(__spreadValues$p({
2678
2500
  resourceId: this.resourceId,
2679
2501
  featureId: this.item.id,
2680
2502
  connector: this.options.connector,
2681
2503
  geom: true,
2682
2504
  fields: null,
2683
2505
  extensions: null
2684
- }).then((onlyGeomItem) => {
2506
+ }, opt)).then((onlyGeomItem) => {
2685
2507
  const geom = onlyGeomItem.geom;
2686
2508
  this.item.geom = geom;
2687
2509
  return createGeoJsonFeature(this.item);
@@ -3311,9 +3133,10 @@ var NgwMap = (function (exports) {
3311
3133
  function fetchNgwLayerExtent({
3312
3134
  resourceId,
3313
3135
  connector,
3314
- cache = true
3136
+ cache = true,
3137
+ signal
3315
3138
  }) {
3316
- return connector.get("layer.extent", { cache }, { id: resourceId }).then((resp) => {
3139
+ return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3317
3140
  if (resp) {
3318
3141
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3319
3142
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3325,11 +3148,12 @@ var NgwMap = (function (exports) {
3325
3148
  resourceId,
3326
3149
  featureId,
3327
3150
  connector,
3328
- cache = true
3151
+ cache = true,
3152
+ signal
3329
3153
  }) {
3330
3154
  return connector.get(
3331
3155
  "feature_layer.feature.item_extent",
3332
- { cache },
3156
+ { cache, signal },
3333
3157
  { id: resourceId, fid: featureId }
3334
3158
  ).then((resp) => {
3335
3159
  if (resp) {
@@ -3340,7 +3164,10 @@ var NgwMap = (function (exports) {
3340
3164
  });
3341
3165
  }
3342
3166
  function fetchNgwExtent(options) {
3343
- return options.connector.getResource(options.resourceId).then((resource) => {
3167
+ return options.connector.getResource(options.resourceId, {
3168
+ signal: options.signal,
3169
+ cache: options.cache
3170
+ }).then((resource) => {
3344
3171
  if (resource) {
3345
3172
  return fetchNgwResourceExtent(resource, options.connector, options);
3346
3173
  }
@@ -3348,11 +3175,11 @@ var NgwMap = (function (exports) {
3348
3175
  }
3349
3176
  function fetchNgwResourceExtent(item, connector, options) {
3350
3177
  if (item.webmap) {
3351
- return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
3178
+ return Promise.resolve(getNgwWebmapExtent(item.webmap));
3352
3179
  } else {
3353
3180
  const resource = item.resource;
3354
3181
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3355
- return connector.getResource(resource.parent.id).then((res) => {
3182
+ return connector.getResource(resource.parent.id, options).then((res) => {
3356
3183
  if (res) {
3357
3184
  return fetchNgwLayerExtent(__spreadProps$c(__spreadValues$l({}, options), {
3358
3185
  resourceId: res.resource.id,
@@ -3372,7 +3199,7 @@ var NgwMap = (function (exports) {
3372
3199
  var __defProp$s = Object.defineProperty;
3373
3200
  var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3374
3201
  var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3375
- var __async$k = (__this, __arguments, generator) => {
3202
+ var __async$n = (__this, __arguments, generator) => {
3376
3203
  return new Promise((resolve, reject) => {
3377
3204
  var fulfilled = (value) => {
3378
3205
  try {
@@ -3400,12 +3227,12 @@ var NgwMap = (function (exports) {
3400
3227
  }
3401
3228
  /** @deprecated use {@link NgwResource.getBounds} instead */
3402
3229
  getExtent() {
3403
- return __async$k(this, null, function* () {
3230
+ return __async$n(this, null, function* () {
3404
3231
  return this.getBounds();
3405
3232
  });
3406
3233
  }
3407
3234
  getBounds(options) {
3408
- return __async$k(this, null, function* () {
3235
+ return __async$n(this, null, function* () {
3409
3236
  if (this._extent) {
3410
3237
  return this._extent;
3411
3238
  }
@@ -3421,7 +3248,7 @@ var NgwMap = (function (exports) {
3421
3248
  }
3422
3249
  }
3423
3250
 
3424
- var __async$j = (__this, __arguments, generator) => {
3251
+ var __async$m = (__this, __arguments, generator) => {
3425
3252
  return new Promise((resolve, reject) => {
3426
3253
  var fulfilled = (value) => {
3427
3254
  try {
@@ -3442,7 +3269,7 @@ var NgwMap = (function (exports) {
3442
3269
  });
3443
3270
  };
3444
3271
  function resourceIdFromLayerOptions(options, connector) {
3445
- return __async$j(this, null, function* () {
3272
+ return __async$m(this, null, function* () {
3446
3273
  const resource = options.resource;
3447
3274
  const item = resource;
3448
3275
  let { keyname, resourceId } = options;
@@ -3544,7 +3371,7 @@ var NgwMap = (function (exports) {
3544
3371
  return target;
3545
3372
  };
3546
3373
  var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3547
- var __async$i = (__this, __arguments, generator) => {
3374
+ var __async$l = (__this, __arguments, generator) => {
3548
3375
  return new Promise((resolve, reject) => {
3549
3376
  var fulfilled = (value) => {
3550
3377
  try {
@@ -3596,7 +3423,7 @@ var NgwMap = (function (exports) {
3596
3423
  }
3597
3424
  }
3598
3425
  addLayer(options) {
3599
- return __async$i(this, null, function* () {
3426
+ return __async$l(this, null, function* () {
3600
3427
  if (!this.qms && options.qmsId) {
3601
3428
  try {
3602
3429
  this.qms = yield loadJson(
@@ -3704,7 +3531,7 @@ var NgwMap = (function (exports) {
3704
3531
  };
3705
3532
  var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
3706
3533
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3707
- var __async$h = (__this, __arguments, generator) => {
3534
+ var __async$k = (__this, __arguments, generator) => {
3708
3535
  return new Promise((resolve, reject) => {
3709
3536
  var fulfilled = (value) => {
3710
3537
  try {
@@ -3725,7 +3552,7 @@ var NgwMap = (function (exports) {
3725
3552
  });
3726
3553
  };
3727
3554
  function createBasemapLayerAdapter(_0) {
3728
- return __async$h(this, arguments, function* ({
3555
+ return __async$k(this, arguments, function* ({
3729
3556
  webMap,
3730
3557
  item
3731
3558
  }) {
@@ -3746,7 +3573,7 @@ var NgwMap = (function (exports) {
3746
3573
  if (TileAdapter) {
3747
3574
  class BasemapTileAdapter extends TileAdapter {
3748
3575
  addLayer(opt) {
3749
- return __async$h(this, null, function* () {
3576
+ return __async$k(this, null, function* () {
3750
3577
  return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$b(__spreadValues$i({}, opt), { url }));
3751
3578
  });
3752
3579
  }
@@ -3786,11 +3613,12 @@ var NgwMap = (function (exports) {
3786
3613
  function fetchNgwLayerCount({
3787
3614
  connector,
3788
3615
  resourceId,
3789
- cache = true
3616
+ cache = true,
3617
+ signal
3790
3618
  }) {
3791
3619
  return connector.get(
3792
3620
  "feature_layer.feature.count",
3793
- { cache },
3621
+ { cache, signal },
3794
3622
  {
3795
3623
  id: resourceId
3796
3624
  }
@@ -3844,13 +3672,34 @@ var NgwMap = (function (exports) {
3844
3672
  return a;
3845
3673
  };
3846
3674
  var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
3675
+ var __async$j = (__this, __arguments, generator) => {
3676
+ return new Promise((resolve, reject) => {
3677
+ var fulfilled = (value) => {
3678
+ try {
3679
+ step(generator.next(value));
3680
+ } catch (e) {
3681
+ reject(e);
3682
+ }
3683
+ };
3684
+ var rejected = (value) => {
3685
+ try {
3686
+ step(generator.throw(value));
3687
+ } catch (e) {
3688
+ reject(e);
3689
+ }
3690
+ };
3691
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3692
+ step((generator = generator.apply(__this, __arguments)).next());
3693
+ });
3694
+ };
3847
3695
  function fetchNgwLayerItems(options) {
3848
- const filters = options.filters;
3849
- if (filters) {
3850
- return createFeatureFieldFilterQueries(__spreadProps$a(__spreadValues$h({}, options), {
3851
- filters
3852
- })).then((data) => {
3853
- var _a;
3696
+ return __async$j(this, null, function* () {
3697
+ var _a;
3698
+ const filters = options.filters;
3699
+ if (filters) {
3700
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$a(__spreadValues$h({}, options), {
3701
+ filters
3702
+ }));
3854
3703
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3855
3704
  if (clientFilterValidate) {
3856
3705
  data = data.filter((y) => {
@@ -3862,10 +3711,10 @@ var NgwMap = (function (exports) {
3862
3711
  });
3863
3712
  }
3864
3713
  return data;
3865
- });
3866
- } else {
3867
- return fetchNgwLayerItemsRequest(options);
3868
- }
3714
+ } else {
3715
+ return fetchNgwLayerItemsRequest(options);
3716
+ }
3717
+ });
3869
3718
  }
3870
3719
  function isFilterWithAnyCase(filters) {
3871
3720
  if (filters[0] === "any") {
@@ -3883,8 +3732,29 @@ var NgwMap = (function (exports) {
3883
3732
  return false;
3884
3733
  }
3885
3734
 
3735
+ var __async$i = (__this, __arguments, generator) => {
3736
+ return new Promise((resolve, reject) => {
3737
+ var fulfilled = (value) => {
3738
+ try {
3739
+ step(generator.next(value));
3740
+ } catch (e) {
3741
+ reject(e);
3742
+ }
3743
+ };
3744
+ var rejected = (value) => {
3745
+ try {
3746
+ step(generator.throw(value));
3747
+ } catch (e) {
3748
+ reject(e);
3749
+ }
3750
+ };
3751
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3752
+ step((generator = generator.apply(__this, __arguments)).next());
3753
+ });
3754
+ };
3886
3755
  function fetchNgwLayerFeatures(options) {
3887
- return fetchNgwLayerItems(options).then((x) => {
3756
+ return __async$i(this, null, function* () {
3757
+ const x = yield fetchNgwLayerItems(options);
3888
3758
  const features = [];
3889
3759
  x.forEach((y) => {
3890
3760
  features.push(createGeoJsonFeature(y));
@@ -3944,7 +3814,7 @@ var NgwMap = (function (exports) {
3944
3814
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3945
3815
  var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
3946
3816
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3947
- var __async$g = (__this, __arguments, generator) => {
3817
+ var __async$h = (__this, __arguments, generator) => {
3948
3818
  return new Promise((resolve, reject) => {
3949
3819
  var fulfilled = (value) => {
3950
3820
  try {
@@ -3965,7 +3835,7 @@ var NgwMap = (function (exports) {
3965
3835
  });
3966
3836
  };
3967
3837
  function createGeoJsonAdapter(props) {
3968
- return __async$g(this, null, function* () {
3838
+ return __async$h(this, null, function* () {
3969
3839
  var _a, _b;
3970
3840
  const {
3971
3841
  item,
@@ -3981,29 +3851,35 @@ var NgwMap = (function (exports) {
3981
3851
  const _loadedIds = [];
3982
3852
  let _fullDataLoad = false;
3983
3853
  let _lastFilterArgs;
3984
- let _dataPromise;
3854
+ let internalAbortController;
3985
3855
  const resourceId = yield resourceIdFromLayerOptions(options, connector);
3986
3856
  if ((_b = (_a = options.adapterOptions) == null ? void 0 : _a.popupOptions) == null ? void 0 : _b.fromProperties) {
3987
3857
  options.adapterOptions.popupOptions.createPopupContent = ({ feature }) => {
3988
3858
  return feature && createPopupContent(feature, item);
3989
3859
  };
3990
3860
  }
3991
- const getData = (filters, filterOpt) => __async$g(this, null, function* () {
3861
+ const getData = (filters, filterOpt) => __async$h(this, null, function* () {
3992
3862
  abort();
3863
+ internalAbortController = new AbortController();
3864
+ const internalSignal = internalAbortController.signal;
3865
+ if (filterOpt == null ? void 0 : filterOpt.signal) {
3866
+ filterOpt.signal.addEventListener("abort", internalAbortController.abort);
3867
+ }
3868
+ filterOpt = filterOpt || {};
3869
+ filterOpt.signal = internalSignal;
3993
3870
  _lastFilterArgs = { filters, options: filterOpt };
3994
- _dataPromise = fetchNgwLayerFeatureCollection(__spreadValues$g({
3871
+ return fetchNgwLayerFeatureCollection(__spreadValues$g({
3995
3872
  resourceId,
3996
3873
  filters,
3997
3874
  connector,
3998
3875
  cache: true
3999
3876
  }, filterOpt));
4000
- return yield _dataPromise;
4001
3877
  });
4002
3878
  let removed = false;
4003
3879
  const abort = () => {
4004
- if (_dataPromise) {
4005
- _dataPromise.cancel();
4006
- _dataPromise = void 0;
3880
+ if (internalAbortController) {
3881
+ internalAbortController.abort();
3882
+ internalAbortController = void 0;
4007
3883
  }
4008
3884
  };
4009
3885
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
@@ -4016,7 +3892,7 @@ var NgwMap = (function (exports) {
4016
3892
  __publicField$f(this, "__disableMapMoveListener");
4017
3893
  }
4018
3894
  addLayer(opt) {
4019
- return __async$g(this, null, function* () {
3895
+ return __async$h(this, null, function* () {
4020
3896
  let needUpdate = !opt.data;
4021
3897
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
4022
3898
  if (options.id !== void 0) {
@@ -4061,7 +3937,7 @@ var NgwMap = (function (exports) {
4061
3937
  return this.getBounds();
4062
3938
  }
4063
3939
  getBounds() {
4064
- return __async$g(this, null, function* () {
3940
+ return __async$h(this, null, function* () {
4065
3941
  const hasData = this.getLayers && this.getLayers().length;
4066
3942
  const strategy = this.options.strategy;
4067
3943
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -4087,7 +3963,7 @@ var NgwMap = (function (exports) {
4087
3963
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4088
3964
  }
4089
3965
  updateLayer(filterArgs) {
4090
- return __async$g(this, null, function* () {
3966
+ return __async$h(this, null, function* () {
4091
3967
  var _a2;
4092
3968
  filterArgs = filterArgs || _lastFilterArgs || {};
4093
3969
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
@@ -4153,7 +4029,7 @@ var NgwMap = (function (exports) {
4153
4029
  });
4154
4030
  }
4155
4031
  propertiesFilter(filters, opt) {
4156
- return __async$g(this, null, function* () {
4032
+ return __async$h(this, null, function* () {
4157
4033
  abort();
4158
4034
  if (this.filter && _fullDataLoad) {
4159
4035
  this.filter((e) => {
@@ -4227,7 +4103,7 @@ var NgwMap = (function (exports) {
4227
4103
  });
4228
4104
  }
4229
4105
 
4230
- var __async$f = (__this, __arguments, generator) => {
4106
+ var __async$g = (__this, __arguments, generator) => {
4231
4107
  return new Promise((resolve, reject) => {
4232
4108
  var fulfilled = (value) => {
4233
4109
  try {
@@ -4248,7 +4124,7 @@ var NgwMap = (function (exports) {
4248
4124
  });
4249
4125
  };
4250
4126
  function createWebMapAdapter(_0) {
4251
- return __async$f(this, arguments, function* ({
4127
+ return __async$g(this, arguments, function* ({
4252
4128
  layerOptions: options,
4253
4129
  webMap,
4254
4130
  connector
@@ -4376,7 +4252,7 @@ var NgwMap = (function (exports) {
4376
4252
  };
4377
4253
  var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4378
4254
  var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4379
- var __async$e = (__this, __arguments, generator) => {
4255
+ var __async$f = (__this, __arguments, generator) => {
4380
4256
  return new Promise((resolve, reject) => {
4381
4257
  var fulfilled = (value) => {
4382
4258
  try {
@@ -4397,7 +4273,7 @@ var NgwMap = (function (exports) {
4397
4273
  });
4398
4274
  };
4399
4275
  function createRasterAdapter(_0) {
4400
- return __async$e(this, arguments, function* ({
4276
+ return __async$f(this, arguments, function* ({
4401
4277
  layerOptions,
4402
4278
  webMap,
4403
4279
  connector,
@@ -4453,7 +4329,7 @@ var NgwMap = (function (exports) {
4453
4329
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4454
4330
  }
4455
4331
  getLegend(options) {
4456
- return __async$e(this, null, function* () {
4332
+ return __async$f(this, null, function* () {
4457
4333
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4458
4334
  params: { id: resourceId },
4459
4335
  cache: true
@@ -4473,7 +4349,7 @@ var NgwMap = (function (exports) {
4473
4349
  });
4474
4350
  }
4475
4351
  getIdentificationIds() {
4476
- return __async$e(this, null, function* () {
4352
+ return __async$f(this, null, function* () {
4477
4353
  if (this.item) {
4478
4354
  if (adapter === "MVT") {
4479
4355
  return [this.item.resource.id];
@@ -4514,7 +4390,7 @@ var NgwMap = (function (exports) {
4514
4390
  return a;
4515
4391
  };
4516
4392
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
4517
- var __async$d = (__this, __arguments, generator) => {
4393
+ var __async$e = (__this, __arguments, generator) => {
4518
4394
  return new Promise((resolve, reject) => {
4519
4395
  var fulfilled = (value) => {
4520
4396
  try {
@@ -4550,7 +4426,7 @@ var NgwMap = (function (exports) {
4550
4426
  "tmsclient_layer"
4551
4427
  ];
4552
4428
  function createAdapterFromFirstStyle(_0) {
4553
- return __async$d(this, arguments, function* ({
4429
+ return __async$e(this, arguments, function* ({
4554
4430
  layerOptions,
4555
4431
  webMap,
4556
4432
  connector,
@@ -4569,7 +4445,7 @@ var NgwMap = (function (exports) {
4569
4445
  });
4570
4446
  }
4571
4447
  function createAsyncAdapter(options, webMap, connector) {
4572
- return __async$d(this, null, function* () {
4448
+ return __async$e(this, null, function* () {
4573
4449
  let adapter;
4574
4450
  let item;
4575
4451
  const adapterType = options.adapter;
@@ -4772,7 +4648,7 @@ var NgwMap = (function (exports) {
4772
4648
  };
4773
4649
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4774
4650
  var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4775
- var __async$c = (__this, __arguments, generator) => {
4651
+ var __async$d = (__this, __arguments, generator) => {
4776
4652
  return new Promise((resolve, reject) => {
4777
4653
  var fulfilled = (value) => {
4778
4654
  try {
@@ -4822,7 +4698,7 @@ var NgwMap = (function (exports) {
4822
4698
  }
4823
4699
  }
4824
4700
  static create(webMap, item, options, connector, parent) {
4825
- return __async$c(this, null, function* () {
4701
+ return __async$d(this, null, function* () {
4826
4702
  const ngwWebmapItem = new _NgwWebmapItem(
4827
4703
  webMap,
4828
4704
  item,
@@ -4851,15 +4727,14 @@ var NgwMap = (function (exports) {
4851
4727
  return this.layer;
4852
4728
  }
4853
4729
  getLegend(options) {
4854
- return __async$c(this, null, function* () {
4730
+ return __async$d(this, null, function* () {
4855
4731
  var _a;
4856
4732
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4857
4733
  if (id !== void 0) {
4858
4734
  const connector = this.connector;
4859
4735
  if (connector) {
4860
4736
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4861
- params: { id: this.item.resourceId },
4862
- cache: true
4737
+ params: { id: this.item.resourceId }
4863
4738
  }, options));
4864
4739
  const legend = {
4865
4740
  layerId: id,
@@ -5047,7 +4922,7 @@ var NgwMap = (function (exports) {
5047
4922
  return a;
5048
4923
  };
5049
4924
  var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5050
- var __async$b = (__this, __arguments, generator) => {
4925
+ var __async$c = (__this, __arguments, generator) => {
5051
4926
  return new Promise((resolve, reject) => {
5052
4927
  var fulfilled = (value) => {
5053
4928
  try {
@@ -5068,7 +4943,7 @@ var NgwMap = (function (exports) {
5068
4943
  });
5069
4944
  };
5070
4945
  function createOnFirstShowAdapter(_0) {
5071
- return __async$b(this, arguments, function* ({
4946
+ return __async$c(this, arguments, function* ({
5072
4947
  webMap,
5073
4948
  adapterOptions = {},
5074
4949
  onLayerAdded,
@@ -5094,7 +4969,7 @@ var NgwMap = (function (exports) {
5094
4969
  return this._removed;
5095
4970
  }
5096
4971
  showLayer() {
5097
- return __async$b(this, null, function* () {
4972
+ return __async$c(this, null, function* () {
5098
4973
  this.options.visibility = true;
5099
4974
  if (this.layer.length) {
5100
4975
  for (const x of this.layer) {
@@ -5106,7 +4981,7 @@ var NgwMap = (function (exports) {
5106
4981
  });
5107
4982
  }
5108
4983
  hideLayer() {
5109
- return __async$b(this, null, function* () {
4984
+ return __async$c(this, null, function* () {
5110
4985
  this.options.visibility = false;
5111
4986
  if (this.layer) {
5112
4987
  for (const x of this.layer) {
@@ -5116,7 +4991,7 @@ var NgwMap = (function (exports) {
5116
4991
  });
5117
4992
  }
5118
4993
  loadLayer() {
5119
- return __async$b(this, null, function* () {
4994
+ return __async$c(this, null, function* () {
5120
4995
  if (!this.layer.length && !this._creatingInProgress) {
5121
4996
  this._creatingInProgress = true;
5122
4997
  const Adapter = yield createAdapter(this);
@@ -5150,7 +5025,7 @@ var NgwMap = (function (exports) {
5150
5025
  });
5151
5026
  }
5152
5027
 
5153
- var __async$a = (__this, __arguments, generator) => {
5028
+ var __async$b = (__this, __arguments, generator) => {
5154
5029
  return new Promise((resolve, reject) => {
5155
5030
  var fulfilled = (value) => {
5156
5031
  try {
@@ -5171,7 +5046,7 @@ var NgwMap = (function (exports) {
5171
5046
  });
5172
5047
  };
5173
5048
  function createOnFirstShowNgwAdapter(_0) {
5174
- return __async$a(this, arguments, function* ({
5049
+ return __async$b(this, arguments, function* ({
5175
5050
  webMap,
5176
5051
  connector,
5177
5052
  item,
@@ -5227,7 +5102,7 @@ var NgwMap = (function (exports) {
5227
5102
  };
5228
5103
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5229
5104
  var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5230
- var __async$9 = (__this, __arguments, generator) => {
5105
+ var __async$a = (__this, __arguments, generator) => {
5231
5106
  return new Promise((resolve, reject) => {
5232
5107
  var fulfilled = (value) => {
5233
5108
  try {
@@ -5278,7 +5153,7 @@ var NgwMap = (function (exports) {
5278
5153
  }
5279
5154
  }
5280
5155
  addLayer(options) {
5281
- return __async$9(this, null, function* () {
5156
+ return __async$a(this, null, function* () {
5282
5157
  var _a, _b;
5283
5158
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5284
5159
  this.layer = yield this._getWebMapLayerItem();
@@ -5311,21 +5186,21 @@ var NgwMap = (function (exports) {
5311
5186
  delete this._webmapLayersIds;
5312
5187
  }
5313
5188
  showLayer() {
5314
- return __async$9(this, null, function* () {
5189
+ return __async$a(this, null, function* () {
5315
5190
  if (this.layer && this.layer.properties) {
5316
5191
  return this.layer.properties.property("visibility").set(true);
5317
5192
  }
5318
5193
  });
5319
5194
  }
5320
5195
  hideLayer() {
5321
- return __async$9(this, null, function* () {
5196
+ return __async$a(this, null, function* () {
5322
5197
  if (this.layer && this.layer.properties) {
5323
5198
  return this.layer.properties.property("visibility").set(false);
5324
5199
  }
5325
5200
  });
5326
5201
  }
5327
5202
  setOpacity(val) {
5328
- return __async$9(this, null, function* () {
5203
+ return __async$a(this, null, function* () {
5329
5204
  if (this.layer && this.layer.properties) {
5330
5205
  return this.layer.properties.property("opacity").set(val);
5331
5206
  }
@@ -5350,22 +5225,22 @@ var NgwMap = (function (exports) {
5350
5225
  return webmap.bookmark_resource.id;
5351
5226
  }
5352
5227
  }
5353
- fetchBookmarks() {
5228
+ fetchBookmarks(options) {
5354
5229
  const bookmarkResId = this.getBookmarksResourceId();
5355
5230
  const connector = this.options.connector;
5356
5231
  if (bookmarkResId) {
5357
- return connector.getResourceOrFail(bookmarkResId).then((item) => {
5232
+ return connector.getResourceOrFail(bookmarkResId, options).then((item) => {
5358
5233
  var _a;
5359
5234
  const labelField = (_a = item.feature_layer) == null ? void 0 : _a.fields.find(
5360
5235
  (x) => x.label_field
5361
5236
  );
5362
5237
  const keyname = labelField && labelField.keyname;
5363
- return fetchNgwLayerItems({
5238
+ return fetchNgwLayerItems(__spreadValues$a({
5364
5239
  connector,
5365
5240
  resourceId: bookmarkResId,
5366
5241
  geom: false,
5367
5242
  fields: keyname ? [keyname] : void 0
5368
- }).then((items) => {
5243
+ }, options)).then((items) => {
5369
5244
  const bookmarks = [];
5370
5245
  for (const i of items) {
5371
5246
  const bookmark = new BookmarkItem({
@@ -5384,24 +5259,24 @@ var NgwMap = (function (exports) {
5384
5259
  "Webmap was not loaded correctly, it is impossible to extract bookmarks"
5385
5260
  );
5386
5261
  }
5387
- getLegend() {
5388
- return __async$9(this, null, function* () {
5262
+ getLegend(options) {
5263
+ return __async$a(this, null, function* () {
5389
5264
  const legends = [];
5390
5265
  let deps = this.getDependLayers();
5391
5266
  deps = deps.sort((a, b) => b.id - a.id);
5392
5267
  for (const d of deps) {
5393
- const layerLegend = yield d.getLegend();
5268
+ const layerLegend = yield d.getLegend(options);
5394
5269
  legends.push(...layerLegend);
5395
5270
  }
5396
5271
  return legends;
5397
5272
  });
5398
5273
  }
5399
- getIdentificationIds() {
5400
- return __async$9(this, null, function* () {
5274
+ getIdentificationIds(options) {
5275
+ return __async$a(this, null, function* () {
5401
5276
  const visibleLayers = [];
5402
5277
  let ids = this._webmapLayersIds;
5403
5278
  if (!ids) {
5404
- ids = yield this._getWebMapIds();
5279
+ ids = yield this._getWebMapIds(options);
5405
5280
  this._webmapLayersIds = ids;
5406
5281
  }
5407
5282
  if (ids && ids.length) {
@@ -5423,7 +5298,7 @@ var NgwMap = (function (exports) {
5423
5298
  });
5424
5299
  }
5425
5300
  _getWebMapLayerItem() {
5426
- return __async$9(this, null, function* () {
5301
+ return __async$a(this, null, function* () {
5427
5302
  if (!this.resourceId) {
5428
5303
  return void 0;
5429
5304
  }
@@ -5453,7 +5328,7 @@ var NgwMap = (function (exports) {
5453
5328
  });
5454
5329
  }
5455
5330
  getWebMapConfig(id) {
5456
- return __async$9(this, null, function* () {
5331
+ return __async$a(this, null, function* () {
5457
5332
  const data = yield this.options.connector.getResource(id);
5458
5333
  if (data) {
5459
5334
  this.response = data;
@@ -5547,8 +5422,8 @@ var NgwMap = (function (exports) {
5547
5422
  }
5548
5423
  return item;
5549
5424
  }
5550
- _getWebMapIds() {
5551
- return __async$9(this, null, function* () {
5425
+ _getWebMapIds(options) {
5426
+ return __async$a(this, null, function* () {
5552
5427
  const webMapItem = this.layer;
5553
5428
  if (webMapItem && webMapItem.item.item_type === "root") {
5554
5429
  const layers = webMapItem.tree.getDescendants();
@@ -5557,7 +5432,7 @@ var NgwMap = (function (exports) {
5557
5432
  const item = x.item;
5558
5433
  if (item.item_type === "layer") {
5559
5434
  const id = item.layer_style_id;
5560
- const promise = this.options.connector.getResource(id).then((y) => {
5435
+ const promise = this.options.connector.getResource(id, options).then((y) => {
5561
5436
  if (y) {
5562
5437
  const parentId = Number(y.resource.parent.id);
5563
5438
  item.parentId = parentId;
@@ -5591,7 +5466,7 @@ var NgwMap = (function (exports) {
5591
5466
  return a;
5592
5467
  };
5593
5468
  var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5594
- var __async$8 = (__this, __arguments, generator) => {
5469
+ var __async$9 = (__this, __arguments, generator) => {
5595
5470
  return new Promise((resolve, reject) => {
5596
5471
  var fulfilled = (value) => {
5597
5472
  try {
@@ -5636,7 +5511,7 @@ var NgwMap = (function (exports) {
5636
5511
  classAdapters[cls] = adapter;
5637
5512
  }
5638
5513
  onLoadSync(webMap) {
5639
- return __async$8(this, null, function* () {
5514
+ return __async$9(this, null, function* () {
5640
5515
  if (this.options.resourceId && this.url) {
5641
5516
  const resourceIds = [this.options.resourceId];
5642
5517
  if (resourceIds.length) {
@@ -5719,7 +5594,7 @@ var NgwMap = (function (exports) {
5719
5594
  }
5720
5595
  identify(options = {}) {
5721
5596
  if (this._item) {
5722
- return CancelablePromise.resolve(this._item);
5597
+ return Promise.resolve(this._item);
5723
5598
  }
5724
5599
  return fetchNgwLayerItem(__spreadValues$8({
5725
5600
  connector: this.connector,
@@ -5734,30 +5609,30 @@ var NgwMap = (function (exports) {
5734
5609
  return resp;
5735
5610
  });
5736
5611
  }
5737
- resource() {
5612
+ resource(opt) {
5738
5613
  if (this._resource) {
5739
- return CancelablePromise.resolve(this._resource.feature_layer);
5614
+ return Promise.resolve(this._resource.feature_layer);
5740
5615
  }
5741
- return this.connector.getResource(this.layerId).then((resp) => {
5616
+ return this.connector.getResource(this.layerId, opt).then((resp) => {
5742
5617
  this._resource = resp;
5743
5618
  return this._resource.feature_layer;
5744
5619
  });
5745
5620
  }
5746
- getBounds() {
5621
+ getBounds(opt) {
5747
5622
  if (this._extent) {
5748
- return CancelablePromise.resolve(this._extent);
5623
+ return Promise.resolve(this._extent);
5749
5624
  }
5750
- return fetchNgwLayerItemExtent({
5625
+ return fetchNgwLayerItemExtent(__spreadValues$8({
5751
5626
  connector: this.connector,
5752
5627
  featureId: this.id,
5753
5628
  resourceId: this.layerId
5754
- });
5629
+ }, opt));
5755
5630
  }
5756
- geojson() {
5631
+ geojson(options) {
5757
5632
  if (this._geojson) {
5758
- return CancelablePromise.resolve(this._geojson);
5633
+ return Promise.resolve(this._geojson);
5759
5634
  }
5760
- return this.identify().then((resp) => {
5635
+ return this.identify(options).then((resp) => {
5761
5636
  return resp.toGeojson().then((geojson) => {
5762
5637
  this._geojson = geojson;
5763
5638
  return geojson;
@@ -5766,8 +5641,29 @@ var NgwMap = (function (exports) {
5766
5641
  }
5767
5642
  }
5768
5643
 
5644
+ var __async$8 = (__this, __arguments, generator) => {
5645
+ return new Promise((resolve, reject) => {
5646
+ var fulfilled = (value) => {
5647
+ try {
5648
+ step(generator.next(value));
5649
+ } catch (e) {
5650
+ reject(e);
5651
+ }
5652
+ };
5653
+ var rejected = (value) => {
5654
+ try {
5655
+ step(generator.throw(value));
5656
+ } catch (e) {
5657
+ reject(e);
5658
+ }
5659
+ };
5660
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
5661
+ step((generator = generator.apply(__this, __arguments)).next());
5662
+ });
5663
+ };
5769
5664
  function fetchNgwLayerFeature(options) {
5770
- return fetchNgwLayerItem(options).then((item) => {
5665
+ return __async$8(this, null, function* () {
5666
+ const item = yield fetchNgwLayerItem(options);
5771
5667
  return createGeoJsonFeature(item);
5772
5668
  });
5773
5669
  }
@@ -5852,7 +5748,7 @@ var NgwMap = (function (exports) {
5852
5748
  const withGeom = item.features.find((x) => x.geom);
5853
5749
  if (withGeom && withGeom.geom) {
5854
5750
  const geom = withGeom.geom;
5855
- return CancelablePromise.resolve(
5751
+ return Promise.resolve(
5856
5752
  createGeoJsonFeature(__spreadProps$4(__spreadValues$7({}, withGeom), {
5857
5753
  geom
5858
5754
  }))
@@ -5865,7 +5761,7 @@ var NgwMap = (function (exports) {
5865
5761
  if (params && params.length) {
5866
5762
  return fetchNgwLayerFeature(__spreadValues$7(__spreadProps$4(__spreadValues$7({}, requestOptions), { connector }), params[0]));
5867
5763
  }
5868
- return CancelablePromise.resolve(void 0);
5764
+ return Promise.resolve(void 0);
5869
5765
  }
5870
5766
  function fetchIdentifyItem(options) {
5871
5767
  const { connector, identify } = options;
@@ -5875,7 +5771,7 @@ var NgwMap = (function (exports) {
5875
5771
  connector
5876
5772
  }, options.requestOptions), params[0]));
5877
5773
  }
5878
- return CancelablePromise.resolve(void 0);
5774
+ return Promise.resolve(void 0);
5879
5775
  }
5880
5776
  function featureLayerIdentify(options) {
5881
5777
  const { geom, signal, cache, layers } = options;
@@ -5919,9 +5815,9 @@ var NgwMap = (function (exports) {
5919
5815
  function sendIdentifyRequest(ev, options) {
5920
5816
  deprecatedMapClick(ev);
5921
5817
  const [lng, lat] = ev.lngLat;
5922
- const { geom, radius, signal, cache } = options;
5818
+ const { geom, radius } = options;
5923
5819
  const geom_ = geom != null ? geom : getCirclePolygonCoordinates(lng, lat, radius);
5924
- return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_, signal, cache }));
5820
+ return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_ }));
5925
5821
  }
5926
5822
  function createIdentifyItem(opt) {
5927
5823
  return new IdentifyItem(opt);
@@ -7131,7 +7027,7 @@ var NgwMap = (function (exports) {
7131
7027
  __publicField$3(this, "_mapState", []);
7132
7028
  __publicField$3(this, "_extent");
7133
7029
  __publicField$3(this, "_eventsStatus", {});
7134
- __publicField$3(this, "_coordFromMapClickPromise");
7030
+ __publicField$3(this, "_coordFromMapClickAbort");
7135
7031
  __publicField$3(this, "_mapEvents", {});
7136
7032
  this.mapAdapter = mapOptions.mapAdapter;
7137
7033
  this._starterKits = mapOptions.starterKits || [];
@@ -7446,36 +7342,34 @@ var NgwMap = (function (exports) {
7446
7342
  return { stop };
7447
7343
  }
7448
7344
  stopGetCoordFromMapClick() {
7449
- if (this._coordFromMapClickPromise) {
7450
- this._coordFromMapClickPromise.cancel();
7345
+ if (this._coordFromMapClickAbort) {
7346
+ this._coordFromMapClickAbort();
7347
+ this._coordFromMapClickAbort = void 0;
7451
7348
  }
7452
7349
  }
7453
7350
  getCoordFromMapClick() {
7454
- if (!this._coordFromMapClickPromise) {
7455
- this._coordFromMapClickPromise = new CancelablePromise(
7456
- (resolve, reject, onCancel) => {
7457
- const cursor = this.getCursor() || "grab";
7458
- this._removeEventListeners({ include: ["click"] });
7459
- this.setCursor("crosshair");
7460
- const onCancel_ = () => {
7461
- this.setCursor(cursor);
7462
- this._addEventsListeners({ include: ["click"] });
7463
- this.mapAdapter.emitter.off("click", onMapClick);
7464
- this._coordFromMapClickPromise = void 0;
7465
- };
7466
- const onMapClick = (e) => {
7467
- onCancel_();
7468
- deprecatedMapClick(e);
7469
- resolve(e.lngLat);
7470
- };
7471
- this.mapAdapter.emitter.once("click", onMapClick);
7472
- onCancel(onCancel_);
7473
- }
7474
- );
7351
+ if (!this._coordFromMapClickAbort) {
7352
+ return new Promise((resolve, reject) => {
7353
+ const cursor = this.getCursor() || "grab";
7354
+ this._removeEventListeners({ include: ["click"] });
7355
+ this.setCursor("crosshair");
7356
+ const onCancel_ = () => {
7357
+ this.setCursor(cursor);
7358
+ this._addEventsListeners({ include: ["click"] });
7359
+ this.mapAdapter.emitter.off("click", onMapClick);
7360
+ this._coordFromMapClickAbort = void 0;
7361
+ };
7362
+ const onMapClick = (e) => {
7363
+ onCancel_();
7364
+ deprecatedMapClick(e);
7365
+ resolve(e.lngLat);
7366
+ };
7367
+ this.mapAdapter.emitter.once("click", onMapClick);
7368
+ this._coordFromMapClickAbort = onCancel_;
7369
+ });
7475
7370
  } else {
7476
7371
  return this.getCoordFromMapClick();
7477
7372
  }
7478
- return this._coordFromMapClickPromise;
7479
7373
  }
7480
7374
  _emitStatusEvent(eventName, data) {
7481
7375
  const _eventName = eventName;
@@ -9291,26 +9185,35 @@ var NgwMap = (function (exports) {
9291
9185
  }, options));
9292
9186
  }
9293
9187
  fetchIdentifyItem(identify, requestOptions) {
9188
+ const abortController = new AbortController();
9189
+ const abortSignal = abortController.signal;
9190
+ if (requestOptions == null ? void 0 : requestOptions.signal) {
9191
+ requestOptions.signal.addEventListener("abort", abortController.abort);
9192
+ }
9193
+ requestOptions = requestOptions || {};
9194
+ requestOptions.signal = abortSignal;
9294
9195
  const promise = fetchIdentifyItem({
9295
9196
  identify,
9296
9197
  connector: this.connector,
9297
9198
  requestOptions
9298
9199
  // multiple,
9299
9200
  });
9300
- this._addPromise("identify", promise);
9201
+ this._addPromise("identify", promise, abortController);
9301
9202
  return promise;
9302
9203
  }
9303
9204
  fetchIdentifyGeoJson(identify, multiple = false) {
9205
+ const abortController = new AbortController();
9304
9206
  const promise = fetchIdentifyGeoJson({
9305
9207
  identify,
9306
9208
  connector: this.connector,
9307
- multiple
9209
+ multiple,
9210
+ requestOptions: { signal: abortController.signal }
9308
9211
  });
9309
9212
  if (promise && "then" in promise) {
9310
- this._addPromise("identify", promise);
9213
+ this._addPromise("identify", promise, abortController);
9311
9214
  return promise;
9312
9215
  } else {
9313
- return CancelablePromise.resolve(promise);
9216
+ return Promise.resolve(promise);
9314
9217
  }
9315
9218
  }
9316
9219
  /**
@@ -9484,7 +9387,7 @@ var NgwMap = (function (exports) {
9484
9387
  args.forEach((name) => {
9485
9388
  const group = this._promises[name];
9486
9389
  if (group) {
9487
- group.forEach((x) => x.cancel());
9390
+ group.forEach((x) => x[1].abort());
9488
9391
  this._promises[name] = [];
9489
9392
  }
9490
9393
  });
@@ -9551,11 +9454,13 @@ var NgwMap = (function (exports) {
9551
9454
  }, highlightDuration);
9552
9455
  }
9553
9456
  }
9457
+ const abortController = new AbortController();
9554
9458
  const selectPromise = sendIdentifyRequest(ev, {
9555
9459
  layers: ids,
9556
9460
  connector: this.connector,
9557
9461
  radius,
9558
- geom
9462
+ geom,
9463
+ signal: abortController.signal
9559
9464
  }).then((resp) => {
9560
9465
  const identify = __spreadProps(__spreadValues({}, resp), {
9561
9466
  resources: ids,
@@ -9566,22 +9471,22 @@ var NgwMap = (function (exports) {
9566
9471
  this._emitStatusEvent("ngw:select", identifyEvent);
9567
9472
  return identifyEvent;
9568
9473
  });
9569
- this._addPromise("select", selectPromise);
9474
+ this._addPromise("select", selectPromise, abortController);
9570
9475
  return selectPromise;
9571
9476
  });
9572
9477
  }
9573
- _addPromise(groupName, promise) {
9478
+ _addPromise(groupName, promise, abortController) {
9574
9479
  const group = this._promises[groupName];
9575
- if (group && group.indexOf(promise) === -1) {
9480
+ if (group && group.findIndex((g) => g[0] === promise) === -1) {
9576
9481
  const removeFromGroup = () => {
9577
- const index = group.indexOf(promise);
9482
+ const index = group.findIndex((g) => g[0] === promise);
9578
9483
  if (index !== -1) {
9579
9484
  group.splice(index, 1);
9580
9485
  }
9581
9486
  };
9582
9487
  promise.then(removeFromGroup);
9583
9488
  promise.catch(removeFromGroup);
9584
- group.push(promise);
9489
+ group.push([promise, abortController]);
9585
9490
  }
9586
9491
  }
9587
9492
  _isFitFromResource() {