diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 20af2f68a65..00000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ -} \ No newline at end of file diff --git a/ReactWindows/Playground/Resources/main.dev.jsbundle b/ReactWindows/Playground/Resources/main.dev.jsbundle index 981a1293f29..48276199446 100644 --- a/ReactWindows/Playground/Resources/main.dev.jsbundle +++ b/ReactWindows/Playground/Resources/main.dev.jsbundle @@ -1196,12 +1196,12 @@ return ( React.createElement(View,{elevation:'1.0'}, React.createElement(View,{style:{marginLeft:20}}, React.createElement(View,{style:{borderLeftWidth:5,borderRightWidth:10,borderTopWidth:2, borderBottomWidth: 8}}, -React.createElement(View,{style:{margin:10,borderWidth:10,borderRadius:5,borderLeftColor:'red',borderRightColor:'blue',borderTopColor:'yellow',borderBottomColor:'green'}}, +React.createElement(View,{style:{margin:10,borderWidth:10,borderRadius:20,borderColor:'red'}}, React.createElement(View,{style:{padding:10,flexDirection:'row'}}, React.createElement(Switch,null), React.createElement(Text,{style:{color:'orange',flex:1}},"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec.")), React.createElement(View,null, -React.createElement(TextInput,{style:{height:40,color:'purple',borderWidth:5,borderColor:'purple'}})))))));}}); +React.createElement(TextInput,{style:{margin:10,height:40,color:'purple',borderWidth:5,borderColor:'purple'}})))))));}}); diff --git a/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs index 2275210dafd..19e6a70b69c 100644 --- a/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs +++ b/ReactWindows/ReactNative.Tests/Bridge/JavaScriptModuleRegistryTests.cs @@ -16,15 +16,15 @@ public class JavaScriptModuleRegistryTests [TestMethod] public void JavaScriptModuleRegistry_ArgumentChecks() { - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); var config = new JavaScriptModulesConfig.Builder().Build(); AssertEx.Throws( () => new JavaScriptModuleRegistry(null, config), - ex => Assert.AreEqual("catalystInstance", ex.ParamName)); + ex => Assert.AreEqual("reactInstance", ex.ParamName)); AssertEx.Throws( - () => new JavaScriptModuleRegistry(catalystInstance, null), + () => new JavaScriptModuleRegistry(reactInstance, null), ex => Assert.AreEqual("config", ex.ParamName)); } @@ -41,7 +41,7 @@ public void JavaScriptModuleRegistry_Invoke() var moduleIds = new List(); var methodIds = new List(); var argsList = new List(); - var catalystInstance = new MockCatalystInstance((moduleId, methodId, args, tracingName) => + var reactInstance = new MockReactInstance((moduleId, methodId, args, tracingName) => { moduleIds.Add(moduleId); methodIds.Add(methodId); @@ -49,7 +49,7 @@ public void JavaScriptModuleRegistry_Invoke() are.Set(); }); - var registry = new JavaScriptModuleRegistry(catalystInstance, config); + var registry = new JavaScriptModuleRegistry(reactInstance, config); var module = registry.GetJavaScriptModule(); module.Foo(42); @@ -71,8 +71,8 @@ public void JavaScriptModuleRegistry_Invoke() public void JavaScriptModuleRegistry_InvalidModule_Throws() { var config = new JavaScriptModulesConfig.Builder().Build(); - var catalystInstance = new MockCatalystInstance(); - var registry = new JavaScriptModuleRegistry(catalystInstance, config); + var reactInstance = new MockReactInstance(); + var registry = new JavaScriptModuleRegistry(reactInstance, config); AssertEx.Throws(() => registry.GetJavaScriptModule()); } diff --git a/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs b/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs index 54c07a90195..138fcb9e9c6 100644 --- a/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs +++ b/ReactWindows/ReactNative.Tests/Bridge/NativeModuleBaseTests.cs @@ -44,12 +44,12 @@ public void NativeModuleBase_Invocation_ArgumentNull() testModule.Initialize(); - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); AssertEx.Throws( () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(null, new JArray()), - ex => Assert.AreEqual("catalystInstance", ex.ParamName)); + ex => Assert.AreEqual("reactInstance", ex.ParamName)); AssertEx.Throws( - () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, null), + () => testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, null), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -60,9 +60,9 @@ public void NativeModuleBase_Invocation_ArgumentInvalidCount() testModule.Initialize(); - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); AssertEx.Throws( - () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, new JArray()), + () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, new JArray()), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -73,9 +73,9 @@ public void NativeModuleBase_Invocation_ArgumentConversionException() testModule.Initialize(); - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); AssertEx.Throws( - () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { default(object) })), + () => testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { default(object) })), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -90,13 +90,13 @@ public void NativeModuleBase_Invocation() Assert.AreEqual(2, testModule.Methods.Count); - var catalystInstance = new MockCatalystInstance(); - testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, new JArray()); - testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(catalystInstance, new JArray()); + var reactInstance = new MockReactInstance(); + testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray()); + testModule.Methods[nameof(TestNativeModule.Foo)].Invoke(reactInstance, new JArray()); Assert.AreEqual(2, fooCount); - testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 })); - testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(catalystInstance, JArray.FromObject(new[] { 17 })); + testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 42 })); + testModule.Methods[nameof(TestNativeModule.Bar)].Invoke(reactInstance, JArray.FromObject(new[] { 17 })); Assert.AreEqual(59, barSum); } @@ -110,13 +110,13 @@ public void NativeModuleBase_Invocation_Callbacks() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); - module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 })); + module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42 })); Assert.AreEqual(42, id); Assert.IsTrue(args.Cast().SequenceEqual(callbackArgs)); } @@ -131,14 +131,14 @@ public void NativeModuleBase_Invocation_Callbacks_InvalidArgumentThrows() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); AssertEx.Throws( - () => module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { default(object) })), + () => module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { default(object) })), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -151,13 +151,13 @@ public void NativeModuleBase_Invocation_Callbacks_NullCallback() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); - module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 })); + module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42 })); Assert.AreEqual(0, args.Count); } @@ -170,13 +170,13 @@ public void NativeModuleBase_Invocation_Promises_Resolve() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); - module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42, 43 })); + module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42, 43 })); Assert.AreEqual(42, id); Assert.IsTrue(args.SequenceEqual(new[] { 17 })); } @@ -185,7 +185,7 @@ public void NativeModuleBase_Invocation_Promises_Resolve() public void NativeModuleBase_CompiledDelegateFactory_Perf() { var module = new PerfNativeModule(CompiledReactDelegateFactory.Instance); - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); var args = JArray.FromObject(new[] { 42 }); module.Initialize(); @@ -193,7 +193,7 @@ public void NativeModuleBase_CompiledDelegateFactory_Perf() var n = 100000; for (var i = 0; i < n; ++i) { - module.Methods[nameof(PerfNativeModule.Foo)].Invoke(catalystInstance, args); + module.Methods[nameof(PerfNativeModule.Foo)].Invoke(reactInstance, args); } } @@ -206,18 +206,18 @@ public void NativeModuleBase_Invocation_Promises_InvalidArgumentThrows() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); AssertEx.Throws( - () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { default(object), 43 })), + () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { default(object), 43 })), ex => Assert.AreEqual("jsArguments", ex.ParamName)); AssertEx.Throws( - () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42, default(object) })), + () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42, default(object) })), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -230,14 +230,14 @@ public void NativeModuleBase_Invocation_Promises_IncorrectArgumentCount() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); AssertEx.Throws( - () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42 })), + () => module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42 })), ex => Assert.AreEqual("jsArguments", ex.ParamName)); } @@ -252,13 +252,13 @@ public void NativeModuleBase_Invocation_Promises_Reject() var id = default(int); var args = default(Dictionary[]); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject[]>(); }); - module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42, 43 })); + module.Methods[nameof(CallbackNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42, 43 })); Assert.AreEqual(43, id); Assert.AreEqual(1, args.Length); var d = args[0]; @@ -277,13 +277,13 @@ public void NativeModuleBase_Invocation_Promises_NullCallback() var id = default(int); var args = default(List); - var catalystInstance = new MockCatalystInstance((i, a) => + var reactInstance = new MockReactInstance((i, a) => { id = i; args = a.ToObject>(); }); - module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(catalystInstance, JArray.FromObject(new[] { 42, 43 })); + module.Methods[nameof(PromiseNativeModule.Foo)].Invoke(reactInstance, JArray.FromObject(new[] { 42, 43 })); Assert.AreEqual(1, args.Count); Assert.IsNull(args[0]); } @@ -292,7 +292,7 @@ public void NativeModuleBase_Invocation_Promises_NullCallback() public void NativeModuleBase_ReflectionDelegateFactory_Perf() { var module = new PerfNativeModule(ReflectionReactDelegateFactory.Instance); - var catalystInstance = new MockCatalystInstance(); + var reactInstance = new MockReactInstance(); var args = JArray.FromObject(new[] { 42 }); module.Initialize(); @@ -300,7 +300,7 @@ public void NativeModuleBase_ReflectionDelegateFactory_Perf() var n = 100000; for (var i = 0; i < n; ++i) { - module.Methods[nameof(PerfNativeModule.Foo)].Invoke(catalystInstance, args); + module.Methods[nameof(PerfNativeModule.Foo)].Invoke(reactInstance, args); } } diff --git a/ReactWindows/ReactNative.Tests/Hosting/Bridge/ReactBridgeTests.cs b/ReactWindows/ReactNative.Tests/Bridge/ReactBridgeTests.cs similarity index 99% rename from ReactWindows/ReactNative.Tests/Hosting/Bridge/ReactBridgeTests.cs rename to ReactWindows/ReactNative.Tests/Bridge/ReactBridgeTests.cs index 71c4ca97843..f9bdc06bdf4 100644 --- a/ReactWindows/ReactNative.Tests/Hosting/Bridge/ReactBridgeTests.cs +++ b/ReactWindows/ReactNative.Tests/Bridge/ReactBridgeTests.cs @@ -3,13 +3,12 @@ using Newtonsoft.Json.Linq; using ReactNative.Bridge; using ReactNative.Bridge.Queue; -using ReactNative.Hosting.Bridge; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -namespace ReactNative.Tests.Hosting.Bridge +namespace ReactNative.Tests.Bridge { [TestClass] public class ReactBridgeTests diff --git a/ReactWindows/ReactNative.Tests/Bridge/ReactContextTests.cs b/ReactWindows/ReactNative.Tests/Bridge/ReactContextTests.cs deleted file mode 100644 index 1ac0c0cfa06..00000000000 --- a/ReactWindows/ReactNative.Tests/Bridge/ReactContextTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; - -namespace ReactNative.Tests.Bridge -{ - [TestClass] - public class ReactContextTests - { - } -} diff --git a/ReactWindows/ReactNative.Tests/Bridge/CatalystInstanceTests.cs b/ReactWindows/ReactNative.Tests/Bridge/ReactInstanceTests.cs similarity index 85% rename from ReactWindows/ReactNative.Tests/Bridge/CatalystInstanceTests.cs rename to ReactWindows/ReactNative.Tests/Bridge/ReactInstanceTests.cs index ce40d16b69f..21f6b7abaf5 100644 --- a/ReactWindows/ReactNative.Tests/Bridge/CatalystInstanceTests.cs +++ b/ReactWindows/ReactNative.Tests/Bridge/ReactInstanceTests.cs @@ -9,10 +9,10 @@ namespace ReactNative.Tests.Bridge { [TestClass] - public class CatalystInstanceTests + public class ReactInstanceTests { [TestMethod] - public async Task CatalystInstance_GetModules() + public async Task ReactInstance_GetModules() { var module = new TestNativeModule(); @@ -25,9 +25,9 @@ public async Task CatalystInstance_GetModules() .Build(); var executor = new MockJavaScriptExecutor((p0, p1, p2) => JValue.CreateNull()); - var builder = new CatalystInstance.Builder() + var builder = new ReactInstance.Builder() { - QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default, + QueueConfigurationSpec = ReactQueueConfigurationSpec.Default, Registry = registry, JavaScriptModulesConfig = jsConfig, JavaScriptExecutorFactory = () => executor, @@ -48,7 +48,7 @@ public async Task CatalystInstance_GetModules() } [TestMethod] - public async Task CatalystInstance_Initialize_Dispose() + public async Task ReactInstance_Initialize_Dispose() { var module = new TestNativeModule(); @@ -59,9 +59,9 @@ public async Task CatalystInstance_Initialize_Dispose() var jsConfig = new JavaScriptModulesConfig.Builder().Build(); var executor = new MockJavaScriptExecutor((p0, p1, p2) => JValue.CreateNull()); - var builder = new CatalystInstance.Builder() + var builder = new ReactInstance.Builder() { - QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default, + QueueConfigurationSpec = ReactQueueConfigurationSpec.Default, Registry = registry, JavaScriptModulesConfig = jsConfig, JavaScriptExecutorFactory = () => executor, @@ -89,17 +89,17 @@ await DispatcherHelpers.RunOnDispatcherAsync(() => Assert.AreEqual(1, module.InitializeCalls); await DispatcherHelpers.RunOnDispatcherAsync(() => instance.Dispose()); - Assert.AreEqual(1, module.OnCatalystInstanceDisposeCalls); + Assert.AreEqual(1, module.OnReactInstanceDisposeCalls); // Dispose is idempotent await DispatcherHelpers.RunOnDispatcherAsync(() => instance.Dispose()); - Assert.AreEqual(1, module.OnCatalystInstanceDisposeCalls); + Assert.AreEqual(1, module.OnReactInstanceDisposeCalls); Assert.IsTrue(instance.IsDisposed); } [TestMethod] - public async Task CatalystInstance_ExceptionHandled_Disposes() + public async Task ReactInstance_ExceptionHandled_Disposes() { var eventHandler = new AutoResetEvent(false); var module = new OnDisposeNativeModule(() => eventHandler.Set()); @@ -117,9 +117,9 @@ public async Task CatalystInstance_ExceptionHandled_Disposes() Task.Run(() => tcs.SetResult(ex)); }); - var builder = new CatalystInstance.Builder() + var builder = new ReactInstance.Builder() { - QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default, + QueueConfigurationSpec = ReactQueueConfigurationSpec.Default, Registry = registry, JavaScriptModulesConfig = jsConfig, JavaScriptExecutorFactory = () => executor, @@ -148,7 +148,7 @@ public int InitializeCalls set; } - public int OnCatalystInstanceDisposeCalls + public int OnReactInstanceDisposeCalls { get; set; @@ -167,9 +167,9 @@ public override void Initialize() InitializeCalls++; } - public override void OnCatalystInstanceDispose() + public override void OnReactInstanceDispose() { - OnCatalystInstanceDisposeCalls++; + OnReactInstanceDisposeCalls++; } } @@ -190,7 +190,7 @@ public override string Name } } - public override void OnCatalystInstanceDispose() + public override void OnReactInstanceDispose() { _onDispose(); } diff --git a/ReactWindows/ReactNative.Tests/Hosting/Bridge/ChakraJavaScriptExecutorTests.cs b/ReactWindows/ReactNative.Tests/Chakra/Executor/ChakraJavaScriptExecutorTests.cs similarity index 91% rename from ReactWindows/ReactNative.Tests/Hosting/Bridge/ChakraJavaScriptExecutorTests.cs rename to ReactWindows/ReactNative.Tests/Chakra/Executor/ChakraJavaScriptExecutorTests.cs index 4760133d504..9eeee52e02f 100644 --- a/ReactWindows/ReactNative.Tests/Hosting/Bridge/ChakraJavaScriptExecutorTests.cs +++ b/ReactWindows/ReactNative.Tests/Chakra/Executor/ChakraJavaScriptExecutorTests.cs @@ -1,14 +1,9 @@ using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Newtonsoft.Json.Linq; -using ReactNative.Bridge; -using ReactNative.Bridge.Queue; -using ReactNative.Hosting.Bridge; using System; -using System.IO; using System.Threading.Tasks; -using Windows.Storage; -namespace ReactNative.Tests.Hosting.Bridge +namespace ReactNative.Tests.Chakra.Executor { [TestClass] public class ChakraJavaScriptExecutorTests diff --git a/ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs b/ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs index 5d3b10e7380..faccca9b31e 100644 --- a/ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs +++ b/ReactWindows/ReactNative.Tests/Internal/JavaScriptHelpers.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using ReactNative.Bridge.Queue; -using ReactNative.Hosting.Bridge; +using ReactNative.Chakra.Executor; using System; using System.IO; using System.Threading.Tasks; diff --git a/ReactWindows/ReactNative.Tests/Internal/MockCatalystInstance.cs b/ReactWindows/ReactNative.Tests/Internal/MockReactInstance.cs similarity index 82% rename from ReactWindows/ReactNative.Tests/Internal/MockCatalystInstance.cs rename to ReactWindows/ReactNative.Tests/Internal/MockReactInstance.cs index 5e8e8749a89..45192e588d9 100644 --- a/ReactWindows/ReactNative.Tests/Internal/MockCatalystInstance.cs +++ b/ReactWindows/ReactNative.Tests/Internal/MockReactInstance.cs @@ -7,27 +7,27 @@ namespace ReactNative.Tests { - class MockCatalystInstance : ICatalystInstance + class MockReactInstance : IReactInstance { private readonly Action _callback; private readonly Action _function; - public MockCatalystInstance() + public MockReactInstance() : this((_, __) => { }, (p0, p1, p2, p3) => { }) { } - public MockCatalystInstance(Action callback) + public MockReactInstance(Action callback) : this(callback, (p0, p1, p2, p3) => { }) { } - public MockCatalystInstance(Action function) + public MockReactInstance(Action function) : this((_, __) => { }, function) { } - public MockCatalystInstance(Action callback, Action function) + public MockReactInstance(Action callback, Action function) { _callback = callback; _function = function; @@ -49,7 +49,7 @@ public IEnumerable NativeModules } } - public ICatalystQueueConfiguration QueueConfiguration + public IReactQueueConfiguration QueueConfiguration { get { diff --git a/ReactWindows/ReactNative.Tests/Modules/Toast/ToastNotificationTests.cs b/ReactWindows/ReactNative.Tests/Modules/Toast/ToastNotificationTests.cs index fa41bdb0889..940ef0e322e 100644 --- a/ReactWindows/ReactNative.Tests/Modules/Toast/ToastNotificationTests.cs +++ b/ReactWindows/ReactNative.Tests/Modules/Toast/ToastNotificationTests.cs @@ -10,23 +10,19 @@ public class ToastNotificationTests { const string TEST_CATEGORY = "Modules"; - [TestMethod] - [TestCategory(TEST_CATEGORY)] + [TestMethod, TestCategory(TEST_CATEGORY)] public void ToastModule_Null_ArgumentsTest() { AssertEx.Throws( () => new ToastModule(null), ex => Assert.AreEqual("reactContext", ex.ParamName)); - var context = new ReactContext(); var module = new ToastModule(context); Assert.AreSame(context, module.Context); - } - [TestMethod] - [TestCategory(TEST_CATEGORY)] + [TestMethod, TestCategory(TEST_CATEGORY)] public void Send_Toast_Invalid_Duration() { var context = new ReactContext(); @@ -37,8 +33,8 @@ public void Send_Toast_Invalid_Duration() ex => Assert.AreEqual("duration", ex.ParamName)); } - [TestMethod] - [TestCategory(TEST_CATEGORY)] + [TestMethod, TestCategory(TEST_CATEGORY)] + [Ignore] public void Send_Basic_Toast() { var context = new ReactContext(); @@ -47,8 +43,8 @@ public void Send_Basic_Toast() module.show("SHORT TOAST", 0); } - [TestMethod] - [TestCategory(TEST_CATEGORY)] + [TestMethod, TestCategory(TEST_CATEGORY)] + [Ignore] public void Send_Long_Toast() { var context = new ReactContext(); @@ -56,7 +52,5 @@ public void Send_Long_Toast() module.show("LONG TOAST container", 1); } - - } } diff --git a/ReactWindows/ReactNative.Tests/ReactNative.Tests.csproj b/ReactWindows/ReactNative.Tests/ReactNative.Tests.csproj index 47bffc1f285..dfab8d0c322 100644 --- a/ReactWindows/ReactNative.Tests/ReactNative.Tests.csproj +++ b/ReactWindows/ReactNative.Tests/ReactNative.Tests.csproj @@ -95,22 +95,22 @@ - + - - + + - + @@ -121,7 +121,7 @@ - + diff --git a/ReactWindows/ReactNative.Tests/UIManager/Events/EventDispatcherTests.cs b/ReactWindows/ReactNative.Tests/UIManager/Events/EventDispatcherTests.cs index 971defceb33..5a25a0a1298 100644 --- a/ReactWindows/ReactNative.Tests/UIManager/Events/EventDispatcherTests.cs +++ b/ReactWindows/ReactNative.Tests/UIManager/Events/EventDispatcherTests.cs @@ -33,7 +33,7 @@ public async Task EventDispatcher_IncorrectThreadCalls() AssertEx.Throws(() => dispatcher.OnResume()); AssertEx.Throws(() => dispatcher.OnSuspend()); AssertEx.Throws(() => dispatcher.OnSuspend()); - AssertEx.Throws(() => dispatcher.OnCatalystInstanceDispose()); + AssertEx.Throws(() => dispatcher.OnReactInstanceDispose()); await DispatcherHelpers.RunOnDispatcherAsync(context.Dispose); } @@ -41,6 +41,7 @@ public async Task EventDispatcher_IncorrectThreadCalls() [TestMethod] public async Task EventDispatcher_EventDispatches() { + // TODO: check non-determinism var waitDispatched = new AutoResetEvent(false); var executor = new MockJavaScriptExecutor((p0, p1, p2) => { @@ -67,6 +68,7 @@ public async Task EventDispatcher_EventDispatches() [TestMethod] public async Task EventDispatcher_NonCoalesced() { + // TODO: check non-determinism var waitDispatched = new AutoResetEvent(false); var executor = new MockJavaScriptExecutor((p0, p1, p2) => { @@ -100,6 +102,7 @@ public async Task EventDispatcher_NonCoalesced() [TestMethod] public async Task EventDispatcher_MultipleDispatches() { + // TODO: check non-determinism var waitDispatched = new AutoResetEvent(false); var executor = new MockJavaScriptExecutor((p0, p1, p2) => { @@ -326,7 +329,7 @@ public async Task EventDispatcher_OnShutdown_EventDoesNotDispatch() } [TestMethod] - public async Task EventDispatcher_OnCatalystInstanceDispose_EventDoesNotDispatch() + public async Task EventDispatcher_OnReactInstanceDispose_EventDoesNotDispatch() { var waitDispatched = new AutoResetEvent(false); var executor = new MockJavaScriptExecutor((p0, p1, p2) => @@ -348,7 +351,7 @@ public async Task EventDispatcher_OnCatalystInstanceDispose_EventDoesNotDispatch using (BlockJavaScriptThread(context)) { dispatcher.DispatchEvent(testEvent); - await DispatcherHelpers.RunOnDispatcherAsync(dispatcher.OnCatalystInstanceDispose); + await DispatcherHelpers.RunOnDispatcherAsync(dispatcher.OnReactInstanceDispose); } Assert.IsFalse(waitDispatched.WaitOne(500)); @@ -359,6 +362,7 @@ public async Task EventDispatcher_OnCatalystInstanceDispose_EventDoesNotDispatch [TestMethod] public async Task EventDispatcher_DispatchedAfterSuspend_ThenResume() { + // TODO: check non-determinism var waitDispatched = new AutoResetEvent(false); var executor = new MockJavaScriptExecutor((p0, p1, p2) => { @@ -389,23 +393,23 @@ public async Task EventDispatcher_DispatchedAfterSuspend_ThenResume() private static async Task CreateContextAsync(IJavaScriptExecutor executor) { - var catalystInstance = await DispatcherHelpers.CallOnDispatcherAsync(() => CreateCatalystInstance(executor)); - await InitializeCatalystInstanceAsync(catalystInstance); + var reactInstance = await DispatcherHelpers.CallOnDispatcherAsync(() => CreateReactInstance(executor)); + await InitializeReactInstanceAsync(reactInstance); var context = new ReactContext(); - context.InitializeWithInstance(catalystInstance); + context.InitializeWithInstance(reactInstance); return context; } - private static CatalystInstance CreateCatalystInstance(IJavaScriptExecutor executor) + private static ReactInstance CreateReactInstance(IJavaScriptExecutor executor) { var registry = new NativeModuleRegistry.Builder().Build(); var jsModules = new JavaScriptModulesConfig.Builder() .Add() .Build(); - var instance = new CatalystInstance.Builder + var instance = new ReactInstance.Builder { - QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default, + QueueConfigurationSpec = ReactQueueConfigurationSpec.Default, BundleLoader = JavaScriptBundleLoader.CreateFileLoader("ms-appx:///Resources/test.js"), JavaScriptModulesConfig = jsModules, Registry = registry, @@ -418,9 +422,9 @@ private static CatalystInstance CreateCatalystInstance(IJavaScriptExecutor execu return instance; } - private static Task InitializeCatalystInstanceAsync(CatalystInstance catalystInstance) + private static Task InitializeReactInstanceAsync(ReactInstance reactInstance) { - return catalystInstance.InitializeBridgeAsync(); + return reactInstance.InitializeBridgeAsync(); } private static IDisposable BlockJavaScriptThread(ReactContext reactContext) diff --git a/ReactWindows/ReactNative.Tests/UIManager/CatalystStylesDiffMapTests.cs b/ReactWindows/ReactNative.Tests/UIManager/ReactStylesDiffMapTests.cs similarity index 76% rename from ReactWindows/ReactNative.Tests/UIManager/CatalystStylesDiffMapTests.cs rename to ReactWindows/ReactNative.Tests/UIManager/ReactStylesDiffMapTests.cs index a8a5ff489b3..731e1ea22cc 100644 --- a/ReactWindows/ReactNative.Tests/UIManager/CatalystStylesDiffMapTests.cs +++ b/ReactWindows/ReactNative.Tests/UIManager/ReactStylesDiffMapTests.cs @@ -7,18 +7,18 @@ namespace ReactNative.Tests.UIManager { [TestClass] - public class CatalystStylesDiffMapTests + public class ReactStylesDiffMapTests { [TestMethod] - public void CatalystStylesDiffMap_ArgumentChecks() + public void ReactStylesDiffMap_ArgumentChecks() { AssertEx.Throws( - () => new CatalystStylesDiffMap(null), + () => new ReactStylesDiffMap(null), ex => Assert.AreEqual("properties", ex.ParamName)); } [TestMethod] - public void CatalystStylesDiffMap_Behavior() + public void ReactStylesDiffMap_Behavior() { var json = new JObject { @@ -26,7 +26,7 @@ public void CatalystStylesDiffMap_Behavior() { "bar", "qux" }, }; - var properties = new CatalystStylesDiffMap(json); + var properties = new ReactStylesDiffMap(json); Assert.AreEqual(2, properties.Keys.Count); Assert.IsTrue(new[] { "bar", "foo" }.SequenceEqual(properties.Keys.OrderBy(k => k))); Assert.IsInstanceOfType(properties.GetProperty("foo", typeof(short)), typeof(short)); diff --git a/ReactWindows/ReactNative.Tests/UIManager/ViewManagersPropertyCacheTests.cs b/ReactWindows/ReactNative.Tests/UIManager/ViewManagersPropertyCacheTests.cs index 359d92d02b5..50d92ce2e6b 100644 --- a/ReactWindows/ReactNative.Tests/UIManager/ViewManagersPropertyCacheTests.cs +++ b/ReactWindows/ReactNative.Tests/UIManager/ViewManagersPropertyCacheTests.cs @@ -53,7 +53,7 @@ public void ViewManagersPropertyCache_ViewManager_Set() var setters = ViewManagersPropertyCache.GetNativePropertySettersForViewManagerType(typeof(ViewManagerValueTest)); Assert.AreEqual(3, setters.Count); - var properties = new CatalystStylesDiffMap(new JObject + var properties = new ReactStylesDiffMap(new JObject { { "Foo", "v1" }, { "Bar1", "v2" }, @@ -85,7 +85,7 @@ public void ViewManagersPropertyCache_ShadowNode_Set() var setters = ViewManagersPropertyCache.GetNativePropertySettersForShadowNodeType(typeof(ShadowNodeValueTest)); Assert.AreEqual(3, setters.Count); - var properties = new CatalystStylesDiffMap(new JObject + var properties = new ReactStylesDiffMap(new JObject { { "Foo", 42 }, { "Qux1", "v2" }, @@ -127,7 +127,7 @@ public void ViewManagersPropertyCache_Defaults() var instance = new DefaultsTest(); var setters = ViewManagersPropertyCache.GetNativePropertySettersForViewManagerType(typeof(DefaultsTest)); - var properties = new CatalystStylesDiffMap(new JObject()); + var properties = new ReactStylesDiffMap(new JObject()); instance.ByteValue = byte.MaxValue; instance.SByteValue = sbyte.MaxValue; diff --git a/ReactWindows/ReactNative/Bridge/BridgeBusyEventArgs.cs b/ReactWindows/ReactNative/Bridge/BridgeBusyEventArgs.cs index 76fcba99f86..f1132651f7a 100644 --- a/ReactWindows/ReactNative/Bridge/BridgeBusyEventArgs.cs +++ b/ReactWindows/ReactNative/Bridge/BridgeBusyEventArgs.cs @@ -3,7 +3,7 @@ namespace ReactNative.Bridge { /// - /// Event arguments sent when a is busy. + /// Event arguments sent when a is busy. /// public class BridgeBusyEventArgs : EventArgs { diff --git a/ReactWindows/ReactNative/Bridge/BridgeIdleEventArgs.cs b/ReactWindows/ReactNative/Bridge/BridgeIdleEventArgs.cs index d526846d9a2..2b009247340 100644 --- a/ReactWindows/ReactNative/Bridge/BridgeIdleEventArgs.cs +++ b/ReactWindows/ReactNative/Bridge/BridgeIdleEventArgs.cs @@ -3,7 +3,7 @@ namespace ReactNative.Bridge { /// - /// Event arguments sent when a is idle. + /// Event arguments sent when a is idle. /// public class BridgeIdleEventArgs : EventArgs { diff --git a/ReactWindows/ReactNative/Bridge/CompiledReactDelegateFactory.cs b/ReactWindows/ReactNative/Bridge/CompiledReactDelegateFactory.cs index be4fceececc..db712f584e9 100644 --- a/ReactWindows/ReactNative/Bridge/CompiledReactDelegateFactory.cs +++ b/ReactWindows/ReactNative/Bridge/CompiledReactDelegateFactory.cs @@ -17,8 +17,8 @@ public sealed class CompiledReactDelegateFactory : ReactDelegateFactoryBase private static readonly ConstructorInfo s_newArgumentException = (ConstructorInfo)ReflectionHelpers.InfoOf(() => new ArgumentException(default(string), default(string))); private static readonly ConstructorInfo s_newNativeArgumentParseException = (ConstructorInfo)ReflectionHelpers.InfoOf(() => new NativeArgumentsParseException(default(string), default(string))); private static readonly ConstructorInfo s_newNativeArgumentParseExceptionInner = (ConstructorInfo)ReflectionHelpers.InfoOf(() => new NativeArgumentsParseException(default(string), default(string), default(Exception))); - private static readonly MethodInfo s_createCallback = ((MethodInfo)ReflectionHelpers.InfoOf(() => CreateCallback(default(JToken), default(ICatalystInstance)))); - private static readonly MethodInfo s_createPromise = ((MethodInfo)ReflectionHelpers.InfoOf(() => CreatePromise(default(JToken), default(JToken), default(ICatalystInstance)))); + private static readonly MethodInfo s_createCallback = ((MethodInfo)ReflectionHelpers.InfoOf(() => CreateCallback(default(JToken), default(IReactInstance)))); + private static readonly MethodInfo s_createPromise = ((MethodInfo)ReflectionHelpers.InfoOf(() => CreatePromise(default(JToken), default(JToken), default(IReactInstance)))); private static readonly MethodInfo s_toObject = ((MethodInfo)ReflectionHelpers.InfoOf((JToken token) => token.ToObject(typeof(Type)))); private static readonly MethodInfo s_stringFormat = (MethodInfo)ReflectionHelpers.InfoOf(() => string.Format(default(IFormatProvider), default(string), default(object))); private static readonly MethodInfo s_getIndex = (MethodInfo)ReflectionHelpers.InfoOf((JArray arr) => arr[0]); @@ -37,12 +37,12 @@ private CompiledReactDelegateFactory() { } /// /// The method. /// The invocation delegate. - public override Action Create(INativeModule module, MethodInfo method) + public override Action Create(INativeModule module, MethodInfo method) { return GenerateExpression(module, method).Compile(); } - private static Expression> GenerateExpression(INativeModule module, MethodInfo method) + private static Expression> GenerateExpression(INativeModule module, MethodInfo method) { var parameterInfos = method.GetParameters(); @@ -53,7 +53,7 @@ private static Expression> Gene var extractExpressions = new Expression[n]; var moduleInstanceParameter = Expression.Parameter(typeof(INativeModule), "moduleInstance"); - var catalystInstanceParameter = Expression.Parameter(typeof(ICatalystInstance), "catalystInstance"); + var reactInstanceParameter = Expression.Parameter(typeof(IReactInstance), "reactInstance"); var jsArgumentsParameter = Expression.Parameter(typeof(JArray), "jsArguments"); for (var i = 0; i < n; ++i) @@ -66,7 +66,7 @@ private static Expression> Gene parameterInfo.ParameterType, parameterExpression, jsArgumentsParameter, - catalystInstanceParameter, + reactInstanceParameter, jsArgumentsParameter.Name, module.Name, method.Name, @@ -79,13 +79,13 @@ private static Expression> Gene // if (moduleInstance == null) // throw new ArgumentNullException(nameof(moduleInstance)); // - blockStatements[0] = CreateNullCheckExpression(moduleInstanceParameter); + blockStatements[0] = CreateNullCheckExpression(moduleInstanceParameter); // - // if (catalystInstance == null) - // throw new ArgumentNullException(nameof(catalystInstance)); + // if (reactInstance == null) + // throw new ArgumentNullException(nameof(reactInstance)); // - blockStatements[1] = CreateNullCheckExpression(catalystInstanceParameter); + blockStatements[1] = CreateNullCheckExpression(reactInstanceParameter); // // if (jsArguments == null) @@ -143,10 +143,10 @@ private static Expression> Gene method, parameterExpressions); - return Expression.Lambda>( + return Expression.Lambda>( Expression.Block(parameterExpressions, blockStatements), moduleInstanceParameter, - catalystInstanceParameter, + reactInstanceParameter, jsArgumentsParameter ); } @@ -155,7 +155,7 @@ private static Expression GenerateExtractExpression( Type type, Expression leftExpression, Expression argumentsExpression, - Expression catalystInstanceExpression, + Expression reactInstanceExpression, string parameterName, string moduleName, string methodName, @@ -199,7 +199,7 @@ private static Expression GenerateExtractExpression( if (type == typeof(ICallback)) { // - // CreateCallback(jsArguments[i], catalystInstance); + // CreateCallback(jsArguments[i], reactInstance); // valueExpression = Expression.Call( s_createCallback, @@ -208,7 +208,7 @@ private static Expression GenerateExtractExpression( s_getIndex, Expression.Constant(argumentIndex) ), - catalystInstanceExpression); + reactInstanceExpression); } else if (type == typeof(IPromise)) { @@ -216,7 +216,7 @@ private static Expression GenerateExtractExpression( // if (i > jsArguments.Count - 2) // throw new NativeArgumentsParseException(...); // - // CreatePromise(jsArguments[i], jsArguments[i + 1], catalystInstance); + // CreatePromise(jsArguments[i], jsArguments[i + 1], reactInstance); // valueExpression = Expression.Condition( Expression.Equal( @@ -241,7 +241,7 @@ private static Expression GenerateExtractExpression( s_getIndex, Expression.Constant(argumentIndex + 1) ), - catalystInstanceExpression + reactInstanceExpression ), Expression.Throw( Expression.New( diff --git a/ReactWindows/ReactNative/Bridge/INativeMethod.cs b/ReactWindows/ReactNative/Bridge/INativeMethod.cs index d42cb57a8ef..e293524c6e4 100644 --- a/ReactWindows/ReactNative/Bridge/INativeMethod.cs +++ b/ReactWindows/ReactNative/Bridge/INativeMethod.cs @@ -15,8 +15,8 @@ public interface INativeMethod /// /// Invoke the native method. /// - /// The catalyst instance. + /// The react instance. /// The arguments. - void Invoke(ICatalystInstance catalystInstance, JArray jsArguments); + void Invoke(IReactInstance reactInstance, JArray jsArguments); } } diff --git a/ReactWindows/ReactNative/Bridge/INativeModule.cs b/ReactWindows/ReactNative/Bridge/INativeModule.cs index 28e75e98ee9..210d0d1e524 100644 --- a/ReactWindows/ReactNative/Bridge/INativeModule.cs +++ b/ReactWindows/ReactNative/Bridge/INativeModule.cs @@ -3,7 +3,7 @@ namespace ReactNative.Bridge { /// - /// A native module whose API can be provided to JavaScript catalyst + /// A native module whose API can be provided to JavaScript react /// instances. /// /// @@ -42,15 +42,15 @@ public interface INativeModule string Name { get; } /// - /// Called after the creation of a , in - /// order to initialize native modules that require the catalyst or + /// Called after the creation of a , in + /// order to initialize native modules that require the react or /// JavaScript modules. /// void Initialize(); /// - /// Called before a is disposed. + /// Called before a is disposed. /// - void OnCatalystInstanceDispose(); + void OnReactInstanceDispose(); } } diff --git a/ReactWindows/ReactNative/Bridge/IReactDelegateFactory.cs b/ReactWindows/ReactNative/Bridge/IReactDelegateFactory.cs index 5389b1c3611..d6fc43a7a21 100644 --- a/ReactWindows/ReactNative/Bridge/IReactDelegateFactory.cs +++ b/ReactWindows/ReactNative/Bridge/IReactDelegateFactory.cs @@ -21,7 +21,7 @@ public interface IReactDelegateFactory /// /// The method. /// The invocation delegate. - Action Create(INativeModule module, MethodInfo method); + Action Create(INativeModule module, MethodInfo method); /// /// Check that the method is valid for . diff --git a/ReactWindows/ReactNative/Bridge/ICatalystInstance.cs b/ReactWindows/ReactNative/Bridge/IReactInstance.cs similarity index 88% rename from ReactWindows/ReactNative/Bridge/ICatalystInstance.cs rename to ReactWindows/ReactNative/Bridge/IReactInstance.cs index 522ea413789..590932c5d88 100644 --- a/ReactWindows/ReactNative/Bridge/ICatalystInstance.cs +++ b/ReactWindows/ReactNative/Bridge/IReactInstance.cs @@ -10,7 +10,7 @@ namespace ReactNative.Bridge /// environment allowing the invocation of JavaScript methods and lets a /// set of native APIs be invokable from JavaScript as well. /// - public interface ICatalystInstance : ICancelable + public interface IReactInstance : ICancelable { /// /// Enumerates the available native modules. @@ -18,12 +18,9 @@ public interface ICatalystInstance : ICancelable IEnumerable NativeModules { get; } /// - /// The catalyst queue configuration. + /// The react queue configuration. /// - /// - /// TODO: is it okay for this to be public? - /// - ICatalystQueueConfiguration QueueConfiguration { get; } + IReactQueueConfiguration QueueConfiguration { get; } /// /// Initializes the instance. diff --git a/ReactWindows/ReactNative/Bridge/JavaScriptBundleLoader.cs b/ReactWindows/ReactNative/Bridge/JavaScriptBundleLoader.cs index 5ac5e3b4f20..48d987c6283 100644 --- a/ReactWindows/ReactNative/Bridge/JavaScriptBundleLoader.cs +++ b/ReactWindows/ReactNative/Bridge/JavaScriptBundleLoader.cs @@ -7,7 +7,7 @@ namespace ReactNative.Bridge { /// /// A class that stores JavaScript bundle information and allows the - /// to load a correct bundle through the + /// to load a correct bundle through the /// . /// public abstract class JavaScriptBundleLoader diff --git a/ReactWindows/ReactNative/Bridge/JavaScriptModuleRegistry.cs b/ReactWindows/ReactNative/Bridge/JavaScriptModuleRegistry.cs index f4f51e1c908..7122a51b223 100644 --- a/ReactWindows/ReactNative/Bridge/JavaScriptModuleRegistry.cs +++ b/ReactWindows/ReactNative/Bridge/JavaScriptModuleRegistry.cs @@ -7,7 +7,7 @@ namespace ReactNative.Bridge { /// /// Class responsible for holding all s - /// registered to a . Requires that + /// registered to a . Requires that /// JavaScript modules use the base /// class, and implement each of it's methods to dispatch through the /// method. @@ -19,14 +19,14 @@ public class JavaScriptModuleRegistry /// /// Instantiates the . /// - /// The catalyst instance. + /// The react instance. /// The module configuration. public JavaScriptModuleRegistry( - ICatalystInstance catalystInstance, + IReactInstance reactInstance, JavaScriptModulesConfig config) { - if (catalystInstance == null) - throw new ArgumentNullException(nameof(catalystInstance)); + if (reactInstance == null) + throw new ArgumentNullException(nameof(reactInstance)); if (config == null) throw new ArgumentNullException(nameof(config)); @@ -35,7 +35,7 @@ public JavaScriptModuleRegistry( { var type = registration.ModuleInterface; var moduleInstance = (IJavaScriptModule)Activator.CreateInstance(type); - var invokeHandler = new JavaScriptModuleInvocationHandler(catalystInstance, registration); + var invokeHandler = new JavaScriptModuleInvocationHandler(reactInstance, registration); moduleInstance.InvocationHandler = invokeHandler; _moduleInstances.Add(type, moduleInstance); } @@ -63,21 +63,21 @@ public T GetJavaScriptModule() where T : IJavaScriptModule class JavaScriptModuleInvocationHandler : IInvocationHandler { - private readonly ICatalystInstance _catalystInstance; + private readonly IReactInstance _reactInstance; private readonly JavaScriptModuleRegistration _moduleRegistration; public JavaScriptModuleInvocationHandler( - ICatalystInstance catalystInstance, + IReactInstance reactInstance, JavaScriptModuleRegistration moduleRegistration) { - _catalystInstance = catalystInstance; + _reactInstance = reactInstance; _moduleRegistration = moduleRegistration; } public void Invoke(string name, object[] args) { var tracingName = _moduleRegistration.GetTracingName(name); - _catalystInstance.InvokeFunction( + _reactInstance.InvokeFunction( _moduleRegistration.ModuleId, _moduleRegistration.GetMethodId(name), JArray.FromObject(args), diff --git a/ReactWindows/ReactNative/Bridge/NativeModuleBase.cs b/ReactWindows/ReactNative/Bridge/NativeModuleBase.cs index 9c92f1cdc89..ba7c498ac1d 100644 --- a/ReactWindows/ReactNative/Bridge/NativeModuleBase.cs +++ b/ReactWindows/ReactNative/Bridge/NativeModuleBase.cs @@ -9,9 +9,9 @@ namespace ReactNative.Bridge { /// - /// Base class for catalyst native modules. Implementations can be linked + /// Base class for react native modules. Implementations can be linked /// to lifecycle events, such as the creation and disposal of the - /// by overriding the appropriate methods. + /// by overriding the appropriate methods. /// /// Native methods are exposed to JavaScript with the /// annotation. These methods may only @@ -28,7 +28,7 @@ namespace ReactNative.Bridge /// /// /// Default implementations of and - /// are provided for convenience. + /// are provided for convenience. /// Subclasses need not call these base methods should they choose to /// override them. /// @@ -117,8 +117,8 @@ public abstract string Name } /// - /// Called after the creation of a , in - /// order to initialize native modules that require the catalyst or + /// Called after the creation of a , in + /// order to initialize native modules that require the react or /// JavaScript modules. /// public virtual void Initialize() @@ -126,9 +126,9 @@ public virtual void Initialize() } /// - /// Called before a is disposed. + /// Called before a is disposed. /// - public virtual void OnCatalystInstanceDispose() + public virtual void OnReactInstanceDispose() { } @@ -168,7 +168,7 @@ private IReadOnlyDictionary InitializeMethods() class NativeMethod : INativeMethod { private readonly NativeModuleBase _instance; - private readonly Lazy> _invokeDelegate; + private readonly Lazy> _invokeDelegate; public NativeMethod(NativeModuleBase instance, MethodInfo method) { @@ -176,7 +176,7 @@ public NativeMethod(NativeModuleBase instance, MethodInfo method) var delegateFactory = instance._delegateFactory; delegateFactory.Validate(method); - _invokeDelegate = new Lazy>(() => delegateFactory.Create(instance, method)); + _invokeDelegate = new Lazy>(() => delegateFactory.Create(instance, method)); Type = delegateFactory.GetMethodType(method); } @@ -185,11 +185,11 @@ public string Type get; } - public void Invoke(ICatalystInstance catalystInstance, JArray jsArguments) + public void Invoke(IReactInstance reactInstance, JArray jsArguments) { using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "callNativeModuleMethod")) { - _invokeDelegate.Value(_instance, catalystInstance, jsArguments); + _invokeDelegate.Value(_instance, reactInstance, jsArguments); } } } diff --git a/ReactWindows/ReactNative/Bridge/NativeModuleRegistry.cs b/ReactWindows/ReactNative/Bridge/NativeModuleRegistry.cs index b97a332574f..2a9bcdec049 100644 --- a/ReactWindows/ReactNative/Bridge/NativeModuleRegistry.cs +++ b/ReactWindows/ReactNative/Bridge/NativeModuleRegistry.cs @@ -88,12 +88,12 @@ public void OnBatchComplete() /// /// Invoke a method on a native module. /// - /// The catalyst instance. + /// The react instance. /// The module ID. /// The method ID. /// The parameters. internal /* TODO: public? */ void Invoke( - ICatalystInstance catalystInstance, + IReactInstance reactInstance, int moduleId, int methodId, JArray parameters) @@ -103,17 +103,17 @@ public void OnBatchComplete() if (_moduleTable.Count < moduleId) throw new ArgumentOutOfRangeException("Call to unknown module: " + moduleId, nameof(moduleId)); - _moduleTable[moduleId].Invoke(catalystInstance, methodId, parameters); + _moduleTable[moduleId].Invoke(reactInstance, methodId, parameters); } /// - /// Hook to notify modules that the has + /// Hook to notify modules that the has /// been initialized. /// - internal /* TODO: public? */ void NotifyCatalystInstanceInitialize() + internal /* TODO: public? */ void NotifyReactInstanceInitialize() { DispatcherHelpers.AssertOnDispatcher(); - using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "NativeModuleRegistry_NotifyCatalystInstanceInitialize")) + using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "NativeModuleRegistry_NotifyReactInstanceInitialize")) { foreach (var module in _moduleInstances.Values) { @@ -123,17 +123,17 @@ public void OnBatchComplete() } /// - /// Hook to notify modules that the has + /// Hook to notify modules that the has /// been disposed. /// - internal /* TODO: public? */ void NotifyCatalystInstanceDispose() + internal /* TODO: public? */ void NotifyReactInstanceDispose() { DispatcherHelpers.AssertOnDispatcher(); - using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "NativeModuleRegistry_NotifyCatalystInstanceDestroy")) + using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "NativeModuleRegistry_NotifyReactInstanceDestroy")) { foreach (var module in _moduleInstances.Values) { - module.OnCatalystInstanceDispose(); + module.OnReactInstanceDispose(); } } } @@ -166,9 +166,9 @@ public ModuleDefinition(int id, string name, INativeModule target) public INativeModule Target { get; } - public void Invoke(ICatalystInstance catalystInstance, int methodId, JArray parameters) + public void Invoke(IReactInstance reactInstance, int methodId, JArray parameters) { - _methods[methodId].Method.Invoke(catalystInstance, parameters); + _methods[methodId].Method.Invoke(reactInstance, parameters); } public void WriteModuleDescription(JsonWriter writer) diff --git a/ReactWindows/ReactNative/Bridge/Queue/ICatalystQueueConfiguration.cs b/ReactWindows/ReactNative/Bridge/Queue/IReactQueueConfiguration.cs similarity index 83% rename from ReactWindows/ReactNative/Bridge/Queue/ICatalystQueueConfiguration.cs rename to ReactWindows/ReactNative/Bridge/Queue/IReactQueueConfiguration.cs index 221cfeb5d63..c10666f3e32 100644 --- a/ReactWindows/ReactNative/Bridge/Queue/ICatalystQueueConfiguration.cs +++ b/ReactWindows/ReactNative/Bridge/Queue/IReactQueueConfiguration.cs @@ -4,11 +4,11 @@ namespace ReactNative.Bridge.Queue { /// /// Specifies which s must be used to run - /// the various contexts of execution within catalyst (dispatcher, native + /// the various contexts of execution within react (dispatcher, native /// modules, and JS). Some of these queue *may* be the same but should be /// coded against as if they are different. /// - public interface ICatalystQueueConfiguration : IDisposable + public interface IReactQueueConfiguration : IDisposable { /// /// The main UI thread. diff --git a/ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfiguration.cs b/ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfiguration.cs similarity index 87% rename from ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfiguration.cs rename to ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfiguration.cs index 348ee656742..c4624184e40 100644 --- a/ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfiguration.cs +++ b/ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfiguration.cs @@ -4,17 +4,17 @@ namespace ReactNative.Bridge.Queue { /// /// Specifies which s must be used to run - /// the various contexts of execution within catalyst (dispatcher, native + /// the various contexts of execution within react (dispatcher, native /// modules, and JS). Some of these queue *may* be the same but should be /// coded against as if they are different. /// - class CatalystQueueConfiguration : ICatalystQueueConfiguration + class ReactQueueConfiguration : IReactQueueConfiguration { private readonly MessageQueueThread _dispatcherQueueThread; private readonly MessageQueueThread _nativeModulesQueueThread; private readonly MessageQueueThread _jsQueueThread; - private CatalystQueueConfiguration( + private ReactQueueConfiguration( MessageQueueThread dispatcherQueueThread, MessageQueueThread nativeModulesQueueThread, MessageQueueThread jsQueueThread) @@ -61,7 +61,7 @@ public IMessageQueueThread JavaScriptQueueThread /// Disposes the queue configuration. /// /// - /// Should be called whenever the corresponding + /// Should be called whenever the corresponding /// is disposed. /// public void Dispose() @@ -77,8 +77,8 @@ public void Dispose() /// The configuration specification. /// The exception handler. /// The queue configuration. - public static CatalystQueueConfiguration Create( - CatalystQueueConfigurationSpec spec, + public static ReactQueueConfiguration Create( + ReactQueueConfigurationSpec spec, Action exceptionHandler) { var dispatcherThreadSpec = MessageQueueThreadSpec.DispatcherThreadSpec; @@ -92,7 +92,7 @@ public static CatalystQueueConfiguration Create( ? MessageQueueThread.Create(spec.NativeModulesQueueThreadSpec, exceptionHandler) : dispatcherThread; - return new CatalystQueueConfiguration(dispatcherThread, nativeModulesThread, jsThread); + return new ReactQueueConfiguration(dispatcherThread, nativeModulesThread, jsThread); } } } diff --git a/ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfigurationSpec.cs b/ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfigurationSpec.cs similarity index 79% rename from ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfigurationSpec.cs rename to ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfigurationSpec.cs index 89a4284236b..22466797d05 100644 --- a/ReactWindows/ReactNative/Bridge/Queue/CatalystQueueConfigurationSpec.cs +++ b/ReactWindows/ReactNative/Bridge/Queue/ReactQueueConfigurationSpec.cs @@ -3,13 +3,13 @@ namespace ReactNative.Bridge.Queue { /// - /// Specification for creating a . - /// This exists so the is able to set + /// Specification for creating a . + /// This exists so the is able to set /// exception handlers on the s it uses. /// - public sealed class CatalystQueueConfigurationSpec + public sealed class ReactQueueConfigurationSpec { - private CatalystQueueConfigurationSpec( + private ReactQueueConfigurationSpec( MessageQueueThreadSpec nativeModulesQueueThreadSpec, MessageQueueThreadSpec jsQueueThreadSpec) { @@ -34,11 +34,11 @@ public MessageQueueThreadSpec JSQueueThreadSpec } /// - /// The default instance. + /// The default instance. /// - public static CatalystQueueConfigurationSpec Default { get; } = CreateDefault(); + public static ReactQueueConfigurationSpec Default { get; } = CreateDefault(); - private static CatalystQueueConfigurationSpec CreateDefault() + private static ReactQueueConfigurationSpec CreateDefault() { return new Builder() { @@ -49,7 +49,7 @@ private static CatalystQueueConfigurationSpec CreateDefault() } /// - /// Builder for . + /// Builder for . /// public sealed class Builder { @@ -89,10 +89,10 @@ public MessageQueueThreadSpec JSQueueThreadSpec } /// - /// Build the . + /// Build the . /// /// The instance. - public CatalystQueueConfigurationSpec Build() + public ReactQueueConfigurationSpec Build() { if (_nativeModulesQueueThreadSpec == null) { @@ -104,7 +104,7 @@ public CatalystQueueConfigurationSpec Build() throw new InvalidOperationException("JS queue thread spec has not been set."); } - return new CatalystQueueConfigurationSpec(_nativeModulesQueueThreadSpec, _jsQueueThreadSpec); + return new ReactQueueConfigurationSpec(_nativeModulesQueueThreadSpec, _jsQueueThreadSpec); } } } diff --git a/ReactWindows/ReactNative/Hosting/Bridge/ReactBridge.cs b/ReactWindows/ReactNative/Bridge/ReactBridge.cs similarity index 98% rename from ReactWindows/ReactNative/Hosting/Bridge/ReactBridge.cs rename to ReactWindows/ReactNative/Bridge/ReactBridge.cs index f7a4a26fbb5..1f91d97af72 100644 --- a/ReactWindows/ReactNative/Hosting/Bridge/ReactBridge.cs +++ b/ReactWindows/ReactNative/Bridge/ReactBridge.cs @@ -1,11 +1,10 @@ using Newtonsoft.Json.Linq; -using ReactNative.Bridge; using ReactNative.Bridge.Queue; using ReactNative.Common; using ReactNative.Tracing; using System; -namespace ReactNative.Hosting.Bridge +namespace ReactNative.Bridge { /// /// Class to the JavaScript execution environment and means of transport diff --git a/ReactWindows/ReactNative/Bridge/ReactContext.cs b/ReactWindows/ReactNative/Bridge/ReactContext.cs index 1a6ba9654da..581569ec65d 100644 --- a/ReactWindows/ReactNative/Bridge/ReactContext.cs +++ b/ReactWindows/ReactNative/Bridge/ReactContext.cs @@ -7,7 +7,7 @@ namespace ReactNative.Bridge { /// - /// Abstract context wrapper for the catalyst instance to manage + /// Abstract context wrapper for the react instance to manage /// lifecycle events. /// public class ReactContext : IDisposable @@ -16,28 +16,28 @@ public class ReactContext : IDisposable private readonly List _lifecycleEventListeners = new List(); - private ICatalystInstance _catalystInstance; + private IReactInstance _reactInstance; /// - /// The catalyst instance associated with the context. + /// The react instance associated with the context. /// - public ICatalystInstance CatalystInstance + public IReactInstance ReactInstance { get { - AssertCatalystInstance(); - return _catalystInstance; + AssertReactInstance(); + return _reactInstance; } } /// - /// Checks if the context has an active . + /// Checks if the context has an active . /// - public bool HasActiveCatalystInstance + public bool HasActiveReactInstance { get { - return _catalystInstance != null && !_catalystInstance.IsDisposed; + return _reactInstance != null && !_reactInstance.IsDisposed; } } @@ -52,35 +52,35 @@ public Action NativeModuleCallExceptionHandler /// /// Gets the instance of the associated - /// with the . + /// with the . /// /// Type of JavaScript module. /// The JavaScript module instance. public T GetJavaScriptModule() where T : IJavaScriptModule { - AssertCatalystInstance(); - return _catalystInstance.GetJavaScriptModule(); + AssertReactInstance(); + return _reactInstance.GetJavaScriptModule(); } /// /// Gets the instance of the associated - /// with the . + /// with the . /// /// Type of native module. /// The native module instance. public T GetNativeModule() where T : INativeModule { - AssertCatalystInstance(); - return _catalystInstance.GetNativeModule(); + AssertReactInstance(); + return _reactInstance.GetNativeModule(); } /// /// Adds a lifecycle event listener to the context. /// /// The listener. - public void AddLifecycleEventListener(ILifecycleEventListener listener) + public virtual void AddLifecycleEventListener(ILifecycleEventListener listener) { _lock.EnterWriteLock(); try @@ -97,7 +97,7 @@ public void AddLifecycleEventListener(ILifecycleEventListener listener) /// Removes a lifecycle event listener from the context. /// /// The listener. - public void RemoveLifecycleEventListener(ILifecycleEventListener listener) + public virtual void RemoveLifecycleEventListener(ILifecycleEventListener listener) { _lock.EnterWriteLock(); try @@ -184,15 +184,15 @@ public void Dispose() listener.OnDestroy(); } - var catalystInstance = _catalystInstance; - if (catalystInstance != null) + var reactInstance = _reactInstance; + if (reactInstance != null) { - catalystInstance.Dispose(); + reactInstance.Dispose(); } } /// - /// Checks if the current thread is on the catalyst instance dispatcher + /// Checks if the current thread is on the react instance dispatcher /// queue thread. /// /// @@ -201,18 +201,18 @@ public void Dispose() /// public bool IsOnDispatcherQueueThread() { - AssertCatalystInstance(); - return _catalystInstance.QueueConfiguration.DispatcherQueueThread.IsOnThread(); + AssertReactInstance(); + return _reactInstance.QueueConfiguration.DispatcherQueueThread.IsOnThread(); } /// - /// Asserts that the current thread is on the catalyst instance native + /// Asserts that the current thread is on the react instance native /// modules queue thread. /// public void AssertOnDispatcherQueueThread() { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.DispatcherQueueThread.AssertOnThread(); + AssertReactInstance(); + _reactInstance.QueueConfiguration.DispatcherQueueThread.AssertOnThread(); } /// @@ -221,12 +221,12 @@ public void AssertOnDispatcherQueueThread() /// The action. public void RunOnDispatcherQueueThread(Action action) { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.DispatcherQueueThread.RunOnQueue(action); + AssertReactInstance(); + _reactInstance.QueueConfiguration.DispatcherQueueThread.RunOnQueue(action); } /// - /// Checks if the current thread is on the catalyst instance + /// Checks if the current thread is on the react instance /// JavaScript queue thread. /// /// @@ -235,18 +235,18 @@ public void RunOnDispatcherQueueThread(Action action) /// public bool IsOnJavaScriptQueueThread() { - AssertCatalystInstance(); - return _catalystInstance.QueueConfiguration.JavaScriptQueueThread.IsOnThread(); + AssertReactInstance(); + return _reactInstance.QueueConfiguration.JavaScriptQueueThread.IsOnThread(); } /// - /// Asserts that the current thread is on the catalyst instance + /// Asserts that the current thread is on the react instance /// JavaScript queue thread. /// public void AssertOnJavaScriptQueueThread() { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.JavaScriptQueueThread.AssertOnThread(); + AssertReactInstance(); + _reactInstance.QueueConfiguration.JavaScriptQueueThread.AssertOnThread(); } /// @@ -255,12 +255,12 @@ public void AssertOnJavaScriptQueueThread() /// The action. public void RunOnJavaScriptQueueThread(Action action) { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.JavaScriptQueueThread.RunOnQueue(action); + AssertReactInstance(); + _reactInstance.QueueConfiguration.JavaScriptQueueThread.RunOnQueue(action); } /// - /// Checks if the current thread is on the catalyst instance native + /// Checks if the current thread is on the react instance native /// modules queue thread. /// /// @@ -269,18 +269,18 @@ public void RunOnJavaScriptQueueThread(Action action) /// public bool IsOnNativeModulesQueueThread() { - AssertCatalystInstance(); - return _catalystInstance.QueueConfiguration.NativeModulesQueueThread.IsOnThread(); + AssertReactInstance(); + return _reactInstance.QueueConfiguration.NativeModulesQueueThread.IsOnThread(); } /// - /// Asserts that the current thread is on the catalyst instance native + /// Asserts that the current thread is on the react instance native /// modules queue thread. /// public void AssertOnNativeModulesQueueThread() { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.NativeModulesQueueThread.AssertOnThread(); + AssertReactInstance(); + _reactInstance.QueueConfiguration.NativeModulesQueueThread.AssertOnThread(); } /// @@ -289,8 +289,8 @@ public void AssertOnNativeModulesQueueThread() /// The action. public void RunOnNativeModulesQueueThread(Action action) { - AssertCatalystInstance(); - _catalystInstance.QueueConfiguration.NativeModulesQueueThread.RunOnQueue(action); + AssertReactInstance(); + _reactInstance.QueueConfiguration.NativeModulesQueueThread.RunOnQueue(action); } /// @@ -302,8 +302,8 @@ public void RunOnNativeModulesQueueThread(Action action) public void HandleException(Exception exception) { var nativeModuleCallExceptionHandler = NativeModuleCallExceptionHandler; - if (_catalystInstance != null && - !_catalystInstance.IsDisposed && + if (_reactInstance != null && + !_reactInstance.IsDisposed && nativeModuleCallExceptionHandler != null) { nativeModuleCallExceptionHandler(exception); @@ -316,31 +316,31 @@ public void HandleException(Exception exception) } /// - /// Set and initialize the instance + /// Set and initialize the instance /// for this context. /// - /// The catalyst instance. + /// The react instance. /// /// This method should be called exactly once. /// - internal void InitializeWithInstance(ICatalystInstance instance) + internal void InitializeWithInstance(IReactInstance instance) { if (instance == null) throw new ArgumentNullException(nameof(instance)); - if (_catalystInstance != null) + if (_reactInstance != null) { - throw new InvalidOperationException("Catalyst instance has already been set."); + throw new InvalidOperationException("React instance has already been set."); } - _catalystInstance = instance; + _reactInstance = instance; } - private void AssertCatalystInstance() + private void AssertReactInstance() { - if (_catalystInstance == null) + if (_reactInstance == null) { - throw new InvalidOperationException("Catalyst instance has not been set."); + throw new InvalidOperationException("React instance has not been set."); } } } diff --git a/ReactWindows/ReactNative/Bridge/ReactContextNativeModuleBase.cs b/ReactWindows/ReactNative/Bridge/ReactContextNativeModuleBase.cs index ae32f2b9116..852e3e0c301 100644 --- a/ReactWindows/ReactNative/Bridge/ReactContextNativeModuleBase.cs +++ b/ReactWindows/ReactNative/Bridge/ReactContextNativeModuleBase.cs @@ -3,7 +3,7 @@ namespace ReactNative.Bridge { /// - /// Base class for catalyst native modules that require access to the + /// Base class for react native modules that require access to the /// . /// public abstract class ReactContextNativeModuleBase : NativeModuleBase diff --git a/ReactWindows/ReactNative/Bridge/ReactDelegateFactoryBase.cs b/ReactWindows/ReactNative/Bridge/ReactDelegateFactoryBase.cs index 29896e8663a..95ec0c28545 100644 --- a/ReactWindows/ReactNative/Bridge/ReactDelegateFactoryBase.cs +++ b/ReactWindows/ReactNative/Bridge/ReactDelegateFactoryBase.cs @@ -26,7 +26,7 @@ protected ReactDelegateFactoryBase() { } /// /// The method. /// The invocation delegate. - public abstract Action Create(INativeModule module, MethodInfo method); + public abstract Action Create(INativeModule module, MethodInfo method); /// /// Extracts the native method type from the method. @@ -88,12 +88,12 @@ public void Validate(MethodInfo method) /// Create a callback. /// /// The callback ID token. - /// The catalyst instance. + /// The react instance. /// The callback. - protected static ICallback CreateCallback(JToken callbackToken, ICatalystInstance catalystInstance) + protected static ICallback CreateCallback(JToken callbackToken, IReactInstance reactInstance) { var id = callbackToken.Value(); - return new Callback(id, catalystInstance); + return new Callback(id, reactInstance); } /// @@ -101,12 +101,12 @@ protected static ICallback CreateCallback(JToken callbackToken, ICatalystInstanc /// /// The resolve callback ID token. /// The reject callback ID token. - /// The catalyst instance. + /// The react instance. /// The promise. - protected static IPromise CreatePromise(JToken resolveToken, JToken rejectToken, ICatalystInstance catalystInstance) + protected static IPromise CreatePromise(JToken resolveToken, JToken rejectToken, IReactInstance reactInstance) { - var resolveCallback = CreateCallback(resolveToken, catalystInstance); - var rejectCallback = CreateCallback(rejectToken, catalystInstance); + var resolveCallback = CreateCallback(resolveToken, reactInstance); + var rejectCallback = CreateCallback(rejectToken, reactInstance); return new Promise(resolveCallback, rejectCallback); } @@ -115,9 +115,9 @@ class Callback : ICallback private static readonly object[] s_empty = new object[0]; private readonly int _id; - private readonly ICatalystInstance _instance; + private readonly IReactInstance _instance; - public Callback(int id, ICatalystInstance instance) + public Callback(int id, IReactInstance instance) { _id = id; _instance = instance; diff --git a/ReactWindows/ReactNative/Bridge/CatalystInstance.cs b/ReactWindows/ReactNative/Bridge/ReactInstance.cs similarity index 90% rename from ReactWindows/ReactNative/Bridge/CatalystInstance.cs rename to ReactWindows/ReactNative/Bridge/ReactInstance.cs index cb79272b651..223a3e6a24a 100644 --- a/ReactWindows/ReactNative/Bridge/CatalystInstance.cs +++ b/ReactWindows/ReactNative/Bridge/ReactInstance.cs @@ -2,7 +2,6 @@ using Newtonsoft.Json.Linq; using ReactNative.Bridge.Queue; using ReactNative.Common; -using ReactNative.Hosting.Bridge; using ReactNative.Tracing; using System; using System.Collections.Generic; @@ -17,7 +16,7 @@ namespace ReactNative.Bridge /// A higher level API on top of the and module registries. This provides an /// environment allowing the invocation of JavaScript methods. /// - class CatalystInstance : ICatalystInstance, IDisposable + class ReactInstance : IReactInstance, IDisposable { private readonly NativeModuleRegistry _registry; private readonly JavaScriptModuleRegistry _jsRegistry; @@ -32,8 +31,8 @@ class CatalystInstance : ICatalystInstance, IDisposable private int _pendingJsCalls; - private CatalystInstance( - CatalystQueueConfigurationSpec catalystQueueConfigurationSpec, + private ReactInstance( + ReactQueueConfigurationSpec reactQueueConfigurationSpec, Func jsExecutorFactory, NativeModuleRegistry registry, JavaScriptModulesConfig jsModulesConfig, @@ -47,8 +46,8 @@ private CatalystInstance( _bundleLoader = bundleLoader; _jsRegistry = new JavaScriptModuleRegistry(this, _jsModulesConfig); - QueueConfiguration = CatalystQueueConfiguration.Create( - catalystQueueConfigurationSpec, + QueueConfiguration = ReactQueueConfiguration.Create( + reactQueueConfigurationSpec, HandleException); } @@ -70,7 +69,7 @@ public IEnumerable NativeModules } } - public ICatalystQueueConfiguration QueueConfiguration + public IReactQueueConfiguration QueueConfiguration { get; } @@ -90,11 +89,11 @@ public void Initialize() DispatcherHelpers.AssertOnDispatcher(); if (_initialized) { - throw new InvalidOperationException("This catalyst instance has already been initialized."); + throw new InvalidOperationException("This react instance has already been initialized."); } _initialized = true; - _registry.NotifyCatalystInstanceInitialize(); + _registry.NotifyReactInstanceInitialize(); } public async Task InitializeBridgeAsync() @@ -182,7 +181,7 @@ public void Dispose() } IsDisposed = true; - _registry.NotifyCatalystInstanceDispose(); + _registry.NotifyReactInstanceDispose(); QueueConfiguration.Dispose(); if (Interlocked.Exchange(ref _pendingJsCalls, 0) != 0) @@ -251,18 +250,18 @@ private void OnBridgeBusy() public sealed class Builder { - private CatalystQueueConfigurationSpec _catalystQueueConfigurationSpec; + private ReactQueueConfigurationSpec _reactQueueConfigurationSpec; private NativeModuleRegistry _registry; private JavaScriptModulesConfig _jsModulesConfig; private Func _jsExecutorFactory; private JavaScriptBundleLoader _bundleLoader; private Action _nativeModuleCallExceptionHandler; - public CatalystQueueConfigurationSpec QueueConfigurationSpec + public ReactQueueConfigurationSpec QueueConfigurationSpec { set { - _catalystQueueConfigurationSpec = value; + _reactQueueConfigurationSpec = value; } } @@ -306,17 +305,17 @@ public Action NativeModuleCallExceptionHandler } } - public CatalystInstance Build() + public ReactInstance Build() { - AssertNotNull(_catalystQueueConfigurationSpec, nameof(QueueConfigurationSpec)); + AssertNotNull(_reactQueueConfigurationSpec, nameof(QueueConfigurationSpec)); AssertNotNull(_jsExecutorFactory, nameof(JavaScriptExecutorFactory)); AssertNotNull(_registry, nameof(Registry)); AssertNotNull(_jsModulesConfig, nameof(JavaScriptModulesConfig)); AssertNotNull(_bundleLoader, nameof(BundleLoader)); AssertNotNull(_nativeModuleCallExceptionHandler, nameof(NativeModuleCallExceptionHandler)); - return new CatalystInstance( - _catalystQueueConfigurationSpec, + return new ReactInstance( + _reactQueueConfigurationSpec, _jsExecutorFactory, _registry, _jsModulesConfig, @@ -337,9 +336,9 @@ private void AssertNotNull(object value, string name) class NativeModulesReactCallback : IReactCallback { - private readonly CatalystInstance _parent; + private readonly ReactInstance _parent; - public NativeModulesReactCallback(CatalystInstance parent) + public NativeModulesReactCallback(ReactInstance parent) { _parent = parent; } diff --git a/ReactWindows/ReactNative/ReactMethodAttribute.cs b/ReactWindows/ReactNative/Bridge/ReactMethodAttribute.cs similarity index 90% rename from ReactWindows/ReactNative/ReactMethodAttribute.cs rename to ReactWindows/ReactNative/Bridge/ReactMethodAttribute.cs index af5f8b679e4..e75ab045691 100644 --- a/ReactWindows/ReactNative/ReactMethodAttribute.cs +++ b/ReactWindows/ReactNative/Bridge/ReactMethodAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace ReactNative +namespace ReactNative.Bridge { /// /// An attribute for annotating methods in an diff --git a/ReactWindows/ReactNative/Bridge/ReflectionReactDelegateFactory.cs b/ReactWindows/ReactNative/Bridge/ReflectionReactDelegateFactory.cs index 132d7a431d8..3d4c93ac285 100644 --- a/ReactWindows/ReactNative/Bridge/ReflectionReactDelegateFactory.cs +++ b/ReactWindows/ReactNative/Bridge/ReflectionReactDelegateFactory.cs @@ -25,19 +25,19 @@ private ReflectionReactDelegateFactory() { } /// /// The method. /// The invocation delegate. - public override Action Create(INativeModule module, MethodInfo method) + public override Action Create(INativeModule module, MethodInfo method) { var extractors = CreateExtractors(module, method); var expectedArguments = extractors.Sum(e => e.ExpectedArguments); var extractFunctions = extractors.Select(e => e.ExtractFunction).ToList(); - return (moduleInstance, catalystInstance, arguments) => + return (moduleInstance, reactInstance, arguments) => Invoke( method, expectedArguments, extractFunctions, moduleInstance, - catalystInstance, + reactInstance, arguments); } @@ -66,13 +66,13 @@ private Extractor CreateExtractor(Type type, string moduleName, string methodNam { return new Extractor( 1, - (catalystInstance, arguments, index) => + (reactInstance, arguments, index) => { try { return new Result( index + 1, - CreateCallback(arguments[index], catalystInstance)); + CreateCallback(arguments[index], reactInstance)); } catch (Exception ex) { @@ -87,7 +87,7 @@ private Extractor CreateExtractor(Type type, string moduleName, string methodNam { return new Extractor( 2, - (catalystInstance, arguments, index) => + (reactInstance, arguments, index) => { var nextIndex = index + 1; if (nextIndex >= arguments.Count) @@ -101,7 +101,7 @@ private Extractor CreateExtractor(Type type, string moduleName, string methodNam { return new Result( nextIndex + 1, - CreatePromise(arguments[index], arguments[nextIndex], catalystInstance)); + CreatePromise(arguments[index], arguments[nextIndex], reactInstance)); } catch (Exception ex) { @@ -116,7 +116,7 @@ private Extractor CreateExtractor(Type type, string moduleName, string methodNam { return new Extractor( 1, - (catalystInstance, arguments, index) => + (reactInstance, arguments, index) => { try { @@ -138,15 +138,15 @@ private Extractor CreateExtractor(Type type, string moduleName, string methodNam private static void Invoke( MethodInfo method, int expectedArguments, - IList> extractors, + IList> extractors, INativeModule moduleInstance, - ICatalystInstance catalystInstance, + IReactInstance reactInstance, JArray jsArguments) { if (moduleInstance == null) throw new ArgumentNullException(nameof(moduleInstance)); - if (catalystInstance == null) - throw new ArgumentNullException(nameof(catalystInstance)); + if (reactInstance == null) + throw new ArgumentNullException(nameof(reactInstance)); if (jsArguments == null) throw new ArgumentNullException(nameof(jsArguments)); @@ -168,7 +168,7 @@ private static void Invoke( var args = new object[extractors.Count]; for (var j = 0; j < c; ++j) { - var result = extractors[j](catalystInstance, jsArguments, idx); + var result = extractors[j](reactInstance, jsArguments, idx); args[j] = result.Value; idx = result.NextIndex; } @@ -191,14 +191,14 @@ public Result(int nextIndex, object value) private struct Extractor { - public Extractor(int expectedArguments, Func extractFunction) + public Extractor(int expectedArguments, Func extractFunction) { ExpectedArguments = expectedArguments; ExtractFunction = extractFunction; } public int ExpectedArguments { get; } - public Func ExtractFunction { get; } + public Func ExtractFunction { get; } } } } diff --git a/ReactWindows/ReactNative/Hosting/Bridge/ChakraJavaScriptExecutor.cs b/ReactWindows/ReactNative/Chakra/Executor/ChakraJavaScriptExecutor.cs similarity index 83% rename from ReactWindows/ReactNative/Hosting/Bridge/ChakraJavaScriptExecutor.cs rename to ReactWindows/ReactNative/Chakra/Executor/ChakraJavaScriptExecutor.cs index 9cd1060f023..bf23510ca0d 100644 --- a/ReactWindows/ReactNative/Hosting/Bridge/ChakraJavaScriptExecutor.cs +++ b/ReactWindows/ReactNative/Chakra/Executor/ChakraJavaScriptExecutor.cs @@ -7,7 +7,7 @@ using Windows.System.Profile; #endif -namespace ReactNative.Hosting.Bridge +namespace ReactNative.Chakra.Executor { /// /// JavaScript runtime wrapper. @@ -142,7 +142,6 @@ private void InitializeChakra() { JavaScriptContext.StartDebugging(); } - #endif var consolePropertyId = default(JavaScriptPropertyId); @@ -152,9 +151,9 @@ private void InitializeChakra() var consoleObject = JavaScriptValue.CreateObject(); JavaScriptValue.GlobalObject.SetProperty(consolePropertyId, consoleObject, true); - DefineHostCallback(consoleObject, "log", ConsoleCallback, IntPtr.Zero); - DefineHostCallback(consoleObject, "warn", ConsoleCallback, IntPtr.Zero); - DefineHostCallback(consoleObject, "error", ConsoleCallback, IntPtr.Zero); + DefineHostCallback(consoleObject, "log", ConsoleLog, IntPtr.Zero); + DefineHostCallback(consoleObject, "warn", ConsoleWarn, IntPtr.Zero); + DefineHostCallback(consoleObject, "error", ConsoleError, IntPtr.Zero); Debug.WriteLine("Chakra initialization successful."); } @@ -170,7 +169,40 @@ private static void DefineHostCallback( obj.SetProperty(propertyId, function, true); } + #region Console Callbacks + + private static JavaScriptValue ConsoleLog( + JavaScriptValue callee, + bool isConstructCall, + JavaScriptValue[] arguments, + ushort argumentCount, + IntPtr callbackData) + { + return ConsoleCallback("Log", callee, isConstructCall, arguments, argumentCount, callbackData); + } + + private static JavaScriptValue ConsoleWarn( + JavaScriptValue callee, + bool isConstructCall, + JavaScriptValue[] arguments, + ushort argumentCount, + IntPtr callbackData) + { + return ConsoleCallback("Warn", callee, isConstructCall, arguments, argumentCount, callbackData); + } + + private static JavaScriptValue ConsoleError( + JavaScriptValue callee, + bool isConstructCall, + JavaScriptValue[] arguments, + ushort argumentCount, + IntPtr callbackData) + { + return ConsoleCallback("Error", callee, isConstructCall, arguments, argumentCount, callbackData); + } + private static JavaScriptValue ConsoleCallback( + string kind, JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, @@ -179,7 +211,7 @@ private static JavaScriptValue ConsoleCallback( { try { - Debug.Write("JS console> "); + Debug.Write("Chakra " + kind + ">"); // First argument is this-context, ignore... for (var i = 1; i < argumentCount; ++i) @@ -192,7 +224,7 @@ private static JavaScriptValue ConsoleCallback( catch (Exception ex) { Debug.WriteLine( - "#EXCEPTION in ChakraExecutor::ConsoleCallback()! " + ex.Message); + "Error in ChakraExecutor.ConsoleCallback: " + ex.Message); } return JavaScriptValue.Invalid; @@ -218,5 +250,7 @@ private static string Stringify(JavaScriptValue value) throw new NotImplementedException(); } } + + #endregion } } diff --git a/ReactWindows/ReactNative/Hosting/Bridge/JTokenToJavaScriptValueConverter.cs b/ReactWindows/ReactNative/Chakra/Executor/JTokenToJavaScriptValueConverter.cs similarity index 98% rename from ReactWindows/ReactNative/Hosting/Bridge/JTokenToJavaScriptValueConverter.cs rename to ReactWindows/ReactNative/Chakra/Executor/JTokenToJavaScriptValueConverter.cs index f2931444b97..15749fc8e14 100644 --- a/ReactWindows/ReactNative/Hosting/Bridge/JTokenToJavaScriptValueConverter.cs +++ b/ReactWindows/ReactNative/Chakra/Executor/JTokenToJavaScriptValueConverter.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json.Linq; using System; -namespace ReactNative.Hosting.Bridge +namespace ReactNative.Chakra.Executor { sealed class JTokenToJavaScriptValueConverter { diff --git a/ReactWindows/ReactNative/Hosting/Bridge/JavaScriptValueToJTokenConverter.cs b/ReactWindows/ReactNative/Chakra/Executor/JavaScriptValueToJTokenConverter.cs similarity index 98% rename from ReactWindows/ReactNative/Hosting/Bridge/JavaScriptValueToJTokenConverter.cs rename to ReactWindows/ReactNative/Chakra/Executor/JavaScriptValueToJTokenConverter.cs index f40a677796f..567795378b4 100644 --- a/ReactWindows/ReactNative/Hosting/Bridge/JavaScriptValueToJTokenConverter.cs +++ b/ReactWindows/ReactNative/Chakra/Executor/JavaScriptValueToJTokenConverter.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json.Linq; using System; -namespace ReactNative.Hosting.Bridge +namespace ReactNative.Chakra.Executor { sealed class JavaScriptValueToJTokenConverter { diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptBackgroundWorkItemCallback.cs b/ReactWindows/ReactNative/Chakra/JavaScriptBackgroundWorkItemCallback.cs similarity index 93% rename from ReactWindows/ReactNative/Hosting/JavaScriptBackgroundWorkItemCallback.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptBackgroundWorkItemCallback.cs index 18ac1aa4536..15d379e9d61 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptBackgroundWorkItemCallback.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptBackgroundWorkItemCallback.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptBeforeCollectCallback.cs b/ReactWindows/ReactNative/Chakra/JavaScriptBeforeCollectCallback.cs similarity index 89% rename from ReactWindows/ReactNative/Hosting/JavaScriptBeforeCollectCallback.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptBeforeCollectCallback.cs index 06643a89dba..71ab3e7dca1 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptBeforeCollectCallback.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptBeforeCollectCallback.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptContext.cs b/ReactWindows/ReactNative/Chakra/JavaScriptContext.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptContext.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptContext.cs index bfa6ca20f84..1d64791f251 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptContext.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptContext.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptEngineException.cs b/ReactWindows/ReactNative/Chakra/JavaScriptEngineException.cs similarity index 97% rename from ReactWindows/ReactNative/Hosting/JavaScriptEngineException.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptEngineException.cs index 86098f48818..d250a9671a3 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptEngineException.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptEngineException.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.Serialization; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptErrorCode.cs b/ReactWindows/ReactNative/Chakra/JavaScriptErrorCode.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptErrorCode.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptErrorCode.cs index 7abf8462c08..2d4eb17ab9a 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptErrorCode.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptErrorCode.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System.Diagnostics.CodeAnalysis; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptException.cs b/ReactWindows/ReactNative/Chakra/JavaScriptException.cs similarity index 97% rename from ReactWindows/ReactNative/Hosting/JavaScriptException.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptException.cs index 888c17aaff2..fce70443adc 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptException.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptException.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.Serialization; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptFatalException.cs b/ReactWindows/ReactNative/Chakra/JavaScriptFatalException.cs similarity index 96% rename from ReactWindows/ReactNative/Hosting/JavaScriptFatalException.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptFatalException.cs index 7927401f4c8..5c85aedaeda 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptFatalException.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptFatalException.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.Serialization; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptMemoryAllocationCallback.cs b/ReactWindows/ReactNative/Chakra/JavaScriptMemoryAllocationCallback.cs similarity index 96% rename from ReactWindows/ReactNative/Hosting/JavaScriptMemoryAllocationCallback.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptMemoryAllocationCallback.cs index df24f05dc00..c7e644c1206 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptMemoryAllocationCallback.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptMemoryAllocationCallback.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptMemoryEventType.cs b/ReactWindows/ReactNative/Chakra/JavaScriptMemoryEventType.cs similarity index 93% rename from ReactWindows/ReactNative/Hosting/JavaScriptMemoryEventType.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptMemoryEventType.cs index 83c0b3d54ec..e1a64ffa2cb 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptMemoryEventType.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptMemoryEventType.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { /// /// Allocation callback event type. diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptNativeFunction.cs b/ReactWindows/ReactNative/Chakra/JavaScriptNativeFunction.cs similarity index 96% rename from ReactWindows/ReactNative/Hosting/JavaScriptNativeFunction.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptNativeFunction.cs index ac119ff1a9f..40a43e89e01 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptNativeFunction.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptNativeFunction.cs @@ -1,6 +1,6 @@ using System; -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System.Runtime.InteropServices; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptObjectFinalizeCallback.cs b/ReactWindows/ReactNative/Chakra/JavaScriptObjectFinalizeCallback.cs similarity index 90% rename from ReactWindows/ReactNative/Hosting/JavaScriptObjectFinalizeCallback.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptObjectFinalizeCallback.cs index 8a8f8385eca..14971a1a993 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptObjectFinalizeCallback.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptObjectFinalizeCallback.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptPropertyId.cs b/ReactWindows/ReactNative/Chakra/JavaScriptPropertyId.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptPropertyId.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptPropertyId.cs index 7af468d1b20..65b56e74eec 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptPropertyId.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptPropertyId.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptRuntime.cs b/ReactWindows/ReactNative/Chakra/JavaScriptRuntime.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptRuntime.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptRuntime.cs index 06525f579dd..fe9d0d941f0 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptRuntime.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptRuntime.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptRuntimeAttributes.cs b/ReactWindows/ReactNative/Chakra/JavaScriptRuntimeAttributes.cs similarity index 97% rename from ReactWindows/ReactNative/Hosting/JavaScriptRuntimeAttributes.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptRuntimeAttributes.cs index 765ebcb3f3f..2267204c803 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptRuntimeAttributes.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptRuntimeAttributes.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Diagnostics.CodeAnalysis; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptRuntimeVersion.cs b/ReactWindows/ReactNative/Chakra/JavaScriptRuntimeVersion.cs similarity index 94% rename from ReactWindows/ReactNative/Hosting/JavaScriptRuntimeVersion.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptRuntimeVersion.cs index 266a51a4580..b46be65bf4a 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptRuntimeVersion.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptRuntimeVersion.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { /// /// Version of the runtime. diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptScriptException.cs b/ReactWindows/ReactNative/Chakra/JavaScriptScriptException.cs similarity index 98% rename from ReactWindows/ReactNative/Hosting/JavaScriptScriptException.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptScriptException.cs index 5ae42613eae..461b1ce6cc1 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptScriptException.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptScriptException.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.Serialization; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptSourceContext.cs b/ReactWindows/ReactNative/Chakra/JavaScriptSourceContext.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptSourceContext.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptSourceContext.cs index 1e7dc92af1f..6851a2fd882 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptSourceContext.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptSourceContext.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptThreadServiceCallback.cs b/ReactWindows/ReactNative/Chakra/JavaScriptThreadServiceCallback.cs similarity index 96% rename from ReactWindows/ReactNative/Hosting/JavaScriptThreadServiceCallback.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptThreadServiceCallback.cs index b9a3a3e337b..a523b5acb63 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptThreadServiceCallback.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptThreadServiceCallback.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptUsageException.cs b/ReactWindows/ReactNative/Chakra/JavaScriptUsageException.cs similarity index 96% rename from ReactWindows/ReactNative/Hosting/JavaScriptUsageException.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptUsageException.cs index 73fd9cff602..f7139fc49dd 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptUsageException.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptUsageException.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.Serialization; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptValue.cs b/ReactWindows/ReactNative/Chakra/JavaScriptValue.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/JavaScriptValue.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptValue.cs index bce6f4383b3..14c0dd475cc 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptValue.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptValue.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Runtime.InteropServices; diff --git a/ReactWindows/ReactNative/Hosting/JavaScriptValueType.cs b/ReactWindows/ReactNative/Chakra/JavaScriptValueType.cs similarity index 97% rename from ReactWindows/ReactNative/Hosting/JavaScriptValueType.cs rename to ReactWindows/ReactNative/Chakra/JavaScriptValueType.cs index 3014e80ad28..6fff1037d49 100644 --- a/ReactWindows/ReactNative/Hosting/JavaScriptValueType.cs +++ b/ReactWindows/ReactNative/Chakra/JavaScriptValueType.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { /// /// The JavaScript type of a JavaScriptValue. diff --git a/ReactWindows/ReactNative/Hosting/Native.cs b/ReactWindows/ReactNative/Chakra/Native.cs similarity index 99% rename from ReactWindows/ReactNative/Hosting/Native.cs rename to ReactWindows/ReactNative/Chakra/Native.cs index 601b3e5bc1c..9ae26b2dfa7 100644 --- a/ReactWindows/ReactNative/Hosting/Native.cs +++ b/ReactWindows/ReactNative/Chakra/Native.cs @@ -1,4 +1,4 @@ -namespace ReactNative.Hosting +namespace ReactNative.Chakra { using System; using System.Diagnostics.CodeAnalysis; diff --git a/ReactWindows/ReactNative/CoreModulesPackage.cs b/ReactWindows/ReactNative/CoreModulesPackage.cs index 2f6913b6ff5..ea3ce83169b 100644 --- a/ReactWindows/ReactNative/CoreModulesPackage.cs +++ b/ReactWindows/ReactNative/CoreModulesPackage.cs @@ -13,11 +13,6 @@ namespace ReactNative /// It should be used for modules that require special integration with /// other framework parts (e.g., with the list of packages to load view /// managers from). - /// - /// TODO: - /// 1. Add Core native modules - /// 2. Implement UIManagerModule - /// 3. Add remaining JavaScript modules /// class CoreModulesPackage : IReactPackage { @@ -44,13 +39,17 @@ public IReadOnlyList CreateNativeModules(ReactContext reactContex uiManagerModule = new UIManagerModule( reactContext, viewManagerList, - _uiImplementationProvider.CreateUIImplementation( + _uiImplementationProvider.Create( reactContext, viewManagerList)); } return new List { + //new AnimationsDebugModule( + // reactContext, + // _reactInstanceManager.DevSupportManager.DevSettings), + //new SystemInfoModule(), new DeviceEventManagerModule(reactContext, _hardwareBackButtonHandler), new ExceptionsManagerModule(_reactInstanceManager.DevSupportManager), new Timing(reactContext), @@ -58,6 +57,7 @@ public IReadOnlyList CreateNativeModules(ReactContext reactContex _reactInstanceManager.SourceUrl, _reactInstanceManager.DevSupportManager.SourceMapUrl), uiManagerModule, + //new DebugComponentOwnershipModule(reactContext), }; } @@ -65,10 +65,14 @@ public IReadOnlyList CreateJavaScriptModulesConfig() { return new List { + typeof(RCTDeviceEventEmitter), + //typeof(JSTimersExecution), typeof(RCTEventEmitter), typeof(RCTNativeAppEventEmitter), typeof(AppRegistry), + // TODO: some tracing module + //typeof(RCTDebugComponentOwnership), }; } diff --git a/ReactWindows/ReactNative/CreateJsBundle.cmd b/ReactWindows/ReactNative/CreateJsBundle.cmd deleted file mode 100644 index 67e6e7784ce..00000000000 --- a/ReactWindows/ReactNative/CreateJsBundle.cmd +++ /dev/null @@ -1,43 +0,0 @@ -@ECHO OFF -REM -REM Create the main.jsbundle from the JS assets. -REM This bundle will be included into the app package -REM -REM Since the --root option of the react-native bundle -REM command crashes we need some tricks in here... -REM - -SET ProjectJsDir=%~dp0.\Javascript\lib -SET ReactNativeJsDir=%~dp0.\Javascript\uwp-native - -PUSHD %ProjectJsDir% - -FOR /F "usebackq delims=" %%f IN (`DIR /B "%ReactNativeJsDir%\*.js"`) DO CALL :CheckFileExists %%f - -FOR /F "usebackq delims=" %%f IN (`DIR /B "%ReactNativeJsDir%\*.js"`) DO CALL :CopyFiles %%f - -CALL react-native bundle --out main.jsbundle --minify - -FOR /F "usebackq delims=" %%f IN (`DIR /B "%ReactNativeJsDir%\*.js"`) DO CALL :DeleteFiles %%f -ECHO Done -POPD -GOTO :EOF - - -POPD - -:CheckFileExists -SET File=%* -IF EXIST "%File%" ECHO #ERROR: File %ToFile% exists already! && SET FileOverwriteDetected=1 -GOTO :EOF - -:CopyFiles -SET FromFile=%ReactNativeJsDir%\%* -SET ToFile=%* -COPY "%FromFile%" "%ToFile%" > nul -GOTO :EOF - -:DeleteFiles -SET File=%* -DEL "%File%" -GOTO :EOF diff --git a/ReactWindows/ReactNative/IReactInstanceManager.cs b/ReactWindows/ReactNative/IReactInstanceManager.cs index b34a0cfbcab..eeb53d78932 100644 --- a/ReactWindows/ReactNative/IReactInstanceManager.cs +++ b/ReactWindows/ReactNative/IReactInstanceManager.cs @@ -12,8 +12,8 @@ namespace ReactNative { /// - /// This interface manages instances of . - /// It exposes a way to configure catalyst instances using + /// This interface manages instances of . + /// It exposes a way to configure react instances using /// and keeps track of the lifecycle of that /// instance. It also sets up a connection between the instance and the /// developer support functionality of the framework. @@ -97,20 +97,20 @@ public interface IReactInstanceManager void OnDestroy(); /// - /// Attach given to a catalyst instance + /// Attach given to a react instance /// manager and start the JavaScript application using the JavaScript /// module provided by the . If /// the react context is currently being (re-)created, or if the react /// context has not been created yet, the JavaScript application /// associated with the provided root view will be started /// asynchronously. This view will then be tracked by this manager and - /// in case of catalyst instance restart, it will be re-attached. + /// in case of react instance restart, it will be re-attached. /// /// The root view. void AttachMeasuredRootView(ReactRootView rootView); /// - /// Detach given from the current catalyst + /// Detach given from the current react /// instance. This method is idempotent and can be called multiple /// times on the same instance. /// diff --git a/ReactWindows/ReactNative/IReactPackage.cs b/ReactWindows/ReactNative/IReactPackage.cs index bf43ad34aee..3b9049e74c2 100644 --- a/ReactWindows/ReactNative/IReactPackage.cs +++ b/ReactWindows/ReactNative/IReactPackage.cs @@ -7,7 +7,7 @@ namespace ReactNative.Modules.Core { /// - /// Main interface for providing additional capabilities to the catalyst + /// Main interface for providing additional capabilities to the react /// framework through the following mechanisms: /// /// 1) Registering new native modules. @@ -25,7 +25,7 @@ namespace ReactNative.Modules.Core public interface IReactPackage { /// - /// Creates the list of native modules to register with the catalyst + /// Creates the list of native modules to register with the react /// instance. /// /// The react application context. @@ -34,7 +34,7 @@ public interface IReactPackage /// /// Creates the list of JavaScript modules to register with the - /// catalyst instance. + /// react instance. /// /// The list of JavaScript modules. /// diff --git a/ReactWindows/ReactNative/LifecycleState.cs b/ReactWindows/ReactNative/LifecycleState.cs index 8dc003c3a8e..97efee05627 100644 --- a/ReactWindows/ReactNative/LifecycleState.cs +++ b/ReactWindows/ReactNative/LifecycleState.cs @@ -1,11 +1,19 @@ namespace ReactNative { /// - /// A enumeration to signify the current lifecycle state for a . + /// An enumeration to signify the current lifecycle state for a + /// . /// public enum LifecycleState { + /// + /// Lifecycle state before an application is resumed. + /// BeforeResume, + + /// + /// Lifecycle state of a resumed application. + /// Resumed, } } diff --git a/ReactWindows/ReactNative/Modules/Core/DeviceEventManagerModule.cs b/ReactWindows/ReactNative/Modules/Core/DeviceEventManagerModule.cs index 0773b31a997..e875d465dc2 100644 --- a/ReactWindows/ReactNative/Modules/Core/DeviceEventManagerModule.cs +++ b/ReactWindows/ReactNative/Modules/Core/DeviceEventManagerModule.cs @@ -55,7 +55,7 @@ public void EmitHardwareBackPressed() } /// - /// Invokes the default back handler for the host of this catalyst + /// Invokes the default back handler for the host of this react /// instance. This should be invoked if JavaScript does not want to /// handle the back press itself. /// diff --git a/ReactWindows/ReactNative/ReactInstanceManager.cs b/ReactWindows/ReactNative/ReactInstanceManager.cs index 4cd65892759..bb0e3459e9c 100644 --- a/ReactWindows/ReactNative/ReactInstanceManager.cs +++ b/ReactWindows/ReactNative/ReactInstanceManager.cs @@ -2,7 +2,7 @@ using ReactNative.Bridge.Queue; using ReactNative.Common; using ReactNative.DevSupport; -using ReactNative.Hosting.Bridge; +using ReactNative.Chakra.Executor; using ReactNative.Modules.Core; using ReactNative.Tracing; using ReactNative.UIManager; @@ -14,8 +14,8 @@ namespace ReactNative { /// - /// This interface manages instances of . - /// It exposes a way to configure catalyst instances using + /// This interface manages instances of . + /// It exposes a way to configure react instances using /// and keeps track of the lifecycle of that /// instance. It also sets up a connection between the instance and the /// developer support functionality of the framework. @@ -30,15 +30,10 @@ namespace ReactNative /// application using this instance manager. It is required to pass /// lifecycle events to the instance manager (i.e., , /// , and ). - /// - /// TODO: - /// 1.Implement background task functionality and ReactContextInitAsyncTask class hierarchy. - /// 2.Lifecycle managment functoinality. i.e. resume, pause, etc - /// 3.Implement Backbutton handler - /// 4.Implement js bundler load progress checks to ensure thread safety - /// 5.Implement the ViewGroupManager as well as the main ReactViewManager - /// 6.Create DevManager functionality to manage things like exceptions. /// + /// + /// TODO: additional debugging support and memory pressure management. + /// public class ReactInstanceManager : IReactInstanceManager { private readonly List _attachedRootViews = new List(); @@ -265,14 +260,14 @@ public void OnDestroy() } /// - /// Attach given to a catalyst instance + /// Attach given to a react instance /// manager and start the JavaScript application using the JavaScript /// module provided by the . If /// the react context is currently being (re-)created, or if the react /// context has not been created yet, the JavaScript application /// associated with the provided root view will be started /// asynchronously. This view will then be tracked by this manager and - /// in case of catalyst instance restart, it will be re-attached. + /// in case of react instance restart, it will be re-attached. /// /// The root view. public void AttachMeasuredRootView(ReactRootView rootView) @@ -291,12 +286,12 @@ public void AttachMeasuredRootView(ReactRootView rootView) var currentReactContext = _currentReactContext; if (_contextInitializationTask == null && currentReactContext != null) { - AttachMeasuredRootViewToInstance(rootView, currentReactContext.CatalystInstance); + AttachMeasuredRootViewToInstance(rootView, currentReactContext.ReactInstance); } } /// - /// Detach given from the current catalyst + /// Detach given from the current react /// instance. This method is idempotent and can be called multiple /// times on the same instance. /// @@ -311,9 +306,9 @@ public void DetachRootView(ReactRootView rootView) if (_attachedRootViews.Remove(rootView)) { var currentReactContext = _currentReactContext; - if (currentReactContext != null && currentReactContext.HasActiveCatalystInstance) + if (currentReactContext != null && currentReactContext.HasActiveReactInstance) { - DetachViewFromInstance(rootView, currentReactContext.CatalystInstance); + DetachViewFromInstance(rootView, currentReactContext.ReactInstance); } } } @@ -405,9 +400,9 @@ private async Task InitializeReactContextAsync( var reactContext = await CreateReactContextAsync(jsExecutorFactory, jsBundleLoader); SetupReactContext(reactContext); } - catch + catch (Exception ex) { - // TODO: add exception handler through dev support manager. + _devSupportManager.HandleException(ex); } finally { @@ -438,9 +433,9 @@ private void SetupReactContext(ReactContext reactContext) } _currentReactContext = reactContext; - var catalystInstance = reactContext.CatalystInstance; + var reactInstance = reactContext.ReactInstance; - catalystInstance.Initialize(); + reactInstance.Initialize(); // TODO: set up dev support and memory pressure hooks @@ -448,7 +443,7 @@ private void SetupReactContext(ReactContext reactContext) foreach (var rootView in _attachedRootViews) { - AttachMeasuredRootViewToInstance(rootView, catalystInstance); + AttachMeasuredRootViewToInstance(rootView, reactInstance); } OnReactContextInitialized(reactContext); @@ -456,7 +451,7 @@ private void SetupReactContext(ReactContext reactContext) private void AttachMeasuredRootViewToInstance( ReactRootView rootView, - ICatalystInstance catalystInstance) + IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); @@ -465,7 +460,7 @@ private void AttachMeasuredRootViewToInstance( rootView.Children.Clear(); // TODO: reset root view tag? - var uiManagerModule = catalystInstance.GetNativeModule(); + var uiManagerModule = reactInstance.GetNativeModule(); var rootTag = uiManagerModule.AddMeasuredRootView(rootView); var jsAppModuleName = rootView.JavaScriptModuleName; @@ -475,13 +470,13 @@ private void AttachMeasuredRootViewToInstance( { "initalProps", null /* TODO: add launch options to root view */ } }; - catalystInstance.GetJavaScriptModule().runApplication(jsAppModuleName, appParameters); + reactInstance.GetJavaScriptModule().runApplication(jsAppModuleName, appParameters); } - private void DetachViewFromInstance(ReactRootView rootView, ICatalystInstance catalystInstance) + private void DetachViewFromInstance(ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); - catalystInstance.GetJavaScriptModule().unmountApplicationComponentAtRootTag(rootView.GetTag()); + reactInstance.GetJavaScriptModule().unmountApplicationComponentAtRootTag(rootView.GetTag()); } private void TearDownReactContext(ReactContext reactContext) @@ -495,7 +490,7 @@ private void TearDownReactContext(ReactContext reactContext) foreach (var rootView in _attachedRootViews) { - DetachViewFromInstance(rootView, reactContext.CatalystInstance); + DetachViewFromInstance(rootView, reactContext.ReactInstance); } reactContext.Dispose(); @@ -546,9 +541,9 @@ private async Task CreateReactContextAsync( } var exceptionHandler = _nativeModuleCallExceptionHandler ?? _devSupportManager.HandleException; - var catalystInstanceBuilder = new CatalystInstance.Builder + var reactInstanceBuilder = new ReactInstance.Builder { - QueueConfigurationSpec = CatalystQueueConfigurationSpec.Default, + QueueConfigurationSpec = ReactQueueConfigurationSpec.Default, JavaScriptExecutorFactory = jsExecutorFactory, Registry = nativeModuleRegistry, JavaScriptModulesConfig = javaScriptModulesConfig, @@ -556,19 +551,19 @@ private async Task CreateReactContextAsync( NativeModuleCallExceptionHandler = exceptionHandler, }; - var catalystInstance = default(CatalystInstance); - using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "createCatalystInstance")) + var reactInstance = default(ReactInstance); + using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "createReactInstance")) { - catalystInstance = catalystInstanceBuilder.Build(); + reactInstance = reactInstanceBuilder.Build(); } // TODO: add bridge idle debug listener - reactContext.InitializeWithInstance(catalystInstance); + reactContext.InitializeWithInstance(reactInstance); using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "RunJavaScriptBundle")) { - await catalystInstance.InitializeBridgeAsync(); + await reactInstance.InitializeBridgeAsync(); } return reactContext; diff --git a/ReactWindows/ReactNative/ReactNative.csproj b/ReactWindows/ReactNative/ReactNative.csproj index 24ceea4c2cb..c478d1441e8 100644 --- a/ReactWindows/ReactNative/ReactNative.csproj +++ b/ReactWindows/ReactNative/ReactNative.csproj @@ -104,7 +104,6 @@ - @@ -112,7 +111,7 @@ - + @@ -132,14 +131,14 @@ - + - - - + + + @@ -153,10 +152,10 @@ - - - - + + + + @@ -168,12 +167,11 @@ + - - @@ -181,28 +179,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -213,17 +211,16 @@ - - - + + + - - + @@ -231,13 +228,14 @@ + - + @@ -251,7 +249,6 @@ - @@ -260,13 +257,12 @@ - - - + + @@ -281,11 +277,11 @@ - + - + diff --git a/ReactWindows/ReactNative/Reflection/EnumHelpers.cs b/ReactWindows/ReactNative/Reflection/EnumHelpers.cs new file mode 100644 index 00000000000..3305cabdf6e --- /dev/null +++ b/ReactWindows/ReactNative/Reflection/EnumHelpers.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +namespace ReactNative.Reflection +{ + static class EnumHelpers + { + private static readonly ConcurrentDictionary> s_enumCache = + new ConcurrentDictionary>(); + + public static T Parse(string value) + { + var lookup = s_enumCache.GetOrAdd( + typeof(T), + type => Enum.GetValues(type) + .Cast() + .ToDictionary( + e => Normalize(e.ToString()), + e => e)); + + var result = default(object); + if (!lookup.TryGetValue(Normalize(value), out result)) + { + throw new ArgumentOutOfRangeException( + nameof(value), + string.Format( + CultureInfo.InvariantCulture, + "Invalid value '{0}' for type '{1}'.", + value, + typeof(T))); + } + + return (T)result; + } + + private static string Normalize(string value) + { + return value.ToLowerInvariant().Replace("-", ""); + } + } +} diff --git a/ReactWindows/ReactNative/Reflection/MethodInfoHelpers.cs b/ReactWindows/ReactNative/Reflection/MethodInfoHelpers.cs deleted file mode 100644 index 797868958d0..00000000000 --- a/ReactWindows/ReactNative/Reflection/MethodInfoHelpers.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Reflection; -using System.Threading.Tasks; - -namespace ReactNative.Reflection -{ - /// - /// Helper methods for . - /// - static class MethodInfoHelpers - { - - } -} diff --git a/ReactWindows/ReactNative/Shell/MainReactPackage.cs b/ReactWindows/ReactNative/Shell/MainReactPackage.cs index 6c24388d6ad..e5966daf0a5 100644 --- a/ReactWindows/ReactNative/Shell/MainReactPackage.cs +++ b/ReactWindows/ReactNative/Shell/MainReactPackage.cs @@ -51,13 +51,15 @@ public IReadOnlyList CreateViewManagers( //new ReactHorizontalScrollViewManager(), new ReactImageManager(), new ReactVirtualImageManager(), + //new ReactProgressBarViewManager(), new ReactRawTextManager(), //new RecyclerViewBackedScrollViewManager(), new ReactScrollViewManager(), new ReactSwitchManager(), new ReactTextInputManager(), - new ReactTextViewManager(), new ReactMultilineTextInputManager(), + new ReactTextViewManager(), + //new ReactToolbarManager(), new ReactViewManager(), //new ReactViewPagerManager(), //new ReactTextInlineImageViewManager(), diff --git a/ReactWindows/ReactNative/Touch/IOnInterceptTouchEventListener.cs b/ReactWindows/ReactNative/Touch/IOnInterceptTouchEventListener.cs index 9ee17675cd5..848632b1e3e 100644 --- a/ReactWindows/ReactNative/Touch/IOnInterceptTouchEventListener.cs +++ b/ReactWindows/ReactNative/Touch/IOnInterceptTouchEventListener.cs @@ -2,13 +2,23 @@ namespace ReactNative.Touch { + /// + /// A listener for intercepting touch events. + /// public interface IOnInterceptTouchEventListener { /// - /// Called when a onInterceptTouch is invoked on a view group + /// Called to evaluate touch interception occurs on a view parent. /// - /// The motion event being dispatched down the hierarchy. - /// Return true to steal motion event from the children and have the dispatched to this view, or return false to allow motion event to be delivered to children view + /// The sender of the event. + /// + /// The motion event being dispatched down the hierarchy. + /// + /// + /// true to steal the motion event from the children and + /// dispatch to this view, or false to allow the motion + /// event to be delivered to the child view. + /// bool OnInterceptTouchEvent(object sender, PointerRoutedEventArgs @event); } } \ No newline at end of file diff --git a/ReactWindows/ReactNative/Touch/ICatalystInterceptingViewGroup.cs b/ReactWindows/ReactNative/Touch/IReactInterceptingViewParent.cs similarity index 92% rename from ReactWindows/ReactNative/Touch/ICatalystInterceptingViewGroup.cs rename to ReactWindows/ReactNative/Touch/IReactInterceptingViewParent.cs index d1dd90eb7a7..a55f6683156 100644 --- a/ReactWindows/ReactNative/Touch/ICatalystInterceptingViewGroup.cs +++ b/ReactWindows/ReactNative/Touch/IReactInterceptingViewParent.cs @@ -5,7 +5,7 @@ /// subviews that can /// be instantiated by . /// - public interface ICatalystInterceptingViewGroup + public interface IReactInterceptingViewParent { /// /// A callback that should diff --git a/ReactWindows/ReactNative/Touch/JavaScriptResponderHandler.cs b/ReactWindows/ReactNative/Touch/JavaScriptResponderHandler.cs index 04c2a4de973..f884e3dafd6 100644 --- a/ReactWindows/ReactNative/Touch/JavaScriptResponderHandler.cs +++ b/ReactWindows/ReactNative/Touch/JavaScriptResponderHandler.cs @@ -5,10 +5,11 @@ namespace ReactNative.Touch { /// - /// This class coordinates JSResponder commands for . - /// It should be set as the - /// for all newly created native views that implement - /// and will dispatch touch + /// This class coordinates JavaScript responder commands for the + /// . It should be set + /// as the for all newly + /// created native views that implement + /// and will dispatch touch /// events to the JavaScript gesture recognizer when the JavaScript /// responder is set to be enabled. /// @@ -16,16 +17,38 @@ public class JavaScriptResponderHandler : IOnInterceptTouchEventListener { private const int JavaScriptResponderUnset = -1; + /// + /// Sets the JavaScript responder to the given view. + /// + /// The view tag. + /// + /// The view instance. + /// public void SetJavaScriptResponder(int tag, Panel viewParentBlockingNativeResponder) { throw new NotImplementedException(); } + /// + /// Clears the JavaScript responder. + /// public void ClearJavaScriptResponder() { throw new NotImplementedException(); } + /// + /// Called to evaluate touch interception occurs on a view parent. + /// + /// The sender of the event. + /// + /// The motion event being dispatched down the hierarchy. + /// + /// + /// true to steal the motion event from the children and + /// dispatch to this view, or false to allow the motion + /// event to be delivered to the child view. + /// public bool OnInterceptTouchEvent(object sender, PointerRoutedEventArgs ev) { throw new NotImplementedException(); diff --git a/ReactWindows/ReactNative/UIManager/Animation/AnimationRegistry.cs b/ReactWindows/ReactNative/UIManager/Animation/AnimationRegistry.cs deleted file mode 100644 index 4dd83a4f4b5..00000000000 --- a/ReactWindows/ReactNative/UIManager/Animation/AnimationRegistry.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ReactNative.UIManager.Animation -{ - public class AnimationRegistry - { - public AnimationRegistry() - { - } - } -} \ No newline at end of file diff --git a/ReactWindows/ReactNative/UIManager/BaseViewManager.cs b/ReactWindows/ReactNative/UIManager/BaseViewManager.cs index 48ebc9b1a1c..7f39b06399f 100644 --- a/ReactWindows/ReactNative/UIManager/BaseViewManager.cs +++ b/ReactWindows/ReactNative/UIManager/BaseViewManager.cs @@ -26,6 +26,7 @@ public abstract class BaseViewManager : Vi private const string PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX"; private const string PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY"; private const string PROP_OPACITY = "opacity"; + private const string PROP_ELEVATION = "elevation"; /// /// Set's the styling layout @@ -57,6 +58,13 @@ public void SetOpacity(TFrameworkElement view, double opacity) view.Opacity = opacity; } + [ReactProperty(PROP_ELEVATION)] + public void SetElevation(TFrameworkElement view, double elevation) + { + var transform = EnsureTransform(view); + transform.TranslateZ = elevation; + } + /// /// Sets the scaleX property of the . /// @@ -119,13 +127,12 @@ private void SetRotationY(TFrameworkElement view, double rotation) private void SetTransformMatrix(TFrameworkElement view, JObject matrix) { - // TODO: eliminate closure in action. - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_TRANSLATE_X, value => SetTranslationX(view, value)); - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_TRANSLATE_Y, value => SetTranslationY(view, value)); - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_ROTATE_X, value => SetRotationX(view, value)); - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_ROTATE_Y, value => SetRotationY(view, value)); - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_SCALE_X, value => SetScaleX(view, value)); - LookupAndDo(matrix, PROP_DECOMPOSED_MATRIX_SCALE_Y, value => SetScaleY(view, value)); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_TRANSLATE_X, view, SetTranslationX); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_TRANSLATE_Y, view, SetTranslationY); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_ROTATE_X, view, SetRotationX); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_ROTATE_Y, view, SetRotationY); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_SCALE_X, view, SetScaleX); + ApplyProperty(matrix, PROP_DECOMPOSED_MATRIX_SCALE_Y, view, SetScaleY); } private void ResetTransformMatrix(TFrameworkElement view) @@ -138,12 +145,12 @@ private void ResetTransformMatrix(TFrameworkElement view) SetScaleY(view, 1.0); } - private static void LookupAndDo(JObject matrix, string name, Action onFound) + private static void ApplyProperty(JObject matrix, string name, TFrameworkElement view, Action apply) { var token = default(JToken); if (matrix.TryGetValue(name, out token)) { - onFound(token.ToObject()); + apply(view, token.ToObject()); } } diff --git a/ReactWindows/ReactNative/UIManager/BorderedContentControl.cs b/ReactWindows/ReactNative/UIManager/BorderedContentControl.cs index fe9fabadaeb..22fd7293af4 100644 --- a/ReactWindows/ReactNative/UIManager/BorderedContentControl.cs +++ b/ReactWindows/ReactNative/UIManager/BorderedContentControl.cs @@ -1,5 +1,4 @@ using Facebook.CSSLayout; -using System.Diagnostics; using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -14,11 +13,7 @@ public class BorderedContentControl : ContentControl { private static readonly SolidColorBrush s_defaultBorderBrush = new SolidColorBrush(Colors.Black); - private Border _customBorder; - private Border _customLeftBorder; - private Border _customRightBorder; - private Border _customTopBorder; - private Border _customBottomBorder; + private bool _hasCustomBorder; /// /// Instantiates the . @@ -31,18 +26,6 @@ public BorderedContentControl(object content) base.Content = content; } - private bool HasCustomBorder - { - get - { - return _customBorder != null || - _customLeftBorder != null || - _customRightBorder != null || - _customTopBorder != null || - _customBottomBorder != null; - } - } - /// /// An intentional override of the /// property that returns the child without any borders. @@ -51,17 +34,14 @@ private bool HasCustomBorder { get { - if (!HasCustomBorder) + if (!_hasCustomBorder) { return (UIElement)base.Content; } - else if (_customBorder != null) - { - return _customBorder.Child; - } else { - return _customBottomBorder.Child; + var customBorder = EnsureBorder(); + return customBorder.Child; } } } @@ -72,19 +52,8 @@ private bool HasCustomBorder /// The width. public void SetBorderWidth(double width) { - EnsureBorder(); - - if (_customBorder != null) - { - _customBorder.BorderThickness = new Thickness(width); - } - else if (_customBorder == null) - { - _customLeftBorder.BorderThickness = new Thickness(width, 0, 0, 0); - _customTopBorder.BorderThickness = new Thickness(0, width, 0, 0); - _customRightBorder.BorderThickness = new Thickness(0, 0, width, 0); - _customBottomBorder.BorderThickness = new Thickness(0, 0, 0, width); - } + var customBorder = EnsureBorder(); + customBorder.BorderThickness = new Thickness(width); } /// @@ -94,35 +63,8 @@ public void SetBorderWidth(double width) /// The width. public void SetBorderWidth(CSSSpacingType kind, double width) { - if (kind == CSSSpacingType.All) - { - SetBorderWidth(width); - } - - EnsureBorder(); - - if (_customBorder != null) - { - _customBorder.SetBorderWidth(kind, width); - } - else - { - switch (kind) - { - case CSSSpacingType.Left: - _customLeftBorder.BorderThickness = new Thickness(width, 0, 0, 0); - break; - case CSSSpacingType.Top: - _customTopBorder.BorderThickness = new Thickness(0, width, 0, 0); - break; - case CSSSpacingType.Right: - _customRightBorder.BorderThickness = new Thickness(0, 0, width, 0); - break; - case CSSSpacingType.Bottom: - _customBottomBorder.BorderThickness = new Thickness(0, 0, 0, width); - break; - } - } + var customBorder = EnsureBorder(); + customBorder.SetBorderWidth(kind, width); } /// @@ -131,61 +73,8 @@ public void SetBorderWidth(CSSSpacingType kind, double width) /// The masked color. public void SetBorderColor(uint color) { - EnsureBorder(); - - var brush = new SolidColorBrush(ColorHelpers.Parse(color)); - - if (_customBorder != null) - { - _customBorder.BorderBrush = brush; - } - else - { - Debug.Assert(_customLeftBorder != null); - Debug.Assert(_customTopBorder != null); - Debug.Assert(_customRightBorder != null); - Debug.Assert(_customBottomBorder != null); - - _customLeftBorder.BorderBrush = brush; - _customTopBorder.BorderBrush = brush; - _customRightBorder.BorderBrush = brush; - _customBottomBorder.BorderBrush = brush; - } - } - - /// - /// Sets the border color. - /// - /// The width specification. - /// The masked color. - public void SetBorderColor(CSSSpacingType kind, uint color) - { - if (kind == CSSSpacingType.All) - { - SetBorderColor(color); - } - else - { - var brush = new SolidColorBrush(ColorHelpers.Parse(color)); - - EnsureSideBorders(); - - switch (kind) - { - case CSSSpacingType.Left: - _customLeftBorder.BorderBrush = brush; - break; - case CSSSpacingType.Top: - _customTopBorder.BorderBrush = brush; - break; - case CSSSpacingType.Right: - _customRightBorder.BorderBrush = brush; - break; - case CSSSpacingType.Bottom: - _customBottomBorder.BorderBrush = brush; - break; - } - } + var customBorder = EnsureBorder(); + customBorder.BorderBrush = new SolidColorBrush(ColorHelpers.Parse(color)); } /// @@ -194,86 +83,26 @@ public void SetBorderColor(CSSSpacingType kind, uint color) /// The radius. public void SetBorderRadius(double radius) { - var cornerRadius = new CornerRadius(radius); - - EnsureBorder(); - - if (_customBorder != null) - { - _customBorder.CornerRadius = cornerRadius; - } - else - { - Debug.Assert(_customLeftBorder != null); - Debug.Assert(_customTopBorder != null); - Debug.Assert(_customRightBorder != null); - Debug.Assert(_customBottomBorder != null); - - _customLeftBorder.CornerRadius = new CornerRadius(radius, 0, 0, 0); - _customTopBorder.CornerRadius = new CornerRadius(0, radius, 0, 0); - _customRightBorder.CornerRadius = new CornerRadius(0, 0, radius, 0); - _customBottomBorder.CornerRadius = new CornerRadius(0, 0, 0, radius); - } + var customBorder = EnsureBorder(); + customBorder.CornerRadius = new CornerRadius(radius); } - private void EnsureBorder() + private Border EnsureBorder() { - if (HasCustomBorder) + if (_hasCustomBorder) { - return; + return (Border)base.Content; } - + var inner = Content; + _hasCustomBorder = true; base.Content = null; - _customBorder = new Border(); - _customBorder.BorderThickness = BorderThickness; - _customBorder.BorderBrush = BorderBrush; - base.Content = _customBorder; - _customBorder.Child = inner; - } - - private void EnsureSideBorders() - { - if (HasCustomBorder && _customBorder == null) - { - return; - } - - _customLeftBorder = new Border(); - _customRightBorder = new Border(); - _customTopBorder = new Border(); - _customBottomBorder = new Border(); - - _customLeftBorder.Child = _customTopBorder; - _customTopBorder.Child = _customRightBorder; - _customRightBorder.Child = _customBottomBorder; - - var borderThickness = _customBorder != null ? _customBorder.BorderThickness : BorderThickness; - var cornerRadius = _customBorder != null ? _customBorder.CornerRadius : new CornerRadius(); - var borderBrush = _customBorder != null ? _customBorder.BorderBrush : BorderBrush; - var child = _customBorder != null ? _customBorder.Child : (UIElement)Content; - - if (_customBorder != null) - { - _customBorder.Child = null; - _customBorder = null; - } - - _customLeftBorder.BorderThickness = new Thickness(borderThickness.Left, 0, 0, 0); - _customLeftBorder.CornerRadius = new CornerRadius(cornerRadius.TopLeft, 0, 0, cornerRadius.BottomLeft); - _customLeftBorder.BorderBrush = borderBrush; - _customTopBorder.BorderThickness = new Thickness(0, borderThickness.Top, 0, 0); - _customTopBorder.CornerRadius = new CornerRadius(0, cornerRadius.TopRight, 0, 0); - _customTopBorder.BorderBrush = borderBrush; - _customRightBorder.BorderThickness = new Thickness(0, 0, borderThickness.Right, 0); - _customRightBorder.CornerRadius = new CornerRadius(0, 0, cornerRadius.BottomRight, 0); - _customRightBorder.BorderBrush = borderBrush; - _customBottomBorder.BorderThickness = new Thickness(0, 0, 0, borderThickness.Bottom); - _customBottomBorder.CornerRadius = new CornerRadius(); - _customBottomBorder.BorderBrush = borderBrush; - _customBottomBorder.Child = child; - - base.Content = _customLeftBorder; + var customBorder = new Border(); + customBorder.BorderThickness = BorderThickness; + customBorder.BorderBrush = BorderBrush; + customBorder.Child = inner; + base.Content = customBorder; + return customBorder; } } } diff --git a/ReactWindows/ReactNative/UIManager/CatalystStylesDiffMapExtensions.cs b/ReactWindows/ReactNative/UIManager/CatalystStylesDiffMapExtensions.cs deleted file mode 100644 index ee2427b7e75..00000000000 --- a/ReactWindows/ReactNative/UIManager/CatalystStylesDiffMapExtensions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ReactNative.UIManager -{ - static class CatalystStylesDiffMapExtensions - { - public static T GetProperty(this CatalystStylesDiffMap properties, string name) - { - return (T)properties.GetProperty(name, typeof(T)); - } - } -} diff --git a/ReactWindows/ReactNative/UIManager/Events/Event.cs b/ReactWindows/ReactNative/UIManager/Events/Event.cs index e8fe4d7f008..45620f45309 100644 --- a/ReactWindows/ReactNative/UIManager/Events/Event.cs +++ b/ReactWindows/ReactNative/UIManager/Events/Event.cs @@ -17,8 +17,11 @@ public abstract class Event : IDisposable private int _viewTag; private TimeSpan _timestamp; - protected Event() { } - + /// + /// Base constructor for . + /// + /// The view tag. + /// The event timestamp. protected Event(int viewTag, TimeSpan timestamp) { Init(viewTag, timestamp); diff --git a/ReactWindows/ReactNative/UIManager/Events/EventDispatcher.cs b/ReactWindows/ReactNative/UIManager/Events/EventDispatcher.cs index 8e1b3b2f707..4c417e8d6f5 100644 --- a/ReactWindows/ReactNative/UIManager/Events/EventDispatcher.cs +++ b/ReactWindows/ReactNative/UIManager/Events/EventDispatcher.cs @@ -160,9 +160,9 @@ public void OnSuspend() } /// - /// Called before the catalyst instance is disposed. + /// Called before the react instance is disposed. /// - public void OnCatalystInstanceDispose() + public void OnReactInstanceDispose() { ClearCallback(); } diff --git a/ReactWindows/ReactNative/UIManager/Events/IOnIntercepTextGotFocusEventListener.cs b/ReactWindows/ReactNative/UIManager/Events/IOnIntercepTextGotFocusEventListener.cs deleted file mode 100644 index 0624a3f0fc4..00000000000 --- a/ReactWindows/ReactNative/UIManager/Events/IOnIntercepTextGotFocusEventListener.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ReactNative.UIManager.Events -{ - /// - /// The interface for defining the methods for receiving and losing control focus. - /// - public interface IOnIntercepTextFocusEventListener - { - void OnInterceptLostFocusEvent(object sender, RoutedEventArgs @event); - - void OnInterceptGotFocusEvent(object sender, RoutedEventArgs @event); - } -} diff --git a/ReactWindows/ReactNative/UIManager/Events/IOnInterceptTextInputEventListener.cs b/ReactWindows/ReactNative/UIManager/Events/IOnInterceptTextInputEventListener.cs deleted file mode 100644 index 88575116cb2..00000000000 --- a/ReactWindows/ReactNative/UIManager/Events/IOnInterceptTextInputEventListener.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Input; - -namespace ReactNative.UIManager.Events -{ - public interface IOnInterceptTextInputEventListener - { - /// - /// Called when a onInterceptTouch is invoked on a view group - /// - /// The motion event being dispatched down the hierarchy. - /// Return true to steal motion event from the children and have the dispatched to this view, or return false to allow motion event to be delivered to children view - void OnInterceptTextChangeEvent(object sender, TextChangedEventArgs @event); - } -} diff --git a/ReactWindows/ReactNative/UIManager/IPropertySetter.cs b/ReactWindows/ReactNative/UIManager/IPropertySetter.cs index 32fcbe56a4e..d3ab35f0f6a 100644 --- a/ReactWindows/ReactNative/UIManager/IPropertySetter.cs +++ b/ReactWindows/ReactNative/UIManager/IPropertySetter.cs @@ -8,8 +8,8 @@ interface IPropertySetter string PropertyType { get; } - void UpdateShadowNodeProperty(ReactShadowNode shadowNode, CatalystStylesDiffMap value); + void UpdateShadowNodeProperty(ReactShadowNode shadowNode, ReactStylesDiffMap value); - void UpdateViewManagerProperty(ViewManager viewManager, FrameworkElement view, CatalystStylesDiffMap value); + void UpdateViewManagerProperty(ViewManager viewManager, FrameworkElement view, ReactStylesDiffMap value); } } diff --git a/ReactWindows/ReactNative/UIManager/IReactPointerEventsView.cs b/ReactWindows/ReactNative/UIManager/IReactPointerEventsView.cs new file mode 100644 index 00000000000..fea8a8a0895 --- /dev/null +++ b/ReactWindows/ReactNative/UIManager/IReactPointerEventsView.cs @@ -0,0 +1,14 @@ +namespace ReactNative.UIManager +{ + /// + /// This interface should be implemented be native subclasses that support pointer + /// events handling.It is used to find the target View of a touch event. + /// + public interface IReactPointerEventsView + { + /// + /// Return the pointer events of the view. + /// + PointerEvents PointerEvents { get; } + } +} diff --git a/ReactWindows/ReactNative/UIManager/ISizeChangedListener.cs b/ReactWindows/ReactNative/UIManager/ISizeChangedListener.cs deleted file mode 100644 index 48339407236..00000000000 --- a/ReactWindows/ReactNative/UIManager/ISizeChangedListener.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.UI.Xaml; - -namespace ReactNative.UIManager -{ - /// - /// Interface listener to hook into size change events for XAML components of type - /// - public interface ISizeChangedListener - { - void OnSizeChanged(object sender, SizeChangedEventArgs e); - } -} diff --git a/ReactWindows/ReactNative/UIManager/LayoutShadowNode.cs b/ReactWindows/ReactNative/UIManager/LayoutShadowNode.cs index cdd631fcd94..bf199ea7a59 100644 --- a/ReactWindows/ReactNative/UIManager/LayoutShadowNode.cs +++ b/ReactWindows/ReactNative/UIManager/LayoutShadowNode.cs @@ -1,9 +1,5 @@ using Facebook.CSSLayout; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; +using ReactNative.Reflection; namespace ReactNative.UIManager { @@ -13,9 +9,6 @@ namespace ReactNative.UIManager /// public class LayoutShadowNode : ReactShadowNode { - private static readonly ConcurrentDictionary> s_enumCache = - new ConcurrentDictionary>(); - // TODO: replace with CSSConstants.Undefined private const float Undefined = float.NaN; @@ -97,7 +90,7 @@ public void SetFlex(float flex) public void SetFlexDirection(string flexDirection) { FlexDirection = flexDirection != null - ? Parse(flexDirection, nameof(flexDirection)) + ? EnumHelpers.Parse(flexDirection) : CSSFlexDirection.Column; } @@ -109,7 +102,7 @@ public void SetFlexDirection(string flexDirection) public void SetFlexWrap(string flexWrap) { Wrap = flexWrap != null - ? Parse(flexWrap, nameof(flexWrap)) + ? EnumHelpers.Parse(flexWrap) : CSSWrap.NoWrap; } @@ -121,7 +114,7 @@ public void SetFlexWrap(string flexWrap) public void SetAlignSelf(string alignSelf) { AlignSelf = alignSelf != null - ? Parse(alignSelf, nameof(alignSelf)) + ? EnumHelpers.Parse(alignSelf) : CSSAlign.Auto; } @@ -133,7 +126,7 @@ public void SetAlignSelf(string alignSelf) public void SetAlignItems(string alignItems) { AlignItems = alignItems != null - ? Parse(alignItems, nameof(alignItems)) + ? EnumHelpers.Parse(alignItems) : CSSAlign.Stretch; } @@ -145,7 +138,7 @@ public void SetAlignItems(string alignItems) public void SetJustifyContent(string justifyContent) { JustifyContent = justifyContent != null - ? Parse(justifyContent, nameof(justifyContent)) + ? EnumHelpers.Parse(justifyContent) : CSSJustify.FlexStart; } @@ -212,33 +205,8 @@ public void SetBorderWidth(int index, float borderWidth) public void SetPosition(string position) { PositionType = position != null - ? Parse(position, nameof(position)) + ? EnumHelpers.Parse(position) : CSSPositionType.Relative; } - - private static T Parse(string value, string paramName) - { - var lookup = s_enumCache.GetOrAdd( - typeof(T), - type => Enum.GetValues(type) - .Cast() - .ToDictionary( - e => e.ToString().ToLowerInvariant(), - e => e)); - - var result = default(object); - if (!lookup.TryGetValue(value.ToLowerInvariant().Replace("-", ""), out result)) - { - throw new ArgumentOutOfRangeException( - paramName, - string.Format( - CultureInfo.InvariantCulture, - "Invalid value '{0}' for type '{1}'.", - value, - typeof(T))); - } - - return (T)result; - } } } \ No newline at end of file diff --git a/ReactWindows/ReactNative/UIManager/MeasureAssertions.cs b/ReactWindows/ReactNative/UIManager/MeasureAssertions.cs new file mode 100644 index 00000000000..7d20c2d1ff2 --- /dev/null +++ b/ReactWindows/ReactNative/UIManager/MeasureAssertions.cs @@ -0,0 +1,20 @@ +using System; + +namespace ReactNative.UIManager +{ + static class MeasureAssertions + { + public static void AssertExplicitMeasurement(double width, double height) + { + if (IsUnspecified(width) || IsUnspecified(height)) + { + throw new InvalidOperationException("A react view must have an explicit width and height."); + } + } + + private static bool IsUnspecified(double value) + { + return double.IsInfinity(value) || double.IsNaN(value); + } + } +} diff --git a/ReactWindows/ReactNative/UIManager/NativeViewHierarchyManager.cs b/ReactWindows/ReactNative/UIManager/NativeViewHierarchyManager.cs index 57243cc172d..62e5ac23e9f 100644 --- a/ReactWindows/ReactNative/UIManager/NativeViewHierarchyManager.cs +++ b/ReactWindows/ReactNative/UIManager/NativeViewHierarchyManager.cs @@ -2,7 +2,6 @@ using ReactNative.Bridge; using ReactNative.Touch; using ReactNative.Tracing; -using ReactNative.UIManager.Animation; using System; using System.Collections.Generic; using System.Globalization; @@ -18,9 +17,9 @@ namespace ReactNative.UIManager /// corresponding instances of . The /// communicates with this class by it's /// public interface methods: - /// - + /// - /// - - /// - + /// - /// - /// executing all the scheduled operations at the end of the JavaScript batch. /// @@ -41,9 +40,8 @@ namespace ReactNative.UIManager /// /// TODO: /// 1) AnimationRegistry - /// 2) UpdateLayout - /// 3) Measure - /// 4) ShowPopupMenu + /// 2) Measure + /// 3) ShowPopupMenu /// public class NativeViewHierarchyManager { @@ -53,7 +51,6 @@ public class NativeViewHierarchyManager private readonly ViewManagerRegistry _viewManagers; private readonly JavaScriptResponderHandler _jsResponderHandler; private readonly RootViewManager _rootViewManager; - private readonly AnimationRegistry _animationRegistry; /// /// Instantiates the . @@ -67,18 +64,6 @@ public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) _rootTags = new Dictionary(); _jsResponderHandler = new JavaScriptResponderHandler(); _rootViewManager = new RootViewManager(); - _animationRegistry = new AnimationRegistry(); - } - - /// - /// The animation registry. - /// - public AnimationRegistry Animations - { - get - { - return _animationRegistry; - } } /// @@ -95,7 +80,7 @@ public bool LayoutAnimationEnabled /// /// The view tag. /// The properties. - public void UpdateProperties(int tag, CatalystStylesDiffMap properties) + public void UpdateProperties(int tag, ReactStylesDiffMap properties) { DispatcherHelpers.AssertOnDispatcher(); var viewManager = ResolveViewManager(tag); @@ -135,18 +120,18 @@ public void UpdateLayout(int parentTag, int tag, int x, int y, int width, int he var viewToUpdate = ResolveView(tag); var parentViewManager = default(ViewManager); - var parentViewGroupManager = default(ViewGroupManager); + var parentViewParentManager = default(ViewParentManager); if (!_tagsToViewManagers.TryGetValue(parentTag, out parentViewManager) || - (parentViewGroupManager = parentViewManager as ViewGroupManager) == null) + (parentViewParentManager = parentViewManager as ViewParentManager) == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, - "Trying to use view with tag '{0}' as a parent, but its manager doesn't extend ViewGroupManager.", + "Trying to use view with tag '{0}' as a parent, but its manager doesn't extend ViewParentManager.", tag)); } - if (!parentViewGroupManager.NeedsCustomLayoutForChildren) + if (!parentViewParentManager.NeedsCustomLayoutForChildren) { UpdateLayout(viewToUpdate, x, y, width, height); } @@ -160,7 +145,7 @@ public void UpdateLayout(int parentTag, int tag, int x, int y, int width, int he /// The tag. /// The class name. /// The properties. - public void CreateView(ThemedReactContext themedContext, int tag, string className, CatalystStylesDiffMap initialProperties) + public void CreateView(ThemedReactContext themedContext, int tag, string className, ReactStylesDiffMap initialProperties) { DispatcherHelpers.AssertOnDispatcher(); using (Tracer.Trace(Tracer.TRACE_TAG_REACT_VIEW, "NativeViewHierarcyManager.CreateView") @@ -203,10 +188,10 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo tag)); } - var viewGroupManager = (ViewGroupManager)viewManager; + var viewParentManager = (ViewParentManager)viewManager; var viewToManage = _tagsToViews[tag]; - var lastIndexToRemove = viewGroupManager.GetChildCount(viewToManage); + var lastIndexToRemove = viewParentManager.GetChildCount(viewToManage); if (indicesToRemove != null) { for (var i = indicesToRemove.Length - 1; i >= 0; --i) @@ -222,7 +207,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo tag)); } - if (indexToRemove >= viewGroupManager.GetChildCount(viewToManage)) + if (indexToRemove >= viewParentManager.GetChildCount(viewToManage)) { throw new InvalidOperationException( string.Format( @@ -243,7 +228,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo tag)); } - viewGroupManager.RemoveChildAt(viewToManage, indexToRemove); + viewParentManager.RemoveChildAt(viewToManage, indexToRemove); lastIndexToRemove = indexToRemove; } } @@ -263,7 +248,7 @@ public void ManageChildren(int tag, int[] indicesToRemove, ViewAtIndex[] viewsTo viewAtIndex.Tag)); } - viewGroupManager.AddView(viewToManage, viewToAdd, viewAtIndex.Index); + viewParentManager.AddView(viewToManage, viewToAdd, viewAtIndex.Index); } } @@ -304,12 +289,6 @@ public void RemoveRootView(int rootViewTag) } var rootView = _tagsToViews[rootViewTag]; - var sizeMonitoringPanel = rootView as SizeMonitoringCanvas; - if (sizeMonitoringPanel != null) - { - sizeMonitoringPanel.RemoveSizeChanged(); - } - DropView(rootView); _rootTags.Remove(rootViewTag); } @@ -350,7 +329,7 @@ public void Measure(int tag, int[] outputBuffer) /// The themed context. public void AddRootView(int tag, SizeMonitoringCanvas view, ThemedReactContext themedContext) { - AddRootViewGroup(tag, view, themedContext); + AddRootViewParent(tag, view, themedContext); } /// @@ -490,7 +469,7 @@ private ViewManager ResolveViewManager(int tag) return viewManager; } - private void AddRootViewGroup(int tag, FrameworkElement view, ThemedReactContext themedContext) + private void AddRootViewParent(int tag, FrameworkElement view, ThemedReactContext themedContext) { DispatcherHelpers.AssertOnDispatcher(); _tagsToViews.Add(tag, view); @@ -514,13 +493,13 @@ private void DropView(FrameworkElement view) var viewManager = default(ViewManager); if (_tagsToViewManagers.TryGetValue(tag, out viewManager)) { - var viewGroup = view as Panel; - var viewGroupManager = viewManager as ViewGroupManager; - if (viewGroup != null && viewGroupManager != null) + var viewParent = view as Panel; + var viewParentManager = viewManager as ViewParentManager; + if (viewParent != null && viewParentManager != null) { - for (var i = viewGroupManager.GetChildCount(viewGroup) - 1; i >= 0; --i) + for (var i = viewParentManager.GetChildCount(viewParent) - 1; i >= 0; --i) { - var child = viewGroupManager.GetChildAt(viewGroup, i); + var child = viewParentManager.GetChildAt(viewParent, i); var managedChild = default(FrameworkElement); if (_tagsToViews.TryGetValue(child.GetTag(), out managedChild)) { @@ -529,7 +508,7 @@ private void DropView(FrameworkElement view) } } - viewGroupManager.RemoveAllChildren(viewGroup); + viewParentManager.RemoveAllChildren(viewParent); } _tagsToViews.Remove(tag); diff --git a/ReactWindows/ReactNative/UIManager/NativeViewHierarchyOptimizer.cs b/ReactWindows/ReactNative/UIManager/NativeViewHierarchyOptimizer.cs index 006bfecb4fe..8c46ee11a4b 100644 --- a/ReactWindows/ReactNative/UIManager/NativeViewHierarchyOptimizer.cs +++ b/ReactWindows/ReactNative/UIManager/NativeViewHierarchyOptimizer.cs @@ -75,7 +75,7 @@ public NativeViewHierarchyOptimizer( public void HandleCreateView( ReactShadowNode node, ThemedReactContext themedContext, - CatalystStylesDiffMap initialProperties) + ReactStylesDiffMap initialProperties) { #if !ENABLED _uiViewOperationQueue.EnqueueCreateView( @@ -110,7 +110,7 @@ public void HandleCreateView( /// The node. /// The class name. /// The properties. - public void HandleUpdateView(ReactShadowNode node, string className, CatalystStylesDiffMap properties) + public void HandleUpdateView(ReactShadowNode node, string className, ReactStylesDiffMap properties) { #if !ENABLED _uiViewOperationQueue.EnqueueUpdateProperties(node.ReactTag, className, properties); @@ -426,7 +426,7 @@ private void ApplyLayoutRecursive(ReactShadowNode node, int x, int y) } } - private void TransitionLayoutOnlyViewToNativeView(ReactShadowNode node, CatalystStylesDiffMap properties) + private void TransitionLayoutOnlyViewToNativeView(ReactShadowNode node, ReactStylesDiffMap properties) { var parent = node.Parent; if (parent == null) @@ -473,7 +473,7 @@ private void TransitionLayoutOnlyViewToNativeView(ReactShadowNode node, Catalyst _tagsWithLayoutVisited.Clear(); } - private bool IsLayoutOnlyAndCollapsible(CatalystStylesDiffMap properties) + private bool IsLayoutOnlyAndCollapsible(ReactStylesDiffMap properties) { if (properties == null) { diff --git a/ReactWindows/ReactNative/UIManager/PanelViewGroupManager.cs b/ReactWindows/ReactNative/UIManager/PanelViewParentManager.cs similarity index 94% rename from ReactWindows/ReactNative/UIManager/PanelViewGroupManager.cs rename to ReactWindows/ReactNative/UIManager/PanelViewParentManager.cs index ab9abc5332c..532f398a548 100644 --- a/ReactWindows/ReactNative/UIManager/PanelViewGroupManager.cs +++ b/ReactWindows/ReactNative/UIManager/PanelViewParentManager.cs @@ -9,7 +9,7 @@ namespace ReactNative.UIManager /// extending . /// /// Type of panel. - public abstract class PanelViewGroupManager : ViewGroupManager + public abstract class PanelViewParentManager : ViewParentManager where TPanel : Panel { /// @@ -54,9 +54,9 @@ public sealed override void UpdateExtraData(FrameworkElement root, object extraD } /// - /// Gets the number of children in the view group. + /// Gets the number of children for the view parent. /// - /// The view group. + /// The view parent. /// The number of children. public sealed override int GetChildCount(FrameworkElement parent) { @@ -88,7 +88,7 @@ public sealed override void AddView(FrameworkElement parent, FrameworkElement ch /// /// Removes the child at the given index. /// - /// The view group. + /// The view parent. /// The index. public override void RemoveChildAt(FrameworkElement parent, int index) { @@ -96,9 +96,9 @@ public override void RemoveChildAt(FrameworkElement parent, int index) } /// - /// Removes all children from the view group. + /// Removes all children from the view parent. /// - /// The view group. + /// The view parent. public override void RemoveAllChildren(FrameworkElement parent) { RemoveAllChildren((TPanel)parent); @@ -225,9 +225,9 @@ protected virtual void UpdateExtraData(TPanel root, object extraData) } /// - /// Gets the number of children in the view group. + /// Gets the number of children in the view parent. /// - /// The view group. + /// The view parent. /// The number of children. protected virtual int GetChildCount(TPanel parent) { @@ -259,7 +259,7 @@ protected virtual void AddView(TPanel parent, FrameworkElement child, int index) /// /// Removes the child at the given index. /// - /// The view group. + /// The view parent. /// The index. protected virtual void RemoveChildAt(TPanel parent, int index) { @@ -267,9 +267,9 @@ protected virtual void RemoveChildAt(TPanel parent, int index) } /// - /// Removes all children from the view group. + /// Removes all children from the view parent. /// - /// The view group. + /// The view parent. protected virtual void RemoveAllChildren(TPanel parent) { parent.Children.Clear(); diff --git a/ReactWindows/ReactNative/UIManager/PropertySetter.cs b/ReactWindows/ReactNative/UIManager/PropertySetter.cs index 9f7a9b3c01e..13a23a786a7 100644 --- a/ReactWindows/ReactNative/UIManager/PropertySetter.cs +++ b/ReactWindows/ReactNative/UIManager/PropertySetter.cs @@ -71,7 +71,7 @@ string IPropertySetter.PropertyType } } - public void UpdateShadowNodeProperty(ReactShadowNode shadowNode, CatalystStylesDiffMap properties) + public void UpdateShadowNodeProperty(ReactShadowNode shadowNode, ReactStylesDiffMap properties) { if (shadowNode == null) throw new ArgumentNullException(nameof(shadowNode)); @@ -81,7 +81,7 @@ public void UpdateShadowNodeProperty(ReactShadowNode shadowNode, CatalystStylesD Invoke(shadowNode, GetShadowNodeArgs(properties)); } - public void UpdateViewManagerProperty(ViewManager viewManager, FrameworkElement view, CatalystStylesDiffMap properties) + public void UpdateViewManagerProperty(ViewManager viewManager, FrameworkElement view, ReactStylesDiffMap properties) { if (viewManager == null) throw new ArgumentNullException(nameof(viewManager)); @@ -91,12 +91,12 @@ public void UpdateViewManagerProperty(ViewManager viewManager, FrameworkElement Invoke(viewManager, GetViewManagerArgs(view, properties)); } - protected virtual object[] GetShadowNodeArgs(CatalystStylesDiffMap properties) + protected virtual object[] GetShadowNodeArgs(ReactStylesDiffMap properties) { throw new NotSupportedException("ReactShadowNode properties cannot be changed with this setter."); } - protected virtual object[] GetViewManagerArgs(FrameworkElement view, CatalystStylesDiffMap properties) + protected virtual object[] GetViewManagerArgs(FrameworkElement view, ReactStylesDiffMap properties) { throw new NotSupportedException("ViewManager properties cannot be changed with this setter."); } @@ -107,7 +107,7 @@ protected virtual void OnInvoked() { } - protected object ExtractProperty(CatalystStylesDiffMap properties) + protected object ExtractProperty(ReactStylesDiffMap properties) { var result = properties.GetProperty(Name, PropertyType); var defaultFunc = default(Func); @@ -242,7 +242,7 @@ protected override Type GetPropertyType(MethodInfo method) return parameters[1].ParameterType; } - protected override object[] GetViewManagerArgs(FrameworkElement view, CatalystStylesDiffMap properties) + protected override object[] GetViewManagerArgs(FrameworkElement view, ReactStylesDiffMap properties) { s_args[0] = view; s_args[1] = ExtractProperty(properties); @@ -302,7 +302,7 @@ protected override Type GetPropertyType(MethodInfo method) return parameters[2].ParameterType; } - protected override object[] GetViewManagerArgs(FrameworkElement view, CatalystStylesDiffMap properties) + protected override object[] GetViewManagerArgs(FrameworkElement view, ReactStylesDiffMap properties) { s_args[0] = view; s_args[1] = _index; @@ -341,7 +341,7 @@ protected override Type GetPropertyType(MethodInfo method) return parameters[0].ParameterType; } - protected override object[] GetShadowNodeArgs(CatalystStylesDiffMap properties) + protected override object[] GetShadowNodeArgs(ReactStylesDiffMap properties) { s_args[0] = properties.GetProperty(Name, PropertyType); return s_args; @@ -390,7 +390,7 @@ protected override Type GetPropertyType(MethodInfo method) return parameters[1].ParameterType; } - protected override object[] GetShadowNodeArgs(CatalystStylesDiffMap properties) + protected override object[] GetShadowNodeArgs(ReactStylesDiffMap properties) { s_args[0] = _index; s_args[1] = ExtractProperty(properties); diff --git a/ReactWindows/ReactNative/UIManager/ReactPointerEventsView.cs b/ReactWindows/ReactNative/UIManager/ReactPointerEventsView.cs deleted file mode 100644 index 9ba538e8959..00000000000 --- a/ReactWindows/ReactNative/UIManager/ReactPointerEventsView.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ReactNative.UIManager -{ - /// - /// This interface should be implemented be native subclasses that support pointer - /// events handling.It is used to find the target View of a touch event. - /// - public interface ReactPointerEventsView - { - /// - /// Return the PointerEvents of the View. - /// - /// - PointerEvents GetPointerEvents(); - } -} diff --git a/ReactWindows/ReactNative/UIManager/ReactShadowNode.cs b/ReactWindows/ReactNative/UIManager/ReactShadowNode.cs index a8f87204528..7944ac12cfe 100644 --- a/ReactWindows/ReactNative/UIManager/ReactShadowNode.cs +++ b/ReactWindows/ReactNative/UIManager/ReactShadowNode.cs @@ -328,7 +328,7 @@ public virtual void OnBeforeLayout() /// Updates the properties of the node. /// /// The properties. - public void UpdateProperties(CatalystStylesDiffMap properties) + public void UpdateProperties(ReactStylesDiffMap properties) { var setters = ViewManagersPropertyCache.GetNativePropertySettersForShadowNodeType(GetType()); foreach (var key in properties.Keys) diff --git a/ReactWindows/ReactNative/UIManager/CatalystStylesDiffMap.cs b/ReactWindows/ReactNative/UIManager/ReactStylesDiffMap.cs similarity index 89% rename from ReactWindows/ReactNative/UIManager/CatalystStylesDiffMap.cs rename to ReactWindows/ReactNative/UIManager/ReactStylesDiffMap.cs index a4dac50c9c4..be976a116ae 100644 --- a/ReactWindows/ReactNative/UIManager/CatalystStylesDiffMap.cs +++ b/ReactWindows/ReactNative/UIManager/ReactStylesDiffMap.cs @@ -7,15 +7,15 @@ namespace ReactNative.UIManager /// /// A simple container for react properties for views. /// - public class CatalystStylesDiffMap + public class ReactStylesDiffMap { private readonly JObject _properties; /// - /// Instantiates the . + /// Instantiates the . /// /// The property map. - public CatalystStylesDiffMap(JObject properties) + public ReactStylesDiffMap(JObject properties) { if (properties == null) throw new ArgumentNullException(nameof(properties)); diff --git a/ReactWindows/ReactNative/UIManager/ReactStylesDiffMapExtensions.cs b/ReactWindows/ReactNative/UIManager/ReactStylesDiffMapExtensions.cs new file mode 100644 index 00000000000..d2b15c7642c --- /dev/null +++ b/ReactWindows/ReactNative/UIManager/ReactStylesDiffMapExtensions.cs @@ -0,0 +1,10 @@ +namespace ReactNative.UIManager +{ + static class ReactStylesDiffMapExtensions + { + public static T GetProperty(this ReactStylesDiffMap properties, string name) + { + return (T)properties.GetProperty(name, typeof(T)); + } + } +} diff --git a/ReactWindows/ReactNative/UIManager/RootViewManager.cs b/ReactWindows/ReactNative/UIManager/RootViewManager.cs index 04925cfa3ab..eaa52feb4a4 100644 --- a/ReactWindows/ReactNative/UIManager/RootViewManager.cs +++ b/ReactWindows/ReactNative/UIManager/RootViewManager.cs @@ -3,7 +3,7 @@ /// /// View manager for react root view components. /// - public class RootViewManager : PanelViewGroupManager + public class RootViewManager : PanelViewParentManager { /// /// The name of the react root view. @@ -25,5 +25,16 @@ protected override SizeMonitoringCanvas CreateViewInstanceCore(ThemedReactContex { return new SizeMonitoringCanvas(); } + + /// + /// Called when view is detached from view hierarchy and allows for + /// additional cleanup by the . + /// + /// The react context. + /// The view. + protected override void OnDropViewInstance(ThemedReactContext reactContext, SizeMonitoringCanvas view) + { + view.RemoveSizeChanged(); + } } } \ No newline at end of file diff --git a/ReactWindows/ReactNative/UIManager/ThemedReactContext.cs b/ReactWindows/ReactNative/UIManager/ThemedReactContext.cs index f9b05b85408..8e194e2d8ce 100644 --- a/ReactWindows/ReactNative/UIManager/ThemedReactContext.cs +++ b/ReactWindows/ReactNative/UIManager/ThemedReactContext.cs @@ -1,26 +1,41 @@ - +using ReactNative.Bridge; + namespace ReactNative.UIManager { - using ReactNative.Bridge; - + /// + /// A wrapper that delegates lifecycle events to + /// the original instance of . + /// public class ThemedReactContext : ReactContext { - private readonly ReactContext mReactContext; + private readonly ReactContext _reactContext; - public ThemedReactContext(ReactContext reactApplicationContext) { - InitializeWithInstance(reactApplicationContext.CatalystInstance); - mReactContext = reactApplicationContext; + /// + /// Instantiates the . + /// + /// The inner context. + public ThemedReactContext(ReactContext reactContext) + { + InitializeWithInstance(reactContext.ReactInstance); + _reactContext = reactContext; } - public void addLifecycleEventListener(ILifecycleEventListener listener) + /// + /// Adds a lifecycle event listener to the context. + /// + /// The listener. + public override void AddLifecycleEventListener(ILifecycleEventListener listener) { - mReactContext.AddLifecycleEventListener(listener); + _reactContext.AddLifecycleEventListener(listener); } - public void removeLifecycleEventListener(ILifecycleEventListener listener) + /// + /// Removes a lifecycle event listener from the context. + /// + /// The listener. + public override void RemoveLifecycleEventListener(ILifecycleEventListener listener) { - mReactContext.RemoveLifecycleEventListener(listener); + _reactContext.RemoveLifecycleEventListener(listener); } - } } diff --git a/ReactWindows/ReactNative/UIManager/UIImplementation.cs b/ReactWindows/ReactNative/UIManager/UIImplementation.cs index add882508fd..91b486fbcea 100644 --- a/ReactWindows/ReactNative/UIManager/UIImplementation.cs +++ b/ReactWindows/ReactNative/UIManager/UIImplementation.cs @@ -14,12 +14,10 @@ namespace ReactNative.UIManager /// An class that is used to receive React commands from JavaScript and /// translate them into a shadow node hierarchy that is then mapped to a /// native view hierarchy. - /// - /// TODO: - /// 1. View registration for root and children - /// 2. Shadow DOM item updates - /// 3. Animation support /// + /// + /// TODO: Animation support + /// public class UIImplementation { private readonly int[] _measureBuffer = new int[4]; @@ -74,8 +72,8 @@ protected UIImplementation( public void RegisterRootView( SizeMonitoringCanvas rootView, int tag, - int width, - int height, + float width, + float height, ThemedReactContext context) { var rootCssNode = CreateRootShadowNode(); @@ -109,8 +107,8 @@ public void RemoveRootView(int rootViewTag) /// The event dispatcher. public void UpdateRootNodeSize( int rootViewTag, - int newWidth, - int newHeight, + float newWidth, + float newHeight, EventDispatcher eventDispatcher) { var rootCssNode = _shadowNodeRegistry.GetNode(rootViewTag); @@ -146,10 +144,10 @@ public void CreateView(int tag, string className, int rootViewTag, JObject prope _shadowNodeRegistry.AddNode(cssNode); - var styles = default(CatalystStylesDiffMap); + var styles = default(ReactStylesDiffMap); if (properties != null) { - styles = new CatalystStylesDiffMap(properties); + styles = new ReactStylesDiffMap(properties); cssNode.UpdateProperties(styles); } @@ -178,7 +176,7 @@ public void UpdateView(int tag, string className, JObject properties) if (properties != null) { - var styles = new CatalystStylesDiffMap(properties); + var styles = new ReactStylesDiffMap(properties); cssNode.UpdateProperties(styles); HandleUpdateView(cssNode, className, styles); } @@ -543,6 +541,7 @@ public void ShowPopupMenu(int reactTag, string[] items, ICallback error, ICallba /// public void OnSuspend() { + _operationsQueue.OnSuspend(); } /// @@ -550,6 +549,7 @@ public void OnSuspend() /// public void OnResume() { + _operationsQueue.OnResume(); } /// @@ -557,9 +557,10 @@ public void OnResume() /// public void OnShutdown() { + _operationsQueue.OnShutdown(); } - private void HandleCreateView(ReactShadowNode cssNode, int rootViewTag, CatalystStylesDiffMap styles) + private void HandleCreateView(ReactShadowNode cssNode, int rootViewTag, ReactStylesDiffMap styles) { if (!cssNode.IsVirtual) { @@ -570,7 +571,7 @@ private void HandleCreateView(ReactShadowNode cssNode, int rootViewTag, Catalyst private void HandleUpdateView( ReactShadowNode cssNode, string className, - CatalystStylesDiffMap styles) + ReactStylesDiffMap styles) { if (!cssNode.IsVirtual) { @@ -728,17 +729,17 @@ private void AssertNodeDoesNotNeedCustomLayoutForChildren(ReactShadowNode node) node.ViewClass)); } - var viewGroupManager = viewManager as ViewGroupManager; - if (viewGroupManager == null) + var viewParentManager = viewManager as ViewParentManager; + if (viewParentManager == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, - "Trying to use view '{0}' as a parent but its manager is not a ViewGroupManager.", + "Trying to use view '{0}' as a parent but its manager is not a ViewParentManager.", node.ViewClass)); } - if (viewGroupManager.NeedsCustomLayoutForChildren) + if (viewParentManager.NeedsCustomLayoutForChildren) { throw new InvalidOperationException( string.Format( diff --git a/ReactWindows/ReactNative/UIManager/UIImplementationProvider.cs b/ReactWindows/ReactNative/UIManager/UIImplementationProvider.cs index 524384d1855..3f3e28dbcc3 100644 --- a/ReactWindows/ReactNative/UIManager/UIImplementationProvider.cs +++ b/ReactWindows/ReactNative/UIManager/UIImplementationProvider.cs @@ -1,16 +1,21 @@ using ReactNative.Bridge; -using ReactNative.UIManager; using System.Collections.Generic; -using Windows.UI.Xaml; namespace ReactNative.UIManager { /// - /// Provides UIImplementation to use in + /// Provides to use in the + /// . /// public class UIImplementationProvider { - public UIImplementation CreateUIImplementation( + /// + /// Creates the instance. + /// + /// The react context. + /// The view managers. + /// + public UIImplementation Create( ReactContext reactContext, IReadOnlyList viewManagers) { diff --git a/ReactWindows/ReactNative/UIManager/UIManagerModule.Constants.cs b/ReactWindows/ReactNative/UIManager/UIManagerModule.Constants.cs index d5b79fd2463..e383896f04d 100644 --- a/ReactWindows/ReactNative/UIManager/UIManagerModule.Constants.cs +++ b/ReactWindows/ReactNative/UIManager/UIManagerModule.Constants.cs @@ -1,11 +1,12 @@ using ReactNative.UIManager.Events; using System.Collections.Generic; +using Map = System.Collections.Generic.Dictionary; namespace ReactNative.UIManager { - using Windows.UI.Xaml; - using Map = Dictionary; - + /// + /// Native module to allow JavaScript to create and update native views. + /// public partial class UIManagerModule { private const string CUSTOM_BUBBLING_EVENT_TYPES_KEY = "customBubblingEventTypes"; @@ -14,8 +15,14 @@ public partial class UIManagerModule public const string ACTION_DISMISSED = "dismissed"; public const string ACTION_ITEM_SELECTED = "itemSelected"; - public static Dictionary CreateConstants( - IReadOnlyList viewManagers) + /// + /// Create the declared constants for the module. + /// + /// + /// The view managers exported by the module. + /// + /// The constants map. + public static Dictionary CreateConstants(IReadOnlyList viewManagers) { var constants = GetConstants(); var bubblingEventTypesConstants = GetBubblingEventTypeConstants(); @@ -65,7 +72,7 @@ public static Dictionary CreateConstants( return constants; } - public static IDictionary GetBubblingEventTypeConstants() + private static IDictionary GetBubblingEventTypeConstants() { return new Map { @@ -142,7 +149,7 @@ public static IDictionary GetBubblingEventTypeConstants() }; } - public static Dictionary GetDirectEventTypeConstants() + private static Dictionary GetDirectEventTypeConstants() { return new Map { @@ -184,7 +191,7 @@ public static Dictionary GetDirectEventTypeConstants() }; } - public static Dictionary GetConstants() + private static Dictionary GetConstants() { return new Map { diff --git a/ReactWindows/ReactNative/UIManager/UIManagerModule.cs b/ReactWindows/ReactNative/UIManager/UIManagerModule.cs index d140a142734..d521bc42d94 100644 --- a/ReactWindows/ReactNative/UIManager/UIManagerModule.cs +++ b/ReactWindows/ReactNative/UIManager/UIManagerModule.cs @@ -2,15 +2,13 @@ using ReactNative.Bridge; using ReactNative.Tracing; using ReactNative.UIManager.Events; -using ReactNative.Views; using System; using System.Collections.Generic; -using Windows.UI.Xaml; namespace ReactNative.UIManager { /// - /// Native module to allow JS to create and update native Views. + /// Native module to allow JavaScript to create and update native views. /// /// /// TODO: @@ -85,27 +83,29 @@ public EventDispatcher EventDispatcher } /// - /// Registers a new root view. JS can use the returned tag with manageChildren to add/remove - /// children to this view. + /// Registers a new root view. /// - /// - /// + /// The root view instance. + /// The root view tag. + /// + /// JavaScript can use the returned tag with to add or remove children + /// to this view through . + /// public int AddMeasuredRootView(SizeMonitoringCanvas rootView) { var tag = _nextRootTag; _nextRootTag += RootViewTagIncrement; - // TODO: round? - var width = (int)Math.Floor(rootView.ActualWidth); - var height = (int)Math.Floor(rootView.ActualHeight); + var width = (float)rootView.ActualWidth; + var height = (float)rootView.ActualHeight; var context = new ThemedReactContext(Context); _uiImplementation.RegisterRootView(rootView, tag, width, height, context); rootView.SetOnSizeChangedListener((sender, args) => { - var newWidth = (int)Math.Floor(args.NewSize.Width); // TODO: round? - var newHeight = (int)Math.Floor(args.NewSize.Height); // TODO: round? + var newWidth = (float)args.NewSize.Width; + var newHeight = (float)args.NewSize.Height; Context.RunOnDispatcherQueueThread(() => { @@ -411,10 +411,10 @@ public void OnBatchComplete() #region NativeModuleBase - public override void OnCatalystInstanceDispose() + public override void OnReactInstanceDispose() { - base.OnCatalystInstanceDispose(); - _eventDispatcher.OnCatalystInstanceDispose(); + base.OnReactInstanceDispose(); + _eventDispatcher.OnReactInstanceDispose(); } #endregion diff --git a/ReactWindows/ReactNative/UIManager/UIViewOperationQueue.cs b/ReactWindows/ReactNative/UIManager/UIViewOperationQueue.cs index 25760f5a718..44137bae0cb 100644 --- a/ReactWindows/ReactNative/UIManager/UIViewOperationQueue.cs +++ b/ReactWindows/ReactNative/UIManager/UIViewOperationQueue.cs @@ -17,14 +17,15 @@ namespace ReactNative.UIManager /// public class UIViewOperationQueue { - private readonly int[] _measureBuffer = new int[4]; - private readonly object _operationsLock = new object(); + private readonly int[] _measureBuffer = new int[4]; - private IList _operations = new List(); private readonly NativeViewHierarchyManager _nativeViewHierarchyManager; private readonly ReactContext _reactContext; + private IList _operations = new List(); + private bool _isRunning; + /// /// Instantiates the . /// @@ -165,7 +166,7 @@ public void EnqueueCreateView( ThemedReactContext themedContext, int viewReactTag, string viewClassName, - CatalystStylesDiffMap initialProperties) + ReactStylesDiffMap initialProperties) { EnqueueOperation(() => _nativeViewHierarchyManager.CreateView( themedContext, @@ -180,7 +181,7 @@ public void EnqueueCreateView( /// The view tag. /// The class name. /// The properties. - public void EnqueueUpdateProperties(int tag, string className, CatalystStylesDiffMap properties) + public void EnqueueUpdateProperties(int tag, string className, ReactStylesDiffMap properties) { EnqueueOperation(() => _nativeViewHierarchyManager.UpdateProperties(tag, properties)); @@ -308,6 +309,35 @@ public void EnqueueFindTargetForTouch( }); } + /// + /// Called when the host receives the suspend event. + /// + public void OnSuspend() + { + lock (_operationsLock) + { + _isRunning = false; + } + } + + /// + /// Called when the host receives the resume event. + /// + public void OnResume() + { + lock (_operationsLock) + { + _isRunning = true; + } + } + + /// + /// Called when the host is shutting down. + /// + public void OnShutdown() + { + } + /// /// Dispatches the view updates. /// @@ -319,10 +349,13 @@ internal void ExecuteOperations(int batchId) var operations = default(IList); lock (_operationsLock) { - operations = _operations.Count == 0 ? null : _operations; - if (operations != null) + if (_isRunning) { - _operations = new List(); + operations = _operations.Count == 0 ? null : _operations; + if (operations != null) + { + _operations = new List(); + } } } diff --git a/ReactWindows/ReactNative/UIManager/ViewManager.cs b/ReactWindows/ReactNative/UIManager/ViewManager.cs index e89c3f65dab..59bd91737b2 100644 --- a/ReactWindows/ReactNative/UIManager/ViewManager.cs +++ b/ReactWindows/ReactNative/UIManager/ViewManager.cs @@ -68,7 +68,7 @@ public IReadOnlyDictionary NativeProperties /// /// The view to update. /// The properties. - public void UpdateProperties(FrameworkElement viewToUpdate, CatalystStylesDiffMap properties) + public void UpdateProperties(FrameworkElement viewToUpdate, ReactStylesDiffMap properties) { var propertySetters = ViewManagersPropertyCache.GetNativePropertySettersForViewManagerType(GetType()); @@ -98,7 +98,7 @@ public FrameworkElement CreateView( { var view = CreateViewInstance(reactContext); AddEventEmitters(reactContext, view); - var interceptor = view as ICatalystInterceptingViewGroup; + var interceptor = view as IReactInterceptingViewParent; if (interceptor != null) { interceptor.SetOnInterceptTouchEventListener(jsResponderHandler); diff --git a/ReactWindows/ReactNative/UIManager/ViewGroupManager.cs b/ReactWindows/ReactNative/UIManager/ViewParentManager.cs similarity index 82% rename from ReactWindows/ReactNative/UIManager/ViewGroupManager.cs rename to ReactWindows/ReactNative/UIManager/ViewParentManager.cs index 97b8d97c155..14f5d98d770 100644 --- a/ReactWindows/ReactNative/UIManager/ViewGroupManager.cs +++ b/ReactWindows/ReactNative/UIManager/ViewParentManager.cs @@ -7,8 +7,13 @@ namespace ReactNative.UIManager /// /// Class providing child management API for view managers. /// - public abstract class ViewGroupManager : ViewManager + public abstract class ViewParentManager : ViewManager { + /// + /// The instance that represents the type of shadow + /// node that this manager will return from + /// . + /// public sealed override Type ShadowNodeType { get @@ -59,9 +64,9 @@ public override void UpdateExtraData(FrameworkElement root, object extraData) public abstract void AddView(FrameworkElement parent, FrameworkElement child, int index); /// - /// Gets the number of children in the view group. + /// Gets the number of children in the view parent. /// - /// The view group. + /// The view parent. /// The number of children. public abstract int GetChildCount(FrameworkElement parent); @@ -76,14 +81,14 @@ public override void UpdateExtraData(FrameworkElement root, object extraData) /// /// Removes the child at the given index. /// - /// The view group. + /// The view parent. /// The index. public abstract void RemoveChildAt(FrameworkElement parent, int index); /// - /// Removes all children from the view group. + /// Removes all children from the view parent. /// - /// The view group. + /// The view parent. public abstract void RemoveAllChildren(FrameworkElement parent); } } diff --git a/ReactWindows/ReactNative/UIManager/ViewProperties.cs b/ReactWindows/ReactNative/UIManager/ViewProperties.cs index 3512e5a6ce8..b35fcb3b184 100644 --- a/ReactWindows/ReactNative/UIManager/ViewProperties.cs +++ b/ReactWindows/ReactNative/UIManager/ViewProperties.cs @@ -62,7 +62,6 @@ public static class ViewProperties public const string BorderWidth = "borderWidth"; public const string BorderLeftWidth = "borderLeftWidth"; - public const string BorderColor = "borderColor"; public const string BorderTopWidth = "borderTopWidth"; public const string BorderRightWidth = "borderRightWidth"; public const string BorderBottomWidth = "borderBottomWidth"; diff --git a/ReactWindows/ReactNative/Views/Image/ReactImageManager.cs b/ReactWindows/ReactNative/Views/Image/ReactImageManager.cs index 5ef973f603d..9bbcd2af9ca 100644 --- a/ReactWindows/ReactNative/Views/Image/ReactImageManager.cs +++ b/ReactWindows/ReactNative/Views/Image/ReactImageManager.cs @@ -193,7 +193,7 @@ private ImageBrush GetImageBrush(Border border) private static EventDispatcher GetEventDispatcher(FrameworkElement image) { - return image.GetReactContext().CatalystInstance.GetNativeModule().EventDispatcher; + return image.GetReactContext().ReactInstance.GetNativeModule().EventDispatcher; } } } diff --git a/ReactWindows/ReactNative/Views/ReactViewManager.cs b/ReactWindows/ReactNative/Views/ReactViewManager.cs deleted file mode 100644 index 81168fa5ba7..00000000000 --- a/ReactWindows/ReactNative/Views/ReactViewManager.cs +++ /dev/null @@ -1,14 +0,0 @@ -using ReactNative.UIManager; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ReactNative.Views.View -{ - public class ReactViewManager : ViewGroupManager - { - - } -} diff --git a/ReactWindows/ReactNative/Views/Scroll/ReactScrollViewManager.cs b/ReactWindows/ReactNative/Views/Scroll/ReactScrollViewManager.cs index 7b95f5c9570..391e2778ba8 100644 --- a/ReactWindows/ReactNative/Views/Scroll/ReactScrollViewManager.cs +++ b/ReactWindows/ReactNative/Views/Scroll/ReactScrollViewManager.cs @@ -10,7 +10,7 @@ namespace ReactNative.Views.Scroll /// /// TODO: implement this as a proper ScrollViewer instead of a ListView. /// - public class ReactScrollViewManager : ViewGroupManager + public class ReactScrollViewManager : ViewParentManager { private const string ReactClass = "RCTScrollView"; diff --git a/ReactWindows/ReactNative/Views/Switch/ReactSwitchShadowNode.cs b/ReactWindows/ReactNative/Views/Switch/ReactSwitchShadowNode.cs index 3c5069f1b6c..185db21800f 100644 --- a/ReactWindows/ReactNative/Views/Switch/ReactSwitchShadowNode.cs +++ b/ReactWindows/ReactNative/Views/Switch/ReactSwitchShadowNode.cs @@ -19,6 +19,9 @@ public ReactSwitchShadowNode() private static MeasureOutput MeasureSwitch(CSSNode node, float width, float height) { // TODO: figure out how to properly measure the switch. + // We are currently blocked until we switch to a UWP-specific React + // JavaScript library as the iOS library we currently use specifies + // an exact width and height for switch nodes. return new MeasureOutput(56, 40); } } diff --git a/ReactWindows/ReactNative/Views/Text/FontStyleHelpers.cs b/ReactWindows/ReactNative/Views/Text/FontStyleHelpers.cs index 3a2872436fe..ac691dd86d1 100644 --- a/ReactWindows/ReactNative/Views/Text/FontStyleHelpers.cs +++ b/ReactWindows/ReactNative/Views/Text/FontStyleHelpers.cs @@ -4,45 +4,35 @@ namespace ReactNative.Views.Text { static class FontStyleHelpers { - public static bool TryParseFontWeightString(string fontWeightString, out FontWeight fontWeight) + public static FontWeight? ParseFontWeight(string fontWeightString) { var fontWeightNumeric = fontWeightString != null ? ParseNumericFontWeight(fontWeightString) : -1; - fontWeight = default(FontWeight); - if (fontWeightNumeric >= 500 || fontWeightString == "bold") { - fontWeight = FontWeights.Bold; - return true; + return FontWeights.Bold; } else if (fontWeightString == "normal" || (fontWeightNumeric != -1 && fontWeightNumeric < 500)) { - fontWeight = FontWeights.Normal; - return true; + return FontWeights.Normal; } - return false; + return null; } - public static bool TryParseFontStyleString(string fontStyleString, out FontStyle fontStyle) + public static FontStyle? ParseFontStyle(string fontStyleString) { - fontStyle = default(FontStyle); - switch (fontStyleString) { case "italic": - fontStyle = FontStyle.Italic; - break; + return FontStyle.Italic; case "normal": - fontStyle = FontStyle.Normal; - break; + return FontStyle.Normal; default: - return false; + return null; } - - return true; } private static int ParseNumericFontWeight(string fontWeightString) diff --git a/ReactWindows/ReactNative/Views/Text/ReactRawTextManager.cs b/ReactWindows/ReactNative/Views/Text/ReactRawTextManager.cs index 3720b0f5734..8bb592b2ac8 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactRawTextManager.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactRawTextManager.cs @@ -4,10 +4,16 @@ namespace ReactNative.Views.Text { + /// + /// A virtual view manager for raw text nodes. + /// public class ReactRawTextManager : ReactTextViewManager { private const string ReactClass = "RCTRawText"; + /// + /// The name of the view manager. + /// public override string Name { get @@ -16,15 +22,29 @@ public override string Name } } + /// + /// Should not be called, as this is a virtual view manager. + /// + /// Irrelevant. + /// Irrelevant. protected override TextBlock CreateViewInstanceCore(ThemedReactContext reactContext) { throw new InvalidOperationException("RCTRawText does not map to a native view."); } + /// + /// Should not be called, as this is a virtual view manager. + /// + /// Irrelevant. + /// Irrelevant. protected override void UpdateExtraData(TextBlock root, object extraData) { } + /// + /// Creates a shadow node instance for a view. + /// + /// The shadow node instance. protected override ReactTextShadowNode CreateShadowNodeInstanceCore() { return new ReactTextShadowNode(true); diff --git a/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs b/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs index d89a5e9ff93..a737563ff76 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs @@ -12,6 +12,9 @@ namespace ReactNative.Views.Text { + /// + /// The shadow node implementation for text views. + /// public class ReactTextShadowNode : LayoutShadowNode { private const string INLINE_IMAGE_PLACEHOLDER = "I"; @@ -38,6 +41,12 @@ public class ReactTextShadowNode : LayoutShadowNode private readonly bool _isVirtual; + /// + /// Instantiates the . + /// + /// + /// A flag signaling whether or not the shadow node is virtual. + /// public ReactTextShadowNode(bool isVirtual) { _isVirtual = isVirtual; @@ -48,6 +57,12 @@ public ReactTextShadowNode(bool isVirtual) } } + /// + /// Flag signaling if the given node is virtual. + /// + /// + /// All text nodes except the root text node are virtual. + /// public override bool IsVirtual { get @@ -56,6 +71,12 @@ public override bool IsVirtual } } + /// + /// Flag signaling if the given node is a root node for virtual nodes. + /// + /// + /// The root text node is a virtual anchor. + /// public override bool IsVirtualAnchor { get @@ -64,6 +85,10 @@ public override bool IsVirtualAnchor } } + /// + /// Called once per batch of updates by the + /// if the text node is dirty. + /// public override void OnBeforeLayout() { // We need to perform this operation on the dispatcher in UWP as @@ -81,16 +106,10 @@ public override void OnBeforeLayout() MarkUpdated(); } - protected override void MarkUpdated() - { - base.MarkUpdated(); - - if (!_isVirtual) - { - dirty(); - } - } - + /// + /// Called to aggregate all the changes to the virtual text nodes. + /// + /// The UI operation queue. public override void OnCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { if (_isVirtual) @@ -105,6 +124,10 @@ public override void OnCollectExtraUpdates(UIViewOperationQueue uiViewOperationQ } } + /// + /// Sets the text for the node. + /// + /// The text. [ReactProperty("text")] public void SetText(string text) { @@ -112,6 +135,10 @@ public void SetText(string text) MarkUpdated(); } + /// + /// Sets the number of lines for the node. + /// + /// The number of lines. [ReactProperty(ViewProperties.NumberOfLines, DefaultInteger = UNSET)] public void SetNumberOfLines(int numberOfLines) { @@ -119,6 +146,10 @@ public void SetNumberOfLines(int numberOfLines) MarkUpdated(); } + /// + /// Sets the line height for the node. + /// + /// The line height. [ReactProperty(ViewProperties.LineHeight, DefaultInteger = UNSET)] public void SetLineHeight(int lineHeight) { @@ -126,6 +157,10 @@ public void SetLineHeight(int lineHeight) MarkUpdated(); } + /// + /// Sets the font size for the node. + /// + /// The font size. [ReactProperty(ViewProperties.FontSize, DefaultDouble = UNSET)] public void SetFontSize(double fontSize) { @@ -133,7 +168,11 @@ public void SetFontSize(double fontSize) MarkUpdated(); } - [ReactProperty(ViewProperties.Color)] + /// + /// Sets the font color for the node. + /// + /// The masked color value. + [ReactProperty(ViewProperties.Color, CustomType = "Color")] public void SetColor(uint? color) { _isColorSet = color.HasValue; @@ -145,7 +184,11 @@ public void SetColor(uint? color) MarkUpdated(); } - [ReactProperty(ViewProperties.BackgroundColor)] + /// + /// Sets the background color for the node. + /// + /// The masked color value. + [ReactProperty(ViewProperties.BackgroundColor, CustomType = "Color")] public void SetBackgroundColor(uint? color) { if (!IsVirtualAnchor) @@ -160,6 +203,10 @@ public void SetBackgroundColor(uint? color) } } + /// + /// Sets the font family for the node. + /// + /// The font family. [ReactProperty(ViewProperties.FontFamily)] public void SetFontFamily(string fontFamily) { @@ -167,31 +214,48 @@ public void SetFontFamily(string fontFamily) MarkUpdated(); } + /// + /// Sets the font weight for the node. + /// + /// The font weight string. [ReactProperty(ViewProperties.FontWeight)] public void SetFontWeight(string fontWeightString) { - var fontWeight = default(FontWeight); - if (FontStyleHelpers.TryParseFontWeightString(fontWeightString, out fontWeight)) + var fontWeight = FontStyleHelpers.ParseFontWeight(fontWeightString); + if (_fontWeight.HasValue != fontWeight.HasValue || + (_fontWeight.HasValue && fontWeight.HasValue && + _fontWeight.Value.Weight != fontWeight.Value.Weight)) { - if (_fontWeight.HasValue && _fontWeight.Value.Weight != fontWeight.Weight) - { - _fontWeight = fontWeight; - MarkUpdated(); - } + _fontWeight = fontWeight; + MarkUpdated(); } } + /// + /// Sets the font style for the node. + /// + /// The font style string. [ReactProperty(ViewProperties.FontStyle)] public void SetFontStyle(string fontStyleString) { - var fontStyle = default(FontStyle); - if (FontStyleHelpers.TryParseFontStyleString(fontStyleString, out fontStyle)) + var fontStyle = FontStyleHelpers.ParseFontStyle(fontStyleString); + if (_fontStyle != fontStyle) { - if (_fontStyle != fontStyle) - { - _fontStyle = fontStyle; - MarkUpdated(); - } + _fontStyle = fontStyle; + MarkUpdated(); + } + } + + /// + /// Marks a node as dirty. + /// + protected override void MarkUpdated() + { + base.MarkUpdated(); + + if (!_isVirtual) + { + dirty(); } } diff --git a/ReactWindows/ReactNative/Views/Text/ReactTextUpdate.cs b/ReactWindows/ReactNative/Views/Text/ReactTextUpdate.cs deleted file mode 100644 index 723cf4d3a60..00000000000 --- a/ReactWindows/ReactNative/Views/Text/ReactTextUpdate.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ReactNative.Views.Text -{ - class ReactTextUpdate - { - } -} diff --git a/ReactWindows/ReactNative/Views/Text/ReactTextViewManager.cs b/ReactWindows/ReactNative/Views/Text/ReactTextViewManager.cs index ffd3f1c8dc6..a2e60d65a4a 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactTextViewManager.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactTextViewManager.cs @@ -5,10 +5,16 @@ namespace ReactNative.Views.Text { + /// + /// The view manager for text views. + /// public class ReactTextViewManager : BaseViewManager { private const string ReactClass = "RCTText"; + /// + /// The name of the view manager. + /// public override string Name { get @@ -17,6 +23,11 @@ public override string Name } } + /// + /// Creates the view instance. + /// + /// The react context. + /// The view instance. protected override TextBlock CreateViewInstanceCore(ThemedReactContext reactContext) { return new TextBlock @@ -25,11 +36,20 @@ protected override TextBlock CreateViewInstanceCore(ThemedReactContext reactCont }; } + /// + /// Creates the shadow node instance. + /// + /// The shadow node instance. protected override ReactTextShadowNode CreateShadowNodeInstanceCore() { return new ReactTextShadowNode(false); } + /// + /// Updates the node with the changes to the inner virtual nodes. + /// + /// The view instance. + /// The aggregated virtual node changes. protected override void UpdateExtraData(TextBlock root, object extraData) { var inline = (Inline)extraData; diff --git a/ReactWindows/ReactNative/Views/Text/ReactVirtualTextViewManager.cs b/ReactWindows/ReactNative/Views/Text/ReactVirtualTextViewManager.cs index 3c07a3dc4d5..b0e65a05a1f 100644 --- a/ReactWindows/ReactNative/Views/Text/ReactVirtualTextViewManager.cs +++ b/ReactWindows/ReactNative/Views/Text/ReactVirtualTextViewManager.cs @@ -1,9 +1,15 @@ namespace ReactNative.Views.Text { + /// + /// A virtual view manager for raw text nodes. + /// public class ReactVirtualTextViewManager : ReactRawTextManager { private const string ReactClass = "RCTVirtualText"; + /// + /// The view manager name. + /// public override string Name { get diff --git a/ReactWindows/ReactNative/Views/TextInput/ReactTextInputShadowNode.cs b/ReactWindows/ReactNative/Views/TextInput/ReactTextInputShadowNode.cs index 0e932b550d9..238935ffde7 100644 --- a/ReactWindows/ReactNative/Views/TextInput/ReactTextInputShadowNode.cs +++ b/ReactWindows/ReactNative/Views/TextInput/ReactTextInputShadowNode.cs @@ -101,14 +101,13 @@ public void SetFontFamily(string fontFamily) [ReactProperty(ViewProperties.FontWeight)] public void SetFontWeight(string fontWeightString) { - var fontWeight = default(FontWeight); - if (FontStyleHelpers.TryParseFontWeightString(fontWeightString, out fontWeight)) + var fontWeight = FontStyleHelpers.ParseFontWeight(fontWeightString); + if (_textBoxStyle.FontWeight.HasValue != fontWeight.HasValue || + (_textBoxStyle.FontWeight.HasValue && fontWeight.HasValue && + _textBoxStyle.FontWeight.Value.Weight != fontWeight.Value.Weight)) { - if (_textBoxStyle.FontWeight.HasValue || _textBoxStyle.FontWeight.Value.Weight != fontWeight.Weight) - { - _textBoxStyle.FontWeight = fontWeight; - MarkUpdated(); - } + _textBoxStyle.FontWeight = fontWeight; + MarkUpdated(); } } @@ -119,14 +118,11 @@ public void SetFontWeight(string fontWeightString) [ReactProperty(ViewProperties.FontStyle)] public void SetFontStyle(string fontStyleString) { - var fontStyle = default(FontStyle); - if (FontStyleHelpers.TryParseFontStyleString(fontStyleString, out fontStyle)) + var fontStyle = FontStyleHelpers.ParseFontStyle(fontStyleString); + if (_textBoxStyle.FontStyle != fontStyle) { - if (_textBoxStyle.FontStyle != fontStyle) - { - _textBoxStyle.FontStyle = fontStyle; - MarkUpdated(); - } + _textBoxStyle.FontStyle = fontStyle; + MarkUpdated(); } } @@ -145,7 +141,7 @@ public void SetText(string text) /// Sets the the backgrund border color for a . /// /// - [ReactProperty(ViewProperties.BorderColor)] + [ReactProperty("borderColor")] public void SetBorderColor(uint? color) { if (color.HasValue) diff --git a/ReactWindows/ReactNative/Views/View/ReactCanvas.cs b/ReactWindows/ReactNative/Views/View/ReactCanvas.cs new file mode 100644 index 00000000000..e49a988a7d4 --- /dev/null +++ b/ReactWindows/ReactNative/Views/View/ReactCanvas.cs @@ -0,0 +1,59 @@ +using ReactNative.Touch; +using ReactNative.UIManager; +using Windows.Foundation; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Input; + +namespace ReactNative.Views.View +{ + /// + /// Backing for a react view. + /// + /// + /// TODO: Implement clipping. + /// + public class ReactCanvas : Canvas, IReactInterceptingViewParent, IReactPointerEventsView + { + private IOnInterceptTouchEventListener _onInterceptTouchEventListener; + + /// + /// The pointer events supported by the view. + /// + public PointerEvents PointerEvents { get; internal set; } = PointerEvents.Auto; + + /// + /// Sets the touch event listener for the react view. + /// + /// The custom touch event listener. + public void SetOnInterceptTouchEventListener(IOnInterceptTouchEventListener listener) + { + _onInterceptTouchEventListener = listener; + PointerPressed += OnInterceptTouchEvent; + } + + /// + /// Provides the behavior for the measure pass of the layout cycle. + /// + /// The available size. + /// The desired size. + /// + /// Simple override that asserts that the desired size is explicit. + /// + protected override Size MeasureOverride(Size availableSize) + { + var resultSize = base.MeasureOverride(availableSize); + MeasureAssertions.AssertExplicitMeasurement(resultSize.Width, resultSize.Height); + return resultSize; + } + + private void OnInterceptTouchEvent(object sender, PointerRoutedEventArgs ev) + { + if (PointerEvents == PointerEvents.None || PointerEvents == PointerEvents.BoxNone) + { + return; + } + + _onInterceptTouchEventListener.OnInterceptTouchEvent(sender, ev); + } + } +} diff --git a/ReactWindows/ReactNative/Views/View/ReactPanel.cs b/ReactWindows/ReactNative/Views/View/ReactPanel.cs deleted file mode 100644 index 307767f5fa0..00000000000 --- a/ReactWindows/ReactNative/Views/View/ReactPanel.cs +++ /dev/null @@ -1,229 +0,0 @@ -using ReactNative.Touch; -using ReactNative.UIManager; -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Media.Media3D; - -namespace ReactNative.Views.View -{ - /// - /// Backing for a React View. Has support for borders, but since borders - /// aren't common, lazy initializes most of the storage needed for them. Also supports - /// 3D transformations such as elevation depth. - /// - public class ReactPanel : Canvas, ICatalystInterceptingViewGroup, ReactPointerEventsView - { - private IOnInterceptTouchEventListener _onInterceptTouchEventListener; - private PointerEvents _PointerEvents = PointerEvents.Auto; - private Border _Border; - private CompositeTransform3D _Transform = new CompositeTransform3D(); - - public ReactPanel() : base() - { - this.SizeChanged += OnBoundsChanged; - } - - public PointerEvents PointerEvents - { - set - { - _PointerEvents = value; - } - } - - /// - /// Stubbed out so any class that implements can - /// override the OnBoundsChanged. - /// TODO: The default behavior for RCTView still needs to be - /// d. - /// - /// - /// - protected virtual void OnBoundsChanged(object sender, SizeChangedEventArgs e) - { - } - - public PointerEvents GetPointerEvents() - { - return _PointerEvents; - } - - /// - /// Sets the touch event listener for the react view. - /// - /// The custom touch event listener. - public void SetOnInterceptTouchEventListener(IOnInterceptTouchEventListener listener) - { - _onInterceptTouchEventListener = listener; - this.PointerPressed += OnInterceptTouchEvent; - } - - private void OnInterceptTouchEvent(object sender, PointerRoutedEventArgs ev) - { - if (_PointerEvents == PointerEvents.None || _PointerEvents == PointerEvents.BoxNone) - { - return; - } - - _onInterceptTouchEventListener.OnInterceptTouchEvent(sender, ev); - } - - public void SetBackgroundColor(string color) - { - this.Background = ParseColor(color); - } - - private static Brush ParseColor(string color) - { - var r = Convert.ToByte(color.Substring(1, 2), 16); - var g = Convert.ToByte(color.Substring(3, 2), 16); - var b = Convert.ToByte(color.Substring(5, 2), 16); - return new SolidColorBrush(Windows.UI.Color.FromArgb(255, r, g, b)); - } - - /// - /// Sets the border background color. - /// - /// The Hex color code - public void SetBorderBackgroundColor(string color) - { - GetOrCreateReactViewBorder().Background = ParseColor(color); - } - - /// - /// Sets the outer border brush color. - /// - /// The color Hex code - public void SetBorderOuterColor(string color) - { - GetOrCreateReactViewBorder().BorderBrush = ParseColor(color); - } - - /// - /// Sets the border radius. - /// - /// Boder radius - public void SetBorderRadius(float borderRadius) - { - GetOrCreateReactViewBorder().CornerRadius = new CornerRadius(borderRadius); - } - - private Border GetOrCreateReactViewBorder() - { - if (_Border == null) - { - _Border = new Border(); - _Border.Child = this; - } - - return _Border; - } - - /// - /// Sets the border padding for the . - /// - /// The padding of the in pixels. - public void SetBorderThickness(float thickness) - { - GetOrCreateReactViewBorder().BorderThickness = new Thickness(thickness); - } - - /// - /// Sets the padding for the . - /// - /// The padding of the in pixels. - public void SetBorderPadding(float thickness) - { - GetOrCreateReactViewBorder().Padding = new Thickness(thickness); - } - - /// - /// Sets an elevation 3D transformation effect on the . - /// - /// The positive negative elevation Z Index value of the view. - public void SetElevationEffect(float elevation) - { - _Transform.TranslateZ = elevation; - this.Transform3D = _Transform; - } - - /// - /// Sets the distance to translate along the x-axis in pixels of the view panel. - /// - /// The translation distance value along the x-axis. - public void setTranslationX(float distance) - { - _Transform.TranslateX = distance; - this.Transform3D = _Transform; - } - - /// - /// Sets the angle in degrees of clockwise rotation around the x-axis - /// of the view panel. - /// - /// The x-axis rotation degrees. - public void setRotationX(float degrees) - { - _Transform.RotationX = degrees; - this.Transform3D = _Transform; - } - - /// - /// Sets the angle in degrees of clockwise rotation around the y-axis - /// of the view panel. - /// - /// The y-axis rotation degrees. - public void setRotationY(float degrees) - { - _Transform.RotationY = degrees; - this.Transform3D = _Transform; - } - - - /// - /// Sets the distance to translate along the y-axis in pixels of the view panel. - /// - /// The translation distance value along the y-axis. - public void setTranslationY(float value) - { - _Transform.TranslateY = value; - this.Transform3D = _Transform; - } - - /// - /// Sets the y-axis scale factor. You can use this property to stretch or shrink - /// the panel along the y-axis. - /// - /// The y-axis scale factor. - public void setScaleY(float factor) - { - _Transform.ScaleY = factor; - this.Transform3D = _Transform; - } - - /// - /// Sets the y-axis scale factor. You can use this property to stretch or shrink - /// the panel along the x-axis. - /// - /// The x-axis scale factor. - public void setScaleX(float factor) - { - _Transform.ScaleX = factor; - this.Transform3D = _Transform; - } - - /// - /// Retrieves the number of subviews for the current view. - /// - public int ChildrenCount - { - get - { - return this.Children.Count; - } - } - } -} diff --git a/ReactWindows/ReactNative/Views/View/ReactViewManager.cs b/ReactWindows/ReactNative/Views/View/ReactViewManager.cs index 4e7c949448e..438b693248f 100644 --- a/ReactWindows/ReactNative/Views/View/ReactViewManager.cs +++ b/ReactWindows/ReactNative/Views/View/ReactViewManager.cs @@ -8,7 +8,10 @@ namespace ReactNative.Views.View { - public class ReactViewManager : ViewGroupManager + /// + /// View manager for React view instances. + /// + public class ReactViewManager : ViewParentManager { private const string ReactClass = ViewProperties.ViewClassName; private const int CommandSetPressed = 1; @@ -47,31 +50,51 @@ public override IReadOnlyDictionary CommandsMap /// The index. public override void AddView(FrameworkElement parent, FrameworkElement child, int index) { - var panel = GetPanel(parent); + var panel = GetInstance(parent); panel.Children.Insert(index, child); } + /// + /// Gets the number of children in the view parent. + /// + /// The view parent. + /// The number of children. public override int GetChildCount(FrameworkElement parent) { - var panel = GetPanel(parent); + var panel = GetInstance(parent); return panel.Children.Count; } + /// + /// Gets the child at the given index. + /// + /// The parent view. + /// The index. + /// The child view. public override FrameworkElement GetChildAt(FrameworkElement parent, int index) { - var panel = GetPanel(parent); + var panel = GetInstance(parent); return (FrameworkElement)panel.Children[index]; } + /// + /// Removes the child at the given index. + /// + /// The view parent. + /// The index. public override void RemoveChildAt(FrameworkElement parent, int index) { - var panel = GetPanel(parent); + var panel = GetInstance(parent); panel.Children.RemoveAt(index); } + /// + /// Removes all children from the view parent. + /// + /// The view parent. public override void RemoveAllChildren(FrameworkElement parent) { - var panel = GetPanel(parent); + var panel = GetInstance(parent); panel.Children.Clear(); } @@ -86,7 +109,7 @@ public override void RemoveAllChildren(FrameworkElement parent) /// Optional arguments for the command. public override void ReceiveCommand(FrameworkElement view, int commandId, JArray args) { - var panel = GetPanel(view); + var panel = GetInstance(view); if (args.Count != 1) { throw new ArgumentException("Receive commands for the ReactViewModel currently only supports the setPressed command", nameof(args)); @@ -112,19 +135,22 @@ public void SetBorderRadius(BorderedContentControl view, double radius) } /// - /// Sets the elevation transformation effect of the . + /// Set the border color of the . /// /// The view panel. - /// The 3D Z-Location index of the . - [ReactProperty("elevation")] - public void SetElevation(BorderedContentControl view, float elevation) + /// The color hex code. + [ReactProperty("borderColor", CustomType = "Color")] + public void SetBorderColor(BorderedContentControl view, uint? color) { - var panel = GetPanel(view); - panel.SetElevationEffect(elevation); + // TODO: what if color is null? + if (color.HasValue) + { + view.SetBorderColor(color.Value); + } } /// - /// Sets the pointer events based on a event string key. + /// Sets the pointer events based on a event string key. /// /// The view panel. /// The event to propogate down to the view. @@ -140,7 +166,7 @@ public void SetPointerEvents(BorderedContentControl view, string pointerEventsSt } /// - /// Sets the border thickness of the . + /// Sets the border thickness of the . /// /// The view panel. /// The property index. @@ -157,28 +183,6 @@ public void SetBorderWidth(BorderedContentControl view, int index, double width) view.SetBorderWidth(ViewProperties.BorderSpacingTypes[index], width); } - /// - /// Set the border color of the . - /// - /// The view panel. - /// The property index. - /// The color hex code. - [ReactPropertyGroup( - "borderColor", - "borderLeftColor", - "borderRightColor", - "borderTopColor", - "borderBottomColor", - CustomType = "Color")] - public void SetBorderColor(BorderedContentControl view, int index, uint? color) - { - // TODO: what if color is null? - if (color.HasValue) - { - view.SetBorderColor(ViewProperties.BorderSpacingTypes[index], color.Value); - } - } - /// /// Creates a new view instance of type . /// @@ -186,17 +190,17 @@ public void SetBorderColor(BorderedContentControl view, int index, uint? color) /// The view instance. protected override FrameworkElement CreateViewInstance(ThemedReactContext reactContext) { - return new BorderedContentControl(new ReactPanel()); + return new BorderedContentControl(new ReactCanvas()); } - private ReactPanel GetPanel(FrameworkElement element) + private ReactCanvas GetInstance(FrameworkElement element) { return GetPanel((BorderedContentControl)element); } - private ReactPanel GetPanel(BorderedContentControl control) + private ReactCanvas GetPanel(BorderedContentControl control) { - return (ReactPanel)control.Content; + return (ReactCanvas)control.Content; } } } diff --git a/ReactWindows/UpgradeLog.htm b/ReactWindows/UpgradeLog.htm deleted file mode 100644 index 2284a0f8135..00000000000 Binary files a/ReactWindows/UpgradeLog.htm and /dev/null differ diff --git a/windows-packager/.index.ios.js.swp b/windows-packager/.index.ios.js.swp deleted file mode 100644 index d88ed8cd09c..00000000000 Binary files a/windows-packager/.index.ios.js.swp and /dev/null differ