feat: complete TASK-WP0-06 public cache

This commit is contained in:
suyx
2026-07-27 23:05:23 +08:00
parent e12a83d6d3
commit 2dd6f5c2c2
11 changed files with 775 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
import {
createPublicAssetCacheForTest,
registerPublicAssetServiceWorker,
} from "../../../apps/web/src/public-asset-cache.js";
declare global {
interface Window {
dadaCacheProbe: {
cache: ReturnType<typeof createPublicAssetCacheForTest>;
register(): Promise<void>;
};
}
}
let tick = 1_000;
const cache = createPublicAssetCacheForTest({ maxBytes: 20, now: () => ++tick });
window.dadaCacheProbe = {
cache,
async register() {
await registerPublicAssetServiceWorker();
await navigator.serviceWorker.ready;
document.querySelector("#status")!.textContent = "ready";
},
};
void window.dadaCacheProbe.register();