@fluixi/reactive 1.0.0-alpha.77 → 1.0.0-alpha.79
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.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/observable/observable.cjs +1 -1
- package/dist/lib/observable/observable.mjs +1 -1
- package/dist/lib/observable/subscription.cjs +1 -1
- package/dist/lib/observable/subscription.d.ts.map +1 -1
- package/dist/lib/observable/subscription.js +1 -2
- package/dist/lib/observable/subscription.mjs +1 -1
- package/dist/lib/predicates.cjs +1 -0
- package/dist/lib/predicates.d.ts +37 -0
- package/dist/lib/predicates.d.ts.map +1 -0
- package/dist/lib/predicates.js +62 -0
- package/dist/lib/predicates.mjs +1 -0
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.d.ts +6 -6
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.d.ts.map +1 -1
- package/dist/lib/signal/signal.js +16 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/lib/signal/utilities.cjs +1 -1
- package/dist/lib/signal/utilities.mjs +1 -1
- package/dist/lib/store/setter.types.d.ts +1 -1
- package/dist/lib/store/setter.types.d.ts.map +1 -1
- package/dist/lib/subject.cjs +1 -1
- package/dist/lib/subject.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 +16 -12
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var mt="1.0.0-alpha.77";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as Ne}from"@fluixi/utils/functions";var q=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:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(Ne(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.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:r,_subscriptions:n}=this;if(r){if(Ne(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 n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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 kr(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new pe(t,r,n);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((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Me=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var He=0,$e=1,H=2,te=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))}},D=class extends te{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.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 r of[...this.observers])r.markDirty(H);fe(this)}}peek(){return this._value}},O=class extends te{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=He}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=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=r,a.untracked=n}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(H);fe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);fe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function fe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function $(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=V(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){L(e,t)}function gt(e){return!!e&&e.disposed===!0}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=V(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(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 re(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=V(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ge(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function ne(){return a.owner}function ze(e){let t=a.owner;return a.owner=e,t}function W(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function L(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)L(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function F(e){let t=V(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>L(t))}finally{a.owner=r}}function Ye(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){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 r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Xe(){a.batchDepth===0&&z()}function ye(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var de=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=V(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{L(this.owner,!1),W(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new C(()=>Rt(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),L(this.owner))}};function oe(e){let t=new de(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}Ye(()=>{});var Qe=Symbol.for("signal"),Et=Symbol.for("memo"),kt=Symbol.for("signal-node");function f(e,t){let r=new D(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Xe(),i});return Object.defineProperty(n,Qe,{value:!0,enumerable:!0}),Object.defineProperty(n,kt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=ne(),s=new O(()=>W(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Qe,{value:!0,enumerable:!0}),Object.defineProperty(i,Et,{value:!0,enumerable:!0}),i}function g(e,t){let r=t;return oe(()=>{r=e(r)})}function Pt(e,t){let r=t;oe(()=>{r=e(r)})}function Dt(e,t){let r=t;return oe(()=>{r=e(r)})}function A(e){return ye(e)}function S(e){return $(e)}function Je(e){return ye(e),Promise.resolve()}function Ct(){return[()=>!1,Je]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=$(()=>t(c,o,i));return o=c,u}}function Vr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,d,T;F(h=>{T=h;let[k,j]=f(u);d=j,l=t(p,k)});let x={item:p,rendered:l,dispose:T,setIndex:d};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Gr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),T=c.get(d);if(T&&!y.has(d))T.setIndex(l),u.push(T);else{let x,h,k;F(j=>{k=j;let[R,B]=f(l);h=B;let J=v(P=>{let w=(e()||[])[R()];return w??P},i[l]);x=r(J,R)}),u.push({rendered:x,dispose:k,setIndex:h})}p.push(d),y.add(d)}for(let[l,d]of c)y.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,d=o[u];F(T=>{l=T;let[x,h]=f(d);y=h,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var Te=!1,Ut=Symbol.for("signal"),jt=Symbol.for("memo"),Bt=Symbol.for("resource");function he(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[jt]===!0}function Nt(e){return typeof e=="function"&&e[Bt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ze(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ze(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var be=null;function Lt(e){be=e}function xe(e){be&&be(e)}var me=null;function Vt(e){me=e}function we(e){return me?me(e):void 0}var ve=null;function Gt(e){ve=e}function Oe(){return ve?ve():void 0}var Se=null;function Kt(e){Se=e}function ge(e,t){Se&&Se(e,t)}function Wt(e,t=(r,n)=>r===n){let r=new Map;return g(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=f(e(),t);return g(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Ae=Symbol();function Y(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0:Oe(),i=s!==void 0?we(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=f(void 0,{equals:!1}),[d,T]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=f(void 0,{equals:!1}),[k,j]=f(void 0,{equals:!1}),R=Ae,B=!1;g(()=>{let b=n();if(k(),b===!1||b===null||b===void 0){R=Ae,A(()=>{T("unresolved"),h(void 0),l(void 0)});return}let w=B;if(B=!1,R!==Ae&&b===R&&!w)return;if(R=b,c){c=!1;return}let Z=!1;m(()=>Z=!0);let Be=S(d),bt=S(u),qe=Be==="ready"||Be==="refreshing";A(()=>{T(qe?"refreshing":"pending"),l(void 0)});try{let _=o(b,{value:bt,refetching:qe});Xt(_)?(h(_),xe(_),_.then(ee=>{Z||(s!==void 0&&ge(s,ee),A(()=>{p(()=>ee),T("ready"),h(void 0)}))},ee=>{Z||A(()=>{l(ee),T("errored"),h(void 0)})})):A(()=>{p(()=>_),T("ready"),h(void 0)})}catch(_){if(Z)return;A(()=>{l(_),T("errored"),h(void 0)})}});let J=()=>{let b=d();return b==="pending"||b==="refreshing"},P=(()=>{let b=y();if(b)throw b;if(J()){let w=x();if(w)throw w}return u()});return Object.defineProperties(P,{state:{get:d},loading:{get:J},error:{get:y},latest:{get:u}}),Object.defineProperty(P,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(P,Symbol.for("signal"),{value:!0,enumerable:!0}),[P,{mutate:p,refetch:()=>{B=!0,j(void 0)}}]}function et(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let T=typeof d=="function"?d(S(r)):d;return n(()=>T),c(!0),p(),u=setTimeout(y,t),T});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=et(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=Y(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function se(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:se(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=se(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=v(e);return v(()=>se(t()))}var Re=G();Ge((e,t)=>{let r=re(t,Re);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return K(Re,e,t)}var tt=G();We((e,t)=>{let r=re(t,tt);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return K(tt,e,t)}var or={State:D,Computed:O,subtle:{Watcher:C,untrack:$,currentComputed:Le,hasSinks:Ve}};var hn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");function Cn(e,t){let[r,n]=f(e,t);return Object.assign(r,{set:n})}function Fn(e,t,r){return v(e,t,r)}function In(e,t){return g(e,t)}function sr(...e){let[t,r]=Y(...e);return Object.assign(t,r)}import{$PROXY as Ee,batch as ct,createEffect as ae,createMemo as ke,createSignal as lt,untrack as ir}from"@fluixi/reactive/signal";var ue=Symbol("store-raw"),U=Symbol("store-node"),rt=Symbol("store-has"),Pe=Symbol("store-self"),De=Symbol("store-track"),ar=Symbol("store-name"),ur=Symbol("store-store"),nt=new WeakMap,ot=new WeakMap;function pt(e){let[t,r]=lt(e),n=t;return n.$=r,n}function ce(e){let t=nt.get(e);return t||nt.set(e,t={keys:new Map}),t}function st(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=pt(r)),n}function it(e){let t=ce(e);(t.all||(t.all=pt()))()}function at(e,t){e.$(typeof t=="function"?()=>t:t)}function ft(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 ie(e){if(!ft(e))return e;let t=ot.get(e);if(t)return t;let r=new Proxy(e,cr);return ot.set(e,r),r}var cr={get(e,t,r){if(t===ue||t===U)return e;if(t===Ee)return r;if(t===rt)return i=>i in e;if(t==="__proxy")return!0;if(t===De||t===Pe)return it(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=st(ce(e),t,n)();return ft(s)?ie(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===ue||t===Ee||t===U||t===rt||t===Pe||t===De?!0:(st(ce(e),t,e[t])(),t in e)},ownKeys(e){return it(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ce(e),c=i.keys.get(t);if(c&&at(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&at(u,e.length)}i.all&&i.all.$(void 0)}function ut(e,t){return typeof e=="function"?e(t):e}function Ce(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ce(o,n):X(e,r,n)}}function Ie(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function dt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)dt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,ut(r,e[s]));return}X(e,o,ut(r,e[o]))}function _e(e,t,r){dt(e,Ie(t),r)}function lr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ce(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&_e(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ce(e,r);return}if(Array.isArray(t[1])&&t.length>=3){_e(e,`${r}.${t[1].join(".")}`,t[2]);return}_e(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ie(t)){if(r==null)return;r=r[n]}return r}var E=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ct(()=>lr(this.root,n)))}get state(){return ie(this.root)}get proxy(){return ie(this.root)}get accessor(){return(()=>ie(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return Q(this.state);let r=this.state;for(let n of Ie(t)){if(r==null)return;r=r[n]}return Q(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ae(()=>t(this.state))}watch(t,r){let n;return ae(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=lt(this.state);return t.toObservable()}dispose(){}},pr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function yt(e,t){for(let r of pr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function le(e,t={immutable:!0}){let r=new E(e,t);return yt(r.set,r),[r.proxy,r.set]}function Tt(e,t={}){return new E(e,{...t,immutable:!1})}function fr(e,t={}){let r=new E(e(),t);return ae(()=>r.set(e())),r}function dr(e,t,r){return ae(()=>r(t(e)))}function yr(e,t,r){return ke(()=>t(e),void 0,r)}function Tr(e,t={}){let r=new E(e,t),n=(()=>r.proxy);return yt(n,r),n}function Q(e){if(e==null||typeof e!="object")return e;let t=e[ue];return t!==void 0?t:e}function ht(e){return ir(()=>Q(e))}function hr(e){return Ue(e)}function br(e){return Ue(e)?e[U]:null}function mr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ue(e){return!!e&&typeof e=="object"&&(Ee in e||e.__proxy===!0)}function vr(e){return e}var Sr=Object.freeze({createStore:le,createMutableStore:Tt,batch:ct,unwrap:Q,untrackStore:ht});function je(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(je);let t={};for(let r of Object.keys(e))t[r]=je(e[r]);return t}function xr(e){return t=>{let r=je(t);return e(r),r}}function wr(e,t={}){return()=>e}function Or(e,t){let[r,n]=le(e,t);return new Proxy(r,{get:(o,s)=>s==="set"?n:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{ar as $NAME,U as $NODE,bn as $PROXY,ue as $RAW,Pe as $SELF,hn as $SIGNAL,ur as $STORE,De as $TRACK,M as Observable,pe as SafeSubscriber,or as Signal,E as Store,Sr as StoreAPI,Me as Subject,N as Subscriber,q as Subscription,Re as SuspenseContext,mt as VERSION,Te as __DEV__,A as batch,wt as createChildOwner,Pt as createComputed,fr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,et as createDebouncedSignal,zt as createDeferred,g as createEffect,rr as createErrorBoundary,v as createMemo,Tt as createMutableStore,Dt as createRenderEffect,Y as createResource,F as createRoot,Wt as createSelector,f as createSignal,le as createStore,dr as createStoreEffect,yr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,In as effect,Ft as flush,br as getNode,ne as getOwner,we as getServerData,mr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,$t as isProvider,Nt as isResource,he as isSignal,hr as isStore,Ue as isStoreProxy,Ht as isSuspense,Gr as keyArray,Ze as makeArrayFlat,Vr as mapArray,Fn as memo,vr as modifiable,Oe as nextResourceId,It as on,m as onCleanup,kr as operate,xr as produceUtil,K as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,wr as reconcileUtil,ge as reportResourceData,sr as resource,W as runWithOwner,ze as setOwner,Kt as setResourceDataSink,Gt as setResourceIdSource,Lt as setResourceTracker,Vt as setServerDataGetter,Cn as signal,Je as startTransition,Or as store,xe as trackResourcePromise,S as untrack,ht as untrackStore,Q as unwrap,At as useContext,Ct as useTransition,Tr as wrap};
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var v=(i,r)=>{for(var e in r)a(i,e,{get:r[e],enumerable:!0})},F=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of O(r))!h.call(i,o)&&o!==e&&a(i,o,{get:()=>r[o],enumerable:!(t=d(r,o))||t.enumerable});return i};var T=i=>F(a({},"__esModule",{value:!0}),i);var A={};v(A,{Observable:()=>l,SafeSubscriber:()=>c,Subscriber:()=>u,Subscription:()=>p,operate:()=>y});module.exports=T(A);function b(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function f(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var p=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:e}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let t of r)t.remove(this);if(e){for(let t of e)if(b(t)&&!(t instanceof i))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(f(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:e,_subscriptions:t}=this;if(e){if(b(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:e}=this;if(!e)return;let t=e.indexOf(r);t!==-1&&(e.splice(t,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:e}=this;e?Array.isArray(e)?e.push(r):this._parentOrParents=[e,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:e}=this;if(e===r)this._parentOrParents=null;else if(Array.isArray(e)){let t=e.indexOf(r);t!==-1&&(e.splice(t,1),e.length===1&&(this._parentOrParents=e[0]))}}};var u=class extends p{constructor(e,t,o){super();this.isStopped=!1;let n;e?typeof e=="object"?n=e:n={next:e,error:t,complete:o}:n={},this.destination=n}next(e){if(!this.isStopped&&this.destination.next)try{this.destination.next(e)}catch(t){this.error(t)}}error(e){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(e)}catch(t){throw t}else throw e;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(e){this.error(e);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},c=class extends u{constructor(e,t,o,n){super(e,t,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=n||null}next(e){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(e)}catch(t){this.error(t)}}error(e){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(e)}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 y(i){return new u(i.next,i.error,i.complete)}var l=class extends p{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,e,t){let o;r instanceof u?o=r:o=new c(r,e,t);let{_subscribe:n}=this;try{let s=n.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((e,t)=>t(e),this)}toPromise(){return new Promise((r,e)=>{let t;this.subscribe({next:o=>t=o,error:e,complete:()=>r(t)})})}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function c(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function b(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var p=class i{constructor(e){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;e&&(this._subscriptions=[e])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:e,_subscriptions:r}=this;if(e instanceof i)e.remove(this);else if(e!==null)for(let t of e)t.remove(this);if(r){for(let t of r)if(c(t)&&!(t instanceof i))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(b(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(e){if(!e||e===this)return this;if(e.closed)return this;let{_closed:r,_subscriptions:t}=this;if(r){if(c(e))try{e()}catch(o){console.error("Error in unsubscribe function:",o)}else if(e.unsubscribe)try{e.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof i&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let t=r.indexOf(e);t!==-1&&(r.splice(t,1),e._removeParent(this))}_addParent(e){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(e):this._parentOrParents=[r,e]:this._parentOrParents=e}_removeParent(e){let{_parentOrParents:r}=this;if(r===e)this._parentOrParents=null;else if(Array.isArray(r)){let t=r.indexOf(e);t!==-1&&(r.splice(t,1),r.length===1&&(this._parentOrParents=r[0]))}}};var u=class extends p{constructor(r,t,o){super();this.isStopped=!1;let n;r?typeof r=="object"?n=r:n={next:r,error:t,complete:o}:n={},this.destination=n}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(t){this.error(t)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(t){throw t}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},a=class extends u{constructor(r,t,o,n){super(r,t,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=n||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(t){this.error(t)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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 v(i){return new u(i.next,i.error,i.complete)}var l=class extends p{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,t){let o;e instanceof u?o=e:o=new a(e,r,t);let{_subscribe:n}=this;try{let s=n.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...e){return e.length===0?this:e.reduce((r,t)=>t(r),this)}toPromise(){return new Promise((e,r)=>{let t;this.subscribe({next:o=>t=o,error:r,complete:()=>e(t)})})}};export{l as Observable,a as SafeSubscriber,u as Subscriber,p as Subscription,v as operate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var v=(i,r)=>{for(var e in r)a(i,e,{get:r[e],enumerable:!0})},F=(i,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of O(r))!h.call(i,o)&&o!==e&&a(i,o,{get:()=>r[o],enumerable:!(t=d(r,o))||t.enumerable});return i};var T=i=>F(a({},"__esModule",{value:!0}),i);var A={};v(A,{Observable:()=>l,SafeSubscriber:()=>c,Subscriber:()=>p,operate:()=>y});module.exports=T(A);function b(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function f(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var u=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:e}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let t of r)t.remove(this);if(e){for(let t of e)if(b(t)&&!(t instanceof i))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(f(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:e,_subscriptions:t}=this;if(e){if(b(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:e}=this;if(!e)return;let t=e.indexOf(r);t!==-1&&(e.splice(t,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:e}=this;e?Array.isArray(e)?e.push(r):this._parentOrParents=[e,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:e}=this;if(e===r)this._parentOrParents=null;else if(Array.isArray(e)){let t=e.indexOf(r);t!==-1&&(e.splice(t,1),e.length===1&&(this._parentOrParents=e[0]))}}};var p=class extends u{constructor(e,t,o){super();this.isStopped=!1;let n;e?typeof e=="object"?n=e:n={next:e,error:t,complete:o}:n={},this.destination=n}next(e){if(!this.isStopped&&this.destination.next)try{this.destination.next(e)}catch(t){this.error(t)}}error(e){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(e)}catch(t){throw t}else throw e;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(e){this.error(e);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},c=class extends p{constructor(e,t,o,n){super(e,t,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=n||null}next(e){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(e)}catch(t){this.error(t)}}error(e){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(e)}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 y(i){return new p(i.next,i.error,i.complete)}var l=class extends u{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,e,t){let o;r instanceof p?o=r:o=new c(r,e,t);let{_subscribe:n}=this;try{let s=n.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((e,t)=>t(e),this)}toPromise(){return new Promise((r,e)=>{let t;this.subscribe({next:o=>t=o,error:e,complete:()=>r(t)})})}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function c(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function b(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var p=class i{constructor(e){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;e&&(this._subscriptions=[e])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:e,_subscriptions:r}=this;if(e instanceof i)e.remove(this);else if(e!==null)for(let t of e)t.remove(this);if(r){for(let t of r)if(c(t)&&!(t instanceof i))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(b(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(e){if(!e||e===this)return this;if(e.closed)return this;let{_closed:r,_subscriptions:t}=this;if(r){if(c(e))try{e()}catch(o){console.error("Error in unsubscribe function:",o)}else if(e.unsubscribe)try{e.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof i&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let t=r.indexOf(e);t!==-1&&(r.splice(t,1),e._removeParent(this))}_addParent(e){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(e):this._parentOrParents=[r,e]:this._parentOrParents=e}_removeParent(e){let{_parentOrParents:r}=this;if(r===e)this._parentOrParents=null;else if(Array.isArray(r)){let t=r.indexOf(e);t!==-1&&(r.splice(t,1),r.length===1&&(this._parentOrParents=r[0]))}}};var u=class extends p{constructor(r,t,o){super();this.isStopped=!1;let n;r?typeof r=="object"?n=r:n={next:r,error:t,complete:o}:n={},this.destination=n}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(t){this.error(t)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(t){throw t}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},a=class extends u{constructor(r,t,o,n){super(r,t,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=n||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(t){this.error(t)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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 v(i){return new u(i.next,i.error,i.complete)}var l=class extends p{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,t){let o;e instanceof u?o=e:o=new a(e,r,t);let{_subscribe:n}=this;try{let s=n.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...e){return e.length===0?this:e.reduce((r,t)=>t(r),this)}toPromise(){return new Promise((e,r)=>{let t;this.subscribe({next:o=>t=o,error:r,complete:()=>e(t)})})}};export{l as Observable,a as SafeSubscriber,u as Subscriber,v as operate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var b=(i,r)=>{for(var n in r)e(i,n,{get:r[n],enumerable:!0})},p=(i,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of a(r))!l.call(i,t)&&t!==n&&e(i,t,{get:()=>r[t],enumerable:!(s=u(r,t))||s.enumerable});return i};var h=i=>p(e({},"__esModule",{value:!0}),i);var d={};b(d,{Subscription:()=>c});module.exports=h(d);function o(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function f(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var c=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:n}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let s of r)s.remove(this);if(n){for(let s of n)if(o(s)&&!(s instanceof i))try{s()}catch(t){console.error("Error in unsubscribe function:",t)}else if(f(s)&&typeof s.unsubscribe=="function")try{s.unsubscribe()}catch(t){console.error("Error unsubscribing child:",t)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:n,_subscriptions:s}=this;if(n){if(o(r))try{r()}catch(t){console.error("Error in unsubscribe function:",t)}else if(r.unsubscribe)try{r.unsubscribe()}catch(t){console.error("Error unsubscribing:",t)}return this}return s||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:n}=this;if(!n)return;let s=n.indexOf(r);s!==-1&&(n.splice(s,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(r):this._parentOrParents=[n,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:n}=this;if(n===r)this._parentOrParents=null;else if(Array.isArray(n)){let s=n.indexOf(r);s!==-1&&(n.splice(s,1),n.length===1&&(this._parentOrParents=n[0]))}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/lib/observable/subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/lib/observable/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAiB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAa,YAAW,gBAAgB;IACnD,eAAe,CAAC,OAAO,CAAC,OAAO,CAAS;IACxC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAGxB;IAChB,eAAe,CAAC,OAAO,CAAC,cAAc,CAEtB;IAEhB;;;;OAIG;gBACS,WAAW,CAAC,EAAE,cAAc;IAMxC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;OAKG;IACH,WAAW,IAAI,IAAI;IAuCnB;;;;;;;;OAQG;IACH,GAAG,CAAC,YAAY,EAAE,gBAAgB,GAAG,cAAc,GAAG,IAAI;IA8C1D;;;;;OAKG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAexC,eAAe;IACf,OAAO,CAAC,UAAU;IAWlB,eAAe;IACf,OAAO,CAAC,aAAa;CActB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isObject } from '
|
|
2
|
-
import { isFunction } from '@fluixi/utils/functions';
|
|
1
|
+
import { isObject, isFunction } from '../predicates.js';
|
|
3
2
|
/**
|
|
4
3
|
* Represents a disposable resource, such as the execution of an Observable.
|
|
5
4
|
* This is the primary mechanism for cleaning up Observable executions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function o(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var c=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:n}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let s of r)s.remove(this);if(n){for(let s of n)if(e(s)&&!(s instanceof i))try{s()}catch(t){console.error("Error in unsubscribe function:",t)}else if(o(s)&&typeof s.unsubscribe=="function")try{s.unsubscribe()}catch(t){console.error("Error unsubscribing child:",t)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:n,_subscriptions:s}=this;if(n){if(e(r))try{r()}catch(t){console.error("Error in unsubscribe function:",t)}else if(r.unsubscribe)try{r.unsubscribe()}catch(t){console.error("Error unsubscribing:",t)}return this}return s||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:n}=this;if(!n)return;let s=n.indexOf(r);s!==-1&&(n.splice(s,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(r):this._parentOrParents=[n,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:n}=this;if(n===r)this._parentOrParents=null;else if(Array.isArray(n)){let s=n.indexOf(r);s!==-1&&(n.splice(s,1),n.length===1&&(this._parentOrParents=n[0]))}}};export{c as Subscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(n,t)=>{for(var r in t)e(n,r,{get:t[r],enumerable:!0})},p=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s(t))!c.call(n,o)&&o!==r&&e(n,o,{get:()=>t[o],enumerable:!(i=f(t,o))||i.enumerable});return n};var a=n=>p(e({},"__esModule",{value:!0}),n);var x={};u(x,{isFunction:()=>y,isObject:()=>k,isPromise:()=>w});module.exports=a(x);function y(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function k(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}function w(n){return n instanceof Promise||!!n&&(typeof n=="object"||typeof n=="function")&&"then"in n}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type predicates this package needs, inlined.
|
|
3
|
+
*
|
|
4
|
+
* They came from `@fluixi/utils`, and the import was the only thing standing between
|
|
5
|
+
* this package and being installable on its own — a signals library that drags a
|
|
6
|
+
* framework's utility package behind it reads as a framework component, whatever the
|
|
7
|
+
* README says. Three predicates are not worth a dependency.
|
|
8
|
+
*
|
|
9
|
+
* These match the `@fluixi/utils` originals exactly, including the parts that look
|
|
10
|
+
* incidental. Each of those exclusions is load-bearing here.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A callable, excluding classes.
|
|
14
|
+
*
|
|
15
|
+
* The class check matters: a signal's setter accepts an updater function, and
|
|
16
|
+
* `set(SomeClass)` means "store this class", not "call it with the previous value".
|
|
17
|
+
* Without the exclusion the constructor would be invoked.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isFunction<T extends Function = Function>(value: unknown): value is T;
|
|
20
|
+
/**
|
|
21
|
+
* A plain-ish object: not null, not an array, not a function, and not one of the
|
|
22
|
+
* built-ins with their own identity.
|
|
23
|
+
*
|
|
24
|
+
* Date, RegExp, Map, Set and Error are excluded because a store must treat them as
|
|
25
|
+
* opaque values rather than walking into them — proxying a Date's internals produces
|
|
26
|
+
* an object that fails every method call on it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isObject(value: unknown): value is Record<string | symbol, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Thenable, rather than `instanceof Promise`.
|
|
31
|
+
*
|
|
32
|
+
* A resource fetcher may return a promise from another realm or another
|
|
33
|
+
* implementation, and those are still awaitable. Functions are included because a
|
|
34
|
+
* thenable function is legal, if unusual.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
37
|
+
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/lib/predicates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAKpF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAUlF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAO1E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type predicates this package needs, inlined.
|
|
3
|
+
*
|
|
4
|
+
* They came from `@fluixi/utils`, and the import was the only thing standing between
|
|
5
|
+
* this package and being installable on its own — a signals library that drags a
|
|
6
|
+
* framework's utility package behind it reads as a framework component, whatever the
|
|
7
|
+
* README says. Three predicates are not worth a dependency.
|
|
8
|
+
*
|
|
9
|
+
* These match the `@fluixi/utils` originals exactly, including the parts that look
|
|
10
|
+
* incidental. Each of those exclusions is load-bearing here.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A callable, excluding classes.
|
|
14
|
+
*
|
|
15
|
+
* The class check matters: a signal's setter accepts an updater function, and
|
|
16
|
+
* `set(SomeClass)` means "store this class", not "call it with the previous value".
|
|
17
|
+
* Without the exclusion the constructor would be invoked.
|
|
18
|
+
*/
|
|
19
|
+
export function isFunction(value) {
|
|
20
|
+
return (typeof value === 'function' &&
|
|
21
|
+
!/^class\s/.test(Function.prototype.toString.call(value)));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A plain-ish object: not null, not an array, not a function, and not one of the
|
|
25
|
+
* built-ins with their own identity.
|
|
26
|
+
*
|
|
27
|
+
* Date, RegExp, Map, Set and Error are excluded because a store must treat them as
|
|
28
|
+
* opaque values rather than walking into them — proxying a Date's internals produces
|
|
29
|
+
* an object that fails every method call on it.
|
|
30
|
+
*/
|
|
31
|
+
export function isObject(value) {
|
|
32
|
+
if (value == null)
|
|
33
|
+
return false;
|
|
34
|
+
if (Array.isArray(value))
|
|
35
|
+
return false;
|
|
36
|
+
if (typeof value === 'function')
|
|
37
|
+
return false;
|
|
38
|
+
if (value instanceof Date)
|
|
39
|
+
return false;
|
|
40
|
+
if (value instanceof RegExp)
|
|
41
|
+
return false;
|
|
42
|
+
if (value instanceof Map)
|
|
43
|
+
return false;
|
|
44
|
+
if (value instanceof Set)
|
|
45
|
+
return false;
|
|
46
|
+
if (value instanceof Error)
|
|
47
|
+
return false;
|
|
48
|
+
return typeof value === 'object';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thenable, rather than `instanceof Promise`.
|
|
52
|
+
*
|
|
53
|
+
* A resource fetcher may return a promise from another realm or another
|
|
54
|
+
* implementation, and those are still awaitable. Functions are included because a
|
|
55
|
+
* thenable function is legal, if unusual.
|
|
56
|
+
*/
|
|
57
|
+
export function isPromise(value) {
|
|
58
|
+
return (value instanceof Promise ||
|
|
59
|
+
(!!value &&
|
|
60
|
+
(typeof value === 'object' || typeof value === 'function') &&
|
|
61
|
+
'then' in value));
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function o(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}function r(n){return n instanceof Promise||!!n&&(typeof n=="object"||typeof n=="function")&&"then"in n}export{t as isFunction,o as isObject,r as isPromise};
|
|
@@ -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);var Oe=require("@fluixi/utils/object"),ce=require("@fluixi/utils/functions"),G=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((0,ce.isFunction)(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if((0,Oe.isObject)(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((0,ce.isFunction)(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 G{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 G{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 Te=require("@fluixi/utils");var Xe=Symbol.for("signal");function Ce(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 Re=0,_e=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===_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=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);Ae(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(_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 Ce(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 pe(e){Ne&&Ne(e)}var rt=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),ot=Symbol.for("signal-node"),V=0,ve=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,st=!1,he=!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 Le(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 R(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 C=O.get(r);if(C&&C.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=ve,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===V||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);$&&Ue(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(C),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 j=a();b?b=!1:d.next(j)})}),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&&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,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=V)}catch(r){if((0,Te.isPromise)(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 be(e){if(!(e.disposed||!e.fn||e.state===V)&&(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?Ge(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)&&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(!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++)be(e[t])}}finally{he=!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 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=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 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&&M(w);return r&&(o.suspense=r),Ge(o),()=>U(o)}function Ge(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=V)}catch(r){if((0,Te.isPromise)(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;oe(r),i=s}}}var w;function Ve(){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)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[C,P]=R(void 0,{equals:!1}),[x,S]=R("unresolved",{equals:!1}),[F,l]=R(void 0,{equals:!1}),[se,m]=R(void 0,{equals:!1}),[$,k]=R(!1),[je,me]=R(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){pe(D),m(D);let p=z&&M(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=Ve());let u=o();if(je(),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&&j(q)&&!T&&!y){(L(x)!=="ready"||L(C)!==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=L(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 C()});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:C},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,me(u=>u+1)},invalidate:()=>{let u=L(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 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 +1 @@
|
|
|
1
|
-
import{isObject as je}from"@fluixi/utils/object";import{isFunction as xe}from"@fluixi/utils/functions";var G=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(xe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(je(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(xe(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 G{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())}},le=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 G{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 le(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)})})}};import{isPromise as Ne}from"@fluixi/utils";var $e=Symbol.for("signal");function Se(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 ge=0,Oe=1,J=2,ce=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 ce{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===Oe&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=ge}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);Ce(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===ge;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Oe);Ce(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ce(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Re(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function _e(){return h.owner}function Ae(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function Ee(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function He(e){return!!e&&typeof e.then=="function"}Ee(()=>{});var Ke=Symbol.for("signal"),Ye=Symbol.for("memo");function Q(e,t,n){let o=t,r=_e(),s=new X(()=>Ae(r,()=>{try{return o=e(o)}catch(f){if(He(f))return Re(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 Se(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 Fe(e){let t=Q(e);return Q(()=>Z(t()))}var ke=null;function fe(e){ke&&ke(e)}var Je=Symbol.for("signal");var De=Symbol("fluixi-proxy"),Xe=Symbol.for("signal-node"),V=0,pe=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,Qe=!1,de=!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 Ie(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)ve(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 qe(e,t){for(let n=0;n<e.length;n++)t(e[n])}function R(e,t){let n=e;typeof n=="object"&&n&&De in n&&delete n[De];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 C=O.get(r);if(C&&C.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=pe,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===V||m===pe?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&qe(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(C),x=[],S=new Set;qe(P,F);for(let l of x)it(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return he(()=>{let j=a();b?b=!1:d.next(j)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:o,enumerable:!1}),r}function he(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&&M(w);return r&&(o.suspense=r),Ue(o,t),()=>U(o)}function Ue(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=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{v=n,c=o}}function ve(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===re||e.state===pe||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?Me(e):Ue(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)&&ve(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(!de){de=!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++)ve(e[t])}}finally{de=!1}}}function L(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=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),Fe(()=>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 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&&M(w);return r&&(o.suspense=r),Me(o),()=>U(o)}function Me(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=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(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 Be(){return w||(w=at())}var E=new Map,A=new Map,ft=0,dt=Symbol.for("signal"),pt=Symbol.for("resource");function en(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)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[C,P]=R(void 0,{equals:!1}),[x,S]=R("unresolved",{equals:!1}),[F,l]=R(void 0,{equals:!1}),[se,m]=R(void 0,{equals:!1}),[$,k]=R(!1),[Ge,Te]=R(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function ye(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(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){fe(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(p)})}function be(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function me(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;he(()=>{z===void 0&&(z=Be());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&&j(q)&&!T&&!y){(L(x)!=="ready"||L(C)!==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)}),ye(u,g,!0,()=>p);return}let we=L(x),Ve=we==="ready"||we==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),ye(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return C()});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:C},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,Te(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,Te(T=>T+1)}}]}function tn(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function nn(){E.clear(),A.clear()}export{nn as clearAllCachedResources,tn as clearCachedResourceNamespace,en as createCachedResource};
|
|
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,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Signals core (L0 graph + L1 runtime), as a drop-in for `@fluixi/reactive/signal`.
|
|
2
|
+
* The complete reactive API running on the TC39 Signals core (L0 graph + L1 runtime).
|
|
4
3
|
*
|
|
5
|
-
* This is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* This is what `@fluixi/reactive/signal` re-exports, so it is the default and not an
|
|
5
|
+
* opt-in. It had its own `signal-next` subpath during the migration, when the legacy
|
|
6
|
+
* implementation was still the default; that subpath is gone, having ended up with no
|
|
7
|
+
* export `./signal` did not already have. When the native `globalThis.Signal` ships,
|
|
8
|
+
* L0 becomes a thin polyfill swap underneath this same surface.
|
|
9
9
|
*
|
|
10
10
|
* Coverage: signals, memos, effects, computed, render effects, roots, ownership,
|
|
11
11
|
* batch, untrack, on, transitions (minimal), context, resources (+ SSR seeding),
|