@gfean/react-native-bundle-drop 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BundleDrop.podspec +17 -20
- package/README.md +77 -1
- package/android/build.gradle +4 -0
- package/android/src/main/java/com/bundledrop/BundleDropFileOps.kt +20 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +4 -1
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +5 -1
- package/docs/native-fingerprint.md +211 -0
- package/expo/android/build.gradle +61 -56
- package/ios/BundleDropLocator.swift +12 -0
- package/ios/BundleDropModule.swift +31 -13
- package/ios/BundleDropReactContent.swift +54 -0
- package/ios/BundleDropStartupRecovery.swift +48 -2
- package/ios/BundleDropStartupRecoveryAdapter.swift +87 -30
- package/lib/CLI/cli.js +12 -0
- package/lib/CLI/scripts/doctor.js +18 -7
- package/lib/CLI/scripts/expo/configure-expo.js +8 -3
- package/lib/CLI/scripts/fingerprint-cli.d.ts +12 -0
- package/lib/CLI/scripts/fingerprint-cli.js +36 -0
- package/lib/CLI/scripts/native/write-runtime-identity.js +3 -1
- package/lib/CLI/scripts/sight-ota.js +12 -3
- package/lib/CLI/scripts/upload-cli.d.ts +3 -0
- package/lib/CLI/scripts/upload-cli.js +239 -107
- package/lib/context.js +9 -1
- package/lib/errors.d.ts +2 -1
- package/lib/errors.js +2 -1
- package/lib/expo/buildIdentity.d.ts +1 -1
- package/lib/expo/buildIdentity.js +3 -0
- package/lib/expo/runtimeVersion.d.ts +10 -0
- package/lib/expo/runtimeVersion.js +11 -9
- package/lib/fingerprint/client.d.ts +5 -0
- package/lib/fingerprint/client.js +21 -0
- package/lib/fingerprint/collect.d.ts +3 -0
- package/lib/fingerprint/collect.js +116 -0
- package/lib/fingerprint/config.d.ts +14 -0
- package/lib/fingerprint/config.js +60 -0
- package/lib/fingerprint/normalizeBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeBuildNumber.js +55 -0
- package/lib/fingerprint/normalizeIosBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeIosBuildNumber.js +62 -0
- package/lib/fingerprint/types.d.ts +29 -0
- package/lib/fingerprint/types.js +2 -0
- package/lib/fingerprint/worker.d.ts +1 -0
- package/lib/fingerprint/worker.js +24 -0
- package/lib/fs/installedReportHistory.d.ts +2 -0
- package/lib/fs/installedReportHistory.js +55 -0
- package/lib/loadConfig.d.ts +6 -2
- package/lib/manager/downloadAndInstall.d.ts +1 -0
- package/lib/manager/downloadAndInstall.js +4 -0
- package/lib/manager/pendingRollback.d.ts +11 -0
- package/lib/manager/pendingRollback.js +54 -0
- package/lib/manager/reporting.d.ts +1 -0
- package/lib/manager/reporting.js +23 -6
- package/lib/manager/updateState.d.ts +3 -0
- package/lib/manager/updateState.js +1 -0
- package/lib/metro.js +3 -0
- package/lib/native/bundleDropNative.d.ts +2 -0
- package/lib/native/bundleDropNative.js +15 -5
- package/lib/patch-engine/installFromPatchSet.js +1 -1
- package/lib/patch-engine/patchTransport.d.ts +2 -1
- package/lib/patch-engine/patchTransport.js +4 -2
- package/lib/runtime/service.d.ts +2 -1
- package/lib/runtime/service.js +77 -22
- package/lib/scripts/bundle.js +10 -0
- package/lib/scripts/canonicalArtifact.d.ts +3 -0
- package/lib/scripts/canonicalArtifact.js +3 -1
- package/lib/scripts/exportProject.js +11 -0
- package/lib/scripts/nativeBuildNumber.d.ts +9 -0
- package/lib/scripts/nativeBuildNumber.js +110 -0
- package/lib/scripts/runtimeCompatibilityMetadata.d.ts +10 -0
- package/lib/scripts/runtimeCompatibilityMetadata.js +13 -0
- package/package.json +26 -12
- package/third_party/expo-fingerprint/LICENSE +22 -0
- package/third_party/expo-fingerprint/NOTICE +5 -0
- package/third_party/expo-fingerprint/PROVENANCE.md +41 -0
- package/third_party/expo-fingerprint/build/Config.js +122 -0
- package/third_party/expo-fingerprint/build/Dedup.js +89 -0
- package/third_party/expo-fingerprint/build/ExpoConfig.js +93 -0
- package/third_party/expo-fingerprint/build/ExpoConfigLoader.js +201 -0
- package/third_party/expo-fingerprint/build/ExpoResolver.js +84 -0
- package/third_party/expo-fingerprint/build/Fingerprint.js +111 -0
- package/third_party/expo-fingerprint/build/Fingerprint.types.js +3 -0
- package/third_party/expo-fingerprint/build/Options.js +140 -0
- package/third_party/expo-fingerprint/build/Presets.js +62 -0
- package/third_party/expo-fingerprint/build/ProjectWorkflow.js +163 -0
- package/third_party/expo-fingerprint/build/Sort.js +46 -0
- package/third_party/expo-fingerprint/build/hash/FileHookTransform.js +42 -0
- package/third_party/expo-fingerprint/build/hash/Hash.js +264 -0
- package/third_party/expo-fingerprint/build/hash/ReactImportsPatcher.js +344 -0
- package/third_party/expo-fingerprint/build/index.js +23 -0
- package/third_party/expo-fingerprint/build/sourcer/AutolinkingConfig.js +130 -0
- package/third_party/expo-fingerprint/build/sourcer/Bare.js +231 -0
- package/third_party/expo-fingerprint/build/sourcer/Expo.js +376 -0
- package/third_party/expo-fingerprint/build/sourcer/Packages.js +54 -0
- package/third_party/expo-fingerprint/build/sourcer/PatchPackage.js +22 -0
- package/third_party/expo-fingerprint/build/sourcer/SourceSkips.js +79 -0
- package/third_party/expo-fingerprint/build/sourcer/Sourcer.js +58 -0
- package/third_party/expo-fingerprint/build/sourcer/Utils.js +129 -0
- package/third_party/expo-fingerprint/build/types/module.d.js +2 -0
- package/third_party/expo-fingerprint/build/utils/Concurrency.js +47 -0
- package/third_party/expo-fingerprint/build/utils/Env.js +28 -0
- package/third_party/expo-fingerprint/build/utils/Path.js +161 -0
- package/third_party/expo-fingerprint/build/utils/Predicates.js +6 -0
- package/third_party/expo-fingerprint/build/utils/Profile.js +41 -0
- package/third_party/expo-fingerprint/build/utils/Spawn.js +38 -0
- package/third_party/expo-fingerprint/build/utils/SpawnIPC.js +28 -0
- package/third_party/expo-fingerprint/scheme-1-contract.json +132 -0
- package/third_party/expo-fingerprint/upstream-files.json +37 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeAutolinkingConfig = normalizeAutolinkingConfig;
|
|
7
|
+
exports.isPathLike = isPathLike;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const Path_1 = require("../utils/Path");
|
|
10
|
+
const NAMED_ARRAY_KEYS = new Set(['modules', 'projects', 'plugins', 'pods', 'extraDependencies']);
|
|
11
|
+
const STRING_ARRAY_KEYS = new Set(['coreFeatures', 'configurations', 'buildTypes']);
|
|
12
|
+
const FILE_URL_REGEX = /^file:/i;
|
|
13
|
+
const NETWORK_URL_REGEX = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
14
|
+
const RELATIVE_OR_NODE_MODULES_PATH_REGEX = /^(?:\.\.?\/|node_modules\/)/;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes resolved autolinking config before it is hashed.
|
|
17
|
+
* Converts react-native-config dependency maps to a sorted array of objects and sorts known
|
|
18
|
+
* arrays by their identifying field. `scriptPhases` is left in order.
|
|
19
|
+
*
|
|
20
|
+
* When `stripPaths` is true, filesystem path fields are omitted, including `scriptPhases[].path`
|
|
21
|
+
* and `sourceDir` / `podspecPath` overrides from the project's **react-native.config.js**.
|
|
22
|
+
* Linked names and `scriptPhases` names remain.
|
|
23
|
+
*/
|
|
24
|
+
function normalizeAutolinkingConfig(config, options) {
|
|
25
|
+
const roots = (options.roots ?? []).map((root) => (0, Path_1.toPosixPath)(root));
|
|
26
|
+
return normalizeNode(structuredClone(config), options.stripPaths, roots);
|
|
27
|
+
}
|
|
28
|
+
function normalizeNode(value, stripPaths, roots, parentKey) {
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
const mapped = value
|
|
31
|
+
.map((item) => normalizeNode(item, stripPaths, roots, parentKey))
|
|
32
|
+
.filter((item) => item !== undefined);
|
|
33
|
+
return sortKnownArray(parentKey, mapped);
|
|
34
|
+
}
|
|
35
|
+
if (value && typeof value === 'object') {
|
|
36
|
+
if (isNamedDependencyMap(value)) {
|
|
37
|
+
return normalizeNode(namedMapToSortedArray(value), stripPaths, roots, 'modules');
|
|
38
|
+
}
|
|
39
|
+
const result = {};
|
|
40
|
+
for (const [key, child] of Object.entries(value)) {
|
|
41
|
+
if (stripPaths && typeof child === 'string' && isPathLike(child, roots)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
result[key] = normalizeNode(child, stripPaths, roots, key);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
if (stripPaths && typeof value === 'string' && isPathLike(value, roots)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* True when `value` is a `{ [packageName]: { root | platforms } }` map from react-native-config.
|
|
55
|
+
* Those maps are converted to arrays because object key order is not stable across autolinking.
|
|
56
|
+
*/
|
|
57
|
+
function isNamedDependencyMap(value) {
|
|
58
|
+
const entries = Object.entries(value);
|
|
59
|
+
if (entries.length === 0) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return entries.every(([, child]) => child != null &&
|
|
63
|
+
typeof child === 'object' &&
|
|
64
|
+
!Array.isArray(child) &&
|
|
65
|
+
('platforms' in child || 'root' in child));
|
|
66
|
+
}
|
|
67
|
+
function namedMapToSortedArray(map) {
|
|
68
|
+
return Object.entries(map)
|
|
69
|
+
.sort(([left], [right]) => compareStrings(left, right))
|
|
70
|
+
.map(([name, child]) => ({ ...child, name }));
|
|
71
|
+
}
|
|
72
|
+
function sortKnownArray(parentKey, items) {
|
|
73
|
+
if (parentKey && STRING_ARRAY_KEYS.has(parentKey)) {
|
|
74
|
+
return [...items].sort((left, right) => compareStrings(String(left), String(right)));
|
|
75
|
+
}
|
|
76
|
+
if (parentKey && NAMED_ARRAY_KEYS.has(parentKey)) {
|
|
77
|
+
return [...items].sort((left, right) => compareStrings(namedKey(left), namedKey(right)));
|
|
78
|
+
}
|
|
79
|
+
return items;
|
|
80
|
+
}
|
|
81
|
+
function namedKey(value) {
|
|
82
|
+
if (value == null || typeof value !== 'object') {
|
|
83
|
+
return String(value);
|
|
84
|
+
}
|
|
85
|
+
const record = value;
|
|
86
|
+
for (const key of ['packageName', 'name', 'podName', 'id', 'url']) {
|
|
87
|
+
if (typeof record[key] === 'string') {
|
|
88
|
+
return record[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
function compareStrings(left, right) {
|
|
94
|
+
if (left < right) {
|
|
95
|
+
return -1;
|
|
96
|
+
}
|
|
97
|
+
if (left > right) {
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* True when `value` is a filesystem path, including values already rewritten relative to
|
|
104
|
+
* `projectRoot` or a dependency root.
|
|
105
|
+
* URLs are kept so extra Maven repos and similar project settings still hash.
|
|
106
|
+
*/
|
|
107
|
+
function isPathLike(value, roots) {
|
|
108
|
+
if (!value) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (FILE_URL_REGEX.test(value)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (NETWORK_URL_REGEX.test(value)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const posixValue = (0, Path_1.toPosixPath)(value);
|
|
118
|
+
if (path_1.default.posix.isAbsolute(posixValue) || path_1.default.win32.isAbsolute(value)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
for (const root of roots) {
|
|
122
|
+
if (!root) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (posixValue === root || posixValue.startsWith(`${root}/`)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return RELATIVE_OR_NODE_MODULES_PATH_REGEX.test(posixValue);
|
|
130
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getBareAndroidSourcesAsync = getBareAndroidSourcesAsync;
|
|
7
|
+
exports.getBareIosSourcesAsync = getBareIosSourcesAsync;
|
|
8
|
+
exports.getPackageJsonScriptSourcesAsync = getPackageJsonScriptSourcesAsync;
|
|
9
|
+
exports.getGitIgnoreSourcesAsync = getGitIgnoreSourcesAsync;
|
|
10
|
+
exports.getCoreAutolinkingSourcesFromRncCliAsync = getCoreAutolinkingSourcesFromRncCliAsync;
|
|
11
|
+
exports.getCoreAutolinkingSourcesFromExpoAndroid = getCoreAutolinkingSourcesFromExpoAndroid;
|
|
12
|
+
exports.getCoreAutolinkingSourcesFromExpoIos = getCoreAutolinkingSourcesFromExpoIos;
|
|
13
|
+
const Env_1 = require("../utils/Env");
|
|
14
|
+
const Spawn_1 = __importDefault(require("../utils/Spawn"));
|
|
15
|
+
const assert_1 = __importDefault(require("assert"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
20
|
+
const ExpoResolver_1 = require("../ExpoResolver");
|
|
21
|
+
const Path_1 = require("../utils/Path");
|
|
22
|
+
const Profile_1 = require("../utils/Profile");
|
|
23
|
+
const AutolinkingConfig_1 = require("./AutolinkingConfig");
|
|
24
|
+
const SourceSkips_1 = require("./SourceSkips");
|
|
25
|
+
const Utils_1 = require("./Utils");
|
|
26
|
+
const debug = require('debug')('expo:fingerprint:sourcer:Bare');
|
|
27
|
+
async function getBareAndroidSourcesAsync(projectRoot, options) {
|
|
28
|
+
if (options.platforms.includes('android')) {
|
|
29
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'android', 'bareNativeDir');
|
|
30
|
+
if (result != null) {
|
|
31
|
+
debug(`Adding bare native dir - ${chalk_1.default.dim('android')}`);
|
|
32
|
+
return [result];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
async function getBareIosSourcesAsync(projectRoot, options) {
|
|
38
|
+
if (options.platforms.includes('ios')) {
|
|
39
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'ios', 'bareNativeDir');
|
|
40
|
+
if (result != null) {
|
|
41
|
+
debug(`Adding bare native dir - ${chalk_1.default.dim('ios')}`);
|
|
42
|
+
return [result];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
async function getPackageJsonScriptSourcesAsync(projectRoot, options) {
|
|
48
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonScriptsAll) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
let packageJson;
|
|
52
|
+
try {
|
|
53
|
+
packageJson = require((0, resolve_from_1.default)(path_1.default.resolve(projectRoot), './package.json'));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
debug(`Unable to read package.json from ${path_1.default.resolve(projectRoot)}/package.json: ` + e);
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const results = [];
|
|
60
|
+
if (packageJson.scripts) {
|
|
61
|
+
debug(`Adding package.json contents - ${chalk_1.default.dim('scripts')}`);
|
|
62
|
+
const id = 'packageJson:scripts';
|
|
63
|
+
results.push({
|
|
64
|
+
type: 'contents',
|
|
65
|
+
id,
|
|
66
|
+
contents: normalizePackageJsonScriptSources(packageJson.scripts, options),
|
|
67
|
+
reasons: [id],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
async function getGitIgnoreSourcesAsync(projectRoot, options) {
|
|
73
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.GitIgnore) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, '.gitignore', 'bareGitIgnore');
|
|
77
|
+
if (result != null) {
|
|
78
|
+
debug(`Adding file - ${chalk_1.default.dim('.gitignore')}`);
|
|
79
|
+
return [result];
|
|
80
|
+
}
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
async function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
84
|
+
if (useRNCoreAutolinkingFromExpo === true) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const { stdout } = await (0, Spawn_1.default)('npx', ['react-native', 'config'], {
|
|
89
|
+
cwd: projectRoot,
|
|
90
|
+
env: (0, Env_1.getOriginalEnv)(),
|
|
91
|
+
});
|
|
92
|
+
const config = JSON.parse(stdout);
|
|
93
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
94
|
+
config,
|
|
95
|
+
contentsId: 'rncoreAutolinkingConfig',
|
|
96
|
+
reasons: ['rncoreAutolinking'],
|
|
97
|
+
options,
|
|
98
|
+
});
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources.\n${e}`));
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
107
|
+
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('android')) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const args = [
|
|
111
|
+
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
|
|
112
|
+
'react-native-config',
|
|
113
|
+
'--json',
|
|
114
|
+
'--platform',
|
|
115
|
+
'android',
|
|
116
|
+
];
|
|
117
|
+
try {
|
|
118
|
+
const { stdout } = await (0, Spawn_1.default)('node', args, {
|
|
119
|
+
cwd: projectRoot,
|
|
120
|
+
env: (0, Env_1.getOriginalEnv)(),
|
|
121
|
+
});
|
|
122
|
+
const config = JSON.parse(stdout);
|
|
123
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
124
|
+
config,
|
|
125
|
+
contentsId: 'rncoreAutolinkingConfig:android',
|
|
126
|
+
reasons: ['rncoreAutolinkingAndroid'],
|
|
127
|
+
options,
|
|
128
|
+
platform: 'android',
|
|
129
|
+
});
|
|
130
|
+
return results;
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for android.\n${e}`));
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function getCoreAutolinkingSourcesFromExpoIos(projectRoot, options, useRNCoreAutolinkingFromExpo) {
|
|
138
|
+
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('ios')) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const { stdout } = await (0, Spawn_1.default)('node', [
|
|
143
|
+
(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot),
|
|
144
|
+
'react-native-config',
|
|
145
|
+
'--json',
|
|
146
|
+
'--platform',
|
|
147
|
+
'ios',
|
|
148
|
+
], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
|
|
149
|
+
const config = JSON.parse(stdout);
|
|
150
|
+
const results = await parseCoreAutolinkingSourcesAsync({
|
|
151
|
+
config,
|
|
152
|
+
contentsId: 'rncoreAutolinkingConfig:ios',
|
|
153
|
+
reasons: ['rncoreAutolinkingIos'],
|
|
154
|
+
options,
|
|
155
|
+
platform: 'ios',
|
|
156
|
+
});
|
|
157
|
+
return results;
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for ios.\n${e}`));
|
|
161
|
+
throw e;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function parseCoreAutolinkingSourcesAsync({ config, reasons, contentsId, platform, options, }) {
|
|
165
|
+
const logTag = platform
|
|
166
|
+
? `react-native core autolinking dir for ${platform}`
|
|
167
|
+
: 'react-native core autolinking dir';
|
|
168
|
+
const results = [];
|
|
169
|
+
const root = await (0, Utils_1.maybeGetRealPathAsync)(config.root);
|
|
170
|
+
const autolinkingConfig = {};
|
|
171
|
+
for (const [depName, depData] of Object.entries(config.dependencies)) {
|
|
172
|
+
try {
|
|
173
|
+
stripRncoreAutolinkingAbsolutePaths(depData, root);
|
|
174
|
+
const filePath = (0, Path_1.toPosixPath)(depData.root);
|
|
175
|
+
debug(`Adding ${logTag} - ${chalk_1.default.dim(filePath)}`);
|
|
176
|
+
results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(root, filePath, reasons, options.nativeModuleSourceType));
|
|
177
|
+
autolinkingConfig[depName] = depData;
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
debug(chalk_1.default.red(`Error adding ${logTag} - ${depName}.\n${e}`));
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
results.push({
|
|
185
|
+
type: 'contents',
|
|
186
|
+
id: contentsId,
|
|
187
|
+
contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(autolinkingConfig, {
|
|
188
|
+
stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
|
|
189
|
+
roots: [root],
|
|
190
|
+
})),
|
|
191
|
+
reasons,
|
|
192
|
+
});
|
|
193
|
+
return results;
|
|
194
|
+
}
|
|
195
|
+
function stripRncoreAutolinkingAbsolutePaths(dependency, root) {
|
|
196
|
+
(0, assert_1.default)(dependency.root);
|
|
197
|
+
const dependencyRoot = dependency.root;
|
|
198
|
+
const cmakeDepRoot = node_process_1.default.platform === 'win32' ? dependencyRoot.replace(/\\/g, '/') : dependencyRoot;
|
|
199
|
+
dependency.root = (0, Path_1.toPosixPath)(path_1.default.relative(root, dependencyRoot));
|
|
200
|
+
for (const platformData of Object.values(dependency.platforms)) {
|
|
201
|
+
for (const [key, value] of Object.entries(platformData ?? {})) {
|
|
202
|
+
let newValue;
|
|
203
|
+
if (node_process_1.default.platform === 'win32' &&
|
|
204
|
+
['cmakeListsPath', 'cxxModuleCMakeListsPath'].includes(key)) {
|
|
205
|
+
// CMake paths on Windows are serving in slashes,
|
|
206
|
+
// we have to check startsWith with the same slashes.
|
|
207
|
+
newValue = value?.startsWith?.(cmakeDepRoot)
|
|
208
|
+
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
|
|
209
|
+
: value;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
newValue = value?.startsWith?.(dependencyRoot)
|
|
213
|
+
? (0, Path_1.toPosixPath)(path_1.default.relative(root, value))
|
|
214
|
+
: value;
|
|
215
|
+
}
|
|
216
|
+
platformData[key] = newValue;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function normalizePackageJsonScriptSources(scripts, options) {
|
|
221
|
+
if (options.sourceSkips & SourceSkips_1.SourceSkips.PackageJsonAndroidAndIosScriptsIfNotContainRun) {
|
|
222
|
+
// Replicate the behavior of `expo prebuild`
|
|
223
|
+
if (!scripts.android?.includes('run') || scripts.android === 'expo run:android') {
|
|
224
|
+
delete scripts.android;
|
|
225
|
+
}
|
|
226
|
+
if (!scripts.ios?.includes('run') || scripts.ios === 'expo run:ios') {
|
|
227
|
+
delete scripts.ios;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return JSON.stringify(scripts);
|
|
231
|
+
}
|