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,517 @@
|
|
|
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
|
+
/*::
|
|
12
|
+
export type SetupArgs = {
|
|
13
|
+
action: 'add' | 'update' | 'deinit' | 'sync' | 'codegen' | 'download' | 'scaffold' | null,
|
|
14
|
+
version: string | null,
|
|
15
|
+
// Local two-flavor artifact source (advanced). The directory contains
|
|
16
|
+
// `debug/` and `release/` cache slots, each with artifacts.json.
|
|
17
|
+
artifacts: string | null,
|
|
18
|
+
skipCodegen: boolean,
|
|
19
|
+
// Artifact download policy: 'auto' fetches when missing, 'skip' never
|
|
20
|
+
// fetches, 'force' clears the cache slot and re-downloads.
|
|
21
|
+
downloadPolicy: 'auto' | 'skip' | 'force',
|
|
22
|
+
// `add` target selection: which app target (when several) and which project.
|
|
23
|
+
productName: string | null,
|
|
24
|
+
xcodeprojPath: string | null,
|
|
25
|
+
// `add`: run `pod deintegrate` + strip RN from the Podfile before injecting.
|
|
26
|
+
// Also implied on the zero-arg path when resolveAction's safe-gate detects a
|
|
27
|
+
// freshly-scaffolded CocoaPods project (see setup-apple-spm.js).
|
|
28
|
+
deintegrate: boolean,
|
|
29
|
+
// Skip the single remaining confirmation (the add/update dirty-pbxproj
|
|
30
|
+
// warning). Non-TTY auto-proceeds regardless (git is the safety net).
|
|
31
|
+
yes: boolean,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type DownloadArgs = {
|
|
35
|
+
version: string | null,
|
|
36
|
+
flavor: string,
|
|
37
|
+
output: string | null,
|
|
38
|
+
coreTarball: string | null,
|
|
39
|
+
headersTarball: string | null,
|
|
40
|
+
depsTarball: string | null,
|
|
41
|
+
depsHeadersTarball: string | null,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type ResolvedArtifact = {
|
|
45
|
+
url: string,
|
|
46
|
+
version: string,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type ProcessResult = {
|
|
50
|
+
label: string,
|
|
51
|
+
version: string,
|
|
52
|
+
xcframeworkPath: string,
|
|
53
|
+
url: string,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type ArtifactResultEntry =
|
|
57
|
+
| {name: string, error: void, label: string, version: string, xcframeworkPath: string, url: string}
|
|
58
|
+
| {name: string, error: string};
|
|
59
|
+
|
|
60
|
+
export type AutolinkingArgs = {
|
|
61
|
+
appRoot: string,
|
|
62
|
+
reactNativeRoot: string | null,
|
|
63
|
+
autolinkingJson: string | null,
|
|
64
|
+
output: string | null,
|
|
65
|
+
xcframeworksPath: string | null,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type SpmTarget = {
|
|
69
|
+
name: string,
|
|
70
|
+
path: string,
|
|
71
|
+
exclude: Array<string>,
|
|
72
|
+
publicHeadersPath: string | null,
|
|
73
|
+
resources?: Array<string>,
|
|
74
|
+
// Swift target names this target depends on (already toSwiftName()'d).
|
|
75
|
+
// Emitted into the target's SPM `dependencies:` array so the compiler sees
|
|
76
|
+
// the dependent target's headers / module map.
|
|
77
|
+
spmTargetDependencies?: Array<string>,
|
|
78
|
+
// Explicit allowlist of source files (paths relative to target.path).
|
|
79
|
+
// Mirrors CocoaPods' `s.source_files`. When non-empty, the SPM target
|
|
80
|
+
// declares `sources: [...]` and only these files are compiled — test dirs,
|
|
81
|
+
// .js/.podspec/.md siblings, etc. can never sneak in. Null/empty means
|
|
82
|
+
// fall back to SPM's default scan of target.path.
|
|
83
|
+
sources?: ?Array<string>,
|
|
84
|
+
// Header search paths declared by the dep's podspec
|
|
85
|
+
// (pod_target_xcconfig HEADER_SEARCH_PATHS), already substituted relative
|
|
86
|
+
// to the dep's source dir. Path-style includes like
|
|
87
|
+
// `<react/renderer/components/safeareacontext/X.h>` resolve through these.
|
|
88
|
+
// Emitted as `.headerSearchPath(...)` directives in the target's
|
|
89
|
+
// cSettings / cxxSettings.
|
|
90
|
+
headerSearchPaths?: ?Array<string>,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Routing metadata kept alongside an SpmTarget in main(). Lives in a wrapper
|
|
94
|
+
// (not on SpmTarget) so the target type stays describable from the outside.
|
|
95
|
+
export type TargetEntry = {
|
|
96
|
+
target: SpmTarget,
|
|
97
|
+
origin: 'npm' | 'spmModule',
|
|
98
|
+
// The dep's npm package name (origin 'npm' only). Used in the
|
|
99
|
+
// missing-manifest error so the message names the package the developer
|
|
100
|
+
// installed, not its derived Swift target name.
|
|
101
|
+
npmName?: string,
|
|
102
|
+
// The dep's checked-in package root (origin 'npm' only) — the directory that
|
|
103
|
+
// holds its root `Package.swift` and `.react-native/` metadata. Threaded from
|
|
104
|
+
// the autolinking model (`dep.root`) so the watch file can flag manifest edits
|
|
105
|
+
// without walking up from the (possibly nested) target source dir.
|
|
106
|
+
root?: string,
|
|
107
|
+
// Filled in for npm-origin entries during the mirror step; consumed by the
|
|
108
|
+
// synth-package emission step further down.
|
|
109
|
+
mirrorReady?: ?{
|
|
110
|
+
synthPkgDir: string,
|
|
111
|
+
mirroredResources: ?Array<string>,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// autolinking.json shape (output of @react-native-community/cli config).
|
|
117
|
+
// All fields are optional because the JSON is user-influenced; the consumer
|
|
118
|
+
// checks at runtime.
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
export type AutolinkingIosPlatform = {
|
|
121
|
+
sourceDir?: ?string,
|
|
122
|
+
podspecPath?: ?string,
|
|
123
|
+
...
|
|
124
|
+
};
|
|
125
|
+
// As parsed from autolinking.json — all fields optional because the JSON is
|
|
126
|
+
// user-influenced. main() validates and narrows to AutolinkedDep before use.
|
|
127
|
+
export type AutolinkingDepJson = {
|
|
128
|
+
root?: ?string,
|
|
129
|
+
platforms?: ?{ios?: ?AutolinkingIosPlatform, ...},
|
|
130
|
+
...
|
|
131
|
+
};
|
|
132
|
+
export type RawAutolinkingJson = {
|
|
133
|
+
dependencies?: ?{[string]: AutolinkingDepJson},
|
|
134
|
+
...
|
|
135
|
+
};
|
|
136
|
+
// Validated/normalized dep — name and ios platform are guaranteed present.
|
|
137
|
+
// Produced from AutolinkingDepJson in main() and passed through
|
|
138
|
+
// expandSpmDependencies to autolinkingDepToSpmTarget.
|
|
139
|
+
export type AutolinkedDep = {
|
|
140
|
+
name: string,
|
|
141
|
+
root: string,
|
|
142
|
+
platforms: {ios: AutolinkingIosPlatform, ...},
|
|
143
|
+
// Resolved Swift target / module / headers-subdir name. Defaults to
|
|
144
|
+
// toSwiftName(name) and is overridden by the dep's react-native.config.js
|
|
145
|
+
// `spm.name`. Populated by expandSpmDependencies — always present after
|
|
146
|
+
// expansion; optional in the type so caller-side construction stays simple.
|
|
147
|
+
swiftName?: string,
|
|
148
|
+
// Populated by expandSpmDependencies from each dep's
|
|
149
|
+
// react-native.config.js `spm.dependencies` array.
|
|
150
|
+
spmDependencies?: Array<string>,
|
|
151
|
+
...
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// CLI `config` output minimally typed for the bits we read in
|
|
155
|
+
// generate-spm-autolinking-config.js.
|
|
156
|
+
export type CliConfigJson = {
|
|
157
|
+
root?: ?string,
|
|
158
|
+
reactNativePath?: ?string,
|
|
159
|
+
project?: ?{ios?: ?{sourceDir?: ?string, ...}, ...},
|
|
160
|
+
...
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Entry shape for an spmModule declared in react-native.config.js.
|
|
164
|
+
export type SpmModuleConfig = {
|
|
165
|
+
name: string,
|
|
166
|
+
path: string,
|
|
167
|
+
exclude?: Array<string>,
|
|
168
|
+
publicHeadersPath?: ?string,
|
|
169
|
+
// Optional CocoaPods-style glob allowlist (analog of s.source_files).
|
|
170
|
+
// When set, replaces auto source discovery for the module — only files
|
|
171
|
+
// matching one of these patterns are passed to SPM via `sources:`.
|
|
172
|
+
sources?: Array<string>,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// Inputs to the Swift emitters in generate-spm-autolinking.js.
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
export type NpmDepRef = {
|
|
179
|
+
swiftName: string,
|
|
180
|
+
// Path passed to .package(path:). Relative to autolinked/ (the aggregator's
|
|
181
|
+
// dir). For in-place synth this is the dep's real source dir.
|
|
182
|
+
packagePath?: string,
|
|
183
|
+
// The npm package name (e.g. react-native-safe-area-context). Used by the
|
|
184
|
+
// aggregator's eval-time missing-manifest guard to name the library a
|
|
185
|
+
// developer installed (not its Swift target name).
|
|
186
|
+
npmName?: string,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type AggregatorInput = {
|
|
190
|
+
npmDeps?: ReadonlyArray<NpmDepRef>,
|
|
191
|
+
inlineTargets?: ReadonlyArray<SpmTarget>,
|
|
192
|
+
hasReactDep?: boolean,
|
|
193
|
+
// Relative path from the aggregator's dir (autolinking/) to
|
|
194
|
+
// build/xcframeworks. Used for the inline-target ReactNative dep.
|
|
195
|
+
xcframeworksRelPath?: ?string,
|
|
196
|
+
// Autolinking-plugin contributions (Expo & other frameworks). Merged into
|
|
197
|
+
// the aggregator's package deps + the AutolinkedAggregate target deps.
|
|
198
|
+
pluginPackageDeps?: ReadonlyArray<PluginPackageDep>,
|
|
199
|
+
pluginProductDeps?: ReadonlyArray<PluginProductDep>,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// --- Autolinking plugins (PREVIEW / unstable contract) ---
|
|
203
|
+
|
|
204
|
+
// A framework's plugin package dependency: local (path) or remote (url+version).
|
|
205
|
+
export type PluginPackageDep = {
|
|
206
|
+
name: string,
|
|
207
|
+
path?: string,
|
|
208
|
+
url?: string,
|
|
209
|
+
version?: string,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// A product the AutolinkedAggregate target should link.
|
|
213
|
+
export type PluginProductDep = {name: string, package: string};
|
|
214
|
+
|
|
215
|
+
// A generated source file (e.g. Expo's ExpoModulesProvider.swift) to register
|
|
216
|
+
// in the codegen package so it compiles.
|
|
217
|
+
export type PluginGeneratedSource = {path: string};
|
|
218
|
+
|
|
219
|
+
// A plugin-declared dynamic XCFramework pair. RN validates both paths, stages
|
|
220
|
+
// immutable app-local slots, and links/embeds the selected framework outside
|
|
221
|
+
// SwiftPM.
|
|
222
|
+
export type PluginFlavoredFramework = {
|
|
223
|
+
id: string,
|
|
224
|
+
frameworkName: string,
|
|
225
|
+
linkage: 'dynamic',
|
|
226
|
+
flavors: {debug: string, release: string},
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type XcframeworkSlice = {
|
|
230
|
+
sdk: string,
|
|
231
|
+
platform: string,
|
|
232
|
+
variant: ?string,
|
|
233
|
+
architectures: Array<string>,
|
|
234
|
+
libraryIdentifier: string,
|
|
235
|
+
libraryPath: string,
|
|
236
|
+
binaryPath: string,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export type ParsedXcframework = {
|
|
240
|
+
path: string,
|
|
241
|
+
frameworkName: string,
|
|
242
|
+
executableName: string,
|
|
243
|
+
slices: Array<XcframeworkSlice>,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type FlavoredFrameworkManifestEntry = {
|
|
247
|
+
id: string,
|
|
248
|
+
frameworkName: string,
|
|
249
|
+
executableName: string,
|
|
250
|
+
linkage: 'dynamic',
|
|
251
|
+
artifactRelativePath: string,
|
|
252
|
+
slices: Array<XcframeworkSlice>,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export type FlavoredFrameworksManifest = {
|
|
256
|
+
version: 1,
|
|
257
|
+
frameworks: Array<FlavoredFrameworkManifestEntry>,
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// How a plugin depends on React — the single source of truth so a plugin's
|
|
261
|
+
// own Package.swift doesn't re-derive RN's package path/identity/products.
|
|
262
|
+
// Local vs remote is distinguished by which keys are present:
|
|
263
|
+
// - local: {name, path (absolute), relPath (relative to outputDir)}
|
|
264
|
+
// - remote: {name, url, version}
|
|
265
|
+
// `path` is absolute so it's correct no matter which subdir of outputDir the
|
|
266
|
+
// plugin writes its manifest into (the manifests are gitignored + regenerated).
|
|
267
|
+
export type ReactPackageRef =
|
|
268
|
+
| {name: string, path: string, relPath?: string}
|
|
269
|
+
| {name: string, url: string, version: string};
|
|
270
|
+
|
|
271
|
+
export type ReactDescriptor = {
|
|
272
|
+
packageRef: ReactPackageRef,
|
|
273
|
+
// The products a React-consuming target may depend on — the same set RN wires
|
|
274
|
+
// into its own autolinked targets (parity), filtered to those resolvable this
|
|
275
|
+
// run. Every listed product is safe to reference without guarding. Note
|
|
276
|
+
// ReactAppHeaders lives in the separate, per-app React-GeneratedCode package.
|
|
277
|
+
products: Array<{name: string, package: string}>,
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// Context handed to every plugin. Includes the JS root (projectRoot) and the
|
|
281
|
+
// parsed autolinking data so a framework can scan the discovered deps.
|
|
282
|
+
export type PluginContext = {
|
|
283
|
+
appRoot: string,
|
|
284
|
+
projectRoot: string,
|
|
285
|
+
reactNativeRoot: string,
|
|
286
|
+
autolinking: {readonly [string]: unknown},
|
|
287
|
+
outputDir: string,
|
|
288
|
+
// How to depend on React (package ref + product set); null only when there is
|
|
289
|
+
// no resolvable React dependency at all.
|
|
290
|
+
react: ?ReactDescriptor,
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export type PluginResult = {
|
|
294
|
+
packageDependencies: Array<PluginPackageDep>,
|
|
295
|
+
productDependencies: Array<PluginProductDep>,
|
|
296
|
+
generatedSources: Array<PluginGeneratedSource>,
|
|
297
|
+
flavoredFrameworks: Array<PluginFlavoredFramework>,
|
|
298
|
+
// Absolute paths (dirs or files) the Xcode auto-sync build phase should watch
|
|
299
|
+
// for staleness, e.g. the plugin dep's own `Package.swift` and per-module
|
|
300
|
+
// manifests. Folded into `.spm-sync-watch-paths` by main().
|
|
301
|
+
watchPaths: Array<string>,
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export type SpmAutolinkingPlugin = (context: PluginContext) => ?{
|
|
305
|
+
packageDependencies?: Array<PluginPackageDep>,
|
|
306
|
+
productDependencies?: Array<PluginProductDep>,
|
|
307
|
+
generatedSources?: Array<PluginGeneratedSource>,
|
|
308
|
+
flavoredFrameworks?: Array<PluginFlavoredFramework>,
|
|
309
|
+
watchPaths?: Array<string>,
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export type DiscoveredPlugin = {
|
|
313
|
+
depName: string,
|
|
314
|
+
pluginPath: string,
|
|
315
|
+
plugin: SpmAutolinkingPlugin,
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export type SynthPackageSpec = {
|
|
319
|
+
swiftName: string,
|
|
320
|
+
exclude?: Array<string>,
|
|
321
|
+
publicHeadersPath?: ?string,
|
|
322
|
+
// Explicit allowlist of source paths (relative to `targetPath`). When
|
|
323
|
+
// present and non-empty, the synth Package.swift emits `sources: [...]`
|
|
324
|
+
// — SPM will only compile these files.
|
|
325
|
+
sources?: ?Array<string>,
|
|
326
|
+
spmDependencies?: Array<{swiftName: string}>,
|
|
327
|
+
hasReactDep?: boolean,
|
|
328
|
+
// Relative path (posix, from the synth dir <outputDir>/packages/<Name>) to
|
|
329
|
+
// the app's React xcframeworks package and codegen package. Computed by the
|
|
330
|
+
// caller at generation time — the synth holds no runtime discovery.
|
|
331
|
+
reactNativePackagePath?: string,
|
|
332
|
+
codegenPackagePath?: string,
|
|
333
|
+
resources?: ?Array<string>,
|
|
334
|
+
isDynamic?: boolean,
|
|
335
|
+
targetPath?: string,
|
|
336
|
+
// Fallback relative base for sibling synth packages when the caller does not
|
|
337
|
+
// supply absolute paths (tests). Production uses siblingSynthAbsolutePaths.
|
|
338
|
+
siblingPackageBaseRelative?: string,
|
|
339
|
+
siblingSynthAbsolutePaths?: {[swiftName: string]: string},
|
|
340
|
+
// Header search paths from the dep's podspec `pod_target_xcconfig`
|
|
341
|
+
// HEADER_SEARCH_PATHS, with `$(PODS_TARGET_SRCROOT)` substituted and the
|
|
342
|
+
// synth wrapper's `root/` prefix applied. Emitted as `.headerSearchPath()`
|
|
343
|
+
// directives on cSettings / cxxSettings so path-style includes like
|
|
344
|
+
// `<react/renderer/components/safeareacontext/X.h>` resolve through the
|
|
345
|
+
// dep's own `common/cpp/` subtree.
|
|
346
|
+
headerSearchPaths?: ?Array<string>,
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
export type GeneratePackageArgs = {
|
|
351
|
+
appRoot: string,
|
|
352
|
+
reactNativeRoot: string | null,
|
|
353
|
+
version: string | null,
|
|
354
|
+
debugArtifactsDir: string | null,
|
|
355
|
+
releaseArtifactsDir: string | null,
|
|
356
|
+
appName: string | null,
|
|
357
|
+
targetName: string | null,
|
|
358
|
+
sourcePath: string | null,
|
|
359
|
+
iosVersion: string,
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// A preprocessor define lifted from a podspec's pod_target_xcconfig
|
|
363
|
+
// (OTHER_CFLAGS `-D...` tokens + GCC_PREPROCESSOR_DEFINITIONS entries). `value`
|
|
364
|
+
// is null for a bare `-DNAME` (define with no value); `config` scopes the
|
|
365
|
+
// define to a build configuration (from `[config=*Debug*]`/`[config=*Release*]`
|
|
366
|
+
// xcconfig keys), null = unconditional. Emitted as SPM `.define(...)`.
|
|
367
|
+
export type PreprocessorDefine = {
|
|
368
|
+
name: string,
|
|
369
|
+
value: ?string,
|
|
370
|
+
config: ?('debug' | 'release'),
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// ---------------------------------------------------------------------------
|
|
374
|
+
// Scaffold types — for the `npx react-native spm scaffold` command that
|
|
375
|
+
// generates a `Package.swift` into `node_modules/<dep>/` for community RN
|
|
376
|
+
// libraries that don't ship SPM support. Inputs come from the dep's podspec
|
|
377
|
+
// (read via `pod ipc spec --format=json` when CocoaPods is available, or a
|
|
378
|
+
// regex fallback). The output Package.swift is treated as "self-managed" by
|
|
379
|
+
// the autolinker — see isSelfManagedPackage in generate-spm-autolinking.js.
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
|
|
382
|
+
// Flattened, subspec-merged view of a podspec — what the translation layer
|
|
383
|
+
// consumes. HEADER_SEARCH_PATHS / source globs are kept as raw strings;
|
|
384
|
+
// substitution of `$(PODS_TARGET_SRCROOT)` etc. happens during translation
|
|
385
|
+
// so the raw model stays portable.
|
|
386
|
+
export type PodspecModel = {
|
|
387
|
+
name: string,
|
|
388
|
+
version: string,
|
|
389
|
+
sourceFiles: Array<string>,
|
|
390
|
+
publicHeaderFiles: Array<string>,
|
|
391
|
+
privateHeaderFiles: Array<string>,
|
|
392
|
+
excludeFiles: Array<string>,
|
|
393
|
+
headerMappingsDir: ?string,
|
|
394
|
+
// Every subspec's header_mappings_dir (union). dirname() of each is added as
|
|
395
|
+
// a header search path so `<namespace/...>` includes resolve from the
|
|
396
|
+
// physical source tree (SPM has no header_mappings_dir copy step).
|
|
397
|
+
headerMappingsDirs: Array<string>,
|
|
398
|
+
headerDir: ?string,
|
|
399
|
+
frameworks: Array<string>,
|
|
400
|
+
weakFrameworks: Array<string>,
|
|
401
|
+
libraries: Array<string>,
|
|
402
|
+
// Merged dependency name list. With pod-ipc, includes the deps materialized
|
|
403
|
+
// by `install_modules_dependencies(s)` (React-Core, React-Fabric, ...).
|
|
404
|
+
// Version constraints stripped — we only need the name to bucket.
|
|
405
|
+
dependencies: Array<string>,
|
|
406
|
+
compilerFlags: Array<string>,
|
|
407
|
+
// Raw header-search-path entries from `pod_target_xcconfig['HEADER_SEARCH_PATHS']`.
|
|
408
|
+
// May contain Xcode build setting placeholders like `$(PODS_TARGET_SRCROOT)`.
|
|
409
|
+
headerSearchPaths: Array<string>,
|
|
410
|
+
// Preprocessor defines lifted from pod_target_xcconfig OTHER_CFLAGS (`-D`
|
|
411
|
+
// tokens) + GCC_PREPROCESSOR_DEFINITIONS (incl. per-config variants). Already
|
|
412
|
+
// resolved by `pod ipc` (e.g. `-DWORKLETS_VERSION=#{package['version']}` →
|
|
413
|
+
// `WORKLETS_VERSION=0.9.2`). Emitted as `.define(...)` on the SPM target.
|
|
414
|
+
preprocessorDefines: Array<PreprocessorDefine>,
|
|
415
|
+
// File paths or glob patterns the dep declares as bundled resources.
|
|
416
|
+
resources: Array<string>,
|
|
417
|
+
requiresArc: boolean,
|
|
418
|
+
// Warnings collected during parsing — surfaced in the scaffold summary so
|
|
419
|
+
// a user can spot fields that didn't translate cleanly (unknown env vars,
|
|
420
|
+
// unrecognized $(...) tokens, etc.). Never throws on parse errors.
|
|
421
|
+
warnings: Array<string>,
|
|
422
|
+
// True when produced by the regex fallback rather than pod-ipc. Used to
|
|
423
|
+
// emit a louder banner in the scaffold summary explaining that dependency
|
|
424
|
+
// wiring may be incomplete.
|
|
425
|
+
partial: boolean,
|
|
426
|
+
// True when the podspec source calls `install_modules_dependencies(s)` —
|
|
427
|
+
// RN's Podfile-side helper that injects the React-Core family. We strip that
|
|
428
|
+
// helper before evaluating the spec (and the regex parser can't expand it),
|
|
429
|
+
// so React-Core never surfaces in `dependencies`. The scaffolder treats this
|
|
430
|
+
// flag as an implicit React-core dependency (a plain ObjC module using the
|
|
431
|
+
// helper has no `codegenConfig` to key off).
|
|
432
|
+
usesInstallModulesDependencies: boolean,
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// Intermediate translation result — concrete data the Swift emitter consumes.
|
|
436
|
+
// Decouples podspec reading from SPM-specific shaping so each side can be
|
|
437
|
+
// tested in isolation.
|
|
438
|
+
export type SpmScaffoldSpec = {
|
|
439
|
+
// Swift target / module name. Default: toSwiftName(podspec.name); overridden
|
|
440
|
+
// by `header_dir` when present.
|
|
441
|
+
swiftName: string,
|
|
442
|
+
// Source file paths relative to the dep root, ready for `sources: [...]`
|
|
443
|
+
// emission after the `root/` wrapper-dir prefix is applied at emit time.
|
|
444
|
+
sources: Array<string>,
|
|
445
|
+
// Header search paths resolved to dep-root-relative form. Each entry
|
|
446
|
+
// becomes `.headerSearchPath("<path>")` in cSettings + cxxSettings.
|
|
447
|
+
headerSearchPaths: Array<string>,
|
|
448
|
+
// Preprocessor defines (resolved by pod ipc) — emitted as `.define(...)` in
|
|
449
|
+
// cSettings + cxxSettings, honoring any per-config scope.
|
|
450
|
+
preprocessorDefines: Array<PreprocessorDefine>,
|
|
451
|
+
// True when the target has ObjC(++) sources (.m/.mm). Drives emitting +
|
|
452
|
+
// `-include`ing a prefix header that ambient-imports Foundation/UIKit (which
|
|
453
|
+
// CocoaPods provides via a generated prefix.pch and SPM does not).
|
|
454
|
+
needsObjCPrefix: boolean,
|
|
455
|
+
// Bucketed dependency references — pre-computed by the translation layer.
|
|
456
|
+
// `coreReactNative` is true when ANY React-* / RCT* / RCT-Folly / glog
|
|
457
|
+
// dep is present (so we add React's invariant header products).
|
|
458
|
+
// `siblingNames` are npm names that match other autolinked deps — resolved
|
|
459
|
+
// to Swift names by the scaffold orchestrator before emit.
|
|
460
|
+
coreReactNative: boolean,
|
|
461
|
+
siblingNames: Array<string>,
|
|
462
|
+
// Extra frameworks beyond the autolinker's default UIKit/Foundation/CoreGraphics
|
|
463
|
+
// set. Merged with the defaults at emit time.
|
|
464
|
+
extraFrameworks: Array<string>,
|
|
465
|
+
weakFrameworks: Array<string>,
|
|
466
|
+
// Compiler flags lifted from `s.compiler_flags`. Tokenized, ready for
|
|
467
|
+
// `cxxSettings: [.unsafeFlags([...])]`.
|
|
468
|
+
compilerFlags: Array<string>,
|
|
469
|
+
// Public-headers strategy. `mappingsDir` (when set) drives publicHeadersPath
|
|
470
|
+
// so the autolinker's centralized headers tree exposes `#import <SwiftName/...>`.
|
|
471
|
+
publicHeadersPath: ?string,
|
|
472
|
+
// Root-level headers (podspecs like `s.source_files = "*.{h,m,mm}"`) that the
|
|
473
|
+
// scaffold writer mirrors into a generated include/<SwiftName>/ shim dir so
|
|
474
|
+
// the CocoaPods header-map spelling `#import <SwiftName/Header.h>` resolves
|
|
475
|
+
// for dependents (publicHeadersPath is then "include").
|
|
476
|
+
namespacedShimHeaders: Array<string>,
|
|
477
|
+
// File paths (relative to dep root) the emitter should declare as `.copy(...)`
|
|
478
|
+
// resources on the target.
|
|
479
|
+
resources: Array<string>,
|
|
480
|
+
// Carried through from the PodspecModel; surfaced in the scaffold summary.
|
|
481
|
+
warnings: Array<string>,
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
// Per-dep outcome from one scaffold run. The orchestrator returns an array
|
|
485
|
+
// of these so the CLI summary can print a structured table.
|
|
486
|
+
export type ScaffoldResult =
|
|
487
|
+
| {
|
|
488
|
+
depName: string,
|
|
489
|
+
status: 'written',
|
|
490
|
+
packageSwiftPath: string,
|
|
491
|
+
warnings: Array<string>,
|
|
492
|
+
// True when the dep's Package.swift already existed (a regen — slot
|
|
493
|
+
// changed, --force, etc.); false on first-time scaffolds. The CLI
|
|
494
|
+
// orchestrator prompts only for first-time scaffolds.
|
|
495
|
+
previouslyExisted: boolean,
|
|
496
|
+
}
|
|
497
|
+
| {
|
|
498
|
+
depName: string,
|
|
499
|
+
status:
|
|
500
|
+
| 'skipped-self-managed'
|
|
501
|
+
| 'skipped-autogen'
|
|
502
|
+
| 'skipped-scaffolder-marker'
|
|
503
|
+
| 'skipped-no-ios'
|
|
504
|
+
| 'skipped-no-podspec'
|
|
505
|
+
| 'skipped-opt-out'
|
|
506
|
+
| 'skipped-mixed-language'
|
|
507
|
+
| 'skipped-is-react-native',
|
|
508
|
+
reason: string,
|
|
509
|
+
}
|
|
510
|
+
| {
|
|
511
|
+
depName: string,
|
|
512
|
+
status: 'error',
|
|
513
|
+
reason: string,
|
|
514
|
+
};
|
|
515
|
+
*/
|
|
516
|
+
|
|
517
|
+
module.exports = {};
|