react-native-windows 0.66.0-preview.2 → 0.66.0-preview.6

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 (28) hide show
  1. package/CHANGELOG.json +79 -1
  2. package/CHANGELOG.md +39 -4
  3. package/Microsoft.ReactNative/IReactDispatcher.cpp +40 -2
  4. package/Microsoft.ReactNative/IReactDispatcher.h +19 -3
  5. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +7 -6
  6. package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -3
  7. package/Microsoft.ReactNative/ReactCoreInjection.cpp +18 -9
  8. package/Microsoft.ReactNative/ReactCoreInjection.h +5 -6
  9. package/Microsoft.ReactNative/ReactCoreInjection.idl +5 -5
  10. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +131 -123
  11. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +2 -1
  12. package/Microsoft.ReactNative/RedBox.cpp +11 -9
  13. package/Microsoft.ReactNative/RedBox.h +2 -1
  14. package/Microsoft.ReactNative/RedBoxHandler.cpp +1 -1
  15. package/Microsoft.ReactNative/packages.config +2 -2
  16. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +1993 -0
  17. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +21 -0
  18. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +6 -0
  19. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +7 -1
  20. package/Mso/future/futureWinRT.h +3 -1
  21. package/PropertySheets/JSEngine.props +5 -4
  22. package/Scripts/Tracing/Stop-Tracing.ps1 +14 -3
  23. package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +1 -1
  24. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
  25. package/Shared/Shared.vcxitems +1 -1
  26. package/Shared/Threading/MessageDispatchQueue.cpp +79 -0
  27. package/Shared/Threading/MessageDispatchQueue.h +31 -0
  28. package/package.json +2 -2
package/CHANGELOG.json CHANGED
@@ -2,7 +2,85 @@
2
2
  "name": "react-native-windows",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 06 Sep 2021 15:06:33 GMT",
5
+ "date": "Mon, 04 Oct 2021 15:07:18 GMT",
6
+ "tag": "react-native-windows_v0.66.0-preview.6",
7
+ "version": "0.66.0-preview.6",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "comment": "Upgrade ReactNative.V8Jsi.Windows to 0.65.5",
12
+ "author": "julio.rocha@microsoft.com",
13
+ "commit": "8b1048e4a3491c01f2b2d4382822f8d98f3ccfe5",
14
+ "package": "react-native-windows"
15
+ },
16
+ {
17
+ "comment": "Allow injection of custom UI thread",
18
+ "author": "30809111+acoates-ms@users.noreply.github.com",
19
+ "commit": "a20892ade44390cdb10f25c31a2f35ce61328b97",
20
+ "package": "react-native-windows"
21
+ },
22
+ {
23
+ "comment": "ReactNativeHost ReloadInstance and UnloadInstance actions do not always fire completed events",
24
+ "author": "30809111+acoates-ms@users.noreply.github.com",
25
+ "commit": "b848d68c45c3f9b51938ce9881e276cae1d58448",
26
+ "package": "react-native-windows"
27
+ },
28
+ {
29
+ "comment": "Make hermes consume icu.dll in Windows for local aware functions",
30
+ "author": "anandrag@microsoft.com",
31
+ "commit": "652dfd2e5f50f575c0dfb9dd90efd5eb14d485bb",
32
+ "package": "react-native-windows"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "date": "Mon, 27 Sep 2021 15:07:31 GMT",
39
+ "tag": "react-native-windows_v0.66.0-preview.5",
40
+ "version": "0.66.0-preview.5",
41
+ "comments": {
42
+ "prerelease": [
43
+ {
44
+ "comment": "Migrate NapiJsiRuntime from V8-JSI (#8617)",
45
+ "author": "julio.rocha@microsoft.com",
46
+ "commit": "b4d6793bc39203a7671163f7770307f24f90ef91",
47
+ "package": "react-native-windows"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ {
53
+ "date": "Mon, 20 Sep 2021 15:07:01 GMT",
54
+ "tag": "react-native-windows_v0.66.0-preview.4",
55
+ "version": "0.66.0-preview.4",
56
+ "comments": {
57
+ "prerelease": [
58
+ {
59
+ "comment": "Restore Fast Refresh",
60
+ "author": "34109996+chiaramooney@users.noreply.github.com",
61
+ "commit": "71803345c9e89ee419332119fd5667370c5c19d3",
62
+ "package": "react-native-windows"
63
+ }
64
+ ]
65
+ }
66
+ },
67
+ {
68
+ "date": "Mon, 13 Sep 2021 15:06:37 GMT",
69
+ "tag": "react-native-windows_v0.66.0-preview.3",
70
+ "version": "0.66.0-preview.3",
71
+ "comments": {
72
+ "prerelease": [
73
+ {
74
+ "comment": "Bump hermes to v0.9",
75
+ "author": "anandrag@microsoft.com",
76
+ "commit": "2afad93679990d06cec763bd6c12ce44efef0c4a",
77
+ "package": "react-native-windows"
78
+ }
79
+ ]
80
+ }
81
+ },
82
+ {
83
+ "date": "Mon, 06 Sep 2021 15:06:48 GMT",
6
84
  "tag": "react-native-windows_v0.66.0-preview.2",
7
85
  "version": "0.66.0-preview.2",
8
86
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,52 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 06 Sep 2021 15:06:33 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 04 Oct 2021 15:07:18 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.66.0-preview.2
7
+ ## 0.66.0-preview.6
8
8
 
9
- Mon, 06 Sep 2021 15:06:33 GMT
9
+ Mon, 04 Oct 2021 15:07:18 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Fix race condition when building customer projects (dannyvv@microsoft.com)
13
+ - Upgrade ReactNative.V8Jsi.Windows to 0.65.5 (julio.rocha@microsoft.com)
14
+ - Allow injection of custom UI thread (30809111+acoates-ms@users.noreply.github.com)
15
+ - ReactNativeHost ReloadInstance and UnloadInstance actions do not always fire completed events (30809111+acoates-ms@users.noreply.github.com)
16
+ - Make hermes consume icu.dll in Windows for local aware functions (anandrag@microsoft.com)
14
17
 
18
+ ## 0.66.0-preview.5
19
+
20
+ Mon, 27 Sep 2021 15:07:31 GMT
21
+
22
+ ### Changes
23
+
24
+ - Migrate NapiJsiRuntime from V8-JSI (#8617) (julio.rocha@microsoft.com)
25
+
26
+ ## 0.66.0-preview.4
27
+
28
+ Mon, 20 Sep 2021 15:07:01 GMT
29
+
30
+ ### Changes
31
+
32
+ - Restore Fast Refresh (34109996+chiaramooney@users.noreply.github.com)
33
+
34
+ ## 0.66.0-preview.3
35
+
36
+ Mon, 13 Sep 2021 15:06:37 GMT
37
+
38
+ ### Changes
39
+
40
+ - Bump hermes to v0.9 (anandrag@microsoft.com)
41
+
42
+ ## 0.66.0-preview.2
43
+
44
+ Mon, 06 Sep 2021 15:06:48 GMT
45
+
46
+ ### Changes
47
+
48
+ - Fix race condition when building customer projects (dannyvv@microsoft.com)
49
+
15
50
  ## 0.66.0-preview.1
16
51
 
17
52
  Fri, 03 Sep 2021 18:48:19 GMT
@@ -10,6 +10,27 @@ using namespace Windows::Foundation;
10
10
 
11
11
  namespace winrt::Microsoft::ReactNative::implementation {
12
12
 
13
+ // Implements IDispatchQueue2 on top of a custom IReactDispatcher provided by the application
14
+ struct WrappedReactDispatcher : public Mso::UnknownObject<Mso::React::IDispatchQueue2> {
15
+ WrappedReactDispatcher(const winrt::Microsoft::ReactNative::IReactDispatcher &dispatcher) noexcept
16
+ : m_dispatcher(dispatcher) {}
17
+
18
+ void Post(Mso::DispatchTask &&task) const noexcept override {
19
+ m_dispatcher.Post(task);
20
+ }
21
+
22
+ void InvokeElsePost(Mso::DispatchTask &&task) const noexcept override {
23
+ if (m_dispatcher.HasThreadAccess()) {
24
+ task();
25
+ } else {
26
+ Post(std::move(task));
27
+ }
28
+ }
29
+
30
+ private:
31
+ winrt::Microsoft::ReactNative::IReactDispatcher m_dispatcher;
32
+ };
33
+
13
34
  ReactDispatcher::ReactDispatcher(Mso::DispatchQueue &&queue) noexcept : m_queue{std::move(queue)} {}
14
35
 
15
36
  bool ReactDispatcher::HasThreadAccess() noexcept {
@@ -20,12 +41,29 @@ void ReactDispatcher::Post(ReactDispatcherCallback const &callback) noexcept {
20
41
  return m_queue.Post([callback]() noexcept { callback(); });
21
42
  }
22
43
 
44
+ void ReactDispatcher::Post(Mso::DispatchTask &&task) const noexcept {
45
+ m_queue.Post(std::move(task));
46
+ }
47
+
48
+ void ReactDispatcher::InvokeElsePost(Mso::DispatchTask &&task) const noexcept {
49
+ m_queue.InvokeElsePost(std::move(task));
50
+ }
51
+
23
52
  /*static*/ IReactDispatcher ReactDispatcher::CreateSerialDispatcher() noexcept {
24
53
  return make<ReactDispatcher>(Mso::DispatchQueue{});
25
54
  }
26
55
 
27
- /*static*/ Mso::DispatchQueue ReactDispatcher::GetUIDispatchQueue(IReactPropertyBag const &properties) noexcept {
28
- return GetUIDispatcher(properties).as<ReactDispatcher>()->m_queue;
56
+ /*static*/ Mso::CntPtr<Mso::React::IDispatchQueue2> ReactDispatcher::GetUIDispatchQueue2(
57
+ IReactPropertyBag const &properties) noexcept {
58
+ auto iReactDispatcher = GetUIDispatcher(properties);
59
+
60
+ if (!iReactDispatcher)
61
+ return nullptr;
62
+
63
+ if (auto simpleDispatcher = iReactDispatcher.try_as<IDispatchQueue2>())
64
+ return simpleDispatcher.get();
65
+
66
+ return Mso::Make<WrappedReactDispatcher>(iReactDispatcher);
29
67
  }
30
68
 
31
69
  /*static*/ IReactDispatcher ReactDispatcher::UIThreadDispatcher() noexcept {
@@ -6,9 +6,23 @@
6
6
  #include <dispatchQueue/dispatchQueue.h>
7
7
  #include <winrt/Microsoft.ReactNative.h>
8
8
 
9
+ namespace Mso::React {
10
+
11
+ MSO_GUID(IDispatchQueue2, "a8d9db25-3d16-4476-ae65-682fcee1260c")
12
+ struct IDispatchQueue2 : ::IUnknown {
13
+ //! Post the task to the end of the queue for asynchronous invocation.
14
+ virtual void Post(Mso::DispatchTask &&task) const noexcept = 0;
15
+
16
+ //! Invoke the task immediately if the queue uses the current thread. Otherwise, post it.
17
+ //! The immediate execution ignores the suspend or shutdown states.
18
+ virtual void InvokeElsePost(Mso::DispatchTask &&task) const noexcept = 0;
19
+ };
20
+
21
+ } // namespace Mso::React
22
+
9
23
  namespace winrt::Microsoft::ReactNative::implementation {
10
24
 
11
- struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IReactDispatcher>> {
25
+ struct ReactDispatcher : implements<ReactDispatcher, IReactDispatcher, Mso::React::IDispatchQueue2> {
12
26
  ReactDispatcher() = default;
13
27
  ReactDispatcher(Mso::DispatchQueue &&queue) noexcept;
14
28
 
@@ -17,8 +31,7 @@ struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IR
17
31
 
18
32
  static IReactDispatcher CreateSerialDispatcher() noexcept;
19
33
 
20
- static Mso::DispatchQueue GetUIDispatchQueue(IReactPropertyBag const &properties) noexcept;
21
-
34
+ static Mso::CntPtr<IDispatchQueue2> GetUIDispatchQueue2(IReactPropertyBag const &properties) noexcept;
22
35
  static IReactDispatcher UIThreadDispatcher() noexcept;
23
36
  static IReactPropertyName UIDispatcherProperty() noexcept;
24
37
  static IReactDispatcher GetUIDispatcher(IReactPropertyBag const &properties) noexcept;
@@ -26,6 +39,9 @@ struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IR
26
39
 
27
40
  static IReactPropertyName JSDispatcherProperty() noexcept;
28
41
 
42
+ void Post(Mso::DispatchTask &&task) const noexcept override;
43
+ void InvokeElsePost(Mso::DispatchTask &&task) const noexcept override;
44
+
29
45
  private:
30
46
  Mso::DispatchQueue m_queue;
31
47
  };
@@ -16,11 +16,8 @@ namespace Microsoft::ReactNative {
16
16
 
17
17
  AppearanceChangeListener::AppearanceChangeListener(
18
18
  const Mso::React::IReactContext &context,
19
- Mso::DispatchQueue const &uiQueue) noexcept
20
- : Mso::ActiveObject<>(uiQueue), m_context(&context) {
21
- // Ensure we're constructed on the UI thread
22
- VerifyElseCrash(uiQueue.HasThreadAccess());
23
-
19
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept
20
+ : m_queue(&uiQueue), m_context(&context) {
24
21
  if (auto currentApp = xaml::TryGetCurrentApplication()) {
25
22
  m_currentTheme = currentApp.RequestedTheme();
26
23
 
@@ -29,7 +26,11 @@ AppearanceChangeListener::AppearanceChangeListener(
29
26
  m_revoker = m_uiSettings.ColorValuesChanged(
30
27
  winrt::auto_revoke, [weakThis{Mso::WeakPtr(this)}](const auto & /*sender*/, const auto & /*args*/) noexcept {
31
28
  if (auto strongThis = weakThis.GetStrongPtr()) {
32
- strongThis->InvokeInQueueStrong([strongThis]() noexcept { strongThis->OnColorValuesChanged(); });
29
+ strongThis->m_queue->Post([weakThis]() noexcept {
30
+ if (auto strongThis = weakThis.GetStrongPtr()) {
31
+ strongThis->OnColorValuesChanged();
32
+ }
33
+ });
33
34
  }
34
35
  });
35
36
  }
@@ -3,30 +3,34 @@
3
3
 
4
4
  #pragma once
5
5
 
6
- #include <activeObject/activeObject.h>
7
6
  #include <cxxreact/CxxModule.h>
8
7
  #include <eventWaitHandle/eventWaitHandle.h>
9
8
 
10
9
  #include <winrt/Windows.UI.ViewManagement.h>
11
10
 
11
+ #include <IReactDispatcher.h>
12
12
  #include <React.h>
13
+ #include <object/refCountedObject.h>
13
14
  #include "IReactInstance.h"
14
15
 
15
16
  namespace Microsoft::ReactNative {
16
17
 
17
18
  // Listens for the current theme on the UI thread, storing the most recent. Will emit JS events on Appearance change.
18
- class AppearanceChangeListener final : public Mso::ActiveObject<> {
19
+ class AppearanceChangeListener final : public Mso::RefCountedObject<Mso::RefCountStrategy::WeakRef, Mso::IRefCounted> {
19
20
  using ApplicationTheme = xaml::ApplicationTheme;
20
21
  using UISettings = winrt::Windows::UI::ViewManagement::UISettings;
21
22
 
22
23
  public:
23
- AppearanceChangeListener(const Mso::React::IReactContext &context, Mso::DispatchQueue const &uiQueue) noexcept;
24
+ AppearanceChangeListener(
25
+ const Mso::React::IReactContext &context,
26
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept;
24
27
  const char *GetColorScheme() const noexcept;
25
28
 
26
29
  private:
27
30
  static const char *ToString(ApplicationTheme theme) noexcept;
28
31
  void OnColorValuesChanged() noexcept;
29
32
 
33
+ Mso::CntPtr<const Mso::React::IDispatchQueue2> m_queue;
30
34
  UISettings m_uiSettings;
31
35
  UISettings::ColorValuesChanged_revoker m_revoker;
32
36
  std::atomic<ApplicationTheme> m_currentTheme;
@@ -5,6 +5,7 @@
5
5
  #include "ReactCoreInjection.h"
6
6
  #include "ReactCoreInjection.g.cpp"
7
7
  #include "ReactViewOptions.g.cpp"
8
+ #include <future/futureWinRT.h>
8
9
  #include "IReactContext.h"
9
10
  #include "ReactContext.h"
10
11
  #include "ReactInstanceWin.h"
@@ -86,16 +87,18 @@ ReactViewHost::ReactViewHost(
86
87
 
87
88
  // ReactViewOptions ReactViewHost::Options() noexcept;
88
89
  // ReactNative::ReactNativeHost ReactViewHost::ReactHost() noexcept {}
89
- void ReactViewHost::ReloadViewInstance() noexcept {
90
- m_viewHost->ReloadViewInstance();
90
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::ReloadViewInstance() noexcept {
91
+ return make<Mso::AsyncActionFutureAdapter>(m_viewHost->ReloadViewInstance());
91
92
  }
92
93
 
93
- void ReactViewHost::ReloadViewInstanceWithOptions(ReactNative::ReactViewOptions options) noexcept {
94
- m_viewHost->ReloadViewInstanceWithOptions(options.as<ReactViewOptions>()->CreateViewOptions());
94
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::ReloadViewInstanceWithOptions(
95
+ ReactNative::ReactViewOptions options) noexcept {
96
+ return make<Mso::AsyncActionFutureAdapter>(
97
+ m_viewHost->ReloadViewInstanceWithOptions(options.as<ReactViewOptions>()->CreateViewOptions()));
95
98
  }
96
99
 
97
- void ReactViewHost::UnloadViewInstance() noexcept {
98
- m_viewHost->UnloadViewInstance();
100
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::UnloadViewInstance() noexcept {
101
+ return make<Mso::AsyncActionFutureAdapter>(m_viewHost->UnloadViewInstance());
99
102
  }
100
103
 
101
104
  //! This class ensures that we access ReactRootView from UI thread.
@@ -149,10 +152,16 @@ struct ReactViewInstance : public Mso::UnknownObject<Mso::RefCountStrategy::Weak
149
152
  }
150
153
  };
151
154
 
152
- void ReactViewHost::AttachViewInstance(ReactNative::IReactViewInstance viewInstance) noexcept {
153
- m_viewHost->AttachViewInstance(*Mso::Make<ReactViewInstance>(viewInstance, m_uiDispatcher));
155
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::AttachViewInstance(
156
+ ReactNative::IReactViewInstance viewInstance) noexcept {
157
+ return make<Mso::AsyncActionFutureAdapter>(
158
+ m_viewHost->AttachViewInstance(*Mso::Make<ReactViewInstance>(viewInstance, m_uiDispatcher)));
154
159
  }
155
160
 
156
- void ReactViewHost::DetachViewInstance() noexcept {}
161
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::DetachViewInstance() noexcept {
162
+ Mso::Promise<void> promise;
163
+ promise.SetValue();
164
+ return make<Mso::AsyncActionFutureAdapter>(promise.AsFuture());
165
+ }
157
166
 
158
167
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -53,12 +53,11 @@ struct ReactViewHost : public winrt::implements<ReactViewHost, IReactViewHost> {
53
53
  Mso::React::IReactViewHost &viewHost,
54
54
  const winrt::Microsoft::ReactNative::IReactDispatcher &uiDispatcher);
55
55
 
56
- /*Windows::Foundation::IAsyncAction */ void ReloadViewInstance() noexcept;
57
- /*Windows::Foundation::IAsyncAction */ void ReloadViewInstanceWithOptions(
58
- ReactNative::ReactViewOptions options) noexcept;
59
- /*Windows::Foundation::IAsyncAction */ void UnloadViewInstance() noexcept;
60
- /*Windows::Foundation::IAsyncAction */ void AttachViewInstance(IReactViewInstance viewInstance) noexcept;
61
- /*Windows::Foundation::IAsyncAction */ void DetachViewInstance() noexcept;
56
+ Windows::Foundation::IAsyncAction ReloadViewInstance() noexcept;
57
+ Windows::Foundation::IAsyncAction ReloadViewInstanceWithOptions(ReactNative::ReactViewOptions options) noexcept;
58
+ Windows::Foundation::IAsyncAction UnloadViewInstance() noexcept;
59
+ Windows::Foundation::IAsyncAction AttachViewInstance(IReactViewInstance viewInstance) noexcept;
60
+ Windows::Foundation::IAsyncAction DetachViewInstance() noexcept;
62
61
 
63
62
  private:
64
63
  Mso::CntPtr<Mso::React::IReactViewHost> m_viewHost;
@@ -50,19 +50,19 @@ DOC_STRING("Settings per each IReactViewHost associated with an IReactHost insta
50
50
  interface IReactViewHost
51
51
  {
52
52
  DOC_STRING("Reloads the IReactViewInstance if it is attached.")
53
- /*Windows.Foundation.IAsyncAction*/ void ReloadViewInstance();
53
+ Windows.Foundation.IAsyncAction ReloadViewInstance();
54
54
 
55
55
  DOC_STRING("Reloads IReactViewInstance if it is attached with a new set of options.")
56
- /*Windows.Foundation.IAsyncAction*/ void ReloadViewInstanceWithOptions(ReactViewOptions options);
56
+ Windows.Foundation.IAsyncAction ReloadViewInstanceWithOptions(ReactViewOptions options);
57
57
 
58
58
  DOC_STRING("Unloads the attached IReactViewInstance.")
59
- /*Windows.Foundation.IAsyncAction*/ void UnloadViewInstance();
59
+ Windows.Foundation.IAsyncAction UnloadViewInstance();
60
60
 
61
61
  DOC_STRING("Attaches IReactViewInstance to the IReactViewHost.")
62
- /*Windows.Foundation.IAsyncAction*/ void AttachViewInstance(IReactViewInstance viewInstance);
62
+ Windows.Foundation.IAsyncAction AttachViewInstance(IReactViewInstance viewInstance);
63
63
 
64
64
  DOC_STRING("Detaches IReactViewInstance from the IReactViewHost.")
65
- /*Windows.Foundation.IAsyncAction*/ void DetachViewInstance();
65
+ Windows.Foundation.IAsyncAction DetachViewInstance();
66
66
  }
67
67
 
68
68
  [experimental]