@fgv/ts-web-extras
Version:
Browser-compatible utilities and FileTree implementations
311 lines (261 loc) • 9.94 kB
Markdown
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { FileTree } from '@fgv/ts-json-base';
import { Result } from '@fgv/ts-utils';
// @public
export class BrowserHashProvider {
static hashParts(parts: string[], algorithm?: string, separator?: string): Promise<Result<string>>;
static hashString(data: string, algorithm?: string): Promise<Result<string>>;
}
// @public
const defaultFileApiTreeInitParams: FileTree.IFileTreeInitParams<string>;
// @public
export function exportAsJson(data: unknown, filename: string): void;
// @public
export function exportUsingFileSystemAPI(data: unknown, suggestedName: string, description?: string, window?: Window): Promise<boolean>;
// @public
export function extractDirectoryPath(path: string): string;
// @public
function extractFileListMetadata(fileList: FileList): Array<IFileMetadata>;
// @public
function extractFileMetadata(file: File): IFileMetadata;
// @public
export class FileApiTreeAccessors<TCT extends string = string> {
static create<TCT extends string = string>(initializers: TreeInitializer[], params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
static extractFileMetadata(file: File): IFileMetadata;
static fromDirectoryUpload<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
static fromFileList<TCT extends string = string>(fileList: FileList, params?: FileTree.IFileTreeInitParams<TCT>): Promise<Result<FileTree.FileTree<TCT>>>;
static getOriginalFile(fileList: FileList, targetPath: string): Result<File>;
}
// @public
export interface FilePickerAcceptType {
// (undocumented)
accept: Record<string, string | string[]>;
// (undocumented)
description?: string;
}
// @public
interface FileSystemCreateWritableOptions_2 {
// (undocumented)
keepExistingData?: boolean;
}
export { FileSystemCreateWritableOptions_2 as FileSystemCreateWritableOptions }
// @public
interface FileSystemDirectoryHandle_2 extends FileSystemHandle_2 {
// (undocumented)
[](): AsyncIterableIterator<[string, FileSystemHandle_2]>;
// (undocumented)
entries(): AsyncIterableIterator<[string, FileSystemHandle_2]>;
// (undocumented)
getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions_2): Promise<FileSystemDirectoryHandle_2>;
// (undocumented)
getFileHandle(name: string, options?: FileSystemGetFileOptions_2): Promise<FileSystemFileHandle_2>;
// (undocumented)
keys(): AsyncIterableIterator<string>;
// (undocumented)
readonly kind: 'directory';
// (undocumented)
removeEntry(name: string, options?: FileSystemRemoveOptions_2): Promise<void>;
// (undocumented)
resolve(possibleDescendant: FileSystemHandle_2): Promise<string[] | null>;
// (undocumented)
values(): AsyncIterableIterator<FileSystemHandle_2>;
}
export { FileSystemDirectoryHandle_2 as FileSystemDirectoryHandle }
// @public
interface FileSystemFileHandle_2 extends FileSystemHandle_2 {
// (undocumented)
createWritable(options?: FileSystemCreateWritableOptions_2): Promise<FileSystemWritableFileStream_2>;
// (undocumented)
getFile(): Promise<File>;
// (undocumented)
readonly kind: 'file';
}
export { FileSystemFileHandle_2 as FileSystemFileHandle }
// @public
interface FileSystemGetDirectoryOptions_2 {
// (undocumented)
create?: boolean;
}
export { FileSystemGetDirectoryOptions_2 as FileSystemGetDirectoryOptions }
// @public
interface FileSystemGetFileOptions_2 {
// (undocumented)
create?: boolean;
}
export { FileSystemGetFileOptions_2 as FileSystemGetFileOptions }
// @public
interface FileSystemHandle_2 {
// (undocumented)
isSameEntry(other: FileSystemHandle_2): Promise<boolean>;
// (undocumented)
readonly kind: 'file' | 'directory';
// (undocumented)
readonly name: string;
// (undocumented)
queryPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
// (undocumented)
requestPermission(descriptor?: FileSystemHandlePermissionDescriptor): Promise<PermissionState>;
}
export { FileSystemHandle_2 as FileSystemHandle }
// @public
export interface FileSystemHandlePermissionDescriptor {
// (undocumented)
mode?: 'read' | 'readwrite';
}
// @public
interface FileSystemRemoveOptions_2 {
// (undocumented)
recursive?: boolean;
}
export { FileSystemRemoveOptions_2 as FileSystemRemoveOptions }
// @public
interface FileSystemWritableFileStream_2 extends WritableStream {
// (undocumented)
seek(position: number): Promise<void>;
// (undocumented)
truncate(size: number): Promise<void>;
// (undocumented)
write(data: BufferSource | Blob | string): Promise<void>;
}
export { FileSystemWritableFileStream_2 as FileSystemWritableFileStream }
declare namespace FileTreeHelpers {
export {
fromFileList,
fromDirectoryUpload,
getOriginalFile,
extractFileListMetadata,
extractFileMetadata,
defaultFileApiTreeInitParams
}
}
// @public
function fromDirectoryUpload(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
// @public
function fromFileList(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>;
// @public
function getOriginalFile(fileList: FileList, path: string): Result<File>;
// @public
export interface IDirectoryHandleTreeInitializer {
// (undocumented)
readonly dirHandles: FileSystemDirectoryHandle_2[];
// (undocumented)
readonly nonRecursive?: boolean;
// (undocumented)
readonly prefix?: string;
}
// @public
export interface IFileHandleTreeInitializer {
// (undocumented)
readonly fileHandles: FileSystemFileHandle_2[];
// (undocumented)
readonly prefix?: string;
}
// @public
export interface IFileListTreeInitializer {
// (undocumented)
readonly fileList: FileList;
}
// @public
export interface IFileMetadata {
// (undocumented)
lastModified: number;
// (undocumented)
name: string;
// (undocumented)
path: string;
// (undocumented)
size: number;
// (undocumented)
type: string;
}
// @public
export interface IFsAccessApis {
// (undocumented)
showDirectoryPicker(options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2>;
// (undocumented)
showOpenFilePicker(options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[]>;
// (undocumented)
showSaveFilePicker(options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2>;
}
// @public
export function isDirectoryHandle(handle: FileSystemHandle_2): handle is FileSystemDirectoryHandle_2;
// @public
export function isFileHandle(handle: FileSystemHandle_2): handle is FileSystemFileHandle_2;
// @public
export function isFilePath(path: string): boolean;
// @public
export interface IUrlConfigOptions {
config?: string;
configStartDir?: string;
contextFilter?: string;
input?: string;
inputStartDir?: string;
interactive?: boolean;
loadZip?: boolean;
maxDistance?: number;
qualifierDefaults?: string;
reduceQualifiers?: boolean;
resourceTypes?: string;
zipFile?: string;
zipPath?: string;
}
// @public
export function parseContextFilter(contextFilter: string): Record<string, string>;
// @public
export function parseQualifierDefaults(qualifierDefaults: string): Record<string, string[]>;
// @public
export function parseResourceTypes(resourceTypes: string): string[];
// @public
export function parseUrlParameters(): IUrlConfigOptions;
// @public
export function safeShowDirectoryPicker(window: Window, options?: ShowDirectoryPickerOptions): Promise<FileSystemDirectoryHandle_2 | null>;
// @public
export function safeShowOpenFilePicker(window: Window, options?: ShowOpenFilePickerOptions): Promise<FileSystemFileHandle_2[] | null>;
// @public
export function safeShowSaveFilePicker(window: Window, options?: ShowSaveFilePickerOptions): Promise<FileSystemFileHandle_2 | null>;
// @public
export interface ShowDirectoryPickerOptions {
// (undocumented)
id?: string;
// (undocumented)
mode?: 'read' | 'readwrite';
// (undocumented)
startIn?: FileSystemHandle_2 | WellKnownDirectory;
}
// @public
export interface ShowOpenFilePickerOptions {
// (undocumented)
excludeAcceptAllOption?: boolean;
// (undocumented)
id?: string;
// (undocumented)
multiple?: boolean;
// (undocumented)
startIn?: FileSystemHandle_2 | WellKnownDirectory;
// (undocumented)
types?: FilePickerAcceptType[];
}
// @public
export interface ShowSaveFilePickerOptions {
// (undocumented)
excludeAcceptAllOption?: boolean;
// (undocumented)
id?: string;
// (undocumented)
startIn?: FileSystemHandle_2 | WellKnownDirectory;
// (undocumented)
suggestedName?: string;
// (undocumented)
types?: FilePickerAcceptType[];
}
// @public
export function supportsFileSystemAccess(window: Window): window is WindowWithFsAccess;
// @public
export type TreeInitializer = IFileListTreeInitializer | IFileHandleTreeInitializer | IDirectoryHandleTreeInitializer;
// @public
export type WellKnownDirectory = 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos';
// @public
export type WindowWithFsAccess = Window & IFsAccessApis;
```