UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

55 lines (54 loc) • 3.18 kB
import { DbClient } from './client.js'; import { LiveQueryKey } from './live-query-options.js'; /** * The adapter layer: what the first-party framework adapters * (`@tanstack/react-db`, `@tanstack/preact-db`, `@tanstack/vue-db`, * `@tanstack/svelte-db`, `@tanstack/solid-db`, `@tanstack/angular-db`) build * their bindings from. It centralizes logic every adapter used to duplicate, * so they stay consistent across frameworks. * * Application code should use an adapter instead. Everything exported here is * unstable for external use and changes with the adapters that share it. */ export * from './live-query-primitives.js'; export * from './live-query-observer.js'; export * from './live-query-window-binding.js'; export { configPool, getLiveQueryHash, getPreparedLiveQueryIdentity, getPreparedLiveQuerySources, prepareLiveQueryValue, rejectLiveQueryInput, releaseDeferredOnReclaim, resolveLiveQueryValue, resumeDeferredLiveQueryCollections, } from './live-query-options.js'; export type { DeferredLiveQueryCollections } from './live-query-options.js'; export { createLiveQueryWindowController, fetchNextLiveQueryWindowPage, } from './live-query-window-controller.js'; export type { CreateLiveQueryWindowControllerOptions, LiveQueryWindowController, LiveQueryWindowSnapshot, } from './live-query-window-controller.js'; /** * The `queryKey` of a config-object query input, if it supplies one. An empty * key is absent, as it is for `getLiveQueryHash`, so a hook and a `DbClient` * preload agree on the query's identity. */ export declare function getLiveQueryKey(input: unknown): LiveQueryKey | undefined; /** A process-unique number for a source object, without retaining it. */ export declare function getSourceObjectToken(source: object): number; /** * The source object each Collection ID named while one binding is mounted, * per client scope. */ export type LiveQuerySourceIdClaims = WeakMap<object, Map<string, number>>; export declare function createLiveQuerySourceIdClaims(): LiveQuerySourceIdClaims; /** Record a query's sources, or throw before recording any. */ export declare function claimLiveQuerySourceIds(claims: LiveQuerySourceIdClaims, sources: ReadonlyArray<{ id: string; }>, client: DbClient | undefined, bindingName: string): void; /** Where a binding that compares query identity checks a prepared query. */ export interface LiveQueryIdentityScope { /** This binding's source Collection ID claims. */ claims: LiveQuerySourceIdClaims; client: DbClient | undefined; bindingName: string; /** Report a descriptor source that no client bound. */ onUnboundDescriptor?: (alias: string) => never; } /** * Identify a prepared query for a binding that compares query identity. The * identity throws `UnhashableQueryIRError` for IR without a stable identity, * then the query's sources claim their Collection IDs. The binding's render * boundary releases the sync starts a rejected render deferred; see * `rejectLiveQueryInput`. */ export declare function identifyLiveQuery<TIdentity = unknown>(preparedValue: unknown, scope: LiveQueryIdentityScope, identify?: (preparedValue: unknown) => TIdentity): TIdentity;