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

@preact/signals

Package Overview
Dependencies
Maintainers
10
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

test/ssr.test.tsx

6

CHANGELOG.md
# @preact/signals
## 1.1.1
### Patch Changes
- [#198](https://github.com/preactjs/signals/pull/198) [`3db7500`](https://github.com/preactjs/signals/commit/3db7500beea4c447f22fbde80af7b5171afa171c) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Fix server-sider-render error when unmounting a signal passed as text into JSX.
## 1.1.0

@@ -4,0 +10,0 @@

2

dist/signals.js

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

var r,n,i=require("preact"),t=require("preact/hooks"),f=require("@preact/signals-core");function o(r,n){i.options[r]=n.bind(null,i.options[r]||function(){})}function e(r){if(n)n();n=r&&r.S()}function u(r){var n=this,i=r.data,o=c(i);o.value=i;var e=t.useMemo(function(){var r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}n.__$u.c=function(){n.base.data=e.peek()};return f.computed(function(){var r=o.value.value;return 0===r?0:!0===r?"":r||""})},[]);return e.value}u.displayName="_st";Object.defineProperties(f.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:u},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});o("__b",function(r,n){if("string"==typeof n.type){var i,t=n.props;for(var o in t)if("children"!==o){var e=t[o];if(e instanceof f.Signal){if(!i)n.__np=i={};i[o]=e;t[o]=e.peek()}}}r(n)});o("__r",function(n,i){e();var t,o=i.__c;if(o){o.__$f&=-2;if(void 0===(t=o.__$u))o.__$u=t=function(r){var n;f.effect(function(){n=this});n.c=function(){o.__$f|=1;o.setState({})};return n}()}r=o;e(t);n(i)});o("__e",function(n,i,t,f){e();r=void 0;n(i,t,f)});o("diffed",function(n,i){e();r=void 0;var t;if("string"==typeof i.type&&(t=i.__e)){var f=i.__np,o=i.props;if(f){var u=t.U;if(u)for(var c in u){var v=u[c];if(void 0!==v&&!(c in f)){v.d();u[c]=void 0}}else t.U=u={};for(var s in f){var p=u[s],l=f[s];if(void 0===p){p=a(t,s,l,o);u[s]=p}else p.o(l,o)}}}n(i)});function a(r,n,i,t){var o=n in r&&void 0===r.ownerSVGElement,e=f.signal(i);return{o:function(r,n){e.value=r;t=n},d:f.effect(function(){var i=e.value.value;if(t[n]!==i){t[n]=i;if(o)r[n]=i;else if(i)r.setAttribute(n,i);else r.removeAttribute(n)}})}}o("unmount",function(r,n){var i=n.__c,t=i&&i.__$u;if(t)t.d();if("string"==typeof n.type){var f=n.__e,o=f.U;if(o){f.U=null;for(var e in o){var u=o[e];if(u)u.d()}}}r(n)});o("__h",function(r,n,i,t){if(t<3)n.__$f|=2;r(n,i,t)});i.Component.prototype.shouldComponentUpdate=function(r,n){var i=this.__$u;if(!(i&&void 0!==i.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in n)return!0;for(var f in r)if("__source"!==f&&r[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in r))return!0;return!1};function c(r){return t.useMemo(function(){return f.signal(r)},[])}exports.Signal=f.Signal;exports.batch=f.batch;exports.computed=f.computed;exports.effect=f.effect;exports.signal=f.signal;exports.useComputed=function(n){var i=t.useRef(n);i.current=n;r.__$f|=4;return t.useMemo(function(){return f.computed(function(){return i.current()})},[])};exports.useSignal=c;exports.useSignalEffect=function(r){var n=t.useRef(r);n.current=r;t.useEffect(function(){return f.effect(function(){n.current()})},[])};//# sourceMappingURL=signals.js.map
var r,n,i=require("preact"),t=require("preact/hooks"),f=require("@preact/signals-core");function o(r,n){i.options[r]=n.bind(null,i.options[r]||function(){})}function e(r){if(n)n();n=r&&r.S()}function u(r){var n=this,i=r.data,o=c(i);o.value=i;var e=t.useMemo(function(){var r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}n.__$u.c=function(){n.base.data=e.peek()};return f.computed(function(){var r=o.value.value;return 0===r?0:!0===r?"":r||""})},[]);return e.value}u.displayName="_st";Object.defineProperties(f.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:u},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});o("__b",function(r,n){if("string"==typeof n.type){var i,t=n.props;for(var o in t)if("children"!==o){var e=t[o];if(e instanceof f.Signal){if(!i)n.__np=i={};i[o]=e;t[o]=e.peek()}}}r(n)});o("__r",function(n,i){e();var t,o=i.__c;if(o){o.__$f&=-2;if(void 0===(t=o.__$u))o.__$u=t=function(r){var n;f.effect(function(){n=this});n.c=function(){o.__$f|=1;o.setState({})};return n}()}r=o;e(t);n(i)});o("__e",function(n,i,t,f){e();r=void 0;n(i,t,f)});o("diffed",function(n,i){e();r=void 0;var t;if("string"==typeof i.type&&(t=i.__e)){var f=i.__np,o=i.props;if(f){var u=t.U;if(u)for(var c in u){var v=u[c];if(void 0!==v&&!(c in f)){v.d();u[c]=void 0}}else t.U=u={};for(var s in f){var p=u[s],d=f[s];if(void 0===p){p=a(t,s,d,o);u[s]=p}else p.o(d,o)}}}n(i)});function a(r,n,i,t){var o=n in r&&void 0===r.ownerSVGElement,e=f.signal(i);return{o:function(r,n){e.value=r;t=n},d:f.effect(function(){var i=e.value.value;if(t[n]!==i){t[n]=i;if(o)r[n]=i;else if(i)r.setAttribute(n,i);else r.removeAttribute(n)}})}}o("unmount",function(r,n){if("string"==typeof n.type){var i=n.__e;if(i){var t=i.U;if(t){i.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=n.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}r(n)});o("__h",function(r,n,i,t){if(t<3)n.__$f|=2;r(n,i,t)});i.Component.prototype.shouldComponentUpdate=function(r,n){var i=this.__$u;if(!(i&&void 0!==i.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in n)return!0;for(var f in r)if("__source"!==f&&r[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in r))return!0;return!1};function c(r){return t.useMemo(function(){return f.signal(r)},[])}exports.Signal=f.Signal;exports.batch=f.batch;exports.computed=f.computed;exports.effect=f.effect;exports.signal=f.signal;exports.useComputed=function(n){var i=t.useRef(n);i.current=n;r.__$f|=4;return t.useMemo(function(){return f.computed(function(){return i.current()})},[])};exports.useSignal=c;exports.useSignalEffect=function(r){var n=t.useRef(r);n.current=r;t.useEffect(function(){return f.effect(function(){n.current()})},[])};//# sourceMappingURL=signals.js.map

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

!function(n,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],i):i((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,i,r,t){var f,e;function o(n,r){i.options[n]=r.bind(null,i.options[n]||function(){})}function u(n){if(e)e();e=n&&n.S()}function c(n){var i=this,f=n.data,e=v(f);e.value=f;var o=r.useMemo(function(){var n=i.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}i.__$u.c=function(){i.base.data=o.peek()};return t.computed(function(){var n=e.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}c.displayName="_st";Object.defineProperties(t.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:c},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});o("__b",function(n,i){if("string"==typeof i.type){var r,f=i.props;for(var e in f)if("children"!==e){var o=f[e];if(o instanceof t.Signal){if(!r)i.__np=r={};r[e]=o;f[e]=o.peek()}}}n(i)});o("__r",function(n,i){u();var r,e=i.__c;if(e){e.__$f&=-2;if(void 0===(r=e.__$u))e.__$u=r=function(n){var i;t.effect(function(){i=this});i.c=function(){e.__$f|=1;e.setState({})};return i}()}f=e;u(r);n(i)});o("__e",function(n,i,r,t){u();f=void 0;n(i,r,t)});o("diffed",function(n,i){u();f=void 0;var r;if("string"==typeof i.type&&(r=i.__e)){var t=i.__np,e=i.props;if(t){var o=r.U;if(o)for(var c in o){var v=o[c];if(void 0!==v&&!(c in t)){v.d();o[c]=void 0}}else r.U=o={};for(var s in t){var l=o[s],d=t[s];if(void 0===l){l=a(r,s,d,e);o[s]=l}else l.o(d,e)}}}n(i)});function a(n,i,r,f){var e=i in n&&void 0===n.ownerSVGElement,o=t.signal(r);return{o:function(n,i){o.value=n;f=i},d:t.effect(function(){var r=o.value.value;if(f[i]!==r){f[i]=r;if(e)n[i]=r;else if(r)n.setAttribute(i,r);else n.removeAttribute(i)}})}}o("unmount",function(n,i){var r=i.__c,t=r&&r.__$u;if(t)t.d();if("string"==typeof i.type){var f=i.__e,e=f.U;if(e){f.U=null;for(var o in e){var u=e[o];if(u)u.d()}}}n(i)});o("__h",function(n,i,r,t){if(t<3)i.__$f|=2;n(i,r,t)});i.Component.prototype.shouldComponentUpdate=function(n,i){var r=this.__$u;if(!(r&&void 0!==r.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in i)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var e in this.props)if(!(e in n))return!0;return!1};function v(n){return r.useMemo(function(){return t.signal(n)},[])}n.Signal=t.Signal;n.batch=t.batch;n.computed=t.computed;n.effect=t.effect;n.signal=t.signal;n.useComputed=function(n){var i=r.useRef(n);i.current=n;f.__$f|=4;return r.useMemo(function(){return t.computed(function(){return i.current()})},[])};n.useSignal=v;n.useSignalEffect=function(n){var i=r.useRef(n);i.current=n;r.useEffect(function(){return t.effect(function(){i.current()})},[])}});//# sourceMappingURL=signals.min.js.map
!function(n,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],i):i((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,i,r,t){var f,e;function o(n,r){i.options[n]=r.bind(null,i.options[n]||function(){})}function u(n){if(e)e();e=n&&n.S()}function a(n){var i=this,f=n.data,e=v(f);e.value=f;var o=r.useMemo(function(){var n=i.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}i.__$u.c=function(){i.base.data=o.peek()};return t.computed(function(){var n=e.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}a.displayName="_st";Object.defineProperties(t.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:a},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});o("__b",function(n,i){if("string"==typeof i.type){var r,f=i.props;for(var e in f)if("children"!==e){var o=f[e];if(o instanceof t.Signal){if(!r)i.__np=r={};r[e]=o;f[e]=o.peek()}}}n(i)});o("__r",function(n,i){u();var r,e=i.__c;if(e){e.__$f&=-2;if(void 0===(r=e.__$u))e.__$u=r=function(n){var i;t.effect(function(){i=this});i.c=function(){e.__$f|=1;e.setState({})};return i}()}f=e;u(r);n(i)});o("__e",function(n,i,r,t){u();f=void 0;n(i,r,t)});o("diffed",function(n,i){u();f=void 0;var r;if("string"==typeof i.type&&(r=i.__e)){var t=i.__np,e=i.props;if(t){var o=r.U;if(o)for(var a in o){var v=o[a];if(void 0!==v&&!(a in t)){v.d();o[a]=void 0}}else r.U=o={};for(var s in t){var d=o[s],l=t[s];if(void 0===d){d=c(r,s,l,e);o[s]=d}else d.o(l,e)}}}n(i)});function c(n,i,r,f){var e=i in n&&void 0===n.ownerSVGElement,o=t.signal(r);return{o:function(n,i){o.value=n;f=i},d:t.effect(function(){var r=o.value.value;if(f[i]!==r){f[i]=r;if(e)n[i]=r;else if(r)n.setAttribute(i,r);else n.removeAttribute(i)}})}}o("unmount",function(n,i){if("string"==typeof i.type){var r=i.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var f in t){var e=t[f];if(e)e.d()}}}}else{var o=i.__c;if(o){var u=o.__$u;if(u){o.__$u=void 0;u.d()}}}n(i)});o("__h",function(n,i,r,t){if(t<3)i.__$f|=2;n(i,r,t)});i.Component.prototype.shouldComponentUpdate=function(n,i){var r=this.__$u;if(!(r&&void 0!==r.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in i)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var e in this.props)if(!(e in n))return!0;return!1};function v(n){return r.useMemo(function(){return t.signal(n)},[])}n.Signal=t.Signal;n.batch=t.batch;n.computed=t.computed;n.effect=t.effect;n.signal=t.signal;n.useComputed=function(n){var i=r.useRef(n);i.current=n;f.__$f|=4;return r.useMemo(function(){return t.computed(function(){return i.current()})},[])};n.useSignal=v;n.useSignalEffect=function(n){var i=r.useRef(n);i.current=n;r.useEffect(function(){return t.effect(function(){i.current()})},[])}});//# sourceMappingURL=signals.min.js.map

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

import{Component as n,options as r}from"preact";import{useMemo as i,useRef as t,useEffect as f}from"preact/hooks";import{Signal as o,computed as u,signal as e,effect as a}from"@preact/signals-core";export{Signal,batch,computed,effect,signal}from"@preact/signals-core";var c,v;function s(n,i){r[n]=i.bind(null,r[n]||function(){})}function l(n){if(v)v();v=n&&n.S()}function p(n){var r=this,t=n.data,f=_(t);f.value=t;var o=i(function(){var n=r.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}r.__$u.c=function(){r.base.data=o.peek()};return u(function(){var n=f.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}p.displayName="_st";Object.defineProperties(o.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:p},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});s("__b",function(n,r){if("string"==typeof r.type){var i,t=r.props;for(var f in t)if("children"!==f){var u=t[f];if(u instanceof o){if(!i)r.__np=i={};i[f]=u;t[f]=u.peek()}}}n(r)});s("__r",function(n,r){l();var i,t=r.__c;if(t){t.__$f&=-2;if(void 0===(i=t.__$u))t.__$u=i=function(n){var r;a(function(){r=this});r.c=function(){t.__$f|=1;t.setState({})};return r}()}c=t;l(i);n(r)});s("__e",function(n,r,i,t){l();c=void 0;n(r,i,t)});s("diffed",function(n,r){l();c=void 0;var i;if("string"==typeof r.type&&(i=r.__e)){var t=r.__np,f=r.props;if(t){var o=i.U;if(o)for(var u in o){var e=o[u];if(void 0!==e&&!(u in t)){e.d();o[u]=void 0}}else i.U=o={};for(var a in t){var v=o[a],s=t[a];if(void 0===v){v=d(i,a,s,f);o[a]=v}else v.o(s,f)}}}n(r)});function d(n,r,i,t){var f=r in n&&void 0===n.ownerSVGElement,o=e(i);return{o:function(n,r){o.value=n;t=r},d:a(function(){var i=o.value.value;if(t[r]!==i){t[r]=i;if(f)n[r]=i;else if(i)n.setAttribute(r,i);else n.removeAttribute(r)}})}}s("unmount",function(n,r){var i=r.__c,t=i&&i.__$u;if(t)t.d();if("string"==typeof r.type){var f=r.__e,o=f.U;if(o){f.U=null;for(var u in o){var e=o[u];if(e)e.d()}}}n(r)});s("__h",function(n,r,i,t){if(t<3)r.__$f|=2;n(r,i,t)});n.prototype.shouldComponentUpdate=function(n,r){var i=this.__$u;if(!(i&&void 0!==i.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in r)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in n))return!0;return!1};function _(n){return i(function(){return e(n)},[])}function h(n){var r=t(n);r.current=n;c.__$f|=4;return i(function(){return u(function(){return r.current()})},[])}function g(n){var r=t(n);r.current=n;f(function(){return a(function(){r.current()})},[])}export{h as useComputed,_ as useSignal,g as useSignalEffect};//# sourceMappingURL=signals.module.js.map
import{Component as n,options as i}from"preact";import{useMemo as r,useRef as t,useEffect as f}from"preact/hooks";import{Signal as o,computed as e,signal as u,effect as a}from"@preact/signals-core";export{Signal,batch,computed,effect,signal}from"@preact/signals-core";var c,v;function s(n,r){i[n]=r.bind(null,i[n]||function(){})}function l(n){if(v)v();v=n&&n.S()}function p(n){var i=this,t=n.data,f=_(t);f.value=t;var o=r(function(){var n=i.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}i.__$u.c=function(){i.base.data=o.peek()};return e(function(){var n=f.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}p.displayName="_st";Object.defineProperties(o.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:p},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});s("__b",function(n,i){if("string"==typeof i.type){var r,t=i.props;for(var f in t)if("children"!==f){var e=t[f];if(e instanceof o){if(!r)i.__np=r={};r[f]=e;t[f]=e.peek()}}}n(i)});s("__r",function(n,i){l();var r,t=i.__c;if(t){t.__$f&=-2;if(void 0===(r=t.__$u))t.__$u=r=function(n){var i;a(function(){i=this});i.c=function(){t.__$f|=1;t.setState({})};return i}()}c=t;l(r);n(i)});s("__e",function(n,i,r,t){l();c=void 0;n(i,r,t)});s("diffed",function(n,i){l();c=void 0;var r;if("string"==typeof i.type&&(r=i.__e)){var t=i.__np,f=i.props;if(t){var o=r.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in t)){u.d();o[e]=void 0}}else r.U=o={};for(var a in t){var v=o[a],s=t[a];if(void 0===v){v=d(r,a,s,f);o[a]=v}else v.o(s,f)}}}n(i)});function d(n,i,r,t){var f=i in n&&void 0===n.ownerSVGElement,o=u(r);return{o:function(n,i){o.value=n;t=i},d:a(function(){var r=o.value.value;if(t[i]!==r){t[i]=r;if(f)n[i]=r;else if(r)n.setAttribute(i,r);else n.removeAttribute(i)}})}}s("unmount",function(n,i){if("string"==typeof i.type){var r=i.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=i.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}n(i)});s("__h",function(n,i,r,t){if(t<3)i.__$f|=2;n(i,r,t)});n.prototype.shouldComponentUpdate=function(n,i){var r=this.__$u;if(!(r&&void 0!==r.s||4&this.__$f))return!0;if(3&this.__$f)return!0;for(var t in i)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in n))return!0;return!1};function _(n){return r(function(){return u(n)},[])}function h(n){var i=t(n);i.current=n;c.__$f|=4;return r(function(){return e(function(){return i.current()})},[])}function g(n){var i=t(n);i.current=n;f(function(){return a(function(){i.current()})},[])}export{h as useComputed,_ as useSignal,g as useSignalEffect};//# sourceMappingURL=signals.module.js.map
{
"name": "@preact/signals",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",

@@ -44,5 +44,6 @@ "description": "",

"devDependencies": {
"preact": "10.9.0"
"preact": "10.9.0",
"preact-render-to-string": "^5.2.4"
},
"scripts": {}
}

@@ -246,19 +246,24 @@ import { options, Component } from "preact";

hook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {
let component = vnode.__c;
const updater = component && component._updater;
if (updater) {
updater._dispose();
}
if (typeof vnode.type === "string") {
const dom = vnode.__e as Element;
const updaters = dom._updaters;
if (updaters) {
dom._updaters = null;
for (let prop in updaters) {
let updater = updaters[prop];
if (updater) updater._dispose();
let dom = vnode.__e as Element | undefined;
// vnode._dom is undefined during string rendering
if (dom) {
const updaters = dom._updaters;
if (updaters) {
dom._updaters = undefined;
for (let prop in updaters) {
let updater = updaters[prop];
if (updater) updater._dispose();
}
}
}
} else {
let component = vnode.__c;
if (component) {
const updater = component._updater;
if (updater) {
component._updater = undefined;
updater._dispose();
}
}
}

@@ -265,0 +270,0 @@ old(vnode);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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