From a81b218264bc035f3572751fdf38d3feed6a06ac Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 3 May 2016 11:51:06 -0700 Subject: [PATCH] React New Reconciler This is an outline for the new reconciler infrastructure. I created a noop renderer to have something to get started from. I split the reconciler folder into old and new, as well as shared. I put shouldUpdateReactComponent in shared as an example of a utility that can easily be shared between both. I plan on breaking out more utilities like these. --- src/renderers/noop/ReactNoop.js | 40 +++++++++++++++++++ .../shared/reconciler/new/ReactFiber.js | 29 ++++++++++++++ .../reconciler/new/ReactNewReconciler.js | 38 ++++++++++++++++++ .../{ => old}/ReactChildReconciler.js | 0 .../{ => old}/ReactComponentEnvironment.js | 0 .../{ => old}/ReactCompositeComponent.js | 0 .../{ => old}/ReactDefaultBatchingStrategy.js | 0 .../{ => old}/ReactEmptyComponent.js | 0 .../{ => old}/ReactEventEmitterMixin.js | 0 .../{ => old}/ReactInstanceHandles.js | 0 .../reconciler/{ => old}/ReactInstanceMap.js | 0 .../reconciler/{ => old}/ReactMultiChild.js | 0 .../{ => old}/ReactMultiChildUpdateTypes.js | 0 .../{ => old}/ReactNativeComponent.js | 0 .../shared/reconciler/{ => old}/ReactOwner.js | 0 .../reconciler/{ => old}/ReactReconciler.js | 0 .../shared/reconciler/{ => old}/ReactRef.js | 0 .../{ => old}/ReactSimpleEmptyComponent.js | 0 .../reconciler/{ => old}/ReactStateSetters.js | 0 .../reconciler/{ => old}/ReactUpdateQueue.js | 0 .../reconciler/{ => old}/ReactUpdates.js | 0 .../{ => old}/instantiateReactComponent.js | 0 .../shouldUpdateReactComponent.js | 0 23 files changed, 107 insertions(+) create mode 100644 src/renderers/noop/ReactNoop.js create mode 100644 src/renderers/shared/reconciler/new/ReactFiber.js create mode 100644 src/renderers/shared/reconciler/new/ReactNewReconciler.js rename src/renderers/shared/reconciler/{ => old}/ReactChildReconciler.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactComponentEnvironment.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactCompositeComponent.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactDefaultBatchingStrategy.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactEmptyComponent.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactEventEmitterMixin.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactInstanceHandles.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactInstanceMap.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactMultiChild.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactMultiChildUpdateTypes.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactNativeComponent.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactOwner.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactReconciler.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactRef.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactSimpleEmptyComponent.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactStateSetters.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactUpdateQueue.js (100%) rename src/renderers/shared/reconciler/{ => old}/ReactUpdates.js (100%) rename src/renderers/shared/reconciler/{ => old}/instantiateReactComponent.js (100%) rename src/renderers/shared/reconciler/{ => shared}/shouldUpdateReactComponent.js (100%) diff --git a/src/renderers/noop/ReactNoop.js b/src/renderers/noop/ReactNoop.js new file mode 100644 index 0000000000000..3759fa701c4a9 --- /dev/null +++ b/src/renderers/noop/ReactNoop.js @@ -0,0 +1,40 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ReactNoop + * @flow + */ + +/** + * This is a renderer of React that doesn't have a render target output. + * It is useful to demonstrate the internals of the reconciler in isolation + * and for testing semantics of reconciliation separate from the host + * environment. + */ + +'use strict'; + +var ReactNewReconciler = require('ReactNewReconciler'); + +var NoopRenderer = ReactNewReconciler({ + + createHostInstance() { + + } + +}); + +var ReactNoop = { + + render(element : ReactElement) { + + } + +}; + +module.exports = ReactNoop; diff --git a/src/renderers/shared/reconciler/new/ReactFiber.js b/src/renderers/shared/reconciler/new/ReactFiber.js new file mode 100644 index 0000000000000..ba91b590c825c --- /dev/null +++ b/src/renderers/shared/reconciler/new/ReactFiber.js @@ -0,0 +1,29 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ReactFiber + * @flow + */ + +'use strict'; + +type EffectTag = number; + +export type Fiber = { + + handlerTag: EffectTag + +}; + +module.exports = function() : Fiber { + return { + + handlerTag: 0 + + }; +} diff --git a/src/renderers/shared/reconciler/new/ReactNewReconciler.js b/src/renderers/shared/reconciler/new/ReactNewReconciler.js new file mode 100644 index 0000000000000..b419794954a05 --- /dev/null +++ b/src/renderers/shared/reconciler/new/ReactNewReconciler.js @@ -0,0 +1,38 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ReactNewReconciler + * @flow + */ + +'use strict'; + +type ReactHostElement = { + type: T, + props: P +}; + +export type HostConfig = { + + createHostInstance(element : ReactHostElement) : I + +}; + +export type Reconciler = { + mountNewRoot(element : ReactElement) : void; +}; + +module.exports = function(config : HostConfig) : Reconciler { + return { + + mountNewRoot() { + + } + + }; +} diff --git a/src/renderers/shared/reconciler/ReactChildReconciler.js b/src/renderers/shared/reconciler/old/ReactChildReconciler.js similarity index 100% rename from src/renderers/shared/reconciler/ReactChildReconciler.js rename to src/renderers/shared/reconciler/old/ReactChildReconciler.js diff --git a/src/renderers/shared/reconciler/ReactComponentEnvironment.js b/src/renderers/shared/reconciler/old/ReactComponentEnvironment.js similarity index 100% rename from src/renderers/shared/reconciler/ReactComponentEnvironment.js rename to src/renderers/shared/reconciler/old/ReactComponentEnvironment.js diff --git a/src/renderers/shared/reconciler/ReactCompositeComponent.js b/src/renderers/shared/reconciler/old/ReactCompositeComponent.js similarity index 100% rename from src/renderers/shared/reconciler/ReactCompositeComponent.js rename to src/renderers/shared/reconciler/old/ReactCompositeComponent.js diff --git a/src/renderers/shared/reconciler/ReactDefaultBatchingStrategy.js b/src/renderers/shared/reconciler/old/ReactDefaultBatchingStrategy.js similarity index 100% rename from src/renderers/shared/reconciler/ReactDefaultBatchingStrategy.js rename to src/renderers/shared/reconciler/old/ReactDefaultBatchingStrategy.js diff --git a/src/renderers/shared/reconciler/ReactEmptyComponent.js b/src/renderers/shared/reconciler/old/ReactEmptyComponent.js similarity index 100% rename from src/renderers/shared/reconciler/ReactEmptyComponent.js rename to src/renderers/shared/reconciler/old/ReactEmptyComponent.js diff --git a/src/renderers/shared/reconciler/ReactEventEmitterMixin.js b/src/renderers/shared/reconciler/old/ReactEventEmitterMixin.js similarity index 100% rename from src/renderers/shared/reconciler/ReactEventEmitterMixin.js rename to src/renderers/shared/reconciler/old/ReactEventEmitterMixin.js diff --git a/src/renderers/shared/reconciler/ReactInstanceHandles.js b/src/renderers/shared/reconciler/old/ReactInstanceHandles.js similarity index 100% rename from src/renderers/shared/reconciler/ReactInstanceHandles.js rename to src/renderers/shared/reconciler/old/ReactInstanceHandles.js diff --git a/src/renderers/shared/reconciler/ReactInstanceMap.js b/src/renderers/shared/reconciler/old/ReactInstanceMap.js similarity index 100% rename from src/renderers/shared/reconciler/ReactInstanceMap.js rename to src/renderers/shared/reconciler/old/ReactInstanceMap.js diff --git a/src/renderers/shared/reconciler/ReactMultiChild.js b/src/renderers/shared/reconciler/old/ReactMultiChild.js similarity index 100% rename from src/renderers/shared/reconciler/ReactMultiChild.js rename to src/renderers/shared/reconciler/old/ReactMultiChild.js diff --git a/src/renderers/shared/reconciler/ReactMultiChildUpdateTypes.js b/src/renderers/shared/reconciler/old/ReactMultiChildUpdateTypes.js similarity index 100% rename from src/renderers/shared/reconciler/ReactMultiChildUpdateTypes.js rename to src/renderers/shared/reconciler/old/ReactMultiChildUpdateTypes.js diff --git a/src/renderers/shared/reconciler/ReactNativeComponent.js b/src/renderers/shared/reconciler/old/ReactNativeComponent.js similarity index 100% rename from src/renderers/shared/reconciler/ReactNativeComponent.js rename to src/renderers/shared/reconciler/old/ReactNativeComponent.js diff --git a/src/renderers/shared/reconciler/ReactOwner.js b/src/renderers/shared/reconciler/old/ReactOwner.js similarity index 100% rename from src/renderers/shared/reconciler/ReactOwner.js rename to src/renderers/shared/reconciler/old/ReactOwner.js diff --git a/src/renderers/shared/reconciler/ReactReconciler.js b/src/renderers/shared/reconciler/old/ReactReconciler.js similarity index 100% rename from src/renderers/shared/reconciler/ReactReconciler.js rename to src/renderers/shared/reconciler/old/ReactReconciler.js diff --git a/src/renderers/shared/reconciler/ReactRef.js b/src/renderers/shared/reconciler/old/ReactRef.js similarity index 100% rename from src/renderers/shared/reconciler/ReactRef.js rename to src/renderers/shared/reconciler/old/ReactRef.js diff --git a/src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js b/src/renderers/shared/reconciler/old/ReactSimpleEmptyComponent.js similarity index 100% rename from src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js rename to src/renderers/shared/reconciler/old/ReactSimpleEmptyComponent.js diff --git a/src/renderers/shared/reconciler/ReactStateSetters.js b/src/renderers/shared/reconciler/old/ReactStateSetters.js similarity index 100% rename from src/renderers/shared/reconciler/ReactStateSetters.js rename to src/renderers/shared/reconciler/old/ReactStateSetters.js diff --git a/src/renderers/shared/reconciler/ReactUpdateQueue.js b/src/renderers/shared/reconciler/old/ReactUpdateQueue.js similarity index 100% rename from src/renderers/shared/reconciler/ReactUpdateQueue.js rename to src/renderers/shared/reconciler/old/ReactUpdateQueue.js diff --git a/src/renderers/shared/reconciler/ReactUpdates.js b/src/renderers/shared/reconciler/old/ReactUpdates.js similarity index 100% rename from src/renderers/shared/reconciler/ReactUpdates.js rename to src/renderers/shared/reconciler/old/ReactUpdates.js diff --git a/src/renderers/shared/reconciler/instantiateReactComponent.js b/src/renderers/shared/reconciler/old/instantiateReactComponent.js similarity index 100% rename from src/renderers/shared/reconciler/instantiateReactComponent.js rename to src/renderers/shared/reconciler/old/instantiateReactComponent.js diff --git a/src/renderers/shared/reconciler/shouldUpdateReactComponent.js b/src/renderers/shared/reconciler/shared/shouldUpdateReactComponent.js similarity index 100% rename from src/renderers/shared/reconciler/shouldUpdateReactComponent.js rename to src/renderers/shared/reconciler/shared/shouldUpdateReactComponent.js