Skip to content

Commit

Permalink
Fixed vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van der Heijden committed Jun 5, 2019
1 parent e87f9d5 commit 7ad5875
Show file tree
Hide file tree
Showing 8 changed files with 955 additions and 2,095 deletions.
10 changes: 5 additions & 5 deletions lib/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function () {
function Actions(names) {
var _this = this;

(0, _classCallCheck2.default)(this, Actions);
(0, _classCallCheck2["default"])(this, Actions);
this._callbacks = names.reduce(function (o, action) {
typeof action !== 'string' || !action.length || action.charAt(0) === '_' ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Cannot use action `%s`. Each action must be a sting with at least one character and cannot start with an underscore.', action) : (0, _invariant.default)(false) : undefined;
_this.hasOwnProperty(action) ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Action `%s` is already set (duplicate actions are not allowed).', action) : (0, _invariant.default)(false) : undefined;
typeof action !== 'string' || !action.length || action.charAt(0) === '_' ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Cannot use action `%s`. Each action must be a sting with at least one character and cannot start with an underscore.', action) : (0, _invariant["default"])(false) : undefined;
_this.hasOwnProperty(action) ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Action `%s` is already set (duplicate actions are not allowed).', action) : (0, _invariant["default"])(false) : undefined;
var onKey = "on".concat(action.charAt(0).toUpperCase()).concat(action.substr(1));

_this[action] = function () {
Expand All @@ -43,11 +43,11 @@ function () {
}, {});
}

(0, _createClass2.default)(Actions, [{
(0, _createClass2["default"])(Actions, [{
key: "_on",
value: function _on(onKey, payload) {
this._callbacks[onKey].forEach(function (cb) {
return cb.apply(void 0, (0, _toConsumableArray2.default)(payload));
return cb.apply(void 0, (0, _toConsumableArray2["default"])(payload));
});
}
}, {
Expand Down
46 changes: 23 additions & 23 deletions lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports["default"] = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

Expand All @@ -30,40 +30,40 @@ var ComponentFactory = function ComponentFactory(SuperClass) {
var Component =
/*#__PURE__*/
function (_SuperClass) {
(0, _inherits2.default)(Component, _SuperClass);
(0, _inherits2["default"])(Component, _SuperClass);

function Component(props) {
var _this;

(0, _classCallCheck2.default)(this, Component);
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Component).call(this, props));
(0, _classCallCheck2["default"])(this, Component);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Component).call(this, props));
_this._vlowStores_ = {};
_this._vlowState_ = _states.default.init;
_this._vlowState_ = _states["default"].init;
_this._vlowTmpState = null;
return _this;
}

(0, _createClass2.default)(Component, [{
(0, _createClass2["default"])(Component, [{
key: "_vlowRegisterStore_",
value: function _vlowRegisterStore_(store) {
this._vlowState_ !== _states.default.init ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Component `%s` is trying to register a store outside the constructor.', this.constructor.name) : (0, _invariant.default)(false) : undefined; // Debug only valid props
this._vlowState_ !== _states["default"].init ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Component `%s` is trying to register a store outside the constructor.', this.constructor.name) : (0, _invariant["default"])(false) : undefined; // Debug only valid props

if (process.env.NODE_ENV !== 'production') {
(0, _invariant.default)(store.constructor !== Array, 'Component `%s` is registering a store using an Array, most likely you are using `.mapStore()` instead of `.mapStores()`.', this.constructor.name);
(0, _invariant["default"])(store.constructor !== Array, 'Component `%s` is registering a store using an Array, most likely you are using `.mapStore()` instead of `.mapStores()`.', this.constructor.name);

if (typeof store !== 'function') {
var invalidProps = Object.keys(store).filter(function (k) {
return k !== 'store' && k !== 'keys' && k !== 'altState';
});
(0, _invariant.default)(!invalidProps.length, 'Component `%s` is registering a store using invalid properties: `%s` (only `store`, `keys` and `altState` are allowed).', this.constructor.name, invalidProps);
(0, _invariant["default"])(!invalidProps.length, 'Component `%s` is registering a store using invalid properties: `%s` (only `store`, `keys` and `altState` are allowed).', this.constructor.name, invalidProps);
}
} // End debug


var keys = store.keys;
var altState = store.altState;
keys && altState ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Component `%s` is registering a store using both `keys` and `altState` but they cannot be used at the same time.', this.constructor.name) : (0, _invariant.default)(false) : undefined;
store = _store.default._vlowGetOrCreateStore(typeof store === 'function' ? store : store.store);
keys && altState ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Component `%s` is registering a store using both `keys` and `altState` but they cannot be used at the same time.', this.constructor.name) : (0, _invariant["default"])(false) : undefined;
store = _store["default"]._vlowGetOrCreateStore(typeof store === 'function' ? store : store.store);

var id = store._vlowAddListener(this, keys, altState);

Expand All @@ -73,7 +73,7 @@ var ComponentFactory = function ComponentFactory(SuperClass) {
}, {
key: "mapStore",
value: function mapStore(store) {
this._vlowTmpState !== null ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Component `%s` must only make one call to either `.mapStore()` or `.mapStores()`.', this.constructor.name) : (0, _invariant.default)(false) : undefined;
this._vlowTmpState !== null ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Component `%s` must only make one call to either `.mapStore()` or `.mapStores()`.', this.constructor.name) : (0, _invariant["default"])(false) : undefined;

this._vlowRegisterStore_(store);
}
Expand All @@ -82,25 +82,25 @@ var ComponentFactory = function ComponentFactory(SuperClass) {
value: function mapStores(stores) {
var _this2 = this;

this._vlowTmpState !== null ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Component `%s` must only make one call to either `.mapStore()` or `.mapStores()`.', this.constructor.name) : (0, _invariant.default)(false) : undefined;
stores.constructor !== Array ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Function `.mapStores()` on Component `%s` is expecting an Array got got `%s`.', this.constructor.name, stores) : (0, _invariant.default)(false) : undefined;
this._vlowTmpState !== null ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Component `%s` must only make one call to either `.mapStore()` or `.mapStores()`.', this.constructor.name) : (0, _invariant["default"])(false) : undefined;
stores.constructor !== Array ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Function `.mapStores()` on Component `%s` is expecting an Array got got `%s`.', this.constructor.name, stores) : (0, _invariant["default"])(false) : undefined;
stores.forEach(function (s) {
return _this2._vlowRegisterStore_(s);
});
}
}, {
key: "componentWillMount",
value: function componentWillMount() {
this._vlowState_ = _states.default.ready;
!!this._vlowTmpState && this._vlowTmpState !== this.state ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Component `%s` state has been overwritten after registering a store.', this.constructor.name) : (0, _invariant.default)(false) : undefined;
this._vlowState_ = _states["default"].ready;
!!this._vlowTmpState && this._vlowTmpState !== this.state ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Component `%s` state has been overwritten after registering a store.', this.constructor.name) : (0, _invariant["default"])(false) : undefined;
delete this._vlowTmpState;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var _this3 = this;

this._vlowState_ = _states.default.stop;
this._vlowState_ = _states["default"].stop;
Object.keys(this._vlowStores_).forEach(function (id) {
return _this3._vlowStores_[id]._vlowRemoveListener(id);
});
Expand All @@ -115,21 +115,21 @@ var ComponentFactory = function ComponentFactory(SuperClass) {
var Component =
/*#__PURE__*/
function (_ComponentFactory) {
(0, _inherits2.default)(Component, _ComponentFactory);
(0, _inherits2["default"])(Component, _ComponentFactory);

function Component() {
(0, _classCallCheck2.default)(this, Component);
return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Component).apply(this, arguments));
(0, _classCallCheck2["default"])(this, Component);
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Component).apply(this, arguments));
}

(0, _createClass2.default)(Component, null, [{
(0, _createClass2["default"])(Component, null, [{
key: "extend",
value: function extend(SuperClass) {
return ComponentFactory(SuperClass);
}
}]);
return Component;
}(ComponentFactory(_react.default.Component));
}(ComponentFactory(_react["default"].Component));

var _default = Component;
exports.default = _default;
exports["default"] = _default;
16 changes: 8 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "Store", {
enumerable: true,
get: function get() {
return _store.default;
return _store["default"];
}
});
Object.defineProperty(exports, "Component", {
enumerable: true,
get: function get() {
return _component.default;
return _component["default"];
}
});
Object.defineProperty(exports, "createActions", {
Expand All @@ -26,10 +26,10 @@ Object.defineProperty(exports, "createActions", {
Object.defineProperty(exports, "withVlow", {
enumerable: true,
get: function get() {
return _withVlow.default;
return _withVlow["default"];
}
});
exports.default = void 0;
exports["default"] = void 0;

var _store = _interopRequireDefault(require("./store"));

Expand Down Expand Up @@ -63,9 +63,9 @@ var _withVlow = _interopRequireDefault(require("./withVlow"));
var Vlow = {
version: '1.1.4'
};
Vlow.Store = _store.default;
Vlow.Component = _component.default;
Vlow.Store = _store["default"];
Vlow.Component = _component["default"];
Vlow.createActions = _actions.createActions;
Vlow.withVlow = _withVlow.default;
Vlow.withVlow = _withVlow["default"];
var _default = Vlow;
exports.default = _default;
exports["default"] = _default;
4 changes: 2 additions & 2 deletions lib/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports["default"] = void 0;
var States = {
init: 0,
// Component is being constructed.
Expand All @@ -13,4 +13,4 @@ var States = {

};
var _default = States;
exports.default = _default;
exports["default"] = _default;
24 changes: 12 additions & 12 deletions lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

Expand All @@ -28,7 +28,7 @@ function () {
function Store() {
var _this = this;

(0, _classCallCheck2.default)(this, Store);
(0, _classCallCheck2["default"])(this, Store);
this._vlowLastId_ = 0;
this._vlowListeners_ = {};
this.state = this.state || {}; // ensure state, may be overwritten in SubClass constructor
Expand All @@ -42,7 +42,7 @@ function () {
});
}

(0, _createClass2.default)(Store, [{
(0, _createClass2["default"])(Store, [{
key: "setState",
value: function setState(newState, cb) {
var _this2 = this;
Expand All @@ -53,7 +53,7 @@ function () {
} // update local state, this is not a real component so we can update the state immediately.


this.state = (0, _extends2.default)(this.state, newState); // get listeners
this.state = (0, _extends2["default"])(this.state, newState); // get listeners

var listeners = Object.values(this._vlowListeners_); // counter is used only when a callback argument is used

Expand Down Expand Up @@ -90,16 +90,16 @@ function () {

if (Object.keys(state).length) {
switch (component._vlowState_) {
case _states.default.init:
counter ? process.env.NODE_ENV !== 'production' ? (0, _invariant.default)(false, 'Store `%s` is using `setState()` with a callback on component `%s` which is not yet mounted. This is not possible, make sure all components are mounted or remove the callback from setState.', this.constructor.name, component.constructor.name) : (0, _invariant.default)(false) : undefined;
component.state = (0, _extends2.default)(component.state || {}, state);
case _states["default"].init:
counter ? process.env.NODE_ENV !== 'production' ? (0, _invariant["default"])(false, 'Store `%s` is using `setState()` with a callback on component `%s` which is not yet mounted. This is not possible, make sure all components are mounted or remove the callback from setState.', this.constructor.name, component.constructor.name) : (0, _invariant["default"])(false) : undefined;
component.state = (0, _extends2["default"])(component.state || {}, state);
break;

case _states.default.ready:
case _states["default"].ready:
component.setState(state, counter);
break;

case _states.default.stop:
case _states["default"].stop:
counter && counter.i--;
break;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ function () {
key: "_vlowGetOrCreateStore",
value: function _vlowGetOrCreateStore(StoreClass) {
var storeMap = _stores.find(function (m) {
return m.class === StoreClass;
return m["class"] === StoreClass;
});

if (storeMap) {
Expand All @@ -159,7 +159,7 @@ function () {
var store = new StoreClass();

_stores.push({
class: StoreClass,
"class": StoreClass,
store: store
});

Expand All @@ -170,4 +170,4 @@ function () {
}();

var _default = Store;
exports.default = _default;
exports["default"] = _default;
16 changes: 8 additions & 8 deletions lib/withVlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

Expand Down Expand Up @@ -33,29 +33,29 @@ var withVlow = function withVlow(stores, WrappedComponent) {
var WithVlow =
/*#__PURE__*/
function (_Component) {
(0, _inherits2.default)(WithVlow, _Component);
(0, _inherits2["default"])(WithVlow, _Component);

function WithVlow(props) {
var _this;

(0, _classCallCheck2.default)(this, WithVlow);
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(WithVlow).call(this, props));
(0, _classCallCheck2["default"])(this, WithVlow);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(WithVlow).call(this, props));
Array.isArray(stores) ? _this.mapStores(stores) : _this.mapStore(stores);
return _this;
}

(0, _createClass2.default)(WithVlow, [{
(0, _createClass2["default"])(WithVlow, [{
key: "render",
value: function render() {
return _react.default.createElement(WrappedComponent, (0, _extends2.default)({}, this.state, this.props), null);
return _react["default"].createElement(WrappedComponent, (0, _extends2["default"])({}, this.state, this.props), null);
}
}]);
return WithVlow;
}(_component.default);
}(_component["default"]);

WithVlow.displayName = "WithVlow()(".concat(WrappedComponent.displayName || WrappedComponent.name || 'Component', ")");
return WithVlow;
};

var _default = withVlow;
exports.default = _default;
exports["default"] = _default;
Loading

0 comments on commit 7ad5875

Please sign in to comment.