UNPKG

react-apollo

Version:
1,343 lines (1,242 loc) 112 kB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('redux'), require('apollo-client'), require('graphql-tag')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'redux', 'apollo-client', 'graphql-tag'], factory) : (factory((global['react-apollo'] = global['react-apollo'] || {}),global.React,global.PropTypes,global.redux,global.apolloClient,global.graphqlTag)); }(this, (function (exports,React,PropTypes,redux,apolloClient,graphqlTag) { 'use strict'; graphqlTag = 'default' in graphqlTag ? graphqlTag['default'] : graphqlTag; var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var invariant = require('invariant'); var ApolloProvider = (function (_super) { __extends(ApolloProvider, _super); function ApolloProvider(props, context) { var _this = _super.call(this, props, context) || this; invariant(props.client, 'ApolloClient was not passed a client instance. Make ' + 'sure you pass in your client via the "client" prop.'); if (!props.store) { props.client.initStore(); } return _this; } ApolloProvider.prototype.componentWillReceiveProps = function (nextProps) { if (nextProps.client !== this.props.client && !nextProps.store) { nextProps.client.initStore(); } }; ApolloProvider.prototype.getChildContext = function () { return { store: this.props.store || this.context.store, client: this.props.client, }; }; ApolloProvider.prototype.render = function () { return React.Children.only(this.props.children); }; return ApolloProvider; }(React.Component)); ApolloProvider.propTypes = { store: PropTypes.shape({ subscribe: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired, getState: PropTypes.func.isRequired, }), client: PropTypes.object.isRequired, children: PropTypes.element.isRequired, }; ApolloProvider.childContextTypes = { store: PropTypes.object, client: PropTypes.object.isRequired, }; ApolloProvider.contextTypes = { store: PropTypes.object, }; function shallowEqual(objA, objB) { if (!objA || !objB) return true; if (objA === objB) return true; var keysA = Object.keys(objA); var keysB = Object.keys(objB); if (keysA.length !== keysB.length) return false; var hasOwn = Object.prototype.hasOwnProperty; for (var i = 0; i < keysA.length; i++) { if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { return false; } } return true; } var invariant$2 = require('invariant'); var DocumentType; (function (DocumentType) { DocumentType[DocumentType["Query"] = 0] = "Query"; DocumentType[DocumentType["Mutation"] = 1] = "Mutation"; DocumentType[DocumentType["Subscription"] = 2] = "Subscription"; })(DocumentType || (DocumentType = {})); function parser(document) { var variables, type, name; invariant$2((!!document && !!document.kind), "Argument of " + document + " passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document"); var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; }); var queries = document.definitions.filter(function (x) { return x.kind === 'OperationDefinition' && x.operation === 'query'; }); var mutations = document.definitions.filter(function (x) { return x.kind === 'OperationDefinition' && x.operation === 'mutation'; }); var subscriptions = document.definitions.filter(function (x) { return x.kind === 'OperationDefinition' && x.operation === 'subscription'; }); invariant$2(!fragments.length || (queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. You must include a query, subscription or mutation as well"); invariant$2(((queries.length + mutations.length + subscriptions.length) <= 1), "react-apollo only supports a query, subscription, or a mutation per HOC. " + document + " had " + queries.length + " queries, " + subscriptions.length + " subscriptions and " + mutations.length + " mutations. You can use 'compose' to join multiple operation types to a component"); type = queries.length ? DocumentType.Query : DocumentType.Mutation; if (!queries.length && !mutations.length) type = DocumentType.Subscription; var definitions = queries.length ? queries : (mutations.length ? mutations : subscriptions); invariant$2(definitions.length === 1, "react-apollo only supports one defintion per HOC. " + document + " had " + definitions.length + " definitions. You can use 'compose' to join multiple operation types to a component"); var definition = definitions[0]; variables = definition.variableDefinitions || []; var hasName = definition.name && definition.name.kind === 'Name'; name = hasName ? definition.name.value : 'data'; return { name: name, type: type, variables: variables }; } var __extends$1 = (undefined && undefined.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (undefined && undefined.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var pick = require('lodash.pick'); var invariant$1 = require('invariant'); var assign = require('object-assign'); var hoistNonReactStatics = require('hoist-non-react-statics'); var defaultMapPropsToOptions = function (props) { return ({}); }; var defaultMapResultToProps = function (props) { return props; }; var defaultMapPropsToSkip = function (props) { return false; }; function observableQueryFields(observable) { var fields = pick(observable, 'variables', 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling', 'subscribeToMore'); Object.keys(fields).forEach(function (key) { if (typeof fields[key] === 'function') { fields[key] = fields[key].bind(observable); } }); return fields; } function getDisplayName(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } var nextVersion = 0; function graphql(document, operationOptions) { if (operationOptions === void 0) { operationOptions = {}; } var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c; var mapPropsToOptions = options; if (typeof mapPropsToOptions !== 'function') mapPropsToOptions = function () { return options; }; var mapPropsToSkip = skip; if (typeof mapPropsToSkip !== 'function') mapPropsToSkip = (function () { return skip; }); var mapResultToProps = operationOptions.props; var operation = parser(document); var version = nextVersion++; function wrapWithApolloComponent(WrappedComponent) { var graphQLDisplayName = alias + "(" + getDisplayName(WrappedComponent) + ")"; var recycler = new ObservableQueryRecycler(); var GraphQL = (function (_super) { __extends$1(GraphQL, _super); function GraphQL(props, context) { var _this = _super.call(this, props, context) || this; _this.previousData = {}; _this.version = version; _this.client = context.client; invariant$1(!!_this.client, "Could not find \"client\" in the context of " + ("\"" + graphQLDisplayName + "\". ") + "Wrap the root component in an <ApolloProvider>"); _this.store = _this.client.store; _this.type = operation.type; return _this; } GraphQL.prototype.componentWillMount = function () { if (!this.shouldSkip(this.props)) { this.setInitialProps(); } }; GraphQL.prototype.componentDidMount = function () { this.hasMounted = true; if (this.type === DocumentType.Mutation) return; if (!this.shouldSkip(this.props)) { this.subscribeToQuery(); } }; GraphQL.prototype.componentWillReceiveProps = function (nextProps, nextContext) { if (shallowEqual(this.props, nextProps) && this.client === nextContext.client) { return; } this.shouldRerender = true; if (this.client !== nextContext.client) { this.client = nextContext.client; this.unsubscribeFromQuery(); this.queryObservable = null; this.previousData = {}; this.updateQuery(nextProps); if (!this.shouldSkip(nextProps)) { this.subscribeToQuery(); } return; } if (this.type === DocumentType.Mutation) { return; } if (this.type === DocumentType.Subscription && operationOptions.shouldResubscribe && operationOptions.shouldResubscribe(this.props, nextProps)) { this.unsubscribeFromQuery(); delete this.queryObservable; this.updateQuery(nextProps); this.subscribeToQuery(); return; } if (this.shouldSkip(nextProps)) { if (!this.shouldSkip(this.props)) { this.unsubscribeFromQuery(); } return; } this.updateQuery(nextProps); this.subscribeToQuery(); }; GraphQL.prototype.componentWillUnmount = function () { if (this.type === DocumentType.Query) { if (this.queryObservable) { recycler.recycle(this.queryObservable); delete this.queryObservable; } this.unsubscribeFromQuery(); } if (this.type === DocumentType.Subscription) this.unsubscribeFromQuery(); this.hasMounted = false; }; GraphQL.prototype.calculateOptions = function (props, newOpts) { if (props === void 0) { props = this.props; } var opts = mapPropsToOptions(props); if (newOpts && newOpts.variables) { newOpts.variables = assign({}, opts.variables, newOpts.variables); } if (newOpts) opts = assign({}, opts, newOpts); if (opts.variables || !operation.variables.length) return opts; var variables = {}; for (var _i = 0, _a = operation.variables; _i < _a.length; _i++) { var _b = _a[_i], variable = _b.variable, type = _b.type; if (!variable.name || !variable.name.value) continue; if (typeof props[variable.name.value] !== 'undefined') { variables[variable.name.value] = props[variable.name.value]; continue; } if (type.kind !== 'NonNullType') { variables[variable.name.value] = null; continue; } invariant$1(typeof props[variable.name.value] !== 'undefined', "The operation '" + operation.name + "' wrapping '" + getDisplayName(WrappedComponent) + "' " + ("is expecting a variable: '" + variable.name.value + "' but it was not found in the props ") + ("passed to '" + graphQLDisplayName + "'")); } opts = __assign({}, opts, { variables: variables }); return opts; }; GraphQL.prototype.calculateResultProps = function (result) { var name = this.type === DocumentType.Mutation ? 'mutate' : 'data'; if (operationOptions.name) name = operationOptions.name; var newResult = (_a = {}, _a[name] = result, _a.ownProps = this.props, _a); if (mapResultToProps) return mapResultToProps(newResult); return _b = {}, _b[name] = defaultMapResultToProps(result), _b; var _a, _b; }; GraphQL.prototype.setInitialProps = function () { if (this.type === DocumentType.Mutation) { return; } var opts = this.calculateOptions(this.props); this.createQuery(opts); }; GraphQL.prototype.createQuery = function (opts) { if (this.type === DocumentType.Subscription) { this.queryObservable = this.client.subscribe(assign({ query: document, }, opts)); } else { var queryObservable = recycler.reuse(opts); if (queryObservable === null) { this.queryObservable = this.client.watchQuery(assign({ query: document, metadata: { reactComponent: { displayName: graphQLDisplayName, }, }, }, opts)); } else { this.queryObservable = queryObservable; } } }; GraphQL.prototype.updateQuery = function (props) { var opts = this.calculateOptions(props); if (!this.queryObservable) { this.createQuery(opts); } if (this.queryObservable._setOptionsNoResult) { this.queryObservable._setOptionsNoResult(opts); } else { if (this.queryObservable.setOptions) { this.queryObservable.setOptions(opts) .catch(function (error) { return null; }); } } }; GraphQL.prototype.fetchData = function () { if (this.shouldSkip()) return false; if (operation.type === DocumentType.Mutation || operation.type === DocumentType.Subscription) return false; var opts = this.calculateOptions(); if (opts.ssr === false) return false; if (opts.fetchPolicy === 'network-only' || opts.fetchPolicy === 'cache-and-network') { opts.fetchPolicy = 'cache-first'; } var observable = this.client.watchQuery(assign({ query: document }, opts)); var result = observable.currentResult(); if (result.loading) { return observable.result(); } else { return false; } }; GraphQL.prototype.subscribeToQuery = function () { var _this = this; if (this.querySubscription) { return; } var next = function (results) { if (_this.type === DocumentType.Subscription) { _this.lastSubscriptionData = results; results = { data: results }; } var clashingKeys = Object.keys(observableQueryFields(results.data)); invariant$1(clashingKeys.length === 0, "the result of the '" + graphQLDisplayName + "' operation contains keys that " + "conflict with the return object." + clashingKeys.map(function (k) { return "'" + k + "'"; }).join(', ') + " not allowed."); _this.forceRenderChildren(); }; var handleError = function (error) { if (error.hasOwnProperty('graphQLErrors')) return next({ error: error }); throw error; }; this.querySubscription = this.queryObservable.subscribe({ next: next, error: handleError }); }; GraphQL.prototype.unsubscribeFromQuery = function () { if (this.querySubscription) { this.querySubscription.unsubscribe(); delete this.querySubscription; } }; GraphQL.prototype.shouldSkip = function (props) { if (props === void 0) { props = this.props; } return mapPropsToSkip(props) || mapPropsToOptions(props).skip; }; GraphQL.prototype.forceRenderChildren = function () { this.shouldRerender = true; if (this.hasMounted) this.setState({}); }; GraphQL.prototype.getWrappedInstance = function () { invariant$1(operationOptions.withRef, "To access the wrapped instance, you need to specify " + "{ withRef: true } in the options"); return this.refs.wrappedInstance; }; GraphQL.prototype.dataForChild = function () { var _this = this; if (this.type === DocumentType.Mutation) { return function (mutationOpts) { var opts = _this.calculateOptions(_this.props, mutationOpts); if (typeof opts.variables === 'undefined') delete opts.variables; opts.mutation = document; return _this.client.mutate(opts); }; } var opts = this.calculateOptions(this.props); var data = {}; assign(data, observableQueryFields(this.queryObservable)); if (this.type === DocumentType.Subscription) { assign(data, { loading: !this.lastSubscriptionData, variables: opts.variables, }, this.lastSubscriptionData); } else { var currentResult = this.queryObservable.currentResult(); var loading = currentResult.loading, error_1 = currentResult.error, networkStatus = currentResult.networkStatus; assign(data, { loading: loading, networkStatus: networkStatus }); var logErrorTimeoutId_1 = setTimeout(function () { if (error_1) { console.error('Unhandled (in react-apollo)', error_1.stack || error_1); } }, 10); Object.defineProperty(data, 'error', { configurable: true, enumerable: true, get: function () { clearTimeout(logErrorTimeoutId_1); return error_1; }, }); if (loading) { assign(data, this.previousData, currentResult.data); } else if (error_1) { assign(data, (this.queryObservable.getLastResult() || {}).data); } else { assign(data, currentResult.data); this.previousData = currentResult.data; } } return data; }; GraphQL.prototype.render = function () { if (this.shouldSkip()) { return React.createElement(WrappedComponent, this.props); } var _a = this, shouldRerender = _a.shouldRerender, renderedElement = _a.renderedElement, props = _a.props; this.shouldRerender = false; if (!shouldRerender && renderedElement && renderedElement.type === WrappedComponent) { return renderedElement; } var data = this.dataForChild(); var clientProps = this.calculateResultProps(data); var mergedPropsAndData = assign({}, props, clientProps); if (operationOptions.withRef) mergedPropsAndData.ref = 'wrappedInstance'; this.renderedElement = React.createElement(WrappedComponent, mergedPropsAndData); return this.renderedElement; }; return GraphQL; }(React.Component)); GraphQL.displayName = graphQLDisplayName; GraphQL.WrappedComponent = WrappedComponent; GraphQL.contextTypes = { client: PropTypes.object.isRequired, }; return hoistNonReactStatics(GraphQL, WrappedComponent, {}); } return wrapWithApolloComponent; } var ObservableQueryRecycler = (function () { function ObservableQueryRecycler() { this.observableQueries = []; } ObservableQueryRecycler.prototype.recycle = function (observableQuery) { observableQuery.setOptions({ fetchPolicy: 'standby', pollInterval: 0, fetchResults: false, }); this.observableQueries.push({ observableQuery: observableQuery, subscription: observableQuery.subscribe({}), }); }; ObservableQueryRecycler.prototype.reuse = function (options) { if (this.observableQueries.length <= 0) { return null; } var _a = this.observableQueries.pop(), observableQuery = _a.observableQuery, subscription = _a.subscription; subscription.unsubscribe(); observableQuery.setOptions(__assign({}, options, { pollInterval: options.pollInterval, fetchPolicy: options.fetchPolicy })); return observableQuery; }; return ObservableQueryRecycler; }()); var __extends$2 = (undefined && undefined.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var invariant$3 = require('invariant'); var assign$1 = require('object-assign'); var hoistNonReactStatics$1 = require('hoist-non-react-statics'); function getDisplayName$1(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } function withApollo(WrappedComponent, operationOptions) { if (operationOptions === void 0) { operationOptions = {}; } var withDisplayName = "withApollo(" + getDisplayName$1(WrappedComponent) + ")"; var WithApollo = (function (_super) { __extends$2(WithApollo, _super); function WithApollo(props, context) { var _this = _super.call(this, props, context) || this; _this.client = context.client; invariant$3(!!_this.client, "Could not find \"client\" in the context of " + ("\"" + withDisplayName + "\". ") + "Wrap the root component in an <ApolloProvider>"); return _this; } WithApollo.prototype.getWrappedInstance = function () { invariant$3(operationOptions.withRef, "To access the wrapped instance, you need to specify " + "{ withRef: true } in the options"); return this.refs.wrappedInstance; }; WithApollo.prototype.render = function () { var props = assign$1({}, this.props); props.client = this.client; if (operationOptions.withRef) props.ref = 'wrappedInstance'; return React.createElement(WrappedComponent, props); }; return WithApollo; }(React.Component)); WithApollo.displayName = withDisplayName; WithApollo.WrappedComponent = WrappedComponent; WithApollo.contextTypes = { client: PropTypes.object.isRequired }; return hoistNonReactStatics$1(WithApollo, WrappedComponent, {}); } exports.ApolloProvider = ApolloProvider; exports.graphql = graphql; exports.withApollo = withApollo; exports.compose = redux.compose; exports.gql = graphqlTag; Object.keys(apolloClient).forEach(function (key) { exports[key] = apolloClient[key]; }); Object.defineProperty(exports, '__esModule', { value: true }); }))); },{"apollo-client":2,"graphql-tag":2,"hoist-non-react-statics":7,"invariant":8,"lodash.pick":9,"object-assign":20,"prop-types":24,"react":2,"redux":31}],2:[function(require,module,exports){ },{}],3:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; },{}],4:[function(require,module,exports){ "use strict"; /** * Copyright (c) 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. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; },{}],5:[function(require,module,exports){ (function (process){ /** * Copyright (c) 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. * */ 'use strict'; /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var validateFormat = function validateFormat(format) {}; if (process.env.NODE_ENV !== 'production') { validateFormat = function validateFormat(format) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } }; } function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } module.exports = invariant; }).call(this,require('_process')) },{"_process":3}],6:[function(require,module,exports){ (function (process){ /** * Copyright 2014-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 this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ 'use strict'; var emptyFunction = require('./emptyFunction'); /** * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var warning = emptyFunction; if (process.env.NODE_ENV !== 'production') { (function () { var printWarning = function printWarning(format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; warning = function warning(condition, format) { if (format === undefined) { throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); } if (format.indexOf('Failed Composite propType: ') === 0) { return; // Ignore CompositeComponent proptype check. } if (!condition) { for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } printWarning.apply(undefined, [format].concat(args)); } }; })(); } module.exports = warning; }).call(this,require('_process')) },{"./emptyFunction":4,"_process":3}],7:[function(require,module,exports){ /** * Copyright 2015, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ 'use strict'; var REACT_STATICS = { childContextTypes: true, contextTypes: true, defaultProps: true, displayName: true, getDefaultProps: true, mixins: true, propTypes: true, type: true }; var KNOWN_STATICS = { name: true, length: true, prototype: true, caller: true, arguments: true, arity: true }; var isGetOwnPropertySymbolsAvailable = typeof Object.getOwnPropertySymbols === 'function'; module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, customStatics) { if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components var keys = Object.getOwnPropertyNames(sourceComponent); /* istanbul ignore else */ if (isGetOwnPropertySymbolsAvailable) { keys = keys.concat(Object.getOwnPropertySymbols(sourceComponent)); } for (var i = 0; i < keys.length; ++i) { if (!REACT_STATICS[keys[i]] && !KNOWN_STATICS[keys[i]] && (!customStatics || !customStatics[keys[i]])) { try { targetComponent[keys[i]] = sourceComponent[keys[i]]; } catch (error) { } } } } return targetComponent; }; },{}],8:[function(require,module,exports){ (function (process){ /** * 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 this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var invariant = function(condition, format, a, b, c, d, e, f) { if (process.env.NODE_ENV !== 'production') { if (format === undefined) { throw new Error('invariant requires an error message argument'); } } if (!condition) { var error; if (format === undefined) { error = new Error( 'Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.' ); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error( format.replace(/%s/g, function() { return args[argIndex++]; }) ); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } }; module.exports = invariant; }).call(this,require('_process')) },{"_process":3}],9:[function(require,module,exports){ (function (global){ /** * lodash (Custom Build) <https://lodash.com/> * Build: `lodash modularize exports="npm" -o ./` * Copyright jQuery Foundation and other contributors <https://jquery.org/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0, MAX_SAFE_INTEGER = 9007199254740991; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', symbolTag = '[object Symbol]'; /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. * * @private * @param {Function} func The function to invoke. * @param {*} thisArg The `this` binding of `func`. * @param {Array} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function arrayMap(array, iteratee) { var index = -1, length = array ? array.length : 0, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } /** * 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; } /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; /** Built-in value references. */ var Symbol = root.Symbol, propertyIsEnumerable = objectProto.propertyIsEnumerable, spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; /** * The base implementation of `_.flatten` with support for restricting flattening. * * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; predicate || (predicate = isFlattenable); result || (result = []); while (++index < length) { var value = array[index]; if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). baseFlatten(value, depth - 1, predicate, isStrict, result); } else { arrayPush(result, value); } } else if (!isStrict) { result[result.length] = value; } } return result; } /** * The base implementation of `_.pick` without support for individual * property identifiers. * * @private * @param {Object} object The source object. * @param {string[]} props The property identifiers to pick. * @returns {Object} Returns the new object. */ function basePick(object, props) { object = Object(object); return basePickBy(object, props, function(value, key) { return key in object; }); } /** * The base implementation of `_.pickBy` without support for iteratee shorthands. * * @private * @param {Object} object The source object. * @param {string[]} props The property identifiers to pick from. * @param {Function} predicate The function invoked per property. * @returns {Object} Returns the new object. */ function basePickBy(object, props, predicate) { var index = -1, length = props.length, result = {}; while (++index < length) { var key = props[index], value = object[key]; if (predicate(value, key)) { result[key] = value; } } return result; } /** * The base implementation of `_.rest` which doesn't validate or coerce arguments. * * @private * @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. */ function baseRest(func, start) { start = nativeMax(start === undefined ? (func.length - 1) : start, 0); return function() { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = array; return apply(func, this, otherArgs); }; } /** * Checks if `value` is a flattenable `arguments` object or array. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. */ function isFlattenable(value) { return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); } /** * Converts `value` to a string key if it's not a string or symbol. * * @private * @param {*} value The value to inspect. * @returns {string|symbol} Returns the key. */ function toKey(value) { if (typeof value == 'string' || isSymbol(value)) { return value; } var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } /** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, * else `false`. * @example * * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); * // => false */ function isArguments(value) { // Safari 8.1 makes `arguments.callee` enumerable in strict mode. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); } /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray = Array.isArray; /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * * _.isArrayLike([1, 2, 3]); * // => true * * _.isArrayLike(document.body.children); * // => true * * _.isArrayLike('abc'); * // => true * * _.isArrayLike(_.noop); * // => false */ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } /** * This method is like `_.isArrayLike` except that it also checks if `value` * is an object. * * @static * @memberOf _ * @since 4.0.0 * @categ