expo 58.0.17 → 58.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/expo/modules/ExpoModulesPackage.kt +1 -1
  3. package/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt +1 -1
  4. package/build/winter/fetch/RequestUtils.d.ts +1 -0
  5. package/build/winter/fetch/RequestUtils.js +4 -2
  6. package/build/winter/fetch/RequestUtils.js.map +1 -1
  7. package/build/winter/fetch/fetch.js +4 -2
  8. package/build/winter/fetch/fetch.js.map +1 -1
  9. package/bundledNativeModules.json +19 -19
  10. package/package.json +12 -12
  11. package/scripts/spm/README.md +43 -3
  12. package/scripts/spm/__tests__/cli.test.js +17 -2
  13. package/scripts/spm/__tests__/commands.test.js +61 -0
  14. package/scripts/spm/__tests__/diagnostics.test.js +210 -9
  15. package/scripts/spm/__tests__/direct.test.js +387 -0
  16. package/scripts/spm/__tests__/flavored-frameworks.test.js +127 -0
  17. package/scripts/spm/__tests__/helpers.js +9 -0
  18. package/scripts/spm/__tests__/manifests.test.js +38 -50
  19. package/scripts/spm/__tests__/plugin.test.js +1238 -53
  20. package/scripts/spm/__tests__/precompiled-sources.test.js +139 -0
  21. package/scripts/spm/classify.js +8 -6
  22. package/scripts/spm/cli.js +11 -4
  23. package/scripts/spm/commands.js +18 -1
  24. package/scripts/spm/diagnostics.js +112 -8
  25. package/scripts/spm/direct.js +215 -0
  26. package/scripts/spm/flavored-frameworks.js +125 -40
  27. package/scripts/spm/manifests.js +4 -3
  28. package/scripts/spm/plugin.js +432 -82
  29. package/src/winter/fetch/RequestUtils.ts +8 -4
  30. package/src/winter/fetch/__tests__/fetch-test.native.ts +56 -0
  31. package/src/winter/fetch/fetch.ts +8 -2
  32. package/template.tgz +0 -0
@@ -9,10 +9,12 @@ const {
9
9
  FLAVORS,
10
10
  assertHeadersMatchSources,
11
11
  byteOrder,
12
+ hasPrecompiledArtifact,
12
13
  headersXCFrameworkDirs,
13
14
  prepareCompileInterfaces,
14
15
  resolveFlavoredFramework,
15
16
  resolveHeadersXCFramework,
17
+ resolveHeadersXCFrameworkWithSource,
16
18
  stableFrameworkId,
17
19
  validateFlavoredFramework,
18
20
  } = require('../flavored-frameworks');
@@ -59,6 +61,52 @@ function declaration(frameworkName, debug, release, overrides = {}) {
59
61
  };
60
62
  }
61
63
 
64
+ describe('hasPrecompiledArtifact', () => {
65
+ const savedEnvPath = process.env.EXPO_PRECOMPILED_MODULES_PATH;
66
+ let moduleRoot;
67
+ const lookup = () =>
68
+ hasPrecompiledArtifact({
69
+ packageName: '@expo-spm-test/no-monorepo-build',
70
+ moduleRoot,
71
+ frameworkName: 'ExpoProbe',
72
+ });
73
+ const xcframeworksDir = (flavor) =>
74
+ path.join(moduleRoot, 'prebuilds', 'output', flavor, 'xcframeworks');
75
+
76
+ beforeEach(() => {
77
+ delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
78
+ moduleRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'has-artifact-'));
79
+ });
80
+
81
+ afterEach(() => {
82
+ fs.rmSync(moduleRoot, { recursive: true, force: true });
83
+ if (savedEnvPath === undefined) {
84
+ delete process.env.EXPO_PRECOMPILED_MODULES_PATH;
85
+ } else {
86
+ process.env.EXPO_PRECOMPILED_MODULES_PATH = savedEnvPath;
87
+ }
88
+ });
89
+
90
+ it('is false when no flavor of the framework exists', () => {
91
+ expect(lookup()).toBe(false);
92
+ });
93
+
94
+ it('is true for an xcframework of either flavor', () => {
95
+ fs.mkdirSync(path.join(xcframeworksDir('release'), 'ExpoProbe.xcframework'), {
96
+ recursive: true,
97
+ });
98
+ expect(lookup()).toBe(true);
99
+ });
100
+
101
+ // The pair is not validated or extracted: nothing is linked from it.
102
+ it('is true for a tarball, leaving it unextracted', () => {
103
+ fs.mkdirSync(xcframeworksDir('debug'), { recursive: true });
104
+ fs.writeFileSync(path.join(xcframeworksDir('debug'), 'ExpoProbe.tar.gz'), 'not a tarball');
105
+ expect(lookup()).toBe(true);
106
+ expect(fs.readdirSync(xcframeworksDir('debug'))).toEqual(['ExpoProbe.tar.gz']);
107
+ });
108
+ });
109
+
62
110
  describe('byteOrder', () => {
63
111
  // The compile-interface merge and the declaration order both run through it,
64
112
  // and a locale-aware comparison would order these the other way around.
@@ -330,6 +378,59 @@ describe('artifact preparation', () => {
330
378
  ).toThrow('is not part of an .xcframework');
331
379
  });
332
380
 
381
+ it('returns a headers xcframework directory where it lies', () => {
382
+ const headers = path.join(root, 'expo-modules-core', 'output', 'headers', 'xcframeworks');
383
+ const xcframework = makeXcframework(headers, 'ExpoModulesCoreHeaders', '.');
384
+
385
+ expect(
386
+ resolveHeadersXCFrameworkWithSource({
387
+ packageName: 'expo-modules-core',
388
+ moduleRoot: path.join(root, 'module'),
389
+ productName: 'ExpoModulesCore',
390
+ cacheDir: path.join(root, 'cache'),
391
+ })
392
+ ).toEqual({
393
+ xcframework,
394
+ source: { kind: 'env', dir: path.join(root, 'expo-modules-core', 'output') },
395
+ });
396
+ });
397
+
398
+ itNotWindows('expands a bundled headers tarball into the cache', () => {
399
+ const source = path.join(root, 'source');
400
+ makeXcframework(source, 'ExpoModulesCoreHeaders', 'headers');
401
+ const moduleRoot = path.join(root, 'module');
402
+ packTarball(
403
+ path.join(source, 'headers'),
404
+ path.join(
405
+ moduleRoot,
406
+ 'prebuilds',
407
+ 'output',
408
+ 'headers',
409
+ 'xcframeworks',
410
+ 'ExpoModulesCoreHeaders.tar.gz'
411
+ ),
412
+ ['ExpoModulesCoreHeaders.xcframework']
413
+ );
414
+
415
+ const result = resolveHeadersXCFrameworkWithSource({
416
+ packageName: 'expo-spm-headers-fixture',
417
+ moduleRoot,
418
+ productName: 'ExpoModulesCore',
419
+ cacheDir: path.join(root, 'cache'),
420
+ });
421
+ expect(result).toEqual({
422
+ xcframework: path.join(
423
+ root,
424
+ 'cache',
425
+ 'expo-modules-core-headers',
426
+ 'headers',
427
+ 'ExpoModulesCoreHeaders.xcframework'
428
+ ),
429
+ source: { kind: 'bundled', dir: path.join(moduleRoot, 'prebuilds', 'output') },
430
+ });
431
+ expect(fs.existsSync(path.join(result.xcframework, 'Info.plist'))).toBe(true);
432
+ });
433
+
333
434
  it('produces byte-identical compile interfaces regardless of declaration order', () => {
334
435
  const aDebug = makeXcframework(root, 'ExpoA', 'a-debug', 'a');
335
436
  const aRelease = makeXcframework(root, 'ExpoA', 'a-release', 'a');
@@ -443,10 +544,36 @@ describe('resolveHeadersXCFramework', () => {
443
544
  expect(fs.existsSync(path.join(resolved, 'Info.plist'))).toBe(true);
444
545
  });
445
546
 
547
+ const rebuildHint =
548
+ 'Reinstall test-package, or from the Expo repository root run `node tools/bin/expotools.js prebuild test-package`. Then run `node node_modules/react-native/scripts/setup-apple-spm.js update` from your app directory again.';
549
+
446
550
  it('rejects an expanded XCFramework with no Info.plist', () => {
447
551
  const shipped = headersIn(path.join(moduleRoot, 'prebuilds', 'output'));
448
552
  fs.rmSync(path.join(shipped, 'Info.plist'));
449
553
  expect(resolve).toThrow(`${shipped} has no Info.plist`);
554
+ expect(resolve).toThrow('its build or its extraction did not finish');
555
+ expect(resolve).toThrow(rebuildHint);
556
+ });
557
+
558
+ itNotWindows('rejects a tarball whose XCFramework has no Info.plist', () => {
559
+ const source = path.join(root, 'source');
560
+ fs.rmSync(path.join(headersIn(source), 'Info.plist'));
561
+ const tarball = packTarball(
562
+ path.join(source, 'headers', 'xcframeworks'),
563
+ path.join(
564
+ moduleRoot,
565
+ 'prebuilds',
566
+ 'output',
567
+ 'headers',
568
+ 'xcframeworks',
569
+ 'ExpoPairHeaders.tar.gz'
570
+ ),
571
+ ['ExpoPairHeaders.xcframework']
572
+ );
573
+
574
+ expect(resolve).toThrow(`${tarball} holds ExpoPairHeaders.xcframework with no Info.plist`);
575
+ expect(resolve).toThrow('its build or its extraction did not finish');
576
+ expect(resolve).toThrow(rebuildHint);
450
577
  });
451
578
  });
452
579
 
@@ -4,6 +4,8 @@ const fs = require('fs');
4
4
  const os = require('os');
5
5
  const path = require('path');
6
6
 
7
+ const { spmUpdateCommand } = require('../commands');
8
+
7
9
  /** A podspec with the given body lines. */
8
10
  const spec = (...body) => ['Pod::Spec.new do |s|', ...body, 'end', ''].join('\n');
9
11
 
@@ -14,6 +16,9 @@ const metadataEntry = (packageRoot, productName, fields = {}) => ({
14
16
  ...fields,
15
17
  });
16
18
 
19
+ /** How an error asks the user to update the app's packages; Expo apps have no `react-native` CLI. */
20
+ const rerunSpmUpdate = `Then run \`${spmUpdateCommand()}\` from your app directory again.`;
21
+
17
22
  const tempDirs = [];
18
23
 
19
24
  /** A new directory under the OS temp dir, removed by `removeTempDirs`. */
@@ -62,6 +67,9 @@ function runPlugin(tmp, context = {}) {
62
67
  outputDir: path.join(tmp, 'out'),
63
68
  appRoot: path.join(tmp, 'app', 'ios'),
64
69
  projectRoot: path.join(tmp, 'app'),
70
+ // Fixtures that link real packages would otherwise resolve the repository's react-native, and
71
+ // the update command in every error would name that path.
72
+ reactNativeRoot: path.join(tmp, 'app', 'node_modules', 'react-native'),
65
73
  ...context,
66
74
  });
67
75
  }
@@ -82,6 +90,7 @@ module.exports = {
82
90
  metadataEntry,
83
91
  printed,
84
92
  removeTempDirs,
93
+ rerunSpmUpdate,
85
94
  runPlugin,
86
95
  spec,
87
96
  thrownBy,
@@ -4,9 +4,6 @@ const fs = require('fs');
4
4
  const os = require('os');
5
5
  const path = require('path');
6
6
 
7
- jest.mock('../cli', () => ({ runDumpPackage: jest.fn() }));
8
- const { runDumpPackage } = require('../cli');
9
-
10
7
  const {
11
8
  parseDumpedManifest,
12
9
  renderSourceManifest,
@@ -271,18 +268,15 @@ describe('macro plugin flags', () => {
271
268
  });
272
269
 
273
270
  it('carries the flags through emitSourceManifestPackage', () => {
274
- runDumpPackage.mockReturnValue(
271
+ emitSourceManifestPackage(
272
+ moduleRoot,
273
+ { frameworkSearchPath: '/abs/interfaces', outDir, macroFlags: MACRO_FLAGS },
275
274
  JSON.stringify({
276
275
  name: 'TestModule',
277
276
  products: [{ name: 'TestModule', type: { library: ['automatic'] }, targets: ['Main'] }],
278
277
  targets: [{ name: 'Main', type: 'regular', path: 'Main', dependencies: [] }],
279
278
  })
280
279
  );
281
- emitSourceManifestPackage(moduleRoot, {
282
- frameworkSearchPath: '/abs/interfaces',
283
- outDir,
284
- macroFlags: MACRO_FLAGS,
285
- });
286
280
 
287
281
  expect(
288
282
  fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
@@ -350,8 +344,8 @@ describe('implicit target source paths', () => {
350
344
  fs.mkdirSync(outDir, { recursive: true });
351
345
  });
352
346
 
353
- const emit = () =>
354
- emitSourceManifestPackage(moduleRoot, { frameworkSearchPath: '/abs/interfaces', outDir });
347
+ const emit = (dump) =>
348
+ emitSourceManifestPackage(moduleRoot, { frameworkSearchPath: '/abs/interfaces', outDir }, dump);
355
349
  const emittedManifest = () =>
356
350
  fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8');
357
351
 
@@ -361,9 +355,8 @@ describe('implicit target source paths', () => {
361
355
 
362
356
  it('resolves a target with no explicit path to its predefined source directory', () => {
363
357
  fs.mkdirSync(path.join(moduleRoot, 'Sources', 'Example'), { recursive: true });
364
- runDumpPackage.mockReturnValue(dumpWithoutPath);
365
358
 
366
- expect(emit().ok.packageDep).toEqual({
359
+ expect(emit(dumpWithoutPath).ok.packageDep).toEqual({
367
360
  name: 'TestModule',
368
361
  path: path.join(outDir, 'expo-source', 'TestModule'),
369
362
  });
@@ -371,20 +364,18 @@ describe('implicit target source paths', () => {
371
364
  });
372
365
 
373
366
  it('leaves an explicit path untouched', () => {
374
- runDumpPackage.mockReturnValue(
367
+ emit(
375
368
  JSON.stringify({
376
369
  name: 'TestModule',
377
370
  products: [{ name: 'TestModule', type: { library: ['automatic'] }, targets: ['Example'] }],
378
371
  targets: [{ name: 'Example', type: 'regular', path: 'ios/Example', dependencies: [] }],
379
372
  })
380
373
  );
381
- emit();
382
374
  expect(emittedManifest()).toContain('path: "root/ios/Example"');
383
375
  });
384
376
 
385
377
  it('skips the module and names the unresolved targets instead of emitting root/undefined', () => {
386
- runDumpPackage.mockReturnValue(dumpWithoutPath);
387
- const result = emit();
378
+ const result = emit(dumpWithoutPath);
388
379
 
389
380
  expect(result.ok).toBeUndefined();
390
381
  expect(result.refusal).toEqual({
@@ -540,14 +531,17 @@ describe('single-target packages with sources directly in a predefined directory
540
531
  fs.mkdirSync(path.dirname(target), { recursive: true });
541
532
  fs.writeFileSync(target, content);
542
533
  };
543
- const emit = () =>
544
- emitSourceManifestPackage(moduleRoot, { frameworkSearchPath: '/abs/interfaces', outDir });
534
+ const emit = (targetNames) =>
535
+ emitSourceManifestPackage(
536
+ moduleRoot,
537
+ { frameworkSearchPath: '/abs/interfaces', outDir },
538
+ dumpTargets(targetNames)
539
+ );
545
540
 
546
541
  it('resolves the only target to the bare predefined directory holding its sources', () => {
547
542
  write('Sources/File.swift');
548
- runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
549
543
 
550
- expect(emit().refusal).toBeUndefined();
544
+ expect(emit(['RootSrc']).refusal).toBeUndefined();
551
545
  expect(
552
546
  fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
553
547
  ).toContain('path: "root/Sources"');
@@ -556,9 +550,8 @@ describe('single-target packages with sources directly in a predefined directory
556
550
  it('prefers Sources/<target name> over the bare directory', () => {
557
551
  write('Sources/File.swift');
558
552
  write('Sources/RootSrc/File.swift');
559
- runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
560
553
 
561
- emit();
554
+ emit(['RootSrc']);
562
555
  expect(
563
556
  fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
564
557
  ).toContain('path: "root/Sources/RootSrc"');
@@ -566,16 +559,17 @@ describe('single-target packages with sources directly in a predefined directory
566
559
 
567
560
  it('never resolves the targets of a multi-target package to the shared bare directory', () => {
568
561
  write('Sources/File.swift');
569
- runDumpPackage.mockReturnValue(dumpTargets(['A', 'B']));
570
562
 
571
- expect(emit().refusal).toEqual({ reason: 'unresolvable-target-path', targetNames: ['A', 'B'] });
563
+ expect(emit(['A', 'B']).refusal).toEqual({
564
+ reason: 'unresolvable-target-path',
565
+ targetNames: ['A', 'B'],
566
+ });
572
567
  });
573
568
 
574
569
  it('accepts a predefined directory whose sources are nested below it', () => {
575
570
  write('Sources/Nested/File.swift');
576
- runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
577
571
 
578
- expect(emit().refusal).toBeUndefined();
572
+ expect(emit(['RootSrc']).refusal).toBeUndefined();
579
573
  expect(
580
574
  fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8')
581
575
  ).toContain('path: "root/Sources"');
@@ -583,9 +577,8 @@ describe('single-target packages with sources directly in a predefined directory
583
577
 
584
578
  it('ignores a predefined directory with no source files at any depth', () => {
585
579
  write('Sources/Nested/README.md', '# docs\n');
586
- runDumpPackage.mockReturnValue(dumpTargets(['RootSrc']));
587
580
 
588
- expect(emit().refusal).toEqual({
581
+ expect(emit(['RootSrc']).refusal).toEqual({
589
582
  reason: 'unresolvable-target-path',
590
583
  targetNames: ['RootSrc'],
591
584
  });
@@ -1090,12 +1083,11 @@ describe('the minimum floor a checked-in manifest is raised to', () => {
1090
1083
  });
1091
1084
 
1092
1085
  const emitted = (declared, minimum) => {
1093
- runDumpPackage.mockReturnValue(dumpWithIos(declared));
1094
- emitSourceManifestPackage(moduleRoot, {
1095
- frameworkSearchPath: '/abs/interfaces',
1096
- outDir,
1097
- minimumIosDeploymentTarget: minimum,
1098
- });
1086
+ emitSourceManifestPackage(
1087
+ moduleRoot,
1088
+ { frameworkSearchPath: '/abs/interfaces', outDir, minimumIosDeploymentTarget: minimum },
1089
+ dumpWithIos(declared)
1090
+ );
1099
1091
  return fs.readFileSync(path.join(outDir, 'expo-source', 'TestModule', 'Package.swift'), 'utf8');
1100
1092
  };
1101
1093
 
@@ -1219,12 +1211,11 @@ describe('dependencies on targets the generated package cannot declare', () => {
1219
1211
  const moduleRoot = path.join(tmp, 'module');
1220
1212
  const outDir = path.join(tmp, 'out');
1221
1213
  fs.mkdirSync(path.join(moduleRoot, 'ios', 'Src'), { recursive: true });
1222
- runDumpPackage.mockReturnValue(dumpWithBinaryTarget);
1223
-
1224
- const result = emitSourceManifestPackage(moduleRoot, {
1225
- frameworkSearchPath: '/abs/interfaces',
1226
- outDir,
1227
- });
1214
+ const result = emitSourceManifestPackage(
1215
+ moduleRoot,
1216
+ { frameworkSearchPath: '/abs/interfaces', outDir },
1217
+ dumpWithBinaryTarget
1218
+ );
1228
1219
 
1229
1220
  expect(result.ok).toBeUndefined();
1230
1221
  expect(result.refusal).toEqual({
@@ -1894,15 +1885,12 @@ let package = Package(
1894
1885
  const emittedManifestPath = () =>
1895
1886
  path.join(outDir, 'expo-source', 'TestModule', 'Package.swift');
1896
1887
  const emittedManifest = () => fs.readFileSync(emittedManifestPath(), 'utf8');
1897
- const emit = (dump, react, satisfiedDependencies) => {
1898
- runDumpPackage.mockReturnValue(dump);
1899
- return emitSourceManifestPackage(moduleRoot, {
1900
- react,
1901
- frameworkSearchPath: '/abs/interfaces',
1902
- outDir,
1903
- satisfiedDependencies,
1904
- });
1905
- };
1888
+ const emit = (dump, react, satisfiedDependencies) =>
1889
+ emitSourceManifestPackage(
1890
+ moduleRoot,
1891
+ { react, frameworkSearchPath: '/abs/interfaces', outDir, satisfiedDependencies },
1892
+ dump
1893
+ );
1906
1894
 
1907
1895
  // A package can export several products; only the ones a precompiled framework
1908
1896
  // provides go, and the package stays while anything still depends on it.