From b5847aa7a4b5c9f99710cdf6a1f4a92b06e74799 Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Thu, 13 Aug 2015 10:31:44 +0200 Subject: [PATCH] v3.3.0 --- dist/omniscient.js | 686 +++++++++++++++++++++-------------------- dist/omniscient.min.js | 4 +- package.json | 2 +- 3 files changed, 350 insertions(+), 342 deletions(-) diff --git a/dist/omniscient.js b/dist/omniscient.js index 76ffff3..f2cb34e 100644 --- a/dist/omniscient.js +++ b/dist/omniscient.js @@ -1,284 +1,387 @@ /** -* Omniscient.js v3.2.0 +* Omniscient.js v3.3.0 * Authors: @torgeir,@mikaelbr ***************************************/ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.omniscient=e()}}(function(){var define,module,exports;return (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;oHello! - * }); - * React.render(, document.body); - * ``` + * @module cached.withDefaults + * @returns {Function} cached with overriden defaults + * @api public + */ +module.exports.withDefaults = factory; + +function factory (methods) { + var isEqual = (methods && methods.isEqualProps) || shouldupdate.isEqualProps; + + return function cached (f) { + var input, + output; + + return function () { + if (!isEqual(arguments, input)) { + output = f.apply(this, arguments); + } + // Update input either way to allow GC reclaim it unless + // anything else is referring to it. + input = arguments; + return output; + }; + }; +} + +},{"./shouldupdate":35}],3:[function(_dereq_,module,exports){ +"use strict"; + +var assign = _dereq_('lodash.assign'); + +var shouldComponentUpdate = _dereq_('./shouldupdate'); +var cached = _dereq_('./cached'); + +/** + * Create components for functional views. * - * #### Un-wrapping curors - * ```jsx - * var localComponent = component.withDefaults({ - * cursorField: 'foobar' - * }); + * The API of Omniscient is pretty simple, you create a component + * with a render function and the mixins you need. * - * var Component = localComponent(function (myCursor) { - * // Now you have myCursor directly instead of having to do props.foobar - * }); + * When using the created component, you can pass a cursor or an object + * as data to it. This data will be the render function's first argument, + * and it will also be available on `this.props`. * - * React.render(, document.body); - * ``` + * If you simply pass one cursor, the cursor will be accessible on the + * `props.cursor` accessor. Data placed on the property `statics` of the + * component's arguments will not be tracked for changes. * - * @param {Object} Options Options with defaults to override + * @param {String} displayName Component's display name. Used when debug()'ing and by React + * @param {Array|Object} mixins React mixins. Object literals with functions, or array of object literals with functions. + * @param {Function} render Properties that do not trigger update when changed. Can be cursors, object and immutable structures * * @property {Function} shouldComponentUpdate Get default shouldComponentUpdate - * @module omniscient.withDefaults + * @module omniscient * @returns {Component} * @api public */ -module.exports.withDefaults = factory; - -function factory (options) { - var debug; - options = options || {}; - var _shouldComponentUpdate = options.shouldComponentUpdate || - shouldComponentUpdate.withDefaults(options); - var _isCursor = options.isCursor || shouldComponentUpdate.isCursor; - var _isImmutable = options.isImmutable || shouldComponentUpdate.isImmutable; - var _isJsx = !!options.jsx; - var _hiddenCursorField = options.cursorField || '__singleCursor'; - var _isNode = options.isNode || isNode; - var _cached = cached.withDefaults(_shouldComponentUpdate); +module.exports = function (React) { + var instance = factory(); /** - * Activate debugging for components. Will log when a component renders, - * the outcome of `shouldComponentUpdate`, and why the component re-renders. + * Create a “local” instance of the Omniscient component creator by using the `.withDefaults` method. + * This also allows you to override any defaults that Omniscient use to check equality of objects, + * unwrap cursors, etc. + * + * ### Options + * ```js + * { + * // Goes directly to component + * shouldComponentUpdate: function(nextProps, nextState), // check update + * jsx: false, // whether or not to default to jsx components + * cursorField: '__singleCursor', // cursor property name to "unwrap" before passing in to render + * isNode: function(propValue), // determines if propValue is a valid React node + * + * // Passed on to `shouldComponentUpdate` + * isCursor: function(cursor), // check if prop is cursor + * unCursor: function (cursor), // convert cursor to object + * isEqualCursor: function (oneCursor, otherCursor), // compares cursor + * isEqualState: function (currentState, nextState), // compares state + * isEqualProps: function (currentProps, nextProps), // compares props + * isImmutable: function (maybeImmutable) // check if object is immutable + * } + * ``` * - * ### Example + * ### Examples + * #### Always use JSX * ```js - * Search>: shouldComponentUpdate => true (cursors have changed) - * Search>: render - * SearchBox>: shouldComponentUpdate => true (cursors have changed) - * SearchBox>: render + * var component = require('omniscient'); + * var jsxComponent = component.withDefaults({ + * jsx: true + * }); + * + * var Greeting = jsxComponent(function () { + * return

Hello!

+ * }); + * React.render(, document.body); * ``` * - * @example omniscient.debug(/Search/i); + * #### Un-wrapping curors + * ```jsx + * var localComponent = component.withDefaults({ + * cursorField: 'foobar' + * }); * - * @param {RegExp} pattern Filter pattern. Only show messages matching pattern + * var Component = localComponent(function (myCursor) { + * // Now you have myCursor directly instead of having to do props.foobar + * }); + * + * React.render(, document.body); + * ``` * - * @property {Object} jsx Get component for use in JSX + * @param {Object} Options Options with defaults to override * - * @module omniscient.debug - * @returns {Immstruct} + * @property {Function} shouldComponentUpdate Get default shouldComponentUpdate + * + * @module omniscient.withDefaults + * @returns {Component} * @api public */ - ComponentCreator.debug = debugFn; - ComponentCreator.cached = _cached; - ComponentCreator.shouldComponentUpdate = _shouldComponentUpdate; - return ComponentCreator; - - function ComponentCreator (displayName, mixins, render) { - var options = createDefaultArguments(displayName, mixins, render); - var methodStatics = pickStaticMixins(options.mixins); - - var componentObject = { - displayName: options.displayName || options.render.name, - mixins: options.mixins, - render: function render () { - if (debug) debug.call(this, 'render'); - // If `props['__singleCursor']` is set a single cursor was passed - // to the component, pick it out and pass it. - var input = this.props[_hiddenCursorField] || this.props; - this.cursor = this.props[_hiddenCursorField]; - return options.render.call(this, input, this.props.statics); - } - }; - - if (methodStatics) { - componentObject.statics = methodStatics; - removeOldStaticMethods(options.mixins); - } - - var Component = React.createClass(componentObject); - if (_isJsx) { - return Component; - } + instance.withDefaults = factory; + + return instance; + + function factory (options) { + var debug; + options = options || {}; + var _shouldComponentUpdate = options.shouldComponentUpdate || + shouldComponentUpdate.withDefaults(options); + var _isCursor = options.isCursor || shouldComponentUpdate.isCursor; + var _isImmutable = options.isImmutable || shouldComponentUpdate.isImmutable; + var _isJsx = !!options.jsx; + var _hiddenCursorField = options.cursorField || '__singleCursor'; + var _isNode = options.isNode || isNode; + var _cached = cached.withDefaults(_shouldComponentUpdate); /** - * Invoke component (rendering it) + * Activate debugging for components. Will log when a component renders, + * the outcome of `shouldComponentUpdate`, and why the component re-renders. + * + * ### Example + * ```js + * Search>: shouldComponentUpdate => true (cursors have changed) + * Search>: render + * SearchBox>: shouldComponentUpdate => true (cursors have changed) + * SearchBox>: render + * ``` + * + * @example omniscient.debug(/Search/i); * - * @param {String} displayName Component display name. Used in debug and by React - * @param {Object} props Properties that **do** trigger update when changed. Can be cursors, object and immutable structures - * @param {Object} statics Properties that do not trigger update when changed. Can be cursors, object and immutable structuress - * @param {Object} ..rest Child components (React elements, scalar values) + * @param {RegExp} pattern Filter pattern. Only show messages matching pattern * * @property {Object} jsx Get component for use in JSX - - * @module Component - * @returns {ReactElement} + * + * @module omniscient.debug + * @returns {Immstruct} * @api public */ - var create = function (key, props, statics) { - var _props; - var inputCursor; - var children; - - if (typeof key === 'object') { - statics = props; - props = key; - key = void 0; - } - - children = flatten(sliceFrom(arguments, statics).filter(_isNode)); + ComponentCreator.debug = debugFn; + ComponentCreator.cached = _cached; + ComponentCreator.shouldComponentUpdate = _shouldComponentUpdate; + return ComponentCreator; + + function ComponentCreator (displayName, mixins, render) { + var options = createDefaultArguments(displayName, mixins, render); + var methodStatics = pickStaticMixins(options.mixins); + + var componentObject = { + displayName: options.displayName || options.render.name, + mixins: options.mixins, + render: function render () { + if (debug) debug.call(this, 'render'); + // If `props['__singleCursor']` is set a single cursor was passed + // to the component, pick it out and pass it. + var input = this.props[_hiddenCursorField] || this.props; + this.cursor = this.props[_hiddenCursorField]; + return options.render.call(this, input, this.props.statics); + } + }; - // If passed props is a signle cursor we move it to `props[_hiddenCursorField]` - // to simplify should component update. The render function will move it back. - // The name '__singleCursor' is used to not clash with names of user passed properties - if (_isCursor(props) || _isImmutable(props)) { - inputCursor = props; - _props = {}; - _props[_hiddenCursorField] = inputCursor; - } else { - _props = assign({}, props); + if (methodStatics) { + componentObject.statics = methodStatics; + removeOldStaticMethods(options.mixins); } - // If statics is a node (due to it being optional) - // don't attach the node to the statics prop - if (!!statics && !props.statics && !_isNode(statics)) { - _props.statics = statics; + var Component = React.createClass(componentObject); + if (_isJsx) { + return Component; } - if (key) { - _props.key = key; - } + /** + * Invoke component (rendering it) + * + * @param {String} displayName Component display name. Used in debug and by React + * @param {Object} props Properties that **do** trigger update when changed. Can be cursors, object and immutable structures + * @param {Object} statics Properties that do not trigger update when changed. Can be cursors, object and immutable structuress + * @param {Object} ..rest Child components (React elements, scalar values) + * + * @property {Object} jsx Get component for use in JSX + + * @module Component + * @returns {ReactElement} + * @api public + */ + var create = function (key, props, statics) { + var _props; + var inputCursor; + var children; + + if (typeof key === 'object') { + statics = props; + props = key; + key = void 0; + } - if (!!children.length) { - _props.children = children; - } + children = flatten(sliceFrom(arguments, statics).filter(_isNode)); - return React.createElement(Component, _props); - }; + // If passed props is a signle cursor we move it to `props[_hiddenCursorField]` + // to simplify should component update. The render function will move it back. + // The name '__singleCursor' is used to not clash with names of user passed properties + if (_isCursor(props) || _isImmutable(props)) { + inputCursor = props; + _props = {}; + _props[_hiddenCursorField] = inputCursor; + } else { + _props = assign({}, props); + } - create.jsx = Component; + // If statics is a node (due to it being optional) + // don't attach the node to the statics prop + if (!!statics && !props.statics && !_isNode(statics)) { + _props.statics = statics; + } - if (methodStatics) { - create = assign(create, methodStatics); - } + if (key) { + _props.key = key; + } - return create; - } + if (!!children.length) { + _props.children = children; + } - function debugFn (pattern, logFn) { - if (_shouldComponentUpdate.debug) { - debug = _shouldComponentUpdate.debug(pattern, logFn); - } - } + return React.createElement(Component, _props); + }; - function createDefaultArguments (displayName, mixins, render) { + create.jsx = Component; - // (render) - if (typeof displayName === 'function') { - render = displayName; - mixins = []; - displayName = void 0; - } + if (methodStatics) { + create = assign(create, methodStatics); + } - // (mixins, render) - if (typeof displayName === 'object' && typeof mixins === 'function') { - render = mixins; - mixins = displayName; - displayName = void 0; + return create; } - // (displayName, render) - if (typeof displayName === 'string' && typeof mixins === 'function') { - render = mixins; - mixins = []; + function debugFn (pattern, logFn) { + if (_shouldComponentUpdate.debug) { + debug = _shouldComponentUpdate.debug(pattern, logFn); + } } - // Else (displayName, mixins, render) + function createDefaultArguments (displayName, mixins, render) { - if (!Array.isArray(mixins)) { - mixins = [mixins]; - } + // (render) + if (typeof displayName === 'function') { + render = displayName; + mixins = []; + displayName = void 0; + } + + // (mixins, render) + if (typeof displayName === 'object' && typeof mixins === 'function') { + render = mixins; + mixins = displayName; + displayName = void 0; + } + + // (displayName, render) + if (typeof displayName === 'string' && typeof mixins === 'function') { + render = mixins; + mixins = []; + } - // Add built-in lifetime methods to keep `statics` up to date. - mixins.unshift(componentWillMount.asMixin, - componentWillReceiveProps.asMixin); + // Else (displayName, mixins, render) - if (!hasShouldComponentUpdate(mixins)) { - mixins.unshift({ - shouldComponentUpdate: _shouldComponentUpdate - }); + if (!Array.isArray(mixins)) { + mixins = [mixins]; + } + + // Add built-in lifetime methods to keep `statics` up to date. + mixins.unshift(componentWillMount.asMixin, + componentWillReceiveProps.asMixin); + + if (!hasShouldComponentUpdate(mixins)) { + mixins.unshift({ + shouldComponentUpdate: _shouldComponentUpdate + }); + } + + return { + displayName: displayName, + mixins: mixins, + render: render + }; } + } - return { - displayName: displayName, - mixins: mixins, - render: render - }; + /** + * Predicate showing whether or not the argument is a valid React Node + * or not. Can be numbers, strings, bools, and React Elements. + * + * React's isNode check from ReactPropTypes validator + * but adjusted to not accept objects to avoid collision with props & statics. + * + * @param {String} propValue Property value to check if is valid React Node + * + * @returns {Boolean} + * @api private + */ + function isNode (propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (React.isValidElement(propValue)) { + return true; + } + return false; + default: + return false; + } } } @@ -331,38 +434,6 @@ function flatten (array) { return Array.prototype.concat.apply([], array); } -/** - * Predicate showing whether or not the argument is a valid React Node - * or not. Can be numbers, strings, bools, and React Elements. - * - * React's isNode check from ReactPropTypes validator - * but adjusted to not accept objects to avoid collision with props & statics. - * - * @param {String} propValue Property value to check if is valid React Node - * - * @returns {Boolean} - * @api private - */ -function isNode (propValue) { - switch (typeof propValue) { - case 'number': - case 'string': - return true; - case 'boolean': - return !propValue; - case 'object': - if (Array.isArray(propValue)) { - return propValue.every(isNode); - } - if (React.isValidElement(propValue)) { - return true; - } - return false; - default: - return false; - } -} - function delegate(delegee) { var delegateFunction = function() { return delegateFunction.delegee.apply(this, arguments); @@ -402,8 +473,8 @@ function componentWillReceiveProps (newProps) { var currentStatics = currentProps.statics; var newStatics = newProps.statics; var haveChangedStatics = newStatics !== currentStatics && - newStatics && - typeof newStatics === 'object'; + newStatics && + typeof newStatics === 'object'; if (haveChangedStatics) { Object.keys(newStatics).forEach(function (key) { @@ -427,71 +498,7 @@ componentWillReceiveProps.asMixin = { componentWillReceiveProps: componentWillReceiveProps }; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./cached":2,"./shouldupdate":34,"lodash.assign":3}],2:[function(_dereq_,module,exports){ -"use strict"; - -var shouldupdate = _dereq_('./shouldupdate'); - -/** - * Directly fetch `cache` to use outside of Omniscient. - * You can do this if you want to define functions that caches computed - * result to avoid recomputing if invoked with equal arguments as last time. - * - * Returns optimized version of given `f` function for repeated - * calls with an equal inputs. Returned function caches last input - * and a result of the computation for it, which is handy for - * optimizing `render` when computations are run on unchanged parts - * of state. Although note that only last result is cached so it is - * not practical to call it mulitple times with in the same `render` - * call. - * - * @param {Function} Function that does a computation. - * - * @module cached - * @returns {Function} Optimized function - * @api public - */ -module.exports = factory(); - -/** - * Create a “local” instance of the `cache` with overriden defaults. - * - * ### Options - * ```js - * { - * isEqualProps: function (currentProps, nextProps), // check props - * } - * ``` - * - * @param {Object} [Options] Options with defaults to override - * - * @module cached.withDefaults - * @returns {Function} cached with overriden defaults - * @api public - */ -module.exports.withDefaults = factory; - -function factory (methods) { - var isEqual = (methods && methods.isEqualProps) || shouldupdate.isEqualProps; - - return function cached (f) { - var input, - output; - - return function () { - if (!isEqual(arguments, input)) { - output = f.apply(this, arguments); - } - // Update input either way to allow GC reclaim it unless - // anything else is referring to it. - input = arguments; - return output; - }; - }; -} - -},{"./shouldupdate":34}],3:[function(_dereq_,module,exports){ +},{"./cached":2,"./shouldupdate":35,"lodash.assign":4}],4:[function(_dereq_,module,exports){ /** * lodash 3.2.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -573,7 +580,7 @@ var assign = createAssigner(function(object, source, customizer) { module.exports = assign; -},{"lodash._baseassign":4,"lodash._createassigner":6,"lodash.keys":10}],4:[function(_dereq_,module,exports){ +},{"lodash._baseassign":5,"lodash._createassigner":7,"lodash.keys":11}],5:[function(_dereq_,module,exports){ /** * lodash 3.2.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -602,7 +609,7 @@ function baseAssign(object, source) { module.exports = baseAssign; -},{"lodash._basecopy":5,"lodash.keys":10}],5:[function(_dereq_,module,exports){ +},{"lodash._basecopy":6,"lodash.keys":11}],6:[function(_dereq_,module,exports){ /** * lodash 3.0.1 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -636,7 +643,7 @@ function baseCopy(source, props, object) { module.exports = baseCopy; -},{}],6:[function(_dereq_,module,exports){ +},{}],7:[function(_dereq_,module,exports){ /** * lodash 3.1.1 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -690,7 +697,7 @@ function createAssigner(assigner) { module.exports = createAssigner; -},{"lodash._bindcallback":7,"lodash._isiterateecall":8,"lodash.restparam":9}],7:[function(_dereq_,module,exports){ +},{"lodash._bindcallback":8,"lodash._isiterateecall":9,"lodash.restparam":10}],8:[function(_dereq_,module,exports){ /** * lodash 3.0.1 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -757,7 +764,7 @@ function identity(value) { module.exports = bindCallback; -},{}],8:[function(_dereq_,module,exports){ +},{}],9:[function(_dereq_,module,exports){ /** * lodash 3.0.9 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -891,7 +898,7 @@ function isObject(value) { module.exports = isIterateeCall; -},{}],9:[function(_dereq_,module,exports){ +},{}],10:[function(_dereq_,module,exports){ /** * lodash 3.6.1 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -960,7 +967,7 @@ function restParam(func, start) { module.exports = restParam; -},{}],10:[function(_dereq_,module,exports){ +},{}],11:[function(_dereq_,module,exports){ /** * lodash 3.1.2 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -1198,7 +1205,7 @@ function keysIn(object) { module.exports = keys; -},{"lodash._getnative":11,"lodash.isarguments":12,"lodash.isarray":13}],11:[function(_dereq_,module,exports){ +},{"lodash._getnative":12,"lodash.isarguments":13,"lodash.isarray":14}],12:[function(_dereq_,module,exports){ /** * lodash 3.9.1 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -1337,7 +1344,7 @@ function isNative(value) { module.exports = getNative; -},{}],12:[function(_dereq_,module,exports){ +},{}],13:[function(_dereq_,module,exports){ /** * lodash 3.0.4 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -1445,7 +1452,7 @@ function isArguments(value) { module.exports = isArguments; -},{}],13:[function(_dereq_,module,exports){ +},{}],14:[function(_dereq_,module,exports){ /** * lodash 3.0.4 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -1627,7 +1634,7 @@ function isNative(value) { module.exports = isArray; -},{}],14:[function(_dereq_,module,exports){ +},{}],15:[function(_dereq_,module,exports){ /** * lodash 3.0.4 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -1691,7 +1698,7 @@ function isEqual(value, other, customizer, thisArg) { module.exports = isEqual; -},{"lodash._baseisequal":15,"lodash._bindcallback":21}],15:[function(_dereq_,module,exports){ +},{"lodash._baseisequal":16,"lodash._bindcallback":22}],16:[function(_dereq_,module,exports){ /** * lodash 3.0.7 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2035,9 +2042,9 @@ function isObject(value) { module.exports = baseIsEqual; -},{"lodash.isarray":16,"lodash.istypedarray":17,"lodash.keys":18}],16:[function(_dereq_,module,exports){ -arguments[4][13][0].apply(exports,arguments) -},{"dup":13}],17:[function(_dereq_,module,exports){ +},{"lodash.isarray":17,"lodash.istypedarray":18,"lodash.keys":19}],17:[function(_dereq_,module,exports){ +arguments[4][14][0].apply(exports,arguments) +},{"dup":14}],18:[function(_dereq_,module,exports){ /** * lodash 3.0.2 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2149,15 +2156,15 @@ function isTypedArray(value) { module.exports = isTypedArray; -},{}],18:[function(_dereq_,module,exports){ -arguments[4][10][0].apply(exports,arguments) -},{"dup":10,"lodash._getnative":19,"lodash.isarguments":20,"lodash.isarray":16}],19:[function(_dereq_,module,exports){ +},{}],19:[function(_dereq_,module,exports){ arguments[4][11][0].apply(exports,arguments) -},{"dup":11}],20:[function(_dereq_,module,exports){ +},{"dup":11,"lodash._getnative":20,"lodash.isarguments":21,"lodash.isarray":17}],20:[function(_dereq_,module,exports){ arguments[4][12][0].apply(exports,arguments) },{"dup":12}],21:[function(_dereq_,module,exports){ -arguments[4][7][0].apply(exports,arguments) -},{"dup":7}],22:[function(_dereq_,module,exports){ +arguments[4][13][0].apply(exports,arguments) +},{"dup":13}],22:[function(_dereq_,module,exports){ +arguments[4][8][0].apply(exports,arguments) +},{"dup":8}],23:[function(_dereq_,module,exports){ /** * lodash 3.1.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2209,7 +2216,7 @@ var pick = restParam(function(object, props) { module.exports = pick; -},{"lodash._baseflatten":23,"lodash._bindcallback":26,"lodash._pickbyarray":27,"lodash._pickbycallback":28,"lodash.restparam":33}],23:[function(_dereq_,module,exports){ +},{"lodash._baseflatten":24,"lodash._bindcallback":27,"lodash._pickbyarray":28,"lodash._pickbycallback":29,"lodash.restparam":34}],24:[function(_dereq_,module,exports){ /** * lodash 3.1.4 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2342,13 +2349,13 @@ function isLength(value) { module.exports = baseFlatten; -},{"lodash.isarguments":24,"lodash.isarray":25}],24:[function(_dereq_,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"dup":12}],25:[function(_dereq_,module,exports){ +},{"lodash.isarguments":25,"lodash.isarray":26}],25:[function(_dereq_,module,exports){ arguments[4][13][0].apply(exports,arguments) },{"dup":13}],26:[function(_dereq_,module,exports){ -arguments[4][7][0].apply(exports,arguments) -},{"dup":7}],27:[function(_dereq_,module,exports){ +arguments[4][14][0].apply(exports,arguments) +},{"dup":14}],27:[function(_dereq_,module,exports){ +arguments[4][8][0].apply(exports,arguments) +},{"dup":8}],28:[function(_dereq_,module,exports){ /** * lodash 3.0.2 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2423,7 +2430,7 @@ function isObject(value) { module.exports = pickByArray; -},{}],28:[function(_dereq_,module,exports){ +},{}],29:[function(_dereq_,module,exports){ /** * lodash 3.0.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2469,7 +2476,7 @@ function pickByCallback(object, predicate) { module.exports = pickByCallback; -},{"lodash._basefor":29,"lodash.keysin":30}],29:[function(_dereq_,module,exports){ +},{"lodash._basefor":30,"lodash.keysin":31}],30:[function(_dereq_,module,exports){ /** * lodash 3.0.2 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2557,7 +2564,7 @@ function isObject(value) { module.exports = baseFor; -},{}],30:[function(_dereq_,module,exports){ +},{}],31:[function(_dereq_,module,exports){ /** * lodash 3.0.8 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` @@ -2691,13 +2698,13 @@ function keysIn(object) { module.exports = keysIn; -},{"lodash.isarguments":31,"lodash.isarray":32}],31:[function(_dereq_,module,exports){ -arguments[4][12][0].apply(exports,arguments) -},{"dup":12}],32:[function(_dereq_,module,exports){ +},{"lodash.isarguments":32,"lodash.isarray":33}],32:[function(_dereq_,module,exports){ arguments[4][13][0].apply(exports,arguments) },{"dup":13}],33:[function(_dereq_,module,exports){ -arguments[4][9][0].apply(exports,arguments) -},{"dup":9}],34:[function(_dereq_,module,exports){ +arguments[4][14][0].apply(exports,arguments) +},{"dup":14}],34:[function(_dereq_,module,exports){ +arguments[4][10][0].apply(exports,arguments) +},{"dup":10}],35:[function(_dereq_,module,exports){ "use strict"; var filter = _dereq_('lodash.pick'), @@ -2735,6 +2742,7 @@ module.exports = factory(); * isEqualState: function (currentState, nextState), // check state * isImmutable: function (currentState, nextState), // check if object is immutable * isEqualProps: function (currentProps, nextProps), // check props + * isIgnorable: function (propertyValue, propertyKey), // check if property item is ignorable * unCursor: function (cursor) // convert from cursor to object * } * ``` @@ -2991,5 +2999,5 @@ function or (fn1, fn2) { }; } -},{"lodash.isequal":14,"lodash.pick":22}]},{},[1])(1) +},{"lodash.isequal":15,"lodash.pick":23}]},{},[1])(1) }); \ No newline at end of file diff --git a/dist/omniscient.min.js b/dist/omniscient.min.js index 4c50d8f..3feb0f9 100644 --- a/dist/omniscient.min.js +++ b/dist/omniscient.min.js @@ -1,5 +1,5 @@ /** -* Omniscient.js v3.2.0 +* Omniscient.js v3.3.0 * Authors: @torgeir,@mikaelbr ***************************************/ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.omniscient=t()}}(function(){return function t(n,r,e){function o(a,i){if(!r[a]){if(!n[a]){var c="function"==typeof require&&require;if(!i&&c)return c(a,!0);if(u)return u(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=r[a]={exports:{}};n[a][0].call(f.exports,function(t){var r=n[a][1][t];return o(r?r:t)},f,f.exports,t,n,r,e)}return r[a].exports}for(var u="function"==typeof require&&require,a=0;a2?r[a-2]:void 0,c=a>2?r[2]:void 0,s=a>1?r[a-1]:void 0;for("function"==typeof i?(i=o(i,s,5),a-=2):(i="function"==typeof s?s:void 0,a-=i?1:0),c&&u(r[0],r[1],c)&&(i=3>a?void 0:i,a=1);++e-1&&t%1==0&&n>t}function a(t,n,r){if(!c(r))return!1;var e=typeof n;if("number"==e?o(r)&&u(n,r.length):"string"==e&&n in r){var a=r[n];return t===t?t===a:a!==a}return!1}function i(t){return"number"==typeof t&&t>-1&&t%1==0&&f>=t}function c(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}var s=/^\d+$/,f=9007199254740991,l=e("length");n.exports=a},{}],9:[function(t,n,r){function e(t,n){if("function"!=typeof t)throw new TypeError(o);return n=u(void 0===n?t.length-1:+n||0,0),function(){for(var r=arguments,e=-1,o=u(r.length-n,0),a=Array(o);++e-1&&t%1==0&&n>t}function a(t){return"number"==typeof t&&t>-1&&t%1==0&&b>=t}function i(t){for(var n=s(t),r=n.length,e=r&&t.length,o=!!e&&a(e)&&(p(t)||l(t)),i=-1,c=[];++i0;++e-1&&t%1==0&&l>=t}function i(t){return e(t)&&u(t)&&s.call(t,"callee")&&!f.call(t,"callee")}var c=Object.prototype,s=c.hasOwnProperty,f=c.propertyIsEnumerable,l=9007199254740991,p=o("length");n.exports=i},{}],13:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){var r=null==t?void 0:t[n];return c(r)?r:void 0}function u(t){return"number"==typeof t&&t>-1&&t%1==0&&g>=t}function a(t){return i(t)&&y.call(t)==f}function i(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function c(t){return null==t?!1:a(t)?v.test(d.call(t)):e(t)&&l.test(t)}var s="[object Array]",f="[object Function]",l=/^\[object .+?Constructor\]$/,p=Object.prototype,d=Function.prototype.toString,h=p.hasOwnProperty,y=p.toString,v=RegExp("^"+d.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),b=o(Array,"isArray"),g=9007199254740991,m=b||function(t){return e(t)&&u(t.length)&&y.call(t)==s};n.exports=m},{}],14:[function(t,n,r){function e(t,n,r,e){r="function"==typeof r?u(r,e,3):void 0;var a=r?r(t,n):void 0;return void 0===a?o(t,n,r):!!a}var o=t("lodash._baseisequal"),u=t("lodash._bindcallback");n.exports=e},{"lodash._baseisequal":15,"lodash._bindcallback":21}],15:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){for(var r=-1,e=t.length;++rs))return!1;for(;++c-1&&t%1==0&&P>=t}function u(t){return e(t)&&o(t.length)&&!!q[U.call(t)]}var a="[object Arguments]",i="[object Array]",c="[object Boolean]",s="[object Date]",f="[object Error]",l="[object Function]",p="[object Map]",d="[object Number]",h="[object Object]",y="[object RegExp]",v="[object Set]",b="[object String]",g="[object WeakMap]",m="[object ArrayBuffer]",j="[object Float32Array]",x="[object Float64Array]",_="[object Int8Array]",w="[object Int16Array]",k="[object Int32Array]",E="[object Uint8Array]",A="[object Uint8ClampedArray]",O="[object Uint16Array]",C="[object Uint32Array]",q={};q[j]=q[x]=q[_]=q[w]=q[k]=q[E]=q[A]=q[O]=q[C]=!0,q[a]=q[i]=q[m]=q[c]=q[s]=q[f]=q[l]=q[p]=q[d]=q[h]=q[y]=q[v]=q[b]=q[g]=!1;var I=Object.prototype,U=I.toString,P=9007199254740991;n.exports=u},{}],18:[function(t,n,r){arguments[4][10][0].apply(r,arguments)},{dup:10,"lodash._getnative":19,"lodash.isarguments":20,"lodash.isarray":16}],19:[function(t,n,r){arguments[4][11][0].apply(r,arguments)},{dup:11}],20:[function(t,n,r){arguments[4][12][0].apply(r,arguments)},{dup:12}],21:[function(t,n,r){arguments[4][7][0].apply(r,arguments)},{dup:7}],22:[function(t,n,r){var e=t("lodash._baseflatten"),o=t("lodash._bindcallback"),u=t("lodash._pickbyarray"),a=t("lodash._pickbycallback"),i=t("lodash.restparam"),c=i(function(t,n){return null==t?{}:"function"==typeof n[0]?a(t,o(n[0],n[1],3)):u(t,e(n))});n.exports=c},{"lodash._baseflatten":23,"lodash._bindcallback":26,"lodash._pickbyarray":27,"lodash._pickbycallback":28,"lodash.restparam":33}],23:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){for(var r=-1,e=n.length,o=t.length;++r-1&&t%1==0&&l>=t}var s=t("lodash.isarguments"),f=t("lodash.isarray"),l=9007199254740991,p=a("length");n.exports=u},{"lodash.isarguments":24,"lodash.isarray":25}],24:[function(t,n,r){arguments[4][12][0].apply(r,arguments)},{dup:12}],25:[function(t,n,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],26:[function(t,n,r){arguments[4][7][0].apply(r,arguments)},{dup:7}],27:[function(t,n,r){function e(t,n){t=o(t);for(var r=-1,e=n.length,u={};++r-1&&t%1==0&&n>t}function o(t){return"number"==typeof t&&t>-1&&t%1==0&&p>=t}function u(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function a(t){if(null==t)return[];u(t)||(t=Object(t));var n=t.length;n=n&&o(n)&&(c(t)||i(t))&&n||0;for(var r=t.constructor,a=-1,s="function"==typeof r&&r.prototype===t,f=Array(n),p=n>0;++a false (equal input)"),!1;if(!j(this.state,n))return b&&b.call(this,"shouldComponentUpdate => true (state has changed)"),!0;var r=d(t,E),e=d(this.props,E);return x(e,r)?(b&&b.call(this,"shouldComponentUpdate => false"),!1):(b&&b.call(this,"shouldComponentUpdate => true (props have changed)"),!0)}function r(t,n){return h(t,n,function(t,n){return t===n?!0:o(t,n,_,u)})}function e(t,n){if(t===n)return!0;var r=o(t,n,g,m);if(void 0!==r)return r;var e=o(t,n,_,u);return void 0!==e?e:h(t,n,function(t,n){if(t===n)return!0;var r=o(t,n,g,m);return void 0!==r?r:o(t,n,_,u)})}function y(t,n){return k(t)===k(n)}function v(t,n){"function"==typeof t&&(n=t,t=void 0);var r=n;!r&&console.debug&&(r=console.debug.bind(console)),!r&&console.info&&(r=console.info.bind(console));var e=new RegExp(t||".*");return b=function(t){var n=this._currentElement;this._reactInternalInstance&&this._reactInternalInstance._currentElement&&(n=this._reactInternalInstance._currentElement);var o=n&&n.key?" key="+n.key:"",u=this.constructor.displayName;o||u||(u="Unknown");var a=u+o;e.test(a)&&r("<"+a+">: "+t)}}var b;t=t||{};var g=t.isCursor||c,m=t.isEqualCursor||y,j=t.isEqualState||r,x=t.isEqualProps||e,_=t.isImmutable||a,w=t.isIgnorable||f,k=t.unCursor||i,E=s(p(w,l));return n.isCursor=g,n.isEqualState=j,n.isEqualProps=x,n.isEqualCursor=m,n.isImmutable=_,n.debug=v,n}function o(t,n,r,e){var o=r(t),u=r(n);return o&&u?e(t,n):o||u?!1:void 0}function u(t,n){return t===n}function a(t){return!(!t||!t[y])}function i(t){return t&&t.deref?t.deref():t}function c(t){return!(!t||"function"!=typeof t.deref)}function s(t){return function(){return!t.apply(t,arguments)}}function f(t,n){return"statics"===n}function l(t,n){return"children"===n}function p(t,n){return function(){return t.apply(null,arguments)||n.apply(null,arguments)}}var d=t("lodash.pick"),h=t("lodash.isequal");n.exports=e(),n.exports.withDefaults=e;var y="@@__IMMUTABLE_ITERABLE__@@"},{"lodash.isequal":14,"lodash.pick":22}]},{},[1])(1)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.omniscient=t()}}(function(){return function t(n,r,e){function o(a,i){if(!r[a]){if(!n[a]){var c="function"==typeof require&&require;if(!i&&c)return c(a,!0);if(u)return u(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=r[a]={exports:{}};n[a][0].call(f.exports,function(t){var r=n[a][1][t];return o(r?r:t)},f,f.exports,t,n,r,e)}return r[a].exports}for(var u="function"==typeof require&&require,a=0;a2?r[a-2]:void 0,c=a>2?r[2]:void 0,s=a>1?r[a-1]:void 0;for("function"==typeof i?(i=o(i,s,5),a-=2):(i="function"==typeof s?s:void 0,a-=i?1:0),c&&u(r[0],r[1],c)&&(i=3>a?void 0:i,a=1);++e-1&&t%1==0&&n>t}function a(t,n,r){if(!c(r))return!1;var e=typeof n;if("number"==e?o(r)&&u(n,r.length):"string"==e&&n in r){var a=r[n];return t===t?t===a:a!==a}return!1}function i(t){return"number"==typeof t&&t>-1&&t%1==0&&f>=t}function c(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}var s=/^\d+$/,f=9007199254740991,l=e("length");n.exports=a},{}],10:[function(t,n,r){function e(t,n){if("function"!=typeof t)throw new TypeError(o);return n=u(void 0===n?t.length-1:+n||0,0),function(){for(var r=arguments,e=-1,o=u(r.length-n,0),a=Array(o);++e-1&&t%1==0&&n>t}function a(t){return"number"==typeof t&&t>-1&&t%1==0&&b>=t}function i(t){for(var n=s(t),r=n.length,e=r&&t.length,o=!!e&&a(e)&&(p(t)||l(t)),i=-1,c=[];++i0;++e-1&&t%1==0&&l>=t}function i(t){return e(t)&&u(t)&&s.call(t,"callee")&&!f.call(t,"callee")}var c=Object.prototype,s=c.hasOwnProperty,f=c.propertyIsEnumerable,l=9007199254740991,p=o("length");n.exports=i},{}],14:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){var r=null==t?void 0:t[n];return c(r)?r:void 0}function u(t){return"number"==typeof t&&t>-1&&t%1==0&&g>=t}function a(t){return i(t)&&y.call(t)==f}function i(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function c(t){return null==t?!1:a(t)?v.test(d.call(t)):e(t)&&l.test(t)}var s="[object Array]",f="[object Function]",l=/^\[object .+?Constructor\]$/,p=Object.prototype,d=Function.prototype.toString,h=p.hasOwnProperty,y=p.toString,v=RegExp("^"+d.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),b=o(Array,"isArray"),g=9007199254740991,m=b||function(t){return e(t)&&u(t.length)&&y.call(t)==s};n.exports=m},{}],15:[function(t,n,r){function e(t,n,r,e){r="function"==typeof r?u(r,e,3):void 0;var a=r?r(t,n):void 0;return void 0===a?o(t,n,r):!!a}var o=t("lodash._baseisequal"),u=t("lodash._bindcallback");n.exports=e},{"lodash._baseisequal":16,"lodash._bindcallback":22}],16:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){for(var r=-1,e=t.length;++rs))return!1;for(;++c-1&&t%1==0&&P>=t}function u(t){return e(t)&&o(t.length)&&!!q[U.call(t)]}var a="[object Arguments]",i="[object Array]",c="[object Boolean]",s="[object Date]",f="[object Error]",l="[object Function]",p="[object Map]",d="[object Number]",h="[object Object]",y="[object RegExp]",v="[object Set]",b="[object String]",g="[object WeakMap]",m="[object ArrayBuffer]",j="[object Float32Array]",x="[object Float64Array]",_="[object Int8Array]",w="[object Int16Array]",k="[object Int32Array]",E="[object Uint8Array]",A="[object Uint8ClampedArray]",O="[object Uint16Array]",C="[object Uint32Array]",q={};q[j]=q[x]=q[_]=q[w]=q[k]=q[E]=q[A]=q[O]=q[C]=!0,q[a]=q[i]=q[m]=q[c]=q[s]=q[f]=q[l]=q[p]=q[d]=q[h]=q[y]=q[v]=q[b]=q[g]=!1;var I=Object.prototype,U=I.toString,P=9007199254740991;n.exports=u},{}],19:[function(t,n,r){arguments[4][11][0].apply(r,arguments)},{dup:11,"lodash._getnative":20,"lodash.isarguments":21,"lodash.isarray":17}],20:[function(t,n,r){arguments[4][12][0].apply(r,arguments)},{dup:12}],21:[function(t,n,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],22:[function(t,n,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],23:[function(t,n,r){var e=t("lodash._baseflatten"),o=t("lodash._bindcallback"),u=t("lodash._pickbyarray"),a=t("lodash._pickbycallback"),i=t("lodash.restparam"),c=i(function(t,n){return null==t?{}:"function"==typeof n[0]?a(t,o(n[0],n[1],3)):u(t,e(n))});n.exports=c},{"lodash._baseflatten":24,"lodash._bindcallback":27,"lodash._pickbyarray":28,"lodash._pickbycallback":29,"lodash.restparam":34}],24:[function(t,n,r){function e(t){return!!t&&"object"==typeof t}function o(t,n){for(var r=-1,e=n.length,o=t.length;++r-1&&t%1==0&&l>=t}var s=t("lodash.isarguments"),f=t("lodash.isarray"),l=9007199254740991,p=a("length");n.exports=u},{"lodash.isarguments":25,"lodash.isarray":26}],25:[function(t,n,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],26:[function(t,n,r){arguments[4][14][0].apply(r,arguments)},{dup:14}],27:[function(t,n,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],28:[function(t,n,r){function e(t,n){t=o(t);for(var r=-1,e=n.length,u={};++r-1&&t%1==0&&n>t}function o(t){return"number"==typeof t&&t>-1&&t%1==0&&p>=t}function u(t){var n=typeof t;return!!t&&("object"==n||"function"==n)}function a(t){if(null==t)return[];u(t)||(t=Object(t));var n=t.length;n=n&&o(n)&&(c(t)||i(t))&&n||0;for(var r=t.constructor,a=-1,s="function"==typeof r&&r.prototype===t,f=Array(n),p=n>0;++a false (equal input)"),!1;if(!j(this.state,n))return b&&b.call(this,"shouldComponentUpdate => true (state has changed)"),!0;var r=d(t,E),e=d(this.props,E);return x(e,r)?(b&&b.call(this,"shouldComponentUpdate => false"),!1):(b&&b.call(this,"shouldComponentUpdate => true (props have changed)"),!0)}function r(t,n){return h(t,n,function(t,n){return t===n?!0:o(t,n,_,u)})}function e(t,n){if(t===n)return!0;var r=o(t,n,g,m);if(void 0!==r)return r;var e=o(t,n,_,u);return void 0!==e?e:h(t,n,function(t,n){if(t===n)return!0;var r=o(t,n,g,m);return void 0!==r?r:o(t,n,_,u)})}function y(t,n){return k(t)===k(n)}function v(t,n){"function"==typeof t&&(n=t,t=void 0);var r=n;!r&&console.debug&&(r=console.debug.bind(console)),!r&&console.info&&(r=console.info.bind(console));var e=new RegExp(t||".*");return b=function(t){var n=this._currentElement;this._reactInternalInstance&&this._reactInternalInstance._currentElement&&(n=this._reactInternalInstance._currentElement);var o=n&&n.key?" key="+n.key:"",u=this.constructor.displayName;o||u||(u="Unknown");var a=u+o;e.test(a)&&r("<"+a+">: "+t)}}var b;t=t||{};var g=t.isCursor||c,m=t.isEqualCursor||y,j=t.isEqualState||r,x=t.isEqualProps||e,_=t.isImmutable||a,w=t.isIgnorable||f,k=t.unCursor||i,E=s(p(w,l));return n.isCursor=g,n.isEqualState=j,n.isEqualProps=x,n.isEqualCursor=m,n.isImmutable=_,n.debug=v,n}function o(t,n,r,e){var o=r(t),u=r(n);return o&&u?e(t,n):o||u?!1:void 0}function u(t,n){return t===n}function a(t){return!(!t||!t[y])}function i(t){return t&&t.deref?t.deref():t}function c(t){return!(!t||"function"!=typeof t.deref)}function s(t){return function(){return!t.apply(t,arguments)}}function f(t,n){return"statics"===n}function l(t,n){return"children"===n}function p(t,n){return function(){return t.apply(null,arguments)||n.apply(null,arguments)}}var d=t("lodash.pick"),h=t("lodash.isequal");n.exports=e(),n.exports.withDefaults=e;var y="@@__IMMUTABLE_ITERABLE__@@"},{"lodash.isequal":15,"lodash.pick":23}]},{},[1])(1)}); \ No newline at end of file diff --git a/package.json b/package.json index 0524eb5..5ffd302 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "omniscient", - "version": "3.2.0", + "version": "3.3.0", "description": "A library providing an abstraction for React components for passing the same data structure through the entire component flow using cursors and immutable data structures.", "main": "index.js", "directories": {