/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util/schema"; import { type ITabularMigration, type ITabularMigrationApplier } from "../migrations"; import { BaseTabularStorage, ClientProvidedKeysOption } from "./BaseTabularStorage"; import { AnyTabularStorage, AutoGeneratedKeys, CoveringIndexQueryOptions, DeleteSearchCriteria, InsertEntity, QueryOptions, SearchCriteria, SimplifyPrimaryKey, TabularSubscribeOptions } from "./ITabularStorage"; export declare const SHARED_IN_MEMORY_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken; /** * Tabular repository that mirrors an internal `InMemoryTabularStorage` across * browser tabs / windows via the BroadcastChannel API. */ export declare class SharedInMemoryTabularStorage, Entity = FromSchema, PrimaryKey = SimplifyPrimaryKey, Value = Omit, InsertType extends InsertEntity> = InsertEntity>> extends BaseTabularStorage { private channel; private channelName; private inMemoryRepo; private isInitialized; private syncInProgress; private pendingMessages; /** * Resolves when the current `syncFromOtherTabs()` settles, either because a * peer tab sent a `SYNC_RESPONSE` (drained, then resolved) or because the * sync timeout fired. `setupDatabase({ awaitTabSync: true })` awaits this so * callers that immediately read after setup do not race the replay. */ private syncSettled; private syncSettledResolver; constructor(channelName: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof NoInfer | readonly (keyof NoInfer)[])[], clientProvidedKeys?: ClientProvidedKeysOption, tabularMigrations?: ReadonlyArray); private isBroadcastChannelAvailable; private initializeBroadcastChannel; private setupEventForwarding; private handleBroadcastMessage; /** * The `while` loop covers the case where replaying a queued message triggers * a new sync cycle that re-queues additional messages. */ private drainPendingMessages; private syncFromOtherTabs; private resolveSyncSettled; private copyDataFromArray; private broadcast; /** * Initialize the cross-tab sync barrier and apply any pending migrations. * * Defaults to `awaitTabSync: true` so that callers that immediately read or * write after `setupDatabase()` resolves see other tabs' replayed rows; the * fire-and-forget shape regressed in 64591e3 and caused first-call races. * Pass `awaitTabSync: false` only for latency-sensitive startup paths that * explicitly tolerate a stale initial view. */ setupDatabase(options?: { awaitTabSync?: boolean; }): Promise; /** Shared in-memory rows do not survive a process restart. */ isDurable(): boolean; getMigrationApplier(): ITabularMigrationApplier | null; put(value: InsertType): Promise; putBulk(values: InsertType[]): Promise; get(key: PrimaryKey): Promise; delete(value: PrimaryKey | Entity): Promise; deleteAll(): Promise; getAll(options?: QueryOptions): Promise; size(): Promise; getOffsetPage(offset: number, limit: number): Promise; query(criteria: SearchCriteria, options?: QueryOptions): Promise; queryIndex(criteria: SearchCriteria, options: CoveringIndexQueryOptions): Promise[]>; deleteSearch(criteria: DeleteSearchCriteria): Promise; /** * Delegates to the internal InMemoryTabularStorage; cross-tab changes already * land in that store via the BroadcastChannel handler. */ subscribeToChanges(callback: (change: any) => void, options?: TabularSubscribeOptions): () => void; destroy(): void; } //# sourceMappingURL=SharedInMemoryTabularStorage.d.ts.map