@nextgis/ngw-connector 1.11.3 → 1.12.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,94 @@
1
- /** Bundle of @nextgis/ngw-connector; version: 1.11.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-connector; version: 1.12.0; author: NextGIS */
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */
16
+ /* global Reflect, Promise */
17
+
18
+ var extendStatics = function(d, b) {
19
+ extendStatics = Object.setPrototypeOf ||
20
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
+ return extendStatics(d, b);
23
+ };
24
+
25
+ function __extends(d, b) {
26
+ if (typeof b !== "function" && b !== null)
27
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28
+ extendStatics(d, b);
29
+ function __() { this.constructor = d; }
30
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
+ }
32
+
33
+ var __assign = function() {
34
+ __assign = Object.assign || function __assign(t) {
35
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
36
+ s = arguments[i];
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
38
+ }
39
+ return t;
40
+ };
41
+ return __assign.apply(this, arguments);
42
+ };
43
+
44
+ function __awaiter(thisArg, _arguments, P, generator) {
45
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
+ return new (P || (P = Promise))(function (resolve, reject) {
47
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
51
+ });
52
+ }
53
+
54
+ function __generator(thisArg, body) {
55
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
56
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
57
+ function verb(n) { return function (v) { return step([n, v]); }; }
58
+ function step(op) {
59
+ if (f) throw new TypeError("Generator is already executing.");
60
+ while (_) try {
61
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
62
+ if (y = 0, t) op = [op[0] & 2, t.value];
63
+ switch (op[0]) {
64
+ case 0: case 1: t = op; break;
65
+ case 4: _.label++; return { value: op[1], done: false };
66
+ case 5: _.label++; y = op[1]; op = [0]; continue;
67
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
68
+ default:
69
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
70
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
71
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
72
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
73
+ if (t[2]) _.ops.pop();
74
+ _.trys.pop(); continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
78
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
79
+ }
80
+ }
81
+
82
+ function __spreadArray(to, from, pack) {
83
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
84
+ if (ar || !(i in from)) {
85
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
86
+ ar[i] = from[i];
87
+ }
88
+ }
89
+ return to.concat(ar || Array.prototype.slice.call(from));
90
+ }
91
+
2
92
  var events = {exports: {}};
3
93
 
4
94
  var R = typeof Reflect === 'object' ? Reflect : null;
@@ -475,34 +565,43 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
475
565
  }
476
566
  }
477
567
 
478
- class CancelError extends Error {
479
- constructor() {
480
- super();
481
- this.name = 'CancelError';
482
- Object.setPrototypeOf(this, CancelError.prototype);
568
+ var CancelError = /** @class */ (function (_super) {
569
+ __extends(CancelError, _super);
570
+ function CancelError() {
571
+ var _this = _super.call(this) || this;
572
+ _this.name = 'CancelError';
573
+ Object.setPrototypeOf(_this, CancelError.prototype);
574
+ return _this;
483
575
  }
484
- }
576
+ return CancelError;
577
+ }(Error));
485
578
 
486
- class PromiseControl {
487
- constructor(options = {}) {
579
+ var PromiseControl = /** @class */ (function () {
580
+ function PromiseControl(options) {
581
+ if (options === void 0) { options = {}; }
488
582
  this.options = options;
489
583
  this._promises = new Map();
490
584
  }
491
- get isLoaded() {
492
- return this._promises.size > 0;
493
- }
494
- remove(promise) {
585
+ Object.defineProperty(PromiseControl.prototype, "isLoaded", {
586
+ get: function () {
587
+ return this._promises.size > 0;
588
+ },
589
+ enumerable: false,
590
+ configurable: true
591
+ });
592
+ PromiseControl.prototype.remove = function (promise) {
495
593
  if (this._promises.has(promise)) {
496
594
  this._promises.delete(promise);
497
595
  this._onStop();
498
596
  }
499
- }
500
- get(promise) {
597
+ };
598
+ PromiseControl.prototype.get = function (promise) {
501
599
  return this._promises.get(promise);
502
- }
503
- add(promise, name) {
504
- const key = name ? name : promise;
505
- const exist = this._promises.get(key);
600
+ };
601
+ PromiseControl.prototype.add = function (promise, name) {
602
+ var _this = this;
603
+ var key = name ? name : promise;
604
+ var exist = this._promises.get(key);
506
605
  if (this.options.onStart && !this.isLoaded) {
507
606
  this.options.onStart();
508
607
  }
@@ -510,14 +609,14 @@ class PromiseControl {
510
609
  return exist;
511
610
  }
512
611
  this._promises.set(key, promise);
513
- promise.finally(() => {
514
- this.remove(key);
612
+ promise.finally(function () {
613
+ _this.remove(key);
515
614
  });
516
615
  return promise;
517
- }
518
- abort() {
616
+ };
617
+ PromiseControl.prototype.abort = function () {
519
618
  if (this.isLoaded) {
520
- this._promises.forEach((x) => {
619
+ this._promises.forEach(function (x) {
521
620
  if (x.cancel) {
522
621
  x.cancel();
523
622
  }
@@ -525,52 +624,63 @@ class PromiseControl {
525
624
  this._promises.clear();
526
625
  this._onStop();
527
626
  }
528
- }
529
- waitFunc(func, name = '') {
627
+ };
628
+ PromiseControl.prototype.waitFunc = function (func, name) {
629
+ if (name === void 0) { name = ''; }
530
630
  name = name || func.name;
531
- const exist = this.get(name);
631
+ var exist = this.get(name);
532
632
  if (exist) {
533
633
  return exist;
534
634
  }
535
635
  return this.add(func(), name);
536
- }
537
- WaitForMe(name = '') {
538
- const get = this.get.bind(this);
539
- const add = this.add.bind(this);
636
+ };
637
+ PromiseControl.prototype.WaitForMe = function (name) {
638
+ if (name === void 0) { name = ''; }
639
+ var get = this.get.bind(this);
640
+ var add = this.add.bind(this);
540
641
  return function (target, key, descriptor) {
541
- const originalMethod = descriptor.value;
642
+ var originalMethod = descriptor.value;
542
643
  name = name || key;
543
- descriptor.value = function (...args) {
544
- const exist = get(name);
644
+ descriptor.value = function () {
645
+ var args = [];
646
+ for (var _i = 0; _i < arguments.length; _i++) {
647
+ args[_i] = arguments[_i];
648
+ }
649
+ var exist = get(name);
545
650
  if (exist) {
546
651
  return exist;
547
652
  }
548
- const result = add(originalMethod.apply(this, args), name);
653
+ var result = add(originalMethod.apply(this, args), name);
549
654
  return result;
550
655
  };
551
656
  return descriptor;
552
657
  };
553
- }
658
+ };
554
659
  /** @deprecated use {@link PromiseControl.WaitForMe } instead */
555
- GetOrCreateDecorator(name = '') {
660
+ PromiseControl.prototype.GetOrCreateDecorator = function (name) {
661
+ if (name === void 0) { name = ''; }
556
662
  return this.WaitForMe(name);
557
- }
558
- _onStop() {
663
+ };
664
+ PromiseControl.prototype._onStop = function () {
559
665
  if (this.options.onStop && !this.isLoaded) {
560
666
  this.options.onStop();
561
667
  }
562
- }
563
- }
668
+ };
669
+ return PromiseControl;
670
+ }());
564
671
 
565
- class TimeoutError extends Error {
566
- constructor() {
567
- super();
568
- this.name = 'TimeoutError';
569
- Object.setPrototypeOf(this, TimeoutError.prototype);
672
+ var TimeoutError = /** @class */ (function (_super) {
673
+ __extends(TimeoutError, _super);
674
+ function TimeoutError() {
675
+ var _this = _super.call(this) || this;
676
+ _this.name = 'TimeoutError';
677
+ Object.setPrototypeOf(_this, TimeoutError.prototype);
678
+ return _this;
570
679
  }
571
- }
680
+ return TimeoutError;
681
+ }(Error));
572
682
 
573
- const handleCallback = (resolve, reject, callback, r) => {
683
+ var handleCallback = function (resolve, reject, callback, r) {
574
684
  try {
575
685
  resolve(callback(r));
576
686
  }
@@ -578,7 +688,7 @@ const handleCallback = (resolve, reject, callback, r) => {
578
688
  reject(e);
579
689
  }
580
690
  };
581
- let ID$1 = 0;
691
+ var ID$1 = 0;
582
692
  /**
583
693
  * Promise that can be canceled
584
694
  *
@@ -623,48 +733,49 @@ let ID$1 = 0;
623
733
  * promise.cancel();
624
734
  * ```
625
735
  */
626
- class CancelablePromise$1 {
627
- constructor(executor, timeout) {
736
+ var CancelablePromise$1 = /** @class */ (function () {
737
+ function CancelablePromise(executor, timeout) {
738
+ var _this = this;
628
739
  this.id = ID$1++;
629
740
  this._isCanceled = false;
630
741
  this._isPending = true;
631
742
  this._cancelHandlers = [];
632
743
  this._children = [];
633
- this._cancelPromise = new Promise((resolve_, reject_) => {
634
- this._setCanceledCallback = (er) => resolve_(er || new CancelError());
744
+ this._cancelPromise = new Promise(function (resolve_, reject_) {
745
+ _this._setCanceledCallback = function (er) { return resolve_(er || new CancelError()); };
635
746
  });
636
- const promises = [
747
+ var promises = [
637
748
  this._cancelPromise,
638
- new Promise((resolve, reject) => {
639
- const onResolve = (value) => {
640
- if (value instanceof CancelablePromise$1) {
641
- this.attach(value);
749
+ new Promise(function (resolve, reject) {
750
+ var onResolve = function (value) {
751
+ if (value instanceof CancelablePromise) {
752
+ _this.attach(value);
642
753
  }
643
754
  else {
644
- this._isPending = false;
755
+ _this._isPending = false;
645
756
  }
646
757
  // TODO: fix types, `undefined` not allowed since 19.12.2020
647
758
  resolve(value);
648
759
  };
649
- const onReject = (error) => {
650
- this._isPending = false;
760
+ var onReject = function (error) {
761
+ _this._isPending = false;
651
762
  reject(error);
652
763
  };
653
- const onCancel = (handler) => {
654
- if (!this._isPending) {
764
+ var onCancel = function (handler) {
765
+ if (!_this._isPending) {
655
766
  throw new Error('The `onCancel` handler was attached after the promise settled.');
656
767
  }
657
- this._cancelHandlers.push(handler);
768
+ _this._cancelHandlers.push(handler);
658
769
  };
659
770
  return executor(onResolve, onReject, onCancel);
660
771
  }),
661
772
  ];
662
773
  if (timeout) {
663
- promises.push(new Promise((resolve, reject) => {
664
- setTimeout(() => {
665
- if (this._isPending) {
774
+ promises.push(new Promise(function (resolve, reject) {
775
+ setTimeout(function () {
776
+ if (_this._isPending) {
666
777
  try {
667
- this.cancel();
778
+ _this.cancel();
668
779
  }
669
780
  finally {
670
781
  reject(new TimeoutError());
@@ -675,21 +786,23 @@ class CancelablePromise$1 {
675
786
  }
676
787
  this._promise = Promise.race(promises);
677
788
  }
678
- static createControl(opt) {
789
+ CancelablePromise.createControl = function (opt) {
679
790
  return new PromiseControl(opt);
680
- }
681
- static resolve(value) {
682
- return new CancelablePromise$1((resolve) => resolve(value));
683
- }
684
- static reject(value) {
685
- return new CancelablePromise$1((resolve, reject) => reject(value));
686
- }
687
- static all(values) {
688
- return new CancelablePromise$1((resolve, reject) => {
791
+ };
792
+ CancelablePromise.resolve = function (value) {
793
+ return new CancelablePromise(function (resolve) { return resolve(value); });
794
+ };
795
+ CancelablePromise.reject = function (value) {
796
+ return new CancelablePromise(function (resolve, reject) { return reject(value); });
797
+ };
798
+ CancelablePromise.all = function (values) {
799
+ var _this = this;
800
+ return new CancelablePromise(function (resolve, reject) {
689
801
  Promise.all(values).then(resolve).catch(reject);
690
- }).catch((er) => {
691
- if (er instanceof this.CancelError) {
692
- for (const v of values) {
802
+ }).catch(function (er) {
803
+ if (er instanceof _this.CancelError) {
804
+ for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
805
+ var v = values_1[_i];
693
806
  if ('cancel' in v) {
694
807
  v.cancel();
695
808
  }
@@ -697,19 +810,20 @@ class CancelablePromise$1 {
697
810
  }
698
811
  throw er;
699
812
  });
700
- }
701
- attach(p) {
813
+ };
814
+ CancelablePromise.prototype.attach = function (p) {
702
815
  if (this._isCanceled) {
703
816
  p.cancel();
704
817
  }
705
818
  else {
706
819
  this._children.push(p);
707
820
  }
708
- }
709
- then(onfulfilled, onrejected) {
710
- const p = new CancelablePromise$1((resolve, reject) => {
711
- if (this._promise) {
712
- const reject_ = (r) => {
821
+ };
822
+ CancelablePromise.prototype.then = function (onfulfilled, onrejected) {
823
+ var _this = this;
824
+ var p = new CancelablePromise(function (resolve, reject) {
825
+ if (_this._promise) {
826
+ var reject_1 = function (r) {
713
827
  if (onrejected) {
714
828
  handleCallback(resolve, reject, onrejected, r);
715
829
  }
@@ -717,9 +831,9 @@ class CancelablePromise$1 {
717
831
  reject(r);
718
832
  }
719
833
  };
720
- this._promise.then((r) => {
721
- if (this._isCanceled) {
722
- reject_(r);
834
+ _this._promise.then(function (r) {
835
+ if (_this._isCanceled) {
836
+ reject_1(r);
723
837
  }
724
838
  else {
725
839
  if (onfulfilled) {
@@ -729,20 +843,20 @@ class CancelablePromise$1 {
729
843
  resolve(r);
730
844
  }
731
845
  }
732
- }, reject_);
846
+ }, reject_1);
733
847
  }
734
848
  });
735
849
  p._parentPromise = this;
736
850
  this._children.push(p);
737
851
  return p;
738
- }
739
- catch(onrejected) {
852
+ };
853
+ CancelablePromise.prototype.catch = function (onrejected) {
740
854
  if (this._isCanceled && onrejected) {
741
855
  onrejected(new CancelError());
742
856
  }
743
857
  return this.then(undefined, onrejected);
744
- }
745
- finally(onfinally) {
858
+ };
859
+ CancelablePromise.prototype.finally = function (onfinally) {
746
860
  if (this._promise) {
747
861
  return this._promise.finally(onfinally);
748
862
  }
@@ -750,24 +864,25 @@ class CancelablePromise$1 {
750
864
  return Promise.reject(new CancelError());
751
865
  }
752
866
  return Promise.reject(onfinally);
753
- }
754
- cancel() {
867
+ };
868
+ CancelablePromise.prototype.cancel = function () {
755
869
  // No reason to run cancel action if promise is already complete
756
870
  if (this._isCanceled || !this._isPending) {
757
871
  return this;
758
872
  }
759
873
  this._isCanceled = true;
760
- const parent = this._getTopParent();
874
+ var parent = this._getTopParent();
761
875
  if (parent) {
762
876
  parent.cancel();
763
877
  }
764
878
  if (this._children) {
765
- this._children.forEach((x) => x.cancel());
879
+ this._children.forEach(function (x) { return x.cancel(); });
766
880
  }
767
881
  if (this._isPending) {
768
882
  if (this._cancelHandlers.length) {
769
883
  try {
770
- for (const handler of this._cancelHandlers) {
884
+ for (var _i = 0, _a = this._cancelHandlers; _i < _a.length; _i++) {
885
+ var handler = _a[_i];
771
886
  handler();
772
887
  }
773
888
  }
@@ -781,10 +896,10 @@ class CancelablePromise$1 {
781
896
  }
782
897
  this._destroy();
783
898
  return this;
784
- }
785
- _getTopParent() {
786
- let parent = this._parentPromise;
787
- let hasParent = !!parent;
899
+ };
900
+ CancelablePromise.prototype._getTopParent = function () {
901
+ var parent = this._parentPromise;
902
+ var hasParent = !!parent;
788
903
  while (hasParent) {
789
904
  if (parent && parent._parentPromise) {
790
905
  parent = parent._parentPromise;
@@ -795,16 +910,17 @@ class CancelablePromise$1 {
795
910
  }
796
911
  }
797
912
  return parent;
798
- }
799
- _destroy() {
913
+ };
914
+ CancelablePromise.prototype._destroy = function () {
800
915
  this._setCanceledCallback = undefined;
801
916
  this._cancelPromise = undefined;
802
917
  this._promise = undefined;
803
- }
804
- }
805
- CancelablePromise$1.CancelError = CancelError;
806
- CancelablePromise$1.TimeoutError = TimeoutError;
807
- CancelablePromise$1.PromiseControl = PromiseControl;
918
+ };
919
+ CancelablePromise.CancelError = CancelError;
920
+ CancelablePromise.TimeoutError = TimeoutError;
921
+ CancelablePromise.PromiseControl = PromiseControl;
922
+ return CancelablePromise;
923
+ }());
808
924
  Object.setPrototypeOf(CancelablePromise$1.prototype, Promise.prototype);
809
925
 
810
926
  /**
@@ -883,15 +999,15 @@ function isEqual(a, b, o, p) {
883
999
  }
884
1000
  // based on https://stackoverflow.com/a/13143059
885
1001
  function objectDeepEqual(o, p) {
886
- const keysO = Object.keys(o).sort();
887
- const keysP = Object.keys(p).sort();
1002
+ var keysO = Object.keys(o).sort();
1003
+ var keysP = Object.keys(p).sort();
888
1004
  if (keysO.length !== keysP.length)
889
1005
  return false;
890
1006
  if (keysO.join('') !== keysP.join(''))
891
1007
  return false;
892
- for (let i = 0; i < keysO.length; i++) {
893
- const oVal = o[keysO[i]];
894
- const pVal = p[keysP[i]];
1008
+ for (var i = 0; i < keysO.length; i++) {
1009
+ var oVal = o[keysO[i]];
1010
+ var pVal = p[keysP[i]];
895
1011
  if (!isEqual(oVal, pVal, o, p)) {
896
1012
  return false;
897
1013
  }
@@ -900,8 +1016,8 @@ function objectDeepEqual(o, p) {
900
1016
  }
901
1017
 
902
1018
  function objectRemoveEmpty(obj) {
903
- const newObj = {};
904
- Object.keys(obj).forEach((key) => {
1019
+ var newObj = {};
1020
+ Object.keys(obj).forEach(function (key) {
905
1021
  if (!(obj[key] instanceof Array) && obj[key] === Object(obj[key])) {
906
1022
  newObj[key] = objectRemoveEmpty(obj[key]);
907
1023
  }
@@ -947,23 +1063,24 @@ function fixUrlStr(url) {
947
1063
  * console.log(COUNTER); // 1
948
1064
  * ```
949
1065
  */
950
- class Cache$1 {
951
- constructor(options = {}) {
1066
+ var Cache$1 = /** @class */ (function () {
1067
+ function Cache(options) {
1068
+ if (options === void 0) { options = {}; }
952
1069
  var _a;
953
1070
  this.cache = [];
954
- const namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : 'default';
955
- if (Cache$1.instance[namespace]) {
956
- return Cache$1.instance[namespace];
1071
+ var namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : 'default';
1072
+ if (Cache.instance[namespace]) {
1073
+ return Cache.instance[namespace];
957
1074
  }
958
- Cache$1.instance[namespace] = this;
1075
+ Cache.instance[namespace] = this;
959
1076
  return this;
960
1077
  }
961
- clean() {
1078
+ Cache.prototype.clean = function () {
962
1079
  this.cache.length = 0;
963
- }
964
- all() {
1080
+ };
1081
+ Cache.prototype.all = function () {
965
1082
  return this.cache;
966
- }
1083
+ };
967
1084
  /**
968
1085
  * Caching only a non-empty value.
969
1086
  *
@@ -986,23 +1103,24 @@ class Cache$1 {
986
1103
  *
987
1104
  * ```
988
1105
  */
989
- addFull(key, valueToSet, props) {
1106
+ Cache.prototype.addFull = function (key, valueToSet, props) {
990
1107
  return this.add(key, valueToSet, props, true);
991
- }
992
- add(key, valueToSet, props, onlyFull) {
993
- const exist = this._find(key, props);
1108
+ };
1109
+ Cache.prototype.add = function (key, valueToSet, props, onlyFull) {
1110
+ var _this = this;
1111
+ var exist = this._find(key, props);
994
1112
  if (!exist) {
995
- let value;
1113
+ var value = void 0;
996
1114
  if (valueToSet instanceof Function) {
997
1115
  value = valueToSet();
998
1116
  }
999
1117
  else {
1000
1118
  value = valueToSet;
1001
1119
  }
1002
- const props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1003
- const cacheItem = {
1004
- key,
1005
- value,
1120
+ var props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1121
+ var cacheItem = {
1122
+ key: key,
1123
+ value: value,
1006
1124
  props: props_,
1007
1125
  // TODO: remove backward compatibility use only props
1008
1126
  options: props_,
@@ -1012,14 +1130,14 @@ class Cache$1 {
1012
1130
  }
1013
1131
  this.cache.push(cacheItem);
1014
1132
  if (value instanceof Promise) {
1015
- value.catch((er) => {
1016
- this.delete(key, props);
1133
+ value.catch(function (er) {
1134
+ _this.delete(key, props);
1017
1135
  throw er;
1018
1136
  });
1019
1137
  if (onlyFull) {
1020
- value.then((x) => {
1138
+ value.then(function (x) {
1021
1139
  if (!full(x)) {
1022
- this.delete(key, props);
1140
+ _this.delete(key, props);
1023
1141
  }
1024
1142
  return x;
1025
1143
  });
@@ -1031,50 +1149,55 @@ class Cache$1 {
1031
1149
  else {
1032
1150
  return exist.value;
1033
1151
  }
1034
- }
1035
- match(key, props) {
1036
- const cacheRecord = this._find(key, props);
1152
+ };
1153
+ Cache.prototype.match = function (key, props) {
1154
+ var cacheRecord = this._find(key, props);
1037
1155
  if (cacheRecord) {
1038
1156
  return cacheRecord.value;
1039
1157
  }
1040
- }
1041
- matchAll(key, props) {
1158
+ };
1159
+ Cache.prototype.matchAll = function (key, props) {
1160
+ var _this = this;
1042
1161
  if (key) {
1043
1162
  return this.cache
1044
- .filter((x) => this._filter(x, key, props))
1045
- .map((x) => x.value);
1163
+ .filter(function (x) { return _this._filter(x, key, props); })
1164
+ .map(function (x) { return x.value; });
1046
1165
  }
1047
- return this.cache.map((x) => x.value);
1048
- }
1049
- delete(keyOrItem, props) {
1050
- let exist = [];
1166
+ return this.cache.map(function (x) { return x.value; });
1167
+ };
1168
+ Cache.prototype.delete = function (keyOrItem, props) {
1169
+ var _this = this;
1170
+ var exist = [];
1051
1171
  if (typeof keyOrItem === 'string') {
1052
- exist = this.cache.filter((x) => this._filter(x, keyOrItem, props));
1172
+ exist = this.cache.filter(function (x) { return _this._filter(x, keyOrItem, props); });
1053
1173
  }
1054
1174
  else {
1055
1175
  exist.push(keyOrItem);
1056
1176
  }
1057
- for (const e of exist) {
1058
- const index = this.cache.indexOf(e);
1177
+ for (var _i = 0, exist_1 = exist; _i < exist_1.length; _i++) {
1178
+ var e = exist_1[_i];
1179
+ var index = this.cache.indexOf(e);
1059
1180
  this.cache.splice(index, 1);
1060
1181
  }
1061
- }
1062
- _find(key, props) {
1063
- return this.cache.find((x) => this._filter(x, key, props));
1064
- }
1065
- _filter(item, key, props) {
1182
+ };
1183
+ Cache.prototype._find = function (key, props) {
1184
+ var _this = this;
1185
+ return this.cache.find(function (x) { return _this._filter(x, key, props); });
1186
+ };
1187
+ Cache.prototype._filter = function (item, key, props) {
1066
1188
  if (item.key === key) {
1067
1189
  if (props) {
1068
1190
  // TODO: remove backward compatibility
1069
- const itemProps = item.props || item.options;
1191
+ var itemProps = item.props || item.options;
1070
1192
  return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1071
1193
  }
1072
1194
  return true;
1073
1195
  }
1074
1196
  return false;
1075
- }
1076
- }
1077
- Cache$1.instance = {};
1197
+ };
1198
+ Cache.instance = {};
1199
+ return Cache;
1200
+ }());
1078
1201
 
1079
1202
  /**
1080
1203
  * Caching for asynchronous functions
@@ -1087,43 +1210,49 @@ var Cache = Cache$1;
1087
1210
  /**
1088
1211
  * Thrown when...
1089
1212
  */
1090
- class NgwError extends Error {
1091
- constructor(er) {
1092
- super();
1093
- this.name = 'NgwError';
1094
- Object.assign(this, er);
1095
- Object.setPrototypeOf(this, NgwError.prototype);
1096
- }
1097
- }
1213
+ var NgwError = /** @class */ (function (_super) {
1214
+ __extends(NgwError, _super);
1215
+ function NgwError(er) {
1216
+ var _this = _super.call(this) || this;
1217
+ _this.name = 'NgwError';
1218
+ Object.assign(_this, er);
1219
+ Object.setPrototypeOf(_this, NgwError.prototype);
1220
+ return _this;
1221
+ }
1222
+ return NgwError;
1223
+ }(Error));
1098
1224
 
1099
1225
  /**
1100
1226
  * Thrown when...
1101
1227
  */
1102
- class NetworkError extends Error {
1103
- constructor(url) {
1104
- super();
1105
- this.name = 'NetworkError';
1106
- Object.setPrototypeOf(this, NetworkError.prototype);
1107
- this.message = `Unable to request ${url}.
1108
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`; // /control-panel/cors
1109
- }
1110
- }
1228
+ var NetworkError = /** @class */ (function (_super) {
1229
+ __extends(NetworkError, _super);
1230
+ function NetworkError(url) {
1231
+ var _this = _super.call(this) || this;
1232
+ _this.name = 'NetworkError';
1233
+ Object.setPrototypeOf(_this, NetworkError.prototype);
1234
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
1235
+ return _this;
1236
+ }
1237
+ return NetworkError;
1238
+ }(Error));
1111
1239
 
1112
1240
  function isObject(val) {
1113
1241
  return Object.prototype.toString.call(val) === '[object Object]';
1114
1242
  }
1115
1243
 
1116
- let loadData;
1244
+ var loadData;
1117
1245
  // @ts-ignore
1118
1246
  {
1119
- loadData = (url, callback, options = {}, error, onCancel) => {
1247
+ loadData = function (url, callback, options, error, onCancel) {
1248
+ if (options === void 0) { options = {}; }
1120
1249
  options.method = options.method || 'GET';
1121
- const xhr = new XMLHttpRequest();
1250
+ var xhr = new XMLHttpRequest();
1122
1251
  xhr.open(options.method || 'GET', url, true); // true for asynchronous
1123
1252
  if (options.responseType === 'blob') {
1124
1253
  xhr.responseType = options.responseType;
1125
1254
  }
1126
- const getResponseText = () => {
1255
+ var getResponseText = function () {
1127
1256
  try {
1128
1257
  return JSON.parse(xhr.responseText);
1129
1258
  }
@@ -1131,8 +1260,9 @@ let loadData;
1131
1260
  return xhr.responseText;
1132
1261
  }
1133
1262
  };
1134
- const processingResponse = (forError = false) => {
1135
- const cb = forError ? error : callback;
1263
+ var processingResponse = function (forError) {
1264
+ if (forError === void 0) { forError = false; }
1265
+ var cb = forError ? error : callback;
1136
1266
  if (options.responseType === 'blob') {
1137
1267
  cb(xhr.response);
1138
1268
  }
@@ -1145,7 +1275,7 @@ let loadData;
1145
1275
  }
1146
1276
  }
1147
1277
  };
1148
- xhr.onload = () => {
1278
+ xhr.onload = function () {
1149
1279
  if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
1150
1280
  error(new NgwError(getResponseText()));
1151
1281
  }
@@ -1167,7 +1297,7 @@ let loadData;
1167
1297
  // error('request error');
1168
1298
  // }
1169
1299
  // };
1170
- xhr.onerror = (er) => {
1300
+ xhr.onerror = function (er) {
1171
1301
  if (xhr.status === 0) {
1172
1302
  error(new NetworkError(url));
1173
1303
  }
@@ -1177,17 +1307,17 @@ let loadData;
1177
1307
  };
1178
1308
  xhr.upload.onprogress = function (e) {
1179
1309
  if (e.lengthComputable) {
1180
- const percentComplete = (e.loaded / e.total) * 100;
1310
+ var percentComplete = (e.loaded / e.total) * 100;
1181
1311
  if (options.onProgress) {
1182
1312
  options.onProgress(percentComplete, e);
1183
1313
  }
1184
1314
  // console.log(percentComplete + '% uploaded');
1185
1315
  }
1186
1316
  };
1187
- const headers = options.headers;
1317
+ var headers = options.headers;
1188
1318
  if (headers) {
1189
- for (const h in headers) {
1190
- const header = headers[h];
1319
+ for (var h in headers) {
1320
+ var header = headers[h];
1191
1321
  if (typeof header === 'string') {
1192
1322
  xhr.setRequestHeader(h, header);
1193
1323
  }
@@ -1196,12 +1326,12 @@ let loadData;
1196
1326
  if (options.withCredentials !== undefined) {
1197
1327
  xhr.withCredentials = options.withCredentials;
1198
1328
  }
1199
- let data;
1329
+ var data;
1200
1330
  if (options.file) {
1201
1331
  data = new FormData();
1202
1332
  data.append('file', options.file);
1203
1333
  if (options.data) {
1204
- for (const d in options.data) {
1334
+ for (var d in options.data) {
1205
1335
  data.append(d, data[d]);
1206
1336
  }
1207
1337
  }
@@ -1214,7 +1344,7 @@ let loadData;
1214
1344
  : null;
1215
1345
  }
1216
1346
  if (onCancel) {
1217
- onCancel(() => {
1347
+ onCancel(function () {
1218
1348
  xhr.abort();
1219
1349
  });
1220
1350
  }
@@ -1223,10 +1353,10 @@ let loadData;
1223
1353
  }
1224
1354
 
1225
1355
  // https://github.com/Leaflet/Leaflet/blob/b507e21c510b53cd704fb8d3f89bb46ea925c8eb/src/core/Util.js#L165
1226
- const templateRe = /\{ *([\w_-]+) *\}/g;
1356
+ var templateRe = /\{ *([\w_-]+) *\}/g;
1227
1357
  function template(str, data) {
1228
- return str.replace(templateRe, (s, key) => {
1229
- let value = data[key];
1358
+ return str.replace(templateRe, function (s, key) {
1359
+ var value = data[key];
1230
1360
  if (value === undefined) {
1231
1361
  throw new Error('No value provided for letiable ' + s);
1232
1362
  }
@@ -1240,33 +1370,39 @@ function template(str, data) {
1240
1370
  /**
1241
1371
  * Thrown when ...
1242
1372
  */
1243
- class ResourceNotFoundError extends NgwError {
1244
- constructor(obj) {
1245
- super(obj);
1246
- this.name = 'ResourceNotFoundError';
1247
- this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
1248
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1249
- }
1250
- }
1373
+ var ResourceNotFoundError = /** @class */ (function (_super) {
1374
+ __extends(ResourceNotFoundError, _super);
1375
+ function ResourceNotFoundError(obj) {
1376
+ var _this = _super.call(this, obj) || this;
1377
+ _this.name = 'ResourceNotFoundError';
1378
+ _this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
1379
+ Object.setPrototypeOf(_this, ResourceNotFoundError.prototype);
1380
+ return _this;
1381
+ }
1382
+ return ResourceNotFoundError;
1383
+ }(NgwError));
1251
1384
 
1252
1385
  /**
1253
1386
  * Thrown when ...
1254
1387
  */
1255
- class InsufficientPermissionsError extends NgwError {
1256
- constructor(obj) {
1257
- super(obj);
1258
- this.name = 'InsufficientPermissionsError';
1259
- this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
1260
- Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1261
- }
1262
- }
1263
-
1264
- const CONNECTORS = [];
1388
+ var InsufficientPermissionsError = /** @class */ (function (_super) {
1389
+ __extends(InsufficientPermissionsError, _super);
1390
+ function InsufficientPermissionsError(obj) {
1391
+ var _this = _super.call(this, obj) || this;
1392
+ _this.name = 'InsufficientPermissionsError';
1393
+ _this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
1394
+ Object.setPrototypeOf(_this, InsufficientPermissionsError.prototype);
1395
+ return _this;
1396
+ }
1397
+ return InsufficientPermissionsError;
1398
+ }(NgwError));
1399
+
1400
+ var CONNECTORS = [];
1265
1401
  function addConnector(connector) {
1266
1402
  CONNECTORS.push(connector);
1267
1403
  }
1268
1404
  function findConnector(options) {
1269
- return CONNECTORS.find((x) => {
1405
+ return CONNECTORS.find(function (x) {
1270
1406
  if (x.options.baseUrl === options.baseUrl) {
1271
1407
  if (options.auth) {
1272
1408
  if (x.options.auth) {
@@ -1281,13 +1417,13 @@ function findConnector(options) {
1281
1417
  });
1282
1418
  }
1283
1419
  function removeConnector(connector) {
1284
- const index = CONNECTORS.indexOf(connector);
1420
+ var index = CONNECTORS.indexOf(connector);
1285
1421
  if (index !== -1) {
1286
1422
  CONNECTORS.splice(index, 1);
1287
1423
  }
1288
1424
  }
1289
1425
 
1290
- const exclude = ['description'];
1426
+ var exclude = ['description'];
1291
1427
  /**
1292
1428
  * @remarks
1293
1429
  * https://docs.nextgis.ru/docs_ngweb_dev/doc/developer/resource.html#search-resources
@@ -1298,14 +1434,16 @@ const exclude = ['description'];
1298
1434
  *
1299
1435
  * @param resource - Any property from NGW resource item
1300
1436
  */
1301
- function resourceToQuery(resource, prefix = '') {
1437
+ function resourceToQuery(resource, prefix) {
1438
+ if (prefix === void 0) { prefix = ''; }
1302
1439
  prefix = prefix ? prefix + '__' : '';
1303
- const query = {};
1304
- for (const [key, value] of Object.entries(resource)) {
1440
+ var query = {};
1441
+ for (var _i = 0, _a = Object.entries(resource); _i < _a.length; _i++) {
1442
+ var _b = _a[_i], key = _b[0], value = _b[1];
1305
1443
  if (exclude.indexOf(key) === -1) {
1306
1444
  if (isObject(value)) {
1307
1445
  if (key === 'owner_user') {
1308
- const children = resourceToQuery(value, key);
1446
+ var children = resourceToQuery(value, key);
1309
1447
  Object.assign(query, children);
1310
1448
  }
1311
1449
  else if (key === 'parent' && 'id' in value) {
@@ -1324,8 +1462,8 @@ function resourceCompare(res1, res2) {
1324
1462
  return objectDeepEqual(res1, res2);
1325
1463
  }
1326
1464
 
1327
- class ResourcesControl {
1328
- constructor(connector) {
1465
+ var ResourcesControl = /** @class */ (function () {
1466
+ function ResourcesControl(connector) {
1329
1467
  this.connector = connector;
1330
1468
  this.cache = new Cache();
1331
1469
  }
@@ -1339,10 +1477,11 @@ class ResourcesControl {
1339
1477
  * @remarks
1340
1478
  * Fetching resource would be cached to speed up next call
1341
1479
  */
1342
- getOne(resource, requestOptions) {
1343
- const cache = new Cache();
1344
- const forCache = {};
1345
- const opt = { ...requestOptions, cache: false };
1480
+ ResourcesControl.prototype.getOne = function (resource, requestOptions) {
1481
+ var _this = this;
1482
+ var cache = new Cache();
1483
+ var forCache = {};
1484
+ var opt = __assign(__assign({}, requestOptions), { cache: false });
1346
1485
  if (typeof resource === 'string') {
1347
1486
  forCache.keyname = resource;
1348
1487
  }
@@ -1352,28 +1491,28 @@ class ResourcesControl {
1352
1491
  else if (isObject(resource)) {
1353
1492
  forCache.id = resource.id;
1354
1493
  }
1355
- const makeRequest = () => {
1494
+ var makeRequest = function () {
1356
1495
  if (typeof resource === 'string') {
1357
- return this._fetchResourceBy({ keyname: resource }, opt);
1496
+ return _this._fetchResourceBy({ keyname: resource }, opt);
1358
1497
  }
1359
1498
  else if (typeof resource === 'number') {
1360
- return this._fetchResourceById(resource, opt);
1499
+ return _this._fetchResourceById(resource, opt);
1361
1500
  }
1362
1501
  else if (isObject(resource)) {
1363
- return this._fetchResourceBy(resource, opt);
1502
+ return _this._fetchResourceBy(resource, opt);
1364
1503
  }
1365
1504
  return CancelablePromise.resolve(undefined);
1366
1505
  };
1367
1506
  return cache.addFull('resource', makeRequest, forCache);
1368
- }
1369
- getOneOrFail(resource, requestOptions) {
1370
- return this.getOne(resource, requestOptions).then((res) => {
1507
+ };
1508
+ ResourcesControl.prototype.getOneOrFail = function (resource, requestOptions) {
1509
+ return this.getOne(resource, requestOptions).then(function (res) {
1371
1510
  if (res) {
1372
1511
  return res;
1373
1512
  }
1374
1513
  throw new ResourceNotFoundError();
1375
1514
  });
1376
- }
1515
+ };
1377
1516
  /**
1378
1517
  * A fast way to retrieve resource ID for any resource definition.
1379
1518
  * @param resource - Any available resource definition
@@ -1384,19 +1523,19 @@ class ResourcesControl {
1384
1523
  * then this method will come in handy to facilitate the extraction of the identifier
1385
1524
  * if the resource is specified through a keyname or other parameters.
1386
1525
  */
1387
- getId(resource, requestOptions) {
1526
+ ResourcesControl.prototype.getId = function (resource, requestOptions) {
1388
1527
  if (typeof resource === 'number') {
1389
1528
  return CancelablePromise.resolve(resource);
1390
1529
  }
1391
1530
  else if (typeof resource === 'string' || isObject(resource)) {
1392
- return this.getOne(resource, requestOptions).then((res) => {
1531
+ return this.getOne(resource, requestOptions).then(function (res) {
1393
1532
  if (res) {
1394
1533
  return res.resource.id;
1395
1534
  }
1396
1535
  });
1397
1536
  }
1398
1537
  return CancelablePromise.resolve(undefined);
1399
- }
1538
+ };
1400
1539
  /**
1401
1540
  * A fast way to retrieve resource ID for any resource definition.
1402
1541
  * @param resource - Any available resource definition
@@ -1405,33 +1544,32 @@ class ResourcesControl {
1405
1544
  * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
1406
1545
  * To not make one more checks if the resource is definitely exists
1407
1546
  */
1408
- getIdOrFail(resource, requestOptions) {
1409
- return this.getId(resource, requestOptions).then((resp) => {
1547
+ ResourcesControl.prototype.getIdOrFail = function (resource, requestOptions) {
1548
+ return this.getId(resource, requestOptions).then(function (resp) {
1410
1549
  if (resp === undefined) {
1411
1550
  throw new Error();
1412
1551
  }
1413
1552
  return resp;
1414
1553
  });
1415
- }
1416
- getMany(resource, requestOptions) {
1417
- return this._resourceCacheFilter(resource).then((items) => {
1554
+ };
1555
+ ResourcesControl.prototype.getMany = function (resource, requestOptions) {
1556
+ var _this = this;
1557
+ return this._resourceCacheFilter(resource).then(function (items) {
1418
1558
  if (!items.length) {
1419
- const query = {};
1559
+ var query = {};
1420
1560
  if (resource.keyname) {
1421
1561
  query.keyname = resource.keyname;
1422
1562
  }
1423
1563
  else {
1424
1564
  Object.assign(query, resourceToQuery(resource));
1425
1565
  }
1426
- return this.connector
1427
- .get('resource.search', requestOptions, {
1428
- serialization: 'full',
1429
- ...query,
1430
- })
1431
- .then((resources) => {
1566
+ return _this.connector
1567
+ .get('resource.search', requestOptions, __assign({ serialization: 'full' }, query))
1568
+ .then(function (resources) {
1432
1569
  if (resources) {
1433
- for (const x of resources) {
1434
- this.cache.add('resource.item', CancelablePromise.resolve(x), {
1570
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
1571
+ var x = resources_1[_i];
1572
+ _this.cache.add('resource.item', CancelablePromise.resolve(x), {
1435
1573
  id: x.resource.id,
1436
1574
  });
1437
1575
  }
@@ -1441,97 +1579,122 @@ class ResourcesControl {
1441
1579
  }
1442
1580
  return items;
1443
1581
  });
1444
- }
1445
- getParent(resource, requestOptions) {
1446
- return this.getOne(resource, requestOptions).then((child) => {
1582
+ };
1583
+ ResourcesControl.prototype.getParent = function (resource, requestOptions) {
1584
+ var _this = this;
1585
+ return this.getOne(resource, requestOptions).then(function (child) {
1447
1586
  if (child) {
1448
- return this.getOne(child.resource.parent.id, requestOptions);
1587
+ return _this.getOne(child.resource.parent.id, requestOptions);
1449
1588
  }
1450
1589
  return CancelablePromise.resolve(undefined);
1451
1590
  });
1452
- }
1453
- getChildrenOf(resource, requestOptions) {
1454
- return this.getId(resource).then((parent) => {
1455
- return this.connector
1456
- .get('resource.collection', { cache: true, ...requestOptions }, {
1457
- parent,
1591
+ };
1592
+ ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
1593
+ var _this = this;
1594
+ return this.getId(resource).then(function (parent) {
1595
+ return _this.connector
1596
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
1597
+ parent: parent,
1458
1598
  })
1459
- .then((items) => {
1460
- for (const i of items) {
1461
- this.cache.add('resource.item', CancelablePromise.resolve(i), {
1599
+ .then(function (items) {
1600
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1601
+ var i = items_1[_i];
1602
+ _this.cache.add('resource.item', CancelablePromise.resolve(i), {
1462
1603
  id: i.resource.id,
1463
1604
  });
1464
1605
  }
1465
1606
  return items;
1466
1607
  });
1467
1608
  });
1468
- }
1469
- update(resource, data) {
1470
- return this.getId(resource).then((id) => {
1609
+ };
1610
+ ResourcesControl.prototype.update = function (resource, data) {
1611
+ var _this = this;
1612
+ return this.getId(resource).then(function (id) {
1471
1613
  if (id !== undefined) {
1472
- return this.connector.put('resource.item', { data }, { id });
1614
+ return _this.connector.put('resource.item', { data: data }, { id: id });
1473
1615
  }
1474
1616
  });
1475
- }
1617
+ };
1476
1618
  /**
1477
1619
  * Fast way to delete resource from NGW and clean cache.
1478
1620
  * @param resource - Resource definition
1479
1621
  */
1480
- delete(resource) {
1481
- return this.getId(resource).then((id) => {
1622
+ ResourcesControl.prototype.delete = function (resource) {
1623
+ var _this = this;
1624
+ return this.getId(resource).then(function (id) {
1482
1625
  if (id !== undefined) {
1483
- return this.connector.delete('resource.item', null, { id }).then(() => {
1484
- this._cleanResourceItemCache(id);
1626
+ return _this.connector.delete('resource.item', null, { id: id }).then(function () {
1627
+ _this._cleanResourceItemCache(id);
1485
1628
  return undefined;
1486
1629
  });
1487
1630
  }
1488
1631
  });
1489
- }
1490
- async _cleanResourceItemCache(id) {
1491
- const all = this.cache.all();
1492
- const toDelete = [];
1493
- for (const c of all) {
1494
- const cid = c.options && c.options.id;
1495
- if (['resource.item', 'resource'].includes(c.key) && cid !== undefined) {
1496
- if (typeof cid === 'number') {
1497
- if (cid === id) {
1498
- toDelete.push(c);
1499
- }
1500
- }
1501
- else {
1502
- const rid = await this.getId(cid);
1503
- if (rid === id) {
1504
- toDelete.push(c);
1505
- }
1632
+ };
1633
+ ResourcesControl.prototype._cleanResourceItemCache = function (id) {
1634
+ return __awaiter(this, void 0, void 0, function () {
1635
+ var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
1636
+ return __generator(this, function (_b) {
1637
+ switch (_b.label) {
1638
+ case 0:
1639
+ all = this.cache.all();
1640
+ toDelete = [];
1641
+ _i = 0, all_1 = all;
1642
+ _b.label = 1;
1643
+ case 1:
1644
+ if (!(_i < all_1.length)) return [3 /*break*/, 5];
1645
+ c = all_1[_i];
1646
+ cid = c.options && c.options.id;
1647
+ if (!(['resource.item', 'resource'].includes(c.key) && cid !== undefined)) return [3 /*break*/, 4];
1648
+ if (!(typeof cid === 'number')) return [3 /*break*/, 2];
1649
+ if (cid === id) {
1650
+ toDelete.push(c);
1651
+ }
1652
+ return [3 /*break*/, 4];
1653
+ case 2: return [4 /*yield*/, this.getId(cid)];
1654
+ case 3:
1655
+ rid = _b.sent();
1656
+ if (rid === id) {
1657
+ toDelete.push(c);
1658
+ }
1659
+ _b.label = 4;
1660
+ case 4:
1661
+ _i++;
1662
+ return [3 /*break*/, 1];
1663
+ case 5:
1664
+ for (_a = 0, toDelete_1 = toDelete; _a < toDelete_1.length; _a++) {
1665
+ d = toDelete_1[_a];
1666
+ this.cache.delete(d);
1667
+ }
1668
+ return [2 /*return*/];
1506
1669
  }
1507
- }
1508
- }
1509
- for (const d of toDelete) {
1510
- this.cache.delete(d);
1511
- }
1512
- }
1513
- _fetchResourceById(id, requestOptions) {
1514
- const promise = () => this.connector.get('resource.item', requestOptions, { id });
1670
+ });
1671
+ });
1672
+ };
1673
+ ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
1674
+ var _this = this;
1675
+ var promise = function () {
1676
+ return _this.connector.get('resource.item', requestOptions, { id: id });
1677
+ };
1515
1678
  return this.cache
1516
1679
  .add('resource.item', promise, {
1517
- id,
1680
+ id: id,
1518
1681
  })
1519
- .catch((er) => {
1682
+ .catch(function (er) {
1520
1683
  if (!(er instanceof ResourceNotFoundError)) {
1521
1684
  throw er;
1522
1685
  }
1523
1686
  return undefined;
1524
1687
  });
1525
- }
1526
- _fetchResourceBy(resource, requestOptions) {
1527
- return this.getMany(resource, requestOptions).then((resources) => {
1688
+ };
1689
+ ResourcesControl.prototype._fetchResourceBy = function (resource, requestOptions) {
1690
+ return this.getMany(resource, requestOptions).then(function (resources) {
1528
1691
  return resources[0];
1529
1692
  });
1530
- }
1531
- _resourceCacheFilter(resource) {
1532
- return CancelablePromise.all(this.cache.matchAll('resource.item')).then((resources) => {
1533
- const items = [];
1534
- resources.filter((x) => {
1693
+ };
1694
+ ResourcesControl.prototype._resourceCacheFilter = function (resource) {
1695
+ return CancelablePromise.all(this.cache.matchAll('resource.item')).then(function (resources) {
1696
+ var items = [];
1697
+ resources.filter(function (x) {
1535
1698
  if (x) {
1536
1699
  // identical by uniq props
1537
1700
  if (resource.keyname && x.resource.keyname) {
@@ -1545,23 +1708,24 @@ class ResourcesControl {
1545
1708
  });
1546
1709
  return items;
1547
1710
  });
1548
- }
1549
- }
1711
+ };
1712
+ return ResourcesControl;
1713
+ }());
1550
1714
 
1551
1715
  function apiRequest(opt) {
1552
- const params = opt.params;
1553
- return new CancelablePromise((resolve, reject) => {
1716
+ var params = opt.params;
1717
+ return new CancelablePromise(function (resolve, reject) {
1554
1718
  opt.connector
1555
1719
  .connect()
1556
- .then((apiItems) => {
1557
- let apiItem = apiItems && apiItems[opt.name];
1720
+ .then(function (apiItems) {
1721
+ var apiItem = apiItems && apiItems[opt.name];
1558
1722
  if (apiItem) {
1559
- apiItem = [...apiItem];
1560
- let url = apiItem.shift();
1723
+ apiItem = __spreadArray([], apiItem, true);
1724
+ var url = apiItem.shift();
1561
1725
  if (apiItem.length) {
1562
- const replaceParams = {};
1563
- for (let fry = 0; fry < apiItem.length; fry++) {
1564
- const arg = apiItem[fry];
1726
+ var replaceParams = {};
1727
+ for (var fry = 0; fry < apiItem.length; fry++) {
1728
+ var arg = apiItem[fry];
1565
1729
  replaceParams[fry] = '{' + arg + '}';
1566
1730
  if (params[arg] === undefined) {
1567
1731
  throw new Error('`' + arg + '`' + ' url api argument is not specified');
@@ -1573,21 +1737,21 @@ function apiRequest(opt) {
1573
1737
  }
1574
1738
  // Transfer part of the parameters from `params` to the URL string
1575
1739
  if (params) {
1576
- const paramArray = [];
1577
- const paramList = params.paramList;
1740
+ var paramArray_1 = [];
1741
+ var paramList = params.paramList;
1578
1742
  if (Array.isArray(paramList)) {
1579
1743
  delete params.paramList;
1580
- paramList.forEach((x) => {
1581
- paramArray.push(`${x[0]}=${x[1]}`);
1744
+ paramList.forEach(function (x) {
1745
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1582
1746
  });
1583
1747
  }
1584
- for (const p in params) {
1748
+ for (var p in params) {
1585
1749
  if (apiItem.indexOf(p) === -1) {
1586
- paramArray.push(`${p}=${params[p]}`);
1750
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1587
1751
  }
1588
1752
  }
1589
- if (paramArray.length) {
1590
- url = url + '?' + paramArray.join('&');
1753
+ if (paramArray_1.length) {
1754
+ url = url + '?' + paramArray_1.join('&');
1591
1755
  }
1592
1756
  }
1593
1757
  if (url) {
@@ -1601,20 +1765,20 @@ function apiRequest(opt) {
1601
1765
  resolve(undefined);
1602
1766
  }
1603
1767
  })
1604
- .catch((er) => {
1768
+ .catch(function (er) {
1605
1769
  reject(er);
1606
1770
  });
1607
1771
  });
1608
1772
  }
1609
1773
 
1610
- let ID = 0;
1611
- class NgwConnector$1 {
1612
- constructor(options) {
1774
+ var ID = 0;
1775
+ var NgwConnector$1 = /** @class */ (function () {
1776
+ function NgwConnector(options) {
1613
1777
  this.options = options;
1614
1778
  this.id = ID++;
1615
1779
  this.emitter = new events.exports.EventEmitter();
1616
1780
  this.routeStr = '/api/component/pyramid/route';
1617
- const exist = findConnector(options);
1781
+ var exist = findConnector(options);
1618
1782
  if (exist) {
1619
1783
  return exist;
1620
1784
  }
@@ -1626,19 +1790,19 @@ class NgwConnector$1 {
1626
1790
  addConnector(this);
1627
1791
  }
1628
1792
  }
1629
- static create(options) {
1793
+ NgwConnector.create = function (options) {
1630
1794
  return new this(options);
1631
- }
1795
+ };
1632
1796
  /**
1633
1797
  * Fast way to specify the connection address to NextGIS Web.
1634
1798
  * The current connection will be severed.
1635
1799
  * @param baseUrl - NGW url
1636
1800
  */
1637
- setNgw(baseUrl) {
1801
+ NgwConnector.prototype.setNgw = function (baseUrl) {
1638
1802
  this.logout();
1639
1803
  this.options.baseUrl = baseUrl;
1640
1804
  addConnector(this);
1641
- }
1805
+ };
1642
1806
  /**
1643
1807
  * Establishing a connection with NextGIS Web to fulfill all other requests.
1644
1808
  * @remarks
@@ -1652,101 +1816,105 @@ class NgwConnector$1 {
1652
1816
  * .catch((er) => console.log('Connection problem', er));
1653
1817
  * ```
1654
1818
  */
1655
- connect() {
1656
- const cache = new Cache();
1657
- const auth = this.options.auth;
1658
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1659
- const makeQuery = () => {
1660
- return this.makeQuery(this.routeStr, {}, {})
1661
- .then((route) => {
1662
- resolve(route);
1663
- })
1664
- .catch((er) => {
1665
- reject(er);
1666
- });
1667
- };
1668
- if (auth) {
1669
- const { login, password } = auth;
1670
- if (login && password) {
1671
- return this.getUserInfo({ login, password })
1672
- .then(() => {
1673
- makeQuery();
1819
+ NgwConnector.prototype.connect = function () {
1820
+ var _this = this;
1821
+ var cache = new Cache();
1822
+ var auth = this.options.auth;
1823
+ var makeConnect = function () {
1824
+ return new CancelablePromise(function (resolve, reject) {
1825
+ var makeQuery = function () {
1826
+ return _this.makeQuery(_this.routeStr, {}, {})
1827
+ .then(function (route) {
1828
+ resolve(route);
1674
1829
  })
1675
- .catch((er) => reject(er));
1830
+ .catch(function (er) {
1831
+ reject(er);
1832
+ });
1833
+ };
1834
+ if (auth) {
1835
+ var login = auth.login, password = auth.password;
1836
+ if (login && password) {
1837
+ return _this.getUserInfo({ login: login, password: password })
1838
+ .then(function () {
1839
+ makeQuery();
1840
+ })
1841
+ .catch(function (er) { return reject(er); });
1842
+ }
1676
1843
  }
1677
- }
1678
- return makeQuery();
1679
- });
1844
+ return makeQuery();
1845
+ });
1846
+ };
1680
1847
  return cache.add('route', makeConnect, {
1681
1848
  id: this.id,
1682
- auth,
1849
+ auth: auth,
1683
1850
  baseUrl: this.options.baseUrl,
1684
1851
  });
1685
- }
1852
+ };
1686
1853
  /**
1687
1854
  * Quick way to change NextGIS Web user.
1688
1855
  * @param credentials - New user credentials
1689
1856
  */
1690
- login(credentials) {
1857
+ NgwConnector.prototype.login = function (credentials) {
1691
1858
  this.logout();
1692
1859
  addConnector(this);
1693
1860
  return this.getUserInfo(credentials);
1694
- }
1861
+ };
1695
1862
  /**
1696
1863
  * Disconnecting a user. Aborting all current requests
1697
1864
  */
1698
- logout() {
1865
+ NgwConnector.prototype.logout = function () {
1699
1866
  removeConnector(this);
1700
1867
  this.options.auth = undefined;
1701
1868
  this.user = undefined;
1702
1869
  this.emitter.emit('logout');
1703
1870
  this.resources.cache.clean();
1704
- }
1705
- getUserInfo(credentials) {
1871
+ };
1872
+ NgwConnector.prototype.getUserInfo = function (credentials) {
1873
+ var _this = this;
1706
1874
  if (this.user && this.user.id) {
1707
1875
  return CancelablePromise.resolve(this.user);
1708
1876
  }
1709
1877
  if (credentials) {
1710
1878
  this.options.auth = credentials;
1711
1879
  }
1712
- const options = {
1880
+ var options = {
1713
1881
  headers: this.getAuthorizationHeaders(credentials),
1714
1882
  // withCredentials: true
1715
1883
  };
1716
1884
  // Do not use apiRequest('auth.current_user') to avoid circular-references
1717
1885
  return this.makeQuery('/api/component/auth/current_user', {}, options)
1718
- .then((data) => {
1719
- this.user = data;
1720
- this.emitter.emit('login', data);
1886
+ .then(function (data) {
1887
+ _this.user = data;
1888
+ _this.emitter.emit('login', data);
1721
1889
  return data;
1722
1890
  })
1723
- .catch((er) => {
1724
- this.emitter.emit('login:error', er);
1891
+ .catch(function (er) {
1892
+ _this.emitter.emit('login:error', er);
1725
1893
  throw er;
1726
1894
  });
1727
- }
1895
+ };
1728
1896
  /**
1729
1897
  * Obtaining the required Headers for authentication of requests in the NGW.
1730
1898
  */
1731
- getAuthorizationHeaders(credentials) {
1732
- const client = this.makeClientId(credentials);
1899
+ NgwConnector.prototype.getAuthorizationHeaders = function (credentials) {
1900
+ var client = this.makeClientId(credentials);
1733
1901
  if (client) {
1734
1902
  return {
1735
1903
  Authorization: 'Basic ' + client,
1736
1904
  };
1737
1905
  }
1738
- }
1739
- makeClientId(credentials) {
1906
+ };
1907
+ NgwConnector.prototype.makeClientId = function (credentials) {
1740
1908
  credentials = credentials || this.options.auth;
1741
1909
  if (credentials) {
1742
- const { login, password } = credentials;
1743
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1910
+ var login = credentials.login, password = credentials.password;
1911
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
1744
1912
  // @ts-ignore
1745
1913
  {
1746
1914
  return window.btoa(str);
1747
1915
  }
1748
1916
  }
1749
- }
1917
+ };
1750
1918
  /**
1751
1919
  * Send request to NGW api router.
1752
1920
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1776,25 +1944,27 @@ class NgwConnector$1 {
1776
1944
  *
1777
1945
  * ```
1778
1946
  */
1779
- apiRequest(name, params_ = {}, requestOptions = {}) {
1780
- const { method, headers, withCredentials, responseType } = requestOptions;
1781
- const params = objectRemoveEmpty(params_);
1782
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
1947
+ NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
1948
+ var _this = this;
1949
+ if (params_ === void 0) { params_ = {}; }
1950
+ if (requestOptions === void 0) { requestOptions = {}; }
1951
+ var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
1952
+ var params = objectRemoveEmpty(params_);
1953
+ var makeApiRequest = function () {
1954
+ return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
1955
+ };
1783
1956
  if (requestOptions.cache && method === 'GET') {
1784
- const cache = new Cache();
1785
- return cache.add(name, makeApiRequest, {
1786
- params,
1787
- ...objectRemoveEmpty({
1788
- headers,
1789
- withCredentials,
1790
- responseType,
1791
- baseUrl: this.options.baseUrl,
1792
- auth: this.options.auth,
1793
- }),
1794
- });
1957
+ var cache = new Cache();
1958
+ return cache.add(name, makeApiRequest, __assign({ params: params }, objectRemoveEmpty({
1959
+ headers: headers,
1960
+ withCredentials: withCredentials,
1961
+ responseType: responseType,
1962
+ baseUrl: this.options.baseUrl,
1963
+ auth: this.options.auth,
1964
+ })));
1795
1965
  }
1796
1966
  return makeApiRequest();
1797
- }
1967
+ };
1798
1968
  /**
1799
1969
  * Shortcut method for send POST request to NGW.
1800
1970
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1808,62 +1978,63 @@ class NgwConnector$1 {
1808
1978
  * .catch((error) => console.warn(error));
1809
1979
  * ```
1810
1980
  */
1811
- post(name, options, params) {
1981
+ NgwConnector.prototype.post = function (name, options, params) {
1812
1982
  options = options || {};
1813
1983
  options.method = 'POST';
1814
1984
  return this.apiRequest(name, params, options);
1815
- }
1985
+ };
1816
1986
  /**
1817
1987
  * Shortcut method for send GET request to NGW.
1818
1988
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1819
1989
  * @param options - Request options
1820
1990
  * @param params - Request item params or query params
1821
1991
  */
1822
- get(name, options, params) {
1992
+ NgwConnector.prototype.get = function (name, options, params) {
1823
1993
  options = options || {};
1824
1994
  options.method = 'GET';
1825
1995
  return this.apiRequest(name, params, options);
1826
- }
1996
+ };
1827
1997
  /**
1828
1998
  * Shortcut method for send PATCH request to NGW.
1829
1999
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1830
2000
  * @param options - Request options
1831
2001
  * @param params - Request item params or query params
1832
2002
  */
1833
- patch(name, options, params) {
2003
+ NgwConnector.prototype.patch = function (name, options, params) {
1834
2004
  options = options || {};
1835
2005
  options.method = 'PATCH';
1836
2006
  return this.apiRequest(name, params, options);
1837
- }
2007
+ };
1838
2008
  /**
1839
2009
  * Shortcut method for send PUT request to NGW.
1840
2010
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1841
2011
  * @param options - Request options
1842
2012
  * @param params - Request item params or query params
1843
2013
  */
1844
- put(name, options, params) {
2014
+ NgwConnector.prototype.put = function (name, options, params) {
1845
2015
  options = options || {};
1846
2016
  options.method = 'PUT';
1847
2017
  return this.apiRequest(name, params, options);
1848
- }
2018
+ };
1849
2019
  /**
1850
2020
  * Shortcut method for send DELETE request to NGW.
1851
2021
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1852
2022
  * @param options - Request options
1853
2023
  * @param params - Request item params or query params
1854
2024
  */
1855
- delete(name, options, params) {
2025
+ NgwConnector.prototype.delete = function (name, options, params) {
1856
2026
  options = options || {};
1857
2027
  options.method = 'DELETE';
1858
2028
  return this.apiRequest(name, params, options);
1859
- }
2029
+ };
1860
2030
  /**
1861
2031
  * Send request to NGW.
1862
2032
  * @param url - URL address to NGW
1863
2033
  * @param params - Query params
1864
2034
  * @param options - Request options
1865
2035
  */
1866
- makeQuery(url, params, options = {}) {
2036
+ NgwConnector.prototype.makeQuery = function (url, params, options) {
2037
+ if (options === void 0) { options = {}; }
1867
2038
  url = (this.options.baseUrl ? this.options.baseUrl : '') + url;
1868
2039
  if (url) {
1869
2040
  if (params) {
@@ -1876,112 +2047,110 @@ class NgwConnector$1 {
1876
2047
  else {
1877
2048
  throw new Error('Empty `url` not allowed');
1878
2049
  }
1879
- }
2050
+ };
1880
2051
  // -------------------------------------------------------------------------
1881
2052
  // Resource Methods
1882
2053
  // -------------------------------------------------------------------------
1883
2054
  /**
1884
2055
  * {@inheritDoc ResourcesControl.getOne}
1885
2056
  */
1886
- getResource(resource, requestOptions) {
2057
+ NgwConnector.prototype.getResource = function (resource, requestOptions) {
1887
2058
  return this.resources.getOne(resource, requestOptions);
1888
- }
2059
+ };
1889
2060
  /**
1890
2061
  * {@inheritDoc ResourcesControl.getOneOrFail}
1891
2062
  */
1892
- getResourceOrFail(resource, requestOptions) {
2063
+ NgwConnector.prototype.getResourceOrFail = function (resource, requestOptions) {
1893
2064
  return this.resources.getOneOrFail(resource, requestOptions);
1894
- }
2065
+ };
1895
2066
  /**
1896
2067
  * @deprecated - use {@link NgwConnector.getResource}
1897
2068
  */
1898
- getResourceBy(resource) {
2069
+ NgwConnector.prototype.getResourceBy = function (resource) {
1899
2070
  return this.resources.getOne(resource);
1900
- }
2071
+ };
1901
2072
  /**
1902
2073
  * @deprecated - use {@link NgwConnector.getResource}
1903
2074
  */
1904
- getResourceByKeyname(keyname) {
2075
+ NgwConnector.prototype.getResourceByKeyname = function (keyname) {
1905
2076
  return this.resources.getOne(keyname);
1906
- }
2077
+ };
1907
2078
  /**
1908
2079
  * @deprecated - use {@link NgwConnector.getResource}
1909
2080
  */
1910
- getResourceById(id) {
2081
+ NgwConnector.prototype.getResourceById = function (id) {
1911
2082
  return this.resources.getOne(id);
1912
- }
2083
+ };
1913
2084
  /**
1914
2085
  * {@inheritDoc ResourcesControl.getId}
1915
2086
  */
1916
- getResourceId(resource, requestOptions) {
2087
+ NgwConnector.prototype.getResourceId = function (resource, requestOptions) {
1917
2088
  return this.resources.getId(resource, requestOptions);
1918
- }
2089
+ };
1919
2090
  /**
1920
2091
  * {@inheritDoc ResourcesControl.getIdOrFail}
1921
2092
  */
1922
- getResourceIdOrFail(resource, requestOptions) {
2093
+ NgwConnector.prototype.getResourceIdOrFail = function (resource, requestOptions) {
1923
2094
  return this.resources.getIdOrFail(resource, requestOptions);
1924
- }
2095
+ };
1925
2096
  /**
1926
2097
  * {@inheritDoc ResourcesControl.getMany}
1927
2098
  */
1928
- getResourcesBy(resource, requestOptions) {
2099
+ NgwConnector.prototype.getResourcesBy = function (resource, requestOptions) {
1929
2100
  return this.resources.getMany(resource, requestOptions);
1930
- }
2101
+ };
1931
2102
  /**
1932
2103
  * {@inheritDoc ResourcesControl.getParent}
1933
2104
  */
1934
- getResourceParent(resource, requestOptions) {
2105
+ NgwConnector.prototype.getResourceParent = function (resource, requestOptions) {
1935
2106
  return this.resources.getParent(resource, requestOptions);
1936
- }
2107
+ };
1937
2108
  /**
1938
2109
  * {@inheritDoc ResourcesControl.getChildrenOf}
1939
2110
  */
1940
- getResourceChildren(resource, requestOptions) {
2111
+ NgwConnector.prototype.getResourceChildren = function (resource, requestOptions) {
1941
2112
  return this.resources.getChildrenOf(resource, requestOptions);
1942
- }
2113
+ };
1943
2114
  /**
1944
2115
  * {@inheritDoc ResourcesControl.update}
1945
2116
  */
1946
- updateResource(resource, data) {
2117
+ NgwConnector.prototype.updateResource = function (resource, data) {
1947
2118
  return this.resources.update(resource, data);
1948
- }
2119
+ };
1949
2120
  /**
1950
2121
  * {@inheritDoc ResourcesControl.delete}
1951
2122
  */
1952
- deleteResource(resource) {
2123
+ NgwConnector.prototype.deleteResource = function (resource) {
1953
2124
  return this.resources.delete(resource);
1954
- }
2125
+ };
1955
2126
  /**
1956
2127
  * @internal
1957
2128
  */
1958
- _loadData(url, options) {
2129
+ NgwConnector.prototype._loadData = function (url, options) {
2130
+ var _this = this;
1959
2131
  options.responseType = options.responseType || 'json';
1960
- return new CancelablePromise((resolve, reject, onCancel) => {
1961
- if (this.user) {
2132
+ return new CancelablePromise(function (resolve, reject, onCancel) {
2133
+ if (_this.user) {
1962
2134
  options = options || {};
1963
2135
  // options.withCredentials = true;
1964
- options.headers = {
1965
- ...this.getAuthorizationHeaders(),
1966
- ...options.headers,
1967
- };
2136
+ options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
1968
2137
  }
1969
2138
  loadData(url, resolve, options, reject, onCancel);
1970
- }).catch((httpError) => {
2139
+ }).catch(function (httpError) {
1971
2140
  if (httpError instanceof CancelablePromise.CancelError) ;
1972
2141
  else {
1973
2142
  // @ts-ignore
1974
2143
  {
1975
2144
  console.warn('DEV WARN', httpError);
1976
2145
  }
1977
- const er = this._handleHttpError(httpError);
2146
+ var er = _this._handleHttpError(httpError);
1978
2147
  if (er) {
1979
2148
  throw er;
1980
2149
  }
1981
2150
  }
1982
2151
  });
1983
- }
1984
- _handleHttpError(er) {
2152
+ };
2153
+ NgwConnector.prototype._handleHttpError = function (er) {
1985
2154
  if (er) {
1986
2155
  if (er instanceof NgwError) {
1987
2156
  if (er.exception === 'nextgisweb.resource.exception.ResourceNotFound') {
@@ -1993,12 +2162,13 @@ class NgwConnector$1 {
1993
2162
  }
1994
2163
  }
1995
2164
  return er;
1996
- }
1997
- }
1998
- NgwConnector$1.errors = {
1999
- NgwError,
2000
- ResourceNotFoundError,
2001
- };
2165
+ };
2166
+ NgwConnector.errors = {
2167
+ NgwError: NgwError,
2168
+ ResourceNotFoundError: ResourceNotFoundError,
2169
+ };
2170
+ return NgwConnector;
2171
+ }());
2002
2172
 
2003
2173
  /**
2004
2174
  * A lightweight HTTP client optimized for use with {@link http://docs.nextgis.ru/docs_ngweb_dev/doc/developer/toc.html | NextGIS Web} API