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
@@ -0,0 +1,5 @@
<!doctype html>
<html lang="zh-CN">
<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>Dada public cache probe</title></head>
<body><main><h1>Public cache probe</h1><output id="status">starting</output></main><script type="module" src="/tests/e2e/fixtures/public-asset-cache.ts"></script></body>
</html>
+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();