Socket
Socket
Sign inDemoInstall

@expo/image-utils

Package Overview
Dependencies
Maintainers
27
Versions
93
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.5.2-canary-20240719-83ee47b to 0.5.2-canary-20240814-ce0f7d5

20

build/Download.js

@@ -10,6 +10,6 @@ "use strict";

const jimp_compact_1 = __importDefault(require("jimp-compact"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const path_1 = __importDefault(require("path"));
const stream_1 = __importDefault(require("stream"));
const tempy_1 = __importDefault(require("tempy"));
const temp_dir_1 = __importDefault(require("temp-dir"));
const unique_string_1 = __importDefault(require("unique-string"));
const util_1 = __importDefault(require("util"));

@@ -21,2 +21,7 @@ // cache downloaded images into memory

}
function temporaryDirectory() {
const directory = path_1.default.join(temp_dir_1.default, (0, unique_string_1.default)());
fs_extra_1.default.mkdirSync(directory);
return directory;
}
async function downloadOrUseCachedImage(url) {

@@ -36,11 +41,16 @@ if (url in cacheDownloadedKeys) {

async function downloadImage(url) {
const outputPath = tempy_1.default.directory();
const response = await (0, node_fetch_1.default)(url);
const outputPath = temporaryDirectory();
const response = await fetch(url);
if (!response.ok) {
throw new Error(`It was not possible to download image from '${url}'`);
}
if (!response.body) {
throw new Error(`No response received from '${url}'`);
}
// Download to local file
const streamPipeline = util_1.default.promisify(stream_1.default.pipeline);
const localPath = path_1.default.join(outputPath, path_1.default.basename(stripQueryParams(url)));
await streamPipeline(response.body, fs_extra_1.default.createWriteStream(localPath));
// Type casting is required, see: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65542
const readableBody = stream_1.default.Readable.fromWeb(response.body);
await streamPipeline(readableBody, fs_extra_1.default.createWriteStream(localPath));
// If an image URL doesn't have a name, get the mime type and move the file.

@@ -47,0 +57,0 @@ const img = await jimp_compact_1.default.read(localPath);

{
"name": "@expo/image-utils",
"version": "0.5.2-canary-20240719-83ee47b",
"version": "0.5.2-canary-20240814-ce0f7d5",
"description": "A package used by Expo CLI for processing images",

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

"jimp-compact": "0.16.1",
"node-fetch": "^2.6.0",
"parse-png": "^2.1.0",
"resolve-from": "^5.0.0",
"semver": "^7.6.0",
"tempy": "0.3.0"
"temp-dir": "~2.0.0",
"unique-string": "~2.0.0"
},

@@ -49,5 +49,4 @@ "devDependencies": {

"@types/getenv": "^0.7.0",
"@types/node-fetch": "^2.6.5",
"@types/semver": "^6.0.0",
"expo-module-scripts": "3.6.0-canary-20240719-83ee47b"
"expo-module-scripts": "3.6.0-canary-20240814-ce0f7d5"
},

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

},
"gitHead": "83ee47b5c89c7f1b1a5101189580eaf3555f5962"
"gitHead": "ce0f7d5c7eaec2c8d06ee4e0dc0e58cd6c1612ed"
}

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