react-native 0.87.0-rc.0 → 0.87.0-rc.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 (70) hide show
  1. package/Libraries/Core/InitializeCore.js +9 -1
  2. package/Libraries/Core/ReactNativeVersion.js +1 -1
  3. package/Libraries/ReactNative/AppRegistry.flow.js +1 -0
  4. package/Libraries/ReactNative/AppRegistryImpl.js +2 -3
  5. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +5 -116
  6. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +5 -31
  7. package/React/Base/RCTVersion.m +1 -1
  8. package/React/I18n/RCTLocalizedString.mm +38 -2
  9. package/React-Core-prebuilt.podspec +45 -17
  10. package/React-Core.podspec +9 -2
  11. package/ReactAndroid/external-artifacts/build.gradle.kts +49 -0
  12. package/ReactAndroid/gradle.properties +1 -1
  13. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/SynchronousMountItem.kt +8 -2
  14. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  15. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  16. package/index.js +15 -3
  17. package/index.js.flow +0 -2
  18. package/package.json +27 -29
  19. package/react-native.config.js +81 -0
  20. package/scripts/cocoapods/fabric.rb +1 -1
  21. package/scripts/cocoapods/rncore.rb +35 -78
  22. package/scripts/cocoapods/rncore_facades.rb +232 -0
  23. package/scripts/cocoapods/rndependencies.rb +64 -3
  24. package/scripts/cocoapods/rndeps_facades.rb +193 -0
  25. package/scripts/cocoapods/spm.rb +78 -11
  26. package/scripts/codegen/templates/Package.swift.spm-template +97 -0
  27. package/scripts/react-native-xcode.sh +20 -0
  28. package/scripts/react_native_pods.rb +65 -16
  29. package/scripts/replace-rncore-version.js +53 -6
  30. package/scripts/setup-apple-spm.js +1165 -0
  31. package/scripts/spm/__doc__/rfc-spm-xcframework.md +707 -0
  32. package/scripts/spm/__doc__/spm-autolinking-plugins.md +244 -0
  33. package/scripts/spm/__doc__/spm-header-paths-contract.md +97 -0
  34. package/scripts/spm/__doc__/spm-plugins-assessment.md +128 -0
  35. package/scripts/spm/__doc__/spm-scripts.md +451 -0
  36. package/scripts/spm/autolinking-plugins.js +331 -0
  37. package/scripts/spm/download-spm-artifacts.js +1409 -0
  38. package/scripts/spm/expand-spm-dependencies.js +216 -0
  39. package/scripts/spm/flavored-frameworks.js +1008 -0
  40. package/scripts/spm/generate-spm-autolinking-config.js +161 -0
  41. package/scripts/spm/generate-spm-autolinking.js +1888 -0
  42. package/scripts/spm/generate-spm-package.js +302 -0
  43. package/scripts/spm/generate-spm-xcodeproj.js +2224 -0
  44. package/scripts/spm/read-podspec.js +695 -0
  45. package/scripts/spm/scaffold-package-swift.js +1206 -0
  46. package/scripts/spm/spm-pbxproj.js +654 -0
  47. package/scripts/spm/spm-types.js +517 -0
  48. package/scripts/spm/spm-utils.js +645 -0
  49. package/scripts/spm/sync-spm-autolinking.js +160 -0
  50. package/sdks/.hermesv1version +1 -0
  51. package/sdks/hermes-engine/utils/replace_hermes_version.js +18 -4
  52. package/sdks/hermes-engine/version.properties +1 -1
  53. package/src/asset-registry.js +1 -1
  54. package/src/react-private-interface.js +145 -0
  55. package/src/react-private-interface.js.flow +48 -0
  56. package/src/setup-env.js +22 -0
  57. package/src/unstable-internals-do-not-use.d.ts +214 -0
  58. package/src/unstable-internals-do-not-use.js +76 -0
  59. package/third-party-podspecs/ReactNativeDependencies.podspec +2 -2
  60. package/types_generated/Libraries/ReactNative/AppRegistry.flow.d.ts +2 -2
  61. package/types_generated/Libraries/ReactPrivate/ReactNativePrivateInterface.d.ts +6 -21
  62. package/types_generated/index.d.ts +1 -2
  63. package/types_generated/src/private/renderer/events/dispatchNativeEvent.d.ts +26 -0
  64. package/types_generated/src/react-private-interface.d.ts +33 -0
  65. package/Libraries/Utilities/SceneTracker.js +0 -42
  66. package/jest-preset.js +0 -26
  67. package/rn-get-polyfills.js +0 -13
  68. package/types/tsconfig.json +0 -17
  69. package/types_generated/Libraries/Components/Touchable/Touchable.d.ts +0 -261
  70. package/types_generated/tsconfig.test.json +0 -17
@@ -0,0 +1,302 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /*:: import type {GeneratePackageArgs} from './spm-types'; */
14
+
15
+ /**
16
+ * generate-spm-package.js – Generates the xcframeworks sub-package for a
17
+ * React Native app using prebuilt XCFrameworks via Swift Package Manager.
18
+ *
19
+ * Usage:
20
+ * node generate-spm-package.js [options]
21
+ *
22
+ * Options:
23
+ * --app-root <path> Path to the app directory (default: cwd)
24
+ * --react-native-root <path> Path to react-native package root
25
+ * --version <ver> RN version for Maven artifact URLs
26
+ * --debug-artifacts-dir <path> Complete Debug artifact cache slot
27
+ * --release-artifacts-dir <path> Complete Release artifact cache slot
28
+ * --app-name <name> App/package name (default: from package.json)
29
+ * --target-name <name> Main app target name (default: derived from app-name)
30
+ * --source-path <path> Path to app source relative to app-root (default: auto-detected)
31
+ * --ios-version <ver> Minimum iOS version (default: 15)
32
+ *
33
+ * Generates build/xcframeworks/Package.swift + symlinks. The xcodeproj
34
+ * references this sub-package directly; no separate app-level Package.swift
35
+ * is needed.
36
+ */
37
+
38
+ const {prepareFlavoredFrameworks} = require('./flavored-frameworks');
39
+ const {
40
+ deriveAppName,
41
+ displayPath,
42
+ findProjectRoot,
43
+ makeLogger,
44
+ readPackageJson,
45
+ resolveReactNativeRoot,
46
+ toSwiftName,
47
+ } = require('./spm-utils');
48
+ const fs = require('fs');
49
+ const path = require('path');
50
+ const yargs = require('yargs');
51
+
52
+ const {log} = makeLogger('generate-spm-package');
53
+
54
+ function parseArgs(argv /*: Array<string> */) /*: GeneratePackageArgs */ {
55
+ const parsed = yargs(argv)
56
+ .version(false)
57
+ .option('app-root', {
58
+ type: 'string',
59
+ default: process.cwd(),
60
+ describe: 'Path to the app directory',
61
+ })
62
+ .option('react-native-root', {
63
+ type: 'string',
64
+ describe: 'Path to react-native package root',
65
+ })
66
+ .option('version', {
67
+ type: 'string',
68
+ describe: 'RN version for Maven artifact URLs',
69
+ })
70
+ .option('debug-artifacts-dir', {
71
+ type: 'string',
72
+ describe: 'Path to the complete Debug artifacts cache slot',
73
+ })
74
+ .option('release-artifacts-dir', {
75
+ type: 'string',
76
+ describe: 'Path to the complete Release artifacts cache slot',
77
+ })
78
+ .option('app-name', {
79
+ type: 'string',
80
+ describe: 'App/package name (default: from package.json)',
81
+ })
82
+ .option('target-name', {
83
+ type: 'string',
84
+ describe: 'Main app target name (default: derived from app-name)',
85
+ })
86
+ .option('source-path', {
87
+ type: 'string',
88
+ describe:
89
+ 'Path to app source relative to app-root (default: auto-detected)',
90
+ })
91
+ .option('ios-version', {
92
+ type: 'string',
93
+ default: '15',
94
+ describe: 'Minimum iOS version',
95
+ })
96
+ .usage(
97
+ 'Usage: $0 [options]\n\nGenerates the xcframeworks sub-package for a React Native app using SPM.',
98
+ )
99
+ .help()
100
+ .parseSync();
101
+
102
+ return {
103
+ appRoot: parsed['app-root'],
104
+ reactNativeRoot: parsed['react-native-root'] ?? null,
105
+ version: parsed.version ?? null,
106
+ debugArtifactsDir: parsed['debug-artifacts-dir'] ?? null,
107
+ releaseArtifactsDir: parsed['release-artifacts-dir'] ?? null,
108
+ appName: parsed['app-name'] ?? null,
109
+ targetName: parsed['target-name'] ?? null,
110
+ sourcePath: parsed['source-path'] ?? null,
111
+ iosVersion: parsed['ios-version'],
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Find the app's main Swift/ObjC source directory.
117
+ * Looks for directories that contain native iOS source files.
118
+ */
119
+ function findSourcePath(
120
+ appRoot /*: string */,
121
+ packageName /*: string */,
122
+ ) /*: string */ {
123
+ // Derive from package name (e.g. "@react-native/tester" -> "Tester")
124
+ const derived = toSwiftName(packageName.replace(/^@[^/]+\//, ''));
125
+
126
+ // Also check "RN" + derived (e.g. "Tester" -> "RNTester") and "RN" + whole name
127
+ const rnPrefixed = 'RN' + derived;
128
+ const candidates = [derived, rnPrefixed, 'ios', 'App', 'Sources', 'src'];
129
+ for (const c of candidates) {
130
+ if (fs.existsSync(path.join(appRoot, c))) {
131
+ return c;
132
+ }
133
+ }
134
+
135
+ // Scan for a directory that looks like an iOS source root
136
+ // (contains .m, .mm, .swift, or .h files)
137
+ try {
138
+ const entries /*: Array<{name: string, isDirectory(): boolean}> */ =
139
+ // $FlowFixMe[incompatible-type] Dirent.name is string|Buffer in Flow but always string here
140
+ fs.readdirSync(appRoot, {withFileTypes: true});
141
+ for (const entry of entries) {
142
+ if (!entry.isDirectory()) continue;
143
+ if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
144
+ const dirPath = path.join(appRoot, entry.name);
145
+ const subEntries = fs.readdirSync(dirPath);
146
+ const hasNativeSources = subEntries.some((f /*: string | Buffer */) =>
147
+ /\.(m|mm|swift|cpp|h|hpp)$/.test(String(f)),
148
+ );
149
+ if (hasNativeSources) {
150
+ return entry.name;
151
+ }
152
+ }
153
+ } catch (_) {
154
+ // ignore
155
+ }
156
+
157
+ return derived;
158
+ }
159
+
160
+ /**
161
+ * Generates the Package.swift for the xcframeworks sub-package.
162
+ *
163
+ * When using local xcframeworks (from the cache), we put the binary targets in
164
+ * a dedicated Package.swift at build/xcframeworks/. The generated .xcodeproj
165
+ * references this sub-package via XCLocalSwiftPackageReference; the codegen
166
+ * Package.swift also imports it as a named package dependency.
167
+ */
168
+ function generateXCFrameworksPackageSwift() /*: string */ {
169
+ return `// swift-tools-version: 6.0
170
+ // AUTO-GENERATED by scripts/generate-spm-package.js – do not edit manually.
171
+ import PackageDescription
172
+
173
+ let package = Package(
174
+ name: "ReactNative",
175
+ products: [
176
+ .library(name: "ReactHeaders", targets: ["ReactHeaders"]),
177
+ .library(name: "ReactNativeHeaders", targets: ["ReactNativeHeaders"]),
178
+ .library(name: "ReactNativeDependenciesHeaders", targets: ["ReactNativeDependenciesHeaders"]),
179
+ ],
180
+ targets: [
181
+ .target(
182
+ name: "ReactHeaders",
183
+ dependencies: ["ReactNativeHeaders"],
184
+ path: "ReactHeadersTarget",
185
+ publicHeadersPath: "include"
186
+ ),
187
+ .binaryTarget(
188
+ name: "ReactNativeHeaders",
189
+ path: "ReactNativeHeaders.xcframework"
190
+ ),
191
+ .binaryTarget(
192
+ name: "ReactNativeDependenciesHeaders",
193
+ path: "ReactNativeDependenciesHeaders.xcframework"
194
+ ),
195
+ ]
196
+ )
197
+ `;
198
+ }
199
+
200
+ function main(
201
+ argv /*:: ?: Array<string> */,
202
+ dependencies /*:: ?: {prepareFlavoredFrameworks?: typeof prepareFlavoredFrameworks} */,
203
+ ) /*: void */ {
204
+ const args = parseArgs(argv ?? process.argv.slice(2));
205
+ // Ensure appRoot is always absolute so path.join/path.resolve produce absolute paths
206
+ // even when called with --app-root . or other relative paths.
207
+ const appRoot = path.resolve(args.appRoot);
208
+
209
+ // Read app package.json
210
+ // package.json may be in a parent directory (e.g. when appRoot is ios/).
211
+ const projectRoot = findProjectRoot(appRoot);
212
+ const pkgJson = readPackageJson(projectRoot);
213
+ if (!pkgJson) {
214
+ throw new Error(
215
+ `[generate-spm-package] No package.json found in ${appRoot} or parent directories`,
216
+ );
217
+ }
218
+
219
+ let rnRoot =
220
+ args.reactNativeRoot != null
221
+ ? path.resolve(args.reactNativeRoot)
222
+ : resolveReactNativeRoot(appRoot, projectRoot);
223
+ if (rnRoot == null) {
224
+ throw new Error(
225
+ '[generate-spm-package] Could not find react-native. Pass --react-native-root.',
226
+ );
227
+ }
228
+
229
+ let version = args.version;
230
+ if (version == null) {
231
+ const rnPkg = readPackageJson(rnRoot);
232
+ version = rnPkg?.version ?? '0.0.0';
233
+ }
234
+
235
+ const rawName = pkgJson.name ?? path.basename(appRoot);
236
+ const sourcePath = args.sourcePath ?? findSourcePath(appRoot, rawName);
237
+ const appName = args.appName ?? deriveAppName(rawName, sourcePath);
238
+ const targetName = args.targetName ?? appName + 'App';
239
+
240
+ log(`App name: ${appName}`);
241
+ log(`Target name: ${targetName}`);
242
+ log(`Source path: ${sourcePath}`);
243
+ log(`Version: ${version}`);
244
+
245
+ const debugArtifactsDir = args.debugArtifactsDir;
246
+ const releaseArtifactsDir = args.releaseArtifactsDir;
247
+ if ((debugArtifactsDir == null) !== (releaseArtifactsDir == null)) {
248
+ throw new Error(
249
+ '[generate-spm-package] both --debug-artifacts-dir and --release-artifacts-dir are required',
250
+ );
251
+ }
252
+ if (debugArtifactsDir != null && releaseArtifactsDir != null) {
253
+ const prepare =
254
+ dependencies?.prepareFlavoredFrameworks ?? prepareFlavoredFrameworks;
255
+ prepare({
256
+ appRoot,
257
+ debugArtifactsDir,
258
+ releaseArtifactsDir,
259
+ });
260
+ const xcfwLinksDir = path.join(appRoot, 'build', 'xcframeworks');
261
+ const xcfwPkgContent = generateXCFrameworksPackageSwift();
262
+ const xcfwPkgPath = path.join(xcfwLinksDir, 'Package.swift');
263
+ let packageChanged = true;
264
+ try {
265
+ packageChanged = fs.readFileSync(xcfwPkgPath, 'utf8') !== xcfwPkgContent;
266
+ } catch {}
267
+ if (packageChanged) {
268
+ fs.writeFileSync(xcfwPkgPath, xcfwPkgContent, 'utf8');
269
+ }
270
+ log(
271
+ `${packageChanged ? 'Generated' : 'Unchanged'}: ${path.relative(
272
+ appRoot,
273
+ xcfwPkgPath,
274
+ )}`,
275
+ );
276
+ log(
277
+ `Artifact slots: debug=${displayPath(debugArtifactsDir)}, ` +
278
+ `release=${displayPath(releaseArtifactsDir)}`,
279
+ );
280
+ } else {
281
+ // Auto-detect an already-generated invariant package.
282
+ const xcfwLinksDir = path.join(appRoot, 'build', 'xcframeworks');
283
+ if (fs.existsSync(path.join(xcfwLinksDir, 'Package.swift'))) {
284
+ log(`Auto-detected local xcframeworks: build/xcframeworks`);
285
+ }
286
+ }
287
+ }
288
+
289
+ if (require.main === module) {
290
+ try {
291
+ main();
292
+ } catch (e) {
293
+ console.error(e.message);
294
+ process.exitCode = 1;
295
+ }
296
+ }
297
+
298
+ module.exports = {
299
+ main,
300
+ generateXCFrameworksPackageSwift,
301
+ findSourcePath,
302
+ };