@nextgis/ngw-map 3.0.0-alpha.0 → 3.0.0-alpha.12
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.
- package/lib/index.d.ts +11 -3
- package/lib/ngw-map.cjs.js +27 -16
- package/lib/ngw-map.cjs.js.map +1 -1
- package/lib/ngw-map.cjs.prod.js +1 -1
- package/lib/ngw-map.cjs.prod.js.map +1 -1
- package/lib/ngw-map.esm-browser.js +2122 -1337
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +1 -1
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +29 -16
- package/lib/ngw-map.esm-bundler.js.map +1 -1
- package/lib/ngw-map.esm-bundler.prod.js +1 -1
- package/lib/ngw-map.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-map.global.js +2122 -1337
- package/lib/ngw-map.global.js.map +1 -1
- package/lib/ngw-map.global.prod.js +1 -1
- package/lib/ngw-map.global.prod.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.8; author: NextGIS */
|
|
2
2
|
var domain;
|
|
3
3
|
|
|
4
4
|
// This constructor is used to store event handlers. Instantiating this is
|
|
@@ -29,7 +29,7 @@ EventEmitter.init = function() {
|
|
|
29
29
|
this.domain = null;
|
|
30
30
|
if (EventEmitter.usingDomains) {
|
|
31
31
|
// if there is an active domain, then attach to it.
|
|
32
|
-
if (domain.active
|
|
32
|
+
if (domain.active) ;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
|
|
@@ -824,12 +824,12 @@ function fixUrlStr(url) {
|
|
|
824
824
|
return url.replace(/([^:]\/)\/+/g, "$1");
|
|
825
825
|
}
|
|
826
826
|
|
|
827
|
-
var __defProp$
|
|
828
|
-
var __defNormalProp$
|
|
829
|
-
var __publicField$
|
|
827
|
+
var __defProp$Q = Object.defineProperty;
|
|
828
|
+
var __defNormalProp$Q = (obj, key, value) => key in obj ? __defProp$Q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
829
|
+
var __publicField$z = (obj, key, value) => __defNormalProp$Q(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
830
830
|
const _Cache = class _Cache {
|
|
831
831
|
constructor(options = {}) {
|
|
832
|
-
__publicField$
|
|
832
|
+
__publicField$z(this, "cache", []);
|
|
833
833
|
var _a;
|
|
834
834
|
const namespace = (_a = options.namespace) != null ? _a : "default";
|
|
835
835
|
if (_Cache.instance[namespace]) {
|
|
@@ -865,10 +865,23 @@ const _Cache = class _Cache {
|
|
|
865
865
|
* });
|
|
866
866
|
* ```
|
|
867
867
|
*/
|
|
868
|
-
addFull(key, valueToSet,
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
868
|
+
addFull(key, valueToSet, propsOrOptions, expirationTime) {
|
|
869
|
+
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
870
|
+
propsOrOptions.onlyFull = true;
|
|
871
|
+
}
|
|
872
|
+
return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
|
|
873
|
+
}
|
|
874
|
+
add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
|
|
875
|
+
let opt;
|
|
876
|
+
let props;
|
|
877
|
+
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
878
|
+
opt = propsOrOptions;
|
|
879
|
+
onlyFull = opt.onlyFull;
|
|
880
|
+
expirationTime = opt.expirationTime;
|
|
881
|
+
props = opt.props;
|
|
882
|
+
} else {
|
|
883
|
+
props = propsOrOptions;
|
|
884
|
+
}
|
|
872
885
|
const exist = this._find(key, props);
|
|
873
886
|
if (!exist) {
|
|
874
887
|
let value;
|
|
@@ -878,10 +891,12 @@ const _Cache = class _Cache {
|
|
|
878
891
|
value = valueToSet;
|
|
879
892
|
}
|
|
880
893
|
const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
|
|
894
|
+
expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
|
|
881
895
|
const cacheItem = {
|
|
882
896
|
key,
|
|
883
897
|
value,
|
|
884
|
-
props: nonEmptyProps
|
|
898
|
+
props: nonEmptyProps,
|
|
899
|
+
expirationTime
|
|
885
900
|
};
|
|
886
901
|
if (onlyFull && !full(value)) {
|
|
887
902
|
return value;
|
|
@@ -908,9 +923,19 @@ const _Cache = class _Cache {
|
|
|
908
923
|
}
|
|
909
924
|
match(key, props) {
|
|
910
925
|
const cacheRecord = this._find(key, props);
|
|
926
|
+
if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
|
|
927
|
+
this.delete(cacheRecord);
|
|
928
|
+
return void 0;
|
|
929
|
+
}
|
|
911
930
|
return cacheRecord == null ? void 0 : cacheRecord.value;
|
|
912
931
|
}
|
|
913
932
|
matchAll(key, props) {
|
|
933
|
+
const now = Date.now();
|
|
934
|
+
this.cache.forEach((item) => {
|
|
935
|
+
if (item.expirationTime && now > item.expirationTime) {
|
|
936
|
+
this.delete(item);
|
|
937
|
+
}
|
|
938
|
+
});
|
|
914
939
|
if (key) {
|
|
915
940
|
return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
|
|
916
941
|
}
|
|
@@ -935,87 +960,305 @@ const _Cache = class _Cache {
|
|
|
935
960
|
return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
|
|
936
961
|
}
|
|
937
962
|
};
|
|
938
|
-
__publicField$
|
|
963
|
+
__publicField$z(_Cache, "instance", {});
|
|
939
964
|
let Cache = _Cache;
|
|
940
965
|
|
|
941
|
-
var
|
|
942
|
-
|
|
943
|
-
|
|
966
|
+
var pkg = {
|
|
967
|
+
name: "@nextgis/ngw-connector",
|
|
968
|
+
version: "3.0.0-alpha.8",
|
|
969
|
+
_priority: 12,
|
|
970
|
+
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
971
|
+
main: "index.js",
|
|
972
|
+
module: "lib/ngw-connector.esm-bundler.js",
|
|
973
|
+
unpkg: "lib/ngw-connector.global.prod.js",
|
|
974
|
+
jsdelivr: "lib/ngw-connector.global.prod.js",
|
|
975
|
+
types: "lib/index.d.ts",
|
|
976
|
+
dependencies: {
|
|
977
|
+
"@nextgis/cache": "^3.0.0-alpha.7",
|
|
978
|
+
"@nextgis/cancelable-promise": "^3.0.0-alpha.5",
|
|
979
|
+
"@nextgis/utils": "^3.0.0-alpha.5",
|
|
980
|
+
"@types/events": "^3.0.0",
|
|
981
|
+
events: "*",
|
|
982
|
+
"form-data": "^4.0.0"
|
|
983
|
+
},
|
|
984
|
+
devDependencies: {
|
|
985
|
+
"@nextgis/build-tools": "^3.0.0-alpha.5"
|
|
986
|
+
},
|
|
987
|
+
scripts: {
|
|
988
|
+
clean: "rimraf ./lib",
|
|
989
|
+
dev: "node ../build-tools/lib/build.js",
|
|
990
|
+
prod: "npm run dev -- --release",
|
|
991
|
+
lint: "eslint ./src/**/*.ts --fix --c ../../.eslintrc",
|
|
992
|
+
watch: "npm run dev -- --watch",
|
|
993
|
+
"gen:types": "node ./scripts/generator"
|
|
994
|
+
},
|
|
995
|
+
buildOptions: {
|
|
996
|
+
name: "NgwConnector",
|
|
997
|
+
formats: [
|
|
998
|
+
"esm-bundler",
|
|
999
|
+
"esm-browser",
|
|
1000
|
+
"cjs",
|
|
1001
|
+
"global"
|
|
1002
|
+
]
|
|
1003
|
+
},
|
|
1004
|
+
keywords: [
|
|
1005
|
+
"NextGIS",
|
|
1006
|
+
"MAP"
|
|
1007
|
+
],
|
|
1008
|
+
author: "NextGIS",
|
|
1009
|
+
files: [
|
|
1010
|
+
"index.js",
|
|
1011
|
+
"lib"
|
|
1012
|
+
],
|
|
1013
|
+
license: "MIT",
|
|
1014
|
+
homepage: "https://github.com/nextgis/nextgis_frontend/tree/master/packages/ngw-connector#readme",
|
|
1015
|
+
repository: {
|
|
1016
|
+
type: "git",
|
|
1017
|
+
url: "git://github.com/nextgis/nextgis_frontend.git"
|
|
1018
|
+
},
|
|
1019
|
+
engines: {
|
|
1020
|
+
node: ">=18.20.4"
|
|
1021
|
+
},
|
|
1022
|
+
gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const CONNECTORS = [];
|
|
1026
|
+
function addConnector(connector) {
|
|
1027
|
+
CONNECTORS.push(connector);
|
|
1028
|
+
}
|
|
1029
|
+
function findConnector(options) {
|
|
1030
|
+
return CONNECTORS.find((x) => {
|
|
1031
|
+
if (x.options.baseUrl === options.baseUrl) {
|
|
1032
|
+
if (options.auth) {
|
|
1033
|
+
if (x.options.auth) {
|
|
1034
|
+
return objectDeepEqual(x.options.auth, options.auth);
|
|
1035
|
+
}
|
|
1036
|
+
} else {
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
function removeConnector(connector) {
|
|
1043
|
+
const index = CONNECTORS.indexOf(connector);
|
|
1044
|
+
if (index !== -1) {
|
|
1045
|
+
CONNECTORS.splice(index, 1);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
class AbortError extends Error {
|
|
1050
|
+
constructor(message = "AbortError") {
|
|
1051
|
+
super(message);
|
|
1052
|
+
this.name = "AbortError";
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
var __defProp$P = Object.defineProperty;
|
|
1057
|
+
var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1058
|
+
var __publicField$y = (obj, key, value) => __defNormalProp$P(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
944
1059
|
class NgwError extends Error {
|
|
945
1060
|
constructor(er) {
|
|
946
1061
|
super();
|
|
947
|
-
__publicField$
|
|
948
|
-
__publicField$
|
|
949
|
-
__publicField$
|
|
950
|
-
__publicField$
|
|
951
|
-
__publicField$
|
|
952
|
-
__publicField$
|
|
953
|
-
__publicField$
|
|
954
|
-
__publicField$
|
|
1062
|
+
__publicField$y(this, "name", "NgwError");
|
|
1063
|
+
__publicField$y(this, "title");
|
|
1064
|
+
__publicField$y(this, "message");
|
|
1065
|
+
__publicField$y(this, "detail");
|
|
1066
|
+
__publicField$y(this, "exception");
|
|
1067
|
+
__publicField$y(this, "status_code");
|
|
1068
|
+
__publicField$y(this, "data");
|
|
1069
|
+
__publicField$y(this, "guru_meditation");
|
|
955
1070
|
Object.assign(this, er);
|
|
956
1071
|
Object.setPrototypeOf(this, NgwError.prototype);
|
|
957
1072
|
}
|
|
958
1073
|
}
|
|
959
1074
|
|
|
960
|
-
var __defProp$
|
|
961
|
-
var __defNormalProp$
|
|
962
|
-
var __publicField$
|
|
1075
|
+
var __defProp$O = Object.defineProperty;
|
|
1076
|
+
var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1077
|
+
var __publicField$x = (obj, key, value) => __defNormalProp$O(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1078
|
+
class InsufficientPermissionsError extends NgwError {
|
|
1079
|
+
constructor(obj) {
|
|
1080
|
+
super(obj);
|
|
1081
|
+
__publicField$x(this, "name", "InsufficientPermissionsError");
|
|
1082
|
+
__publicField$x(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
|
|
1083
|
+
Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
var __defProp$N = Object.defineProperty;
|
|
1088
|
+
var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1089
|
+
var __publicField$w = (obj, key, value) => __defNormalProp$N(obj, key + "" , value);
|
|
1090
|
+
class NetworkError extends Error {
|
|
1091
|
+
constructor(url) {
|
|
1092
|
+
super();
|
|
1093
|
+
__publicField$w(this, "name", "NetworkError");
|
|
1094
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1095
|
+
this.message = `Unable to request ${url}.
|
|
1096
|
+
Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
var __defProp$M = Object.defineProperty;
|
|
1101
|
+
var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1102
|
+
var __publicField$v = (obj, key, value) => __defNormalProp$M(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1103
|
+
let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
|
|
1104
|
+
constructor(obj) {
|
|
1105
|
+
super(obj);
|
|
1106
|
+
__publicField$v(this, "message", "There is no response from the server or problem connecting to server.");
|
|
1107
|
+
__publicField$v(this, "title", "Network error");
|
|
1108
|
+
__publicField$v(this, "detail", "Check network connectivity and try again later.");
|
|
1109
|
+
Object.setPrototypeOf(this, NetworksResponseError.prototype);
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
var __defProp$L = Object.defineProperty;
|
|
1114
|
+
var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1115
|
+
var __publicField$u = (obj, key, value) => __defNormalProp$L(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
963
1116
|
class ResourceNotFoundError extends NgwError {
|
|
964
1117
|
constructor(obj) {
|
|
965
1118
|
super(obj);
|
|
966
|
-
__publicField$
|
|
967
|
-
__publicField$
|
|
1119
|
+
__publicField$u(this, "name", "ResourceNotFoundError");
|
|
1120
|
+
__publicField$u(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
|
|
968
1121
|
Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
|
|
969
1122
|
}
|
|
970
1123
|
}
|
|
971
1124
|
|
|
972
|
-
function
|
|
973
|
-
|
|
1125
|
+
function isError(error) {
|
|
1126
|
+
if (isObject$1(error)) {
|
|
1127
|
+
return error.status_code && error.exception && error.title;
|
|
1128
|
+
}
|
|
1129
|
+
return false;
|
|
974
1130
|
}
|
|
975
1131
|
|
|
976
|
-
function
|
|
977
|
-
|
|
1132
|
+
function extractError(error) {
|
|
1133
|
+
if (isObject$1(error)) {
|
|
1134
|
+
if (error.name && error.message && error.title) {
|
|
1135
|
+
return {
|
|
1136
|
+
title: error.title,
|
|
1137
|
+
message: error.message,
|
|
1138
|
+
detail: error.detail || null,
|
|
1139
|
+
data: error.data && error.data.data ? error.data.data : null
|
|
1140
|
+
};
|
|
1141
|
+
} else if (error.exception) {
|
|
1142
|
+
if (error.status === void 0 || error.status === 0 || error.data === void 0) {
|
|
1143
|
+
return new NetworksResponseError$1({
|
|
1144
|
+
title: error.title,
|
|
1145
|
+
status_code: error.status_code,
|
|
1146
|
+
exception: error.exception
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return {
|
|
1151
|
+
title: typeof error.title === "string" ? error.title : "Unexpected error",
|
|
1152
|
+
message: typeof error.message === "string" ? error.message : "Something went wrong."
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
978
1155
|
}
|
|
979
1156
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1157
|
+
var errors = /*#__PURE__*/Object.freeze({
|
|
1158
|
+
__proto__: null,
|
|
1159
|
+
AbortError: AbortError,
|
|
1160
|
+
InsufficientPermissionsError: InsufficientPermissionsError,
|
|
1161
|
+
NetworkError: NetworkError,
|
|
1162
|
+
NetworksResponseError: NetworksResponseError$1,
|
|
1163
|
+
NgwError: NgwError,
|
|
1164
|
+
ResourceNotFoundError: ResourceNotFoundError,
|
|
1165
|
+
extractError: extractError,
|
|
1166
|
+
isError: isError
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
var __defProp$K = Object.defineProperty;
|
|
1170
|
+
var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1171
|
+
var __publicField$t = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1172
|
+
class BaseAPIError extends Error {
|
|
1173
|
+
constructor(message) {
|
|
1174
|
+
super(message || "Something went wrong.");
|
|
1175
|
+
__publicField$t(this, "title");
|
|
1176
|
+
this.name = "BaseAPIError";
|
|
1177
|
+
this.title = "Unknown API error";
|
|
1178
|
+
if (Error.captureStackTrace) {
|
|
1179
|
+
Error.captureStackTrace(this, BaseAPIError);
|
|
996
1180
|
}
|
|
997
1181
|
}
|
|
998
|
-
|
|
1182
|
+
}
|
|
1183
|
+
class NetworksResponseError extends BaseAPIError {
|
|
1184
|
+
// prettier-ignore
|
|
1185
|
+
constructor(message) {
|
|
1186
|
+
super(message || "There is no response from the server or problem connecting to server.");
|
|
1187
|
+
__publicField$t(this, "detail");
|
|
1188
|
+
this.title = "Network error";
|
|
1189
|
+
this.detail = "Check network connectivity and try again later.";
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
class InvalidResponseError extends BaseAPIError {
|
|
1193
|
+
constructor(message) {
|
|
1194
|
+
super(message || "Something went wrong.");
|
|
1195
|
+
this.title = "Unexpected server response";
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
class ServerResponseError extends BaseAPIError {
|
|
1199
|
+
constructor(data) {
|
|
1200
|
+
super(data.message);
|
|
1201
|
+
__publicField$t(this, "detail");
|
|
1202
|
+
__publicField$t(this, "data");
|
|
1203
|
+
this.title = data.title || this.title;
|
|
1204
|
+
this.detail = data.detail || null;
|
|
1205
|
+
this.data = data;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
class LunkwillError extends Error {
|
|
1209
|
+
// prettier-ignore
|
|
1210
|
+
constructor(message, data = {}) {
|
|
1211
|
+
super(message || "Unexpected error while processing long-running request.");
|
|
1212
|
+
__publicField$t(this, "title");
|
|
1213
|
+
__publicField$t(this, "data");
|
|
1214
|
+
this.name = "LunkwillError";
|
|
1215
|
+
this.title = "Long-running request error";
|
|
1216
|
+
this.data = data;
|
|
1217
|
+
if (Error.captureStackTrace) {
|
|
1218
|
+
Error.captureStackTrace(this, LunkwillError);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
class LunkwillRequestCancelled extends LunkwillError {
|
|
1223
|
+
constructor(data) {
|
|
1224
|
+
super("Long-running request was cancelled.", data);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
class LunkwillRequestFailed extends LunkwillError {
|
|
1228
|
+
constructor(data) {
|
|
1229
|
+
super(void 0, data);
|
|
1230
|
+
}
|
|
999
1231
|
}
|
|
1000
1232
|
|
|
1001
|
-
var __defProp$
|
|
1002
|
-
var __getOwnPropSymbols$
|
|
1003
|
-
var __hasOwnProp$
|
|
1004
|
-
var __propIsEnum$
|
|
1005
|
-
var __defNormalProp$
|
|
1006
|
-
var __spreadValues$
|
|
1233
|
+
var __defProp$J = Object.defineProperty;
|
|
1234
|
+
var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
|
|
1235
|
+
var __hasOwnProp$y = Object.prototype.hasOwnProperty;
|
|
1236
|
+
var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
|
|
1237
|
+
var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1238
|
+
var __spreadValues$x = (a, b) => {
|
|
1007
1239
|
for (var prop in b || (b = {}))
|
|
1008
|
-
if (__hasOwnProp$
|
|
1009
|
-
__defNormalProp$
|
|
1010
|
-
if (__getOwnPropSymbols$
|
|
1011
|
-
for (var prop of __getOwnPropSymbols$
|
|
1012
|
-
if (__propIsEnum$
|
|
1013
|
-
__defNormalProp$
|
|
1240
|
+
if (__hasOwnProp$y.call(b, prop))
|
|
1241
|
+
__defNormalProp$J(a, prop, b[prop]);
|
|
1242
|
+
if (__getOwnPropSymbols$y)
|
|
1243
|
+
for (var prop of __getOwnPropSymbols$y(b)) {
|
|
1244
|
+
if (__propIsEnum$y.call(b, prop))
|
|
1245
|
+
__defNormalProp$J(a, prop, b[prop]);
|
|
1014
1246
|
}
|
|
1015
1247
|
return a;
|
|
1016
1248
|
};
|
|
1017
|
-
var
|
|
1018
|
-
var
|
|
1249
|
+
var __objRest$5 = (source, exclude) => {
|
|
1250
|
+
var target = {};
|
|
1251
|
+
for (var prop in source)
|
|
1252
|
+
if (__hasOwnProp$y.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1253
|
+
target[prop] = source[prop];
|
|
1254
|
+
if (source != null && __getOwnPropSymbols$y)
|
|
1255
|
+
for (var prop of __getOwnPropSymbols$y(source)) {
|
|
1256
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$y.call(source, prop))
|
|
1257
|
+
target[prop] = source[prop];
|
|
1258
|
+
}
|
|
1259
|
+
return target;
|
|
1260
|
+
};
|
|
1261
|
+
var __async$v = (__this, __arguments, generator) => {
|
|
1019
1262
|
return new Promise((resolve, reject) => {
|
|
1020
1263
|
var fulfilled = (value) => {
|
|
1021
1264
|
try {
|
|
@@ -1035,123 +1278,967 @@ var __async$s = (__this, __arguments, generator) => {
|
|
|
1035
1278
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
1036
1279
|
});
|
|
1037
1280
|
};
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1281
|
+
function lunkwillCheckResponse(lwResp) {
|
|
1282
|
+
const ct = lwResp.headers.get("content-type");
|
|
1283
|
+
return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
|
|
1284
|
+
}
|
|
1285
|
+
function responseJson(response) {
|
|
1286
|
+
return __async$v(this, null, function* () {
|
|
1287
|
+
try {
|
|
1288
|
+
return response.json();
|
|
1289
|
+
} catch (e) {
|
|
1290
|
+
throw new Error();
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
function lunkwillResponseUrl(lwResp) {
|
|
1295
|
+
return __async$v(this, null, function* () {
|
|
1296
|
+
const lwData = yield responseJson(lwResp);
|
|
1297
|
+
let delay = lwData.delay_ms;
|
|
1298
|
+
const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
|
|
1299
|
+
const sum = `/api/lunkwill/${lwData.id}/summary`;
|
|
1300
|
+
const res = `/api/lunkwill/${lwData.id}/response`;
|
|
1301
|
+
const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
|
|
1302
|
+
let failed = false;
|
|
1303
|
+
let ready = false;
|
|
1304
|
+
while (!ready) {
|
|
1305
|
+
yield sleep(failed ? retry : delay);
|
|
1306
|
+
failed = false;
|
|
1307
|
+
let lwResp2;
|
|
1308
|
+
let lwData2;
|
|
1309
|
+
try {
|
|
1310
|
+
lwResp2 = yield fetch(sum, { credentials: "same-origin" });
|
|
1311
|
+
lwData2 = yield lwResp2.json();
|
|
1312
|
+
} catch (e) {
|
|
1313
|
+
failed = true;
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
switch (lwData2.status) {
|
|
1317
|
+
case void 0:
|
|
1318
|
+
throw new LunkwillError(void 0, lwData2);
|
|
1319
|
+
case "ready":
|
|
1320
|
+
ready = true;
|
|
1321
|
+
break;
|
|
1322
|
+
case "cancelled":
|
|
1323
|
+
throw new LunkwillRequestCancelled(lwData2);
|
|
1324
|
+
case "failed":
|
|
1325
|
+
throw new LunkwillRequestFailed(lwData2);
|
|
1326
|
+
case "spooled":
|
|
1327
|
+
case "processing":
|
|
1328
|
+
case "buffering":
|
|
1329
|
+
delay = lwData2.delay_ms;
|
|
1330
|
+
break;
|
|
1331
|
+
default:
|
|
1332
|
+
throw new LunkwillError(void 0, lwData2);
|
|
1070
1333
|
}
|
|
1071
1334
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1335
|
+
return res;
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function lunkwillFetch(lwRespUrl) {
|
|
1339
|
+
return __async$v(this, null, function* () {
|
|
1340
|
+
try {
|
|
1341
|
+
return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
|
|
1342
|
+
} catch (e) {
|
|
1343
|
+
throw new NetworksResponseError();
|
|
1078
1344
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
if (
|
|
1105
|
-
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
const mediaContentTypes = [
|
|
1348
|
+
"application/pdf",
|
|
1349
|
+
"image/png",
|
|
1350
|
+
"image/jpeg",
|
|
1351
|
+
"image/tiff",
|
|
1352
|
+
"text/csv"
|
|
1353
|
+
];
|
|
1354
|
+
const mediaContentTypesRegex = new RegExp(mediaContentTypes.join("|"));
|
|
1355
|
+
function isMediaContentType(contentType) {
|
|
1356
|
+
return mediaContentTypesRegex.test(contentType);
|
|
1357
|
+
}
|
|
1358
|
+
function encodeQueryParams(value) {
|
|
1359
|
+
const result = [];
|
|
1360
|
+
for (const [k, v] of Object.entries(value)) {
|
|
1361
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
1362
|
+
result.push(`${k}=${encodeURIComponent(v)}`);
|
|
1363
|
+
} else if (Array.isArray(v)) {
|
|
1364
|
+
result.push(`${k}=${v.map(encodeURIComponent).join(",")}`);
|
|
1365
|
+
} else {
|
|
1366
|
+
for (const [sk, sv] of Object.entries(v)) {
|
|
1367
|
+
const ske = `${k}[${encodeURIComponent(sk)}]`;
|
|
1368
|
+
if (typeof sv === "string" || typeof sv === "number" || typeof sv === "boolean") {
|
|
1369
|
+
result.push(`${ske}=${encodeURIComponent(sv)}`);
|
|
1370
|
+
} else if (Array.isArray(sv)) {
|
|
1371
|
+
const sve = sv.map(encodeURIComponent);
|
|
1372
|
+
result.push(`${ske}=${sve.join(",")}`);
|
|
1106
1373
|
}
|
|
1107
|
-
}
|
|
1374
|
+
}
|
|
1108
1375
|
}
|
|
1109
|
-
return Promise.resolve(void 0);
|
|
1110
1376
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
* To not make one more checks if the resource is definitely exists
|
|
1118
|
-
*/
|
|
1119
|
-
getIdOrFail(resource, requestOptions) {
|
|
1120
|
-
return this.getId(resource, requestOptions).then((resp) => {
|
|
1121
|
-
if (resp === void 0) {
|
|
1122
|
-
throw new Error();
|
|
1123
|
-
}
|
|
1124
|
-
return resp;
|
|
1125
|
-
});
|
|
1377
|
+
return result.join("&");
|
|
1378
|
+
}
|
|
1379
|
+
function generateUrl(path, query) {
|
|
1380
|
+
let urlParams = "";
|
|
1381
|
+
if (query !== void 0) {
|
|
1382
|
+
urlParams = "?" + encodeQueryParams(query);
|
|
1126
1383
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1384
|
+
return path + urlParams;
|
|
1385
|
+
}
|
|
1386
|
+
function request(path, options, cacheEngine) {
|
|
1387
|
+
return __async$v(this, null, function* () {
|
|
1388
|
+
var _b;
|
|
1389
|
+
const defaults = {
|
|
1390
|
+
method: "GET",
|
|
1391
|
+
credentials: "same-origin",
|
|
1392
|
+
headers: {}
|
|
1393
|
+
};
|
|
1394
|
+
const _a = __spreadValues$x(__spreadValues$x({}, defaults), options), {
|
|
1395
|
+
withCredentials,
|
|
1396
|
+
responseType,
|
|
1397
|
+
cacheProps,
|
|
1398
|
+
cacheName,
|
|
1399
|
+
lunkwill,
|
|
1400
|
+
cache,
|
|
1401
|
+
query,
|
|
1402
|
+
json
|
|
1403
|
+
} = _a, opt = __objRest$5(_a, [
|
|
1404
|
+
"withCredentials",
|
|
1405
|
+
"responseType",
|
|
1406
|
+
"cacheProps",
|
|
1407
|
+
"cacheName",
|
|
1408
|
+
"lunkwill",
|
|
1409
|
+
"cache",
|
|
1410
|
+
"query",
|
|
1411
|
+
"json"
|
|
1412
|
+
]);
|
|
1413
|
+
if (withCredentials) {
|
|
1414
|
+
opt.credentials = "include";
|
|
1415
|
+
}
|
|
1416
|
+
let useLunkwill = false;
|
|
1417
|
+
if (lunkwill !== void 0) {
|
|
1418
|
+
lunkwill.toHeaders(opt.headers || {});
|
|
1419
|
+
useLunkwill = true;
|
|
1420
|
+
}
|
|
1421
|
+
const lunkwillReturnUrl = !!opt.lunkwillReturnUrl;
|
|
1422
|
+
delete opt.lunkwillReturnUrl;
|
|
1423
|
+
if (json !== void 0) {
|
|
1424
|
+
opt.body = JSON.stringify(json);
|
|
1425
|
+
const headers = opt.headers || {};
|
|
1426
|
+
headers["Content-Type"] = "application/json";
|
|
1427
|
+
opt.headers = headers;
|
|
1428
|
+
}
|
|
1429
|
+
const url = generateUrl(path, query);
|
|
1430
|
+
const makeRequest = () => __async$v(this, null, function* () {
|
|
1431
|
+
let response;
|
|
1432
|
+
try {
|
|
1433
|
+
response = yield fetch(url, opt);
|
|
1434
|
+
} catch (e) {
|
|
1435
|
+
if (opt.signal && opt.signal.aborted) {
|
|
1436
|
+
throw e;
|
|
1135
1437
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1438
|
+
throw new NetworksResponseError();
|
|
1439
|
+
}
|
|
1440
|
+
if (useLunkwill && lunkwillCheckResponse(response)) {
|
|
1441
|
+
const lwRespUrl = yield lunkwillResponseUrl(response);
|
|
1442
|
+
if (lunkwillReturnUrl) {
|
|
1443
|
+
return lwRespUrl;
|
|
1444
|
+
}
|
|
1445
|
+
response = yield lunkwillFetch(lwRespUrl);
|
|
1446
|
+
}
|
|
1447
|
+
const respCType = response.headers.get("content-type");
|
|
1448
|
+
const respJSON = respCType && (respCType.includes("application/json") || respCType.includes("application/vnd.lunkwill.request-summary+json"));
|
|
1449
|
+
let body;
|
|
1450
|
+
try {
|
|
1451
|
+
const respMedia = respCType && isMediaContentType(respCType);
|
|
1452
|
+
if (responseType === "blob" || respMedia) {
|
|
1453
|
+
body = yield response.blob();
|
|
1454
|
+
} else if (respJSON) {
|
|
1455
|
+
body = yield response.json();
|
|
1456
|
+
} else {
|
|
1457
|
+
throw new InvalidResponseError();
|
|
1458
|
+
}
|
|
1459
|
+
} catch (e) {
|
|
1460
|
+
if (e.name === "AbortError" || e instanceof InvalidResponseError) {
|
|
1461
|
+
throw e;
|
|
1462
|
+
}
|
|
1463
|
+
throw new InvalidResponseError();
|
|
1464
|
+
}
|
|
1465
|
+
if (400 <= response.status && response.status <= 599) {
|
|
1466
|
+
throw new ServerResponseError(body);
|
|
1467
|
+
}
|
|
1468
|
+
return body;
|
|
1469
|
+
});
|
|
1470
|
+
if (cacheEngine && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
|
|
1471
|
+
const props = cacheProps ? cacheProps : __spreadValues$x({}, objectRemoveEmpty({
|
|
1472
|
+
withCredentials,
|
|
1473
|
+
responseType
|
|
1474
|
+
}));
|
|
1475
|
+
return cacheEngine.add(cacheName || url, makeRequest, {
|
|
1476
|
+
props,
|
|
1477
|
+
expirationTime: cache ? void 0 : 500
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
return makeRequest();
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
var __defProp$I = Object.defineProperty;
|
|
1485
|
+
var __defProps$i = Object.defineProperties;
|
|
1486
|
+
var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
|
|
1487
|
+
var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
|
|
1488
|
+
var __hasOwnProp$x = Object.prototype.hasOwnProperty;
|
|
1489
|
+
var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
|
|
1490
|
+
var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1491
|
+
var __spreadValues$w = (a, b) => {
|
|
1492
|
+
for (var prop in b || (b = {}))
|
|
1493
|
+
if (__hasOwnProp$x.call(b, prop))
|
|
1494
|
+
__defNormalProp$I(a, prop, b[prop]);
|
|
1495
|
+
if (__getOwnPropSymbols$x)
|
|
1496
|
+
for (var prop of __getOwnPropSymbols$x(b)) {
|
|
1497
|
+
if (__propIsEnum$x.call(b, prop))
|
|
1498
|
+
__defNormalProp$I(a, prop, b[prop]);
|
|
1499
|
+
}
|
|
1500
|
+
return a;
|
|
1501
|
+
};
|
|
1502
|
+
var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
|
|
1503
|
+
var __objRest$4 = (source, exclude) => {
|
|
1504
|
+
var target = {};
|
|
1505
|
+
for (var prop in source)
|
|
1506
|
+
if (__hasOwnProp$x.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1507
|
+
target[prop] = source[prop];
|
|
1508
|
+
if (source != null && __getOwnPropSymbols$x)
|
|
1509
|
+
for (var prop of __getOwnPropSymbols$x(source)) {
|
|
1510
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$x.call(source, prop))
|
|
1511
|
+
target[prop] = source[prop];
|
|
1512
|
+
}
|
|
1513
|
+
return target;
|
|
1514
|
+
};
|
|
1515
|
+
var __async$u = (__this, __arguments, generator) => {
|
|
1516
|
+
return new Promise((resolve, reject) => {
|
|
1517
|
+
var fulfilled = (value) => {
|
|
1518
|
+
try {
|
|
1519
|
+
step(generator.next(value));
|
|
1520
|
+
} catch (e) {
|
|
1521
|
+
reject(e);
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
var rejected = (value) => {
|
|
1525
|
+
try {
|
|
1526
|
+
step(generator.throw(value));
|
|
1527
|
+
} catch (e) {
|
|
1528
|
+
reject(e);
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1532
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1533
|
+
});
|
|
1534
|
+
};
|
|
1535
|
+
function routeURL(name, baseUrl, routeData, ...rest) {
|
|
1536
|
+
const [template, ...params] = routeData[name];
|
|
1537
|
+
const first = rest[0];
|
|
1538
|
+
let sub;
|
|
1539
|
+
if (first === void 0) {
|
|
1540
|
+
sub = [];
|
|
1541
|
+
} else if (typeof first === "object" && first !== null) {
|
|
1542
|
+
if (rest.length > 1) {
|
|
1543
|
+
throw new Error("Too many arguments for route(name, object)!");
|
|
1544
|
+
}
|
|
1545
|
+
sub = [];
|
|
1546
|
+
for (const [p, v] of Object.entries(first)) {
|
|
1547
|
+
sub[params.indexOf(p)] = String(v);
|
|
1548
|
+
}
|
|
1549
|
+
} else {
|
|
1550
|
+
sub = rest.map((v) => String(v));
|
|
1551
|
+
}
|
|
1552
|
+
return fixUrlStr(
|
|
1553
|
+
baseUrl + template.replace(/\{(\w+)\}/g, function(m, a) {
|
|
1554
|
+
const idx = parseInt(a);
|
|
1555
|
+
const value = sub[idx];
|
|
1556
|
+
if (value === void 0) {
|
|
1557
|
+
const msg = `Undefined parameter ${idx} in "${template}".`;
|
|
1558
|
+
throw new Error(msg);
|
|
1559
|
+
}
|
|
1560
|
+
return String(value);
|
|
1561
|
+
})
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
function route(name, connector, ...rest) {
|
|
1565
|
+
const result = {
|
|
1566
|
+
url: (opt) => __async$u(this, null, function* () {
|
|
1567
|
+
var _a;
|
|
1568
|
+
const routeData = yield connector.connect();
|
|
1569
|
+
const template = routeURL(
|
|
1570
|
+
name,
|
|
1571
|
+
(_a = connector.options.baseUrl) != null ? _a : "",
|
|
1572
|
+
routeData,
|
|
1573
|
+
...rest
|
|
1574
|
+
);
|
|
1575
|
+
return generateUrl(template, opt == null ? void 0 : opt.query);
|
|
1576
|
+
})
|
|
1577
|
+
};
|
|
1578
|
+
const methods = ["get", "post", "put", "delete", "patch"];
|
|
1579
|
+
for (const method of methods) {
|
|
1580
|
+
const methodResp = (requestOptions) => __async$u(this, null, function* () {
|
|
1581
|
+
var _b;
|
|
1582
|
+
const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$4(_a, ["headers"]);
|
|
1583
|
+
const routeData = yield connector.connect();
|
|
1584
|
+
const template = routeURL(
|
|
1585
|
+
name,
|
|
1586
|
+
(_b = connector.options.baseUrl) != null ? _b : "",
|
|
1587
|
+
routeData,
|
|
1588
|
+
...rest
|
|
1589
|
+
);
|
|
1590
|
+
const headers = objectRemoveEmpty(__spreadValues$w(__spreadValues$w({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
|
|
1591
|
+
return request(
|
|
1592
|
+
template,
|
|
1593
|
+
__spreadProps$i(__spreadValues$w({
|
|
1594
|
+
headers
|
|
1595
|
+
}, restOpt), {
|
|
1596
|
+
method
|
|
1597
|
+
}),
|
|
1598
|
+
connector.cache
|
|
1599
|
+
);
|
|
1600
|
+
});
|
|
1601
|
+
result[method] = methodResp;
|
|
1602
|
+
}
|
|
1603
|
+
return result;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function isObject(val) {
|
|
1607
|
+
return Object.prototype.toString.call(val) === "[object Object]";
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
let loadData;
|
|
1611
|
+
{
|
|
1612
|
+
loadData = (url, callback, options = {}, error, onCancel) => {
|
|
1613
|
+
options.method = options.method || "GET";
|
|
1614
|
+
const xhr = new XMLHttpRequest();
|
|
1615
|
+
xhr.open(options.method || "GET", url, true);
|
|
1616
|
+
if (options.responseType === "blob") {
|
|
1617
|
+
xhr.responseType = options.responseType;
|
|
1618
|
+
}
|
|
1619
|
+
const getResponseText = () => {
|
|
1620
|
+
try {
|
|
1621
|
+
return JSON.parse(xhr.responseText);
|
|
1622
|
+
} catch (er) {
|
|
1623
|
+
return xhr.responseText;
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
const processingResponse = (forError = false) => {
|
|
1627
|
+
const cb = forError ? error : callback;
|
|
1628
|
+
if (options.responseType === "blob") {
|
|
1629
|
+
cb(xhr.response);
|
|
1630
|
+
} else {
|
|
1631
|
+
if (xhr.responseText) {
|
|
1632
|
+
cb(getResponseText());
|
|
1633
|
+
} else {
|
|
1634
|
+
error({ message: "" });
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
xhr.onload = () => {
|
|
1639
|
+
if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
|
|
1640
|
+
error(new NgwError(getResponseText()));
|
|
1641
|
+
}
|
|
1642
|
+
processingResponse();
|
|
1643
|
+
};
|
|
1644
|
+
xhr.onerror = (er) => {
|
|
1645
|
+
if (xhr.status === 0) {
|
|
1646
|
+
error(new NetworkError(url));
|
|
1647
|
+
} else {
|
|
1648
|
+
error(er);
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
xhr.upload.onprogress = function(e) {
|
|
1652
|
+
if (e.lengthComputable) {
|
|
1653
|
+
const percentComplete = e.loaded / e.total * 100;
|
|
1654
|
+
if (options.onProgress) {
|
|
1655
|
+
options.onProgress(percentComplete, e);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
const headers = options.headers;
|
|
1660
|
+
if (headers) {
|
|
1661
|
+
for (const h in headers) {
|
|
1662
|
+
const header = headers[h];
|
|
1663
|
+
if (typeof header === "string") {
|
|
1664
|
+
xhr.setRequestHeader(h, header);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
if (options.withCredentials !== void 0) {
|
|
1669
|
+
xhr.withCredentials = options.withCredentials;
|
|
1670
|
+
}
|
|
1671
|
+
let data;
|
|
1672
|
+
if (options.file) {
|
|
1673
|
+
data = new FormData();
|
|
1674
|
+
data.append("file", options.file);
|
|
1675
|
+
if (options.data) {
|
|
1676
|
+
for (const d in options.data) {
|
|
1677
|
+
data.append(d, data[d]);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
} else {
|
|
1681
|
+
data = options.data ? typeof options.data === "string" ? options.data : JSON.stringify(options.data) : null;
|
|
1682
|
+
}
|
|
1683
|
+
if (onCancel) {
|
|
1684
|
+
onCancel(() => {
|
|
1685
|
+
xhr.abort();
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
xhr.send(data);
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
const templateRe = /\{ *([\w_-]+) *\}/g;
|
|
1693
|
+
function template(str, data) {
|
|
1694
|
+
return str.replace(templateRe, (s, key) => {
|
|
1695
|
+
let value = data[key];
|
|
1696
|
+
if (value === void 0) {
|
|
1697
|
+
throw new Error("No value provided for letiable " + s);
|
|
1698
|
+
} else if (typeof value === "function") {
|
|
1699
|
+
value = value(data);
|
|
1700
|
+
}
|
|
1701
|
+
return value;
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
var __defProp$H = Object.defineProperty;
|
|
1706
|
+
var __defProps$h = Object.defineProperties;
|
|
1707
|
+
var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
|
|
1708
|
+
var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
|
|
1709
|
+
var __hasOwnProp$w = Object.prototype.hasOwnProperty;
|
|
1710
|
+
var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
|
|
1711
|
+
var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1712
|
+
var __spreadValues$v = (a, b) => {
|
|
1713
|
+
for (var prop in b || (b = {}))
|
|
1714
|
+
if (__hasOwnProp$w.call(b, prop))
|
|
1715
|
+
__defNormalProp$H(a, prop, b[prop]);
|
|
1716
|
+
if (__getOwnPropSymbols$w)
|
|
1717
|
+
for (var prop of __getOwnPropSymbols$w(b)) {
|
|
1718
|
+
if (__propIsEnum$w.call(b, prop))
|
|
1719
|
+
__defNormalProp$H(a, prop, b[prop]);
|
|
1720
|
+
}
|
|
1721
|
+
return a;
|
|
1722
|
+
};
|
|
1723
|
+
var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
|
|
1724
|
+
var __objRest$3 = (source, exclude) => {
|
|
1725
|
+
var target = {};
|
|
1726
|
+
for (var prop in source)
|
|
1727
|
+
if (__hasOwnProp$w.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1728
|
+
target[prop] = source[prop];
|
|
1729
|
+
if (source != null && __getOwnPropSymbols$w)
|
|
1730
|
+
for (var prop of __getOwnPropSymbols$w(source)) {
|
|
1731
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$w.call(source, prop))
|
|
1732
|
+
target[prop] = source[prop];
|
|
1733
|
+
}
|
|
1734
|
+
return target;
|
|
1735
|
+
};
|
|
1736
|
+
var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1737
|
+
var __async$t = (__this, __arguments, generator) => {
|
|
1738
|
+
return new Promise((resolve, reject) => {
|
|
1739
|
+
var fulfilled = (value) => {
|
|
1740
|
+
try {
|
|
1741
|
+
step(generator.next(value));
|
|
1742
|
+
} catch (e) {
|
|
1743
|
+
reject(e);
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
var rejected = (value) => {
|
|
1747
|
+
try {
|
|
1748
|
+
step(generator.throw(value));
|
|
1749
|
+
} catch (e) {
|
|
1750
|
+
reject(e);
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1754
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1755
|
+
});
|
|
1756
|
+
};
|
|
1757
|
+
let ID$2 = 0;
|
|
1758
|
+
let REQUEST_ID = 0;
|
|
1759
|
+
class NgwConnector {
|
|
1760
|
+
constructor(options) {
|
|
1761
|
+
this.options = options;
|
|
1762
|
+
__publicField$s(this, "id", ID$2++);
|
|
1763
|
+
__publicField$s(this, "emitter", new EventEmitter());
|
|
1764
|
+
__publicField$s(this, "user");
|
|
1765
|
+
__publicField$s(this, "cache");
|
|
1766
|
+
__publicField$s(this, "withCredentials");
|
|
1767
|
+
__publicField$s(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
|
|
1768
|
+
__publicField$s(this, "routeStr", "/api/component/pyramid/route");
|
|
1769
|
+
__publicField$s(this, "activeRequests", {});
|
|
1770
|
+
__publicField$s(this, "requestTransform");
|
|
1771
|
+
const exist = findConnector(options);
|
|
1772
|
+
this.cache = new Cache({ namespace: options.cacheId });
|
|
1773
|
+
if (exist) {
|
|
1774
|
+
return exist;
|
|
1775
|
+
} else {
|
|
1776
|
+
const { route: route2, requestTransform, withCredentials } = this.options;
|
|
1777
|
+
if (route2) {
|
|
1778
|
+
this.routeStr = route2;
|
|
1779
|
+
}
|
|
1780
|
+
if (requestTransform) {
|
|
1781
|
+
this.requestTransform = requestTransform;
|
|
1782
|
+
}
|
|
1783
|
+
if (withCredentials !== void 0) {
|
|
1784
|
+
this.withCredentials = withCredentials;
|
|
1785
|
+
}
|
|
1786
|
+
addConnector(this);
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Clear the cache.
|
|
1791
|
+
*/
|
|
1792
|
+
clearCache() {
|
|
1793
|
+
this.cache.clean();
|
|
1794
|
+
}
|
|
1795
|
+
setRequestTransform(requestTransform) {
|
|
1796
|
+
this.requestTransform = requestTransform;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Fast way to specify the connection address to NextGIS Web.
|
|
1800
|
+
* The current connection will be severed.
|
|
1801
|
+
* @param baseUrl - NGW url
|
|
1802
|
+
*/
|
|
1803
|
+
setNgw(baseUrl) {
|
|
1804
|
+
this.logout();
|
|
1805
|
+
this.options.baseUrl = baseUrl;
|
|
1806
|
+
addConnector(this);
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Establishing a connection with NextGIS Web to fulfill all other requests.
|
|
1810
|
+
* @remarks
|
|
1811
|
+
* This method need not be called manually as it is used when forming a request in {@link apiRequest | apiRequest}.
|
|
1812
|
+
* Can be used to check connection.
|
|
1813
|
+
* @example
|
|
1814
|
+
* ```javascript
|
|
1815
|
+
* const connector = new NgwConnector({ baseUrl: 'https://demo.nextgis.com' });
|
|
1816
|
+
* connector.connect()
|
|
1817
|
+
* .then(() => console.log('Ok'))
|
|
1818
|
+
* .catch((er) => console.log('Connection problem', er));
|
|
1819
|
+
* ```
|
|
1820
|
+
*/
|
|
1821
|
+
connect() {
|
|
1822
|
+
return __async$t(this, null, function* () {
|
|
1823
|
+
const auth = this.options.auth;
|
|
1824
|
+
if (auth) {
|
|
1825
|
+
const { login, password } = auth;
|
|
1826
|
+
if (login && password) {
|
|
1827
|
+
yield this._login({ login, password });
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
const routeUrl = `${this.routeStr}?client=${this.client}`;
|
|
1831
|
+
return yield this.makeQuery(
|
|
1832
|
+
routeUrl,
|
|
1833
|
+
{},
|
|
1834
|
+
{
|
|
1835
|
+
cacheName: "route",
|
|
1836
|
+
cache: true,
|
|
1837
|
+
cacheProps: {
|
|
1838
|
+
id: this.id,
|
|
1839
|
+
auth,
|
|
1840
|
+
baseUrl: this.options.baseUrl
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
);
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Quick way to change NextGIS Web user.
|
|
1848
|
+
* @param credentials - New user credentials
|
|
1849
|
+
*/
|
|
1850
|
+
login(credentials, options) {
|
|
1851
|
+
this.logout();
|
|
1852
|
+
addConnector(this);
|
|
1853
|
+
return this._login(credentials, options);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Disconnecting a user. Aborting all current requests
|
|
1857
|
+
*/
|
|
1858
|
+
logout() {
|
|
1859
|
+
this.abort();
|
|
1860
|
+
removeConnector(this);
|
|
1861
|
+
this.options.auth = void 0;
|
|
1862
|
+
this.user = void 0;
|
|
1863
|
+
this.clearCache();
|
|
1864
|
+
this.emitter.emit("logout");
|
|
1865
|
+
}
|
|
1866
|
+
getUserInfo(credentials, options) {
|
|
1867
|
+
return __async$t(this, null, function* () {
|
|
1868
|
+
if (this.user && this.user.id) {
|
|
1869
|
+
return this.user;
|
|
1870
|
+
}
|
|
1871
|
+
if (credentials) {
|
|
1872
|
+
this.options.auth = credentials;
|
|
1873
|
+
}
|
|
1874
|
+
const options_ = __spreadValues$v({
|
|
1875
|
+
headers: this.getAuthorizationHeaders(credentials),
|
|
1876
|
+
cache: true
|
|
1877
|
+
}, options);
|
|
1878
|
+
return this.makeQuery(
|
|
1879
|
+
"/api/component/auth/current_user",
|
|
1880
|
+
{},
|
|
1881
|
+
options_
|
|
1882
|
+
);
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
1887
|
+
*/
|
|
1888
|
+
getAuthorizationHeaders(credentials) {
|
|
1889
|
+
const client = this.makeClientId(credentials);
|
|
1890
|
+
if (client) {
|
|
1891
|
+
return {
|
|
1892
|
+
Authorization: `Basic ${client}`
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
return {};
|
|
1896
|
+
}
|
|
1897
|
+
makeClientId(credentials) {
|
|
1898
|
+
credentials = credentials || this.options.auth;
|
|
1899
|
+
if (credentials) {
|
|
1900
|
+
const { login, password } = credentials;
|
|
1901
|
+
const encodedStr = [login, password].map(encodeURIComponent).join(":");
|
|
1902
|
+
{
|
|
1903
|
+
return window.btoa(encodedStr);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
/** Stop all api requests */
|
|
1908
|
+
abort() {
|
|
1909
|
+
for (const abortController of Object.values(this.activeRequests)) {
|
|
1910
|
+
abortController.abort();
|
|
1911
|
+
}
|
|
1912
|
+
this.activeRequests = {};
|
|
1913
|
+
}
|
|
1914
|
+
getActiveApiRequests() {
|
|
1915
|
+
return __spreadValues$v({}, this.activeRequests);
|
|
1916
|
+
}
|
|
1917
|
+
route(name, ...rest) {
|
|
1918
|
+
return route(name, this, ...rest);
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Send request to NGW.
|
|
1922
|
+
* @param url - URL address to NGW
|
|
1923
|
+
* @param params - Query params
|
|
1924
|
+
* @param options - Request options
|
|
1925
|
+
*/
|
|
1926
|
+
makeQuery(_0, _1) {
|
|
1927
|
+
return __async$t(this, arguments, function* (url, params, options = {}) {
|
|
1928
|
+
var _b;
|
|
1929
|
+
url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
|
|
1930
|
+
if (!url) {
|
|
1931
|
+
throw new Error("Empty `url` not allowed");
|
|
1932
|
+
}
|
|
1933
|
+
if (params) {
|
|
1934
|
+
const _a = params, restParams = __objRest$3(_a, ["paramList"]);
|
|
1935
|
+
url = template(url, restParams);
|
|
1936
|
+
}
|
|
1937
|
+
url = encodeURI(fixUrlStr(url));
|
|
1938
|
+
options = __spreadValues$v({ withCredentials: this.withCredentials }, options);
|
|
1939
|
+
const {
|
|
1940
|
+
cache,
|
|
1941
|
+
signal: externalSignal,
|
|
1942
|
+
method = "GET",
|
|
1943
|
+
headers,
|
|
1944
|
+
cacheName,
|
|
1945
|
+
cacheProps,
|
|
1946
|
+
responseType,
|
|
1947
|
+
withCredentials
|
|
1948
|
+
} = options;
|
|
1949
|
+
const internalAbortController = new AbortController();
|
|
1950
|
+
const internalSignal = internalAbortController.signal;
|
|
1951
|
+
if (externalSignal) {
|
|
1952
|
+
if (externalSignal.aborted) {
|
|
1953
|
+
throw new AbortError();
|
|
1954
|
+
}
|
|
1955
|
+
externalSignal.addEventListener("abort", () => {
|
|
1956
|
+
internalAbortController.abort();
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
options.signal = internalSignal;
|
|
1960
|
+
const createPromise = () => __async$t(this, null, function* () {
|
|
1961
|
+
const id = REQUEST_ID++;
|
|
1962
|
+
this.activeRequests[id] = internalAbortController;
|
|
1963
|
+
try {
|
|
1964
|
+
return this._loadData(url, options);
|
|
1965
|
+
} finally {
|
|
1966
|
+
this._cleanActiveRequest(id);
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
if (method === "GET") {
|
|
1970
|
+
const cacheOptions = cacheProps ? cacheProps : __spreadProps$h(__spreadValues$v({}, objectRemoveEmpty({
|
|
1971
|
+
headers,
|
|
1972
|
+
withCredentials,
|
|
1973
|
+
responseType,
|
|
1974
|
+
baseUrl: this.options.baseUrl,
|
|
1975
|
+
userId: (_b = this.user) == null ? void 0 : _b.id
|
|
1976
|
+
})), {
|
|
1977
|
+
params
|
|
1978
|
+
});
|
|
1979
|
+
return this.cache.add(cacheName || url, createPromise, {
|
|
1980
|
+
props: cacheOptions,
|
|
1981
|
+
expirationTime: cache ? void 0 : 500
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
return createPromise();
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
_loadData(url, options) {
|
|
1988
|
+
options.responseType = options.responseType || "json";
|
|
1989
|
+
return new Promise((resolve, reject) => {
|
|
1990
|
+
var _a;
|
|
1991
|
+
if (this.user) {
|
|
1992
|
+
options = options || {};
|
|
1993
|
+
options.headers = __spreadValues$v(__spreadValues$v({}, this.getAuthorizationHeaders()), options.headers);
|
|
1994
|
+
}
|
|
1995
|
+
if (this.requestTransform) {
|
|
1996
|
+
const [transUrl, transOptions] = this.requestTransform(url, options);
|
|
1997
|
+
url = transUrl;
|
|
1998
|
+
options = transOptions;
|
|
1999
|
+
}
|
|
2000
|
+
let runOnAbort = void 0;
|
|
2001
|
+
loadData(url, resolve, options, reject, (handler) => {
|
|
2002
|
+
runOnAbort = handler;
|
|
2003
|
+
});
|
|
2004
|
+
(_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
|
|
2005
|
+
if (runOnAbort !== void 0) {
|
|
2006
|
+
runOnAbort();
|
|
2007
|
+
}
|
|
2008
|
+
reject(new AbortError());
|
|
2009
|
+
});
|
|
2010
|
+
}).catch((httpError) => {
|
|
2011
|
+
if (httpError.name !== "AbortError") {
|
|
2012
|
+
{
|
|
2013
|
+
console.warn("DEV WARN", httpError);
|
|
2014
|
+
}
|
|
2015
|
+
const er = this._handleHttpError(httpError);
|
|
2016
|
+
if (er) {
|
|
2017
|
+
throw er;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
throw httpError;
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
_login(credentials, options) {
|
|
2024
|
+
return __async$t(this, null, function* () {
|
|
2025
|
+
try {
|
|
2026
|
+
const data = yield this.getUserInfo(credentials, options);
|
|
2027
|
+
this.user = data;
|
|
2028
|
+
this.emitter.emit("login", data);
|
|
2029
|
+
return data;
|
|
2030
|
+
} catch (er) {
|
|
2031
|
+
this.emitter.emit("login:error", er);
|
|
2032
|
+
throw er;
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
_cleanActiveRequest(requestId) {
|
|
2037
|
+
delete this.activeRequests[requestId];
|
|
2038
|
+
}
|
|
2039
|
+
_handleHttpError(er) {
|
|
2040
|
+
if (er) {
|
|
2041
|
+
if (er instanceof NgwError) {
|
|
2042
|
+
if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
|
|
2043
|
+
throw new ResourceNotFoundError(er);
|
|
2044
|
+
} else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
|
|
2045
|
+
throw new InsufficientPermissionsError(er);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
return er;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
__publicField$s(NgwConnector, "errors", errors);
|
|
2053
|
+
|
|
2054
|
+
function resourceCompare(res1, res2) {
|
|
2055
|
+
return objectDeepEqual(res1, res2);
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
const exclude = ["description"];
|
|
2059
|
+
function resourceToQuery(resource, prefix = "") {
|
|
2060
|
+
prefix = prefix ? prefix + "__" : "";
|
|
2061
|
+
const query = {};
|
|
2062
|
+
for (const [key, value] of Object.entries(resource)) {
|
|
2063
|
+
if (exclude.indexOf(key) === -1) {
|
|
2064
|
+
if (isObject(value)) {
|
|
2065
|
+
if (key === "owner_user") {
|
|
2066
|
+
const children = resourceToQuery(
|
|
2067
|
+
value,
|
|
2068
|
+
key
|
|
2069
|
+
);
|
|
2070
|
+
Object.assign(query, children);
|
|
2071
|
+
} else if (key === "parent" && "id" in value) {
|
|
2072
|
+
query.parent_id = value.id;
|
|
2073
|
+
}
|
|
2074
|
+
} else if (defined(value)) {
|
|
2075
|
+
query[prefix + key] = value;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
return query;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
var __defProp$G = Object.defineProperty;
|
|
2083
|
+
var __defProps$g = Object.defineProperties;
|
|
2084
|
+
var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
|
|
2085
|
+
var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
|
|
2086
|
+
var __hasOwnProp$v = Object.prototype.hasOwnProperty;
|
|
2087
|
+
var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
|
|
2088
|
+
var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2089
|
+
var __spreadValues$u = (a, b) => {
|
|
2090
|
+
for (var prop in b || (b = {}))
|
|
2091
|
+
if (__hasOwnProp$v.call(b, prop))
|
|
2092
|
+
__defNormalProp$G(a, prop, b[prop]);
|
|
2093
|
+
if (__getOwnPropSymbols$v)
|
|
2094
|
+
for (var prop of __getOwnPropSymbols$v(b)) {
|
|
2095
|
+
if (__propIsEnum$v.call(b, prop))
|
|
2096
|
+
__defNormalProp$G(a, prop, b[prop]);
|
|
2097
|
+
}
|
|
2098
|
+
return a;
|
|
2099
|
+
};
|
|
2100
|
+
var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
|
|
2101
|
+
var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2102
|
+
var __async$s = (__this, __arguments, generator) => {
|
|
2103
|
+
return new Promise((resolve, reject) => {
|
|
2104
|
+
var fulfilled = (value) => {
|
|
2105
|
+
try {
|
|
2106
|
+
step(generator.next(value));
|
|
2107
|
+
} catch (e) {
|
|
2108
|
+
reject(e);
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
var rejected = (value) => {
|
|
2112
|
+
try {
|
|
2113
|
+
step(generator.throw(value));
|
|
2114
|
+
} catch (e) {
|
|
2115
|
+
reject(e);
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2119
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2120
|
+
});
|
|
2121
|
+
};
|
|
2122
|
+
class ResourcesControl {
|
|
2123
|
+
constructor({
|
|
2124
|
+
connector,
|
|
2125
|
+
cacheId
|
|
2126
|
+
}) {
|
|
2127
|
+
__publicField$r(this, "cache");
|
|
2128
|
+
__publicField$r(this, "connector");
|
|
2129
|
+
this.connector = connector;
|
|
2130
|
+
this.cache = new Cache({ namespace: cacheId });
|
|
2131
|
+
}
|
|
2132
|
+
// -------------------------------------------------------------------------
|
|
2133
|
+
// Resource Methods
|
|
2134
|
+
// -------------------------------------------------------------------------
|
|
2135
|
+
/**
|
|
2136
|
+
* Receive resource from NGW by id, keyname or search-object parameter.
|
|
2137
|
+
* @param resource - Resource id, keyname or search-object
|
|
2138
|
+
*
|
|
2139
|
+
* @remarks
|
|
2140
|
+
* Fetching resource would be cached to speed up next call
|
|
2141
|
+
*/
|
|
2142
|
+
getOne(resource, requestOptions) {
|
|
2143
|
+
const opt = __spreadValues$u({}, requestOptions);
|
|
2144
|
+
if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
|
|
2145
|
+
if (resource.id !== void 0) {
|
|
2146
|
+
resource.id;
|
|
2147
|
+
} else {
|
|
2148
|
+
if (resource.keyname) {
|
|
2149
|
+
resource.keyname;
|
|
2150
|
+
}
|
|
2151
|
+
if (resource.display_name) {
|
|
2152
|
+
resource.display_name;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
if (typeof resource === "string") {
|
|
2157
|
+
return this._fetchResourceBy({ keyname: resource }, opt);
|
|
2158
|
+
} else if (typeof resource === "number") {
|
|
2159
|
+
return this._fetchResourceById(resource, opt);
|
|
2160
|
+
} else if (isObject(resource)) {
|
|
2161
|
+
return this._fetchResourceBy(resource, opt);
|
|
2162
|
+
}
|
|
2163
|
+
return Promise.resolve(void 0);
|
|
2164
|
+
}
|
|
2165
|
+
getOneOrFail(resource, requestOptions) {
|
|
2166
|
+
return this.getOne(resource, requestOptions).then((res) => {
|
|
2167
|
+
if (res) {
|
|
2168
|
+
return res;
|
|
2169
|
+
}
|
|
2170
|
+
throw new ResourceNotFoundError();
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
2175
|
+
* @param resource - Any available resource definition
|
|
2176
|
+
*
|
|
2177
|
+
* @remarks
|
|
2178
|
+
* There are situations when exactly the resource id is needed
|
|
2179
|
+
* (for example, to compose the correct request to the api)
|
|
2180
|
+
* then this method will come in handy to facilitate the extraction of the identifier
|
|
2181
|
+
* if the resource is specified through a keyname or other parameters.
|
|
2182
|
+
*/
|
|
2183
|
+
getId(resource, requestOptions) {
|
|
2184
|
+
if (typeof resource === "number") {
|
|
2185
|
+
return Promise.resolve(resource);
|
|
2186
|
+
} else if (typeof resource === "string" || isObject(resource)) {
|
|
2187
|
+
return this.getOne(resource, requestOptions).then((res) => {
|
|
2188
|
+
if (res) {
|
|
2189
|
+
return res.resource.id;
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
return Promise.resolve(void 0);
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* A fast way to retrieve resource ID for any resource definition.
|
|
2197
|
+
* @param resource - Any available resource definition
|
|
2198
|
+
*
|
|
2199
|
+
* @remarks
|
|
2200
|
+
* Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
|
|
2201
|
+
* To not make one more checks if the resource is definitely exists
|
|
2202
|
+
*/
|
|
2203
|
+
getIdOrFail(resource, requestOptions) {
|
|
2204
|
+
return this.getId(resource, requestOptions).then((resp) => {
|
|
2205
|
+
if (resp === void 0) {
|
|
2206
|
+
throw new Error();
|
|
2207
|
+
}
|
|
2208
|
+
return resp;
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
getMany(resource, requestOptions) {
|
|
2212
|
+
return this._resourceCacheFilter(resource).then((items) => {
|
|
2213
|
+
if (!items.length) {
|
|
2214
|
+
const query = {};
|
|
2215
|
+
if (resource.keyname) {
|
|
2216
|
+
query.keyname = resource.keyname;
|
|
2217
|
+
} else {
|
|
2218
|
+
Object.assign(query, resourceToQuery(resource));
|
|
2219
|
+
}
|
|
2220
|
+
return this.connector.route("resource.search").get(__spreadProps$g(__spreadValues$u({}, requestOptions), {
|
|
2221
|
+
query: __spreadValues$u({
|
|
2222
|
+
serialization: "full"
|
|
2223
|
+
}, query)
|
|
2224
|
+
})).then((resources) => {
|
|
2225
|
+
if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
|
|
2226
|
+
for (const x of resources) {
|
|
2227
|
+
this.cache.add("resource.item", Promise.resolve(x), {
|
|
2228
|
+
id: x.resource.id
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
return resources;
|
|
2233
|
+
});
|
|
1148
2234
|
}
|
|
1149
2235
|
return items;
|
|
1150
2236
|
});
|
|
1151
2237
|
}
|
|
1152
2238
|
getParent(resource, requestOptions) {
|
|
1153
2239
|
return this.getOne(resource, requestOptions).then((child) => {
|
|
1154
|
-
|
|
2240
|
+
var _a, _b;
|
|
2241
|
+
if ((_b = (_a = child == null ? void 0 : child.resource) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) {
|
|
1155
2242
|
return this.getOne(child.resource.parent.id, requestOptions);
|
|
1156
2243
|
}
|
|
1157
2244
|
return Promise.resolve(void 0);
|
|
@@ -1183,10 +2270,21 @@ class ResourcesControl {
|
|
|
1183
2270
|
}
|
|
1184
2271
|
});
|
|
1185
2272
|
}
|
|
1186
|
-
_getChildrenOf(
|
|
1187
|
-
return this
|
|
1188
|
-
parent
|
|
1189
|
-
|
|
2273
|
+
_getChildrenOf(_0, _1) {
|
|
2274
|
+
return __async$s(this, arguments, function* (parentDef, requestOptions, _items = []) {
|
|
2275
|
+
let parent = void 0;
|
|
2276
|
+
if (typeof parentDef === "string") {
|
|
2277
|
+
parent = yield this.getId(parentDef, requestOptions);
|
|
2278
|
+
} else if (typeof parentDef === "object") {
|
|
2279
|
+
parent = parentDef.id;
|
|
2280
|
+
} else {
|
|
2281
|
+
parent = parentDef;
|
|
2282
|
+
}
|
|
2283
|
+
const items = yield this.connector.route("resource.collection").get(__spreadProps$g(__spreadValues$u({}, requestOptions), {
|
|
2284
|
+
query: {
|
|
2285
|
+
parent
|
|
2286
|
+
}
|
|
2287
|
+
}));
|
|
1190
2288
|
const recursivePromises = [];
|
|
1191
2289
|
for (const item of items) {
|
|
1192
2290
|
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
@@ -1235,7 +2333,7 @@ class ResourcesControl {
|
|
|
1235
2333
|
});
|
|
1236
2334
|
}
|
|
1237
2335
|
_fetchResourceById(id, requestOptions) {
|
|
1238
|
-
return this.connector.
|
|
2336
|
+
return this.connector.route("resource.item", { id }).get(requestOptions);
|
|
1239
2337
|
}
|
|
1240
2338
|
_fetchResourceBy(resource, requestOptions) {
|
|
1241
2339
|
return this.getMany(resource, requestOptions).then((resources) => {
|
|
@@ -1259,78 +2357,22 @@ class ResourcesControl {
|
|
|
1259
2357
|
});
|
|
1260
2358
|
return items;
|
|
1261
2359
|
}
|
|
1262
|
-
);
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
const CONNECTORS = [];
|
|
1267
|
-
function addConnector(connector) {
|
|
1268
|
-
CONNECTORS.push(connector);
|
|
1269
|
-
}
|
|
1270
|
-
function findConnector(options) {
|
|
1271
|
-
return CONNECTORS.find((x) => {
|
|
1272
|
-
if (x.options.baseUrl === options.baseUrl) {
|
|
1273
|
-
if (options.auth) {
|
|
1274
|
-
if (x.options.auth) {
|
|
1275
|
-
return objectDeepEqual(x.options.auth, options.auth);
|
|
1276
|
-
}
|
|
1277
|
-
} else {
|
|
1278
|
-
return true;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
function removeConnector(connector) {
|
|
1284
|
-
const index = CONNECTORS.indexOf(connector);
|
|
1285
|
-
if (index !== -1) {
|
|
1286
|
-
CONNECTORS.splice(index, 1);
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
class AbortError extends Error {
|
|
1291
|
-
constructor(message = "AbortError") {
|
|
1292
|
-
super(message);
|
|
1293
|
-
this.name = "AbortError";
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
var __defProp$G = Object.defineProperty;
|
|
1298
|
-
var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1299
|
-
var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1300
|
-
class InsufficientPermissionsError extends NgwError {
|
|
1301
|
-
constructor(obj) {
|
|
1302
|
-
super(obj);
|
|
1303
|
-
__publicField$r(this, "name", "InsufficientPermissionsError");
|
|
1304
|
-
__publicField$r(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
|
|
1305
|
-
Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
const templateRe = /\{ *([\w_-]+) *\}/g;
|
|
1310
|
-
function template(str, data) {
|
|
1311
|
-
return str.replace(templateRe, (s, key) => {
|
|
1312
|
-
let value = data[key];
|
|
1313
|
-
if (value === void 0) {
|
|
1314
|
-
throw new Error("No value provided for letiable " + s);
|
|
1315
|
-
} else if (typeof value === "function") {
|
|
1316
|
-
value = value(data);
|
|
1317
|
-
}
|
|
1318
|
-
return value;
|
|
1319
|
-
});
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
1320
2362
|
}
|
|
1321
2363
|
|
|
1322
2364
|
var __defProp$F = Object.defineProperty;
|
|
1323
|
-
var __getOwnPropSymbols$
|
|
1324
|
-
var __hasOwnProp$
|
|
1325
|
-
var __propIsEnum$
|
|
2365
|
+
var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
|
|
2366
|
+
var __hasOwnProp$u = Object.prototype.hasOwnProperty;
|
|
2367
|
+
var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
|
|
1326
2368
|
var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1327
|
-
var __spreadValues$
|
|
2369
|
+
var __spreadValues$t = (a, b) => {
|
|
1328
2370
|
for (var prop in b || (b = {}))
|
|
1329
|
-
if (__hasOwnProp$
|
|
2371
|
+
if (__hasOwnProp$u.call(b, prop))
|
|
1330
2372
|
__defNormalProp$F(a, prop, b[prop]);
|
|
1331
|
-
if (__getOwnPropSymbols$
|
|
1332
|
-
for (var prop of __getOwnPropSymbols$
|
|
1333
|
-
if (__propIsEnum$
|
|
2373
|
+
if (__getOwnPropSymbols$u)
|
|
2374
|
+
for (var prop of __getOwnPropSymbols$u(b)) {
|
|
2375
|
+
if (__propIsEnum$u.call(b, prop))
|
|
1334
2376
|
__defNormalProp$F(a, prop, b[prop]);
|
|
1335
2377
|
}
|
|
1336
2378
|
return a;
|
|
@@ -1376,343 +2418,57 @@ function apiRequest(opt) {
|
|
|
1376
2418
|
url = template(url, replaceParams);
|
|
1377
2419
|
}
|
|
1378
2420
|
}
|
|
1379
|
-
if (params) {
|
|
1380
|
-
const paramArray = [];
|
|
1381
|
-
const paramList = params.paramList;
|
|
1382
|
-
if (Array.isArray(paramList)) {
|
|
1383
|
-
paramList.forEach(([key, value]) => {
|
|
1384
|
-
paramArray.push(`${key}=${value}`);
|
|
1385
|
-
});
|
|
1386
|
-
}
|
|
1387
|
-
for (const p in params) {
|
|
1388
|
-
if (apiItem.indexOf(p) === -1) {
|
|
1389
|
-
paramArray.push(`${p}=${params[p]}`);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
if (paramArray.length) {
|
|
1393
|
-
url = `${url}?${paramArray.join("&")}`;
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
if (url) {
|
|
1397
|
-
return connector.makeQuery(url, params, __spreadValues$u({
|
|
1398
|
-
cacheName: name
|
|
1399
|
-
}, requestOptions));
|
|
1400
|
-
} else {
|
|
1401
|
-
throw new Error("Request URL is not set");
|
|
1402
|
-
}
|
|
1403
|
-
} else {
|
|
1404
|
-
return void 0;
|
|
1405
|
-
}
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
var __defProp$E = Object.defineProperty;
|
|
1410
|
-
var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1411
|
-
var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
|
|
1412
|
-
class NetworkError extends Error {
|
|
1413
|
-
constructor(url) {
|
|
1414
|
-
super();
|
|
1415
|
-
__publicField$q(this, "name", "NetworkError");
|
|
1416
|
-
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1417
|
-
this.message = `Unable to request ${url}.
|
|
1418
|
-
Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
let loadData;
|
|
1423
|
-
{
|
|
1424
|
-
loadData = (url, callback, options = {}, error, onCancel) => {
|
|
1425
|
-
options.method = options.method || "GET";
|
|
1426
|
-
const xhr = new XMLHttpRequest();
|
|
1427
|
-
xhr.open(options.method || "GET", url, true);
|
|
1428
|
-
if (options.responseType === "blob") {
|
|
1429
|
-
xhr.responseType = options.responseType;
|
|
1430
|
-
}
|
|
1431
|
-
const getResponseText = () => {
|
|
1432
|
-
try {
|
|
1433
|
-
return JSON.parse(xhr.responseText);
|
|
1434
|
-
} catch (er) {
|
|
1435
|
-
return xhr.responseText;
|
|
1436
|
-
}
|
|
1437
|
-
};
|
|
1438
|
-
const processingResponse = (forError = false) => {
|
|
1439
|
-
const cb = forError ? error : callback;
|
|
1440
|
-
if (options.responseType === "blob") {
|
|
1441
|
-
cb(xhr.response);
|
|
1442
|
-
} else {
|
|
1443
|
-
if (xhr.responseText) {
|
|
1444
|
-
cb(getResponseText());
|
|
1445
|
-
} else {
|
|
1446
|
-
error({ message: "" });
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
};
|
|
1450
|
-
xhr.onload = () => {
|
|
1451
|
-
if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
|
|
1452
|
-
error(new NgwError(getResponseText()));
|
|
1453
|
-
}
|
|
1454
|
-
processingResponse();
|
|
1455
|
-
};
|
|
1456
|
-
xhr.onerror = (er) => {
|
|
1457
|
-
if (xhr.status === 0) {
|
|
1458
|
-
error(new NetworkError(url));
|
|
1459
|
-
} else {
|
|
1460
|
-
error(er);
|
|
1461
|
-
}
|
|
1462
|
-
};
|
|
1463
|
-
xhr.upload.onprogress = function(e) {
|
|
1464
|
-
if (e.lengthComputable) {
|
|
1465
|
-
const percentComplete = e.loaded / e.total * 100;
|
|
1466
|
-
if (options.onProgress) {
|
|
1467
|
-
options.onProgress(percentComplete, e);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
};
|
|
1471
|
-
const headers = options.headers;
|
|
1472
|
-
if (headers) {
|
|
1473
|
-
for (const h in headers) {
|
|
1474
|
-
const header = headers[h];
|
|
1475
|
-
if (typeof header === "string") {
|
|
1476
|
-
xhr.setRequestHeader(h, header);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
if (options.withCredentials !== void 0) {
|
|
1481
|
-
xhr.withCredentials = options.withCredentials;
|
|
1482
|
-
}
|
|
1483
|
-
let data;
|
|
1484
|
-
if (options.file) {
|
|
1485
|
-
data = new FormData();
|
|
1486
|
-
data.append("file", options.file);
|
|
1487
|
-
if (options.data) {
|
|
1488
|
-
for (const d in options.data) {
|
|
1489
|
-
data.append(d, data[d]);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
} else {
|
|
1493
|
-
data = options.data ? typeof options.data === "string" ? options.data : JSON.stringify(options.data) : null;
|
|
1494
|
-
}
|
|
1495
|
-
if (onCancel) {
|
|
1496
|
-
onCancel(() => {
|
|
1497
|
-
xhr.abort();
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
xhr.send(data);
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
var __defProp$D = Object.defineProperty;
|
|
1505
|
-
var __defProps$d = Object.defineProperties;
|
|
1506
|
-
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
1507
|
-
var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
|
|
1508
|
-
var __hasOwnProp$u = Object.prototype.hasOwnProperty;
|
|
1509
|
-
var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
|
|
1510
|
-
var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1511
|
-
var __spreadValues$t = (a, b) => {
|
|
1512
|
-
for (var prop in b || (b = {}))
|
|
1513
|
-
if (__hasOwnProp$u.call(b, prop))
|
|
1514
|
-
__defNormalProp$D(a, prop, b[prop]);
|
|
1515
|
-
if (__getOwnPropSymbols$u)
|
|
1516
|
-
for (var prop of __getOwnPropSymbols$u(b)) {
|
|
1517
|
-
if (__propIsEnum$u.call(b, prop))
|
|
1518
|
-
__defNormalProp$D(a, prop, b[prop]);
|
|
1519
|
-
}
|
|
1520
|
-
return a;
|
|
1521
|
-
};
|
|
1522
|
-
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
1523
|
-
var __objRest$2 = (source, exclude) => {
|
|
1524
|
-
var target = {};
|
|
1525
|
-
for (var prop in source)
|
|
1526
|
-
if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1527
|
-
target[prop] = source[prop];
|
|
1528
|
-
if (source != null && __getOwnPropSymbols$u)
|
|
1529
|
-
for (var prop of __getOwnPropSymbols$u(source)) {
|
|
1530
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
|
|
1531
|
-
target[prop] = source[prop];
|
|
1532
|
-
}
|
|
1533
|
-
return target;
|
|
1534
|
-
};
|
|
1535
|
-
var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1536
|
-
var __async$q = (__this, __arguments, generator) => {
|
|
1537
|
-
return new Promise((resolve, reject) => {
|
|
1538
|
-
var fulfilled = (value) => {
|
|
1539
|
-
try {
|
|
1540
|
-
step(generator.next(value));
|
|
1541
|
-
} catch (e) {
|
|
1542
|
-
reject(e);
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
var rejected = (value) => {
|
|
1546
|
-
try {
|
|
1547
|
-
step(generator.throw(value));
|
|
1548
|
-
} catch (e) {
|
|
1549
|
-
reject(e);
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1552
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1553
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
1554
|
-
});
|
|
1555
|
-
};
|
|
1556
|
-
let ID$2 = 0;
|
|
1557
|
-
let REQUEST_ID = 0;
|
|
1558
|
-
class NgwConnector {
|
|
1559
|
-
constructor(options) {
|
|
1560
|
-
this.options = options;
|
|
1561
|
-
__publicField$p(this, "id", ID$2++);
|
|
1562
|
-
__publicField$p(this, "emitter", new EventEmitter());
|
|
1563
|
-
__publicField$p(this, "user");
|
|
1564
|
-
__publicField$p(this, "resources");
|
|
1565
|
-
__publicField$p(this, "cache");
|
|
1566
|
-
__publicField$p(this, "routeStr", "/api/component/pyramid/route");
|
|
1567
|
-
__publicField$p(this, "activeRequests", {});
|
|
1568
|
-
__publicField$p(this, "requestTransform");
|
|
1569
|
-
const exist = findConnector(options);
|
|
1570
|
-
this.cache = new Cache({ namespace: options.cacheId });
|
|
1571
|
-
if (exist) {
|
|
1572
|
-
return exist;
|
|
1573
|
-
} else {
|
|
1574
|
-
if (this.options.route) {
|
|
1575
|
-
this.routeStr = this.options.route;
|
|
1576
|
-
}
|
|
1577
|
-
if (this.options.requestTransform) {
|
|
1578
|
-
this.requestTransform = this.options.requestTransform;
|
|
1579
|
-
}
|
|
1580
|
-
this.resources = new ResourcesControl({
|
|
1581
|
-
connector: this,
|
|
1582
|
-
cacheId: options.cacheId
|
|
1583
|
-
});
|
|
1584
|
-
addConnector(this);
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
static create(options) {
|
|
1588
|
-
return new this(options);
|
|
1589
|
-
}
|
|
1590
|
-
/**
|
|
1591
|
-
* Clear the cache.
|
|
1592
|
-
*/
|
|
1593
|
-
clearCache() {
|
|
1594
|
-
this.cache.clean();
|
|
1595
|
-
this.resources.cache.clean();
|
|
1596
|
-
}
|
|
1597
|
-
setRequestTransform(requestTransform) {
|
|
1598
|
-
this.requestTransform = requestTransform;
|
|
1599
|
-
}
|
|
1600
|
-
/**
|
|
1601
|
-
* Fast way to specify the connection address to NextGIS Web.
|
|
1602
|
-
* The current connection will be severed.
|
|
1603
|
-
* @param baseUrl - NGW url
|
|
1604
|
-
*/
|
|
1605
|
-
setNgw(baseUrl) {
|
|
1606
|
-
this.logout();
|
|
1607
|
-
this.options.baseUrl = baseUrl;
|
|
1608
|
-
addConnector(this);
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* Establishing a connection with NextGIS Web to fulfill all other requests.
|
|
1612
|
-
* @remarks
|
|
1613
|
-
* This method need not be called manually as it is used when forming a request in {@link apiRequest | apiRequest}.
|
|
1614
|
-
* Can be used to check connection.
|
|
1615
|
-
* @example
|
|
1616
|
-
* ```javascript
|
|
1617
|
-
* const connector = new NgwConnector({baseUrl: 'https://demo.nextgis.com'});
|
|
1618
|
-
* connector.connect()
|
|
1619
|
-
* .then(() => console.log('Ok'))
|
|
1620
|
-
* .catch((er) => console.log('Connection problem', er));
|
|
1621
|
-
* ```
|
|
1622
|
-
*/
|
|
1623
|
-
connect() {
|
|
1624
|
-
return __async$q(this, null, function* () {
|
|
1625
|
-
const auth = this.options.auth;
|
|
1626
|
-
if (auth) {
|
|
1627
|
-
const { login, password } = auth;
|
|
1628
|
-
if (login && password) {
|
|
1629
|
-
yield this._login({ login, password });
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
return yield this.makeQuery(
|
|
1633
|
-
this.routeStr,
|
|
1634
|
-
{},
|
|
1635
|
-
{
|
|
1636
|
-
cacheName: "route",
|
|
1637
|
-
cache: true,
|
|
1638
|
-
cacheProps: {
|
|
1639
|
-
id: this.id,
|
|
1640
|
-
auth,
|
|
1641
|
-
baseUrl: this.options.baseUrl
|
|
2421
|
+
if (params) {
|
|
2422
|
+
const paramArray = [];
|
|
2423
|
+
const paramList = params.paramList;
|
|
2424
|
+
if (Array.isArray(paramList)) {
|
|
2425
|
+
paramList.forEach(([key, value]) => {
|
|
2426
|
+
paramArray.push(`${key}=${value}`);
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
for (const p in params) {
|
|
2430
|
+
if (apiItem.indexOf(p) === -1) {
|
|
2431
|
+
paramArray.push(`${p}=${params[p]}`);
|
|
1642
2432
|
}
|
|
1643
2433
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* Quick way to change NextGIS Web user.
|
|
1649
|
-
* @param credentials - New user credentials
|
|
1650
|
-
*/
|
|
1651
|
-
login(credentials, options) {
|
|
1652
|
-
this.logout();
|
|
1653
|
-
addConnector(this);
|
|
1654
|
-
return this._login(credentials, options);
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Disconnecting a user. Aborting all current requests
|
|
1658
|
-
*/
|
|
1659
|
-
logout() {
|
|
1660
|
-
this.abort();
|
|
1661
|
-
removeConnector(this);
|
|
1662
|
-
this.options.auth = void 0;
|
|
1663
|
-
this.user = void 0;
|
|
1664
|
-
this.clearCache();
|
|
1665
|
-
this.emitter.emit("logout");
|
|
1666
|
-
}
|
|
1667
|
-
getUserInfo(credentials, options) {
|
|
1668
|
-
return __async$q(this, null, function* () {
|
|
1669
|
-
if (this.user && this.user.id) {
|
|
1670
|
-
return this.user;
|
|
2434
|
+
if (paramArray.length) {
|
|
2435
|
+
url = `${url}?${paramArray.join("&")}`;
|
|
2436
|
+
}
|
|
1671
2437
|
}
|
|
1672
|
-
if (
|
|
1673
|
-
|
|
2438
|
+
if (url) {
|
|
2439
|
+
return connector.makeQuery(url, params, __spreadValues$t({
|
|
2440
|
+
cacheName: name
|
|
2441
|
+
}, requestOptions));
|
|
2442
|
+
} else {
|
|
2443
|
+
throw new Error("Request URL is not set");
|
|
1674
2444
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
2445
|
+
} else {
|
|
2446
|
+
return void 0;
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
var __defProp$E = Object.defineProperty;
|
|
2452
|
+
var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2453
|
+
var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
|
|
2454
|
+
class NgwConnectorExtended extends NgwConnector {
|
|
2455
|
+
constructor(options) {
|
|
2456
|
+
super(options);
|
|
2457
|
+
__publicField$q(this, "resources");
|
|
2458
|
+
this.resources = new ResourcesControl({
|
|
2459
|
+
connector: this,
|
|
2460
|
+
cacheId: options.cacheId
|
|
1683
2461
|
});
|
|
1684
2462
|
}
|
|
2463
|
+
static create(options) {
|
|
2464
|
+
return new this(options);
|
|
2465
|
+
}
|
|
1685
2466
|
/**
|
|
1686
|
-
*
|
|
2467
|
+
* Clear the cache.
|
|
1687
2468
|
*/
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
return {
|
|
1692
|
-
Authorization: `Basic ${client}`
|
|
1693
|
-
};
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
makeClientId(credentials) {
|
|
1697
|
-
credentials = credentials || this.options.auth;
|
|
1698
|
-
if (credentials) {
|
|
1699
|
-
const { login, password } = credentials;
|
|
1700
|
-
const str = `${login}:${password}`;
|
|
1701
|
-
const encodedStr = encodeURIComponent(str);
|
|
1702
|
-
{
|
|
1703
|
-
return window.btoa(encodedStr);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
/** Stop all api requests */
|
|
1708
|
-
abort() {
|
|
1709
|
-
for (const abortController of Object.values(this.activeRequests)) {
|
|
1710
|
-
abortController.abort();
|
|
1711
|
-
}
|
|
1712
|
-
this.activeRequests = {};
|
|
1713
|
-
}
|
|
1714
|
-
getActiveApiRequests() {
|
|
1715
|
-
return __spreadValues$t({}, this.activeRequests);
|
|
2469
|
+
clearCache() {
|
|
2470
|
+
super.clearCache();
|
|
2471
|
+
this.resources.cache.clean();
|
|
1716
2472
|
}
|
|
1717
2473
|
/**
|
|
1718
2474
|
* Send request to NGW api router.
|
|
@@ -1831,74 +2587,6 @@ class NgwConnector {
|
|
|
1831
2587
|
options
|
|
1832
2588
|
);
|
|
1833
2589
|
}
|
|
1834
|
-
/**
|
|
1835
|
-
* Send request to NGW.
|
|
1836
|
-
* @param url - URL address to NGW
|
|
1837
|
-
* @param params - Query params
|
|
1838
|
-
* @param options - Request options
|
|
1839
|
-
*/
|
|
1840
|
-
makeQuery(_0, _1) {
|
|
1841
|
-
return __async$q(this, arguments, function* (url, params, options = {}) {
|
|
1842
|
-
var _b;
|
|
1843
|
-
url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
|
|
1844
|
-
if (!url) {
|
|
1845
|
-
throw new Error("Empty `url` not allowed");
|
|
1846
|
-
}
|
|
1847
|
-
if (params) {
|
|
1848
|
-
const _a = params, restParams = __objRest$2(_a, ["paramList"]);
|
|
1849
|
-
url = template(url, restParams);
|
|
1850
|
-
}
|
|
1851
|
-
url = encodeURI(fixUrlStr(url));
|
|
1852
|
-
const {
|
|
1853
|
-
cache,
|
|
1854
|
-
signal: externalSignal,
|
|
1855
|
-
method = "GET",
|
|
1856
|
-
headers,
|
|
1857
|
-
cacheName,
|
|
1858
|
-
cacheProps,
|
|
1859
|
-
responseType,
|
|
1860
|
-
withCredentials
|
|
1861
|
-
} = options;
|
|
1862
|
-
const internalAbortController = new AbortController();
|
|
1863
|
-
const internalSignal = internalAbortController.signal;
|
|
1864
|
-
if (externalSignal) {
|
|
1865
|
-
if (externalSignal.aborted) {
|
|
1866
|
-
throw new AbortError();
|
|
1867
|
-
}
|
|
1868
|
-
externalSignal.addEventListener("abort", () => {
|
|
1869
|
-
internalAbortController.abort();
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
options.signal = internalSignal;
|
|
1873
|
-
const createPromise = () => __async$q(this, null, function* () {
|
|
1874
|
-
const id = REQUEST_ID++;
|
|
1875
|
-
this.activeRequests[id] = internalAbortController;
|
|
1876
|
-
try {
|
|
1877
|
-
return this._loadData(url, options);
|
|
1878
|
-
} finally {
|
|
1879
|
-
this._cleanActiveRequest(id);
|
|
1880
|
-
}
|
|
1881
|
-
});
|
|
1882
|
-
if (cache && method === "GET") {
|
|
1883
|
-
const cacheOptions = cacheProps ? cacheProps : __spreadProps$d(__spreadValues$t({}, objectRemoveEmpty({
|
|
1884
|
-
headers,
|
|
1885
|
-
withCredentials,
|
|
1886
|
-
responseType,
|
|
1887
|
-
baseUrl: this.options.baseUrl,
|
|
1888
|
-
userId: (_b = this.user) == null ? void 0 : _b.id
|
|
1889
|
-
})), {
|
|
1890
|
-
params
|
|
1891
|
-
});
|
|
1892
|
-
return this.cache.add(
|
|
1893
|
-
cacheName || url,
|
|
1894
|
-
createPromise,
|
|
1895
|
-
cacheOptions,
|
|
1896
|
-
false
|
|
1897
|
-
);
|
|
1898
|
-
}
|
|
1899
|
-
return createPromise();
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
2590
|
// -------------------------------------------------------------------------
|
|
1903
2591
|
// Resource Methods
|
|
1904
2592
|
// -------------------------------------------------------------------------
|
|
@@ -1974,92 +2662,21 @@ class NgwConnector {
|
|
|
1974
2662
|
deleteResource(resource) {
|
|
1975
2663
|
return this.resources.delete(resource);
|
|
1976
2664
|
}
|
|
1977
|
-
/**
|
|
1978
|
-
* @internal
|
|
1979
|
-
*/
|
|
1980
|
-
_loadData(url, options) {
|
|
1981
|
-
options.responseType = options.responseType || "json";
|
|
1982
|
-
return new Promise((resolve, reject) => {
|
|
1983
|
-
var _a;
|
|
1984
|
-
if (this.user) {
|
|
1985
|
-
options = options || {};
|
|
1986
|
-
options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
|
|
1987
|
-
}
|
|
1988
|
-
if (this.requestTransform) {
|
|
1989
|
-
const [transUrl, transOptions] = this.requestTransform(url, options);
|
|
1990
|
-
url = transUrl;
|
|
1991
|
-
options = transOptions;
|
|
1992
|
-
}
|
|
1993
|
-
let runOnAbort = void 0;
|
|
1994
|
-
loadData(url, resolve, options, reject, (handler) => {
|
|
1995
|
-
runOnAbort = handler;
|
|
1996
|
-
});
|
|
1997
|
-
(_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
|
|
1998
|
-
if (runOnAbort !== void 0) {
|
|
1999
|
-
runOnAbort();
|
|
2000
|
-
}
|
|
2001
|
-
reject(new AbortError());
|
|
2002
|
-
});
|
|
2003
|
-
}).catch((httpError) => {
|
|
2004
|
-
if (httpError.name !== "AbortError") {
|
|
2005
|
-
{
|
|
2006
|
-
console.warn("DEV WARN", httpError);
|
|
2007
|
-
}
|
|
2008
|
-
const er = this._handleHttpError(httpError);
|
|
2009
|
-
if (er) {
|
|
2010
|
-
throw er;
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
throw httpError;
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
_login(credentials, options) {
|
|
2017
|
-
return __async$q(this, null, function* () {
|
|
2018
|
-
try {
|
|
2019
|
-
const data = yield this.getUserInfo(credentials, options);
|
|
2020
|
-
this.user = data;
|
|
2021
|
-
this.emitter.emit("login", data);
|
|
2022
|
-
return data;
|
|
2023
|
-
} catch (er) {
|
|
2024
|
-
this.emitter.emit("login:error", er);
|
|
2025
|
-
throw er;
|
|
2026
|
-
}
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
_cleanActiveRequest(requestId) {
|
|
2030
|
-
delete this.activeRequests[requestId];
|
|
2031
|
-
}
|
|
2032
|
-
_handleHttpError(er) {
|
|
2033
|
-
if (er) {
|
|
2034
|
-
if (er instanceof NgwError) {
|
|
2035
|
-
if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
|
|
2036
|
-
throw new ResourceNotFoundError(er);
|
|
2037
|
-
} else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
|
|
2038
|
-
throw new InsufficientPermissionsError(er);
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
return er;
|
|
2043
|
-
}
|
|
2044
2665
|
}
|
|
2045
|
-
__publicField$p(NgwConnector, "errors", {
|
|
2046
|
-
NgwError,
|
|
2047
|
-
ResourceNotFoundError
|
|
2048
|
-
});
|
|
2049
2666
|
|
|
2050
|
-
var __defProp$
|
|
2667
|
+
var __defProp$D = Object.defineProperty;
|
|
2051
2668
|
var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
|
|
2052
2669
|
var __hasOwnProp$t = Object.prototype.hasOwnProperty;
|
|
2053
2670
|
var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
|
|
2054
|
-
var __defNormalProp$
|
|
2671
|
+
var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2055
2672
|
var __spreadValues$s = (a, b) => {
|
|
2056
2673
|
for (var prop in b || (b = {}))
|
|
2057
2674
|
if (__hasOwnProp$t.call(b, prop))
|
|
2058
|
-
__defNormalProp$
|
|
2675
|
+
__defNormalProp$D(a, prop, b[prop]);
|
|
2059
2676
|
if (__getOwnPropSymbols$t)
|
|
2060
2677
|
for (var prop of __getOwnPropSymbols$t(b)) {
|
|
2061
2678
|
if (__propIsEnum$t.call(b, prop))
|
|
2062
|
-
__defNormalProp$
|
|
2679
|
+
__defNormalProp$D(a, prop, b[prop]);
|
|
2063
2680
|
}
|
|
2064
2681
|
return a;
|
|
2065
2682
|
};
|
|
@@ -2141,26 +2758,30 @@ function propertiesFilter(properties, filters) {
|
|
|
2141
2758
|
return logic === "any" ? filters_.some(filterFunction) : filters_.every(filterFunction);
|
|
2142
2759
|
}
|
|
2143
2760
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2761
|
+
const config = {
|
|
2762
|
+
defaultRequestLimit: 7e3
|
|
2763
|
+
};
|
|
2764
|
+
|
|
2765
|
+
var __defProp$C = Object.defineProperty;
|
|
2766
|
+
var __defProps$f = Object.defineProperties;
|
|
2767
|
+
var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
|
|
2147
2768
|
var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
|
|
2148
2769
|
var __hasOwnProp$s = Object.prototype.hasOwnProperty;
|
|
2149
2770
|
var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
|
|
2150
|
-
var __defNormalProp$
|
|
2771
|
+
var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2151
2772
|
var __spreadValues$r = (a, b) => {
|
|
2152
2773
|
for (var prop in b || (b = {}))
|
|
2153
2774
|
if (__hasOwnProp$s.call(b, prop))
|
|
2154
|
-
__defNormalProp$
|
|
2775
|
+
__defNormalProp$C(a, prop, b[prop]);
|
|
2155
2776
|
if (__getOwnPropSymbols$s)
|
|
2156
2777
|
for (var prop of __getOwnPropSymbols$s(b)) {
|
|
2157
2778
|
if (__propIsEnum$s.call(b, prop))
|
|
2158
|
-
__defNormalProp$
|
|
2779
|
+
__defNormalProp$C(a, prop, b[prop]);
|
|
2159
2780
|
}
|
|
2160
2781
|
return a;
|
|
2161
2782
|
};
|
|
2162
|
-
var __spreadProps$
|
|
2163
|
-
var __async$
|
|
2783
|
+
var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
|
|
2784
|
+
var __async$q = (__this, __arguments, generator) => {
|
|
2164
2785
|
return new Promise((resolve, reject) => {
|
|
2165
2786
|
var fulfilled = (value) => {
|
|
2166
2787
|
try {
|
|
@@ -2196,15 +2817,12 @@ function createGeoJsonFeature(item) {
|
|
|
2196
2817
|
}
|
|
2197
2818
|
function updateItemRequestParam(params, options) {
|
|
2198
2819
|
const { extensions, geom, fields, srs, ilike, like } = options;
|
|
2199
|
-
|
|
2200
|
-
if (
|
|
2201
|
-
params.
|
|
2202
|
-
}
|
|
2203
|
-
if (fields !== void 0) {
|
|
2204
|
-
params.fields = Array.isArray(fields) ? fields.join(",") : "";
|
|
2820
|
+
params.extensions = extensions ? extensions : [];
|
|
2821
|
+
if (fields) {
|
|
2822
|
+
params.fields = fields;
|
|
2205
2823
|
}
|
|
2206
2824
|
if (geom !== void 0) {
|
|
2207
|
-
params.geom = geom
|
|
2825
|
+
params.geom = geom;
|
|
2208
2826
|
if (!geom) {
|
|
2209
2827
|
delete params.srs;
|
|
2210
2828
|
delete params.geom_format;
|
|
@@ -2219,8 +2837,17 @@ function updateItemRequestParam(params, options) {
|
|
|
2219
2837
|
params.srs = srs;
|
|
2220
2838
|
}
|
|
2221
2839
|
}
|
|
2840
|
+
function paramListToQuery(paramList) {
|
|
2841
|
+
return paramList.reduce(
|
|
2842
|
+
(acc, [key, value]) => {
|
|
2843
|
+
acc[key] = value;
|
|
2844
|
+
return acc;
|
|
2845
|
+
},
|
|
2846
|
+
{}
|
|
2847
|
+
);
|
|
2848
|
+
}
|
|
2222
2849
|
function createFeatureFieldFilterQueries(opt) {
|
|
2223
|
-
return __async$
|
|
2850
|
+
return __async$q(this, null, function* () {
|
|
2224
2851
|
const queries = getQueries(opt);
|
|
2225
2852
|
const itemsParts = yield Promise.all(queries);
|
|
2226
2853
|
const ids = [];
|
|
@@ -2264,13 +2891,13 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
|
|
|
2264
2891
|
for (const f of filters_) {
|
|
2265
2892
|
if (isPropertyFilter(f)) {
|
|
2266
2893
|
_queries.push(
|
|
2267
|
-
fetchNgwLayerItemsRequest(__spreadProps$
|
|
2894
|
+
fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
|
|
2268
2895
|
paramList: [..._parentAllParams, ...paramList, createParam(f)]
|
|
2269
2896
|
}))
|
|
2270
2897
|
);
|
|
2271
2898
|
} else {
|
|
2272
2899
|
getQueries(
|
|
2273
|
-
__spreadProps$
|
|
2900
|
+
__spreadProps$f(__spreadValues$r({}, opt), {
|
|
2274
2901
|
filters: f
|
|
2275
2902
|
}),
|
|
2276
2903
|
_queries,
|
|
@@ -2291,7 +2918,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
|
|
|
2291
2918
|
if (propertiesFilterList.length) {
|
|
2292
2919
|
for (const x of propertiesFilterList) {
|
|
2293
2920
|
getQueries(
|
|
2294
|
-
__spreadProps$
|
|
2921
|
+
__spreadProps$f(__spreadValues$r({}, opt), {
|
|
2295
2922
|
filters: x
|
|
2296
2923
|
}),
|
|
2297
2924
|
_queries,
|
|
@@ -2300,7 +2927,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
|
|
|
2300
2927
|
}
|
|
2301
2928
|
} else {
|
|
2302
2929
|
_queries.push(
|
|
2303
|
-
fetchNgwLayerItemsRequest(__spreadProps$
|
|
2930
|
+
fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
|
|
2304
2931
|
paramList: [..._parentAllParams, ...paramList, ...filters2]
|
|
2305
2932
|
}))
|
|
2306
2933
|
);
|
|
@@ -2319,6 +2946,7 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
2319
2946
|
const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
|
|
2320
2947
|
const {
|
|
2321
2948
|
limit,
|
|
2949
|
+
query,
|
|
2322
2950
|
cache,
|
|
2323
2951
|
signal,
|
|
2324
2952
|
offset,
|
|
@@ -2329,12 +2957,10 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
2329
2957
|
intersects,
|
|
2330
2958
|
resourceId
|
|
2331
2959
|
} = options;
|
|
2332
|
-
if (limit) {
|
|
2333
|
-
|
|
2334
|
-
params.limit = limit;
|
|
2335
|
-
}
|
|
2960
|
+
if (limit && limit !== Number.POSITIVE_INFINITY) {
|
|
2961
|
+
params.limit = limit;
|
|
2336
2962
|
} else {
|
|
2337
|
-
params.limit =
|
|
2963
|
+
params.limit = config.defaultRequestLimit;
|
|
2338
2964
|
}
|
|
2339
2965
|
if (offset) {
|
|
2340
2966
|
params.offset = offset;
|
|
@@ -2353,38 +2979,31 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
2353
2979
|
params.intersects = intersects;
|
|
2354
2980
|
}
|
|
2355
2981
|
if (paramList) {
|
|
2356
|
-
params
|
|
2982
|
+
Object.assign(params, paramListToQuery(paramList));
|
|
2357
2983
|
}
|
|
2358
|
-
|
|
2359
|
-
id: resourceId
|
|
2360
|
-
}, params);
|
|
2361
|
-
return connector.get(
|
|
2362
|
-
"feature_layer.feature.collection",
|
|
2363
|
-
{ cache, signal },
|
|
2364
|
-
reqParams
|
|
2365
|
-
);
|
|
2984
|
+
return connector.route("feature_layer.feature.collection", { id: Number(resourceId) }).get({ query: __spreadValues$r(__spreadValues$r({}, params), query), cache, signal });
|
|
2366
2985
|
}
|
|
2367
2986
|
|
|
2368
|
-
var __defProp$
|
|
2369
|
-
var __defProps$
|
|
2370
|
-
var __getOwnPropDescs$
|
|
2987
|
+
var __defProp$B = Object.defineProperty;
|
|
2988
|
+
var __defProps$e = Object.defineProperties;
|
|
2989
|
+
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
2371
2990
|
var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
|
|
2372
2991
|
var __hasOwnProp$r = Object.prototype.hasOwnProperty;
|
|
2373
2992
|
var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
|
|
2374
|
-
var __defNormalProp$
|
|
2993
|
+
var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2375
2994
|
var __spreadValues$q = (a, b) => {
|
|
2376
2995
|
for (var prop in b || (b = {}))
|
|
2377
2996
|
if (__hasOwnProp$r.call(b, prop))
|
|
2378
|
-
__defNormalProp$
|
|
2997
|
+
__defNormalProp$B(a, prop, b[prop]);
|
|
2379
2998
|
if (__getOwnPropSymbols$r)
|
|
2380
2999
|
for (var prop of __getOwnPropSymbols$r(b)) {
|
|
2381
3000
|
if (__propIsEnum$r.call(b, prop))
|
|
2382
|
-
__defNormalProp$
|
|
3001
|
+
__defNormalProp$B(a, prop, b[prop]);
|
|
2383
3002
|
}
|
|
2384
3003
|
return a;
|
|
2385
3004
|
};
|
|
2386
|
-
var __spreadProps$
|
|
2387
|
-
var __async$
|
|
3005
|
+
var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
|
|
3006
|
+
var __async$p = (__this, __arguments, generator) => {
|
|
2388
3007
|
return new Promise((resolve, reject) => {
|
|
2389
3008
|
var fulfilled = (value) => {
|
|
2390
3009
|
try {
|
|
@@ -2405,61 +3024,56 @@ var __async$o = (__this, __arguments, generator) => {
|
|
|
2405
3024
|
});
|
|
2406
3025
|
};
|
|
2407
3026
|
function fetchNgwLayerItem(options) {
|
|
2408
|
-
return __async$
|
|
3027
|
+
return __async$p(this, null, function* () {
|
|
2409
3028
|
const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
|
|
2410
3029
|
updateItemRequestParam(params, options);
|
|
2411
|
-
const
|
|
2412
|
-
id: options.resourceId,
|
|
3030
|
+
const resp = yield options.connector.route("feature_layer.feature.item", {
|
|
3031
|
+
id: Number(options.resourceId),
|
|
2413
3032
|
fid: options.featureId
|
|
2414
|
-
}, params);
|
|
2415
|
-
const
|
|
2416
|
-
"feature_layer.feature.item",
|
|
2417
|
-
options,
|
|
2418
|
-
queryParams
|
|
2419
|
-
);
|
|
2420
|
-
const toGeojson = () => __async$o(this, null, function* () {
|
|
3033
|
+
}).get(__spreadProps$e(__spreadValues$q({}, options), { query: params }));
|
|
3034
|
+
const toGeojson = () => __async$p(this, null, function* () {
|
|
2421
3035
|
if (resp.geom) {
|
|
2422
3036
|
return createGeoJsonFeature(resp);
|
|
2423
3037
|
} else {
|
|
2424
|
-
const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$
|
|
3038
|
+
const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$e(__spreadValues$q({}, options), {
|
|
2425
3039
|
geom: true,
|
|
2426
3040
|
fields: null,
|
|
2427
3041
|
extensions: null
|
|
2428
3042
|
}));
|
|
2429
3043
|
const geom = onlyGeomItem.geom;
|
|
2430
|
-
return createGeoJsonFeature(__spreadProps$
|
|
3044
|
+
return createGeoJsonFeature(__spreadProps$e(__spreadValues$q({}, resp), { geom }));
|
|
2431
3045
|
}
|
|
2432
3046
|
});
|
|
2433
|
-
return __spreadProps$
|
|
3047
|
+
return __spreadProps$e(__spreadValues$q({}, resp), {
|
|
2434
3048
|
toGeojson
|
|
2435
3049
|
});
|
|
2436
3050
|
});
|
|
2437
3051
|
}
|
|
2438
3052
|
|
|
2439
|
-
var __defProp$
|
|
3053
|
+
var __defProp$A = Object.defineProperty;
|
|
2440
3054
|
var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
|
|
2441
3055
|
var __hasOwnProp$q = Object.prototype.hasOwnProperty;
|
|
2442
3056
|
var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
|
|
2443
|
-
var __defNormalProp$
|
|
3057
|
+
var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2444
3058
|
var __spreadValues$p = (a, b) => {
|
|
2445
3059
|
for (var prop in b || (b = {}))
|
|
2446
3060
|
if (__hasOwnProp$q.call(b, prop))
|
|
2447
|
-
__defNormalProp$
|
|
3061
|
+
__defNormalProp$A(a, prop, b[prop]);
|
|
2448
3062
|
if (__getOwnPropSymbols$q)
|
|
2449
3063
|
for (var prop of __getOwnPropSymbols$q(b)) {
|
|
2450
3064
|
if (__propIsEnum$q.call(b, prop))
|
|
2451
|
-
__defNormalProp$
|
|
3065
|
+
__defNormalProp$A(a, prop, b[prop]);
|
|
2452
3066
|
}
|
|
2453
3067
|
return a;
|
|
2454
3068
|
};
|
|
2455
|
-
var __publicField$
|
|
3069
|
+
var __publicField$p = (obj, key, value) => __defNormalProp$A(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2456
3070
|
class BookmarkItem {
|
|
2457
3071
|
constructor(options) {
|
|
2458
3072
|
this.options = options;
|
|
2459
|
-
__publicField$
|
|
2460
|
-
__publicField$
|
|
2461
|
-
__publicField$
|
|
2462
|
-
__publicField$
|
|
3073
|
+
__publicField$p(this, "name");
|
|
3074
|
+
__publicField$p(this, "resourceId");
|
|
3075
|
+
__publicField$p(this, "item");
|
|
3076
|
+
__publicField$p(this, "_extent");
|
|
2463
3077
|
this.resourceId = options.resourceId;
|
|
2464
3078
|
const item = options.item;
|
|
2465
3079
|
this.item = item;
|
|
@@ -2473,10 +3087,10 @@ class BookmarkItem {
|
|
|
2473
3087
|
if (this._extent) {
|
|
2474
3088
|
return Promise.resolve(this._extent);
|
|
2475
3089
|
}
|
|
2476
|
-
return this.options.connector.
|
|
3090
|
+
return this.options.connector.route("feature_layer.feature.item_extent", {
|
|
2477
3091
|
id: this.resourceId,
|
|
2478
3092
|
fid: this.item.id
|
|
2479
|
-
}).then((resp) => {
|
|
3093
|
+
}).get(opt).then((resp) => {
|
|
2480
3094
|
const { minLat, minLon, maxLat, maxLon } = resp.extent;
|
|
2481
3095
|
const lonLat = [minLon, minLat, maxLon, maxLat];
|
|
2482
3096
|
this._extent = lonLat;
|
|
@@ -2605,14 +3219,14 @@ function treeEvery_(item, filterFunc = (x) => !!x, relation, _filtered = []) {
|
|
|
2605
3219
|
return true;
|
|
2606
3220
|
}
|
|
2607
3221
|
|
|
2608
|
-
var __defProp$
|
|
2609
|
-
var __defNormalProp$
|
|
2610
|
-
var __publicField$
|
|
3222
|
+
var __defProp$z = Object.defineProperty;
|
|
3223
|
+
var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3224
|
+
var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2611
3225
|
class TreeHelper {
|
|
2612
3226
|
constructor(item) {
|
|
2613
|
-
__publicField$
|
|
2614
|
-
__publicField$
|
|
2615
|
-
__publicField$
|
|
3227
|
+
__publicField$o(this, "item");
|
|
3228
|
+
__publicField$o(this, "_children", []);
|
|
3229
|
+
__publicField$o(this, "_parent");
|
|
2616
3230
|
this.item = item;
|
|
2617
3231
|
}
|
|
2618
3232
|
setParent(parent) {
|
|
@@ -2675,19 +3289,19 @@ class TreeHelper {
|
|
|
2675
3289
|
}
|
|
2676
3290
|
}
|
|
2677
3291
|
|
|
2678
|
-
var __defProp$
|
|
2679
|
-
var __defNormalProp$
|
|
2680
|
-
var __publicField$
|
|
3292
|
+
var __defProp$y = Object.defineProperty;
|
|
3293
|
+
var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3294
|
+
var __publicField$n = (obj, key, value) => __defNormalProp$y(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2681
3295
|
class BaseProperty {
|
|
2682
3296
|
constructor(name, item, options) {
|
|
2683
|
-
__publicField$
|
|
2684
|
-
__publicField$
|
|
2685
|
-
__publicField$
|
|
2686
|
-
__publicField$
|
|
2687
|
-
__publicField$
|
|
2688
|
-
__publicField$
|
|
2689
|
-
__publicField$
|
|
2690
|
-
__publicField$
|
|
3297
|
+
__publicField$n(this, "options");
|
|
3298
|
+
__publicField$n(this, "emitter", new EventEmitter());
|
|
3299
|
+
__publicField$n(this, "name");
|
|
3300
|
+
__publicField$n(this, "item");
|
|
3301
|
+
__publicField$n(this, "_blocked", false);
|
|
3302
|
+
__publicField$n(this, "_container");
|
|
3303
|
+
__publicField$n(this, "_value");
|
|
3304
|
+
__publicField$n(this, "_removeEventsListener");
|
|
2691
3305
|
this.item = item;
|
|
2692
3306
|
this.options = Object.assign({}, options);
|
|
2693
3307
|
this.name = name;
|
|
@@ -2784,23 +3398,23 @@ class BaseProperty {
|
|
|
2784
3398
|
}
|
|
2785
3399
|
}
|
|
2786
3400
|
|
|
2787
|
-
var __defProp$
|
|
3401
|
+
var __defProp$x = Object.defineProperty;
|
|
2788
3402
|
var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
|
|
2789
3403
|
var __hasOwnProp$p = Object.prototype.hasOwnProperty;
|
|
2790
3404
|
var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
|
|
2791
|
-
var __defNormalProp$
|
|
3405
|
+
var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2792
3406
|
var __spreadValues$o = (a, b) => {
|
|
2793
3407
|
for (var prop in b || (b = {}))
|
|
2794
3408
|
if (__hasOwnProp$p.call(b, prop))
|
|
2795
|
-
__defNormalProp$
|
|
3409
|
+
__defNormalProp$x(a, prop, b[prop]);
|
|
2796
3410
|
if (__getOwnPropSymbols$p)
|
|
2797
3411
|
for (var prop of __getOwnPropSymbols$p(b)) {
|
|
2798
3412
|
if (__propIsEnum$p.call(b, prop))
|
|
2799
|
-
__defNormalProp$
|
|
3413
|
+
__defNormalProp$x(a, prop, b[prop]);
|
|
2800
3414
|
}
|
|
2801
3415
|
return a;
|
|
2802
3416
|
};
|
|
2803
|
-
var __publicField$
|
|
3417
|
+
var __publicField$m = (obj, key, value) => __defNormalProp$x(obj, key + "" , value);
|
|
2804
3418
|
const _CheckProperty = class _CheckProperty extends BaseProperty {
|
|
2805
3419
|
constructor(name, item, options) {
|
|
2806
3420
|
super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
|
|
@@ -2908,7 +3522,7 @@ const _CheckProperty = class _CheckProperty extends BaseProperty {
|
|
|
2908
3522
|
}
|
|
2909
3523
|
}
|
|
2910
3524
|
};
|
|
2911
|
-
__publicField$
|
|
3525
|
+
__publicField$m(_CheckProperty, "options", {
|
|
2912
3526
|
hierarchy: true,
|
|
2913
3527
|
bubble: false,
|
|
2914
3528
|
propagation: false,
|
|
@@ -2917,31 +3531,31 @@ __publicField$l(_CheckProperty, "options", {
|
|
|
2917
3531
|
});
|
|
2918
3532
|
let CheckProperty = _CheckProperty;
|
|
2919
3533
|
|
|
2920
|
-
var __defProp$
|
|
3534
|
+
var __defProp$w = Object.defineProperty;
|
|
2921
3535
|
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
2922
3536
|
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
2923
3537
|
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
2924
|
-
var __defNormalProp$
|
|
3538
|
+
var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2925
3539
|
var __spreadValues$n = (a, b) => {
|
|
2926
3540
|
for (var prop in b || (b = {}))
|
|
2927
3541
|
if (__hasOwnProp$o.call(b, prop))
|
|
2928
|
-
__defNormalProp$
|
|
3542
|
+
__defNormalProp$w(a, prop, b[prop]);
|
|
2929
3543
|
if (__getOwnPropSymbols$o)
|
|
2930
3544
|
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
2931
3545
|
if (__propIsEnum$o.call(b, prop))
|
|
2932
|
-
__defNormalProp$
|
|
3546
|
+
__defNormalProp$w(a, prop, b[prop]);
|
|
2933
3547
|
}
|
|
2934
3548
|
return a;
|
|
2935
3549
|
};
|
|
2936
|
-
var __publicField$
|
|
3550
|
+
var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2937
3551
|
const BOOLEAN_TYPE = "boolean";
|
|
2938
3552
|
const STRING_TYPE = "string";
|
|
2939
3553
|
const _ItemProperties = class _ItemProperties {
|
|
2940
3554
|
constructor(item, propertiesList) {
|
|
2941
3555
|
this.item = item;
|
|
2942
|
-
__publicField$
|
|
2943
|
-
__publicField$
|
|
2944
|
-
__publicField$
|
|
3556
|
+
__publicField$l(this, "options", {});
|
|
3557
|
+
__publicField$l(this, "_properties", {});
|
|
3558
|
+
__publicField$l(this, "_propertiesList", []);
|
|
2945
3559
|
if (propertiesList) {
|
|
2946
3560
|
propertiesList.forEach(this._setPropertyHandler.bind(this));
|
|
2947
3561
|
}
|
|
@@ -3004,35 +3618,35 @@ const _ItemProperties = class _ItemProperties {
|
|
|
3004
3618
|
return Handler;
|
|
3005
3619
|
}
|
|
3006
3620
|
};
|
|
3007
|
-
__publicField$
|
|
3621
|
+
__publicField$l(_ItemProperties, "handlers", {
|
|
3008
3622
|
CheckProperty
|
|
3009
3623
|
});
|
|
3010
3624
|
let ItemProperties = _ItemProperties;
|
|
3011
3625
|
|
|
3012
|
-
var __defProp$
|
|
3626
|
+
var __defProp$v = Object.defineProperty;
|
|
3013
3627
|
var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
|
|
3014
3628
|
var __hasOwnProp$n = Object.prototype.hasOwnProperty;
|
|
3015
3629
|
var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
|
|
3016
|
-
var __defNormalProp$
|
|
3630
|
+
var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3017
3631
|
var __spreadValues$m = (a, b) => {
|
|
3018
3632
|
for (var prop in b || (b = {}))
|
|
3019
3633
|
if (__hasOwnProp$n.call(b, prop))
|
|
3020
|
-
__defNormalProp$
|
|
3634
|
+
__defNormalProp$v(a, prop, b[prop]);
|
|
3021
3635
|
if (__getOwnPropSymbols$n)
|
|
3022
3636
|
for (var prop of __getOwnPropSymbols$n(b)) {
|
|
3023
3637
|
if (__propIsEnum$n.call(b, prop))
|
|
3024
|
-
__defNormalProp$
|
|
3638
|
+
__defNormalProp$v(a, prop, b[prop]);
|
|
3025
3639
|
}
|
|
3026
3640
|
return a;
|
|
3027
3641
|
};
|
|
3028
|
-
var __publicField$
|
|
3642
|
+
var __publicField$k = (obj, key, value) => __defNormalProp$v(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3029
3643
|
let ID$1 = 0;
|
|
3030
3644
|
class Item {
|
|
3031
3645
|
constructor(options) {
|
|
3032
|
-
__publicField$
|
|
3033
|
-
__publicField$
|
|
3034
|
-
__publicField$
|
|
3035
|
-
__publicField$
|
|
3646
|
+
__publicField$k(this, "options", {});
|
|
3647
|
+
__publicField$k(this, "properties");
|
|
3648
|
+
__publicField$k(this, "tree");
|
|
3649
|
+
__publicField$k(this, "id", ID$1);
|
|
3036
3650
|
ID$1 += 1;
|
|
3037
3651
|
this.options = __spreadValues$m({}, options);
|
|
3038
3652
|
this.tree = new TreeHelper(this);
|
|
@@ -3046,7 +3660,7 @@ class WebmapLayerOpacityPropertyHandler extends BaseProperty {
|
|
|
3046
3660
|
getProperty() {
|
|
3047
3661
|
const layer = this.item.layer;
|
|
3048
3662
|
if (layer) {
|
|
3049
|
-
return layer && layer.options && layer.options.opacity !== void 0 ? layer.options.opacity : 1;
|
|
3663
|
+
return layer && layer.options && layer.options.opacity !== void 0 && layer.options.opacity !== null ? layer.options.opacity : 1;
|
|
3050
3664
|
}
|
|
3051
3665
|
return 1;
|
|
3052
3666
|
}
|
|
@@ -3086,25 +3700,25 @@ class WebmapLayerOpacityPropertyHandler extends BaseProperty {
|
|
|
3086
3700
|
}
|
|
3087
3701
|
}
|
|
3088
3702
|
|
|
3089
|
-
var __defProp$
|
|
3090
|
-
var __defProps$
|
|
3091
|
-
var __getOwnPropDescs$
|
|
3703
|
+
var __defProp$u = Object.defineProperty;
|
|
3704
|
+
var __defProps$d = Object.defineProperties;
|
|
3705
|
+
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
3092
3706
|
var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
|
|
3093
3707
|
var __hasOwnProp$m = Object.prototype.hasOwnProperty;
|
|
3094
3708
|
var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
|
|
3095
|
-
var __defNormalProp$
|
|
3709
|
+
var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3096
3710
|
var __spreadValues$l = (a, b) => {
|
|
3097
3711
|
for (var prop in b || (b = {}))
|
|
3098
3712
|
if (__hasOwnProp$m.call(b, prop))
|
|
3099
|
-
__defNormalProp$
|
|
3713
|
+
__defNormalProp$u(a, prop, b[prop]);
|
|
3100
3714
|
if (__getOwnPropSymbols$m)
|
|
3101
3715
|
for (var prop of __getOwnPropSymbols$m(b)) {
|
|
3102
3716
|
if (__propIsEnum$m.call(b, prop))
|
|
3103
|
-
__defNormalProp$
|
|
3717
|
+
__defNormalProp$u(a, prop, b[prop]);
|
|
3104
3718
|
}
|
|
3105
3719
|
return a;
|
|
3106
3720
|
};
|
|
3107
|
-
var __spreadProps$
|
|
3721
|
+
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
3108
3722
|
function getNgwWebmapExtent(webmap) {
|
|
3109
3723
|
const bottom = webmap["extent_bottom"];
|
|
3110
3724
|
const left = webmap["extent_left"];
|
|
@@ -3127,7 +3741,7 @@ function fetchNgwLayerExtent({
|
|
|
3127
3741
|
cache = true,
|
|
3128
3742
|
signal
|
|
3129
3743
|
}) {
|
|
3130
|
-
return connector.
|
|
3744
|
+
return connector.route("layer.extent", { id: Number(resourceId) }).get({ cache, signal }).then((resp) => {
|
|
3131
3745
|
if (resp) {
|
|
3132
3746
|
const { maxLat, maxLon, minLat, minLon } = resp.extent;
|
|
3133
3747
|
const extentArray = [minLon, minLat, maxLon, maxLat];
|
|
@@ -3142,11 +3756,10 @@ function fetchNgwLayerItemExtent({
|
|
|
3142
3756
|
cache = true,
|
|
3143
3757
|
signal
|
|
3144
3758
|
}) {
|
|
3145
|
-
return connector.
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
).then((resp) => {
|
|
3759
|
+
return connector.route("feature_layer.feature.item_extent", {
|
|
3760
|
+
id: Number(resourceId),
|
|
3761
|
+
fid: featureId
|
|
3762
|
+
}).get({ cache, signal }).then((resp) => {
|
|
3150
3763
|
if (resp) {
|
|
3151
3764
|
const { maxLat, maxLon, minLat, minLon } = resp.extent;
|
|
3152
3765
|
const extentArray = [minLon, minLat, maxLon, maxLat];
|
|
@@ -3169,17 +3782,17 @@ function fetchNgwResourceExtent(item, connector, options) {
|
|
|
3169
3782
|
return Promise.resolve(getNgwWebmapExtent(item.webmap));
|
|
3170
3783
|
} else {
|
|
3171
3784
|
const resource = item.resource;
|
|
3172
|
-
if (resource.cls && resource.cls.indexOf("style") !== -1) {
|
|
3785
|
+
if (resource.cls && resource.parent && resource.cls.indexOf("style") !== -1) {
|
|
3173
3786
|
return connector.getResource(resource.parent.id, options).then((res) => {
|
|
3174
3787
|
if (res) {
|
|
3175
|
-
return fetchNgwLayerExtent(__spreadProps$
|
|
3788
|
+
return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
|
|
3176
3789
|
resourceId: res.resource.id,
|
|
3177
3790
|
connector
|
|
3178
3791
|
}));
|
|
3179
3792
|
}
|
|
3180
3793
|
});
|
|
3181
3794
|
} else {
|
|
3182
|
-
return fetchNgwLayerExtent(__spreadProps$
|
|
3795
|
+
return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
|
|
3183
3796
|
resourceId: resource.id,
|
|
3184
3797
|
connector
|
|
3185
3798
|
}));
|
|
@@ -3187,10 +3800,10 @@ function fetchNgwResourceExtent(item, connector, options) {
|
|
|
3187
3800
|
}
|
|
3188
3801
|
}
|
|
3189
3802
|
|
|
3190
|
-
var __defProp$
|
|
3191
|
-
var __defNormalProp$
|
|
3192
|
-
var __publicField$
|
|
3193
|
-
var __async$
|
|
3803
|
+
var __defProp$t = Object.defineProperty;
|
|
3804
|
+
var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3805
|
+
var __publicField$j = (obj, key, value) => __defNormalProp$t(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3806
|
+
var __async$o = (__this, __arguments, generator) => {
|
|
3194
3807
|
return new Promise((resolve, reject) => {
|
|
3195
3808
|
var fulfilled = (value) => {
|
|
3196
3809
|
try {
|
|
@@ -3212,18 +3825,18 @@ var __async$n = (__this, __arguments, generator) => {
|
|
|
3212
3825
|
};
|
|
3213
3826
|
class NgwResource {
|
|
3214
3827
|
constructor() {
|
|
3215
|
-
__publicField$
|
|
3216
|
-
__publicField$
|
|
3217
|
-
__publicField$
|
|
3828
|
+
__publicField$j(this, "item");
|
|
3829
|
+
__publicField$j(this, "connector");
|
|
3830
|
+
__publicField$j(this, "_extent");
|
|
3218
3831
|
}
|
|
3219
3832
|
/** @deprecated use {@link NgwResource.getBounds} instead */
|
|
3220
3833
|
getExtent() {
|
|
3221
|
-
return __async$
|
|
3834
|
+
return __async$o(this, null, function* () {
|
|
3222
3835
|
return this.getBounds();
|
|
3223
3836
|
});
|
|
3224
3837
|
}
|
|
3225
3838
|
getBounds(options) {
|
|
3226
|
-
return __async$
|
|
3839
|
+
return __async$o(this, null, function* () {
|
|
3227
3840
|
if (this._extent) {
|
|
3228
3841
|
return this._extent;
|
|
3229
3842
|
}
|
|
@@ -3239,7 +3852,7 @@ class NgwResource {
|
|
|
3239
3852
|
}
|
|
3240
3853
|
}
|
|
3241
3854
|
|
|
3242
|
-
var __async$
|
|
3855
|
+
var __async$n = (__this, __arguments, generator) => {
|
|
3243
3856
|
return new Promise((resolve, reject) => {
|
|
3244
3857
|
var fulfilled = (value) => {
|
|
3245
3858
|
try {
|
|
@@ -3260,7 +3873,7 @@ var __async$m = (__this, __arguments, generator) => {
|
|
|
3260
3873
|
});
|
|
3261
3874
|
};
|
|
3262
3875
|
function resourceIdFromLayerOptions(options, connector) {
|
|
3263
|
-
return __async$
|
|
3876
|
+
return __async$n(this, null, function* () {
|
|
3264
3877
|
const resource = options.resource;
|
|
3265
3878
|
const item = resource;
|
|
3266
3879
|
let { keyname, resourceId } = options;
|
|
@@ -3333,23 +3946,23 @@ function updateQmsOptions(qms) {
|
|
|
3333
3946
|
};
|
|
3334
3947
|
}
|
|
3335
3948
|
|
|
3336
|
-
var __defProp$
|
|
3949
|
+
var __defProp$s = Object.defineProperty;
|
|
3337
3950
|
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
|
|
3338
3951
|
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
|
|
3339
3952
|
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
|
|
3340
|
-
var __defNormalProp$
|
|
3953
|
+
var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3341
3954
|
var __spreadValues$k = (a, b) => {
|
|
3342
3955
|
for (var prop in b || (b = {}))
|
|
3343
3956
|
if (__hasOwnProp$l.call(b, prop))
|
|
3344
|
-
__defNormalProp$
|
|
3957
|
+
__defNormalProp$s(a, prop, b[prop]);
|
|
3345
3958
|
if (__getOwnPropSymbols$l)
|
|
3346
3959
|
for (var prop of __getOwnPropSymbols$l(b)) {
|
|
3347
3960
|
if (__propIsEnum$l.call(b, prop))
|
|
3348
|
-
__defNormalProp$
|
|
3961
|
+
__defNormalProp$s(a, prop, b[prop]);
|
|
3349
3962
|
}
|
|
3350
3963
|
return a;
|
|
3351
3964
|
};
|
|
3352
|
-
var __objRest$
|
|
3965
|
+
var __objRest$2 = (source, exclude) => {
|
|
3353
3966
|
var target = {};
|
|
3354
3967
|
for (var prop in source)
|
|
3355
3968
|
if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -3361,8 +3974,8 @@ var __objRest$1 = (source, exclude) => {
|
|
|
3361
3974
|
}
|
|
3362
3975
|
return target;
|
|
3363
3976
|
};
|
|
3364
|
-
var __publicField$
|
|
3365
|
-
var __async$
|
|
3977
|
+
var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3978
|
+
var __async$m = (__this, __arguments, generator) => {
|
|
3366
3979
|
return new Promise((resolve, reject) => {
|
|
3367
3980
|
var fulfilled = (value) => {
|
|
3368
3981
|
try {
|
|
@@ -3386,7 +3999,7 @@ const URL = "https://qms.nextgis.com";
|
|
|
3386
3999
|
function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
|
|
3387
4000
|
let webMap;
|
|
3388
4001
|
if ("webMap" in webMapOrOptions) {
|
|
3389
|
-
const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$
|
|
4002
|
+
const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$2(_a, ["webMap", "url"]);
|
|
3390
4003
|
webMap = webMap_;
|
|
3391
4004
|
if (url_) {
|
|
3392
4005
|
url = url_;
|
|
@@ -3402,9 +4015,9 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
|
|
|
3402
4015
|
}
|
|
3403
4016
|
class QmsAdapter {
|
|
3404
4017
|
constructor(map, options) {
|
|
3405
|
-
__publicField$
|
|
3406
|
-
__publicField$
|
|
3407
|
-
__publicField$
|
|
4018
|
+
__publicField$i(this, "qms");
|
|
4019
|
+
__publicField$i(this, "options");
|
|
4020
|
+
__publicField$i(this, "map");
|
|
3408
4021
|
this.map = map;
|
|
3409
4022
|
const opt = __spreadValues$k(__spreadValues$k({}, createOpt), options);
|
|
3410
4023
|
this.options = opt;
|
|
@@ -3414,7 +4027,7 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
|
|
|
3414
4027
|
}
|
|
3415
4028
|
}
|
|
3416
4029
|
addLayer(options) {
|
|
3417
|
-
return __async$
|
|
4030
|
+
return __async$m(this, null, function* () {
|
|
3418
4031
|
if (!this.qms && options.qmsId) {
|
|
3419
4032
|
try {
|
|
3420
4033
|
this.qms = yield loadJson(
|
|
@@ -3458,29 +4071,29 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
|
|
|
3458
4071
|
return QmsAdapter;
|
|
3459
4072
|
}
|
|
3460
4073
|
|
|
3461
|
-
var __defProp$
|
|
4074
|
+
var __defProp$r = Object.defineProperty;
|
|
3462
4075
|
var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
|
|
3463
4076
|
var __hasOwnProp$k = Object.prototype.hasOwnProperty;
|
|
3464
4077
|
var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
|
|
3465
|
-
var __defNormalProp$
|
|
4078
|
+
var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3466
4079
|
var __spreadValues$j = (a, b) => {
|
|
3467
4080
|
for (var prop in b || (b = {}))
|
|
3468
4081
|
if (__hasOwnProp$k.call(b, prop))
|
|
3469
|
-
__defNormalProp$
|
|
4082
|
+
__defNormalProp$r(a, prop, b[prop]);
|
|
3470
4083
|
if (__getOwnPropSymbols$k)
|
|
3471
4084
|
for (var prop of __getOwnPropSymbols$k(b)) {
|
|
3472
4085
|
if (__propIsEnum$k.call(b, prop))
|
|
3473
|
-
__defNormalProp$
|
|
4086
|
+
__defNormalProp$r(a, prop, b[prop]);
|
|
3474
4087
|
}
|
|
3475
4088
|
return a;
|
|
3476
4089
|
};
|
|
3477
|
-
var __publicField$
|
|
4090
|
+
var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3478
4091
|
class QmsKit {
|
|
3479
4092
|
constructor(options) {
|
|
3480
|
-
__publicField$
|
|
4093
|
+
__publicField$h(this, "options", {
|
|
3481
4094
|
url: "https://qms.nextgis.com"
|
|
3482
4095
|
});
|
|
3483
|
-
__publicField$
|
|
4096
|
+
__publicField$h(this, "url");
|
|
3484
4097
|
this.options = __spreadValues$j(__spreadValues$j({}, this.options), options);
|
|
3485
4098
|
this.url = this.options.url;
|
|
3486
4099
|
}
|
|
@@ -3496,33 +4109,33 @@ class QmsKit {
|
|
|
3496
4109
|
return createQmsAdapter({ webMap, url: this.url });
|
|
3497
4110
|
}
|
|
3498
4111
|
}
|
|
3499
|
-
__publicField$
|
|
4112
|
+
__publicField$h(QmsKit, "utils", {
|
|
3500
4113
|
createQmsAdapter
|
|
3501
4114
|
});
|
|
3502
4115
|
|
|
3503
|
-
var __defProp$
|
|
3504
|
-
var __defProps$
|
|
3505
|
-
var __getOwnPropDescs$
|
|
4116
|
+
var __defProp$q = Object.defineProperty;
|
|
4117
|
+
var __defProps$c = Object.defineProperties;
|
|
4118
|
+
var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
|
|
3506
4119
|
var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
|
|
3507
4120
|
var __getProtoOf$2 = Object.getPrototypeOf;
|
|
3508
4121
|
var __hasOwnProp$j = Object.prototype.hasOwnProperty;
|
|
3509
4122
|
var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
|
|
3510
4123
|
var __reflectGet$2 = Reflect.get;
|
|
3511
|
-
var __defNormalProp$
|
|
4124
|
+
var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3512
4125
|
var __spreadValues$i = (a, b) => {
|
|
3513
4126
|
for (var prop in b || (b = {}))
|
|
3514
4127
|
if (__hasOwnProp$j.call(b, prop))
|
|
3515
|
-
__defNormalProp$
|
|
4128
|
+
__defNormalProp$q(a, prop, b[prop]);
|
|
3516
4129
|
if (__getOwnPropSymbols$j)
|
|
3517
4130
|
for (var prop of __getOwnPropSymbols$j(b)) {
|
|
3518
4131
|
if (__propIsEnum$j.call(b, prop))
|
|
3519
|
-
__defNormalProp$
|
|
4132
|
+
__defNormalProp$q(a, prop, b[prop]);
|
|
3520
4133
|
}
|
|
3521
4134
|
return a;
|
|
3522
4135
|
};
|
|
3523
|
-
var __spreadProps$
|
|
4136
|
+
var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
|
|
3524
4137
|
var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
|
|
3525
|
-
var __async$
|
|
4138
|
+
var __async$l = (__this, __arguments, generator) => {
|
|
3526
4139
|
return new Promise((resolve, reject) => {
|
|
3527
4140
|
var fulfilled = (value) => {
|
|
3528
4141
|
try {
|
|
@@ -3543,7 +4156,7 @@ var __async$k = (__this, __arguments, generator) => {
|
|
|
3543
4156
|
});
|
|
3544
4157
|
};
|
|
3545
4158
|
function createBasemapLayerAdapter(_0) {
|
|
3546
|
-
return __async$
|
|
4159
|
+
return __async$l(this, arguments, function* ({
|
|
3547
4160
|
webMap,
|
|
3548
4161
|
item
|
|
3549
4162
|
}) {
|
|
@@ -3564,8 +4177,10 @@ function createBasemapLayerAdapter(_0) {
|
|
|
3564
4177
|
if (TileAdapter) {
|
|
3565
4178
|
class BasemapTileAdapter extends TileAdapter {
|
|
3566
4179
|
addLayer(opt) {
|
|
3567
|
-
return __async$
|
|
3568
|
-
|
|
4180
|
+
return __async$l(this, null, function* () {
|
|
4181
|
+
if (url) {
|
|
4182
|
+
return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$c(__spreadValues$i({}, opt), { url }));
|
|
4183
|
+
}
|
|
3569
4184
|
});
|
|
3570
4185
|
}
|
|
3571
4186
|
}
|
|
@@ -3607,13 +4222,9 @@ function fetchNgwLayerCount({
|
|
|
3607
4222
|
cache = true,
|
|
3608
4223
|
signal
|
|
3609
4224
|
}) {
|
|
3610
|
-
return connector.
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
{
|
|
3614
|
-
id: resourceId
|
|
3615
|
-
}
|
|
3616
|
-
).then((resp) => {
|
|
4225
|
+
return connector.route("feature_layer.feature.count", {
|
|
4226
|
+
id: resourceId
|
|
4227
|
+
}).get({ cache, signal }).then((resp) => {
|
|
3617
4228
|
return resp.total_count;
|
|
3618
4229
|
});
|
|
3619
4230
|
}
|
|
@@ -3644,26 +4255,26 @@ function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
|
3644
4255
|
return fields;
|
|
3645
4256
|
}
|
|
3646
4257
|
|
|
3647
|
-
var __defProp$
|
|
3648
|
-
var __defProps$
|
|
3649
|
-
var __getOwnPropDescs$
|
|
4258
|
+
var __defProp$p = Object.defineProperty;
|
|
4259
|
+
var __defProps$b = Object.defineProperties;
|
|
4260
|
+
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
3650
4261
|
var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
|
|
3651
4262
|
var __hasOwnProp$i = Object.prototype.hasOwnProperty;
|
|
3652
4263
|
var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
|
|
3653
|
-
var __defNormalProp$
|
|
4264
|
+
var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3654
4265
|
var __spreadValues$h = (a, b) => {
|
|
3655
4266
|
for (var prop in b || (b = {}))
|
|
3656
4267
|
if (__hasOwnProp$i.call(b, prop))
|
|
3657
|
-
__defNormalProp$
|
|
4268
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
3658
4269
|
if (__getOwnPropSymbols$i)
|
|
3659
4270
|
for (var prop of __getOwnPropSymbols$i(b)) {
|
|
3660
4271
|
if (__propIsEnum$i.call(b, prop))
|
|
3661
|
-
__defNormalProp$
|
|
4272
|
+
__defNormalProp$p(a, prop, b[prop]);
|
|
3662
4273
|
}
|
|
3663
4274
|
return a;
|
|
3664
4275
|
};
|
|
3665
|
-
var __spreadProps$
|
|
3666
|
-
var __async$
|
|
4276
|
+
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
4277
|
+
var __async$k = (__this, __arguments, generator) => {
|
|
3667
4278
|
return new Promise((resolve, reject) => {
|
|
3668
4279
|
var fulfilled = (value) => {
|
|
3669
4280
|
try {
|
|
@@ -3684,17 +4295,17 @@ var __async$j = (__this, __arguments, generator) => {
|
|
|
3684
4295
|
});
|
|
3685
4296
|
};
|
|
3686
4297
|
function fetchNgwLayerItems(options) {
|
|
3687
|
-
return __async$
|
|
4298
|
+
return __async$k(this, null, function* () {
|
|
3688
4299
|
var _a;
|
|
3689
4300
|
const filters = options.filters;
|
|
3690
4301
|
if (filters) {
|
|
3691
|
-
let data = yield createFeatureFieldFilterQueries(__spreadProps$
|
|
4302
|
+
let data = yield createFeatureFieldFilterQueries(__spreadProps$b(__spreadValues$h({}, options), {
|
|
3692
4303
|
filters
|
|
3693
4304
|
}));
|
|
3694
4305
|
const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
|
|
3695
4306
|
if (clientFilterValidate) {
|
|
3696
4307
|
data = data.filter((y) => {
|
|
3697
|
-
const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$
|
|
4308
|
+
const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$b(__spreadValues$h({}, y.fields), {
|
|
3698
4309
|
id: y.id
|
|
3699
4310
|
}));
|
|
3700
4311
|
const result = propertiesFilter(fields, filters);
|
|
@@ -3723,7 +4334,7 @@ function isFilterWithAnyCase(filters) {
|
|
|
3723
4334
|
return false;
|
|
3724
4335
|
}
|
|
3725
4336
|
|
|
3726
|
-
var __async$
|
|
4337
|
+
var __async$j = (__this, __arguments, generator) => {
|
|
3727
4338
|
return new Promise((resolve, reject) => {
|
|
3728
4339
|
var fulfilled = (value) => {
|
|
3729
4340
|
try {
|
|
@@ -3744,7 +4355,7 @@ var __async$i = (__this, __arguments, generator) => {
|
|
|
3744
4355
|
});
|
|
3745
4356
|
};
|
|
3746
4357
|
function fetchNgwLayerFeatures(options) {
|
|
3747
|
-
return __async$
|
|
4358
|
+
return __async$j(this, null, function* () {
|
|
3748
4359
|
const x = yield fetchNgwLayerItems(options);
|
|
3749
4360
|
const features = [];
|
|
3750
4361
|
x.forEach((y) => {
|
|
@@ -3782,30 +4393,30 @@ function getLayerFilterOptions(options) {
|
|
|
3782
4393
|
return filterOptions;
|
|
3783
4394
|
}
|
|
3784
4395
|
|
|
3785
|
-
var __defProp$
|
|
3786
|
-
var __defProps$
|
|
3787
|
-
var __getOwnPropDescs$
|
|
4396
|
+
var __defProp$o = Object.defineProperty;
|
|
4397
|
+
var __defProps$a = Object.defineProperties;
|
|
4398
|
+
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
3788
4399
|
var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
|
|
3789
4400
|
var __getProtoOf$1 = Object.getPrototypeOf;
|
|
3790
4401
|
var __hasOwnProp$h = Object.prototype.hasOwnProperty;
|
|
3791
4402
|
var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
|
|
3792
4403
|
var __reflectGet$1 = Reflect.get;
|
|
3793
|
-
var __defNormalProp$
|
|
4404
|
+
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3794
4405
|
var __spreadValues$g = (a, b) => {
|
|
3795
4406
|
for (var prop in b || (b = {}))
|
|
3796
4407
|
if (__hasOwnProp$h.call(b, prop))
|
|
3797
|
-
__defNormalProp$
|
|
4408
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
3798
4409
|
if (__getOwnPropSymbols$h)
|
|
3799
4410
|
for (var prop of __getOwnPropSymbols$h(b)) {
|
|
3800
4411
|
if (__propIsEnum$h.call(b, prop))
|
|
3801
|
-
__defNormalProp$
|
|
4412
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
3802
4413
|
}
|
|
3803
4414
|
return a;
|
|
3804
4415
|
};
|
|
3805
|
-
var __spreadProps$
|
|
3806
|
-
var __publicField$
|
|
4416
|
+
var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
|
|
4417
|
+
var __publicField$g = (obj, key, value) => __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3807
4418
|
var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
|
|
3808
|
-
var __async$
|
|
4419
|
+
var __async$i = (__this, __arguments, generator) => {
|
|
3809
4420
|
return new Promise((resolve, reject) => {
|
|
3810
4421
|
var fulfilled = (value) => {
|
|
3811
4422
|
try {
|
|
@@ -3826,7 +4437,7 @@ var __async$h = (__this, __arguments, generator) => {
|
|
|
3826
4437
|
});
|
|
3827
4438
|
};
|
|
3828
4439
|
function createGeoJsonAdapter(props) {
|
|
3829
|
-
return __async$
|
|
4440
|
+
return __async$i(this, null, function* () {
|
|
3830
4441
|
var _a, _b;
|
|
3831
4442
|
const {
|
|
3832
4443
|
item,
|
|
@@ -3849,7 +4460,7 @@ function createGeoJsonAdapter(props) {
|
|
|
3849
4460
|
return feature && createPopupContent(feature, item);
|
|
3850
4461
|
};
|
|
3851
4462
|
}
|
|
3852
|
-
const getData = (filters, filterOpt) => __async$
|
|
4463
|
+
const getData = (filters, filterOpt) => __async$i(this, null, function* () {
|
|
3853
4464
|
abort();
|
|
3854
4465
|
internalAbortController = new AbortController();
|
|
3855
4466
|
const internalSignal = internalAbortController.signal;
|
|
@@ -3876,14 +4487,14 @@ function createGeoJsonAdapter(props) {
|
|
|
3876
4487
|
class NgwGeoJsonAdapter extends GeoJsonAdapter {
|
|
3877
4488
|
constructor() {
|
|
3878
4489
|
super(...arguments);
|
|
3879
|
-
__publicField$
|
|
3880
|
-
__publicField$
|
|
3881
|
-
__publicField$
|
|
3882
|
-
__publicField$
|
|
3883
|
-
__publicField$
|
|
4490
|
+
__publicField$g(this, "emitter", new EventEmitter());
|
|
4491
|
+
__publicField$g(this, "__onMapMove");
|
|
4492
|
+
__publicField$g(this, "__onMapMoveStart");
|
|
4493
|
+
__publicField$g(this, "__enableMapMoveListener");
|
|
4494
|
+
__publicField$g(this, "__disableMapMoveListener");
|
|
3884
4495
|
}
|
|
3885
4496
|
addLayer(opt) {
|
|
3886
|
-
return __async$
|
|
4497
|
+
return __async$i(this, null, function* () {
|
|
3887
4498
|
let needUpdate = !opt.data;
|
|
3888
4499
|
const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
|
|
3889
4500
|
if (options.id !== void 0) {
|
|
@@ -3928,7 +4539,7 @@ function createGeoJsonAdapter(props) {
|
|
|
3928
4539
|
return this.getBounds();
|
|
3929
4540
|
}
|
|
3930
4541
|
getBounds() {
|
|
3931
|
-
return __async$
|
|
4542
|
+
return __async$i(this, null, function* () {
|
|
3932
4543
|
const hasData = this.getLayers && this.getLayers().length;
|
|
3933
4544
|
const strategy = this.options.strategy;
|
|
3934
4545
|
if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
|
|
@@ -3953,10 +4564,10 @@ function createGeoJsonAdapter(props) {
|
|
|
3953
4564
|
getCount() {
|
|
3954
4565
|
return fetchNgwLayerCount({ connector, resourceId, cache: true });
|
|
3955
4566
|
}
|
|
3956
|
-
updateLayer(
|
|
3957
|
-
return __async$
|
|
4567
|
+
updateLayer(opt) {
|
|
4568
|
+
return __async$i(this, null, function* () {
|
|
3958
4569
|
var _a2;
|
|
3959
|
-
filterArgs =
|
|
4570
|
+
const filterArgs = opt || _lastFilterArgs || {};
|
|
3960
4571
|
if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
|
|
3961
4572
|
yield webMap.onLoad("create");
|
|
3962
4573
|
filterArgs.options = filterArgs.options || {};
|
|
@@ -3981,7 +4592,7 @@ function createGeoJsonAdapter(props) {
|
|
|
3981
4592
|
try {
|
|
3982
4593
|
this.emitter.emit("preupdate", filterArgs);
|
|
3983
4594
|
webMap._emitLayerEvent("layer:preupdate", options.id || "", filterArgs);
|
|
3984
|
-
const data = yield getData(filterArgs.filters, __spreadProps$
|
|
4595
|
+
const data = yield getData(filterArgs.filters, __spreadProps$a(__spreadValues$g({}, filterArgs.options), {
|
|
3985
4596
|
srs: this.options.srs
|
|
3986
4597
|
}));
|
|
3987
4598
|
let newData = data;
|
|
@@ -4010,7 +4621,7 @@ function createGeoJsonAdapter(props) {
|
|
|
4010
4621
|
isFull: _fullDataLoad
|
|
4011
4622
|
});
|
|
4012
4623
|
} catch (er) {
|
|
4013
|
-
if (er instanceof Error && er.name !== "
|
|
4624
|
+
if (er instanceof Error && er.name !== "AbortError") {
|
|
4014
4625
|
throw er;
|
|
4015
4626
|
}
|
|
4016
4627
|
}
|
|
@@ -4020,7 +4631,7 @@ function createGeoJsonAdapter(props) {
|
|
|
4020
4631
|
});
|
|
4021
4632
|
}
|
|
4022
4633
|
propertiesFilter(filters, opt) {
|
|
4023
|
-
return __async$
|
|
4634
|
+
return __async$i(this, null, function* () {
|
|
4024
4635
|
abort();
|
|
4025
4636
|
if (this.filter && _fullDataLoad) {
|
|
4026
4637
|
this.filter((e) => {
|
|
@@ -4034,7 +4645,7 @@ function createGeoJsonAdapter(props) {
|
|
|
4034
4645
|
if (this.clearLayer) {
|
|
4035
4646
|
this.clearLayer();
|
|
4036
4647
|
}
|
|
4037
|
-
const data = yield getData(filters, __spreadProps$
|
|
4648
|
+
const data = yield getData(filters, __spreadProps$a(__spreadValues$g({}, opt), {
|
|
4038
4649
|
srs: this.options.srs
|
|
4039
4650
|
}));
|
|
4040
4651
|
this.setData(data);
|
|
@@ -4094,7 +4705,7 @@ function createGeoJsonAdapter(props) {
|
|
|
4094
4705
|
});
|
|
4095
4706
|
}
|
|
4096
4707
|
|
|
4097
|
-
var __async$
|
|
4708
|
+
var __async$h = (__this, __arguments, generator) => {
|
|
4098
4709
|
return new Promise((resolve, reject) => {
|
|
4099
4710
|
var fulfilled = (value) => {
|
|
4100
4711
|
try {
|
|
@@ -4115,7 +4726,7 @@ var __async$g = (__this, __arguments, generator) => {
|
|
|
4115
4726
|
});
|
|
4116
4727
|
};
|
|
4117
4728
|
function createWebMapAdapter(_0) {
|
|
4118
|
-
return __async$
|
|
4729
|
+
return __async$h(this, arguments, function* ({
|
|
4119
4730
|
layerOptions: options,
|
|
4120
4731
|
webMap,
|
|
4121
4732
|
connector
|
|
@@ -4223,27 +4834,27 @@ function ngwApiToAdapterOptions({
|
|
|
4223
4834
|
}
|
|
4224
4835
|
}
|
|
4225
4836
|
|
|
4226
|
-
var __defProp$
|
|
4227
|
-
var __defProps$
|
|
4228
|
-
var __getOwnPropDescs$
|
|
4837
|
+
var __defProp$n = Object.defineProperty;
|
|
4838
|
+
var __defProps$9 = Object.defineProperties;
|
|
4839
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
4229
4840
|
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
4230
4841
|
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
4231
4842
|
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
4232
|
-
var __defNormalProp$
|
|
4843
|
+
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4233
4844
|
var __spreadValues$f = (a, b) => {
|
|
4234
4845
|
for (var prop in b || (b = {}))
|
|
4235
4846
|
if (__hasOwnProp$g.call(b, prop))
|
|
4236
|
-
__defNormalProp$
|
|
4847
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
4237
4848
|
if (__getOwnPropSymbols$g)
|
|
4238
4849
|
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
4239
4850
|
if (__propIsEnum$g.call(b, prop))
|
|
4240
|
-
__defNormalProp$
|
|
4851
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
4241
4852
|
}
|
|
4242
4853
|
return a;
|
|
4243
4854
|
};
|
|
4244
|
-
var __spreadProps$
|
|
4245
|
-
var __publicField$
|
|
4246
|
-
var __async$
|
|
4855
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
4856
|
+
var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4857
|
+
var __async$g = (__this, __arguments, generator) => {
|
|
4247
4858
|
return new Promise((resolve, reject) => {
|
|
4248
4859
|
var fulfilled = (value) => {
|
|
4249
4860
|
try {
|
|
@@ -4263,11 +4874,47 @@ var __async$f = (__this, __arguments, generator) => {
|
|
|
4263
4874
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
4264
4875
|
});
|
|
4265
4876
|
};
|
|
4877
|
+
class Legend {
|
|
4878
|
+
constructor({
|
|
4879
|
+
layerId,
|
|
4880
|
+
legend,
|
|
4881
|
+
onSymbolRenderChange
|
|
4882
|
+
}) {
|
|
4883
|
+
__publicField$f(this, "layerId");
|
|
4884
|
+
__publicField$f(this, "legend");
|
|
4885
|
+
__publicField$f(this, "onSymbolRenderChange");
|
|
4886
|
+
this.layerId = layerId;
|
|
4887
|
+
this.legend = this.createLegend(legend);
|
|
4888
|
+
this.onSymbolRenderChange = onSymbolRenderChange;
|
|
4889
|
+
}
|
|
4890
|
+
createLegend(items) {
|
|
4891
|
+
return items.map((params) => __spreadProps$9(__spreadValues$f({}, params), {
|
|
4892
|
+
/** @deprecated use display_name instead */
|
|
4893
|
+
name: params.display_name,
|
|
4894
|
+
/** @deprecated use icon instead */
|
|
4895
|
+
symbol: params.icon
|
|
4896
|
+
}));
|
|
4897
|
+
}
|
|
4898
|
+
setSymbolRender(symbolIndex, status) {
|
|
4899
|
+
const legendItem = this.legend.find((l) => l.index === symbolIndex);
|
|
4900
|
+
if (legendItem) {
|
|
4901
|
+
const render = legendItem.render;
|
|
4902
|
+
if (render !== status) {
|
|
4903
|
+
legendItem.render = status;
|
|
4904
|
+
if (this.onSymbolRenderChange) {
|
|
4905
|
+
this.onSymbolRenderChange(
|
|
4906
|
+
this.legend.filter((l) => l.render).map((l) => l.index)
|
|
4907
|
+
);
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4266
4913
|
function createRasterAdapter(_0) {
|
|
4267
|
-
return __async$
|
|
4914
|
+
return __async$g(this, arguments, function* ({
|
|
4268
4915
|
layerOptions,
|
|
4269
|
-
webMap,
|
|
4270
4916
|
connector,
|
|
4917
|
+
webMap,
|
|
4271
4918
|
item
|
|
4272
4919
|
}) {
|
|
4273
4920
|
const resourceCls = item.resource.cls;
|
|
@@ -4296,16 +4943,17 @@ function createRasterAdapter(_0) {
|
|
|
4296
4943
|
constructor(map, _options) {
|
|
4297
4944
|
super(map, _options);
|
|
4298
4945
|
this.map = map;
|
|
4299
|
-
|
|
4300
|
-
__publicField$
|
|
4301
|
-
__publicField$
|
|
4946
|
+
__publicField$f(this, "item", item);
|
|
4947
|
+
__publicField$f(this, "resourceId", resourceId);
|
|
4948
|
+
__publicField$f(this, "_blocked", false);
|
|
4949
|
+
__publicField$f(this, "_layerVisibility");
|
|
4302
4950
|
const opt = ngwApiToAdapterOptions({
|
|
4303
4951
|
options: layerOptions,
|
|
4304
4952
|
webMap,
|
|
4305
4953
|
baseUrl: connector.options.baseUrl || ""
|
|
4306
4954
|
});
|
|
4307
4955
|
if (opt) {
|
|
4308
|
-
const layerAdapterOptions = __spreadProps$
|
|
4956
|
+
const layerAdapterOptions = __spreadProps$9(__spreadValues$f(__spreadValues$f({}, opt), layerOptions.adapterOptions), {
|
|
4309
4957
|
params: { resource: resourceId },
|
|
4310
4958
|
layers: opt.layers || String(resourceId),
|
|
4311
4959
|
resourceId
|
|
@@ -4319,42 +4967,98 @@ function createRasterAdapter(_0) {
|
|
|
4319
4967
|
addLayer(addOptions) {
|
|
4320
4968
|
return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
|
|
4321
4969
|
}
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
}, options));
|
|
4328
|
-
const id = this.options.id;
|
|
4329
|
-
if (id !== void 0) {
|
|
4330
|
-
const legend = {
|
|
4331
|
-
layerId: id,
|
|
4332
|
-
legend: ngwLegend.map(({ display_name, icon }) => ({
|
|
4333
|
-
name: display_name,
|
|
4334
|
-
symbol: icon
|
|
4335
|
-
}))
|
|
4336
|
-
};
|
|
4337
|
-
return [legend];
|
|
4970
|
+
showLayer() {
|
|
4971
|
+
this._layerVisibility = true;
|
|
4972
|
+
if (this.layer) {
|
|
4973
|
+
if (!this._blocked) {
|
|
4974
|
+
webMap.mapAdapter.showLayer(this.layer);
|
|
4338
4975
|
}
|
|
4339
|
-
|
|
4340
|
-
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
hideLayer() {
|
|
4979
|
+
this._layerVisibility = false;
|
|
4980
|
+
if (this.layer) {
|
|
4981
|
+
webMap.mapAdapter.hideLayer(this.layer);
|
|
4982
|
+
}
|
|
4341
4983
|
}
|
|
4342
4984
|
getIdentificationIds() {
|
|
4343
|
-
return __async$
|
|
4985
|
+
return __async$g(this, null, function* () {
|
|
4344
4986
|
if (this.item) {
|
|
4345
4987
|
if (adapter === "MVT") {
|
|
4346
4988
|
return [this.item.resource.id];
|
|
4347
4989
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4990
|
+
if (this.item.resource.parent) {
|
|
4991
|
+
const id = this.item.resource.parent.id;
|
|
4992
|
+
if (defined(id)) {
|
|
4993
|
+
return [id];
|
|
4994
|
+
}
|
|
4351
4995
|
}
|
|
4352
4996
|
}
|
|
4353
4997
|
return [];
|
|
4354
4998
|
});
|
|
4355
4999
|
}
|
|
4356
|
-
|
|
4357
|
-
|
|
5000
|
+
getLegend(options) {
|
|
5001
|
+
return __async$g(this, null, function* () {
|
|
5002
|
+
const id = this.options.id;
|
|
5003
|
+
if (id !== void 0) {
|
|
5004
|
+
const ngwLegend = yield connector.route("render.legend_symbols", { id: resourceId }).get(__spreadValues$f({
|
|
5005
|
+
cache: true
|
|
5006
|
+
}, options));
|
|
5007
|
+
const legend = new Legend({
|
|
5008
|
+
layerId: id,
|
|
5009
|
+
legend: ngwLegend,
|
|
5010
|
+
onSymbolRenderChange: this._setLegendSymbol.bind(this)
|
|
5011
|
+
});
|
|
5012
|
+
return [legend];
|
|
5013
|
+
}
|
|
5014
|
+
return [];
|
|
5015
|
+
});
|
|
5016
|
+
}
|
|
5017
|
+
_hideLayer() {
|
|
5018
|
+
if (this.options.id) {
|
|
5019
|
+
webMap.mapAdapter.hideLayer(this.layer);
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
_showLayer() {
|
|
5023
|
+
if (this.options.id) {
|
|
5024
|
+
if (this._layerVisibility) {
|
|
5025
|
+
webMap.showLayer(this.options.id, { silent: true });
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
5029
|
+
_setLegendSymbol(renderIndexes) {
|
|
5030
|
+
const intervals = this._consolidateIntervals(renderIndexes);
|
|
5031
|
+
if (!intervals.length) {
|
|
5032
|
+
this._hideLayer();
|
|
5033
|
+
this._blocked = true;
|
|
5034
|
+
} else {
|
|
5035
|
+
this._blocked = false;
|
|
5036
|
+
this._showLayer();
|
|
5037
|
+
}
|
|
5038
|
+
if (this.updateLayer) {
|
|
5039
|
+
this.updateLayer({
|
|
5040
|
+
params: {
|
|
5041
|
+
[`symbols[${resourceId}]`]: intervals.join(",") || void 0
|
|
5042
|
+
}
|
|
5043
|
+
});
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
_consolidateIntervals(symbols) {
|
|
5047
|
+
const sortedSymbols = symbols.slice().sort((a, b) => a - b);
|
|
5048
|
+
const intervals = [];
|
|
5049
|
+
let start = sortedSymbols[0];
|
|
5050
|
+
let end = start;
|
|
5051
|
+
for (let i = 1; i <= sortedSymbols.length; i++) {
|
|
5052
|
+
if (sortedSymbols[i] === end + 1) {
|
|
5053
|
+
end = sortedSymbols[i];
|
|
5054
|
+
} else {
|
|
5055
|
+
intervals.push(start === end ? `${start}` : `${start}-${end}`);
|
|
5056
|
+
start = sortedSymbols[i];
|
|
5057
|
+
end = start;
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
return intervals;
|
|
5061
|
+
}
|
|
4358
5062
|
};
|
|
4359
5063
|
} else {
|
|
4360
5064
|
throw new Error(adapter + " not supported yet. Only TILE");
|
|
@@ -4362,26 +5066,26 @@ function createRasterAdapter(_0) {
|
|
|
4362
5066
|
});
|
|
4363
5067
|
}
|
|
4364
5068
|
|
|
4365
|
-
var __defProp$
|
|
4366
|
-
var __defProps$
|
|
4367
|
-
var __getOwnPropDescs$
|
|
5069
|
+
var __defProp$m = Object.defineProperty;
|
|
5070
|
+
var __defProps$8 = Object.defineProperties;
|
|
5071
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
4368
5072
|
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
4369
5073
|
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
4370
5074
|
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
4371
|
-
var __defNormalProp$
|
|
5075
|
+
var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4372
5076
|
var __spreadValues$e = (a, b) => {
|
|
4373
5077
|
for (var prop in b || (b = {}))
|
|
4374
5078
|
if (__hasOwnProp$f.call(b, prop))
|
|
4375
|
-
__defNormalProp$
|
|
5079
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
4376
5080
|
if (__getOwnPropSymbols$f)
|
|
4377
5081
|
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
4378
5082
|
if (__propIsEnum$f.call(b, prop))
|
|
4379
|
-
__defNormalProp$
|
|
5083
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
4380
5084
|
}
|
|
4381
5085
|
return a;
|
|
4382
5086
|
};
|
|
4383
|
-
var __spreadProps$
|
|
4384
|
-
var __async$
|
|
5087
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
5088
|
+
var __async$f = (__this, __arguments, generator) => {
|
|
4385
5089
|
return new Promise((resolve, reject) => {
|
|
4386
5090
|
var fulfilled = (value) => {
|
|
4387
5091
|
try {
|
|
@@ -4417,7 +5121,7 @@ const supportCls = [
|
|
|
4417
5121
|
"tmsclient_layer"
|
|
4418
5122
|
];
|
|
4419
5123
|
function createAdapterFromFirstStyle(_0) {
|
|
4420
|
-
return __async$
|
|
5124
|
+
return __async$f(this, arguments, function* ({
|
|
4421
5125
|
layerOptions,
|
|
4422
5126
|
webMap,
|
|
4423
5127
|
connector,
|
|
@@ -4428,7 +5132,7 @@ function createAdapterFromFirstStyle(_0) {
|
|
|
4428
5132
|
const firstStyle = childrenStyles && childrenStyles[0];
|
|
4429
5133
|
if (firstStyle) {
|
|
4430
5134
|
return createAsyncAdapter(
|
|
4431
|
-
__spreadProps$
|
|
5135
|
+
__spreadProps$8(__spreadValues$e({}, layerOptions), { resource: firstStyle.resource.id }),
|
|
4432
5136
|
webMap,
|
|
4433
5137
|
connector
|
|
4434
5138
|
);
|
|
@@ -4436,7 +5140,7 @@ function createAdapterFromFirstStyle(_0) {
|
|
|
4436
5140
|
});
|
|
4437
5141
|
}
|
|
4438
5142
|
function createAsyncAdapter(options, webMap, connector) {
|
|
4439
|
-
return __async$
|
|
5143
|
+
return __async$f(this, null, function* () {
|
|
4440
5144
|
let adapter;
|
|
4441
5145
|
let item;
|
|
4442
5146
|
const adapterType = options.adapter;
|
|
@@ -4451,13 +5155,13 @@ function createAsyncAdapter(options, webMap, connector) {
|
|
|
4451
5155
|
}
|
|
4452
5156
|
if (item) {
|
|
4453
5157
|
const cls = item.resource.cls;
|
|
4454
|
-
const layerOptions = __spreadProps$
|
|
5158
|
+
const layerOptions = __spreadProps$8(__spreadValues$e({}, options), {
|
|
4455
5159
|
resource: resourceId
|
|
4456
5160
|
});
|
|
4457
5161
|
const adapterOptions = {
|
|
4458
5162
|
layerOptions,
|
|
4459
|
-
webMap,
|
|
4460
5163
|
connector,
|
|
5164
|
+
webMap,
|
|
4461
5165
|
item
|
|
4462
5166
|
};
|
|
4463
5167
|
if (supportCls.indexOf(cls) !== -1) {
|
|
@@ -4483,15 +5187,15 @@ function createAsyncAdapter(options, webMap, connector) {
|
|
|
4483
5187
|
} else if (cls === "basemap_layer") {
|
|
4484
5188
|
adapter = createBasemapLayerAdapter(adapterOptions);
|
|
4485
5189
|
} else {
|
|
4486
|
-
if (adapterType === "GEOJSON") {
|
|
5190
|
+
if (adapterType === "GEOJSON" && item.resource.parent) {
|
|
4487
5191
|
const parentItem = yield connector.getResource(
|
|
4488
5192
|
item.resource.parent.id
|
|
4489
5193
|
);
|
|
4490
5194
|
if (parentItem) {
|
|
4491
|
-
const parentOptions = __spreadProps$
|
|
5195
|
+
const parentOptions = __spreadProps$8(__spreadValues$e({}, options), {
|
|
4492
5196
|
resource: item.resource.parent.id
|
|
4493
5197
|
});
|
|
4494
|
-
adapter = createGeoJsonAdapter(__spreadProps$
|
|
5198
|
+
adapter = createGeoJsonAdapter(__spreadProps$8(__spreadValues$e({}, adapterOptions), {
|
|
4495
5199
|
item: parentItem,
|
|
4496
5200
|
layerOptions: parentOptions
|
|
4497
5201
|
}));
|
|
@@ -4535,31 +5239,46 @@ function createAsyncAdapter(options, webMap, connector) {
|
|
|
4535
5239
|
});
|
|
4536
5240
|
}
|
|
4537
5241
|
|
|
4538
|
-
var __defProp$
|
|
5242
|
+
var __defProp$l = Object.defineProperty;
|
|
5243
|
+
var __defProps$7 = Object.defineProperties;
|
|
5244
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
4539
5245
|
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
4540
5246
|
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
4541
5247
|
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
4542
|
-
var __defNormalProp$
|
|
5248
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4543
5249
|
var __spreadValues$d = (a, b) => {
|
|
4544
5250
|
for (var prop in b || (b = {}))
|
|
4545
5251
|
if (__hasOwnProp$e.call(b, prop))
|
|
4546
|
-
__defNormalProp$
|
|
5252
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
4547
5253
|
if (__getOwnPropSymbols$e)
|
|
4548
5254
|
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
4549
5255
|
if (__propIsEnum$e.call(b, prop))
|
|
4550
|
-
__defNormalProp$
|
|
5256
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
4551
5257
|
}
|
|
4552
5258
|
return a;
|
|
4553
5259
|
};
|
|
5260
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
5261
|
+
var __objRest$1 = (source, exclude) => {
|
|
5262
|
+
var target = {};
|
|
5263
|
+
for (var prop in source)
|
|
5264
|
+
if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5265
|
+
target[prop] = source[prop];
|
|
5266
|
+
if (source != null && __getOwnPropSymbols$e)
|
|
5267
|
+
for (var prop of __getOwnPropSymbols$e(source)) {
|
|
5268
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
|
|
5269
|
+
target[prop] = source[prop];
|
|
5270
|
+
}
|
|
5271
|
+
return target;
|
|
5272
|
+
};
|
|
4554
5273
|
function updateImageParams(params, resourceId) {
|
|
4555
|
-
const { bbox, width, height, nd } =
|
|
4556
|
-
return {
|
|
5274
|
+
const _a = params, { bbox, width, height, nd } = _a, rest = __objRest$1(_a, ["bbox", "width", "height", "nd"]);
|
|
5275
|
+
return __spreadProps$7(__spreadValues$d({}, rest), {
|
|
4557
5276
|
resource: Array.isArray(resourceId) ? resourceId.join(",") : resourceId,
|
|
4558
5277
|
extent: bbox,
|
|
4559
5278
|
size: width + "," + height,
|
|
4560
5279
|
timestamp: Date.now(),
|
|
4561
5280
|
nd: nd != null ? nd : 200
|
|
4562
|
-
};
|
|
5281
|
+
});
|
|
4563
5282
|
}
|
|
4564
5283
|
const vectorLayerGeomToPaintTypeAlias = {
|
|
4565
5284
|
POINT: "point",
|
|
@@ -4580,6 +5299,9 @@ function createNgwLayerAdapter(options, webMap, connector) {
|
|
|
4580
5299
|
if (headers) {
|
|
4581
5300
|
options.headers = headers;
|
|
4582
5301
|
}
|
|
5302
|
+
if (connector.withCredentials !== void 0) {
|
|
5303
|
+
options.withCredentials = connector.withCredentials;
|
|
5304
|
+
}
|
|
4583
5305
|
return createAsyncAdapter(options, webMap, connector);
|
|
4584
5306
|
}
|
|
4585
5307
|
function extendNgwWebmapLayerAdapter(opt) {
|
|
@@ -4616,24 +5338,27 @@ function setScaleRatio(scale, lat = 0) {
|
|
|
4616
5338
|
return zoom;
|
|
4617
5339
|
}
|
|
4618
5340
|
|
|
4619
|
-
var __defProp$
|
|
5341
|
+
var __defProp$k = Object.defineProperty;
|
|
5342
|
+
var __defProps$6 = Object.defineProperties;
|
|
5343
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
4620
5344
|
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
4621
5345
|
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
4622
5346
|
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
4623
|
-
var __defNormalProp$
|
|
5347
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4624
5348
|
var __spreadValues$c = (a, b) => {
|
|
4625
5349
|
for (var prop in b || (b = {}))
|
|
4626
5350
|
if (__hasOwnProp$d.call(b, prop))
|
|
4627
|
-
__defNormalProp$
|
|
5351
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
4628
5352
|
if (__getOwnPropSymbols$d)
|
|
4629
5353
|
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
4630
5354
|
if (__propIsEnum$d.call(b, prop))
|
|
4631
|
-
__defNormalProp$
|
|
5355
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
4632
5356
|
}
|
|
4633
5357
|
return a;
|
|
4634
5358
|
};
|
|
4635
|
-
var
|
|
4636
|
-
var
|
|
5359
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
5360
|
+
var __publicField$e = (obj, key, value) => __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5361
|
+
var __async$e = (__this, __arguments, generator) => {
|
|
4637
5362
|
return new Promise((resolve, reject) => {
|
|
4638
5363
|
var fulfilled = (value) => {
|
|
4639
5364
|
try {
|
|
@@ -4657,11 +5382,11 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4657
5382
|
constructor(webMap, item, options, connector, parent, noInit) {
|
|
4658
5383
|
super(__spreadValues$c(__spreadValues$c({}, _NgwWebmapItem.options), options));
|
|
4659
5384
|
this.webMap = webMap;
|
|
4660
|
-
__publicField$
|
|
4661
|
-
__publicField$
|
|
4662
|
-
__publicField$
|
|
4663
|
-
__publicField$
|
|
4664
|
-
__publicField$
|
|
5385
|
+
__publicField$e(this, "item");
|
|
5386
|
+
__publicField$e(this, "connector");
|
|
5387
|
+
__publicField$e(this, "layer");
|
|
5388
|
+
__publicField$e(this, "emitter", new EventEmitter());
|
|
5389
|
+
__publicField$e(this, "_rootDescendantsCount", 0);
|
|
4665
5390
|
if (connector) {
|
|
4666
5391
|
this.connector = connector;
|
|
4667
5392
|
}
|
|
@@ -4683,7 +5408,7 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4683
5408
|
}
|
|
4684
5409
|
}
|
|
4685
5410
|
static create(webMap, item, options, connector, parent) {
|
|
4686
|
-
return __async$
|
|
5411
|
+
return __async$e(this, null, function* () {
|
|
4687
5412
|
const ngwWebmapItem = new _NgwWebmapItem(
|
|
4688
5413
|
webMap,
|
|
4689
5414
|
item,
|
|
@@ -4712,21 +5437,21 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4712
5437
|
return this.layer;
|
|
4713
5438
|
}
|
|
4714
5439
|
getLegend(options) {
|
|
4715
|
-
return __async$
|
|
5440
|
+
return __async$e(this, null, function* () {
|
|
4716
5441
|
var _a;
|
|
4717
5442
|
const id = (_a = this.layer) == null ? void 0 : _a.id;
|
|
4718
5443
|
if (id !== void 0) {
|
|
4719
5444
|
const connector = this.connector;
|
|
4720
|
-
if (connector) {
|
|
4721
|
-
const ngwLegend = yield connector.
|
|
4722
|
-
params: { id: this.item.resourceId }
|
|
4723
|
-
}, options));
|
|
5445
|
+
if (connector && "resourceId" in this.item) {
|
|
5446
|
+
const ngwLegend = yield connector.route("render.legend_symbols", { id: Number(this.item.resourceId) }).get(__spreadValues$c({}, options));
|
|
4724
5447
|
const legend = {
|
|
4725
5448
|
layerId: id,
|
|
4726
|
-
legend: ngwLegend.map((
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
5449
|
+
legend: ngwLegend.map((legend2) => __spreadValues$c({
|
|
5450
|
+
/** @deprecated use display_name instead */
|
|
5451
|
+
name: legend2.display_name,
|
|
5452
|
+
/** @deprecated use icon instead */
|
|
5453
|
+
symbol: legend2.icon
|
|
5454
|
+
}, legend2))
|
|
4730
5455
|
};
|
|
4731
5456
|
return [legend];
|
|
4732
5457
|
}
|
|
@@ -4737,16 +5462,18 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4737
5462
|
getItemOptions(item) {
|
|
4738
5463
|
const transparency = item.item_type === "layer" && item.layer_transparency;
|
|
4739
5464
|
const opacity = typeof transparency === "number" ? (100 - transparency) / 100 : void 0;
|
|
4740
|
-
const options = {
|
|
5465
|
+
const options = __spreadProps$6(__spreadValues$c({
|
|
4741
5466
|
visibility: false,
|
|
4742
|
-
name: item.display_name
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
5467
|
+
name: item.display_name
|
|
5468
|
+
}, this.options), {
|
|
5469
|
+
params: {
|
|
5470
|
+
resource: "resourceId" in this.item ? this.item.resourceId : void 0,
|
|
5471
|
+
item: this.item
|
|
5472
|
+
}
|
|
5473
|
+
});
|
|
5474
|
+
delete options.id;
|
|
4748
5475
|
if (this.options.order) {
|
|
4749
|
-
const subOrder = this.options.drawOrderEnabled && "draw_order_position" in item ? this._rootDescendantsCount - item.draw_order_position : this.id;
|
|
5476
|
+
const subOrder = this.options.drawOrderEnabled && "draw_order_position" in item && item.draw_order_position !== void 0 && item.draw_order_position !== null ? this._rootDescendantsCount - item.draw_order_position : this.id;
|
|
4750
5477
|
const subLevel = String(subOrder).padStart(4, "0");
|
|
4751
5478
|
options.order = Number((this.options.order | 0) + "." + subLevel);
|
|
4752
5479
|
}
|
|
@@ -4755,17 +5482,16 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4755
5482
|
}
|
|
4756
5483
|
if (item.item_type === "layer") {
|
|
4757
5484
|
const { maxZoom, minZoom } = this._getZoomRange(item);
|
|
4758
|
-
Object.assign(options, {
|
|
4759
|
-
updateWmsParams: item.updateWmsParams
|
|
5485
|
+
Object.assign(options, __spreadProps$6(__spreadValues$c({
|
|
5486
|
+
updateWmsParams: item.updateWmsParams
|
|
5487
|
+
}, options), {
|
|
4760
5488
|
url: item.url,
|
|
4761
|
-
headers: this.options.headers,
|
|
4762
|
-
ratio: this.options.ratio,
|
|
4763
5489
|
maxZoom,
|
|
4764
5490
|
minZoom,
|
|
4765
5491
|
minScale: item.layer_min_scale_denom,
|
|
4766
5492
|
maxScale: item.layer_max_scale_denom,
|
|
4767
5493
|
interactive: item.layer_identifiable
|
|
4768
|
-
});
|
|
5494
|
+
}));
|
|
4769
5495
|
}
|
|
4770
5496
|
if (opacity !== void 0) {
|
|
4771
5497
|
options.opacity = opacity;
|
|
@@ -4803,7 +5529,7 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4803
5529
|
if (enabled) {
|
|
4804
5530
|
this.properties.set("visibility", true);
|
|
4805
5531
|
}
|
|
4806
|
-
if (options.opacity !== void 0) {
|
|
5532
|
+
if (options.opacity !== void 0 && options.opacity !== null) {
|
|
4807
5533
|
this.webMap.setLayerOpacity(l, options.opacity);
|
|
4808
5534
|
}
|
|
4809
5535
|
};
|
|
@@ -4852,8 +5578,8 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
|
|
|
4852
5578
|
return totalValue;
|
|
4853
5579
|
}
|
|
4854
5580
|
};
|
|
4855
|
-
__publicField$
|
|
4856
|
-
__publicField$
|
|
5581
|
+
__publicField$e(_NgwWebmapItem, "GetAdapterFromLayerType", {});
|
|
5582
|
+
__publicField$e(_NgwWebmapItem, "options", {
|
|
4857
5583
|
properties: [
|
|
4858
5584
|
{
|
|
4859
5585
|
type: "boolean",
|
|
@@ -4893,24 +5619,24 @@ __publicField$d(_NgwWebmapItem, "options", {
|
|
|
4893
5619
|
});
|
|
4894
5620
|
let NgwWebmapItem = _NgwWebmapItem;
|
|
4895
5621
|
|
|
4896
|
-
var __defProp$
|
|
5622
|
+
var __defProp$j = Object.defineProperty;
|
|
4897
5623
|
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
4898
5624
|
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
4899
5625
|
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
4900
|
-
var __defNormalProp$
|
|
5626
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4901
5627
|
var __spreadValues$b = (a, b) => {
|
|
4902
5628
|
for (var prop in b || (b = {}))
|
|
4903
5629
|
if (__hasOwnProp$c.call(b, prop))
|
|
4904
|
-
__defNormalProp$
|
|
5630
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
4905
5631
|
if (__getOwnPropSymbols$c)
|
|
4906
5632
|
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
4907
5633
|
if (__propIsEnum$c.call(b, prop))
|
|
4908
|
-
__defNormalProp$
|
|
5634
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
4909
5635
|
}
|
|
4910
5636
|
return a;
|
|
4911
5637
|
};
|
|
4912
|
-
var __publicField$
|
|
4913
|
-
var __async$
|
|
5638
|
+
var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5639
|
+
var __async$d = (__this, __arguments, generator) => {
|
|
4914
5640
|
return new Promise((resolve, reject) => {
|
|
4915
5641
|
var fulfilled = (value) => {
|
|
4916
5642
|
try {
|
|
@@ -4931,7 +5657,7 @@ var __async$c = (__this, __arguments, generator) => {
|
|
|
4931
5657
|
});
|
|
4932
5658
|
};
|
|
4933
5659
|
function createOnFirstShowAdapter(_0) {
|
|
4934
|
-
return __async$
|
|
5660
|
+
return __async$d(this, arguments, function* ({
|
|
4935
5661
|
webMap,
|
|
4936
5662
|
adapterOptions = {},
|
|
4937
5663
|
onLayerAdded,
|
|
@@ -4939,10 +5665,10 @@ function createOnFirstShowAdapter(_0) {
|
|
|
4939
5665
|
}) {
|
|
4940
5666
|
class OnFirstShowAdapter {
|
|
4941
5667
|
constructor() {
|
|
4942
|
-
__publicField$
|
|
4943
|
-
__publicField$
|
|
4944
|
-
__publicField$
|
|
4945
|
-
__publicField$
|
|
5668
|
+
__publicField$d(this, "options", {});
|
|
5669
|
+
__publicField$d(this, "layer", []);
|
|
5670
|
+
__publicField$d(this, "_removed", false);
|
|
5671
|
+
__publicField$d(this, "_creatingInProgress", false);
|
|
4946
5672
|
}
|
|
4947
5673
|
addLayer() {
|
|
4948
5674
|
return this.layer;
|
|
@@ -4957,7 +5683,7 @@ function createOnFirstShowAdapter(_0) {
|
|
|
4957
5683
|
return this._removed;
|
|
4958
5684
|
}
|
|
4959
5685
|
showLayer() {
|
|
4960
|
-
return __async$
|
|
5686
|
+
return __async$d(this, null, function* () {
|
|
4961
5687
|
this.options.visibility = true;
|
|
4962
5688
|
if (this.layer.length) {
|
|
4963
5689
|
for (const x of this.layer) {
|
|
@@ -4969,7 +5695,7 @@ function createOnFirstShowAdapter(_0) {
|
|
|
4969
5695
|
});
|
|
4970
5696
|
}
|
|
4971
5697
|
hideLayer() {
|
|
4972
|
-
return __async$
|
|
5698
|
+
return __async$d(this, null, function* () {
|
|
4973
5699
|
this.options.visibility = false;
|
|
4974
5700
|
if (this.layer) {
|
|
4975
5701
|
for (const x of this.layer) {
|
|
@@ -4979,7 +5705,7 @@ function createOnFirstShowAdapter(_0) {
|
|
|
4979
5705
|
});
|
|
4980
5706
|
}
|
|
4981
5707
|
loadLayer() {
|
|
4982
|
-
return __async$
|
|
5708
|
+
return __async$d(this, null, function* () {
|
|
4983
5709
|
if (!this.layer.length && !this._creatingInProgress) {
|
|
4984
5710
|
this._creatingInProgress = true;
|
|
4985
5711
|
const Adapter = yield createAdapter(this);
|
|
@@ -5013,7 +5739,7 @@ function createOnFirstShowAdapter(_0) {
|
|
|
5013
5739
|
});
|
|
5014
5740
|
}
|
|
5015
5741
|
|
|
5016
|
-
var __async$
|
|
5742
|
+
var __async$c = (__this, __arguments, generator) => {
|
|
5017
5743
|
return new Promise((resolve, reject) => {
|
|
5018
5744
|
var fulfilled = (value) => {
|
|
5019
5745
|
try {
|
|
@@ -5034,7 +5760,7 @@ var __async$b = (__this, __arguments, generator) => {
|
|
|
5034
5760
|
});
|
|
5035
5761
|
};
|
|
5036
5762
|
function createOnFirstShowNgwAdapter(_0) {
|
|
5037
|
-
return __async$
|
|
5763
|
+
return __async$c(this, arguments, function* ({
|
|
5038
5764
|
webMap,
|
|
5039
5765
|
connector,
|
|
5040
5766
|
item,
|
|
@@ -5070,24 +5796,27 @@ function createOnFirstShowNgwAdapter(_0) {
|
|
|
5070
5796
|
|
|
5071
5797
|
const WEBMAP_BASELAYER_ID_PREFIX = "webmap-baselayer";
|
|
5072
5798
|
|
|
5073
|
-
var __defProp$
|
|
5799
|
+
var __defProp$i = Object.defineProperty;
|
|
5800
|
+
var __defProps$5 = Object.defineProperties;
|
|
5801
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
5074
5802
|
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
5075
5803
|
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
5076
5804
|
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
5077
|
-
var __defNormalProp$
|
|
5805
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5078
5806
|
var __spreadValues$a = (a, b) => {
|
|
5079
5807
|
for (var prop in b || (b = {}))
|
|
5080
5808
|
if (__hasOwnProp$b.call(b, prop))
|
|
5081
|
-
__defNormalProp$
|
|
5809
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
5082
5810
|
if (__getOwnPropSymbols$b)
|
|
5083
5811
|
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
5084
5812
|
if (__propIsEnum$b.call(b, prop))
|
|
5085
|
-
__defNormalProp$
|
|
5813
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
5086
5814
|
}
|
|
5087
5815
|
return a;
|
|
5088
5816
|
};
|
|
5089
|
-
var
|
|
5090
|
-
var
|
|
5817
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
5818
|
+
var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5819
|
+
var __async$b = (__this, __arguments, generator) => {
|
|
5091
5820
|
return new Promise((resolve, reject) => {
|
|
5092
5821
|
var fulfilled = (value) => {
|
|
5093
5822
|
try {
|
|
@@ -5111,21 +5840,20 @@ class NgwWebmapLayerAdapter {
|
|
|
5111
5840
|
constructor(map, options) {
|
|
5112
5841
|
this.map = map;
|
|
5113
5842
|
this.options = options;
|
|
5114
|
-
__publicField$
|
|
5115
|
-
__publicField$
|
|
5843
|
+
__publicField$c(this, "layer");
|
|
5844
|
+
__publicField$c(this, "NgwWebmapItem", NgwWebmapItem);
|
|
5116
5845
|
/**
|
|
5117
5846
|
* Radius for searching objects in pixels
|
|
5118
5847
|
*/
|
|
5119
|
-
__publicField$
|
|
5848
|
+
__publicField$c(this, "pixelRadius", 10);
|
|
5120
5849
|
// webmapSettings.identify_radius,
|
|
5121
|
-
__publicField$
|
|
5122
|
-
__publicField$
|
|
5123
|
-
__publicField$
|
|
5124
|
-
__publicField$
|
|
5125
|
-
__publicField$
|
|
5126
|
-
__publicField$
|
|
5127
|
-
__publicField$
|
|
5128
|
-
__publicField$b(this, "_lastActiveBaselayer");
|
|
5850
|
+
__publicField$c(this, "resourceId");
|
|
5851
|
+
__publicField$c(this, "webmapClassName", "webmap");
|
|
5852
|
+
__publicField$c(this, "emitter", new EventEmitter());
|
|
5853
|
+
__publicField$c(this, "_extent");
|
|
5854
|
+
__publicField$c(this, "webmapResource");
|
|
5855
|
+
__publicField$c(this, "_webmapBaselayersIds", []);
|
|
5856
|
+
__publicField$c(this, "_lastActiveBaselayer");
|
|
5129
5857
|
const r = options.resourceId;
|
|
5130
5858
|
if (Array.isArray(r)) {
|
|
5131
5859
|
this.resourceId = r[0];
|
|
@@ -5138,11 +5866,11 @@ class NgwWebmapLayerAdapter {
|
|
|
5138
5866
|
}
|
|
5139
5867
|
}
|
|
5140
5868
|
addLayer(options) {
|
|
5141
|
-
return __async$
|
|
5142
|
-
var _a
|
|
5869
|
+
return __async$b(this, null, function* () {
|
|
5870
|
+
var _a;
|
|
5143
5871
|
this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
|
|
5144
5872
|
this.layer = yield this._getWebMapLayerItem();
|
|
5145
|
-
const extentConstrained = (
|
|
5873
|
+
const extentConstrained = (_a = this.webmapResource) == null ? void 0 : _a.constraining_extent;
|
|
5146
5874
|
if (this.options.useExtentConstrained && this._extent && extentConstrained) {
|
|
5147
5875
|
this.options.webMap.setView({ maxBounds: this._extent });
|
|
5148
5876
|
}
|
|
@@ -5167,25 +5895,24 @@ class NgwWebmapLayerAdapter {
|
|
|
5167
5895
|
this.options.webMap.setView({ maxBounds: null });
|
|
5168
5896
|
}
|
|
5169
5897
|
delete this.layer;
|
|
5170
|
-
delete this.
|
|
5171
|
-
delete this._webmapLayersIds;
|
|
5898
|
+
delete this.webmapResource;
|
|
5172
5899
|
}
|
|
5173
5900
|
showLayer() {
|
|
5174
|
-
return __async$
|
|
5901
|
+
return __async$b(this, null, function* () {
|
|
5175
5902
|
if (this.layer && this.layer.properties) {
|
|
5176
5903
|
return this.layer.properties.property("visibility").set(true);
|
|
5177
5904
|
}
|
|
5178
5905
|
});
|
|
5179
5906
|
}
|
|
5180
5907
|
hideLayer() {
|
|
5181
|
-
return __async$
|
|
5908
|
+
return __async$b(this, null, function* () {
|
|
5182
5909
|
if (this.layer && this.layer.properties) {
|
|
5183
5910
|
return this.layer.properties.property("visibility").set(false);
|
|
5184
5911
|
}
|
|
5185
5912
|
});
|
|
5186
5913
|
}
|
|
5187
5914
|
setOpacity(val) {
|
|
5188
|
-
return __async$
|
|
5915
|
+
return __async$b(this, null, function* () {
|
|
5189
5916
|
if (this.layer && this.layer.properties) {
|
|
5190
5917
|
return this.layer.properties.property("opacity").set(val);
|
|
5191
5918
|
}
|
|
@@ -5196,7 +5923,7 @@ class NgwWebmapLayerAdapter {
|
|
|
5196
5923
|
return this.getBounds();
|
|
5197
5924
|
}
|
|
5198
5925
|
getBounds() {
|
|
5199
|
-
const webmap = this.
|
|
5926
|
+
const webmap = this.webmapResource;
|
|
5200
5927
|
if (webmap) {
|
|
5201
5928
|
return getNgwWebmapExtent(webmap);
|
|
5202
5929
|
}
|
|
@@ -5205,8 +5932,8 @@ class NgwWebmapLayerAdapter {
|
|
|
5205
5932
|
return this.layer && this.layer.tree.getDescendants() || [];
|
|
5206
5933
|
}
|
|
5207
5934
|
getBookmarksResourceId() {
|
|
5208
|
-
const webmap = this.
|
|
5209
|
-
if (webmap) {
|
|
5935
|
+
const webmap = this.webmapResource;
|
|
5936
|
+
if (webmap && webmap.bookmark_resource) {
|
|
5210
5937
|
return webmap.bookmark_resource.id;
|
|
5211
5938
|
}
|
|
5212
5939
|
}
|
|
@@ -5245,7 +5972,7 @@ class NgwWebmapLayerAdapter {
|
|
|
5245
5972
|
);
|
|
5246
5973
|
}
|
|
5247
5974
|
getLegend(options) {
|
|
5248
|
-
return __async$
|
|
5975
|
+
return __async$b(this, null, function* () {
|
|
5249
5976
|
const legends = [];
|
|
5250
5977
|
let deps = this.getDependLayers();
|
|
5251
5978
|
deps = deps.sort((a, b) => b.id - a.id);
|
|
@@ -5257,78 +5984,65 @@ class NgwWebmapLayerAdapter {
|
|
|
5257
5984
|
});
|
|
5258
5985
|
}
|
|
5259
5986
|
getIdentificationIds(options) {
|
|
5260
|
-
return __async$
|
|
5987
|
+
return __async$b(this, null, function* () {
|
|
5261
5988
|
const visibleLayers = [];
|
|
5262
|
-
let
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
const parentId = item.parentId;
|
|
5273
|
-
if (parentId !== void 0 && item.item_type === "layer" && item.layer_identifiable) {
|
|
5274
|
-
const visible = x.properties.property("visibility");
|
|
5275
|
-
const isVisible = visible.get() && !visible.isBlocked();
|
|
5276
|
-
if (isVisible) {
|
|
5277
|
-
visibleLayers.push(parentId);
|
|
5278
|
-
}
|
|
5989
|
+
let deps = this.getDependLayers();
|
|
5990
|
+
deps = deps.sort((a, b) => b.id - a.id);
|
|
5991
|
+
deps.forEach((x) => {
|
|
5992
|
+
const item = x.item;
|
|
5993
|
+
const parentId = "style_parent_id" in item ? item.style_parent_id : void 0;
|
|
5994
|
+
if (parentId !== void 0 && parentId !== null && item.item_type === "layer" && item.layer_identifiable) {
|
|
5995
|
+
const visible = x.properties.property("visibility");
|
|
5996
|
+
const isVisible = visible.get() && !visible.isBlocked();
|
|
5997
|
+
if (isVisible) {
|
|
5998
|
+
visibleLayers.push(parentId);
|
|
5279
5999
|
}
|
|
5280
|
-
}
|
|
5281
|
-
}
|
|
6000
|
+
}
|
|
6001
|
+
});
|
|
5282
6002
|
return visibleLayers;
|
|
5283
6003
|
});
|
|
5284
6004
|
}
|
|
5285
6005
|
_getWebMapLayerItem() {
|
|
5286
|
-
return __async$
|
|
5287
|
-
if (this.resourceId) {
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
const headers = this.options.connector.getAuthorizationHeaders();
|
|
5294
|
-
if (headers) {
|
|
5295
|
-
options.headers = headers;
|
|
5296
|
-
}
|
|
5297
|
-
}
|
|
5298
|
-
options.setViewDelay = this.options.setViewDelay;
|
|
5299
|
-
options.order = this.options.order;
|
|
5300
|
-
options.ratio = this.options.ratio;
|
|
5301
|
-
options.crossOrigin = this.options.crossOrigin;
|
|
5302
|
-
options.minZoom = this.options.minZoom;
|
|
5303
|
-
options.maxZoom = this.options.maxZoom;
|
|
5304
|
-
options.drawOrderEnabled = webmap.draw_order_enabled;
|
|
5305
|
-
options.popupOptions = this.options.popupOptions;
|
|
5306
|
-
const layer = new this.NgwWebmapItem(
|
|
5307
|
-
this.options.webMap,
|
|
5308
|
-
webmap.root_item,
|
|
5309
|
-
options,
|
|
5310
|
-
this.options.connector
|
|
5311
|
-
);
|
|
5312
|
-
layer.emitter.on("init", () => resolve(layer));
|
|
5313
|
-
});
|
|
5314
|
-
}
|
|
6006
|
+
return __async$b(this, null, function* () {
|
|
6007
|
+
if (!this.resourceId) {
|
|
6008
|
+
return void 0;
|
|
6009
|
+
}
|
|
6010
|
+
const webmap = yield this.getWebMapConfig(this.resourceId);
|
|
6011
|
+
if (!webmap || !webmap.root_item) {
|
|
6012
|
+
return void 0;
|
|
5315
6013
|
}
|
|
6014
|
+
return new Promise((resolve) => {
|
|
6015
|
+
var _a;
|
|
6016
|
+
const connector = this.options.connector;
|
|
6017
|
+
const headers = (connector == null ? void 0 : connector.options.auth) ? connector.getAuthorizationHeaders() : void 0;
|
|
6018
|
+
const withCredentials = connector.withCredentials;
|
|
6019
|
+
const options = __spreadProps$5(__spreadValues$a({}, this.options), {
|
|
6020
|
+
withCredentials,
|
|
6021
|
+
headers,
|
|
6022
|
+
drawOrderEnabled: (_a = webmap.draw_order_enabled) != null ? _a : false
|
|
6023
|
+
});
|
|
6024
|
+
const layer = new this.NgwWebmapItem(
|
|
6025
|
+
this.options.webMap,
|
|
6026
|
+
webmap.root_item,
|
|
6027
|
+
options,
|
|
6028
|
+
connector
|
|
6029
|
+
);
|
|
6030
|
+
layer.emitter.on("init", () => {
|
|
6031
|
+
resolve(layer);
|
|
6032
|
+
});
|
|
6033
|
+
});
|
|
5316
6034
|
});
|
|
5317
6035
|
}
|
|
5318
6036
|
getWebMapConfig(id) {
|
|
5319
|
-
return __async$
|
|
6037
|
+
return __async$b(this, null, function* () {
|
|
6038
|
+
var _a;
|
|
5320
6039
|
const data = yield this.options.connector.getResource(id);
|
|
5321
6040
|
if (data) {
|
|
5322
|
-
this.response = data;
|
|
5323
6041
|
const webmap = data[this.webmapClassName];
|
|
6042
|
+
this.webmapResource = webmap;
|
|
5324
6043
|
this._setupBaselayers(data);
|
|
5325
6044
|
if (webmap) {
|
|
5326
|
-
this._extent =
|
|
5327
|
-
webmap.extent_left,
|
|
5328
|
-
webmap.extent_bottom,
|
|
5329
|
-
webmap.extent_right,
|
|
5330
|
-
webmap.extent_top
|
|
5331
|
-
];
|
|
6045
|
+
this._extent = (_a = webmap.initial_extent) != null ? _a : void 0;
|
|
5332
6046
|
this._updateItemsParams(webmap.root_item, this.options.webMap, data);
|
|
5333
6047
|
return webmap;
|
|
5334
6048
|
}
|
|
@@ -5380,23 +6094,25 @@ class NgwWebmapLayerAdapter {
|
|
|
5380
6094
|
_updateItemsParams(item, webMap, data) {
|
|
5381
6095
|
if (item) {
|
|
5382
6096
|
if (item.item_type === "group" || item.item_type === "root") {
|
|
5383
|
-
if (item.children) {
|
|
5384
|
-
|
|
6097
|
+
if ("children" in item && item.children) {
|
|
6098
|
+
const children = item.children.map(
|
|
5385
6099
|
(x) => this._updateItemsParams(x, webMap, data)
|
|
5386
6100
|
);
|
|
6101
|
+
item.children = children;
|
|
5387
6102
|
}
|
|
5388
6103
|
if (item.item_type === "root") {
|
|
5389
6104
|
item.display_name = data.resource.display_name;
|
|
5390
6105
|
}
|
|
5391
6106
|
} else if (item.item_type === "layer") {
|
|
6107
|
+
const layerItem = item;
|
|
5392
6108
|
const url = fixUrlStr(
|
|
5393
6109
|
this.options.connector.options.baseUrl + "/api/component/render/image"
|
|
5394
6110
|
);
|
|
5395
|
-
const resourceId =
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
const adapter =
|
|
6111
|
+
const resourceId = layerItem.layer_style_id;
|
|
6112
|
+
layerItem.url = url;
|
|
6113
|
+
layerItem.resourceId = resourceId;
|
|
6114
|
+
layerItem.updateWmsParams = (params) => updateImageParams(params, resourceId);
|
|
6115
|
+
const adapter = layerItem.layer_adapter.toUpperCase();
|
|
5400
6116
|
const layerAdapterOptions = ngwApiToAdapterOptions({
|
|
5401
6117
|
options: {
|
|
5402
6118
|
adapter,
|
|
@@ -5405,56 +6121,31 @@ class NgwWebmapLayerAdapter {
|
|
|
5405
6121
|
webMap,
|
|
5406
6122
|
baseUrl: this.options.connector.options.baseUrl || ""
|
|
5407
6123
|
});
|
|
5408
|
-
item = __spreadValues$a(__spreadValues$a({},
|
|
6124
|
+
item = __spreadValues$a(__spreadValues$a({}, layerItem), layerAdapterOptions);
|
|
5409
6125
|
}
|
|
5410
6126
|
}
|
|
5411
6127
|
return item;
|
|
5412
6128
|
}
|
|
5413
|
-
_getWebMapIds(options) {
|
|
5414
|
-
return __async$a(this, null, function* () {
|
|
5415
|
-
const webMapItem = this.layer;
|
|
5416
|
-
if (webMapItem && webMapItem.item.item_type === "root") {
|
|
5417
|
-
const layers = webMapItem.tree.getDescendants();
|
|
5418
|
-
const promises = [];
|
|
5419
|
-
for (const x of layers) {
|
|
5420
|
-
const item = x.item;
|
|
5421
|
-
if (item.item_type === "layer") {
|
|
5422
|
-
const id = item.layer_style_id;
|
|
5423
|
-
const promise = this.options.connector.getResource(id, options).then((y) => {
|
|
5424
|
-
if (y) {
|
|
5425
|
-
const parentId = Number(y.resource.parent.id);
|
|
5426
|
-
item.parentId = parentId;
|
|
5427
|
-
return parentId;
|
|
5428
|
-
}
|
|
5429
|
-
});
|
|
5430
|
-
promises.push(promise);
|
|
5431
|
-
}
|
|
5432
|
-
}
|
|
5433
|
-
const ids = yield Promise.all(promises);
|
|
5434
|
-
return ids.filter((x) => x !== void 0);
|
|
5435
|
-
}
|
|
5436
|
-
});
|
|
5437
|
-
}
|
|
5438
6129
|
}
|
|
5439
6130
|
|
|
5440
|
-
var __defProp$
|
|
6131
|
+
var __defProp$h = Object.defineProperty;
|
|
5441
6132
|
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
5442
6133
|
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
5443
6134
|
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
5444
|
-
var __defNormalProp$
|
|
6135
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5445
6136
|
var __spreadValues$9 = (a, b) => {
|
|
5446
6137
|
for (var prop in b || (b = {}))
|
|
5447
6138
|
if (__hasOwnProp$a.call(b, prop))
|
|
5448
|
-
__defNormalProp$
|
|
6139
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
5449
6140
|
if (__getOwnPropSymbols$a)
|
|
5450
6141
|
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
5451
6142
|
if (__propIsEnum$a.call(b, prop))
|
|
5452
|
-
__defNormalProp$
|
|
6143
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
5453
6144
|
}
|
|
5454
6145
|
return a;
|
|
5455
6146
|
};
|
|
5456
|
-
var __publicField$
|
|
5457
|
-
var __async$
|
|
6147
|
+
var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6148
|
+
var __async$a = (__this, __arguments, generator) => {
|
|
5458
6149
|
return new Promise((resolve, reject) => {
|
|
5459
6150
|
var fulfilled = (value) => {
|
|
5460
6151
|
try {
|
|
@@ -5477,9 +6168,9 @@ var __async$9 = (__this, __arguments, generator) => {
|
|
|
5477
6168
|
class NgwKit {
|
|
5478
6169
|
constructor(options) {
|
|
5479
6170
|
this.options = options;
|
|
5480
|
-
__publicField$
|
|
5481
|
-
__publicField$
|
|
5482
|
-
__publicField$
|
|
6171
|
+
__publicField$b(this, "url");
|
|
6172
|
+
__publicField$b(this, "connector");
|
|
6173
|
+
__publicField$b(this, "webMap");
|
|
5483
6174
|
if (this.options.connector) {
|
|
5484
6175
|
this.url = this.options.connector.options.baseUrl || "";
|
|
5485
6176
|
this.connector = this.options.connector;
|
|
@@ -5489,7 +6180,7 @@ class NgwKit {
|
|
|
5489
6180
|
} else {
|
|
5490
6181
|
throw new Error("url is not defined");
|
|
5491
6182
|
}
|
|
5492
|
-
this.connector = new
|
|
6183
|
+
this.connector = new NgwConnectorExtended({
|
|
5493
6184
|
baseUrl: this.url,
|
|
5494
6185
|
auth: this.options.auth
|
|
5495
6186
|
});
|
|
@@ -5499,7 +6190,7 @@ class NgwKit {
|
|
|
5499
6190
|
classAdapters[cls] = adapter;
|
|
5500
6191
|
}
|
|
5501
6192
|
onLoadSync(webMap) {
|
|
5502
|
-
return __async$
|
|
6193
|
+
return __async$a(this, null, function* () {
|
|
5503
6194
|
if (this.options.resourceId && this.url) {
|
|
5504
6195
|
const resourceIds = [this.options.resourceId];
|
|
5505
6196
|
if (resourceIds.length) {
|
|
@@ -5540,37 +6231,57 @@ class NgwKit {
|
|
|
5540
6231
|
}
|
|
5541
6232
|
}
|
|
5542
6233
|
|
|
5543
|
-
var __defProp$
|
|
6234
|
+
var __defProp$g = Object.defineProperty;
|
|
5544
6235
|
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
5545
6236
|
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
5546
6237
|
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
5547
|
-
var __defNormalProp$
|
|
6238
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5548
6239
|
var __spreadValues$8 = (a, b) => {
|
|
5549
6240
|
for (var prop in b || (b = {}))
|
|
5550
6241
|
if (__hasOwnProp$9.call(b, prop))
|
|
5551
|
-
__defNormalProp$
|
|
6242
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
5552
6243
|
if (__getOwnPropSymbols$9)
|
|
5553
6244
|
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
5554
6245
|
if (__propIsEnum$9.call(b, prop))
|
|
5555
|
-
__defNormalProp$
|
|
6246
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
5556
6247
|
}
|
|
5557
6248
|
return a;
|
|
5558
6249
|
};
|
|
5559
|
-
var __publicField$
|
|
6250
|
+
var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6251
|
+
var __async$9 = (__this, __arguments, generator) => {
|
|
6252
|
+
return new Promise((resolve, reject) => {
|
|
6253
|
+
var fulfilled = (value) => {
|
|
6254
|
+
try {
|
|
6255
|
+
step(generator.next(value));
|
|
6256
|
+
} catch (e) {
|
|
6257
|
+
reject(e);
|
|
6258
|
+
}
|
|
6259
|
+
};
|
|
6260
|
+
var rejected = (value) => {
|
|
6261
|
+
try {
|
|
6262
|
+
step(generator.throw(value));
|
|
6263
|
+
} catch (e) {
|
|
6264
|
+
reject(e);
|
|
6265
|
+
}
|
|
6266
|
+
};
|
|
6267
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
6268
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
6269
|
+
});
|
|
6270
|
+
};
|
|
5560
6271
|
class IdentifyItem {
|
|
5561
6272
|
constructor(options) {
|
|
5562
|
-
__publicField$
|
|
5563
|
-
__publicField$
|
|
5564
|
-
__publicField$
|
|
5565
|
-
__publicField$
|
|
5566
|
-
__publicField$
|
|
5567
|
-
__publicField$
|
|
5568
|
-
__publicField$
|
|
5569
|
-
__publicField$
|
|
5570
|
-
__publicField$
|
|
5571
|
-
__publicField$
|
|
5572
|
-
__publicField$
|
|
5573
|
-
__publicField$
|
|
6273
|
+
__publicField$a(this, "id");
|
|
6274
|
+
__publicField$a(this, "label");
|
|
6275
|
+
__publicField$a(this, "layerId");
|
|
6276
|
+
__publicField$a(this, "parent");
|
|
6277
|
+
__publicField$a(this, "fields");
|
|
6278
|
+
__publicField$a(this, "geom");
|
|
6279
|
+
__publicField$a(this, "extensions");
|
|
6280
|
+
__publicField$a(this, "connector");
|
|
6281
|
+
__publicField$a(this, "_item");
|
|
6282
|
+
__publicField$a(this, "_geojson");
|
|
6283
|
+
__publicField$a(this, "_resource");
|
|
6284
|
+
__publicField$a(this, "_extent");
|
|
5574
6285
|
const f = options.feature;
|
|
5575
6286
|
this.id = f.id;
|
|
5576
6287
|
this.geom = f.geom;
|
|
@@ -5598,12 +6309,16 @@ class IdentifyItem {
|
|
|
5598
6309
|
});
|
|
5599
6310
|
}
|
|
5600
6311
|
resource(opt) {
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
6312
|
+
return __async$9(this, null, function* () {
|
|
6313
|
+
if (this._resource && this._resource.feature_layer) {
|
|
6314
|
+
return this._resource.feature_layer;
|
|
6315
|
+
}
|
|
6316
|
+
const resp = yield this.connector.getResource(this.layerId, opt);
|
|
6317
|
+
if (!(resp == null ? void 0 : resp.feature_layer)) {
|
|
6318
|
+
throw new Error("Resource is not avector layer");
|
|
6319
|
+
}
|
|
5605
6320
|
this._resource = resp;
|
|
5606
|
-
return
|
|
6321
|
+
return resp.feature_layer;
|
|
5607
6322
|
});
|
|
5608
6323
|
}
|
|
5609
6324
|
getBounds(opt) {
|
|
@@ -5656,21 +6371,21 @@ function fetchNgwLayerFeature(options) {
|
|
|
5656
6371
|
});
|
|
5657
6372
|
}
|
|
5658
6373
|
|
|
5659
|
-
var __defProp$
|
|
6374
|
+
var __defProp$f = Object.defineProperty;
|
|
5660
6375
|
var __defProps$4 = Object.defineProperties;
|
|
5661
6376
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
5662
6377
|
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
5663
6378
|
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
5664
6379
|
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
5665
|
-
var __defNormalProp$
|
|
6380
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5666
6381
|
var __spreadValues$7 = (a, b) => {
|
|
5667
6382
|
for (var prop in b || (b = {}))
|
|
5668
6383
|
if (__hasOwnProp$8.call(b, prop))
|
|
5669
|
-
__defNormalProp$
|
|
6384
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
5670
6385
|
if (__getOwnPropSymbols$8)
|
|
5671
6386
|
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
5672
6387
|
if (__propIsEnum$8.call(b, prop))
|
|
5673
|
-
__defNormalProp$
|
|
6388
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
5674
6389
|
}
|
|
5675
6390
|
return a;
|
|
5676
6391
|
};
|
|
@@ -5767,13 +6482,13 @@ function featureLayerIdentify(options) {
|
|
|
5767
6482
|
if (!wkt) {
|
|
5768
6483
|
throw new Error("Not valid geometry format to make intersection");
|
|
5769
6484
|
}
|
|
5770
|
-
const
|
|
6485
|
+
const json = {
|
|
5771
6486
|
geom: wkt,
|
|
5772
6487
|
srs: 3857,
|
|
5773
6488
|
layers
|
|
5774
6489
|
};
|
|
5775
|
-
return options.connector.
|
|
5776
|
-
|
|
6490
|
+
return options.connector.route("feature_layer.identify").post({
|
|
6491
|
+
json,
|
|
5777
6492
|
signal,
|
|
5778
6493
|
cache
|
|
5779
6494
|
});
|
|
@@ -5833,9 +6548,11 @@ var __async$7 = (__this, __arguments, generator) => {
|
|
|
5833
6548
|
};
|
|
5834
6549
|
function getCompanyLogo(connector, options) {
|
|
5835
6550
|
return __async$7(this, null, function* () {
|
|
5836
|
-
var _a;
|
|
5837
|
-
const settings = yield connector.
|
|
5838
|
-
|
|
6551
|
+
var _a, _b;
|
|
6552
|
+
const settings = yield connector.route("pyramid.settings").get({
|
|
6553
|
+
query: {
|
|
6554
|
+
component: "pyramid"
|
|
6555
|
+
}
|
|
5839
6556
|
});
|
|
5840
6557
|
if (settings && settings.company_logo && settings.company_logo.enabled) {
|
|
5841
6558
|
const anchor = document.createElement("a");
|
|
@@ -5852,12 +6569,21 @@ function getCompanyLogo(connector, options) {
|
|
|
5852
6569
|
img.style.maxWidth = "100px";
|
|
5853
6570
|
img.src = "";
|
|
5854
6571
|
try {
|
|
5855
|
-
const
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
6572
|
+
const resp = yield connector.route("pyramid.csettings").get();
|
|
6573
|
+
const logo = (_b = resp.pyramid) == null ? void 0 : _b.header_logo;
|
|
6574
|
+
if (logo) {
|
|
6575
|
+
const [mimeType, base64Data] = logo;
|
|
6576
|
+
const byteCharacters = atob(base64Data);
|
|
6577
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
6578
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
6579
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
6580
|
+
}
|
|
6581
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
6582
|
+
const blob = new Blob([byteArray], { type: mimeType });
|
|
6583
|
+
const urlCreator = window.URL || window.webkitURL;
|
|
6584
|
+
const imageUrl = urlCreator.createObjectURL(blob);
|
|
6585
|
+
img.src = imageUrl;
|
|
6586
|
+
}
|
|
5861
6587
|
} catch (er) {
|
|
5862
6588
|
console.warn(er);
|
|
5863
6589
|
}
|
|
@@ -6514,19 +7240,19 @@ const typeExpressions = {
|
|
|
6514
7240
|
typeof: evaluateArgs(([arg]) => typeOfValue(arg))
|
|
6515
7241
|
};
|
|
6516
7242
|
|
|
6517
|
-
var __defProp$
|
|
7243
|
+
var __defProp$e = Object.defineProperty;
|
|
6518
7244
|
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
6519
7245
|
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
6520
7246
|
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
6521
|
-
var __defNormalProp$
|
|
7247
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6522
7248
|
var __spreadValues$6 = (a, b) => {
|
|
6523
7249
|
for (var prop in b || (b = {}))
|
|
6524
7250
|
if (__hasOwnProp$7.call(b, prop))
|
|
6525
|
-
__defNormalProp$
|
|
7251
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
6526
7252
|
if (__getOwnPropSymbols$7)
|
|
6527
7253
|
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
6528
7254
|
if (__propIsEnum$7.call(b, prop))
|
|
6529
|
-
__defNormalProp$
|
|
7255
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
6530
7256
|
}
|
|
6531
7257
|
return a;
|
|
6532
7258
|
};
|
|
@@ -6551,19 +7277,19 @@ function evaluate(expression, data = {}) {
|
|
|
6551
7277
|
throw new Error(`Expression "${name}" is not supported.`);
|
|
6552
7278
|
}
|
|
6553
7279
|
|
|
6554
|
-
var __defProp$
|
|
7280
|
+
var __defProp$d = Object.defineProperty;
|
|
6555
7281
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
6556
7282
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
6557
7283
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
6558
|
-
var __defNormalProp$
|
|
7284
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6559
7285
|
var __spreadValues$5 = (a, b) => {
|
|
6560
7286
|
for (var prop in b || (b = {}))
|
|
6561
7287
|
if (__hasOwnProp$6.call(b, prop))
|
|
6562
|
-
__defNormalProp$
|
|
7288
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
6563
7289
|
if (__getOwnPropSymbols$6)
|
|
6564
7290
|
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
6565
7291
|
if (__propIsEnum$6.call(b, prop))
|
|
6566
|
-
__defNormalProp$
|
|
7292
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
6567
7293
|
}
|
|
6568
7294
|
return a;
|
|
6569
7295
|
};
|
|
@@ -6602,19 +7328,19 @@ function createExpressionCallback(paint) {
|
|
|
6602
7328
|
return;
|
|
6603
7329
|
}
|
|
6604
7330
|
|
|
6605
|
-
var __defProp$
|
|
7331
|
+
var __defProp$c = Object.defineProperty;
|
|
6606
7332
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
6607
7333
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
6608
7334
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
6609
|
-
var __defNormalProp$
|
|
7335
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6610
7336
|
var __spreadValues$4 = (a, b) => {
|
|
6611
7337
|
for (var prop in b || (b = {}))
|
|
6612
7338
|
if (__hasOwnProp$5.call(b, prop))
|
|
6613
|
-
__defNormalProp$
|
|
7339
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
6614
7340
|
if (__getOwnPropSymbols$5)
|
|
6615
7341
|
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
6616
7342
|
if (__propIsEnum$5.call(b, prop))
|
|
6617
|
-
__defNormalProp$
|
|
7343
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
6618
7344
|
}
|
|
6619
7345
|
return a;
|
|
6620
7346
|
};
|
|
@@ -6738,95 +7464,95 @@ function preparePaint({
|
|
|
6738
7464
|
return newPaint;
|
|
6739
7465
|
}
|
|
6740
7466
|
|
|
6741
|
-
var __defProp$
|
|
6742
|
-
var __defNormalProp$
|
|
6743
|
-
var __publicField$
|
|
7467
|
+
var __defProp$b = Object.defineProperty;
|
|
7468
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7469
|
+
var __publicField$9 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6744
7470
|
class KeyCodes {
|
|
6745
7471
|
constructor() {
|
|
6746
|
-
__publicField$
|
|
6747
|
-
__publicField$
|
|
6748
|
-
__publicField$
|
|
6749
|
-
__publicField$
|
|
6750
|
-
__publicField$
|
|
6751
|
-
__publicField$
|
|
6752
|
-
__publicField$
|
|
6753
|
-
__publicField$
|
|
6754
|
-
__publicField$
|
|
6755
|
-
__publicField$
|
|
6756
|
-
__publicField$
|
|
6757
|
-
__publicField$
|
|
6758
|
-
__publicField$
|
|
6759
|
-
__publicField$
|
|
6760
|
-
__publicField$
|
|
6761
|
-
__publicField$
|
|
6762
|
-
__publicField$
|
|
6763
|
-
__publicField$
|
|
6764
|
-
__publicField$
|
|
6765
|
-
__publicField$
|
|
6766
|
-
__publicField$
|
|
6767
|
-
__publicField$
|
|
6768
|
-
__publicField$
|
|
6769
|
-
__publicField$
|
|
6770
|
-
__publicField$
|
|
6771
|
-
__publicField$
|
|
6772
|
-
__publicField$
|
|
6773
|
-
__publicField$
|
|
6774
|
-
__publicField$
|
|
6775
|
-
__publicField$
|
|
6776
|
-
__publicField$
|
|
6777
|
-
__publicField$
|
|
6778
|
-
__publicField$
|
|
6779
|
-
__publicField$
|
|
6780
|
-
__publicField$
|
|
6781
|
-
__publicField$
|
|
6782
|
-
__publicField$
|
|
6783
|
-
__publicField$
|
|
6784
|
-
__publicField$
|
|
6785
|
-
__publicField$
|
|
6786
|
-
__publicField$
|
|
6787
|
-
__publicField$
|
|
6788
|
-
__publicField$
|
|
6789
|
-
__publicField$
|
|
6790
|
-
__publicField$
|
|
6791
|
-
__publicField$
|
|
6792
|
-
__publicField$
|
|
6793
|
-
__publicField$
|
|
6794
|
-
__publicField$
|
|
6795
|
-
__publicField$
|
|
6796
|
-
__publicField$
|
|
6797
|
-
__publicField$
|
|
6798
|
-
__publicField$
|
|
6799
|
-
__publicField$
|
|
7472
|
+
__publicField$9(this, "backspace", 8);
|
|
7473
|
+
__publicField$9(this, "tab", 9);
|
|
7474
|
+
__publicField$9(this, "enter", 13);
|
|
7475
|
+
__publicField$9(this, "shift", 16);
|
|
7476
|
+
__publicField$9(this, "ctrl", 17);
|
|
7477
|
+
__publicField$9(this, "alt", 18);
|
|
7478
|
+
__publicField$9(this, "pause/break", 19);
|
|
7479
|
+
__publicField$9(this, "caps_lock", 20);
|
|
7480
|
+
__publicField$9(this, "escape", 27);
|
|
7481
|
+
__publicField$9(this, "page_up", 33);
|
|
7482
|
+
__publicField$9(this, "page_down", 34);
|
|
7483
|
+
__publicField$9(this, "end", 35);
|
|
7484
|
+
__publicField$9(this, "home", 36);
|
|
7485
|
+
__publicField$9(this, "left_arrow", 37);
|
|
7486
|
+
__publicField$9(this, "up_arrow", 38);
|
|
7487
|
+
__publicField$9(this, "right_arrow", 39);
|
|
7488
|
+
__publicField$9(this, "down_arrow", 40);
|
|
7489
|
+
__publicField$9(this, "insert", 45);
|
|
7490
|
+
__publicField$9(this, "delete", 46);
|
|
7491
|
+
__publicField$9(this, "left_window_key", 91);
|
|
7492
|
+
__publicField$9(this, "right_window_key", 92);
|
|
7493
|
+
__publicField$9(this, "select_key", 93);
|
|
7494
|
+
__publicField$9(this, "numpad_0", 96);
|
|
7495
|
+
__publicField$9(this, "numpad_1", 97);
|
|
7496
|
+
__publicField$9(this, "numpad_2", 98);
|
|
7497
|
+
__publicField$9(this, "numpad_3", 99);
|
|
7498
|
+
__publicField$9(this, "numpad_4", 100);
|
|
7499
|
+
__publicField$9(this, "numpad_5", 101);
|
|
7500
|
+
__publicField$9(this, "numpad_6", 102);
|
|
7501
|
+
__publicField$9(this, "numpad_7", 103);
|
|
7502
|
+
__publicField$9(this, "numpad_8", 104);
|
|
7503
|
+
__publicField$9(this, "numpad_9", 105);
|
|
7504
|
+
__publicField$9(this, "multiply", 106);
|
|
7505
|
+
__publicField$9(this, "add", 107);
|
|
7506
|
+
__publicField$9(this, "subtract", 109);
|
|
7507
|
+
__publicField$9(this, "decimal_point", 110);
|
|
7508
|
+
__publicField$9(this, "divide", 111);
|
|
7509
|
+
__publicField$9(this, "f1", 112);
|
|
7510
|
+
__publicField$9(this, "f2", 113);
|
|
7511
|
+
__publicField$9(this, "f3", 114);
|
|
7512
|
+
__publicField$9(this, "f4", 115);
|
|
7513
|
+
__publicField$9(this, "f5", 116);
|
|
7514
|
+
__publicField$9(this, "f6", 117);
|
|
7515
|
+
__publicField$9(this, "f7", 118);
|
|
7516
|
+
__publicField$9(this, "f8", 119);
|
|
7517
|
+
__publicField$9(this, "f9", 120);
|
|
7518
|
+
__publicField$9(this, "f10", 121);
|
|
7519
|
+
__publicField$9(this, "f11", 122);
|
|
7520
|
+
__publicField$9(this, "f12", 123);
|
|
7521
|
+
__publicField$9(this, "num_lock", 144);
|
|
7522
|
+
__publicField$9(this, "scroll_lock", 145);
|
|
7523
|
+
__publicField$9(this, "semi-colon", 186);
|
|
7524
|
+
__publicField$9(this, "equal_sign", 187);
|
|
7525
|
+
__publicField$9(this, ",", 188);
|
|
6800
7526
|
// "comma";
|
|
6801
|
-
__publicField$
|
|
7527
|
+
__publicField$9(this, "-", 189);
|
|
6802
7528
|
// "dash";
|
|
6803
|
-
__publicField$
|
|
7529
|
+
__publicField$9(this, ".", 190);
|
|
6804
7530
|
// "period";
|
|
6805
|
-
__publicField$
|
|
7531
|
+
__publicField$9(this, "/", 191);
|
|
6806
7532
|
// "forward slash";
|
|
6807
|
-
__publicField$
|
|
7533
|
+
__publicField$9(this, "`", 192);
|
|
6808
7534
|
// "grave accent";
|
|
6809
|
-
__publicField$
|
|
7535
|
+
__publicField$9(this, "[", 219);
|
|
6810
7536
|
// "open bracket";
|
|
6811
|
-
__publicField$
|
|
7537
|
+
__publicField$9(this, "\\", 220);
|
|
6812
7538
|
// "back slash";
|
|
6813
|
-
__publicField$
|
|
7539
|
+
__publicField$9(this, "]", 221);
|
|
6814
7540
|
// "close braket";
|
|
6815
|
-
__publicField$
|
|
7541
|
+
__publicField$9(this, "'", 222);
|
|
6816
7542
|
}
|
|
6817
7543
|
// "single quote"
|
|
6818
7544
|
}
|
|
6819
7545
|
|
|
6820
|
-
var __defProp$
|
|
6821
|
-
var __defNormalProp$
|
|
6822
|
-
var __publicField$
|
|
7546
|
+
var __defProp$a = Object.defineProperty;
|
|
7547
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7548
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6823
7549
|
class Keys {
|
|
6824
7550
|
constructor() {
|
|
6825
|
-
__publicField$
|
|
6826
|
-
__publicField$
|
|
6827
|
-
__publicField$
|
|
6828
|
-
__publicField$
|
|
6829
|
-
__publicField$
|
|
7551
|
+
__publicField$8(this, "keyCodeAlias", new KeyCodes());
|
|
7552
|
+
__publicField$8(this, "keys", {});
|
|
7553
|
+
__publicField$8(this, "_windowOnFocus");
|
|
7554
|
+
__publicField$8(this, "_keysPressed");
|
|
7555
|
+
__publicField$8(this, "_keysReleased");
|
|
6830
7556
|
this._windowOnFocus = this.windowOnFocus.bind(this);
|
|
6831
7557
|
this._keysPressed = this.keysPressed.bind(this);
|
|
6832
7558
|
this._keysReleased = this.keysReleased.bind(this);
|
|
@@ -6865,15 +7591,15 @@ class Keys {
|
|
|
6865
7591
|
}
|
|
6866
7592
|
}
|
|
6867
7593
|
|
|
6868
|
-
var __defProp$
|
|
6869
|
-
var __defNormalProp$
|
|
6870
|
-
var __publicField$
|
|
7594
|
+
var __defProp$9 = Object.defineProperty;
|
|
7595
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7596
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6871
7597
|
class StateItem {
|
|
6872
7598
|
constructor(webMap, opt) {
|
|
6873
7599
|
this.webMap = webMap;
|
|
6874
|
-
__publicField$
|
|
6875
|
-
__publicField$
|
|
6876
|
-
__publicField$
|
|
7600
|
+
__publicField$7(this, "name");
|
|
7601
|
+
__publicField$7(this, "event");
|
|
7602
|
+
__publicField$7(this, "value");
|
|
6877
7603
|
if (opt) {
|
|
6878
7604
|
if (opt.value) {
|
|
6879
7605
|
this.setValue(opt.value);
|
|
@@ -6882,7 +7608,11 @@ class StateItem {
|
|
|
6882
7608
|
this.name = opt.name;
|
|
6883
7609
|
}
|
|
6884
7610
|
if (opt.event) {
|
|
6885
|
-
|
|
7611
|
+
if (typeof opt.event === "string") {
|
|
7612
|
+
this.event = [opt.event];
|
|
7613
|
+
} else {
|
|
7614
|
+
this.event = opt.event;
|
|
7615
|
+
}
|
|
6886
7616
|
}
|
|
6887
7617
|
}
|
|
6888
7618
|
}
|
|
@@ -6894,6 +7624,34 @@ class StateItem {
|
|
|
6894
7624
|
}
|
|
6895
7625
|
}
|
|
6896
7626
|
|
|
7627
|
+
var __defProp$8 = Object.defineProperty;
|
|
7628
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7629
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7630
|
+
class BoundState extends StateItem {
|
|
7631
|
+
constructor() {
|
|
7632
|
+
super(...arguments);
|
|
7633
|
+
__publicField$6(this, "name", "bounds");
|
|
7634
|
+
__publicField$6(this, "event", ["moveend"]);
|
|
7635
|
+
}
|
|
7636
|
+
getValue() {
|
|
7637
|
+
return this.webMap.getBounds();
|
|
7638
|
+
}
|
|
7639
|
+
setValue(bounds) {
|
|
7640
|
+
this.webMap.setView({ bounds });
|
|
7641
|
+
}
|
|
7642
|
+
toString() {
|
|
7643
|
+
const data = this.getValue();
|
|
7644
|
+
if (data) {
|
|
7645
|
+
return data.slice(0, 4).map((x) => x.toFixed(5)).join("_");
|
|
7646
|
+
}
|
|
7647
|
+
return void 0;
|
|
7648
|
+
}
|
|
7649
|
+
parse(str) {
|
|
7650
|
+
const lngLat = str.split("_").map(Number);
|
|
7651
|
+
return lngLat;
|
|
7652
|
+
}
|
|
7653
|
+
}
|
|
7654
|
+
|
|
6897
7655
|
var __defProp$7 = Object.defineProperty;
|
|
6898
7656
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6899
7657
|
var __publicField$5 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -6901,7 +7659,7 @@ class CenterState extends StateItem {
|
|
|
6901
7659
|
constructor() {
|
|
6902
7660
|
super(...arguments);
|
|
6903
7661
|
__publicField$5(this, "name", "center");
|
|
6904
|
-
__publicField$5(this, "event", "moveend");
|
|
7662
|
+
__publicField$5(this, "event", ["moveend"]);
|
|
6905
7663
|
}
|
|
6906
7664
|
getValue() {
|
|
6907
7665
|
return this.webMap.getCenter();
|
|
@@ -6909,9 +7667,13 @@ class CenterState extends StateItem {
|
|
|
6909
7667
|
setValue(val) {
|
|
6910
7668
|
this.webMap.setCenter(val);
|
|
6911
7669
|
}
|
|
6912
|
-
toString(
|
|
6913
|
-
const
|
|
6914
|
-
|
|
7670
|
+
toString() {
|
|
7671
|
+
const data = this.getValue();
|
|
7672
|
+
if (data) {
|
|
7673
|
+
const d = data.map((x) => x.toFixed(5));
|
|
7674
|
+
return d[0] + "_" + d[1];
|
|
7675
|
+
}
|
|
7676
|
+
return "";
|
|
6915
7677
|
}
|
|
6916
7678
|
parse(str) {
|
|
6917
7679
|
const lngLat = str.split("_").map(Number);
|
|
@@ -6926,7 +7688,7 @@ class ZoomState extends StateItem {
|
|
|
6926
7688
|
constructor() {
|
|
6927
7689
|
super(...arguments);
|
|
6928
7690
|
__publicField$4(this, "name", "zoom");
|
|
6929
|
-
__publicField$4(this, "event", "zoomend");
|
|
7691
|
+
__publicField$4(this, "event", ["zoomend"]);
|
|
6930
7692
|
}
|
|
6931
7693
|
getValue() {
|
|
6932
7694
|
const zoom = this.webMap.getZoom();
|
|
@@ -6935,8 +7697,8 @@ class ZoomState extends StateItem {
|
|
|
6935
7697
|
setValue(val) {
|
|
6936
7698
|
this.webMap.setZoom(val);
|
|
6937
7699
|
}
|
|
6938
|
-
toString(
|
|
6939
|
-
return String(
|
|
7700
|
+
toString() {
|
|
7701
|
+
return String(this.getValue());
|
|
6940
7702
|
}
|
|
6941
7703
|
parse(str) {
|
|
6942
7704
|
return Number(str);
|
|
@@ -7005,14 +7767,14 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7005
7767
|
__publicField$3(this, "mapAdapter");
|
|
7006
7768
|
__publicField$3(this, "runtimeParams", []);
|
|
7007
7769
|
__publicField$3(this, "getPaintFunctions", _WebMapMain.getPaintFunctions);
|
|
7008
|
-
__publicField$3(this, "
|
|
7770
|
+
__publicField$3(this, "mapStateItems", [CenterState, ZoomState, BoundState]);
|
|
7009
7771
|
__publicField$3(this, "id", ID++);
|
|
7010
7772
|
/**
|
|
7011
7773
|
* From runtime params
|
|
7012
7774
|
*/
|
|
7775
|
+
__publicField$3(this, "mapState", []);
|
|
7013
7776
|
__publicField$3(this, "_initMapState", {});
|
|
7014
7777
|
__publicField$3(this, "_starterKits");
|
|
7015
|
-
__publicField$3(this, "_mapState", []);
|
|
7016
7778
|
__publicField$3(this, "_extent");
|
|
7017
7779
|
__publicField$3(this, "_eventsStatus", {});
|
|
7018
7780
|
__publicField$3(this, "_coordFromMapClickAbort");
|
|
@@ -7047,7 +7809,7 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7047
7809
|
create() {
|
|
7048
7810
|
return __async$6(this, null, function* () {
|
|
7049
7811
|
if (!this.getEventStatus("create")) {
|
|
7050
|
-
yield this._setInitMapState(this.
|
|
7812
|
+
yield this._setInitMapState(this.mapStateItems);
|
|
7051
7813
|
yield this._setupMap();
|
|
7052
7814
|
this._emitStatusEvent("create", this);
|
|
7053
7815
|
}
|
|
@@ -7067,16 +7829,22 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7067
7829
|
this.mapAdapter.destroy();
|
|
7068
7830
|
}
|
|
7069
7831
|
}
|
|
7070
|
-
|
|
7832
|
+
mapStateWithFunc(func) {
|
|
7071
7833
|
const state = {};
|
|
7072
|
-
this.
|
|
7073
|
-
state[x.name] = x
|
|
7834
|
+
this.mapState.forEach((x) => {
|
|
7835
|
+
state[x.name] = func(x);
|
|
7074
7836
|
});
|
|
7075
7837
|
return state;
|
|
7076
7838
|
}
|
|
7839
|
+
getStateAsString() {
|
|
7840
|
+
return this.mapStateWithFunc((x) => x.toString());
|
|
7841
|
+
}
|
|
7842
|
+
getState() {
|
|
7843
|
+
return this.mapStateWithFunc((x) => x.getValue());
|
|
7844
|
+
}
|
|
7077
7845
|
getRuntimeParams() {
|
|
7078
7846
|
const state = {};
|
|
7079
|
-
this.
|
|
7847
|
+
this.mapState.forEach((x) => {
|
|
7080
7848
|
for (const r of this.runtimeParams) {
|
|
7081
7849
|
const val = r.get(x.name);
|
|
7082
7850
|
if (val !== void 0) {
|
|
@@ -7110,9 +7878,11 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7110
7878
|
* @param cursor - Available cursor name from https://developer.mozilla.org/ru/docs/Web/CSS/cursor
|
|
7111
7879
|
*/
|
|
7112
7880
|
setCursor(cursor) {
|
|
7113
|
-
|
|
7114
|
-
this.mapAdapter.setCursor
|
|
7115
|
-
|
|
7881
|
+
this.onLoad().then(() => {
|
|
7882
|
+
if (this.mapAdapter.setCursor) {
|
|
7883
|
+
this.mapAdapter.setCursor(cursor);
|
|
7884
|
+
}
|
|
7885
|
+
});
|
|
7116
7886
|
}
|
|
7117
7887
|
getCursor() {
|
|
7118
7888
|
if (this.mapAdapter.getCursor) {
|
|
@@ -7418,7 +8188,7 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7418
8188
|
_setInitMapState(states) {
|
|
7419
8189
|
for (const X of states) {
|
|
7420
8190
|
const state = new X(this);
|
|
7421
|
-
this.
|
|
8191
|
+
this.mapState.push(state);
|
|
7422
8192
|
for (const r of this.runtimeParams) {
|
|
7423
8193
|
const str = r.get(state.name);
|
|
7424
8194
|
if (str !== void 0) {
|
|
@@ -7454,13 +8224,15 @@ const _WebMapMain = class _WebMapMain {
|
|
|
7454
8224
|
events.forEach((x) => {
|
|
7455
8225
|
this._mapEvents[x] = (data) => {
|
|
7456
8226
|
if (this.runtimeParams.length) {
|
|
7457
|
-
const
|
|
7458
|
-
|
|
7459
|
-
|
|
8227
|
+
const mapStatusEvents = this.mapState.filter(
|
|
8228
|
+
(y) => y.event.includes(x)
|
|
8229
|
+
);
|
|
8230
|
+
mapStatusEvents.forEach((mapStatusEvent) => {
|
|
8231
|
+
const value = mapStatusEvent.toString();
|
|
7460
8232
|
this.runtimeParams.forEach((r) => {
|
|
7461
8233
|
r.set(mapStatusEvent.name, value);
|
|
7462
8234
|
});
|
|
7463
|
-
}
|
|
8235
|
+
});
|
|
7464
8236
|
}
|
|
7465
8237
|
if (this._eventsStatus) {
|
|
7466
8238
|
this.emitter.emit(x, data);
|
|
@@ -7805,7 +8577,7 @@ class WebMapLayers extends WebMapMain {
|
|
|
7805
8577
|
}
|
|
7806
8578
|
}
|
|
7807
8579
|
const opacity = options.opacity;
|
|
7808
|
-
if (opacity !== void 0 && opacity <= 1) {
|
|
8580
|
+
if (opacity !== void 0 && opacity !== null && opacity <= 1) {
|
|
7809
8581
|
this.setLayerOpacity(_adapter, opacity);
|
|
7810
8582
|
}
|
|
7811
8583
|
const getBounds = layer && (_adapter.getBounds || _adapter.getExtent);
|
|
@@ -8036,11 +8808,11 @@ class WebMapLayers extends WebMapMain {
|
|
|
8036
8808
|
}
|
|
8037
8809
|
return Promise.resolve();
|
|
8038
8810
|
}
|
|
8039
|
-
updateLayer(layerDef) {
|
|
8811
|
+
updateLayer(layerDef, options) {
|
|
8040
8812
|
const layer = this.getLayer(layerDef);
|
|
8041
8813
|
if (layer) {
|
|
8042
8814
|
if (layer.updateLayer) {
|
|
8043
|
-
return Promise.resolve(layer.updateLayer());
|
|
8815
|
+
return Promise.resolve(layer.updateLayer(options));
|
|
8044
8816
|
} else if (this.isLayerVisible(layer)) {
|
|
8045
8817
|
return this.hideLayer(layer, { silent: true }).then(() => {
|
|
8046
8818
|
return this.showLayer(layer, { silent: true });
|
|
@@ -8957,9 +9729,10 @@ function prepareWebMapOptions(options) {
|
|
|
8957
9729
|
});
|
|
8958
9730
|
}
|
|
8959
9731
|
if (!options.connector) {
|
|
8960
|
-
options.connector = new
|
|
9732
|
+
options.connector = new NgwConnectorExtended({
|
|
8961
9733
|
baseUrl: options.baseUrl || "",
|
|
8962
|
-
auth: options.auth
|
|
9734
|
+
auth: options.auth,
|
|
9735
|
+
withCredentials: options.withCredentials
|
|
8963
9736
|
});
|
|
8964
9737
|
} else if (options.connector) {
|
|
8965
9738
|
options.baseUrl = options.connector.options.baseUrl;
|
|
@@ -9188,8 +9961,16 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9188
9961
|
this._addPromise("identify", promise, abortController);
|
|
9189
9962
|
return promise;
|
|
9190
9963
|
}
|
|
9191
|
-
fetchIdentifyGeoJson(identify, multiple =
|
|
9964
|
+
fetchIdentifyGeoJson(identify, { multiple, signal } = {}) {
|
|
9192
9965
|
const abortController = new AbortController();
|
|
9966
|
+
if (signal) {
|
|
9967
|
+
if (signal.aborted) {
|
|
9968
|
+
return Promise.reject(new NgwConnectorExtended.errors.AbortError());
|
|
9969
|
+
}
|
|
9970
|
+
signal.addEventListener("abort", () => {
|
|
9971
|
+
abortController.abort("AbortError");
|
|
9972
|
+
});
|
|
9973
|
+
}
|
|
9193
9974
|
const promise = fetchIdentifyGeoJson({
|
|
9194
9975
|
identify,
|
|
9195
9976
|
connector: this.connector,
|
|
@@ -9207,7 +9988,7 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9207
9988
|
* @deprecated use {@link fetchIdentifyGeoJson} instead
|
|
9208
9989
|
*/
|
|
9209
9990
|
getIdentifyGeoJson(identify, multiple = false) {
|
|
9210
|
-
return this.fetchIdentifyGeoJson(identify, multiple);
|
|
9991
|
+
return this.fetchIdentifyGeoJson(identify, { multiple });
|
|
9211
9992
|
}
|
|
9212
9993
|
getNgwLayers() {
|
|
9213
9994
|
return __async$1(this, null, function* () {
|
|
@@ -9230,7 +10011,7 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9230
10011
|
if (mem.layer.getDependLayers) {
|
|
9231
10012
|
const dependLayers = mem.layer.getDependLayers();
|
|
9232
10013
|
const dependFit = dependLayers.find((x) => {
|
|
9233
|
-
return x.item && x.item.
|
|
10014
|
+
return x.item && "style_parent_id" in x.item && x.item.style_parent_id !== void 0 && x.item.style_parent_id === id;
|
|
9234
10015
|
});
|
|
9235
10016
|
if (dependFit) {
|
|
9236
10017
|
return dependFit.layer;
|
|
@@ -9273,14 +10054,7 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9273
10054
|
item = yield this.connector.getResource(resourceId);
|
|
9274
10055
|
}
|
|
9275
10056
|
if (item) {
|
|
9276
|
-
|
|
9277
|
-
resourceId: item.resource.id,
|
|
9278
|
-
connector: this.connector
|
|
9279
|
-
}).then((extent) => {
|
|
9280
|
-
if (extent) {
|
|
9281
|
-
this.fitBounds(extent, options);
|
|
9282
|
-
}
|
|
9283
|
-
});
|
|
10057
|
+
this.fitResource(item.resource.id);
|
|
9284
10058
|
}
|
|
9285
10059
|
}
|
|
9286
10060
|
} else {
|
|
@@ -9292,6 +10066,18 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9292
10066
|
}
|
|
9293
10067
|
});
|
|
9294
10068
|
}
|
|
10069
|
+
fitResource(resource, options) {
|
|
10070
|
+
return __async$1(this, null, function* () {
|
|
10071
|
+
const resourceId = yield this.connector.resources.getIdOrFail(resource);
|
|
10072
|
+
const extent = yield fetchNgwExtent({
|
|
10073
|
+
resourceId,
|
|
10074
|
+
connector: this.connector
|
|
10075
|
+
});
|
|
10076
|
+
if (extent) {
|
|
10077
|
+
this.fitBounds(extent, options);
|
|
10078
|
+
}
|
|
10079
|
+
});
|
|
10080
|
+
}
|
|
9295
10081
|
/** @deprecated use {@link fitLayer} instead */
|
|
9296
10082
|
zoomToLayer(layerDef) {
|
|
9297
10083
|
return __async$1(this, null, function* () {
|
|
@@ -9471,8 +10257,7 @@ const _NgwMap = class _NgwMap extends WebMap {
|
|
|
9471
10257
|
group.splice(index, 1);
|
|
9472
10258
|
}
|
|
9473
10259
|
};
|
|
9474
|
-
promise.then(removeFromGroup);
|
|
9475
|
-
promise.catch(removeFromGroup);
|
|
10260
|
+
promise.then(removeFromGroup, removeFromGroup);
|
|
9476
10261
|
group.push([promise, abortController]);
|
|
9477
10262
|
}
|
|
9478
10263
|
}
|