lumencode 0.4.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -38
- package/index.js +79 -10
- package/lib/aggregate.js +40 -6
- package/lib/cache.js +8 -0
- package/lib/git.js +24 -2
- package/lib/report.js +14 -14
- package/lib/server.js +523 -412
- package/package.json +1 -1
- package/public/api.js +6 -0
- package/public/app.js +699 -526
- package/public/charts.js +285 -95
- package/public/config.js +22 -21
- package/public/git-insights.js +39 -113
- package/public/index.html +728 -341
- package/public/style.css +829 -1702
- package/public/ui-state.js +8 -67
- package/public/utils.js +10 -0
- package/public/work-report.js +1 -22
package/package.json
CHANGED
package/public/api.js
CHANGED
|
@@ -27,6 +27,7 @@ export function createLatestRequestGuard() {
|
|
|
27
27
|
const cache = new Map();
|
|
28
28
|
const pending = new Map();
|
|
29
29
|
const DEFAULT_TTL = 30_000;
|
|
30
|
+
const CACHE_MAX_SIZE = 50;
|
|
30
31
|
|
|
31
32
|
export function clearApiCache() {
|
|
32
33
|
cache.clear();
|
|
@@ -49,6 +50,11 @@ export async function cachedFetch(url, options = {}, ttl = DEFAULT_TTL) {
|
|
|
49
50
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
50
51
|
const data = await res.json();
|
|
51
52
|
cache.set(key, { data, expire: Date.now() + ttl });
|
|
53
|
+
// LRU eviction
|
|
54
|
+
while (cache.size > CACHE_MAX_SIZE) {
|
|
55
|
+
const oldest = cache.keys().next().value;
|
|
56
|
+
cache.delete(oldest);
|
|
57
|
+
}
|
|
52
58
|
return data;
|
|
53
59
|
} finally {
|
|
54
60
|
pending.delete(key);
|