@fluixi/reactive 1.0.0-alpha.53
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/LICENSE +21 -0
- package/README.md +343 -0
- package/dist/cdn/reactive.cjs +1 -0
- package/dist/cdn/reactive.d.ts +11 -0
- package/dist/cdn/reactive.d.ts.map +1 -0
- package/dist/cdn/reactive.global.js +1 -0
- package/dist/cdn/reactive.js +10 -0
- package/dist/cdn/reactive.mjs +1 -0
- package/dist/cdn/signal.cjs +1 -0
- package/dist/cdn/signal.d.ts +19 -0
- package/dist/cdn/signal.d.ts.map +1 -0
- package/dist/cdn/signal.global.js +1 -0
- package/dist/cdn/signal.js +18 -0
- package/dist/cdn/signal.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/observable/index.cjs +1 -0
- package/dist/lib/observable/index.d.ts +4 -0
- package/dist/lib/observable/index.d.ts.map +1 -0
- package/dist/lib/observable/index.js +3 -0
- package/dist/lib/observable/index.mjs +1 -0
- package/dist/lib/observable/observable.cjs +1 -0
- package/dist/lib/observable/observable.d.ts +383 -0
- package/dist/lib/observable/observable.d.ts.map +1 -0
- package/dist/lib/observable/observable.js +339 -0
- package/dist/lib/observable/observable.mjs +1 -0
- package/dist/lib/observable/subscription.cjs +1 -0
- package/dist/lib/observable/subscription.d.ts +70 -0
- package/dist/lib/observable/subscription.d.ts.map +1 -0
- package/dist/lib/observable/subscription.js +190 -0
- package/dist/lib/observable/subscription.mjs +1 -0
- package/dist/lib/observable/types.cjs +1 -0
- package/dist/lib/observable/types.d.ts +44 -0
- package/dist/lib/observable/types.d.ts.map +1 -0
- package/dist/lib/observable/types.js +1 -0
- package/dist/lib/observable/types.mjs +0 -0
- package/dist/lib/signal/cached-resource.cjs +1 -0
- package/dist/lib/signal/cached-resource.d.ts +94 -0
- package/dist/lib/signal/cached-resource.d.ts.map +1 -0
- package/dist/lib/signal/cached-resource.js +257 -0
- package/dist/lib/signal/cached-resource.mjs +1 -0
- package/dist/lib/signal/graph/children.cjs +1 -0
- package/dist/lib/signal/graph/children.d.ts +2 -0
- package/dist/lib/signal/graph/children.d.ts.map +1 -0
- package/dist/lib/signal/graph/children.js +30 -0
- package/dist/lib/signal/graph/children.mjs +1 -0
- package/dist/lib/signal/graph/compat.cjs +1 -0
- package/dist/lib/signal/graph/compat.d.ts +64 -0
- package/dist/lib/signal/graph/compat.d.ts.map +1 -0
- package/dist/lib/signal/graph/compat.js +178 -0
- package/dist/lib/signal/graph/compat.mjs +1 -0
- package/dist/lib/signal/graph/core.cjs +1 -0
- package/dist/lib/signal/graph/core.d.ts +95 -0
- package/dist/lib/signal/graph/core.d.ts.map +1 -0
- package/dist/lib/signal/graph/core.js +254 -0
- package/dist/lib/signal/graph/core.mjs +1 -0
- package/dist/lib/signal/graph/derived.cjs +1 -0
- package/dist/lib/signal/graph/derived.d.ts +14 -0
- package/dist/lib/signal/graph/derived.d.ts.map +1 -0
- package/dist/lib/signal/graph/derived.js +81 -0
- package/dist/lib/signal/graph/derived.mjs +1 -0
- package/dist/lib/signal/graph/detect.cjs +1 -0
- package/dist/lib/signal/graph/detect.d.ts +16 -0
- package/dist/lib/signal/graph/detect.d.ts.map +1 -0
- package/dist/lib/signal/graph/detect.js +36 -0
- package/dist/lib/signal/graph/detect.mjs +1 -0
- package/dist/lib/signal/graph/error-boundary.cjs +1 -0
- package/dist/lib/signal/graph/error-boundary.d.ts +16 -0
- package/dist/lib/signal/graph/error-boundary.d.ts.map +1 -0
- package/dist/lib/signal/graph/error-boundary.js +34 -0
- package/dist/lib/signal/graph/error-boundary.mjs +1 -0
- package/dist/lib/signal/graph/index.cjs +1 -0
- package/dist/lib/signal/graph/index.d.ts +21 -0
- package/dist/lib/signal/graph/index.d.ts.map +1 -0
- package/dist/lib/signal/graph/index.js +20 -0
- package/dist/lib/signal/graph/index.mjs +1 -0
- package/dist/lib/signal/graph/resource.cjs +1 -0
- package/dist/lib/signal/graph/resource.d.ts +36 -0
- package/dist/lib/signal/graph/resource.d.ts.map +1 -0
- package/dist/lib/signal/graph/resource.js +156 -0
- package/dist/lib/signal/graph/resource.mjs +1 -0
- package/dist/lib/signal/graph/runtime.cjs +1 -0
- package/dist/lib/signal/graph/runtime.d.ts +56 -0
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -0
- package/dist/lib/signal/graph/runtime.js +277 -0
- package/dist/lib/signal/graph/runtime.mjs +1 -0
- package/dist/lib/signal/graph/signal-next.cjs +1 -0
- package/dist/lib/signal/graph/signal-next.d.ts +37 -0
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -0
- package/dist/lib/signal/graph/signal-next.js +41 -0
- package/dist/lib/signal/graph/signal-next.mjs +1 -0
- package/dist/lib/signal/graph/ssr-hooks.cjs +1 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts +28 -0
- package/dist/lib/signal/graph/ssr-hooks.d.ts.map +1 -0
- package/dist/lib/signal/graph/ssr-hooks.js +45 -0
- package/dist/lib/signal/graph/ssr-hooks.mjs +1 -0
- package/dist/lib/signal/graph/state.cjs +1 -0
- package/dist/lib/signal/graph/state.d.ts +43 -0
- package/dist/lib/signal/graph/state.d.ts.map +1 -0
- package/dist/lib/signal/graph/state.js +37 -0
- package/dist/lib/signal/graph/state.mjs +1 -0
- package/dist/lib/signal/graph/suspense.cjs +1 -0
- package/dist/lib/signal/graph/suspense.d.ts +13 -0
- package/dist/lib/signal/graph/suspense.d.ts.map +1 -0
- package/dist/lib/signal/graph/suspense.js +36 -0
- package/dist/lib/signal/graph/suspense.mjs +1 -0
- package/dist/lib/signal/index-legacy.cjs +1 -0
- package/dist/lib/signal/index-legacy.d.ts +12 -0
- package/dist/lib/signal/index-legacy.d.ts.map +1 -0
- package/dist/lib/signal/index-legacy.js +11 -0
- package/dist/lib/signal/index-legacy.mjs +1 -0
- package/dist/lib/signal/index.cjs +1 -0
- package/dist/lib/signal/index.d.ts +12 -0
- package/dist/lib/signal/index.d.ts.map +1 -0
- package/dist/lib/signal/index.js +11 -0
- package/dist/lib/signal/index.mjs +1 -0
- package/dist/lib/signal/list.cjs +1 -0
- package/dist/lib/signal/list.d.ts +39 -0
- package/dist/lib/signal/list.d.ts.map +1 -0
- package/dist/lib/signal/list.js +172 -0
- package/dist/lib/signal/list.mjs +1 -0
- package/dist/lib/signal/signal.cjs +1 -0
- package/dist/lib/signal/signal.d.ts +295 -0
- package/dist/lib/signal/signal.d.ts.map +1 -0
- package/dist/lib/signal/signal.js +1219 -0
- package/dist/lib/signal/signal.mjs +1 -0
- package/dist/lib/signal/types.cjs +1 -0
- package/dist/lib/signal/types.d.ts +133 -0
- package/dist/lib/signal/types.d.ts.map +1 -0
- package/dist/lib/signal/types.js +38 -0
- package/dist/lib/signal/types.mjs +1 -0
- package/dist/lib/signal/utilities.cjs +1 -0
- package/dist/lib/signal/utilities.d.ts +355 -0
- package/dist/lib/signal/utilities.d.ts.map +1 -0
- package/dist/lib/signal/utilities.js +504 -0
- package/dist/lib/signal/utilities.mjs +1 -0
- package/dist/lib/store/index.cjs +1 -0
- package/dist/lib/store/index.d.ts +14 -0
- package/dist/lib/store/index.d.ts.map +1 -0
- package/dist/lib/store/index.js +11 -0
- package/dist/lib/store/index.mjs +1 -0
- package/dist/lib/store/setter.types.cjs +1 -0
- package/dist/lib/store/setter.types.d.ts +79 -0
- package/dist/lib/store/setter.types.d.ts.map +1 -0
- package/dist/lib/store/setter.types.js +65 -0
- package/dist/lib/store/setter.types.mjs +0 -0
- package/dist/lib/store/store.cjs +1 -0
- package/dist/lib/store/store.d.ts +86 -0
- package/dist/lib/store/store.d.ts.map +1 -0
- package/dist/lib/store/store.js +442 -0
- package/dist/lib/store/store.mjs +1 -0
- package/dist/lib/store/types.cjs +1 -0
- package/dist/lib/store/types.d.ts +57 -0
- package/dist/lib/store/types.d.ts.map +1 -0
- package/dist/lib/store/types.js +1 -0
- package/dist/lib/store/types.mjs +0 -0
- package/dist/lib/store/utils.cjs +1 -0
- package/dist/lib/store/utils.d.ts +13 -0
- package/dist/lib/store/utils.d.ts.map +1 -0
- package/dist/lib/store/utils.js +29 -0
- package/dist/lib/store/utils.mjs +1 -0
- package/dist/lib/subject.cjs +1 -0
- package/dist/lib/subject.d.ts +14 -0
- package/dist/lib/subject.d.ts.map +1 -0
- package/dist/lib/subject.js +169 -0
- package/dist/lib/subject.mjs +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var le=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!He.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Je=e=>Ye(le({},"__esModule",{value:!0}),e);var Ot={};Ke(Ot,{clearAllCachedResources:()=>gt,clearCachedResourceNamespace:()=>St,createCachedResource:()=>xt});module.exports=Je(Ot);var Oe=require("@fluixi/utils/object"),ce=require("@fluixi/utils/functions"),G=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if((0,ce.isFunction)(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if((0,Oe.isObject)(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if((0,ce.isFunction)(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends G{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},fe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends G{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new fe(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var Te=require("@fluixi/utils");var Xe=Symbol.for("signal");function Re(e){return typeof e=="function"&&e[Xe]===!0}var Qe="__fluixi_signal_next_state__",Ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Qe]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ze,onSuspend:null,onError:null};var Ce=0,_e=1,J=2,de=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends de{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===_e&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ce}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ae(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Ce;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(_e);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Pe(){return h.owner}function Fe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function ke(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function et(e){return!!e&&typeof e.then=="function"}ke(()=>{});var tt=Symbol.for("signal"),nt=Symbol.for("memo");function Q(e,t,n){let o=t,r=Pe(),s=new X(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(et(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,tt,{value:!0,enumerable:!0}),Object.defineProperty(a,nt,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Re(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Q(e);return Q(()=>Z(t()))}var Ne=null;function pe(e){Ne&&Ne(e)}var rt=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),ot=Symbol.for("signal-node"),V=0,ve=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,st=!1,he=!1,N=0,it=1e6,O=new WeakMap,ee=null;var ut=new Map,at=0;function lt(){return`node_${++at}_${Date.now()}`}function ct(e){!1}function ft(e,t,n){let o={id:lt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ct(o),o}function dt(e,t){return e===t}function Le(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function pt(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)be(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ue(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ie in n&&delete n[Ie];let o=ft("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||dt;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=ve,st&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===V||m===ve?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(R),x=[],S=new Set;Ue(P,F);for(let l of x)pt(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return ye(()=>{let j=a();b?b=!1:d.next(j)})}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),Object.defineProperty(a,ot,{value:o,enumerable:!1}),r}function ye(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Me(o,t),()=>U(o)}function Me(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>it)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if((0,Te.isPromise)(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=n,c=o}}function be(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===re||e.state===ve||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Ge(e):Me(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&be(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ht()}}function ht(){if(!he){he=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)be(e[t])}}finally{he=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Be(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function vt(e){let t=Symbol("context"),n=Tt(t);return{id:t,Provider:n,defaultValue:e}}function Tt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return yt(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),qe(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function yt(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ge(o),()=>U(o)}function Ge(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=V)}catch(r){if((0,Te.isPromise)(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Ve(){return w||(w=vt())}var E=new Map,A=new Map,bt=0,mt=Symbol.for("signal"),wt=Symbol.for("resource");function xt(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${bt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[je,me]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function we(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){pe(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)})}function xe(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Se(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;ye(()=>{z===void 0&&(z=Ve());let u=o();if(je(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=E.get(g);if(q&&j(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),we(u,g,!0,()=>p);return}let ge=L(x),$e=ge==="ready"||ge==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),we(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,wt,{value:!0,enumerable:!0}),Object.defineProperty(H,mt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,me(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,me(T=>T+1)}}]}function St(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function gt(){E.clear(),A.clear()}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createCachedResource — reactive resource with TTL-based caching.
|
|
3
|
+
*
|
|
4
|
+
* Fetches once and returns the cached result for subsequent reads within the
|
|
5
|
+
* TTL window. After the TTL expires the next read triggers a re-fetch.
|
|
6
|
+
*
|
|
7
|
+
* Two forms (mirrors createResource):
|
|
8
|
+
*
|
|
9
|
+
* // 1. no reactive source
|
|
10
|
+
* const [data, { refetch, invalidate }] = createCachedResource(
|
|
11
|
+
* () => apiClient.get('/data'),
|
|
12
|
+
* { ttl: 5 * 60_000, name: 'my-data' }
|
|
13
|
+
* );
|
|
14
|
+
*
|
|
15
|
+
* // 2. reactive source (re-fetches when source value changes)
|
|
16
|
+
* const [data, { refetch, invalidate }] = createCachedResource(
|
|
17
|
+
* () => workspaceId(),
|
|
18
|
+
* (id) => apiClient.get(`/workspaces/${id}`),
|
|
19
|
+
* { ttl: 5 * 60_000, name: 'workspace' }
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* Options:
|
|
23
|
+
* ttl — cache lifetime in ms. Default: Infinity (manual invalidate only)
|
|
24
|
+
* name — cache namespace. If omitted, each call-site gets its own isolated cache.
|
|
25
|
+
* staleWhileRevalidate — when true (default), show stale data while background-fetching.
|
|
26
|
+
* When false, show a loading state during revalidation.
|
|
27
|
+
*
|
|
28
|
+
* Resource shape (same as createResource):
|
|
29
|
+
* data() — current value (throws pending promise during initial load for Suspense)
|
|
30
|
+
* data.loading — true during initial load
|
|
31
|
+
* data.latest — value without throwing
|
|
32
|
+
* data.error — last error
|
|
33
|
+
* data.stale — true when showing stale data during background revalidation
|
|
34
|
+
*
|
|
35
|
+
* Actions:
|
|
36
|
+
* refetch() — force re-fetch regardless of TTL, keeps showing current value while loading
|
|
37
|
+
* invalidate() — delete cache entry and re-fetch (shows loading on next read)
|
|
38
|
+
*/
|
|
39
|
+
import { type Setter, type Resource } from './signal.js';
|
|
40
|
+
export interface CachedResourceOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Cache lifetime in milliseconds.
|
|
43
|
+
* Default: `Infinity` — data lives until `invalidate()` is called.
|
|
44
|
+
*/
|
|
45
|
+
ttl?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Cache namespace. Two calls that share the same `name` share their cache
|
|
48
|
+
* entries. When omitted, each `createCachedResource` call-site gets a
|
|
49
|
+
* private cache isolated from all others.
|
|
50
|
+
*/
|
|
51
|
+
name?: string;
|
|
52
|
+
/**
|
|
53
|
+
* When `true` (default), stale data is returned immediately while a
|
|
54
|
+
* background re-fetch runs. The resource stays in `state='ready'` and
|
|
55
|
+
* `stale=true` during revalidation — no loading skeleton.
|
|
56
|
+
*
|
|
57
|
+
* When `false`, a foreground re-fetch is triggered that sets
|
|
58
|
+
* `state='refreshing'` (data is still visible but `loading=true`).
|
|
59
|
+
*/
|
|
60
|
+
staleWhileRevalidate?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export type CachedResource<T> = Resource<T> & {
|
|
63
|
+
/** `true` while serving stale data during a background re-fetch. */
|
|
64
|
+
stale: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type CachedResourceReturn<T> = [
|
|
67
|
+
CachedResource<T>,
|
|
68
|
+
{
|
|
69
|
+
mutate: Setter<T | undefined>;
|
|
70
|
+
/** Force re-fetch, bypassing TTL. Current value stays visible. */
|
|
71
|
+
refetch: () => void;
|
|
72
|
+
/** Delete the cache entry for the current key and trigger a fresh fetch. */
|
|
73
|
+
invalidate: () => void;
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* No-source overload — fetch is not keyed by any reactive value.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createCachedResource<T>(fetcher: () => Promise<T> | T, options?: CachedResourceOptions): CachedResourceReturn<T>;
|
|
80
|
+
/**
|
|
81
|
+
* With-source overload — fetch re-runs whenever the source accessor returns a
|
|
82
|
+
* new value (falsy source suspends the fetch, same as `createResource`).
|
|
83
|
+
*/
|
|
84
|
+
export declare function createCachedResource<T, S>(source: () => S | false | null | undefined, fetcher: (key: S) => Promise<T> | T, options?: CachedResourceOptions): CachedResourceReturn<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Clear all TTL cache entries for a given namespace (name).
|
|
87
|
+
* Useful to invalidate a whole category of data at once.
|
|
88
|
+
*/
|
|
89
|
+
export declare function clearCachedResourceNamespace(name: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Clear the entire TTL cache. Useful on logout / workspace switch.
|
|
92
|
+
*/
|
|
93
|
+
export declare function clearAllCachedResources(): void;
|
|
94
|
+
//# sourceMappingURL=cached-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-resource.d.ts","sourceRoot":"","sources":["../../../src/lib/signal/cached-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EASL,KAAK,MAAM,EACX,KAAK,QAAQ,EAEd,MAAM,aAAa,CAAC;AAgBrB,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG;IAC5C,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,cAAc,CAAC,CAAC,CAAC;IACjB;QACE,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;QAC9B,kEAAkE;QAClE,OAAO,EAAE,MAAM,IAAI,CAAC;QACpB,4EAA4E;QAC5E,UAAU,EAAE,MAAM,IAAI,CAAC;KACxB;CACF,CAAC;AAQF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC7B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAE3B;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EACvC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,EAC1C,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EACnC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAoP3B;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAK/D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createCachedResource — reactive resource with TTL-based caching.
|
|
3
|
+
*
|
|
4
|
+
* Fetches once and returns the cached result for subsequent reads within the
|
|
5
|
+
* TTL window. After the TTL expires the next read triggers a re-fetch.
|
|
6
|
+
*
|
|
7
|
+
* Two forms (mirrors createResource):
|
|
8
|
+
*
|
|
9
|
+
* // 1. no reactive source
|
|
10
|
+
* const [data, { refetch, invalidate }] = createCachedResource(
|
|
11
|
+
* () => apiClient.get('/data'),
|
|
12
|
+
* { ttl: 5 * 60_000, name: 'my-data' }
|
|
13
|
+
* );
|
|
14
|
+
*
|
|
15
|
+
* // 2. reactive source (re-fetches when source value changes)
|
|
16
|
+
* const [data, { refetch, invalidate }] = createCachedResource(
|
|
17
|
+
* () => workspaceId(),
|
|
18
|
+
* (id) => apiClient.get(`/workspaces/${id}`),
|
|
19
|
+
* { ttl: 5 * 60_000, name: 'workspace' }
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* Options:
|
|
23
|
+
* ttl — cache lifetime in ms. Default: Infinity (manual invalidate only)
|
|
24
|
+
* name — cache namespace. If omitted, each call-site gets its own isolated cache.
|
|
25
|
+
* staleWhileRevalidate — when true (default), show stale data while background-fetching.
|
|
26
|
+
* When false, show a loading state during revalidation.
|
|
27
|
+
*
|
|
28
|
+
* Resource shape (same as createResource):
|
|
29
|
+
* data() — current value (throws pending promise during initial load for Suspense)
|
|
30
|
+
* data.loading — true during initial load
|
|
31
|
+
* data.latest — value without throwing
|
|
32
|
+
* data.error — last error
|
|
33
|
+
* data.stale — true when showing stale data during background revalidation
|
|
34
|
+
*
|
|
35
|
+
* Actions:
|
|
36
|
+
* refetch() — force re-fetch regardless of TTL, keeps showing current value while loading
|
|
37
|
+
* invalidate() — delete cache entry and re-fetch (shows loading on next read)
|
|
38
|
+
*/
|
|
39
|
+
import { createSignal, createEffect, onCleanup, batch, untrack, useContext, getSuspenseContext, trackResourcePromise, } from './signal.js';
|
|
40
|
+
const ttlCache = new Map();
|
|
41
|
+
const inflight = new Map();
|
|
42
|
+
let _autoId = 0;
|
|
43
|
+
// ── Symbol constants (must match signal.ts) ───────────────────────────────────
|
|
44
|
+
const $SIGNAL = Symbol.for('signal');
|
|
45
|
+
const $RESOURCE = Symbol.for('resource');
|
|
46
|
+
export function createCachedResource(sourceOrFetcher, fetcherOrOptions, opts = {}) {
|
|
47
|
+
// ── Normalise overloads ──────────────────────────────────────────────────
|
|
48
|
+
let sourceFn;
|
|
49
|
+
let fetchFn;
|
|
50
|
+
let options;
|
|
51
|
+
if (typeof fetcherOrOptions === 'function') {
|
|
52
|
+
sourceFn = sourceOrFetcher;
|
|
53
|
+
fetchFn = fetcherOrOptions;
|
|
54
|
+
options = opts;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// No source — treat the first arg as fetcher, source = () => true
|
|
58
|
+
sourceFn = () => true;
|
|
59
|
+
fetchFn = sourceOrFetcher;
|
|
60
|
+
options = fetcherOrOptions ?? opts;
|
|
61
|
+
}
|
|
62
|
+
const { ttl = Infinity, name = `_auto_${_autoId++}`, staleWhileRevalidate = true, } = options;
|
|
63
|
+
const ns = name;
|
|
64
|
+
const buildKey = (key) => `${ns}:${JSON.stringify(key)}`;
|
|
65
|
+
const isFresh = (entry) => ttl === Infinity || Date.now() - entry.timestamp <= ttl;
|
|
66
|
+
// ── Reactive state ────────────────────────────────────────────────────────
|
|
67
|
+
const [value, setValue] = createSignal(undefined, { equals: false });
|
|
68
|
+
const [resourceState, setResourceState] = createSignal('unresolved', { equals: false });
|
|
69
|
+
const [resourceError, setResourceError] = createSignal(undefined, { equals: false });
|
|
70
|
+
const [pendingP, setPendingP] = createSignal(undefined, { equals: false });
|
|
71
|
+
const [isStale, setIsStale] = createSignal(false);
|
|
72
|
+
const [tick, setTick] = createSignal(0, { equals: false });
|
|
73
|
+
const UNSET = Symbol('unset');
|
|
74
|
+
let prevKey = UNSET;
|
|
75
|
+
let flagRefetch = false;
|
|
76
|
+
let flagInvalidate = false;
|
|
77
|
+
// ── Fetch helper ──────────────────────────────────────────────────────────
|
|
78
|
+
function doFetch(key, ck, background, isCancelled) {
|
|
79
|
+
// Attach to an in-flight request for the same key (dedup).
|
|
80
|
+
if (inflight.has(ck)) {
|
|
81
|
+
inflight.get(ck).then((v) => { if (!isCancelled())
|
|
82
|
+
settle(v, background); }, (e) => { if (!isCancelled() && !background)
|
|
83
|
+
fail(e); });
|
|
84
|
+
if (!background)
|
|
85
|
+
setPendingP(inflight.get(ck));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const promise = Promise.resolve(fetchFn(key)).then((v) => {
|
|
89
|
+
ttlCache.set(ck, { value: v, timestamp: Date.now() });
|
|
90
|
+
inflight.delete(ck);
|
|
91
|
+
return v;
|
|
92
|
+
}, (e) => {
|
|
93
|
+
inflight.delete(ck);
|
|
94
|
+
throw e;
|
|
95
|
+
});
|
|
96
|
+
inflight.set(ck, promise);
|
|
97
|
+
if (!background) {
|
|
98
|
+
trackResourcePromise(promise); // server async SSR: collect & await
|
|
99
|
+
setPendingP(promise);
|
|
100
|
+
// Register with nearest Suspense boundary for initial loads.
|
|
101
|
+
const suspCtx = _SuspenseContext && useContext(_SuspenseContext);
|
|
102
|
+
if (suspCtx) {
|
|
103
|
+
suspCtx.increment();
|
|
104
|
+
promise.finally(() => suspCtx.decrement());
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
promise.then((v) => { if (!isCancelled())
|
|
108
|
+
settle(v, background); }, (e) => { if (!isCancelled() && !background)
|
|
109
|
+
fail(e); });
|
|
110
|
+
}
|
|
111
|
+
function settle(v, background) {
|
|
112
|
+
batch(() => {
|
|
113
|
+
setValue(() => v);
|
|
114
|
+
setResourceState('ready');
|
|
115
|
+
setIsStale(false);
|
|
116
|
+
setPendingP(undefined);
|
|
117
|
+
setResourceError(undefined);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function fail(e) {
|
|
121
|
+
batch(() => {
|
|
122
|
+
setResourceError(e);
|
|
123
|
+
setResourceState('errored');
|
|
124
|
+
setPendingP(undefined);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// ── Suspense context (lazy, avoid module-init order issues) ───────────────
|
|
128
|
+
let _SuspenseContext;
|
|
129
|
+
// ── Main effect ───────────────────────────────────────────────────────────
|
|
130
|
+
createEffect(() => {
|
|
131
|
+
// Lazily grab the suspense context the first time the effect runs,
|
|
132
|
+
// so it's looked up in the correct component Owner scope.
|
|
133
|
+
if (_SuspenseContext === undefined) {
|
|
134
|
+
_SuspenseContext = getSuspenseContext();
|
|
135
|
+
}
|
|
136
|
+
const key = sourceFn();
|
|
137
|
+
tick(); // track manual triggers
|
|
138
|
+
// Suspend fetch when source is falsy (mirrors createResource)
|
|
139
|
+
if (key === false || key === null || key === undefined) {
|
|
140
|
+
prevKey = UNSET;
|
|
141
|
+
batch(() => {
|
|
142
|
+
setResourceState('unresolved');
|
|
143
|
+
setPendingP(undefined);
|
|
144
|
+
setResourceError(undefined);
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const doRefetch = flagRefetch;
|
|
149
|
+
const doInvalidate = flagInvalidate;
|
|
150
|
+
flagRefetch = false;
|
|
151
|
+
flagInvalidate = false;
|
|
152
|
+
const ck = buildKey(key);
|
|
153
|
+
// Clear cache on explicit invalidate
|
|
154
|
+
if (doInvalidate)
|
|
155
|
+
ttlCache.delete(ck);
|
|
156
|
+
const keyChanged = prevKey === UNSET || key !== prevKey;
|
|
157
|
+
prevKey = key;
|
|
158
|
+
let cancelled = false;
|
|
159
|
+
onCleanup(() => { cancelled = true; });
|
|
160
|
+
const cached = ttlCache.get(ck);
|
|
161
|
+
// ── Cache HIT (fresh) ─────────────────────────────────────────────────
|
|
162
|
+
if (cached && isFresh(cached) && !doRefetch && !doInvalidate) {
|
|
163
|
+
// Serve synchronously — no loading state, no fetch.
|
|
164
|
+
const cur = untrack(resourceState);
|
|
165
|
+
if (cur !== 'ready' || untrack(value) !== cached.value) {
|
|
166
|
+
batch(() => {
|
|
167
|
+
setValue(() => cached.value);
|
|
168
|
+
setResourceState('ready');
|
|
169
|
+
setIsStale(false);
|
|
170
|
+
setResourceError(undefined);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// ── Cache HIT (stale) + staleWhileRevalidate ──────────────────────────
|
|
176
|
+
if (cached && staleWhileRevalidate && !doInvalidate) {
|
|
177
|
+
// Show stale value immediately, background-fetch new data.
|
|
178
|
+
batch(() => {
|
|
179
|
+
setValue(() => cached.value);
|
|
180
|
+
setResourceState('ready');
|
|
181
|
+
setIsStale(true);
|
|
182
|
+
setResourceError(undefined);
|
|
183
|
+
setPendingP(undefined);
|
|
184
|
+
});
|
|
185
|
+
doFetch(key, ck, true /* background */, () => cancelled);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// ── No cache / invalidated / manual-refetch / SWR=false ──────────────
|
|
189
|
+
// Show loading state (keeps current value visible during 'refreshing').
|
|
190
|
+
const cur = untrack(resourceState);
|
|
191
|
+
const isReload = cur === 'ready' || cur === 'refreshing';
|
|
192
|
+
batch(() => {
|
|
193
|
+
setResourceState(isReload ? 'refreshing' : 'pending');
|
|
194
|
+
setResourceError(undefined);
|
|
195
|
+
setIsStale(false);
|
|
196
|
+
});
|
|
197
|
+
doFetch(key, ck, false /* foreground */, () => cancelled);
|
|
198
|
+
});
|
|
199
|
+
// ── Resource accessor ─────────────────────────────────────────────────────
|
|
200
|
+
// During 'pending': throw the pending promise → Suspense shows skeleton.
|
|
201
|
+
// During 'refreshing': return stale value (no Suspense regression).
|
|
202
|
+
// During 'ready'/'errored': return value or throw error.
|
|
203
|
+
const resource = (() => {
|
|
204
|
+
const e = resourceError();
|
|
205
|
+
if (e)
|
|
206
|
+
throw e;
|
|
207
|
+
const s = resourceState();
|
|
208
|
+
if (s === 'pending') {
|
|
209
|
+
const p = pendingP();
|
|
210
|
+
if (p)
|
|
211
|
+
throw p;
|
|
212
|
+
}
|
|
213
|
+
return value();
|
|
214
|
+
});
|
|
215
|
+
Object.defineProperty(resource, $RESOURCE, { value: true, enumerable: true });
|
|
216
|
+
Object.defineProperty(resource, $SIGNAL, { value: true, enumerable: true });
|
|
217
|
+
Object.defineProperties(resource, {
|
|
218
|
+
state: { get: resourceState },
|
|
219
|
+
loading: { get: () => { const s = resourceState(); return s === 'pending' || s === 'refreshing'; } },
|
|
220
|
+
error: { get: resourceError },
|
|
221
|
+
latest: { get: value },
|
|
222
|
+
stale: { get: isStale },
|
|
223
|
+
});
|
|
224
|
+
// ── Actions ───────────────────────────────────────────────────────────────
|
|
225
|
+
const refetch = () => {
|
|
226
|
+
flagRefetch = true;
|
|
227
|
+
setTick(v => v + 1);
|
|
228
|
+
};
|
|
229
|
+
const invalidate = () => {
|
|
230
|
+
const key = untrack(sourceFn);
|
|
231
|
+
if (key !== null && key !== undefined && key !== false) {
|
|
232
|
+
ttlCache.delete(buildKey(key));
|
|
233
|
+
}
|
|
234
|
+
flagInvalidate = true;
|
|
235
|
+
setTick(v => v + 1);
|
|
236
|
+
};
|
|
237
|
+
return [resource, { mutate: setValue, refetch, invalidate }];
|
|
238
|
+
}
|
|
239
|
+
// ── Cache utilities ────────────────────────────────────────────────────────────
|
|
240
|
+
/**
|
|
241
|
+
* Clear all TTL cache entries for a given namespace (name).
|
|
242
|
+
* Useful to invalidate a whole category of data at once.
|
|
243
|
+
*/
|
|
244
|
+
export function clearCachedResourceNamespace(name) {
|
|
245
|
+
const prefix = `${name}:`;
|
|
246
|
+
for (const key of ttlCache.keys()) {
|
|
247
|
+
if (key.startsWith(prefix))
|
|
248
|
+
ttlCache.delete(key);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Clear the entire TTL cache. Useful on logout / workspace switch.
|
|
253
|
+
*/
|
|
254
|
+
export function clearAllCachedResources() {
|
|
255
|
+
ttlCache.clear();
|
|
256
|
+
inflight.clear();
|
|
257
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject as je}from"@fluixi/utils/object";import{isFunction as xe}from"@fluixi/utils/functions";var G=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(xe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(je(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(xe(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends G{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},le=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends G{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new le(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};import{isPromise as Ne}from"@fluixi/utils";var $e=Symbol.for("signal");function Se(e){return typeof e=="function"&&e[$e]===!0}var We="__fluixi_signal_next_state__",ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[We]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ze,onSuspend:null,onError:null};var ge=0,Oe=1,J=2,ce=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends ce{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Oe&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=ge}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Re(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===ge;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Oe);Re(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Re(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ce(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function _e(){return h.owner}function Ae(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function Ee(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function He(e){return!!e&&typeof e.then=="function"}Ee(()=>{});var Ke=Symbol.for("signal"),Ye=Symbol.for("memo");function Q(e,t,n){let o=t,r=_e(),s=new X(()=>Ae(r,()=>{try{return o=e(o)}catch(f){if(He(f))return Ce(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ke,{value:!0,enumerable:!0}),Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Se(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function Fe(e){let t=Q(e);return Q(()=>Z(t()))}var ke=null;function fe(e){ke&&ke(e)}var Je=Symbol.for("signal");var De=Symbol("fluixi-proxy"),Xe=Symbol.for("signal-node"),V=0,pe=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,Qe=!1,de=!1,N=0,Ze=1e6,O=new WeakMap,ee=null;var et=new Map,tt=0;function nt(){return`node_${++tt}_${Date.now()}`}function rt(e){!1}function ot(e,t,n){let o={id:nt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return rt(o),o}function st(e,t){return e===t}function Ie(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function it(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)ve(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function qe(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&De in n&&delete n[De];let o=ot("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||st;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=pe,Qe&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===V||m===pe?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&qe(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(R),x=[],S=new Set;qe(P,F);for(let l of x)it(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return he(()=>{let j=a();b?b=!1:d.next(j)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:o,enumerable:!1}),r}function he(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ue(o,t),()=>U(o)}function Ue(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>Ze)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{v=n,c=o}}function ve(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===re||e.state===pe||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Me(e):Ue(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&ve(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ut()}}function ut(){if(!de){de=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)ve(e[t])}}finally{de=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Le(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function at(e){let t=Symbol("context"),n=lt(t);return{id:t,Provider:n,defaultValue:e}}function lt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return ct(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),Fe(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function ct(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Me(o),()=>U(o)}function Me(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Be(){return w||(w=at())}var E=new Map,A=new Map,ft=0,dt=Symbol.for("signal"),pt=Symbol.for("resource");function en(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${ft++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ge,Te]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function ye(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){fe(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(p)})}function be(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function me(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;he(()=>{z===void 0&&(z=Be());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Le(()=>{p=!0});let q=E.get(g);if(q&&j(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),ye(u,g,!0,()=>p);return}let we=L(x),Ve=we==="ready"||we==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),ye(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,pt,{value:!0,enumerable:!0}),Object.defineProperty(H,dt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,Te(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,Te(T=>T+1)}}]}function tn(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function nn(){E.clear(),A.clear()}export{nn as clearAllCachedResources,tn as clearCachedResourceNamespace,en as createCachedResource};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of k(t))!O.call(e,s)&&s!==r&&h(e,s,{get:()=>t[s],enumerable:!(o=g(t,s))||o.enumerable});return e};var C=e=>q(h({},"__esModule",{value:!0}),e);var G={};A(G,{readChildren:()=>V});module.exports=C(G);var E="__fluixi_signal_next_state__",D=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var v=0,y=1,l=2,w=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let t=n.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var f=class extends w{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=l;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(n.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===y&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=v}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked;n.consumer=this,n.untracked=!1;let s,u=!1,i;try{s=this._fn()}catch(c){u=!0,i=c,s=this._value}finally{n.consumer=r,n.untracked=o}let a=!this._initialized||this._threw!==u||(u?i!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=i,this._value=s,a){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);T(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===v;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(y);T(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function T(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function m(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function b(){return n.owner}function x(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function S(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function P(e){return!!e&&typeof e.then=="function"}S(()=>{});var R=Symbol.for("signal"),N=Symbol.for("memo");function d(e,t,r){let o=t,s=b(),u=new f(()=>x(s,()=>{try{return o=e(o)}catch(a){if(P(a))return m(a),o;throw a}}),{equals:r?.equals}),i=(()=>u.get());return Object.defineProperty(i,R,{value:!0,enumerable:!0}),Object.defineProperty(i,N,{value:!0,enumerable:!0}),i}var M=Symbol.for("signal");function _(e){return typeof e=="function"&&e[M]===!0}function p(e){if(typeof e=="function"&&!e.length){let t=e();return _(t)?t:p(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let o=p(e[r]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function V(e){let t=d(e);return d(()=>p(t()))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/children.ts"],"names":[],"mappings":"AAyBA,wBAAgB,YAAY,CAAC,EAAE,EAAE,GAAG,uCAKnC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* readChildren — resolve a children thunk into a reactive accessor: unwrap nested
|
|
3
|
+
* thunks, flatten arrays, and stop at signals/memos so they stay reactive. Built on
|
|
4
|
+
* the TC39 memo (compat), so the resolution tracks TC39 signals correctly.
|
|
5
|
+
*/
|
|
6
|
+
import { createMemo } from './compat.js';
|
|
7
|
+
import { isSignal, __DEV__ } from './detect.js';
|
|
8
|
+
function resolveChildrenValue(children) {
|
|
9
|
+
if (typeof children === 'function' && !children.length) {
|
|
10
|
+
const result = children();
|
|
11
|
+
if (isSignal(result))
|
|
12
|
+
return result;
|
|
13
|
+
return resolveChildrenValue(result);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(children)) {
|
|
16
|
+
const results = [];
|
|
17
|
+
for (let i = 0; i < children.length; i++) {
|
|
18
|
+
const result = resolveChildrenValue(children[i]);
|
|
19
|
+
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
|
|
20
|
+
}
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
return children;
|
|
24
|
+
}
|
|
25
|
+
export function readChildren(fn) {
|
|
26
|
+
const children = createMemo(fn);
|
|
27
|
+
return __DEV__
|
|
28
|
+
? createMemo(() => resolveChildrenValue(children()), undefined, { name: 'children' })
|
|
29
|
+
: createMemo(() => resolveChildrenValue(children()));
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _="__fluixi_signal_next_state__",g=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[_]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:g,onSuspend:null,onError:null};var w=0,v=1,l=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var f=class extends h{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=l;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===v&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=w}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,u=!1,i;try{s=this._fn()}catch(c){u=!0,i=c,s=this._value}finally{r.consumer=n,r.untracked=o}let a=!this._initialized||this._threw!==u||(u?i!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=i,this._value=s,a){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);y(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===w;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(v);y(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function y(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function T(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function m(){return r.owner}function b(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function x(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function k(e){return!!e&&typeof e.then=="function"}x(()=>{});var O=Symbol.for("signal"),A=Symbol.for("memo");function d(e,t,n){let o=t,s=m(),u=new f(()=>b(s,()=>{try{return o=e(o)}catch(a){if(k(a))return T(a),o;throw a}}),{equals:n?.equals}),i=(()=>u.get());return Object.defineProperty(i,O,{value:!0,enumerable:!0}),Object.defineProperty(i,A,{value:!0,enumerable:!0}),i}var q=Symbol.for("signal");function S(e){return typeof e=="function"&&e[q]===!0}function p(e){if(typeof e=="function"&&!e.length){let t=e();return S(t)?t:p(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=p(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function Y(e){let t=d(e);return d(()=>p(t()))}export{Y as readChildren};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!G.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(o=W(t,s))||o.enumerable});return e};var F=e=>V(b({},"__esModule",{value:!0}),e);var se={};j(se,{batch:()=>ee,createComputed:()=>X,createEffect:()=>Q,createMemo:()=>J,createRenderEffect:()=>Z,createRoot:()=>A,createSignal:()=>B,flush:()=>re,flushSync:()=>d,getOwner:()=>y,on:()=>oe,onCleanup:()=>D,runWithOwner:()=>h,setOwner:()=>P,startTransition:()=>M,untrack:()=>te,useTransition:()=>ne});module.exports=F(se);var H="__fluixi_signal_next_state__",K=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[H]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:K,onSuspend:null,onError:null};var k=0,O=1,f=2,p=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))}},w=class extends p{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(f);x(this)}}peek(){return this._value}},c=class extends p{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=f;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===O&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===f)break}(this.state===f||!this._initialized)&&this.recompute(),this.state=k}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{r.consumer=n,r.untracked=o}let a=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(f);x(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===k;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(O);x(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function x(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var v=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 S(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function q(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function C(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function y(){return r.owner}function P(e){let t=r.owner;return r.owner=e,t}function h(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function D(e){r.owner&&(r.owner.cleanups??=[]).push(e)}function T(e){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)T(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}}function A(e){let t=q(r.owner);r.owner&&(r.owner.owned??=[]).push(t);let n=r.owner;r.owner=t;try{return e(()=>T(t))}finally{r.owner=n}}function E(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function L(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(d)))}function d(){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 R(){r.batchDepth===0&&d()}function g(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&d()}}var _=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=q(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{T(this.owner),h(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new v(()=>L(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),T(this.owner))}};function m(e){let t=new _(e);return()=>t.dispose()}function Y(e){return!!e&&typeof e.then=="function"}E(()=>{});var N=Symbol.for("signal"),$=Symbol.for("memo"),U=Symbol.for("signal-node");function B(e,t){let n=new w(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let u=typeof i=="function"?i(n.peek()):i;return n.set(u),R(),u});return Object.defineProperty(o,N,{value:!0,enumerable:!0}),Object.defineProperty(o,U,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function J(e,t,n){let o=t,s=y(),i=new c(()=>h(s,()=>{try{return o=e(o)}catch(a){if(Y(a))return C(a),o;throw a}}),{equals:n?.equals}),u=(()=>i.get());return Object.defineProperty(u,N,{value:!0,enumerable:!0}),Object.defineProperty(u,$,{value:!0,enumerable:!0}),u}function Q(e,t){let n=t;return m(()=>{n=e(n)})}function X(e,t){let n=t;m(()=>{n=e(n)})}function Z(e,t){let n=t;return m(()=>{n=e(n)})}function ee(e){return g(e)}function te(e){return S(e)}function M(e){return g(e),Promise.resolve()}function ne(){return[()=>!1,M]}function re(){return d(),Promise.resolve()}function oe(e,t,n){let o=Array.isArray(e),s,i=n?.defer??!1;return u=>{let a=o?e.map(I=>I()):e();if(i){i=!1,s=a;return}let l=S(()=>t(a,s,u));return s=a,l}}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { flushSync } from './runtime.js';
|
|
2
|
+
export { createRoot, onCleanup, getOwner, setOwner, runWithOwner } from './runtime.js';
|
|
3
|
+
export type Accessor<T> = () => T;
|
|
4
|
+
export type Setter<T> = (value: T | ((prev: T) => T)) => T;
|
|
5
|
+
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
6
|
+
export interface SignalOptions<T> {
|
|
7
|
+
equals?: ((a: T, b: T) => boolean) | false;
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Legacy passthrough flags (ignored by the TC39 core); kept for option compatibility. */
|
|
10
|
+
internal?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface MemoOptions<T> extends SignalOptions<T> {
|
|
13
|
+
initial?: T;
|
|
14
|
+
}
|
|
15
|
+
/** createSignal — a writable cell, returned as the legacy `[get, set]` tuple. */
|
|
16
|
+
export declare function createSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
|
|
17
|
+
/** createMemo — a lazy, cached derived value (legacy accessor). */
|
|
18
|
+
export declare function createMemo<T>(fn: (prev?: T) => T, value?: T, options?: SignalOptions<T>): Accessor<T>;
|
|
19
|
+
/**
|
|
20
|
+
* createEffect — a re-running side effect. The fn receives the previous return
|
|
21
|
+
* value and may return a new one (legacy signature) or a cleanup function.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createEffect<T>(fn: (prev?: T) => T | (() => void), value?: T): () => void;
|
|
24
|
+
/**
|
|
25
|
+
* createComputed — an EAGER, owner-managed reactive computation (returns void).
|
|
26
|
+
* Unlike a lazy memo it runs immediately and re-runs eagerly when a dep changes;
|
|
27
|
+
* used for derivations with side effects (e.g. store internals). On L1 that is an
|
|
28
|
+
* eager effect whose dispose is owned by the current scope.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createComputed<T>(fn: (prev?: T) => T, value?: T): void;
|
|
31
|
+
/**
|
|
32
|
+
* createRenderEffect — an effect that runs in the render phase. For the reactive
|
|
33
|
+
* core this is an eager effect (the render-vs-commit timing distinction is a DOM-
|
|
34
|
+
* layer concern); returns a dispose like createEffect.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createRenderEffect<T>(fn: (prev?: T) => T | (() => void), value?: T): () => void;
|
|
37
|
+
/** batch — coalesce writes so dependent effects flush once. */
|
|
38
|
+
export declare function batch<T>(fn: () => T): T;
|
|
39
|
+
/** untrack — read without subscribing. */
|
|
40
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
41
|
+
/**
|
|
42
|
+
* startTransition — run `fn`'s updates as one batch. (Minimal port: the concurrent
|
|
43
|
+
* time-slicing/deferral of the legacy implementation is a later refinement; the
|
|
44
|
+
* batched-commit semantics that callers rely on are preserved.)
|
|
45
|
+
*/
|
|
46
|
+
export declare function startTransition(fn: () => void): Promise<void>;
|
|
47
|
+
/** useTransition — `[isPending, startTransition]`. isPending is synchronous here (no deferral). */
|
|
48
|
+
export declare function useTransition(): [() => boolean, (fn: () => void) => Promise<void>];
|
|
49
|
+
/** Force any pending effects to run now. */
|
|
50
|
+
export { flushSync };
|
|
51
|
+
/**
|
|
52
|
+
* flush — drain pending effects, returning a Promise (legacy `flush()` is async; many
|
|
53
|
+
* callers do `flush().then(...)`). Effects already flush synchronously on each write via
|
|
54
|
+
* afterWrite, so this just settles any remainder and resolves.
|
|
55
|
+
*/
|
|
56
|
+
export declare function flush(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* on(deps, fn, { defer }) — an explicit-dependency helper. Reads `deps` (tracked),
|
|
59
|
+
* then runs `fn(value, prevValue, prevResult)` untracked. `defer` skips the first run.
|
|
60
|
+
*/
|
|
61
|
+
export declare function on<D, R>(deps: Accessor<D> | Array<Accessor<unknown>>, fn: (value: D, prev: D | undefined, prevResult: R | undefined) => R, options?: {
|
|
62
|
+
defer?: boolean;
|
|
63
|
+
}): (prev?: R) => R | undefined;
|
|
64
|
+
//# sourceMappingURL=compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/compat.ts"],"names":[],"mappings":"AAgBA,OAAO,EAKL,SAAS,EAIV,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAgBvF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAClC,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3D,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,CAAC;CACb;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAwB/E;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,CAAC,EAC1B,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EACnB,KAAK,CAAC,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,QAAQ,CAAC,CAAC,CAAC,CAgCb;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,EAClC,KAAK,CAAC,EAAE,CAAC,GACR,MAAM,IAAI,CASZ;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAKtE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,EAClC,KAAK,CAAC,EAAE,CAAC,GACR,MAAM,IAAI,CAKZ;AAED,+DAA+D;AAC/D,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEvC;AAED,0CAA0C;AAC1C,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D;AAED,mGAAmG;AACnG,wBAAgB,aAAa,IAAI,CAAC,MAAM,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAElF;AAED,4CAA4C;AAC5C,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;GAIG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGrC;AAED;;;GAGG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,EACrB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAC5C,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,EACnE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5B,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAiB7B"}
|