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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 2.4.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.0; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -474,308 +474,6 @@ var NgwMap = (function (exports) {
474
474
  return ret;
475
475
  }
476
476
 
477
- var __defProp$N = Object.defineProperty;
478
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
479
- var __publicField$z = (obj, key, value) => __defNormalProp$N(obj, typeof key !== "symbol" ? key + "" : key, value);
480
- class CancelError extends Error {
481
- constructor() {
482
- super();
483
- __publicField$z(this, "name", "CancelError");
484
- Object.setPrototypeOf(this, CancelError.prototype);
485
- }
486
- }
487
-
488
- var __defProp$M = Object.defineProperty;
489
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
490
- var __publicField$y = (obj, key, value) => __defNormalProp$M(obj, typeof key !== "symbol" ? key + "" : key, value);
491
- class PromiseControl {
492
- constructor(options = {}) {
493
- this.options = options;
494
- __publicField$y(this, "_promises", /* @__PURE__ */ new Map());
495
- }
496
- get isLoaded() {
497
- return this._promises.size > 0;
498
- }
499
- remove(promise) {
500
- if (this._promises.has(promise)) {
501
- this._promises.delete(promise);
502
- this._onStop();
503
- }
504
- }
505
- get(promise) {
506
- return this._promises.get(promise);
507
- }
508
- add(promise, name) {
509
- const key = name ? name : promise;
510
- const exist = this._promises.get(key);
511
- if (this.options.onStart && !this.isLoaded) {
512
- this.options.onStart();
513
- }
514
- if (exist) {
515
- return exist;
516
- }
517
- this._promises.set(key, promise);
518
- promise.finally(() => {
519
- this.remove(key);
520
- });
521
- return promise;
522
- }
523
- abort() {
524
- if (this.isLoaded) {
525
- this._promises.forEach((x) => {
526
- if (x.cancel) {
527
- x.cancel();
528
- }
529
- });
530
- this._promises.clear();
531
- this._onStop();
532
- }
533
- }
534
- waitFunc(func, name = "") {
535
- name = name || func.name;
536
- const exist = this.get(name);
537
- if (exist) {
538
- return exist;
539
- }
540
- return this.add(func(), name);
541
- }
542
- WaitForMe(name = "") {
543
- const get = this.get.bind(this);
544
- const add = this.add.bind(this);
545
- return function(target, key, descriptor) {
546
- const originalMethod = descriptor.value;
547
- name = name || key;
548
- descriptor.value = function(...args) {
549
- const exist = get(name);
550
- if (exist) {
551
- return exist;
552
- }
553
- const result = add(originalMethod.apply(this, args), name);
554
- return result;
555
- };
556
- return descriptor;
557
- };
558
- }
559
- /** @deprecated use {@link PromiseControl.WaitForMe } instead */
560
- GetOrCreateDecorator(name = "") {
561
- return this.WaitForMe(name);
562
- }
563
- _onStop() {
564
- if (this.options.onStop && !this.isLoaded) {
565
- this.options.onStop();
566
- }
567
- }
568
- }
569
-
570
- var __defProp$L = Object.defineProperty;
571
- var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
572
- var __publicField$x = (obj, key, value) => __defNormalProp$L(obj, typeof key !== "symbol" ? key + "" : key, value);
573
- class TimeoutError extends Error {
574
- constructor() {
575
- super();
576
- __publicField$x(this, "name", "TimeoutError");
577
- Object.setPrototypeOf(this, TimeoutError.prototype);
578
- }
579
- }
580
-
581
- var __defProp$K = Object.defineProperty;
582
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
583
- var __publicField$w = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
584
- var _a;
585
- const handleCallback = (resolve, reject, callback, r) => {
586
- try {
587
- resolve(callback(r));
588
- } catch (e) {
589
- reject(e);
590
- }
591
- };
592
- let ID$3 = 0;
593
- _a = Symbol.toStringTag;
594
- const _CancelablePromise = class _CancelablePromise {
595
- constructor(executor, timeout) {
596
- // @ts-ignore
597
- __publicField$w(this, _a);
598
- __publicField$w(this, "id", ID$3++);
599
- __publicField$w(this, "_isCanceled", false);
600
- __publicField$w(this, "_isPending", true);
601
- __publicField$w(this, "_promise");
602
- __publicField$w(this, "_cancelPromise");
603
- __publicField$w(this, "_cancelHandlers", []);
604
- __publicField$w(this, "_setCanceledCallback");
605
- __publicField$w(this, "_parentPromise");
606
- __publicField$w(this, "_children", []);
607
- this._cancelPromise = new Promise((resolve_, reject_) => {
608
- this._setCanceledCallback = (er) => resolve_(er || new CancelError());
609
- });
610
- const promises = [
611
- this._cancelPromise,
612
- new Promise((resolve, reject) => {
613
- const onResolve = (value) => {
614
- if (value instanceof _CancelablePromise) {
615
- this.attach(value);
616
- } else {
617
- this._isPending = false;
618
- }
619
- resolve(value);
620
- };
621
- const onReject = (error) => {
622
- this._isPending = false;
623
- reject(error);
624
- };
625
- const onCancel = (handler) => {
626
- if (!this._isPending) {
627
- throw new Error(
628
- "The `onCancel` handler was attached after the promise settled."
629
- );
630
- }
631
- this._cancelHandlers.push(handler);
632
- };
633
- return executor(onResolve, onReject, onCancel);
634
- })
635
- ];
636
- if (timeout) {
637
- promises.push(
638
- new Promise((resolve, reject) => {
639
- setTimeout(() => {
640
- if (this._isPending) {
641
- try {
642
- this.cancel();
643
- } finally {
644
- reject(new TimeoutError());
645
- }
646
- }
647
- }, timeout);
648
- })
649
- );
650
- }
651
- this._promise = Promise.race(promises);
652
- }
653
- static createControl(opt) {
654
- return new PromiseControl(opt);
655
- }
656
- static resolve(value) {
657
- return new _CancelablePromise((resolve) => resolve(value));
658
- }
659
- static reject(value) {
660
- return new _CancelablePromise((resolve, reject) => reject(value));
661
- }
662
- static all(values) {
663
- return new _CancelablePromise((resolve, reject) => {
664
- Promise.all(values).then(resolve).catch(reject);
665
- }).catch((er) => {
666
- if (er instanceof this.CancelError) {
667
- for (const v of values) {
668
- const v_ = v;
669
- if ("cancel" in v_) {
670
- v_.cancel();
671
- }
672
- }
673
- }
674
- throw er;
675
- });
676
- }
677
- attach(p) {
678
- if (this._isCanceled) {
679
- p.cancel();
680
- } else {
681
- this._children.push(p);
682
- }
683
- }
684
- then(onfulfilled, onrejected) {
685
- const p = new _CancelablePromise((resolve, reject) => {
686
- if (this._promise) {
687
- const reject_ = (r) => {
688
- if (onrejected) {
689
- handleCallback(resolve, reject, onrejected, r);
690
- } else {
691
- reject(r);
692
- }
693
- };
694
- this._promise.then((r) => {
695
- if (this._isCanceled) {
696
- reject_(r);
697
- } else {
698
- if (onfulfilled) {
699
- handleCallback(resolve, reject, onfulfilled, r);
700
- } else {
701
- resolve(r);
702
- }
703
- }
704
- }, reject_);
705
- }
706
- });
707
- p._parentPromise = this;
708
- this._children.push(p);
709
- return p;
710
- }
711
- catch(onrejected) {
712
- if (this._isCanceled && onrejected) {
713
- onrejected(new CancelError());
714
- }
715
- return this.then(void 0, onrejected);
716
- }
717
- finally(onfinally) {
718
- if (this._promise) {
719
- return this._promise.finally(onfinally);
720
- }
721
- if (this._isCanceled) {
722
- return Promise.reject(new CancelError());
723
- }
724
- return Promise.reject(onfinally);
725
- }
726
- cancel() {
727
- if (this._isCanceled || !this._isPending) {
728
- return this;
729
- }
730
- this._isCanceled = true;
731
- const parent = this._getTopParent();
732
- if (parent) {
733
- parent.cancel();
734
- }
735
- if (this._children) {
736
- this._children.forEach((x) => x.cancel());
737
- }
738
- if (this._isPending) {
739
- if (this._cancelHandlers.length) {
740
- try {
741
- for (const handler of this._cancelHandlers) {
742
- handler();
743
- }
744
- } catch (error) {
745
- }
746
- }
747
- if (this._setCanceledCallback) {
748
- this._setCanceledCallback();
749
- }
750
- }
751
- this._destroy();
752
- return this;
753
- }
754
- _getTopParent() {
755
- let parent = this._parentPromise;
756
- let hasParent = !!parent;
757
- while (hasParent) {
758
- if (parent && parent._parentPromise) {
759
- parent = parent._parentPromise;
760
- hasParent = !!parent;
761
- } else {
762
- hasParent = false;
763
- }
764
- }
765
- return parent;
766
- }
767
- _destroy() {
768
- this._setCanceledCallback = void 0;
769
- this._cancelPromise = void 0;
770
- this._promise = void 0;
771
- }
772
- };
773
- __publicField$w(_CancelablePromise, "CancelError", CancelError);
774
- __publicField$w(_CancelablePromise, "TimeoutError", TimeoutError);
775
- __publicField$w(_CancelablePromise, "PromiseControl", PromiseControl);
776
- let CancelablePromise = _CancelablePromise;
777
- Object.setPrototypeOf(CancelablePromise.prototype, Promise.prototype);
778
-
779
477
  const svgPath = {
780
478
  brill: '<path d="m6 0-5 6 5 6 5-6z"/>',
781
479
  circle: '<circle cx="6" cy="6" r="6"/>',
@@ -1114,7 +812,7 @@ var NgwMap = (function (exports) {
1114
812
  }
1115
813
 
1116
814
  function round(val, toFixed) {
1117
- const n = toFixed ? Number("1e+" + toFixed) : 1;
815
+ const n = 1;
1118
816
  return Math.round((val + Number.EPSILON) * n) / n;
1119
817
  }
1120
818
 
@@ -1129,9 +827,9 @@ var NgwMap = (function (exports) {
1129
827
  return url.replace(/([^:]\/)\/+/g, "$1");
1130
828
  }
1131
829
 
1132
- var __defProp$J = Object.defineProperty;
1133
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1134
- var __publicField$v = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
830
+ var __defProp$K = Object.defineProperty;
831
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
832
+ var __publicField$v = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
1135
833
  const _Cache = class _Cache {
1136
834
  constructor(options = {}) {
1137
835
  __publicField$v(this, "cache", []);
@@ -1167,8 +865,7 @@ var NgwMap = (function (exports) {
1167
865
  * // somewhere else in the code
1168
866
  * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
1169
867
  * console.log(resp); // 'New item'
1170
- * })
1171
- *
868
+ * });
1172
869
  * ```
1173
870
  */
1174
871
  addFull(key, valueToSet, props) {
@@ -1183,13 +880,11 @@ var NgwMap = (function (exports) {
1183
880
  } else {
1184
881
  value = valueToSet;
1185
882
  }
1186
- const props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
883
+ const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1187
884
  const cacheItem = {
1188
885
  key,
1189
886
  value,
1190
- props: props_,
1191
- // TODO: remove backward compatibility use only props
1192
- options: props_
887
+ props: nonEmptyProps
1193
888
  };
1194
889
  if (onlyFull && !full(value)) {
1195
890
  return value;
@@ -1198,7 +893,6 @@ var NgwMap = (function (exports) {
1198
893
  if (value instanceof Promise) {
1199
894
  value.catch((er) => {
1200
895
  this.delete(key, props);
1201
- throw er;
1202
896
  });
1203
897
  if (onlyFull) {
1204
898
  value.then((x) => {
@@ -1217,9 +911,7 @@ var NgwMap = (function (exports) {
1217
911
  }
1218
912
  match(key, props) {
1219
913
  const cacheRecord = this._find(key, props);
1220
- if (cacheRecord) {
1221
- return cacheRecord.value;
1222
- }
914
+ return cacheRecord == null ? void 0 : cacheRecord.value;
1223
915
  }
1224
916
  matchAll(key, props) {
1225
917
  if (key) {
@@ -1228,37 +920,30 @@ var NgwMap = (function (exports) {
1228
920
  return this.cache.map((x) => x.value);
1229
921
  }
1230
922
  delete(keyOrItem, props) {
1231
- let exist = [];
1232
- if (typeof keyOrItem === "string") {
1233
- exist = this.cache.filter((x) => this._filter(x, keyOrItem, props));
1234
- } else {
1235
- exist.push(keyOrItem);
1236
- }
1237
- for (const e of exist) {
1238
- const index = this.cache.indexOf(e);
1239
- this.cache.splice(index, 1);
923
+ const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
924
+ for (const item of itemsToDelete) {
925
+ const index = this.cache.indexOf(item);
926
+ if (index !== -1) {
927
+ this.cache.splice(index, 1);
928
+ }
1240
929
  }
1241
930
  }
1242
931
  _find(key, props) {
1243
932
  return this.cache.find((x) => this._filter(x, key, props));
1244
933
  }
1245
934
  _filter(item, key, props) {
1246
- if (item.key === key) {
1247
- if (props) {
1248
- const itemProps = item.props || item.options;
1249
- return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1250
- }
1251
- return true;
1252
- }
1253
- return false;
935
+ if (item.key !== key) return false;
936
+ if (!props) return true;
937
+ const itemProps = item.props;
938
+ return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1254
939
  }
1255
940
  };
1256
941
  __publicField$v(_Cache, "instance", {});
1257
942
  let Cache = _Cache;
1258
943
 
1259
- var __defProp$I = Object.defineProperty;
1260
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1261
- var __publicField$u = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
944
+ var __defProp$J = Object.defineProperty;
945
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
946
+ var __publicField$u = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
1262
947
  class NgwError extends Error {
1263
948
  constructor(er) {
1264
949
  super();
@@ -1275,9 +960,9 @@ var NgwMap = (function (exports) {
1275
960
  }
1276
961
  }
1277
962
 
1278
- var __defProp$H = Object.defineProperty;
1279
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1280
- var __publicField$t = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
963
+ var __defProp$I = Object.defineProperty;
964
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
965
+ var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
1281
966
  class ResourceNotFoundError extends NgwError {
1282
967
  constructor(obj) {
1283
968
  super(obj);
@@ -1316,27 +1001,24 @@ var NgwMap = (function (exports) {
1316
1001
  return query;
1317
1002
  }
1318
1003
 
1319
- var __defProp$G = Object.defineProperty;
1320
- var __defProps$d = Object.defineProperties;
1321
- var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
1322
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1323
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1324
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1325
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1326
- var __spreadValues$t = (a, b) => {
1004
+ var __defProp$H = Object.defineProperty;
1005
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1006
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1007
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1008
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1009
+ var __spreadValues$v = (a, b) => {
1327
1010
  for (var prop in b || (b = {}))
1328
- if (__hasOwnProp$u.call(b, prop))
1329
- __defNormalProp$G(a, prop, b[prop]);
1330
- if (__getOwnPropSymbols$u)
1331
- for (var prop of __getOwnPropSymbols$u(b)) {
1332
- if (__propIsEnum$u.call(b, prop))
1333
- __defNormalProp$G(a, prop, b[prop]);
1011
+ if (__hasOwnProp$w.call(b, prop))
1012
+ __defNormalProp$H(a, prop, b[prop]);
1013
+ if (__getOwnPropSymbols$w)
1014
+ for (var prop of __getOwnPropSymbols$w(b)) {
1015
+ if (__propIsEnum$w.call(b, prop))
1016
+ __defNormalProp$H(a, prop, b[prop]);
1334
1017
  }
1335
1018
  return a;
1336
1019
  };
1337
- var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
1338
- var __publicField$s = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1339
- var __async$l = (__this, __arguments, generator) => {
1020
+ var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1021
+ var __async$s = (__this, __arguments, generator) => {
1340
1022
  return new Promise((resolve, reject) => {
1341
1023
  var fulfilled = (value) => {
1342
1024
  try {
@@ -1377,39 +1059,27 @@ var NgwMap = (function (exports) {
1377
1059
  * Fetching resource would be cached to speed up next call
1378
1060
  */
1379
1061
  getOne(resource, requestOptions) {
1380
- const cache = this.cache;
1381
- const forCache = {};
1382
- const opt = __spreadProps$d(__spreadValues$t({}, requestOptions), { cache: false });
1383
- if (typeof resource === "string") {
1384
- forCache.keyname = resource;
1385
- } else if (typeof resource === "number") {
1386
- forCache.id = resource;
1387
- } else if (isObject(resource)) {
1062
+ const opt = __spreadValues$v({}, requestOptions);
1063
+ if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1388
1064
  if (resource.id !== void 0) {
1389
- forCache.id = resource.id;
1065
+ resource.id;
1390
1066
  } else {
1391
1067
  if (resource.keyname) {
1392
- forCache.keyname = resource.keyname;
1068
+ resource.keyname;
1393
1069
  }
1394
1070
  if (resource.display_name) {
1395
- forCache.display_name = resource.display_name;
1071
+ resource.display_name;
1396
1072
  }
1397
1073
  }
1398
1074
  }
1399
- const makeRequest = () => {
1400
- if (typeof resource === "string") {
1401
- return this._fetchResourceBy({ keyname: resource }, opt);
1402
- } else if (typeof resource === "number") {
1403
- return this._fetchResourceById(resource, opt);
1404
- } else if (isObject(resource)) {
1405
- return this._fetchResourceBy(resource, opt);
1406
- }
1407
- return CancelablePromise.resolve(void 0);
1408
- };
1409
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1410
- return cache.addFull("resource", makeRequest, forCache);
1075
+ if (typeof resource === "string") {
1076
+ return this._fetchResourceBy({ keyname: resource }, opt);
1077
+ } else if (typeof resource === "number") {
1078
+ return this._fetchResourceById(resource, opt);
1079
+ } else if (isObject(resource)) {
1080
+ return this._fetchResourceBy(resource, opt);
1411
1081
  }
1412
- return makeRequest();
1082
+ return Promise.resolve(void 0);
1413
1083
  }
1414
1084
  getOneOrFail(resource, requestOptions) {
1415
1085
  return this.getOne(resource, requestOptions).then((res) => {
@@ -1431,7 +1101,7 @@ var NgwMap = (function (exports) {
1431
1101
  */
1432
1102
  getId(resource, requestOptions) {
1433
1103
  if (typeof resource === "number") {
1434
- return CancelablePromise.resolve(resource);
1104
+ return Promise.resolve(resource);
1435
1105
  } else if (typeof resource === "string" || isObject(resource)) {
1436
1106
  return this.getOne(resource, requestOptions).then((res) => {
1437
1107
  if (res) {
@@ -1439,7 +1109,7 @@ var NgwMap = (function (exports) {
1439
1109
  }
1440
1110
  });
1441
1111
  }
1442
- return CancelablePromise.resolve(void 0);
1112
+ return Promise.resolve(void 0);
1443
1113
  }
1444
1114
  /**
1445
1115
  * A fast way to retrieve resource ID for any resource definition.
@@ -1466,12 +1136,12 @@ var NgwMap = (function (exports) {
1466
1136
  } else {
1467
1137
  Object.assign(query, resourceToQuery(resource));
1468
1138
  }
1469
- return this.connector.get("resource.search", requestOptions, __spreadValues$t({
1139
+ return this.connector.get("resource.search", requestOptions, __spreadValues$v({
1470
1140
  serialization: "full"
1471
1141
  }, query)).then((resources) => {
1472
- if (resources) {
1142
+ if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
1473
1143
  for (const x of resources) {
1474
- this.cache.add("resource.item", CancelablePromise.resolve(x), {
1144
+ this.cache.add("resource.item", Promise.resolve(x), {
1475
1145
  id: x.resource.id
1476
1146
  });
1477
1147
  }
@@ -1487,7 +1157,7 @@ var NgwMap = (function (exports) {
1487
1157
  if (child) {
1488
1158
  return this.getOne(child.resource.parent.id, requestOptions);
1489
1159
  }
1490
- return CancelablePromise.resolve(void 0);
1160
+ return Promise.resolve(void 0);
1491
1161
  });
1492
1162
  }
1493
1163
  getChildrenOf(resource, requestOptions) {
@@ -1517,18 +1187,16 @@ var NgwMap = (function (exports) {
1517
1187
  });
1518
1188
  }
1519
1189
  _getChildrenOf(parent, requestOptions, _items = []) {
1520
- return this.connector.get(
1521
- "resource.collection",
1522
- __spreadValues$t({ cache: true }, requestOptions),
1523
- {
1524
- parent
1525
- }
1526
- ).then((items) => {
1190
+ return this.connector.get("resource.collection", requestOptions, {
1191
+ parent
1192
+ }).then((items) => {
1527
1193
  const recursivePromises = [];
1528
1194
  for (const item of items) {
1529
- this.cache.add("resource.item", CancelablePromise.resolve(item), {
1530
- id: item.resource.id
1531
- });
1195
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
1196
+ this.cache.add("resource.item", Promise.resolve(item), {
1197
+ id: item.resource.id
1198
+ });
1199
+ }
1532
1200
  _items.push(item);
1533
1201
  if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
1534
1202
  recursivePromises.push(
@@ -1537,7 +1205,7 @@ var NgwMap = (function (exports) {
1537
1205
  }
1538
1206
  }
1539
1207
  if (recursivePromises.length) {
1540
- return CancelablePromise.all(recursivePromises).then(() => {
1208
+ return Promise.all(recursivePromises).then(() => {
1541
1209
  return _items;
1542
1210
  });
1543
1211
  }
@@ -1545,11 +1213,12 @@ var NgwMap = (function (exports) {
1545
1213
  });
1546
1214
  }
1547
1215
  _cleanResourceItemCache(id) {
1548
- return __async$l(this, null, function* () {
1216
+ return __async$s(this, null, function* () {
1217
+ var _a;
1549
1218
  const all = this.cache.all();
1550
1219
  const toDelete = [];
1551
1220
  for (const c of all) {
1552
- const cid = c.options && c.options.id;
1221
+ const cid = (_a = c.props) == null ? void 0 : _a.id;
1553
1222
  if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
1554
1223
  if (typeof cid === "number") {
1555
1224
  if (cid === id) {
@@ -1569,18 +1238,7 @@ var NgwMap = (function (exports) {
1569
1238
  });
1570
1239
  }
1571
1240
  _fetchResourceById(id, requestOptions) {
1572
- const promise = () => this.connector.get("resource.item", requestOptions, { id });
1573
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1574
- return this.cache.add("resource.item", promise, {
1575
- id
1576
- }).catch((er) => {
1577
- if (!(er instanceof ResourceNotFoundError)) {
1578
- throw er;
1579
- }
1580
- return void 0;
1581
- });
1582
- }
1583
- return promise();
1241
+ return this.connector.get("resource.item", requestOptions, { id });
1584
1242
  }
1585
1243
  _fetchResourceBy(resource, requestOptions) {
1586
1244
  return this.getMany(resource, requestOptions).then((resources) => {
@@ -1588,7 +1246,7 @@ var NgwMap = (function (exports) {
1588
1246
  });
1589
1247
  }
1590
1248
  _resourceCacheFilter(resource) {
1591
- return CancelablePromise.all(this.cache.matchAll("resource.item")).then(
1249
+ return Promise.all(this.cache.matchAll("resource.item")).then(
1592
1250
  (resources) => {
1593
1251
  const items = [];
1594
1252
  resources.filter((x) => {
@@ -1632,9 +1290,16 @@ var NgwMap = (function (exports) {
1632
1290
  }
1633
1291
  }
1634
1292
 
1635
- var __defProp$F = Object.defineProperty;
1636
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1637
- var __publicField$r = (obj, key, value) => __defNormalProp$F(obj, typeof key !== "symbol" ? key + "" : key, value);
1293
+ class AbortError extends Error {
1294
+ constructor(message = "AbortError") {
1295
+ super(message);
1296
+ this.name = "AbortError";
1297
+ }
1298
+ }
1299
+
1300
+ var __defProp$G = Object.defineProperty;
1301
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1302
+ var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1638
1303
  class InsufficientPermissionsError extends NgwError {
1639
1304
  constructor(obj) {
1640
1305
  super(obj);
@@ -1657,64 +1322,96 @@ var NgwMap = (function (exports) {
1657
1322
  });
1658
1323
  }
1659
1324
 
1325
+ var __defProp$F = Object.defineProperty;
1326
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1327
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1328
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1329
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1330
+ var __spreadValues$u = (a, b) => {
1331
+ for (var prop in b || (b = {}))
1332
+ if (__hasOwnProp$v.call(b, prop))
1333
+ __defNormalProp$F(a, prop, b[prop]);
1334
+ if (__getOwnPropSymbols$v)
1335
+ for (var prop of __getOwnPropSymbols$v(b)) {
1336
+ if (__propIsEnum$v.call(b, prop))
1337
+ __defNormalProp$F(a, prop, b[prop]);
1338
+ }
1339
+ return a;
1340
+ };
1341
+ var __async$r = (__this, __arguments, generator) => {
1342
+ return new Promise((resolve, reject) => {
1343
+ var fulfilled = (value) => {
1344
+ try {
1345
+ step(generator.next(value));
1346
+ } catch (e) {
1347
+ reject(e);
1348
+ }
1349
+ };
1350
+ var rejected = (value) => {
1351
+ try {
1352
+ step(generator.throw(value));
1353
+ } catch (e) {
1354
+ reject(e);
1355
+ }
1356
+ };
1357
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1358
+ step((generator = generator.apply(__this, __arguments)).next());
1359
+ });
1360
+ };
1660
1361
  function apiRequest(opt) {
1661
- const params = opt.params;
1662
- return new CancelablePromise((resolve, reject) => {
1663
- return opt.connector.connect().then((apiItems) => {
1664
- let apiItem = apiItems && apiItems[opt.name];
1665
- if (apiItem) {
1666
- apiItem = [...apiItem];
1667
- let url = apiItem.shift();
1668
- if (apiItem.length) {
1669
- const replaceParams = {};
1670
- for (let fry = 0; fry < apiItem.length; fry++) {
1671
- const arg = apiItem[fry];
1672
- replaceParams[fry] = "{" + arg + "}";
1673
- if (params[arg] === void 0) {
1674
- throw new Error(
1675
- "`" + arg + "` url api argument is not specified"
1676
- );
1677
- }
1678
- }
1679
- if (url) {
1680
- url = template(url, replaceParams);
1362
+ return __async$r(this, null, function* () {
1363
+ const { params, name, connector, requestOptions } = opt;
1364
+ const apiItems = yield connector.connect();
1365
+ let apiItem = apiItems && apiItems[name];
1366
+ if (apiItem) {
1367
+ apiItem = [...apiItem];
1368
+ let url = apiItem.shift();
1369
+ if (apiItem.length) {
1370
+ const replaceParams = {};
1371
+ for (let fry = 0; fry < apiItem.length; fry++) {
1372
+ const arg = apiItem[fry];
1373
+ replaceParams[fry] = `{${arg}}`;
1374
+ if (params[arg] === void 0) {
1375
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
1681
1376
  }
1682
1377
  }
1683
- if (params) {
1684
- const paramArray = [];
1685
- const paramList = params.paramList;
1686
- if (Array.isArray(paramList)) {
1687
- delete params.paramList;
1688
- paramList.forEach((x) => {
1689
- paramArray.push(`${x[0]}=${x[1]}`);
1690
- });
1691
- }
1692
- for (const p in params) {
1693
- if (apiItem.indexOf(p) === -1) {
1694
- paramArray.push(`${p}=${params[p]}`);
1695
- }
1696
- }
1697
- if (paramArray.length) {
1698
- url = url + "?" + paramArray.join("&");
1378
+ if (url) {
1379
+ url = template(url, replaceParams);
1380
+ }
1381
+ }
1382
+ if (params) {
1383
+ const paramArray = [];
1384
+ const paramList = params.paramList;
1385
+ if (Array.isArray(paramList)) {
1386
+ paramList.forEach(([key, value]) => {
1387
+ paramArray.push(`${key}=${value}`);
1388
+ });
1389
+ }
1390
+ for (const p in params) {
1391
+ if (apiItem.indexOf(p) === -1) {
1392
+ paramArray.push(`${p}=${params[p]}`);
1699
1393
  }
1700
1394
  }
1701
- if (url) {
1702
- resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1703
- } else {
1704
- reject(new Error("request url is not set"));
1395
+ if (paramArray.length) {
1396
+ url = `${url}?${paramArray.join("&")}`;
1705
1397
  }
1398
+ }
1399
+ if (url) {
1400
+ return connector.makeQuery(url, params, __spreadValues$u({
1401
+ cacheName: name
1402
+ }, requestOptions));
1706
1403
  } else {
1707
- resolve(void 0);
1404
+ throw new Error("Request URL is not set");
1708
1405
  }
1709
- }).catch((er) => {
1710
- reject(er);
1711
- });
1406
+ } else {
1407
+ return void 0;
1408
+ }
1712
1409
  });
1713
1410
  }
1714
1411
 
1715
1412
  var __defProp$E = Object.defineProperty;
1716
1413
  var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1717
- var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, typeof key !== "symbol" ? key + "" : key, value);
1414
+ var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
1718
1415
  class NetworkError extends Error {
1719
1416
  constructor(url) {
1720
1417
  super();
@@ -1808,23 +1505,59 @@ var NgwMap = (function (exports) {
1808
1505
  }
1809
1506
 
1810
1507
  var __defProp$D = Object.defineProperty;
1811
- var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
1812
- var __hasOwnProp$t = Object.prototype.hasOwnProperty;
1813
- var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
1508
+ var __defProps$d = Object.defineProperties;
1509
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
1510
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1511
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1512
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1814
1513
  var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1815
- var __spreadValues$s = (a, b) => {
1514
+ var __spreadValues$t = (a, b) => {
1816
1515
  for (var prop in b || (b = {}))
1817
- if (__hasOwnProp$t.call(b, prop))
1516
+ if (__hasOwnProp$u.call(b, prop))
1818
1517
  __defNormalProp$D(a, prop, b[prop]);
1819
- if (__getOwnPropSymbols$t)
1820
- for (var prop of __getOwnPropSymbols$t(b)) {
1821
- if (__propIsEnum$t.call(b, prop))
1518
+ if (__getOwnPropSymbols$u)
1519
+ for (var prop of __getOwnPropSymbols$u(b)) {
1520
+ if (__propIsEnum$u.call(b, prop))
1822
1521
  __defNormalProp$D(a, prop, b[prop]);
1823
1522
  }
1824
1523
  return a;
1825
1524
  };
1525
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
1526
+ var __objRest$2 = (source, exclude) => {
1527
+ var target = {};
1528
+ for (var prop in source)
1529
+ if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
1530
+ target[prop] = source[prop];
1531
+ if (source != null && __getOwnPropSymbols$u)
1532
+ for (var prop of __getOwnPropSymbols$u(source)) {
1533
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
1534
+ target[prop] = source[prop];
1535
+ }
1536
+ return target;
1537
+ };
1826
1538
  var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
1539
+ var __async$q = (__this, __arguments, generator) => {
1540
+ return new Promise((resolve, reject) => {
1541
+ var fulfilled = (value) => {
1542
+ try {
1543
+ step(generator.next(value));
1544
+ } catch (e) {
1545
+ reject(e);
1546
+ }
1547
+ };
1548
+ var rejected = (value) => {
1549
+ try {
1550
+ step(generator.throw(value));
1551
+ } catch (e) {
1552
+ reject(e);
1553
+ }
1554
+ };
1555
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1556
+ step((generator = generator.apply(__this, __arguments)).next());
1557
+ });
1558
+ };
1827
1559
  let ID$2 = 0;
1560
+ let REQUEST_ID = 0;
1828
1561
  class NgwConnector {
1829
1562
  constructor(options) {
1830
1563
  this.options = options;
@@ -1834,7 +1567,7 @@ var NgwMap = (function (exports) {
1834
1567
  __publicField$p(this, "resources");
1835
1568
  __publicField$p(this, "cache");
1836
1569
  __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1837
- __publicField$p(this, "activeRequests", []);
1570
+ __publicField$p(this, "activeRequests", {});
1838
1571
  __publicField$p(this, "requestTransform");
1839
1572
  const exist = findConnector(options);
1840
1573
  this.cache = new Cache({ namespace: options.cacheId });
@@ -1891,29 +1624,27 @@ var NgwMap = (function (exports) {
1891
1624
  * ```
1892
1625
  */
1893
1626
  connect() {
1894
- const auth = this.options.auth;
1895
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1896
- const makeQuery = () => {
1897
- return this.makeQuery(this.routeStr, {}, {}).then((route) => {
1898
- resolve(route);
1899
- }).catch((er) => {
1900
- reject(er);
1901
- });
1902
- };
1627
+ return __async$q(this, null, function* () {
1628
+ const auth = this.options.auth;
1903
1629
  if (auth) {
1904
1630
  const { login, password } = auth;
1905
1631
  if (login && password) {
1906
- return this._login({ login, password }).then(() => {
1907
- return makeQuery();
1908
- }).catch((er) => reject(er));
1632
+ yield this._login({ login, password });
1909
1633
  }
1910
1634
  }
1911
- return makeQuery();
1912
- });
1913
- return this.cache.add("route", makeConnect, {
1914
- id: this.id,
1915
- auth,
1916
- baseUrl: this.options.baseUrl
1635
+ return yield this.makeQuery(
1636
+ this.routeStr,
1637
+ {},
1638
+ {
1639
+ cacheName: "route",
1640
+ cache: true,
1641
+ cacheProps: {
1642
+ id: this.id,
1643
+ auth,
1644
+ baseUrl: this.options.baseUrl
1645
+ }
1646
+ }
1647
+ );
1917
1648
  });
1918
1649
  }
1919
1650
  /**
@@ -1937,20 +1668,22 @@ var NgwMap = (function (exports) {
1937
1668
  this.emitter.emit("logout");
1938
1669
  }
1939
1670
  getUserInfo(credentials, options) {
1940
- if (this.user && this.user.id) {
1941
- return CancelablePromise.resolve(this.user);
1942
- }
1943
- if (credentials) {
1944
- this.options.auth = credentials;
1945
- }
1946
- const options_ = __spreadValues$s({
1947
- headers: this.getAuthorizationHeaders(credentials)
1948
- }, options);
1949
- return this.makeQuery(
1950
- "/api/component/auth/current_user",
1951
- {},
1952
- options_
1953
- );
1671
+ return __async$q(this, null, function* () {
1672
+ if (this.user && this.user.id) {
1673
+ return this.user;
1674
+ }
1675
+ if (credentials) {
1676
+ this.options.auth = credentials;
1677
+ }
1678
+ const options_ = __spreadValues$t({
1679
+ headers: this.getAuthorizationHeaders(credentials)
1680
+ }, options);
1681
+ return this.makeQuery(
1682
+ "/api/component/auth/current_user",
1683
+ {},
1684
+ options_
1685
+ );
1686
+ });
1954
1687
  }
1955
1688
  /**
1956
1689
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -1959,7 +1692,7 @@ var NgwMap = (function (exports) {
1959
1692
  const client = this.makeClientId(credentials);
1960
1693
  if (client) {
1961
1694
  return {
1962
- Authorization: "Basic " + client
1695
+ Authorization: `Basic ${client}`
1963
1696
  };
1964
1697
  }
1965
1698
  }
@@ -1967,21 +1700,22 @@ var NgwMap = (function (exports) {
1967
1700
  credentials = credentials || this.options.auth;
1968
1701
  if (credentials) {
1969
1702
  const { login, password } = credentials;
1970
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1703
+ const str = `${login}:${password}`;
1704
+ const encodedStr = encodeURIComponent(str);
1971
1705
  {
1972
- return window.btoa(str);
1706
+ return window.btoa(encodedStr);
1973
1707
  }
1974
1708
  }
1975
1709
  }
1976
1710
  /** Stop all api requests */
1977
1711
  abort() {
1978
- for (const req of this.activeRequests) {
1979
- req.cancel();
1712
+ for (const abortController of Object.values(this.activeRequests)) {
1713
+ abortController.abort();
1980
1714
  }
1981
- this.activeRequests = [];
1715
+ this.activeRequests = {};
1982
1716
  }
1983
1717
  getActiveApiRequests() {
1984
- return [...this.activeRequests];
1718
+ return __spreadValues$t({}, this.activeRequests);
1985
1719
  }
1986
1720
  /**
1987
1721
  * Send request to NGW api router.
@@ -2013,23 +1747,10 @@ var NgwMap = (function (exports) {
2013
1747
  * ```
2014
1748
  */
2015
1749
  apiRequest(name, params_ = {}, requestOptions = {}) {
2016
- var _a, _b;
2017
- const { method, headers, withCredentials, responseType } = requestOptions;
1750
+ var _a;
2018
1751
  params_ = (_a = requestOptions.params) != null ? _a : params_;
2019
1752
  const params = objectRemoveEmpty(params_);
2020
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
2021
- if (requestOptions.cache && method === "GET") {
2022
- return this.cache.add(name, makeApiRequest, __spreadValues$s({
2023
- params
2024
- }, objectRemoveEmpty({
2025
- headers,
2026
- withCredentials,
2027
- responseType,
2028
- baseUrl: this.options.baseUrl,
2029
- userId: (_b = this.user) == null ? void 0 : _b.id
2030
- })));
2031
- }
2032
- return makeApiRequest();
1753
+ return apiRequest({ name, params, requestOptions, connector: this });
2033
1754
  }
2034
1755
  /**
2035
1756
  * Shortcut method for send POST request to NGW.
@@ -2119,17 +1840,67 @@ var NgwMap = (function (exports) {
2119
1840
  * @param params - Query params
2120
1841
  * @param options - Request options
2121
1842
  */
2122
- makeQuery(url, params, options = {}) {
2123
- url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
2124
- if (url) {
1843
+ makeQuery(_0, _1) {
1844
+ return __async$q(this, arguments, function* (url, params, options = {}) {
1845
+ var _b;
1846
+ url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1847
+ if (!url) {
1848
+ throw new Error("Empty `url` not allowed");
1849
+ }
2125
1850
  if (params) {
2126
- url = template(url, params);
1851
+ const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1852
+ url = template(url, restParams);
1853
+ }
1854
+ url = encodeURI(fixUrlStr(url));
1855
+ const {
1856
+ cache,
1857
+ signal: externalSignal,
1858
+ method = "GET",
1859
+ headers,
1860
+ cacheName,
1861
+ cacheProps,
1862
+ responseType,
1863
+ withCredentials
1864
+ } = options;
1865
+ const internalAbortController = new AbortController();
1866
+ const internalSignal = internalAbortController.signal;
1867
+ if (externalSignal) {
1868
+ if (externalSignal.aborted) {
1869
+ throw new AbortError();
1870
+ }
1871
+ externalSignal.addEventListener("abort", () => {
1872
+ internalAbortController.abort();
1873
+ });
1874
+ }
1875
+ options.signal = internalSignal;
1876
+ const createPromise = () => __async$q(this, null, function* () {
1877
+ const id = REQUEST_ID++;
1878
+ this.activeRequests[id] = internalAbortController;
1879
+ try {
1880
+ return this._loadData(url, options);
1881
+ } finally {
1882
+ this._cleanActiveRequest(id);
1883
+ }
1884
+ });
1885
+ if (cache && method === "GET") {
1886
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$d(__spreadValues$t({}, objectRemoveEmpty({
1887
+ headers,
1888
+ withCredentials,
1889
+ responseType,
1890
+ baseUrl: this.options.baseUrl,
1891
+ userId: (_b = this.user) == null ? void 0 : _b.id
1892
+ })), {
1893
+ params
1894
+ });
1895
+ return this.cache.add(
1896
+ cacheName || url,
1897
+ createPromise,
1898
+ cacheOptions,
1899
+ false
1900
+ );
2127
1901
  }
2128
- url = encodeURI(fixUrlStr(url));
2129
- return this._loadData(url, options);
2130
- } else {
2131
- throw new Error("Empty `url` not allowed");
2132
- }
1902
+ return createPromise();
1903
+ });
2133
1904
  }
2134
1905
  // -------------------------------------------------------------------------
2135
1906
  // Resource Methods
@@ -2211,26 +1982,29 @@ var NgwMap = (function (exports) {
2211
1982
  */
2212
1983
  _loadData(url, options) {
2213
1984
  options.responseType = options.responseType || "json";
2214
- if (options.signal && options.signal.aborted) {
2215
- return CancelablePromise.reject(new CancelablePromise.CancelError());
2216
- }
2217
- const request = new CancelablePromise((resolve, reject, onCancel) => {
1985
+ return new Promise((resolve, reject) => {
1986
+ var _a;
2218
1987
  if (this.user) {
2219
1988
  options = options || {};
2220
- options.headers = __spreadValues$s(__spreadValues$s({}, this.getAuthorizationHeaders()), options.headers);
1989
+ options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
2221
1990
  }
2222
1991
  if (this.requestTransform) {
2223
1992
  const [transUrl, transOptions] = this.requestTransform(url, options);
2224
1993
  url = transUrl;
2225
1994
  options = transOptions;
2226
1995
  }
2227
- loadData(url, resolve, options, reject, onCancel);
2228
- }).then((resp) => {
2229
- this._cleanActiveRequests(request);
2230
- return resp;
1996
+ let runOnAbort = void 0;
1997
+ loadData(url, resolve, options, reject, (handler) => {
1998
+ runOnAbort = handler;
1999
+ });
2000
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2001
+ if (runOnAbort !== void 0) {
2002
+ runOnAbort();
2003
+ }
2004
+ reject(new AbortError());
2005
+ });
2231
2006
  }).catch((httpError) => {
2232
- this._cleanActiveRequests(request);
2233
- if (httpError instanceof CancelablePromise.CancelError) ; else {
2007
+ if (httpError.name !== "AbortError") {
2234
2008
  {
2235
2009
  console.warn("DEV WARN", httpError);
2236
2010
  }
@@ -2239,31 +2013,24 @@ var NgwMap = (function (exports) {
2239
2013
  throw er;
2240
2014
  }
2241
2015
  }
2016
+ throw httpError;
2242
2017
  });
2243
- if (options.signal && typeof options.signal.addEventListener === "function") {
2244
- options.signal.addEventListener("abort", () => {
2245
- request.cancel();
2246
- this._cleanActiveRequests(request);
2247
- });
2248
- }
2249
- this.activeRequests.push(request);
2250
- return request;
2251
2018
  }
2252
2019
  _login(credentials, options) {
2253
- return this.getUserInfo(credentials, options).then((data) => {
2254
- this.user = data;
2255
- this.emitter.emit("login", data);
2256
- return data;
2257
- }).catch((er) => {
2258
- this.emitter.emit("login:error", er);
2259
- throw er;
2020
+ return __async$q(this, null, function* () {
2021
+ try {
2022
+ const data = yield this.getUserInfo(credentials, options);
2023
+ this.user = data;
2024
+ this.emitter.emit("login", data);
2025
+ return data;
2026
+ } catch (er) {
2027
+ this.emitter.emit("login:error", er);
2028
+ throw er;
2029
+ }
2260
2030
  });
2261
2031
  }
2262
- _cleanActiveRequests(request) {
2263
- const activeRequestIndex = this.activeRequests.indexOf(request);
2264
- if (activeRequestIndex !== -1) {
2265
- this.activeRequests.splice(activeRequestIndex, 1);
2266
- }
2032
+ _cleanActiveRequest(requestId) {
2033
+ delete this.activeRequests[requestId];
2267
2034
  }
2268
2035
  _handleHttpError(er) {
2269
2036
  if (er) {
@@ -2284,17 +2051,17 @@ var NgwMap = (function (exports) {
2284
2051
  });
2285
2052
 
2286
2053
  var __defProp$C = Object.defineProperty;
2287
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2288
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2289
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2054
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2055
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2056
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2290
2057
  var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2291
- var __spreadValues$r = (a, b) => {
2058
+ var __spreadValues$s = (a, b) => {
2292
2059
  for (var prop in b || (b = {}))
2293
- if (__hasOwnProp$s.call(b, prop))
2060
+ if (__hasOwnProp$t.call(b, prop))
2294
2061
  __defNormalProp$C(a, prop, b[prop]);
2295
- if (__getOwnPropSymbols$s)
2296
- for (var prop of __getOwnPropSymbols$s(b)) {
2297
- if (__propIsEnum$s.call(b, prop))
2062
+ if (__getOwnPropSymbols$t)
2063
+ for (var prop of __getOwnPropSymbols$t(b)) {
2064
+ if (__propIsEnum$t.call(b, prop))
2298
2065
  __defNormalProp$C(a, prop, b[prop]);
2299
2066
  }
2300
2067
  return a;
@@ -2342,7 +2109,7 @@ var NgwMap = (function (exports) {
2342
2109
  return false;
2343
2110
  }
2344
2111
  function featureFilter(feature, filters) {
2345
- const properties = __spreadValues$r({}, feature.properties);
2112
+ const properties = __spreadValues$s({}, feature.properties);
2346
2113
  if (properties) {
2347
2114
  properties.$id = feature.id;
2348
2115
  return propertiesFilter(properties, filters);
@@ -2380,22 +2147,42 @@ var NgwMap = (function (exports) {
2380
2147
  var __defProp$B = Object.defineProperty;
2381
2148
  var __defProps$c = Object.defineProperties;
2382
2149
  var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
2383
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2384
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2385
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2150
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2151
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2152
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2386
2153
  var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2387
- var __spreadValues$q = (a, b) => {
2154
+ var __spreadValues$r = (a, b) => {
2388
2155
  for (var prop in b || (b = {}))
2389
- if (__hasOwnProp$r.call(b, prop))
2156
+ if (__hasOwnProp$s.call(b, prop))
2390
2157
  __defNormalProp$B(a, prop, b[prop]);
2391
- if (__getOwnPropSymbols$r)
2392
- for (var prop of __getOwnPropSymbols$r(b)) {
2393
- if (__propIsEnum$r.call(b, prop))
2158
+ if (__getOwnPropSymbols$s)
2159
+ for (var prop of __getOwnPropSymbols$s(b)) {
2160
+ if (__propIsEnum$s.call(b, prop))
2394
2161
  __defNormalProp$B(a, prop, b[prop]);
2395
2162
  }
2396
2163
  return a;
2397
2164
  };
2398
2165
  var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
2166
+ var __async$p = (__this, __arguments, generator) => {
2167
+ return new Promise((resolve, reject) => {
2168
+ var fulfilled = (value) => {
2169
+ try {
2170
+ step(generator.next(value));
2171
+ } catch (e) {
2172
+ reject(e);
2173
+ }
2174
+ };
2175
+ var rejected = (value) => {
2176
+ try {
2177
+ step(generator.throw(value));
2178
+ } catch (e) {
2179
+ reject(e);
2180
+ }
2181
+ };
2182
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2183
+ step((generator = generator.apply(__this, __arguments)).next());
2184
+ });
2185
+ };
2399
2186
  const FEATURE_REQUEST_PARAMS = {
2400
2187
  srs: 4326,
2401
2188
  geom_format: "geojson"
@@ -2436,10 +2223,9 @@ var NgwMap = (function (exports) {
2436
2223
  }
2437
2224
  }
2438
2225
  function createFeatureFieldFilterQueries(opt) {
2439
- const queries = getQueries(
2440
- opt
2441
- );
2442
- return CancelablePromise.all(queries).then((itemsParts) => {
2226
+ return __async$p(this, null, function* () {
2227
+ const queries = getQueries(opt);
2228
+ const itemsParts = yield Promise.all(queries);
2443
2229
  const ids = [];
2444
2230
  const items = [];
2445
2231
  for (const part of itemsParts) {
@@ -2472,20 +2258,22 @@ var NgwMap = (function (exports) {
2472
2258
  return [`${isFldStr}${field_}__${operation}`, v];
2473
2259
  }
2474
2260
  function getQueries(opt, _queries = [], _parentAllParams = []) {
2261
+ var _a;
2475
2262
  const { filters } = opt;
2263
+ const paramList = (_a = opt.paramList) != null ? _a : [];
2476
2264
  const logic = typeof filters[0] === "string" ? filters[0] : "all";
2477
2265
  const filters_ = filters.filter((x) => Array.isArray(x));
2478
2266
  if (logic === "any") {
2479
2267
  for (const f of filters_) {
2480
2268
  if (isPropertyFilter(f)) {
2481
2269
  _queries.push(
2482
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2483
- paramList: [..._parentAllParams, createParam(f)]
2270
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2271
+ paramList: [..._parentAllParams, ...paramList, createParam(f)]
2484
2272
  }))
2485
2273
  );
2486
2274
  } else {
2487
2275
  getQueries(
2488
- __spreadProps$c(__spreadValues$q({}, opt), {
2276
+ __spreadProps$c(__spreadValues$r({}, opt), {
2489
2277
  filters: f
2490
2278
  }),
2491
2279
  _queries,
@@ -2506,7 +2294,7 @@ var NgwMap = (function (exports) {
2506
2294
  if (propertiesFilterList.length) {
2507
2295
  for (const x of propertiesFilterList) {
2508
2296
  getQueries(
2509
- __spreadProps$c(__spreadValues$q({}, opt), {
2297
+ __spreadProps$c(__spreadValues$r({}, opt), {
2510
2298
  filters: x
2511
2299
  }),
2512
2300
  _queries,
@@ -2515,8 +2303,8 @@ var NgwMap = (function (exports) {
2515
2303
  }
2516
2304
  } else {
2517
2305
  _queries.push(
2518
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2519
- paramList: [..._parentAllParams, ...filters2]
2306
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2307
+ paramList: [..._parentAllParams, ...paramList, ...filters2]
2520
2308
  }))
2521
2309
  );
2522
2310
  }
@@ -2531,7 +2319,7 @@ var NgwMap = (function (exports) {
2531
2319
  return `POLYGON((${polygon.join(", ")}))`;
2532
2320
  }
2533
2321
  function fetchNgwLayerItemsRequest(options) {
2534
- const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2322
+ const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2535
2323
  const {
2536
2324
  limit,
2537
2325
  cache,
@@ -2570,7 +2358,7 @@ var NgwMap = (function (exports) {
2570
2358
  if (paramList) {
2571
2359
  params.paramList = paramList;
2572
2360
  }
2573
- const reqParams = __spreadValues$q({
2361
+ const reqParams = __spreadValues$r({
2574
2362
  id: resourceId
2575
2363
  }, params);
2576
2364
  return connector.get(
@@ -2583,52 +2371,90 @@ var NgwMap = (function (exports) {
2583
2371
  var __defProp$A = Object.defineProperty;
2584
2372
  var __defProps$b = Object.defineProperties;
2585
2373
  var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2586
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2587
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2588
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2374
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2375
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2376
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2589
2377
  var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2590
- var __spreadValues$p = (a, b) => {
2378
+ var __spreadValues$q = (a, b) => {
2591
2379
  for (var prop in b || (b = {}))
2592
- if (__hasOwnProp$q.call(b, prop))
2380
+ if (__hasOwnProp$r.call(b, prop))
2593
2381
  __defNormalProp$A(a, prop, b[prop]);
2594
- if (__getOwnPropSymbols$q)
2595
- for (var prop of __getOwnPropSymbols$q(b)) {
2596
- if (__propIsEnum$q.call(b, prop))
2382
+ if (__getOwnPropSymbols$r)
2383
+ for (var prop of __getOwnPropSymbols$r(b)) {
2384
+ if (__propIsEnum$r.call(b, prop))
2597
2385
  __defNormalProp$A(a, prop, b[prop]);
2598
2386
  }
2599
2387
  return a;
2600
2388
  };
2601
2389
  var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
2390
+ var __async$o = (__this, __arguments, generator) => {
2391
+ return new Promise((resolve, reject) => {
2392
+ var fulfilled = (value) => {
2393
+ try {
2394
+ step(generator.next(value));
2395
+ } catch (e) {
2396
+ reject(e);
2397
+ }
2398
+ };
2399
+ var rejected = (value) => {
2400
+ try {
2401
+ step(generator.throw(value));
2402
+ } catch (e) {
2403
+ reject(e);
2404
+ }
2405
+ };
2406
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2407
+ step((generator = generator.apply(__this, __arguments)).next());
2408
+ });
2409
+ };
2602
2410
  function fetchNgwLayerItem(options) {
2603
- const params = __spreadValues$p({}, FEATURE_REQUEST_PARAMS);
2604
- updateItemRequestParam(params, options);
2605
- const queryParams = __spreadValues$p({
2606
- id: options.resourceId,
2607
- fid: options.featureId
2608
- }, params);
2609
- const cache = options.cache || true;
2610
- return options.connector.get("feature_layer.feature.item", { cache }, queryParams).then((resp) => {
2611
- return __spreadProps$b(__spreadValues$p({}, resp), {
2612
- toGeojson: () => {
2613
- if (resp.geom) {
2614
- return CancelablePromise.resolve(createGeoJsonFeature(resp));
2615
- } else {
2616
- return fetchNgwLayerItem(__spreadProps$b(__spreadValues$p({}, options), {
2617
- geom: true,
2618
- fields: null,
2619
- extensions: null
2620
- })).then((onlyGeomItem) => {
2621
- const geom = onlyGeomItem.geom;
2622
- return createGeoJsonFeature(__spreadProps$b(__spreadValues$p({}, resp), { geom }));
2623
- });
2624
- }
2411
+ return __async$o(this, null, function* () {
2412
+ const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2413
+ updateItemRequestParam(params, options);
2414
+ const queryParams = __spreadValues$q({
2415
+ id: options.resourceId,
2416
+ fid: options.featureId
2417
+ }, params);
2418
+ const resp = yield options.connector.get(
2419
+ "feature_layer.feature.item",
2420
+ options,
2421
+ queryParams
2422
+ );
2423
+ const toGeojson = () => __async$o(this, null, function* () {
2424
+ if (resp.geom) {
2425
+ return createGeoJsonFeature(resp);
2426
+ } else {
2427
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$b(__spreadValues$q({}, options), {
2428
+ geom: true,
2429
+ fields: null,
2430
+ extensions: null
2431
+ }));
2432
+ const geom = onlyGeomItem.geom;
2433
+ return createGeoJsonFeature(__spreadProps$b(__spreadValues$q({}, resp), { geom }));
2625
2434
  }
2626
2435
  });
2436
+ return __spreadProps$b(__spreadValues$q({}, resp), {
2437
+ toGeojson
2438
+ });
2627
2439
  });
2628
2440
  }
2629
2441
 
2630
2442
  var __defProp$z = Object.defineProperty;
2443
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2444
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2445
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2631
2446
  var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2447
+ var __spreadValues$p = (a, b) => {
2448
+ for (var prop in b || (b = {}))
2449
+ if (__hasOwnProp$q.call(b, prop))
2450
+ __defNormalProp$z(a, prop, b[prop]);
2451
+ if (__getOwnPropSymbols$q)
2452
+ for (var prop of __getOwnPropSymbols$q(b)) {
2453
+ if (__propIsEnum$q.call(b, prop))
2454
+ __defNormalProp$z(a, prop, b[prop]);
2455
+ }
2456
+ return a;
2457
+ };
2632
2458
  var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2633
2459
  class BookmarkItem {
2634
2460
  constructor(options) {
@@ -2646,11 +2472,11 @@ var NgwMap = (function (exports) {
2646
2472
  this.name = String(item.id);
2647
2473
  }
2648
2474
  }
2649
- extent() {
2475
+ extent(opt) {
2650
2476
  if (this._extent) {
2651
- return CancelablePromise.resolve(this._extent);
2477
+ return Promise.resolve(this._extent);
2652
2478
  }
2653
- return this.options.connector.get("feature_layer.feature.item_extent", null, {
2479
+ return this.options.connector.get("feature_layer.feature.item_extent", opt, {
2654
2480
  id: this.resourceId,
2655
2481
  fid: this.item.id
2656
2482
  }).then((resp) => {
@@ -2660,18 +2486,18 @@ var NgwMap = (function (exports) {
2660
2486
  return lonLat;
2661
2487
  });
2662
2488
  }
2663
- geoJson() {
2489
+ geoJson(opt) {
2664
2490
  if (this.item.geom) {
2665
- return CancelablePromise.resolve(createGeoJsonFeature(this.item));
2491
+ return Promise.resolve(createGeoJsonFeature(this.item));
2666
2492
  } else {
2667
- return fetchNgwLayerItem({
2493
+ return fetchNgwLayerItem(__spreadValues$p({
2668
2494
  resourceId: this.resourceId,
2669
2495
  featureId: this.item.id,
2670
2496
  connector: this.options.connector,
2671
2497
  geom: true,
2672
2498
  fields: null,
2673
2499
  extensions: null
2674
- }).then((onlyGeomItem) => {
2500
+ }, opt)).then((onlyGeomItem) => {
2675
2501
  const geom = onlyGeomItem.geom;
2676
2502
  this.item.geom = geom;
2677
2503
  return createGeoJsonFeature(this.item);
@@ -2681,22 +2507,20 @@ var NgwMap = (function (exports) {
2681
2507
  }
2682
2508
 
2683
2509
  function treeEvery(item, filter, relation, itemPrepare) {
2684
- return !!treeWrapper(item, filter, relation, treeEvery_, itemPrepare);
2510
+ return !!treeWrapper(item, filter, relation, treeEvery_);
2685
2511
  }
2686
2512
  function treeSome(item, filter, relation, itemPrepare) {
2687
- return !!treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2513
+ return !!treeWrapper(item, filter, relation, treeFind_);
2688
2514
  }
2689
2515
  function treeFind(item, filter, relation, itemPrepare) {
2690
- return treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2516
+ return treeWrapper(item, filter, relation, treeFind_);
2691
2517
  }
2692
2518
  function treeFilter(item, filter, relation, itemPrepare) {
2693
2519
  return treeWrapper(
2694
2520
  item,
2695
2521
  filter,
2696
2522
  relation,
2697
- treeFilter_,
2698
- itemPrepare
2699
- );
2523
+ treeFilter_);
2700
2524
  }
2701
2525
  function getChildren(item, relation = "children") {
2702
2526
  let children = [];
@@ -2713,13 +2537,6 @@ var NgwMap = (function (exports) {
2713
2537
  }
2714
2538
  function treeWrapper(item, filter = (x) => !!x, relation = "children", treeFunction, itemPrepare) {
2715
2539
  const filterFunction = typeof filter === "function" ? filter : (i) => propertiesFilter(i, filter);
2716
- if (itemPrepare) {
2717
- return treeFunction(
2718
- item,
2719
- (i) => filterFunction(itemPrepare(i)),
2720
- relation
2721
- );
2722
- }
2723
2540
  return treeFunction(item, filterFunction, relation);
2724
2541
  }
2725
2542
  function treeFind_(item, filterFunc = (x) => !!x, relation, _filtered = []) {
@@ -2986,7 +2803,7 @@ var NgwMap = (function (exports) {
2986
2803
  }
2987
2804
  return a;
2988
2805
  };
2989
- var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, typeof key !== "symbol" ? key + "" : key, value);
2806
+ var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, key + "" , value);
2990
2807
  const _CheckProperty = class _CheckProperty extends BaseProperty {
2991
2808
  constructor(name, item, options) {
2992
2809
  super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
@@ -3310,9 +3127,10 @@ var NgwMap = (function (exports) {
3310
3127
  function fetchNgwLayerExtent({
3311
3128
  resourceId,
3312
3129
  connector,
3313
- cache = true
3130
+ cache = true,
3131
+ signal
3314
3132
  }) {
3315
- return connector.get("layer.extent", { cache }, { id: resourceId }).then((resp) => {
3133
+ return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3316
3134
  if (resp) {
3317
3135
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3318
3136
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3324,11 +3142,12 @@ var NgwMap = (function (exports) {
3324
3142
  resourceId,
3325
3143
  featureId,
3326
3144
  connector,
3327
- cache = true
3145
+ cache = true,
3146
+ signal
3328
3147
  }) {
3329
3148
  return connector.get(
3330
3149
  "feature_layer.feature.item_extent",
3331
- { cache },
3150
+ { cache, signal },
3332
3151
  { id: resourceId, fid: featureId }
3333
3152
  ).then((resp) => {
3334
3153
  if (resp) {
@@ -3339,7 +3158,10 @@ var NgwMap = (function (exports) {
3339
3158
  });
3340
3159
  }
3341
3160
  function fetchNgwExtent(options) {
3342
- return options.connector.getResource(options.resourceId).then((resource) => {
3161
+ return options.connector.getResource(options.resourceId, {
3162
+ signal: options.signal,
3163
+ cache: options.cache
3164
+ }).then((resource) => {
3343
3165
  if (resource) {
3344
3166
  return fetchNgwResourceExtent(resource, options.connector, options);
3345
3167
  }
@@ -3347,11 +3169,11 @@ var NgwMap = (function (exports) {
3347
3169
  }
3348
3170
  function fetchNgwResourceExtent(item, connector, options) {
3349
3171
  if (item.webmap) {
3350
- return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
3172
+ return Promise.resolve(getNgwWebmapExtent(item.webmap));
3351
3173
  } else {
3352
3174
  const resource = item.resource;
3353
3175
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3354
- return connector.getResource(resource.parent.id).then((res) => {
3176
+ return connector.getResource(resource.parent.id, options).then((res) => {
3355
3177
  if (res) {
3356
3178
  return fetchNgwLayerExtent(__spreadProps$a(__spreadValues$l({}, options), {
3357
3179
  resourceId: res.resource.id,
@@ -3371,7 +3193,7 @@ var NgwMap = (function (exports) {
3371
3193
  var __defProp$s = Object.defineProperty;
3372
3194
  var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3373
3195
  var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3374
- var __async$k = (__this, __arguments, generator) => {
3196
+ var __async$n = (__this, __arguments, generator) => {
3375
3197
  return new Promise((resolve, reject) => {
3376
3198
  var fulfilled = (value) => {
3377
3199
  try {
@@ -3399,12 +3221,12 @@ var NgwMap = (function (exports) {
3399
3221
  }
3400
3222
  /** @deprecated use {@link NgwResource.getBounds} instead */
3401
3223
  getExtent() {
3402
- return __async$k(this, null, function* () {
3224
+ return __async$n(this, null, function* () {
3403
3225
  return this.getBounds();
3404
3226
  });
3405
3227
  }
3406
3228
  getBounds(options) {
3407
- return __async$k(this, null, function* () {
3229
+ return __async$n(this, null, function* () {
3408
3230
  if (this._extent) {
3409
3231
  return this._extent;
3410
3232
  }
@@ -3420,7 +3242,7 @@ var NgwMap = (function (exports) {
3420
3242
  }
3421
3243
  }
3422
3244
 
3423
- var __async$j = (__this, __arguments, generator) => {
3245
+ var __async$m = (__this, __arguments, generator) => {
3424
3246
  return new Promise((resolve, reject) => {
3425
3247
  var fulfilled = (value) => {
3426
3248
  try {
@@ -3441,7 +3263,7 @@ var NgwMap = (function (exports) {
3441
3263
  });
3442
3264
  };
3443
3265
  function resourceIdFromLayerOptions(options, connector) {
3444
- return __async$j(this, null, function* () {
3266
+ return __async$m(this, null, function* () {
3445
3267
  const resource = options.resource;
3446
3268
  const item = resource;
3447
3269
  let { keyname, resourceId } = options;
@@ -3543,7 +3365,7 @@ var NgwMap = (function (exports) {
3543
3365
  return target;
3544
3366
  };
3545
3367
  var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3546
- var __async$i = (__this, __arguments, generator) => {
3368
+ var __async$l = (__this, __arguments, generator) => {
3547
3369
  return new Promise((resolve, reject) => {
3548
3370
  var fulfilled = (value) => {
3549
3371
  try {
@@ -3595,7 +3417,7 @@ var NgwMap = (function (exports) {
3595
3417
  }
3596
3418
  }
3597
3419
  addLayer(options) {
3598
- return __async$i(this, null, function* () {
3420
+ return __async$l(this, null, function* () {
3599
3421
  if (!this.qms && options.qmsId) {
3600
3422
  try {
3601
3423
  this.qms = yield loadJson(
@@ -3703,7 +3525,7 @@ var NgwMap = (function (exports) {
3703
3525
  };
3704
3526
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3705
3527
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3706
- var __async$h = (__this, __arguments, generator) => {
3528
+ var __async$k = (__this, __arguments, generator) => {
3707
3529
  return new Promise((resolve, reject) => {
3708
3530
  var fulfilled = (value) => {
3709
3531
  try {
@@ -3724,7 +3546,7 @@ var NgwMap = (function (exports) {
3724
3546
  });
3725
3547
  };
3726
3548
  function createBasemapLayerAdapter(_0) {
3727
- return __async$h(this, arguments, function* ({
3549
+ return __async$k(this, arguments, function* ({
3728
3550
  webMap,
3729
3551
  item
3730
3552
  }) {
@@ -3745,7 +3567,7 @@ var NgwMap = (function (exports) {
3745
3567
  if (TileAdapter) {
3746
3568
  class BasemapTileAdapter extends TileAdapter {
3747
3569
  addLayer(opt) {
3748
- return __async$h(this, null, function* () {
3570
+ return __async$k(this, null, function* () {
3749
3571
  return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$9(__spreadValues$i({}, opt), { url }));
3750
3572
  });
3751
3573
  }
@@ -3785,11 +3607,12 @@ var NgwMap = (function (exports) {
3785
3607
  function fetchNgwLayerCount({
3786
3608
  connector,
3787
3609
  resourceId,
3788
- cache = true
3610
+ cache = true,
3611
+ signal
3789
3612
  }) {
3790
3613
  return connector.get(
3791
3614
  "feature_layer.feature.count",
3792
- { cache },
3615
+ { cache, signal },
3793
3616
  {
3794
3617
  id: resourceId
3795
3618
  }
@@ -3843,13 +3666,34 @@ var NgwMap = (function (exports) {
3843
3666
  return a;
3844
3667
  };
3845
3668
  var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
3669
+ var __async$j = (__this, __arguments, generator) => {
3670
+ return new Promise((resolve, reject) => {
3671
+ var fulfilled = (value) => {
3672
+ try {
3673
+ step(generator.next(value));
3674
+ } catch (e) {
3675
+ reject(e);
3676
+ }
3677
+ };
3678
+ var rejected = (value) => {
3679
+ try {
3680
+ step(generator.throw(value));
3681
+ } catch (e) {
3682
+ reject(e);
3683
+ }
3684
+ };
3685
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3686
+ step((generator = generator.apply(__this, __arguments)).next());
3687
+ });
3688
+ };
3846
3689
  function fetchNgwLayerItems(options) {
3847
- const filters = options.filters;
3848
- if (filters) {
3849
- return createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
3850
- filters
3851
- })).then((data) => {
3852
- var _a;
3690
+ return __async$j(this, null, function* () {
3691
+ var _a;
3692
+ const filters = options.filters;
3693
+ if (filters) {
3694
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
3695
+ filters
3696
+ }));
3853
3697
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3854
3698
  if (clientFilterValidate) {
3855
3699
  data = data.filter((y) => {
@@ -3861,10 +3705,10 @@ var NgwMap = (function (exports) {
3861
3705
  });
3862
3706
  }
3863
3707
  return data;
3864
- });
3865
- } else {
3866
- return fetchNgwLayerItemsRequest(options);
3867
- }
3708
+ } else {
3709
+ return fetchNgwLayerItemsRequest(options);
3710
+ }
3711
+ });
3868
3712
  }
3869
3713
  function isFilterWithAnyCase(filters) {
3870
3714
  if (filters[0] === "any") {
@@ -3882,8 +3726,29 @@ var NgwMap = (function (exports) {
3882
3726
  return false;
3883
3727
  }
3884
3728
 
3729
+ var __async$i = (__this, __arguments, generator) => {
3730
+ return new Promise((resolve, reject) => {
3731
+ var fulfilled = (value) => {
3732
+ try {
3733
+ step(generator.next(value));
3734
+ } catch (e) {
3735
+ reject(e);
3736
+ }
3737
+ };
3738
+ var rejected = (value) => {
3739
+ try {
3740
+ step(generator.throw(value));
3741
+ } catch (e) {
3742
+ reject(e);
3743
+ }
3744
+ };
3745
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3746
+ step((generator = generator.apply(__this, __arguments)).next());
3747
+ });
3748
+ };
3885
3749
  function fetchNgwLayerFeatures(options) {
3886
- return fetchNgwLayerItems(options).then((x) => {
3750
+ return __async$i(this, null, function* () {
3751
+ const x = yield fetchNgwLayerItems(options);
3887
3752
  const features = [];
3888
3753
  x.forEach((y) => {
3889
3754
  features.push(createGeoJsonFeature(y));
@@ -3943,7 +3808,7 @@ var NgwMap = (function (exports) {
3943
3808
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
3944
3809
  var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
3945
3810
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3946
- var __async$g = (__this, __arguments, generator) => {
3811
+ var __async$h = (__this, __arguments, generator) => {
3947
3812
  return new Promise((resolve, reject) => {
3948
3813
  var fulfilled = (value) => {
3949
3814
  try {
@@ -3964,7 +3829,7 @@ var NgwMap = (function (exports) {
3964
3829
  });
3965
3830
  };
3966
3831
  function createGeoJsonAdapter(props) {
3967
- return __async$g(this, null, function* () {
3832
+ return __async$h(this, null, function* () {
3968
3833
  var _a, _b;
3969
3834
  const {
3970
3835
  item,
@@ -3980,29 +3845,35 @@ var NgwMap = (function (exports) {
3980
3845
  const _loadedIds = [];
3981
3846
  let _fullDataLoad = false;
3982
3847
  let _lastFilterArgs;
3983
- let _dataPromise;
3848
+ let internalAbortController;
3984
3849
  const resourceId = yield resourceIdFromLayerOptions(options, connector);
3985
3850
  if ((_b = (_a = options.adapterOptions) == null ? void 0 : _a.popupOptions) == null ? void 0 : _b.fromProperties) {
3986
3851
  options.adapterOptions.popupOptions.createPopupContent = ({ feature }) => {
3987
3852
  return feature && createPopupContent(feature, item);
3988
3853
  };
3989
3854
  }
3990
- const getData = (filters, filterOpt) => __async$g(this, null, function* () {
3855
+ const getData = (filters, filterOpt) => __async$h(this, null, function* () {
3991
3856
  abort();
3857
+ internalAbortController = new AbortController();
3858
+ const internalSignal = internalAbortController.signal;
3859
+ if (filterOpt == null ? void 0 : filterOpt.signal) {
3860
+ filterOpt.signal.addEventListener("abort", internalAbortController.abort);
3861
+ }
3862
+ filterOpt = filterOpt || {};
3863
+ filterOpt.signal = internalSignal;
3992
3864
  _lastFilterArgs = { filters, options: filterOpt };
3993
- _dataPromise = fetchNgwLayerFeatureCollection(__spreadValues$g({
3865
+ return fetchNgwLayerFeatureCollection(__spreadValues$g({
3994
3866
  resourceId,
3995
3867
  filters,
3996
3868
  connector,
3997
3869
  cache: true
3998
3870
  }, filterOpt));
3999
- return yield _dataPromise;
4000
3871
  });
4001
3872
  let removed = false;
4002
3873
  const abort = () => {
4003
- if (_dataPromise) {
4004
- _dataPromise.cancel();
4005
- _dataPromise = void 0;
3874
+ if (internalAbortController) {
3875
+ internalAbortController.abort();
3876
+ internalAbortController = void 0;
4006
3877
  }
4007
3878
  };
4008
3879
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
@@ -4015,7 +3886,7 @@ var NgwMap = (function (exports) {
4015
3886
  __publicField$f(this, "__disableMapMoveListener");
4016
3887
  }
4017
3888
  addLayer(opt) {
4018
- return __async$g(this, null, function* () {
3889
+ return __async$h(this, null, function* () {
4019
3890
  let needUpdate = !opt.data;
4020
3891
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
4021
3892
  if (options.id !== void 0) {
@@ -4060,7 +3931,7 @@ var NgwMap = (function (exports) {
4060
3931
  return this.getBounds();
4061
3932
  }
4062
3933
  getBounds() {
4063
- return __async$g(this, null, function* () {
3934
+ return __async$h(this, null, function* () {
4064
3935
  const hasData = this.getLayers && this.getLayers().length;
4065
3936
  const strategy = this.options.strategy;
4066
3937
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -4086,7 +3957,7 @@ var NgwMap = (function (exports) {
4086
3957
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4087
3958
  }
4088
3959
  updateLayer(filterArgs) {
4089
- return __async$g(this, null, function* () {
3960
+ return __async$h(this, null, function* () {
4090
3961
  var _a2;
4091
3962
  filterArgs = filterArgs || _lastFilterArgs || {};
4092
3963
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
@@ -4152,7 +4023,7 @@ var NgwMap = (function (exports) {
4152
4023
  });
4153
4024
  }
4154
4025
  propertiesFilter(filters, opt) {
4155
- return __async$g(this, null, function* () {
4026
+ return __async$h(this, null, function* () {
4156
4027
  abort();
4157
4028
  if (this.filter && _fullDataLoad) {
4158
4029
  this.filter((e) => {
@@ -4226,7 +4097,7 @@ var NgwMap = (function (exports) {
4226
4097
  });
4227
4098
  }
4228
4099
 
4229
- var __async$f = (__this, __arguments, generator) => {
4100
+ var __async$g = (__this, __arguments, generator) => {
4230
4101
  return new Promise((resolve, reject) => {
4231
4102
  var fulfilled = (value) => {
4232
4103
  try {
@@ -4247,7 +4118,7 @@ var NgwMap = (function (exports) {
4247
4118
  });
4248
4119
  };
4249
4120
  function createWebMapAdapter(_0) {
4250
- return __async$f(this, arguments, function* ({
4121
+ return __async$g(this, arguments, function* ({
4251
4122
  layerOptions: options,
4252
4123
  webMap,
4253
4124
  connector
@@ -4375,7 +4246,7 @@ var NgwMap = (function (exports) {
4375
4246
  };
4376
4247
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4377
4248
  var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4378
- var __async$e = (__this, __arguments, generator) => {
4249
+ var __async$f = (__this, __arguments, generator) => {
4379
4250
  return new Promise((resolve, reject) => {
4380
4251
  var fulfilled = (value) => {
4381
4252
  try {
@@ -4396,7 +4267,7 @@ var NgwMap = (function (exports) {
4396
4267
  });
4397
4268
  };
4398
4269
  function createRasterAdapter(_0) {
4399
- return __async$e(this, arguments, function* ({
4270
+ return __async$f(this, arguments, function* ({
4400
4271
  layerOptions,
4401
4272
  webMap,
4402
4273
  connector,
@@ -4452,7 +4323,7 @@ var NgwMap = (function (exports) {
4452
4323
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4453
4324
  }
4454
4325
  getLegend(options) {
4455
- return __async$e(this, null, function* () {
4326
+ return __async$f(this, null, function* () {
4456
4327
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4457
4328
  params: { id: resourceId },
4458
4329
  cache: true
@@ -4472,7 +4343,7 @@ var NgwMap = (function (exports) {
4472
4343
  });
4473
4344
  }
4474
4345
  getIdentificationIds() {
4475
- return __async$e(this, null, function* () {
4346
+ return __async$f(this, null, function* () {
4476
4347
  if (this.item) {
4477
4348
  if (adapter === "MVT") {
4478
4349
  return [this.item.resource.id];
@@ -4513,7 +4384,7 @@ var NgwMap = (function (exports) {
4513
4384
  return a;
4514
4385
  };
4515
4386
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
4516
- var __async$d = (__this, __arguments, generator) => {
4387
+ var __async$e = (__this, __arguments, generator) => {
4517
4388
  return new Promise((resolve, reject) => {
4518
4389
  var fulfilled = (value) => {
4519
4390
  try {
@@ -4549,7 +4420,7 @@ var NgwMap = (function (exports) {
4549
4420
  "tmsclient_layer"
4550
4421
  ];
4551
4422
  function createAdapterFromFirstStyle(_0) {
4552
- return __async$d(this, arguments, function* ({
4423
+ return __async$e(this, arguments, function* ({
4553
4424
  layerOptions,
4554
4425
  webMap,
4555
4426
  connector,
@@ -4568,7 +4439,7 @@ var NgwMap = (function (exports) {
4568
4439
  });
4569
4440
  }
4570
4441
  function createAsyncAdapter(options, webMap, connector) {
4571
- return __async$d(this, null, function* () {
4442
+ return __async$e(this, null, function* () {
4572
4443
  let adapter;
4573
4444
  let item;
4574
4445
  const adapterType = options.adapter;
@@ -4765,7 +4636,7 @@ var NgwMap = (function (exports) {
4765
4636
  return a;
4766
4637
  };
4767
4638
  var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4768
- var __async$c = (__this, __arguments, generator) => {
4639
+ var __async$d = (__this, __arguments, generator) => {
4769
4640
  return new Promise((resolve, reject) => {
4770
4641
  var fulfilled = (value) => {
4771
4642
  try {
@@ -4815,7 +4686,7 @@ var NgwMap = (function (exports) {
4815
4686
  }
4816
4687
  }
4817
4688
  static create(webMap, item, options, connector, parent) {
4818
- return __async$c(this, null, function* () {
4689
+ return __async$d(this, null, function* () {
4819
4690
  const ngwWebmapItem = new _NgwWebmapItem(
4820
4691
  webMap,
4821
4692
  item,
@@ -4844,15 +4715,14 @@ var NgwMap = (function (exports) {
4844
4715
  return this.layer;
4845
4716
  }
4846
4717
  getLegend(options) {
4847
- return __async$c(this, null, function* () {
4718
+ return __async$d(this, null, function* () {
4848
4719
  var _a;
4849
4720
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4850
4721
  if (id !== void 0) {
4851
4722
  const connector = this.connector;
4852
4723
  if (connector) {
4853
4724
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4854
- params: { id: this.item.resourceId },
4855
- cache: true
4725
+ params: { id: this.item.resourceId }
4856
4726
  }, options));
4857
4727
  const legend = {
4858
4728
  layerId: id,
@@ -5043,7 +4913,7 @@ var NgwMap = (function (exports) {
5043
4913
  return a;
5044
4914
  };
5045
4915
  var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5046
- var __async$b = (__this, __arguments, generator) => {
4916
+ var __async$c = (__this, __arguments, generator) => {
5047
4917
  return new Promise((resolve, reject) => {
5048
4918
  var fulfilled = (value) => {
5049
4919
  try {
@@ -5064,7 +4934,7 @@ var NgwMap = (function (exports) {
5064
4934
  });
5065
4935
  };
5066
4936
  function createOnFirstShowAdapter(_0) {
5067
- return __async$b(this, arguments, function* ({
4937
+ return __async$c(this, arguments, function* ({
5068
4938
  webMap,
5069
4939
  adapterOptions = {},
5070
4940
  onLayerAdded,
@@ -5090,7 +4960,7 @@ var NgwMap = (function (exports) {
5090
4960
  return this._removed;
5091
4961
  }
5092
4962
  showLayer() {
5093
- return __async$b(this, null, function* () {
4963
+ return __async$c(this, null, function* () {
5094
4964
  this.options.visibility = true;
5095
4965
  if (this.layer.length) {
5096
4966
  for (const x of this.layer) {
@@ -5102,7 +4972,7 @@ var NgwMap = (function (exports) {
5102
4972
  });
5103
4973
  }
5104
4974
  hideLayer() {
5105
- return __async$b(this, null, function* () {
4975
+ return __async$c(this, null, function* () {
5106
4976
  this.options.visibility = false;
5107
4977
  if (this.layer) {
5108
4978
  for (const x of this.layer) {
@@ -5112,7 +4982,7 @@ var NgwMap = (function (exports) {
5112
4982
  });
5113
4983
  }
5114
4984
  loadLayer() {
5115
- return __async$b(this, null, function* () {
4985
+ return __async$c(this, null, function* () {
5116
4986
  if (!this.layer.length && !this._creatingInProgress) {
5117
4987
  this._creatingInProgress = true;
5118
4988
  const Adapter = yield createAdapter(this);
@@ -5146,7 +5016,7 @@ var NgwMap = (function (exports) {
5146
5016
  });
5147
5017
  }
5148
5018
 
5149
- var __async$a = (__this, __arguments, generator) => {
5019
+ var __async$b = (__this, __arguments, generator) => {
5150
5020
  return new Promise((resolve, reject) => {
5151
5021
  var fulfilled = (value) => {
5152
5022
  try {
@@ -5167,7 +5037,7 @@ var NgwMap = (function (exports) {
5167
5037
  });
5168
5038
  };
5169
5039
  function createOnFirstShowNgwAdapter(_0) {
5170
- return __async$a(this, arguments, function* ({
5040
+ return __async$b(this, arguments, function* ({
5171
5041
  webMap,
5172
5042
  connector,
5173
5043
  item,
@@ -5220,7 +5090,7 @@ var NgwMap = (function (exports) {
5220
5090
  return a;
5221
5091
  };
5222
5092
  var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5223
- var __async$9 = (__this, __arguments, generator) => {
5093
+ var __async$a = (__this, __arguments, generator) => {
5224
5094
  return new Promise((resolve, reject) => {
5225
5095
  var fulfilled = (value) => {
5226
5096
  try {
@@ -5271,7 +5141,7 @@ var NgwMap = (function (exports) {
5271
5141
  }
5272
5142
  }
5273
5143
  addLayer(options) {
5274
- return __async$9(this, null, function* () {
5144
+ return __async$a(this, null, function* () {
5275
5145
  var _a, _b;
5276
5146
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5277
5147
  this.layer = yield this._getWebMapLayerItem();
@@ -5304,21 +5174,21 @@ var NgwMap = (function (exports) {
5304
5174
  delete this._webmapLayersIds;
5305
5175
  }
5306
5176
  showLayer() {
5307
- return __async$9(this, null, function* () {
5177
+ return __async$a(this, null, function* () {
5308
5178
  if (this.layer && this.layer.properties) {
5309
5179
  return this.layer.properties.property("visibility").set(true);
5310
5180
  }
5311
5181
  });
5312
5182
  }
5313
5183
  hideLayer() {
5314
- return __async$9(this, null, function* () {
5184
+ return __async$a(this, null, function* () {
5315
5185
  if (this.layer && this.layer.properties) {
5316
5186
  return this.layer.properties.property("visibility").set(false);
5317
5187
  }
5318
5188
  });
5319
5189
  }
5320
5190
  setOpacity(val) {
5321
- return __async$9(this, null, function* () {
5191
+ return __async$a(this, null, function* () {
5322
5192
  if (this.layer && this.layer.properties) {
5323
5193
  return this.layer.properties.property("opacity").set(val);
5324
5194
  }
@@ -5343,22 +5213,22 @@ var NgwMap = (function (exports) {
5343
5213
  return webmap.bookmark_resource.id;
5344
5214
  }
5345
5215
  }
5346
- fetchBookmarks() {
5216
+ fetchBookmarks(options) {
5347
5217
  const bookmarkResId = this.getBookmarksResourceId();
5348
5218
  const connector = this.options.connector;
5349
5219
  if (bookmarkResId) {
5350
- return connector.getResourceOrFail(bookmarkResId).then((item) => {
5220
+ return connector.getResourceOrFail(bookmarkResId, options).then((item) => {
5351
5221
  var _a;
5352
5222
  const labelField = (_a = item.feature_layer) == null ? void 0 : _a.fields.find(
5353
5223
  (x) => x.label_field
5354
5224
  );
5355
5225
  const keyname = labelField && labelField.keyname;
5356
- return fetchNgwLayerItems({
5226
+ return fetchNgwLayerItems(__spreadValues$a({
5357
5227
  connector,
5358
5228
  resourceId: bookmarkResId,
5359
5229
  geom: false,
5360
5230
  fields: keyname ? [keyname] : void 0
5361
- }).then((items) => {
5231
+ }, options)).then((items) => {
5362
5232
  const bookmarks = [];
5363
5233
  for (const i of items) {
5364
5234
  const bookmark = new BookmarkItem({
@@ -5377,24 +5247,24 @@ var NgwMap = (function (exports) {
5377
5247
  "Webmap was not loaded correctly, it is impossible to extract bookmarks"
5378
5248
  );
5379
5249
  }
5380
- getLegend() {
5381
- return __async$9(this, null, function* () {
5250
+ getLegend(options) {
5251
+ return __async$a(this, null, function* () {
5382
5252
  const legends = [];
5383
5253
  let deps = this.getDependLayers();
5384
5254
  deps = deps.sort((a, b) => b.id - a.id);
5385
5255
  for (const d of deps) {
5386
- const layerLegend = yield d.getLegend();
5256
+ const layerLegend = yield d.getLegend(options);
5387
5257
  legends.push(...layerLegend);
5388
5258
  }
5389
5259
  return legends;
5390
5260
  });
5391
5261
  }
5392
- getIdentificationIds() {
5393
- return __async$9(this, null, function* () {
5262
+ getIdentificationIds(options) {
5263
+ return __async$a(this, null, function* () {
5394
5264
  const visibleLayers = [];
5395
5265
  let ids = this._webmapLayersIds;
5396
5266
  if (!ids) {
5397
- ids = yield this._getWebMapIds();
5267
+ ids = yield this._getWebMapIds(options);
5398
5268
  this._webmapLayersIds = ids;
5399
5269
  }
5400
5270
  if (ids && ids.length) {
@@ -5416,7 +5286,7 @@ var NgwMap = (function (exports) {
5416
5286
  });
5417
5287
  }
5418
5288
  _getWebMapLayerItem() {
5419
- return __async$9(this, null, function* () {
5289
+ return __async$a(this, null, function* () {
5420
5290
  if (this.resourceId) {
5421
5291
  const webmap = yield this.getWebMapConfig(this.resourceId);
5422
5292
  if (webmap && webmap.root_item) {
@@ -5449,7 +5319,7 @@ var NgwMap = (function (exports) {
5449
5319
  });
5450
5320
  }
5451
5321
  getWebMapConfig(id) {
5452
- return __async$9(this, null, function* () {
5322
+ return __async$a(this, null, function* () {
5453
5323
  const data = yield this.options.connector.getResource(id);
5454
5324
  if (data) {
5455
5325
  this.response = data;
@@ -5543,8 +5413,8 @@ var NgwMap = (function (exports) {
5543
5413
  }
5544
5414
  return item;
5545
5415
  }
5546
- _getWebMapIds() {
5547
- return __async$9(this, null, function* () {
5416
+ _getWebMapIds(options) {
5417
+ return __async$a(this, null, function* () {
5548
5418
  const webMapItem = this.layer;
5549
5419
  if (webMapItem && webMapItem.item.item_type === "root") {
5550
5420
  const layers = webMapItem.tree.getDescendants();
@@ -5553,7 +5423,7 @@ var NgwMap = (function (exports) {
5553
5423
  const item = x.item;
5554
5424
  if (item.item_type === "layer") {
5555
5425
  const id = item.layer_style_id;
5556
- const promise = this.options.connector.getResource(id).then((y) => {
5426
+ const promise = this.options.connector.getResource(id, options).then((y) => {
5557
5427
  if (y) {
5558
5428
  const parentId = Number(y.resource.parent.id);
5559
5429
  item.parentId = parentId;
@@ -5587,7 +5457,7 @@ var NgwMap = (function (exports) {
5587
5457
  return a;
5588
5458
  };
5589
5459
  var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5590
- var __async$8 = (__this, __arguments, generator) => {
5460
+ var __async$9 = (__this, __arguments, generator) => {
5591
5461
  return new Promise((resolve, reject) => {
5592
5462
  var fulfilled = (value) => {
5593
5463
  try {
@@ -5632,7 +5502,7 @@ var NgwMap = (function (exports) {
5632
5502
  classAdapters[cls] = adapter;
5633
5503
  }
5634
5504
  onLoadSync(webMap) {
5635
- return __async$8(this, null, function* () {
5505
+ return __async$9(this, null, function* () {
5636
5506
  if (this.options.resourceId && this.url) {
5637
5507
  const resourceIds = [this.options.resourceId];
5638
5508
  if (resourceIds.length) {
@@ -5715,7 +5585,7 @@ var NgwMap = (function (exports) {
5715
5585
  }
5716
5586
  identify(options = {}) {
5717
5587
  if (this._item) {
5718
- return CancelablePromise.resolve(this._item);
5588
+ return Promise.resolve(this._item);
5719
5589
  }
5720
5590
  return fetchNgwLayerItem(__spreadValues$8({
5721
5591
  connector: this.connector,
@@ -5730,30 +5600,30 @@ var NgwMap = (function (exports) {
5730
5600
  return resp;
5731
5601
  });
5732
5602
  }
5733
- resource() {
5603
+ resource(opt) {
5734
5604
  if (this._resource) {
5735
- return CancelablePromise.resolve(this._resource.feature_layer);
5605
+ return Promise.resolve(this._resource.feature_layer);
5736
5606
  }
5737
- return this.connector.getResource(this.layerId).then((resp) => {
5607
+ return this.connector.getResource(this.layerId, opt).then((resp) => {
5738
5608
  this._resource = resp;
5739
5609
  return this._resource.feature_layer;
5740
5610
  });
5741
5611
  }
5742
- getBounds() {
5612
+ getBounds(opt) {
5743
5613
  if (this._extent) {
5744
- return CancelablePromise.resolve(this._extent);
5614
+ return Promise.resolve(this._extent);
5745
5615
  }
5746
- return fetchNgwLayerItemExtent({
5616
+ return fetchNgwLayerItemExtent(__spreadValues$8({
5747
5617
  connector: this.connector,
5748
5618
  featureId: this.id,
5749
5619
  resourceId: this.layerId
5750
- });
5620
+ }, opt));
5751
5621
  }
5752
- geojson() {
5622
+ geojson(options) {
5753
5623
  if (this._geojson) {
5754
- return CancelablePromise.resolve(this._geojson);
5624
+ return Promise.resolve(this._geojson);
5755
5625
  }
5756
- return this.identify().then((resp) => {
5626
+ return this.identify(options).then((resp) => {
5757
5627
  return resp.toGeojson().then((geojson) => {
5758
5628
  this._geojson = geojson;
5759
5629
  return geojson;
@@ -5762,8 +5632,29 @@ var NgwMap = (function (exports) {
5762
5632
  }
5763
5633
  }
5764
5634
 
5635
+ var __async$8 = (__this, __arguments, generator) => {
5636
+ return new Promise((resolve, reject) => {
5637
+ var fulfilled = (value) => {
5638
+ try {
5639
+ step(generator.next(value));
5640
+ } catch (e) {
5641
+ reject(e);
5642
+ }
5643
+ };
5644
+ var rejected = (value) => {
5645
+ try {
5646
+ step(generator.throw(value));
5647
+ } catch (e) {
5648
+ reject(e);
5649
+ }
5650
+ };
5651
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
5652
+ step((generator = generator.apply(__this, __arguments)).next());
5653
+ });
5654
+ };
5765
5655
  function fetchNgwLayerFeature(options) {
5766
- return fetchNgwLayerItem(options).then((item) => {
5656
+ return __async$8(this, null, function* () {
5657
+ const item = yield fetchNgwLayerItem(options);
5767
5658
  return createGeoJsonFeature(item);
5768
5659
  });
5769
5660
  }
@@ -5848,7 +5739,7 @@ var NgwMap = (function (exports) {
5848
5739
  const withGeom = item.features.find((x) => x.geom);
5849
5740
  if (withGeom && withGeom.geom) {
5850
5741
  const geom = withGeom.geom;
5851
- return CancelablePromise.resolve(
5742
+ return Promise.resolve(
5852
5743
  createGeoJsonFeature(__spreadProps$4(__spreadValues$7({}, withGeom), {
5853
5744
  geom
5854
5745
  }))
@@ -5861,7 +5752,7 @@ var NgwMap = (function (exports) {
5861
5752
  if (params && params.length) {
5862
5753
  return fetchNgwLayerFeature(__spreadValues$7(__spreadProps$4(__spreadValues$7({}, requestOptions), { connector }), params[0]));
5863
5754
  }
5864
- return CancelablePromise.resolve(void 0);
5755
+ return Promise.resolve(void 0);
5865
5756
  }
5866
5757
  function fetchIdentifyItem(options) {
5867
5758
  const { connector, identify } = options;
@@ -5871,7 +5762,7 @@ var NgwMap = (function (exports) {
5871
5762
  connector
5872
5763
  }, options.requestOptions), params[0]));
5873
5764
  }
5874
- return CancelablePromise.resolve(void 0);
5765
+ return Promise.resolve(void 0);
5875
5766
  }
5876
5767
  function featureLayerIdentify(options) {
5877
5768
  const { geom, signal, cache, layers } = options;
@@ -5915,9 +5806,9 @@ var NgwMap = (function (exports) {
5915
5806
  function sendIdentifyRequest(ev, options) {
5916
5807
  deprecatedMapClick(ev);
5917
5808
  const [lng, lat] = ev.lngLat;
5918
- const { geom, radius, signal, cache } = options;
5809
+ const { geom, radius } = options;
5919
5810
  const geom_ = geom != null ? geom : getCirclePolygonCoordinates(lng, lat, radius);
5920
- return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_, signal, cache }));
5811
+ return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_ }));
5921
5812
  }
5922
5813
  function createIdentifyItem(opt) {
5923
5814
  return new IdentifyItem(opt);
@@ -7127,7 +7018,7 @@ var NgwMap = (function (exports) {
7127
7018
  __publicField$3(this, "_mapState", []);
7128
7019
  __publicField$3(this, "_extent");
7129
7020
  __publicField$3(this, "_eventsStatus", {});
7130
- __publicField$3(this, "_coordFromMapClickPromise");
7021
+ __publicField$3(this, "_coordFromMapClickAbort");
7131
7022
  __publicField$3(this, "_mapEvents", {});
7132
7023
  this.mapAdapter = mapOptions.mapAdapter;
7133
7024
  this._starterKits = mapOptions.starterKits || [];
@@ -7442,36 +7333,34 @@ var NgwMap = (function (exports) {
7442
7333
  return { stop };
7443
7334
  }
7444
7335
  stopGetCoordFromMapClick() {
7445
- if (this._coordFromMapClickPromise) {
7446
- this._coordFromMapClickPromise.cancel();
7336
+ if (this._coordFromMapClickAbort) {
7337
+ this._coordFromMapClickAbort();
7338
+ this._coordFromMapClickAbort = void 0;
7447
7339
  }
7448
7340
  }
7449
7341
  getCoordFromMapClick() {
7450
- if (!this._coordFromMapClickPromise) {
7451
- this._coordFromMapClickPromise = new CancelablePromise(
7452
- (resolve, reject, onCancel) => {
7453
- const cursor = this.getCursor() || "grab";
7454
- this._removeEventListeners({ include: ["click"] });
7455
- this.setCursor("crosshair");
7456
- const onCancel_ = () => {
7457
- this.setCursor(cursor);
7458
- this._addEventsListeners({ include: ["click"] });
7459
- this.mapAdapter.emitter.off("click", onMapClick);
7460
- this._coordFromMapClickPromise = void 0;
7461
- };
7462
- const onMapClick = (e) => {
7463
- onCancel_();
7464
- deprecatedMapClick(e);
7465
- resolve(e.lngLat);
7466
- };
7467
- this.mapAdapter.emitter.once("click", onMapClick);
7468
- onCancel(onCancel_);
7469
- }
7470
- );
7342
+ if (!this._coordFromMapClickAbort) {
7343
+ return new Promise((resolve, reject) => {
7344
+ const cursor = this.getCursor() || "grab";
7345
+ this._removeEventListeners({ include: ["click"] });
7346
+ this.setCursor("crosshair");
7347
+ const onCancel_ = () => {
7348
+ this.setCursor(cursor);
7349
+ this._addEventsListeners({ include: ["click"] });
7350
+ this.mapAdapter.emitter.off("click", onMapClick);
7351
+ this._coordFromMapClickAbort = void 0;
7352
+ };
7353
+ const onMapClick = (e) => {
7354
+ onCancel_();
7355
+ deprecatedMapClick(e);
7356
+ resolve(e.lngLat);
7357
+ };
7358
+ this.mapAdapter.emitter.once("click", onMapClick);
7359
+ this._coordFromMapClickAbort = onCancel_;
7360
+ });
7471
7361
  } else {
7472
7362
  return this.getCoordFromMapClick();
7473
7363
  }
7474
- return this._coordFromMapClickPromise;
7475
7364
  }
7476
7365
  _emitStatusEvent(eventName, data) {
7477
7366
  const _eventName = eventName;
@@ -9286,26 +9175,35 @@ var NgwMap = (function (exports) {
9286
9175
  }, options));
9287
9176
  }
9288
9177
  fetchIdentifyItem(identify, requestOptions) {
9178
+ const abortController = new AbortController();
9179
+ const abortSignal = abortController.signal;
9180
+ if (requestOptions == null ? void 0 : requestOptions.signal) {
9181
+ requestOptions.signal.addEventListener("abort", abortController.abort);
9182
+ }
9183
+ requestOptions = requestOptions || {};
9184
+ requestOptions.signal = abortSignal;
9289
9185
  const promise = fetchIdentifyItem({
9290
9186
  identify,
9291
9187
  connector: this.connector,
9292
9188
  requestOptions
9293
9189
  // multiple,
9294
9190
  });
9295
- this._addPromise("identify", promise);
9191
+ this._addPromise("identify", promise, abortController);
9296
9192
  return promise;
9297
9193
  }
9298
9194
  fetchIdentifyGeoJson(identify, multiple = false) {
9195
+ const abortController = new AbortController();
9299
9196
  const promise = fetchIdentifyGeoJson({
9300
9197
  identify,
9301
9198
  connector: this.connector,
9302
- multiple
9199
+ multiple,
9200
+ requestOptions: { signal: abortController.signal }
9303
9201
  });
9304
9202
  if (promise && "then" in promise) {
9305
- this._addPromise("identify", promise);
9203
+ this._addPromise("identify", promise, abortController);
9306
9204
  return promise;
9307
9205
  } else {
9308
- return CancelablePromise.resolve(promise);
9206
+ return Promise.resolve(promise);
9309
9207
  }
9310
9208
  }
9311
9209
  /**
@@ -9479,7 +9377,7 @@ var NgwMap = (function (exports) {
9479
9377
  args.forEach((name) => {
9480
9378
  const group = this._promises[name];
9481
9379
  if (group) {
9482
- group.forEach((x) => x.cancel());
9380
+ group.forEach((x) => x[1].abort());
9483
9381
  this._promises[name] = [];
9484
9382
  }
9485
9383
  });
@@ -9546,11 +9444,13 @@ var NgwMap = (function (exports) {
9546
9444
  }, highlightDuration);
9547
9445
  }
9548
9446
  }
9447
+ const abortController = new AbortController();
9549
9448
  const selectPromise = sendIdentifyRequest(ev, {
9550
9449
  layers: ids,
9551
9450
  connector: this.connector,
9552
9451
  radius,
9553
- geom
9452
+ geom,
9453
+ signal: abortController.signal
9554
9454
  }).then((resp) => {
9555
9455
  const identify = __spreadProps(__spreadValues({}, resp), {
9556
9456
  resources: ids,
@@ -9561,22 +9461,22 @@ var NgwMap = (function (exports) {
9561
9461
  this._emitStatusEvent("ngw:select", identifyEvent);
9562
9462
  return identifyEvent;
9563
9463
  });
9564
- this._addPromise("select", selectPromise);
9464
+ this._addPromise("select", selectPromise, abortController);
9565
9465
  return selectPromise;
9566
9466
  });
9567
9467
  }
9568
- _addPromise(groupName, promise) {
9468
+ _addPromise(groupName, promise, abortController) {
9569
9469
  const group = this._promises[groupName];
9570
- if (group && group.indexOf(promise) === -1) {
9470
+ if (group && group.findIndex((g) => g[0] === promise) === -1) {
9571
9471
  const removeFromGroup = () => {
9572
- const index = group.indexOf(promise);
9472
+ const index = group.findIndex((g) => g[0] === promise);
9573
9473
  if (index !== -1) {
9574
9474
  group.splice(index, 1);
9575
9475
  }
9576
9476
  };
9577
9477
  promise.then(removeFromGroup);
9578
9478
  promise.catch(removeFromGroup);
9579
- group.push(promise);
9479
+ group.push([promise, abortController]);
9580
9480
  }
9581
9481
  }
9582
9482
  _isFitFromResource() {