@fluixi/reactive 1.0.0-alpha.75 → 1.0.0-alpha.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +1 -0
- package/dist/lib/signal/api.d.ts +13 -0
- package/dist/lib/signal/api.d.ts.map +1 -0
- package/dist/lib/signal/api.js +31 -0
- package/dist/lib/signal/api.mjs +1 -0
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.d.ts +3 -0
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +3 -0
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/resource-api.cjs +1 -0
- package/dist/lib/signal/resource-api.d.ts +27 -0
- package/dist/lib/signal/resource-api.d.ts.map +1 -0
- package/dist/lib/signal/resource-api.js +27 -0
- package/dist/lib/signal/resource-api.mjs +1 -0
- package/dist/lib/store/api.cjs +1 -0
- package/dist/lib/store/api.d.ts +7 -0
- package/dist/lib/store/api.d.ts.map +1 -0
- package/dist/lib/store/api.js +30 -0
- package/dist/lib/store/api.mjs +1 -0
- package/dist/lib/store/index.cjs +1 -1
- package/dist/lib/store/index.d.ts +2 -0
- package/dist/lib/store/index.d.ts.map +1 -1
- package/dist/lib/store/index.js +2 -0
- package/dist/lib/store/index.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
|
-
var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var ye=0,Te=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);X(this)}}peek(){return this._value}},g=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Te&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=ye}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);X(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===ye;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(Te);X(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function X(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var A=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function H(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function V(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function we(e){o.onSuspend=e}function Se(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function K(){return o.owner}function be(e){let n=o.owner;return o.owner=e,n}function L(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function D(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function ge(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(j)))}function j(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function ke(){o.batchDepth===0&&j()}function Z(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&j()}}var J=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{F(this.owner,!1),L(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new A(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Y(e){let n=new J(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}ge(()=>{});var Re=Symbol.for("signal"),Ne=Symbol.for("memo"),Ve=Symbol.for("signal-node");function p(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),ke(),a});return Object.defineProperty(r,Re,{value:!0,enumerable:!0}),Object.defineProperty(r,Ve,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function S(e,n,t){let r=n,s=K(),u=new g(()=>L(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return Se(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,Re,{value:!0,enumerable:!0}),Object.defineProperty(a,Ne,{value:!0,enumerable:!0}),a}function P(e,n){let t=n;return Y(()=>{t=e(t)})}function Le(e,n){let t=n;Y(()=>{t=e(t)})}function je(e,n){let t=n;return Y(()=>{t=e(t)})}function k(e){return Z(e)}function w(e){return U(e)}function Oe(e){return Z(e),Promise.resolve()}function Ge(){return[()=>!1,Oe]}function We(){return j(),Promise.resolve()}function ze(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(d=>d()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function En(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let d=s[i],h=u.get(d);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,f,y;D(T=>{y=T;let[_,q]=p(i);f=q,l=n(d,_)});let x={item:d,rendered:l,dispose:y,setIndex:f};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Cn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],d=[],h=new Set;for(let l=0;l<a.length;l++){let f=n(a[l]),y=c.get(f);if(y&&!h.has(f))y.setIndex(l),i.push(y);else{let x,T,_;D(q=>{_=q;let[R,I]=p(l);T=I;let G=S(E=>{let b=(e()||[])[R()];return b??E},a[l]);x=t(G,R)}),i.push({rendered:x,dispose:_,setIndex:T})}d.push(f),h.add(f)}for(let[l,f]of c)h.has(l)||f.dispose();return s=d,u=i,i.map(l=>l.rendered)})})}function An(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let d,h,l,f=s[i];D(y=>{l=y;let[x,T]=p(f);h=T,d=n(x,i)}),r.push({rendered:d,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ee=!1,$e=Symbol.for("signal"),He=Symbol.for("memo"),Ke=Symbol.for("resource");function ne(e){return typeof e=="function"&&e[$e]===!0}function Ye(e){return typeof e=="function"&&e[He]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function _e(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?_e(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var te=null;function en(e){te=e}function ie(e){te&&te(e)}var re=null;function nn(e){re=e}function ue(e){return re?re(e):void 0}var oe=null;function tn(e){oe=e}function ae(){return oe?oe():void 0}var se=null;function rn(e){se=e}function ce(e,n){se&&se(e,n)}function on(e,n=(t,r)=>t===r){let t=new Map;return P(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=p(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function sn(e,n){let[t,r]=p(e(),n);return P(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function un(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function an(e){return!!e&&typeof e.then=="function"}var le=Symbol();function de(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ae(),a=u!==void 0?ue(u):void 0,c=a!==void 0,[i,d]=p(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=p(void 0,{equals:!1}),[f,y]=p(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=p(void 0,{equals:!1}),[_,q]=p(void 0,{equals:!1}),R=le,I=!1;P(()=>{let m=r();if(_(),m===!1||m===null||m===void 0){R=le,k(()=>{y("unresolved"),T(void 0),l(void 0)});return}let b=I;if(I=!1,R!==le&&m===R&&!b)return;if(R=m,c){c=!1;return}let W=!1;v(()=>W=!0);let pe=w(f),Ae=w(i),he=pe==="ready"||pe==="refreshing";k(()=>{y(he?"refreshing":"pending"),l(void 0)});try{let O=s(m,{value:Ae,refetching:he});an(O)?(T(O),ie(O),O.then(z=>{W||(u!==void 0&&ce(u,z),k(()=>{d(()=>z),y("ready"),T(void 0)}))},z=>{W||k(()=>{l(z),y("errored"),T(void 0)})})):k(()=>{d(()=>O),y("ready"),T(void 0)})}catch(O){if(W)return;k(()=>{l(O),y("errored"),T(void 0)})}});let G=()=>{let m=f();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(G()){let b=x();if(b)throw b}return i()});return Object.defineProperties(E,{state:{get:f},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:d,refetch:()=>{I=!0,q(void 0)}}]}function Ee(e,n=300){let[t,r]=p(e),[s,u]=p(e),[a,c]=p(!1),i,d=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{d();let f=w(t);return u(()=>f),c(!1),f},l=(f=>{let y=typeof f=="function"?f(w(t)):f;return r(()=>y),c(!0),d(),i=setTimeout(h,n),y});return v(d),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{d(),c(!1)}}]}function cn(e){return e!=null&&e!==""}function ln(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=cn}=t,[a,c,i]=Ee(e,r),d=()=>u(a())?a():!1,[h,{refetch:l}]=de(d,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function Q(e){if(typeof e=="function"&&!e.length){let n=e();return ne(n)?n:Q(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=Q(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function dn(e){let n=S(e);return S(()=>Q(n()))}var fe=N();we((e,n)=>{let t=H(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function fn(){let[e,n]=p(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function pn(e,n){return V(fe,e,n)}var Ce=N();xe((e,n)=>{let t=H(n,Ce);return t?(t.setError(e),!0):!1});function hn(){let[e,n]=p(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function yn(e,n){return V(Ce,e,n)}var Tn={State:C,Computed:g,subtle:{Watcher:A,untrack:U,currentComputed:me,hasSinks:ve}};var Zn=Symbol.for("signal"),et=Symbol.for("fluixi-proxy");export{et as $PROXY,Zn as $SIGNAL,Tn as Signal,fe as SuspenseContext,ee as __DEV__,k as batch,qe as createChildOwner,Le as createComputed,N as createContext,un as createDebounce,ln as createDebouncedResource,Ee as createDebouncedSignal,sn as createDeferred,P as createEffect,hn as createErrorBoundary,S as createMemo,je as createRenderEffect,de as createResource,D as createRoot,on as createSelector,p as createSignal,fn as createSuspenseBoundary,Ie as disposeScope,We as flush,K as getOwner,ue as getServerData,An as indexArray,Xe as isComponent,Ye as isMemo,Me as isOwnerDisposed,Ze as isProvider,Qe as isResource,ne as isSignal,Je as isSuspense,Cn as keyArray,_e as makeArrayFlat,En as mapArray,ae as nextResourceId,ze as on,v as onCleanup,V as provide,yn as provideErrorBoundary,pn as provideSuspense,dn as readChildren,ce as reportResourceData,L as runWithOwner,be as setOwner,rn as setResourceDataSink,tn as setResourceIdSource,en as setResourceTracker,nn as setServerDataGetter,Oe as startTransition,ie as trackResourcePromise,w as untrack,Ue as useContext,Ge as useTransition};
|
|
1
|
+
var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var Te=0,ye=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);J(this)}}peek(){return this._value}},b=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===ye&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=Te}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);J(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Te;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(ye);J(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function J(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var D=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function N(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function Se(e){o.onSuspend=e}function we(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function Y(){return o.owner}function ge(e){let n=o.owner;return o.owner=e,n}function V(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function P(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function be(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(H)))}function H(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function Re(){o.batchDepth===0&&H()}function ee(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&H()}}var Z=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{F(this.owner,!1),V(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new D(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Q(e){let n=new Z(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}be(()=>{});var ke=Symbol.for("signal"),je=Symbol.for("memo"),Ne=Symbol.for("signal-node");function d(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Re(),a});return Object.defineProperty(r,ke,{value:!0,enumerable:!0}),Object.defineProperty(r,Ne,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function S(e,n,t){let r=n,s=Y(),u=new b(()=>V(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return we(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,ke,{value:!0,enumerable:!0}),Object.defineProperty(a,je,{value:!0,enumerable:!0}),a}function R(e,n){let t=n;return Q(()=>{t=e(t)})}function Ve(e,n){let t=n;Q(()=>{t=e(t)})}function He(e,n){let t=n;return Q(()=>{t=e(t)})}function k(e){return ee(e)}function w(e){return U(e)}function Oe(e){return ee(e),Promise.resolve()}function Le(){return[()=>!1,Oe]}function Ge(){return H(),Promise.resolve()}function We(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function En(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let f=s[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;P(y=>{T=y;let[A,q]=d(i);p=q,l=n(f,A)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Cn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,A;P(q=>{A=q;let[O,I]=d(l);y=I;let G=S(E=>{let g=(e()||[])[O()];return g??E},a[l]);x=t(G,O)}),i.push({rendered:x,dispose:A,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return s=f,u=i,i.map(l=>l.rendered)})})}function Dn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let f,h,l,p=s[i];P(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ne=!1,ze=Symbol.for("signal"),$e=Symbol.for("memo"),Ke=Symbol.for("resource");function te(e){return typeof e=="function"&&e[ze]===!0}function Ye(e){return typeof e=="function"&&e[$e]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function _e(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?_e(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var re=null;function en(e){re=e}function ue(e){re&&re(e)}var oe=null;function nn(e){oe=e}function ae(e){return oe?oe(e):void 0}var se=null;function tn(e){se=e}function ce(){return se?se():void 0}var ie=null;function rn(e){ie=e}function le(e,n){ie&&ie(e,n)}function on(e,n=(t,r)=>t===r){let t=new Map;return R(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=d(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function sn(e,n){let[t,r]=d(e(),n);return R(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function un(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function an(e){return!!e&&typeof e.then=="function"}var de=Symbol();function L(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ce(),a=u!==void 0?ae(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[A,q]=d(void 0,{equals:!1}),O=de,I=!1;R(()=>{let m=r();if(A(),m===!1||m===null||m===void 0){O=de,k(()=>{T("unresolved"),y(void 0),l(void 0)});return}let g=I;if(I=!1,O!==de&&m===O&&!g)return;if(O=m,c){c=!1;return}let W=!1;v(()=>W=!0);let pe=w(p),Ce=w(i),he=pe==="ready"||pe==="refreshing";k(()=>{T(he?"refreshing":"pending"),l(void 0)});try{let _=s(m,{value:Ce,refetching:he});an(_)?(y(_),ue(_),_.then(z=>{W||(u!==void 0&&le(u,z),k(()=>{f(()=>z),T("ready"),y(void 0)}))},z=>{W||k(()=>{l(z),T("errored"),y(void 0)})})):k(()=>{f(()=>_),T("ready"),y(void 0)})}catch(_){if(W)return;k(()=>{l(_),T("errored"),y(void 0)})}});let G=()=>{let m=p();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(G()){let g=x();if(g)throw g}return i()});return Object.defineProperties(E,{state:{get:p},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:f,refetch:()=>{I=!0,q(void 0)}}]}function Ae(e,n=300){let[t,r]=d(e),[s,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(w(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function cn(e){return e!=null&&e!==""}function ln(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=cn}=t,[a,c,i]=Ae(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=L(f,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function X(e){if(typeof e=="function"&&!e.length){let n=e();return te(n)?n:X(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=X(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function dn(e){let n=S(e);return S(()=>X(n()))}var fe=j();Se((e,n)=>{let t=K(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function fn(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function pn(e,n){return N(fe,e,n)}var Ee=j();xe((e,n)=>{let t=K(n,Ee);return t?(t.setError(e),!0):!1});function hn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function Tn(e,n){return N(Ee,e,n)}var yn={State:C,Computed:b,subtle:{Watcher:D,untrack:U,currentComputed:me,hasSinks:ve}};var et=Symbol.for("signal"),nt=Symbol.for("fluixi-proxy");function yt(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function mt(e,n,t){return S(e,n,t)}function vt(e,n){return R(e,n)}function mn(...e){let[n,t]=L(...e);return Object.assign(n,t)}export{nt as $PROXY,et as $SIGNAL,yn as Signal,fe as SuspenseContext,ne as __DEV__,k as batch,qe as createChildOwner,Ve as createComputed,j as createContext,un as createDebounce,ln as createDebouncedResource,Ae as createDebouncedSignal,sn as createDeferred,R as createEffect,hn as createErrorBoundary,S as createMemo,He as createRenderEffect,L as createResource,P as createRoot,on as createSelector,d as createSignal,fn as createSuspenseBoundary,Ie as disposeScope,vt as effect,Ge as flush,Y as getOwner,ae as getServerData,Dn as indexArray,Xe as isComponent,Ye as isMemo,Me as isOwnerDisposed,Ze as isProvider,Qe as isResource,te as isSignal,Je as isSuspense,Cn as keyArray,_e as makeArrayFlat,En as mapArray,mt as memo,ce as nextResourceId,We as on,v as onCleanup,N as provide,Tn as provideErrorBoundary,pn as provideSuspense,dn as readChildren,le as reportResourceData,mn as resource,V as runWithOwner,ge as setOwner,rn as setResourceDataSink,tn as setResourceIdSource,en as setResourceTracker,nn as setServerDataGetter,yt as signal,Oe as startTransition,ue as trackResourcePromise,w as untrack,Ue as useContext,Le as useTransition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var A=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var pe=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},he=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of de(t))!fe.call(e,s)&&s!==n&&A(e,s,{get:()=>t[s],enumerable:!(o=le(t,s))||o.enumerable});return e};var ve=e=>he(A({},"__esModule",{value:!0}),e);var Re={};pe(Re,{resource:()=>ke});module.exports=ve(Re);var Te="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[Te]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var F=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},R=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);C(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===K&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(c){i=!0,a=c,s=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(v);C(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===F;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var _=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ye(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function j(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)E(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function me(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ye(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{E(this.owner,!1),N(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new _(()=>me(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let t=new I(e);return()=>t.dispose()}U(()=>{});var Se=Symbol.for("signal");var ge=Symbol.for("signal-node");function h(e,t){let n=new R(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let a=typeof i=="function"?i(n.peek()):i;return n.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,ge,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function J(e,t){let n=t;return B(()=>{n=e(n)})}function d(e){return $(e)}function V(e){return L(e)}var Q=null;function te(e){Q&&Q(e)}var X=null;function ne(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,t){ee&&ee(e,t)}function xe(e){return!!e&&typeof e.then=="function"}var M=Symbol();function se(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=n.transport===!1?void 0:re(),a=i!==void 0?ne(i):void 0,w=a!==void 0,[c,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[ie,p]=h(void 0,{equals:!1}),[ue,ae]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ue(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let S=D;if(D=!1,m!==M&&u===m&&!S)return;if(m=u,w){w=!1;return}let g=!1;j(()=>g=!0);let z=V(q),ce=V(c),H=z==="ready"||z==="refreshing";d(()=>{f(H?"refreshing":"pending"),y(void 0)});try{let l=s(u,{value:ce,refetching:H});xe(l)?(p(l),te(l),l.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>l),f("ready"),p(void 0)})}catch(l){if(g)return;d(()=>{y(l),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},b=(()=>{let u=G();if(u)throw u;if(W()){let S=ie();if(S)throw S}return c()});return Object.defineProperties(b,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:c}}),Object.defineProperty(b,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(b,Symbol.for("signal"),{value:!0,enumerable:!0}),[b,{mutate:P,refetch:()=>{D=!0,ae(void 0)}}]}function ke(...e){let[t,n]=se(...e);return Object.assign(t,n)}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resource` — `createResource` as one binding instead of a tuple.
|
|
3
|
+
*
|
|
4
|
+
* const user = resource(userId, fetchUser);
|
|
5
|
+
*
|
|
6
|
+
* user(); // the value — suspends under <Suspense>, exactly as before
|
|
7
|
+
* user.latest; // last settled value, kept across a refetch
|
|
8
|
+
* user.loading; // boolean
|
|
9
|
+
* user.error;
|
|
10
|
+
* user.refetch();
|
|
11
|
+
* user.mutate(next);
|
|
12
|
+
*
|
|
13
|
+
* `createResource` already hands back a callable carrying `loading`/`error`/`latest`,
|
|
14
|
+
* with only the two actions split into a second tuple slot — so this mostly folds that
|
|
15
|
+
* split away.
|
|
16
|
+
*
|
|
17
|
+
* The returned function IS the accessor `createResource` gave back, with the two actions
|
|
18
|
+
* assigned onto it — so suspending, tracking and SSR seeding are untouched, and a read is
|
|
19
|
+
* the same call it always was.
|
|
20
|
+
*/
|
|
21
|
+
import { createResource } from './graph/resource.js';
|
|
22
|
+
import type { ResourceActions, ResourceReturn } from './graph/resource.js';
|
|
23
|
+
type ResourceAccessor<T> = ResourceReturn<T>[0];
|
|
24
|
+
export type ResourceHandle<T> = ResourceAccessor<T> & ResourceActions<T>;
|
|
25
|
+
export declare function resource<T>(...args: Parameters<typeof createResource>): ResourceHandle<T>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=resource-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-api.d.ts","sourceRoot":"","sources":["../../../src/lib/signal/resource-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE3E,KAAK,gBAAgB,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AAEzE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAMzF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resource` — `createResource` as one binding instead of a tuple.
|
|
3
|
+
*
|
|
4
|
+
* const user = resource(userId, fetchUser);
|
|
5
|
+
*
|
|
6
|
+
* user(); // the value — suspends under <Suspense>, exactly as before
|
|
7
|
+
* user.latest; // last settled value, kept across a refetch
|
|
8
|
+
* user.loading; // boolean
|
|
9
|
+
* user.error;
|
|
10
|
+
* user.refetch();
|
|
11
|
+
* user.mutate(next);
|
|
12
|
+
*
|
|
13
|
+
* `createResource` already hands back a callable carrying `loading`/`error`/`latest`,
|
|
14
|
+
* with only the two actions split into a second tuple slot — so this mostly folds that
|
|
15
|
+
* split away.
|
|
16
|
+
*
|
|
17
|
+
* The returned function IS the accessor `createResource` gave back, with the two actions
|
|
18
|
+
* assigned onto it — so suspending, tracking and SSR seeding are untouched, and a read is
|
|
19
|
+
* the same call it always was.
|
|
20
|
+
*/
|
|
21
|
+
import { createResource } from './graph/resource.js';
|
|
22
|
+
export function resource(...args) {
|
|
23
|
+
const [read, actions] = createResource(...args);
|
|
24
|
+
// Assigned onto the accessor itself, so `loading`/`error`/`latest` stay the live
|
|
25
|
+
// properties createResource put there rather than copies that would latch.
|
|
26
|
+
return Object.assign(read, actions);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var H=0,F=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},R=class extends k{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let n of[...this.observers])n.markDirty(v);A(this)}}peek(){return this._value}},T=class extends k{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===F&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(c){s=!0,a=c,i=this._value}finally{r.consumer=n,r.untracked=o}let w=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(v);A(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===H;if(this.state=n,o){if(this.observers)for(let i of[...this.observers])i.markDirty(F);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var _=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function C(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)C(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new T(()=>{C(this.owner,!1),I(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new _(()=>fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),C(this.owner))}};function $(e){let t=new E(e);return()=>t.dispose()}L(()=>{});var he=Symbol.for("signal");var ve=Symbol.for("signal-node");function h(e,t){let n=new R(e,{equals:t?.equals}),o=(()=>n.get()),i=(s=>{let a=typeof s=="function"?s(n.peek()):s;return n.set(a),U(),a});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,ve,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,i]}function B(e,t){let n=t;return $(()=>{n=e(n)})}function d(e){return Y(e)}function j(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function te(e){return Q?Q(e):void 0}var X=null;function ne(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function Te(e){return!!e&&typeof e.then=="function"}var V=Symbol();function oe(e,t,n={}){let o,i;typeof t=="function"?(o=typeof e=="function"?e:()=>e,i=t):(o=()=>!0,i=e,t&&typeof t=="object"&&(n=t));let s=n.transport===!1?void 0:ne(),a=s!==void 0?te(s):void 0,w=a!==void 0,[c,P]=h(a!==void 0?a.value:n.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=V,D=!1;B(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=V,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let S=D;if(D=!1,m!==V&&u===m&&!S)return;if(m=u,w){w=!1;return}let g=!1;N(()=>g=!0);let W=j(q),ae=j(c),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let l=i(u,{value:ae,refetching:z});Te(l)?(p(l),ee(l),l.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>l),f("ready"),p(void 0)})}catch(l){if(g)return;d(()=>{y(l),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},b=(()=>{let u=M();if(u)throw u;if(G()){let S=se();if(S)throw S}return c()});return Object.defineProperties(b,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:c}}),Object.defineProperty(b,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(b,Symbol.for("signal"),{value:!0,enumerable:!0}),[b,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}function Ne(...e){let[t,n]=oe(...e);return Object.assign(t,n)}export{Ne as resource};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of H(t))!W.call(e,o)&&o!==n&&m(e,o,{get:()=>t[o],enumerable:!(r=_(t,o))||r.enumerable});return e};var F=e=>C(m({},"__esModule",{value:!0}),e);var J={};z(J,{store:()=>G});module.exports=F(J);var i=require("@fluixi/reactive/signal"),h=Symbol("store-raw"),j=Symbol("store-node"),w=Symbol("store-has"),P=Symbol("store-self"),N=Symbol("store-track");var I=new WeakMap,U=new WeakMap;function M(e){let[t,n]=(0,i.createSignal)(e),r=t;return r.$=n,r}function p(e){let t=I.get(e);return t||I.set(e,t={keys:new Map}),t}function v(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=M(n)),r}function $(e){let t=p(e);(t.all||(t.all=M()))()}function D(e,t){e.$(typeof t=="function"?()=>t:t)}function E(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 l(e){if(!E(e))return e;let t=U.get(e);if(t)return t;let n=new Proxy(e,X);return U.set(e,n),n}var X={get(e,t,n){if(t===h||t===j)return e;if(t===i.$PROXY)return n;if(t===w)return a=>a in e;if(t==="__proxy")return!0;if(t===N||t===P)return $(e),n;let r=e[t];if(typeof r=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return r;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(n);let s=v(p(e),t,r)();return E(s)?l(s):s},set(){return!0},deleteProperty(e,t){return t in e&&u(e,t,void 0),!0},has(e,t){return t===h||t===i.$PROXY||t===j||t===w||t===P||t===N?!0:(v(p(e),t,e[t])(),t in e)},ownKeys(e){return $(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function u(e,t,n){if(e[t]===n&&(n!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;n===void 0?delete e[t]:e[t]=n;let a=p(e),c=a.keys.get(t);if(c&&D(c,n),o&&e.length!==s){let f=a.keys.get("length");f&&D(f,e.length)}a.all&&a.all.$(void 0)}function R(e,t){return typeof e=="function"?e(t):e}function A(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];r&&typeof r=="object"&&!Array.isArray(r)&&o&&typeof o=="object"&&!Array.isArray(o)?A(o,r):u(e,n,r)}}function g(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function K(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let a=t[s];if(a==="*"){let f=t.slice(s+1);if(Array.isArray(e))for(let T=0;T<e.length;T++)K(e[T],f,n);return}let c=e[a];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},u(e,a,c)),e=c}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)u(e,s,R(n,e[s]));return}u(e,o,R(n,e[o]))}function S(e,t,n){K(e,g(t),n)}function q(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&A(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&S(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){A(e,n);return}if(Array.isArray(t[1])&&t.length>=3){S(e,`${n}.${t[1].join(".")}`,t[2]);return}S(e,String(n),t[1])}function O(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(O);let t={};for(let n of Object.keys(e))t[n]=O(e[n]);return t}function y(e,t){let n=e;for(let r of g(t)){if(n==null)return;n=n[r]}return n}var d=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>(0,i.batch)(()=>q(this.root,r)))}get state(){return l(this.root)}get proxy(){return l(this.root)}get accessor(){return(()=>l(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return b(this.state);let n=this.state;for(let r of g(t)){if(n==null)return;n=n[r]}return b(n)}select(t){return(0,i.createMemo)(()=>t(this.state))}subscribe(t){return(0,i.createEffect)(()=>t(this.state))}watch(t,n){let r;return(0,i.createEffect)(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return(0,i.createMemo)(()=>this.state[t])}produce(t){this.set((n=>{let r=O(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=y(this.root,t);this.set(t,r.concat(n))}pop(t){let n=y(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=y(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=y(this.root,t).slice(),a=s.splice(n,r,...o);return this.set(t,s),a}insert(t,n,r){let o=y(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=y(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=(0,i.createSignal)(this.state);return t.toObservable()}dispose(){}},L=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function V(e,t){for(let n of L)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function x(e,t={immutable:!0}){let n=new d(e,t);return V(n.set,n),[n.proxy,n.set]}function Y(e,t={}){return new d(e,{...t,immutable:!1})}function b(e){if(e==null||typeof e!="object")return e;let t=e[h];return t!==void 0?t:e}function B(e){return(0,i.untrack)(()=>b(e))}var Z=Object.freeze({createStore:x,createMutableStore:Y,batch:i.batch,unwrap:b,untrackStore:B});function G(e,t){let[n,r]=x(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Immutable, Store, StoreOptions } from './store.js';
|
|
2
|
+
/** The reactive state, plus the setter that writes it. */
|
|
3
|
+
export type StoreHandle<T> = Immutable<T> & {
|
|
4
|
+
set: Store<T>['set'];
|
|
5
|
+
};
|
|
6
|
+
export declare function store<T>(initialState: T, options?: StoreOptions<T>): StoreHandle<T>;
|
|
7
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/lib/store/api.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,0DAA0D;AAC1D,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC;AAErE,wBAAgB,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAUnF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `store` — `createStore` as one binding instead of a tuple.
|
|
3
|
+
*
|
|
4
|
+
* const user = store({ name: 'Ada' });
|
|
5
|
+
* user.name; // reads, and tracks that key
|
|
6
|
+
* user.set({ name: 'Grace' }); // writes
|
|
7
|
+
*
|
|
8
|
+
* It returns the reactive state itself, with `set` on it. That's the difference from
|
|
9
|
+
* `signal`, and it's deliberate: `.get()` exists on a signal because a value has no
|
|
10
|
+
* other way to be read, while a store is an object whose whole point is that property
|
|
11
|
+
* access IS the read. Spelling it `user.get().name` would add a call to look uniform and
|
|
12
|
+
* lose the thing that makes a store worth using.
|
|
13
|
+
*
|
|
14
|
+
* Reads still subscribe per key, so an effect over `user.name` doesn't re-run when
|
|
15
|
+
* `user.role` changes.
|
|
16
|
+
*
|
|
17
|
+
* The one cost: a `set` key in your own state is shadowed by the setter. Reach for
|
|
18
|
+
* `createStore` if you need that name — it is unchanged.
|
|
19
|
+
*/
|
|
20
|
+
import { createStore } from './store.js';
|
|
21
|
+
export function store(initialState, options) {
|
|
22
|
+
const [state, set] = createStore(initialState, options);
|
|
23
|
+
// A thin wrapper rather than assigning onto the state: the store proxy is the tracking
|
|
24
|
+
// boundary, and writing a key through it would be a state change. Reads fall through
|
|
25
|
+
// to it untouched, so they subscribe exactly as they did before.
|
|
26
|
+
return new Proxy(state, {
|
|
27
|
+
get: (target, key) => (key === 'set' ? set : target[key]),
|
|
28
|
+
has: (target, key) => key === 'set' || Reflect.has(target, key),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$PROXY as g,batch as E,createEffect as x,createMemo as j,createSignal as K,untrack as z}from"@fluixi/reactive/signal";var m=Symbol("store-raw"),w=Symbol("store-node"),P=Symbol("store-has"),N=Symbol("store-self"),I=Symbol("store-track");var U=new WeakMap,v=new WeakMap;function _(e){let[t,n]=K(e),r=t;return r.$=n,r}function l(e){let t=U.get(e);return t||U.set(e,t={keys:new Map}),t}function $(e,t,n){let r=e.keys.get(t);return r||e.keys.set(t,r=_(n)),r}function D(e){let t=l(e);(t.all||(t.all=_()))()}function R(e,t){e.$(typeof t=="function"?()=>t:t)}function H(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 f(e){if(!H(e))return e;let t=v.get(e);if(t)return t;let n=new Proxy(e,C);return v.set(e,n),n}var C={get(e,t,n){if(t===m||t===w)return e;if(t===g)return n;if(t===P)return i=>i in e;if(t==="__proxy")return!0;if(t===I||t===N)return D(e),n;let r=e[t];if(typeof r=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return r;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(n);let s=$(l(e),t,r)();return H(s)?f(s):s},set(){return!0},deleteProperty(e,t){return t in e&&y(e,t,void 0),!0},has(e,t){return t===m||t===g||t===w||t===P||t===N||t===I?!0:($(l(e),t,e[t])(),t in e)},ownKeys(e){return D(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function y(e,t,n){if(e[t]===n&&(n!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;n===void 0?delete e[t]:e[t]=n;let i=l(e),a=i.keys.get(t);if(a&&R(a,n),o&&e.length!==s){let u=i.keys.get("length");u&&R(u,e.length)}i.all&&i.all.$(void 0)}function M(e,t){return typeof e=="function"?e(t):e}function S(e,t){for(let n of Object.keys(t)){let r=t[n],o=e[n];r&&typeof r=="object"&&!Array.isArray(r)&&o&&typeof o=="object"&&!Array.isArray(o)?S(o,r):y(e,n,r)}}function A(e){let t=[],n=e.replace(/\[([^\]]*)\]/g,".$1");for(let r of n.split("."))r.length&&t.push(r);return t}function W(e,t,n){let r=t.length-1;for(let s=0;s<r;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let b=0;b<e.length;b++)W(e[b],u,n);return}let a=e[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(t[s+1])?[]:{},y(e,i,a)),e=a}let o=t[r];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)y(e,s,M(n,e[s]));return}y(e,o,M(n,e[o]))}function T(e,t,n){W(e,A(t),n)}function F(e,t){let n=t[0];if(typeof n=="function"&&t.length===1){let r=n(e);r&&r!==e&&S(e,r);return}if(Array.isArray(n)&&t.length===1){for(let r of n)Array.isArray(r)&&T(e,r[0],r[1]);return}if(n&&typeof n=="object"&&!Array.isArray(n)&&t.length===1){S(e,n);return}if(Array.isArray(t[1])&&t.length>=3){T(e,`${n}.${t[1].join(".")}`,t[2]);return}T(e,String(n),t[1])}function h(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(h);let t={};for(let n of Object.keys(e))t[n]=h(e[n]);return t}function c(e,t){let n=e;for(let r of A(t)){if(n==null)return;n=n[r]}return n}var p=class{constructor(t,n={immutable:!0}){this.options=n;this.root=t,this.set=((...r)=>E(()=>F(this.root,r)))}get state(){return f(this.root)}get proxy(){return f(this.root)}get accessor(){return(()=>f(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return d(this.state);let n=this.state;for(let r of A(t)){if(n==null)return;n=n[r]}return d(n)}select(t){return j(()=>t(this.state))}subscribe(t){return x(()=>t(this.state))}watch(t,n){let r;return x(()=>{let o=t(this.state);Object.is(o,r)||(n(o,r),r=o)})}reactive(t){return j(()=>this.state[t])}produce(t){this.set((n=>{let r=h(n);return t(r),r}))}reconcile(t,n={}){this.set(t)}push(t,...n){let r=c(this.root,t);this.set(t,r.concat(n))}pop(t){let n=c(this.root,t).slice(),r=n.pop();return this.set(t,n),r}shift(t){let n=c(this.root,t).slice(),r=n.shift();return this.set(t,n),r}splice(t,n,r,...o){let s=c(this.root,t).slice(),i=s.splice(n,r,...o);return this.set(t,s),i}insert(t,n,r){let o=c(this.root,t).slice();o.splice(n,0,r),this.set(t,o)}removeAt(t,n){let r=c(this.root,t).slice(),o=r.splice(n,1);return this.set(t,r),o}toObservable(){let[t]=K(this.state);return t.toObservable()}dispose(){}},X=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function q(e,t){for(let n of X)e[n]=t[n].bind(t);e.$=t.reactive.bind(t)}function O(e,t={immutable:!0}){let n=new p(e,t);return q(n.set,n),[n.proxy,n.set]}function L(e,t={}){return new p(e,{...t,immutable:!1})}function d(e){if(e==null||typeof e!="object")return e;let t=e[m];return t!==void 0?t:e}function V(e){return z(()=>d(e))}var B=Object.freeze({createStore:O,createMutableStore:L,batch:E,unwrap:d,untrackStore:V});function Q(e,t){let[n,r]=O(e,t);return new Proxy(n,{get:(o,s)=>s==="set"?r:o[s],has:(o,s)=>s==="set"||Reflect.has(o,s)})}export{Q as store};
|
package/dist/lib/store/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var st=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ot(t))!nt.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=rt(t,n))||o.enumerable});return e};var at=e=>it(g({},"__esModule",{value:!0}),e);var ft={};st(ft,{$NAME:()=>H,$NODE:()=>u,$RAW:()=>d,$SELF:()=>S,$STORE:()=>W,$TRACK:()=>h,Store:()=>y,StoreAPI:()=>Z,createComputedStore:()=>X,createMutableStore:()=>$,createStore:()=>T,createStoreEffect:()=>q,createStoreMemo:()=>V,getNode:()=>G,getStoreNode:()=>J,isStore:()=>B,isStoreProxy:()=>O,modifiable:()=>Q,produceUtil:()=>k,reconcileUtil:()=>tt,store:()=>et,untrackStore:()=>I,unwrap:()=>p,wrap:()=>Y});module.exports=at(ft);var i=require("@fluixi/reactive/signal"),d=Symbol("store-raw"),u=Symbol("store-node"),R=Symbol("store-has"),S=Symbol("store-self"),h=Symbol("store-track"),H=Symbol("store-name"),W=Symbol("store-store"),D=new WeakMap,E=new WeakMap;function C(e){let[t,r]=(0,i.createSignal)(e),o=t;return o.$=r,o}function A(e){let t=D.get(e);return t||D.set(e,t={keys:new Map}),t}function M(e,t,r){let o=e.keys.get(t);return o||e.keys.set(t,o=C(r)),o}function v(e){let t=A(e);(t.all||(t.all=C()))()}function K(e,t){e.$(typeof t=="function"?()=>t:t)}function F(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 b(e){if(!F(e))return e;let t=E.get(e);if(t)return t;let r=new Proxy(e,ct);return E.set(e,r),r}var ct={get(e,t,r){if(t===d||t===u)return e;if(t===i.$PROXY)return r;if(t===R)return a=>a in e;if(t==="__proxy")return!0;if(t===h||t===S)return v(e),r;let o=e[t];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return o;let n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get)return n.get.call(r);let s=M(A(e),t,o)();return F(s)?b(s):s},set(){return!0},deleteProperty(e,t){return t in e&&l(e,t,void 0),!0},has(e,t){return t===d||t===i.$PROXY||t===u||t===R||t===S||t===h?!0:(M(A(e),t,e[t])(),t in e)},ownKeys(e){return v(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function l(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let n=Array.isArray(e),s=n?e.length:0;r===void 0?delete e[t]:e[t]=r;let a=A(e),c=a.keys.get(t);if(c&&K(c,r),n&&e.length!==s){let m=a.keys.get("length");m&&K(m,e.length)}a.all&&a.all.$(void 0)}function _(e,t){return typeof e=="function"?e(t):e}function w(e,t){for(let r of Object.keys(t)){let o=t[r],n=e[r];o&&typeof o=="object"&&!Array.isArray(o)&&n&&typeof n=="object"&&!Array.isArray(n)?w(n,o):l(e,r,o)}}function N(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let o of r.split("."))o.length&&t.push(o);return t}function z(e,t,r){let o=t.length-1;for(let s=0;s<o;s++){let a=t[s];if(a==="*"){let m=t.slice(s+1);if(Array.isArray(e))for(let x=0;x<e.length;x++)z(e[x],m,r);return}let c=e[a];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},l(e,a,c)),e=c}let n=t[o];if(n==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)l(e,s,_(r,e[s]));return}l(e,n,_(r,e[n]))}function j(e,t,r){z(e,N(t),r)}function yt(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let o=r(e);o&&o!==e&&w(e,o);return}if(Array.isArray(r)&&t.length===1){for(let o of r)Array.isArray(o)&&j(e,o[0],o[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){w(e,r);return}if(Array.isArray(t[1])&&t.length>=3){j(e,`${r}.${t[1].join(".")}`,t[2]);return}j(e,String(r),t[1])}function P(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(P);let t={};for(let r of Object.keys(e))t[r]=P(e[r]);return t}function f(e,t){let r=e;for(let o of N(t)){if(r==null)return;r=r[o]}return r}var y=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...o)=>(0,i.batch)(()=>yt(this.root,o)))}get state(){return b(this.root)}get proxy(){return b(this.root)}get accessor(){return(()=>b(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return p(this.state);let r=this.state;for(let o of N(t)){if(r==null)return;r=r[o]}return p(r)}select(t){return(0,i.createMemo)(()=>t(this.state))}subscribe(t){return(0,i.createEffect)(()=>t(this.state))}watch(t,r){let o;return(0,i.createEffect)(()=>{let n=t(this.state);Object.is(n,o)||(r(n,o),o=n)})}reactive(t){return(0,i.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let o=P(r);return t(o),o}))}reconcile(t,r={}){this.set(t)}push(t,...r){let o=f(this.root,t);this.set(t,o.concat(r))}pop(t){let r=f(this.root,t).slice(),o=r.pop();return this.set(t,r),o}shift(t){let r=f(this.root,t).slice(),o=r.shift();return this.set(t,r),o}splice(t,r,o,...n){let s=f(this.root,t).slice(),a=s.splice(r,o,...n);return this.set(t,s),a}insert(t,r,o){let n=f(this.root,t).slice();n.splice(r,0,o),this.set(t,n)}removeAt(t,r){let o=f(this.root,t).slice(),n=o.splice(r,1);return this.set(t,o),n}toObservable(){let[t]=(0,i.createSignal)(this.state);return t.toObservable()}dispose(){}},ut=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function L(e,t){for(let r of ut)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function T(e,t={immutable:!0}){let r=new y(e,t);return L(r.set,r),[r.proxy,r.set]}function $(e,t={}){return new y(e,{...t,immutable:!1})}function X(e,t={}){let r=new y(e(),t);return(0,i.createEffect)(()=>r.set(e())),r}function q(e,t,r){return(0,i.createEffect)(()=>r(t(e)))}function V(e,t,r){return(0,i.createMemo)(()=>t(e),void 0,r)}function Y(e,t={}){let r=new y(e,t),o=(()=>r.proxy);return L(o,r),o}function p(e){if(e==null||typeof e!="object")return e;let t=e[d];return t!==void 0?t:e}function I(e){return(0,i.untrack)(()=>p(e))}function B(e){return O(e)}function G(e){return O(e)?e[u]:null}function J(e){return e&&typeof e=="object"&&u in e?e[u]:null}function O(e){return!!e&&typeof e=="object"&&(i.$PROXY in e||e.__proxy===!0)}function Q(e){return e}var Z=Object.freeze({createStore:T,createMutableStore:$,batch:i.batch,unwrap:p,untrackStore:I});function U(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(U);let t={};for(let r of Object.keys(e))t[r]=U(e[r]);return t}function k(e){return t=>{let r=U(t);return e(r),r}}function tt(e,t={}){return()=>e}function et(e,t){let[r,o]=T(e,t);return new Proxy(r,{get:(n,s)=>s==="set"?o:n[s],has:(n,s)=>s==="set"||Reflect.has(n,s)})}
|
|
@@ -11,4 +11,6 @@ export { createStore, createMutableStore, createComputedStore, createStoreEffect
|
|
|
11
11
|
export type { StoreSetter, StoreAccessor, StoreOptions, Immutable, } from './store.js';
|
|
12
12
|
export { produce as produceUtil, reconcile as reconcileUtil } from './utils.js';
|
|
13
13
|
export type { ReconcileOptions, Producer } from './types.js';
|
|
14
|
+
export { store } from './api.js';
|
|
15
|
+
export type { StoreHandle } from './api.js';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhF,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhF,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/lib/store/index.js
CHANGED
|
@@ -9,3 +9,5 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { createStore, createMutableStore, createComputedStore, createStoreEffect, createStoreMemo, wrap, unwrap, getStoreNode, isStoreProxy, modifiable, untrackStore, StoreAPI, $RAW, $NODE, $TRACK, $NAME, $STORE, $SELF, Store, isStore, getNode, } from './store.js';
|
|
11
11
|
export { produce as produceUtil, reconcile as reconcileUtil } from './utils.js';
|
|
12
|
+
// The short API — one object instead of a tuple, matching `signal`.
|
|
13
|
+
export { store } from './api.js';
|
package/dist/lib/store/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$PROXY as
|
|
1
|
+
import{$PROXY as O,batch as _,createEffect as T,createMemo as x,createSignal as H,untrack as q}from"@fluixi/reactive/signal";var m=Symbol("store-raw"),u=Symbol("store-node"),U=Symbol("store-has"),g=Symbol("store-self"),j=Symbol("store-track"),V=Symbol("store-name"),Y=Symbol("store-store"),R=new WeakMap,D=new WeakMap;function W(e){let[t,r]=H(e),o=t;return o.$=r,o}function b(e){let t=R.get(e);return t||R.set(e,t={keys:new Map}),t}function E(e,t,r){let o=e.keys.get(t);return o||e.keys.set(t,o=W(r)),o}function M(e){let t=b(e);(t.all||(t.all=W()))()}function v(e,t){e.$(typeof t=="function"?()=>t:t)}function C(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 d(e){if(!C(e))return e;let t=D.get(e);if(t)return t;let r=new Proxy(e,B);return D.set(e,r),r}var B={get(e,t,r){if(t===m||t===u)return e;if(t===O)return r;if(t===U)return i=>i in e;if(t==="__proxy")return!0;if(t===j||t===g)return M(e),r;let o=e[t];if(typeof o=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return o;let n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get)return n.get.call(r);let s=E(b(e),t,o)();return C(s)?d(s):s},set(){return!0},deleteProperty(e,t){return t in e&&f(e,t,void 0),!0},has(e,t){return t===m||t===O||t===u||t===U||t===g||t===j?!0:(E(b(e),t,e[t])(),t in e)},ownKeys(e){return M(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function f(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let n=Array.isArray(e),s=n?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=b(e),a=i.keys.get(t);if(a&&v(a,r),n&&e.length!==s){let l=i.keys.get("length");l&&v(l,e.length)}i.all&&i.all.$(void 0)}function K(e,t){return typeof e=="function"?e(t):e}function w(e,t){for(let r of Object.keys(t)){let o=t[r],n=e[r];o&&typeof o=="object"&&!Array.isArray(o)&&n&&typeof n=="object"&&!Array.isArray(n)?w(n,o):f(e,r,o)}}function N(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let o of r.split("."))o.length&&t.push(o);return t}function F(e,t,r){let o=t.length-1;for(let s=0;s<o;s++){let i=t[s];if(i==="*"){let l=t.slice(s+1);if(Array.isArray(e))for(let h=0;h<e.length;h++)F(e[h],l,r);return}let a=e[i];(a==null||typeof a!="object")&&(a=/^\d+$/.test(t[s+1])?[]:{},f(e,i,a)),e=a}let n=t[o];if(n==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)f(e,s,K(r,e[s]));return}f(e,n,K(r,e[n]))}function A(e,t,r){F(e,N(t),r)}function G(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let o=r(e);o&&o!==e&&w(e,o);return}if(Array.isArray(r)&&t.length===1){for(let o of r)Array.isArray(o)&&A(e,o[0],o[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){w(e,r);return}if(Array.isArray(t[1])&&t.length>=3){A(e,`${r}.${t[1].join(".")}`,t[2]);return}A(e,String(r),t[1])}function P(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(P);let t={};for(let r of Object.keys(e))t[r]=P(e[r]);return t}function y(e,t){let r=e;for(let o of N(t)){if(r==null)return;r=r[o]}return r}var c=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...o)=>_(()=>G(this.root,o)))}get state(){return d(this.root)}get proxy(){return d(this.root)}get accessor(){return(()=>d(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return p(this.state);let r=this.state;for(let o of N(t)){if(r==null)return;r=r[o]}return p(r)}select(t){return x(()=>t(this.state))}subscribe(t){return T(()=>t(this.state))}watch(t,r){let o;return T(()=>{let n=t(this.state);Object.is(n,o)||(r(n,o),o=n)})}reactive(t){return x(()=>this.state[t])}produce(t){this.set((r=>{let o=P(r);return t(o),o}))}reconcile(t,r={}){this.set(t)}push(t,...r){let o=y(this.root,t);this.set(t,o.concat(r))}pop(t){let r=y(this.root,t).slice(),o=r.pop();return this.set(t,r),o}shift(t){let r=y(this.root,t).slice(),o=r.shift();return this.set(t,r),o}splice(t,r,o,...n){let s=y(this.root,t).slice(),i=s.splice(r,o,...n);return this.set(t,s),i}insert(t,r,o){let n=y(this.root,t).slice();n.splice(r,0,o),this.set(t,n)}removeAt(t,r){let o=y(this.root,t).slice(),n=o.splice(r,1);return this.set(t,o),n}toObservable(){let[t]=H(this.state);return t.toObservable()}dispose(){}},J=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function z(e,t){for(let r of J)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function S(e,t={immutable:!0}){let r=new c(e,t);return z(r.set,r),[r.proxy,r.set]}function L(e,t={}){return new c(e,{...t,immutable:!1})}function Q(e,t={}){let r=new c(e(),t);return T(()=>r.set(e())),r}function Z(e,t,r){return T(()=>r(t(e)))}function k(e,t,r){return x(()=>t(e),void 0,r)}function tt(e,t={}){let r=new c(e,t),o=(()=>r.proxy);return z(o,r),o}function p(e){if(e==null||typeof e!="object")return e;let t=e[m];return t!==void 0?t:e}function X(e){return q(()=>p(e))}function et(e){return $(e)}function rt(e){return $(e)?e[u]:null}function ot(e){return e&&typeof e=="object"&&u in e?e[u]:null}function $(e){return!!e&&typeof e=="object"&&(O in e||e.__proxy===!0)}function nt(e){return e}var st=Object.freeze({createStore:S,createMutableStore:L,batch:_,unwrap:p,untrackStore:X});function I(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(I);let t={};for(let r of Object.keys(e))t[r]=I(e[r]);return t}function it(e){return t=>{let r=I(t);return e(r),r}}function at(e,t={}){return()=>e}function ct(e,t){let[r,o]=S(e,t);return new Proxy(r,{get:(n,s)=>s==="set"?o:n[s],has:(n,s)=>s==="set"||Reflect.has(n,s)})}export{V as $NAME,u as $NODE,m as $RAW,g as $SELF,Y as $STORE,j as $TRACK,c as Store,st as StoreAPI,Q as createComputedStore,L as createMutableStore,S as createStore,Z as createStoreEffect,k as createStoreMemo,rt as getNode,ot as getStoreNode,et as isStore,$ as isStoreProxy,nt as modifiable,it as produceUtil,at as reconcileUtil,ct as store,X as untrackStore,p as unwrap,tt as wrap};
|