public async Task UIManagerModule_CustomEvents_Constants()
        {
            var context = new ReactContext();
            var viewManagers = new List<IViewManager>();
            var uiImplementation = new UIImplementation(context, viewManagers);

            var module = await DispatcherHelpers.CallOnDispatcherAsync(
                () => new UIManagerModule(context, viewManagers, uiImplementation));

            var constants = module.Constants;

            Assert.AreEqual("onSelect", constants.GetMap("customBubblingEventTypes").GetMap("topSelect").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onSelectCapture", constants.GetMap("customBubblingEventTypes").GetMap("topSelect").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onChange", constants.GetMap("customBubblingEventTypes").GetMap("topChange").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onChangeCapture", constants.GetMap("customBubblingEventTypes").GetMap("topChange").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchStart", constants.GetMap("customBubblingEventTypes").GetMap("topTouchStart").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchStartCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchStart").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchMove", constants.GetMap("customBubblingEventTypes").GetMap("topTouchMove").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchMoveCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchMove").GetMap("phasedRegistrationNames").GetValue("captured"));
            Assert.AreEqual("onTouchEnd", constants.GetMap("customBubblingEventTypes").GetMap("topTouchEnd").GetMap("phasedRegistrationNames").GetValue("bubbled"));
            Assert.AreEqual("onTouchEndCapture", constants.GetMap("customBubblingEventTypes").GetMap("topTouchEnd").GetMap("phasedRegistrationNames").GetValue("captured"));

            Assert.AreEqual("onSelectionChange", constants.GetMap("customDirectEventTypes").GetMap("topSelectionChange").GetValue("registrationName"));
            Assert.AreEqual("onLoadingStart", constants.GetMap("customDirectEventTypes").GetMap("topLoadingStart").GetValue("registrationName"));
            Assert.AreEqual("onLoadingFinish", constants.GetMap("customDirectEventTypes").GetMap("topLoadingFinish").GetValue("registrationName"));
            Assert.AreEqual("onLoadingError", constants.GetMap("customDirectEventTypes").GetMap("topLoadingError").GetValue("registrationName"));
            Assert.AreEqual("onLayout", constants.GetMap("customDirectEventTypes").GetMap("topLayout").GetValue("registrationName"));
        }
 public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
 {
     return new List<INativeModule>
     {
          new CodePushNativeModule(reactContext, this)
     };
 }
 /// <summary>
 /// Creates the list of native modules to register with the react
 /// instance. 
 /// </summary>
 /// <param name="reactContext">The react application context.</param>
 /// <returns>The list of native modules.</returns>
 public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
 {
     return new List<INativeModule>
     {
         new RNShareModule(),
     };
 }
        /// <summary>
        /// Instantiates the <see cref="ReactContextNativeModuleBase"/>.
        /// </summary>
        /// <param name="reactContext">The React context.</param>
        protected ReactContextNativeModuleBase(ReactContext reactContext)
        {
            if (reactContext == null)
                throw new ArgumentNullException(nameof(reactContext));

            Context = reactContext;
        }
 public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
 {
     return new List<INativeModule>
     {
         new RNDeviceInfoModule(reactContext)
     };
 }
        public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
        {
            var uiManagerModule = default(INativeModule);
            using (Tracer.Trace(Tracer.TRACE_TAG_REACT_BRIDGE, "createUIManagerModule").Start())
            {
                var viewManagerList = _reactInstanceManager.CreateAllViewManagers(reactContext);
                uiManagerModule = new UIManagerModule(
                    reactContext, 
                    viewManagerList,
                    _uiImplementationProvider.Create(
                        reactContext, 
                        viewManagerList));
            }

            return new List<INativeModule>
            {
                //new AnimationsDebugModule(
                //    reactContext,
                //    _reactInstanceManager.DevSupportManager.DevSettings),
                //new SystemInfoModule(),
                new DeviceEventManagerModule(reactContext, _hardwareBackButtonHandler),
                new ExceptionsManagerModule(_reactInstanceManager.DevSupportManager),
                new Timing(reactContext),
                new SourceCodeModule(
                    _reactInstanceManager.SourceUrl,
                    _reactInstanceManager.DevSupportManager.SourceMapUrl),
                uiManagerModule,
                //new DebugComponentOwnershipModule(reactContext),
            };
        }
Пример #7
0
 /// <summary>
 /// Creates the list of view managers that should be registered with
 /// the <see cref="UIManagerModule"/>.
 /// </summary>
 /// <param name="reactContext">The react application context.</param>
 /// <returns>The list of view managers.</returns>
 public IReadOnlyList<IViewManager> CreateViewManagers(
     ReactContext reactContext)
 {
     return new List<IViewManager>
     {
         new LinearGradientViewManager(),
     };
 }
 /// <summary>
 /// Instantiates the <see cref="DeviceEventManagerModule"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 /// <param name="onBackPressed">
 /// The action to take when back is pressed.
 /// </param>
 public DeviceEventManagerModule(
     ReactContext reactContext,
     Action onBackPressed)
   : base(reactContext)
 {
     _invokeDefaultBackPressAction = () =>
     {
         DispatcherHelpers.AssertOnDispatcher();
         onBackPressed();
     };
 }
        public void ReactContextNativeModuleBase_ArgumentChecks()
        {
            ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
                () => { new TestModule(null); }
            );
            Assert.AreEqual("reactContext", ex.ParamName);

            var context = new ReactContext();
            var module = new TestModule(context);
            Assert.AreSame(context, module.Context);
        }
        public void UIManagerModule_ArgumentChecks()
        {
            var context = new ReactContext();
            var viewManagers = new List<IViewManager>();
            var uiImplementation = new UIImplementation(context, viewManagers);

            AssertEx.Throws<ArgumentNullException>(
                () => new UIManagerModule(context, null, uiImplementation),
                ex => Assert.AreEqual("viewManagers", ex.ParamName));

            AssertEx.Throws<ArgumentNullException>(
                () => new UIManagerModule(context, viewManagers, null),
                ex => Assert.AreEqual("uiImplementation", ex.ParamName));
        }
        /// <summary>
        /// Instantiates a <see cref="UIManagerModule"/>.
        /// </summary>
        /// <param name="reactContext">The React context.</param>
        /// <param name="viewManagers">The view managers.</param>
        /// <param name="uiImplementation">The UI implementation.</param>
        public UIManagerModule(
            ReactContext reactContext,
            IReadOnlyList<IViewManager> viewManagers,
            UIImplementation uiImplementation)
            : base(reactContext)
        {
            if (viewManagers == null)
                throw new ArgumentNullException(nameof(viewManagers));
            if (uiImplementation == null)
                throw new ArgumentNullException(nameof(uiImplementation));

            _eventDispatcher = new EventDispatcher(reactContext);
            _uiImplementation = uiImplementation;
            _moduleConstants = CreateConstants(viewManagers);
            reactContext.AddLifecycleEventListener(this);
        }
        public async Task UIManagerModule_Constants_ViewManagerOverrides()
        {
            var context = new ReactContext();
            var viewManagers = new List<IViewManager> { new TestViewManager() };
            var uiImplementation = new UIImplementation(context, viewManagers);

            var module = await DispatcherHelpers.CallOnDispatcherAsync(
                () => new UIManagerModule(context, viewManagers, uiImplementation));

            var constants = module.Constants;

            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetValue("otherSelectionChange"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetMap("topSelectionChange").GetValue("registrationName"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetMap("topLoadingStart").GetValue("foo"));
            Assert.AreEqual(42, constants.GetMap("customDirectEventTypes").GetValue("topLoadingError"));
        }
Пример #13
0
 public WebSocketModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
Пример #14
0
 public WebSocketModule(ReactContext reactContext)
     : base(reactContext)
 {
     Websockets.Net.WebsocketConnection.Link();
 }
Пример #15
0
 public DialogModule(ReactContext reactContext)
     : base(reactContext)
 {
     _dialog = new ReactDialog();
 }
Пример #16
0
 public RNFSManager(ReactContext reactContext)
     : base(reactContext)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="OrientationModule"/>.
 /// </summary>
 internal OrientationModule(ReactContext _context)
 {
     RCTContext = _context;
     DisplayInformation.GetForCurrentView().OrientationChanged += this.OnOrientationChange;
 }
 public CodePushNativeModule(ReactContext reactContext, CodePushReactPackage codePush) : base(reactContext)
 {
     _reactContext = reactContext;
     _codePush = codePush;
 }
Пример #19
0
 /// <summary>
 /// Creates the list of native modules to register with the react
 /// instance. 
 /// </summary>
 /// <param name="reactContext">The react application context.</param>
 /// <returns>The list of native modules.</returns>
 public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
 {
     return new List<INativeModule>(0);
 }
Пример #20
0
 /// <summary>
 /// Instantiates the <see cref="NetInfoModule"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 public NetInfoModule(ReactContext reactContext)
     : this(new DefaultNetworkInformation(), reactContext)
 {
 }
        private void ProcessPackage(
            IReactPackage reactPackage,
            ReactContext reactContext,
            NativeModuleRegistry.Builder nativeRegistryBuilder,
            JavaScriptModuleRegistry.Builder jsModulesBuilder)
        {
            foreach (var nativeModule in reactPackage.CreateNativeModules(reactContext))
            {
                nativeRegistryBuilder.Add(nativeModule);
            }

            foreach (var type in reactPackage.CreateJavaScriptModulesConfig())
            {
                jsModulesBuilder.Add(type);
            }
        }
Пример #22
0
 /// <summary>
 /// Instantiates the <see cref="UIViewOperationQueueInstance"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 /// <param name="viewManagers">
 /// The view manager registry.
 /// </param>
 public UIViewOperationQueue(ReactContext reactContext, ViewManagerRegistry viewManagers) :
     base(reactContext, new NativeViewHierarchyManager(viewManagers, DispatcherHelpers.MainDispatcher, null), ReactChoreographer.Instance)
 {
 }
Пример #23
0
 /// <summary>
 /// Instantiates the <see cref="UIViewOperationQueueInstance"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 /// <param name="nativeViewHierarchyManager">
 /// The native view hierarchy manager.
 /// </param>
 public UIViewOperationQueueInstance(ReactContext reactContext, NativeViewHierarchyManager nativeViewHierarchyManager, ReactChoreographer reactChoreographer)
 {
     _nativeViewHierarchyManager = nativeViewHierarchyManager;
     _reactContext       = reactContext;
     _reactChoreographer = reactChoreographer;
 }
 public ReactNativeSSHClientModule(ReactContext reactContext) : base(reactContext)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="ThemedReactContext"/>.
 /// </summary>
 /// <param name="reactContext">The inner context.</param>
 public ThemedReactContext(ReactContext reactContext)
 {
     InitializeWithInstance(reactContext.ReactInstance);
     _reactContext = reactContext;
 }
 public void OnReactContextDestroyed(ReactContext context)
 {
     if (context == _currentContext)
     {
         ResetCurrentContext(null);
     }
 }
 /// <summary>
 /// Instantiates the <see cref="ReactContextInitializedEventArgs"/>.
 /// </summary>
 /// <param name="context">The React context.</param>
 internal ReactContextInitializedEventArgs(ReactContext context)
 {
     Context = context;
 }
 /// <summary>
 /// Instantiates the <see cref="NetInfoModule"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 public NetInfoModule(ReactContext reactContext)
     : this(new DefaultNetworkInformation(), reactContext)
 {
 }
Пример #29
0
 /// <summary>
 /// Instantiates the <see cref="NetInfoModule"/>.
 /// </summary>
 /// <param name="networkInfo">The network information.</param>
 /// <param name="reactContext">The React context.</param>
 public NetInfoModule(INetworkInformation networkInfo, ReactContext reactContext)
     : base(reactContext)
 {
     _networkInfo = networkInfo;
 }
 public DialogModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="NativeAnimatedModule"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 public NativeAnimatedModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
 public void Initialize(ReactContext reactContext)
 {
     _reactContext = reactContext;
 }
 /// <summary>
 /// Instantiates the <see cref="UIImplementation"/>.
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 /// <param name="viewManagers">The view managers.</param>
 public UIImplementation(ReactContext reactContext, IReadOnlyList<IViewManager> viewManagers)
     : this(reactContext, new ViewManagerRegistry(viewManagers))
 {
 }
Пример #34
0
 /// <summary>
 /// Instantiates the <see cref="RNViewShotModule"/>.
 /// </summary>
 public RNViewShotModule(ReactContext reactContext) : base(reactContext)
 {
     this._reactContext = reactContext;
 }
        private void ResetCurrentContext(ReactContext context)
        {
            if (_currentContext == context)
            {
                return;
            }

            _currentContext = context;

            if (_devSettings.IsHotModuleReplacementEnabled && context != null)
            {
                var uri = new Uri(SourceUrl);
                var path = uri.LocalPath.Substring(1); // strip initial slash in path
                var host = uri.Host;
                var port = uri.Port;
                context.GetJavaScriptModule<HMRClient>().enable("windows", path, host, port);
            }
        }
 public void OnReactContextDestroyed(ReactContext context)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="ReactWebViewManager"/>.
 /// </summary>
 /// <param name="context">The React context.</param>
 public ReactWebViewManager(ReactContext context)
 {
     _context = context;
 }
 public void OnNewReactContextCreated(ReactContext context)
 {
 }
Пример #39
0
 public RNDeviceInfoModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
Пример #40
0
 public RNJuvoPlayerApiModule(ReactContext reactContext)
     : base(reactContext)
 {
     seekLogic = new SeekLogic(this);
 }
Пример #41
0
 public CodePushNativeModule(ReactContext reactContext, CodePushReactPackage codePush)
     : base(reactContext)
 {
     _reactContext = reactContext;
     _codePush     = codePush;
 }
Пример #42
0
 public IReadOnlyList <INativeModule> CreateNativeModules(ReactContext reactContext)
 {
     return(new List <INativeModule>(0));
 }
Пример #43
0
 public RCTCameraViewManager(ReactContext reactContext)
 {
     _reactContext = reactContext;
 }
Пример #44
0
 internal NetworkingModule(ReactContext reactContext)
     : this(CreateDefaultHttpClient(), reactContext)
 {
 }
Пример #45
0
 /// <summary>
 /// Creates the list of view managers that should be registered with
 /// the <see cref="UIManagerModule"/>.
 /// </summary>
 /// <param name="reactContext">The react application context.</param>
 /// <returns>The list of view managers.</returns>
 public IReadOnlyList <IViewManager> CreateViewManagers(
     ReactContext reactContext)
 {
     return(new List <IViewManager>(0));
 }
Пример #46
0
 /// <summary>
 /// Instantiates the <see cref="NetworkingModule"/>.
 /// </summary>
 /// <param name="client">The HTTP client.</param>
 /// <param name="reactContext">The context.</param>
 internal NetworkingModule(IHttpClient client, ReactContext reactContext)
     : base(reactContext)
 {
     _client = client;
     _tasks  = new TaskCancellationManager <int>();
 }
 private void OnReactContextInitialized(ReactContext reactContext)
 {
     ReactContextInitialized?
         .Invoke(this, new ReactContextInitializedEventArgs(reactContext));
 }
 public void OnNewReactContextCreated(ReactContext context)
 {
     ResetCurrentContext(context);
 }
 private void MoveReactContextToCurrentLifecycleState(ReactContext reactContext)
 {
     if (_lifecycleState == LifecycleState.Resumed)
     {
         reactContext.OnResume();
     }
 }
Пример #50
0
        private async Task <ReactContext> CreateReactContextAsync(
            Func <IJavaScriptExecutor> jsExecutorFactory,
            JavaScriptBundleLoader jsBundleLoader)
        {
            RNTracer.Write(ReactConstants.Tag, "Creating React context.");

            _sourceUrl = jsBundleLoader.SourceUrl;

            var nativeRegistryBuilder = new NativeModuleRegistry.Builder();
            var jsModulesBuilder      = new JavaScriptModuleRegistry.Builder();

            var reactContext = new ReactContext();

            if (_useDeveloperSupport)
            {
                reactContext.NativeModuleCallExceptionHandler = _devSupportManager.HandleException;
            }

            using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "createAndProcessCoreModulesPackage").Start())
            {
                var coreModulesPackage =
                    new CoreModulesPackage(this, InvokeDefaultOnBackPressed, _uiImplementationProvider);


                ProcessPackage(coreModulesPackage, reactContext, nativeRegistryBuilder, jsModulesBuilder);
            }

            foreach (var reactPackage in _packages)
            {
                using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "createAndProcessCustomReactPackage").Start())
                {
                    ProcessPackage(reactPackage, reactContext, nativeRegistryBuilder, jsModulesBuilder);
                }
            }

            var nativeModuleRegistry = default(NativeModuleRegistry);

            using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "buildNativeModuleRegistry").Start())
            {
                nativeModuleRegistry = nativeRegistryBuilder.Build();
            }

            var exceptionHandler     = _nativeModuleCallExceptionHandler ?? _devSupportManager.HandleException;
            var reactInstanceBuilder = new ReactInstance.Builder
            {
                QueueConfigurationSpec    = ReactQueueConfigurationSpec.Default,
                JavaScriptExecutorFactory = jsExecutorFactory,
                Registry = nativeModuleRegistry,
                JavaScriptModuleRegistry         = jsModulesBuilder.Build(),
                BundleLoader                     = jsBundleLoader,
                NativeModuleCallExceptionHandler = exceptionHandler,
            };

            var reactInstance = default(ReactInstance);

            using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "createReactInstance").Start())
            {
                reactInstance = reactInstanceBuilder.Build();
            }

            // TODO: add bridge idle debug listener
            reactContext.InitializeWithInstance(reactInstance);

            reactInstance.Initialize();

            //using (RNTracer.Trace(RNTracer.TRACE_TAG_REACT_BRIDGE, "RunJavaScriptBundle").Start())
            {
                await reactInstance.InitializeBridgeAsync().ConfigureAwait(false);
            }

            return(reactContext);
        }
 /// <summary>
 /// Creates the list of view managers that should be registered with
 /// the <see cref="UIManagerModule"/>.
 /// </summary>
 /// <param name="reactContext">The react application context.</param>
 /// <returns>The list of view managers.</returns>
 public IReadOnlyList<IViewManager> CreateViewManagers(
     ReactContext reactContext)
 {
     return new List<IViewManager>(0);
 }
Пример #52
0
 public Accelerometer(ReactContext reactContext) : base(reactContext)
 {
 }
 public TestModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="RNAppCenterModule"/>.
 /// </summary>
 public RNAppCenterModule(ReactContext reactContext) : base(reactContext)
 {
 }
 /// <summary>
 /// Instantiates the <see cref="NetInfoModule"/>.
 /// </summary>
 /// <param name="networkInfo">The network information.</param>
 /// <param name="reactContext">The React context.</param>
 public NetInfoModule(INetworkInformation networkInfo, ReactContext reactContext)
     : base(reactContext)
 {
     _networkInfo = networkInfo;
 }
Пример #56
0
 public LocationModule(ReactContext reactContext)
     : base(reactContext)
 {
 }
 private UIImplementation(ReactContext reactContext, ViewManagerRegistry viewManagers)
     : this(
           viewManagers,
           new UIViewOperationQueue(reactContext, new NativeViewHierarchyManager(viewManagers)))
 {
 }
Пример #58
0
 public PSPDFKitModule(ReactContext reactContext, PSPDFKitViewManger viewManager) : base(reactContext)
 {
     _viewManager = viewManager;
 }
Пример #59
0
 private void OnReactContextInitialized(ReactContext reactContext)
 {
     ReactContextInitialized?
     .Invoke(this, new ReactContextInitializedEventArgs(reactContext));
 }
 /// <summary>
 /// Instantiates the <see cref="LauncherModule"/>. 
 /// </summary>
 /// <param name="reactContext">The React context.</param>
 public LauncherModule(ReactContext reactContext) 
     : base(reactContext)
 {
 }