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.
- package/android/build.gradle +2 -2
- package/android/proguard-rules.pro +4 -0
- package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +5 -1
- package/android/src/main/java/expo/modules/fetch/OkHttpFileUrlInterceptor.kt +5 -1
- package/build/winter/runtime.native.js +0 -2
- package/build/winter/runtime.native.js.map +1 -1
- package/bundledNativeModules.json +76 -76
- package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
- package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
- package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
- package/package.json +13 -13
- package/scripts/spm/README.md +0 -3
- package/scripts/spm/__tests__/app-target.test.js +105 -1
- package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
- package/scripts/spm/__tests__/classify.test.js +17 -19
- package/scripts/spm/__tests__/cli.test.js +57 -1
- package/scripts/spm/__tests__/diagnostics.test.js +806 -183
- package/scripts/spm/__tests__/flavored-frameworks.test.js +9 -0
- package/scripts/spm/__tests__/helpers.js +88 -0
- package/scripts/spm/__tests__/manifests.test.js +1330 -104
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +3304 -111
- package/scripts/spm/__tests__/podspec.test.js +27 -138
- package/scripts/spm/__tests__/spm-dependencies.test.js +344 -0
- package/scripts/spm/app-target.js +42 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +78 -79
- package/scripts/spm/cli.js +23 -9
- package/scripts/spm/diagnostics.js +605 -192
- package/scripts/spm/flavored-frameworks.js +231 -64
- package/scripts/spm/manifests.js +565 -196
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +679 -205
- package/scripts/spm/podspec.js +57 -170
- package/src/winter/runtime.native.ts +0 -2
- package/template.tgz +0 -0
- package/build/winter/AbortSignal.d.ts +0 -3
- package/build/winter/AbortSignal.js +0 -96
- package/build/winter/AbortSignal.js.map +0 -1
- package/src/winter/AbortSignal.ts +0 -132
- package/src/winter/__tests__/AbortSignal.test.native.ts +0 -163
package/scripts/spm/manifests.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const {
|
|
12
|
+
const { appleSourceDir, scanAppleSources } = require('./classify');
|
|
13
13
|
const { reactProductDependencies, reactPackageDeclarations } = require('./react-descriptor');
|
|
14
14
|
const { runDumpPackage } = require('./cli');
|
|
15
|
+
const { pluginError } = require('./diagnostics');
|
|
15
16
|
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
18
|
// Pure: parse `swift package dump-package` JSON → { name, products, targets }
|
|
@@ -19,8 +20,7 @@ const { runDumpPackage } = require('./cli');
|
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* A same-package target dependency: the bare target name, or `{ name, platforms }`
|
|
22
|
-
* when the manifest conditions it.
|
|
23
|
-
* deps — the injected React set covers those.
|
|
23
|
+
* when the manifest conditions it.
|
|
24
24
|
*/
|
|
25
25
|
function siblingDependency(dep) {
|
|
26
26
|
const [name, condition] = dep.byName ?? dep.target ?? [];
|
|
@@ -32,14 +32,239 @@ function siblingDependency(dep) {
|
|
|
32
32
|
const siblingName = (dep) => (typeof dep === 'string' ? dep : dep.name);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* The version a dumped source-control dependency is pinned at, or null when it names
|
|
36
|
+
* no form the generated package can declare. `.package(url:from:)` arrives here as a
|
|
37
|
+
* range — `dump-package` has already widened it — so there is no `from:` form to read.
|
|
37
38
|
*/
|
|
38
|
-
function
|
|
39
|
+
function packageRequirement(requirement) {
|
|
40
|
+
const [form, values] = Object.entries(requirement ?? {})[0] ?? [];
|
|
41
|
+
if (form === 'range') {
|
|
42
|
+
const { lowerBound, upperBound } = values?.[0] ?? {};
|
|
43
|
+
return lowerBound != null && upperBound != null
|
|
44
|
+
? { kind: 'range', lowerBound, upperBound }
|
|
45
|
+
: null;
|
|
46
|
+
}
|
|
47
|
+
if (form === 'exact' || form === 'branch' || form === 'revision') {
|
|
48
|
+
return typeof values?.[0] === 'string' ? { kind: form, value: values[0] } : null;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A prebuilt-metadata `spmPackages` entry in the shape a dumped manifest's packages
|
|
55
|
+
* take, `{ identity, url, requirement }`, plus the product the module links from it.
|
|
56
|
+
* The document publishes exactly one string requirement per entry, so its only key
|
|
57
|
+
* is the requirement's kind.
|
|
58
|
+
*/
|
|
59
|
+
function documentedPackage({ url, productName, version }) {
|
|
60
|
+
const [[kind, value]] = Object.entries(version);
|
|
61
|
+
return { identity: spmPackageIdentity({ url }), url, requirement: { kind, value }, productName };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Whether a trait set is anything but the default one every dumped dependency carries. */
|
|
65
|
+
function hasNonDefaultTraits(traits) {
|
|
66
|
+
if (traits == null) return false;
|
|
67
|
+
return traits.length !== 1 || traits[0]?.name !== 'default';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The packages the generated manifest mirrors, keyed by every name a target dependency
|
|
72
|
+
* may resolve them by, plus one entry per package it cannot declare. A dropped package
|
|
73
|
+
* is invisible until the module's first `import` of it, so every form this cannot
|
|
74
|
+
* render is collected rather than skipped.
|
|
75
|
+
*/
|
|
76
|
+
function parsePackageDependencies(dependencies, injectedNames) {
|
|
77
|
+
const packageDeps = [];
|
|
78
|
+
const packagesByName = new Map();
|
|
79
|
+
const unsupported = [];
|
|
80
|
+
// SwiftPM resolves a package by identity or `.package(name:)` name, case-insensitively; a
|
|
81
|
+
// reported package answers to both, so a target dependency on it joins that report.
|
|
82
|
+
const reportedByName = new Map();
|
|
83
|
+
const report = (form, identity, ...otherNames) => {
|
|
84
|
+
const entry = { form, identity: identity ?? null, target: null };
|
|
85
|
+
unsupported.push(entry);
|
|
86
|
+
for (const name of [identity, ...otherNames]) {
|
|
87
|
+
if (typeof name !== 'string' || reportedByName.has(name.toLowerCase())) continue;
|
|
88
|
+
reportedByName.set(name.toLowerCase(), entry);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const dependency of dependencies ?? []) {
|
|
92
|
+
const [form, declarations] = Object.entries(dependency ?? {})[0] ?? [];
|
|
93
|
+
const declared = declarations?.[0] ?? {};
|
|
94
|
+
const reportDeclared = (fault) =>
|
|
95
|
+
report(fault, declared.identity, declared.nameForTargetDependencyResolutionOnly);
|
|
96
|
+
if (form === 'sourceControl') {
|
|
97
|
+
const url = declared.location?.remote?.[0]?.urlString;
|
|
98
|
+
const requirement = url != null ? packageRequirement(declared.requirement) : null;
|
|
99
|
+
if (url == null) {
|
|
100
|
+
reportDeclared('unsupported-location');
|
|
101
|
+
} else if (requirement == null) {
|
|
102
|
+
reportDeclared('unsupported-requirement');
|
|
103
|
+
} else {
|
|
104
|
+
// Traits select which of a package's code builds, and this renders none of them,
|
|
105
|
+
// so a non-default set would build something other than the module declared.
|
|
106
|
+
if (hasNonDefaultTraits(declared.traits)) report('unsupported-traits', declared.identity);
|
|
107
|
+
const pkg = { identity: declared.identity ?? null, url, requirement };
|
|
108
|
+
packageDeps.push(pkg);
|
|
109
|
+
for (const name of [declared.identity, declared.nameForTargetDependencyResolutionOnly]) {
|
|
110
|
+
if (typeof name !== 'string') continue;
|
|
111
|
+
// Two packages answering to one name would resolve to whichever was declared
|
|
112
|
+
// last — a silent choice between two different dependencies.
|
|
113
|
+
if ((packagesByName.get(name.toLowerCase()) ?? pkg) !== pkg) {
|
|
114
|
+
report('ambiguous-package-name', name);
|
|
115
|
+
}
|
|
116
|
+
packagesByName.set(name.toLowerCase(), pkg);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else if (form === 'fileSystem') {
|
|
120
|
+
// Mirroring one would mean rewriting its path against the `root` symlink, which
|
|
121
|
+
// this plugin does not do.
|
|
122
|
+
reportDeclared('local-path');
|
|
123
|
+
} else if (form === 'registry') {
|
|
124
|
+
reportDeclared('registry');
|
|
125
|
+
} else {
|
|
126
|
+
reportDeclared('unknown-form');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// SwiftPM refuses a graph where two packages resolve to one identity, so a mirrored
|
|
130
|
+
// package may not take a name the injected declarations already occupy.
|
|
131
|
+
const injected = new Set(injectedNames.map((name) => name.toLowerCase()));
|
|
132
|
+
for (const { identity } of packageDeps) {
|
|
133
|
+
if (identity != null && injected.has(identity.toLowerCase())) {
|
|
134
|
+
report('collides-with-injected', identity);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { packageDeps, packagesByName, reportedByName, unsupportedPackageDeps: unsupported };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Identities the injected RN declarations occupy (mirrors react-descriptor.js); a path
|
|
142
|
+
* package answers to its dir name and its `name:`.
|
|
143
|
+
*/
|
|
144
|
+
function injectedPackageNames(react) {
|
|
145
|
+
if (react == null) return [];
|
|
146
|
+
const ref = react.packageRef;
|
|
147
|
+
return [
|
|
148
|
+
ref.name,
|
|
149
|
+
ref.url != null ? spmPackageIdentity(ref) : null,
|
|
150
|
+
ref.path != null ? path.basename(ref.path) : null,
|
|
151
|
+
...react.products.map((p) => p.package),
|
|
152
|
+
].filter((name) => typeof name === 'string');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hasEntries = (value) => value != null && Object.keys(value).length > 0;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Whether a target-dependency condition sets anything this renderer does not carry.
|
|
159
|
+
* Swift tools 6.1 added traits to it, and a condition rendered without them would
|
|
160
|
+
* apply the dependency more widely than the module declared.
|
|
161
|
+
*/
|
|
162
|
+
function unrenderableCondition(condition) {
|
|
163
|
+
return Object.entries(condition ?? {}).some(
|
|
164
|
+
([key, value]) =>
|
|
165
|
+
key !== 'platformNames' && value != null && (!Array.isArray(value) || value.length > 0)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Why a `.product` dependency cannot be mirrored, or null when it can. */
|
|
170
|
+
function productFault(declaredPackage, moduleAliases, condition) {
|
|
171
|
+
if (declaredPackage == null) return 'undeclared-package';
|
|
172
|
+
// An alias renames a dependency's modules. Rendering the dependency without it would
|
|
173
|
+
// leave the module importing a name nothing declares, or reintroduce the duplicate
|
|
174
|
+
// module name the alias exists to resolve.
|
|
175
|
+
if (hasEntries(moduleAliases)) return 'module-aliases';
|
|
176
|
+
if (unrenderableCondition(condition)) return 'unsupported-condition';
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The name a mirrored `.product` must give its package. The mirrored declaration carries
|
|
182
|
+
* no `name:`, so a dependency that named the package by a deprecated `.package(name:)`
|
|
183
|
+
* has to name the identity instead; a name that differs only in case resolves as written.
|
|
184
|
+
*/
|
|
185
|
+
function resolvablePackageName(written, declaredPackage) {
|
|
186
|
+
const { identity } = declaredPackage;
|
|
187
|
+
return identity != null && identity.toLowerCase() !== written.toLowerCase() ? identity : written;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Keep only regular targets and library products; resolve each target's dependencies
|
|
192
|
+
* against the targets and packages this package declares, in their declared order, and
|
|
193
|
+
* collect everything the generated package cannot re-declare.
|
|
194
|
+
*/
|
|
195
|
+
function parseDumpedManifest(json, injectedNames = []) {
|
|
39
196
|
const pkg = JSON.parse(json);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
197
|
+
const { packageDeps, packagesByName, reportedByName, unsupportedPackageDeps } =
|
|
198
|
+
parsePackageDependencies(pkg.dependencies, injectedNames);
|
|
199
|
+
const declaredTargets = pkg.targets ?? [];
|
|
200
|
+
const declaredKinds = new Map(declaredTargets.map((t) => [t.name, t.type]));
|
|
201
|
+
const regular = declaredTargets.filter((t) => t.type === 'regular');
|
|
202
|
+
const regularNames = new Set(regular.map((t) => t.name));
|
|
203
|
+
const unsupportedTargetDeps = [];
|
|
204
|
+
// The PRODUCT names the mirrored targets take from those packages. Dependency
|
|
205
|
+
// diagnostics match a pod name against these — `libavif/libdav1d` is covered by the
|
|
206
|
+
// `libavif` product, whatever the package it ships in is called.
|
|
207
|
+
const spmProductNames = [];
|
|
208
|
+
|
|
209
|
+
const targets = regular.map((t) => {
|
|
210
|
+
const dependencies = [];
|
|
211
|
+
for (const dep of t.dependencies ?? []) {
|
|
212
|
+
if (dep.product != null) {
|
|
213
|
+
const [name, packageName, moduleAliases, condition] = dep.product;
|
|
214
|
+
const declaredPackage =
|
|
215
|
+
packageName != null ? (packagesByName.get(packageName.toLowerCase()) ?? null) : null;
|
|
216
|
+
const fault = productFault(declaredPackage, moduleAliases, condition);
|
|
217
|
+
if (fault != null) {
|
|
218
|
+
// Already reported under its declaration; attach the target there.
|
|
219
|
+
const reported = reportedByName.get((packageName ?? '').toLowerCase());
|
|
220
|
+
if (fault === 'undeclared-package' && reported != null) reported.target ??= t.name;
|
|
221
|
+
else {
|
|
222
|
+
unsupportedPackageDeps.push({
|
|
223
|
+
form: fault,
|
|
224
|
+
identity: packageName ?? null,
|
|
225
|
+
target: t.name,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
dependencies.push({
|
|
231
|
+
product: name,
|
|
232
|
+
package: resolvablePackageName(packageName, declaredPackage),
|
|
233
|
+
platforms: condition?.platformNames ?? [],
|
|
234
|
+
});
|
|
235
|
+
spmProductNames.push(name);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const sibling = siblingDependency(dep);
|
|
239
|
+
if (sibling == null) continue;
|
|
240
|
+
const name = siblingName(sibling);
|
|
241
|
+
if (unrenderableCondition((dep.byName ?? dep.target)[1])) {
|
|
242
|
+
unsupportedPackageDeps.push({
|
|
243
|
+
form: 'unsupported-target-condition',
|
|
244
|
+
identity: name,
|
|
245
|
+
target: t.name,
|
|
246
|
+
});
|
|
247
|
+
} else if (regularNames.has(name)) {
|
|
248
|
+
dependencies.push(sibling);
|
|
249
|
+
} else if (declaredKinds.has(name)) {
|
|
250
|
+
// Only regular targets are mirrored, so a dependency on a target of any other
|
|
251
|
+
// kind names a target the generated package does not declare. Dropping it
|
|
252
|
+
// silently ends in an undefined symbol at link time, so it is collected.
|
|
253
|
+
unsupportedTargetDeps.push({
|
|
254
|
+
target: t.name,
|
|
255
|
+
dependsOn: name,
|
|
256
|
+
kind: declaredKinds.get(name),
|
|
257
|
+
});
|
|
258
|
+
} else if (dep.byName != null) {
|
|
259
|
+
// Resolves against the declared packages' PRODUCTS, which a dump does not list;
|
|
260
|
+
// rendered verbatim, SwiftPM names it if it resolves to nothing.
|
|
261
|
+
dependencies.push(
|
|
262
|
+
typeof sibling === 'string' ? name : { byName: name, platforms: sibling.platforms }
|
|
263
|
+
);
|
|
264
|
+
spmProductNames.push(name);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
43
268
|
name: t.name,
|
|
44
269
|
// An omitted `path:` is resolved against the filesystem by the emit layer.
|
|
45
270
|
path: t.path ?? null,
|
|
@@ -48,33 +273,26 @@ function parseDumpedManifest(json) {
|
|
|
48
273
|
sources: t.sources ?? [],
|
|
49
274
|
resources: t.resources ?? [],
|
|
50
275
|
settings: t.settings ?? [],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Only regular targets are mirrored, so a dependency on a target of any other kind
|
|
56
|
-
// would name a target the generated package does not declare.
|
|
57
|
-
const targets = regular.map((t) => ({
|
|
58
|
-
...t,
|
|
59
|
-
siblingDeps: t.siblingDeps.filter((d) => regularNames.has(siblingName(d))),
|
|
60
|
-
}));
|
|
61
|
-
// Dropping such a dependency silently ends in an undefined symbol at link time, so it
|
|
62
|
-
// is collected and reported. A name that is NO target of this package is a product of
|
|
63
|
-
// a dependency package — `.byName` resolves to that too — and is correctly dropped.
|
|
64
|
-
const declaredKinds = new Map((pkg.targets ?? []).map((t) => [t.name, t.type]));
|
|
65
|
-
const unsupportedTargetDeps = regular.flatMap((t) =>
|
|
66
|
-
t.siblingDeps
|
|
67
|
-
.map(siblingName)
|
|
68
|
-
.filter((name) => !regularNames.has(name) && declaredKinds.has(name))
|
|
69
|
-
.map((name) => ({ target: t.name, dependsOn: name, kind: declaredKinds.get(name) }))
|
|
70
|
-
);
|
|
276
|
+
dependencies,
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
|
|
71
280
|
const products = (pkg.products ?? [])
|
|
72
281
|
.filter((p) => Object.keys(p.type ?? {})[0] === 'library')
|
|
73
282
|
.map((p) => ({ name: p.name, targets: (p.targets ?? []).filter((n) => regularNames.has(n)) }))
|
|
74
283
|
.filter((p) => p.targets.length);
|
|
75
284
|
const iosDeploymentTarget =
|
|
76
285
|
(pkg.platforms ?? []).find((p) => p.platformName === 'ios')?.version ?? null;
|
|
77
|
-
return {
|
|
286
|
+
return {
|
|
287
|
+
name: pkg.name,
|
|
288
|
+
iosDeploymentTarget,
|
|
289
|
+
products,
|
|
290
|
+
targets,
|
|
291
|
+
packageDeps,
|
|
292
|
+
spmProductNames: [...new Set(spmProductNames)],
|
|
293
|
+
unsupportedTargetDeps,
|
|
294
|
+
unsupportedPackageDeps,
|
|
295
|
+
};
|
|
78
296
|
}
|
|
79
297
|
|
|
80
298
|
// ---------------------------------------------------------------------------
|
|
@@ -108,26 +326,36 @@ const SWIFT_PLATFORM_CASES = new Map([
|
|
|
108
326
|
function swiftPlatformCases(names, context) {
|
|
109
327
|
const declared = (names ?? []).map((p) => SWIFT_PLATFORM_CASES.get(p)).filter((p) => p != null);
|
|
110
328
|
if (declared.length === 0 && (names ?? []).length > 0) {
|
|
111
|
-
throw
|
|
112
|
-
`Cannot generate a consumption Package.swift for ${context}: its platform condition names only `
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
'platform Swift Package Manager supports.'
|
|
117
|
-
);
|
|
329
|
+
throw pluginError({
|
|
330
|
+
what: `Cannot generate a consumption Package.swift for ${context}: its platform condition names only ${names.map((n) => `"${n}"`).join(', ')}, which PackageDescription 6.0 does not declare.`,
|
|
331
|
+
why: 'Dropping the condition would apply the declaration on every platform, wider than the module declared.',
|
|
332
|
+
how: 'Add the platform to SWIFT_PLATFORM_CASES in expo/scripts/spm/manifests.js, or condition the declaration on a platform Swift Package Manager supports.',
|
|
333
|
+
});
|
|
118
334
|
}
|
|
119
335
|
return declared;
|
|
120
336
|
}
|
|
121
337
|
|
|
338
|
+
/** SwiftPM allows only `platforms:` in a target-dependency condition. */
|
|
339
|
+
function renderPlatformCondition(platforms, context) {
|
|
340
|
+
const cases = swiftPlatformCases(platforms, context);
|
|
341
|
+
return cases.length ? `, condition: .when(platforms: [${cases.join(', ')}])` : '';
|
|
342
|
+
}
|
|
343
|
+
|
|
122
344
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
345
|
+
* One target dependency — a sibling target, a mirrored package's product, or a
|
|
346
|
+
* `.byName` the module wrote against one of its packages — conditioned on platforms
|
|
347
|
+
* when the module declared it so.
|
|
125
348
|
*/
|
|
126
|
-
function
|
|
127
|
-
if (typeof dep === 'string') return `"${dep}"`;
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
349
|
+
function renderTargetDependency(dep) {
|
|
350
|
+
if (typeof dep === 'string') return `"${escapeSwiftString(dep)}"`;
|
|
351
|
+
const kind = dep.product != null ? 'product' : dep.byName != null ? 'byName' : 'target';
|
|
352
|
+
const dependsOn = dep.product ?? dep.byName ?? dep.name;
|
|
353
|
+
const condition = renderPlatformCondition(dep.platforms, `the dependency on "${dependsOn}"`);
|
|
354
|
+
const name = escapeSwiftString(dependsOn);
|
|
355
|
+
if (kind === 'product') {
|
|
356
|
+
return `.product(name: "${name}", package: "${escapeSwiftString(dep.package)}"${condition})`;
|
|
357
|
+
}
|
|
358
|
+
return condition ? `.${kind}(name: "${name}"${condition})` : `"${name}"`;
|
|
131
359
|
}
|
|
132
360
|
|
|
133
361
|
const RESOURCE_RULES = new Map([
|
|
@@ -151,12 +379,11 @@ function renderResource(resource, targetName) {
|
|
|
151
379
|
const localization =
|
|
152
380
|
options?.localization != null ? RESOURCE_LOCALIZATIONS.get(options.localization) : null;
|
|
153
381
|
if (call == null || (options?.localization != null && localization == null)) {
|
|
154
|
-
throw
|
|
155
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": resource "${resource.path}"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
382
|
+
throw pluginError({
|
|
383
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": resource "${resource.path}" uses the unsupported rule \`${JSON.stringify(resource.rule)}\`.`,
|
|
384
|
+
why: 'This plugin renders .process, .copy and .embedInCode with .default/.base localizations; a newer Swift Package Manager rule needs support added in expo/scripts/spm/manifests.js.',
|
|
385
|
+
how: 'Declare the resource with one of the supported rules meanwhile.',
|
|
386
|
+
});
|
|
160
387
|
}
|
|
161
388
|
return localization != null
|
|
162
389
|
? `${call}("${resource.path}", localization: ${localization})`
|
|
@@ -191,10 +418,9 @@ const INTEROPERABILITY_MODES = new Map([
|
|
|
191
418
|
]);
|
|
192
419
|
|
|
193
420
|
function settingError(targetName, setting, explanation) {
|
|
194
|
-
return
|
|
195
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": build setting
|
|
196
|
-
|
|
197
|
-
);
|
|
421
|
+
return pluginError({
|
|
422
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": build setting \`${JSON.stringify(setting.kind)}\` ${explanation}`,
|
|
423
|
+
});
|
|
198
424
|
}
|
|
199
425
|
|
|
200
426
|
/**
|
|
@@ -303,18 +529,27 @@ function renderFileRules(target) {
|
|
|
303
529
|
);
|
|
304
530
|
}
|
|
305
531
|
|
|
306
|
-
/**
|
|
307
|
-
|
|
532
|
+
/**
|
|
533
|
+
* Mirror a manifest's targets, products and packages — a checked-in one as
|
|
534
|
+
* `parseDumpedManifest` read it, or a `pureSwiftManifest` — and inject the given deps.
|
|
535
|
+
*/
|
|
536
|
+
function renderSourceManifest({
|
|
537
|
+
manifest,
|
|
538
|
+
pkgDeps = [],
|
|
539
|
+
injectedTargetDeps = [],
|
|
540
|
+
frameworkSearchPath,
|
|
541
|
+
extraSwiftFlags = [],
|
|
542
|
+
}) {
|
|
308
543
|
const targetsSwift = manifest.targets
|
|
309
544
|
.map((t) => {
|
|
310
545
|
if (t.path == null) {
|
|
311
|
-
throw
|
|
312
|
-
`Cannot generate a consumption Package.swift for "${manifest.name}": target "${t.name}" has no source path
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
);
|
|
546
|
+
throw pluginError({
|
|
547
|
+
what: `Cannot generate a consumption Package.swift for "${manifest.name}": target "${t.name}" has no source path.`,
|
|
548
|
+
why: "Its path was neither declared in the module's manifest nor resolved on disk, so the generated target would point at nothing.",
|
|
549
|
+
how: 'Resolve target paths with resolveTargetPaths before rendering.',
|
|
550
|
+
});
|
|
316
551
|
}
|
|
317
|
-
const deps = [...t.
|
|
552
|
+
const deps = [...t.dependencies.map(renderTargetDependency), ...injectedTargetDeps];
|
|
318
553
|
const depsSwift = deps.length
|
|
319
554
|
? `\n${deps.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
320
555
|
: '';
|
|
@@ -324,7 +559,7 @@ function renderSourceManifest(manifest, pkgDeps, injected, frameworkSearchPath)
|
|
|
324
559
|
return ` .target(
|
|
325
560
|
name: "${t.name}",
|
|
326
561
|
dependencies: [${depsSwift}],
|
|
327
|
-
path: "root/${t.path}",${renderFileRules(t)}${headers}${renderTargetSettings(frameworkSearchPath, t.settings, t.name)}
|
|
562
|
+
path: "root/${t.path}",${renderFileRules(t)}${headers}${renderTargetSettings(frameworkSearchPath, t.settings, t.name, extraSwiftFlags)}
|
|
328
563
|
)`;
|
|
329
564
|
})
|
|
330
565
|
.join(',\n');
|
|
@@ -335,19 +570,24 @@ function renderSourceManifest(manifest, pkgDeps, injected, frameworkSearchPath)
|
|
|
335
570
|
` .library(name: "${p.name}", targets: [${p.targets.map((n) => `"${n}"`).join(', ')}])`
|
|
336
571
|
)
|
|
337
572
|
.join(',\n');
|
|
338
|
-
const
|
|
339
|
-
|
|
573
|
+
const declarations = [...pkgDeps, ...(manifest.packageDeps ?? []).map(packageDeclaration)];
|
|
574
|
+
const packageDepsSwift = declarations.length
|
|
575
|
+
? `\n${declarations.map((dep) => ` ${dep},`).join('\n')}\n `
|
|
340
576
|
: '';
|
|
341
577
|
|
|
578
|
+
const origin = manifest.pureSwift
|
|
579
|
+
? `// Pure-Swift source consumption package for "${manifest.name}".`
|
|
580
|
+
: `// Source consumption package for "${manifest.name}": mirrors the module's checked-in
|
|
581
|
+
// Package.swift targets and injects invariant React compile dependencies.`;
|
|
582
|
+
|
|
342
583
|
return `// swift-tools-version: 6.0
|
|
343
584
|
// AUTO-GENERATED by expo/scripts/spm/plugin.js — do not edit.
|
|
344
|
-
|
|
345
|
-
// Package.swift targets and injects invariant React compile dependencies.
|
|
585
|
+
${origin}
|
|
346
586
|
import PackageDescription
|
|
347
587
|
|
|
348
588
|
let package = Package(
|
|
349
589
|
name: "${manifest.name}",
|
|
350
|
-
platforms: ${renderPlatforms(manifest.iosDeploymentTarget
|
|
590
|
+
platforms: ${renderPlatforms(manifest.iosDeploymentTarget)},
|
|
351
591
|
products: [
|
|
352
592
|
${productsSwift}
|
|
353
593
|
],
|
|
@@ -365,57 +605,73 @@ ${targetsSwift}
|
|
|
365
605
|
const PRIVACY_MANIFEST = 'PrivacyInfo.xcprivacy';
|
|
366
606
|
|
|
367
607
|
/**
|
|
368
|
-
*
|
|
369
|
-
*
|
|
608
|
+
* The identity SwiftPM resolves a package URL to: its last path component, without
|
|
609
|
+
* trailing slashes or a `.git` suffix. It is the repository name, which differs
|
|
610
|
+
* from the product where a repository ships one under another name, as
|
|
611
|
+
* `libavif-Xcode` ships `libavif`.
|
|
612
|
+
*/
|
|
613
|
+
function spmPackageIdentity(pkg) {
|
|
614
|
+
return pkg.url
|
|
615
|
+
.replace(/\/+$/, '')
|
|
616
|
+
.split('/')
|
|
617
|
+
.pop()
|
|
618
|
+
.replace(/\.git$/, '');
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* `.package(url:)` for a package a checked-in manifest declares or one from
|
|
623
|
+
* `documentedPackage`. Only a dumped package has a range, and only a documented one
|
|
624
|
+
* has `from`, which `dump-package` widens into a range.
|
|
370
625
|
*/
|
|
371
|
-
function
|
|
626
|
+
function packageDeclaration({ url, requirement }) {
|
|
627
|
+
const quoted = (value) => `"${escapeSwiftString(value)}"`;
|
|
628
|
+
const pin =
|
|
629
|
+
requirement.kind === 'range'
|
|
630
|
+
? `${quoted(requirement.lowerBound)}..<${quoted(requirement.upperBound)}`
|
|
631
|
+
: `${requirement.kind}: ${quoted(requirement.value)}`;
|
|
632
|
+
return `.package(url: ${quoted(url)}, ${pin})`;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* A pure-Swift module as the manifest `renderSourceManifest` mirrors: one Swift target
|
|
637
|
+
* over its `ios`/`apple` sources, depending on the product of each documented package.
|
|
638
|
+
*
|
|
639
|
+
* @param packages `documentedPackage` entries.
|
|
640
|
+
*/
|
|
641
|
+
function pureSwiftManifest({
|
|
372
642
|
product,
|
|
373
643
|
srcRel,
|
|
374
|
-
pkgDeps,
|
|
375
|
-
targetDeps,
|
|
376
|
-
frameworkSearchPath,
|
|
377
644
|
excludes = [],
|
|
378
645
|
iosDeploymentTarget = null,
|
|
379
|
-
hasPrivacyManifest = false
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
:
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
targets: [
|
|
409
|
-
.target(
|
|
410
|
-
name: "${product}",
|
|
411
|
-
dependencies: [${targetDepsSwift}],
|
|
412
|
-
path: "root/${srcRel}",${excludeSwift}${resourcesSwift}${renderTargetSettings(frameworkSearchPath, [], product)}
|
|
413
|
-
),
|
|
414
|
-
],
|
|
415
|
-
swiftLanguageModes: [.v5],
|
|
416
|
-
cxxLanguageStandard: .cxx20
|
|
417
|
-
)
|
|
418
|
-
`;
|
|
646
|
+
hasPrivacyManifest = false,
|
|
647
|
+
packages = [],
|
|
648
|
+
}) {
|
|
649
|
+
const target = {
|
|
650
|
+
name: product,
|
|
651
|
+
path: srcRel,
|
|
652
|
+
publicHeadersPath: null,
|
|
653
|
+
// SwiftPM resolves exclude paths against the target path, not the package root.
|
|
654
|
+
exclude: excludes,
|
|
655
|
+
sources: [],
|
|
656
|
+
// `.copy`, not `.process`: Apple reads a privacy manifest by its exact name, and
|
|
657
|
+
// .process may rename or transform what it puts in the bundle.
|
|
658
|
+
resources: hasPrivacyManifest ? [{ path: PRIVACY_MANIFEST, rule: { copy: {} } }] : [],
|
|
659
|
+
settings: [],
|
|
660
|
+
dependencies: packages.map((pkg) => ({
|
|
661
|
+
product: pkg.productName,
|
|
662
|
+
package: pkg.identity,
|
|
663
|
+
platforms: [],
|
|
664
|
+
})),
|
|
665
|
+
};
|
|
666
|
+
return {
|
|
667
|
+
name: product,
|
|
668
|
+
pureSwift: true,
|
|
669
|
+
iosDeploymentTarget,
|
|
670
|
+
products: [{ name: product, targets: [product] }],
|
|
671
|
+
targets: [target],
|
|
672
|
+
packageDeps: packages,
|
|
673
|
+
spmProductNames: packages.map((pkg) => pkg.productName),
|
|
674
|
+
};
|
|
419
675
|
}
|
|
420
676
|
|
|
421
677
|
function escapeSwiftString(value) {
|
|
@@ -426,23 +682,26 @@ function escapeSwiftString(value) {
|
|
|
426
682
|
* A target's `*Settings:` arguments: Expo's binary-free interface tree first, then
|
|
427
683
|
* whatever the module itself declared, in its own order.
|
|
428
684
|
*/
|
|
429
|
-
function renderTargetSettings(frameworkSearchPath, settings, targetName) {
|
|
430
|
-
const
|
|
685
|
+
function renderTargetSettings(frameworkSearchPath, settings, targetName, extraSwiftFlags = []) {
|
|
686
|
+
const unsafeFlags = (flags) =>
|
|
687
|
+
`.unsafeFlags([${flags.map((f) => `"${escapeSwiftString(f)}"`).join(', ')}])`;
|
|
688
|
+
const interfaceFlags = unsafeFlags(['-F', frameworkSearchPath]);
|
|
689
|
+
// `-Xfrontend` is a Swift driver flag; clang rejects it, so it stays out of c/cxxSettings.
|
|
690
|
+
const swiftInterfaceFlags = unsafeFlags(['-F', frameworkSearchPath, ...extraSwiftFlags]);
|
|
431
691
|
for (const setting of settings ?? []) {
|
|
432
692
|
if (!SETTING_TOOLS.has(setting.tool)) {
|
|
433
|
-
throw
|
|
434
|
-
`Cannot generate a consumption Package.swift for target "${targetName}": build setting tool
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
'expo/scripts/spm/manifests.js.'
|
|
438
|
-
);
|
|
693
|
+
throw pluginError({
|
|
694
|
+
what: `Cannot generate a consumption Package.swift for target "${targetName}": build setting tool "${setting.tool}" has no arguments to be rendered into.`,
|
|
695
|
+
why: 'This plugin renders the c, cxx, swift and linker tools; a newer Swift Package Manager tool needs a family added in expo/scripts/spm/manifests.js.',
|
|
696
|
+
});
|
|
439
697
|
}
|
|
440
698
|
}
|
|
441
699
|
return SETTING_FAMILIES.map(([tool, label]) => {
|
|
442
700
|
const own = (settings ?? [])
|
|
443
701
|
.filter((s) => s.tool === tool)
|
|
444
702
|
.map((s) => renderSetting(s, targetName));
|
|
445
|
-
const
|
|
703
|
+
const injected = tool === 'swift' ? swiftInterfaceFlags : interfaceFlags;
|
|
704
|
+
const values = tool === 'linker' ? own : [injected, ...own];
|
|
446
705
|
return values.length ? `\n ${label}: [${values.join(', ')}],` : '';
|
|
447
706
|
}).join('');
|
|
448
707
|
}
|
|
@@ -452,6 +711,26 @@ function renderPlatforms(iosDeploymentTarget) {
|
|
|
452
711
|
return iosDeploymentTarget != null ? `[.iOS("${iosDeploymentTarget}")]` : '[.iOS(.v15)]';
|
|
453
712
|
}
|
|
454
713
|
|
|
714
|
+
/**
|
|
715
|
+
* The higher of two iOS floors, or null when neither side declares one.
|
|
716
|
+
*
|
|
717
|
+
* CocoaPods raises every Expo pod to ExpoModulesCore's deployment target after
|
|
718
|
+
* install (`reconcile_expo_module_deployment_targets`). Under SwiftPM the
|
|
719
|
+
* generated manifest is the only place to do that, because importing a module
|
|
720
|
+
* built for a higher floor than the importer is a compile error.
|
|
721
|
+
*/
|
|
722
|
+
function raiseFloor(declared, minimum) {
|
|
723
|
+
if (declared == null) return minimum ?? null;
|
|
724
|
+
if (minimum == null) return declared;
|
|
725
|
+
const components = (version) => version.split('.').map(Number);
|
|
726
|
+
const [left, right] = [components(declared), components(minimum)];
|
|
727
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
728
|
+
const delta = (left[i] ?? 0) - (right[i] ?? 0);
|
|
729
|
+
if (delta !== 0) return delta > 0 ? declared : minimum;
|
|
730
|
+
}
|
|
731
|
+
return declared;
|
|
732
|
+
}
|
|
733
|
+
|
|
455
734
|
// ---------------------------------------------------------------------------
|
|
456
735
|
// I/O: emit a package dir (write manifest + `root` symlink) and return deps
|
|
457
736
|
// ---------------------------------------------------------------------------
|
|
@@ -508,13 +787,117 @@ function resolveTargetPaths(targets, moduleRoot) {
|
|
|
508
787
|
return { targets: resolved, unresolvedTargets };
|
|
509
788
|
}
|
|
510
789
|
|
|
511
|
-
/**
|
|
512
|
-
|
|
790
|
+
/**
|
|
791
|
+
* A precompiled framework already links these products; declaring them again would
|
|
792
|
+
* link a second copy. `spmProductNames` still names them, as the module links them
|
|
793
|
+
* all the same. SwiftPM can still build a provided product through a package kept for
|
|
794
|
+
* its other products, so `partlyProvidedPackages` returns each such package and, once,
|
|
795
|
+
* every package kept while the module named a provided product without a package.
|
|
796
|
+
*/
|
|
797
|
+
function withoutSatisfiedProducts(manifest, satisfiedDependencies) {
|
|
798
|
+
const targetNames = new Set(manifest.targets.map((t) => t.name));
|
|
799
|
+
// A byName that names no sibling target resolves to a product of a declared package.
|
|
800
|
+
const bareProductName = (dep) => {
|
|
801
|
+
const name = typeof dep === 'string' ? dep : dep.byName;
|
|
802
|
+
return name != null && !targetNames.has(name) ? name : null;
|
|
803
|
+
};
|
|
804
|
+
const isSatisfied = (dep) => satisfiedDependencies.has(dep.product ?? bareProductName(dep));
|
|
805
|
+
const skipped = manifest.targets.flatMap((t) => t.dependencies).filter(isSatisfied);
|
|
806
|
+
if (skipped.length === 0) return { manifest, partlyProvidedPackages: [] };
|
|
807
|
+
const targets = manifest.targets.map((t) => ({
|
|
808
|
+
...t,
|
|
809
|
+
dependencies: t.dependencies.filter((dep) => !isSatisfied(dep)),
|
|
810
|
+
}));
|
|
811
|
+
const remaining = targets.flatMap((t) => t.dependencies);
|
|
812
|
+
const unique = (names) => [...new Set(names)];
|
|
813
|
+
const productsFrom = (deps, key) =>
|
|
814
|
+
unique(
|
|
815
|
+
deps
|
|
816
|
+
.filter((dep) => dep.product != null && dep.package.toLowerCase() === key)
|
|
817
|
+
.map((dep) => dep.product)
|
|
818
|
+
);
|
|
819
|
+
const bareNamesIn = (deps) => unique(deps.map(bareProductName).filter((name) => name != null));
|
|
820
|
+
// Which package a bare name comes from is unknown: a skipped one may have been any
|
|
821
|
+
// package's last use, and a remaining one may still use any of them.
|
|
822
|
+
const skippedBareNames = bareNamesIn(skipped);
|
|
823
|
+
const remainingBareNames = bareNamesIn(remaining);
|
|
824
|
+
const packageDeps = [];
|
|
825
|
+
const partlyProvidedPackages = [];
|
|
826
|
+
for (const pkg of manifest.packageDeps) {
|
|
827
|
+
const key = pkg.identity?.toLowerCase();
|
|
828
|
+
const providedProducts = key != null ? productsFrom(skipped, key) : [];
|
|
829
|
+
const lost = key != null && (providedProducts.length > 0 || skippedBareNames.length > 0);
|
|
830
|
+
const keptProducts = productsFrom(remaining, key);
|
|
831
|
+
if (lost && !keptProducts.length && !remainingBareNames.length) continue;
|
|
832
|
+
packageDeps.push(pkg);
|
|
833
|
+
if (providedProducts.length) {
|
|
834
|
+
partlyProvidedPackages.push({
|
|
835
|
+
url: pkg.url,
|
|
836
|
+
providedProducts,
|
|
837
|
+
keptProducts,
|
|
838
|
+
...(remainingBareNames.length > 0 ? { unattributedNames: remainingBareNames } : {}),
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (skippedBareNames.length && packageDeps.length) {
|
|
843
|
+
partlyProvidedPackages.push({
|
|
844
|
+
providedProducts: skippedBareNames,
|
|
845
|
+
keptPackages: packageDeps.map((pkg) => pkg.url),
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return { manifest: { ...manifest, targets, packageDeps }, partlyProvidedPackages };
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Render `manifest` against Expo's binary-free framework interface tree, with RN's
|
|
853
|
+
* invariant React products injected and its floor raised to the minimum, and write it
|
|
854
|
+
* to `<outDir>/expo-source/<name>` beside a `root` symlink to the real module source,
|
|
855
|
+
* so target `path:`s resolve to real files. Returns what React Native links from it.
|
|
856
|
+
*/
|
|
857
|
+
function emitPackage(
|
|
858
|
+
manifest,
|
|
859
|
+
moduleRoot,
|
|
860
|
+
{
|
|
861
|
+
react = null,
|
|
862
|
+
frameworkSearchPath,
|
|
863
|
+
outDir,
|
|
864
|
+
codegenPkgPath = null,
|
|
865
|
+
minimumIosDeploymentTarget = null,
|
|
866
|
+
macroFlags = [],
|
|
867
|
+
satisfiedDependencies = new Set(),
|
|
868
|
+
}
|
|
869
|
+
) {
|
|
870
|
+
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
871
|
+
const { manifest: linked, partlyProvidedPackages } = withoutSatisfiedProducts(
|
|
872
|
+
manifest,
|
|
873
|
+
satisfiedDependencies
|
|
874
|
+
);
|
|
875
|
+
const manifestSwift = renderSourceManifest({
|
|
876
|
+
manifest: {
|
|
877
|
+
...linked,
|
|
878
|
+
iosDeploymentTarget: raiseFloor(manifest.iosDeploymentTarget, minimumIosDeploymentTarget),
|
|
879
|
+
},
|
|
880
|
+
pkgDeps,
|
|
881
|
+
injectedTargetDeps: targetDeps,
|
|
882
|
+
frameworkSearchPath,
|
|
883
|
+
extraSwiftFlags: macroFlags,
|
|
884
|
+
});
|
|
885
|
+
const pkgDir = path.join(outDir, 'expo-source', manifest.name);
|
|
886
|
+
fs.mkdirSync(pkgDir, { recursive: true });
|
|
513
887
|
const rootLink = path.join(pkgDir, 'root');
|
|
514
888
|
try {
|
|
515
889
|
fs.rmSync(rootLink, { recursive: true, force: true });
|
|
516
890
|
} catch {}
|
|
517
891
|
fs.symlinkSync(moduleRoot, rootLink);
|
|
892
|
+
fs.writeFileSync(path.join(pkgDir, 'Package.swift'), manifestSwift);
|
|
893
|
+
return {
|
|
894
|
+
ok: {
|
|
895
|
+
packageDep: { name: manifest.name, path: pkgDir },
|
|
896
|
+
productDeps: manifest.products.map((p) => ({ name: p.name, package: manifest.name })),
|
|
897
|
+
spmProductNames: manifest.spmProductNames,
|
|
898
|
+
partlyProvidedPackages,
|
|
899
|
+
},
|
|
900
|
+
};
|
|
518
901
|
}
|
|
519
902
|
|
|
520
903
|
/**
|
|
@@ -523,97 +906,83 @@ function linkRoot(pkgDir, moduleRoot) {
|
|
|
523
906
|
* ExpoModulesCore loads its Clang module map, which declares `use React`.
|
|
524
907
|
*/
|
|
525
908
|
function sourceDependencies(react, codegenPkgPath) {
|
|
526
|
-
|
|
909
|
+
if (react == null) return { targetDeps: [], pkgDeps: [] };
|
|
527
910
|
return {
|
|
528
|
-
targetDeps:
|
|
529
|
-
pkgDeps:
|
|
911
|
+
targetDeps: reactProductDependencies(react),
|
|
912
|
+
pkgDeps: reactPackageDeclarations(react, codegenPkgPath),
|
|
530
913
|
};
|
|
531
914
|
}
|
|
532
915
|
|
|
533
916
|
/**
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* compilation at Expo's binary-free framework interface tree. RN owns the merge;
|
|
538
|
-
* the checked-in manifest stays for standalone dev/describe.
|
|
917
|
+
* Emit a CONSUMPTION Package.swift for a source module that ships a checked-in
|
|
918
|
+
* Package.swift, re-declaring its library targets. RN owns the merge; the checked-in
|
|
919
|
+
* manifest stays for standalone dev/describe.
|
|
539
920
|
*
|
|
540
|
-
* Returns `{
|
|
541
|
-
*
|
|
542
|
-
* sources cannot be located — the module is then skipped and
|
|
543
|
-
* emitted broken.
|
|
921
|
+
* Returns `{ ok }` with the emitted package, or `{ refusal }` when the manifest
|
|
922
|
+
* depends on a target or declares a Swift package the generated package cannot
|
|
923
|
+
* declare, or a target's sources cannot be located — the module is then skipped and
|
|
924
|
+
* diagnosed rather than emitted broken.
|
|
544
925
|
*/
|
|
545
|
-
function emitSourceManifestPackage(moduleRoot,
|
|
546
|
-
const { unsupportedTargetDeps, ...dumped } = parseDumpedManifest(
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (unresolvedTargets.length) return { unresolvedTargets };
|
|
550
|
-
const manifest = { ...dumped, targets };
|
|
551
|
-
const pkgDir = path.join(outDir, 'expo-source', manifest.name);
|
|
552
|
-
fs.mkdirSync(pkgDir, { recursive: true });
|
|
553
|
-
linkRoot(pkgDir, moduleRoot);
|
|
554
|
-
|
|
555
|
-
const { targetDeps, pkgDeps } = sourceDependencies(react, codegenPkgPath);
|
|
556
|
-
fs.writeFileSync(
|
|
557
|
-
path.join(pkgDir, 'Package.swift'),
|
|
558
|
-
renderSourceManifest(manifest, pkgDeps, targetDeps, frameworkSearchPath)
|
|
926
|
+
function emitSourceManifestPackage(moduleRoot, emitContext) {
|
|
927
|
+
const { unsupportedTargetDeps, unsupportedPackageDeps, ...dumped } = parseDumpedManifest(
|
|
928
|
+
runDumpPackage(moduleRoot),
|
|
929
|
+
injectedPackageNames(emitContext.react)
|
|
559
930
|
);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
931
|
+
if (unsupportedTargetDeps.length) {
|
|
932
|
+
return {
|
|
933
|
+
refusal: { reason: 'unsupported-target-dependency', dependencies: unsupportedTargetDeps },
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
if (unsupportedPackageDeps.length) {
|
|
937
|
+
return {
|
|
938
|
+
refusal: { reason: 'unsupported-package-dependency', dependencies: unsupportedPackageDeps },
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
const { targets, unresolvedTargets } = resolveTargetPaths(dumped.targets, moduleRoot);
|
|
942
|
+
if (unresolvedTargets.length) {
|
|
943
|
+
return { refusal: { reason: 'unresolvable-target-path', targetNames: unresolvedTargets } };
|
|
944
|
+
}
|
|
945
|
+
return emitPackage({ ...dumped, targets }, moduleRoot, emitContext);
|
|
565
946
|
}
|
|
566
947
|
|
|
567
948
|
/**
|
|
568
|
-
* Emit a source consumption package for a module WITHOUT a checked-in
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
949
|
+
* Emit a source consumption package for a pure-Swift module WITHOUT a checked-in
|
|
950
|
+
* Package.swift: `pureSwiftManifest` over the module's `ios` or `apple` sources.
|
|
951
|
+
*
|
|
952
|
+
* Returns `{ ok }` with the emitted package. The module must have Apple sources;
|
|
953
|
+
* `plugin.js#emitSourceModule` checks that first.
|
|
572
954
|
*/
|
|
573
955
|
function emitPureSwiftSourcePackage(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
956
|
+
{
|
|
957
|
+
moduleRoot,
|
|
958
|
+
product,
|
|
959
|
+
iosDeploymentTarget = null,
|
|
960
|
+
spmPackages = [],
|
|
961
|
+
sources = scanAppleSources(moduleRoot),
|
|
962
|
+
},
|
|
963
|
+
emitContext
|
|
581
964
|
) {
|
|
582
|
-
const srcDir =
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
fs.writeFileSync(
|
|
593
|
-
path.join(pkgDir, 'Package.swift'),
|
|
594
|
-
renderPureSwiftManifest(
|
|
595
|
-
product,
|
|
596
|
-
srcRel,
|
|
597
|
-
pkgDeps,
|
|
598
|
-
targetDeps,
|
|
599
|
-
frameworkSearchPath,
|
|
600
|
-
collectIgnoredDirs(srcDir),
|
|
601
|
-
iosDeploymentTarget,
|
|
602
|
-
fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST))
|
|
603
|
-
)
|
|
604
|
-
);
|
|
605
|
-
|
|
606
|
-
return {
|
|
607
|
-
packageDep: { name: product, path: pkgDir },
|
|
608
|
-
productDep: { name: product, package: product },
|
|
609
|
-
};
|
|
965
|
+
const srcDir = appleSourceDir(moduleRoot);
|
|
966
|
+
const manifest = pureSwiftManifest({
|
|
967
|
+
product,
|
|
968
|
+
srcRel: path.relative(moduleRoot, srcDir),
|
|
969
|
+
excludes: sources.ignoredDirs,
|
|
970
|
+
iosDeploymentTarget,
|
|
971
|
+
hasPrivacyManifest: fs.existsSync(path.join(srcDir, PRIVACY_MANIFEST)),
|
|
972
|
+
packages: spmPackages.map(documentedPackage),
|
|
973
|
+
});
|
|
974
|
+
return emitPackage(manifest, moduleRoot, emitContext);
|
|
610
975
|
}
|
|
611
976
|
|
|
612
977
|
module.exports = {
|
|
613
978
|
parseDumpedManifest,
|
|
614
979
|
resolveTargetPaths,
|
|
615
980
|
renderSourceManifest,
|
|
616
|
-
|
|
981
|
+
pureSwiftManifest,
|
|
982
|
+
spmPackageIdentity,
|
|
983
|
+
documentedPackage,
|
|
984
|
+
packageDeclaration,
|
|
985
|
+
raiseFloor,
|
|
617
986
|
emitSourceManifestPackage,
|
|
618
987
|
emitPureSwiftSourcePackage,
|
|
619
988
|
};
|