expo 58.0.17 → 58.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/expo/modules/ExpoModulesPackage.kt +1 -1
  3. package/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt +1 -1
  4. package/build/winter/fetch/RequestUtils.d.ts +1 -0
  5. package/build/winter/fetch/RequestUtils.js +4 -2
  6. package/build/winter/fetch/RequestUtils.js.map +1 -1
  7. package/build/winter/fetch/fetch.js +4 -2
  8. package/build/winter/fetch/fetch.js.map +1 -1
  9. package/bundledNativeModules.json +19 -19
  10. package/package.json +12 -12
  11. package/scripts/spm/README.md +43 -3
  12. package/scripts/spm/__tests__/cli.test.js +17 -2
  13. package/scripts/spm/__tests__/commands.test.js +61 -0
  14. package/scripts/spm/__tests__/diagnostics.test.js +210 -9
  15. package/scripts/spm/__tests__/direct.test.js +387 -0
  16. package/scripts/spm/__tests__/flavored-frameworks.test.js +127 -0
  17. package/scripts/spm/__tests__/helpers.js +9 -0
  18. package/scripts/spm/__tests__/manifests.test.js +38 -50
  19. package/scripts/spm/__tests__/plugin.test.js +1238 -53
  20. package/scripts/spm/__tests__/precompiled-sources.test.js +139 -0
  21. package/scripts/spm/classify.js +8 -6
  22. package/scripts/spm/cli.js +11 -4
  23. package/scripts/spm/commands.js +18 -1
  24. package/scripts/spm/diagnostics.js +112 -8
  25. package/scripts/spm/direct.js +215 -0
  26. package/scripts/spm/flavored-frameworks.js +125 -40
  27. package/scripts/spm/manifests.js +4 -3
  28. package/scripts/spm/plugin.js +432 -82
  29. package/src/winter/fetch/RequestUtils.ts +8 -4
  30. package/src/winter/fetch/__tests__/fetch-test.native.ts +56 -0
  31. package/src/winter/fetch/fetch.ts +8 -2
  32. package/template.tgz +0 -0
@@ -48,9 +48,11 @@ function isBlob(obj: any): obj is Blob {
48
48
  /**
49
49
  * Normalize a BodyInit object to a Uint8Array for NativeRequest
50
50
  */
51
- export async function normalizeBodyInitAsync(
52
- body: BodyInit | null | undefined
53
- ): Promise<{ body: Uint8Array | null; overriddenHeaders?: NativeHeadersType }> {
51
+ export async function normalizeBodyInitAsync(body: BodyInit | null | undefined): Promise<{
52
+ body: Uint8Array | null;
53
+ defaultHeaders?: NativeHeadersType;
54
+ overriddenHeaders?: NativeHeadersType;
55
+ }> {
54
56
  if (body == null) {
55
57
  return { body: null };
56
58
  }
@@ -69,9 +71,11 @@ export async function normalizeBodyInitAsync(
69
71
  }
70
72
 
71
73
  if (body instanceof Blob || isBlob(body)) {
74
+ // An empty type still sets the header.
75
+ // On iOS, URLSession sends `application/x-www-form-urlencoded` for a POST body without a Content-Type.
72
76
  return {
73
77
  body: new Uint8Array(await blobToArrayBufferAsync(body)),
74
- overriddenHeaders: [['Content-Type', body.type]],
78
+ defaultHeaders: [['Content-Type', body.type ?? '']],
75
79
  };
76
80
  }
77
81
 
@@ -0,0 +1,56 @@
1
+ /// <reference types="node" />
2
+
3
+ import { fetch } from '../fetch';
4
+
5
+ globalThis.ReadableStream = require('node:stream/web').ReadableStream;
6
+ globalThis.TextEncoder = require('node:util').TextEncoder;
7
+
8
+ const mockStart = jest.fn(async () => {});
9
+
10
+ jest.mock('../ExpoFetchModule', () => {
11
+ class StubNativeResponse {
12
+ addListener() {}
13
+ removeListener() {}
14
+ }
15
+ class StubNativeRequest {
16
+ start = mockStart;
17
+ cancel() {}
18
+ }
19
+ return {
20
+ ExpoFetchModule: {
21
+ NativeRequest: StubNativeRequest,
22
+ NativeResponse: StubNativeResponse,
23
+ },
24
+ };
25
+ });
26
+
27
+ function getStartedHeaders(): [string, string][] {
28
+ return (mockStart.mock.calls[0] as any[])[1].headers;
29
+ }
30
+
31
+ describe('Setting the Content-Type header from the body', () => {
32
+ beforeEach(() => {
33
+ mockStart.mockClear();
34
+ });
35
+
36
+ it('should keep the caller content-type header for a blob body', async () => {
37
+ await fetch('https://example.test/', {
38
+ method: 'POST',
39
+ headers: { Accept: '*/*', 'content-type': 'application/octet-stream' },
40
+ body: new Blob(['hello'], { type: 'text/plain' }),
41
+ });
42
+ expect(getStartedHeaders()).toEqual([
43
+ ['Accept', '*/*'],
44
+ ['content-type', 'application/octet-stream'],
45
+ ]);
46
+ });
47
+
48
+ it('should keep the caller content-type header for a blob body without a type', async () => {
49
+ await fetch('https://example.test/', {
50
+ method: 'POST',
51
+ headers: { 'Content-Type': 'image/jpeg' },
52
+ body: new Blob(['hello']),
53
+ });
54
+ expect(getStartedHeaders()).toEqual([['Content-Type', 'image/jpeg']]);
55
+ });
56
+ });
@@ -62,8 +62,14 @@ export async function fetch(
62
62
 
63
63
  const request = new ExpoFetchModule.NativeRequest(response) as NativeRequest;
64
64
 
65
- const { body: requestBody, overriddenHeaders } = await normalizeBodyInitAsync(body);
66
- if (overriddenHeaders) {
65
+ const {
66
+ body: requestBody,
67
+ defaultHeaders,
68
+ overriddenHeaders,
69
+ } = await normalizeBodyInitAsync(body);
70
+ if (defaultHeaders) {
71
+ headers = overrideHeaders(defaultHeaders, headers);
72
+ } else if (overriddenHeaders) {
67
73
  headers = overrideHeaders(headers, overriddenHeaders);
68
74
  }
69
75
 
package/template.tgz CHANGED
Binary file