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,25 @@
import type { ExpoConfig } from '@expo/config-types';
/**
* Rule to transform from config to build properties
*
* @example
* ```ts
* {
* propName: 'expo.jsEngine',
* propValueGetter: (config) => config.ios?.jsEngine ?? config.jsEngine ?? 'hermes',
* }
* ```
* Will lookup a value through the `propValueGetter`, and update to `hermesEnabled` key-value in **android/gradle.properties**
* or `expo.jsEngine` key-value in **ios/Podfile.properties.json**.
*
*/
/**
* Source config can be either expo config or generic config
*/
export type BuildPropertiesConfig = ExpoConfig | Record<string, any>;
export interface ConfigToPropertyRuleType<SourceConfigType extends BuildPropertiesConfig> {
/** Property name in `android/gradle.properties` or `ios/Podfile.properties.json` */
propName: string;
/** Passing config and get the property value */
propValueGetter: (config: SourceConfigType) => string | null | undefined;
}

View File

@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=BuildProperties.types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BuildProperties.types.js","names":[],"sources":["../../src/utils/BuildProperties.types.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\n/**\n * Rule to transform from config to build properties\n *\n * @example\n * ```ts\n * {\n * propName: 'expo.jsEngine',\n * propValueGetter: (config) => config.ios?.jsEngine ?? config.jsEngine ?? 'hermes',\n * }\n * ```\n * Will lookup a value through the `propValueGetter`, and update to `hermesEnabled` key-value in **android/gradle.properties**\n * or `expo.jsEngine` key-value in **ios/Podfile.properties.json**.\n *\n */\n\n/**\n * Source config can be either expo config or generic config\n */\nexport type BuildPropertiesConfig = ExpoConfig | Record<string, any>;\n\nexport interface ConfigToPropertyRuleType<SourceConfigType extends BuildPropertiesConfig> {\n /** Property name in `android/gradle.properties` or `ios/Podfile.properties.json` */\n propName: string;\n\n /** Passing config and get the property value */\n propValueGetter: (config: SourceConfigType) => string | null | undefined;\n}\n"],"mappings":"","ignoreList":[]}

View File

@@ -0,0 +1,31 @@
import { Android, ExpoConfig, IOS } from '@expo/config-types';
export type ExpoConfigUpdates = Pick<ExpoConfig, 'sdkVersion' | 'runtimeVersion' | 'updates' | 'slug'>;
export declare const FINGERPRINT_RUNTIME_VERSION_SENTINEL = "file:fingerprint";
export declare function getExpoUpdatesPackageVersion(projectRoot: string): string | null;
export declare function getUpdateUrl(config: Pick<ExpoConfigUpdates, 'updates'>): string | null;
export declare function getAppVersion(config: Pick<ExpoConfig, 'version'>): string;
export declare function getNativeVersion(config: Pick<ExpoConfig, 'version'> & {
android?: Pick<Android, 'versionCode'>;
ios?: Pick<IOS, 'buildNumber'>;
}, platform: 'android' | 'ios'): string;
export declare function getRuntimeVersionNullableAsync(...[projectRoot, config, platform]: Parameters<typeof getRuntimeVersionAsync>): Promise<string | null>;
export declare function getRuntimeVersionAsync(projectRoot: string, config: Pick<ExpoConfig, 'version' | 'runtimeVersion' | 'sdkVersion'> & {
android?: Pick<Android, 'versionCode' | 'runtimeVersion'>;
ios?: Pick<IOS, 'buildNumber' | 'runtimeVersion'>;
}, platform: 'android' | 'ios'): Promise<string | null>;
export declare function resolveRuntimeVersionPolicyAsync(policy: 'appVersion' | 'nativeVersion' | 'sdkVersion', config: Pick<ExpoConfig, 'version' | 'sdkVersion'> & {
android?: Pick<Android, 'versionCode'>;
ios?: Pick<IOS, 'buildNumber'>;
}, platform: 'android' | 'ios'): Promise<string>;
export declare function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null;
export declare function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean;
export declare function getUpdatesUseEmbeddedUpdate(config: Pick<ExpoConfigUpdates, 'updates'>): boolean;
export declare function getUpdatesBsdiffPatchSupportEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean;
export declare function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>): number;
export declare function getUpdatesCheckOnLaunch(config: Pick<ExpoConfigUpdates, 'updates'>, expoUpdatesPackageVersion?: string | null): 'NEVER' | 'ERROR_RECOVERY_ONLY' | 'ALWAYS' | 'WIFI_ONLY';
export declare function getUpdatesCodeSigningCertificate(projectRoot: string, config: Pick<ExpoConfigUpdates, 'updates'>): string | undefined;
export declare function getUpdatesCodeSigningMetadata(config: Pick<ExpoConfigUpdates, 'updates'>): NonNullable<ExpoConfigUpdates['updates']>['codeSigningMetadata'];
export declare function getUpdatesCodeSigningMetadataStringified(config: Pick<ExpoConfigUpdates, 'updates'>): string | undefined;
export declare function getUpdatesRequestHeaders(config: Pick<ExpoConfigUpdates, 'updates'>): NonNullable<ExpoConfigUpdates['updates']>['requestHeaders'];
export declare function getUpdatesRequestHeadersStringified(config: Pick<ExpoConfigUpdates, 'updates'>): string | undefined;
export declare function getDisableAntiBrickingMeasures(config: Pick<ExpoConfigUpdates, 'updates'>): boolean | undefined;

View File

@@ -0,0 +1,237 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FINGERPRINT_RUNTIME_VERSION_SENTINEL = void 0;
exports.getAppVersion = getAppVersion;
exports.getDisableAntiBrickingMeasures = getDisableAntiBrickingMeasures;
exports.getExpoUpdatesPackageVersion = getExpoUpdatesPackageVersion;
exports.getNativeVersion = getNativeVersion;
exports.getRuntimeVersionAsync = getRuntimeVersionAsync;
exports.getRuntimeVersionNullableAsync = getRuntimeVersionNullableAsync;
exports.getSDKVersion = getSDKVersion;
exports.getUpdateUrl = getUpdateUrl;
exports.getUpdatesBsdiffPatchSupportEnabled = getUpdatesBsdiffPatchSupportEnabled;
exports.getUpdatesCheckOnLaunch = getUpdatesCheckOnLaunch;
exports.getUpdatesCodeSigningCertificate = getUpdatesCodeSigningCertificate;
exports.getUpdatesCodeSigningMetadata = getUpdatesCodeSigningMetadata;
exports.getUpdatesCodeSigningMetadataStringified = getUpdatesCodeSigningMetadataStringified;
exports.getUpdatesEnabled = getUpdatesEnabled;
exports.getUpdatesRequestHeaders = getUpdatesRequestHeaders;
exports.getUpdatesRequestHeadersStringified = getUpdatesRequestHeadersStringified;
exports.getUpdatesTimeout = getUpdatesTimeout;
exports.getUpdatesUseEmbeddedUpdate = getUpdatesUseEmbeddedUpdate;
exports.resolveRuntimeVersionPolicyAsync = resolveRuntimeVersionPolicyAsync;
function _sdkRuntimeVersions() {
const data = require("@expo/sdk-runtime-versions");
_sdkRuntimeVersions = function () {
return data;
};
return data;
}
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _getenv() {
const data = require("getenv");
_getenv = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _resolveFrom() {
const data = _interopRequireDefault(require("resolve-from"));
_resolveFrom = function () {
return data;
};
return data;
}
function _semver() {
const data = _interopRequireDefault(require("semver"));
_semver = function () {
return data;
};
return data;
}
function AndroidVersion() {
const data = _interopRequireWildcard(require("../android/Version"));
AndroidVersion = function () {
return data;
};
return data;
}
function IOSVersion() {
const data = _interopRequireWildcard(require("../ios/Version"));
IOSVersion = function () {
return data;
};
return data;
}
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const FINGERPRINT_RUNTIME_VERSION_SENTINEL = exports.FINGERPRINT_RUNTIME_VERSION_SENTINEL = 'file:fingerprint';
function getExpoUpdatesPackageVersion(projectRoot) {
const expoUpdatesPackageJsonPath = _resolveFrom().default.silent(projectRoot, 'expo-updates/package.json');
if (!expoUpdatesPackageJsonPath || !_fs().default.existsSync(expoUpdatesPackageJsonPath)) {
return null;
}
const packageJson = JSON.parse(_fs().default.readFileSync(expoUpdatesPackageJsonPath, 'utf8'));
return packageJson.version;
}
function getUpdateUrl(config) {
return config.updates?.url ?? null;
}
function getAppVersion(config) {
return config.version ?? '1.0.0';
}
function getNativeVersion(config, platform) {
const version = IOSVersion().getVersion(config);
switch (platform) {
case 'ios':
{
const buildNumber = IOSVersion().getBuildNumber(config);
return `${version}(${buildNumber})`;
}
case 'android':
{
const versionCode = AndroidVersion().getVersionCode(config);
return `${version}(${versionCode})`;
}
default:
{
throw new Error(`"${platform}" is not a supported platform. Choose either "ios" or "android".`);
}
}
}
async function getRuntimeVersionNullableAsync(...[projectRoot, config, platform]) {
try {
return await getRuntimeVersionAsync(projectRoot, config, platform);
} catch (e) {
if ((0, _getenv().boolish)('EXPO_DEBUG', false)) {
console.log(e);
}
return null;
}
}
async function getRuntimeVersionAsync(projectRoot, config, platform) {
const runtimeVersion = config[platform]?.runtimeVersion ?? config.runtimeVersion;
if (!runtimeVersion) {
return null;
}
if (typeof runtimeVersion === 'string') {
if (runtimeVersion === FINGERPRINT_RUNTIME_VERSION_SENTINEL) {
throw new Error(`${FINGERPRINT_RUNTIME_VERSION_SENTINEL} is a reserved value for runtime version. To use a fingerprint runtime version, use the "fingerprint" runtime version policy.`);
}
return runtimeVersion;
} else if (!runtimeVersion.policy) {
throw new Error(`"${runtimeVersion}" is not a valid runtime version. Only a string or a runtime version policy is supported.`);
} else if (runtimeVersion.policy === 'fingerprint') {
return FINGERPRINT_RUNTIME_VERSION_SENTINEL;
} else {
return await resolveRuntimeVersionPolicyAsync(runtimeVersion.policy, config, platform);
}
}
async function resolveRuntimeVersionPolicyAsync(policy, config, platform) {
if (policy === 'appVersion') {
return getAppVersion(config);
} else if (policy === 'nativeVersion') {
return getNativeVersion(config, platform);
} else if (policy === 'sdkVersion') {
if (!config.sdkVersion) {
throw new Error("An SDK version must be defined when using the 'sdkVersion' runtime policy.");
}
return (0, _sdkRuntimeVersions().getRuntimeVersionForSDKVersion)(config.sdkVersion);
} else {
// fingerprint is resolvable only at build time (not in config plugin).
throw new Error(`"${policy}" is not a valid runtime version policy type.`);
}
}
function getSDKVersion(config) {
return typeof config.sdkVersion === 'string' ? config.sdkVersion : null;
}
function getUpdatesEnabled(config) {
// allow override of enabled property
if (config.updates?.enabled !== undefined) {
return config.updates.enabled;
}
return getUpdateUrl(config) !== null;
}
function getUpdatesUseEmbeddedUpdate(config) {
if (config.updates?.useEmbeddedUpdate !== undefined) {
return config.updates.useEmbeddedUpdate;
}
return true;
}
function getUpdatesBsdiffPatchSupportEnabled(config) {
if (config.updates?.enableBsdiffPatchSupport !== undefined) {
return config.updates.enableBsdiffPatchSupport;
}
return false;
}
function getUpdatesTimeout(config) {
return config.updates?.fallbackToCacheTimeout ?? 0;
}
function getUpdatesCheckOnLaunch(config, expoUpdatesPackageVersion) {
if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {
// native 'ERROR_RECOVERY_ONLY' option was only introduced in 0.11.x
if (expoUpdatesPackageVersion && _semver().default.gte(expoUpdatesPackageVersion, '0.11.0')) {
return 'ERROR_RECOVERY_ONLY';
}
return 'NEVER';
} else if (config.updates?.checkAutomatically === 'ON_LOAD') {
return 'ALWAYS';
} else if (config.updates?.checkAutomatically === 'WIFI_ONLY') {
return 'WIFI_ONLY';
} else if (config.updates?.checkAutomatically === 'NEVER') {
return 'NEVER';
}
return 'ALWAYS';
}
function getUpdatesCodeSigningCertificate(projectRoot, config) {
const codeSigningCertificatePath = config.updates?.codeSigningCertificate;
if (!codeSigningCertificatePath) {
return undefined;
}
const finalPath = _path().default.join(projectRoot, codeSigningCertificatePath);
if (!_fs().default.existsSync(finalPath)) {
throw new Error(`File not found at \`updates.codeSigningCertificate\` path: ${finalPath}`);
}
return _fs().default.readFileSync(finalPath, 'utf8');
}
function getUpdatesCodeSigningMetadata(config) {
return config.updates?.codeSigningMetadata;
}
function getUpdatesCodeSigningMetadataStringified(config) {
const metadata = getUpdatesCodeSigningMetadata(config);
if (!metadata) {
return undefined;
}
return JSON.stringify(metadata);
}
function getUpdatesRequestHeaders(config) {
return config.updates?.requestHeaders;
}
function getUpdatesRequestHeadersStringified(config) {
const metadata = getUpdatesRequestHeaders(config);
if (!metadata) {
return undefined;
}
return JSON.stringify(metadata);
}
function getDisableAntiBrickingMeasures(config) {
return config.updates?.disableAntiBrickingMeasures;
}
//# sourceMappingURL=Updates.js.map

File diff suppressed because one or more lines are too long

27
node_modules/@expo/config-plugins/build/utils/XML.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
export type XMLValue = boolean | number | string | null | XMLArray | XMLObject;
export interface XMLArray extends Array<XMLValue> {
}
export interface XMLObject {
[key: string]: XMLValue | undefined;
}
export declare function writeXMLAsync(options: {
path: string;
xml: any;
}): Promise<void>;
export declare function readXMLAsync(options: {
path: string;
fallback?: string | null;
}): Promise<XMLObject>;
export declare function _processAndroidXML(manifest: any): XMLObject;
export declare function parseXMLAsync(contents: string): Promise<XMLObject>;
export declare function format(manifest: any, { indentLevel, newline }?: {
indentLevel?: number | undefined;
newline?: string | undefined;
}): string;
/**
* Escapes Android string literals, specifically characters `"`, `'`, `\`, `\n`, `\r`, `\t`
*
* @param value unescaped Android XML string literal.
*/
export declare function escapeAndroidString(value: string): string;
export declare function unescapeAndroidString(value: string): string;

164
node_modules/@expo/config-plugins/build/utils/XML.js generated vendored Normal file
View File

@@ -0,0 +1,164 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports._processAndroidXML = _processAndroidXML;
exports.escapeAndroidString = escapeAndroidString;
exports.format = format;
exports.parseXMLAsync = parseXMLAsync;
exports.readXMLAsync = readXMLAsync;
exports.unescapeAndroidString = unescapeAndroidString;
exports.writeXMLAsync = writeXMLAsync;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _os() {
const data = require("os");
_os = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _xml2js() {
const data = require("xml2js");
_xml2js = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
async function writeXMLAsync(options) {
const xml = format(options.xml);
await _fs().default.promises.mkdir(_path().default.dirname(options.path), {
recursive: true
});
await _fs().default.promises.writeFile(options.path, xml);
}
async function readXMLAsync(options) {
let contents = '';
try {
contents = await _fs().default.promises.readFile(options.path, {
encoding: 'utf8',
flag: 'r'
});
} catch {
// catch and use fallback
}
const parser = new (_xml2js().Parser)();
const manifest = await parser.parseStringPromise(contents || options.fallback || '');
return _processAndroidXML(manifest);
}
function _processAndroidXML(manifest) {
// For strings.xml
if (Array.isArray(manifest?.resources?.string)) {
for (const string of manifest?.resources?.string) {
if (string.$.translatable === 'false' || string.$.translatable === false) {
continue;
}
if (!('_' in string)) {
throw new Error(`Empty string resource not supported: ${JSON.stringify(string)}`);
}
string._ = unescapeAndroidString(string._);
}
}
return manifest;
}
async function parseXMLAsync(contents) {
const xml = await new (_xml2js().Parser)().parseStringPromise(contents);
return xml;
}
const stringTimesN = (n, char) => Array(n + 1).join(char);
function format(manifest, {
indentLevel = 2,
newline = _os().EOL
} = {}) {
let xmlInput;
if (typeof manifest === 'string') {
xmlInput = manifest;
} else if (manifest.toString) {
const builder = new (_xml2js().Builder)({
headless: true
});
// For strings.xml
if (Array.isArray(manifest?.resources?.string)) {
for (const string of manifest?.resources?.string) {
if (string.$.translatable === 'false' || string.$.translatable === false) {
continue;
}
string._ = escapeAndroidString(string._);
}
}
xmlInput = builder.buildObject(manifest);
return xmlInput;
} else {
throw new Error(`Invalid XML value passed in: ${manifest}`);
}
const indentString = stringTimesN(indentLevel, ' ');
let formatted = '';
const regex = /(>)(<)(\/*)/g;
const xml = xmlInput.replace(regex, `$1${newline}$2$3`);
let pad = 0;
xml.split(/\r?\n/).map(line => line.trim()).forEach(line => {
let indent = 0;
if (line.match(/.+<\/\w[^>]*>$/)) {
indent = 0;
} else if (line.match(/^<\/\w/)) {
if (pad !== 0) {
pad -= 1;
}
} else if (line.match(/^<\w([^>]*[^/])?>.*$/)) {
indent = 1;
} else {
indent = 0;
}
const padding = stringTimesN(pad, indentString);
formatted += padding + line + newline;
pad += indent;
});
return formatted.trim();
}
/**
* Escapes Android string literals, specifically characters `"`, `'`, `\`, `\n`, `\r`, `\t`
*
* @param value unescaped Android XML string literal.
*/
function escapeAndroidString(value) {
value = value.replace(/[\n\r\t'"@]/g, m => {
switch (m) {
case '"':
case "'":
case '@':
return '\\' + m;
case '\n':
return '\\n';
case '\r':
return '\\r';
case '\t':
return '\\t';
default:
throw new Error(`Cannot escape unhandled XML character: ${m}`);
}
});
if (value.match(/(^\s|\s$)/)) {
value = '"' + value + '"';
}
return value;
}
function unescapeAndroidString(value) {
return value.replace(/\\(.)/g, '$1');
}
//# sourceMappingURL=XML.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
export interface CodeBlock {
start: number;
end: number;
code: string;
}
/**
* Insert contents at given offset
* @param srcContents source contents
* @param insertion content to insert
* @param offset `srcContents` offset to insert `insertion`
* @returns updated contents
*/
export declare function insertContentsAtOffset(srcContents: string, insertion: string, offset: number): string;
/**
* Replace contents at given start and end offset
*
* @param contents source contents
* @param replacement new contents to place in [startOffset:endOffset]
* @param startOffset `contents` start offset for replacement
* @param endOffset `contents` end offset for replacement
* @returns updated contents
*/
export declare function replaceContentsWithOffset(contents: string, replacement: string, startOffset: number, endOffset: number): string;
/**
* String.prototype.search() with offset support
*
* @param source source string to search
* @param regexp RegExp pattern to search
* @param offset start offset of `source` to search `regexp` pattern
* @returns The index of the first match between the regular expression and the given string, or -1 if no match was found.
*/
export declare function searchFromOffset(source: string, regexp: RegExp, offset: number): number;

View File

@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.insertContentsAtOffset = insertContentsAtOffset;
exports.replaceContentsWithOffset = replaceContentsWithOffset;
exports.searchFromOffset = searchFromOffset;
/**
* Insert contents at given offset
* @param srcContents source contents
* @param insertion content to insert
* @param offset `srcContents` offset to insert `insertion`
* @returns updated contents
*/
function insertContentsAtOffset(srcContents, insertion, offset) {
const srcContentsLength = srcContents.length;
if (offset < 0 || offset > srcContentsLength) {
throw new Error('Invalid parameters.');
}
if (offset === 0) {
return `${insertion}${srcContents}`;
} else if (offset === srcContentsLength) {
return `${srcContents}${insertion}`;
}
const prefix = srcContents.substring(0, offset);
const suffix = srcContents.substring(offset);
return `${prefix}${insertion}${suffix}`;
}
/**
* Replace contents at given start and end offset
*
* @param contents source contents
* @param replacement new contents to place in [startOffset:endOffset]
* @param startOffset `contents` start offset for replacement
* @param endOffset `contents` end offset for replacement
* @returns updated contents
*/
function replaceContentsWithOffset(contents, replacement, startOffset, endOffset) {
const contentsLength = contents.length;
if (startOffset < 0 || endOffset < 0 || startOffset >= contentsLength || endOffset >= contentsLength || startOffset > endOffset) {
throw new Error('Invalid parameters.');
}
const prefix = contents.substring(0, startOffset);
const suffix = contents.substring(endOffset + 1);
return `${prefix}${replacement}${suffix}`;
}
/**
* String.prototype.search() with offset support
*
* @param source source string to search
* @param regexp RegExp pattern to search
* @param offset start offset of `source` to search `regexp` pattern
* @returns The index of the first match between the regular expression and the given string, or -1 if no match was found.
*/
function searchFromOffset(source, regexp, offset) {
const target = source.substring(offset);
const matchedIndex = target.search(regexp);
return matchedIndex < 0 ? matchedIndex : matchedIndex + offset;
}
//# sourceMappingURL=commonCodeMod.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"commonCodeMod.js","names":["insertContentsAtOffset","srcContents","insertion","offset","srcContentsLength","length","Error","prefix","substring","suffix","replaceContentsWithOffset","contents","replacement","startOffset","endOffset","contentsLength","searchFromOffset","source","regexp","target","matchedIndex","search"],"sources":["../../src/utils/commonCodeMod.ts"],"sourcesContent":["export interface CodeBlock {\n start: number;\n end: number;\n code: string;\n}\n\n/**\n * Insert contents at given offset\n * @param srcContents source contents\n * @param insertion content to insert\n * @param offset `srcContents` offset to insert `insertion`\n * @returns updated contents\n */\nexport function insertContentsAtOffset(\n srcContents: string,\n insertion: string,\n offset: number\n): string {\n const srcContentsLength = srcContents.length;\n if (offset < 0 || offset > srcContentsLength) {\n throw new Error('Invalid parameters.');\n }\n if (offset === 0) {\n return `${insertion}${srcContents}`;\n } else if (offset === srcContentsLength) {\n return `${srcContents}${insertion}`;\n }\n\n const prefix = srcContents.substring(0, offset);\n const suffix = srcContents.substring(offset);\n return `${prefix}${insertion}${suffix}`;\n}\n\n/**\n * Replace contents at given start and end offset\n *\n * @param contents source contents\n * @param replacement new contents to place in [startOffset:endOffset]\n * @param startOffset `contents` start offset for replacement\n * @param endOffset `contents` end offset for replacement\n * @returns updated contents\n */\nexport function replaceContentsWithOffset(\n contents: string,\n replacement: string,\n startOffset: number,\n endOffset: number\n): string {\n const contentsLength = contents.length;\n if (\n startOffset < 0 ||\n endOffset < 0 ||\n startOffset >= contentsLength ||\n endOffset >= contentsLength ||\n startOffset > endOffset\n ) {\n throw new Error('Invalid parameters.');\n }\n const prefix = contents.substring(0, startOffset);\n const suffix = contents.substring(endOffset + 1);\n return `${prefix}${replacement}${suffix}`;\n}\n\n/**\n * String.prototype.search() with offset support\n *\n * @param source source string to search\n * @param regexp RegExp pattern to search\n * @param offset start offset of `source` to search `regexp` pattern\n * @returns The index of the first match between the regular expression and the given string, or -1 if no match was found.\n */\nexport function searchFromOffset(source: string, regexp: RegExp, offset: number): number {\n const target = source.substring(offset);\n const matchedIndex = target.search(regexp);\n return matchedIndex < 0 ? matchedIndex : matchedIndex + offset;\n}\n"],"mappings":";;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAsBA,CACpCC,WAAmB,EACnBC,SAAiB,EACjBC,MAAc,EACN;EACR,MAAMC,iBAAiB,GAAGH,WAAW,CAACI,MAAM;EAC5C,IAAIF,MAAM,GAAG,CAAC,IAAIA,MAAM,GAAGC,iBAAiB,EAAE;IAC5C,MAAM,IAAIE,KAAK,CAAC,qBAAqB,CAAC;EACxC;EACA,IAAIH,MAAM,KAAK,CAAC,EAAE;IAChB,OAAO,GAAGD,SAAS,GAAGD,WAAW,EAAE;EACrC,CAAC,MAAM,IAAIE,MAAM,KAAKC,iBAAiB,EAAE;IACvC,OAAO,GAAGH,WAAW,GAAGC,SAAS,EAAE;EACrC;EAEA,MAAMK,MAAM,GAAGN,WAAW,CAACO,SAAS,CAAC,CAAC,EAAEL,MAAM,CAAC;EAC/C,MAAMM,MAAM,GAAGR,WAAW,CAACO,SAAS,CAACL,MAAM,CAAC;EAC5C,OAAO,GAAGI,MAAM,GAAGL,SAAS,GAAGO,MAAM,EAAE;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CACvCC,QAAgB,EAChBC,WAAmB,EACnBC,WAAmB,EACnBC,SAAiB,EACT;EACR,MAAMC,cAAc,GAAGJ,QAAQ,CAACN,MAAM;EACtC,IACEQ,WAAW,GAAG,CAAC,IACfC,SAAS,GAAG,CAAC,IACbD,WAAW,IAAIE,cAAc,IAC7BD,SAAS,IAAIC,cAAc,IAC3BF,WAAW,GAAGC,SAAS,EACvB;IACA,MAAM,IAAIR,KAAK,CAAC,qBAAqB,CAAC;EACxC;EACA,MAAMC,MAAM,GAAGI,QAAQ,CAACH,SAAS,CAAC,CAAC,EAAEK,WAAW,CAAC;EACjD,MAAMJ,MAAM,GAAGE,QAAQ,CAACH,SAAS,CAACM,SAAS,GAAG,CAAC,CAAC;EAChD,OAAO,GAAGP,MAAM,GAAGK,WAAW,GAAGH,MAAM,EAAE;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,gBAAgBA,CAACC,MAAc,EAAEC,MAAc,EAAEf,MAAc,EAAU;EACvF,MAAMgB,MAAM,GAAGF,MAAM,CAACT,SAAS,CAACL,MAAM,CAAC;EACvC,MAAMiB,YAAY,GAAGD,MAAM,CAACE,MAAM,CAACH,MAAM,CAAC;EAC1C,OAAOE,YAAY,GAAG,CAAC,GAAGA,YAAY,GAAGA,YAAY,GAAGjB,MAAM;AAChE","ignoreList":[]}

View File

@@ -0,0 +1,15 @@
export declare class UnexpectedError extends Error {
readonly name = "UnexpectedError";
constructor(message: string);
}
export type PluginErrorCode = 'INVALID_PLUGIN_TYPE' | 'INVALID_PLUGIN_IMPORT' | 'PLUGIN_NOT_FOUND' | 'CONFLICTING_PROVIDER' | 'INVALID_MOD_ORDER' | 'MISSING_PROVIDER';
/**
* Based on `JsonFileError` from `@expo/json-file`
*/
export declare class PluginError extends Error {
code: PluginErrorCode;
cause?: Error | undefined;
readonly name = "PluginError";
readonly isPluginError = true;
constructor(message: string, code: PluginErrorCode, cause?: Error | undefined);
}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UnexpectedError = exports.PluginError = void 0;
class UnexpectedError extends Error {
name = 'UnexpectedError';
constructor(message) {
super(`${message}\nReport this issue: https://github.com/expo/expo/issues`);
}
}
exports.UnexpectedError = UnexpectedError;
/**
* Based on `JsonFileError` from `@expo/json-file`
*/
class PluginError extends Error {
name = 'PluginError';
isPluginError = true;
constructor(message, code, cause) {
super(cause ? `${message}\n└─ Cause: ${cause.name}: ${cause.message}` : message);
this.code = code;
this.cause = cause;
}
}
exports.PluginError = PluginError;
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","names":["UnexpectedError","Error","name","constructor","message","exports","PluginError","isPluginError","code","cause"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["export class UnexpectedError extends Error {\n readonly name = 'UnexpectedError';\n\n constructor(message: string) {\n super(`${message}\\nReport this issue: https://github.com/expo/expo/issues`);\n }\n}\n\nexport type PluginErrorCode =\n | 'INVALID_PLUGIN_TYPE'\n | 'INVALID_PLUGIN_IMPORT'\n | 'PLUGIN_NOT_FOUND'\n | 'CONFLICTING_PROVIDER'\n | 'INVALID_MOD_ORDER'\n | 'MISSING_PROVIDER';\n\n/**\n * Based on `JsonFileError` from `@expo/json-file`\n */\nexport class PluginError extends Error {\n readonly name = 'PluginError';\n readonly isPluginError = true;\n\n constructor(\n message: string,\n public code: PluginErrorCode,\n public cause?: Error\n ) {\n super(cause ? `${message}\\n└─ Cause: ${cause.name}: ${cause.message}` : message);\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EAChCC,IAAI,GAAG,iBAAiB;EAEjCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAAC,GAAGA,OAAO,0DAA0D,CAAC;EAC7E;AACF;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAUD;AACA;AACA;AACO,MAAMM,WAAW,SAASL,KAAK,CAAC;EAC5BC,IAAI,GAAG,aAAa;EACpBK,aAAa,GAAG,IAAI;EAE7BJ,WAAWA,CACTC,OAAe,EACRI,IAAqB,EACrBC,KAAa,EACpB;IACA,KAAK,CAACA,KAAK,GAAG,GAAGL,OAAO,eAAeK,KAAK,CAACP,IAAI,KAAKO,KAAK,CAACL,OAAO,EAAE,GAAGA,OAAO,CAAC;IAAC,KAH1EI,IAAqB,GAArBA,IAAqB;IAAA,KACrBC,KAAa,GAAbA,KAAa;EAGtB;AACF;AAACJ,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}

View File

@@ -0,0 +1,4 @@
/** A basic function that copies a single file to another file location. */
export declare function copyFilePathToPathAsync(src: string, dest: string): Promise<void>;
/** Remove a single file (not directory). Returns `true` if a file was actually deleted. */
export declare function removeFile(filePath: string): boolean;

45
node_modules/@expo/config-plugins/build/utils/fs.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.copyFilePathToPathAsync = copyFilePathToPathAsync;
exports.removeFile = removeFile;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** A basic function that copies a single file to another file location. */
async function copyFilePathToPathAsync(src, dest) {
const srcFile = await _fs().default.promises.readFile(src);
await _fs().default.promises.mkdir(_path().default.dirname(dest), {
recursive: true
});
await _fs().default.promises.writeFile(dest, srcFile);
}
/** Remove a single file (not directory). Returns `true` if a file was actually deleted. */
function removeFile(filePath) {
try {
_fs().default.unlinkSync(filePath);
return true;
} catch (error) {
// Skip if the remove did nothing.
if (error.code === 'ENOENT') {
return false;
}
throw error;
}
}
//# sourceMappingURL=fs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fs.js","names":["_fs","data","_interopRequireDefault","require","_path","e","__esModule","default","copyFilePathToPathAsync","src","dest","srcFile","fs","promises","readFile","mkdir","path","dirname","recursive","writeFile","removeFile","filePath","unlinkSync","error","code"],"sources":["../../src/utils/fs.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\n/** A basic function that copies a single file to another file location. */\nexport async function copyFilePathToPathAsync(src: string, dest: string): Promise<void> {\n const srcFile = await fs.promises.readFile(src);\n await fs.promises.mkdir(path.dirname(dest), { recursive: true });\n await fs.promises.writeFile(dest, srcFile);\n}\n\n/** Remove a single file (not directory). Returns `true` if a file was actually deleted. */\nexport function removeFile(filePath: string): boolean {\n try {\n fs.unlinkSync(filePath);\n return true;\n } catch (error: any) {\n // Skip if the remove did nothing.\n if (error.code === 'ENOENT') {\n return false;\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwB,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB;AACO,eAAeG,uBAAuBA,CAACC,GAAW,EAAEC,IAAY,EAAiB;EACtF,MAAMC,OAAO,GAAG,MAAMC,aAAE,CAACC,QAAQ,CAACC,QAAQ,CAACL,GAAG,CAAC;EAC/C,MAAMG,aAAE,CAACC,QAAQ,CAACE,KAAK,CAACC,eAAI,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;IAAEQ,SAAS,EAAE;EAAK,CAAC,CAAC;EAChE,MAAMN,aAAE,CAACC,QAAQ,CAACM,SAAS,CAACT,IAAI,EAAEC,OAAO,CAAC;AAC5C;;AAEA;AACO,SAASS,UAAUA,CAACC,QAAgB,EAAW;EACpD,IAAI;IACFT,aAAE,CAACU,UAAU,CAACD,QAAQ,CAAC;IACvB,OAAO,IAAI;EACb,CAAC,CAAC,OAAOE,KAAU,EAAE;IACnB;IACA,IAAIA,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;MAC3B,OAAO,KAAK;IACd;IACA,MAAMD,KAAK;EACb;AACF","ignoreList":[]}

View File

@@ -0,0 +1,36 @@
export type MergeResults = {
contents: string;
didClear: boolean;
didMerge: boolean;
};
/**
* Merge the contents of two files together and add a generated header.
*
* @param src contents of the original file
* @param newSrc new contents to merge into the original file
* @param identifier used to update and remove merges
* @param anchor regex to where the merge should begin
* @param offset line offset to start merging at (<1 for behind the anchor)
* @param comment comment style `//` or `#`
*/
export declare function mergeContents({ src, newSrc, tag, anchor, offset, comment, }: {
src: string;
newSrc: string;
tag: string;
anchor: string | RegExp;
offset: number;
comment: string;
}): MergeResults;
export declare function removeContents({ src, tag }: {
src: string;
tag: string;
}): MergeResults;
/**
* Removes the generated section from a file, returns null when nothing can be removed.
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
*
* @param src
*/
export declare function removeGeneratedContents(src: string, tag: string): string | null;
export declare function createGeneratedHeaderComment(contents: string, tag: string, comment: string): string;
export declare function createHash(src: string): string;

View File

@@ -0,0 +1,128 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createGeneratedHeaderComment = createGeneratedHeaderComment;
exports.createHash = createHash;
exports.mergeContents = mergeContents;
exports.removeContents = removeContents;
exports.removeGeneratedContents = removeGeneratedContents;
function _crypto() {
const data = _interopRequireDefault(require("crypto"));
_crypto = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* Get line indexes for the generated section of a file.
*
* @param src
*/
function getGeneratedSectionIndexes(src, tag) {
const contents = src.split('\n');
const start = contents.findIndex(line => new RegExp(`@generated begin ${tag} -`).test(line));
const end = contents.findIndex(line => new RegExp(`@generated end ${tag}$`).test(line));
return {
contents,
start,
end
};
}
/**
* Merge the contents of two files together and add a generated header.
*
* @param src contents of the original file
* @param newSrc new contents to merge into the original file
* @param identifier used to update and remove merges
* @param anchor regex to where the merge should begin
* @param offset line offset to start merging at (<1 for behind the anchor)
* @param comment comment style `//` or `#`
*/
function mergeContents({
src,
newSrc,
tag,
anchor,
offset,
comment
}) {
const header = createGeneratedHeaderComment(newSrc, tag, comment);
if (!src.includes(header)) {
// Ensure the old generated contents are removed.
const sanitizedTarget = removeGeneratedContents(src, tag);
return {
contents: addLines(sanitizedTarget ?? src, anchor, offset, [header, ...newSrc.split('\n'), `${comment} @generated end ${tag}`]),
didMerge: true,
didClear: !!sanitizedTarget
};
}
return {
contents: src,
didClear: false,
didMerge: false
};
}
function removeContents({
src,
tag
}) {
// Ensure the old generated contents are removed.
const sanitizedTarget = removeGeneratedContents(src, tag);
return {
contents: sanitizedTarget ?? src,
didMerge: false,
didClear: !!sanitizedTarget
};
}
function addLines(content, find, offset, toAdd) {
const lines = content.split('\n');
let lineIndex = lines.findIndex(line => line.match(find));
if (lineIndex < 0) {
const error = new Error(`Failed to match "${find}" in contents:\n${content}`);
// @ts-ignore
error.code = 'ERR_NO_MATCH';
throw error;
}
for (const newLine of toAdd) {
lines.splice(lineIndex + offset, 0, newLine);
lineIndex++;
}
return lines.join('\n');
}
/**
* Removes the generated section from a file, returns null when nothing can be removed.
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
*
* @param src
*/
function removeGeneratedContents(src, tag) {
const {
contents,
start,
end
} = getGeneratedSectionIndexes(src, tag);
if (start > -1 && end > -1 && start < end) {
contents.splice(start, end - start + 1);
// TODO: We could in theory check that the contents we're removing match the hash used in the header,
// this would ensure that we don't accidentally remove lines that someone added or removed from the generated section.
return contents.join('\n');
}
return null;
}
function createGeneratedHeaderComment(contents, tag, comment) {
const hashKey = createHash(contents);
// Everything after the `${tag} ` is unversioned and can be freely modified without breaking changes.
return `${comment} @generated begin ${tag} - expo prebuild (DO NOT MODIFY) ${hashKey}`;
}
function createHash(src) {
// this doesn't need to be secure, the shorter the better.
const hash = _crypto().default.createHash('sha1').update(src).digest('hex');
return `sync-${hash}`;
}
//# sourceMappingURL=generateCode.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
/**
* Sort the glob result alphabetically, to ensure results are identical across different devices (Linux/MacOS).
* Since `glob@9` the results are determined by the OS and not guaranteed to be sorted.
*
* @see https://github.com/isaacs/node-glob/issues/576#issuecomment-1972765500
*/
export declare function withSortedGlobResult(glob: string[]): string[];

16
node_modules/@expo/config-plugins/build/utils/glob.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.withSortedGlobResult = withSortedGlobResult;
/**
* Sort the glob result alphabetically, to ensure results are identical across different devices (Linux/MacOS).
* Since `glob@9` the results are determined by the OS and not guaranteed to be sorted.
*
* @see https://github.com/isaacs/node-glob/issues/576#issuecomment-1972765500
*/
function withSortedGlobResult(glob) {
return glob.sort((a, b) => a.localeCompare(b));
}
//# sourceMappingURL=glob.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"glob.js","names":["withSortedGlobResult","glob","sort","a","b","localeCompare"],"sources":["../../src/utils/glob.ts"],"sourcesContent":["/**\n * Sort the glob result alphabetically, to ensure results are identical across different devices (Linux/MacOS).\n * Since `glob@9` the results are determined by the OS and not guaranteed to be sorted.\n *\n * @see https://github.com/isaacs/node-glob/issues/576#issuecomment-1972765500\n */\nexport function withSortedGlobResult(glob: string[]) {\n return glob.sort((a, b) => a.localeCompare(b));\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAoBA,CAACC,IAAc,EAAE;EACnD,OAAOA,IAAI,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC;AAChD","ignoreList":[]}

View File

@@ -0,0 +1,11 @@
import { ExpoConfig } from '@expo/config-types';
import { ModPlatform } from '../Plugin.types';
export type PluginHistoryItem = {
name: string;
version: string;
platform?: ModPlatform;
};
export declare function getHistoryItem(config: Pick<ExpoConfig, '_internal'>, name: string): PluginHistoryItem | null;
export declare function addHistoryItem(config: ExpoConfig, item: Omit<PluginHistoryItem, 'version'> & {
version?: string;
}): ExpoConfig;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addHistoryItem = addHistoryItem;
exports.getHistoryItem = getHistoryItem;
function getHistoryItem(config, name) {
return config._internal?.pluginHistory?.[name] ?? null;
}
function addHistoryItem(config, item) {
if (!config._internal) {
config._internal = {};
}
if (!config._internal.pluginHistory) {
config._internal.pluginHistory = {};
}
if (!item.version) {
item.version = 'UNVERSIONED';
}
config._internal.pluginHistory[item.name] = item;
return config;
}
//# sourceMappingURL=history.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"history.js","names":["getHistoryItem","config","name","_internal","pluginHistory","addHistoryItem","item","version"],"sources":["../../src/utils/history.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ModPlatform } from '../Plugin.types';\n\nexport type PluginHistoryItem = {\n name: string;\n version: string;\n platform?: ModPlatform;\n};\n\nexport function getHistoryItem(\n config: Pick<ExpoConfig, '_internal'>,\n name: string\n): PluginHistoryItem | null {\n return config._internal?.pluginHistory?.[name] ?? null;\n}\n\nexport function addHistoryItem(\n config: ExpoConfig,\n item: Omit<PluginHistoryItem, 'version'> & { version?: string }\n): ExpoConfig {\n if (!config._internal) {\n config._internal = {};\n }\n if (!config._internal.pluginHistory) {\n config._internal.pluginHistory = {};\n }\n\n if (!item.version) {\n item.version = 'UNVERSIONED';\n }\n\n config._internal.pluginHistory[item.name] = item;\n\n return config;\n}\n"],"mappings":";;;;;;;AAUO,SAASA,cAAcA,CAC5BC,MAAqC,EACrCC,IAAY,EACc;EAC1B,OAAOD,MAAM,CAACE,SAAS,EAAEC,aAAa,GAAGF,IAAI,CAAC,IAAI,IAAI;AACxD;AAEO,SAASG,cAAcA,CAC5BJ,MAAkB,EAClBK,IAA+D,EACnD;EACZ,IAAI,CAACL,MAAM,CAACE,SAAS,EAAE;IACrBF,MAAM,CAACE,SAAS,GAAG,CAAC,CAAC;EACvB;EACA,IAAI,CAACF,MAAM,CAACE,SAAS,CAACC,aAAa,EAAE;IACnCH,MAAM,CAACE,SAAS,CAACC,aAAa,GAAG,CAAC,CAAC;EACrC;EAEA,IAAI,CAACE,IAAI,CAACC,OAAO,EAAE;IACjBD,IAAI,CAACC,OAAO,GAAG,aAAa;EAC9B;EAEAN,MAAM,CAACE,SAAS,CAACC,aAAa,CAACE,IAAI,CAACJ,IAAI,CAAC,GAAGI,IAAI;EAEhD,OAAOL,MAAM;AACf","ignoreList":[]}

View File

@@ -0,0 +1,17 @@
import { ExpoConfig } from '@expo/config-types';
/**
* on iOS only, we support a special case where
* StringsMap contains a 'Localizable.strings'?: StringsMap; entry
* Values written into `Localizable.strings` for iOS.
*/
export type StringsMap = Record<string, string>;
export type LocaleJson = Record<string, string> & {
ios?: StringsMap;
android?: StringsMap;
};
export type ExpoConfigLocales = NonNullable<ExpoConfig['locales']>;
export type ResolvedLocalesJson = Record<string, LocaleJson>;
export declare function getResolvedLocalesAsync(projectRoot: string, input: ExpoConfigLocales, forPlatform: 'ios' | 'android'): Promise<{
localesMap: ResolvedLocalesJson;
localizableStringsIOS?: ResolvedLocalesJson;
}>;

View File

@@ -0,0 +1,132 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getResolvedLocalesAsync = getResolvedLocalesAsync;
function _jsonFile() {
const data = _interopRequireDefault(require("@expo/json-file"));
_jsonFile = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _warnings() {
const data = require("./warnings");
_warnings = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* on iOS only, we support a special case where
* StringsMap contains a 'Localizable.strings'?: StringsMap; entry
* Values written into `Localizable.strings` for iOS.
*/
async function getResolvedLocalesAsync(projectRoot, input, forPlatform) {
const locales = {};
const localizableStringsIOS = {};
for (const [lang, localeJsonPath] of Object.entries(input)) {
const locale = await getLocales(projectRoot, localeJsonPath, forPlatform, lang);
if (locale) {
const {
android,
ios,
...rest
} = {
android: {},
ios: {},
...locale
};
if (forPlatform === 'ios') {
const {
localizableStringsEntry,
otherEntries
} = extractIosLocalizableStrings({
ios,
lang
});
if (localizableStringsEntry) {
localizableStringsIOS[lang] = localizableStringsEntry;
}
locales[lang] = {
...rest,
...otherEntries
};
} else {
locales[lang] = {
...rest,
...android
};
}
}
}
return {
localesMap: locales,
localizableStringsIOS
};
}
async function getLocales(projectRoot, localeJsonPath, forPlatform, lang) {
if (typeof localeJsonPath === 'string') {
try {
return await _jsonFile().default.readAsync(_path().default.join(projectRoot, localeJsonPath));
} catch {
// Add a warning when a json file cannot be parsed.
(0, _warnings().addWarningForPlatform)(forPlatform, `locales.${lang}`, `Failed to parse JSON of locale file for language: ${lang}`, 'https://docs.expo.dev/guides/localization/#translating-app-metadata');
return null;
}
}
// In the off chance that someone defined the locales json in the config, pass it directly to the object.
// We do this to make the types more elegant.
return localeJsonPath;
}
function extractIosLocalizableStrings({
ios,
lang
}) {
const LOCALIZABLE_STR_ENTRY = 'Localizable.strings';
if (!(LOCALIZABLE_STR_ENTRY in ios)) {
return {
localizableStringsEntry: undefined,
otherEntries: ios
};
}
const {
[LOCALIZABLE_STR_ENTRY]: localizableStringsEntry,
...otherEntries
} = ios;
if (!localizableStringsEntry) {
return {
localizableStringsEntry: undefined,
otherEntries
};
}
if (!isStringsMap(localizableStringsEntry)) {
(0, _warnings().addWarningForPlatform)('ios', `locales.${lang}.ios['${LOCALIZABLE_STR_ENTRY}']`, 'Expected a JSON object mapping string keys to string values', 'https://docs.expo.dev/guides/localization/#translating-app-metadata');
return {
localizableStringsEntry: undefined,
otherEntries
};
}
return {
localizableStringsEntry,
otherEntries
};
}
function isStringsMap(value) {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return false;
}
return Object.values(value).every(item => typeof item === 'string');
}
//# sourceMappingURL=locales.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
type LeftBrackets = ['(', '{'];
type RightBrackets = [')', '}'];
type LeftBracket = LeftBrackets[number];
type RightBracket = RightBrackets[number];
type Bracket = LeftBracket | RightBracket;
export declare function findMatchingBracketPosition(contents: string, bracket: Bracket, offset?: number): number;
export {};

View File

@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findMatchingBracketPosition = findMatchingBracketPosition;
function findMatchingBracketPosition(contents, bracket, offset = 0) {
// search first occurrence of `bracket`
const firstBracketPos = contents.indexOf(bracket, offset);
if (firstBracketPos < 0) {
return -1;
}
let stackCounter = 0;
const matchingBracket = getMatchingBracket(bracket);
if (isLeftBracket(bracket)) {
const contentsLength = contents.length;
// search forward
for (let i = firstBracketPos + 1; i < contentsLength; ++i) {
const c = contents[i];
if (c === bracket) {
stackCounter += 1;
} else if (c === matchingBracket) {
if (stackCounter === 0) {
return i;
}
stackCounter -= 1;
}
}
} else {
// search backward
for (let i = firstBracketPos - 1; i >= 0; --i) {
const c = contents[i];
if (c === bracket) {
stackCounter += 1;
} else if (c === matchingBracket) {
if (stackCounter === 0) {
return i;
}
stackCounter -= 1;
}
}
}
return -1;
}
function isLeftBracket(bracket) {
const leftBracketList = ['(', '{'];
return leftBracketList.includes(bracket);
}
function getMatchingBracket(bracket) {
switch (bracket) {
case '(':
return ')';
case ')':
return '(';
case '{':
return '}';
case '}':
return '{';
default:
throw new Error(`Unsupported bracket - ${bracket}`);
}
}
//# sourceMappingURL=matchBrackets.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"matchBrackets.js","names":["findMatchingBracketPosition","contents","bracket","offset","firstBracketPos","indexOf","stackCounter","matchingBracket","getMatchingBracket","isLeftBracket","contentsLength","length","i","c","leftBracketList","includes","Error"],"sources":["../../src/utils/matchBrackets.ts"],"sourcesContent":["type LeftBrackets = ['(', '{'];\ntype RightBrackets = [')', '}'];\n\ntype LeftBracket = LeftBrackets[number];\ntype RightBracket = RightBrackets[number];\ntype Bracket = LeftBracket | RightBracket;\n\nexport function findMatchingBracketPosition(\n contents: string,\n bracket: Bracket,\n offset: number = 0\n): number {\n // search first occurrence of `bracket`\n const firstBracketPos = contents.indexOf(bracket, offset);\n if (firstBracketPos < 0) {\n return -1;\n }\n\n let stackCounter = 0;\n const matchingBracket = getMatchingBracket(bracket);\n\n if (isLeftBracket(bracket)) {\n const contentsLength = contents.length;\n // search forward\n for (let i = firstBracketPos + 1; i < contentsLength; ++i) {\n const c = contents[i];\n if (c === bracket) {\n stackCounter += 1;\n } else if (c === matchingBracket) {\n if (stackCounter === 0) {\n return i;\n }\n stackCounter -= 1;\n }\n }\n } else {\n // search backward\n for (let i = firstBracketPos - 1; i >= 0; --i) {\n const c = contents[i];\n if (c === bracket) {\n stackCounter += 1;\n } else if (c === matchingBracket) {\n if (stackCounter === 0) {\n return i;\n }\n stackCounter -= 1;\n }\n }\n }\n\n return -1;\n}\n\nfunction isLeftBracket(bracket: Bracket): boolean {\n const leftBracketList: readonly Bracket[] = ['(', '{'];\n return leftBracketList.includes(bracket);\n}\n\nfunction getMatchingBracket(bracket: Bracket): Bracket {\n switch (bracket) {\n case '(':\n return ')';\n case ')':\n return '(';\n case '{':\n return '}';\n case '}':\n return '{';\n default:\n throw new Error(`Unsupported bracket - ${bracket}`);\n }\n}\n"],"mappings":";;;;;;AAOO,SAASA,2BAA2BA,CACzCC,QAAgB,EAChBC,OAAgB,EAChBC,MAAc,GAAG,CAAC,EACV;EACR;EACA,MAAMC,eAAe,GAAGH,QAAQ,CAACI,OAAO,CAACH,OAAO,EAAEC,MAAM,CAAC;EACzD,IAAIC,eAAe,GAAG,CAAC,EAAE;IACvB,OAAO,CAAC,CAAC;EACX;EAEA,IAAIE,YAAY,GAAG,CAAC;EACpB,MAAMC,eAAe,GAAGC,kBAAkB,CAACN,OAAO,CAAC;EAEnD,IAAIO,aAAa,CAACP,OAAO,CAAC,EAAE;IAC1B,MAAMQ,cAAc,GAAGT,QAAQ,CAACU,MAAM;IACtC;IACA,KAAK,IAAIC,CAAC,GAAGR,eAAe,GAAG,CAAC,EAAEQ,CAAC,GAAGF,cAAc,EAAE,EAAEE,CAAC,EAAE;MACzD,MAAMC,CAAC,GAAGZ,QAAQ,CAACW,CAAC,CAAC;MACrB,IAAIC,CAAC,KAAKX,OAAO,EAAE;QACjBI,YAAY,IAAI,CAAC;MACnB,CAAC,MAAM,IAAIO,CAAC,KAAKN,eAAe,EAAE;QAChC,IAAID,YAAY,KAAK,CAAC,EAAE;UACtB,OAAOM,CAAC;QACV;QACAN,YAAY,IAAI,CAAC;MACnB;IACF;EACF,CAAC,MAAM;IACL;IACA,KAAK,IAAIM,CAAC,GAAGR,eAAe,GAAG,CAAC,EAAEQ,CAAC,IAAI,CAAC,EAAE,EAAEA,CAAC,EAAE;MAC7C,MAAMC,CAAC,GAAGZ,QAAQ,CAACW,CAAC,CAAC;MACrB,IAAIC,CAAC,KAAKX,OAAO,EAAE;QACjBI,YAAY,IAAI,CAAC;MACnB,CAAC,MAAM,IAAIO,CAAC,KAAKN,eAAe,EAAE;QAChC,IAAID,YAAY,KAAK,CAAC,EAAE;UACtB,OAAOM,CAAC;QACV;QACAN,YAAY,IAAI,CAAC;MACnB;IACF;EACF;EAEA,OAAO,CAAC,CAAC;AACX;AAEA,SAASG,aAAaA,CAACP,OAAgB,EAAW;EAChD,MAAMY,eAAmC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;EACtD,OAAOA,eAAe,CAACC,QAAQ,CAACb,OAAO,CAAC;AAC1C;AAEA,SAASM,kBAAkBA,CAACN,OAAgB,EAAW;EACrD,QAAQA,OAAO;IACb,KAAK,GAAG;MACN,OAAO,GAAG;IACZ,KAAK,GAAG;MACN,OAAO,GAAG;IACZ,KAAK,GAAG;MACN,OAAO,GAAG;IACZ,KAAK,GAAG;MACN,OAAO,GAAG;IACZ;MACE,MAAM,IAAIc,KAAK,CAAC,yBAAyBd,OAAO,EAAE,CAAC;EACvD;AACF","ignoreList":[]}

View File

@@ -0,0 +1,3 @@
export declare function fileExistsAsync(file: string): Promise<boolean>;
export declare function directoryExistsAsync(file: string): Promise<boolean>;
export declare function fileExists(file: string): boolean;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.directoryExistsAsync = directoryExistsAsync;
exports.fileExists = fileExists;
exports.fileExistsAsync = fileExistsAsync;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* A non-failing version of async FS stat.
*
* @param file
*/
async function statAsync(file) {
try {
return await _fs().default.promises.stat(file);
} catch {
return null;
}
}
async function fileExistsAsync(file) {
return (await statAsync(file))?.isFile() ?? false;
}
async function directoryExistsAsync(file) {
return (await statAsync(file))?.isDirectory() ?? false;
}
function fileExists(file) {
try {
return _fs().default.statSync(file).isFile();
} catch {
return false;
}
}
//# sourceMappingURL=modules.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"modules.js","names":["_fs","data","_interopRequireDefault","require","e","__esModule","default","statAsync","file","fs","promises","stat","fileExistsAsync","isFile","directoryExistsAsync","isDirectory","fileExists","statSync"],"sources":["../../src/utils/modules.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * A non-failing version of async FS stat.\n *\n * @param file\n */\nasync function statAsync(file: string): Promise<fs.Stats | null> {\n try {\n return await fs.promises.stat(file);\n } catch {\n return null;\n }\n}\n\nexport async function fileExistsAsync(file: string): Promise<boolean> {\n return (await statAsync(file))?.isFile() ?? false;\n}\n\nexport async function directoryExistsAsync(file: string): Promise<boolean> {\n return (await statAsync(file))?.isDirectory() ?? false;\n}\n\nexport function fileExists(file: string): boolean {\n try {\n return fs.statSync(file).isFile();\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoB,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpB;AACA;AACA;AACA;AACA;AACA,eAAeG,SAASA,CAACC,IAAY,EAA4B;EAC/D,IAAI;IACF,OAAO,MAAMC,aAAE,CAACC,QAAQ,CAACC,IAAI,CAACH,IAAI,CAAC;EACrC,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;AAEO,eAAeI,eAAeA,CAACJ,IAAY,EAAoB;EACpE,OAAO,CAAC,MAAMD,SAAS,CAACC,IAAI,CAAC,GAAGK,MAAM,CAAC,CAAC,IAAI,KAAK;AACnD;AAEO,eAAeC,oBAAoBA,CAACN,IAAY,EAAoB;EACzE,OAAO,CAAC,MAAMD,SAAS,CAACC,IAAI,CAAC,GAAGO,WAAW,CAAC,CAAC,IAAI,KAAK;AACxD;AAEO,SAASC,UAAUA,CAACR,IAAY,EAAW;EAChD,IAAI;IACF,OAAOC,aAAE,CAACQ,QAAQ,CAACT,IAAI,CAAC,CAACK,MAAM,CAAC,CAAC;EACnC,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
/** `lodash.get` */
export declare function get(obj: any, key: string): any;

20
node_modules/@expo/config-plugins/build/utils/obj.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.get = get;
/** `lodash.get` */
function get(obj, key) {
const branches = key.split('.');
let current = obj;
let branch;
while (branch = branches.shift()) {
if (!(branch in current)) {
return undefined;
}
current = current[branch];
}
return current;
}
//# sourceMappingURL=obj.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"obj.js","names":["get","obj","key","branches","split","current","branch","shift","undefined"],"sources":["../../src/utils/obj.ts"],"sourcesContent":["/** `lodash.get` */\nexport function get(obj: any, key: string): any {\n const branches = key.split('.');\n let current: any = obj;\n let branch: string | undefined;\n while ((branch = branches.shift())) {\n if (!(branch in current)) {\n return undefined;\n }\n current = current[branch];\n }\n return current;\n}\n"],"mappings":";;;;;;AAAA;AACO,SAASA,GAAGA,CAACC,GAAQ,EAAEC,GAAW,EAAO;EAC9C,MAAMC,QAAQ,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC;EAC/B,IAAIC,OAAY,GAAGJ,GAAG;EACtB,IAAIK,MAA0B;EAC9B,OAAQA,MAAM,GAAGH,QAAQ,CAACI,KAAK,CAAC,CAAC,EAAG;IAClC,IAAI,EAAED,MAAM,IAAID,OAAO,CAAC,EAAE;MACxB,OAAOG,SAAS;IAClB;IACAH,OAAO,GAAGA,OAAO,CAACC,MAAM,CAAC;EAC3B;EACA,OAAOD,OAAO;AAChB","ignoreList":[]}

View File

@@ -0,0 +1,45 @@
import { ConfigPlugin, StaticPlugin } from '../Plugin.types';
export declare const pluginFileName = "app.plugin.js";
/**
* Resolve the config plugin from a node module or package.
* If the module or package does not include a config plugin, this function throws a `PluginError`.
* The resolution is done in following order:
* 1. Is the reference a relative file path or an import specifier with file path? e.g. `./file.js`, `pkg/file.js` or `@org/pkg/file.js`?
* - Resolve the config plugin as-is
* 2. If the reference a module? e.g. `expo-font`
* - Resolve the root `app.plugin.js` file within the module, e.g. `expo-font/app.plugin.js`
* 3. Does the module have a valid config plugin in the `main` field?
* - Resolve the `main` entry point as config plugin
*/
export declare function resolvePluginForModule(projectRoot: string, pluginReference: string): {
filePath: string;
isPluginFile: boolean;
};
export declare function moduleNameIsDirectFileReference(name: string): boolean;
export declare function moduleNameIsPackageReference(name: string): boolean;
export declare function normalizeStaticPlugin(plugin: StaticPlugin | ConfigPlugin | string): StaticPlugin;
export declare function assertInternalProjectRoot(projectRoot?: string): asserts projectRoot;
export declare function resolveConfigPluginFunction(projectRoot: string, pluginReference: string): ConfigPlugin<unknown>;
export declare function resolveConfigPluginFunctionWithInfo(projectRoot: string, pluginReference: string): {
plugin: ConfigPlugin<unknown>;
pluginFile: string;
pluginReference: string;
isPluginFile: boolean;
};
/**
* - Resolve the exported contents of an Expo config (be it default or module.exports)
* - Assert no promise exports
* - Return config type
* - Serialize config
*
* @param props.plugin plugin results
* @param props.pluginFile plugin file path
* @param props.pluginReference the string used to reference the plugin
* @param props.isPluginFile is file path from the app.plugin.js module root
*/
export declare function resolveConfigPluginExport({ plugin, pluginFile, pluginReference, isPluginFile, }: {
plugin: any;
pluginFile: string;
pluginReference: string;
isPluginFile: boolean;
}): ConfigPlugin<unknown>;

View File

@@ -0,0 +1,224 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertInternalProjectRoot = assertInternalProjectRoot;
exports.moduleNameIsDirectFileReference = moduleNameIsDirectFileReference;
exports.moduleNameIsPackageReference = moduleNameIsPackageReference;
exports.normalizeStaticPlugin = normalizeStaticPlugin;
exports.pluginFileName = void 0;
exports.resolveConfigPluginExport = resolveConfigPluginExport;
exports.resolveConfigPluginFunction = resolveConfigPluginFunction;
exports.resolveConfigPluginFunctionWithInfo = resolveConfigPluginFunctionWithInfo;
exports.resolvePluginForModule = resolvePluginForModule;
function _assert() {
const data = _interopRequireDefault(require("assert"));
_assert = function () {
return data;
};
return data;
}
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _resolveFrom() {
const data = _interopRequireDefault(require("resolve-from"));
_resolveFrom = function () {
return data;
};
return data;
}
function _errors() {
const data = require("./errors");
_errors = function () {
return data;
};
return data;
}
function _modules() {
const data = require("./modules");
_modules = function () {
return data;
};
return data;
}
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// Default plugin entry file name.
const pluginFileName = exports.pluginFileName = 'app.plugin.js';
/**
* Resolve the config plugin from a node module or package.
* If the module or package does not include a config plugin, this function throws a `PluginError`.
* The resolution is done in following order:
* 1. Is the reference a relative file path or an import specifier with file path? e.g. `./file.js`, `pkg/file.js` or `@org/pkg/file.js`?
* - Resolve the config plugin as-is
* 2. If the reference a module? e.g. `expo-font`
* - Resolve the root `app.plugin.js` file within the module, e.g. `expo-font/app.plugin.js`
* 3. Does the module have a valid config plugin in the `main` field?
* - Resolve the `main` entry point as config plugin
*/
function resolvePluginForModule(projectRoot, pluginReference) {
if (moduleNameIsDirectFileReference(pluginReference)) {
// Only resolve `./file.js`, `package/file.js`, `@org/package/file.js`
const pluginScriptFile = _resolveFrom().default.silent(projectRoot, pluginReference);
if (pluginScriptFile) {
return {
// NOTE(cedric): `path.sep` is required here, we are resolving the absolute path, not the plugin reference
isPluginFile: pluginScriptFile.endsWith(path().sep + pluginFileName),
filePath: pluginScriptFile
};
}
} else if (moduleNameIsPackageReference(pluginReference)) {
// Only resolve `package -> package/app.plugin.js`, `@org/package -> @org/package/app.plugin.js`
const pluginPackageFile = _resolveFrom().default.silent(projectRoot, `${pluginReference}/${pluginFileName}`);
if (pluginPackageFile && (0, _modules().fileExists)(pluginPackageFile)) {
return {
isPluginFile: true,
filePath: pluginPackageFile
};
}
// Try to resole the `main` entry as config plugin
const packageMainEntry = _resolveFrom().default.silent(projectRoot, pluginReference);
if (packageMainEntry) {
return {
isPluginFile: false,
filePath: packageMainEntry
};
}
}
throw new (_errors().PluginError)(`Failed to resolve plugin for module "${pluginReference}" relative to "${projectRoot}". Do you have node modules installed?`, 'PLUGIN_NOT_FOUND');
}
// TODO: Test windows
function pathIsFilePath(name) {
// Matches lines starting with: . / ~/
return !!name.match(/^(\.|~\/|\/)/g);
}
function moduleNameIsDirectFileReference(name) {
if (pathIsFilePath(name)) {
return true;
}
const slashCount = name.split('/')?.length;
// Orgs (like @expo/config ) should have more than one slash to be a direct file.
if (name.startsWith('@')) {
return slashCount > 2;
}
// Regular packages should be considered direct reference if they have more than one slash.
return slashCount > 1;
}
function moduleNameIsPackageReference(name) {
const slashCount = name.split('/')?.length;
return name.startsWith('@') ? slashCount === 2 : slashCount === 1;
}
function normalizeStaticPlugin(plugin) {
if (Array.isArray(plugin)) {
(0, _assert().default)(plugin.length > 0 && plugin.length < 3, `Wrong number of arguments provided for static config plugin, expected either 1 or 2, got ${plugin.length}`);
return plugin;
}
return [plugin, undefined];
}
function assertInternalProjectRoot(projectRoot) {
(0, _assert().default)(projectRoot, `Unexpected: Config \`_internal.projectRoot\` isn't defined by expo-cli, this is a bug.`);
}
// Resolve the module function and assert type
function resolveConfigPluginFunction(projectRoot, pluginReference) {
const {
plugin
} = resolveConfigPluginFunctionWithInfo(projectRoot, pluginReference);
return plugin;
}
// Resolve the module function and assert type
function resolveConfigPluginFunctionWithInfo(projectRoot, pluginReference) {
const {
filePath: pluginFile,
isPluginFile
} = resolvePluginForModule(projectRoot, pluginReference);
let result;
try {
result = requirePluginFile(pluginFile);
} catch (error) {
const learnMoreLink = 'Learn more: https://docs.expo.dev/guides/config-plugins/';
let underlyingError;
let stack;
if (error instanceof Error) {
const errorWithCode = error;
underlyingError = `${errorWithCode.message} ${errorWithCode.code ?? ''}`;
stack = errorWithCode.stack;
} else {
underlyingError = String(error);
}
let errorMessage = `Unable to resolve a valid config plugin for ${pluginReference}.\n`;
if (!isPluginFile) {
errorMessage += `• No "${pluginFileName}" file found in ${pluginReference}: config plugins are typically exported from an "${pluginFileName}" file in the package root.\n`;
}
errorMessage += `• main export of ${pluginReference} does not appear to be a config plugin: the following error was thrown when importing ${pluginFile}: ${underlyingError}\n`;
errorMessage += `Verify that ${pluginReference} includes a config plugin. If it does not, then remove the entry from plugins in your app config file. ${learnMoreLink}`;
const pluginError = new (_errors().PluginError)(errorMessage, 'INVALID_PLUGIN_IMPORT');
if (stack) {
pluginError.stack = stack;
}
throw pluginError;
}
const plugin = resolveConfigPluginExport({
plugin: result,
pluginFile,
pluginReference,
isPluginFile
});
return {
plugin,
pluginFile,
pluginReference,
isPluginFile
};
}
/**
* - Resolve the exported contents of an Expo config (be it default or module.exports)
* - Assert no promise exports
* - Return config type
* - Serialize config
*
* @param props.plugin plugin results
* @param props.pluginFile plugin file path
* @param props.pluginReference the string used to reference the plugin
* @param props.isPluginFile is file path from the app.plugin.js module root
*/
function resolveConfigPluginExport({
plugin,
pluginFile,
pluginReference,
isPluginFile
}) {
if (plugin.default != null) {
plugin = plugin.default;
}
if (typeof plugin !== 'function') {
const learnMoreLink = `Learn more: https://docs.expo.dev/guides/config-plugins/`;
// If the plugin reference is a node module, and that node module does not export a function then it probably doesn't have a config plugin.
if (!isPluginFile && !moduleNameIsDirectFileReference(pluginReference)) {
throw new (_errors().PluginError)(`Package "${pluginReference}" does not contain a valid config plugin. Module must export a function from file: ${pluginFile}\n${learnMoreLink}`, 'INVALID_PLUGIN_TYPE');
}
throw new (_errors().PluginError)(`Plugin "${pluginReference}" must export a function from file: ${pluginFile}. ${learnMoreLink}`, 'INVALID_PLUGIN_TYPE');
}
return plugin;
}
function requirePluginFile(filePath) {
try {
return require(filePath);
} catch (error) {
// TODO: Improve error messages
throw error;
}
}
//# sourceMappingURL=plugin-resolver.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
export declare function sortObject<T extends Record<string, any> = Record<string, any>>(obj: T, compareFn?: (a: string, b: string) => number): T;
export declare function sortObjWithOrder<T extends Record<string, any> = Record<string, any>>(obj: T, order: string[]): T;
export declare function sortWithOrder(obj: string[], order: string[]): string[];
export declare const reverseSortString: (a: string, b: string) => 1 | 0 | -1;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reverseSortString = void 0;
exports.sortObjWithOrder = sortObjWithOrder;
exports.sortObject = sortObject;
exports.sortWithOrder = sortWithOrder;
function sortObject(obj, compareFn) {
return Object.keys(obj).sort(compareFn).reduce((acc, key) => ({
...acc,
[key]: obj[key]
}), {});
}
function sortObjWithOrder(obj, order) {
const sorted = sortWithOrder(Object.keys(obj), order);
return sorted.reduce((acc, key) => ({
...acc,
[key]: obj[key]
}), {});
}
function sortWithOrder(obj, order) {
const groupOrder = [...new Set(order.concat(obj))];
const sorted = [];
while (groupOrder.length) {
const key = groupOrder.shift();
const index = obj.indexOf(key);
if (index > -1) {
const [item] = obj.splice(index, 1);
sorted.push(item);
}
}
return sorted;
}
const reverseSortString = (a, b) => {
if (a < b) return 1;
if (a > b) return -1;
return 0;
};
exports.reverseSortString = reverseSortString;
//# sourceMappingURL=sortObject.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sortObject.js","names":["sortObject","obj","compareFn","Object","keys","sort","reduce","acc","key","sortObjWithOrder","order","sorted","sortWithOrder","groupOrder","Set","concat","length","shift","index","indexOf","item","splice","push","reverseSortString","a","b","exports"],"sources":["../../src/utils/sortObject.ts"],"sourcesContent":["export function sortObject<T extends Record<string, any> = Record<string, any>>(\n obj: T,\n compareFn?: (a: string, b: string) => number\n): T {\n return Object.keys(obj)\n .sort(compareFn)\n .reduce(\n (acc, key) => ({\n ...acc,\n [key]: obj[key],\n }),\n {}\n ) as T;\n}\n\nexport function sortObjWithOrder<T extends Record<string, any> = Record<string, any>>(\n obj: T,\n order: string[]\n): T {\n const sorted = sortWithOrder(Object.keys(obj), order);\n\n return sorted.reduce(\n (acc, key) => ({\n ...acc,\n [key]: obj[key],\n }),\n {}\n ) as T;\n}\n\nexport function sortWithOrder(obj: string[], order: string[]): string[] {\n const groupOrder = [...new Set(order.concat(obj))];\n const sorted: string[] = [];\n\n while (groupOrder.length) {\n const key = groupOrder.shift()!;\n const index = obj.indexOf(key);\n if (index > -1) {\n const [item] = obj.splice(index, 1);\n sorted.push(item);\n }\n }\n\n return sorted;\n}\n\nexport const reverseSortString = (a: string, b: string) => {\n if (a < b) return 1;\n if (a > b) return -1;\n return 0;\n};\n"],"mappings":";;;;;;;;;AAAO,SAASA,UAAUA,CACxBC,GAAM,EACNC,SAA4C,EACzC;EACH,OAAOC,MAAM,CAACC,IAAI,CAACH,GAAG,CAAC,CACpBI,IAAI,CAACH,SAAS,CAAC,CACfI,MAAM,CACL,CAACC,GAAG,EAAEC,GAAG,MAAM;IACb,GAAGD,GAAG;IACN,CAACC,GAAG,GAAGP,GAAG,CAACO,GAAG;EAChB,CAAC,CAAC,EACF,CAAC,CACH,CAAC;AACL;AAEO,SAASC,gBAAgBA,CAC9BR,GAAM,EACNS,KAAe,EACZ;EACH,MAAMC,MAAM,GAAGC,aAAa,CAACT,MAAM,CAACC,IAAI,CAACH,GAAG,CAAC,EAAES,KAAK,CAAC;EAErD,OAAOC,MAAM,CAACL,MAAM,CAClB,CAACC,GAAG,EAAEC,GAAG,MAAM;IACb,GAAGD,GAAG;IACN,CAACC,GAAG,GAAGP,GAAG,CAACO,GAAG;EAChB,CAAC,CAAC,EACF,CAAC,CACH,CAAC;AACH;AAEO,SAASI,aAAaA,CAACX,GAAa,EAAES,KAAe,EAAY;EACtE,MAAMG,UAAU,GAAG,CAAC,GAAG,IAAIC,GAAG,CAACJ,KAAK,CAACK,MAAM,CAACd,GAAG,CAAC,CAAC,CAAC;EAClD,MAAMU,MAAgB,GAAG,EAAE;EAE3B,OAAOE,UAAU,CAACG,MAAM,EAAE;IACxB,MAAMR,GAAG,GAAGK,UAAU,CAACI,KAAK,CAAC,CAAE;IAC/B,MAAMC,KAAK,GAAGjB,GAAG,CAACkB,OAAO,CAACX,GAAG,CAAC;IAC9B,IAAIU,KAAK,GAAG,CAAC,CAAC,EAAE;MACd,MAAM,CAACE,IAAI,CAAC,GAAGnB,GAAG,CAACoB,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC;MACnCP,MAAM,CAACW,IAAI,CAACF,IAAI,CAAC;IACnB;EACF;EAEA,OAAOT,MAAM;AACf;AAEO,MAAMY,iBAAiB,GAAGA,CAACC,CAAS,EAAEC,CAAS,KAAK;EACzD,IAAID,CAAC,GAAGC,CAAC,EAAE,OAAO,CAAC;EACnB,IAAID,CAAC,GAAGC,CAAC,EAAE,OAAO,CAAC,CAAC;EACpB,OAAO,CAAC;AACV,CAAC;AAACC,OAAA,CAAAH,iBAAA,GAAAA,iBAAA","ignoreList":[]}

View File

@@ -0,0 +1,2 @@
export declare function isValidAndroidAssetName(assetNameWithoutExtension: string): boolean;
export declare function assertValidAndroidAssetName(assetNameWithoutExtension: string, tag?: string): void;

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertValidAndroidAssetName = assertValidAndroidAssetName;
exports.isValidAndroidAssetName = isValidAndroidAssetName;
// this is an approximation of the android resource name rules
const validPattern = /^[a-z][a-z0-9_]*$/;
const blockList = ['abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default', 'if', 'package', 'synchronized', 'boolean', 'do', 'goto', 'private', 'this', 'break', 'double', 'implements', 'protected', 'throw', 'byte', 'else', 'import', 'public', 'throws', 'case', 'enum', 'instanceof', 'return', 'transient', 'catch', 'extends', 'int', 'short', 'try', 'char', 'final', 'interface', 'static', 'void', 'class', 'finally', 'long', 'strictfp', 'volatile', 'const', 'float', 'native', 'super', 'while', '_'];
function isValidAndroidAssetName(assetNameWithoutExtension) {
return validPattern.test(assetNameWithoutExtension) && !blockList.includes(assetNameWithoutExtension);
}
function assertValidAndroidAssetName(assetNameWithoutExtension, tag) {
if (!isValidAndroidAssetName(assetNameWithoutExtension)) {
const prefix = tag ? `[${tag}] ` : '';
throw new Error(`${prefix}Resource name "${assetNameWithoutExtension}" is not valid. Android resource names must start with a letter and contain only ` + `lowercase a-z, 0-9, or underscore characters. Additionally, Java reserved words are not allowed.`);
}
}
//# sourceMappingURL=validations.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validations.js","names":["validPattern","blockList","isValidAndroidAssetName","assetNameWithoutExtension","test","includes","assertValidAndroidAssetName","tag","prefix","Error"],"sources":["../../src/utils/validations.ts"],"sourcesContent":["// this is an approximation of the android resource name rules\nconst validPattern = /^[a-z][a-z0-9_]*$/;\n\nconst blockList = [\n 'abstract',\n 'continue',\n 'for',\n 'new',\n 'switch',\n 'assert',\n 'default',\n 'if',\n 'package',\n 'synchronized',\n 'boolean',\n 'do',\n 'goto',\n 'private',\n 'this',\n 'break',\n 'double',\n 'implements',\n 'protected',\n 'throw',\n 'byte',\n 'else',\n 'import',\n 'public',\n 'throws',\n 'case',\n 'enum',\n 'instanceof',\n 'return',\n 'transient',\n 'catch',\n 'extends',\n 'int',\n 'short',\n 'try',\n 'char',\n 'final',\n 'interface',\n 'static',\n 'void',\n 'class',\n 'finally',\n 'long',\n 'strictfp',\n 'volatile',\n 'const',\n 'float',\n 'native',\n 'super',\n 'while',\n '_',\n];\n\nexport function isValidAndroidAssetName(assetNameWithoutExtension: string) {\n return (\n validPattern.test(assetNameWithoutExtension) && !blockList.includes(assetNameWithoutExtension)\n );\n}\n\nexport function assertValidAndroidAssetName(assetNameWithoutExtension: string, tag?: string) {\n if (!isValidAndroidAssetName(assetNameWithoutExtension)) {\n const prefix = tag ? `[${tag}] ` : '';\n throw new Error(\n `${prefix}Resource name \"${assetNameWithoutExtension}\" is not valid. Android resource names must start with a letter and contain only ` +\n `lowercase a-z, 0-9, or underscore characters. Additionally, Java reserved words are not allowed.`\n );\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA,MAAMA,YAAY,GAAG,mBAAmB;AAExC,MAAMC,SAAS,GAAG,CAChB,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,cAAc,EACd,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,KAAK,EACL,OAAO,EACP,KAAK,EACL,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,GAAG,CACJ;AAEM,SAASC,uBAAuBA,CAACC,yBAAiC,EAAE;EACzE,OACEH,YAAY,CAACI,IAAI,CAACD,yBAAyB,CAAC,IAAI,CAACF,SAAS,CAACI,QAAQ,CAACF,yBAAyB,CAAC;AAElG;AAEO,SAASG,2BAA2BA,CAACH,yBAAiC,EAAEI,GAAY,EAAE;EAC3F,IAAI,CAACL,uBAAuB,CAACC,yBAAyB,CAAC,EAAE;IACvD,MAAMK,MAAM,GAAGD,GAAG,GAAG,IAAIA,GAAG,IAAI,GAAG,EAAE;IACrC,MAAM,IAAIE,KAAK,CACb,GAAGD,MAAM,kBAAkBL,yBAAyB,mFAAmF,GACrI,kGACJ,CAAC;EACH;AACF","ignoreList":[]}

View File

@@ -0,0 +1,26 @@
import { ModPlatform } from '../Plugin.types';
/**
* Log a warning that doesn't disrupt the spinners.
*
* ```sh
* » android: android.package: property is invalid https://expo.fyi/android-package
* ```
*
* @param property Name of the config property that triggered the warning (best-effort)
* @param text Main warning message
* @param link Useful link to resources related to the warning
*/
export declare function addWarningAndroid(property: string, text: string, link?: string): void;
/**
* Log a warning that doesn't disrupt the spinners.
*
* ```sh
* » ios: ios.bundleIdentifier: property is invalid https://expo.fyi/bundle-identifier
* ```
*
* @param property Name of the config property that triggered the warning (best-effort)
* @param text Main warning message
* @param link Useful link to resources related to the warning
*/
export declare function addWarningIOS(property: string, text: string, link?: string): void;
export declare function addWarningForPlatform(platform: ModPlatform & string, property: string, text: string, link?: string): void;

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addWarningAndroid = addWarningAndroid;
exports.addWarningForPlatform = addWarningForPlatform;
exports.addWarningIOS = addWarningIOS;
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* Log a warning that doesn't disrupt the spinners.
*
* ```sh
* » android: android.package: property is invalid https://expo.fyi/android-package
* ```
*
* @param property Name of the config property that triggered the warning (best-effort)
* @param text Main warning message
* @param link Useful link to resources related to the warning
*/
function addWarningAndroid(property, text, link) {
console.warn(formatWarning('android', property, text, link));
}
/**
* Log a warning that doesn't disrupt the spinners.
*
* ```sh
* » ios: ios.bundleIdentifier: property is invalid https://expo.fyi/bundle-identifier
* ```
*
* @param property Name of the config property that triggered the warning (best-effort)
* @param text Main warning message
* @param link Useful link to resources related to the warning
*/
function addWarningIOS(property, text, link) {
console.warn(formatWarning('ios', property, text, link));
}
function addWarningForPlatform(platform, property, text, link) {
console.warn(formatWarning(platform, property, text, link));
}
function formatWarning(platform, property, warning, link) {
return _chalk().default.yellow`${'» ' + _chalk().default.bold(platform)}: ${property}: ${warning}${link ? _chalk().default.gray(' ' + link) : ''}`;
}
//# sourceMappingURL=warnings.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"warnings.js","names":["_chalk","data","_interopRequireDefault","require","e","__esModule","default","addWarningAndroid","property","text","link","console","warn","formatWarning","addWarningIOS","addWarningForPlatform","platform","warning","chalk","yellow","bold","gray"],"sources":["../../src/utils/warnings.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { ModPlatform } from '../Plugin.types';\n\n/**\n * Log a warning that doesn't disrupt the spinners.\n *\n * ```sh\n * » android: android.package: property is invalid https://expo.fyi/android-package\n * ```\n *\n * @param property Name of the config property that triggered the warning (best-effort)\n * @param text Main warning message\n * @param link Useful link to resources related to the warning\n */\nexport function addWarningAndroid(property: string, text: string, link?: string) {\n console.warn(formatWarning('android', property, text, link));\n}\n\n/**\n * Log a warning that doesn't disrupt the spinners.\n *\n * ```sh\n * » ios: ios.bundleIdentifier: property is invalid https://expo.fyi/bundle-identifier\n * ```\n *\n * @param property Name of the config property that triggered the warning (best-effort)\n * @param text Main warning message\n * @param link Useful link to resources related to the warning\n */\nexport function addWarningIOS(property: string, text: string, link?: string) {\n console.warn(formatWarning('ios', property, text, link));\n}\n\nexport function addWarningForPlatform(\n platform: ModPlatform & string,\n property: string,\n text: string,\n link?: string\n) {\n console.warn(formatWarning(platform, property, text, link));\n}\n\nfunction formatWarning(platform: string, property: string, warning: string, link?: string) {\n return chalk.yellow`${'» ' + chalk.bold(platform)}: ${property}: ${warning}${\n link ? chalk.gray(' ' + link) : ''\n }`;\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,iBAAiBA,CAACC,QAAgB,EAAEC,IAAY,EAAEC,IAAa,EAAE;EAC/EC,OAAO,CAACC,IAAI,CAACC,aAAa,CAAC,SAAS,EAAEL,QAAQ,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,aAAaA,CAACN,QAAgB,EAAEC,IAAY,EAAEC,IAAa,EAAE;EAC3EC,OAAO,CAACC,IAAI,CAACC,aAAa,CAAC,KAAK,EAAEL,QAAQ,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAC;AAC1D;AAEO,SAASK,qBAAqBA,CACnCC,QAA8B,EAC9BR,QAAgB,EAChBC,IAAY,EACZC,IAAa,EACb;EACAC,OAAO,CAACC,IAAI,CAACC,aAAa,CAACG,QAAQ,EAAER,QAAQ,EAAEC,IAAI,EAAEC,IAAI,CAAC,CAAC;AAC7D;AAEA,SAASG,aAAaA,CAACG,QAAgB,EAAER,QAAgB,EAAES,OAAe,EAAEP,IAAa,EAAE;EACzF,OAAOQ,gBAAK,CAACC,MAAM,GAAG,IAAI,GAAGD,gBAAK,CAACE,IAAI,CAACJ,QAAQ,CAAC,KAAKR,QAAQ,KAAKS,OAAO,GACxEP,IAAI,GAAGQ,gBAAK,CAACG,IAAI,CAAC,GAAG,GAAGX,IAAI,CAAC,GAAG,EAAE,EAClC;AACJ","ignoreList":[]}