@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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as pt}from"@fluixi/utils/object";import{isFunction as Ie}from"@fluixi/utils/functions";var $=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(Ie(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(pt(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(Ie(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 Q=class extends ${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 Q{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 W=class extends ${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 Q?r=t:r=new de(t,n,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}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 le}from"@fluixi/utils";var Z=!1,vt=Symbol.for("signal"),ht=Symbol.for("memo"),Tt=Symbol.for("resource");function ee(e){return typeof e=="function"&&e[vt]===!0}function bt(e){return typeof e=="function"&&e[ht]===!0}function yt(e){return typeof e=="function"&&e[Tt]===!0}function mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function wt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function xt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Me(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Me(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var gt="__fluixi_signal_next_state__",St=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[gt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:St,onSuspend:null,onError:null};var Le=0,Be=1,z=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))}},ne=class extends te{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(z);pe(this)}}peek(){return this._value}},G=class extends te{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=z;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.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===Be&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=Le}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let n=a.consumer,o=a.untracked;a.consumer=this,a.untracked=!1;let r,s=!1,l;try{r=this._fn()}catch(f){s=!0,l=f,r=this._value}finally{a.consumer=n,a.untracked=o}let c=!this._initialized||this._threw!==s||(s?l!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=l,this._value=r,c){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(z);pe(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Le;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Be);pe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function pe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var re=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 Ot(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Te(){return a.owner}function oe(e,t){let n=a.owner;a.owner=e;try{return t()}finally{a.owner=n}}function be(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function ve(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)ve(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 Ve(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Ct(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(ye)))}function ye(){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 je(){a.batchDepth===0&&ye()}var he=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Ot(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new G(()=>{ve(this.owner,!1),oe(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new re(()=>Ct(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),ve(this.owner))}};function $e(e){let t=new he(e);return()=>t.dispose()}function Rt(e){return!!e&&typeof e.then=="function"}Ve(()=>{});var We=Symbol.for("signal"),_t=Symbol.for("memo"),At=Symbol.for("signal-node");function me(e,t){let n=new ne(e,{equals:t?.equals}),o=(()=>n.get()),r=(s=>{let l=typeof s=="function"?s(n.peek()):s;return n.set(l),je(),l});return Object.defineProperty(o,We,{value:!0,enumerable:!0}),Object.defineProperty(o,At,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,r]}function se(e,t,n){let o=t,r=Te(),s=new G(()=>oe(r,()=>{try{return o=e(o)}catch(c){if(Rt(c))return Ge(c),o;throw c}}),{equals:n?.equals}),l=(()=>s.get());return Object.defineProperty(l,We,{value:!0,enumerable:!0}),Object.defineProperty(l,_t,{value:!0,enumerable:!0}),l}function we(e,t){let n=t;return $e(()=>{n=e(n)})}function ze(e,t=(n,o)=>n===o){let n=new Map;return we(()=>{let o=e();for(let[r,s]of n){let[l,c]=s,f=t(r,o);l()!==f&&c(f)}}),o=>{let r=n.get(o);if(!r){let[s,l]=me(!1);r=[s,l],n.set(o,r);let c=e();l(t(o,c))}return r[0]()}}function Ft(e,t){let[n,o]=me(e(),t);return we(()=>{let r=e();t?.timeoutMs?setTimeout(()=>o(()=>r),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),n}function Et(e,t){let n,o=(...r)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...r)},t)};return be(()=>{n!==void 0&&clearTimeout(n)}),o}function ie(e){if(typeof e=="function"&&!e.length){let t=e();return ee(t)?t:ie(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=ie(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function He(e){let t=se(e);return se(()=>ie(t()))}var xe=null;function Pt(e){xe=e}function Ye(e){xe&&xe(e)}var ge=null;function kt(e){ge=e}function Ke(e){return ge?ge(e):void 0}var Se=null;function Dt(e){Se=e}function Xe(){return Se?Se():void 0}var Oe=null;function qt(e){Oe=e}function Je(e,t){Oe&&Oe(e,t)}var Ee=Symbol.for("signal"),Nt=Symbol.for("memo"),Ut=Symbol.for("resource"),Qe=Symbol("fluixi-proxy"),tt=Symbol.for("signal-node"),A=0,H=1,E=2,F=3,u=null,d=null,i=null,ue=null,ae=0,It=!1,Ce=!1,V=0,Mt=1e6,m=new WeakMap,g=null;var Lt=null,Bt=new Map,Gt=0,Re={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function Mn(e){u=e,Re.owner=e,Re.context=e}function Ln(){return Re}function Vt(){return`node_${++Gt}_${Date.now()}`}function jt(e){!1}function nt(e,t,n){let o={id:Vt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return jt(o),o}function rt(e,t){return e===t}function Pe(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var _e=null,Ae=null;function ot(){if(!_e){let[e,t]=M(!1);_e=e,Ae=t}}function st(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)X(e);else if(e.pure&&!e.computed&&e.accessor){let t=d,n=i;d=null,i=[],e.accessor(),d=t;let o=i;if(i=n,o.length>0){let r=i;ce(o),i=r}}}function Ze(e,t){for(let n=0;n<e.length;n++)t(e[n])}function M(e,t){let n=e;typeof n=="object"&&n&&Qe in n&&delete n[Qe];let o=nt("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[l,c];m.set(r,new Set);let s;function l(){let f=d;if(f){f.sources?f.sources.indexOf(r)===-1&&f.sources.push(r):f.sources=[r];let p=m.get(r);p&&!p.has(f)&&p.add(f)}return n}function c(f){let p=typeof f=="function"?f(n):f,b=o.equals||rt;if(t?.equals===!1||!b(n,p)){n=p,o.value=p,o.version++,o.updated=Date.now();let k=m.get(r);if(k&&k.size>0){let D=function(v,h=!1){let q=v.state;if(!(q===F&&v===d)){if(h&&!v.pure){q===A&&(v.state=H,It&&(i!==null&&i.indexOf(v)===-1?i.push(v):C.push(v)));return}if(!w.has(v)&&(w.add(v),v.state=E,q===A||q===H?C.push(v):!v.pure&&i!==null&&i.indexOf(v)===-1&&i.push(v),v.pure&&v.accessor)){let O=m.get(v.accessor);O&&Ze(Array.from(O),R=>D(R,!0))}}};var x=D;let S=Array.from(k),C=[],w=new Set;Ze(S,D);for(let v of C)st(v)}}}return l.toObservable=()=>new W(f=>{let p=!0;return K(()=>{let x=l();p?p=!1:f.next(x)})}),Object.defineProperty(l,Ee,{value:!0,enumerable:!0}),Object.defineProperty(l,tt,{value:o,enumerable:!1}),r}function K(e,t,n){let o={fn:e,state:E,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&P(T);return r&&(o.suspense=r),ke(o,t),()=>U(o)}function ke(e,t){if(e.sources){for(let r of e.sources){let s=m.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=d,o=u;if(d=e,u=e,ae++,ae>Mt)throw ae=0,d=n,u=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=F;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===F&&(e.state=A)}catch(r){if(le(r)){let s=T&&P(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Pe(r)}finally{d=n,u=o}}function X(e){if(!(e.disposed||!e.fn||e.state===A)&&(e.state===E||e.state===H||e.state===F)){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?lt(e):ke(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=m.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 $t(e,t,n){let o=nt("memo",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r={fn:e,state:E,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};u&&(u.owned?u.owned.push(r):u.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;m.has(c)||m.set(c,new Set);let f=m.get(c);f&&f.add(d)}if(r.state!==A){if(r.sources){for(let p of r.sources){let b=m.get(p);b&&b.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let p=0;p<r.cleanups.length;p++)r.cleanups[p]();r.cleanups=null}if(r.owned){for(let p=0;p<r.owned.length;p++)U(r.owned[p]);r.owned=null}let c=d,f=u;d=r,u=r,r.state=F;try{let p=r.fn(r.value),b=o.equals||rt;if(n?.equals===!1||!b(r.value,p)){r.value=p,o.value=p,o.version++,o.updated=Date.now();let k=s,S=m.get(k);if(S&&S.size>0){let v=function(h,q=!1){if(h===r)return;let O=h.state;if(O!==F){if(q&&!h.pure){O===A&&(h.state=H,i!==null&&i.indexOf(h)===-1?i.push(h):w.push(h));return}if(!D.has(h)&&(D.add(h),h.state=E,O===A||O===H?w.push(h):!h.pure&&i!==null&&i.indexOf(h)===-1&&i.push(h),h.pure&&h.accessor)){let R=m.get(h.accessor);if(R&&R.size>0)for(let j of Array.from(R))v(j,!0)}}};var l=v;let C=Array.from(S),w=[],D=new Set;for(let h=0;h<C.length;h++)v(C[h]);for(let h of w)st(h)}}r.state===F&&(r.state=A)}catch(p){if(le(p)){let b=T&&P(T);if(!b&&T){let x=f;for(;x;){if(x.contexts?.has(T.id)){b=x.contexts.get(T.id);break}x=x.owner}}return b&&(b.increment(),p.finally(()=>b.decrement())),r.value}Pe(p)}finally{d=c,u=f}}return r.value};return r.accessor=s,m.set(s,new Set),s.toObservable=()=>new W(l=>{let c=!0;return K(()=>{let p=s();c?c=!1:l.next(p)})}),Object.defineProperty(s,Ee,{value:!0,enumerable:!0}),Object.defineProperty(s,Nt,{value:!0,enumerable:!0}),Object.defineProperty(s,tt,{value:o,enumerable:!1}),s}function ce(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=m.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=i.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?t.indexOf(c)===-1&&t.push(c):(c.computed||!c.pure)&&n.indexOf(c)===-1&&n.push(c)}i=null;for(let r of n)(r.computed||!r.pure)&&X(r)}function _(e){if(i&&V>0)return e();if(i&&V===0){let t=i,n=[];i=n,V++;let o;try{o=e()}finally{V--,i=t}let r=i;return ce(n),i=r,o}V++,i=[],ue=[];try{return e()}finally{V--,it()}}function it(){if(!Ce){Ce=!0,ae=0;try{for(;i&&i.length>0;){let e=i;i=null,ce(e)}if(i=null,ue){let e=ue;ue=null;for(let t=0;t<e.length;t++)X(e[t])}}finally{Ce=!1}}}function Wt(e){let t={owned:null,cleanups:null,contexts:null,owner:u},n=d;d=null;let o=u;u=t;try{return e(()=>{if(t.owned)for(let r=0;r<t.owned.length;r++)U(t.owned[r]);if(t.cleanups)for(let r=0;r<t.cleanups.length;r++)t.cleanups[r]()})}finally{u=o,d=n}}function Y(e){let t=d;d=null;try{return e()}finally{d=t}}function Fe(e){u&&(u.cleanups?u.cleanups.push(e):u.cleanups=[e])}function zt(e,t,n={}){let o,r;typeof t=="function"?(o=typeof e=="function"?e:()=>e,r=t):(o=()=>!0,r=e,t&&typeof t=="object"&&(n=t));let{initialValue:s,name:l}=n,c=n.transport===!1?void 0:Xe(),f=c!==void 0?Ke(c):void 0,p=f!==void 0,[b,x]=M(f!==void 0?f.value:n.initialValue,{equals:!1}),[k,S]=M(void 0,{equals:!1}),[C,w]=M(f!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,v]=M(void 0,{equals:!1}),[h,q]=M(void 0,{equals:!1}),O=Symbol(),R=O,j=!1,ct=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},ft=K(()=>{let y=o?o():e;if(h(),y===!1||y===null||y===void 0){R=O,_(()=>{w("unresolved"),v(void 0),S(void 0)});return}let L=j;if(j=!1,R!==O&&y===R&&!L)return;if(R=y,p){p=!1;return}let B=!1;Fe(()=>B=!0);let Ne=Y(C),dt=Y(b),Ue=Ne==="ready"||Ne==="refreshing";_(()=>{w(Ue?"refreshing":"pending"),S(void 0)});try{let N=r(y,{value:dt,refetching:Ue});if(le(N)){v(N),Ye(N),N.then(I=>{B||(c!==void 0&&Je(c,I),_(()=>{x(()=>I),ct(I),w("ready"),v(void 0)}))},I=>{B||_(()=>{S(I),w("errored"),v(void 0)})}).catch(I=>{B||_(()=>{S(I),w("errored"),v(void 0)})});let fe=T&&P(T);fe&&(fe.increment(),N.finally(()=>fe.decrement()))}else{if(B)return;_(()=>{x(()=>N),w("ready"),v(void 0)})}}catch(N){if(B)return;_(()=>{S(N),w("errored"),v(void 0)})}});Fe(ft);let qe=()=>{let y=C();return y==="pending"||y==="refreshing"},J=(()=>{let y=k();if(y)throw y;if(qe()){let L=D();if(L)throw L}return b()});return Object.defineProperty(J,Ut,{value:!0,enumerable:!0}),Object.defineProperty(J,Ee,{value:!0,enumerable:!0}),Object.defineProperties(J,{state:{get:C},loading:{get:()=>qe()},error:{get:k},latest:{get:b}}),[J,{mutate:x,refetch:()=>{j=!0,q(void 0)}}]}function Ht(){return u}function Yt(e,t){let n=u,o=d;u=e,d=null;try{return t()}finally{u=n,d=o}}function De(e){let t=Symbol("context"),n=Kt(t);return{id:t,Provider:n,defaultValue:e}}function Kt(e){return t=>{let n=u;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return at(()=>{o=Y(()=>{let r=u;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),He(()=>t.children)})}),o}}function P(e){let t=u;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 Xt(){return new Promise(e=>{queueMicrotask(()=>{it(),e()})})}function ut(e){if(g&&g.running)return e(),g.done;ot();let t,n=new Promise(r=>t=r),o={running:!0,effects:[],resolve:t,done:n};g=o;try{e()}finally{o.running=!1}return o.effects.length?(Ae(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,Ae(!1),r.length&&_(()=>{for(let s of r)s.state=E,X(s)}),t()}),n):(g=null,t(),n)}function Jt(){return ot(),[_e,ut]}function Qt(e,t,n){let o=n?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):Y(()=>t(l,s))}}function at(e,t,n){let o={fn:e,state:E,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&P(T);return r&&(o.suspense=r),lt(o),()=>U(o)}function lt(e){if(e.sources){for(let r of e.sources){let s=m.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=d,n=u,o=i;d=e,u=e,i===null&&(i=[]),e.state=F;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===F&&(e.state=A)}catch(r){if(le(r)){let s=T&&P(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Pe(r)}finally{d=t,u=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;ce(r),i=s}}}function Zt(e,t,n){let o={fn:e,state:E,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,computed:!0,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]),g&&g.running?(i||(i=[]),i.indexOf(o)===-1&&i.push(o)):i?i.indexOf(o)===-1&&i.push(o):ke(o,t)}var T;function en(){return T||(T=De())}var et;function tn(){return et||(et=De())}function nn(e){if(!e.length)return;let t=e.slice();e.length=0;for(let n of t)n.state=E,X(n)}function rn(e){let t=T&&P(T);t&&t.inFallback()?K(()=>{t.inFallback()||e()}):e()}function on(e){Lt=e}function sn(e){let t=T&&P(T);return t&&(t.increment(),e.finally(()=>t.decrement())),e}var Gn={createSignal:M,createEffect:K,createMemo:$t,createComputed:Zt,createRoot:Wt,createSelector:ze,createResource:zt,batch:_,untrack:Y,onCleanup:Fe,getOwner:Ht,runWithOwner:Yt,createContext:De,useContext:P,flush:Xt,startTransition:ut,useTransition:Jt,isSignal:ee,on:Qt,createRenderEffect:at,getSuspenseContext:en,getSuspenseListContext:tn,resumeEffects:nn,onResolve:rn,setScheduler:on,trackPromise:sn};export{Nt as $MEMO,Qe as $PROXY,Ut as $RESOURCE,Ee as $SIGNAL,Z as __DEV__,_ as batch,Zt as createComputed,De as createContext,Et as createDebounce,Ft as createDeferred,K as createEffect,$t as createMemo,Kt as createProvider,at as createRenderEffect,zt as createResource,Wt as createRoot,ze as createSelector,M as createSignal,Gn as default,Xt as flush,Ht as getOwner,Ke as getServerData,Ln as getSharedConfig,en as getSuspenseContext,tn as getSuspenseListContext,mt as isComponent,bt as isMemo,xt as isProvider,yt as isResource,ee as isSignal,wt as isSuspense,Me as makeArrayFlat,Xe as nextResourceId,Qt as on,Fe as onCleanup,rn as onResolve,He as readChildren,Je as reportResourceData,nn as resumeEffects,Yt as runWithOwner,Mn as setOwner,qt as setResourceDataSink,Dt as setResourceIdSource,Pt as setResourceTracker,on as setScheduler,kt as setServerDataGetter,Re as sharedConfig,ut as startTransition,sn as trackPromise,Ye as trackResourcePromise,Y as untrack,P as useContext,Jt as useTransition};
|
|
1
|
+
function de(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Me(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 $(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var W=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(de(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Me(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(de(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var Z=class extends W{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends Z{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}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 z=class extends W{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof Z?r=n:r=new pe(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var ee=!1,vn=Symbol.for("signal"),Tn=Symbol.for("memo"),bn=Symbol.for("resource");function ne(e){return typeof e=="function"&&e[vn]===!0}function yn(e){return typeof e=="function"&&e[Tn]===!0}function mn(e){return typeof e=="function"&&e[bn]===!0}function wn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function xn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function gn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Le(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Le(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Sn="__fluixi_signal_next_state__",On=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Sn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:On,onSuspend:null,onError:null};var Be=0,je=1,H=2,te=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},re=class extends te{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(H);he(this)}}peek(){return this._value}},j=class extends te{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=H;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.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===je&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===H)break}(this.state===H||!this._initialized)&&this.recompute(),this.state=Be}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked;a.consumer=this,a.untracked=!1;let r,s=!1,l;try{r=this._fn()}catch(f){s=!0,l=f,r=this._value}finally{a.consumer=t,a.untracked=o}let c=!this._initialized||this._threw!==s||(s?l!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=l,this._value=r,c){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(H);he(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Be;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(je);he(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function he(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var oe=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function Cn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function be(){return a.owner}function se(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function ye(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function ve(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)ve(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function Ve(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Rn(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(me)))}function me(){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 n=a.queue;a.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function $e(){a.batchDepth===0&&me()}var Te=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=Cn(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{ve(this.owner,!1),se(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new oe(()=>Rn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&a.onSuspend){a.onSuspend(n,this.owner);return}if(a.onError&&a.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),ve(this.owner))}};function We(e){let n=new Te(e);return()=>n.dispose()}function _n(e){return!!e&&typeof e.then=="function"}Ve(()=>{});var ze=Symbol.for("signal"),An=Symbol.for("memo"),Fn=Symbol.for("signal-node");function we(e,n){let t=new re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),$e(),l});return Object.defineProperty(o,ze,{value:!0,enumerable:!0}),Object.defineProperty(o,Fn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function ie(e,n,t){let o=n,r=be(),s=new j(()=>se(r,()=>{try{return o=e(o)}catch(c){if(_n(c))return Ge(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,ze,{value:!0,enumerable:!0}),Object.defineProperty(l,An,{value:!0,enumerable:!0}),l}function xe(e,n){let t=n;return We(()=>{t=e(t)})}function He(e,n=(t,o)=>t===o){let t=new Map;return xe(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,f=n(r,o);l()!==f&&c(f)}}),o=>{let r=t.get(o);if(!r){let[s,l]=we(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function En(e,n){let[t,o]=we(e(),n);return xe(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function kn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ye(()=>{t!==void 0&&clearTimeout(t)}),o}function ue(e){if(typeof e=="function"&&!e.length){let n=e();return ne(n)?n:ue(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ue(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ye(e){let n=ie(e);return ie(()=>ue(n()))}var ge=null;function Pn(e){ge=e}function Ke(e){ge&&ge(e)}var Se=null;function Dn(e){Se=e}function Xe(e){return Se?Se(e):void 0}var Oe=null;function qn(e){Oe=e}function Je(){return Oe?Oe():void 0}var Ce=null;function Nn(e){Ce=e}function Qe(e,n){Ce&&Ce(e,n)}var ke=Symbol.for("signal"),Un=Symbol.for("memo"),In=Symbol.for("resource"),Ze=Symbol("fluixi-proxy"),tn=Symbol.for("signal-node"),A=0,Y=1,E=2,F=3,u=null,d=null,i=null,ae=null,le=0,Mn=!1,Re=!1,G=0,Ln=1e6,m=new WeakMap,g=null;var Bn=null,jn=new Map,Gn=0,_e={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function Lt(e){u=e,_e.owner=e,_e.context=e}function Bt(){return _e}function Vn(){return`node_${++Gn}_${Date.now()}`}function $n(e){!1}function rn(e,n,t){let o={id:Vn(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return $n(o),o}function on(e,n){return e===n}function Pe(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var Ae=null,Fe=null;function sn(){if(!Ae){let[e,n]=M(!1);Ae=e,Fe=n}}function un(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)J(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=i;d=null,i=[],e.accessor(),d=n;let o=i;if(i=t,o.length>0){let r=i;ce(o),i=r}}}function en(e,n){for(let t=0;t<e.length;t++)n(e[t])}function M(e,n){let t=e;typeof t=="object"&&t&&Ze in t&&delete t[Ze];let o=rn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];m.set(r,new Set);let s;function l(){let f=d;if(f){f.sources?f.sources.indexOf(r)===-1&&f.sources.push(r):f.sources=[r];let p=m.get(r);p&&!p.has(f)&&p.add(f)}return t}function c(f){let p=typeof f=="function"?f(t):f,b=o.equals||on;if(n?.equals===!1||!b(t,p)){t=p,o.value=p,o.version++,o.updated=Date.now();let P=m.get(r);if(P&&P.size>0){let D=function(h,v=!1){let q=h.state;if(!(q===F&&h===d)){if(v&&!h.pure){q===A&&(h.state=Y,Mn&&(i!==null&&i.indexOf(h)===-1?i.push(h):C.push(h)));return}if(!w.has(h)&&(w.add(h),h.state=E,q===A||q===Y?C.push(h):!h.pure&&i!==null&&i.indexOf(h)===-1&&i.push(h),h.pure&&h.accessor)){let O=m.get(h.accessor);O&&en(Array.from(O),R=>D(R,!0))}}};var x=D;let S=Array.from(P),C=[],w=new Set;en(S,D);for(let h of C)un(h)}}}return l.toObservable=()=>new z(f=>{let p=!0;return X(()=>{let x=l();p?p=!1:f.next(x)})}),Object.defineProperty(l,ke,{value:!0,enumerable:!0}),Object.defineProperty(l,tn,{value:o,enumerable:!1}),r}function X(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&k(T);return r&&(o.suspense=r),De(o,n),()=>U(o)}function De(e,n){if(e.sources){for(let r of e.sources){let s=m.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 t=d,o=u;if(d=e,u=e,le++,le>Ln)throw le=0,d=t,u=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=F;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===F&&(e.state=A)}catch(r){if($(r)){let s=T&&k(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Pe(r)}finally{d=t,u=o}}function J(e){if(!(e.disposed||!e.fn||e.state===A)&&(e.state===E||e.state===Y||e.state===F)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)U(e.owned[n]);e.owned=null}e.renderEffect?fn(e):De(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=m.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)U(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function Wn(e,n,t){let o=rn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};u&&(u.owned?u.owned.push(r):u.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;m.has(c)||m.set(c,new Set);let f=m.get(c);f&&f.add(d)}if(r.state!==A){if(r.sources){for(let p of r.sources){let b=m.get(p);b&&b.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let p=0;p<r.cleanups.length;p++)r.cleanups[p]();r.cleanups=null}if(r.owned){for(let p=0;p<r.owned.length;p++)U(r.owned[p]);r.owned=null}let c=d,f=u;d=r,u=r,r.state=F;try{let p=r.fn(r.value),b=o.equals||on;if(t?.equals===!1||!b(r.value,p)){r.value=p,o.value=p,o.version++,o.updated=Date.now();let P=s,S=m.get(P);if(S&&S.size>0){let h=function(v,q=!1){if(v===r)return;let O=v.state;if(O!==F){if(q&&!v.pure){O===A&&(v.state=Y,i!==null&&i.indexOf(v)===-1?i.push(v):w.push(v));return}if(!D.has(v)&&(D.add(v),v.state=E,O===A||O===Y?w.push(v):!v.pure&&i!==null&&i.indexOf(v)===-1&&i.push(v),v.pure&&v.accessor)){let R=m.get(v.accessor);if(R&&R.size>0)for(let V of Array.from(R))h(V,!0)}}};var l=h;let C=Array.from(S),w=[],D=new Set;for(let v=0;v<C.length;v++)h(C[v]);for(let v of w)un(v)}}r.state===F&&(r.state=A)}catch(p){if($(p)){let b=T&&k(T);if(!b&&T){let x=f;for(;x;){if(x.contexts?.has(T.id)){b=x.contexts.get(T.id);break}x=x.owner}}return b&&(b.increment(),p.finally(()=>b.decrement())),r.value}Pe(p)}finally{d=c,u=f}}return r.value};return r.accessor=s,m.set(s,new Set),s.toObservable=()=>new z(l=>{let c=!0;return X(()=>{let p=s();c?c=!1:l.next(p)})}),Object.defineProperty(s,ke,{value:!0,enumerable:!0}),Object.defineProperty(s,Un,{value:!0,enumerable:!0}),Object.defineProperty(s,tn,{value:o,enumerable:!1}),s}function ce(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=m.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=i.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?n.indexOf(c)===-1&&n.push(c):(c.computed||!c.pure)&&t.indexOf(c)===-1&&t.push(c)}i=null;for(let r of t)(r.computed||!r.pure)&&J(r)}function _(e){if(i&&G>0)return e();if(i&&G===0){let n=i,t=[];i=t,G++;let o;try{o=e()}finally{G--,i=n}let r=i;return ce(t),i=r,o}G++,i=[],ae=[];try{return e()}finally{G--,an()}}function an(){if(!Re){Re=!0,le=0;try{for(;i&&i.length>0;){let e=i;i=null,ce(e)}if(i=null,ae){let e=ae;ae=null;for(let n=0;n<e.length;n++)J(e[n])}}finally{Re=!1}}}function zn(e){let n={owned:null,cleanups:null,contexts:null,owner:u},t=d;d=null;let o=u;u=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)U(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{u=o,d=t}}function K(e){let n=d;d=null;try{return e()}finally{d=n}}function Ee(e){u&&(u.cleanups?u.cleanups.push(e):u.cleanups=[e])}function Hn(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:l}=t,c=t.transport===!1?void 0:Je(),f=c!==void 0?Xe(c):void 0,p=f!==void 0,[b,x]=M(f!==void 0?f.value:t.initialValue,{equals:!1}),[P,S]=M(void 0,{equals:!1}),[C,w]=M(f!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,h]=M(void 0,{equals:!1}),[v,q]=M(void 0,{equals:!1}),O=Symbol(),R=O,V=!1,dn=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},pn=X(()=>{let y=o?o():e;if(v(),y===!1||y===null||y===void 0){R=O,_(()=>{w("unresolved"),h(void 0),S(void 0)});return}let L=V;if(V=!1,R!==O&&y===R&&!L)return;if(R=y,p){p=!1;return}let B=!1;Ee(()=>B=!0);let Ue=K(C),hn=K(b),Ie=Ue==="ready"||Ue==="refreshing";_(()=>{w(Ie?"refreshing":"pending"),S(void 0)});try{let N=r(y,{value:hn,refetching:Ie});if($(N)){h(N),Ke(N),N.then(I=>{B||(c!==void 0&&Qe(c,I),_(()=>{x(()=>I),dn(I),w("ready"),h(void 0)}))},I=>{B||_(()=>{S(I),w("errored"),h(void 0)})}).catch(I=>{B||_(()=>{S(I),w("errored"),h(void 0)})});let fe=T&&k(T);fe&&(fe.increment(),N.finally(()=>fe.decrement()))}else{if(B)return;_(()=>{x(()=>N),w("ready"),h(void 0)})}}catch(N){if(B)return;_(()=>{S(N),w("errored"),h(void 0)})}});Ee(pn);let Ne=()=>{let y=C();return y==="pending"||y==="refreshing"},Q=(()=>{let y=P();if(y)throw y;if(Ne()){let L=D();if(L)throw L}return b()});return Object.defineProperty(Q,In,{value:!0,enumerable:!0}),Object.defineProperty(Q,ke,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:C},loading:{get:()=>Ne()},error:{get:P},latest:{get:b}}),[Q,{mutate:x,refetch:()=>{V=!0,q(void 0)}}]}function Yn(){return u}function Kn(e,n){let t=u,o=d;u=e,d=null;try{return n()}finally{u=t,d=o}}function qe(e){let n=Symbol("context"),t=Xn(n);return{id:n,Provider:t,defaultValue:e}}function Xn(e){return n=>{let t=u;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return cn(()=>{o=K(()=>{let r=u;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ye(()=>n.children)})}),o}}function k(e){let n=u;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Jn(){return new Promise(e=>{queueMicrotask(()=>{an(),e()})})}function ln(e){if(g&&g.running)return e(),g.done;sn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};g=o;try{e()}finally{o.running=!1}return o.effects.length?(Fe(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,Fe(!1),r.length&&_(()=>{for(let s of r)s.state=E,J(s)}),n()}),t):(g=null,n(),t)}function Qn(){return sn(),[Ae,ln]}function Zn(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):K(()=>n(l,s))}}function cn(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&k(T);return r&&(o.suspense=r),fn(o),()=>U(o)}function fn(e){if(e.sources){for(let r of e.sources){let s=m.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 n=d,t=u,o=i;d=e,u=e,i===null&&(i=[]),e.state=F;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===F&&(e.state=A)}catch(r){if($(r)){let s=T&&k(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Pe(r)}finally{d=n,u=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;ce(r),i=s}}}function et(e,n,t){let o={fn:e,state:E,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,computed:!0,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]),g&&g.running?(i||(i=[]),i.indexOf(o)===-1&&i.push(o)):i?i.indexOf(o)===-1&&i.push(o):De(o,n)}var T;function nt(){return T||(T=qe())}var nn;function tt(){return nn||(nn=qe())}function rt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=E,J(t)}function ot(e){let n=T&&k(T);n&&n.inFallback()?X(()=>{n.inFallback()||e()}):e()}function st(e){Bn=e}function it(e){let n=T&&k(T);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var Gt={createSignal:M,createEffect:X,createMemo:Wn,createComputed:et,createRoot:zn,createSelector:He,createResource:Hn,batch:_,untrack:K,onCleanup:Ee,getOwner:Yn,runWithOwner:Kn,createContext:qe,useContext:k,flush:Jn,startTransition:ln,useTransition:Qn,isSignal:ne,on:Zn,createRenderEffect:cn,getSuspenseContext:nt,getSuspenseListContext:tt,resumeEffects:rt,onResolve:ot,setScheduler:st,trackPromise:it};export{Un as $MEMO,Ze as $PROXY,In as $RESOURCE,ke as $SIGNAL,ee as __DEV__,_ as batch,et as createComputed,qe as createContext,kn as createDebounce,En as createDeferred,X as createEffect,Wn as createMemo,Xn as createProvider,cn as createRenderEffect,Hn as createResource,zn as createRoot,He as createSelector,M as createSignal,Gt as default,Jn as flush,Yn as getOwner,Xe as getServerData,Bt as getSharedConfig,nt as getSuspenseContext,tt as getSuspenseListContext,wn as isComponent,yn as isMemo,gn as isProvider,mn as isResource,ne as isSignal,xn as isSuspense,Le as makeArrayFlat,Je as nextResourceId,Zn as on,Ee as onCleanup,ot as onResolve,Ye as readChildren,Qe as reportResourceData,rt as resumeEffects,Kn as runWithOwner,Lt as setOwner,Nn as setResourceDataSink,qn as setResourceIdSource,Pn as setResourceTracker,st as setScheduler,Dn as setServerDataGetter,_e as sharedConfig,ln as startTransition,it as trackPromise,Ke as trackResourcePromise,K as untrack,k as useContext,Qn as useTransition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},j=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of K(e))!G.call(t,o)&&o!==r&&w(t,o,{get:()=>e[o],enumerable:!(n=I(e,o))||n.enumerable});return t};var H=t=>j(w({},"__esModule",{value:!0}),t);var ve={};V(ve,{combineSignal:()=>se,combineSignals:()=>ie,debounceSignal:()=>he,distinctSignal:()=>oe,everySignal:()=>te,filterSignal:()=>X,findSignal:()=>ee,guardSignal:()=>fe,mapSignal:()=>Q,mergeSignal:()=>ue,omitSignal:()=>le,pickSignal:()=>pe,readSignal:()=>Te,reduceSignal:()=>Z,selectSignal:()=>ae,someSignal:()=>re,sortSignal:()=>ne,throttleSignal:()=>be,whenSignal:()=>de,zipSignal:()=>ce});module.exports=H(ve);var L="__fluixi_signal_next_state__",N=t=>{typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)},s=globalThis[L]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:N,onSuspend:null,onError:null};var k=0,C=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let e=s.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},b=class extends h{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(d);O(this)}}peek(){return this._value}},l=class extends h{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===C&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=k}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let r=s.consumer,n=s.untracked;s.consumer=this,s.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{s.consumer=r,s.untracked=n}let p=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,p){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(d);O(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===k;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(C);O(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function O(t){if(t.watchers)for(let e of[...t.watchers])e._notify(t)}var T=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function z(t){return{cleanups:null,owned:null,parent:t,contexts:null}}function P(t){return s.onSuspend?(s.onSuspend(t,s.owner),!0):!1}function U(){return s.owner}function S(t,e){let r=s.owner;s.owner=t;try{return e()}finally{s.owner=r}}function m(t,e=!0){if(!t.disposed){if(t.owned){for(let r=t.owned.length-1;r>=0;r--)m(t.owned[r]);t.owned=null}if(t.cleanups){for(let r=t.cleanups.length-1;r>=0;r--)t.cleanups[r]();t.cleanups=null}e&&(t.disposed=!0)}}function D(t){s.hostSchedule=t??(e=>{Promise.resolve().then(e)})}function W(t){t.queued||(t.queued=!0,s.queue.push(t),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(A)))}function A(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let t=0;try{for(;s.queue.length;){if(++t>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=s.queue;s.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{s.flushing=!1}}function E(){s.batchDepth===0&&A()}var x=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=z(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{m(this.owner,!1),S(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new T(()=>W(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&s.onSuspend){s.onSuspend(e,this.owner);return}if(s.onError&&s.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),m(this.owner))}};function R(t){let e=new x(t);return()=>e.dispose()}function Y(t){return!!t&&typeof t.then=="function"}D(()=>{});var q=Symbol.for("signal"),$=Symbol.for("memo"),J=Symbol.for("signal-node");function g(t,e){let r=new b(t,{equals:e?.equals}),n=(()=>r.get()),o=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),E(),u});return Object.defineProperty(n,q,{value:!0,enumerable:!0}),Object.defineProperty(n,J,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function c(t,e,r){let n=e,o=U(),i=new l(()=>S(o,()=>{try{return n=t(n)}catch(p){if(Y(p))return P(p),n;throw p}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,q,{value:!0,enumerable:!0}),Object.defineProperty(u,$,{value:!0,enumerable:!0}),u}function M(t,e){let r=e;return R(()=>{r=t(r)})}var B=require("@fluixi/utils/object"),_=require("@fluixi/utils/functions"),f=class t{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 t)e.remove(this);else if(e!==null)for(let n of e)n.remove(this);if(r){for(let n of r)if((0,_.isFunction)(n)&&!(n instanceof t))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,B.isObject)(n)&&typeof n.unsubscribe=="function")try{n.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:n}=this;if(r){if((0,_.isFunction)(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 n||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof t&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(e);n!==-1&&(r.splice(n,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 n=r.indexOf(e);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var v=class extends f{constructor(r,n,o){super();this.isStopped=!1;let i;r?typeof r=="object"?i=r:i={next:r,error:n,complete:o}:i={},this.destination=i}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())}},F=class extends v{constructor(r,n,o,i){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||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)}};var y=class extends f{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,n){let o;e instanceof v?o=e:o=new F(e,r,n);let{_subscribe:i}=this;try{let u=i.call(this,o);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&o.add(u)}catch(u){o.error(u)}return o}pipe(...e){return e.length===0?this:e.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((e,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>e(n)})})}};function Q(t,e,r){return c(()=>e(t()),void 0,r)}function X(t,e,r){return c(()=>t().filter(e),void 0,r)}function Z(t,e,r,n){return c(()=>t().reduce(e,r),void 0,n)}function ee(t,e,r){return c(()=>t().find(e),void 0,r)}function re(t,e,r){return c(()=>t().some(e),void 0,r)}function te(t,e,r){return c(()=>t().every(e),void 0,r)}function ne(t,e,r){return c(()=>[...t()].sort(e),void 0,r)}function oe(t,e){return c(()=>[...new Set(t())],void 0,e)}function se(t,e,r){return c(()=>{let n=t.map(o=>o());return e(n)},void 0,r)}function ie(...t){return new y(e=>{let r=()=>t.map(o=>typeof o=="function"?o():o.get()),n=t.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):M(()=>{e.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ue(t,e,r){return c(()=>t()||e(),void 0,r)}function ce(t,e,r,n){return c(()=>r(t(),e()),void 0,n)}function ae(t,e,r){return c(()=>e(t()),void 0,{equals:r,internal:!0})}function pe(t,e,r){return c(()=>{let n=t(),o={};for(let i of e)o[i]=n[i];return o},void 0,r)}function le(t,e,r){return c(()=>{let o={...t()};for(let i of e)delete o[i];return o},void 0,r)}function de(t,e,r,n){return c(()=>t()?e():r(),void 0,n)}function fe(t,e,r){return c(()=>t()?e():void 0,void 0,r)}function he(t,e,r){let[n,o]=g(t()),i;return c(()=>{let u=t();clearTimeout(i),i=setTimeout(()=>o(()=>u),e)}),n}function be(t,e,r){let[n,o]=g(t()),i=0,u;return c(()=>{let p=t(),a=Date.now();a-i>=e?(i=a,o(()=>p)):(clearTimeout(u),u=setTimeout(()=>{i=Date.now(),o(()=>p)},e-(a-i)))}),n}function Te(t){let e=t;for(;typeof e=="function";)e=e();return e}
|
|
1
|
+
"use strict";var w=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of K(e))!G.call(t,o)&&o!==r&&w(t,o,{get:()=>e[o],enumerable:!(n=I(e,o))||n.enumerable});return t};var H=t=>V(w({},"__esModule",{value:!0}),t);var ve={};j(ve,{combineSignal:()=>se,combineSignals:()=>ie,debounceSignal:()=>he,distinctSignal:()=>oe,everySignal:()=>te,filterSignal:()=>X,findSignal:()=>ee,guardSignal:()=>fe,mapSignal:()=>Q,mergeSignal:()=>ue,omitSignal:()=>le,pickSignal:()=>pe,readSignal:()=>Te,reduceSignal:()=>Z,selectSignal:()=>ae,someSignal:()=>re,sortSignal:()=>ne,throttleSignal:()=>be,whenSignal:()=>de,zipSignal:()=>ce});module.exports=H(ve);var L="__fluixi_signal_next_state__",N=t=>{typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)},s=globalThis[L]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:N,onSuspend:null,onError:null};var k=0,P=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let e=s.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},b=class extends h{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(d);m(this)}}peek(){return this._value}},l=class extends h{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===P&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=k}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let r=s.consumer,n=s.untracked;s.consumer=this,s.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{s.consumer=r,s.untracked=n}let p=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,p){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(d);m(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===k;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(P);m(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function m(t){if(t.watchers)for(let e of[...t.watchers])e._notify(t)}var T=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function z(t){return{cleanups:null,owned:null,parent:t,contexts:null}}function C(t){return s.onSuspend?(s.onSuspend(t,s.owner),!0):!1}function E(){return s.owner}function S(t,e){let r=s.owner;s.owner=t;try{return e()}finally{s.owner=r}}function O(t,e=!0){if(!t.disposed){if(t.owned){for(let r=t.owned.length-1;r>=0;r--)O(t.owned[r]);t.owned=null}if(t.cleanups){for(let r=t.cleanups.length-1;r>=0;r--)t.cleanups[r]();t.cleanups=null}e&&(t.disposed=!0)}}function D(t){s.hostSchedule=t??(e=>{Promise.resolve().then(e)})}function W(t){t.queued||(t.queued=!0,s.queue.push(t),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(A)))}function A(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let t=0;try{for(;s.queue.length;){if(++t>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=s.queue;s.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{s.flushing=!1}}function U(){s.batchDepth===0&&A()}var x=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=z(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{O(this.owner,!1),S(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new T(()=>W(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&s.onSuspend){s.onSuspend(e,this.owner);return}if(s.onError&&s.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),O(this.owner))}};function R(t){let e=new x(t);return()=>e.dispose()}function Y(t){return!!t&&typeof t.then=="function"}D(()=>{});var q=Symbol.for("signal"),$=Symbol.for("memo"),J=Symbol.for("signal-node");function g(t,e){let r=new b(t,{equals:e?.equals}),n=(()=>r.get()),o=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),U(),u});return Object.defineProperty(n,q,{value:!0,enumerable:!0}),Object.defineProperty(n,J,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function c(t,e,r){let n=e,o=E(),i=new l(()=>S(o,()=>{try{return n=t(n)}catch(p){if(Y(p))return C(p),n;throw p}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,q,{value:!0,enumerable:!0}),Object.defineProperty(u,$,{value:!0,enumerable:!0}),u}function M(t,e){let r=e;return R(()=>{r=t(r)})}function _(t){return typeof t=="function"&&!/^class\s/.test(Function.prototype.toString.call(t))}function B(t){return t==null||Array.isArray(t)||typeof t=="function"||t instanceof Date||t instanceof RegExp||t instanceof Map||t instanceof Set||t instanceof Error?!1:typeof t=="object"}var f=class t{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 t)e.remove(this);else if(e!==null)for(let n of e)n.remove(this);if(r){for(let n of r)if(_(n)&&!(n instanceof t))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(B(n)&&typeof n.unsubscribe=="function")try{n.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:n}=this;if(r){if(_(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 n||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof t&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(e);n!==-1&&(r.splice(n,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 n=r.indexOf(e);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var v=class extends f{constructor(r,n,o){super();this.isStopped=!1;let i;r?typeof r=="object"?i=r:i={next:r,error:n,complete:o}:i={},this.destination=i}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())}},F=class extends v{constructor(r,n,o,i){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||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)}};var y=class extends f{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,n){let o;e instanceof v?o=e:o=new F(e,r,n);let{_subscribe:i}=this;try{let u=i.call(this,o);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&o.add(u)}catch(u){o.error(u)}return o}pipe(...e){return e.length===0?this:e.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((e,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>e(n)})})}};function Q(t,e,r){return c(()=>e(t()),void 0,r)}function X(t,e,r){return c(()=>t().filter(e),void 0,r)}function Z(t,e,r,n){return c(()=>t().reduce(e,r),void 0,n)}function ee(t,e,r){return c(()=>t().find(e),void 0,r)}function re(t,e,r){return c(()=>t().some(e),void 0,r)}function te(t,e,r){return c(()=>t().every(e),void 0,r)}function ne(t,e,r){return c(()=>[...t()].sort(e),void 0,r)}function oe(t,e){return c(()=>[...new Set(t())],void 0,e)}function se(t,e,r){return c(()=>{let n=t.map(o=>o());return e(n)},void 0,r)}function ie(...t){return new y(e=>{let r=()=>t.map(o=>typeof o=="function"?o():o.get()),n=t.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):M(()=>{e.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ue(t,e,r){return c(()=>t()||e(),void 0,r)}function ce(t,e,r,n){return c(()=>r(t(),e()),void 0,n)}function ae(t,e,r){return c(()=>e(t()),void 0,{equals:r,internal:!0})}function pe(t,e,r){return c(()=>{let n=t(),o={};for(let i of e)o[i]=n[i];return o},void 0,r)}function le(t,e,r){return c(()=>{let o={...t()};for(let i of e)delete o[i];return o},void 0,r)}function de(t,e,r,n){return c(()=>t()?e():r(),void 0,n)}function fe(t,e,r){return c(()=>t()?e():void 0,void 0,r)}function he(t,e,r){let[n,o]=g(t()),i;return c(()=>{let u=t();clearTimeout(i),i=setTimeout(()=>o(()=>u),e)}),n}function be(t,e,r){let[n,o]=g(t()),i=0,u;return c(()=>{let p=t(),a=Date.now();a-i>=e?(i=a,o(()=>p)):(clearTimeout(u),u=setTimeout(()=>{i=Date.now(),o(()=>p)},e-(a-i)))}),n}function Te(t){let e=t;for(;typeof e=="function";)e=e();return e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var M="__fluixi_signal_next_state__",B=t=>{typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)},s=globalThis[M]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:B,onSuspend:null,onError:null};var _=0,F=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let e=s.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},b=class extends h{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(d);w(this)}}peek(){return this._value}},l=class extends h{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===F&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=_}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let r=s.consumer,n=s.untracked;s.consumer=this,s.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{s.consumer=r,s.untracked=n}let p=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,p){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(d);w(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===_;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(F);w(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function w(t){if(t.watchers)for(let e of[...t.watchers])e._notify(t)}var T=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function I(t){return{cleanups:null,owned:null,parent:t,contexts:null}}function k(t){return s.onSuspend?(s.onSuspend(t,s.owner),!0):!1}function C(){return s.owner}function x(t,e){let r=s.owner;s.owner=t;try{return e()}finally{s.owner=r}}function O(t,e=!0){if(!t.disposed){if(t.owned){for(let r=t.owned.length-1;r>=0;r--)O(t.owned[r]);t.owned=null}if(t.cleanups){for(let r=t.cleanups.length-1;r>=0;r--)t.cleanups[r]();t.cleanups=null}e&&(t.disposed=!0)}}function P(t){s.hostSchedule=t??(e=>{Promise.resolve().then(e)})}function K(t){t.queued||(t.queued=!0,s.queue.push(t),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(S)))}function S(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let t=0;try{for(;s.queue.length;){if(++t>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=s.queue;s.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{s.flushing=!1}}function U(){s.batchDepth===0&&S()}var m=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=I(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{O(this.owner,!1),x(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new T(()=>K(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&s.onSuspend){s.onSuspend(e,this.owner);return}if(s.onError&&s.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),O(this.owner))}};function D(t){let e=new m(t);return()=>e.dispose()}function G(t){return!!t&&typeof t.then=="function"}P(()=>{});var E=Symbol.for("signal"),V=Symbol.for("memo"),j=Symbol.for("signal-node");function A(t,e){let r=new b(t,{equals:e?.equals}),n=(()=>r.get()),o=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),U(),u});return Object.defineProperty(n,E,{value:!0,enumerable:!0}),Object.defineProperty(n,j,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function c(t,e,r){let n=e,o=C(),i=new l(()=>x(o,()=>{try{return n=t(n)}catch(p){if(G(p))return k(p),n;throw p}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,E,{value:!0,enumerable:!0}),Object.defineProperty(u,V,{value:!0,enumerable:!0}),u}function R(t,e){let r=e;return D(()=>{r=t(r)})}import{isObject as H}from"@fluixi/utils/object";import{isFunction as q}from"@fluixi/utils/functions";var f=class t{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 t)e.remove(this);else if(e!==null)for(let n of e)n.remove(this);if(r){for(let n of r)if(q(n)&&!(n instanceof t))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(H(n)&&typeof n.unsubscribe=="function")try{n.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:n}=this;if(r){if(q(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 n||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof t&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(e);n!==-1&&(r.splice(n,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 n=r.indexOf(e);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var v=class extends f{constructor(r,n,o){super();this.isStopped=!1;let i;r?typeof r=="object"?i=r:i={next:r,error:n,complete:o}:i={},this.destination=i}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())}},g=class extends v{constructor(r,n,o,i){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||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)}};var y=class extends f{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,n){let o;e instanceof v?o=e:o=new g(e,r,n);let{_subscribe:i}=this;try{let u=i.call(this,o);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&o.add(u)}catch(u){o.error(u)}return o}pipe(...e){return e.length===0?this:e.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((e,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>e(n)})})}};function ce(t,e,r){return c(()=>e(t()),void 0,r)}function ae(t,e,r){return c(()=>t().filter(e),void 0,r)}function pe(t,e,r,n){return c(()=>t().reduce(e,r),void 0,n)}function le(t,e,r){return c(()=>t().find(e),void 0,r)}function de(t,e,r){return c(()=>t().some(e),void 0,r)}function fe(t,e,r){return c(()=>t().every(e),void 0,r)}function he(t,e,r){return c(()=>[...t()].sort(e),void 0,r)}function be(t,e){return c(()=>[...new Set(t())],void 0,e)}function Te(t,e,r){return c(()=>{let n=t.map(o=>o());return e(n)},void 0,r)}function ve(...t){return new y(e=>{let r=()=>t.map(o=>typeof o=="function"?o():o.get()),n=t.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):R(()=>{e.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ye(t,e,r){return c(()=>t()||e(),void 0,r)}function we(t,e,r,n){return c(()=>r(t(),e()),void 0,n)}function Oe(t,e,r){return c(()=>e(t()),void 0,{equals:r,internal:!0})}function me(t,e,r){return c(()=>{let n=t(),o={};for(let i of e)o[i]=n[i];return o},void 0,r)}function xe(t,e,r){return c(()=>{let o={...t()};for(let i of e)delete o[i];return o},void 0,r)}function Se(t,e,r,n){return c(()=>t()?e():r(),void 0,n)}function Ae(t,e,r){return c(()=>t()?e():void 0,void 0,r)}function ge(t,e,r){let[n,o]=A(t()),i;return c(()=>{let u=t();clearTimeout(i),i=setTimeout(()=>o(()=>u),e)}),n}function _e(t,e,r){let[n,o]=A(t()),i=0,u;return c(()=>{let p=t(),a=Date.now();a-i>=e?(i=a,o(()=>p)):(clearTimeout(u),u=setTimeout(()=>{i=Date.now(),o(()=>p)},e-(a-i)))}),n}function Fe(t){let e=t;for(;typeof e=="function";)e=e();return e}export{Te as combineSignal,ve as combineSignals,ge as debounceSignal,be as distinctSignal,fe as everySignal,ae as filterSignal,le as findSignal,Ae as guardSignal,ce as mapSignal,ye as mergeSignal,xe as omitSignal,me as pickSignal,Fe as readSignal,pe as reduceSignal,Oe as selectSignal,de as someSignal,he as sortSignal,_e as throttleSignal,Se as whenSignal,we as zipSignal};
|
|
1
|
+
var B="__fluixi_signal_next_state__",I=t=>{typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)},s=globalThis[B]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:I,onSuspend:null,onError:null};var F=0,k=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let e=s.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},b=class extends h{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(d);w(this)}}peek(){return this._value}},l=class extends h{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===k&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let r=s.consumer,n=s.untracked;s.consumer=this,s.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{s.consumer=r,s.untracked=n}let p=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,p){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(d);w(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===F;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(k);w(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function w(t){if(t.watchers)for(let e of[...t.watchers])e._notify(t)}var T=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function K(t){return{cleanups:null,owned:null,parent:t,contexts:null}}function P(t){return s.onSuspend?(s.onSuspend(t,s.owner),!0):!1}function C(){return s.owner}function x(t,e){let r=s.owner;s.owner=t;try{return e()}finally{s.owner=r}}function m(t,e=!0){if(!t.disposed){if(t.owned){for(let r=t.owned.length-1;r>=0;r--)m(t.owned[r]);t.owned=null}if(t.cleanups){for(let r=t.cleanups.length-1;r>=0;r--)t.cleanups[r]();t.cleanups=null}e&&(t.disposed=!0)}}function E(t){s.hostSchedule=t??(e=>{Promise.resolve().then(e)})}function G(t){t.queued||(t.queued=!0,s.queue.push(t),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(S)))}function S(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let t=0;try{for(;s.queue.length;){if(++t>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=s.queue;s.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{s.flushing=!1}}function D(){s.batchDepth===0&&S()}var O=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=K(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{m(this.owner,!1),x(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new T(()=>G(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&s.onSuspend){s.onSuspend(e,this.owner);return}if(s.onError&&s.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),m(this.owner))}};function U(t){let e=new O(t);return()=>e.dispose()}function j(t){return!!t&&typeof t.then=="function"}E(()=>{});var R=Symbol.for("signal"),V=Symbol.for("memo"),H=Symbol.for("signal-node");function A(t,e){let r=new b(t,{equals:e?.equals}),n=(()=>r.get()),o=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),D(),u});return Object.defineProperty(n,R,{value:!0,enumerable:!0}),Object.defineProperty(n,H,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function c(t,e,r){let n=e,o=C(),i=new l(()=>x(o,()=>{try{return n=t(n)}catch(p){if(j(p))return P(p),n;throw p}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,R,{value:!0,enumerable:!0}),Object.defineProperty(u,V,{value:!0,enumerable:!0}),u}function q(t,e){let r=e;return U(()=>{r=t(r)})}function g(t){return typeof t=="function"&&!/^class\s/.test(Function.prototype.toString.call(t))}function M(t){return t==null||Array.isArray(t)||typeof t=="function"||t instanceof Date||t instanceof RegExp||t instanceof Map||t instanceof Set||t instanceof Error?!1:typeof t=="object"}var f=class t{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 t)e.remove(this);else if(e!==null)for(let n of e)n.remove(this);if(r){for(let n of r)if(g(n)&&!(n instanceof t))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(M(n)&&typeof n.unsubscribe=="function")try{n.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:n}=this;if(r){if(g(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 n||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof t&&e._addParent(this),this}remove(e){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(e);n!==-1&&(r.splice(n,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 n=r.indexOf(e);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var v=class extends f{constructor(r,n,o){super();this.isStopped=!1;let i;r?typeof r=="object"?i=r:i={next:r,error:n,complete:o}:i={},this.destination=i}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())}},_=class extends v{constructor(r,n,o,i){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||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)}};var y=class extends f{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,n){let o;e instanceof v?o=e:o=new _(e,r,n);let{_subscribe:i}=this;try{let u=i.call(this,o);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&o.add(u)}catch(u){o.error(u)}return o}pipe(...e){return e.length===0?this:e.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((e,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>e(n)})})}};function ce(t,e,r){return c(()=>e(t()),void 0,r)}function ae(t,e,r){return c(()=>t().filter(e),void 0,r)}function pe(t,e,r,n){return c(()=>t().reduce(e,r),void 0,n)}function le(t,e,r){return c(()=>t().find(e),void 0,r)}function de(t,e,r){return c(()=>t().some(e),void 0,r)}function fe(t,e,r){return c(()=>t().every(e),void 0,r)}function he(t,e,r){return c(()=>[...t()].sort(e),void 0,r)}function be(t,e){return c(()=>[...new Set(t())],void 0,e)}function Te(t,e,r){return c(()=>{let n=t.map(o=>o());return e(n)},void 0,r)}function ve(...t){return new y(e=>{let r=()=>t.map(o=>typeof o=="function"?o():o.get()),n=t.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):q(()=>{e.next(r())}));return()=>{n.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function ye(t,e,r){return c(()=>t()||e(),void 0,r)}function we(t,e,r,n){return c(()=>r(t(),e()),void 0,n)}function me(t,e,r){return c(()=>e(t()),void 0,{equals:r,internal:!0})}function Oe(t,e,r){return c(()=>{let n=t(),o={};for(let i of e)o[i]=n[i];return o},void 0,r)}function xe(t,e,r){return c(()=>{let o={...t()};for(let i of e)delete o[i];return o},void 0,r)}function Se(t,e,r,n){return c(()=>t()?e():r(),void 0,n)}function Ae(t,e,r){return c(()=>t()?e():void 0,void 0,r)}function ge(t,e,r){let[n,o]=A(t()),i;return c(()=>{let u=t();clearTimeout(i),i=setTimeout(()=>o(()=>u),e)}),n}function _e(t,e,r){let[n,o]=A(t()),i=0,u;return c(()=>{let p=t(),a=Date.now();a-i>=e?(i=a,o(()=>p)):(clearTimeout(u),u=setTimeout(()=>{i=Date.now(),o(()=>p)},e-(a-i)))}),n}function Fe(t){let e=t;for(;typeof e=="function";)e=e();return e}export{Te as combineSignal,ve as combineSignals,ge as debounceSignal,be as distinctSignal,fe as everySignal,ae as filterSignal,le as findSignal,Ae as guardSignal,ce as mapSignal,ye as mergeSignal,xe as omitSignal,Oe as pickSignal,Fe as readSignal,pe as reduceSignal,me as selectSignal,de as someSignal,he as sortSignal,_e as throttleSignal,Se as whenSignal,we as zipSignal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetAtPath } from '@fluixi/utils/object';
|
|
1
|
+
import type { GetAtPath } from '@fluixi/utils/object';
|
|
2
2
|
export type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | Function;
|
|
3
3
|
export type AnyObject = Record<string, any>;
|
|
4
4
|
export type Callback<T> = (prev: T) => T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setter.types.d.ts","sourceRoot":"","sources":["../../../src/lib/store/setter.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"setter.types.d.ts","sourceRoot":"","sources":["../../../src/lib/store/setter.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,GACT,IAAI,GACJ,QAAQ,CAAC;AAEb,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAMD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAI9C,KAAK,YAAY,CAAC,CAAC,IAAI,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defineProperty;var d=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var T=(o,e)=>{for(var r in e)a(o,r,{get:e[r],enumerable:!0})},y=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!O.call(o,i)&&i!==r&&a(o,i,{get:()=>e[i],enumerable:!(t=d(e,i))||t.enumerable});return o};var F=o=>y(a({},"__esModule",{value:!0}),o);var S={};T(S,{Subject:()=>f});module.exports=F(S);function b(o){return typeof o=="function"&&!/^class\s/.test(Function.prototype.toString.call(o))}function h(o){return o==null||Array.isArray(o)||typeof o=="function"||o instanceof Date||o instanceof RegExp||o instanceof Map||o instanceof Set||o instanceof Error?!1:typeof o=="object"}var p=class o{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 o)e.remove(this);else if(e!==null)for(let t of e)t.remove(this);if(r){for(let t of r)if(b(t)&&!(t instanceof o))try{t()}catch(i){console.error("Error in unsubscribe function:",i)}else if(h(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(i){console.error("Error unsubscribing child:",i)}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(b(e))try{e()}catch(i){console.error("Error in unsubscribe function:",i)}else if(e.unsubscribe)try{e.unsubscribe()}catch(i){console.error("Error unsubscribing:",i)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof o&&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,i){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:t,complete:i}:s={},this.destination=s}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())}},l=class extends u{constructor(r,t,i,s){super(r,t,i);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||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)}};var c=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 i;e instanceof u?i=e:i=new l(e,r,t);let{_subscribe:s}=this;try{let n=s.call(this,i);n&&(typeof n=="function"||typeof n.unsubscribe=="function")&&i.add(n)}catch(n){i.error(n)}return i}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:i=>t=i,error:r,complete:()=>e(t)})})}};var f=class extends c{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 t=this.observers.indexOf(r);t!==-1&&this.observers.splice(t,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:t}=this,i=t.length,s=t.slice();for(let n=0;n<i;n++)s[n].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:t}=this;this.observers=[];let i=t.length,s=t.slice();for(let n=0;n<i;n++)s[n].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let t=r.length,i=r.slice();for(let s=0;s<t;s++)i[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new c(t=>this.subscribe(t))}};
|
package/dist/lib/subject.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a(o){return typeof o=="function"&&!/^class\s/.test(Function.prototype.toString.call(o))}function l(o){return o==null||Array.isArray(o)||typeof o=="function"||o instanceof Date||o instanceof RegExp||o instanceof Map||o instanceof Set||o instanceof Error?!1:typeof o=="object"}var p=class o{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 o)t.remove(this);else if(t!==null)for(let e of t)e.remove(this);if(r){for(let e of r)if(a(e)&&!(e instanceof o))try{e()}catch(i){console.error("Error in unsubscribe function:",i)}else if(l(e)&&typeof e.unsubscribe=="function")try{e.unsubscribe()}catch(i){console.error("Error unsubscribing child:",i)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:e}=this;if(r){if(a(t))try{t()}catch(i){console.error("Error in unsubscribe function:",i)}else if(t.unsubscribe)try{t.unsubscribe()}catch(i){console.error("Error unsubscribing:",i)}return this}return e||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof o&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let e=r.indexOf(t);e!==-1&&(r.splice(e,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 e=r.indexOf(t);e!==-1&&(r.splice(e,1),r.length===1&&(this._parentOrParents=r[0]))}}};var u=class extends p{constructor(r,e,i){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:e,complete:i}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(e){this.error(e)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(e){throw e}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())}},b=class extends u{constructor(r,e,i,s){super(r,e,i);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(e){this.error(e)}}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)}};var c=class extends p{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,e){let i;t instanceof u?i=t:i=new b(t,r,e);let{_subscribe:s}=this;try{let n=s.call(this,i);n&&(typeof n=="function"||typeof n.unsubscribe=="function")&&i.add(n)}catch(n){i.error(n)}return i}pipe(...t){return t.length===0?this:t.reduce((r,e)=>e(r),this)}toPromise(){return new Promise((t,r)=>{let e;this.subscribe({next:i=>e=i,error:r,complete:()=>t(e)})})}};var f=class extends c{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 e=this.observers.indexOf(r);e!==-1&&this.observers.splice(e,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:e}=this,i=e.length,s=e.slice();for(let n=0;n<i;n++)s[n].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:e}=this;this.observers=[];let i=e.length,s=e.slice();for(let n=0;n<i;n++)s[n].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let e=r.length,i=r.slice();for(let s=0;s<e;s++)i[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new c(e=>this.subscribe(e))}};export{f as Subject};
|