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

View File

@@ -0,0 +1,29 @@
type ContentsJsonImageScale = '1x' | '2x' | '3x';
type ContentsJsonImageIdiom = 'iphone' | 'ipad' | 'watchos' | 'ios' | 'ios-marketing' | 'universal';
type ContentsJsonImageAppearance = {
appearance: 'luminosity';
value: 'dark';
};
export interface ContentsJsonImage {
appearances?: ContentsJsonImageAppearance[];
idiom: ContentsJsonImageIdiom;
size?: string;
scale?: ContentsJsonImageScale;
filename?: string;
platform?: ContentsJsonImageIdiom;
}
export interface ContentsJson {
images: ContentsJsonImage[];
info: {
version: number;
author: string;
};
}
/**
* Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.
*
* @param directory path to add the Contents.json to.
* @param contents image json data
*/
export declare function writeContentsJsonAsync(directory: string, { images }: Pick<ContentsJson, 'images'>): Promise<void>;
export {};

28
node_modules/expo-asset/plugin/build/AssetContents.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeContentsJsonAsync = writeContentsJsonAsync;
// Forked from `@expo/prebuild-config`, because its not exposed as public API or through a correct dependency chain
// See: https://github.com/expo/expo/blob/80ee356c2c90d6498b45c95214ed7be169d63f75/packages/%40expo/prebuild-config/src/plugins/icons/AssetContents.ts
const promises_1 = __importDefault(require("node:fs/promises"));
const node_path_1 = __importDefault(require("node:path"));
/**
* Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.
*
* @param directory path to add the Contents.json to.
* @param contents image json data
*/
async function writeContentsJsonAsync(directory, { images }) {
const data = {
images,
info: {
version: 1,
// common practice is for the tool that generated the icons to be the "author"
author: 'expo',
},
};
await promises_1.default.mkdir(directory, { recursive: true });
await promises_1.default.writeFile(node_path_1.default.join(directory, 'Contents.json'), JSON.stringify(data, null, 2));
}

6
node_modules/expo-asset/plugin/build/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare const IMAGE_TYPES: string[];
export declare const FONT_TYPES: string[];
export declare const MEDIA_TYPES: string[];
export declare const ACCEPTED_TYPES: string[];
export declare function resolveAssetPaths(assets: string[], projectRoot: string): Promise<string[]>;
export declare function validateAssets(assets: string[], platform: 'android' | 'ios'): string[];

49
node_modules/expo-asset/plugin/build/utils.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ACCEPTED_TYPES = exports.MEDIA_TYPES = exports.FONT_TYPES = exports.IMAGE_TYPES = void 0;
exports.resolveAssetPaths = resolveAssetPaths;
exports.validateAssets = validateAssets;
const config_plugins_1 = require("expo/config-plugins");
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
exports.IMAGE_TYPES = ['.png', '.jpg', '.gif'];
exports.FONT_TYPES = ['.otf', '.ttf'];
exports.MEDIA_TYPES = ['.mp4', '.mp3', '.lottie', '.riv'];
exports.ACCEPTED_TYPES = ['.json', '.db', ...exports.IMAGE_TYPES, ...exports.MEDIA_TYPES, ...exports.FONT_TYPES];
async function resolveAssetPaths(assets, projectRoot) {
const promises = assets.map(async (p) => {
const resolvedPath = path_1.default.resolve(projectRoot, p);
const stat = await promises_1.default.stat(resolvedPath);
if (stat.isDirectory()) {
const dir = await promises_1.default.readdir(resolvedPath);
return dir.map((file) => path_1.default.join(resolvedPath, file));
}
return [resolvedPath];
});
return (await Promise.all(promises)).flat();
}
function validateAssets(assets, platform) {
return assets.filter((asset) => {
const ext = path_1.default.extname(asset);
const name = path_1.default.basename(asset, ext);
const isNameValid = platform === 'android' ? (0, config_plugins_1.isValidAndroidAssetName)(name) : true;
const accepted = exports.ACCEPTED_TYPES.includes(ext);
const isFont = exports.FONT_TYPES.includes(ext);
if (!isNameValid) {
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'expo-asset', `\`${name}\` is not a supported asset name - file-based resource names must contain only lowercase a-z, 0-9, or underscore`);
return;
}
if (!accepted) {
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'expo-asset', `\`${ext}\` is not a supported asset type`);
return;
}
if (isFont) {
config_plugins_1.WarningAggregator.addWarningForPlatform(platform, 'expo-asset', `Fonts are not supported with the \`expo-asset\` plugin. Use \`expo-font\` instead. Ignoring ${asset}`);
return;
}
return asset;
});
}

6
node_modules/expo-asset/plugin/build/withAssets.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type ConfigPlugin } from 'expo/config-plugins';
export type AssetProps = {
assets?: string[];
};
declare const _default: ConfigPlugin<AssetProps | null>;
export default _default;

18
node_modules/expo-asset/plugin/build/withAssets.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_plugins_1 = require("expo/config-plugins");
const withAssetsAndroid_1 = require("./withAssetsAndroid");
const withAssetsIos_1 = require("./withAssetsIos");
const pkg = require('expo-asset/package.json');
const withAssets = (config, props) => {
if (!props) {
return config;
}
if (props.assets && props.assets.length === 0) {
return config;
}
config = (0, withAssetsIos_1.withAssetsIos)(config, props.assets ?? []);
config = (0, withAssetsAndroid_1.withAssetsAndroid)(config, props.assets ?? []);
return config;
};
exports.default = (0, config_plugins_1.createRunOncePlugin)(withAssets, pkg.name, pkg.version);

View File

@@ -0,0 +1,2 @@
import { type ConfigPlugin } from 'expo/config-plugins';
export declare const withAssetsAndroid: ConfigPlugin<string[]>;

View File

@@ -0,0 +1,48 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withAssetsAndroid = void 0;
const config_plugins_1 = require("expo/config-plugins");
const fs_1 = __importDefault(require("fs"));
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
const utils_1 = require("./utils");
const withAssetsAndroid = (config, assets) => {
return (0, config_plugins_1.withDangerousMod)(config, [
'android',
async (config) => {
const resolvedAssets = await (0, utils_1.resolveAssetPaths)(assets, config.modRequest.projectRoot);
const validAssets = (0, utils_1.validateAssets)(resolvedAssets, 'android');
validAssets.forEach((asset) => {
const assetsDir = getAssetDir(asset, config.modRequest.platformProjectRoot);
fs_1.default.mkdirSync(assetsDir, { recursive: true });
});
await Promise.all(validAssets.map(async (asset) => {
const assetsDir = getAssetDir(asset, config.modRequest.platformProjectRoot);
const output = path_1.default.join(assetsDir, path_1.default.basename(asset));
await promises_1.default.copyFile(asset, output);
}));
return config;
},
]);
};
exports.withAssetsAndroid = withAssetsAndroid;
function getAssetDir(asset, root) {
const assetPath = ['app', 'src', 'main', 'assets'];
const resPath = ['app', 'src', 'main', 'res'];
const ext = path_1.default.extname(asset);
if (utils_1.IMAGE_TYPES.includes(ext)) {
return path_1.default.join(root, ...resPath, 'drawable');
}
else if (utils_1.FONT_TYPES.includes(ext)) {
return path_1.default.join(root, ...assetPath, 'fonts');
}
else if (utils_1.MEDIA_TYPES.includes(ext)) {
return path_1.default.join(root, ...resPath, 'raw');
}
else {
return path_1.default.join(root, ...assetPath);
}
}

View File

@@ -0,0 +1,2 @@
import { type ConfigPlugin } from 'expo/config-plugins';
export declare const withAssetsIos: ConfigPlugin<string[]>;

72
node_modules/expo-asset/plugin/build/withAssetsIos.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withAssetsIos = void 0;
const image_utils_1 = require("@expo/image-utils");
const config_plugins_1 = require("expo/config-plugins");
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
const AssetContents_1 = require("./AssetContents");
const utils_1 = require("./utils");
const IMAGE_DIR = 'Images.xcassets';
const withAssetsIos = (config, assets) => {
config = addAssetsToTarget(config, assets);
return config;
};
exports.withAssetsIos = withAssetsIos;
function addAssetsToTarget(config, assets) {
return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
const resolvedAssets = await (0, utils_1.resolveAssetPaths)(assets, config.modRequest.projectRoot);
const validAssets = (0, utils_1.validateAssets)(resolvedAssets, 'ios');
const project = config.modResults;
const platformProjectRoot = config.modRequest.platformProjectRoot;
config_plugins_1.IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');
const images = validAssets.filter((asset) => utils_1.IMAGE_TYPES.includes(path_1.default.extname(asset)));
const assetsForResourcesDir = validAssets.filter((asset) => !utils_1.IMAGE_TYPES.includes(path_1.default.extname(asset)));
await addImageAssets(images, config.modRequest.projectRoot);
addResourceFiles(project, platformProjectRoot, assetsForResourcesDir);
return config;
});
}
function addResourceFiles(project, platformRoot, assets) {
for (const asset of assets) {
const assetPath = path_1.default.relative(platformRoot, asset);
config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
filepath: assetPath,
groupName: 'Resources',
project,
isBuildFile: true,
verbose: true,
});
}
}
async function addImageAssets(assets, root) {
const iosNamedProjectRoot = config_plugins_1.IOSConfig.Paths.getSourceRoot(root);
for (const asset of assets) {
const name = path_1.default.basename(asset, path_1.default.extname(asset));
const image = path_1.default.basename(asset);
const assetPath = path_1.default.resolve(iosNamedProjectRoot, `${IMAGE_DIR}/${name}.imageset`);
await promises_1.default.mkdir(assetPath, { recursive: true });
const buffer = await (0, image_utils_1.generateImageAsync)({ projectRoot: root }, {
src: asset,
});
await promises_1.default.writeFile(path_1.default.resolve(assetPath, image), buffer.source);
await writeContentsJsonFileAsync({
assetPath,
image,
});
}
}
async function writeContentsJsonFileAsync({ assetPath, image, }) {
const images = buildContentsJsonImages({ image });
await (0, AssetContents_1.writeContentsJsonAsync)(assetPath, { images });
}
function buildContentsJsonImages({ image }) {
return [
{ idiom: 'universal', filename: image, scale: '1x' },
{ idiom: 'universal', scale: '2x' },
{ idiom: 'universal', scale: '3x' },
];
}

51
node_modules/expo-asset/plugin/src/AssetContents.ts generated vendored Normal file
View File

@@ -0,0 +1,51 @@
// Forked from `@expo/prebuild-config`, because its not exposed as public API or through a correct dependency chain
// See: https://github.com/expo/expo/blob/80ee356c2c90d6498b45c95214ed7be169d63f75/packages/%40expo/prebuild-config/src/plugins/icons/AssetContents.ts
import fs from 'node:fs/promises';
import path from 'node:path';
type ContentsJsonImageScale = '1x' | '2x' | '3x';
type ContentsJsonImageIdiom = 'iphone' | 'ipad' | 'watchos' | 'ios' | 'ios-marketing' | 'universal';
type ContentsJsonImageAppearance = {
appearance: 'luminosity';
value: 'dark';
};
export interface ContentsJsonImage {
appearances?: ContentsJsonImageAppearance[];
idiom: ContentsJsonImageIdiom;
size?: string;
scale?: ContentsJsonImageScale;
filename?: string;
platform?: ContentsJsonImageIdiom;
}
export interface ContentsJson {
images: ContentsJsonImage[];
info: {
version: number;
author: string;
};
}
/**
* Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.
*
* @param directory path to add the Contents.json to.
* @param contents image json data
*/
export async function writeContentsJsonAsync(
directory: string,
{ images }: Pick<ContentsJson, 'images'>
) {
const data = {
images,
info: {
version: 1,
// common practice is for the tool that generated the icons to be the "author"
author: 'expo',
},
};
await fs.mkdir(directory, { recursive: true });
await fs.writeFile(path.join(directory, 'Contents.json'), JSON.stringify(data, null, 2));
}

59
node_modules/expo-asset/plugin/src/utils.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import { isValidAndroidAssetName, WarningAggregator } from 'expo/config-plugins';
import fs from 'fs/promises';
import path from 'path';
export const IMAGE_TYPES = ['.png', '.jpg', '.gif'];
export const FONT_TYPES = ['.otf', '.ttf'];
export const MEDIA_TYPES = ['.mp4', '.mp3', '.lottie', '.riv'];
export const ACCEPTED_TYPES = ['.json', '.db', ...IMAGE_TYPES, ...MEDIA_TYPES, ...FONT_TYPES];
export async function resolveAssetPaths(assets: string[], projectRoot: string) {
const promises = assets.map(async (p) => {
const resolvedPath = path.resolve(projectRoot, p);
const stat = await fs.stat(resolvedPath);
if (stat.isDirectory()) {
const dir = await fs.readdir(resolvedPath);
return dir.map((file) => path.join(resolvedPath, file));
}
return [resolvedPath];
});
return (await Promise.all(promises)).flat();
}
export function validateAssets(assets: string[], platform: 'android' | 'ios') {
return assets.filter((asset) => {
const ext = path.extname(asset);
const name = path.basename(asset, ext);
const isNameValid = platform === 'android' ? isValidAndroidAssetName(name) : true;
const accepted = ACCEPTED_TYPES.includes(ext);
const isFont = FONT_TYPES.includes(ext);
if (!isNameValid) {
WarningAggregator.addWarningForPlatform(
platform,
'expo-asset',
`\`${name}\` is not a supported asset name - file-based resource names must contain only lowercase a-z, 0-9, or underscore`
);
return;
}
if (!accepted) {
WarningAggregator.addWarningForPlatform(
platform,
'expo-asset',
`\`${ext}\` is not a supported asset type`
);
return;
}
if (isFont) {
WarningAggregator.addWarningForPlatform(
platform,
'expo-asset',
`Fonts are not supported with the \`expo-asset\` plugin. Use \`expo-font\` instead. Ignoring ${asset}`
);
return;
}
return asset;
});
}

27
node_modules/expo-asset/plugin/src/withAssets.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { type ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins';
import { withAssetsAndroid } from './withAssetsAndroid';
import { withAssetsIos } from './withAssetsIos';
const pkg = require('expo-asset/package.json');
export type AssetProps = {
assets?: string[];
};
const withAssets: ConfigPlugin<AssetProps | null> = (config, props) => {
if (!props) {
return config;
}
if (props.assets && props.assets.length === 0) {
return config;
}
config = withAssetsIos(config, props.assets ?? []);
config = withAssetsAndroid(config, props.assets ?? []);
return config;
};
export default createRunOncePlugin(withAssets, pkg.name, pkg.version);

View File

@@ -0,0 +1,46 @@
import { type ConfigPlugin, withDangerousMod } from 'expo/config-plugins';
import fs from 'fs';
import fsp from 'fs/promises';
import path from 'path';
import { FONT_TYPES, IMAGE_TYPES, MEDIA_TYPES, resolveAssetPaths, validateAssets } from './utils';
export const withAssetsAndroid: ConfigPlugin<string[]> = (config, assets) => {
return withDangerousMod(config, [
'android',
async (config) => {
const resolvedAssets = await resolveAssetPaths(assets, config.modRequest.projectRoot);
const validAssets = validateAssets(resolvedAssets, 'android');
validAssets.forEach((asset) => {
const assetsDir = getAssetDir(asset, config.modRequest.platformProjectRoot);
fs.mkdirSync(assetsDir, { recursive: true });
});
await Promise.all(
validAssets.map(async (asset) => {
const assetsDir = getAssetDir(asset, config.modRequest.platformProjectRoot);
const output = path.join(assetsDir, path.basename(asset));
await fsp.copyFile(asset, output);
})
);
return config;
},
]);
};
function getAssetDir(asset: string, root: string) {
const assetPath = ['app', 'src', 'main', 'assets'];
const resPath = ['app', 'src', 'main', 'res'];
const ext = path.extname(asset);
if (IMAGE_TYPES.includes(ext)) {
return path.join(root, ...resPath, 'drawable');
} else if (FONT_TYPES.includes(ext)) {
return path.join(root, ...assetPath, 'fonts');
} else if (MEDIA_TYPES.includes(ext)) {
return path.join(root, ...resPath, 'raw');
} else {
return path.join(root, ...assetPath);
}
}

93
node_modules/expo-asset/plugin/src/withAssetsIos.ts generated vendored Normal file
View File

@@ -0,0 +1,93 @@
import { type ImageOptions, generateImageAsync } from '@expo/image-utils';
import type { ExpoConfig } from 'expo/config';
import {
type ConfigPlugin,
IOSConfig,
type XcodeProject,
withXcodeProject,
} from 'expo/config-plugins';
import fs from 'fs/promises';
import path from 'path';
import { type ContentsJsonImage, writeContentsJsonAsync } from './AssetContents';
import { IMAGE_TYPES, resolveAssetPaths, validateAssets } from './utils';
const IMAGE_DIR = 'Images.xcassets';
export const withAssetsIos: ConfigPlugin<string[]> = (config, assets) => {
config = addAssetsToTarget(config, assets);
return config;
};
function addAssetsToTarget(config: ExpoConfig, assets: string[]) {
return withXcodeProject(config, async (config) => {
const resolvedAssets = await resolveAssetPaths(assets, config.modRequest.projectRoot);
const validAssets = validateAssets(resolvedAssets, 'ios');
const project = config.modResults;
const platformProjectRoot = config.modRequest.platformProjectRoot;
IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');
const images = validAssets.filter((asset) => IMAGE_TYPES.includes(path.extname(asset)));
const assetsForResourcesDir = validAssets.filter(
(asset) => !IMAGE_TYPES.includes(path.extname(asset))
);
await addImageAssets(images, config.modRequest.projectRoot);
addResourceFiles(project, platformProjectRoot, assetsForResourcesDir);
return config;
});
}
function addResourceFiles(project: XcodeProject, platformRoot: string, assets: string[]) {
for (const asset of assets) {
const assetPath = path.relative(platformRoot, asset);
IOSConfig.XcodeUtils.addResourceFileToGroup({
filepath: assetPath,
groupName: 'Resources',
project,
isBuildFile: true,
verbose: true,
});
}
}
async function addImageAssets(assets: string[], root: string) {
const iosNamedProjectRoot = IOSConfig.Paths.getSourceRoot(root);
for (const asset of assets) {
const name = path.basename(asset, path.extname(asset));
const image = path.basename(asset);
const assetPath = path.resolve(iosNamedProjectRoot, `${IMAGE_DIR}/${name}.imageset`);
await fs.mkdir(assetPath, { recursive: true });
const buffer = await generateImageAsync({ projectRoot: root }, {
src: asset,
} as unknown as ImageOptions);
await fs.writeFile(path.resolve(assetPath, image), buffer.source);
await writeContentsJsonFileAsync({
assetPath,
image,
});
}
}
async function writeContentsJsonFileAsync({
assetPath,
image,
}: {
assetPath: string;
image: string;
}) {
const images = buildContentsJsonImages({ image });
await writeContentsJsonAsync(assetPath, { images });
}
function buildContentsJsonImages({ image }: { image: string }): ContentsJsonImage[] {
return [
{ idiom: 'universal', filename: image, scale: '1x' },
{ idiom: 'universal', scale: '2x' },
{ idiom: 'universal', scale: '3x' },
];
}

9
node_modules/expo-asset/plugin/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"extends": "expo-module-scripts/tsconfig.plugin",
"compilerOptions": {
"outDir": "build",
"rootDir": "src"
},
"include": ["./src"],
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
}