import { BlobDownloadTracker } from './BlobDownloadTracker'; /** * BlobRef Resolution for Dexie Cloud * * Handles lazy resolution of BlobRefs when reading from the database. * BlobRefs are symbolic references to blobs stored in blob storage. * They get resolved on-demand when the object is read. * * The server sends offloaded binary data in the format: * { _bt: 'Uint8Array', ref: '1:blobId', size: 1234 } * { _bt: 'Blob', ref: '1:blobId', size: 1234, ct: 'image/png' } * * The _bt field preserves the original JavaScript type. * The ref format is '{version}:{blobId}' where version identifies * the storage backend configuration. */ /** * Original type that was offloaded to blob storage. * Matches the TSON type names. */ export type BlobRefOrigType = 'Blob' | 'ArrayBuffer' | 'Uint8Array' | 'Int8Array' | 'Uint8ClampedArray' | 'Int16Array' | 'Uint16Array' | 'Int32Array' | 'Uint32Array' | 'Float32Array' | 'Float64Array' | 'BigInt64Array' | 'BigUint64Array' | 'DataView' | 'string'; /** * BlobRef represents a reference to binary data stored in blob storage. * The _bt field contains the original JavaScript type (Uint8Array, Blob, etc.) * The presence of 'ref' instead of 'v' indicates this is an offloaded blob. */ export interface BlobRef { _bt: BlobRefOrigType; ref: string; size: number; ct?: string; } /** * Resolved blob with its keyPath for queueing */ export interface ResolvedBlob { keyPath: string; data: Blob | ArrayBuffer | ArrayBufferView | string; ref: string; } /** * Check if a value is a BlobRef (offloaded binary data) * A BlobRef has _bt (type), ref (blob ID), but no v (inline data) */ export declare function isBlobRef(value: unknown): value is BlobRef; /** * Serialized TSONRef shape (after IndexedDB structured clone). * The Symbol is lost but properties remain. */ export interface SerializedTSONRef { type: string; ref: string; size: number; contentType?: string; } /** * Check if a value is a serialized TSONRef (after IndexedDB storage) * Has 'type' instead of '$t', and no Symbol marker */ export declare function isSerializedTSONRef(value: unknown): value is SerializedTSONRef; /** * Recursively check if an object contains any BlobRefs */ export declare function hasBlobRefs(obj: unknown, visited?: WeakSet): boolean; /** * Convert downloaded Uint8Array to the original type specified in BlobRef */ export declare function convertToOriginalType(data: Uint8Array, ref: BlobRef): Blob | ArrayBuffer | ArrayBufferView | string; /** * Recursively resolve all BlobRefs in an object and collect them for queueing. * Returns a new object with BlobRefs replaced by their original type data, * and populates the resolvedBlobs array with keyPath info for each blob. * * @param obj - Object to resolve * @param dbUrl - Base URL for the database * @param accessToken - Access token for blob downloads * @param resolvedBlobs - Array to collect resolved blob info * @param currentPath - Current property path (for tracking) * @param visited - WeakMap for circular reference detection */ export declare function resolveAllBlobRefs(obj: unknown, dbUrl: string, resolvedBlobs: ResolvedBlob[] | undefined, currentPath: string | undefined, visited: WeakMap | undefined, tracker: BlobDownloadTracker): Promise; /** * Check if an object has unresolved BlobRefs */ export declare function hasUnresolvedBlobRefs(obj: unknown): boolean;