react-native-windows 0.82.0 → 0.82.3
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/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +52 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/Pch/pch.h +2 -0
- package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
- package/PropertySheets/CIBuildOptimizations.props +29 -0
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/README.md +1 -1
- package/ReactCommon/ReactCommon.vcxproj +10 -10
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +379 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +47 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +143 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +98 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +254 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +9 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +91 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +147 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +622 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +121 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +409 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp +628 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +79 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +138 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +732 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +687 -0
- package/Scripts/OfficeReact.Win32.nuspec +0 -11
- package/Shared/Networking/WinRTWebSocketResource.cpp +5 -4
- package/Shared/Shared.vcxitems +9 -9
- package/package.json +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +2 -0
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
#if _MSC_VER
|
|
9
|
+
#pragma warning(push)
|
|
10
|
+
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
|
+
#endif
|
|
12
|
+
#include "ModuleRegistry.h"
|
|
13
|
+
|
|
14
|
+
#ifndef RCT_FIT_RM_OLD_RUNTIME
|
|
15
|
+
|
|
16
|
+
#include <glog/logging.h>
|
|
17
|
+
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
|
|
18
|
+
#include <utility>
|
|
19
|
+
|
|
20
|
+
#include "NativeModule.h"
|
|
21
|
+
#include "TraceSection.h"
|
|
22
|
+
|
|
23
|
+
namespace facebook::react {
|
|
24
|
+
|
|
25
|
+
namespace {
|
|
26
|
+
|
|
27
|
+
std::string normalizeName(std::string name) {
|
|
28
|
+
// TODO mhorowitz #10487027: This is super ugly. We should just
|
|
29
|
+
// change iOS to emit normalized names, drop the "RK..." from
|
|
30
|
+
// names hardcoded in Android, and then delete this and the
|
|
31
|
+
// similar hacks in js.
|
|
32
|
+
if (name.compare(0, 3, "RCT") == 0) {
|
|
33
|
+
return name.substr(3);
|
|
34
|
+
} else if (name.compare(0, 2, "RK") == 0) {
|
|
35
|
+
return name.substr(2);
|
|
36
|
+
}
|
|
37
|
+
return name;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} // namespace
|
|
41
|
+
|
|
42
|
+
ModuleRegistry::ModuleRegistry(
|
|
43
|
+
std::vector<std::unique_ptr<NativeModule>> modules,
|
|
44
|
+
ModuleNotFoundCallback callback)
|
|
45
|
+
: modules_{std::move(modules)},
|
|
46
|
+
moduleNotFoundCallback_{std::move(callback)} {}
|
|
47
|
+
|
|
48
|
+
void ModuleRegistry::updateModuleNamesFromIndex(size_t index) {
|
|
49
|
+
for (; index < modules_.size(); index++) {
|
|
50
|
+
std::string name = normalizeName(modules_[index]->getName());
|
|
51
|
+
modulesByName_[name] = index;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void ModuleRegistry::registerModules(
|
|
56
|
+
std::vector<std::unique_ptr<NativeModule>> modules) {
|
|
57
|
+
TraceSection s_("ModuleRegistry::registerModules");
|
|
58
|
+
// Noop if there are no NativeModules to add
|
|
59
|
+
if (modules.empty()) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (modules_.empty() && unknownModules_.empty()) {
|
|
64
|
+
modules_ = std::move(modules);
|
|
65
|
+
} else {
|
|
66
|
+
size_t modulesSize = modules_.size();
|
|
67
|
+
size_t addModulesSize = modules.size();
|
|
68
|
+
bool addToNames = !modulesByName_.empty();
|
|
69
|
+
modules_.reserve(modulesSize + addModulesSize);
|
|
70
|
+
std::move(modules.begin(), modules.end(), std::back_inserter(modules_));
|
|
71
|
+
if (!unknownModules_.empty()) {
|
|
72
|
+
for (size_t index = modulesSize; index < modulesSize + addModulesSize;
|
|
73
|
+
index++) {
|
|
74
|
+
std::string name = normalizeName(modules_[index]->getName());
|
|
75
|
+
auto it = unknownModules_.find(name);
|
|
76
|
+
if (it != unknownModules_.end()) {
|
|
77
|
+
throw std::runtime_error(
|
|
78
|
+
"module " + name +
|
|
79
|
+
" was required without being registered and is now being registered.");
|
|
80
|
+
} else if (addToNames) {
|
|
81
|
+
modulesByName_[name] = index;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else if (addToNames) {
|
|
85
|
+
updateModuleNamesFromIndex(modulesSize);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
std::vector<std::string> ModuleRegistry::moduleNames() {
|
|
91
|
+
TraceSection s_("ModuleRegistry::moduleNames");
|
|
92
|
+
std::vector<std::string> names;
|
|
93
|
+
for (size_t i = 0; i < modules_.size(); i++) {
|
|
94
|
+
std::string name = normalizeName(modules_[i]->getName());
|
|
95
|
+
modulesByName_[name] = i;
|
|
96
|
+
names.push_back(std::move(name));
|
|
97
|
+
}
|
|
98
|
+
return names;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
|
|
102
|
+
TraceSection s("ModuleRegistry::getConfig", "module", name);
|
|
103
|
+
|
|
104
|
+
// Initialize modulesByName_
|
|
105
|
+
if (modulesByName_.empty() && !modules_.empty()) {
|
|
106
|
+
moduleNames();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
auto it = modulesByName_.find(name);
|
|
110
|
+
|
|
111
|
+
if (it == modulesByName_.end()) {
|
|
112
|
+
if (unknownModules_.find(name) != unknownModules_.end()) {
|
|
113
|
+
BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
|
|
114
|
+
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
|
|
115
|
+
return std::nullopt;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!moduleNotFoundCallback_) {
|
|
119
|
+
unknownModules_.insert(name);
|
|
120
|
+
BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
|
|
121
|
+
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
|
|
122
|
+
return std::nullopt;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
|
|
126
|
+
|
|
127
|
+
bool wasModuleLazilyLoaded = moduleNotFoundCallback_(name);
|
|
128
|
+
it = modulesByName_.find(name);
|
|
129
|
+
|
|
130
|
+
bool wasModuleRegisteredWithRegistry =
|
|
131
|
+
wasModuleLazilyLoaded && it != modulesByName_.end();
|
|
132
|
+
|
|
133
|
+
if (!wasModuleRegisteredWithRegistry) {
|
|
134
|
+
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
|
|
135
|
+
unknownModules_.insert(name);
|
|
136
|
+
return std::nullopt;
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// If we've gotten this far, then we've signaled moduleJSRequireBeginningEnd
|
|
143
|
+
|
|
144
|
+
size_t index = it->second;
|
|
145
|
+
|
|
146
|
+
CHECK(index < modules_.size());
|
|
147
|
+
NativeModule* module = modules_[index].get();
|
|
148
|
+
|
|
149
|
+
// string name, object constants, array methodNames (methodId is index),
|
|
150
|
+
// [array promiseMethodIds], [array syncMethodIds]
|
|
151
|
+
folly::dynamic config = folly::dynamic::array(name);
|
|
152
|
+
|
|
153
|
+
{
|
|
154
|
+
TraceSection s_("ModuleRegistry::getConstants", "module", name);
|
|
155
|
+
/**
|
|
156
|
+
* In the case that there are constants, we'll initialize the NativeModule,
|
|
157
|
+
* and signal moduleJSRequireEndingStart. Otherwise, we'll simply signal the
|
|
158
|
+
* event. The Module will be initialized when we invoke one of its
|
|
159
|
+
* NativeModule methods.
|
|
160
|
+
*/
|
|
161
|
+
config.push_back(module->getConstants());
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
{
|
|
165
|
+
TraceSection s_("ModuleRegistry::getMethods", "module", name);
|
|
166
|
+
std::vector<MethodDescriptor> methods = module->getMethods();
|
|
167
|
+
|
|
168
|
+
folly::dynamic methodNames = folly::dynamic::array;
|
|
169
|
+
folly::dynamic promiseMethodIds = folly::dynamic::array;
|
|
170
|
+
folly::dynamic syncMethodIds = folly::dynamic::array;
|
|
171
|
+
|
|
172
|
+
for (auto& descriptor : methods) {
|
|
173
|
+
// TODO: #10487027 compare tags instead of doing string comparison?
|
|
174
|
+
methodNames.push_back(std::move(descriptor.name));
|
|
175
|
+
if (descriptor.type == "promise") {
|
|
176
|
+
promiseMethodIds.push_back(methodNames.size() - 1);
|
|
177
|
+
} else if (descriptor.type == "sync") {
|
|
178
|
+
syncMethodIds.push_back(methodNames.size() - 1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!methodNames.empty()) {
|
|
183
|
+
config.push_back(std::move(methodNames));
|
|
184
|
+
if (!promiseMethodIds.empty() || !syncMethodIds.empty()) {
|
|
185
|
+
config.push_back(std::move(promiseMethodIds));
|
|
186
|
+
if (!syncMethodIds.empty()) {
|
|
187
|
+
config.push_back(std::move(syncMethodIds));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (config.size() == 2 && config[1].empty()) {
|
|
194
|
+
// no constants or methods
|
|
195
|
+
return std::nullopt;
|
|
196
|
+
} else {
|
|
197
|
+
return ModuleConfig{index, std::move(config)};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
std::string ModuleRegistry::getModuleName(unsigned int moduleId) {
|
|
202
|
+
if (moduleId >= modules_.size()) {
|
|
203
|
+
throw std::runtime_error(
|
|
204
|
+
"moduleId " + std::to_string(moduleId) + " out of range [0.." +
|
|
205
|
+
std::to_string(modules_.size()) + ")");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return modules_[moduleId]->getName();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
std::string ModuleRegistry::getModuleSyncMethodName(
|
|
212
|
+
unsigned int moduleId,
|
|
213
|
+
unsigned int methodId) {
|
|
214
|
+
if (moduleId >= modules_.size()) {
|
|
215
|
+
throw std::runtime_error(
|
|
216
|
+
"moduleId " + std::to_string(moduleId) + " out of range [0.." +
|
|
217
|
+
std::to_string(modules_.size()) + ")");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return modules_[moduleId]->getSyncMethodName(methodId);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
void ModuleRegistry::callNativeMethod(
|
|
224
|
+
unsigned int moduleId,
|
|
225
|
+
unsigned int methodId,
|
|
226
|
+
folly::dynamic&& params,
|
|
227
|
+
int callId) {
|
|
228
|
+
if (moduleId >= modules_.size()) {
|
|
229
|
+
throw std::runtime_error(
|
|
230
|
+
"moduleId " + std::to_string(moduleId) + " out of range [0.." +
|
|
231
|
+
std::to_string(modules_.size()) + ")");
|
|
232
|
+
}
|
|
233
|
+
modules_[moduleId]->invoke(methodId, std::move(params), callId);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
MethodCallResult ModuleRegistry::callSerializableNativeHook(
|
|
237
|
+
unsigned int moduleId,
|
|
238
|
+
unsigned int methodId,
|
|
239
|
+
folly::dynamic&& params) {
|
|
240
|
+
if (moduleId >= modules_.size()) {
|
|
241
|
+
throw std::runtime_error(
|
|
242
|
+
"moduleId " + std::to_string(moduleId) + " out of range [0.." +
|
|
243
|
+
std::to_string(modules_.size()) + ")");
|
|
244
|
+
}
|
|
245
|
+
return modules_[moduleId]->callSerializableNativeHook(
|
|
246
|
+
methodId, std::move(params));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
} // namespace facebook::react
|
|
250
|
+
|
|
251
|
+
#endif // RCT_FIT_RM_OLD_RUNTIME
|
|
252
|
+
#if _MSC_VER
|
|
253
|
+
#pragma warning(pop)
|
|
254
|
+
#endif
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
#if _MSC_VER
|
|
9
|
+
#pragma warning(push)
|
|
10
|
+
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
|
+
#endif
|
|
12
|
+
|
|
8
13
|
#include "NativeToJsBridge.h"
|
|
9
14
|
|
|
10
15
|
#ifndef RCT_FIT_RM_OLD_RUNTIME
|
|
@@ -352,3 +357,7 @@ NativeToJsBridge::getInspectorTargetDelegate() {
|
|
|
352
357
|
} // namespace facebook::react
|
|
353
358
|
|
|
354
359
|
#endif // RCT_FIT_RM_OLD_RUNTIME
|
|
360
|
+
|
|
361
|
+
#if _MSC_VER
|
|
362
|
+
#pragma warning(pop)
|
|
363
|
+
#endif
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
#if _MSC_VER
|
|
9
|
+
#pragma warning(push)
|
|
10
|
+
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
|
+
#endif
|
|
12
|
+
#include "RAMBundleRegistry.h"
|
|
13
|
+
|
|
14
|
+
#ifndef RCT_FIT_RM_OLD_RUNTIME
|
|
15
|
+
|
|
16
|
+
#include <folly/String.h>
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
|
|
20
|
+
namespace facebook::react {
|
|
21
|
+
|
|
22
|
+
#pragma clang diagnostic push
|
|
23
|
+
#pragma clang diagnostic ignored "-Wdeprecated"
|
|
24
|
+
constexpr uint32_t RAMBundleRegistry::MAIN_BUNDLE_ID;
|
|
25
|
+
#pragma clang diagnostic pop
|
|
26
|
+
|
|
27
|
+
std::unique_ptr<RAMBundleRegistry> RAMBundleRegistry::singleBundleRegistry(
|
|
28
|
+
std::unique_ptr<JSModulesUnbundle> mainBundle) {
|
|
29
|
+
return std::make_unique<RAMBundleRegistry>(std::move(mainBundle));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
std::unique_ptr<RAMBundleRegistry> RAMBundleRegistry::multipleBundlesRegistry(
|
|
33
|
+
std::unique_ptr<JSModulesUnbundle> mainBundle,
|
|
34
|
+
std::function<std::unique_ptr<JSModulesUnbundle>(std::string)> factory) {
|
|
35
|
+
return std::make_unique<RAMBundleRegistry>(
|
|
36
|
+
std::move(mainBundle), std::move(factory));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
RAMBundleRegistry::RAMBundleRegistry(
|
|
40
|
+
std::unique_ptr<JSModulesUnbundle> mainBundle,
|
|
41
|
+
std::function<std::unique_ptr<JSModulesUnbundle>(std::string)> factory)
|
|
42
|
+
: m_factory(std::move(factory)) {
|
|
43
|
+
m_bundles.emplace(MAIN_BUNDLE_ID, std::move(mainBundle));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void RAMBundleRegistry::registerBundle(
|
|
47
|
+
uint32_t bundleId,
|
|
48
|
+
std::string bundlePath) {
|
|
49
|
+
m_bundlePaths.emplace(bundleId, std::move(bundlePath));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
JSModulesUnbundle::Module RAMBundleRegistry::getModule(
|
|
53
|
+
uint32_t bundleId,
|
|
54
|
+
uint32_t moduleId) {
|
|
55
|
+
if (m_bundles.find(bundleId) == m_bundles.end()) {
|
|
56
|
+
if (!m_factory) {
|
|
57
|
+
throw std::runtime_error(
|
|
58
|
+
"You need to register factory function in order to "
|
|
59
|
+
"support multiple RAM bundles.");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
auto bundlePath = m_bundlePaths.find(bundleId);
|
|
63
|
+
if (bundlePath == m_bundlePaths.end()) {
|
|
64
|
+
throw std::runtime_error(
|
|
65
|
+
"In order to fetch RAM bundle from the registry, its file "
|
|
66
|
+
"path needs to be registered first.");
|
|
67
|
+
}
|
|
68
|
+
m_bundles.emplace(bundleId, m_factory(bundlePath->second));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
auto module = getBundle(bundleId)->getModule(moduleId);
|
|
72
|
+
if (bundleId == MAIN_BUNDLE_ID) {
|
|
73
|
+
return module;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
"seg-" + std::to_string(bundleId) + '_' + module.name,
|
|
78
|
+
std::move(module.code),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
JSModulesUnbundle* RAMBundleRegistry::getBundle(uint32_t bundleId) const {
|
|
83
|
+
return m_bundles.at(bundleId).get();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} // namespace facebook::react
|
|
87
|
+
|
|
88
|
+
#endif // RCT_FIT_RM_OLD_RUNTIME
|
|
89
|
+
#if _MSC_VER
|
|
90
|
+
#pragma warning(pop)
|
|
91
|
+
#endif
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
#if _MSC_VER
|
|
9
|
+
#pragma warning(push)
|
|
10
|
+
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
|
+
#endif
|
|
12
|
+
#include "ReactMarker.h"
|
|
13
|
+
#include <cxxreact/JSExecutor.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react::ReactMarker {
|
|
16
|
+
|
|
17
|
+
#if __clang__
|
|
18
|
+
#pragma clang diagnostic push
|
|
19
|
+
#pragma clang diagnostic ignored "-Wglobal-constructors"
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
LogTaggedMarker logTaggedMarkerBridgelessImpl = nullptr;
|
|
23
|
+
LogTaggedMarker logTaggedMarkerImpl = nullptr;
|
|
24
|
+
std::shared_mutex logTaggedMarkerImplMutex;
|
|
25
|
+
|
|
26
|
+
#if __clang__
|
|
27
|
+
#pragma clang diagnostic pop
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
void logMarker(const ReactMarkerId markerId) {
|
|
31
|
+
logTaggedMarker(markerId, nullptr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void logTaggedMarker(const ReactMarkerId markerId, const char* tag) {
|
|
35
|
+
LogTaggedMarker marker = nullptr;
|
|
36
|
+
{
|
|
37
|
+
std::shared_lock lock(logTaggedMarkerImplMutex);
|
|
38
|
+
marker = logTaggedMarkerImpl;
|
|
39
|
+
}
|
|
40
|
+
if (marker != nullptr) {
|
|
41
|
+
marker(markerId, tag);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void logMarkerBridgeless(const ReactMarkerId markerId) {
|
|
46
|
+
logTaggedMarkerBridgeless(markerId, nullptr);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void logTaggedMarkerBridgeless(const ReactMarkerId markerId, const char* tag) {
|
|
50
|
+
logTaggedMarkerBridgelessImpl(markerId, tag);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void logMarkerDone(const ReactMarkerId markerId, double markerTime) {
|
|
54
|
+
StartupLogger::getInstance().logStartupEvent(markerId, markerTime);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
StartupLogger& StartupLogger::getInstance() {
|
|
58
|
+
static StartupLogger instance;
|
|
59
|
+
return instance;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void StartupLogger::logStartupEvent(
|
|
63
|
+
const ReactMarkerId markerId,
|
|
64
|
+
double markerTime) {
|
|
65
|
+
switch (markerId) {
|
|
66
|
+
case ReactMarkerId::APP_STARTUP_START:
|
|
67
|
+
if (!std::isnan(appStartupStartTime)) {
|
|
68
|
+
// We had a startup start time, which indicates a warm start (user
|
|
69
|
+
// closed the app and start again). In this case we need to invalidate
|
|
70
|
+
// all other startup timings.
|
|
71
|
+
reset();
|
|
72
|
+
}
|
|
73
|
+
appStartupStartTime = markerTime;
|
|
74
|
+
return;
|
|
75
|
+
|
|
76
|
+
case ReactMarkerId::APP_STARTUP_STOP:
|
|
77
|
+
if (std::isnan(appStartupEndTime)) {
|
|
78
|
+
appStartupEndTime = markerTime;
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
|
|
82
|
+
case ReactMarkerId::INIT_REACT_RUNTIME_START:
|
|
83
|
+
if (std::isnan(initReactRuntimeStartTime)) {
|
|
84
|
+
initReactRuntimeStartTime = markerTime;
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
|
|
88
|
+
case ReactMarkerId::INIT_REACT_RUNTIME_STOP:
|
|
89
|
+
if (std::isnan(initReactRuntimeEndTime)) {
|
|
90
|
+
initReactRuntimeEndTime = markerTime;
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
|
|
94
|
+
case ReactMarkerId::RUN_JS_BUNDLE_START:
|
|
95
|
+
if (std::isnan(runJSBundleStartTime)) {
|
|
96
|
+
runJSBundleStartTime = markerTime;
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
|
|
100
|
+
case ReactMarkerId::RUN_JS_BUNDLE_STOP:
|
|
101
|
+
if (std::isnan(runJSBundleEndTime)) {
|
|
102
|
+
runJSBundleEndTime = markerTime;
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
|
|
106
|
+
default:
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void StartupLogger::reset() {
|
|
112
|
+
appStartupStartTime = std::nan("");
|
|
113
|
+
appStartupEndTime = std::nan("");
|
|
114
|
+
initReactRuntimeStartTime = std::nan("");
|
|
115
|
+
initReactRuntimeEndTime = std::nan("");
|
|
116
|
+
runJSBundleStartTime = std::nan("");
|
|
117
|
+
runJSBundleEndTime = std::nan("");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
double StartupLogger::getAppStartupStartTime() {
|
|
121
|
+
return appStartupStartTime;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
double StartupLogger::getInitReactRuntimeStartTime() {
|
|
125
|
+
return initReactRuntimeStartTime;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
double StartupLogger::getInitReactRuntimeEndTime() {
|
|
129
|
+
return initReactRuntimeEndTime;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
double StartupLogger::getRunJSBundleStartTime() {
|
|
133
|
+
return runJSBundleStartTime;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
double StartupLogger::getRunJSBundleEndTime() {
|
|
137
|
+
return runJSBundleEndTime;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
double StartupLogger::getAppStartupEndTime() {
|
|
141
|
+
return appStartupEndTime;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
} // namespace facebook::react::ReactMarker
|
|
145
|
+
#if _MSC_VER
|
|
146
|
+
#pragma warning(pop)
|
|
147
|
+
#endif
|