-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathReactInstanceSettings.h
More file actions
360 lines (270 loc) · 12.1 KB
/
Copy pathReactInstanceSettings.h
File metadata and controls
360 lines (270 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "InstanceCreatedEventArgs.g.h"
#include "InstanceDestroyedEventArgs.g.h"
#include "InstanceLoadedEventArgs.g.h"
#include "ReactInstanceSettings.g.h"
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.h>
#include "React.h"
#include "ReactPropertyBag.h"
namespace winrt::Microsoft::ReactNative::implementation {
struct InstanceCreatedEventArgs : InstanceCreatedEventArgsT<InstanceCreatedEventArgs> {
InstanceCreatedEventArgs() = default;
InstanceCreatedEventArgs(Mso::CntPtr<Mso::React::IReactContext> &&context);
winrt::Microsoft::ReactNative::IReactContext Context() noexcept;
winrt::Windows::Foundation::IInspectable RuntimeHandle() noexcept;
private:
winrt::Microsoft::ReactNative::IReactContext m_context;
};
struct InstanceLoadedEventArgs : InstanceLoadedEventArgsT<InstanceLoadedEventArgs> {
InstanceLoadedEventArgs() = default;
InstanceLoadedEventArgs(Mso::CntPtr<Mso::React::IReactContext> &&context, bool failed);
winrt::Microsoft::ReactNative::IReactContext Context() noexcept;
winrt::Windows::Foundation::IInspectable RuntimeHandle() noexcept;
bool Failed() noexcept;
private:
winrt::Microsoft::ReactNative::IReactContext m_context;
bool m_failed;
};
struct InstanceDestroyedEventArgs : InstanceDestroyedEventArgsT<InstanceDestroyedEventArgs> {
InstanceDestroyedEventArgs() = default;
InstanceDestroyedEventArgs(Mso::CntPtr<Mso::React::IReactContext> &&context);
winrt::Microsoft::ReactNative::IReactContext Context() noexcept;
private:
winrt::Microsoft::ReactNative::IReactContext m_context;
};
struct ReactInstanceSettings : ReactInstanceSettingsT<ReactInstanceSettings> {
ReactInstanceSettings() noexcept;
IReactPropertyBag Properties() noexcept;
IReactNotificationService Notifications() noexcept;
winrt::Windows::Foundation::Collections::IVector<IReactPackageProvider> PackageProviders() noexcept;
//! This controls the availability of various developer support functionality including
//! RedBox, and the Developer Menu
bool UseDeveloperSupport() noexcept;
void UseDeveloperSupport(bool value) noexcept;
hstring JavaScriptBundleFile() noexcept;
void JavaScriptBundleFile(hstring const &value) noexcept;
hstring JavaScriptBundleSuffix() noexcept;
void JavaScriptBundleSuffix(hstring const &value) noexcept;
hstring BundleAppId() noexcept;
void BundleAppId(hstring const &value) noexcept;
//! When querying the bundle server for a bundle, should it request the dev bundle or release bundle
bool RequestDevBundle() noexcept;
void RequestDevBundle(bool value) noexcept;
//! Should the instance trigger the hot reload logic when it first loads the instance
//! Most edits should be visible within a second or two without the instance having to reload
//! Non-compatible changes still cause full reloads
bool UseFastRefresh() noexcept;
void UseFastRefresh(bool value) noexcept;
//! Should the instance monitor for changes to the JS and reload the instance when a change is
//! detected. Generally its preferred to use FastFreshed instead of this. But if there is some
//! issue with hot reloading in your app, then this can be used instead
bool UseLiveReload() noexcept;
void UseLiveReload(bool value) noexcept;
//! Should the instance setup the JS environment such that a JS debugger can attach to the JS environment
bool UseDirectDebugger() noexcept;
void UseDirectDebugger(bool value) noexcept;
//! Should the instance setup the JS environment to immediately break waiting for a JS debugger
//! This allows a JS debugger to be able to debug the boot JS code with in the instance
bool DebuggerBreakOnNextLine() noexcept;
void DebuggerBreakOnNextLine(bool value) noexcept;
bool EnableJITCompilation() noexcept;
void EnableJITCompilation(bool value) noexcept;
bool EnableByteCodeCaching() noexcept;
void EnableByteCodeCaching(bool value) noexcept;
bool EnableDefaultCrashHandler() noexcept;
void EnableDefaultCrashHandler(bool value) noexcept;
//! Same as UseDeveloperSupport
bool EnableDeveloperMenu() noexcept;
void EnableDeveloperMenu(bool value) noexcept;
hstring ByteCodeFileUri() noexcept;
void ByteCodeFileUri(hstring const &value) noexcept;
hstring DebugBundlePath() noexcept;
void DebugBundlePath(hstring const &value) noexcept;
hstring BundleRootPath() noexcept;
void BundleRootPath(hstring const &value) noexcept;
uint16_t DebuggerPort() noexcept;
void DebuggerPort(uint16_t value) noexcept;
hstring DebuggerRuntimeName() noexcept;
void DebuggerRuntimeName(hstring const &value) noexcept;
IRedBoxHandler RedBoxHandler() noexcept;
void RedBoxHandler(IRedBoxHandler const &value) noexcept;
LogHandler NativeLogger() noexcept;
void NativeLogger(LogHandler const &value) noexcept;
IReactDispatcher UIDispatcher() noexcept;
void UIDispatcher(IReactDispatcher const &value) noexcept;
hstring SourceBundleHost() noexcept;
void SourceBundleHost(hstring const &value) noexcept;
uint16_t SourceBundlePort() noexcept;
void SourceBundlePort(uint16_t value) noexcept;
bool RequestInlineSourceMap() noexcept;
void RequestInlineSourceMap(bool value) noexcept;
JSIEngine JSIEngineOverride() noexcept;
void JSIEngineOverride(JSIEngine value) noexcept;
winrt::event_token InstanceCreated(
winrt::Windows::Foundation::EventHandler<winrt::Microsoft::ReactNative::InstanceCreatedEventArgs> const
&handler) noexcept;
void InstanceCreated(winrt::event_token const &token) noexcept;
winrt::event_token InstanceLoaded(
winrt::Windows::Foundation::EventHandler<winrt::Microsoft::ReactNative::InstanceLoadedEventArgs> const
&handler) noexcept;
void InstanceLoaded(winrt::event_token const &token) noexcept;
winrt::event_token InstanceDestroyed(
winrt::Windows::Foundation::EventHandler<winrt::Microsoft::ReactNative::InstanceDestroyedEventArgs> const
&handler) noexcept;
void InstanceDestroyed(winrt::event_token const &token) noexcept;
static void RaiseInstanceCreated(
IReactNotificationService const ¬ificationService,
winrt::Microsoft::ReactNative::InstanceCreatedEventArgs const &args) noexcept;
static void RaiseInstanceLoaded(
IReactNotificationService const ¬ificationService,
winrt::Microsoft::ReactNative::InstanceLoadedEventArgs const &args) noexcept;
static void RaiseInstanceDestroyed(
IReactNotificationService const ¬ificationService,
winrt::Microsoft::ReactNative::InstanceDestroyedEventArgs const &args) noexcept;
private:
IReactPropertyBag m_properties{ReactPropertyBagHelper::CreatePropertyBag()};
IReactNotificationService m_notifications{ReactNotificationServiceHelper::CreateNotificationService()};
::winrt::Windows::Foundation::Collections::IVector<IReactPackageProvider> m_packageProviders{
single_threaded_vector<IReactPackageProvider>()};
hstring m_javaScriptBundleFile{};
hstring m_bundleAppId{};
bool m_devBundle{true};
bool m_enableJITCompilation{true};
bool m_enableByteCodeCaching{false};
hstring m_byteCodeFileUri{};
hstring m_debugBundlePath{};
hstring m_bundleSuffix{L".bundle"};
hstring m_bundleRootPath{};
uint16_t m_debuggerPort{9229};
IRedBoxHandler m_redBoxHandler{nullptr};
hstring m_sourceBundleHost{};
hstring m_debuggerRuntimeName{};
uint16_t m_sourceBundlePort{0};
bool m_requestInlineSourceMap{true};
LogHandler m_nativeLogger{nullptr};
JSIEngine m_jSIEngineOverride{JSIEngine::Hermes};
};
} // namespace winrt::Microsoft::ReactNative::implementation
namespace winrt::Microsoft::ReactNative::factory_implementation {
struct ReactInstanceSettings : ReactInstanceSettingsT<ReactInstanceSettings, implementation::ReactInstanceSettings> {};
} // namespace winrt::Microsoft::ReactNative::factory_implementation
namespace winrt::Microsoft::ReactNative::implementation {
//=============================================================================================
// ReactInstanceSettings inline implementation
//=============================================================================================
inline IReactPropertyBag ReactInstanceSettings::Properties() noexcept {
return m_properties;
}
inline IReactNotificationService ReactInstanceSettings::Notifications() noexcept {
return m_notifications;
}
inline winrt::Windows::Foundation::Collections::IVector<IReactPackageProvider>
ReactInstanceSettings::PackageProviders() noexcept {
return m_packageProviders;
}
inline hstring ReactInstanceSettings::JavaScriptBundleFile() noexcept {
return m_javaScriptBundleFile;
}
inline void ReactInstanceSettings::JavaScriptBundleFile(hstring const &value) noexcept {
m_javaScriptBundleFile = value;
}
inline hstring ReactInstanceSettings::JavaScriptBundleSuffix() noexcept {
return m_bundleSuffix;
}
inline void ReactInstanceSettings::JavaScriptBundleSuffix(hstring const &value) noexcept {
m_bundleSuffix = value;
}
inline hstring ReactInstanceSettings::BundleAppId() noexcept {
return m_bundleAppId;
}
inline void ReactInstanceSettings::BundleAppId(hstring const &value) noexcept {
m_bundleAppId = value;
}
inline bool ReactInstanceSettings::RequestDevBundle() noexcept {
return m_devBundle;
}
inline void ReactInstanceSettings::RequestDevBundle(bool value) noexcept {
m_devBundle = value;
}
inline bool ReactInstanceSettings::EnableJITCompilation() noexcept {
return m_enableJITCompilation;
}
inline void ReactInstanceSettings::EnableJITCompilation(bool value) noexcept {
m_enableJITCompilation = value;
}
inline bool ReactInstanceSettings::EnableByteCodeCaching() noexcept {
return m_enableByteCodeCaching;
}
inline void ReactInstanceSettings::EnableByteCodeCaching(bool value) noexcept {
m_enableByteCodeCaching = value;
}
inline hstring ReactInstanceSettings::ByteCodeFileUri() noexcept {
return m_byteCodeFileUri;
}
inline void ReactInstanceSettings::ByteCodeFileUri(hstring const &value) noexcept {
m_byteCodeFileUri = value;
}
inline hstring ReactInstanceSettings::DebugBundlePath() noexcept {
return m_debugBundlePath;
}
inline void ReactInstanceSettings::DebugBundlePath(hstring const &value) noexcept {
m_debugBundlePath = value;
}
inline hstring ReactInstanceSettings::BundleRootPath() noexcept {
return m_bundleRootPath;
}
inline void ReactInstanceSettings::BundleRootPath(hstring const &value) noexcept {
m_bundleRootPath = value;
}
inline uint16_t ReactInstanceSettings::DebuggerPort() noexcept {
return m_debuggerPort;
}
inline void ReactInstanceSettings::DebuggerPort(uint16_t value) noexcept {
m_debuggerPort = value;
}
inline hstring ReactInstanceSettings::DebuggerRuntimeName() noexcept {
return m_debuggerRuntimeName;
}
inline void ReactInstanceSettings::DebuggerRuntimeName(hstring const &value) noexcept {
m_debuggerRuntimeName = value;
}
inline IRedBoxHandler ReactInstanceSettings::RedBoxHandler() noexcept {
return m_redBoxHandler;
}
inline void ReactInstanceSettings::RedBoxHandler(IRedBoxHandler const &value) noexcept {
m_redBoxHandler = value;
}
inline LogHandler ReactInstanceSettings::NativeLogger() noexcept {
return m_nativeLogger;
}
inline void ReactInstanceSettings::NativeLogger(LogHandler const &value) noexcept {
m_nativeLogger = value;
}
inline hstring ReactInstanceSettings::SourceBundleHost() noexcept {
return m_sourceBundleHost;
}
inline void ReactInstanceSettings::SourceBundleHost(hstring const &value) noexcept {
m_sourceBundleHost = value;
}
inline uint16_t ReactInstanceSettings::SourceBundlePort() noexcept {
return m_sourceBundlePort;
}
inline void ReactInstanceSettings::SourceBundlePort(uint16_t value) noexcept {
m_sourceBundlePort = value;
}
inline bool ReactInstanceSettings::RequestInlineSourceMap() noexcept {
return m_requestInlineSourceMap;
}
inline void ReactInstanceSettings::RequestInlineSourceMap(bool value) noexcept {
m_requestInlineSourceMap = value;
}
inline JSIEngine ReactInstanceSettings::JSIEngineOverride() noexcept {
return m_jSIEngineOverride;
}
inline void ReactInstanceSettings::JSIEngineOverride(JSIEngine value) noexcept {
m_jSIEngineOverride = value;
}
} // namespace winrt::Microsoft::ReactNative::implementation