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,8 @@
import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
export declare function getBareAndroidSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getBareIosSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getPackageJsonScriptSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getGitIgnoreSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>;
export declare function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>;
export declare function getCoreAutolinkingSourcesFromExpoIos(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>;

216
node_modules/@expo/fingerprint/build/sourcer/Bare.js generated vendored Normal file
View File

@@ -0,0 +1,216 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBareAndroidSourcesAsync = getBareAndroidSourcesAsync;
exports.getBareIosSourcesAsync = getBareIosSourcesAsync;
exports.getPackageJsonScriptSourcesAsync = getPackageJsonScriptSourcesAsync;
exports.getGitIgnoreSourcesAsync = getGitIgnoreSourcesAsync;
exports.getCoreAutolinkingSourcesFromRncCliAsync = getCoreAutolinkingSourcesFromRncCliAsync;
exports.getCoreAutolinkingSourcesFromExpoAndroid = getCoreAutolinkingSourcesFromExpoAndroid;
exports.getCoreAutolinkingSourcesFromExpoIos = getCoreAutolinkingSourcesFromExpoIos;
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
const assert_1 = __importDefault(require("assert"));
const chalk_1 = __importDefault(require("chalk"));
const node_process_1 = __importDefault(require("node:process"));
const path_1 = __importDefault(require("path"));
const resolve_from_1 = __importDefault(require("resolve-from"));
const ExpoResolver_1 = require("../ExpoResolver");
const SourceSkips_1 = require("./SourceSkips");
const Utils_1 = require("./Utils");
const Path_1 = require("../utils/Path");
const debug = require('debug')('expo:fingerprint:sourcer:Bare');
async function getBareAndroidSourcesAsync(projectRoot, options) {
if (options.platforms.includes('android')) {
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'android', 'bareNativeDir');
if (result != null) {
debug(`Adding bare native dir - ${chalk_1.default.dim('android')}`);
return [result];
}
}
return [];
}
async function getBareIosSourcesAsync(projectRoot, options) {
if (options.platforms.includes('ios')) {
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'ios', 'bareNativeDir');
if (result != null) {
debug(`Adding bare native dir - ${chalk_1.default.dim('ios')}`);
return [result];
}
}
return [];
}
async function getPackageJsonScriptSourcesAsync(projectRoot, options) {
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonScriptsAll) {
return [];
}
let packageJson;
try {
packageJson = require((0, resolve_from_1.default)(path_1.default.resolve(projectRoot), './package.json'));
}
catch (e) {
debug(`Unable to read package.json from ${path_1.default.resolve(projectRoot)}/package.json: ` + e);
return [];
}
const results = [];
if (packageJson.scripts) {
debug(`Adding package.json contents - ${chalk_1.default.dim('scripts')}`);
const id = 'packageJson:scripts';
results.push({
type: 'contents',
id,
contents: normalizePackageJsonScriptSources(packageJson.scripts, options),
reasons: [id],
});
}
return results;
}
async function getGitIgnoreSourcesAsync(projectRoot, options) {
if (options.sourceSkips & SourceSkips_1.SourceSkips.GitIgnore) {
return [];
}
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, '.gitignore', 'bareGitIgnore');
if (result != null) {
debug(`Adding file - ${chalk_1.default.dim('.gitignore')}`);
return [result];
}
return [];
}
async function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot, options, useRNCoreAutolinkingFromExpo) {
if (useRNCoreAutolinkingFromExpo === true) {
return [];
}
try {
const { stdout } = await (0, spawn_async_1.default)('npx', ['react-native', 'config'], { cwd: projectRoot });
const config = JSON.parse(stdout);
const results = await parseCoreAutolinkingSourcesAsync({
config,
contentsId: 'rncoreAutolinkingConfig',
reasons: ['rncoreAutolinking'],
});
return results;
}
catch (e) {
debug(chalk_1.default.red(`Error adding react-native core autolinking sources.\n${e}`));
return [];
}
}
async function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot, options, useRNCoreAutolinkingFromExpo) {
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('android')) {
return [];
}
const args = [
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
'react-native-config',
'--json',
'--platform',
'android',
];
try {
const { stdout } = await (0, spawn_async_1.default)('node', args, { cwd: projectRoot });
const config = JSON.parse(stdout);
const results = await parseCoreAutolinkingSourcesAsync({
config,
contentsId: 'rncoreAutolinkingConfig:android',
reasons: ['rncoreAutolinkingAndroid'],
platform: 'android',
});
return results;
}
catch (e) {
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for android.\n${e}`));
return [];
}
}
async function getCoreAutolinkingSourcesFromExpoIos(projectRoot, options, useRNCoreAutolinkingFromExpo) {
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('ios')) {
return [];
}
try {
const { stdout } = await (0, spawn_async_1.default)('node', [
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
'react-native-config',
'--json',
'--platform',
'ios',
], { cwd: projectRoot });
const config = JSON.parse(stdout);
const results = await parseCoreAutolinkingSourcesAsync({
config,
contentsId: 'rncoreAutolinkingConfig:ios',
reasons: ['rncoreAutolinkingIos'],
platform: 'ios',
});
return results;
}
catch (e) {
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for ios.\n${e}`));
return [];
}
}
async function parseCoreAutolinkingSourcesAsync({ config, reasons, contentsId, platform, }) {
const logTag = platform
? `react-native core autolinking dir for ${platform}`
: 'react-native core autolinking dir';
const results = [];
const { root } = config;
const autolinkingConfig = {};
for (const [depName, depData] of Object.entries(config.dependencies)) {
try {
stripRncoreAutolinkingAbsolutePaths(depData, root);
const filePath = (0, Path_1.toPosixPath)(depData.root);
debug(`Adding ${logTag} - ${chalk_1.default.dim(filePath)}`);
results.push({ type: 'dir', filePath, reasons });
autolinkingConfig[depName] = depData;
}
catch (e) {
debug(chalk_1.default.red(`Error adding ${logTag} - ${depName}.\n${e}`));
}
}
results.push({
type: 'contents',
id: contentsId,
contents: JSON.stringify(autolinkingConfig),
reasons,
});
return results;
}
function stripRncoreAutolinkingAbsolutePaths(dependency, root) {
(0, assert_1.default)(dependency.root);
const dependencyRoot = dependency.root;
const cmakeDepRoot = node_process_1.default.platform === 'win32' ? dependencyRoot.replace(/\\/g, '/') : dependencyRoot;
dependency.root = (0, Path_1.toPosixPath)(path_1.default.relative(root, dependencyRoot));
for (const platformData of Object.values(dependency.platforms)) {
for (const [key, value] of Object.entries(platformData ?? {})) {
let newValue;
if (node_process_1.default.platform === 'win32' &&
['cmakeListsPath', 'cxxModuleCMakeListsPath'].includes(key)) {
// CMake paths on Windows are serving in slashes,
// we have to check startsWith with the same slashes.
newValue = value?.startsWith?.(cmakeDepRoot)
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
: value;
}
else {
newValue = value?.startsWith?.(dependencyRoot)
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
: value;
}
platformData[key] = newValue;
}
}
}
function normalizePackageJsonScriptSources(scripts, options) {
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun) {
// Replicate the behavior of `expo prebuild`
if (!scripts.android?.includes('run') || scripts.android === 'expo run:android') {
delete scripts.android;
}
if (!scripts.ios?.includes('run') || scripts.ios === 'expo run:ios') {
delete scripts.ios;
}
}
return JSON.stringify(scripts);
}
//# sourceMappingURL=Bare.js.map

File diff suppressed because one or more lines are too long

23
node_modules/@expo/fingerprint/build/sourcer/Expo.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import type { ExpoConfig, ProjectConfig } from 'expo/config';
import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
export declare function getExpoConfigSourcesAsync(projectRoot: string, config: ProjectConfig | null, loadedModules: string[] | null, options: NormalizedOptions): Promise<HashSource[]>;
export declare function createHashSourceExternalFileAsync({ projectRoot, file, reason, }: {
projectRoot: string;
file: string;
reason: string;
}): Promise<HashSource | null>;
export declare function getEasBuildSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getExpoAutolinkingAndroidSourcesAsync(projectRoot: string, options: NormalizedOptions, expoAutolinkingVersion: string): Promise<HashSource[]>;
/**
* Gets the patch sources for the `patch-project`.
*/
export declare function getExpoCNGPatchSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getExpoAutolinkingIosSourcesAsync(projectRoot: string, options: NormalizedOptions, expoAutolinkingVersion: string): Promise<HashSource[]>;
/**
* Sort the expo-modules-autolinking android config to make it stable from hashing.
*/
export declare function sortExpoAutolinkingAndroidConfig(config: Record<string, any>): Record<string, any>;
/**
* Get the props for a config-plugin
*/
export declare function getConfigPluginProps<Props>(config: ExpoConfig, pluginName: string): Props | null;

339
node_modules/@expo/fingerprint/build/sourcer/Expo.js generated vendored Normal file
View File

@@ -0,0 +1,339 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExpoConfigSourcesAsync = getExpoConfigSourcesAsync;
exports.createHashSourceExternalFileAsync = createHashSourceExternalFileAsync;
exports.getEasBuildSourcesAsync = getEasBuildSourcesAsync;
exports.getExpoAutolinkingAndroidSourcesAsync = getExpoAutolinkingAndroidSourcesAsync;
exports.getExpoCNGPatchSourcesAsync = getExpoCNGPatchSourcesAsync;
exports.getExpoAutolinkingIosSourcesAsync = getExpoAutolinkingIosSourcesAsync;
exports.sortExpoAutolinkingAndroidConfig = sortExpoAutolinkingAndroidConfig;
exports.getConfigPluginProps = getConfigPluginProps;
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
const semver_1 = __importDefault(require("semver"));
const ExpoResolver_1 = require("../ExpoResolver");
const SourceSkips_1 = require("./SourceSkips");
const Utils_1 = require("./Utils");
const Path_1 = require("../utils/Path");
const debug = require('debug')('expo:fingerprint:sourcer:Expo');
async function getExpoConfigSourcesAsync(projectRoot, config, loadedModules, options) {
if (options.sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAll) {
return [];
}
if (config == null) {
return [];
}
const results = [];
let expoConfig = normalizeExpoConfig(config.exp, projectRoot, options);
// external files in config
const isAndroid = options.platforms.includes('android');
const isIos = options.platforms.includes('ios');
const splashScreenPluginProps = getConfigPluginProps(expoConfig, 'expo-splash-screen');
const externalFiles = [
// icons
expoConfig.icon,
isAndroid ? expoConfig.android?.icon : undefined,
...(isIos ? collectIosIcons(expoConfig.ios?.icon) : []),
isAndroid ? expoConfig.android?.adaptiveIcon?.foregroundImage : undefined,
isAndroid ? expoConfig.android?.adaptiveIcon?.backgroundImage : undefined,
// expo-splash-screen images
splashScreenPluginProps?.image,
splashScreenPluginProps?.dark?.image,
isAndroid ? splashScreenPluginProps?.android?.image : undefined,
isAndroid ? splashScreenPluginProps?.android?.mdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.hdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.xhdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.xxhdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.xxxhdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.image : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.mdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.hdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.xhdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.xxhdpi : undefined,
isAndroid ? splashScreenPluginProps?.android?.dark?.xxxhdpi : undefined,
isIos ? splashScreenPluginProps?.ios?.image : undefined,
isIos ? splashScreenPluginProps?.ios?.tabletImage : undefined,
isIos ? splashScreenPluginProps?.ios?.dark?.image : undefined,
isIos ? splashScreenPluginProps?.ios?.dark?.tabletImage : undefined,
// legacy splash images
expoConfig.splash?.image,
isAndroid ? expoConfig.android?.splash?.image : undefined,
isAndroid ? expoConfig.android?.splash?.mdpi : undefined,
isAndroid ? expoConfig.android?.splash?.hdpi : undefined,
isAndroid ? expoConfig.android?.splash?.xhdpi : undefined,
isAndroid ? expoConfig.android?.splash?.xxhdpi : undefined,
isAndroid ? expoConfig.android?.splash?.xxxhdpi : undefined,
isIos ? expoConfig.ios?.splash?.image : undefined,
isIos ? expoConfig.ios?.splash?.tabletImage : undefined,
// google service files
isAndroid ? expoConfig.android?.googleServicesFile : undefined,
isIos ? expoConfig.ios?.googleServicesFile : undefined,
]
.filter((file) => Boolean(file))
.map((filePath) => ensureRelativePath(projectRoot, filePath));
const externalFileSources = (await Promise.all(externalFiles.map((file) => createHashSourceExternalFileAsync({ projectRoot, file, reason: 'expoConfigExternalFile' })))).filter(Boolean);
results.push(...externalFileSources);
expoConfig = postUpdateExpoConfig(expoConfig, projectRoot);
results.push({
type: 'contents',
id: 'expoConfig',
contents: (0, Utils_1.stringifyJsonSorted)(expoConfig),
reasons: ['expoConfig'],
});
// config plugins
const configPluginModules = (loadedModules ?? []).map((modulePath) => ({
type: 'file',
filePath: (0, Path_1.toPosixPath)(modulePath),
reasons: ['expoConfigPlugins'],
}));
results.push(...configPluginModules);
return results;
}
function normalizeExpoConfig(config, projectRoot, options) {
// Deep clone by JSON.parse/stringify that assumes the config is serializable.
const normalizedConfig = JSON.parse(JSON.stringify(config));
const { sourceSkips } = options;
delete normalizedConfig._internal;
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigVersions) {
delete normalizedConfig.version;
delete normalizedConfig.android?.versionCode;
delete normalizedConfig.ios?.buildNumber;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigRuntimeVersionIfString) {
if (typeof normalizedConfig.runtimeVersion === 'string') {
delete normalizedConfig.runtimeVersion;
}
if (typeof normalizedConfig.android?.runtimeVersion === 'string') {
delete normalizedConfig.android.runtimeVersion;
}
if (typeof normalizedConfig.ios?.runtimeVersion === 'string') {
delete normalizedConfig.ios.runtimeVersion;
}
if (typeof normalizedConfig.web?.runtimeVersion === 'string') {
delete normalizedConfig.web.runtimeVersion;
}
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigNames) {
normalizedConfig.name = '';
delete normalizedConfig.description;
delete normalizedConfig.web?.name;
delete normalizedConfig.web?.shortName;
delete normalizedConfig.web?.description;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAndroidPackage) {
delete normalizedConfig.android?.package;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigIosBundleIdentifier) {
delete normalizedConfig.ios?.bundleIdentifier;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigSchemes) {
delete normalizedConfig.scheme;
normalizedConfig.slug = '';
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigEASProject) {
delete normalizedConfig.owner;
delete normalizedConfig?.extra?.eas;
delete normalizedConfig?.updates?.url;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAssets) {
delete normalizedConfig.icon;
delete normalizedConfig.splash;
delete normalizedConfig.android?.adaptiveIcon;
delete normalizedConfig.android?.icon;
delete normalizedConfig.android?.splash;
delete normalizedConfig.ios?.icon;
delete normalizedConfig.ios?.splash;
delete normalizedConfig.web?.favicon;
delete normalizedConfig.web?.splash;
}
if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigExtraSection) {
delete normalizedConfig.extra;
}
return (0, Utils_1.relativizeJsonPaths)(normalizedConfig, projectRoot);
}
/**
* Gives the last chance to modify the ExpoConfig.
* For example, we can remove some fields that are already included in the fingerprint.
*/
function postUpdateExpoConfig(config, projectRoot) {
// The config is already a clone, so we can modify it in place for performance.
// googleServicesFile may contain absolute paths on EAS with file-based secrets.
// Given we include googleServicesFile as external files already, we can remove it from the config.
delete config.android?.googleServicesFile;
delete config.ios?.googleServicesFile;
return config;
}
/**
* Collect iOS icon to flattened file paths.
*/
function collectIosIcons(icon) {
if (icon == null) {
return [];
}
if (typeof icon === 'string') {
return [icon];
}
return [icon.light, icon.dark, icon.tinted].filter((file) => Boolean(file));
}
/**
* The filePath in config could be relative (`./assets/icon.png`, `assets/icon.png`) or even absolute.
* We need to normalize the path and return as relative path without `./` prefix.
*/
function ensureRelativePath(projectRoot, filePath) {
const absolutePath = path_1.default.resolve(projectRoot, filePath);
return path_1.default.relative(projectRoot, absolutePath);
}
async function createHashSourceExternalFileAsync({ projectRoot, file, reason, }) {
const hashSource = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, reason);
if (hashSource) {
debug(`Adding config external file - ${chalk_1.default.dim(file)}`);
if (hashSource.type === 'file' || hashSource.type === 'dir') {
// We include the expo config contents in the fingerprint,
// the `filePath` hashing for the external files is not necessary.
// Especially people using EAS environment variables for the google service files,
// the `filePath` will be different between local and remote builds.
// We use a fixed override hash key and basically ignore the `filePath` hashing.
hashSource.overrideHashKey = 'expoConfigExternalFile:contentsOnly';
}
}
return hashSource;
}
async function getEasBuildSourcesAsync(projectRoot, options) {
const files = ['eas.json', '.easignore'];
const results = (await Promise.all(files.map(async (file) => {
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, 'easBuild');
if (result != null) {
debug(`Adding eas file - ${chalk_1.default.dim(file)}`);
}
return result;
}))).filter(Boolean);
return results;
}
async function getExpoAutolinkingAndroidSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
if (!options.platforms.includes('android')) {
return [];
}
try {
const reasons = ['expoAutolinkingAndroid'];
const results = [];
const { stdout } = await (0, spawn_async_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', 'android', '--json'], { cwd: projectRoot });
const config = sortExpoAutolinkingAndroidConfig(JSON.parse(stdout));
for (const module of config.modules) {
for (const project of module.projects) {
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, project.sourceDir));
project.sourceDir = filePath; // use relative path for the dir
debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
results.push({ type: 'dir', filePath, reasons });
// `aarProjects` is present in project starting from SDK 53+.
if (project.aarProjects) {
for (const aarProject of project.aarProjects) {
// use relative path for aarProject fields
aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, aarProject.aarFilePath));
aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, aarProject.projectDir));
}
}
if (typeof project.shouldUsePublicationScriptPath === 'string') {
project.shouldUsePublicationScriptPath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, project.shouldUsePublicationScriptPath));
}
}
if (module.plugins) {
for (const plugin of module.plugins) {
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, plugin.sourceDir));
plugin.sourceDir = filePath; // use relative path for the dir
debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
results.push({ type: 'dir', filePath, reasons });
}
}
// Backward compatibility for SDK versions earlier than 53
if (module.aarProjects) {
for (const aarProject of module.aarProjects) {
// use relative path for aarProject fields
aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, aarProject.aarFilePath));
aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, aarProject.projectDir));
}
}
}
results.push({
type: 'contents',
id: 'expoAutolinkingConfig:android',
contents: JSON.stringify(config),
reasons,
});
return results;
}
catch {
return [];
}
}
/**
* Gets the patch sources for the `patch-project`.
*/
async function getExpoCNGPatchSourcesAsync(projectRoot, options) {
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'cng-patches', 'expoCNGPatches');
if (result != null) {
debug(`Adding dir - ${chalk_1.default.dim('cng-patches')}`);
return [result];
}
return [];
}
async function getExpoAutolinkingIosSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
if (!options.platforms.includes('ios')) {
return [];
}
// expo-modules-autolinking 1.10.0 added support for apple platform
const platform = semver_1.default.lt(expoAutolinkingVersion, '1.10.0') ? 'ios' : 'apple';
try {
const reasons = ['expoAutolinkingIos'];
const results = [];
const { stdout } = await (0, spawn_async_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', platform, '--json'], { cwd: projectRoot });
const config = JSON.parse(stdout);
for (const module of config.modules) {
for (const pod of module.pods) {
const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, pod.podspecDir));
pod.podspecDir = filePath; // use relative path for the dir
debug(`Adding expo-modules-autolinking ios dir - ${chalk_1.default.dim(filePath)}`);
results.push({ type: 'dir', filePath, reasons });
}
}
results.push({
type: 'contents',
id: 'expoAutolinkingConfig:ios',
contents: JSON.stringify(config),
reasons,
});
return results;
}
catch {
return [];
}
}
/**
* Sort the expo-modules-autolinking android config to make it stable from hashing.
*/
function sortExpoAutolinkingAndroidConfig(config) {
for (const module of config.modules) {
// Sort the projects by project.name
module.projects.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
}
return config;
}
/**
* Get the props for a config-plugin
*/
function getConfigPluginProps(config, pluginName) {
const plugin = (config.plugins ?? []).find((plugin) => {
if (Array.isArray(plugin)) {
return plugin[0] === pluginName;
}
return plugin === pluginName;
});
if (Array.isArray(plugin)) {
return (plugin[1] ?? null);
}
return null;
}
//# sourceMappingURL=Expo.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
interface PackageSourcerParams {
/**
* The package name.
*
* Note that the package should be a direct dependency or devDependency of the project.
* Otherwise on pnpm isolated mode the resolution will fail.
*/
packageName: string;
/**
* Hashing **package.json** file for the package rather than the entire directory.
* This is useful when the package contains a lot of files.
*/
packageJsonOnly: boolean;
}
export declare function getDefaultPackageSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;
export declare function getPackageSourceAsync(projectRoot: string, params: PackageSourcerParams): Promise<HashSource | null>;
export {};

View File

@@ -0,0 +1,41 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultPackageSourcesAsync = getDefaultPackageSourcesAsync;
exports.getPackageSourceAsync = getPackageSourceAsync;
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
const resolve_from_1 = __importDefault(require("resolve-from"));
const Utils_1 = require("./Utils");
const debug = require('debug')('expo:fingerprint:sourcer:Packages');
const DEFAULT_PACKAGES = [
{
packageName: 'react-native',
packageJsonOnly: true,
},
];
async function getDefaultPackageSourcesAsync(projectRoot, options) {
const results = await Promise.all(DEFAULT_PACKAGES.map((params) => getPackageSourceAsync(projectRoot, params)));
return results.filter(Boolean);
}
async function getPackageSourceAsync(projectRoot, params) {
const reason = `package:${params.packageName}`;
const packageJsonPath = resolve_from_1.default.silent(projectRoot, `${params.packageName}/package.json`);
if (packageJsonPath == null) {
return null;
}
debug(`Adding package - ${chalk_1.default.dim(params.packageName)}`);
if (params.packageJsonOnly) {
return {
type: 'contents',
id: reason,
contents: JSON.stringify(require(packageJsonPath)), // keep the json collapsed by serializing/deserializing
reasons: [reason],
};
}
const packageRoot = path_1.default.relative(projectRoot, path_1.default.dirname(packageJsonPath));
return await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, packageRoot, reason);
}
//# sourceMappingURL=Packages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Packages.js","sourceRoot":"","sources":["../../src/sourcer/Packages.ts"],"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AAG,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,cAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9E,OAAO,MAAM,IAAA,mCAA2B,EAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC"}

View File

@@ -0,0 +1,2 @@
import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
export declare function getPatchPackageSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;

View File

@@ -0,0 +1,23 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPatchPackageSourcesAsync = getPatchPackageSourcesAsync;
const chalk_1 = __importDefault(require("chalk"));
const Utils_1 = require("./Utils");
const Path_1 = require("../utils/Path");
const debug = require('debug')('expo:fingerprint:sourcer:PatchPackage');
async function getPatchPackageSourcesAsync(projectRoot, options) {
if ((0, Path_1.isIgnoredPathWithMatchObjects)('patches', options.ignoreDirMatchObjects)) {
debug(`Skipping dir - ${chalk_1.default.dim('patches')} (ignored by ignoreDirMatchObjects)`);
return [];
}
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'patches', 'patchPackage');
if (result != null) {
debug(`Adding dir - ${chalk_1.default.dim('patches')}`);
return [result];
}
return [];
}
//# sourceMappingURL=PatchPackage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PatchPackage.js","sourceRoot":"","sources":["../../src/sourcer/PatchPackage.ts"],"names":[],"mappings":";;;;;AAQA,kEAcC;AAtBD,kDAA0B;AAE1B,mCAAsD;AAEtD,wCAA8D;AAE9D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,uCAAuC,CAAC,CAAC;AAEjE,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,OAA0B;IAE1B,IAAI,IAAA,oCAA6B,EAAC,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAC5E,KAAK,CAAC,kBAAkB,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,qCAAqC,CAAC,CAAC;QACnF,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,mCAA2B,EAAC,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IACzF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,KAAK,CAAC,gBAAgB,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}

View File

@@ -0,0 +1,46 @@
/**
* Bitmask of values that can be used to skip certain parts of the sourcers when generating a fingerprint.
*/
export declare enum SourceSkips {
/** Skip nothing */
None = 0,
/** Versions in app.json, including Android versionCode and iOS buildNumber */
ExpoConfigVersions = 1,
/** runtimeVersion in app.json if it is a string */
ExpoConfigRuntimeVersionIfString = 2,
/** App names in app.json, including shortName and description */
ExpoConfigNames = 4,
/** Android package name in app.json */
ExpoConfigAndroidPackage = 8,
/** iOS bundle identifier in app.json */
ExpoConfigIosBundleIdentifier = 16,
/** Schemes in app.json */
ExpoConfigSchemes = 32,
/** EAS project information in app.json */
ExpoConfigEASProject = 64,
/** Assets in app.json, including icons and splash assets */
ExpoConfigAssets = 128,
/**
* Skip the whole ExpoConfig.
* Prefer the other ExpoConfig source skips when possible and use this flag with caution.
* This will potentially ignore some native changes that should be part of most fingerprints.
* E.g., adding a new config plugin, changing the app icon, or changing the app name.
*/
ExpoConfigAll = 256,
/**
* package.json scripts if android and ios items do not contain "run".
* Because prebuild will change the scripts in package.json,
* this is useful to generate a consistent fingerprint before and after prebuild.
*/
PackageJsonAndroidAndIosScriptsIfNotContainRun = 512,
/**
* Skip the whole `scripts` section in the project's package.json.
*/
PackageJsonScriptsAll = 1024,
/**
* Skip .gitignore files.
*/
GitIgnore = 2048,
/** The [extra](https://docs.expo.dev/versions/latest/config/app/#extra) section in app.json */
ExpoConfigExtraSection = 4096
}

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourceSkips = void 0;
/**
* Bitmask of values that can be used to skip certain parts of the sourcers when generating a fingerprint.
*/
var SourceSkips;
(function (SourceSkips) {
/** Skip nothing */
SourceSkips[SourceSkips["None"] = 0] = "None";
//#region - ExpoConfig source (e.g., app.json, app.config.js, etc.)
/** Versions in app.json, including Android versionCode and iOS buildNumber */
SourceSkips[SourceSkips["ExpoConfigVersions"] = 1] = "ExpoConfigVersions";
/** runtimeVersion in app.json if it is a string */
SourceSkips[SourceSkips["ExpoConfigRuntimeVersionIfString"] = 2] = "ExpoConfigRuntimeVersionIfString";
/** App names in app.json, including shortName and description */
SourceSkips[SourceSkips["ExpoConfigNames"] = 4] = "ExpoConfigNames";
/** Android package name in app.json */
SourceSkips[SourceSkips["ExpoConfigAndroidPackage"] = 8] = "ExpoConfigAndroidPackage";
/** iOS bundle identifier in app.json */
SourceSkips[SourceSkips["ExpoConfigIosBundleIdentifier"] = 16] = "ExpoConfigIosBundleIdentifier";
/** Schemes in app.json */
SourceSkips[SourceSkips["ExpoConfigSchemes"] = 32] = "ExpoConfigSchemes";
/** EAS project information in app.json */
SourceSkips[SourceSkips["ExpoConfigEASProject"] = 64] = "ExpoConfigEASProject";
/** Assets in app.json, including icons and splash assets */
SourceSkips[SourceSkips["ExpoConfigAssets"] = 128] = "ExpoConfigAssets";
/**
* Skip the whole ExpoConfig.
* Prefer the other ExpoConfig source skips when possible and use this flag with caution.
* This will potentially ignore some native changes that should be part of most fingerprints.
* E.g., adding a new config plugin, changing the app icon, or changing the app name.
*/
SourceSkips[SourceSkips["ExpoConfigAll"] = 256] = "ExpoConfigAll";
//#endregion - ExpoConfig source (e.g., app.json, app.config.js, etc.)
/**
* package.json scripts if android and ios items do not contain "run".
* Because prebuild will change the scripts in package.json,
* this is useful to generate a consistent fingerprint before and after prebuild.
*/
SourceSkips[SourceSkips["PackageJsonAndroidAndIosScriptsIfNotContainRun"] = 512] = "PackageJsonAndroidAndIosScriptsIfNotContainRun";
/**
* Skip the whole `scripts` section in the project's package.json.
*/
SourceSkips[SourceSkips["PackageJsonScriptsAll"] = 1024] = "PackageJsonScriptsAll";
/**
* Skip .gitignore files.
*/
SourceSkips[SourceSkips["GitIgnore"] = 2048] = "GitIgnore";
/** The [extra](https://docs.expo.dev/versions/latest/config/app/#extra) section in app.json */
SourceSkips[SourceSkips["ExpoConfigExtraSection"] = 4096] = "ExpoConfigExtraSection";
})(SourceSkips || (exports.SourceSkips = SourceSkips = {}));
//# sourceMappingURL=SourceSkips.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SourceSkips.js","sourceRoot":"","sources":["../../src/sourcer/SourceSkips.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WA2DX;AA3DD,WAAY,WAAW;IACrB,mBAAmB;IACnB,6CAAQ,CAAA;IAER,mEAAmE;IAEnE,8EAA8E;IAC9E,yEAA2B,CAAA;IAE3B,mDAAmD;IACnD,qGAAyC,CAAA;IAEzC,iEAAiE;IACjE,mEAAwB,CAAA;IAExB,uCAAuC;IACvC,qFAAiC,CAAA;IAEjC,wCAAwC;IACxC,gGAAsC,CAAA;IAEtC,0BAA0B;IAC1B,wEAA0B,CAAA;IAE1B,0CAA0C;IAC1C,8EAA6B,CAAA;IAE7B,4DAA4D;IAC5D,uEAAyB,CAAA;IAEzB;;;;;OAKG;IACH,iEAAsB,CAAA;IAEtB,sEAAsE;IAEtE;;;;OAIG;IACH,mIAAuD,CAAA;IAEvD;;OAEG;IACH,kFAA+B,CAAA;IAE/B;;OAEG;IACH,0DAAmB,CAAA;IAEnB,+FAA+F;IAC/F,oFAAgC,CAAA;AAClC,CAAC,EA3DW,WAAW,2BAAX,WAAW,QA2DtB"}

View File

@@ -0,0 +1,2 @@
import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
export declare function getHashSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>;

View File

@@ -0,0 +1,59 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHashSourcesAsync = getHashSourcesAsync;
const chalk_1 = __importDefault(require("chalk"));
const semver_1 = __importDefault(require("semver"));
const Bare_1 = require("./Bare");
const Expo_1 = require("./Expo");
const ExpoConfig_1 = require("../ExpoConfig");
const ExpoResolver_1 = require("../ExpoResolver");
const Packages_1 = require("./Packages");
const PatchPackage_1 = require("./PatchPackage");
const Profile_1 = require("../utils/Profile");
const debug = require('debug')('expo:fingerprint:sourcer:Sourcer');
async function getHashSourcesAsync(projectRoot, options) {
const { config: expoConfig, loadedModules } = await (0, ExpoConfig_1.getExpoConfigAsync)(projectRoot, options);
const expoAutolinkingVersion = (0, ExpoResolver_1.resolveExpoAutolinkingVersion)(projectRoot) ?? '0.0.0';
const useRNCoreAutolinkingFromExpo =
// expo-modules-autolinking supports the `react-native-config` core autolinking from 1.11.2.
// To makes the `useRNCoreAutolinkingFromExpo` default to `true` for Expo SDK 52 and higher.
// We check the expo-modules-autolinking version from 1.12.0.
typeof options.useRNCoreAutolinkingFromExpo === 'boolean'
? options.useRNCoreAutolinkingFromExpo
: semver_1.default.gte(expoAutolinkingVersion, '1.12.0');
const results = await Promise.all([
// expo
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingAndroidSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingIosSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
(0, Profile_1.profile)(options, Expo_1.getExpoConfigSourcesAsync)(projectRoot, expoConfig, loadedModules, options),
(0, Profile_1.profile)(options, Expo_1.getEasBuildSourcesAsync)(projectRoot, options),
(0, Profile_1.profile)(options, Expo_1.getExpoCNGPatchSourcesAsync)(projectRoot, options),
// bare managed files
(0, Profile_1.profile)(options, Bare_1.getGitIgnoreSourcesAsync)(projectRoot, options),
(0, Profile_1.profile)(options, Bare_1.getPackageJsonScriptSourcesAsync)(projectRoot, options),
// bare native files
(0, Profile_1.profile)(options, Bare_1.getBareAndroidSourcesAsync)(projectRoot, options),
(0, Profile_1.profile)(options, Bare_1.getBareIosSourcesAsync)(projectRoot, options),
// react-native core autolinking
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoAndroid)(projectRoot, options, useRNCoreAutolinkingFromExpo),
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoIos)(projectRoot, options, useRNCoreAutolinkingFromExpo),
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromRncCliAsync)(projectRoot, options, useRNCoreAutolinkingFromExpo),
// patch-package
(0, Profile_1.profile)(options, PatchPackage_1.getPatchPackageSourcesAsync)(projectRoot, options),
// some known dependencies, e.g. react-native
(0, Profile_1.profile)(options, Packages_1.getDefaultPackageSourcesAsync)(projectRoot, options),
]);
// extra sources
if (options.extraSources) {
for (const source of options.extraSources) {
debug(`Adding extra source - ${chalk_1.default.dim(JSON.stringify(source))}`);
}
results.push(options.extraSources);
}
// flatten results
return [].concat(...results);
}
//# sourceMappingURL=Sourcer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Sourcer.js","sourceRoot":"","sources":["../../src/sourcer/Sourcer.ts"],"names":[],"mappings":";;;;;AA4BA,kDAyEC;AArGD,kDAA0B;AAC1B,oDAA4B;AAE5B,iCAQgB;AAChB,iCAMgB;AAChB,8CAAmD;AACnD,kDAAgE;AAChE,yCAA2D;AAC3D,iDAA6D;AAE7D,8CAA2C;AAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,CAAC;AAE5D,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,OAA0B;IAE1B,MAAM,EAAE,MAAM,EAAE,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AsB,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC;QAE9D,gCAAgC;QAChC,IAAA,iBAAO,EAAC,OAAO,EAAE,+CAAwC,CAAC,CACxD,WAAW,EACX,OAAO,EACP,4BAA4B,CAC7B;QACD,IAAA,iBAAO,EAAC,OAAO,EAAE,2CAAoC,CAAC,CACpD,WAAW,EACX,OAAO,EACP,4BAA4B,CAC7B;QACD,IAAA,iBAAO,EAAC,OAAO,EAAE,+CAAwC,CAAC,CACxD,WAAW,EACX,OAAO,EACP,4BAA4B,CAC7B;QAED,gBAAgB;QAChB,IAAA,iBAAO,EAAC,OAAO,EAAE,0CAA2B,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC;QAEnE,6CAA6C;QAC7C,IAAA,iBAAO,EAAC,OAAO,EAAE,wCAA6B,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC;KACtE,CAAC,CAAC;IAEH,gBAAgB;IAChB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YAC1C,KAAK,CAAC,yBAAyB,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAED,kBAAkB;IAClB,OAAQ,EAAmB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;AACjD,CAAC"}

View File

@@ -0,0 +1,10 @@
import type { HashSource } from '../Fingerprint.types';
export declare function getFileBasedHashSourceAsync(projectRoot: string, filePath: string, reason: string): Promise<HashSource | null>;
/**
* A version of `JSON.stringify` that keeps the keys sorted
*/
export declare function stringifyJsonSorted(target: any, space?: string | number | undefined): string;
/**
* Transform absolute paths in JSON to relative paths based on the project root.
*/
export declare function relativizeJsonPaths(value: any, projectRoot: string): any;

78
node_modules/@expo/fingerprint/build/sourcer/Utils.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFileBasedHashSourceAsync = getFileBasedHashSourceAsync;
exports.stringifyJsonSorted = stringifyJsonSorted;
exports.relativizeJsonPaths = relativizeJsonPaths;
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
const Path_1 = require("../utils/Path");
async function getFileBasedHashSourceAsync(projectRoot, filePath, reason) {
let result = null;
try {
const stat = await promises_1.default.stat(path_1.default.join(projectRoot, filePath));
result = {
type: stat.isDirectory() ? 'dir' : 'file',
filePath: (0, Path_1.toPosixPath)(filePath),
reasons: [reason],
};
}
catch {
result = null;
}
return result;
}
/**
* A version of `JSON.stringify` that keeps the keys sorted
*/
function stringifyJsonSorted(target, space) {
return JSON.stringify(target, (_, value) => sortJson(value), space);
}
/**
* Transform absolute paths in JSON to relative paths based on the project root.
*/
function relativizeJsonPaths(value, projectRoot) {
if (typeof value === 'string' && value.startsWith(projectRoot)) {
return (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, value));
}
if (Array.isArray(value)) {
return value.map((item) => relativizeJsonPaths(item, projectRoot));
}
if (value && typeof value === 'object') {
return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, relativizeJsonPaths(val, projectRoot)]));
}
return value;
}
function sortJson(json) {
if (Array.isArray(json)) {
return json.sort((a, b) => {
// Sort array items by their stringified value.
// We don't need the array to be sorted in meaningful way, just to be sorted in deterministic.
// E.g. `[{ b: '2' }, {}, { a: '3' }, null]` -> `[null, { a : '3' }, { b: '2' }, {}]`
// This result is not a perfect solution, but it's good enough for our use case.
const stringifiedA = stringifyJsonSorted(a);
const stringifiedB = stringifyJsonSorted(b);
if (stringifiedA < stringifiedB) {
return -1;
}
else if (stringifiedA > stringifiedB) {
return 1;
}
return 0;
});
}
if (json != null && typeof json === 'object') {
// Sort object items by keys
return Object.keys(json)
.sort()
.reduce((acc, key) => {
acc[key] = json[key];
return acc;
}, {});
}
// Return primitives
return json;
}
//# sourceMappingURL=Utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/sourcer/Utils.ts"],"names":[],"mappings":";;;;;AAMA,kEAiBC;AAKD,kDAEC;AAKD,kDAgBC;AAnDD,2DAA6B;AAC7B,gDAAwB;AAGxB,wCAA4C;AAErC,KAAK,UAAU,2BAA2B,CAC/C,WAAmB,EACnB,QAAgB,EAChB,MAAc;IAEd,IAAI,MAAM,GAAsB,IAAI,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC7D,MAAM,GAAG;YACP,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACzC,QAAQ,EAAE,IAAA,kBAAW,EAAC,QAAQ,CAAC;YAC/B,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,MAAW,EAAE,KAAmC;IAClF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAAU,EAAE,WAAmB;IACjE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/D,OAAO,IAAA,kBAA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