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

refract-preact-xstream

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refract-preact-xstream - npm Package Compare versions

Comparing version 2.0.0-rc.0 to 2.0.0-rc.1

91

index.es.js

@@ -30,2 +30,10 @@ import xs from 'xstream';

var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
var PROPS_EFFECT = '@@refract/effect/props';

@@ -66,5 +74,12 @@ var toProps = function (props) { return ({

var shallowEquals = function (left, right) {
return left === right ||
(Object.keys(left).length === Object.keys(right).length &&
Object.keys(left).every(function (leftKey) { return left[leftKey] === right[leftKey]; }));
};
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement) {
instance.state = {
children: null
children: null,
props: {},
decoratedProps: {}
};

@@ -92,21 +107,16 @@ var setState = function (state) {

var payload_1 = effect.payload;
if (payload_1.replace) {
setState({
replace: payload_1.replace,
props: Object.keys(payload_1.props || {}).reduce(function (props, propName) {
var prop = payload_1.props[propName];
if (propName !== 'children' &&
typeof prop === 'function') {
decorateProp(props, prop, propName);
}
else {
props[propName] = prop;
}
return props;
}, {})
});
}
else {
setState(payload_1);
}
setState({
replace: payload_1.replace,
props: payload_1.props,
decoratedProps: Object.keys(payload_1.props || {}).reduce(function (props, propName) {
var prop = payload_1.props[propName];
var previousProp = instance.state.props[propName];
if (propName !== 'children' &&
typeof prop === 'function' &&
prop !== previousProp) {
decorateProp(props, prop, propName);
}
return props;
}, {})
});
}

@@ -209,3 +219,4 @@ else {

Object.keys(nextProps).forEach(function (propName) {
if (typeof instance.props[propName] === 'function' &&
if (propName !== 'children' &&
typeof instance.props[propName] === 'function' &&
nextProps[propName] !== instance.props[propName]) {

@@ -227,17 +238,28 @@ decorateProp(decoratedProps, nextProps[propName], propName);

instance.getChildProps = function () {
var _a = instance.state, _b = _a.props, props = _b === void 0 ? {} : _b, replace = _a.replace;
if (replace === true) {
return Object.assign({}, props, {
pushEvent: pushEvent
});
var state = instance.state;
var stateProps = __assign({}, state.props, state.decoratedProps);
if (state.replace === true) {
return __assign({}, stateProps, { pushEvent: pushEvent });
}
else if (replace === false) {
return Object.assign({}, instance.props, decoratedProps, props, {
pushEvent: pushEvent
});
var componentProps = __assign({}, instance.props, decoratedProps, { pushEvent: pushEvent });
if (state.replace === false) {
return __assign({}, componentProps, stateProps);
}
return Object.assign({}, instance.props, decoratedProps, {
pushEvent: pushEvent
});
return componentProps;
};
instance.havePropsChanged = function (newProps, newState) {
var state = instance.state;
if (state.children) {
return state.children !== newState.children;
}
var haveStatePropsChanged = !shallowEquals(state.props, newState.props);
if (newState.replace === true) {
return haveStatePropsChanged;
}
var havePropsChanged = !shallowEquals(instance.props, newProps);
if (newState.replace === false) {
return havePropsChanged || haveStatePropsChanged;
}
return havePropsChanged;
};
}; };

@@ -272,2 +294,5 @@

};
WithEffects.prototype.shouldComponentUpdate = function (nextProps, nextState) {
return this.havePropsChanged(nextProps, nextState);
};
WithEffects.prototype.componentDidUpdate = function (prevProps) {

@@ -274,0 +299,0 @@ this.pushProps(prevProps);

@@ -36,2 +36,10 @@ 'use strict';

var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
var PROPS_EFFECT = '@@refract/effect/props';

@@ -72,5 +80,12 @@ var toProps = function (props) { return ({

var shallowEquals = function (left, right) {
return left === right ||
(Object.keys(left).length === Object.keys(right).length &&
Object.keys(left).every(function (leftKey) { return left[leftKey] === right[leftKey]; }));
};
var configureComponent = function (handler, errorHandler) { return function (aperture, instance, isValidElement) {
instance.state = {
children: null
children: null,
props: {},
decoratedProps: {}
};

@@ -98,21 +113,16 @@ var setState = function (state) {

var payload_1 = effect.payload;
if (payload_1.replace) {
setState({
replace: payload_1.replace,
props: Object.keys(payload_1.props || {}).reduce(function (props, propName) {
var prop = payload_1.props[propName];
if (propName !== 'children' &&
typeof prop === 'function') {
decorateProp(props, prop, propName);
}
else {
props[propName] = prop;
}
return props;
}, {})
});
}
else {
setState(payload_1);
}
setState({
replace: payload_1.replace,
props: payload_1.props,
decoratedProps: Object.keys(payload_1.props || {}).reduce(function (props, propName) {
var prop = payload_1.props[propName];
var previousProp = instance.state.props[propName];
if (propName !== 'children' &&
typeof prop === 'function' &&
prop !== previousProp) {
decorateProp(props, prop, propName);
}
return props;
}, {})
});
}

@@ -215,3 +225,4 @@ else {

Object.keys(nextProps).forEach(function (propName) {
if (typeof instance.props[propName] === 'function' &&
if (propName !== 'children' &&
typeof instance.props[propName] === 'function' &&
nextProps[propName] !== instance.props[propName]) {

@@ -233,17 +244,28 @@ decorateProp(decoratedProps, nextProps[propName], propName);

instance.getChildProps = function () {
var _a = instance.state, _b = _a.props, props = _b === void 0 ? {} : _b, replace = _a.replace;
if (replace === true) {
return Object.assign({}, props, {
pushEvent: pushEvent
});
var state = instance.state;
var stateProps = __assign({}, state.props, state.decoratedProps);
if (state.replace === true) {
return __assign({}, stateProps, { pushEvent: pushEvent });
}
else if (replace === false) {
return Object.assign({}, instance.props, decoratedProps, props, {
pushEvent: pushEvent
});
var componentProps = __assign({}, instance.props, decoratedProps, { pushEvent: pushEvent });
if (state.replace === false) {
return __assign({}, componentProps, stateProps);
}
return Object.assign({}, instance.props, decoratedProps, {
pushEvent: pushEvent
});
return componentProps;
};
instance.havePropsChanged = function (newProps, newState) {
var state = instance.state;
if (state.children) {
return state.children !== newState.children;
}
var haveStatePropsChanged = !shallowEquals(state.props, newState.props);
if (newState.replace === true) {
return haveStatePropsChanged;
}
var havePropsChanged = !shallowEquals(instance.props, newProps);
if (newState.replace === false) {
return havePropsChanged || haveStatePropsChanged;
}
return havePropsChanged;
};
}; };

@@ -278,2 +300,5 @@

};
WithEffects.prototype.shouldComponentUpdate = function (nextProps, nextState) {
return this.havePropsChanged(nextProps, nextState);
};
WithEffects.prototype.componentDidUpdate = function (prevProps) {

@@ -280,0 +305,0 @@ this.pushProps(prevProps);

{
"name": "refract-preact-xstream",
"description": "Refract bindings for Preact with xstream: master your app effects reactively!",
"version": "2.0.0-rc.0",
"version": "2.0.0-rc.1",
"main": "index.js",

@@ -6,0 +6,0 @@ "jsnext:main": "index.es.js",

@@ -6,3 +6,4 @@ import { ComponentFactory, VNode } from 'preact'

replace?: boolean
props?: any
props: object
decoratedProps: object
children: VNode | null

@@ -9,0 +10,0 @@ }

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