@shockpkg/core
Version:
shockpkg core
124 lines (123 loc) • 2.66 kB
TypeScript
import { Transform } from 'node:stream';
export interface IPackagesListPackage {
/**
* Package name.
*/
name: string;
/**
* File name.
*/
file: string;
/**
* File size.
*/
size: number;
/**
* SHA256 hash of the file contents.
*/
sha256: string;
/**
* SHA1 hash of the file contents.
*/
sha1: string;
/**
* MD5 hash of the file contents.
*/
md5: string;
/**
* Source, URL for root or file path for children.
*/
source: string;
/**
* Optional child package list.
*/
packages?: IPackagesListPackage[];
/**
* Zipped info if a child package or null if a root package.
*/
zipped?: string;
}
/**
* Package object.
*/
export declare class Package {
/**
* Package name.
*/
readonly name: string;
/**
* File name.
*/
readonly file: string;
/**
* File size.
*/
readonly size: number;
/**
* SHA256 hash of file.
*/
readonly sha256: string;
/**
* SHA1 hash of file.
*/
readonly sha1: string;
/**
* MD5 hash of file.
*/
readonly md5: string;
/**
* Source path, URL for root, file path for child packages.
*/
readonly source: string;
/**
* Zipped info if a child package or null if a root package.
*/
readonly zipped: string | null;
/**
* Child packages.
*/
readonly packages: Package[];
/**
* The parent package this package is found in.
*/
readonly parent: Package | null;
/**
* Package constructor.
*
* @param info Package info.
* @param parent Package parent.
*/
constructor(info: Readonly<IPackagesListPackage>, parent?: Package | null);
/**
* Get zipped compression method.
*
* @returns Compression method.
*/
getZippedCompression(): number;
/**
* Get zipped data slice.
*
* @returns Data start and size.
*/
getZippedSlice(): [number, number];
/**
* Get zipped data decompressor.
*
* @returns Transform stream or null if entry not compressed.
*/
getZippedDecompressor(): Transform | null;
/**
* Create child packages list.
*
* @param infos Package infos.
* @returns Package instance.
*/
protected _createPackages(infos?: readonly Readonly<IPackagesListPackage>[]): Package[];
/**
* Create a child package.
*
* @param info Package info.
* @returns Package instance.
*/
protected _createPackage(info: Readonly<IPackagesListPackage>): Package;
}