New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vite-imagetools

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-imagetools - npm Package Compare versions

Comparing version 3.0.0-next.5 to 3.0.0-next.6

9

dist/directives/background.d.ts

@@ -1,2 +0,7 @@

import { DirectiveContext, DirectiveOptions } from "../types";
export declare const background: ({ background }: DirectiveOptions, ctx: DirectiveContext) => any;
import { Color } from "sharp";
import { MetaDirective } from "../types";
interface BackgroundOptions {
background: string;
}
export declare const background: MetaDirective<BackgroundOptions, Color>;
export {};

@@ -1,3 +0,8 @@

import { FitEnum } from "sharp";
import { DirectiveContext, DirectiveOptions } from "../types";
export declare const fit: ({ fit }: DirectiveOptions, ctx: DirectiveContext) => keyof FitEnum;
import { MetaDirective } from "../types";
interface FitOptions {
fit: FitValue;
}
export declare const fitValues: readonly ["cover", "contain", "fill", "inside", "outside"];
export declare type FitValue = typeof fitValues[number];
export declare const fit: MetaDirective<FitOptions, FitValue>;
export {};

@@ -1,6 +0,10 @@

import { Directive, ImageFormat } from "../types";
import { Directive } from "../types";
declare type FormatShorthandOptions = {
[key in ImageFormat]?: '';
};
interface FormatOptions {
format: ImageFormat;
}
export declare const format: Directive<FormatOptions>;
export declare type ImageFormat = 'heic' | 'heif' | 'avif' | 'jpeg' | 'jpg' | 'png' | 'tiff' | 'webp' | 'gif';
export declare const format: Directive<FormatOptions | FormatShorthandOptions>;
export {};
import { Directive } from "../types";
interface FlipOptions {
interface InvertOptions {
invert: string;
}
export declare const invert: Directive<FlipOptions>;
export declare const invert: Directive<InvertOptions>;
export {};

@@ -1,3 +0,8 @@

import { KernelEnum } from "sharp";
import { DirectiveContext, DirectiveOptions } from "../types";
export declare const kernel: ({ kernel }: DirectiveOptions, ctx: DirectiveContext) => keyof KernelEnum;
import { MetaDirective } from "../types";
interface KernelOptions {
kernel: KernelValue;
}
export declare const kernelValues: readonly ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"];
export declare type KernelValue = typeof kernelValues[number];
export declare const kernel: MetaDirective<KernelOptions, KernelValue>;
export {};
import { Directive } from "../types";
interface FlipOptions {
interface NormalizeOptions {
normalize: string;
}
export declare const normalize: Directive<FlipOptions>;
export declare const normalize: Directive<NormalizeOptions>;
export {};

@@ -1,2 +0,8 @@

import { DirectiveContext, DirectiveOptions } from "../types";
export declare const position: ({ position }: DirectiveOptions, ctx: DirectiveContext) => any;
import { MetaDirective } from "../types";
interface PositionOptions {
position: PositionValue;
}
export declare const positionValues: readonly ["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "center", "centre", "cover", "entropy", "attention"];
export declare type PositionValue = typeof positionValues[number];
export declare const position: MetaDirective<PositionOptions, PositionValue>;
export {};

@@ -1,2 +0,6 @@

import { DirectiveContext, DirectiveOptions } from "../types";
export declare const quality: ({ quality: _quality }: DirectiveOptions, ctx: DirectiveContext) => number;
import { MetaDirective } from "../types";
interface QualityOptions {
quality: string;
}
export declare const quality: MetaDirective<QualityOptions, number>;
export {};

@@ -7,5 +7,4 @@ import { Directive } from "../types";

w: string;
background: string;
}
export declare const resize: Directive<ResizeOptions>;
export {};

@@ -48,3 +48,4 @@ import type { Sharp } from 'sharp';

*/
export declare type Directive<A = {}> = (cfg: DirectiveOptions & A, ctx: DirectiveContext) => ImageTransformation | null;
export declare type Directive<A = {}> = (cfg: Partial<DirectiveOptions & A>, ctx: DirectiveContext) => ImageTransformation | null;
export declare type MetaDirective<A = {}, T = any> = (cfg: Partial<DirectiveOptions & A>, ctx: DirectiveContext) => T | null;
/**

@@ -68,2 +69,1 @@ * A function that takes an image applies some transformations and returns the image.

}
export declare type ImageFormat = 'heic' | 'heif' | 'avif' | 'jpeg' | 'jpg' | 'png' | 'tiff' | 'webp' | 'gif';

@@ -0,14 +1,52 @@

/// <reference types="node" />
import { Sharp } from "sharp";
import { Directive, DirectiveOptions, ImageTransformation } from "./types";
/**
* This function calculates the cartesian product of two or more array and is straight from stackoverflow ;)
* Should be replaced with something more legible but works for now.
* @internal
*/
export declare const cartesian: (...a: any[]) => any;
export declare function buildDirectiveOptions(src: URL): DirectiveOptions[];
export declare function buildTransforms(config: DirectiveOptions, directives: Directive[]): {
metadata: {};
/**
* This function extracts all parameters from a given URL and returns them as an array of entries.
* @param src the url to get the parameter from
* @returns
*/
export declare function extractParameterEntries(src: URL): [string, string[]][];
/**
* This function builds up all possible combinations the given entries can be combined
* an returns it as an array of objects that can be given to a the directives.
* @param entries The url parameter entries
* @returns An array of directive options
*/
export declare function buildDirectiveOptions(entries: [string, string[]][]): {
[k: string]: string;
}[];
/**
* This method takes a directive options and an array of directives,
* invoking each directive with the config an evaluating each return.
* This builds up an array of transformation functions that can then be applied to the Sharp image instance.
* @param options The directive options
* @param directives The directives to apply
* @returns An array of ImageTransforms
*/
export declare function buildTransforms(options: DirectiveOptions, directives: Directive[]): {
metadata: Record<string, any>;
transforms: ImageTransformation[];
parametersUsed: Set<unknown>;
};
export declare function restoreFromCache(id: string, cachePath: string): Promise<import("cacache").GetCacheObject | {
data: any;
/**
* This function tries to load a given id from cache and return the data + metadata.
* If loading fails (i.e. the image is not cached) it will return and empty object.
* @param id The image cache ID to restore
* @param cachePath The cache path to restore from
* @returns The image data and metadata
*/
export declare function restoreFromCache(id: string, cachePath: string): Promise<{
data: Buffer;
metadata: any;
} | {
data?: undefined;
metadata?: undefined;
}>;
export declare function transformImage(image: Sharp, transforms: ImageTransformation[]): Sharp;
{
"name": "vite-imagetools",
"version": "3.0.0-next.5",
"version": "3.0.0-next.6",
"main": "dist/index.cjs",

@@ -5,0 +5,0 @@ "module": "dist/index.mjs",

@@ -53,3 +53,3 @@ # vite-imagetools :toolbox:

For example the following diretive will turn the _jpg_ image into a _webp_ one and resize it to be 400 pixels wide:
```
```js
import Logo from 'example.jpg?format=webp&width=400'

@@ -84,3 +84,3 @@ ```

This functionality is especially useful when generating responsive images, as you can easily generate a list of different widths.
(You can even generate a correct srcset as output! See [output formats](#output-formats)) for details.)
(You can even generate a correct srcset as output! See [output formats](#output-formats) for details.)

@@ -273,2 +273,2 @@ ## Install

## License
[MIT © Jonas Kruckenberg.](./LICENSE)
[MIT © Jonas Kruckenberg.](./LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc