Skip to content

Commit 0f70801

Browse files
committed
feat(ElementInspector): Adds Element Inspector dev tooling to ReactWindows
Element Inspector is useful for tracing which component is responsible for a particular UI element. Element Inspector uses the UIManager API 'findSubviewIn', which also needed to be wired up and implemented. Also adding some infrastructure in preparation for HMR and FPS debugging. Fixes microsoft#214 - Implement UIManagerModule.findSubviewIn Fixes microsoft#355 - Add element inspector dev tooling
1 parent 8f07840 commit 0f70801

15 files changed

+453
-143
lines changed

ReactWindows/ReactNative/CoreModulesPackage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using ReactNative.Bridge;
2+
using ReactNative.DevSupport;
23
using ReactNative.Modules.Core;
4+
using ReactNative.Modules.DevSupport;
35
using ReactNative.Tracing;
46
using ReactNative.UIManager;
57
using ReactNative.UIManager.Events;
@@ -71,6 +73,7 @@ public IReadOnlyList<Type> CreateJavaScriptModulesConfig()
7173
typeof(RCTNativeAppEventEmitter),
7274
typeof(AppRegistry),
7375
// TODO: some tracing module
76+
typeof(HMRClient),
7477
//typeof(RCTDebugComponentOwnership),
7578
};
7679
}

ReactWindows/ReactNative/DevSupport/DevInternalSettings.cs

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
using Windows.Storage;
1+
using ReactNative.Modules.DevSupport;
2+
using System.Collections.Generic;
3+
using Windows.Storage;
24

35
namespace ReactNative.DevSupport
46
{
5-
class DevInternalSettings
7+
class DevInternalSettings : IDeveloperSettings
68
{
7-
private const string JSDevModeDebugKey = "js_dev_mode_debug";
9+
private const string FpsDebugKey = "fps_debug";
810
private const string DebugServerHostKey = "debug_http_host";
11+
private const string JsDevModeDebugKey = "js_dev_mode_debug";
12+
private const string AnimationsDebugKey = "animations_debug";
13+
private const string JsMinifyDebugKey = "js_minify_debug";
14+
private const string ElementInspectorKey = "inspector_debug";
915
private const string ReloadOnJSChangeKey = "reload_on_js_change";
1016
private const string HotModuleReplacementKey = "hot_module_replacement";
1117

18+
private static readonly HashSet<string> s_triggerReload = new HashSet<string>
19+
{
20+
FpsDebugKey,
21+
ReloadOnJSChangeKey,
22+
JsDevModeDebugKey,
23+
JsMinifyDebugKey,
24+
};
25+
1226
private readonly IDevSupportManager _debugManager;
1327

1428
public DevInternalSettings(IDevSupportManager debugManager)
@@ -21,14 +35,14 @@ public bool IsJavaScriptDevModeEnabled
2135
get
2236
{
2337
#if DEBUG
24-
return GetSetting(JSDevModeDebugKey, true);
38+
return GetSetting(JsDevModeDebugKey, true);
2539
#else
2640
return GetSetting(JSDevModeDebugKey, false);
2741
#endif
2842
}
2943
set
3044
{
31-
SetSetting(JSDevModeDebugKey, value);
45+
SetSetting(JsDevModeDebugKey, value);
3246
}
3347
}
3448

@@ -44,6 +58,42 @@ public string DebugServerHost
4458
}
4559
}
4660

61+
public bool IsAnimationFpsDebugEnabled
62+
{
63+
get
64+
{
65+
return GetSetting(ReloadOnJSChangeKey, false);
66+
}
67+
set
68+
{
69+
SetSetting(ReloadOnJSChangeKey, value);
70+
}
71+
}
72+
73+
public bool IsElementInspectorEnabled
74+
{
75+
get
76+
{
77+
return GetSetting(ElementInspectorKey, false);
78+
}
79+
set
80+
{
81+
SetSetting(ElementInspectorKey, value);
82+
}
83+
}
84+
85+
public bool IsFpsDebugEnabled
86+
{
87+
get
88+
{
89+
return GetSetting(FpsDebugKey, false);
90+
}
91+
set
92+
{
93+
SetSetting(FpsDebugKey, value);
94+
}
95+
}
96+
4797
public bool IsHotModuleReplacementEnabled
4898
{
4999
get
@@ -56,6 +106,18 @@ public bool IsHotModuleReplacementEnabled
56106
}
57107
}
58108

109+
public bool IsJavaScriptMinifyEnabled
110+
{
111+
get
112+
{
113+
return GetSetting(JsMinifyDebugKey, false);
114+
}
115+
set
116+
{
117+
SetSetting(JsMinifyDebugKey, value);
118+
}
119+
}
120+
59121
public bool IsReloadOnJavaScriptChangeEnabled
60122
{
61123
get
@@ -87,7 +149,11 @@ private void SetSetting<T>(string key, T value)
87149
{
88150
var values = ApplicationData.Current.LocalSettings.Values;
89151
values[key] = value;
90-
_debugManager.ReloadSettings();
152+
153+
if (s_triggerReload.Contains(key))
154+
{
155+
_debugManager.ReloadSettings();
156+
}
91157
}
92158
}
93159
}

0 commit comments

Comments
 (0)