import { BlobHandleAndSize } from '@platforma-sdk/model'; import { LRUCache } from 'lru-cache'; import { ComputedRef, EffectScope } from 'vue'; import { ZodSchema } from 'zod'; import { Fetcher } from '@milaboratories/helpers'; type FileHandle = BlobHandleAndSize["handle"]; export type ReactiveFileContentOps = { /** Maximum size in bytes of file content to cache */ cacheSize: number; lruCache?: LRUCache; fetcher?: Fetcher; }; declare class FileContentData { readonly bytes: Uint8Array; private _str; private _rawJson; private _zodSchema; private _validatedJson; constructor(bytes: Uint8Array); get str(): string; get rawJson(): unknown; validatedJson(schema: ZodSchema): T | undefined; } export declare class ReactiveFileContent { private currentScope; private readonly fileDataCache; private readonly fetcher; private ns; private currentKey; private constructor(); /** * Experimental method to invalidate the refs map cache for a given key. */ withInvalidate(key: string, cb: () => T): T; stopScope(): void; private doFetch; private getSize; private getRefsMap; private invalidate; private withHandle; private getDataRef; getContentBytes(handle: FileHandle): ComputedRef; getContentBytes(handle: FileHandle | undefined): ComputedRef | undefined; getContentString(handle: FileHandle): ComputedRef; getContentString(handle: FileHandle | undefined): ComputedRef | undefined; getContentJson(handle: FileHandle, schema: ZodSchema): ComputedRef; getContentJson(handle: FileHandle | undefined, schema: ZodSchema): ComputedRef | undefined; getContentJson(handle: FileHandle): ComputedRef; getContentJson(handle: FileHandle | undefined): ComputedRef | undefined; getContentJson(handle: FileHandle | undefined, schema?: ZodSchema): ComputedRef | undefined; private static initScope; /** * Creates a ReactiveFileContent instance with isolated cache and fetcher. * Use this when you need component-specific caching. * * @example * ```ts * import { ReactiveFileContent } from '@platforma-sdk/ui-vue'; * import { computed } from 'vue'; * * const fileContent = ReactiveFileContent.use(); * * const processedData = computed(() => { * const content = fileContent.getContentString(fileHandle).value; * return content?.split('\n').length ?? 0; * }); * ``` */ static use(_ops?: Partial, _scope?: EffectScope): ReactiveFileContent; /** * Creates a ReactiveFileContent instance with globally shared cache and fetcher. * Use this to share file content cache across multiple components. * * @example * ```ts * import { ReactiveFileContent } from '@platforma-sdk/ui-vue'; * import { computed } from 'vue'; * * const fileContent = ReactiveFileContent.useGlobal(); * * const combinedData = computed(() => { * const data1 = fileContent.getContentJson(handle1).value; * const data2 = fileContent.getContentJson(handle2).value; * return { data1, data2 }; * }); * ``` */ static useGlobal(_ops?: Partial, _scope?: EffectScope): ReactiveFileContent; } export {}; //# sourceMappingURL=fileContent.d.ts.map