Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expo/image-utils

Package Overview
Dependencies
Maintainers
26
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/image-utils - npm Package Compare versions

Comparing version 0.0.1-canary-20231205-250b31f to 0.0.1-canary-20240109-93608d8

1

build/Image.d.ts
/// <reference types="node" />
import { ImageOptions } from './Image.types';
export declare function getMimeType(srcPath: string): string | null;
export declare function generateImageAsync(options: {

@@ -4,0 +5,0 @@ projectRoot: string;

39

build/Image.js

@@ -29,7 +29,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getPngInfo = exports.compositeImagesAsync = exports.generateFaviconAsync = exports.generateImageAsync = void 0;
exports.getPngInfo = exports.compositeImagesAsync = exports.generateFaviconAsync = exports.generateImageAsync = exports.getMimeType = void 0;
const chalk_1 = __importDefault(require("chalk"));
const fs_1 = __importDefault(require("fs"));
const mime_1 = __importDefault(require("mime"));
const parse_png_1 = __importDefault(require("parse-png"));
const path_1 = __importDefault(require("path"));
const Cache = __importStar(require("./Cache"));

@@ -41,3 +41,2 @@ const Download = __importStar(require("./Download"));

const Sharp = __importStar(require("./sharp"));
const supportedMimeTypes = ['image/png', 'image/jpeg', 'image/webp', 'image/gif'];
let hasWarned = false;

@@ -129,2 +128,29 @@ async function resizeImagesAsync(buffer, sizes) {

}
const types = {
png: 'image/png',
jpeg: 'image/jpeg',
jpg: 'image/jpeg',
jpe: 'image/jpeg',
webp: 'image/webp',
gif: 'image/gif',
};
const inverseMimeTypes = {
'image/png': 'png',
'image/jpeg': 'jpg',
'image/webp': 'webp',
'image/gif': 'gif',
};
function getMimeType(srcPath) {
if (typeof srcPath !== 'string')
return null;
try {
// If the path is a URL, use the pathname
const url = new URL(srcPath);
srcPath = url.pathname;
}
catch { }
const ext = path_1.default.extname(srcPath).replace(/^\./, '');
return types[ext] ?? null;
}
exports.getMimeType = getMimeType;
async function ensureImageOptionsAsync(imageOptions) {

@@ -139,11 +165,8 @@ const icon = {

}
const mimeType = mime_1.default.getType(icon.src);
const mimeType = getMimeType(icon.src);
if (!mimeType) {
throw new Error(`Invalid mimeType for image with source: ${icon.src}`);
}
if (!supportedMimeTypes.includes(mimeType)) {
throw new Error(`Supplied image is not a supported image type: ${imageOptions.src}`);
}
if (!icon.name) {
icon.name = `icon_${getDimensionsId(imageOptions)}.${mime_1.default.getExtension(mimeType)}`;
icon.name = `icon_${getDimensionsId(imageOptions)}.${inverseMimeTypes[mimeType]}`;
}

@@ -150,0 +173,0 @@ return icon;

{
"name": "@expo/image-utils",
"version": "0.0.1-canary-20231205-250b31f",
"version": "0.0.1-canary-20240109-93608d8",
"description": "A package used by Expo CLI for processing images",

@@ -39,3 +39,2 @@ "main": "build/index.js",

"jimp-compact": "0.16.1",
"mime": "^2.4.4",
"node-fetch": "^2.6.0",

@@ -50,6 +49,5 @@ "parse-png": "^2.1.0",

"@types/getenv": "^0.7.0",
"@types/mime": "^2.0.3",
"@types/node-fetch": "^2.6.5",
"@types/semver": "^6.0.0",
"expo-module-scripts": "0.0.1-canary-20231205-250b31f"
"expo-module-scripts": "0.0.1-canary-20240109-93608d8"
},

@@ -59,3 +57,3 @@ "publishConfig": {

},
"gitHead": "250b31f516a04578a29c6bcda29aab80ef4d4e2d"
"gitHead": "93608d8dcb0268312e0c8ed22036ebfa6efe9830"
}

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