react-native-windows 0.65.2 → 0.65.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.
- package/CHANGELOG.json +79 -1
- package/CHANGELOG.md +43 -8
- package/Microsoft.ReactNative/IReactDispatcher.cpp +40 -2
- package/Microsoft.ReactNative/IReactDispatcher.h +19 -3
- package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +7 -6
- package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -3
- package/Microsoft.ReactNative/ReactCoreInjection.cpp +18 -9
- package/Microsoft.ReactNative/ReactCoreInjection.h +5 -6
- package/Microsoft.ReactNative/ReactCoreInjection.idl +5 -5
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +137 -130
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +2 -1
- package/Microsoft.ReactNative/RedBox.cpp +11 -9
- package/Microsoft.ReactNative/RedBox.h +2 -1
- package/Microsoft.ReactNative/RedBoxHandler.cpp +1 -1
- package/Microsoft.ReactNative/packages.config +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +1993 -0
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +21 -0
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +6 -0
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +6 -0
- package/Mso/future/futureWinRT.h +3 -1
- package/PropertySheets/JSEngine.props +4 -3
- package/Scripts/OfficeReact.Win32.nuspec +6 -4
- package/Shared/JSI/NapiJsiV8RuntimeHolder.cpp +1 -1
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
- package/Shared/Threading/MessageDispatchQueue.cpp +79 -0
- package/Shared/Threading/MessageDispatchQueue.h +31 -0
- package/package.json +4 -4
|
@@ -350,168 +350,174 @@ void ReactInstanceWin::Initialize() noexcept {
|
|
|
350
350
|
});
|
|
351
351
|
#endif
|
|
352
352
|
|
|
353
|
-
|
|
354
|
-
#ifndef CORE_ABI
|
|
353
|
+
m_uiQueue->Post([this, weakThis = Mso::WeakPtr{this}]() noexcept {
|
|
355
354
|
// Objects that must be created on the UI thread
|
|
356
355
|
if (auto strongThis = weakThis.GetStrongPtr()) {
|
|
356
|
+
#ifndef CORE_ABI
|
|
357
357
|
strongThis->m_appTheme = std::make_shared<Microsoft::ReactNative::AppTheme>(
|
|
358
358
|
strongThis->GetReactContext(), strongThis->m_uiMessageThread.LoadWithLock());
|
|
359
359
|
Microsoft::ReactNative::I18nManager::InitI18nInfo(
|
|
360
360
|
winrt::Microsoft::ReactNative::ReactPropertyBag(strongThis->Options().Properties));
|
|
361
361
|
strongThis->m_appearanceListener = Mso::Make<Microsoft::ReactNative::AppearanceChangeListener>(
|
|
362
|
-
strongThis->GetReactContext(), strongThis->m_uiQueue);
|
|
363
|
-
|
|
362
|
+
strongThis->GetReactContext(), *(strongThis->m_uiQueue));
|
|
364
363
|
Microsoft::ReactNative::DeviceInfoHolder::InitDeviceInfoHolder(strongThis->GetReactContext());
|
|
365
|
-
}
|
|
366
364
|
#endif
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
// auto cxxModulesProviders = GetCxxModuleProviders();
|
|
370
|
-
|
|
371
|
-
auto devSettings = std::make_shared<facebook::react::DevSettings>();
|
|
372
|
-
devSettings->useJITCompilation = m_options.EnableJITCompilation;
|
|
373
|
-
devSettings->sourceBundleHost = SourceBundleHost();
|
|
374
|
-
devSettings->sourceBundlePort = SourceBundlePort();
|
|
375
|
-
devSettings->debugBundlePath = DebugBundlePath();
|
|
376
|
-
devSettings->liveReloadCallback = GetLiveReloadCallback();
|
|
377
|
-
devSettings->errorCallback = GetErrorCallback();
|
|
378
|
-
devSettings->loggingCallback = GetLoggingCallback();
|
|
379
|
-
m_redboxHandler = devSettings->redboxHandler = std::move(GetRedBoxHandler());
|
|
380
|
-
devSettings->useDirectDebugger = m_useDirectDebugger;
|
|
381
|
-
devSettings->debuggerBreakOnNextLine = m_debuggerBreakOnNextLine;
|
|
382
|
-
devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort;
|
|
383
|
-
devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName;
|
|
384
|
-
devSettings->useWebDebugger = m_useWebDebugger;
|
|
385
|
-
devSettings->useFastRefresh = m_isFastReloadEnabled;
|
|
386
|
-
// devSettings->memoryTracker = GetMemoryTracker();
|
|
387
|
-
devSettings->bundleRootPath = BundleRootPath();
|
|
388
|
-
|
|
389
|
-
devSettings->waitingForDebuggerCallback = GetWaitingForDebuggerCallback();
|
|
390
|
-
devSettings->debuggerAttachCallback = GetDebuggerAttachCallback();
|
|
391
|
-
#ifndef CORE_ABI
|
|
392
|
-
devSettings->showDevMenuCallback = [weakThis]() noexcept {
|
|
365
|
+
|
|
366
|
+
strongThis->Queue().Post([this, weakThis]() noexcept {
|
|
393
367
|
if (auto strongThis = weakThis.GetStrongPtr()) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
368
|
+
// auto cxxModulesProviders = GetCxxModuleProviders();
|
|
369
|
+
|
|
370
|
+
auto devSettings = std::make_shared<facebook::react::DevSettings>();
|
|
371
|
+
devSettings->useJITCompilation = m_options.EnableJITCompilation;
|
|
372
|
+
devSettings->sourceBundleHost = SourceBundleHost();
|
|
373
|
+
devSettings->sourceBundlePort = SourceBundlePort();
|
|
374
|
+
devSettings->debugBundlePath = DebugBundlePath();
|
|
375
|
+
devSettings->liveReloadCallback = GetLiveReloadCallback();
|
|
376
|
+
devSettings->errorCallback = GetErrorCallback();
|
|
377
|
+
devSettings->loggingCallback = GetLoggingCallback();
|
|
378
|
+
m_redboxHandler = devSettings->redboxHandler = std::move(GetRedBoxHandler());
|
|
379
|
+
devSettings->useDirectDebugger = m_useDirectDebugger;
|
|
380
|
+
devSettings->debuggerBreakOnNextLine = m_debuggerBreakOnNextLine;
|
|
381
|
+
devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort;
|
|
382
|
+
devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName;
|
|
383
|
+
devSettings->useWebDebugger = m_useWebDebugger;
|
|
384
|
+
devSettings->useFastRefresh = m_isFastReloadEnabled;
|
|
385
|
+
// devSettings->memoryTracker = GetMemoryTracker();
|
|
386
|
+
devSettings->bundleRootPath = BundleRootPath();
|
|
387
|
+
|
|
388
|
+
devSettings->waitingForDebuggerCallback = GetWaitingForDebuggerCallback();
|
|
389
|
+
devSettings->debuggerAttachCallback = GetDebuggerAttachCallback();
|
|
390
|
+
|
|
391
|
+
#ifndef CORE_ABI
|
|
392
|
+
devSettings->showDevMenuCallback = [weakThis]() noexcept {
|
|
393
|
+
if (auto strongThis = weakThis.GetStrongPtr()) {
|
|
394
|
+
strongThis->m_uiQueue->Post([context = strongThis->m_reactContext]() {
|
|
395
|
+
Microsoft::ReactNative::DevMenuManager::Show(context->Properties());
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
399
|
#endif
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
401
|
+
// Now that ReactNativeWindows is building outside devmain, it is missing
|
|
402
|
+
// fix given by PR https://github.com/microsoft/react-native-windows/pull/2624 causing
|
|
403
|
+
// regression. We're turning off console redirection till the fix is available in devmain.
|
|
404
|
+
// Bug https://office.visualstudio.com/DefaultCollection/OC/_workitems/edit/3441551 is tracking this
|
|
405
|
+
devSettings->debuggerConsoleRedirection =
|
|
406
|
+
false; // JSHost::ChangeGate::ChakraCoreDebuggerConsoleRedirection();
|
|
406
407
|
|
|
407
408
|
#ifdef CORE_ABI
|
|
408
|
-
|
|
409
|
+
std::vector<facebook::react::NativeModuleDescription> cxxModules;
|
|
409
410
|
#else
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
411
|
+
// Acquire default modules and then populate with custom modules.
|
|
412
|
+
// Note that some of these have custom thread affinity.
|
|
413
|
+
std::vector<facebook::react::NativeModuleDescription> cxxModules = Microsoft::ReactNative::GetCoreModules(
|
|
414
|
+
m_batchingUIThread,
|
|
415
|
+
m_jsMessageThread.Load(),
|
|
416
|
+
std::move(m_appTheme),
|
|
417
|
+
std::move(m_appearanceListener),
|
|
418
|
+
m_reactContext);
|
|
418
419
|
#endif
|
|
419
420
|
|
|
420
|
-
|
|
421
|
+
auto nmp = std::make_shared<winrt::Microsoft::ReactNative::NativeModulesProvider>();
|
|
421
422
|
|
|
422
|
-
|
|
423
|
+
LoadModules(nmp, m_options.TurboModuleProvider);
|
|
423
424
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
auto modules = nmp->GetModules(m_reactContext, m_jsMessageThread.Load());
|
|
426
|
+
cxxModules.insert(
|
|
427
|
+
cxxModules.end(), std::make_move_iterator(modules.begin()), std::make_move_iterator(modules.end()));
|
|
427
428
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
429
|
+
if (m_options.ModuleProvider != nullptr) {
|
|
430
|
+
std::vector<facebook::react::NativeModuleDescription> customCxxModules =
|
|
431
|
+
m_options.ModuleProvider->GetModules(m_reactContext, m_jsMessageThread.Load());
|
|
432
|
+
cxxModules.insert(std::end(cxxModules), std::begin(customCxxModules), std::end(customCxxModules));
|
|
433
|
+
}
|
|
433
434
|
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
|
|
436
|
+
std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
|
|
436
437
|
|
|
437
|
-
|
|
438
|
-
|
|
438
|
+
switch (m_options.JsiEngine) {
|
|
439
|
+
case JSIEngine::Hermes:
|
|
439
440
|
#if defined(USE_HERMES)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
devSettings->jsiRuntimeHolder =
|
|
442
|
+
std::make_shared<facebook::react::HermesRuntimeHolder>(devSettings, m_jsMessageThread.Load());
|
|
443
|
+
devSettings->inlineSourceMap = false;
|
|
444
|
+
break;
|
|
444
445
|
#endif
|
|
445
|
-
|
|
446
|
+
case JSIEngine::V8:
|
|
446
447
|
#if defined(USE_V8)
|
|
447
448
|
#ifndef CORE_ABI
|
|
448
|
-
|
|
449
|
-
|
|
449
|
+
preparedScriptStore =
|
|
450
|
+
std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(getApplicationLocalFolder());
|
|
450
451
|
#endif // CORE_ABI
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
452
|
+
devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
|
|
453
|
+
devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
|
|
454
|
+
break;
|
|
454
455
|
#endif // USE_V8
|
|
455
|
-
|
|
456
|
+
case JSIEngine::Chakra:
|
|
456
457
|
#ifndef CORE_ABI
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
458
|
+
if (m_options.EnableByteCodeCaching || !m_options.ByteCodeFileUri.empty()) {
|
|
459
|
+
scriptStore = std::make_unique<Microsoft::ReactNative::UwpScriptStore>();
|
|
460
|
+
preparedScriptStore = std::make_unique<Microsoft::ReactNative::UwpPreparedScriptStore>(
|
|
461
|
+
winrt::to_hstring(m_options.ByteCodeFileUri));
|
|
462
|
+
}
|
|
462
463
|
#endif
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
464
|
+
devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::JSI::ChakraRuntimeHolder>(
|
|
465
|
+
devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
467
468
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
469
|
+
m_jsiRuntimeHolder = devSettings->jsiRuntimeHolder;
|
|
470
|
+
|
|
471
|
+
try {
|
|
472
|
+
// We need to keep the instance wrapper alive as its destruction shuts down the native queue.
|
|
473
|
+
m_options.TurboModuleProvider->SetReactContext(
|
|
474
|
+
winrt::make<implementation::ReactContext>(Mso::Copy(m_reactContext)));
|
|
475
|
+
auto bundleRootPath = devSettings->bundleRootPath;
|
|
476
|
+
auto instanceWrapper = facebook::react::CreateReactInstance(
|
|
477
|
+
std::shared_ptr<facebook::react::Instance>(strongThis->m_instance.Load()),
|
|
478
|
+
std::move(bundleRootPath), // bundleRootPath
|
|
479
|
+
std::move(cxxModules),
|
|
480
|
+
m_options.TurboModuleProvider,
|
|
481
|
+
std::make_unique<BridgeUIBatchInstanceCallback>(weakThis),
|
|
482
|
+
m_jsMessageThread.Load(),
|
|
483
|
+
Mso::Copy(m_batchingUIThread),
|
|
484
|
+
std::move(devSettings));
|
|
485
|
+
|
|
486
|
+
m_instanceWrapper.Exchange(std::move(instanceWrapper));
|
|
486
487
|
|
|
487
488
|
#ifdef USE_FABRIC
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
489
|
+
// Eagerly init the FabricUI binding
|
|
490
|
+
if (m_options.EnableFabric()) {
|
|
491
|
+
Microsoft::ReactNative::SchedulerSettings::SetRuntimeExecutor(
|
|
492
|
+
winrt::Microsoft::ReactNative::ReactPropertyBag(m_reactContext->Properties()),
|
|
493
|
+
m_instanceWrapper.Load()->GetInstance()->getRuntimeExecutor(false /*shouldFlush*/));
|
|
494
|
+
m_options.TurboModuleProvider->getModule("FabricUIManagerBinding", m_instance.Load()->getJSCallInvoker());
|
|
495
|
+
}
|
|
495
496
|
#endif
|
|
497
|
+
LoadJSBundles();
|
|
498
|
+
|
|
499
|
+
if (UseDeveloperSupport() && State() != ReactInstanceState::HasError) {
|
|
500
|
+
folly::dynamic params = folly::dynamic::array(
|
|
501
|
+
STRING(RN_PLATFORM),
|
|
502
|
+
DebugBundlePath(),
|
|
503
|
+
SourceBundleHost(),
|
|
504
|
+
SourceBundlePort(),
|
|
505
|
+
m_isFastReloadEnabled);
|
|
506
|
+
m_instance.Load()->callJSFunction("HMRClient", "setup", std::move(params));
|
|
507
|
+
}
|
|
496
508
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
509
|
+
} catch (std::exception &e) {
|
|
510
|
+
OnErrorWithMessage(e.what());
|
|
511
|
+
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
512
|
+
} catch (winrt::hresult_error const &e) {
|
|
513
|
+
OnErrorWithMessage(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()));
|
|
514
|
+
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
515
|
+
} catch (...) {
|
|
516
|
+
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
517
|
+
}
|
|
503
518
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
OnErrorWithMessage(e.what());
|
|
507
|
-
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
508
|
-
} catch (winrt::hresult_error const &e) {
|
|
509
|
-
OnErrorWithMessage(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()));
|
|
510
|
-
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
511
|
-
} catch (...) {
|
|
512
|
-
OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
|
|
513
|
-
}
|
|
514
|
-
}
|
|
519
|
+
});
|
|
520
|
+
};
|
|
515
521
|
});
|
|
516
522
|
}
|
|
517
523
|
|
|
@@ -656,10 +662,11 @@ void ReactInstanceWin::InitNativeMessageThread() noexcept {
|
|
|
656
662
|
|
|
657
663
|
void ReactInstanceWin::InitUIMessageThread() noexcept {
|
|
658
664
|
// Native queue was already given us in constructor.
|
|
659
|
-
|
|
665
|
+
|
|
666
|
+
m_uiQueue = winrt::Microsoft::ReactNative::implementation::ReactDispatcher::GetUIDispatchQueue2(m_options.Properties);
|
|
660
667
|
VerifyElseCrashSz(m_uiQueue, "No UI Dispatcher provided");
|
|
661
|
-
m_uiMessageThread.Exchange(
|
|
662
|
-
|
|
668
|
+
m_uiMessageThread.Exchange(std::make_shared<MessageDispatchQueue2>(
|
|
669
|
+
*m_uiQueue, Mso::MakeWeakMemberFunctor(this, &ReactInstanceWin::OnError)));
|
|
663
670
|
|
|
664
671
|
auto batchingUIThread = Microsoft::ReactNative::MakeBatchingQueueThread(m_uiMessageThread.Load());
|
|
665
672
|
m_batchingUIThread = batchingUIThread;
|
|
@@ -744,7 +751,7 @@ std::shared_ptr<IRedBoxHandler> ReactInstanceWin::GetRedBoxHandler() noexcept {
|
|
|
744
751
|
#ifndef CORE_ABI
|
|
745
752
|
} else if (UseDeveloperSupport()) {
|
|
746
753
|
auto localWkReactHost = m_weakReactHost;
|
|
747
|
-
return CreateDefaultRedBoxHandler(std::move(localWkReactHost),
|
|
754
|
+
return CreateDefaultRedBoxHandler(std::move(localWkReactHost), *m_uiQueue);
|
|
748
755
|
#endif
|
|
749
756
|
} else {
|
|
750
757
|
return {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
+
#include "IReactDispatcher.h"
|
|
6
7
|
#include "IReactInstanceInternal.h"
|
|
7
8
|
#include "ReactContext.h"
|
|
8
9
|
#include "ReactNativeHeaders.h"
|
|
@@ -178,7 +179,7 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal>
|
|
|
178
179
|
std::shared_ptr<Microsoft::ReactNative::AppTheme> m_appTheme;
|
|
179
180
|
Mso::CntPtr<Microsoft::ReactNative::AppearanceChangeListener> m_appearanceListener;
|
|
180
181
|
#endif
|
|
181
|
-
Mso::
|
|
182
|
+
Mso::CntPtr<Mso::React::IDispatchQueue2> m_uiQueue;
|
|
182
183
|
std::deque<JSCallEntry> m_jsCallQueue;
|
|
183
184
|
|
|
184
185
|
std::shared_ptr<facebook::jsi::RuntimeHolderLazyInit> m_jsiRuntimeHolder;
|
|
@@ -408,8 +408,10 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
|
|
|
408
408
|
* This class is implemented such that the methods on IRedBoxHandler are thread safe.
|
|
409
409
|
*/
|
|
410
410
|
struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultRedBoxHandler>, IRedBoxHandler {
|
|
411
|
-
DefaultRedBoxHandler(
|
|
412
|
-
|
|
411
|
+
DefaultRedBoxHandler(
|
|
412
|
+
Mso::WeakPtr<Mso::React::IReactHost> &&weakReactHost,
|
|
413
|
+
const Mso::React::IDispatchQueue2 &uiQueue) noexcept
|
|
414
|
+
: m_weakReactHost{std::move(weakReactHost)}, m_uiQueue{&uiQueue} {}
|
|
413
415
|
|
|
414
416
|
~DefaultRedBoxHandler() {
|
|
415
417
|
// Hide any currently showing redBoxes
|
|
@@ -418,7 +420,7 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
|
|
|
418
420
|
std::scoped_lock lock{m_lockRedBox};
|
|
419
421
|
std::swap(m_redBoxes, redBoxes);
|
|
420
422
|
}
|
|
421
|
-
m_uiQueue
|
|
423
|
+
m_uiQueue->Post([redBoxes = std::move(redBoxes)]() {
|
|
422
424
|
for (const auto &redBox : redBoxes) {
|
|
423
425
|
redBox->Dismiss();
|
|
424
426
|
}
|
|
@@ -472,14 +474,14 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
|
|
|
472
474
|
}
|
|
473
475
|
|
|
474
476
|
if (redbox) {
|
|
475
|
-
m_uiQueue
|
|
477
|
+
m_uiQueue->Post([redboxCaptured = std::move(redbox), errorInfo = std::move(info)]() {
|
|
476
478
|
redboxCaptured->UpdateError(std::move(errorInfo));
|
|
477
479
|
});
|
|
478
480
|
}
|
|
479
481
|
}
|
|
480
482
|
|
|
481
483
|
virtual void dismissRedbox() override {
|
|
482
|
-
m_uiQueue
|
|
484
|
+
m_uiQueue->Post([wkthis = std::weak_ptr(shared_from_this())]() {
|
|
483
485
|
if (auto pthis = wkthis.lock()) {
|
|
484
486
|
std::scoped_lock lock{pthis->m_lockRedBox};
|
|
485
487
|
if (!pthis->m_redBoxes.empty())
|
|
@@ -523,11 +525,11 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
|
|
|
523
525
|
return;
|
|
524
526
|
m_showingRedBox = true;
|
|
525
527
|
|
|
526
|
-
m_uiQueue
|
|
528
|
+
m_uiQueue->Post([redboxCaptured = std::move(redbox)]() { redboxCaptured->ShowNewJSError(); });
|
|
527
529
|
}
|
|
528
530
|
|
|
529
531
|
private:
|
|
530
|
-
const Mso::
|
|
532
|
+
Mso::CntPtr<const Mso::React::IDispatchQueue2> m_uiQueue;
|
|
531
533
|
bool m_showingRedBox{false}; // Access from UI Thread only
|
|
532
534
|
std::mutex m_lockRedBox;
|
|
533
535
|
std::vector<std::shared_ptr<RedBox>> m_redBoxes; // Protected by m_lockRedBox
|
|
@@ -575,9 +577,9 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
|
|
|
575
577
|
|
|
576
578
|
std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
|
|
577
579
|
Mso::WeakPtr<IReactHost> &&weakReactHost,
|
|
578
|
-
Mso::
|
|
580
|
+
const Mso::React::IDispatchQueue2 &uiQueue) noexcept {
|
|
579
581
|
#ifndef CORE_ABI
|
|
580
|
-
return std::make_shared<DefaultRedBoxHandler>(std::move(weakReactHost),
|
|
582
|
+
return std::make_shared<DefaultRedBoxHandler>(std::move(weakReactHost), uiQueue);
|
|
581
583
|
#else
|
|
582
584
|
return nullptr;
|
|
583
585
|
#endif
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
#pragma once
|
|
4
4
|
#include <DevSettings.h>
|
|
5
|
+
#include "IReactDispatcher.h"
|
|
5
6
|
#include "IRedBoxHandler.h"
|
|
6
7
|
#include "ReactHost/React.h"
|
|
7
8
|
|
|
@@ -12,5 +13,5 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
|
|
|
12
13
|
|
|
13
14
|
std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
|
|
14
15
|
Mso::WeakPtr<IReactHost> &&weakReactHost,
|
|
15
|
-
Mso::
|
|
16
|
+
const Mso::React::IDispatchQueue2 &uiQueue) noexcept;
|
|
16
17
|
} // namespace Mso::React
|
|
@@ -34,7 +34,7 @@ struct DefaultRedBoxHandler : winrt::implements<DefaultRedBoxHandler, IRedBoxHan
|
|
|
34
34
|
auto hostImpl = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeHost>(host);
|
|
35
35
|
Mso::WeakPtr<Mso::React::IReactHost> wkHost(hostImpl->ReactHost());
|
|
36
36
|
m_redBoxHandler = Mso::React::CreateDefaultRedBoxHandler(
|
|
37
|
-
std::move(wkHost), ReactDispatcher::
|
|
37
|
+
std::move(wkHost), *ReactDispatcher::GetUIDispatchQueue2(host.InstanceSettings().Properties()));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
void ShowNewError(IRedBoxErrorInfo const &info, RedBoxErrorType type) noexcept {
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<package id="Microsoft.Windows.CppWinRT" version="2.0.210312.4" targetFramework="native" />
|
|
9
9
|
<package id="Microsoft.WinUI" version="3.0.0-preview4.210210.4" targetFramework="native" />
|
|
10
10
|
<package id="ReactNative.Hermes.Windows" version="0.8.0-ms.0" targetFramework="native" />
|
|
11
|
-
<!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.
|
|
11
|
+
<!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.5" targetFramework="native" / -->
|
|
12
12
|
</packages>
|