import { EventSubscriber, FileData, FileRef, ObjectIdentifier, PropertyName } from '@verdant-web/common'; import { Context } from '../context/context.js'; export type EntityFileEvents = { change: () => void; }; export declare const UPDATE: unique symbol; export declare const MARK_FAILED: unique symbol; export interface EntityFileContext { readonly oid: ObjectIdentifier; readonly key: PropertyName; getFileRef(): FileRef | null; applyFileRef(file: FileRef): void; subscribe(callback: () => void): () => void; onChange(): void; } export type EntityFileSnapshot = { id: string; url?: string | null; name: string; remote: boolean; type: string; file?: Blob | null; alt: string | null; }; /** * Provides a consistent interface for files used in an app via * Entity access. */ export declare class EntityFile extends EventSubscriber { readonly id: string; private _objectUrl; private _fileData; private _loading; private _failed; private _failedReason; private _downloadRemote; private _uploaded; private _alt; private ctx; private unsubscribes; private fileContext; constructor(id: string, { downloadRemote, ctx, fileContext, }: { downloadRemote?: boolean; ctx: Context; fileContext: EntityFileContext; }); get downloadRemote(): boolean; get isFile(): boolean; get isUploaded(): boolean; get error(): string | null; get alt(): string | null; setAlt: (alt: string | null) => void; private onContextChange; private emitChange; [UPDATE]: (fileData: FileData) => void; [MARK_FAILED]: (reason?: string) => void; private onUploaded; get url(): string | null; get name(): string | null; get type(): string | null; get loading(): boolean; get failed(): boolean; destroy: () => void; getSnapshot(): EntityFileSnapshot; }