@webreflection/signals 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var r,f,u,b,i,o=!0,n=class{static{f=s=>s.#t,u=s=>s.#s,b=(s,e)=>{s.#s=e}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return x(this.#s),this.#t}set value(s){if(this.#t=s,o){let e=this.#s;this.#s=new Set,y(e)}}peek(){return this.#t}},a=Symbol(),h=class extends n{#s=!0;#t;[a](){if(this.#s)return;this.#s=!0;let s=u(this);b(this,new Set),y(s)}get value(){return x(u(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=w(this,f(this));return this.#t}},l=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[a](){this.invalid||this.disposed||(this.invalid=!0,i||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,d(this),this.cleanup=w(this,this.fn)}},m=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let e of s)e.peek()}}},d=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(k)},S=t=>new h(t),k=t=>{t.disposed=!0,d(t)},v=t=>{let s=new l(t);return i&&i.sub.push(s),s.peek(),()=>{s.disposed||k(s)}},p=t=>{o=t},y=t=>{for(let s of t)s[a]()},x=t=>{o&&i&&t.add(i)},w=(t,s)=>{let e=i;i=t;try{return s()}finally{i=e}},T=t=>new n(t),V=t=>{let s=o;p(!1);try{return t()}finally{p(s)}};var z=t=>function(...e){let c,g=v(()=>{c??=t.apply(this,e)??this});return c[Symbol.dispose]=g,c};export{h as Computed,n as Signal,m as batch,S as computed,z as disposable,v as effect,T as signal,V as untracked};
1
+ var r,p,u,f,i,n=!0,o=class{static{p=s=>s.#t,u=s=>s.#s,f=(s,e)=>{s.#s=e}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return y(this.#s),this.#t}set value(s){if(this.#t=s,n){let e=this.#s;this.#s=new Set,k(e)}}peek(){return this.#t}},a=Symbol(),h=class extends o{#s=!0;#t;[a](){if(this.#s)return;this.#s=!0;let s=u(this);f(this,new Set),k(s)}get value(){return y(u(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=x(this,p(this));return this.#t}},l=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[a](){this.invalid||this.disposed||(this.invalid=!0,i||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,b(this),this.cleanup=x(this,this.fn)}},g=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let e of s)e.peek()}}},b=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(d)},m=t=>new h(t),d=t=>{t.disposed=!0,b(t)},v=t=>{let s=new l(t);return i&&i.sub.push(s),s.peek(),()=>{s.disposed||d(s)}},k=t=>{for(let s of t)s[a]()},y=t=>{n&&i&&t.add(i)},x=(t,s)=>{let e=i;i=t;try{return s()}finally{i=e}},S=t=>new o(t),V=t=>{let s=n;n=!1;try{return t()}finally{n=s}};var z=t=>function(...e){let c,w=v(()=>{c??=t.apply(this,e)??this});return c[Symbol.dispose]=w,c};export{h as Computed,o as Signal,g as batch,m as computed,z as disposable,v as effect,S as signal,V as untracked};
package/dist/signals.js CHANGED
@@ -1 +1 @@
1
- var r,f,o,p,e,c=!0,n=class{static{f=s=>s.#t,o=s=>s.#s,p=(s,i)=>{s.#s=i}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return v(this.#s),this.#t}set value(s){if(this.#t=s,c){let i=this.#s;this.#s=new Set,k(i)}}peek(){return this.#t}},l=Symbol(),u=class extends n{#s=!0;#t;[l](){if(this.#s)return;this.#s=!0;let s=o(this);p(this,new Set),k(s)}get value(){return v(o(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=w(this,f(this));return this.#t}},h=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[l](){this.invalid||this.disposed||(this.invalid=!0,e||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,b(this),this.cleanup=w(this,this.fn)}},y=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let i of s)i.peek()}}},b=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(d)},g=t=>new u(t),d=t=>{t.disposed=!0,b(t)},x=t=>{let s=new h(t);return e&&e.sub.push(s),s.peek(),()=>{s.disposed||d(s)}},a=t=>{c=t},k=t=>{for(let s of t)s[l]()},v=t=>{c&&e&&t.add(e)},w=(t,s)=>{let i=e;e=t;try{return s()}finally{e=i}},S=t=>new n(t),m=t=>{let s=c;a(!1);try{return t()}finally{a(s)}};export{u as Computed,n as Signal,y as batch,g as computed,x as effect,S as signal,m as untracked};
1
+ var r,a,c,f,e,n=!0,o=class{static{a=s=>s.#t,c=s=>s.#s,f=(s,i)=>{s.#s=i}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return k(this.#s),this.#t}set value(s){if(this.#t=s,n){let i=this.#s;this.#s=new Set,d(i)}}peek(){return this.#t}},l=Symbol(),u=class extends o{#s=!0;#t;[l](){if(this.#s)return;this.#s=!0;let s=c(this);f(this,new Set),d(s)}get value(){return k(c(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=v(this,a(this));return this.#t}},h=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[l](){this.invalid||this.disposed||(this.invalid=!0,e||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,p(this),this.cleanup=v(this,this.fn)}},w=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let i of s)i.peek()}}},p=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(b)},y=t=>new u(t),b=t=>{t.disposed=!0,p(t)},x=t=>{let s=new h(t);return e&&e.sub.push(s),s.peek(),()=>{s.disposed||b(s)}},d=t=>{for(let s of t)s[l]()},k=t=>{n&&e&&t.add(e)},v=(t,s)=>{let i=e;e=t;try{return s()}finally{e=i}},g=t=>new o(t),S=t=>{let s=n;n=!1;try{return t()}finally{n=s}};export{u as Computed,o as Signal,w as batch,y as computed,x as effect,g as signal,S as untracked};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webreflection/signals",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A minimalistic Preact-like signals implementation",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -140,10 +140,6 @@ export const effect = fn => {
140
140
  };
141
141
  };
142
142
 
143
- const forceTracking = value => {
144
- tracking = value;
145
- };
146
-
147
143
  const notify = subscribers => {
148
144
  for (const subscriber of subscribers) subscriber[compute]();
149
145
  };
@@ -169,7 +165,7 @@ export const signal = init => new Signal(init);
169
165
  /** @type {<T>(fn: () => T) => T} */
170
166
  export const untracked = fn => {
171
167
  const before = tracking;
172
- forceTracking(false);
168
+ tracking = false;
173
169
  try { return fn() }
174
- finally { forceTracking(before) }
170
+ finally { tracking = before }
175
171
  };