@fluixi/reactive 1.0.0-alpha.79 → 1.0.0-alpha.80
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.
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/children.cjs +1 -1
- package/dist/lib/signal/graph/children.mjs +1 -1
- package/dist/lib/signal/graph/detect.cjs +1 -1
- package/dist/lib/signal/graph/detect.d.ts +1 -0
- package/dist/lib/signal/graph/detect.d.ts.map +1 -1
- package/dist/lib/signal/graph/detect.js +4 -1
- package/dist/lib/signal/graph/detect.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +1 -1
- package/package.json +2 -2
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var yn="1.0.0-alpha.79";function ze(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ot(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function Ye(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var pe=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let r of t)r.remove(this);if(n){for(let r of n)if(ze(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Ot(r)&&typeof r.unsubscribe=="function")try{r.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:r}=this;if(n){if(ze(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return r||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let r=n.indexOf(t);r!==-1&&(n.splice(r,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let r=n.indexOf(t);r!==-1&&(n.splice(r,1),n.length===1&&(this._parentOrParents=n[0]))}}};var Te=class extends pe{constructor(n,r,o){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:r,complete:o}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(r){throw r}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Xe=class extends Te{constructor(n,r,o,s){super(n,r,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function Lr(e){return new Te(e.next,e.error,e.complete)}var B=class extends pe{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,r){let o;t instanceof Te?o=t:o=new Xe(t,n,r);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((n,r)=>r(n),this)}toPromise(){return new Promise((t,n)=>{let r;this.subscribe({next:o=>r=o,error:n,complete:()=>t(r)})})}};var Rt=class extends B{constructor(){super(n=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)n.error(this.thrownError);else if(this.isStopped)n.complete();else return this.observers.push(n),()=>{let r=this.observers.indexOf(n);r!==-1&&this.observers.splice(r,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(n){if(this.isStopped)return;let{observers:r}=this,o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].next?.(n)}error(n){if(this.isStopped)return;this.hasError=!0,this.thrownError=n,this.isStopped=!0;let{observers:r}=this;this.observers=[];let o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].error?.(n)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:n}=this;this.observers=[];let r=n.length,o=n.slice();for(let s=0;s<r;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(r=>this.subscribe(r))}};var mn="__fluixi_signal_next_state__",hn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[mn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:hn,onSuspend:null,onError:null};var At=0,Ct=1,ye=2,Pe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},te=class extends Pe{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(ye);Qe(this)}}peek(){return this._value}},$=class extends Pe{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ye;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(a.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===Ct&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ye)break}(this.state===ye||!this._initialized)&&this.recompute(),this.state=At}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let n=a.consumer,r=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=n,a.untracked=r}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(ye);Qe(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===At;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Ct);Qe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Qe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ne=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 me(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Et(){return a.consumer}function Pt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function bn(e){let t=be(e);return e&&(e.owned??=[]).push(t),t}function vn(e,t=!0){he(e,t)}function Sn(e){return!!e&&e.disposed===!0}function be(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ve(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>{let o=a.owner,s=be(o);(s.contexts=new Map).set(t,r.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return r.children}finally{a.owner=o}}}}function xn(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function ke(e,t){let n=e;for(;n;){if(n.contexts&&n.contexts.has(t.id))return n.contexts.get(t.id);n=n.parent}return t.defaultValue}function Se(e,t,n){let r=be(a.owner);(r.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(r);let o=a.owner;a.owner=r;try{return n()}finally{a.owner=o}}function kt(e){a.onSuspend=e}function _t(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ft(e){a.onError=e}function _e(){return a.owner}function Dt(e){let t=a.owner;return a.owner=e,t}function xe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function _(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function he(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)he(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 re(e){let t=be(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>he(t))}finally{a.owner=n}}function Ut(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function gn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(ge)))}function ge(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{a.flushing=!1}}function It(){a.batchDepth===0&&ge()}function Ze(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&ge()}}var Je=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=be(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new $(()=>{he(this.owner,!1),xe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new ne(()=>gn(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"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),he(this.owner))}};function Fe(e){let t=new Je(e);return()=>t.dispose()}function wn(e){return!!e&&typeof e.then=="function"}Ut(()=>{});var Mt=Symbol.for("signal"),On=Symbol.for("memo"),Rn=Symbol.for("signal-node");function h(e,t){let n=new te(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),It(),i});return Object.defineProperty(r,Mt,{value:!0,enumerable:!0}),Object.defineProperty(r,Rn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[r,o]}function y(e,t,n){let r=t,o=_e(),s=new $(()=>xe(o,()=>{try{return r=e(r)}catch(c){if(wn(c))return _t(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,Mt,{value:!0,enumerable:!0}),Object.defineProperty(i,On,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return Fe(()=>{n=e(n)})}function An(e,t){let n=t;Fe(()=>{n=e(n)})}function Cn(e,t){let n=t;return Fe(()=>{n=e(n)})}function V(e){return Ze(e)}function U(e){return me(e)}function qt(e){return Ze(e),Promise.resolve()}function En(){return[()=>!1,qt]}function Pn(){return ge(),Promise.resolve()}function kn(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let c=r?e.map(l=>l()):e();if(s){s=!1,o=c;return}let u=me(()=>t(c,o,i));return o=c,u}}function no(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let u of r)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let l=o[u],b=s.get(l);if(b&&!c.has(b))b.setIndex(u),i.push(b),c.add(b);else{let d,m,v;re(x=>{v=x;let[C,p]=h(u);m=p,d=t(l,C)});let w={item:l,rendered:d,dispose:v,setIndex:m};i.push(w),c.add(w)}}for(let u of r)c.has(u)||u.dispose();return r=i,i.map(u=>u.rendered)})})}function ro(e,t,n,r){let o=[],s=[];return _(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return U(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let c=new Map;for(let d=0;d<o.length;d++)c.set(o[d],s[d]);let u=[],l=[],b=new Set;for(let d=0;d<i.length;d++){let m=t(i[d]),v=c.get(m);if(v&&!b.has(m))v.setIndex(d),u.push(v);else{let w,x,C;re(p=>{C=p;let[F,R]=h(d);x=R;let N=y(E=>{let D=(e()||[])[F()];return D??E},i[d]);w=n(N,F)}),u.push({rendered:w,dispose:C,setIndex:x})}l.push(m),b.add(m)}for(let[d,m]of c)b.has(d)||m.dispose();return o=l,s=u,u.map(d=>d.rendered)})})}function oo(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let u=s;u<i;u++){let l,b,d,m=o[u];re(v=>{d=v;let[w,x]=h(m);b=x,l=t(w,u)}),r.push({rendered:l,setItem:b,dispose:d})}for(let u=i;u<s;u++)r[u].dispose();i<s&&(r=r.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)r[u].setItem(o[u]);return r.map(u=>u.rendered)})})}var De=!1,_n=Symbol.for("signal"),Fn=Symbol.for("memo"),Dn=Symbol.for("resource");function et(e){return typeof e=="function"&&e[_n]===!0}function Un(e){return typeof e=="function"&&e[Fn]===!0}function In(e){return typeof e=="function"&&e[Dn]===!0}function Mn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function qn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Nn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Nt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Nt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var tt=null;function jt(e){tt=e}function oe(e){tt&&tt(e)}var nt=null;function Bt(e){nt=e}function Ue(e){return nt?nt(e):void 0}var rt=null;function Lt(e){rt=e}function Ie(){return rt?rt():void 0}var ot=null;function $t(e){ot=e}function Me(e,t){ot&&ot(e,t)}function jn(e,t=(n,r)=>n===r){let n=new Map;return M(()=>{let r=e();for(let[o,s]of n){let[i,c]=s,u=t(o,r);i()!==u&&c(u)}}),r=>{let o=n.get(r);if(!o){let[s,i]=h(!1);o=[s,i],n.set(r,o);let c=e();i(t(r,c))}return o[0]()}}function Bn(e,t){let[n,r]=h(e(),t);return M(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function Ln(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return _(()=>{n!==void 0&&clearTimeout(n)}),r}function $n(e){return!!e&&typeof e.then=="function"}var st=Symbol();function we(e,t,n={}){let r,o;typeof t=="function"?(r=typeof e=="function"?e:()=>e,o=t):(r=()=>!0,o=e,t&&typeof t=="object"&&(n=t));let s=n.transport===!1?void 0:Ie(),i=s!==void 0?Ue(s):void 0,c=i!==void 0,[u,l]=h(i!==void 0?i.value:n.initialValue,{equals:!1}),[b,d]=h(void 0,{equals:!1}),[m,v]=h(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,x]=h(void 0,{equals:!1}),[C,p]=h(void 0,{equals:!1}),F=st,R=!1;M(()=>{let A=r();if(C(),A===!1||A===null||A===void 0){F=st,V(()=>{v("unresolved"),x(void 0),d(void 0)});return}let D=R;if(R=!1,F!==st&&A===F&&!D)return;if(F=A,c){c=!1;return}let L=!1;_(()=>L=!0);let H=U(m),de=U(u),J=H==="ready"||H==="refreshing";V(()=>{v(J?"refreshing":"pending"),d(void 0)});try{let I=o(A,{value:de,refetching:J});$n(I)?(x(I),oe(I),I.then(W=>{L||(s!==void 0&&Me(s,W),V(()=>{l(()=>W),v("ready"),x(void 0)}))},W=>{L||V(()=>{d(W),v("errored"),x(void 0)})})):V(()=>{l(()=>I),v("ready"),x(void 0)})}catch(I){if(L)return;V(()=>{d(I),v("errored"),x(void 0)})}});let N=()=>{let A=m();return A==="pending"||A==="refreshing"},E=(()=>{let A=b();if(A)throw A;if(N()){let D=w();if(D)throw D}return u()});return Object.defineProperties(E,{state:{get:m},loading:{get:N},error:{get:b},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function Vt(e,t=300){let[n,r]=h(e),[o,s]=h(e),[i,c]=h(!1),u,l=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},b=()=>{l();let m=U(n);return s(()=>m),c(!1),m},d=(m=>{let v=typeof m=="function"?m(U(n)):m;return r(()=>v),c(!0),l(),u=setTimeout(b,t),v});return _(l),[o,d,{immediate:n,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function Vn(e){return e!=null&&e!==""}function Kn(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=Vn}=n,[i,c,u]=Vt(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=we(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function qe(e){if(typeof e=="function"&&!e.length){let t=e();return et(t)?t:qe(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=qe(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function it(e){let t=y(e);return y(()=>qe(t()))}var ut=ve();kt((e,t)=>{let n=ke(t,ut);n&&(n.increment(),e.finally(()=>n.decrement()))});function Hn(){let[e,t]=h(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function Wn(e,t){return Se(ut,e,t)}var Kt=ve();Ft((e,t)=>{let n=ke(t,Kt);return n?(n.setError(e),!0):!1});function Gn(){let[e,t]=h(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function zn(e,t){return Se(Kt,e,t)}var Yn={State:te,Computed:$,subtle:{Watcher:ne,untrack:me,currentComputed:Et,hasSinks:Pt}};var Eo=Symbol.for("signal"),Po=Symbol.for("fluixi-proxy");function Ko(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function Ho(e,t,n){return y(e,t,n)}function Wo(e,t){return M(e,t)}function Xn(...e){let[t,n]=we(...e);return Object.assign(t,n)}import{$PROXY as ct,batch as Jt,createEffect as je,createMemo as lt,createSignal as Zt,untrack as Qn}from"@fluixi/reactive/signal";var Be=Symbol("store-raw"),ie=Symbol("store-node"),Ht=Symbol("store-has"),ft=Symbol("store-self"),dt=Symbol("store-track"),Jn=Symbol("store-name"),Zn=Symbol("store-store"),Wt=new WeakMap,Gt=new WeakMap;function en(e){let[t,n]=Zt(e),r=t;return r.$=n,r}function Le(e){let t=Wt.get(e);return t||Wt.set(e,t={keys:new Map}),t}function zt(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=en(n)),r}function Yt(e){let t=Le(e);(t.all||(t.all=en()))()}function Xt(e,t){e.$(typeof t=="function"?()=>t:t)}function tn(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ne(e){if(!tn(e))return e;let t=Gt.get(e);if(t)return t;let n=new Proxy(e,er);return Gt.set(e,n),n}var er={get(e,t,n){if(t===Be||t===ie)return e;if(t===ct)return n;if(t===Ht)return i=>i in e;if(t==="__proxy")return!0;if(t===dt||t===ft)return Yt(e),n;let r=e[t];if(typeof r=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return r;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(n);let s=zt(Le(e),t,r)();return tn(s)?Ne(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Oe(e,t,void 0),!0},has(e,t){return t===Be||t===ct||t===ie||t===Ht||t===ft||t===dt?!0:(zt(Le(e),t,e[t])(),t in e)},ownKeys(e){return Yt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Oe(e,t,n){if(e[t]===n&&(n!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;n===void 0?delete e[t]:e[t]=n;let i=Le(e),c=i.keys.get(t);if(c&&Xt(c,n),o&&e.length!==s){let u=i.keys.get("length");u&&Xt(u,e.length)}i.all&&i.all.$(void 0)}function Qt(e,t){return typeof e=="function"?e(t):e}function pt(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];r&&typeof r=="object"&&!Array.isArray(r)&&o&&typeof o=="object"&&!Array.isArray(o)?pt(o,r):Oe(e,n,r)}}function yt(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function nn(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)nn(e[l],u,n);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Oe(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Oe(e,s,Qt(n,e[s]));return}Oe(e,o,Qt(n,e[o]))}function at(e,t,n){nn(e,yt(t),n)}function tr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&pt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&at(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){pt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){at(e,`${n}.${t[1].join(".")}`,t[2]);return}at(e,String(n),t[1])}function Tt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Tt);let t={};for(let n of Object.keys(e))t[n]=Tt(e[n]);return t}function se(e,t){let n=e;for(let r of yt(t)){if(n==null)return;n=n[r]}return n}var G=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>Jt(()=>tr(this.root,r)))}get state(){return Ne(this.root)}get proxy(){return Ne(this.root)}get accessor(){return(()=>Ne(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Re(this.state);let n=this.state;for(let r of yt(t)){if(n==null)return;n=n[r]}return Re(n)}select(t){return lt(()=>t(this.state))}subscribe(t){return je(()=>t(this.state))}watch(t,n){let r;return je(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return lt(()=>this.state[t])}produce(t){this.set((n=>{let r=Tt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=se(this.root,t);this.set(t,r.concat(n))}pop(t){let n=se(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=se(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=se(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=se(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=se(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=Zt(this.state);return t.toObservable()}dispose(){}},nr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function rn(e,t){for(let n of nr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function $e(e,t={immutable:!0}){let n=new G(e,t);return rn(n.set,n),[n.proxy,n.set]}function on(e,t={}){return new G(e,{...t,immutable:!1})}function rr(e,t={}){let n=new G(e(),t);return je(()=>n.set(e())),n}function or(e,t,n){return je(()=>n(t(e)))}function sr(e,t,n){return lt(()=>t(e),void 0,n)}function ir(e,t={}){let n=new G(e,t),r=(()=>n.proxy);return rn(r,n),r}function Re(e){if(e==null||typeof e!="object")return e;let t=e[Be];return t!==void 0?t:e}function sn(e){return Qn(()=>Re(e))}function ur(e){return mt(e)}function ar(e){return mt(e)?e[ie]:null}function cr(e){return e&&typeof e=="object"&&ie in e?e[ie]:null}function mt(e){return!!e&&typeof e=="object"&&(ct in e||e.__proxy===!0)}function lr(e){return e}var fr=Object.freeze({createStore:$e,createMutableStore:on,batch:Jt,unwrap:Re,untrackStore:sn});function ht(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(ht);let t={};for(let n of Object.keys(e))t[n]=ht(e[n]);return t}function dr(e){return t=>{let n=ht(t);return e(n),n}}function pr(e,t={}){return()=>e}function Tr(e,t){let[n,r]=$e(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function fs(e,t,n){return y(()=>t(e()),void 0,n)}function ds(e,t,n){return y(()=>e().filter(t),void 0,n)}function ps(e,t,n,r){return y(()=>e().reduce(t,n),void 0,r)}function Ts(e,t,n){return y(()=>e().find(t),void 0,n)}function ys(e,t,n){return y(()=>e().some(t),void 0,n)}function ms(e,t,n){return y(()=>e().every(t),void 0,n)}function hs(e,t,n){return y(()=>[...e()].sort(t),void 0,n)}function bs(e,t){return y(()=>[...new Set(e())],void 0,t)}function vs(e,t,n){return y(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function Ss(...e){return new B(t=>{let n=()=>e.map(o=>typeof o=="function"?o():o.get()),r=e.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{t.next(n())}):typeof o!="function"?o.subscribe(()=>{t.next(n())}):M(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function xs(e,t,n){return y(()=>e()||t(),void 0,n)}function gs(e,t,n,r){return y(()=>n(e(),t()),void 0,r)}function ws(e,t,n){return y(()=>t(e()),void 0,{equals:n,internal:!0})}function Os(e,t,n){return y(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function Rs(e,t,n){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function As(e,t,n,r){return y(()=>e()?t():n(),void 0,r)}function Cs(e,t,n){return y(()=>e()?t():void 0,void 0,n)}function Es(e,t,n){let[r,o]=h(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function Ps(e,t,n){let[r,o]=h(e()),s=0,i;return y(()=>{let c=e(),u=Date.now();u-s>=t?(s=u,o(()=>c)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>c)},t-(u-s)))}),r}function ks(e){let t=e;for(;typeof t=="function";)t=t();return t}var yr=Symbol.for("signal");var un=Symbol("fluixi-proxy"),mr=Symbol.for("signal-node"),Ae=0,vt=1,We=2,ae=3,S=null,O=null,f=null,Ke=null,He=0,hr=!1,bt=!1,ue=0,br=1e6,K=new WeakMap,Ve=null;var vr=new Map,Sr=0;function xr(){return`node_${++Sr}_${Date.now()}`}function gr(e){!1}function wr(e,t,n){let r={id:xr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return gr(r),r}function Or(e,t){return e===t}function cn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Rr(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Ve&&Ve.running&&!e.pure)Ve.effects.indexOf(e)===-1&&Ve.effects.push(e);else if(!e.pure||e.computed)xt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;Ge(r),f=o}}}function an(e,t){for(let n=0;n<e.length;n++)t(e[n])}function z(e,t){let n=e;typeof n=="object"&&n&&un in n&&delete n[un];let r=wr("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,c];K.set(o,new Set);let s;function i(){let u=O;if(u){u.sources?u.sources.indexOf(o)===-1&&u.sources.push(o):u.sources=[o];let l=K.get(o);l&&!l.has(u)&&l.add(u)}return n}function c(u){let l=typeof u=="function"?u(n):u,b=r.equals||Or;if(t?.equals===!1||!b(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let m=K.get(o);if(m&&m.size>0){let C=function(p,F=!1){let R=p.state;if(!(R===ae&&p===O)){if(F&&!p.pure){R===Ae&&(p.state=vt,hr&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=We,R===Ae||R===vt?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let N=K.get(p.accessor);N&&an(Array.from(N),E=>C(E,!0))}}};var d=C;let v=Array.from(m),w=[],x=new Set;an(v,C);for(let p of w)Rr(p)}}}return i.toObservable=()=>new B(u=>{let l=!0;return St(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,yr,{value:!0,enumerable:!0}),Object.defineProperty(i,mr,{value:r,enumerable:!1}),o}function St(e,t,n){let r={fn:e,state:We,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=q&&fe(q);return o&&(r.suspense=o),ln(r,t),()=>ce(r)}function ln(e,t){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,He++,He>br)throw He=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ae;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ae&&(e.state=Ae)}catch(o){if(Ye(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}cn(o)}finally{O=n,S=r}}function xt(e){if(!(e.disposed||!e.fn||e.state===Ae)&&(e.state===We||e.state===vt||e.state===ae)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)ce(e.owned[t]);e.owned=null}e.renderEffect?dn(e):ln(e,e.value)}}function ce(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=K.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)ce(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function Ge(e){let t=[],n=[];for(let o of e)o.pure&&!o.computed&&o.accessor?t.indexOf(o)===-1&&t.push(o):(o.computed||!o.pure)&&n.indexOf(o)===-1&&n.push(o);f=[];let r=0;for(;r<t.length;){let o=t[r++],s=K.get(o.accessor);if(s&&s.size>0){let c=O;O=null,o.accessor(),O=c}let i=f.splice(0);for(let c of i)c.pure&&!c.computed&&c.accessor?t.indexOf(c)===-1&&t.push(c):(c.computed||!c.pure)&&n.indexOf(c)===-1&&n.push(c)}f=null;for(let o of n)(o.computed||!o.pure)&&xt(o)}function Y(e){if(f&&ue>0)return e();if(f&&ue===0){let t=f,n=[];f=n,ue++;let r;try{r=e()}finally{ue--,f=t}let o=f;return Ge(n),f=o,r}ue++,f=[],Ke=[];try{return e()}finally{ue--,Ar()}}function Ar(){if(!bt){bt=!0,He=0;try{for(;f&&f.length>0;){let e=f;f=null,Ge(e)}if(f=null,Ke){let e=Ke;Ke=null;for(let t=0;t<e.length;t++)xt(e[t])}}finally{bt=!1}}}function le(e){let t=O;O=null;try{return e()}finally{O=t}}function fn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Cr(e){let t=Symbol("context"),n=Er(t);return{id:t,Provider:n,defaultValue:e}}function Er(e){return t=>{let n=S;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let r;return Pr(()=>{r=le(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),it(()=>t.children)})}),r}}function fe(e){let t=S;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function Pr(e,t,n){let r={fn:e,state:We,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=q&&fe(q);return o&&(r.suspense=o),dn(r),()=>ce(r)}function dn(e){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let o=0;o<e.cleanups.length;o++)e.cleanups[o]();e.cleanups=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ae;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ae&&(e.state=Ae)}catch(o){if(Ye(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}cn(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;Ge(o),f=s}}}var q;function pn(){return q||(q=Cr())}var Q=new Map,X=new Map,kr=0,_r=Symbol.for("signal"),Fr=Symbol.for("resource");function js(e,t,n={}){let r,o,s;typeof t=="function"?(r=e,o=t,s=n):(r=()=>!0,o=e,s=t??n);let{ttl:i=1/0,name:c=`_auto_${kr++}`,staleWhileRevalidate:u=!0}=s,l=c,b=T=>`${l}:${JSON.stringify(T)}`,d=T=>i===1/0||Date.now()-T.timestamp<=i,[m,v]=z(void 0,{equals:!1}),[w,x]=z("unresolved",{equals:!1}),[C,p]=z(void 0,{equals:!1}),[F,R]=z(void 0,{equals:!1}),[N,E]=z(!1),[A,D]=z(0,{equals:!1}),L=Symbol("unset"),H=L,de=!1,J=!1;function I(T,P,k,j){if(X.has(P)){X.get(P).then(g=>{j()||W(g,k)},g=>{!j()&&!k&>(g)}),k||R(X.get(P));return}let Z=Promise.resolve(o(T)).then(g=>(Q.set(P,{value:g,timestamp:Date.now()}),X.delete(P),g),g=>{throw X.delete(P),g});if(X.set(P,Z),!k){oe(Z),R(Z);let g=Ce&&fe(Ce);g&&(g.increment(),Z.finally(()=>g.decrement()))}Z.then(g=>{j()||W(g,k)},g=>{!j()&&!k&>(g)})}function W(T,P){Y(()=>{v(()=>T),x("ready"),E(!1),R(void 0),p(void 0)})}function gt(T){Y(()=>{p(T),x("errored"),R(void 0)})}let Ce;St(()=>{Ce===void 0&&(Ce=pn());let T=r();if(A(),T===!1||T===null||T===void 0){H=L,Y(()=>{x("unresolved"),R(void 0),p(void 0)});return}let P=de,k=J;de=!1,J=!1;let j=b(T);k&&Q.delete(j);let Z=H===L||T!==H;H=T;let g=!1;fn(()=>{g=!0});let ee=Q.get(j);if(ee&&d(ee)&&!P&&!k){(le(w)!=="ready"||le(m)!==ee.value)&&Y(()=>{v(()=>ee.value),x("ready"),E(!1),p(void 0)});return}if(ee&&u&&!k){Y(()=>{v(()=>ee.value),x("ready"),E(!0),p(void 0),R(void 0)}),I(T,j,!0,()=>g);return}let wt=le(w),Tn=wt==="ready"||wt==="refreshing";Y(()=>{x(Tn?"refreshing":"pending"),p(void 0),E(!1)}),I(T,j,!1,()=>g)});let Ee=(()=>{let T=C();if(T)throw T;if(w()==="pending"){let k=F();if(k)throw k}return m()});return Object.defineProperty(Ee,Fr,{value:!0,enumerable:!0}),Object.defineProperty(Ee,_r,{value:!0,enumerable:!0}),Object.defineProperties(Ee,{state:{get:w},loading:{get:()=>{let T=w();return T==="pending"||T==="refreshing"}},error:{get:C},latest:{get:m},stale:{get:N}}),[Ee,{mutate:v,refetch:()=>{de=!0,D(T=>T+1)},invalidate:()=>{let T=le(r);T!=null&&T!==!1&&Q.delete(b(T)),J=!0,D(P=>P+1)}}]}function Bs(e){let t=`${e}:`;for(let n of Q.keys())n.startsWith(t)&&Q.delete(n)}function Ls(){Q.clear(),X.clear()}export{Jn as $NAME,ie as $NODE,Po as $PROXY,Be as $RAW,ft as $SELF,Eo as $SIGNAL,Zn as $STORE,dt as $TRACK,B as Observable,Xe as SafeSubscriber,Yn as Signal,G as Store,fr as StoreAPI,Rt as Subject,Te as Subscriber,pe as Subscription,ut as SuspenseContext,yn as VERSION,De as __DEV__,V as batch,Ls as clearAllCachedResources,Bs as clearCachedResourceNamespace,vs as combineSignal,Ss as combineSignals,js as createCachedResource,bn as createChildOwner,An as createComputed,rr as createComputedStore,ve as createContext,Ln as createDebounce,Kn as createDebouncedResource,Vt as createDebouncedSignal,Bn as createDeferred,M as createEffect,Gn as createErrorBoundary,y as createMemo,on as createMutableStore,Cn as createRenderEffect,we as createResource,re as createRoot,jn as createSelector,h as createSignal,$e as createStore,or as createStoreEffect,sr as createStoreMemo,Hn as createSuspenseBoundary,Es as debounceSignal,vn as disposeScope,bs as distinctSignal,Wo as effect,ms as everySignal,ds as filterSignal,Ts as findSignal,Pn as flush,ar as getNode,_e as getOwner,Ue as getServerData,cr as getStoreNode,Cs as guardSignal,oo as indexArray,Mn as isComponent,Un as isMemo,Sn as isOwnerDisposed,Nn as isProvider,In as isResource,et as isSignal,ur as isStore,mt as isStoreProxy,qn as isSuspense,ro as keyArray,Nt as makeArrayFlat,no as mapArray,fs as mapSignal,Ho as memo,xs as mergeSignal,lr as modifiable,Ie as nextResourceId,Rs as omitSignal,kn as on,_ as onCleanup,Lr as operate,Os as pickSignal,dr as produceUtil,Se as provide,zn as provideErrorBoundary,Wn as provideSuspense,it as readChildren,ks as readSignal,pr as reconcileUtil,ps as reduceSignal,Me as reportResourceData,Xn as resource,xe as runWithOwner,ws as selectSignal,Dt as setOwner,$t as setResourceDataSink,Lt as setResourceIdSource,jt as setResourceTracker,Bt as setServerDataGetter,Ko as signal,ys as someSignal,hs as sortSignal,qt as startTransition,Tr as store,Ps as throttleSignal,oe as trackResourcePromise,U as untrack,sn as untrackStore,Re as unwrap,xn as useContext,En as useTransition,As as whenSignal,ir as wrap,gs as zipSignal};
|
|
1
|
+
var Sn="1.0.0-alpha.80";function Ye(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Rt(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function Xe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var pe=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let r of t)r.remove(this);if(n){for(let r of n)if(Ye(r)&&!(r instanceof e))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Rt(r)&&typeof r.unsubscribe=="function")try{r.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:r}=this;if(n){if(Ye(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return r||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let r=n.indexOf(t);r!==-1&&(n.splice(r,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let r=n.indexOf(t);r!==-1&&(n.splice(r,1),n.length===1&&(this._parentOrParents=n[0]))}}};var Te=class extends pe{constructor(n,r,o){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:r,complete:o}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(r){throw r}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Qe=class extends Te{constructor(n,r,o,s){super(n,r,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(r){this.error(r)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function $r(e){return new Te(e.next,e.error,e.complete)}var B=class extends pe{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,r){let o;t instanceof Te?o=t:o=new Qe(t,n,r);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((n,r)=>r(n),this)}toPromise(){return new Promise((t,n)=>{let r;this.subscribe({next:o=>r=o,error:n,complete:()=>t(r)})})}};var At=class extends B{constructor(){super(n=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)n.error(this.thrownError);else if(this.isStopped)n.complete();else return this.observers.push(n),()=>{let r=this.observers.indexOf(n);r!==-1&&this.observers.splice(r,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(n){if(this.isStopped)return;let{observers:r}=this,o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].next?.(n)}error(n){if(this.isStopped)return;this.hasError=!0,this.thrownError=n,this.isStopped=!0;let{observers:r}=this;this.observers=[];let o=r.length,s=r.slice();for(let i=0;i<o;i++)s[i].error?.(n)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:n}=this;this.observers=[];let r=n.length,o=n.slice();for(let s=0;s<r;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(r=>this.subscribe(r))}};var xn="__fluixi_signal_next_state__",gn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[xn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:gn,onSuspend:null,onError:null};var Ct=0,Et=1,ye=2,ke=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},te=class extends ke{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(ye);Je(this)}}peek(){return this._value}},$=class extends ke{constructor(n,r){super();this._threw=!1;this._initialized=!1;this.state=ye;this.sources=null;this._fn=n,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(a.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===Et&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===ye)break}(this.state===ye||!this._initialized)&&this.recompute(),this.state=Ct}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let n=a.consumer,r=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=n,a.untracked=r}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(ye);Je(this)}}markDirty(n){if(this.state>=n)return;let r=this.state===Ct;if(this.state=n,r){if(this.observers)for(let o of[...this.observers])o.markDirty(Et);Je(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Je(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var ne=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 me(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Pt(){return a.consumer}function kt(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wn(e){let t=be(e);return e&&(e.owned??=[]).push(t),t}function On(e,t=!0){he(e,t)}function Rn(e){return!!e&&e.disposed===!0}function be(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ve(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>{let o=a.owner,s=be(o);(s.contexts=new Map).set(t,r.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return r.children}finally{a.owner=o}}}}function An(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function _e(e,t){let n=e;for(;n;){if(n.contexts&&n.contexts.has(t.id))return n.contexts.get(t.id);n=n.parent}return t.defaultValue}function Se(e,t,n){let r=be(a.owner);(r.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(r);let o=a.owner;a.owner=r;try{return n()}finally{a.owner=o}}function _t(e){a.onSuspend=e}function Ft(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Dt(e){a.onError=e}function Fe(){return a.owner}function Ut(e){let t=a.owner;return a.owner=e,t}function xe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function _(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function he(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)he(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 re(e){let t=be(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let n=a.owner;a.owner=t;try{return e(()=>he(t))}finally{a.owner=n}}function It(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Cn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(ge)))}function ge(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{a.flushing=!1}}function Mt(){a.batchDepth===0&&ge()}function et(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&ge()}}var Ze=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=be(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new $(()=>{he(this.owner,!1),xe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new ne(()=>Cn(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"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),he(this.owner))}};function De(e){let t=new Ze(e);return()=>t.dispose()}function En(e){return!!e&&typeof e.then=="function"}It(()=>{});var qt=Symbol.for("signal"),Pn=Symbol.for("memo"),kn=Symbol.for("signal-node");function h(e,t){let n=new te(e,{equals:t?.equals}),r=(()=>n.get()),o=(s=>{let i=typeof s=="function"?s(n.peek()):s;return n.set(i),Mt(),i});return Object.defineProperty(r,qt,{value:!0,enumerable:!0}),Object.defineProperty(r,kn,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[r,o]}function y(e,t,n){let r=t,o=Fe(),s=new $(()=>xe(o,()=>{try{return r=e(r)}catch(c){if(En(c))return Ft(c),r;throw c}}),{equals:n?.equals}),i=(()=>s.get());return Object.defineProperty(i,qt,{value:!0,enumerable:!0}),Object.defineProperty(i,Pn,{value:!0,enumerable:!0}),i}function M(e,t){let n=t;return De(()=>{n=e(n)})}function _n(e,t){let n=t;De(()=>{n=e(n)})}function Fn(e,t){let n=t;return De(()=>{n=e(n)})}function V(e){return et(e)}function U(e){return me(e)}function Nt(e){return et(e),Promise.resolve()}function Dn(){return[()=>!1,Nt]}function Un(){return ge(),Promise.resolve()}function In(e,t,n){let r=Array.isArray(e),o,s=n?.defer??!1;return i=>{let c=r?e.map(l=>l()):e();if(s){s=!1,o=c;return}let u=me(()=>t(c,o,i));return o=c,u}}function ro(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=new Map;for(let u of r)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let l=o[u],b=s.get(l);if(b&&!c.has(b))b.setIndex(u),i.push(b),c.add(b);else{let d,m,v;re(x=>{v=x;let[C,p]=h(u);m=p,d=t(l,C)});let w={item:l,rendered:d,dispose:v,setIndex:m};i.push(w),c.add(w)}}for(let u of r)c.has(u)||u.dispose();return r=i,i.map(u=>u.rendered)})})}function oo(e,t,n,r){let o=[],s=[];return _(()=>{for(let i of s)i.dispose();o=[],s=[]}),y(()=>{let i=e()||[];return U(()=>{if(i.length===0){for(let d of s)d.dispose();return o=[],s=[],r?.fallback?r.fallback():[]}let c=new Map;for(let d=0;d<o.length;d++)c.set(o[d],s[d]);let u=[],l=[],b=new Set;for(let d=0;d<i.length;d++){let m=t(i[d]),v=c.get(m);if(v&&!b.has(m))v.setIndex(d),u.push(v);else{let w,x,C;re(p=>{C=p;let[F,R]=h(d);x=R;let N=y(E=>{let D=(e()||[])[F()];return D??E},i[d]);w=n(N,F)}),u.push({rendered:w,dispose:C,setIndex:x})}l.push(m),b.add(m)}for(let[d,m]of c)b.has(d)||m.dispose();return o=l,s=u,u.map(d=>d.rendered)})})}function so(e,t,n){let r=[];return _(()=>{for(let o of r)o.dispose();r=[]}),y(()=>{let o=e()||[];return U(()=>{if(o.length===0){for(let u of r)u.dispose();return r=[],n?.fallback?n.fallback():[]}let s=r.length,i=o.length;for(let u=s;u<i;u++){let l,b,d,m=o[u];re(v=>{d=v;let[w,x]=h(m);b=x,l=t(w,u)}),r.push({rendered:l,setItem:b,dispose:d})}for(let u=i;u<s;u++)r[u].dispose();i<s&&(r=r.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)r[u].setItem(o[u]);return r.map(u=>u.rendered)})})}var Mn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,we=typeof process>"u"?Mn:!1,qn=Symbol.for("signal"),Nn=Symbol.for("memo"),jn=Symbol.for("resource");function Ue(e){return typeof e=="function"&&e[qn]===!0}function jt(e){return typeof e=="function"&&e[Nn]===!0}function Bt(e){return typeof e=="function"&&e[jn]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Vt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function tt(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?tt(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt=null;function Kt(e){nt=e}function oe(e){nt&&nt(e)}var rt=null;function Ht(e){rt=e}function Ie(e){return rt?rt(e):void 0}var ot=null;function Wt(e){ot=e}function Me(){return ot?ot():void 0}var st=null;function Gt(e){st=e}function qe(e,t){st&&st(e,t)}function Bn(e,t=(n,r)=>n===r){let n=new Map;return M(()=>{let r=e();for(let[o,s]of n){let[i,c]=s,u=t(o,r);i()!==u&&c(u)}}),r=>{let o=n.get(r);if(!o){let[s,i]=h(!1);o=[s,i],n.set(r,o);let c=e();i(t(r,c))}return o[0]()}}function Ln(e,t){let[n,r]=h(e(),t);return M(()=>{let o=e();t?.timeoutMs?setTimeout(()=>r(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),n}function $n(e,t){let n,r=(...o)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...o)},t)};return _(()=>{n!==void 0&&clearTimeout(n)}),r}function Vn(e){return!!e&&typeof e.then=="function"}var it=Symbol();function Oe(e,t,n={}){let r,o;typeof t=="function"?(r=typeof e=="function"?e:()=>e,o=t):(r=()=>!0,o=e,t&&typeof t=="object"&&(n=t));let s=n.transport===!1?void 0:Me(),i=s!==void 0?Ie(s):void 0,c=i!==void 0,[u,l]=h(i!==void 0?i.value:n.initialValue,{equals:!1}),[b,d]=h(void 0,{equals:!1}),[m,v]=h(i!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,x]=h(void 0,{equals:!1}),[C,p]=h(void 0,{equals:!1}),F=it,R=!1;M(()=>{let A=r();if(C(),A===!1||A===null||A===void 0){F=it,V(()=>{v("unresolved"),x(void 0),d(void 0)});return}let D=R;if(R=!1,F!==it&&A===F&&!D)return;if(F=A,c){c=!1;return}let L=!1;_(()=>L=!0);let H=U(m),de=U(u),J=H==="ready"||H==="refreshing";V(()=>{v(J?"refreshing":"pending"),d(void 0)});try{let I=o(A,{value:de,refetching:J});Vn(I)?(x(I),oe(I),I.then(W=>{L||(s!==void 0&&qe(s,W),V(()=>{l(()=>W),v("ready"),x(void 0)}))},W=>{L||V(()=>{d(W),v("errored"),x(void 0)})})):V(()=>{l(()=>I),v("ready"),x(void 0)})}catch(I){if(L)return;V(()=>{d(I),v("errored"),x(void 0)})}});let N=()=>{let A=m();return A==="pending"||A==="refreshing"},E=(()=>{let A=b();if(A)throw A;if(N()){let D=w();if(D)throw D}return u()});return Object.defineProperties(E,{state:{get:m},loading:{get:N},error:{get:b},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:l,refetch:()=>{R=!0,p(void 0)}}]}function zt(e,t=300){let[n,r]=h(e),[o,s]=h(e),[i,c]=h(!1),u,l=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},b=()=>{l();let m=U(n);return s(()=>m),c(!1),m},d=(m=>{let v=typeof m=="function"?m(U(n)):m;return r(()=>v),c(!0),l(),u=setTimeout(b,t),v});return _(l),[o,d,{immediate:n,pending:i,flush:b,cancel:()=>{l(),c(!1)}}]}function Kn(e){return e!=null&&e!==""}function Hn(e,t,n={}){let{delay:r=300,initialValue:o,shouldFetch:s=Kn}=n,[i,c,u]=zt(e,r),l=()=>s(i())?i():!1,[b,{refetch:d}]=Oe(l,t,o===void 0?{}:{initialValue:o});return[b,{...u,query:i,setQuery:c,refetch:d}]}function Ne(e){if(typeof e=="function"&&!e.length){let t=e();return Ue(t)?t:Ne(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Ne(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function ut(e){let t=y(e);return we?y(()=>Ne(t()),void 0,{name:"children"}):y(()=>Ne(t()))}var at=ve();_t((e,t)=>{let n=_e(t,at);n&&(n.increment(),e.finally(()=>n.decrement()))});function Wn(){let[e,t]=h(0),n=0;return{increment:()=>t(n+=1),decrement:()=>t(n-=1),inFallback:()=>e()>0}}function Gn(e,t){return Se(at,e,t)}var Yt=ve();Dt((e,t)=>{let n=_e(t,Yt);return n?(n.setError(e),!0):!1});function zn(){let[e,t]=h(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:r=>t(()=>r)}}function Yn(e,t){return Se(Yt,e,t)}var Xn={State:te,Computed:$,subtle:{Watcher:ne,untrack:me,currentComputed:Pt,hasSinks:kt}};var Po=Symbol.for("signal"),ko=Symbol.for("fluixi-proxy");function Ho(e,t){let[n,r]=h(e,t);return Object.assign(n,{set:r})}function Wo(e,t,n){return y(e,t,n)}function Go(e,t){return M(e,t)}function Qn(...e){let[t,n]=Oe(...e);return Object.assign(t,n)}import{$PROXY as lt,batch as rn,createEffect as Be,createMemo as ft,createSignal as on,untrack as Jn}from"@fluixi/reactive/signal";var Le=Symbol("store-raw"),ie=Symbol("store-node"),Xt=Symbol("store-has"),dt=Symbol("store-self"),pt=Symbol("store-track"),Zn=Symbol("store-name"),er=Symbol("store-store"),Qt=new WeakMap,Jt=new WeakMap;function sn(e){let[t,n]=on(e),r=t;return r.$=n,r}function $e(e){let t=Qt.get(e);return t||Qt.set(e,t={keys:new Map}),t}function Zt(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=sn(n)),r}function en(e){let t=$e(e);(t.all||(t.all=sn()))()}function tn(e,t){e.$(typeof t=="function"?()=>t:t)}function un(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function je(e){if(!un(e))return e;let t=Jt.get(e);if(t)return t;let n=new Proxy(e,tr);return Jt.set(e,n),n}var tr={get(e,t,n){if(t===Le||t===ie)return e;if(t===lt)return n;if(t===Xt)return i=>i in e;if(t==="__proxy")return!0;if(t===pt||t===dt)return en(e),n;let r=e[t];if(typeof r=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return r;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(n);let s=Zt($e(e),t,r)();return un(s)?je(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Re(e,t,void 0),!0},has(e,t){return t===Le||t===lt||t===ie||t===Xt||t===dt||t===pt?!0:(Zt($e(e),t,e[t])(),t in e)},ownKeys(e){return en(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Re(e,t,n){if(e[t]===n&&(n!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;n===void 0?delete e[t]:e[t]=n;let i=$e(e),c=i.keys.get(t);if(c&&tn(c,n),o&&e.length!==s){let u=i.keys.get("length");u&&tn(u,e.length)}i.all&&i.all.$(void 0)}function nn(e,t){return typeof e=="function"?e(t):e}function Tt(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];r&&typeof r=="object"&&!Array.isArray(r)&&o&&typeof o=="object"&&!Array.isArray(o)?Tt(o,r):Re(e,n,r)}}function mt(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function an(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let l=0;l<e.length;l++)an(e[l],u,n);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Re(e,i,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Re(e,s,nn(n,e[s]));return}Re(e,o,nn(n,e[o]))}function ct(e,t,n){an(e,mt(t),n)}function nr(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&Tt(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&ct(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){Tt(e,n);return}if(Array.isArray(t[1])&&t.length>=3){ct(e,`${n}.${t[1].join(".")}`,t[2]);return}ct(e,String(n),t[1])}function yt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(yt);let t={};for(let n of Object.keys(e))t[n]=yt(e[n]);return t}function se(e,t){let n=e;for(let r of mt(t)){if(n==null)return;n=n[r]}return n}var G=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>rn(()=>nr(this.root,r)))}get state(){return je(this.root)}get proxy(){return je(this.root)}get accessor(){return(()=>je(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Ae(this.state);let n=this.state;for(let r of mt(t)){if(n==null)return;n=n[r]}return Ae(n)}select(t){return ft(()=>t(this.state))}subscribe(t){return Be(()=>t(this.state))}watch(t,n){let r;return Be(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return ft(()=>this.state[t])}produce(t){this.set((n=>{let r=yt(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=se(this.root,t);this.set(t,r.concat(n))}pop(t){let n=se(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=se(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=se(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=se(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=se(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=on(this.state);return t.toObservable()}dispose(){}},rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function cn(e,t){for(let n of rr)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function Ve(e,t={immutable:!0}){let n=new G(e,t);return cn(n.set,n),[n.proxy,n.set]}function ln(e,t={}){return new G(e,{...t,immutable:!1})}function or(e,t={}){let n=new G(e(),t);return Be(()=>n.set(e())),n}function sr(e,t,n){return Be(()=>n(t(e)))}function ir(e,t,n){return ft(()=>t(e),void 0,n)}function ur(e,t={}){let n=new G(e,t),r=(()=>n.proxy);return cn(r,n),r}function Ae(e){if(e==null||typeof e!="object")return e;let t=e[Le];return t!==void 0?t:e}function fn(e){return Jn(()=>Ae(e))}function ar(e){return ht(e)}function cr(e){return ht(e)?e[ie]:null}function lr(e){return e&&typeof e=="object"&&ie in e?e[ie]:null}function ht(e){return!!e&&typeof e=="object"&&(lt in e||e.__proxy===!0)}function fr(e){return e}var dr=Object.freeze({createStore:Ve,createMutableStore:ln,batch:rn,unwrap:Ae,untrackStore:fn});function bt(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(bt);let t={};for(let n of Object.keys(e))t[n]=bt(e[n]);return t}function pr(e){return t=>{let n=bt(t);return e(n),n}}function Tr(e,t={}){return()=>e}function yr(e,t){let[n,r]=Ve(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}function ds(e,t,n){return y(()=>t(e()),void 0,n)}function ps(e,t,n){return y(()=>e().filter(t),void 0,n)}function Ts(e,t,n,r){return y(()=>e().reduce(t,n),void 0,r)}function ys(e,t,n){return y(()=>e().find(t),void 0,n)}function ms(e,t,n){return y(()=>e().some(t),void 0,n)}function hs(e,t,n){return y(()=>e().every(t),void 0,n)}function bs(e,t,n){return y(()=>[...e()].sort(t),void 0,n)}function vs(e,t){return y(()=>[...new Set(e())],void 0,t)}function Ss(e,t,n){return y(()=>{let r=e.map(o=>o());return t(r)},void 0,n)}function xs(...e){return new B(t=>{let n=()=>e.map(o=>typeof o=="function"?o():o.get()),r=e.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{t.next(n())}):typeof o!="function"?o.subscribe(()=>{t.next(n())}):M(()=>{t.next(n())}));return()=>{r.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function gs(e,t,n){return y(()=>e()||t(),void 0,n)}function ws(e,t,n,r){return y(()=>n(e(),t()),void 0,r)}function Os(e,t,n){return y(()=>t(e()),void 0,{equals:n,internal:!0})}function Rs(e,t,n){return y(()=>{let r=e(),o={};for(let s of t)o[s]=r[s];return o},void 0,n)}function As(e,t,n){return y(()=>{let o={...e()};for(let s of t)delete o[s];return o},void 0,n)}function Cs(e,t,n,r){return y(()=>e()?t():n(),void 0,r)}function Es(e,t,n){return y(()=>e()?t():void 0,void 0,n)}function Ps(e,t,n){let[r,o]=h(e()),s;return y(()=>{let i=e();clearTimeout(s),s=setTimeout(()=>o(()=>i),t)}),r}function ks(e,t,n){let[r,o]=h(e()),s=0,i;return y(()=>{let c=e(),u=Date.now();u-s>=t?(s=u,o(()=>c)):(clearTimeout(i),i=setTimeout(()=>{s=Date.now(),o(()=>c)},t-(u-s)))}),r}function _s(e){let t=e;for(;typeof t=="function";)t=t();return t}var mr=Symbol.for("signal");var dn=Symbol("fluixi-proxy"),hr=Symbol.for("signal-node"),Ce=0,St=1,Ge=2,ae=3,S=null,O=null,f=null,He=null,We=0,br=!1,vt=!1,ue=0,vr=1e6,K=new WeakMap,Ke=null;var Sr=new Map,xr=0;function gr(){return`node_${++xr}_${Date.now()}`}function wr(e){we&&Sr.set(e.id,new WeakRef(e))}function Or(e,t,n){let r={id:gr(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return wr(r),r}function Rr(e,t){return e===t}function Tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function Ar(e){if(f)f.indexOf(e)===-1&&f.push(e);else if(Ke&&Ke.running&&!e.pure)Ke.effects.indexOf(e)===-1&&Ke.effects.push(e);else if(!e.pure||e.computed)gt(e);else if(e.pure&&!e.computed&&e.accessor){let t=O,n=f;O=null,f=[],e.accessor(),O=t;let r=f;if(f=n,r.length>0){let o=f;ze(r),f=o}}}function pn(e,t){for(let n=0;n<e.length;n++)t(e[n])}function z(e,t){let n=e;typeof n=="object"&&n&&dn in n&&delete n[dn];let r=Or("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),o=[i,c];K.set(o,new Set);let s;function i(){let u=O;if(u){u.sources?u.sources.indexOf(o)===-1&&u.sources.push(o):u.sources=[o];let l=K.get(o);l&&!l.has(u)&&l.add(u)}return n}function c(u){let l=typeof u=="function"?u(n):u,b=r.equals||Rr;if(t?.equals===!1||!b(n,l)){n=l,r.value=l,r.version++,r.updated=Date.now();let m=K.get(o);if(m&&m.size>0){let C=function(p,F=!1){let R=p.state;if(!(R===ae&&p===O)){if(F&&!p.pure){R===Ce&&(p.state=St,br&&(f!==null&&f.indexOf(p)===-1?f.push(p):w.push(p)));return}if(!x.has(p)&&(x.add(p),p.state=Ge,R===Ce||R===St?w.push(p):!p.pure&&f!==null&&f.indexOf(p)===-1&&f.push(p),p.pure&&p.accessor)){let N=K.get(p.accessor);N&&pn(Array.from(N),E=>C(E,!0))}}};var d=C;let v=Array.from(m),w=[],x=new Set;pn(v,C);for(let p of w)Ar(p)}}}return i.toObservable=()=>new B(u=>{let l=!0;return xt(()=>{let d=i();l?l=!1:u.next(d)})}),Object.defineProperty(i,mr,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:r,enumerable:!1}),o}function xt(e,t,n){let r={fn:e,state:Ge,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=q&&fe(q);return o&&(r.suspense=o),yn(r,t),()=>ce(r)}function yn(e,t){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let n=O,r=S;if(O=e,S=e,We++,We>vr)throw We=0,O=n,S=r,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=ae;let o=e.fn(t);typeof o=="function"&&(e.cleanups?e.cleanups.push(o):e.cleanups=[o]),e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=n,S=r}}function gt(e){if(!(e.disposed||!e.fn||e.state===Ce)&&(e.state===Ge||e.state===St||e.state===ae)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)ce(e.owned[t]);e.owned=null}e.renderEffect?hn(e):yn(e,e.value)}}function ce(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=K.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)ce(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function ze(e){let t=[],n=[];for(let o of e)o.pure&&!o.computed&&o.accessor?t.indexOf(o)===-1&&t.push(o):(o.computed||!o.pure)&&n.indexOf(o)===-1&&n.push(o);f=[];let r=0;for(;r<t.length;){let o=t[r++],s=K.get(o.accessor);if(s&&s.size>0){let c=O;O=null,o.accessor(),O=c}let i=f.splice(0);for(let c of i)c.pure&&!c.computed&&c.accessor?t.indexOf(c)===-1&&t.push(c):(c.computed||!c.pure)&&n.indexOf(c)===-1&&n.push(c)}f=null;for(let o of n)(o.computed||!o.pure)&>(o)}function Y(e){if(f&&ue>0)return e();if(f&&ue===0){let t=f,n=[];f=n,ue++;let r;try{r=e()}finally{ue--,f=t}let o=f;return ze(n),f=o,r}ue++,f=[],He=[];try{return e()}finally{ue--,Cr()}}function Cr(){if(!vt){vt=!0,We=0;try{for(;f&&f.length>0;){let e=f;f=null,ze(e)}if(f=null,He){let e=He;He=null;for(let t=0;t<e.length;t++)gt(e[t])}}finally{vt=!1}}}function le(e){let t=O;O=null;try{return e()}finally{O=t}}function mn(e){S&&(S.cleanups?S.cleanups.push(e):S.cleanups=[e])}function Er(e){let t=Symbol("context"),n=Pr(t);return{id:t,Provider:n,defaultValue:e}}function Pr(e){return t=>{let n=S;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let r;return kr(()=>{r=le(()=>{let o=S;return o&&(o.contexts||(o.contexts=new Map),o.contexts.set(e,t.value)),ut(()=>t.children)})}),r}}function fe(e){let t=S;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function kr(e,t,n){let r={fn:e,state:Ge,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:S,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};S&&(S.owned?S.owned.push(r):S.owned=[r]);let o=q&&fe(q);return o&&(r.suspense=o),hn(r),()=>ce(r)}function hn(e){if(e.sources){for(let o of e.sources){let s=K.get(o);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let o=0;o<e.cleanups.length;o++)e.cleanups[o]();e.cleanups=null}if(e.owned){for(let o=0;o<e.owned.length;o++)ce(e.owned[o]);e.owned=null}let t=O,n=S,r=f;O=e,S=e,f===null&&(f=[]),e.state=ae;try{let o=e.fn(e.value);typeof o=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(o)),e.value=o,e.state===ae&&(e.state=Ce)}catch(o){if(Xe(o)){let s=q&&fe(q);s&&(s.increment(),o.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Tn(o)}finally{O=t,S=n;let o=f;if(f=r,o!==r&&o&&o.length>0){let s=f;ze(o),f=s}}}var q;function bn(){return q||(q=Er())}var Q=new Map,X=new Map,_r=0,Fr=Symbol.for("signal"),Dr=Symbol.for("resource");function Ls(e,t,n={}){let r,o,s;typeof t=="function"?(r=e,o=t,s=n):(r=()=>!0,o=e,s=t??n);let{ttl:i=1/0,name:c=`_auto_${_r++}`,staleWhileRevalidate:u=!0}=s,l=c,b=T=>`${l}:${JSON.stringify(T)}`,d=T=>i===1/0||Date.now()-T.timestamp<=i,[m,v]=z(void 0,{equals:!1}),[w,x]=z("unresolved",{equals:!1}),[C,p]=z(void 0,{equals:!1}),[F,R]=z(void 0,{equals:!1}),[N,E]=z(!1),[A,D]=z(0,{equals:!1}),L=Symbol("unset"),H=L,de=!1,J=!1;function I(T,P,k,j){if(X.has(P)){X.get(P).then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)}),k||R(X.get(P));return}let Z=Promise.resolve(o(T)).then(g=>(Q.set(P,{value:g,timestamp:Date.now()}),X.delete(P),g),g=>{throw X.delete(P),g});if(X.set(P,Z),!k){oe(Z),R(Z);let g=Ee&&fe(Ee);g&&(g.increment(),Z.finally(()=>g.decrement()))}Z.then(g=>{j()||W(g,k)},g=>{!j()&&!k&&wt(g)})}function W(T,P){Y(()=>{v(()=>T),x("ready"),E(!1),R(void 0),p(void 0)})}function wt(T){Y(()=>{p(T),x("errored"),R(void 0)})}let Ee;xt(()=>{Ee===void 0&&(Ee=bn());let T=r();if(A(),T===!1||T===null||T===void 0){H=L,Y(()=>{x("unresolved"),R(void 0),p(void 0)});return}let P=de,k=J;de=!1,J=!1;let j=b(T);k&&Q.delete(j);let Z=H===L||T!==H;H=T;let g=!1;mn(()=>{g=!0});let ee=Q.get(j);if(ee&&d(ee)&&!P&&!k){(le(w)!=="ready"||le(m)!==ee.value)&&Y(()=>{v(()=>ee.value),x("ready"),E(!1),p(void 0)});return}if(ee&&u&&!k){Y(()=>{v(()=>ee.value),x("ready"),E(!0),p(void 0),R(void 0)}),I(T,j,!0,()=>g);return}let Ot=le(w),vn=Ot==="ready"||Ot==="refreshing";Y(()=>{x(vn?"refreshing":"pending"),p(void 0),E(!1)}),I(T,j,!1,()=>g)});let Pe=(()=>{let T=C();if(T)throw T;if(w()==="pending"){let k=F();if(k)throw k}return m()});return Object.defineProperty(Pe,Dr,{value:!0,enumerable:!0}),Object.defineProperty(Pe,Fr,{value:!0,enumerable:!0}),Object.defineProperties(Pe,{state:{get:w},loading:{get:()=>{let T=w();return T==="pending"||T==="refreshing"}},error:{get:C},latest:{get:m},stale:{get:N}}),[Pe,{mutate:v,refetch:()=>{de=!0,D(T=>T+1)},invalidate:()=>{let T=le(r);T!=null&&T!==!1&&Q.delete(b(T)),J=!0,D(P=>P+1)}}]}function $s(e){let t=`${e}:`;for(let n of Q.keys())n.startsWith(t)&&Q.delete(n)}function Vs(){Q.clear(),X.clear()}export{Zn as $NAME,ie as $NODE,ko as $PROXY,Le as $RAW,dt as $SELF,Po as $SIGNAL,er as $STORE,pt as $TRACK,B as Observable,Qe as SafeSubscriber,Xn as Signal,G as Store,dr as StoreAPI,At as Subject,Te as Subscriber,pe as Subscription,at as SuspenseContext,Sn as VERSION,we as __DEV__,V as batch,Vs as clearAllCachedResources,$s as clearCachedResourceNamespace,Ss as combineSignal,xs as combineSignals,Ls as createCachedResource,wn as createChildOwner,_n as createComputed,or as createComputedStore,ve as createContext,$n as createDebounce,Hn as createDebouncedResource,zt as createDebouncedSignal,Ln as createDeferred,M as createEffect,zn as createErrorBoundary,y as createMemo,ln as createMutableStore,Fn as createRenderEffect,Oe as createResource,re as createRoot,Bn as createSelector,h as createSignal,Ve as createStore,sr as createStoreEffect,ir as createStoreMemo,Wn as createSuspenseBoundary,Ps as debounceSignal,On as disposeScope,vs as distinctSignal,Go as effect,hs as everySignal,ps as filterSignal,ys as findSignal,Un as flush,cr as getNode,Fe as getOwner,Ie as getServerData,lr as getStoreNode,Es as guardSignal,so as indexArray,Lt as isComponent,jt as isMemo,Rn as isOwnerDisposed,Vt as isProvider,Bt as isResource,Ue as isSignal,ar as isStore,ht as isStoreProxy,$t as isSuspense,oo as keyArray,tt as makeArrayFlat,ro as mapArray,ds as mapSignal,Wo as memo,gs as mergeSignal,fr as modifiable,Me as nextResourceId,As as omitSignal,In as on,_ as onCleanup,$r as operate,Rs as pickSignal,pr as produceUtil,Se as provide,Yn as provideErrorBoundary,Gn as provideSuspense,ut as readChildren,_s as readSignal,Tr as reconcileUtil,Ts as reduceSignal,qe as reportResourceData,Qn as resource,xe as runWithOwner,Os as selectSignal,Ut as setOwner,Gt as setResourceDataSink,Wt as setResourceIdSource,Kt as setResourceTracker,Ht as setServerDataGetter,Ho as signal,ms as someSignal,bs as sortSignal,Nt as startTransition,yr as store,ks as throttleSignal,oe as trackResourcePromise,U as untrack,fn as untrackStore,Ae as unwrap,An as useContext,Dn as useTransition,Cs as whenSignal,ur as wrap,ws as zipSignal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var le=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!He.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Je=e=>Ye(le({},"__esModule",{value:!0}),e);var Ot={};Ke(Ot,{clearAllCachedResources:()=>gt,clearCachedResourceNamespace:()=>St,createCachedResource:()=>xt});module.exports=Je(Ot);function ce(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Oe(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(ce(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Oe(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(ce(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},de=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new de(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var Xe=Symbol.for("signal");function Re(e){return typeof e=="function"&&e[Xe]===!0}var Qe="__fluixi_signal_next_state__",Ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Qe]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ze,onSuspend:null,onError:null};var Ce=0,_e=1,J=2,pe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends pe{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===_e&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ce}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ae(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Ce;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(_e);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Pe(){return h.owner}function Fe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function ke(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function et(e){return!!e&&typeof e.then=="function"}ke(()=>{});var tt=Symbol.for("signal"),nt=Symbol.for("memo");function Q(e,t,n){let o=t,r=Pe(),s=new X(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(et(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,tt,{value:!0,enumerable:!0}),Object.defineProperty(a,nt,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Re(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Q(e);return Q(()=>Z(t()))}var Ne=null;function he(e){Ne&&Ne(e)}var rt=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),ot=Symbol.for("signal-node"),G=0,Te=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,st=!1,ve=!1,N=0,it=1e6,O=new WeakMap,ee=null;var ut=new Map,at=0;function lt(){return`node_${++at}_${Date.now()}`}function ct(e){!1}function ft(e,t,n){let o={id:lt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ct(o),o}function dt(e,t){return e===t}function Me(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function pt(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)be(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ue(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ie in n&&delete n[Ie];let o=ft("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||dt;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===G&&(l.state=Te,st&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===G||m===Te?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var V=F;let P=Array.from(R),x=[],S=new Set;Ue(P,F);for(let l of x)pt(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return ye(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),Object.defineProperty(a,ot,{value:o,enumerable:!1}),r}function ye(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Le(o,t),()=>U(o)}function Le(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>it)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Me(r)}finally{v=n,c=o}}function be(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===re||e.state===Te||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?je(e):Le(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&be(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ht()}}function ht(){if(!ve){ve=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)be(e[t])}}finally{ve=!1}}}function M(e){let t=v;v=null;try{return e()}finally{v=t}}function Be(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function vt(e){let t=Symbol("context"),n=Tt(t);return{id:t,Provider:n,defaultValue:e}}function Tt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return yt(()=>{o=M(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),qe(()=>t.children)})}),o}}function L(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function yt(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),je(o),()=>U(o)}function je(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Me(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Ge(){return w||(w=vt())}var E=new Map,A=new Map,bt=0,mt=Symbol.for("signal"),wt=Symbol.for("resource");function xt(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${bt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ve,me]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function we(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){he(D),m(D);let p=z&&L(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)})}function xe(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Se(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;ye(()=>{z===void 0&&(z=Ge());let u=o();if(Ve(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=E.get(g);if(q&&V(q)&&!T&&!y){(M(x)!=="ready"||M(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),we(u,g,!0,()=>p);return}let ge=M(x),$e=ge==="ready"||ge==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),we(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,wt,{value:!0,enumerable:!0}),Object.defineProperty(H,mt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,me(u=>u+1)},invalidate:()=>{let u=M(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,me(T=>T+1)}}]}function St(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function gt(){E.clear(),A.clear()}
|
|
1
|
+
"use strict";var ce=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)ce(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!He.call(e,r)&&r!==n&&ce(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Xe=e=>Ye(ce({},"__esModule",{value:!0}),e);var Rt={};Ke(Rt,{clearAllCachedResources:()=>Ot,clearCachedResourceNamespace:()=>gt,createCachedResource:()=>St});module.exports=Xe(Rt);function fe(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ce(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function de(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(fe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ce(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(fe(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new pe(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var Je=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?Je:!1,Qe=Symbol.for("signal");function he(e){return typeof e=="function"&&e[Qe]===!0}var Ze="__fluixi_signal_next_state__",et=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Ze]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:et,onSuspend:null,onError:null};var _e=0,Ae=1,J=2,ve=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var Q=class extends ve{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===Ae&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=_e}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Pe(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===_e;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ae);Pe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Pe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Fe(){return h.owner}function ke(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function De(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function tt(e){return!!e&&typeof e.then=="function"}De(()=>{});var nt=Symbol.for("signal"),rt=Symbol.for("memo");function Z(e,t,n){let o=t,r=Fe(),s=new Q(()=>ke(r,()=>{try{return o=e(o)}catch(f){if(tt(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,nt,{value:!0,enumerable:!0}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),a}function ee(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:ee(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=ee(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Z(e);return X?Z(()=>ee(t()),void 0,{name:"children"}):Z(()=>ee(t()))}var Ne=null;function Te(e){Ne&&Ne(e)}var ot=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),st=Symbol.for("signal-node"),G=0,be=1,oe=2,I=3,c=null,v=null,i=null,ne=null,re=0,it=!1,ye=!1,N=0,ut=1e6,O=new WeakMap,te=null;var at=new Map,lt=0;function ct(){return`node_${++lt}_${Date.now()}`}function ft(e){X&&at.set(e.id,new WeakRef(e))}function dt(e,t,n){let o={id:ct(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ft(o),o}function pt(e,t){return e===t}function Le(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function ht(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(te&&te.running&&!e.pure)te.effects.indexOf(e)===-1&&te.effects.push(e);else if(!e.pure||e.computed)we(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;se(o),i=r}}}function Ue(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ie in n&&delete n[Ie];let o=dt("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||pt;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,ie=!1){let m=l.state;if(!(m===I&&l===v)){if(ie&&!l.pure){m===G&&(l.state=be,it&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=oe,m===G||m===be?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var V=F;let E=Array.from(R),x=[],S=new Set;Ue(E,F);for(let l of x)ht(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return me(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,ot,{value:!0,enumerable:!0}),Object.defineProperty(a,st,{value:o,enumerable:!1}),r}function me(e,t,n){let o={fn:e,state:oe,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Me(o,t),()=>U(o)}function Me(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,re++,re>ut)throw re=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(de(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=n,c=o}}function we(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===oe||e.state===be||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?je(e):Me(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function se(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&we(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return se(n),i=r,o}N++,i=[],ne=[];try{return e()}finally{N--,vt()}}function vt(){if(!ye){ye=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,ne){let e=ne;ne=null;for(let t=0;t<e.length;t++)we(e[t])}}finally{ye=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Be(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function Tt(e){let t=Symbol("context"),n=yt(t);return{id:t,Provider:n,defaultValue:e}}function yt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return bt(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),qe(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function bt(e,t,n){let o={fn:e,state:oe,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),je(o),()=>U(o)}function je(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(de(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;se(r),i=s}}}var w;function Ge(){return w||(w=Tt())}var P=new Map,A=new Map,mt=0,wt=Symbol.for("signal"),xt=Symbol.for("resource");function St(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${mt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,E]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ve,xe]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function Se(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||ge(p,y)},p=>{!g()&&!y&&Oe(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(P.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){Te(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||ge(p,y)},p=>{!g()&&!y&&Oe(p)})}function ge(u,T){_(()=>{E(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Oe(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;me(()=>{z===void 0&&(z=Ge());let u=o();if(Ve(),u===!1||u===null||u===void 0){W=ue,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let g=B(u);y&&P.delete(g);let D=W===ue||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=P.get(g);if(q&&V(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{E(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{E(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),Se(u,g,!0,()=>p);return}let Re=L(x),$e=Re==="ready"||Re==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),Se(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(H,xt,{value:!0,enumerable:!0}),Object.defineProperty(H,wt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:E,refetch:()=>{ae=!0,xe(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&P.delete(B(u)),le=!0,xe(T=>T+1)}}]}function gt(e){let t=`${e}:`;for(let n of P.keys())n.startsWith(t)&&P.delete(n)}function Ot(){P.clear(),A.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function le(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function ge(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function ce(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(le(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(ge(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(le(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},fe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new fe(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var $e=Symbol.for("signal");function Oe(e){return typeof e=="function"&&e[$e]===!0}var We="__fluixi_signal_next_state__",ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[We]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ze,onSuspend:null,onError:null};var Re=0,Ce=1,J=2,de=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends de{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===Ce&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Re}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);_e(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Re;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ce);_e(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _e(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ae(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Ee(){return h.owner}function Pe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function Fe(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function He(e){return!!e&&typeof e.then=="function"}Fe(()=>{});var Ke=Symbol.for("signal"),Ye=Symbol.for("memo");function Q(e,t,n){let o=t,r=Ee(),s=new X(()=>Pe(r,()=>{try{return o=e(o)}catch(f){if(He(f))return Ae(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ke,{value:!0,enumerable:!0}),Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Oe(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function De(e){let t=Q(e);return Q(()=>Z(t()))}var qe=null;function pe(e){qe&&qe(e)}var Je=Symbol.for("signal");var Ne=Symbol("fluixi-proxy"),Xe=Symbol.for("signal-node"),G=0,ve=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,Qe=!1,he=!1,N=0,Ze=1e6,O=new WeakMap,ee=null;var et=new Map,tt=0;function nt(){return`node_${++tt}_${Date.now()}`}function rt(e){!1}function ot(e,t,n){let o={id:nt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return rt(o),o}function st(e,t){return e===t}function Ue(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function it(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)ye(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ie(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ne in n&&delete n[Ne];let o=ot("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||st;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===G&&(l.state=ve,Qe&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===G||m===ve?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ie(Array.from($),k=>F(k,!0))}}};var V=F;let P=Array.from(R),x=[],S=new Set;Ie(P,F);for(let l of x)it(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return Te(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:o,enumerable:!1}),r}function Te(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Me(o,t),()=>U(o)}function Me(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>Ze)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(ce(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=n,c=o}}function ye(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===re||e.state===ve||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Be(e):Me(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&ye(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ut()}}function ut(){if(!he){he=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)ye(e[t])}}finally{he=!1}}}function M(e){let t=v;v=null;try{return e()}finally{v=t}}function Le(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function at(e){let t=Symbol("context"),n=lt(t);return{id:t,Provider:n,defaultValue:e}}function lt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return ct(()=>{o=M(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),De(()=>t.children)})}),o}}function L(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function ct(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Be(o),()=>U(o)}function Be(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(ce(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function je(){return w||(w=at())}var E=new Map,A=new Map,ft=0,dt=Symbol.for("signal"),pt=Symbol.for("resource");function tn(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${ft++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ge,be]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function me(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||we(p,y)},p=>{!g()&&!y&&xe(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){pe(D),m(D);let p=z&&L(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||we(p,y)},p=>{!g()&&!y&&xe(p)})}function we(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function xe(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;Te(()=>{z===void 0&&(z=je());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Le(()=>{p=!0});let q=E.get(g);if(q&&V(q)&&!T&&!y){(M(x)!=="ready"||M(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),me(u,g,!0,()=>p);return}let Se=M(x),Ve=Se==="ready"||Se==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),me(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,pt,{value:!0,enumerable:!0}),Object.defineProperty(H,dt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,be(u=>u+1)},invalidate:()=>{let u=M(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,be(T=>T+1)}}]}function nn(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function rn(){E.clear(),A.clear()}export{rn as clearAllCachedResources,nn as clearCachedResourceNamespace,tn as createCachedResource};
|
|
1
|
+
function ce(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Re(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(ce(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Re(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(ce(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},de=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new de(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var $e=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?$e:!1,We=Symbol.for("signal");function pe(e){return typeof e=="function"&&e[We]===!0}var ze="__fluixi_signal_next_state__",He=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[ze]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:He,onSuspend:null,onError:null};var Ce=0,_e=1,J=2,he=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var Q=class extends he{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===_e&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ce}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ae(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Ce;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(_e);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Pe(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Ee(){return h.owner}function Fe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function ke(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Ke(e){return!!e&&typeof e.then=="function"}ke(()=>{});var Ye=Symbol.for("signal"),Xe=Symbol.for("memo");function Z(e,t,n){let o=t,r=Ee(),s=new Q(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(Ke(f))return Pe(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:!0,enumerable:!0}),a}function ee(e){if(typeof e=="function"&&!e.length){let t=e();return pe(t)?t:ee(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=ee(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function De(e){let t=Z(e);return X?Z(()=>ee(t()),void 0,{name:"children"}):Z(()=>ee(t()))}var qe=null;function ve(e){qe&&qe(e)}var Je=Symbol.for("signal");var Ne=Symbol("fluixi-proxy"),Qe=Symbol.for("signal-node"),G=0,ye=1,oe=2,I=3,c=null,v=null,i=null,ne=null,re=0,Ze=!1,Te=!1,N=0,et=1e6,O=new WeakMap,te=null;var tt=new Map,nt=0;function rt(){return`node_${++nt}_${Date.now()}`}function ot(e){X&&tt.set(e.id,new WeakRef(e))}function st(e,t,n){let o={id:rt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ot(o),o}function it(e,t){return e===t}function Ue(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function ut(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(te&&te.running&&!e.pure)te.effects.indexOf(e)===-1&&te.effects.push(e);else if(!e.pure||e.computed)me(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;se(o),i=r}}}function Ie(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ne in n&&delete n[Ne];let o=st("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||it;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,ie=!1){let m=l.state;if(!(m===I&&l===v)){if(ie&&!l.pure){m===G&&(l.state=ye,Ze&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=oe,m===G||m===ye?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ie(Array.from($),k=>F(k,!0))}}};var V=F;let E=Array.from(R),x=[],S=new Set;Ie(E,F);for(let l of x)ut(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return be(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Qe,{value:o,enumerable:!1}),r}function be(e,t,n){let o={fn:e,state:oe,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Le(o,t),()=>U(o)}function Le(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,re++,re>et)throw re=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=n,c=o}}function me(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===oe||e.state===ye||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Be(e):Le(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function se(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&me(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return se(n),i=r,o}N++,i=[],ne=[];try{return e()}finally{N--,at()}}function at(){if(!Te){Te=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,ne){let e=ne;ne=null;for(let t=0;t<e.length;t++)me(e[t])}}finally{Te=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Me(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function lt(e){let t=Symbol("context"),n=ct(t);return{id:t,Provider:n,defaultValue:e}}function ct(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return ft(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),De(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function ft(e,t,n){let o={fn:e,state:oe,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Be(o),()=>U(o)}function Be(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;se(r),i=s}}}var w;function je(){return w||(w=lt())}var P=new Map,A=new Map,dt=0,pt=Symbol.for("signal"),ht=Symbol.for("resource");function cn(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${dt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,E]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ge,we]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function xe(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||Se(p,y)},p=>{!g()&&!y&&ge(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(P.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){ve(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||Se(p,y)},p=>{!g()&&!y&&ge(p)})}function Se(u,T){_(()=>{E(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function ge(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;be(()=>{z===void 0&&(z=je());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ue,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let g=B(u);y&&P.delete(g);let D=W===ue||u!==W;W=u;let p=!1;Me(()=>{p=!0});let q=P.get(g);if(q&&V(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{E(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{E(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),xe(u,g,!0,()=>p);return}let Oe=L(x),Ve=Oe==="ready"||Oe==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),xe(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(H,ht,{value:!0,enumerable:!0}),Object.defineProperty(H,pt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:E,refetch:()=>{ae=!0,we(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&P.delete(B(u)),le=!0,we(T=>T+1)}}]}function fn(e){let t=`${e}:`;for(let n of P.keys())n.startsWith(t)&&P.delete(n)}function dn(){P.clear(),A.clear()}export{dn as clearAllCachedResources,fn as clearCachedResourceNamespace,cn as createCachedResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of k(t))!A.call(e,s)&&s!==n&&h(e,s,{get:()=>t[s],enumerable:!(o=O(t,s))||o.enumerable});return e};var D=e=>C(h({},"__esModule",{value:!0}),e);var G={};q(G,{readChildren:()=>W});module.exports=D(G);var E="__fluixi_signal_next_state__",P=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:P,onSuspend:null,onError:null};var y=0,v=1,l=2,w=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))}};var f=class extends w{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=l;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===v&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=y}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,u=!1,i;try{s=this._fn()}catch(c){u=!0,i=c,s=this._value}finally{r.consumer=n,r.untracked=o}let a=!this._initialized||this._threw!==u||(u?i!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=i,this._value=s,a){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);T(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===y;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(v);T(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function T(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function m(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function b(){return r.owner}function x(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function _(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function R(e){return!!e&&typeof e.then=="function"}_(()=>{});var N=Symbol.for("signal"),M=Symbol.for("memo");function d(e,t,n){let o=t,s=b(),u=new f(()=>x(s,()=>{try{return o=e(o)}catch(a){if(R(a))return m(a),o;throw a}}),{equals:n?.equals}),i=(()=>u.get());return Object.defineProperty(i,N,{value:!0,enumerable:!0}),Object.defineProperty(i,M,{value:!0,enumerable:!0}),i}var I=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,S=typeof process>"u"?I:!1,V=Symbol.for("signal");function g(e){return typeof e=="function"&&e[V]===!0}function p(e){if(typeof e=="function"&&!e.length){let t=e();return g(t)?t:p(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=p(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function W(e){let t=d(e);return S?d(()=>p(t()),void 0,{name:"children"}):d(()=>p(t()))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g="__fluixi_signal_next_state__",O=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[g]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:O,onSuspend:null,onError:null};var w=0,y=1,l=2,h=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 f=class extends h{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=l;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.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===y&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=w}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked;n.consumer=this,n.untracked=!1;let s,u=!1,i;try{s=this._fn()}catch(c){u=!0,i=c,s=this._value}finally{n.consumer=r,n.untracked=o}let a=!this._initialized||this._threw!==u||(u?i!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=i,this._value=s,a){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);v(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===w;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(y);v(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function v(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function T(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function m(){return n.owner}function b(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function x(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function k(e){return!!e&&typeof e.then=="function"}x(()=>{});var A=Symbol.for("signal"),q=Symbol.for("memo");function d(e,t,r){let o=t,s=m(),u=new f(()=>b(s,()=>{try{return o=e(o)}catch(a){if(k(a))return T(a),o;throw a}}),{equals:r?.equals}),i=(()=>u.get());return Object.defineProperty(i,A,{value:!0,enumerable:!0}),Object.defineProperty(i,q,{value:!0,enumerable:!0}),i}var C=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,_=typeof process>"u"?C:!1,D=Symbol.for("signal");function S(e){return typeof e=="function"&&e[D]===!0}function p(e){if(typeof e=="function"&&!e.length){let t=e();return S(t)?t:p(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let o=p(e[r]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function Y(e){let t=d(e);return _?d(()=>p(t()),void 0,{name:"children"}):d(()=>p(t()))}export{Y as readChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var e=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var s=(n,o)=>{for(var t in o)e(n,t,{get:o[t],enumerable:!0})},_=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of u(o))!p.call(n,r)&&r!==t&&e(n,r,{get:()=>o[r],enumerable:!(i=c(o,r))||i.enumerable});return n};var a=n=>_(e({},"__esModule",{value:!0}),n);var g={};s(g,{__BROWSER_PROD__:()=>f,__DEV__:()=>m,isComponent:()=>E,isMemo:()=>A,isProvider:()=>T,isResource:()=>R,isSignal:()=>d,isSuspense:()=>O,makeArrayFlat:()=>y});module.exports=a(g);var f=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,m=typeof process>"u"?f:!1,x=Symbol.for("signal"),S=Symbol.for("memo"),b=Symbol.for("resource");function d(n){return typeof n=="function"&&n[x]===!0}function A(n){return typeof n=="function"&&n[S]===!0}function R(n){return typeof n=="function"&&n[b]===!0}function E(n){return typeof n=="function"&&n[Symbol.for("fluixi-component")]===!0}function O(n){return typeof n=="function"&&n[Symbol.for("fluixi-suspense")]===!0}function T(n){return typeof n=="function"&&n[Symbol.for("fluixi-provider")]===!0}function y(n){return Array.isArray(n)?n.length===2&&n[1]===" "?Array.isArray(n[0])?y(n[0]):(typeof n[0]=="function",n[0]):n.length===1&&typeof n[0]=="function"?n[0]:n:n}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* signal.ts so it survives once that file is retired.
|
|
6
6
|
*/
|
|
7
7
|
import type { Accessor, Resource } from '../signal.js';
|
|
8
|
+
export declare const __BROWSER_PROD__: boolean;
|
|
8
9
|
export declare const __DEV__: boolean;
|
|
9
10
|
export declare function isSignal<T = any>(value: any): value is Accessor<T>;
|
|
10
11
|
export declare function isMemo<T = any>(value: any): value is Accessor<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,gBAAgB,SAAmF,CAAC;AACjH,eAAO,MAAM,OAAO,SAGuB,CAAC;AAM5C,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAElE;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAEhE;AAED,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAEpE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE/C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE9C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE9C;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAShD"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const __BROWSER_PROD__ = typeof window === 'undefined' ? false : window.__FLUIXI_PROD__ === true;
|
|
2
|
+
export const __DEV__ = typeof process === 'undefined'
|
|
3
|
+
? __BROWSER_PROD__
|
|
4
|
+
: process.env.NODE_ENV !== 'production';
|
|
2
5
|
const $SIGNAL = Symbol.for('signal');
|
|
3
6
|
const $MEMO = Symbol.for('memo');
|
|
4
7
|
const $RESOURCE = Symbol.for('resource');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,f=typeof process>"u"?o:!1,r=Symbol.for("signal"),t=Symbol.for("memo"),e=Symbol.for("resource");function y(n){return typeof n=="function"&&n[r]===!0}function c(n){return typeof n=="function"&&n[t]===!0}function u(n){return typeof n=="function"&&n[e]===!0}function p(n){return typeof n=="function"&&n[Symbol.for("fluixi-component")]===!0}function s(n){return typeof n=="function"&&n[Symbol.for("fluixi-suspense")]===!0}function _(n){return typeof n=="function"&&n[Symbol.for("fluixi-provider")]===!0}function i(n){return Array.isArray(n)?n.length===2&&n[1]===" "?Array.isArray(n[0])?i(n[0]):(typeof n[0]=="function",n[0]):n.length===1&&typeof n[0]=="function"?n[0]:n:n}export{o as __BROWSER_PROD__,f as __DEV__,p as isComponent,c as isMemo,_ as isProvider,u as isResource,y as isSignal,s as isSuspense,i as makeArrayFlat};
|
|
@@ -1 +1 @@
|
|
|
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=t.transport===!1?void 0: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");
|
|
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 An={};ln(An,{$PROXY:()=>Cn,$SIGNAL:()=>En,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:()=>O,createSelector:()=>Ke,createSignal:()=>d,createSuspenseBoundary:()=>Ze,disposeScope:()=>Re,flush:()=>Fe,getOwner:()=>j,getServerData:()=>Z,indexArray:()=>xn,isComponent:()=>Le,isMemo:()=>Ne,isOwnerDisposed:()=>_e,isProvider:()=>We,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:()=>Ge,setServerDataGetter:()=>ze,startTransition:()=>le,trackResourcePromise:()=>J,untrack:()=>w,useContext:()=>Oe,useTransition:()=>Ue});module.exports=fn(An);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 _e(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 Oe(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 O(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(W)))}function W(){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&&W()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&W()}}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 W(),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;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 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;O(U=>{C=U;let[R,F]=d(l);T=F;let G=S(A=>{let g=(e()||[])[R()];return g??A},a[l]);x=t(G,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];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 bn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Q=typeof process>"u"?bn:!1,gn=Symbol.for("signal"),kn=Symbol.for("memo"),Rn=Symbol.for("resource");function X(e){return typeof e=="function"&&e[gn]===!0}function Ne(e){return typeof e=="function"&&e[kn]===!0}function Ve(e){return typeof e=="function"&&e[Rn]===!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 We(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 Ge(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 _n(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=t.transport===!1?void 0: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(m,{value:sn,refetching:we});_n(_)?(T(_),J(_),_.then($=>{z||(u!==void 0&&ne(u,$),b(()=>{f(()=>$),y("ready"),T(void 0)}))},$=>{z||b(()=>{l($),y("errored"),T(void 0)})})):b(()=>{f(()=>_),y("ready"),T(void 0)})}catch(_){if(z)return;b(()=>{l(_),y("errored"),T(void 0)})}});let G=()=>{let m=p();return m==="pending"||m==="refreshing"},A=(()=>{let m=h();if(m)throw m;if(G()){let g=x();if(g)throw g}return i()});return Object.defineProperties(A,{state:{get:p},loading:{get:G},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 Q?S(()=>re(n()),void 0,{name:"children"}):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 En=Symbol.for("signal"),Cn=Symbol.for("fluixi-proxy");
|
|
@@ -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,$=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=t.transport===!1?void 0: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};
|
|
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 _e(e){return Z(e),Promise.resolve()}function We(){return[()=>!1,_e]}function Ge(){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 Cn(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 An(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 W=S(E=>{let b=(e()||[])[R()];return b??E},a[l]);x=t(W,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 Dn(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 $e=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ee=typeof process>"u"?$e:!1,He=Symbol.for("signal"),Ke=Symbol.for("memo"),Ye=Symbol.for("resource");function ne(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[Ye]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(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 nn(e){te=e}function ie(e){te&&te(e)}var re=null;function tn(e){re=e}function ue(e){return re?re(e):void 0}var oe=null;function rn(e){oe=e}function ae(){return oe?oe():void 0}var se=null;function on(e){se=e}function ce(e,n){se&&se(e,n)}function sn(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 un(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 an(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 cn(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=t.transport===!1?void 0: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 G=!1;v(()=>G=!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});cn(_)?(T(_),ie(_),_.then(z=>{G||(u!==void 0&&ce(u,z),k(()=>{d(()=>z),y("ready"),T(void 0)}))},z=>{G||k(()=>{l(z),y("errored"),T(void 0)})})):k(()=>{d(()=>_),y("ready"),T(void 0)})}catch(_){if(G)return;k(()=>{l(_),y("errored"),T(void 0)})}});let W=()=>{let m=f();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(W()){let b=x();if(b)throw b}return i()});return Object.defineProperties(E,{state:{get:f},loading:{get:W},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 ln(e){return e!=null&&e!==""}function dn(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=ln}=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 fn(e){let n=S(e);return ee?S(()=>Q(n()),void 0,{name:"children"}):S(()=>Q(n()))}var fe=N();we((e,n)=>{let t=H(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function pn(){let[e,n]=p(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function hn(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 yn(){let[e,n]=p(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function Tn(e,n){return V(Ce,e,n)}var mn={State:C,Computed:g,subtle:{Watcher:A,untrack:U,currentComputed:me,hasSinks:ve}};var et=Symbol.for("signal"),nt=Symbol.for("fluixi-proxy");export{nt as $PROXY,et as $SIGNAL,mn as Signal,fe as SuspenseContext,ee as __DEV__,k as batch,qe as createChildOwner,Le as createComputed,N as createContext,an as createDebounce,dn as createDebouncedResource,Ee as createDebouncedSignal,un as createDeferred,P as createEffect,yn as createErrorBoundary,S as createMemo,je as createRenderEffect,de as createResource,D as createRoot,sn as createSelector,p as createSignal,pn as createSuspenseBoundary,Ie as disposeScope,Ge as flush,K as getOwner,ue as getServerData,Dn as indexArray,Je as isComponent,Qe as isMemo,Me as isOwnerDisposed,en as isProvider,Xe as isResource,ne as isSignal,Ze as isSuspense,An as keyArray,Oe as makeArrayFlat,Cn as mapArray,ae as nextResourceId,ze as on,v as onCleanup,V as provide,Tn as provideErrorBoundary,hn as provideSuspense,fn as readChildren,ce as reportResourceData,L as runWithOwner,be as setOwner,on as setResourceDataSink,rn as setResourceIdSource,nn as setResourceTracker,tn as setServerDataGetter,_e as startTransition,ie as trackResourcePromise,w as untrack,Ue as useContext,We as useTransition};
|