j-gallery
Version:
a picture layout library
406 lines (329 loc) • 11.6 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define(factory);
else if(typeof exports === 'object')
exports["ReactHotAPI"] = factory();
else
root["ReactHotAPI"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
module.exports = __webpack_require__(4);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
function bindAutoBindMethod(component, method) {
var boundMethod = method.bind(component);
boundMethod.__reactBoundContext = component;
boundMethod.__reactBoundMethod = method;
boundMethod.__reactBoundArguments = null;
var componentName = component.constructor.displayName,
_bind = boundMethod.bind;
boundMethod.bind = function (newThis) {
var args = Array.prototype.slice.call(arguments, 1);
if (newThis !== component && newThis !== null) {
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
);
return boundMethod;
}
var reboundMethod = _bind.apply(boundMethod, arguments);
reboundMethod.__reactBoundContext = component;
reboundMethod.__reactBoundMethod = method;
reboundMethod.__reactBoundArguments = args;
return reboundMethod;
};
return boundMethod;
}
/**
* 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
*/
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;
}
// Skip already bound methods
if (component.hasOwnProperty(autoBindKey) &&
component[autoBindKey].__reactBoundContext === component) {
continue;
}
var method = component.__reactAutoBindMap[autoBindKey];
component[autoBindKey] = bindAutoBindMethod(component, method);
}
};
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var bindAutoBindMethods = __webpack_require__(1);
var traverseRenderedChildren = __webpack_require__(7);
function setPendingForceUpdate(internalInstance) {
if (internalInstance._pendingForceUpdate === false) {
internalInstance._pendingForceUpdate = true;
}
}
function forceUpdateIfPending(internalInstance, React) {
if (internalInstance._pendingForceUpdate === true) {
// `|| internalInstance` for React 0.12 and earlier
var instance = internalInstance._instance || internalInstance;
if (instance.forceUpdate) {
instance.forceUpdate();
} else if (React && React.Component) {
React.Component.prototype.forceUpdate.call(instance);
}
}
}
/**
* 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);
}
module.exports = deepForceUpdate;
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* 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 = [];
function wrapMethod(key) {
return function () {
if (storedPrototype[key]) {
return storedPrototype[key].apply(this, arguments);
}
};
}
function patchProperty(proto, key) {
proto[key] = storedPrototype[key];
if (typeof proto[key] !== 'function' ||
key === 'type' ||
key === 'constructor') {
return;
}
proto[key] = wrapMethod(key);
if (storedPrototype[key].isReactClassApproved) {
proto[key].isReactClassApproved = storedPrototype[key].isReactClassApproved;
}
if (proto.__reactAutoBindMap && proto.__reactAutoBindMap[key]) {
proto.__reactAutoBindMap[key] = proto[key];
}
}
function updateStoredPrototype(freshPrototype) {
storedPrototype = {};
Object.getOwnPropertyNames(freshPrototype).forEach(function (key) {
storedPrototype[key] = freshPrototype[key];
});
}
function reconcileWithStoredPrototypes(freshPrototype) {
knownPrototypes.push(freshPrototype);
knownPrototypes.forEach(function (proto) {
Object.getOwnPropertyNames(storedPrototype).forEach(function (key) {
patchProperty(proto, key);
});
});
}
return function assimilatePrototype(freshPrototype) {
if (Object.prototype.hasOwnProperty.call(freshPrototype, '__isAssimilatedByReactHotAPI')) {
return;
}
updateStoredPrototype(freshPrototype);
reconcileWithStoredPrototypes(freshPrototype);
freshPrototype.__isAssimilatedByReactHotAPI = true;
};
};
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var makePatchReactClass = __webpack_require__(5);
/**
* 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(getRootInstances, React) {
if (typeof getRootInstances !== 'function') {
throw new Error('Expected getRootInstances to be a function.');
}
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(getRootInstances, React);
}
var patchReactClass = patchers[persistentId];
return patchReactClass(NextClass);
};
};
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var makeAssimilatePrototype = __webpack_require__(3),
requestForceUpdateAll = __webpack_require__(6);
function hasNonStubTypeProperty(ReactClass) {
if (!ReactClass.hasOwnProperty('type')) {
return false;
}
var descriptor = Object.getOwnPropertyDescriptor(ReactClass, 'type');
if (typeof descriptor.get === 'function') {
return false;
}
return true;
}
function getPrototype(ReactClass) {
var prototype = ReactClass.prototype,
seemsLegit = prototype && typeof prototype.render === 'function';
if (!seemsLegit && hasNonStubTypeProperty(ReactClass)) {
prototype = ReactClass.type.prototype;
}
return prototype;
}
/**
* Returns a function that will patch React class with new versions of itself
* on subsequent invocations. Both legacy and ES6 style classes are supported.
*/
module.exports = function makePatchReactClass(getRootInstances, React) {
var assimilatePrototype = makeAssimilatePrototype(),
FirstClass = null;
return function patchReactClass(NextClass) {
var nextPrototype = getPrototype(NextClass);
assimilatePrototype(nextPrototype);
if (FirstClass) {
requestForceUpdateAll(getRootInstances, React);
}
return FirstClass || (FirstClass = NextClass);
};
};
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
var deepForceUpdate = __webpack_require__(2);
var isRequestPending = false;
module.exports = function requestForceUpdateAll(getRootInstances, React) {
if (isRequestPending) {
return;
}
/**
* 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;
var rootInstances = getRootInstances(),
rootInstance;
for (var key in rootInstances) {
if (rootInstances.hasOwnProperty(key)) {
rootInstance = rootInstances[key];
// `|| rootInstance` for React 0.12 and earlier
rootInstance = rootInstance._reactInternalInstance || rootInstance;
deepForceUpdate(rootInstance, React);
}
}
}
setTimeout(forceUpdateAll);
};
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
function traverseRenderedChildren(internalInstance, callback, argument) {
callback(internalInstance, argument);
if (internalInstance._renderedComponent) {
traverseRenderedChildren(
internalInstance._renderedComponent,
callback,
argument
);
} else {
for (var key in internalInstance._renderedChildren) {
traverseRenderedChildren(
internalInstance._renderedChildren[key],
callback,
argument
);
}
}
}
module.exports = traverseRenderedChildren;
/***/ }
/******/ ])
});