New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@preact/signals-react

Package Overview
Dependencies
Maintainers
6
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals-react - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

6

CHANGELOG.md
# @preact/signals-react
## 3.0.1
### Patch Changes
- [#640](https://github.com/preactjs/signals/pull/640) [`503128f`](https://github.com/preactjs/signals/commit/503128f55af128ddc3b1f2133bc90f576d699d6c) Thanks [@andrewiggins](https://github.com/andrewiggins)! - Don't track signals read during an SSR render (e.g. renderToString, renderToStaticMarkup)
## 3.0.0

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

2

package.json
{
"name": "@preact/signals-react",
"version": "3.0.0",
"version": "3.0.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Manage state with style in React",

@@ -101,2 +101,6 @@ # Signals

### Using signals with React's SSR APIs
Components rendered using SSR APIs (e.g. `renderToString`) in a server environment (i.e. an environment without a global `window` object) will not track signals used during render. Components generally don't rerender when using SSR APIs so tracking signal usage is useless since changing these signals can't trigger a rerender.
### Rendering optimizations

@@ -136,3 +140,3 @@

Using signals into render props is not recommended. In this situation, the component that reads the signal is the component that calls the render prop, which may or may not be hooked up to track signals. For example:
Using signals in render props is not recommended. In this situation, the component that reads the signal is the component that calls the render prop, which may or may not be hooked up to track signals. For example:

@@ -139,0 +143,0 @@ ```js

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

var n,r=require("@preact/signals-core"),t=require("react"),e=require("use-sync-external-store/shim/index.js"),i=t.version.split(".").map(Number),u=[],o=Symbol.for(i[0]>=19?"react.transitional.element":"react.element"),f=Symbol.dispose||Symbol.for("Symbol.dispose");function c(r,t){var e=t.effect.S();n=t;return s.bind(t,r,e)}function s(r,t){t();n=r}var a,l=Promise.prototype.then.bind(Promise.resolve());function v(){if(!a)a=l(p)}function p(){var r;a=void 0;null==(r=n)||r.f()}var d="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function b(i){if(void 0===i)i=0;v();var u=t.useRef();if(null==u.current)u.current=function(t){var e,i,u,o,s=0,a=r.effect(function(){i=this});i.c=function(){s=s+1|0;if(o)o()};return(e={u:t,effect:i,subscribe:function(n){o=n;return function(){s=s+1|0;o=void 0;a()}},getSnapshot:function(){return s},S:function(){if(null!=n){var r=n.u,t=this.u;if(0==r&&0==t||0==r&&1==t){n.f();u=c(void 0,this)}else if(1==r&&0==t||2==r&&0==t);else u=c(n,this)}else u=c(void 0,this)},f:function(){var n=u;u=void 0;null==n||n()}})[f]=function(){this.f()},e}(i);var o=u.current;e.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot);o.S();if(0===i)d(p);return o}Object.defineProperties(r.Signal.prototype,{$$typeof:{configurable:!0,value:o},type:{configurable:!0,value:function(n){var r=n.data,t=b(1);try{return r.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});exports._useSignalsImplementation=b;exports.ensureFinalCleanup=v;exports.useComputed=function(n){var e=t.useRef(n);e.current=n;return t.useMemo(function(){return r.computed(function(){return e.current()})},u)};exports.useSignal=function(n){return t.useMemo(function(){return r.signal(n)},u)};exports.useSignalEffect=function(n){var e=t.useRef(n);e.current=n;t.useEffect(function(){return r.effect(function(){return e.current()})},u)};exports.useSignals=function(n){return b(n)};exports.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(t,e){if("string"==typeof t&&e)for(var i in e){var u=e[i];if("children"!==i&&u instanceof r.Signal)e[i]=u.value}return n.call.apply(n,[n,t,e].concat([].slice.call(arguments,2)))}};//# sourceMappingURL=runtime.js.map
var n,t=require("@preact/signals-core"),e=require("react"),r=require("use-sync-external-store/shim/index.js"),i=e.version.split(".").map(Number)[0],u=[],o=Symbol.for(i>=19?"react.transitional.element":"react.element"),f=Symbol.dispose||Symbol.for("Symbol.dispose");function c(t,e){var r=e.effect.S();n=e;return s.bind(e,t,r)}function s(t,e){e();n=t}var a,l,v=function(){},p=((a={u:0,effect:{s:void 0,c:function(){},S:function(){return v},d:function(){}},subscribe:function(){return v},getSnapshot:function(){return 0},S:function(){},f:function(){}})[f]=function(){},a),d=Promise.prototype.then.bind(Promise.resolve());function b(){if(!l)l=d(y)}function y(){var t;l=void 0;null==(t=n)||t.f()}var g="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function h(i){if(void 0===i)i=0;b();var u=e.useRef();if(null==u.current)if("undefined"==typeof window)u.current=p;else u.current=function(e){var r,i,u,o,s=0,a=t.effect(function(){i=this});i.c=function(){s=s+1|0;if(o)o()};return(r={u:e,effect:i,subscribe:function(n){o=n;return function(){s=s+1|0;o=void 0;a()}},getSnapshot:function(){return s},S:function(){if(null!=n){var t=n.u,e=this.u;if(0==t&&0==e||0==t&&1==e){n.f();u=c(void 0,this)}else if(1==t&&0==e||2==t&&0==e);else u=c(n,this)}else u=c(void 0,this)},f:function(){var n=u;u=void 0;null==n||n()}})[f]=function(){this.f()},r}(i);var o=u.current;r.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot);o.S();if(0===i)g(y);return o}Object.defineProperties(t.Signal.prototype,{$$typeof:{configurable:!0,value:o},type:{configurable:!0,value:function(n){var t=n.data,e=h(1);try{return t.value}finally{e.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});exports._useSignalsImplementation=h;exports.ensureFinalCleanup=b;exports.useComputed=function(n){var r=e.useRef(n);r.current=n;return e.useMemo(function(){return t.computed(function(){return r.current()})},u)};exports.useSignal=function(n){return e.useMemo(function(){return t.signal(n)},u)};exports.useSignalEffect=function(n){var r=e.useRef(n);r.current=n;e.useEffect(function(){return t.effect(function(){return r.current()})},u)};exports.useSignals=function(n){return h(n)};exports.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(e,r){if("string"==typeof e&&r)for(var i in r){var u=r[i];if("children"!==i&&u instanceof t.Signal)r[i]=u.value}return n.call.apply(n,[n,e,r].concat([].slice.call(arguments,2)))}};//# sourceMappingURL=runtime.js.map

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

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals-core"),require("react"),require("use-sync-external-store/shim/index.js")):"function"==typeof define&&define.amd?define(["exports","@preact/signals-core","react","use-sync-external-store/shim/index.js"],e):e((n||self).reactSignalsRuntime={},n.preactSignalsCore,n.react,n.index_js)}(this,function(n,e,t,i){var r,o=t.version.split(".").map(Number),u=[],f=Symbol.for(o[0]>=19?"react.transitional.element":"react.element"),c=Symbol.dispose||Symbol.for("Symbol.dispose");function s(n,e){var t=e.effect.S();r=e;return a.bind(e,n,t)}function a(n,e){e();r=n}var l,v=Promise.prototype.then.bind(Promise.resolve());function d(){if(!l)l=v(p)}function p(){var n;l=void 0;null==(n=r)||n.f()}var y="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function b(n){if(void 0===n)n=0;d();var o=t.useRef();if(null==o.current)o.current=function(n){var t,i,o,u,f=0,a=e.effect(function(){i=this});i.c=function(){f=f+1|0;if(u)u()};return(t={o:n,effect:i,subscribe:function(n){u=n;return function(){f=f+1|0;u=void 0;a()}},getSnapshot:function(){return f},S:function(){if(null!=r){var n=r.o,e=this.o;if(0==n&&0==e||0==n&&1==e){r.f();o=s(void 0,this)}else if(1==n&&0==e||2==n&&0==e);else o=s(r,this)}else o=s(void 0,this)},f:function(){var n=o;o=void 0;null==n||n()}})[c]=function(){this.f()},t}(n);var u=o.current;i.useSyncExternalStore(u.subscribe,u.getSnapshot,u.getSnapshot);u.S();if(0===n)y(p);return u}Object.defineProperties(e.Signal.prototype,{$$typeof:{configurable:!0,value:f},type:{configurable:!0,value:function(n){var e=n.data,t=b(1);try{return e.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});n.u=b;n.ensureFinalCleanup=d;n.useComputed=function(n){var i=t.useRef(n);i.current=n;return t.useMemo(function(){return e.computed(function(){return i.current()})},u)};n.useSignal=function(n){return t.useMemo(function(){return e.signal(n)},u)};n.useSignalEffect=function(n){var i=t.useRef(n);i.current=n;t.useEffect(function(){return e.effect(function(){return i.current()})},u)};n.useSignals=function(n){return b(n)};n.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(t,i){if("string"==typeof t&&i)for(var r in i){var o=i[r];if("children"!==r&&o instanceof e.Signal)i[r]=o.value}return n.call.apply(n,[n,t,i].concat([].slice.call(arguments,2)))}}});//# sourceMappingURL=runtime.min.js.map
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals-core"),require("react"),require("use-sync-external-store/shim/index.js")):"function"==typeof define&&define.amd?define(["exports","@preact/signals-core","react","use-sync-external-store/shim/index.js"],e):e((n||self).reactSignalsRuntime={},n.preactSignalsCore,n.react,n.index_js)}(this,function(n,e,t,i){var r,u=t.version.split(".").map(Number)[0],o=[],f=Symbol.for(u>=19?"react.transitional.element":"react.element"),c=Symbol.dispose||Symbol.for("Symbol.dispose");function s(n,e){var t=e.effect.S();r=e;return a.bind(e,n,t)}function a(n,e){e();r=n}var l,d,v=function(){},p=((l={u:0,effect:{s:void 0,c:function(){},S:function(){return v},d:function(){}},subscribe:function(){return v},getSnapshot:function(){return 0},S:function(){},f:function(){}})[c]=function(){},l),b=Promise.prototype.then.bind(Promise.resolve());function y(){if(!d)d=b(h)}function h(){var n;d=void 0;null==(n=r)||n.f()}var g="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function m(n){if(void 0===n)n=0;y();var u=t.useRef();if(null==u.current)if("undefined"==typeof window)u.current=p;else u.current=function(n){var t,i,u,o,f=0,a=e.effect(function(){i=this});i.c=function(){f=f+1|0;if(o)o()};return(t={u:n,effect:i,subscribe:function(n){o=n;return function(){f=f+1|0;o=void 0;a()}},getSnapshot:function(){return f},S:function(){if(null!=r){var n=r.u,e=this.u;if(0==n&&0==e||0==n&&1==e){r.f();u=s(void 0,this)}else if(1==n&&0==e||2==n&&0==e);else u=s(r,this)}else u=s(void 0,this)},f:function(){var n=u;u=void 0;null==n||n()}})[c]=function(){this.f()},t}(n);var o=u.current;i.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot);o.S();if(0===n)g(h);return o}Object.defineProperties(e.Signal.prototype,{$$typeof:{configurable:!0,value:f},type:{configurable:!0,value:function(n){var e=n.data,t=m(1);try{return e.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});n.o=m;n.ensureFinalCleanup=y;n.useComputed=function(n){var i=t.useRef(n);i.current=n;return t.useMemo(function(){return e.computed(function(){return i.current()})},o)};n.useSignal=function(n){return t.useMemo(function(){return e.signal(n)},o)};n.useSignalEffect=function(n){var i=t.useRef(n);i.current=n;t.useEffect(function(){return e.effect(function(){return i.current()})},o)};n.useSignals=function(n){return m(n)};n.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(t,i){if("string"==typeof t&&i)for(var r in i){var u=i[r];if("children"!==r&&u instanceof e.Signal)i[r]=u.value}return n.call.apply(n,[n,t,i].concat([].slice.call(arguments,2)))}}});//# sourceMappingURL=runtime.min.js.map

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

import{Signal as n,signal as t,computed as r,effect as i}from"@preact/signals-core";import{version as e,useRef as o,useMemo as u,useEffect as f,useLayoutEffect as c}from"react";import{useSyncExternalStore as a}from"use-sync-external-store/shim/index.js";var l=e.split(".").map(Number),s=[],v=Symbol.for(l[0]>=19?"react.transitional.element":"react.element");function m(t){if("function"!=typeof t)return t;else return function(r,i){if("string"==typeof r&&i)for(var e in i){var o=i[e];if("children"!==e&&o instanceof n)i[e]=o.value}return t.call.apply(t,[t,r,i].concat([].slice.call(arguments,2)))}}var p,d=Symbol.dispose||Symbol.for("Symbol.dispose");function b(n,t){var r=t.effect.S();p=t;return y.bind(t,n,r)}function y(n,t){t();p=n}var h,g=Promise.prototype.then.bind(Promise.resolve());function S(){if(!h)h=g(x)}function x(){var n;h=void 0;null==(n=p)||n.f()}var j="undefined"!=typeof window?c:f;function w(n){if(void 0===n)n=0;S();var t=o();if(null==t.current)t.current=function(n){var t,r,e,o,u=0,f=i(function(){r=this});r.c=function(){u=u+1|0;if(o)o()};return(t={o:n,effect:r,subscribe:function(n){o=n;return function(){u=u+1|0;o=void 0;f()}},getSnapshot:function(){return u},S:function(){if(null!=p){var n=p.o,t=this.o;if(0==n&&0==t||0==n&&1==t){p.f();e=b(void 0,this)}else if(1==n&&0==t||2==n&&0==t);else e=b(p,this)}else e=b(void 0,this)},f:function(){var n=e;e=void 0;null==n||n()}})[d]=function(){this.f()},t}(n);var r=t.current;a(r.subscribe,r.getSnapshot,r.getSnapshot);r.S();if(0===n)j(x);return r}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:v},type:{configurable:!0,value:function(n){var t=n.data,r=w(1);try{return t.value}finally{r.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});function P(n){return w(n)}function useSignal(n){return u(function(){return t(n)},s)}function useComputed(n){var t=o(n);t.current=n;return u(function(){return r(function(){return t.current()})},s)}function useSignalEffect(n){var t=o(n);t.current=n;f(function(){return i(function(){return t.current()})},s)}export{w as _useSignalsImplementation,S as ensureFinalCleanup,useComputed,useSignal,useSignalEffect,P as useSignals,m as wrapJsx};//# sourceMappingURL=runtime.module.js.map
import{Signal as n,signal as t,computed as r,effect as i}from"@preact/signals-core";import{version as e,useRef as o,useMemo as u,useEffect as f,useLayoutEffect as c}from"react";import{useSyncExternalStore as a}from"use-sync-external-store/shim/index.js";var s=e.split(".").map(Number)[0],l=[],v=Symbol.for(s>=19?"react.transitional.element":"react.element");function d(t){if("function"!=typeof t)return t;else return function(r,i){if("string"==typeof r&&i)for(var e in i){var o=i[e];if("children"!==e&&o instanceof n)i[e]=o.value}return t.call.apply(t,[t,r,i].concat([].slice.call(arguments,2)))}}var p,m=Symbol.dispose||Symbol.for("Symbol.dispose");function b(n,t){var r=t.effect.S();p=t;return y.bind(t,n,r)}function y(n,t){t();p=n}var g,h,_=function(){},S=((g={o:0,effect:{s:void 0,c:function(){},S:function(){return _},d:function(){}},subscribe:function(){return _},getSnapshot:function(){return 0},S:function(){},f:function(){}})[m]=function(){},g),w=Promise.prototype.then.bind(Promise.resolve());function x(){if(!h)h=w(j)}function j(){var n;h=void 0;null==(n=p)||n.f()}var P="undefined"!=typeof window?c:f;function $(n){if(void 0===n)n=0;x();var t=o();if(null==t.current)if("undefined"==typeof window)t.current=S;else t.current=function(n){var t,r,e,o,u=0,f=i(function(){r=this});r.c=function(){u=u+1|0;if(o)o()};return(t={o:n,effect:r,subscribe:function(n){o=n;return function(){u=u+1|0;o=void 0;f()}},getSnapshot:function(){return u},S:function(){if(null!=p){var n=p.o,t=this.o;if(0==n&&0==t||0==n&&1==t){p.f();e=b(void 0,this)}else if(1==n&&0==t||2==n&&0==t);else e=b(p,this)}else e=b(void 0,this)},f:function(){var n=e;e=void 0;null==n||n()}})[m]=function(){this.f()},t}(n);var r=t.current;a(r.subscribe,r.getSnapshot,r.getSnapshot);r.S();if(0===n)P(j);return r}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:v},type:{configurable:!0,value:function(n){var t=n.data,r=$(1);try{return t.value}finally{r.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});function k(n){return $(n)}function useSignal(n){return u(function(){return t(n)},l)}function useComputed(n){var t=o(n);t.current=n;return u(function(){return r(function(){return t.current()})},l)}function useSignalEffect(n){var t=o(n);t.current=n;f(function(){return i(function(){return t.current()})},l)}export{$ as _useSignalsImplementation,x as ensureFinalCleanup,useComputed,useSignal,useSignalEffect,k as useSignals,d as wrapJsx};//# sourceMappingURL=runtime.module.js.map

@@ -288,2 +288,29 @@ import {

const noop = () => {};
function createEmptyEffectStore(): EffectStore {
return {
_usage: UNMANAGED,
effect: {
_sources: undefined,
_callback() {},
_start() {
return /* endEffect */ noop;
},
_dispose() {},
},
subscribe() {
return /* unsubscribe */ noop;
},
getSnapshot() {
return 0;
},
_start() {},
f() {},
[symDispose]() {},
};
}
const emptyEffectStore = createEmptyEffectStore();
const _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());

@@ -316,3 +343,7 @@

if (storeRef.current == null) {
storeRef.current = createEffectStore(_usage);
if (typeof window === "undefined") {
storeRef.current = emptyEffectStore;
} else {
storeRef.current = createEffectStore(_usage);
}
}

@@ -319,0 +350,0 @@

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