react-native 0.87.0-rc.1 → 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.
- package/Libraries/Core/InitializeCore.js +8 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/ReactNative/AppRegistry.flow.js +1 -0
- package/Libraries/ReactNative/AppRegistryImpl.js +2 -3
- package/React/Base/RCTVersion.m +1 -1
- package/React/I18n/RCTLocalizedString.mm +38 -2
- package/React-Core-prebuilt.podspec +45 -17
- package/React-Core.podspec +9 -2
- package/ReactAndroid/external-artifacts/build.gradle.kts +49 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/SynchronousMountItem.kt +8 -2
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +10 -8
- package/react-native.config.js +81 -0
- package/scripts/cocoapods/fabric.rb +1 -1
- package/scripts/cocoapods/rncore.rb +35 -78
- package/scripts/cocoapods/rncore_facades.rb +232 -0
- package/scripts/cocoapods/rndependencies.rb +64 -3
- package/scripts/cocoapods/rndeps_facades.rb +193 -0
- package/scripts/cocoapods/spm.rb +78 -11
- package/scripts/codegen/templates/Package.swift.spm-template +97 -0
- package/scripts/react-native-xcode.sh +20 -0
- package/scripts/react_native_pods.rb +65 -16
- package/scripts/replace-rncore-version.js +53 -6
- package/scripts/setup-apple-spm.js +1165 -0
- package/scripts/spm/__doc__/rfc-spm-xcframework.md +707 -0
- package/scripts/spm/__doc__/spm-autolinking-plugins.md +244 -0
- package/scripts/spm/__doc__/spm-header-paths-contract.md +97 -0
- package/scripts/spm/__doc__/spm-plugins-assessment.md +128 -0
- package/scripts/spm/__doc__/spm-scripts.md +451 -0
- package/scripts/spm/autolinking-plugins.js +331 -0
- package/scripts/spm/download-spm-artifacts.js +1409 -0
- package/scripts/spm/expand-spm-dependencies.js +216 -0
- package/scripts/spm/flavored-frameworks.js +1008 -0
- package/scripts/spm/generate-spm-autolinking-config.js +161 -0
- package/scripts/spm/generate-spm-autolinking.js +1888 -0
- package/scripts/spm/generate-spm-package.js +302 -0
- package/scripts/spm/generate-spm-xcodeproj.js +2224 -0
- package/scripts/spm/read-podspec.js +695 -0
- package/scripts/spm/scaffold-package-swift.js +1206 -0
- package/scripts/spm/spm-pbxproj.js +654 -0
- package/scripts/spm/spm-types.js +517 -0
- package/scripts/spm/spm-utils.js +645 -0
- package/scripts/spm/sync-spm-autolinking.js +160 -0
- package/sdks/.hermesv1version +1 -0
- package/sdks/hermes-engine/utils/replace_hermes_version.js +18 -4
- package/sdks/hermes-engine/version.properties +1 -1
- package/third-party-podspecs/ReactNativeDependencies.podspec +2 -2
- package/types_generated/Libraries/ReactNative/AppRegistry.flow.d.ts +2 -2
- package/Libraries/Utilities/SceneTracker.js +0 -42
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
const {toSwiftName} = require('./spm-utils');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* expand-spm-dependencies.js — Resolves transitive native deps declared via
|
|
19
|
+
* `spm.dependencies` in a library's react-native.config.js.
|
|
20
|
+
*
|
|
21
|
+
* SPM has no equivalent of CocoaPods' podspec `s.dependency`, so library
|
|
22
|
+
* authors declare the same relationships explicitly:
|
|
23
|
+
*
|
|
24
|
+
* // react-native-reanimated/react-native.config.js
|
|
25
|
+
* module.exports = {
|
|
26
|
+
* dependency: { platforms: { ios: {} } },
|
|
27
|
+
* spm: { dependencies: ['react-native-worklets'] },
|
|
28
|
+
* };
|
|
29
|
+
*
|
|
30
|
+
* This module reads the directly-autolinked deps (from autolinking.json),
|
|
31
|
+
* follows each one's spm.dependencies recursively, and returns the deduped
|
|
32
|
+
* list with autolinking-shaped entries so the downstream pipeline can convert
|
|
33
|
+
* each to an SPM target without further branching.
|
|
34
|
+
*
|
|
35
|
+
* I/O is injected (readConfig, resolveDep) so the logic stays pure and
|
|
36
|
+
* testable.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/*::
|
|
40
|
+
import type {AutolinkedDep} from './spm-types';
|
|
41
|
+
|
|
42
|
+
// react-native.config.js entries have a user-defined shape, so we use an
|
|
43
|
+
// inexact object type and access properties dynamically.
|
|
44
|
+
type RnConfig = {...};
|
|
45
|
+
type ReadConfig = (root: string) => ?RnConfig;
|
|
46
|
+
type ResolveDep = (name: string, fromRoot: string) => ?string;
|
|
47
|
+
type Options = {
|
|
48
|
+
readConfig: ReadConfig,
|
|
49
|
+
resolveDep: ResolveDep,
|
|
50
|
+
};
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
// Validates and returns the Swift target name for a dep. Falls back to
|
|
54
|
+
// toSwiftName(npmName) when no override is set. The override is the dep's
|
|
55
|
+
// `react-native.config.js` `spm.name`, intended for libraries whose import
|
|
56
|
+
// prefix differs from the auto-derived name (e.g. `react-native-worklets`
|
|
57
|
+
// publishes headers under `<worklets/...>` via the podspec `s.header_dir`,
|
|
58
|
+
// so the SPM target name should be `worklets`, not `ReactNativeWorklets`).
|
|
59
|
+
function resolveSwiftName(
|
|
60
|
+
npmName /*: string */,
|
|
61
|
+
config /*: ?RnConfig */,
|
|
62
|
+
) /*: string */ {
|
|
63
|
+
// $FlowFixMe[prop-missing] config has dynamic shape
|
|
64
|
+
const override = config?.spm?.name;
|
|
65
|
+
if (override == null) {
|
|
66
|
+
return toSwiftName(npmName);
|
|
67
|
+
}
|
|
68
|
+
if (typeof override !== 'string' || override.length === 0) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`react-native autolinking: '${npmName}' has an invalid 'spm.name' override: expected a non-empty string, got ${JSON.stringify(override)}.`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
// Accept Swift-identifier style (TitleCase / snake_case) and header-dir
|
|
74
|
+
// style (lowercase, optional hyphens). Reject whitespace, slashes, and
|
|
75
|
+
// other characters that would break SPM target / module identifiers.
|
|
76
|
+
if (!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(override)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`react-native autolinking: '${npmName}' has an invalid 'spm.name' override '${override}': must start with a letter or underscore and contain only letters, digits, underscores, or hyphens.`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return override;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function expandSpmDependencies(
|
|
85
|
+
directDeps /*: Array<AutolinkedDep> */,
|
|
86
|
+
options /*: Options */,
|
|
87
|
+
) /*: Array<AutolinkedDep> */ {
|
|
88
|
+
const {readConfig, resolveDep} = options;
|
|
89
|
+
const byName /*: Map<string, AutolinkedDep> */ = new Map();
|
|
90
|
+
for (const dep of directDeps) {
|
|
91
|
+
byName.set(dep.name, {...dep, spmDependencies: []});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const queue /*: Array<string> */ = directDeps.map(d => d.name);
|
|
95
|
+
while (queue.length > 0) {
|
|
96
|
+
const currentName = queue.shift();
|
|
97
|
+
if (typeof currentName !== 'string') {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const current = byName.get(currentName);
|
|
101
|
+
if (current == null) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const config = readConfig(current.root);
|
|
105
|
+
// Resolve swiftName lazily from the same config read we already need for
|
|
106
|
+
// spm.dependencies — saves a duplicate readConfig call per direct dep.
|
|
107
|
+
if (current.swiftName == null) {
|
|
108
|
+
current.swiftName = resolveSwiftName(currentName, config);
|
|
109
|
+
}
|
|
110
|
+
// $FlowFixMe[prop-missing] config has dynamic shape
|
|
111
|
+
const transitives /*: Array<string> */ = config?.spm?.dependencies ?? [];
|
|
112
|
+
|
|
113
|
+
const currentSpmDeps /*: Array<string> */ = [];
|
|
114
|
+
for (const transitiveName of transitives) {
|
|
115
|
+
if (!byName.has(transitiveName)) {
|
|
116
|
+
const transitiveRoot = resolveDep(transitiveName, current.root);
|
|
117
|
+
if (transitiveRoot == null) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`react-native autolinking: '${currentName}' declares an unresolvable spm.dependency '${transitiveName}'. Ensure '${transitiveName}' is installed and visible via Node module resolution from ${current.root}.`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const transitiveConfig = readConfig(transitiveRoot);
|
|
124
|
+
// $FlowFixMe[prop-missing] config has dynamic shape
|
|
125
|
+
const iosPlatform = transitiveConfig?.dependency?.platforms?.ios;
|
|
126
|
+
if (iosPlatform == null) {
|
|
127
|
+
// No iOS native code — nothing to autolink and nothing to declare
|
|
128
|
+
// as an SPM target dep; mirrors the silent skip in
|
|
129
|
+
// autolinkingDepToSpmTarget for android-only deps.
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
byName.set(transitiveName, {
|
|
134
|
+
name: transitiveName,
|
|
135
|
+
root: transitiveRoot,
|
|
136
|
+
platforms: {ios: iosPlatform},
|
|
137
|
+
swiftName: resolveSwiftName(transitiveName, transitiveConfig),
|
|
138
|
+
spmDependencies: [],
|
|
139
|
+
});
|
|
140
|
+
queue.push(transitiveName);
|
|
141
|
+
}
|
|
142
|
+
currentSpmDeps.push(transitiveName);
|
|
143
|
+
}
|
|
144
|
+
current.spmDependencies = currentSpmDeps;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Collision check: two deps mapping to the same Swift name (whether via
|
|
148
|
+
// override or auto-derivation) would clobber each other in the synth
|
|
149
|
+
// package layout and the centralized headers tree. Surface it now with a
|
|
150
|
+
// clear message instead of letting SPM emit a confusing duplicate-target
|
|
151
|
+
// error later.
|
|
152
|
+
// Key case-INSENSITIVELY: resolveSwiftName permits lowercase ('worklets')
|
|
153
|
+
// while toSwiftName produces TitleCase ('Worklets') — an exact-equality check
|
|
154
|
+
// passes but the two still collide as directories on the default
|
|
155
|
+
// case-insensitive macOS filesystem (synth package layout + headers tree).
|
|
156
|
+
const seen /*: Map<string, {name: string, swiftName: string}> */ = new Map();
|
|
157
|
+
for (const dep of byName.values()) {
|
|
158
|
+
const swiftName = dep.swiftName;
|
|
159
|
+
if (swiftName == null) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const key = swiftName.toLowerCase();
|
|
163
|
+
const existing = seen.get(key);
|
|
164
|
+
if (existing != null) {
|
|
165
|
+
const same = existing.swiftName === swiftName;
|
|
166
|
+
throw new Error(
|
|
167
|
+
`react-native autolinking: SPM Swift name collision: '${existing.name}' ('${existing.swiftName}') and '${dep.name}' ('${swiftName}') ` +
|
|
168
|
+
(same
|
|
169
|
+
? `both resolve to '${swiftName}'.`
|
|
170
|
+
: `differ only in case, which collides on case-insensitive filesystems.`) +
|
|
171
|
+
` Set a distinct 'spm.name' in one of their react-native.config.js files.`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
seen.set(key, {name: dep.name, swiftName});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return Array.from(byName.values());
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// Default I/O implementations
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
function defaultReadConfig(root /*: string */) /*: ?RnConfig */ {
|
|
185
|
+
const configPath = path.join(root, 'react-native.config.js');
|
|
186
|
+
if (!fs.existsSync(configPath)) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
// $FlowFixMe[unsupported-syntax]
|
|
191
|
+
return require(configPath);
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function defaultResolveDep(
|
|
198
|
+
name /*: string */,
|
|
199
|
+
fromRoot /*: string */,
|
|
200
|
+
) /*: ?string */ {
|
|
201
|
+
try {
|
|
202
|
+
const pkgJsonPath = require.resolve(`${name}/package.json`, {
|
|
203
|
+
paths: [fromRoot],
|
|
204
|
+
});
|
|
205
|
+
return path.dirname(pkgJsonPath);
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
module.exports = {
|
|
212
|
+
expandSpmDependencies,
|
|
213
|
+
resolveSwiftName,
|
|
214
|
+
defaultReadConfig,
|
|
215
|
+
defaultResolveDep,
|
|
216
|
+
};
|