@expo/fingerprint 0.20.13 → 0.21.1
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/build/Config.js +69 -44
- package/build/Config.js.map +1 -1
- package/build/Dedup.js +82 -36
- package/build/Dedup.js.map +1 -1
- package/build/ExpoConfig.d.ts +11 -2
- package/build/ExpoConfig.js +118 -34
- package/build/ExpoConfig.js.map +1 -1
- package/build/ExpoConfigLoader.d.ts +41 -0
- package/build/ExpoConfigLoader.js +185 -145
- package/build/ExpoConfigLoader.js.map +1 -1
- package/build/ExpoResolver.js +77 -43
- package/build/ExpoResolver.js.map +1 -1
- package/build/Fingerprint.js +67 -76
- package/build/Fingerprint.js.map +1 -1
- package/build/Fingerprint.types.d.ts +98 -5
- package/build/Fingerprint.types.js +6 -3
- package/build/Fingerprint.types.js.map +1 -1
- package/build/Options.d.ts +1 -2
- package/build/Options.js +101 -51
- package/build/Options.js.map +1 -1
- package/build/Presets.d.ts +26 -0
- package/build/Presets.js +50 -0
- package/build/Presets.js.map +1 -0
- package/build/ProjectWorkflow.js +129 -67
- package/build/ProjectWorkflow.js.map +1 -1
- package/build/Sort.js +30 -16
- package/build/Sort.js.map +1 -1
- package/build/hash/FileHookTransform.js +26 -20
- package/build/hash/FileHookTransform.js.map +1 -1
- package/build/hash/Hash.d.ts +8 -1
- package/build/hash/Hash.js +208 -116
- package/build/hash/Hash.js.map +1 -1
- package/build/hash/ReactImportsPatcher.js +39 -27
- package/build/hash/ReactImportsPatcher.js.map +1 -1
- package/build/index.js +40 -22
- package/build/index.js.map +1 -1
- package/build/sourcer/AutolinkingConfig.d.ts +19 -0
- package/build/sourcer/AutolinkingConfig.js +159 -0
- package/build/sourcer/AutolinkingConfig.js.map +1 -0
- package/build/sourcer/Bare.js +192 -94
- package/build/sourcer/Bare.js.map +1 -1
- package/build/sourcer/Expo.d.ts +3 -2
- package/build/sourcer/Expo.js +264 -121
- package/build/sourcer/Expo.js.map +1 -1
- package/build/sourcer/Packages.d.ts +4 -3
- package/build/sourcer/Packages.js +83 -23
- package/build/sourcer/Packages.js.map +1 -1
- package/build/sourcer/PatchPackage.js +32 -14
- package/build/sourcer/PatchPackage.js.map +1 -1
- package/build/sourcer/SourceSkips.d.ts +27 -2
- package/build/sourcer/SourceSkips.js +65 -48
- package/build/sourcer/SourceSkips.js.map +1 -1
- package/build/sourcer/Sourcer.js +57 -38
- package/build/sourcer/Sourcer.js.map +1 -1
- package/build/sourcer/Utils.d.ts +14 -0
- package/build/sourcer/Utils.js +113 -41
- package/build/sourcer/Utils.js.map +1 -1
- package/build/types/module.d.ts +7 -0
- package/build/utils/Concurrency.js +29 -22
- package/build/utils/Concurrency.js.map +1 -1
- package/build/utils/Path.d.ts +5 -0
- package/build/utils/Path.js +138 -75
- package/build/utils/Path.js.map +1 -1
- package/build/utils/Predicates.js +11 -3
- package/build/utils/Predicates.js.map +1 -1
- package/build/utils/Profile.js +29 -20
- package/build/utils/Profile.js.map +1 -1
- package/build/utils/SpawnIPC.js +41 -16
- package/build/utils/SpawnIPC.js.map +1 -1
- package/cli/build/cli.js +94 -60
- package/cli/build/cli.js.map +1 -0
- package/cli/build/commands/diffFingerprints.js +76 -53
- package/cli/build/commands/diffFingerprints.js.map +1 -0
- package/cli/build/commands/generateFingerprint.js +129 -72
- package/cli/build/commands/generateFingerprint.js.map +1 -0
- package/cli/build/runLegacyCLIAsync.js +31 -22
- package/cli/build/runLegacyCLIAsync.js.map +1 -0
- package/cli/build/utils/args.js +110 -67
- package/cli/build/utils/args.js.map +1 -0
- package/cli/build/utils/errors.js +49 -20
- package/cli/build/utils/errors.js.map +1 -0
- package/cli/build/utils/log.js +62 -20
- package/cli/build/utils/log.js.map +1 -0
- package/cli/build/utils/readFingerprintFileAsync.js +25 -9
- package/cli/build/utils/readFingerprintFileAsync.js.map +1 -0
- package/cli/build/utils/withConsoleDisabledAsync.js +16 -8
- package/cli/build/utils/withConsoleDisabledAsync.js.map +1 -0
- package/package.json +37 -31
package/build/hash/Hash.js
CHANGED
|
@@ -1,33 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
createContentsHashResultsAsync: null,
|
|
7
|
+
createDirHashResultsAsync: null,
|
|
8
|
+
createFileHashResultsAsync: null,
|
|
9
|
+
createFingerprintFromSourcesAsync: null,
|
|
10
|
+
createFingerprintSourceAsync: null,
|
|
11
|
+
createPackageHashResultsAsync: null,
|
|
12
|
+
createSourceId: null
|
|
13
|
+
});
|
|
14
|
+
function _export(target, all) {
|
|
15
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_export(exports, {
|
|
21
|
+
get createContentsHashResultsAsync () {
|
|
22
|
+
return createContentsHashResultsAsync;
|
|
23
|
+
},
|
|
24
|
+
get createDirHashResultsAsync () {
|
|
25
|
+
return createDirHashResultsAsync;
|
|
26
|
+
},
|
|
27
|
+
get createFileHashResultsAsync () {
|
|
28
|
+
return createFileHashResultsAsync;
|
|
29
|
+
},
|
|
30
|
+
get createFingerprintFromSourcesAsync () {
|
|
31
|
+
return createFingerprintFromSourcesAsync;
|
|
32
|
+
},
|
|
33
|
+
get createFingerprintSourceAsync () {
|
|
34
|
+
return createFingerprintSourceAsync;
|
|
35
|
+
},
|
|
36
|
+
get createPackageHashResultsAsync () {
|
|
37
|
+
return createPackageHashResultsAsync;
|
|
38
|
+
},
|
|
39
|
+
get createSourceId () {
|
|
40
|
+
return createSourceId;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
function _crypto() {
|
|
44
|
+
const data = require("crypto");
|
|
45
|
+
_crypto = function() {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function _fs() {
|
|
51
|
+
const data = require("fs");
|
|
52
|
+
_fs = function() {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _promises() {
|
|
58
|
+
const data = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
|
59
|
+
_promises = function() {
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
function _path() {
|
|
65
|
+
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
66
|
+
_path = function() {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
function _stream() {
|
|
72
|
+
const data = require("stream");
|
|
73
|
+
_stream = function() {
|
|
74
|
+
return data;
|
|
75
|
+
};
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
const _Concurrency = require("../utils/Concurrency");
|
|
79
|
+
const _Path = require("../utils/Path");
|
|
80
|
+
const _Predicates = require("../utils/Predicates");
|
|
81
|
+
const _Profile = require("../utils/Profile");
|
|
82
|
+
const _FileHookTransform = require("./FileHookTransform");
|
|
83
|
+
const _ReactImportsPatcher = require("./ReactImportsPatcher");
|
|
84
|
+
function _interop_require_default(obj) {
|
|
85
|
+
return obj && obj.__esModule ? obj : {
|
|
86
|
+
default: obj
|
|
87
|
+
};
|
|
88
|
+
}
|
|
26
89
|
async function createFingerprintFromSourcesAsync(sources, projectRoot, options) {
|
|
27
|
-
const limiter = (0,
|
|
28
|
-
const fingerprintSources = await Promise.all(sources.map((source)
|
|
29
|
-
const hasher = (0,
|
|
30
|
-
for (const source of fingerprintSources)
|
|
90
|
+
const limiter = (0, _Concurrency.createLimiter)(options.concurrentIoLimit);
|
|
91
|
+
const fingerprintSources = await Promise.all(sources.map((source)=>createFingerprintSourceAsync(source, limiter, projectRoot, options)));
|
|
92
|
+
const hasher = (0, _crypto().createHash)(options.hashAlgorithm);
|
|
93
|
+
for (const source of fingerprintSources){
|
|
31
94
|
if (source.hash != null) {
|
|
32
95
|
hasher.update(createSourceId(source));
|
|
33
96
|
hasher.update(source.hash);
|
|
@@ -36,16 +99,12 @@ async function createFingerprintFromSourcesAsync(sources, projectRoot, options)
|
|
|
36
99
|
const hash = hasher.digest('hex');
|
|
37
100
|
return {
|
|
38
101
|
sources: fingerprintSources,
|
|
39
|
-
hash
|
|
102
|
+
hash
|
|
40
103
|
};
|
|
41
104
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Create a `FingerprintSource` from a `HashSource`
|
|
44
|
-
* This function will get a hash value and merge back to original source
|
|
45
|
-
*/
|
|
46
105
|
async function createFingerprintSourceAsync(source, limiter, projectRoot, options) {
|
|
47
106
|
let result = null;
|
|
48
|
-
switch
|
|
107
|
+
switch(source.type){
|
|
49
108
|
case 'contents':
|
|
50
109
|
result = await createContentsHashResultsAsync(source, options);
|
|
51
110
|
break;
|
|
@@ -53,7 +112,10 @@ async function createFingerprintSourceAsync(source, limiter, projectRoot, option
|
|
|
53
112
|
result = await createFileHashResultsAsync(source.filePath, limiter, projectRoot, options);
|
|
54
113
|
break;
|
|
55
114
|
case 'dir':
|
|
56
|
-
result = await (0,
|
|
115
|
+
result = await (0, _Profile.profile)(options, createDirHashResultsAsync, `createDirHashResultsAsync(${source.filePath})`)(source.filePath, limiter, projectRoot, options);
|
|
116
|
+
break;
|
|
117
|
+
case 'package':
|
|
118
|
+
result = await createPackageHashResultsAsync(source, options);
|
|
57
119
|
break;
|
|
58
120
|
default:
|
|
59
121
|
throw new Error('Unsupported source type');
|
|
@@ -61,119 +123,120 @@ async function createFingerprintSourceAsync(source, limiter, projectRoot, option
|
|
|
61
123
|
return {
|
|
62
124
|
...source,
|
|
63
125
|
hash: result?.hex ?? null,
|
|
64
|
-
...
|
|
126
|
+
...options.debug ? {
|
|
127
|
+
debugInfo: result?.debugInfo
|
|
128
|
+
} : undefined
|
|
65
129
|
};
|
|
66
130
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Create a `HashResult` from a file
|
|
69
|
-
*/
|
|
70
131
|
async function createFileHashResultsAsync(filePath, limiter, projectRoot, options) {
|
|
71
132
|
// Backup code for faster hashing
|
|
72
133
|
/*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if ((0, Path_1.isIgnoredPathWithMatchObjects)(filePath, options.ignorePathMatchObjects)) {
|
|
134
|
+
return limiter(async () => {
|
|
135
|
+
if (isIgnoredPathWithMatchObjects(filePath, options.ignorePathMatchObjects)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const hasher = createHash(options.hashAlgorithm);
|
|
140
|
+
|
|
141
|
+
const stat = await fs.stat(filePath);
|
|
142
|
+
hasher.update(`${stat.size}`);
|
|
143
|
+
|
|
144
|
+
const buffer = Buffer.alloc(4096);
|
|
145
|
+
const fd = await fs.open(filePath, 'r');
|
|
146
|
+
await fd.read(buffer, 0, buffer.length, 0);
|
|
147
|
+
await fd.close();
|
|
148
|
+
hasher.update(buffer);
|
|
149
|
+
console.log('stat', filePath, stat.size);
|
|
150
|
+
return { id: path.relative(projectRoot, filePath), hex: hasher.digest('hex') };
|
|
151
|
+
});
|
|
152
|
+
*/ return limiter(()=>{
|
|
153
|
+
return new Promise((resolve, reject)=>{
|
|
154
|
+
if ((0, _Path.isIgnoredPathWithMatchObjects)(filePath, options.ignorePathMatchObjects)) {
|
|
95
155
|
return resolve(null);
|
|
96
156
|
}
|
|
97
157
|
let resolved = false;
|
|
98
|
-
const hasher = (0,
|
|
99
|
-
const fileHookTransform = options.fileHookTransform
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
158
|
+
const hasher = (0, _crypto().createHash)(options.hashAlgorithm);
|
|
159
|
+
const fileHookTransform = options.fileHookTransform ? new _FileHookTransform.FileHookTransform({
|
|
160
|
+
type: 'file',
|
|
161
|
+
filePath
|
|
162
|
+
}, options.fileHookTransform, options.debug) : null;
|
|
163
|
+
let stream = (0, _fs().createReadStream)(_path().default.join(projectRoot, filePath), {
|
|
164
|
+
highWaterMark: 1024
|
|
104
165
|
});
|
|
105
|
-
if (options.enableReactImportsPatcher &&
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
stream = (0, stream_1.pipeline)(stream, transform, (err) => {
|
|
166
|
+
if (options.enableReactImportsPatcher && (filePath.endsWith('.h') || filePath.endsWith('.m') || filePath.endsWith('.mm'))) {
|
|
167
|
+
const transform = new _ReactImportsPatcher.ReactImportsPatchTransform();
|
|
168
|
+
stream = (0, _stream().pipeline)(stream, transform, (err)=>{
|
|
109
169
|
if (err) {
|
|
110
170
|
reject(err);
|
|
111
171
|
}
|
|
112
172
|
});
|
|
113
173
|
}
|
|
114
174
|
if (fileHookTransform) {
|
|
115
|
-
stream = (0,
|
|
175
|
+
stream = (0, _stream().pipeline)(stream, fileHookTransform, (err)=>{
|
|
116
176
|
if (err) {
|
|
117
177
|
reject(err);
|
|
118
178
|
}
|
|
119
179
|
});
|
|
120
180
|
}
|
|
121
|
-
stream.on('close', ()
|
|
181
|
+
stream.on('close', ()=>{
|
|
122
182
|
if (!resolved) {
|
|
123
183
|
const hex = hasher.digest('hex');
|
|
124
184
|
const isTransformed = fileHookTransform?.isTransformed;
|
|
125
|
-
const debugInfo = options.debug
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
185
|
+
const debugInfo = options.debug ? {
|
|
186
|
+
path: filePath,
|
|
187
|
+
hash: hex,
|
|
188
|
+
...isTransformed ? {
|
|
189
|
+
isTransformed
|
|
190
|
+
} : undefined
|
|
191
|
+
} : undefined;
|
|
132
192
|
resolve({
|
|
133
193
|
type: 'file',
|
|
134
194
|
id: filePath,
|
|
135
195
|
hex,
|
|
136
|
-
...
|
|
196
|
+
...debugInfo ? {
|
|
197
|
+
debugInfo
|
|
198
|
+
} : undefined
|
|
137
199
|
});
|
|
138
200
|
resolved = true;
|
|
139
201
|
}
|
|
140
202
|
});
|
|
141
|
-
stream.on('error', (e)
|
|
203
|
+
stream.on('error', (e)=>{
|
|
142
204
|
reject(e);
|
|
143
205
|
});
|
|
144
|
-
stream.on('data', (chunk)
|
|
206
|
+
stream.on('data', (chunk)=>{
|
|
145
207
|
hasher.update(chunk);
|
|
146
208
|
});
|
|
147
209
|
});
|
|
148
210
|
});
|
|
149
211
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Create `HashResult` for a dir.
|
|
152
|
-
* If the dir is excluded, returns null rather than a HashResult
|
|
153
|
-
*/
|
|
154
212
|
async function createDirHashResultsAsync(dirPath, limiter, projectRoot, options, depth = 0) {
|
|
155
213
|
// Using `ignoreDirMatchObjects` as an optimization to skip the whole directory
|
|
156
|
-
if ((0,
|
|
214
|
+
if ((0, _Path.isIgnoredPathWithMatchObjects)(dirPath, options.ignoreDirMatchObjects)) {
|
|
157
215
|
return null;
|
|
158
216
|
}
|
|
159
|
-
const dirents = (await
|
|
160
|
-
|
|
217
|
+
const dirents = (await _promises().default.readdir(_path().default.join(projectRoot, dirPath), {
|
|
218
|
+
withFileTypes: true
|
|
219
|
+
})).sort((a, b)=>a.name.localeCompare(b.name));
|
|
220
|
+
const results = (await Promise.all(dirents.map(async (dirent)=>{
|
|
161
221
|
if (dirent.isDirectory()) {
|
|
162
|
-
|
|
222
|
+
// Skip nested node_modules inside a package.
|
|
223
|
+
if (dirent.name === 'node_modules') {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const filePath = (0, _Path.toPosixPath)(_path().default.join(dirPath, dirent.name));
|
|
163
227
|
return await createDirHashResultsAsync(filePath, limiter, projectRoot, options, depth + 1);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const filePath = (0, Path_1.toPosixPath)(path_1.default.join(dirPath, dirent.name));
|
|
228
|
+
} else if (dirent.isFile()) {
|
|
229
|
+
const filePath = (0, _Path.toPosixPath)(_path().default.join(dirPath, dirent.name));
|
|
167
230
|
return await createFileHashResultsAsync(filePath, limiter, projectRoot, options);
|
|
168
231
|
}
|
|
169
232
|
return null;
|
|
170
|
-
}))).filter(
|
|
233
|
+
}))).filter(_Predicates.nonNullish);
|
|
171
234
|
if (results.length === 0) {
|
|
172
235
|
return null;
|
|
173
236
|
}
|
|
174
|
-
const hasher = (0,
|
|
237
|
+
const hasher = (0, _crypto().createHash)(options.hashAlgorithm);
|
|
175
238
|
const children = [];
|
|
176
|
-
for (const result of results)
|
|
239
|
+
for (const result of results){
|
|
177
240
|
hasher.update(result.id);
|
|
178
241
|
hasher.update(result.hex);
|
|
179
242
|
children.push(result.debugInfo);
|
|
@@ -183,51 +246,80 @@ async function createDirHashResultsAsync(dirPath, limiter, projectRoot, options,
|
|
|
183
246
|
type: 'dir',
|
|
184
247
|
id: dirPath,
|
|
185
248
|
hex,
|
|
186
|
-
...
|
|
249
|
+
...options.debug ? {
|
|
250
|
+
debugInfo: {
|
|
251
|
+
path: dirPath,
|
|
252
|
+
children,
|
|
253
|
+
hash: hex
|
|
254
|
+
}
|
|
255
|
+
} : undefined
|
|
187
256
|
};
|
|
188
257
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Create `HashResult` for a `HashSourceContents`
|
|
191
|
-
*/
|
|
192
258
|
async function createContentsHashResultsAsync(source, options) {
|
|
193
259
|
let isTransformed = undefined;
|
|
194
260
|
if (options.fileHookTransform) {
|
|
195
261
|
const transformedContents = options.fileHookTransform({
|
|
196
262
|
type: 'contents',
|
|
197
|
-
id: source.id
|
|
198
|
-
}, source.contents, true
|
|
263
|
+
id: source.id
|
|
264
|
+
}, source.contents, true, 'utf8') ?? '';
|
|
199
265
|
if (options.debug) {
|
|
200
266
|
isTransformed = transformedContents !== source.contents;
|
|
201
267
|
}
|
|
202
268
|
source.contents = transformedContents;
|
|
203
269
|
}
|
|
204
|
-
const hex = (0,
|
|
205
|
-
const debugInfo = options.debug
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
270
|
+
const hex = (0, _crypto().createHash)(options.hashAlgorithm).update(source.contents).digest('hex');
|
|
271
|
+
const debugInfo = options.debug ? {
|
|
272
|
+
hash: hex,
|
|
273
|
+
...isTransformed ? {
|
|
274
|
+
isTransformed
|
|
275
|
+
} : undefined
|
|
276
|
+
} : undefined;
|
|
211
277
|
return {
|
|
212
278
|
type: 'contents',
|
|
213
279
|
id: source.id,
|
|
214
280
|
hex,
|
|
215
|
-
...
|
|
281
|
+
...debugInfo ? {
|
|
282
|
+
debugInfo
|
|
283
|
+
} : undefined
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async function createPackageHashResultsAsync(source, options) {
|
|
287
|
+
if ((0, _Path.isIgnoredPathWithMatchObjects)(source.filePath, options.ignorePathMatchObjects)) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const { name, version } = source;
|
|
291
|
+
const hex = (0, _crypto().createHash)(options.hashAlgorithm).update(JSON.stringify({
|
|
292
|
+
name,
|
|
293
|
+
version
|
|
294
|
+
})).digest('hex');
|
|
295
|
+
const debugInfo = options.debug ? {
|
|
296
|
+
path: source.filePath,
|
|
297
|
+
name,
|
|
298
|
+
version,
|
|
299
|
+
hash: hex
|
|
300
|
+
} : undefined;
|
|
301
|
+
return {
|
|
302
|
+
type: 'package',
|
|
303
|
+
id: createSourceId(source),
|
|
304
|
+
hex,
|
|
305
|
+
...debugInfo ? {
|
|
306
|
+
debugInfo
|
|
307
|
+
} : undefined
|
|
216
308
|
};
|
|
217
309
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Create id from given source
|
|
220
|
-
*/
|
|
221
310
|
function createSourceId(source) {
|
|
222
|
-
switch
|
|
311
|
+
switch(source.type){
|
|
223
312
|
case 'contents':
|
|
224
313
|
return source.id;
|
|
225
314
|
case 'file':
|
|
226
315
|
return source.overrideHashKey ?? source.filePath;
|
|
227
316
|
case 'dir':
|
|
228
317
|
return source.overrideHashKey ?? source.filePath;
|
|
318
|
+
case 'package':
|
|
319
|
+
return source.overrideHashKey ?? `${source.name}@${source.version}`;
|
|
229
320
|
default:
|
|
230
321
|
throw new Error('Unsupported source type');
|
|
231
322
|
}
|
|
232
323
|
}
|
|
233
|
-
|
|
324
|
+
|
|
325
|
+
//# sourceMappingURL=Hash.js.map
|
package/build/hash/Hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["hash/Hash.ts"],"sourcesContent":[null],"names":["createContentsHashResultsAsync","createDirHashResultsAsync","createFileHashResultsAsync","createFingerprintFromSourcesAsync","createFingerprintSourceAsync","createPackageHashResultsAsync","createSourceId","sources","projectRoot","options","limiter","createLimiter","concurrentIoLimit","fingerprintSources","Promise","all","map","source","hasher","createHash","hashAlgorithm","hash","update","digest","result","type","filePath","profile","Error","hex","debug","debugInfo","undefined","resolve","reject","isIgnoredPathWithMatchObjects","ignorePathMatchObjects","resolved","fileHookTransform","FileHookTransform","stream","createReadStream","path","join","highWaterMark","enableReactImportsPatcher","endsWith","transform","ReactImportsPatchTransform","pipeline","err","on","isTransformed","id","e","chunk","dirPath","depth","ignoreDirMatchObjects","dirents","fs","readdir","withFileTypes","sort","a","b","name","localeCompare","results","dirent","isDirectory","toPosixPath","isFile","filter","nonNullish","length","children","push","transformedContents","contents","version","JSON","stringify","overrideHashKey"],"mappings":";;;;;;;;;;;;;;;;;;;;QAqQsBA;eAAAA;;QAjEAC;eAAAA;;QAlGAC;eAAAA;;QAnEAC;eAAAA;;QA6BAC;eAAAA;;QAoPAC;eAAAA;;QAwBNC;eAAAA;;;;yBAxUW;;;;;;;yBACM;;;;;;;gEAClB;;;;;;;gEACE;;;;;;;yBACuB;;;;;;6BAiBI;sBACe;4BAChC;yBACH;mCACU;qCACS;;;;;;AAKpC,eAAeH,kCACpBI,OAAqB,EACrBC,WAAmB,EACnBC,OAA0B;IAE1B,MAAMC,UAAUC,IAAAA,0BAAa,EAACF,QAAQG,iBAAiB;IACvD,MAAMC,qBAAqB,MAAMC,QAAQC,GAAG,CAC1CR,QAAQS,GAAG,CAAC,CAACC,SAAWb,6BAA6Ba,QAAQP,SAASF,aAAaC;IAGrF,MAAMS,SAASC,IAAAA,oBAAU,EAACV,QAAQW,aAAa;IAC/C,KAAK,MAAMH,UAAUJ,mBAAoB;QACvC,IAAII,OAAOI,IAAI,IAAI,MAAM;YACvBH,OAAOI,MAAM,CAAChB,eAAeW;YAC7BC,OAAOI,MAAM,CAACL,OAAOI,IAAI;QAC3B;IACF;IACA,MAAMA,OAAOH,OAAOK,MAAM,CAAC;IAE3B,OAAO;QACLhB,SAASM;QACTQ;IACF;AACF;AAMO,eAAejB,6BACpBa,MAAkB,EAClBP,OAAgB,EAChBF,WAAmB,EACnBC,OAA0B;IAE1B,IAAIe,SAA4B;IAChC,OAAQP,OAAOQ,IAAI;QACjB,KAAK;YACHD,SAAS,MAAMxB,+BAA+BiB,QAAQR;YACtD;QACF,KAAK;YACHe,SAAS,MAAMtB,2BAA2Be,OAAOS,QAAQ,EAAEhB,SAASF,aAAaC;YACjF;QACF,KAAK;YACHe,SAAS,MAAMG,IAAAA,gBAAO,EACpBlB,SACA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S,QAAQ;QAClD,KAAK;YACH,OAAOT,OAAOkE,eAAe,IAAI,GAAGlE,OAAOiD,IAAI,CAAC,CAAC,EAAEjD,OAAO+D,OAAO,EAAE;QACrE;YACE,MAAM,IAAIpD,MAAM;IACpB;AACF"}
|
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
ReactImportsPatchTransform: null,
|
|
7
|
+
patchChunk: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
get ReactImportsPatchTransform () {
|
|
17
|
+
return ReactImportsPatchTransform;
|
|
18
|
+
},
|
|
19
|
+
get patchChunk () {
|
|
20
|
+
return patchChunk;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function _stream() {
|
|
24
|
+
const data = require("stream");
|
|
25
|
+
_stream = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
class ReactImportsPatchTransform extends _stream().Transform {
|
|
10
31
|
readLength = 0;
|
|
11
32
|
lengthOfFilePortionContainingHeadersToTransform;
|
|
12
33
|
transformFn;
|
|
13
|
-
static DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM = 16 * 1024;
|
|
14
|
-
constructor(options)
|
|
34
|
+
static DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM = 16 * 1024;
|
|
35
|
+
constructor(options){
|
|
15
36
|
super();
|
|
16
|
-
this.lengthOfFilePortionContainingHeadersToTransform =
|
|
17
|
-
options?.lengthOfFilePortionContainingHeadersToTransform ??
|
|
18
|
-
ReactImportsPatchTransform.DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM;
|
|
37
|
+
this.lengthOfFilePortionContainingHeadersToTransform = options?.lengthOfFilePortionContainingHeadersToTransform ?? ReactImportsPatchTransform.DEFAULT_LENGTH_OF_FILE_PORTION_CONTAINING_HEADERS_TO_TRANSFORM;
|
|
19
38
|
this.transformFn = options?.transformFn ?? patchChunk;
|
|
20
39
|
}
|
|
21
40
|
_transform(chunk, _encoding, callback) {
|
|
@@ -23,11 +42,9 @@ class ReactImportsPatchTransform extends stream_1.Transform {
|
|
|
23
42
|
let result;
|
|
24
43
|
if (remainingLength <= 0) {
|
|
25
44
|
result = chunk.toString();
|
|
26
|
-
}
|
|
27
|
-
else if (remainingLength >= chunk.length) {
|
|
45
|
+
} else if (remainingLength >= chunk.length) {
|
|
28
46
|
result = this.transformFn(chunk.toString());
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
47
|
+
} else {
|
|
31
48
|
const portionToTransform = chunk.slice(0, remainingLength).toString();
|
|
32
49
|
const portionToLeave = chunk.slice(remainingLength).toString();
|
|
33
50
|
result = this.transformFn(portionToTransform) + portionToLeave;
|
|
@@ -37,14 +54,8 @@ class ReactImportsPatchTransform extends stream_1.Transform {
|
|
|
37
54
|
callback();
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
|
-
exports.ReactImportsPatchTransform = ReactImportsPatchTransform;
|
|
41
|
-
/**
|
|
42
|
-
* Patch imports from a data chunk
|
|
43
|
-
* @param headerSet prebuilt React-Core header set
|
|
44
|
-
* @param chunk target chunk data
|
|
45
|
-
*/
|
|
46
57
|
function patchChunk(chunk, headerSet = HEADER_SET) {
|
|
47
|
-
let transformContent = chunk.replace(/(?<=^\s*)#import\s+"(.+)"(?=\s*$)/gm, (match, headerName)
|
|
58
|
+
let transformContent = chunk.replace(/(?<=^\s*)#import\s+"(.+)"(?=\s*$)/gm, (match, headerName)=>{
|
|
48
59
|
// `#import "RCTBridge.h"` -> `#import <React/RCTBridge.h>`
|
|
49
60
|
if (headerSet.has(headerName)) {
|
|
50
61
|
return `#import <React/${headerName}>`;
|
|
@@ -59,7 +70,7 @@ function patchChunk(chunk, headerSet = HEADER_SET) {
|
|
|
59
70
|
// Otherwise, return original import
|
|
60
71
|
return match;
|
|
61
72
|
});
|
|
62
|
-
transformContent = transformContent.replace(/(?<=^\s*)#(if|elif)\s+__has_include\("(.+)"\)(?=\s*$)/gm, (match, ifPrefix, headerName)
|
|
73
|
+
transformContent = transformContent.replace(/(?<=^\s*)#(if|elif)\s+__has_include\("(.+)"\)(?=\s*$)/gm, (match, ifPrefix, headerName)=>{
|
|
63
74
|
// `#if __has_include("RCTBridge.h")` -> `#if __has_include(<React/RCTBridge.h>)`
|
|
64
75
|
if (headerSet.has(headerName)) {
|
|
65
76
|
return `#${ifPrefix} __has_include(<React/${headerName}>)`;
|
|
@@ -342,6 +353,7 @@ const HEADER_SET = new Set([
|
|
|
342
353
|
'React-Core-umbrella.h',
|
|
343
354
|
'React-Core.modulemap',
|
|
344
355
|
'UIView+Private.h',
|
|
345
|
-
'UIView+React.h'
|
|
356
|
+
'UIView+React.h'
|
|
346
357
|
]);
|
|
347
|
-
|
|
358
|
+
|
|
359
|
+
//# sourceMappingURL=ReactImportsPatcher.js.map
|