@nextgis/ngw-map 3.0.0-alpha.6 → 3.0.0-alpha.7
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/ngw-map.cjs.js +1 -1
- package/lib/ngw-map.esm-browser.js +41 -18
- 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 +1 -1
- package/lib/ngw-map.global.js +41 -18
- 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 +4 -4
package/lib/ngw-map.cjs.js
CHANGED
|
@@ -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.7; author: NextGIS */
|
|
2
2
|
var domain;
|
|
3
3
|
|
|
4
4
|
// This constructor is used to store event handlers. Instantiating this is
|
|
@@ -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
|
}
|
|
@@ -940,7 +965,7 @@ let Cache = _Cache;
|
|
|
940
965
|
|
|
941
966
|
var pkg = {
|
|
942
967
|
name: "@nextgis/ngw-connector",
|
|
943
|
-
version: "3.0.0-alpha.
|
|
968
|
+
version: "3.0.0-alpha.7",
|
|
944
969
|
_priority: 12,
|
|
945
970
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
946
971
|
main: "index.js",
|
|
@@ -949,7 +974,7 @@ var pkg = {
|
|
|
949
974
|
jsdelivr: "lib/ngw-connector.global.prod.js",
|
|
950
975
|
types: "lib/index.d.ts",
|
|
951
976
|
dependencies: {
|
|
952
|
-
"@nextgis/cache": "^3.0.0-alpha.
|
|
977
|
+
"@nextgis/cache": "^3.0.0-alpha.7",
|
|
953
978
|
"@nextgis/cancelable-promise": "^3.0.0-alpha.5",
|
|
954
979
|
"@nextgis/utils": "^3.0.0-alpha.5",
|
|
955
980
|
"@types/events": "^3.0.0",
|
|
@@ -1701,9 +1726,6 @@ class NgwConnector {
|
|
|
1701
1726
|
addConnector(this);
|
|
1702
1727
|
}
|
|
1703
1728
|
}
|
|
1704
|
-
static create(options) {
|
|
1705
|
-
return new this(options);
|
|
1706
|
-
}
|
|
1707
1729
|
/**
|
|
1708
1730
|
* Clear the cache.
|
|
1709
1731
|
*/
|
|
@@ -1884,7 +1906,7 @@ class NgwConnector {
|
|
|
1884
1906
|
this._cleanActiveRequest(id);
|
|
1885
1907
|
}
|
|
1886
1908
|
});
|
|
1887
|
-
if (
|
|
1909
|
+
if (method === "GET") {
|
|
1888
1910
|
const cacheOptions = cacheProps ? cacheProps : __spreadProps$g(__spreadValues$v({}, objectRemoveEmpty({
|
|
1889
1911
|
headers,
|
|
1890
1912
|
withCredentials,
|
|
@@ -1894,12 +1916,10 @@ class NgwConnector {
|
|
|
1894
1916
|
})), {
|
|
1895
1917
|
params
|
|
1896
1918
|
});
|
|
1897
|
-
return this.cache.add(
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
false
|
|
1902
|
-
);
|
|
1919
|
+
return this.cache.add(cacheName || url, createPromise, {
|
|
1920
|
+
props: cacheOptions,
|
|
1921
|
+
expirationTime: cache ? void 0 : 500
|
|
1922
|
+
});
|
|
1903
1923
|
}
|
|
1904
1924
|
return createPromise();
|
|
1905
1925
|
});
|
|
@@ -2363,6 +2383,9 @@ class NgwConnectorExtended extends NgwConnector {
|
|
|
2363
2383
|
cacheId: options.cacheId
|
|
2364
2384
|
});
|
|
2365
2385
|
}
|
|
2386
|
+
static create(options) {
|
|
2387
|
+
return new this(options);
|
|
2388
|
+
}
|
|
2366
2389
|
/**
|
|
2367
2390
|
* Clear the cache.
|
|
2368
2391
|
*/
|