molstar
Version:
A comprehensive macromolecular library.
59 lines (58 loc) • 1.9 kB
TypeScript
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { UUID } from './uuid';
import { DataType, DataResponse } from './data-source';
import { Task } from '../mol-task';
export { AssetManager, Asset };
declare type _File = File;
declare type Asset = Asset.Url | Asset.File;
declare namespace Asset {
type Url = {
kind: 'url';
id: UUID;
url: string;
title?: string;
body?: string;
headers?: [string, string][];
};
type File = {
kind: 'file';
id: UUID;
name: string;
file?: _File;
};
function Url(url: string, options?: {
body?: string;
title?: string;
headers?: [string, string][];
}): Url;
function File(file: _File): File;
function isUrl(x?: Asset): x is Url;
function isFile(x?: Asset): x is File;
interface Wrapper<T extends DataType = DataType> {
readonly data: DataResponse<T>;
dispose: () => void;
}
function Wrapper<T extends DataType = DataType>(data: DataResponse<T>, asset: Asset, manager: AssetManager): {
data: DataResponse<T>;
dispose: () => void;
};
function getUrl(url: string | Url): string;
function getUrlAsset(manager: AssetManager, url: string | Url, body?: string): Url;
}
declare class AssetManager {
private _assets;
get assets(): {
asset: Asset;
file: File;
refCount: number;
}[];
tryFindUrl(url: string, body?: string): Asset.Url | undefined;
set(asset: Asset, file: File): void;
resolve<T extends DataType>(asset: Asset, type: T, store?: boolean): Task<Asset.Wrapper<T>>;
release(asset: Asset): void;
}