WIP - add extractor, generate snippet_data
This commit is contained in:
108
node_modules/react-side-effect/lib/index.es.js
generated
vendored
Normal file
108
node_modules/react-side-effect/lib/index.es.js
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
import React, { Component } from 'react';
|
||||
import ExecutionEnvironment from 'exenv';
|
||||
import shallowEqual from 'shallowequal';
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
function withSideEffect(reducePropsToState, handleStateChangeOnClient, mapStateOnServer) {
|
||||
if (typeof reducePropsToState !== 'function') {
|
||||
throw new Error('Expected reducePropsToState to be a function.');
|
||||
}
|
||||
if (typeof handleStateChangeOnClient !== 'function') {
|
||||
throw new Error('Expected handleStateChangeOnClient to be a function.');
|
||||
}
|
||||
if (typeof mapStateOnServer !== 'undefined' && typeof mapStateOnServer !== 'function') {
|
||||
throw new Error('Expected mapStateOnServer to either be undefined or a function.');
|
||||
}
|
||||
|
||||
function getDisplayName(WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
}
|
||||
|
||||
return function wrap(WrappedComponent) {
|
||||
if (typeof WrappedComponent !== 'function') {
|
||||
throw new Error('Expected WrappedComponent to be a React component.');
|
||||
}
|
||||
|
||||
var mountedInstances = [];
|
||||
var state = void 0;
|
||||
|
||||
function emitChange() {
|
||||
state = reducePropsToState(mountedInstances.map(function (instance) {
|
||||
return instance.props;
|
||||
}));
|
||||
|
||||
if (SideEffect.canUseDOM) {
|
||||
handleStateChangeOnClient(state);
|
||||
} else if (mapStateOnServer) {
|
||||
state = mapStateOnServer(state);
|
||||
}
|
||||
}
|
||||
|
||||
var SideEffect = function (_Component) {
|
||||
_inherits(SideEffect, _Component);
|
||||
|
||||
function SideEffect() {
|
||||
_classCallCheck(this, SideEffect);
|
||||
|
||||
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
// Try to use displayName of wrapped component
|
||||
SideEffect.peek = function peek() {
|
||||
return state;
|
||||
};
|
||||
|
||||
// Expose canUseDOM so tests can monkeypatch it
|
||||
|
||||
|
||||
SideEffect.rewind = function rewind() {
|
||||
if (SideEffect.canUseDOM) {
|
||||
throw new Error('You may only call rewind() on the server. Call peek() to read the current state.');
|
||||
}
|
||||
|
||||
var recordedState = state;
|
||||
state = undefined;
|
||||
mountedInstances = [];
|
||||
return recordedState;
|
||||
};
|
||||
|
||||
SideEffect.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
||||
return !shallowEqual(nextProps, this.props);
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillMount = function componentWillMount() {
|
||||
mountedInstances.push(this);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentDidUpdate = function componentDidUpdate() {
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var index = mountedInstances.indexOf(this);
|
||||
mountedInstances.splice(index, 1);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.render = function render() {
|
||||
return React.createElement(WrappedComponent, this.props);
|
||||
};
|
||||
|
||||
return SideEffect;
|
||||
}(Component);
|
||||
|
||||
SideEffect.displayName = 'SideEffect(' + getDisplayName(WrappedComponent) + ')';
|
||||
SideEffect.canUseDOM = ExecutionEnvironment.canUseDOM;
|
||||
|
||||
|
||||
return SideEffect;
|
||||
};
|
||||
}
|
||||
|
||||
export default withSideEffect;
|
||||
113
node_modules/react-side-effect/lib/index.js
generated
vendored
Normal file
113
node_modules/react-side-effect/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var React = require('react');
|
||||
var React__default = _interopDefault(React);
|
||||
var ExecutionEnvironment = _interopDefault(require('exenv'));
|
||||
var shallowEqual = _interopDefault(require('shallowequal'));
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
function withSideEffect(reducePropsToState, handleStateChangeOnClient, mapStateOnServer) {
|
||||
if (typeof reducePropsToState !== 'function') {
|
||||
throw new Error('Expected reducePropsToState to be a function.');
|
||||
}
|
||||
if (typeof handleStateChangeOnClient !== 'function') {
|
||||
throw new Error('Expected handleStateChangeOnClient to be a function.');
|
||||
}
|
||||
if (typeof mapStateOnServer !== 'undefined' && typeof mapStateOnServer !== 'function') {
|
||||
throw new Error('Expected mapStateOnServer to either be undefined or a function.');
|
||||
}
|
||||
|
||||
function getDisplayName(WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
}
|
||||
|
||||
return function wrap(WrappedComponent) {
|
||||
if (typeof WrappedComponent !== 'function') {
|
||||
throw new Error('Expected WrappedComponent to be a React component.');
|
||||
}
|
||||
|
||||
var mountedInstances = [];
|
||||
var state = void 0;
|
||||
|
||||
function emitChange() {
|
||||
state = reducePropsToState(mountedInstances.map(function (instance) {
|
||||
return instance.props;
|
||||
}));
|
||||
|
||||
if (SideEffect.canUseDOM) {
|
||||
handleStateChangeOnClient(state);
|
||||
} else if (mapStateOnServer) {
|
||||
state = mapStateOnServer(state);
|
||||
}
|
||||
}
|
||||
|
||||
var SideEffect = function (_Component) {
|
||||
_inherits(SideEffect, _Component);
|
||||
|
||||
function SideEffect() {
|
||||
_classCallCheck(this, SideEffect);
|
||||
|
||||
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
// Try to use displayName of wrapped component
|
||||
SideEffect.peek = function peek() {
|
||||
return state;
|
||||
};
|
||||
|
||||
// Expose canUseDOM so tests can monkeypatch it
|
||||
|
||||
|
||||
SideEffect.rewind = function rewind() {
|
||||
if (SideEffect.canUseDOM) {
|
||||
throw new Error('You may only call rewind() on the server. Call peek() to read the current state.');
|
||||
}
|
||||
|
||||
var recordedState = state;
|
||||
state = undefined;
|
||||
mountedInstances = [];
|
||||
return recordedState;
|
||||
};
|
||||
|
||||
SideEffect.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
||||
return !shallowEqual(nextProps, this.props);
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillMount = function componentWillMount() {
|
||||
mountedInstances.push(this);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentDidUpdate = function componentDidUpdate() {
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var index = mountedInstances.indexOf(this);
|
||||
mountedInstances.splice(index, 1);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.render = function render() {
|
||||
return React__default.createElement(WrappedComponent, this.props);
|
||||
};
|
||||
|
||||
return SideEffect;
|
||||
}(React.Component);
|
||||
|
||||
SideEffect.displayName = 'SideEffect(' + getDisplayName(WrappedComponent) + ')';
|
||||
SideEffect.canUseDOM = ExecutionEnvironment.canUseDOM;
|
||||
|
||||
|
||||
return SideEffect;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = withSideEffect;
|
||||
211
node_modules/react-side-effect/lib/index.umd.js
generated
vendored
Normal file
211
node_modules/react-side-effect/lib/index.umd.js
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
|
||||
typeof define === 'function' && define.amd ? define(['react'], factory) :
|
||||
(global.withSideEffect = factory(global.React));
|
||||
}(this, (function (React) { 'use strict';
|
||||
|
||||
var React__default = 'default' in React ? React['default'] : React;
|
||||
|
||||
function createCommonjsModule(fn, module) {
|
||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||
}
|
||||
|
||||
var exenv = createCommonjsModule(function (module) {
|
||||
/*!
|
||||
Copyright (c) 2015 Jed Watson.
|
||||
Based on code that is Copyright 2013-2015, Facebook, Inc.
|
||||
All rights reserved.
|
||||
*/
|
||||
/* global define */
|
||||
|
||||
(function () {
|
||||
|
||||
var canUseDOM = !!(
|
||||
typeof window !== 'undefined' &&
|
||||
window.document &&
|
||||
window.document.createElement
|
||||
);
|
||||
|
||||
var ExecutionEnvironment = {
|
||||
|
||||
canUseDOM: canUseDOM,
|
||||
|
||||
canUseWorkers: typeof Worker !== 'undefined',
|
||||
|
||||
canUseEventListeners:
|
||||
canUseDOM && !!(window.addEventListener || window.attachEvent),
|
||||
|
||||
canUseViewport: canUseDOM && !!window.screen
|
||||
|
||||
};
|
||||
|
||||
if (typeof undefined === 'function' && typeof undefined.amd === 'object' && undefined.amd) {
|
||||
undefined(function () {
|
||||
return ExecutionEnvironment;
|
||||
});
|
||||
} else if ('object' !== 'undefined' && module.exports) {
|
||||
module.exports = ExecutionEnvironment;
|
||||
} else {
|
||||
window.ExecutionEnvironment = ExecutionEnvironment;
|
||||
}
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
||||
|
||||
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
|
||||
|
||||
if(ret !== void 0) {
|
||||
return !!ret;
|
||||
}
|
||||
|
||||
if(objA === objB) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(typeof objA !== 'object' || !objA ||
|
||||
typeof objB !== 'object' || !objB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = Object.keys(objA);
|
||||
var keysB = Object.keys(objB);
|
||||
|
||||
if(keysA.length !== keysB.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
||||
|
||||
// Test for A's keys different from B.
|
||||
for(var idx = 0; idx < keysA.length; idx++) {
|
||||
|
||||
var key = keysA[idx];
|
||||
|
||||
if(!bHasOwnProperty(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var valueA = objA[key];
|
||||
var valueB = objB[key];
|
||||
|
||||
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
|
||||
|
||||
if(ret === false ||
|
||||
ret === void 0 && valueA !== valueB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
function withSideEffect(reducePropsToState, handleStateChangeOnClient, mapStateOnServer) {
|
||||
if (typeof reducePropsToState !== 'function') {
|
||||
throw new Error('Expected reducePropsToState to be a function.');
|
||||
}
|
||||
if (typeof handleStateChangeOnClient !== 'function') {
|
||||
throw new Error('Expected handleStateChangeOnClient to be a function.');
|
||||
}
|
||||
if (typeof mapStateOnServer !== 'undefined' && typeof mapStateOnServer !== 'function') {
|
||||
throw new Error('Expected mapStateOnServer to either be undefined or a function.');
|
||||
}
|
||||
|
||||
function getDisplayName(WrappedComponent) {
|
||||
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
}
|
||||
|
||||
return function wrap(WrappedComponent) {
|
||||
if (typeof WrappedComponent !== 'function') {
|
||||
throw new Error('Expected WrappedComponent to be a React component.');
|
||||
}
|
||||
|
||||
var mountedInstances = [];
|
||||
var state = void 0;
|
||||
|
||||
function emitChange() {
|
||||
state = reducePropsToState(mountedInstances.map(function (instance) {
|
||||
return instance.props;
|
||||
}));
|
||||
|
||||
if (SideEffect.canUseDOM) {
|
||||
handleStateChangeOnClient(state);
|
||||
} else if (mapStateOnServer) {
|
||||
state = mapStateOnServer(state);
|
||||
}
|
||||
}
|
||||
|
||||
var SideEffect = function (_Component) {
|
||||
_inherits(SideEffect, _Component);
|
||||
|
||||
function SideEffect() {
|
||||
_classCallCheck(this, SideEffect);
|
||||
|
||||
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
// Try to use displayName of wrapped component
|
||||
SideEffect.peek = function peek() {
|
||||
return state;
|
||||
};
|
||||
|
||||
// Expose canUseDOM so tests can monkeypatch it
|
||||
|
||||
|
||||
SideEffect.rewind = function rewind() {
|
||||
if (SideEffect.canUseDOM) {
|
||||
throw new Error('You may only call rewind() on the server. Call peek() to read the current state.');
|
||||
}
|
||||
|
||||
var recordedState = state;
|
||||
state = undefined;
|
||||
mountedInstances = [];
|
||||
return recordedState;
|
||||
};
|
||||
|
||||
SideEffect.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
||||
return !shallowequal(nextProps, this.props);
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillMount = function componentWillMount() {
|
||||
mountedInstances.push(this);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentDidUpdate = function componentDidUpdate() {
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
var index = mountedInstances.indexOf(this);
|
||||
mountedInstances.splice(index, 1);
|
||||
emitChange();
|
||||
};
|
||||
|
||||
SideEffect.prototype.render = function render() {
|
||||
return React__default.createElement(WrappedComponent, this.props);
|
||||
};
|
||||
|
||||
return SideEffect;
|
||||
}(React.Component);
|
||||
|
||||
SideEffect.displayName = 'SideEffect(' + getDisplayName(WrappedComponent) + ')';
|
||||
SideEffect.canUseDOM = exenv.canUseDOM;
|
||||
|
||||
|
||||
return SideEffect;
|
||||
};
|
||||
}
|
||||
|
||||
return withSideEffect;
|
||||
|
||||
})));
|
||||
1
node_modules/react-side-effect/lib/index.umd.min.js
generated
vendored
Normal file
1
node_modules/react-side-effect/lib/index.umd.min.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):e.withSideEffect=t(e.React)}(this,function(e){"use strict";var t="default"in e?e.default:e;var n,o=(function(e){var t,n;t=!("undefined"==typeof window||!window.document||!window.document.createElement),n={canUseDOM:t,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:t&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:t&&!!window.screen},e.exports?e.exports=n:window.ExecutionEnvironment=n}(n={exports:{}},n.exports),n.exports),r=function(e,t,n,o){var r=n?n.call(o,e,t):void 0;if(void 0!==r)return!!r;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),c=Object.keys(t);if(i.length!==c.length)return!1;for(var f=Object.prototype.hasOwnProperty.bind(t),p=0;p<i.length;p++){var u=i[p];if(!f(u))return!1;var a=e[u],s=t[u];if(!1===(r=n?n.call(o,a,s,u):void 0)||void 0===r&&a!==s)return!1}return!0};return function(n,i,c){if("function"!=typeof n)throw new Error("Expected reducePropsToState to be a function.");if("function"!=typeof i)throw new Error("Expected handleStateChangeOnClient to be a function.");if(void 0!==c&&"function"!=typeof c)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(f){if("function"!=typeof f)throw new Error("Expected WrappedComponent to be a React component.");var p=[],u=void 0;function a(){u=n(p.map(function(e){return e.props})),s.canUseDOM?i(u):c&&(u=c(u))}var s=function(e){function n(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(n,e),n.peek=function(){return u},n.rewind=function(){if(n.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var e=u;return u=void 0,p=[],e},n.prototype.shouldComponentUpdate=function(e){return!r(e,this.props)},n.prototype.componentWillMount=function(){p.push(this),a()},n.prototype.componentDidUpdate=function(){a()},n.prototype.componentWillUnmount=function(){var e=p.indexOf(this);p.splice(e,1),a()},n.prototype.render=function(){return t.createElement(f,this.props)},n}(e.Component);return s.displayName="SideEffect("+function(e){return e.displayName||e.name||"Component"}(f)+")",s.canUseDOM=o.canUseDOM,s}}});
|
||||
Reference in New Issue
Block a user