@types/spritesmith
TypeScript icon, indicating that this package has built-in type declarations

3.4.5 • Public • Published

Installation

npm install --save @types/spritesmith

Summary

This package contains type definitions for spritesmith (https://github.com/twolfson/spritesmith).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spritesmith.

index.d.ts

import { Transform } from "stream";
import { BufferFile } from "vinyl";

declare class Spritesmith {
    constructor(params?: Spritesmith.SpritesmithParams);
    static run(
        params:
            & Spritesmith.SpritesmithParams
            & Spritesmith.SpritesmithProcessImagesOptions
            & {
                src: Spritesmith.SpritesmithCreateImagesSrc;
            },
        callback: (err: Error | null, result: Spritesmith.SpritesmithResult) => void,
    ): void;
    createImages(
        src: Spritesmith.SpritesmithCreateImagesSrc,
        callback: (err: Error | null, images: Spritesmith.SpritesmithImage[]) => void,
    ): void;
    processImages(
        images: Spritesmith.SpritesmithImage[],
        options?: Spritesmith.SpritesmithProcessImagesOptions,
    ): Spritesmith.SpritesmithResult<Transform>;
}

declare namespace Spritesmith {
    interface SpritesmithParams {
        engine?: string;
        engineOpts?: Record<string, unknown>;
    }

    type SpritesmithCreateImagesSrc = Array<string | BufferFile>;
    interface SpritesmithImage {
        width: number;
        height: number;
        [key: string]: unknown;
    }

    interface SpritesmithProcessImagesOptions {
        padding?: number;
        exportOpts?: {
            format?: "png" | "jpg" | "jpeg" | "webp";
            quality?: number;
            background?: string;
            [key: string]: unknown;
        };
        algorithm?: "top-down" | "left-right" | "diagonal" | "alt-diagonal" | "binary-tree";
        algorithmOpts?: {
            sort?: boolean;
        };
    }

    interface SpritesmithResult<Image extends Buffer | Transform = Buffer> {
        image: Image;
        coordinates: Record<string, { x: number; y: number; width: number; height: number }>;
        properties: { width: number; height: number };
    }
}

export = Spritesmith;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: @types/vinyl

Credits

These definitions were written by Zenoo.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/spritesmith

Weekly Downloads

1,354

Version

3.4.5

License

MIT

Unpacked Size

6.35 kB

Total Files

5

Last publish

Collaborators

  • types