react-native-windows 0.66.0 → 0.66.4

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 (44) hide show
  1. package/CHANGELOG.json +103 -1
  2. package/CHANGELOG.md +43 -4
  3. package/Chakra/Chakra.vcxitems +0 -1
  4. package/Chakra/Chakra.vcxitems.filters +0 -3
  5. package/Chakra/ChakraHelpers.cpp +0 -267
  6. package/Chakra/ChakraInstanceArgs.h +0 -5
  7. package/Chakra/ChakraPlatform.h +0 -4
  8. package/Chakra/ChakraTracing.cpp +0 -33
  9. package/Chakra/ChakraValue.h +0 -4
  10. package/Chakra/Utf8DebugExtensions.cpp +0 -5
  11. package/Chakra/Utf8DebugExtensions.h +0 -6
  12. package/Libraries/AppTheme/AppTheme.d.ts +3 -2
  13. package/Libraries/AppTheme/AppTheme.js +20 -2
  14. package/Libraries/AppTheme/AppTheme.js.map +1 -1
  15. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +3 -3
  16. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +3 -5
  17. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +0 -4
  18. package/Microsoft.ReactNative/ReactRootView.cpp +28 -3
  19. package/Microsoft.ReactNative/ReactRootView.h +6 -0
  20. package/Microsoft.ReactNative/Version.rc +1 -1
  21. package/Microsoft.ReactNative/Views/DevMenu.cpp +0 -1
  22. package/Microsoft.ReactNative/Views/RootViewManager.cpp +8 -9
  23. package/PropertySheets/JSEngine.props +0 -3
  24. package/PropertySheets/React.Cpp.props +2 -1
  25. package/Scripts/Microsoft.ReactNative.targets +1 -1
  26. package/Shared/HermesRuntimeHolder.cpp +3 -1
  27. package/Shared/HermesSamplingProfiler.cpp +6 -7
  28. package/Shared/HermesShim.cpp +85 -0
  29. package/Shared/HermesShim.h +19 -0
  30. package/Shared/JSI/ChakraApi.cpp +1 -37
  31. package/Shared/JSI/ChakraApi.h +0 -4
  32. package/Shared/JSI/ChakraJsiRuntime_edgemode.cpp +1 -5
  33. package/Shared/JSI/ChakraRuntime.cpp +0 -12
  34. package/Shared/JSI/ChakraRuntimeFactory.h +0 -2
  35. package/Shared/OInstance.cpp +12 -29
  36. package/Shared/Shared.vcxitems +5 -10
  37. package/Shared/Shared.vcxitems.filters +6 -3
  38. package/package.json +3 -3
  39. package/template/metro.config.js +8 -1
  40. package/template/metro.devMode.config.js +3 -1
  41. package/Chakra/ChakraCoreDebugger.h +0 -147
  42. package/Scripts/Microsoft.ChakraCore.ARM64.nuspec +0 -50
  43. package/Scripts/Microsoft.ChakraCore.ARM64.targets +0 -15
  44. package/Shared/JSI/ChakraCoreRuntime.h +0 -59
package/CHANGELOG.json CHANGED
@@ -2,7 +2,109 @@
2
2
  "name": "react-native-windows",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 11 Oct 2021 15:06:48 GMT",
5
+ "date": "Mon, 15 Nov 2021 16:09:26 GMT",
6
+ "tag": "react-native-windows_v0.66.4",
7
+ "version": "0.66.4",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Fix crash loading bundle in win32",
12
+ "author": "julio.rocha@microsoft.com",
13
+ "commit": "9fded4d64856fc7ab1df0040a79466afff3d52fd",
14
+ "package": "react-native-windows"
15
+ },
16
+ {
17
+ "comment": "Drop ChakraCore dependency (#9056)",
18
+ "author": "julio.rocha@microsoft.com",
19
+ "commit": "ba708e10314005ab6a59b1b17cb58675e80729f9",
20
+ "package": "react-native-windows"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Mon, 01 Nov 2021 19:10:27 GMT",
27
+ "tag": "react-native-windows_v0.66.3",
28
+ "version": "0.66.3",
29
+ "comments": {
30
+ "patch": [
31
+ {
32
+ "comment": "Fix Microsoft.ReactNative.dll version string",
33
+ "author": "asklar@microsoft.com",
34
+ "commit": "61da34482a055ee52ba23b826d154a7a9fbf0bee",
35
+ "package": "react-native-windows"
36
+ },
37
+ {
38
+ "comment": "Fix crash when using TextInput.blur()",
39
+ "author": "30809111+acoates-ms@users.noreply.github.com",
40
+ "commit": "da602613ebf5593feebb432bffd8a14f0679f2cc",
41
+ "package": "react-native-windows"
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "date": "Mon, 25 Oct 2021 15:07:26 GMT",
48
+ "tag": "react-native-windows_v0.66.2",
49
+ "version": "0.66.2",
50
+ "comments": {
51
+ "patch": [
52
+ {
53
+ "comment": "Add more symbols to Hermes DLL Loader Shim",
54
+ "author": "ngerlem@microsoft.com",
55
+ "commit": "fb9caf3b0384f30a615c4ece8e79f335bbbb4e33",
56
+ "package": "react-native-windows"
57
+ },
58
+ {
59
+ "comment": "Fix win32 apps referencing the M.RN nuget package so they can use RNW",
60
+ "author": "asklar@microsoft.com",
61
+ "commit": "4963656efc29f87d6850186b220563086ded4bc2",
62
+ "package": "react-native-windows"
63
+ },
64
+ {
65
+ "comment": "Fix EBUSY race conditions between metro bundler and msbuild",
66
+ "author": "dannyvv@microsoft.com",
67
+ "commit": "7e93fce8ba42bbd170995c114c65c9aa120dc68b",
68
+ "package": "react-native-windows"
69
+ },
70
+ {
71
+ "comment": "Fix crash when direct debugging Chakra",
72
+ "author": "anandrag@microsoft.com",
73
+ "commit": "1314dbfb3268b9919adb1c125f91f2dddd82690b",
74
+ "package": "react-native-windows"
75
+ },
76
+ {
77
+ "comment": "Fix AppTheme Regressions",
78
+ "author": "ngerlem@microsoft.com",
79
+ "commit": "d86d0d22a59a84ae9984378cb6aa239bfbe2031f",
80
+ "package": "react-native-windows"
81
+ }
82
+ ]
83
+ }
84
+ },
85
+ {
86
+ "date": "Mon, 18 Oct 2021 15:08:36 GMT",
87
+ "tag": "react-native-windows_v0.66.1",
88
+ "version": "0.66.1",
89
+ "comments": {
90
+ "patch": [
91
+ {
92
+ "comment": "Fix WACK for apps not packaging hermes.dll",
93
+ "author": "ngerlem@microsoft.com",
94
+ "commit": "dc11d60eef65114d80fc92e8c7f19c24f3dbacc9",
95
+ "package": "react-native-windows"
96
+ },
97
+ {
98
+ "comment": "Loosen RN peer dependency",
99
+ "author": "ngerlem@microsoft.com",
100
+ "commit": "6c37292c2a955bdffedc5dbd89eb4225c24582df",
101
+ "package": "react-native-windows"
102
+ }
103
+ ]
104
+ }
105
+ },
106
+ {
107
+ "date": "Mon, 11 Oct 2021 15:07:19 GMT",
6
108
  "tag": "react-native-windows_v0.66.0",
7
109
  "version": "0.66.0",
8
110
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,56 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 11 Oct 2021 15:06:48 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 15 Nov 2021 16:09:26 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.66.0
7
+ ## 0.66.4
8
8
 
9
- Mon, 11 Oct 2021 15:06:48 GMT
9
+ Mon, 15 Nov 2021 16:09:26 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Promote 0.66 to latest (ngerlem@microsoft.com)
13
+ - Fix crash loading bundle in win32 (julio.rocha@microsoft.com)
14
+ - Drop ChakraCore dependency (#9056) (julio.rocha@microsoft.com)
14
15
 
16
+ ## 0.66.3
17
+
18
+ Mon, 01 Nov 2021 19:10:27 GMT
19
+
20
+ ### Patches
21
+
22
+ - Fix Microsoft.ReactNative.dll version string (asklar@microsoft.com)
23
+ - Fix crash when using TextInput.blur() (30809111+acoates-ms@users.noreply.github.com)
24
+
25
+ ## 0.66.2
26
+
27
+ Mon, 25 Oct 2021 15:07:26 GMT
28
+
29
+ ### Patches
30
+
31
+ - Add more symbols to Hermes DLL Loader Shim (ngerlem@microsoft.com)
32
+ - Fix win32 apps referencing the M.RN nuget package so they can use RNW (asklar@microsoft.com)
33
+ - Fix EBUSY race conditions between metro bundler and msbuild (dannyvv@microsoft.com)
34
+ - Fix crash when direct debugging Chakra (anandrag@microsoft.com)
35
+ - Fix AppTheme Regressions (ngerlem@microsoft.com)
36
+
37
+ ## 0.66.1
38
+
39
+ Mon, 18 Oct 2021 15:08:36 GMT
40
+
41
+ ### Patches
42
+
43
+ - Fix WACK for apps not packaging hermes.dll (ngerlem@microsoft.com)
44
+ - Loosen RN peer dependency (ngerlem@microsoft.com)
45
+
46
+ ## 0.66.0
47
+
48
+ Mon, 11 Oct 2021 15:07:19 GMT
49
+
50
+ ### Patches
51
+
52
+ - Promote 0.66 to latest (ngerlem@microsoft.com)
53
+
15
54
  ## 0.66.0-preview.6
16
55
 
17
56
  Mon, 04 Oct 2021 15:07:37 GMT
@@ -21,7 +21,6 @@
21
21
  <ClCompile Include="$(MSBuildThisFileDirectory)Utf8DebugExtensions.cpp" />
22
22
  </ItemGroup>
23
23
  <ItemGroup>
24
- <ClInclude Include="$(MSBuildThisFileDirectory)ChakraCoreDebugger.h" />
25
24
  <ClInclude Include="$(MSBuildThisFileDirectory)ChakraHelpers.h" />
26
25
  <ClInclude Include="$(MSBuildThisFileDirectory)ChakraInstanceArgs.h" />
27
26
  <ClInclude Include="$(MSBuildThisFileDirectory)ChakraPlatform.h" />
@@ -21,9 +21,6 @@
21
21
  </ClCompile>
22
22
  </ItemGroup>
23
23
  <ItemGroup>
24
- <ClInclude Include="$(MSBuildThisFileDirectory)ChakraCoreDebugger.h">
25
- <Filter>Header Files</Filter>
26
- </ClInclude>
27
24
  <ClInclude Include="$(MSBuildThisFileDirectory)ChakraHelpers.h">
28
25
  <Filter>Header Files</Filter>
29
26
  </ClInclude>
@@ -32,198 +32,6 @@
32
32
  namespace facebook {
33
33
  namespace react {
34
34
 
35
- #if !defined(USE_EDGEMODE_JSRT)
36
- namespace {
37
-
38
- template <class T>
39
- size_t fwrite(T *p, size_t count, FILE *file) noexcept {
40
- static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable to be serialized into a file");
41
- return fwrite(p, sizeof(*p), count, file);
42
- }
43
-
44
- template <class T>
45
- bool fwrite(const T &val, FILE *file) noexcept {
46
- return fwrite(&val, 1, file) == 1;
47
- }
48
-
49
- #if !defined(CHAKRACORE_UWP)
50
- struct FileVersionInfoResource {
51
- uint16_t len;
52
- uint16_t valLen;
53
- uint16_t type;
54
- wchar_t key[_countof(L"VS_VERSION_INFO")];
55
- uint16_t padding1;
56
- VS_FIXEDFILEINFO fixedFileInfo;
57
- uint32_t padding2;
58
- };
59
- #endif
60
- class ChakraVersionInfo {
61
- public:
62
- ChakraVersionInfo() noexcept : m_fileVersionMS{0}, m_fileVersionLS{0}, m_productVersionMS{0}, m_productVersionLS{0} {}
63
-
64
- bool initialize() noexcept {
65
- #if !defined(CHAKRACORE_UWP)
66
- auto freeLibraryWrapper = [](void *p) { FreeLibrary((HMODULE)p); };
67
- HMODULE moduleHandle;
68
- // This code is win32 only at the moment. We will need to change these
69
- // lines if we want to support UWP.
70
- if (!GetModuleHandleExW(
71
- 0,
72
- Microsoft::React::GetRuntimeOptionBool("JSI.ForceSystemChakra") ? L"Chakra.dll" : L"ChakraCore.dll",
73
- &moduleHandle)) {
74
- return false;
75
- }
76
- std::unique_ptr<void, decltype(freeLibraryWrapper)> moduleHandleWrapper(
77
- moduleHandle, std::move(freeLibraryWrapper));
78
-
79
- HRSRC versionResourceHandle = FindResourceW(moduleHandle, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
80
- if (!versionResourceHandle ||
81
- SizeofResource(static_cast<HMODULE>(moduleHandleWrapper.get()), versionResourceHandle) <
82
- sizeof(FileVersionInfoResource)) {
83
- return false;
84
- }
85
-
86
- HGLOBAL versionResourcePtrHandle = LoadResource(moduleHandle, versionResourceHandle);
87
- if (!versionResourcePtrHandle) {
88
- return false;
89
- }
90
-
91
- FileVersionInfoResource *chakraVersionInfo =
92
- static_cast<FileVersionInfoResource *>(LockResource(versionResourcePtrHandle));
93
- if (!chakraVersionInfo) {
94
- return false;
95
- }
96
-
97
- m_fileVersionMS = chakraVersionInfo->fixedFileInfo.dwFileVersionMS;
98
- m_fileVersionLS = chakraVersionInfo->fixedFileInfo.dwFileVersionLS;
99
- m_productVersionMS = chakraVersionInfo->fixedFileInfo.dwProductVersionMS;
100
- m_productVersionLS = chakraVersionInfo->fixedFileInfo.dwProductVersionLS;
101
- #endif
102
- return true;
103
- }
104
-
105
- bool operator==(const ChakraVersionInfo &rhs) const noexcept {
106
- return (m_fileVersionMS == rhs.m_fileVersionMS) && (m_fileVersionLS == rhs.m_fileVersionLS) &&
107
- (m_productVersionMS == rhs.m_productVersionMS) && (m_productVersionLS == rhs.m_productVersionLS);
108
- }
109
-
110
- bool operator!=(const ChakraVersionInfo &rhs) const noexcept {
111
- return !(*this == rhs);
112
- }
113
-
114
- private:
115
- uint32_t m_fileVersionMS;
116
- uint32_t m_fileVersionLS;
117
- uint32_t m_productVersionMS;
118
- uint32_t m_productVersionLS;
119
- };
120
-
121
- class BytecodePrefix {
122
- public:
123
- static std::pair<bool, BytecodePrefix> getBytecodePrefix(uint64_t bundleVersion) noexcept {
124
- std::pair<bool, BytecodePrefix> result{false, BytecodePrefix{bundleVersion}};
125
- result.first = result.second.m_chakraVersionInfo.initialize();
126
- return result;
127
- }
128
-
129
- bool operator==(const BytecodePrefix &rhs) const noexcept {
130
- return (m_bytecodeFileFormatVersion == rhs.m_bytecodeFileFormatVersion) &&
131
- (m_bundleVersion == rhs.m_bundleVersion) && (m_chakraVersionInfo == rhs.m_chakraVersionInfo);
132
- }
133
-
134
- bool operator!=(const BytecodePrefix &rhs) const noexcept {
135
- return !(*this == rhs);
136
- }
137
-
138
- private:
139
- uint64_t m_bytecodeFileFormatVersion;
140
- uint64_t m_bundleVersion;
141
- ChakraVersionInfo m_chakraVersionInfo;
142
-
143
- static constexpr uint32_t s_bytecodeFileFormatVersion = 2;
144
-
145
- BytecodePrefix(uint64_t bundleVersion) noexcept
146
- : m_bytecodeFileFormatVersion{s_bytecodeFileFormatVersion},
147
- m_bundleVersion{bundleVersion},
148
- m_chakraVersionInfo{} {}
149
- };
150
-
151
- void serializeBytecodeToFileCore(
152
- const std::shared_ptr<const JSBigString> &script,
153
- const BytecodePrefix &bytecodePrefix,
154
- const std::string &bytecodeFileName) {
155
- FILE *bytecodeFilePtr;
156
- // bytecode is a binary representation, so we need to pass in the "b" flag to
157
- // fopen_s
158
- if (_wfopen_s(&bytecodeFilePtr, Microsoft::Common::Unicode::Utf8ToUtf16(bytecodeFileName).c_str(), L"wb")) {
159
- return;
160
- }
161
- std::unique_ptr<FILE, decltype(&fclose)> bytecodeFilePtrWrapper(bytecodeFilePtr, fclose);
162
-
163
- const std::wstring scriptUTF16 = Microsoft::Common::Unicode::Utf8ToUtf16(script->c_str(), script->size());
164
-
165
- unsigned int bytecodeSize = 0;
166
- if (JsSerializeScript(scriptUTF16.c_str(), nullptr, &bytecodeSize) != JsNoError) {
167
- return;
168
- }
169
-
170
- std::unique_ptr<uint8_t[]> bytecode(std::make_unique<uint8_t[]>(bytecodeSize));
171
- if (JsSerializeScript(scriptUTF16.c_str(), bytecode.get(), &bytecodeSize) != JsNoError) {
172
- return;
173
- }
174
-
175
- constexpr size_t bytecodePrefixSize = sizeof(bytecodePrefix);
176
- uint8_t zeroArray[sizeof(bytecodePrefix)]{};
177
-
178
- if (fwrite(zeroArray, bytecodePrefixSize, bytecodeFilePtrWrapper.get()) != bytecodePrefixSize ||
179
- fwrite(bytecode.get(), bytecodeSize, bytecodeFilePtrWrapper.get()) != bytecodeSize ||
180
- fflush(bytecodeFilePtrWrapper.get())) {
181
- return;
182
- }
183
-
184
- fseek(bytecodeFilePtrWrapper.get(), 0, SEEK_SET);
185
- if (!fwrite(bytecodePrefix, bytecodeFilePtrWrapper.get()) || fflush(bytecodeFilePtrWrapper.get())) {
186
- return;
187
- }
188
- }
189
-
190
- std::unique_ptr<JSBigString> tryGetBytecode(const BytecodePrefix &bytecodePrefix, const std::string &bytecodeFileName) {
191
- auto bytecodeBigStringPtr =
192
- std::make_unique<FileMappingBigString>(bytecodeFileName, static_cast<uint32_t>(sizeof(BytecodePrefix)));
193
-
194
- if (!bytecodeBigStringPtr->file_data() || bytecodeBigStringPtr->file_size() < sizeof(bytecodePrefix) ||
195
- *reinterpret_cast<const BytecodePrefix *>(bytecodeBigStringPtr->file_data()) != bytecodePrefix) {
196
- return nullptr;
197
- }
198
-
199
- return bytecodeBigStringPtr;
200
- }
201
-
202
- void serializeBytecodeToFile(
203
- const std::shared_ptr<const JSBigString> &script,
204
- const BytecodePrefix &bytecodePrefix,
205
- std::string &&bytecodeFileName,
206
- bool async) {
207
- std::future<void> bytecodeSerializationFuture = std::async(
208
- std::launch::async,
209
- [](const std::shared_ptr<const JSBigString> &script,
210
- const BytecodePrefix &bytecodePrefix,
211
- const std::string &bytecodeFileName) {
212
- MinimalChakraRuntime chakraRuntime(false /* multithreaded */);
213
- serializeBytecodeToFileCore(script, bytecodePrefix, bytecodeFileName);
214
- },
215
- script,
216
- bytecodePrefix,
217
- std::move(bytecodeFileName));
218
-
219
- if (!async) {
220
- bytecodeSerializationFuture.wait();
221
- }
222
- }
223
-
224
- } // namespace
225
- #endif
226
-
227
35
  MinimalChakraRuntime::MinimalChakraRuntime(bool multithreaded)
228
36
  : runtime{new JsRuntimeHandle,
229
37
  [](JsRuntimeHandle *h) {
@@ -355,7 +163,6 @@ JsValueRef evaluateScript(JsValueRef script, JsValueRef source) {
355
163
  JsValueRef exn = nullptr;
356
164
  JsValueRef value = nullptr;
357
165
 
358
- #if defined(USE_EDGEMODE_JSRT)
359
166
  const wchar_t *scriptRaw;
360
167
  size_t scriptRawLength;
361
168
  JsStringToPointer(script, &scriptRaw, &scriptRawLength);
@@ -365,11 +172,6 @@ JsValueRef evaluateScript(JsValueRef script, JsValueRef source) {
365
172
  JsStringToPointer(source, &sourceRaw, &sourceRawLength);
366
173
 
367
174
  auto result = JsRunScript(scriptRaw, JS_SOURCE_CONTEXT_NONE /*sourceContext*/, sourceRaw, &value);
368
- #else
369
- JsSourceContext sourceContext = getNextSourceContext();
370
- auto result = JsRun(script, sourceContext, source, JsParseScriptAttributeNone, &value);
371
- #endif
372
-
373
175
  bool hasException = false;
374
176
  if (result == JsErrorInExceptionState || (JsHasException(&hasException), hasException)) {
375
177
  JsGetAndClearException(&exn);
@@ -385,18 +187,10 @@ JsValueRef evaluateScript(JsValueRef script, JsValueRef source) {
385
187
 
386
188
  JsValueRef evaluateScript(std::unique_ptr<const JSBigString> &&script, JsValueRef sourceURL) {
387
189
  ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_START);
388
- #if defined(USE_EDGEMODE_JSRT)
389
190
  JsValueRef jsScript = jsStringFromBigString(*script.get());
390
- #else
391
- JsValueRefUniquePtr jsScript = jsArrayBufferFromBigString(std::move(script));
392
- #endif
393
191
  ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP);
394
192
 
395
- #if defined(USE_EDGEMODE_JSRT)
396
193
  return evaluateScript(jsScript, sourceURL);
397
- #else
398
- return evaluateScript(jsScript.get(), sourceURL);
399
- #endif
400
194
  }
401
195
 
402
196
  JsValueRef evaluateScriptWithBytecode(
@@ -405,72 +199,11 @@ JsValueRef evaluateScriptWithBytecode(
405
199
  JsValueRef scriptFileName,
406
200
  [[maybe_unused]] std::string &&bytecodeFileName,
407
201
  [[maybe_unused]] bool asyncBytecodeGeneration) {
408
- #if defined(WINRT)
409
202
  // TODO:
410
203
  // ChakraRT does not support the JsRunSerialized() API.
411
204
  // Hence for UWP implementation, we fall back to using the original source
412
205
  // code right now.
413
206
  return evaluateScript(std::move(script), scriptFileName);
414
- #else
415
- auto bytecodePrefixOptional = BytecodePrefix::getBytecodePrefix(scriptVersion);
416
- if (!bytecodePrefixOptional.first) {
417
- return evaluateScript(std::move(script), scriptFileName);
418
- }
419
-
420
- auto &bytecodePrefix = bytecodePrefixOptional.second;
421
- std::unique_ptr<const JSBigString> bytecode = tryGetBytecode(bytecodePrefix, bytecodeFileName);
422
- if (!bytecode) {
423
- std::shared_ptr<const JSBigString> sharedScript(script.release());
424
- serializeBytecodeToFile(sharedScript, bytecodePrefix, std::move(bytecodeFileName), asyncBytecodeGeneration);
425
- ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_START);
426
- JsValueRefUniquePtr jsScript = jsArrayBufferFromBigString(sharedScript);
427
- ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP);
428
- return evaluateScript(jsScript.get(), scriptFileName);
429
- }
430
-
431
- ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_START);
432
- JsValueRefUniquePtr jsScript = jsArrayBufferFromBigString(std::move(script));
433
- ReactMarker::logMarker(ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP);
434
- JsValueRef exn = nullptr;
435
- JsValueRef value = nullptr;
436
- JsErrorCode result = JsRunSerialized(
437
- jsArrayBufferFromBigString(std::move(bytecode)).get(),
438
- [](JsSourceContext sourceContext, JsValueRef *value, JsParseScriptAttributes *parseAttributes) {
439
- *value = reinterpret_cast<JsValueRef>(sourceContext);
440
- *parseAttributes = JsParseScriptAttributeNone;
441
- return true;
442
- },
443
- reinterpret_cast<JsSourceContext>(jsScript.get()),
444
- scriptFileName,
445
- &value);
446
-
447
- // Currently, when the existing bundle.bytecode is incompatible with the
448
- // ChakraCore.dll used, we do not update it. This is because we memory mapped
449
- // bundle.bytecode into a JsExternalArrayBuffer, whose lifetime is controlled
450
- // by the JS engine. Hence we cannot remove/rename/modify bytecode.bundle
451
- // until the JS garbage collector deletes the corresponding
452
- // JsExternalArrayBuffer.
453
- if (result == JsErrorBadSerializedScript) {
454
- JsGetAndClearException(&exn);
455
- return evaluateScript(jsScript.get(), scriptFileName);
456
- }
457
-
458
- // This code is duplicated from evaluateScript.
459
- // TODO (task 1977635) get rid of this duplicated code.
460
- bool hasException = false;
461
- if (result == JsErrorInExceptionState || (JsHasException(&hasException), hasException)) {
462
- JsGetAndClearException(&exn);
463
- std::string exceptionDescription = "JavaScriptException in " + ChakraValue(scriptFileName).toString().str();
464
-
465
- throw ChakraJSException(exn, exceptionDescription.c_str());
466
- }
467
-
468
- if (value == nullptr) {
469
- formatAndThrowJSException(exn, scriptFileName);
470
- }
471
-
472
- return value;
473
- #endif
474
207
  }
475
208
 
476
209
  void formatAndThrowJSException(JsValueRef exn, JsValueRef source) {
@@ -3,12 +3,7 @@
3
3
 
4
4
  #pragma once
5
5
 
6
- #if defined(USE_EDGEMODE_JSRT)
7
6
  #include <jsrt.h>
8
- #else
9
- #include <ChakraCore.h>
10
- #endif
11
-
12
7
  #include "DevSettings.h"
13
8
 
14
9
  namespace facebook {
@@ -13,11 +13,7 @@
13
13
 
14
14
  #include "Logging.h"
15
15
 
16
- #if defined(USE_EDGEMODE_JSRT)
17
16
  #include <jsrt.h>
18
- #else
19
- #include <ChakraCore.h>
20
- #endif
21
17
 
22
18
  #define CHAKRA_FAILED(jsErrorCode) ((jsErrorCode) != ::JsErrorCode::JsNoError)
23
19
 
@@ -50,15 +50,6 @@ static JsValueRef __stdcall nativeTraceBeginSectionJNF(
50
50
  if (argumentType == JsValueType::JsString) {
51
51
  CHAKRA_ASSERTDO(JsGetStringLength(arguments[2], &profileNameLength));
52
52
  profileName.resize(profileNameLength);
53
-
54
- // TODO: CharkaRT doesn't have JsCopyString, implement alternative.
55
- #if !defined(USE_EDGEMODE_JSRT)
56
- CHAKRA_ASSERTDO(JsCopyString(
57
- arguments[2],
58
- const_cast<char *>(profileName.data()),
59
- profileNameLength + 1 /* length */,
60
- nullptr /* written */));
61
- #endif
62
53
  }
63
54
  #ifndef NDEBUG
64
55
  else {
@@ -73,12 +64,6 @@ static JsValueRef __stdcall nativeTraceBeginSectionJNF(
73
64
  if (argumentType == JsValueType::JsString) {
74
65
  CHAKRA_ASSERTDO(JsGetStringLength(arguments[3], &argsLength));
75
66
  argsStr.resize(argsLength + 1);
76
-
77
- // TODO: CharkaRT doesn't have JsCopyString, implement alternative.
78
- #if !defined(USE_EDGEMODE_JSRT)
79
- CHAKRA_ASSERTDO(JsCopyString(
80
- arguments[3], const_cast<char *>(argsStr.data()), argsLength + 1 /* length */, nullptr /* written */));
81
- #endif
82
67
  }
83
68
  #ifndef NDEBUG
84
69
  else {
@@ -149,15 +134,6 @@ static void beginOrEndAsync(bool isEnd, JsValueRef arguments[], unsigned short a
149
134
  if (argumentType == JsValueType::JsString) {
150
135
  CHAKRA_ASSERTDO(JsGetStringLength(arguments[2], &profileNameLength));
151
136
  profileName.resize(profileNameLength);
152
-
153
- // TODO: CharkaRT doesn't have JsCopyString, implement alternative.
154
- #if !defined(USE_EDGEMODE_JSRT)
155
- CHAKRA_ASSERTDO(JsCopyString(
156
- arguments[2],
157
- const_cast<char *>(profileName.data()),
158
- profileNameLength + 1 /* length */,
159
- nullptr /* written */));
160
- #endif
161
137
  }
162
138
  #ifndef NDEBUG
163
139
  else {
@@ -240,15 +216,6 @@ static JsValueRef __stdcall nativeTraceCounterJNF(
240
216
  if (argumentType == JsValueType::JsString) {
241
217
  CHAKRA_ASSERTDO(JsGetStringLength(arguments[2], &profileNameLength));
242
218
  profileName.resize(profileNameLength);
243
-
244
- // TODO: CharkaRT doesn't have JsCopyString, implement alternative.
245
- #if !defined(USE_EDGEMODE_JSRT)
246
- CHAKRA_ASSERTDO(JsCopyString(
247
- arguments[2],
248
- const_cast<char *>(profileName.data()),
249
- profileNameLength + 1 /* length */,
250
- nullptr /* written */));
251
- #endif
252
219
  }
253
220
  #ifndef NDEBUG
254
221
  else {
@@ -10,11 +10,7 @@
10
10
 
11
11
  #include <folly/dynamic.h>
12
12
 
13
- #if defined(USE_EDGEMODE_JSRT)
14
13
  #include <jsrt.h>
15
- #else
16
- #include <ChakraCore.h>
17
- #endif
18
14
 
19
15
  #include "Utf8DebugExtensions.h"
20
16
 
@@ -38,16 +38,11 @@ JsErrorCode JsPointerToStringUtf8(
38
38
  if (stringValue == nullptr) {
39
39
  return JsErrorNullArgument;
40
40
  }
41
- #if defined(USE_EDGEMODE_JSRT)
42
41
  // JsCreateString is not supported in universal chakra engine
43
42
  // So we convert the utf8 string to utf16 first and call JsPointerToString to
44
43
  // convert the string to JsValueRef
45
44
  std::wstring wstr = Microsoft::Common::Unicode::Utf8ToUtf16(stringValue, stringLength);
46
45
  return JsPointerToString(wstr.c_str(), wstr.size(), string);
47
-
48
- #else
49
- return JsCreateString(stringValue, stringLength, string);
50
- #endif
51
46
  }
52
47
 
53
48
  JsErrorCode JsStringToStdStringUtf8(_In_ JsValueRef stringValue, std::string &string) {
@@ -3,13 +3,7 @@
3
3
 
4
4
  #pragma once
5
5
 
6
- #if defined(USE_EDGEMODE_JSRT)
7
6
  #include <jsrt.h>
8
- #else
9
- #include <ChakraCore.h>
10
- #include <cstdint> //for uint16_t in <ChakraCore.h>
11
- #endif
12
-
13
7
  #include <string>
14
8
  #if _HAS_CXX17
15
9
  #include <string_view>
@@ -1,9 +1,10 @@
1
- import { NativeEventEmitter } from 'react-native';
2
- import { IHighContrastColors } from './AppThemeTypes';
1
+ import { EmitterSubscription, NativeEventEmitter } from 'react-native';
2
+ import { IHighContrastColors, IHighContrastChangedEvent } from './AppThemeTypes';
3
3
  declare class AppThemeModule extends NativeEventEmitter {
4
4
  private _isHighContrast;
5
5
  private _highContrastColors;
6
6
  constructor();
7
+ addListener(eventName: 'highContrastChanged', listener: (nativeEvent: IHighContrastChangedEvent) => void): EmitterSubscription;
7
8
  get isHighContrast(): boolean;
8
9
  get currentHighContrastColors(): IHighContrastColors;
9
10
  }
@@ -7,10 +7,25 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.AppTheme = void 0;
9
9
  const react_native_1 = require("react-native");
10
- const NativeAppTheme = react_native_1.NativeModules.RTCAppTheme;
10
+ // We previously gracefully handled importing AppTheme in the Jest environment.
11
+ // Mock the NM until we have a coherent story for exporting our own Jest mocks,
12
+ // or remove this API.
13
+ const NativeAppTheme = react_native_1.NativeModules.RTCAppTheme || {
14
+ initialHighContrast: false,
15
+ initialHighContrastColors: {
16
+ ButtonFaceColor: '',
17
+ ButtonTextColor: '',
18
+ GrayTextColor: '',
19
+ HighlightColor: '',
20
+ HighlightTextColor: '',
21
+ HotlightColor: '',
22
+ WindowColor: '',
23
+ WindowTextColor: '',
24
+ },
25
+ };
11
26
  class AppThemeModule extends react_native_1.NativeEventEmitter {
12
27
  constructor() {
13
- super(NativeAppTheme);
28
+ super();
14
29
  this._highContrastColors = NativeAppTheme.initialHighContrastColors;
15
30
  this._isHighContrast = NativeAppTheme.initialHighContrast;
16
31
  this.addListener('highContrastChanged', (nativeEvent) => {
@@ -18,6 +33,9 @@ class AppThemeModule extends react_native_1.NativeEventEmitter {
18
33
  this._highContrastColors = nativeEvent.highContrastColors;
19
34
  });
20
35
  }
36
+ addListener(eventName, listener) {
37
+ return super.addListener(eventName, listener);
38
+ }
21
39
  get isHighContrast() {
22
40
  return this._isHighContrast;
23
41
  }