react-native-windows 0.78.4 → 0.78.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Directory.Build.props +6 -4
- package/Folly/Folly.vcxproj +46 -6
- package/Folly/Folly.vcxproj.filters +16 -4
- package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +26 -18
- package/Folly/TEMP_UntilFollyUpdate/Conv.cpp +1205 -0
- package/Folly/TEMP_UntilFollyUpdate/chrono/Hardware.h +155 -0
- package/Folly/TEMP_UntilFollyUpdate/concurrency/CacheLocality.cpp +633 -0
- package/Folly/TEMP_UntilFollyUpdate/{dynamic-inl.h → json/dynamic-inl.h} +3 -4
- package/Folly/TEMP_UntilFollyUpdate/{json.cpp → json/json.cpp} +14 -10
- package/Folly/TEMP_UntilFollyUpdate/lang/SafeAssert.h +7 -14
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +6 -6
- package/Folly/ThreadNameStub.cpp +10 -0
- package/Folly/cgmanifest.json +11 -1
- package/Libraries/Components/View/View.windows.js +107 -56
- package/Libraries/Components/View/ViewAccessibility.d.ts +60 -1
- package/Libraries/Image/Image.windows.js +42 -21
- package/Libraries/Modal/Modal.d.ts +7 -0
- package/Libraries/Modal/Modal.windows.js +7 -1
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +3 -0
- package/Libraries/Text/Text.d.ts +18 -0
- package/Microsoft.ReactNative/AsynchronousEventBeat.cpp +4 -25
- package/Microsoft.ReactNative/AsynchronousEventBeat.h +0 -3
- package/Microsoft.ReactNative/Base/FollyIncludes.h +1 -0
- package/Microsoft.ReactNative/CallInvoker.cpp +42 -0
- package/Microsoft.ReactNative/CallInvoker.h +34 -0
- package/Microsoft.ReactNative/{JSDispatcherWriter.cpp → CallInvokerWriter.cpp} +35 -47
- package/Microsoft.ReactNative/CallInvokerWriter.h +74 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +0 -5
- package/Microsoft.ReactNative/CompositionSwitcher.idl +7 -0
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +12 -2
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.cpp +100 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.h +31 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +77 -11
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +43 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +7 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +86 -56
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +0 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +0 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +118 -63
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -8
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +16 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +34 -11
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +133 -135
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +9 -6
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +46 -49
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +6 -1
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +13 -8
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +146 -25
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +14 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +160 -12
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +6 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.cpp +47 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.h +15 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +6 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +7 -9
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +40 -36
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +68 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +11 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +70 -13
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +10 -2
- package/Microsoft.ReactNative/Fabric/ImageManager.cpp +5 -5
- package/Microsoft.ReactNative/Fabric/ImageRequestParams.cpp +26 -0
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +47 -8
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +10 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/CompositionAccessibilityProps.h +67 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +22 -4
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +15 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +20 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/MouseEvent.h +20 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +247 -45
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +15 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.cpp +39 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.h +54 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +126 -0
- package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +73 -0
- package/Microsoft.ReactNative/IReactContext.cpp +17 -0
- package/Microsoft.ReactNative/IReactContext.h +1 -0
- package/Microsoft.ReactNative/IReactContext.idl +18 -1
- package/Microsoft.ReactNative/IReactDispatcher.idl +1 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.cpp +12 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.h +2 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.idl +8 -0
- package/Microsoft.ReactNative/JsiApi.cpp +10 -2
- package/Microsoft.ReactNative/JsiApi.h +1 -0
- package/Microsoft.ReactNative/JsiApi.idl +1 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -3
- package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +2 -3
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +7 -12
- package/Microsoft.ReactNative/Modules/Animated/AnimationDriver.cpp +2 -1
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedModule.cpp +4 -8
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +6 -8
- package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +6 -15
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +13 -24
- package/Microsoft.ReactNative/QuirkSettings.cpp +0 -16
- package/Microsoft.ReactNative/QuirkSettings.h +0 -3
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +11 -1
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +78 -68
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -2
- package/Microsoft.ReactNative/ReactInstanceSettings.cpp +12 -0
- package/Microsoft.ReactNative/ReactInstanceSettings.h +2 -0
- package/Microsoft.ReactNative/ReactInstanceSettings.idl +6 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -0
- package/Microsoft.ReactNative/ReactSupport.cpp +44 -11
- package/Microsoft.ReactNative/RedBox.cpp +30 -1
- package/Microsoft.ReactNative/SchedulerSettings.cpp +4 -4
- package/Microsoft.ReactNative/SchedulerSettings.h +1 -1
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +30 -12
- package/Microsoft.ReactNative/Utils/ImageUtils.h +1 -0
- package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +37 -31
- package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +1 -0
- package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +2 -0
- package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +94 -27
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +27 -6
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.cpp +45 -11
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h +6 -0
- package/Microsoft.ReactNative.Cxx/JSI/decorator.h +220 -0
- package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +28 -0
- package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +6 -0
- package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +241 -4
- package/Microsoft.ReactNative.Cxx/JSI/jsi.h +207 -19
- package/Microsoft.ReactNative.Cxx/JSValue.cpp +19 -3
- package/Microsoft.ReactNative.Cxx/JSValue.h +15 -7
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
- package/Microsoft.ReactNative.Cxx/NativeModules.h +60 -2
- package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +1267 -614
- package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +4 -2
- package/Microsoft.ReactNative.Cxx/ReactContext.h +7 -0
- package/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +11 -13
- package/Microsoft.ReactNative.Cxx/TurboModuleProvider.h +2 -3
- package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +81 -20
- package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +47 -2
- package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +13 -0
- package/Microsoft.ReactNative.Cxx/stubs/glog/logging.h +1 -1
- package/Microsoft.ReactNative.Managed/ReactContext.cs +3 -1
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/React.Cpp.props +2 -1
- package/PropertySheets/WebView2.props +1 -1
- package/PropertySheets/WinUI.props +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +429 -0
- package/ReactCommon/cgmanifest.json +1 -1
- package/Shared/HermesRuntimeHolder.cpp +6 -0
- package/Shared/JSI/ChakraRuntime.cpp +4 -0
- package/Shared/JSI/ChakraRuntime.h +2 -0
- package/Shared/Modules/BlobModule.cpp +14 -16
- package/Shared/Modules/BlobModule.h +3 -1
- package/Shared/Networking/WinRTWebSocketResource.cpp +82 -101
- package/Shared/Networking/WinRTWebSocketResource.h +91 -7
- package/Shared/Shared.vcxitems +11 -7
- package/Shared/Shared.vcxitems.filters +6 -1
- package/Shared/TurboModuleManager.cpp +0 -15
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +6 -6
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +6 -6
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +6 -6
- package/codegen/react/components/rnwcore/InputAccessory.g.h +6 -6
- package/codegen/react/components/rnwcore/ModalHostView.g.h +11 -7
- package/codegen/react/components/rnwcore/Props.cpp +2 -1
- package/codegen/react/components/rnwcore/Props.h +1 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +6 -6
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +6 -6
- package/codegen/react/components/rnwcore/Switch.g.h +6 -6
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +6 -6
- package/index.windows.js +4 -2
- package/package.json +3 -4
- package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
- package/stubs/glog/logging.h +1 -1
- package/Microsoft.ReactNative/JSDispatcherWriter.h +0 -47
- package/Microsoft.ReactNative/SynchronousEventBeat.cpp +0 -51
- package/Microsoft.ReactNative/SynchronousEventBeat.h +0 -31
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// [Windows] Brought forward from react-native - switch to using react-native/ReactCxxPlatform/react/threading version
|
|
9
|
+
// once we integrate that far
|
|
10
|
+
|
|
11
|
+
#include "TaskDispatchThread.h"
|
|
12
|
+
|
|
13
|
+
#include <folly/portability/SysResource.h>
|
|
14
|
+
#include <folly/system/ThreadName.h>
|
|
15
|
+
#include <chrono>
|
|
16
|
+
#include <future>
|
|
17
|
+
#include <utility>
|
|
18
|
+
|
|
19
|
+
#include <glog/logging.h>
|
|
20
|
+
|
|
21
|
+
#ifdef ANDROID
|
|
22
|
+
#include <fbjni/fbjni.h>
|
|
23
|
+
#include <sys/syscall.h>
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace facebook::react {
|
|
27
|
+
|
|
28
|
+
TaskDispatchThread::TaskDispatchThread(std::string threadName, int priorityOffset) noexcept
|
|
29
|
+
: threadName_(std::move(threadName)) {
|
|
30
|
+
#ifdef ANDROID
|
|
31
|
+
// Attaches the thread to JVM just in case anything calls out to Java
|
|
32
|
+
thread_ = std::thread([&]() {
|
|
33
|
+
facebook::jni::ThreadScope::WithClassLoader([&]() {
|
|
34
|
+
int result = setpriority(PRIO_PROCESS, static_cast<pid_t>(::syscall(SYS_gettid)), priorityOffset);
|
|
35
|
+
|
|
36
|
+
if (result != 0) {
|
|
37
|
+
LOG(INFO) << " setCurrentThreadPriority failed with pri errno: " << errno;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
loop();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
#else
|
|
45
|
+
thread_ = std::thread(&TaskDispatchThread::loop, this);
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
TaskDispatchThread::~TaskDispatchThread() noexcept {
|
|
50
|
+
quit();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
bool TaskDispatchThread::isOnThread() noexcept {
|
|
54
|
+
return std::this_thread::get_id() == thread_.get_id();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bool TaskDispatchThread::isRunning() noexcept {
|
|
58
|
+
return running_;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void TaskDispatchThread::runAsync(TaskFn &&task, std::chrono::milliseconds delayMs) noexcept {
|
|
62
|
+
if (!running_) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
std::lock_guard<std::mutex> guard(queueLock_);
|
|
66
|
+
auto dispatchTime = std::chrono::system_clock::now() + delayMs;
|
|
67
|
+
queue_.emplace(dispatchTime, std::move(task));
|
|
68
|
+
loopCv_.notify_one();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void TaskDispatchThread::runSync(TaskFn &&task) noexcept {
|
|
72
|
+
std::promise<void> promise;
|
|
73
|
+
runAsync([&]() {
|
|
74
|
+
if (running_) {
|
|
75
|
+
task();
|
|
76
|
+
}
|
|
77
|
+
promise.set_value();
|
|
78
|
+
});
|
|
79
|
+
promise.get_future().wait();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void TaskDispatchThread::quit() noexcept {
|
|
83
|
+
if (!running_) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
running_ = false;
|
|
87
|
+
loopCv_.notify_one();
|
|
88
|
+
if (thread_.joinable()) {
|
|
89
|
+
if (!isOnThread()) {
|
|
90
|
+
thread_.join();
|
|
91
|
+
} else {
|
|
92
|
+
thread_.detach();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void TaskDispatchThread::loop() noexcept {
|
|
98
|
+
if (!threadName_.empty()) {
|
|
99
|
+
folly::setThreadName(threadName_);
|
|
100
|
+
}
|
|
101
|
+
while (running_) {
|
|
102
|
+
std::unique_lock<std::mutex> lock(queueLock_);
|
|
103
|
+
loopCv_.wait(lock, [&]() { return !running_ || !queue_.empty(); });
|
|
104
|
+
while (!queue_.empty()) {
|
|
105
|
+
auto task = queue_.top();
|
|
106
|
+
auto now = std::chrono::system_clock::now();
|
|
107
|
+
if (task.dispatchTime > now) {
|
|
108
|
+
if (running_) {
|
|
109
|
+
loopCv_.wait_until(lock, task.dispatchTime);
|
|
110
|
+
} else {
|
|
111
|
+
// Shutting down, skip all the delayed tasks that are not to be
|
|
112
|
+
// executed yet
|
|
113
|
+
queue_.pop();
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
queue_.pop();
|
|
119
|
+
lock.unlock();
|
|
120
|
+
task.fn();
|
|
121
|
+
lock.lock();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// [Windows] Brought forward from react-native - switch to using react-native/ReactCxxPlatform/react/threading version
|
|
9
|
+
// once we integrate that far
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <chrono>
|
|
14
|
+
#include <condition_variable>
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <mutex>
|
|
17
|
+
#include <queue>
|
|
18
|
+
#include <thread>
|
|
19
|
+
|
|
20
|
+
namespace facebook::react {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Representation of a thread looper which can add tasks to a queue and handle
|
|
24
|
+
* the synchronization of callers.
|
|
25
|
+
*/
|
|
26
|
+
class TaskDispatchThread {
|
|
27
|
+
public:
|
|
28
|
+
using TaskFn = std::function<void()>;
|
|
29
|
+
using TimePoint = std::chrono::time_point<std::chrono::system_clock>;
|
|
30
|
+
|
|
31
|
+
TaskDispatchThread(std::string threadName = "", int priorityOffset = 0) noexcept;
|
|
32
|
+
|
|
33
|
+
~TaskDispatchThread() noexcept;
|
|
34
|
+
|
|
35
|
+
/** Return true if the current thread is the same as this looper's thread. */
|
|
36
|
+
bool isOnThread() noexcept;
|
|
37
|
+
|
|
38
|
+
/** Return true until TaskDispatchThread.quit() is called */
|
|
39
|
+
bool isRunning() noexcept;
|
|
40
|
+
|
|
41
|
+
/** Add task to the queue and return immediately. */
|
|
42
|
+
void runAsync(TaskFn &&task, std::chrono::milliseconds delayMs = std::chrono::milliseconds::zero()) noexcept;
|
|
43
|
+
|
|
44
|
+
/** Add task to the queue and wait until it has completed. */
|
|
45
|
+
void runSync(TaskFn &&task) noexcept;
|
|
46
|
+
|
|
47
|
+
/** Shut down and clean up the thread. */
|
|
48
|
+
void quit() noexcept;
|
|
49
|
+
|
|
50
|
+
protected:
|
|
51
|
+
struct Task {
|
|
52
|
+
TimePoint dispatchTime;
|
|
53
|
+
TaskFn fn;
|
|
54
|
+
|
|
55
|
+
Task(TimePoint dispatchTime, TaskFn &&fn) : dispatchTime(dispatchTime), fn(std::move(fn)) {}
|
|
56
|
+
|
|
57
|
+
bool operator<(const Task &other) const {
|
|
58
|
+
// Have the earliest tasks be at the front of the queue.
|
|
59
|
+
return dispatchTime > other.dispatchTime;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
void loop() noexcept;
|
|
64
|
+
|
|
65
|
+
std::mutex queueLock_;
|
|
66
|
+
std::condition_variable loopCv_;
|
|
67
|
+
std::priority_queue<Task> queue_;
|
|
68
|
+
std::atomic<bool> running_{true};
|
|
69
|
+
std::string threadName_;
|
|
70
|
+
std::thread thread_;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace facebook::react
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
#include "XamlUIService.h"
|
|
9
9
|
#endif
|
|
10
10
|
|
|
11
|
+
#include "CallInvoker.h"
|
|
12
|
+
#include "Utils/Helpers.h"
|
|
13
|
+
|
|
11
14
|
namespace winrt::Microsoft::ReactNative::implementation {
|
|
12
15
|
|
|
13
16
|
//=============================================================================
|
|
@@ -97,10 +100,24 @@ IReactDispatcher ReactContext::UIDispatcher() noexcept {
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
IReactDispatcher ReactContext::JSDispatcher() noexcept {
|
|
103
|
+
#if defined(DEBUG) && defined(USE_FABRIC)
|
|
104
|
+
VerifyElseCrashSz(
|
|
105
|
+
!::Microsoft::ReactNative::IsFabricEnabled(Properties()),
|
|
106
|
+
"ReactContext.JSRuntime is not supported on new arch, use ReactContext.CallInvoker instead.");
|
|
107
|
+
#endif
|
|
100
108
|
return Properties().Get(ReactDispatcherHelper::JSDispatcherProperty()).try_as<IReactDispatcher>();
|
|
101
109
|
}
|
|
102
110
|
|
|
111
|
+
winrt::Microsoft::ReactNative::CallInvoker ReactContext::CallInvoker() noexcept {
|
|
112
|
+
return winrt::Microsoft::ReactNative::implementation::CallInvoker::FromProperties(ReactPropertyBag(Properties()));
|
|
113
|
+
}
|
|
114
|
+
|
|
103
115
|
winrt::Windows::Foundation::IInspectable ReactContext::JSRuntime() noexcept {
|
|
116
|
+
#if defined(DEBUG) && defined(USE_FABRIC)
|
|
117
|
+
VerifyElseCrashSz(
|
|
118
|
+
!::Microsoft::ReactNative::IsFabricEnabled(Properties()),
|
|
119
|
+
"ReactContext.JSRuntime is not supported on new arch, use ReactContext.CallInvoker instead.");
|
|
120
|
+
#endif
|
|
104
121
|
return m_context->JsiRuntime();
|
|
105
122
|
}
|
|
106
123
|
|
|
@@ -43,6 +43,7 @@ struct ReactContext : winrt::implements<ReactContext, IReactContext> {
|
|
|
43
43
|
IReactNotificationService Notifications() noexcept;
|
|
44
44
|
IReactDispatcher UIDispatcher() noexcept;
|
|
45
45
|
IReactDispatcher JSDispatcher() noexcept;
|
|
46
|
+
winrt::Microsoft::ReactNative::CallInvoker CallInvoker() noexcept;
|
|
46
47
|
IInspectable JSRuntime() noexcept;
|
|
47
48
|
LoadingState LoadingState() noexcept;
|
|
48
49
|
|
|
@@ -14,6 +14,18 @@ import "IReactPropertyBag.idl";
|
|
|
14
14
|
namespace Microsoft.ReactNative
|
|
15
15
|
{
|
|
16
16
|
|
|
17
|
+
DOC_STRING("Function that acts on a JsiRuntime, provided as the argument to the function. ABI safe version of facebook::react::CallFunc in CallInvoker.h. Most direct usage of this should be avoided by using ReactContext.CallInvoker.")
|
|
18
|
+
delegate void CallFunc(Object runtime);
|
|
19
|
+
|
|
20
|
+
[webhosthidden]
|
|
21
|
+
[default_interface]
|
|
22
|
+
DOC_STRING("CallInvoker used to access the jsi runtime. Most direct usage of this should be avoided by using ReactContext.CallInvoker.")
|
|
23
|
+
runtimeclass CallInvoker
|
|
24
|
+
{
|
|
25
|
+
void InvokeAsync(CallFunc func);
|
|
26
|
+
void InvokeSync(CallFunc func);
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
DOC_STRING(
|
|
18
30
|
"Used to represent the state of the React Native JavaScript instance")
|
|
19
31
|
enum LoadingState
|
|
@@ -173,6 +185,7 @@ namespace Microsoft.ReactNative
|
|
|
173
185
|
"It is a shortcut for the @ReactDispatcherHelper.UIDispatcherProperty from the @.Properties property bag.")
|
|
174
186
|
IReactDispatcher UIDispatcher { get; };
|
|
175
187
|
|
|
188
|
+
[deprecated("Use @IReactContext.CallInvoker instead", deprecate, 1)]
|
|
176
189
|
DOC_STRING(
|
|
177
190
|
"Gets the JavaScript engine thread dispatcher.\n"
|
|
178
191
|
"It is a shortcut for the @ReactDispatcherHelper.JSDispatcherProperty from the @.Properties property bag.")
|
|
@@ -182,9 +195,13 @@ namespace Microsoft.ReactNative
|
|
|
182
195
|
"Gets the JavaScript runtime for the running React instance.\n"
|
|
183
196
|
"It can be null if Web debugging is used.\n"
|
|
184
197
|
"**Note: do not use this property directly. "
|
|
185
|
-
"It is an experimental property
|
|
198
|
+
"It is an experimental property will be removed in a future version.\n"
|
|
199
|
+
"Deprecated for new Arch: Use @IReactContext.CallInvoker instead.")
|
|
186
200
|
Object JSRuntime { get; };
|
|
187
201
|
|
|
202
|
+
DOC_STRING("used to schedule work on the JS runtime. Most direct usage of this should be avoided by using ReactContext.CallInvoker.")
|
|
203
|
+
CallInvoker CallInvoker { get; };
|
|
204
|
+
|
|
188
205
|
#if !defined(CORE_ABI) && !defined(USE_FABRIC)
|
|
189
206
|
[deprecated("Use @XamlUIService.DispatchEvent instead", deprecate, 1)]
|
|
190
207
|
DOC_STRING("Deprecated property. Use @XamlUIService.DispatchEvent instead. It will be removed in a future version.")
|
|
@@ -48,6 +48,7 @@ namespace Microsoft.ReactNative
|
|
|
48
48
|
"a specific React instance.")
|
|
49
49
|
static IReactPropertyName UIDispatcherProperty { get; };
|
|
50
50
|
|
|
51
|
+
[deprecated("Use @IReactContext.CallInvoker instead", deprecate, 1)]
|
|
51
52
|
DOC_STRING(
|
|
52
53
|
"Gets name of the `JSDispatcher` property for the @IReactPropertyBag.\n"
|
|
53
54
|
"Generally you can use @IReactContext.JSDispatcher to get the value of this property for "
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#include "pch.h"
|
|
5
5
|
#include "IReactModuleBuilder.h"
|
|
6
|
+
#include <IReactContext.h>
|
|
6
7
|
#include <strsafe.h>
|
|
7
8
|
#include "DynamicWriter.h"
|
|
8
9
|
#include "ReactHost/MsoUtils.h"
|
|
@@ -74,6 +75,10 @@ void ReactModuleBuilder::AddInitializer(InitializerDelegate const &initializer)
|
|
|
74
75
|
m_initializers.push_back(initializer);
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
void ReactModuleBuilder::AddJsiInitializer(JsiInitializerDelegate const &initializer) noexcept {
|
|
79
|
+
m_jsiinitializers.push_back(initializer);
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
void ReactModuleBuilder::AddConstantProvider(ConstantProviderDelegate const &constantProvider) noexcept {
|
|
78
83
|
m_constantProviders.push_back(constantProvider);
|
|
79
84
|
}
|
|
@@ -155,6 +160,13 @@ std::unique_ptr<CxxModule> ReactModuleBuilder::MakeCxxModule(
|
|
|
155
160
|
for (auto &initializer : m_initializers) {
|
|
156
161
|
initializer(m_reactContext);
|
|
157
162
|
}
|
|
163
|
+
for (auto &initializer : m_jsiinitializers) {
|
|
164
|
+
initializer(
|
|
165
|
+
m_reactContext,
|
|
166
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactContext>(m_reactContext)
|
|
167
|
+
->GetInner()
|
|
168
|
+
.JsiRuntime());
|
|
169
|
+
}
|
|
158
170
|
return std::make_unique<ABICxxModule>(
|
|
159
171
|
nativeModule, Mso::Copy(name), Mso::Copy(m_constantProviders), Mso::Copy(m_methods));
|
|
160
172
|
}
|
|
@@ -12,6 +12,7 @@ struct ReactModuleBuilder : winrt::implements<ReactModuleBuilder, IReactModuleBu
|
|
|
12
12
|
|
|
13
13
|
public: // IReactModuleBuilder
|
|
14
14
|
void AddInitializer(InitializerDelegate const &initializer) noexcept;
|
|
15
|
+
void AddJsiInitializer(JsiInitializerDelegate const &initializer) noexcept;
|
|
15
16
|
void AddConstantProvider(ConstantProviderDelegate const &constantProvider) noexcept;
|
|
16
17
|
void AddMethod(hstring const &name, MethodReturnType returnType, MethodDelegate const &method) noexcept;
|
|
17
18
|
void AddSyncMethod(hstring const &name, SyncMethodDelegate const &method) noexcept;
|
|
@@ -29,6 +30,7 @@ struct ReactModuleBuilder : winrt::implements<ReactModuleBuilder, IReactModuleBu
|
|
|
29
30
|
private:
|
|
30
31
|
IReactContext m_reactContext;
|
|
31
32
|
std::vector<InitializerDelegate> m_initializers;
|
|
33
|
+
std::vector<JsiInitializerDelegate> m_jsiinitializers;
|
|
32
34
|
std::vector<ConstantProviderDelegate> m_constantProviders;
|
|
33
35
|
std::vector<facebook::xplat::module::CxxModule::Method> m_methods;
|
|
34
36
|
};
|
|
@@ -15,6 +15,12 @@ namespace Microsoft.ReactNative
|
|
|
15
15
|
"Experimental code uses it to initialize TurboModule `CallInvoker`.")
|
|
16
16
|
delegate void InitializerDelegate(IReactContext reactContext);
|
|
17
17
|
|
|
18
|
+
DOC_STRING(
|
|
19
|
+
"A delegate that sets `reactContext` for a module.\n"
|
|
20
|
+
"We use it for a stand-alone initialize method, strongly typed JS events and functions.\n"
|
|
21
|
+
"Experimental code uses it to initialize TurboModule `CallInvoker`.")
|
|
22
|
+
delegate void JsiInitializerDelegate(IReactContext reactContext, Object runtimeHandle);
|
|
23
|
+
|
|
18
24
|
DOC_STRING("Native method return type.")
|
|
19
25
|
enum MethodReturnType
|
|
20
26
|
{
|
|
@@ -59,6 +65,8 @@ namespace Microsoft.ReactNative
|
|
|
59
65
|
"There can be multiple initializer methods which are called in the order they were registered.")
|
|
60
66
|
void AddInitializer(InitializerDelegate initializer);
|
|
61
67
|
|
|
68
|
+
void AddJsiInitializer(JsiInitializerDelegate initializer);
|
|
69
|
+
|
|
62
70
|
DOC_STRING(
|
|
63
71
|
"Adds a constant provider method to define constants for the native module. See @ConstantProviderDelegate.")
|
|
64
72
|
void AddConstantProvider(ConstantProviderDelegate constantProvider);
|
|
@@ -482,8 +482,8 @@ facebook::jsi::JSError const &jsError) { \
|
|
|
482
482
|
jsiRuntime->evaluateJavaScript(jsiPalBuffer, "Form_JSI_API_not_a_real_file");
|
|
483
483
|
ReactNative::JsiRuntime abiJsiResult{make<JsiRuntime>(Mso::Copy(jsiRuntimeHolder), Mso::Copy(jsiRuntime))};
|
|
484
484
|
std::scoped_lock lock{s_mutex};
|
|
485
|
-
s_jsiRuntimeMap.try_emplace(reinterpret_cast<uintptr_t>(jsiRuntime.get()), abiJsiResult);
|
|
486
|
-
return
|
|
485
|
+
auto it = s_jsiRuntimeMap.try_emplace(reinterpret_cast<uintptr_t>(jsiRuntime.get()), abiJsiResult);
|
|
486
|
+
return it.first->second.get();
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
ReactNative::JsiRuntime JsiRuntime::MakeChakraRuntime() {
|
|
@@ -553,6 +553,14 @@ bool JsiRuntime::DrainMicrotasks(int32_t maxMicrotasksHint) try {
|
|
|
553
553
|
throw;
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
+
void JsiRuntime::QueueMicrotask(JsiObjectRef callback) try {
|
|
557
|
+
auto funcPtr = RuntimeAccessor::AsPointerValue(callback);
|
|
558
|
+
auto const &jsiFunc = RuntimeAccessor::AsFunction(&funcPtr);
|
|
559
|
+
m_runtimeAccessor->queueMicrotask(jsiFunc);
|
|
560
|
+
} catch (JSI_SET_ERROR) {
|
|
561
|
+
throw;
|
|
562
|
+
}
|
|
563
|
+
|
|
556
564
|
JsiObjectRef JsiRuntime::Global() try {
|
|
557
565
|
return PointerAccessor::MakeJsiObjectData(m_runtimeAccessor->global());
|
|
558
566
|
} catch (JSI_SET_ERROR) {
|
|
@@ -77,6 +77,7 @@ struct JsiRuntime : JsiRuntimeT<JsiRuntime> {
|
|
|
77
77
|
ReactNative::JsiPreparedJavaScript PrepareJavaScript(IJsiByteBuffer const &buffer, hstring const &sourceUrl);
|
|
78
78
|
JsiValueRef EvaluatePreparedJavaScript(ReactNative::JsiPreparedJavaScript const &js);
|
|
79
79
|
bool DrainMicrotasks(int32_t maxMicrotasksHint);
|
|
80
|
+
void QueueMicrotask(JsiObjectRef callback);
|
|
80
81
|
JsiObjectRef Global();
|
|
81
82
|
hstring Description();
|
|
82
83
|
bool IsInspectable();
|
|
@@ -249,6 +249,7 @@ namespace Microsoft.ReactNative
|
|
|
249
249
|
JsiPreparedJavaScript PrepareJavaScript(IJsiByteBuffer buffer, String sourceUrl);
|
|
250
250
|
JsiValueRef EvaluatePreparedJavaScript(JsiPreparedJavaScript js);
|
|
251
251
|
Boolean DrainMicrotasks(Int32 maxMicrotasksHint);
|
|
252
|
+
void QueueMicrotask(JsiObjectRef callback);
|
|
252
253
|
JsiObjectRef Global { get; };
|
|
253
254
|
String Description { get; };
|
|
254
255
|
Boolean IsInspectable { get; };
|
|
@@ -200,9 +200,6 @@
|
|
|
200
200
|
<ClInclude Include="DynamicWriter.h">
|
|
201
201
|
<DependentUpon>IJSValueWriter.idl</DependentUpon>
|
|
202
202
|
</ClInclude>
|
|
203
|
-
<ClInclude Include="JSDispatcherWriter.h">
|
|
204
|
-
<DependentUpon>IJSValueWriter.idl</DependentUpon>
|
|
205
|
-
</ClInclude>
|
|
206
203
|
<ClInclude Include="HResult.h" />
|
|
207
204
|
<ClInclude Include="IReactDispatcher.h">
|
|
208
205
|
<DependentUpon>IReactDispatcher.idl</DependentUpon>
|
|
@@ -22,12 +22,11 @@ void AccessibilityInfo::Initialize(winrt::Microsoft::ReactNative::ReactContext c
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
void AccessibilityInfo::isReduceMotionEnabled(std::function<void(bool)> const &onSuccess) noexcept {
|
|
25
|
-
|
|
26
|
-
m_context.UIDispatcher().Post([weakThis = weak_from_this(), jsDispatcher, onSuccess] {
|
|
25
|
+
m_context.UIDispatcher().Post([weakThis = weak_from_this(), onSuccess] {
|
|
27
26
|
if (auto strongThis = weakThis.lock()) {
|
|
28
27
|
winrt::Windows::UI::ViewManagement::UISettings uiSettings;
|
|
29
28
|
auto animationsEnabled = uiSettings.AnimationsEnabled();
|
|
30
|
-
|
|
29
|
+
onSuccess(!animationsEnabled);
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -44,7 +44,6 @@ void Alert::ProcessPendingAlertRequestsXaml() noexcept {
|
|
|
44
44
|
const auto &pendingAlert = pendingAlerts.front();
|
|
45
45
|
const auto &args = pendingAlert.args;
|
|
46
46
|
const auto &result = pendingAlert.result;
|
|
47
|
-
auto jsDispatcher = m_context.JSDispatcher();
|
|
48
47
|
|
|
49
48
|
xaml::Controls::ContentDialog dialog{};
|
|
50
49
|
xaml::Controls::TextBlock titleTextBlock;
|
|
@@ -110,7 +109,7 @@ void Alert::ProcessPendingAlertRequestsXaml() noexcept {
|
|
|
110
109
|
} else if (IsXamlIsland()) {
|
|
111
110
|
// We cannot show a ContentDialog in a XAML Island unless it is assigned a
|
|
112
111
|
// XamlRoot instance. In such cases, we just treat the alert as dismissed.
|
|
113
|
-
|
|
112
|
+
result(m_constants.dismissed, m_constants.buttonNeutral);
|
|
114
113
|
pendingAlerts.pop();
|
|
115
114
|
ProcessPendingAlertRequests();
|
|
116
115
|
return;
|
|
@@ -138,19 +137,17 @@ void Alert::ProcessPendingAlertRequestsXaml() noexcept {
|
|
|
138
137
|
const auto hasCloseButton = dialog.CloseButtonText().size() > 0;
|
|
139
138
|
auto asyncOp = dialog.ShowAsync();
|
|
140
139
|
asyncOp.Completed(
|
|
141
|
-
[hasCloseButton,
|
|
140
|
+
[hasCloseButton, result, this](
|
|
142
141
|
const winrt::IAsyncOperation<xaml::Controls::ContentDialogResult> &asyncOp, winrt::AsyncStatus status) {
|
|
143
142
|
switch (asyncOp.GetResults()) {
|
|
144
143
|
case xaml::Controls::ContentDialogResult::Primary:
|
|
145
|
-
|
|
144
|
+
result(m_constants.buttonClicked, m_constants.buttonPositive);
|
|
146
145
|
break;
|
|
147
146
|
case xaml::Controls::ContentDialogResult::Secondary:
|
|
148
|
-
|
|
147
|
+
result(m_constants.buttonClicked, m_constants.buttonNegative);
|
|
149
148
|
break;
|
|
150
149
|
case xaml::Controls::ContentDialogResult::None:
|
|
151
|
-
|
|
152
|
-
result(hasCloseButton ? m_constants.buttonClicked : m_constants.dismissed, m_constants.buttonNeutral);
|
|
153
|
-
});
|
|
150
|
+
result(hasCloseButton ? m_constants.buttonClicked : m_constants.dismissed, m_constants.buttonNeutral);
|
|
154
151
|
break;
|
|
155
152
|
default:
|
|
156
153
|
break;
|
|
@@ -164,7 +161,6 @@ void Alert::ProcessPendingAlertRequestsMessageDialog() noexcept {
|
|
|
164
161
|
const auto &pendingAlert = pendingAlerts.front();
|
|
165
162
|
const auto &args = pendingAlert.args;
|
|
166
163
|
const auto &result = pendingAlert.result;
|
|
167
|
-
auto jsDispatcher = m_context.JSDispatcher();
|
|
168
164
|
|
|
169
165
|
auto cancelable = args.cancelable.value_or(true);
|
|
170
166
|
auto messageDialog = winrt::Windows::UI::Popups::MessageDialog(
|
|
@@ -208,11 +204,10 @@ void Alert::ProcessPendingAlertRequestsMessageDialog() noexcept {
|
|
|
208
204
|
|
|
209
205
|
auto asyncOp = messageDialog.ShowAsync();
|
|
210
206
|
asyncOp.Completed(
|
|
211
|
-
[
|
|
207
|
+
[result, this](
|
|
212
208
|
const winrt::IAsyncOperation<winrt::Windows::UI::Popups::IUICommand> &asyncOp, winrt::AsyncStatus status) {
|
|
213
209
|
auto uicommand = asyncOp.GetResults();
|
|
214
|
-
|
|
215
|
-
[id = uicommand.Id(), result, this] { result(m_constants.buttonClicked, winrt::unbox_value<int>(id)); });
|
|
210
|
+
result(m_constants.buttonClicked, winrt::unbox_value<int>(uicommand.Id()));
|
|
216
211
|
pendingAlerts.pop();
|
|
217
212
|
ProcessPendingAlertRequests();
|
|
218
213
|
});
|
|
@@ -50,7 +50,6 @@ void AnimationDriver::StartAnimation() {
|
|
|
50
50
|
animatedValue->PropertySet().StartAnimation(ValueAnimatedNode::s_valueName, animation);
|
|
51
51
|
animatedValue->AddActiveAnimation(m_id);
|
|
52
52
|
}
|
|
53
|
-
scopedBatch.End();
|
|
54
53
|
|
|
55
54
|
m_scopedBatchCompletedToken = scopedBatch.Completed(
|
|
56
55
|
[weakSelf = weak_from_this(), weakManager = m_manager, id = m_id, tag = m_animatedValueTag](auto sender, auto) {
|
|
@@ -74,6 +73,8 @@ void AnimationDriver::StartAnimation() {
|
|
|
74
73
|
}
|
|
75
74
|
});
|
|
76
75
|
|
|
76
|
+
scopedBatch.End();
|
|
77
|
+
|
|
77
78
|
m_animation = animation;
|
|
78
79
|
m_scopedBatch = scopedBatch;
|
|
79
80
|
}
|
|
@@ -56,9 +56,7 @@ void NativeAnimatedModule::getValue(double tag, std::function<void(double)> cons
|
|
|
56
56
|
callback = std::move(saveValueCallback)]() {
|
|
57
57
|
if (auto pThis = wkThis.lock()) {
|
|
58
58
|
pThis->m_nodesManager->GetValue(
|
|
59
|
-
tag, [context = pThis->m_context, callback = std::move(callback)](double value) {
|
|
60
|
-
context.JSDispatcher().Post([callback = std::move(callback), value]() { callback(value); });
|
|
61
|
-
});
|
|
59
|
+
tag, [context = pThis->m_context, callback = std::move(callback)](double value) { callback(value); });
|
|
62
60
|
}
|
|
63
61
|
});
|
|
64
62
|
}
|
|
@@ -131,11 +129,9 @@ void NativeAnimatedModule::startAnimatingNode(
|
|
|
131
129
|
nodeTag,
|
|
132
130
|
animationConfig.AsObject(),
|
|
133
131
|
[context = pThis->m_context, endCallback = std::move(endCallback)](bool finished) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
endCallback(std::move(result));
|
|
138
|
-
});
|
|
132
|
+
ReactNativeSpecs::AnimatedModuleSpec_EndResult result;
|
|
133
|
+
result.finished = finished;
|
|
134
|
+
endCallback(std::move(result));
|
|
139
135
|
},
|
|
140
136
|
pThis->m_nodesManager);
|
|
141
137
|
}
|
|
@@ -96,13 +96,13 @@ void AppState::SetDeactivated(bool deactivated) noexcept {
|
|
|
96
96
|
if (winrt::Microsoft::ReactNative::implementation::QuirkSettings::GetMapWindowDeactivatedToAppStateInactive(
|
|
97
97
|
m_context.Properties())) {
|
|
98
98
|
m_deactivated = deactivated;
|
|
99
|
-
|
|
99
|
+
AppStateDidChange({GetAppState()});
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
void AppState::SetEnteredBackground(bool enteredBackground) noexcept {
|
|
104
104
|
m_enteredBackground = enteredBackground;
|
|
105
|
-
|
|
105
|
+
AppStateDidChange({GetAppState()});
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
std::string AppState::GetAppState() noexcept {
|
|
@@ -16,27 +16,25 @@ void Clipboard::Initialize(winrt::Microsoft::ReactNative::ReactContext const &re
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
void Clipboard::getString(React::ReactPromise<std::string> result) noexcept {
|
|
19
|
-
|
|
20
|
-
m_reactContext.UIDispatcher().Post([jsDispatcher, result] {
|
|
19
|
+
m_reactContext.UIDispatcher().Post([result] {
|
|
21
20
|
auto data = DataTransfer::Clipboard::GetContent();
|
|
22
21
|
auto asyncOp = data.GetTextAsync();
|
|
23
22
|
// unfortunately, lambda captures doesn't work well with winrt::fire_and_forget and co_await here
|
|
24
23
|
// call asyncOp.Completed explicitly
|
|
25
|
-
asyncOp.Completed([
|
|
24
|
+
asyncOp.Completed([result](const IAsyncOperation<winrt::hstring> &asyncOp, AsyncStatus status) {
|
|
26
25
|
switch (status) {
|
|
27
26
|
case AsyncStatus::Completed: {
|
|
28
27
|
auto text = std::wstring(asyncOp.GetResults());
|
|
29
|
-
|
|
30
|
-
[result, text] { result.Resolve(std::string{Microsoft::Common::Unicode::Utf16ToUtf8(text)}); });
|
|
28
|
+
result.Resolve(std::string{Microsoft::Common::Unicode::Utf16ToUtf8(text)});
|
|
31
29
|
break;
|
|
32
30
|
}
|
|
33
31
|
case AsyncStatus::Canceled: {
|
|
34
|
-
|
|
32
|
+
result.Reject(React::ReactError());
|
|
35
33
|
break;
|
|
36
34
|
}
|
|
37
35
|
case AsyncStatus::Error: {
|
|
38
36
|
auto message = std::wstring(winrt::hresult_error(asyncOp.ErrorCode()).message());
|
|
39
|
-
|
|
37
|
+
result.Reject(message.c_str());
|
|
40
38
|
break;
|
|
41
39
|
}
|
|
42
40
|
case AsyncStatus::Started: {
|
|
@@ -48,7 +46,7 @@ void Clipboard::getString(React::ReactPromise<std::string> result) noexcept {
|
|
|
48
46
|
);
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
void Clipboard::setString(
|
|
49
|
+
void Clipboard::setString(winrt::hstring content) noexcept {
|
|
52
50
|
m_reactContext.UIDispatcher().Post([=] {
|
|
53
51
|
DataTransfer::DataPackage data;
|
|
54
52
|
data.SetText(content);
|
|
@@ -18,7 +18,7 @@ struct Clipboard {
|
|
|
18
18
|
void getString(winrt::Microsoft::ReactNative::ReactPromise<std::string> result) noexcept;
|
|
19
19
|
|
|
20
20
|
REACT_METHOD(setString)
|
|
21
|
-
void setString(
|
|
21
|
+
void setString(winrt::hstring content) noexcept;
|
|
22
22
|
|
|
23
23
|
winrt::Microsoft::ReactNative::ReactContext m_reactContext;
|
|
24
24
|
};
|
|
@@ -109,14 +109,10 @@ void ImageLoader::getSize(std::string uri, React::ReactPromise<std::vector<doubl
|
|
|
109
109
|
context.Properties().Handle(),
|
|
110
110
|
std::move(uri),
|
|
111
111
|
{},
|
|
112
|
-
[result
|
|
113
|
-
|
|
114
|
-
result.Resolve(std::vector<double>{width, height});
|
|
115
|
-
});
|
|
112
|
+
[result](double width, double height) noexcept {
|
|
113
|
+
result.Resolve(std::vector<double>{width, height});
|
|
116
114
|
},
|
|
117
|
-
[result
|
|
118
|
-
context.JSDispatcher().Post([result = std::move(result)]() noexcept { result.Reject("Failed"); });
|
|
119
|
-
}
|
|
115
|
+
[result]() noexcept { result.Reject("Failed"); }
|
|
120
116
|
#ifdef USE_FABRIC
|
|
121
117
|
,
|
|
122
118
|
IsFabricEnabled(context.Properties().Handle())
|
|
@@ -138,15 +134,10 @@ void ImageLoader::getSizeWithHeaders(
|
|
|
138
134
|
context.Properties().Handle(),
|
|
139
135
|
std::move(uri),
|
|
140
136
|
std::move(headers),
|
|
141
|
-
[result
|
|
142
|
-
|
|
143
|
-
result.Resolve(
|
|
144
|
-
Microsoft::ReactNativeSpecs::ImageLoaderIOSSpec_getSizeWithHeaders_returnType{width, height});
|
|
145
|
-
});
|
|
137
|
+
[result](double width, double height) noexcept {
|
|
138
|
+
result.Resolve(Microsoft::ReactNativeSpecs::ImageLoaderIOSSpec_getSizeWithHeaders_returnType{width, height});
|
|
146
139
|
},
|
|
147
|
-
[result
|
|
148
|
-
context.JSDispatcher().Post([result = std::move(result)]() noexcept { result.Reject("Failed"); });
|
|
149
|
-
}
|
|
140
|
+
[result]() noexcept { result.Reject("Failed"); }
|
|
150
141
|
#ifdef USE_FABRIC
|
|
151
142
|
,
|
|
152
143
|
IsFabricEnabled(context.Properties().Handle())
|