expo 58.0.1 → 58.0.2
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/android/build.gradle +2 -2
- package/bundledNativeModules.json +71 -71
- package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
- package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
- package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
- package/package.json +11 -11
- package/scripts/spm/__tests__/app-target.test.js +105 -1
- package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
- package/scripts/spm/__tests__/classify.test.js +17 -19
- package/scripts/spm/__tests__/diagnostics.test.js +705 -132
- package/scripts/spm/__tests__/manifests.test.js +1086 -75
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +2549 -346
- package/scripts/spm/app-target.js +42 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +54 -77
- package/scripts/spm/diagnostics.js +540 -147
- package/scripts/spm/flavored-frameworks.js +80 -125
- package/scripts/spm/manifests.js +523 -205
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +592 -277
- package/scripts/spm/podspec.js +56 -19
- package/template.tgz +0 -0
|
@@ -15,13 +15,11 @@ const { execFileSync } = require('child_process');
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
|
|
18
|
+
const { pluginError } = require('./diagnostics');
|
|
19
|
+
|
|
18
20
|
const FLAVORS = ['debug', 'release'];
|
|
19
21
|
|
|
20
|
-
/**
|
|
21
|
-
* Byte order, the order CocoaPods sorts in. Declaration order reaches the build:
|
|
22
|
-
* it decides which contributor a colliding artifact is taken from, so it must not
|
|
23
|
-
* vary with the machine's locale.
|
|
24
|
-
*/
|
|
22
|
+
/** CocoaPods' byte order: it picks which contributor wins a collision, so never locale-dependent. */
|
|
25
23
|
const byteOrder = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
26
24
|
|
|
27
25
|
function stableFrameworkId(frameworkName) {
|
|
@@ -53,10 +51,8 @@ function existingArtifactSource(baseDir, flavor, frameworkName) {
|
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* package at `moduleRoot`. `buildPath` is relative to a prebuild output root,
|
|
59
|
-
* `bundledPath` to the package's `prebuilds` directory.
|
|
54
|
+
* Lookup order: EXPO_PRECOMPILED_MODULES_PATH, monorepo prebuild output, the npm package's
|
|
55
|
+
* `prebuilds/` copy.
|
|
60
56
|
*/
|
|
61
57
|
function precompiledBaseDirs(buildPath, moduleRoot, bundledPath) {
|
|
62
58
|
const bases = [];
|
|
@@ -91,35 +87,33 @@ function validateTarEntries(tarballPath, frameworkName) {
|
|
|
91
87
|
.map((entry) => entry.replace(/^\.\//, '').replace(/\/$/, ''))
|
|
92
88
|
.filter(Boolean);
|
|
93
89
|
if (entries.length === 0) {
|
|
94
|
-
throw
|
|
90
|
+
throw pluginError({ what: `${tarballPath} is empty` });
|
|
95
91
|
}
|
|
96
92
|
const roots = new Set();
|
|
97
93
|
for (const entry of entries) {
|
|
98
94
|
const parts = entry.split('/');
|
|
99
95
|
if (path.isAbsolute(entry) || parts.includes('..')) {
|
|
100
|
-
throw
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
96
|
+
throw pluginError({
|
|
97
|
+
what: `${tarballPath} holds the unsafe path '${entry}'.`,
|
|
98
|
+
why: 'Extracting it would write outside the plugin cache, so the archive is not a precompiled Expo artifact.',
|
|
99
|
+
how: 'Delete it and rebuild or re-download the precompiled module.',
|
|
100
|
+
});
|
|
105
101
|
}
|
|
106
102
|
if (!/.+\.xcframework$/.test(parts[0])) {
|
|
107
|
-
throw
|
|
108
|
-
`
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
);
|
|
103
|
+
throw pluginError({
|
|
104
|
+
what: `in ${tarballPath}, '${entry}' is not part of an .xcframework.`,
|
|
105
|
+
why: 'A flavor tarball holds only XCFramework directories, so this archive was packed by something other than the Expo prebuild pipeline.',
|
|
106
|
+
how: 'Delete it and rebuild or re-download the precompiled module.',
|
|
107
|
+
});
|
|
113
108
|
}
|
|
114
109
|
roots.add(parts[0]);
|
|
115
110
|
}
|
|
116
111
|
if (!roots.has(expectedRoot)) {
|
|
117
|
-
throw
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
);
|
|
112
|
+
throw pluginError({
|
|
113
|
+
what: `${tarballPath} does not contain ${expectedRoot}; it holds ${Array.from(roots).sort().join(', ')}.`,
|
|
114
|
+
why: 'The tarball belongs to a different product or the prebuild for this one did not finish.',
|
|
115
|
+
how: 'Rebuild the module with the Expo prebuild pipeline, or re-download its precompiled artifacts.',
|
|
116
|
+
});
|
|
123
117
|
}
|
|
124
118
|
}
|
|
125
119
|
|
|
@@ -148,9 +142,9 @@ function extractTarball(sourcePath, frameworkName, cacheDir, flavor) {
|
|
|
148
142
|
execFileSync('tar', ['-xzf', sourcePath, '-C', temp], { stdio: 'pipe' });
|
|
149
143
|
const extracted = path.join(temp, `${frameworkName}.xcframework`);
|
|
150
144
|
if (!fs.existsSync(path.join(extracted, 'Info.plist'))) {
|
|
151
|
-
throw
|
|
152
|
-
|
|
153
|
-
);
|
|
145
|
+
throw pluginError({
|
|
146
|
+
what: `${sourcePath} did not extract ${frameworkName}.xcframework/Info.plist`,
|
|
147
|
+
});
|
|
154
148
|
}
|
|
155
149
|
fs.writeFileSync(path.join(temp, '.source.json'), stamp, 'utf8');
|
|
156
150
|
});
|
|
@@ -194,30 +188,26 @@ function validateFlavoredFramework(framework) {
|
|
|
194
188
|
framework.flavors == null ||
|
|
195
189
|
typeof framework.flavors !== 'object'
|
|
196
190
|
) {
|
|
197
|
-
throw
|
|
198
|
-
'
|
|
199
|
-
|
|
200
|
-
);
|
|
191
|
+
throw pluginError({
|
|
192
|
+
what: 'flavored framework declarations require a stable id, frameworkName, linkage="dynamic", and debug/release paths',
|
|
193
|
+
});
|
|
201
194
|
}
|
|
202
195
|
|
|
203
196
|
const normalized = {};
|
|
204
197
|
for (const flavor of FLAVORS) {
|
|
205
198
|
const value = framework.flavors[flavor];
|
|
206
199
|
if (typeof value !== 'string' || !path.isAbsolute(value)) {
|
|
207
|
-
throw
|
|
208
|
-
`[expo-spm-plugin] ${framework.frameworkName} ${flavor} path must be absolute`
|
|
209
|
-
);
|
|
200
|
+
throw pluginError({ what: `${framework.frameworkName} ${flavor} path must be absolute` });
|
|
210
201
|
}
|
|
211
202
|
if (path.basename(value) !== `${framework.frameworkName}.xcframework`) {
|
|
212
|
-
throw
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
203
|
+
throw pluginError({
|
|
204
|
+
what: `${framework.frameworkName} ${flavor} path must identify ${framework.frameworkName}.xcframework: ${value}`,
|
|
205
|
+
});
|
|
216
206
|
}
|
|
217
207
|
if (!fs.existsSync(path.join(value, 'Info.plist'))) {
|
|
218
|
-
throw
|
|
219
|
-
|
|
220
|
-
);
|
|
208
|
+
throw pluginError({
|
|
209
|
+
what: `${framework.frameworkName} ${flavor} XCFramework is incomplete: ${value}`,
|
|
210
|
+
});
|
|
221
211
|
}
|
|
222
212
|
normalized[flavor] = path.resolve(value);
|
|
223
213
|
}
|
|
@@ -245,11 +235,10 @@ function resolveFlavoredFramework({ packageName, moduleRoot, frameworkName, cach
|
|
|
245
235
|
}
|
|
246
236
|
for (const flavor of FLAVORS) {
|
|
247
237
|
if (sources[flavor] == null) {
|
|
248
|
-
throw
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
);
|
|
238
|
+
throw pluginError({
|
|
239
|
+
what: `${frameworkName} has an incomplete precompiled pair in ${baseDir}: missing ${flavor}.`,
|
|
240
|
+
how: 'Run the Expo prebuild pipeline for both Debug and Release before react-native spm update.',
|
|
241
|
+
});
|
|
253
242
|
}
|
|
254
243
|
}
|
|
255
244
|
return validateFlavoredFramework({
|
|
@@ -274,39 +263,33 @@ function spmDependencyBaseDirs(depName, ownerModuleRoot) {
|
|
|
274
263
|
return precompiledBaseDirs(['.spm-deps', depName], ownerModuleRoot, ['spm-deps', depName]);
|
|
275
264
|
}
|
|
276
265
|
|
|
277
|
-
/**
|
|
278
|
-
* A dependency copied verbatim from an upstream `.binaryTarget` can be a static
|
|
279
|
-
* library, and one built from a package whose product is named differently ships
|
|
280
|
-
* a differently named framework. Both reach RN and the interface tree as a slice
|
|
281
|
-
* that is not `<Dep>.framework`, and fail there with a message naming neither the
|
|
282
|
-
* dependency nor the module that pulled it in — so they are rejected here.
|
|
283
|
-
*/
|
|
284
266
|
function readXcframeworkPlist(plistPath) {
|
|
285
267
|
try {
|
|
286
268
|
return JSON.parse(
|
|
287
269
|
execFileSync('plutil', ['-convert', 'json', '-o', '-', plistPath], { encoding: 'utf8' })
|
|
288
270
|
);
|
|
289
271
|
} catch (error) {
|
|
290
|
-
throw
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
'
|
|
294
|
-
'pipeline, or reinstall the package that ships it.',
|
|
272
|
+
throw pluginError(
|
|
273
|
+
{
|
|
274
|
+
what: `${plistPath} could not be read as a property list: ${error.message}.`,
|
|
275
|
+
why: 'An XCFramework keeps the list of what it holds there, so this one is damaged or was never an XCFramework.',
|
|
276
|
+
how: 'Delete it and rebuild the dependency with the Expo prebuild pipeline, or reinstall the package that ships it.',
|
|
277
|
+
},
|
|
295
278
|
{ cause: error }
|
|
296
279
|
);
|
|
297
280
|
}
|
|
298
281
|
}
|
|
299
282
|
|
|
283
|
+
/** Rejects a static library or misnamed framework here, where the error can name the dependency. */
|
|
300
284
|
function assertEmbeddableFramework(depName, xcframeworkPath) {
|
|
301
285
|
const plistPath = path.join(xcframeworkPath, 'Info.plist');
|
|
302
286
|
const plist = readXcframeworkPlist(plistPath);
|
|
303
287
|
if (plist.AvailableLibraries != null && !Array.isArray(plist.AvailableLibraries)) {
|
|
304
|
-
throw
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
);
|
|
288
|
+
throw pluginError({
|
|
289
|
+
what: `${plistPath} lists AvailableLibraries as something other than a list of slices, so the plugin cannot tell what the XCFramework holds.`,
|
|
290
|
+
why: 'The artifact is damaged.',
|
|
291
|
+
how: 'Delete it and rebuild the dependency with the Expo prebuild pipeline, or reinstall the package that ships it.',
|
|
292
|
+
});
|
|
310
293
|
}
|
|
311
294
|
const libraries = plist.AvailableLibraries ?? [];
|
|
312
295
|
const expected = `${depName}.framework`;
|
|
@@ -317,23 +300,15 @@ function assertEmbeddableFramework(depName, xcframeworkPath) {
|
|
|
317
300
|
const found =
|
|
318
301
|
unusable.map((libraryPath) => libraryPath ?? 'a slice with no LibraryPath').join(', ') ||
|
|
319
302
|
'no library slices';
|
|
320
|
-
throw
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
"Expo prebuild pipeline, or exclude the Expo module that links it in your app's " +
|
|
326
|
-
'package.json: "expo": { "autolinking": { "exclude": [...] } }.'
|
|
327
|
-
);
|
|
303
|
+
throw pluginError({
|
|
304
|
+
what: `${depName} does not ship a ${expected}: ${xcframeworkPath} holds ${found}.`,
|
|
305
|
+
why: "React Native links and embeds Expo's precompiled dependencies as dynamic frameworks named after the product, so a static library, a differently named framework and an XCFramework without slices are all unusable.",
|
|
306
|
+
how: 'Rebuild the dependency with the Expo prebuild pipeline, or exclude the Expo module that links it in your app\'s package.json: "expo": { "autolinking": { "exclude": [...] } }.',
|
|
307
|
+
});
|
|
328
308
|
}
|
|
329
309
|
}
|
|
330
310
|
|
|
331
|
-
/**
|
|
332
|
-
* XCFrameworks are directories; a stale file of the same name is not one. Only an
|
|
333
|
-
* absent path counts as "not built here" — swallowing every error would make an
|
|
334
|
-
* unreadable one look identical to a missing artifact, and the app would be built
|
|
335
|
-
* without a dependency it links.
|
|
336
|
-
*/
|
|
311
|
+
/** Only ENOENT/ENOTDIR mean absent; other errors must not look like a missing artifact. */
|
|
337
312
|
function isDirectory(candidate) {
|
|
338
313
|
try {
|
|
339
314
|
return fs.statSync(candidate).isDirectory();
|
|
@@ -341,22 +316,20 @@ function isDirectory(candidate) {
|
|
|
341
316
|
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {
|
|
342
317
|
return false;
|
|
343
318
|
}
|
|
344
|
-
throw
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
'
|
|
348
|
-
'the Expo prebuild pipeline — then run `npx react-native spm update` again.',
|
|
319
|
+
throw pluginError(
|
|
320
|
+
{
|
|
321
|
+
what: `${candidate} could not be read: ${error.message}.`,
|
|
322
|
+
why: 'The plugin cannot tell whether a precompiled dependency is there, and it will not silently build an app without one.',
|
|
323
|
+
how: 'Make that path readable — or delete it and rebuild the dependency with the Expo prebuild pipeline — then run `npx react-native spm update` again.',
|
|
324
|
+
},
|
|
349
325
|
{ cause: error }
|
|
350
326
|
);
|
|
351
327
|
}
|
|
352
328
|
}
|
|
353
329
|
|
|
354
330
|
/**
|
|
355
|
-
* RN
|
|
356
|
-
*
|
|
357
|
-
* distinct products can collide after `stableFrameworkId` (Foo and ExpoFoo both
|
|
358
|
-
* become expo-foo), and a dependency can carry the name of a module, so the check
|
|
359
|
-
* belongs on the combined array rather than on either source.
|
|
331
|
+
* RN rejects the whole graph on a repeated id/name (Foo and ExpoFoo both → expo-foo).
|
|
332
|
+
* A dependency can carry a module's name, so this runs on the combined array.
|
|
360
333
|
*/
|
|
361
334
|
function assertDistinctFlavoredFrameworks(frameworks) {
|
|
362
335
|
const describe = (framework) =>
|
|
@@ -371,15 +344,11 @@ function assertDistinctFlavoredFrameworks(frameworks) {
|
|
|
371
344
|
for (const framework of frameworks) {
|
|
372
345
|
const previous = seen.get(framework[key]);
|
|
373
346
|
if (previous != null) {
|
|
374
|
-
throw
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
"Exclude the Expo module that brings in one of the two in your app's package.json: " +
|
|
380
|
-
'"expo": { "autolinking": { "exclude": [...] } }, and report the pair at ' +
|
|
381
|
-
'https://github.com/expo/expo/issues — one of the two products has to be renamed.'
|
|
382
|
-
);
|
|
347
|
+
throw pluginError({
|
|
348
|
+
what: `${describe(previous)} and ${describe(framework)} both declare the ${label} "${framework[key]}".`,
|
|
349
|
+
why: 'React Native embeds each flavored framework once and rejects the whole autolinking graph over a collision, so no Expo module would build.',
|
|
350
|
+
how: 'Exclude the Expo module that brings in one of the two in your app\'s package.json: "expo": { "autolinking": { "exclude": [...] } }, and report the pair at https://github.com/expo/expo/issues — one of the two products has to be renamed.',
|
|
351
|
+
});
|
|
383
352
|
}
|
|
384
353
|
seen.set(framework[key], framework);
|
|
385
354
|
}
|
|
@@ -387,10 +356,8 @@ function assertDistinctFlavoredFrameworks(frameworks) {
|
|
|
387
356
|
}
|
|
388
357
|
|
|
389
358
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* a complete bundled copy — CocoaPods resolves it the same way in
|
|
393
|
-
* `expo-modules-autolinking/scripts/ios/precompiled_modules.rb`.
|
|
359
|
+
* Null when no artifact exists. Each flavor walks all candidates, so a partial monorepo build
|
|
360
|
+
* cannot shadow a complete bundled copy (as precompiled_modules.rb).
|
|
394
361
|
*/
|
|
395
362
|
function resolveSpmDependencyFramework(depName, ownerModuleRoot) {
|
|
396
363
|
const bases = spmDependencyBaseDirs(depName, ownerModuleRoot);
|
|
@@ -405,14 +372,11 @@ function resolveSpmDependencyFramework(depName, ownerModuleRoot) {
|
|
|
405
372
|
}
|
|
406
373
|
for (const flavor of FLAVORS) {
|
|
407
374
|
if (flavors[flavor] == null) {
|
|
408
|
-
throw
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
'dependency for both flavors with the Expo prebuild pipeline, or install a package ' +
|
|
414
|
-
`that ships both. Searched: ${bases.join(', ')}.`
|
|
415
|
-
);
|
|
375
|
+
throw pluginError({
|
|
376
|
+
what: `${depName} has no ${flavor} XCFramework, although its ${resolved[0]} one resolved.`,
|
|
377
|
+
why: `Expo declares its precompiled dependencies as immutable pairs, so half a pair would link in one configuration and fail to launch in the other with dyld "Library not loaded: @rpath/${depName}.framework/${depName}".`,
|
|
378
|
+
how: `Build the dependency for both flavors with the Expo prebuild pipeline, or install a package that ships both. Searched: ${bases.join(', ')}.`,
|
|
379
|
+
});
|
|
416
380
|
}
|
|
417
381
|
}
|
|
418
382
|
const framework = validateFlavoredFramework({
|
|
@@ -428,16 +392,9 @@ function resolveSpmDependencyFramework(depName, ownerModuleRoot) {
|
|
|
428
392
|
}
|
|
429
393
|
|
|
430
394
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* Two modules can link the same package, and RN's flavored frameworks are a flat
|
|
435
|
-
* app-wide array that rejects a repeated id or framework name, so each dependency
|
|
436
|
-
* is declared exactly once. Its owner — the first consuming pod name in byte
|
|
437
|
-
* order, as CocoaPods' `ensure_shared_spm_deps` picks it — is also the npm
|
|
438
|
-
* package searched for a bundled copy, so the two installers must order names
|
|
439
|
-
* identically. The other consumers need nothing: one declaration serves the whole
|
|
440
|
-
* app.
|
|
395
|
+
* One declaration per linked SwiftPM package; owner = first consumer pod in byte order
|
|
396
|
+
* (CocoaPods' ensure_shared_spm_deps), searched for the bundled copy.
|
|
397
|
+
* The two installers must order names identically.
|
|
441
398
|
*/
|
|
442
399
|
function resolveSpmDependencyFrameworks(consumers) {
|
|
443
400
|
const owners = new Map();
|
|
@@ -498,9 +455,7 @@ function prepareCompileInterfaces(frameworks, destination) {
|
|
|
498
455
|
.filter((candidate) => fs.existsSync(candidate))
|
|
499
456
|
.sort();
|
|
500
457
|
if (sliceFrameworks.length === 0) {
|
|
501
|
-
throw
|
|
502
|
-
`[expo-spm-plugin] ${source} has no ${framework.frameworkName}.framework slices`
|
|
503
|
-
);
|
|
458
|
+
throw pluginError({ what: `${source} has no ${framework.frameworkName}.framework slices` });
|
|
504
459
|
}
|
|
505
460
|
const target = path.join(temp, `${framework.frameworkName}.framework`);
|
|
506
461
|
for (const slice of sliceFrameworks) {
|