expo 58.0.0 → 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.
Files changed (41) 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 +76 -76
  8. package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
  9. package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
  10. package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
  11. package/package.json +13 -13
  12. package/scripts/spm/README.md +0 -3
  13. package/scripts/spm/__tests__/app-target.test.js +105 -1
  14. package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
  15. package/scripts/spm/__tests__/classify.test.js +17 -19
  16. package/scripts/spm/__tests__/cli.test.js +57 -1
  17. package/scripts/spm/__tests__/diagnostics.test.js +806 -183
  18. package/scripts/spm/__tests__/flavored-frameworks.test.js +9 -0
  19. package/scripts/spm/__tests__/helpers.js +88 -0
  20. package/scripts/spm/__tests__/manifests.test.js +1330 -104
  21. package/scripts/spm/__tests__/metadata.test.js +120 -0
  22. package/scripts/spm/__tests__/plugin.test.js +3304 -111
  23. package/scripts/spm/__tests__/podspec.test.js +27 -138
  24. package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
  25. package/scripts/spm/app-target.js +42 -1
  26. package/scripts/spm/autolink-gate.js +40 -0
  27. package/scripts/spm/classify.js +78 -79
  28. package/scripts/spm/cli.js +23 -9
  29. package/scripts/spm/diagnostics.js +605 -192
  30. package/scripts/spm/flavored-frameworks.js +231 -64
  31. package/scripts/spm/manifests.js +565 -196
  32. package/scripts/spm/metadata.js +152 -0
  33. package/scripts/spm/plugin.js +679 -205
  34. package/scripts/spm/podspec.js +57 -170
  35. package/src/winter/runtime.native.ts +0 -2
  36. package/template.tgz +0 -0
  37. package/build/winter/AbortSignal.d.ts +0 -3
  38. package/build/winter/AbortSignal.js +0 -96
  39. package/build/winter/AbortSignal.js.map +0 -1
  40. package/src/winter/AbortSignal.ts +0 -132
  41. package/src/winter/__tests__/AbortSignal.test.native.ts +0 -163
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Module discovery & classification for the Expo SwiftPM plugin: locate built
3
- * xcframeworks, find module roots, and decide whether a module needs React wired
4
- * in / is pure-Swift. Filesystem reads only; the React-detection predicate is
2
+ * Module discovery & classification for the Expo SwiftPM plugin: find module
3
+ * roots and Apple source directories, and decide whether a module needs React
4
+ * wired in / is pure-Swift. Filesystem reads only; the React-detection predicate is
5
5
  * split out as a pure function (`textImportsReact`) for unit testing.
6
6
  */
7
7
 
@@ -16,8 +16,15 @@ const CORE_REACT_PRODUCTS = new Set(['ExpoModulesCore', 'ExpoModulesJSI', 'ExpoM
16
16
  // Directories classification never looks into: tests, vendored deps, build output.
17
17
  const IGNORED_DIR_RX = /^(Tests?|__tests__|node_modules|build|\.build)$/;
18
18
 
19
- function isIgnoredDir(name) {
20
- return IGNORED_DIR_RX.test(name);
19
+ // Where a module keeps its Apple sources, in the order they are looked for.
20
+ const APPLE_SOURCE_DIRS = ['ios', 'apple'];
21
+
22
+ /** The first of the module's Apple source directories that exists, or null. */
23
+ function appleSourceDir(moduleRoot) {
24
+ return (
25
+ APPLE_SOURCE_DIRS.map((dir) => path.join(moduleRoot, dir)).find((dir) => fs.existsSync(dir)) ??
26
+ null
27
+ );
21
28
  }
22
29
 
23
30
  // A direct source-level import of the React/Hermes/jsi families (NOT ExpoModulesCore).
@@ -39,6 +46,15 @@ function findModuleRoot(startDir) {
39
46
  return startDir;
40
47
  }
41
48
 
49
+ /**
50
+ * The package root a prebuilt-metadata entry documents, or null when it documents
51
+ * none or the directory is gone: a stale entry is not identity.
52
+ */
53
+ function documentedPackageRoot(entry) {
54
+ const root = entry?.packageRoot;
55
+ return root != null && fs.existsSync(root) ? root : null;
56
+ }
57
+
42
58
  /**
43
59
  * Absolute paths RN should watch for autolinking staleness (the `watchPaths`
44
60
  * plugin contract): each module's checked-in Package.swift and its
@@ -58,53 +74,66 @@ function collectWatchPaths(moduleRoots) {
58
74
  return watchPaths;
59
75
  }
60
76
 
61
- function sourceTreeImportsReact(dir) {
62
- let entries = [];
77
+ /**
78
+ * Every file under `dir` outside the ignored directories, and those directories
79
+ * relative to `dir`, sorted. An ignored directory is not descended into: SwiftPM
80
+ * rejects an exclude path already covered by an excluded ancestor.
81
+ */
82
+ function walkSourceTree(dir) {
83
+ const files = [];
84
+ const ignoredDirs = [];
85
+ const visit = (current, prefix) => {
86
+ let entries = [];
87
+ try {
88
+ entries = fs.readdirSync(current, { withFileTypes: true });
89
+ } catch {
90
+ return;
91
+ }
92
+ for (const e of entries) {
93
+ const rel = prefix ? `${prefix}/${e.name}` : e.name;
94
+ if (!e.isDirectory()) files.push(path.join(current, e.name));
95
+ else if (IGNORED_DIR_RX.test(e.name)) ignoredDirs.push(rel);
96
+ else visit(path.join(current, e.name), rel);
97
+ }
98
+ };
99
+ visit(dir, '');
100
+ return { files, ignoredDirs: ignoredDirs.sort() };
101
+ }
102
+
103
+ const REACT_SCANNED_RX = /\.(swift|m|mm|c|h|hpp|cpp|cc)$/;
104
+ const NON_SWIFT_SOURCE_RX = /\.(m|mm|c|cpp|cc)$/;
105
+
106
+ function fileImportsReact(file) {
63
107
  try {
64
- entries = fs.readdirSync(dir, { withFileTypes: true });
108
+ return textImportsReact(fs.readFileSync(file, 'utf8'));
65
109
  } catch {
66
110
  return false;
67
111
  }
68
- for (const e of entries) {
69
- const p = path.join(dir, e.name);
70
- if (e.isDirectory()) {
71
- if (isIgnoredDir(e.name)) continue;
72
- if (sourceTreeImportsReact(p)) return true;
73
- } else if (/\.(swift|m|mm|c|h|hpp|cpp|cc)$/.test(e.name)) {
74
- let content = '';
75
- try {
76
- content = fs.readFileSync(p, 'utf8');
77
- } catch {
78
- continue;
79
- }
80
- if (textImportsReact(content)) return true;
81
- }
82
- }
83
- return false;
84
112
  }
85
113
 
86
114
  /**
87
- * The ignored directories under `dir`, relative to it and sorted. A generated
88
- * target must exclude exactly what classification skipped, or its production
89
- * library compiles test sources (and their `@testable` imports and mocks).
90
- * An ignored directory is not descended into: SwiftPM rejects an exclude path
91
- * already covered by an excluded ancestor.
115
+ * What classification needs from a module's Apple sources, from one walk of each
116
+ * source directory. `ignoredDirs` are the ones under the source directory a
117
+ * generated target compiles: it must exclude exactly what classification skipped,
118
+ * or its production library compiles test sources (and their `@testable` imports
119
+ * and mocks). React is looked for in `common/` too, which a module shares across
120
+ * platforms.
92
121
  */
93
- function collectIgnoredDirs(dir, prefix = '') {
94
- let entries = [];
95
- try {
96
- entries = fs.readdirSync(dir, { withFileTypes: true });
97
- } catch {
98
- return [];
99
- }
100
- const ignored = [];
101
- for (const e of entries) {
102
- if (!e.isDirectory()) continue;
103
- const rel = prefix ? `${prefix}/${e.name}` : e.name;
104
- if (isIgnoredDir(e.name)) ignored.push(rel);
105
- else ignored.push(...collectIgnoredDirs(path.join(dir, e.name), rel));
122
+ function scanAppleSources(moduleRoot) {
123
+ const sourceDir = appleSourceDir(moduleRoot);
124
+ let pureSwift = true;
125
+ let importsReact = false;
126
+ let ignoredDirs = [];
127
+ for (const sub of [...APPLE_SOURCE_DIRS, 'common']) {
128
+ const dir = path.join(moduleRoot, sub);
129
+ const tree = walkSourceTree(dir);
130
+ if (dir === sourceDir) ignoredDirs = tree.ignoredDirs;
131
+ for (const file of tree.files) {
132
+ if (sub !== 'common' && NON_SWIFT_SOURCE_RX.test(file)) pureSwift = false;
133
+ if (!importsReact && REACT_SCANNED_RX.test(file)) importsReact = fileImportsReact(file);
134
+ }
106
135
  }
107
- return prefix ? ignored : ignored.sort();
136
+ return { hasSources: sourceDir != null, pureSwift, importsReact, ignoredDirs };
108
137
  }
109
138
 
110
139
  /**
@@ -113,49 +142,19 @@ function collectIgnoredDirs(dir, prefix = '') {
113
142
  * Modules API does NOT inherit React — only modules whose own source imports the
114
143
  * React/Hermes/jsi families (or the core bridge layer itself) do.
115
144
  */
116
- function moduleNeedsReact(podName, moduleRoot) {
117
- if (CORE_REACT_PRODUCTS.has(podName)) return true;
118
- for (const sub of ['ios', 'apple', 'common']) {
119
- const dir = path.join(moduleRoot, sub);
120
- if (sourceTreeImportsReact(dir)) return true;
121
- }
122
- return false;
123
- }
124
-
125
- /** Cheap check: a module is pure-Swift if its iOS/apple source has no .m/.mm/.c/.cpp files. */
126
- function isPureSwift(moduleRoot) {
127
- const hasNonSwift = (dir) => {
128
- let entries = [];
129
- try {
130
- entries = fs.readdirSync(dir, { withFileTypes: true });
131
- } catch {
132
- return false;
133
- }
134
- for (const e of entries) {
135
- const p = path.join(dir, e.name);
136
- if (e.isDirectory()) {
137
- if (isIgnoredDir(e.name)) continue;
138
- if (hasNonSwift(p)) return true;
139
- } else if (/\.(m|mm|c|cpp|cc)$/.test(e.name)) {
140
- return true;
141
- }
142
- }
143
- return false;
144
- };
145
- return ['ios', 'apple']
146
- .map((s) => path.join(moduleRoot, s))
147
- .filter((d) => fs.existsSync(d))
148
- .every((d) => !hasNonSwift(d));
145
+ function moduleNeedsReact(podName, sources) {
146
+ return CORE_REACT_PRODUCTS.has(podName) || sources.importsReact;
149
147
  }
150
148
 
151
149
  module.exports = {
150
+ APPLE_SOURCE_DIRS,
152
151
  CORE_REACT_PRODUCTS,
153
152
  REACT_IMPORT_RX,
153
+ appleSourceDir,
154
154
  textImportsReact,
155
- sourceTreeImportsReact,
156
- collectIgnoredDirs,
157
155
  collectWatchPaths,
156
+ documentedPackageRoot,
158
157
  findModuleRoot,
159
158
  moduleNeedsReact,
160
- isPureSwift,
159
+ scanAppleSources,
161
160
  };
@@ -19,16 +19,29 @@ function resolveAutolinkingBin() {
19
19
  });
20
20
  }
21
21
 
22
- /** `expo-modules-autolinking resolve --platform apple --json` from the app root. */
22
+ function runAutolinking(appRoot, args) {
23
+ return JSON.parse(
24
+ execFileSync(process.execPath, [resolveAutolinkingBin(), ...args], {
25
+ cwd: appRoot,
26
+ encoding: 'utf8',
27
+ maxBuffer: MAX_BUFFER,
28
+ })
29
+ );
30
+ }
31
+
32
+ /**
33
+ * `resolve --platform apple --json`: {modules, extraDependencies}, both always arrays
34
+ * (older CLIs return the bare array).
35
+ */
23
36
  function resolveExpoModules(appRoot) {
24
- const bin = resolveAutolinkingBin();
25
- const stdout = execFileSync(process.execPath, [bin, 'resolve', '--platform', 'apple', '--json'], {
26
- cwd: appRoot,
27
- encoding: 'utf8',
28
- maxBuffer: MAX_BUFFER,
29
- });
30
- const parsed = JSON.parse(stdout);
31
- return Array.isArray(parsed) ? parsed : (parsed.modules ?? []);
37
+ const parsed = runAutolinking(appRoot, ['resolve', '--platform', 'apple', '--json']);
38
+ if (Array.isArray(parsed)) return { modules: parsed, extraDependencies: [] };
39
+ return { modules: parsed.modules ?? [], extraDependencies: parsed.extraDependencies ?? [] };
40
+ }
41
+
42
+ /** `prebuilt-metadata --json`: the same pod → package → product document `pod install` reads. */
43
+ function prebuiltMetadata(appRoot) {
44
+ return runAutolinking(appRoot, ['prebuilt-metadata', '--json']);
32
45
  }
33
46
 
34
47
  /**
@@ -96,6 +109,7 @@ function runDumpPackage(moduleRoot) {
96
109
  module.exports = {
97
110
  resolveAutolinkingBin,
98
111
  resolveExpoModules,
112
+ prebuiltMetadata,
99
113
  generateModulesProvider,
100
114
  runDumpPackage,
101
115
  };