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
24
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 0.0.3 to 0.0.4

9

CHANGELOG.md
# @preact/signals
## 0.0.4
### Patch Changes
- 702a9c5: Update TypeScript types to mark computed signals as readonly
- 5f8be64: Optimize size of CJS & UMD bundles.
- Updated dependencies [702a9c5]
- @preact/signals-core@0.0.5
## 0.0.3

@@ -4,0 +13,0 @@

6

dist/signals.d.ts

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

import { Signal } from "@preact/signals-core";
export * from "@preact/signals-core";
import { signal, computed, batch, effect, Signal, type ReadonlySignal } from "@preact/signals-core";
export { signal, computed, batch, effect, Signal, type ReadonlySignal };
export declare function useSignal<T>(value: T): Signal<T>;
export declare function useComputed<T>(compute: () => T): Signal<T>;
export declare function useComputed<T>(compute: () => T): ReadonlySignal<T>;
/**

@@ -6,0 +6,0 @@ * @todo Determine which Reactive implementation we'll be using.

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

var n,r,t,e=require("preact"),i=require("preact/hooks"),u=require("@preact/signals-core"),o=new WeakSet,f=new WeakSet,c=new WeakSet;function a(n,r){e.options[n]=r.bind(null,e.options[n]||function(){})}var v=new WeakMap;function s(n){t&&t(!0,!0),r=n,t=n&&n._()}function l(n){var r=u.signal(void 0);return r._c=!0,r._u=n,r}function d(n){var r=v.get(n);if(r)r.__.length=0;else{var t=[];(r=l(function(){for(var r=n.__e,e=n.props,i=0;i<t.length;i++){var u=t[i],o=e[u]._v;u in r?r[u]=o:o?r.setAttribute(u,o):r.removeAttribute(u)}})).__=t,v.set(n,r)}return r}function h(n,r,t){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(h):n instanceof u.Signal&&(t[r]=e.createElement(p,{data:n})))}function p(n){var t=this,e=n.data,o=i.useMemo(function(){for(var n=t.__v;n=n.__;)if(n.__c){c.add(n.__c);break}return r._u=function(){t.base.data=o._v},u.computed(function(){var n=e.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}a("__b",function(n,r){if("string"==typeof r.type){var t,e=r.props;for(var i in e){var o=e[i];"children"===i?h(o,"children",e):o instanceof u.Signal&&(t||(t=d(r)),t.__.push(i))}s(t)}n(r)}),a("__r",function(r,t){var e,i=t.__c;i&&(o.delete(i),void 0===(e=v.get(i))&&(e=l(function(){o.add(i),i.setState({})}),v.set(i,e))),n=i,s(e),r(t)}),a("__e",function(r,t,e,i){s(),n=void 0,r(t,e,i)}),a("diffed",function(r,t){s(),n=void 0,r(t)}),a("unmount",function(n,r){var t=r.__c||r,e=v.get(t);if(e){v.delete(t);var i=e._d;i&&(i.forEach(function(n){return n._s.delete(e)}),i.clear())}n(r)}),a("__h",function(n,r,t,e){e<3&&f.add(r),n(r,t,e)}),e.Component.prototype.shouldComponentUpdate=function(n,r){var t,e=v.get(this);if(!(e&&0!==(null==(t=e._d)?void 0:t.size)||c.has(this)))return!0;if(o.has(this))return!0;if(f.has(this))return!0;for(var i in r)return!0;for(var u in n)if("__source"!==u&&n[u]!==this.props[u])return!0;for(var a in this.props)if(!(a in n))return!0;return!1},exports.useComputed=function(r){var t=i.useRef(r);return t.current=r,c.add(n),i.useMemo(function(){return u.computed(function(){return t.current()})},[])},exports.useSignal=function(n){return i.useMemo(function(){return u.signal(n)},[])},Object.keys(u).forEach(function(n){"default"===n||exports.hasOwnProperty(n)||Object.defineProperty(exports,n,{enumerable:!0,get:function(){return u[n]}})});
var n,r,t,e=require("preact"),i=require("preact/hooks"),u=require("@preact/signals-core"),o=new WeakSet,f=new WeakSet,c=new WeakSet;function a(n,r){e.options[n]=r.bind(null,e.options[n]||function(){})}var v=new WeakMap;function s(n){t&&t(!0,!0),r=n,t=n&&n._()}function l(n){var r=u.signal(void 0);return r._c=!0,r._u=n,r}function b(n){var r=v.get(n);if(r)r.__.length=0;else{var t=[];(r=l(function(){for(var r=n.__e,e=n.props,i=0;i<t.length;i++){var u=t[i],o=e[u]._v;u in r?r[u]=o:o?r.setAttribute(u,o):r.removeAttribute(u)}})).__=t,v.set(n,r)}return r}function p(n,r,t){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(p):n instanceof u.Signal&&(t[r]=e.createElement(h,{data:n})))}function h(n){var t=this,e=n.data,o=i.useMemo(function(){for(var n=t.__v;n=n.__;)if(n.__c){c.add(n.__c);break}return r._u=function(){t.base.data=o._v},u.computed(function(){var n=e.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}a("__b",function(n,r){if("string"==typeof r.type){var t,e=r.props;for(var i in e){var o=e[i];"children"===i?p(o,"children",e):o instanceof u.Signal&&(t||(t=b(r)),t.__.push(i))}s(t)}n(r)}),a("__r",function(r,t){var e,i=t.__c;i&&(o.delete(i),void 0===(e=v.get(i))&&(e=l(function(){o.add(i),i.setState({})}),v.set(i,e))),n=i,s(e),r(t)}),a("__e",function(r,t,e,i){s(),n=void 0,r(t,e,i)}),a("diffed",function(r,t){s(),n=void 0,r(t)}),a("unmount",function(n,r){var t=r.__c||r,e=v.get(t);if(e){v.delete(t);var i=e._d;i&&(i.forEach(function(n){return n._s.delete(e)}),i.clear())}n(r)}),a("__h",function(n,r,t,e){e<3&&f.add(r),n(r,t,e)}),e.Component.prototype.shouldComponentUpdate=function(n,r){var t,e=v.get(this);if(!(e&&0!==(null==(t=e._d)?void 0:t.size)||c.has(this)))return!0;if(o.has(this))return!0;if(f.has(this))return!0;for(var i in r)return!0;for(var u in n)if("__source"!==u&&n[u]!==this.props[u])return!0;for(var a in this.props)if(!(a in n))return!0;return!1},Object.defineProperty(exports,"Signal",{enumerable:!0,get:function(){return u.Signal}}),Object.defineProperty(exports,"batch",{enumerable:!0,get:function(){return u.batch}}),Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return u.computed}}),Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return u.effect}}),Object.defineProperty(exports,"signal",{enumerable:!0,get:function(){return u.signal}}),exports.useComputed=function(r){var t=i.useRef(r);return t.current=r,c.add(n),i.useMemo(function(){return u.computed(function(){return t.current()})},[])},exports.useSignal=function(n){return i.useMemo(function(){return u.signal(n)},[])};
//# sourceMappingURL=signals.js.map

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

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],r):r((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,r,t,e){var i,o,u,f=new WeakSet,c=new WeakSet,a=new WeakSet;function v(n,t){r.options[n]=t.bind(null,r.options[n]||function(){})}var s=new WeakMap;function d(n){u&&u(!0,!0),o=n,u=n&&n._()}function l(n){var r=e.signal(void 0);return r._c=!0,r._u=n,r}function p(n){var r=s.get(n);if(r)r.__.length=0;else{var t=[];(r=l(function(){for(var r=n.__e,e=n.props,i=0;i<t.length;i++){var o=t[i],u=e[o]._v;o in r?r[o]=u:u?r.setAttribute(o,u):r.removeAttribute(o)}})).__=t,s.set(n,r)}return r}function h(n,t,i){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(h):n instanceof e.Signal&&(i[t]=r.createElement(_,{data:n})))}function _(n){var r=this,i=n.data,u=t.useMemo(function(){for(var n=r.__v;n=n.__;)if(n.__c){a.add(n.__c);break}return o._u=function(){r.base.data=u._v},e.computed(function(){var n=i.value;return 0===n?0:!0===n?"":n||""})},[]);return u.value}v("__b",function(n,r){if("string"==typeof r.type){var t,i=r.props;for(var o in i){var u=i[o];"children"===o?h(u,"children",i):u instanceof e.Signal&&(t||(t=p(r)),t.__.push(o))}d(t)}n(r)}),v("__r",function(n,r){var t,e=r.__c;e&&(f.delete(e),void 0===(t=s.get(e))&&(t=l(function(){f.add(e),e.setState({})}),s.set(e,t))),i=e,d(t),n(r)}),v("__e",function(n,r,t,e){d(),i=void 0,n(r,t,e)}),v("diffed",function(n,r){d(),i=void 0,n(r)}),v("unmount",function(n,r){var t=r.__c||r,e=s.get(t);if(e){s.delete(t);var i=e._d;i&&(i.forEach(function(n){return n._s.delete(e)}),i.clear())}n(r)}),v("__h",function(n,r,t,e){e<3&&c.add(r),n(r,t,e)}),r.Component.prototype.shouldComponentUpdate=function(n,r){var t,e=s.get(this);if(!(e&&0!==(null==(t=e._d)?void 0:t.size)||a.has(this)))return!0;if(f.has(this))return!0;if(c.has(this))return!0;for(var i in r)return!0;for(var o in n)if("__source"!==o&&n[o]!==this.props[o])return!0;for(var u in this.props)if(!(u in n))return!0;return!1},n.useComputed=function(n){var r=t.useRef(n);return r.current=n,a.add(i),t.useMemo(function(){return e.computed(function(){return r.current()})},[])},n.useSignal=function(n){return t.useMemo(function(){return e.signal(n)},[])},Object.keys(e).forEach(function(r){"default"===r||n.hasOwnProperty(r)||Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[r]}})})});
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],e):e((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,e,r,t){var i,u,o,f=new WeakSet,c=new WeakSet,a=new WeakSet;function s(n,r){e.options[n]=r.bind(null,e.options[n]||function(){})}var v=new WeakMap;function l(n){o&&o(!0,!0),u=n,o=n&&n._()}function d(n){var e=t.signal(void 0);return e._c=!0,e._u=n,e}function b(n){var e=v.get(n);if(e)e.__.length=0;else{var r=[];(e=d(function(){for(var e=n.__e,t=n.props,i=0;i<r.length;i++){var u=r[i],o=t[u]._v;u in e?e[u]=o:o?e.setAttribute(u,o):e.removeAttribute(u)}})).__=r,v.set(n,e)}return e}function p(n,r,i){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(p):n instanceof t.Signal&&(i[r]=e.createElement(h,{data:n})))}function h(n){var e=this,i=n.data,o=r.useMemo(function(){for(var n=e.__v;n=n.__;)if(n.__c){a.add(n.__c);break}return u._u=function(){e.base.data=o._v},t.computed(function(){var n=i.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}s("__b",function(n,e){if("string"==typeof e.type){var r,i=e.props;for(var u in i){var o=i[u];"children"===u?p(o,"children",i):o instanceof t.Signal&&(r||(r=b(e)),r.__.push(u))}l(r)}n(e)}),s("__r",function(n,e){var r,t=e.__c;t&&(f.delete(t),void 0===(r=v.get(t))&&(r=d(function(){f.add(t),t.setState({})}),v.set(t,r))),i=t,l(r),n(e)}),s("__e",function(n,e,r,t){l(),i=void 0,n(e,r,t)}),s("diffed",function(n,e){l(),i=void 0,n(e)}),s("unmount",function(n,e){var r=e.__c||e,t=v.get(r);if(t){v.delete(r);var i=t._d;i&&(i.forEach(function(n){return n._s.delete(t)}),i.clear())}n(e)}),s("__h",function(n,e,r,t){t<3&&c.add(e),n(e,r,t)}),e.Component.prototype.shouldComponentUpdate=function(n,e){var r,t=v.get(this);if(!(t&&0!==(null==(r=t._d)?void 0:r.size)||a.has(this)))return!0;if(f.has(this))return!0;if(c.has(this))return!0;for(var i in e)return!0;for(var u in n)if("__source"!==u&&n[u]!==this.props[u])return!0;for(var o in this.props)if(!(o in n))return!0;return!1},Object.defineProperty(n,"Signal",{enumerable:!0,get:function(){return t.Signal}}),Object.defineProperty(n,"batch",{enumerable:!0,get:function(){return t.batch}}),Object.defineProperty(n,"computed",{enumerable:!0,get:function(){return t.computed}}),Object.defineProperty(n,"effect",{enumerable:!0,get:function(){return t.effect}}),Object.defineProperty(n,"signal",{enumerable:!0,get:function(){return t.signal}}),n.useComputed=function(n){var e=r.useRef(n);return e.current=n,a.add(i),r.useMemo(function(){return t.computed(function(){return e.current()})},[])},n.useSignal=function(n){return r.useMemo(function(){return t.signal(n)},[])}});
//# sourceMappingURL=signals.min.js.map

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

import{Component as n,options as r,createElement as t}from"preact";import{useMemo as i,useRef as o}from"preact/hooks";import{Signal as e,signal as f,computed as u}from"@preact/signals-core";export*from"@preact/signals-core";var a,c,v,s=new WeakSet,p=new WeakSet,h=new WeakSet;function l(n,t){r[n]=t.bind(null,r[n]||function(){})}var d=new WeakMap;function _(n){v&&v(!0,!0),c=n,v=n&&n._()}function m(n){var r=f(void 0);return r._c=!0,r._u=n,r}function k(n){var r=d.get(n);if(r)r.__.length=0;else{var t=[];(r=m(function(){for(var r=n.__e,i=n.props,o=0;o<t.length;o++){var e=t[o],f=i[e]._v;e in r?r[e]=f:f?r.setAttribute(e,f):r.removeAttribute(e)}})).__=t,d.set(n,r)}return r}function w(n,r,i){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(w):n instanceof e&&(i[r]=t(W,{data:n})))}function W(n){var r=this,t=n.data,o=i(function(){for(var n=r.__v;n=n.__;)if(n.__c){h.add(n.__c);break}return c._u=function(){r.base.data=o._v},u(function(){var n=t.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}function b(n){return i(function(){return f(n)},[])}function g(n){var r=o(n);return r.current=n,h.add(a),i(function(){return u(function(){return r.current()})},[])}l("__b",function(n,r){if("string"==typeof r.type){var t,i=r.props;for(var o in i){var f=i[o];"children"===o?w(f,"children",i):f instanceof e&&(t||(t=k(r)),t.__.push(o))}_(t)}n(r)}),l("__r",function(n,r){var t,i=r.__c;i&&(s.delete(i),void 0===(t=d.get(i))&&(t=m(function(){s.add(i),i.setState({})}),d.set(i,t))),a=i,_(t),n(r)}),l("__e",function(n,r,t,i){_(),a=void 0,n(r,t,i)}),l("diffed",function(n,r){_(),a=void 0,n(r)}),l("unmount",function(n,r){var t=r.__c||r,i=d.get(t);if(i){d.delete(t);var o=i._d;o&&(o.forEach(function(n){return n._s.delete(i)}),o.clear())}n(r)}),l("__h",function(n,r,t,i){i<3&&p.add(r),n(r,t,i)}),n.prototype.shouldComponentUpdate=function(n,r){var t,i=d.get(this);if(!(i&&0!==(null==(t=i._d)?void 0:t.size)||h.has(this)))return!0;if(s.has(this))return!0;if(p.has(this))return!0;for(var o in r)return!0;for(var e in n)if("__source"!==e&&n[e]!==this.props[e])return!0;for(var f in this.props)if(!(f in n))return!0;return!1};export{g as useComputed,b as useSignal};
import{Component as n,options as r,createElement as t}from"preact";import{useMemo as i,useRef as o}from"preact/hooks";import{Signal as e,signal as f,computed as u}from"@preact/signals-core";export{Signal,batch,computed,effect,signal}from"@preact/signals-core";var a,c,v,s=new WeakSet,l=new WeakSet,p=new WeakSet;function h(n,t){r[n]=t.bind(null,r[n]||function(){})}var d=new WeakMap;function _(n){v&&v(!0,!0),c=n,v=n&&n._()}function m(n){var r=f(void 0);return r._c=!0,r._u=n,r}function k(n){var r=d.get(n);if(r)r.__.length=0;else{var t=[];(r=m(function(){for(var r=n.__e,i=n.props,o=0;o<t.length;o++){var e=t[o],f=i[e]._v;e in r?r[e]=f:f?r.setAttribute(e,f):r.removeAttribute(e)}})).__=t,d.set(n,r)}return r}function g(n,r,i){"object"!=typeof n||null==n||(Array.isArray(n)?n.forEach(g):n instanceof e&&(i[r]=t(b,{data:n})))}function b(n){var r=this,t=n.data,o=i(function(){for(var n=r.__v;n=n.__;)if(n.__c){p.add(n.__c);break}return c._u=function(){r.base.data=o._v},u(function(){var n=t.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}function w(n){return i(function(){return f(n)},[])}function S(n){var r=o(n);return r.current=n,p.add(a),i(function(){return u(function(){return r.current()})},[])}h("__b",function(n,r){if("string"==typeof r.type){var t,i=r.props;for(var o in i){var f=i[o];"children"===o?g(f,"children",i):f instanceof e&&(t||(t=k(r)),t.__.push(o))}_(t)}n(r)}),h("__r",function(n,r){var t,i=r.__c;i&&(s.delete(i),void 0===(t=d.get(i))&&(t=m(function(){s.add(i),i.setState({})}),d.set(i,t))),a=i,_(t),n(r)}),h("__e",function(n,r,t,i){_(),a=void 0,n(r,t,i)}),h("diffed",function(n,r){_(),a=void 0,n(r)}),h("unmount",function(n,r){var t=r.__c||r,i=d.get(t);if(i){d.delete(t);var o=i._d;o&&(o.forEach(function(n){return n._s.delete(i)}),o.clear())}n(r)}),h("__h",function(n,r,t,i){i<3&&l.add(r),n(r,t,i)}),n.prototype.shouldComponentUpdate=function(n,r){var t,i=d.get(this);if(!(i&&0!==(null==(t=i._d)?void 0:t.size)||p.has(this)))return!0;if(s.has(this))return!0;if(l.has(this))return!0;for(var o in r)return!0;for(var e in n)if("__source"!==e&&n[e]!==this.props[e])return!0;for(var f in this.props)if(!(f in n))return!0;return!1};export{S as useComputed,w as useSignal};
//# sourceMappingURL=signals.module.js.map
{
"name": "@preact/signals",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",

@@ -10,3 +10,3 @@ "description": "",

],
"repository": "preactjs/preact",
"repository": "preactjs/signals",
"bugs": "https://github.com/preactjs/signals/issues",

@@ -24,3 +24,2 @@ "homepage": "https://preactjs.com",

"source": "src/index.ts",
"mangle": "../../mangle.json",
"exports": {

@@ -35,4 +34,5 @@ ".": {

},
"mangle": "../../mangle.json",
"dependencies": {
"@preact/signals-core": "^0.0.4"
"@preact/signals-core": "^0.0.5"
},

@@ -39,0 +39,0 @@ "peerDependencies": {

import { options, Component, createElement } from "preact";
import { useRef, useMemo } from "preact/hooks";
import { signal, computed, Signal } from "@preact/signals-core";
import {
signal,
computed,
batch,
effect,
Signal,
type ReadonlySignal,
} from "@preact/signals-core";
import {
VNode,

@@ -13,4 +20,3 @@ ComponentType,

// @todo: export Signal only as a type?
export * from "@preact/signals-core";
export { signal, computed, batch, effect, Signal, type ReadonlySignal };

@@ -17,0 +23,0 @@ // Components that have a pending Signal update: (used to bypass default sCU:false)

import * as core from "@preact/signals-core";
import * as adapter from "@preact/signals";
describe("exports", () => {
it("should re-export core", () => {
const keys = Object.keys(core);
describe("@preact/signals", () => {
describe("exports", () => {
it("should re-export core", () => {
const keys = Object.keys(core);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
expect(key in adapter).to.equal(
true,
`"${key}" is not exported from preact adapter`
);
}
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
expect(key in adapter).to.equal(
true,
`"${key}" is not exported from preact adapter`
);
}
});
});
});

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