2015-01-30 01:10:49 +00:00
|
|
|
/**
|
2015-03-23 22:07:33 +00:00
|
|
|
* Copyright (c) 2015-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.
|
2015-01-30 01:10:49 +00:00
|
|
|
*
|
2015-05-08 16:45:43 +00:00
|
|
|
* @providesModule ReactNativeDefaultInjection
|
2015-03-26 01:19:28 +00:00
|
|
|
* @flow
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
2015-05-19 20:43:46 +00:00
|
|
|
'use strict';
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
/**
|
2015-10-29 04:05:15 +00:00
|
|
|
* Make sure essential globals are available and are patched correctly. Please don't remove this
|
|
|
|
* line. Bundles created by react-packager `require` it before executing any application code. This
|
|
|
|
* ensures it exists in the dependency graph and can be `require`d.
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
|
|
|
require('InitializeJavaScriptAppEngine');
|
2015-10-29 04:05:15 +00:00
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
var EventPluginHub = require('EventPluginHub');
|
|
|
|
var EventPluginUtils = require('EventPluginUtils');
|
|
|
|
var IOSDefaultEventPluginOrder = require('IOSDefaultEventPluginOrder');
|
|
|
|
var IOSNativeBridgeEventPlugin = require('IOSNativeBridgeEventPlugin');
|
|
|
|
var NodeHandle = require('NodeHandle');
|
2015-11-26 15:13:16 +00:00
|
|
|
var ReactElement = require('ReactElement');
|
2015-03-09 05:39:23 +00:00
|
|
|
var ReactComponentEnvironment = require('ReactComponentEnvironment');
|
2015-01-30 01:10:49 +00:00
|
|
|
var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
|
2015-04-01 02:01:48 +00:00
|
|
|
var ReactEmptyComponent = require('ReactEmptyComponent');
|
2015-01-30 01:10:49 +00:00
|
|
|
var ReactInstanceHandles = require('ReactInstanceHandles');
|
2015-05-08 16:45:43 +00:00
|
|
|
var ReactNativeComponentEnvironment = require('ReactNativeComponentEnvironment');
|
|
|
|
var ReactNativeGlobalInteractionHandler = require('ReactNativeGlobalInteractionHandler');
|
|
|
|
var ReactNativeGlobalResponderHandler = require('ReactNativeGlobalResponderHandler');
|
|
|
|
var ReactNativeMount = require('ReactNativeMount');
|
|
|
|
var ReactNativeTextComponent = require('ReactNativeTextComponent');
|
2015-03-09 05:39:23 +00:00
|
|
|
var ReactNativeComponent = require('ReactNativeComponent');
|
2015-01-30 01:10:49 +00:00
|
|
|
var ReactUpdates = require('ReactUpdates');
|
|
|
|
var ResponderEventPlugin = require('ResponderEventPlugin');
|
|
|
|
var UniversalWorkerNodeHandle = require('UniversalWorkerNodeHandle');
|
|
|
|
|
2016-03-02 12:27:13 +00:00
|
|
|
var invariant = require('fbjs/lib/invariant');
|
2015-04-01 02:01:48 +00:00
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
// Just to ensure this gets packaged, since its only caller is from Native.
|
|
|
|
require('RCTEventEmitter');
|
|
|
|
require('RCTLog');
|
2015-06-15 17:48:24 +00:00
|
|
|
require('JSTimersExecution');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
function inject() {
|
|
|
|
/**
|
|
|
|
* Inject module for resolving DOM hierarchy and plugin ordering.
|
|
|
|
*/
|
|
|
|
EventPluginHub.injection.injectEventPluginOrder(IOSDefaultEventPluginOrder);
|
|
|
|
EventPluginHub.injection.injectInstanceHandle(ReactInstanceHandles);
|
|
|
|
|
|
|
|
ResponderEventPlugin.injection.injectGlobalResponderHandler(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeGlobalResponderHandler
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ResponderEventPlugin.injection.injectGlobalInteractionHandler(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeGlobalInteractionHandler
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some important event plugins included by default (without having to require
|
|
|
|
* them).
|
|
|
|
*/
|
|
|
|
EventPluginHub.injection.injectEventPluginsByName({
|
|
|
|
'ResponderEventPlugin': ResponderEventPlugin,
|
|
|
|
'IOSNativeBridgeEventPlugin': IOSNativeBridgeEventPlugin
|
|
|
|
});
|
|
|
|
|
|
|
|
ReactUpdates.injection.injectReconcileTransaction(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeComponentEnvironment.ReactReconcileTransaction
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ReactUpdates.injection.injectBatchingStrategy(
|
|
|
|
ReactDefaultBatchingStrategy
|
|
|
|
);
|
|
|
|
|
2015-03-09 05:39:23 +00:00
|
|
|
ReactComponentEnvironment.injection.injectEnvironment(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeComponentEnvironment
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
|
2015-11-26 15:13:16 +00:00
|
|
|
var EmptyComponent = () => {
|
|
|
|
// Can't import View at the top because it depends on React to make its composite
|
|
|
|
var View = require('View');
|
|
|
|
return ReactElement.createElement(View, {
|
|
|
|
collapsable: true,
|
|
|
|
style: { position: 'absolute' }
|
|
|
|
});
|
|
|
|
};
|
|
|
|
ReactEmptyComponent.injection.injectEmptyComponent(EmptyComponent);
|
2015-04-01 02:01:48 +00:00
|
|
|
|
2015-05-08 16:45:43 +00:00
|
|
|
EventPluginUtils.injection.injectMount(ReactNativeMount);
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-03-09 05:39:23 +00:00
|
|
|
ReactNativeComponent.injection.injectTextComponentClass(
|
2015-05-08 16:45:43 +00:00
|
|
|
ReactNativeTextComponent
|
2015-03-09 05:39:23 +00:00
|
|
|
);
|
2015-07-24 00:50:16 +00:00
|
|
|
ReactNativeComponent.injection.injectGenericComponentClass(function(tag) {
|
2015-04-03 15:38:06 +00:00
|
|
|
// Show a nicer error message for non-function tags
|
|
|
|
var info = '';
|
|
|
|
if (typeof tag === 'string' && /^[a-z]/.test(tag)) {
|
|
|
|
info += ' Each component name should start with an uppercase letter.';
|
|
|
|
}
|
|
|
|
invariant(false, 'Expected a component class, got %s.%s', tag, info);
|
|
|
|
});
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
NodeHandle.injection.injectImplementation(UniversalWorkerNodeHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
inject: inject,
|
|
|
|
};
|