@nextgis/ngw-map 2.4.0 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 2.4.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.0; author: NextGIS */
2
2
  var domain;
3
3
 
4
4
  // This constructor is used to store event handlers. Instantiating this is
@@ -471,308 +471,6 @@ function unwrapListeners(arr) {
471
471
  return ret;
472
472
  }
473
473
 
474
- var __defProp$N = Object.defineProperty;
475
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
476
- var __publicField$z = (obj, key, value) => __defNormalProp$N(obj, typeof key !== "symbol" ? key + "" : key, value);
477
- class CancelError extends Error {
478
- constructor() {
479
- super();
480
- __publicField$z(this, "name", "CancelError");
481
- Object.setPrototypeOf(this, CancelError.prototype);
482
- }
483
- }
484
-
485
- var __defProp$M = Object.defineProperty;
486
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
487
- var __publicField$y = (obj, key, value) => __defNormalProp$M(obj, typeof key !== "symbol" ? key + "" : key, value);
488
- class PromiseControl {
489
- constructor(options = {}) {
490
- this.options = options;
491
- __publicField$y(this, "_promises", /* @__PURE__ */ new Map());
492
- }
493
- get isLoaded() {
494
- return this._promises.size > 0;
495
- }
496
- remove(promise) {
497
- if (this._promises.has(promise)) {
498
- this._promises.delete(promise);
499
- this._onStop();
500
- }
501
- }
502
- get(promise) {
503
- return this._promises.get(promise);
504
- }
505
- add(promise, name) {
506
- const key = name ? name : promise;
507
- const exist = this._promises.get(key);
508
- if (this.options.onStart && !this.isLoaded) {
509
- this.options.onStart();
510
- }
511
- if (exist) {
512
- return exist;
513
- }
514
- this._promises.set(key, promise);
515
- promise.finally(() => {
516
- this.remove(key);
517
- });
518
- return promise;
519
- }
520
- abort() {
521
- if (this.isLoaded) {
522
- this._promises.forEach((x) => {
523
- if (x.cancel) {
524
- x.cancel();
525
- }
526
- });
527
- this._promises.clear();
528
- this._onStop();
529
- }
530
- }
531
- waitFunc(func, name = "") {
532
- name = name || func.name;
533
- const exist = this.get(name);
534
- if (exist) {
535
- return exist;
536
- }
537
- return this.add(func(), name);
538
- }
539
- WaitForMe(name = "") {
540
- const get = this.get.bind(this);
541
- const add = this.add.bind(this);
542
- return function(target, key, descriptor) {
543
- const originalMethod = descriptor.value;
544
- name = name || key;
545
- descriptor.value = function(...args) {
546
- const exist = get(name);
547
- if (exist) {
548
- return exist;
549
- }
550
- const result = add(originalMethod.apply(this, args), name);
551
- return result;
552
- };
553
- return descriptor;
554
- };
555
- }
556
- /** @deprecated use {@link PromiseControl.WaitForMe } instead */
557
- GetOrCreateDecorator(name = "") {
558
- return this.WaitForMe(name);
559
- }
560
- _onStop() {
561
- if (this.options.onStop && !this.isLoaded) {
562
- this.options.onStop();
563
- }
564
- }
565
- }
566
-
567
- var __defProp$L = Object.defineProperty;
568
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
569
- var __publicField$x = (obj, key, value) => __defNormalProp$L(obj, typeof key !== "symbol" ? key + "" : key, value);
570
- class TimeoutError extends Error {
571
- constructor() {
572
- super();
573
- __publicField$x(this, "name", "TimeoutError");
574
- Object.setPrototypeOf(this, TimeoutError.prototype);
575
- }
576
- }
577
-
578
- var __defProp$K = Object.defineProperty;
579
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
580
- var __publicField$w = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
581
- var _a;
582
- const handleCallback = (resolve, reject, callback, r) => {
583
- try {
584
- resolve(callback(r));
585
- } catch (e) {
586
- reject(e);
587
- }
588
- };
589
- let ID$3 = 0;
590
- _a = Symbol.toStringTag;
591
- const _CancelablePromise = class _CancelablePromise {
592
- constructor(executor, timeout) {
593
- // @ts-ignore
594
- __publicField$w(this, _a);
595
- __publicField$w(this, "id", ID$3++);
596
- __publicField$w(this, "_isCanceled", false);
597
- __publicField$w(this, "_isPending", true);
598
- __publicField$w(this, "_promise");
599
- __publicField$w(this, "_cancelPromise");
600
- __publicField$w(this, "_cancelHandlers", []);
601
- __publicField$w(this, "_setCanceledCallback");
602
- __publicField$w(this, "_parentPromise");
603
- __publicField$w(this, "_children", []);
604
- this._cancelPromise = new Promise((resolve_, reject_) => {
605
- this._setCanceledCallback = (er) => resolve_(er || new CancelError());
606
- });
607
- const promises = [
608
- this._cancelPromise,
609
- new Promise((resolve, reject) => {
610
- const onResolve = (value) => {
611
- if (value instanceof _CancelablePromise) {
612
- this.attach(value);
613
- } else {
614
- this._isPending = false;
615
- }
616
- resolve(value);
617
- };
618
- const onReject = (error) => {
619
- this._isPending = false;
620
- reject(error);
621
- };
622
- const onCancel = (handler) => {
623
- if (!this._isPending) {
624
- throw new Error(
625
- "The `onCancel` handler was attached after the promise settled."
626
- );
627
- }
628
- this._cancelHandlers.push(handler);
629
- };
630
- return executor(onResolve, onReject, onCancel);
631
- })
632
- ];
633
- if (timeout) {
634
- promises.push(
635
- new Promise((resolve, reject) => {
636
- setTimeout(() => {
637
- if (this._isPending) {
638
- try {
639
- this.cancel();
640
- } finally {
641
- reject(new TimeoutError());
642
- }
643
- }
644
- }, timeout);
645
- })
646
- );
647
- }
648
- this._promise = Promise.race(promises);
649
- }
650
- static createControl(opt) {
651
- return new PromiseControl(opt);
652
- }
653
- static resolve(value) {
654
- return new _CancelablePromise((resolve) => resolve(value));
655
- }
656
- static reject(value) {
657
- return new _CancelablePromise((resolve, reject) => reject(value));
658
- }
659
- static all(values) {
660
- return new _CancelablePromise((resolve, reject) => {
661
- Promise.all(values).then(resolve).catch(reject);
662
- }).catch((er) => {
663
- if (er instanceof this.CancelError) {
664
- for (const v of values) {
665
- const v_ = v;
666
- if ("cancel" in v_) {
667
- v_.cancel();
668
- }
669
- }
670
- }
671
- throw er;
672
- });
673
- }
674
- attach(p) {
675
- if (this._isCanceled) {
676
- p.cancel();
677
- } else {
678
- this._children.push(p);
679
- }
680
- }
681
- then(onfulfilled, onrejected) {
682
- const p = new _CancelablePromise((resolve, reject) => {
683
- if (this._promise) {
684
- const reject_ = (r) => {
685
- if (onrejected) {
686
- handleCallback(resolve, reject, onrejected, r);
687
- } else {
688
- reject(r);
689
- }
690
- };
691
- this._promise.then((r) => {
692
- if (this._isCanceled) {
693
- reject_(r);
694
- } else {
695
- if (onfulfilled) {
696
- handleCallback(resolve, reject, onfulfilled, r);
697
- } else {
698
- resolve(r);
699
- }
700
- }
701
- }, reject_);
702
- }
703
- });
704
- p._parentPromise = this;
705
- this._children.push(p);
706
- return p;
707
- }
708
- catch(onrejected) {
709
- if (this._isCanceled && onrejected) {
710
- onrejected(new CancelError());
711
- }
712
- return this.then(void 0, onrejected);
713
- }
714
- finally(onfinally) {
715
- if (this._promise) {
716
- return this._promise.finally(onfinally);
717
- }
718
- if (this._isCanceled) {
719
- return Promise.reject(new CancelError());
720
- }
721
- return Promise.reject(onfinally);
722
- }
723
- cancel() {
724
- if (this._isCanceled || !this._isPending) {
725
- return this;
726
- }
727
- this._isCanceled = true;
728
- const parent = this._getTopParent();
729
- if (parent) {
730
- parent.cancel();
731
- }
732
- if (this._children) {
733
- this._children.forEach((x) => x.cancel());
734
- }
735
- if (this._isPending) {
736
- if (this._cancelHandlers.length) {
737
- try {
738
- for (const handler of this._cancelHandlers) {
739
- handler();
740
- }
741
- } catch (error) {
742
- }
743
- }
744
- if (this._setCanceledCallback) {
745
- this._setCanceledCallback();
746
- }
747
- }
748
- this._destroy();
749
- return this;
750
- }
751
- _getTopParent() {
752
- let parent = this._parentPromise;
753
- let hasParent = !!parent;
754
- while (hasParent) {
755
- if (parent && parent._parentPromise) {
756
- parent = parent._parentPromise;
757
- hasParent = !!parent;
758
- } else {
759
- hasParent = false;
760
- }
761
- }
762
- return parent;
763
- }
764
- _destroy() {
765
- this._setCanceledCallback = void 0;
766
- this._cancelPromise = void 0;
767
- this._promise = void 0;
768
- }
769
- };
770
- __publicField$w(_CancelablePromise, "CancelError", CancelError);
771
- __publicField$w(_CancelablePromise, "TimeoutError", TimeoutError);
772
- __publicField$w(_CancelablePromise, "PromiseControl", PromiseControl);
773
- let CancelablePromise = _CancelablePromise;
774
- Object.setPrototypeOf(CancelablePromise.prototype, Promise.prototype);
775
-
776
474
  const svgPath = {
777
475
  brill: '<path d="m6 0-5 6 5 6 5-6z"/>',
778
476
  circle: '<circle cx="6" cy="6" r="6"/>',
@@ -1111,7 +809,7 @@ function objectRemoveEmpty(obj) {
1111
809
  }
1112
810
 
1113
811
  function round(val, toFixed) {
1114
- const n = toFixed ? Number("1e+" + toFixed) : 1;
812
+ const n = 1;
1115
813
  return Math.round((val + Number.EPSILON) * n) / n;
1116
814
  }
1117
815
 
@@ -1126,9 +824,9 @@ function fixUrlStr(url) {
1126
824
  return url.replace(/([^:]\/)\/+/g, "$1");
1127
825
  }
1128
826
 
1129
- var __defProp$J = Object.defineProperty;
1130
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1131
- var __publicField$v = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
827
+ var __defProp$K = Object.defineProperty;
828
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
829
+ var __publicField$v = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
1132
830
  const _Cache = class _Cache {
1133
831
  constructor(options = {}) {
1134
832
  __publicField$v(this, "cache", []);
@@ -1164,8 +862,7 @@ const _Cache = class _Cache {
1164
862
  * // somewhere else in the code
1165
863
  * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
1166
864
  * console.log(resp); // 'New item'
1167
- * })
1168
- *
865
+ * });
1169
866
  * ```
1170
867
  */
1171
868
  addFull(key, valueToSet, props) {
@@ -1180,13 +877,11 @@ const _Cache = class _Cache {
1180
877
  } else {
1181
878
  value = valueToSet;
1182
879
  }
1183
- const props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
880
+ const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1184
881
  const cacheItem = {
1185
882
  key,
1186
883
  value,
1187
- props: props_,
1188
- // TODO: remove backward compatibility use only props
1189
- options: props_
884
+ props: nonEmptyProps
1190
885
  };
1191
886
  if (onlyFull && !full(value)) {
1192
887
  return value;
@@ -1195,7 +890,6 @@ const _Cache = class _Cache {
1195
890
  if (value instanceof Promise) {
1196
891
  value.catch((er) => {
1197
892
  this.delete(key, props);
1198
- throw er;
1199
893
  });
1200
894
  if (onlyFull) {
1201
895
  value.then((x) => {
@@ -1214,9 +908,7 @@ const _Cache = class _Cache {
1214
908
  }
1215
909
  match(key, props) {
1216
910
  const cacheRecord = this._find(key, props);
1217
- if (cacheRecord) {
1218
- return cacheRecord.value;
1219
- }
911
+ return cacheRecord == null ? void 0 : cacheRecord.value;
1220
912
  }
1221
913
  matchAll(key, props) {
1222
914
  if (key) {
@@ -1225,37 +917,30 @@ const _Cache = class _Cache {
1225
917
  return this.cache.map((x) => x.value);
1226
918
  }
1227
919
  delete(keyOrItem, props) {
1228
- let exist = [];
1229
- if (typeof keyOrItem === "string") {
1230
- exist = this.cache.filter((x) => this._filter(x, keyOrItem, props));
1231
- } else {
1232
- exist.push(keyOrItem);
1233
- }
1234
- for (const e of exist) {
1235
- const index = this.cache.indexOf(e);
1236
- this.cache.splice(index, 1);
920
+ const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
921
+ for (const item of itemsToDelete) {
922
+ const index = this.cache.indexOf(item);
923
+ if (index !== -1) {
924
+ this.cache.splice(index, 1);
925
+ }
1237
926
  }
1238
927
  }
1239
928
  _find(key, props) {
1240
929
  return this.cache.find((x) => this._filter(x, key, props));
1241
930
  }
1242
931
  _filter(item, key, props) {
1243
- if (item.key === key) {
1244
- if (props) {
1245
- const itemProps = item.props || item.options;
1246
- return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1247
- }
1248
- return true;
1249
- }
1250
- return false;
932
+ if (item.key !== key) return false;
933
+ if (!props) return true;
934
+ const itemProps = item.props;
935
+ return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1251
936
  }
1252
937
  };
1253
938
  __publicField$v(_Cache, "instance", {});
1254
939
  let Cache = _Cache;
1255
940
 
1256
- var __defProp$I = Object.defineProperty;
1257
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1258
- var __publicField$u = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
941
+ var __defProp$J = Object.defineProperty;
942
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
943
+ var __publicField$u = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
1259
944
  class NgwError extends Error {
1260
945
  constructor(er) {
1261
946
  super();
@@ -1272,9 +957,9 @@ class NgwError extends Error {
1272
957
  }
1273
958
  }
1274
959
 
1275
- var __defProp$H = Object.defineProperty;
1276
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1277
- var __publicField$t = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
960
+ var __defProp$I = Object.defineProperty;
961
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
962
+ var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
1278
963
  class ResourceNotFoundError extends NgwError {
1279
964
  constructor(obj) {
1280
965
  super(obj);
@@ -1313,27 +998,24 @@ function resourceToQuery(resource, prefix = "") {
1313
998
  return query;
1314
999
  }
1315
1000
 
1316
- var __defProp$G = Object.defineProperty;
1317
- var __defProps$d = Object.defineProperties;
1318
- var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
1319
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1320
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1321
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1322
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1323
- var __spreadValues$t = (a, b) => {
1001
+ var __defProp$H = Object.defineProperty;
1002
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1003
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1004
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1005
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1006
+ var __spreadValues$v = (a, b) => {
1324
1007
  for (var prop in b || (b = {}))
1325
- if (__hasOwnProp$u.call(b, prop))
1326
- __defNormalProp$G(a, prop, b[prop]);
1327
- if (__getOwnPropSymbols$u)
1328
- for (var prop of __getOwnPropSymbols$u(b)) {
1329
- if (__propIsEnum$u.call(b, prop))
1330
- __defNormalProp$G(a, prop, b[prop]);
1008
+ if (__hasOwnProp$w.call(b, prop))
1009
+ __defNormalProp$H(a, prop, b[prop]);
1010
+ if (__getOwnPropSymbols$w)
1011
+ for (var prop of __getOwnPropSymbols$w(b)) {
1012
+ if (__propIsEnum$w.call(b, prop))
1013
+ __defNormalProp$H(a, prop, b[prop]);
1331
1014
  }
1332
1015
  return a;
1333
1016
  };
1334
- var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
1335
- var __publicField$s = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1336
- var __async$l = (__this, __arguments, generator) => {
1017
+ var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1018
+ var __async$s = (__this, __arguments, generator) => {
1337
1019
  return new Promise((resolve, reject) => {
1338
1020
  var fulfilled = (value) => {
1339
1021
  try {
@@ -1374,39 +1056,27 @@ class ResourcesControl {
1374
1056
  * Fetching resource would be cached to speed up next call
1375
1057
  */
1376
1058
  getOne(resource, requestOptions) {
1377
- const cache = this.cache;
1378
- const forCache = {};
1379
- const opt = __spreadProps$d(__spreadValues$t({}, requestOptions), { cache: false });
1380
- if (typeof resource === "string") {
1381
- forCache.keyname = resource;
1382
- } else if (typeof resource === "number") {
1383
- forCache.id = resource;
1384
- } else if (isObject(resource)) {
1059
+ const opt = __spreadValues$v({}, requestOptions);
1060
+ if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1385
1061
  if (resource.id !== void 0) {
1386
- forCache.id = resource.id;
1062
+ resource.id;
1387
1063
  } else {
1388
1064
  if (resource.keyname) {
1389
- forCache.keyname = resource.keyname;
1065
+ resource.keyname;
1390
1066
  }
1391
1067
  if (resource.display_name) {
1392
- forCache.display_name = resource.display_name;
1068
+ resource.display_name;
1393
1069
  }
1394
1070
  }
1395
1071
  }
1396
- const makeRequest = () => {
1397
- if (typeof resource === "string") {
1398
- return this._fetchResourceBy({ keyname: resource }, opt);
1399
- } else if (typeof resource === "number") {
1400
- return this._fetchResourceById(resource, opt);
1401
- } else if (isObject(resource)) {
1402
- return this._fetchResourceBy(resource, opt);
1403
- }
1404
- return CancelablePromise.resolve(void 0);
1405
- };
1406
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1407
- return cache.addFull("resource", makeRequest, forCache);
1072
+ if (typeof resource === "string") {
1073
+ return this._fetchResourceBy({ keyname: resource }, opt);
1074
+ } else if (typeof resource === "number") {
1075
+ return this._fetchResourceById(resource, opt);
1076
+ } else if (isObject(resource)) {
1077
+ return this._fetchResourceBy(resource, opt);
1408
1078
  }
1409
- return makeRequest();
1079
+ return Promise.resolve(void 0);
1410
1080
  }
1411
1081
  getOneOrFail(resource, requestOptions) {
1412
1082
  return this.getOne(resource, requestOptions).then((res) => {
@@ -1428,7 +1098,7 @@ class ResourcesControl {
1428
1098
  */
1429
1099
  getId(resource, requestOptions) {
1430
1100
  if (typeof resource === "number") {
1431
- return CancelablePromise.resolve(resource);
1101
+ return Promise.resolve(resource);
1432
1102
  } else if (typeof resource === "string" || isObject(resource)) {
1433
1103
  return this.getOne(resource, requestOptions).then((res) => {
1434
1104
  if (res) {
@@ -1436,7 +1106,7 @@ class ResourcesControl {
1436
1106
  }
1437
1107
  });
1438
1108
  }
1439
- return CancelablePromise.resolve(void 0);
1109
+ return Promise.resolve(void 0);
1440
1110
  }
1441
1111
  /**
1442
1112
  * A fast way to retrieve resource ID for any resource definition.
@@ -1463,12 +1133,12 @@ class ResourcesControl {
1463
1133
  } else {
1464
1134
  Object.assign(query, resourceToQuery(resource));
1465
1135
  }
1466
- return this.connector.get("resource.search", requestOptions, __spreadValues$t({
1136
+ return this.connector.get("resource.search", requestOptions, __spreadValues$v({
1467
1137
  serialization: "full"
1468
1138
  }, query)).then((resources) => {
1469
- if (resources) {
1139
+ if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
1470
1140
  for (const x of resources) {
1471
- this.cache.add("resource.item", CancelablePromise.resolve(x), {
1141
+ this.cache.add("resource.item", Promise.resolve(x), {
1472
1142
  id: x.resource.id
1473
1143
  });
1474
1144
  }
@@ -1484,7 +1154,7 @@ class ResourcesControl {
1484
1154
  if (child) {
1485
1155
  return this.getOne(child.resource.parent.id, requestOptions);
1486
1156
  }
1487
- return CancelablePromise.resolve(void 0);
1157
+ return Promise.resolve(void 0);
1488
1158
  });
1489
1159
  }
1490
1160
  getChildrenOf(resource, requestOptions) {
@@ -1514,18 +1184,16 @@ class ResourcesControl {
1514
1184
  });
1515
1185
  }
1516
1186
  _getChildrenOf(parent, requestOptions, _items = []) {
1517
- return this.connector.get(
1518
- "resource.collection",
1519
- __spreadValues$t({ cache: true }, requestOptions),
1520
- {
1521
- parent
1522
- }
1523
- ).then((items) => {
1187
+ return this.connector.get("resource.collection", requestOptions, {
1188
+ parent
1189
+ }).then((items) => {
1524
1190
  const recursivePromises = [];
1525
1191
  for (const item of items) {
1526
- this.cache.add("resource.item", CancelablePromise.resolve(item), {
1527
- id: item.resource.id
1528
- });
1192
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
1193
+ this.cache.add("resource.item", Promise.resolve(item), {
1194
+ id: item.resource.id
1195
+ });
1196
+ }
1529
1197
  _items.push(item);
1530
1198
  if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
1531
1199
  recursivePromises.push(
@@ -1534,7 +1202,7 @@ class ResourcesControl {
1534
1202
  }
1535
1203
  }
1536
1204
  if (recursivePromises.length) {
1537
- return CancelablePromise.all(recursivePromises).then(() => {
1205
+ return Promise.all(recursivePromises).then(() => {
1538
1206
  return _items;
1539
1207
  });
1540
1208
  }
@@ -1542,11 +1210,12 @@ class ResourcesControl {
1542
1210
  });
1543
1211
  }
1544
1212
  _cleanResourceItemCache(id) {
1545
- return __async$l(this, null, function* () {
1213
+ return __async$s(this, null, function* () {
1214
+ var _a;
1546
1215
  const all = this.cache.all();
1547
1216
  const toDelete = [];
1548
1217
  for (const c of all) {
1549
- const cid = c.options && c.options.id;
1218
+ const cid = (_a = c.props) == null ? void 0 : _a.id;
1550
1219
  if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
1551
1220
  if (typeof cid === "number") {
1552
1221
  if (cid === id) {
@@ -1566,18 +1235,7 @@ class ResourcesControl {
1566
1235
  });
1567
1236
  }
1568
1237
  _fetchResourceById(id, requestOptions) {
1569
- const promise = () => this.connector.get("resource.item", requestOptions, { id });
1570
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1571
- return this.cache.add("resource.item", promise, {
1572
- id
1573
- }).catch((er) => {
1574
- if (!(er instanceof ResourceNotFoundError)) {
1575
- throw er;
1576
- }
1577
- return void 0;
1578
- });
1579
- }
1580
- return promise();
1238
+ return this.connector.get("resource.item", requestOptions, { id });
1581
1239
  }
1582
1240
  _fetchResourceBy(resource, requestOptions) {
1583
1241
  return this.getMany(resource, requestOptions).then((resources) => {
@@ -1585,7 +1243,7 @@ class ResourcesControl {
1585
1243
  });
1586
1244
  }
1587
1245
  _resourceCacheFilter(resource) {
1588
- return CancelablePromise.all(this.cache.matchAll("resource.item")).then(
1246
+ return Promise.all(this.cache.matchAll("resource.item")).then(
1589
1247
  (resources) => {
1590
1248
  const items = [];
1591
1249
  resources.filter((x) => {
@@ -1629,9 +1287,16 @@ function removeConnector(connector) {
1629
1287
  }
1630
1288
  }
1631
1289
 
1632
- var __defProp$F = Object.defineProperty;
1633
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1634
- var __publicField$r = (obj, key, value) => __defNormalProp$F(obj, typeof key !== "symbol" ? key + "" : key, value);
1290
+ class AbortError extends Error {
1291
+ constructor(message = "AbortError") {
1292
+ super(message);
1293
+ this.name = "AbortError";
1294
+ }
1295
+ }
1296
+
1297
+ var __defProp$G = Object.defineProperty;
1298
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1299
+ var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1635
1300
  class InsufficientPermissionsError extends NgwError {
1636
1301
  constructor(obj) {
1637
1302
  super(obj);
@@ -1654,64 +1319,96 @@ function template(str, data) {
1654
1319
  });
1655
1320
  }
1656
1321
 
1322
+ var __defProp$F = Object.defineProperty;
1323
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1324
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1325
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1326
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1327
+ var __spreadValues$u = (a, b) => {
1328
+ for (var prop in b || (b = {}))
1329
+ if (__hasOwnProp$v.call(b, prop))
1330
+ __defNormalProp$F(a, prop, b[prop]);
1331
+ if (__getOwnPropSymbols$v)
1332
+ for (var prop of __getOwnPropSymbols$v(b)) {
1333
+ if (__propIsEnum$v.call(b, prop))
1334
+ __defNormalProp$F(a, prop, b[prop]);
1335
+ }
1336
+ return a;
1337
+ };
1338
+ var __async$r = (__this, __arguments, generator) => {
1339
+ return new Promise((resolve, reject) => {
1340
+ var fulfilled = (value) => {
1341
+ try {
1342
+ step(generator.next(value));
1343
+ } catch (e) {
1344
+ reject(e);
1345
+ }
1346
+ };
1347
+ var rejected = (value) => {
1348
+ try {
1349
+ step(generator.throw(value));
1350
+ } catch (e) {
1351
+ reject(e);
1352
+ }
1353
+ };
1354
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1355
+ step((generator = generator.apply(__this, __arguments)).next());
1356
+ });
1357
+ };
1657
1358
  function apiRequest(opt) {
1658
- const params = opt.params;
1659
- return new CancelablePromise((resolve, reject) => {
1660
- return opt.connector.connect().then((apiItems) => {
1661
- let apiItem = apiItems && apiItems[opt.name];
1662
- if (apiItem) {
1663
- apiItem = [...apiItem];
1664
- let url = apiItem.shift();
1665
- if (apiItem.length) {
1666
- const replaceParams = {};
1667
- for (let fry = 0; fry < apiItem.length; fry++) {
1668
- const arg = apiItem[fry];
1669
- replaceParams[fry] = "{" + arg + "}";
1670
- if (params[arg] === void 0) {
1671
- throw new Error(
1672
- "`" + arg + "` url api argument is not specified"
1673
- );
1674
- }
1675
- }
1676
- if (url) {
1677
- url = template(url, replaceParams);
1359
+ return __async$r(this, null, function* () {
1360
+ const { params, name, connector, requestOptions } = opt;
1361
+ const apiItems = yield connector.connect();
1362
+ let apiItem = apiItems && apiItems[name];
1363
+ if (apiItem) {
1364
+ apiItem = [...apiItem];
1365
+ let url = apiItem.shift();
1366
+ if (apiItem.length) {
1367
+ const replaceParams = {};
1368
+ for (let fry = 0; fry < apiItem.length; fry++) {
1369
+ const arg = apiItem[fry];
1370
+ replaceParams[fry] = `{${arg}}`;
1371
+ if (params[arg] === void 0) {
1372
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
1678
1373
  }
1679
1374
  }
1680
- if (params) {
1681
- const paramArray = [];
1682
- const paramList = params.paramList;
1683
- if (Array.isArray(paramList)) {
1684
- delete params.paramList;
1685
- paramList.forEach((x) => {
1686
- paramArray.push(`${x[0]}=${x[1]}`);
1687
- });
1688
- }
1689
- for (const p in params) {
1690
- if (apiItem.indexOf(p) === -1) {
1691
- paramArray.push(`${p}=${params[p]}`);
1692
- }
1693
- }
1694
- if (paramArray.length) {
1695
- url = url + "?" + paramArray.join("&");
1375
+ if (url) {
1376
+ url = template(url, replaceParams);
1377
+ }
1378
+ }
1379
+ if (params) {
1380
+ const paramArray = [];
1381
+ const paramList = params.paramList;
1382
+ if (Array.isArray(paramList)) {
1383
+ paramList.forEach(([key, value]) => {
1384
+ paramArray.push(`${key}=${value}`);
1385
+ });
1386
+ }
1387
+ for (const p in params) {
1388
+ if (apiItem.indexOf(p) === -1) {
1389
+ paramArray.push(`${p}=${params[p]}`);
1696
1390
  }
1697
1391
  }
1698
- if (url) {
1699
- resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1700
- } else {
1701
- reject(new Error("request url is not set"));
1392
+ if (paramArray.length) {
1393
+ url = `${url}?${paramArray.join("&")}`;
1702
1394
  }
1395
+ }
1396
+ if (url) {
1397
+ return connector.makeQuery(url, params, __spreadValues$u({
1398
+ cacheName: name
1399
+ }, requestOptions));
1703
1400
  } else {
1704
- resolve(void 0);
1401
+ throw new Error("Request URL is not set");
1705
1402
  }
1706
- }).catch((er) => {
1707
- reject(er);
1708
- });
1403
+ } else {
1404
+ return void 0;
1405
+ }
1709
1406
  });
1710
1407
  }
1711
1408
 
1712
1409
  var __defProp$E = Object.defineProperty;
1713
1410
  var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1714
- var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, typeof key !== "symbol" ? key + "" : key, value);
1411
+ var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
1715
1412
  class NetworkError extends Error {
1716
1413
  constructor(url) {
1717
1414
  super();
@@ -1805,23 +1502,59 @@ let loadData;
1805
1502
  }
1806
1503
 
1807
1504
  var __defProp$D = Object.defineProperty;
1808
- var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
1809
- var __hasOwnProp$t = Object.prototype.hasOwnProperty;
1810
- var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
1505
+ var __defProps$d = Object.defineProperties;
1506
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
1507
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1508
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1509
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1811
1510
  var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1812
- var __spreadValues$s = (a, b) => {
1511
+ var __spreadValues$t = (a, b) => {
1813
1512
  for (var prop in b || (b = {}))
1814
- if (__hasOwnProp$t.call(b, prop))
1513
+ if (__hasOwnProp$u.call(b, prop))
1815
1514
  __defNormalProp$D(a, prop, b[prop]);
1816
- if (__getOwnPropSymbols$t)
1817
- for (var prop of __getOwnPropSymbols$t(b)) {
1818
- if (__propIsEnum$t.call(b, prop))
1515
+ if (__getOwnPropSymbols$u)
1516
+ for (var prop of __getOwnPropSymbols$u(b)) {
1517
+ if (__propIsEnum$u.call(b, prop))
1819
1518
  __defNormalProp$D(a, prop, b[prop]);
1820
1519
  }
1821
1520
  return a;
1822
1521
  };
1522
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
1523
+ var __objRest$2 = (source, exclude) => {
1524
+ var target = {};
1525
+ for (var prop in source)
1526
+ if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
1527
+ target[prop] = source[prop];
1528
+ if (source != null && __getOwnPropSymbols$u)
1529
+ for (var prop of __getOwnPropSymbols$u(source)) {
1530
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
1531
+ target[prop] = source[prop];
1532
+ }
1533
+ return target;
1534
+ };
1823
1535
  var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
1536
+ var __async$q = (__this, __arguments, generator) => {
1537
+ return new Promise((resolve, reject) => {
1538
+ var fulfilled = (value) => {
1539
+ try {
1540
+ step(generator.next(value));
1541
+ } catch (e) {
1542
+ reject(e);
1543
+ }
1544
+ };
1545
+ var rejected = (value) => {
1546
+ try {
1547
+ step(generator.throw(value));
1548
+ } catch (e) {
1549
+ reject(e);
1550
+ }
1551
+ };
1552
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1553
+ step((generator = generator.apply(__this, __arguments)).next());
1554
+ });
1555
+ };
1824
1556
  let ID$2 = 0;
1557
+ let REQUEST_ID = 0;
1825
1558
  class NgwConnector {
1826
1559
  constructor(options) {
1827
1560
  this.options = options;
@@ -1831,7 +1564,7 @@ class NgwConnector {
1831
1564
  __publicField$p(this, "resources");
1832
1565
  __publicField$p(this, "cache");
1833
1566
  __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1834
- __publicField$p(this, "activeRequests", []);
1567
+ __publicField$p(this, "activeRequests", {});
1835
1568
  __publicField$p(this, "requestTransform");
1836
1569
  const exist = findConnector(options);
1837
1570
  this.cache = new Cache({ namespace: options.cacheId });
@@ -1888,29 +1621,27 @@ class NgwConnector {
1888
1621
  * ```
1889
1622
  */
1890
1623
  connect() {
1891
- const auth = this.options.auth;
1892
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1893
- const makeQuery = () => {
1894
- return this.makeQuery(this.routeStr, {}, {}).then((route) => {
1895
- resolve(route);
1896
- }).catch((er) => {
1897
- reject(er);
1898
- });
1899
- };
1624
+ return __async$q(this, null, function* () {
1625
+ const auth = this.options.auth;
1900
1626
  if (auth) {
1901
1627
  const { login, password } = auth;
1902
1628
  if (login && password) {
1903
- return this._login({ login, password }).then(() => {
1904
- return makeQuery();
1905
- }).catch((er) => reject(er));
1629
+ yield this._login({ login, password });
1906
1630
  }
1907
1631
  }
1908
- return makeQuery();
1909
- });
1910
- return this.cache.add("route", makeConnect, {
1911
- id: this.id,
1912
- auth,
1913
- baseUrl: this.options.baseUrl
1632
+ return yield this.makeQuery(
1633
+ this.routeStr,
1634
+ {},
1635
+ {
1636
+ cacheName: "route",
1637
+ cache: true,
1638
+ cacheProps: {
1639
+ id: this.id,
1640
+ auth,
1641
+ baseUrl: this.options.baseUrl
1642
+ }
1643
+ }
1644
+ );
1914
1645
  });
1915
1646
  }
1916
1647
  /**
@@ -1934,20 +1665,22 @@ class NgwConnector {
1934
1665
  this.emitter.emit("logout");
1935
1666
  }
1936
1667
  getUserInfo(credentials, options) {
1937
- if (this.user && this.user.id) {
1938
- return CancelablePromise.resolve(this.user);
1939
- }
1940
- if (credentials) {
1941
- this.options.auth = credentials;
1942
- }
1943
- const options_ = __spreadValues$s({
1944
- headers: this.getAuthorizationHeaders(credentials)
1945
- }, options);
1946
- return this.makeQuery(
1947
- "/api/component/auth/current_user",
1948
- {},
1949
- options_
1950
- );
1668
+ return __async$q(this, null, function* () {
1669
+ if (this.user && this.user.id) {
1670
+ return this.user;
1671
+ }
1672
+ if (credentials) {
1673
+ this.options.auth = credentials;
1674
+ }
1675
+ const options_ = __spreadValues$t({
1676
+ headers: this.getAuthorizationHeaders(credentials)
1677
+ }, options);
1678
+ return this.makeQuery(
1679
+ "/api/component/auth/current_user",
1680
+ {},
1681
+ options_
1682
+ );
1683
+ });
1951
1684
  }
1952
1685
  /**
1953
1686
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -1956,7 +1689,7 @@ class NgwConnector {
1956
1689
  const client = this.makeClientId(credentials);
1957
1690
  if (client) {
1958
1691
  return {
1959
- Authorization: "Basic " + client
1692
+ Authorization: `Basic ${client}`
1960
1693
  };
1961
1694
  }
1962
1695
  }
@@ -1964,21 +1697,22 @@ class NgwConnector {
1964
1697
  credentials = credentials || this.options.auth;
1965
1698
  if (credentials) {
1966
1699
  const { login, password } = credentials;
1967
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1700
+ const str = `${login}:${password}`;
1701
+ const encodedStr = encodeURIComponent(str);
1968
1702
  {
1969
- return window.btoa(str);
1703
+ return window.btoa(encodedStr);
1970
1704
  }
1971
1705
  }
1972
1706
  }
1973
1707
  /** Stop all api requests */
1974
1708
  abort() {
1975
- for (const req of this.activeRequests) {
1976
- req.cancel();
1709
+ for (const abortController of Object.values(this.activeRequests)) {
1710
+ abortController.abort();
1977
1711
  }
1978
- this.activeRequests = [];
1712
+ this.activeRequests = {};
1979
1713
  }
1980
1714
  getActiveApiRequests() {
1981
- return [...this.activeRequests];
1715
+ return __spreadValues$t({}, this.activeRequests);
1982
1716
  }
1983
1717
  /**
1984
1718
  * Send request to NGW api router.
@@ -2010,23 +1744,10 @@ class NgwConnector {
2010
1744
  * ```
2011
1745
  */
2012
1746
  apiRequest(name, params_ = {}, requestOptions = {}) {
2013
- var _a, _b;
2014
- const { method, headers, withCredentials, responseType } = requestOptions;
1747
+ var _a;
2015
1748
  params_ = (_a = requestOptions.params) != null ? _a : params_;
2016
1749
  const params = objectRemoveEmpty(params_);
2017
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
2018
- if (requestOptions.cache && method === "GET") {
2019
- return this.cache.add(name, makeApiRequest, __spreadValues$s({
2020
- params
2021
- }, objectRemoveEmpty({
2022
- headers,
2023
- withCredentials,
2024
- responseType,
2025
- baseUrl: this.options.baseUrl,
2026
- userId: (_b = this.user) == null ? void 0 : _b.id
2027
- })));
2028
- }
2029
- return makeApiRequest();
1750
+ return apiRequest({ name, params, requestOptions, connector: this });
2030
1751
  }
2031
1752
  /**
2032
1753
  * Shortcut method for send POST request to NGW.
@@ -2116,17 +1837,67 @@ class NgwConnector {
2116
1837
  * @param params - Query params
2117
1838
  * @param options - Request options
2118
1839
  */
2119
- makeQuery(url, params, options = {}) {
2120
- url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
2121
- if (url) {
1840
+ makeQuery(_0, _1) {
1841
+ return __async$q(this, arguments, function* (url, params, options = {}) {
1842
+ var _b;
1843
+ url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1844
+ if (!url) {
1845
+ throw new Error("Empty `url` not allowed");
1846
+ }
2122
1847
  if (params) {
2123
- url = template(url, params);
1848
+ const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1849
+ url = template(url, restParams);
1850
+ }
1851
+ url = encodeURI(fixUrlStr(url));
1852
+ const {
1853
+ cache,
1854
+ signal: externalSignal,
1855
+ method = "GET",
1856
+ headers,
1857
+ cacheName,
1858
+ cacheProps,
1859
+ responseType,
1860
+ withCredentials
1861
+ } = options;
1862
+ const internalAbortController = new AbortController();
1863
+ const internalSignal = internalAbortController.signal;
1864
+ if (externalSignal) {
1865
+ if (externalSignal.aborted) {
1866
+ throw new AbortError();
1867
+ }
1868
+ externalSignal.addEventListener("abort", () => {
1869
+ internalAbortController.abort();
1870
+ });
1871
+ }
1872
+ options.signal = internalSignal;
1873
+ const createPromise = () => __async$q(this, null, function* () {
1874
+ const id = REQUEST_ID++;
1875
+ this.activeRequests[id] = internalAbortController;
1876
+ try {
1877
+ return this._loadData(url, options);
1878
+ } finally {
1879
+ this._cleanActiveRequest(id);
1880
+ }
1881
+ });
1882
+ if (cache && method === "GET") {
1883
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$d(__spreadValues$t({}, objectRemoveEmpty({
1884
+ headers,
1885
+ withCredentials,
1886
+ responseType,
1887
+ baseUrl: this.options.baseUrl,
1888
+ userId: (_b = this.user) == null ? void 0 : _b.id
1889
+ })), {
1890
+ params
1891
+ });
1892
+ return this.cache.add(
1893
+ cacheName || url,
1894
+ createPromise,
1895
+ cacheOptions,
1896
+ false
1897
+ );
2124
1898
  }
2125
- url = encodeURI(fixUrlStr(url));
2126
- return this._loadData(url, options);
2127
- } else {
2128
- throw new Error("Empty `url` not allowed");
2129
- }
1899
+ return createPromise();
1900
+ });
2130
1901
  }
2131
1902
  // -------------------------------------------------------------------------
2132
1903
  // Resource Methods
@@ -2208,26 +1979,29 @@ class NgwConnector {
2208
1979
  */
2209
1980
  _loadData(url, options) {
2210
1981
  options.responseType = options.responseType || "json";
2211
- if (options.signal && options.signal.aborted) {
2212
- return CancelablePromise.reject(new CancelablePromise.CancelError());
2213
- }
2214
- const request = new CancelablePromise((resolve, reject, onCancel) => {
1982
+ return new Promise((resolve, reject) => {
1983
+ var _a;
2215
1984
  if (this.user) {
2216
1985
  options = options || {};
2217
- options.headers = __spreadValues$s(__spreadValues$s({}, this.getAuthorizationHeaders()), options.headers);
1986
+ options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
2218
1987
  }
2219
1988
  if (this.requestTransform) {
2220
1989
  const [transUrl, transOptions] = this.requestTransform(url, options);
2221
1990
  url = transUrl;
2222
1991
  options = transOptions;
2223
1992
  }
2224
- loadData(url, resolve, options, reject, onCancel);
2225
- }).then((resp) => {
2226
- this._cleanActiveRequests(request);
2227
- return resp;
1993
+ let runOnAbort = void 0;
1994
+ loadData(url, resolve, options, reject, (handler) => {
1995
+ runOnAbort = handler;
1996
+ });
1997
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
1998
+ if (runOnAbort !== void 0) {
1999
+ runOnAbort();
2000
+ }
2001
+ reject(new AbortError());
2002
+ });
2228
2003
  }).catch((httpError) => {
2229
- this._cleanActiveRequests(request);
2230
- if (httpError instanceof CancelablePromise.CancelError) ; else {
2004
+ if (httpError.name !== "AbortError") {
2231
2005
  {
2232
2006
  console.warn("DEV WARN", httpError);
2233
2007
  }
@@ -2236,31 +2010,24 @@ class NgwConnector {
2236
2010
  throw er;
2237
2011
  }
2238
2012
  }
2013
+ throw httpError;
2239
2014
  });
2240
- if (options.signal && typeof options.signal.addEventListener === "function") {
2241
- options.signal.addEventListener("abort", () => {
2242
- request.cancel();
2243
- this._cleanActiveRequests(request);
2244
- });
2245
- }
2246
- this.activeRequests.push(request);
2247
- return request;
2248
2015
  }
2249
2016
  _login(credentials, options) {
2250
- return this.getUserInfo(credentials, options).then((data) => {
2251
- this.user = data;
2252
- this.emitter.emit("login", data);
2253
- return data;
2254
- }).catch((er) => {
2255
- this.emitter.emit("login:error", er);
2256
- throw er;
2017
+ return __async$q(this, null, function* () {
2018
+ try {
2019
+ const data = yield this.getUserInfo(credentials, options);
2020
+ this.user = data;
2021
+ this.emitter.emit("login", data);
2022
+ return data;
2023
+ } catch (er) {
2024
+ this.emitter.emit("login:error", er);
2025
+ throw er;
2026
+ }
2257
2027
  });
2258
2028
  }
2259
- _cleanActiveRequests(request) {
2260
- const activeRequestIndex = this.activeRequests.indexOf(request);
2261
- if (activeRequestIndex !== -1) {
2262
- this.activeRequests.splice(activeRequestIndex, 1);
2263
- }
2029
+ _cleanActiveRequest(requestId) {
2030
+ delete this.activeRequests[requestId];
2264
2031
  }
2265
2032
  _handleHttpError(er) {
2266
2033
  if (er) {
@@ -2281,17 +2048,17 @@ __publicField$p(NgwConnector, "errors", {
2281
2048
  });
2282
2049
 
2283
2050
  var __defProp$C = Object.defineProperty;
2284
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2285
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2286
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2051
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2052
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2053
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2287
2054
  var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2288
- var __spreadValues$r = (a, b) => {
2055
+ var __spreadValues$s = (a, b) => {
2289
2056
  for (var prop in b || (b = {}))
2290
- if (__hasOwnProp$s.call(b, prop))
2057
+ if (__hasOwnProp$t.call(b, prop))
2291
2058
  __defNormalProp$C(a, prop, b[prop]);
2292
- if (__getOwnPropSymbols$s)
2293
- for (var prop of __getOwnPropSymbols$s(b)) {
2294
- if (__propIsEnum$s.call(b, prop))
2059
+ if (__getOwnPropSymbols$t)
2060
+ for (var prop of __getOwnPropSymbols$t(b)) {
2061
+ if (__propIsEnum$t.call(b, prop))
2295
2062
  __defNormalProp$C(a, prop, b[prop]);
2296
2063
  }
2297
2064
  return a;
@@ -2339,7 +2106,7 @@ function isPropertyFilter(filter) {
2339
2106
  return false;
2340
2107
  }
2341
2108
  function featureFilter(feature, filters) {
2342
- const properties = __spreadValues$r({}, feature.properties);
2109
+ const properties = __spreadValues$s({}, feature.properties);
2343
2110
  if (properties) {
2344
2111
  properties.$id = feature.id;
2345
2112
  return propertiesFilter(properties, filters);
@@ -2377,22 +2144,42 @@ function propertiesFilter(properties, filters) {
2377
2144
  var __defProp$B = Object.defineProperty;
2378
2145
  var __defProps$c = Object.defineProperties;
2379
2146
  var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
2380
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2381
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2382
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2147
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2148
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2149
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2383
2150
  var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2384
- var __spreadValues$q = (a, b) => {
2151
+ var __spreadValues$r = (a, b) => {
2385
2152
  for (var prop in b || (b = {}))
2386
- if (__hasOwnProp$r.call(b, prop))
2153
+ if (__hasOwnProp$s.call(b, prop))
2387
2154
  __defNormalProp$B(a, prop, b[prop]);
2388
- if (__getOwnPropSymbols$r)
2389
- for (var prop of __getOwnPropSymbols$r(b)) {
2390
- if (__propIsEnum$r.call(b, prop))
2155
+ if (__getOwnPropSymbols$s)
2156
+ for (var prop of __getOwnPropSymbols$s(b)) {
2157
+ if (__propIsEnum$s.call(b, prop))
2391
2158
  __defNormalProp$B(a, prop, b[prop]);
2392
2159
  }
2393
2160
  return a;
2394
2161
  };
2395
2162
  var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
2163
+ var __async$p = (__this, __arguments, generator) => {
2164
+ return new Promise((resolve, reject) => {
2165
+ var fulfilled = (value) => {
2166
+ try {
2167
+ step(generator.next(value));
2168
+ } catch (e) {
2169
+ reject(e);
2170
+ }
2171
+ };
2172
+ var rejected = (value) => {
2173
+ try {
2174
+ step(generator.throw(value));
2175
+ } catch (e) {
2176
+ reject(e);
2177
+ }
2178
+ };
2179
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2180
+ step((generator = generator.apply(__this, __arguments)).next());
2181
+ });
2182
+ };
2396
2183
  const FEATURE_REQUEST_PARAMS = {
2397
2184
  srs: 4326,
2398
2185
  geom_format: "geojson"
@@ -2433,10 +2220,9 @@ function updateItemRequestParam(params, options) {
2433
2220
  }
2434
2221
  }
2435
2222
  function createFeatureFieldFilterQueries(opt) {
2436
- const queries = getQueries(
2437
- opt
2438
- );
2439
- return CancelablePromise.all(queries).then((itemsParts) => {
2223
+ return __async$p(this, null, function* () {
2224
+ const queries = getQueries(opt);
2225
+ const itemsParts = yield Promise.all(queries);
2440
2226
  const ids = [];
2441
2227
  const items = [];
2442
2228
  for (const part of itemsParts) {
@@ -2469,20 +2255,22 @@ function createParam(pf) {
2469
2255
  return [`${isFldStr}${field_}__${operation}`, v];
2470
2256
  }
2471
2257
  function getQueries(opt, _queries = [], _parentAllParams = []) {
2258
+ var _a;
2472
2259
  const { filters } = opt;
2260
+ const paramList = (_a = opt.paramList) != null ? _a : [];
2473
2261
  const logic = typeof filters[0] === "string" ? filters[0] : "all";
2474
2262
  const filters_ = filters.filter((x) => Array.isArray(x));
2475
2263
  if (logic === "any") {
2476
2264
  for (const f of filters_) {
2477
2265
  if (isPropertyFilter(f)) {
2478
2266
  _queries.push(
2479
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2480
- paramList: [..._parentAllParams, createParam(f)]
2267
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2268
+ paramList: [..._parentAllParams, ...paramList, createParam(f)]
2481
2269
  }))
2482
2270
  );
2483
2271
  } else {
2484
2272
  getQueries(
2485
- __spreadProps$c(__spreadValues$q({}, opt), {
2273
+ __spreadProps$c(__spreadValues$r({}, opt), {
2486
2274
  filters: f
2487
2275
  }),
2488
2276
  _queries,
@@ -2503,7 +2291,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2503
2291
  if (propertiesFilterList.length) {
2504
2292
  for (const x of propertiesFilterList) {
2505
2293
  getQueries(
2506
- __spreadProps$c(__spreadValues$q({}, opt), {
2294
+ __spreadProps$c(__spreadValues$r({}, opt), {
2507
2295
  filters: x
2508
2296
  }),
2509
2297
  _queries,
@@ -2512,8 +2300,8 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2512
2300
  }
2513
2301
  } else {
2514
2302
  _queries.push(
2515
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2516
- paramList: [..._parentAllParams, ...filters2]
2303
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2304
+ paramList: [..._parentAllParams, ...paramList, ...filters2]
2517
2305
  }))
2518
2306
  );
2519
2307
  }
@@ -2528,7 +2316,7 @@ function createWktFromCoordArray(coord) {
2528
2316
  return `POLYGON((${polygon.join(", ")}))`;
2529
2317
  }
2530
2318
  function fetchNgwLayerItemsRequest(options) {
2531
- const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2319
+ const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2532
2320
  const {
2533
2321
  limit,
2534
2322
  cache,
@@ -2567,7 +2355,7 @@ function fetchNgwLayerItemsRequest(options) {
2567
2355
  if (paramList) {
2568
2356
  params.paramList = paramList;
2569
2357
  }
2570
- const reqParams = __spreadValues$q({
2358
+ const reqParams = __spreadValues$r({
2571
2359
  id: resourceId
2572
2360
  }, params);
2573
2361
  return connector.get(
@@ -2580,52 +2368,90 @@ function fetchNgwLayerItemsRequest(options) {
2580
2368
  var __defProp$A = Object.defineProperty;
2581
2369
  var __defProps$b = Object.defineProperties;
2582
2370
  var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2583
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2584
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2585
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2371
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2372
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2373
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2586
2374
  var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2587
- var __spreadValues$p = (a, b) => {
2375
+ var __spreadValues$q = (a, b) => {
2588
2376
  for (var prop in b || (b = {}))
2589
- if (__hasOwnProp$q.call(b, prop))
2377
+ if (__hasOwnProp$r.call(b, prop))
2590
2378
  __defNormalProp$A(a, prop, b[prop]);
2591
- if (__getOwnPropSymbols$q)
2592
- for (var prop of __getOwnPropSymbols$q(b)) {
2593
- if (__propIsEnum$q.call(b, prop))
2379
+ if (__getOwnPropSymbols$r)
2380
+ for (var prop of __getOwnPropSymbols$r(b)) {
2381
+ if (__propIsEnum$r.call(b, prop))
2594
2382
  __defNormalProp$A(a, prop, b[prop]);
2595
2383
  }
2596
2384
  return a;
2597
2385
  };
2598
2386
  var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
2387
+ var __async$o = (__this, __arguments, generator) => {
2388
+ return new Promise((resolve, reject) => {
2389
+ var fulfilled = (value) => {
2390
+ try {
2391
+ step(generator.next(value));
2392
+ } catch (e) {
2393
+ reject(e);
2394
+ }
2395
+ };
2396
+ var rejected = (value) => {
2397
+ try {
2398
+ step(generator.throw(value));
2399
+ } catch (e) {
2400
+ reject(e);
2401
+ }
2402
+ };
2403
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2404
+ step((generator = generator.apply(__this, __arguments)).next());
2405
+ });
2406
+ };
2599
2407
  function fetchNgwLayerItem(options) {
2600
- const params = __spreadValues$p({}, FEATURE_REQUEST_PARAMS);
2601
- updateItemRequestParam(params, options);
2602
- const queryParams = __spreadValues$p({
2603
- id: options.resourceId,
2604
- fid: options.featureId
2605
- }, params);
2606
- const cache = options.cache || true;
2607
- return options.connector.get("feature_layer.feature.item", { cache }, queryParams).then((resp) => {
2608
- return __spreadProps$b(__spreadValues$p({}, resp), {
2609
- toGeojson: () => {
2610
- if (resp.geom) {
2611
- return CancelablePromise.resolve(createGeoJsonFeature(resp));
2612
- } else {
2613
- return fetchNgwLayerItem(__spreadProps$b(__spreadValues$p({}, options), {
2614
- geom: true,
2615
- fields: null,
2616
- extensions: null
2617
- })).then((onlyGeomItem) => {
2618
- const geom = onlyGeomItem.geom;
2619
- return createGeoJsonFeature(__spreadProps$b(__spreadValues$p({}, resp), { geom }));
2620
- });
2621
- }
2408
+ return __async$o(this, null, function* () {
2409
+ const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2410
+ updateItemRequestParam(params, options);
2411
+ const queryParams = __spreadValues$q({
2412
+ id: options.resourceId,
2413
+ fid: options.featureId
2414
+ }, params);
2415
+ const resp = yield options.connector.get(
2416
+ "feature_layer.feature.item",
2417
+ options,
2418
+ queryParams
2419
+ );
2420
+ const toGeojson = () => __async$o(this, null, function* () {
2421
+ if (resp.geom) {
2422
+ return createGeoJsonFeature(resp);
2423
+ } else {
2424
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$b(__spreadValues$q({}, options), {
2425
+ geom: true,
2426
+ fields: null,
2427
+ extensions: null
2428
+ }));
2429
+ const geom = onlyGeomItem.geom;
2430
+ return createGeoJsonFeature(__spreadProps$b(__spreadValues$q({}, resp), { geom }));
2622
2431
  }
2623
2432
  });
2433
+ return __spreadProps$b(__spreadValues$q({}, resp), {
2434
+ toGeojson
2435
+ });
2624
2436
  });
2625
2437
  }
2626
2438
 
2627
2439
  var __defProp$z = Object.defineProperty;
2440
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2441
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2442
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2628
2443
  var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2444
+ var __spreadValues$p = (a, b) => {
2445
+ for (var prop in b || (b = {}))
2446
+ if (__hasOwnProp$q.call(b, prop))
2447
+ __defNormalProp$z(a, prop, b[prop]);
2448
+ if (__getOwnPropSymbols$q)
2449
+ for (var prop of __getOwnPropSymbols$q(b)) {
2450
+ if (__propIsEnum$q.call(b, prop))
2451
+ __defNormalProp$z(a, prop, b[prop]);
2452
+ }
2453
+ return a;
2454
+ };
2629
2455
  var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2630
2456
  class BookmarkItem {
2631
2457
  constructor(options) {
@@ -2643,11 +2469,11 @@ class BookmarkItem {
2643
2469
  this.name = String(item.id);
2644
2470
  }
2645
2471
  }
2646
- extent() {
2472
+ extent(opt) {
2647
2473
  if (this._extent) {
2648
- return CancelablePromise.resolve(this._extent);
2474
+ return Promise.resolve(this._extent);
2649
2475
  }
2650
- return this.options.connector.get("feature_layer.feature.item_extent", null, {
2476
+ return this.options.connector.get("feature_layer.feature.item_extent", opt, {
2651
2477
  id: this.resourceId,
2652
2478
  fid: this.item.id
2653
2479
  }).then((resp) => {
@@ -2657,18 +2483,18 @@ class BookmarkItem {
2657
2483
  return lonLat;
2658
2484
  });
2659
2485
  }
2660
- geoJson() {
2486
+ geoJson(opt) {
2661
2487
  if (this.item.geom) {
2662
- return CancelablePromise.resolve(createGeoJsonFeature(this.item));
2488
+ return Promise.resolve(createGeoJsonFeature(this.item));
2663
2489
  } else {
2664
- return fetchNgwLayerItem({
2490
+ return fetchNgwLayerItem(__spreadValues$p({
2665
2491
  resourceId: this.resourceId,
2666
2492
  featureId: this.item.id,
2667
2493
  connector: this.options.connector,
2668
2494
  geom: true,
2669
2495
  fields: null,
2670
2496
  extensions: null
2671
- }).then((onlyGeomItem) => {
2497
+ }, opt)).then((onlyGeomItem) => {
2672
2498
  const geom = onlyGeomItem.geom;
2673
2499
  this.item.geom = geom;
2674
2500
  return createGeoJsonFeature(this.item);
@@ -2678,22 +2504,20 @@ class BookmarkItem {
2678
2504
  }
2679
2505
 
2680
2506
  function treeEvery(item, filter, relation, itemPrepare) {
2681
- return !!treeWrapper(item, filter, relation, treeEvery_, itemPrepare);
2507
+ return !!treeWrapper(item, filter, relation, treeEvery_);
2682
2508
  }
2683
2509
  function treeSome(item, filter, relation, itemPrepare) {
2684
- return !!treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2510
+ return !!treeWrapper(item, filter, relation, treeFind_);
2685
2511
  }
2686
2512
  function treeFind(item, filter, relation, itemPrepare) {
2687
- return treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2513
+ return treeWrapper(item, filter, relation, treeFind_);
2688
2514
  }
2689
2515
  function treeFilter(item, filter, relation, itemPrepare) {
2690
2516
  return treeWrapper(
2691
2517
  item,
2692
2518
  filter,
2693
2519
  relation,
2694
- treeFilter_,
2695
- itemPrepare
2696
- );
2520
+ treeFilter_);
2697
2521
  }
2698
2522
  function getChildren(item, relation = "children") {
2699
2523
  let children = [];
@@ -2710,13 +2534,6 @@ function getChildren(item, relation = "children") {
2710
2534
  }
2711
2535
  function treeWrapper(item, filter = (x) => !!x, relation = "children", treeFunction, itemPrepare) {
2712
2536
  const filterFunction = typeof filter === "function" ? filter : (i) => propertiesFilter(i, filter);
2713
- if (itemPrepare) {
2714
- return treeFunction(
2715
- item,
2716
- (i) => filterFunction(itemPrepare(i)),
2717
- relation
2718
- );
2719
- }
2720
2537
  return treeFunction(item, filterFunction, relation);
2721
2538
  }
2722
2539
  function treeFind_(item, filterFunc = (x) => !!x, relation, _filtered = []) {
@@ -2983,7 +2800,7 @@ var __spreadValues$o = (a, b) => {
2983
2800
  }
2984
2801
  return a;
2985
2802
  };
2986
- var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, typeof key !== "symbol" ? key + "" : key, value);
2803
+ var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, key + "" , value);
2987
2804
  const _CheckProperty = class _CheckProperty extends BaseProperty {
2988
2805
  constructor(name, item, options) {
2989
2806
  super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
@@ -3307,9 +3124,10 @@ function getNgwWebmapExtent(webmap) {
3307
3124
  function fetchNgwLayerExtent({
3308
3125
  resourceId,
3309
3126
  connector,
3310
- cache = true
3127
+ cache = true,
3128
+ signal
3311
3129
  }) {
3312
- return connector.get("layer.extent", { cache }, { id: resourceId }).then((resp) => {
3130
+ return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3313
3131
  if (resp) {
3314
3132
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3315
3133
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3321,11 +3139,12 @@ function fetchNgwLayerItemExtent({
3321
3139
  resourceId,
3322
3140
  featureId,
3323
3141
  connector,
3324
- cache = true
3142
+ cache = true,
3143
+ signal
3325
3144
  }) {
3326
3145
  return connector.get(
3327
3146
  "feature_layer.feature.item_extent",
3328
- { cache },
3147
+ { cache, signal },
3329
3148
  { id: resourceId, fid: featureId }
3330
3149
  ).then((resp) => {
3331
3150
  if (resp) {
@@ -3336,7 +3155,10 @@ function fetchNgwLayerItemExtent({
3336
3155
  });
3337
3156
  }
3338
3157
  function fetchNgwExtent(options) {
3339
- return options.connector.getResource(options.resourceId).then((resource) => {
3158
+ return options.connector.getResource(options.resourceId, {
3159
+ signal: options.signal,
3160
+ cache: options.cache
3161
+ }).then((resource) => {
3340
3162
  if (resource) {
3341
3163
  return fetchNgwResourceExtent(resource, options.connector, options);
3342
3164
  }
@@ -3344,11 +3166,11 @@ function fetchNgwExtent(options) {
3344
3166
  }
3345
3167
  function fetchNgwResourceExtent(item, connector, options) {
3346
3168
  if (item.webmap) {
3347
- return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
3169
+ return Promise.resolve(getNgwWebmapExtent(item.webmap));
3348
3170
  } else {
3349
3171
  const resource = item.resource;
3350
3172
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3351
- return connector.getResource(resource.parent.id).then((res) => {
3173
+ return connector.getResource(resource.parent.id, options).then((res) => {
3352
3174
  if (res) {
3353
3175
  return fetchNgwLayerExtent(__spreadProps$a(__spreadValues$l({}, options), {
3354
3176
  resourceId: res.resource.id,
@@ -3368,7 +3190,7 @@ function fetchNgwResourceExtent(item, connector, options) {
3368
3190
  var __defProp$s = Object.defineProperty;
3369
3191
  var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3370
3192
  var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3371
- var __async$k = (__this, __arguments, generator) => {
3193
+ var __async$n = (__this, __arguments, generator) => {
3372
3194
  return new Promise((resolve, reject) => {
3373
3195
  var fulfilled = (value) => {
3374
3196
  try {
@@ -3396,12 +3218,12 @@ class NgwResource {
3396
3218
  }
3397
3219
  /** @deprecated use {@link NgwResource.getBounds} instead */
3398
3220
  getExtent() {
3399
- return __async$k(this, null, function* () {
3221
+ return __async$n(this, null, function* () {
3400
3222
  return this.getBounds();
3401
3223
  });
3402
3224
  }
3403
3225
  getBounds(options) {
3404
- return __async$k(this, null, function* () {
3226
+ return __async$n(this, null, function* () {
3405
3227
  if (this._extent) {
3406
3228
  return this._extent;
3407
3229
  }
@@ -3417,7 +3239,7 @@ class NgwResource {
3417
3239
  }
3418
3240
  }
3419
3241
 
3420
- var __async$j = (__this, __arguments, generator) => {
3242
+ var __async$m = (__this, __arguments, generator) => {
3421
3243
  return new Promise((resolve, reject) => {
3422
3244
  var fulfilled = (value) => {
3423
3245
  try {
@@ -3438,7 +3260,7 @@ var __async$j = (__this, __arguments, generator) => {
3438
3260
  });
3439
3261
  };
3440
3262
  function resourceIdFromLayerOptions(options, connector) {
3441
- return __async$j(this, null, function* () {
3263
+ return __async$m(this, null, function* () {
3442
3264
  const resource = options.resource;
3443
3265
  const item = resource;
3444
3266
  let { keyname, resourceId } = options;
@@ -3540,7 +3362,7 @@ var __objRest$1 = (source, exclude) => {
3540
3362
  return target;
3541
3363
  };
3542
3364
  var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3543
- var __async$i = (__this, __arguments, generator) => {
3365
+ var __async$l = (__this, __arguments, generator) => {
3544
3366
  return new Promise((resolve, reject) => {
3545
3367
  var fulfilled = (value) => {
3546
3368
  try {
@@ -3592,7 +3414,7 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3592
3414
  }
3593
3415
  }
3594
3416
  addLayer(options) {
3595
- return __async$i(this, null, function* () {
3417
+ return __async$l(this, null, function* () {
3596
3418
  if (!this.qms && options.qmsId) {
3597
3419
  try {
3598
3420
  this.qms = yield loadJson(
@@ -3700,7 +3522,7 @@ var __spreadValues$i = (a, b) => {
3700
3522
  };
3701
3523
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3702
3524
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3703
- var __async$h = (__this, __arguments, generator) => {
3525
+ var __async$k = (__this, __arguments, generator) => {
3704
3526
  return new Promise((resolve, reject) => {
3705
3527
  var fulfilled = (value) => {
3706
3528
  try {
@@ -3721,7 +3543,7 @@ var __async$h = (__this, __arguments, generator) => {
3721
3543
  });
3722
3544
  };
3723
3545
  function createBasemapLayerAdapter(_0) {
3724
- return __async$h(this, arguments, function* ({
3546
+ return __async$k(this, arguments, function* ({
3725
3547
  webMap,
3726
3548
  item
3727
3549
  }) {
@@ -3742,7 +3564,7 @@ function createBasemapLayerAdapter(_0) {
3742
3564
  if (TileAdapter) {
3743
3565
  class BasemapTileAdapter extends TileAdapter {
3744
3566
  addLayer(opt) {
3745
- return __async$h(this, null, function* () {
3567
+ return __async$k(this, null, function* () {
3746
3568
  return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$9(__spreadValues$i({}, opt), { url }));
3747
3569
  });
3748
3570
  }
@@ -3782,11 +3604,12 @@ function createPopupContent(feature, item) {
3782
3604
  function fetchNgwLayerCount({
3783
3605
  connector,
3784
3606
  resourceId,
3785
- cache = true
3607
+ cache = true,
3608
+ signal
3786
3609
  }) {
3787
3610
  return connector.get(
3788
3611
  "feature_layer.feature.count",
3789
- { cache },
3612
+ { cache, signal },
3790
3613
  {
3791
3614
  id: resourceId
3792
3615
  }
@@ -3840,13 +3663,34 @@ var __spreadValues$h = (a, b) => {
3840
3663
  return a;
3841
3664
  };
3842
3665
  var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
3666
+ var __async$j = (__this, __arguments, generator) => {
3667
+ return new Promise((resolve, reject) => {
3668
+ var fulfilled = (value) => {
3669
+ try {
3670
+ step(generator.next(value));
3671
+ } catch (e) {
3672
+ reject(e);
3673
+ }
3674
+ };
3675
+ var rejected = (value) => {
3676
+ try {
3677
+ step(generator.throw(value));
3678
+ } catch (e) {
3679
+ reject(e);
3680
+ }
3681
+ };
3682
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3683
+ step((generator = generator.apply(__this, __arguments)).next());
3684
+ });
3685
+ };
3843
3686
  function fetchNgwLayerItems(options) {
3844
- const filters = options.filters;
3845
- if (filters) {
3846
- return createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
3847
- filters
3848
- })).then((data) => {
3849
- var _a;
3687
+ return __async$j(this, null, function* () {
3688
+ var _a;
3689
+ const filters = options.filters;
3690
+ if (filters) {
3691
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
3692
+ filters
3693
+ }));
3850
3694
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3851
3695
  if (clientFilterValidate) {
3852
3696
  data = data.filter((y) => {
@@ -3858,10 +3702,10 @@ function fetchNgwLayerItems(options) {
3858
3702
  });
3859
3703
  }
3860
3704
  return data;
3861
- });
3862
- } else {
3863
- return fetchNgwLayerItemsRequest(options);
3864
- }
3705
+ } else {
3706
+ return fetchNgwLayerItemsRequest(options);
3707
+ }
3708
+ });
3865
3709
  }
3866
3710
  function isFilterWithAnyCase(filters) {
3867
3711
  if (filters[0] === "any") {
@@ -3879,8 +3723,29 @@ function isFilterWithAnyCase(filters) {
3879
3723
  return false;
3880
3724
  }
3881
3725
 
3726
+ var __async$i = (__this, __arguments, generator) => {
3727
+ return new Promise((resolve, reject) => {
3728
+ var fulfilled = (value) => {
3729
+ try {
3730
+ step(generator.next(value));
3731
+ } catch (e) {
3732
+ reject(e);
3733
+ }
3734
+ };
3735
+ var rejected = (value) => {
3736
+ try {
3737
+ step(generator.throw(value));
3738
+ } catch (e) {
3739
+ reject(e);
3740
+ }
3741
+ };
3742
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3743
+ step((generator = generator.apply(__this, __arguments)).next());
3744
+ });
3745
+ };
3882
3746
  function fetchNgwLayerFeatures(options) {
3883
- return fetchNgwLayerItems(options).then((x) => {
3747
+ return __async$i(this, null, function* () {
3748
+ const x = yield fetchNgwLayerItems(options);
3884
3749
  const features = [];
3885
3750
  x.forEach((y) => {
3886
3751
  features.push(createGeoJsonFeature(y));
@@ -3940,7 +3805,7 @@ var __spreadValues$g = (a, b) => {
3940
3805
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
3941
3806
  var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
3942
3807
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3943
- var __async$g = (__this, __arguments, generator) => {
3808
+ var __async$h = (__this, __arguments, generator) => {
3944
3809
  return new Promise((resolve, reject) => {
3945
3810
  var fulfilled = (value) => {
3946
3811
  try {
@@ -3961,7 +3826,7 @@ var __async$g = (__this, __arguments, generator) => {
3961
3826
  });
3962
3827
  };
3963
3828
  function createGeoJsonAdapter(props) {
3964
- return __async$g(this, null, function* () {
3829
+ return __async$h(this, null, function* () {
3965
3830
  var _a, _b;
3966
3831
  const {
3967
3832
  item,
@@ -3977,29 +3842,35 @@ function createGeoJsonAdapter(props) {
3977
3842
  const _loadedIds = [];
3978
3843
  let _fullDataLoad = false;
3979
3844
  let _lastFilterArgs;
3980
- let _dataPromise;
3845
+ let internalAbortController;
3981
3846
  const resourceId = yield resourceIdFromLayerOptions(options, connector);
3982
3847
  if ((_b = (_a = options.adapterOptions) == null ? void 0 : _a.popupOptions) == null ? void 0 : _b.fromProperties) {
3983
3848
  options.adapterOptions.popupOptions.createPopupContent = ({ feature }) => {
3984
3849
  return feature && createPopupContent(feature, item);
3985
3850
  };
3986
3851
  }
3987
- const getData = (filters, filterOpt) => __async$g(this, null, function* () {
3852
+ const getData = (filters, filterOpt) => __async$h(this, null, function* () {
3988
3853
  abort();
3854
+ internalAbortController = new AbortController();
3855
+ const internalSignal = internalAbortController.signal;
3856
+ if (filterOpt == null ? void 0 : filterOpt.signal) {
3857
+ filterOpt.signal.addEventListener("abort", internalAbortController.abort);
3858
+ }
3859
+ filterOpt = filterOpt || {};
3860
+ filterOpt.signal = internalSignal;
3989
3861
  _lastFilterArgs = { filters, options: filterOpt };
3990
- _dataPromise = fetchNgwLayerFeatureCollection(__spreadValues$g({
3862
+ return fetchNgwLayerFeatureCollection(__spreadValues$g({
3991
3863
  resourceId,
3992
3864
  filters,
3993
3865
  connector,
3994
3866
  cache: true
3995
3867
  }, filterOpt));
3996
- return yield _dataPromise;
3997
3868
  });
3998
3869
  let removed = false;
3999
3870
  const abort = () => {
4000
- if (_dataPromise) {
4001
- _dataPromise.cancel();
4002
- _dataPromise = void 0;
3871
+ if (internalAbortController) {
3872
+ internalAbortController.abort();
3873
+ internalAbortController = void 0;
4003
3874
  }
4004
3875
  };
4005
3876
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
@@ -4012,7 +3883,7 @@ function createGeoJsonAdapter(props) {
4012
3883
  __publicField$f(this, "__disableMapMoveListener");
4013
3884
  }
4014
3885
  addLayer(opt) {
4015
- return __async$g(this, null, function* () {
3886
+ return __async$h(this, null, function* () {
4016
3887
  let needUpdate = !opt.data;
4017
3888
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
4018
3889
  if (options.id !== void 0) {
@@ -4057,7 +3928,7 @@ function createGeoJsonAdapter(props) {
4057
3928
  return this.getBounds();
4058
3929
  }
4059
3930
  getBounds() {
4060
- return __async$g(this, null, function* () {
3931
+ return __async$h(this, null, function* () {
4061
3932
  const hasData = this.getLayers && this.getLayers().length;
4062
3933
  const strategy = this.options.strategy;
4063
3934
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -4083,7 +3954,7 @@ function createGeoJsonAdapter(props) {
4083
3954
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4084
3955
  }
4085
3956
  updateLayer(filterArgs) {
4086
- return __async$g(this, null, function* () {
3957
+ return __async$h(this, null, function* () {
4087
3958
  var _a2;
4088
3959
  filterArgs = filterArgs || _lastFilterArgs || {};
4089
3960
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
@@ -4149,7 +4020,7 @@ function createGeoJsonAdapter(props) {
4149
4020
  });
4150
4021
  }
4151
4022
  propertiesFilter(filters, opt) {
4152
- return __async$g(this, null, function* () {
4023
+ return __async$h(this, null, function* () {
4153
4024
  abort();
4154
4025
  if (this.filter && _fullDataLoad) {
4155
4026
  this.filter((e) => {
@@ -4223,7 +4094,7 @@ function createGeoJsonAdapter(props) {
4223
4094
  });
4224
4095
  }
4225
4096
 
4226
- var __async$f = (__this, __arguments, generator) => {
4097
+ var __async$g = (__this, __arguments, generator) => {
4227
4098
  return new Promise((resolve, reject) => {
4228
4099
  var fulfilled = (value) => {
4229
4100
  try {
@@ -4244,7 +4115,7 @@ var __async$f = (__this, __arguments, generator) => {
4244
4115
  });
4245
4116
  };
4246
4117
  function createWebMapAdapter(_0) {
4247
- return __async$f(this, arguments, function* ({
4118
+ return __async$g(this, arguments, function* ({
4248
4119
  layerOptions: options,
4249
4120
  webMap,
4250
4121
  connector
@@ -4372,7 +4243,7 @@ var __spreadValues$f = (a, b) => {
4372
4243
  };
4373
4244
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4374
4245
  var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4375
- var __async$e = (__this, __arguments, generator) => {
4246
+ var __async$f = (__this, __arguments, generator) => {
4376
4247
  return new Promise((resolve, reject) => {
4377
4248
  var fulfilled = (value) => {
4378
4249
  try {
@@ -4393,7 +4264,7 @@ var __async$e = (__this, __arguments, generator) => {
4393
4264
  });
4394
4265
  };
4395
4266
  function createRasterAdapter(_0) {
4396
- return __async$e(this, arguments, function* ({
4267
+ return __async$f(this, arguments, function* ({
4397
4268
  layerOptions,
4398
4269
  webMap,
4399
4270
  connector,
@@ -4449,7 +4320,7 @@ function createRasterAdapter(_0) {
4449
4320
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4450
4321
  }
4451
4322
  getLegend(options) {
4452
- return __async$e(this, null, function* () {
4323
+ return __async$f(this, null, function* () {
4453
4324
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4454
4325
  params: { id: resourceId },
4455
4326
  cache: true
@@ -4469,7 +4340,7 @@ function createRasterAdapter(_0) {
4469
4340
  });
4470
4341
  }
4471
4342
  getIdentificationIds() {
4472
- return __async$e(this, null, function* () {
4343
+ return __async$f(this, null, function* () {
4473
4344
  if (this.item) {
4474
4345
  if (adapter === "MVT") {
4475
4346
  return [this.item.resource.id];
@@ -4510,7 +4381,7 @@ var __spreadValues$e = (a, b) => {
4510
4381
  return a;
4511
4382
  };
4512
4383
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
4513
- var __async$d = (__this, __arguments, generator) => {
4384
+ var __async$e = (__this, __arguments, generator) => {
4514
4385
  return new Promise((resolve, reject) => {
4515
4386
  var fulfilled = (value) => {
4516
4387
  try {
@@ -4546,7 +4417,7 @@ const supportCls = [
4546
4417
  "tmsclient_layer"
4547
4418
  ];
4548
4419
  function createAdapterFromFirstStyle(_0) {
4549
- return __async$d(this, arguments, function* ({
4420
+ return __async$e(this, arguments, function* ({
4550
4421
  layerOptions,
4551
4422
  webMap,
4552
4423
  connector,
@@ -4565,7 +4436,7 @@ function createAdapterFromFirstStyle(_0) {
4565
4436
  });
4566
4437
  }
4567
4438
  function createAsyncAdapter(options, webMap, connector) {
4568
- return __async$d(this, null, function* () {
4439
+ return __async$e(this, null, function* () {
4569
4440
  let adapter;
4570
4441
  let item;
4571
4442
  const adapterType = options.adapter;
@@ -4762,7 +4633,7 @@ var __spreadValues$c = (a, b) => {
4762
4633
  return a;
4763
4634
  };
4764
4635
  var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4765
- var __async$c = (__this, __arguments, generator) => {
4636
+ var __async$d = (__this, __arguments, generator) => {
4766
4637
  return new Promise((resolve, reject) => {
4767
4638
  var fulfilled = (value) => {
4768
4639
  try {
@@ -4812,7 +4683,7 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4812
4683
  }
4813
4684
  }
4814
4685
  static create(webMap, item, options, connector, parent) {
4815
- return __async$c(this, null, function* () {
4686
+ return __async$d(this, null, function* () {
4816
4687
  const ngwWebmapItem = new _NgwWebmapItem(
4817
4688
  webMap,
4818
4689
  item,
@@ -4841,15 +4712,14 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4841
4712
  return this.layer;
4842
4713
  }
4843
4714
  getLegend(options) {
4844
- return __async$c(this, null, function* () {
4715
+ return __async$d(this, null, function* () {
4845
4716
  var _a;
4846
4717
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4847
4718
  if (id !== void 0) {
4848
4719
  const connector = this.connector;
4849
4720
  if (connector) {
4850
4721
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4851
- params: { id: this.item.resourceId },
4852
- cache: true
4722
+ params: { id: this.item.resourceId }
4853
4723
  }, options));
4854
4724
  const legend = {
4855
4725
  layerId: id,
@@ -5040,7 +4910,7 @@ var __spreadValues$b = (a, b) => {
5040
4910
  return a;
5041
4911
  };
5042
4912
  var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5043
- var __async$b = (__this, __arguments, generator) => {
4913
+ var __async$c = (__this, __arguments, generator) => {
5044
4914
  return new Promise((resolve, reject) => {
5045
4915
  var fulfilled = (value) => {
5046
4916
  try {
@@ -5061,7 +4931,7 @@ var __async$b = (__this, __arguments, generator) => {
5061
4931
  });
5062
4932
  };
5063
4933
  function createOnFirstShowAdapter(_0) {
5064
- return __async$b(this, arguments, function* ({
4934
+ return __async$c(this, arguments, function* ({
5065
4935
  webMap,
5066
4936
  adapterOptions = {},
5067
4937
  onLayerAdded,
@@ -5087,7 +4957,7 @@ function createOnFirstShowAdapter(_0) {
5087
4957
  return this._removed;
5088
4958
  }
5089
4959
  showLayer() {
5090
- return __async$b(this, null, function* () {
4960
+ return __async$c(this, null, function* () {
5091
4961
  this.options.visibility = true;
5092
4962
  if (this.layer.length) {
5093
4963
  for (const x of this.layer) {
@@ -5099,7 +4969,7 @@ function createOnFirstShowAdapter(_0) {
5099
4969
  });
5100
4970
  }
5101
4971
  hideLayer() {
5102
- return __async$b(this, null, function* () {
4972
+ return __async$c(this, null, function* () {
5103
4973
  this.options.visibility = false;
5104
4974
  if (this.layer) {
5105
4975
  for (const x of this.layer) {
@@ -5109,7 +4979,7 @@ function createOnFirstShowAdapter(_0) {
5109
4979
  });
5110
4980
  }
5111
4981
  loadLayer() {
5112
- return __async$b(this, null, function* () {
4982
+ return __async$c(this, null, function* () {
5113
4983
  if (!this.layer.length && !this._creatingInProgress) {
5114
4984
  this._creatingInProgress = true;
5115
4985
  const Adapter = yield createAdapter(this);
@@ -5143,7 +5013,7 @@ function createOnFirstShowAdapter(_0) {
5143
5013
  });
5144
5014
  }
5145
5015
 
5146
- var __async$a = (__this, __arguments, generator) => {
5016
+ var __async$b = (__this, __arguments, generator) => {
5147
5017
  return new Promise((resolve, reject) => {
5148
5018
  var fulfilled = (value) => {
5149
5019
  try {
@@ -5164,7 +5034,7 @@ var __async$a = (__this, __arguments, generator) => {
5164
5034
  });
5165
5035
  };
5166
5036
  function createOnFirstShowNgwAdapter(_0) {
5167
- return __async$a(this, arguments, function* ({
5037
+ return __async$b(this, arguments, function* ({
5168
5038
  webMap,
5169
5039
  connector,
5170
5040
  item,
@@ -5217,7 +5087,7 @@ var __spreadValues$a = (a, b) => {
5217
5087
  return a;
5218
5088
  };
5219
5089
  var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5220
- var __async$9 = (__this, __arguments, generator) => {
5090
+ var __async$a = (__this, __arguments, generator) => {
5221
5091
  return new Promise((resolve, reject) => {
5222
5092
  var fulfilled = (value) => {
5223
5093
  try {
@@ -5268,7 +5138,7 @@ class NgwWebmapLayerAdapter {
5268
5138
  }
5269
5139
  }
5270
5140
  addLayer(options) {
5271
- return __async$9(this, null, function* () {
5141
+ return __async$a(this, null, function* () {
5272
5142
  var _a, _b;
5273
5143
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5274
5144
  this.layer = yield this._getWebMapLayerItem();
@@ -5301,21 +5171,21 @@ class NgwWebmapLayerAdapter {
5301
5171
  delete this._webmapLayersIds;
5302
5172
  }
5303
5173
  showLayer() {
5304
- return __async$9(this, null, function* () {
5174
+ return __async$a(this, null, function* () {
5305
5175
  if (this.layer && this.layer.properties) {
5306
5176
  return this.layer.properties.property("visibility").set(true);
5307
5177
  }
5308
5178
  });
5309
5179
  }
5310
5180
  hideLayer() {
5311
- return __async$9(this, null, function* () {
5181
+ return __async$a(this, null, function* () {
5312
5182
  if (this.layer && this.layer.properties) {
5313
5183
  return this.layer.properties.property("visibility").set(false);
5314
5184
  }
5315
5185
  });
5316
5186
  }
5317
5187
  setOpacity(val) {
5318
- return __async$9(this, null, function* () {
5188
+ return __async$a(this, null, function* () {
5319
5189
  if (this.layer && this.layer.properties) {
5320
5190
  return this.layer.properties.property("opacity").set(val);
5321
5191
  }
@@ -5340,22 +5210,22 @@ class NgwWebmapLayerAdapter {
5340
5210
  return webmap.bookmark_resource.id;
5341
5211
  }
5342
5212
  }
5343
- fetchBookmarks() {
5213
+ fetchBookmarks(options) {
5344
5214
  const bookmarkResId = this.getBookmarksResourceId();
5345
5215
  const connector = this.options.connector;
5346
5216
  if (bookmarkResId) {
5347
- return connector.getResourceOrFail(bookmarkResId).then((item) => {
5217
+ return connector.getResourceOrFail(bookmarkResId, options).then((item) => {
5348
5218
  var _a;
5349
5219
  const labelField = (_a = item.feature_layer) == null ? void 0 : _a.fields.find(
5350
5220
  (x) => x.label_field
5351
5221
  );
5352
5222
  const keyname = labelField && labelField.keyname;
5353
- return fetchNgwLayerItems({
5223
+ return fetchNgwLayerItems(__spreadValues$a({
5354
5224
  connector,
5355
5225
  resourceId: bookmarkResId,
5356
5226
  geom: false,
5357
5227
  fields: keyname ? [keyname] : void 0
5358
- }).then((items) => {
5228
+ }, options)).then((items) => {
5359
5229
  const bookmarks = [];
5360
5230
  for (const i of items) {
5361
5231
  const bookmark = new BookmarkItem({
@@ -5374,24 +5244,24 @@ class NgwWebmapLayerAdapter {
5374
5244
  "Webmap was not loaded correctly, it is impossible to extract bookmarks"
5375
5245
  );
5376
5246
  }
5377
- getLegend() {
5378
- return __async$9(this, null, function* () {
5247
+ getLegend(options) {
5248
+ return __async$a(this, null, function* () {
5379
5249
  const legends = [];
5380
5250
  let deps = this.getDependLayers();
5381
5251
  deps = deps.sort((a, b) => b.id - a.id);
5382
5252
  for (const d of deps) {
5383
- const layerLegend = yield d.getLegend();
5253
+ const layerLegend = yield d.getLegend(options);
5384
5254
  legends.push(...layerLegend);
5385
5255
  }
5386
5256
  return legends;
5387
5257
  });
5388
5258
  }
5389
- getIdentificationIds() {
5390
- return __async$9(this, null, function* () {
5259
+ getIdentificationIds(options) {
5260
+ return __async$a(this, null, function* () {
5391
5261
  const visibleLayers = [];
5392
5262
  let ids = this._webmapLayersIds;
5393
5263
  if (!ids) {
5394
- ids = yield this._getWebMapIds();
5264
+ ids = yield this._getWebMapIds(options);
5395
5265
  this._webmapLayersIds = ids;
5396
5266
  }
5397
5267
  if (ids && ids.length) {
@@ -5413,7 +5283,7 @@ class NgwWebmapLayerAdapter {
5413
5283
  });
5414
5284
  }
5415
5285
  _getWebMapLayerItem() {
5416
- return __async$9(this, null, function* () {
5286
+ return __async$a(this, null, function* () {
5417
5287
  if (this.resourceId) {
5418
5288
  const webmap = yield this.getWebMapConfig(this.resourceId);
5419
5289
  if (webmap && webmap.root_item) {
@@ -5446,7 +5316,7 @@ class NgwWebmapLayerAdapter {
5446
5316
  });
5447
5317
  }
5448
5318
  getWebMapConfig(id) {
5449
- return __async$9(this, null, function* () {
5319
+ return __async$a(this, null, function* () {
5450
5320
  const data = yield this.options.connector.getResource(id);
5451
5321
  if (data) {
5452
5322
  this.response = data;
@@ -5540,8 +5410,8 @@ class NgwWebmapLayerAdapter {
5540
5410
  }
5541
5411
  return item;
5542
5412
  }
5543
- _getWebMapIds() {
5544
- return __async$9(this, null, function* () {
5413
+ _getWebMapIds(options) {
5414
+ return __async$a(this, null, function* () {
5545
5415
  const webMapItem = this.layer;
5546
5416
  if (webMapItem && webMapItem.item.item_type === "root") {
5547
5417
  const layers = webMapItem.tree.getDescendants();
@@ -5550,7 +5420,7 @@ class NgwWebmapLayerAdapter {
5550
5420
  const item = x.item;
5551
5421
  if (item.item_type === "layer") {
5552
5422
  const id = item.layer_style_id;
5553
- const promise = this.options.connector.getResource(id).then((y) => {
5423
+ const promise = this.options.connector.getResource(id, options).then((y) => {
5554
5424
  if (y) {
5555
5425
  const parentId = Number(y.resource.parent.id);
5556
5426
  item.parentId = parentId;
@@ -5584,7 +5454,7 @@ var __spreadValues$9 = (a, b) => {
5584
5454
  return a;
5585
5455
  };
5586
5456
  var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5587
- var __async$8 = (__this, __arguments, generator) => {
5457
+ var __async$9 = (__this, __arguments, generator) => {
5588
5458
  return new Promise((resolve, reject) => {
5589
5459
  var fulfilled = (value) => {
5590
5460
  try {
@@ -5629,7 +5499,7 @@ class NgwKit {
5629
5499
  classAdapters[cls] = adapter;
5630
5500
  }
5631
5501
  onLoadSync(webMap) {
5632
- return __async$8(this, null, function* () {
5502
+ return __async$9(this, null, function* () {
5633
5503
  if (this.options.resourceId && this.url) {
5634
5504
  const resourceIds = [this.options.resourceId];
5635
5505
  if (resourceIds.length) {
@@ -5712,7 +5582,7 @@ class IdentifyItem {
5712
5582
  }
5713
5583
  identify(options = {}) {
5714
5584
  if (this._item) {
5715
- return CancelablePromise.resolve(this._item);
5585
+ return Promise.resolve(this._item);
5716
5586
  }
5717
5587
  return fetchNgwLayerItem(__spreadValues$8({
5718
5588
  connector: this.connector,
@@ -5727,30 +5597,30 @@ class IdentifyItem {
5727
5597
  return resp;
5728
5598
  });
5729
5599
  }
5730
- resource() {
5600
+ resource(opt) {
5731
5601
  if (this._resource) {
5732
- return CancelablePromise.resolve(this._resource.feature_layer);
5602
+ return Promise.resolve(this._resource.feature_layer);
5733
5603
  }
5734
- return this.connector.getResource(this.layerId).then((resp) => {
5604
+ return this.connector.getResource(this.layerId, opt).then((resp) => {
5735
5605
  this._resource = resp;
5736
5606
  return this._resource.feature_layer;
5737
5607
  });
5738
5608
  }
5739
- getBounds() {
5609
+ getBounds(opt) {
5740
5610
  if (this._extent) {
5741
- return CancelablePromise.resolve(this._extent);
5611
+ return Promise.resolve(this._extent);
5742
5612
  }
5743
- return fetchNgwLayerItemExtent({
5613
+ return fetchNgwLayerItemExtent(__spreadValues$8({
5744
5614
  connector: this.connector,
5745
5615
  featureId: this.id,
5746
5616
  resourceId: this.layerId
5747
- });
5617
+ }, opt));
5748
5618
  }
5749
- geojson() {
5619
+ geojson(options) {
5750
5620
  if (this._geojson) {
5751
- return CancelablePromise.resolve(this._geojson);
5621
+ return Promise.resolve(this._geojson);
5752
5622
  }
5753
- return this.identify().then((resp) => {
5623
+ return this.identify(options).then((resp) => {
5754
5624
  return resp.toGeojson().then((geojson) => {
5755
5625
  this._geojson = geojson;
5756
5626
  return geojson;
@@ -5759,8 +5629,29 @@ class IdentifyItem {
5759
5629
  }
5760
5630
  }
5761
5631
 
5632
+ var __async$8 = (__this, __arguments, generator) => {
5633
+ return new Promise((resolve, reject) => {
5634
+ var fulfilled = (value) => {
5635
+ try {
5636
+ step(generator.next(value));
5637
+ } catch (e) {
5638
+ reject(e);
5639
+ }
5640
+ };
5641
+ var rejected = (value) => {
5642
+ try {
5643
+ step(generator.throw(value));
5644
+ } catch (e) {
5645
+ reject(e);
5646
+ }
5647
+ };
5648
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
5649
+ step((generator = generator.apply(__this, __arguments)).next());
5650
+ });
5651
+ };
5762
5652
  function fetchNgwLayerFeature(options) {
5763
- return fetchNgwLayerItem(options).then((item) => {
5653
+ return __async$8(this, null, function* () {
5654
+ const item = yield fetchNgwLayerItem(options);
5764
5655
  return createGeoJsonFeature(item);
5765
5656
  });
5766
5657
  }
@@ -5845,7 +5736,7 @@ function fetchIdentifyGeoJson(options) {
5845
5736
  const withGeom = item.features.find((x) => x.geom);
5846
5737
  if (withGeom && withGeom.geom) {
5847
5738
  const geom = withGeom.geom;
5848
- return CancelablePromise.resolve(
5739
+ return Promise.resolve(
5849
5740
  createGeoJsonFeature(__spreadProps$4(__spreadValues$7({}, withGeom), {
5850
5741
  geom
5851
5742
  }))
@@ -5858,7 +5749,7 @@ function fetchIdentifyGeoJson(options) {
5858
5749
  if (params && params.length) {
5859
5750
  return fetchNgwLayerFeature(__spreadValues$7(__spreadProps$4(__spreadValues$7({}, requestOptions), { connector }), params[0]));
5860
5751
  }
5861
- return CancelablePromise.resolve(void 0);
5752
+ return Promise.resolve(void 0);
5862
5753
  }
5863
5754
  function fetchIdentifyItem(options) {
5864
5755
  const { connector, identify } = options;
@@ -5868,7 +5759,7 @@ function fetchIdentifyItem(options) {
5868
5759
  connector
5869
5760
  }, options.requestOptions), params[0]));
5870
5761
  }
5871
- return CancelablePromise.resolve(void 0);
5762
+ return Promise.resolve(void 0);
5872
5763
  }
5873
5764
  function featureLayerIdentify(options) {
5874
5765
  const { geom, signal, cache, layers } = options;
@@ -5912,9 +5803,9 @@ function getPolygonCoordinates(geom) {
5912
5803
  function sendIdentifyRequest(ev, options) {
5913
5804
  deprecatedMapClick(ev);
5914
5805
  const [lng, lat] = ev.lngLat;
5915
- const { geom, radius, signal, cache } = options;
5806
+ const { geom, radius } = options;
5916
5807
  const geom_ = geom != null ? geom : getCirclePolygonCoordinates(lng, lat, radius);
5917
- return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_, signal, cache }));
5808
+ return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_ }));
5918
5809
  }
5919
5810
  function createIdentifyItem(opt) {
5920
5811
  return new IdentifyItem(opt);
@@ -7124,7 +7015,7 @@ const _WebMapMain = class _WebMapMain {
7124
7015
  __publicField$3(this, "_mapState", []);
7125
7016
  __publicField$3(this, "_extent");
7126
7017
  __publicField$3(this, "_eventsStatus", {});
7127
- __publicField$3(this, "_coordFromMapClickPromise");
7018
+ __publicField$3(this, "_coordFromMapClickAbort");
7128
7019
  __publicField$3(this, "_mapEvents", {});
7129
7020
  this.mapAdapter = mapOptions.mapAdapter;
7130
7021
  this._starterKits = mapOptions.starterKits || [];
@@ -7439,36 +7330,34 @@ const _WebMapMain = class _WebMapMain {
7439
7330
  return { stop };
7440
7331
  }
7441
7332
  stopGetCoordFromMapClick() {
7442
- if (this._coordFromMapClickPromise) {
7443
- this._coordFromMapClickPromise.cancel();
7333
+ if (this._coordFromMapClickAbort) {
7334
+ this._coordFromMapClickAbort();
7335
+ this._coordFromMapClickAbort = void 0;
7444
7336
  }
7445
7337
  }
7446
7338
  getCoordFromMapClick() {
7447
- if (!this._coordFromMapClickPromise) {
7448
- this._coordFromMapClickPromise = new CancelablePromise(
7449
- (resolve, reject, onCancel) => {
7450
- const cursor = this.getCursor() || "grab";
7451
- this._removeEventListeners({ include: ["click"] });
7452
- this.setCursor("crosshair");
7453
- const onCancel_ = () => {
7454
- this.setCursor(cursor);
7455
- this._addEventsListeners({ include: ["click"] });
7456
- this.mapAdapter.emitter.off("click", onMapClick);
7457
- this._coordFromMapClickPromise = void 0;
7458
- };
7459
- const onMapClick = (e) => {
7460
- onCancel_();
7461
- deprecatedMapClick(e);
7462
- resolve(e.lngLat);
7463
- };
7464
- this.mapAdapter.emitter.once("click", onMapClick);
7465
- onCancel(onCancel_);
7466
- }
7467
- );
7339
+ if (!this._coordFromMapClickAbort) {
7340
+ return new Promise((resolve, reject) => {
7341
+ const cursor = this.getCursor() || "grab";
7342
+ this._removeEventListeners({ include: ["click"] });
7343
+ this.setCursor("crosshair");
7344
+ const onCancel_ = () => {
7345
+ this.setCursor(cursor);
7346
+ this._addEventsListeners({ include: ["click"] });
7347
+ this.mapAdapter.emitter.off("click", onMapClick);
7348
+ this._coordFromMapClickAbort = void 0;
7349
+ };
7350
+ const onMapClick = (e) => {
7351
+ onCancel_();
7352
+ deprecatedMapClick(e);
7353
+ resolve(e.lngLat);
7354
+ };
7355
+ this.mapAdapter.emitter.once("click", onMapClick);
7356
+ this._coordFromMapClickAbort = onCancel_;
7357
+ });
7468
7358
  } else {
7469
7359
  return this.getCoordFromMapClick();
7470
7360
  }
7471
- return this._coordFromMapClickPromise;
7472
7361
  }
7473
7362
  _emitStatusEvent(eventName, data) {
7474
7363
  const _eventName = eventName;
@@ -9283,26 +9172,35 @@ const _NgwMap = class _NgwMap extends WebMap {
9283
9172
  }, options));
9284
9173
  }
9285
9174
  fetchIdentifyItem(identify, requestOptions) {
9175
+ const abortController = new AbortController();
9176
+ const abortSignal = abortController.signal;
9177
+ if (requestOptions == null ? void 0 : requestOptions.signal) {
9178
+ requestOptions.signal.addEventListener("abort", abortController.abort);
9179
+ }
9180
+ requestOptions = requestOptions || {};
9181
+ requestOptions.signal = abortSignal;
9286
9182
  const promise = fetchIdentifyItem({
9287
9183
  identify,
9288
9184
  connector: this.connector,
9289
9185
  requestOptions
9290
9186
  // multiple,
9291
9187
  });
9292
- this._addPromise("identify", promise);
9188
+ this._addPromise("identify", promise, abortController);
9293
9189
  return promise;
9294
9190
  }
9295
9191
  fetchIdentifyGeoJson(identify, multiple = false) {
9192
+ const abortController = new AbortController();
9296
9193
  const promise = fetchIdentifyGeoJson({
9297
9194
  identify,
9298
9195
  connector: this.connector,
9299
- multiple
9196
+ multiple,
9197
+ requestOptions: { signal: abortController.signal }
9300
9198
  });
9301
9199
  if (promise && "then" in promise) {
9302
- this._addPromise("identify", promise);
9200
+ this._addPromise("identify", promise, abortController);
9303
9201
  return promise;
9304
9202
  } else {
9305
- return CancelablePromise.resolve(promise);
9203
+ return Promise.resolve(promise);
9306
9204
  }
9307
9205
  }
9308
9206
  /**
@@ -9476,7 +9374,7 @@ const _NgwMap = class _NgwMap extends WebMap {
9476
9374
  args.forEach((name) => {
9477
9375
  const group = this._promises[name];
9478
9376
  if (group) {
9479
- group.forEach((x) => x.cancel());
9377
+ group.forEach((x) => x[1].abort());
9480
9378
  this._promises[name] = [];
9481
9379
  }
9482
9380
  });
@@ -9543,11 +9441,13 @@ const _NgwMap = class _NgwMap extends WebMap {
9543
9441
  }, highlightDuration);
9544
9442
  }
9545
9443
  }
9444
+ const abortController = new AbortController();
9546
9445
  const selectPromise = sendIdentifyRequest(ev, {
9547
9446
  layers: ids,
9548
9447
  connector: this.connector,
9549
9448
  radius,
9550
- geom
9449
+ geom,
9450
+ signal: abortController.signal
9551
9451
  }).then((resp) => {
9552
9452
  const identify = __spreadProps(__spreadValues({}, resp), {
9553
9453
  resources: ids,
@@ -9558,22 +9458,22 @@ const _NgwMap = class _NgwMap extends WebMap {
9558
9458
  this._emitStatusEvent("ngw:select", identifyEvent);
9559
9459
  return identifyEvent;
9560
9460
  });
9561
- this._addPromise("select", selectPromise);
9461
+ this._addPromise("select", selectPromise, abortController);
9562
9462
  return selectPromise;
9563
9463
  });
9564
9464
  }
9565
- _addPromise(groupName, promise) {
9465
+ _addPromise(groupName, promise, abortController) {
9566
9466
  const group = this._promises[groupName];
9567
- if (group && group.indexOf(promise) === -1) {
9467
+ if (group && group.findIndex((g) => g[0] === promise) === -1) {
9568
9468
  const removeFromGroup = () => {
9569
- const index = group.indexOf(promise);
9469
+ const index = group.findIndex((g) => g[0] === promise);
9570
9470
  if (index !== -1) {
9571
9471
  group.splice(index, 1);
9572
9472
  }
9573
9473
  };
9574
9474
  promise.then(removeFromGroup);
9575
9475
  promise.catch(removeFromGroup);
9576
- group.push(promise);
9476
+ group.push([promise, abortController]);
9577
9477
  }
9578
9478
  }
9579
9479
  _isFitFromResource() {