@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.
Files changed (107) hide show
  1. package/BundleDrop.podspec +17 -20
  2. package/README.md +77 -1
  3. package/android/build.gradle +4 -0
  4. package/android/src/main/java/com/bundledrop/BundleDropFileOps.kt +20 -0
  5. package/android/src/main/java/com/bundledrop/BundleDropModule.kt +4 -1
  6. package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +5 -1
  7. package/docs/native-fingerprint.md +211 -0
  8. package/expo/android/build.gradle +61 -56
  9. package/ios/BundleDropLocator.swift +12 -0
  10. package/ios/BundleDropModule.swift +31 -13
  11. package/ios/BundleDropReactContent.swift +54 -0
  12. package/ios/BundleDropStartupRecovery.swift +48 -2
  13. package/ios/BundleDropStartupRecoveryAdapter.swift +87 -30
  14. package/lib/CLI/cli.js +12 -0
  15. package/lib/CLI/scripts/doctor.js +18 -7
  16. package/lib/CLI/scripts/expo/configure-expo.js +8 -3
  17. package/lib/CLI/scripts/fingerprint-cli.d.ts +12 -0
  18. package/lib/CLI/scripts/fingerprint-cli.js +36 -0
  19. package/lib/CLI/scripts/native/write-runtime-identity.js +3 -1
  20. package/lib/CLI/scripts/sight-ota.js +12 -3
  21. package/lib/CLI/scripts/upload-cli.d.ts +3 -0
  22. package/lib/CLI/scripts/upload-cli.js +239 -107
  23. package/lib/context.js +9 -1
  24. package/lib/errors.d.ts +2 -1
  25. package/lib/errors.js +2 -1
  26. package/lib/expo/buildIdentity.d.ts +1 -1
  27. package/lib/expo/buildIdentity.js +3 -0
  28. package/lib/expo/runtimeVersion.d.ts +10 -0
  29. package/lib/expo/runtimeVersion.js +11 -9
  30. package/lib/fingerprint/client.d.ts +5 -0
  31. package/lib/fingerprint/client.js +21 -0
  32. package/lib/fingerprint/collect.d.ts +3 -0
  33. package/lib/fingerprint/collect.js +116 -0
  34. package/lib/fingerprint/config.d.ts +14 -0
  35. package/lib/fingerprint/config.js +60 -0
  36. package/lib/fingerprint/normalizeBuildNumber.d.ts +4 -0
  37. package/lib/fingerprint/normalizeBuildNumber.js +55 -0
  38. package/lib/fingerprint/normalizeIosBuildNumber.d.ts +4 -0
  39. package/lib/fingerprint/normalizeIosBuildNumber.js +62 -0
  40. package/lib/fingerprint/types.d.ts +29 -0
  41. package/lib/fingerprint/types.js +2 -0
  42. package/lib/fingerprint/worker.d.ts +1 -0
  43. package/lib/fingerprint/worker.js +24 -0
  44. package/lib/fs/installedReportHistory.d.ts +2 -0
  45. package/lib/fs/installedReportHistory.js +55 -0
  46. package/lib/loadConfig.d.ts +6 -2
  47. package/lib/manager/downloadAndInstall.d.ts +1 -0
  48. package/lib/manager/downloadAndInstall.js +4 -0
  49. package/lib/manager/pendingRollback.d.ts +11 -0
  50. package/lib/manager/pendingRollback.js +54 -0
  51. package/lib/manager/reporting.d.ts +1 -0
  52. package/lib/manager/reporting.js +23 -6
  53. package/lib/manager/updateState.d.ts +3 -0
  54. package/lib/manager/updateState.js +1 -0
  55. package/lib/metro.js +3 -0
  56. package/lib/native/bundleDropNative.d.ts +2 -0
  57. package/lib/native/bundleDropNative.js +15 -5
  58. package/lib/patch-engine/installFromPatchSet.js +1 -1
  59. package/lib/patch-engine/patchTransport.d.ts +2 -1
  60. package/lib/patch-engine/patchTransport.js +4 -2
  61. package/lib/runtime/service.d.ts +2 -1
  62. package/lib/runtime/service.js +77 -22
  63. package/lib/scripts/bundle.js +10 -0
  64. package/lib/scripts/canonicalArtifact.d.ts +3 -0
  65. package/lib/scripts/canonicalArtifact.js +3 -1
  66. package/lib/scripts/exportProject.js +11 -0
  67. package/lib/scripts/nativeBuildNumber.d.ts +9 -0
  68. package/lib/scripts/nativeBuildNumber.js +110 -0
  69. package/lib/scripts/runtimeCompatibilityMetadata.d.ts +10 -0
  70. package/lib/scripts/runtimeCompatibilityMetadata.js +13 -0
  71. package/package.json +26 -12
  72. package/third_party/expo-fingerprint/LICENSE +22 -0
  73. package/third_party/expo-fingerprint/NOTICE +5 -0
  74. package/third_party/expo-fingerprint/PROVENANCE.md +41 -0
  75. package/third_party/expo-fingerprint/build/Config.js +122 -0
  76. package/third_party/expo-fingerprint/build/Dedup.js +89 -0
  77. package/third_party/expo-fingerprint/build/ExpoConfig.js +93 -0
  78. package/third_party/expo-fingerprint/build/ExpoConfigLoader.js +201 -0
  79. package/third_party/expo-fingerprint/build/ExpoResolver.js +84 -0
  80. package/third_party/expo-fingerprint/build/Fingerprint.js +111 -0
  81. package/third_party/expo-fingerprint/build/Fingerprint.types.js +3 -0
  82. package/third_party/expo-fingerprint/build/Options.js +140 -0
  83. package/third_party/expo-fingerprint/build/Presets.js +62 -0
  84. package/third_party/expo-fingerprint/build/ProjectWorkflow.js +163 -0
  85. package/third_party/expo-fingerprint/build/Sort.js +46 -0
  86. package/third_party/expo-fingerprint/build/hash/FileHookTransform.js +42 -0
  87. package/third_party/expo-fingerprint/build/hash/Hash.js +264 -0
  88. package/third_party/expo-fingerprint/build/hash/ReactImportsPatcher.js +344 -0
  89. package/third_party/expo-fingerprint/build/index.js +23 -0
  90. package/third_party/expo-fingerprint/build/sourcer/AutolinkingConfig.js +130 -0
  91. package/third_party/expo-fingerprint/build/sourcer/Bare.js +231 -0
  92. package/third_party/expo-fingerprint/build/sourcer/Expo.js +376 -0
  93. package/third_party/expo-fingerprint/build/sourcer/Packages.js +54 -0
  94. package/third_party/expo-fingerprint/build/sourcer/PatchPackage.js +22 -0
  95. package/third_party/expo-fingerprint/build/sourcer/SourceSkips.js +79 -0
  96. package/third_party/expo-fingerprint/build/sourcer/Sourcer.js +58 -0
  97. package/third_party/expo-fingerprint/build/sourcer/Utils.js +129 -0
  98. package/third_party/expo-fingerprint/build/types/module.d.js +2 -0
  99. package/third_party/expo-fingerprint/build/utils/Concurrency.js +47 -0
  100. package/third_party/expo-fingerprint/build/utils/Env.js +28 -0
  101. package/third_party/expo-fingerprint/build/utils/Path.js +161 -0
  102. package/third_party/expo-fingerprint/build/utils/Predicates.js +6 -0
  103. package/third_party/expo-fingerprint/build/utils/Profile.js +41 -0
  104. package/third_party/expo-fingerprint/build/utils/Spawn.js +38 -0
  105. package/third_party/expo-fingerprint/build/utils/SpawnIPC.js +28 -0
  106. package/third_party/expo-fingerprint/scheme-1-contract.json +132 -0
  107. package/third_party/expo-fingerprint/upstream-files.json +37 -0
@@ -0,0 +1,376 @@
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.getExpoConfigSourcesAsync = getExpoConfigSourcesAsync;
7
+ exports.createHashSourceExternalFileAsync = createHashSourceExternalFileAsync;
8
+ exports.getEasBuildSourcesAsync = getEasBuildSourcesAsync;
9
+ exports.getExpoAutolinkingAndroidSourcesAsync = getExpoAutolinkingAndroidSourcesAsync;
10
+ exports.getExpoCNGPatchSourcesAsync = getExpoCNGPatchSourcesAsync;
11
+ exports.getExpoAutolinkingIosSourcesAsync = getExpoAutolinkingIosSourcesAsync;
12
+ exports.sortExpoAutolinkingAndroidConfig = sortExpoAutolinkingAndroidConfig;
13
+ exports.getConfigPluginProps = getConfigPluginProps;
14
+ const Env_1 = require("../utils/Env");
15
+ const Spawn_1 = __importDefault(require("../utils/Spawn"));
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const semver_1 = __importDefault(require("semver"));
19
+ const ExpoResolver_1 = require("../ExpoResolver");
20
+ const Path_1 = require("../utils/Path");
21
+ const Profile_1 = require("../utils/Profile");
22
+ const AutolinkingConfig_1 = require("./AutolinkingConfig");
23
+ const SourceSkips_1 = require("./SourceSkips");
24
+ const Utils_1 = require("./Utils");
25
+ const debug = require('debug')('expo:fingerprint:sourcer:Expo');
26
+ async function getExpoConfigSourcesAsync(projectRoot, config, loadedModules, options) {
27
+ if (options.sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAll) {
28
+ return [];
29
+ }
30
+ if (config == null) {
31
+ return [];
32
+ }
33
+ const results = [];
34
+ let expoConfig = normalizeExpoConfig(config.exp, projectRoot, options);
35
+ // external files in config
36
+ const isAndroid = options.platforms.includes('android');
37
+ const isIos = options.platforms.includes('ios');
38
+ const splashScreenPluginProps = getConfigPluginProps(expoConfig, 'expo-splash-screen');
39
+ const fontPluginProps = getConfigPluginProps(expoConfig, 'expo-font');
40
+ const externalFiles = [
41
+ // expo-font files
42
+ ...(fontPluginProps?.fonts ?? []),
43
+ ...(isIos ? (fontPluginProps?.ios?.fonts ?? []) : []),
44
+ ...(isAndroid
45
+ ? (fontPluginProps?.android?.fonts ?? []).flatMap((f) => typeof f === 'string'
46
+ ? [f]
47
+ : // When a variable font file backs several definitions,
48
+ // a family may name the file path once instead of each definition repeating it
49
+ (f.fontDefinitions ?? []).map((d) => d.path ?? f.path))
50
+ : []),
51
+ // icons
52
+ expoConfig.icon,
53
+ isAndroid ? expoConfig.android?.icon : undefined,
54
+ ...(isIos ? collectIosIcons(expoConfig.ios?.icon) : []),
55
+ isAndroid ? expoConfig.android?.adaptiveIcon?.foregroundImage : undefined,
56
+ isAndroid ? expoConfig.android?.adaptiveIcon?.backgroundImage : undefined,
57
+ // expo-splash-screen images
58
+ splashScreenPluginProps?.image,
59
+ splashScreenPluginProps?.dark?.image,
60
+ isAndroid ? splashScreenPluginProps?.android?.image : undefined,
61
+ isAndroid ? splashScreenPluginProps?.android?.mdpi : undefined,
62
+ isAndroid ? splashScreenPluginProps?.android?.hdpi : undefined,
63
+ isAndroid ? splashScreenPluginProps?.android?.xhdpi : undefined,
64
+ isAndroid ? splashScreenPluginProps?.android?.xxhdpi : undefined,
65
+ isAndroid ? splashScreenPluginProps?.android?.xxxhdpi : undefined,
66
+ isAndroid ? splashScreenPluginProps?.android?.dark?.image : undefined,
67
+ isAndroid ? splashScreenPluginProps?.android?.dark?.mdpi : undefined,
68
+ isAndroid ? splashScreenPluginProps?.android?.dark?.hdpi : undefined,
69
+ isAndroid ? splashScreenPluginProps?.android?.dark?.xhdpi : undefined,
70
+ isAndroid ? splashScreenPluginProps?.android?.dark?.xxhdpi : undefined,
71
+ isAndroid ? splashScreenPluginProps?.android?.dark?.xxxhdpi : undefined,
72
+ isIos ? splashScreenPluginProps?.ios?.image : undefined,
73
+ isIos ? splashScreenPluginProps?.ios?.tabletImage : undefined,
74
+ isIos ? splashScreenPluginProps?.ios?.dark?.image : undefined,
75
+ isIos ? splashScreenPluginProps?.ios?.dark?.tabletImage : undefined,
76
+ // google service files
77
+ isAndroid ? expoConfig.android?.googleServicesFile : undefined,
78
+ isIos ? expoConfig.ios?.googleServicesFile : undefined,
79
+ ]
80
+ .filter((file) => Boolean(file))
81
+ .map((filePath) => ensureRelativePath(projectRoot, filePath));
82
+ const externalFileSources = (await Promise.all(externalFiles.map((file) => createHashSourceExternalFileAsync({ projectRoot, file, reason: 'expoConfigExternalFile' })))).filter(Boolean);
83
+ results.push(...externalFileSources);
84
+ expoConfig = postUpdateExpoConfig(expoConfig, projectRoot);
85
+ results.push({
86
+ type: 'contents',
87
+ id: 'expoConfig',
88
+ contents: (0, Utils_1.stringifyJsonSorted)(expoConfig),
89
+ reasons: ['expoConfig'],
90
+ });
91
+ // config plugins
92
+ // With `configPluginSourceType: 'package'`, node_modules plugin files collapse to their package
93
+ // name+version; in-repo files and virtual modules are hashed directly.
94
+ const configPluginModules = await Promise.all((loadedModules ?? []).map(async (loadedModule) => {
95
+ if (loadedModule.type === 'contents') {
96
+ return {
97
+ type: 'contents',
98
+ id: loadedModule.id,
99
+ contents: loadedModule.contents,
100
+ reasons: ['expoConfigPlugins'],
101
+ };
102
+ }
103
+ if (options.configPluginSourceType === 'package') {
104
+ const packageJsonPath = (0, Path_1.getNodeModulesPackageJsonPath)(loadedModule.path);
105
+ if (packageJsonPath) {
106
+ const identity = await (0, Utils_1.readPackageIdentityAsync)(path_1.default.join(projectRoot, packageJsonPath));
107
+ if (identity) {
108
+ return {
109
+ type: 'package',
110
+ ...identity,
111
+ filePath: packageJsonPath,
112
+ reasons: ['expoConfigPlugins'],
113
+ };
114
+ }
115
+ }
116
+ }
117
+ return { type: 'file', filePath: loadedModule.path, reasons: ['expoConfigPlugins'] };
118
+ }));
119
+ results.push(...configPluginModules);
120
+ return results;
121
+ }
122
+ function normalizeExpoConfig(config, projectRoot, options) {
123
+ // Deep clone by JSON.parse/stringify that assumes the config is serializable.
124
+ const normalizedConfig = JSON.parse(JSON.stringify(config));
125
+ const { sourceSkips } = options;
126
+ delete normalizedConfig._internal;
127
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigVersions) {
128
+ delete normalizedConfig.version;
129
+ delete normalizedConfig.android?.versionCode;
130
+ delete normalizedConfig.android?.version;
131
+ delete normalizedConfig.ios?.buildNumber;
132
+ delete normalizedConfig.ios?.version;
133
+ }
134
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigRuntimeVersionIfString) {
135
+ if (typeof normalizedConfig.runtimeVersion === 'string') {
136
+ delete normalizedConfig.runtimeVersion;
137
+ }
138
+ if (typeof normalizedConfig.android?.runtimeVersion === 'string') {
139
+ delete normalizedConfig.android.runtimeVersion;
140
+ }
141
+ if (typeof normalizedConfig.ios?.runtimeVersion === 'string') {
142
+ delete normalizedConfig.ios.runtimeVersion;
143
+ }
144
+ if (typeof normalizedConfig.web?.runtimeVersion === 'string') {
145
+ delete normalizedConfig.web.runtimeVersion;
146
+ }
147
+ }
148
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigNames) {
149
+ normalizedConfig.name = '';
150
+ delete normalizedConfig.description;
151
+ delete normalizedConfig.web?.name;
152
+ delete normalizedConfig.web?.shortName;
153
+ delete normalizedConfig.web?.description;
154
+ }
155
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAndroidPackage) {
156
+ delete normalizedConfig.android?.package;
157
+ }
158
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigIosBundleIdentifier) {
159
+ delete normalizedConfig.ios?.bundleIdentifier;
160
+ }
161
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigSchemes) {
162
+ delete normalizedConfig.scheme;
163
+ normalizedConfig.slug = '';
164
+ }
165
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigEASProject) {
166
+ delete normalizedConfig.owner;
167
+ delete normalizedConfig?.extra?.eas;
168
+ delete normalizedConfig?.updates?.url;
169
+ }
170
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigAssets) {
171
+ delete normalizedConfig.icon;
172
+ delete normalizedConfig.android?.adaptiveIcon;
173
+ delete normalizedConfig.android?.icon;
174
+ delete normalizedConfig.ios?.icon;
175
+ delete normalizedConfig.web?.favicon;
176
+ delete normalizedConfig.web?.splash;
177
+ }
178
+ if (sourceSkips & SourceSkips_1.SourceSkips.ExpoConfigExtraSection) {
179
+ delete normalizedConfig.extra;
180
+ }
181
+ return (0, Utils_1.relativizeJsonPaths)(normalizedConfig, projectRoot);
182
+ }
183
+ /**
184
+ * Gives the last chance to modify the ExpoConfig.
185
+ * For example, we can remove some fields that are already included in the fingerprint.
186
+ */
187
+ function postUpdateExpoConfig(config, projectRoot) {
188
+ // The config is already a clone, so we can modify it in place for performance.
189
+ // googleServicesFile may contain absolute paths on EAS with file-based secrets.
190
+ // Given we include googleServicesFile as external files already, we can remove it from the config.
191
+ delete config.android?.googleServicesFile;
192
+ delete config.ios?.googleServicesFile;
193
+ return config;
194
+ }
195
+ /**
196
+ * Collect iOS icon to flattened file paths.
197
+ */
198
+ function collectIosIcons(icon) {
199
+ if (icon == null) {
200
+ return [];
201
+ }
202
+ if (typeof icon === 'string') {
203
+ return [icon];
204
+ }
205
+ return [icon.light, icon.dark, icon.tinted].filter((file) => Boolean(file));
206
+ }
207
+ /**
208
+ * The filePath in config could be relative (`./assets/icon.png`, `assets/icon.png`) or even absolute.
209
+ * We need to normalize the path and return as relative path without `./` prefix.
210
+ */
211
+ function ensureRelativePath(projectRoot, filePath) {
212
+ const absolutePath = path_1.default.resolve(projectRoot, filePath);
213
+ return path_1.default.relative(projectRoot, absolutePath);
214
+ }
215
+ async function createHashSourceExternalFileAsync({ projectRoot, file, reason, }) {
216
+ const hashSource = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, reason);
217
+ if (!hashSource)
218
+ throw new Error(`Required Expo fingerprint input is missing: ${file}`);
219
+ if (hashSource) {
220
+ debug(`Adding config external file - ${chalk_1.default.dim(file)}`);
221
+ if (hashSource.type === 'file' || hashSource.type === 'dir') {
222
+ // We include the expo config contents in the fingerprint,
223
+ // the `filePath` hashing for the external files is not necessary.
224
+ // Especially people using EAS environment variables for the google service files,
225
+ // the `filePath` will be different between local and remote builds.
226
+ // We use a fixed override hash key and basically ignore the `filePath` hashing.
227
+ hashSource.overrideHashKey = 'expoConfigExternalFile:contentsOnly';
228
+ }
229
+ }
230
+ return hashSource;
231
+ }
232
+ async function getEasBuildSourcesAsync(projectRoot, options) {
233
+ const files = [
234
+ ...(options.sourceSkips & SourceSkips_1.SourceSkips.EasJson ? [] : ['eas.json']),
235
+ ...(options.sourceSkips & SourceSkips_1.SourceSkips.Easignore ? [] : ['.easignore']),
236
+ ];
237
+ const results = (await Promise.all(files.map(async (file) => {
238
+ const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, file, 'easBuild');
239
+ if (result != null) {
240
+ debug(`Adding eas file - ${chalk_1.default.dim(file)}`);
241
+ }
242
+ return result;
243
+ }))).filter(Boolean);
244
+ return results;
245
+ }
246
+ async function getExpoAutolinkingAndroidSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
247
+ if (!options.platforms.includes('android')) {
248
+ return [];
249
+ }
250
+ try {
251
+ const reasons = ['expoAutolinkingAndroid'];
252
+ const results = [];
253
+ const realProjectRoot = await (0, Utils_1.maybeGetRealPathAsync)(projectRoot);
254
+ const { stdout } = await (0, Spawn_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', 'android', '--json'], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
255
+ const config = sortExpoAutolinkingAndroidConfig(JSON.parse(stdout));
256
+ for (const module of config.modules) {
257
+ for (const project of module.projects) {
258
+ const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, project.sourceDir));
259
+ project.sourceDir = filePath; // use relative path for the dir
260
+ debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
261
+ results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
262
+ // `aarProjects` is present in project starting from SDK 53+.
263
+ if (project.aarProjects) {
264
+ for (const aarProject of project.aarProjects) {
265
+ // use relative path for aarProject fields
266
+ aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.aarFilePath));
267
+ aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.projectDir));
268
+ }
269
+ }
270
+ if (typeof project.shouldUsePublicationScriptPath === 'string') {
271
+ project.shouldUsePublicationScriptPath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, project.shouldUsePublicationScriptPath));
272
+ }
273
+ }
274
+ if (module.plugins) {
275
+ for (const plugin of module.plugins) {
276
+ const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, plugin.sourceDir));
277
+ plugin.sourceDir = filePath; // use relative path for the dir
278
+ debug(`Adding expo-modules-autolinking android dir - ${chalk_1.default.dim(filePath)}`);
279
+ results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
280
+ }
281
+ }
282
+ // Backward compatibility for SDK versions earlier than 53
283
+ if (module.aarProjects) {
284
+ for (const aarProject of module.aarProjects) {
285
+ // use relative path for aarProject fields
286
+ aarProject.aarFilePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.aarFilePath));
287
+ aarProject.projectDir = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, aarProject.projectDir));
288
+ }
289
+ }
290
+ }
291
+ results.push({
292
+ type: 'contents',
293
+ id: 'expoAutolinkingConfig:android',
294
+ contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(config, {
295
+ stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
296
+ roots: [realProjectRoot],
297
+ })),
298
+ reasons,
299
+ });
300
+ return results;
301
+ }
302
+ catch (error) {
303
+ throw error;
304
+ }
305
+ }
306
+ /**
307
+ * Gets the patch sources for the `patch-project`.
308
+ */
309
+ async function getExpoCNGPatchSourcesAsync(projectRoot, options) {
310
+ const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'cng-patches', 'expoCNGPatches');
311
+ if (result != null) {
312
+ debug(`Adding dir - ${chalk_1.default.dim('cng-patches')}`);
313
+ return [result];
314
+ }
315
+ return [];
316
+ }
317
+ async function getExpoAutolinkingIosSourcesAsync(projectRoot, options, expoAutolinkingVersion) {
318
+ if (!options.platforms.includes('ios')) {
319
+ return [];
320
+ }
321
+ // expo-modules-autolinking 1.10.0 added support for apple platform
322
+ const platform = semver_1.default.lt(expoAutolinkingVersion, '1.10.0') ? 'ios' : 'apple';
323
+ try {
324
+ const reasons = ['expoAutolinkingIos'];
325
+ const results = [];
326
+ const realProjectRoot = await (0, Utils_1.maybeGetRealPathAsync)(projectRoot);
327
+ const { stdout } = await (0, Spawn_1.default)('node', [(0, ExpoResolver_1.resolveExpoAutolinkingCliPath)(projectRoot), 'resolve', '-p', platform, '--json'], { cwd: projectRoot, env: (0, Env_1.getOriginalEnv)() });
328
+ const config = JSON.parse(stdout);
329
+ for (const module of config.modules) {
330
+ for (const pod of module.pods) {
331
+ const filePath = (0, Path_1.toPosixPath)(path_1.default.relative(realProjectRoot, pod.podspecDir));
332
+ pod.podspecDir = filePath; // use relative path for the dir
333
+ debug(`Adding expo-modules-autolinking ios dir - ${chalk_1.default.dim(filePath)}`);
334
+ results.push(await (0, Utils_1.createAutolinkingHashSourceAsync)(realProjectRoot, filePath, reasons, options.nativeModuleSourceType));
335
+ }
336
+ }
337
+ results.push({
338
+ type: 'contents',
339
+ id: 'expoAutolinkingConfig:ios',
340
+ contents: JSON.stringify((0, Profile_1.profile)(options, AutolinkingConfig_1.normalizeAutolinkingConfig)(config, {
341
+ stripPaths: !!(options.sourceSkips & SourceSkips_1.SourceSkips.AutolinkingConfigPaths),
342
+ roots: [realProjectRoot],
343
+ })),
344
+ reasons,
345
+ });
346
+ return results;
347
+ }
348
+ catch (error) {
349
+ throw error;
350
+ }
351
+ }
352
+ /**
353
+ * Sort the expo-modules-autolinking android config to make it stable from hashing.
354
+ */
355
+ function sortExpoAutolinkingAndroidConfig(config) {
356
+ for (const module of config.modules) {
357
+ // Sort the projects by project.name
358
+ module.projects.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
359
+ }
360
+ return config;
361
+ }
362
+ /**
363
+ * Get the props for a config-plugin
364
+ */
365
+ function getConfigPluginProps(config, pluginName) {
366
+ const plugin = (config.plugins ?? []).find((plugin) => {
367
+ if (Array.isArray(plugin)) {
368
+ return plugin[0] === pluginName;
369
+ }
370
+ return plugin === pluginName;
371
+ });
372
+ if (Array.isArray(plugin)) {
373
+ return (plugin[1] ?? null);
374
+ }
375
+ return null;
376
+ }
@@ -0,0 +1,54 @@
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.getDefaultPackageSourcesAsync = getDefaultPackageSourcesAsync;
7
+ exports.getPackageSourceAsync = getPackageSourceAsync;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const resolve_from_1 = __importDefault(require("resolve-from"));
12
+ const Path_1 = require("../utils/Path");
13
+ const Utils_1 = require("./Utils");
14
+ const debug = require('debug')('expo:fingerprint:sourcer:Packages');
15
+ const DEFAULT_PACKAGES = [
16
+ {
17
+ packageName: 'react-native',
18
+ sourceType: 'package',
19
+ },
20
+ ];
21
+ async function getDefaultPackageSourcesAsync(projectRoot, options) {
22
+ const results = await Promise.all(DEFAULT_PACKAGES.map((params) => getPackageSourceAsync(projectRoot, params)));
23
+ return results.filter(Boolean);
24
+ }
25
+ async function getPackageSourceAsync(projectRoot, params) {
26
+ const reason = `package:${params.packageName}`;
27
+ const packageJsonPath = resolve_from_1.default.silent(projectRoot, `${params.packageName}/package.json`);
28
+ if (packageJsonPath == null) {
29
+ return null;
30
+ }
31
+ debug(`Adding package - ${chalk_1.default.dim(params.packageName)}`);
32
+ if (params.sourceType === 'package') {
33
+ let packageJson;
34
+ try {
35
+ packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, 'utf8'));
36
+ }
37
+ catch (error) {
38
+ // A resolved package.json that can't be read shouldn't crash fingerprinting; skip the source.
39
+ if (error.code === 'ENOENT') {
40
+ return null;
41
+ }
42
+ throw error;
43
+ }
44
+ return {
45
+ type: 'package',
46
+ name: packageJson.name ?? '',
47
+ version: packageJson.version ?? '',
48
+ filePath: (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, packageJsonPath)),
49
+ reasons: [reason],
50
+ };
51
+ }
52
+ const packageRoot = path_1.default.relative(projectRoot, path_1.default.dirname(packageJsonPath));
53
+ return await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, packageRoot, reason);
54
+ }
@@ -0,0 +1,22 @@
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.getPatchPackageSourcesAsync = getPatchPackageSourcesAsync;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const Path_1 = require("../utils/Path");
9
+ const Utils_1 = require("./Utils");
10
+ const debug = require('debug')('expo:fingerprint:sourcer:PatchPackage');
11
+ async function getPatchPackageSourcesAsync(projectRoot, options) {
12
+ if ((0, Path_1.isIgnoredPathWithMatchObjects)('patches', options.ignoreDirMatchObjects)) {
13
+ debug(`Skipping dir - ${chalk_1.default.dim('patches')} (ignored by ignoreDirMatchObjects)`);
14
+ return [];
15
+ }
16
+ const result = await (0, Utils_1.getFileBasedHashSourceAsync)(projectRoot, 'patches', 'patchPackage');
17
+ if (result != null) {
18
+ debug(`Adding dir - ${chalk_1.default.dim('patches')}`);
19
+ return [result];
20
+ }
21
+ return [];
22
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SourceSkips = void 0;
4
+ /**
5
+ * Bitmask of values that can be used to skip certain parts of the sources when generating a fingerprint.
6
+ */
7
+ var SourceSkips;
8
+ (function (SourceSkips) {
9
+ /** Skip nothing. */
10
+ SourceSkips[SourceSkips["None"] = 0] = "None";
11
+ //#region - ExpoConfig source (e.g., app.json, app.config.js, etc.)
12
+ /**
13
+ * Versions in app.json, including `version`, `android.versionCode`, `ios.buildNumber`, and the
14
+ * platform-specific overrides `ios.version` and `android.version` (which take precedence over
15
+ * the top-level `version`).
16
+ */
17
+ SourceSkips[SourceSkips["ExpoConfigVersions"] = 1] = "ExpoConfigVersions";
18
+ /** `runtimeVersion` in app.json if it is a string. */
19
+ SourceSkips[SourceSkips["ExpoConfigRuntimeVersionIfString"] = 2] = "ExpoConfigRuntimeVersionIfString";
20
+ /** App names in app.json, including `name`, `description`, `web.name`, `web.shortName`, and `web.description`. */
21
+ SourceSkips[SourceSkips["ExpoConfigNames"] = 4] = "ExpoConfigNames";
22
+ /** Android package name in app.json. */
23
+ SourceSkips[SourceSkips["ExpoConfigAndroidPackage"] = 8] = "ExpoConfigAndroidPackage";
24
+ /** iOS bundle identifier in app.json. */
25
+ SourceSkips[SourceSkips["ExpoConfigIosBundleIdentifier"] = 16] = "ExpoConfigIosBundleIdentifier";
26
+ /** Schemes in app.json. */
27
+ SourceSkips[SourceSkips["ExpoConfigSchemes"] = 32] = "ExpoConfigSchemes";
28
+ /** EAS project information in app.json. */
29
+ SourceSkips[SourceSkips["ExpoConfigEASProject"] = 64] = "ExpoConfigEASProject";
30
+ /** Assets in app.json, including icons and splash assets. */
31
+ SourceSkips[SourceSkips["ExpoConfigAssets"] = 128] = "ExpoConfigAssets";
32
+ /**
33
+ * Skip the whole ExpoConfig.
34
+ * Prefer the other ExpoConfig source skips when possible and use this flag with caution.
35
+ * This will potentially ignore some native changes that should be part of most fingerprints.
36
+ * E.g., adding a new config plugin, changing the app icon, or changing the app name.
37
+ */
38
+ SourceSkips[SourceSkips["ExpoConfigAll"] = 256] = "ExpoConfigAll";
39
+ //#endregion - ExpoConfig source (e.g., app.json, app.config.js, etc.)
40
+ /**
41
+ * package.json scripts if android and ios items do not contain "run".
42
+ * Because prebuild will change the scripts in package.json,
43
+ * this is useful to generate a consistent fingerprint before and after prebuild.
44
+ */
45
+ SourceSkips[SourceSkips["PackageJsonAndroidAndIosScriptsIfNotContainRun"] = 512] = "PackageJsonAndroidAndIosScriptsIfNotContainRun";
46
+ /**
47
+ * Skip the whole `scripts` section in the project's package.json.
48
+ */
49
+ SourceSkips[SourceSkips["PackageJsonScriptsAll"] = 1024] = "PackageJsonScriptsAll";
50
+ /**
51
+ * Skip .gitignore files.
52
+ */
53
+ SourceSkips[SourceSkips["GitIgnore"] = 2048] = "GitIgnore";
54
+ /** The [extra](https://docs.expo.dev/versions/latest/config/app/#extra) section in app.json */
55
+ SourceSkips[SourceSkips["ExpoConfigExtraSection"] = 4096] = "ExpoConfigExtraSection";
56
+ //#region - EAS Build source
57
+ /**
58
+ * Skip eas.json.
59
+ * Most of its content, such as build profiles and submit settings, does not affect the native
60
+ * project. Note that some fields do, e.g. `ios.buildConfiguration` or `android.gradleCommand`.
61
+ */
62
+ SourceSkips[SourceSkips["EasJson"] = 8192] = "EasJson";
63
+ /**
64
+ * Skip .easignore.
65
+ * The file only controls which files are uploaded to EAS Build.
66
+ * Note that excluding a file that does affect the native build will not change the fingerprint.
67
+ */
68
+ SourceSkips[SourceSkips["Easignore"] = 16384] = "Easignore";
69
+ //#endregion - EAS Build source
70
+ /**
71
+ * Path fields in the resolved autolinking config from `expo-modules-autolinking` and
72
+ * `react-native-config`.
73
+ * The config itself is still hashed. Filesystem paths, and values that sit under the project
74
+ * root, are omitted, including `scriptPhases[].path` and `sourceDir` / `podspecPath` overrides
75
+ * from the project's **react-native.config.js**. Those overrides will not change the fingerprint.
76
+ * Linked module names and `scriptPhases` names remain.
77
+ */
78
+ SourceSkips[SourceSkips["AutolinkingConfigPaths"] = 32768] = "AutolinkingConfigPaths";
79
+ })(SourceSkips || (exports.SourceSkips = SourceSkips = {}));
@@ -0,0 +1,58 @@
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.getHashSourcesAsync = getHashSourcesAsync;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const semver_1 = __importDefault(require("semver"));
9
+ const ExpoConfig_1 = require("../ExpoConfig");
10
+ const ExpoResolver_1 = require("../ExpoResolver");
11
+ const Profile_1 = require("../utils/Profile");
12
+ const Bare_1 = require("./Bare");
13
+ const Expo_1 = require("./Expo");
14
+ const Packages_1 = require("./Packages");
15
+ const PatchPackage_1 = require("./PatchPackage");
16
+ const debug = require('debug')('expo:fingerprint:sourcer:Sourcer');
17
+ async function getHashSourcesAsync(projectRoot, options) {
18
+ const { config: expoConfig, loadedModules } = await (0, ExpoConfig_1.getExpoConfigAsync)(projectRoot, options);
19
+ const expoAutolinkingVersion = (0, ExpoResolver_1.resolveExpoAutolinkingVersion)(projectRoot) ?? '0.0.0';
20
+ const useRNCoreAutolinkingFromExpo =
21
+ // expo-modules-autolinking supports the `react-native-config` core autolinking from 1.11.2.
22
+ // To makes the `useRNCoreAutolinkingFromExpo` default to `true` for Expo SDK 52 and higher.
23
+ // We check the expo-modules-autolinking version from 1.12.0.
24
+ typeof options.useRNCoreAutolinkingFromExpo === 'boolean'
25
+ ? options.useRNCoreAutolinkingFromExpo
26
+ : semver_1.default.gte(expoAutolinkingVersion, '1.12.0');
27
+ const results = await Promise.all([
28
+ // expo
29
+ expoAutolinkingVersion === '0.0.0' ? [] : (0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingAndroidSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
30
+ expoAutolinkingVersion === '0.0.0' ? [] : (0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingIosSourcesAsync)(projectRoot, options, expoAutolinkingVersion),
31
+ (0, Profile_1.profile)(options, Expo_1.getExpoConfigSourcesAsync)(projectRoot, expoConfig, loadedModules, options),
32
+ (0, Profile_1.profile)(options, Expo_1.getEasBuildSourcesAsync)(projectRoot, options),
33
+ (0, Profile_1.profile)(options, Expo_1.getExpoCNGPatchSourcesAsync)(projectRoot, options),
34
+ // bare managed files
35
+ (0, Profile_1.profile)(options, Bare_1.getGitIgnoreSourcesAsync)(projectRoot, options),
36
+ (0, Profile_1.profile)(options, Bare_1.getPackageJsonScriptSourcesAsync)(projectRoot, options),
37
+ // bare native files
38
+ (0, Profile_1.profile)(options, Bare_1.getBareAndroidSourcesAsync)(projectRoot, options),
39
+ (0, Profile_1.profile)(options, Bare_1.getBareIosSourcesAsync)(projectRoot, options),
40
+ // react-native core autolinking
41
+ (0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoAndroid)(projectRoot, options, useRNCoreAutolinkingFromExpo),
42
+ (0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoIos)(projectRoot, options, useRNCoreAutolinkingFromExpo),
43
+ (0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromRncCliAsync)(projectRoot, options, useRNCoreAutolinkingFromExpo),
44
+ // patch-package
45
+ (0, Profile_1.profile)(options, PatchPackage_1.getPatchPackageSourcesAsync)(projectRoot, options),
46
+ // some known dependencies, e.g. react-native
47
+ (0, Profile_1.profile)(options, Packages_1.getDefaultPackageSourcesAsync)(projectRoot, options),
48
+ ]);
49
+ // extra sources
50
+ if (options.extraSources) {
51
+ for (const source of options.extraSources) {
52
+ debug(`Adding extra source - ${chalk_1.default.dim(JSON.stringify(source))}`);
53
+ }
54
+ results.push(options.extraSources);
55
+ }
56
+ // flatten results
57
+ return [].concat(...results);
58
+ }