react-native-windows 0.67.8 → 0.67.11
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/CHANGELOG.json +168 -0
- package/CHANGELOG.md +65 -4
- package/Chakra/ChakraHelpers.cpp +0 -1
- package/Directory.Build.props +4 -0
- package/Folly/Folly.vcxproj +4 -5
- package/Libraries/Network/RCTNetworkingWinShared.js +7 -0
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +2 -3
- package/Microsoft.ReactNative/IReactContext.cpp +17 -0
- package/Microsoft.ReactNative/IReactContext.h +2 -0
- package/Microsoft.ReactNative/IReactContext.idl +27 -0
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
- package/Microsoft.ReactNative/packages.config +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.cpp +17 -5
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h +36 -7
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +26 -16
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +52 -0
- package/Microsoft.ReactNative.Cxx/JSValueWriter.h +1 -1
- package/Microsoft.ReactNative.Cxx/NativeModules.h +2 -2
- package/Microsoft.ReactNative.Cxx/ReactPromise.cpp +21 -1
- package/Microsoft.ReactNative.Cxx/ReactPromise.h +27 -0
- package/Microsoft.ReactNative.Cxx/TurboModuleProvider.h +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/JSEngine.props +1 -1
- package/Scripts/OfficeReact.Win32.nuspec +1 -1
- package/Shared/BaseScriptStoreImpl.cpp +1 -1
- package/Shared/CppRuntimeOptions.h +50 -0
- package/Shared/CreateModules.h +20 -1
- package/Shared/InspectorPackagerConnection.cpp +7 -5
- package/Shared/InspectorPackagerConnection.h +2 -2
- package/Shared/JSI/ChakraApi.cpp +0 -1
- package/Shared/JSI/ChakraRuntime.cpp +0 -1
- package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +72 -2
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +3 -1
- package/Shared/Modules/BlobModule.cpp +376 -0
- package/Shared/Modules/BlobModule.h +153 -0
- package/Shared/Modules/CxxModuleUtilities.cpp +19 -0
- package/Shared/Modules/CxxModuleUtilities.h +23 -0
- package/Shared/Modules/FileReaderModule.cpp +156 -0
- package/Shared/Modules/FileReaderModule.h +54 -0
- package/Shared/Modules/HttpModule.cpp +201 -0
- package/Shared/Modules/HttpModule.h +60 -0
- package/Shared/Modules/IBlobPersistor.h +30 -0
- package/Shared/Modules/IHttpModuleProxy.h +30 -0
- package/Shared/Modules/IRequestBodyHandler.h +52 -0
- package/Shared/Modules/IResponseHandler.h +27 -0
- package/Shared/Modules/IUriHandler.h +37 -0
- package/Shared/Modules/IWebSocketModuleContentHandler.h +26 -0
- package/Shared/Modules/IWebSocketModuleProxy.h +22 -0
- package/Shared/Modules/NetworkingModule.cpp +1 -1
- package/Shared/Modules/WebSocketModule.cpp +97 -23
- package/Shared/Modules/WebSocketModule.h +35 -6
- package/Shared/Networking/IHttpResource.h +101 -0
- package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
- package/Shared/Networking/OriginPolicy.h +15 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +747 -0
- package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
- package/Shared/Networking/WinRTHttpResource.cpp +465 -0
- package/Shared/Networking/WinRTHttpResource.h +86 -0
- package/Shared/Networking/WinRTTypes.h +33 -0
- package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +31 -22
- package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
- package/Shared/OInstance.cpp +41 -4
- package/Shared/OInstance.h +8 -4
- package/Shared/RuntimeOptions.cpp +96 -15
- package/Shared/RuntimeOptions.h +32 -8
- package/Shared/Shared.vcxitems +28 -5
- package/Shared/Shared.vcxitems.filters +93 -15
- package/Shared/Utils/WinRTConversions.cpp +22 -0
- package/Shared/Utils/WinRTConversions.h +15 -0
- package/fmt/fmt.vcxproj +4 -5
- package/package.json +1 -1
- package/Shared/IHttpResource.h +0 -34
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,174 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Mon, 20 Jun 2022 15:08:04 GMT",
|
|
6
|
+
"tag": "react-native-windows_v0.67.11",
|
|
7
|
+
"version": "0.67.11",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "vmorozov@microsoft.com",
|
|
12
|
+
"package": "react-native-windows",
|
|
13
|
+
"commit": "247fa688a24a58c3b22411babbcd3b6396744895",
|
|
14
|
+
"comment": "Fix use of [[maybe_unused]] attribute"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "vmorozov@microsoft.com",
|
|
18
|
+
"package": "react-native-windows",
|
|
19
|
+
"commit": "2b74c16a6d631ff7ba65ae28a81de5b26906bd40",
|
|
20
|
+
"comment": "Fix ExecuteJsi on instance shutdown"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Mon, 30 May 2022 15:09:46 GMT",
|
|
27
|
+
"tag": "react-native-windows_v0.67.10",
|
|
28
|
+
"version": "0.67.10",
|
|
29
|
+
"comments": {
|
|
30
|
+
"patch": [
|
|
31
|
+
{
|
|
32
|
+
"author": "acoates@microsoft.com",
|
|
33
|
+
"package": "react-native-windows",
|
|
34
|
+
"commit": "not available",
|
|
35
|
+
"comment": "Expose LoadingState on ReactContext"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "vmorozov@microsoft.com",
|
|
39
|
+
"package": "react-native-windows",
|
|
40
|
+
"commit": "not available",
|
|
41
|
+
"comment": "Support PreparedScriptStore for V8 Node-API."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "julio@rochsquadron.net",
|
|
45
|
+
"package": "react-native-windows",
|
|
46
|
+
"commit": "not available",
|
|
47
|
+
"comment": "Implement Blob module (#9352)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "vmorozov@microsoft.com",
|
|
51
|
+
"package": "react-native-windows",
|
|
52
|
+
"commit": "not available",
|
|
53
|
+
"comment": "Fix RuntimeOptions for RNW Desktop"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "jthysell@microsoft.com",
|
|
57
|
+
"package": "react-native-windows",
|
|
58
|
+
"commit": "not available",
|
|
59
|
+
"comment": "[0.67] Change CG registration for folly and fmt from `other` to `git`"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"date": "Mon, 30 May 2022 15:09:33 GMT",
|
|
66
|
+
"tag": "react-native-windows_v0.67.10",
|
|
67
|
+
"version": "0.67.10",
|
|
68
|
+
"comments": {
|
|
69
|
+
"patch": [
|
|
70
|
+
{
|
|
71
|
+
"author": "acoates@microsoft.com",
|
|
72
|
+
"package": "react-native-windows",
|
|
73
|
+
"commit": "1d8934a3235695ce7ef5796976a2e5c0413d3ef8",
|
|
74
|
+
"comment": "Expose LoadingState on ReactContext"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"author": "vmorozov@microsoft.com",
|
|
78
|
+
"package": "react-native-windows",
|
|
79
|
+
"commit": "6d6015d5f24540e355160a5be62af1cc1a3903b0",
|
|
80
|
+
"comment": "Support PreparedScriptStore for V8 Node-API."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"author": "julio@rochsquadron.net",
|
|
84
|
+
"package": "react-native-windows",
|
|
85
|
+
"commit": "932c3b9e6732b83d60b608d3d44fed7f4cc6a6de",
|
|
86
|
+
"comment": "Implement Blob module (#9352)"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"author": "vmorozov@microsoft.com",
|
|
90
|
+
"package": "react-native-windows",
|
|
91
|
+
"commit": "13824a0805d2e9bd2eef44852029b193daf56664",
|
|
92
|
+
"comment": "Fix RuntimeOptions for RNW Desktop"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"author": "jthysell@microsoft.com",
|
|
96
|
+
"package": "react-native-windows",
|
|
97
|
+
"commit": "93498b92be5a6900b06b35b20c4e81ba18a10647",
|
|
98
|
+
"comment": "[0.67] Change CG registration for folly and fmt from `other` to `git`"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"date": "Mon, 02 May 2022 15:10:57 GMT",
|
|
105
|
+
"tag": "react-native-windows_v0.67.9",
|
|
106
|
+
"version": "0.67.9",
|
|
107
|
+
"comments": {
|
|
108
|
+
"patch": [
|
|
109
|
+
{
|
|
110
|
+
"author": "53799235+ZihanChen-MSFT@users.noreply.github.com",
|
|
111
|
+
"package": "react-native-windows",
|
|
112
|
+
"commit": "not available",
|
|
113
|
+
"comment": "Fix clang-check errors in NativeModules.h"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"author": "vmorozov@microsoft.com",
|
|
117
|
+
"package": "react-native-windows",
|
|
118
|
+
"commit": "not available",
|
|
119
|
+
"comment": "Fix JSI for Node-API and update V8 to 0.65.11"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"author": "julio.rocha@microsoft.com",
|
|
123
|
+
"package": "react-native-windows",
|
|
124
|
+
"commit": "not available",
|
|
125
|
+
"comment": "Handle abrupt WebSocket connection interruption (#9829)"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"date": "Mon, 02 May 2022 15:10:43 GMT",
|
|
132
|
+
"tag": "react-native-windows_v0.67.9",
|
|
133
|
+
"version": "0.67.9",
|
|
134
|
+
"comments": {
|
|
135
|
+
"patch": [
|
|
136
|
+
{
|
|
137
|
+
"author": "53799235+ZihanChen-MSFT@users.noreply.github.com",
|
|
138
|
+
"package": "react-native-windows",
|
|
139
|
+
"commit": "9458dad1646fa2a8a5afea7383133eeca144fb88",
|
|
140
|
+
"comment": "Fix clang-check errors in NativeModules.h"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"author": "vmorozov@microsoft.com",
|
|
144
|
+
"package": "react-native-windows",
|
|
145
|
+
"commit": "38c0547235927e51c08bd17b08b2f6be878fd0a5",
|
|
146
|
+
"comment": "Fix JSI for Node-API and update V8 to 0.65.11"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"author": "julio.rocha@microsoft.com",
|
|
150
|
+
"package": "react-native-windows",
|
|
151
|
+
"commit": "e3ef52d578991181c00a6487c902ce4c31cc702a",
|
|
152
|
+
"comment": "Handle abrupt WebSocket connection interruption (#9829)"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"date": "Mon, 25 Apr 2022 15:11:36 GMT",
|
|
159
|
+
"tag": "react-native-windows_v0.67.8",
|
|
160
|
+
"version": "0.67.8",
|
|
161
|
+
"comments": {
|
|
162
|
+
"patch": [
|
|
163
|
+
{
|
|
164
|
+
"author": "vmorozov@microsoft.com",
|
|
165
|
+
"package": "react-native-windows",
|
|
166
|
+
"commit": "not available",
|
|
167
|
+
"comment": "Fix Sequential DispatchQueue deadlock on shutdown"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
},
|
|
4
172
|
{
|
|
5
173
|
"date": "Mon, 25 Apr 2022 15:11:22 GMT",
|
|
6
174
|
"tag": "react-native-windows_v0.67.8",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,78 @@
|
|
|
1
1
|
# Change Log - react-native-windows
|
|
2
2
|
|
|
3
|
-
This log was last generated on Mon,
|
|
3
|
+
This log was last generated on Mon, 20 Jun 2022 15:08:04 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.67.
|
|
7
|
+
## 0.67.11
|
|
8
8
|
|
|
9
|
-
Mon,
|
|
9
|
+
Mon, 20 Jun 2022 15:08:04 GMT
|
|
10
10
|
|
|
11
11
|
### Patches
|
|
12
12
|
|
|
13
|
-
- Fix
|
|
13
|
+
- Fix use of [[maybe_unused]] attribute (vmorozov@microsoft.com)
|
|
14
|
+
- Fix ExecuteJsi on instance shutdown (vmorozov@microsoft.com)
|
|
14
15
|
|
|
16
|
+
## 0.67.10
|
|
17
|
+
|
|
18
|
+
Mon, 30 May 2022 15:09:46 GMT
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- Expose LoadingState on ReactContext (acoates@microsoft.com)
|
|
23
|
+
- Support PreparedScriptStore for V8 Node-API. (vmorozov@microsoft.com)
|
|
24
|
+
- Implement Blob module (#9352) (julio@rochsquadron.net)
|
|
25
|
+
- Fix RuntimeOptions for RNW Desktop (vmorozov@microsoft.com)
|
|
26
|
+
- [0.67] Change CG registration for folly and fmt from `other` to `git` (jthysell@microsoft.com)
|
|
27
|
+
|
|
28
|
+
## 0.67.10
|
|
29
|
+
|
|
30
|
+
Mon, 30 May 2022 15:09:33 GMT
|
|
31
|
+
|
|
32
|
+
### Patches
|
|
33
|
+
|
|
34
|
+
- Expose LoadingState on ReactContext (acoates@microsoft.com)
|
|
35
|
+
- Support PreparedScriptStore for V8 Node-API. (vmorozov@microsoft.com)
|
|
36
|
+
- Implement Blob module (#9352) (julio@rochsquadron.net)
|
|
37
|
+
- Fix RuntimeOptions for RNW Desktop (vmorozov@microsoft.com)
|
|
38
|
+
- [0.67] Change CG registration for folly and fmt from `other` to `git` (jthysell@microsoft.com)
|
|
39
|
+
|
|
40
|
+
## 0.67.9
|
|
41
|
+
|
|
42
|
+
Mon, 02 May 2022 15:10:57 GMT
|
|
43
|
+
|
|
44
|
+
### Patches
|
|
45
|
+
|
|
46
|
+
- Fix clang-check errors in NativeModules.h (53799235+ZihanChen-MSFT@users.noreply.github.com)
|
|
47
|
+
- Fix JSI for Node-API and update V8 to 0.65.11 (vmorozov@microsoft.com)
|
|
48
|
+
- Handle abrupt WebSocket connection interruption (#9829) (julio.rocha@microsoft.com)
|
|
49
|
+
|
|
50
|
+
## 0.67.9
|
|
51
|
+
|
|
52
|
+
Mon, 02 May 2022 15:10:43 GMT
|
|
53
|
+
|
|
54
|
+
### Patches
|
|
55
|
+
|
|
56
|
+
- Fix clang-check errors in NativeModules.h (53799235+ZihanChen-MSFT@users.noreply.github.com)
|
|
57
|
+
- Fix JSI for Node-API and update V8 to 0.65.11 (vmorozov@microsoft.com)
|
|
58
|
+
- Handle abrupt WebSocket connection interruption (#9829) (julio.rocha@microsoft.com)
|
|
59
|
+
|
|
60
|
+
## 0.67.8
|
|
61
|
+
|
|
62
|
+
Mon, 25 Apr 2022 15:11:36 GMT
|
|
63
|
+
|
|
64
|
+
### Patches
|
|
65
|
+
|
|
66
|
+
- Fix Sequential DispatchQueue deadlock on shutdown (vmorozov@microsoft.com)
|
|
67
|
+
|
|
68
|
+
## 0.67.8
|
|
69
|
+
|
|
70
|
+
Mon, 25 Apr 2022 15:11:22 GMT
|
|
71
|
+
|
|
72
|
+
### Patches
|
|
73
|
+
|
|
74
|
+
- Fix Sequential DispatchQueue deadlock on shutdown (vmorozov@microsoft.com)
|
|
75
|
+
|
|
15
76
|
## 0.67.7
|
|
16
77
|
|
|
17
78
|
Mon, 04 Apr 2022 15:13:28 GMT
|
package/Chakra/ChakraHelpers.cpp
CHANGED
package/Directory.Build.props
CHANGED
|
@@ -18,8 +18,12 @@
|
|
|
18
18
|
The PR (windows-vs-pr.yml) and CI (publish.yml() turn it back on.
|
|
19
19
|
-->
|
|
20
20
|
<EnableSourceLink Condition="'$(EnableSourceLink)' == ''">false</EnableSourceLink>
|
|
21
|
+
<!-- When bumping the Folly version, be sure to bump the git hash of that version's commit too. -->
|
|
21
22
|
<FollyVersion>2021.06.28.00</FollyVersion>
|
|
23
|
+
<FollyCommitHash>f434460f8a98e85f3ddb75390ddd1cc330c8f658</FollyCommitHash>
|
|
24
|
+
<!-- When bumping the fmt version, be sure to bump the git hash of that version's commit too. -->
|
|
22
25
|
<FmtVersion>7.1.3</FmtVersion>
|
|
26
|
+
<FmtCommitHash>7bdf0628b1276379886c7f6dda2cef2b3b374f0b</FmtCommitHash>
|
|
23
27
|
</PropertyGroup>
|
|
24
28
|
|
|
25
29
|
<PropertyGroup Label="Configuration">
|
package/Folly/Folly.vcxproj
CHANGED
|
@@ -299,11 +299,10 @@
|
|
|
299
299
|
"Registrations": [
|
|
300
300
|
{
|
|
301
301
|
"Component": {
|
|
302
|
-
"Type": "
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
"
|
|
306
|
-
"DownloadUrl": "https://github.com/facebook/folly/archive/v$(FollyVersion).zip"
|
|
302
|
+
"Type": "git",
|
|
303
|
+
"Git": {
|
|
304
|
+
"RepositoryUrl": "https://github.com/facebook/folly",
|
|
305
|
+
"CommitHash": "$(FollyCommitHash)"
|
|
307
306
|
}
|
|
308
307
|
},
|
|
309
308
|
"DevelopmentDependency": false
|
|
@@ -61,6 +61,11 @@ type RCTNetworkingEventDefinitions = $ReadOnly<{
|
|
|
61
61
|
],
|
|
62
62
|
}>;
|
|
63
63
|
|
|
64
|
+
let _requestId = 1;
|
|
65
|
+
function generateRequestId(): number {
|
|
66
|
+
return _requestId++;
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
const RCTNetworking = {
|
|
65
70
|
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
|
|
66
71
|
eventType: K,
|
|
@@ -82,11 +87,13 @@ const RCTNetworking = {
|
|
|
82
87
|
callback: (requestId: number) => void,
|
|
83
88
|
withCredentials: boolean,
|
|
84
89
|
) {
|
|
90
|
+
const requestId = generateRequestId();
|
|
85
91
|
const body = convertRequestBody(data);
|
|
86
92
|
RCTNetworkingNative.sendRequest(
|
|
87
93
|
{
|
|
88
94
|
method,
|
|
89
95
|
url,
|
|
96
|
+
requestId,
|
|
90
97
|
data: {...body, trackingName},
|
|
91
98
|
headers,
|
|
92
99
|
responseType,
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
#include <Modules/ClipboardModule.h>
|
|
14
14
|
#include <Modules/LinkingManagerModule.h>
|
|
15
15
|
#include <Modules/NativeUIManager.h>
|
|
16
|
-
#include <Modules/NetworkingModule.h>
|
|
17
16
|
#include <Modules/PaperUIManagerModule.h>
|
|
18
17
|
#include <Threading/MessageQueueThreadFactory.h>
|
|
19
18
|
|
|
@@ -50,8 +49,8 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
|
|
|
50
49
|
std::vector<facebook::react::NativeModuleDescription> modules;
|
|
51
50
|
|
|
52
51
|
modules.emplace_back(
|
|
53
|
-
|
|
54
|
-
[]() { return
|
|
52
|
+
"Networking",
|
|
53
|
+
[props = context->Properties()]() { return Microsoft::React::CreateHttpModule(props); },
|
|
55
54
|
jsMessageQueue);
|
|
56
55
|
|
|
57
56
|
modules.emplace_back(
|
|
@@ -96,6 +96,23 @@ Windows::Foundation::IInspectable ReactContext::JSRuntime() noexcept {
|
|
|
96
96
|
return m_context->JsiRuntime();
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
LoadingState ReactContext::LoadingState() noexcept {
|
|
100
|
+
switch (m_context->State()) {
|
|
101
|
+
case Mso::React::ReactInstanceState::Loading:
|
|
102
|
+
case Mso::React::ReactInstanceState::WaitingForDebugger:
|
|
103
|
+
return LoadingState::Loading;
|
|
104
|
+
case Mso::React::ReactInstanceState::Loaded:
|
|
105
|
+
return LoadingState::Loaded;
|
|
106
|
+
case Mso::React::ReactInstanceState::HasError:
|
|
107
|
+
return LoadingState::HasError;
|
|
108
|
+
case Mso::React::ReactInstanceState::Unloaded:
|
|
109
|
+
return LoadingState::Unloaded;
|
|
110
|
+
default:
|
|
111
|
+
assert(false);
|
|
112
|
+
return LoadingState::HasError;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
99
116
|
#ifndef CORE_ABI
|
|
100
117
|
// Deprecated: Use XamlUIService directly.
|
|
101
118
|
void ReactContext::DispatchEvent(
|
|
@@ -42,6 +42,8 @@ struct ReactContext : winrt::implements<ReactContext, IReactContext> {
|
|
|
42
42
|
IReactDispatcher UIDispatcher() noexcept;
|
|
43
43
|
IReactDispatcher JSDispatcher() noexcept;
|
|
44
44
|
IInspectable JSRuntime() noexcept;
|
|
45
|
+
LoadingState LoadingState() noexcept;
|
|
46
|
+
|
|
45
47
|
#ifndef CORE_ABI
|
|
46
48
|
void DispatchEvent(
|
|
47
49
|
xaml::FrameworkElement const &view,
|
|
@@ -13,6 +13,29 @@ import "IReactPropertyBag.idl";
|
|
|
13
13
|
|
|
14
14
|
namespace Microsoft.ReactNative
|
|
15
15
|
{
|
|
16
|
+
|
|
17
|
+
DOC_STRING(
|
|
18
|
+
"Used to represent the state of the React Native JavaScript instance")
|
|
19
|
+
enum LoadingState
|
|
20
|
+
{
|
|
21
|
+
DOC_STRING(
|
|
22
|
+
"The instance is loading the JavaScript bundle and initial instance setup. Calls to run JavaScript functions will be queued to run once the instance is fully loaded."
|
|
23
|
+
)
|
|
24
|
+
Loading = 0,
|
|
25
|
+
DOC_STRING(
|
|
26
|
+
"The instance is in a ready state. Calls to run JavaScript functions will be run as soon as they are posted to the JavaScript instance."
|
|
27
|
+
)
|
|
28
|
+
Loaded = 1,
|
|
29
|
+
DOC_STRING(
|
|
30
|
+
"The instance has hit an error. Calls to run JavaScript functions will not be run."
|
|
31
|
+
)
|
|
32
|
+
HasError = 2,
|
|
33
|
+
DOC_STRING(
|
|
34
|
+
"The instance has successfully unloaded. Calls to run JavaScript functions will not be run."
|
|
35
|
+
)
|
|
36
|
+
Unloaded = 3
|
|
37
|
+
};
|
|
38
|
+
|
|
16
39
|
[webhosthidden]
|
|
17
40
|
DOC_STRING("An immutable snapshot of the @ReactInstanceSettings used to create the current React instance.")
|
|
18
41
|
interface IReactSettingsSnapshot
|
|
@@ -167,5 +190,9 @@ namespace Microsoft.ReactNative
|
|
|
167
190
|
"The `paramsArgWriter` is a @JSValueArgWriter delegate that receives @IJSValueWriter to serialize "
|
|
168
191
|
"the event parameters.")
|
|
169
192
|
void EmitJSEvent(String eventEmitterName, String eventName, JSValueArgWriter paramsArgWriter);
|
|
193
|
+
|
|
194
|
+
DOC_STRING(
|
|
195
|
+
"Gets the state of the ReactNative instance.")
|
|
196
|
+
LoadingState LoadingState { get; };
|
|
170
197
|
}
|
|
171
198
|
} // namespace Microsoft.ReactNative
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
#include <CreateModules.h>
|
|
5
|
+
#include <Networking/WinRTWebSocketResource.h>
|
|
5
6
|
#include <QuirkSettings.h>
|
|
6
7
|
#include <React.h>
|
|
7
8
|
#include <ReactPropertyBag.h>
|
|
8
|
-
#include <WinRTWebSocketResource.h>
|
|
9
9
|
|
|
10
10
|
// React Native
|
|
11
11
|
#include <cxxreact/CxxModule.h>
|
|
@@ -17,11 +17,11 @@ using winrt::Microsoft::ReactNative::ReactPropertyBag;
|
|
|
17
17
|
using winrt::Microsoft::ReactNative::ReactPropertyId;
|
|
18
18
|
using winrt::Microsoft::ReactNative::implementation::QuirkSettings;
|
|
19
19
|
|
|
20
|
-
namespace Microsoft::React {
|
|
20
|
+
namespace Microsoft::React::Networking {
|
|
21
21
|
|
|
22
22
|
std::shared_ptr<IWebSocketResource> IWebSocketResource::Make() {
|
|
23
23
|
std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
|
|
24
24
|
return std::make_shared<WinRTWebSocketResource>(std::move(certExceptions));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
} // namespace Microsoft::React
|
|
27
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<package id="Microsoft.Windows.CppWinRT" version="2.0.210312.4" targetFramework="native" />
|
|
9
9
|
<package id="Microsoft.WinUI" version="3.0.0-preview4.210210.4" targetFramework="native" />
|
|
10
10
|
<package id="ReactNative.Hermes.Windows" version="0.10.0-ms.1" targetFramework="native" />
|
|
11
|
-
<!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.
|
|
11
|
+
<!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.15" targetFramework="native" / -->
|
|
12
12
|
</packages>
|
|
@@ -10,16 +10,19 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
|
|
|
10
10
|
|
|
11
11
|
namespace winrt::Microsoft::ReactNative {
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
// If it is not found, then create it and store it in the context.Properties().
|
|
15
|
-
//
|
|
16
|
-
|
|
13
|
+
// Try to get JSI Runtime for the current JS dispatcher thread.
|
|
14
|
+
// If it is not found, then create it based on context JSI runtime and store it in the context.Properties().
|
|
15
|
+
// The function returns nullptr if the current context does not have JSI runtime.
|
|
16
|
+
// It makes sure that the JSI runtime holder is removed when the instance is unloaded.
|
|
17
|
+
facebook::jsi::Runtime *TryGetOrCreateContextRuntime(ReactContext const &context) noexcept {
|
|
17
18
|
ReactDispatcher jsDispatcher = context.JSDispatcher();
|
|
18
19
|
VerifyElseCrashSz(jsDispatcher.HasThreadAccess(), "Must be in JS thread");
|
|
19
20
|
|
|
20
21
|
// The JSI runtime is not available if we do Web debugging when JS is running in web browser.
|
|
21
22
|
JsiRuntime abiJsiRuntime = context.Handle().JSRuntime().as<JsiRuntime>();
|
|
22
|
-
|
|
23
|
+
if (!abiJsiRuntime) {
|
|
24
|
+
return nullptr;
|
|
25
|
+
}
|
|
23
26
|
|
|
24
27
|
// See if the JSI runtime was previously created.
|
|
25
28
|
JsiAbiRuntime *runtime = JsiAbiRuntime::GetFromJsiRuntime(abiJsiRuntime);
|
|
@@ -51,6 +54,15 @@ facebook::jsi::Runtime &GetOrCreateContextRuntime(ReactContext const &context) n
|
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
return runtime;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Calls TryGetOrCreateContextRuntime to get JSI runtime.
|
|
61
|
+
// It crashes when TryGetOrCreateContextRuntime returns null.
|
|
62
|
+
// Note: deprecated in favor of TryGetOrCreateContextRuntime.
|
|
63
|
+
[[deprecated]] facebook::jsi::Runtime &GetOrCreateContextRuntime(ReactContext const &context) noexcept {
|
|
64
|
+
facebook::jsi::Runtime *runtime = TryGetOrCreateContextRuntime(context);
|
|
65
|
+
VerifyElseCrashSz(runtime, "JSI runtime is not available");
|
|
54
66
|
return *runtime;
|
|
55
67
|
}
|
|
56
68
|
|
|
@@ -7,26 +7,55 @@
|
|
|
7
7
|
|
|
8
8
|
#include "../ReactContext.h"
|
|
9
9
|
#include "JsiAbiApi.h"
|
|
10
|
+
#include "ReactPromise.h"
|
|
10
11
|
|
|
11
12
|
namespace winrt::Microsoft::ReactNative {
|
|
12
13
|
|
|
13
|
-
//
|
|
14
|
-
// If it is not found, then create it and store it in the context.Properties().
|
|
15
|
-
//
|
|
16
|
-
|
|
14
|
+
// Try to get JSI Runtime for the current JS dispatcher thread.
|
|
15
|
+
// If it is not found, then create it based on context JSI runtime and store it in the context.Properties().
|
|
16
|
+
// The function returns nullptr if the current context does not have JSI runtime.
|
|
17
|
+
// It makes sure that the JSI runtime holder is removed when the instance is unloaded.
|
|
18
|
+
facebook::jsi::Runtime *TryGetOrCreateContextRuntime(ReactContext const &context) noexcept;
|
|
19
|
+
|
|
20
|
+
// Calls TryGetOrCreateContextRuntime to get JSI runtime.
|
|
21
|
+
// It crashes when TryGetOrCreateContextRuntime returns null.
|
|
22
|
+
// Note: deprecated in favor of TryGetOrCreateContextRuntime.
|
|
23
|
+
[[deprecated]] facebook::jsi::Runtime &GetOrCreateContextRuntime(ReactContext const &context) noexcept;
|
|
17
24
|
|
|
18
25
|
// Call provided lambda with the facebook::jsi::Runtime& parameter.
|
|
19
26
|
// For example: ExecuteJsi(context, [](facebook::jsi::Runtime& runtime){...})
|
|
20
27
|
// The code is executed synchronously if it is already in JSDispatcher, or asynchronously otherwise.
|
|
21
28
|
template <class TCodeWithRuntime>
|
|
22
|
-
void ExecuteJsi(ReactContext const &context, TCodeWithRuntime const &code) {
|
|
29
|
+
void ExecuteJsi(ReactContext const &context, TCodeWithRuntime const &code, ReactPromise<void> *callStatus = nullptr) {
|
|
23
30
|
ReactDispatcher jsDispatcher = context.JSDispatcher();
|
|
31
|
+
auto callCode = [](ReactContext const &context, TCodeWithRuntime const &code, ReactPromise<void> *callStatus) {
|
|
32
|
+
facebook::jsi::Runtime *runtime = TryGetOrCreateContextRuntime(context);
|
|
33
|
+
if (runtime) {
|
|
34
|
+
code(*runtime);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Report status of the call
|
|
38
|
+
if (callStatus) {
|
|
39
|
+
if (runtime) {
|
|
40
|
+
callStatus->Resolve();
|
|
41
|
+
} else {
|
|
42
|
+
callStatus->Reject("No JSI runtime");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
24
47
|
if (jsDispatcher.HasThreadAccess()) {
|
|
25
48
|
// Execute immediately if we are in JS thread.
|
|
26
|
-
|
|
49
|
+
callCode(context, code, callStatus);
|
|
27
50
|
} else {
|
|
28
51
|
// Otherwise, schedule work in JS thread.
|
|
29
|
-
jsDispatcher.Post([
|
|
52
|
+
jsDispatcher.Post([callCode,
|
|
53
|
+
context,
|
|
54
|
+
code,
|
|
55
|
+
callStatus = callStatus ? std::make_unique<ReactPromise<void>>(*callStatus)
|
|
56
|
+
: std::unique_ptr<ReactPromise<void>>(nullptr)]() noexcept {
|
|
57
|
+
callCode(context, code, callStatus.get());
|
|
58
|
+
});
|
|
30
59
|
}
|
|
31
60
|
}
|
|
32
61
|
|
|
@@ -190,7 +190,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
|
|
|
190
190
|
facebook::jsi::Function createFunctionFromHostFunction(
|
|
191
191
|
const facebook::jsi::PropNameID &name,
|
|
192
192
|
unsigned int paramCount,
|
|
193
|
-
facebook::jsi::HostFunctionType
|
|
193
|
+
facebook::jsi::HostFunctionType func) override;
|
|
194
194
|
facebook::jsi::Value call(
|
|
195
195
|
const facebook::jsi::Function &func,
|
|
196
196
|
const facebook::jsi::Value &jsThis,
|
|
@@ -440,6 +440,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
|
|
|
440
440
|
|
|
441
441
|
private: // Shared NAPI call helpers
|
|
442
442
|
napi_value RunScript(napi_value script, const char *sourceUrl);
|
|
443
|
+
napi_value RunScriptBuffer(const std::shared_ptr<const facebook::jsi::Buffer> &buffer, const char *sourceUrl);
|
|
443
444
|
std::vector<uint8_t> SerializeScript(napi_value script, const char *sourceUrl);
|
|
444
445
|
napi_value RunSerializedScript(span<const uint8_t> serialized, napi_value source, const char *sourceUrl);
|
|
445
446
|
napi_ext_ref CreateReference(napi_value value) const;
|
|
@@ -475,7 +476,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
|
|
|
475
476
|
void SetProperty(napi_value object, napi_value propertyId, napi_value value, napi_property_attributes attrs) const;
|
|
476
477
|
napi_value CreateArray(size_t length) const;
|
|
477
478
|
void SetElement(napi_value array, uint32_t index, napi_value value) const;
|
|
478
|
-
static napi_value JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept;
|
|
479
|
+
static napi_value __cdecl JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept;
|
|
479
480
|
napi_value CreateExternalFunction(napi_value name, int32_t paramCount, napi_callback callback, void *callbackData);
|
|
480
481
|
napi_value CreateExternalObject(void *data, napi_finalize finalizeCallback) const;
|
|
481
482
|
template <typename T>
|
|
@@ -620,9 +621,7 @@ NapiJsiRuntime::NapiJsiRuntime(napi_env env) noexcept : m_env{env} {
|
|
|
620
621
|
|
|
621
622
|
Value NapiJsiRuntime::evaluateJavaScript(const shared_ptr<const Buffer> &buffer, const string &sourceUrl) {
|
|
622
623
|
EnvScope envScope{m_env};
|
|
623
|
-
napi_value
|
|
624
|
-
napi_value result = RunScript(script, sourceUrl.c_str());
|
|
625
|
-
|
|
624
|
+
napi_value result = RunScriptBuffer(buffer, sourceUrl.c_str());
|
|
626
625
|
return ToJsiValue(result);
|
|
627
626
|
}
|
|
628
627
|
|
|
@@ -1406,6 +1405,21 @@ napi_value NapiJsiRuntime::RunScript(napi_value script, const char *sourceUrl) {
|
|
|
1406
1405
|
return result;
|
|
1407
1406
|
}
|
|
1408
1407
|
|
|
1408
|
+
napi_value NapiJsiRuntime::RunScriptBuffer(
|
|
1409
|
+
const std::shared_ptr<const facebook::jsi::Buffer> &buffer,
|
|
1410
|
+
const char *sourceUrl) {
|
|
1411
|
+
napi_ext_buffer napiBuffer{};
|
|
1412
|
+
napiBuffer.buffer_object = NativeObjectWrapper<std::shared_ptr<const facebook::jsi::Buffer>>::Wrap(
|
|
1413
|
+
std::shared_ptr<const facebook::jsi::Buffer>{buffer});
|
|
1414
|
+
napiBuffer.data = buffer->data();
|
|
1415
|
+
napiBuffer.byte_size = buffer->size();
|
|
1416
|
+
|
|
1417
|
+
napi_value result{};
|
|
1418
|
+
CHECK_NAPI(napi_ext_run_script_buffer(m_env, &napiBuffer, sourceUrl, &result));
|
|
1419
|
+
|
|
1420
|
+
return result;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1409
1423
|
// Serializes script with the sourceUrl origin.
|
|
1410
1424
|
vector<uint8_t> NapiJsiRuntime::SerializeScript(napi_value script, const char *sourceUrl) {
|
|
1411
1425
|
vector<uint8_t> result;
|
|
@@ -1702,7 +1716,7 @@ void NapiJsiRuntime::SetElement(napi_value array, uint32_t index, napi_value val
|
|
|
1702
1716
|
}
|
|
1703
1717
|
|
|
1704
1718
|
// The NAPI external function callback used for the JSI host function implementation.
|
|
1705
|
-
/*static*/ napi_value NapiJsiRuntime::JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept {
|
|
1719
|
+
/*static*/ napi_value __cdecl NapiJsiRuntime::JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept {
|
|
1706
1720
|
HostFunctionWrapper *hostFuncWrapper{};
|
|
1707
1721
|
size_t argc{};
|
|
1708
1722
|
CHECK_NAPI_ELSE_CRASH(
|
|
@@ -1750,15 +1764,11 @@ napi_value NapiJsiRuntime::CreateExternalObject(void *data, napi_finalize finali
|
|
|
1750
1764
|
// Wraps up std::unique_ptr as an external object.
|
|
1751
1765
|
template <typename T>
|
|
1752
1766
|
napi_value NapiJsiRuntime::CreateExternalObject(unique_ptr<T> &&data) const {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
} else {
|
|
1759
|
-
delete static_cast<T *>(dataToDestroy);
|
|
1760
|
-
}
|
|
1761
|
-
});
|
|
1767
|
+
napi_finalize finalize = [](napi_env /*env*/, void *dataToDestroy, void * /*finalizerHint*/) {
|
|
1768
|
+
// We wrap dataToDestroy in a unique_ptr to avoid calling delete explicitly.
|
|
1769
|
+
unique_ptr<T> dataDeleter{static_cast<T *>(dataToDestroy)};
|
|
1770
|
+
};
|
|
1771
|
+
napi_value object = CreateExternalObject(data.get(), finalize);
|
|
1762
1772
|
|
|
1763
1773
|
// We only call data.release() after the CreateExternalObject succeeds.
|
|
1764
1774
|
// Otherwise, when CreateExternalObject fails and an exception is thrown,
|
|
@@ -1807,7 +1817,7 @@ napi_value NapiJsiRuntime::GetHostObjectProxyHandler() {
|
|
|
1807
1817
|
// Sets Proxy trap method as a pointer to NapiJsiRuntime instance method.
|
|
1808
1818
|
template <napi_value (NapiJsiRuntime::*trapMethod)(span<napi_value>), size_t argCount>
|
|
1809
1819
|
void NapiJsiRuntime::SetProxyTrap(napi_value handler, napi_value propertyName) {
|
|
1810
|
-
|
|
1820
|
+
napi_callback proxyTrap = [](napi_env env, napi_callback_info info) noexcept {
|
|
1811
1821
|
NapiJsiRuntime *runtime{};
|
|
1812
1822
|
napi_value args[argCount]{};
|
|
1813
1823
|
size_t actualArgCount{argCount};
|