///
import type { Stat } from 'encryptedfs';
import type { FileSystem } from '../types.js';
import type { ContentNode, DoneMessage, FileSystemReadable, StatEncoded, TreeNode, Parsed, HeaderGeneric, HeaderContent } from './types.js';
import { ReadableStream, TransformStream } from 'stream/web';
import { HeaderSize, HeaderType, HeaderMagic } from './types.js';
/**
* Generates a serializable format of file stats
*/
declare function generateStats(stat: Stat): StatEncoded;
/**
* This is a utility for walking a file tree while matching a file path globstar pattern.
* @param fs - file system to work against, supports nodes `fs` and our `FileSystemReadable` provided by vaults.
* @param basePath - The path to start walking from.
* @param pattern - The pattern to match against, defaults to everything
* @param yieldRoot - toggles yielding details of the basePath. Defaults to true.
* @param yieldParents - Toggles yielding details about parents of pattern matched paths. Defaults to false.
* @param yieldDirectories - Toggles yielding directories that match the pattern. Defaults to true.
* @param yieldFiles - Toggles yielding files that match the pattern. Defaults to true.
* @param yieldStats - Toggles including stats in file and directory details. Defaults to false.
*/
declare function globWalk({ fs, basePath, pattern, yieldRoot, yieldParents, yieldDirectories, yieldFiles, yieldStats, }: {
fs: FileSystem | FileSystemReadable;
basePath?: string;
pattern?: string;
yieldRoot?: boolean;
yieldParents?: boolean;
yieldDirectories?: boolean;
yieldFiles?: boolean;
yieldStats?: boolean;
}): AsyncGenerator;
/**
* Creates the base header with extra bytes to fill in extra header data for sub headers.
* Formatted as...
* 'H'(1) | HEADER_TYPE(1)
*/
declare function generateGenericHeader(headerData: HeaderGeneric): Uint8Array;
/**
* Creates the content header which identifies the content with the length.
* Data should follow this header.
* Formatted as...
* generic_header(10) | total_size(8)[data_size + header_size] | i_node(4) | 'D'(1)
*/
declare function generateContentHeader(headerData: HeaderContent): Uint8Array;
declare function parseGenericHeader(data: Uint8Array): Parsed;
declare function parseContentHeader(data: Uint8Array): Parsed;
/**
* Takes a filesystem and filePath and generates a content header with the contents of the file in chunks.
* The chunk size is specified by the `chunkSize` parameter.
* @param fs - File system used to access files.
* @param path - filePath for the file to serialize.
* @param iNode - file identifier number to be included in the header.
* @param chunkSize - Maximum chunk sized used when sending file data, defaults to 4kB
*/
declare function encodeContent(fs: FileSystem | FileSystemReadable, path: string, iNode: number, chunkSize?: number): AsyncGenerator;
/**
* Takes an AsyncGenerator and serializes it into a `ReadableStream`
* @param fs
* @param treeGen - An AsyncGenerator that yields the files and directories of a file tree.
* @param yieldContents - Toggles sending the contents of files after the file tree.
*/
declare function serializerStreamFactory(fs: FileSystem | FileSystemReadable, treeGen: AsyncGenerator, yieldContents?: boolean): ReadableStream;
/**
* Type-guard for checking if an object is structured as a `DoneMessage`.
*/
declare function isDoneMessage(data: unknown): data is DoneMessage;
/**
* Type-guard assertion for checking if an object is structured as a `TreeNode`.
*/
declare function parseTreeNode(data: unknown): asserts data is TreeNode;
/**
* Creates a TransformStream webStream to transform a binary `UInt8Array` stream into a parsed file tree stream.
* Will yield `TreeNode`s defining the file tree.
* If file contents are included in the stream it will yield `ContentNode`s defining the file metadata and raw binary
* `UInit8Array` chunks of the contents.
*/
declare function parserTransformStreamFactory(): TransformStream;
export { HeaderSize, HeaderType, HeaderMagic, generateStats, globWalk, generateGenericHeader, generateContentHeader, parseGenericHeader, parseContentHeader, encodeContent, serializerStreamFactory, isDoneMessage, parseTreeNode, parserTransformStreamFactory, };