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();
