@bscotch/stitch
Version:
Stitch: The GameMaker Studio 2 Asset Pipeline Development Kit.
45 lines • 1.68 kB
TypeScript
import { Pathy } from '@bscotch/pathy';
import { ZodSchema, ZodTypeDef } from 'zod';
import { type DeletedAsset, type Asset, type AudioAsset } from './assetSource.types.js';
/**
* Compute the type of a record that results from diffing
* the keys of two records (the keys that are only in the `Left` record).
*/
export type DiffByKeys<Left, Right> = {
[Key in keyof Left as Key extends keyof Right ? never : Key]: Left[Key];
};
/**
* Vue-style props definitions, with prop names as keys mapping to
* functions that return the prop value.
*/
export type Props<T, S> = {
[Key in keyof T]: (arg: S) => T[Key] | Promise<T[Key]>;
};
export interface AssetSourceFileOptions<T extends Asset> {
/**
* Path to the file, such that the instance cwd is the
* directory containing the config.
*/
path: Pathy;
metaSchema: ZodSchema<T, ZodTypeDef, unknown>;
props: Props<DiffByKeys<T, Asset>, this>;
meta?: T | DeletedAsset;
}
export declare class AssetSourceFile<T extends Asset> {
protected options: AssetSourceFileOptions<T>;
constructor(options: AssetSourceFileOptions<T>);
get path(): Pathy<unknown>;
isDeleted(): Promise<boolean>;
/**
* If the file does not exist, returns `undefined`. Else
* returns its checksum.
*/
computeChecksum(): Promise<string | undefined>;
refresh(): Promise<this>;
toJSON(): T | DeletedAsset;
}
export declare class AssetSourceFileAudio extends AssetSourceFile<AudioAsset> {
constructor(path: Pathy, meta?: AudioAsset | DeletedAsset);
static from(path: Pathy, meta: AudioAsset | DeletedAsset): AssetSourceFileAudio;
}
//# sourceMappingURL=AssetSourceFile.d.ts.map