@gfean/react-native-bundle-drop 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BundleDrop.podspec +17 -20
- package/README.md +77 -1
- package/android/build.gradle +4 -0
- package/android/src/main/java/com/bundledrop/BundleDropFileOps.kt +20 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +4 -1
- package/android/src/main/java/com/bundledrop/BundleDropNativePaths.kt +5 -1
- package/docs/native-fingerprint.md +211 -0
- package/expo/android/build.gradle +61 -56
- package/ios/BundleDropLocator.swift +12 -0
- package/ios/BundleDropModule.swift +31 -13
- package/ios/BundleDropReactContent.swift +54 -0
- package/ios/BundleDropStartupRecovery.swift +48 -2
- package/ios/BundleDropStartupRecoveryAdapter.swift +87 -30
- package/lib/CLI/cli.js +12 -0
- package/lib/CLI/scripts/doctor.js +18 -7
- package/lib/CLI/scripts/expo/configure-expo.js +8 -3
- package/lib/CLI/scripts/fingerprint-cli.d.ts +12 -0
- package/lib/CLI/scripts/fingerprint-cli.js +36 -0
- package/lib/CLI/scripts/native/write-runtime-identity.js +3 -1
- package/lib/CLI/scripts/sight-ota.js +12 -3
- package/lib/CLI/scripts/upload-cli.d.ts +3 -0
- package/lib/CLI/scripts/upload-cli.js +239 -107
- package/lib/context.js +9 -1
- package/lib/errors.d.ts +2 -1
- package/lib/errors.js +2 -1
- package/lib/expo/buildIdentity.d.ts +1 -1
- package/lib/expo/buildIdentity.js +3 -0
- package/lib/expo/runtimeVersion.d.ts +10 -0
- package/lib/expo/runtimeVersion.js +11 -9
- package/lib/fingerprint/client.d.ts +5 -0
- package/lib/fingerprint/client.js +21 -0
- package/lib/fingerprint/collect.d.ts +3 -0
- package/lib/fingerprint/collect.js +116 -0
- package/lib/fingerprint/config.d.ts +14 -0
- package/lib/fingerprint/config.js +60 -0
- package/lib/fingerprint/normalizeBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeBuildNumber.js +55 -0
- package/lib/fingerprint/normalizeIosBuildNumber.d.ts +4 -0
- package/lib/fingerprint/normalizeIosBuildNumber.js +62 -0
- package/lib/fingerprint/types.d.ts +29 -0
- package/lib/fingerprint/types.js +2 -0
- package/lib/fingerprint/worker.d.ts +1 -0
- package/lib/fingerprint/worker.js +24 -0
- package/lib/fs/installedReportHistory.d.ts +2 -0
- package/lib/fs/installedReportHistory.js +55 -0
- package/lib/loadConfig.d.ts +6 -2
- package/lib/manager/downloadAndInstall.d.ts +1 -0
- package/lib/manager/downloadAndInstall.js +4 -0
- package/lib/manager/pendingRollback.d.ts +11 -0
- package/lib/manager/pendingRollback.js +54 -0
- package/lib/manager/reporting.d.ts +1 -0
- package/lib/manager/reporting.js +23 -6
- package/lib/manager/updateState.d.ts +3 -0
- package/lib/manager/updateState.js +1 -0
- package/lib/metro.js +3 -0
- package/lib/native/bundleDropNative.d.ts +2 -0
- package/lib/native/bundleDropNative.js +15 -5
- package/lib/patch-engine/installFromPatchSet.js +1 -1
- package/lib/patch-engine/patchTransport.d.ts +2 -1
- package/lib/patch-engine/patchTransport.js +4 -2
- package/lib/runtime/service.d.ts +2 -1
- package/lib/runtime/service.js +77 -22
- package/lib/scripts/bundle.js +10 -0
- package/lib/scripts/canonicalArtifact.d.ts +3 -0
- package/lib/scripts/canonicalArtifact.js +3 -1
- package/lib/scripts/exportProject.js +11 -0
- package/lib/scripts/nativeBuildNumber.d.ts +9 -0
- package/lib/scripts/nativeBuildNumber.js +110 -0
- package/lib/scripts/runtimeCompatibilityMetadata.d.ts +10 -0
- package/lib/scripts/runtimeCompatibilityMetadata.js +13 -0
- package/package.json +26 -12
- package/third_party/expo-fingerprint/LICENSE +22 -0
- package/third_party/expo-fingerprint/NOTICE +5 -0
- package/third_party/expo-fingerprint/PROVENANCE.md +41 -0
- package/third_party/expo-fingerprint/build/Config.js +122 -0
- package/third_party/expo-fingerprint/build/Dedup.js +89 -0
- package/third_party/expo-fingerprint/build/ExpoConfig.js +93 -0
- package/third_party/expo-fingerprint/build/ExpoConfigLoader.js +201 -0
- package/third_party/expo-fingerprint/build/ExpoResolver.js +84 -0
- package/third_party/expo-fingerprint/build/Fingerprint.js +111 -0
- package/third_party/expo-fingerprint/build/Fingerprint.types.js +3 -0
- package/third_party/expo-fingerprint/build/Options.js +140 -0
- package/third_party/expo-fingerprint/build/Presets.js +62 -0
- package/third_party/expo-fingerprint/build/ProjectWorkflow.js +163 -0
- package/third_party/expo-fingerprint/build/Sort.js +46 -0
- package/third_party/expo-fingerprint/build/hash/FileHookTransform.js +42 -0
- package/third_party/expo-fingerprint/build/hash/Hash.js +264 -0
- package/third_party/expo-fingerprint/build/hash/ReactImportsPatcher.js +344 -0
- package/third_party/expo-fingerprint/build/index.js +23 -0
- package/third_party/expo-fingerprint/build/sourcer/AutolinkingConfig.js +130 -0
- package/third_party/expo-fingerprint/build/sourcer/Bare.js +231 -0
- package/third_party/expo-fingerprint/build/sourcer/Expo.js +376 -0
- package/third_party/expo-fingerprint/build/sourcer/Packages.js +54 -0
- package/third_party/expo-fingerprint/build/sourcer/PatchPackage.js +22 -0
- package/third_party/expo-fingerprint/build/sourcer/SourceSkips.js +79 -0
- package/third_party/expo-fingerprint/build/sourcer/Sourcer.js +58 -0
- package/third_party/expo-fingerprint/build/sourcer/Utils.js +129 -0
- package/third_party/expo-fingerprint/build/types/module.d.js +2 -0
- package/third_party/expo-fingerprint/build/utils/Concurrency.js +47 -0
- package/third_party/expo-fingerprint/build/utils/Env.js +28 -0
- package/third_party/expo-fingerprint/build/utils/Path.js +161 -0
- package/third_party/expo-fingerprint/build/utils/Predicates.js +6 -0
- package/third_party/expo-fingerprint/build/utils/Profile.js +41 -0
- package/third_party/expo-fingerprint/build/utils/Spawn.js +38 -0
- package/third_party/expo-fingerprint/build/utils/SpawnIPC.js +28 -0
- package/third_party/expo-fingerprint/scheme-1-contract.json +132 -0
- package/third_party/expo-fingerprint/upstream-files.json +37 -0
|
@@ -0,0 +1,264 @@
|
|
|
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.createFingerprintFromSourcesAsync = createFingerprintFromSourcesAsync;
|
|
7
|
+
exports.createFingerprintSourceAsync = createFingerprintSourceAsync;
|
|
8
|
+
exports.createFileHashResultsAsync = createFileHashResultsAsync;
|
|
9
|
+
exports.createDirHashResultsAsync = createDirHashResultsAsync;
|
|
10
|
+
exports.createContentsHashResultsAsync = createContentsHashResultsAsync;
|
|
11
|
+
exports.createPackageHashResultsAsync = createPackageHashResultsAsync;
|
|
12
|
+
exports.createSourceId = createSourceId;
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const stream_1 = require("stream");
|
|
18
|
+
const Concurrency_1 = require("../utils/Concurrency");
|
|
19
|
+
const Path_1 = require("../utils/Path");
|
|
20
|
+
const Predicates_1 = require("../utils/Predicates");
|
|
21
|
+
const Profile_1 = require("../utils/Profile");
|
|
22
|
+
const FileHookTransform_1 = require("./FileHookTransform");
|
|
23
|
+
const ReactImportsPatcher_1 = require("./ReactImportsPatcher");
|
|
24
|
+
/**
|
|
25
|
+
* Create a `Fingerprint` from `HashSources` array
|
|
26
|
+
*/
|
|
27
|
+
async function createFingerprintFromSourcesAsync(sources, projectRoot, options) {
|
|
28
|
+
const limiter = (0, Concurrency_1.createLimiter)(options.concurrentIoLimit);
|
|
29
|
+
const fingerprintSources = await Promise.all(sources.map((source) => createFingerprintSourceAsync(source, limiter, projectRoot, options)));
|
|
30
|
+
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
|
|
31
|
+
for (const source of fingerprintSources) {
|
|
32
|
+
if (source.hash != null) {
|
|
33
|
+
hasher.update(createSourceId(source));
|
|
34
|
+
hasher.update(source.hash);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const hash = hasher.digest('hex');
|
|
38
|
+
return {
|
|
39
|
+
sources: fingerprintSources,
|
|
40
|
+
hash,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a `FingerprintSource` from a `HashSource`
|
|
45
|
+
* This function will get a hash value and merge back to original source
|
|
46
|
+
*/
|
|
47
|
+
async function createFingerprintSourceAsync(source, limiter, projectRoot, options) {
|
|
48
|
+
let result = null;
|
|
49
|
+
switch (source.type) {
|
|
50
|
+
case 'contents':
|
|
51
|
+
result = await createContentsHashResultsAsync(source, options);
|
|
52
|
+
break;
|
|
53
|
+
case 'file':
|
|
54
|
+
result = await createFileHashResultsAsync(source.filePath, limiter, projectRoot, options);
|
|
55
|
+
break;
|
|
56
|
+
case 'dir':
|
|
57
|
+
result = await (0, Profile_1.profile)(options, createDirHashResultsAsync, `createDirHashResultsAsync(${source.filePath})`)(source.filePath, limiter, projectRoot, options);
|
|
58
|
+
break;
|
|
59
|
+
case 'package':
|
|
60
|
+
result = await createPackageHashResultsAsync(source, options);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
throw new Error('Unsupported source type');
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...source,
|
|
67
|
+
hash: result?.hex ?? null,
|
|
68
|
+
...(options.debug ? { debugInfo: result?.debugInfo } : undefined),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a `HashResult` from a file
|
|
73
|
+
*/
|
|
74
|
+
async function createFileHashResultsAsync(filePath, limiter, projectRoot, options) {
|
|
75
|
+
// Backup code for faster hashing
|
|
76
|
+
/*
|
|
77
|
+
return limiter(async () => {
|
|
78
|
+
if (isIgnoredPathWithMatchObjects(filePath, options.ignorePathMatchObjects)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const hasher = createHash(options.hashAlgorithm);
|
|
83
|
+
|
|
84
|
+
const stat = await fs.stat(filePath);
|
|
85
|
+
hasher.update(`${stat.size}`);
|
|
86
|
+
|
|
87
|
+
const buffer = Buffer.alloc(4096);
|
|
88
|
+
const fd = await fs.open(filePath, 'r');
|
|
89
|
+
await fd.read(buffer, 0, buffer.length, 0);
|
|
90
|
+
await fd.close();
|
|
91
|
+
hasher.update(buffer);
|
|
92
|
+
console.log('stat', filePath, stat.size);
|
|
93
|
+
return { id: path.relative(projectRoot, filePath), hex: hasher.digest('hex') };
|
|
94
|
+
});
|
|
95
|
+
*/
|
|
96
|
+
return limiter(() => {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
if ((0, Path_1.isIgnoredPathWithMatchObjects)(filePath, options.ignorePathMatchObjects)) {
|
|
99
|
+
return resolve(null);
|
|
100
|
+
}
|
|
101
|
+
let resolved = false;
|
|
102
|
+
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
|
|
103
|
+
const fileHookTransform = options.fileHookTransform
|
|
104
|
+
? new FileHookTransform_1.FileHookTransform({ type: 'file', filePath }, options.fileHookTransform, options.debug)
|
|
105
|
+
: null;
|
|
106
|
+
let stream = (0, fs_1.createReadStream)(path_1.default.join(projectRoot, filePath), {
|
|
107
|
+
highWaterMark: 1024,
|
|
108
|
+
});
|
|
109
|
+
if (options.enableReactImportsPatcher &&
|
|
110
|
+
(filePath.endsWith('.h') || filePath.endsWith('.m') || filePath.endsWith('.mm'))) {
|
|
111
|
+
const transform = new ReactImportsPatcher_1.ReactImportsPatchTransform();
|
|
112
|
+
stream = (0, stream_1.pipeline)(stream, transform, (err) => {
|
|
113
|
+
if (err) {
|
|
114
|
+
reject(err);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (fileHookTransform) {
|
|
119
|
+
stream = (0, stream_1.pipeline)(stream, fileHookTransform, (err) => {
|
|
120
|
+
if (err) {
|
|
121
|
+
reject(err);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
stream.on('close', () => {
|
|
126
|
+
if (!resolved) {
|
|
127
|
+
const hex = hasher.digest('hex');
|
|
128
|
+
const isTransformed = fileHookTransform?.isTransformed;
|
|
129
|
+
const debugInfo = options.debug
|
|
130
|
+
? {
|
|
131
|
+
path: filePath,
|
|
132
|
+
hash: hex,
|
|
133
|
+
...(isTransformed ? { isTransformed } : undefined),
|
|
134
|
+
}
|
|
135
|
+
: undefined;
|
|
136
|
+
resolve({
|
|
137
|
+
type: 'file',
|
|
138
|
+
id: filePath,
|
|
139
|
+
hex,
|
|
140
|
+
...(debugInfo ? { debugInfo } : undefined),
|
|
141
|
+
});
|
|
142
|
+
resolved = true;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
stream.on('error', (e) => {
|
|
146
|
+
reject(e);
|
|
147
|
+
});
|
|
148
|
+
stream.on('data', (chunk) => {
|
|
149
|
+
hasher.update(chunk);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create `HashResult` for a dir.
|
|
156
|
+
* If the dir is excluded, returns null rather than a HashResult
|
|
157
|
+
*/
|
|
158
|
+
async function createDirHashResultsAsync(dirPath, limiter, projectRoot, options, depth = 0) {
|
|
159
|
+
// Using `ignoreDirMatchObjects` as an optimization to skip the whole directory
|
|
160
|
+
if ((0, Path_1.isIgnoredPathWithMatchObjects)(dirPath, options.ignoreDirMatchObjects)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const dirents = (await promises_1.default.readdir(path_1.default.join(projectRoot, dirPath), { withFileTypes: true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
164
|
+
const results = (await Promise.all(dirents.map(async (dirent) => {
|
|
165
|
+
if (dirent.isDirectory()) {
|
|
166
|
+
// Skip nested node_modules inside a package.
|
|
167
|
+
if (dirent.name === 'node_modules') {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const filePath = (0, Path_1.toPosixPath)(path_1.default.join(dirPath, dirent.name));
|
|
171
|
+
return await createDirHashResultsAsync(filePath, limiter, projectRoot, options, depth + 1);
|
|
172
|
+
}
|
|
173
|
+
else if (dirent.isFile()) {
|
|
174
|
+
const filePath = (0, Path_1.toPosixPath)(path_1.default.join(dirPath, dirent.name));
|
|
175
|
+
return await createFileHashResultsAsync(filePath, limiter, projectRoot, options);
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}))).filter(Predicates_1.nonNullish);
|
|
179
|
+
if (results.length === 0) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
const hasher = (0, crypto_1.createHash)(options.hashAlgorithm);
|
|
183
|
+
const children = [];
|
|
184
|
+
for (const result of results) {
|
|
185
|
+
hasher.update(result.id);
|
|
186
|
+
hasher.update(result.hex);
|
|
187
|
+
children.push(result.debugInfo);
|
|
188
|
+
}
|
|
189
|
+
const hex = hasher.digest('hex');
|
|
190
|
+
return {
|
|
191
|
+
type: 'dir',
|
|
192
|
+
id: dirPath,
|
|
193
|
+
hex,
|
|
194
|
+
...(options.debug ? { debugInfo: { path: dirPath, children, hash: hex } } : undefined),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Create `HashResult` for a `HashSourceContents`
|
|
199
|
+
*/
|
|
200
|
+
async function createContentsHashResultsAsync(source, options) {
|
|
201
|
+
let isTransformed = undefined;
|
|
202
|
+
if (options.fileHookTransform) {
|
|
203
|
+
const transformedContents = options.fileHookTransform({
|
|
204
|
+
type: 'contents',
|
|
205
|
+
id: source.id,
|
|
206
|
+
}, source.contents, true /* isEndOfFile */, 'utf8') ?? '';
|
|
207
|
+
if (options.debug) {
|
|
208
|
+
isTransformed = transformedContents !== source.contents;
|
|
209
|
+
}
|
|
210
|
+
source.contents = transformedContents;
|
|
211
|
+
}
|
|
212
|
+
const hex = (0, crypto_1.createHash)(options.hashAlgorithm).update(source.contents).digest('hex');
|
|
213
|
+
const debugInfo = options.debug
|
|
214
|
+
? {
|
|
215
|
+
hash: hex,
|
|
216
|
+
...(isTransformed ? { isTransformed } : undefined),
|
|
217
|
+
}
|
|
218
|
+
: undefined;
|
|
219
|
+
return {
|
|
220
|
+
type: 'contents',
|
|
221
|
+
id: source.id,
|
|
222
|
+
hex,
|
|
223
|
+
...(debugInfo ? { debugInfo } : undefined),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Create a `HashResult` for a package from its embedded `name` and `version`.
|
|
228
|
+
* The sourcer reads these from the `package.json`, so the hash depends on the package identity
|
|
229
|
+
* rather than its resolved path or unrelated contents.
|
|
230
|
+
* Returns null when the package is ignored.
|
|
231
|
+
*/
|
|
232
|
+
async function createPackageHashResultsAsync(source, options) {
|
|
233
|
+
if ((0, Path_1.isIgnoredPathWithMatchObjects)(source.filePath, options.ignorePathMatchObjects)) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const { name, version } = source;
|
|
237
|
+
const hex = (0, crypto_1.createHash)(options.hashAlgorithm)
|
|
238
|
+
.update(JSON.stringify({ name, version }))
|
|
239
|
+
.digest('hex');
|
|
240
|
+
const debugInfo = options.debug ? { path: source.filePath, name, version, hash: hex } : undefined;
|
|
241
|
+
return {
|
|
242
|
+
type: 'package',
|
|
243
|
+
id: createSourceId(source),
|
|
244
|
+
hex,
|
|
245
|
+
...(debugInfo ? { debugInfo } : undefined),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create id from given source
|
|
250
|
+
*/
|
|
251
|
+
function createSourceId(source) {
|
|
252
|
+
switch (source.type) {
|
|
253
|
+
case 'contents':
|
|
254
|
+
return source.id;
|
|
255
|
+
case 'file':
|
|
256
|
+
return source.overrideHashKey ?? source.filePath;
|
|
257
|
+
case 'dir':
|
|
258
|
+
return source.overrideHashKey ?? source.filePath;
|
|
259
|
+
case 'package':
|
|
260
|
+
return source.overrideHashKey ?? `${source.name}@${source.version}`;
|
|
261
|
+
default:
|
|
262
|
+
throw new Error('Unsupported source type');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReactImportsPatchTransform = void 0;
|
|
4
|
+
exports.patchChunk = patchChunk;
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
/**
|
|
7
|
+
* A transform stream that patches React import statements in Objective-C files.
|
|
8
|
+
*/
|
|
9
|
+
class ReactImportsPatchTransform extends stream_1.Transform {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super();
|
|
12
|
+
this.readLength = 0;
|
|
13
|
+
this.lengthOfFilePortionContainingHeadersToTransform =
|
|
14
|
+
options?.lengthOfFilePortionContainingHeadersToTransform ??
|
|
15
|
+
ReactImportsPatchTransform.DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM;
|
|
16
|
+
this.transformFn = options?.transformFn ?? patchChunk;
|
|
17
|
+
}
|
|
18
|
+
_transform(chunk, _encoding, callback) {
|
|
19
|
+
const remainingLength = this.lengthOfFilePortionContainingHeadersToTransform - this.readLength;
|
|
20
|
+
let result;
|
|
21
|
+
if (remainingLength <= 0) {
|
|
22
|
+
result = chunk.toString();
|
|
23
|
+
}
|
|
24
|
+
else if (remainingLength >= chunk.length) {
|
|
25
|
+
result = this.transformFn(chunk.toString());
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const portionToTransform = chunk.slice(0, remainingLength).toString();
|
|
29
|
+
const portionToLeave = chunk.slice(remainingLength).toString();
|
|
30
|
+
result = this.transformFn(portionToTransform) + portionToLeave;
|
|
31
|
+
}
|
|
32
|
+
this.push(result);
|
|
33
|
+
this.readLength += chunk.length;
|
|
34
|
+
callback();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ReactImportsPatchTransform = ReactImportsPatchTransform;
|
|
38
|
+
ReactImportsPatchTransform.DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM = 16 * 1024; // 16KB
|
|
39
|
+
/**
|
|
40
|
+
* Patch imports from a data chunk
|
|
41
|
+
* @param headerSet prebuilt React-Core header set
|
|
42
|
+
* @param chunk target chunk data
|
|
43
|
+
*/
|
|
44
|
+
function patchChunk(chunk, headerSet = HEADER_SET) {
|
|
45
|
+
let transformContent = chunk.replace(/(?<=^\s*)#import\s+"(.+)"(?=\s*$)/gm, (match, headerName) => {
|
|
46
|
+
// `#import "RCTBridge.h"` -> `#import <React/RCTBridge.h>`
|
|
47
|
+
if (headerSet.has(headerName)) {
|
|
48
|
+
return `#import <React/${headerName}>`;
|
|
49
|
+
}
|
|
50
|
+
// `#import "React/RCTBridge.h"` -> `#import <React/RCTBridge.h>`
|
|
51
|
+
if (headerName.startsWith('React/')) {
|
|
52
|
+
const name = headerName.substring(6);
|
|
53
|
+
if (headerSet.has(name)) {
|
|
54
|
+
return `#import <React/${name}>`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Otherwise, return original import
|
|
58
|
+
return match;
|
|
59
|
+
});
|
|
60
|
+
transformContent = transformContent.replace(/(?<=^\s*)#(if|elif)\s+__has_include\("(.+)"\)(?=\s*$)/gm, (match, ifPrefix, headerName) => {
|
|
61
|
+
// `#if __has_include("RCTBridge.h")` -> `#if __has_include(<React/RCTBridge.h>)`
|
|
62
|
+
if (headerSet.has(headerName)) {
|
|
63
|
+
return `#${ifPrefix} __has_include(<React/${headerName}>)`;
|
|
64
|
+
}
|
|
65
|
+
// `#if __has_include("React/RCTBridge.h")` -> `#if __has_include(<React/RCTBridge.h>)`
|
|
66
|
+
if (headerName.startsWith('React/')) {
|
|
67
|
+
const name = headerName.substring(6);
|
|
68
|
+
if (headerSet.has(name)) {
|
|
69
|
+
return `#${ifPrefix} __has_include(<React/${name}>)`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Otherwise, return original import
|
|
73
|
+
return match;
|
|
74
|
+
});
|
|
75
|
+
return transformContent;
|
|
76
|
+
}
|
|
77
|
+
// Fingerprint doesn't run `pod install` so we have a snapshot of the headers in the React-Core module from react-native 0.74.
|
|
78
|
+
const HEADER_SET = new Set([
|
|
79
|
+
'CoreModulesPlugins.h',
|
|
80
|
+
'FBXXHashUtils.h',
|
|
81
|
+
'NSTextStorage+FontScaling.h',
|
|
82
|
+
'RCTAccessibilityManager+Internal.h',
|
|
83
|
+
'RCTAccessibilityManager.h',
|
|
84
|
+
'RCTActionSheetManager.h',
|
|
85
|
+
'RCTActivityIndicatorView.h',
|
|
86
|
+
'RCTActivityIndicatorViewManager.h',
|
|
87
|
+
'RCTAdditionAnimatedNode.h',
|
|
88
|
+
'RCTAlertController.h',
|
|
89
|
+
'RCTAlertManager.h',
|
|
90
|
+
'RCTAnimatedImage.h',
|
|
91
|
+
'RCTAnimatedNode.h',
|
|
92
|
+
'RCTAnimationDriver.h',
|
|
93
|
+
'RCTAnimationPlugins.h',
|
|
94
|
+
'RCTAnimationType.h',
|
|
95
|
+
'RCTAnimationUtils.h',
|
|
96
|
+
'RCTAppState.h',
|
|
97
|
+
'RCTAppearance.h',
|
|
98
|
+
'RCTAssert.h',
|
|
99
|
+
'RCTAutoInsetsProtocol.h',
|
|
100
|
+
'RCTBackedTextInputDelegate.h',
|
|
101
|
+
'RCTBackedTextInputDelegateAdapter.h',
|
|
102
|
+
'RCTBackedTextInputViewProtocol.h',
|
|
103
|
+
'RCTBaseTextInputShadowView.h',
|
|
104
|
+
'RCTBaseTextInputView.h',
|
|
105
|
+
'RCTBaseTextInputViewManager.h',
|
|
106
|
+
'RCTBaseTextShadowView.h',
|
|
107
|
+
'RCTBaseTextViewManager.h',
|
|
108
|
+
'RCTBlobManager.h',
|
|
109
|
+
'RCTBorderCurve.h',
|
|
110
|
+
'RCTBorderDrawing.h',
|
|
111
|
+
'RCTBorderStyle.h',
|
|
112
|
+
'RCTBridge+Inspector.h',
|
|
113
|
+
'RCTBridge+Private.h',
|
|
114
|
+
'RCTBridge.h',
|
|
115
|
+
'RCTBridgeConstants.h',
|
|
116
|
+
'RCTBridgeDelegate.h',
|
|
117
|
+
'RCTBridgeMethod.h',
|
|
118
|
+
'RCTBridgeModule.h',
|
|
119
|
+
'RCTBridgeModuleDecorator.h',
|
|
120
|
+
'RCTBridgeProxy+Cxx.h',
|
|
121
|
+
'RCTBridgeProxy.h',
|
|
122
|
+
'RCTBundleAssetImageLoader.h',
|
|
123
|
+
'RCTBundleManager.h',
|
|
124
|
+
'RCTBundleURLProvider.h',
|
|
125
|
+
'RCTClipboard.h',
|
|
126
|
+
'RCTColorAnimatedNode.h',
|
|
127
|
+
'RCTComponent.h',
|
|
128
|
+
'RCTComponentData.h',
|
|
129
|
+
'RCTComponentEvent.h',
|
|
130
|
+
'RCTConstants.h',
|
|
131
|
+
'RCTConvert+CoreLocation.h',
|
|
132
|
+
'RCTConvert+Text.h',
|
|
133
|
+
'RCTConvert+Transform.h',
|
|
134
|
+
'RCTConvert.h',
|
|
135
|
+
'RCTCursor.h',
|
|
136
|
+
'RCTCxxConvert.h',
|
|
137
|
+
'RCTDataRequestHandler.h',
|
|
138
|
+
'RCTDebuggingOverlay.h',
|
|
139
|
+
'RCTDebuggingOverlayManager.h',
|
|
140
|
+
'RCTDecayAnimation.h',
|
|
141
|
+
'RCTDefines.h',
|
|
142
|
+
'RCTDevLoadingView.h',
|
|
143
|
+
'RCTDevLoadingViewProtocol.h',
|
|
144
|
+
'RCTDevLoadingViewSetEnabled.h',
|
|
145
|
+
'RCTDevMenu.h',
|
|
146
|
+
'RCTDevSettings.h',
|
|
147
|
+
'RCTDeviceInfo.h',
|
|
148
|
+
'RCTDiffClampAnimatedNode.h',
|
|
149
|
+
'RCTDisplayLink.h',
|
|
150
|
+
'RCTDisplayWeakRefreshable.h',
|
|
151
|
+
'RCTDivisionAnimatedNode.h',
|
|
152
|
+
'RCTDynamicTypeRamp.h',
|
|
153
|
+
'RCTErrorCustomizer.h',
|
|
154
|
+
'RCTErrorInfo.h',
|
|
155
|
+
'RCTEventAnimation.h',
|
|
156
|
+
'RCTEventDispatcher.h',
|
|
157
|
+
'RCTEventDispatcherProtocol.h',
|
|
158
|
+
'RCTEventEmitter.h',
|
|
159
|
+
'RCTExceptionsManager.h',
|
|
160
|
+
'RCTFPSGraph.h',
|
|
161
|
+
'RCTFileReaderModule.h',
|
|
162
|
+
'RCTFileRequestHandler.h',
|
|
163
|
+
'RCTFont.h',
|
|
164
|
+
'RCTFrameAnimation.h',
|
|
165
|
+
'RCTFrameUpdate.h',
|
|
166
|
+
'RCTGIFImageDecoder.h',
|
|
167
|
+
'RCTHTTPRequestHandler.h',
|
|
168
|
+
'RCTI18nManager.h',
|
|
169
|
+
'RCTI18nUtil.h',
|
|
170
|
+
'RCTImageBlurUtils.h',
|
|
171
|
+
'RCTImageCache.h',
|
|
172
|
+
'RCTImageDataDecoder.h',
|
|
173
|
+
'RCTImageEditingManager.h',
|
|
174
|
+
'RCTImageLoader.h',
|
|
175
|
+
'RCTImageLoaderLoggable.h',
|
|
176
|
+
'RCTImageLoaderProtocol.h',
|
|
177
|
+
'RCTImageLoaderWithAttributionProtocol.h',
|
|
178
|
+
'RCTImagePlugins.h',
|
|
179
|
+
'RCTImageShadowView.h',
|
|
180
|
+
'RCTImageSource.h',
|
|
181
|
+
'RCTImageStoreManager.h',
|
|
182
|
+
'RCTImageURLLoader.h',
|
|
183
|
+
'RCTImageURLLoaderWithAttribution.h',
|
|
184
|
+
'RCTImageUtils.h',
|
|
185
|
+
'RCTImageView.h',
|
|
186
|
+
'RCTImageViewManager.h',
|
|
187
|
+
'RCTInitializing.h',
|
|
188
|
+
'RCTInputAccessoryShadowView.h',
|
|
189
|
+
'RCTInputAccessoryView.h',
|
|
190
|
+
'RCTInputAccessoryViewContent.h',
|
|
191
|
+
'RCTInputAccessoryViewManager.h',
|
|
192
|
+
'RCTInspector.h',
|
|
193
|
+
'RCTInspectorDevServerHelper.h',
|
|
194
|
+
'RCTInspectorPackagerConnection.h',
|
|
195
|
+
'RCTInterpolationAnimatedNode.h',
|
|
196
|
+
'RCTInvalidating.h',
|
|
197
|
+
'RCTJSStackFrame.h',
|
|
198
|
+
'RCTJSThread.h',
|
|
199
|
+
'RCTJavaScriptExecutor.h',
|
|
200
|
+
'RCTJavaScriptLoader.h',
|
|
201
|
+
'RCTKeyCommands.h',
|
|
202
|
+
'RCTKeyboardObserver.h',
|
|
203
|
+
'RCTLayout.h',
|
|
204
|
+
'RCTLayoutAnimation.h',
|
|
205
|
+
'RCTLayoutAnimationGroup.h',
|
|
206
|
+
'RCTLinkingManager.h',
|
|
207
|
+
'RCTLinkingPlugins.h',
|
|
208
|
+
'RCTLocalAssetImageLoader.h',
|
|
209
|
+
'RCTLocalizedString.h',
|
|
210
|
+
'RCTLog.h',
|
|
211
|
+
'RCTLogBox.h',
|
|
212
|
+
'RCTLogBoxView.h',
|
|
213
|
+
'RCTMacros.h',
|
|
214
|
+
'RCTManagedPointer.h',
|
|
215
|
+
'RCTMockDef.h',
|
|
216
|
+
'RCTModalHostView.h',
|
|
217
|
+
'RCTModalHostViewController.h',
|
|
218
|
+
'RCTModalHostViewManager.h',
|
|
219
|
+
'RCTModalManager.h',
|
|
220
|
+
'RCTModuleData.h',
|
|
221
|
+
'RCTModuleMethod.h',
|
|
222
|
+
'RCTModuloAnimatedNode.h',
|
|
223
|
+
'RCTMultilineTextInputView.h',
|
|
224
|
+
'RCTMultilineTextInputViewManager.h',
|
|
225
|
+
'RCTMultipartDataTask.h',
|
|
226
|
+
'RCTMultipartStreamReader.h',
|
|
227
|
+
'RCTMultiplicationAnimatedNode.h',
|
|
228
|
+
'RCTNativeAnimatedModule.h',
|
|
229
|
+
'RCTNativeAnimatedNodesManager.h',
|
|
230
|
+
'RCTNativeAnimatedTurboModule.h',
|
|
231
|
+
'RCTNetworkPlugins.h',
|
|
232
|
+
'RCTNetworkTask.h',
|
|
233
|
+
'RCTNetworking.h',
|
|
234
|
+
'RCTNullability.h',
|
|
235
|
+
'RCTObjectAnimatedNode.h',
|
|
236
|
+
'RCTPLTag.h',
|
|
237
|
+
'RCTPackagerClient.h',
|
|
238
|
+
'RCTPackagerConnection.h',
|
|
239
|
+
'RCTParserUtils.h',
|
|
240
|
+
'RCTPerformanceLogger.h',
|
|
241
|
+
'RCTPerformanceLoggerLabels.h',
|
|
242
|
+
'RCTPlatform.h',
|
|
243
|
+
'RCTPointerEvents.h',
|
|
244
|
+
'RCTProfile.h',
|
|
245
|
+
'RCTPropsAnimatedNode.h',
|
|
246
|
+
'RCTRawTextShadowView.h',
|
|
247
|
+
'RCTRawTextViewManager.h',
|
|
248
|
+
'RCTReconnectingWebSocket.h',
|
|
249
|
+
'RCTRedBox.h',
|
|
250
|
+
'RCTRedBoxExtraDataViewController.h',
|
|
251
|
+
'RCTRedBoxSetEnabled.h',
|
|
252
|
+
'RCTRefreshControl.h',
|
|
253
|
+
'RCTRefreshControlManager.h',
|
|
254
|
+
'RCTRefreshableProtocol.h',
|
|
255
|
+
'RCTReloadCommand.h',
|
|
256
|
+
'RCTResizeMode.h',
|
|
257
|
+
'RCTRootContentView.h',
|
|
258
|
+
'RCTRootShadowView.h',
|
|
259
|
+
'RCTRootView.h',
|
|
260
|
+
'RCTRootViewDelegate.h',
|
|
261
|
+
'RCTRootViewInternal.h',
|
|
262
|
+
'RCTRuntimeExecutorModule.h',
|
|
263
|
+
'RCTSafeAreaShadowView.h',
|
|
264
|
+
'RCTSafeAreaView.h',
|
|
265
|
+
'RCTSafeAreaViewLocalData.h',
|
|
266
|
+
'RCTSafeAreaViewManager.h',
|
|
267
|
+
'RCTScrollContentShadowView.h',
|
|
268
|
+
'RCTScrollContentView.h',
|
|
269
|
+
'RCTScrollContentViewManager.h',
|
|
270
|
+
'RCTScrollEvent.h',
|
|
271
|
+
'RCTScrollView.h',
|
|
272
|
+
'RCTScrollViewManager.h',
|
|
273
|
+
'RCTScrollableProtocol.h',
|
|
274
|
+
'RCTSegmentedControl.h',
|
|
275
|
+
'RCTSegmentedControlManager.h',
|
|
276
|
+
'RCTSettingsManager.h',
|
|
277
|
+
'RCTSettingsPlugins.h',
|
|
278
|
+
'RCTShadowView+Internal.h',
|
|
279
|
+
'RCTShadowView+Layout.h',
|
|
280
|
+
'RCTShadowView.h',
|
|
281
|
+
'RCTSinglelineTextInputView.h',
|
|
282
|
+
'RCTSinglelineTextInputViewManager.h',
|
|
283
|
+
'RCTSourceCode.h',
|
|
284
|
+
'RCTSpringAnimation.h',
|
|
285
|
+
'RCTStatusBarManager.h',
|
|
286
|
+
'RCTStyleAnimatedNode.h',
|
|
287
|
+
'RCTSubtractionAnimatedNode.h',
|
|
288
|
+
'RCTSurface.h',
|
|
289
|
+
'RCTSurfaceDelegate.h',
|
|
290
|
+
'RCTSurfaceHostingProxyRootView.h',
|
|
291
|
+
'RCTSurfaceHostingView.h',
|
|
292
|
+
'RCTSurfacePresenterStub.h',
|
|
293
|
+
'RCTSurfaceProtocol.h',
|
|
294
|
+
'RCTSurfaceRootShadowView.h',
|
|
295
|
+
'RCTSurfaceRootShadowViewDelegate.h',
|
|
296
|
+
'RCTSurfaceRootView.h',
|
|
297
|
+
'RCTSurfaceSizeMeasureMode.h',
|
|
298
|
+
'RCTSurfaceStage.h',
|
|
299
|
+
'RCTSurfaceView+Internal.h',
|
|
300
|
+
'RCTSurfaceView.h',
|
|
301
|
+
'RCTSwitch.h',
|
|
302
|
+
'RCTSwitchManager.h',
|
|
303
|
+
'RCTTextAttributes.h',
|
|
304
|
+
'RCTTextDecorationLineType.h',
|
|
305
|
+
'RCTTextSelection.h',
|
|
306
|
+
'RCTTextShadowView.h',
|
|
307
|
+
'RCTTextTransform.h',
|
|
308
|
+
'RCTTextView.h',
|
|
309
|
+
'RCTTextViewManager.h',
|
|
310
|
+
'RCTTiming.h',
|
|
311
|
+
'RCTTouchEvent.h',
|
|
312
|
+
'RCTTouchHandler.h',
|
|
313
|
+
'RCTTrackingAnimatedNode.h',
|
|
314
|
+
'RCTTransformAnimatedNode.h',
|
|
315
|
+
'RCTTurboModuleRegistry.h',
|
|
316
|
+
'RCTUIImageViewAnimated.h',
|
|
317
|
+
'RCTUIManager.h',
|
|
318
|
+
'RCTUIManagerObserverCoordinator.h',
|
|
319
|
+
'RCTUIManagerUtils.h',
|
|
320
|
+
'RCTUITextField.h',
|
|
321
|
+
'RCTUITextView.h',
|
|
322
|
+
'RCTUIUtils.h',
|
|
323
|
+
'RCTURLRequestDelegate.h',
|
|
324
|
+
'RCTURLRequestHandler.h',
|
|
325
|
+
'RCTUtils.h',
|
|
326
|
+
'RCTUtilsUIOverride.h',
|
|
327
|
+
'RCTValueAnimatedNode.h',
|
|
328
|
+
'RCTVersion.h',
|
|
329
|
+
'RCTVibration.h',
|
|
330
|
+
'RCTVibrationPlugins.h',
|
|
331
|
+
'RCTView.h',
|
|
332
|
+
'RCTViewManager.h',
|
|
333
|
+
'RCTViewUtils.h',
|
|
334
|
+
'RCTVirtualTextShadowView.h',
|
|
335
|
+
'RCTVirtualTextView.h',
|
|
336
|
+
'RCTVirtualTextViewManager.h',
|
|
337
|
+
'RCTWebSocketExecutor.h',
|
|
338
|
+
'RCTWebSocketModule.h',
|
|
339
|
+
'RCTWrapperViewController.h',
|
|
340
|
+
'React-Core-umbrella.h',
|
|
341
|
+
'React-Core.modulemap',
|
|
342
|
+
'UIView+Private.h',
|
|
343
|
+
'UIView+React.h',
|
|
344
|
+
]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DEFAULT_SOURCE_SKIPS = exports.DEFAULT_IGNORE_PATHS = void 0;
|
|
18
|
+
__exportStar(require("./Fingerprint"), exports);
|
|
19
|
+
__exportStar(require("./Fingerprint.types"), exports);
|
|
20
|
+
__exportStar(require("./sourcer/SourceSkips"), exports);
|
|
21
|
+
var Options_1 = require("./Options");
|
|
22
|
+
Object.defineProperty(exports, "DEFAULT_IGNORE_PATHS", { enumerable: true, get: function () { return Options_1.DEFAULT_IGNORE_PATHS; } });
|
|
23
|
+
Object.defineProperty(exports, "DEFAULT_SOURCE_SKIPS", { enumerable: true, get: function () { return Options_1.DEFAULT_SOURCE_SKIPS; } });
|