@fluixi/reactive 1.0.0-alpha.66 → 1.0.0-alpha.68

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 ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var z=0,H=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends q{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(b);I(this)}}peek(){return this._value}},g=class extends q{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=z}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(a){i=!0,u=a,s=this._value}finally{r.consumer=t,r.untracked=o}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);I(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===z;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(H);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function N(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)N(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&A()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var V=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{N(this.owner,!1),j(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new C(()=>fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),N(this.owner))}};function $(e){let n=new V(e);return()=>n.dispose()}L(()=>{});var he=Symbol.for("signal");var Te=Symbol.for("signal-node");function p(e,n){let t=new D(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),U(),u});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,Te,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function Q(e,n){let t=n;return $(()=>{t=e(t)})}function m(e){return Y(e)}function S(e){return K(e)}var B=null;function ee(e){B&&B(e)}var J=null;function te(e){return J?J(e):void 0}var X=null;function ne(){return X?X():void 0}var Z=null;function re(e,n){Z&&Z(e,n)}function ve(e){return!!e&&typeof e.then=="function"}var M=Symbol();function oe(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=ne(),u=i!==void 0?te(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:t.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,y]=p(void 0,{equals:!1}),[ie,ue]=p(void 0,{equals:!1}),k=M,E=!1;Q(()=>{let c=o();if(ie(),c===!1||c===null||c===void 0){k=M,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==M&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let G=S(f),ae=S(a),W=G==="ready"||G==="refreshing";m(()=>{h(W?"refreshing":"pending"),T(void 0)});try{let w=s(c,{value:ae,refetching:W});ve(w)?(y(w),ee(w),w.then(P=>{O||(i!==void 0&&re(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let F=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(F()){let R=se();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:F},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ue(void 0)}}]}function we(e,n=300){let[t,o]=p(e),[s,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(t);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(t)):f;return o(()=>h),l(!0),d(),a=setTimeout(v,n),h});return x(d),[s,T,{immediate:t,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function me(e){return e!=null&&e!==""}function Me(e,n,t={}){let{delay:o=300,initialValue:s,shouldFetch:i=me}=t,[u,l,a]=we(e,o),d=()=>i(u())?u():!1,[v,{refetch:T}]=oe(d,n,s===void 0?{}:{initialValue:s});return[v,{...a,query:u,setQuery:l,refetch:T}]}export{Me as createDebouncedResource,we as createDebouncedSignal};
1
+ var ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var z=0,H=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},D=class extends q{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(b);I(this)}}peek(){return this._value}},g=class extends q{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===H&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=z}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(a){i=!0,u=a,s=this._value}finally{r.consumer=n,r.untracked=o}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);I(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===z;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(H);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function N(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)N(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&A()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var V=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{N(this.owner,!1),j(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new C(()=>fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),N(this.owner))}};function $(e){let t=new V(e);return()=>t.dispose()}L(()=>{});var he=Symbol.for("signal");var Te=Symbol.for("signal-node");function p(e,t){let n=new D(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let u=typeof i=="function"?i(n.peek()):i;return n.set(u),U(),u});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,Te,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function Q(e,t){let n=t;return $(()=>{n=e(n)})}function m(e){return Y(e)}function S(e){return K(e)}var B=null;function ee(e){B&&B(e)}var J=null;function ne(e){return J?J(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function ve(e){return!!e&&typeof e.then=="function"}var M=Symbol();function oe(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=te(),u=i!==void 0?ne(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:n.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,y]=p(void 0,{equals:!1}),[ie,ue]=p(void 0,{equals:!1}),k=M,E=!1;Q(()=>{let c=o();if(ie(),c===!1||c===null||c===void 0){k=M,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==M&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let G=S(f),ae=S(a),W=G==="ready"||G==="refreshing";m(()=>{h(W?"refreshing":"pending"),T(void 0)});try{let w=s(c,{value:ae,refetching:W});ve(w)?(y(w),ee(w),w.then(P=>{O||(i!==void 0&&re(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let F=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(F()){let R=se();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:F},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ue(void 0)}}]}function we(e,t=300){let[n,o]=p(e),[s,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(n);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(n)):f;return o(()=>h),l(!0),d(),a=setTimeout(v,t),h});return x(d),[s,T,{immediate:n,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function me(e){return e!=null&&e!==""}function Me(e,t,n={}){let{delay:o=300,initialValue:s,shouldFetch:i=me}=n,[u,l,a]=we(e,o),d=()=>i(u())?u():!1,[v,{refetch:T}]=oe(d,t,s===void 0?{}:{initialValue:s});return[v,{...a,query:u,setQuery:l,refetch:T}]}export{Me as createDebouncedResource,we as createDebouncedSignal};
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)C(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ce(t))!de.call(e,s)&&s!==n&&C(e,s,{get:()=>t[s],enumerable:!(o=le(t,s))||o.enumerable});return e};var he=e=>pe(C({},"__esModule",{value:!0}),e);var ke={};fe(ke,{createResource:()=>xe});module.exports=he(ke);var ve="__fluixi_signal_next_state__",Te=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ve]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Te,onSuspend:null,onError:null};var H=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},_=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);A(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===K&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(l){i=!0,a=l,s=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,w){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);A(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===H;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var R=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function we(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function V(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)E(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ye(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=we(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{E(this.owner,!1),N(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new R(()=>ye(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let t=new I(e);return()=>t.dispose()}U(()=>{});var Se=Symbol.for("signal");var be=Symbol.for("signal-node");function h(e,t){let n=new _(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let a=typeof i=="function"?i(n.peek()):i;return n.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,be,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function J(e,t){let n=t;return B(()=>{n=e(n)})}function d(e){return $(e)}function j(e){return L(e)}var Q=null;function te(e){Q&&Q(e)}var X=null;function ne(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,t){ee&&ee(e,t)}function ge(e){return!!e&&typeof e.then=="function"}var M=Symbol();function xe(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=re(),a=i!==void 0?ne(i):void 0,w=a!==void 0,[l,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==M&&u===m&&!b)return;if(m=u,w){w=!1;return}let g=!1;V(()=>g=!0);let z=j(q),ae=j(l),F=z==="ready"||z==="refreshing";d(()=>{f(F?"refreshing":"pending"),y(void 0)});try{let c=s(u,{value:ae,refetching:F});ge(c)?(p(c),te(c),c.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=G();if(u)throw u;if(W()){let b=se();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}
1
+ "use strict";var C=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(e,n)=>{for(var t in n)C(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ce(n))!de.call(e,s)&&s!==t&&C(e,s,{get:()=>n[s],enumerable:!(o=le(n,s))||o.enumerable});return e};var he=e=>pe(C({},"__esModule",{value:!0}),e);var ke={};fe(ke,{createResource:()=>xe});module.exports=he(ke);var ve="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ve]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var H=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);A(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(l){i=!0,a=l,s=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);A(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===H;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Te(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function V(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)E(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ye(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=Te(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{E(this.owner,!1),N(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>ye(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let n=new I(e);return()=>n.dispose()}U(()=>{});var Se=Symbol.for("signal");var be=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let a=typeof i=="function"?i(t.peek()):i;return t.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,be,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function J(e,n){let t=n;return B(()=>{t=e(t)})}function d(e){return $(e)}function j(e){return L(e)}var Q=null;function ne(e){Q&&Q(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ge(e){return!!e&&typeof e.then=="function"}var M=Symbol();function xe(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=re(),a=i!==void 0?te(i):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==M&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;V(()=>g=!0);let z=j(q),ae=j(l),F=z==="ready"||z==="refreshing";d(()=>{f(F?"refreshing":"pending"),y(void 0)});try{let c=s(u,{value:ae,refetching:F});ge(c)?(p(c),ne(c),c.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=G();if(u)throw u;if(W()){let b=se();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}
@@ -1 +1 @@
1
- var ae="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var F=0,H=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},_=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);C(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===H&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(l){s=!0,a=l,i=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,w){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);C(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===F;if(this.state=n,o){if(this.observers)for(let i of[...this.observers])i.markDirty(H);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var R=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function A(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)A(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function de(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{A(this.owner,!1),I(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new R(()=>de(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),A(this.owner))}};function $(e){let t=new E(e);return()=>t.dispose()}L(()=>{});var pe=Symbol.for("signal");var he=Symbol.for("signal-node");function h(e,t){let n=new _(e,{equals:t?.equals}),o=(()=>n.get()),i=(s=>{let a=typeof s=="function"?s(n.peek()):s;return n.set(a),U(),a});return Object.defineProperty(o,pe,{value:!0,enumerable:!0}),Object.defineProperty(o,he,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,i]}function B(e,t){let n=t;return $(()=>{n=e(n)})}function d(e){return Y(e)}function V(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function te(e){return Q?Q(e):void 0}var X=null;function ne(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function ve(e){return!!e&&typeof e.then=="function"}var j=Symbol();function Ae(e,t,n={}){let o,i;typeof t=="function"?(o=typeof e=="function"?e:()=>e,i=t):(o=()=>!0,i=e,t&&typeof t=="object"&&(n=t));let s=ne(),a=s!==void 0?te(s):void 0,w=a!==void 0,[l,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[oe,p]=h(void 0,{equals:!1}),[se,ie]=h(void 0,{equals:!1}),m=j,D=!1;B(()=>{let u=o();if(se(),u===!1||u===null||u===void 0){m=j,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==j&&u===m&&!b)return;if(m=u,w){w=!1;return}let g=!1;N(()=>g=!0);let W=V(q),ue=V(l),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let c=i(u,{value:ue,refetching:z});ve(c)?(p(c),ee(c),c.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=M();if(u)throw u;if(G()){let b=oe();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ie(void 0)}}]}export{Ae as createResource};
1
+ var ae="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var F=0,H=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);C(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(l){s=!0,a=l,i=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);C(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===F;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(H);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function A(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)A(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function de(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{A(this.owner,!1),I(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>de(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),A(this.owner))}};function $(e){let n=new E(e);return()=>n.dispose()}L(()=>{});var pe=Symbol.for("signal");var he=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let a=typeof s=="function"?s(t.peek()):s;return t.set(a),U(),a});return Object.defineProperty(o,pe,{value:!0,enumerable:!0}),Object.defineProperty(o,he,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function B(e,n){let t=n;return $(()=>{t=e(t)})}function d(e){return Y(e)}function V(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function ne(e){return Q?Q(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,n){Z&&Z(e,n)}function ve(e){return!!e&&typeof e.then=="function"}var j=Symbol();function Ae(e,n,t={}){let o,i;typeof n=="function"?(o=typeof e=="function"?e:()=>e,i=n):(o=()=>!0,i=e,n&&typeof n=="object"&&(t=n));let s=te(),a=s!==void 0?ne(s):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[oe,p]=h(void 0,{equals:!1}),[se,ie]=h(void 0,{equals:!1}),m=j,D=!1;B(()=>{let u=o();if(se(),u===!1||u===null||u===void 0){m=j,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==j&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;N(()=>g=!0);let W=V(q),ue=V(l),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let c=i(u,{value:ue,refetching:z});ve(c)?(p(c),ee(c),c.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=M();if(u)throw u;if(G()){let b=oe();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ie(void 0)}}]}export{Ae as createResource};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!g.call(e,o)&&o!==r&&w(e,o,{get:()=>t[o],enumerable:!(s=S(t,o))||s.enumerable});return e};var C=e=>O(w({},"__esModule",{value:!0}),e);var B={};q(B,{afterWrite:()=>j,batch:()=>L,createContext:()=>P,createRoot:()=>V,effect:()=>U,flushSync:()=>f,getOwner:()=>A,isOwnerDisposed:()=>N,onCleanup:()=>H,provide:()=>G,readContextFrom:()=>I,reportSuspend:()=>M,runWithOwner:()=>m,setErrorHandler:()=>W,setOwner:()=>F,setScheduler:()=>K,setSuspendHandler:()=>R,useContext:()=>z});module.exports=C(B);var E="__fluixi_signal_next_state__",D=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var T=0,_=1,a=2,v=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let t=n.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var l=class extends v{constructor(r,s){super();this._threw=!1;this._initialized=!1;this.state=a;this.sources=null;this._fn=r,this._equals=s?.equals===!1?()=>!1:s?.equals??Object.is}get(){if(n.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===_&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===a)break}(this.state===a||!this._initialized)&&this.recompute(),this.state=T}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=n.consumer,s=n.untracked;n.consumer=this,n.untracked=!1;let o,i=!1,p;try{o=this._fn()}catch(u){i=!0,p=u,o=this._value}finally{n.consumer=r,n.untracked=s}let x=!this._initialized||this._threw!==i||(i?p!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=p,this._value=o,x){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(a);b(this)}}markDirty(r){if(this.state>=r)return;let s=this.state===T;if(this.state=r,s){if(this.observers)for(let o of[...this.observers])o.markDirty(_);b(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function b(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var d=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function N(e){return!!e&&e.disposed===!0}function h(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function P(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:s=>{let o=n.owner,i=h(o);(i.contexts=new Map).set(t,s.value),o&&(o.owned??=[]).push(i),n.owner=i;try{return s.children}finally{n.owner=o}}}}function z(e){let t=n.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function I(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function G(e,t,r){let s=h(n.owner);(s.contexts=new Map).set(e.id,t),n.owner&&(n.owner.owned??=[]).push(s);let o=n.owner;n.owner=s;try{return r()}finally{n.owner=o}}function R(e){n.onSuspend=e}function M(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function W(e){n.onError=e}function A(){return n.owner}function F(e){let t=n.owner;return n.owner=e,t}function m(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function H(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function c(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)c(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function V(e){let t=h(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>c(t))}finally{n.owner=r}}function K(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Y(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(f)))}function f(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=n.queue;n.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{n.flushing=!1}}function j(){n.batchDepth===0&&f()}function L(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&f()}}var y=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=h(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{c(this.owner,!1),m(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new d(()=>Y(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&n.onSuspend){n.onSuspend(t,this.owner);return}if(n.onError&&n.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),c(this.owner))}};function U(e){let t=new y(e);return()=>t.dispose()}
1
+ "use strict";var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!g.call(e,o)&&o!==r&&w(e,o,{get:()=>t[o],enumerable:!(s=S(t,o))||s.enumerable});return e};var C=e=>q(w({},"__esModule",{value:!0}),e);var Q={};O(Q,{afterWrite:()=>U,batch:()=>B,createChildOwner:()=>N,createContext:()=>I,createRoot:()=>Y,disposeScope:()=>P,effect:()=>J,flushSync:()=>f,getOwner:()=>H,isOwnerDisposed:()=>z,onCleanup:()=>K,provide:()=>M,readContextFrom:()=>R,reportSuspend:()=>A,runWithOwner:()=>x,setErrorHandler:()=>F,setOwner:()=>V,setScheduler:()=>j,setSuspendHandler:()=>W,useContext:()=>G});module.exports=C(Q);var E="__fluixi_signal_next_state__",D=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var T=0,_=1,d=2,v=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let t=n.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var c=class extends v{constructor(r,s){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=s?.equals===!1?()=>!1:s?.equals??Object.is}get(){if(n.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===_&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=T}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=n.consumer,s=n.untracked;n.consumer=this,n.untracked=!1;let o,i=!1,p;try{o=this._fn()}catch(u){i=!0,p=u,o=this._value}finally{n.consumer=r,n.untracked=s}let m=!this._initialized||this._threw!==i||(i?p!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=p,this._value=o,m){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(d);b(this)}}markDirty(r){if(this.state>=r)return;let s=this.state===T;if(this.state=r,s){if(this.observers)for(let o of[...this.observers])o.markDirty(_);b(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function b(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var h=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function N(e){let t=l(e);return e&&(e.owned??=[]).push(t),t}function P(e,t=!0){a(e,t)}function z(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:s=>{let o=n.owner,i=l(o);(i.contexts=new Map).set(t,s.value),o&&(o.owned??=[]).push(i),n.owner=i;try{return s.children}finally{n.owner=o}}}}function G(e){let t=n.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function R(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let s=l(n.owner);(s.contexts=new Map).set(e.id,t),n.owner&&(n.owner.owned??=[]).push(s);let o=n.owner;n.owner=s;try{return r()}finally{n.owner=o}}function W(e){n.onSuspend=e}function A(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function F(e){n.onError=e}function H(){return n.owner}function V(e){let t=n.owner;return n.owner=e,t}function x(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function K(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function a(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)a(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function Y(e){let t=l(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>a(t))}finally{n.owner=r}}function j(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function L(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(f)))}function f(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=n.queue;n.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{n.flushing=!1}}function U(){n.batchDepth===0&&f()}function B(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&f()}}var y=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=l(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{a(this.owner,!1),x(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new h(()=>L(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&n.onSuspend){n.onSuspend(t,this.owner);return}if(n.onError&&n.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),a(this.owner))}};function J(e){let t=new y(e);return()=>t.dispose()}
@@ -8,6 +8,22 @@ export interface Owner {
8
8
  * queued onMount) from running against — and resurrecting — a dead owner. */
9
9
  disposed?: boolean;
10
10
  }
11
+ /**
12
+ * A child scope of `parent`, attached so the parent's teardown disposes it too.
13
+ *
14
+ * For a derivation that re-runs: context still resolves up the chain from the
15
+ * creation-time owner, while anything registered during a run belongs to this
16
+ * scope and can be torn down before the next one — instead of accumulating on
17
+ * the enclosing scope and only running when that finally dies.
18
+ */
19
+ export declare function createChildOwner(parent: Owner | null): Owner;
20
+ /**
21
+ * Tear down a scope's children and cleanups.
22
+ *
23
+ * `final: false` keeps the scope itself alive and reusable — what a re-running
24
+ * derivation needs between runs.
25
+ */
26
+ export declare function disposeScope(owner: Owner, final?: boolean): void;
11
27
  /** True once `owner` has been disposed. Deferred work should bail rather than run. */
12
28
  export declare function isOwnerDisposed(owner: Owner | null): boolean;
13
29
  export interface Context<T> {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/runtime.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IACnC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC;iFAC6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAE5D;AAUD,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,4FAA4F;IAI5F,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,GAAG,CAAC;CAC7E;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsB7D;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,SAAS,CAOtF;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAO1F;AAED,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAW3E;AAGD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GACpE,IAAI,CAEN;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAMhE;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAC7B,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,IAAI,GAC5D,IAAI,CAEN;AAED,wBAAgB,QAAQ,IAAI,KAAK,GAAG,IAAI,CAEvC;AAED,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAI1D;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQnE;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAO9C;AAmBD,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAU/D;AAGD,wBAAgB,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAEzE;AAYD,qDAAqD;AACrD,wBAAgB,SAAS,IAAI,IAAI,CAqBhC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOvC;AA8DD,0FAA0F;AAC1F,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAGhE"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/runtime.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IACnC,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC;iFAC6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,UAAO,GAAG,IAAI,CAE7D;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAE5D;AAUD,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,4FAA4F;IAI5F,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,GAAG,CAAC;CAC7E;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsB7D;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,SAAS,CAOtF;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAO1F;AAED,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAW3E;AAGD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GACpE,IAAI,CAEN;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAMhE;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAC7B,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,IAAI,GAC5D,IAAI,CAEN;AAED,wBAAgB,QAAQ,IAAI,KAAK,GAAG,IAAI,CAEvC;AAED,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAI1D;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQnE;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAO9C;AAmBD,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAU/D;AAGD,wBAAgB,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAEzE;AAYD,qDAAqD;AACrD,wBAAgB,SAAS,IAAI,IAAI,CAqBhC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOvC;AA8DD,0FAA0F;AAC1F,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,IAAI,CAGhE"}
@@ -16,6 +16,29 @@
16
16
  */
17
17
  import { Computed, Watcher } from './core.js';
18
18
  import { G } from './state.js';
19
+ /**
20
+ * A child scope of `parent`, attached so the parent's teardown disposes it too.
21
+ *
22
+ * For a derivation that re-runs: context still resolves up the chain from the
23
+ * creation-time owner, while anything registered during a run belongs to this
24
+ * scope and can be torn down before the next one — instead of accumulating on
25
+ * the enclosing scope and only running when that finally dies.
26
+ */
27
+ export function createChildOwner(parent) {
28
+ const owner = makeOwner(parent);
29
+ if (parent)
30
+ (parent.owned ??= []).push(owner);
31
+ return owner;
32
+ }
33
+ /**
34
+ * Tear down a scope's children and cleanups.
35
+ *
36
+ * `final: false` keeps the scope itself alive and reusable — what a re-running
37
+ * derivation needs between runs.
38
+ */
39
+ export function disposeScope(owner, final = true) {
40
+ disposeOwner(owner, final);
41
+ }
19
42
  /** True once `owner` has been disposed. Deferred work should bail rather than run. */
20
43
  export function isOwnerDisposed(owner) {
21
44
  return !!owner && owner.disposed === true;
@@ -1 +1 @@
1
- var m="__fluixi_signal_next_state__",x=t=>{typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)},e=globalThis[m]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:x,onSuspend:null,onError:null};var y=0,T=1,a=2,p=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(e.untracked)return;let n=e.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}};var l=class extends p{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=a;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(e.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===T&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===a)break}(this.state===a||!this._initialized)&&this.recompute(),this.state=y}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=e.consumer,o=e.untracked;e.consumer=this,e.untracked=!1;let s,i=!1,f;try{s=this._fn()}catch(u){i=!0,f=u,s=this._value}finally{e.consumer=r,e.untracked=o}let b=!this._initialized||this._threw!==i||(i?f!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=f,this._value=s,b){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(a);_(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===y;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(T);_(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _(t){if(t.watchers)for(let n of[...t.watchers])n._notify(t)}var d=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let r of n)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...n){for(let r of n)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let r=this._pending.size===0;this._pending.add(n),r&&this._notifyFn()}};function D(t){return!!t&&t.disposed===!0}function h(t){return{cleanups:null,owned:null,parent:t,contexts:null}}function N(t){let n=Symbol("context");return{id:n,defaultValue:t,Provider:o=>{let s=e.owner,i=h(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),e.owner=i;try{return o.children}finally{e.owner=s}}}}function P(t){let n=e.owner;for(;n;){if(n.contexts&&n.contexts.has(t.id))return n.contexts.get(t.id);n=n.parent}return t.defaultValue}function z(t,n){let r=t;for(;r;){if(r.contexts&&r.contexts.has(n.id))return r.contexts.get(n.id);r=r.parent}return n.defaultValue}function I(t,n,r){let o=h(e.owner);(o.contexts=new Map).set(t.id,n),e.owner&&(e.owner.owned??=[]).push(o);let s=e.owner;e.owner=o;try{return r()}finally{e.owner=s}}function G(t){e.onSuspend=t}function R(t){return e.onSuspend?(e.onSuspend(t,e.owner),!0):!1}function M(t){e.onError=t}function W(){return e.owner}function A(t){let n=e.owner;return e.owner=t,n}function S(t,n){let r=e.owner;e.owner=t;try{return n()}finally{e.owner=r}}function F(t){if(e.owner){if(e.owner.disposed){t();return}(e.owner.cleanups??=[]).push(t)}}function c(t,n=!0){if(!t.disposed){if(t.owned){for(let r=t.owned.length-1;r>=0;r--)c(t.owned[r]);t.owned=null}if(t.cleanups){for(let r=t.cleanups.length-1;r>=0;r--)t.cleanups[r]();t.cleanups=null}n&&(t.disposed=!0)}}function H(t){let n=h(e.owner);e.owner&&(e.owner.owned??=[]).push(n);let r=e.owner;e.owner=n;try{return t(()=>c(n))}finally{e.owner=r}}function V(t){e.hostSchedule=t??(n=>{Promise.resolve().then(n)})}function k(t){t.queued||(t.queued=!0,e.queue.push(t),!e.scheduled&&e.batchDepth===0&&(e.scheduled=!0,e.hostSchedule(v)))}function v(){if(e.scheduled=!1,e.flushing)return;e.flushing=!0;let t=0;try{for(;e.queue.length;){if(++t>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=e.queue;e.queue=[];for(let r of n)r.queued=!1,r.disposed||r.run()}}finally{e.flushing=!1}}function K(){e.batchDepth===0&&v()}function Y(t){e.batchDepth++;try{return t()}finally{--e.batchDepth===0&&v()}}var w=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=h(e.owner),e.owner&&(e.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{c(this.owner,!1),S(this.owner,()=>{let r=n();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new d(()=>k(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&e.onSuspend){e.onSuspend(n,this.owner);return}if(e.onError&&e.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),c(this.owner))}};function j(t){let n=new w(t);return()=>n.dispose()}export{K as afterWrite,Y as batch,N as createContext,H as createRoot,j as effect,v as flushSync,W as getOwner,D as isOwnerDisposed,F as onCleanup,I as provide,z as readContextFrom,R as reportSuspend,S as runWithOwner,M as setErrorHandler,A as setOwner,V as setScheduler,G as setSuspendHandler,P as useContext};
1
+ var x="__fluixi_signal_next_state__",m=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},t=globalThis[x]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:m,onSuspend:null,onError:null};var y=0,T=1,d=2,p=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(t.untracked)return;let n=t.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}};var c=class extends p{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(t.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===T&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=y}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=t.consumer,o=t.untracked;t.consumer=this,t.untracked=!1;let s,i=!1,f;try{s=this._fn()}catch(u){i=!0,f=u,s=this._value}finally{t.consumer=r,t.untracked=o}let b=!this._initialized||this._threw!==i||(i?f!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=f,this._value=s,b){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(d);_(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===y;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(T);_(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var h=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let r of n)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...n){for(let r of n)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let r=this._pending.size===0;this._pending.add(n),r&&this._notifyFn()}};function D(e){let n=l(e);return e&&(e.owned??=[]).push(n),n}function N(e,n=!0){a(e,n)}function P(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function z(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:o=>{let s=t.owner,i=l(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),t.owner=i;try{return o.children}finally{t.owner=s}}}}function I(e){let n=t.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function G(e,n){let r=e;for(;r;){if(r.contexts&&r.contexts.has(n.id))return r.contexts.get(n.id);r=r.parent}return n.defaultValue}function R(e,n,r){let o=l(t.owner);(o.contexts=new Map).set(e.id,n),t.owner&&(t.owner.owned??=[]).push(o);let s=t.owner;t.owner=o;try{return r()}finally{t.owner=s}}function M(e){t.onSuspend=e}function W(e){return t.onSuspend?(t.onSuspend(e,t.owner),!0):!1}function A(e){t.onError=e}function F(){return t.owner}function H(e){let n=t.owner;return t.owner=e,n}function S(e,n){let r=t.owner;t.owner=e;try{return n()}finally{t.owner=r}}function V(e){if(t.owner){if(t.owner.disposed){e();return}(t.owner.cleanups??=[]).push(e)}}function a(e,n=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)a(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}n&&(e.disposed=!0)}}function K(e){let n=l(t.owner);t.owner&&(t.owner.owned??=[]).push(n);let r=t.owner;t.owner=n;try{return e(()=>a(n))}finally{t.owner=r}}function Y(e){t.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function k(e){e.queued||(e.queued=!0,t.queue.push(e),!t.scheduled&&t.batchDepth===0&&(t.scheduled=!0,t.hostSchedule(v)))}function v(){if(t.scheduled=!1,t.flushing)return;t.flushing=!0;let e=0;try{for(;t.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=t.queue;t.queue=[];for(let r of n)r.queued=!1,r.disposed||r.run()}}finally{t.flushing=!1}}function j(){t.batchDepth===0&&v()}function L(e){t.batchDepth++;try{return e()}finally{--t.batchDepth===0&&v()}}var w=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=l(t.owner),t.owner&&(t.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{a(this.owner,!1),S(this.owner,()=>{let r=n();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new h(()=>k(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&t.onSuspend){t.onSuspend(n,this.owner);return}if(t.onError&&t.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),a(this.owner))}};function U(e){let n=new w(e);return()=>n.dispose()}export{j as afterWrite,L as batch,D as createChildOwner,z as createContext,K as createRoot,N as disposeScope,U as effect,v as flushSync,F as getOwner,P as isOwnerDisposed,V as onCleanup,R as provide,G as readContextFrom,W as reportSuspend,S as runWithOwner,A as setErrorHandler,H as setOwner,Y as setScheduler,M as setSuspendHandler,I as useContext};
@@ -1 +1 @@
1
- "use strict";var se=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var un=Object.prototype.hasOwnProperty;var an=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},cn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of sn(n))!un.call(e,o)&&o!==t&&se(e,o,{get:()=>n[o],enumerable:!(r=on(n,o))||r.enumerable});return e};var ln=e=>cn(se({},"__esModule",{value:!0}),e);var On={};an(On,{$PROXY:()=>_n,$SIGNAL:()=>Rn,Signal:()=>tn,SuspenseContext:()=>oe,__DEV__:()=>Q,batch:()=>b,createComputed:()=>Pe,createContext:()=>q,createDebounce:()=>Ke,createDebouncedResource:()=>Ye,createDebouncedSignal:()=>me,createDeferred:()=>He,createEffect:()=>E,createErrorBoundary:()=>en,createMemo:()=>S,createRenderEffect:()=>qe,createResource:()=>te,createRoot:()=>O,createSelector:()=>$e,createSignal:()=>d,createSuspenseBoundary:()=>Xe,flush:()=>Me,getOwner:()=>V,getServerData:()=>Z,indexArray:()=>wn,isComponent:()=>Ne,isMemo:()=>Fe,isOwnerDisposed:()=>ke,isProvider:()=>Le,isResource:()=>Be,isSignal:()=>X,isSuspense:()=>Ve,keyArray:()=>vn,makeArrayFlat:()=>de,mapArray:()=>mn,nextResourceId:()=>ee,on:()=>Ue,onCleanup:()=>v,provide:()=>I,provideErrorBoundary:()=>nn,provideSuspense:()=>Je,readChildren:()=>Qe,reportResourceData:()=>ne,runWithOwner:()=>M,setOwner:()=>ae,setResourceDataSink:()=>ze,setResourceIdSource:()=>We,setResourceTracker:()=>je,setServerDataGetter:()=>Ge,startTransition:()=>le,trackResourcePromise:()=>J,untrack:()=>w,useContext:()=>Re,useTransition:()=>Ie});module.exports=ln(On);var dn="__fluixi_signal_next_state__",fn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[dn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fn,onSuspend:null,onError:null};var Se=0,xe=1,B=2,z=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let n=s.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends z{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(B);ie(this)}}peek(){return this._value}},k=class extends z{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=B;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===xe&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===B)break}(this.state===B||!this._initialized)&&this.recompute(),this.state=Se}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=s.consumer,r=s.untracked;s.consumer=this,s.untracked=!1;let o,u=!1,a;try{o=this._fn()}catch(i){u=!0,a=i,o=this._value}finally{s.consumer=t,s.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=u,this._error=a,this._value=o,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(B);ie(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Se;if(this.state=t,r){if(this.observers)for(let o of[...this.observers])o.markDirty(xe);ie(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ie(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function N(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function be(){return s.consumer}function ge(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ke(e){return!!e&&e.disposed===!0}function H(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let o=s.owner,u=H(o);(u.contexts=new Map).set(n,r.value),o&&(o.owned??=[]).push(u),s.owner=u;try{return r.children}finally{s.owner=o}}}}function Re(e){let n=s.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function I(e,n,t){let r=H(s.owner);(r.contexts=new Map).set(e.id,n),s.owner&&(s.owner.owned??=[]).push(r);let o=s.owner;s.owner=r;try{return t()}finally{s.owner=o}}function _e(e){s.onSuspend=e}function Oe(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function Ee(e){s.onError=e}function V(){return s.owner}function ae(e){let n=s.owner;return s.owner=e,n}function M(e,n){let t=s.owner;s.owner=e;try{return n()}finally{s.owner=t}}function v(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function $(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)$(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function O(e){let n=H(s.owner);s.owner&&(s.owner.owned??=[]).push(n);let t=s.owner;s.owner=n;try{return e(()=>$(n))}finally{s.owner=t}}function Ce(e){s.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function pn(e){e.queued||(e.queued=!0,s.queue.push(e),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(L)))}function L(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=s.queue;s.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function Ae(){s.batchDepth===0&&L()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&L()}}var ue=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=H(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{$(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new P(()=>pn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&s.onSuspend){s.onSuspend(n,this.owner);return}if(s.onError&&s.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),$(this.owner))}};function Y(e){let n=new ue(e);return()=>n.dispose()}function hn(e){return!!e&&typeof e.then=="function"}Ce(()=>{});var De=Symbol.for("signal"),yn=Symbol.for("memo"),Tn=Symbol.for("signal-node");function d(e,n){let t=new D(e,{equals:n?.equals}),r=(()=>t.get()),o=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Ae(),a});return Object.defineProperty(r,De,{value:!0,enumerable:!0}),Object.defineProperty(r,Tn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,o]}function S(e,n,t){let r=n,o=V(),u=new k(()=>M(o,()=>{try{return r=e(r)}catch(c){if(hn(c))return Oe(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,De,{value:!0,enumerable:!0}),Object.defineProperty(a,yn,{value:!0,enumerable:!0}),a}function E(e,n){let t=n;return Y(()=>{t=e(t)})}function Pe(e,n){let t=n;Y(()=>{t=e(t)})}function qe(e,n){let t=n;return Y(()=>{t=e(t)})}function b(e){return ce(e)}function w(e){return N(e)}function le(e){return ce(e),Promise.resolve()}function Ie(){return[()=>!1,le]}function Me(){return L(),Promise.resolve()}function Ue(e,n,t){let r=Array.isArray(e),o,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,o=c;return}let i=N(()=>n(c,o,a));return o=c,i}}function mn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<o.length;i++){let f=o[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,y;O(T=>{y=T;let[C,U]=d(i);p=U,l=n(f,C)});let x={item:f,rendered:l,dispose:y,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function vn(e,n,t,r){let o=[],u=[];return v(()=>{for(let a of u)a.dispose();o=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return o=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),y=c.get(p);if(y&&!h.has(p))y.setIndex(l),i.push(y);else{let x,T,C;O(U=>{C=U;let[R,F]=d(l);T=F;let j=S(A=>{let g=(e()||[])[R()];return g??A},a[l]);x=t(j,R)}),i.push({rendered:x,dispose:C,setIndex:T})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return o=f,u=i,i.map(l=>l.rendered)})})}function wn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=o.length;for(let i=u;i<a;i++){let f,h,l,p=o[i];O(y=>{l=y;let[x,T]=d(p);h=T,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(o[i]);return r.map(i=>i.rendered)})})}var Q=!1,Sn=Symbol.for("signal"),xn=Symbol.for("memo"),bn=Symbol.for("resource");function X(e){return typeof e=="function"&&e[Sn]===!0}function Fe(e){return typeof e=="function"&&e[xn]===!0}function Be(e){return typeof e=="function"&&e[bn]===!0}function Ne(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ve(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Le(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function de(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?de(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var fe=null;function je(e){fe=e}function J(e){fe&&fe(e)}var pe=null;function Ge(e){pe=e}function Z(e){return pe?pe(e):void 0}var he=null;function We(e){he=e}function ee(){return he?he():void 0}var ye=null;function ze(e){ye=e}function ne(e,n){ye&&ye(e,n)}function $e(e,n=(t,r)=>t===r){let t=new Map;return E(()=>{let r=e();for(let[o,u]of t){let[a,c]=u,i=n(o,r);a()!==i&&c(i)}}),r=>{let o=t.get(r);if(!o){let[u,a]=d(!1);o=[u,a],t.set(r,o);let c=e();a(n(r,c))}return o[0]()}}function He(e,n){let[t,r]=d(e(),n);return E(()=>{let o=e();n?.timeoutMs?setTimeout(()=>r(()=>o),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),t}function Ke(e,n){let t,r=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function gn(e){return!!e&&typeof e.then=="function"}var Te=Symbol();function te(e,n,t={}){let r,o;typeof n=="function"?(r=typeof e=="function"?e:()=>e,o=n):(r=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let u=ee(),a=u!==void 0?Z(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,y]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,U]=d(void 0,{equals:!1}),R=Te,F=!1;E(()=>{let m=r();if(C(),m===!1||m===null||m===void 0){R=Te,b(()=>{y("unresolved"),T(void 0),l(void 0)});return}let g=F;if(F=!1,R!==Te&&m===R&&!g)return;if(R=m,c){c=!1;return}let G=!1;v(()=>G=!0);let ve=w(p),rn=w(i),we=ve==="ready"||ve==="refreshing";b(()=>{y(we?"refreshing":"pending"),l(void 0)});try{let _=o(m,{value:rn,refetching:we});gn(_)?(T(_),J(_),_.then(W=>{G||(u!==void 0&&ne(u,W),b(()=>{f(()=>W),y("ready"),T(void 0)}))},W=>{G||b(()=>{l(W),y("errored"),T(void 0)})})):b(()=>{f(()=>_),y("ready"),T(void 0)})}catch(_){if(G)return;b(()=>{l(_),y("errored"),T(void 0)})}});let j=()=>{let m=p();return m==="pending"||m==="refreshing"},A=(()=>{let m=h();if(m)throw m;if(j()){let g=x();if(g)throw g}return i()});return Object.defineProperties(A,{state:{get:p},loading:{get:j},error:{get:h},latest:{get:i}}),Object.defineProperty(A,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(A,Symbol.for("signal"),{value:!0,enumerable:!0}),[A,{mutate:f,refetch:()=>{F=!0,U(void 0)}}]}function me(e,n=300){let[t,r]=d(e),[o,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let y=typeof p=="function"?p(w(t)):p;return r(()=>y),c(!0),f(),i=setTimeout(h,n),y});return v(f),[o,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function kn(e){return e!=null&&e!==""}function Ye(e,n,t={}){let{delay:r=300,initialValue:o,shouldFetch:u=kn}=t,[a,c,i]=me(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=te(f,n,o===void 0?{}:{initialValue:o});return[h,{...i,query:a,setQuery:c,refetch:l}]}function re(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:re(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=re(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function Qe(e){let n=S(e);return S(()=>re(n()))}var oe=q();_e((e,n)=>{let t=K(n,oe);t&&(t.increment(),e.finally(()=>t.decrement()))});function Xe(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function Je(e,n){return I(oe,e,n)}var Ze=q();Ee((e,n)=>{let t=K(n,Ze);return t?(t.setError(e),!0):!1});function en(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function nn(e,n){return I(Ze,e,n)}var tn={State:D,Computed:k,subtle:{Watcher:P,untrack:N,currentComputed:be,hasSinks:ge}};var Rn=Symbol.for("signal"),_n=Symbol.for("fluixi-proxy");
1
+ "use strict";var se=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var cn=Object.prototype.hasOwnProperty;var ln=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},dn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of an(n))!cn.call(e,o)&&o!==t&&se(e,o,{get:()=>n[o],enumerable:!(r=un(n,o))||r.enumerable});return e};var fn=e=>dn(se({},"__esModule",{value:!0}),e);var Cn={};ln(Cn,{$PROXY:()=>En,$SIGNAL:()=>_n,Signal:()=>on,SuspenseContext:()=>oe,__DEV__:()=>Q,batch:()=>b,createChildOwner:()=>ke,createComputed:()=>Ie,createContext:()=>q,createDebounce:()=>Qe,createDebouncedResource:()=>Xe,createDebouncedSignal:()=>me,createDeferred:()=>Ye,createEffect:()=>E,createErrorBoundary:()=>tn,createMemo:()=>S,createRenderEffect:()=>Me,createResource:()=>te,createRoot:()=>_,createSelector:()=>Ke,createSignal:()=>d,createSuspenseBoundary:()=>Ze,disposeScope:()=>Re,flush:()=>Fe,getOwner:()=>j,getServerData:()=>Z,indexArray:()=>xn,isComponent:()=>Le,isMemo:()=>Ne,isOwnerDisposed:()=>Oe,isProvider:()=>Ge,isResource:()=>Ve,isSignal:()=>X,isSuspense:()=>je,keyArray:()=>Sn,makeArrayFlat:()=>de,mapArray:()=>wn,nextResourceId:()=>ee,on:()=>Be,onCleanup:()=>v,provide:()=>I,provideErrorBoundary:()=>rn,provideSuspense:()=>en,readChildren:()=>Je,reportResourceData:()=>ne,runWithOwner:()=>M,setOwner:()=>ae,setResourceDataSink:()=>He,setResourceIdSource:()=>$e,setResourceTracker:()=>We,setServerDataGetter:()=>ze,startTransition:()=>le,trackResourcePromise:()=>J,untrack:()=>w,useContext:()=>_e,useTransition:()=>Ue});module.exports=fn(Cn);var pn="__fluixi_signal_next_state__",hn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[pn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:hn,onSuspend:null,onError:null};var Se=0,xe=1,B=2,H=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let n=s.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends H{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(B);ie(this)}}peek(){return this._value}},k=class extends H{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=B;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===xe&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===B)break}(this.state===B||!this._initialized)&&this.recompute(),this.state=Se}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=s.consumer,r=s.untracked;s.consumer=this,s.untracked=!1;let o,u=!1,a;try{o=this._fn()}catch(i){u=!0,a=i,o=this._value}finally{s.consumer=t,s.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=u,this._error=a,this._value=o,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(B);ie(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Se;if(this.state=t,r){if(this.observers)for(let o of[...this.observers])o.markDirty(xe);ie(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ie(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function N(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function be(){return s.consumer}function ge(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ke(e){let n=L(e);return e&&(e.owned??=[]).push(n),n}function Re(e,n=!0){V(e,n)}function Oe(e){return!!e&&e.disposed===!0}function L(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let o=s.owner,u=L(o);(u.contexts=new Map).set(n,r.value),o&&(o.owned??=[]).push(u),s.owner=u;try{return r.children}finally{s.owner=o}}}}function _e(e){let n=s.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function I(e,n,t){let r=L(s.owner);(r.contexts=new Map).set(e.id,n),s.owner&&(s.owner.owned??=[]).push(r);let o=s.owner;s.owner=r;try{return t()}finally{s.owner=o}}function Ee(e){s.onSuspend=e}function Ce(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function Ae(e){s.onError=e}function j(){return s.owner}function ae(e){let n=s.owner;return s.owner=e,n}function M(e,n){let t=s.owner;s.owner=e;try{return n()}finally{s.owner=t}}function v(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function _(e){let n=L(s.owner);s.owner&&(s.owner.owned??=[]).push(n);let t=s.owner;s.owner=n;try{return e(()=>V(n))}finally{s.owner=t}}function De(e){s.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function yn(e){e.queued||(e.queued=!0,s.queue.push(e),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(G)))}function G(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=s.queue;s.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function Pe(){s.batchDepth===0&&G()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&G()}}var ue=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=L(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new P(()=>yn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&s.onSuspend){s.onSuspend(n,this.owner);return}if(s.onError&&s.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Y(e){let n=new ue(e);return()=>n.dispose()}function Tn(e){return!!e&&typeof e.then=="function"}De(()=>{});var qe=Symbol.for("signal"),mn=Symbol.for("memo"),vn=Symbol.for("signal-node");function d(e,n){let t=new D(e,{equals:n?.equals}),r=(()=>t.get()),o=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Pe(),a});return Object.defineProperty(r,qe,{value:!0,enumerable:!0}),Object.defineProperty(r,vn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,o]}function S(e,n,t){let r=n,o=j(),u=new k(()=>M(o,()=>{try{return r=e(r)}catch(c){if(Tn(c))return Ce(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,qe,{value:!0,enumerable:!0}),Object.defineProperty(a,mn,{value:!0,enumerable:!0}),a}function E(e,n){let t=n;return Y(()=>{t=e(t)})}function Ie(e,n){let t=n;Y(()=>{t=e(t)})}function Me(e,n){let t=n;return Y(()=>{t=e(t)})}function b(e){return ce(e)}function w(e){return N(e)}function le(e){return ce(e),Promise.resolve()}function Ue(){return[()=>!1,le]}function Fe(){return G(),Promise.resolve()}function Be(e,n,t){let r=Array.isArray(e),o,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,o=c;return}let i=N(()=>n(c,o,a));return o=c,i}}function wn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<o.length;i++){let f=o[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,y;_(T=>{y=T;let[C,U]=d(i);p=U,l=n(f,C)});let x={item:f,rendered:l,dispose:y,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Sn(e,n,t,r){let o=[],u=[];return v(()=>{for(let a of u)a.dispose();o=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return o=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),y=c.get(p);if(y&&!h.has(p))y.setIndex(l),i.push(y);else{let x,T,C;_(U=>{C=U;let[R,F]=d(l);T=F;let W=S(A=>{let g=(e()||[])[R()];return g??A},a[l]);x=t(W,R)}),i.push({rendered:x,dispose:C,setIndex:T})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return o=f,u=i,i.map(l=>l.rendered)})})}function xn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=o.length;for(let i=u;i<a;i++){let f,h,l,p=o[i];_(y=>{l=y;let[x,T]=d(p);h=T,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(o[i]);return r.map(i=>i.rendered)})})}var Q=!1,bn=Symbol.for("signal"),gn=Symbol.for("memo"),kn=Symbol.for("resource");function X(e){return typeof e=="function"&&e[bn]===!0}function Ne(e){return typeof e=="function"&&e[gn]===!0}function Ve(e){return typeof e=="function"&&e[kn]===!0}function Le(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Ge(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function de(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?de(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var fe=null;function We(e){fe=e}function J(e){fe&&fe(e)}var pe=null;function ze(e){pe=e}function Z(e){return pe?pe(e):void 0}var he=null;function $e(e){he=e}function ee(){return he?he():void 0}var ye=null;function He(e){ye=e}function ne(e,n){ye&&ye(e,n)}function Ke(e,n=(t,r)=>t===r){let t=new Map;return E(()=>{let r=e();for(let[o,u]of t){let[a,c]=u,i=n(o,r);a()!==i&&c(i)}}),r=>{let o=t.get(r);if(!o){let[u,a]=d(!1);o=[u,a],t.set(r,o);let c=e();a(n(r,c))}return o[0]()}}function Ye(e,n){let[t,r]=d(e(),n);return E(()=>{let o=e();n?.timeoutMs?setTimeout(()=>r(()=>o),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),t}function Qe(e,n){let t,r=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function Rn(e){return!!e&&typeof e.then=="function"}var Te=Symbol();function te(e,n,t={}){let r,o;typeof n=="function"?(r=typeof e=="function"?e:()=>e,o=n):(r=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let u=ee(),a=u!==void 0?Z(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,y]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,U]=d(void 0,{equals:!1}),R=Te,F=!1;E(()=>{let m=r();if(C(),m===!1||m===null||m===void 0){R=Te,b(()=>{y("unresolved"),T(void 0),l(void 0)});return}let g=F;if(F=!1,R!==Te&&m===R&&!g)return;if(R=m,c){c=!1;return}let z=!1;v(()=>z=!0);let ve=w(p),sn=w(i),we=ve==="ready"||ve==="refreshing";b(()=>{y(we?"refreshing":"pending"),l(void 0)});try{let O=o(m,{value:sn,refetching:we});Rn(O)?(T(O),J(O),O.then($=>{z||(u!==void 0&&ne(u,$),b(()=>{f(()=>$),y("ready"),T(void 0)}))},$=>{z||b(()=>{l($),y("errored"),T(void 0)})})):b(()=>{f(()=>O),y("ready"),T(void 0)})}catch(O){if(z)return;b(()=>{l(O),y("errored"),T(void 0)})}});let W=()=>{let m=p();return m==="pending"||m==="refreshing"},A=(()=>{let m=h();if(m)throw m;if(W()){let g=x();if(g)throw g}return i()});return Object.defineProperties(A,{state:{get:p},loading:{get:W},error:{get:h},latest:{get:i}}),Object.defineProperty(A,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(A,Symbol.for("signal"),{value:!0,enumerable:!0}),[A,{mutate:f,refetch:()=>{F=!0,U(void 0)}}]}function me(e,n=300){let[t,r]=d(e),[o,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let y=typeof p=="function"?p(w(t)):p;return r(()=>y),c(!0),f(),i=setTimeout(h,n),y});return v(f),[o,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function On(e){return e!=null&&e!==""}function Xe(e,n,t={}){let{delay:r=300,initialValue:o,shouldFetch:u=On}=t,[a,c,i]=me(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=te(f,n,o===void 0?{}:{initialValue:o});return[h,{...i,query:a,setQuery:c,refetch:l}]}function re(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:re(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=re(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function Je(e){let n=S(e);return S(()=>re(n()))}var oe=q();Ee((e,n)=>{let t=K(n,oe);t&&(t.increment(),e.finally(()=>t.decrement()))});function Ze(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function en(e,n){return I(oe,e,n)}var nn=q();Ae((e,n)=>{let t=K(n,nn);return t?(t.setError(e),!0):!1});function tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function rn(e,n){return I(nn,e,n)}var on={State:D,Computed:k,subtle:{Watcher:P,untrack:N,currentComputed:be,hasSinks:ge}};var _n=Symbol.for("signal"),En=Symbol.for("fluixi-proxy");
@@ -28,7 +28,7 @@ export { createSelector, createDeferred, createDebounce } from './derived.js';
28
28
  export { createDebouncedSignal, createDebouncedResource, type DebounceControls, type DebouncedResourceOptions, type DebouncedResourceControls, } from './debounced.js';
29
29
  export { readChildren } from './children.js';
30
30
  export { createSignal, createMemo, createEffect, createComputed, createRenderEffect, createRoot, onCleanup, getOwner, setOwner, runWithOwner, batch, untrack, on, flush, startTransition, useTransition, } from './compat.js';
31
- export { createContext, useContext, provide, isOwnerDisposed, type Context, type Owner } from './runtime.js';
31
+ export { createContext, useContext, provide, isOwnerDisposed, createChildOwner, disposeScope, type Context, type Owner } from './runtime.js';
32
32
  export { createResource, type ResourceReturn, type ResourceActions } from './resource.js';
33
33
  export { createSuspenseBoundary, provideSuspense, SuspenseContext, type SuspenseBoundary, } from './suspense.js';
34
34
  export { createErrorBoundary, provideErrorBoundary, type ErrorBoundary, } from './error-boundary.js';
@@ -1 +1 @@
1
- {"version":3,"file":"signal-next.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/signal-next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,YAAY,EACV,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EACrE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAChF,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EACzE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAC9E,UAAU,EAAE,iBAAiB,EAC7B,mBAAmB,EAAE,uBAAuB,EAAE,2BAA2B,GAC1E,MAAM,cAAc,CAAC;AAKtB,cAAc,YAAY,CAAC;AAI3B,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,EACP,EAAE,EACF,KAAK,EACL,eAAe,EACf,aAAa,GAKd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAG7G,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAOpC,eAAO,MAAM,OAAO,eAAuB,CAAC;AAC5C,eAAO,MAAM,MAAM,eAA6B,CAAC"}
1
+ {"version":3,"file":"signal-next.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/signal-next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,YAAY,EACV,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EACrE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAChF,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EACzE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAC9E,UAAU,EAAE,iBAAiB,EAC7B,mBAAmB,EAAE,uBAAuB,EAAE,2BAA2B,GAC1E,MAAM,cAAc,CAAC;AAKtB,cAAc,YAAY,CAAC;AAI3B,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,EACP,EAAE,EACF,KAAK,EACL,eAAe,EACf,aAAa,GAKd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAG7I,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAOpC,eAAO,MAAM,OAAO,eAAuB,CAAC;AAC5C,eAAO,MAAM,MAAM,eAA6B,CAAC"}
@@ -21,7 +21,7 @@ export { createSignal, createMemo, createEffect, createComputed, createRenderEff
21
21
  // like the store keep type-checking. (Runtime is identical; only the surface type differs.)
22
22
  } from './compat.js';
23
23
  // Context (owner-tree)
24
- export { createContext, useContext, provide, isOwnerDisposed } from './runtime.js';
24
+ export { createContext, useContext, provide, isOwnerDisposed, createChildOwner, disposeScope } from './runtime.js';
25
25
  // Resources (+ __FX_DATA__ SSR seeding, reused from legacy hooks)
26
26
  export { createResource } from './resource.js';
27
27
  // Suspense
@@ -1 +1 @@
1
- var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var ye=0,Te=1,M=2,W=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends W{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);X(this)}}peek(){return this._value}},g=class extends W{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Te&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=ye}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);X(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===ye;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(Te);X(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function X(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var A=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){return!!e&&e.disposed===!0}function $(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function F(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=$(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ie(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function H(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function B(e,n,t){let r=$(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function we(e){o.onSuspend=e}function Se(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function K(){return o.owner}function be(e){let n=o.owner;return o.owner=e,n}function N(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function z(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)z(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function D(e){let n=$(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>z(n))}finally{o.owner=t}}function ge(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Me(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(V)))}function V(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function ke(){o.batchDepth===0&&V()}function Z(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&V()}}var J=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=$(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{z(this.owner,!1),N(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new A(()=>Me(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function Y(e){let n=new J(e);return()=>n.dispose()}function Ue(e){return!!e&&typeof e.then=="function"}ge(()=>{});var Re=Symbol.for("signal"),Fe=Symbol.for("memo"),Be=Symbol.for("signal-node");function p(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),ke(),a});return Object.defineProperty(r,Re,{value:!0,enumerable:!0}),Object.defineProperty(r,Be,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function S(e,n,t){let r=n,s=K(),u=new g(()=>N(s,()=>{try{return r=e(r)}catch(c){if(Ue(c))return Se(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,Re,{value:!0,enumerable:!0}),Object.defineProperty(a,Fe,{value:!0,enumerable:!0}),a}function P(e,n){let t=n;return Y(()=>{t=e(t)})}function Ne(e,n){let t=n;Y(()=>{t=e(t)})}function Ve(e,n){let t=n;return Y(()=>{t=e(t)})}function k(e){return Z(e)}function w(e){return U(e)}function _e(e){return Z(e),Promise.resolve()}function Le(){return[()=>!1,_e]}function je(){return V(),Promise.resolve()}function Ge(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(d=>d()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function _n(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let d=s[i],h=u.get(d);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,f,y;D(T=>{y=T;let[O,q]=p(i);f=q,l=n(d,O)});let x={item:d,rendered:l,dispose:y,setIndex:f};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function On(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],d=[],h=new Set;for(let l=0;l<a.length;l++){let f=n(a[l]),y=c.get(f);if(y&&!h.has(f))y.setIndex(l),i.push(y);else{let x,T,O;D(q=>{O=q;let[R,I]=p(l);T=I;let L=S(E=>{let b=(e()||[])[R()];return b??E},a[l]);x=t(L,R)}),i.push({rendered:x,dispose:O,setIndex:T})}d.push(f),h.add(f)}for(let[l,f]of c)h.has(l)||f.dispose();return s=d,u=i,i.map(l=>l.rendered)})})}function En(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let d,h,l,f=s[i];D(y=>{l=y;let[x,T]=p(f);h=T,d=n(x,i)}),r.push({rendered:d,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ee=!1,We=Symbol.for("signal"),ze=Symbol.for("memo"),$e=Symbol.for("resource");function ne(e){return typeof e=="function"&&e[We]===!0}function He(e){return typeof e=="function"&&e[ze]===!0}function Ke(e){return typeof e=="function"&&e[$e]===!0}function Ye(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Qe(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Xe(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Oe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Oe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var te=null;function Je(e){te=e}function ie(e){te&&te(e)}var re=null;function Ze(e){re=e}function ue(e){return re?re(e):void 0}var oe=null;function en(e){oe=e}function ae(){return oe?oe():void 0}var se=null;function nn(e){se=e}function ce(e,n){se&&se(e,n)}function tn(e,n=(t,r)=>t===r){let t=new Map;return P(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=p(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function rn(e,n){let[t,r]=p(e(),n);return P(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function on(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function sn(e){return!!e&&typeof e.then=="function"}var le=Symbol();function de(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=ae(),a=u!==void 0?ue(u):void 0,c=a!==void 0,[i,d]=p(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=p(void 0,{equals:!1}),[f,y]=p(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=p(void 0,{equals:!1}),[O,q]=p(void 0,{equals:!1}),R=le,I=!1;P(()=>{let m=r();if(O(),m===!1||m===null||m===void 0){R=le,k(()=>{y("unresolved"),T(void 0),l(void 0)});return}let b=I;if(I=!1,R!==le&&m===R&&!b)return;if(R=m,c){c=!1;return}let j=!1;v(()=>j=!0);let pe=w(f),Ae=w(i),he=pe==="ready"||pe==="refreshing";k(()=>{y(he?"refreshing":"pending"),l(void 0)});try{let _=s(m,{value:Ae,refetching:he});sn(_)?(T(_),ie(_),_.then(G=>{j||(u!==void 0&&ce(u,G),k(()=>{d(()=>G),y("ready"),T(void 0)}))},G=>{j||k(()=>{l(G),y("errored"),T(void 0)})})):k(()=>{d(()=>_),y("ready"),T(void 0)})}catch(_){if(j)return;k(()=>{l(_),y("errored"),T(void 0)})}});let L=()=>{let m=f();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(L()){let b=x();if(b)throw b}return i()});return Object.defineProperties(E,{state:{get:f},loading:{get:L},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:d,refetch:()=>{I=!0,q(void 0)}}]}function Ee(e,n=300){let[t,r]=p(e),[s,u]=p(e),[a,c]=p(!1),i,d=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{d();let f=w(t);return u(()=>f),c(!1),f},l=(f=>{let y=typeof f=="function"?f(w(t)):f;return r(()=>y),c(!0),d(),i=setTimeout(h,n),y});return v(d),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{d(),c(!1)}}]}function un(e){return e!=null&&e!==""}function an(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=un}=t,[a,c,i]=Ee(e,r),d=()=>u(a())?a():!1,[h,{refetch:l}]=de(d,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function Q(e){if(typeof e=="function"&&!e.length){let n=e();return ne(n)?n:Q(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=Q(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function cn(e){let n=S(e);return S(()=>Q(n()))}var fe=F();we((e,n)=>{let t=H(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function ln(){let[e,n]=p(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function dn(e,n){return B(fe,e,n)}var Ce=F();xe((e,n)=>{let t=H(n,Ce);return t?(t.setError(e),!0):!1});function fn(){let[e,n]=p(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function pn(e,n){return B(Ce,e,n)}var hn={State:C,Computed:g,subtle:{Watcher:A,untrack:U,currentComputed:me,hasSinks:ve}};var Xn=Symbol.for("signal"),Jn=Symbol.for("fluixi-proxy");export{Jn as $PROXY,Xn as $SIGNAL,hn as Signal,fe as SuspenseContext,ee as __DEV__,k as batch,Ne as createComputed,F as createContext,on as createDebounce,an as createDebouncedResource,Ee as createDebouncedSignal,rn as createDeferred,P as createEffect,fn as createErrorBoundary,S as createMemo,Ve as createRenderEffect,de as createResource,D as createRoot,tn as createSelector,p as createSignal,ln as createSuspenseBoundary,je as flush,K as getOwner,ue as getServerData,En as indexArray,Ye as isComponent,He as isMemo,qe as isOwnerDisposed,Xe as isProvider,Ke as isResource,ne as isSignal,Qe as isSuspense,On as keyArray,Oe as makeArrayFlat,_n as mapArray,ae as nextResourceId,Ge as on,v as onCleanup,B as provide,pn as provideErrorBoundary,dn as provideSuspense,cn as readChildren,ce as reportResourceData,N as runWithOwner,be as setOwner,nn as setResourceDataSink,en as setResourceIdSource,Je as setResourceTracker,Ze as setServerDataGetter,_e as startTransition,ie as trackResourcePromise,w as untrack,Ie as useContext,Le as useTransition};
1
+ var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var ye=0,Te=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);X(this)}}peek(){return this._value}},g=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Te&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=ye}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);X(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===ye;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(Te);X(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function X(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var A=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function H(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function V(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function we(e){o.onSuspend=e}function Se(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function K(){return o.owner}function be(e){let n=o.owner;return o.owner=e,n}function L(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function D(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function ge(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(j)))}function j(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function ke(){o.batchDepth===0&&j()}function Z(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&j()}}var J=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{F(this.owner,!1),L(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new A(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Y(e){let n=new J(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}ge(()=>{});var Re=Symbol.for("signal"),Ne=Symbol.for("memo"),Ve=Symbol.for("signal-node");function p(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),ke(),a});return Object.defineProperty(r,Re,{value:!0,enumerable:!0}),Object.defineProperty(r,Ve,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function S(e,n,t){let r=n,s=K(),u=new g(()=>L(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return Se(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,Re,{value:!0,enumerable:!0}),Object.defineProperty(a,Ne,{value:!0,enumerable:!0}),a}function P(e,n){let t=n;return Y(()=>{t=e(t)})}function Le(e,n){let t=n;Y(()=>{t=e(t)})}function je(e,n){let t=n;return Y(()=>{t=e(t)})}function k(e){return Z(e)}function w(e){return U(e)}function Oe(e){return Z(e),Promise.resolve()}function Ge(){return[()=>!1,Oe]}function We(){return j(),Promise.resolve()}function ze(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(d=>d()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function En(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let d=s[i],h=u.get(d);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,f,y;D(T=>{y=T;let[_,q]=p(i);f=q,l=n(d,_)});let x={item:d,rendered:l,dispose:y,setIndex:f};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Cn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],d=[],h=new Set;for(let l=0;l<a.length;l++){let f=n(a[l]),y=c.get(f);if(y&&!h.has(f))y.setIndex(l),i.push(y);else{let x,T,_;D(q=>{_=q;let[R,I]=p(l);T=I;let G=S(E=>{let b=(e()||[])[R()];return b??E},a[l]);x=t(G,R)}),i.push({rendered:x,dispose:_,setIndex:T})}d.push(f),h.add(f)}for(let[l,f]of c)h.has(l)||f.dispose();return s=d,u=i,i.map(l=>l.rendered)})})}function An(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let d,h,l,f=s[i];D(y=>{l=y;let[x,T]=p(f);h=T,d=n(x,i)}),r.push({rendered:d,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ee=!1,$e=Symbol.for("signal"),He=Symbol.for("memo"),Ke=Symbol.for("resource");function ne(e){return typeof e=="function"&&e[$e]===!0}function Ye(e){return typeof e=="function"&&e[He]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function _e(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?_e(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var te=null;function en(e){te=e}function ie(e){te&&te(e)}var re=null;function nn(e){re=e}function ue(e){return re?re(e):void 0}var oe=null;function tn(e){oe=e}function ae(){return oe?oe():void 0}var se=null;function rn(e){se=e}function ce(e,n){se&&se(e,n)}function on(e,n=(t,r)=>t===r){let t=new Map;return P(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=p(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function sn(e,n){let[t,r]=p(e(),n);return P(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function un(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function an(e){return!!e&&typeof e.then=="function"}var le=Symbol();function de(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=ae(),a=u!==void 0?ue(u):void 0,c=a!==void 0,[i,d]=p(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=p(void 0,{equals:!1}),[f,y]=p(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=p(void 0,{equals:!1}),[_,q]=p(void 0,{equals:!1}),R=le,I=!1;P(()=>{let m=r();if(_(),m===!1||m===null||m===void 0){R=le,k(()=>{y("unresolved"),T(void 0),l(void 0)});return}let b=I;if(I=!1,R!==le&&m===R&&!b)return;if(R=m,c){c=!1;return}let W=!1;v(()=>W=!0);let pe=w(f),Ae=w(i),he=pe==="ready"||pe==="refreshing";k(()=>{y(he?"refreshing":"pending"),l(void 0)});try{let O=s(m,{value:Ae,refetching:he});an(O)?(T(O),ie(O),O.then(z=>{W||(u!==void 0&&ce(u,z),k(()=>{d(()=>z),y("ready"),T(void 0)}))},z=>{W||k(()=>{l(z),y("errored"),T(void 0)})})):k(()=>{d(()=>O),y("ready"),T(void 0)})}catch(O){if(W)return;k(()=>{l(O),y("errored"),T(void 0)})}});let G=()=>{let m=f();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(G()){let b=x();if(b)throw b}return i()});return Object.defineProperties(E,{state:{get:f},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:d,refetch:()=>{I=!0,q(void 0)}}]}function Ee(e,n=300){let[t,r]=p(e),[s,u]=p(e),[a,c]=p(!1),i,d=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{d();let f=w(t);return u(()=>f),c(!1),f},l=(f=>{let y=typeof f=="function"?f(w(t)):f;return r(()=>y),c(!0),d(),i=setTimeout(h,n),y});return v(d),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{d(),c(!1)}}]}function cn(e){return e!=null&&e!==""}function ln(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=cn}=t,[a,c,i]=Ee(e,r),d=()=>u(a())?a():!1,[h,{refetch:l}]=de(d,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function Q(e){if(typeof e=="function"&&!e.length){let n=e();return ne(n)?n:Q(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=Q(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function dn(e){let n=S(e);return S(()=>Q(n()))}var fe=N();we((e,n)=>{let t=H(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function fn(){let[e,n]=p(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function pn(e,n){return V(fe,e,n)}var Ce=N();xe((e,n)=>{let t=H(n,Ce);return t?(t.setError(e),!0):!1});function hn(){let[e,n]=p(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function yn(e,n){return V(Ce,e,n)}var Tn={State:C,Computed:g,subtle:{Watcher:A,untrack:U,currentComputed:me,hasSinks:ve}};var Zn=Symbol.for("signal"),et=Symbol.for("fluixi-proxy");export{et as $PROXY,Zn as $SIGNAL,Tn as Signal,fe as SuspenseContext,ee as __DEV__,k as batch,qe as createChildOwner,Le as createComputed,N as createContext,un as createDebounce,ln as createDebouncedResource,Ee as createDebouncedSignal,sn as createDeferred,P as createEffect,hn as createErrorBoundary,S as createMemo,je as createRenderEffect,de as createResource,D as createRoot,on as createSelector,p as createSignal,fn as createSuspenseBoundary,Ie as disposeScope,We as flush,K as getOwner,ue as getServerData,An as indexArray,Xe as isComponent,Ye as isMemo,Me as isOwnerDisposed,Ze as isProvider,Qe as isResource,ne as isSignal,Je as isSuspense,Cn as keyArray,_e as makeArrayFlat,En as mapArray,ae as nextResourceId,ze as on,v as onCleanup,V as provide,yn as provideErrorBoundary,pn as provideSuspense,dn as readChildren,ce as reportResourceData,L as runWithOwner,be as setOwner,rn as setResourceDataSink,tn as setResourceIdSource,en as setResourceTracker,nn as setServerDataGetter,Oe as startTransition,ie as trackResourcePromise,w as untrack,Ue as useContext,Ge as useTransition};