expo 56.0.15 → 56.0.17
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 +8 -0
- package/android/src/main/java/expo/modules/fetch/FetchExceptions.kt +6 -0
- package/android/src/main/java/expo/modules/fetch/NativeResponse.kt +20 -7
- package/build/utils/getBundleUrl.web.d.ts.map +1 -1
- package/build/winter/fetch/FetchResponse.d.ts +0 -3
- package/build/winter/fetch/FetchResponse.d.ts.map +1 -1
- package/build/winter/fetch/createBlob.d.ts +8 -0
- package/build/winter/fetch/createBlob.d.ts.map +1 -0
- package/bundledNativeModules.json +34 -34
- package/ios/Fetch/ExpoFetchModule.swift +13 -0
- package/ios/Fetch/FetchExceptions.swift +7 -0
- package/package.json +16 -16
- package/src/utils/__tests__/getBundleUrl.test.web.ts +34 -0
- package/src/utils/getBundleUrl.web.ts +8 -6
- package/src/winter/fetch/FetchResponse.ts +16 -4
- package/src/winter/fetch/__tests__/FetchResponse-blob-test.native.ts +88 -0
- package/src/winter/fetch/__tests__/FetchResponse-test.ts +10 -0
- package/src/winter/fetch/createBlob.ts +26 -0
- package/template.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -10,7 +10,7 @@ buildscript {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
group = 'host.exp.exponent'
|
|
13
|
-
version = '56.0.
|
|
13
|
+
version = '56.0.17'
|
|
14
14
|
|
|
15
15
|
expoModule {
|
|
16
16
|
// We can't prebuild the module because it depends on the generated files.
|
|
@@ -21,7 +21,7 @@ android {
|
|
|
21
21
|
namespace "expo.core"
|
|
22
22
|
defaultConfig {
|
|
23
23
|
versionCode 1
|
|
24
|
-
versionName "56.0.
|
|
24
|
+
versionName "56.0.17"
|
|
25
25
|
consumerProguardFiles("proguard-rules.pro")
|
|
26
26
|
}
|
|
27
27
|
testOptions {
|
|
@@ -4,6 +4,7 @@ package expo.modules.fetch
|
|
|
4
4
|
|
|
5
5
|
import android.util.Log
|
|
6
6
|
import com.facebook.react.bridge.ReactContext
|
|
7
|
+
import com.facebook.react.modules.blob.BlobModule
|
|
7
8
|
import com.facebook.react.modules.network.CookieJarContainer
|
|
8
9
|
import com.facebook.react.modules.network.ForwardingCookieHandler
|
|
9
10
|
import com.facebook.react.modules.network.OkHttpClientProvider
|
|
@@ -49,6 +50,13 @@ class ExpoFetchModule : Module() {
|
|
|
49
50
|
cookieJarContainer.setCookieJar(JavaNetCookieJar(cookieHandler))
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
// TODO(kudo,20260706): remove this when we install expo-blob as globalThis.Blob
|
|
54
|
+
AsyncFunction("unstable_createBlobData") { data: ByteArray ->
|
|
55
|
+
val blobModule = reactContext.getNativeModule(BlobModule::class.java)
|
|
56
|
+
?: throw FetchBlobModuleUnavailableException()
|
|
57
|
+
return@AsyncFunction blobModule.store(data)
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
OnDestroy {
|
|
53
61
|
cookieHandler.destroy()
|
|
54
62
|
cookieJarContainer.removeCookieJar()
|
|
@@ -15,3 +15,9 @@ internal class FetchAndroidContextLostException :
|
|
|
15
15
|
|
|
16
16
|
internal class FetchRedirectException :
|
|
17
17
|
CodedException("Redirect is not allowed when redirect mode is 'error'")
|
|
18
|
+
|
|
19
|
+
internal class FetchBlobModuleUnavailableException :
|
|
20
|
+
CodedException(
|
|
21
|
+
"Unable to store the response body as a blob because React Native's BlobModule is not available. " +
|
|
22
|
+
"Make sure your app includes the React Native blob support or read the body with arrayBuffer() instead"
|
|
23
|
+
)
|
|
@@ -8,7 +8,9 @@ import expo.modules.kotlin.AppContext
|
|
|
8
8
|
import expo.modules.kotlin.sharedobjects.SharedObject
|
|
9
9
|
import kotlinx.coroutines.CoroutineScope
|
|
10
10
|
import kotlinx.coroutines.Dispatchers
|
|
11
|
+
import kotlinx.coroutines.NonCancellable
|
|
11
12
|
import kotlinx.coroutines.launch
|
|
13
|
+
import kotlinx.coroutines.withContext
|
|
12
14
|
import okhttp3.Call
|
|
13
15
|
import okhttp3.Callback
|
|
14
16
|
import okhttp3.Response
|
|
@@ -138,10 +140,17 @@ internal class NativeResponse(appContext: AppContext, private val coroutineScope
|
|
|
138
140
|
responseInit = createResponseInit(response)
|
|
139
141
|
state = ResponseState.RESPONSE_RECEIVED
|
|
140
142
|
|
|
141
|
-
coroutineScope.launch
|
|
143
|
+
coroutineScope.launch {
|
|
142
144
|
val stream = response.body?.source() ?: return@launch
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
try {
|
|
146
|
+
pumpResponseBodyStream(stream)
|
|
147
|
+
} finally {
|
|
148
|
+
// Close off the modules queue so the blocking call doesn't stall it.
|
|
149
|
+
// NonCancellable guarantees the response is released even if the scope is canceled mid-stream.
|
|
150
|
+
withContext(NonCancellable + Dispatchers.IO) {
|
|
151
|
+
response.close()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
145
154
|
|
|
146
155
|
if (this@NativeResponse.state == ResponseState.BODY_STREAMING_STARTED) {
|
|
147
156
|
emit("didComplete")
|
|
@@ -182,9 +191,13 @@ internal class NativeResponse(appContext: AppContext, private val coroutineScope
|
|
|
182
191
|
)
|
|
183
192
|
}
|
|
184
193
|
|
|
185
|
-
private fun pumpResponseBodyStream(stream: BufferedSource) {
|
|
194
|
+
private suspend fun pumpResponseBodyStream(stream: BufferedSource) {
|
|
186
195
|
try {
|
|
187
|
-
while (
|
|
196
|
+
while (true) {
|
|
197
|
+
val data = withContext(Dispatchers.IO) {
|
|
198
|
+
if (stream.exhausted()) null else stream.buffer.readByteArray()
|
|
199
|
+
} ?: break
|
|
200
|
+
|
|
188
201
|
if (isInvalidState(
|
|
189
202
|
ResponseState.RESPONSE_RECEIVED,
|
|
190
203
|
ResponseState.BODY_STREAMING_STARTED,
|
|
@@ -194,9 +207,9 @@ internal class NativeResponse(appContext: AppContext, private val coroutineScope
|
|
|
194
207
|
break
|
|
195
208
|
}
|
|
196
209
|
if (state == ResponseState.RESPONSE_RECEIVED) {
|
|
197
|
-
sink.appendBufferBody(
|
|
210
|
+
sink.appendBufferBody(data)
|
|
198
211
|
} else if (state == ResponseState.BODY_STREAMING_STARTED) {
|
|
199
|
-
emit("didReceiveResponseData",
|
|
212
|
+
emit("didReceiveResponseData", data)
|
|
200
213
|
} else {
|
|
201
214
|
break
|
|
202
215
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBundleUrl.web.d.ts","sourceRoot":"","sources":["../../src/utils/getBundleUrl.web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBundleUrl.web.d.ts","sourceRoot":"","sources":["../../src/utils/getBundleUrl.web.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAe5C"}
|
|
@@ -21,9 +21,6 @@ export declare class FetchResponse extends ConcreteNativeResponse implements Res
|
|
|
21
21
|
get bodyUsed(): boolean;
|
|
22
22
|
get headers(): Headers;
|
|
23
23
|
get ok(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* This method is not currently supported by react-native's Blob constructor.
|
|
26
|
-
*/
|
|
27
24
|
blob(): Promise<Blob>;
|
|
28
25
|
formData(): Promise<UniversalFormData>;
|
|
29
26
|
json(): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchResponse.d.ts","sourceRoot":"","sources":["../../../src/winter/fetch/FetchResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchResponse.d.ts","sourceRoot":"","sources":["../../../src/winter/fetch/FetchResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGzE,QAAA,MAAM,sBAAsB,EAAqC,OAAO,cAAc,CAAC;AACvF,MAAM,MAAM,gCAAgC,GAAG,MAAM,IAAI,CAAC;AAI1D,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACvE,KAAK,iBAAiB,GAAG,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC;AAW1D,QAAA,MAAM,QAAQ,eAAgC,CAAC;AAuI/C;;GAEG;AACH,qBAAa,aAAc,SAAQ,sBAAuB,YAAW,QAAQ;IAM/D,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IALjD,OAAO,CAAC,CAAC,QAAQ,CAAC,CAGhB;gBAE2B,oBAAoB,EAAE,gCAAgC;IAQnF,IAAa,WAAW,IAAI,iBAAiB,CAE5C;IAED,IAAa,MAAM,IAAI,MAAM,CAE5B;IAED,IAAa,UAAU,IAAI,MAAM,CAEhC;IAED,IAAa,GAAG,IAAI,MAAM,CAEzB;IAED,IAAa,UAAU,IAAI,OAAO,CAEjC;IAED,IAAI,IAAI,IAAI,SAAS,CAEpB;IAED,IAAI,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,CA0EzD;IAED,IAAa,QAAQ,IAAI,OAAO,CAE/B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,EAAE,IAAI,OAAO,CAEhB;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBrB,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAgBtC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAMpB,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAKhC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAanC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAatC,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,MAAM;IAShB,KAAK,IAAI,aAAa;IAgDtB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,QAAQ,CAQd;CACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function isReactNativeBlobGlobal(): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* react-native's `Blob` cannot be created from binary data in JS, so store the
|
|
4
|
+
* bytes in its native blob store and reference them, like XHR responses do.
|
|
5
|
+
* TODO(kudo,20260706): remove this when we install expo-blob as globalThis.Blob
|
|
6
|
+
*/
|
|
7
|
+
export declare function createReactNativeBlobAsync(buffer: ArrayBuffer, type: string): Promise<Blob>;
|
|
8
|
+
//# sourceMappingURL=createBlob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBlob.d.ts","sourceRoot":"","sources":["../../../src/winter/fetch/createBlob.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,IAAI,OAAO,CAMjD;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUjG"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@expo/dom-webview": "~56.0.6",
|
|
3
|
-
"@expo/fingerprint": "~0.19.
|
|
4
|
-
"@expo/metro-runtime": "~56.0.
|
|
3
|
+
"@expo/fingerprint": "~0.19.9",
|
|
4
|
+
"@expo/metro-runtime": "~56.0.18",
|
|
5
5
|
"@expo/vector-icons": "^15.0.2",
|
|
6
|
-
"@expo/ui": "~56.0.
|
|
6
|
+
"@expo/ui": "~56.0.23",
|
|
7
7
|
"@react-native-async-storage/async-storage": "2.2.0",
|
|
8
8
|
"@react-native-community/datetimepicker": "9.1.0",
|
|
9
9
|
"@react-native-masked-view/masked-view": "0.3.2",
|
|
@@ -17,28 +17,28 @@
|
|
|
17
17
|
"expo-analytics-amplitude": "~11.3.0",
|
|
18
18
|
"expo-app-auth": "~11.1.0",
|
|
19
19
|
"expo-app-loader-provider": "~8.0.0",
|
|
20
|
-
"expo-app-metrics": "~56.0.
|
|
20
|
+
"expo-app-metrics": "~56.0.23",
|
|
21
21
|
"expo-apple-authentication": "~56.0.4",
|
|
22
22
|
"expo-application": "~56.0.3",
|
|
23
|
-
"expo-asset": "~56.0.
|
|
24
|
-
"expo-audio": "~56.0.
|
|
25
|
-
"expo-auth-session": "~56.0.
|
|
26
|
-
"expo-background-fetch": "~56.0.
|
|
27
|
-
"expo-background-task": "~56.0.
|
|
23
|
+
"expo-asset": "~56.0.21",
|
|
24
|
+
"expo-audio": "~56.0.13",
|
|
25
|
+
"expo-auth-session": "~56.0.16",
|
|
26
|
+
"expo-background-fetch": "~56.0.23",
|
|
27
|
+
"expo-background-task": "~56.0.23",
|
|
28
28
|
"expo-battery": "~56.0.4",
|
|
29
|
-
"expo-blur": "~56.0.
|
|
29
|
+
"expo-blur": "~56.0.4",
|
|
30
30
|
"expo-brightness": "~56.0.5",
|
|
31
|
-
"expo-brownfield": "~56.0.
|
|
32
|
-
"expo-build-properties": "~56.0.
|
|
31
|
+
"expo-brownfield": "~56.0.25",
|
|
32
|
+
"expo-build-properties": "~56.0.24",
|
|
33
33
|
"expo-calendar": "~56.0.9",
|
|
34
34
|
"expo-camera": "~56.0.8",
|
|
35
35
|
"expo-cellular": "~56.0.5",
|
|
36
36
|
"expo-checkbox": "~56.0.1",
|
|
37
37
|
"expo-clipboard": "~56.0.4",
|
|
38
|
-
"expo-constants": "~56.0.
|
|
39
|
-
"expo-contacts": "~56.0.
|
|
38
|
+
"expo-constants": "~56.0.22",
|
|
39
|
+
"expo-contacts": "~56.0.11",
|
|
40
40
|
"expo-crypto": "~56.0.4",
|
|
41
|
-
"expo-dev-client": "~56.0.
|
|
41
|
+
"expo-dev-client": "~56.0.24",
|
|
42
42
|
"expo-device": "~56.0.4",
|
|
43
43
|
"expo-document-picker": "~56.0.4",
|
|
44
44
|
"expo-file-system": "~56.0.8",
|
|
@@ -49,52 +49,52 @@
|
|
|
49
49
|
"expo-haptics": "~56.0.3",
|
|
50
50
|
"expo-image": "~56.0.11",
|
|
51
51
|
"expo-image-loader": "~56.0.3",
|
|
52
|
-
"expo-image-manipulator": "~56.0.
|
|
53
|
-
"expo-image-picker": "~56.0.
|
|
52
|
+
"expo-image-manipulator": "~56.0.23",
|
|
53
|
+
"expo-image-picker": "~56.0.22",
|
|
54
54
|
"expo-intent-launcher": "~56.0.4",
|
|
55
|
-
"expo-insights": "~56.0.
|
|
55
|
+
"expo-insights": "~56.0.22",
|
|
56
56
|
"expo-keep-awake": "~56.0.3",
|
|
57
57
|
"expo-linear-gradient": "~56.0.4",
|
|
58
|
-
"expo-linking": "~56.0.
|
|
59
|
-
"expo-local-authentication": "~56.0.
|
|
58
|
+
"expo-linking": "~56.0.16",
|
|
59
|
+
"expo-local-authentication": "~56.0.5",
|
|
60
60
|
"expo-localization": "~56.0.6",
|
|
61
|
-
"expo-location": "~56.0.
|
|
61
|
+
"expo-location": "~56.0.22",
|
|
62
62
|
"expo-mail-composer": "~56.0.4",
|
|
63
63
|
"expo-manifests": "~56.0.4",
|
|
64
64
|
"expo-maps": "~56.0.7",
|
|
65
65
|
"expo-mcp": "~0.2.1",
|
|
66
|
-
"expo-media-library": "~56.0.
|
|
66
|
+
"expo-media-library": "~56.0.10",
|
|
67
67
|
"expo-mesh-gradient": "~56.0.3",
|
|
68
|
-
"expo-module-template": "~56.0.
|
|
69
|
-
"expo-modules-core": "~56.0.
|
|
68
|
+
"expo-module-template": "~56.0.17",
|
|
69
|
+
"expo-modules-core": "~56.0.22",
|
|
70
70
|
"expo-navigation-bar": "~56.0.3",
|
|
71
71
|
"expo-network": "~56.0.5",
|
|
72
|
-
"expo-notifications": "~56.0.
|
|
73
|
-
"expo-observe": "~56.0.
|
|
72
|
+
"expo-notifications": "~56.0.22",
|
|
73
|
+
"expo-observe": "~56.0.26",
|
|
74
74
|
"expo-print": "~56.0.4",
|
|
75
75
|
"expo-live-photo": "~56.0.4",
|
|
76
|
-
"expo-router": "~56.2.
|
|
76
|
+
"expo-router": "~56.2.16",
|
|
77
77
|
"expo-screen-capture": "~56.0.4",
|
|
78
78
|
"expo-screen-orientation": "~56.0.5",
|
|
79
79
|
"expo-secure-store": "~56.0.4",
|
|
80
80
|
"expo-sensors": "~56.0.6",
|
|
81
81
|
"expo-server": "~56.0.5",
|
|
82
|
-
"expo-sharing": "~56.0.
|
|
82
|
+
"expo-sharing": "~56.0.23",
|
|
83
83
|
"expo-sms": "~56.0.3",
|
|
84
84
|
"expo-speech": "~56.0.3",
|
|
85
|
-
"expo-splash-screen": "~56.0.
|
|
85
|
+
"expo-splash-screen": "~56.0.14",
|
|
86
86
|
"expo-sqlite": "~56.0.5",
|
|
87
87
|
"expo-status-bar": "~56.0.4",
|
|
88
88
|
"expo-store-review": "~56.0.3",
|
|
89
89
|
"expo-symbols": "~56.0.6",
|
|
90
90
|
"expo-system-ui": "~56.0.5",
|
|
91
|
-
"expo-task-manager": "~56.0.
|
|
91
|
+
"expo-task-manager": "~56.0.23",
|
|
92
92
|
"expo-tracking-transparency": "~56.0.5",
|
|
93
|
-
"expo-updates": "~56.0.
|
|
93
|
+
"expo-updates": "~56.0.23",
|
|
94
94
|
"expo-video-thumbnails": "~56.0.3",
|
|
95
95
|
"expo-video": "~56.1.4",
|
|
96
|
-
"expo-web-browser": "~56.0.
|
|
97
|
-
"expo-widgets": "~56.0.
|
|
96
|
+
"expo-web-browser": "~56.0.6",
|
|
97
|
+
"expo-widgets": "~56.0.24",
|
|
98
98
|
"jest-expo": "~56.0.5",
|
|
99
99
|
"lottie-react-native": "~7.3.4",
|
|
100
100
|
"react": "19.2.3",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"react-native-pager-view": "8.0.1",
|
|
109
109
|
"react-native-worklets": "0.8.3",
|
|
110
110
|
"react-native-reanimated": "4.3.1",
|
|
111
|
-
"react-native-screens": "4.
|
|
111
|
+
"react-native-screens": "~4.26.0",
|
|
112
112
|
"react-native-safe-area-context": "~5.7.0",
|
|
113
113
|
"react-native-svg": "15.15.4",
|
|
114
114
|
"react-native-view-shot": "5.1.0",
|
|
@@ -24,6 +24,19 @@ public final class ExpoFetchModule: Module {
|
|
|
24
24
|
urlSession.invalidateAndCancel()
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// TODO(kudo,20260706): remove this when we install expo-blob as globalThis.Blob
|
|
28
|
+
AsyncFunction("unstable_createBlobData") { (data: Data) -> String in
|
|
29
|
+
guard let blobManager: NSObject = self.appContext?.nativeModule(named: "BlobModule") else {
|
|
30
|
+
throw FetchBlobModuleUnavailableException()
|
|
31
|
+
}
|
|
32
|
+
let store = NSSelectorFromString("store:")
|
|
33
|
+
guard blobManager.responds(to: store),
|
|
34
|
+
let blobId = blobManager.perform(store, with: data as NSData)?.takeUnretainedValue() as? String else {
|
|
35
|
+
throw FetchBlobModuleUnavailableException()
|
|
36
|
+
}
|
|
37
|
+
return blobId
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
// swiftlint:disable:next closure_body_length
|
|
28
41
|
Class(NativeResponse.self) {
|
|
29
42
|
Constructor {
|
|
@@ -19,3 +19,10 @@ internal final class FetchRedirectException: Exception {
|
|
|
19
19
|
"Redirect is not allowed when redirect mode is 'error'"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
internal final class FetchBlobModuleUnavailableException: Exception {
|
|
24
|
+
override var reason: String {
|
|
25
|
+
"Unable to store the response body as a blob because React Native's BlobModule is not available. " +
|
|
26
|
+
"Make sure your app includes the React Native blob support (React-RCTBlob) or read the body with arrayBuffer() instead"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo",
|
|
3
|
-
"version": "56.0.
|
|
3
|
+
"version": "56.0.17",
|
|
4
4
|
"description": "The Expo SDK",
|
|
5
5
|
"main": "src/Expo.ts",
|
|
6
6
|
"module": "src/Expo.ts",
|
|
@@ -68,25 +68,25 @@
|
|
|
68
68
|
"homepage": "https://github.com/expo/expo/tree/main/packages/expo",
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@babel/runtime": "^7.20.0",
|
|
71
|
-
"@expo/cli": "^56.1.
|
|
72
|
-
"@expo/config": "~56.0.
|
|
73
|
-
"@expo/config-plugins": "~56.0.
|
|
71
|
+
"@expo/cli": "^56.1.21",
|
|
72
|
+
"@expo/config": "~56.0.13",
|
|
73
|
+
"@expo/config-plugins": "~56.0.14",
|
|
74
74
|
"@expo/devtools": "~56.0.2",
|
|
75
75
|
"@expo/dom-webview": "~56.0.6",
|
|
76
|
-
"@expo/fingerprint": "^0.19.
|
|
77
|
-
"@expo/local-build-cache-provider": "^56.0.
|
|
76
|
+
"@expo/fingerprint": "^0.19.9",
|
|
77
|
+
"@expo/local-build-cache-provider": "^56.0.10",
|
|
78
78
|
"@expo/log-box": "^56.0.14",
|
|
79
79
|
"@expo/metro": "~56.0.0",
|
|
80
|
-
"@expo/metro-config": "~56.0.
|
|
80
|
+
"@expo/metro-config": "~56.0.18",
|
|
81
81
|
"@ungap/structured-clone": "^1.3.0",
|
|
82
|
-
"babel-preset-expo": "~56.0.
|
|
83
|
-
"expo-asset": "~56.0.
|
|
84
|
-
"expo-constants": "~56.0.
|
|
82
|
+
"babel-preset-expo": "~56.0.18",
|
|
83
|
+
"expo-asset": "~56.0.21",
|
|
84
|
+
"expo-constants": "~56.0.22",
|
|
85
85
|
"expo-file-system": "~56.0.8",
|
|
86
86
|
"expo-font": "~56.0.7",
|
|
87
87
|
"expo-keep-awake": "~56.0.3",
|
|
88
|
-
"expo-modules-autolinking": "~56.0.
|
|
89
|
-
"expo-modules-core": "~56.0.
|
|
88
|
+
"expo-modules-autolinking": "~56.0.21",
|
|
89
|
+
"expo-modules-core": "~56.0.22",
|
|
90
90
|
"pretty-format": "^29.7.0",
|
|
91
91
|
"react-refresh": "^0.14.2",
|
|
92
92
|
"whatwg-url-minimum": "^0.1.2"
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
"react-native": "0.85.3",
|
|
101
101
|
"rimraf": "^6.1.2",
|
|
102
102
|
"web-streams-polyfill": "^3.3.2",
|
|
103
|
-
"@expo/
|
|
104
|
-
"expo-updates": "56.0.
|
|
105
|
-
"@expo/
|
|
103
|
+
"@expo/dom-webview": "56.0.6",
|
|
104
|
+
"expo-updates": "56.0.23",
|
|
105
|
+
"@expo/metro-runtime": "56.0.18"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"@expo/dom-webview": "*",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"scripts/resolveAppEntry.js"
|
|
140
140
|
]
|
|
141
141
|
},
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "60c9da71e15060aa859a7a6e85f4b14062b761f4",
|
|
143
143
|
"scripts": {
|
|
144
144
|
"build": "tsc",
|
|
145
145
|
"clean": "rimraf build",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function setCurrentScript(src: string | null) {
|
|
6
|
+
Object.defineProperty(document, 'currentScript', {
|
|
7
|
+
configurable: true,
|
|
8
|
+
value: src == null ? null : Object.assign(document.createElement('script'), { src }),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// The web test project runs this file in jsdom, the node project on the server.
|
|
13
|
+
// `getBundleUrl` reads `document.currentScript`, so only assert in the browser.
|
|
14
|
+
if (typeof window === 'undefined') {
|
|
15
|
+
it('noop', () => {});
|
|
16
|
+
} else {
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
setCurrentScript(null);
|
|
19
|
+
jest.resetModules();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns the bundle URL while the script is executing synchronously', () => {
|
|
23
|
+
setCurrentScript('https://localhost:8081/index.bundle?platform=web');
|
|
24
|
+
const { getBundleUrl } = require('../getBundleUrl');
|
|
25
|
+
expect(getBundleUrl()).toBe('https://localhost:8081/index.bundle');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('still returns the bundle URL after the script finished executing', () => {
|
|
29
|
+
setCurrentScript('https://localhost:8081/index.bundle?platform=web');
|
|
30
|
+
const { getBundleUrl } = require('../getBundleUrl');
|
|
31
|
+
setCurrentScript(null);
|
|
32
|
+
expect(getBundleUrl()).toBe('https://localhost:8081/index.bundle');
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
|
+
// `document.currentScript` is only set during synchronous script execution, so we capture its URL
|
|
4
|
+
// at module load; reading it later (effect, async, dynamic import) would see `null`.
|
|
5
|
+
const initialScriptURL: string | null =
|
|
6
|
+
typeof window !== 'undefined' ? (document.currentScript as HTMLScriptElement)?.src : null;
|
|
7
|
+
|
|
3
8
|
export function getBundleUrl(): string | null {
|
|
4
|
-
let scriptURL: string | null
|
|
9
|
+
let scriptURL: string | null = initialScriptURL;
|
|
5
10
|
|
|
6
11
|
if (typeof window === 'undefined') {
|
|
7
12
|
// For server runtime, we use the filename of the current script
|
|
8
|
-
// @ts-
|
|
13
|
+
// @ts-expect-error The react-native tsconfig doesn't support CJS
|
|
9
14
|
scriptURL = 'file://' + __filename;
|
|
10
|
-
} else {
|
|
11
|
-
// TODO: Try to support `import.meta.url` when the ecosystem supports ESM,
|
|
12
|
-
// and jest doesn't throw SyntaxError when accessing `import.meta`.
|
|
13
|
-
scriptURL = (document.currentScript as HTMLScriptElement)?.src;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
if (scriptURL == null) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
20
|
+
|
|
19
21
|
const url = new URL(scriptURL);
|
|
20
22
|
return `${url.protocol}//${url.host}${url.pathname}`;
|
|
21
23
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExpoFetchModule } from './ExpoFetchModule';
|
|
2
2
|
import type { NativeHeadersType, NativeResponse } from './NativeRequest';
|
|
3
|
+
import { createReactNativeBlobAsync, isReactNativeBlobGlobal } from './createBlob';
|
|
3
4
|
|
|
4
5
|
const ConcreteNativeResponse = ExpoFetchModule.NativeResponse as typeof NativeResponse;
|
|
5
6
|
export type AbortSubscriptionCleanupFunction = () => void;
|
|
@@ -20,6 +21,8 @@ interface ResponseMetadata {
|
|
|
20
21
|
|
|
21
22
|
const stateKey = Symbol('FetchResponse.state');
|
|
22
23
|
|
|
24
|
+
let hasWarnedAboutReactNativeBlob = false;
|
|
25
|
+
|
|
23
26
|
interface ConsumptionWrapper {
|
|
24
27
|
stream: ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
25
28
|
// Stops the wrapper from marking its body as consumed. Called by clone()
|
|
@@ -280,13 +283,22 @@ export class FetchResponse extends ConcreteNativeResponse implements Response {
|
|
|
280
283
|
return this.status >= 200 && this.status < 300;
|
|
281
284
|
}
|
|
282
285
|
|
|
283
|
-
/**
|
|
284
|
-
* This method is not currently supported by react-native's Blob constructor.
|
|
285
|
-
*/
|
|
286
286
|
async blob(): Promise<Blob> {
|
|
287
287
|
this.checkBodyUsedError('blob');
|
|
288
|
+
const type = this.headers.get('content-type') ?? '';
|
|
288
289
|
const buffer = await this.arrayBuffer();
|
|
289
|
-
|
|
290
|
+
|
|
291
|
+
if (isReactNativeBlobGlobal()) {
|
|
292
|
+
if (__DEV__ && !hasWarnedAboutReactNativeBlob) {
|
|
293
|
+
hasWarnedAboutReactNativeBlob = true;
|
|
294
|
+
console.warn(
|
|
295
|
+
"Response.blob() is using React Native's Blob, which copies the response into the native blob store and reads it back through base64 encoding. This may be slow for large responses. Add the `expo-blob` package to your app to avoid the performance overhead."
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return createReactNativeBlobAsync(buffer, type);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return new Blob([buffer], { type });
|
|
290
302
|
}
|
|
291
303
|
|
|
292
304
|
async formData(): Promise<UniversalFormData> {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { FetchResponse } from '../FetchResponse';
|
|
2
|
+
|
|
3
|
+
jest.mock('../ExpoFetchModule', () => {
|
|
4
|
+
const helloWorld = new TextEncoder().encode('hello world');
|
|
5
|
+
|
|
6
|
+
class StubNativeResponse {
|
|
7
|
+
// Getters on the prototype, like the real native binding, so super.x works.
|
|
8
|
+
get _rawHeaders(): [string, string][] {
|
|
9
|
+
return [['content-type', 'text/plain']];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
addListener() {}
|
|
13
|
+
removeListener() {}
|
|
14
|
+
removeAllListeners() {}
|
|
15
|
+
|
|
16
|
+
async arrayBuffer(): Promise<ArrayBuffer> {
|
|
17
|
+
return helloWorld.buffer.slice(
|
|
18
|
+
helloWorld.byteOffset,
|
|
19
|
+
helloWorld.byteOffset + helloWorld.byteLength
|
|
20
|
+
) as ArrayBuffer;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
ExpoFetchModule: {
|
|
26
|
+
NativeResponse: StubNativeResponse,
|
|
27
|
+
unstable_createBlobData: jest.fn(async () => 'mock-blob-id'),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('FetchResponse blob() with react-native Blob', () => {
|
|
33
|
+
const originalBlob = globalThis.Blob;
|
|
34
|
+
const RNBlob = require('react-native/Libraries/Blob/Blob').default;
|
|
35
|
+
const { ExpoFetchModule } = require('../ExpoFetchModule');
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
globalThis.Blob = RNBlob;
|
|
39
|
+
ExpoFetchModule.unstable_createBlobData.mockClear();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
globalThis.Blob = originalBlob;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
function makeResponse(): FetchResponse {
|
|
47
|
+
return new FetchResponse(() => {});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
it('should warn about the performance overhead only once', async () => {
|
|
51
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await makeResponse().blob();
|
|
55
|
+
await makeResponse().blob();
|
|
56
|
+
|
|
57
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('expo-blob'));
|
|
59
|
+
} finally {
|
|
60
|
+
warnSpy.mockRestore();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return a react-native blob backed by the native blob store', async () => {
|
|
65
|
+
const response = makeResponse();
|
|
66
|
+
const blob = await response.blob();
|
|
67
|
+
|
|
68
|
+
expect(blob).toBeInstanceOf(RNBlob);
|
|
69
|
+
expect((blob as any).data.blobId).toBe('mock-blob-id');
|
|
70
|
+
expect(blob.size).toBe(11);
|
|
71
|
+
expect(blob.type).toBe('text/plain');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should store the body bytes in the native blob store', async () => {
|
|
75
|
+
const response = makeResponse();
|
|
76
|
+
await response.blob();
|
|
77
|
+
|
|
78
|
+
expect(ExpoFetchModule.unstable_createBlobData).toHaveBeenCalledTimes(1);
|
|
79
|
+
const bytes = ExpoFetchModule.unstable_createBlobData.mock.calls[0][0] as Uint8Array;
|
|
80
|
+
expect(new TextDecoder().decode(bytes)).toBe('hello world');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should reject a second blob() call with TypeError', async () => {
|
|
84
|
+
const response = makeResponse();
|
|
85
|
+
await response.blob();
|
|
86
|
+
await expect(response.blob()).rejects.toThrow(TypeError);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -89,6 +89,7 @@ jest.mock('../ExpoFetchModule', () => {
|
|
|
89
89
|
ExpoFetchModule: {
|
|
90
90
|
NativeRequest: StubNativeRequest,
|
|
91
91
|
NativeResponse: StubNativeResponse,
|
|
92
|
+
unstable_createBlobData: jest.fn(async () => 'mock-blob-id'),
|
|
92
93
|
},
|
|
93
94
|
};
|
|
94
95
|
});
|
|
@@ -254,6 +255,15 @@ describe('FetchResponse', () => {
|
|
|
254
255
|
});
|
|
255
256
|
});
|
|
256
257
|
|
|
258
|
+
describe('blob()', () => {
|
|
259
|
+
it('should create a blob with type from the content-type header', async () => {
|
|
260
|
+
const response = makeResponse();
|
|
261
|
+
const blob = await response.blob();
|
|
262
|
+
expect(blob.size).toBe(11);
|
|
263
|
+
expect(blob.type).toBe('text/plain');
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
257
267
|
describe('body methods', () => {
|
|
258
268
|
it('rejects a second arrayBuffer() call with TypeError', async () => {
|
|
259
269
|
const response = makeResponse();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ExpoFetchModule } from './ExpoFetchModule';
|
|
2
|
+
|
|
3
|
+
export function isReactNativeBlobGlobal(): boolean {
|
|
4
|
+
try {
|
|
5
|
+
return globalThis.Blob === require('react-native/Libraries/Blob/Blob').default;
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* react-native's `Blob` cannot be created from binary data in JS, so store the
|
|
13
|
+
* bytes in its native blob store and reference them, like XHR responses do.
|
|
14
|
+
* TODO(kudo,20260706): remove this when we install expo-blob as globalThis.Blob
|
|
15
|
+
*/
|
|
16
|
+
export async function createReactNativeBlobAsync(buffer: ArrayBuffer, type: string): Promise<Blob> {
|
|
17
|
+
const BlobManager = require('react-native/Libraries/Blob/BlobManager').default;
|
|
18
|
+
const blobId: string = await ExpoFetchModule.unstable_createBlobData(new Uint8Array(buffer));
|
|
19
|
+
return BlobManager.createFromOptions({
|
|
20
|
+
blobId,
|
|
21
|
+
offset: 0,
|
|
22
|
+
size: buffer.byteLength,
|
|
23
|
+
type,
|
|
24
|
+
lastModified: Date.now(),
|
|
25
|
+
});
|
|
26
|
+
}
|
package/template.tgz
CHANGED
|
Binary file
|