react-native-windows 0.71.18 → 0.71.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 (52) hide show
  1. package/Directory.Build.props +0 -5
  2. package/Microsoft.ReactNative/IReactDispatcher.cpp +0 -4
  3. package/Microsoft.ReactNative/IReactDispatcher.h +0 -1
  4. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +4 -2
  5. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +11 -31
  6. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +2 -0
  7. package/Microsoft.ReactNative/Views/DevMenu.cpp +3 -3
  8. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +1 -1
  9. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +2103 -0
  10. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +73 -0
  11. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +12 -43
  12. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +6 -17
  13. package/Microsoft.ReactNative.Managed/packages.lock.json +2 -28
  14. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  15. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  16. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +1 -1
  17. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  18. package/PropertySheets/JSEngine.props +4 -4
  19. package/PropertySheets/React.Cpp.props +0 -1
  20. package/PropertySheets/Warnings.props +0 -6
  21. package/ReactCommon/ReactCommon.vcxproj +1 -53
  22. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +0 -36
  23. package/Shared/BaseScriptStoreImpl.cpp +42 -13
  24. package/Shared/DevSupportManager.cpp +9 -2
  25. package/Shared/DevSupportManager.h +6 -2
  26. package/Shared/Hasher.cpp +64 -0
  27. package/Shared/Hasher.h +24 -0
  28. package/Shared/HermesRuntimeHolder.cpp +84 -344
  29. package/Shared/HermesRuntimeHolder.h +21 -32
  30. package/Shared/HermesSamplingProfiler.cpp +14 -66
  31. package/Shared/HermesSamplingProfiler.h +3 -5
  32. package/Shared/HermesShim.cpp +118 -0
  33. package/Shared/HermesShim.h +21 -0
  34. package/Shared/InspectorPackagerConnection.cpp +108 -62
  35. package/Shared/InspectorPackagerConnection.h +21 -9
  36. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +209 -0
  37. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +44 -0
  38. package/Shared/JSI/RuntimeHolder.h +2 -2
  39. package/Shared/JSI/ScriptStore.h +20 -18
  40. package/Shared/OInstance.cpp +33 -17
  41. package/Shared/Shared.vcxitems +9 -19
  42. package/Shared/Shared.vcxitems.filters +31 -23
  43. package/Shared/V8JSIRuntimeHolder.cpp +70 -0
  44. package/Shared/V8JSIRuntimeHolder.h +53 -0
  45. package/package.json +2 -2
  46. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +1 -1
  47. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiLoader.cpp +0 -16
  48. package/ReactCommon/cgmanifest.json +0 -15
  49. package/Shared/JSI/V8RuntimeHolder.cpp +0 -262
  50. package/Shared/JSI/V8RuntimeHolder.h +0 -37
  51. package/Shared/SafeLoadLibrary.cpp +0 -41
  52. package/Shared/SafeLoadLibrary.h +0 -15
@@ -0,0 +1,73 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+ #ifndef MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
6
+ #define MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
7
+
8
+ // JSI
9
+ #include <js_native_ext_api.h>
10
+ #include <jsi/jsi.h>
11
+
12
+ // Standard Library
13
+ #include <memory>
14
+
15
+ namespace Microsoft::JSI {
16
+
17
+ ///
18
+ // NodeApiJsiRuntime factory function.
19
+ // TODO: Rename as MakeNapiJsiRuntime once code is dropped from V8-JSI.
20
+ ///
21
+ std::unique_ptr<facebook::jsi::Runtime> __cdecl MakeNodeApiJsiRuntime(napi_env env) noexcept;
22
+
23
+ template <typename T>
24
+ struct NativeObjectWrapper;
25
+
26
+ template <typename T>
27
+ struct NativeObjectWrapper<std::unique_ptr<T>> {
28
+ static napi_ext_native_data Wrap(std::unique_ptr<T> &&obj) noexcept {
29
+ napi_ext_native_data nativeData{};
30
+ nativeData.data = obj.release();
31
+ nativeData.finalize_cb = [](napi_env /*env*/, void *data, void * /*finalizeHint*/) {
32
+ std::unique_ptr<T> obj{reinterpret_cast<T *>(data)};
33
+ };
34
+ return nativeData;
35
+ }
36
+
37
+ static T *Unwrap(napi_ext_native_data &nativeData) noexcept {
38
+ return reinterpret_cast<T *>(nativeData.data);
39
+ }
40
+ };
41
+
42
+ template <typename T>
43
+ struct NativeObjectWrapper<std::shared_ptr<T>> {
44
+ static napi_ext_native_data Wrap(std::shared_ptr<T> &&obj) noexcept {
45
+ static_assert(
46
+ sizeof(SharedPtrHolder) == sizeof(std::shared_ptr<T>), "std::shared_ptr expected to have size of two pointers");
47
+ SharedPtrHolder ptrHolder;
48
+ new (std::addressof(ptrHolder)) std::shared_ptr(std::move(obj));
49
+ napi_ext_native_data nativeData{};
50
+ nativeData.data = ptrHolder.ptr1;
51
+ nativeData.finalize_hint = ptrHolder.ptr2;
52
+ nativeData.finalize_cb = [](napi_env /*env*/, void *data, void *finalizeHint) {
53
+ SharedPtrHolder ptrHolder{data, finalizeHint};
54
+ std::shared_ptr<T> obj(std::move(*reinterpret_cast<std::shared_ptr<T> *>(std::addressof(ptrHolder))));
55
+ };
56
+ return nativeData;
57
+ }
58
+
59
+ static std::shared_ptr<T> Unwrap(napi_ext_native_data &nativeData) noexcept {
60
+ SharedPtrHolder ptrHolder{nativeData.data, nativeData.finalize_hint};
61
+ return *reinterpret_cast<std::shared_ptr<T> *>(std::addressof(ptrHolder));
62
+ }
63
+
64
+ private:
65
+ struct SharedPtrHolder {
66
+ void *ptr1;
67
+ void *ptr2;
68
+ };
69
+ };
70
+
71
+ } // namespace Microsoft::JSI
72
+
73
+ #endif // MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
@@ -14,14 +14,6 @@
14
14
  <TurboModule_SourcePath Condition="'$(TurboModule_SourcePath)' == '' AND Exists('$(MSBuildThisFileDirectory)ReactCommon\TurboModule.h')">$(MSBuildThisFileDirectory)</TurboModule_SourcePath>
15
15
  <Bridging_SourcePath Condition="'$(Bridging_SourcePath)' == '' AND '$(ReactNativeDir)' != ''">$(ReactNativeDir)\ReactCommon\react\bridging</Bridging_SourcePath>
16
16
  <Bridging_SourcePath Condition="'$(Bridging_SourcePath)' == '' AND Exists('$(MSBuildThisFileDirectory)ReactCommon\CallbackWrapper.h')">$(MSBuildThisFileDirectory)ReactCommon</Bridging_SourcePath>
17
-
18
- <NodeApiJsiCommitHash>53b897b03c1c7e57c3372acc6234447a44e150d6</NodeApiJsiCommitHash>
19
- <NodeApiJsiLocal Condition="Exists('$(MSBuildThisFileDirectory)NodeApiJsiRuntime.cpp')">true</NodeApiJsiLocal>
20
- <NodeApiJsiDir Condition="'$(NodeApiJsiDir)' == '' AND '$(NodeApiJsiLocal)' == 'true'">$(MSBuildThisFileDirectory)</NodeApiJsiDir>
21
- <NodeApiJsiDir Condition="'$(NodeApiJsiDir)' == '' AND '$(ReactNativeDir)' != ''">$(ReactNativeDir)\..\..\node_modules\.node-api-jsi\node-api-jsi-$(NodeApiJsiCommitHash)\</NodeApiJsiDir>
22
- <NodeApiJsiSrcDir Condition="'$(NodeApiJsiSrcDir)' == '' AND '$(NodeApiJsiLocal)' != 'true'">$(NodeApiJsiDir)src\</NodeApiJsiSrcDir>
23
- <NodeApiJsiSrcDir Condition="'$(NodeApiJsiSrcDir)' == ''">$(MSBuildThisFileDirectory)</NodeApiJsiSrcDir>
24
- <NodeApiDir Condition="'$(NodeApiDir)' == ''">$(NodeApiJsiDir)node-api\</NodeApiDir>
25
17
  </PropertyGroup>
26
18
  <ItemDefinitionGroup>
27
19
  <ClCompile>
@@ -31,11 +23,8 @@
31
23
  $(CallInvoker_SourcePath);
32
24
  $(TurboModule_SourcePath);
33
25
  $(Bridging_SourcePath);
34
- $(NodeApiDir);
35
- $(NodeApiJsiSrcDir);
36
26
  %(AdditionalIncludeDirectories)
37
27
  </AdditionalIncludeDirectories>
38
- <PreprocessorDefinitions>JSI_VERSION=9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
39
28
  </ClCompile>
40
29
  <Midl>
41
30
  <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -51,6 +40,7 @@
51
40
  <ClInclude Include="$(MSBuildThisFileDirectory)CoreApp.h" />
52
41
  <ClInclude Include="$(MSBuildThisFileDirectory)DesktopWindowBridge.h" />
53
42
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\LongLivedJsiValue.h" />
43
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiRuntime.h" />
54
44
  <ClInclude Include="$(MSBuildThisFileDirectory)TurboModuleProvider.h" />
55
45
  <ClInclude Include="$(CallInvoker_SourcePath)\ReactCommon\CallInvoker.h" />
56
46
  <ClInclude Include="$(MSBuildThisFileDirectory)XamlUtils.h" />
@@ -100,14 +90,6 @@
100
90
  <ClInclude Include="$(MSBuildThisFileDirectory)UI.Xaml.Media.Media3D.h" />
101
91
  <ClInclude Include="$(MSBuildThisFileDirectory)UI.Xaml.Navigation.h" />
102
92
  <ClInclude Include="$(MSBuildThisFileDirectory)UI.Xaml.Shapes.h" />
103
- <ClInclude Include="$(NodeApiDir)js_native_api.h" />
104
- <ClInclude Include="$(NodeApiDir)js_native_api_types.h" />
105
- <ClInclude Include="$(NodeApiDir)js_runtime_api.h" />
106
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.h" />
107
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.inc" />
108
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.h" />
109
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.inc" />
110
- <ClInclude Include="$(NodeApiJsiSrcDir)NodeApiJsiRuntime.h" />
111
93
  </ItemGroup>
112
94
  <ItemGroup Condition="'$(BuildMSRNCxx)' != 'false'">
113
95
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\JsiAbiApi.cpp" />
@@ -120,18 +102,16 @@
120
102
  <ClCompile Include="$(MSBuildThisFileDirectory)ReactPromise.cpp" />
121
103
  <ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleProvider.cpp" />
122
104
  </ItemGroup>
123
- <ItemGroup Condition="'$(BuildMSRNCxxJsi)' != 'false'">
124
- <ClCompile Include="$(JSI_SourcePath)\jsi\jsi.cpp">
125
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
126
- <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
127
- </ClCompile>
128
- </ItemGroup>
129
- <ItemGroup Condition="'$(BuildMSRNCxxReactCommon)' != 'false'">
105
+ <ItemGroup Condition="'$(BuildMSRNCxx)' != 'false' and '$(BuildMSRNCxxReactCommon)' != 'false'">
130
106
  <!--
131
- Make sure all Meta code uses the same flags to improve build parallelism.
107
+ Make sure all FB code uses the same flags to improve build parallelism.
132
108
  This is because msbuild has to invoke different cl.exe invocations for each
133
109
  set of flags and msbuild inside a project is single threaded.
134
110
  -->
111
+ <ClCompile Include="$(JSI_SourcePath)\jsi\jsi.cpp">
112
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
113
+ <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
114
+ </ClCompile>
135
115
  <ClCompile Include="$(Bridging_SourcePath)\LongLivedObject.cpp">
136
116
  <PrecompiledHeader>NotUsing</PrecompiledHeader>
137
117
  <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
@@ -145,23 +125,12 @@
145
125
  <DisableSpecificWarnings>%(DisableSpecificWarnings);4100</DisableSpecificWarnings>
146
126
  </ClCompile>
147
127
  </ItemGroup>
148
- <ItemGroup Condition="'$(BuildMSRNCxxNodeApiJsi)' != 'false'">
149
- <ClCompile Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.cpp">
150
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
151
- </ClCompile>
152
- <ClCompile Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.cpp">
153
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
154
- </ClCompile>
155
- <ClCompile Include="$(NodeApiJsiSrcDir)NodeApiJsiRuntime.cpp">
156
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
157
- </ClCompile>
158
- </ItemGroup>
159
- <ItemGroup Condition="'$(BuildMSRNCxxNodeApiJsiLoader)' != 'false'">
160
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiLoader.cpp">
161
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
162
- </ClCompile>
163
- </ItemGroup>
164
128
  <ItemGroup>
165
129
  <None Include="$(MSBuildThisFileDirectory)README.md" />
166
130
  </ItemGroup>
131
+ <ItemGroup>
132
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiRuntime.cpp">
133
+ <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
134
+ </ClCompile>
135
+ </ItemGroup>
167
136
  </Project>
@@ -27,13 +27,10 @@
27
27
  <ClCompile Include="$(MSBuildThisFileDirectory)JSI\JsiApiContext.cpp">
28
28
  <Filter>JSI</Filter>
29
29
  </ClCompile>
30
- <ClCompile Include="$(Bridging_SourcePath)\LongLivedObject.cpp" />
31
- <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiLoader.cpp">
32
- <Filter>NodeApiJsi</Filter>
30
+ <ClCompile Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiRuntime.cpp">
31
+ <Filter>JSI</Filter>
33
32
  </ClCompile>
34
- <ClCompile Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.cpp" />
35
- <ClCompile Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.cpp" />
36
- <ClCompile Include="$(NodeApiJsiSrcDir)NodeApiJsiRuntime.cpp" />
33
+ <ClCompile Include="$(Bridging_SourcePath)\LongLivedObject.cpp" />
37
34
  </ItemGroup>
38
35
  <ItemGroup>
39
36
  <ClInclude Include="$(MSBuildThisFileDirectory)Crash.h" />
@@ -156,19 +153,14 @@
156
153
  <ClInclude Include="$(MSBuildThisFileDirectory)XamlUtils.h">
157
154
  <Filter>UI</Filter>
158
155
  </ClInclude>
156
+ <ClInclude Include="$(MSBuildThisFileDirectory)JSI\NodeApiJsiRuntime.h">
157
+ <Filter>JSI</Filter>
158
+ </ClInclude>
159
159
  <ClInclude Include="$(Bridging_SourcePath)\CallbackWrapper.h" />
160
160
  <ClInclude Include="$(MSBuildThisFileDirectory)CoreApp.h" />
161
161
  <ClInclude Include="$(MSBuildThisFileDirectory)JSI\LongLivedJsiValue.h">
162
162
  <Filter>TurboModule</Filter>
163
163
  </ClInclude>
164
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.h" />
165
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\NodeApi.inc" />
166
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.h" />
167
- <ClInclude Include="$(NodeApiJsiSrcDir)ApiLoaders\JSRuntimeApi.inc" />
168
- <ClInclude Include="$(NodeApiJsiSrcDir)NodeApiJsiRuntime.h" />
169
- <ClInclude Include="$(NodeApiDir)js_native_api.h" />
170
- <ClInclude Include="$(NodeApiDir)js_native_api_types.h" />
171
- <ClInclude Include="$(NodeApiDir)js_runtime_api.h" />
172
164
  </ItemGroup>
173
165
  <ItemGroup>
174
166
  <Filter Include="JSI">
@@ -180,9 +172,6 @@
180
172
  <Filter Include="TurboModule">
181
173
  <UniqueIdentifier>{b5c0294c-d72f-44fa-8509-369f7d3e4a56}</UniqueIdentifier>
182
174
  </Filter>
183
- <Filter Include="NodeApiJsi">
184
- <UniqueIdentifier>{a34cd50a-190c-4cbb-8fe1-6ff1e16fe389}</UniqueIdentifier>
185
- </Filter>
186
175
  </ItemGroup>
187
176
  <ItemGroup>
188
177
  <None Include="$(MSBuildThisFileDirectory)README.md" />
@@ -24,21 +24,11 @@
24
24
  "Microsoft.SourceLink.Common": "1.0.0"
25
25
  }
26
26
  },
27
- "boost": {
28
- "type": "Transitive",
29
- "resolved": "1.76.0",
30
- "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
31
- },
32
27
  "Microsoft.Build.Tasks.Git": {
33
28
  "type": "Transitive",
34
29
  "resolved": "1.0.0",
35
30
  "contentHash": "z2fpmmt+1Jfl+ZnBki9nSP08S1/tbEOxFdsK1rSR+LBehIJz1Xv9/6qOOoGNqlwnAGGVGis1Oj6S8Kt9COEYlQ=="
36
31
  },
37
- "Microsoft.JavaScript.Hermes": {
38
- "type": "Transitive",
39
- "resolved": "0.1.15",
40
- "contentHash": "My/u5RvxoymtwWokoweU6iVpuP79w271UjadcmSNqnQ9ESIv00tlVP4sHnIiN3t2lJNDeciyE1EVF4swGPECKQ=="
41
- },
42
32
  "Microsoft.Net.Native.Compiler": {
43
33
  "type": "Transitive",
44
34
  "resolved": "2.2.7-rel-27913-00",
@@ -70,16 +60,6 @@
70
60
  "resolved": "1.0.0",
71
61
  "contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
72
62
  },
73
- "Microsoft.UI.Xaml": {
74
- "type": "Transitive",
75
- "resolved": "2.7.0",
76
- "contentHash": "dB4im13tfmMgL/V3Ei+3kD2rUF+/lTxAmR4gjJ45l577eljHfdo/KUrxpq/3I1Vp6e5GCDG1evDaEGuDxypLMg=="
77
- },
78
- "Microsoft.Windows.SDK.BuildTools": {
79
- "type": "Transitive",
80
- "resolved": "10.0.22000.194",
81
- "contentHash": "4L0P3zqut466SIqT3VBeLTNUQTxCBDOrTRymRuROCRJKazcK7ibLz9yAO1nKWRt50ttCj39oAa2Iuz9ZTDmLlg=="
82
- },
83
63
  "NETStandard.Library": {
84
64
  "type": "Transitive",
85
65
  "resolved": "2.0.3",
@@ -164,7 +144,6 @@
164
144
  "folly": {
165
145
  "type": "Project",
166
146
  "dependencies": {
167
- "boost": "[1.76.0, )",
168
147
  "fmt": "[1.0.0, )"
169
148
  }
170
149
  },
@@ -173,18 +152,13 @@
173
152
  "dependencies": {
174
153
  "Common": "[1.0.0, )",
175
154
  "Folly": "[1.0.0, )",
176
- "Microsoft.JavaScript.Hermes": "[0.1.15, )",
177
- "Microsoft.UI.Xaml": "[2.7.0, )",
178
- "Microsoft.Windows.SDK.BuildTools": "[10.0.22000.194, )",
179
- "ReactCommon": "[1.0.0, )",
180
- "boost": "[1.76.0, )"
155
+ "ReactCommon": "[1.0.0, )"
181
156
  }
182
157
  },
183
158
  "reactcommon": {
184
159
  "type": "Project",
185
160
  "dependencies": {
186
- "Folly": "[1.0.0, )",
187
- "boost": "[1.76.0, )"
161
+ "Folly": "[1.0.0, )"
188
162
  }
189
163
  }
190
164
  },
@@ -19,7 +19,7 @@
19
19
  <!-- WinUI package name and version are set by WinUI.props -->
20
20
  <PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" Condition="'$(OverrideWinUIPackage)'!='true'" />
21
21
  <!-- Hermes version is set by JSEngine.props -->
22
- <PackageReference Include="Microsoft.JavaScript.Hermes" Version="$(HermesVersion)" Condition="$(UseHermes)" />
22
+ <PackageReference Include="ReactNative.Hermes.Windows" Version="$(HermesVersion)" Condition="$(UseHermes)" />
23
23
  </ItemGroup>
24
24
 
25
25
  <Import Project="$(ReactNativeWindowsDir)PropertySheets\ManagedCodeGen\Microsoft.ReactNative.Managed.CodeGen.targets"
@@ -19,7 +19,7 @@
19
19
  <!-- WinUI package name and version are set by WinUI.props -->
20
20
  <PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" Condition="'$(OverrideWinUIPackage)'!='true'" />
21
21
  <!-- Hermes version is set by JSEngine.props -->
22
- <PackageReference Include="Microsoft.JavaScript.Hermes" Version="$(HermesVersion)" Condition="$(UseHermes)" />
22
+ <PackageReference Include="ReactNative.Hermes.Windows" Version="$(HermesVersion)" Condition="$(UseHermes)" />
23
23
  </ItemGroup>
24
24
 
25
25
  <!-- The props file for bundling is not set up to be just defaults, it assumes to be run at the end of the project. -->
@@ -24,7 +24,7 @@
24
24
  <!-- WinUI package name and version are set by WinUI.props -->
25
25
  <PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" Condition="'$(OverrideWinUIPackage)'!='true'" />
26
26
  <!-- Hermes version is set by JSEngine.props -->
27
- <PackageReference Include="Microsoft.JavaScript.Hermes" Version="$(HermesVersion)" Condition="$(UseHermes)" />
27
+ <PackageReference Include="ReactNative.Hermes.Windows" Version="$(HermesVersion)" Condition="$(UseHermes)" />
28
28
  </ItemGroup>
29
29
 
30
30
  <!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.71.18</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.71.20</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>71</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>18</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>20</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>7a340bdc0265c205c6b21266fb43b4eb3fd6bba1</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>fbe998224a24862ab7ac61ba86a817c89476fdfa</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
@@ -14,9 +14,9 @@
14
14
  <!-- Enabling this will (1) Include hermes glues in the Microsoft.ReactNative binaries AND (2) Make hermes the default engine -->
15
15
  <UseHermes Condition="'$(UseHermes)' == ''">false</UseHermes>
16
16
  <!-- This will be true if (1) the client want to use hermes by setting UseHermes to true OR (2) We are building for UWP where dynamic switching is enabled -->
17
- <HermesVersion Condition="'$(HermesVersion)' == ''">0.1.15</HermesVersion>
18
- <HermesPackage Condition="'$(HermesPackage)' == '' And Exists('$(PkgMicrosoft_JavaScript_Hermes)')">$(PkgMicrosoft_JavaScript_Hermes)</HermesPackage>
19
- <HermesPackage Condition="'$(HermesPackage)' == ''">$(NuGetPackageRoot)\Microsoft.JavaScript.Hermes\$(HermesVersion)</HermesPackage>
17
+ <HermesVersion Condition="'$(HermesVersion)' == ''">0.71.1</HermesVersion>
18
+ <HermesPackage Condition="'$(HermesPackage)' == '' And Exists('$(PkgReactNative_Hermes_Windows)')">$(PkgReactNative_Hermes_Windows)</HermesPackage>
19
+ <HermesPackage Condition="'$(HermesPackage)' == ''">$(NuGetPackageRoot)\ReactNative.Hermes.Windows\$(HermesVersion)</HermesPackage>
20
20
  <EnableHermesInspectorInReleaseFlavor Condition="'$(EnableHermesInspectorInReleaseFlavor)' == ''">false</EnableHermesInspectorInReleaseFlavor>
21
21
  <!-- Disable linking Hermes into the output in cases where we need to fully rely on HermesShim -->
22
22
  <HermesNoLink Condition="'$(HermesNoLink)' == '' and '$(Configuration)' == 'Release' and '$(EnableHermesInspectorInReleaseFlavor)' != 'true'">true</HermesNoLink>
@@ -24,7 +24,7 @@
24
24
  <EnableDevServerHBCBundles Condition="'$(EnableDevServerHBCBundles)' == ''">false</EnableDevServerHBCBundles>
25
25
 
26
26
  <UseV8 Condition="'$(UseV8)' == ''">false</UseV8>
27
- <V8Version Condition="'$(V8Version)' == ''">0.71.5</V8Version>
27
+ <V8Version Condition="'$(V8Version)' == ''">0.71.3</V8Version>
28
28
  <V8PackageName>ReactNative.V8Jsi.Windows</V8PackageName>
29
29
  <V8PackageName Condition="'$(V8AppPlatform)' != 'win32'">$(V8PackageName).UWP</V8PackageName>
30
30
  <V8Package>$(NuGetPackageRoot)\$(V8PackageName).$(V8Version)</V8Package>
@@ -57,7 +57,6 @@
57
57
  <PreprocessorDefinitions Condition="'$(EnableDevServerHBCBundles)'=='true'">ENABLE_DEVSERVER_HBCBUNDLES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
58
58
  <PreprocessorDefinitions Condition="'$(UseV8)'=='true'">USE_V8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
59
59
  <PreprocessorDefinitions Condition="'$(UseFabric)'=='true'">USE_FABRIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
60
- <PreprocessorDefinitions>JSI_VERSION=9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
61
60
  </ClCompile>
62
61
  </ItemDefinitionGroup>
63
62
 
@@ -34,12 +34,6 @@
34
34
  <TreatWarningAsError>true</TreatWarningAsError>
35
35
  <WarningLevel>Level4</WarningLevel>
36
36
  </ClCompile>
37
- <Link>
38
- <!--
39
- LNK4199: /DELAYLOAD:v8jsi.dll ignored; no imports found from v8jsi.dll
40
- -->
41
- <AdditionalOptions>/ignore:4199 %(AdditionalOptions)</AdditionalOptions>
42
- </Link>
43
37
  </ItemDefinitionGroup>
44
38
 
45
39
  </Project>
@@ -106,7 +106,6 @@
106
106
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\cxxreact\SystraceSection.h" />
107
107
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.h" />
108
108
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.h" />
109
- <ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector\InspectorInterfaces.h" />
110
109
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.h" />
111
110
  <ClInclude Include="$(YogaDir)\yoga\YGEnums.h" />
112
111
  <ClInclude Include="$(YogaDir)\yoga\YGMacros.h" />
@@ -128,7 +127,6 @@
128
127
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsi\jsi\JSIDynamic.cpp" />
129
128
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.cpp" />
130
129
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.cpp" />
131
- <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector\InspectorInterfaces.cpp" />
132
130
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.cpp" />
133
131
  <CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\reactperflogger\BridgeNativeModulePerfLogger.cpp" />
134
132
  <ClCompile Include="$(YogaDir)\yoga\log.cpp" />
@@ -180,52 +178,6 @@
180
178
  <ItemGroup>
181
179
  <PackageReference Include="boost" Version="1.76.0.0" />
182
180
  </ItemGroup>
183
- <PropertyGroup>
184
- <NodeApiJsiZipDir>$(NodeApiJsiDir)..\.node-api-jsi-zip</NodeApiJsiZipDir>
185
- <NodeApiJsiZipFile>$(NodeApiJsiZipDir)\node-api-jsi-$(NodeApiJsiCommitHash).zip</NodeApiJsiZipFile>
186
- <CGManifestFile>$(MSBuildThisFileDirectory)cgmanifest.json</CGManifestFile>
187
- </PropertyGroup>
188
- <Target Name="DownloadNodeApiJsi" BeforeTargets="PrepareForBuild" Inputs="$(NodeApiJsiZipFile)" Outputs="$(NodeApiJsiZipFile)">
189
- <Message Text="Downloading node-api-jsi..." Importance="High" />
190
- <DownloadFile
191
- SourceUrl="https://github.com/microsoft/node-api-jsi/archive/$(NodeApiJsiCommitHash).zip"
192
- DestinationFileName="$(NodeApiJsiZipFile)"
193
- DestinationFolder="$(NodeApiJsiZipDir)"
194
- Retries="10" />
195
- </Target>
196
- <Target Name="UnzipNodeApiJsi" BeforeTargets="PrepareForBuild" DependsOnTargets="DownloadNodeApiJsi">
197
- <Message Text="Unzipping node-api-jsi to $([MSBuild]::NormalizePath($(NodeApiJsiDir)..))." Importance="High"
198
- Condition="!Exists('$(NodeApiJsiDir)src\NodeApiJsiRuntime.h')" />
199
- <Unzip
200
- Condition="!Exists('$(NodeApiJsiDir)src\NodeApiJsiRuntime.h')"
201
- SourceFiles="$(NodeApiJsiZipFile)"
202
- DestinationFolder="$([MSBuild]::NormalizePath($(NodeApiJsiDir)..))"
203
- OverwriteReadOnlyFiles="true" />
204
- </Target>
205
- <Target Name="WriteCGManifest" BeforeTargets="PrepareForBuild" DependsOnTargets="DownloadNodeApiJsi" Inputs="$(NodeApiJsiZipFile)" Outputs="$(CGManifestFile)">
206
- <PropertyGroup>
207
- <CGManifestText>{
208
- "$schema": "https://json.schemastore.org/component-detection-manifest.json",
209
- "Registrations": [
210
- {
211
- "Component": {
212
- "Type": "git",
213
- "Git": {
214
- "RepositoryUrl": "https://github.com/microsoft/node-api-jsi",
215
- "CommitHash": "$(NodeApiJsiCommitHash)"
216
- }
217
- },
218
- "DevelopmentDependency": false
219
- }
220
- ]
221
- }</CGManifestText>
222
- </PropertyGroup>
223
- <Message Text="Generating $(CGManifestFile)." Importance="High" />
224
- <WriteLinesToFile
225
- File="$(CGManifestFile)"
226
- Overwrite="true"
227
- Lines="$(CGManifestText)" />
228
- </Target>
229
181
  <Target Name="EnsureNodeModuleBuildImports" BeforeTargets="PrepareForBuild">
230
182
  <Error Condition="!Exists('$(ReactNativeDir)')" Text="This project references code in the node_modules folder that is missing on this computer. Use `yarn install` to download them." />
231
183
  <Error Condition="!Exists('$(YogaDir)')" Text="This project references code in the node_modules folder that is missing on this computer. Use `yarn install` to download them." />
@@ -235,11 +187,7 @@
235
187
  </ItemGroup>
236
188
  <Target Name="Deploy" />
237
189
  <!-- Reenable this task if we need to temporarily replace any folly files for fixes, while we wait for PRs to land in folly -->
238
- <Target Name="ApplyReactCommonTemporaryPatch" BeforeTargets="PrepareForBuild" DependsOnTargets="UnzipNodeApiJsi">
239
- <ItemGroup>
240
- <NodeApiJsiFiles Include="$([MSBuild]::NormalizePath($(NodeApiJsiDir)))\jsi\**\*.*" />
241
- </ItemGroup>
242
- <Copy DestinationFiles="@(NodeApiJsiFiles->'$(ReactNativeDir)\ReactCommon\jsi\%(RecursiveDir)%(Filename)%(Extension)')" SourceFiles="@(NodeApiJsiFiles)" />
190
+ <Target Name="ApplyReactCommonTemporaryPatch" BeforeTargets="PrepareForBuild">
243
191
  <Copy DestinationFiles="@(TemporaryReactCommonPatchFiles->'$(ReactNativeDir)\ReactCommon\%(RecursiveDir)%(Filename)%(Extension)')" SourceFiles="@(TemporaryReactCommonPatchFiles)" />
244
192
  </Target>
245
193
  </Project>
@@ -15,23 +15,6 @@ Write-Host "Destination root: [$TargetRoot]"
15
15
  Write-Host "React Native root: [$ReactNativeRoot]"
16
16
  Write-Host "ReactCommon Override root: [$ReactCommonOverrideRoot]"
17
17
 
18
- [xml]$props = gc $PSScriptRoot\..\..\Directory.Build.props
19
- [string] $NodeApiJsiCommitHash = $props.Project.PropertyGroup.NodeApiJsiCommitHash;
20
- $NodeApiJsiCommitHash = $NodeApiJsiCommitHash.Trim()
21
- $NodeApiJsiRoot = "$SourceRoot\node_modules\.node-api-jsi\node-api-jsi-${NodeApiJsiCommitHash}";
22
- Write-Host "Node-API JSI root: [$NodeApiJsiRoot]"
23
-
24
- # Download Node-API JSI if running on a machine which hasn't run native build logic to acquire it
25
- if (!(Test-Path $NodeApiJsiRoot)) {
26
- Write-Host "Downloading Node-API JSI $NodeApiJsiCommitHash"
27
- $NodeApiJsiZip = "$SourceRoot\node_modules\.node-api-jsi\node-api-jsi-${NodeApiJsiCommitHash}.zip"
28
- $NodeApiJsiDest = "$SourceRoot\node_modules\.node-api-jsi"
29
-
30
- New-Item $NodeApiJsiRoot -ItemType Directory
31
- Invoke-RestMethod -Uri "https://github.com/microsoft/node-api-jsi/archive/${NodeApiJsiCommitHash}.zip" -OutFile $NodeApiJsiZip
32
- Expand-Archive -LiteralPath $NodeApiJsiZip -DestinationPath $NodeApiJsiDest
33
- }
34
-
35
18
  md -Force $TargetRoot
36
19
 
37
20
  $patterns = $Extensions| ForEach-Object {"*.$_"}
@@ -56,25 +39,6 @@ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\jsi.h -Destination $
56
39
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\jsi-inl.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
57
40
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\jsi\jsi\threadsafe.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\jsi\
58
41
 
59
- # Microsoft.ReactNative.CXX project Node-API files
60
- New-Item $TargetRoot\Microsoft.ReactNative.Cxx\node-api -ItemType Directory -Force
61
- Copy-Item -Force -Path $NodeApiJsiRoot\node-api\js_native_api.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\node-api\
62
- Copy-Item -Force -Path $NodeApiJsiRoot\node-api\js_native_api_types.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\node-api\
63
- Copy-Item -Force -Path $NodeApiJsiRoot\node-api\js_runtime_api.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\node-api\
64
-
65
- # Microsoft.ReactNative.CXX project Node-API JSI files
66
- New-Item $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders -ItemType Directory -Force
67
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\JSRuntimeApi.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
68
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\JSRuntimeApi.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
69
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\JSRuntimeApi.inc -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
70
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\NodeApi.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
71
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\NodeApi.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
72
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\NodeApi.inc -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
73
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\NodeApi_posix.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
74
- Copy-Item -Force -Path $NodeApiJsiRoot\src\ApiLoaders\NodeApi_win.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ApiLoaders\
75
- Copy-Item -Force -Path $NodeApiJsiRoot\src\NodeApiJsiRuntime.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\
76
- Copy-Item -Force -Path $NodeApiJsiRoot\src\NodeApiJsiRuntime.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\
77
-
78
42
  # Microsoft.ReactNative.CXX project TurboModule files
79
43
  New-Item -ItemType Directory -Path $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon -Force
80
44
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\callinvoker\ReactCommon\CallInvoker.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
@@ -4,6 +4,7 @@
4
4
  #include "pch.h"
5
5
 
6
6
  #include "BaseScriptStoreImpl.h"
7
+ #include "Hasher.h"
7
8
  #include "MemoryMappedBuffer.h"
8
9
 
9
10
  #include <CppRuntimeOptions.h>
@@ -92,6 +93,7 @@ struct PreparedScriptPrefix {
92
93
  jsi::ScriptVersion_t scriptVersion;
93
94
  jsi::JSRuntimeVersion_t runtimeVersion;
94
95
  uint64_t sizeInBytes;
96
+ std::uint8_t hash[32];
95
97
  };
96
98
 
97
99
  struct PreparedScriptSuffix {
@@ -197,40 +199,40 @@ std::string BasePreparedScriptStoreImpl::getPreparedScriptFileName(
197
199
  // Essentially, we are trying to construct,
198
200
  // prep_<source_url>_<runtime_id>_<preparation_tag>.cache
199
201
 
200
- std::string prparedScriptFileName("prep_");
202
+ std::string preparedScriptFileName("prep_");
201
203
 
202
204
  const std::string &scriptUrl = scriptSignature.url;
203
205
 
204
206
  // As a crude heuristic we choose the last 64 characters of the source url.
205
207
  constexpr int MAXLENGTH = 64;
206
- prparedScriptFileName.append(
208
+ preparedScriptFileName.append(
207
209
  scriptUrl.begin() + ((scriptUrl.size() < MAXLENGTH) ? 0 : (scriptUrl.size() - MAXLENGTH)), scriptUrl.end());
208
210
 
209
211
  // Make a valid file name.
210
- std::replace(prparedScriptFileName.begin(), prparedScriptFileName.end(), '\\', '_');
211
- std::replace(prparedScriptFileName.begin(), prparedScriptFileName.end(), '/', '_');
212
- std::replace(prparedScriptFileName.begin(), prparedScriptFileName.end(), ':', '_');
213
- std::replace(prparedScriptFileName.begin(), prparedScriptFileName.end(), '.', '_');
212
+ std::replace(preparedScriptFileName.begin(), preparedScriptFileName.end(), '\\', '_');
213
+ std::replace(preparedScriptFileName.begin(), preparedScriptFileName.end(), '/', '_');
214
+ std::replace(preparedScriptFileName.begin(), preparedScriptFileName.end(), ':', '_');
215
+ std::replace(preparedScriptFileName.begin(), preparedScriptFileName.end(), '.', '_');
214
216
 
215
217
  if (runtimeSignature.runtimeName.empty()) {
216
218
  std::terminate();
217
219
  }
218
220
 
219
- prparedScriptFileName.append("_");
220
- prparedScriptFileName.append(runtimeSignature.runtimeName);
221
+ preparedScriptFileName.append("_");
222
+ preparedScriptFileName.append(runtimeSignature.runtimeName);
221
223
 
222
224
  if (prepareTag) {
223
- prparedScriptFileName.append("_");
224
- prparedScriptFileName.append(prepareTag);
225
+ preparedScriptFileName.append("_");
226
+ preparedScriptFileName.append(prepareTag);
225
227
  }
226
228
 
227
- // TODO :: Need to constuct a hash. ref:
229
+ // TODO :: Need to construct a hash. ref:
228
230
  // https://en.wikipedia.org/wiki/Base64#Filenames
229
231
 
230
232
  // extension
231
- prparedScriptFileName.append(".cache");
233
+ preparedScriptFileName.append(".cache");
232
234
 
233
- return prparedScriptFileName;
235
+ return preparedScriptFileName;
234
236
  }
235
237
 
236
238
  std::shared_ptr<const jsi::Buffer> BasePreparedScriptStoreImpl::tryGetPreparedScript(
@@ -269,6 +271,24 @@ std::shared_ptr<const jsi::Buffer> BasePreparedScriptStoreImpl::tryGetPreparedSc
269
271
  return nullptr;
270
272
  }
271
273
 
274
+ std::optional<std::vector<std::uint8_t>> hashBuffer = Microsoft::ReactNative::GetSHA256Hash(
275
+ reinterpret_cast<const std::uint8_t *>(buffer->data()) + sizeof(PreparedScriptPrefix),
276
+ static_cast<size_t>(prefix->sizeInBytes));
277
+ if (!hashBuffer) {
278
+ // Hashing failed.
279
+ return nullptr;
280
+ }
281
+
282
+ if (hashBuffer.value().size() < sizeof(prefix->hash)) {
283
+ // Unexpected hash size.
284
+ return nullptr;
285
+ }
286
+
287
+ if (memcmp(hashBuffer.value().data(), prefix->hash, sizeof(prefix->hash)) != 0) {
288
+ // Hash doesn't match. Store is possibly corrupted. It is safer to bail out.
289
+ return nullptr;
290
+ }
291
+
272
292
  const PreparedScriptSuffix *suffix = reinterpret_cast<const PreparedScriptSuffix *>(
273
293
  buffer->data() + sizeof(PreparedScriptPrefix) + prefix->sizeInBytes);
274
294
  if (strncmp(suffix->eof, PERSIST_EOF, sizeof(suffix->eof)) != 0) {
@@ -297,6 +317,15 @@ void BasePreparedScriptStoreImpl::persistPreparedScript(
297
317
  prefix->runtimeVersion = runtimeMetadata.version;
298
318
  prefix->sizeInBytes = preparedScript->size();
299
319
 
320
+ std::optional<std::vector<std::uint8_t>> hashBuffer =
321
+ Microsoft::ReactNative::GetSHA256Hash(preparedScript->data(), preparedScript->size());
322
+ if (!hashBuffer) {
323
+ // Hashing failed.
324
+ std::terminate();
325
+ }
326
+
327
+ memcpy_s(prefix->hash, sizeof(prefix->hash), hashBuffer.value().data(), hashBuffer.value().size());
328
+
300
329
  memcpy_s(
301
330
  newBuffer->data() + sizeof(PreparedScriptPrefix),
302
331
  newBuffer->size() - sizeof(PreparedScriptPrefix),