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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 2.5.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.1; author: NextGIS */
2
2
  var 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, 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, 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, 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"/>',
@@ -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$f = Object.defineProperties;
1318
- var __getOwnPropDescs$f = 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$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(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$f(__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,58 +1319,90 @@ 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
 
@@ -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$f = Object.defineProperties;
1506
+ var __getOwnPropDescs$f = 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$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(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;
@@ -1832,7 +1565,7 @@ class NgwConnector {
1832
1565
  __publicField$p(this, "cache");
1833
1566
  __publicField$p(this, "withCredentials");
1834
1567
  __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1835
- __publicField$p(this, "activeRequests", []);
1568
+ __publicField$p(this, "activeRequests", {});
1836
1569
  __publicField$p(this, "requestTransform");
1837
1570
  const exist = findConnector(options);
1838
1571
  this.cache = new Cache({ namespace: options.cacheId });
@@ -1893,29 +1626,27 @@ class NgwConnector {
1893
1626
  * ```
1894
1627
  */
1895
1628
  connect() {
1896
- const auth = this.options.auth;
1897
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1898
- const makeQuery = () => {
1899
- return this.makeQuery(this.routeStr, {}, {}).then((route) => {
1900
- resolve(route);
1901
- }).catch((er) => {
1902
- reject(er);
1903
- });
1904
- };
1629
+ return __async$q(this, null, function* () {
1630
+ const auth = this.options.auth;
1905
1631
  if (auth) {
1906
1632
  const { login, password } = auth;
1907
1633
  if (login && password) {
1908
- return this._login({ login, password }).then(() => {
1909
- return makeQuery();
1910
- }).catch((er) => reject(er));
1634
+ yield this._login({ login, password });
1911
1635
  }
1912
1636
  }
1913
- return makeQuery();
1914
- });
1915
- return this.cache.add("route", makeConnect, {
1916
- id: this.id,
1917
- auth,
1918
- baseUrl: this.options.baseUrl
1637
+ return yield this.makeQuery(
1638
+ this.routeStr,
1639
+ {},
1640
+ {
1641
+ cacheName: "route",
1642
+ cache: true,
1643
+ cacheProps: {
1644
+ id: this.id,
1645
+ auth,
1646
+ baseUrl: this.options.baseUrl
1647
+ }
1648
+ }
1649
+ );
1919
1650
  });
1920
1651
  }
1921
1652
  /**
@@ -1939,20 +1670,22 @@ class NgwConnector {
1939
1670
  this.emitter.emit("logout");
1940
1671
  }
1941
1672
  getUserInfo(credentials, options) {
1942
- if (this.user && this.user.id) {
1943
- return CancelablePromise.resolve(this.user);
1944
- }
1945
- if (credentials) {
1946
- this.options.auth = credentials;
1947
- }
1948
- const options_ = __spreadValues$s({
1949
- headers: this.getAuthorizationHeaders(credentials)
1950
- }, options);
1951
- return this.makeQuery(
1952
- "/api/component/auth/current_user",
1953
- {},
1954
- options_
1955
- );
1673
+ return __async$q(this, null, function* () {
1674
+ if (this.user && this.user.id) {
1675
+ return this.user;
1676
+ }
1677
+ if (credentials) {
1678
+ this.options.auth = credentials;
1679
+ }
1680
+ const options_ = __spreadValues$t({
1681
+ headers: this.getAuthorizationHeaders(credentials)
1682
+ }, options);
1683
+ return this.makeQuery(
1684
+ "/api/component/auth/current_user",
1685
+ {},
1686
+ options_
1687
+ );
1688
+ });
1956
1689
  }
1957
1690
  /**
1958
1691
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -1961,7 +1694,7 @@ class NgwConnector {
1961
1694
  const client = this.makeClientId(credentials);
1962
1695
  if (client) {
1963
1696
  return {
1964
- Authorization: "Basic " + client
1697
+ Authorization: `Basic ${client}`
1965
1698
  };
1966
1699
  }
1967
1700
  }
@@ -1969,21 +1702,22 @@ class NgwConnector {
1969
1702
  credentials = credentials || this.options.auth;
1970
1703
  if (credentials) {
1971
1704
  const { login, password } = credentials;
1972
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1705
+ const str = `${login}:${password}`;
1706
+ const encodedStr = encodeURIComponent(str);
1973
1707
  {
1974
- return window.btoa(str);
1708
+ return window.btoa(encodedStr);
1975
1709
  }
1976
1710
  }
1977
1711
  }
1978
1712
  /** Stop all api requests */
1979
1713
  abort() {
1980
- for (const req of this.activeRequests) {
1981
- req.cancel();
1714
+ for (const abortController of Object.values(this.activeRequests)) {
1715
+ abortController.abort();
1982
1716
  }
1983
- this.activeRequests = [];
1717
+ this.activeRequests = {};
1984
1718
  }
1985
1719
  getActiveApiRequests() {
1986
- return [...this.activeRequests];
1720
+ return __spreadValues$t({}, this.activeRequests);
1987
1721
  }
1988
1722
  /**
1989
1723
  * Send request to NGW api router.
@@ -2015,26 +1749,10 @@ class NgwConnector {
2015
1749
  * ```
2016
1750
  */
2017
1751
  apiRequest(name, params_ = {}, requestOptions = {}) {
2018
- var _a, _b;
2019
- requestOptions = __spreadValues$s({
2020
- withCredentials: this.withCredentials
2021
- }, requestOptions);
2022
- const { method, headers, withCredentials, responseType } = requestOptions;
1752
+ var _a;
2023
1753
  params_ = (_a = requestOptions.params) != null ? _a : params_;
2024
1754
  const params = objectRemoveEmpty(params_);
2025
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
2026
- if (requestOptions.cache && method === "GET") {
2027
- return this.cache.add(name, makeApiRequest, __spreadValues$s({
2028
- params
2029
- }, objectRemoveEmpty({
2030
- headers,
2031
- withCredentials,
2032
- responseType,
2033
- baseUrl: this.options.baseUrl,
2034
- userId: (_b = this.user) == null ? void 0 : _b.id
2035
- })));
2036
- }
2037
- return makeApiRequest();
1755
+ return apiRequest({ name, params, requestOptions, connector: this });
2038
1756
  }
2039
1757
  /**
2040
1758
  * Shortcut method for send POST request to NGW.
@@ -2124,17 +1842,68 @@ class NgwConnector {
2124
1842
  * @param params - Query params
2125
1843
  * @param options - Request options
2126
1844
  */
2127
- makeQuery(url, params, options = {}) {
2128
- url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
2129
- if (url) {
1845
+ makeQuery(_0, _1) {
1846
+ return __async$q(this, arguments, function* (url, params, options = {}) {
1847
+ var _b;
1848
+ url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1849
+ if (!url) {
1850
+ throw new Error("Empty `url` not allowed");
1851
+ }
2130
1852
  if (params) {
2131
- url = template(url, params);
1853
+ const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1854
+ url = template(url, restParams);
1855
+ }
1856
+ url = encodeURI(fixUrlStr(url));
1857
+ options = __spreadValues$t({ withCredentials: this.withCredentials }, options);
1858
+ const {
1859
+ cache,
1860
+ signal: externalSignal,
1861
+ method = "GET",
1862
+ headers,
1863
+ cacheName,
1864
+ cacheProps,
1865
+ responseType,
1866
+ withCredentials
1867
+ } = options;
1868
+ const internalAbortController = new AbortController();
1869
+ const internalSignal = internalAbortController.signal;
1870
+ if (externalSignal) {
1871
+ if (externalSignal.aborted) {
1872
+ throw new AbortError();
1873
+ }
1874
+ externalSignal.addEventListener("abort", () => {
1875
+ internalAbortController.abort();
1876
+ });
1877
+ }
1878
+ options.signal = internalSignal;
1879
+ const createPromise = () => __async$q(this, null, function* () {
1880
+ const id = REQUEST_ID++;
1881
+ this.activeRequests[id] = internalAbortController;
1882
+ try {
1883
+ return this._loadData(url, options);
1884
+ } finally {
1885
+ this._cleanActiveRequest(id);
1886
+ }
1887
+ });
1888
+ if (cache && method === "GET") {
1889
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$f(__spreadValues$t({}, objectRemoveEmpty({
1890
+ headers,
1891
+ withCredentials,
1892
+ responseType,
1893
+ baseUrl: this.options.baseUrl,
1894
+ userId: (_b = this.user) == null ? void 0 : _b.id
1895
+ })), {
1896
+ params
1897
+ });
1898
+ return this.cache.add(
1899
+ cacheName || url,
1900
+ createPromise,
1901
+ cacheOptions,
1902
+ false
1903
+ );
2132
1904
  }
2133
- url = encodeURI(fixUrlStr(url));
2134
- return this._loadData(url, options);
2135
- } else {
2136
- throw new Error("Empty `url` not allowed");
2137
- }
1905
+ return createPromise();
1906
+ });
2138
1907
  }
2139
1908
  // -------------------------------------------------------------------------
2140
1909
  // Resource Methods
@@ -2216,26 +1985,29 @@ class NgwConnector {
2216
1985
  */
2217
1986
  _loadData(url, options) {
2218
1987
  options.responseType = options.responseType || "json";
2219
- if (options.signal && options.signal.aborted) {
2220
- return CancelablePromise.reject(new CancelablePromise.CancelError());
2221
- }
2222
- const request = new CancelablePromise((resolve, reject, onCancel) => {
1988
+ return new Promise((resolve, reject) => {
1989
+ var _a;
2223
1990
  if (this.user) {
2224
1991
  options = options || {};
2225
- options.headers = __spreadValues$s(__spreadValues$s({}, this.getAuthorizationHeaders()), options.headers);
1992
+ options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
2226
1993
  }
2227
1994
  if (this.requestTransform) {
2228
1995
  const [transUrl, transOptions] = this.requestTransform(url, options);
2229
1996
  url = transUrl;
2230
1997
  options = transOptions;
2231
1998
  }
2232
- loadData(url, resolve, options, reject, onCancel);
2233
- }).then((resp) => {
2234
- this._cleanActiveRequests(request);
2235
- return resp;
1999
+ let runOnAbort = void 0;
2000
+ loadData(url, resolve, options, reject, (handler) => {
2001
+ runOnAbort = handler;
2002
+ });
2003
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2004
+ if (runOnAbort !== void 0) {
2005
+ runOnAbort();
2006
+ }
2007
+ reject(new AbortError());
2008
+ });
2236
2009
  }).catch((httpError) => {
2237
- this._cleanActiveRequests(request);
2238
- if (httpError instanceof CancelablePromise.CancelError) ; else {
2010
+ if (httpError.name !== "AbortError") {
2239
2011
  {
2240
2012
  console.warn("DEV WARN", httpError);
2241
2013
  }
@@ -2244,31 +2016,24 @@ class NgwConnector {
2244
2016
  throw er;
2245
2017
  }
2246
2018
  }
2019
+ throw httpError;
2247
2020
  });
2248
- if (options.signal && typeof options.signal.addEventListener === "function") {
2249
- options.signal.addEventListener("abort", () => {
2250
- request.cancel();
2251
- this._cleanActiveRequests(request);
2252
- });
2253
- }
2254
- this.activeRequests.push(request);
2255
- return request;
2256
2021
  }
2257
2022
  _login(credentials, options) {
2258
- return this.getUserInfo(credentials, options).then((data) => {
2259
- this.user = data;
2260
- this.emitter.emit("login", data);
2261
- return data;
2262
- }).catch((er) => {
2263
- this.emitter.emit("login:error", er);
2264
- throw er;
2023
+ return __async$q(this, null, function* () {
2024
+ try {
2025
+ const data = yield this.getUserInfo(credentials, options);
2026
+ this.user = data;
2027
+ this.emitter.emit("login", data);
2028
+ return data;
2029
+ } catch (er) {
2030
+ this.emitter.emit("login:error", er);
2031
+ throw er;
2032
+ }
2265
2033
  });
2266
2034
  }
2267
- _cleanActiveRequests(request) {
2268
- const activeRequestIndex = this.activeRequests.indexOf(request);
2269
- if (activeRequestIndex !== -1) {
2270
- this.activeRequests.splice(activeRequestIndex, 1);
2271
- }
2035
+ _cleanActiveRequest(requestId) {
2036
+ delete this.activeRequests[requestId];
2272
2037
  }
2273
2038
  _handleHttpError(er) {
2274
2039
  if (er) {
@@ -2289,17 +2054,17 @@ __publicField$p(NgwConnector, "errors", {
2289
2054
  });
2290
2055
 
2291
2056
  var __defProp$C = Object.defineProperty;
2292
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2293
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2294
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2057
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2058
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2059
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2295
2060
  var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2296
- var __spreadValues$r = (a, b) => {
2061
+ var __spreadValues$s = (a, b) => {
2297
2062
  for (var prop in b || (b = {}))
2298
- if (__hasOwnProp$s.call(b, prop))
2063
+ if (__hasOwnProp$t.call(b, prop))
2299
2064
  __defNormalProp$C(a, prop, b[prop]);
2300
- if (__getOwnPropSymbols$s)
2301
- for (var prop of __getOwnPropSymbols$s(b)) {
2302
- if (__propIsEnum$s.call(b, prop))
2065
+ if (__getOwnPropSymbols$t)
2066
+ for (var prop of __getOwnPropSymbols$t(b)) {
2067
+ if (__propIsEnum$t.call(b, prop))
2303
2068
  __defNormalProp$C(a, prop, b[prop]);
2304
2069
  }
2305
2070
  return a;
@@ -2347,7 +2112,7 @@ function isPropertyFilter(filter) {
2347
2112
  return false;
2348
2113
  }
2349
2114
  function featureFilter(feature, filters) {
2350
- const properties = __spreadValues$r({}, feature.properties);
2115
+ const properties = __spreadValues$s({}, feature.properties);
2351
2116
  if (properties) {
2352
2117
  properties.$id = feature.id;
2353
2118
  return propertiesFilter(properties, filters);
@@ -2385,22 +2150,42 @@ function propertiesFilter(properties, filters) {
2385
2150
  var __defProp$B = Object.defineProperty;
2386
2151
  var __defProps$e = Object.defineProperties;
2387
2152
  var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2388
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2389
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2390
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2153
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2154
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2155
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2391
2156
  var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2392
- var __spreadValues$q = (a, b) => {
2157
+ var __spreadValues$r = (a, b) => {
2393
2158
  for (var prop in b || (b = {}))
2394
- if (__hasOwnProp$r.call(b, prop))
2159
+ if (__hasOwnProp$s.call(b, prop))
2395
2160
  __defNormalProp$B(a, prop, b[prop]);
2396
- if (__getOwnPropSymbols$r)
2397
- for (var prop of __getOwnPropSymbols$r(b)) {
2398
- if (__propIsEnum$r.call(b, prop))
2161
+ if (__getOwnPropSymbols$s)
2162
+ for (var prop of __getOwnPropSymbols$s(b)) {
2163
+ if (__propIsEnum$s.call(b, prop))
2399
2164
  __defNormalProp$B(a, prop, b[prop]);
2400
2165
  }
2401
2166
  return a;
2402
2167
  };
2403
2168
  var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2169
+ var __async$p = (__this, __arguments, generator) => {
2170
+ return new Promise((resolve, reject) => {
2171
+ var fulfilled = (value) => {
2172
+ try {
2173
+ step(generator.next(value));
2174
+ } catch (e) {
2175
+ reject(e);
2176
+ }
2177
+ };
2178
+ var rejected = (value) => {
2179
+ try {
2180
+ step(generator.throw(value));
2181
+ } catch (e) {
2182
+ reject(e);
2183
+ }
2184
+ };
2185
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2186
+ step((generator = generator.apply(__this, __arguments)).next());
2187
+ });
2188
+ };
2404
2189
  const FEATURE_REQUEST_PARAMS = {
2405
2190
  srs: 4326,
2406
2191
  geom_format: "geojson"
@@ -2441,10 +2226,9 @@ function updateItemRequestParam(params, options) {
2441
2226
  }
2442
2227
  }
2443
2228
  function createFeatureFieldFilterQueries(opt) {
2444
- const queries = getQueries(
2445
- opt
2446
- );
2447
- return CancelablePromise.all(queries).then((itemsParts) => {
2229
+ return __async$p(this, null, function* () {
2230
+ const queries = getQueries(opt);
2231
+ const itemsParts = yield Promise.all(queries);
2448
2232
  const ids = [];
2449
2233
  const items = [];
2450
2234
  for (const part of itemsParts) {
@@ -2486,13 +2270,13 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2486
2270
  for (const f of filters_) {
2487
2271
  if (isPropertyFilter(f)) {
2488
2272
  _queries.push(
2489
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$q({}, opt), {
2273
+ fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2490
2274
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
2491
2275
  }))
2492
2276
  );
2493
2277
  } else {
2494
2278
  getQueries(
2495
- __spreadProps$e(__spreadValues$q({}, opt), {
2279
+ __spreadProps$e(__spreadValues$r({}, opt), {
2496
2280
  filters: f
2497
2281
  }),
2498
2282
  _queries,
@@ -2513,7 +2297,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2513
2297
  if (propertiesFilterList.length) {
2514
2298
  for (const x of propertiesFilterList) {
2515
2299
  getQueries(
2516
- __spreadProps$e(__spreadValues$q({}, opt), {
2300
+ __spreadProps$e(__spreadValues$r({}, opt), {
2517
2301
  filters: x
2518
2302
  }),
2519
2303
  _queries,
@@ -2522,7 +2306,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2522
2306
  }
2523
2307
  } else {
2524
2308
  _queries.push(
2525
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$q({}, opt), {
2309
+ fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2526
2310
  paramList: [..._parentAllParams, ...paramList, ...filters2]
2527
2311
  }))
2528
2312
  );
@@ -2538,7 +2322,7 @@ function createWktFromCoordArray(coord) {
2538
2322
  return `POLYGON((${polygon.join(", ")}))`;
2539
2323
  }
2540
2324
  function fetchNgwLayerItemsRequest(options) {
2541
- const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2325
+ const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2542
2326
  const {
2543
2327
  limit,
2544
2328
  cache,
@@ -2577,7 +2361,7 @@ function fetchNgwLayerItemsRequest(options) {
2577
2361
  if (paramList) {
2578
2362
  params.paramList = paramList;
2579
2363
  }
2580
- const reqParams = __spreadValues$q({
2364
+ const reqParams = __spreadValues$r({
2581
2365
  id: resourceId
2582
2366
  }, params);
2583
2367
  return connector.get(
@@ -2590,52 +2374,90 @@ function fetchNgwLayerItemsRequest(options) {
2590
2374
  var __defProp$A = Object.defineProperty;
2591
2375
  var __defProps$d = Object.defineProperties;
2592
2376
  var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
2593
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2594
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2595
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2377
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2378
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2379
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2596
2380
  var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2597
- var __spreadValues$p = (a, b) => {
2381
+ var __spreadValues$q = (a, b) => {
2598
2382
  for (var prop in b || (b = {}))
2599
- if (__hasOwnProp$q.call(b, prop))
2383
+ if (__hasOwnProp$r.call(b, prop))
2600
2384
  __defNormalProp$A(a, prop, b[prop]);
2601
- if (__getOwnPropSymbols$q)
2602
- for (var prop of __getOwnPropSymbols$q(b)) {
2603
- if (__propIsEnum$q.call(b, prop))
2385
+ if (__getOwnPropSymbols$r)
2386
+ for (var prop of __getOwnPropSymbols$r(b)) {
2387
+ if (__propIsEnum$r.call(b, prop))
2604
2388
  __defNormalProp$A(a, prop, b[prop]);
2605
2389
  }
2606
2390
  return a;
2607
2391
  };
2608
2392
  var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
2393
+ var __async$o = (__this, __arguments, generator) => {
2394
+ return new Promise((resolve, reject) => {
2395
+ var fulfilled = (value) => {
2396
+ try {
2397
+ step(generator.next(value));
2398
+ } catch (e) {
2399
+ reject(e);
2400
+ }
2401
+ };
2402
+ var rejected = (value) => {
2403
+ try {
2404
+ step(generator.throw(value));
2405
+ } catch (e) {
2406
+ reject(e);
2407
+ }
2408
+ };
2409
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2410
+ step((generator = generator.apply(__this, __arguments)).next());
2411
+ });
2412
+ };
2609
2413
  function fetchNgwLayerItem(options) {
2610
- const params = __spreadValues$p({}, FEATURE_REQUEST_PARAMS);
2611
- updateItemRequestParam(params, options);
2612
- const queryParams = __spreadValues$p({
2613
- id: options.resourceId,
2614
- fid: options.featureId
2615
- }, params);
2616
- const cache = options.cache || true;
2617
- return options.connector.get("feature_layer.feature.item", { cache }, queryParams).then((resp) => {
2618
- return __spreadProps$d(__spreadValues$p({}, resp), {
2619
- toGeojson: () => {
2620
- if (resp.geom) {
2621
- return CancelablePromise.resolve(createGeoJsonFeature(resp));
2622
- } else {
2623
- return fetchNgwLayerItem(__spreadProps$d(__spreadValues$p({}, options), {
2624
- geom: true,
2625
- fields: null,
2626
- extensions: null
2627
- })).then((onlyGeomItem) => {
2628
- const geom = onlyGeomItem.geom;
2629
- return createGeoJsonFeature(__spreadProps$d(__spreadValues$p({}, resp), { geom }));
2630
- });
2631
- }
2414
+ return __async$o(this, null, function* () {
2415
+ const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2416
+ updateItemRequestParam(params, options);
2417
+ const queryParams = __spreadValues$q({
2418
+ id: options.resourceId,
2419
+ fid: options.featureId
2420
+ }, params);
2421
+ const resp = yield options.connector.get(
2422
+ "feature_layer.feature.item",
2423
+ options,
2424
+ queryParams
2425
+ );
2426
+ const toGeojson = () => __async$o(this, null, function* () {
2427
+ if (resp.geom) {
2428
+ return createGeoJsonFeature(resp);
2429
+ } else {
2430
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$d(__spreadValues$q({}, options), {
2431
+ geom: true,
2432
+ fields: null,
2433
+ extensions: null
2434
+ }));
2435
+ const geom = onlyGeomItem.geom;
2436
+ return createGeoJsonFeature(__spreadProps$d(__spreadValues$q({}, resp), { geom }));
2632
2437
  }
2633
2438
  });
2439
+ return __spreadProps$d(__spreadValues$q({}, resp), {
2440
+ toGeojson
2441
+ });
2634
2442
  });
2635
2443
  }
2636
2444
 
2637
2445
  var __defProp$z = Object.defineProperty;
2446
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2447
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2448
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2638
2449
  var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2450
+ var __spreadValues$p = (a, b) => {
2451
+ for (var prop in b || (b = {}))
2452
+ if (__hasOwnProp$q.call(b, prop))
2453
+ __defNormalProp$z(a, prop, b[prop]);
2454
+ if (__getOwnPropSymbols$q)
2455
+ for (var prop of __getOwnPropSymbols$q(b)) {
2456
+ if (__propIsEnum$q.call(b, prop))
2457
+ __defNormalProp$z(a, prop, b[prop]);
2458
+ }
2459
+ return a;
2460
+ };
2639
2461
  var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2640
2462
  class BookmarkItem {
2641
2463
  constructor(options) {
@@ -2653,11 +2475,11 @@ class BookmarkItem {
2653
2475
  this.name = String(item.id);
2654
2476
  }
2655
2477
  }
2656
- extent() {
2478
+ extent(opt) {
2657
2479
  if (this._extent) {
2658
- return CancelablePromise.resolve(this._extent);
2480
+ return Promise.resolve(this._extent);
2659
2481
  }
2660
- return this.options.connector.get("feature_layer.feature.item_extent", null, {
2482
+ return this.options.connector.get("feature_layer.feature.item_extent", opt, {
2661
2483
  id: this.resourceId,
2662
2484
  fid: this.item.id
2663
2485
  }).then((resp) => {
@@ -2667,18 +2489,18 @@ class BookmarkItem {
2667
2489
  return lonLat;
2668
2490
  });
2669
2491
  }
2670
- geoJson() {
2492
+ geoJson(opt) {
2671
2493
  if (this.item.geom) {
2672
- return CancelablePromise.resolve(createGeoJsonFeature(this.item));
2494
+ return Promise.resolve(createGeoJsonFeature(this.item));
2673
2495
  } else {
2674
- return fetchNgwLayerItem({
2496
+ return fetchNgwLayerItem(__spreadValues$p({
2675
2497
  resourceId: this.resourceId,
2676
2498
  featureId: this.item.id,
2677
2499
  connector: this.options.connector,
2678
2500
  geom: true,
2679
2501
  fields: null,
2680
2502
  extensions: null
2681
- }).then((onlyGeomItem) => {
2503
+ }, opt)).then((onlyGeomItem) => {
2682
2504
  const geom = onlyGeomItem.geom;
2683
2505
  this.item.geom = geom;
2684
2506
  return createGeoJsonFeature(this.item);
@@ -3308,9 +3130,10 @@ function getNgwWebmapExtent(webmap) {
3308
3130
  function fetchNgwLayerExtent({
3309
3131
  resourceId,
3310
3132
  connector,
3311
- cache = true
3133
+ cache = true,
3134
+ signal
3312
3135
  }) {
3313
- return connector.get("layer.extent", { cache }, { id: resourceId }).then((resp) => {
3136
+ return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3314
3137
  if (resp) {
3315
3138
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3316
3139
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3322,11 +3145,12 @@ function fetchNgwLayerItemExtent({
3322
3145
  resourceId,
3323
3146
  featureId,
3324
3147
  connector,
3325
- cache = true
3148
+ cache = true,
3149
+ signal
3326
3150
  }) {
3327
3151
  return connector.get(
3328
3152
  "feature_layer.feature.item_extent",
3329
- { cache },
3153
+ { cache, signal },
3330
3154
  { id: resourceId, fid: featureId }
3331
3155
  ).then((resp) => {
3332
3156
  if (resp) {
@@ -3337,7 +3161,10 @@ function fetchNgwLayerItemExtent({
3337
3161
  });
3338
3162
  }
3339
3163
  function fetchNgwExtent(options) {
3340
- return options.connector.getResource(options.resourceId).then((resource) => {
3164
+ return options.connector.getResource(options.resourceId, {
3165
+ signal: options.signal,
3166
+ cache: options.cache
3167
+ }).then((resource) => {
3341
3168
  if (resource) {
3342
3169
  return fetchNgwResourceExtent(resource, options.connector, options);
3343
3170
  }
@@ -3345,11 +3172,11 @@ function fetchNgwExtent(options) {
3345
3172
  }
3346
3173
  function fetchNgwResourceExtent(item, connector, options) {
3347
3174
  if (item.webmap) {
3348
- return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
3175
+ return Promise.resolve(getNgwWebmapExtent(item.webmap));
3349
3176
  } else {
3350
3177
  const resource = item.resource;
3351
3178
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3352
- return connector.getResource(resource.parent.id).then((res) => {
3179
+ return connector.getResource(resource.parent.id, options).then((res) => {
3353
3180
  if (res) {
3354
3181
  return fetchNgwLayerExtent(__spreadProps$c(__spreadValues$l({}, options), {
3355
3182
  resourceId: res.resource.id,
@@ -3369,7 +3196,7 @@ function fetchNgwResourceExtent(item, connector, options) {
3369
3196
  var __defProp$s = Object.defineProperty;
3370
3197
  var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3371
3198
  var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3372
- var __async$k = (__this, __arguments, generator) => {
3199
+ var __async$n = (__this, __arguments, generator) => {
3373
3200
  return new Promise((resolve, reject) => {
3374
3201
  var fulfilled = (value) => {
3375
3202
  try {
@@ -3397,12 +3224,12 @@ class NgwResource {
3397
3224
  }
3398
3225
  /** @deprecated use {@link NgwResource.getBounds} instead */
3399
3226
  getExtent() {
3400
- return __async$k(this, null, function* () {
3227
+ return __async$n(this, null, function* () {
3401
3228
  return this.getBounds();
3402
3229
  });
3403
3230
  }
3404
3231
  getBounds(options) {
3405
- return __async$k(this, null, function* () {
3232
+ return __async$n(this, null, function* () {
3406
3233
  if (this._extent) {
3407
3234
  return this._extent;
3408
3235
  }
@@ -3418,7 +3245,7 @@ class NgwResource {
3418
3245
  }
3419
3246
  }
3420
3247
 
3421
- var __async$j = (__this, __arguments, generator) => {
3248
+ var __async$m = (__this, __arguments, generator) => {
3422
3249
  return new Promise((resolve, reject) => {
3423
3250
  var fulfilled = (value) => {
3424
3251
  try {
@@ -3439,7 +3266,7 @@ var __async$j = (__this, __arguments, generator) => {
3439
3266
  });
3440
3267
  };
3441
3268
  function resourceIdFromLayerOptions(options, connector) {
3442
- return __async$j(this, null, function* () {
3269
+ return __async$m(this, null, function* () {
3443
3270
  const resource = options.resource;
3444
3271
  const item = resource;
3445
3272
  let { keyname, resourceId } = options;
@@ -3541,7 +3368,7 @@ var __objRest$1 = (source, exclude) => {
3541
3368
  return target;
3542
3369
  };
3543
3370
  var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3544
- var __async$i = (__this, __arguments, generator) => {
3371
+ var __async$l = (__this, __arguments, generator) => {
3545
3372
  return new Promise((resolve, reject) => {
3546
3373
  var fulfilled = (value) => {
3547
3374
  try {
@@ -3593,7 +3420,7 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3593
3420
  }
3594
3421
  }
3595
3422
  addLayer(options) {
3596
- return __async$i(this, null, function* () {
3423
+ return __async$l(this, null, function* () {
3597
3424
  if (!this.qms && options.qmsId) {
3598
3425
  try {
3599
3426
  this.qms = yield loadJson(
@@ -3701,7 +3528,7 @@ var __spreadValues$i = (a, b) => {
3701
3528
  };
3702
3529
  var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
3703
3530
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3704
- var __async$h = (__this, __arguments, generator) => {
3531
+ var __async$k = (__this, __arguments, generator) => {
3705
3532
  return new Promise((resolve, reject) => {
3706
3533
  var fulfilled = (value) => {
3707
3534
  try {
@@ -3722,7 +3549,7 @@ var __async$h = (__this, __arguments, generator) => {
3722
3549
  });
3723
3550
  };
3724
3551
  function createBasemapLayerAdapter(_0) {
3725
- return __async$h(this, arguments, function* ({
3552
+ return __async$k(this, arguments, function* ({
3726
3553
  webMap,
3727
3554
  item
3728
3555
  }) {
@@ -3743,7 +3570,7 @@ function createBasemapLayerAdapter(_0) {
3743
3570
  if (TileAdapter) {
3744
3571
  class BasemapTileAdapter extends TileAdapter {
3745
3572
  addLayer(opt) {
3746
- return __async$h(this, null, function* () {
3573
+ return __async$k(this, null, function* () {
3747
3574
  return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$b(__spreadValues$i({}, opt), { url }));
3748
3575
  });
3749
3576
  }
@@ -3783,11 +3610,12 @@ function createPopupContent(feature, item) {
3783
3610
  function fetchNgwLayerCount({
3784
3611
  connector,
3785
3612
  resourceId,
3786
- cache = true
3613
+ cache = true,
3614
+ signal
3787
3615
  }) {
3788
3616
  return connector.get(
3789
3617
  "feature_layer.feature.count",
3790
- { cache },
3618
+ { cache, signal },
3791
3619
  {
3792
3620
  id: resourceId
3793
3621
  }
@@ -3841,13 +3669,34 @@ var __spreadValues$h = (a, b) => {
3841
3669
  return a;
3842
3670
  };
3843
3671
  var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
3672
+ var __async$j = (__this, __arguments, generator) => {
3673
+ return new Promise((resolve, reject) => {
3674
+ var fulfilled = (value) => {
3675
+ try {
3676
+ step(generator.next(value));
3677
+ } catch (e) {
3678
+ reject(e);
3679
+ }
3680
+ };
3681
+ var rejected = (value) => {
3682
+ try {
3683
+ step(generator.throw(value));
3684
+ } catch (e) {
3685
+ reject(e);
3686
+ }
3687
+ };
3688
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3689
+ step((generator = generator.apply(__this, __arguments)).next());
3690
+ });
3691
+ };
3844
3692
  function fetchNgwLayerItems(options) {
3845
- const filters = options.filters;
3846
- if (filters) {
3847
- return createFeatureFieldFilterQueries(__spreadProps$a(__spreadValues$h({}, options), {
3848
- filters
3849
- })).then((data) => {
3850
- var _a;
3693
+ return __async$j(this, null, function* () {
3694
+ var _a;
3695
+ const filters = options.filters;
3696
+ if (filters) {
3697
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$a(__spreadValues$h({}, options), {
3698
+ filters
3699
+ }));
3851
3700
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3852
3701
  if (clientFilterValidate) {
3853
3702
  data = data.filter((y) => {
@@ -3859,10 +3708,10 @@ function fetchNgwLayerItems(options) {
3859
3708
  });
3860
3709
  }
3861
3710
  return data;
3862
- });
3863
- } else {
3864
- return fetchNgwLayerItemsRequest(options);
3865
- }
3711
+ } else {
3712
+ return fetchNgwLayerItemsRequest(options);
3713
+ }
3714
+ });
3866
3715
  }
3867
3716
  function isFilterWithAnyCase(filters) {
3868
3717
  if (filters[0] === "any") {
@@ -3880,8 +3729,29 @@ function isFilterWithAnyCase(filters) {
3880
3729
  return false;
3881
3730
  }
3882
3731
 
3732
+ var __async$i = (__this, __arguments, generator) => {
3733
+ return new Promise((resolve, reject) => {
3734
+ var fulfilled = (value) => {
3735
+ try {
3736
+ step(generator.next(value));
3737
+ } catch (e) {
3738
+ reject(e);
3739
+ }
3740
+ };
3741
+ var rejected = (value) => {
3742
+ try {
3743
+ step(generator.throw(value));
3744
+ } catch (e) {
3745
+ reject(e);
3746
+ }
3747
+ };
3748
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3749
+ step((generator = generator.apply(__this, __arguments)).next());
3750
+ });
3751
+ };
3883
3752
  function fetchNgwLayerFeatures(options) {
3884
- return fetchNgwLayerItems(options).then((x) => {
3753
+ return __async$i(this, null, function* () {
3754
+ const x = yield fetchNgwLayerItems(options);
3885
3755
  const features = [];
3886
3756
  x.forEach((y) => {
3887
3757
  features.push(createGeoJsonFeature(y));
@@ -3941,7 +3811,7 @@ var __spreadValues$g = (a, b) => {
3941
3811
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3942
3812
  var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
3943
3813
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3944
- var __async$g = (__this, __arguments, generator) => {
3814
+ var __async$h = (__this, __arguments, generator) => {
3945
3815
  return new Promise((resolve, reject) => {
3946
3816
  var fulfilled = (value) => {
3947
3817
  try {
@@ -3962,7 +3832,7 @@ var __async$g = (__this, __arguments, generator) => {
3962
3832
  });
3963
3833
  };
3964
3834
  function createGeoJsonAdapter(props) {
3965
- return __async$g(this, null, function* () {
3835
+ return __async$h(this, null, function* () {
3966
3836
  var _a, _b;
3967
3837
  const {
3968
3838
  item,
@@ -3978,29 +3848,35 @@ function createGeoJsonAdapter(props) {
3978
3848
  const _loadedIds = [];
3979
3849
  let _fullDataLoad = false;
3980
3850
  let _lastFilterArgs;
3981
- let _dataPromise;
3851
+ let internalAbortController;
3982
3852
  const resourceId = yield resourceIdFromLayerOptions(options, connector);
3983
3853
  if ((_b = (_a = options.adapterOptions) == null ? void 0 : _a.popupOptions) == null ? void 0 : _b.fromProperties) {
3984
3854
  options.adapterOptions.popupOptions.createPopupContent = ({ feature }) => {
3985
3855
  return feature && createPopupContent(feature, item);
3986
3856
  };
3987
3857
  }
3988
- const getData = (filters, filterOpt) => __async$g(this, null, function* () {
3858
+ const getData = (filters, filterOpt) => __async$h(this, null, function* () {
3989
3859
  abort();
3860
+ internalAbortController = new AbortController();
3861
+ const internalSignal = internalAbortController.signal;
3862
+ if (filterOpt == null ? void 0 : filterOpt.signal) {
3863
+ filterOpt.signal.addEventListener("abort", internalAbortController.abort);
3864
+ }
3865
+ filterOpt = filterOpt || {};
3866
+ filterOpt.signal = internalSignal;
3990
3867
  _lastFilterArgs = { filters, options: filterOpt };
3991
- _dataPromise = fetchNgwLayerFeatureCollection(__spreadValues$g({
3868
+ return fetchNgwLayerFeatureCollection(__spreadValues$g({
3992
3869
  resourceId,
3993
3870
  filters,
3994
3871
  connector,
3995
3872
  cache: true
3996
3873
  }, filterOpt));
3997
- return yield _dataPromise;
3998
3874
  });
3999
3875
  let removed = false;
4000
3876
  const abort = () => {
4001
- if (_dataPromise) {
4002
- _dataPromise.cancel();
4003
- _dataPromise = void 0;
3877
+ if (internalAbortController) {
3878
+ internalAbortController.abort();
3879
+ internalAbortController = void 0;
4004
3880
  }
4005
3881
  };
4006
3882
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
@@ -4013,7 +3889,7 @@ function createGeoJsonAdapter(props) {
4013
3889
  __publicField$f(this, "__disableMapMoveListener");
4014
3890
  }
4015
3891
  addLayer(opt) {
4016
- return __async$g(this, null, function* () {
3892
+ return __async$h(this, null, function* () {
4017
3893
  let needUpdate = !opt.data;
4018
3894
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
4019
3895
  if (options.id !== void 0) {
@@ -4058,7 +3934,7 @@ function createGeoJsonAdapter(props) {
4058
3934
  return this.getBounds();
4059
3935
  }
4060
3936
  getBounds() {
4061
- return __async$g(this, null, function* () {
3937
+ return __async$h(this, null, function* () {
4062
3938
  const hasData = this.getLayers && this.getLayers().length;
4063
3939
  const strategy = this.options.strategy;
4064
3940
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -4084,7 +3960,7 @@ function createGeoJsonAdapter(props) {
4084
3960
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4085
3961
  }
4086
3962
  updateLayer(filterArgs) {
4087
- return __async$g(this, null, function* () {
3963
+ return __async$h(this, null, function* () {
4088
3964
  var _a2;
4089
3965
  filterArgs = filterArgs || _lastFilterArgs || {};
4090
3966
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
@@ -4150,7 +4026,7 @@ function createGeoJsonAdapter(props) {
4150
4026
  });
4151
4027
  }
4152
4028
  propertiesFilter(filters, opt) {
4153
- return __async$g(this, null, function* () {
4029
+ return __async$h(this, null, function* () {
4154
4030
  abort();
4155
4031
  if (this.filter && _fullDataLoad) {
4156
4032
  this.filter((e) => {
@@ -4224,7 +4100,7 @@ function createGeoJsonAdapter(props) {
4224
4100
  });
4225
4101
  }
4226
4102
 
4227
- var __async$f = (__this, __arguments, generator) => {
4103
+ var __async$g = (__this, __arguments, generator) => {
4228
4104
  return new Promise((resolve, reject) => {
4229
4105
  var fulfilled = (value) => {
4230
4106
  try {
@@ -4245,7 +4121,7 @@ var __async$f = (__this, __arguments, generator) => {
4245
4121
  });
4246
4122
  };
4247
4123
  function createWebMapAdapter(_0) {
4248
- return __async$f(this, arguments, function* ({
4124
+ return __async$g(this, arguments, function* ({
4249
4125
  layerOptions: options,
4250
4126
  webMap,
4251
4127
  connector
@@ -4373,7 +4249,7 @@ var __spreadValues$f = (a, b) => {
4373
4249
  };
4374
4250
  var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4375
4251
  var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4376
- var __async$e = (__this, __arguments, generator) => {
4252
+ var __async$f = (__this, __arguments, generator) => {
4377
4253
  return new Promise((resolve, reject) => {
4378
4254
  var fulfilled = (value) => {
4379
4255
  try {
@@ -4394,7 +4270,7 @@ var __async$e = (__this, __arguments, generator) => {
4394
4270
  });
4395
4271
  };
4396
4272
  function createRasterAdapter(_0) {
4397
- return __async$e(this, arguments, function* ({
4273
+ return __async$f(this, arguments, function* ({
4398
4274
  layerOptions,
4399
4275
  webMap,
4400
4276
  connector,
@@ -4450,7 +4326,7 @@ function createRasterAdapter(_0) {
4450
4326
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4451
4327
  }
4452
4328
  getLegend(options) {
4453
- return __async$e(this, null, function* () {
4329
+ return __async$f(this, null, function* () {
4454
4330
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4455
4331
  params: { id: resourceId },
4456
4332
  cache: true
@@ -4470,7 +4346,7 @@ function createRasterAdapter(_0) {
4470
4346
  });
4471
4347
  }
4472
4348
  getIdentificationIds() {
4473
- return __async$e(this, null, function* () {
4349
+ return __async$f(this, null, function* () {
4474
4350
  if (this.item) {
4475
4351
  if (adapter === "MVT") {
4476
4352
  return [this.item.resource.id];
@@ -4511,7 +4387,7 @@ var __spreadValues$e = (a, b) => {
4511
4387
  return a;
4512
4388
  };
4513
4389
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
4514
- var __async$d = (__this, __arguments, generator) => {
4390
+ var __async$e = (__this, __arguments, generator) => {
4515
4391
  return new Promise((resolve, reject) => {
4516
4392
  var fulfilled = (value) => {
4517
4393
  try {
@@ -4547,7 +4423,7 @@ const supportCls = [
4547
4423
  "tmsclient_layer"
4548
4424
  ];
4549
4425
  function createAdapterFromFirstStyle(_0) {
4550
- return __async$d(this, arguments, function* ({
4426
+ return __async$e(this, arguments, function* ({
4551
4427
  layerOptions,
4552
4428
  webMap,
4553
4429
  connector,
@@ -4566,7 +4442,7 @@ function createAdapterFromFirstStyle(_0) {
4566
4442
  });
4567
4443
  }
4568
4444
  function createAsyncAdapter(options, webMap, connector) {
4569
- return __async$d(this, null, function* () {
4445
+ return __async$e(this, null, function* () {
4570
4446
  let adapter;
4571
4447
  let item;
4572
4448
  const adapterType = options.adapter;
@@ -4769,7 +4645,7 @@ var __spreadValues$c = (a, b) => {
4769
4645
  };
4770
4646
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4771
4647
  var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4772
- var __async$c = (__this, __arguments, generator) => {
4648
+ var __async$d = (__this, __arguments, generator) => {
4773
4649
  return new Promise((resolve, reject) => {
4774
4650
  var fulfilled = (value) => {
4775
4651
  try {
@@ -4819,7 +4695,7 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4819
4695
  }
4820
4696
  }
4821
4697
  static create(webMap, item, options, connector, parent) {
4822
- return __async$c(this, null, function* () {
4698
+ return __async$d(this, null, function* () {
4823
4699
  const ngwWebmapItem = new _NgwWebmapItem(
4824
4700
  webMap,
4825
4701
  item,
@@ -4848,15 +4724,14 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4848
4724
  return this.layer;
4849
4725
  }
4850
4726
  getLegend(options) {
4851
- return __async$c(this, null, function* () {
4727
+ return __async$d(this, null, function* () {
4852
4728
  var _a;
4853
4729
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4854
4730
  if (id !== void 0) {
4855
4731
  const connector = this.connector;
4856
4732
  if (connector) {
4857
4733
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4858
- params: { id: this.item.resourceId },
4859
- cache: true
4734
+ params: { id: this.item.resourceId }
4860
4735
  }, options));
4861
4736
  const legend = {
4862
4737
  layerId: id,
@@ -5044,7 +4919,7 @@ var __spreadValues$b = (a, b) => {
5044
4919
  return a;
5045
4920
  };
5046
4921
  var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5047
- var __async$b = (__this, __arguments, generator) => {
4922
+ var __async$c = (__this, __arguments, generator) => {
5048
4923
  return new Promise((resolve, reject) => {
5049
4924
  var fulfilled = (value) => {
5050
4925
  try {
@@ -5065,7 +4940,7 @@ var __async$b = (__this, __arguments, generator) => {
5065
4940
  });
5066
4941
  };
5067
4942
  function createOnFirstShowAdapter(_0) {
5068
- return __async$b(this, arguments, function* ({
4943
+ return __async$c(this, arguments, function* ({
5069
4944
  webMap,
5070
4945
  adapterOptions = {},
5071
4946
  onLayerAdded,
@@ -5091,7 +4966,7 @@ function createOnFirstShowAdapter(_0) {
5091
4966
  return this._removed;
5092
4967
  }
5093
4968
  showLayer() {
5094
- return __async$b(this, null, function* () {
4969
+ return __async$c(this, null, function* () {
5095
4970
  this.options.visibility = true;
5096
4971
  if (this.layer.length) {
5097
4972
  for (const x of this.layer) {
@@ -5103,7 +4978,7 @@ function createOnFirstShowAdapter(_0) {
5103
4978
  });
5104
4979
  }
5105
4980
  hideLayer() {
5106
- return __async$b(this, null, function* () {
4981
+ return __async$c(this, null, function* () {
5107
4982
  this.options.visibility = false;
5108
4983
  if (this.layer) {
5109
4984
  for (const x of this.layer) {
@@ -5113,7 +4988,7 @@ function createOnFirstShowAdapter(_0) {
5113
4988
  });
5114
4989
  }
5115
4990
  loadLayer() {
5116
- return __async$b(this, null, function* () {
4991
+ return __async$c(this, null, function* () {
5117
4992
  if (!this.layer.length && !this._creatingInProgress) {
5118
4993
  this._creatingInProgress = true;
5119
4994
  const Adapter = yield createAdapter(this);
@@ -5147,7 +5022,7 @@ function createOnFirstShowAdapter(_0) {
5147
5022
  });
5148
5023
  }
5149
5024
 
5150
- var __async$a = (__this, __arguments, generator) => {
5025
+ var __async$b = (__this, __arguments, generator) => {
5151
5026
  return new Promise((resolve, reject) => {
5152
5027
  var fulfilled = (value) => {
5153
5028
  try {
@@ -5168,7 +5043,7 @@ var __async$a = (__this, __arguments, generator) => {
5168
5043
  });
5169
5044
  };
5170
5045
  function createOnFirstShowNgwAdapter(_0) {
5171
- return __async$a(this, arguments, function* ({
5046
+ return __async$b(this, arguments, function* ({
5172
5047
  webMap,
5173
5048
  connector,
5174
5049
  item,
@@ -5224,7 +5099,7 @@ var __spreadValues$a = (a, b) => {
5224
5099
  };
5225
5100
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5226
5101
  var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5227
- var __async$9 = (__this, __arguments, generator) => {
5102
+ var __async$a = (__this, __arguments, generator) => {
5228
5103
  return new Promise((resolve, reject) => {
5229
5104
  var fulfilled = (value) => {
5230
5105
  try {
@@ -5275,7 +5150,7 @@ class NgwWebmapLayerAdapter {
5275
5150
  }
5276
5151
  }
5277
5152
  addLayer(options) {
5278
- return __async$9(this, null, function* () {
5153
+ return __async$a(this, null, function* () {
5279
5154
  var _a, _b;
5280
5155
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5281
5156
  this.layer = yield this._getWebMapLayerItem();
@@ -5308,21 +5183,21 @@ class NgwWebmapLayerAdapter {
5308
5183
  delete this._webmapLayersIds;
5309
5184
  }
5310
5185
  showLayer() {
5311
- return __async$9(this, null, function* () {
5186
+ return __async$a(this, null, function* () {
5312
5187
  if (this.layer && this.layer.properties) {
5313
5188
  return this.layer.properties.property("visibility").set(true);
5314
5189
  }
5315
5190
  });
5316
5191
  }
5317
5192
  hideLayer() {
5318
- return __async$9(this, null, function* () {
5193
+ return __async$a(this, null, function* () {
5319
5194
  if (this.layer && this.layer.properties) {
5320
5195
  return this.layer.properties.property("visibility").set(false);
5321
5196
  }
5322
5197
  });
5323
5198
  }
5324
5199
  setOpacity(val) {
5325
- return __async$9(this, null, function* () {
5200
+ return __async$a(this, null, function* () {
5326
5201
  if (this.layer && this.layer.properties) {
5327
5202
  return this.layer.properties.property("opacity").set(val);
5328
5203
  }
@@ -5347,22 +5222,22 @@ class NgwWebmapLayerAdapter {
5347
5222
  return webmap.bookmark_resource.id;
5348
5223
  }
5349
5224
  }
5350
- fetchBookmarks() {
5225
+ fetchBookmarks(options) {
5351
5226
  const bookmarkResId = this.getBookmarksResourceId();
5352
5227
  const connector = this.options.connector;
5353
5228
  if (bookmarkResId) {
5354
- return connector.getResourceOrFail(bookmarkResId).then((item) => {
5229
+ return connector.getResourceOrFail(bookmarkResId, options).then((item) => {
5355
5230
  var _a;
5356
5231
  const labelField = (_a = item.feature_layer) == null ? void 0 : _a.fields.find(
5357
5232
  (x) => x.label_field
5358
5233
  );
5359
5234
  const keyname = labelField && labelField.keyname;
5360
- return fetchNgwLayerItems({
5235
+ return fetchNgwLayerItems(__spreadValues$a({
5361
5236
  connector,
5362
5237
  resourceId: bookmarkResId,
5363
5238
  geom: false,
5364
5239
  fields: keyname ? [keyname] : void 0
5365
- }).then((items) => {
5240
+ }, options)).then((items) => {
5366
5241
  const bookmarks = [];
5367
5242
  for (const i of items) {
5368
5243
  const bookmark = new BookmarkItem({
@@ -5381,24 +5256,24 @@ class NgwWebmapLayerAdapter {
5381
5256
  "Webmap was not loaded correctly, it is impossible to extract bookmarks"
5382
5257
  );
5383
5258
  }
5384
- getLegend() {
5385
- return __async$9(this, null, function* () {
5259
+ getLegend(options) {
5260
+ return __async$a(this, null, function* () {
5386
5261
  const legends = [];
5387
5262
  let deps = this.getDependLayers();
5388
5263
  deps = deps.sort((a, b) => b.id - a.id);
5389
5264
  for (const d of deps) {
5390
- const layerLegend = yield d.getLegend();
5265
+ const layerLegend = yield d.getLegend(options);
5391
5266
  legends.push(...layerLegend);
5392
5267
  }
5393
5268
  return legends;
5394
5269
  });
5395
5270
  }
5396
- getIdentificationIds() {
5397
- return __async$9(this, null, function* () {
5271
+ getIdentificationIds(options) {
5272
+ return __async$a(this, null, function* () {
5398
5273
  const visibleLayers = [];
5399
5274
  let ids = this._webmapLayersIds;
5400
5275
  if (!ids) {
5401
- ids = yield this._getWebMapIds();
5276
+ ids = yield this._getWebMapIds(options);
5402
5277
  this._webmapLayersIds = ids;
5403
5278
  }
5404
5279
  if (ids && ids.length) {
@@ -5420,7 +5295,7 @@ class NgwWebmapLayerAdapter {
5420
5295
  });
5421
5296
  }
5422
5297
  _getWebMapLayerItem() {
5423
- return __async$9(this, null, function* () {
5298
+ return __async$a(this, null, function* () {
5424
5299
  if (!this.resourceId) {
5425
5300
  return void 0;
5426
5301
  }
@@ -5450,7 +5325,7 @@ class NgwWebmapLayerAdapter {
5450
5325
  });
5451
5326
  }
5452
5327
  getWebMapConfig(id) {
5453
- return __async$9(this, null, function* () {
5328
+ return __async$a(this, null, function* () {
5454
5329
  const data = yield this.options.connector.getResource(id);
5455
5330
  if (data) {
5456
5331
  this.response = data;
@@ -5544,8 +5419,8 @@ class NgwWebmapLayerAdapter {
5544
5419
  }
5545
5420
  return item;
5546
5421
  }
5547
- _getWebMapIds() {
5548
- return __async$9(this, null, function* () {
5422
+ _getWebMapIds(options) {
5423
+ return __async$a(this, null, function* () {
5549
5424
  const webMapItem = this.layer;
5550
5425
  if (webMapItem && webMapItem.item.item_type === "root") {
5551
5426
  const layers = webMapItem.tree.getDescendants();
@@ -5554,7 +5429,7 @@ class NgwWebmapLayerAdapter {
5554
5429
  const item = x.item;
5555
5430
  if (item.item_type === "layer") {
5556
5431
  const id = item.layer_style_id;
5557
- const promise = this.options.connector.getResource(id).then((y) => {
5432
+ const promise = this.options.connector.getResource(id, options).then((y) => {
5558
5433
  if (y) {
5559
5434
  const parentId = Number(y.resource.parent.id);
5560
5435
  item.parentId = parentId;
@@ -5588,7 +5463,7 @@ var __spreadValues$9 = (a, b) => {
5588
5463
  return a;
5589
5464
  };
5590
5465
  var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5591
- var __async$8 = (__this, __arguments, generator) => {
5466
+ var __async$9 = (__this, __arguments, generator) => {
5592
5467
  return new Promise((resolve, reject) => {
5593
5468
  var fulfilled = (value) => {
5594
5469
  try {
@@ -5633,7 +5508,7 @@ class NgwKit {
5633
5508
  classAdapters[cls] = adapter;
5634
5509
  }
5635
5510
  onLoadSync(webMap) {
5636
- return __async$8(this, null, function* () {
5511
+ return __async$9(this, null, function* () {
5637
5512
  if (this.options.resourceId && this.url) {
5638
5513
  const resourceIds = [this.options.resourceId];
5639
5514
  if (resourceIds.length) {
@@ -5716,7 +5591,7 @@ class IdentifyItem {
5716
5591
  }
5717
5592
  identify(options = {}) {
5718
5593
  if (this._item) {
5719
- return CancelablePromise.resolve(this._item);
5594
+ return Promise.resolve(this._item);
5720
5595
  }
5721
5596
  return fetchNgwLayerItem(__spreadValues$8({
5722
5597
  connector: this.connector,
@@ -5731,30 +5606,30 @@ class IdentifyItem {
5731
5606
  return resp;
5732
5607
  });
5733
5608
  }
5734
- resource() {
5609
+ resource(opt) {
5735
5610
  if (this._resource) {
5736
- return CancelablePromise.resolve(this._resource.feature_layer);
5611
+ return Promise.resolve(this._resource.feature_layer);
5737
5612
  }
5738
- return this.connector.getResource(this.layerId).then((resp) => {
5613
+ return this.connector.getResource(this.layerId, opt).then((resp) => {
5739
5614
  this._resource = resp;
5740
5615
  return this._resource.feature_layer;
5741
5616
  });
5742
5617
  }
5743
- getBounds() {
5618
+ getBounds(opt) {
5744
5619
  if (this._extent) {
5745
- return CancelablePromise.resolve(this._extent);
5620
+ return Promise.resolve(this._extent);
5746
5621
  }
5747
- return fetchNgwLayerItemExtent({
5622
+ return fetchNgwLayerItemExtent(__spreadValues$8({
5748
5623
  connector: this.connector,
5749
5624
  featureId: this.id,
5750
5625
  resourceId: this.layerId
5751
- });
5626
+ }, opt));
5752
5627
  }
5753
- geojson() {
5628
+ geojson(options) {
5754
5629
  if (this._geojson) {
5755
- return CancelablePromise.resolve(this._geojson);
5630
+ return Promise.resolve(this._geojson);
5756
5631
  }
5757
- return this.identify().then((resp) => {
5632
+ return this.identify(options).then((resp) => {
5758
5633
  return resp.toGeojson().then((geojson) => {
5759
5634
  this._geojson = geojson;
5760
5635
  return geojson;
@@ -5763,8 +5638,29 @@ class IdentifyItem {
5763
5638
  }
5764
5639
  }
5765
5640
 
5641
+ var __async$8 = (__this, __arguments, generator) => {
5642
+ return new Promise((resolve, reject) => {
5643
+ var fulfilled = (value) => {
5644
+ try {
5645
+ step(generator.next(value));
5646
+ } catch (e) {
5647
+ reject(e);
5648
+ }
5649
+ };
5650
+ var rejected = (value) => {
5651
+ try {
5652
+ step(generator.throw(value));
5653
+ } catch (e) {
5654
+ reject(e);
5655
+ }
5656
+ };
5657
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
5658
+ step((generator = generator.apply(__this, __arguments)).next());
5659
+ });
5660
+ };
5766
5661
  function fetchNgwLayerFeature(options) {
5767
- return fetchNgwLayerItem(options).then((item) => {
5662
+ return __async$8(this, null, function* () {
5663
+ const item = yield fetchNgwLayerItem(options);
5768
5664
  return createGeoJsonFeature(item);
5769
5665
  });
5770
5666
  }
@@ -5849,7 +5745,7 @@ function fetchIdentifyGeoJson(options) {
5849
5745
  const withGeom = item.features.find((x) => x.geom);
5850
5746
  if (withGeom && withGeom.geom) {
5851
5747
  const geom = withGeom.geom;
5852
- return CancelablePromise.resolve(
5748
+ return Promise.resolve(
5853
5749
  createGeoJsonFeature(__spreadProps$4(__spreadValues$7({}, withGeom), {
5854
5750
  geom
5855
5751
  }))
@@ -5862,7 +5758,7 @@ function fetchIdentifyGeoJson(options) {
5862
5758
  if (params && params.length) {
5863
5759
  return fetchNgwLayerFeature(__spreadValues$7(__spreadProps$4(__spreadValues$7({}, requestOptions), { connector }), params[0]));
5864
5760
  }
5865
- return CancelablePromise.resolve(void 0);
5761
+ return Promise.resolve(void 0);
5866
5762
  }
5867
5763
  function fetchIdentifyItem(options) {
5868
5764
  const { connector, identify } = options;
@@ -5872,7 +5768,7 @@ function fetchIdentifyItem(options) {
5872
5768
  connector
5873
5769
  }, options.requestOptions), params[0]));
5874
5770
  }
5875
- return CancelablePromise.resolve(void 0);
5771
+ return Promise.resolve(void 0);
5876
5772
  }
5877
5773
  function featureLayerIdentify(options) {
5878
5774
  const { geom, signal, cache, layers } = options;
@@ -5916,9 +5812,9 @@ function getPolygonCoordinates(geom) {
5916
5812
  function sendIdentifyRequest(ev, options) {
5917
5813
  deprecatedMapClick(ev);
5918
5814
  const [lng, lat] = ev.lngLat;
5919
- const { geom, radius, signal, cache } = options;
5815
+ const { geom, radius } = options;
5920
5816
  const geom_ = geom != null ? geom : getCirclePolygonCoordinates(lng, lat, radius);
5921
- return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_, signal, cache }));
5817
+ return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_ }));
5922
5818
  }
5923
5819
  function createIdentifyItem(opt) {
5924
5820
  return new IdentifyItem(opt);
@@ -7128,7 +7024,7 @@ const _WebMapMain = class _WebMapMain {
7128
7024
  __publicField$3(this, "_mapState", []);
7129
7025
  __publicField$3(this, "_extent");
7130
7026
  __publicField$3(this, "_eventsStatus", {});
7131
- __publicField$3(this, "_coordFromMapClickPromise");
7027
+ __publicField$3(this, "_coordFromMapClickAbort");
7132
7028
  __publicField$3(this, "_mapEvents", {});
7133
7029
  this.mapAdapter = mapOptions.mapAdapter;
7134
7030
  this._starterKits = mapOptions.starterKits || [];
@@ -7443,36 +7339,34 @@ const _WebMapMain = class _WebMapMain {
7443
7339
  return { stop };
7444
7340
  }
7445
7341
  stopGetCoordFromMapClick() {
7446
- if (this._coordFromMapClickPromise) {
7447
- this._coordFromMapClickPromise.cancel();
7342
+ if (this._coordFromMapClickAbort) {
7343
+ this._coordFromMapClickAbort();
7344
+ this._coordFromMapClickAbort = void 0;
7448
7345
  }
7449
7346
  }
7450
7347
  getCoordFromMapClick() {
7451
- if (!this._coordFromMapClickPromise) {
7452
- this._coordFromMapClickPromise = new CancelablePromise(
7453
- (resolve, reject, onCancel) => {
7454
- const cursor = this.getCursor() || "grab";
7455
- this._removeEventListeners({ include: ["click"] });
7456
- this.setCursor("crosshair");
7457
- const onCancel_ = () => {
7458
- this.setCursor(cursor);
7459
- this._addEventsListeners({ include: ["click"] });
7460
- this.mapAdapter.emitter.off("click", onMapClick);
7461
- this._coordFromMapClickPromise = void 0;
7462
- };
7463
- const onMapClick = (e) => {
7464
- onCancel_();
7465
- deprecatedMapClick(e);
7466
- resolve(e.lngLat);
7467
- };
7468
- this.mapAdapter.emitter.once("click", onMapClick);
7469
- onCancel(onCancel_);
7470
- }
7471
- );
7348
+ if (!this._coordFromMapClickAbort) {
7349
+ return new Promise((resolve, reject) => {
7350
+ const cursor = this.getCursor() || "grab";
7351
+ this._removeEventListeners({ include: ["click"] });
7352
+ this.setCursor("crosshair");
7353
+ const onCancel_ = () => {
7354
+ this.setCursor(cursor);
7355
+ this._addEventsListeners({ include: ["click"] });
7356
+ this.mapAdapter.emitter.off("click", onMapClick);
7357
+ this._coordFromMapClickAbort = void 0;
7358
+ };
7359
+ const onMapClick = (e) => {
7360
+ onCancel_();
7361
+ deprecatedMapClick(e);
7362
+ resolve(e.lngLat);
7363
+ };
7364
+ this.mapAdapter.emitter.once("click", onMapClick);
7365
+ this._coordFromMapClickAbort = onCancel_;
7366
+ });
7472
7367
  } else {
7473
7368
  return this.getCoordFromMapClick();
7474
7369
  }
7475
- return this._coordFromMapClickPromise;
7476
7370
  }
7477
7371
  _emitStatusEvent(eventName, data) {
7478
7372
  const _eventName = eventName;
@@ -9288,26 +9182,35 @@ const _NgwMap = class _NgwMap extends WebMap {
9288
9182
  }, options));
9289
9183
  }
9290
9184
  fetchIdentifyItem(identify, requestOptions) {
9185
+ const abortController = new AbortController();
9186
+ const abortSignal = abortController.signal;
9187
+ if (requestOptions == null ? void 0 : requestOptions.signal) {
9188
+ requestOptions.signal.addEventListener("abort", abortController.abort);
9189
+ }
9190
+ requestOptions = requestOptions || {};
9191
+ requestOptions.signal = abortSignal;
9291
9192
  const promise = fetchIdentifyItem({
9292
9193
  identify,
9293
9194
  connector: this.connector,
9294
9195
  requestOptions
9295
9196
  // multiple,
9296
9197
  });
9297
- this._addPromise("identify", promise);
9198
+ this._addPromise("identify", promise, abortController);
9298
9199
  return promise;
9299
9200
  }
9300
9201
  fetchIdentifyGeoJson(identify, multiple = false) {
9202
+ const abortController = new AbortController();
9301
9203
  const promise = fetchIdentifyGeoJson({
9302
9204
  identify,
9303
9205
  connector: this.connector,
9304
- multiple
9206
+ multiple,
9207
+ requestOptions: { signal: abortController.signal }
9305
9208
  });
9306
9209
  if (promise && "then" in promise) {
9307
- this._addPromise("identify", promise);
9210
+ this._addPromise("identify", promise, abortController);
9308
9211
  return promise;
9309
9212
  } else {
9310
- return CancelablePromise.resolve(promise);
9213
+ return Promise.resolve(promise);
9311
9214
  }
9312
9215
  }
9313
9216
  /**
@@ -9481,7 +9384,7 @@ const _NgwMap = class _NgwMap extends WebMap {
9481
9384
  args.forEach((name) => {
9482
9385
  const group = this._promises[name];
9483
9386
  if (group) {
9484
- group.forEach((x) => x.cancel());
9387
+ group.forEach((x) => x[1].abort());
9485
9388
  this._promises[name] = [];
9486
9389
  }
9487
9390
  });
@@ -9548,11 +9451,13 @@ const _NgwMap = class _NgwMap extends WebMap {
9548
9451
  }, highlightDuration);
9549
9452
  }
9550
9453
  }
9454
+ const abortController = new AbortController();
9551
9455
  const selectPromise = sendIdentifyRequest(ev, {
9552
9456
  layers: ids,
9553
9457
  connector: this.connector,
9554
9458
  radius,
9555
- geom
9459
+ geom,
9460
+ signal: abortController.signal
9556
9461
  }).then((resp) => {
9557
9462
  const identify = __spreadProps(__spreadValues({}, resp), {
9558
9463
  resources: ids,
@@ -9563,22 +9468,22 @@ const _NgwMap = class _NgwMap extends WebMap {
9563
9468
  this._emitStatusEvent("ngw:select", identifyEvent);
9564
9469
  return identifyEvent;
9565
9470
  });
9566
- this._addPromise("select", selectPromise);
9471
+ this._addPromise("select", selectPromise, abortController);
9567
9472
  return selectPromise;
9568
9473
  });
9569
9474
  }
9570
- _addPromise(groupName, promise) {
9475
+ _addPromise(groupName, promise, abortController) {
9571
9476
  const group = this._promises[groupName];
9572
- if (group && group.indexOf(promise) === -1) {
9477
+ if (group && group.findIndex((g) => g[0] === promise) === -1) {
9573
9478
  const removeFromGroup = () => {
9574
- const index = group.indexOf(promise);
9479
+ const index = group.findIndex((g) => g[0] === promise);
9575
9480
  if (index !== -1) {
9576
9481
  group.splice(index, 1);
9577
9482
  }
9578
9483
  };
9579
9484
  promise.then(removeFromGroup);
9580
9485
  promise.catch(removeFromGroup);
9581
- group.push(promise);
9486
+ group.push([promise, abortController]);
9582
9487
  }
9583
9488
  }
9584
9489
  _isFitFromResource() {