import { Result, Converter, Validator } from '@fgv/ts-utils'; import { FileTree, JsonValue } from '@fgv/ts-json-base'; /** * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive. * @public */ export declare class ZipFileItem implements FileTree.IFileTreeFileItem { /** * Indicates that this `FileTree.FileTreeItem` is a file. */ readonly type: 'file'; /** * The absolute path of the file within the ZIP archive. */ readonly absolutePath: string; /** * The name of the file */ readonly name: string; /** * The base name of the file (without extension) */ readonly baseName: string; /** * The extension of the file */ readonly extension: string; /** * The content type of the file. */ get contentType(): TCT | undefined; /** * The pre-loaded contents of the file. */ private readonly _contents; /** * The ZIP file tree accessors that created this item. */ private readonly _accessors; /** * Mutable content type of the file. */ private _contentType; /** * Flag to track if content type should be inferred on first access. */ private _shouldInferContentType; /** * Constructor for ZipFileItem. * @param zipFilePath - The path of the file within the ZIP. * @param contents - The pre-loaded contents of the file. * @param accessors - The ZIP file tree accessors. */ constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors); /** * Sets the content type of the file. * @param contentType - The content type of the file. */ setContentType(contentType: TCT | undefined): void; /** * Gets the contents of the file as parsed JSON. */ getContents(): Result; getContents(converter: Validator | Converter): Result; /** * Gets the raw contents of the file as a string. */ getRawContents(): Result; } /** * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive. * @public */ export declare class ZipDirectoryItem implements FileTree.IFileTreeDirectoryItem { /** * Indicates that this `FileTree.FileTreeItem` is a directory. */ readonly type: 'directory'; /** * The absolute path of the directory within the ZIP archive. */ readonly absolutePath: string; /** * The name of the directory */ readonly name: string; /** * The ZIP file tree accessors that created this item. */ private readonly _accessors; /** * Constructor for ZipDirectoryItem. * @param directoryPath - The path of the directory within the ZIP. * @param accessors - The ZIP file tree accessors. */ constructor(directoryPath: string, accessors: ZipFileTreeAccessors); /** * Gets the children of the directory. */ getChildren(): Result>>; } /** * File tree accessors for ZIP archives. * @public */ export declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors { /** * The unzipped file data. */ private readonly _files; /** * Optional prefix to prepend to paths. */ private readonly _prefix; /** * Content type inference function. */ private readonly _inferContentType; /** * Cache of all items in the ZIP for efficient lookups. */ private readonly _itemCache; /** * Constructor for ZipFileTreeAccessors. * @param files - The unzipped file data from fflate. * @param params - Optional initialization parameters. */ private constructor(); /** * Default function to infer the content type of a file. * @param filePath - The path of the file. * @param provided - Optional supplied content type. * @returns `Success` with the content type of the file if successful, or * `Failure` with an error message otherwise. * @remarks This default implementation always returns `Success` with `undefined`. * @public */ static defaultInferContentType(__filePath: string, __provided?: string): Result; /** * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous). * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array. * @param prefix - Optional prefix to prepend to paths. * @returns Result containing the ZipFileTreeAccessors instance. */ static fromBuffer(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Result>; /** * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous). * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array. * @param params - Optional initialization parameters. * @returns Result containing the ZipFileTreeAccessors instance. */ static fromBuffer(zipBuffer: ArrayBuffer | Uint8Array, params?: FileTree.IFileTreeInitParams): Result>; /** * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous). * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array. * @param prefix - Optional prefix to prepend to paths. * @returns Promise containing Result with the ZipFileTreeAccessors instance. */ static fromBufferAsync(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Promise>>; /** * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous). * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array. * @param params - Optional initialization parameters. * @returns Promise containing Result with the ZipFileTreeAccessors instance. */ static fromBufferAsync(zipBuffer: ArrayBuffer | Uint8Array, params?: FileTree.IFileTreeInitParams): Promise>>; /** * Creates a new ZipFileTreeAccessors instance from a File object (browser environment). * @param file - The File object containing ZIP data. * @param params - Optional initialization parameters. * @returns Result containing the ZipFileTreeAccessors instance. */ static fromFile(file: File, params?: FileTree.IFileTreeInitParams): Promise>>; /** * Builds the cache of all items in the ZIP archive. */ private _buildItemCache; /** * Resolves paths to an absolute path. */ resolveAbsolutePath(...paths: string[]): string; /** * Gets the extension of a path. */ getExtension(path: string): string; /** * Gets the base name of a path. */ getBaseName(path: string, suffix?: string): string; /** * Joins paths together. */ joinPaths(...paths: string[]): string; /** * Gets an item from the file tree. */ getItem(path: string): Result>; /** * Gets the contents of a file in the file tree. */ getFileContents(path: string): Result; /** * Gets the content type of a file in the file tree. */ getFileContentType(path: string, provided?: string): Result; /** * Gets the children of a directory in the file tree. */ getChildren(path: string): Result>>; /** * Checks if childPath is a direct child of parentPath. */ private _isDirectChild; } //# sourceMappingURL=zipFileTreeAccessors.d.ts.map