expo 58.0.25 → 58.1.0
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/src/main/java/expo/modules/fetch/ExpoFetchModule.kt +14 -2
- package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +15 -0
- package/android/src/test/java/expo/modules/fetch/NativeResponseTest.kt +256 -0
- package/build/async-require/asyncRequireModule.js +0 -2
- package/build/async-require/asyncRequireModule.js.map +1 -1
- package/build/winter/fetch/FetchResponse.d.ts +1 -0
- package/build/winter/fetch/FetchResponse.js +9 -8
- package/build/winter/fetch/FetchResponse.js.map +1 -1
- package/bundledNativeModules.json +26 -26
- package/ios/Expo/Fetch/ExpoFetchModule.swift +2 -2
- package/ios/Expo/Fetch/NativeResponse.swift +7 -1
- package/ios/ExpoObjC/AppDelegates/EXBundleConfiguration.mm +3 -0
- package/ios/Tests/NativeResponseTests.swift +171 -0
- package/package.json +11 -11
- package/scripts/spm/README.md +11 -9
- package/scripts/spm/__tests__/direct.test.js +117 -12
- package/scripts/spm/__tests__/plugin.test.js +179 -8
- package/scripts/spm/__tests__/real-manifests.test.js +3 -3
- package/scripts/spm/direct.js +132 -81
- package/scripts/spm/plugin.js +64 -31
- package/src/async-require/asyncRequireModule.ts +0 -2
- package/src/winter/fetch/FetchResponse.ts +10 -8
- package/src/winter/fetch/__tests__/FetchResponse-test.ts +19 -4
- package/template.tgz +0 -0
package/scripts/spm/plugin.js
CHANGED
|
@@ -90,7 +90,12 @@ const {
|
|
|
90
90
|
resolveHeadersXCFrameworkWithSource,
|
|
91
91
|
resolveSpmDependencyFrameworks,
|
|
92
92
|
} = require('./flavored-frameworks');
|
|
93
|
-
const {
|
|
93
|
+
const {
|
|
94
|
+
HEADERS_STAND_INS,
|
|
95
|
+
dumpModuleManifest,
|
|
96
|
+
emitDirectPackage,
|
|
97
|
+
headersStandInsOf,
|
|
98
|
+
} = require('./direct');
|
|
94
99
|
const {
|
|
95
100
|
emitExpoModulesJSIHeadersPackage,
|
|
96
101
|
emitPureSwiftSourcePackage,
|
|
@@ -488,10 +493,11 @@ const describeSource = (source) => `${SOURCE_LABELS[source.kind]} (${source.dir}
|
|
|
488
493
|
* each of them. Returns the `pluginError` parts describing the mix, or null when there is
|
|
489
494
|
* none.
|
|
490
495
|
*
|
|
496
|
+
* @param referenceSource where the `referenceName` binary the subjects must match comes from.
|
|
491
497
|
* @param subjects `{ label, packageName, source }` for each precompiled artifact to check.
|
|
492
498
|
*/
|
|
493
|
-
function mixedSourcesReport(
|
|
494
|
-
const mixed = subjects.filter((subject) => subject.source?.kind !==
|
|
499
|
+
function mixedSourcesReport(referenceSource, subjects, referenceName = 'ExpoModulesCore') {
|
|
500
|
+
const mixed = subjects.filter((subject) => subject.source?.kind !== referenceSource?.kind);
|
|
495
501
|
if (mixed.length === 0) return null;
|
|
496
502
|
const packages = [...new Set(mixed.map((subject) => subject.packageName))].join(' ');
|
|
497
503
|
return {
|
|
@@ -500,36 +506,48 @@ function mixedSourcesReport(coreSource, subjects) {
|
|
|
500
506
|
(subject) =>
|
|
501
507
|
`${subject.label} (${subject.packageName}) comes from ${describeSource(subject.source)}`
|
|
502
508
|
)
|
|
503
|
-
.join('; ')}, but
|
|
504
|
-
why:
|
|
505
|
-
how: `Take every precompiled module from one place: unset EXPO_PRECOMPILED_MODULES_PATH if it is set; from the Expo repository root, build the packages into the same place as
|
|
509
|
+
.join('; ')}, but ${referenceName} comes from ${describeSource(referenceSource)}.`,
|
|
510
|
+
why: `Precompiled Expo modules, and the headers Expo modules compile against, are bound to the exact ${referenceName} build they were made with, so mixing builds from different places can crash the app at launch on a missing symbol.`,
|
|
511
|
+
how: `Take every precompiled module from one place: unset EXPO_PRECOMPILED_MODULES_PATH if it is set; from the Expo repository root, build the packages into the same place as ${referenceName} with \`node tools/bin/expotools.js prebuild ${packages}\`; otherwise reinstall your JavaScript dependencies so every package uses the build it ships. ${rerunSpmUpdate()}`,
|
|
506
512
|
};
|
|
507
513
|
}
|
|
508
514
|
|
|
509
515
|
/**
|
|
510
|
-
* The
|
|
511
|
-
* come from the same kind of place as the
|
|
516
|
+
* The headers xcframework of `productName`, for direct modules to compile against. It must
|
|
517
|
+
* come from the same kind of place as the precompiled `productName` binary.
|
|
518
|
+
*
|
|
519
|
+
* @param precompiled the records of the pods linked precompiled.
|
|
512
520
|
*/
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
|
|
521
|
+
function resolveHeadersStandIn({ packageName, productName }, precompiled, cacheDir) {
|
|
522
|
+
const binary = precompiled.find(
|
|
523
|
+
({ identity }) => identity.packageName === packageName && identity.productName === productName
|
|
524
|
+
);
|
|
525
|
+
if (binary == null) {
|
|
526
|
+
throw pluginError({
|
|
527
|
+
what: `Expo modules built from their own Package.swift compile against ${productName}Headers.xcframework, but no precompiled ${productName} (${packageName}) is linked to check those headers against.`,
|
|
528
|
+
why: `The headers must come from the same build as the ${productName} binary. Either a buildFromSource entry names ${productName} or ${packageName} exactly, or ${packageName} has no precompiled ${productName}.`,
|
|
529
|
+
how: `Remove the buildFromSource entry that names ${productName} or ${packageName}. Otherwise, from the Expo repository root, run \`node tools/bin/expotools.js prebuild ${packageName}\`. ${rerunSpmUpdate()}`,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
const lookup = { packageName, moduleRoot: binary.identity.moduleRoot, productName };
|
|
533
|
+
const binarySource = frameworkSource(binary.framework);
|
|
516
534
|
const lookupRank = (source) => PRECOMPILED_SOURCE_KINDS.indexOf(source.kind);
|
|
517
|
-
const builtLocally =
|
|
518
|
-
// Headers past the place a local
|
|
535
|
+
const builtLocally = binarySource?.kind === 'env' || binarySource?.kind === 'monorepo';
|
|
536
|
+
// Headers past the place a local build of the binary comes from cannot match it, so the
|
|
519
537
|
// lookup ends there: a broken copy further on would fail first, with advice that cannot
|
|
520
538
|
// fix the missing headers. No headers up to that place mean the build produced none.
|
|
521
539
|
const headers = resolveHeadersXCFrameworkWithSource({
|
|
522
540
|
...lookup,
|
|
523
541
|
cacheDir,
|
|
524
|
-
lastKind: builtLocally ?
|
|
542
|
+
lastKind: builtLocally ? binarySource.kind : undefined,
|
|
525
543
|
});
|
|
526
|
-
if (builtLocally && (headers == null || lookupRank(headers.source) > lookupRank(
|
|
544
|
+
if (builtLocally && (headers == null || lookupRank(headers.source) > lookupRank(binarySource))) {
|
|
527
545
|
const prebuild = '`node tools/bin/expotools.js prebuild expo-modules-core expo-modules-jsi`';
|
|
528
546
|
throw pluginError({
|
|
529
|
-
what: `${productName}Headers.xcframework is missing under ${
|
|
547
|
+
what: `${productName}Headers.xcframework is missing under ${binarySource.dir}, where ${productName} comes from (${SOURCE_LABELS[binarySource.kind]}).`,
|
|
530
548
|
why: `Expo modules built from their own Package.swift compile against these headers, and the headers must come from the same build as ${productName}. That build did not produce them.`,
|
|
531
549
|
how:
|
|
532
|
-
|
|
550
|
+
binarySource.kind === 'env'
|
|
533
551
|
? `Unset EXPO_PRECOMPILED_MODULES_PATH, or point it at a directory that holds a complete prebuild of expo-modules-core and expo-modules-jsi, including their headers. ${rerunSpmUpdate()}`
|
|
534
552
|
: `From the Expo repository root, run ${prebuild}. ${rerunSpmUpdate()}`,
|
|
535
553
|
});
|
|
@@ -541,16 +559,18 @@ function resolveCoreHeaders(core, coreSource, cacheDir) {
|
|
|
541
559
|
how: `From the Expo repository root, run \`node tools/bin/expotools.js prebuild ${packageName}\`. Otherwise upgrade ${packageName} to a version that ships a headers xcframework. ${rerunSpmUpdate()}`,
|
|
542
560
|
});
|
|
543
561
|
}
|
|
544
|
-
const mixed = mixedSourcesReport(
|
|
545
|
-
|
|
546
|
-
|
|
562
|
+
const mixed = mixedSourcesReport(
|
|
563
|
+
binarySource,
|
|
564
|
+
[{ label: `${productName}Headers.xcframework`, packageName, source: headers.source }],
|
|
565
|
+
productName
|
|
566
|
+
);
|
|
547
567
|
if (mixed != null) throw pluginError(mixed);
|
|
548
568
|
return headers.xcframework;
|
|
549
569
|
}
|
|
550
570
|
|
|
551
571
|
/**
|
|
552
572
|
* Emits the source package of the module whose first pod is `identity`: its checked-in
|
|
553
|
-
* manifest as it stands when that depends on
|
|
573
|
+
* manifest as it stands when that depends on a headers stand-in (`direct` is then
|
|
554
574
|
* set), else that manifest mirrored, or else one Swift target over its sources. A
|
|
555
575
|
* pure-Swift module is refused when its podspec declares linkage, because the
|
|
556
576
|
* emitted package would link less than the podspec does. Returns null for a module
|
|
@@ -563,14 +583,17 @@ function emitSourceModule(identity, hasManifest, emitContext, dumpManifest) {
|
|
|
563
583
|
identity;
|
|
564
584
|
if (hasManifest) {
|
|
565
585
|
const { json, manifest } = dumpManifest(moduleRoot, packageName);
|
|
566
|
-
|
|
586
|
+
const standIns = headersStandInsOf(manifest);
|
|
587
|
+
if (standIns.length === 0) {
|
|
567
588
|
return emitSourceManifestPackage(moduleRoot, emitContext, json);
|
|
568
589
|
}
|
|
569
590
|
const emission = emitDirectPackage({
|
|
570
591
|
moduleRoot,
|
|
571
592
|
packageName,
|
|
572
593
|
outDir: emitContext.outDir,
|
|
573
|
-
|
|
594
|
+
headersXCFrameworks: Object.fromEntries(
|
|
595
|
+
standIns.map((standIn) => [standIn, emitContext.headersXCFramework(standIn)])
|
|
596
|
+
),
|
|
574
597
|
jsiHeadersPkgPath: emitContext.jsiHeadersPkgPath,
|
|
575
598
|
macrosPackageRoot: emitContext.macrosPackageRoot,
|
|
576
599
|
react: emitContext.react,
|
|
@@ -742,7 +765,7 @@ function linkPasses(
|
|
|
742
765
|
let sourceModules = { emitted: [], refusals: new Map() };
|
|
743
766
|
if (coreAvailable) {
|
|
744
767
|
let resolvedMacroFlags = null;
|
|
745
|
-
|
|
768
|
+
const resolvedHeadersXCFrameworks = new Map();
|
|
746
769
|
sourceModules = linkSourceModules(
|
|
747
770
|
modules,
|
|
748
771
|
identities,
|
|
@@ -760,13 +783,15 @@ function linkPasses(
|
|
|
760
783
|
get macrosPackageRoot() {
|
|
761
784
|
return macrosPackageRoot(core.moduleRoot);
|
|
762
785
|
},
|
|
763
|
-
// Lazy: only a direct module needs
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
786
|
+
// Lazy: only a direct module needs headers, and only then must they exist.
|
|
787
|
+
headersXCFramework(standIn) {
|
|
788
|
+
if (!resolvedHeadersXCFrameworks.has(standIn)) {
|
|
789
|
+
resolvedHeadersXCFrameworks.set(
|
|
790
|
+
standIn,
|
|
791
|
+
resolveHeadersStandIn(HEADERS_STAND_INS[standIn], precompiled, cacheDir)
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
return resolvedHeadersXCFrameworks.get(standIn);
|
|
770
795
|
},
|
|
771
796
|
},
|
|
772
797
|
dumpManifest
|
|
@@ -1059,6 +1084,14 @@ module.exports = function expoSpmPlugin(context) {
|
|
|
1059
1084
|
const fallbackEntries = new Map();
|
|
1060
1085
|
const coreMatch = matchBuildFromSource({ podName: CORE_POD, packageName: CORE_PACKAGE });
|
|
1061
1086
|
if (coreMatch != null) fallbackEntries.set(CORE_POD, coreMatch.entry);
|
|
1087
|
+
// A direct module checks its headers against the binary of their product in the first round,
|
|
1088
|
+
// so a product a pattern matches must be linked precompiled from the start.
|
|
1089
|
+
for (const { packageName, productName } of Object.values(HEADERS_STAND_INS)) {
|
|
1090
|
+
const match = matchBuildFromSource({ podName: productName, packageName });
|
|
1091
|
+
if (match?.exact === false && !fallbackEntries.has(productName)) {
|
|
1092
|
+
fallbackEntries.set(productName, match.entry);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1062
1095
|
const emittedByRound = [];
|
|
1063
1096
|
let passes;
|
|
1064
1097
|
let fallingBack;
|
|
@@ -96,8 +96,6 @@ function asyncRequireImpl<T>(
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// On native, requiring a missing module reports a fatal error via `global.ErrorUtils`
|
|
100
|
-
// instead of throwing, so the split bundle must be loaded before importing
|
|
101
99
|
const maybeLoadBundlePromise = maybeLoadBundle(moduleID, paths);
|
|
102
100
|
if (maybeLoadBundlePromise != null) {
|
|
103
101
|
return maybeLoadBundlePromise.then(importAll);
|
|
@@ -316,14 +316,13 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
316
316
|
|
|
317
317
|
pull: async (controller) => {
|
|
318
318
|
if (body.streamingState === 'none') {
|
|
319
|
+
body.streamingState = 'started';
|
|
319
320
|
const completedData = await this.startStreaming();
|
|
320
321
|
|
|
321
322
|
if (completedData != null) {
|
|
322
323
|
this.enqueueBodyChunk(controller, completedData);
|
|
323
324
|
this.closeBodyStream(controller);
|
|
324
325
|
body.streamingState = 'completed';
|
|
325
|
-
} else {
|
|
326
|
-
body.streamingState = 'started';
|
|
327
326
|
}
|
|
328
327
|
} else if (body.streamingState === 'completed') {
|
|
329
328
|
this.closeBodyStream(controller);
|
|
@@ -334,12 +333,6 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
334
333
|
// Flag first — the stream is already `closed` when this callback
|
|
335
334
|
// runs, so the guard must not go stale if cancelStreaming throws.
|
|
336
335
|
this.bodyStreamClosed = true;
|
|
337
|
-
// text() and arrayBuffer() set this before the native read, and
|
|
338
|
-
// only on an uncloned response. A clone sets the same flag from
|
|
339
|
-
// its stream wrapper, and that cancel still has to reach native.
|
|
340
|
-
if (body.consumed && !body.cloned) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
336
|
body.consumed = true;
|
|
344
337
|
this.cancelStreaming(String(reason));
|
|
345
338
|
},
|
|
@@ -422,6 +415,7 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
422
415
|
return body.readAsBuffer();
|
|
423
416
|
}
|
|
424
417
|
|
|
418
|
+
this.lockBodyStream();
|
|
425
419
|
return super.arrayBuffer();
|
|
426
420
|
}
|
|
427
421
|
|
|
@@ -435,6 +429,7 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
435
429
|
return new TextDecoder().decode(await body.readAsBuffer());
|
|
436
430
|
}
|
|
437
431
|
|
|
432
|
+
this.lockBodyStream();
|
|
438
433
|
return super.text();
|
|
439
434
|
}
|
|
440
435
|
|
|
@@ -499,6 +494,13 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
499
494
|
return clone;
|
|
500
495
|
}
|
|
501
496
|
|
|
497
|
+
// Native reads the body without a reader on the stream. Lock the stream as
|
|
498
|
+
// the Fetch spec does, so body.cancel() and body.getReader() cannot reach
|
|
499
|
+
// native while that read waits.
|
|
500
|
+
private lockBodyStream(): void {
|
|
501
|
+
this.body?.getReader();
|
|
502
|
+
}
|
|
503
|
+
|
|
502
504
|
private checkBodyUsedError(method: string): void {
|
|
503
505
|
const body = this[stateKey].body;
|
|
504
506
|
|
|
@@ -199,7 +199,7 @@ describe('FetchResponse', () => {
|
|
|
199
199
|
// without calling controller.error(), so the bodyStreamClosed guard goes stale.
|
|
200
200
|
// Native events landing after that used to throw on the errored stream.
|
|
201
201
|
|
|
202
|
-
it('
|
|
202
|
+
it('should surface the error and mark the body used after the first read rejects', async () => {
|
|
203
203
|
const response = makeResponse();
|
|
204
204
|
|
|
205
205
|
(response as any).startStreaming = async () => {
|
|
@@ -207,7 +207,12 @@ describe('FetchResponse', () => {
|
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
const reader = response.body!.getReader();
|
|
210
|
+
expect(response.bodyUsed).toBe(false);
|
|
210
211
|
await expect(reader.read()).rejects.toThrow('native module call failed');
|
|
212
|
+
reader.releaseLock();
|
|
213
|
+
|
|
214
|
+
expect(response.bodyUsed).toBe(true);
|
|
215
|
+
expect(() => response.clone()).toThrow(TypeError);
|
|
211
216
|
});
|
|
212
217
|
|
|
213
218
|
it('does not throw on native events that arrive after pull() rejected', async () => {
|
|
@@ -388,13 +393,23 @@ describe('FetchResponse', () => {
|
|
|
388
393
|
await expect(response.text()).rejects.toThrow(TypeError);
|
|
389
394
|
});
|
|
390
395
|
|
|
391
|
-
it('
|
|
396
|
+
it('rejects body.cancel() while text() reads the body', async () => {
|
|
392
397
|
const response = makeResponse();
|
|
393
398
|
const nativeCancel = jest.spyOn(response, 'cancelStreaming');
|
|
394
399
|
const pending = response.text();
|
|
395
|
-
await response.body!.cancel('not needed');
|
|
400
|
+
await expect(response.body!.cancel('not needed')).rejects.toHaveProperty('name', 'TypeError');
|
|
396
401
|
expect(nativeCancel).not.toHaveBeenCalled();
|
|
397
|
-
await pending;
|
|
402
|
+
await expect(pending).resolves.toBe('hello world');
|
|
403
|
+
expect(response.body!.locked).toBe(true);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it('does not start native streaming when body.getReader() runs during arrayBuffer()', async () => {
|
|
407
|
+
const response = makeResponse();
|
|
408
|
+
const nativeStart = jest.spyOn(response, 'startStreaming');
|
|
409
|
+
const pending = response.arrayBuffer();
|
|
410
|
+
expect(() => response.body!.getReader()).toThrow();
|
|
411
|
+
expect(nativeStart).not.toHaveBeenCalled();
|
|
412
|
+
expect((await pending).byteLength).toBe(11);
|
|
398
413
|
});
|
|
399
414
|
|
|
400
415
|
it('calls native cancel when both clone branches are canceled', async () => {
|
package/template.tgz
CHANGED
|
Binary file
|