@gfean/react-native-bundle-drop 0.10.0 → 0.12.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 +60 -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 +9 -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 +1 -0
  22. package/lib/CLI/scripts/upload-cli.js +43 -0
  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 +25 -11
  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,93 @@
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.getExpoConfigAsync = getExpoConfigAsync;
7
+ exports.diffLoadedModules = diffLoadedModules;
8
+ const Env_1 = require("./utils/Env");
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ const os_1 = __importDefault(require("os"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const resolve_from_1 = __importDefault(require("resolve-from"));
13
+ const ExpoConfigLoader_1 = require("./ExpoConfigLoader");
14
+ const SpawnIPC_1 = require("./utils/SpawnIPC");
15
+ const FINGERPRINT_ENV_MODE = process.env.NODE_ENV === 'development' ? 'development' : 'production';
16
+ /**
17
+ * An out-of-process `expo/config` loader that can be used to get the Expo config and loaded modules.
18
+ */
19
+ async function getExpoConfigAsync(projectRoot, options) {
20
+ const result = {
21
+ config: null,
22
+ loadedModules: null,
23
+ };
24
+ if (!resolve_from_1.default.silent(path_1.default.resolve(projectRoot), 'expo/config')) {
25
+ return result;
26
+ }
27
+ const tmpDir = await promises_1.default.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'expo-fingerprint-'));
28
+ const ignoredFile = await createTempIgnoredFileAsync(tmpDir, options);
29
+ try {
30
+ const [{ config, loadedModules: modulesWithPlugins }, { loadedModules: modulesWithoutPlugins },] = await Promise.all([
31
+ spawnConfigLoaderAsync(projectRoot, ignoredFile, /* skipPlugins */ false),
32
+ spawnConfigLoaderAsync(projectRoot, ignoredFile, /* skipPlugins */ true),
33
+ ]);
34
+ result.config = config;
35
+ result.loadedModules = diffLoadedModules(modulesWithPlugins ?? [], modulesWithoutPlugins ?? []);
36
+ }
37
+ catch (e) {
38
+ throw e;
39
+ }
40
+ finally {
41
+ try {
42
+ await promises_1.default.rm(tmpDir, { recursive: true });
43
+ }
44
+ catch { }
45
+ }
46
+ return result;
47
+ }
48
+ async function spawnConfigLoaderAsync(projectRoot, ignoredFile, skipPlugins) {
49
+ const args = [
50
+ (0, ExpoConfigLoader_1.getExpoConfigLoaderPath)(),
51
+ path_1.default.resolve(projectRoot),
52
+ ignoredFile,
53
+ '--mode',
54
+ FINGERPRINT_ENV_MODE,
55
+ ];
56
+ if (skipPlugins) {
57
+ args.push('--skipPlugins');
58
+ }
59
+ const childEnv = (0, Env_1.setNodeEnv)(FINGERPRINT_ENV_MODE, { systemEnv: (0, Env_1.getOriginalEnv)() });
60
+ childEnv.__EXPO_CONFIG_MODE = FINGERPRINT_ENV_MODE;
61
+ const { message } = await (0, SpawnIPC_1.spawnWithIpcAsync)('node', args, { cwd: projectRoot, env: childEnv });
62
+ return JSON.parse(message);
63
+ }
64
+ /**
65
+ * Keep only the config-plugin modules attributable to applying plugins.
66
+ *
67
+ * Anything that also loads when plugins are skipped is the config-loading framework and is dropped.
68
+ * In-repo files are always kept regardless of the diff, so a local plugin imported at the top of
69
+ * `app.config` (which loads during config evaluation, not plugin application) is never lost.
70
+ */
71
+ function diffLoadedModules(withPlugins, withoutPlugins) {
72
+ const skippedKeys = new Set(withoutPlugins.map(getLoadedModuleKey));
73
+ return withPlugins.filter((source) => isInRepoLoadedModule(source) || !skippedKeys.has(getLoadedModuleKey(source)));
74
+ }
75
+ /** Stable identity of a loaded module: its file path, or its id for a virtual module. */
76
+ function getLoadedModuleKey(source) {
77
+ return source.type === 'file' ? source.path : source.id;
78
+ }
79
+ /** Whether a loaded module is a project-local file (e.g. a local config plugin) rather than a dependency. */
80
+ function isInRepoLoadedModule(source) {
81
+ const key = getLoadedModuleKey(source);
82
+ // `..` means the path escaped the project root (e.g. a hoisted or linked dependency).
83
+ return !key.startsWith('..') && !key.includes('node_modules');
84
+ }
85
+ /**
86
+ * Create a temporary file with ignored paths from options that will be read by the ExpoConfigLoader.
87
+ */
88
+ async function createTempIgnoredFileAsync(tmpDir, options) {
89
+ const ignoredFile = path_1.default.join(tmpDir, '.fingerprintignore');
90
+ const ignorePaths = options.ignorePathMatchObjects.map((match) => match.pattern);
91
+ await promises_1.default.writeFile(ignoredFile, ignorePaths.join('\n'));
92
+ return ignoredFile;
93
+ }
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /**
3
+ * A helper script to load the Expo config and loaded plugins from a project
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.installModuleCaptureHook = installModuleCaptureHook;
10
+ exports.resolveLoadedModuleSourcesAsync = resolveLoadedModuleSourcesAsync;
11
+ exports.getExpoConfigLoaderPath = getExpoConfigLoaderPath;
12
+ const Env_1 = require("./utils/Env");
13
+ const promises_1 = __importDefault(require("fs/promises"));
14
+ const module_1 = __importDefault(require("module"));
15
+ const node_process_1 = __importDefault(require("node:process"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const resolve_from_1 = __importDefault(require("resolve-from"));
18
+ const Options_1 = require("./Options");
19
+ const Path_1 = require("./utils/Path");
20
+ async function runAsync(programName, args = []) {
21
+ if (args[0] == null) {
22
+ console.log(`Usage: ${programName} <projectRoot> [ignoredFile] --mode <development|production> [--skipPlugins]`);
23
+ return;
24
+ }
25
+ const projectRoot = path_1.default.resolve(args[0]);
26
+ const skipPlugins = args.includes('--skipPlugins');
27
+ const ignoredFileArg = args[1] && !args[1].startsWith('--') ? args[1] : null;
28
+ const ignoredFile = ignoredFileArg ? path_1.default.resolve(ignoredFileArg) : null;
29
+ const modeFlagIndex = args.indexOf('--mode');
30
+ const mode = modeFlagIndex >= 0 ? args[modeFlagIndex + 1] : undefined;
31
+ if (mode !== 'development' && mode !== 'production') {
32
+ throw new Error(`Unsupported Expo config mode: ${mode}`);
33
+ }
34
+ globalThis.__DEV__ = mode === 'development';
35
+ (0, Env_1.loadProjectEnv)(projectRoot, { mode });
36
+ const { getCapturedModules, uninstall } = installModuleCaptureHook();
37
+ let config;
38
+ try {
39
+ const { getConfig } = require((0, resolve_from_1.default)(path_1.default.resolve(projectRoot), 'expo/config'));
40
+ config = await getConfig(projectRoot, {
41
+ skipSDKVersionRequirement: true,
42
+ skipPlugins,
43
+ });
44
+ }
45
+ finally {
46
+ uninstall();
47
+ }
48
+ const ignoredPaths = [
49
+ ...DEFAULT_CONFIG_LOADING_IGNORE_PATHS,
50
+ ...(await loadIgnoredPathsAsync(ignoredFile)),
51
+ ];
52
+ const loadedModules = await resolveLoadedModuleSourcesAsync(getCapturedModules(), projectRoot, ignoredPaths);
53
+ const result = JSON.stringify({
54
+ // The plugins-skipped pass only contributes its module list to the diff; its config is unused.
55
+ config: skipPlugins ? null : config,
56
+ loadedModules,
57
+ });
58
+ if (node_process_1.default.send) {
59
+ node_process_1.default.send(result);
60
+ }
61
+ else {
62
+ console.log(result);
63
+ }
64
+ }
65
+ // If running from the command line
66
+ if (require.main?.filename === __filename) {
67
+ (async () => {
68
+ const programIndex = node_process_1.default.argv.findIndex((arg) => arg === __filename);
69
+ const programName = node_process_1.default.argv[programIndex] ?? __filename;
70
+ try {
71
+ await runAsync(programName, node_process_1.default.argv.slice(programIndex + 1));
72
+ }
73
+ catch (e) {
74
+ console.error('Uncaught Error', e);
75
+ node_process_1.default.exit(1);
76
+ }
77
+ })();
78
+ }
79
+ /**
80
+ * Load the generated ignored paths file from caller and remove the file after loading
81
+ */
82
+ async function loadIgnoredPathsAsync(ignoredFile) {
83
+ if (!ignoredFile) {
84
+ return Options_1.DEFAULT_IGNORE_PATHS;
85
+ }
86
+ const ignorePaths = [];
87
+ try {
88
+ const fingerprintIgnore = await promises_1.default.readFile(ignoredFile, 'utf8');
89
+ const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
90
+ for (const line of fingerprintIgnoreLines) {
91
+ const trimmedLine = line.trim();
92
+ if (trimmedLine) {
93
+ ignorePaths.push(trimmedLine);
94
+ }
95
+ }
96
+ }
97
+ catch { }
98
+ return ignorePaths;
99
+ }
100
+ /**
101
+ * Observe every CommonJS module compiled while the hook is installed.
102
+ * We hook `Module.prototype._compile` to keep each module's authoritative filename and source
103
+ * content. Every argument is forwarded: Node 22.18+ passes a `format` argument that tells it to
104
+ * strip types from a `.ts` file.
105
+ */
106
+ function installModuleCaptureHook() {
107
+ const moduleProto = module_1.default.prototype;
108
+ const capturedModules = [];
109
+ const originalCompile = moduleProto._compile;
110
+ moduleProto._compile = function (content, filename, ...rest) {
111
+ capturedModules.push({ id: this.id ?? filename, filename, content });
112
+ return originalCompile.call(this, content, filename, ...rest);
113
+ };
114
+ return {
115
+ getCapturedModules: () => capturedModules,
116
+ uninstall: () => {
117
+ moduleProto._compile = originalCompile;
118
+ },
119
+ };
120
+ }
121
+ /**
122
+ * Turn captured modules into config-plugin sources, dropping ignored paths.
123
+ * A real file becomes a `file` source; a module with no file on disk (virtual / compiled from a
124
+ * string) becomes a `contents` source keyed by its project-relative path so it stays stable across
125
+ * runs. A path that exists but is not a file (e.g. a directory) is skipped.
126
+ */
127
+ async function resolveLoadedModuleSourcesAsync(capturedModules, projectRoot, ignoredPaths) {
128
+ const seen = new Set();
129
+ const ignoredPathMatchObjects = (0, Path_1.buildPathMatchObjects)(ignoredPaths);
130
+ const candidates = capturedModules
131
+ .map(({ filename, content }) => ({
132
+ relativePath: (0, Path_1.toPosixPath)(path_1.default.relative(projectRoot, filename)),
133
+ filename,
134
+ content,
135
+ }))
136
+ .filter(({ relativePath }) => {
137
+ if (seen.has(relativePath) ||
138
+ (0, Path_1.isIgnoredPathWithMatchObjects)(relativePath, ignoredPathMatchObjects)) {
139
+ return false;
140
+ }
141
+ seen.add(relativePath);
142
+ return true;
143
+ });
144
+ const sources = await Promise.all(candidates.map(async ({ relativePath, filename, content }) => {
145
+ try {
146
+ const stat = await promises_1.default.stat(filename);
147
+ return stat.isFile() ? { type: 'file', path: relativePath } : null;
148
+ }
149
+ catch (error) {
150
+ if (error.code === 'ENOENT') {
151
+ return { type: 'contents', id: relativePath, contents: content };
152
+ }
153
+ throw error;
154
+ }
155
+ }));
156
+ return sources.filter((source) => source !== null);
157
+ }
158
+ /**
159
+ * Get the path to the ExpoConfigLoader file.
160
+ */
161
+ function getExpoConfigLoaderPath() {
162
+ return path_1.default.join(__dirname, 'ExpoConfigLoader.js');
163
+ }
164
+ // Ignore known non-native packages loaded while applying config plugins, which the plugins-skipped
165
+ // diff can't drop since they only load during plugin application.
166
+ const DEFAULT_CONFIG_LOADING_IGNORE_PATHS = [
167
+ '**/node_modules/@expo/**/*',
168
+ `**/node_modules/{${[
169
+ 'ansi-styles',
170
+ 'base64-js',
171
+ 'big-integer',
172
+ 'bplist-creator',
173
+ 'chalk',
174
+ 'cross-spawn',
175
+ 'debug',
176
+ 'has-flag',
177
+ 'isexe',
178
+ 'jimp-compact',
179
+ 'ms',
180
+ 'parse-png',
181
+ 'path-key',
182
+ 'plist',
183
+ 'pngjs',
184
+ // The loader and the project's plugins can resolve different copies. Its
185
+ // module-cache warmness must not turn this JS resolution helper into a
186
+ // native input when the CLI is installed outside the app checkout.
187
+ 'resolve-from',
188
+ 'sax',
189
+ 'semver',
190
+ 'shebang-command',
191
+ 'shebang-regex',
192
+ 'simple-plist',
193
+ 'stream-buffers',
194
+ 'supports-color',
195
+ 'uuid',
196
+ 'which',
197
+ 'xcode',
198
+ 'xml2js',
199
+ 'xmlbuilder',
200
+ ].join(',')}}/**/*`,
201
+ ];
@@ -0,0 +1,84 @@
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.resolveExpoVersion = resolveExpoVersion;
7
+ exports.resolveExpoAutolinkingPackageRoot = resolveExpoAutolinkingPackageRoot;
8
+ exports.resolveExpoAutolinkingCliPath = resolveExpoAutolinkingCliPath;
9
+ exports.resolveExpoAutolinkingVersion = resolveExpoAutolinkingVersion;
10
+ exports.resolveExpoConfigPluginsPackagePath = resolveExpoConfigPluginsPackagePath;
11
+ exports.satisfyExpoVersion = satisfyExpoVersion;
12
+ const path_1 = __importDefault(require("path"));
13
+ const resolve_from_1 = __importDefault(require("resolve-from"));
14
+ const semver_1 = __importDefault(require("semver"));
15
+ let cachedExpoAutolinkingPackageRoot = null;
16
+ /**
17
+ * Resolve the version of `expo` package in the project.
18
+ */
19
+ function resolveExpoVersion(projectRoot) {
20
+ const expoPackageJsonPath = resolve_from_1.default.silent(projectRoot, 'expo/package.json');
21
+ if (expoPackageJsonPath) {
22
+ const expoPackageJson = require(expoPackageJsonPath);
23
+ return expoPackageJson.version;
24
+ }
25
+ return null;
26
+ }
27
+ /**
28
+ * Resolve the package root of `expo-modules-autolinking` package in the project.
29
+ */
30
+ function resolveExpoAutolinkingPackageRoot(projectRoot) {
31
+ if (cachedExpoAutolinkingPackageRoot) {
32
+ const [cachedProjectRoot, cachedPackageRoot] = cachedExpoAutolinkingPackageRoot;
33
+ if (cachedProjectRoot === projectRoot) {
34
+ return cachedPackageRoot;
35
+ }
36
+ }
37
+ const expoPackageRoot = resolve_from_1.default.silent(projectRoot, 'expo/package.json');
38
+ const autolinkingPackageJsonPath = resolve_from_1.default.silent(expoPackageRoot ?? projectRoot, 'expo-modules-autolinking/package.json');
39
+ if (autolinkingPackageJsonPath) {
40
+ const autolinkingPackageRoot = path_1.default.dirname(autolinkingPackageJsonPath);
41
+ cachedExpoAutolinkingPackageRoot = [projectRoot, autolinkingPackageRoot];
42
+ return autolinkingPackageRoot;
43
+ }
44
+ return null;
45
+ }
46
+ /**
47
+ * Resolve the path to the `expo-modules-autolinking` CLI in the project.
48
+ * @throws If the package is not found in the project.
49
+ */
50
+ function resolveExpoAutolinkingCliPath(projectRoot) {
51
+ const autolinkingPackageRoot = resolveExpoAutolinkingPackageRoot(projectRoot);
52
+ if (autolinkingPackageRoot == null) {
53
+ throw new Error('Cannot resolve expo-modules-autolinking package in the project.');
54
+ }
55
+ return path_1.default.join(autolinkingPackageRoot, 'bin', 'expo-modules-autolinking.js');
56
+ }
57
+ /**
58
+ * Resolve the version of `expo-modules-autolinking` package in the project.
59
+ */
60
+ function resolveExpoAutolinkingVersion(projectRoot) {
61
+ const autolinkingPackageRoot = resolveExpoAutolinkingPackageRoot(projectRoot);
62
+ if (autolinkingPackageRoot) {
63
+ const autolinkingPackageJson = require(path_1.default.join(autolinkingPackageRoot, 'package.json'));
64
+ return autolinkingPackageJson.version;
65
+ }
66
+ return null;
67
+ }
68
+ /**
69
+ * Resolve the package root of `expo/config-plugins` package in the project.
70
+ */
71
+ function resolveExpoConfigPluginsPackagePath(projectRoot) {
72
+ return resolve_from_1.default.silent(projectRoot, 'expo/config-plugins') ?? null;
73
+ }
74
+ /**
75
+ * Resolve the `expo` package version and check if it satisfies the provided semver range.
76
+ * @returns `null` if the `expo` package is not found in the project.
77
+ */
78
+ function satisfyExpoVersion(projectRoot, range) {
79
+ const expoVersion = resolveExpoVersion(projectRoot);
80
+ if (expoVersion) {
81
+ return semver_1.default.satisfies(expoVersion, range);
82
+ }
83
+ return null;
84
+ }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFingerprintAsync = createFingerprintAsync;
4
+ exports.createProjectHashAsync = createProjectHashAsync;
5
+ exports.diffFingerprintChangesAsync = diffFingerprintChangesAsync;
6
+ exports.diffFingerprints = diffFingerprints;
7
+ const Dedup_1 = require("./Dedup");
8
+ const Options_1 = require("./Options");
9
+ const Sort_1 = require("./Sort");
10
+ const Hash_1 = require("./hash/Hash");
11
+ const Sourcer_1 = require("./sourcer/Sourcer");
12
+ /**
13
+ * Create a fingerprint for a project.
14
+ * @example
15
+ * ```js
16
+ * const fingerprint = await createFingerprintAsync('/app');
17
+ * console.log(fingerprint);
18
+ * ```
19
+ */
20
+ async function createFingerprintAsync(projectRoot, options) {
21
+ const opts = await (0, Options_1.normalizeOptionsAsync)(projectRoot, options);
22
+ const sources = await (0, Sourcer_1.getHashSourcesAsync)(projectRoot, opts);
23
+ const normalizedSources = (0, Sort_1.sortSources)((0, Dedup_1.dedupSources)(sources, projectRoot));
24
+ const fingerprint = await (0, Hash_1.createFingerprintFromSourcesAsync)(normalizedSources, projectRoot, opts);
25
+ return fingerprint;
26
+ }
27
+ /**
28
+ * Create a native hash value for a project.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const hash = await createProjectHashAsync('/app');
33
+ * console.log(hash);
34
+ * ```
35
+ */
36
+ async function createProjectHashAsync(projectRoot, options) {
37
+ const fingerprint = await createFingerprintAsync(projectRoot, options);
38
+ return fingerprint.hash;
39
+ }
40
+ /**
41
+ * Diff the fingerprint with the fingerprint of the provided project.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * // Create a fingerprint for the project
46
+ * const fingerprint = await createFingerprintAsync('/app');
47
+ *
48
+ * // Make some changes to the project
49
+ *
50
+ * // Calculate the diff
51
+ * const diff = await diffFingerprintChangesAsync(fingerprint, '/app');
52
+ * console.log(diff);
53
+ * ```
54
+ */
55
+ async function diffFingerprintChangesAsync(fingerprint, projectRoot, options) {
56
+ const newFingerprint = await createFingerprintAsync(projectRoot, options);
57
+ if (fingerprint.hash === newFingerprint.hash) {
58
+ return [];
59
+ }
60
+ return diffFingerprints(fingerprint, newFingerprint);
61
+ }
62
+ /**
63
+ * Diff two fingerprints. The implementation assumes that the sources are sorted.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * // Create a fingerprint for the project
68
+ * const fingerprint = await createFingerprintAsync('/app');
69
+ *
70
+ * // Make some changes to the project
71
+ *
72
+ * // Create a fingerprint again
73
+ * const fingerprint2 = await createFingerprintAsync('/app');
74
+ * const diff = await diffFingerprints(fingerprint, fingerprint2);
75
+ * console.log(diff);
76
+ * ```
77
+ */
78
+ function diffFingerprints(fingerprint1, fingerprint2) {
79
+ let index1 = 0;
80
+ let index2 = 0;
81
+ let source1 = fingerprint1.sources[index1];
82
+ let source2 = fingerprint2.sources[index2];
83
+ const diff = [];
84
+ while (source1 != null && source2 != null) {
85
+ const compareResult = (0, Sort_1.compareSource)(source1, source2);
86
+ if (compareResult === 0) {
87
+ if (source1.hash !== source2.hash) {
88
+ diff.push({ op: 'changed', beforeSource: source1, afterSource: source2 });
89
+ }
90
+ source1 = fingerprint1.sources[++index1];
91
+ source2 = fingerprint2.sources[++index2];
92
+ }
93
+ else if (compareResult < 0) {
94
+ diff.push({ op: 'removed', removedSource: source1 });
95
+ source1 = fingerprint1.sources[++index1];
96
+ }
97
+ else {
98
+ diff.push({ op: 'added', addedSource: source2 });
99
+ source2 = fingerprint2.sources[++index2];
100
+ }
101
+ }
102
+ while (source1 != null) {
103
+ diff.push({ op: 'removed', removedSource: source1 });
104
+ source1 = fingerprint1.sources[++index1];
105
+ }
106
+ while (source2 != null) {
107
+ diff.push({ op: 'added', addedSource: source2 });
108
+ source2 = fingerprint2.sources[++index2];
109
+ }
110
+ return diff;
111
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //#endregion
@@ -0,0 +1,140 @@
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.DEFAULT_SOURCE_SKIPS = exports.DEFAULT_IGNORE_PATHS = exports.FINGERPRINT_IGNORE_FILENAME = void 0;
7
+ exports.normalizeOptionsAsync = normalizeOptionsAsync;
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const os_1 = __importDefault(require("os"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const ExpoResolver_1 = require("./ExpoResolver");
12
+ const Presets_1 = require("./Presets");
13
+ const ProjectWorkflow_1 = require("./ProjectWorkflow");
14
+ const Path_1 = require("./utils/Path");
15
+ exports.FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore';
16
+ exports.DEFAULT_IGNORE_PATHS = [
17
+ exports.FINGERPRINT_IGNORE_FILENAME,
18
+ // Android
19
+ '**/android/build/**/*',
20
+ '**/android/.cxx/**/*',
21
+ '**/android/.gradle/**/*',
22
+ '**/android/app/build/**/*',
23
+ '**/android/app/.cxx/**/*',
24
+ '**/android/app/.gradle/**/*',
25
+ '**/android-annotation/build/**/*',
26
+ '**/android-annotation/.cxx/**/*',
27
+ '**/android-annotation/.gradle/**/*',
28
+ '**/android-annotation-processor/build/**/*',
29
+ '**/android-annotation-processor/.cxx/**/*',
30
+ '**/android-annotation-processor/.gradle/**/*',
31
+ // Often has different line endings, thus we have to ignore it
32
+ '**/android/gradlew.bat',
33
+ // Android gradle plugins
34
+ '**/*-gradle-plugin/build/**/*',
35
+ '**/*-gradle-plugin/.cxx/**/*',
36
+ '**/*-gradle-plugin/.gradle/**/*',
37
+ // iOS
38
+ '**/ios/Pods/**/*',
39
+ '**/ios/build/**/*',
40
+ '**/ios/.xcode.env.local',
41
+ '**/ios/**/project.xcworkspace',
42
+ '**/ios/*.xcworkspace/xcuserdata/**/*',
43
+ '**/.swiftpm/**/*',
44
+ // System files that differ from machine to machine
45
+ '**/.DS_Store',
46
+ // Ignore all expo configs because we will read expo config in a HashSourceContents already
47
+ 'app.config.ts',
48
+ 'app.config.js',
49
+ 'app.config.json',
50
+ 'app.json',
51
+ // Ignore CocoaPods generated files
52
+ // https://github.com/expo/expo/blob/d0e39858ead9a194d90990f89903e773b9d33582/packages/expo-sqlite/ios/ExpoSQLite.podspec#L25-L36
53
+ // https://github.com/expo/expo/blob/d0e39858ead9a194d90990f89903e773b9d33582/packages/expo-updates/ios/EXUpdates.podspec#L51-L58
54
+ '**/node_modules/expo-sqlite/ios/sqlite3.[ch]',
55
+ '**/node_modules/expo-updates/ios/EXUpdates/BSPatch/bspatch.c',
56
+ // expo-modules-jsi has build artifacts
57
+ '**/node_modules/expo-modules-jsi/apple/{Products,.build,.DerivedData,.generated}/**/*',
58
+ // Ignore node binaries that might be platform dependent
59
+ '**/node_modules/**/*.node',
60
+ '**/node_modules/@img/sharp-*/**/*',
61
+ '**/node_modules/sharp/{build,vendor}/**/*',
62
+ // Precompiled autolinking patches for external packages
63
+ '**/node_modules/**/*.podspec.json',
64
+ // Ignore known 3rd party binaries artifacts
65
+ // It happens mostly on iOS because the autolinking root is the whole package root as its podspec
66
+ '**/node_modules/@shopify/react-native-skia/libs/**/*',
67
+ ];
68
+ exports.DEFAULT_SOURCE_SKIPS = (0, Presets_1.resolvePreset)(Presets_1.DEFAULT_PRESET).sourceSkips;
69
+ async function normalizeOptionsAsync(projectRoot, options) {
70
+ // Bundle Drop's versioned options are the sole calculation authority.
71
+ const config = null;
72
+ const preset = (0, Presets_1.resolvePreset)(options?.preset ?? config?.preset ?? Presets_1.DEFAULT_PRESET);
73
+ const ignorePathMatchObjects = await collectIgnorePathsAsync(projectRoot, config?.ignorePaths, options);
74
+ const useCNGForPlatforms = await resolveUseCNGAsync(projectRoot, options, ignorePathMatchObjects);
75
+ if (useCNGForPlatforms.android) {
76
+ (0, Path_1.appendIgnorePath)(ignorePathMatchObjects, 'android/**/*');
77
+ }
78
+ if (useCNGForPlatforms.ios) {
79
+ (0, Path_1.appendIgnorePath)(ignorePathMatchObjects, 'ios/**/*');
80
+ }
81
+ return {
82
+ // Defaults, derived from the resolved preset
83
+ platforms: ['android', 'ios'],
84
+ concurrentIoLimit: os_1.default.cpus().length,
85
+ hashAlgorithm: 'sha1',
86
+ sourceSkips: preset.sourceSkips,
87
+ nativeModuleSourceType: preset.nativeModuleSourceType,
88
+ configPluginSourceType: preset.configPluginSourceType,
89
+ // Options from config
90
+ ...config,
91
+ // Explicit options (any explicitly provided value replaces the preset default)
92
+ ...Object.fromEntries(Object.entries(options ?? {}).filter(([_, v]) => v != null)),
93
+ // These options are computed by both default and explicit options, so we put them last.
94
+ enableReactImportsPatcher: options?.enableReactImportsPatcher ??
95
+ config?.enableReactImportsPatcher ??
96
+ (0, ExpoResolver_1.satisfyExpoVersion)(projectRoot, '<52.0.0') ??
97
+ false,
98
+ ignorePathMatchObjects,
99
+ ignoreDirMatchObjects: (0, Path_1.buildDirMatchObjects)(ignorePathMatchObjects),
100
+ useCNGForPlatforms,
101
+ };
102
+ }
103
+ async function collectIgnorePathsAsync(projectRoot, pathsFromConfig, options) {
104
+ const ignorePaths = [
105
+ ...exports.DEFAULT_IGNORE_PATHS,
106
+ ...(pathsFromConfig ?? []),
107
+ ...(options?.ignorePaths ?? []),
108
+ ...(options?.dirExcludes?.map((dirExclude) => `${dirExclude}/**/*`) ?? []),
109
+ ];
110
+ const fingerprintIgnorePath = path_1.default.join(projectRoot, exports.FINGERPRINT_IGNORE_FILENAME);
111
+ try {
112
+ const fingerprintIgnore = await promises_1.default.readFile(fingerprintIgnorePath, 'utf8');
113
+ const fingerprintIgnoreLines = fingerprintIgnore.split('\n');
114
+ for (const line of fingerprintIgnoreLines) {
115
+ const trimmedLine = line.trim();
116
+ if (trimmedLine) {
117
+ ignorePaths.push(trimmedLine);
118
+ }
119
+ }
120
+ }
121
+ catch { }
122
+ return (0, Path_1.buildPathMatchObjects)(ignorePaths);
123
+ }
124
+ async function resolveUseCNGAsync(projectRoot, options, ignorePathMatchObjects) {
125
+ const results = {
126
+ android: false,
127
+ ios: false,
128
+ };
129
+ const platforms = options?.platforms ?? ['android', 'ios'];
130
+ for (const platform of platforms) {
131
+ const explicitMode = options?.bundleDropNativeProjectMode?.[platform];
132
+ if (explicitMode) {
133
+ results[platform] = explicitMode === 'cng';
134
+ continue;
135
+ }
136
+ const projectWorkflow = await (0, ProjectWorkflow_1.resolveProjectWorkflowAsync)(projectRoot, platform, ignorePathMatchObjects);
137
+ results[platform] = projectWorkflow === 'managed';
138
+ }
139
+ return results;
140
+ }