first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

21
node_modules/@expo/image-utils/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

20
node_modules/@expo/image-utils/README.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
<!-- Title -->
<h1 align="center">
👋 Welcome to <br><code>@expo/image-utils</code>
</h1>
<p align="center">A library for image processing functionality in Expo CLI.</p>
<!-- Body -->
It uses `sharp` for image processing if it's available through a global `sharp-cli` installation. Otherwise it uses `jimp`, a Node library with no native dependencies, and warns the user that they may want to install `sharp-cli` for faster image processing.
## Advanced Configuration
This package can be configured using the following environment variables.
### EXPO_IMAGE_UTILS_NO_SHARP
When truthy, this will force global `sharp-cli` resolution methods like `isAvailableAsync()` and `findSharpInstanceAsync()` to fail. Other processes can use this to fallback on Jimp for image modifications. By default this is falsy (undefined).
`findSharpInstanceAsync()` will throw an error if disabled because it shouldn't be invoked if `isAvailableAsync()` returns `false`.

7
node_modules/@expo/image-utils/build/Cache.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { ImageOptions } from './Image.types';
export declare function createCacheKey(fileSource: string, properties: string[]): string;
export declare function createCacheKeyWithDirectoryAsync(projectRoot: string, type: string, icon: ImageOptions): Promise<string>;
export declare function ensureCacheDirectory(projectRoot: string, type: string, cacheKey: string): Promise<string>;
export declare function getImageFromCacheAsync(fileName: string, cacheKey: string): Promise<null | Buffer>;
export declare function cacheImageAsync(fileName: string, buffer: Buffer, cacheKey: string): Promise<void>;
export declare function clearUnusedCachesAsync(projectRoot: string, type: string): Promise<void>;

81
node_modules/@expo/image-utils/build/Cache.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCacheKey = createCacheKey;
exports.createCacheKeyWithDirectoryAsync = createCacheKeyWithDirectoryAsync;
exports.ensureCacheDirectory = ensureCacheDirectory;
exports.getImageFromCacheAsync = getImageFromCacheAsync;
exports.cacheImageAsync = cacheImageAsync;
exports.clearUnusedCachesAsync = clearUnusedCachesAsync;
const crypto_1 = __importDefault(require("crypto"));
const fs_1 = __importDefault(require("fs"));
const path_1 = require("path");
const CACHE_LOCATION = '.expo/web/cache/production/images';
const cacheKeys = {};
// Calculate SHA256 Checksum value of a file based on its contents
function calculateHash(filePath) {
const contents = filePath.startsWith('http') ? filePath : fs_1.default.readFileSync(filePath);
return crypto_1.default.createHash('sha256').update(contents).digest('hex');
}
// Create a hash key for caching the images between builds
function createCacheKey(fileSource, properties) {
const hash = calculateHash(fileSource);
return [hash].concat(properties).filter(Boolean).join('-');
}
async function createCacheKeyWithDirectoryAsync(projectRoot, type, icon) {
const iconProperties = [icon.resizeMode];
if (icon.backgroundColor) {
iconProperties.push(icon.backgroundColor);
}
const cacheKey = `${type}-${createCacheKey(icon.src, iconProperties)}`;
if (!(cacheKey in cacheKeys)) {
cacheKeys[cacheKey] = await ensureCacheDirectory(projectRoot, type, cacheKey);
}
return cacheKey;
}
async function ensureCacheDirectory(projectRoot, type, cacheKey) {
const cacheFolder = (0, path_1.join)(projectRoot, CACHE_LOCATION, type, cacheKey);
await fs_1.default.promises.mkdir(cacheFolder, { recursive: true });
return cacheFolder;
}
async function getImageFromCacheAsync(fileName, cacheKey) {
try {
return await fs_1.default.promises.readFile((0, path_1.resolve)(cacheKeys[cacheKey], fileName));
}
catch {
return null;
}
}
async function cacheImageAsync(fileName, buffer, cacheKey) {
try {
await fs_1.default.promises.writeFile((0, path_1.resolve)(cacheKeys[cacheKey], fileName), buffer);
}
catch (error) {
console.warn(`Error caching image: "${fileName}". ${error.message}`);
}
}
async function clearUnusedCachesAsync(projectRoot, type) {
// Clean up any old caches
const cacheFolder = (0, path_1.join)(projectRoot, CACHE_LOCATION, type);
await fs_1.default.promises.mkdir(cacheFolder, { recursive: true });
const currentCaches = await fs_1.default.promises.readdir(cacheFolder);
if (!Array.isArray(currentCaches)) {
console.warn('Failed to read the icon cache');
return;
}
const deleteCachePromises = [];
for (const cache of currentCaches) {
// skip hidden folders
if (cache.startsWith('.')) {
continue;
}
// delete
if (!(cache in cacheKeys)) {
deleteCachePromises.push(fs_1.default.promises.rm((0, path_1.join)(cacheFolder, cache), { force: true, recursive: true }));
}
}
await Promise.all(deleteCachePromises);
}
//# sourceMappingURL=Cache.js.map

1
node_modules/@expo/image-utils/build/Cache.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../src/Cache.ts"],"names":[],"mappings":";;;;;AAiBA,wCAGC;AAED,4EAiBC;AAED,oDAQC;AAED,wDASC;AAED,0CAUC;AAED,wDA0BC;AApGD,oDAA4B;AAC5B,4CAAoB;AACpB,+BAAqC;AAIrC,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D,MAAM,SAAS,GAA8B,EAA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K,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,MAAM,mBAAmB,GAAoB,EAAE,CAAC;IAChD,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;QAClC,sBAAsB;QACtB,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,SAAS;QACT,IAAI,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,EAAE,CAAC;YAC1B,mBAAmB,CAAC,IAAI,CACtB,YAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAC3E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC"}

2
node_modules/@expo/image-utils/build/Download.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare function downloadOrUseCachedImage(url: string): Promise<string>;
export declare function downloadImage(url: string): Promise<string>;

68
node_modules/@expo/image-utils/build/Download.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.downloadOrUseCachedImage = downloadOrUseCachedImage;
exports.downloadImage = downloadImage;
const crypto_1 = require("crypto");
const fs_1 = __importDefault(require("fs"));
// @ts-ignore
const jimp_compact_1 = __importDefault(require("jimp-compact"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const stream_1 = __importDefault(require("stream"));
const util_1 = __importDefault(require("util"));
// cache downloaded images into memory
const cacheDownloadedKeys = {};
function stripQueryParams(url) {
return url.split('?')[0].split('#')[0];
}
function temporaryDirectory() {
const directory = path_1.default.join(os_1.default.tmpdir(), (0, crypto_1.randomBytes)(16).toString('hex'));
fs_1.default.mkdirSync(directory, { recursive: true });
return directory;
}
async function downloadOrUseCachedImage(url) {
if (url in cacheDownloadedKeys) {
return cacheDownloadedKeys[url];
}
if (url.startsWith('http')) {
cacheDownloadedKeys[url] = await downloadImage(url);
}
else {
cacheDownloadedKeys[url] = url;
}
return cacheDownloadedKeys[url];
}
async function downloadImage(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)));
// 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_1.default.createWriteStream(localPath));
// If an image URL doesn't have a name, get the mime type and move the file.
const img = await jimp_compact_1.default.read(localPath);
const mime = img.getMIME().split('/').pop();
if (!localPath.endsWith(mime)) {
const newPath = path_1.default.join(outputPath, `image.${mime}`);
const parentPath = path_1.default.dirname(newPath);
if (!fs_1.default.existsSync(parentPath)) {
await fs_1.default.promises.mkdir(parentPath, { recursive: true });
}
// NOTE: EXDEV can't happen since we're just renaming the file in the same directory
await fs_1.default.promises.rename(localPath, newPath);
return newPath;
}
return localPath;
}
//# sourceMappingURL=Download.js.map

1
node_modules/@expo/image-utils/build/Download.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Download.js","sourceRoot":"","sources":["../src/Download.ts"],"names":[],"mappings":";;;;;AAuBA,4DAUC;AAED,sCAiCC;AApED,mCAAqC;AACrC,4CAAoB;AACpB,aAAa;AACb,gEAAgC;AAChC,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAE5B,gDA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AAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}

1
node_modules/@expo/image-utils/build/Ico.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function generateAsync(buffers: Buffer[]): Promise<Buffer>;

97
node_modules/@expo/image-utils/build/Ico.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateAsync = generateAsync;
// Inspired by https://github.com/kevva/to-ico but reuses existing packages to keep bundle size small.
const parse_png_1 = __importDefault(require("parse-png"));
const constants = {
directorySize: 16,
bitmapSize: 40,
headerSize: 6,
colorMode: 0,
};
function createHeader(header) {
const buffer = Buffer.alloc(constants.headerSize);
buffer.writeUInt16LE(0, 0);
buffer.writeUInt16LE(1, 2);
buffer.writeUInt16LE(header, 4);
return buffer;
}
function createDirectory(data, offset) {
const buffer = Buffer.alloc(constants.directorySize);
const size = data.data.length + constants.bitmapSize;
const width = data.width === 256 ? 0 : data.width;
const height = data.height === 256 ? 0 : data.height;
const bpp = data.bpp * 8;
buffer.writeUInt8(width, 0);
buffer.writeUInt8(height, 1);
buffer.writeUInt8(0, 2);
buffer.writeUInt8(0, 3);
buffer.writeUInt16LE(1, 4);
buffer.writeUInt16LE(bpp, 6);
buffer.writeUInt32LE(size, 8);
buffer.writeUInt32LE(offset, 12);
return buffer;
}
function createBitmap(data, compression) {
const buffer = Buffer.alloc(constants.bitmapSize);
buffer.writeUInt32LE(constants.bitmapSize, 0);
buffer.writeInt32LE(data.width, 4);
buffer.writeInt32LE(data.height * 2, 8);
buffer.writeUInt16LE(1, 12);
buffer.writeUInt16LE(data.bpp * 8, 14);
buffer.writeUInt32LE(compression, 16);
buffer.writeUInt32LE(data.data.length, 20);
buffer.writeInt32LE(0, 24);
buffer.writeInt32LE(0, 28);
buffer.writeUInt32LE(0, 32);
buffer.writeUInt32LE(0, 36);
return buffer;
}
function createDIB(data, width, height, bpp) {
const cols = width * bpp;
const rows = height * cols;
const end = rows - cols;
const buffer = Buffer.alloc(data.length);
for (let row = 0; row < rows; row += cols) {
for (let col = 0; col < cols; col += bpp) {
let pos = row + col;
const r = data.readUInt8(pos);
const g = data.readUInt8(pos + 1);
const b = data.readUInt8(pos + 2);
const a = data.readUInt8(pos + 3);
pos = end - row + col;
buffer.writeUInt8(b, pos);
buffer.writeUInt8(g, pos + 1);
buffer.writeUInt8(r, pos + 2);
buffer.writeUInt8(a, pos + 3);
}
}
return buffer;
}
function generateFromPNGs(pngs) {
const header = createHeader(pngs.length);
const arr = [header];
let len = header.length;
let offset = constants.headerSize + constants.directorySize * pngs.length;
for (const png of pngs) {
const dir = createDirectory(png, offset);
arr.push(dir);
len += dir.length;
offset += png.data.length + constants.bitmapSize;
}
for (const png of pngs) {
const header = createBitmap(png, constants.colorMode);
const dib = createDIB(png.data, png.width, png.height, png.bpp);
arr.push(header, dib);
len += header.length + dib.length;
}
return Buffer.concat(arr, len);
}
async function generateAsync(buffers) {
const pngs = await Promise.all(buffers.map((x) => (0, parse_png_1.default)(x)));
return generateFromPNGs(pngs);
}
//# sourceMappingURL=Ico.js.map

1
node_modules/@expo/image-utils/build/Ico.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Ico.js","sourceRoot":"","sources":["../src/Ico.ts"],"names":[],"mappings":";;;;;AAmHA,sCAGC;AAtHD,sGAAsG;AACtG,0DAAiC;AASjC,MAAM,SAAS,GAAG;IAChB,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;CACb,CAAC;AAEF,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAElD,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3B,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,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;QAClB,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC;IACnD,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACtB,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,OAAiB;IACnD,MAAM,IAAI,GAAU,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mBAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}

33
node_modules/@expo/image-utils/build/Image.d.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import { ImageOptions } from './Image.types';
export declare function getMimeType(srcPath: string): string | null;
export declare function generateImageBackgroundAsync(imageOptions: Omit<ImageOptions, 'src'>): Promise<Buffer>;
export declare function generateImageAsync(options: {
projectRoot: string;
cacheType?: string;
}, imageOptions: ImageOptions): Promise<{
source: Buffer;
name: string;
}>;
export declare function generateFaviconAsync(pngImageBuffer: Buffer, sizes?: number[]): Promise<Buffer>;
/**
* Layers the provided foreground image over the provided background image.
*
* @param foregroundImageBuffer
* @param foregroundImageBuffer
* @param x pixel offset from the left edge, defaults to 0.
* @param y pixel offset from the top edge, defaults to 0.
*/
export declare function compositeImagesAsync({ foreground, background, x, y, }: {
foreground: Buffer;
background: Buffer;
x?: number;
y?: number;
}): Promise<Buffer>;
type PNGInfo = {
data: Buffer;
width: number;
height: number;
bpp: number;
};
export declare function getPngInfo(src: string): Promise<PNGInfo>;
export {};

263
node_modules/@expo/image-utils/build/Image.js generated vendored Normal file
View File

@@ -0,0 +1,263 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMimeType = getMimeType;
exports.generateImageBackgroundAsync = generateImageBackgroundAsync;
exports.generateImageAsync = generateImageAsync;
exports.generateFaviconAsync = generateFaviconAsync;
exports.compositeImagesAsync = compositeImagesAsync;
exports.getPngInfo = getPngInfo;
const chalk_1 = __importDefault(require("chalk"));
const fs_1 = __importDefault(require("fs"));
const parse_png_1 = __importDefault(require("parse-png"));
const path_1 = __importDefault(require("path"));
const Cache = __importStar(require("./Cache"));
const Download = __importStar(require("./Download"));
const Ico = __importStar(require("./Ico"));
const env_1 = require("./env");
const Jimp = __importStar(require("./jimp"));
const Sharp = __importStar(require("./sharp"));
let hasWarned = false;
async function resizeImagesAsync(buffer, sizes) {
const sharp = await getSharpAsync();
if (!sharp) {
return Jimp.resizeBufferAsync(buffer, sizes);
}
return Sharp.resizeBufferAsync(buffer, sizes);
}
async function resizeAsync(imageOptions) {
const sharp = await getSharpAsync();
const { width, height, backgroundColor, resizeMode } = imageOptions;
if (!sharp) {
const inputOptions = { input: imageOptions.src, quality: 100 };
const jimp = await Jimp.resize(inputOptions, {
width,
height,
fit: resizeMode,
background: backgroundColor,
});
if (imageOptions.removeTransparency) {
jimp.colorType(2);
}
if (imageOptions.borderRadius) {
// TODO: support setting border radius with Jimp. Currently only support making the image a circle
await Jimp.circleAsync(jimp);
}
// Convert to png buffer
return jimp.getBufferAsync('image/png');
}
try {
let sharpBuffer = sharp(imageOptions.src)
.keepIccProfile()
.ensureAlpha()
.resize(width, height, { fit: resizeMode, background: 'transparent' });
// Skip an extra step if the background is explicitly transparent.
if (backgroundColor && backgroundColor !== 'transparent') {
// Add the background color to the image
sharpBuffer = sharpBuffer.composite([
{
// create a background color
input: {
create: {
width,
height,
// allow alpha colors
channels: imageOptions.removeTransparency ? 3 : 4,
background: backgroundColor,
},
},
// dest-over makes the first image (input) appear on top of the created image (background color)
blend: 'dest-over',
},
]);
}
else if (imageOptions.removeTransparency) {
sharpBuffer.flatten();
}
if (imageOptions.borderRadius) {
const mask = Buffer.from(`<svg><rect x="0" y="0" width="${width}" height="${height}"
rx="${imageOptions.borderRadius}" ry="${imageOptions.borderRadius}"
fill="${backgroundColor && backgroundColor !== 'transparent' ? backgroundColor : 'none'}" /></svg>`);
sharpBuffer.composite([{ input: mask, blend: 'dest-in' }]);
}
return await sharpBuffer.png().toBuffer();
}
catch (error) {
throw new Error(`It was not possible to generate splash screen '${imageOptions.src}'. ${error.message}`);
}
}
async function getSharpAsync() {
if (await Sharp.isAvailableAsync()) {
return await Sharp.findSharpInstanceAsync();
}
return null;
}
function getDimensionsId(imageOptions) {
return imageOptions.width === imageOptions.height
? `${imageOptions.width}`
: `${imageOptions.width}x${imageOptions.height}`;
}
async function maybeWarnAboutInstallingSharpAsync() {
if (env_1.env.EXPO_IMAGE_UTILS_NO_SHARP) {
return;
}
if (env_1.env.EXPO_IMAGE_UTILS_DEBUG && !hasWarned && !(await Sharp.isAvailableAsync())) {
hasWarned = true;
console.warn(chalk_1.default.yellow(`Using node to generate images. This is much slower than using native packages.\n\u203A Optionally you can stop the process and try again after successfully running \`npm install -g sharp-cli\`.\n`));
}
}
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;
}
async function ensureImageOptionsAsync(imageOptions) {
const icon = {
...imageOptions,
src: await Download.downloadOrUseCachedImage(imageOptions.src),
};
// Default to contain
if (!icon.resizeMode) {
icon.resizeMode = 'contain';
}
const mimeType = getMimeType(icon.src);
if (!mimeType) {
throw new Error(`Invalid mimeType for image with source: ${icon.src}`);
}
if (!icon.name) {
icon.name = `icon_${getDimensionsId(imageOptions)}.${inverseMimeTypes[mimeType]}`;
}
return icon;
}
async function generateImageBackgroundAsync(imageOptions) {
const { width, height, backgroundColor, borderRadius } = imageOptions;
const sharp = await getSharpAsync();
if (!sharp) {
const jimp = await Jimp.createSquareAsync({
size: width,
color: backgroundColor,
});
if (borderRadius) {
const image = await Jimp.getJimpImageAsync(jimp);
// TODO: support setting border radius with Jimp. Currently only support making the image a circle
return await Jimp.circleAsync(image);
}
return jimp;
}
const sharpBuffer = sharp({
create: {
width,
height,
channels: 4,
// TODO(cedric): this background color has to be defined for Sharp, but it's optionally typed here
// When we rework `@expo/image-utils`, this needs to be taken into account.
background: backgroundColor,
},
});
if (imageOptions.borderRadius) {
const mask = Buffer.from(`<svg><rect x="0" y="0" width="${width}" height="${height}"
rx="${borderRadius}" ry="${borderRadius}"
fill="${backgroundColor && backgroundColor !== 'transparent' ? backgroundColor : 'none'}" /></svg>`);
sharpBuffer.composite([{ input: mask, blend: 'dest-in' }]);
}
return await sharpBuffer.png().toBuffer();
}
async function generateImageAsync(options, imageOptions) {
const icon = await ensureImageOptionsAsync(imageOptions);
if (!options.cacheType) {
await maybeWarnAboutInstallingSharpAsync();
return { name: icon.name, source: await resizeAsync(icon) };
}
const cacheKey = await Cache.createCacheKeyWithDirectoryAsync(options.projectRoot, options.cacheType, icon);
const name = icon.name;
let source = await Cache.getImageFromCacheAsync(name, cacheKey);
if (!source) {
await maybeWarnAboutInstallingSharpAsync();
source = await resizeAsync(icon);
await Cache.cacheImageAsync(name, source, cacheKey);
}
return { name, source };
}
async function generateFaviconAsync(pngImageBuffer, sizes = [16, 32, 48]) {
const buffers = await resizeImagesAsync(pngImageBuffer, sizes);
return await Ico.generateAsync(buffers);
}
/**
* Layers the provided foreground image over the provided background image.
*
* @param foregroundImageBuffer
* @param foregroundImageBuffer
* @param x pixel offset from the left edge, defaults to 0.
* @param y pixel offset from the top edge, defaults to 0.
*/
async function compositeImagesAsync({ foreground, background, x = 0, y = 0, }) {
const sharp = await getSharpAsync();
if (!sharp) {
const image = (await Jimp.getJimpImageAsync(background)).composite(await Jimp.getJimpImageAsync(foreground), x, y);
return await image.getBufferAsync(image.getMIME());
}
return await sharp(background)
.keepIccProfile()
.composite([{ input: foreground, left: x, top: y }])
.toBuffer();
}
async function getPngInfo(src) {
return await (0, parse_png_1.default)(fs_1.default.readFileSync(src));
}
//# sourceMappingURL=Image.js.map

1
node_modules/@expo/image-utils/build/Image.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

13
node_modules/@expo/image-utils/build/Image.types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export type ResizeMode = 'contain' | 'cover' | 'fill' | 'inside' | 'outside';
export type ImageFormat = 'input' | 'jpeg' | 'jpg' | 'png' | 'raw' | 'tiff' | 'webp';
export type ImageOptions = {
src: string;
name?: string;
resizeMode: ResizeMode;
backgroundColor?: string;
removeTransparency?: boolean;
width: number;
height: number;
padding?: number;
borderRadius?: number;
};

3
node_modules/@expo/image-utils/build/Image.types.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Image.types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":""}

8
node_modules/@expo/image-utils/build/env.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
declare class Env {
/** Enable image utils related debugging messages */
get EXPO_IMAGE_UTILS_DEBUG(): boolean;
/** Disable all Sharp related functionality. */
get EXPO_IMAGE_UTILS_NO_SHARP(): boolean;
}
export declare const env: Env;
export {};

16
node_modules/@expo/image-utils/build/env.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.env = void 0;
const getenv_1 = require("getenv");
class Env {
/** Enable image utils related debugging messages */
get EXPO_IMAGE_UTILS_DEBUG() {
return (0, getenv_1.boolish)('EXPO_IMAGE_UTILS_DEBUG', false);
}
/** Disable all Sharp related functionality. */
get EXPO_IMAGE_UTILS_NO_SHARP() {
return (0, getenv_1.boolish)('EXPO_IMAGE_UTILS_NO_SHARP', false);
}
}
exports.env = new Env();
//# sourceMappingURL=env.js.map

1
node_modules/@expo/image-utils/build/env.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEjC,MAAM,GAAG;IACP,oDAAoD;IACpD,IAAI,sBAAsB;QACxB,OAAO,IAAA,gBAAO,EAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,+CAA+C;IAC/C,IAAI,yBAAyB;QAC3B,OAAO,IAAA,gBAAO,EAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;CACF;AAEY,QAAA,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC"}

9
node_modules/@expo/image-utils/build/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import * as Cache from './Cache';
import { compositeImagesAsync, generateFaviconAsync, generateImageAsync, generateImageBackgroundAsync, getPngInfo } from './Image';
import { ImageFormat, ImageOptions, ResizeMode } from './Image.types';
import { jimpAsync, createSquareAsync } from './jimp';
import { findSharpInstanceAsync, isAvailableAsync, sharpAsync } from './sharp';
import { SharpCommandOptions, SharpGlobalOptions } from './sharp.types';
export declare function imageAsync(options: SharpGlobalOptions, commands?: SharpCommandOptions[]): Promise<Buffer<ArrayBufferLike> | string[]>;
export { jimpAsync, createSquareAsync, findSharpInstanceAsync, isAvailableAsync, sharpAsync, generateImageAsync, generateImageBackgroundAsync, generateFaviconAsync, Cache, compositeImagesAsync, getPngInfo, };
export { SharpGlobalOptions, SharpCommandOptions, ResizeMode, ImageFormat, ImageOptions };

59
node_modules/@expo/image-utils/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPngInfo = exports.compositeImagesAsync = exports.Cache = exports.generateFaviconAsync = exports.generateImageBackgroundAsync = exports.generateImageAsync = exports.sharpAsync = exports.isAvailableAsync = exports.findSharpInstanceAsync = exports.createSquareAsync = exports.jimpAsync = void 0;
exports.imageAsync = imageAsync;
const Cache = __importStar(require("./Cache"));
exports.Cache = Cache;
const Image_1 = require("./Image");
Object.defineProperty(exports, "compositeImagesAsync", { enumerable: true, get: function () { return Image_1.compositeImagesAsync; } });
Object.defineProperty(exports, "generateFaviconAsync", { enumerable: true, get: function () { return Image_1.generateFaviconAsync; } });
Object.defineProperty(exports, "generateImageAsync", { enumerable: true, get: function () { return Image_1.generateImageAsync; } });
Object.defineProperty(exports, "generateImageBackgroundAsync", { enumerable: true, get: function () { return Image_1.generateImageBackgroundAsync; } });
Object.defineProperty(exports, "getPngInfo", { enumerable: true, get: function () { return Image_1.getPngInfo; } });
const jimp_1 = require("./jimp");
Object.defineProperty(exports, "jimpAsync", { enumerable: true, get: function () { return jimp_1.jimpAsync; } });
Object.defineProperty(exports, "createSquareAsync", { enumerable: true, get: function () { return jimp_1.createSquareAsync; } });
const sharp_1 = require("./sharp");
Object.defineProperty(exports, "findSharpInstanceAsync", { enumerable: true, get: function () { return sharp_1.findSharpInstanceAsync; } });
Object.defineProperty(exports, "isAvailableAsync", { enumerable: true, get: function () { return sharp_1.isAvailableAsync; } });
Object.defineProperty(exports, "sharpAsync", { enumerable: true, get: function () { return sharp_1.sharpAsync; } });
async function imageAsync(options, commands = []) {
if (await (0, sharp_1.isAvailableAsync)()) {
return (0, sharp_1.sharpAsync)(options, commands);
}
return (0, jimp_1.jimpAsync)({ ...options, format: (0, jimp_1.convertFormat)(options.format), originalInput: options.input }, commands);
}
//# sourceMappingURL=index.js.map

1
node_modules/@expo/image-utils/build/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,gCAWC;AAxBD,+CAAiC;AAmC/B,sBAAK;AAlCP,mCAMiB;AA6Bf,qGAlCA,4BAAoB,OAkCA;AAFpB,qGA/BA,4BAAoB,OA+BA;AAFpB,mGA5BA,0BAAkB,OA4BA;AAClB,6GA5BA,oCAA4B,OA4BA;AAI5B,2FA/BA,kBAAU,OA+BA;AA5BZ,iCAAqE;AAkBnE,0FAlBsB,gBAAS,OAkBtB;AACT,kGAnBiC,wBAAiB,OAmBjC;AAlBnB,mCAA+E;AAmB7E,uGAnBO,8BAAsB,OAmBP;AACtB,iGApB+B,wBAAgB,OAoB/B;AAChB,2FArBiD,kBAAU,OAqBjD;AAlBL,KAAK,UAAU,UAAU,CAC9B,OAA2B,EAC3B,WAAkC,EAAE;IAEpC,IAAI,MAAM,IAAA,wBAAgB,GAAE,EAAE,CAAC;QAC7B,OAAO,IAAA,kBAAU,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAA,gBAAS,EACd,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,IAAA,oBAAa,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,KAAK,EAAE,EACnF,QAAQ,CACT,CAAC;AACJ,CAAC"}

22
node_modules/@expo/image-utils/build/jimp.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import Jimp from 'jimp-compact';
import { ResizeOptions, SharpCommandOptions, SharpGlobalOptions } from './sharp.types';
type JimpGlobalOptions = Omit<SharpGlobalOptions, 'input'> & {
input: string | Buffer | Jimp;
originalInput: string;
};
export declare function resizeBufferAsync(buffer: Buffer, sizes: number[]): Promise<Buffer[]>;
export declare function convertFormat(format?: string): string | undefined;
export declare function jimpAsync(options: JimpGlobalOptions, commands?: SharpCommandOptions[]): Promise<Buffer>;
export declare function isFolderAsync(path: string): Promise<boolean>;
export declare function circleAsync(jimp: Jimp): Promise<Jimp>;
/**
* Create a square image of a given size and color. Defaults to a white PNG.
*/
export declare function createSquareAsync({ size, color, mime, }: {
size: number;
color?: string;
mime?: any;
}): Promise<Buffer>;
export declare function getJimpImageAsync(input: string | Buffer | Jimp): Promise<Jimp>;
export declare function resize({ input, quality }: JimpGlobalOptions, { background, position, fit, width, height }: Omit<ResizeOptions, 'operation'>): Promise<Jimp>;
export {};

230
node_modules/@expo/image-utils/build/jimp.js generated vendored Normal file
View File

@@ -0,0 +1,230 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resizeBufferAsync = resizeBufferAsync;
exports.convertFormat = convertFormat;
exports.jimpAsync = jimpAsync;
exports.isFolderAsync = isFolderAsync;
exports.circleAsync = circleAsync;
exports.createSquareAsync = createSquareAsync;
exports.getJimpImageAsync = getJimpImageAsync;
exports.resize = resize;
const fs_1 = __importDefault(require("fs"));
// @ts-ignore
const jimp_compact_1 = __importDefault(require("jimp-compact"));
const path = __importStar(require("path"));
async function resizeBufferAsync(buffer, sizes) {
return Promise.all(sizes.map(async (size) => {
// Parse the buffer each time to prevent mutable copies.
// Parse the buffer each time to prevent mutable copies.
const jimpImage = await jimp_compact_1.default.read(buffer);
const mime = jimpImage.getMIME();
return jimpImage.resize(size, size).getBufferAsync(mime);
}));
}
function convertFormat(format) {
if (typeof format === 'undefined')
return format;
const input = format?.toLowerCase();
switch (input) {
case 'png':
case 'webp':
case 'jpeg':
return `image/${input}`;
case 'jpg':
return `image/jpeg`;
}
return undefined;
}
async function jimpAsync(options, commands = []) {
if (commands.length) {
const command = commands.shift();
if (command) {
let input;
if (command.operation === 'resize') {
input = await resize(options, command);
}
else if (command.operation === 'flatten') {
input = await flatten(options, command);
}
else {
throw new Error(`The operation: '${command.operation}' is not supported with Jimp`);
}
// @ts-ignore
return jimpAsync({ ...options, input }, commands);
}
}
const image = await getJimpImageAsync(options.input);
const mime = typeof options.format === 'string' ? options.format : image.getMIME();
const imgBuffer = await image.getBufferAsync(mime);
if (typeof options.output === 'string') {
if (await isFolderAsync(options.output)) {
await fs_1.default.promises.writeFile(path.join(options.output, path.basename(options.originalInput)), imgBuffer);
}
else {
await fs_1.default.promises.writeFile(options.output, imgBuffer);
}
}
return imgBuffer;
}
async function isFolderAsync(path) {
try {
return (await fs_1.default.promises.stat(path)).isDirectory();
}
catch {
return false;
}
}
function circleAsync(jimp) {
const diameter = Math.min(jimp.bitmap.width, jimp.bitmap.height);
const center = {
x: jimp.bitmap.width / 2,
y: jimp.bitmap.height / 2,
};
return new Promise((resolve) => {
jimp
.resize(diameter, diameter)
.crop((jimp.bitmap.width - diameter) / 2, (jimp.bitmap.height - diameter) / 2, diameter, diameter)
.scanQuiet(0, 0, diameter, diameter, (x, y, idx) => {
const radius = diameter / 2;
const curR = Math.sqrt(Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2));
if (radius - curR <= 0.0) {
jimp.bitmap.data[idx + 3] = 0;
}
else if (radius - curR < 1.0) {
jimp.bitmap.data[idx + 3] = 255 * (radius - curR);
}
});
resolve(jimp);
});
}
/**
* Create a square image of a given size and color. Defaults to a white PNG.
*/
async function createSquareAsync({ size, color = '#FFFFFF', mime = jimp_compact_1.default.MIME_PNG, }) {
const image = await new jimp_compact_1.default(size, size, color);
// Convert Jimp image to a Buffer
return await image.getBufferAsync(mime);
}
async function getJimpImageAsync(input) {
// @ts-ignore: Jimp types are broken
if (typeof input === 'string' || input instanceof Buffer)
return await jimp_compact_1.default.read(input);
return input;
}
async function resize({ input, quality = 100 }, { background, position, fit, width, height }) {
let initialImage = await getJimpImageAsync(input);
if (width && !height) {
height = jimp_compact_1.default.AUTO;
}
else if (!width && height) {
width = jimp_compact_1.default.AUTO;
}
else if (!width && !height) {
width = initialImage.bitmap.width;
height = initialImage.bitmap.height;
}
const jimpPosition = convertPosition(position);
const jimpQuality = typeof quality !== 'number' ? 100 : quality;
if (fit === 'cover') {
initialImage = initialImage.cover(width, height, jimpPosition);
}
else if (fit === 'contain') {
initialImage = initialImage.contain(width, height, jimpPosition);
}
else {
throw new Error(`Unsupported fit: ${fit}. Supported values are 'cover' or 'contain' when using Jimp`);
}
if (background) {
initialImage = initialImage.composite(new jimp_compact_1.default(width, height, background), 0, 0, {
mode: jimp_compact_1.default.BLEND_DESTINATION_OVER,
opacitySource: 1,
opacityDest: 1,
});
}
return await initialImage.quality(jimpQuality);
}
async function flatten({ input, quality = 100 }, { background }) {
const initialImage = await getJimpImageAsync(input);
const jimpQuality = typeof quality !== 'number' ? 100 : quality;
return initialImage.quality(jimpQuality).background(jimp_compact_1.default.cssColorToHex(background));
}
/**
* Convert sharp position to Jimp position.
*
* @param position
*/
function convertPosition(position) {
if (!position)
return convertPosition('center');
switch (position) {
case 'center':
case 'centre':
return jimp_compact_1.default.VERTICAL_ALIGN_MIDDLE | jimp_compact_1.default.HORIZONTAL_ALIGN_CENTER;
case 'north':
case 'top':
return jimp_compact_1.default.VERTICAL_ALIGN_TOP | jimp_compact_1.default.HORIZONTAL_ALIGN_CENTER;
case 'east':
case 'right':
return jimp_compact_1.default.VERTICAL_ALIGN_MIDDLE | jimp_compact_1.default.HORIZONTAL_ALIGN_RIGHT;
case 'south':
case 'bottom':
return jimp_compact_1.default.VERTICAL_ALIGN_BOTTOM | jimp_compact_1.default.HORIZONTAL_ALIGN_CENTER;
case 'west':
case 'left':
return jimp_compact_1.default.VERTICAL_ALIGN_MIDDLE | jimp_compact_1.default.HORIZONTAL_ALIGN_LEFT;
case 'northeast':
case 'right top':
return jimp_compact_1.default.VERTICAL_ALIGN_TOP | jimp_compact_1.default.HORIZONTAL_ALIGN_RIGHT;
case 'southeast':
case 'right bottom':
return jimp_compact_1.default.VERTICAL_ALIGN_BOTTOM | jimp_compact_1.default.HORIZONTAL_ALIGN_RIGHT;
case 'southwest':
case 'left bottom':
return jimp_compact_1.default.VERTICAL_ALIGN_BOTTOM | jimp_compact_1.default.HORIZONTAL_ALIGN_LEFT;
case 'northwest':
case 'left top':
return jimp_compact_1.default.VERTICAL_ALIGN_TOP | jimp_compact_1.default.HORIZONTAL_ALIGN_LEFT;
case 'entropy':
case 'attention':
throw new Error(`Position: '${position}' is not supported`);
default:
throw new Error(`Unknown position: '${position}'`);
}
}
//# sourceMappingURL=jimp.js.map

1
node_modules/@expo/image-utils/build/jimp.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
declare module 'module' {
namespace Module {
const globalPaths: readonly string[] | void;
}
}
/** Resolve a globally installed module before a locally installed one */
export declare const resolveGlobal: (id: string) => string;

144
node_modules/@expo/image-utils/build/resolveGlobal.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
"use strict";
// NOTE: This file is replicated to multiple packages! Keep these files in-sync:
// - packages/@expo/cli/src/utils/resolveGlobal.ts
// - packages/@expo/image-utils/src/resolveGlobal.ts
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveGlobal = void 0;
const child_process_1 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const module_1 = __importDefault(require("module"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const memoize = (fn) => {
let result;
return (...args) => {
if (result === undefined) {
result = { value: fn(...args) };
}
return result.value;
};
};
const isWindows = process.platform === 'win32';
const getDelimitedPaths = (delimited) => delimited
.split(path_1.default.delimiter)
.map((target) => {
try {
const normalized = path_1.default.normalize(target.trim());
if (!normalized) {
return null;
}
else if (!path_1.default.isAbsolute(normalized)) {
return path_1.default.resolve(process.cwd(), normalized);
}
else {
return normalized;
}
}
catch {
return null;
}
})
.filter((target) => !!target);
const execGetPaths = (cmd, args) => {
const result = (0, child_process_1.spawnSync)(cmd, args, { encoding: 'utf8' });
if (!result.error && result.status === 0 && result.stdout) {
const paths = getDelimitedPaths(result.stdout.replace(/[\r\n]+/g, path_1.default.delimiter));
return paths.filter((target) => fs_1.default.existsSync(target));
}
return [];
};
const getNativeNodePaths = () => {
if (Array.isArray(module_1.default.globalPaths)) {
return module_1.default.globalPaths;
}
else {
return [];
}
};
const getHomePath = memoize(() => {
try {
return os_1.default.homedir();
}
catch {
return isWindows ? (process.env.UserProfile ?? process.env.USERPROFILE) : process.env.HOME;
}
});
const getNpmDefaultPaths = () => {
const prefix = [];
const localAppData = process.env.LocalAppData || process.env.LOCALAPPDATA;
if (isWindows && localAppData) {
prefix.push(path_1.default.resolve(localAppData, 'npm'));
}
else if (!isWindows) {
prefix.push('/usr/local/lib/node_modules');
}
return prefix.filter((target) => fs_1.default.existsSync(target));
};
const getNpmPrefixPaths = memoize(() => {
const npmPrefix = execGetPaths(isWindows ? 'npm.cmd' : 'npm', ['config', '-g', 'get', 'prefix']);
return npmPrefix.map((prefix) => path_1.default.resolve(prefix, 'lib'));
});
const getYarnDefaultPaths = () => {
const prefix = [];
const homePath = getHomePath();
const localAppData = process.env.LocalAppData || process.env.LOCALAPPDATA;
const dataHomePath = process.env.XDG_DATA_HOME || (homePath && path_1.default.join(homePath, '.local', 'share'));
if (isWindows && localAppData) {
prefix.push(path_1.default.resolve(localAppData, 'Yarn', 'global'));
}
if (dataHomePath) {
prefix.push(path_1.default.resolve(dataHomePath, 'yarn', 'global'));
}
if (homePath) {
prefix.push(path_1.default.resolve(homePath, '.yarn', 'global'));
}
return prefix.filter((target) => fs_1.default.existsSync(target));
};
const getYarnPrefixPaths = memoize(() => {
return execGetPaths(isWindows ? 'yarn.cmd' : 'yarn', ['global', 'dir']);
});
const getPnpmPrefixPaths = memoize(() => {
return execGetPaths(isWindows ? 'pnpm.cmd' : 'pnpm', ['root', '-g']);
});
const getBunPrefixPaths = memoize(() => {
const prefix = [];
const bunPath = execGetPaths(isWindows ? 'bun.cmd' : 'bun', ['pm', 'bin', '-g'])[0];
if (!bunPath) {
return [];
}
prefix.push(path_1.default.resolve(bunPath, 'global'));
const moduleEntry = fs_1.default.readdirSync(bunPath, { withFileTypes: true }).find((entry) => {
return entry.isSymbolicLink() && entry.name !== 'global';
});
if (moduleEntry) {
try {
const moduleTarget = fs_1.default.realpathSync(path_1.default.resolve(bunPath, moduleEntry.name));
const splitIdx = moduleTarget.indexOf(path_1.default.sep + 'node_modules' + path_1.default.sep);
if (splitIdx > -1) {
const modulePath = moduleTarget.slice(0, splitIdx);
prefix.push(modulePath);
}
}
catch { }
}
return prefix.filter((target) => fs_1.default.existsSync(target));
});
const getPaths = () => [
...getNpmDefaultPaths(),
...getNpmPrefixPaths(),
...getYarnDefaultPaths(),
...getYarnPrefixPaths(),
...getPnpmPrefixPaths(),
...getBunPrefixPaths(),
...getNativeNodePaths(),
process.cwd(),
];
/** Resolve a globally installed module before a locally installed one */
const resolveGlobal = (id) => {
return require.resolve(id, { paths: getPaths() });
};
exports.resolveGlobal = resolveGlobal;
//# sourceMappingURL=resolveGlobal.js.map

File diff suppressed because one or more lines are too long

13
node_modules/@expo/image-utils/build/sharp.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { SharpCommandOptions, SharpGlobalOptions } from './sharp.types';
export declare function resizeBufferAsync(buffer: Buffer, sizes: number[]): Promise<Buffer[]>;
/**
* Returns `true` if a global sharp instance can be found.
* This functionality can be overridden with `process.env.EXPO_IMAGE_UTILS_NO_SHARP=1`.
*/
export declare function isAvailableAsync(): Promise<boolean>;
export declare function sharpAsync(options: SharpGlobalOptions, commands?: SharpCommandOptions[]): Promise<string[]>;
/**
* Returns the instance of `sharp` installed by the global `sharp-cli` package.
* This method will throw errors if the `sharp` instance cannot be found, these errors can be circumvented by ensuring `isAvailableAsync()` resolves to `true`.
*/
export declare function findSharpInstanceAsync(): Promise<typeof import('sharp') | null>;

188
node_modules/@expo/image-utils/build/sharp.js generated vendored Normal file
View File

@@ -0,0 +1,188 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resizeBufferAsync = resizeBufferAsync;
exports.isAvailableAsync = isAvailableAsync;
exports.sharpAsync = sharpAsync;
exports.findSharpInstanceAsync = findSharpInstanceAsync;
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
const assert_1 = __importDefault(require("assert"));
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
const resolve_from_1 = __importDefault(require("resolve-from"));
const semver_1 = __importDefault(require("semver"));
const env_1 = require("./env");
const resolveGlobal_1 = require("./resolveGlobal");
const SHARP_HELP_PATTERN = /\n\nSpecify --help for available options/g;
const SHARP_REQUIRED_VERSION = '^5.2.0';
async function resizeBufferAsync(buffer, sizes) {
const sharp = await findSharpInstanceAsync();
(0, assert_1.default)(sharp, 'Sharp is being used while its not initialized');
const metadata = await sharp(buffer).metadata();
// Create buffer for each size
const resizedBuffers = await Promise.all(sizes.map((dimension) => {
const density = metadata.density != null
? (dimension / Math.max(metadata.width, metadata.height)) * metadata.density
: null;
return sharp(buffer, {
density: density == null ? undefined : Math.ceil(density),
})
.resize(dimension, dimension, { fit: 'contain', background: 'transparent' })
.toBuffer();
}));
return resizedBuffers;
}
/**
* Returns `true` if a global sharp instance can be found.
* This functionality can be overridden with `process.env.EXPO_IMAGE_UTILS_NO_SHARP=1`.
*/
async function isAvailableAsync() {
if (env_1.env.EXPO_IMAGE_UTILS_NO_SHARP) {
return false;
}
try {
// Attempt to find Sharp
await findSharpInstanceAsync();
// Only mark as available when both CLI and module are found
return !!_sharpBin && !!_sharpInstance;
}
catch {
return false;
}
}
async function sharpAsync(options, commands = []) {
const bin = await findSharpBinAsync();
try {
const { stdout } = await (0, spawn_async_1.default)(bin, [
...getOptions(options),
...getCommandOptions(commands),
]);
const outputFilePaths = stdout.trim().split('\n');
return outputFilePaths;
}
catch (error) {
if (error.stderr) {
throw new Error('\nProcessing images using sharp-cli failed: ' +
error.message +
'\nOutput: ' +
error.stderr.replace(SHARP_HELP_PATTERN, ''));
}
else {
throw error;
}
}
}
function getOptions(options) {
const args = [];
for (const [key, value] of Object.entries(options)) {
if (value != null && value !== false) {
if (typeof value === 'boolean') {
args.push(`--${key}`);
}
else if (typeof value === 'number') {
args.push(`--${key}`, value.toFixed());
}
else {
args.push(`--${key}`, value);
}
}
}
return args;
}
function getCommandOptions(commands) {
const args = [];
for (const command of commands) {
if (command.operation === 'resize') {
const { operation, width, ...namedOptions } = command;
args.push(operation, width.toFixed(), ...getOptions(namedOptions));
}
else {
const { operation, ...namedOptions } = command;
args.push(operation, ...getOptions(namedOptions));
}
args.push('--');
}
return args;
}
let _sharpBin = null;
let _sharpInstance = null;
async function findSharpBinAsync() {
if (_sharpBin)
return _sharpBin;
try {
let sharpCliPackagePath;
try {
sharpCliPackagePath = (0, resolveGlobal_1.resolveGlobal)('sharp-cli/package.json');
}
catch {
sharpCliPackagePath = require.resolve('sharp-cli/package.json');
}
const sharpCliPackage = require(sharpCliPackagePath);
const sharpInstance = sharpCliPackagePath
? require((0, resolve_from_1.default)(sharpCliPackagePath, 'sharp'))
: null;
if (sharpCliPackagePath &&
semver_1.default.satisfies(sharpCliPackage.version, SHARP_REQUIRED_VERSION) &&
typeof sharpCliPackage.bin.sharp === 'string' &&
typeof _sharpInstance?.versions?.vips === 'string') {
_sharpBin = path_1.default.join(path_1.default.dirname(sharpCliPackagePath), sharpCliPackage.bin.sharp);
_sharpInstance = sharpInstance;
return _sharpBin;
}
}
catch (error) {
_sharpBin = null;
_sharpInstance = null;
// `sharp-cli` and/or `sharp` modules could not be found, falling back to global binary only
if (env_1.env.EXPO_IMAGE_UTILS_DEBUG) {
console.warn('Sharp could not be loaded, reason:', error);
}
}
let installedCliVersion;
try {
installedCliVersion = (await (0, spawn_async_1.default)('sharp', ['--version'])).stdout.toString().trim();
}
catch {
return '';
}
if (!semver_1.default.satisfies(installedCliVersion, SHARP_REQUIRED_VERSION)) {
showVersionMismatchWarning(SHARP_REQUIRED_VERSION, installedCliVersion);
return '';
}
// Use the `sharp-cli` reference from PATH
_sharpBin = 'sharp';
return _sharpBin;
}
/**
* Returns the instance of `sharp` installed by the global `sharp-cli` package.
* This method will throw errors if the `sharp` instance cannot be found, these errors can be circumvented by ensuring `isAvailableAsync()` resolves to `true`.
*/
async function findSharpInstanceAsync() {
if (env_1.env.EXPO_IMAGE_UTILS_NO_SHARP) {
throw new Error('Global instance of sharp-cli cannot be retrieved because sharp-cli has been disabled with the environment variable `EXPO_IMAGE_UTILS_NO_SHARP`');
}
// Return the cached instance
if (_sharpInstance)
return _sharpInstance;
// Resolve `sharp-cli` and `sharp`, this also loads the sharp module if it can be found
await findSharpBinAsync();
if (!_sharpInstance) {
throw new Error(`Failed to find the instance of sharp used by the global sharp-cli package.`);
}
return _sharpInstance;
}
let versionMismatchWarningShown = false;
function showVersionMismatchWarning(requiredCliVersion, installedCliVersion) {
if (versionMismatchWarningShown) {
return;
}
console.warn([
chalk_1.default.yellow(`Expo supports version "${requiredCliVersion}" of \`sharp-cli\`, current version: "${installedCliVersion}".`),
chalk_1.default.yellow.dim(`If you can remove or upgrade using \`npm (un)install -g sharp-cli@${requiredCliVersion}\`.`),
chalk_1.default.yellow.dim(`Or disable \`sharp-cli\` with \`EXPO_IMAGE_UTILS_NO_SHARP=1\`.`),
].join('\n'));
versionMismatchWarningShown = true;
}
//# sourceMappingURL=sharp.js.map

1
node_modules/@expo/image-utils/build/sharp.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

35
node_modules/@expo/image-utils/build/sharp.types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import { ImageFormat, ResizeMode } from './Image.types';
export type SharpGlobalOptions = {
compressionLevel?: '';
format?: ImageFormat;
input: string;
limitInputPixels?: number;
output: string;
progressive?: boolean;
quality?: number;
withMetadata?: boolean;
[key: string]: string | number | boolean | undefined | null;
};
export type SharpCommandOptions = RemoveAlphaOptions | ResizeOptions | FlattenOptions;
export type FlattenOptions = {
operation: 'flatten';
background: string;
};
export type RemoveAlphaOptions = {
operation: 'removeAlpha';
};
export type Position = 'center' | 'centre' | 'north' | 'east' | 'south' | 'west' | 'northeast' | 'southeast' | 'southwest' | 'northwest' | 'top' | 'right' | 'bottom' | 'left' | 'right top' | 'right bottom' | 'left bottom' | 'left top' | 'entropy' | 'attention';
export type ResizeOptions = {
operation: 'resize';
background?: string;
fastShrinkOnLoad?: boolean;
fit?: ResizeMode;
height?: number;
kernel?: 'nearest' | 'cubic' | 'mitchell' | 'lanczos2' | 'lanczos3';
position?: Position;
width: number;
withoutEnlargement?: boolean;
};
export type Options = object | {
[key: string]: boolean | number | string | undefined;
};

3
node_modules/@expo/image-utils/build/sharp.types.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=sharp.types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sharp.types.js","sourceRoot":"","sources":["../src/sharp.types.ts"],"names":[],"mappings":""}

52
node_modules/@expo/image-utils/package.json generated vendored Normal file
View File

@@ -0,0 +1,52 @@
{
"name": "@expo/image-utils",
"version": "0.8.12",
"description": "A package used by Expo CLI for processing images",
"main": "build/index.js",
"scripts": {
"build": "expo-module tsc",
"clean": "expo-module clean",
"lint": "expo-module lint",
"prepare": "expo-module clean && yarn run build",
"prepublishOnly": "expo-module prepublishOnly",
"test": "expo-module test",
"test:e2e": "yarn run prepare && expo-module test --config e2e/jest.config.js",
"typecheck": "expo-module typecheck",
"watch": "expo-module tsc --watch --preserveWatchOutput"
},
"repository": {
"type": "git",
"url": "https://github.com/expo/expo.git",
"directory": "packages/@expo/image-utils"
},
"keywords": [
"json"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/expo/expo/issues"
},
"homepage": "https://github.com/expo/expo/tree/main/packages/%40expo/image-utils#readme",
"files": [
"build"
],
"dependencies": {
"@expo/spawn-async": "^1.7.2",
"chalk": "^4.0.0",
"getenv": "^2.0.0",
"jimp-compact": "0.16.1",
"parse-png": "^2.1.0",
"resolve-from": "^5.0.0",
"semver": "^7.6.0"
},
"devDependencies": {
"@types/getenv": "^1.0.0",
"@types/semver": "^7.0.0",
"expo-module-scripts": "^55.0.2",
"sharp-cli": "^5.2.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "436ffb4355d5207f4a03fbc3568cd33424a40f3e"
}