react-native-windows 0.67.10 → 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 CHANGED
@@ -1,6 +1,66 @@
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
+ },
4
64
  {
5
65
  "date": "Mon, 30 May 2022 15:09:33 GMT",
6
66
  "tag": "react-native-windows_v0.67.10",
package/CHANGELOG.md CHANGED
@@ -1,21 +1,42 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 30 May 2022 15:09:33 GMT and should not be manually modified.
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.10
7
+ ## 0.67.11
8
8
 
9
- Mon, 30 May 2022 15:09:33 GMT
9
+ Mon, 20 Jun 2022 15:08:04 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Expose LoadingState on ReactContext (acoates@microsoft.com)
14
- - Support PreparedScriptStore for V8 Node-API. (vmorozov@microsoft.com)
15
- - Implement Blob module (#9352) (julio@rochsquadron.net)
16
- - Fix RuntimeOptions for RNW Desktop (vmorozov@microsoft.com)
17
- - [0.67] Change CG registration for folly and fmt from `other` to `git` (jthysell@microsoft.com)
13
+ - Fix use of [[maybe_unused]] attribute (vmorozov@microsoft.com)
14
+ - Fix ExecuteJsi on instance shutdown (vmorozov@microsoft.com)
18
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
+
19
40
  ## 0.67.9
20
41
 
21
42
  Mon, 02 May 2022 15:10:57 GMT
@@ -10,16 +10,19 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
10
10
 
11
11
  namespace winrt::Microsoft::ReactNative {
12
12
 
13
- // Get JSI Runtime from the current JS dispatcher thread.
14
- // If it is not found, then create it and store it in the context.Properties().
15
- // Make sure that the JSI runtime holder is removed when the instance is unloaded.
16
- facebook::jsi::Runtime &GetOrCreateContextRuntime(ReactContext const &context) noexcept {
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
- VerifyElseCrashSz(abiJsiRuntime, "JSI runtime is not available");
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
- // Get JSI Runtime from the current JS dispatcher thread.
14
- // If it is not found, then create it and store it in the context.Properties().
15
- // Make sure that the JSI runtime holder is removed when the instance is unloaded.
16
- facebook::jsi::Runtime &GetOrCreateContextRuntime(ReactContext const &context) noexcept;
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
- code(GetOrCreateContextRuntime(context));
49
+ callCode(context, code, callStatus);
27
50
  } else {
28
51
  // Otherwise, schedule work in JS thread.
29
- jsDispatcher.Post([context, code]() noexcept { code(GetOrCreateContextRuntime(context)); });
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
 
@@ -287,7 +287,7 @@ inline JSValueArgWriter MakeJSValueWriter(T &&argWriter) noexcept {
287
287
 
288
288
  template <class... TArgs>
289
289
  inline JSValueArgWriter MakeJSValueWriter(TArgs &&... args) noexcept {
290
- return [&args...](IJSValueWriter const &[[maybe_unused]] writer) noexcept { (WriteValue(writer, args), ...); };
290
+ return [&args...]([[maybe_unused]] IJSValueWriter const &writer) noexcept { (WriteValue(writer, args), ...); };
291
291
  }
292
292
 
293
293
  } // namespace winrt::Microsoft::ReactNative
@@ -6,7 +6,6 @@
6
6
 
7
7
  #include "pch.h"
8
8
  #include "ReactPromise.h"
9
- #include "JSValueWriter.h"
10
9
 
11
10
  namespace winrt::Microsoft::ReactNative {
12
11
 
@@ -105,6 +104,27 @@ bool ReactPromiseBase::TrySetState(State newState) const noexcept {
105
104
  return false;
106
105
  }
107
106
 
107
+ /*static*/ MethodResultCallback ReactPromiseBase::GetRejectResultCallback(
108
+ std::function<void(ReactError const &)> const &reject) noexcept {
109
+ return [reject](IJSValueWriter const &outputWriter) noexcept {
110
+ winrt::com_ptr<JSValueTreeWriter> writer = outputWriter.as<JSValueTreeWriter>();
111
+ JSValue jsValue = writer->TakeValue();
112
+ ReactError err{};
113
+ err.Code = jsValue.AsArray()[0].AsObject()[ErrorMapKeyCode].AsString();
114
+ err.Message = jsValue.AsArray()[0].AsObject()[ErrorMapKeyMessage].AsString();
115
+ err.UserInfo = jsValue.AsArray()[0].AsObject()[ErrorMapKeyUserInfo].AsObject().Copy();
116
+ reject(err);
117
+ };
118
+ }
119
+
120
+ ReactPromise<void>::ReactPromise(
121
+ std::function<void()> const &resolve,
122
+ std::function<void(ReactError const &)> const &reject) noexcept
123
+ : ReactPromiseBase(
124
+ winrt::make<JSValueTreeWriter>(),
125
+ [resolve](IJSValueWriter const & /*outputWriter*/) noexcept { resolve(); },
126
+ GetRejectResultCallback(reject)) {}
127
+
108
128
  // Successfully resolve the ReactPromise<void>.
109
129
  void ReactPromise<void>::Resolve() const noexcept {
110
130
  if (TrySetState(State::Resolved) && m_resolve) {
@@ -5,6 +5,11 @@
5
5
  // vnext/Microsoft.ReactNative.Cxx/README.md
6
6
 
7
7
  #pragma once
8
+ #include <functional>
9
+ #include "JSValueReader.h"
10
+ #include "JSValueTreeReader.h"
11
+ #include "JSValueTreeWriter.h"
12
+ #include "JSValueWriter.h"
8
13
  #include "ReactError.h"
9
14
  #include "winrt/Microsoft.ReactNative.h"
10
15
 
@@ -35,6 +40,7 @@ struct ReactPromiseBase {
35
40
 
36
41
  protected:
37
42
  bool TrySetState(State newState) const noexcept;
43
+ static MethodResultCallback GetRejectResultCallback(std::function<void(ReactError const &)> const &reject) noexcept;
38
44
 
39
45
  protected:
40
46
  const std::shared_ptr<std::atomic<State>> m_state;
@@ -47,6 +53,10 @@ template <class T>
47
53
  struct ReactPromise : ReactPromiseBase {
48
54
  using ReactPromiseBase::ReactPromiseBase;
49
55
 
56
+ ReactPromise(
57
+ std::function<void(T const &)> const &resolve,
58
+ std::function<void(ReactError const &)> const &reject) noexcept;
59
+
50
60
  // Successfully resolve the IReactPromise with an optional value.
51
61
  void Resolve(T const &value) const noexcept;
52
62
  };
@@ -55,10 +65,27 @@ template <>
55
65
  struct ReactPromise<void> : ReactPromiseBase {
56
66
  using ReactPromiseBase::ReactPromiseBase;
57
67
 
68
+ ReactPromise(std::function<void()> const &resolve, std::function<void(ReactError const &)> const &reject) noexcept;
69
+
58
70
  // Successfully resolve the IReactPromise with an optional value.
59
71
  void Resolve() const noexcept;
60
72
  };
61
73
 
74
+ template <class T>
75
+ ReactPromise<T>::ReactPromise(
76
+ std::function<void(T const &)> const &resolve,
77
+ std::function<void(ReactError const &)> const &reject) noexcept
78
+ : ReactPromiseBase(
79
+ winrt::make<JSValueTreeWriter>(),
80
+ [resolve](IJSValueWriter const &outputWriter) noexcept {
81
+ winrt::com_ptr<JSValueTreeWriter> writer = outputWriter.as<JSValueTreeWriter>();
82
+ auto reader = winrt::make<JSValueTreeReader>(writer->TakeValue());
83
+ T result{};
84
+ ReadArgs(reader, result);
85
+ resolve(result);
86
+ },
87
+ GetRejectResultCallback(reject)) {}
88
+
62
89
  // Successfully resolve the ReactPromise with an optional value.
63
90
  template <class T>
64
91
  void ReactPromise<T>::Resolve(T const &value) const noexcept {
@@ -23,7 +23,7 @@ void AddTurboModuleProvider(IReactPackageBuilder const &packageBuilder, std::wst
23
23
  IJsiHostObject abiTurboModule{nullptr};
24
24
  // We expect the initializer to be called immediately for TurboModules
25
25
  moduleBuilder.AddInitializer([&abiTurboModule](IReactContext const &context) mutable {
26
- GetOrCreateContextRuntime(ReactContext{context}); // Ensure the JSI runtime is created.
26
+ TryGetOrCreateContextRuntime(ReactContext{context}); // Ensure the JSI runtime is created.
27
27
  auto callInvoker = MakeAbiCallInvoker(context.JSDispatcher());
28
28
  auto turboModule = std::make_shared<TTurboModule>(callInvoker);
29
29
  abiTurboModule = winrt::make<JsiHostObjectWrapper>(std::move(turboModule));
@@ -10,10 +10,10 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.67.10</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.67.11</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>67</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>10</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>11</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
18
  </PropertyGroup>
19
19
  </Project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.67.10",
3
+ "version": "0.67.11",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",