import type { ColumnLayout, ElementKind, TypedArray } from './layout.js'; export type Backing = SharedArrayBuffer | ArrayBuffer; export type ColumnKey = string & { readonly __columnKey: unique symbol; }; export type RegionKey = string & { readonly __regionKey: unique symbol; }; export type WorkerMode = 'single' | 'sab' | 'no-sab' | 'auto'; export type BackingStrategy = 'resizable-sab' | 'grow-patch-sab' | 'resizable-ab' | 'grow-patch-ab'; export interface RuntimeCapabilities { readonly sabAvailable: boolean; readonly resizableSab: boolean; readonly resizableAb: boolean; readonly waitAsync: boolean; readonly waitBlocking: boolean; readonly crossOriginIsolated: boolean | undefined; readonly backing: BackingStrategy; } export declare const isSharedBacking: (b: ArrayBufferLike) => b is SharedArrayBuffer; export declare function selectBacking(req: WorkerMode, sabAvailable: boolean, resizableSab: boolean, resizableAb: boolean, emitDiagnostic?: (message: string) => void): BackingStrategy; export declare function probeCapabilities(req: WorkerMode, emitDiagnostic?: (message: string) => void): RuntimeCapabilities; export interface Column { readonly layout: ColumnLayout; readonly key: ColumnKey; view: TA; backing: Backing; capacity(): number; } export interface Region { view: TA; backing: Backing; readonly key: RegionKey; capacity(): number; } export interface RegionOpts { readonly fixed?: boolean; readonly maxLength?: number; readonly fill?: number; } export interface ViewHolder { __rebind(newBacking: Backing): void; } export interface BuffersConfig { readonly capabilities: RuntimeCapabilities; readonly maxEntities: number; /** _RESERVE_FACTOR — multiplies initialCapacity for the address-space reservation. */ readonly growthReserveFactor?: number; /** _RESERVE_ROWS — floor on a column's reserved capacity. */ readonly minReserveRows?: number; } export interface ExportedColumnHandle { readonly key: ColumnKey; readonly backing: SharedArrayBuffer; readonly layout: ColumnLayout; } export interface ExportedRegionHandle { readonly key: RegionKey; readonly backing: SharedArrayBuffer; readonly element: ElementKind; } export interface SharedHandleManifest { readonly columns: ReadonlyArray; readonly regions: ReadonlyArray; } export interface ColumnGrowthNotice { readonly key: ColumnKey; readonly backing: SharedArrayBuffer; readonly layout: ColumnLayout; } /** A REGION re-backing (topic rings, cursor tables): same protocol, element-typed instead of laid out. */ export interface RegionGrowthNotice { readonly key: RegionKey; readonly backing: SharedArrayBuffer; readonly element: ElementKind; } export type GrowthNotice = ColumnGrowthNotice | RegionGrowthNotice; export interface ColumnGrowthLog { /** Monotonic re-backing generation. Equal across two reads ⇒ nothing re-backed (the steady-state check). */ readonly generation: number; /** Re-backing notices accumulated since the last drain (latest backing per column/region). Empty unless `generation` advanced. */ drain(): GrowthNotice[]; } export declare class Buffers { #private; readonly capabilities: RuntimeCapabilities; constructor(config: BuffersConfig); column(key: ColumnKey, layout: ColumnLayout, initialCapacity: number): Column; region(key: RegionKey, element: ElementKind, length: number, opts?: RegionOpts): Region; grow(col: Column, newCapacity: number): Column; columnGrowth(): ColumnGrowthLog; /** * Grow a REGION to hold `requiredBytes` — in place via the backing's reservation when possible * (length-tracking views auto-widen; no notice), else allocate-copy re-back. A shared re-back is * journaled like a column re-back so worker-captured views re-wrap at the next wave fence. * Serial / quiescent callers only (topic rings, cursor tables — mutated only at serial slots). */ rebackRegion(reg: Region, requiredBytes: number): void; registerAccessor(key: ColumnKey, accessor: ViewHolder): void; unregisterAccessor(key: ColumnKey, accessor: ViewHolder): void; get(key: ColumnKey | RegionKey): Column | Region | undefined; exportSharedHandles(): SharedHandleManifest; } export declare function sharedBacking(col: Column): SharedArrayBuffer | null; export declare function snapshotInto(col: Column, count: number, out: TypedArray, outOffset: number): number; export declare function rowSlice(col: Column, row: number): TypedArray; export declare function columnKey(archetypeId: number, componentTypeId: number, fieldIndex: number): ColumnKey; //# sourceMappingURL=buffers.d.ts.map