react-hot-api
Advanced tools
Comparing version 0.4.6 to 0.5.0-alpha
@@ -59,4 +59,64 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
module.exports = __webpack_require__(4); | ||
var createProxy = __webpack_require__(9).createProxy; | ||
var getForceUpdate = __webpack_require__(9).getForceUpdate; | ||
/** | ||
* Returns a function that will patch React class with new versions of itself | ||
* on subsequent invocations. Both legacy and ES6 style classes are supported. | ||
*/ | ||
function makePatchReactClass(React) { | ||
var forceUpdate = getForceUpdate(React); | ||
var proxy; | ||
return function patchReactClass(NextClass) { | ||
if (!proxy) { | ||
proxy = createProxy(NextClass); | ||
} else { | ||
var mountedInstances = proxy.update(NextClass); | ||
requestAnimationFrame(function () { | ||
mountedInstances.forEach(forceUpdate); | ||
}); | ||
} | ||
return proxy.get(); | ||
}; | ||
}; | ||
/** | ||
* Returns a function that, when invoked, patches a React class with a new | ||
* version of itself. To patch different classes, pass different IDs. | ||
*/ | ||
module.exports = function makeMakeHot(React) { | ||
if (arguments.length === 2) { | ||
// Support legacy signature | ||
React = arguments[1]; | ||
} | ||
if (typeof React !== 'object' || typeof React.Component !== 'function') { | ||
throw new Error('React is now the single required argument, and React Hot API now requires React 0.13+.'); | ||
} | ||
var patchers = {}; | ||
return function makeHot(NextClass, persistentId) { | ||
persistentId = persistentId || NextClass.displayName || NextClass.name; | ||
if (!persistentId) { | ||
console.error( | ||
'Hot reload is disabled for one of your types. To enable it, pass a ' + | ||
'string uniquely identifying this class within this current module ' + | ||
'as a second parameter to makeHot.' | ||
); | ||
return NextClass; | ||
} | ||
if (!patchers[persistentId]) { | ||
patchers[persistentId] = makePatchReactClass(React); | ||
} | ||
var patchReactClass = patchers[persistentId]; | ||
return patchReactClass(NextClass); | ||
}; | ||
}; | ||
/***/ }, | ||
@@ -66,4 +126,393 @@ /* 1 */ | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is an object, else `false`. | ||
* @example | ||
* | ||
* _.isObject({}); | ||
* // => true | ||
* | ||
* _.isObject([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObject(1); | ||
* // => false | ||
*/ | ||
function isObject(value) { | ||
// Avoid a V8 JIT bug in Chrome 19-20. | ||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details. | ||
var type = typeof value; | ||
return !!value && (type == 'object' || type == 'function'); | ||
} | ||
module.exports = isObject; | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var getLength = __webpack_require__(31), | ||
isLength = __webpack_require__(5); | ||
/** | ||
* Checks if `value` is array-like. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`. | ||
*/ | ||
function isArrayLike(value) { | ||
return value != null && isLength(getLength(value)); | ||
} | ||
module.exports = isArrayLike; | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Checks if `value` is object-like. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
module.exports = isObjectLike; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isNative = __webpack_require__(36); | ||
/** | ||
* Gets the native function at `key` of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the method to get. | ||
* @returns {*} Returns the function if it's native, else `undefined`. | ||
*/ | ||
function getNative(object, key) { | ||
var value = object == null ? undefined : object[key]; | ||
return isNative(value) ? value : undefined; | ||
} | ||
module.exports = getNative; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
*/ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
/** | ||
* Checks if `value` is a valid array-like length. | ||
* | ||
* **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`. | ||
*/ | ||
function isLength(value) { | ||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; | ||
} | ||
module.exports = isLength; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** Used to detect unsigned integer values. */ | ||
var reIsUint = /^\d+$/; | ||
/** | ||
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
*/ | ||
var MAX_SAFE_INTEGER = 9007199254740991; | ||
/** | ||
* Checks if `value` is a valid array-like index. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. | ||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. | ||
*/ | ||
function isIndex(value, length) { | ||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; | ||
length = length == null ? MAX_SAFE_INTEGER : length; | ||
return value > -1 && value % 1 == 0 && value < length; | ||
} | ||
module.exports = isIndex; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isArrayLike = __webpack_require__(2), | ||
isObjectLike = __webpack_require__(3); | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Native method references. */ | ||
var propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
/** | ||
* Checks if `value` is classified as an `arguments` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isArguments(function() { return arguments; }()); | ||
* // => true | ||
* | ||
* _.isArguments([1, 2, 3]); | ||
* // => false | ||
*/ | ||
function isArguments(value) { | ||
return isObjectLike(value) && isArrayLike(value) && | ||
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); | ||
} | ||
module.exports = isArguments; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var getNative = __webpack_require__(4), | ||
isLength = __webpack_require__(5), | ||
isObjectLike = __webpack_require__(3); | ||
/** `Object#toString` result references. */ | ||
var arrayTag = '[object Array]'; | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objToString = objectProto.toString; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsArray = getNative(Array, 'isArray'); | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isArray([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isArray(function() { return arguments; }()); | ||
* // => false | ||
*/ | ||
var isArray = nativeIsArray || function(value) { | ||
return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; | ||
}; | ||
module.exports = isArray; | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
function _interopRequire(obj) { return obj && obj.__esModule ? obj['default'] : obj; } | ||
var _createClassProxy = __webpack_require__(13); | ||
exports.createProxy = _interopRequire(_createClassProxy); | ||
var _getForceUpdate = __webpack_require__(15); | ||
exports.getForceUpdate = _interopRequire(_getForceUpdate); | ||
/***/ }, | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max; | ||
/** | ||
* Creates a function that invokes `func` with the `this` binding of the | ||
* created function and arguments from `start` and beyond provided as an array. | ||
* | ||
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Function | ||
* @param {Function} func The function to apply a rest parameter to. | ||
* @param {number} [start=func.length-1] The start position of the rest parameter. | ||
* @returns {Function} Returns the new function. | ||
* @example | ||
* | ||
* var say = _.restParam(function(what, names) { | ||
* return what + ' ' + _.initial(names).join(', ') + | ||
* (_.size(names) > 1 ? ', & ' : '') + _.last(names); | ||
* }); | ||
* | ||
* say('hello', 'fred', 'barney', 'pebbles'); | ||
* // => 'hello fred, barney, & pebbles' | ||
*/ | ||
function restParam(func, start) { | ||
if (typeof func != 'function') { | ||
throw new TypeError(FUNC_ERROR_TEXT); | ||
} | ||
start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); | ||
return function() { | ||
var args = arguments, | ||
index = -1, | ||
length = nativeMax(args.length - start, 0), | ||
rest = Array(length); | ||
while (++index < length) { | ||
rest[index] = args[start + index]; | ||
} | ||
switch (start) { | ||
case 0: return func.call(this, rest); | ||
case 1: return func.call(this, args[0], rest); | ||
case 2: return func.call(this, args[0], args[1], rest); | ||
} | ||
var otherArgs = Array(start + 1); | ||
index = -1; | ||
while (++index < start) { | ||
otherArgs[index] = args[index]; | ||
} | ||
otherArgs[start] = rest; | ||
return func.apply(this, otherArgs); | ||
}; | ||
} | ||
module.exports = restParam; | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var getNative = __webpack_require__(4), | ||
isArrayLike = __webpack_require__(2), | ||
isObject = __webpack_require__(1), | ||
shimKeys = __webpack_require__(34); | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeKeys = getNative(Object, 'keys'); | ||
/** | ||
* Creates an array of the own enumerable property names of `object`. | ||
* | ||
* **Note:** Non-object values are coerced to objects. See the | ||
* [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) | ||
* for more details. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
* @example | ||
* | ||
* function Foo() { | ||
* this.a = 1; | ||
* this.b = 2; | ||
* } | ||
* | ||
* Foo.prototype.c = 3; | ||
* | ||
* _.keys(new Foo); | ||
* // => ['a', 'b'] (iteration order is not guaranteed) | ||
* | ||
* _.keys('hi'); | ||
* // => ['0', '1'] | ||
*/ | ||
var keys = !nativeKeys ? shimKeys : function(object) { | ||
var Ctor = object == null ? undefined : object.constructor; | ||
if ((typeof Ctor == 'function' && Ctor.prototype === object) || | ||
(typeof object != 'function' && isArrayLike(object))) { | ||
return shimKeys(object); | ||
} | ||
return isObject(object) ? nativeKeys(object) : []; | ||
}; | ||
module.exports = keys; | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-2015, 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 React source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* Original: | ||
* https://github.com/facebook/react/blob/6508b1ad273a6f371e8d90ae676e5390199461b4/src/isomorphic/classic/class/ReactClass.js#L650-L713 | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.deleteUnknownAutoBindMethods = deleteUnknownAutoBindMethods; | ||
exports.bindAutoBindMethods = bindAutoBindMethods; | ||
function bindAutoBindMethod(component, method) { | ||
@@ -82,12 +531,5 @@ var boundMethod = method.bind(component); | ||
if (newThis !== component && newThis !== null) { | ||
console.warn( | ||
'bind(): React component methods may only be bound to the ' + | ||
'component instance. See ' + componentName | ||
); | ||
console.warn('bind(): React component methods may only be bound to the ' + 'component instance. See ' + componentName); | ||
} else if (!args.length) { | ||
console.warn( | ||
'bind(): You are binding a component method to the component. ' + | ||
'React does this for you automatically in a high-performance ' + | ||
'way, so you can safely remove this call. See ' + componentName | ||
); | ||
console.warn('bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See ' + componentName); | ||
return boundMethod; | ||
@@ -108,29 +550,30 @@ } | ||
/** | ||
* Performs auto-binding similar to how React does it. | ||
* Skips already auto-bound methods. | ||
* Based on https://github.com/facebook/react/blob/b264372e2b3ad0b0c0c0cc95a2f383e4a1325c3d/src/classic/class/ReactClass.js#L639-L705 | ||
* Deletes autobound methods that are no longer in autobind map. | ||
*/ | ||
module.exports = function bindAutoBindMethods(internalInstance) { | ||
var component = typeof internalInstance.getPublicInstance === 'function' ? | ||
internalInstance.getPublicInstance() : | ||
internalInstance; | ||
for (var autoBindKey in component.__reactAutoBindMap) { | ||
if (!component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) { | ||
continue; | ||
function deleteUnknownAutoBindMethods(component) { | ||
if (!component.__reactAutoBindMap) { | ||
return; | ||
} | ||
for (var name in component) { | ||
if (component.hasOwnProperty(name) && !component.__reactAutoBindMap.hasOwnProperty(name) && typeof Object.getOwnPropertyDescriptor(component, name).value === 'function' && component[name].__reactBoundArguments === null) { | ||
delete component[name]; | ||
} | ||
} | ||
} | ||
// Skip already bound methods | ||
if (component.hasOwnProperty(autoBindKey) && | ||
component[autoBindKey].__reactBoundContext === component) { | ||
continue; | ||
function bindAutoBindMethods(component) { | ||
for (var autoBindKey in component.__reactAutoBindMap) { | ||
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) { | ||
var method = component.__reactAutoBindMap[autoBindKey]; | ||
component[autoBindKey] = bindAutoBindMethod(component, method); | ||
} | ||
var method = component.__reactAutoBindMap[autoBindKey]; | ||
component[autoBindKey] = bindAutoBindMethod(component, method); | ||
} | ||
}; | ||
} | ||
; | ||
/***/ }, | ||
/* 2 */ | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -140,40 +583,79 @@ | ||
var bindAutoBindMethods = __webpack_require__(1); | ||
var traverseRenderedChildren = __webpack_require__(7); | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports['default'] = proxyClass; | ||
function setPendingForceUpdate(internalInstance) { | ||
if (internalInstance._pendingForceUpdate === false) { | ||
internalInstance._pendingForceUpdate = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _createPrototypeProxy = __webpack_require__(14); | ||
var _createPrototypeProxy2 = _interopRequireDefault(_createPrototypeProxy); | ||
var _bindAutoBindMethods = __webpack_require__(12); | ||
function proxyClass(InitialClass) { | ||
// Prevent double wrapping. | ||
// Given a proxy class, return the existing proxy managing it. | ||
if (InitialClass.__reactPatchProxy) { | ||
return InitialClass.__reactPatchProxy; | ||
} | ||
} | ||
function forceUpdateIfPending(internalInstance, React) { | ||
if (internalInstance._pendingForceUpdate === true) { | ||
// `|| internalInstance` for React 0.12 and earlier | ||
var instance = internalInstance._instance || internalInstance; | ||
var prototypeProxy = (0, _createPrototypeProxy2['default'])(); | ||
var CurrentClass = undefined; | ||
if (instance.forceUpdate) { | ||
instance.forceUpdate(); | ||
} else if (React && React.Component) { | ||
React.Component.prototype.forceUpdate.call(instance); | ||
function ProxyClass() { | ||
CurrentClass.apply(this, arguments); | ||
} | ||
// Point proxy constructor to the proxy prototype | ||
ProxyClass.prototype = prototypeProxy.get(); | ||
function update(NextClass) { | ||
if (typeof NextClass !== 'function') { | ||
throw new Error('Expected a constructor.'); | ||
} | ||
// Save the next constructor so we call it | ||
CurrentClass = NextClass; | ||
// Update the prototype proxy with new methods | ||
var mountedInstances = prototypeProxy.update(NextClass.prototype); | ||
// Set up the constructor property so accessing the statics work | ||
ProxyClass.prototype.constructor = ProxyClass; | ||
// Naïvely proxy static methods and properties | ||
ProxyClass.prototype.constructor.__proto__ = NextClass; | ||
// Try to infer displayName | ||
ProxyClass.displayName = NextClass.name || NextClass.displayName; | ||
// We might have added new methods that need to be auto-bound | ||
mountedInstances.forEach(_bindAutoBindMethods.bindAutoBindMethods); | ||
mountedInstances.forEach(_bindAutoBindMethods.deleteUnknownAutoBindMethods); | ||
// Let the user take care of redrawing | ||
return mountedInstances; | ||
}; | ||
function get() { | ||
return ProxyClass; | ||
} | ||
} | ||
/** | ||
* Updates a React component recursively, so even if children define funky | ||
* `shouldComponentUpdate`, they are forced to re-render. | ||
* Makes sure that any newly added methods are properly auto-bound. | ||
*/ | ||
function deepForceUpdate(internalInstance, React) { | ||
traverseRenderedChildren(internalInstance, bindAutoBindMethods); | ||
traverseRenderedChildren(internalInstance, setPendingForceUpdate); | ||
traverseRenderedChildren(internalInstance, forceUpdateIfPending, React); | ||
update(InitialClass); | ||
var proxy = { | ||
get: get, | ||
update: update | ||
}; | ||
ProxyClass.__reactPatchProxy = proxy; | ||
return proxy; | ||
} | ||
module.exports = deepForceUpdate; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 3 */ | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -183,229 +665,1081 @@ | ||
/** | ||
* Returns a function that establishes the first prototype passed to it | ||
* as the "source of truth" and patches its methods on subsequent invocations, | ||
* also patching current and previous prototypes to forward calls to it. | ||
*/ | ||
module.exports = function makeAssimilatePrototype() { | ||
var storedPrototype, | ||
knownPrototypes = []; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports['default'] = createPrototypeProxy; | ||
function wrapMethod(key) { | ||
return function () { | ||
if (storedPrototype[key]) { | ||
return storedPrototype[key].apply(this, arguments); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _lodashObjectAssign = __webpack_require__(37); | ||
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign); | ||
var _lodashArrayDifference = __webpack_require__(16); | ||
var _lodashArrayDifference2 = _interopRequireDefault(_lodashArrayDifference); | ||
function createPrototypeProxy() { | ||
var proxy = {}; | ||
var current = null; | ||
var mountedInstances = []; | ||
/** | ||
* Creates a proxied method that calls the current version, whenever available. | ||
*/ | ||
function proxyMethod(name) { | ||
// Wrap to always call the current version | ||
var proxiedMethod = function proxiedMethod() { | ||
if (typeof current[name] === 'function') { | ||
return current[name].apply(this, arguments); | ||
} | ||
}; | ||
// Copy properties of the original function, if any | ||
(0, _lodashObjectAssign2['default'])(proxiedMethod, current[name]); | ||
return proxiedMethod; | ||
} | ||
function patchProperty(proto, key) { | ||
proto[key] = storedPrototype[key]; | ||
/** | ||
* Augments the original componentWillMount with instance tracking. | ||
* We're using it instead of componentDidMount because it works with shallow rendering. | ||
* TODO: maybe this is a bad idea and we should instead fix shallow rendering. | ||
*/ | ||
function proxiedComponentWillMount() { | ||
mountedInstances.push(this); | ||
if (typeof current.componentWillMount === 'function') { | ||
return current.componentWillMount.apply(this, arguments); | ||
} | ||
} | ||
if (typeof proto[key] !== 'function' || | ||
key === 'type' || | ||
key === 'constructor') { | ||
return; | ||
/** | ||
* Augments the original componentWillUnmount with instance tracking. | ||
*/ | ||
function proxiedComponentWillUnmount() { | ||
mountedInstances.splice(mountedInstances.indexOf(this), 1); | ||
if (typeof current.componentWillUnmount === 'function') { | ||
return current.componentWillUnmount.apply(this, arguments); | ||
} | ||
} | ||
proto[key] = wrapMethod(key); | ||
/** | ||
* Defines a property on the proxy. | ||
*/ | ||
function defineProxyProperty(name, descriptor) { | ||
Object.defineProperty(proxy, name, descriptor); | ||
} | ||
if (storedPrototype[key].isReactClassApproved) { | ||
proto[key].isReactClassApproved = storedPrototype[key].isReactClassApproved; | ||
/** | ||
* Defines a property, attempting to keep the original descriptor configuration. | ||
*/ | ||
function defineProxyPropertyWithValue(name, value) { | ||
var _ref = Object.getOwnPropertyDescriptor(current, name) || {}; | ||
var _ref$enumerable = _ref.enumerable; | ||
var enumerable = _ref$enumerable === undefined ? false : _ref$enumerable; | ||
var _ref$writable = _ref.writable; | ||
var writable = _ref$writable === undefined ? true : _ref$writable; | ||
defineProxyProperty(name, { | ||
configurable: true, | ||
enumerable: enumerable, | ||
writable: writable, | ||
value: value | ||
}); | ||
} | ||
/** | ||
* Creates an auto-bind map mimicking the original map, but directed at proxy. | ||
*/ | ||
function createAutoBindMap() { | ||
if (!current.__reactAutoBindMap) { | ||
return; | ||
} | ||
if (proto.__reactAutoBindMap && proto.__reactAutoBindMap[key]) { | ||
proto.__reactAutoBindMap[key] = proto[key]; | ||
var __reactAutoBindMap = {}; | ||
for (var _name in current.__reactAutoBindMap) { | ||
if (current.__reactAutoBindMap.hasOwnProperty(_name)) { | ||
__reactAutoBindMap[_name] = proxy[_name]; | ||
} | ||
} | ||
return __reactAutoBindMap; | ||
} | ||
function updateStoredPrototype(freshPrototype) { | ||
storedPrototype = {}; | ||
/** | ||
* Applies the updated prototype. | ||
*/ | ||
function update(next) { | ||
// Save current source of truth | ||
current = next; | ||
Object.getOwnPropertyNames(freshPrototype).forEach(function (key) { | ||
storedPrototype[key] = freshPrototype[key]; | ||
// Find changed property names | ||
var currentNames = Object.getOwnPropertyNames(current); | ||
var previousName = Object.getOwnPropertyNames(proxy); | ||
var addedNames = (0, _lodashArrayDifference2['default'])(currentNames, previousName); | ||
var removedNames = (0, _lodashArrayDifference2['default'])(previousName, currentNames); | ||
// Remove properties and methods that are no longer there | ||
removedNames.forEach(function (name) { | ||
delete proxy[name]; | ||
}); | ||
} | ||
function reconcileWithStoredPrototypes(freshPrototype) { | ||
knownPrototypes.push(freshPrototype); | ||
knownPrototypes.forEach(function (proto) { | ||
Object.getOwnPropertyNames(storedPrototype).forEach(function (key) { | ||
patchProperty(proto, key); | ||
}); | ||
// Copy every descriptor | ||
currentNames.forEach(function (name) { | ||
var descriptor = Object.getOwnPropertyDescriptor(current, name); | ||
if (typeof descriptor.value === 'function') { | ||
// Functions require additional wrapping so they can be bound later | ||
defineProxyPropertyWithValue(name, proxyMethod(name)); | ||
} else { | ||
// Other values can be copied directly | ||
defineProxyProperty(name, descriptor); | ||
} | ||
}); | ||
// Track mounting and unmounting | ||
defineProxyPropertyWithValue('componentWillMount', proxiedComponentWillMount); | ||
defineProxyPropertyWithValue('componentWillUnmount', proxiedComponentWillUnmount); | ||
defineProxyPropertyWithValue('__reactAutoBindMap', createAutoBindMap()); | ||
// Set up the prototype chain | ||
proxy.__proto__ = next; | ||
return mountedInstances; | ||
} | ||
return function assimilatePrototype(freshPrototype) { | ||
if (Object.prototype.hasOwnProperty.call(freshPrototype, '__isAssimilatedByReactHotAPI')) { | ||
return; | ||
} | ||
/** | ||
* Returns the up-to-date proxy prototype. | ||
*/ | ||
function get() { | ||
return proxy; | ||
} | ||
updateStoredPrototype(freshPrototype); | ||
reconcileWithStoredPrototypes(freshPrototype); | ||
freshPrototype.__isAssimilatedByReactHotAPI = true; | ||
return { | ||
update: update, | ||
get: get | ||
}; | ||
}; | ||
} | ||
; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 4 */ | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
/** | ||
* Returns a function that force-updates an instance | ||
* regardless of whether it descends from React.Component or not. | ||
*/ | ||
"use strict"; | ||
var makePatchReactClass = __webpack_require__(5); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = getForceUpdate; | ||
function getForceUpdate(React) { | ||
return function (instance) { | ||
React.Component.prototype.forceUpdate.call(instance); | ||
}; | ||
} | ||
module.exports = exports["default"]; | ||
/***/ }, | ||
/* 16 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var baseDifference = __webpack_require__(22), | ||
baseFlatten = __webpack_require__(23), | ||
isArrayLike = __webpack_require__(2), | ||
isObjectLike = __webpack_require__(3), | ||
restParam = __webpack_require__(10); | ||
/** | ||
* Returns a function that, when invoked, patches a React class with a new | ||
* version of itself. To patch different classes, pass different IDs. | ||
* Creates an array of unique `array` values not included in the other | ||
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Array | ||
* @param {Array} array The array to inspect. | ||
* @param {...Array} [values] The arrays of values to exclude. | ||
* @returns {Array} Returns the new array of filtered values. | ||
* @example | ||
* | ||
* _.difference([1, 2, 3], [4, 2]); | ||
* // => [1, 3] | ||
*/ | ||
module.exports = function makeMakeHot(getRootInstances, React) { | ||
if (typeof getRootInstances !== 'function') { | ||
throw new Error('Expected getRootInstances to be a function.'); | ||
var difference = restParam(function(array, values) { | ||
return (isObjectLike(array) && isArrayLike(array)) | ||
? baseDifference(array, baseFlatten(values, false, true)) | ||
: []; | ||
}); | ||
module.exports = difference; | ||
/***/ }, | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {var cachePush = __webpack_require__(28), | ||
getNative = __webpack_require__(4); | ||
/** Native method references. */ | ||
var Set = getNative(global, 'Set'); | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeCreate = getNative(Object, 'create'); | ||
/** | ||
* | ||
* Creates a cache object to store unique values. | ||
* | ||
* @private | ||
* @param {Array} [values] The values to cache. | ||
*/ | ||
function SetCache(values) { | ||
var length = values ? values.length : 0; | ||
this.data = { 'hash': nativeCreate(null), 'set': new Set }; | ||
while (length--) { | ||
this.push(values[length]); | ||
} | ||
} | ||
var patchers = {}; | ||
// Add functions to the `Set` cache. | ||
SetCache.prototype.push = cachePush; | ||
return function makeHot(NextClass, persistentId) { | ||
persistentId = persistentId || NextClass.displayName || NextClass.name; | ||
module.exports = SetCache; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
if (!persistentId) { | ||
console.error( | ||
'Hot reload is disabled for one of your types. To enable it, pass a ' + | ||
'string uniquely identifying this class within this current module ' + | ||
'as a second parameter to makeHot.' | ||
); | ||
return NextClass; | ||
} | ||
/***/ }, | ||
/* 18 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
if (!patchers[persistentId]) { | ||
patchers[persistentId] = makePatchReactClass(getRootInstances, React); | ||
/** | ||
* Appends the elements of `values` to `array`. | ||
* | ||
* @private | ||
* @param {Array} array The array to modify. | ||
* @param {Array} values The values to append. | ||
* @returns {Array} Returns `array`. | ||
*/ | ||
function arrayPush(array, values) { | ||
var index = -1, | ||
length = values.length, | ||
offset = array.length; | ||
while (++index < length) { | ||
array[offset + index] = values[index]; | ||
} | ||
return array; | ||
} | ||
module.exports = arrayPush; | ||
/***/ }, | ||
/* 19 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var keys = __webpack_require__(11); | ||
/** | ||
* A specialized version of `_.assign` for customizing assigned values without | ||
* support for argument juggling, multiple sources, and `this` binding `customizer` | ||
* functions. | ||
* | ||
* @private | ||
* @param {Object} object The destination object. | ||
* @param {Object} source The source object. | ||
* @param {Function} customizer The function to customize assigned values. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function assignWith(object, source, customizer) { | ||
var index = -1, | ||
props = keys(source), | ||
length = props.length; | ||
while (++index < length) { | ||
var key = props[index], | ||
value = object[key], | ||
result = customizer(value, source[key], key, object, source); | ||
if ((result === result ? (result !== value) : (value === value)) || | ||
(value === undefined && !(key in object))) { | ||
object[key] = result; | ||
} | ||
} | ||
return object; | ||
} | ||
var patchReactClass = patchers[persistentId]; | ||
return patchReactClass(NextClass); | ||
}; | ||
}; | ||
module.exports = assignWith; | ||
/***/ }, | ||
/* 5 */ | ||
/* 20 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var baseCopy = __webpack_require__(21), | ||
keys = __webpack_require__(11); | ||
var makeAssimilatePrototype = __webpack_require__(3), | ||
requestForceUpdateAll = __webpack_require__(6); | ||
/** | ||
* The base implementation of `_.assign` without support for argument juggling, | ||
* multiple sources, and `customizer` functions. | ||
* | ||
* @private | ||
* @param {Object} object The destination object. | ||
* @param {Object} source The source object. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseAssign(object, source) { | ||
return source == null | ||
? object | ||
: baseCopy(source, keys(source), object); | ||
} | ||
function hasNonStubTypeProperty(ReactClass) { | ||
if (!ReactClass.hasOwnProperty('type')) { | ||
return false; | ||
module.exports = baseAssign; | ||
/***/ }, | ||
/* 21 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copies properties of `source` to `object`. | ||
* | ||
* @private | ||
* @param {Object} source The object to copy properties from. | ||
* @param {Array} props The property names to copy. | ||
* @param {Object} [object={}] The object to copy properties to. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseCopy(source, props, object) { | ||
object || (object = {}); | ||
var index = -1, | ||
length = props.length; | ||
while (++index < length) { | ||
var key = props[index]; | ||
object[key] = source[key]; | ||
} | ||
return object; | ||
} | ||
var descriptor = Object.getOwnPropertyDescriptor(ReactClass, 'type'); | ||
if (typeof descriptor.get === 'function') { | ||
return false; | ||
module.exports = baseCopy; | ||
/***/ }, | ||
/* 22 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var baseIndexOf = __webpack_require__(24), | ||
cacheIndexOf = __webpack_require__(27), | ||
createCache = __webpack_require__(30); | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** | ||
* The base implementation of `_.difference` which accepts a single array | ||
* of values to exclude. | ||
* | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {Array} values The values to exclude. | ||
* @returns {Array} Returns the new array of filtered values. | ||
*/ | ||
function baseDifference(array, values) { | ||
var length = array ? array.length : 0, | ||
result = []; | ||
if (!length) { | ||
return result; | ||
} | ||
var index = -1, | ||
indexOf = baseIndexOf, | ||
isCommon = true, | ||
cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null, | ||
valuesLength = values.length; | ||
return true; | ||
if (cache) { | ||
indexOf = cacheIndexOf; | ||
isCommon = false; | ||
values = cache; | ||
} | ||
outer: | ||
while (++index < length) { | ||
var value = array[index]; | ||
if (isCommon && value === value) { | ||
var valuesIndex = valuesLength; | ||
while (valuesIndex--) { | ||
if (values[valuesIndex] === value) { | ||
continue outer; | ||
} | ||
} | ||
result.push(value); | ||
} | ||
else if (indexOf(values, value, 0) < 0) { | ||
result.push(value); | ||
} | ||
} | ||
return result; | ||
} | ||
function getPrototype(ReactClass) { | ||
var prototype = ReactClass.prototype, | ||
seemsLegit = prototype && typeof prototype.render === 'function'; | ||
module.exports = baseDifference; | ||
if (!seemsLegit && hasNonStubTypeProperty(ReactClass)) { | ||
prototype = ReactClass.type.prototype; | ||
/***/ }, | ||
/* 23 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var arrayPush = __webpack_require__(18), | ||
isArguments = __webpack_require__(7), | ||
isArray = __webpack_require__(8), | ||
isArrayLike = __webpack_require__(2), | ||
isObjectLike = __webpack_require__(3); | ||
/** | ||
* The base implementation of `_.flatten` with added support for restricting | ||
* flattening and specifying the start index. | ||
* | ||
* @private | ||
* @param {Array} array The array to flatten. | ||
* @param {boolean} [isDeep] Specify a deep flatten. | ||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects. | ||
* @param {Array} [result=[]] The initial result value. | ||
* @returns {Array} Returns the new flattened array. | ||
*/ | ||
function baseFlatten(array, isDeep, isStrict, result) { | ||
result || (result = []); | ||
var index = -1, | ||
length = array.length; | ||
while (++index < length) { | ||
var value = array[index]; | ||
if (isObjectLike(value) && isArrayLike(value) && | ||
(isStrict || isArray(value) || isArguments(value))) { | ||
if (isDeep) { | ||
// Recursively flatten arrays (susceptible to call stack limits). | ||
baseFlatten(value, isDeep, isStrict, result); | ||
} else { | ||
arrayPush(result, value); | ||
} | ||
} else if (!isStrict) { | ||
result[result.length] = value; | ||
} | ||
} | ||
return result; | ||
} | ||
return prototype; | ||
module.exports = baseFlatten; | ||
/***/ }, | ||
/* 24 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var indexOfNaN = __webpack_require__(32); | ||
/** | ||
* The base implementation of `_.indexOf` without support for binary searches. | ||
* | ||
* @private | ||
* @param {Array} array The array to search. | ||
* @param {*} value The value to search for. | ||
* @param {number} fromIndex The index to search from. | ||
* @returns {number} Returns the index of the matched value, else `-1`. | ||
*/ | ||
function baseIndexOf(array, value, fromIndex) { | ||
if (value !== value) { | ||
return indexOfNaN(array, fromIndex); | ||
} | ||
var index = fromIndex - 1, | ||
length = array.length; | ||
while (++index < length) { | ||
if (array[index] === value) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | ||
module.exports = baseIndexOf; | ||
/***/ }, | ||
/* 25 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Returns a function that will patch React class with new versions of itself | ||
* on subsequent invocations. Both legacy and ES6 style classes are supported. | ||
* The base implementation of `_.property` without support for deep paths. | ||
* | ||
* @private | ||
* @param {string} key The key of the property to get. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
module.exports = function makePatchReactClass(getRootInstances, React) { | ||
var assimilatePrototype = makeAssimilatePrototype(), | ||
FirstClass = null; | ||
function baseProperty(key) { | ||
return function(object) { | ||
return object == null ? undefined : object[key]; | ||
}; | ||
} | ||
return function patchReactClass(NextClass) { | ||
var nextPrototype = getPrototype(NextClass); | ||
assimilatePrototype(nextPrototype); | ||
module.exports = baseProperty; | ||
if (FirstClass) { | ||
requestForceUpdateAll(getRootInstances, React); | ||
} | ||
return FirstClass || (FirstClass = NextClass); | ||
/***/ }, | ||
/* 26 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var identity = __webpack_require__(39); | ||
/** | ||
* A specialized version of `baseCallback` which only supports `this` binding | ||
* and specifying the number of arguments to provide to `func`. | ||
* | ||
* @private | ||
* @param {Function} func The function to bind. | ||
* @param {*} thisArg The `this` binding of `func`. | ||
* @param {number} [argCount] The number of arguments to provide to `func`. | ||
* @returns {Function} Returns the callback. | ||
*/ | ||
function bindCallback(func, thisArg, argCount) { | ||
if (typeof func != 'function') { | ||
return identity; | ||
} | ||
if (thisArg === undefined) { | ||
return func; | ||
} | ||
switch (argCount) { | ||
case 1: return function(value) { | ||
return func.call(thisArg, value); | ||
}; | ||
case 3: return function(value, index, collection) { | ||
return func.call(thisArg, value, index, collection); | ||
}; | ||
case 4: return function(accumulator, value, index, collection) { | ||
return func.call(thisArg, accumulator, value, index, collection); | ||
}; | ||
case 5: return function(value, other, key, object, source) { | ||
return func.call(thisArg, value, other, key, object, source); | ||
}; | ||
} | ||
return function() { | ||
return func.apply(thisArg, arguments); | ||
}; | ||
}; | ||
} | ||
module.exports = bindCallback; | ||
/***/ }, | ||
/* 6 */ | ||
/* 27 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var deepForceUpdate = __webpack_require__(2); | ||
var isObject = __webpack_require__(1); | ||
var isRequestPending = false; | ||
/** | ||
* Checks if `value` is in `cache` mimicking the return signature of | ||
* `_.indexOf` by returning `0` if the value is found, else `-1`. | ||
* | ||
* @private | ||
* @param {Object} cache The cache to search. | ||
* @param {*} value The value to search for. | ||
* @returns {number} Returns `0` if `value` is found, else `-1`. | ||
*/ | ||
function cacheIndexOf(cache, value) { | ||
var data = cache.data, | ||
result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value]; | ||
module.exports = function requestForceUpdateAll(getRootInstances, React) { | ||
if (isRequestPending) { | ||
return; | ||
return result ? 0 : -1; | ||
} | ||
module.exports = cacheIndexOf; | ||
/***/ }, | ||
/* 28 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isObject = __webpack_require__(1); | ||
/** | ||
* Adds `value` to the cache. | ||
* | ||
* @private | ||
* @name push | ||
* @memberOf SetCache | ||
* @param {*} value The value to cache. | ||
*/ | ||
function cachePush(value) { | ||
var data = this.data; | ||
if (typeof value == 'string' || isObject(value)) { | ||
data.set.add(value); | ||
} else { | ||
data.hash[value] = true; | ||
} | ||
} | ||
/** | ||
* Forces deep re-render of all mounted React components. | ||
* Hat's off to Omar Skalli (@Chetane) for suggesting this approach: | ||
* https://gist.github.com/Chetane/9a230a9fdcdca21a4e29 | ||
*/ | ||
function forceUpdateAll() { | ||
isRequestPending = false; | ||
module.exports = cachePush; | ||
var rootInstances = getRootInstances(), | ||
rootInstance; | ||
for (var key in rootInstances) { | ||
if (rootInstances.hasOwnProperty(key)) { | ||
rootInstance = rootInstances[key]; | ||
/***/ }, | ||
/* 29 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
// `|| rootInstance` for React 0.12 and earlier | ||
rootInstance = rootInstance._reactInternalInstance || rootInstance; | ||
deepForceUpdate(rootInstance, React); | ||
var bindCallback = __webpack_require__(26), | ||
isIterateeCall = __webpack_require__(33), | ||
restParam = __webpack_require__(10); | ||
/** | ||
* Creates a `_.assign`, `_.defaults`, or `_.merge` function. | ||
* | ||
* @private | ||
* @param {Function} assigner The function to assign values. | ||
* @returns {Function} Returns the new assigner function. | ||
*/ | ||
function createAssigner(assigner) { | ||
return restParam(function(object, sources) { | ||
var index = -1, | ||
length = object == null ? 0 : sources.length, | ||
customizer = length > 2 ? sources[length - 2] : undefined, | ||
guard = length > 2 ? sources[2] : undefined, | ||
thisArg = length > 1 ? sources[length - 1] : undefined; | ||
if (typeof customizer == 'function') { | ||
customizer = bindCallback(customizer, thisArg, 5); | ||
length -= 2; | ||
} else { | ||
customizer = typeof thisArg == 'function' ? thisArg : undefined; | ||
length -= (customizer ? 1 : 0); | ||
} | ||
if (guard && isIterateeCall(sources[0], sources[1], guard)) { | ||
customizer = length < 3 ? undefined : customizer; | ||
length = 1; | ||
} | ||
while (++index < length) { | ||
var source = sources[index]; | ||
if (source) { | ||
assigner(object, source, customizer); | ||
} | ||
} | ||
return object; | ||
}); | ||
} | ||
module.exports = createAssigner; | ||
/***/ }, | ||
/* 30 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {var SetCache = __webpack_require__(17), | ||
getNative = __webpack_require__(4); | ||
/** Native method references. */ | ||
var Set = getNative(global, 'Set'); | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeCreate = getNative(Object, 'create'); | ||
/** | ||
* Creates a `Set` cache object to optimize linear searches of large arrays. | ||
* | ||
* @private | ||
* @param {Array} [values] The values to cache. | ||
* @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`. | ||
*/ | ||
function createCache(values) { | ||
return (nativeCreate && Set) ? new SetCache(values) : null; | ||
} | ||
module.exports = createCache; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 31 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var baseProperty = __webpack_require__(25); | ||
/** | ||
* Gets the "length" property value of `object`. | ||
* | ||
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) | ||
* that affects Safari on at least iOS 8.1-8.3 ARM64. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {*} Returns the "length" value. | ||
*/ | ||
var getLength = baseProperty('length'); | ||
module.exports = getLength; | ||
/***/ }, | ||
/* 32 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Gets the index at which the first occurrence of `NaN` is found in `array`. | ||
* | ||
* @private | ||
* @param {Array} array The array to search. | ||
* @param {number} fromIndex The index to search from. | ||
* @param {boolean} [fromRight] Specify iterating from right to left. | ||
* @returns {number} Returns the index of the matched `NaN`, else `-1`. | ||
*/ | ||
function indexOfNaN(array, fromIndex, fromRight) { | ||
var length = array.length, | ||
index = fromIndex + (fromRight ? 0 : -1); | ||
while ((fromRight ? index-- : ++index < length)) { | ||
var other = array[index]; | ||
if (other !== other) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | ||
setTimeout(forceUpdateAll); | ||
}; | ||
module.exports = indexOfNaN; | ||
/***/ }, | ||
/* 7 */ | ||
/* 33 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var isArrayLike = __webpack_require__(2), | ||
isIndex = __webpack_require__(6), | ||
isObject = __webpack_require__(1); | ||
function traverseRenderedChildren(internalInstance, callback, argument) { | ||
callback(internalInstance, argument); | ||
/** | ||
* Checks if the provided arguments are from an iteratee call. | ||
* | ||
* @private | ||
* @param {*} value The potential iteratee value argument. | ||
* @param {*} index The potential iteratee index or key argument. | ||
* @param {*} object The potential iteratee object argument. | ||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. | ||
*/ | ||
function isIterateeCall(value, index, object) { | ||
if (!isObject(object)) { | ||
return false; | ||
} | ||
var type = typeof index; | ||
if (type == 'number' | ||
? (isArrayLike(object) && isIndex(index, object.length)) | ||
: (type == 'string' && index in object)) { | ||
var other = object[index]; | ||
return value === value ? (value === other) : (other !== other); | ||
} | ||
return false; | ||
} | ||
if (internalInstance._renderedComponent) { | ||
traverseRenderedChildren( | ||
internalInstance._renderedComponent, | ||
callback, | ||
argument | ||
); | ||
} else { | ||
for (var key in internalInstance._renderedChildren) { | ||
traverseRenderedChildren( | ||
internalInstance._renderedChildren[key], | ||
callback, | ||
argument | ||
); | ||
module.exports = isIterateeCall; | ||
/***/ }, | ||
/* 34 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isArguments = __webpack_require__(7), | ||
isArray = __webpack_require__(8), | ||
isIndex = __webpack_require__(6), | ||
isLength = __webpack_require__(5), | ||
keysIn = __webpack_require__(38); | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
* A fallback implementation of `Object.keys` which creates an array of the | ||
* own enumerable property names of `object`. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
*/ | ||
function shimKeys(object) { | ||
var props = keysIn(object), | ||
propsLength = props.length, | ||
length = propsLength && object.length; | ||
var allowIndexes = !!length && isLength(length) && | ||
(isArray(object) || isArguments(object)); | ||
var index = -1, | ||
result = []; | ||
while (++index < propsLength) { | ||
var key = props[index]; | ||
if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { | ||
result.push(key); | ||
} | ||
} | ||
return result; | ||
} | ||
module.exports = traverseRenderedChildren; | ||
module.exports = shimKeys; | ||
/***/ }, | ||
/* 35 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isObject = __webpack_require__(1); | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]'; | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objToString = objectProto.toString; | ||
/** | ||
* Checks if `value` is classified as a `Function` object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @example | ||
* | ||
* _.isFunction(_); | ||
* // => true | ||
* | ||
* _.isFunction(/abc/); | ||
* // => false | ||
*/ | ||
function isFunction(value) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in older versions of Chrome and Safari which return 'function' for regexes | ||
// and Safari 8 which returns 'object' for typed array constructors. | ||
return isObject(value) && objToString.call(value) == funcTag; | ||
} | ||
module.exports = isFunction; | ||
/***/ }, | ||
/* 36 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isFunction = __webpack_require__(35), | ||
isObjectLike = __webpack_require__(3); | ||
/** Used to detect host constructors (Safari > 5). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var fnToString = Function.prototype.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
); | ||
/** | ||
* Checks if `value` is a native function. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a native function, else `false`. | ||
* @example | ||
* | ||
* _.isNative(Array.prototype.push); | ||
* // => true | ||
* | ||
* _.isNative(_); | ||
* // => false | ||
*/ | ||
function isNative(value) { | ||
if (value == null) { | ||
return false; | ||
} | ||
if (isFunction(value)) { | ||
return reIsNative.test(fnToString.call(value)); | ||
} | ||
return isObjectLike(value) && reIsHostCtor.test(value); | ||
} | ||
module.exports = isNative; | ||
/***/ }, | ||
/* 37 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var assignWith = __webpack_require__(19), | ||
baseAssign = __webpack_require__(20), | ||
createAssigner = __webpack_require__(29); | ||
/** | ||
* Assigns own enumerable properties of source object(s) to the destination | ||
* object. Subsequent sources overwrite property assignments of previous sources. | ||
* If `customizer` is provided it's invoked to produce the assigned values. | ||
* The `customizer` is bound to `thisArg` and invoked with five arguments: | ||
* (objectValue, sourceValue, key, object, source). | ||
* | ||
* **Note:** This method mutates `object` and is based on | ||
* [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @alias extend | ||
* @category Object | ||
* @param {Object} object The destination object. | ||
* @param {...Object} [sources] The source objects. | ||
* @param {Function} [customizer] The function to customize assigned values. | ||
* @param {*} [thisArg] The `this` binding of `customizer`. | ||
* @returns {Object} Returns `object`. | ||
* @example | ||
* | ||
* _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); | ||
* // => { 'user': 'fred', 'age': 40 } | ||
* | ||
* // using a customizer callback | ||
* var defaults = _.partialRight(_.assign, function(value, other) { | ||
* return _.isUndefined(value) ? other : value; | ||
* }); | ||
* | ||
* defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); | ||
* // => { 'user': 'barney', 'age': 36 } | ||
*/ | ||
var assign = createAssigner(function(object, source, customizer) { | ||
return customizer | ||
? assignWith(object, source, customizer) | ||
: baseAssign(object, source); | ||
}); | ||
module.exports = assign; | ||
/***/ }, | ||
/* 38 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
var isArguments = __webpack_require__(7), | ||
isArray = __webpack_require__(8), | ||
isIndex = __webpack_require__(6), | ||
isLength = __webpack_require__(5), | ||
isObject = __webpack_require__(1); | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
* Creates an array of the own and inherited enumerable property names of `object`. | ||
* | ||
* **Note:** Non-object values are coerced to objects. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @returns {Array} Returns the array of property names. | ||
* @example | ||
* | ||
* function Foo() { | ||
* this.a = 1; | ||
* this.b = 2; | ||
* } | ||
* | ||
* Foo.prototype.c = 3; | ||
* | ||
* _.keysIn(new Foo); | ||
* // => ['a', 'b', 'c'] (iteration order is not guaranteed) | ||
*/ | ||
function keysIn(object) { | ||
if (object == null) { | ||
return []; | ||
} | ||
if (!isObject(object)) { | ||
object = Object(object); | ||
} | ||
var length = object.length; | ||
length = (length && isLength(length) && | ||
(isArray(object) || isArguments(object)) && length) || 0; | ||
var Ctor = object.constructor, | ||
index = -1, | ||
isProto = typeof Ctor == 'function' && Ctor.prototype === object, | ||
result = Array(length), | ||
skipIndexes = length > 0; | ||
while (++index < length) { | ||
result[index] = (index + ''); | ||
} | ||
for (var key in object) { | ||
if (!(skipIndexes && isIndex(key, length)) && | ||
!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { | ||
result.push(key); | ||
} | ||
} | ||
return result; | ||
} | ||
module.exports = keysIn; | ||
/***/ }, | ||
/* 39 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* This method returns the first argument provided to it. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Utility | ||
* @param {*} value Any value. | ||
* @returns {*} Returns `value`. | ||
* @example | ||
* | ||
* var object = { 'user': 'fred' }; | ||
* | ||
* _.identity(object) === object; | ||
* // => true | ||
*/ | ||
function identity(value) { | ||
return value; | ||
} | ||
module.exports = identity; | ||
/***/ } | ||
/******/ ]) | ||
}); |
'use strict'; | ||
module.exports = require('./makeMakeHot'); | ||
var createProxy = require('react-proxy').createProxy; | ||
var getForceUpdate = require('react-proxy').getForceUpdate; | ||
/** | ||
* Returns a function that will patch React class with new versions of itself | ||
* on subsequent invocations. Both legacy and ES6 style classes are supported. | ||
*/ | ||
function makePatchReactClass(React) { | ||
var forceUpdate = getForceUpdate(React); | ||
var proxy; | ||
return function patchReactClass(NextClass) { | ||
if (!proxy) { | ||
proxy = createProxy(NextClass); | ||
} else { | ||
var mountedInstances = proxy.update(NextClass); | ||
requestAnimationFrame(function () { | ||
mountedInstances.forEach(forceUpdate); | ||
}); | ||
} | ||
return proxy.get(); | ||
}; | ||
}; | ||
/** | ||
* Returns a function that, when invoked, patches a React class with a new | ||
* version of itself. To patch different classes, pass different IDs. | ||
*/ | ||
module.exports = function makeMakeHot(React) { | ||
if (arguments.length === 2) { | ||
// Support legacy signature | ||
React = arguments[1]; | ||
} | ||
if (typeof React !== 'object' || typeof React.Component !== 'function') { | ||
throw new Error('React is now the single required argument, and React Hot API now requires React 0.13+.'); | ||
} | ||
var patchers = {}; | ||
return function makeHot(NextClass, persistentId) { | ||
persistentId = persistentId || NextClass.displayName || NextClass.name; | ||
if (!persistentId) { | ||
console.error( | ||
'Hot reload is disabled for one of your types. To enable it, pass a ' + | ||
'string uniquely identifying this class within this current module ' + | ||
'as a second parameter to makeHot.' | ||
); | ||
return NextClass; | ||
} | ||
if (!patchers[persistentId]) { | ||
patchers[persistentId] = makePatchReactClass(React); | ||
} | ||
var patchReactClass = patchers[persistentId]; | ||
return patchReactClass(NextClass); | ||
}; | ||
}; |
{ | ||
"name": "react-hot-api", | ||
"version": "0.4.6", | ||
"version": "0.5.0-alpha", | ||
"description": "A generic library implementing hot reload for React components without unmounting or losing their state.", | ||
@@ -20,7 +20,10 @@ "main": "modules/index.js", | ||
"peerDependencies": { | ||
"react": ">=0.11.0 || 0.13.0-beta.1 || 0.13.0-rc1 || 0.13.0-rc2 || ^0.14.0-alpha" | ||
"react": ">=0.13.0 || ^0.14.0-alpha" | ||
}, | ||
"devDependencies": { | ||
"webpack": "1.4.8" | ||
}, | ||
"dependencies": { | ||
"react-proxy": "^0.6.1" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
57244
1494
2
8
1
+ Addedreact-proxy@^0.6.1
+ Addedjs-tokens@4.0.0(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-proxy@0.6.7(transitive)