@nextgis/ngw-connector 3.0.0-alpha.13 → 3.0.0-alpha.16
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 +71 -14
- package/lib/ngw-connector.cjs.js +33 -28
- package/lib/ngw-connector.cjs.js.map +1 -1
- package/lib/ngw-connector.cjs.prod.js +1 -1
- package/lib/ngw-connector.cjs.prod.js.map +1 -1
- package/lib/ngw-connector.esm-browser.js +31 -26
- package/lib/ngw-connector.esm-browser.js.map +1 -1
- package/lib/ngw-connector.esm-browser.prod.js +1 -1
- package/lib/ngw-connector.esm-browser.prod.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.js +31 -26
- package/lib/ngw-connector.esm-bundler.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-connector.global.js +31 -26
- package/lib/ngw-connector.global.js.map +1 -1
- package/lib/ngw-connector.global.prod.js +1 -1
- package/lib/ngw-connector.global.prod.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.16; author: NextGIS */
|
|
2
2
|
function defined(val) {
|
|
3
3
|
return val !== void 0 && val !== null;
|
|
4
4
|
}
|
|
@@ -773,7 +773,7 @@ function unwrapListeners(arr) {
|
|
|
773
773
|
|
|
774
774
|
var pkg = {
|
|
775
775
|
name: "@nextgis/ngw-connector",
|
|
776
|
-
version: "3.0.0-alpha.
|
|
776
|
+
version: "3.0.0-alpha.16",
|
|
777
777
|
_priority: 12,
|
|
778
778
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
779
779
|
main: "index.js",
|
|
@@ -1169,7 +1169,7 @@ function generateUrl(path, query) {
|
|
|
1169
1169
|
}
|
|
1170
1170
|
function request(path, options, cacheEngine) {
|
|
1171
1171
|
return __async$3(this, null, function* () {
|
|
1172
|
-
var _b;
|
|
1172
|
+
var _b, _c;
|
|
1173
1173
|
const defaults = {
|
|
1174
1174
|
method: "GET",
|
|
1175
1175
|
credentials: "same-origin",
|
|
@@ -1194,6 +1194,7 @@ function request(path, options, cacheEngine) {
|
|
|
1194
1194
|
"query",
|
|
1195
1195
|
"json"
|
|
1196
1196
|
]);
|
|
1197
|
+
opt.method = (_b = opt.method) == null ? void 0 : _b.toUpperCase();
|
|
1197
1198
|
if (withCredentials) {
|
|
1198
1199
|
opt.credentials = "include";
|
|
1199
1200
|
}
|
|
@@ -1251,15 +1252,24 @@ function request(path, options, cacheEngine) {
|
|
|
1251
1252
|
}
|
|
1252
1253
|
return body;
|
|
1253
1254
|
});
|
|
1254
|
-
if (cacheEngine
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1255
|
+
if (cacheEngine) {
|
|
1256
|
+
if (((_c = opt.method) == null ? void 0 : _c.toUpperCase()) === "GET") {
|
|
1257
|
+
if (cache !== false) {
|
|
1258
|
+
const props = cacheProps ? cacheProps : __spreadValues$3({}, objectRemoveEmpty({
|
|
1259
|
+
withCredentials,
|
|
1260
|
+
responseType
|
|
1261
|
+
}));
|
|
1262
|
+
return cacheEngine.add(cacheName || url, makeRequest, {
|
|
1263
|
+
props,
|
|
1264
|
+
expirationTime: cache ? void 0 : 500
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
} else {
|
|
1268
|
+
const ignoredForClean = ["api/feature_layer/identify"];
|
|
1269
|
+
if (ignoredForClean.every((part) => !path.includes(part))) {
|
|
1270
|
+
cacheEngine.clean();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1263
1273
|
}
|
|
1264
1274
|
return makeRequest();
|
|
1265
1275
|
});
|
|
@@ -1564,12 +1574,16 @@ class NgwConnector {
|
|
|
1564
1574
|
__publicField$2(this, "user");
|
|
1565
1575
|
__publicField$2(this, "cache");
|
|
1566
1576
|
__publicField$2(this, "withCredentials");
|
|
1577
|
+
// Dedicated cache for route requests, as these are executed before any other requests.
|
|
1578
|
+
// This cache does not need to be cleared during the session.
|
|
1579
|
+
__publicField$2(this, "routeCache");
|
|
1567
1580
|
__publicField$2(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
|
|
1568
1581
|
__publicField$2(this, "routeStr", "/api/component/pyramid/route");
|
|
1569
1582
|
__publicField$2(this, "activeRequests", {});
|
|
1570
1583
|
__publicField$2(this, "requestTransform");
|
|
1571
1584
|
const exist = findConnector(options);
|
|
1572
1585
|
this.cache = new Cache({ namespace: options.cacheId });
|
|
1586
|
+
this.routeCache = new Cache({ namespace: "routecache" });
|
|
1573
1587
|
if (exist) {
|
|
1574
1588
|
return exist;
|
|
1575
1589
|
} else {
|
|
@@ -1630,19 +1644,9 @@ class NgwConnector {
|
|
|
1630
1644
|
}
|
|
1631
1645
|
}
|
|
1632
1646
|
const routeUrl = `${this.routeStr}?client=${this.client}`;
|
|
1633
|
-
return this.
|
|
1634
|
-
|
|
1635
|
-
{}
|
|
1636
|
-
{
|
|
1637
|
-
cacheName: "route",
|
|
1638
|
-
signal,
|
|
1639
|
-
cache: true,
|
|
1640
|
-
cacheProps: {
|
|
1641
|
-
id: this.id,
|
|
1642
|
-
auth,
|
|
1643
|
-
baseUrl: this.options.baseUrl
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1647
|
+
return this.routeCache.add(
|
|
1648
|
+
this.options.baseUrl || String(this.id),
|
|
1649
|
+
() => this.makeQuery(routeUrl, null, { signal, cache: false })
|
|
1646
1650
|
);
|
|
1647
1651
|
});
|
|
1648
1652
|
}
|
|
@@ -1663,6 +1667,7 @@ class NgwConnector {
|
|
|
1663
1667
|
removeConnector(this);
|
|
1664
1668
|
this.options.auth = void 0;
|
|
1665
1669
|
this.user = void 0;
|
|
1670
|
+
this.routeCache.clean();
|
|
1666
1671
|
this.clearCache();
|
|
1667
1672
|
this.emitter.emit("logout");
|
|
1668
1673
|
}
|
|
@@ -1769,7 +1774,7 @@ class NgwConnector {
|
|
|
1769
1774
|
this._cleanActiveRequest(id);
|
|
1770
1775
|
}
|
|
1771
1776
|
});
|
|
1772
|
-
if (method === "GET") {
|
|
1777
|
+
if (method === "GET" && cache !== false) {
|
|
1773
1778
|
const cacheOptions = cacheProps ? cacheProps : __spreadProps$1(__spreadValues$1({}, objectRemoveEmpty({
|
|
1774
1779
|
headers,
|
|
1775
1780
|
withCredentials,
|