expo 58.0.0 → 58.0.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.
Files changed (31) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/proguard-rules.pro +4 -0
  3. package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +5 -1
  4. package/android/src/main/java/expo/modules/fetch/OkHttpFileUrlInterceptor.kt +5 -1
  5. package/build/winter/runtime.native.js +0 -2
  6. package/build/winter/runtime.native.js.map +1 -1
  7. package/bundledNativeModules.json +21 -21
  8. package/package.json +7 -7
  9. package/scripts/spm/README.md +0 -3
  10. package/scripts/spm/__tests__/cli.test.js +57 -1
  11. package/scripts/spm/__tests__/diagnostics.test.js +181 -131
  12. package/scripts/spm/__tests__/flavored-frameworks.test.js +9 -0
  13. package/scripts/spm/__tests__/helpers.js +88 -0
  14. package/scripts/spm/__tests__/manifests.test.js +289 -74
  15. package/scripts/spm/__tests__/plugin.test.js +1101 -111
  16. package/scripts/spm/__tests__/podspec.test.js +27 -138
  17. package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
  18. package/scripts/spm/classify.js +28 -6
  19. package/scripts/spm/cli.js +23 -9
  20. package/scripts/spm/diagnostics.js +111 -91
  21. package/scripts/spm/flavored-frameworks.js +233 -21
  22. package/scripts/spm/manifests.js +85 -34
  23. package/scripts/spm/plugin.js +214 -55
  24. package/scripts/spm/podspec.js +10 -160
  25. package/src/winter/runtime.native.ts +0 -2
  26. package/template.tgz +0 -0
  27. package/build/winter/AbortSignal.d.ts +0 -3
  28. package/build/winter/AbortSignal.js +0 -96
  29. package/build/winter/AbortSignal.js.map +0 -1
  30. package/src/winter/AbortSignal.ts +0 -132
  31. package/src/winter/__tests__/AbortSignal.test.native.ts +0 -163
@@ -13,20 +13,11 @@ const {
13
13
  renderUnsupportedReport,
14
14
  reportUnsupported,
15
15
  renderUnmappedDependencyWarning,
16
- spmConfigProduct,
16
+ collectRootConflicts,
17
+ renderRootConflictWarning,
18
+ renderExtraPodsWarning,
17
19
  } = require('../diagnostics');
18
-
19
- function withModuleDir(files, run) {
20
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-diag-'));
21
- try {
22
- for (const [name, contents] of Object.entries(files)) {
23
- fs.writeFileSync(path.join(dir, name), contents);
24
- }
25
- return run(dir);
26
- } finally {
27
- fs.rmSync(dir, { recursive: true, force: true });
28
- }
29
- }
20
+ const { resolvePodIdentities } = require('../plugin');
30
21
 
31
22
  describe('classifyUnsupported', () => {
32
23
  it('reports a missing interface tree once, not per module', () => {
@@ -107,113 +98,6 @@ describe('classifyUnsupported', () => {
107
98
  });
108
99
  });
109
100
 
110
- describe('spmConfigProduct', () => {
111
- const config = JSON.stringify({
112
- products: [
113
- { name: 'ExpoModulesCore', podName: 'ExpoModulesCore' },
114
- { name: 'ExpoModulesWorklets', podName: 'ExpoModulesWorklets' },
115
- {
116
- name: 'ExpoModulesWorkletsAdapter',
117
- podName: 'ExpoModulesWorkletsAdapter',
118
- sourceOnly: true,
119
- },
120
- ],
121
- });
122
-
123
- it('finds the product declaring a pod', () => {
124
- withModuleDir({ 'spm.config.json': config }, (dir) => {
125
- expect(spmConfigProduct(dir, 'ExpoModulesWorklets')).toEqual({
126
- name: 'ExpoModulesWorklets',
127
- sourceOnly: false,
128
- });
129
- });
130
- });
131
-
132
- it('reports a source-only product as such', () => {
133
- withModuleDir({ 'spm.config.json': config }, (dir) => {
134
- expect(spmConfigProduct(dir, 'ExpoModulesWorkletsAdapter')).toEqual({
135
- name: 'ExpoModulesWorkletsAdapter',
136
- sourceOnly: true,
137
- });
138
- });
139
- });
140
-
141
- it('falls back to the product name when podName is absent', () => {
142
- withModuleDir(
143
- { 'spm.config.json': JSON.stringify({ products: [{ name: 'ExpoFoo' }] }) },
144
- (dir) => {
145
- expect(spmConfigProduct(dir, 'ExpoFoo')).toEqual({ name: 'ExpoFoo', sourceOnly: false });
146
- }
147
- );
148
- });
149
-
150
- it('returns null for an undeclared pod, a missing file, and malformed JSON', () => {
151
- withModuleDir({ 'spm.config.json': config }, (dir) => {
152
- expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull();
153
- });
154
- withModuleDir({}, (dir) => expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull());
155
- withModuleDir({ 'spm.config.json': '{ not json' }, (dir) =>
156
- expect(spmConfigProduct(dir, 'ExpoAudio')).toBeNull()
157
- );
158
- });
159
- });
160
-
161
- describe('unsupported podspec syntax', () => {
162
- const podspecError = {
163
- file: '/m/expo-bad/ios/ExpoBad.podspec',
164
- line: 12,
165
- snippet: 's.platforms = { :ios => MIN_IOS }',
166
- reason: "`MIN_IOS` where a version literal like '16.4' belongs",
167
- };
168
-
169
- it('classifies a module whose podspec the reader refused', () => {
170
- expect(
171
- classifyUnsupported({
172
- pending: [
173
- {
174
- podName: 'ExpoBad',
175
- packageName: 'expo-bad',
176
- moduleRoot: '/m/expo-bad',
177
- podspecError,
178
- },
179
- ],
180
- coreAvailable: true,
181
- })
182
- ).toEqual([
183
- {
184
- reason: 'unsupported-podspec-syntax',
185
- podName: 'ExpoBad',
186
- packageName: 'expo-bad',
187
- moduleRoot: '/m/expo-bad',
188
- file: podspecError.file,
189
- line: podspecError.line,
190
- snippet: podspecError.snippet,
191
- problem: podspecError.reason,
192
- },
193
- ]);
194
- });
195
-
196
- it('reports the file, line and snippet, and how to fix it', () => {
197
- const report = renderUnsupportedReport(
198
- classifyUnsupported({
199
- pending: [
200
- { podName: 'ExpoBad', packageName: 'expo-bad', moduleRoot: '/m/expo-bad', podspecError },
201
- ],
202
- coreAvailable: true,
203
- })
204
- );
205
- expect(report).toContain('error: Expo module "expo-bad" (pod ExpoBad)');
206
- expect(report).toContain('iOS deployment floor');
207
- expect(report).toContain('/m/expo-bad/ios/ExpoBad.podspec:12');
208
- expect(report).toContain('s.platforms = { :ios => MIN_IOS }');
209
- expect(report).toContain("{ :ios => '16.4' }");
210
- expect(report).toContain("s.ios.deployment_target = '16.4'");
211
- expect(report).toContain('platforms: [.iOS("16.4")]');
212
- expect(report).toContain('patch-package expo-bad');
213
- expect(report).not.toContain('linkage');
214
- });
215
- });
216
-
217
101
  describe('diagnostic priority', () => {
218
102
  it('asks for the prebuild first, even when the podspec also needs attention', () => {
219
103
  expect(
@@ -230,7 +114,6 @@ describe('diagnostic priority', () => {
230
114
  line: 19,
231
115
  snippet: "s.frameworks = 'Photos'",
232
116
  },
233
- podspecError: null,
234
117
  },
235
118
  ],
236
119
  coreAvailable: true,
@@ -257,22 +140,12 @@ describe('diagnostic priority order', () => {
257
140
  });
258
141
  const reasonFor = (extra) =>
259
142
  classifyUnsupported({ pending: [pending(extra)], coreAvailable: true })[0].reason;
260
- const podspecError = {
261
- file: '/m/expo-bad/ios/ExpoBad.podspec',
262
- line: 12,
263
- snippet: 's.platforms = { :ios => MIN_IOS }',
264
- reason: 'a computed floor',
265
- };
266
143
  const podspecLinkage = {
267
144
  file: '/m/expo-bad/ios/ExpoBad.podspec',
268
145
  line: 19,
269
146
  snippet: "s.frameworks = 'Photos'",
270
147
  };
271
148
 
272
- it('reports the unreadable floor before the linkage the same podspec declares', () => {
273
- expect(reasonFor({ podspecError, podspecLinkage })).toBe('unsupported-podspec-syntax');
274
- });
275
-
276
149
  it('reports the linkage before targets whose sources it could not find', () => {
277
150
  expect(reasonFor({ podspecLinkage, unresolvedTargets: ['Main'] })).toBe(
278
151
  'needs-manifest-for-linkage'
@@ -377,6 +250,15 @@ describe('unmappedPodDependencies', () => {
377
250
  expect(UNMAPPED_POD_ALLOWLIST.has('sqlite3')).toBe(true);
378
251
  expect(unmappedPodDependencies(['sqlite3', 'SDWebImage'])).toEqual(['SDWebImage']);
379
252
  });
253
+
254
+ it('drops a dependency whose full name or root name is a resolved SwiftPM dependency', () => {
255
+ expect(
256
+ unmappedPodDependencies(
257
+ ['SDWebImage', 'libavif', 'libavif/libdav1d', 'ZXingObjC/OneD'],
258
+ new Set(['SDWebImage', 'libavif'])
259
+ )
260
+ ).toEqual(['ZXingObjC/OneD']);
261
+ });
380
262
  });
381
263
 
382
264
  describe('renderUnsupportedReport', () => {
@@ -637,3 +519,171 @@ describe('dependencies on targets the generated package cannot declare', () => {
637
519
  expect(report).toContain('macro target');
638
520
  });
639
521
  });
522
+
523
+ describe('a module installed twice', () => {
524
+ let tmp;
525
+ const dir = (...segments) => {
526
+ const created = path.join(tmp, ...segments);
527
+ fs.mkdirSync(created, { recursive: true });
528
+ return created;
529
+ };
530
+ const modules = [{ packageName: 'expo-camera', pods: [{ podName: 'ExpoCamera' }] }];
531
+
532
+ beforeAll(() => {
533
+ tmp = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'expo-spm-roots-')));
534
+ });
535
+
536
+ afterEach(() => jest.restoreAllMocks());
537
+
538
+ it('finds no conflict when both roots are the same directory through a symlink', () => {
539
+ const packageRoot = dir('node_modules', 'expo-camera');
540
+ const link = path.join(dir('links'), 'expo-camera');
541
+ fs.symlinkSync(packageRoot, link, 'dir');
542
+
543
+ expect(
544
+ collectRootConflicts(
545
+ resolvePodIdentities(
546
+ modules,
547
+ { ExpoCamera: { packageRoot } },
548
+ new Map([['expo-camera', link]])
549
+ )
550
+ )
551
+ ).toEqual([]);
552
+ });
553
+
554
+ it('finds a conflict when the two roots are different directories', () => {
555
+ const packageRoot = dir('node_modules', 'expo-camera');
556
+ const autolinkedRoot = dir('node_modules', 'some-lib', 'node_modules', 'expo-camera');
557
+
558
+ expect(
559
+ collectRootConflicts(
560
+ resolvePodIdentities(
561
+ modules,
562
+ { ExpoCamera: { packageRoot } },
563
+ new Map([['expo-camera', autolinkedRoot]])
564
+ )
565
+ )
566
+ ).toEqual([{ packageName: 'expo-camera', moduleRoot: packageRoot, autolinkedRoot }]);
567
+ });
568
+
569
+ it('finds no conflict for a documented root that is gone', () => {
570
+ expect(
571
+ collectRootConflicts(
572
+ resolvePodIdentities(
573
+ modules,
574
+ { ExpoCamera: { packageRoot: path.join(tmp, 'vanished') } },
575
+ new Map([['expo-camera', dir('node_modules', 'expo-camera')]])
576
+ )
577
+ )
578
+ ).toEqual([]);
579
+ });
580
+
581
+ // A path that cannot be resolved cannot be compared, and a diagnostic is never
582
+ // worth failing a sync over.
583
+ it('reports nothing, and does not throw, when a root cannot be resolved', () => {
584
+ const packageRoot = dir('node_modules', 'expo-camera');
585
+ jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
586
+ throw Object.assign(new Error('ENOENT'), { code: 'ENOENT' });
587
+ });
588
+
589
+ expect(
590
+ collectRootConflicts(
591
+ resolvePodIdentities(
592
+ modules,
593
+ { ExpoCamera: { packageRoot } },
594
+ new Map([['expo-camera', path.join(tmp, 'elsewhere')]])
595
+ )
596
+ )
597
+ ).toEqual([]);
598
+ });
599
+
600
+ it('names both directories, what uses each, and how to deduplicate', () => {
601
+ const report = renderRootConflictWarning([
602
+ {
603
+ packageName: 'expo-camera',
604
+ moduleRoot: '/app/node_modules/expo-camera',
605
+ autolinkedRoot: '/app/node_modules/some-lib/node_modules/expo-camera',
606
+ },
607
+ ]);
608
+ expect(report).toMatch(/^warning: Expo module "expo-camera"/);
609
+ expect(report).toContain('/app/node_modules/expo-camera');
610
+ expect(report).toContain('/app/node_modules/some-lib/node_modules/expo-camera');
611
+ expect(report).toContain('npm ls expo-camera');
612
+ expect(report).toContain('dedupe');
613
+ });
614
+
615
+ // The copies can be different versions, so the mismatch is not confined to runtime.
616
+ it('names both failure modes, without pseudo-code for the import', () => {
617
+ const report = renderRootConflictWarning([
618
+ {
619
+ packageName: 'expo-camera',
620
+ moduleRoot: '/app/node_modules/expo-camera',
621
+ autolinkedRoot: '/app/node_modules/some-lib/node_modules/expo-camera',
622
+ },
623
+ ]);
624
+ expect(report).toContain("your app's JavaScript imports the second");
625
+ expect(report).toContain('usually surfaces at runtime');
626
+ expect(report).toContain('can fail the build');
627
+ });
628
+
629
+ it('renders nothing when no module is installed twice', () => {
630
+ expect(renderRootConflictWarning([])).toBe('');
631
+ });
632
+ });
633
+
634
+ describe('extra CocoaPods dependencies', () => {
635
+ const pods = [
636
+ { name: 'MyLocalPod', path: '../vendor/MyLocalPod' },
637
+ { name: 'Firebase', git: 'https://github.com/firebase/firebase-ios-sdk.git' },
638
+ { name: 'AppCenter' },
639
+ ];
640
+
641
+ it('names every pod and where it comes from', () => {
642
+ const report = renderExtraPodsWarning(pods);
643
+ expect(report).toContain('MyLocalPod (local path: ../vendor/MyLocalPod)');
644
+ expect(report).toContain('Firebase (git: https://github.com/firebase/firebase-ios-sdk.git)');
645
+ expect(report).toContain('AppCenter (published pod)');
646
+ });
647
+
648
+ it('names a custom spec repo as its own origin, and gives the version', () => {
649
+ const report = renderExtraPodsWarning([
650
+ { name: 'InternalSDK', source: 'https://specs.example.com/private.git', version: '2.1.0' },
651
+ { name: 'AppCenter', version: '5.0.0' },
652
+ ]);
653
+ expect(report).toContain(
654
+ 'InternalSDK (spec repo: https://specs.example.com/private.git, version 2.1.0)'
655
+ );
656
+ expect(report).toContain('AppCenter (published pod, version 5.0.0)');
657
+ });
658
+
659
+ it('names the git ref, the only thing that says which code a git pod means', () => {
660
+ const report = renderExtraPodsWarning([
661
+ { name: 'Firebase', git: 'https://github.com/firebase/firebase-ios-sdk.git', tag: '10.0.0' },
662
+ { name: 'Sentry', git: 'https://github.com/getsentry/sentry-cocoa.git', branch: 'main' },
663
+ { name: 'Lottie', git: 'https://github.com/airbnb/lottie-ios.git', commit: 'a1b2c3d' },
664
+ ]);
665
+ expect(report).toContain(
666
+ 'Firebase (git: https://github.com/firebase/firebase-ios-sdk.git, tag 10.0.0)'
667
+ );
668
+ expect(report).toContain(
669
+ 'Sentry (git: https://github.com/getsentry/sentry-cocoa.git, branch main)'
670
+ );
671
+ expect(report).toContain(
672
+ 'Lottie (git: https://github.com/airbnb/lottie-ios.git, commit a1b2c3d)'
673
+ );
674
+ });
675
+
676
+ it('says what declared them, how they fail, and what to do instead', () => {
677
+ const report = renderExtraPodsWarning(pods);
678
+ expect(report).toMatch(/^warning: /);
679
+ expect(report).toContain('extraPods');
680
+ expect(report).toContain('Podfile.properties.json');
681
+ expect(report).toContain('fails to compile or link');
682
+ expect(report).toContain('at runtime');
683
+ expect(report).toContain('keep this app on CocoaPods');
684
+ });
685
+
686
+ it('renders nothing when the app declares none', () => {
687
+ expect(renderExtraPodsWarning([])).toBe('');
688
+ });
689
+ });
@@ -7,6 +7,7 @@ const path = require('path');
7
7
 
8
8
  const {
9
9
  FLAVORS,
10
+ byteOrder,
10
11
  prepareCompileInterfaces,
11
12
  resolveFlavoredFramework,
12
13
  stableFrameworkId,
@@ -54,6 +55,14 @@ function declaration(frameworkName, debug, release, overrides = {}) {
54
55
  };
55
56
  }
56
57
 
58
+ describe('byteOrder', () => {
59
+ // The compile-interface merge and the declaration order both run through it,
60
+ // and a locale-aware comparison would order these the other way around.
61
+ it('orders every uppercase letter before every lowercase one, as CocoaPods does', () => {
62
+ expect(['expo-a', 'expo-B'].sort(byteOrder)).toEqual(['expo-B', 'expo-a']);
63
+ });
64
+ });
65
+
57
66
  describe('validateFlavoredFramework', () => {
58
67
  let root;
59
68
 
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+
7
+ /** A podspec with the given body lines. */
8
+ const spec = (...body) => ['Pod::Spec.new do |s|', ...body, 'end', ''].join('\n');
9
+
10
+ /** A prebuilt-metadata entry: the package root and product name, plus any optional fields. */
11
+ const metadataEntry = (packageRoot, productName, fields = {}) => ({
12
+ packageRoot,
13
+ productName,
14
+ ...fields,
15
+ });
16
+
17
+ const tempDirs = [];
18
+
19
+ /** A new directory under the OS temp dir, removed by `removeTempDirs`. */
20
+ function makeTempDir(prefix) {
21
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
22
+ tempDirs.push(dir);
23
+ return dir;
24
+ }
25
+
26
+ /** Removes every directory `makeTempDir` created. */
27
+ function removeTempDirs() {
28
+ for (const dir of tempDirs.splice(0)) {
29
+ fs.rmSync(dir, { recursive: true, force: true });
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Silences console.error, console.warn and console.log for the enclosing describe
35
+ * and records the calls, on spies the returned object holds by method name. With
36
+ * `each`, the spies are replaced for every test instead of once.
37
+ */
38
+ function captureConsole({ each = false } = {}) {
39
+ const logs = {};
40
+ (each ? beforeEach : beforeAll)(() => {
41
+ for (const method of ['error', 'warn', 'log']) {
42
+ logs[method] = jest.spyOn(console, method).mockImplementation(() => {});
43
+ }
44
+ });
45
+ (each ? afterEach : afterAll)(() => Object.values(logs).forEach((spy) => spy.mockRestore()));
46
+ return logs;
47
+ }
48
+
49
+ /** Everything a console spy printed, one call per line. */
50
+ const printed = (spy) => spy.mock.calls.map(([text]) => text).join('\n');
51
+
52
+ /**
53
+ * Runs the plugin the way React Native does, for an app at `<tmp>/app` that
54
+ * generates into `<tmp>/out`. `context` adds to or overrides those fields.
55
+ */
56
+ function runPlugin(tmp, context = {}) {
57
+ // Required on first use: this Jest config has no transform to hoist a test
58
+ // file's jest.mock calls, so the plugin must load after they have run.
59
+ const expoSpmPlugin = require('../plugin');
60
+ return expoSpmPlugin({
61
+ react: null,
62
+ outputDir: path.join(tmp, 'out'),
63
+ appRoot: path.join(tmp, 'app', 'ios'),
64
+ projectRoot: path.join(tmp, 'app'),
65
+ ...context,
66
+ });
67
+ }
68
+
69
+ /** The error `fn` throws, or null when it returns. */
70
+ function thrownBy(fn) {
71
+ try {
72
+ fn();
73
+ return null;
74
+ } catch (error) {
75
+ return error;
76
+ }
77
+ }
78
+
79
+ module.exports = {
80
+ captureConsole,
81
+ makeTempDir,
82
+ metadataEntry,
83
+ printed,
84
+ removeTempDirs,
85
+ runPlugin,
86
+ spec,
87
+ thrownBy,
88
+ };