New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@preact/signals-core

Package Overview
Dependencies
Maintainers
6
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals-core - npm Package Compare versions

Comparing version
1.12.2
to
1.13.0
+45
-0
CHANGELOG.md
# @preact/signals-core
## 1.13.0
### Minor Changes
- [#812](https://github.com/preactjs/signals/pull/812) [`19ac39b`](https://github.com/preactjs/signals/commit/19ac39bb4a7a3273090753a50a58efb717f5553d) Thanks [@andrewiggins](https://github.com/andrewiggins)! - Add `createModel` and `action` to signals core package
**`createModel`** provides a structured way to create reactive model classes that encapsulate signals, computed values, and actions:
```js
const CounterModel = createModel((initialCount = 0) => {
const count = signal(initialCount);
const doubled = computed(() => count.value * 2);
effect(() => {
console.log("Count changed:", count.value);
});
return {
count,
doubled,
increment() {
count.value++;
},
};
});
const counter = new CounterModel(5);
counter.increment(); // Updates are automatically batched
counter[Symbol.dispose](); // Cleans up all effects
```
Key features:
- Factory functions can accept arguments for initialization
- All methods are automatically wrapped as actions (batched & untracked)
- Effects created during model construction are captured and disposed when the model is disposed via `Symbol.dispose`
- TypeScript validates that models only contain signals, actions, or nested objects with signals/actions
**`action`** is a helper that wraps a function to run batched and untracked:
```js
const updateAll = action(items => {
items.forEach(item => item.value++);
}); // All updates batched into single notification
```
## 1.12.2

@@ -4,0 +49,0 @@

+10
-1

@@ -133,2 +133,11 @@ declare const BRAND_SYMBOL: unique symbol;

declare function effect(fn: EffectFn, options?: EffectOptions): () => void;
export { computed, effect, batch, untracked, Signal, ReadonlySignal, Effect, Computed, };
declare function action<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
/** Models should only contain signals, actions, and nested objects containing only signals and actions. */
type ValidateModel<TModel> = {
[Key in keyof TModel]: TModel[Key] extends ReadonlySignal<unknown> ? TModel[Key] : TModel[Key] extends (...args: any[]) => any ? TModel[Key] : TModel[Key] extends object ? ValidateModel<TModel[Key]> : `Property ${Key extends string ? `'${Key}' ` : ""}is not a Signal, Action, or an object that contains only Signals and Actions.`;
};
export type Model<TModel> = ValidateModel<TModel> & Disposable;
export type ModelFactory<TModel, TFactoryArgs extends any[] = []> = (...args: TFactoryArgs) => ValidateModel<TModel>;
export type ModelConstructor<TModel, TFactoryArgs extends any[] = []> = new (...args: TFactoryArgs) => Model<TModel>;
declare function createModel<TModel, TFactoryArgs extends any[] = []>(modelFactory: ModelFactory<TModel, TFactoryArgs>): ModelConstructor<TModel, TFactoryArgs>;
export { computed, effect, batch, untracked, action, createModel, Signal, ReadonlySignal, Effect, Computed, };
+1
-1

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

var i=Symbol.for("preact-signals");function t(){if(!(s>1)){var i,t=!1;while(void 0!==n){var r=n;n=void 0;h++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&u(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}h=0;s--;if(t)throw i}else s--}var r=void 0;function o(i){var t=r;r=void 0;try{return i()}finally{r=t}}var n=void 0,s=0,h=0,f=0;function v(i){if(void 0!==r){var t=i.n;if(void 0===t||t.t!==r){t={i:0,S:i,p:r.s,n:void 0,t:r,e:void 0,x:void 0,r:t};if(void 0!==r.s)r.s.n=t;r.s=t;i.n=t;if(32&r.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=r.s;t.n=void 0;r.s.n=t;r.s=t}return t}}}function e(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}e.prototype.brand=i;e.prototype.h=function(){return!0};e.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else o(function(){var i;null==(i=t.W)||i.call(t)})}};e.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,n=i.x;if(void 0!==r){r.x=n;i.e=void 0}if(void 0!==n){n.e=r;i.x=void 0}if(i===this.t){this.t=n;if(void 0===n)o(function(){var i;null==(i=t.Z)||i.call(t)})}}};e.prototype.subscribe=function(i){var t=this;return x(function(){var o=t.value,n=r;r=void 0;try{i(o)}finally{r=n}},{name:"sub"})};e.prototype.valueOf=function(){return this.value};e.prototype.toString=function(){return this.value+""};e.prototype.toJSON=function(){return this.value};e.prototype.peek=function(){var i=r;r=void 0;try{return this.value}finally{r=i}};Object.defineProperty(e.prototype,"value",{get:function(){var i=v(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(h>100)throw new Error("Cycle detected");this.v=i;this.i++;f++;s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{t()}}}});function u(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function d(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function c(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function a(i,t){e.call(this,void 0);this.x=i;this.s=void 0;this.g=f-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}a.prototype=new e;a.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===f)return!0;this.g=f;this.f|=1;if(this.i>0&&!u(this)){this.f&=-2;return!0}var i=r;try{d(this);r=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}r=i;c(this);this.f&=-2;return!0};a.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}e.prototype.S.call(this,i)};a.prototype.U=function(i){if(void 0!==this.t){e.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};a.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(a.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=v(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function l(i){var o=i.u;i.u=void 0;if("function"==typeof o){s++;var n=r;r=void 0;try{o()}catch(t){i.f&=-2;i.f|=8;y(i);throw t}finally{r=n;t()}}}function y(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;l(i)}function w(i){if(r!==this)throw new Error("Out-of-order effect");c(this);r=i;this.f&=-2;if(8&this.f)y(this);t()}function p(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name}p.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};p.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;l(this);d(this);s++;var i=r;r=this;return w.bind(this,i)};p.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=n;n=this}};p.prototype.d=function(){this.f|=8;if(!(1&this.f))y(this)};p.prototype.dispose=function(){this.d()};function x(i,t){var r=new p(i,t);try{r.c()}catch(i){r.d();throw i}var o=r.d.bind(r);o[Symbol.dispose]=o;return o}exports.Computed=a;exports.Effect=p;exports.Signal=e;exports.batch=function(i){if(s>0)return i();s++;try{return i()}finally{t()}};exports.computed=function(i,t){return new a(i,t)};exports.effect=x;exports.signal=function(i,t){return new e(i,t)};exports.untracked=o;//# sourceMappingURL=signals-core.js.map
var i=Symbol.for("preact-signals");function t(){if(!(h>1)){var i,t=!1;while(void 0!==f){var r=f;f=void 0;v++;while(void 0!==r){var n=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&c(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=n}}v=0;h--;if(t)throw i}else h--}function r(i){if(h>0)return i();h++;try{return i()}finally{t()}}var n=void 0;function o(i){var t=n;n=void 0;try{return i()}finally{n=t}}var s,f=void 0,h=0,v=0,e=0;function u(i){if(void 0!==n){var t=i.n;if(void 0===t||t.t!==n){t={i:0,S:i,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:t};if(void 0!==n.s)n.s.n=t;n.s=t;i.n=t;if(32&n.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=n.s;t.n=void 0;n.s.n=t;n.s=t}return t}}}function d(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}d.prototype.brand=i;d.prototype.h=function(){return!0};d.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else o(function(){var i;null==(i=t.W)||i.call(t)})}};d.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,n=i.x;if(void 0!==r){r.x=n;i.e=void 0}if(void 0!==n){n.e=r;i.x=void 0}if(i===this.t){this.t=n;if(void 0===n)o(function(){var i;null==(i=t.Z)||i.call(t)})}}};d.prototype.subscribe=function(i){var t=this;return _(function(){var r=t.value,o=n;n=void 0;try{i(r)}finally{n=o}},{name:"sub"})};d.prototype.valueOf=function(){return this.value};d.prototype.toString=function(){return this.value+""};d.prototype.toJSON=function(){return this.value};d.prototype.peek=function(){var i=n;n=void 0;try{return this.value}finally{n=i}};Object.defineProperty(d.prototype,"value",{get:function(){var i=u(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(v>100)throw new Error("Cycle detected");this.v=i;this.i++;e++;h++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{t()}}}});function c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function l(i){var t=i.s,r=void 0;while(void 0!==t){var n=t.p;if(-1===t.i){t.S.U(t);if(void 0!==n)n.n=t.n;if(void 0!==t.n)t.n.p=n}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=n}i.s=r}function y(i,t){d.call(this,void 0);this.x=i;this.s=void 0;this.g=e-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}y.prototype=new d;y.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===e)return!0;this.g=e;this.f|=1;if(this.i>0&&!c(this)){this.f&=-2;return!0}var i=n;try{a(this);n=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}n=i;l(this);this.f&=-2;return!0};y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}d.prototype.S.call(this,i)};y.prototype.U=function(i){if(void 0!==this.t){d.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=u(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function w(i){var r=i.u;i.u=void 0;if("function"==typeof r){h++;var o=n;n=void 0;try{r()}catch(t){i.f&=-2;i.f|=8;p(i);throw t}finally{n=o;t()}}}function p(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;w(i)}function x(i){if(n!==this)throw new Error("Out-of-order effect");l(this);n=i;this.f&=-2;if(8&this.f)p(this);t()}function b(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name;if(s)s.push(this)}b.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;w(this);a(this);h++;var i=n;n=this;return x.bind(this,i)};b.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=f;f=this}};b.prototype.d=function(){this.f|=8;if(!(1&this.f))p(this)};b.prototype.dispose=function(){this.d()};function _(i,t){var r=new b(i,t);try{r.c()}catch(i){r.d();throw i}var n=r.d.bind(r);n[Symbol.dispose]=n;return n}function g(i){return function(){var t=arguments,n=this;return r(function(){return o(function(){return i.apply(n,[].slice.call(t))})})}}function S(){var i=s;s=[];return function(){var t=s;if(s&&i)i=i.concat(s);s=i;return t}}exports.Computed=y;exports.Effect=b;exports.Signal=d;exports.action=g;exports.batch=r;exports.computed=function(i,t){return new y(i,t)};exports.createModel=function(i){return function(){var t,r,n=S();try{r=i.apply(void 0,[].slice.call(arguments))}catch(i){s=void 0;throw i}finally{t=n()}for(var o in r)if("function"==typeof r[o])r[o]=g(r[o]);r[Symbol.dispose]=g(function(){if(t)for(var i=0;i<t.length;i++)t[i].dispose();t=void 0});return r}};exports.effect=_;exports.signal=function(i,t){return new d(i,t)};exports.untracked=o;//# sourceMappingURL=signals-core.js.map

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

!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((i||self).preactSignalsCore={})}(this,function(i){var t=Symbol.for("preact-signals");function o(){if(!(s>1)){var i,t=!1;while(void 0!==h){var o=h;h=void 0;f++;while(void 0!==o){var n=o.o;o.o=void 0;o.f&=-3;if(!(8&o.f)&&d(o))try{o.c()}catch(o){if(!t){i=o;t=!0}}o=n}}f=0;s--;if(t)throw i}else s--}var n=void 0;function r(i){var t=n;n=void 0;try{return i()}finally{n=t}}var h=void 0,s=0,f=0,v=0;function e(i){if(void 0!==n){var t=i.n;if(void 0===t||t.t!==n){t={i:0,S:i,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:t};if(void 0!==n.s)n.s.n=t;n.s=t;i.n=t;if(32&n.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=n.s;t.n=void 0;n.s.n=t;n.s=t}return t}}}function u(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}u.prototype.brand=t;u.prototype.h=function(){return!0};u.prototype.S=function(i){var t=this,o=this.t;if(o!==i&&void 0===i.e){i.x=o;this.t=i;if(void 0!==o)o.e=i;else r(function(){var i;null==(i=t.W)||i.call(t)})}};u.prototype.U=function(i){var t=this;if(void 0!==this.t){var o=i.e,n=i.x;if(void 0!==o){o.x=n;i.e=void 0}if(void 0!==n){n.e=o;i.x=void 0}if(i===this.t){this.t=n;if(void 0===n)r(function(){var i;null==(i=t.Z)||i.call(t)})}}};u.prototype.subscribe=function(i){var t=this;return g(function(){var o=t.value,r=n;n=void 0;try{i(o)}finally{n=r}},{name:"sub"})};u.prototype.valueOf=function(){return this.value};u.prototype.toString=function(){return this.value+""};u.prototype.toJSON=function(){return this.value};u.prototype.peek=function(){var i=n;n=void 0;try{return this.value}finally{n=i}};Object.defineProperty(u.prototype,"value",{get:function(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(f>100)throw new Error("Cycle detected");this.v=i;this.i++;v++;s++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{o()}}}});function d(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function c(i){for(var t=i.s;void 0!==t;t=t.n){var o=t.S.n;if(void 0!==o)t.r=o;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function a(i){var t=i.s,o=void 0;while(void 0!==t){var n=t.p;if(-1===t.i){t.S.U(t);if(void 0!==n)n.n=t.n;if(void 0!==t.n)t.n.p=n}else o=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=n}i.s=o}function l(i,t){u.call(this,void 0);this.x=i;this.s=void 0;this.g=v-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}l.prototype=new u;l.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===v)return!0;this.g=v;this.f|=1;if(this.i>0&&!d(this)){this.f&=-2;return!0}var i=n;try{c(this);n=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}n=i;a(this);this.f&=-2;return!0};l.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}u.prototype.S.call(this,i)};l.prototype.U=function(i){if(void 0!==this.t){u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};l.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(l.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function y(i){var t=i.u;i.u=void 0;if("function"==typeof t){s++;var r=n;n=void 0;try{t()}catch(t){i.f&=-2;i.f|=8;w(i);throw t}finally{n=r;o()}}}function w(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;y(i)}function p(i){if(n!==this)throw new Error("Out-of-order effect");a(this);n=i;this.f&=-2;if(8&this.f)w(this);o()}function b(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name}b.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;y(this);c(this);s++;var i=n;n=this;return p.bind(this,i)};b.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=h;h=this}};b.prototype.d=function(){this.f|=8;if(!(1&this.f))w(this)};b.prototype.dispose=function(){this.d()};function g(i,t){var o=new b(i,t);try{o.c()}catch(i){o.d();throw i}var n=o.d.bind(o);n[Symbol.dispose]=n;return n}i.Computed=l;i.Effect=b;i.Signal=u;i.batch=function(i){if(s>0)return i();s++;try{return i()}finally{o()}};i.computed=function(i,t){return new l(i,t)};i.effect=g;i.signal=function(i,t){return new u(i,t)};i.untracked=r});//# sourceMappingURL=signals-core.min.js.map
!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((i||self).preactSignalsCore={})}(this,function(i){var t=Symbol.for("preact-signals");function n(){if(!(v>1)){var i,t=!1;while(void 0!==s){var n=s;s=void 0;e++;while(void 0!==n){var o=n.o;n.o=void 0;n.f&=-3;if(!(8&n.f)&&a(n))try{n.c()}catch(n){if(!t){i=n;t=!0}}n=o}}e=0;v--;if(t)throw i}else v--}function o(i){if(v>0)return i();v++;try{return i()}finally{n()}}var r=void 0;function f(i){var t=r;r=void 0;try{return i()}finally{r=t}}var h,s=void 0,v=0,e=0,u=0;function d(i){if(void 0!==r){var t=i.n;if(void 0===t||t.t!==r){t={i:0,S:i,p:r.s,n:void 0,t:r,e:void 0,x:void 0,r:t};if(void 0!==r.s)r.s.n=t;r.s=t;i.n=t;if(32&r.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=r.s;t.n=void 0;r.s.n=t;r.s=t}return t}}}function c(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}c.prototype.brand=t;c.prototype.h=function(){return!0};c.prototype.S=function(i){var t=this,n=this.t;if(n!==i&&void 0===i.e){i.x=n;this.t=i;if(void 0!==n)n.e=i;else f(function(){var i;null==(i=t.W)||i.call(t)})}};c.prototype.U=function(i){var t=this;if(void 0!==this.t){var n=i.e,o=i.x;if(void 0!==n){n.x=o;i.e=void 0}if(void 0!==o){o.e=n;i.x=void 0}if(i===this.t){this.t=o;if(void 0===o)f(function(){var i;null==(i=t.Z)||i.call(t)})}}};c.prototype.subscribe=function(i){var t=this;return m(function(){var n=t.value,o=r;r=void 0;try{i(n)}finally{r=o}},{name:"sub"})};c.prototype.valueOf=function(){return this.value};c.prototype.toString=function(){return this.value+""};c.prototype.toJSON=function(){return this.value};c.prototype.peek=function(){var i=r;r=void 0;try{return this.value}finally{r=i}};Object.defineProperty(c.prototype,"value",{get:function(){var i=d(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(e>100)throw new Error("Cycle detected");this.v=i;this.i++;u++;v++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{n()}}}});function a(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function l(i){for(var t=i.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n)t.r=n;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function y(i){var t=i.s,n=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else n=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=n}function w(i,t){c.call(this,void 0);this.x=i;this.s=void 0;this.g=u-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}w.prototype=new c;w.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===u)return!0;this.g=u;this.f|=1;if(this.i>0&&!a(this)){this.f&=-2;return!0}var i=r;try{l(this);r=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}r=i;y(this);this.f&=-2;return!0};w.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}c.prototype.S.call(this,i)};w.prototype.U=function(i){if(void 0!==this.t){c.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};w.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(w.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=d(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function p(i){var t=i.u;i.u=void 0;if("function"==typeof t){v++;var o=r;r=void 0;try{t()}catch(t){i.f&=-2;i.f|=8;b(i);throw t}finally{r=o;n()}}}function b(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;p(i)}function g(i){if(r!==this)throw new Error("Out-of-order effect");y(this);r=i;this.f&=-2;if(8&this.f)b(this);n()}function _(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name;if(h)h.push(this)}_.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};_.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;p(this);l(this);v++;var i=r;r=this;return g.bind(this,i)};_.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=s;s=this}};_.prototype.d=function(){this.f|=8;if(!(1&this.f))b(this)};_.prototype.dispose=function(){this.d()};function m(i,t){var n=new _(i,t);try{n.c()}catch(i){n.d();throw i}var o=n.d.bind(n);o[Symbol.dispose]=o;return o}function x(i){return function(){var t=arguments,n=this;return o(function(){return f(function(){return i.apply(n,[].slice.call(t))})})}}function S(){var i=h;h=[];return function(){var t=h;if(h&&i)i=i.concat(h);h=i;return t}}i.Computed=w;i.Effect=_;i.Signal=c;i.action=x;i.batch=o;i.computed=function(i,t){return new w(i,t)};i.createModel=function(i){return function(){var t,n,o=S();try{n=i.apply(void 0,[].slice.call(arguments))}catch(i){h=void 0;throw i}finally{t=o()}for(var r in n)if("function"==typeof n[r])n[r]=x(n[r]);n[Symbol.dispose]=x(function(){if(t)for(var i=0;i<t.length;i++)t[i].dispose();t=void 0});return n}};i.effect=m;i.signal=function(i,t){return new c(i,t)};i.untracked=f});//# sourceMappingURL=signals-core.min.js.map

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

const i=Symbol.for("preact-signals");function t(){if(r>1){r--;return}let i,t=!1;while(void 0!==s){let o=s;s=void 0;f++;while(void 0!==o){const n=o.o;o.o=void 0;o.f&=-3;if(!(8&o.f)&&v(o))try{o.c()}catch(o){if(!t){i=o;t=!0}}o=n}}f=0;r--;if(t)throw i}function o(i){if(r>0)return i();r++;try{return i()}finally{t()}}let n,s;function h(i){const t=n;n=void 0;try{return i()}finally{n=t}}let r=0,f=0,e=0;function u(i){if(void 0===n)return;let t=i.n;if(void 0===t||t.t!==n){t={i:0,S:i,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:t};if(void 0!==n.s)n.s.n=t;n.s=t;i.n=t;if(32&n.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=n.s;t.n=void 0;n.s.n=t;n.s=t}return t}}function c(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}c.prototype.brand=i;c.prototype.h=function(){return!0};c.prototype.S=function(i){const t=this.t;if(t!==i&&void 0===i.e){i.x=t;this.t=i;if(void 0!==t)t.e=i;else h(()=>{var i;null==(i=this.W)||i.call(this)})}};c.prototype.U=function(i){if(void 0!==this.t){const t=i.e,o=i.x;if(void 0!==t){t.x=o;i.e=void 0}if(void 0!==o){o.e=t;i.x=void 0}if(i===this.t){this.t=o;if(void 0===o)h(()=>{var i;null==(i=this.Z)||i.call(this)})}}};c.prototype.subscribe=function(i){return E(()=>{const t=this.value,o=n;n=void 0;try{i(t)}finally{n=o}},{name:"sub"})};c.prototype.valueOf=function(){return this.value};c.prototype.toString=function(){return this.value+""};c.prototype.toJSON=function(){return this.value};c.prototype.peek=function(){const i=n;n=void 0;try{return this.value}finally{n=i}};Object.defineProperty(c.prototype,"value",{get(){const i=u(this);if(void 0!==i)i.i=this.i;return this.v},set(i){if(i!==this.v){if(f>100)throw new Error("Cycle detected");this.v=i;this.i++;e++;r++;try{for(let i=this.t;void 0!==i;i=i.x)i.t.N()}finally{t()}}}});function d(i,t){return new c(i,t)}function v(i){for(let t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function l(i){for(let t=i.s;void 0!==t;t=t.n){const o=t.S.n;if(void 0!==o)t.r=o;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function y(i){let t,o=i.s;while(void 0!==o){const i=o.p;if(-1===o.i){o.S.U(o);if(void 0!==i)i.n=o.n;if(void 0!==o.n)o.n.p=i}else t=o;o.S.n=o.r;if(void 0!==o.r)o.r=void 0;o=i}i.s=t}function a(i,t){c.call(this,void 0);this.x=i;this.s=void 0;this.g=e-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}a.prototype=new c;a.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===e)return!0;this.g=e;this.f|=1;if(this.i>0&&!v(this)){this.f&=-2;return!0}const i=n;try{l(this);n=this;const i=this.x();if(16&this.f||this.v!==i||0===this.i){this.v=i;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}n=i;y(this);this.f&=-2;return!0};a.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(let i=this.s;void 0!==i;i=i.n)i.S.S(i)}c.prototype.S.call(this,i)};a.prototype.U=function(i){if(void 0!==this.t){c.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(let i=this.s;void 0!==i;i=i.n)i.S.U(i)}}};a.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(a.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const i=u(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function w(i,t){return new a(i,t)}function _(i){const o=i.u;i.u=void 0;if("function"==typeof o){r++;const s=n;n=void 0;try{o()}catch(t){i.f&=-2;i.f|=8;b(i);throw t}finally{n=s;t()}}}function b(i){for(let t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i)}function g(i){if(n!==this)throw new Error("Out-of-order effect");y(this);n=i;this.f&=-2;if(8&this.f)b(this);t()}function p(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name}p.prototype.c=function(){const i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();if("function"==typeof t)this.u=t}finally{i()}};p.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;_(this);l(this);r++;const i=n;n=this;return g.bind(this,i)};p.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=s;s=this}};p.prototype.d=function(){this.f|=8;if(!(1&this.f))b(this)};p.prototype.dispose=function(){this.d()};function E(i,t){const o=new p(i,t);try{o.c()}catch(i){o.d();throw i}const n=o.d.bind(o);n[Symbol.dispose]=n;return n}export{a as Computed,p as Effect,c as Signal,o as batch,w as computed,E as effect,d as signal,h as untracked};//# sourceMappingURL=signals-core.mjs.map
const i=Symbol.for("preact-signals");function t(){if(f>1){f--;return}let i,t=!1;while(void 0!==s){let n=s;s=void 0;e++;while(void 0!==n){const o=n.o;n.o=void 0;n.f&=-3;if(!(8&n.f)&&l(n))try{n.c()}catch(n){if(!t){i=n;t=!0}}n=o}}e=0;f--;if(t)throw i}function n(i){if(f>0)return i();f++;try{return i()}finally{t()}}let o,s;function h(i){const t=o;o=void 0;try{return i()}finally{o=t}}let r,f=0,e=0,u=0;function c(i){if(void 0===o)return;let t=i.n;if(void 0===t||t.t!==o){t={i:0,S:i,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t};if(void 0!==o.s)o.s.n=t;o.s=t;i.n=t;if(32&o.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=o.s;t.n=void 0;o.s.n=t;o.s=t}return t}}function d(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}d.prototype.brand=i;d.prototype.h=function(){return!0};d.prototype.S=function(i){const t=this.t;if(t!==i&&void 0===i.e){i.x=t;this.t=i;if(void 0!==t)t.e=i;else h(()=>{var i;null==(i=this.W)||i.call(this)})}};d.prototype.U=function(i){if(void 0!==this.t){const t=i.e,n=i.x;if(void 0!==t){t.x=n;i.e=void 0}if(void 0!==n){n.e=t;i.x=void 0}if(i===this.t){this.t=n;if(void 0===n)h(()=>{var i;null==(i=this.Z)||i.call(this)})}}};d.prototype.subscribe=function(i){return m(()=>{const t=this.value,n=o;o=void 0;try{i(t)}finally{o=n}},{name:"sub"})};d.prototype.valueOf=function(){return this.value};d.prototype.toString=function(){return this.value+""};d.prototype.toJSON=function(){return this.value};d.prototype.peek=function(){const i=o;o=void 0;try{return this.value}finally{o=i}};Object.defineProperty(d.prototype,"value",{get(){const i=c(this);if(void 0!==i)i.i=this.i;return this.v},set(i){if(i!==this.v){if(e>100)throw new Error("Cycle detected");this.v=i;this.i++;u++;f++;try{for(let i=this.t;void 0!==i;i=i.x)i.t.N()}finally{t()}}}});function v(i,t){return new d(i,t)}function l(i){for(let t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function y(i){for(let t=i.s;void 0!==t;t=t.n){const n=t.S.n;if(void 0!==n)t.r=n;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function a(i){let t,n=i.s;while(void 0!==n){const i=n.p;if(-1===n.i){n.S.U(n);if(void 0!==i)i.n=n.n;if(void 0!==n.n)n.n.p=i}else t=n;n.S.n=n.r;if(void 0!==n.r)n.r=void 0;n=i}i.s=t}function w(i,t){d.call(this,void 0);this.x=i;this.s=void 0;this.g=u-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}w.prototype=new d;w.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===u)return!0;this.g=u;this.f|=1;if(this.i>0&&!l(this)){this.f&=-2;return!0}const i=o;try{y(this);o=this;const i=this.x();if(16&this.f||this.v!==i||0===this.i){this.v=i;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}o=i;a(this);this.f&=-2;return!0};w.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(let i=this.s;void 0!==i;i=i.n)i.S.S(i)}d.prototype.S.call(this,i)};w.prototype.U=function(i){if(void 0!==this.t){d.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(let i=this.s;void 0!==i;i=i.n)i.S.U(i)}}};w.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(w.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const i=c(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function b(i,t){return new w(i,t)}function _(i){const n=i.u;i.u=void 0;if("function"==typeof n){f++;const s=o;o=void 0;try{n()}catch(t){i.f&=-2;i.f|=8;p(i);throw t}finally{o=s;t()}}}function p(i){for(let t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i)}function g(i){if(o!==this)throw new Error("Out-of-order effect");a(this);o=i;this.f&=-2;if(8&this.f)p(this);t()}function S(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name;if(r)r.push(this)}S.prototype.c=function(){const i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();if("function"==typeof t)this.u=t}finally{i()}};S.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;_(this);y(this);f++;const i=o;o=this;return g.bind(this,i)};S.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=s;s=this}};S.prototype.d=function(){this.f|=8;if(!(1&this.f))p(this)};S.prototype.dispose=function(){this.d()};function m(i,t){const n=new S(i,t);try{n.c()}catch(i){n.d();throw i}const o=n.d.bind(n);o[Symbol.dispose]=o;return o}function E(i){return function(...t){return n(()=>h(()=>i.apply(this,t)))}}function x(i){return function(...t){let n,o;const s=function(){let i=r;r=[];return function(){let t=r;if(r&&i)i=i.concat(r);r=i;return t}}();try{o=i(...t)}catch(i){r=void 0;throw i}finally{n=s()}for(const i in o)if("function"==typeof o[i])o[i]=E(o[i]);o[Symbol.dispose]=E(function(){if(n)for(let i=0;i<n.length;i++)n[i].dispose();n=void 0});return o}}export{w as Computed,S as Effect,d as Signal,E as action,n as batch,b as computed,x as createModel,m as effect,v as signal,h as untracked};//# sourceMappingURL=signals-core.mjs.map

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

var i=Symbol.for("preact-signals");function t(){if(!(s>1)){var i,t=!1;while(void 0!==h){var r=h;h=void 0;f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&c(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}f=0;s--;if(t)throw i}else s--}function r(i){if(s>0)return i();s++;try{return i()}finally{t()}}var o=void 0;function n(i){var t=o;o=void 0;try{return i()}finally{o=t}}var h=void 0,s=0,f=0,v=0;function e(i){if(void 0!==o){var t=i.n;if(void 0===t||t.t!==o){t={i:0,S:i,p:o.s,n:void 0,t:o,e:void 0,x:void 0,r:t};if(void 0!==o.s)o.s.n=t;o.s=t;i.n=t;if(32&o.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=o.s;t.n=void 0;o.s.n=t;o.s=t}return t}}}function u(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}u.prototype.brand=i;u.prototype.h=function(){return!0};u.prototype.S=function(i){var t=this,r=this.t;if(r!==i&&void 0===i.e){i.x=r;this.t=i;if(void 0!==r)r.e=i;else n(function(){var i;null==(i=t.W)||i.call(t)})}};u.prototype.U=function(i){var t=this;if(void 0!==this.t){var r=i.e,o=i.x;if(void 0!==r){r.x=o;i.e=void 0}if(void 0!==o){o.e=r;i.x=void 0}if(i===this.t){this.t=o;if(void 0===o)n(function(){var i;null==(i=t.Z)||i.call(t)})}}};u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=o;o=void 0;try{i(r)}finally{o=n}},{name:"sub"})};u.prototype.valueOf=function(){return this.value};u.prototype.toString=function(){return this.value+""};u.prototype.toJSON=function(){return this.value};u.prototype.peek=function(){var i=o;o=void 0;try{return this.value}finally{o=i}};Object.defineProperty(u.prototype,"value",{get:function(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(f>100)throw new Error("Cycle detected");this.v=i;this.i++;v++;s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{t()}}}});function d(i,t){return new u(i,t)}function c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function y(i,t){u.call(this,void 0);this.x=i;this.s=void 0;this.g=v-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}y.prototype=new u;y.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===v)return!0;this.g=v;this.f|=1;if(this.i>0&&!c(this)){this.f&=-2;return!0}var i=o;try{a(this);o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}o=i;l(this);this.f&=-2;return!0};y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}u.prototype.S.call(this,i)};y.prototype.U=function(i){if(void 0!==this.t){u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function w(i,t){return new y(i,t)}function _(i){var r=i.u;i.u=void 0;if("function"==typeof r){s++;var n=o;o=void 0;try{r()}catch(t){i.f&=-2;i.f|=8;b(i);throw t}finally{o=n;t()}}}function b(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i)}function g(i){if(o!==this)throw new Error("Out-of-order effect");l(this);o=i;this.f&=-2;if(8&this.f)b(this);t()}function p(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name}p.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};p.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;_(this);a(this);s++;var i=o;o=this;return g.bind(this,i)};p.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=h;h=this}};p.prototype.d=function(){this.f|=8;if(!(1&this.f))b(this)};p.prototype.dispose=function(){this.d()};function E(i,t){var r=new p(i,t);try{r.c()}catch(i){r.d();throw i}var o=r.d.bind(r);o[Symbol.dispose]=o;return o}export{y as Computed,p as Effect,u as Signal,r as batch,w as computed,E as effect,d as signal,n as untracked};//# sourceMappingURL=signals-core.module.js.map
var i=Symbol.for("preact-signals");function t(){if(!(s>1)){var i,t=!1;while(void 0!==h){var n=h;h=void 0;v++;while(void 0!==n){var r=n.o;n.o=void 0;n.f&=-3;if(!(8&n.f)&&a(n))try{n.c()}catch(n){if(!t){i=n;t=!0}}n=r}}v=0;s--;if(t)throw i}else s--}function n(i){if(s>0)return i();s++;try{return i()}finally{t()}}var r=void 0;function o(i){var t=r;r=void 0;try{return i()}finally{r=t}}var f,h=void 0,s=0,v=0,u=0;function e(i){if(void 0!==r){var t=i.n;if(void 0===t||t.t!==r){t={i:0,S:i,p:r.s,n:void 0,t:r,e:void 0,x:void 0,r:t};if(void 0!==r.s)r.s.n=t;r.s=t;i.n=t;if(32&r.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=r.s;t.n=void 0;r.s.n=t;r.s=t}return t}}}function d(i,t){this.v=i;this.i=0;this.n=void 0;this.t=void 0;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}d.prototype.brand=i;d.prototype.h=function(){return!0};d.prototype.S=function(i){var t=this,n=this.t;if(n!==i&&void 0===i.e){i.x=n;this.t=i;if(void 0!==n)n.e=i;else o(function(){var i;null==(i=t.W)||i.call(t)})}};d.prototype.U=function(i){var t=this;if(void 0!==this.t){var n=i.e,r=i.x;if(void 0!==n){n.x=r;i.e=void 0}if(void 0!==r){r.e=n;i.x=void 0}if(i===this.t){this.t=r;if(void 0===r)o(function(){var i;null==(i=t.Z)||i.call(t)})}}};d.prototype.subscribe=function(i){var t=this;return m(function(){var n=t.value,o=r;r=void 0;try{i(n)}finally{r=o}},{name:"sub"})};d.prototype.valueOf=function(){return this.value};d.prototype.toString=function(){return this.value+""};d.prototype.toJSON=function(){return this.value};d.prototype.peek=function(){var i=r;r=void 0;try{return this.value}finally{r=i}};Object.defineProperty(d.prototype,"value",{get:function(){var i=e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(v>100)throw new Error("Cycle detected");this.v=i;this.i++;u++;s++;try{for(var n=this.t;void 0!==n;n=n.x)n.t.N()}finally{t()}}}});function c(i,t){return new d(i,t)}function a(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function l(i){for(var t=i.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n)t.r=n;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function y(i){var t=i.s,n=void 0;while(void 0!==t){var r=t.p;if(-1===t.i){t.S.U(t);if(void 0!==r)r.n=t.n;if(void 0!==t.n)t.n.p=r}else n=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=r}i.s=n}function w(i,t){d.call(this,void 0);this.x=i;this.s=void 0;this.g=u-1;this.f=4;this.W=null==t?void 0:t.watched;this.Z=null==t?void 0:t.unwatched;this.name=null==t?void 0:t.name}w.prototype=new d;w.prototype.h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===u)return!0;this.g=u;this.f|=1;if(this.i>0&&!a(this)){this.f&=-2;return!0}var i=r;try{l(this);r=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}r=i;y(this);this.f&=-2;return!0};w.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}d.prototype.S.call(this,i)};w.prototype.U=function(i){if(void 0!==this.t){d.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};w.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(w.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function b(i,t){return new w(i,t)}function _(i){var n=i.u;i.u=void 0;if("function"==typeof n){s++;var o=r;r=void 0;try{n()}catch(t){i.f&=-2;i.f|=8;p(i);throw t}finally{r=o;t()}}}function p(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i)}function g(i){if(r!==this)throw new Error("Out-of-order effect");y(this);r=i;this.f&=-2;if(8&this.f)p(this);t()}function S(i,t){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32;this.name=null==t?void 0:t.name;if(f)f.push(this)}S.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};S.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;_(this);l(this);s++;var i=r;r=this;return g.bind(this,i)};S.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=h;h=this}};S.prototype.d=function(){this.f|=8;if(!(1&this.f))p(this)};S.prototype.dispose=function(){this.d()};function m(i,t){var n=new S(i,t);try{n.c()}catch(i){n.d();throw i}var r=n.d.bind(n);r[Symbol.dispose]=r;return r}function E(i){return function(){var t=arguments,r=this;return n(function(){return o(function(){return i.apply(r,[].slice.call(t))})})}}function x(){var i=f;f=[];return function(){var t=f;if(f&&i)i=i.concat(f);f=i;return t}}function C(i){return function(){var t,n,r=x();try{n=i.apply(void 0,[].slice.call(arguments))}catch(i){f=void 0;throw i}finally{t=r()}for(var o in n)if("function"==typeof n[o])n[o]=E(n[o]);n[Symbol.dispose]=E(function(){if(t)for(var i=0;i<t.length;i++)t[i].dispose();t=void 0});return n}}export{w as Computed,S as Effect,d as Signal,E as action,n as batch,b as computed,C as createModel,m as effect,c as signal,o as untracked};//# sourceMappingURL=signals-core.module.js.map
{
"name": "@preact/signals-core",
"version": "1.12.2",
"version": "1.13.0",
"license": "MIT",

@@ -44,2 +44,3 @@ "description": "Manage state with style in every framework",

"publishConfig": {
"access": "public",
"provenance": true

@@ -46,0 +47,0 @@ },

@@ -215,2 +215,4 @@ // An named symbol/brand for detecting Signal instances even when they weren't

//#region Signal
/**

@@ -433,2 +435,6 @@ * The base class for plain and computed signals.

//#endregion Signal
//#region Computed
function needsToRecompute(target: Computed | Effect): boolean {

@@ -731,2 +737,6 @@ // Check the dependencies for changed values. The dependency list is already

//#endregion Computed
//#region Effect
function cleanupEffect(effect: Effect) {

@@ -813,2 +823,4 @@ const cleanup = effect._cleanup;

let capturedEffects: Effect[] | undefined;
/** @internal */

@@ -822,2 +834,6 @@ function Effect(this: Effect, fn: EffectFn, options?: EffectOptions) {

this.name = options?.name;
if (capturedEffects) {
capturedEffects.push(this);
}
}

@@ -902,2 +918,134 @@

//#endregion Effect
//#region Action
function action<TArgs extends unknown[], TReturn>(
fn: (...args: TArgs) => TReturn
): (...args: TArgs) => TReturn {
return function actionWrapper(this: unknown, ...args: TArgs) {
return batch(() => untracked(() => fn.apply(this, args)));
};
}
//#endregion Action
//#region createModel
/** Models should only contain signals, actions, and nested objects containing only signals and actions. */
type ValidateModel<TModel> = {
[Key in keyof TModel]: TModel[Key] extends ReadonlySignal<unknown>
? TModel[Key]
: TModel[Key] extends (...args: any[]) => any
? TModel[Key]
: TModel[Key] extends object
? ValidateModel<TModel[Key]>
: `Property ${Key extends string ? `'${Key}' ` : ""}is not a Signal, Action, or an object that contains only Signals and Actions.`;
};
export type Model<TModel> = ValidateModel<TModel> & Disposable;
export type ModelFactory<TModel, TFactoryArgs extends any[] = []> = (
...args: TFactoryArgs
) => ValidateModel<TModel>;
export type ModelConstructor<TModel, TFactoryArgs extends any[] = []> = new (
...args: TFactoryArgs
) => Model<TModel>;
/**
* The public types for ModelConstructor require using `new` to help
* disambiguate the function passed into `createModel` and the returned
* constructor function. It is easier to say that `createModel` accepts
* a factory and returns a class, then to say it accepts a factory and
* returns a factory. In other words, this example:
*
* ```ts
* const PersonModel = createModel((name: string) => ({ ... }));
* const person = new PersonModel("John");
* ```
*
* is easier to understand than this example:
*
* ```ts
* const createPerson = createModel((name: string) => ({ ... }));
* const person = createPerson("John");
* ```
*
* However, internally we implement `createModel` to return a function
* that can be called without `new` for simplicity. To bridge the gap
* between the public types and the internal implementation, we define
* this internal interface that extends the public interface but also
* allows calling without `new`.
*
* This pattern is used by the Preact & React adapters to make instantiating
* a model or a function that returns a model easier.
*
* @internal
*/
interface InternalModelConstructor<TModel, TFactoryArgs extends any[]>
extends ModelConstructor<TModel, TFactoryArgs> {
(...args: TFactoryArgs): Model<TModel>;
}
function startCapturingEffects(): () => Effect[] | undefined {
let prevCapturedEffects = capturedEffects;
capturedEffects = [];
return function stopCapturingEffects() {
let modelEffects = capturedEffects;
if (capturedEffects && prevCapturedEffects) {
prevCapturedEffects = prevCapturedEffects.concat(capturedEffects);
}
capturedEffects = prevCapturedEffects;
return modelEffects;
};
}
function createModel<TModel, TFactoryArgs extends any[] = []>(
modelFactory: ModelFactory<TModel, TFactoryArgs>
): ModelConstructor<TModel, TFactoryArgs> {
return function SignalModel(...args: TFactoryArgs): Model<TModel> {
let modelEffects: Effect[] | undefined;
let model: Model<TModel>;
const stopCapturingEffects = startCapturingEffects();
try {
model = modelFactory(...args) as Model<TModel>;
} catch (err) {
// Drop any captured effects on error. Errors from nested models will bubble
// up here and recursively reset `capturedEffects` to `undefined` preventing
// any captured effects from leaking
capturedEffects = undefined;
throw err;
} finally {
modelEffects = stopCapturingEffects();
}
for (const key in model) {
// @ts-expect-error TypeScript can't infer that model[key] is a valid here
if (typeof model[key] === "function") {
// @ts-expect-error TypeScript can't infer that model[key] is a valid function
// to pass to action here
model[key] = action(model[key]);
}
}
model[Symbol.dispose] = action(function disposeModel() {
if (modelEffects) {
for (let i = 0; i < modelEffects.length; i++) {
modelEffects[i].dispose();
}
}
modelEffects = undefined;
});
return model;
} as InternalModelConstructor<TModel, TFactoryArgs>;
}
//#endregion createModel
export {

@@ -908,2 +1056,4 @@ computed,

untracked,
action,
createModel,
Signal,

@@ -910,0 +1060,0 @@ ReadonlySignal,

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