import type { LiveDeltaFrame } from '../live/protocol.js'; import type { RealtimeChange } from '../realtime/publisher.js'; /** * The server-side state of one live-view connection: which rows the client * holds, in view order, and whether rows exist below the window. * * The window is what lets the server place a row for the client (`afterId`) * instead of making the browser repeat `ORDER BY`. It is also what makes a * removal from a truncated view ask for a fresh snapshot instead of silently * shrinking the view. * * Ordering follows `buildOrderBy` in `../list-query`: the sort column first, * then `id`, both in the query's direction. Values are compared in the process * on raw column values. That is exact for numbers, dates, and booleans, and * matches the database for ordinary text. A collation that differs from * code-unit order, or a NULLS rule other than "nulls first", can place a row * inside the window differently from the database. */ export type LiveWindowOptions = { sort: string; order: 'asc' | 'desc'; limit: number; filters?: Record; }; export type LiveWindowResult = { type: 'none'; } | { type: 'frames'; frames: LiveDeltaFrame[]; } | { type: 'resnapshot'; }; export type LiveWindow = { /** Adopt a query result as the current view. */ reset: (items: Record[], hasMore: boolean) => void; /** What this change means for this view. */ apply: (change: RealtimeChange) => LiveWindowResult; }; export declare function createLiveWindow(options: LiveWindowOptions): LiveWindow; //# sourceMappingURL=live-window.d.ts.map