@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.
- package/BundleDrop.podspec +17 -20
- package/README.md +60 -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 +9 -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 +1 -0
- package/lib/CLI/scripts/upload-cli.js +43 -0
- 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 +25 -11
- 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
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { RuntimeCompatibilityMetadata } from './runtimeCompatibilityMetadata';
|
|
1
2
|
export type CanonicalArtifactPlatform = 'ios' | 'android';
|
|
2
3
|
export type CanonicalAssetTraversal = 'strict' | 'legacy-bare';
|
|
3
4
|
export type BuildCanonicalArtifactOptions = {
|
|
4
5
|
platform: CanonicalArtifactPlatform;
|
|
5
6
|
appVersion: string;
|
|
6
7
|
runtimeVersion: string;
|
|
8
|
+
runtimeCompatibility?: RuntimeCompatibilityMetadata;
|
|
9
|
+
buildNumber?: string | null;
|
|
7
10
|
bundlePath: string;
|
|
8
11
|
assetsDir: string;
|
|
9
12
|
outputDir: string;
|
|
@@ -130,7 +130,7 @@ const collectLegacyBareAssets = (assetsDir) => {
|
|
|
130
130
|
* ZIP roles. Framework-specific export commands must finish before this runs.
|
|
131
131
|
*/
|
|
132
132
|
function buildCanonicalArtifact(options) {
|
|
133
|
-
const { platform, appVersion, runtimeVersion, bundlePath, assetsDir, outputDir, sourceMapPath, assetTraversal = 'strict', } = options;
|
|
133
|
+
const { platform, appVersion, runtimeVersion, runtimeCompatibility = { compatibilitySource: 'manual' }, buildNumber, bundlePath, assetsDir, outputDir, sourceMapPath, assetTraversal = 'strict', } = options;
|
|
134
134
|
if (!appVersion.trim())
|
|
135
135
|
throw new Error('Canonical artifact requires an app version');
|
|
136
136
|
if (!runtimeVersion.trim())
|
|
@@ -153,6 +153,8 @@ function buildCanonicalArtifact(options) {
|
|
|
153
153
|
bundlePath: 'main.jsbundle',
|
|
154
154
|
sizeInBytes: bundleBuffer.length,
|
|
155
155
|
runtimeVersion,
|
|
156
|
+
...runtimeCompatibility,
|
|
157
|
+
...(buildNumber != null ? { buildNumber } : {}),
|
|
156
158
|
};
|
|
157
159
|
const metadataBuffer = Buffer.from(JSON.stringify(metadata, null, 2));
|
|
158
160
|
const stagedFiles = new Map([
|
|
@@ -10,6 +10,8 @@ const expo_1 = require("../expo");
|
|
|
10
10
|
const build_receipt_1 = require("../CLI/scripts/expo/build-receipt");
|
|
11
11
|
const canonicalArtifact_1 = require("./canonicalArtifact");
|
|
12
12
|
const bundle_1 = require("./bundle");
|
|
13
|
+
const runtimeVersion_1 = require("../expo/runtimeVersion");
|
|
14
|
+
const nativeBuildNumber_1 = require("./nativeBuildNumber");
|
|
13
15
|
const getExpoArtifactRoot = (projectRoot) => path_1.default.join(projectRoot, '.bundle-drop', 'artifacts');
|
|
14
16
|
const assertExpoUpdatesDoesNotOwnExport = (projectRoot) => {
|
|
15
17
|
const { exp } = (0, expo_1.evaluateExpoConfig)(projectRoot);
|
|
@@ -62,10 +64,19 @@ async function exportProjectArtifact(options) {
|
|
|
62
64
|
const sourceMapPath = path_1.default.join(outputDir, 'main.jsbundle.map');
|
|
63
65
|
fs_extra_1.default.copyFileSync(exported.bundlePath, bundlePath);
|
|
64
66
|
fs_extra_1.default.copyFileSync(exported.sourceMapPath, sourceMapPath);
|
|
67
|
+
const selection = (0, runtimeVersion_1.readBundleDropRuntimeSelection)(projectRoot, options.platform);
|
|
68
|
+
const runtimeCompatibility = selection.source === 'fingerprint'
|
|
69
|
+
? {
|
|
70
|
+
compatibilitySource: 'fingerprint',
|
|
71
|
+
fingerprint: { schemeVersion: 1, hash: buildIdentity.runtimeVersion, manualBoundary: selection.boundary },
|
|
72
|
+
}
|
|
73
|
+
: { compatibilitySource: 'manual' };
|
|
65
74
|
const artifact = (0, canonicalArtifact_1.buildCanonicalArtifact)({
|
|
66
75
|
platform: options.platform,
|
|
67
76
|
appVersion: buildIdentity.appVersion,
|
|
68
77
|
runtimeVersion: buildIdentity.runtimeVersion,
|
|
78
|
+
runtimeCompatibility,
|
|
79
|
+
buildNumber: (0, nativeBuildNumber_1.expoBuildNumber)(buildIdentity),
|
|
69
80
|
bundlePath,
|
|
70
81
|
assetsDir: exported.assetsDirectory,
|
|
71
82
|
outputDir,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExpoBuildIdentity, MobilePlatform } from '../expo/types';
|
|
2
|
+
/** Optional upload context, never a runtime compatibility input. */
|
|
3
|
+
export declare function normalizeBuildNumber(value: unknown, platform: MobilePlatform): string | null;
|
|
4
|
+
export declare function expoBuildNumber(identity: ExpoBuildIdentity): string | null;
|
|
5
|
+
/** Recognize literal statements only; do not evaluate Gradle or select a flavor. */
|
|
6
|
+
export declare function androidBuildNumber(source: string): string | null;
|
|
7
|
+
export declare function readAndroidBuildNumber(projectRoot: string, gradlePath?: string): string | null;
|
|
8
|
+
/** Resolve only the exact standard variable with unambiguous literal settings. */
|
|
9
|
+
export declare function iosBuildNumber(raw: unknown, projectRoot: string): string | null;
|
|
@@ -0,0 +1,110 @@
|
|
|
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.normalizeBuildNumber = normalizeBuildNumber;
|
|
7
|
+
exports.expoBuildNumber = expoBuildNumber;
|
|
8
|
+
exports.androidBuildNumber = androidBuildNumber;
|
|
9
|
+
exports.readAndroidBuildNumber = readAndroidBuildNumber;
|
|
10
|
+
exports.iosBuildNumber = iosBuildNumber;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
/** Optional upload context, never a runtime compatibility input. */
|
|
14
|
+
function normalizeBuildNumber(value, platform) {
|
|
15
|
+
if (typeof value !== 'string' && typeof value !== 'number')
|
|
16
|
+
return null;
|
|
17
|
+
const number = String(value).trim();
|
|
18
|
+
if (platform === 'ios')
|
|
19
|
+
return /^\d+(?:\.\d+){0,2}$/.test(number) && number.length <= 64 ? number : null;
|
|
20
|
+
return /^\d+$/.test(number) && Number.isSafeInteger(Number(number)) &&
|
|
21
|
+
Number(number) > 0 && Number(number) <= 2100000000 ? number : null;
|
|
22
|
+
}
|
|
23
|
+
function expoBuildNumber(identity) {
|
|
24
|
+
const prefix = `${identity.appVersion}(`;
|
|
25
|
+
if (!identity.nativeVersion.startsWith(prefix) || !identity.nativeVersion.endsWith(')'))
|
|
26
|
+
return null;
|
|
27
|
+
return normalizeBuildNumber(identity.nativeVersion.slice(prefix.length, -1), identity.platform);
|
|
28
|
+
}
|
|
29
|
+
function buildTokens(source) {
|
|
30
|
+
const pattern = /\/\*[\s\S]*?\*\/|\/\/[^\r\n]*|"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_$][\w$]*|\d+(?:[A-Za-z_][\w]*)?|\r?\n|[^\s]/g;
|
|
31
|
+
return [...source.matchAll(pattern)].map(match => match[0])
|
|
32
|
+
.filter(token => !token.startsWith('//') && !token.startsWith('/*'));
|
|
33
|
+
}
|
|
34
|
+
/** Recognize literal statements only; do not evaluate Gradle or select a flavor. */
|
|
35
|
+
function androidBuildNumber(source) {
|
|
36
|
+
const tokens = buildTokens(source);
|
|
37
|
+
if (tokens.some(token => ['/', '"', "'", 'productFlavors', 'setVersionCode', 'versionCodeOverride'].includes(token)))
|
|
38
|
+
return null;
|
|
39
|
+
if (tokens.filter(token => token === 'versionCode').length !== 1)
|
|
40
|
+
return null;
|
|
41
|
+
const scopes = [];
|
|
42
|
+
const index = tokens.indexOf('versionCode');
|
|
43
|
+
for (let cursor = 0; cursor < index; cursor++) {
|
|
44
|
+
const token = tokens[cursor];
|
|
45
|
+
if (token === '{')
|
|
46
|
+
scopes.push(tokens[cursor - 1] ?? '');
|
|
47
|
+
else if (token === '}')
|
|
48
|
+
scopes.pop();
|
|
49
|
+
}
|
|
50
|
+
if (scopes[scopes.length - 1] !== 'defaultConfig' || !['{', '\n', '\r\n', ';'].includes(tokens[index - 1]))
|
|
51
|
+
return null;
|
|
52
|
+
const numberIndex = index + (tokens[index + 1] === '=' ? 2 : 1);
|
|
53
|
+
const after = tokens[numberIndex + 1];
|
|
54
|
+
if (after !== undefined && !['\n', '\r\n', ';', '}'].includes(after))
|
|
55
|
+
return null;
|
|
56
|
+
// A continuation on the next line is still an expression.
|
|
57
|
+
const next = tokens.slice(numberIndex + 1).find(item => !['\n', '\r\n'].includes(item));
|
|
58
|
+
if (['\n', '\r\n'].includes(after) && next && /^[+\-*%?.:(\[{&|^<>=!,]$/.test(next))
|
|
59
|
+
return null;
|
|
60
|
+
return normalizeBuildNumber(tokens[numberIndex], 'android');
|
|
61
|
+
}
|
|
62
|
+
function readAndroidBuildNumber(projectRoot, gradlePath) {
|
|
63
|
+
const candidates = gradlePath ? [path_1.default.resolve(projectRoot, gradlePath)] : [
|
|
64
|
+
path_1.default.join(projectRoot, 'android/app/build.gradle'),
|
|
65
|
+
path_1.default.join(projectRoot, 'android/app/build.gradle.kts'),
|
|
66
|
+
];
|
|
67
|
+
const files = candidates.filter(file => fs_1.default.existsSync(file));
|
|
68
|
+
if (files.length !== 1)
|
|
69
|
+
return null;
|
|
70
|
+
return androidBuildNumber(fs_1.default.readFileSync(files[0], 'utf8'));
|
|
71
|
+
}
|
|
72
|
+
/** Resolve only the exact standard variable with unambiguous literal settings. */
|
|
73
|
+
function iosBuildNumber(raw, projectRoot) {
|
|
74
|
+
if (raw !== '$(CURRENT_PROJECT_VERSION)' && raw !== '${CURRENT_PROJECT_VERSION}')
|
|
75
|
+
return normalizeBuildNumber(raw, 'ios');
|
|
76
|
+
const iosDir = path_1.default.join(projectRoot, 'ios');
|
|
77
|
+
if (!fs_1.default.existsSync(iosDir))
|
|
78
|
+
return null;
|
|
79
|
+
const projects = fs_1.default.readdirSync(iosDir).filter(name => name.endsWith('.xcodeproj'));
|
|
80
|
+
if (projects.length !== 1)
|
|
81
|
+
return null;
|
|
82
|
+
const projectFile = path_1.default.join(iosDir, projects[0], 'project.pbxproj');
|
|
83
|
+
if (!fs_1.default.existsSync(projectFile))
|
|
84
|
+
return null;
|
|
85
|
+
const tokens = buildTokens(fs_1.default.readFileSync(projectFile, 'utf8')).filter(token => !['\n', '\r\n'].includes(token));
|
|
86
|
+
// PBX source paths may contain unquoted slashes; validate the setting value below.
|
|
87
|
+
if (tokens.some(token => ['"', "'"].includes(token)))
|
|
88
|
+
return null;
|
|
89
|
+
const scopes = [];
|
|
90
|
+
const values = new Set();
|
|
91
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
92
|
+
const token = tokens[index];
|
|
93
|
+
if (token === '{')
|
|
94
|
+
scopes.push(tokens[index - 1] === '=' && tokens[index - 2] === 'buildSettings' ? 'settings' : '');
|
|
95
|
+
else if (token === '}')
|
|
96
|
+
scopes.pop();
|
|
97
|
+
else if (token === 'CURRENT_PROJECT_VERSION') {
|
|
98
|
+
if (scopes[scopes.length - 1] !== 'settings' || tokens[index + 1] !== '=')
|
|
99
|
+
return null;
|
|
100
|
+
const end = tokens.indexOf(';', index + 2);
|
|
101
|
+
if (end === -1)
|
|
102
|
+
return null;
|
|
103
|
+
const value = normalizeBuildNumber(tokens.slice(index + 2, end).join('').replace(/^"|"$/g, ''), 'ios');
|
|
104
|
+
if (!value)
|
|
105
|
+
return null;
|
|
106
|
+
values.add(value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return values.size === 1 ? [...values][0] : null;
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Display metadata only. runtimeVersion remains the exact compatibility key. */
|
|
2
|
+
export type RuntimeCompatibilityMetadata = {
|
|
3
|
+
compatibilitySource: 'manual' | 'fingerprint';
|
|
4
|
+
fingerprint?: {
|
|
5
|
+
schemeVersion: 1;
|
|
6
|
+
hash: string;
|
|
7
|
+
manualBoundary: string | null;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function runtimeCompatibilityMetadata(runtimeConfig: unknown, platform: 'ios' | 'android', runtimeVersion: string): RuntimeCompatibilityMetadata;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runtimeCompatibilityMetadata = runtimeCompatibilityMetadata;
|
|
4
|
+
const config_1 = require("../fingerprint/config");
|
|
5
|
+
function runtimeCompatibilityMetadata(runtimeConfig, platform, runtimeVersion) {
|
|
6
|
+
const selection = (0, config_1.selectRuntimeVersion)(runtimeConfig, platform);
|
|
7
|
+
if (selection.source !== 'fingerprint')
|
|
8
|
+
return { compatibilitySource: 'manual' };
|
|
9
|
+
return {
|
|
10
|
+
compatibilitySource: 'fingerprint',
|
|
11
|
+
fingerprint: { schemeVersion: 1, hash: runtimeVersion, manualBoundary: selection.boundary },
|
|
12
|
+
};
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gfean/react-native-bundle-drop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"nativeVersion": "0.6.
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"nativeVersion": "0.6.4",
|
|
5
5
|
"description": "Over-the-air updates for Expo and bare React Native apps, with channels, staged rollouts, patch delivery, and rollback.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"clean": "rimraf lib dist",
|
|
39
|
-
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/make-cli-executable.js",
|
|
39
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/build-fingerprint.cjs && node scripts/make-cli-executable.js",
|
|
40
40
|
"test": "jest --runInBand",
|
|
41
41
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
42
42
|
"test:cli:compat": "node scripts/check-cli-compatibility.cjs",
|
|
@@ -52,16 +52,17 @@
|
|
|
52
52
|
"codeql:local:fast": "node scripts/run-codeql-local.cjs fast",
|
|
53
53
|
"codeql:local:full": "node scripts/run-codeql-local.cjs full",
|
|
54
54
|
"codeql:local:compare": "node scripts/run-codeql-local.cjs compare",
|
|
55
|
-
"verify:quick": "yarn typecheck && yarn build && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
|
|
55
|
+
"verify:quick": "yarn typecheck && yarn build && yarn fingerprint:check && yarn coverage:gate && yarn test:expo:plugin && yarn package:check",
|
|
56
56
|
"verify:native": "yarn test:android && yarn test:ios",
|
|
57
57
|
"verify:release": "yarn verify:quick && yarn verify:native && yarn audit:production",
|
|
58
58
|
"prepack": "npm run build",
|
|
59
|
-
"prepublishOnly": "npm run verify:release"
|
|
59
|
+
"prepublishOnly": "npm run verify:release",
|
|
60
|
+
"fingerprint:check": "node scripts/check-fingerprint-contract.cjs"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@types/adm-zip": "^0.
|
|
63
|
+
"@types/adm-zip": "^0.6.0",
|
|
63
64
|
"@types/jest": "^29.5.14",
|
|
64
|
-
"@types/node": "^24.19.
|
|
65
|
+
"@types/node": "^24.19.2",
|
|
65
66
|
"@types/react": "^18.2.66",
|
|
66
67
|
"@types/react-native": "^0.73.0",
|
|
67
68
|
"expo-autolinking-sdk55": "npm:expo-modules-autolinking@55.0.8",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"react-test-renderer": "^18.3.1",
|
|
74
75
|
"rimraf": "^6.1.3",
|
|
75
76
|
"rn-cli-platform-android-078": "npm:@react-native-community/cli-platform-android@15.0.1",
|
|
76
|
-
"ts-jest": "^29.4.
|
|
77
|
+
"ts-jest": "^29.4.15",
|
|
77
78
|
"ts-node": "^10.9.2",
|
|
78
79
|
"typescript": "^5.9.3"
|
|
79
80
|
},
|
|
@@ -88,6 +89,11 @@
|
|
|
88
89
|
"ios/*.{m,h,mm,swift}",
|
|
89
90
|
"third_party/xdelta/NOTICE",
|
|
90
91
|
"third_party/xdelta/PROVENANCE.md",
|
|
92
|
+
"third_party/expo-fingerprint/build/**",
|
|
93
|
+
"third_party/expo-fingerprint/LICENSE",
|
|
94
|
+
"third_party/expo-fingerprint/NOTICE",
|
|
95
|
+
"third_party/expo-fingerprint/PROVENANCE.md",
|
|
96
|
+
"third_party/expo-fingerprint/upstream-files.json",
|
|
91
97
|
"third_party/xdelta/bundle_drop_xdelta.c",
|
|
92
98
|
"third_party/xdelta/bundle_drop_xdelta.h",
|
|
93
99
|
"third_party/xdelta/xdelta3/LICENSE",
|
|
@@ -112,7 +118,9 @@
|
|
|
112
118
|
"expo/bundle-drop-expo-gradle-plugin/build.gradle",
|
|
113
119
|
"expo/bundle-drop-expo-gradle-plugin/src/main/**",
|
|
114
120
|
"expo/ios/Sources/**",
|
|
115
|
-
"README.md"
|
|
121
|
+
"README.md",
|
|
122
|
+
"third_party/expo-fingerprint/scheme-1-contract.json",
|
|
123
|
+
"docs/native-fingerprint.md"
|
|
116
124
|
],
|
|
117
125
|
"keywords": [
|
|
118
126
|
"react-native",
|
|
@@ -172,15 +180,21 @@
|
|
|
172
180
|
},
|
|
173
181
|
"dependencies": {
|
|
174
182
|
"adm-zip": "0.6.1",
|
|
175
|
-
"axios": "1.
|
|
183
|
+
"axios": "1.21.0",
|
|
176
184
|
"chalk": "4.1.2",
|
|
177
185
|
"commander": "14.0.3",
|
|
186
|
+
"debug": "4.4.3",
|
|
178
187
|
"diff": "9.0.0",
|
|
179
188
|
"figures": "3.2.0",
|
|
180
189
|
"form-data": "4.0.6",
|
|
181
190
|
"fs-extra": "11.4.1",
|
|
191
|
+
"glob": "14.0.3",
|
|
192
|
+
"ignore": "5.3.2",
|
|
193
|
+
"minimatch": "11.0.3",
|
|
182
194
|
"plist": "5.0.0",
|
|
183
|
-
"prompts": "2.4.2"
|
|
195
|
+
"prompts": "2.4.2",
|
|
196
|
+
"resolve-from": "5.0.0",
|
|
197
|
+
"semver": "7.7.4"
|
|
184
198
|
},
|
|
185
199
|
"publishConfig": {
|
|
186
200
|
"access": "public"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Contains source adapted from @expo/fingerprint 0.21.5, Expo commit
|
|
2
|
+
d7a68affbace544d36250aa6bdb06e34bda9e8ea.
|
|
3
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo).
|
|
4
|
+
Licensed under the MIT License; see LICENSE.
|
|
5
|
+
Bundle Drop modifications are documented in PROVENANCE.md.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Pinned Expo fingerprint adaptation — scheme 1
|
|
2
|
+
|
|
3
|
+
- Upstream: https://github.com/expo/expo/tree/d7a68affbace544d36250aa6bdb06e34bda9e8ea/packages/%40expo/fingerprint
|
|
4
|
+
- Package: `@expo/fingerprint` 0.21.5, MIT.
|
|
5
|
+
- `upstream-files.json` records original file SHA-256 values before adaptation.
|
|
6
|
+
- `src/` is maintained source; `scripts/build-fingerprint.cjs` produces packaged `build/` files.
|
|
7
|
+
|
|
8
|
+
This is Bundle Drop scheme 1, not an Expo-compatible hash. Its complete calculation
|
|
9
|
+
contract is frozen in `scheme-1-contract.json`. Version 0.11.0 revises the
|
|
10
|
+
pre-release baseline for patched matching dependencies. Earlier Beta calculators
|
|
11
|
+
are not interchangeable; existing Beta apps must be rebuilt with matching build
|
|
12
|
+
and upload tooling. Subsequent calculation changes require a new scheme with
|
|
13
|
+
retained scheme 1 behavior.
|
|
14
|
+
See `docs/native-fingerprint.md` for supported inputs and validation limitations.
|
|
15
|
+
|
|
16
|
+
Adaptations:
|
|
17
|
+
- Node subprocess/environment adapters replace direct Expo utility dependencies.
|
|
18
|
+
- Expo config evaluates in the selected production/development environment rather than forcing development.
|
|
19
|
+
- Executed required config/autolinking collectors fail instead of returning an empty source set.
|
|
20
|
+
- React Native CLI resolves from the installed project; collection never installs a CLI via npx.
|
|
21
|
+
- Bundle Drop owns options and extra sources; `fingerprint.config.js` is not an alternate authority.
|
|
22
|
+
- Stable codepoint sorting replaces locale-sensitive ordering.
|
|
23
|
+
- The config-plugin capture ignores the JS-only `resolve-from` utility alongside
|
|
24
|
+
upstream's existing tooling exclusions. An external upgraded CLI otherwise
|
|
25
|
+
captures a project copy that an in-project CLI has already preloaded, producing
|
|
26
|
+
different inputs for the same project. Evaluated config and actual plugin
|
|
27
|
+
sources remain hashed; no native package source is removed by this correction.
|
|
28
|
+
- Generic calculation dependencies are exact versions in `package.json` with the
|
|
29
|
+
complete resolution in `yarn.lock`. The revised pre-release baseline uses
|
|
30
|
+
minimatch 11.0.3 and glob 14.0.3 for GHSA-g3hv-75wg-m249 and
|
|
31
|
+
GHSA-3g3m-2fjr-6pw4. This intentionally adopts their updated matching semantics,
|
|
32
|
+
including multi-globstar and empty trailing extglob behavior.
|
|
33
|
+
|
|
34
|
+
Input selection, build-number normalization, exclusions, and effective identity
|
|
35
|
+
construction live in the first-party `src/fingerprint/` modules and must be
|
|
36
|
+
versioned together with this adaptation and its supporting dependencies.
|
|
37
|
+
|
|
38
|
+
Inherited limitations remain: this slice does not resolve Gradle artifacts,
|
|
39
|
+
scan installed Pods/SwiftPM sources, interpret arbitrary build scripts, or
|
|
40
|
+
materialize CNG native projections. Name/version-only React Native identity is
|
|
41
|
+
not proof against an in-place React Native core patch.
|
|
@@ -0,0 +1,122 @@
|
|
|
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.loadConfigAsync = loadConfigAsync;
|
|
7
|
+
exports.normalizeSourceSkips = normalizeSourceSkips;
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const SourceSkips_1 = require("./sourcer/SourceSkips");
|
|
11
|
+
const CONFIG_FILES = ['fingerprint.config.js', 'fingerprint.config.cjs'];
|
|
12
|
+
const debug = require('debug')('expo:fingerprint:Config');
|
|
13
|
+
/**
|
|
14
|
+
* Load the fingerprint.config.js from project root.
|
|
15
|
+
* @param projectRoot The project root directory.
|
|
16
|
+
* @param silent Whether to mute console logs when loading the config. This is useful for expo-updates integration and makes sure the JSON output is valid.
|
|
17
|
+
* @returns The loaded config or null if no config file was found.
|
|
18
|
+
*/
|
|
19
|
+
async function loadConfigAsync(projectRoot, silent = false) {
|
|
20
|
+
let configFile;
|
|
21
|
+
try {
|
|
22
|
+
configFile = await resolveConfigFileAsync(projectRoot);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
debug('Resolved config file:', configFile);
|
|
28
|
+
const unregisterMuteLogs = silent ? muteLogs() : null;
|
|
29
|
+
let rawConfig;
|
|
30
|
+
try {
|
|
31
|
+
rawConfig = require(configFile);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
debug('Error loading config file:', e);
|
|
35
|
+
rawConfig = {};
|
|
36
|
+
}
|
|
37
|
+
unregisterMuteLogs?.();
|
|
38
|
+
const supportedConfigKeys = [
|
|
39
|
+
'preset',
|
|
40
|
+
'concurrentIoLimit',
|
|
41
|
+
'hashAlgorithm',
|
|
42
|
+
'ignorePaths',
|
|
43
|
+
'extraSources',
|
|
44
|
+
'sourceSkips',
|
|
45
|
+
'enableReactImportsPatcher',
|
|
46
|
+
'useRNCoreAutolinkingFromExpo',
|
|
47
|
+
'nativeModuleSourceType',
|
|
48
|
+
'configPluginSourceType',
|
|
49
|
+
'debug',
|
|
50
|
+
'fileHookTransform',
|
|
51
|
+
];
|
|
52
|
+
const config = {};
|
|
53
|
+
for (const key of supportedConfigKeys) {
|
|
54
|
+
if (key in rawConfig) {
|
|
55
|
+
if (key === 'sourceSkips') {
|
|
56
|
+
config[key] = normalizeSourceSkips(rawConfig[key]);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
config[key] = rawConfig[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Normalize the sourceSkips from enum number or string array to a valid enum number.
|
|
67
|
+
*/
|
|
68
|
+
function normalizeSourceSkips(sourceSkips) {
|
|
69
|
+
if (sourceSkips == null) {
|
|
70
|
+
return SourceSkips_1.SourceSkips.None;
|
|
71
|
+
}
|
|
72
|
+
if (typeof sourceSkips === 'number') {
|
|
73
|
+
return sourceSkips;
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(sourceSkips)) {
|
|
76
|
+
let result = SourceSkips_1.SourceSkips.None;
|
|
77
|
+
for (const value of sourceSkips) {
|
|
78
|
+
if (typeof value !== 'string') {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const skipValue = SourceSkips_1.SourceSkips[value];
|
|
82
|
+
if (skipValue != null) {
|
|
83
|
+
result |= skipValue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Invalid sourceSkips type: ${sourceSkips}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolve the config file path from the project root.
|
|
92
|
+
*/
|
|
93
|
+
async function resolveConfigFileAsync(projectRoot) {
|
|
94
|
+
return await Promise.any(CONFIG_FILES.map(async (file) => {
|
|
95
|
+
const configPath = path_1.default.resolve(projectRoot, file);
|
|
96
|
+
const stat = await promises_1.default.stat(configPath);
|
|
97
|
+
if (!stat.isFile()) {
|
|
98
|
+
throw new Error(`Config file is not a file: ${configPath}`);
|
|
99
|
+
}
|
|
100
|
+
return configPath;
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Monkey-patch the console to mute logs.
|
|
105
|
+
* @returns A function to unregister the monkey-patch.
|
|
106
|
+
*/
|
|
107
|
+
function muteLogs() {
|
|
108
|
+
const originalConsole = {
|
|
109
|
+
log: console.log,
|
|
110
|
+
warn: console.warn,
|
|
111
|
+
error: console.error,
|
|
112
|
+
};
|
|
113
|
+
const unregister = () => {
|
|
114
|
+
console.log = originalConsole.log;
|
|
115
|
+
console.warn = originalConsole.warn;
|
|
116
|
+
console.error = originalConsole.error;
|
|
117
|
+
};
|
|
118
|
+
console.log = () => { };
|
|
119
|
+
console.warn = () => { };
|
|
120
|
+
console.error = () => { };
|
|
121
|
+
return unregister;
|
|
122
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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.dedupSources = dedupSources;
|
|
7
|
+
exports.mergeSourceWithReasons = mergeSourceWithReasons;
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const debug = require('debug')('expo:fingerprint:Dedup');
|
|
11
|
+
/**
|
|
12
|
+
* Strip duplicated sources, mainly for duplicated file or dir
|
|
13
|
+
*/
|
|
14
|
+
function dedupSources(sources, projectRoot) {
|
|
15
|
+
const newSources = [];
|
|
16
|
+
for (const source of sources) {
|
|
17
|
+
const [duplicatedItemIndex, shouldSwapSource] = findDuplicatedSourceIndex(newSources, source, projectRoot);
|
|
18
|
+
const duplicatedItem = newSources[duplicatedItemIndex];
|
|
19
|
+
if (duplicatedItem != null) {
|
|
20
|
+
debug(`Skipping duplicated source: ${JSON.stringify(source)}`);
|
|
21
|
+
if (shouldSwapSource) {
|
|
22
|
+
newSources[duplicatedItemIndex] = {
|
|
23
|
+
...source,
|
|
24
|
+
reasons: [...source.reasons, ...duplicatedItem.reasons],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
duplicatedItem.reasons = [...duplicatedItem.reasons, ...source.reasons];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
newSources.push(source);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return newSources;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* When two sources are duplicated, merge `src`'s reasons into `dst`
|
|
39
|
+
*/
|
|
40
|
+
function mergeSourceWithReasons(dst, src) {
|
|
41
|
+
return dst;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find the duplicated `source` in `newSources`
|
|
45
|
+
* @return tuple of [duplicatedItemIndexInNewSources, shouldSwapSource]
|
|
46
|
+
*/
|
|
47
|
+
function findDuplicatedSourceIndex(newSources, source, projectRoot) {
|
|
48
|
+
let shouldSwapSource = false;
|
|
49
|
+
if (source.type === 'contents') {
|
|
50
|
+
return [
|
|
51
|
+
newSources.findIndex((item) => item.type === source.type && item.id === source.id) ?? null,
|
|
52
|
+
shouldSwapSource,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
if (source.type === 'package') {
|
|
56
|
+
const key = source.overrideHashKey ?? `${source.name}@${source.version}`;
|
|
57
|
+
return [
|
|
58
|
+
newSources.findIndex((item) => item.type === 'package' &&
|
|
59
|
+
(item.overrideHashKey ?? `${item.name}@${item.version}`) === key) ?? null,
|
|
60
|
+
shouldSwapSource,
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
for (const [index, existingSource] of newSources.entries()) {
|
|
64
|
+
if (existingSource.type === 'contents' || existingSource.type === 'package') {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (isDescendant(source, existingSource, projectRoot)) {
|
|
68
|
+
return [index, shouldSwapSource];
|
|
69
|
+
}
|
|
70
|
+
// If the new source is ancestor of existing source, swap the existing source with the new source
|
|
71
|
+
if (isDescendant(existingSource, source, projectRoot)) {
|
|
72
|
+
shouldSwapSource = true;
|
|
73
|
+
return [index, shouldSwapSource];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [-1, shouldSwapSource];
|
|
77
|
+
}
|
|
78
|
+
function isDescendant(from, to, projectRoot) {
|
|
79
|
+
if (from === to) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const fromPath = path_1.default.join(projectRoot, from.filePath);
|
|
83
|
+
const toPath = path_1.default.join(projectRoot, to.filePath);
|
|
84
|
+
const result = path_1.default.relative(fromPath, toPath).match(/^[./\\/]*$/) != null;
|
|
85
|
+
if (result) {
|
|
86
|
+
(0, assert_1.default)(!(to.type === 'file' && from.type === 'dir'), `Unexpected case which a dir is a descendant of a file - from[${fromPath}] to[${toPath}]`);
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|