Move AppState and DeviceInfo to use module spec files (#4991)

* Move more native modules to Spec files

* Move device info init to object created on UI thread.

* feedback

* format

* Change files

* Add missing method on TestAppStateModule
This commit is contained in:
Andrew Coates 2020-05-22 14:18:33 -07:00 коммит произвёл GitHub
Родитель 198ce2e375
Коммит 8dcf516f91
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
76 изменённых файлов: 457 добавлений и 1890 удалений

Просмотреть файл

@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Move DeviceInfo and AppState to new native module impl",
"packageName": "react-native-windows",
"email": "acoates@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-05-22T18:23:29.688Z"
}

Просмотреть файл

@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Include React namespace in more places",
"packageName": "react-native-windows-codegen",
"email": "acoates@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-05-22T18:23:06.977Z"
}

Просмотреть файл

@ -64,17 +64,17 @@ function translateSpecFunctionParam(
case 'FunctionTypeAnnotation': {
// Ideally we'd get more information about the expected parameters of the callback
// But the current schema doesn't seem to provide the necessary information.
return 'Callback<JSValue>';
return 'Callback<React::JSValue>';
}
case 'ArrayTypeAnnotation':
// Ideally we'd get more information about the expected type of the array
// But the current schema doesn't seem to provide the necessary information.
return 'JSValueArray';
return 'React::JSValueArray';
case 'GenericObjectTypeAnnotation':
return 'JSValueObject';
return 'React::JSValueObject';
case 'ObjectTypeAnnotation':
// TODO we have more information here, and could create a more specific type
return 'JSValueObject';
return 'React::JSValueObject';
default:
throw new Error(
`Unhandled type in translateSpecFunctionParam: ${
@ -140,9 +140,9 @@ function translateSpecReturnType(
case 'ArrayTypeAnnotation':
// Ideally we'd get more information about the expected type of the array
// But the current schema doesn't seem to provide the necessary information.
return 'JSValueArray';
return 'React::JSValueArray';
case 'GenericObjectTypeAnnotation':
return 'JSValueObject';
return 'React::JSValueObject';
default:
throw new Error(`Unhandled type: ${type.type}`);
}

Просмотреть файл

@ -5,7 +5,6 @@
#include <CreateModules.h>
#include <IUIManager.h>
#include <Modules/AppStateModule.h>
#include <Modules/NetworkingModule.h>
#include <Modules/WebSocketModule.h>
#include <NativeModuleFactories.h>
@ -61,8 +60,8 @@ shared_ptr<ITestInstance> TestRunner::GetInstance(
"Timing", [nativeQueue]() -> unique_ptr<CxxModule> { return CreateTimingModule(nativeQueue); }, nativeQueue),
// Apparently mandatory for /IntegrationTests
make_tuple(
AppStateModule::name,
[]() -> unique_ptr<CxxModule> { return make_unique<AppStateModule>(make_unique<AppState>()); },
TestAppStateModule::name,
[]() -> unique_ptr<CxxModule> { return make_unique<TestAppStateModule>(); },
nativeQueue),
// Apparently mandatory for /IntegrationTests
make_tuple(

Просмотреть файл

@ -84,4 +84,29 @@ auto TestDeviceInfoModule::getMethods() -> vector<Method> {
#pragma endregion TestDeviceInfoModule members
#pragma region TestAppStateModule members
/*static*/ string TestAppStateModule::name = "AppState";
TestAppStateModule::TestAppStateModule() {}
string TestAppStateModule::getName() {
return name;
}
auto TestAppStateModule::getConstants() -> map<string, dynamic> {
return {{"initialAppState", "active"}};
}
auto TestAppStateModule::getMethods() -> vector<Method> {
return {Method(
"getCurrentAppState",
[this](folly::dynamic args, Callback cbSuccess, Callback /*cbFailure*/) {
cbSuccess({folly::dynamic::object("app_state", "active")});
},
AsyncTag)};
}
#pragma endregion TestAppStateModule members
} // namespace Microsoft::React::Test

Просмотреть файл

@ -54,4 +54,17 @@ class TestDeviceInfoModule : public facebook::xplat::module::CxxModule {
auto getMethods() -> std::vector<Method> override;
};
class TestAppStateModule : public facebook::xplat::module::CxxModule {
public:
static std::string name;
TestAppStateModule();
std::string getName() override;
auto getConstants() -> std::map<std::string, folly::dynamic> override;
auto getMethods() -> std::vector<Method> override;
};
} // namespace Microsoft::React::Test

Просмотреть файл

@ -1,66 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include <ReactUWP/InstanceFactory.h>
#include "UwpReactInstance.h"
#include <ReactUWP/ReactRootView.h>
#include "Unicode.h"
namespace react {
namespace uwp {
std::vector<std::weak_ptr<UwpReactInstance>> &ReactInstances() noexcept {
static std::vector<std::weak_ptr<UwpReactInstance>> s_instances;
return s_instances;
}
void CleanupExpiredInstances() noexcept {
// Lets cleanup all leftover WeakPtrs.
ReactInstances().erase(
std::remove_if(
ReactInstances().begin(),
ReactInstances().end(),
[](const std::weak_ptr<UwpReactInstance> &weakInstance) { return weakInstance.lock() == nullptr; }),
ReactInstances().end());
}
REACTWINDOWS_API_(std::shared_ptr<IReactInstance>)
CreateReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider) {
return std::make_shared<UwpReactInstance>(moduleProvider, viewManagerProvider);
}
REACTWINDOWS_API_(IReactInstance *)
UnSafeCreateReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider) {
return new UwpReactInstance(moduleProvider, viewManagerProvider);
}
REACTWINDOWS_API_(std::shared_ptr<IXamlRootView>)
CreateReactRootView(XamlView parentView, const wchar_t *pJsComponentName, const ReactInstanceCreator &instanceCreator) {
// Convert input strings to std::string
std::string jsComponentName = Microsoft::Common::Unicode::Utf16ToUtf8(pJsComponentName, wcslen(pJsComponentName));
auto rootView = std::make_shared<react::uwp::ReactRootView>(parentView);
rootView->SetJSComponentName(std::move(jsComponentName));
rootView->SetInstanceCreator(instanceCreator);
return rootView;
}
// Creates a background thread message queue whose tasks will run in serialized
// order
REACTWINDOWS_API_(std::shared_ptr<facebook::react::MessageQueueThread>)
CreateWorkerMessageQueue() {
return std::make_shared<WorkerMessageQueueThread>();
}
} // namespace uwp
} // namespace react

Просмотреть файл

@ -312,8 +312,9 @@
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="LifecycleState.h" />
<ClInclude Include="Modules\AppStateData.h" />
<ClInclude Include="Modules\AppStateModule.h" />
<ClInclude Include="Modules\ClipboardModule.h" />
<ClInclude Include="Modules\DeviceInfoModule.h" />
<ClInclude Include="Modules\DevSettingsModule.h" />
<ClInclude Include="NativeModulesProvider.h" />
<ClInclude Include="Pch\pch.h" />
@ -411,7 +412,6 @@
<ClCompile Include="..\ReactUWP\Modules\Animated\ValueAnimatedNode.cpp" />
<ClCompile Include="..\ReactUwp\Modules\AppearanceModule.cpp" />
<ClCompile Include="..\ReactUWP\Modules\AppThemeModuleUwp.cpp" />
<ClCompile Include="..\ReactUWP\Modules\DeviceInfoModule.cpp" />
<ClCompile Include="..\ReactUWP\Modules\DevSupportManagerUwp.cpp" />
<ClCompile Include="..\ReactUWP\Modules\I18nModule.cpp" />
<ClCompile Include="..\ReactUWP\Modules\ImageViewManagerModule.cpp" />
@ -486,8 +486,9 @@
<DependentUpon>IReactNotificationService.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="Modules\AppStateData.cpp" />
<ClCompile Include="Modules\AppStateModule.cpp" />
<ClCompile Include="Modules\ClipboardModule.cpp" />
<ClCompile Include="Modules\DeviceInfoModule.cpp" />
<ClCompile Include="Modules\DevSettingsModule.cpp" />
<ClCompile Include="NativeModulesProvider.cpp" />
<ClCompile Include="Pch\pch.cpp">

Просмотреть файл

@ -267,12 +267,15 @@
<ClCompile Include="ABIViewManager.cpp" />
<ClCompile Include="IReactDispatcher.cpp" />
<ClCompile Include="IReactNotificationService.cpp" />
<ClCompile Include="Modules\AppStateData.cpp">
<ClCompile Include="Modules\AppStateModule.cpp">
<Filter>Modules</Filter>
</ClCompile>
<ClCompile Include="Modules\ClipboardModule.cpp">
<Filter>Modules</Filter>
</ClCompile>
<ClCompile Include="Modules\DeviceStateModule.cpp">
<Filter>Modules</Filter>
</ClCompile>
<ClCompile Include="Modules\DevSettingsModule.cpp">
<Filter>Modules</Filter>
</ClCompile>
@ -607,12 +610,15 @@
<ClInclude Include="IReactDispatcher.h" />
<ClInclude Include="IReactNotificationService.h" />
<ClInclude Include="LifecycleState.h" />
<ClInclude Include="Modules\AppStateData.h">
<ClInclude Include="Modules\AppStateModule.h">
<Filter>Modules</Filter>
</ClInclude>
<ClInclude Include="Modules\ClipboardModule.h">
<Filter>Modules</Filter>
</ClInclude>
<ClInclude Include="Modules\DeviceStateModule.h">
<Filter>Modules</Filter>
</ClInclude>
<ClInclude Include="Modules\DevSettingsModule.h">
<Filter>Modules</Filter>
</ClInclude>

Просмотреть файл

@ -1,71 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "AppStateData.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::ApplicationModel;
using namespace xaml;
namespace react::uwp {
AppStateData::AppStateData(Mso::React::IReactContext &reactContext, Mso::DispatchQueue const &uiQueue) noexcept
: Super(uiQueue), m_lastState{"active"}, m_reactContext{&reactContext} {}
AppStateData::~AppStateData() = default;
void AppStateData::Initialize() noexcept {
auto currentApp = Application::Current();
m_enteredBackgroundRevoker = currentApp.EnteredBackground(
winrt::auto_revoke,
[weakThis = Mso::WeakPtr{this}](
IInspectable const & /*sender*/, EnteredBackgroundEventArgs const & /*e*/) noexcept {
if (auto strongThis = weakThis.GetStrongPtr()) {
strongThis->RaiseEvent("background");
}
});
m_leavingBackgroundRevoker = currentApp.LeavingBackground(
winrt::auto_revoke,
[weakThis = Mso::WeakPtr{this}](
IInspectable const & /*sender*/, LeavingBackgroundEventArgs const & /*e*/) noexcept {
if (auto strongThis = weakThis.GetStrongPtr()) {
strongThis->RaiseEvent("active");
}
});
}
void AppStateData::Finalize() noexcept {
m_enteredBackgroundRevoker = {};
m_leavingBackgroundRevoker = {};
}
char const *AppStateData::GetState() noexcept {
std::lock_guard lock{m_stateMutex};
return m_lastState;
}
void AppStateData::RaiseEvent(char const *newState) noexcept {
{
std::lock_guard lock{m_stateMutex};
m_lastState = newState;
}
folly::dynamic parameters = folly::dynamic::object("app_state", newState);
m_reactContext->CallJSFunction(
"RCTDeviceEventEmitter", "emit", folly::dynamic::array("appStateDidChange", std::move(parameters)));
}
AppState2::AppState2(Mso::React::IReactContext &reactContext, Mso::DispatchQueue const &uiQueue) noexcept
: m_data{Mso::Make<AppStateData>(reactContext, uiQueue)} {}
AppState2::~AppState2() = default;
char const *AppState2::getState() {
return m_data->GetState();
}
} // namespace react::uwp

Просмотреть файл

@ -1,49 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <Modules/AppStateModule.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Foundation.h>
#include "ReactHost/React.h"
#include "activeObject/activeObject.h"
namespace react::uwp {
// AppStateData ensures that subscription and un-subscription to Application events is happening in Main UI thread.
struct AppStateData : Mso::ActiveObject<> {
using Super = ActiveObjectType;
AppStateData(Mso::React::IReactContext &reactContext, Mso::DispatchQueue const &uiQueue) noexcept;
~AppStateData() override;
void Initialize() noexcept override;
void Finalize() noexcept override;
char const *GetState() noexcept;
private:
void RaiseEvent(char const *newState) noexcept;
private:
std::mutex m_stateMutex;
char const *m_lastState{nullptr};
Mso::CntPtr<Mso::React::IReactContext> m_reactContext;
xaml::Application::EnteredBackground_revoker m_enteredBackgroundRevoker;
xaml::Application::LeavingBackground_revoker m_leavingBackgroundRevoker;
};
// It is a temporary class that we need to keep until we remove ReactUWP
class AppState2 : public facebook::react::AppState {
public:
AppState2(Mso::React::IReactContext &reactContext, Mso::DispatchQueue const &uiQueue) noexcept;
public: // facebook::react::AppState
~AppState2() override;
char const *getState() override;
private:
Mso::CntPtr<AppStateData> m_data;
};
} // namespace react::uwp

Просмотреть файл

@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "AppStateModule.h"
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
#include "Unicode.h"
namespace Microsoft::ReactNative {
void AppState::Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept {
m_context = reactContext;
m_active = true;
auto currentApp = xaml::Application::Current();
m_enteredBackgroundRevoker = currentApp.EnteredBackground(
winrt::auto_revoke,
[weakThis = weak_from_this()](
winrt::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::EnteredBackgroundEventArgs const & /*e*/) noexcept {
if (auto strongThis = weakThis.lock()) {
strongThis->SetActive(false);
}
});
m_leavingBackgroundRevoker = currentApp.LeavingBackground(
winrt::auto_revoke,
[weakThis = weak_from_this()](
winrt::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::LeavingBackgroundEventArgs const & /*e*/) noexcept {
if (auto strongThis = weakThis.lock()) {
strongThis->SetActive(true);
}
});
}
void AppState::GetCurrentAppState(
std::function<void(React::JSValue const &)> const &success,
std::function<void(React::JSValue const &)> const &error) noexcept {
success(m_active ? "active" : "background");
}
void AppState::AddListener(std::string && /*eventName*/) noexcept {
// noop
}
void AppState::RemoveListeners(double /*count*/) noexcept {
// noop
}
void AppState::SetActive(bool active) noexcept {
m_active = active;
AppStateDidChange({m_active ? "active" : "background"});
}
} // namespace Microsoft::ReactNative

Просмотреть файл

@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <NativeModules.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Foundation.h>
namespace Microsoft::ReactNative {
REACT_STRUCT(AppStateChangeArgs)
struct AppStateChangeArgs {
REACT_FIELD(app_state)
std::string app_state;
};
REACT_MODULE(AppState)
struct AppState : public std::enable_shared_from_this<AppState> {
REACT_INIT(Initialize)
void Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
REACT_METHOD(GetCurrentAppState, L"getCurrentAppState")
void GetCurrentAppState(
std::function<void(React::JSValue const &)> const &success,
std::function<void(React::JSValue const &)> const &error) noexcept;
REACT_METHOD(AddListener, L"addListener")
void AddListener(std::string &&eventName) noexcept;
REACT_METHOD(RemoveListeners, L"removeListeners")
void RemoveListeners(double count) noexcept;
REACT_CONSTANT(initialAppState)
const std::string initialAppState{"active"};
REACT_EVENT(AppStateDidChange, L"appStateDidChange")
std::function<void(AppStateChangeArgs const &)> AppStateDidChange;
private:
void SetActive(bool active) noexcept;
std::mutex m_stateMutex;
std::atomic<bool> m_active;
char const *m_lastState{nullptr};
React::ReactContext m_context;
xaml::Application::EnteredBackground_revoker m_enteredBackgroundRevoker;
xaml::Application::LeavingBackground_revoker m_leavingBackgroundRevoker;
};
} // namespace Microsoft::ReactNative

Просмотреть файл

@ -0,0 +1,114 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "DeviceInfoModule.h"
#include <IReactDispatcher.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.ViewManagement.h>
namespace Microsoft::ReactNative {
static const React::ReactPropertyId<React::ReactNonAbiValue<std::shared_ptr<DeviceInfoHolder>>>
&DeviceInfoHolderPropertyId() noexcept {
static const React::ReactPropertyId<React::ReactNonAbiValue<std::shared_ptr<DeviceInfoHolder>>> prop{
L"DeviceInfo", L"DeviceInfoHolder"};
return prop;
}
DeviceInfoHolder::DeviceInfoHolder() {
updateDeviceInfo();
}
void DeviceInfoHolder::InitDeviceInfoHolder(
const winrt::Microsoft::ReactNative::ReactPropertyBag &propertyBag) noexcept {
auto deviceInfoHolder = std::make_shared<DeviceInfoHolder>();
deviceInfoHolder->updateDeviceInfo();
propertyBag.Set(DeviceInfoHolderPropertyId(), std::move(deviceInfoHolder));
auto const &displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
auto const &window = xaml::Window::Current().CoreWindow();
deviceInfoHolder->m_sizeChangedRevoker =
window.SizeChanged(winrt::auto_revoke, [weakHolder = std::weak_ptr(deviceInfoHolder)](auto &&, auto &&) {
if (auto strongHolder = weakHolder.lock()) {
strongHolder->updateDeviceInfo();
}
});
deviceInfoHolder->m_dpiChangedRevoker = displayInfo.DpiChanged(
winrt::auto_revoke, [weakHolder = std::weak_ptr(deviceInfoHolder)](const auto &, const auto &) {
if (auto strongHolder = weakHolder.lock()) {
strongHolder->updateDeviceInfo();
}
});
}
void DeviceInfoHolder::notifyChanged() noexcept {
if (m_notifyCallback) {
m_notifyCallback(getDimensions());
}
}
React::JSValueObject DeviceInfoHolder::GetDimensions(const React::ReactPropertyBag &propertyBag) noexcept {
auto holder = propertyBag.Get(DeviceInfoHolderPropertyId());
return (*holder)->getDimensions();
}
React::JSValueObject DeviceInfoHolder::getDimensions() noexcept {
return React::JSValueObject{
{"windowPhysicalPixels",
React::JSValueObject{{"width", m_windowWidth * m_scale},
{"height", m_windowHeight * m_scale},
{"scale", m_scale},
{"fontScale", m_textScaleFactor},
{"densityDpi", m_dpi}}},
{"screenPhysicalPixels",
React::JSValueObject{{"width", m_screenWidth},
{"height", m_screenHeight},
{"scale", m_scale},
{"fontScale", m_textScaleFactor},
{"densityDpi", m_dpi}}},
};
}
void DeviceInfoHolder::SetCallback(
const React::ReactPropertyBag &propertyBag,
Mso::Functor<void(React::JSValueObject &&)> &&callback) noexcept {
auto holder = propertyBag.Get(DeviceInfoHolderPropertyId());
(*holder)->m_notifyCallback = std::move(callback);
}
void DeviceInfoHolder::updateDeviceInfo() noexcept {
auto const displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
auto const window = xaml::Window::Current().CoreWindow();
winrt::Windows::UI::ViewManagement::UISettings uiSettings;
m_windowWidth = window.Bounds().Width;
m_windowHeight = window.Bounds().Height;
m_scale = static_cast<float>(displayInfo.ResolutionScale()) / 100;
m_textScaleFactor = uiSettings.TextScaleFactor();
m_dpi = displayInfo.LogicalDpi();
m_screenWidth = displayInfo.ScreenWidthInRawPixels();
m_screenHeight = displayInfo.ScreenHeightInRawPixels();
}
void DeviceInfo::GetConstants(React::ReactConstantProvider &provider) noexcept {
provider.Add(L"Dimensions", DeviceInfoHolder::GetDimensions(m_context.Properties()));
}
void DeviceInfo::Initialize(React::ReactContext const &reactContext) noexcept {
m_context = reactContext;
DeviceInfoHolder::SetCallback(
m_context.Properties(), [weakThis = weak_from_this()](React::JSValueObject &&dimensions) {
if (auto strongThis = weakThis.lock()) {
strongThis->m_context.EmitJSEvent(L"RCTDeviceEventEmitter", L"didUpdateDimensions", dimensions);
}
});
}
} // namespace Microsoft::ReactNative

Просмотреть файл

@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <NativeModules.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Graphics.Display.h>
namespace Microsoft::ReactNative {
// Since DeviceInfo provides constants that require the UI thread, we need to initialize it before the module creation
// (module creation can happen on background thread)
// DeviceInfoHolder is created on the UI thread and stored in the PropertyBag so that the DeviceInfo module can return
// the constants synchronously.
struct DeviceInfoHolder {
DeviceInfoHolder();
static void SetCallback(
const React::ReactPropertyBag &propertyBag,
Mso::Functor<void(React::JSValueObject &&)> &&callback) noexcept;
static void InitDeviceInfoHolder(const React::ReactPropertyBag &propertyBag) noexcept;
static React::JSValueObject GetDimensions(const React::ReactPropertyBag &propertyBag) noexcept;
private:
React::JSValueObject getDimensions() noexcept;
void updateDeviceInfo() noexcept;
void notifyChanged() noexcept;
float m_windowWidth{0};
float m_windowHeight{0};
float m_scale{0};
double m_textScaleFactor{0};
float m_dpi{0};
uint32_t m_screenWidth{0};
uint32_t m_screenHeight{0};
winrt::Windows::UI::Core::CoreWindow::SizeChanged_revoker m_sizeChangedRevoker;
winrt::Windows::Graphics::Display::DisplayInformation::DpiChanged_revoker m_dpiChangedRevoker{};
Mso::Functor<void(React::JSValueObject &&)> m_notifyCallback;
};
REACT_MODULE(DeviceInfo)
struct DeviceInfo : public std::enable_shared_from_this<DeviceInfo> {
REACT_INIT(Initialize)
void Initialize(React::ReactContext const &reactContext) noexcept;
REACT_CONSTANT_PROVIDER(GetConstants)
void GetConstants(React::ReactConstantProvider &provider) noexcept;
private:
winrt::Microsoft::ReactNative::ReactContext m_context;
};
} // namespace Microsoft::ReactNative

Просмотреть файл

@ -14,8 +14,10 @@
#include "Microsoft.ReactNative/IReactNotificationService.h"
#include "Microsoft.ReactNative/Threading/MessageQueueThreadFactory.h"
#include "../../codegen/NativeAppStateSpec.g.h"
#include "../../codegen/NativeClipboardSpec.g.h"
#include "../../codegen/NativeDevSettingsSpec.g.h"
#include "../../codegen/NativeDeviceInfoSpec.g.h"
#include "NativeModules.h"
#include "NativeModulesProvider.h"
#include "Unicode.h"
@ -23,9 +25,10 @@
#include <ReactWindowsCore/ViewManager.h>
#include <dispatchQueue/dispatchQueue.h>
#include "IReactDispatcher.h"
#include "Modules/AppStateData.h"
#include "Modules/AppStateModule.h"
#include "Modules/ClipboardModule.h"
#include "Modules/DevSettingsModule.h"
#include "Modules/DeviceInfoModule.h"
#include <Utils/UwpPreparedScriptStore.h>
#include <Utils/UwpScriptStore.h>
@ -177,12 +180,13 @@ void ReactInstanceWin::Initialize() noexcept {
// Objects that must be created on the UI thread
if (auto strongThis = weakThis.GetStrongPtr()) {
auto const &legacyInstance = strongThis->m_legacyReactInstance;
strongThis->m_deviceInfo = std::make_shared<react::uwp::DeviceInfo>(legacyInstance);
strongThis->m_appTheme =
std::make_shared<react::uwp::AppTheme>(legacyInstance, strongThis->m_uiMessageThread.LoadWithLock());
react::uwp::I18nHelper().Instance().setInfo(react::uwp::I18nModule::GetI18nInfo());
strongThis->m_appearanceListener =
Mso::Make<react::uwp::AppearanceChangeListener>(legacyInstance, strongThis->m_uiQueue);
::Microsoft::ReactNative::DeviceInfoHolder::InitDeviceInfoHolder(
winrt::Microsoft::ReactNative::ReactPropertyBag(strongThis->Options().Properties));
}
})
.Then(Queue(), [ this, weakThis = Mso::WeakPtr{this} ]() noexcept {
@ -218,20 +222,22 @@ void ReactInstanceWin::Initialize() noexcept {
devSettings->debuggerConsoleRedirection =
false; // JSHost::ChangeGate::ChakraCoreDebuggerConsoleRedirection();
m_appState = std::make_shared<react::uwp::AppState2>(*m_reactContext, m_uiQueue);
// Acquire default modules and then populate with custom modules
std::vector<facebook::react::NativeModuleDescription> cxxModules = react::uwp::GetCoreModules(
m_uiManager.Load(),
m_batchingUIThread,
m_uiMessageThread.Load(),
std::move(m_deviceInfo),
std::move(m_appState),
std::move(m_appTheme),
std::move(m_appearanceListener),
m_legacyReactInstance);
auto nmp = std::make_shared<winrt::Microsoft::ReactNative::NativeModulesProvider>();
nmp->AddModuleProvider(
L"AppState",
winrt::Microsoft::ReactNative::MakeTurboModuleProvider<
::Microsoft::ReactNative::AppState,
::Microsoft::ReactNativeSpecs::AppStateSpec>());
nmp->AddModuleProvider(
L"Clipboard",
winrt::Microsoft::ReactNative::MakeTurboModuleProvider<
@ -245,6 +251,12 @@ void ReactInstanceWin::Initialize() noexcept {
}
});
nmp->AddModuleProvider(
L"DeviceInfo",
winrt::Microsoft::ReactNative::MakeTurboModuleProvider<
::Microsoft::ReactNative::DeviceInfo,
::Microsoft::ReactNativeSpecs::DeviceInfoSpec>());
nmp->AddModuleProvider(
L"DevSettings",
winrt::Microsoft::ReactNative::MakeTurboModuleProvider<

Просмотреть файл

@ -8,10 +8,8 @@
#include "React_win.h"
#include "activeObject/activeObject.h"
#include <Modules/AppStateModuleUwp.h>
#include <Modules/AppThemeModuleUwp.h>
#include <Modules/AppearanceModule.h>
#include <Modules/DeviceInfoModule.h>
#include <ReactUWP/Modules/I18nModule.h>
#include "UwpReactInstanceProxy.h"
@ -163,8 +161,6 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal,
std::shared_ptr<facebook::react::MessageQueueThread> m_batchingUIThread;
std::shared_ptr<react::uwp::IReactInstance> m_legacyReactInstance;
std::shared_ptr<react::uwp::DeviceInfo> m_deviceInfo;
std::shared_ptr<facebook::react::AppState> m_appState;
std::shared_ptr<IRedBoxHandler> m_redboxHandler;
std::shared_ptr<react::uwp::AppTheme> m_appTheme;
Mso::CntPtr<react::uwp::AppearanceChangeListener> m_appearanceListener;

Просмотреть файл

@ -8,12 +8,10 @@
#include <AsyncStorageModule.h>
#include <Modules/AlertModuleUwp.h>
#include <Modules/Animated/NativeAnimatedModule.h>
#include <Modules/AppStateModuleUwp.h>
#include <Modules/AppThemeModuleUwp.h>
#include <Modules/AppearanceModule.h>
#include <Modules/AsyncStorageModuleWin32.h>
#include <Modules/ClipboardModule.h>
#include <Modules/DeviceInfoModule.h>
#include <Modules/ImageViewManagerModule.h>
#include <Modules/LinkingManagerModule.h>
#include <Modules/LocationObserverModule.h>
@ -52,8 +50,6 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
const std::shared_ptr<facebook::react::IUIManager> &uiManager,
const std::shared_ptr<facebook::react::MessageQueueThread> &messageQueue,
const std::shared_ptr<facebook::react::MessageQueueThread> &uiMessageQueue,
std::shared_ptr<DeviceInfo> &&deviceInfo,
std::shared_ptr<facebook::react::AppState> &&appstate,
std::shared_ptr<react::uwp::AppTheme> &&appTheme,
Mso::CntPtr<AppearanceChangeListener> &&appearanceListener,
const std::shared_ptr<IReactInstance> &uwpInstance) noexcept {
@ -78,9 +74,6 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
modules.emplace_back(
"Timing", [messageQueue]() { return facebook::react::CreateTimingModule(messageQueue); }, messageQueue);
modules.emplace_back(
DeviceInfoModule::name, [deviceInfo]() { return std::make_unique<DeviceInfoModule>(deviceInfo); }, messageQueue);
modules.emplace_back(
LinkingManagerModule::name, []() { return std::make_unique<LinkingManagerModule>(); }, messageQueue);
@ -94,13 +87,6 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
[messageQueue]() { return std::make_unique<LocationObserverModule>(messageQueue); },
MakeSerialQueueThread()); // TODO: figure out threading
modules.emplace_back(
facebook::react::AppStateModule::name,
[appstate = std::move(appstate)]() mutable {
return std::make_unique<facebook::react::AppStateModule>(std::move(appstate));
},
MakeSerialQueueThread());
modules.emplace_back(
react::uwp::AppThemeModule::Name,
[appTheme = std::move(appTheme)]() mutable {

Просмотреть файл

@ -28,8 +28,6 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
const std::shared_ptr<facebook::react::IUIManager> &uiManager,
const std::shared_ptr<facebook::react::MessageQueueThread> &messageQueue,
const std::shared_ptr<facebook::react::MessageQueueThread> &uiMessageQueue,
std::shared_ptr<DeviceInfo> &&deviceInfo,
std::shared_ptr<facebook::react::AppState> &&appstate,
std::shared_ptr<react::uwp::AppTheme> &&appTheme,
Mso::CntPtr<AppearanceChangeListener> &&appearanceListener,
const std::shared_ptr<IReactInstance> &uwpInstance) noexcept;

Просмотреть файл

@ -1,74 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include <ReactUWP/InstanceFactory.h>
#include "UwpReactInstance.h"
#include <ReactUWP/ReactRootView.h>
#include "Unicode.h"
namespace react {
namespace uwp {
std::vector<std::weak_ptr<UwpReactInstance>> &ReactInstances() noexcept {
static std::vector<std::weak_ptr<UwpReactInstance>> s_instances;
return s_instances;
}
void CleanupExpiredInstances() noexcept {
// Lets cleanup all leftover WeakPtrs.
ReactInstances().erase(
std::remove_if(
ReactInstances().begin(),
ReactInstances().end(),
[](const std::weak_ptr<UwpReactInstance> &weakInstance) { return weakInstance.lock() == nullptr; }),
ReactInstances().end());
}
REACTWINDOWS_API_(std::shared_ptr<IReactInstance>)
CreateReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider) {
return std::make_shared<UwpReactInstance>(moduleProvider, viewManagerProvider);
}
REACTWINDOWS_API_(IReactInstance *)
UnSafeCreateReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider) {
return new UwpReactInstance(moduleProvider, viewManagerProvider);
}
REACTWINDOWS_API_(std::shared_ptr<IReactInstance>)
CreateReactInstance(
const std::shared_ptr<facebook::react::TurboModuleRegistry> &turboModuleRegistry,
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider) {
return std::make_shared<UwpReactInstance>(turboModuleRegistry, moduleProvider, viewManagerProvider);
}
REACTWINDOWS_API_(std::shared_ptr<IXamlRootView>)
CreateReactRootView(XamlView parentView, const wchar_t *pJsComponentName, const ReactInstanceCreator &instanceCreator) {
// Convert input strings to std::string
std::string jsComponentName = Microsoft::Common::Unicode::Utf16ToUtf8(pJsComponentName, wcslen(pJsComponentName));
auto rootView = std::make_shared<react::uwp::ReactRootView>(parentView);
rootView->SetJSComponentName(std::move(jsComponentName));
rootView->SetInstanceCreator(instanceCreator);
return rootView;
}
// Creates a background thread message queue whose tasks will run in serialized
// order
REACTWINDOWS_API_(std::shared_ptr<facebook::react::MessageQueueThread>)
CreateWorkerMessageQueue() {
return std::make_shared<WorkerMessageQueueThread>();
}
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,467 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "CoreNativeModules.h"
#include "UwpReactInstance.h"
// ReactUWP
#include <ReactUWP/CreateUwpModules.h>
#include <ReactUWP/IXamlRootView.h>
#include <ReactUWP/Threading/BatchingUIMessageQueueThread.h>
// Modules
#include <Modules/AppStateModuleUwp.h>
#include <Modules/AppThemeModuleUwp.h>
#include <Modules/ClipboardModule.h>
#include <Modules/NativeUIManager.h>
#include <Threading/JSQueueThread.h>
#include <Threading/UIMessageQueueThread.h>
#include <Threading/WorkerMessageQueueThread.h>
// ReactWindowsCore
#include <CreateModules.h>
#include <CxxMessageQueue.h>
#include <DevServerHelper.h>
#include <DevSettings.h>
#include <IUIManager.h>
#include <InstanceManager.h>
#include <NativeModuleProvider.h>
#include "Unicode.h"
#include <Modules/DevSettingsModule.h>
#include <Modules/DeviceInfoModule.h>
#include <cxxreact/CxxNativeModule.h>
#include <cxxreact/Instance.h>
#include <winrt/Windows.ApplicationModel.h>
#include <Utils/UwpPreparedScriptStore.h>
#include <Utils/UwpScriptStore.h>
#if defined(USE_HERMES)
#include "HermesRuntimeHolder.h"
#endif // USE_HERMES
#if defined(USE_V8)
#include <winrt/Windows.Storage.h>
#include "BaseScriptStoreImpl.h"
#include "V8JSIRuntimeHolder.h"
#endif // USE_V8
#include <ReactWindowsCore/IRedBoxHandler.h>
#include <winrt/Windows.UI.Popups.h>
#include "ChakraRuntimeHolder.h"
#include <UI.Popups.h>
#include <tuple>
namespace react {
namespace uwp {
UwpReactInstance::UwpReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider)
: m_moduleProvider(moduleProvider), m_viewManagerProvider(viewManagerProvider) {}
UwpReactInstance::UwpReactInstance(
const std::shared_ptr<facebook::react::TurboModuleRegistry> &turboModuleRegistry,
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider)
: m_moduleProvider(moduleProvider),
m_viewManagerProvider(viewManagerProvider),
m_turboModuleRegistry(turboModuleRegistry) {}
struct UwpReactRedBoxHandler : Mso::React::IRedBoxHandler {
// Inherited via IRedBoxHandler
virtual void showNewError(Mso::React::ErrorInfo &&info, Mso::React::ErrorType) override {
std::stringstream ss;
ss << "A better redbox experience is provided by Microsoft.ReactNative - Consider moving off ReactUwp to Microsoft.ReactNative today!\n\n";
ss << info.Message << "\n\n";
for (auto frame : info.Callstack) {
ss << frame.Method << "\n" << frame.File << ":" << frame.Line << ":" << frame.Column << "\n";
}
auto dlg = winrt::Windows::UI::Popups::MessageDialog(
Microsoft::Common::Unicode::Utf8ToUtf16(ss.str().c_str()), L"RedBox Error");
dlg.ShowAsync();
}
virtual bool isDevSupportEnabled() const override {
return true;
}
virtual void updateError(Mso::React::ErrorInfo &&) override {}
virtual void dismissRedbox() override {}
};
void UwpReactInstance::Start(const std::shared_ptr<IReactInstance> &spThis, const ReactInstanceSettings &settings) {
if (m_started)
return;
m_reactInstanceSettings = settings;
assert(
m_uiDispatcher == nullptr && m_defaultNativeThread == nullptr && m_batchingNativeThread == nullptr &&
m_jsThread == nullptr && m_initThread == nullptr && m_instanceWrapper == nullptr);
m_started = true;
m_uiDispatcher = winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread().Dispatcher();
m_defaultNativeThread = std::make_shared<react::uwp::UIMessageQueueThread>(m_uiDispatcher);
m_batchingNativeThread = std::make_shared<react::uwp::BatchingUIMessageQueueThread>(m_uiDispatcher);
// Objects that must be created on the UI thread
auto deviceInfo(std::make_shared<DeviceInfo>(spThis));
std::shared_ptr<facebook::react::AppState> appstate = std::make_shared<react::uwp::AppState>(spThis);
std::shared_ptr<react::uwp::AppTheme> appTheme =
std::make_shared<react::uwp::AppTheme>(spThis, m_defaultNativeThread);
I18nHelper::Instance().setInfo(I18nModule::GetI18nInfo());
auto appearanceListener = Mso::Make<AppearanceChangeListener>(spThis, Mso::DispatchQueue::MakeCurrentThreadUIQueue());
// TODO: Figure out threading. What thread should this really be on?
m_initThread = std::make_unique<react::uwp::WorkerMessageQueueThread>();
m_jsThread = std::static_pointer_cast<facebook::react::MessageQueueThread>(m_initThread);
m_initThread->runOnQueueSync([this,
spThis,
deviceInfo,
settings,
appstate = std::move(appstate),
appTheme = std::move(appTheme),
appearanceListener = std::move(appearanceListener)]() mutable {
// Setup DevSettings based on our own internal structure
auto devSettings(std::make_shared<facebook::react::DevSettings>());
devSettings->debugBundlePath = settings.DebugBundlePath;
devSettings->useWebDebugger = settings.UseWebDebugger;
devSettings->useDirectDebugger = settings.UseDirectDebugger;
devSettings->debuggerBreakOnNextLine = settings.DebuggerBreakOnNextLine;
devSettings->loggingCallback = std::move(settings.LoggingCallback);
devSettings->redboxHandler = std::move(settings.RedBoxHandler);
devSettings->useJITCompilation = settings.EnableJITCompilation;
devSettings->debugHost = settings.DebugHost;
devSettings->debuggerPort = settings.DebuggerPort;
if (!devSettings->redboxHandler &&
(devSettings->useWebDebugger || devSettings->useDirectDebugger || settings.UseLiveReload)) {
devSettings->redboxHandler = std::move(std::make_shared<UwpReactRedBoxHandler>());
}
// In most cases, using the hardcoded ms-appx URI works fine, but there are
// certain scenarios, such as in optional packaging, where the developer
// might need to modify the path, in which case we should use the custom
// path instead.
devSettings->bundleRootPath = settings.BundleRootPath.empty() ? "ms-appx:///Bundle/" : settings.BundleRootPath;
m_bundleRootPath = devSettings->bundleRootPath;
if (settings.UseLiveReload) {
devSettings->liveReloadCallback = [weakThis = std::weak_ptr<IReactInstance>(spThis)]() noexcept {
auto strongThis = weakThis.lock();
if (strongThis != nullptr) {
auto uwpInstance = std::static_pointer_cast<UwpReactInstance>(strongThis);
// Mark the instance in needs reload state
uwpInstance->SetAsNeedsReload();
// Invoke every callback registered
for (auto const &current : uwpInstance->m_liveReloadCallbacks)
current.second();
}
};
}
devSettings->errorCallback = [weakThis = std::weak_ptr<IReactInstance>(spThis)](std::string message) noexcept {
auto strongThis = weakThis.lock();
if (strongThis != nullptr) {
auto uwpInstance = std::static_pointer_cast<UwpReactInstance>(strongThis);
uwpInstance->OnHitError(message);
}
};
if (settings.UseWebDebugger) {
devSettings->waitingForDebuggerCallback = [weakThis = std::weak_ptr<IReactInstance>(spThis)]() noexcept {
auto strongThis = weakThis.lock();
if (strongThis != nullptr) {
auto uwpInstance = std::static_pointer_cast<UwpReactInstance>(strongThis);
uwpInstance->OnWaitingForDebugger();
}
};
devSettings->debuggerAttachCallback = [weakThis = std::weak_ptr<IReactInstance>(spThis)]() noexcept {
auto strongThis = weakThis.lock();
if (strongThis != nullptr) {
auto uwpInstance = std::static_pointer_cast<UwpReactInstance>(strongThis);
uwpInstance->OnDebuggerAttach();
}
};
}
// Create NativeUIManager & UIManager
m_uiManager = CreateUIManager(spThis, m_viewManagerProvider);
// Acquire default modules and then populate with custom modules
std::vector<facebook::react::NativeModuleDescription> cxxModules = GetCoreModules(
m_uiManager,
m_batchingNativeThread,
m_defaultNativeThread,
std::move(deviceInfo),
std::move(appstate),
std::move(appTheme),
std::move(appearanceListener),
spThis);
cxxModules.emplace_back(
ClipboardModule::name, []() { return std::make_unique<ClipboardModule>(); }, m_batchingNativeThread);
cxxModules.emplace_back(
DevSettingsModule::name, []() { return std::make_unique<DevSettingsModule>(); }, m_batchingNativeThread);
if (m_moduleProvider != nullptr) {
std::vector<facebook::react::NativeModuleDescription> customCxxModules =
m_moduleProvider->GetModules(m_batchingNativeThread);
cxxModules.insert(std::end(cxxModules), std::begin(customCxxModules), std::end(customCxxModules));
}
std::shared_ptr<facebook::react::MessageQueueThread> jsQueue = CreateAndStartJSQueueThread();
if (settings.UseJsi) {
std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
switch (settings.jsiEngine) {
case JSIEngine::Hermes:
#if defined(USE_HERMES)
devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::HermesRuntimeHolder>();
break;
#endif
case JSIEngine::V8:
#if defined(USE_V8)
preparedScriptStore =
std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(getApplicationLocalFolder());
devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
devSettings, jsQueue, std::move(scriptStore), std::move(preparedScriptStore));
break;
#endif
case JSIEngine::Chakra:
if (settings.EnableByteCodeCaching || !settings.ByteCodeFileUri.empty()) {
scriptStore = std::make_unique<UwpScriptStore>();
preparedScriptStore = std::make_unique<UwpPreparedScriptStore>(winrt::to_hstring(settings.ByteCodeFileUri));
}
devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::JSI::ChakraRuntimeHolder>(
devSettings, jsQueue, std::move(scriptStore), std::move(preparedScriptStore));
break;
}
}
try {
// Create the react instance
m_instanceWrapper = facebook::react::CreateReactInstance(
std::string(), // bundleRootPath
std::move(cxxModules),
m_turboModuleRegistry,
m_uiManager,
jsQueue,
m_batchingNativeThread,
std::move(devSettings));
} catch (std::exception &e) {
OnHitError(e.what());
OnHitError("UwpReactInstance: Failed to create React Instance.");
} catch (winrt::hresult_error const &e) {
OnHitError(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()));
OnHitError("UwpReactInstance: Failed to create React Instance.");
} catch (...) {
OnHitError("UwpReactInstance: Failed to create React Instance.");
}
});
}
void UwpReactInstance::AttachMeasuredRootView(IXamlRootView *pRootView, folly::dynamic &&initProps) {
if (!IsInError()) {
m_instanceWrapper->AttachMeasuredRootView(pRootView, std::move(initProps));
}
}
void UwpReactInstance::DetachRootView(IXamlRootView *pRootView) {
m_instanceWrapper->DetachRootView(pRootView);
}
LiveReloadCallbackCookie UwpReactInstance::RegisterLiveReloadCallback(std::function<void()> callback) {
static LiveReloadCallbackCookie g_nextLiveReloadCallbackCookie(0);
// Add callback to map with new cookie
LiveReloadCallbackCookie cookie = ++g_nextLiveReloadCallbackCookie;
m_liveReloadCallbacks[cookie] = callback;
// Its possible this instance is already in a reload state, if so
// trigger immediate reload
if (NeedsReload())
callback();
return cookie;
}
void UwpReactInstance::UnregisterLiveReloadCallback(LiveReloadCallbackCookie &cookie) {
m_liveReloadCallbacks.erase(cookie);
cookie = 0;
}
ErrorCallbackCookie UwpReactInstance::RegisterErrorCallback(std::function<void()> callback) {
static ErrorCallbackCookie g_nextErrorCallbackCookie(0);
// Add callback to map with new cookie
ErrorCallbackCookie cookie = ++g_nextErrorCallbackCookie;
m_errorCallbacks[cookie] = callback;
return cookie;
}
void UwpReactInstance::UnregisterErrorCallback(ErrorCallbackCookie &cookie) {
m_errorCallbacks.erase(cookie);
cookie = 0;
}
DebuggerAttachCallbackCookie UwpReactInstance::RegisterDebuggerAttachCallback(std::function<void()> callback) {
static DebuggerAttachCallbackCookie g_nextDebuggerAttachCallbackCookie(0);
// Add callback to map with new cookie
DebuggerAttachCallbackCookie cookie = ++g_nextDebuggerAttachCallbackCookie;
m_debuggerAttachCallbacks[cookie] = callback;
return cookie;
}
void UwpReactInstance::UnRegisterDebuggerAttachCallback(DebuggerAttachCallbackCookie &cookie) {
m_debuggerAttachCallbacks.erase(cookie);
cookie = 0;
}
void UwpReactInstance::DispatchEvent(int64_t viewTag, std::string eventName, folly::dynamic &&eventData) {
if (!IsInError())
m_instanceWrapper->DispatchEvent(viewTag, eventName, std::move(eventData));
}
void UwpReactInstance::CallJsFunction(
std::string &&moduleName,
std::string &&method,
folly::dynamic &&params) noexcept {
if (!IsInError())
m_instanceWrapper->GetInstance()->callJSFunction(std::move(moduleName), std::move(method), std::move(params));
}
std::shared_ptr<facebook::react::MessageQueueThread> UwpReactInstance::GetNewUIMessageQueue() const {
return std::make_shared<react::uwp::UIMessageQueueThread>(m_uiDispatcher);
}
const std::shared_ptr<facebook::react::MessageQueueThread> &UwpReactInstance::JSMessageQueueThread() const noexcept {
return m_jsThread;
}
const std::shared_ptr<facebook::react::MessageQueueThread> &UwpReactInstance::DefaultNativeMessageQueueThread() const
noexcept {
return m_defaultNativeThread;
}
facebook::react::INativeUIManager *UwpReactInstance::NativeUIManager() const noexcept {
return m_uiManager->getNativeUIManager();
}
static std::string PrettyError(const std::string &error) noexcept {
std::string prettyError = error;
if (prettyError.length() > 0 && prettyError[0] == '{') {
// if starting with {, assume JSONy
// Replace escape characters with actuals
size_t pos = prettyError.find('\\');
while (pos != std::wstring::npos && pos + 2 <= prettyError.length()) {
if (prettyError[pos + 1] == 'n') {
prettyError.replace(pos, 2, "\r\n", 2);
} else if (prettyError[pos + 1] == 'b') {
prettyError.replace(pos, 2, "\b", 2);
} else if (prettyError[pos + 1] == 't') {
prettyError.replace(pos, 2, "\t", 2);
} else if (prettyError[pos + 1] == 'u' && pos + 6 <= prettyError.length()) {
// Convert 4 hex digits
auto hexVal = [&](int c) -> uint16_t {
return uint16_t(
c >= '0' && c <= '9' ? c - '0'
: c >= 'a' && c <= 'f' ? c - 'a' + 10 : c >= 'A' && c <= 'F' ? c - 'A' + 10 : 0);
};
wchar_t replWide = 0;
replWide += hexVal(prettyError[pos + 2]) << 12;
replWide += hexVal(prettyError[pos + 3]) << 8;
replWide += hexVal(prettyError[pos + 4]) << 4;
replWide += hexVal(prettyError[pos + 5]);
std::string repl = Microsoft::Common::Unicode::Utf16ToUtf8(&replWide, 1);
prettyError.replace(pos, 6, repl);
}
pos = prettyError.find('\\', pos + 2);
}
}
return prettyError;
}
void UwpReactInstance::OnHitError(const std::string &error) noexcept {
m_isInError = true;
// Append new error message onto others
if (!m_errorMessage.empty())
m_errorMessage += "\n";
m_errorMessage += " -- ";
m_errorMessage += PrettyError(error);
OutputDebugStringA("UwpReactInstance Error Hit ...\n");
OutputDebugStringA(m_errorMessage.c_str());
OutputDebugStringA("\n");
// Invoke every callback registered
for (auto const &current : m_errorCallbacks)
current.second();
}
void UwpReactInstance::OnWaitingForDebugger() noexcept {
m_isWaitingForDebugger = true;
}
void UwpReactInstance::OnDebuggerAttach() noexcept {
m_isWaitingForDebugger = false;
// Invoke every callback registered
for (auto const &current : m_debuggerAttachCallbacks)
current.second();
}
void UwpReactInstance::SetXamlViewCreatedTestHook(std::function<void(react::uwp::XamlView)> testHook) {
m_xamlViewCreatedTestHook = testHook;
}
void UwpReactInstance::CallXamlViewCreatedTestHook(react::uwp::XamlView view) {
if (m_xamlViewCreatedTestHook != nullptr) {
m_xamlViewCreatedTestHook(view);
}
}
#if defined(USE_V8)
std::string UwpReactInstance::getApplicationLocalFolder() {
try {
auto local = winrt::Windows::Storage::ApplicationData::Current().LocalFolder().Path();
return Microsoft::Common::Unicode::Utf16ToUtf8(local.c_str(), local.size()) + "\\";
} catch (winrt::hresult_error const &ex) {
winrt::hresult hr = ex.to_abi();
if (hr == HRESULT_FROM_WIN32(APPMODEL_ERROR_NO_PACKAGE)) {
// This is a win32 application using UWP APIs, pick a reasonable location for caching bytecode
char tempPath[MAX_PATH];
if (GetTempPathA(MAX_PATH, tempPath)) {
return std::string(tempPath);
}
}
throw ex;
}
}
#endif
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,133 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <IReactInstance.h>
#include <Threading/WorkerMessageQueueThread.h>
#include <Views/ExpressionAnimationStore.h>
#include <winrt/Windows.UI.Core.h>
#include <map>
#include <memory>
#include <string>
namespace facebook {
namespace react {
struct NativeModuleProvider;
}
} // namespace facebook
namespace react {
namespace uwp {
struct ViewManagerProvider;
}
} // namespace react
namespace react {
namespace uwp {
class UwpReactInstance : public IReactInstance, public ::std::enable_shared_from_this<UwpReactInstance> {
public:
// Creation
UwpReactInstance(
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider = nullptr);
UwpReactInstance(
const std::shared_ptr<facebook::react::TurboModuleRegistry> &turboModuleRegistry,
const std::shared_ptr<facebook::react::NativeModuleProvider> &moduleProvider,
const std::shared_ptr<ViewManagerProvider> &viewManagerProvider = nullptr);
void Start(const std::shared_ptr<IReactInstance> &spThis, const ReactInstanceSettings &settings) override;
// IReactInstance implementation
void AttachMeasuredRootView(IXamlRootView *pRootView, folly::dynamic &&initProps) override;
void DetachRootView(IXamlRootView *pRootView) override;
LiveReloadCallbackCookie RegisterLiveReloadCallback(std::function<void()> callback) override;
void UnregisterLiveReloadCallback(LiveReloadCallbackCookie &cookie) override;
ErrorCallbackCookie RegisterErrorCallback(std::function<void()> callback) override;
void UnregisterErrorCallback(ErrorCallbackCookie &cookie) override;
DebuggerAttachCallbackCookie RegisterDebuggerAttachCallback(std::function<void()> callback) override;
void UnRegisterDebuggerAttachCallback(DebuggerAttachCallbackCookie &cookie) override;
void DispatchEvent(int64_t viewTag, std::string eventName, folly::dynamic &&eventData) override;
void CallJsFunction(std::string &&moduleName, std::string &&method, folly::dynamic &&params) noexcept override;
const std::shared_ptr<facebook::react::MessageQueueThread> &JSMessageQueueThread() const noexcept override;
const std::shared_ptr<facebook::react::MessageQueueThread> &DefaultNativeMessageQueueThread() const noexcept override;
facebook::react::INativeUIManager *NativeUIManager() const noexcept override;
bool NeedsReload() const noexcept override {
return m_needsReload;
}
void SetAsNeedsReload() noexcept override {
m_needsReload = true;
}
std::shared_ptr<facebook::react::Instance> GetInnerInstance() const noexcept override {
return m_instanceWrapper->GetInstance();
}
bool IsInError() const noexcept override {
return m_isInError;
}
bool IsWaitingForDebugger() const noexcept override {
return m_isWaitingForDebugger;
}
const std::string &LastErrorMessage() const noexcept override {
return m_errorMessage;
}
void loadBundle(std::string &&jsBundleRelativePath) override {
if (!m_isInError)
m_instanceWrapper->loadBundle(std::move(jsBundleRelativePath));
};
ExpressionAnimationStore &GetExpressionAnimationStore() override {
return m_expressionAnimationStore;
}
const ReactInstanceSettings &GetReactInstanceSettings() const override {
return m_reactInstanceSettings;
}
std::string GetBundleRootPath() const noexcept override {
return m_bundleRootPath;
}
// Test hooks
void SetXamlViewCreatedTestHook(std::function<void(react::uwp::XamlView)> testHook) override;
void CallXamlViewCreatedTestHook(react::uwp::XamlView view) override;
// Public functions
std::shared_ptr<facebook::react::MessageQueueThread> GetNewUIMessageQueue() const;
private:
void OnHitError(const std::string &error) noexcept;
void OnWaitingForDebugger() noexcept;
void OnDebuggerAttach() noexcept;
private:
#if defined(USE_V8)
static std::string getApplicationLocalFolder();
#endif
std::shared_ptr<WorkerMessageQueueThread> m_initThread;
std::shared_ptr<facebook::react::MessageQueueThread> m_jsThread;
std::shared_ptr<facebook::react::MessageQueueThread> m_defaultNativeThread;
std::shared_ptr<facebook::react::MessageQueueThread> m_batchingNativeThread;
std::shared_ptr<facebook::react::IUIManager> m_uiManager;
std::shared_ptr<facebook::react::InstanceWrapper> m_instanceWrapper;
winrt::Windows::UI::Core::CoreDispatcher m_uiDispatcher{nullptr};
std::shared_ptr<facebook::react::NativeModuleProvider> m_moduleProvider;
std::shared_ptr<facebook::react::TurboModuleRegistry> m_turboModuleRegistry;
std::shared_ptr<ViewManagerProvider> m_viewManagerProvider;
std::map<LiveReloadCallbackCookie, std::function<void()>> m_liveReloadCallbacks;
std::map<ErrorCallbackCookie, std::function<void()>> m_errorCallbacks;
std::map<DebuggerAttachCallbackCookie, std::function<void()>> m_debuggerAttachCallbacks;
bool m_needsReload{false};
bool m_started{false};
std::atomic_bool m_isInError{false};
std::atomic_bool m_isWaitingForDebugger{false};
std::string m_errorMessage;
ExpressionAnimationStore m_expressionAnimationStore;
std::function<void(XamlView)> m_xamlViewCreatedTestHook;
std::string m_bundleRootPath;
ReactInstanceSettings m_reactInstanceSettings;
};
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,54 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
// react-native-uwp.dll never links JavaScriptCore (we always use Chakra)
// however, since we share ReactCommon with react-native-win32, which can
// optionally use JavaScriptCore (temporarily), we need to stub some stuff out
// so we can link. This file should go away when we stop comparing perf
// of JavaScriptCore and Chakra so we can remove JavaScriptCore entirely.
extern "C" {
__declspec(dllexport) void *__imp_JSValueMakeString = nullptr;
__declspec(dllexport) void *__imp_JSValueMakeFromJSONString = nullptr;
__declspec(dllexport) void *__imp_JSValueCreateJSONString = nullptr;
__declspec(dllexport) void *__imp_JSValueToStringCopy = nullptr;
__declspec(dllexport) void *__imp_JSValueToObject = nullptr;
__declspec(dllexport) void *__imp_JSValueUnprotect = nullptr;
__declspec(dllexport) void *__imp_JSObjectMake = nullptr;
__declspec(dllexport) void *__imp_JSObjectMakeError = nullptr;
__declspec(dllexport) void *__imp_JSObjectGetProperty = nullptr;
__declspec(dllexport) void *__imp_JSObjectSetProperty = nullptr;
__declspec(dllexport) void *__imp_JSObjectGetPropertyAtIndex = nullptr;
__declspec(dllexport) void *__imp_JSObjectSetPropertyAtIndex = nullptr;
__declspec(dllexport) void *__imp_JSObjectCallAsFunction = nullptr;
__declspec(dllexport) void *__imp_JSObjectCallAsConstructor = nullptr;
__declspec(dllexport) void *__imp_JSObjectCopyPropertyNames = nullptr;
__declspec(dllexport) void *__imp_JSPropertyNameArrayRelease = nullptr;
__declspec(dllexport) void *__imp_JSPropertyNameArrayGetCount = nullptr;
__declspec(dllexport) void *__imp_JSPropertyNameArrayGetNameAtIndex = nullptr;
__declspec(dllexport) void *__imp_JSContextGetGlobalObject = nullptr;
__declspec(dllexport) void *__imp_JSStringCreateWithUTF8CString = nullptr;
__declspec(dllexport) void *__imp_JSStringRetain = nullptr;
__declspec(dllexport) void *__imp_JSStringRelease = nullptr;
__declspec(dllexport) void *__imp_JSStringGetLength = nullptr;
__declspec(dllexport) void *__imp_JSStringGetCharactersPtr = nullptr;
__declspec(dllexport) void *__imp_JSValueGetType = nullptr;
__declspec(dllexport) void *__imp_JSValueMakeUndefined = nullptr;
__declspec(dllexport) void *__imp_JSValueMakeNull = nullptr;
__declspec(dllexport) void *__imp_JSValueMakeNumber = nullptr;
__declspec(dllexport) void *__imp_JSClassCreate = nullptr;
__declspec(dllexport) void *__imp_JSClassRelease = nullptr;
__declspec(dllexport) void *__imp_JSObjectGetPrivate = nullptr;
__declspec(dllexport) void *__imp_JSGlobalContextCreateInGroup = nullptr;
__declspec(dllexport) void *__imp_JSGlobalContextRelease = nullptr;
__declspec(dllexport) void *__imp_JSGlobalContextSetName = nullptr;
__declspec(dllexport) void *__imp_JSStringIsEqualToUTF8CString = nullptr;
__declspec(dllexport) void *__imp_JSEvaluateScript = nullptr;
__declspec(dllexport) void *__imp_JSObjectMakeFunctionWithCallback = nullptr;
__declspec(dllexport) void *__imp_JSValueProtect = nullptr;
__declspec(dllexport) void *__imp_JSValueToNumber = nullptr;
__declspec(dllexport) void *__imp_JSObjectSetPrivate = nullptr;
}

Просмотреть файл

@ -1,64 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// module.cpp : Defines the module that contains the com classes
//
#include "pch.h"
#include <wrl\module.h>
extern "C" HRESULT WINAPI DllCanUnloadNow();
#if !defined(__WRL_CLASSIC_COM__)
extern "C" HRESULT WINAPI DllGetActivationFactory(_In_ HSTRING, _Deref_out_ IActivationFactory **);
extern "C" HRESULT WINAPI
DllGetActivationFactory(_In_ HSTRING activatibleClassId, _Deref_out_ IActivationFactory **factory) {
HRESULT hr = WINRT_GetActivationFactory((void *)activatibleClassId, (void **)factory);
if (hr != S_OK) {
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
hr = module.GetActivationFactory(activatibleClassId, factory);
}
return hr;
}
#endif
#if !defined(__WRL_WINRT_STRICT__)
extern "C" HRESULT WINAPI DllGetClassObject(REFCLSID, REFIID, _Deref_out_ LPVOID *);
extern "C" HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _Deref_out_ LPVOID *ppv) {
auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
return module.GetClassObject(rclsid, riid, ppv);
}
#endif
extern "C" HRESULT WINAPI DllCanUnloadNow() {
HRESULT hr = WINRT_CanUnloadNow();
if (hr == S_OK) {
const auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
hr = module.GetObjectCount() == 0 ? S_OK : S_FALSE;
}
return hr;
}
#if defined(_M_IX86)
#if !defined(__WRL_CLASSIC_COM__)
#pragma comment(linker, "/EXPORT:DllGetActivationFactory=_DllGetActivationFactory@8,PRIVATE")
#endif
#if !defined(__WRL_WINRT_STRICT__)
#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject@12,PRIVATE")
#endif
#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE")
#elif defined(_M_ARM) || defined(_M_AMD64)
#if !defined(__WRL_CLASSIC_COM__)
#pragma comment(linker, "/EXPORT:DllGetActivationFactory,PRIVATE")
#endif
#if !defined(__WRL_WINRT_STRICT__)
#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE")
#endif
#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE")
#endif

Просмотреть файл

@ -1,59 +0,0 @@
;READFIRST
;Please keep the ABI surface in sync across all platforms. If you need to add a
;new EXPORT, add it to the other def files too. The EXPORTs are sorted to aid
;in comparisons.
EXPORTS
??$str_to_floating@N@detail@folly@@YA?AV?$Expected@NW4ConversionCode@folly@@@1@PAV?$Range@PBD@1@@Z
??$str_to_integral@_J@detail@folly@@YA?AV?$Expected@_JW4ConversionCode@folly@@@1@PAV?$Range@PBD@1@@Z
??$str_to_integral@_K@detail@folly@@YA?AV?$Expected@_KW4ConversionCode@folly@@@1@PAV?$Range@PBD@1@@Z
??0ColdClass@cold_detail@folly@@QAA@XZ
??0ReactRootView@uwp@react@@QAA@UDependencyObject@Xaml@UI@Windows@winrt@@@Z
??0TypeError@folly@@QAA@$$QAU01@@Z
??0TypeError@folly@@QAA@ABU01@@Z
??0TypeError@folly@@QAA@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@1@Z
??0TypeError@folly@@QAA@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@@Z
??1TypeError@folly@@UAA@XZ
??4dynamic@folly@@QAAAAU01@$$QAU01@@Z
??4dynamic@folly@@QAAAAU01@ABU01@@Z
??8dynamic@folly@@QBA_NABU01@@Z
??Adynamic@folly@@QGAAAAU01@V?$Range@PBD@1@@Z
?CreateMemoryTracker@react@facebook@@YA?AV?$shared_ptr@VMemoryTracker@react@facebook@@@std@@$$QAV?$shared_ptr@VMessageQueueThread@react@facebook@@@4@@Z
?CreateWorkerMessageQueue@uwp@react@@YA?AV?$shared_ptr@VMessageQueueThread@react@facebook@@@std@@XZ
?InitializeLogging@react@facebook@@YAX$$QAV?$function@$$A6AXW4RCTLogLevel@react@facebook@@PBD@Z@std@@@Z
?InitializeTracing@react@facebook@@YAXPAUINativeTraceHandler@12@@Z
?Make@JSBigAbiString@react@facebook@@SA?AV?$unique_ptr@$$CBUJSBigAbiString@react@facebook@@U?$default_delete@$$CBUJSBigAbiString@react@facebook@@@std@@@std@@$$QAV?$unique_ptr@U?$IAbiArray@D@AbiSafe@@UAbiObjectDeleter@2@@5@@Z
?MakeMemoryMappedBuffer@JSI@Microsoft@@YA?AV?$shared_ptr@VBuffer@jsi@facebook@@@std@@QB_WI@Z
?at@dynamic@folly@@QGBAABU12@V?$Range@PBD@2@@Z
?atImpl@dynamic@folly@@AGBAABU12@ABU12@@Z
?callJSFunction@Instance@react@facebook@@QAAX$$QAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0$$QAUdynamic@folly@@@Z
?checkedMalloc@folly@@YAPAXI@Z
?demangle@folly@@YA?AV?$basic_fbstring@DU?$char_traits@D@std@@V?$allocator@D@2@V?$fbstring_core@D@folly@@@1@PBD@Z
?destroy@dynamic@folly@@AAAXXZ
?get_ptr@dynamic@folly@@QGBAPBU12@V?$Range@PBD@2@@Z
?hash@dynamic@folly@@QBAIXZ
?makeConversionError@folly@@YA?AVConversionError@1@W4ConversionCode@1@V?$Range@PBD@1@@Z
?parseJson@folly@@YA?AUdynamic@1@V?$Range@PBD@1@@Z
?size@dynamic@folly@@QBAIXZ
?str_to_bool@detail@folly@@YA?AV?$Expected@_NW4ConversionCode@folly@@@2@PAV?$Range@PBD@2@@Z
?toJson@folly@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABUdynamic@1@@Z
?Utf16ToUtf8@Unicode@Common@Microsoft@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@5@@Z
?Utf16ToUtf8@Unicode@Common@Microsoft@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_string_view@_WU?$char_traits@_W@std@@@5@@Z
?Utf8ToUtf16@Unicode@Common@Microsoft@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z
dallocxWeak
mallctlWeak
mallctlbymibWeak
mallctlnametomibWeak
mallocxWeak
nallocxWeak
rallocxWeak
sallocxWeak
sdallocxWeak
xallocxWeak
?set@HostObject@jsi@facebook@@UAAXAAVRuntime@23@ABVPropNameID@23@ABVValue@23@@Z
?getPropertyNames@HostObject@jsi@facebook@@UAA?AV?$vector@VPropNameID@jsi@facebook@@V?$allocator@VPropNameID@jsi@facebook@@@std@@@std@@AAVRuntime@23@@Z
??1Value@jsi@facebook@@QAA@XZ
??0TurboModule@react@facebook@@QAA@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VCallInvoker@react@facebook@@@4@@Z
??1TurboModule@react@facebook@@UAA@XZ
?get@TurboModule@react@facebook@@UAA?AVValue@jsi@3@AAVRuntime@53@ABVPropNameID@53@@Z
?GetReactInstanceFromUwpInstance@uwp@react@@YA?AV?$shared_ptr@VInstance@react@facebook@@@std@@ABUInstance@12winrt@@@Z
??0BridgeJSCallInvoker@react@facebook@@QAA@V?$weak_ptr@VInstance@react@facebook@@@std@@@Z

Просмотреть файл

@ -1,85 +0,0 @@
;READFIRST
;Please keep the ABI surface in sync across all platforms. If you need to add a
;new EXPORT, add it to the other def files too. The EXPORTs are sorted to aid
;in comparisons.
EXPORTS
??$str_to_floating@N@detail@folly@@YA?AV?$Expected@NW4ConversionCode@folly@@@1@PEAV?$Range@PEBD@1@@Z
??$str_to_integral@_J@detail@folly@@YA?AV?$Expected@_JW4ConversionCode@folly@@@1@PEAV?$Range@PEBD@1@@Z
??0AppState@react@facebook@@QEAA@XZ
??0AppStateModule@react@facebook@@QEAA@$$QEAV?$shared_ptr@VAppState@react@facebook@@@std@@@Z
??0ColdClass@cold_detail@folly@@QEAA@XZ
??0DeviceInfoModule@uwp@react@@QEAA@V?$shared_ptr@VDeviceInfo@uwp@react@@@std@@@Z
??0DeviceInfo@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0ImageViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0LocationObserverModule@uwp@react@@QEAA@AEBV?$shared_ptr@VMessageQueueThread@react@facebook@@@std@@@Z
??0NativeUIManager@uwp@react@@QEAA@XZ
??0RawTextViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0RootViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0ScrollViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TextInputViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TextViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TypeError@folly@@QEAA@$$QEAU01@@Z
??0TypeError@folly@@QEAA@AEBU01@@Z
??0TypeError@folly@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@1@Z
??0TypeError@folly@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@@Z
??0ViewViewManager@uwp@react@@QEAA@AEBV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0WebSocketModule@uwp@react@@QEAA@XZ
??1DevSupportManager@uwp@react@@QEAA@XZ
??1TypeError@folly@@UEAA@XZ
??4dynamic@folly@@QEAAAEAU01@$$QEAU01@@Z
??4dynamic@folly@@QEAAAEAU01@AEBU01@@Z
??8dynamic@folly@@QEBA_NAEBU01@@Z
??Adynamic@folly@@QEGAAAEAU01@V?$Range@PEBD@1@@Z
?CreateMemoryTracker@react@facebook@@YA?AV?$shared_ptr@VMemoryTracker@react@facebook@@@std@@$$QEAV?$shared_ptr@VMessageQueueThread@react@facebook@@@4@@Z
?CreateTimingModule@react@facebook@@YA?AV?$unique_ptr@VCxxModule@module@xplat@facebook@@U?$default_delete@VCxxModule@module@xplat@facebook@@@std@@@std@@AEBV?$shared_ptr@VMessageQueueThread@react@facebook@@@4@@Z
?CreateWorkerMessageQueue@uwp@react@@YA?AV?$shared_ptr@VMessageQueueThread@react@facebook@@@std@@XZ
?GetJavaScriptFromServer@DevSupportManager@uwp@react@@UEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@00@Z
?InitializeLogging@react@facebook@@YAX$$QEAV?$function@$$A6AXW4RCTLogLevel@react@facebook@@PEBD@Z@std@@@Z
?InitializeTracing@react@facebook@@YAXPEAUINativeTraceHandler@12@@Z
?JsPointerToStringUtf8@react@facebook@@YA?AW4_JsErrorCode@@PEBD_KPEAPEAX@Z
?JsStringToStdStringUtf8@react@facebook@@YA?AW4_JsErrorCode@@PEAXAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
?LoadJavaScriptInProxyMode@DevSupportManager@uwp@react@@UEAA?AV?$function@$$A6A?AV?$unique_ptr@VJSExecutor@react@facebook@@U?$default_delete@VJSExecutor@react@facebook@@@std@@@std@@V?$shared_ptr@VExecutorDelegate@react@facebook@@@2@V?$shared_ptr@VMessageQueueThread@react@facebook@@@2@@Z@std@@AEBUDevSettings@3facebook@@@Z
?Make@JSBigAbiString@react@facebook@@SA?AV?$unique_ptr@$$CBUJSBigAbiString@react@facebook@@U?$default_delete@$$CBUJSBigAbiString@react@facebook@@@std@@@std@@$$QEAV?$unique_ptr@U?$IAbiArray@D@AbiSafe@@UAbiObjectDeleter@2@@5@@Z
?MakeMemoryMappedBuffer@JSI@Microsoft@@YA?AV?$shared_ptr@VBuffer@jsi@facebook@@@std@@QEB_WI@Z
?StartPollingLiveReload@DevSupportManager@uwp@react@@UEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$function@$$A6AXXZ@5@@Z
?StopPollingLiveReload@DevSupportManager@uwp@react@@UEAAXXZ
?assertionFailure@detail@folly@@YAXPEBD00I0@Z
?assume_check@detail@folly@@YAX_N@Z
?at@dynamic@folly@@QEGBAAEBU12@V?$Range@PEBD@2@@Z
?atImpl@dynamic@folly@@AEGBAAEBU12@AEBU12@@Z
?callJSFunction@Instance@react@facebook@@QEAAX$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0$$QEAUdynamic@folly@@@Z
?createUIManagerModule@react@facebook@@YA?AV?$unique_ptr@VCxxModule@module@xplat@facebook@@U?$default_delete@VCxxModule@module@xplat@facebook@@@std@@@std@@V?$shared_ptr@VIUIManager@react@facebook@@@4@@Z
?demangle@folly@@YA?AV?$basic_fbstring@DU?$char_traits@D@std@@V?$allocator@D@2@V?$fbstring_core@D@folly@@@1@PEBD@Z
?destroy@dynamic@folly@@AEAAXXZ
?get_ptr@dynamic@folly@@QEGBAPEBU12@V?$Range@PEBD@2@@Z
?hash@dynamic@folly@@QEBA_KXZ
?logTaggedMarker@ReactMarker@react@facebook@@3P6AXW4ReactMarkerId@123@PEBD@ZEA
?makeConversionError@folly@@YA?AVConversionError@1@W4ConversionCode@1@V?$Range@PEBD@1@@Z
?parseJson@folly@@YA?AUdynamic@1@V?$Range@PEBD@1@@Z
?print_as_pseudo_json@dynamic@folly@@AEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z
?size@dynamic@folly@@QEBA_KXZ
?str_to_bool@detail@folly@@YA?AV?$Expected@_NW4ConversionCode@folly@@@2@PEAV?$Range@PEBD@2@@Z
?toJson@folly@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBUdynamic@1@@Z
?typeName@dynamic@folly@@QEBAPEBDXZ
?update@DeviceInfo@uwp@react@@QEAAXXZ
?Utf16ToUtf8@Unicode@Common@Microsoft@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@5@@Z
?Utf16ToUtf8@Unicode@Common@Microsoft@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$basic_string_view@_WU?$char_traits@_W@std@@@5@@Z
?warnAboutToCrash@ScopeGuardImplBase@detail@folly@@KAXXZ
dallocxWeak
mallctlWeak
mallctlbymibWeak
mallctlnametomibWeak
mallocxWeak
nallocxWeak
rallocxWeak
sallocxWeak
sdallocxWeak
xallocxWeak
?set@HostObject@jsi@facebook@@UEAAXAEAVRuntime@23@AEBVPropNameID@23@AEBVValue@23@@Z
?getPropertyNames@HostObject@jsi@facebook@@UEAA?AV?$vector@VPropNameID@jsi@facebook@@V?$allocator@VPropNameID@jsi@facebook@@@std@@@std@@AEAVRuntime@23@@Z
??1Value@jsi@facebook@@QEAA@XZ
??0TurboModule@react@facebook@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VCallInvoker@react@facebook@@@4@@Z
??1TurboModule@react@facebook@@UEAA@XZ
?get@TurboModule@react@facebook@@UEAA?AVValue@jsi@3@AEAVRuntime@53@AEBVPropNameID@53@@Z
?GetReactInstanceFromUwpInstance@uwp@react@@YA?AV?$shared_ptr@VInstance@react@facebook@@@std@@AEBUInstance@12winrt@@@Z
??0BridgeJSCallInvoker@react@facebook@@QEAA@V?$weak_ptr@VInstance@react@facebook@@@std@@@Z

Просмотреть файл

@ -1,85 +0,0 @@
;READFIRST
;Please keep the ABI surface in sync across all platforms. If you need to add a
;new EXPORT, add it to the other def files too. The EXPORTs are sorted to aid
;in comparisons.
EXPORTS
??$str_to_floating@N@detail@folly@@YG?AV?$Expected@NW4ConversionCode@folly@@@1@PAV?$Range@PBD@1@@Z
??$str_to_integral@_J@detail@folly@@YG?AV?$Expected@_JW4ConversionCode@folly@@@1@PAV?$Range@PBD@1@@Z
??0AppState@react@facebook@@QAE@XZ
??0AppStateModule@react@facebook@@QAE@$$QAV?$shared_ptr@VAppState@react@facebook@@@std@@@Z
??0ColdClass@cold_detail@folly@@QAE@XZ
??0DeviceInfoModule@uwp@react@@QAE@V?$shared_ptr@VDeviceInfo@uwp@react@@@std@@@Z
??0DeviceInfo@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0ImageViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0LocationObserverModule@uwp@react@@QAE@ABV?$shared_ptr@VMessageQueueThread@react@facebook@@@std@@@Z
??0NativeUIManager@uwp@react@@QAE@XZ
??0RawTextViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0RootViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0ScrollViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TextInputViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TextViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0TypeError@folly@@QAE@$$QAU01@@Z
??0TypeError@folly@@QAE@ABU01@@Z
??0TypeError@folly@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@1@Z
??0TypeError@folly@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4Type@dynamic@1@@Z
??0ViewViewManager@uwp@react@@QAE@ABV?$shared_ptr@UIReactInstance@uwp@react@@@std@@@Z
??0WebSocketModule@uwp@react@@QAE@XZ
??1DevSupportManager@uwp@react@@QAE@XZ
??1TypeError@folly@@UAE@XZ
??4dynamic@folly@@QAEAAU01@$$QAU01@@Z
??4dynamic@folly@@QAEAAU01@ABU01@@Z
??8dynamic@folly@@QBE_NABU01@@Z
??Adynamic@folly@@QGAEAAU01@V?$Range@PBD@1@@Z
?CreateMemoryTracker@react@facebook@@YG?AV?$shared_ptr@VMemoryTracker@react@facebook@@@std@@$$QAV?$shared_ptr@VMessageQueueThread@react@facebook@@@4@@Z
?CreateTimingModule@react@facebook@@YG?AV?$unique_ptr@VCxxModule@module@xplat@facebook@@U?$default_delete@VCxxModule@module@xplat@facebook@@@std@@@std@@ABV?$shared_ptr@VMessageQueueThread@react@facebook@@@4@@Z
?CreateWorkerMessageQueue@uwp@react@@YG?AV?$shared_ptr@VMessageQueueThread@react@facebook@@@std@@XZ
?GetJavaScriptFromServer@DevSupportManager@uwp@react@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV45@00@Z
?InitializeLogging@react@facebook@@YGX$$QAV?$function@$$A6GXW4RCTLogLevel@react@facebook@@PBD@Z@std@@@Z
?InitializeTracing@react@facebook@@YGXPAUINativeTraceHandler@12@@Z
?JsPointerToStringUtf8@react@facebook@@YG?AW4_JsErrorCode@@PBDIPAPAX@Z
?JsStringToStdStringUtf8@react@facebook@@YG?AW4_JsErrorCode@@PAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
?LoadJavaScriptInProxyMode@DevSupportManager@uwp@react@@UAE?AV?$function@$$A6G?AV?$unique_ptr@VJSExecutor@react@facebook@@U?$default_delete@VJSExecutor@react@facebook@@@std@@@std@@V?$shared_ptr@VExecutorDelegate@react@facebook@@@2@V?$shared_ptr@VMessageQueueThread@react@facebook@@@2@@Z@std@@ABUDevSettings@3facebook@@@Z
?Make@JSBigAbiString@react@facebook@@SG?AV?$unique_ptr@$$CBUJSBigAbiString@react@facebook@@U?$default_delete@$$CBUJSBigAbiString@react@facebook@@@std@@@std@@$$QAV?$unique_ptr@U?$IAbiArray@D@AbiSafe@@UAbiObjectDeleter@2@@5@@Z
?MakeMemoryMappedBuffer@JSI@Microsoft@@YG?AV?$shared_ptr@VBuffer@jsi@facebook@@@std@@QB_WI@Z
?StartPollingLiveReload@DevSupportManager@uwp@react@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$function@$$A6GXXZ@5@@Z
?StopPollingLiveReload@DevSupportManager@uwp@react@@UAEXXZ
?assertionFailure@detail@folly@@YGXPBD00I0@Z
?assume_check@detail@folly@@YGX_N@Z
?at@dynamic@folly@@QGBEABU12@V?$Range@PBD@2@@Z
?atImpl@dynamic@folly@@AGBEABU12@ABU12@@Z
?callJSFunction@Instance@react@facebook@@QAEX$$QAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0$$QAUdynamic@folly@@@Z
?createUIManagerModule@react@facebook@@YG?AV?$unique_ptr@VCxxModule@module@xplat@facebook@@U?$default_delete@VCxxModule@module@xplat@facebook@@@std@@@std@@V?$shared_ptr@VIUIManager@react@facebook@@@4@@Z
?demangle@folly@@YG?AV?$basic_fbstring@DU?$char_traits@D@std@@V?$allocator@D@2@V?$fbstring_core@D@folly@@@1@PBD@Z
?destroy@dynamic@folly@@AAEXXZ
?get_ptr@dynamic@folly@@QGBEPBU12@V?$Range@PBD@2@@Z
?hash@dynamic@folly@@QBEIXZ
?logTaggedMarker@ReactMarker@react@facebook@@3P6GXW4ReactMarkerId@123@PBD@ZA
?makeConversionError@folly@@YG?AVConversionError@1@W4ConversionCode@1@V?$Range@PBD@1@@Z
?parseJson@folly@@YG?AUdynamic@1@V?$Range@PBD@1@@Z
?print_as_pseudo_json@dynamic@folly@@ABEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z
?size@dynamic@folly@@QBEIXZ
?str_to_bool@detail@folly@@YG?AV?$Expected@_NW4ConversionCode@folly@@@2@PAV?$Range@PBD@2@@Z
?toJson@folly@@YG?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABUdynamic@1@@Z
?typeName@dynamic@folly@@QBEPBDXZ
?update@DeviceInfo@uwp@react@@QAEXXZ
?Utf16ToUtf8@Unicode@Common@Microsoft@@YG?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@5@@Z
?Utf16ToUtf8@Unicode@Common@Microsoft@@YG?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_string_view@_WU?$char_traits@_W@std@@@5@@Z
;?warnAboutToCrash@ScopeGuardImplBase@detail@folly@@KAXXZ
dallocxWeak
mallctlWeak
mallctlbymibWeak
mallctlnametomibWeak
mallocxWeak
nallocxWeak
rallocxWeak
sallocxWeak
sdallocxWeak
xallocxWeak
?set@HostObject@jsi@facebook@@UAEXAAVRuntime@23@ABVPropNameID@23@ABVValue@23@@Z
?getPropertyNames@HostObject@jsi@facebook@@UAE?AV?$vector@VPropNameID@jsi@facebook@@V?$allocator@VPropNameID@jsi@facebook@@@std@@@std@@AAVRuntime@23@@Z
??1Value@jsi@facebook@@QAE@XZ
??0TurboModule@react@facebook@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VCallInvoker@react@facebook@@@4@@Z
??1TurboModule@react@facebook@@UAE@XZ
?get@TurboModule@react@facebook@@UAE?AVValue@jsi@3@AAVRuntime@53@ABVPropNameID@53@@Z
?GetReactInstanceFromUwpInstance@uwp@react@@YA?AV?$shared_ptr@VInstance@react@facebook@@@std@@ABUInstance@12winrt@@@Z
??0BridgeJSCallInvoker@react@facebook@@QAE@V?$weak_ptr@VInstance@react@facebook@@@std@@@Z

Просмотреть файл

@ -1,54 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "AppStateModuleUwp.h"
namespace react {
namespace uwp {
//
// AppState
//
AppState::AppState(const std::shared_ptr<IReactInstance> &reactInstance)
: facebook::react::AppState(), m_wkReactInstance(reactInstance) {
m_lastState = "active";
m_enteredBackgroundRevoker =
xaml::Application::Current().EnteredBackground(winrt::auto_revoke, {this, &AppState::EnteredBackground});
m_leavingBackgroundRevoker =
xaml::Application::Current().LeavingBackground(winrt::auto_revoke, {this, &AppState::LeavingBackground});
}
AppState::~AppState() = default;
const char *AppState::getState() {
return m_lastState;
}
void AppState::EnteredBackground(
winrt::Windows::Foundation::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::EnteredBackgroundEventArgs const & /*e*/) {
fireEvent("background");
}
void AppState::LeavingBackground(
winrt::Windows::Foundation::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::LeavingBackgroundEventArgs const & /*e*/) {
fireEvent("active");
}
void AppState::fireEvent(const char *newState) {
auto instance = m_wkReactInstance.lock();
if (instance) {
m_lastState = newState;
folly::dynamic parameters = folly::dynamic::object("app_state", newState);
instance->CallJsFunction(
"RCTDeviceEventEmitter", "emit", folly::dynamic::array("appStateDidChange", std::move(parameters)));
}
}
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,39 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <IReactInstance.h>
#include <Modules/AppStateModule.h>
#include <winrt/Windows.ApplicationModel.Core.h>
#include <winrt/Windows.Foundation.h>
namespace react {
namespace uwp {
class AppState : public facebook::react::AppState {
public:
AppState(const std::shared_ptr<IReactInstance> &reactInstance);
virtual ~AppState();
const char *getState() override;
private:
void EnteredBackground(
winrt::Windows::Foundation::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::EnteredBackgroundEventArgs const & /*e*/);
void LeavingBackground(
winrt::Windows::Foundation::IInspectable const & /*sender*/,
winrt::Windows::ApplicationModel::LeavingBackgroundEventArgs const & /*e*/);
void fireEvent(const char *newState);
const char *m_lastState;
std::weak_ptr<IReactInstance> m_wkReactInstance;
xaml::Application::EnteredBackground_revoker m_enteredBackgroundRevoker;
xaml::Application::LeavingBackground_revoker m_leavingBackgroundRevoker;
};
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,77 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "ClipboardModule.h"
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
#include "Unicode.h"
#pragma warning(push)
#pragma warning(disable : 4146)
#include <cxxreact/JsArgumentHelpers.h>
#pragma warning(pop)
#if _MSC_VER <= 1913
// VC 19 (2015-2017.6) cannot optimize co_await/cppwinrt usage
#pragma optimize("", off)
#endif
namespace react {
namespace uwp {
//
// ClipboardModule
//
const char *ClipboardModule::name = "Clipboard";
ClipboardModule::~ClipboardModule() = default;
std::string ClipboardModule::getName() {
return name;
}
std::map<std::string, folly::dynamic> ClipboardModule::getConstants() {
return {};
}
std::vector<facebook::xplat::module::CxxModule::Method> ClipboardModule::getMethods() {
return {
Method(
"setString",
[](folly::dynamic args) { ClipboardModule::SetClipboardText(facebook::xplat::jsArgAsString(args, 0)); }),
Method(
"getString",
[](folly::dynamic args, Callback cbSuccess, Callback cbFail) {
ClipboardModule::GetClipboardText(cbSuccess, cbFail);
}),
};
}
/*static*/ void ClipboardModule::SetClipboardText(const std::string &text) {
winrt::Windows::ApplicationModel::DataTransfer::DataPackage data;
data.SetText(Microsoft::Common::Unicode::Utf8ToUtf16(text));
winrt::Windows::ApplicationModel::DataTransfer::Clipboard::SetContent(data);
}
winrt::fire_and_forget GetClipboardTextAsync(
facebook::xplat::module::CxxModule::Callback cbSuccess,
facebook::xplat::module::CxxModule::Callback cbFail) {
winrt::Windows::ApplicationModel::DataTransfer::DataPackageView data =
winrt::Windows::ApplicationModel::DataTransfer::Clipboard::GetContent();
try {
std::wstring text = std::wstring(co_await data.GetTextAsync());
cbSuccess({Microsoft::Common::Unicode::Utf16ToUtf8(text)});
} catch (...) {
cbFail({});
}
}
/*static*/ void ClipboardModule::GetClipboardText(const Callback &cbSuccess, const Callback &cbFail) {
GetClipboardTextAsync(cbSuccess, cbFail);
}
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,29 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <cxxreact/CxxModule.h>
#include <folly/dynamic.h>
namespace react {
namespace uwp {
class ClipboardModule final : public facebook::xplat::module::CxxModule {
public:
virtual ~ClipboardModule();
// CxxModule
std::string getName() override;
std::map<std::string, folly::dynamic> getConstants() override;
auto getMethods() -> std::vector<Method> override;
static const char *name;
private:
static void SetClipboardText(const std::string &text);
static void GetClipboardText(const Callback &cbSuccess, const Callback &cbFail);
};
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,58 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "DevSettingsModule.h"
namespace react::uwp {
auto DevSettingsModule::getConstants() -> std::map<std::string, folly::dynamic> {
return {};
}
const char *DevSettingsModule::name = "DevSettings";
std::string DevSettingsModule::getName() {
return name;
}
DevSettingsModule::DevSettingsModule() {}
void DevSettingsModule::reload() {
assert(false);
}
void DevSettingsModule::setHotLoadingEnabled(bool /*isHotLoadingEnabled*/) {
assert(false);
}
void DevSettingsModule::setIsDebuggingRemotely(bool /*isDebuggingRemotelyEnabled*/) {
assert(false);
}
void DevSettingsModule::setLiveReloadEnabled(bool /*setLiveReloadEnabled*/) {
assert(false);
}
void DevSettingsModule::setProfilingEnabled(bool /*setProfilingEnabled*/) {
assert(false);
}
void DevSettingsModule::toggleElementInspector() {
assert(false);
}
// iOS only.
void DevSettingsModule::setIsShakeToShowDevMenuEnabled(bool /*enabled*/) {
assert(false);
}
auto DevSettingsModule::getMethods() -> std::vector<facebook::xplat::module::CxxModule::Method> {
return {
Method("reload", [this](folly::dynamic args) { reload(); }),
Method("setHotLoadingEnabled", [this](folly::dynamic args) { setHotLoadingEnabled(args[0].getBool()); }),
Method("setIsDebuggingRemotely", [this](folly::dynamic args) { setIsDebuggingRemotely(args[0].getBool()); }),
Method("setLiveReloadEnabled", [this](folly::dynamic args) { setLiveReloadEnabled(args[0].getBool()); }),
Method("setProfilingEnabled", [this](folly::dynamic args) { setProfilingEnabled(args[0].getBool()); }),
Method("toggleElementInspector", [this](folly::dynamic args) { toggleElementInspector(); }),
Method(
"setIsShakeToShowDevMenuEnabled",
[this](folly::dynamic args) { setIsShakeToShowDevMenuEnabled(args[0].getBool()); }),
};
}
} // namespace react::uwp

Просмотреть файл

@ -1,30 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <cxxreact/CxxModule.h>
namespace react::uwp {
class DevSettingsModule : public facebook::xplat::module::CxxModule {
public:
DevSettingsModule();
static const char *name;
std::string getName() override;
std::map<std::string, folly::dynamic> getConstants() override;
std::vector<Method> getMethods() override;
void reload();
void setHotLoadingEnabled(bool isHotLoadingEnabled);
void setIsDebuggingRemotely(bool isDebuggingRemotelyEnabled);
void setLiveReloadEnabled(bool setLiveReloadEnabled);
void setProfilingEnabled(bool setProfilingEnabled);
void toggleElementInspector();
// iOS only.
void setIsShakeToShowDevMenuEnabled(bool enabled);
};
} // namespace react::uwp

Просмотреть файл

@ -1,87 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include <winrt/Windows.Graphics.Display.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.ViewManagement.h>
#include "DeviceInfoModule.h"
namespace react {
namespace uwp {
//
// DeviceInfo
//
DeviceInfo::DeviceInfo(const std::shared_ptr<IReactInstance> &reactInstance) : m_wkReactInstance(reactInstance) {
update();
listenToUpdates();
}
void DeviceInfo::listenToUpdates() {
auto const &displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
auto const &window = xaml::Window::Current().CoreWindow();
m_sizeChangedRevoker = window.SizeChanged(winrt::auto_revoke, [this](auto &&, auto &&) {
update();
fireEvent();
});
m_dpiChangedRevoker = displayInfo.DpiChanged(winrt::auto_revoke, [this](const auto &, const auto &) {
update();
fireEvent();
});
}
void DeviceInfo::update() {
auto const &displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
auto scale = static_cast<float>(displayInfo.ResolutionScale()) / 100;
winrt::Windows::UI::ViewManagement::UISettings uiSettings;
auto const &window = xaml::Window::Current().CoreWindow();
m_dimensions = folly::dynamic::object(
"windowPhysicalPixels",
folly::dynamic::object("width", window.Bounds().Width * scale)("height", window.Bounds().Height * scale)(
"scale", scale)("fontScale", uiSettings.TextScaleFactor())("densityDpi", displayInfo.LogicalDpi()))(
"screenPhysicalPixels",
folly::dynamic::object("width", displayInfo.ScreenWidthInRawPixels())(
"height", displayInfo.ScreenHeightInRawPixels())("scale", scale)("fontScale", uiSettings.TextScaleFactor())(
"densityDpi", displayInfo.LogicalDpi()));
}
void DeviceInfo::fireEvent() {
auto instance = m_wkReactInstance.lock();
if (instance) {
instance->CallJsFunction(
"RCTDeviceEventEmitter",
"emit",
folly::dynamic::array("didUpdateDimensions", std::move(GetDimensionsConstants())));
}
}
//
// DeviceInfoModule
//
const char *DeviceInfoModule::name = "DeviceInfo";
DeviceInfoModule::DeviceInfoModule(std::shared_ptr<DeviceInfo> deviceInfo) : m_deviceInfo(std::move(deviceInfo)) {}
std::string DeviceInfoModule::getName() {
return name;
}
std::map<std::string, folly::dynamic> DeviceInfoModule::getConstants() {
std::map<std::string, folly::dynamic> constants{{"Dimensions", m_deviceInfo->GetDimensionsConstants()}};
return constants;
}
auto DeviceInfoModule::getMethods() -> std::vector<Method> {
return std::vector<Method>();
}
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,51 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <IReactInstance.h>
#include <cxxreact/CxxModule.h>
#include <folly/dynamic.h>
#include <winrt/Windows.Graphics.Display.h>
#include <memory>
#include <vector>
namespace react {
namespace uwp {
// TODO: Emit event to react when dimensions change.
class DeviceInfo {
public:
DeviceInfo(const std::shared_ptr<IReactInstance> &reactInstance);
folly::dynamic GetDimensionsConstants() {
return m_dimensions;
}
void update();
void listenToUpdates();
private:
void fireEvent();
folly::dynamic m_dimensions;
std::weak_ptr<IReactInstance> m_wkReactInstance;
winrt::Windows::UI::Core::CoreWindow::SizeChanged_revoker m_sizeChangedRevoker;
winrt::Windows::Graphics::Display::DisplayInformation::DpiChanged_revoker m_dpiChangedRevoker{};
};
class DeviceInfoModule : public facebook::xplat::module::CxxModule {
public:
DeviceInfoModule(std::shared_ptr<DeviceInfo> deviceInfo);
// CxxModule
std::string getName() override;
std::map<std::string, folly::dynamic> getConstants() override;
auto getMethods() -> std::vector<Method> override;
static const char *name;
private:
std::shared_ptr<DeviceInfo> m_deviceInfo;
};
} // namespace uwp
} // namespace react

Просмотреть файл

@ -1,21 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include <ReactUWPABI.h>
#include <TurboModuleUtils.h>
#include "../ABI/Instance_rt.h"
namespace react::uwp {
std::shared_ptr<facebook::react::Instance> __cdecl GetReactInstanceFromUwpInstance(
const winrt::react::uwp::Instance &uwpInstance) {
auto abiInstance = reinterpret_cast<ABI::react::uwp::Instance *>(winrt::get_abi(uwpInstance));
auto reactInstance = abiInstance->getInstance();
assert(reactInstance);
auto fbInstance = reactInstance->GetInnerInstance();
assert(fbInstance);
return fbInstance;
}
} // namespace react::uwp

Просмотреть файл

@ -1,48 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "AppStateModule.h"
namespace facebook {
namespace react {
//
// AppState
//
AppState::AppState() = default;
AppState::~AppState() = default;
// TODO: real implementation
const char *AppState::getState() {
return "active";
}
//
// AppStateModule
//
const char *AppStateModule::name = "RCTAppState";
AppStateModule::AppStateModule(std::shared_ptr<AppState> &&appState) : m_appState(std::move(appState)) {}
std::string AppStateModule::getName() {
return name;
}
std::map<std::string, folly::dynamic> AppStateModule::getConstants() {
return {{"initialAppState", m_appState->getState()}};
}
auto AppStateModule::getMethods() -> std::vector<facebook::xplat::module::CxxModule::Method> {
return {Method(
"getCurrentAppState",
[this](folly::dynamic args, Callback cbSuccess, Callback /*cbFailure*/) {
cbSuccess({folly::dynamic::object("app_state", m_appState->getState())});
},
AsyncTag)};
}
} // namespace react
} // namespace facebook

Просмотреть файл

@ -1,38 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <cxxreact/CxxModule.h>
#include <folly/dynamic.h>
#include <map>
#include <vector>
namespace facebook {
namespace react {
class AppState {
public:
AppState();
virtual ~AppState();
virtual const char *getState();
};
class AppStateModule : public facebook::xplat::module::CxxModule {
public:
AppStateModule(std::shared_ptr<AppState> &&appState);
static const char *name;
// CxxModule
std::string getName() override;
std::map<std::string, folly::dynamic> getConstants() override;
auto getMethods() -> std::vector<Method> override;
private:
std::shared_ptr<AppState> m_appState;
};
} // namespace react
} // namespace facebook

Просмотреть файл

@ -63,9 +63,6 @@
<ClCompile Include="MemoryTracker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Modules\AppStateModule.cpp">
<Filter>Source Files\Modules</Filter>
</ClCompile>
<ClCompile Include="Modules\AsyncStorageModule.cpp">
<Filter>Source Files\Modules</Filter>
</ClCompile>

Просмотреть файл

@ -193,7 +193,6 @@
<ClCompile Include="JSBigAbiString.cpp" />
<ClCompile Include="LayoutAnimation.cpp" />
<ClCompile Include="MemoryTracker.cpp" />
<ClCompile Include="Modules\AppStateModule.cpp" />
<ClCompile Include="Modules\AsyncStorageModule.cpp" />
<ClCompile Include="Modules\AsyncStorageModuleWin32.cpp" />
<ClCompile Include="Modules\ExceptionsManagerModule.cpp" />

Просмотреть файл

@ -63,9 +63,6 @@
<ClCompile Include="MemoryTracker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Modules\AppStateModule.cpp">
<Filter>Source Files\Modules</Filter>
</ClCompile>
<ClCompile Include="Modules\AsyncStorageModule.cpp">
<Filter>Source Files\Modules</Filter>
</ClCompile>

Просмотреть файл

@ -15,8 +15,8 @@ namespace Microsoft::ReactNativeSpecs {
struct AccessibilityInfoSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(Callback<JSValue>) noexcept>{0, L"isReduceMotionEnabled"},
Method<void(Callback<JSValue>) noexcept>{1, L"isTouchExplorationEnabled"},
Method<void(Callback<React::JSValue>) noexcept>{0, L"isReduceMotionEnabled"},
Method<void(Callback<React::JSValue>) noexcept>{1, L"isTouchExplorationEnabled"},
Method<void(double) noexcept>{2, L"setAccessibilityFocus"},
Method<void(std::string) noexcept>{3, L"announceForAccessibility"},
};

Просмотреть файл

@ -15,13 +15,13 @@ namespace Microsoft::ReactNativeSpecs {
struct AccessibilityManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{0, L"getCurrentBoldTextState"},
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{1, L"getCurrentGrayscaleState"},
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{2, L"getCurrentInvertColorsState"},
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{3, L"getCurrentReduceMotionState"},
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{4, L"getCurrentReduceTransparencyState"},
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{5, L"getCurrentVoiceOverState"},
Method<void(JSValueObject) noexcept>{6, L"setAccessibilityContentSizeMultipliers"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{0, L"getCurrentBoldTextState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{1, L"getCurrentGrayscaleState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{2, L"getCurrentInvertColorsState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{3, L"getCurrentReduceMotionState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{4, L"getCurrentReduceTransparencyState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{5, L"getCurrentVoiceOverState"},
Method<void(React::JSValueObject) noexcept>{6, L"setAccessibilityContentSizeMultipliers"},
Method<void(double) noexcept>{7, L"setAccessibilityFocus"},
Method<void(std::string) noexcept>{8, L"announceForAccessibility"},
};

Просмотреть файл

@ -15,8 +15,8 @@ namespace Microsoft::ReactNativeSpecs {
struct ActionSheetManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Callback<JSValue>) noexcept>{0, L"showActionSheetWithOptions"},
Method<void(JSValueObject, Callback<JSValue>, Callback<JSValue>) noexcept>{1, L"showShareActionSheetWithOptions"},
Method<void(React::JSValueObject, Callback<React::JSValue>) noexcept>{0, L"showActionSheetWithOptions"},
Method<void(React::JSValueObject, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{1, L"showShareActionSheetWithOptions"},
};
template <class TModule>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct AlertManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Callback<JSValue>) noexcept>{0, L"alertWithArgs"},
Method<void(React::JSValueObject, Callback<React::JSValue>) noexcept>{0, L"alertWithArgs"},
};
template <class TModule>

Просмотреть файл

@ -15,12 +15,12 @@ namespace Microsoft::ReactNativeSpecs {
struct AnimatedModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(double, JSValueObject) noexcept>{0, L"createAnimatedNode"},
Method<void(double, React::JSValueObject) noexcept>{0, L"createAnimatedNode"},
Method<void(double) noexcept>{1, L"startListeningToAnimatedNodeValue"},
Method<void(double) noexcept>{2, L"stopListeningToAnimatedNodeValue"},
Method<void(double, double) noexcept>{3, L"connectAnimatedNodes"},
Method<void(double, double) noexcept>{4, L"disconnectAnimatedNodes"},
Method<void(double, double, JSValueObject, Callback<JSValue>) noexcept>{5, L"startAnimatingNode"},
Method<void(double, double, React::JSValueObject, Callback<React::JSValue>) noexcept>{5, L"startAnimatingNode"},
Method<void(double) noexcept>{6, L"stopAnimation"},
Method<void(double, double) noexcept>{7, L"setAnimatedNodeValue"},
Method<void(double, double) noexcept>{8, L"setAnimatedNodeOffset"},
@ -30,7 +30,7 @@ struct AnimatedModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
Method<void(double, double) noexcept>{12, L"disconnectAnimatedNodeFromView"},
Method<void(double) noexcept>{13, L"restoreDefaultValues"},
Method<void(double) noexcept>{14, L"dropAnimatedNode"},
Method<void(double, std::string, JSValueObject) noexcept>{15, L"addAnimatedEventToView"},
Method<void(double, std::string, React::JSValueObject) noexcept>{15, L"addAnimatedEventToView"},
Method<void(double, std::string, double) noexcept>{16, L"removeAnimatedEventFromView"},
Method<void(std::string) noexcept>{17, L"addListener"},
Method<void(double) noexcept>{18, L"removeListeners"},

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct AppStateSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(Callback<JSValue>, Callback<JSValue>) noexcept>{0, L"getCurrentAppState"},
Method<void(Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{0, L"getCurrentAppState"},
Method<void(std::string) noexcept>{1, L"addListener"},
Method<void(double) noexcept>{2, L"removeListeners"},
};

Просмотреть файл

@ -15,12 +15,12 @@ namespace Microsoft::ReactNativeSpecs {
struct AsyncStorageSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueArray, Callback<JSValue>) noexcept>{0, L"multiGet"},
Method<void(JSValueArray, Callback<JSValue>) noexcept>{1, L"multiSet"},
Method<void(JSValueArray, Callback<JSValue>) noexcept>{2, L"multiMerge"},
Method<void(JSValueArray, Callback<JSValue>) noexcept>{3, L"multiRemove"},
Method<void(Callback<JSValue>) noexcept>{4, L"clear"},
Method<void(Callback<JSValue>) noexcept>{5, L"getAllKeys"},
Method<void(React::JSValueArray, Callback<React::JSValue>) noexcept>{0, L"multiGet"},
Method<void(React::JSValueArray, Callback<React::JSValue>) noexcept>{1, L"multiSet"},
Method<void(React::JSValueArray, Callback<React::JSValue>) noexcept>{2, L"multiMerge"},
Method<void(React::JSValueArray, Callback<React::JSValue>) noexcept>{3, L"multiRemove"},
Method<void(Callback<React::JSValue>) noexcept>{4, L"clear"},
Method<void(Callback<React::JSValue>) noexcept>{5, L"getAllKeys"},
};
template <class TModule>

Просмотреть файл

@ -18,8 +18,8 @@ struct BlobModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
Method<void() noexcept>{0, L"addNetworkingHandler"},
Method<void(double) noexcept>{1, L"addWebSocketHandler"},
Method<void(double) noexcept>{2, L"removeWebSocketHandler"},
Method<void(JSValueObject, double) noexcept>{3, L"sendOverSocket"},
Method<void(JSValueArray, std::string) noexcept>{4, L"createFromParts"},
Method<void(React::JSValueObject, double) noexcept>{3, L"sendOverSocket"},
Method<void(React::JSValueArray, std::string) noexcept>{4, L"createFromParts"},
Method<void(std::string) noexcept>{5, L"release"},
};

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft::ReactNativeSpecs {
struct BugReportingSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void() noexcept>{0, L"startReportAProblemFlow"},
Method<void(JSValueObject, JSValueObject) noexcept>{1, L"setExtraData"},
Method<void(React::JSValueObject, React::JSValueObject) noexcept>{1, L"setExtraData"},
Method<void(std::string) noexcept>{2, L"setCategoryID"},
};

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct DatePickerAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Promise<React::JSValue>) noexcept>{0, L"open"},
Method<void(React::JSValueObject, Promise<React::JSValue>) noexcept>{0, L"open"},
};
template <class TModule>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct DevLoadingViewSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(std::string, JSValueObject, JSValueObject) noexcept>{0, L"showMessage"},
Method<void(std::string, React::JSValueObject, React::JSValueObject) noexcept>{0, L"showMessage"},
Method<void() noexcept>{1, L"hide"},
};

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct DialogManagerAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Callback<JSValue>, Callback<JSValue>) noexcept>{0, L"showAlert"},
Method<void(React::JSValueObject, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{0, L"showAlert"},
};
template <class TModule>

Просмотреть файл

@ -15,10 +15,10 @@ namespace Microsoft::ReactNativeSpecs {
struct ExceptionsManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(std::string, JSValueArray, double) noexcept>{0, L"reportFatalException"},
Method<void(std::string, JSValueArray, double) noexcept>{1, L"reportSoftException"},
Method<void(JSValueObject) noexcept>{2, L"reportException"},
Method<void(std::string, JSValueArray, double) noexcept>{3, L"updateExceptionMessage"},
Method<void(std::string, React::JSValueArray, double) noexcept>{0, L"reportFatalException"},
Method<void(std::string, React::JSValueArray, double) noexcept>{1, L"reportSoftException"},
Method<void(React::JSValueObject) noexcept>{2, L"reportException"},
Method<void(std::string, React::JSValueArray, double) noexcept>{3, L"updateExceptionMessage"},
Method<void() noexcept>{4, L"dismissRedbox"},
};

Просмотреть файл

@ -15,8 +15,8 @@ namespace Microsoft::ReactNativeSpecs {
struct FileReaderModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Promise<React::JSValue>) noexcept>{0, L"readAsDataURL"},
Method<void(JSValueObject, std::string, Promise<React::JSValue>) noexcept>{1, L"readAsText"},
Method<void(React::JSValueObject, Promise<React::JSValue>) noexcept>{0, L"readAsDataURL"},
Method<void(React::JSValueObject, std::string, Promise<React::JSValue>) noexcept>{1, L"readAsText"},
};
template <class TModule>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct FrameRateLoggerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject) noexcept>{0, L"setGlobalOptions"},
Method<void(React::JSValueObject) noexcept>{0, L"setGlobalOptions"},
Method<void(std::string) noexcept>{1, L"setContext"},
Method<void() noexcept>{2, L"beginScroll"},
Method<void() noexcept>{3, L"endScroll"},

Просмотреть файл

@ -17,9 +17,9 @@ struct ImageLoaderAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(double) noexcept>{0, L"abortRequest"},
Method<void(std::string, Promise<React::JSValue>) noexcept>{1, L"getSize"},
Method<void(std::string, JSValueObject, Promise<React::JSValue>) noexcept>{2, L"getSizeWithHeaders"},
Method<void(std::string, React::JSValueObject, Promise<React::JSValue>) noexcept>{2, L"getSizeWithHeaders"},
Method<void(std::string, double, Promise<React::JSValue>) noexcept>{3, L"prefetchImage"},
Method<void(JSValueArray, Promise<React::JSValue>) noexcept>{4, L"queryCache"},
Method<void(React::JSValueArray, Promise<React::JSValue>) noexcept>{4, L"queryCache"},
};
template <class TModule>

Просмотреть файл

@ -16,9 +16,9 @@ namespace Microsoft::ReactNativeSpecs {
struct ImageLoaderIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(std::string, Promise<React::JSValue>) noexcept>{0, L"getSize"},
Method<void(std::string, JSValueObject, Promise<React::JSValue>) noexcept>{1, L"getSizeWithHeaders"},
Method<void(std::string, React::JSValueObject, Promise<React::JSValue>) noexcept>{1, L"getSizeWithHeaders"},
Method<void(std::string, Promise<React::JSValue>) noexcept>{2, L"prefetchImage"},
Method<void(JSValueArray, Promise<React::JSValue>) noexcept>{3, L"queryCache"},
Method<void(React::JSValueArray, Promise<React::JSValue>) noexcept>{3, L"queryCache"},
};
template <class TModule>

Просмотреть файл

@ -15,10 +15,10 @@ namespace Microsoft::ReactNativeSpecs {
struct ImagePickerIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(Callback<JSValue>) noexcept>{0, L"canRecordVideos"},
Method<void(Callback<JSValue>) noexcept>{1, L"canUseCamera"},
Method<void(JSValueObject, Callback<JSValue>, Callback<JSValue>) noexcept>{2, L"openCameraDialog"},
Method<void(JSValueObject, Callback<JSValue>, Callback<JSValue>) noexcept>{3, L"openSelectDialog"},
Method<void(Callback<React::JSValue>) noexcept>{0, L"canRecordVideos"},
Method<void(Callback<React::JSValue>) noexcept>{1, L"canUseCamera"},
Method<void(React::JSValueObject, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{2, L"openCameraDialog"},
Method<void(React::JSValueObject, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{3, L"openSelectDialog"},
Method<void() noexcept>{4, L"clearAllPendingVideos"},
Method<void(std::string) noexcept>{5, L"removePendingVideo"},
};

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct JSDevSupportSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject) noexcept>{0, L"onSuccess"},
Method<void(React::JSValueObject) noexcept>{0, L"onSuccess"},
Method<void(double, std::string) noexcept>{1, L"onFailure"},
};

Просмотреть файл

@ -19,7 +19,7 @@ struct LinkingSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
Method<void(std::string, Promise<React::JSValue>) noexcept>{1, L"canOpenURL"},
Method<void(std::string, Promise<React::JSValue>) noexcept>{2, L"openURL"},
Method<void(Promise<React::JSValue>) noexcept>{3, L"openSettings"},
Method<void(std::string, JSValueArray, Promise<React::JSValue>) noexcept>{4, L"sendIntent"},
Method<void(std::string, React::JSValueArray, Promise<React::JSValue>) noexcept>{4, L"sendIntent"},
Method<void(std::string) noexcept>{5, L"addListener"},
Method<void(double) noexcept>{6, L"removeListeners"},
};

Просмотреть файл

@ -15,9 +15,9 @@ namespace Microsoft::ReactNativeSpecs {
struct NetworkingAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(std::string, std::string, double, JSValueArray, JSValueObject, std::string, bool, double, bool) noexcept>{0, L"sendRequest"},
Method<void(std::string, std::string, double, React::JSValueArray, React::JSValueObject, std::string, bool, double, bool) noexcept>{0, L"sendRequest"},
Method<void(double) noexcept>{1, L"abortRequest"},
Method<void(Callback<JSValue>) noexcept>{2, L"clearCookies"},
Method<void(Callback<React::JSValue>) noexcept>{2, L"clearCookies"},
Method<void(std::string) noexcept>{3, L"addListener"},
Method<void(double) noexcept>{4, L"removeListeners"},
};

Просмотреть файл

@ -15,9 +15,9 @@ namespace Microsoft::ReactNativeSpecs {
struct NetworkingIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, Callback<JSValue>) noexcept>{0, L"sendRequest"},
Method<void(React::JSValueObject, Callback<React::JSValue>) noexcept>{0, L"sendRequest"},
Method<void(double) noexcept>{1, L"abortRequest"},
Method<void(Callback<JSValue>) noexcept>{2, L"clearCookies"},
Method<void(Callback<React::JSValue>) noexcept>{2, L"clearCookies"},
Method<void(std::string) noexcept>{3, L"addListener"},
Method<void(double) noexcept>{4, L"removeListeners"},
};

Просмотреть файл

@ -18,7 +18,7 @@ struct PermissionsAndroidSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
Method<void(std::string, Promise<React::JSValue>) noexcept>{0, L"checkPermission"},
Method<void(std::string, Promise<React::JSValue>) noexcept>{1, L"requestPermission"},
Method<void(std::string, Promise<React::JSValue>) noexcept>{2, L"shouldShowRequestPermissionRationale"},
Method<void(JSValueArray, Promise<React::JSValue>) noexcept>{3, L"requestMultiplePermissions"},
Method<void(React::JSValueArray, Promise<React::JSValue>) noexcept>{3, L"requestMultiplePermissions"},
};
template <class TModule>

Просмотреть файл

@ -17,19 +17,19 @@ struct PushNotificationManagerIOSSpec : winrt::Microsoft::ReactNative::TurboModu
static constexpr auto methods = std::tuple{
Method<void(std::string, std::string) noexcept>{0, L"onFinishRemoteNotification"},
Method<void(double) noexcept>{1, L"setApplicationIconBadgeNumber"},
Method<void(Callback<JSValue>) noexcept>{2, L"getApplicationIconBadgeNumber"},
Method<void(JSValueObject, Promise<React::JSValue>) noexcept>{3, L"requestPermissions"},
Method<void(Callback<React::JSValue>) noexcept>{2, L"getApplicationIconBadgeNumber"},
Method<void(React::JSValueObject, Promise<React::JSValue>) noexcept>{3, L"requestPermissions"},
Method<void() noexcept>{4, L"abandonPermissions"},
Method<void(Callback<JSValue>) noexcept>{5, L"checkPermissions"},
Method<void(JSValueObject) noexcept>{6, L"presentLocalNotification"},
Method<void(JSValueObject) noexcept>{7, L"scheduleLocalNotification"},
Method<void(Callback<React::JSValue>) noexcept>{5, L"checkPermissions"},
Method<void(React::JSValueObject) noexcept>{6, L"presentLocalNotification"},
Method<void(React::JSValueObject) noexcept>{7, L"scheduleLocalNotification"},
Method<void() noexcept>{8, L"cancelAllLocalNotifications"},
Method<void(JSValueObject) noexcept>{9, L"cancelLocalNotifications"},
Method<void(React::JSValueObject) noexcept>{9, L"cancelLocalNotifications"},
Method<void(Promise<React::JSValue>) noexcept>{10, L"getInitialNotification"},
Method<void(Callback<JSValue>) noexcept>{11, L"getScheduledLocalNotifications"},
Method<void(Callback<React::JSValue>) noexcept>{11, L"getScheduledLocalNotifications"},
Method<void() noexcept>{12, L"removeAllDeliveredNotifications"},
Method<void(JSValueArray) noexcept>{13, L"removeDeliveredNotifications"},
Method<void(Callback<JSValue>) noexcept>{14, L"getDeliveredNotifications"},
Method<void(React::JSValueArray) noexcept>{13, L"removeDeliveredNotifications"},
Method<void(Callback<React::JSValue>) noexcept>{14, L"getDeliveredNotifications"},
Method<void(std::string) noexcept>{15, L"addListener"},
Method<void(double) noexcept>{16, L"removeListeners"},
};

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct RedBoxSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, std::string) noexcept>{0, L"setExtraData"},
Method<void(React::JSValueObject, std::string) noexcept>{0, L"setExtraData"},
Method<void() noexcept>{1, L"dismiss"},
};

Просмотреть файл

@ -19,10 +19,10 @@ struct SampleTurboModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
SyncMethod<bool(bool) noexcept>{1, L"getBool"},
SyncMethod<double(double) noexcept>{2, L"getNumber"},
SyncMethod<std::string(std::string) noexcept>{3, L"getString"},
SyncMethod<JSValueArray(JSValueArray) noexcept>{4, L"getArray"},
SyncMethod<JSValueObject(JSValueObject) noexcept>{5, L"getObject"},
SyncMethod<JSValueObject(double, std::string, JSValueObject) noexcept>{6, L"getValue"},
Method<void(Callback<JSValue>) noexcept>{7, L"getValueWithCallback"},
SyncMethod<React::JSValueArray(React::JSValueArray) noexcept>{4, L"getArray"},
SyncMethod<React::JSValueObject(React::JSValueObject) noexcept>{5, L"getObject"},
SyncMethod<React::JSValueObject(double, std::string, React::JSValueObject) noexcept>{6, L"getValue"},
Method<void(Callback<React::JSValue>) noexcept>{7, L"getValueWithCallback"},
Method<void(bool, Promise<React::JSValue>) noexcept>{8, L"getValueWithPromise"},
};

Просмотреть файл

@ -15,8 +15,8 @@ namespace Microsoft::ReactNativeSpecs {
struct SegmentFetcherSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(double, JSValueObject, Callback<JSValue>) noexcept>{0, L"fetchSegment"},
Method<void(double, JSValueObject, Callback<JSValue>) noexcept>{1, L"getSegment"},
Method<void(double, React::JSValueObject, Callback<React::JSValue>) noexcept>{0, L"fetchSegment"},
Method<void(double, React::JSValueObject, Callback<React::JSValue>) noexcept>{1, L"getSegment"},
};
template <class TModule>

Просмотреть файл

@ -15,8 +15,8 @@ namespace Microsoft::ReactNativeSpecs {
struct SettingsManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject) noexcept>{0, L"setValues"},
Method<void(JSValueArray) noexcept>{1, L"deleteValues"},
Method<void(React::JSValueObject) noexcept>{0, L"setValues"},
Method<void(React::JSValueArray) noexcept>{1, L"deleteValues"},
};
template <class TModule>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct ShareModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, std::string, Promise<React::JSValue>) noexcept>{0, L"share"},
Method<void(React::JSValueObject, std::string, Promise<React::JSValue>) noexcept>{0, L"share"},
};
template <class TModule>

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct StatusBarManagerAndroid.windowsSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(JSValueObject, bool) noexcept>{0, L"setColor"},
Method<void(React::JSValueObject, bool) noexcept>{0, L"setColor"},
Method<void(bool) noexcept>{1, L"setTranslucent"},
Method<void(std::string) noexcept>{2, L"setStyle"},
Method<void(bool) noexcept>{3, L"setHidden"},

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct StatusBarManagerIOSSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(Callback<JSValue>) noexcept>{0, L"getHeight"},
Method<void(Callback<React::JSValue>) noexcept>{0, L"getHeight"},
Method<void(bool) noexcept>{1, L"setNetworkActivityIndicatorVisible"},
Method<void(std::string) noexcept>{2, L"addListener"},
Method<void(double) noexcept>{3, L"removeListeners"},

Просмотреть файл

@ -15,31 +15,31 @@ namespace Microsoft::ReactNativeSpecs {
struct UIManagerSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
SyncMethod<JSValueObject(std::string) noexcept>{0, L"getConstantsForViewManager"},
SyncMethod<JSValueArray() noexcept>{1, L"getDefaultEventTypes"},
SyncMethod<React::JSValueObject(std::string) noexcept>{0, L"getConstantsForViewManager"},
SyncMethod<React::JSValueArray() noexcept>{1, L"getDefaultEventTypes"},
Method<void() noexcept>{2, L"playTouchSound"},
SyncMethod<JSValueObject(std::string) noexcept>{3, L"lazilyLoadView"},
Method<void(double, std::string, double, JSValueObject) noexcept>{4, L"createView"},
Method<void(double, std::string, JSValueObject) noexcept>{5, L"updateView"},
SyncMethod<React::JSValueObject(std::string) noexcept>{3, L"lazilyLoadView"},
Method<void(double, std::string, double, React::JSValueObject) noexcept>{4, L"createView"},
Method<void(double, std::string, React::JSValueObject) noexcept>{5, L"updateView"},
Method<void(double) noexcept>{6, L"focus"},
Method<void(double) noexcept>{7, L"blur"},
Method<void(double, JSValueArray, Callback<JSValue>) noexcept>{8, L"findSubviewIn"},
Method<void(double, double, JSValueArray) noexcept>{9, L"dispatchViewManagerCommand"},
Method<void(double, Callback<JSValue>) noexcept>{10, L"measure"},
Method<void(double, Callback<JSValue>) noexcept>{11, L"measureInWindow"},
Method<void(double, double, Callback<JSValue>) noexcept>{12, L"viewIsDescendantOf"},
Method<void(double, double, Callback<JSValue>, Callback<JSValue>) noexcept>{13, L"measureLayout"},
Method<void(double, Callback<JSValue>, Callback<JSValue>) noexcept>{14, L"measureLayoutRelativeToParent"},
Method<void(double, React::JSValueArray, Callback<React::JSValue>) noexcept>{8, L"findSubviewIn"},
Method<void(double, double, React::JSValueArray) noexcept>{9, L"dispatchViewManagerCommand"},
Method<void(double, Callback<React::JSValue>) noexcept>{10, L"measure"},
Method<void(double, Callback<React::JSValue>) noexcept>{11, L"measureInWindow"},
Method<void(double, double, Callback<React::JSValue>) noexcept>{12, L"viewIsDescendantOf"},
Method<void(double, double, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{13, L"measureLayout"},
Method<void(double, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{14, L"measureLayoutRelativeToParent"},
Method<void(double, bool) noexcept>{15, L"setJSResponder"},
Method<void() noexcept>{16, L"clearJSResponder"},
Method<void(JSValueObject, Callback<JSValue>, Callback<JSValue>) noexcept>{17, L"configureNextLayoutAnimation"},
Method<void(React::JSValueObject, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{17, L"configureNextLayoutAnimation"},
Method<void(double) noexcept>{18, L"removeSubviewsFromContainerWithID"},
Method<void(double, double) noexcept>{19, L"replaceExistingNonRootView"},
Method<void(double, JSValueArray) noexcept>{20, L"setChildren"},
Method<void(double, JSValueArray, JSValueArray, JSValueArray, JSValueArray, JSValueArray) noexcept>{21, L"manageChildren"},
Method<void(double, React::JSValueArray) noexcept>{20, L"setChildren"},
Method<void(double, React::JSValueArray, React::JSValueArray, React::JSValueArray, React::JSValueArray, React::JSValueArray) noexcept>{21, L"manageChildren"},
Method<void(bool) noexcept>{22, L"setLayoutAnimationEnabledExperimental"},
Method<void(double, double) noexcept>{23, L"sendAccessibilityEvent"},
Method<void(double, JSValueArray, Callback<JSValue>, Callback<JSValue>) noexcept>{24, L"showPopupMenu"},
Method<void(double, React::JSValueArray, Callback<React::JSValue>, Callback<React::JSValue>) noexcept>{24, L"showPopupMenu"},
Method<void() noexcept>{25, L"dismissPopupMenu"},
};

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft::ReactNativeSpecs {
struct VibrationSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(double) noexcept>{0, L"vibrate"},
Method<void(JSValueArray, double) noexcept>{1, L"vibrateByPattern"},
Method<void(React::JSValueArray, double) noexcept>{1, L"vibrateByPattern"},
Method<void() noexcept>{2, L"cancel"},
};

Просмотреть файл

@ -15,7 +15,7 @@ namespace Microsoft::ReactNativeSpecs {
struct WebSocketModuleSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{
Method<void(std::string, JSValueArray, JSValueObject, double) noexcept>{0, L"connect"},
Method<void(std::string, React::JSValueArray, React::JSValueObject, double) noexcept>{0, L"connect"},
Method<void(std::string, double) noexcept>{1, L"send"},
Method<void(std::string, double) noexcept>{2, L"sendBinary"},
Method<void(double) noexcept>{3, L"ping"},

Просмотреть файл

@ -1,15 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <winrt/react.uwp.h>
namespace facebook::react {
class Instance;
}
namespace react::uwp {
extern std::shared_ptr<facebook::react::Instance> __cdecl GetReactInstanceFromUwpInstance(
const winrt::react::uwp::Instance &uwpInstance);
}