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 7.0.1 to 7.0.2

19

dist/index.js

@@ -1,4 +0,4 @@

import path, { basename, extname } from 'node:path';
import { basename, extname } from 'node:path';
import { join } from 'node:path/posix';
import { statSync, mkdirSync, createReadStream } from 'node:fs';
import { mkdirSync, statSync, createReadStream } from 'node:fs';
import { writeFile, readFile, opendir, stat, rm } from 'node:fs/promises';

@@ -14,12 +14,4 @@ import { builtins, builtinOutputFormats, parseURL, extractEntries, resolveConfigs, generateTransforms, applyTransforms, urlFormat, getMetadata } from 'imagetools-core';

};
async function generateImageID(url, config, imageBuffer) {
if (url.host) {
const baseURL = new URL(url.origin + url.pathname);
return hash([baseURL.href, JSON.stringify(config), imageBuffer]);
}
// baseURL isn't a valid URL, but just a string used for an identifier
// use a relative path in the local case so that it's consistent across machines
const baseURL = new URL(url.protocol + path.relative(process.cwd(), url.pathname));
const { mtime } = statSync(path.resolve(process.cwd(), decodeURIComponent(url.pathname)));
return hash([baseURL.href, JSON.stringify(config), mtime.getTime().toString()]);
function generateImageID(config, imageHash) {
return hash([JSON.stringify(config), imageHash]);
}

@@ -116,4 +108,5 @@ function hash(keyParts) {

const imageBuffer = await img.clone().toBuffer();
const imageHash = hash([imageBuffer]);
for (const config of imageConfigs) {
const id = await generateImageID(srcURL, config, imageBuffer);
const id = generateImageID(config, imageHash);
let image;

@@ -120,0 +113,0 @@ let metadata;

/// <reference types="node" resolution-mode="require"/>
import type { ImageConfig } from 'imagetools-core';
export declare const createBasePath: (base?: string) => string;
export declare function generateImageID(url: URL, config: ImageConfig, imageBuffer: Buffer): Promise<string>;
export declare function generateImageID(config: ImageConfig, imageHash: string): string;
export declare function hash(keyParts: Array<string | NodeJS.ArrayBufferView>): string;
{
"name": "vite-imagetools",
"description": "Load and transform images using a toolbox of import directives!",
"version": "7.0.1",
"version": "7.0.2",
"type": "module",

@@ -6,0 +6,0 @@ "types": "dist/index.d.ts",

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