react-native-windows 0.66.8 → 0.66.9

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
@@ -2,7 +2,22 @@
2
2
  "name": "react-native-windows",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 24 Jan 2022 16:10:41 GMT",
5
+ "date": "Mon, 31 Jan 2022 16:12:08 GMT",
6
+ "tag": "react-native-windows_v0.66.9",
7
+ "version": "0.66.9",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Better reporting of failures to load the bundle file",
12
+ "author": "30809111+acoates-ms@users.noreply.github.com",
13
+ "commit": "0951f3da2e746f1feb0bd7e96d3dd8d5d936d6fb",
14
+ "package": "react-native-windows"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 24 Jan 2022 16:11:33 GMT",
6
21
  "tag": "react-native-windows_v0.66.8",
7
22
  "version": "0.66.8",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 24 Jan 2022 16:10:41 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 31 Jan 2022 16:12:08 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.66.8
7
+ ## 0.66.9
8
8
 
9
- Mon, 24 Jan 2022 16:10:41 GMT
9
+ Mon, 31 Jan 2022 16:12:08 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Promote 0.66 to legacy (ngerlem@microsoft.com)
13
+ - Better reporting of failures to load the bundle file (30809111+acoates-ms@users.noreply.github.com)
14
14
 
15
+ ## 0.66.8
16
+
17
+ Mon, 24 Jan 2022 16:11:33 GMT
18
+
19
+ ### Patches
20
+
21
+ - Promote 0.66 to legacy (ngerlem@microsoft.com)
22
+
15
23
  ## 0.66.7
16
24
 
17
25
  Mon, 17 Jan 2022 16:12:35 GMT
@@ -139,14 +139,9 @@ struct ReactViewInstance : public Mso::UnknownObject<Mso::RefCountStrategy::Weak
139
139
  inline Mso::Future<void> PostInUIQueue(winrt::delegate<ReactNative::IReactViewInstance> const &action) noexcept {
140
140
  Mso::Promise<void> promise;
141
141
 
142
- // ReactViewInstance has shorter lifetime than ReactRootControl. Thus, we capture this WeakPtr.
143
- m_uiDispatcher.Post([weakThis = Mso::WeakPtr{this}, promise, action{std::move(action)}]() mutable noexcept {
144
- if (auto strongThis = weakThis.GetStrongPtr()) {
145
- action(strongThis->m_rootControl);
146
- promise.SetValue();
147
- } else {
148
- promise.TryCancel();
149
- }
142
+ m_uiDispatcher.Post([control = m_rootControl, promise, action{std::move(action)}]() mutable noexcept {
143
+ action(control);
144
+ promise.SetValue();
150
145
  });
151
146
  return promise.AsFuture();
152
147
  }
@@ -159,9 +154,7 @@ winrt::Windows::Foundation::IAsyncAction ReactViewHost::AttachViewInstance(
159
154
  }
160
155
 
161
156
  winrt::Windows::Foundation::IAsyncAction ReactViewHost::DetachViewInstance() noexcept {
162
- Mso::Promise<void> promise;
163
- promise.SetValue();
164
- return make<Mso::AsyncActionFutureAdapter>(promise.AsFuture());
157
+ return make<Mso::AsyncActionFutureAdapter>(m_viewHost->DetachViewInstance());
165
158
  }
166
159
 
167
160
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -379,8 +379,13 @@ Mso::Future<void> ReactHost::LoadInQueue(ReactOptions &&options) noexcept {
379
379
  }
380
380
  }
381
381
 
382
- return whenLoaded.AsFuture().Then(m_executor, [this](Mso::Maybe<void> && /*value*/) noexcept {
382
+ return whenLoaded.AsFuture().Then(m_executor, [this](Mso::Maybe<void> &&value) noexcept {
383
383
  std::vector<Mso::Future<void>> loadCompletionList;
384
+
385
+ if (value.IsError()) {
386
+ return Mso::MakeFailedFuture<void>(std::move(value.TakeError()));
387
+ }
388
+
384
389
  ForEachViewHost([&loadCompletionList](auto &viewHost) noexcept {
385
390
  loadCompletionList.push_back(viewHost.UpdateViewInstanceInQueue());
386
391
  });
@@ -224,9 +224,11 @@ ReactInstanceWin::ReactInstanceWin(
224
224
  m_whenLoaded.AsFuture()
225
225
  .Then<Mso::Executors::Inline>(
226
226
  [onLoaded = m_options.OnInstanceLoaded, reactContext = m_reactContext](Mso::Maybe<void> &&value) noexcept {
227
+ auto errCode = value.IsError() ? value.TakeError() : Mso::ErrorCode();
227
228
  if (onLoaded) {
228
- onLoaded.Get()->Invoke(reactContext, value.IsError() ? value.TakeError() : Mso::ErrorCode());
229
+ onLoaded.Get()->Invoke(reactContext, errCode);
229
230
  }
231
+ return Mso::Maybe<void>(errCode);
230
232
  })
231
233
  .Then(Queue(), [whenLoaded = std::move(whenLoaded)](Mso::Maybe<void> &&value) noexcept {
232
234
  whenLoaded.SetValue(std::move(value));
@@ -468,7 +470,7 @@ void ReactInstanceWin::Initialize() noexcept {
468
470
  m_options.TurboModuleProvider,
469
471
  std::make_unique<BridgeUIBatchInstanceCallback>(weakThis),
470
472
  m_jsMessageThread.Load(),
471
- Mso::Copy(m_batchingUIThread),
473
+ m_nativeMessageThread.Load(),
472
474
  std::move(devSettings));
473
475
 
474
476
  m_instanceWrapper.Exchange(std::move(instanceWrapper));
@@ -483,6 +485,16 @@ void ReactInstanceWin::Initialize() noexcept {
483
485
  }
484
486
  #endif
485
487
 
488
+ // The InstanceCreated event can be used to augment the JS environment for all JS code. So it needs to be
489
+ // triggered before any platform JS code is run. Using m_jsMessageThread instead of jsDispatchQueue avoids
490
+ // waiting for the JSCaller which can delay the event until after certain JS code has already run
491
+ m_jsMessageThread.Load()->runOnQueue(
492
+ [onCreated = m_options.OnInstanceCreated, reactContext = m_reactContext]() noexcept {
493
+ if (onCreated) {
494
+ onCreated.Get()->Invoke(reactContext);
495
+ }
496
+ });
497
+
486
498
  LoadJSBundles();
487
499
 
488
500
  if (UseDeveloperSupport() && State() != ReactInstanceState::HasError) {
@@ -558,7 +570,9 @@ void ReactInstanceWin::LoadJSBundles() noexcept {
558
570
 
559
571
  try {
560
572
  instanceWrapper->loadBundleSync(Mso::Copy(strongThis->JavaScriptBundleFile()));
561
- strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
573
+ if (strongThis->State() != ReactInstanceState::HasError) {
574
+ strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
575
+ }
562
576
  } catch (...) {
563
577
  strongThis->OnReactInstanceLoaded(Mso::ExceptionErrorProvider().MakeErrorCode(std::current_exception()));
564
578
  }
@@ -629,13 +643,6 @@ void ReactInstanceWin::InitJSMessageThread() noexcept {
629
643
  Mso::Copy(m_whenDestroyed));
630
644
  auto jsDispatchQueue = Mso::DispatchQueue::MakeCustomQueue(Mso::CntPtr(scheduler));
631
645
 
632
- // This work item will be processed as a first item in JS queue when the react instance is created.
633
- jsDispatchQueue.Post([onCreated = m_options.OnInstanceCreated, reactContext = m_reactContext]() noexcept {
634
- if (onCreated) {
635
- onCreated.Get()->Invoke(reactContext);
636
- }
637
- });
638
-
639
646
  auto jsDispatcher =
640
647
  winrt::make<winrt::Microsoft::ReactNative::implementation::ReactDispatcher>(Mso::Copy(jsDispatchQueue));
641
648
  m_options.Properties.Set(ReactDispatcherHelper::JSDispatcherProperty(), jsDispatcher);
@@ -27,18 +27,20 @@ struct AsyncActionFutureAdapter : winrt::implements<
27
27
  if (strongThis->m_status == AsyncStatus::Started) {
28
28
  if (result.IsValue()) {
29
29
  strongThis->m_status = AsyncStatus::Completed;
30
- if (strongThis->m_completedAssigned) {
31
- handler = std::move(strongThis->m_completed);
32
- }
33
30
  } else {
34
- strongThis->m_status = AsyncStatus::Error;
35
31
  strongThis->m_error = result.GetError();
32
+ strongThis->m_status = Mso::CancellationErrorProvider().TryGetErrorInfo(strongThis->m_error, false)
33
+ ? AsyncStatus::Canceled
34
+ : AsyncStatus::Error;
35
+ }
36
+ if (strongThis->m_completedAssigned) {
37
+ handler = std::move(strongThis->m_completed);
36
38
  }
37
39
  }
38
40
  }
39
41
 
40
42
  if (handler) {
41
- invoke(handler, *strongThis, AsyncStatus::Completed);
43
+ invoke(handler, *strongThis, strongThis->m_status);
42
44
  }
43
45
  }
44
46
  });
@@ -61,86 +61,6 @@
61
61
  #include <tracing/tracing.h>
62
62
  namespace fs = std::filesystem;
63
63
 
64
- namespace {
65
-
66
- #if (defined(_MSC_VER) && !defined(WINRT))
67
-
68
- std::string GetJSBundleDirectory(
69
- const std::string &jsBundleBasePath,
70
- const std::string &jsBundleRelativePath) noexcept {
71
- // If there is a base path, use that to calculate the absolute path.
72
- if (jsBundleBasePath.length() > 0) {
73
- std::string jsBundleDirectory = jsBundleBasePath;
74
- if (jsBundleDirectory.back() != '\\')
75
- jsBundleDirectory += '\\';
76
-
77
- return jsBundleDirectory += jsBundleRelativePath;
78
- } else if (!PathIsRelativeA(jsBundleRelativePath.c_str())) {
79
- // If the given path is an absolute path, return it as-is
80
- return jsBundleRelativePath;
81
- }
82
- // Otherwise use the path of the executable file to construct the absolute
83
- // path.
84
- else {
85
- wchar_t modulePath[MAX_PATH];
86
-
87
- auto len = GetModuleFileNameW(nullptr, modulePath, _countof(modulePath));
88
-
89
- if (len == 0 || (len == _countof(modulePath) && GetLastError() == ERROR_INSUFFICIENT_BUFFER))
90
- return jsBundleRelativePath;
91
-
92
- // remove the trailing filename as we are interested in only the path
93
- auto succeeded = PathRemoveFileSpecW(modulePath);
94
- if (!succeeded)
95
- return jsBundleRelativePath;
96
-
97
- std::string jsBundlePath = Microsoft::Common::Unicode::Utf16ToUtf8(modulePath, wcslen(modulePath));
98
- if (!jsBundlePath.empty() && jsBundlePath.back() != '\\')
99
- jsBundlePath += '\\';
100
-
101
- return jsBundlePath += jsBundleRelativePath;
102
- }
103
- }
104
-
105
- std::string GetJSBundleFilePath(const std::string &jsBundleBasePath, const std::string &jsBundleRelativePath) {
106
- auto jsBundleFilePath = GetJSBundleDirectory(jsBundleBasePath, jsBundleRelativePath);
107
-
108
- // Usually, the module name: "module name" + "." + "platform name", for
109
- // example "lpc.win32". If we can not find the the bundle.js file under the
110
- // normal folder, we are trying to find it under the folder without the dot
111
- // (e.g. "lpcwin32"). VSO:1997035 remove this code after we have better name
112
- // convension
113
- if (PathFileExistsA((jsBundleFilePath + "\\bundle.js").c_str())) {
114
- jsBundleFilePath += "\\bundle.js";
115
- } else {
116
- // remove the dot only if is belongs to the bundle file name.
117
- size_t lastDotPosition = jsBundleFilePath.find_last_of('.');
118
- size_t bundleFilePosition = jsBundleFilePath.find_last_of('\\');
119
- if (lastDotPosition != std::string::npos &&
120
- (bundleFilePosition == std::string::npos || lastDotPosition > bundleFilePosition)) {
121
- jsBundleFilePath.erase(lastDotPosition, 1);
122
- }
123
-
124
- jsBundleFilePath += "\\bundle.js";
125
-
126
- // Back before we have base path plumbed through, we made win32 force a
127
- // seperate folder for each bundle by appending bundle.js Now that we have
128
- // base path, we can handle multiple SDXs with the same index name so we
129
- // should switch to using the same scheme as all the other platforms (and
130
- // the bundle server)
131
- // TODO: We should remove all the previous logic and use the same names as
132
- // the other platforms...
133
- if (!PathFileExistsA(jsBundleFilePath.c_str())) {
134
- jsBundleFilePath = GetJSBundleDirectory(jsBundleBasePath, jsBundleRelativePath) + ".bundle";
135
- }
136
- }
137
-
138
- return jsBundleFilePath;
139
- }
140
- #endif
141
-
142
- } // namespace
143
-
144
64
  using namespace facebook;
145
65
  using namespace Microsoft::JSI;
146
66
 
@@ -560,22 +480,13 @@ void InstanceImpl::loadBundleInternal(std::string &&jsBundleRelativePath, bool s
560
480
  }
561
481
  } else {
562
482
  #if (defined(_MSC_VER) && !defined(WINRT))
563
- auto fullBundleFilePath = GetJSBundleFilePath(m_jsBundleBasePath, jsBundleRelativePath);
564
-
565
- // If fullBundleFilePath exists, load User bundle.
566
- // Otherwise all bundles (User and Platform) are loaded through
567
- // platformBundles.
568
- if (PathFileExistsA(fullBundleFilePath.c_str())) {
569
- auto bundleString = FileMappingBigString::fromPath(fullBundleFilePath);
570
- m_innerInstance->loadScriptFromString(std::move(bundleString), std::move(fullBundleFilePath), synchronously);
571
- }
572
-
483
+ std::string bundlePath = (fs::path(m_devSettings->bundleRootPath) / jsBundleRelativePath).string();
484
+ auto bundleString = FileMappingBigString::fromPath(bundlePath);
573
485
  #else
574
486
  std::string bundlePath = (fs::path(m_devSettings->bundleRootPath) / (jsBundleRelativePath + ".bundle")).string();
575
-
576
487
  auto bundleString = std::make_unique<::Microsoft::ReactNative::StorageFileBigString>(bundlePath);
577
- m_innerInstance->loadScriptFromString(std::move(bundleString), jsBundleRelativePath, synchronously);
578
488
  #endif
489
+ m_innerInstance->loadScriptFromString(std::move(bundleString), std::move(jsBundleRelativePath), synchronously);
579
490
  }
580
491
  } catch (const std::exception &e) {
581
492
  m_devSettings->errorCallback(e.what());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.66.8",
3
+ "version": "0.66.9",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",