export interface UploadBlobUrlResult { uri: string | null; errored: boolean; setErrored: (v: boolean) => void; } /** * Produce a renderable URI for an upload id without going through * `apiFetch`. * * For a consumer that keeps uploads somewhere this package cannot reach — an * on-device database, a cache it populated itself — the resolver is the whole * seam. Return `null` for an id that does not resolve; the hook reports that * as `errored`, which is what a renderer draws its fallback on. * * The `signal` aborts with the effect, so a resolver doing real work can stop * when the row scrolls away. */ export type UploadResolver = (uploadId: string, signal: AbortSignal) => Promise; export interface UploadBlobUrlOptions { /** Upload-fetch path prefix. Defaults to `/uploads`. */ uploadsPath?: string; /** * Resolve the URI yourself instead of fetching it. * * Identity does not have to be stable: the resolver is held in a ref and * only `uploadId` / `uploadsPath` re-run the effect. An inline arrow would * otherwise refetch on every render, and what identifies the resource is the * id, not the function that happens to fetch it. */ resolve?: UploadResolver; } /** * A URI for an upload, fetched through `apiFetch` unless the consumer resolves * it itself. * * # Web gets a blob URL; native gets a data URI * * `URL.createObjectURL` is a browser API. React Native's `URL` does not * implement it in any way that can be relied on across both platforms — so on * native this hook used to hand `` a URI built by a function that * either threw or produced something the image loader could not open, and the * fetch fell into the `catch` below. The visible symptom was that custom * uploaded icons never appeared on a phone: they resolved to the fallback * glyph every time, on every consumer, and looked like a missing-image problem * rather than a URL one. * * Native therefore reads the bytes and builds `data:;base64,…`, which * every RN image loader accepts. The cost is that base64 inflates by a third * and the string sits in the JS heap for as long as the row is mounted, which * is affordable for the icons this exists to draw (the vault caps an upload at * 256KB) and is why web keeps the blob URL — no copy, and revocable. * * The second argument accepts a bare path for backwards compatibility with * `useUploadBlobUrl(id, "/uploads")`; new call sites should pass options. */ export declare function useUploadBlobUrl(uploadId: string | null | undefined, options?: string | UploadBlobUrlOptions): UploadBlobUrlResult; //# sourceMappingURL=useUploadBlobUrl.d.ts.map