@geogirafe/lib-geoportal 1.3.0-dev.3079206142 → 1.3.0-dev.3113960509
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.3.0-dev.
|
|
1
|
+
{"version":"1.3.0-dev.3113960509", "build":"3113960509", "date":"25/11/2026"}
|
|
@@ -94,6 +94,13 @@ export default class AbstractConnectManager {
|
|
|
94
94
|
if (shortId) {
|
|
95
95
|
url.searchParams.set(SHORTLINK_PARAMETER, shortId);
|
|
96
96
|
}
|
|
97
|
+
// Keep the current hash: without a redirect (e.g. the session check on load of an anonymous user),
|
|
98
|
+
// it still contains the shared state, which is restored only after the login workflow.
|
|
99
|
+
// After a redirect, the hash preserved in the query parameter takes precedence.
|
|
100
|
+
const currentHash = this.context.urlManager.getHash();
|
|
101
|
+
if (currentHash) {
|
|
102
|
+
url.hash = currentHash;
|
|
103
|
+
}
|
|
97
104
|
this.restoreUrlHash(url);
|
|
98
105
|
this.context.urlManager.updateUrl(url);
|
|
99
106
|
}
|
|
@@ -69,10 +69,11 @@ export declare class CacheHelper {
|
|
|
69
69
|
private readonly maxCacheCount;
|
|
70
70
|
private cacheCount;
|
|
71
71
|
/**
|
|
72
|
-
* Execute a fetch for the query, and cache the result if successful
|
|
73
|
-
*
|
|
72
|
+
* Execute a fetch for the query, and cache the result if successful.
|
|
73
|
+
* Network errors (offline, DNS, CORS...) are propagated to the caller.
|
|
74
|
+
* A failure while caching does not discard the server response.
|
|
74
75
|
*/
|
|
75
|
-
fetchAndCache(state: SwState, request: Request): Promise<Response
|
|
76
|
+
fetchAndCache(state: SwState, request: Request): Promise<Response>;
|
|
76
77
|
/**
|
|
77
78
|
* Try to load this request from local cache.
|
|
78
79
|
* Returns null if unsuccessful
|
|
@@ -277,28 +277,27 @@ export class CacheHelper {
|
|
|
277
277
|
maxCacheCount = 300; // Number of queries that should be cached by the service-worker for offline usage.
|
|
278
278
|
cacheCount = 0; // Counter related to the max value above
|
|
279
279
|
/**
|
|
280
|
-
* Execute a fetch for the query, and cache the result if successful
|
|
281
|
-
*
|
|
280
|
+
* Execute a fetch for the query, and cache the result if successful.
|
|
281
|
+
* Network errors (offline, DNS, CORS...) are propagated to the caller.
|
|
282
|
+
* A failure while caching does not discard the server response.
|
|
282
283
|
*/
|
|
283
284
|
async fetchAndCache(state, request) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
swLog(state, `${this.cacheCount}/${this.maxCacheCount} caching ${request.url} for offline use.`);
|
|
293
|
-
const copy = response.clone();
|
|
285
|
+
const response = await fetch(request);
|
|
286
|
+
if (this.cacheCount < this.maxCacheCount &&
|
|
287
|
+
this.isCacheAllowed(request) &&
|
|
288
|
+
response.ok &&
|
|
289
|
+
response.type !== 'opaque') {
|
|
290
|
+
this.cacheCount++;
|
|
291
|
+
swLog(state, `${this.cacheCount}/${this.maxCacheCount} caching ${request.url} for offline use.`);
|
|
292
|
+
try {
|
|
294
293
|
const cache = await caches.open(this.appCacheName);
|
|
295
|
-
await cache.put(request,
|
|
294
|
+
await cache.put(request, response.clone());
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
swLog(state, `Failed to cache ${request.url}`, error);
|
|
296
298
|
}
|
|
297
|
-
return response;
|
|
298
|
-
}
|
|
299
|
-
catch {
|
|
300
|
-
return null;
|
|
301
299
|
}
|
|
300
|
+
return response;
|
|
302
301
|
}
|
|
303
302
|
/**
|
|
304
303
|
* Try to load this request from local cache.
|
|
@@ -74,19 +74,25 @@ function handleActivate(event) {
|
|
|
74
74
|
async function handleFetchEvent(event) {
|
|
75
75
|
await swHelperReady;
|
|
76
76
|
const newRequest = swHelper.getRequest(event.request);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!response) {
|
|
85
|
-
// Not found in cache. We try to load from IndexedDB.
|
|
86
|
-
response = await indexDbHelper.loadFromIndexedDB(swHelper.State, event.request);
|
|
77
|
+
try {
|
|
78
|
+
return await cacheHelper.fetchAndCache(swHelper.State, newRequest);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const offlineResponse = await loadOfflineResponse(event.request);
|
|
82
|
+
if (offlineResponse) {
|
|
83
|
+
return offlineResponse;
|
|
87
84
|
}
|
|
85
|
+
log(`Fetch failed for ${event.request.method} ${event.request.url}`, error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function loadOfflineResponse(request) {
|
|
90
|
+
// Use cache only for GET queries
|
|
91
|
+
if (!cacheHelper.isCacheAllowed(request)) {
|
|
92
|
+
return null;
|
|
88
93
|
}
|
|
89
|
-
|
|
94
|
+
const cachedResponse = await cacheHelper.loadFromCache(request);
|
|
95
|
+
return cachedResponse ?? (await indexDbHelper.loadFromIndexedDB(swHelper.State, request));
|
|
90
96
|
}
|
|
91
97
|
function log(str, error) {
|
|
92
98
|
swLog(swHelper.State, str, error);
|