feat: complete TASK-WP0-06 public cache
This commit is contained in:
@@ -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>
|
||||
@@ -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();
|
||||
Reference in New Issue
Block a user