Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-zero

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-zero - npm Package Compare versions

Comparing version 4.9.1 to 4.10.0

8

CHANGELOG.md
# Changelog
### 4.10.0
- Implement connect HOC decorator for preact
### 4.9.2
- Add hot module reloading support to React `connect()` decorator
### 4.9.1

@@ -4,0 +12,0 @@

2

package.json
{
"name": "redux-zero",
"version": "4.9.1",
"version": "4.10.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/redux-zero.js",

import { Component } from "preact";
export default class Connect extends Component<any, {}> {
export declare class Connect extends Component<any, {}> {
unsubscribe: any;

@@ -17,1 +17,23 @@ state: any;

}
export default function connect(mapToProps: any, actions?: {}): (Child: any) => {
new (props?: any, context?: any): {
render(): JSX.Element;
state: {};
props: any;
context: any;
base: HTMLElement;
linkState: (name: string) => (event: Event) => void;
setState<K extends never>(state: Pick<{}, K>, callback?: () => void): void;
setState<K extends never>(fn: (prevState: {}, props: any) => Pick<{}, K>, callback?: () => void): void;
forceUpdate(callback?: () => void): void;
componentWillMount?(): void;
componentDidMount?(): void;
componentWillUnmount?(): void;
componentWillReceiveProps?(nextProps: any, nextContext: any): void;
shouldComponentUpdate?(nextProps: any, nextState: {}, nextContext: any): boolean;
componentWillUpdate?(nextProps: any, nextState: {}, nextContext: any): void;
componentDidUpdate?(previousProps: any, previousState: {}, previousContext: any): void;
};
displayName?: string;
defaultProps?: any;
};

@@ -1,3 +0,3 @@

import Connect from "./components/Connect";
import connect, { Connect } from "./components/Connect";
import Provider from "./components/Provider";
export { Provider, Connect };
export { connect, Provider, Connect };

@@ -117,2 +117,22 @@ 'use strict';

}(preact.Component));
// [ HACK ] to avoid Typechecks
// since there is a small conflict between preact and react typings
// in the future this might become unecessary by updating typings
var ConnectUntyped = Connect;
function connect(mapToProps, actions) {
if (actions === void 0) { actions = {}; }
return function (Child) {
return /** @class */ (function (_super) {
__extends(ConnectWrapper, _super);
function ConnectWrapper() {
return _super !== null && _super.apply(this, arguments) || this;
}
ConnectWrapper.prototype.render = function () {
var props = this.props;
return (preact.h(ConnectUntyped, __assign({}, props, { mapToProps: mapToProps, actions: actions }), function (mappedProps) { return preact.h(Child, __assign({}, mappedProps, props)); }));
};
return ConnectWrapper;
}(preact.Component));
};
}

@@ -133,3 +153,4 @@ var Provider = /** @class */ (function (_super) {

exports.connect = connect;
exports.Provider = Provider;
exports.Connect = Connect;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],e):e(t["redux-zero"]={},t.preact)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function o(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}function r(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}function i(t,e){t="function"==typeof t?t(e):t;var n={};for(var o in t)!function(o){n[o]=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var p=t[o];return"function"==typeof e.middleware?e.middleware(e,p,n):r(e,p.apply(void 0,[e.getState()].concat(n)))}}(o);return n}var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},s=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=e.getProps(),e.actions=e.getActions(),e.update=function(){var t=e.getProps();o(t,e.state)||e.setState(t)},e}return n(e,t),e.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},e.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},e.prototype.getProps=function(){var t=this.props.mapToProps,e=this.context.store&&this.context.store.getState()||{};return t?t(e,this.props):e},e.prototype.getActions=function(){return i(this.props.actions,this.context.store)},e.prototype.render=function(t,e,n){var o=t.children,r=n.store;return o[0](s({store:r},e,this.actions))},e}(e.Component),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getChildContext=function(){return{store:this.props.store}},e.prototype.render=function(){return this.props.children[0]},e}(e.Component);t.Provider=c,t.Connect=u,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(t["redux-zero"]={},t.preact)}(this,function(t,n){"use strict";function e(t,n){function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function o(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}function r(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}function i(t,n){t="function"==typeof t?t(n):t;var e={};for(var o in t)!function(o){e[o]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var u=t[o];return"function"==typeof n.middleware?n.middleware(n,u,e):r(n,u.apply(void 0,[n.getState()].concat(e)))}}(o);return e}var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])},p=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.state=n.getProps(),n.actions=n.getActions(),n.update=function(){var t=n.getProps();o(t,n.state)||n.setState(t)},n}return e(n,t),n.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},n.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},n.prototype.getProps=function(){var t=this.props.mapToProps,n=this.context.store&&this.context.store.getState()||{};return t?t(n,this.props):n},n.prototype.getActions=function(){return i(this.props.actions,this.context.store)},n.prototype.render=function(t,n,e){var o=t.children,r=e.store;return o[0](p({store:r},n,this.actions))},n}(n.Component),c=s,f=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.getChildContext=function(){return{store:this.props.store}},n.prototype.render=function(){return this.props.children[0]},n}(n.Component);t.connect=function(t,o){return void 0===o&&(o={}),function(r){return function(i){function u(){return null!==i&&i.apply(this,arguments)||this}return e(u,i),u.prototype.render=function(){var e=this.props;return n.h(c,p({},e,{mapToProps:t,actions:o}),function(t){return n.h(r,p({},t,e))})},u}(n.Component)}},t.Provider=f,t.Connect=s,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -17,2 +17,23 @@ /// <reference types="react" />

}
export default function connect(mapToProps: any, actions?: {}): (Child: any) => (props: any) => JSX.Element;
export default function connect(mapToProps: any, actions?: {}): (Child: any) => {
new (props?: any, context?: any): {
render(): JSX.Element;
setState<K extends never>(f: (prevState: {}, props: any) => Pick<{}, K>, callback?: () => any): void;
setState<K extends never>(state: Pick<{}, K>, callback?: () => any): void;
forceUpdate(callBack?: () => any): void;
props: any;
state: Readonly<{}>;
context: any;
refs: {
[key: string]: React.ReactInstance;
};
componentWillMount?(): void;
componentDidMount?(): void;
componentWillReceiveProps?(nextProps: any, nextContext: any): void;
shouldComponentUpdate?(nextProps: any, nextState: Readonly<{}>, nextContext: any): boolean;
componentWillUpdate?(nextProps: any, nextState: Readonly<{}>, nextContext: any): void;
componentDidUpdate?(prevProps: any, prevState: Readonly<{}>, prevContext: any): void;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
};
};

@@ -127,3 +127,15 @@ 'use strict';

if (actions === void 0) { actions = {}; }
return function (Child) { return function (props) { return (React.createElement(Connect, __assign({}, props, { mapToProps: mapToProps, actions: actions }), function (mappedProps) { return React.createElement(Child, __assign({}, mappedProps, props)); })); }; };
return function (Child) {
return /** @class */ (function (_super) {
__extends(ConnectWrapper, _super);
function ConnectWrapper() {
return _super !== null && _super.apply(this, arguments) || this;
}
ConnectWrapper.prototype.render = function () {
var props = this.props;
return (React.createElement(Connect, __assign({}, props, { mapToProps: mapToProps, actions: actions }), function (mappedProps) { return React.createElement(Child, __assign({}, mappedProps, props)); }));
};
return ConnectWrapper;
}(React.Component));
};
}

@@ -130,0 +142,0 @@

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t["redux-zero"]={},t.React)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function o(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}function r(t,e,n){return"object"==typeof t?null:new Error("Invalid prop "+e+" supplied to "+n)}function i(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}function s(t,e){t="function"==typeof t?t(e):t;var n={};for(var o in t)!function(o){n[o]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var s=t[o];return"function"==typeof e.middleware?e.middleware(e,s,n):i(e,s.apply(void 0,[e.getState()].concat(n)))}}(o);return n}var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},c=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},p=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=e.getProps(),e.actions=e.getActions(),e.update=function(){var t=e.getProps();o(t,e.state)||e.setState(t)},e}return n(e,t),e.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},e.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},e.prototype.getProps=function(){var t=this.props.mapToProps,e=this.context.store&&this.context.store.getState()||{};return t?t(e,this.props):e},e.prototype.getActions=function(){return s(this.props.actions,this.context.store)},e.prototype.render=function(){return this.props.children(c({store:this.context.store},this.state,this.actions))},e.contextTypes={store:r},e}(e.Component),f=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return n(o,t),o.prototype.getChildContext=function(){return{store:this.props.store}},o.prototype.render=function(){var t=this.props.children;return e.Children.only(t)},o.childContextTypes={store:r},o}(e.Component);t.connect=function(t,n){return void 0===n&&(n={}),function(o){return function(r){return e.createElement(p,c({},r,{mapToProps:t,actions:n}),function(t){return e.createElement(o,c({},t,r))})}}},t.Provider=f,t.Connect=p,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n(t["redux-zero"]={},t.React)}(this,function(t,n){"use strict";function e(t,n){function e(){this.constructor=t}s(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function o(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}function r(t,n,e){return"object"==typeof t?null:new Error("Invalid prop "+n+" supplied to "+e)}function i(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}function p(t,n){t="function"==typeof t?t(n):t;var e={};for(var o in t)!function(o){e[o]=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var p=t[o];return"function"==typeof n.middleware?n.middleware(n,p,e):i(n,p.apply(void 0,[n.getState()].concat(e)))}}(o);return e}var s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])},u=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.state=n.getProps(),n.actions=n.getActions(),n.update=function(){var t=n.getProps();o(t,n.state)||n.setState(t)},n}return e(n,t),n.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},n.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},n.prototype.getProps=function(){var t=this.props.mapToProps,n=this.context.store&&this.context.store.getState()||{};return t?t(n,this.props):n},n.prototype.getActions=function(){return p(this.props.actions,this.context.store)},n.prototype.render=function(){return this.props.children(u({store:this.context.store},this.state,this.actions))},n.contextTypes={store:r},n}(n.Component),f=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return e(o,t),o.prototype.getChildContext=function(){return{store:this.props.store}},o.prototype.render=function(){var t=this.props.children;return n.Children.only(t)},o.childContextTypes={store:r},o}(n.Component);t.connect=function(t,o){return void 0===o&&(o={}),function(r){return function(i){function p(){return null!==i&&i.apply(this,arguments)||this}return e(p,i),p.prototype.render=function(){var e=this.props;return n.createElement(c,u({},e,{mapToProps:t,actions:o}),function(t){return n.createElement(r,u({},t,e))})},p}(n.Component)}},t.Provider=f,t.Connect=c,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -160,2 +160,3 @@ <h1 align="center">

- [React](https://github.com/concretesolutions/redux-zero/tree/master/examples/react/counter)
- [React-Router](https://github.com/concretesolutions/redux-zero/tree/master/examples/react/react-router)
- [Preact](https://github.com/concretesolutions/redux-zero/tree/master/examples/preact/counter)

@@ -162,0 +163,0 @@ - [React Native](https://github.com/concretesolutions/redux-zero/tree/master/examples/react-native/counter)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc