@nextgis/ngw-map 2.4.1 → 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.1; 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) {
@@ -2481,13 +2267,13 @@ var NgwMap = (function (exports) {
2481
2267
  for (const f of filters_) {
2482
2268
  if (isPropertyFilter(f)) {
2483
2269
  _queries.push(
2484
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2270
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2485
2271
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
2486
2272
  }))
2487
2273
  );
2488
2274
  } else {
2489
2275
  getQueries(
2490
- __spreadProps$c(__spreadValues$q({}, opt), {
2276
+ __spreadProps$c(__spreadValues$r({}, opt), {
2491
2277
  filters: f
2492
2278
  }),
2493
2279
  _queries,
@@ -2508,7 +2294,7 @@ var NgwMap = (function (exports) {
2508
2294
  if (propertiesFilterList.length) {
2509
2295
  for (const x of propertiesFilterList) {
2510
2296
  getQueries(
2511
- __spreadProps$c(__spreadValues$q({}, opt), {
2297
+ __spreadProps$c(__spreadValues$r({}, opt), {
2512
2298
  filters: x
2513
2299
  }),
2514
2300
  _queries,
@@ -2517,7 +2303,7 @@ var NgwMap = (function (exports) {
2517
2303
  }
2518
2304
  } else {
2519
2305
  _queries.push(
2520
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$q({}, opt), {
2306
+ fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2521
2307
  paramList: [..._parentAllParams, ...paramList, ...filters2]
2522
2308
  }))
2523
2309
  );
@@ -2533,7 +2319,7 @@ var NgwMap = (function (exports) {
2533
2319
  return `POLYGON((${polygon.join(", ")}))`;
2534
2320
  }
2535
2321
  function fetchNgwLayerItemsRequest(options) {
2536
- const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2322
+ const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2537
2323
  const {
2538
2324
  limit,
2539
2325
  cache,
@@ -2572,7 +2358,7 @@ var NgwMap = (function (exports) {
2572
2358
  if (paramList) {
2573
2359
  params.paramList = paramList;
2574
2360
  }
2575
- const reqParams = __spreadValues$q({
2361
+ const reqParams = __spreadValues$r({
2576
2362
  id: resourceId
2577
2363
  }, params);
2578
2364
  return connector.get(
@@ -2585,52 +2371,90 @@ var NgwMap = (function (exports) {
2585
2371
  var __defProp$A = Object.defineProperty;
2586
2372
  var __defProps$b = Object.defineProperties;
2587
2373
  var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2588
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2589
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2590
- 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;
2591
2377
  var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2592
- var __spreadValues$p = (a, b) => {
2378
+ var __spreadValues$q = (a, b) => {
2593
2379
  for (var prop in b || (b = {}))
2594
- if (__hasOwnProp$q.call(b, prop))
2380
+ if (__hasOwnProp$r.call(b, prop))
2595
2381
  __defNormalProp$A(a, prop, b[prop]);
2596
- if (__getOwnPropSymbols$q)
2597
- for (var prop of __getOwnPropSymbols$q(b)) {
2598
- 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))
2599
2385
  __defNormalProp$A(a, prop, b[prop]);
2600
2386
  }
2601
2387
  return a;
2602
2388
  };
2603
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
+ };
2604
2410
  function fetchNgwLayerItem(options) {
2605
- const params = __spreadValues$p({}, FEATURE_REQUEST_PARAMS);
2606
- updateItemRequestParam(params, options);
2607
- const queryParams = __spreadValues$p({
2608
- id: options.resourceId,
2609
- fid: options.featureId
2610
- }, params);
2611
- const cache = options.cache || true;
2612
- return options.connector.get("feature_layer.feature.item", { cache }, queryParams).then((resp) => {
2613
- return __spreadProps$b(__spreadValues$p({}, resp), {
2614
- toGeojson: () => {
2615
- if (resp.geom) {
2616
- return CancelablePromise.resolve(createGeoJsonFeature(resp));
2617
- } else {
2618
- return fetchNgwLayerItem(__spreadProps$b(__spreadValues$p({}, options), {
2619
- geom: true,
2620
- fields: null,
2621
- extensions: null
2622
- })).then((onlyGeomItem) => {
2623
- const geom = onlyGeomItem.geom;
2624
- return createGeoJsonFeature(__spreadProps$b(__spreadValues$p({}, resp), { geom }));
2625
- });
2626
- }
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 }));
2627
2434
  }
2628
2435
  });
2436
+ return __spreadProps$b(__spreadValues$q({}, resp), {
2437
+ toGeojson
2438
+ });
2629
2439
  });
2630
2440
  }
2631
2441
 
2632
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;
2633
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
+ };
2634
2458
  var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2635
2459
  class BookmarkItem {
2636
2460
  constructor(options) {
@@ -2648,11 +2472,11 @@ var NgwMap = (function (exports) {
2648
2472
  this.name = String(item.id);
2649
2473
  }
2650
2474
  }
2651
- extent() {
2475
+ extent(opt) {
2652
2476
  if (this._extent) {
2653
- return CancelablePromise.resolve(this._extent);
2477
+ return Promise.resolve(this._extent);
2654
2478
  }
2655
- return this.options.connector.get("feature_layer.feature.item_extent", null, {
2479
+ return this.options.connector.get("feature_layer.feature.item_extent", opt, {
2656
2480
  id: this.resourceId,
2657
2481
  fid: this.item.id
2658
2482
  }).then((resp) => {
@@ -2662,18 +2486,18 @@ var NgwMap = (function (exports) {
2662
2486
  return lonLat;
2663
2487
  });
2664
2488
  }
2665
- geoJson() {
2489
+ geoJson(opt) {
2666
2490
  if (this.item.geom) {
2667
- return CancelablePromise.resolve(createGeoJsonFeature(this.item));
2491
+ return Promise.resolve(createGeoJsonFeature(this.item));
2668
2492
  } else {
2669
- return fetchNgwLayerItem({
2493
+ return fetchNgwLayerItem(__spreadValues$p({
2670
2494
  resourceId: this.resourceId,
2671
2495
  featureId: this.item.id,
2672
2496
  connector: this.options.connector,
2673
2497
  geom: true,
2674
2498
  fields: null,
2675
2499
  extensions: null
2676
- }).then((onlyGeomItem) => {
2500
+ }, opt)).then((onlyGeomItem) => {
2677
2501
  const geom = onlyGeomItem.geom;
2678
2502
  this.item.geom = geom;
2679
2503
  return createGeoJsonFeature(this.item);
@@ -2683,22 +2507,20 @@ var NgwMap = (function (exports) {
2683
2507
  }
2684
2508
 
2685
2509
  function treeEvery(item, filter, relation, itemPrepare) {
2686
- return !!treeWrapper(item, filter, relation, treeEvery_, itemPrepare);
2510
+ return !!treeWrapper(item, filter, relation, treeEvery_);
2687
2511
  }
2688
2512
  function treeSome(item, filter, relation, itemPrepare) {
2689
- return !!treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2513
+ return !!treeWrapper(item, filter, relation, treeFind_);
2690
2514
  }
2691
2515
  function treeFind(item, filter, relation, itemPrepare) {
2692
- return treeWrapper(item, filter, relation, treeFind_, itemPrepare);
2516
+ return treeWrapper(item, filter, relation, treeFind_);
2693
2517
  }
2694
2518
  function treeFilter(item, filter, relation, itemPrepare) {
2695
2519
  return treeWrapper(
2696
2520
  item,
2697
2521
  filter,
2698
2522
  relation,
2699
- treeFilter_,
2700
- itemPrepare
2701
- );
2523
+ treeFilter_);
2702
2524
  }
2703
2525
  function getChildren(item, relation = "children") {
2704
2526
  let children = [];
@@ -2715,13 +2537,6 @@ var NgwMap = (function (exports) {
2715
2537
  }
2716
2538
  function treeWrapper(item, filter = (x) => !!x, relation = "children", treeFunction, itemPrepare) {
2717
2539
  const filterFunction = typeof filter === "function" ? filter : (i) => propertiesFilter(i, filter);
2718
- if (itemPrepare) {
2719
- return treeFunction(
2720
- item,
2721
- (i) => filterFunction(itemPrepare(i)),
2722
- relation
2723
- );
2724
- }
2725
2540
  return treeFunction(item, filterFunction, relation);
2726
2541
  }
2727
2542
  function treeFind_(item, filterFunc = (x) => !!x, relation, _filtered = []) {
@@ -2988,7 +2803,7 @@ var NgwMap = (function (exports) {
2988
2803
  }
2989
2804
  return a;
2990
2805
  };
2991
- 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);
2992
2807
  const _CheckProperty = class _CheckProperty extends BaseProperty {
2993
2808
  constructor(name, item, options) {
2994
2809
  super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
@@ -3312,9 +3127,10 @@ var NgwMap = (function (exports) {
3312
3127
  function fetchNgwLayerExtent({
3313
3128
  resourceId,
3314
3129
  connector,
3315
- cache = true
3130
+ cache = true,
3131
+ signal
3316
3132
  }) {
3317
- return connector.get("layer.extent", { cache }, { id: resourceId }).then((resp) => {
3133
+ return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3318
3134
  if (resp) {
3319
3135
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3320
3136
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3326,11 +3142,12 @@ var NgwMap = (function (exports) {
3326
3142
  resourceId,
3327
3143
  featureId,
3328
3144
  connector,
3329
- cache = true
3145
+ cache = true,
3146
+ signal
3330
3147
  }) {
3331
3148
  return connector.get(
3332
3149
  "feature_layer.feature.item_extent",
3333
- { cache },
3150
+ { cache, signal },
3334
3151
  { id: resourceId, fid: featureId }
3335
3152
  ).then((resp) => {
3336
3153
  if (resp) {
@@ -3341,7 +3158,10 @@ var NgwMap = (function (exports) {
3341
3158
  });
3342
3159
  }
3343
3160
  function fetchNgwExtent(options) {
3344
- 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) => {
3345
3165
  if (resource) {
3346
3166
  return fetchNgwResourceExtent(resource, options.connector, options);
3347
3167
  }
@@ -3349,11 +3169,11 @@ var NgwMap = (function (exports) {
3349
3169
  }
3350
3170
  function fetchNgwResourceExtent(item, connector, options) {
3351
3171
  if (item.webmap) {
3352
- return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
3172
+ return Promise.resolve(getNgwWebmapExtent(item.webmap));
3353
3173
  } else {
3354
3174
  const resource = item.resource;
3355
3175
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3356
- return connector.getResource(resource.parent.id).then((res) => {
3176
+ return connector.getResource(resource.parent.id, options).then((res) => {
3357
3177
  if (res) {
3358
3178
  return fetchNgwLayerExtent(__spreadProps$a(__spreadValues$l({}, options), {
3359
3179
  resourceId: res.resource.id,
@@ -3373,7 +3193,7 @@ var NgwMap = (function (exports) {
3373
3193
  var __defProp$s = Object.defineProperty;
3374
3194
  var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3375
3195
  var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3376
- var __async$k = (__this, __arguments, generator) => {
3196
+ var __async$n = (__this, __arguments, generator) => {
3377
3197
  return new Promise((resolve, reject) => {
3378
3198
  var fulfilled = (value) => {
3379
3199
  try {
@@ -3401,12 +3221,12 @@ var NgwMap = (function (exports) {
3401
3221
  }
3402
3222
  /** @deprecated use {@link NgwResource.getBounds} instead */
3403
3223
  getExtent() {
3404
- return __async$k(this, null, function* () {
3224
+ return __async$n(this, null, function* () {
3405
3225
  return this.getBounds();
3406
3226
  });
3407
3227
  }
3408
3228
  getBounds(options) {
3409
- return __async$k(this, null, function* () {
3229
+ return __async$n(this, null, function* () {
3410
3230
  if (this._extent) {
3411
3231
  return this._extent;
3412
3232
  }
@@ -3422,7 +3242,7 @@ var NgwMap = (function (exports) {
3422
3242
  }
3423
3243
  }
3424
3244
 
3425
- var __async$j = (__this, __arguments, generator) => {
3245
+ var __async$m = (__this, __arguments, generator) => {
3426
3246
  return new Promise((resolve, reject) => {
3427
3247
  var fulfilled = (value) => {
3428
3248
  try {
@@ -3443,7 +3263,7 @@ var NgwMap = (function (exports) {
3443
3263
  });
3444
3264
  };
3445
3265
  function resourceIdFromLayerOptions(options, connector) {
3446
- return __async$j(this, null, function* () {
3266
+ return __async$m(this, null, function* () {
3447
3267
  const resource = options.resource;
3448
3268
  const item = resource;
3449
3269
  let { keyname, resourceId } = options;
@@ -3545,7 +3365,7 @@ var NgwMap = (function (exports) {
3545
3365
  return target;
3546
3366
  };
3547
3367
  var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3548
- var __async$i = (__this, __arguments, generator) => {
3368
+ var __async$l = (__this, __arguments, generator) => {
3549
3369
  return new Promise((resolve, reject) => {
3550
3370
  var fulfilled = (value) => {
3551
3371
  try {
@@ -3597,7 +3417,7 @@ var NgwMap = (function (exports) {
3597
3417
  }
3598
3418
  }
3599
3419
  addLayer(options) {
3600
- return __async$i(this, null, function* () {
3420
+ return __async$l(this, null, function* () {
3601
3421
  if (!this.qms && options.qmsId) {
3602
3422
  try {
3603
3423
  this.qms = yield loadJson(
@@ -3705,7 +3525,7 @@ var NgwMap = (function (exports) {
3705
3525
  };
3706
3526
  var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3707
3527
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3708
- var __async$h = (__this, __arguments, generator) => {
3528
+ var __async$k = (__this, __arguments, generator) => {
3709
3529
  return new Promise((resolve, reject) => {
3710
3530
  var fulfilled = (value) => {
3711
3531
  try {
@@ -3726,7 +3546,7 @@ var NgwMap = (function (exports) {
3726
3546
  });
3727
3547
  };
3728
3548
  function createBasemapLayerAdapter(_0) {
3729
- return __async$h(this, arguments, function* ({
3549
+ return __async$k(this, arguments, function* ({
3730
3550
  webMap,
3731
3551
  item
3732
3552
  }) {
@@ -3747,7 +3567,7 @@ var NgwMap = (function (exports) {
3747
3567
  if (TileAdapter) {
3748
3568
  class BasemapTileAdapter extends TileAdapter {
3749
3569
  addLayer(opt) {
3750
- return __async$h(this, null, function* () {
3570
+ return __async$k(this, null, function* () {
3751
3571
  return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$9(__spreadValues$i({}, opt), { url }));
3752
3572
  });
3753
3573
  }
@@ -3787,11 +3607,12 @@ var NgwMap = (function (exports) {
3787
3607
  function fetchNgwLayerCount({
3788
3608
  connector,
3789
3609
  resourceId,
3790
- cache = true
3610
+ cache = true,
3611
+ signal
3791
3612
  }) {
3792
3613
  return connector.get(
3793
3614
  "feature_layer.feature.count",
3794
- { cache },
3615
+ { cache, signal },
3795
3616
  {
3796
3617
  id: resourceId
3797
3618
  }
@@ -3845,13 +3666,34 @@ var NgwMap = (function (exports) {
3845
3666
  return a;
3846
3667
  };
3847
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
+ };
3848
3689
  function fetchNgwLayerItems(options) {
3849
- const filters = options.filters;
3850
- if (filters) {
3851
- return createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
3852
- filters
3853
- })).then((data) => {
3854
- 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
+ }));
3855
3697
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3856
3698
  if (clientFilterValidate) {
3857
3699
  data = data.filter((y) => {
@@ -3863,10 +3705,10 @@ var NgwMap = (function (exports) {
3863
3705
  });
3864
3706
  }
3865
3707
  return data;
3866
- });
3867
- } else {
3868
- return fetchNgwLayerItemsRequest(options);
3869
- }
3708
+ } else {
3709
+ return fetchNgwLayerItemsRequest(options);
3710
+ }
3711
+ });
3870
3712
  }
3871
3713
  function isFilterWithAnyCase(filters) {
3872
3714
  if (filters[0] === "any") {
@@ -3884,8 +3726,29 @@ var NgwMap = (function (exports) {
3884
3726
  return false;
3885
3727
  }
3886
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
+ };
3887
3749
  function fetchNgwLayerFeatures(options) {
3888
- return fetchNgwLayerItems(options).then((x) => {
3750
+ return __async$i(this, null, function* () {
3751
+ const x = yield fetchNgwLayerItems(options);
3889
3752
  const features = [];
3890
3753
  x.forEach((y) => {
3891
3754
  features.push(createGeoJsonFeature(y));
@@ -3945,7 +3808,7 @@ var NgwMap = (function (exports) {
3945
3808
  var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
3946
3809
  var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
3947
3810
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3948
- var __async$g = (__this, __arguments, generator) => {
3811
+ var __async$h = (__this, __arguments, generator) => {
3949
3812
  return new Promise((resolve, reject) => {
3950
3813
  var fulfilled = (value) => {
3951
3814
  try {
@@ -3966,7 +3829,7 @@ var NgwMap = (function (exports) {
3966
3829
  });
3967
3830
  };
3968
3831
  function createGeoJsonAdapter(props) {
3969
- return __async$g(this, null, function* () {
3832
+ return __async$h(this, null, function* () {
3970
3833
  var _a, _b;
3971
3834
  const {
3972
3835
  item,
@@ -3982,29 +3845,35 @@ var NgwMap = (function (exports) {
3982
3845
  const _loadedIds = [];
3983
3846
  let _fullDataLoad = false;
3984
3847
  let _lastFilterArgs;
3985
- let _dataPromise;
3848
+ let internalAbortController;
3986
3849
  const resourceId = yield resourceIdFromLayerOptions(options, connector);
3987
3850
  if ((_b = (_a = options.adapterOptions) == null ? void 0 : _a.popupOptions) == null ? void 0 : _b.fromProperties) {
3988
3851
  options.adapterOptions.popupOptions.createPopupContent = ({ feature }) => {
3989
3852
  return feature && createPopupContent(feature, item);
3990
3853
  };
3991
3854
  }
3992
- const getData = (filters, filterOpt) => __async$g(this, null, function* () {
3855
+ const getData = (filters, filterOpt) => __async$h(this, null, function* () {
3993
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;
3994
3864
  _lastFilterArgs = { filters, options: filterOpt };
3995
- _dataPromise = fetchNgwLayerFeatureCollection(__spreadValues$g({
3865
+ return fetchNgwLayerFeatureCollection(__spreadValues$g({
3996
3866
  resourceId,
3997
3867
  filters,
3998
3868
  connector,
3999
3869
  cache: true
4000
3870
  }, filterOpt));
4001
- return yield _dataPromise;
4002
3871
  });
4003
3872
  let removed = false;
4004
3873
  const abort = () => {
4005
- if (_dataPromise) {
4006
- _dataPromise.cancel();
4007
- _dataPromise = void 0;
3874
+ if (internalAbortController) {
3875
+ internalAbortController.abort();
3876
+ internalAbortController = void 0;
4008
3877
  }
4009
3878
  };
4010
3879
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
@@ -4017,7 +3886,7 @@ var NgwMap = (function (exports) {
4017
3886
  __publicField$f(this, "__disableMapMoveListener");
4018
3887
  }
4019
3888
  addLayer(opt) {
4020
- return __async$g(this, null, function* () {
3889
+ return __async$h(this, null, function* () {
4021
3890
  let needUpdate = !opt.data;
4022
3891
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
4023
3892
  if (options.id !== void 0) {
@@ -4062,7 +3931,7 @@ var NgwMap = (function (exports) {
4062
3931
  return this.getBounds();
4063
3932
  }
4064
3933
  getBounds() {
4065
- return __async$g(this, null, function* () {
3934
+ return __async$h(this, null, function* () {
4066
3935
  const hasData = this.getLayers && this.getLayers().length;
4067
3936
  const strategy = this.options.strategy;
4068
3937
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -4088,7 +3957,7 @@ var NgwMap = (function (exports) {
4088
3957
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4089
3958
  }
4090
3959
  updateLayer(filterArgs) {
4091
- return __async$g(this, null, function* () {
3960
+ return __async$h(this, null, function* () {
4092
3961
  var _a2;
4093
3962
  filterArgs = filterArgs || _lastFilterArgs || {};
4094
3963
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
@@ -4154,7 +4023,7 @@ var NgwMap = (function (exports) {
4154
4023
  });
4155
4024
  }
4156
4025
  propertiesFilter(filters, opt) {
4157
- return __async$g(this, null, function* () {
4026
+ return __async$h(this, null, function* () {
4158
4027
  abort();
4159
4028
  if (this.filter && _fullDataLoad) {
4160
4029
  this.filter((e) => {
@@ -4228,7 +4097,7 @@ var NgwMap = (function (exports) {
4228
4097
  });
4229
4098
  }
4230
4099
 
4231
- var __async$f = (__this, __arguments, generator) => {
4100
+ var __async$g = (__this, __arguments, generator) => {
4232
4101
  return new Promise((resolve, reject) => {
4233
4102
  var fulfilled = (value) => {
4234
4103
  try {
@@ -4249,7 +4118,7 @@ var NgwMap = (function (exports) {
4249
4118
  });
4250
4119
  };
4251
4120
  function createWebMapAdapter(_0) {
4252
- return __async$f(this, arguments, function* ({
4121
+ return __async$g(this, arguments, function* ({
4253
4122
  layerOptions: options,
4254
4123
  webMap,
4255
4124
  connector
@@ -4377,7 +4246,7 @@ var NgwMap = (function (exports) {
4377
4246
  };
4378
4247
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4379
4248
  var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4380
- var __async$e = (__this, __arguments, generator) => {
4249
+ var __async$f = (__this, __arguments, generator) => {
4381
4250
  return new Promise((resolve, reject) => {
4382
4251
  var fulfilled = (value) => {
4383
4252
  try {
@@ -4398,7 +4267,7 @@ var NgwMap = (function (exports) {
4398
4267
  });
4399
4268
  };
4400
4269
  function createRasterAdapter(_0) {
4401
- return __async$e(this, arguments, function* ({
4270
+ return __async$f(this, arguments, function* ({
4402
4271
  layerOptions,
4403
4272
  webMap,
4404
4273
  connector,
@@ -4454,7 +4323,7 @@ var NgwMap = (function (exports) {
4454
4323
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4455
4324
  }
4456
4325
  getLegend(options) {
4457
- return __async$e(this, null, function* () {
4326
+ return __async$f(this, null, function* () {
4458
4327
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4459
4328
  params: { id: resourceId },
4460
4329
  cache: true
@@ -4474,7 +4343,7 @@ var NgwMap = (function (exports) {
4474
4343
  });
4475
4344
  }
4476
4345
  getIdentificationIds() {
4477
- return __async$e(this, null, function* () {
4346
+ return __async$f(this, null, function* () {
4478
4347
  if (this.item) {
4479
4348
  if (adapter === "MVT") {
4480
4349
  return [this.item.resource.id];
@@ -4515,7 +4384,7 @@ var NgwMap = (function (exports) {
4515
4384
  return a;
4516
4385
  };
4517
4386
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
4518
- var __async$d = (__this, __arguments, generator) => {
4387
+ var __async$e = (__this, __arguments, generator) => {
4519
4388
  return new Promise((resolve, reject) => {
4520
4389
  var fulfilled = (value) => {
4521
4390
  try {
@@ -4551,7 +4420,7 @@ var NgwMap = (function (exports) {
4551
4420
  "tmsclient_layer"
4552
4421
  ];
4553
4422
  function createAdapterFromFirstStyle(_0) {
4554
- return __async$d(this, arguments, function* ({
4423
+ return __async$e(this, arguments, function* ({
4555
4424
  layerOptions,
4556
4425
  webMap,
4557
4426
  connector,
@@ -4570,7 +4439,7 @@ var NgwMap = (function (exports) {
4570
4439
  });
4571
4440
  }
4572
4441
  function createAsyncAdapter(options, webMap, connector) {
4573
- return __async$d(this, null, function* () {
4442
+ return __async$e(this, null, function* () {
4574
4443
  let adapter;
4575
4444
  let item;
4576
4445
  const adapterType = options.adapter;
@@ -4767,7 +4636,7 @@ var NgwMap = (function (exports) {
4767
4636
  return a;
4768
4637
  };
4769
4638
  var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4770
- var __async$c = (__this, __arguments, generator) => {
4639
+ var __async$d = (__this, __arguments, generator) => {
4771
4640
  return new Promise((resolve, reject) => {
4772
4641
  var fulfilled = (value) => {
4773
4642
  try {
@@ -4817,7 +4686,7 @@ var NgwMap = (function (exports) {
4817
4686
  }
4818
4687
  }
4819
4688
  static create(webMap, item, options, connector, parent) {
4820
- return __async$c(this, null, function* () {
4689
+ return __async$d(this, null, function* () {
4821
4690
  const ngwWebmapItem = new _NgwWebmapItem(
4822
4691
  webMap,
4823
4692
  item,
@@ -4846,15 +4715,14 @@ var NgwMap = (function (exports) {
4846
4715
  return this.layer;
4847
4716
  }
4848
4717
  getLegend(options) {
4849
- return __async$c(this, null, function* () {
4718
+ return __async$d(this, null, function* () {
4850
4719
  var _a;
4851
4720
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4852
4721
  if (id !== void 0) {
4853
4722
  const connector = this.connector;
4854
4723
  if (connector) {
4855
4724
  const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4856
- params: { id: this.item.resourceId },
4857
- cache: true
4725
+ params: { id: this.item.resourceId }
4858
4726
  }, options));
4859
4727
  const legend = {
4860
4728
  layerId: id,
@@ -5045,7 +4913,7 @@ var NgwMap = (function (exports) {
5045
4913
  return a;
5046
4914
  };
5047
4915
  var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5048
- var __async$b = (__this, __arguments, generator) => {
4916
+ var __async$c = (__this, __arguments, generator) => {
5049
4917
  return new Promise((resolve, reject) => {
5050
4918
  var fulfilled = (value) => {
5051
4919
  try {
@@ -5066,7 +4934,7 @@ var NgwMap = (function (exports) {
5066
4934
  });
5067
4935
  };
5068
4936
  function createOnFirstShowAdapter(_0) {
5069
- return __async$b(this, arguments, function* ({
4937
+ return __async$c(this, arguments, function* ({
5070
4938
  webMap,
5071
4939
  adapterOptions = {},
5072
4940
  onLayerAdded,
@@ -5092,7 +4960,7 @@ var NgwMap = (function (exports) {
5092
4960
  return this._removed;
5093
4961
  }
5094
4962
  showLayer() {
5095
- return __async$b(this, null, function* () {
4963
+ return __async$c(this, null, function* () {
5096
4964
  this.options.visibility = true;
5097
4965
  if (this.layer.length) {
5098
4966
  for (const x of this.layer) {
@@ -5104,7 +4972,7 @@ var NgwMap = (function (exports) {
5104
4972
  });
5105
4973
  }
5106
4974
  hideLayer() {
5107
- return __async$b(this, null, function* () {
4975
+ return __async$c(this, null, function* () {
5108
4976
  this.options.visibility = false;
5109
4977
  if (this.layer) {
5110
4978
  for (const x of this.layer) {
@@ -5114,7 +4982,7 @@ var NgwMap = (function (exports) {
5114
4982
  });
5115
4983
  }
5116
4984
  loadLayer() {
5117
- return __async$b(this, null, function* () {
4985
+ return __async$c(this, null, function* () {
5118
4986
  if (!this.layer.length && !this._creatingInProgress) {
5119
4987
  this._creatingInProgress = true;
5120
4988
  const Adapter = yield createAdapter(this);
@@ -5148,7 +5016,7 @@ var NgwMap = (function (exports) {
5148
5016
  });
5149
5017
  }
5150
5018
 
5151
- var __async$a = (__this, __arguments, generator) => {
5019
+ var __async$b = (__this, __arguments, generator) => {
5152
5020
  return new Promise((resolve, reject) => {
5153
5021
  var fulfilled = (value) => {
5154
5022
  try {
@@ -5169,7 +5037,7 @@ var NgwMap = (function (exports) {
5169
5037
  });
5170
5038
  };
5171
5039
  function createOnFirstShowNgwAdapter(_0) {
5172
- return __async$a(this, arguments, function* ({
5040
+ return __async$b(this, arguments, function* ({
5173
5041
  webMap,
5174
5042
  connector,
5175
5043
  item,
@@ -5222,7 +5090,7 @@ var NgwMap = (function (exports) {
5222
5090
  return a;
5223
5091
  };
5224
5092
  var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5225
- var __async$9 = (__this, __arguments, generator) => {
5093
+ var __async$a = (__this, __arguments, generator) => {
5226
5094
  return new Promise((resolve, reject) => {
5227
5095
  var fulfilled = (value) => {
5228
5096
  try {
@@ -5273,7 +5141,7 @@ var NgwMap = (function (exports) {
5273
5141
  }
5274
5142
  }
5275
5143
  addLayer(options) {
5276
- return __async$9(this, null, function* () {
5144
+ return __async$a(this, null, function* () {
5277
5145
  var _a, _b;
5278
5146
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5279
5147
  this.layer = yield this._getWebMapLayerItem();
@@ -5306,21 +5174,21 @@ var NgwMap = (function (exports) {
5306
5174
  delete this._webmapLayersIds;
5307
5175
  }
5308
5176
  showLayer() {
5309
- return __async$9(this, null, function* () {
5177
+ return __async$a(this, null, function* () {
5310
5178
  if (this.layer && this.layer.properties) {
5311
5179
  return this.layer.properties.property("visibility").set(true);
5312
5180
  }
5313
5181
  });
5314
5182
  }
5315
5183
  hideLayer() {
5316
- return __async$9(this, null, function* () {
5184
+ return __async$a(this, null, function* () {
5317
5185
  if (this.layer && this.layer.properties) {
5318
5186
  return this.layer.properties.property("visibility").set(false);
5319
5187
  }
5320
5188
  });
5321
5189
  }
5322
5190
  setOpacity(val) {
5323
- return __async$9(this, null, function* () {
5191
+ return __async$a(this, null, function* () {
5324
5192
  if (this.layer && this.layer.properties) {
5325
5193
  return this.layer.properties.property("opacity").set(val);
5326
5194
  }
@@ -5345,22 +5213,22 @@ var NgwMap = (function (exports) {
5345
5213
  return webmap.bookmark_resource.id;
5346
5214
  }
5347
5215
  }
5348
- fetchBookmarks() {
5216
+ fetchBookmarks(options) {
5349
5217
  const bookmarkResId = this.getBookmarksResourceId();
5350
5218
  const connector = this.options.connector;
5351
5219
  if (bookmarkResId) {
5352
- return connector.getResourceOrFail(bookmarkResId).then((item) => {
5220
+ return connector.getResourceOrFail(bookmarkResId, options).then((item) => {
5353
5221
  var _a;
5354
5222
  const labelField = (_a = item.feature_layer) == null ? void 0 : _a.fields.find(
5355
5223
  (x) => x.label_field
5356
5224
  );
5357
5225
  const keyname = labelField && labelField.keyname;
5358
- return fetchNgwLayerItems({
5226
+ return fetchNgwLayerItems(__spreadValues$a({
5359
5227
  connector,
5360
5228
  resourceId: bookmarkResId,
5361
5229
  geom: false,
5362
5230
  fields: keyname ? [keyname] : void 0
5363
- }).then((items) => {
5231
+ }, options)).then((items) => {
5364
5232
  const bookmarks = [];
5365
5233
  for (const i of items) {
5366
5234
  const bookmark = new BookmarkItem({
@@ -5379,24 +5247,24 @@ var NgwMap = (function (exports) {
5379
5247
  "Webmap was not loaded correctly, it is impossible to extract bookmarks"
5380
5248
  );
5381
5249
  }
5382
- getLegend() {
5383
- return __async$9(this, null, function* () {
5250
+ getLegend(options) {
5251
+ return __async$a(this, null, function* () {
5384
5252
  const legends = [];
5385
5253
  let deps = this.getDependLayers();
5386
5254
  deps = deps.sort((a, b) => b.id - a.id);
5387
5255
  for (const d of deps) {
5388
- const layerLegend = yield d.getLegend();
5256
+ const layerLegend = yield d.getLegend(options);
5389
5257
  legends.push(...layerLegend);
5390
5258
  }
5391
5259
  return legends;
5392
5260
  });
5393
5261
  }
5394
- getIdentificationIds() {
5395
- return __async$9(this, null, function* () {
5262
+ getIdentificationIds(options) {
5263
+ return __async$a(this, null, function* () {
5396
5264
  const visibleLayers = [];
5397
5265
  let ids = this._webmapLayersIds;
5398
5266
  if (!ids) {
5399
- ids = yield this._getWebMapIds();
5267
+ ids = yield this._getWebMapIds(options);
5400
5268
  this._webmapLayersIds = ids;
5401
5269
  }
5402
5270
  if (ids && ids.length) {
@@ -5418,7 +5286,7 @@ var NgwMap = (function (exports) {
5418
5286
  });
5419
5287
  }
5420
5288
  _getWebMapLayerItem() {
5421
- return __async$9(this, null, function* () {
5289
+ return __async$a(this, null, function* () {
5422
5290
  if (this.resourceId) {
5423
5291
  const webmap = yield this.getWebMapConfig(this.resourceId);
5424
5292
  if (webmap && webmap.root_item) {
@@ -5451,7 +5319,7 @@ var NgwMap = (function (exports) {
5451
5319
  });
5452
5320
  }
5453
5321
  getWebMapConfig(id) {
5454
- return __async$9(this, null, function* () {
5322
+ return __async$a(this, null, function* () {
5455
5323
  const data = yield this.options.connector.getResource(id);
5456
5324
  if (data) {
5457
5325
  this.response = data;
@@ -5545,8 +5413,8 @@ var NgwMap = (function (exports) {
5545
5413
  }
5546
5414
  return item;
5547
5415
  }
5548
- _getWebMapIds() {
5549
- return __async$9(this, null, function* () {
5416
+ _getWebMapIds(options) {
5417
+ return __async$a(this, null, function* () {
5550
5418
  const webMapItem = this.layer;
5551
5419
  if (webMapItem && webMapItem.item.item_type === "root") {
5552
5420
  const layers = webMapItem.tree.getDescendants();
@@ -5555,7 +5423,7 @@ var NgwMap = (function (exports) {
5555
5423
  const item = x.item;
5556
5424
  if (item.item_type === "layer") {
5557
5425
  const id = item.layer_style_id;
5558
- const promise = this.options.connector.getResource(id).then((y) => {
5426
+ const promise = this.options.connector.getResource(id, options).then((y) => {
5559
5427
  if (y) {
5560
5428
  const parentId = Number(y.resource.parent.id);
5561
5429
  item.parentId = parentId;
@@ -5589,7 +5457,7 @@ var NgwMap = (function (exports) {
5589
5457
  return a;
5590
5458
  };
5591
5459
  var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5592
- var __async$8 = (__this, __arguments, generator) => {
5460
+ var __async$9 = (__this, __arguments, generator) => {
5593
5461
  return new Promise((resolve, reject) => {
5594
5462
  var fulfilled = (value) => {
5595
5463
  try {
@@ -5634,7 +5502,7 @@ var NgwMap = (function (exports) {
5634
5502
  classAdapters[cls] = adapter;
5635
5503
  }
5636
5504
  onLoadSync(webMap) {
5637
- return __async$8(this, null, function* () {
5505
+ return __async$9(this, null, function* () {
5638
5506
  if (this.options.resourceId && this.url) {
5639
5507
  const resourceIds = [this.options.resourceId];
5640
5508
  if (resourceIds.length) {
@@ -5717,7 +5585,7 @@ var NgwMap = (function (exports) {
5717
5585
  }
5718
5586
  identify(options = {}) {
5719
5587
  if (this._item) {
5720
- return CancelablePromise.resolve(this._item);
5588
+ return Promise.resolve(this._item);
5721
5589
  }
5722
5590
  return fetchNgwLayerItem(__spreadValues$8({
5723
5591
  connector: this.connector,
@@ -5732,30 +5600,30 @@ var NgwMap = (function (exports) {
5732
5600
  return resp;
5733
5601
  });
5734
5602
  }
5735
- resource() {
5603
+ resource(opt) {
5736
5604
  if (this._resource) {
5737
- return CancelablePromise.resolve(this._resource.feature_layer);
5605
+ return Promise.resolve(this._resource.feature_layer);
5738
5606
  }
5739
- return this.connector.getResource(this.layerId).then((resp) => {
5607
+ return this.connector.getResource(this.layerId, opt).then((resp) => {
5740
5608
  this._resource = resp;
5741
5609
  return this._resource.feature_layer;
5742
5610
  });
5743
5611
  }
5744
- getBounds() {
5612
+ getBounds(opt) {
5745
5613
  if (this._extent) {
5746
- return CancelablePromise.resolve(this._extent);
5614
+ return Promise.resolve(this._extent);
5747
5615
  }
5748
- return fetchNgwLayerItemExtent({
5616
+ return fetchNgwLayerItemExtent(__spreadValues$8({
5749
5617
  connector: this.connector,
5750
5618
  featureId: this.id,
5751
5619
  resourceId: this.layerId
5752
- });
5620
+ }, opt));
5753
5621
  }
5754
- geojson() {
5622
+ geojson(options) {
5755
5623
  if (this._geojson) {
5756
- return CancelablePromise.resolve(this._geojson);
5624
+ return Promise.resolve(this._geojson);
5757
5625
  }
5758
- return this.identify().then((resp) => {
5626
+ return this.identify(options).then((resp) => {
5759
5627
  return resp.toGeojson().then((geojson) => {
5760
5628
  this._geojson = geojson;
5761
5629
  return geojson;
@@ -5764,8 +5632,29 @@ var NgwMap = (function (exports) {
5764
5632
  }
5765
5633
  }
5766
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
+ };
5767
5655
  function fetchNgwLayerFeature(options) {
5768
- return fetchNgwLayerItem(options).then((item) => {
5656
+ return __async$8(this, null, function* () {
5657
+ const item = yield fetchNgwLayerItem(options);
5769
5658
  return createGeoJsonFeature(item);
5770
5659
  });
5771
5660
  }
@@ -5850,7 +5739,7 @@ var NgwMap = (function (exports) {
5850
5739
  const withGeom = item.features.find((x) => x.geom);
5851
5740
  if (withGeom && withGeom.geom) {
5852
5741
  const geom = withGeom.geom;
5853
- return CancelablePromise.resolve(
5742
+ return Promise.resolve(
5854
5743
  createGeoJsonFeature(__spreadProps$4(__spreadValues$7({}, withGeom), {
5855
5744
  geom
5856
5745
  }))
@@ -5863,7 +5752,7 @@ var NgwMap = (function (exports) {
5863
5752
  if (params && params.length) {
5864
5753
  return fetchNgwLayerFeature(__spreadValues$7(__spreadProps$4(__spreadValues$7({}, requestOptions), { connector }), params[0]));
5865
5754
  }
5866
- return CancelablePromise.resolve(void 0);
5755
+ return Promise.resolve(void 0);
5867
5756
  }
5868
5757
  function fetchIdentifyItem(options) {
5869
5758
  const { connector, identify } = options;
@@ -5873,7 +5762,7 @@ var NgwMap = (function (exports) {
5873
5762
  connector
5874
5763
  }, options.requestOptions), params[0]));
5875
5764
  }
5876
- return CancelablePromise.resolve(void 0);
5765
+ return Promise.resolve(void 0);
5877
5766
  }
5878
5767
  function featureLayerIdentify(options) {
5879
5768
  const { geom, signal, cache, layers } = options;
@@ -5917,9 +5806,9 @@ var NgwMap = (function (exports) {
5917
5806
  function sendIdentifyRequest(ev, options) {
5918
5807
  deprecatedMapClick(ev);
5919
5808
  const [lng, lat] = ev.lngLat;
5920
- const { geom, radius, signal, cache } = options;
5809
+ const { geom, radius } = options;
5921
5810
  const geom_ = geom != null ? geom : getCirclePolygonCoordinates(lng, lat, radius);
5922
- return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_, signal, cache }));
5811
+ return featureLayerIdentify(__spreadProps$4(__spreadValues$7({}, options), { geom: geom_ }));
5923
5812
  }
5924
5813
  function createIdentifyItem(opt) {
5925
5814
  return new IdentifyItem(opt);
@@ -7129,7 +7018,7 @@ var NgwMap = (function (exports) {
7129
7018
  __publicField$3(this, "_mapState", []);
7130
7019
  __publicField$3(this, "_extent");
7131
7020
  __publicField$3(this, "_eventsStatus", {});
7132
- __publicField$3(this, "_coordFromMapClickPromise");
7021
+ __publicField$3(this, "_coordFromMapClickAbort");
7133
7022
  __publicField$3(this, "_mapEvents", {});
7134
7023
  this.mapAdapter = mapOptions.mapAdapter;
7135
7024
  this._starterKits = mapOptions.starterKits || [];
@@ -7444,36 +7333,34 @@ var NgwMap = (function (exports) {
7444
7333
  return { stop };
7445
7334
  }
7446
7335
  stopGetCoordFromMapClick() {
7447
- if (this._coordFromMapClickPromise) {
7448
- this._coordFromMapClickPromise.cancel();
7336
+ if (this._coordFromMapClickAbort) {
7337
+ this._coordFromMapClickAbort();
7338
+ this._coordFromMapClickAbort = void 0;
7449
7339
  }
7450
7340
  }
7451
7341
  getCoordFromMapClick() {
7452
- if (!this._coordFromMapClickPromise) {
7453
- this._coordFromMapClickPromise = new CancelablePromise(
7454
- (resolve, reject, onCancel) => {
7455
- const cursor = this.getCursor() || "grab";
7456
- this._removeEventListeners({ include: ["click"] });
7457
- this.setCursor("crosshair");
7458
- const onCancel_ = () => {
7459
- this.setCursor(cursor);
7460
- this._addEventsListeners({ include: ["click"] });
7461
- this.mapAdapter.emitter.off("click", onMapClick);
7462
- this._coordFromMapClickPromise = void 0;
7463
- };
7464
- const onMapClick = (e) => {
7465
- onCancel_();
7466
- deprecatedMapClick(e);
7467
- resolve(e.lngLat);
7468
- };
7469
- this.mapAdapter.emitter.once("click", onMapClick);
7470
- onCancel(onCancel_);
7471
- }
7472
- );
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
+ });
7473
7361
  } else {
7474
7362
  return this.getCoordFromMapClick();
7475
7363
  }
7476
- return this._coordFromMapClickPromise;
7477
7364
  }
7478
7365
  _emitStatusEvent(eventName, data) {
7479
7366
  const _eventName = eventName;
@@ -9288,26 +9175,35 @@ var NgwMap = (function (exports) {
9288
9175
  }, options));
9289
9176
  }
9290
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;
9291
9185
  const promise = fetchIdentifyItem({
9292
9186
  identify,
9293
9187
  connector: this.connector,
9294
9188
  requestOptions
9295
9189
  // multiple,
9296
9190
  });
9297
- this._addPromise("identify", promise);
9191
+ this._addPromise("identify", promise, abortController);
9298
9192
  return promise;
9299
9193
  }
9300
9194
  fetchIdentifyGeoJson(identify, multiple = false) {
9195
+ const abortController = new AbortController();
9301
9196
  const promise = fetchIdentifyGeoJson({
9302
9197
  identify,
9303
9198
  connector: this.connector,
9304
- multiple
9199
+ multiple,
9200
+ requestOptions: { signal: abortController.signal }
9305
9201
  });
9306
9202
  if (promise && "then" in promise) {
9307
- this._addPromise("identify", promise);
9203
+ this._addPromise("identify", promise, abortController);
9308
9204
  return promise;
9309
9205
  } else {
9310
- return CancelablePromise.resolve(promise);
9206
+ return Promise.resolve(promise);
9311
9207
  }
9312
9208
  }
9313
9209
  /**
@@ -9481,7 +9377,7 @@ var NgwMap = (function (exports) {
9481
9377
  args.forEach((name) => {
9482
9378
  const group = this._promises[name];
9483
9379
  if (group) {
9484
- group.forEach((x) => x.cancel());
9380
+ group.forEach((x) => x[1].abort());
9485
9381
  this._promises[name] = [];
9486
9382
  }
9487
9383
  });
@@ -9548,11 +9444,13 @@ var NgwMap = (function (exports) {
9548
9444
  }, highlightDuration);
9549
9445
  }
9550
9446
  }
9447
+ const abortController = new AbortController();
9551
9448
  const selectPromise = sendIdentifyRequest(ev, {
9552
9449
  layers: ids,
9553
9450
  connector: this.connector,
9554
9451
  radius,
9555
- geom
9452
+ geom,
9453
+ signal: abortController.signal
9556
9454
  }).then((resp) => {
9557
9455
  const identify = __spreadProps(__spreadValues({}, resp), {
9558
9456
  resources: ids,
@@ -9563,22 +9461,22 @@ var NgwMap = (function (exports) {
9563
9461
  this._emitStatusEvent("ngw:select", identifyEvent);
9564
9462
  return identifyEvent;
9565
9463
  });
9566
- this._addPromise("select", selectPromise);
9464
+ this._addPromise("select", selectPromise, abortController);
9567
9465
  return selectPromise;
9568
9466
  });
9569
9467
  }
9570
- _addPromise(groupName, promise) {
9468
+ _addPromise(groupName, promise, abortController) {
9571
9469
  const group = this._promises[groupName];
9572
- if (group && group.indexOf(promise) === -1) {
9470
+ if (group && group.findIndex((g) => g[0] === promise) === -1) {
9573
9471
  const removeFromGroup = () => {
9574
- const index = group.indexOf(promise);
9472
+ const index = group.findIndex((g) => g[0] === promise);
9575
9473
  if (index !== -1) {
9576
9474
  group.splice(index, 1);
9577
9475
  }
9578
9476
  };
9579
9477
  promise.then(removeFromGroup);
9580
9478
  promise.catch(removeFromGroup);
9581
- group.push(promise);
9479
+ group.push([promise, abortController]);
9582
9480
  }
9583
9481
  }
9584
9482
  _isFitFromResource() {