import type { PushRepository, PushTokenRow } from "../../db/repositories/push.repository"; import type { SessionStore } from "../../session-store"; import { type LiveActivitySender } from "./liveActivitySender"; /** * How long before the cap to renew. * * Far enough out that a missed tick or a slow APNs round trip still lands inside * the window, close enough that the replacement activity gets a nearly full * 8-hour lifetime of its own. */ export declare const RENEWAL_LEAD_MS: number; export interface LiveActivityRenewalDeps { repo: PushRepository; sender: LiveActivitySender; sessionStore: SessionStore; serverId: string; serverLabel?: string; /** Injected in tests; production uses the real clock. */ now?: () => number; } /** When a row should be renewed: its cap, minus the lead time. */ export declare function renewalDueAt(row: PushTokenRow): number | null; export declare class LiveActivityRenewalScheduler { private readonly deps; private timer; private stopped; private readonly now; constructor(deps: LiveActivityRenewalDeps); /** * Arm the scheduler from persisted state. * * Called on boot, which is what makes a renewal survive a restart: the * deadlines were never in memory to begin with. */ start(): void; stop(): void; /** * Renew everything due, then sleep until the next deadline. * * Re-reads from the DB every tick rather than caching a schedule in memory, so * an activity registered after boot is picked up without re-arming anything. */ tick(): Promise; private scheduleNext; /** * Renew one activity. * * Claims first: `claimRenewal()` succeeds exactly once per row, so a timer * re-armed after a restart mid-window cannot send a second time. */ private renew; /** * Ask the device to start a replacement activity. * * Uses the app-wide push-to-start token, because the replacement does not * exist yet and therefore has no per-activity token. Returns false when the * device never registered one, which is not an error: the app simply cannot be * asked to start an activity remotely, and the next foreground WS update * recreates it. */ private startReplacement; } //# sourceMappingURL=liveActivityRenewal.d.ts.map