@fluixi/reactive 1.0.0-alpha.82 → 1.0.0-alpha.83
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/README.md +4 -0
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +1 -1
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +1 -1
- package/dist/lib/signal/api.mjs +1 -1
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/children.cjs +1 -1
- package/dist/lib/signal/graph/children.mjs +1 -1
- package/dist/lib/signal/graph/compat.cjs +1 -1
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +19 -2
- package/dist/lib/signal/graph/compat.mjs +1 -1
- package/dist/lib/signal/graph/core.cjs +1 -1
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +7 -0
- package/dist/lib/signal/graph/core.mjs +1 -1
- package/dist/lib/signal/graph/debounced.cjs +1 -1
- package/dist/lib/signal/graph/debounced.mjs +1 -1
- package/dist/lib/signal/graph/derived.cjs +1 -1
- package/dist/lib/signal/graph/derived.mjs +1 -1
- package/dist/lib/signal/graph/error-boundary.cjs +1 -1
- package/dist/lib/signal/graph/error-boundary.mjs +1 -1
- package/dist/lib/signal/graph/index.cjs +1 -1
- package/dist/lib/signal/graph/index.mjs +1 -1
- package/dist/lib/signal/graph/observe.cjs +1 -0
- package/dist/lib/signal/graph/observe.d.ts +141 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -0
- package/dist/lib/signal/graph/observe.js +149 -0
- package/dist/lib/signal/graph/observe.mjs +1 -0
- package/dist/lib/signal/graph/resource.cjs +1 -1
- package/dist/lib/signal/graph/resource.mjs +1 -1
- package/dist/lib/signal/graph/runtime.cjs +1 -1
- package/dist/lib/signal/graph/runtime.d.ts +2 -2
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +22 -7
- package/dist/lib/signal/graph/runtime.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +1 -1
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.d.ts +2 -0
- package/dist/lib/signal/graph/state.d.ts.map +1 -1
- package/dist/lib/signal/graph/state.js +1 -0
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +1 -1
- package/dist/lib/signal/graph/suspense.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.d.ts +2 -0
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +2 -0
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/list.cjs +1 -1
- package/dist/lib/signal/list.js +5 -5
- package/dist/lib/signal/list.mjs +1 -1
- package/dist/lib/signal/resource-api.cjs +1 -1
- package/dist/lib/signal/resource-api.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -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/api.cjs +1 -1
- package/dist/lib/store/api.mjs +1 -1
- package/dist/lib/store/index.cjs +1 -1
- package/dist/lib/store/index.mjs +1 -1
- package/dist/lib/store/store.cjs +1 -1
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +148 -8
- package/dist/lib/store/store.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
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 vn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ee=typeof process>"u"?vn:!1,Tn=Symbol.for("signal"),bn=Symbol.for("memo"),yn=Symbol.for("resource");function ne(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[yn]===!0}function xn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function gn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Sn(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 On="__fluixi_signal_next_state__",Cn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[On]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Cn,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 _n(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=_n(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 An(e){return!!e&&typeof e.then=="function"}Ve(()=>{});var ze=Symbol.for("signal"),Fn=Symbol.for("memo"),En=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,En,{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(An(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,Fn,{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 Pn(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 ee?ie(()=>ue(n()),void 0,{name:"children"}):ie(()=>ue(n()))}var ge=null;function Dn(e){ge=e}function Ke(e){ge&&ge(e)}var Se=null;function qn(e){Se=e}function Xe(e){return Se?Se(e):void 0}var Oe=null;function Un(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 Pe=Symbol.for("signal"),In=Symbol.for("memo"),Mn=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,Ln=!1,_e=!1,G=0,Bn=1e6,m=new WeakMap,g=null;var jn=null,Gn=new Map,Vn=0,Re={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function Bt(e){u=e,Re.owner=e,Re.context=e}function jt(){return Re}function $n(){return`node_${++Vn}_${Date.now()}`}function Wn(e){ee&&Gn.set(e.id,new WeakRef(e))}function rn(e,n,t){let o={id:$n(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Wn(o),o}function on(e,n){return e===n}function ke(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 k=m.get(r);if(k&&k.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,Ln&&(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),_=>D(_,!0))}}};var x=D;let S=Array.from(k),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,Pe,{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&&P(T);return r&&(o.suspense=r),De(o,n),()=>N(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++)N(e.owned[r]);e.owned=null}let t=d,o=u;if(d=e,u=e,le++,le>Bn)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&&P(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}ke(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++)N(e.owned[n]);e.owned=null}e.renderEffect?fn(e):De(e,e.value)}}function N(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++)N(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 zn(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++)N(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 k=s,S=m.get(k);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 _=m.get(v.accessor);if(_&&_.size>0)for(let V of Array.from(_))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&&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}ke(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,Pe,{value:!0,enumerable:!0}),Object.defineProperty(s,In,{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 R(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(!_e){_e=!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{_e=!1}}}function Hn(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++)N(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 Yn(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}),[k,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(),_=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){_=O,R(()=>{w("unresolved"),h(void 0),S(void 0)});return}let L=V;if(V=!1,_!==O&&y===_&&!L)return;if(_=y,p){p=!1;return}let B=!1;Ee(()=>B=!0);let Ne=K(C),hn=K(b),Ie=Ne==="ready"||Ne==="refreshing";R(()=>{w(Ie?"refreshing":"pending"),S(void 0)});try{let U=r(y,{value:hn,refetching:Ie});if($(U)){h(U),Ke(U),U.then(I=>{B||(c!==void 0&&Qe(c,I),R(()=>{x(()=>I),dn(I),w("ready"),h(void 0)}))},I=>{B||R(()=>{S(I),w("errored"),h(void 0)})}).catch(I=>{B||R(()=>{S(I),w("errored"),h(void 0)})});let fe=T&&P(T);fe&&(fe.increment(),U.finally(()=>fe.decrement()))}else{if(B)return;R(()=>{x(()=>U),w("ready"),h(void 0)})}}catch(U){if(B)return;R(()=>{S(U),w("errored"),h(void 0)})}});Ee(pn);let Ue=()=>{let y=C();return y==="pending"||y==="refreshing"},Q=(()=>{let y=k();if(y)throw y;if(Ue()){let L=D();if(L)throw L}return b()});return Object.defineProperty(Q,Mn,{value:!0,enumerable:!0}),Object.defineProperty(Q,Pe,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:C},loading:{get:()=>Ue()},error:{get:k},latest:{get:b}}),[Q,{mutate:x,refetch:()=>{V=!0,q(void 0)}}]}function Kn(){return u}function Xn(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=Jn(n);return{id:n,Provider:t,defaultValue:e}}function Jn(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 P(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 Qn(){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&&R(()=>{for(let s of r)s.state=E,J(s)}),n()}),t):(g=null,n(),t)}function Zn(){return sn(),[Ae,ln]}function et(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&&P(T);return r&&(o.suspense=r),fn(o),()=>N(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++)N(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&&P(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}ke(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 nt(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 tt(){return T||(T=qe())}var nn;function rt(){return nn||(nn=qe())}function ot(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=E,J(t)}function st(e){let n=T&&P(T);n&&n.inFallback()?X(()=>{n.inFallback()||e()}):e()}function it(e){jn=e}function ut(e){let n=T&&P(T);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var Vt={createSignal:M,createEffect:X,createMemo:zn,createComputed:nt,createRoot:Hn,createSelector:He,createResource:Yn,batch:R,untrack:K,onCleanup:Ee,getOwner:Kn,runWithOwner:Xn,createContext:qe,useContext:P,flush:Qn,startTransition:ln,useTransition:Zn,isSignal:ne,on:et,createRenderEffect:cn,getSuspenseContext:tt,getSuspenseListContext:rt,resumeEffects:ot,onResolve:st,setScheduler:it,trackPromise:ut};export{In as $MEMO,Ze as $PROXY,Mn as $RESOURCE,Pe as $SIGNAL,ee as __DEV__,R as batch,nt as createComputed,qe as createContext,kn as createDebounce,Pn as createDeferred,X as createEffect,zn as createMemo,Jn as createProvider,cn as createRenderEffect,Yn as createResource,Hn as createRoot,He as createSelector,M as createSignal,Vt as default,Qn as flush,Kn as getOwner,Xe as getServerData,jt as getSharedConfig,tt as getSuspenseContext,rt as getSuspenseListContext,xn as isComponent,mn as isMemo,Sn as isProvider,wn as isResource,ne as isSignal,gn as isSuspense,Le as makeArrayFlat,Je as nextResourceId,et as on,Ee as onCleanup,st as onResolve,Ye as readChildren,Qe as reportResourceData,ot as resumeEffects,Xn as runWithOwner,Bt as setOwner,Nn as setResourceDataSink,Un as setResourceIdSource,Dn as setResourceTracker,it as setScheduler,qn as setServerDataGetter,Re as sharedConfig,ln as startTransition,ut as trackPromise,Ke as trackResourcePromise,K as untrack,P as useContext,Zn as useTransition};
|
|
1
|
+
function he(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ve(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 W(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var $=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(he(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ve(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(he(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 te=class extends ${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())}},be=class extends te{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 ${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 te?r=n:r=new be(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 Rn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,re=typeof process>"u"?Rn:!1,Cn=Symbol.for("signal"),kn=Symbol.for("memo"),_n=Symbol.for("resource");function oe(e){return typeof e=="function"&&e[Cn]===!0}function An(e){return typeof e=="function"&&e[kn]===!0}function Fn(e){return typeof e=="function"&&e[_n]===!0}function En(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Pn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ge(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ge(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var qn="__fluixi_signal_next_state__",Nn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},i=globalThis[qn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Nn,onSuspend:null,onError:null,observer:null};var He="1.0.0-alpha.83";function In(e){return i.observer=e,()=>{i.observer===e&&(i.observer=null)}}var Te=[],Un;function K(e){let n=i.observer;n&&n.created(e.parents===void 0?{...e,parents:Te,origin:e.origin??Un}:e)}function $e(e){return i.observer?(Te.push(e),!0):!1}function ze(){Te.pop()}function Ke(e){i.observer?.ran?.(e)}function Ye(e,n){i.observer?.wrote?.(e,n)}function Y(e){i.observer?.disposed?.(e)}var Mn="__FLUIXI_DEVTOOLS_HOOK__",We=globalThis[Mn];if(typeof We?.inject=="function")try{We.inject({observeReactiveNodes:In,version:He})}catch{}function ye(){return i.observer!=null}var Xe=0,Je=1,X=2,se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(i.untracked)return;let n=i.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},ie=class extends se{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++,Ye(this,i.consumer),this.observers)for(let t of[...this.observers])t.markDirty(X);we(this)}}peek(){return this._value}},j=class extends se{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=X;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(i.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===X)break}(this.state===X||!this._initialized)&&this.recompute(),this.state=Xe}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=i.consumer,o=i.untracked,r=$e(this);i.consumer=this,i.untracked=!1;let s,l=!1,c;try{s=this._fn()}catch(f){l=!0,c=f,s=this._value}finally{i.consumer=t,i.untracked=o,r&&ze()}let v=!this._initialized||this._threw!==l||(l?c!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=l,this._error=c,this._value=s,Ke(this),v){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(X);we(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Xe;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Je);we(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function we(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var ue=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 Ln(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Qe(e){return i.onSuspend?(i.onSuspend(e,i.owner),!0):!1}function ge(){return i.owner}function ae(e,n){let t=i.owner;i.owner=e;try{return n()}finally{i.owner=t}}function V(e){if(i.owner){if(i.owner.disposed){e();return}(i.owner.cleanups??=[]).push(e)}}function me(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)me(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 Ze(e){i.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Bn(e){e.queued||(e.queued=!0,i.queue.push(e),!i.scheduled&&i.batchDepth===0&&(i.scheduled=!0,i.hostSchedule(Se)))}function Se(){if(i.scheduled=!1,i.flushing)return;i.flushing=!0;let e=0;try{for(;i.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=i.queue;i.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{i.flushing=!1}}function en(){i.batchDepth===0&&Se()}var xe=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=Ln(i.owner),i.owner&&(i.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{me(this.owner,!1),ae(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),K({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new ue(()=>Bn(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"&&i.onSuspend){i.onSuspend(n,this.owner);return}if(i.onError&&i.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,Y(this.computed),this.watcher.unwatch(this.computed),me(this.owner))}};function nn(e,n=!1){let t=new xe(e,n);return()=>t.dispose()}function jn(e){return!!e&&typeof e.then=="function"}Ze(()=>{});var tn=Symbol.for("signal"),Vn=Symbol.for("memo"),Gn=Symbol.for("signal-node");function Oe(e,n){let t=new ie(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),en(),l});return Object.defineProperty(o,tn,{value:!0,enumerable:!0}),Object.defineProperty(o,Gn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),K({kind:"signal",node:t,handle:o,name:n?.name,set:r}),ye()&&V(()=>Y(t)),[o,r]}function le(e,n,t){let o=n,r=ge(),s=new j(()=>ae(r,()=>{try{return o=e(o)}catch(c){if(jn(c))return Qe(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,tn,{value:!0,enumerable:!0}),Object.defineProperty(l,Vn,{value:!0,enumerable:!0}),K({kind:"memo",node:s,handle:l,name:t?.name}),ye()&&V(()=>Y(s)),l}function Re(e,n){let t=n;return nn(()=>{t=e(t)},!0)}function rn(e,n=(t,o)=>t===o){let t=new Map;return Re(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,v=n(r,o);l()!==v&&c(v)}}),o=>{let r=t.get(o);if(!r){let[s,l]=Oe(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function Hn(e,n){let[t,o]=Oe(e(),n);return Re(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Wn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return V(()=>{t!==void 0&&clearTimeout(t)}),o}function ce(e){if(typeof e=="function"&&!e.length){let n=e();return oe(n)?n:ce(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ce(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function on(e){let n=le(e);return re?le(()=>ce(n()),void 0,{name:"children"}):le(()=>ce(n()))}var Ce=null;function $n(e){Ce=e}function sn(e){Ce&&Ce(e)}var ke=null;function zn(e){ke=e}function un(e){return ke?ke(e):void 0}var _e=null;function Kn(e){_e=e}function an(){return _e?_e():void 0}var Ae=null;function Yn(e){Ae=e}function ln(e,n){Ae&&Ae(e,n)}var Ne=Symbol.for("signal"),Xn=Symbol.for("memo"),Jn=Symbol.for("resource"),cn=Symbol("fluixi-proxy"),pn=Symbol.for("signal-node"),_=0,J=1,F=2,A=3,a=null,d=null,u=null,fe=null,de=0,Qn=!1,Fe=!1,G=0,Zn=1e6,w=new WeakMap,g=null;var et=null,nt=new Map,tt=0,Ee={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function ar(e){a=e,Ee.owner=e,Ee.context=e}function lr(){return Ee}function rt(){return`node_${++tt}_${Date.now()}`}function ot(e){re&&nt.set(e.id,new WeakRef(e))}function vn(e,n,t){let o={id:rt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return ot(o),o}function hn(e,n){return e===n}function Ie(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var Pe=null,De=null;function bn(){if(!Pe){let[e,n]=M(!1);Pe=e,De=n}}function Tn(e){if(u)u.indexOf(e)===-1&&u.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)ee(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=u;d=null,u=[],e.accessor(),d=n;let o=u;if(u=t,o.length>0){let r=u;pe(o),u=r}}}function fn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function M(e,n){let t=e;typeof t=="object"&&t&&cn in t&&delete t[cn];let o=vn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];w.set(r,new Set);let s;function l(){let v=d;if(v){v.sources?v.sources.indexOf(r)===-1&&v.sources.push(r):v.sources=[r];let f=w.get(r);f&&!f.has(v)&&f.add(v)}return t}function c(v){let f=typeof v=="function"?v(t):v,T=o.equals||hn;if(n?.equals===!1||!T(t,f)){t=f,o.value=f,o.version++,o.updated=Date.now();let P=w.get(r);if(P&&P.size>0){let D=function(p,h=!1){let q=p.state;if(!(q===A&&p===d)){if(h&&!p.pure){q===_&&(p.state=J,Qn&&(u!==null&&u.indexOf(p)===-1?u.push(p):R.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=F,q===_||q===J?R.push(p):!p.pure&&u!==null&&u.indexOf(p)===-1&&u.push(p),p.pure&&p.accessor)){let O=w.get(p.accessor);O&&fn(Array.from(O),C=>D(C,!0))}}};var x=D;let S=Array.from(P),R=[],m=new Set;fn(S,D);for(let p of R)Tn(p)}}}return l.toObservable=()=>new z(v=>{let f=!0;return Z(()=>{let x=l();f?f=!1:v.next(x)})}),Object.defineProperty(l,Ne,{value:!0,enumerable:!0}),Object.defineProperty(l,pn,{value:o,enumerable:!1}),r}function Z(e,n,t){let o={fn:e,state:F,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:a,contexts:null,pure:!1,updatedAt:null};a&&(a.owned?a.owned.push(o):a.owned=[o]);let r=b&&E(b);return r&&(o.suspense=r),Ue(o,n),()=>I(o)}function Ue(e,n){if(e.sources){for(let r of e.sources){let s=w.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let t=d,o=a;if(d=e,a=e,de++,de>Zn)throw de=0,d=t,a=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=A;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===A&&(e.state=_)}catch(r){if(W(r)){let s=b&&E(b);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{d=t,a=o}}function ee(e){if(!(e.disposed||!e.fn||e.state===_)&&(e.state===F||e.state===J||e.state===A)){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++)I(e.owned[n]);e.owned=null}e.renderEffect?xn(e):Ue(e,e.value)}}function I(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=w.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++)I(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 st(e,n,t){let o=vn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:F,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};a&&(a.owned?a.owned.push(r):a.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;w.has(c)||w.set(c,new Set);let v=w.get(c);v&&v.add(d)}if(r.state!==_){if(r.sources){for(let f of r.sources){let T=w.get(f);T&&T.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let f=0;f<r.cleanups.length;f++)r.cleanups[f]();r.cleanups=null}if(r.owned){for(let f=0;f<r.owned.length;f++)I(r.owned[f]);r.owned=null}let c=d,v=a;d=r,a=r,r.state=A;try{let f=r.fn(r.value),T=o.equals||hn;if(t?.equals===!1||!T(r.value,f)){r.value=f,o.value=f,o.version++,o.updated=Date.now();let P=s,S=w.get(P);if(S&&S.size>0){let p=function(h,q=!1){if(h===r)return;let O=h.state;if(O!==A){if(q&&!h.pure){O===_&&(h.state=J,u!==null&&u.indexOf(h)===-1?u.push(h):m.push(h));return}if(!D.has(h)&&(D.add(h),h.state=F,O===_||O===J?m.push(h):!h.pure&&u!==null&&u.indexOf(h)===-1&&u.push(h),h.pure&&h.accessor)){let C=w.get(h.accessor);if(C&&C.size>0)for(let H of Array.from(C))p(H,!0)}}};var l=p;let R=Array.from(S),m=[],D=new Set;for(let h=0;h<R.length;h++)p(R[h]);for(let h of m)Tn(h)}}r.state===A&&(r.state=_)}catch(f){if(W(f)){let T=b&&E(b);if(!T&&b){let x=v;for(;x;){if(x.contexts?.has(b.id)){T=x.contexts.get(b.id);break}x=x.owner}}return T&&(T.increment(),f.finally(()=>T.decrement())),r.value}Ie(f)}finally{d=c,a=v}}return r.value};return r.accessor=s,w.set(s,new Set),s.toObservable=()=>new z(l=>{let c=!0;return Z(()=>{let f=s();c?c=!1:l.next(f)})}),Object.defineProperty(s,Ne,{value:!0,enumerable:!0}),Object.defineProperty(s,Xn,{value:!0,enumerable:!0}),Object.defineProperty(s,pn,{value:o,enumerable:!1}),s}function pe(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);u=[];let o=0;for(;o<n.length;){let r=n[o++],s=w.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=u.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)}u=null;for(let r of t)(r.computed||!r.pure)&&ee(r)}function k(e){if(u&&G>0)return e();if(u&&G===0){let n=u,t=[];u=t,G++;let o;try{o=e()}finally{G--,u=n}let r=u;return pe(t),u=r,o}G++,u=[],fe=[];try{return e()}finally{G--,yn()}}function yn(){if(!Fe){Fe=!0,de=0;try{for(;u&&u.length>0;){let e=u;u=null,pe(e)}if(u=null,fe){let e=fe;fe=null;for(let n=0;n<e.length;n++)ee(e[n])}}finally{Fe=!1}}}function it(e){let n={owned:null,cleanups:null,contexts:null,owner:a},t=d;d=null;let o=a;a=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)I(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{a=o,d=t}}function Q(e){let n=d;d=null;try{return e()}finally{d=n}}function qe(e){a&&(a.cleanups?a.cleanups.push(e):a.cleanups=[e])}function ut(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:an(),v=c!==void 0?un(c):void 0,f=v!==void 0,[T,x]=M(v!==void 0?v.value:t.initialValue,{equals:!1}),[P,S]=M(void 0,{equals:!1}),[R,m]=M(v!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,p]=M(void 0,{equals:!1}),[h,q]=M(void 0,{equals:!1}),O=Symbol(),C=O,H=!1,gn=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)}},Sn=Z(()=>{let y=o?o():e;if(h(),y===!1||y===null||y===void 0){C=O,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let L=H;if(H=!1,C!==O&&y===C&&!L)return;if(C=y,f){f=!1;return}let B=!1;qe(()=>B=!0);let Be=Q(R),On=Q(T),je=Be==="ready"||Be==="refreshing";k(()=>{m(je?"refreshing":"pending"),S(void 0)});try{let N=r(y,{value:On,refetching:je});if(W(N)){p(N),sn(N),N.then(U=>{B||(c!==void 0&&ln(c,U),k(()=>{x(()=>U),gn(U),m("ready"),p(void 0)}))},U=>{B||k(()=>{S(U),m("errored"),p(void 0)})}).catch(U=>{B||k(()=>{S(U),m("errored"),p(void 0)})});let ve=b&&E(b);ve&&(ve.increment(),N.finally(()=>ve.decrement()))}else{if(B)return;k(()=>{x(()=>N),m("ready"),p(void 0)})}}catch(N){if(B)return;k(()=>{S(N),m("errored"),p(void 0)})}});qe(Sn);let Le=()=>{let y=R();return y==="pending"||y==="refreshing"},ne=(()=>{let y=P();if(y)throw y;if(Le()){let L=D();if(L)throw L}return T()});return Object.defineProperty(ne,Jn,{value:!0,enumerable:!0}),Object.defineProperty(ne,Ne,{value:!0,enumerable:!0}),Object.defineProperties(ne,{state:{get:R},loading:{get:()=>Le()},error:{get:P},latest:{get:T}}),[ne,{mutate:x,refetch:()=>{H=!0,q(void 0)}}]}function at(){return a}function lt(e,n){let t=a,o=d;a=e,d=null;try{return n()}finally{a=t,d=o}}function Me(e){let n=Symbol("context"),t=ct(n);return{id:n,Provider:t,defaultValue:e}}function ct(e){return n=>{let t=a;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return mn(()=>{o=Q(()=>{let r=a;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),on(()=>n.children)})}),o}}function E(e){let n=a;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 ft(){return new Promise(e=>{queueMicrotask(()=>{yn(),e()})})}function wn(e){if(g&&g.running)return e(),g.done;bn();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?(De(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,De(!1),r.length&&k(()=>{for(let s of r)s.state=F,ee(s)}),n()}),t):(g=null,n(),t)}function dt(){return bn(),[Pe,wn]}function pt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):Q(()=>n(l,s))}}function mn(e,n,t){let o={fn:e,state:F,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};a&&(a.owned?a.owned.push(o):a.owned=[o]);let r=b&&E(b);return r&&(o.suspense=r),xn(o),()=>I(o)}function xn(e){if(e.sources){for(let r of e.sources){let s=w.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++)I(e.owned[r]);e.owned=null}let n=d,t=a,o=u;d=e,a=e,u===null&&(u=[]),e.state=A;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===A&&(e.state=_)}catch(r){if(W(r)){let s=b&&E(b);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{d=n,a=t;let r=u;if(u=o,r!==o&&r&&r.length>0){let s=u;pe(r),u=s}}}function vt(e,n,t){let o={fn:e,state:F,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:a,contexts:null,pure:!0,computed:!0,updatedAt:null};a&&(a.owned?a.owned.push(o):a.owned=[o]),g&&g.running?(u||(u=[]),u.indexOf(o)===-1&&u.push(o)):u?u.indexOf(o)===-1&&u.push(o):Ue(o,n)}var b;function ht(){return b||(b=Me())}var dn;function bt(){return dn||(dn=Me())}function Tt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=F,ee(t)}function yt(e){let n=b&&E(b);n&&n.inFallback()?Z(()=>{n.inFallback()||e()}):e()}function wt(e){et=e}function mt(e){let n=b&&E(b);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var fr={createSignal:M,createEffect:Z,createMemo:st,createComputed:vt,createRoot:it,createSelector:rn,createResource:ut,batch:k,untrack:Q,onCleanup:qe,getOwner:at,runWithOwner:lt,createContext:Me,useContext:E,flush:ft,startTransition:wn,useTransition:dt,isSignal:oe,on:pt,createRenderEffect:mn,getSuspenseContext:ht,getSuspenseListContext:bt,resumeEffects:Tt,onResolve:yt,setScheduler:wt,trackPromise:mt};export{Xn as $MEMO,cn as $PROXY,Jn as $RESOURCE,Ne as $SIGNAL,re as __DEV__,k as batch,vt as createComputed,Me as createContext,Wn as createDebounce,Hn as createDeferred,Z as createEffect,st as createMemo,ct as createProvider,mn as createRenderEffect,ut as createResource,it as createRoot,rn as createSelector,M as createSignal,fr as default,ft as flush,at as getOwner,un as getServerData,lr as getSharedConfig,ht as getSuspenseContext,bt as getSuspenseListContext,En as isComponent,An as isMemo,Dn as isProvider,Fn as isResource,oe as isSignal,Pn as isSuspense,Ge as makeArrayFlat,an as nextResourceId,pt as on,qe as onCleanup,yt as onResolve,on as readChildren,ln as reportResourceData,Tt as resumeEffects,lt as runWithOwner,ar as setOwner,Yn as setResourceDataSink,Kn as setResourceIdSource,$n as setResourceTracker,wt as setScheduler,zn as setServerDataGetter,Ee as sharedConfig,wn as startTransition,mt as trackPromise,sn as trackResourcePromise,Q as untrack,E as useContext,dt 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 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
|
+
"use strict";var x=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(n,e)=>{for(var r in e)x(n,r,{get:e[r],enumerable:!0})},ee=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J(e))!Q.call(n,o)&&o!==r&&x(n,o,{get:()=>e[o],enumerable:!(t=X(e,o))||t.enumerable});return n};var re=n=>ee(x({},"__esModule",{value:!0}),n);var Pe={};Z(Pe,{combineSignal:()=>ye,combineSignals:()=>Oe,debounceSignal:()=>Fe,distinctSignal:()=>me,everySignal:()=>Te,filterSignal:()=>fe,findSignal:()=>be,guardSignal:()=>Re,mapSignal:()=>de,mergeSignal:()=>xe,omitSignal:()=>Ae,pickSignal:()=>ke,readSignal:()=>De,reduceSignal:()=>ve,selectSignal:()=>Se,someSignal:()=>he,sortSignal:()=>we,throttleSignal:()=>Ce,whenSignal:()=>_e,zipSignal:()=>ge});module.exports=re(Pe);var ne="__fluixi_signal_next_state__",te=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},i=globalThis[ne]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:te,onSuspend:null,onError:null,observer:null};var U="1.0.0-alpha.83";function oe(n){return i.observer=n,()=>{i.observer===n&&(i.observer=null)}}var g=[],ie;function f(n){let e=i.observer;e&&e.created(n.parents===void 0?{...n,parents:g,origin:n.origin??ie}:n)}function M(n){return i.observer?(g.push(n),!0):!1}function B(){g.pop()}function I(n){i.observer?.ran?.(n)}function N(n,e){i.observer?.wrote?.(n,e)}function v(n){i.observer?.disposed?.(n)}var se="__FLUIXI_DEVTOOLS_HOOK__",q=globalThis[se];if(typeof q?.inject=="function")try{q.inject({observeReactiveNodes:oe,version:U})}catch{}function S(){return i.observer!=null}var K=0,j=1,b=2,T=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(i.untracked)return;let e=i.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},w=class extends T{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++,N(this,i.consumer),this.observers)for(let r of[...this.observers])r.markDirty(b);k(this)}}peek(){return this._value}},p=class extends T{constructor(r,t){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){if(i.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===j&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=K}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let r=i.consumer,t=i.untracked,o=M(this);i.consumer=this,i.untracked=!1;let s,u=!1,c;try{s=this._fn()}catch(d){u=!0,c=d,s=this._value}finally{i.consumer=r,i.untracked=t,o&&B()}let l=!this._initialized||this._threw!==u||(u?c!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=c,this._value=s,I(this),l){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(b);k(this)}}markDirty(r){if(this.state>=r)return;let t=this.state===K;if(this.state=r,t){if(this.observers)for(let o of[...this.observers])o.markDirty(j);k(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function k(n){if(n.watchers)for(let e of[...n.watchers])e._notify(n)}var m=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 ue(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function G(n){return i.onSuspend?(i.onSuspend(n,i.owner),!0):!1}function V(){return i.owner}function R(n,e){let r=i.owner;i.owner=n;try{return e()}finally{i.owner=r}}function F(n){if(i.owner){if(i.owner.disposed){n();return}(i.owner.cleanups??=[]).push(n)}}function A(n,e=!0){if(!n.disposed){if(n.owned){for(let r=n.owned.length-1;r>=0;r--)A(n.owned[r]);n.owned=null}if(n.cleanups){for(let r=n.cleanups.length-1;r>=0;r--)n.cleanups[r]();n.cleanups=null}e&&(n.disposed=!0)}}function H(n){i.hostSchedule=n??(e=>{Promise.resolve().then(e)})}function ae(n){n.queued||(n.queued=!0,i.queue.push(n),!i.scheduled&&i.batchDepth===0&&(i.scheduled=!0,i.hostSchedule(C)))}function C(){if(i.scheduled=!1,i.flushing)return;i.flushing=!0;let n=0;try{for(;i.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=i.queue;i.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{i.flushing=!1}}function L(){i.batchDepth===0&&C()}var _=class{constructor(e,r=!1){this.queued=!1;this.disposed=!1;this.owner=ue(i.owner),i.owner&&(i.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new p(()=>{A(this.owner,!1),R(this.owner,()=>{let t=e();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),f({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new m(()=>ae(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"&&i.onSuspend){i.onSuspend(e,this.owner);return}if(i.onError&&i.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,v(this.computed),this.watcher.unwatch(this.computed),A(this.owner))}};function W(n,e=!1){let r=new _(n,e);return()=>r.dispose()}function ce(n){return!!n&&typeof n.then=="function"}H(()=>{});var z=Symbol.for("signal"),pe=Symbol.for("memo"),le=Symbol.for("signal-node");function D(n,e){let r=new w(n,{equals:e?.equals}),t=(()=>r.get()),o=(s=>{let u=typeof s=="function"?s(r.peek()):s;return r.set(u),L(),u});return Object.defineProperty(t,z,{value:!0,enumerable:!0}),Object.defineProperty(t,le,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),f({kind:"signal",node:r,handle:t,name:e?.name,set:o}),S()&&F(()=>v(r)),[t,o]}function a(n,e,r){let t=e,o=V(),s=new p(()=>R(o,()=>{try{return t=n(t)}catch(c){if(ce(c))return G(c),t;throw c}}),{equals:r?.equals}),u=(()=>s.get());return Object.defineProperty(u,z,{value:!0,enumerable:!0}),Object.defineProperty(u,pe,{value:!0,enumerable:!0}),f({kind:"memo",node:s,handle:u,name:r?.name}),S()&&F(()=>v(s)),u}function Y(n,e){let r=e;return W(()=>{r=n(r)},!0)}function P(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function $(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}var h=class n{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 n)e.remove(this);else if(e!==null)for(let t of e)t.remove(this);if(r){for(let t of r)if(P(t)&&!(t instanceof n))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if($(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(e){if(!e||e===this)return this;if(e.closed)return this;let{_closed:r,_subscriptions:t}=this;if(r){if(P(e))try{e()}catch(o){console.error("Error in unsubscribe function:",o)}else if(e.unsubscribe)try{e.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof n&&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 y=class extends h{constructor(r,t,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:t,complete:o}: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())}},E=class extends y{constructor(r,t,o,s){super(r,t,o);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 O=class extends h{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,t){let o;e instanceof y?o=e:o=new E(e,r,t);let{_subscribe:s}=this;try{let u=s.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,t)=>t(r),this)}toPromise(){return new Promise((e,r)=>{let t;this.subscribe({next:o=>t=o,error:r,complete:()=>e(t)})})}};function de(n,e,r){return a(()=>e(n()),void 0,r)}function fe(n,e,r){return a(()=>n().filter(e),void 0,r)}function ve(n,e,r,t){return a(()=>n().reduce(e,r),void 0,t)}function be(n,e,r){return a(()=>n().find(e),void 0,r)}function he(n,e,r){return a(()=>n().some(e),void 0,r)}function Te(n,e,r){return a(()=>n().every(e),void 0,r)}function we(n,e,r){return a(()=>[...n()].sort(e),void 0,r)}function me(n,e){return a(()=>[...new Set(n())],void 0,e)}function ye(n,e,r){return a(()=>{let t=n.map(o=>o());return e(t)},void 0,r)}function Oe(...n){return new O(e=>{let r=()=>n.map(o=>typeof o=="function"?o():o.get()),t=n.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):Y(()=>{e.next(r())}));return()=>{t.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function xe(n,e,r){return a(()=>n()||e(),void 0,r)}function ge(n,e,r,t){return a(()=>r(n(),e()),void 0,t)}function Se(n,e,r){return a(()=>e(n()),void 0,{equals:r,internal:!0})}function ke(n,e,r){return a(()=>{let t=n(),o={};for(let s of e)o[s]=t[s];return o},void 0,r)}function Ae(n,e,r){return a(()=>{let o={...n()};for(let s of e)delete o[s];return o},void 0,r)}function _e(n,e,r,t){return a(()=>n()?e():r(),void 0,t)}function Re(n,e,r){return a(()=>n()?e():void 0,void 0,r)}function Fe(n,e,r){let[t,o]=D(n()),s;return a(()=>{let u=n();clearTimeout(s),s=setTimeout(()=>o(()=>u),e)}),t}function Ce(n,e,r){let[t,o]=D(n()),s=0,u;return a(()=>{let c=n(),l=Date.now();l-s>=e?(s=l,o(()=>c)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),o(()=>c)},e-(l-s)))}),t}function De(n){let e=n;for(;typeof e=="function";)e=e();return e}
|
|
@@ -1 +1 @@
|
|
|
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
|
+
var $="__fluixi_signal_next_state__",X=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},i=globalThis[$]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:X,onSuspend:null,onError:null,observer:null};var E="1.0.0-alpha.83";function J(n){return i.observer=n,()=>{i.observer===n&&(i.observer=null)}}var x=[],Q;function f(n){let e=i.observer;e&&e.created(n.parents===void 0?{...n,parents:x,origin:n.origin??Q}:n)}function q(n){return i.observer?(x.push(n),!0):!1}function M(){x.pop()}function B(n){i.observer?.ran?.(n)}function I(n,e){i.observer?.wrote?.(n,e)}function v(n){i.observer?.disposed?.(n)}var Z="__FLUIXI_DEVTOOLS_HOOK__",U=globalThis[Z];if(typeof U?.inject=="function")try{U.inject({observeReactiveNodes:J,version:E})}catch{}function g(){return i.observer!=null}var N=0,K=1,b=2,T=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(i.untracked)return;let e=i.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},w=class extends T{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++,I(this,i.consumer),this.observers)for(let r of[...this.observers])r.markDirty(b);S(this)}}peek(){return this._value}},p=class extends T{constructor(r,t){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){if(i.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===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=N}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let r=i.consumer,t=i.untracked,o=q(this);i.consumer=this,i.untracked=!1;let s,u=!1,c;try{s=this._fn()}catch(d){u=!0,c=d,s=this._value}finally{i.consumer=r,i.untracked=t,o&&M()}let l=!this._initialized||this._threw!==u||(u?c!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=c,this._value=s,B(this),l){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(b);S(this)}}markDirty(r){if(this.state>=r)return;let t=this.state===N;if(this.state=r,t){if(this.observers)for(let o of[...this.observers])o.markDirty(K);S(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function S(n){if(n.watchers)for(let e of[...n.watchers])e._notify(n)}var m=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 ee(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function j(n){return i.onSuspend?(i.onSuspend(n,i.owner),!0):!1}function G(){return i.owner}function _(n,e){let r=i.owner;i.owner=n;try{return e()}finally{i.owner=r}}function R(n){if(i.owner){if(i.owner.disposed){n();return}(i.owner.cleanups??=[]).push(n)}}function k(n,e=!0){if(!n.disposed){if(n.owned){for(let r=n.owned.length-1;r>=0;r--)k(n.owned[r]);n.owned=null}if(n.cleanups){for(let r=n.cleanups.length-1;r>=0;r--)n.cleanups[r]();n.cleanups=null}e&&(n.disposed=!0)}}function V(n){i.hostSchedule=n??(e=>{Promise.resolve().then(e)})}function re(n){n.queued||(n.queued=!0,i.queue.push(n),!i.scheduled&&i.batchDepth===0&&(i.scheduled=!0,i.hostSchedule(F)))}function F(){if(i.scheduled=!1,i.flushing)return;i.flushing=!0;let n=0;try{for(;i.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=i.queue;i.queue=[];for(let r of e)r.queued=!1,r.disposed||r.run()}}finally{i.flushing=!1}}function H(){i.batchDepth===0&&F()}var A=class{constructor(e,r=!1){this.queued=!1;this.disposed=!1;this.owner=ee(i.owner),i.owner&&(i.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new p(()=>{k(this.owner,!1),_(this.owner,()=>{let t=e();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),f({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new m(()=>re(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"&&i.onSuspend){i.onSuspend(e,this.owner);return}if(i.onError&&i.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,v(this.computed),this.watcher.unwatch(this.computed),k(this.owner))}};function L(n,e=!1){let r=new A(n,e);return()=>r.dispose()}function ne(n){return!!n&&typeof n.then=="function"}V(()=>{});var W=Symbol.for("signal"),te=Symbol.for("memo"),oe=Symbol.for("signal-node");function C(n,e){let r=new w(n,{equals:e?.equals}),t=(()=>r.get()),o=(s=>{let u=typeof s=="function"?s(r.peek()):s;return r.set(u),H(),u});return Object.defineProperty(t,W,{value:!0,enumerable:!0}),Object.defineProperty(t,oe,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),f({kind:"signal",node:r,handle:t,name:e?.name,set:o}),g()&&R(()=>v(r)),[t,o]}function a(n,e,r){let t=e,o=G(),s=new p(()=>_(o,()=>{try{return t=n(t)}catch(c){if(ne(c))return j(c),t;throw c}}),{equals:r?.equals}),u=(()=>s.get());return Object.defineProperty(u,W,{value:!0,enumerable:!0}),Object.defineProperty(u,te,{value:!0,enumerable:!0}),f({kind:"memo",node:s,handle:u,name:r?.name}),g()&&R(()=>v(s)),u}function z(n,e){let r=e;return L(()=>{r=n(r)},!0)}function D(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function Y(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}var h=class n{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 n)e.remove(this);else if(e!==null)for(let t of e)t.remove(this);if(r){for(let t of r)if(D(t)&&!(t instanceof n))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(Y(t)&&typeof t.unsubscribe=="function")try{t.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(e){if(!e||e===this)return this;if(e.closed)return this;let{_closed:r,_subscriptions:t}=this;if(r){if(D(e))try{e()}catch(o){console.error("Error in unsubscribe function:",o)}else if(e.unsubscribe)try{e.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return t||(this._subscriptions=[]),this._subscriptions.push(e),e instanceof n&&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 y=class extends h{constructor(r,t,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:t,complete:o}: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())}},P=class extends y{constructor(r,t,o,s){super(r,t,o);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 O=class extends h{constructor(e){if(super(),e)this._subscribe=e;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(e,r,t){let o;e instanceof y?o=e:o=new P(e,r,t);let{_subscribe:s}=this;try{let u=s.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,t)=>t(r),this)}toPromise(){return new Promise((e,r)=>{let t;this.subscribe({next:o=>t=o,error:r,complete:()=>e(t)})})}};function Pe(n,e,r){return a(()=>e(n()),void 0,r)}function Ee(n,e,r){return a(()=>n().filter(e),void 0,r)}function Ue(n,e,r,t){return a(()=>n().reduce(e,r),void 0,t)}function qe(n,e,r){return a(()=>n().find(e),void 0,r)}function Me(n,e,r){return a(()=>n().some(e),void 0,r)}function Be(n,e,r){return a(()=>n().every(e),void 0,r)}function Ie(n,e,r){return a(()=>[...n()].sort(e),void 0,r)}function Ne(n,e){return a(()=>[...new Set(n())],void 0,e)}function Ke(n,e,r){return a(()=>{let t=n.map(o=>o());return e(t)},void 0,r)}function je(...n){return new O(e=>{let r=()=>n.map(o=>typeof o=="function"?o():o.get()),t=n.map(o=>typeof o=="function"&&o.subscribe?o.subscribe(()=>{e.next(r())}):typeof o!="function"?o.subscribe(()=>{e.next(r())}):z(()=>{e.next(r())}));return()=>{t.forEach(o=>{typeof o=="function"?o():o&&typeof o.unsubscribe=="function"&&o.unsubscribe()})}})}function Ge(n,e,r){return a(()=>n()||e(),void 0,r)}function Ve(n,e,r,t){return a(()=>r(n(),e()),void 0,t)}function He(n,e,r){return a(()=>e(n()),void 0,{equals:r,internal:!0})}function Le(n,e,r){return a(()=>{let t=n(),o={};for(let s of e)o[s]=t[s];return o},void 0,r)}function We(n,e,r){return a(()=>{let o={...n()};for(let s of e)delete o[s];return o},void 0,r)}function ze(n,e,r,t){return a(()=>n()?e():r(),void 0,t)}function Ye(n,e,r){return a(()=>n()?e():void 0,void 0,r)}function $e(n,e,r){let[t,o]=C(n()),s;return a(()=>{let u=n();clearTimeout(s),s=setTimeout(()=>o(()=>u),e)}),t}function Xe(n,e,r){let[t,o]=C(n()),s=0,u;return a(()=>{let c=n(),l=Date.now();l-s>=e?(s=l,o(()=>c)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),o(()=>c)},e-(l-s)))}),t}function Je(n){let e=n;for(;typeof e=="function";)e=e();return e}export{Ke as combineSignal,je as combineSignals,$e as debounceSignal,Ne as distinctSignal,Be as everySignal,Ee as filterSignal,qe as findSignal,Ye as guardSignal,Pe as mapSignal,Ge as mergeSignal,We as omitSignal,Le as pickSignal,Je as readSignal,Ue as reduceSignal,He as selectSignal,Me as someSignal,Ie as sortSignal,Xe as throttleSignal,ze as whenSignal,Ve as zipSignal};
|
package/dist/lib/store/api.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(n,e)=>{for(var t in e)R(n,t,{get:e[t],enumerable:!0})},ee=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of J(e))!Q.call(n,r)&&r!==t&&R(n,r,{get:()=>e[r],enumerable:!(o=B(e,r))||o.enumerable});return n};var ne=n=>ee(R({},"__esModule",{value:!0}),n);var ve={};Z(ve,{store:()=>be});module.exports=ne(ve);var c=require("@fluixi/reactive/signal");var te="__fluixi_signal_next_state__",oe=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},f=globalThis[te]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:oe,onSuspend:null,onError:null,observer:null};var U="1.0.0-alpha.83";function re(n){return f.observer=n,()=>{f.observer===n&&(f.observer=null)}}var se=[],m;function K(n,e){if(!f.observer)return e();let t=m;m=n;try{return e()}finally{m=t}}function M(n){let e=f.observer;e&&e.created(n.parents===void 0?{...n,parents:se,origin:n.origin??m}:n)}function k(n,e,t){f.observer?.moved?.(n,e,t)}function j(n){f.observer?.disposed?.(n)}var ie="__FLUIXI_DEVTOOLS_HOOK__",E=globalThis[ie];if(typeof E?.inject=="function")try{E.inject({observeReactiveNodes:re,version:U})}catch{}function A(){return f.observer!=null}var h=Symbol("store-raw"),H=Symbol("store-node"),W=Symbol("store-has"),C=Symbol("store-self"),q=Symbol("store-track");var v=new WeakMap,P=new WeakMap,y=new WeakMap,w=new WeakMap;function ae(n,e){if(!p(n)||!A())return;let t=new Set,o=i=>{if(!(!p(i)||t.has(i))){t.add(i);for(let a of Object.values(i))o(a)}};o(w.get(e)??e);let r=new Set,s=i=>{if(!p(i))return;let a=i;if(t.has(a)||r.has(a))return;r.add(a);let u=v.get(a);if(u){for(let l of u.keys.values())j(l);u.all&&j(u.all),v.delete(a),y.delete(a),P.delete(a)}for(let l of Object.values(a))s(l)};s(n)}var g=(n,e,t)=>t?`${n}[${String(e)}]`:`${n}.${String(e)}`;function X(n,e,t){let o=e?.owner,r=o&&t!==void 0?g(o.name,t,e?.array):void 0,[s,i]=K(o?.store,()=>(0,c.createSignal)(n,r?{name:r}:void 0)),a=s;return a.$=i,a}function S(n){let e=v.get(n);return e?e.owner||(e.owner=y.get(n)):v.set(n,e={keys:new Map,owner:y.get(n),array:Array.isArray(n)}),e}function G(n,e,t){let o=n.keys.get(e);return o||n.keys.set(e,o=X(t,n,e)),o}function ce(n,e,t,o){let r=y.get(n);if(r&&r.store===e&&r.name===t)return;let s={store:e,name:t};y.set(n,s),w.set(n,w.get(o)??o);let i=v.get(n);if(i&&(i.owner=s,!!A())){for(let[a,u]of i.keys)k(u,e,g(t,a,i.array));i.all&&k(i.all,e,g(t,"*",i.array))}}function V(n){let e=S(n);(e.all||(e.all=X(void 0,e,"*")))()}function F(n,e){n.$(typeof e=="function"?()=>e:e)}function p(n){if(n==null||typeof n!="object")return!1;if(Array.isArray(n))return!0;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function T(n){if(!p(n))return n;let e=P.get(n);if(e)return e;let t=new Proxy(n,ue);return P.set(n,t),t}var ue={get(n,e,t){if(e===h||e===H)return n;if(e===c.$PROXY)return t;if(e===W)return u=>u in n;if(e==="__proxy")return!0;if(e===q||e===C)return V(n),t;let o=n[e];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(n,e))return o;let r=Object.getOwnPropertyDescriptor(n,e);if(r&&r.get)return r.get.call(t);let s=S(n),i=G(s,e,o),a=i();return p(a)?(s.owner&&ce(a,i,g(s.owner.name,e,s.array),n),T(a)):a},set(){return!0},deleteProperty(n,e){return e in n&&b(n,e,void 0),!0},has(n,e){return e===h||e===c.$PROXY||e===H||e===W||e===C||e===q?!0:(G(S(n),e,n[e])(),e in n)},ownKeys(n){return V(n),Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,e){return Reflect.getOwnPropertyDescriptor(n,e)}};function z(n,e=new Set){if(n==null||typeof n!="object")return n;let t=n[h]??n;if(e.has(t)||!p(t))return t;e.add(t);let o=!1,r=i=>{let a=z(i,e);return a!==i&&(o=!0),a};if(Array.isArray(t)){let i=t.map(r);return o?i:t}let s={};for(let i of Object.keys(t))s[i]=r(t[i]);return o?s:t}function b(n,e,t){let o=z(t),r=n[e];if(r===o&&(o!==void 0||e in n))return;let s=Array.isArray(n),i=s?n.length:0;o===void 0?delete n[e]:n[e]=o;let a=S(n),u=a.keys.get(e);if(u&&F(u,o),ae(r,n),s&&n.length!==i){let l=a.keys.get("length");l&&F(l,n.length)}a.all&&a.all.$(void 0)}function L(n,e){return typeof n=="function"?n(e):n}function D(n,e){for(let t of Object.keys(e)){let o=e[t],r=n[t];o&&typeof o=="object"&&!Array.isArray(o)&&r&&typeof r=="object"&&!Array.isArray(r)?D(r,o):b(n,t,o)}}function _(n){let e=[],t=n.replace(/\[([^\]]*)\]/g,".$1");for(let o of t.split("."))o.length&&e.push(o);return e}function Y(n,e,t){let o=e.length-1;for(let s=0;s<o;s++){let i=e[s];if(i==="*"){let u=e.slice(s+1);if(Array.isArray(n))for(let l=0;l<n.length;l++)Y(n[l],u,t);return}let a=n[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(e[s+1])?[]:{},b(n,i,a)),n=a}let r=e[o];if(r==="*"){if(Array.isArray(n))for(let s=0;s<n.length;s++)b(n,s,L(t,n[s]));return}b(n,r,L(t,n[r]))}function N(n,e,t){Y(n,_(e),t)}function le(n,e){let t=e[0];if(typeof t=="function"&&e.length===1){let o=t(n);o&&o!==n&&D(n,o);return}if(Array.isArray(t)&&e.length===1){for(let o of t)Array.isArray(o)&&N(n,o[0],o[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&e.length===1){D(n,t);return}if(Array.isArray(e[1])&&e.length>=3){N(n,`${t}.${e[1].join(".")}`,e[2]);return}N(n,String(t),e[1])}function I(n){if(n==null||typeof n!="object")return n;if(Array.isArray(n))return n.map(I);let e={};for(let t of Object.keys(n))e[t]=I(n[t]);return e}function d(n,e){let t=n;for(let o of _(e)){if(t==null)return;t=t[o]}return t}var O=class{constructor(e,t={immutable:!0}){this.options=t;this.root=e,this.set=((...o)=>(0,c.batch)(()=>le(this.root,o))),e&&typeof e=="object"&&(y.set(e,{store:this,name:t.name??"store"}),w.set(e,e)),M({kind:"store",node:this,handle:()=>this.root,name:t.name})}get state(){return T(this.root)}get proxy(){return T(this.root)}get accessor(){return(()=>T(this.root))}unwrap(){return this.root}getNode(e){return this.root&&this.root[e]}get(e){if(e==null||e==="")return x(this.state);let t=this.state;for(let o of _(e)){if(t==null)return;t=t[o]}return x(t)}select(e){return(0,c.createMemo)(()=>e(this.state))}subscribe(e){return(0,c.createEffect)(()=>e(this.state))}watch(e,t){let o;return(0,c.createEffect)(()=>{let r=e(this.state);Object.is(r,o)||(t(r,o),o=r)})}reactive(e){return(0,c.createMemo)(()=>this.state[e])}produce(e){this.set((t=>{let o=I(t);return e(o),o}))}reconcile(e,t={}){this.set(e)}push(e,...t){let o=d(this.root,e);this.set(e,o.concat(t))}pop(e){let t=d(this.root,e).slice(),o=t.pop();return this.set(e,t),o}shift(e){let t=d(this.root,e).slice(),o=t.shift();return this.set(e,t),o}splice(e,t,o,...r){let s=d(this.root,e).slice(),i=s.splice(t,o,...r);return this.set(e,s),i}insert(e,t,o){let r=d(this.root,e).slice();r.splice(t,0,o),this.set(e,r)}removeAt(e,t){let o=d(this.root,e).slice(),r=o.splice(t,1);return this.set(e,o),r}toObservable(){let[e]=(0,c.createSignal)(this.state);return e.toObservable()}dispose(){}},fe=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function de(n,e){for(let t of fe)n[t]=e[t].bind(e);n.$=e.reactive.bind(e)}function $(n,e={immutable:!0}){let t=new O(n,e);return de(t.set,t),[t.proxy,t.set]}function pe(n,e={}){return new O(n,{...e,immutable:!1})}function x(n){if(n==null||typeof n!="object")return n;let e=n[h];return e!==void 0?e:n}function ye(n){return(0,c.untrack)(()=>x(n))}var xe=Object.freeze({createStore:$,createMutableStore:pe,batch:c.batch,unwrap:x,untrackStore:ye});function be(n,e){let[t,o]=$(n,e);return new Proxy(t,{get:(r,s)=>s==="set"?o:r[s],has:(r,s)=>s==="set"||Reflect.has(r,s)})}
|
package/dist/lib/store/api.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$PROXY as
|
|
1
|
+
import{$PROXY as K,batch as z,createEffect as M,createMemo as H,createSignal as Y,untrack as re}from"@fluixi/reactive/signal";var Z="__fluixi_signal_next_state__",ee=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},l=globalThis[Z]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ee,onSuspend:null,onError:null,observer:null};var _="1.0.0-alpha.83";function ne(n){return l.observer=n,()=>{l.observer===n&&(l.observer=null)}}var te=[],v;function U(n,e){if(!l.observer)return e();let t=v;v=n;try{return e()}finally{v=t}}function E(n){let e=l.observer;e&&e.created(n.parents===void 0?{...n,parents:te,origin:n.origin??v}:n)}function x(n,e,t){l.observer?.moved?.(n,e,t)}function R(n){l.observer?.disposed?.(n)}var oe="__FLUIXI_DEVTOOLS_HOOK__",$=globalThis[oe];if(typeof $?.inject=="function")try{$.inject({observeReactiveNodes:ne,version:_})}catch{}function k(){return l.observer!=null}var T=Symbol("store-raw"),W=Symbol("store-node"),C=Symbol("store-has"),q=Symbol("store-self"),G=Symbol("store-track");var b=new WeakMap,A=new WeakMap,p=new WeakMap,h=new WeakMap;function se(n,e){if(!d(n)||!k())return;let t=new Set,o=i=>{if(!(!d(i)||t.has(i))){t.add(i);for(let a of Object.values(i))o(a)}};o(h.get(e)??e);let r=new Set,s=i=>{if(!d(i))return;let a=i;if(t.has(a)||r.has(a))return;r.add(a);let c=b.get(a);if(c){for(let u of c.keys.values())R(u);c.all&&R(c.all),b.delete(a),p.delete(a),A.delete(a)}for(let u of Object.values(a))s(u)};s(n)}var w=(n,e,t)=>t?`${n}[${String(e)}]`:`${n}.${String(e)}`;function B(n,e,t){let o=e?.owner,r=o&&t!==void 0?w(o.name,t,e?.array):void 0,[s,i]=U(o?.store,()=>Y(n,r?{name:r}:void 0)),a=s;return a.$=i,a}function g(n){let e=b.get(n);return e?e.owner||(e.owner=p.get(n)):b.set(n,e={keys:new Map,owner:p.get(n),array:Array.isArray(n)}),e}function V(n,e,t){let o=n.keys.get(e);return o||n.keys.set(e,o=B(t,n,e)),o}function ie(n,e,t,o){let r=p.get(n);if(r&&r.store===e&&r.name===t)return;let s={store:e,name:t};p.set(n,s),h.set(n,h.get(o)??o);let i=b.get(n);if(i&&(i.owner=s,!!k())){for(let[a,c]of i.keys)x(c,e,w(t,a,i.array));i.all&&x(i.all,e,w(t,"*",i.array))}}function F(n){let e=g(n);(e.all||(e.all=B(void 0,e,"*")))()}function L(n,e){n.$(typeof e=="function"?()=>e:e)}function d(n){if(n==null||typeof n!="object")return!1;if(Array.isArray(n))return!0;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function m(n){if(!d(n))return n;let e=A.get(n);if(e)return e;let t=new Proxy(n,ae);return A.set(n,t),t}var ae={get(n,e,t){if(e===T||e===W)return n;if(e===K)return t;if(e===C)return c=>c in n;if(e==="__proxy")return!0;if(e===G||e===q)return F(n),t;let o=n[e];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(n,e))return o;let r=Object.getOwnPropertyDescriptor(n,e);if(r&&r.get)return r.get.call(t);let s=g(n),i=V(s,e,o),a=i();return d(a)?(s.owner&&ie(a,i,w(s.owner.name,e,s.array),n),m(a)):a},set(){return!0},deleteProperty(n,e){return e in n&&y(n,e,void 0),!0},has(n,e){return e===T||e===K||e===W||e===C||e===q||e===G?!0:(V(g(n),e,n[e])(),e in n)},ownKeys(n){return F(n),Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,e){return Reflect.getOwnPropertyDescriptor(n,e)}};function J(n,e=new Set){if(n==null||typeof n!="object")return n;let t=n[T]??n;if(e.has(t)||!d(t))return t;e.add(t);let o=!1,r=i=>{let a=J(i,e);return a!==i&&(o=!0),a};if(Array.isArray(t)){let i=t.map(r);return o?i:t}let s={};for(let i of Object.keys(t))s[i]=r(t[i]);return o?s:t}function y(n,e,t){let o=J(t),r=n[e];if(r===o&&(o!==void 0||e in n))return;let s=Array.isArray(n),i=s?n.length:0;o===void 0?delete n[e]:n[e]=o;let a=g(n),c=a.keys.get(e);if(c&&L(c,o),se(r,n),s&&n.length!==i){let u=a.keys.get("length");u&&L(u,n.length)}a.all&&a.all.$(void 0)}function X(n,e){return typeof n=="function"?n(e):n}function N(n,e){for(let t of Object.keys(e)){let o=e[t],r=n[t];o&&typeof o=="object"&&!Array.isArray(o)&&r&&typeof r=="object"&&!Array.isArray(r)?N(r,o):y(n,t,o)}}function D(n){let e=[],t=n.replace(/\[([^\]]*)\]/g,".$1");for(let o of t.split("."))o.length&&e.push(o);return e}function Q(n,e,t){let o=e.length-1;for(let s=0;s<o;s++){let i=e[s];if(i==="*"){let c=e.slice(s+1);if(Array.isArray(n))for(let u=0;u<n.length;u++)Q(n[u],c,t);return}let a=n[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(e[s+1])?[]:{},y(n,i,a)),n=a}let r=e[o];if(r==="*"){if(Array.isArray(n))for(let s=0;s<n.length;s++)y(n,s,X(t,n[s]));return}y(n,r,X(t,n[r]))}function j(n,e,t){Q(n,D(e),t)}function ce(n,e){let t=e[0];if(typeof t=="function"&&e.length===1){let o=t(n);o&&o!==n&&N(n,o);return}if(Array.isArray(t)&&e.length===1){for(let o of t)Array.isArray(o)&&j(n,o[0],o[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&e.length===1){N(n,t);return}if(Array.isArray(e[1])&&e.length>=3){j(n,`${t}.${e[1].join(".")}`,e[2]);return}j(n,String(t),e[1])}function P(n){if(n==null||typeof n!="object")return n;if(Array.isArray(n))return n.map(P);let e={};for(let t of Object.keys(n))e[t]=P(n[t]);return e}function f(n,e){let t=n;for(let o of D(e)){if(t==null)return;t=t[o]}return t}var S=class{constructor(e,t={immutable:!0}){this.options=t;this.root=e,this.set=((...o)=>z(()=>ce(this.root,o))),e&&typeof e=="object"&&(p.set(e,{store:this,name:t.name??"store"}),h.set(e,e)),E({kind:"store",node:this,handle:()=>this.root,name:t.name})}get state(){return m(this.root)}get proxy(){return m(this.root)}get accessor(){return(()=>m(this.root))}unwrap(){return this.root}getNode(e){return this.root&&this.root[e]}get(e){if(e==null||e==="")return O(this.state);let t=this.state;for(let o of D(e)){if(t==null)return;t=t[o]}return O(t)}select(e){return H(()=>e(this.state))}subscribe(e){return M(()=>e(this.state))}watch(e,t){let o;return M(()=>{let r=e(this.state);Object.is(r,o)||(t(r,o),o=r)})}reactive(e){return H(()=>this.state[e])}produce(e){this.set((t=>{let o=P(t);return e(o),o}))}reconcile(e,t={}){this.set(e)}push(e,...t){let o=f(this.root,e);this.set(e,o.concat(t))}pop(e){let t=f(this.root,e).slice(),o=t.pop();return this.set(e,t),o}shift(e){let t=f(this.root,e).slice(),o=t.shift();return this.set(e,t),o}splice(e,t,o,...r){let s=f(this.root,e).slice(),i=s.splice(t,o,...r);return this.set(e,s),i}insert(e,t,o){let r=f(this.root,e).slice();r.splice(t,0,o),this.set(e,r)}removeAt(e,t){let o=f(this.root,e).slice(),r=o.splice(t,1);return this.set(e,o),r}toObservable(){let[e]=Y(this.state);return e.toObservable()}dispose(){}},ue=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function le(n,e){for(let t of ue)n[t]=e[t].bind(e);n.$=e.reactive.bind(e)}function I(n,e={immutable:!0}){let t=new S(n,e);return le(t.set,t),[t.proxy,t.set]}function fe(n,e={}){return new S(n,{...e,immutable:!1})}function O(n){if(n==null||typeof n!="object")return n;let e=n[T];return e!==void 0?e:n}function de(n){return re(()=>O(n))}var we=Object.freeze({createStore:I,createMutableStore:fe,batch:z,unwrap:O,untrackStore:de});function Oe(n,e){let[t,o]=I(n,e);return new Proxy(t,{get:(r,s)=>s==="set"?o:r[s],has:(r,s)=>s==="set"||Reflect.has(r,s)})}export{Oe as store};
|
package/dist/lib/store/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var Te=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!me.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=be(t,r))||o.enumerable});return e};var he=e=>Se(P({},"__esModule",{value:!0}),e);var $e={};Te($e,{$NAME:()=>J,$NODE:()=>p,$RAW:()=>v,$SELF:()=>x,$STORE:()=>Q,$TRACK:()=>R,Store:()=>d,StoreAPI:()=>le,createComputedStore:()=>oe,createMutableStore:()=>H,createStore:()=>w,createStoreEffect:()=>re,createStoreMemo:()=>se,getNode:()=>ce,getStoreNode:()=>ue,isStore:()=>ae,isStoreProxy:()=>N,modifiable:()=>fe,produceUtil:()=>de,reconcileUtil:()=>pe,store:()=>ye,untrackStore:()=>W,unwrap:()=>T,wrap:()=>ie});module.exports=he($e);var c=require("@fluixi/reactive/signal");var we="__fluixi_signal_next_state__",ge=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[we]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ge,onSuspend:null,onError:null,observer:null};var q="1.0.0-alpha.83";function Oe(e){return l.observer=e,()=>{l.observer===e&&(l.observer=null)}}var xe=[],g;function V(e,t){if(!l.observer)return t();let n=g;g=e;try{return t()}finally{g=n}}function F(e){let t=l.observer;t&&t.created(e.parents===void 0?{...e,parents:xe,origin:e.origin??g}:e)}function $(e,t,n){l.observer?.moved?.(e,t,n)}function D(e){l.observer?.disposed?.(e)}var Re="__FLUIXI_DEVTOOLS_HOOK__",G=globalThis[Re];if(typeof G?.inject=="function")try{G.inject({observeReactiveNodes:Oe,version:q})}catch{}function I(){return l.observer!=null}var v=Symbol("store-raw"),p=Symbol("store-node"),L=Symbol("store-has"),x=Symbol("store-self"),R=Symbol("store-track"),J=Symbol("store-name"),Q=Symbol("store-store"),h=new WeakMap,U=new WeakMap,m=new WeakMap,j=new WeakMap;function je(e,t){if(!b(e)||!I())return;let n=new Set,o=i=>{if(!(!b(i)||n.has(i))){n.add(i);for(let a of Object.values(i))o(a)}};o(j.get(t)??t);let r=new Set,s=i=>{if(!b(i))return;let a=i;if(n.has(a)||r.has(a))return;r.add(a);let u=h.get(a);if(u){for(let f of u.keys.values())D(f);u.all&&D(u.all),h.delete(a),m.delete(a),U.delete(a)}for(let f of Object.values(a))s(f)};s(e)}var k=(e,t,n)=>n?`${e}[${String(t)}]`:`${e}.${String(t)}`;function Z(e,t,n){let o=t?.owner,r=o&&n!==void 0?k(o.name,n,t?.array):void 0,[s,i]=V(o?.store,()=>(0,c.createSignal)(e,r?{name:r}:void 0)),a=s;return a.$=i,a}function A(e){let t=h.get(e);return t?t.owner||(t.owner=m.get(e)):h.set(e,t={keys:new Map,owner:m.get(e),array:Array.isArray(e)}),t}function X(e,t,n){let o=e.keys.get(t);return o||e.keys.set(t,o=Z(n,e,t)),o}function ke(e,t,n,o){let r=m.get(e);if(r&&r.store===t&&r.name===n)return;let s={store:t,name:n};m.set(e,s),j.set(e,j.get(o)??o);let i=h.get(e);if(i&&(i.owner=s,!!I())){for(let[a,u]of i.keys)$(u,t,k(n,a,i.array));i.all&&$(i.all,t,k(n,"*",i.array))}}function z(e){let t=A(e);(t.all||(t.all=Z(void 0,t,"*")))()}function Y(e,t){e.$(typeof t=="function"?()=>t:t)}function b(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function O(e){if(!b(e))return e;let t=U.get(e);if(t)return t;let n=new Proxy(e,Ae);return U.set(e,n),n}var Ae={get(e,t,n){if(t===v||t===p)return e;if(t===c.$PROXY)return n;if(t===L)return u=>u in e;if(t==="__proxy")return!0;if(t===R||t===x)return z(e),n;let o=e[t];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return o;let r=Object.getOwnPropertyDescriptor(e,t);if(r&&r.get)return r.get.call(n);let s=A(e),i=X(s,t,o),a=i();return b(a)?(s.owner&&ke(a,i,k(s.owner.name,t,s.array),e),O(a)):a},set(){return!0},deleteProperty(e,t){return t in e&&S(e,t,void 0),!0},has(e,t){return t===v||t===c.$PROXY||t===p||t===L||t===x||t===R?!0:(X(A(e),t,e[t])(),t in e)},ownKeys(e){return z(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function ee(e,t=new Set){if(e==null||typeof e!="object")return e;let n=e[v]??e;if(t.has(n)||!b(n))return n;t.add(n);let o=!1,r=i=>{let a=ee(i,t);return a!==i&&(o=!0),a};if(Array.isArray(n)){let i=n.map(r);return o?i:n}let s={};for(let i of Object.keys(n))s[i]=r(n[i]);return o?s:n}function S(e,t,n){let o=ee(n),r=e[t];if(r===o&&(o!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;o===void 0?delete e[t]:e[t]=o;let a=A(e),u=a.keys.get(t);if(u&&Y(u,o),je(r,e),s&&e.length!==i){let f=a.keys.get("length");f&&Y(f,e.length)}a.all&&a.all.$(void 0)}function B(e,t){return typeof e=="function"?e(t):e}function _(e,t){for(let n of Object.keys(t)){let o=t[n],r=e[n];o&&typeof o=="object"&&!Array.isArray(o)&&r&&typeof r=="object"&&!Array.isArray(r)?_(r,o):S(e,n,o)}}function K(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let o of n.split("."))o.length&&t.push(o);return t}function te(e,t,n){let o=t.length-1;for(let s=0;s<o;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let f=0;f<e.length;f++)te(e[f],u,n);return}let a=e[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(t[s+1])?[]:{},S(e,i,a)),e=a}let r=t[o];if(r==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)S(e,s,B(n,e[s]));return}S(e,r,B(n,e[r]))}function E(e,t,n){te(e,K(t),n)}function Ne(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let o=n(e);o&&o!==e&&_(e,o);return}if(Array.isArray(n)&&t.length===1){for(let o of n)Array.isArray(o)&&E(e,o[0],o[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){_(e,n);return}if(Array.isArray(t[1])&&t.length>=3){E(e,`${n}.${t[1].join(".")}`,t[2]);return}E(e,String(n),t[1])}function M(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(M);let t={};for(let n of Object.keys(e))t[n]=M(e[n]);return t}function y(e,t){let n=e;for(let o of K(t)){if(n==null)return;n=n[o]}return n}var d=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...o)=>(0,c.batch)(()=>Ne(this.root,o))),t&&typeof t=="object"&&(m.set(t,{store:this,name:n.name??"store"}),j.set(t,t)),F({kind:"store",node:this,handle:()=>this.root,name:n.name})}get state(){return O(this.root)}get proxy(){return O(this.root)}get accessor(){return(()=>O(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return T(this.state);let n=this.state;for(let o of K(t)){if(n==null)return;n=n[o]}return T(n)}select(t){return(0,c.createMemo)(()=>t(this.state))}subscribe(t){return(0,c.createEffect)(()=>t(this.state))}watch(t,n){let o;return(0,c.createEffect)(()=>{let r=t(this.state);Object.is(r,o)||(n(r,o),o=r)})}reactive(t){return(0,c.createMemo)(()=>this.state[t])}produce(t){this.set((n=>{let o=M(n);return t(o),o}))}reconcile(t,n={}){this.set(t)}push(t,...n){let o=y(this.root,t);this.set(t,o.concat(n))}pop(t){let n=y(this.root,t).slice(),o=n.pop();return this.set(t,n),o}shift(t){let n=y(this.root,t).slice(),o=n.shift();return this.set(t,n),o}splice(t,n,o,...r){let s=y(this.root,t).slice(),i=s.splice(n,o,...r);return this.set(t,s),i}insert(t,n,o){let r=y(this.root,t).slice();r.splice(n,0,o),this.set(t,r)}removeAt(t,n){let o=y(this.root,t).slice(),r=o.splice(n,1);return this.set(t,o),r}toObservable(){let[t]=(0,c.createSignal)(this.state);return t.toObservable()}dispose(){}},Pe=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function ne(e,t){for(let n of Pe)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function w(e,t={immutable:!0}){let n=new d(e,t);return ne(n.set,n),[n.proxy,n.set]}function H(e,t={}){return new d(e,{...t,immutable:!1})}function oe(e,t={}){let n=new d(e(),t);return(0,c.createEffect)(()=>n.set(e())),n}function re(e,t,n){return(0,c.createEffect)(()=>n(t(e)))}function se(e,t,n){return(0,c.createMemo)(()=>t(e),void 0,n)}function ie(e,t={}){let n=new d(e,t),o=(()=>n.proxy);return ne(o,n),o}function T(e){if(e==null||typeof e!="object")return e;let t=e[v];return t!==void 0?t:e}function W(e){return(0,c.untrack)(()=>T(e))}function ae(e){return N(e)}function ce(e){return N(e)?e[p]:null}function ue(e){return e&&typeof e=="object"&&p in e?e[p]:null}function N(e){return!!e&&typeof e=="object"&&(c.$PROXY in e||e.__proxy===!0)}function fe(e){return e}var le=Object.freeze({createStore:w,createMutableStore:H,batch:c.batch,unwrap:T,untrackStore:W});function C(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(C);let t={};for(let n of Object.keys(e))t[n]=C(e[n]);return t}function de(e){return t=>{let n=C(t);return e(n),n}}function pe(e,t={}){return()=>e}function ye(e,t){let[n,o]=w(e,t);return new Proxy(n,{get:(r,s)=>s==="set"?o:r[s],has:(r,s)=>s==="set"||Reflect.has(r,s)})}
|
package/dist/lib/store/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$PROXY as
|
|
1
|
+
import{$PROXY as $,batch as B,createEffect as g,createMemo as D,createSignal as J,untrack as ue}from"@fluixi/reactive/signal";var re="__fluixi_signal_next_state__",se=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},f=globalThis[re]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:se,onSuspend:null,onError:null,observer:null};var C="1.0.0-alpha.83";function ie(e){return f.observer=e,()=>{f.observer===e&&(f.observer=null)}}var ae=[],h;function G(e,t){if(!f.observer)return t();let n=h;h=e;try{return t()}finally{h=n}}function V(e){let t=f.observer;t&&t.created(e.parents===void 0?{...e,parents:ae,origin:e.origin??h}:e)}function k(e,t,n){f.observer?.moved?.(e,t,n)}function A(e){f.observer?.disposed?.(e)}var ce="__FLUIXI_DEVTOOLS_HOOK__",q=globalThis[ce];if(typeof q?.inject=="function")try{q.inject({observeReactiveNodes:ie,version:C})}catch{}function N(){return f.observer!=null}var m=Symbol("store-raw"),y=Symbol("store-node"),F=Symbol("store-has"),I=Symbol("store-self"),E=Symbol("store-track"),fe=Symbol("store-name"),le=Symbol("store-store"),T=new WeakMap,U=new WeakMap,b=new WeakMap,O=new WeakMap;function de(e,t){if(!p(e)||!N())return;let n=new Set,o=i=>{if(!(!p(i)||n.has(i))){n.add(i);for(let a of Object.values(i))o(a)}};o(O.get(t)??t);let r=new Set,s=i=>{if(!p(i))return;let a=i;if(n.has(a)||r.has(a))return;r.add(a);let c=T.get(a);if(c){for(let u of c.keys.values())A(u);c.all&&A(c.all),T.delete(a),b.delete(a),U.delete(a)}for(let u of Object.values(a))s(u)};s(e)}var x=(e,t,n)=>n?`${e}[${String(t)}]`:`${e}.${String(t)}`;function Q(e,t,n){let o=t?.owner,r=o&&n!==void 0?x(o.name,n,t?.array):void 0,[s,i]=G(o?.store,()=>J(e,r?{name:r}:void 0)),a=s;return a.$=i,a}function R(e){let t=T.get(e);return t?t.owner||(t.owner=b.get(e)):T.set(e,t={keys:new Map,owner:b.get(e),array:Array.isArray(e)}),t}function L(e,t,n){let o=e.keys.get(t);return o||e.keys.set(t,o=Q(n,e,t)),o}function pe(e,t,n,o){let r=b.get(e);if(r&&r.store===t&&r.name===n)return;let s={store:t,name:n};b.set(e,s),O.set(e,O.get(o)??o);let i=T.get(e);if(i&&(i.owner=s,!!N())){for(let[a,c]of i.keys)k(c,t,x(n,a,i.array));i.all&&k(i.all,t,x(n,"*",i.array))}}function X(e){let t=R(e);(t.all||(t.all=Q(void 0,t,"*")))()}function z(e,t){e.$(typeof t=="function"?()=>t:t)}function p(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function w(e){if(!p(e))return e;let t=U.get(e);if(t)return t;let n=new Proxy(e,ye);return U.set(e,n),n}var ye={get(e,t,n){if(t===m||t===y)return e;if(t===$)return n;if(t===F)return c=>c in e;if(t==="__proxy")return!0;if(t===E||t===I)return X(e),n;let o=e[t];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return o;let r=Object.getOwnPropertyDescriptor(e,t);if(r&&r.get)return r.get.call(n);let s=R(e),i=L(s,t,o),a=i();return p(a)?(s.owner&&pe(a,i,x(s.owner.name,t,s.array),e),w(a)):a},set(){return!0},deleteProperty(e,t){return t in e&&v(e,t,void 0),!0},has(e,t){return t===m||t===$||t===y||t===F||t===I||t===E?!0:(L(R(e),t,e[t])(),t in e)},ownKeys(e){return X(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Z(e,t=new Set){if(e==null||typeof e!="object")return e;let n=e[m]??e;if(t.has(n)||!p(n))return n;t.add(n);let o=!1,r=i=>{let a=Z(i,t);return a!==i&&(o=!0),a};if(Array.isArray(n)){let i=n.map(r);return o?i:n}let s={};for(let i of Object.keys(n))s[i]=r(n[i]);return o?s:n}function v(e,t,n){let o=Z(n),r=e[t];if(r===o&&(o!==void 0||t in e))return;let s=Array.isArray(e),i=s?e.length:0;o===void 0?delete e[t]:e[t]=o;let a=R(e),c=a.keys.get(t);if(c&&z(c,o),de(r,e),s&&e.length!==i){let u=a.keys.get("length");u&&z(u,e.length)}a.all&&a.all.$(void 0)}function Y(e,t){return typeof e=="function"?e(t):e}function _(e,t){for(let n of Object.keys(t)){let o=t[n],r=e[n];o&&typeof o=="object"&&!Array.isArray(o)&&r&&typeof r=="object"&&!Array.isArray(r)?_(r,o):v(e,n,o)}}function K(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let o of n.split("."))o.length&&t.push(o);return t}function ee(e,t,n){let o=t.length-1;for(let s=0;s<o;s++){let i=t[s];if(i==="*"){let c=t.slice(s+1);if(Array.isArray(e))for(let u=0;u<e.length;u++)ee(e[u],c,n);return}let a=e[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(t[s+1])?[]:{},v(e,i,a)),e=a}let r=t[o];if(r==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)v(e,s,Y(n,e[s]));return}v(e,r,Y(n,e[r]))}function P(e,t,n){ee(e,K(t),n)}function be(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let o=n(e);o&&o!==e&&_(e,o);return}if(Array.isArray(n)&&t.length===1){for(let o of n)Array.isArray(o)&&P(e,o[0],o[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){_(e,n);return}if(Array.isArray(t[1])&&t.length>=3){P(e,`${n}.${t[1].join(".")}`,t[2]);return}P(e,String(n),t[1])}function M(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(M);let t={};for(let n of Object.keys(e))t[n]=M(e[n]);return t}function d(e,t){let n=e;for(let o of K(t)){if(n==null)return;n=n[o]}return n}var l=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...o)=>B(()=>be(this.root,o))),t&&typeof t=="object"&&(b.set(t,{store:this,name:n.name??"store"}),O.set(t,t)),V({kind:"store",node:this,handle:()=>this.root,name:n.name})}get state(){return w(this.root)}get proxy(){return w(this.root)}get accessor(){return(()=>w(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return S(this.state);let n=this.state;for(let o of K(t)){if(n==null)return;n=n[o]}return S(n)}select(t){return D(()=>t(this.state))}subscribe(t){return g(()=>t(this.state))}watch(t,n){let o;return g(()=>{let r=t(this.state);Object.is(r,o)||(n(r,o),o=r)})}reactive(t){return D(()=>this.state[t])}produce(t){this.set((n=>{let o=M(n);return t(o),o}))}reconcile(t,n={}){this.set(t)}push(t,...n){let o=d(this.root,t);this.set(t,o.concat(n))}pop(t){let n=d(this.root,t).slice(),o=n.pop();return this.set(t,n),o}shift(t){let n=d(this.root,t).slice(),o=n.shift();return this.set(t,n),o}splice(t,n,o,...r){let s=d(this.root,t).slice(),i=s.splice(n,o,...r);return this.set(t,s),i}insert(t,n,o){let r=d(this.root,t).slice();r.splice(n,0,o),this.set(t,r)}removeAt(t,n){let o=d(this.root,t).slice(),r=o.splice(n,1);return this.set(t,o),r}toObservable(){let[t]=J(this.state);return t.toObservable()}dispose(){}},ve=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function te(e,t){for(let n of ve)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function j(e,t={immutable:!0}){let n=new l(e,t);return te(n.set,n),[n.proxy,n.set]}function ne(e,t={}){return new l(e,{...t,immutable:!1})}function me(e,t={}){let n=new l(e(),t);return g(()=>n.set(e())),n}function Te(e,t,n){return g(()=>n(t(e)))}function Se(e,t,n){return D(()=>t(e),void 0,n)}function he(e,t={}){let n=new l(e,t),o=(()=>n.proxy);return te(o,n),o}function S(e){if(e==null||typeof e!="object")return e;let t=e[m];return t!==void 0?t:e}function oe(e){return ue(()=>S(e))}function we(e){return H(e)}function ge(e){return H(e)?e[y]:null}function Oe(e){return e&&typeof e=="object"&&y in e?e[y]:null}function H(e){return!!e&&typeof e=="object"&&($ in e||e.__proxy===!0)}function xe(e){return e}var Re=Object.freeze({createStore:j,createMutableStore:ne,batch:B,unwrap:S,untrackStore:oe});function W(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(W);let t={};for(let n of Object.keys(e))t[n]=W(e[n]);return t}function je(e){return t=>{let n=W(t);return e(n),n}}function ke(e,t={}){return()=>e}function Ae(e,t){let[n,o]=j(e,t);return new Proxy(n,{get:(r,s)=>s==="set"?o:r[s],has:(r,s)=>s==="set"||Reflect.has(r,s)})}export{fe as $NAME,y as $NODE,m as $RAW,I as $SELF,le as $STORE,E as $TRACK,l as Store,Re as StoreAPI,me as createComputedStore,ne as createMutableStore,j as createStore,Te as createStoreEffect,Se as createStoreMemo,ge as getNode,Oe as getStoreNode,we as isStore,H as isStoreProxy,xe as modifiable,je as produceUtil,ke as reconcileUtil,Ae as store,oe as untrackStore,S as unwrap,he as wrap};
|
package/dist/lib/store/store.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var oe=(n,e)=>{for(var t in e)k(n,t,{get:e[t],enumerable:!0})},re=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ne(e))!te.call(n,r)&&r!==t&&k(n,r,{get:()=>e[r],enumerable:!(o=ee(e,r))||o.enumerable});return n};var se=n=>re(k({},"__esModule",{value:!0}),n);var je={};oe(je,{$HAS:()=>D,$NAME:()=>fe,$NODE:()=>b,$RAW:()=>h,$SELF:()=>I,$STORE:()=>de,$TRACK:()=>_,Store:()=>d,StoreAPI:()=>ke,createComputedStore:()=>he,createMutableStore:()=>Q,createStore:()=>J,createStoreEffect:()=>we,createStoreMemo:()=>Te,getNode:()=>Oe,getStoreNode:()=>xe,isStore:()=>Se,isStoreProxy:()=>K,modifiable:()=>Re,untrackStore:()=>Z,unwrap:()=>T,wrap:()=>ge});module.exports=se(je);var c=require("@fluixi/reactive/signal");var ie="__fluixi_signal_next_state__",ae=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},f=globalThis[ie]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ae,onSuspend:null,onError:null,observer:null};var W="1.0.0-alpha.83";function ce(n){return f.observer=n,()=>{f.observer===n&&(f.observer=null)}}var ue=[],g;function H(n,e){if(!f.observer)return e();let t=g;g=n;try{return e()}finally{g=t}}function q(n){let e=f.observer;e&&e.created(n.parents===void 0?{...n,parents:ue,origin:n.origin??g}:n)}function j(n,e,t){f.observer?.moved?.(n,e,t)}function A(n){f.observer?.disposed?.(n)}var le="__FLUIXI_DEVTOOLS_HOOK__",C=globalThis[le];if(typeof C?.inject=="function")try{C.inject({observeReactiveNodes:ce,version:W})}catch{}function N(){return f.observer!=null}var h=Symbol("store-raw"),b=Symbol("store-node"),D=Symbol("store-has"),I=Symbol("store-self"),_=Symbol("store-track"),fe=Symbol("store-name"),de=Symbol("store-store"),w=new WeakMap,$=new WeakMap,v=new WeakMap,O=new WeakMap;function ye(n,e){if(!p(n)||!N())return;let t=new Set,o=s=>{if(!(!p(s)||t.has(s))){t.add(s);for(let i of Object.values(s))o(i)}};o(O.get(e)??e);let r=new Set,a=s=>{if(!p(s))return;let i=s;if(t.has(i)||r.has(i))return;r.add(i);let u=w.get(i);if(u){for(let l of u.keys.values())A(l);u.all&&A(u.all),w.delete(i),v.delete(i),$.delete(i)}for(let l of Object.values(i))a(l)};a(n)}var x=(n,e,t)=>t?`${n}[${String(e)}]`:`${n}.${String(e)}`;function X(n,e,t){let o=e?.owner,r=o&&t!==void 0?x(o.name,t,e?.array):void 0,[a,s]=H(o?.store,()=>(0,c.createSignal)(n,r?{name:r}:void 0)),i=a;return i.$=s,i}function R(n){let e=w.get(n);return e?e.owner||(e.owner=v.get(n)):w.set(n,e={keys:new Map,owner:v.get(n),array:Array.isArray(n)}),e}function G(n,e,t){let o=n.keys.get(e);return o||n.keys.set(e,o=X(t,n,e)),o}function pe(n,e,t,o){let r=v.get(n);if(r&&r.store===e&&r.name===t)return;let a={store:e,name:t};v.set(n,a),O.set(n,O.get(o)??o);let s=w.get(n);if(s&&(s.owner=a,!!N())){for(let[i,u]of s.keys)j(u,e,x(t,i,s.array));s.all&&j(s.all,e,x(t,"*",s.array))}}function V(n){let e=R(n);(e.all||(e.all=X(void 0,e,"*")))()}function F(n,e){n.$(typeof e=="function"?()=>e:e)}function p(n){if(n==null||typeof n!="object")return!1;if(Array.isArray(n))return!0;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function S(n){if(!p(n))return n;let e=$.get(n);if(e)return e;let t=new Proxy(n,be);return $.set(n,t),t}var be={get(n,e,t){if(e===h||e===b)return n;if(e===c.$PROXY)return t;if(e===D)return u=>u in n;if(e==="__proxy")return!0;if(e===_||e===I)return V(n),t;let o=n[e];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(n,e))return o;let r=Object.getOwnPropertyDescriptor(n,e);if(r&&r.get)return r.get.call(t);let a=R(n),s=G(a,e,o),i=s();return p(i)?(a.owner&&pe(i,s,x(a.owner.name,e,a.array),n),S(i)):i},set(){return!0},deleteProperty(n,e){return e in n&&m(n,e,void 0),!0},has(n,e){return e===h||e===c.$PROXY||e===b||e===D||e===I||e===_?!0:(G(R(n),e,n[e])(),e in n)},ownKeys(n){return V(n),Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,e){return Reflect.getOwnPropertyDescriptor(n,e)}};function z(n,e=new Set){if(n==null||typeof n!="object")return n;let t=n[h]??n;if(e.has(t)||!p(t))return t;e.add(t);let o=!1,r=s=>{let i=z(s,e);return i!==s&&(o=!0),i};if(Array.isArray(t)){let s=t.map(r);return o?s:t}let a={};for(let s of Object.keys(t))a[s]=r(t[s]);return o?a:t}function m(n,e,t){let o=z(t),r=n[e];if(r===o&&(o!==void 0||e in n))return;let a=Array.isArray(n),s=a?n.length:0;o===void 0?delete n[e]:n[e]=o;let i=R(n),u=i.keys.get(e);if(u&&F(u,o),ye(r,n),a&&n.length!==s){let l=i.keys.get("length");l&&F(l,n.length)}i.all&&i.all.$(void 0)}function L(n,e){return typeof n=="function"?n(e):n}function U(n,e){for(let t of Object.keys(e)){let o=e[t],r=n[t];o&&typeof o=="object"&&!Array.isArray(o)&&r&&typeof r=="object"&&!Array.isArray(r)?U(r,o):m(n,t,o)}}function M(n){let e=[],t=n.replace(/\[([^\]]*)\]/g,".$1");for(let o of t.split("."))o.length&&e.push(o);return e}function Y(n,e,t){let o=e.length-1;for(let a=0;a<o;a++){let s=e[a];if(s==="*"){let u=e.slice(a+1);if(Array.isArray(n))for(let l=0;l<n.length;l++)Y(n[l],u,t);return}let i=n[s];(i==null||typeof i!="object")&&(i=/^\d+$/.test(e[a+1])?[]:{},m(n,s,i)),n=i}let r=e[o];if(r==="*"){if(Array.isArray(n))for(let a=0;a<n.length;a++)m(n,a,L(t,n[a]));return}m(n,r,L(t,n[r]))}function P(n,e,t){Y(n,M(e),t)}function ve(n,e){let t=e[0];if(typeof t=="function"&&e.length===1){let o=t(n);o&&o!==n&&U(n,o);return}if(Array.isArray(t)&&e.length===1){for(let o of t)Array.isArray(o)&&P(n,o[0],o[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&e.length===1){U(n,t);return}if(Array.isArray(e[1])&&e.length>=3){P(n,`${t}.${e[1].join(".")}`,e[2]);return}P(n,String(t),e[1])}function E(n){if(n==null||typeof n!="object")return n;if(Array.isArray(n))return n.map(E);let e={};for(let t of Object.keys(n))e[t]=E(n[t]);return e}function y(n,e){let t=n;for(let o of M(e)){if(t==null)return;t=t[o]}return t}var d=class{constructor(e,t={immutable:!0}){this.options=t;this.root=e,this.set=((...o)=>(0,c.batch)(()=>ve(this.root,o))),e&&typeof e=="object"&&(v.set(e,{store:this,name:t.name??"store"}),O.set(e,e)),q({kind:"store",node:this,handle:()=>this.root,name:t.name})}get state(){return S(this.root)}get proxy(){return S(this.root)}get accessor(){return(()=>S(this.root))}unwrap(){return this.root}getNode(e){return this.root&&this.root[e]}get(e){if(e==null||e==="")return T(this.state);let t=this.state;for(let o of M(e)){if(t==null)return;t=t[o]}return T(t)}select(e){return(0,c.createMemo)(()=>e(this.state))}subscribe(e){return(0,c.createEffect)(()=>e(this.state))}watch(e,t){let o;return(0,c.createEffect)(()=>{let r=e(this.state);Object.is(r,o)||(t(r,o),o=r)})}reactive(e){return(0,c.createMemo)(()=>this.state[e])}produce(e){this.set((t=>{let o=E(t);return e(o),o}))}reconcile(e,t={}){this.set(e)}push(e,...t){let o=y(this.root,e);this.set(e,o.concat(t))}pop(e){let t=y(this.root,e).slice(),o=t.pop();return this.set(e,t),o}shift(e){let t=y(this.root,e).slice(),o=t.shift();return this.set(e,t),o}splice(e,t,o,...r){let a=y(this.root,e).slice(),s=a.splice(t,o,...r);return this.set(e,a),s}insert(e,t,o){let r=y(this.root,e).slice();r.splice(t,0,o),this.set(e,r)}removeAt(e,t){let o=y(this.root,e).slice(),r=o.splice(t,1);return this.set(e,o),r}toObservable(){let[e]=(0,c.createSignal)(this.state);return e.toObservable()}dispose(){}},me=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function B(n,e){for(let t of me)n[t]=e[t].bind(e);n.$=e.reactive.bind(e)}function J(n,e={immutable:!0}){let t=new d(n,e);return B(t.set,t),[t.proxy,t.set]}function Q(n,e={}){return new d(n,{...e,immutable:!1})}function he(n,e={}){let t=new d(n(),e);return(0,c.createEffect)(()=>t.set(n())),t}function we(n,e,t){return(0,c.createEffect)(()=>t(e(n)))}function Te(n,e,t){return(0,c.createMemo)(()=>e(n),void 0,t)}function ge(n,e={}){let t=new d(n,e),o=(()=>t.proxy);return B(o,t),o}function T(n){if(n==null||typeof n!="object")return n;let e=n[h];return e!==void 0?e:n}function Z(n){return(0,c.untrack)(()=>T(n))}function Se(n){return K(n)}function Oe(n){return K(n)?n[b]:null}function xe(n){return n&&typeof n=="object"&&b in n?n[b]:null}function K(n){return!!n&&typeof n=="object"&&(c.$PROXY in n||n.__proxy===!0)}function Re(n){return n}var ke=Object.freeze({createStore:J,createMutableStore:Q,batch:c.batch,unwrap:T,untrackStore:Z});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,EAKN,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,EAKN,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgBnD,KAAK,SAAS,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEzE,UAAU,YAAY,CAAC,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CAClC;AAED,UAAU,aAAa,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;CAAG;AAEjD,eAAO,MAAM,IAAI,eAAsB,EACrC,KAAK,eAAuB,EAC5B,IAAI,eAAsB,EAC1B,KAAK,eAAuB,EAC5B,MAAM,eAAwB,EAC9B,KAAK,eAAuB,EAC5B,MAAM,eAAwB,CAAC;AAuYjC,cAAM,KAAK,CAAC,CAAC;IAMT,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,IAAI,CAAI;IAChB,GAAG,EAAG,WAAW,CAAC,CAAC,CAAC,CAAC;gBAGnB,YAAY,EAAE,CAAC,EACP,OAAO,GAAE,YAAY,CAAC,CAAC,CAAuB;IAmBxD,IAAI,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAExB;IAED,IAAI,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAExB;IAED,IAAI,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE1B;IAED,MAAM,IAAI,CAAC;IAIX,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG;IAK9B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG;IAUvB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;IAIxD,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAI9D,KAAK,CAAC,CAAC,EACL,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EACpC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GAC9C,MAAM,IAAI;IAYb,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC;IAIpC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAQ3C,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAE,gBAAqB,GAAG,IAAI;IAIvE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;IAKzC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAOtB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAOxB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE;IAOhF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAMrD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE;IAO5C,YAAY,IAAI,UAAU,CAAC,CAAC,CAAC;IAK7B,OAAO,IAAI,IAAI;CAChB;AA4BD,iBAAS,WAAW,CAAC,CAAC,EACpB,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,YAAY,CAAC,CAAC,CAAuB,GAC7C,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAIjC;AAED,iBAAS,kBAAkB,CAAC,CAAC,EAC3B,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,WAAW,CAAM,GAC/C,KAAK,CAAC,CAAC,CAAC,CAEV;AAED,+DAA+D;AAC/D,iBAAS,mBAAmB,CAAC,CAAC,EAC5B,EAAE,EAAE,MAAM,CAAC,EACX,OAAO,GAAE,YAAY,CAAC,CAAC,CAAM,GAC5B,KAAK,CAAC,CAAC,CAAC,CAIV;AAED,kDAAkD;AAClD,iBAAS,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAC7B,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EACpC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GACxC,MAAM,IAAI,CAEZ;AAED,uCAAuC;AACvC,iBAAS,eAAe,CAAC,CAAC,EAAE,CAAC,EAC3B,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EACpC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GACvB,MAAM,CAAC,CAET;AAED,sEAAsE;AACtE,iBAAS,IAAI,CAAC,CAAC,SAAS,MAAM,EAC5B,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,YAAY,CAAC,CAAC,CAAM,GAC5B,QAAQ,CAAC,CAAC,CAAC,CAKb;AAED,iBAAS,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAI7B;AAED,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEpC;AAED,KAAK,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAE5D,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAEzE;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAElE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAIpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAMhD;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAExD;AAED,eAAO,MAAM,QAAQ;;;;;;EAMnB,CAAC;AAEH,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,KAAK,GACN,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC"}
|